@antv/g6 5.0.40 → 5.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/g6.min.js CHANGED
@@ -15,7 +15,7 @@
15
15
  * @author AntVis
16
16
  * @docs https://g.antv.antgroup.com/
17
17
  */
18
- var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).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 y(e,t),u(e)}(Ts),pu=0,gu=function(){return u((function t(e,n){var r;s(this,t),this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=e,e.animation=this,this.timeline=n,this.id="".concat(pu++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(r=this.effect)||void 0===r?void 0:r.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}),[{key:"pending",get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending}},{key:"playState",get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"}},{key:"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}},{key:"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}},{key:"currentTime",get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){if(t=Number(t),!isNaN(t)){var e;if(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))}}},{key:"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()}}},{key:"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()}}},{key:"_isFinished",get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)}},{key:"totalDuration",get:function(){return this._totalDuration}},{key:"_needsTick",get:function(){return this.pending||"running"===this.playState||!this._finishedFlag}},{key:"updatePromises",value: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}},{key:"play",value: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()}},{key:"pause",value: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()}},{key:"finish",value: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())}},{key:"cancel",value: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 fu(null,this,this.currentTime,null);setTimeout((function(){t.oncancel(e)}))}}},{key:"reverse",value:function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()}},{key:"updatePlaybackRate",value:function(t){this.playbackRate=t}},{key:"targetAnimations",value:function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()}},{key:"markTarget",value:function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)}},{key:"unmarkTarget",value:function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)}},{key:"tick",value: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))}},{key:"rewind",value: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}}},{key:"persist",value:function(){throw new Error(Qr)}},{key:"addEventListener",value:function(t,e,n){throw new Error(Qr)}},{key:"removeEventListener",value:function(t,e,n){throw new Error(Qr)}},{key:"dispatchEvent",value:function(t){throw new Error(Qr)}},{key:"commitStyles",value:function(){throw new Error(Qr)}},{key:"ensureAlive",value:function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!(null===(t=this.effect)||void 0===t||!t.update(-1)):this._inEffect=!(null===(e=this.effect)||void 0===e||!e.update(this.currentTime));this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))}},{key:"tickCurrentTime",value:function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())}},{key:"fireEvents",value:function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new fu(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 fu(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}}}])}(),vu=.1,mu="function"==typeof Float32Array,yu=function(t,e){return 1-3*e+3*t},bu=function(t,e){return 3*e-6*t},xu=function(t){return 3*t},Eu=function(t,e,n){return((yu(e,n)*t+bu(e,n))*t+xu(e))*t},wu=function(t,e,n){return 3*yu(e,n)*t*t+2*bu(e,n)*t+xu(e)},ku=function(t,e,n,r){if(!(t>=0&&t<=1&&n>=0&&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=mu?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=Eu(o*vu,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=vu;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*vu,s=wu(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=wu(e,n,r);if(0===o)return e;e-=(Eu(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=Eu(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+vu,t,n)};return function(t){return 0===t||1===t?t:Eu(a(t),e,r)}},Mu=function(t){return Math.pow(t,2)},Su=function(t){return Math.pow(t,3)},Nu=function(t){return Math.pow(t,4)},Ou=function(t){return Math.pow(t,5)},Tu=function(t){return Math.pow(t,6)},Au=function(t){return 1-Math.cos(t*Math.PI/2)},Cu=function(t){return 1-Math.sqrt(1-t*t)},Pu=function(t){return t*t*(3*t-2)},Ru=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)},Du=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?1:n,i=e[1],o=void 0===i?.5:i,a=oe(Number(r),1,10),s=oe(Number(o),.1,2);return 0===t||1===t?t:-a*Math.pow(2,10*(t-1))*Math.sin((t-1-s/(2*Math.PI)*Math.asin(1/a))*(2*Math.PI)/s)},Lu=function(t){var e=arguments.length>2?arguments[2]:void 0,n=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),r=n[0],i=void 0===r?1:r,o=n[1],a=void 0===o?100:o,s=n[2],l=void 0===s?10:s,u=n[3],c=void 0===u?0:u;i=oe(i,.1,1e3),a=oe(a,.1,1e3),l=oe(l,.1,1e3),c=oe(c,.1,1e3);var h=Math.sqrt(a/i),d=l/(2*Math.sqrt(a*i)),f=d<1?h*Math.sqrt(1-d*d):0,p=d<1?(d*h-c)/f:-c+h,g=e?e*t/1e3:t;return g=d<1?Math.exp(-g*d*h)*(1*Math.cos(f*g)+p*Math.sin(f*g)):(1+p*g)*Math.exp(-g*h),0===t||1===t?t:1-g},_u=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?10:n;return("start"===e[1]?Math.ceil:Math.floor)(oe(t,0,1)*r)/r},Iu=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),n=e[0],r=e[1],i=e[2],o=e[3];return ku(n,r,i,o)(t)},ju=ku(.42,0,1,1),Bu=function(t){return function(e){return 1-t(1-e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],arguments.length>2?arguments[2]:void 0)}},Fu=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},zu=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Gu={steps:_u,"step-start":function(t){return _u(t,[1,"start"])},"step-end":function(t){return _u(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Iu,ease:function(t){return Iu(t,[.25,.1,.25,1])},in:ju,out:Bu(ju),"in-out":Fu(ju),"out-in":zu(ju),"in-quad":Mu,"out-quad":Bu(Mu),"in-out-quad":Fu(Mu),"out-in-quad":zu(Mu),"in-cubic":Su,"out-cubic":Bu(Su),"in-out-cubic":Fu(Su),"out-in-cubic":zu(Su),"in-quart":Nu,"out-quart":Bu(Nu),"in-out-quart":Fu(Nu),"out-in-quart":zu(Nu),"in-quint":Ou,"out-quint":Bu(Ou),"in-out-quint":Fu(Ou),"out-in-quint":zu(Ou),"in-expo":Tu,"out-expo":Bu(Tu),"in-out-expo":Fu(Tu),"out-in-expo":zu(Tu),"in-sine":Au,"out-sine":Bu(Au),"in-out-sine":Fu(Au),"out-in-sine":zu(Au),"in-circ":Cu,"out-circ":Bu(Cu),"in-out-circ":Fu(Cu),"out-in-circ":zu(Cu),"in-back":Pu,"out-back":Bu(Pu),"in-out-back":Fu(Pu),"out-in-back":zu(Pu),"in-bounce":Ru,"out-bounce":Bu(Ru),"in-out-bounce":Fu(Ru),"out-in-bounce":zu(Ru),"in-elastic":Du,"out-elastic":Bu(Du),"in-out-elastic":Fu(Du),"out-in-elastic":zu(Du),spring:Lu,"spring-in":Lu,"spring-out":Bu(Lu),"spring-in-out":Fu(Lu),"spring-out-in":zu(Lu)},Vu=function(t){return t};function Wu(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Hu="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",Yu=new RegExp("cubic-bezier\\(".concat(Hu,",").concat(Hu,",").concat(Hu,",").concat(Hu,"\\)")),Uu=/steps\(\s*(\d+)\s*\)/,$u=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function qu(t){var e=Yu.exec(t);if(e)return ku.apply(void 0,d(e.slice(1).map(Number)));var n=Uu.exec(t);if(n)return Wu(Number(n[1]),0);var r=$u.exec(t);return r?Wu(Number(r[1]),{start:1,middle:.5,end:0}[r[2]]):Gu[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)]||Gu.linear}function Xu(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))}function Ku(t,e,n){var r=function(t,e,n){if(null===e)return 0;var r=n.endTime;return e<Math.min(n.delay,r)?1:e>=Math.min(n.delay+t+n.endDelay,r)?2:3}(t,e,n),i=function(t,e,n,r,i){switch(r){case 1:return"backwards"===e||"both"===e?0:null;case 3:return n-i;case 2:return"forwards"===e||"both"===e?t:null;case 0: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?1!==e&&(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||2!==n||0===r||0===i&&0!==o||(a=1),a}(a,n.iterationStart,r,n.iterations,i,o),l=function(t,e,n,r){return 2===t&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,a),u=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,l,s);return n.currentIteration=l,n.progress=u,n.easingFunction(u)}function Zu(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Qu(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:qu(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,l=i[a].computedOffset,u=i[s].computedOffset,c=l,h=u;0===o&&(c=-1/0,0===u&&(s=a)),o===i.length-2&&(h=1/0,1===l&&(a=s)),n.push({applyFrom:c,applyTo:h,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:tc(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:r/i;t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)Qu(n)&&t.setAttribute(n,null)}}function Qu(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Ju=function(t,e,n){return function(r){var i=ec(t,e,r);return ae(i)?i:n(i)}};function tc(t,e,n,r){var i=ga[t];if(i&&i.syntax&&i.int){var o=bl.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=o.parser,s=a?a(e,r):e,l=a?a(n,r):n,u=o.mixer(s,l,r);if(u){var c=Ju.apply(void 0,d(u));return function(t){return 0===t?e:1===t?n:c(t)}}}}return Ju(!1,!0,(function(t){return t?n:e}))}function ec(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(ec(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments ".concat(t,":").concat(e))}var nc=function(){return u((function t(){s(this,t),this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Vu,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}),[{key:"easing",get:function(){return this._easing},set:function(t){this.easingFunction=qu(t),this._easing=t}}])}();function rc(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&&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(Ut(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(!Ut(s)&&!Ut(o)){for(var l=1;l<a-i;l++)n[i+l].computedOffset=o+(Number(s)-o)*l/(a-i);i=a,o=Number(s)}}}(),n}var ic="backwards|forwards|both|none".split("|"),oc="reverse|alternate|alternate-reverse".split("|");function ac(t,e){var n;return function(t){var e=new nc;return"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(n){if(void 0!==t[n]&&null!==t[n]&&"auto"!==t[n]){if(("number"==typeof e[n]||"duration"===n)&&("number"!=typeof t[n]||isNaN(t[n])))return;if("fill"===n&&-1===ic.indexOf(t[n]))return;if("direction"===n&&-1===oc.indexOf(t[n]))return;e[n]=t[n]}})):e.duration=t,e}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!==(n=t)&&void 0!==n?n:{duration:"auto"}))}var sc=function(){return u((function t(e,n,r){var i=this;s(this,t),this.composite="replace",this.iterationComposite="replace",this.target=e,this.timing=ac(r),this.timing.effect=this,this.timing.activeDuration=Xu(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=rc(n,this.timing),this.interpolations=Zu(this.normalizedKeyframes,this.timing,this.target);var o=bl.globalThis.Proxy;this.computedTiming=o?new o(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?i.animation&&i.animation.currentTime||null:"currentIteration"===e?i.animation&&"running"===i.animation.playState?t.currentIteration||0:null:"progress"===e?i.animation&&"running"===i.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}),[{key:"applyInterpolations",value:function(){this.interpolations(this.target,Number(this.timeFraction))}},{key:"update",value:function(t){return null!==t&&(this.timeFraction=Ku(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)}},{key:"getKeyframes",value:function(){return this.normalizedKeyframes}},{key:"setKeyframes",value:function(t){this.normalizedKeyframes=rc(t)}},{key:"getComputedTiming",value:function(){return this.computedTiming}},{key:"getTiming",value:function(){return this.timing}},{key:"updateTiming",value:function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))}}])}();function lc(t,e){return Number(t.id)-Number(e.id)}var uc=function(){return u((function t(e){var n=this;s(this,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){n.currentTime=t,n.discardAnimations(),0===n.animations.length?n.timelineTicking=!1:n.requestAnimationFrame(n.webAnimationsNextTick)},this.processRafCallbacks=function(t){var e=n.rafCallbacks;n.rafCallbacks=[],t<Number(n.currentTime)&&(t=Number(n.currentTime)),n.animations.sort(lc),n.animations=n.tick(t,!0,n.animations)[0],e.forEach((function(e){e[1](t)})),n.applyPendingEffects()},this.document=e}),[{key:"getAnimations",value:function(){return this.discardAnimations(),this.animations.slice()}},{key:"isTicking",value:function(){return this.inTick}},{key:"play",value:function(t,e,n){var r=new sc(t,e,n),i=new gu(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i}},{key:"applyDirtiedAnimation",value:function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(lc),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()}}},{key:"restart",value:function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame}},{key:"destroy",value:function(){this.document.defaultView.cancelAnimationFrame(this.frameId)}},{key:"applyPendingEffects",value:function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]}},{key:"updateAnimationsPromises",value:function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))}},{key:"discardAnimations",value:function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))}},{key:"restartWebAnimationsNextTick",value:function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))}},{key:"rAF",value: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}},{key:"requestAnimationFrame",value:function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))}},{key:"tick",value:function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],l=[],u=[];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?l.push(n):u.push(n)})),(r=this.pendingEffects).push.apply(r,a),(i=this.pendingEffects).push.apply(i,s),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[l,u]}}])}();bl.EasingFunction=qu,bl.AnimationTimeline=uc;const cc={duration:500},hc={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var dc,fc,pc,gc,vc,mc,yc,bc,xc;!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"}(dc||(dc={})),function(t){t.DRAW="draw",t.COLLAPSE="collapse",t.EXPAND="expand",t.TRANSFORM="transform"}(fc||(fc={})),t.CanvasEvent=void 0,function(t){t.CLICK="canvas:click",t.DBLCLICK="canvas:dblclick",t.POINTER_OVER="canvas:pointerover",t.POINTER_LEAVE="canvas:pointerleave",t.POINTER_ENTER="canvas:pointerenter",t.POINTER_MOVE="canvas:pointermove",t.POINTER_OUT="canvas:pointerout",t.POINTER_DOWN="canvas:pointerdown",t.POINTER_UP="canvas:pointerup",t.CONTEXT_MENU="canvas:contextmenu",t.DRAG_START="canvas:dragstart",t.DRAG="canvas:drag",t.DRAG_END="canvas:dragend",t.DRAG_ENTER="canvas:dragenter",t.DRAG_OVER="canvas:dragover",t.DRAG_LEAVE="canvas:dragleave",t.DROP="canvas:drop",t.WHEEL="canvas:wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.ComboEvent=void 0,(pc=t.ComboEvent||(t.ComboEvent={})).CLICK="combo:click",pc.DBLCLICK="combo:dblclick",pc.POINTER_OVER="combo:pointerover",pc.POINTER_LEAVE="combo:pointerleave",pc.POINTER_ENTER="combo:pointerenter",pc.POINTER_MOVE="combo:pointermove",pc.POINTER_OUT="combo:pointerout",pc.POINTER_DOWN="combo:pointerdown",pc.POINTER_UP="combo:pointerup",pc.CONTEXT_MENU="combo:contextmenu",pc.DRAG_START="combo:dragstart",pc.DRAG="combo:drag",pc.DRAG_END="combo:dragend",pc.DRAG_ENTER="combo:dragenter",pc.DRAG_OVER="combo:dragover",pc.DRAG_LEAVE="combo:dragleave",pc.DROP="combo:drop",t.CommonEvent=void 0,(gc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",gc.DBLCLICK="dblclick",gc.POINTER_OVER="pointerover",gc.POINTER_LEAVE="pointerleave",gc.POINTER_ENTER="pointerenter",gc.POINTER_MOVE="pointermove",gc.POINTER_OUT="pointerout",gc.POINTER_DOWN="pointerdown",gc.POINTER_UP="pointerup",gc.CONTEXT_MENU="contextmenu",gc.DRAG_START="dragstart",gc.DRAG="drag",gc.DRAG_END="dragend",gc.DRAG_ENTER="dragenter",gc.DRAG_OVER="dragover",gc.DRAG_LEAVE="dragleave",gc.DROP="drop",gc.KEY_DOWN="keydown",gc.KEY_UP="keyup",gc.WHEEL="wheel",t.ContainerEvent=void 0,(vc=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",vc.KEY_UP="keyup",t.EdgeEvent=void 0,(mc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="edge:click",mc.DBLCLICK="edge:dblclick",mc.POINTER_OVER="edge:pointerover",mc.POINTER_LEAVE="edge:pointerleave",mc.POINTER_ENTER="edge:pointerenter",mc.POINTER_MOVE="edge:pointermove",mc.POINTER_OUT="edge:pointerout",mc.POINTER_DOWN="edge:pointerdown",mc.POINTER_UP="edge:pointerup",mc.CONTEXT_MENU="edge:contextmenu",mc.DRAG_ENTER="edge:dragenter",mc.DRAG_OVER="edge:dragover",mc.DRAG_LEAVE="edge:dragleave",mc.DROP="edge:drop",t.GraphEvent=void 0,(yc=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",yc.AFTER_CANVAS_INIT="aftercanvasinit",yc.BEFORE_SIZE_CHANGE="beforesizechange",yc.AFTER_SIZE_CHANGE="aftersizechange",yc.BEFORE_ELEMENT_CREATE="beforeelementcreate",yc.AFTER_ELEMENT_CREATE="afterelementcreate",yc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",yc.AFTER_ELEMENT_UPDATE="afterelementupdate",yc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",yc.AFTER_ELEMENT_DESTROY="afterelementdestroy",yc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",yc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",yc.BEFORE_DRAW="beforedraw",yc.AFTER_DRAW="afterdraw",yc.BEFORE_RENDER="beforerender",yc.AFTER_RENDER="afterrender",yc.BEFORE_ANIMATE="beforeanimate",yc.AFTER_ANIMATE="afteranimate",yc.BEFORE_LAYOUT="beforelayout",yc.AFTER_LAYOUT="afterlayout",yc.BEFORE_STAGE_LAYOUT="beforestagelayout",yc.AFTER_STAGE_LAYOUT="afterstagelayout",yc.BEFORE_TRANSFORM="beforetransform",yc.AFTER_TRANSFORM="aftertransform",yc.BATCH_START="batchstart",yc.BATCH_END="batchend",yc.BEFORE_DESTROY="beforedestroy",yc.AFTER_DESTROY="afterdestroy",yc.BEFORE_RENDERER_CHANGE="beforerendererchange",yc.AFTER_RENDERER_CHANGE="afterrendererchange",t.HistoryEvent=void 0,(bc=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",bc.REDO="redo",bc.CANCEL="cancel",bc.ADD="add",bc.CLEAR="clear",bc.CHANGE="change",t.NodeEvent=void 0,(xc=t.NodeEvent||(t.NodeEvent={})).CLICK="node:click",xc.DBLCLICK="node:dblclick",xc.POINTER_OVER="node:pointerover",xc.POINTER_LEAVE="node:pointerleave",xc.POINTER_ENTER="node:pointerenter",xc.POINTER_MOVE="node:pointermove",xc.POINTER_OUT="node:pointerout",xc.POINTER_DOWN="node:pointerdown",xc.POINTER_UP="node:pointerup",xc.CONTEXT_MENU="node:contextmenu",xc.DRAG_START="node:dragstart",xc.DRAG="node:drag",xc.DRAG_END="node:dragend",xc.DRAG_ENTER="node:dragenter",xc.DRAG_OVER="node:dragover",xc.DRAG_LEAVE="node:dragleave",xc.DROP="node:drop";const Ec="combo",wc="tree";var kc;t.ExtensionCategory=void 0,(kc=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",kc.EDGE="edge",kc.COMBO="combo",kc.THEME="theme",kc.PALETTE="palette",kc.LAYOUT="layout",kc.BEHAVIOR="behavior",kc.PLUGIN="plugin",kc.ANIMATION="animation",kc.TRANSFORM="transform",kc.SHAPE="shape";const Mc={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{},shape:{}};function Sc(t,e){var n;const r=null===(n=Mc[t])||void 0===n?void 0:n[e];if(r)return r}const Nc="5.0.40";function Oc(t){return`[G6 v${Nc}] ${t}`}const Tc=t=>{console.warn(Oc(t))};function Ac(e){const{theme:n}=e;if(!n)return{};const r=Sc(t.ExtensionCategory.THEME,n);return r||(Tc(`The theme of ${n} is not registered.`),{})}function Cc(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=>{var r;return null===(r=t[e])||void 0===r?void 0:r.call(t,...n)}))},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach((t=>{t[e]=n})),Reflect.set(t,e,n))})}function Pc(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)),{});Object.entries(e).forEach((([n,r])=>{(r.length!==t.length||r.some((t=>Ut(t)))||r.every((t=>!["sourceNode","targetNode","childrenNode"].includes(n)&&Ne(t,r[0]))))&&delete e[n]}));const n=Object.entries(e).reduce(((t,[e,n])=>(n.forEach(((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}})),t)),[]);return 0!==t.length&&0===n.length&&n.push({_:0},{_:0}),n}function Rc(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;case"visibility":return"visible";case"collapsed":return!1;case"states":return[];default:return}}function Dc(t,e){const{animation:n}=t;if(!1===n||!1===e)return!1;const r=Object.assign({},cc);return qt(n)&&Object.assign(r,n),qt(e)&&Object.assign(r,e),r}function Lc(e,n,r,i){var o,a;const{animation:s}=e;if(!1===s||!1===i)return[];const l=null===(o=null==e?void 0:e[n])||void 0===o?void 0:o.animation;if(!1===l)return[];const u=null==l?void 0:l[r];if(!1===u)return[];const c=null===(a=Ac(e)[n])||void 0===a?void 0:a.animation,h=(e=[])=>function(e){if("string"==typeof e){return Sc(t.ExtensionCategory.ANIMATION,e)||(Tc(`The animation of ${e} is not registered.`),[])}return e}(e).map((t=>Object.assign(Object.assign(Object.assign(Object.assign({},hc),qt(s)&&s),t),qt(i)&&i)));if(u)return h(u);if(!c)return[];const d=c[r];return!1===d?[]:h(d)}function _c(t,e,n,r=[]){if(!r&&0===t&&0===e&&0===n)return null;if(Array.isArray(r)){let i=-1;const o=[];for(let a=0;a<r.length;a++){const s=r[a];if("translate"===s[0]){if(s[1]===t&&s[2]===e)return null;i=a,o.push(["translate",t,e])}else if("translate3d"===s[0]){if(s[1]===t&&s[2]===e&&s[3]===n)return null;i=a,o.push(["translate3d",t,e,null!=n?n:0])}else o.push(s)}return-1===i&&o.splice(0,0,ae(n)?["translate3d",t,e,null!=n?n:0]:["translate",t,e]),0===o.length?null:o}const i=r?r.replace(/translate(3d)?\([^)]*\)/g,""):"";return 0===n?`translate(${t}, ${e})${i}`:`translate3d(${t}, ${e}, ${n})${i}`}const Ic=(t,e,n)=>{if(!n.length)return null;const[r,i]=e;let o;const a=n.map((e=>{var{fields:n,shape:a,states:s}=e,l=Fe(e,["fields","shape","states"]);const u=(e=>{var n;if(e){const o=t.getShape(e);if(!o)return null;const a=`get${de(e)}Style`,s=(null===(n=null==t?void 0:t[a])||void 0===n?void 0:n.bind(t))||(t=>t);return{shape:o,fromStyle:(null==s?void 0:s(r))||{},toStyle:(null==s?void 0:s(i))||{}}}return{shape:t,fromStyle:r,toStyle:i}})(a);if(!u)return null;const{shape:c,fromStyle:h,toStyle:d}=u,f=[{},{}];if(n.forEach((t=>{var e,n;Object.assign(f[0],{[t]:null!==(e=h[t])&&void 0!==e?e:Rc(t)}),Object.assign(f[1],{[t]:null!==(n=d[t])&&void 0!==n?n:Rc(t)})})),f.some((t=>Object.keys(t).some((t=>["x","y","z"].includes(t)))))){const{x:t=0,y:e=0,z:n,transform:r=""}=c.attributes||{};f.forEach((i=>{var o,a,s;i.transform=_c(null!==(o=i.x)&&void 0!==o?o:t,null!==(a=i.y)&&void 0!==a?a:e,null!==(s=i.z)&&void 0!==s?s:n,r)}))}const p=c.animate(Pc(f),l);return void 0===a&&(o=p),p})).filter(Boolean),s=o||(null==a?void 0:a[0]);return s?Cc(s,a.filter((t=>t!=t))):null},jc=[{fields:["x","y"]}],Bc=jc,Fc=[{fields:["sourceNode","targetNode"]}],zc=Fc,Gc=[{fields:["childrenNode","x","y"]}],Vc=Gc;function Wc(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function Hc(t,e,n){return t>=e&&t<=n}function Yc(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 Uc(t=0){const e=Yc(t);return e[0]+e[2]}function $c(t){return t.max[0]-t.min[0]}function qc(t){return t.max[1]-t.min[1]}function Xc(t){return[$c(t),qc(t)]}function Kc(t,e){const n=Wc(t)?Zc(t):t.getShape("key").getBounds();return e?Qc(n,e):n}function Zc(t){const[e,n,r=0]=t,i=new Ur;return i.setMinMax([e,n,r],[e,n,r]),i}function Qc(t,e){const[n,r,i,o]=Yc(e),[a,s,l]=t.min,[u,c,h]=t.max,d=new Ur;return d.setMinMax([a-o,s-n,l],[u+r,c+i,h]),d}function Jc(t){if(0===t.length)return new Ur;if(1===t.length)return t[0];const e=new Ur;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 th(t,e){return Hc(t[0],e.min[0],e.max[0])&&Hc(t[1],e.min[1],e.max[1])}function eh(t,e,n=!1){const{min:[r,i],max:[o,a]}=e,s=(t[1]===i||t[1]===a)&&(n||Hc(t[0],r,o)),l=(t[0]===r||t[0]===o)&&(n||Hc(t[1],i,a));return s||l}function nh(t,e){const{center:n}=e;return t[0]===n[0]&&t[1]===n[1]}function rh(t,e){const[n,r]=t,[i,o]=e.min,[a,s]=e.max,l=n-i,u=a-n,c=r-o,h=s-r,d=Math.min(l,u,c,h);return d===l?"left":d===u?"right":d===c?"top":d===h?"bottom":"left"}function ih(t,e){const n=me(t);if(th(t,e)){switch(rh(t,e)){case"left":n[0]=e.min[0];break;case"right":n[0]=e.max[0];break;case"top":n[1]=e.min[1];break;case"bottom":n[1]=e.max[1]}}else{const[r,i]=t,[o,a]=e.min,[s,l]=e.max;n[0]=Hc(r,o,s)?r:r<o?o:s,n[1]=Hc(i,a,l)?i:i<a?a:l}return n}var oh=function(t,e){return t===e},ah=function(){function t(t,e){void 0===e&&(e=null),this.value=t,this.next=e}return t.prototype.toString=function(t){return t?t(this.value):"".concat(this.value)},t}(),sh=function(){function t(t){void 0===t&&(t=oh),this.head=null,this.tail=null,this.compare=t}return t.prototype.prepend=function(t){var e=new ah(t,this.head);return this.head=e,this.tail||(this.tail=e),this},t.prototype.append=function(t){var e=new ah(t);return this.head?(this.tail.next=e,this.tail=e,this):(this.head=e,this.tail=e,this)},t.prototype.delete=function(t){if(!this.head)return null;for(var e=null;this.head&&this.compare(this.head.value,t);)e=this.head,this.head=this.head.next;var n=this.head;if(null!==n)for(;n.next;)this.compare(n.next.value,t)?(e=n.next,n.next=n.next.next):n=n.next;return this.compare(this.tail.value,t)&&(this.tail=n),e},t.prototype.find=function(t){var e=t.value,n=void 0===e?void 0:e,r=t.callback,i=void 0===r?void 0:r;if(!this.head)return null;for(var o=this.head;o;){if(i&&i(o.value))return o;if(void 0!==n&&this.compare(o.value,n))return o;o=o.next}return null},t.prototype.deleteTail=function(){var t=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,t;for(var e=this.head;e.next;)e.next.next?e=e.next:e.next=null;return this.tail=e,t},t.prototype.deleteHead=function(){if(!this.head)return null;var t=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),t},t.prototype.fromArray=function(t){var e=this;return t.forEach((function(t){return e.append(t)})),this},t.prototype.toArray=function(){for(var t=[],e=this.head;e;)t.push(e),e=e.next;return t},t.prototype.reverse=function(){for(var t=this.head,e=null,n=null;t;)n=t.next,t.next=e,e=t,t=n;this.tail=this.head,this.head=e},t.prototype.toString=function(t){return void 0===t&&(t=void 0),this.toArray().map((function(e){return e.toString(t)})).toString()},t}(),lh=function(t,e,n){void 0===e&&(e=[]);var r=e.filter((function(e){return e.source===t||e.target===t}));if("target"===n){return r.filter((function(e){return e.source===t})).map((function(t){return t.target}))}if("source"===n){return r.filter((function(e){return e.target===t})).map((function(t){return t.source}))}return r.map((function(e){return e.source===t?e.target:e.source}))},uh={}.toString,ch=function(t,e){return uh.call(t)==="[object "+e+"]"},hh=function(t){return ch(t,"Function")},dh=function(t){return Array.isArray?Array.isArray(t):ch(t,"Array")};var fh,ph=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return function(t,e){var n,r;if(t)if(dh(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var a in t)if(t.hasOwnProperty(a)&&!1===e(t[a],a))break}(t,(function(n,r){hh(t)&&"prototype"===r||e.push(n)})),e};!function(t,e){if(!hh(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.apply(this,r),a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s};n.cache=new Map}((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return fh||(fh=document.createElement("canvas").getContext("2d")),fh.font=[o,a,i,n+"px",r].join(" "),fh.measureText(function(t){return ch(t,"String")}(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],ph(e)).join("")}));function gh(t,e,n,r){if(t===e)return[t];if(r[e])return r[e];for(var i=[],o=0,a=n[e];o<a.length;o++){var s=gh(t,a[o],n,r);if(!s)return;for(var l=0,u=s;l<u.length;l++){var c=u[l];dh(c)?i.push(We(We([],c,!0),[e],!1)):i.push([c,e])}}return r[e]=i,r[e]}var vh,mh=function(t,e,n,r,i){var o=function(t,e,n,r){var i=t.nodes,o=void 0===i?[]:i,a=t.edges,s=void 0===a?[]:a,l={},u={},c={};o.forEach((function(t,n){var r=t.id;u[r]=1/0,r===e&&(u[r]=0)}));for(var h=o.length,d=function(t){var e=function(t,e,n){for(var r,i=1/0,o=0;o<e.length;o++){var a=e[o].id;!n[a]&&t[a]<=i&&(i=t[a],r=e[o])}return r}(u,o,l),i=e.id;if(l[i]=!0,u[i]===1/0)return"continue";var a=[];a=n?function(t,e){return e.filter((function(e){return e.source===t}))}(i,s):function(t,e){return e.filter((function(e){return e.source===t||e.target===t}))}(i,s),a.forEach((function(t){var n=t.target,o=t.source,a=n===i?o:n,s=r&&t[r]?t[r]:1;u[a]>u[e.id]+s?(u[a]=u[e.id]+s,c[a]=[e.id]):u[a]===u[e.id]+s&&c[a].push(e.id)}))},f=0;f<h;f++)d();c[e]=[e];var p={};for(var g in u)u[g]!==1/0&&gh(e,g,c,p);var v={};for(var g in p)v[g]=p[g][0];return{length:u,path:v,allPath:p}}(t,e,r,i),a=o.length,s=o.path,l=o.allPath;return{length:a[n],path:s[n],allPath:l[n]}};!function(t){t.EuclideanDistance="euclideanDistance"}(vh||(vh={}));function yh(t){if(void 0!==t.id)return t.id;if(void 0!==t.source&&void 0!==t.target)return`${t.source}-${t.target}`;throw new Error(Oc("The datum does not have available id."))}function bh(t){return t.combo}function xh(t,e){const n={nodes:(t.nodes||[]).map(yh),edges:(t.edges||[]).map(yh),combos:(t.combos||[]).map(yh)};return e?Object.values(n).flat():n}!function(){function t(t){void 0===t&&(t=10),this.linkedList=new sh,this.maxStep=t}Object.defineProperty(t.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),t.prototype.isEmpty=function(){return!this.linkedList.head},t.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},t.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},t.prototype.push=function(t){this.linkedList.prepend(t),this.length>this.maxStep&&this.linkedList.deleteTail()},t.prototype.pop=function(){var t=this.linkedList.deleteHead();return t?t.value:null},t.prototype.toArray=function(){return this.linkedList.toArray().map((function(t){return t.value}))},t.prototype.clear=function(){for(;!this.isEmpty();)this.pop()}}();const Eh=(t,e,n)=>{var r;switch(n.type){case"degree":{const i=new Map;return null===(r=t.nodes)||void 0===r||r.forEach((t=>{const r=e(yh(t),n.direction).length;i.set(yh(t),r)})),i}case"betweenness":return kh(t,n.directed,n.weightPropertyName);case"closeness":return Mh(t,n.directed,n.weightPropertyName);case"eigenvector":return Nh(t,n.directed);case"pagerank":return Sh(t,n.epsilon,n.linkProb);default:return wh(t)}},wh=t=>{var e;const n=new Map;return null===(e=t.nodes)||void 0===e||e.forEach((t=>{n.set(yh(t),0)})),n},kh=(t,e,n)=>{const r=wh(t),{nodes:i=[]}=t;return i.forEach((o=>{i.forEach((i=>{if(o!==i){const{allPath:a}=mh(t,yh(o),yh(i),e,n),s=a.length;a.flat().forEach((t=>{t!==yh(o)&&t!==yh(i)&&r.set(t,r.get(t)+1/s)}))}}))})),r},Mh=(t,e,n)=>{const r=new Map,{nodes:i=[]}=t;return i.forEach((o=>{const a=i.reduce(((r,i)=>{if(o!==i){const{length:a}=mh(t,yh(o),yh(i),e,n);r+=a}return r}),0);r.set(yh(o),1/a)})),r},Sh=(t,e,n)=>{var r;const i=new Map,o=function(t,e,n){"number"!=typeof e&&(e=1e-6),"number"!=typeof n&&(n=.85);for(var r,i=1,o=0,a=1e3,s=t.nodes,l=void 0===s?[]:s,u=t.edges,c=void 0===u?[]:u,h=l.length,d={},f={},p=0;p<h;++p)d[v=(E=l[p]).id]=1/h,f[v]=1/h;for(var g=function(t){var e={},n=t.nodes,r=void 0===n?[]:n,i=t.edges,o=void 0===i?[]:i;return r.forEach((function(t){e[t.id]={degree:0,inDegree:0,outDegree:0}})),o.forEach((function(t){e[t.source].degree++,e[t.source].outDegree++,e[t.target].degree++,e[t.target].inDegree++})),e}(t);a>0&&i>e;){for(o=0,p=0;p<h;++p){var v=(E=l[p]).id;if(r=0,0===g[E.id].inDegree)d[v]=0;else{for(var m=lh(v,c,"source"),y=0;y<m.length;++y){var b=m[y],x=g[b].outDegree;x>0&&(r+=f[b]/x)}d[v]=n*r,o+=d[v]}}for(o=(1-o)/h,i=0,p=0;p<h;++p){var E;r=d[v=(E=l[p]).id]+o,i+=Math.abs(r-f[v]),f[v]=r}a-=1}return f}(t,e,n);return null===(r=t.nodes)||void 0===r||r.forEach((t=>{i.set(yh(t),o[yh(t)])})),i},Nh=(t,e)=>{const{nodes:n=[]}=t,r=Oh(t,e),i=Th(r,n.length),o=new Map;return n.forEach(((t,e)=>{o.set(yh(t),i[e])})),o},Oh=(t,e)=>{const{nodes:n=[],edges:r=[]}=t,i=Array(n.length).fill(null).map((()=>Array(n.length).fill(0)));return r.forEach((({source:t,target:r})=>{const o=n.findIndex((e=>yh(e)===t)),a=n.findIndex((t=>yh(t)===r));e?i[o][a]=1:(i[o][a]=1,i[a][o]=1)})),i},Th=(t,e,n=100,r=1e-6)=>{let i=Array(e).fill(1),o=1/0;for(let a=0;a<n&&o>r;a++){const n=Array(e).fill(0);for(let r=0;r<e;r++)for(let o=0;o<e;o++)n[r]+=t[r][o]*i[o];const r=Math.sqrt(n.reduce(((t,e)=>t+e*e),0));for(let t=0;t<e;t++)n[t]/=r;o=Math.sqrt(n.reduce(((t,e,n)=>t+(e-i[n])*e),0)),i=n}return i};function Ah(t,e,n,r=Ne){const i=new Map(t.map((t=>[n(t),t]))),o=new Map(e.map((t=>[n(t),t]))),a=new Set(i.keys()),s=new Set(o.keys()),l=[],u=[],c=[],h=[];return s.forEach((t=>{a.has(t)?r(i.get(t),o.get(t))?h.push(o.get(t)):u.push(o.get(t)):l.push(o.get(t))})),a.forEach((t=>{s.has(t)||c.push(i.get(t))})),{enter:l,exit:c,keep:h,update:u}}function Ch(t,e,n){t.forEach((t=>{(t=>{n&&!n(t)||(t.style.visibility=e)})(t)}))}class Ph{constructor(t){this.extensions=[],this.extensionMap={},this.context=t}setExtensions(t){const e=function(t,e,n){const r={},i=t=>(t in r||(r[t]=0),`${e}-${t}-${r[t]++}`);return n.map((e=>"string"==typeof e?{type:e,key:i(e)}:"function"==typeof e?e.call(t):e.key?e:Object.assign(Object.assign({},e),{key:i(e.type)})))}(this.context.graph,this.category,t),{enter:n,update:r,exit:i,keep:o}=Ah(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=Sc(e,r);if(!i)return Tc(`The extension ${r} of ${e} is not registered.`);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())),this.context={},this.extensions=[],this.extensionMap={}}}class Rh{constructor(t,e){this.events=[],this.destroyed=!1,this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){this.context={},this.options={},this.destroyed=!0}}class Dh extends Rh{}class Lh extends Dh{constructor(t,e){super(t,Object.assign({},Lh.defaultOptions,e)),this.isOverlapping=(t,e)=>e.some((e=>t.intersects(e))),this.occupiedBounds=[],this.detectLabelCollision=t=>{const e=this.context.viewport,n={show:[],hide:[]};return this.occupiedBounds=[],t.forEach((t=>{const r=t.getShape("label").getRenderBounds();e.isInViewport(r,!0)&&!this.isOverlapping(r,this.occupiedBounds)?(n.show.push(t),this.occupiedBounds.push(Qc(r,this.options.padding))):n.hide.push(t)})),n},this.hideLabelIfExceedViewport=(t,e)=>{const{exit:n}=Ah(t,e,(t=>t.id));null==n||n.forEach(this.hideLabel)},this.nodeCentralities=new Map,this.sortNodesByCentrality=(t,e)=>{const{model:n}=this.context,r=n.getData(),i=n.getRelatedEdgesData.bind(n);return t.map((t=>(this.nodeCentralities.has(t.id)||(this.nodeCentralities=Eh(r,i,e)),{node:t,centrality:this.nodeCentralities.get(t.id)}))).sort(((t,e)=>e.centrality-t.centrality)).map((t=>t.node))},this.sortLabelElementsInView=t=>{const{sort:e,sortNode:n,sortCombo:r,sortEdge:i}=this.options,{model:o}=this.context;if(Yt(e))return t.sort(((t,n)=>e(o.getElementDataById(t.id),o.getElementDataById(n.id))));const{node:a=[],edge:s=[],combo:l=[]}=ie(t,(t=>t.type)),u=Yt(r)?l.sort(((t,e)=>r(...o.getComboData([t.id,e.id])))):l,c=Yt(n)?a.sort(((t,e)=>n(...o.getNodeData([t.id,e.id])))):this.sortNodesByCentrality(a,n),h=Yt(i)?s.sort(((t,e)=>i(...o.getEdgeData([t.id,e.id])))):s;return[...u,...c,...h]},this.labelElementsInView=[],this.isFirstRender=!0,this.onToggleVisibility=t=>{var e;if("zIndex"===(null===(e=t.data)||void 0===e?void 0:e.stage))return;if(!this.validate(t))return void(this.hiddenElements.size>0&&(this.hiddenElements.forEach(this.showLabel),this.hiddenElements.clear()));const n=this.isFirstRender?this.getLabelElements():this.getLabelElementsInView();this.hideLabelIfExceedViewport(this.labelElementsInView,n),this.labelElementsInView=n;const r=this.sortLabelElementsInView(this.labelElementsInView),{show:i,hide:o}=this.detectLabelCollision(r);for(let t=i.length-1;t>=0;t--)this.showLabel(i[t]);o.forEach(this.hideLabel)},this.hiddenElements=new Map,this.hideLabel=t=>{const e=t.getShape("label");e&&Ch(e,"hidden"),this.hiddenElements.set(t.id,t)},this.showLabel=t=>{const e=t.getShape("label");e&&Ch(e,"visible"),t.toFront(),this.hiddenElements.delete(t.id)},this.onTransform=Re(this.onToggleVisibility,this.options.throttle,{leading:!0}),this.enableToggle=!0,this.toggle=t=>{this.enableToggle&&this.onToggleVisibility(t)},this.onBeforeRender=()=>{this.enableToggle=!1},this.onAfterRender=t=>{this.onToggleVisibility(t),this.enableToggle=!0},this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents(),this.onToggleVisibility({})}getLabelElements(){const{elementMap:t}=this.context.element,e=[];for(const n in t){const r=t[n];r.isVisible()&&r.getShape("label")&&e.push(r)}return e}getLabelElementsInView(){const t=this.context.viewport;return this.getLabelElements().filter((e=>t.isInViewport(e.getShape("key").getRenderBounds())))}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.on(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.on(t.GraphEvent.AFTER_DRAW,this.toggle),e.on(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.off(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.off(t.GraphEvent.AFTER_DRAW,this.toggle),e.off(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Lh.defaultOptions={enable:!0,throttle:100,padding:0,sortNode:{type:"degree"}};const _h=[0,0,0];function Ih(t,e){return t.map(((t,n)=>t+e[n]))}function jh(t,e){return t.map(((t,n)=>t-e[n]))}function Bh(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Fh(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function zh(t,e){return t.map((t=>t*e))}function Gh(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+Math.pow(n-e[r]||0,2)),0))}function Vh(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function Wh(t){const e=t.reduce(((t,e)=>t+Math.pow(e,2)),0);return t.map((t=>t/Math.sqrt(e)))}function Hh(t,e,n=!1){const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(Bh(t,e).reduce(((t,e)=>t+e),0)/(Gh(t,_h)*Gh(e,_h)));return n&&r<0&&(i=2*Math.PI-i),i}function Yh(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function Uh(t){return[t[0],t[1]]}function $h(t){return 2===t.length?[t[0],t[1],0]:t}function qh(t){const[e,n]=t;return e||n?Math.atan2(n,e):0}function Xh(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=$h(t),r=$h(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]]}(jh(n,r),jh(i,o)).every((t=>0===t))}function Kh(t,e,n=!1){if(Xh(t,e))return;const[r,i]=t,[o,a]=e,s=((r[0]-o[0])*(o[1]-a[1])-(r[1]-o[1])*(o[0]-a[0]))/((r[0]-i[0])*(o[1]-a[1])-(r[1]-i[1])*(o[0]-a[0])),l=a[0]-o[0]?(r[0]-o[0]+s*(i[0]-r[0]))/(a[0]-o[0]):(r[1]-o[1]+s*(i[1]-r[1]))/(a[1]-o[1]);return n||Hc(s,0,1)&&Hc(l,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function Zh(t){if(Array.isArray(t))return Hc(t[0],0,1)&&Hc(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]}function Qh(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Jh(t){const{x:e,y:n,z:r}=t.style||{};return void 0!==e||void 0!==n||void 0!==r}function td(t,e="center"){return function(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])]}(t,Zh(e))}function ed(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}function nd(t){var e;return{x:t[0],y:t[1],z:null!==(e=t[2])&&void 0!==e?e:0}}function rd(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function id(t,e,n,r=!1){if(Ne(t,e))return t;const i=Wh(r?jh(t,e):jh(e,t)),o=[i[0]*n,i[1]*n];return Ih(Uh(t),o)}function od(t,e){return t[1]===e[1]}function ad(t,e,n){return Xh([t,e],[e,n])}function sd(t,e){return[2*e[0]-t[0],2*e[1]-t[1]]}function ld(t,e,n,r=!0,i=!1){for(let o=0;o<n.length;o++){let a=n[o],s=n[(o+1)%n.length];r&&(a=Ih(e,a),s=Ih(e,s));const l=Kh([e,i?sd(t,e):t],[a,s]);if(l)return{point:l,line:[a,s]}}return{point:e,line:void 0}}function ud(t,e,n=!1){const r=e.center,i=jh(n?sd(t,r):t,e.center),o=Math.atan2(i[1],i[0]);if(isNaN(o))return r;const a=$c(e)/2,s=qc(e)/2;return[r[0]+a*Math.cos(o),r[1]+s*Math.sin(o)]}function cd(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach((e=>{const i=function(t,e){const n=hd(t,e);return Gh(t,n)}(t,e);i<n&&(n=i,r=e)})),r}function hd(t,e){const[n,r]=e[0],[i,o]=e[1],[a,s]=t,l=i-n,u=o-r;if(0===l&&0===u)return[n,r];let c=((a-n)*l+(s-r)*u)/(l*l+u*u);c>1?c=1:c<0&&(c=0);return[n+c*l,r+c*u]}function dd(t,e=!0){const n=function(t){return Fh(t.reduce(((t,e)=>Ih(t,e)),[0,0]),t.length)}(t);return t.sort((([t,r],[i,o])=>{const a=Math.atan2(r-n[1],t-n[0]),s=Math.atan2(o-n[1],i-n[0]);return e?s-a:a-s}))}function fd(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}const pd=t=>t.map((t=>ne(t)?t.toLocaleLowerCase():t));class gd{constructor(e){this.map=new Map,this.recordKey=new Set,this.onKeyDown=t=>{(null==t?void 0:t.key)&&(this.recordKey.add(t.key),this.trigger(t))},this.onKeyUp=t=>{(null==t?void 0:t.key)&&this.recordKey.delete(t.key)},this.onWheel=e=>{this.triggerExtendKey(t.CommonEvent.WHEEL,e)},this.onDrag=e=>{this.triggerExtendKey(t.CommonEvent.DRAG,e)},this.onFocus=()=>{this.recordKey.clear()},this.emitter=e,this.bindEvents()}bind(t,e){0!==t.length&&this.map.set(t,e)}unbind(t,e){this.map.forEach(((n,r)=>{Ne(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}match(t){const e=pd(Array.from(this.recordKey)).sort(),n=pd(t).sort();return Ne(e,n)}bindEvents(){var e;const{emitter:n}=this;n.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),n.on(t.CommonEvent.KEY_UP,this.onKeyUp),n.on(t.CommonEvent.WHEEL,this.onWheel),n.on(t.CommonEvent.DRAG,this.onDrag),null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"focus",this.onFocus)}trigger(t){this.map.forEach(((e,n)=>{this.match(n)&&e(t)}))}triggerExtendKey(t,e){this.map.forEach(((n,r)=>{r.includes(t)&&Ne(Array.from(this.recordKey),r.filter((e=>e!==t)))&&n(e)}))}destroy(){var e;this.unbindAll(),this.emitter.off(t.CommonEvent.KEY_DOWN,this.onKeyDown),this.emitter.off(t.CommonEvent.KEY_UP,this.onKeyUp),this.emitter.off(t.CommonEvent.WHEEL,this.onWheel),this.emitter.off(t.CommonEvent.DRAG,this.onDrag),null===(e=globalThis.removeEventListener)||void 0===e||e.call(globalThis,"blur",this.onFocus)}}class vd extends Dh{constructor(t,e){super(t,ke({},vd.defaultOptions,e)),this.shortcut=new gd(t.graph),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.clearStates=this.clearStates.bind(this),this.bindEvents()}onPointerDown(t){if(!this.validate(t)||!this.isKeydown()||this.startPoint)return;const{canvas:e,graph:n}=this.context,r=Object.assign({},this.options.style);this.options.style.lineWidth&&(r.lineWidth=+this.options.style.lineWidth/n.getZoom()),this.rectShape=new Xl({id:"g6-brush-select",style:r}),e.appendChild(this.rectShape),this.startPoint=[t.canvas.x,t.canvas.y]}onPointerMove(t){var e;if(!this.startPoint)return;const{immediately:n,mode:r}=this.options;this.endPoint=md(t),null===(e=this.rectShape)||void 0===e||e.attr({x:Math.min(this.endPoint[0],this.startPoint[0]),y:Math.min(this.endPoint[1],this.startPoint[1]),width:Math.abs(this.endPoint[0]-this.startPoint[0]),height:Math.abs(this.endPoint[1]-this.startPoint[1])}),n&&"default"===r&&this.updateElementsStates(fd(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=md(t),this.updateElementsStates(fd(this.startPoint,this.endPoint)),this.clearBrush()):this.clearBrush())}clearStates(){this.endPoint||this.clearElementsStates()}clearElementsStates(){const{graph:t}=this.context,e=Object.values(t.getData()).reduce(((t,e)=>Object.assign({},t,e.reduce(((t,e)=>(t[yh(e)]=[],t)),{}))),{});t.setElementState(e,this.options.animation)}updateElementsStates(t){const{graph:e}=this.context,{enableElements:n,state:r,mode:i,onSelect:o}=this.options,a=this.selector(e,t,n);let s={};switch(i){case"union":a.forEach((t=>{s[t]=[...e.getElementState(t),r]}));break;case"diff":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?n.filter((t=>t!==r)):[...n,r]}));break;case"intersect":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?[r]:[]}));break;default:a.forEach((t=>{s[t]=[r]}))}Yt(o)&&(s=o(s)),e.setElementState(s,this.options.animation)}selector(t,e,n){if(!n||0===n.length)return[];const r=[],i=t.getData();if(n.forEach((n=>{i[`${n}s`].forEach((n=>{const i=yh(n);"hidden"!==t.getElementVisibility(i)&&function(t,e,n,r){const i=t[0],o=t[1];let a=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);const s=r-n;for(let t=0,r=s-1;t<s;r=t++){const s=e[t+n][0],l=e[t+n][1],u=e[r+n][0],c=e[r+n][1];l>o!=c>o&&i<(u-s)*(o-l)/(c-l)+s&&(a=!a)}return a}(t.getElementPosition(i),e)&&r.push(i)}))})),n.includes("edge")){const t=i.edges;null==t||t.forEach((t=>{const{source:e,target:n}=t;r.includes(e)&&r.includes(n)&&r.push(yh(t))}))}return r}clearBrush(){var t;null===(t=this.rectShape)||void 0===t||t.remove(),this.rectShape=void 0,this.startPoint=void 0,this.endPoint=void 0}isKeydown(){const{trigger:t}=this.options,e=Array.isArray(t)?t:[t];return this.shortcut.match(e.filter((t=>"drag"!==t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}bindEvents(){const{graph:e}=this.context;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp),e.on(t.CanvasEvent.CLICK,this.clearStates)}unbindEvents(){const{graph:e}=this.context;e.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.off(t.CommonEvent.POINTER_UP,this.onPointerUp),e.off(t.CanvasEvent.CLICK,this.clearStates)}update(t){this.unbindEvents(),this.options=ke(this.options,t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}vd.defaultOptions={animation:!1,enable:!0,enableElements:["node","combo","edge"],immediately:!1,mode:"default",state:"selected",trigger:["shift"],style:{width:0,height:0,lineWidth:1,fill:"#1677FF",stroke:"#1677FF",fillOpacity:.1,zIndex:2,pointerEvents:"none"}};const md=t=>[t.canvas.x,t.canvas.y],yd=.8,bd=["node","edge","combo"];function xd(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)xd(t,e,n,r,i+1);"BT"===r&&e(t,i)}function Ed(t,e,n,r,i="both"){if("combo"===e||"node"===e)return wd(t,n,r,i);const o=t.getEdgeData(n);if(!o)return[];const a=wd(t,o.source,r-1,i),s=wd(t,o.target,r-1,i);return Array.from(new Set([...a,...s,n]))}function wd(t,e,n,r="both"){const i=new Set,o=new Set,a=new Set;return function(t,e,n){const r=[[t,0]];for(;r.length;){const[t,i]=r.shift();e(t,i);const o=n(t);if(o)for(const t of o)r.push([t,i+1])}}(e,((e,i)=>{i>n||(a.add(e),t.getRelatedEdgesData(e,r).forEach((t=>{const e=yh(t);!o.has(e)&&i<n&&(a.add(e),o.add(e))})))}),(e=>t.getRelatedEdgesData(e,r).map((t=>t.source===e?t.target:t.source)).filter((t=>!i.has(t)&&(i.add(t),!0))))),Array.from(a)}function kd(t){return t.states||[]}class Md extends Dh{constructor(t,e){super(t,Object.assign({},Md.defaultOptions,e)),this.onClickSelect=t=>ze(this,void 0,void 0,(function*(){var e,n;this.validate(t)&&(yield this.updateState(t),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))})),this.onClickCanvas=t=>ze(this,void 0,void 0,(function*(){var e,n;this.validate(t)&&(yield this.clearState(),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))})),this.shortcut=new gd(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),bd.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.on(t.CanvasEvent.CLICK,this.onClickCanvas)}get isMultipleSelect(){const{multiple:t,trigger:e}=this.options;return t&&this.shortcut.match(e)}getNeighborIds(t){const{target:e,targetType:n}=t,{graph:r}=this.context,{degree:i}=this.options;return Ed(r,n,e.id,"function"==typeof i?i(t):i).filter((t=>t!==e.id))}updateState(t){return ze(this,void 0,void 0,(function*(){const{state:e,unselectedState:n,neighborState:r,animation:i}=this.options;if(!e&&!r&&!n)return;const{target:o}=t,{graph:a}=this.context,s=kd(a.getElementData(o.id)).includes(e)?"unselect":"select",l={},u=this.isMultipleSelect,c=[o.id],h=this.getNeighborIds(t);if(u)if(Object.assign(l,this.getDataStates()),"select"===s){const t=(t,e)=>{t.forEach((t=>{const r=new Set(a.getElementState(t));r.add(e),r.delete(n),l[t]=Array.from(r)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{const i=l[t];i.includes(e)||i.includes(r)||i.includes(n)||l[t].push(n)}))}else{const t=l[o.id];l[o.id]=t.filter((t=>t!==e&&t!==r)),t.includes(n)||l[o.id].push(n),h.forEach((t=>{l[t]=l[t].filter((t=>t!==r)),l[t].includes(e)||l[t].push(n)}))}else if("select"===s){Object.assign(l,this.getClearStates(!!n));const t=(t,e)=>{t.forEach((t=>{l[t]||(l[t]=a.getElementState(t)),l[t].push(e)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{c.includes(t)||h.includes(t)||l[t].push(n)}))}else Object.assign(l,this.getClearStates());yield a.setElementState(l,i)}))}getDataStates(){const{graph:t}=this.context,{nodes:e,edges:n,combos:r}=t.getData(),i={};return[...e,...n,...r].forEach((t=>{i[yh(t)]=kd(t)})),i}getClearStates(t=!1){const{graph:e}=this.context,{state:n,unselectedState:r,neighborState:i}=this.options,o=new Set([n,r,i]),{nodes:a,edges:s,combos:l}=e.getData(),u={};return[...a,...s,...l].forEach((e=>{const n=kd(e),r=n.filter((t=>!o.has(t)));(t||r.length!==n.length)&&(u[yh(e)]=r)})),u}clearState(){return ze(this,void 0,void 0,(function*(){const{graph:t}=this.context;yield t.setElementState(this.getClearStates(),this.options.animation)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;bd.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.off(t.CanvasEvent.CLICK,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}function Sd(t){var e;return!!(null===(e=t.style)||void 0===e?void 0:e.collapsed)}function Nd(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function Od(t,e,n=!0){if(!e)return t;if(!Nd(t,e))return t;const r=t.slice(e.length);return n?function(t){var e=he(t);return e.charAt(0).toLowerCase()+e.substring(1)}(r):r}function Td(t,e){const n=Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Nd(n,e)&&Object.assign(t,{[Od(n,e)]:r}),t)),{});if("opacity"in t){const r=function(t,e){return`${e}${de(t)}`}("opacity",e),i=t.opacity;if(r in t){const e=t[r];Object.assign(n,{opacity:i*e})}else Object.assign(n,{opacity:i})}return n}function Ad(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 Cd(t,e){const n="string"==typeof e?[e]:e,r={};return Object.keys(t).forEach((e=>{n.find((t=>e.startsWith(t)))||(r[e]=t[e])})),r}function Pd(t=0){if("number"==typeof t)return[t,t,t];const[e,n=e,r=e]=t;return[e,n,r]}function Rd(t,e){const{datum:n,graph:r}=e;return"function"==typeof t?t.call(r,n):Object.fromEntries(Object.entries(t).map((([t,e])=>"function"==typeof e?[t,e.call(r,n)]:[t,e])))}function Dd(t,e){const n=(null==t?void 0:t.style)||{},r=(null==e?void 0:e.style)||{};for(const t in n)t in r||(r[t]=n[t]);return Object.assign({},t,e,{style:r})}function Ld(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 _d(t){const e="string"==typeof t?Sc("palette",t):t;if("function"!=typeof e)return e}function Id(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 jd(t,e,n=1,r=!1){const i=r?n:1;return Id((t.max[0]-t.min[0])*i,e)}Md.defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],state:"selected",neighborState:"selected",unselectedState:void 0,degree:0};class Bd extends _l{constructor(t){zd(t.style),super(t),this.shapeMap={},this.animateMap={},this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}upsert(e,n,r,i,o){var a,s,l,u,c,h,d,f;const p=this.shapeMap[e];if(!1===r)return void(p&&(null===(a=null==o?void 0:o.beforeDestroy)||void 0===a||a.call(o,p),i.removeChild(p),delete this.shapeMap[e],null===(s=null==o?void 0:o.afterDestroy)||void 0===s||s.call(o,p)));const g="string"==typeof n?Sc(t.ExtensionCategory.SHAPE,n):n;if(!g)throw new Error(Oc(`Shape ${n} not found`));if(!p||p.destroyed||!(p instanceof g)){p&&(null===(l=null==o?void 0:o.beforeDestroy)||void 0===l||l.call(o,p),null==p||p.destroy(),null===(u=null==o?void 0:o.afterDestroy)||void 0===u||u.call(o,p)),null===(c=null==o?void 0:o.beforeCreate)||void 0===c||c.call(o);const t=new g({className:e,style:r});return i.appendChild(t),this.shapeMap[e]=t,null===(h=null==o?void 0:o.afterCreate)||void 0===h||h.call(o,t),t}return null===(d=null==o?void 0:o.beforeUpdate)||void 0===d||d.call(o,p),Dg(p,r),null===(f=null==o?void 0:o.afterUpdate)||void 0===f||f.call(o,p),p}update(t={}){const e=Object.assign({},this.attributes,t);zd(e),function(t,e){const{zIndex:n,transform:r,transformOrigin:i,visibility:o,cursor:a,clipPath:s,component:l}=e,u=Fe(e,["zIndex","transform","transformOrigin","visibility","cursor","clipPath","component"]);Object.assign(t.attributes,u),r&&t.setAttribute("transform",r);ae(n)&&t.setAttribute("zIndex",n);i&&t.setAttribute("transformOrigin",i);o&&t.setAttribute("visibility",o);a&&t.setAttribute("cursor",a);s&&t.setAttribute("clipPath",s);l&&t.setAttribute("component",l)}(this,e),this.render(e,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){return function(t){return Fe(t,["x","y","z","class","className","transform","transformOrigin","zIndex","visibility"])}(t)}get compositeShapes(){return[["badges","badge-"],["ports","port-"]]}animate(t,e){if(0===t.length)return null;const n=[];if(void 0!==t[0].x||void 0!==t[0].y||void 0!==t[0].z){const{x:e=0,y:n=0,z:r=0}=this.attributes;t.forEach((t=>{const{x:i=e,y:o=n,z:a=r}=t;Object.assign(t,{transform:a?[["translate3d",i,o,a]]:[["translate",i,o]]})}))}const r=super.animate(t,e);if(r&&(Fd(this,r),n.push(r)),Array.isArray(t)&&t.length>0){const r=["transform","transformOrigin","x","y","z","zIndex"];if(Object.keys(t[0]).some((t=>!r.includes(t)))){Object.entries(this.shapeMap).forEach((([r,i])=>{const o=this[`get${de(r)}Style`];if(Yt(o)){const r=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t)))),a=i.animate(Pc(r),e);a&&(Fd(i,a),n.push(a))}}));const r=(r,i)=>{if(!Se(r)){const o=this[`get${de(i)}Style`];if(Yt(o)){const i=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t))));Object.entries(i[0]).map((([t])=>{const o=i.map((e=>e[t])),a=r[t];if(a){const t=a.animate(Pc(o),e);t&&(Fd(a,t),n.push(t))}}))}}};this.compositeShapes.forEach((([t,e])=>{const n=Ad(this.shapeMap,e);r(n,t)}))}}return Cc(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;Ch(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}function Fd(t,e){null==e||e.finished.then((()=>{const n=t.activeAnimations.findIndex((t=>t===e));n>-1&&t.activeAnimations.splice(n,1)}))}function zd(t){if(!t)return{};if("x"in t||"y"in t||"z"in t){const{x:e=0,y:n=0,z:r,transform:i}=t,o=_c(e,n,r,i);o&&(t.transform=o)}return t}class Gd extends Bd{constructor(t){super(Dd({style:Gd.defaultStyleProps},t))}isTextStyle(t){return Nd(t,"label")}isBackgroundStyle(t){return Nd(t,"background")}getTextStyle(t){return Cd(Fe(this.getGraphicStyle(t),["padding"]),"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Td(e,"background"),{min:[a,s],center:[l,u],halfExtents:[c,h]}=this.shapeMap.text.getGeometryBounds(),[d,f,p,g]=Yc(i),v=2*c+g+f,{width:m,height:y}=o;m&&y?Object.assign(o,{x:l-Number(m)/2,y:u-Number(y)/2}):Object.assign(o,{x:a-g,y:s-d,width:n?Math.min(v,r+g+f):v,height:2*h+d+p});const{radius:b}=o;if("string"==typeof b&&b.endsWith("%")){const t=Number(b.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Zl,this.getTextStyle(t),e),this.upsert("background",Xl,this.getBackgroundStyle(t),e)}getGeometryBounds(){return(this.getShape("background")||this.getShape("text")).getGeometryBounds()}}Gd.defaultStyleProps={padding:0,fontSize:12,fontFamily:"system-ui, sans-serif",wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};class Vd extends Bd{constructor(t){super(Dd({style:Vd.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",Gd,this.getBadgeStyle(t),e)}getGeometryBounds(){const t=this.getShape("label");return(t.getShape("background")||t.getShape("text")).getGeometryBounds()}}Vd.defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};const Wd={M:["x","y"],m:["dx","dy"],H:["x"],h:["dx"],V:["y"],v:["dy"],L:["x","y"],l:["dx","dy"],Z:[],z:[],C:["x1","y1","x2","y2","x","y"],c:["dx1","dy1","dx2","dy2","dx","dy"],S:["x2","y2","x","y"],s:["dx2","dy2","dx","dy"],Q:["x1","y1","x","y"],q:["dx1","dy1","dx","dy"],T:["x","y"],t:["dx","dy"],A:["rx","ry","rotation","large-arc","sweep","x","y"],a:["rx","ry","rotation","large-arc","sweep","dx","dy"]};function Hd(t){const e=[],n="string"==typeof t?function(t){const e=t.replace(/[\n\r]/g,"").replace(/-/g," -").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ").trim().split(/\s*,|\s+/),n=[];let r="",i={};for(;e.length>0;){let t=e.shift();t in Wd?r=t:e.unshift(t),i={type:r},Wd[r].forEach((n=>{t=e.shift(),i[n]=t})),"M"===r?r="L":"m"===r&&(r="l");const[o,...a]=Object.values(i);n.push([o,...a.map(Number)])}return n}(t):t;return n.forEach((t=>{const n=t[0];if("Z"!==n)if("A"!==n)for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])})),e}const Yd=t=>{if(t.length<2)return[["M",0,0],["L",0,0]];const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(i,r),t.push(e,n);const o=[["M",r[0],r[1]]];for(let e=1;e<t.length-2;e+=1){const[n,r]=t[e-1],[i,a]=t[e],[s,l]=t[e+1],[u,c]=e!==t.length-2?t[e+2]:[s,l],h=i+(s-n)/6,d=a+(l-r)/6,f=s-(u-i)/6,p=l-(c-a)/6;o.push(["C",h,d,f,p,s,l])}return o};class Ud extends Bd{constructor(t){super(Dd({style:Ud.defaultStyleProps},t))}getLabelStyle(t){if(!t.label||!t.d||0===t.d.length)return!1;const e=Td(this.getGraphicStyle(t),"label"),{maxWidth:n,offsetX:r,offsetY:i,autoRotate:o,placement:a,closeToPath:s}=e,l=Fe(e,["maxWidth","offsetX","offsetY","autoRotate","placement","closeToPath"]),u=this.shapeMap.key,c=null==u?void 0:u.getRenderBounds();return Object.assign(function(t,e,n,r,i,o,a){const[s,l]=td(t,e),u={textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:[["translate",s+n,l+r]]};if("center"===e||!i)return u;const c=Hd(o);if(!c||c.length<=3)return u;const h=c.map(((t,e)=>{const n=t,r=c[(e+1)%c.length];return Ne(n,r)?null:[n,r]})).filter(Boolean),d=cd([s,l],h),f=hd([s,l],d);if(f&&d&&(u.transform=[["translate",f[0]+n,f[1]+r]],a)){const t=Math.atan((d[0][1]-d[1][1])/(d[0][0]-d[1][0]));u.transform.push(["rotate",t/Math.PI*180]),u.textAlign="center","right"!==e&&"left"!==e||(u.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return u}(c,a,r,i,s,t.d,o),{wordWrapWidth:jd(c,n)},l)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",Hl,this.getKeyStyle(t),e),this.upsert("label",Gd,this.getLabelStyle(t),e)}}Ud.defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};let $d=class extends zl{constructor(t){super(t),this.onMounted=()=>{this.handleRadius()},this.onAttrModified=()=>{this.handleRadius()},Xd=this,this.isMutationObserved=!0,this.addEventListener(Vs.MOUNTED,this.onMounted),this.addEventListener(Vs.ATTR_MODIFIED,this.onAttrModified)}handleRadius(){const{radius:t,clipPath:e,width:n=0,height:r=0}=this.attributes;if(t&&n&&r){const[i,o]=this.getBounds().min,a={x:i,y:o,radius:t,width:n,height:r};if(e)Object.assign(this.parsedStyle.clipPath.style,a);else{const t=new Xl({style:a});this.style.clipPath=t}}else e&&(this.style.clipPath=null)}};const qd=new WeakMap;let Xd=null;const Kd=t=>{if(Xd&&function(t){const e=[];let n=t.parentNode;for(;n;)e.push(n),n=n.parentNode;return e}(Xd).includes(t)){const e=qd.get(t);e?e.includes(Xd)||e.push(Xd):qd.set(t,[Xd])}},Zd=t=>{const e=qd.get(t);e&&e.forEach((t=>t.handleRadius()))};class Qd extends Bd{constructor(t){super(t)}isImage(){const{src:t}=this.attributes;return!!t}getIconStyle(t=this.attributes){const{width:e=0,height:n=0}=t,r=this.getGraphicStyle(t);return this.isImage()?Object.assign({x:-e/2,y:-n/2},r):Object.assign({textBaseline:"middle",textAlign:"center"},r)}render(t=this.attributes,e=this){this.upsert("icon",this.isImage()?$d:Zl,this.getIconStyle(t),e)}}class Jd extends Bd{get context(){return this.config.context}get parsedAttributes(){return this.attributes}onframe(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>this.onframe(),n.finished.then((()=>this.onframe()))),n}}class tf extends Jd{constructor(t){super(Dd({style:tf.defaultStyleProps},t)),this.type="node"}getSize(t=this.attributes){const{size:e}=t;return Pd(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(Cd(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Td(this.getGraphicStyle(t),"label"),{placement:n,maxWidth:r,offsetX:i,offsetY:o}=e,a=Fe(e,["placement","maxWidth","offsetX","offsetY"]),s=this.getShape("key").getLocalBounds();return Object.assign(Rg(s,n,i,o),{wordWrapWidth:jd(s,r)},a)}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),{fill:n}=e,r=Fe(e,["fill"]),i=Td(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign(Object.assign({},r),{stroke:n}),i)}getIconStyle(t){if(!1===t.icon||!t.iconText&&!t.iconSrc)return!1;const e=Td(this.getGraphicStyle(t),"icon");return Object.assign(function(t,e){const n=Pd(t);let r={};return e.text&&!e.fontSize&&(r={fontSize:.5*Math.min(...n)}),!e.src||e.width&&e.height||(r={width:.5*n[0],height:.5*n[1]}),r}(t.size,e),e)}getBadgesStyle(t){var e;const n=Ad(this.shapeMap,"badge-"),r={};if(Object.keys(n).forEach((t=>{r[t]=!1})),!1===t.badge||!(null===(e=t.badges)||void 0===e?void 0:e.length))return r;const{badges:i=[],badgePalette:o,opacity:a=1}=t,s=Fe(t,["badges","badgePalette","opacity"]),l=_d(o),u=Td(this.getGraphicStyle(s),"badge");return i.forEach(((t,e)=>{r[e]=Object.assign(Object.assign({backgroundFill:l?l[e%(null==l?void 0:l.length)]:void 0,opacity:a},u),this.getBadgeStyle(t))})),r}getBadgeStyle(t){const e=this.getShape("key"),{placement:n="top",offsetX:r,offsetY:i}=t,o=Fe(t,["placement","offsetX","offsetY"]),a=Rg(e.getLocalBounds(),n,r,i,!0);return Object.assign(Object.assign({},a),o)}getPortsStyle(t){var e;const n=this.getPorts(),r={};if(Object.keys(n).forEach((t=>{r[t]=!1})),!1===t.port||!(null===(e=t.ports)||void 0===e?void 0:e.length))return r;const i=Td(this.getGraphicStyle(t),"port"),{ports:o=[]}=t;return o.forEach(((e,n)=>{const o=e.key||n,a=Object.assign(Object.assign({},i),e);if(Ng(a))r[o]=!1;else{const[n,i]=this.getPortXY(t,e);r[o]=Object.assign({transform:[["translate",n,i]]},a)}})),r}getPortXY(t,e){const{placement:n="left"}=e,r=this.getShape("key");return Mg(function(t,e){if(!t)return e.getLocalBounds();const n=t.canvas.getLayer(),r=e.cloneNode();Ch(r,"hidden"),n.appendChild(r);const i=r.getLocalBounds();return r.destroy(),i}(this.context,r),n)}getPorts(){return Ad(this.shapeMap,"port-")}getCenter(){return this.getShape("key").getBounds().center}getIntersectPoint(t,e=!1){return function(t,e,n=!1){return ld(t,td(e,"center"),[td(e,"left-top"),td(e,"right-top"),td(e,"right-bottom"),td(e,"left-bottom")],!1,n).point}(t,this.getShape("key").getBounds(),e)}drawHaloShape(t,e){const n=this.getHaloStyle(t),r=this.getShape("key");this.upsert("halo",r.constructor,n,e)}drawIconShape(t,e){const n=this.getIconStyle(t);this.upsert("icon",Qd,n,e),Kd(this)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{const r=n[t];this.upsert(`badge-${t}`,Vd,r,e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{const r=n[t],i=`port-${t}`;this.upsert(i,Dl,r,e)}))}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Gd,n,e)}_drawKeyShape(t,e){return this.drawKeyShape(t,e)}render(t=this.parsedAttributes,e=this){this._drawKeyShape(t,e),this.getShape("key")&&(this.drawHaloShape(t,e),this.drawIconShape(t,e),this.drawBadgeShapes(t,e),this.drawLabelShape(t,e),this.drawPortShapes(t,e))}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Zd(this)}onframe(){this.drawBadgeShapes(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this)}}tf.defaultStyleProps={x:0,y:0,size:32,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};let ef=class t extends tf{constructor(e){super(Dd({style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",Dl,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{r:Math.min(...this.getSize(t))/2})}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getShape("key").attributes,r=2*n*yd;return!!e&&Object.assign({width:r,height:r},e)}getIntersectPoint(t,e=!1){return ud(t,this.getShape("key").getBounds(),e)}};ef.defaultStyleProps={size:32};class nf extends tf{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",Ul,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{points:this.getPoints(t)})}getIntersectPoint(t,e=!1){var n,r;const{points:i}=this.getShape("key").attributes;return ld(t,[+((null===(n=this.attributes)||void 0===n?void 0:n.x)||0),+((null===(r=this.attributes)||void 0===r?void 0:r.y)||0)],i,!0,e).point}}class rf extends nf{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)}}class of extends ef{constructor(t){super(Dd({style:of.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...Pd(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return ne(t)?parseInt(t)/100*this.parseOuterR():t}drawDonutShape(t,e){const{donuts:n}=t;if(!(null==n?void 0:n.length))return;const r=n.map((t=>ae(t)?{value:t}:t)),i=Td(this.getGraphicStyle(t),"donut"),o=_d(t.donutPalette);if(!o)return;const a=r.reduce(((t,e)=>{var n;return t+(null!==(n=e.value)&&void 0!==n?n:0)}),0),s=this.parseOuterR(),l=this.parseInnerR();let u=0;r.forEach(((t,n)=>{const{value:c=0,color:h=o[n%o.length]}=t,d=Fe(t,["value","color"]),f=360*(0===a?1/r.length:c/a);this.upsert(`round${n}`,Hl,Object.assign(Object.assign(Object.assign({},i),{d:sf(s,l,u,u+f),fill:h}),d),e),u+=f}))}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}of.defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};const af=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],sf=(t=0,e=0,n,r)=>{const[i,o]=[0,0];return Math.abs(n-r)%360<1e-6?((t,e,n,r)=>r<=0||n<=r?[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"]]:[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"],["M",t+r,e],["A",r,r,0,1,0,t-r,e],["A",r,r,0,1,0,t+r,e],["Z"]])(i,o,t,e):((t,e,n,r,i,o)=>{const[a,s]=[i/360*2*Math.PI,o/360*2*Math.PI],l=[af(t,e,r,a),af(t,e,n,a),af(t,e,n,s),af(t,e,r,s)],u=s-a>Math.PI?1:0;return[["M",l[0][0],l[0][1]],["L",l[1][0],l[1][1]],["A",n,n,0,u,1,l[2][0],l[2][1]],["L",l[3][0],l[3][1]],["A",r,r,0,u,0,l[0][0],l[0][1]],["Z"]]})(i,o,t,e,n,r)};class lf extends tf{constructor(t){super(Dd({style:lf.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Il,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return Object.assign(Object.assign({},e),{rx:n/2,ry:r/2})}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getShape("key").attributes,i=2*Math.min(+n,+r)*yd;return!!e&&Object.assign({width:i,height:i},e)}getIntersectPoint(t,e=!1){return ud(t,this.getShape("key").getBounds(),e)}}lf.defaultStyleProps={size:[45,35]};class uf extends nf{constructor(t){super(t)}getOuterR(t){return t.outerR||Math.min(...this.getSize(t))/2}getPoints(t){return[[0,e=this.getOuterR(t)],[e*Math.sqrt(3)/2,e/2],[e*Math.sqrt(3)/2,-e/2],[0,-e],[-e*Math.sqrt(3)/2,-e/2],[-e*Math.sqrt(3)/2,e/2]];var e}getIconStyle(t){const e=super.getIconStyle(t),n=this.getOuterR(t)*yd;return!!e&&Object.assign({width:n,height:n},e)}}
18
+ var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).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 y(e,t),u(e)}(Ts),pu=0,gu=function(){return u((function t(e,n){var r;s(this,t),this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=e,e.animation=this,this.timeline=n,this.id="".concat(pu++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(r=this.effect)||void 0===r?void 0:r.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}),[{key:"pending",get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending}},{key:"playState",get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"}},{key:"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}},{key:"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}},{key:"currentTime",get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){if(t=Number(t),!isNaN(t)){var e;if(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))}}},{key:"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()}}},{key:"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()}}},{key:"_isFinished",get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)}},{key:"totalDuration",get:function(){return this._totalDuration}},{key:"_needsTick",get:function(){return this.pending||"running"===this.playState||!this._finishedFlag}},{key:"updatePromises",value: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}},{key:"play",value: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()}},{key:"pause",value: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()}},{key:"finish",value: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())}},{key:"cancel",value: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 fu(null,this,this.currentTime,null);setTimeout((function(){t.oncancel(e)}))}}},{key:"reverse",value:function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()}},{key:"updatePlaybackRate",value:function(t){this.playbackRate=t}},{key:"targetAnimations",value:function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()}},{key:"markTarget",value:function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)}},{key:"unmarkTarget",value:function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)}},{key:"tick",value: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))}},{key:"rewind",value: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}}},{key:"persist",value:function(){throw new Error(Qr)}},{key:"addEventListener",value:function(t,e,n){throw new Error(Qr)}},{key:"removeEventListener",value:function(t,e,n){throw new Error(Qr)}},{key:"dispatchEvent",value:function(t){throw new Error(Qr)}},{key:"commitStyles",value:function(){throw new Error(Qr)}},{key:"ensureAlive",value:function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!(null===(t=this.effect)||void 0===t||!t.update(-1)):this._inEffect=!(null===(e=this.effect)||void 0===e||!e.update(this.currentTime));this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))}},{key:"tickCurrentTime",value:function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())}},{key:"fireEvents",value:function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new fu(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 fu(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}}}])}(),vu=.1,mu="function"==typeof Float32Array,yu=function(t,e){return 1-3*e+3*t},bu=function(t,e){return 3*e-6*t},xu=function(t){return 3*t},Eu=function(t,e,n){return((yu(e,n)*t+bu(e,n))*t+xu(e))*t},wu=function(t,e,n){return 3*yu(e,n)*t*t+2*bu(e,n)*t+xu(e)},ku=function(t,e,n,r){if(!(t>=0&&t<=1&&n>=0&&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=mu?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=Eu(o*vu,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=vu;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*vu,s=wu(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=wu(e,n,r);if(0===o)return e;e-=(Eu(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=Eu(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+vu,t,n)};return function(t){return 0===t||1===t?t:Eu(a(t),e,r)}},Mu=function(t){return Math.pow(t,2)},Su=function(t){return Math.pow(t,3)},Nu=function(t){return Math.pow(t,4)},Ou=function(t){return Math.pow(t,5)},Tu=function(t){return Math.pow(t,6)},Au=function(t){return 1-Math.cos(t*Math.PI/2)},Cu=function(t){return 1-Math.sqrt(1-t*t)},Pu=function(t){return t*t*(3*t-2)},Ru=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)},Du=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?1:n,i=e[1],o=void 0===i?.5:i,a=oe(Number(r),1,10),s=oe(Number(o),.1,2);return 0===t||1===t?t:-a*Math.pow(2,10*(t-1))*Math.sin((t-1-s/(2*Math.PI)*Math.asin(1/a))*(2*Math.PI)/s)},Lu=function(t){var e=arguments.length>2?arguments[2]:void 0,n=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),r=n[0],i=void 0===r?1:r,o=n[1],a=void 0===o?100:o,s=n[2],l=void 0===s?10:s,u=n[3],c=void 0===u?0:u;i=oe(i,.1,1e3),a=oe(a,.1,1e3),l=oe(l,.1,1e3),c=oe(c,.1,1e3);var h=Math.sqrt(a/i),d=l/(2*Math.sqrt(a*i)),f=d<1?h*Math.sqrt(1-d*d):0,p=d<1?(d*h-c)/f:-c+h,g=e?e*t/1e3:t;return g=d<1?Math.exp(-g*d*h)*(1*Math.cos(f*g)+p*Math.sin(f*g)):(1+p*g)*Math.exp(-g*h),0===t||1===t?t:1-g},_u=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?10:n;return("start"===e[1]?Math.ceil:Math.floor)(oe(t,0,1)*r)/r},Iu=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),n=e[0],r=e[1],i=e[2],o=e[3];return ku(n,r,i,o)(t)},ju=ku(.42,0,1,1),Bu=function(t){return function(e){return 1-t(1-e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],arguments.length>2?arguments[2]:void 0)}},Fu=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},zu=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Gu={steps:_u,"step-start":function(t){return _u(t,[1,"start"])},"step-end":function(t){return _u(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Iu,ease:function(t){return Iu(t,[.25,.1,.25,1])},in:ju,out:Bu(ju),"in-out":Fu(ju),"out-in":zu(ju),"in-quad":Mu,"out-quad":Bu(Mu),"in-out-quad":Fu(Mu),"out-in-quad":zu(Mu),"in-cubic":Su,"out-cubic":Bu(Su),"in-out-cubic":Fu(Su),"out-in-cubic":zu(Su),"in-quart":Nu,"out-quart":Bu(Nu),"in-out-quart":Fu(Nu),"out-in-quart":zu(Nu),"in-quint":Ou,"out-quint":Bu(Ou),"in-out-quint":Fu(Ou),"out-in-quint":zu(Ou),"in-expo":Tu,"out-expo":Bu(Tu),"in-out-expo":Fu(Tu),"out-in-expo":zu(Tu),"in-sine":Au,"out-sine":Bu(Au),"in-out-sine":Fu(Au),"out-in-sine":zu(Au),"in-circ":Cu,"out-circ":Bu(Cu),"in-out-circ":Fu(Cu),"out-in-circ":zu(Cu),"in-back":Pu,"out-back":Bu(Pu),"in-out-back":Fu(Pu),"out-in-back":zu(Pu),"in-bounce":Ru,"out-bounce":Bu(Ru),"in-out-bounce":Fu(Ru),"out-in-bounce":zu(Ru),"in-elastic":Du,"out-elastic":Bu(Du),"in-out-elastic":Fu(Du),"out-in-elastic":zu(Du),spring:Lu,"spring-in":Lu,"spring-out":Bu(Lu),"spring-in-out":Fu(Lu),"spring-out-in":zu(Lu)},Vu=function(t){return t};function Wu(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Hu="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",Yu=new RegExp("cubic-bezier\\(".concat(Hu,",").concat(Hu,",").concat(Hu,",").concat(Hu,"\\)")),Uu=/steps\(\s*(\d+)\s*\)/,$u=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function qu(t){var e=Yu.exec(t);if(e)return ku.apply(void 0,d(e.slice(1).map(Number)));var n=Uu.exec(t);if(n)return Wu(Number(n[1]),0);var r=$u.exec(t);return r?Wu(Number(r[1]),{start:1,middle:.5,end:0}[r[2]]):Gu[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)]||Gu.linear}function Xu(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))}function Ku(t,e,n){var r=function(t,e,n){if(null===e)return 0;var r=n.endTime;return e<Math.min(n.delay,r)?1:e>=Math.min(n.delay+t+n.endDelay,r)?2:3}(t,e,n),i=function(t,e,n,r,i){switch(r){case 1:return"backwards"===e||"both"===e?0:null;case 3:return n-i;case 2:return"forwards"===e||"both"===e?t:null;case 0: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?1!==e&&(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||2!==n||0===r||0===i&&0!==o||(a=1),a}(a,n.iterationStart,r,n.iterations,i,o),l=function(t,e,n,r){return 2===t&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,a),u=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,l,s);return n.currentIteration=l,n.progress=u,n.easingFunction(u)}function Zu(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Qu(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:qu(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,l=i[a].computedOffset,u=i[s].computedOffset,c=l,h=u;0===o&&(c=-1/0,0===u&&(s=a)),o===i.length-2&&(h=1/0,1===l&&(a=s)),n.push({applyFrom:c,applyTo:h,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:tc(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:r/i;t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)Qu(n)&&t.setAttribute(n,null)}}function Qu(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Ju=function(t,e,n){return function(r){var i=ec(t,e,r);return ae(i)?i:n(i)}};function tc(t,e,n,r){var i=ga[t];if(i&&i.syntax&&i.int){var o=bl.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=o.parser,s=a?a(e,r):e,l=a?a(n,r):n,u=o.mixer(s,l,r);if(u){var c=Ju.apply(void 0,d(u));return function(t){return 0===t?e:1===t?n:c(t)}}}}return Ju(!1,!0,(function(t){return t?n:e}))}function ec(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(ec(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments ".concat(t,":").concat(e))}var nc=function(){return u((function t(){s(this,t),this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Vu,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}),[{key:"easing",get:function(){return this._easing},set:function(t){this.easingFunction=qu(t),this._easing=t}}])}();function rc(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&&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(Ut(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(!Ut(s)&&!Ut(o)){for(var l=1;l<a-i;l++)n[i+l].computedOffset=o+(Number(s)-o)*l/(a-i);i=a,o=Number(s)}}}(),n}var ic="backwards|forwards|both|none".split("|"),oc="reverse|alternate|alternate-reverse".split("|");function ac(t,e){var n;return function(t){var e=new nc;return"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(n){if(void 0!==t[n]&&null!==t[n]&&"auto"!==t[n]){if(("number"==typeof e[n]||"duration"===n)&&("number"!=typeof t[n]||isNaN(t[n])))return;if("fill"===n&&-1===ic.indexOf(t[n]))return;if("direction"===n&&-1===oc.indexOf(t[n]))return;e[n]=t[n]}})):e.duration=t,e}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!==(n=t)&&void 0!==n?n:{duration:"auto"}))}var sc=function(){return u((function t(e,n,r){var i=this;s(this,t),this.composite="replace",this.iterationComposite="replace",this.target=e,this.timing=ac(r),this.timing.effect=this,this.timing.activeDuration=Xu(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=rc(n,this.timing),this.interpolations=Zu(this.normalizedKeyframes,this.timing,this.target);var o=bl.globalThis.Proxy;this.computedTiming=o?new o(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?i.animation&&i.animation.currentTime||null:"currentIteration"===e?i.animation&&"running"===i.animation.playState?t.currentIteration||0:null:"progress"===e?i.animation&&"running"===i.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}),[{key:"applyInterpolations",value:function(){this.interpolations(this.target,Number(this.timeFraction))}},{key:"update",value:function(t){return null!==t&&(this.timeFraction=Ku(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)}},{key:"getKeyframes",value:function(){return this.normalizedKeyframes}},{key:"setKeyframes",value:function(t){this.normalizedKeyframes=rc(t)}},{key:"getComputedTiming",value:function(){return this.computedTiming}},{key:"getTiming",value:function(){return this.timing}},{key:"updateTiming",value:function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))}}])}();function lc(t,e){return Number(t.id)-Number(e.id)}var uc=function(){return u((function t(e){var n=this;s(this,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){n.currentTime=t,n.discardAnimations(),0===n.animations.length?n.timelineTicking=!1:n.requestAnimationFrame(n.webAnimationsNextTick)},this.processRafCallbacks=function(t){var e=n.rafCallbacks;n.rafCallbacks=[],t<Number(n.currentTime)&&(t=Number(n.currentTime)),n.animations.sort(lc),n.animations=n.tick(t,!0,n.animations)[0],e.forEach((function(e){e[1](t)})),n.applyPendingEffects()},this.document=e}),[{key:"getAnimations",value:function(){return this.discardAnimations(),this.animations.slice()}},{key:"isTicking",value:function(){return this.inTick}},{key:"play",value:function(t,e,n){var r=new sc(t,e,n),i=new gu(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i}},{key:"applyDirtiedAnimation",value:function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(lc),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()}}},{key:"restart",value:function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame}},{key:"destroy",value:function(){this.document.defaultView.cancelAnimationFrame(this.frameId)}},{key:"applyPendingEffects",value:function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]}},{key:"updateAnimationsPromises",value:function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))}},{key:"discardAnimations",value:function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))}},{key:"restartWebAnimationsNextTick",value:function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))}},{key:"rAF",value: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}},{key:"requestAnimationFrame",value:function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))}},{key:"tick",value:function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],l=[],u=[];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?l.push(n):u.push(n)})),(r=this.pendingEffects).push.apply(r,a),(i=this.pendingEffects).push.apply(i,s),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[l,u]}}])}();bl.EasingFunction=qu,bl.AnimationTimeline=uc;const cc={duration:500},hc={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var dc,fc,pc,gc,vc,mc,yc,bc,xc;!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"}(dc||(dc={})),function(t){t.DRAW="draw",t.COLLAPSE="collapse",t.EXPAND="expand",t.TRANSFORM="transform"}(fc||(fc={})),t.CanvasEvent=void 0,function(t){t.CLICK="canvas:click",t.DBLCLICK="canvas:dblclick",t.POINTER_OVER="canvas:pointerover",t.POINTER_LEAVE="canvas:pointerleave",t.POINTER_ENTER="canvas:pointerenter",t.POINTER_MOVE="canvas:pointermove",t.POINTER_OUT="canvas:pointerout",t.POINTER_DOWN="canvas:pointerdown",t.POINTER_UP="canvas:pointerup",t.CONTEXT_MENU="canvas:contextmenu",t.DRAG_START="canvas:dragstart",t.DRAG="canvas:drag",t.DRAG_END="canvas:dragend",t.DRAG_ENTER="canvas:dragenter",t.DRAG_OVER="canvas:dragover",t.DRAG_LEAVE="canvas:dragleave",t.DROP="canvas:drop",t.WHEEL="canvas:wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.ComboEvent=void 0,(pc=t.ComboEvent||(t.ComboEvent={})).CLICK="combo:click",pc.DBLCLICK="combo:dblclick",pc.POINTER_OVER="combo:pointerover",pc.POINTER_LEAVE="combo:pointerleave",pc.POINTER_ENTER="combo:pointerenter",pc.POINTER_MOVE="combo:pointermove",pc.POINTER_OUT="combo:pointerout",pc.POINTER_DOWN="combo:pointerdown",pc.POINTER_UP="combo:pointerup",pc.CONTEXT_MENU="combo:contextmenu",pc.DRAG_START="combo:dragstart",pc.DRAG="combo:drag",pc.DRAG_END="combo:dragend",pc.DRAG_ENTER="combo:dragenter",pc.DRAG_OVER="combo:dragover",pc.DRAG_LEAVE="combo:dragleave",pc.DROP="combo:drop",t.CommonEvent=void 0,(gc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",gc.DBLCLICK="dblclick",gc.POINTER_OVER="pointerover",gc.POINTER_LEAVE="pointerleave",gc.POINTER_ENTER="pointerenter",gc.POINTER_MOVE="pointermove",gc.POINTER_OUT="pointerout",gc.POINTER_DOWN="pointerdown",gc.POINTER_UP="pointerup",gc.CONTEXT_MENU="contextmenu",gc.DRAG_START="dragstart",gc.DRAG="drag",gc.DRAG_END="dragend",gc.DRAG_ENTER="dragenter",gc.DRAG_OVER="dragover",gc.DRAG_LEAVE="dragleave",gc.DROP="drop",gc.KEY_DOWN="keydown",gc.KEY_UP="keyup",gc.WHEEL="wheel",t.ContainerEvent=void 0,(vc=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",vc.KEY_UP="keyup",t.EdgeEvent=void 0,(mc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="edge:click",mc.DBLCLICK="edge:dblclick",mc.POINTER_OVER="edge:pointerover",mc.POINTER_LEAVE="edge:pointerleave",mc.POINTER_ENTER="edge:pointerenter",mc.POINTER_MOVE="edge:pointermove",mc.POINTER_OUT="edge:pointerout",mc.POINTER_DOWN="edge:pointerdown",mc.POINTER_UP="edge:pointerup",mc.CONTEXT_MENU="edge:contextmenu",mc.DRAG_ENTER="edge:dragenter",mc.DRAG_OVER="edge:dragover",mc.DRAG_LEAVE="edge:dragleave",mc.DROP="edge:drop",t.GraphEvent=void 0,(yc=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",yc.AFTER_CANVAS_INIT="aftercanvasinit",yc.BEFORE_SIZE_CHANGE="beforesizechange",yc.AFTER_SIZE_CHANGE="aftersizechange",yc.BEFORE_ELEMENT_CREATE="beforeelementcreate",yc.AFTER_ELEMENT_CREATE="afterelementcreate",yc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",yc.AFTER_ELEMENT_UPDATE="afterelementupdate",yc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",yc.AFTER_ELEMENT_DESTROY="afterelementdestroy",yc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",yc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",yc.BEFORE_DRAW="beforedraw",yc.AFTER_DRAW="afterdraw",yc.BEFORE_RENDER="beforerender",yc.AFTER_RENDER="afterrender",yc.BEFORE_ANIMATE="beforeanimate",yc.AFTER_ANIMATE="afteranimate",yc.BEFORE_LAYOUT="beforelayout",yc.AFTER_LAYOUT="afterlayout",yc.BEFORE_STAGE_LAYOUT="beforestagelayout",yc.AFTER_STAGE_LAYOUT="afterstagelayout",yc.BEFORE_TRANSFORM="beforetransform",yc.AFTER_TRANSFORM="aftertransform",yc.BATCH_START="batchstart",yc.BATCH_END="batchend",yc.BEFORE_DESTROY="beforedestroy",yc.AFTER_DESTROY="afterdestroy",yc.BEFORE_RENDERER_CHANGE="beforerendererchange",yc.AFTER_RENDERER_CHANGE="afterrendererchange",t.HistoryEvent=void 0,(bc=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",bc.REDO="redo",bc.CANCEL="cancel",bc.ADD="add",bc.CLEAR="clear",bc.CHANGE="change",t.NodeEvent=void 0,(xc=t.NodeEvent||(t.NodeEvent={})).CLICK="node:click",xc.DBLCLICK="node:dblclick",xc.POINTER_OVER="node:pointerover",xc.POINTER_LEAVE="node:pointerleave",xc.POINTER_ENTER="node:pointerenter",xc.POINTER_MOVE="node:pointermove",xc.POINTER_OUT="node:pointerout",xc.POINTER_DOWN="node:pointerdown",xc.POINTER_UP="node:pointerup",xc.CONTEXT_MENU="node:contextmenu",xc.DRAG_START="node:dragstart",xc.DRAG="node:drag",xc.DRAG_END="node:dragend",xc.DRAG_ENTER="node:dragenter",xc.DRAG_OVER="node:dragover",xc.DRAG_LEAVE="node:dragleave",xc.DROP="node:drop";const Ec="combo",wc="tree";var kc;t.ExtensionCategory=void 0,(kc=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",kc.EDGE="edge",kc.COMBO="combo",kc.THEME="theme",kc.PALETTE="palette",kc.LAYOUT="layout",kc.BEHAVIOR="behavior",kc.PLUGIN="plugin",kc.ANIMATION="animation",kc.TRANSFORM="transform",kc.SHAPE="shape";const Mc={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{},shape:{}};function Sc(t,e){var n;const r=null===(n=Mc[t])||void 0===n?void 0:n[e];if(r)return r}const Nc="5.0.41";function Oc(t){return`[G6 v${Nc}] ${t}`}const Tc=t=>{console.warn(Oc(t))};function Ac(e){const{theme:n}=e;if(!n)return{};const r=Sc(t.ExtensionCategory.THEME,n);return r||(Tc(`The theme of ${n} is not registered.`),{})}function Cc(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=>{var r;return null===(r=t[e])||void 0===r?void 0:r.call(t,...n)}))},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach((t=>{t[e]=n})),Reflect.set(t,e,n))})}function Pc(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)),{});Object.entries(e).forEach((([n,r])=>{(r.length!==t.length||r.some((t=>Ut(t)))||r.every((t=>!["sourceNode","targetNode","childrenNode"].includes(n)&&Ne(t,r[0]))))&&delete e[n]}));const n=Object.entries(e).reduce(((t,[e,n])=>(n.forEach(((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}})),t)),[]);return 0!==t.length&&0===n.length&&n.push({_:0},{_:0}),n}function Rc(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;case"visibility":return"visible";case"collapsed":return!1;case"states":return[];default:return}}function Dc(t,e){const{animation:n}=t;if(!1===n||!1===e)return!1;const r=Object.assign({},cc);return qt(n)&&Object.assign(r,n),qt(e)&&Object.assign(r,e),r}function Lc(e,n,r,i){var o,a;const{animation:s}=e;if(!1===s||!1===i)return[];const l=null===(o=null==e?void 0:e[n])||void 0===o?void 0:o.animation;if(!1===l)return[];const u=null==l?void 0:l[r];if(!1===u)return[];const c=null===(a=Ac(e)[n])||void 0===a?void 0:a.animation,h=(e=[])=>function(e){if("string"==typeof e){return Sc(t.ExtensionCategory.ANIMATION,e)||(Tc(`The animation of ${e} is not registered.`),[])}return e}(e).map((t=>Object.assign(Object.assign(Object.assign(Object.assign({},hc),qt(s)&&s),t),qt(i)&&i)));if(u)return h(u);if(!c)return[];const d=c[r];return!1===d?[]:h(d)}function _c(t,e,n,r=[]){if(!r&&0===t&&0===e&&0===n)return null;if(Array.isArray(r)){let i=-1;const o=[];for(let a=0;a<r.length;a++){const s=r[a];if("translate"===s[0]){if(s[1]===t&&s[2]===e)return null;i=a,o.push(["translate",t,e])}else if("translate3d"===s[0]){if(s[1]===t&&s[2]===e&&s[3]===n)return null;i=a,o.push(["translate3d",t,e,null!=n?n:0])}else o.push(s)}return-1===i&&o.splice(0,0,ae(n)?["translate3d",t,e,null!=n?n:0]:["translate",t,e]),0===o.length?null:o}const i=r?r.replace(/translate(3d)?\([^)]*\)/g,""):"";return 0===n?`translate(${t}, ${e})${i}`:`translate3d(${t}, ${e}, ${n})${i}`}const Ic=(t,e,n)=>{if(!n.length)return null;const[r,i]=e;let o;const a=n.map((e=>{var{fields:n,shape:a,states:s}=e,l=Fe(e,["fields","shape","states"]);const u=(e=>{var n;if(e){const o=t.getShape(e);if(!o)return null;const a=`get${de(e)}Style`,s=(null===(n=null==t?void 0:t[a])||void 0===n?void 0:n.bind(t))||(t=>t);return{shape:o,fromStyle:(null==s?void 0:s(r))||{},toStyle:(null==s?void 0:s(i))||{}}}return{shape:t,fromStyle:r,toStyle:i}})(a);if(!u)return null;const{shape:c,fromStyle:h,toStyle:d}=u,f=[{},{}];if(n.forEach((t=>{var e,n;Object.assign(f[0],{[t]:null!==(e=h[t])&&void 0!==e?e:Rc(t)}),Object.assign(f[1],{[t]:null!==(n=d[t])&&void 0!==n?n:Rc(t)})})),f.some((t=>Object.keys(t).some((t=>["x","y","z"].includes(t)))))){const{x:t=0,y:e=0,z:n,transform:r=""}=c.attributes||{};f.forEach((i=>{var o,a,s;i.transform=_c(null!==(o=i.x)&&void 0!==o?o:t,null!==(a=i.y)&&void 0!==a?a:e,null!==(s=i.z)&&void 0!==s?s:n,r)}))}const p=c.animate(Pc(f),l);return void 0===a&&(o=p),p})).filter(Boolean),s=o||(null==a?void 0:a[0]);return s?Cc(s,a.filter((t=>t!=t))):null},jc=[{fields:["x","y"]}],Bc=jc,Fc=[{fields:["sourceNode","targetNode"]}],zc=Fc,Gc=[{fields:["childrenNode","x","y"]}],Vc=Gc;function Wc(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function Hc(t,e,n){return t>=e&&t<=n}function Yc(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 Uc(t=0){const e=Yc(t);return e[0]+e[2]}function $c(t){return t.max[0]-t.min[0]}function qc(t){return t.max[1]-t.min[1]}function Xc(t){return[$c(t),qc(t)]}function Kc(t,e){const n=Wc(t)?Zc(t):t.getShape("key").getBounds();return e?Qc(n,e):n}function Zc(t){const[e,n,r=0]=t,i=new Ur;return i.setMinMax([e,n,r],[e,n,r]),i}function Qc(t,e){const[n,r,i,o]=Yc(e),[a,s,l]=t.min,[u,c,h]=t.max,d=new Ur;return d.setMinMax([a-o,s-n,l],[u+r,c+i,h]),d}function Jc(t){if(0===t.length)return new Ur;if(1===t.length)return t[0];const e=new Ur;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 th(t,e){return Hc(t[0],e.min[0],e.max[0])&&Hc(t[1],e.min[1],e.max[1])}function eh(t,e,n=!1){const{min:[r,i],max:[o,a]}=e,s=(t[1]===i||t[1]===a)&&(n||Hc(t[0],r,o)),l=(t[0]===r||t[0]===o)&&(n||Hc(t[1],i,a));return s||l}function nh(t,e){const{center:n}=e;return t[0]===n[0]&&t[1]===n[1]}function rh(t,e){const[n,r]=t,[i,o]=e.min,[a,s]=e.max,l=n-i,u=a-n,c=r-o,h=s-r,d=Math.min(l,u,c,h);return d===l?"left":d===u?"right":d===c?"top":d===h?"bottom":"left"}function ih(t,e){const n=me(t);if(th(t,e)){switch(rh(t,e)){case"left":n[0]=e.min[0];break;case"right":n[0]=e.max[0];break;case"top":n[1]=e.min[1];break;case"bottom":n[1]=e.max[1]}}else{const[r,i]=t,[o,a]=e.min,[s,l]=e.max;n[0]=Hc(r,o,s)?r:r<o?o:s,n[1]=Hc(i,a,l)?i:i<a?a:l}return n}var oh=function(t,e){return t===e},ah=function(){function t(t,e){void 0===e&&(e=null),this.value=t,this.next=e}return t.prototype.toString=function(t){return t?t(this.value):"".concat(this.value)},t}(),sh=function(){function t(t){void 0===t&&(t=oh),this.head=null,this.tail=null,this.compare=t}return t.prototype.prepend=function(t){var e=new ah(t,this.head);return this.head=e,this.tail||(this.tail=e),this},t.prototype.append=function(t){var e=new ah(t);return this.head?(this.tail.next=e,this.tail=e,this):(this.head=e,this.tail=e,this)},t.prototype.delete=function(t){if(!this.head)return null;for(var e=null;this.head&&this.compare(this.head.value,t);)e=this.head,this.head=this.head.next;var n=this.head;if(null!==n)for(;n.next;)this.compare(n.next.value,t)?(e=n.next,n.next=n.next.next):n=n.next;return this.compare(this.tail.value,t)&&(this.tail=n),e},t.prototype.find=function(t){var e=t.value,n=void 0===e?void 0:e,r=t.callback,i=void 0===r?void 0:r;if(!this.head)return null;for(var o=this.head;o;){if(i&&i(o.value))return o;if(void 0!==n&&this.compare(o.value,n))return o;o=o.next}return null},t.prototype.deleteTail=function(){var t=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,t;for(var e=this.head;e.next;)e.next.next?e=e.next:e.next=null;return this.tail=e,t},t.prototype.deleteHead=function(){if(!this.head)return null;var t=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),t},t.prototype.fromArray=function(t){var e=this;return t.forEach((function(t){return e.append(t)})),this},t.prototype.toArray=function(){for(var t=[],e=this.head;e;)t.push(e),e=e.next;return t},t.prototype.reverse=function(){for(var t=this.head,e=null,n=null;t;)n=t.next,t.next=e,e=t,t=n;this.tail=this.head,this.head=e},t.prototype.toString=function(t){return void 0===t&&(t=void 0),this.toArray().map((function(e){return e.toString(t)})).toString()},t}(),lh=function(t,e,n){void 0===e&&(e=[]);var r=e.filter((function(e){return e.source===t||e.target===t}));if("target"===n){return r.filter((function(e){return e.source===t})).map((function(t){return t.target}))}if("source"===n){return r.filter((function(e){return e.target===t})).map((function(t){return t.source}))}return r.map((function(e){return e.source===t?e.target:e.source}))},uh={}.toString,ch=function(t,e){return uh.call(t)==="[object "+e+"]"},hh=function(t){return ch(t,"Function")},dh=function(t){return Array.isArray?Array.isArray(t):ch(t,"Array")};var fh,ph=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return function(t,e){var n,r;if(t)if(dh(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var a in t)if(t.hasOwnProperty(a)&&!1===e(t[a],a))break}(t,(function(n,r){hh(t)&&"prototype"===r||e.push(n)})),e};!function(t,e){if(!hh(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.apply(this,r),a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s};n.cache=new Map}((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return fh||(fh=document.createElement("canvas").getContext("2d")),fh.font=[o,a,i,n+"px",r].join(" "),fh.measureText(function(t){return ch(t,"String")}(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],ph(e)).join("")}));function gh(t,e,n,r){if(t===e)return[t];if(r[e])return r[e];for(var i=[],o=0,a=n[e];o<a.length;o++){var s=gh(t,a[o],n,r);if(!s)return;for(var l=0,u=s;l<u.length;l++){var c=u[l];dh(c)?i.push(We(We([],c,!0),[e],!1)):i.push([c,e])}}return r[e]=i,r[e]}var vh,mh=function(t,e,n,r,i){var o=function(t,e,n,r){var i=t.nodes,o=void 0===i?[]:i,a=t.edges,s=void 0===a?[]:a,l={},u={},c={};o.forEach((function(t,n){var r=t.id;u[r]=1/0,r===e&&(u[r]=0)}));for(var h=o.length,d=function(t){var e=function(t,e,n){for(var r,i=1/0,o=0;o<e.length;o++){var a=e[o].id;!n[a]&&t[a]<=i&&(i=t[a],r=e[o])}return r}(u,o,l),i=e.id;if(l[i]=!0,u[i]===1/0)return"continue";var a=[];a=n?function(t,e){return e.filter((function(e){return e.source===t}))}(i,s):function(t,e){return e.filter((function(e){return e.source===t||e.target===t}))}(i,s),a.forEach((function(t){var n=t.target,o=t.source,a=n===i?o:n,s=r&&t[r]?t[r]:1;u[a]>u[e.id]+s?(u[a]=u[e.id]+s,c[a]=[e.id]):u[a]===u[e.id]+s&&c[a].push(e.id)}))},f=0;f<h;f++)d();c[e]=[e];var p={};for(var g in u)u[g]!==1/0&&gh(e,g,c,p);var v={};for(var g in p)v[g]=p[g][0];return{length:u,path:v,allPath:p}}(t,e,r,i),a=o.length,s=o.path,l=o.allPath;return{length:a[n],path:s[n],allPath:l[n]}};!function(t){t.EuclideanDistance="euclideanDistance"}(vh||(vh={}));function yh(t){if(void 0!==t.id)return t.id;if(void 0!==t.source&&void 0!==t.target)return`${t.source}-${t.target}`;throw new Error(Oc("The datum does not have available id."))}function bh(t){return t.combo}function xh(t,e){const n={nodes:(t.nodes||[]).map(yh),edges:(t.edges||[]).map(yh),combos:(t.combos||[]).map(yh)};return e?Object.values(n).flat():n}!function(){function t(t){void 0===t&&(t=10),this.linkedList=new sh,this.maxStep=t}Object.defineProperty(t.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),t.prototype.isEmpty=function(){return!this.linkedList.head},t.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},t.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},t.prototype.push=function(t){this.linkedList.prepend(t),this.length>this.maxStep&&this.linkedList.deleteTail()},t.prototype.pop=function(){var t=this.linkedList.deleteHead();return t?t.value:null},t.prototype.toArray=function(){return this.linkedList.toArray().map((function(t){return t.value}))},t.prototype.clear=function(){for(;!this.isEmpty();)this.pop()}}();const Eh=(t,e,n)=>{var r;switch(n.type){case"degree":{const i=new Map;return null===(r=t.nodes)||void 0===r||r.forEach((t=>{const r=e(yh(t),n.direction).length;i.set(yh(t),r)})),i}case"betweenness":return kh(t,n.directed,n.weightPropertyName);case"closeness":return Mh(t,n.directed,n.weightPropertyName);case"eigenvector":return Nh(t,n.directed);case"pagerank":return Sh(t,n.epsilon,n.linkProb);default:return wh(t)}},wh=t=>{var e;const n=new Map;return null===(e=t.nodes)||void 0===e||e.forEach((t=>{n.set(yh(t),0)})),n},kh=(t,e,n)=>{const r=wh(t),{nodes:i=[]}=t;return i.forEach((o=>{i.forEach((i=>{if(o!==i){const{allPath:a}=mh(t,yh(o),yh(i),e,n),s=a.length;a.flat().forEach((t=>{t!==yh(o)&&t!==yh(i)&&r.set(t,r.get(t)+1/s)}))}}))})),r},Mh=(t,e,n)=>{const r=new Map,{nodes:i=[]}=t;return i.forEach((o=>{const a=i.reduce(((r,i)=>{if(o!==i){const{length:a}=mh(t,yh(o),yh(i),e,n);r+=a}return r}),0);r.set(yh(o),1/a)})),r},Sh=(t,e,n)=>{var r;const i=new Map,o=function(t,e,n){"number"!=typeof e&&(e=1e-6),"number"!=typeof n&&(n=.85);for(var r,i=1,o=0,a=1e3,s=t.nodes,l=void 0===s?[]:s,u=t.edges,c=void 0===u?[]:u,h=l.length,d={},f={},p=0;p<h;++p)d[v=(E=l[p]).id]=1/h,f[v]=1/h;for(var g=function(t){var e={},n=t.nodes,r=void 0===n?[]:n,i=t.edges,o=void 0===i?[]:i;return r.forEach((function(t){e[t.id]={degree:0,inDegree:0,outDegree:0}})),o.forEach((function(t){e[t.source].degree++,e[t.source].outDegree++,e[t.target].degree++,e[t.target].inDegree++})),e}(t);a>0&&i>e;){for(o=0,p=0;p<h;++p){var v=(E=l[p]).id;if(r=0,0===g[E.id].inDegree)d[v]=0;else{for(var m=lh(v,c,"source"),y=0;y<m.length;++y){var b=m[y],x=g[b].outDegree;x>0&&(r+=f[b]/x)}d[v]=n*r,o+=d[v]}}for(o=(1-o)/h,i=0,p=0;p<h;++p){var E;r=d[v=(E=l[p]).id]+o,i+=Math.abs(r-f[v]),f[v]=r}a-=1}return f}(t,e,n);return null===(r=t.nodes)||void 0===r||r.forEach((t=>{i.set(yh(t),o[yh(t)])})),i},Nh=(t,e)=>{const{nodes:n=[]}=t,r=Oh(t,e),i=Th(r,n.length),o=new Map;return n.forEach(((t,e)=>{o.set(yh(t),i[e])})),o},Oh=(t,e)=>{const{nodes:n=[],edges:r=[]}=t,i=Array(n.length).fill(null).map((()=>Array(n.length).fill(0)));return r.forEach((({source:t,target:r})=>{const o=n.findIndex((e=>yh(e)===t)),a=n.findIndex((t=>yh(t)===r));e?i[o][a]=1:(i[o][a]=1,i[a][o]=1)})),i},Th=(t,e,n=100,r=1e-6)=>{let i=Array(e).fill(1),o=1/0;for(let a=0;a<n&&o>r;a++){const n=Array(e).fill(0);for(let r=0;r<e;r++)for(let o=0;o<e;o++)n[r]+=t[r][o]*i[o];const r=Math.sqrt(n.reduce(((t,e)=>t+e*e),0));for(let t=0;t<e;t++)n[t]/=r;o=Math.sqrt(n.reduce(((t,e,n)=>t+(e-i[n])*e),0)),i=n}return i};function Ah(t,e,n,r=Ne){const i=new Map(t.map((t=>[n(t),t]))),o=new Map(e.map((t=>[n(t),t]))),a=new Set(i.keys()),s=new Set(o.keys()),l=[],u=[],c=[],h=[];return s.forEach((t=>{a.has(t)?r(i.get(t),o.get(t))?h.push(o.get(t)):u.push(o.get(t)):l.push(o.get(t))})),a.forEach((t=>{s.has(t)||c.push(i.get(t))})),{enter:l,exit:c,keep:h,update:u}}function Ch(t,e,n){t.forEach((t=>{(t=>{n&&!n(t)||(t.style.visibility=e)})(t)}))}class Ph{constructor(t){this.extensions=[],this.extensionMap={},this.context=t}setExtensions(t){const e=function(t,e,n){const r={},i=t=>(t in r||(r[t]=0),`${e}-${t}-${r[t]++}`);return n.map((e=>"string"==typeof e?{type:e,key:i(e)}:"function"==typeof e?e.call(t):e.key?e:Object.assign(Object.assign({},e),{key:i(e.type)})))}(this.context.graph,this.category,t),{enter:n,update:r,exit:i,keep:o}=Ah(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=Sc(e,r);if(!i)return Tc(`The extension ${r} of ${e} is not registered.`);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())),this.context={},this.extensions=[],this.extensionMap={}}}class Rh{constructor(t,e){this.events=[],this.destroyed=!1,this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){this.context={},this.options={},this.destroyed=!0}}class Dh extends Rh{}class Lh extends Dh{constructor(t,e){super(t,Object.assign({},Lh.defaultOptions,e)),this.isOverlapping=(t,e)=>e.some((e=>t.intersects(e))),this.occupiedBounds=[],this.detectLabelCollision=t=>{const e=this.context.viewport,n={show:[],hide:[]};return this.occupiedBounds=[],t.forEach((t=>{const r=t.getShape("label").getRenderBounds();e.isInViewport(r,!0)&&!this.isOverlapping(r,this.occupiedBounds)?(n.show.push(t),this.occupiedBounds.push(Qc(r,this.options.padding))):n.hide.push(t)})),n},this.hideLabelIfExceedViewport=(t,e)=>{const{exit:n}=Ah(t,e,(t=>t.id));null==n||n.forEach(this.hideLabel)},this.nodeCentralities=new Map,this.sortNodesByCentrality=(t,e)=>{const{model:n}=this.context,r=n.getData(),i=n.getRelatedEdgesData.bind(n);return t.map((t=>(this.nodeCentralities.has(t.id)||(this.nodeCentralities=Eh(r,i,e)),{node:t,centrality:this.nodeCentralities.get(t.id)}))).sort(((t,e)=>e.centrality-t.centrality)).map((t=>t.node))},this.sortLabelElementsInView=t=>{const{sort:e,sortNode:n,sortCombo:r,sortEdge:i}=this.options,{model:o}=this.context;if(Yt(e))return t.sort(((t,n)=>e(o.getElementDataById(t.id),o.getElementDataById(n.id))));const{node:a=[],edge:s=[],combo:l=[]}=ie(t,(t=>t.type)),u=Yt(r)?l.sort(((t,e)=>r(...o.getComboData([t.id,e.id])))):l,c=Yt(n)?a.sort(((t,e)=>n(...o.getNodeData([t.id,e.id])))):this.sortNodesByCentrality(a,n),h=Yt(i)?s.sort(((t,e)=>i(...o.getEdgeData([t.id,e.id])))):s;return[...u,...c,...h]},this.labelElementsInView=[],this.isFirstRender=!0,this.onToggleVisibility=t=>{var e;if("zIndex"===(null===(e=t.data)||void 0===e?void 0:e.stage))return;if(!this.validate(t))return void(this.hiddenElements.size>0&&(this.hiddenElements.forEach(this.showLabel),this.hiddenElements.clear()));const n=this.isFirstRender?this.getLabelElements():this.getLabelElementsInView();this.hideLabelIfExceedViewport(this.labelElementsInView,n),this.labelElementsInView=n;const r=this.sortLabelElementsInView(this.labelElementsInView),{show:i,hide:o}=this.detectLabelCollision(r);for(let t=i.length-1;t>=0;t--)this.showLabel(i[t]);o.forEach(this.hideLabel)},this.hiddenElements=new Map,this.hideLabel=t=>{const e=t.getShape("label");e&&Ch(e,"hidden"),this.hiddenElements.set(t.id,t)},this.showLabel=t=>{const e=t.getShape("label");e&&Ch(e,"visible"),t.toFront(),this.hiddenElements.delete(t.id)},this.onTransform=Re(this.onToggleVisibility,this.options.throttle,{leading:!0}),this.enableToggle=!0,this.toggle=t=>{this.enableToggle&&this.onToggleVisibility(t)},this.onBeforeRender=()=>{this.enableToggle=!1},this.onAfterRender=t=>{this.onToggleVisibility(t),this.enableToggle=!0},this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents(),this.onToggleVisibility({})}getLabelElements(){const{elementMap:t}=this.context.element,e=[];for(const n in t){const r=t[n];r.isVisible()&&r.getShape("label")&&e.push(r)}return e}getLabelElementsInView(){const t=this.context.viewport;return this.getLabelElements().filter((e=>t.isInViewport(e.getShape("key").getRenderBounds())))}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.on(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.on(t.GraphEvent.AFTER_DRAW,this.toggle),e.on(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.off(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.off(t.GraphEvent.AFTER_DRAW,this.toggle),e.off(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Lh.defaultOptions={enable:!0,throttle:100,padding:0,sortNode:{type:"degree"}};const _h=[0,0,0];function Ih(t,e){return t.map(((t,n)=>t+e[n]))}function jh(t,e){return t.map(((t,n)=>t-e[n]))}function Bh(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Fh(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function zh(t,e){return t.map((t=>t*e))}function Gh(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+Math.pow(n-e[r]||0,2)),0))}function Vh(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function Wh(t){const e=t.reduce(((t,e)=>t+Math.pow(e,2)),0);return t.map((t=>t/Math.sqrt(e)))}function Hh(t,e,n=!1){const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(Bh(t,e).reduce(((t,e)=>t+e),0)/(Gh(t,_h)*Gh(e,_h)));return n&&r<0&&(i=2*Math.PI-i),i}function Yh(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function Uh(t){return[t[0],t[1]]}function $h(t){return 2===t.length?[t[0],t[1],0]:t}function qh(t){const[e,n]=t;return e||n?Math.atan2(n,e):0}function Xh(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=$h(t),r=$h(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]]}(jh(n,r),jh(i,o)).every((t=>0===t))}function Kh(t,e,n=!1){if(Xh(t,e))return;const[r,i]=t,[o,a]=e,s=((r[0]-o[0])*(o[1]-a[1])-(r[1]-o[1])*(o[0]-a[0]))/((r[0]-i[0])*(o[1]-a[1])-(r[1]-i[1])*(o[0]-a[0])),l=a[0]-o[0]?(r[0]-o[0]+s*(i[0]-r[0]))/(a[0]-o[0]):(r[1]-o[1]+s*(i[1]-r[1]))/(a[1]-o[1]);return n||Hc(s,0,1)&&Hc(l,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function Zh(t){if(Array.isArray(t))return Hc(t[0],0,1)&&Hc(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]}function Qh(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Jh(t){const{x:e,y:n,z:r}=t.style||{};return void 0!==e||void 0!==n||void 0!==r}function td(t,e="center"){return function(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])]}(t,Zh(e))}function ed(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}function nd(t){var e;return{x:t[0],y:t[1],z:null!==(e=t[2])&&void 0!==e?e:0}}function rd(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function id(t,e,n,r=!1){if(Ne(t,e))return t;const i=Wh(r?jh(t,e):jh(e,t)),o=[i[0]*n,i[1]*n];return Ih(Uh(t),o)}function od(t,e){return t[1]===e[1]}function ad(t,e,n){return Xh([t,e],[e,n])}function sd(t,e){return[2*e[0]-t[0],2*e[1]-t[1]]}function ld(t,e,n,r=!0,i=!1){for(let o=0;o<n.length;o++){let a=n[o],s=n[(o+1)%n.length];r&&(a=Ih(e,a),s=Ih(e,s));const l=Kh([e,i?sd(t,e):t],[a,s]);if(l)return{point:l,line:[a,s]}}return{point:e,line:void 0}}function ud(t,e,n=!1){const r=e.center,i=jh(n?sd(t,r):t,e.center),o=Math.atan2(i[1],i[0]);if(isNaN(o))return r;const a=$c(e)/2,s=qc(e)/2;return[r[0]+a*Math.cos(o),r[1]+s*Math.sin(o)]}function cd(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach((e=>{const i=function(t,e){const n=hd(t,e);return Gh(t,n)}(t,e);i<n&&(n=i,r=e)})),r}function hd(t,e){const[n,r]=e[0],[i,o]=e[1],[a,s]=t,l=i-n,u=o-r;if(0===l&&0===u)return[n,r];let c=((a-n)*l+(s-r)*u)/(l*l+u*u);c>1?c=1:c<0&&(c=0);return[n+c*l,r+c*u]}function dd(t,e=!0){const n=function(t){return Fh(t.reduce(((t,e)=>Ih(t,e)),[0,0]),t.length)}(t);return t.sort((([t,r],[i,o])=>{const a=Math.atan2(r-n[1],t-n[0]),s=Math.atan2(o-n[1],i-n[0]);return e?s-a:a-s}))}function fd(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}const pd=t=>t.map((t=>ne(t)?t.toLocaleLowerCase():t));class gd{constructor(e){this.map=new Map,this.recordKey=new Set,this.onKeyDown=t=>{(null==t?void 0:t.key)&&(this.recordKey.add(t.key),this.trigger(t))},this.onKeyUp=t=>{(null==t?void 0:t.key)&&this.recordKey.delete(t.key)},this.onWheel=e=>{this.triggerExtendKey(t.CommonEvent.WHEEL,e)},this.onDrag=e=>{this.triggerExtendKey(t.CommonEvent.DRAG,e)},this.onFocus=()=>{this.recordKey.clear()},this.emitter=e,this.bindEvents()}bind(t,e){0!==t.length&&this.map.set(t,e)}unbind(t,e){this.map.forEach(((n,r)=>{Ne(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}match(t){const e=pd(Array.from(this.recordKey)).sort(),n=pd(t).sort();return Ne(e,n)}bindEvents(){var e;const{emitter:n}=this;n.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),n.on(t.CommonEvent.KEY_UP,this.onKeyUp),n.on(t.CommonEvent.WHEEL,this.onWheel),n.on(t.CommonEvent.DRAG,this.onDrag),null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"focus",this.onFocus)}trigger(t){this.map.forEach(((e,n)=>{this.match(n)&&e(t)}))}triggerExtendKey(t,e){this.map.forEach(((n,r)=>{r.includes(t)&&Ne(Array.from(this.recordKey),r.filter((e=>e!==t)))&&n(e)}))}destroy(){var e;this.unbindAll(),this.emitter.off(t.CommonEvent.KEY_DOWN,this.onKeyDown),this.emitter.off(t.CommonEvent.KEY_UP,this.onKeyUp),this.emitter.off(t.CommonEvent.WHEEL,this.onWheel),this.emitter.off(t.CommonEvent.DRAG,this.onDrag),null===(e=globalThis.removeEventListener)||void 0===e||e.call(globalThis,"blur",this.onFocus)}}class vd extends Dh{constructor(t,e){super(t,ke({},vd.defaultOptions,e)),this.shortcut=new gd(t.graph),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.clearStates=this.clearStates.bind(this),this.bindEvents()}onPointerDown(t){if(!this.validate(t)||!this.isKeydown()||this.startPoint)return;const{canvas:e,graph:n}=this.context,r=Object.assign({},this.options.style);this.options.style.lineWidth&&(r.lineWidth=+this.options.style.lineWidth/n.getZoom()),this.rectShape=new Xl({id:"g6-brush-select",style:r}),e.appendChild(this.rectShape),this.startPoint=[t.canvas.x,t.canvas.y]}onPointerMove(t){var e;if(!this.startPoint)return;const{immediately:n,mode:r}=this.options;this.endPoint=md(t),null===(e=this.rectShape)||void 0===e||e.attr({x:Math.min(this.endPoint[0],this.startPoint[0]),y:Math.min(this.endPoint[1],this.startPoint[1]),width:Math.abs(this.endPoint[0]-this.startPoint[0]),height:Math.abs(this.endPoint[1]-this.startPoint[1])}),n&&"default"===r&&this.updateElementsStates(fd(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=md(t),this.updateElementsStates(fd(this.startPoint,this.endPoint)),this.clearBrush()):this.clearBrush())}clearStates(){this.endPoint||this.clearElementsStates()}clearElementsStates(){const{graph:t}=this.context,e=Object.values(t.getData()).reduce(((t,e)=>Object.assign({},t,e.reduce(((t,e)=>(t[yh(e)]=[],t)),{}))),{});t.setElementState(e,this.options.animation)}updateElementsStates(t){const{graph:e}=this.context,{enableElements:n,state:r,mode:i,onSelect:o}=this.options,a=this.selector(e,t,n);let s={};switch(i){case"union":a.forEach((t=>{s[t]=[...e.getElementState(t),r]}));break;case"diff":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?n.filter((t=>t!==r)):[...n,r]}));break;case"intersect":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?[r]:[]}));break;default:a.forEach((t=>{s[t]=[r]}))}Yt(o)&&(s=o(s)),e.setElementState(s,this.options.animation)}selector(t,e,n){if(!n||0===n.length)return[];const r=[],i=t.getData();if(n.forEach((n=>{i[`${n}s`].forEach((n=>{const i=yh(n);"hidden"!==t.getElementVisibility(i)&&function(t,e,n,r){const i=t[0],o=t[1];let a=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);const s=r-n;for(let t=0,r=s-1;t<s;r=t++){const s=e[t+n][0],l=e[t+n][1],u=e[r+n][0],c=e[r+n][1];l>o!=c>o&&i<(u-s)*(o-l)/(c-l)+s&&(a=!a)}return a}(t.getElementPosition(i),e)&&r.push(i)}))})),n.includes("edge")){const t=i.edges;null==t||t.forEach((t=>{const{source:e,target:n}=t;r.includes(e)&&r.includes(n)&&r.push(yh(t))}))}return r}clearBrush(){var t;null===(t=this.rectShape)||void 0===t||t.remove(),this.rectShape=void 0,this.startPoint=void 0,this.endPoint=void 0}isKeydown(){const{trigger:t}=this.options,e=Array.isArray(t)?t:[t];return this.shortcut.match(e.filter((t=>"drag"!==t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}bindEvents(){const{graph:e}=this.context;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp),e.on(t.CanvasEvent.CLICK,this.clearStates)}unbindEvents(){const{graph:e}=this.context;e.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.off(t.CommonEvent.POINTER_UP,this.onPointerUp),e.off(t.CanvasEvent.CLICK,this.clearStates)}update(t){this.unbindEvents(),this.options=ke(this.options,t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}vd.defaultOptions={animation:!1,enable:!0,enableElements:["node","combo","edge"],immediately:!1,mode:"default",state:"selected",trigger:["shift"],style:{width:0,height:0,lineWidth:1,fill:"#1677FF",stroke:"#1677FF",fillOpacity:.1,zIndex:2,pointerEvents:"none"}};const md=t=>[t.canvas.x,t.canvas.y],yd=.8,bd=["node","edge","combo"];function xd(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)xd(t,e,n,r,i+1);"BT"===r&&e(t,i)}function Ed(t,e,n,r,i="both"){if("combo"===e||"node"===e)return wd(t,n,r,i);const o=t.getEdgeData(n);if(!o)return[];const a=wd(t,o.source,r-1,i),s=wd(t,o.target,r-1,i);return Array.from(new Set([...a,...s,n]))}function wd(t,e,n,r="both"){const i=new Set,o=new Set,a=new Set;return function(t,e,n){const r=[[t,0]];for(;r.length;){const[t,i]=r.shift();e(t,i);const o=n(t);if(o)for(const t of o)r.push([t,i+1])}}(e,((e,i)=>{i>n||(a.add(e),t.getRelatedEdgesData(e,r).forEach((t=>{const e=yh(t);!o.has(e)&&i<n&&(a.add(e),o.add(e))})))}),(e=>t.getRelatedEdgesData(e,r).map((t=>t.source===e?t.target:t.source)).filter((t=>!i.has(t)&&(i.add(t),!0))))),Array.from(a)}function kd(t){return t.states||[]}class Md extends Dh{constructor(t,e){super(t,Object.assign({},Md.defaultOptions,e)),this.onClickSelect=t=>ze(this,void 0,void 0,(function*(){var e,n;this.validate(t)&&(yield this.updateState(t),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))})),this.onClickCanvas=t=>ze(this,void 0,void 0,(function*(){var e,n;this.validate(t)&&(yield this.clearState(),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))})),this.shortcut=new gd(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),bd.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.on(t.CanvasEvent.CLICK,this.onClickCanvas)}get isMultipleSelect(){const{multiple:t,trigger:e}=this.options;return t&&this.shortcut.match(e)}getNeighborIds(t){const{target:e,targetType:n}=t,{graph:r}=this.context,{degree:i}=this.options;return Ed(r,n,e.id,"function"==typeof i?i(t):i).filter((t=>t!==e.id))}updateState(t){return ze(this,void 0,void 0,(function*(){const{state:e,unselectedState:n,neighborState:r,animation:i}=this.options;if(!e&&!r&&!n)return;const{target:o}=t,{graph:a}=this.context,s=kd(a.getElementData(o.id)).includes(e)?"unselect":"select",l={},u=this.isMultipleSelect,c=[o.id],h=this.getNeighborIds(t);if(u)if(Object.assign(l,this.getDataStates()),"select"===s){const t=(t,e)=>{t.forEach((t=>{const r=new Set(a.getElementState(t));r.add(e),r.delete(n),l[t]=Array.from(r)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{const i=l[t];i.includes(e)||i.includes(r)||i.includes(n)||l[t].push(n)}))}else{const t=l[o.id];l[o.id]=t.filter((t=>t!==e&&t!==r)),t.includes(n)||l[o.id].push(n),h.forEach((t=>{l[t]=l[t].filter((t=>t!==r)),l[t].includes(e)||l[t].push(n)}))}else if("select"===s){Object.assign(l,this.getClearStates(!!n));const t=(t,e)=>{t.forEach((t=>{l[t]||(l[t]=a.getElementState(t)),l[t].push(e)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{c.includes(t)||h.includes(t)||l[t].push(n)}))}else Object.assign(l,this.getClearStates());yield a.setElementState(l,i)}))}getDataStates(){const{graph:t}=this.context,{nodes:e,edges:n,combos:r}=t.getData(),i={};return[...e,...n,...r].forEach((t=>{i[yh(t)]=kd(t)})),i}getClearStates(t=!1){const{graph:e}=this.context,{state:n,unselectedState:r,neighborState:i}=this.options,o=new Set([n,r,i]),{nodes:a,edges:s,combos:l}=e.getData(),u={};return[...a,...s,...l].forEach((e=>{const n=kd(e),r=n.filter((t=>!o.has(t)));(t||r.length!==n.length)&&(u[yh(e)]=r)})),u}clearState(){return ze(this,void 0,void 0,(function*(){const{graph:t}=this.context;yield t.setElementState(this.getClearStates(),this.options.animation)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;bd.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.off(t.CanvasEvent.CLICK,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}function Sd(t){var e;return!!(null===(e=t.style)||void 0===e?void 0:e.collapsed)}function Nd(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function Od(t,e,n=!0){if(!e)return t;if(!Nd(t,e))return t;const r=t.slice(e.length);return n?function(t){var e=he(t);return e.charAt(0).toLowerCase()+e.substring(1)}(r):r}function Td(t,e){const n=Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Nd(n,e)&&Object.assign(t,{[Od(n,e)]:r}),t)),{});if("opacity"in t){const r=function(t,e){return`${e}${de(t)}`}("opacity",e),i=t.opacity;if(r in t){const e=t[r];Object.assign(n,{opacity:i*e})}else Object.assign(n,{opacity:i})}return n}function Ad(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 Cd(t,e){const n="string"==typeof e?[e]:e,r={};return Object.keys(t).forEach((e=>{n.find((t=>e.startsWith(t)))||(r[e]=t[e])})),r}function Pd(t=0){if("number"==typeof t)return[t,t,t];const[e,n=e,r=e]=t;return[e,n,r]}function Rd(t,e){const{datum:n,graph:r}=e;return"function"==typeof t?t.call(r,n):Object.fromEntries(Object.entries(t).map((([t,e])=>"function"==typeof e?[t,e.call(r,n)]:[t,e])))}function Dd(t,e){const n=(null==t?void 0:t.style)||{},r=(null==e?void 0:e.style)||{};for(const t in n)t in r||(r[t]=n[t]);return Object.assign({},t,e,{style:r})}function Ld(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 _d(t){const e="string"==typeof t?Sc("palette",t):t;if("function"!=typeof e)return e}function Id(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 jd(t,e,n=1,r=!1){const i=r?n:1;return Id((t.max[0]-t.min[0])*i,e)}Md.defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],state:"selected",neighborState:"selected",unselectedState:void 0,degree:0};class Bd extends _l{constructor(t){zd(t.style),super(t),this.shapeMap={},this.animateMap={},this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}upsert(e,n,r,i,o){var a,s,l,u,c,h,d,f;const p=this.shapeMap[e];if(!1===r)return void(p&&(null===(a=null==o?void 0:o.beforeDestroy)||void 0===a||a.call(o,p),i.removeChild(p),delete this.shapeMap[e],null===(s=null==o?void 0:o.afterDestroy)||void 0===s||s.call(o,p)));const g="string"==typeof n?Sc(t.ExtensionCategory.SHAPE,n):n;if(!g)throw new Error(Oc(`Shape ${n} not found`));if(!p||p.destroyed||!(p instanceof g)){p&&(null===(l=null==o?void 0:o.beforeDestroy)||void 0===l||l.call(o,p),null==p||p.destroy(),null===(u=null==o?void 0:o.afterDestroy)||void 0===u||u.call(o,p)),null===(c=null==o?void 0:o.beforeCreate)||void 0===c||c.call(o);const t=new g({className:e,style:r});return i.appendChild(t),this.shapeMap[e]=t,null===(h=null==o?void 0:o.afterCreate)||void 0===h||h.call(o,t),t}return null===(d=null==o?void 0:o.beforeUpdate)||void 0===d||d.call(o,p),Dg(p,r),null===(f=null==o?void 0:o.afterUpdate)||void 0===f||f.call(o,p),p}update(t={}){const e=Object.assign({},this.attributes,t);zd(e),function(t,e){const{zIndex:n,transform:r,transformOrigin:i,visibility:o,cursor:a,clipPath:s,component:l}=e,u=Fe(e,["zIndex","transform","transformOrigin","visibility","cursor","clipPath","component"]);Object.assign(t.attributes,u),r&&t.setAttribute("transform",r);ae(n)&&t.setAttribute("zIndex",n);i&&t.setAttribute("transformOrigin",i);o&&t.setAttribute("visibility",o);a&&t.setAttribute("cursor",a);s&&t.setAttribute("clipPath",s);l&&t.setAttribute("component",l)}(this,e),this.render(e,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){return function(t){return Fe(t,["x","y","z","class","className","transform","transformOrigin","zIndex","visibility"])}(t)}get compositeShapes(){return[["badges","badge-"],["ports","port-"]]}animate(t,e){if(0===t.length)return null;const n=[];if(void 0!==t[0].x||void 0!==t[0].y||void 0!==t[0].z){const{x:e=0,y:n=0,z:r=0}=this.attributes;t.forEach((t=>{const{x:i=e,y:o=n,z:a=r}=t;Object.assign(t,{transform:a?[["translate3d",i,o,a]]:[["translate",i,o]]})}))}const r=super.animate(t,e);if(r&&(Fd(this,r),n.push(r)),Array.isArray(t)&&t.length>0){const r=["transform","transformOrigin","x","y","z","zIndex"];if(Object.keys(t[0]).some((t=>!r.includes(t)))){Object.entries(this.shapeMap).forEach((([r,i])=>{const o=this[`get${de(r)}Style`];if(Yt(o)){const r=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t)))),a=i.animate(Pc(r),e);a&&(Fd(i,a),n.push(a))}}));const r=(r,i)=>{if(!Se(r)){const o=this[`get${de(i)}Style`];if(Yt(o)){const i=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t))));Object.entries(i[0]).map((([t])=>{const o=i.map((e=>e[t])),a=r[t];if(a){const t=a.animate(Pc(o),e);t&&(Fd(a,t),n.push(t))}}))}}};this.compositeShapes.forEach((([t,e])=>{const n=Ad(this.shapeMap,e);r(n,t)}))}}return Cc(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;Ch(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}function Fd(t,e){null==e||e.finished.then((()=>{const n=t.activeAnimations.findIndex((t=>t===e));n>-1&&t.activeAnimations.splice(n,1)}))}function zd(t){if(!t)return{};if("x"in t||"y"in t||"z"in t){const{x:e=0,y:n=0,z:r,transform:i}=t,o=_c(e,n,r,i);o&&(t.transform=o)}return t}class Gd extends Bd{constructor(t){super(Dd({style:Gd.defaultStyleProps},t))}isTextStyle(t){return Nd(t,"label")}isBackgroundStyle(t){return Nd(t,"background")}getTextStyle(t){return Cd(Fe(this.getGraphicStyle(t),["padding"]),"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Td(e,"background"),{min:[a,s],center:[l,u],halfExtents:[c,h]}=this.shapeMap.text.getGeometryBounds(),[d,f,p,g]=Yc(i),v=2*c+g+f,{width:m,height:y}=o;m&&y?Object.assign(o,{x:l-Number(m)/2,y:u-Number(y)/2}):Object.assign(o,{x:a-g,y:s-d,width:n?Math.min(v,r+g+f):v,height:2*h+d+p});const{radius:b}=o;if("string"==typeof b&&b.endsWith("%")){const t=Number(b.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Zl,this.getTextStyle(t),e),this.upsert("background",Xl,this.getBackgroundStyle(t),e)}getGeometryBounds(){return(this.getShape("background")||this.getShape("text")).getGeometryBounds()}}Gd.defaultStyleProps={padding:0,fontSize:12,fontFamily:"system-ui, sans-serif",wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};class Vd extends Bd{constructor(t){super(Dd({style:Vd.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",Gd,this.getBadgeStyle(t),e)}getGeometryBounds(){const t=this.getShape("label");return(t.getShape("background")||t.getShape("text")).getGeometryBounds()}}Vd.defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};const Wd={M:["x","y"],m:["dx","dy"],H:["x"],h:["dx"],V:["y"],v:["dy"],L:["x","y"],l:["dx","dy"],Z:[],z:[],C:["x1","y1","x2","y2","x","y"],c:["dx1","dy1","dx2","dy2","dx","dy"],S:["x2","y2","x","y"],s:["dx2","dy2","dx","dy"],Q:["x1","y1","x","y"],q:["dx1","dy1","dx","dy"],T:["x","y"],t:["dx","dy"],A:["rx","ry","rotation","large-arc","sweep","x","y"],a:["rx","ry","rotation","large-arc","sweep","dx","dy"]};function Hd(t){const e=[],n="string"==typeof t?function(t){const e=t.replace(/[\n\r]/g,"").replace(/-/g," -").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ").trim().split(/\s*,|\s+/),n=[];let r="",i={};for(;e.length>0;){let t=e.shift();t in Wd?r=t:e.unshift(t),i={type:r},Wd[r].forEach((n=>{t=e.shift(),i[n]=t})),"M"===r?r="L":"m"===r&&(r="l");const[o,...a]=Object.values(i);n.push([o,...a.map(Number)])}return n}(t):t;return n.forEach((t=>{const n=t[0];if("Z"!==n)if("A"!==n)for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])})),e}const Yd=t=>{if(t.length<2)return[["M",0,0],["L",0,0]];const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(i,r),t.push(e,n);const o=[["M",r[0],r[1]]];for(let e=1;e<t.length-2;e+=1){const[n,r]=t[e-1],[i,a]=t[e],[s,l]=t[e+1],[u,c]=e!==t.length-2?t[e+2]:[s,l],h=i+(s-n)/6,d=a+(l-r)/6,f=s-(u-i)/6,p=l-(c-a)/6;o.push(["C",h,d,f,p,s,l])}return o};class Ud extends Bd{constructor(t){super(Dd({style:Ud.defaultStyleProps},t))}getLabelStyle(t){if(!t.label||!t.d||0===t.d.length)return!1;const e=Td(this.getGraphicStyle(t),"label"),{maxWidth:n,offsetX:r,offsetY:i,autoRotate:o,placement:a,closeToPath:s}=e,l=Fe(e,["maxWidth","offsetX","offsetY","autoRotate","placement","closeToPath"]),u=this.shapeMap.key,c=null==u?void 0:u.getRenderBounds();return Object.assign(function(t,e,n,r,i,o,a){const[s,l]=td(t,e),u={textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:[["translate",s+n,l+r]]};if("center"===e||!i)return u;const c=Hd(o);if(!c||c.length<=3)return u;const h=c.map(((t,e)=>{const n=t,r=c[(e+1)%c.length];return Ne(n,r)?null:[n,r]})).filter(Boolean),d=cd([s,l],h),f=hd([s,l],d);if(f&&d&&(u.transform=[["translate",f[0]+n,f[1]+r]],a)){const t=Math.atan((d[0][1]-d[1][1])/(d[0][0]-d[1][0]));u.transform.push(["rotate",t/Math.PI*180]),u.textAlign="center","right"!==e&&"left"!==e||(u.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return u}(c,a,r,i,s,t.d,o),{wordWrapWidth:jd(c,n)},l)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",Hl,this.getKeyStyle(t),e),this.upsert("label",Gd,this.getLabelStyle(t),e)}}Ud.defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};let $d=class extends zl{constructor(t){super(t),this.onMounted=()=>{this.handleRadius()},this.onAttrModified=()=>{this.handleRadius()},Xd=this,this.isMutationObserved=!0,this.addEventListener(Vs.MOUNTED,this.onMounted),this.addEventListener(Vs.ATTR_MODIFIED,this.onAttrModified)}handleRadius(){const{radius:t,clipPath:e,width:n=0,height:r=0}=this.attributes;if(t&&n&&r){const[i,o]=this.getBounds().min,a={x:i,y:o,radius:t,width:n,height:r};if(e)Object.assign(this.parsedStyle.clipPath.style,a);else{const t=new Xl({style:a});this.style.clipPath=t}}else e&&(this.style.clipPath=null)}};const qd=new WeakMap;let Xd=null;const Kd=t=>{if(Xd&&function(t){const e=[];let n=t.parentNode;for(;n;)e.push(n),n=n.parentNode;return e}(Xd).includes(t)){const e=qd.get(t);e?e.includes(Xd)||e.push(Xd):qd.set(t,[Xd])}},Zd=t=>{const e=qd.get(t);e&&e.forEach((t=>t.handleRadius()))};class Qd extends Bd{constructor(t){super(t)}isImage(){const{src:t}=this.attributes;return!!t}getIconStyle(t=this.attributes){const{width:e=0,height:n=0}=t,r=this.getGraphicStyle(t);return this.isImage()?Object.assign({x:-e/2,y:-n/2},r):Object.assign({textBaseline:"middle",textAlign:"center"},r)}render(t=this.attributes,e=this){this.upsert("icon",this.isImage()?$d:Zl,this.getIconStyle(t),e)}}class Jd extends Bd{get context(){return this.config.context}get parsedAttributes(){return this.attributes}onframe(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>this.onframe(),n.finished.then((()=>this.onframe()))),n}}class tf extends Jd{constructor(t){super(Dd({style:tf.defaultStyleProps},t)),this.type="node"}getSize(t=this.attributes){const{size:e}=t;return Pd(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(Cd(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Td(this.getGraphicStyle(t),"label"),{placement:n,maxWidth:r,offsetX:i,offsetY:o}=e,a=Fe(e,["placement","maxWidth","offsetX","offsetY"]),s=this.getShape("key").getLocalBounds();return Object.assign(Rg(s,n,i,o),{wordWrapWidth:jd(s,r)},a)}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),{fill:n}=e,r=Fe(e,["fill"]),i=Td(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign(Object.assign({},r),{stroke:n}),i)}getIconStyle(t){if(!1===t.icon||!t.iconText&&!t.iconSrc)return!1;const e=Td(this.getGraphicStyle(t),"icon");return Object.assign(function(t,e){const n=Pd(t);let r={};return e.text&&!e.fontSize&&(r={fontSize:.5*Math.min(...n)}),!e.src||e.width&&e.height||(r={width:.5*n[0],height:.5*n[1]}),r}(t.size,e),e)}getBadgesStyle(t){var e;const n=Ad(this.shapeMap,"badge-"),r={};if(Object.keys(n).forEach((t=>{r[t]=!1})),!1===t.badge||!(null===(e=t.badges)||void 0===e?void 0:e.length))return r;const{badges:i=[],badgePalette:o,opacity:a=1}=t,s=Fe(t,["badges","badgePalette","opacity"]),l=_d(o),u=Td(this.getGraphicStyle(s),"badge");return i.forEach(((t,e)=>{r[e]=Object.assign(Object.assign({backgroundFill:l?l[e%(null==l?void 0:l.length)]:void 0,opacity:a},u),this.getBadgeStyle(t))})),r}getBadgeStyle(t){const e=this.getShape("key"),{placement:n="top",offsetX:r,offsetY:i}=t,o=Fe(t,["placement","offsetX","offsetY"]),a=Rg(e.getLocalBounds(),n,r,i,!0);return Object.assign(Object.assign({},a),o)}getPortsStyle(t){var e;const n=this.getPorts(),r={};if(Object.keys(n).forEach((t=>{r[t]=!1})),!1===t.port||!(null===(e=t.ports)||void 0===e?void 0:e.length))return r;const i=Td(this.getGraphicStyle(t),"port"),{ports:o=[]}=t;return o.forEach(((e,n)=>{const o=e.key||n,a=Object.assign(Object.assign({},i),e);if(Ng(a))r[o]=!1;else{const[n,i]=this.getPortXY(t,e);r[o]=Object.assign({transform:[["translate",n,i]]},a)}})),r}getPortXY(t,e){const{placement:n="left"}=e,r=this.getShape("key");return Mg(function(t,e){if(!t)return e.getLocalBounds();const n=t.canvas.getLayer(),r=e.cloneNode();Ch(r,"hidden"),n.appendChild(r);const i=r.getLocalBounds();return r.destroy(),i}(this.context,r),n)}getPorts(){return Ad(this.shapeMap,"port-")}getCenter(){return this.getShape("key").getBounds().center}getIntersectPoint(t,e=!1){return function(t,e,n=!1){return ld(t,td(e,"center"),[td(e,"left-top"),td(e,"right-top"),td(e,"right-bottom"),td(e,"left-bottom")],!1,n).point}(t,this.getShape("key").getBounds(),e)}drawHaloShape(t,e){const n=this.getHaloStyle(t),r=this.getShape("key");this.upsert("halo",r.constructor,n,e)}drawIconShape(t,e){const n=this.getIconStyle(t);this.upsert("icon",Qd,n,e),Kd(this)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{const r=n[t];this.upsert(`badge-${t}`,Vd,r,e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{const r=n[t],i=`port-${t}`;this.upsert(i,Dl,r,e)}))}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Gd,n,e)}_drawKeyShape(t,e){return this.drawKeyShape(t,e)}render(t=this.parsedAttributes,e=this){this._drawKeyShape(t,e),this.getShape("key")&&(this.drawHaloShape(t,e),this.drawIconShape(t,e),this.drawBadgeShapes(t,e),this.drawLabelShape(t,e),this.drawPortShapes(t,e))}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Zd(this)}onframe(){this.drawBadgeShapes(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this)}}tf.defaultStyleProps={x:0,y:0,size:32,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};let ef=class t extends tf{constructor(e){super(Dd({style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",Dl,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{r:Math.min(...this.getSize(t))/2})}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getShape("key").attributes,r=2*n*yd;return!!e&&Object.assign({width:r,height:r},e)}getIntersectPoint(t,e=!1){return ud(t,this.getShape("key").getBounds(),e)}};ef.defaultStyleProps={size:32};class nf extends tf{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",Ul,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{points:this.getPoints(t)})}getIntersectPoint(t,e=!1){var n,r;const{points:i}=this.getShape("key").attributes;return ld(t,[+((null===(n=this.attributes)||void 0===n?void 0:n.x)||0),+((null===(r=this.attributes)||void 0===r?void 0:r.y)||0)],i,!0,e).point}}class rf extends nf{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)}}class of extends ef{constructor(t){super(Dd({style:of.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...Pd(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return ne(t)?parseInt(t)/100*this.parseOuterR():t}drawDonutShape(t,e){const{donuts:n}=t;if(!(null==n?void 0:n.length))return;const r=n.map((t=>ae(t)?{value:t}:t)),i=Td(this.getGraphicStyle(t),"donut"),o=_d(t.donutPalette);if(!o)return;const a=r.reduce(((t,e)=>{var n;return t+(null!==(n=e.value)&&void 0!==n?n:0)}),0),s=this.parseOuterR(),l=this.parseInnerR();let u=0;r.forEach(((t,n)=>{const{value:c=0,color:h=o[n%o.length]}=t,d=Fe(t,["value","color"]),f=360*(0===a?1/r.length:c/a);this.upsert(`round${n}`,Hl,Object.assign(Object.assign(Object.assign({},i),{d:sf(s,l,u,u+f),fill:h}),d),e),u+=f}))}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}of.defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};const af=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],sf=(t=0,e=0,n,r)=>{const[i,o]=[0,0];return Math.abs(n-r)%360<1e-6?((t,e,n,r)=>r<=0||n<=r?[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"]]:[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"],["M",t+r,e],["A",r,r,0,1,0,t-r,e],["A",r,r,0,1,0,t+r,e],["Z"]])(i,o,t,e):((t,e,n,r,i,o)=>{const[a,s]=[i/360*2*Math.PI,o/360*2*Math.PI],l=[af(t,e,r,a),af(t,e,n,a),af(t,e,n,s),af(t,e,r,s)],u=s-a>Math.PI?1:0;return[["M",l[0][0],l[0][1]],["L",l[1][0],l[1][1]],["A",n,n,0,u,1,l[2][0],l[2][1]],["L",l[3][0],l[3][1]],["A",r,r,0,u,0,l[0][0],l[0][1]],["Z"]]})(i,o,t,e,n,r)};class lf extends tf{constructor(t){super(Dd({style:lf.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Il,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return Object.assign(Object.assign({},e),{rx:n/2,ry:r/2})}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getShape("key").attributes,i=2*Math.min(+n,+r)*yd;return!!e&&Object.assign({width:i,height:i},e)}getIntersectPoint(t,e=!1){return ud(t,this.getShape("key").getBounds(),e)}}lf.defaultStyleProps={size:[45,35]};class uf extends nf{constructor(t){super(t)}getOuterR(t){return t.outerR||Math.min(...this.getSize(t))/2}getPoints(t){return[[0,e=this.getOuterR(t)],[e*Math.sqrt(3)/2,e/2],[e*Math.sqrt(3)/2,-e/2],[0,-e],[-e*Math.sqrt(3)/2,-e/2],[-e*Math.sqrt(3)/2,e/2]];var e}getIconStyle(t){const e=super.getIconStyle(t),n=this.getOuterR(t)*yd;return!!e&&Object.assign({width:n,height:n},e)}}
19
19
  /*!
20
20
  * @antv/g-plugin-canvas-path-generator
21
21
  * @description A G plugin of path generator with Canvas2D API
@@ -63,12 +63,12 @@ var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).
63
63
  * @date 1/2/2025, 2:58:21 AM
64
64
  * @author AntVis
65
65
  * @docs https://g.antv.antgroup.com/
66
- */class Mp extends tf{constructor(t){super(Object.assign(Object.assign({},t),{style:Object.assign({},Mp.defaultStyleProps,t.style)})),this.rootPointerEvent=new Cs(null),this.forwardEvents=t=>{const e=this.context.canvas,n=e.context.renderingContext.root.ownerDocument.defaultView;this.normalizeToPointerEvent(t,n).forEach((r=>{const i=this.bootstrapEvent(this.rootPointerEvent,r,n,t);Te(e.context.eventService,"mappingTable.pointerupoutside",[]),e.context.eventService.mapEvent(i)}))}}get eventService(){return this.context.canvas.context.eventService}get events(){return[t.CommonEvent.CLICK,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_UP,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE]}getDomElement(){return this.getShape("key").getDomElement()}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.drawPortShapes(t,e)}getKeyStyle(t){const e=Ce(t,["dx","dy","innerHTML","pointerEvents","cursor"]),{dx:n=0,dy:r=0}=e,i=Fe(e,["dx","dy"]),[o,a]=this.getSize(t);return Object.assign(Object.assign({x:n,y:r},i),{width:o,height:a})}drawKeyShape(t,e){const n=this.getKeyStyle(t),{x:r,y:i,width:o=0,height:a=0}=n,s=this.upsert("key-container",Xl,{x:r,y:i,width:o,height:a,opacity:0},e);return this.upsert("key",Fl,n,s)}connectedCallback(){if(!(this.context.canvas.getRenderer("main")instanceof kp))return;const t=this.getDomElement();this.events.forEach((e=>{t.addEventListener(e,this.forwardEvents)}))}attributeChangedCallback(t,e,n){"zIndex"===t&&e!==n&&(this.getDomElement().style.zIndex=n)}destroy(){const t=this.getDomElement();this.events.forEach((e=>{t.removeEventListener(e,this.forwardEvents)})),super.destroy()}normalizeToPointerEvent(t,e){const n=[];if(e.isTouchEvent(t))for(let e=0;e<t.changedTouches.length;e++){const r=t.changedTouches[e];ve(r.button)&&(r.button=0),ve(r.buttons)&&(r.buttons=1),ve(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),ve(r.width)&&(r.width=r.radiusX||1),ve(r.height)&&(r.height=r.radiusY||1),ve(r.tiltX)&&(r.tiltX=0),ve(r.tiltY)&&(r.tiltY=0),ve(r.pointerType)&&(r.pointerType="touch"),ve(r.pointerId)&&(r.pointerId=r.identifier||0),ve(r.pressure)&&(r.pressure=r.force||.5),ve(r.twist)&&(r.twist=0),ve(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;ve(e.isPrimary)&&(e.isPrimary=!0),ve(e.width)&&(e.width=1),ve(e.height)&&(e.height=1),ve(e.tiltX)&&(e.tiltX=0),ve(e.tiltY)&&(e.tiltY=0),ve(e.pointerType)&&(e.pointerType="mouse"),ve(e.pointerId)&&(e.pointerId=1),ve(e.pressure)&&(e.pressure=.5),ve(e.twist)&&(e.twist=0),ve(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.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}bootstrapEvent(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);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const[a,s]=this.context.canvas.getCanvasByViewport([i,o]);return t.canvas.x=a,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:a}=t;if(Ut(r)||Ut(i)){const t=this.eventService.client2Viewport({x:o,y:a});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}onframe(){super.onframe();const{opacity:t}=this.attributes;this.getDomElement().style.opacity=`${t}`}}Mp.defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};let Sp=class t extends tf{constructor(e){super(Dd({style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t),r=super.getKeyStyle(t),{fillOpacity:i,opacity:o=i}=r,a=Fe(r,["fillOpacity","opacity"]);return Object.assign(Object.assign({opacity:o},a),{width:e,height:n,x:-e/2,y:-n/2})}getHaloStyle(t){if(!1===t.halo)return!1;Fe(this.getShape("key").attributes,["fill","stroke"]);const e=Td(this.getGraphicStyle(t),"halo"),n=Number(e.lineWidth),[r,i]=Ih(this.getSize(t),[n,n]);return Object.assign(Object.assign({},e),{width:r,height:i,fill:"transparent",x:-r/2,y:-i/2})}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&Object.assign({width:n*yd,height:r*yd},e)}drawKeyShape(t,e){const n=this.upsert("key",$d,this.getKeyStyle(t),e);return Kd(this),n}drawHaloShape(t,e){this.upsert("halo",Xl,this.getHaloStyle(t),e)}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Zd(this)}};Sp.defaultStyleProps={size:32};class Np extends tf{constructor(t){super(t)}getKeyStyle(t){const[e,n]=this.getSize(t);return Object.assign(Object.assign({},super.getKeyStyle(t)),{width:e,height:n,x:-e/2,y:-n/2})}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getShape("key").attributes;return!!e&&Object.assign({width:n*yd,height:r*yd},e)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}}class Op extends nf{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)*yd;return!!e&&Object.assign({width:n,height:n},e)}getPortXY(t,e){const{placement:n="top"}=e;return Mg(this.getShape("key").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)}}class Tp extends nf{constructor(t){super(Dd({style:Tp.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.getShape("key").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 Mg(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||Se(n||r))return!1;const o=Td(this.getGraphicStyle(t),"icon"),a=this.getShape("key").getLocalBounds(),[s,l]=function(t,e){const{center:n}=t,[r,i]=Xc(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),u=2*function(t,e){let[n,r]=Xc(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(Math.pow(r,2)-Math.pow(Math.sqrt(Math.pow(n/2,2)+Math.pow(r,2))-n/2,2))/(2*r)}(a,i)*yd;return Object.assign({x:s,y:l,width:u,height:u},o)}}Tp.defaultStyleProps={size:40,direction:"up"};class Ap extends tf{constructor(t){super(Dd({style:Ap.defaultStyleProps},t)),this.type="combo",this.updateComboPosition(this.parsedAttributes)}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]=Yc(e);return Ih(Pd(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Pd(t.collapsedSize)}getExpandedKeySize(t){const e=this.getContentBBox(t);return[$c(e),qc(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=e.map((t=>this.context.element.getElement(t))).filter(Boolean);if(0===r.length){const e=new Ur,{x:n=0,y:r=0,size:i}=t,[o,a]=Pd(i);return e.setMinMax([n-o/2,r-a/2,0],[n+o/2,r+a/2,0]),e}const i=Jc(r.map((t=>t.getBounds())));return n?Qc(i,n):i}drawCollapsedMarkerShape(t,e){const n=this.getCollapsedMarkerStyle(t);this.upsert("collapsed-marker",Qd,n,e),Kd(this)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const e=Td(this.getGraphicStyle(t),"collapsedMarker"),{type:n}=e,r=Fe(e,["type"]),i=this.getShape("key"),[o,a]=td(i.getLocalBounds(),"center"),s=Object.assign(Object.assign({},r),{x:o,y:a});if(n){const e=this.getCollapsedMarkerText(n,t);Object.assign(s,{text:e})}return s}getCollapsedMarkerText(t,e){const{childrenData:n=[]}=e,{model:r}=this.context;return"descendant-count"===t?r.getDescendantsData(this.id).length.toString():"child-count"===t?n.length.toString():"node-count"===t?r.getDescendantsData(this.id).filter((t=>"node"===r.getElementType(yh(t)))).length.toString():Yt(t)?t(n):""}getComboPosition(t){const{x:e=0,y:n=0,collapsed:r,childrenData:i=[]}=t;if(0===i.length)return[+e,+n,0];if(r){const{model:t}=this.context,r=t.getDescendantsData(this.id).filter((e=>!t.isCombo(yh(e))));if(r.length>0&&r.some(Jh)){return Fh(r.reduce(((t,e)=>Ih(t,Qh(e))),[0,0,0]),r.length)}return[+e,+n,0]}return this.getContentBBox(t).center}getComboStyle(t){const[e,n]=this.getComboPosition(t);return{x:e,y:n,transform:[["translate",e,n]]}}updateComboPosition(t){const e=this.getComboStyle(t);Object.assign(this.style,e);const{x:n,y:r}=e;this.context.model.syncNodeLikeDatum({id:this.id,style:{x:n,y:r}}),Zd(this)}render(t,e=this){super.render(t,e),this.drawCollapsedMarkerShape(t,e)}update(t={}){super.update(t),this.updateComboPosition(this.parsedAttributes)}onframe(){super.onframe(),this.attributes.collapsed||this.updateComboPosition(this.parsedAttributes),this.drawKeyShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(this.attributes.collapsed?t:t.map((t=>Fe(t,["x","y","z","transform"]))),e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then((()=>this.onframe())),Reflect.set(t,e,n))}):n}}Ap.defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};class Cp extends Ap{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Dl,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),[r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},n),e&&Td(n,"collapsed")),{r:r/2})}getCollapsedKeySize(t){const[e,n]=Pd(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){const e=this.getContentBBox(t),[n,r]=Xc(e),i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2))/2;return[2*i,2*i,0]}getIntersectPoint(t,e=!1){return ud(t,this.getShape("key").getBounds(),e)}}class Pp extends Ap{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},e),t.collapsed&&Td(e,"collapsed")),{width:n,height:r,x:-n/2,y:-r/2})}}const Rp={padding:10};function Dp(t,e,n,r,i,o){const{padding:a}=Object.assign(Rp,o),s=Kc(n,a),l=Kc(r,a),u=[t,...i,e];let c=null;const h=[];for(let t=0,e=u.length;t<e-1;t++){const n=t+1,r=u[t],i=u[n],o=od(d=r,f=i)||function(t,e){return t[0]===e[0]}(d,f);let p=null;if(0===t)if(n===e-1)if(s.intersects(l))p=Vp(r,i,s,l);else if(nh(r,s)||nh(i,l))o||(p=Gp(r,i,s,l));else{const t=ih(r,s),e=ih(i,l);p=Bp(t,e,Ip(t,e)),p.points.unshift(t),p.points.push(e)}else th(i,s)?p=Vp(r,i,s,Kc(i,a),c):o||(p=Fp(r,i,s));else n===e-1?th(r,l)?p=Vp(r,i,Kc(r,a),l,c):o||(p=zp(r,i,l,c)):o||(p=Bp(r,i,c));p?(h.push(...p.points),c=p.direction):c=Ip(r,i),n<e-1&&h.push(i)}var d,f;return h.map(Uh)}const Lp={N:"S",S:"N",W:"E",E:"W"},_p={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function Ip(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function jp(t,e){return"N"===e||"S"===e?qc(t):$c(t)}function Bp(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=Ip(t,r),a=Ip(t,i),s=n?Lp[n]:null,l=o===n||o!==s&&a!==n?r:i;return{points:[l],direction:Ip(l,e)}}function Fp(t,e,n){if(nh(t,n)){const r=Wp(t,e,n);return{points:[r],direction:Ip(r,e)}}{const r=ih(t,n),i=["left","right"].includes(rh(t,n))?[e[0],r[1]]:[r[0],e[1]];return{points:[i],direction:Ip(i,e)}}}function zp(t,e,n,r){const i=nh(e,n)?e:ih(e,n),o=[[i[0],t[1]],[t[0],i[1]]],a=o.filter((t=>function(t,e){return!th(t,e)}(t,n)&&!eh(t,n,!0))),s=a.filter((e=>Ip(e,t)!==r));if(s.length>0){const n=s.find((e=>Ip(t,e)===r))||s[0];return{points:[n],direction:Ip(n,e)}}{const i=id(e,Ht(o,a)[0],jp(n,r)/2);return{points:[Wp(i,t,n),i],direction:Ip(i,e)}}}function Gp(t,e,n,r){let i=Fp(t,e,n);const o=$h(i.points[0]);if(th(o,r)){i=Fp(e,t,r);const a=$h(i.points[0]);if(th(a,n)){const s=id(t,o,jp(n,Ip(t,o))/2),l=id(e,a,jp(r,Ip(e,a))/2),u=[(s[0]+l[0])/2,(s[1]+l[1])/2],c=Fp(t,u,n),h=zp(u,e,r,c.direction);i.points=[c.points[0],h.points[0]],i.direction=h.direction}}return i}function Vp(t,e,n,r,i){const o=.01,a=Jc([n,r]),s=Gh(e,a.center)>Gh(t,a.center),[l,u]=s?[e,t]:[t,e],c=qc(a)+$c(a);let h;if(i){const t=[l[0]+c*Math.cos(_p[i]),l[1]+c*Math.sin(_p[i])];h=id(ih(t,a),t,o)}else h=id(ih(l,a),l,-.01);let d=Wp(h,u,a),f=[rd(h,2),rd(d,2)];if(Ne(rd(h),rd(d))){const t=Hh(jh(h,l),[1,0,0])+Math.PI/2;d=[u[0]+c*Math.cos(t),u[1]+c*Math.sin(t),0],d=rd(id(ih(d,a),u,-.01),2);f=[h,Wp(h,d,a),d]}return{points:s?f.reverse():f,direction:Ip(s?h:d,e)}}function Wp(t,e,n){let r=[t[0],e[1]];return th(r,n)&&(r=[e[0],t[1]]),r}function Hp(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=ed(t.getPoint(o)),s=ed(t.getPoint(o+.01));let l="start"===e?"left":"end"===e?"right":"center";if(od(a,s)||!n){const[e,n]=Yp(t,o,r,i);return{transform:[["translate",e,n]],textAlign:l}}let u=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(l="center"===l?l:"left"===l?"right":"left",r*=-1,u+=Math.PI);const[c,h]=Yp(t,o,r,i,u);return{textAlign:l,transform:[["translate",c,h],["rotate",u/Math.PI*180]]}}function Yp(t,e,n,r,i){const[o,a]=ed(t.getPoint(e));let s=n,l=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),l=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+l]}function Up(t,e,n,r){if(Ne(t,e))return t;const i=jh(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=Wh(Yh(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function $p(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 qp(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,l=o[n+1]||i;if(!ad(s,t,l)&&e){const[n,r]=function(t,e,n,r){const i=Vh(t,e),o=Vh(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])],l=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,l]}(s,t,l,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]])})),a.push(["L",i[0],i[1]]),n&&a.push(["Z"]),a}function Xp(t,e,n,r,i){const o=Kc(t),a=t.getCenter();let s=r&&Og(r),l=i&&Og(i);if(!s||!l){const r=(t=>{const e=Math.PI/2,n=qc(t)/2,r=$c(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]}})(o),i=r[e][0],u=r[e][1],[c,h]=Xc(o),d=Math.max(c,h),f=Ih(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Ih(a,[d*Math.cos(u),d*Math.sin(u),0]);s=Pg(t,f),l=Pg(t,p),n||([s,l]=[l,s])}return[s,l]}function Kp(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[l,u]=Xp(t,e,n,a,s);const c=function(t,e,n,r){const i=t.getCenter();if(Ne(e,n)){const t=jh(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Ih(e,o),Ih(n,Bh(o,[1,-1,1]))]}return[id(i,e,Gh(i,e)+r),id(i,n,Gh(i,n)+r)]}(t,l,u,r);return a&&(l=Cg(a,c[0])),s&&(u=Cg(s,c[c.length-1])),$p(l,u,c)}function Zp(t,e,n,r,i,o,a){const s=Sg(t),l=s[o||a],u=s[a||o];let[c,h]=Xp(t,n,r,l,u);const d=function(t,e,n,r){const i=[],o=Kc(t);if(Ne(e,n)){switch(rh(e,o)){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=rh(e,o),a=rh(n,o);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]),l=s(t,e),u=s(a,n),c=Wp(l,u,o);i.push(l,c,u)}}return i}(t,c,h,i);return l&&(c=Cg(l,d[0])),u&&(h=Cg(u,d[d.length-1])),qp([c,...d,h],e)}function Qp(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)}}function Jp(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(yh(r));if(!t)break;r=t}if(n.some((t=>{var e;return null===(e=t.style)||void 0===e?void 0:e.collapsed}))){const t=n.reverse().findIndex(Sd);return n[t]||n.at(-1)}return t}const tg=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var eg=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",-t/2,0],["A",n,n,0,1,0,2*n-t/2,0],["A",n,n,0,1,0,-t/2,0],["Z"]]},diamond:(t,e)=>[["M",-t/2,0],["L",0,-e/2],["L",t/2,0],["L",0,e/2],["Z"]],rect:(t,e)=>[["M",-t/2,-e/2],["L",t/2,-e/2],["L",t/2,e/2],["L",-t/2,e/2],["Z"]],simple:(t,e)=>[["M",t/2,-e/2],["L",-t/2,0],["L",t/2,0],["L",-t/2,0],["L",t/2,e/2]],triangle:tg,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",-n,0],["L",0,-e/2],["L",0,e/2],["Z"],["M",i-n,-e/2],["L",i+r-n,-e/2],["L",i+r-n,e/2],["L",i-n,e/2],["Z"]]},vee:(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",4*t/5-t/2,0],["L",t/2,e/2],["Z"]]});class ng extends Jd{constructor(t){super(Dd({style:ng.defaultStyleProps},t)),this.type="edge"}get sourceNode(){const{sourceNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}get targetNode(){const{targetNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}getKeyStyle(t){const e=this.getGraphicStyle(t),{loop:n}=e,r=Fe(e,["loop"]),{sourceNode:i,targetNode:o}=this;var a,s;const l={d:n&&(s=o,(a=i)&&s&&a===s)?this.getLoopPath(t):this.getKeyPath(t)};return Hl.PARSED_STYLE_LIST.forEach((t=>{t in r&&(l[t]=r[t])})),l}getLoopPath(t){const{sourcePort:e,targetPort:n}=t,r=this.sourceNode,i=Kc(r),o=Math.max($c(i),qc(i)),{placement:a,clockwise:s,dist:l=o}=Td(this.getGraphicStyle(t),"loop");return Kp(r,a,s,l,e,n)}getEndpoints(t,e=!0,n=[]){const{sourcePort:r,targetPort:i}=t,{sourceNode:o,targetNode:a}=this,[s,l]=function(t,e,n,r){const i=Tg(t,e,n,r),o=Tg(e,t,r,n);return[i,o]}(o,a,r,i);if(!e){return[s?Og(s):o.getCenter(),l?Og(l):a.getCenter()]}const u="function"==typeof n?n():n;return[Ag(s||o,u[0]||l||a),Ag(l||a,u[u.length-1]||s||o)]}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),n=Td(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign({},e),n)}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Td(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a}=e,s=Fe(e,["placement","offsetX","offsetY","autoRotate","maxWidth"]),l=Hp(this.shapeMap.key,n,o,r,i),u=this.shapeMap.key.getLocalBounds(),c=function(t,e,n=1){return Id(Gh(t[0],t[1])*n,e)}([u.min,u.max],a);return Object.assign({wordWrapWidth:c},l,s)}getBadgeStyle(t){if(!1===t.badge||!t.badgeText)return!1;const e=Td(t,"badge"),{offsetX:n,offsetY:r,placement:i}=e,o=Fe(e,["offsetX","offsetY","placement"]);return Object.assign(o,function(t,e,n,r,i){var o,a;const s=2*(null===(o=t.badge)||void 0===o?void 0:o.getGeometryBounds().halfExtents[0])||0,l=2*(null===(a=t.label)||void 0===a?void 0:a.getGeometryBounds().halfExtents[0])||0;return Hp(t.key,n,!0,(l?(l/2+s/2)*("suffix"===e?1:-1):0)+r,i)}(this.shapeMap,i,t.labelPlacement,n,r))}drawArrow(t,e){var n;const r="start"===e,i=t["start"===e?"startArrow":"endArrow"],o=this.shapeMap.key;if(i){const e=this.getArrowStyle(t,r),[n,i,a]=r?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],s=o.parsedStyle[n];if(s)s.attr(e);else{const t=new(e.src?zl:Hl)({style:e});o.style[n]=t}o.style[i]=t[a]||e.width/2+ +e.lineWidth}else{const t=r?"markerStart":"markerEnd";null===(n=o.style[t])||void 0===n||n.destroy(),o.style[t]=null}}getArrowStyle(t,e){const n=this.getShape("key").attributes,r=e?"startArrow":"endArrow",i=Td(this.getGraphicStyle(t),r),{size:o,type:a}=i,s=Fe(i,["size","type"]),[l,u]=Pd(function(t,e){return e||(t<4?10:4===t?12:2.5*t)}(n.lineWidth,o)),c=(Yt(a)?a:eg[a]||tg)(l,u);return Object.assign(Ce(n,["stroke","strokeOpacity","fillOpacity"]),{width:l,height:u},Object.assign({},c&&{d:c,fill:"simple"===a?"":n.stroke}),s)}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Gd,n,e)}drawHaloShape(t,e){const n=this.getHaloStyle(t);this.upsert("halo",Hl,n,e)}drawBadgeShape(t,e){const n=this.getBadgeStyle(t);this.upsert("badge",Vd,n,e)}drawSourceArrow(t){this.drawArrow(t,"start")}drawTargetArrow(t){this.drawArrow(t,"end")}drawKeyShape(t,e){const n=this.getKeyStyle(t);return this.upsert("key",Hl,n,e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.getShape("key")&&(this.drawSourceArrow(t),this.drawTargetArrow(t),this.drawLabelShape(t,e),this.drawHaloShape(t,e),this.drawBadgeShape(t,e))}onframe(){this.drawKeyShape(this.parsedAttributes,this),this.drawSourceArrow(this.parsedAttributes),this.drawTargetArrow(this.parsedAttributes),this.drawHaloShape(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this),this.drawBadgeShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(t,e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then((()=>this.onframe())),Reflect.set(t,e,n))}):n}}ng.defaultStyleProps={badge:!0,badgeOffsetX:0,badgeOffsetY:0,badgePlacement:"suffix",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,loop:!0,startArrow:!1,startArrowLineDash:0,startArrowLineJoin:"round",startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"vee",endArrow:!1,endArrowLineDash:0,endArrowLineJoin:"round",endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"vee",loopPlacement:"top",loopClockwise:!0};class rg extends ng{constructor(t){super(Dd({style:rg.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 ae(t)?[t,1-t]:t}(i),function(t){return ae(t)?[t,-t]:t}(o),r);return $p(e,n,a)}getControlPoints(t,e,n,r,i){return 2===(null==i?void 0:i.length)?i:[Up(t,e,n[0],r[0]),Up(t,e,n[1],r[1])]}}rg.defaultStyleProps={curvePosition:.5,curveOffset:20};class ig extends rg{constructor(t){super(Dd({style:ig.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]]]}}ig.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};class og extends rg{constructor(t){super(Dd({style:og.defaultStyleProps},t))}get ref(){return this.context.model.getRootsData()[0]}getEndpoints(t){if(this.sourceNode.id===this.ref.id)return super.getEndpoints(t);const e=Qh(this.ref);return[this.sourceNode.getIntersectPoint(e,!0),this.targetNode.getIntersectPoint(e)]}toRadialCoordinate(t){const e=Qh(this.ref);return[Gh(t,e),qh(jh(t,e))]}getControlPoints(t,e,n,r){const[i,o]=this.toRadialCoordinate(t),[a]=this.toRadialCoordinate(e),s=a-i;return[[t[0]+(s*n[0]+r[0])*Math.cos(o),t[1]+(s*n[0]+r[0])*Math.sin(o)],[e[0]-(s*n[1]-r[0])*Math.cos(o),e[1]-(s*n[1]-r[0])*Math.sin(o)]]}}og.defaultStyleProps={curvePosition:.5,curveOffset:20};class ag extends rg{constructor(t){super(Dd({style:ag.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]]]}}ag.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};let sg=class t extends ng{constructor(e){super(Dd({style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};sg.defaultStyleProps={};const lg={enableObstacleAvoidance:!1,offset:10,maxAllowedDirectionChange:Math.PI/2,maximumLoops:3e3,gridSize:5,startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{right:{stepX:1,stepY:0},left:{stepX:-1,stepY:0},bottom:{stepX:0,stepY:1},top:{stepX:0,stepY:-1}},penalties:{0:0,90:0},distFunc:Vh},ug=t=>`${Math.round(t[0])}|||${Math.round(t[1])}`;function cg(t,e){const n=t=>Math.round(t/e);return ae(t)?n(t):t.map(n)}function hg(t,e){const n=e[0]-t[0],r=e[1]-t[1];return n||r?Math.atan2(r,n):0}function dg(t,e,n,r){const i=hg(t,e),o=n[ug(t)];return function(t,e){const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n}(hg(o||r,t),i)}function fg(t,e,n){return Math.min(...e.map((e=>n(t,e))))}const pg=(t,e,n,r)=>{if(!e)return[t];const{directionMap:i,offset:o}=r,a=Qc(e.getRenderBounds(),o),s=Object.keys(i).reduce(((e,r)=>{if(n.includes(r)){const n=i[r],[o,s]=Xc(a),l=[t[0]+n.stepX*o,t[1]+n.stepY*s],u=function(t){const{min:[e,n],max:[r,i]}=t,o=[e,i],a=[r,i],s=[r,n],l=[e,n];return[[o,a],[a,s],[s,l],[l,o]]}(a);for(let n=0;n<u.length;n++){const r=Kh([t,l],u[n]);r&&eh(r,a)&&e.push(r)}}return e}),[]);return th(t,a)||s.push(t),s.map((t=>cg(t,r.gridSize)))},gg=(t,e,n,r,i,o,a)=>{const s=[];let l=[o[0]===r[0]?r[0]:t[0]*a,o[1]===r[1]?r[1]:t[1]*a];s.unshift(l);let u=t,c=e[ug(u)];for(;c;){const t=c,r=u;dg(t,r,e,n)&&(l=[t[0]===r[0]?l[0]:t[0]*a,t[1]===r[1]?l[1]:t[1]*a],s.unshift(l)),c=e[ug(t)],u=t}const h=i.map((t=>[t[0]*a,t[1]*a])),d=function(t,e,n){let r=t[0],i=n(t[0],e);for(let o=0;o<t.length;o++){const a=t[o],s=n(a,e);s<i&&(r=a,i=s)}return r}(h,l,Vh);return s.unshift(d),s};function vg(t,e,n,r){const i=Uh(t.getCenter()),o=Uh(e.getCenter()),a=Object.assign(lg,r),{gridSize:s}=a,l=((t,e)=>{const{offset:n,gridSize:r}=e,i={};return t.forEach((t=>{if(!t||t.destroyed||!t.isVisible())return;const e=Qc(t.getRenderBounds(),n);for(let t=cg(e.min[0],r);t<=cg(e.max[0],r);t+=1)for(let n=cg(e.min[1],r);n<=cg(e.max[1],r);n+=1)i[`${t}|||${n}`]=!0})),i})(a.enableObstacleAvoidance?n:[t,e],a),u=cg(i,s),c=cg(o,s),h=pg(i,t,a.startDirections,a),d=pg(o,e,a.endDirections,a);h.forEach((t=>delete l[ug(t)])),d.forEach((t=>delete l[ug(t)]));const f={},p={},g={},v={},m={},y=new mg;for(let t=0;t<h.length;t++){const e=h[t],n=ug(e);f[n]=e,v[n]=0,m[n]=fg(e,d,a.distFunc),y.add({id:n,value:m[n]})}const b=d.map((t=>ug(t)));let x,E=a.maximumLoops,w=1/0;for(const[t,e]of Object.entries(f))m[t]<=w&&(w=m[t],x=e);for(;Object.keys(f).length>0&&E>0;){const t=y.minId(!1);if(!t)break;x=f[t];const e=ug(x);if(b.includes(e))return gg(x,g,u,o,h,c,s);delete f[e],y.remove(e),p[e]=!0;for(const t of Object.values(a.directionMap)){const n=Ih(x,[t.stepX,t.stepY]),r=ug(n);if(p[r])continue;const i=dg(x,n,g,u);if(i>a.maxAllowedDirectionChange)continue;if(l[r])continue;f[r]||(f[r]=n);const o=a.penalties[i],c=a.distFunc(x,n)+(isNaN(o)?s:o),h=v[e]+c,b=v[r];b&&h>=b||(g[r]=x,v[r]=h,m[r]=h+fg(n,d,a.distFunc),y.add({id:r,value:m[r]}))}E-=1}return[]}class mg{constructor(){this.arr=[],this.map={},this.arr=[],this.map={}}_innerAdd(t,e){let n=0,r=e-1;for(;r-n>1;){const e=Math.floor((n+r)/2);if(this.arr[e].value>t.value)r=e;else{if(!(this.arr[e].value<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n=e}}this.arr.splice(r,0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;if(!e||this.arr[e-1].value<t.value)return this.arr.push(t),void(this.map[t.id]=!0);this._innerAdd(t,e)}remove(t){this.map[t]&&delete this.map[t]}_clearAndGetMinId(){let t;for(let e=this.arr.length-1;e>=0;e--)this.map[this.arr[e].id]?t=this.arr[e].id:this.arr.splice(e,1);return t}_findFirstId(){for(;this.arr.length;){const t=this.arr.shift();if(this.map[t.id])return t.id}}minId(t){return t?this._clearAndGetMinId():this._findFirstId()}}class yg extends ng{constructor(t){super(Dd({style:yg.defaultStyleProps},t))}getControlPoints(t){const{router:e}=t,{sourceNode:n,targetNode:r}=this,[i,o]=this.getEndpoints(t,!1);let a=[];if(e)if("shortest-path"===e.type){a=vg(n,r,this.context.element.getNodes(),e),a.length||(a=Dp(i,o,n,r,t.controlPoints,{padding:e.offset}))}else"orth"===e.type&&(a=Dp(i,o,n,r,t.controlPoints,e));else a=t.controlPoints;return a}getPoints(t){const e=this.getControlPoints(t),[n,r]=this.getEndpoints(t,!0,e);return[n,...e,r]}getKeyPath(t){return qp(this.getPoints(t),t.radius)}getLoopPath(t){const{sourcePort:e,targetPort:n,radius:r}=t,i=this.sourceNode,o=Kc(i),a=Math.max($c(o),qc(o))/4,{placement:s,clockwise:l,dist:u=a}=Td(this.getGraphicStyle(t),"loop");return Zp(i,r,s,l,u,e,n)}}yg.defaultStyleProps={radius:0,controlPoints:[],router:!1};class bg extends ng{constructor(t){super(Dd({style:bg.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||Up(r,i,e,n))}}function xg(t){return t instanceof tf&&"node"===t.type}function Eg(t){return t instanceof ng}function wg(t){return t instanceof Ap}bg.defaultStyleProps={curvePosition:.5,curveOffset:30};const kg={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],default:[.5,.5]};function Mg(t,e,n=kg,r=!0){const i=[.5,.5],o=ne(e)?Oe(n,e.toLocaleLowerCase(),i):e;if(!r&&ne(e))return o;const[a,s]=o||i;return[t.min[0]+$c(t)*a,t.min[1]+qc(t)*s]}function Sg(t){if(!t)return{};const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{var i;const{key:o,placement:a}=n;Ng(n)&&(e[i=o||r]||(e[i]=td(t.getShape("key").getBounds(),a)))})),e}function Ng(t){const{r:e}=t;return!e||0===Number(e)}function Og(t){return Wc(t)?t:t.getPosition()}function Tg(t,e,n,r){const i=Sg(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>Og(t))),s=function(t,e){const n=Sg(t);if(e)return[Og(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>Og(t))):[t.getCenter()]}(e,r),[l]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=Gh(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>Og(t)===l))}function Ag(t,e){return wg(t)||xg(t)?Pg(t,e):Cg(t,e)}function Cg(t,e){if(!t||!e)return[0,0,0];if(Wc(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return ud(Wc(e)?e:xg(e)?e.getCenter():e.getPosition(),t.getBounds())}function Pg(t,e){if(!t||!e)return[0,0,0];const n=Wc(e)?e:xg(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function Rg(t,e="bottom",n=0,r=0,i=!1){const o=e.split("-"),[a,s]=td(t,e),l=o.includes("left")?"right":o.includes("right")?"left":"center";let u=o.includes("top")?"bottom":o.includes("bottom")?"top":"middle";return i&&(u="top"===u?"bottom":"bottom"===u?"top":u),{transform:[["translate",a+n,s+r]],textBaseline:u,textAlign:l}}function Dg(t,e){"update"in t?t.update(e):t.attr(e)}function Lg(t){return Oe(t,"__to_be_destroyed__",!1)}class _g extends Dh{constructor(t,e){super(t,Object.assign({},_g.defaultOptions,e)),this.onCollapseExpand=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{target:e}=t;if(!(xg(n=e)||Eg(n)||wg(n)))return;var n;const r=e.id,{model:i,graph:o}=this.context,a=i.getElementDataById(r);if(!a)return!1;const{onCollapse:s,onExpand:l,animation:u,align:c}=this.options;Sd(a)?(yield o.expandElement(r,{animation:u,align:c}),null==l||l(r)):(yield o.collapseElement(r,{animation:u,align:c}),null==s||s(r))})),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`node:${e}`,this.onCollapseExpand),t.on(`combo:${e}`,this.onCollapseExpand)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`node:${e}`,this.onCollapseExpand),t.off(`combo:${e}`,this.onCollapseExpand)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}_g.defaultOptions={enable:!0,animation:!0,trigger:t.CommonEvent.DBLCLICK,align:!0};const Ig="g6-create-edge-assist-node-id";class jg extends Dh{constructor(t,e){super(t,Object.assign({},jg.defaultOptions,e)),this.drop=t=>ze(this,void 0,void 0,(function*(){const{targetType:e}=t;["combo","node"].includes(e)&&this.source?yield this.handleCreateEdge(t):yield this.cancelEdge()})),this.handleCreateEdge=t=>ze(this,void 0,void 0,(function*(){var e,n,r;if(!this.validate(t))return;const{graph:i,canvas:o,batch:a,element:s}=this.context,{style:l}=this.options;if(this.source)return this.createEdge(t),void(yield this.cancelEdge());a.startBatch(),o.setCursor("crosshair"),this.source=this.getSelectedNodeIDs([t.target.id])[0];const u=i.getElementData(this.source);i.addNodeData([{id:Ig,style:{visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}],x:null===(e=u.style)||void 0===e?void 0:e.x,y:null===(n=u.style)||void 0===n?void 0:n.y}}]),i.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:Ig,style:Object.assign({pointerEvents:"none"},l)}]),yield null===(r=s.draw({animation:!1}))||void 0===r?void 0:r.finished})),this.updateAssistEdge=t=>ze(this,void 0,void 0,(function*(){var e;if(!this.source)return;const{model:n,element:r}=this.context;n.translateNodeTo(Ig,[t.canvas.x,t.canvas.y]),yield null===(e=r.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished})),this.createEdge=t=>{var e,n;const{graph:r}=this.context,{style:i,onFinish:o,onCreate:a}=this.options;if(void 0===(null===(e=t.target)||void 0===e?void 0:e.id)||void 0===this.source)return;const s=null===(n=this.getSelectedNodeIDs([t.target.id]))||void 0===n?void 0:n[0];var l;const u=a({id:`${this.source}-${s}-${De[l=l||"g"]?De[l]+=1:De[l]=1,l+De[l]}`,source:this.source,target:s,style:i});r.addEdgeData([u]),o(u)},this.cancelEdge=()=>ze(this,void 0,void 0,(function*(){var t;if(!this.source)return;const{graph:e,element:n,batch:r}=this.context;e.removeNodeData([Ig]),this.source=void 0,yield null===(t=n.draw({animation:!1}))||void 0===t?void 0:t.finished,r.endBatch()})),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context,{trigger:n}=this.options;this.unbindEvents(),"click"===n?(e.on(t.NodeEvent.CLICK,this.handleCreateEdge),e.on(t.ComboEvent.CLICK,this.handleCreateEdge),e.on(t.CanvasEvent.CLICK,this.cancelEdge),e.on(t.EdgeEvent.CLICK,this.cancelEdge)):(e.on(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.on(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.on(t.CommonEvent.POINTER_UP,this.drop)),e.on(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.CLICK,this.handleCreateEdge),e.off(t.ComboEvent.CLICK,this.handleCreateEdge),e.off(t.CanvasEvent.CLICK,this.cancelEdge),e.off(t.EdgeEvent.CLICK,this.cancelEdge),e.off(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.off(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.off(t.CommonEvent.POINTER_UP,this.drop),e.off(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}destroy(){this.unbindEvents(),super.destroy()}}jg.defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};class Bg extends Dh{constructor(t,e){super(t,Object.assign({},Bg.defaultOptions,e)),this.isDragging=!1,this.onDragStart=t=>{this.validate(t)&&(this.isDragging=!0,this.context.canvas.setCursor("grabbing"))},this.onDrag=t=>{if(!this.isDragging)return;const{x:e,y:n}=t.movement;e|n&&this.translate([e,n],!1)},this.onDragEnd=()=>{var t,e;this.isDragging=!1,this.context.canvas.setCursor(this.defaultCursor),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)},this.invokeOnFinish=ye((()=>{var t,e;null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)}),300),this.shortcut=new gd(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(qt(e)){const{up:t=[],down:n=[],left:r=[],right:i=[]}=e;this.shortcut.bind(t,(t=>this.onTranslate([0,1],t))),this.shortcut.bind(n,(t=>this.onTranslate([0,-1],t))),this.shortcut.bind(r,(t=>this.onTranslate([1,0],t))),this.shortcut.bind(i,(t=>this.onTranslate([-1,0],t)))}else{const{graph:e}=this.context;e.on(t.CommonEvent.DRAG_START,this.onDragStart),e.on(t.CommonEvent.DRAG,this.onDrag),e.on(t.CommonEvent.DRAG_END,this.onDragEnd)}}onTranslate(t,e){return ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;yield this.translate(Bh(t,r),this.options.animation),this.invokeOnFinish()}))}translate(t,e){return ze(this,void 0,void 0,(function*(){t=this.clampByDirection(t),t=this.clampByRange(t),yield this.context.graph.translateBy(t,e)}))}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[a,s,l,u]=Yc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return"function"==typeof e?e(t):!!e}unbindEvents(){this.shortcut.unbindAll();const{graph:e}=this.context;e.off(t.CommonEvent.DRAG_START,this.onDragStart),e.off(t.CommonEvent.DRAG,this.onDrag),e.off(t.CommonEvent.DRAG_END,this.onDragEnd)}destroy(){this.shortcut.destroy(),this.unbindEvents(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}Bg.defaultOptions={enable:t=>!("targetType"in t)||"canvas"===t.targetType,sensitivity:10,direction:"both",range:1/0};class Fg extends Dh{constructor(e,n){super(e,Object.assign({},Fg.defaultOptions,n)),this.enable=!1,this.enableElements=["node","combo"],this.target=[],this.shadowOrigin=[0,0],this.hiddenEdges=[],this.isDragging=!1,this.onDrop=t=>ze(this,void 0,void 0,(function*(){var e;if("link"!==this.options.dropEffect)return;const{model:n,element:r}=this.context,i=t.target.id;this.target.forEach((t=>{const e=n.getParentData(t,Ec);e&&yh(e)===i&&n.refreshComboData(i),n.setParent(t,i,Ec)})),yield null===(e=null==r?void 0:r.draw({animation:!0}))||void 0===e?void 0:e.finished})),this.setCursor=e=>{if(this.isDragging)return;const{type:n}=e,{canvas:r}=this.context,{cursor:i}=this.options;n===t.CommonEvent.POINTER_ENTER?r.setCursor((null==i?void 0:i.grab)||"grab"):r.setCursor((null==i?void 0:i.default)||"default")},this.onDragStart=this.onDragStart.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onDrop=this.onDrop.bind(this),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.addEventListener("blur",this.onDragEnd),r.addEventListener("contextmenu",this.onDragEnd)),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),e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)})),["link"].includes(this.options.dropEffect)&&(e.on(t.ComboEvent.DROP,this.onDrop),e.on(t.CanvasEvent.DROP,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}getDelta(t){const e=this.context.graph.getZoom();return Fh([t.dx,t.dy],e)}onDragStart(t){var e;if(this.enable=this.validate(t),!this.enable)return;const{batch:n,canvas:r,graph:i}=this.context;r.setCursor((null===(e=this.options.cursor)||void 0===e?void 0:e.grabbing)||"grabbing"),this.isDragging=!0,n.startBatch();const o=t.target.id;i.getElementState(o).includes(this.options.state)?this.target=this.getSelectedNodeIDs([o]):this.target=[o],this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target)}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.options.shadow?this.moveShadow(e):this.moveElement(this.target,e)}onDragEnd(){var t,e,n;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]=jh([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t,this.target);const{batch:r,canvas:i}=this.context;r.endBatch(),i.setCursor((null===(n=this.options.cursor)||void 0===n?void 0:n.grab)||"grab"),this.isDragging=!1,this.target=[]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}moveElement(t,e){return ze(this,void 0,void 0,(function*(){const{graph:n,model:r}=this.context,{dropEffect:i}=this.options;"move"===i&&t.forEach((t=>r.refreshComboData(t))),n.translateElementBy(Object.fromEntries(t.map((t=>[t,e]))),!1)}))}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=Td(this.options,"shadow"),n=Jc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Xc(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr(Object.assign(Object.assign(Object.assign({},e),s),{visibility:"visible"})):(this.shadow=new Xl({style:Object.assign(Object.assign(Object.assign({$layer:"transient"},e),s),{pointerEvents:"none"})}),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(yh):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(yh))).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.removeEventListener("blur",this.onDragEnd),r.removeEventListener("contextmenu",this.onDragEnd)),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(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)})),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){var t;this.unbindEvents(),null===(t=this.shadow)||void 0===t||t.destroy(),super.destroy()}}Fg.defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),dropEffect:"move",state:"selected",hideEdge:"none",shadow:!1,shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5],cursor:{default:"default",grab:"grab",grabbing:"grabbing"}};var zg=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 Gg(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 Vg(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)&&Vg(i,e,n,r))return!0;return!1}const Wg=()=>!0;class Hg{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||Wg,n=t.edgeFilter||Wg;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];Gg([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];Vg(this.getNode(t),new Set,e,r)}}let Yg=class t extends zg{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((n=>{n.childrenMap.get(t)?.forEach((t=>{n.parentMap.delete(t.id)}));const r=n.parentMap.get(t);r&&n.childrenMap.get(r.id)?.delete(e),n.parentMap.delete(t),n.childrenMap.delete(t)})),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.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);if(!r)return;const i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(null==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 Vg(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Gg([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 Gg([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 Vg(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 Hg({graph:this,...t})}};class Ug{constructor(t,e){this.context=t,this.options=e||{}}}function $g(t){const{nodes:e,edges:n}=t,r={nodes:[],edges:[],combos:[]};return e.forEach((t=>{const e=t.data._isCombo?r.combos:r.nodes,{x:n,y:i,z:o=0}=t.data;null==e||e.push({id:t.id,style:{x:n,y:i,z:o}})})),n.forEach((t=>{const{id:e,source:n,target:i,data:{points:o=[],controlPoints:a=o.slice(1,o.length-1)}}=t;r.edges.push({id:e,source:n,target:i,style:Object.assign({},(null==a?void 0:a.length)?{controlPoints:a.map(ed)}:{})})})),r}function qg(t,e,...n){if(e in t)return t[e](...n);if("instance"in t){const r=t.instance;if(e in r)return r[e](...n)}return null}function Xg(t,e){if(e in t)return t[e];if("instance"in t){const n=t.instance;if(e in n)return n[e]}return null}class Kg extends Fg{get forceLayoutInstance(){return this.context.layout.getLayoutInstance().find((t=>["d3-force","d3-force-3d"].includes(null==t?void 0:t.id)))}validate(t){return!!this.context.layout&&(this.forceLayoutInstance?super.validate(t):(Tc("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}moveElement(t,e){return ze(this,void 0,void 0,(function*(){const n=this.forceLayoutInstance;this.context.graph.getNodeData(t).forEach(((r,i)=>{const{x:o=0,y:a=0}=r.style||{};n&&qg(n,"setFixedPosition",t[i],[...Ih([+o,+a],e)])}))}))}onDragStart(t){if(this.enable=this.validate(t),!this.enable)return;this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target);const e=this.forceLayoutInstance;e&&Xg(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach((t=>{const{x:n=0,y:r=0}=t.style||{};e&&qg(e,"setFixedPosition",yh(t),[+n,+r])}))}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.moveElement(this.target,e)}onDragEnd(){const t=this.forceLayoutInstance;t&&Xg(t,"simulation").alphaTarget(0),this.options.fixed||this.context.graph.getNodeData(this.target).forEach((e=>{t&&qg(t,"setFixedPosition",yh(e),[null,null,null])}))}}class Zg extends Dh{constructor(t,e){super(t,Object.assign({},Zg.defaultOptions,e)),this.isZoomEvent=t=>Boolean(t.data&&"scale"in t.data),this.relatedEdgeToUpdate=new Set,this.zoom=this.context.graph.getZoom(),this.fixElementSize=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{graph:e}=this.context,{state:n,nodeFilter:r,edgeFilter:i,comboFilter:o}=this.options,a=(n?e.getElementDataByState("node",n):e.getNodeData()).filter(r),s=(n?e.getElementDataByState("edge",n):e.getEdgeData()).filter(i),l=(n?e.getElementDataByState("combo",n):e.getComboData()).filter(o),u=this.isZoomEvent(t)?this.zoom=Math.max(.01,Math.min(t.data.scale,10)):this.zoom,c=[...a,...l];c.length>0&&c.forEach((t=>this.fixNodeLike(t,u))),this.updateRelatedEdges(),s.length>0&&s.forEach((t=>this.fixEdge(t,u)))})),this.cachedStyles=new Map,this.getOriginalFieldValue=(t,e,n)=>{var r;const i=this.cachedStyles.get(t)||[],o=(null===(r=i.find((t=>t.shape===e)))||void 0===r?void 0:r.style)||{};return n in o||(o[n]=e.attributes[n],this.cachedStyles.set(t,[...i.filter((t=>t.shape!==e)),{shape:e,style:o}])),o[n]},this.scaleEntireElement=(t,e,n)=>{e.setLocalScale(1/n);const r=this.cachedStyles.get(t)||[];r.push({shape:e}),this.cachedStyles.set(t,r)},this.scaleSpecificShapes=(t,e,n)=>{const r=function(t){const e=[],n=t=>{(null==t?void 0:t.children.length)&&t.children.forEach((t=>{e.push(t),n(t)}))};return n(t),e}(t);(Array.isArray(n)?n:[n]).forEach((n=>{const{shape:i,fields:o}=n,a="function"==typeof i?i(r):t.getShape(i);a&&(o?o.forEach((n=>{const r=this.getOriginalFieldValue(t.id,a,n);ae(r)&&(a.style[n]=r/e)})):this.scaleEntireElement(t.id,a,e))}))},this.skipIfExceedViewport=t=>{const{viewport:e}=this.context;return!(null==e?void 0:e.isInViewport(t.getRenderBounds(),!1,30))},this.fixNodeLike=(t,e)=>{const n=yh(t),{element:r,model:i}=this.context,o=r.getElement(n);if(!o||this.skipIfExceedViewport(o))return;i.getRelatedEdgesData(n).forEach((t=>this.relatedEdgeToUpdate.add(yh(t))));const a=this.options[o.type];a?this.scaleSpecificShapes(o,e,a):this.scaleEntireElement(n,o,e)},this.fixEdge=(t,e)=>{const n=yh(t),r=this.context.element.getElement(n);if(!r||this.skipIfExceedViewport(r))return;const i=this.options.edge;if(!i)return r.style.transformOrigin="center",void this.scaleEntireElement(n,r,e);this.scaleSpecificShapes(r,e,i)},this.updateRelatedEdges=()=>{const{element:t}=this.context;this.relatedEdgeToUpdate.size>0&&this.relatedEdgeToUpdate.forEach((e=>{const n=t.getElement(e);null==n||n.update({})})),this.relatedEdgeToUpdate.clear()},this.resetTransform=t=>ze(this,void 0,void 0,(function*(){var e;(null===(e=t.data)||void 0===e?void 0:e.firstRender)||(this.options.reset?this.restoreCachedStyles():this.fixElementSize({data:{scale:this.zoom}}))})),this.bindEvents()}restoreCachedStyles(){if(this.cachedStyles.size>0){this.cachedStyles.forEach((t=>{t.forEach((({shape:t,style:e})=>{if(Se(e))t.setLocalScale(1);else{if(this.options.state)return;Object.entries(e).forEach((([e,n])=>t.style[e]=n))}}))}));const{graph:t,element:e}=this.context,n=Object.keys(Object.fromEntries(this.cachedStyles)).filter((e=>e&&"node"===t.getElementType(e)));if(n.length>0){const r=new Set;n.forEach((e=>{t.getRelatedEdgesData(e).forEach((t=>r.add(yh(t))))})),r.forEach((t=>{const n=null==e?void 0:e.getElement(t);null==n||n.update({})}))}}}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.on(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.off(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Zg.defaultOptions={enable:t=>t.data.scale<1,nodeFilter:()=>!0,edgeFilter:()=>!0,comboFilter:()=>!0,edge:[{shape:"key",fields:["lineWidth"]},{shape:"halo",fields:["lineWidth"]},{shape:"label"}],reset:!1};class Qg extends Dh{constructor(t,e){super(t,Object.assign({},Qg.defaultOptions,e)),this.focus=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{graph:e}=this.context;yield e.focusElement(t.target.id,this.options.animation)})),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),bd.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;bd.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}destroy(){this.unbindEvents(),super.destroy()}}Qg.defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};class Jg extends Dh{constructor(e,n){super(e,Object.assign({},Jg.defaultOptions,n)),this.isFrozen=!1,this.toggleFrozen=t=>{this.isFrozen="dragstart"===t.type},this.hoverElement=e=>{if(!this.validate(e))return;const n=e.type===t.CommonEvent.POINTER_ENTER;this.updateElementsState(e,n);const{onHover:r,onHoverEnd:i}=this.options;n?null==r||r(e):null==i||i(e)},this.updateElementsState=(t,e)=>{if(!this.options.state&&!this.options.inactiveState)return;const{graph:n}=this.context,{state:r,animation:i,inactiveState:o}=this.options,a=this.getActiveIds(t),s={};if(r&&Object.assign(s,this.getElementsState(a,r,e)),o){const t=xh(n.getData(),!0).filter((t=>!a.includes(t)));Object.assign(s,this.getElementsState(t,o,e))}n.setElementState(s,i)},this.getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach((t=>{const o=r.getElementState(t);i[t]=n?o.includes(e)?o:[...o,e]:o.filter((t=>t!==e))})),i},this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),bd.forEach((n=>{e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)}));const n=this.context.canvas.document;n.addEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.addEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}getActiveIds(t){const{graph:e}=this.context,{degree:n,direction:r}=this.options,i=t.target.id;return n?Ed(e,t.targetType,i,"function"==typeof n?n(t):n,r):[i]}validate(t){if(this.destroyed||this.isFrozen||Lg(t.target)||this.context.graph.isCollapsingExpanding)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;bd.forEach((n=>{e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)}));const n=this.context.canvas.document;n.removeEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.removeEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}destroy(){this.unbindEvents(),super.destroy()}}Jg.defaultOptions={animation:!1,enable:!0,degree:0,direction:"both",state:"active",inactiveState:void 0};class tv extends vd{onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e}=this.context;this.pathShape=new Hl({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[md(t)]}onPointerMove(t){var e;if(!this.points)return;const{immediately:n,mode:r}=this.options;this.points.push(md(t)),null===(e=this.pathShape)||void 0===e||e.setAttribute("d",function(t,e=!0){const n=[];return t.forEach(((t,e)=>{n.push([0===e?"M":"L",...t])})),e&&n.push(["Z"]),n}(this.points)),n&&"default"===r&&this.points.length>2&&super.updateElementsStates(this.points)}onPointerUp(){this.points&&(this.points.length<2||super.updateElementsStates(this.points),this.clearLasso())}clearLasso(){var t;null===(t=this.pathShape)||void 0===t||t.remove(),this.pathShape=void 0,this.points=void 0}}class ev extends Dh{constructor(t,e){super(t,Object.assign({},ev.defaultOptions,e)),this.hiddenShapes=[],this.isVisible=!0,this.setElementsVisibility=(t,e,n)=>{t.filter(Boolean).forEach((t=>{"hidden"!==e||t.isVisible()?"visible"===e&&this.hiddenShapes.includes(t)?this.hiddenShapes.splice(this.hiddenShapes.indexOf(t),1):Ch(t,e,n):this.hiddenShapes.push(t)}))},this.filterShapes=(t,e)=>{if(Yt(e))return n=>!e(t,n);const n=null==e?void 0:e[t];return t=>!t.className||!(null==n?void 0:n.includes(t.className))},this.hideShapes=t=>{if(!this.validate(t)||!this.isVisible)return;const{element:e}=this.context,{shapes:n={}}=this.options;this.setElementsVisibility(e.getNodes(),"hidden",this.filterShapes("node",n)),this.setElementsVisibility(e.getEdges(),"hidden",this.filterShapes("edge",n)),this.setElementsVisibility(e.getCombos(),"hidden",this.filterShapes("combo",n)),this.isVisible=!1},this.showShapes=ye((t=>{if(!this.validate(t)||this.isVisible)return;const{element:e}=this.context;this.setElementsVisibility(e.getNodes(),"visible"),this.setElementsVisibility(e.getEdges(),"visible"),this.setElementsVisibility(e.getCombos(),"visible"),this.isVisible=!0}),this.options.debounce),this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.on(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.off(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}ev.defaultOptions={enable:!0,debounce:200,shapes:t=>"node"===t};class nv extends Dh{constructor(t,e){super(t,Object.assign({},nv.defaultOptions,e)),this.onWheel=t=>ze(this,void 0,void 0,(function*(){this.options.preventDefault&&t.preventDefault();const e=t.deltaX,n=t.deltaY;yield this.scroll([-e,-n],t)})),this.shortcut=new gd(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e,n;const{trigger:r}=this.options;if(this.shortcut.unbindAll(),qt(r)){null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel);const{up:n=[],down:i=[],left:o=[],right:a=[]}=r;this.shortcut.bind(n,(t=>this.scroll([0,-10],t))),this.shortcut.bind(i,(t=>this.scroll([0,10],t))),this.shortcut.bind(o,(t=>this.scroll([-10,0],t))),this.shortcut.bind(a,(t=>this.scroll([10,0],t)))}else null===(n=this.graphDom)||void 0===n||n.addEventListener(t.CommonEvent.WHEEL,this.onWheel,{passive:!1})}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}formatDisplacement(t){const{sensitivity:e}=this.options;return t=Bh(t,e),t=this.clampByDirection(t),t=this.clampByRange(t)}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[a,s,l,u]=Yc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}scroll(t,e){return ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{onFinish:n}=this.options,r=this.context.graph,i=this.formatDisplacement(t);yield r.translateBy(i,!1),null==n||n()}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel),super.destroy()}}nv.defaultOptions={enable:!0,sensitivity:1,preventDefault:!0,range:1/0};class rv extends Dh{constructor(t,e){super(t,Object.assign({},rv.defaultOptions,e)),this.zoom=(t,e,n)=>ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{graph:r}=this.context;let i;"viewport"in e&&(i=ed(e.viewport));const{sensitivity:o,onFinish:a}=this.options,s=1+oe(t,-50,50)*o/100,l=r.getZoom();yield r.zoomTo(l*s,n,i),null==a||a()})),this.onReset=()=>ze(this,void 0,void 0,(function*(){yield this.context.graph.zoomTo(1,this.options.animation)})),this.preventDefault=t=>{this.options.preventDefault&&t.preventDefault()},this.shortcut=new gd(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e;const{trigger:n}=this.options;if(this.shortcut.unbindAll(),Array.isArray(n)&&(null===(e=this.context.canvas.getContainer())||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,this.preventDefault),this.shortcut.bind([...n,t.CommonEvent.WHEEL],(t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(null!=n?n:e),t,!1)}))),"object"==typeof n){const{zoomIn:t=[],zoomOut:e=[],reset:r=[]}=n;this.shortcut.bind(t,(t=>this.zoom(10,t,this.options.animation))),this.shortcut.bind(e,(t=>this.zoom(-10,t,this.options.animation))),this.shortcut.bind(r,this.onReset)}}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.context.canvas.getContainer())||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.preventDefault),super.destroy()}}rv.defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[],preventDefault:!0};var iv={assign:Object.assign,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},ov=iv,av={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 sv(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof sv)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}ov.assign(sv.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 lv=function(t,e,n){void 0===e&&(e={});var r,i=new sv(t,e=ov.assign({},av,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 l=0;l<s;l++){var u=new sv(a[l],e);r.children[l]=u,o.push(u),u.parent=r,u.depth=r.depth+1}}return i},uv=lv,cv=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=uv(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),hv=cv;function dv(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 fv(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){fv(t,e,n)}))}function pv(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(pv(t,e),n)})),n}function gv(t,e){fv(t,-pv(t,e),e)}function vv(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){vv(t,e.children[r],n)}))}function mv(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){mv(t,e,n)}))}dv.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(dv.fromNode(t,e))})),e?new dv(t.height,t.width,t.x,n):new dv(t.width,t.height,t.y,n)};var yv=lv,bv=function(t,e){for(var n=yv(t.data,e,!0),r=yv(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 l=t.children[s];"right"===a(l,s)?r.children.push(l):n.children.push(l)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},xv=bv,Ev=["LR","RL","TB","BT","H","V"],wv=["LR","RL","H"],kv=Ev[0],Mv=function(t,e,n){var r=e.direction||kv;if(e.isHorizontal=function(t){return wv.indexOf(t)>-1}(r),-1===Ev.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===Ev[0])n(t,e);else if(r===Ev[1])n(t,e),t.right2left();else if(r===Ev[2])n(t,e);else if(r===Ev[3])n(t,e),t.bottom2top();else if(r===Ev[4]||r===Ev[5]){var i=xv(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 l=e.fixedRoot;return void 0===l&&(l=!0),l&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){var n=e.isHorizontal?["x","y"]:["y","x"],r=n[0],i=n[1],o={x:1/0,y:1/0},a={x:-1/0,y:-1/0},s=0;t.DFTraverse((function(t){s++;var e=t.x,n=t.y;o.x=Math.min(o.x,e),o.y=Math.min(o.y,n),a.x=Math.max(a.x,e),a.y=Math.max(a.y,n)}));var l=a[i]-o[i];if(0===l)return;var u=2*Math.PI/s;t.DFTraverse((function(e){var n=(e[i]-o[i])/l*(2*Math.PI-u)+u,a=e[r]-t[r];e.x=Math.cos(n)*a,e.y=Math.sin(n)*a}))}}(t,e),t};function Sv(t,e){return Sv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Sv(t,e)}var Nv=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,u=t.c[e],c=u.mod;null!==r&&null!==u;){l(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(c+u.prelim);h>0&&(c+=h,o(t,e,n.index,h));var d=l(r),f=l(u);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(u=a(u))&&(c+=u.mod)}!r&&u?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,u,c):r&&!u&&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 l(t){return t.y+t.h}function u(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}mv(t,n);var c=dv.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=u(l(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=l(e.c[o].er);i(e,o,n),n=u(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)}(c),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)}(c,0),vv(c,t,n),gv(t,n),t},Ov=Mv,Tv=iv,Av=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Sv(n,r),e.prototype.execute=function(){return Ov(this.rootNode,this.options,Nv)},e}(hv),Cv={};var Pv=function(t,e){return e=Tv.assign({},Cv,e),new Av(t,e).execute()},Rv=iv;function Dv(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 Lv={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function _v(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){_v(t,e.children[r],n)}))}function Iv(t,e){return Iv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Iv(t,e)}var jv=function(t,e){void 0===e&&(e={}),e=Rv.assign({},Lv,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 Dv(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),_v(i,t,e.isHorizontal),t},Bv=Mv,Fv=iv,zv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Iv(n,r),e.prototype.execute=function(){var t=this;return t.rootNode.width=0,Bv(t.rootNode,t.options,jv)},e}(hv),Gv={};var Vv=function(t,e){return e=Fv.assign({},Gv,e),new zv(t,e).execute()},Wv=iv;function Hv(t,e){return Hv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Hv(t,e)}var Yv=hv,Uv=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+Wv.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+Wv.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},$v=bv,qv=iv,Xv=["LR","RL","H"],Kv=Xv[0],Zv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Hv(n,r),e.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?Kv:a,l=t.align;if(s&&-1===Xv.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Xv[0])Uv(e,r,o,l);else if(s===Xv[1])Uv(e,r,o,l),e.right2left();else if(s===Xv[2]){var u=$v(e,t),c=u.left,h=u.right;Uv(c,r,o,l),c.right2left(),Uv(h,r,o,l);var d=c.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},e}(Yv),Qv={};var Jv=function(t,e){return e=qv.assign({},Qv,e),new Zv(t,e).execute()},tm=iv;function em(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=em(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function nm(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){nm(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 rm={getSubTreeSep:function(){return 0}};function im(t,e){return im=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},im(t,e)}var om=function(t,e){void 0===e&&(e={}),e=tm.assign({},rm,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,em(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}}}})),nm(t)},am=Mv,sm=iv,lm=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,im(n,r),e.prototype.execute=function(){return am(this.rootNode,this.options,om)},e}(hv),um={};var cm=function(t,e){return e=sm.assign({},um,e),new lm(t,e).execute()},hm={compactBox:Pv,dendrogram:Vv,indented:Jv,mindmap:cm};const dm=(t,e)=>{if("next"!==t&&"prev"!==t)return e},fm=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let pm=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 fm(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&fm(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,dm)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},gm=class extends pm{};const vm=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)mm(t,e,n,a);for(;a=i.dequeue();)mm(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(mm(t,e,n,a,!0));break}}return r},mm=(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,bm(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,bm(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},ym=(t,e)=>{const n=new Yg;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 gm);const s=r+1;return n.getAllNodes().forEach((t=>{bm(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},bm=(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)},xm=(t,e)=>{const n="greedy"===e?((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=ym(t,e);return null===(n=vm(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)):Em(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)})}))},Em=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},wm=(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},km=t=>{const e=new Yg;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},Mm=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let a,s,l=Number(t.width)/2,u=Number(t.height)/2;return i||o?(Math.abs(o)*l>Math.abs(i)*u?(o<0&&(u=-u),a=u*i/o,s=u):(i<0&&(l=-l),a=l,s=l*o/i),{x:n+a,y:r+s}):{x:0,y:0}},Sm=t=>{const e=[],n=Om(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},Nm=(t,e,n,r)=>{const i={width:0,height:0};return ae(n)&&ae(r)&&(i.rank=n,i.order=r),wm(t,"border",i,e)},Om=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},Tm=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),Am=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>Am(t,e,n,r,i,o))),n&&o.push(e.id))},Cm=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>t.getNeighbors(e),a=[],s=[];return i.forEach((e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);Am(t,e,"post"===n,s,o,a)})),a},Pm=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],l=wm(t,"border",a,n);i.data[e][o]=l,t.setParent(l,r),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:l,data:{weight:1}})},Rm=t=>{t.getAllNodes().forEach((t=>{Dm(t)})),t.getAllEdges().forEach((t=>{Dm(t)}))},Dm=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},Lm=t=>{t.getAllNodes().forEach((t=>{_m(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>_m(t))),t.data.hasOwnProperty("y")&&_m(t.data)}))},_m=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},Im=t=>{t.getAllNodes().forEach((t=>{jm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>jm(t))),t.data.hasOwnProperty("x")&&jm(t.data)}))},jm=t=>{const e=t.x;t.x=t.y,t.y=e},Bm=(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 l=Nm(t,"_bt"),u=Nm(t,"_bb"),c=t.getNode(a);t.setParent(l,a),c.data.borderTop=l,t.setParent(u,a),c.data.borderBottom=u,null==s||s.forEach((s=>{Bm(t,e,n,r,i,o,s.id);const c=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=c!==h?1:i-o[a]+1;t.addEdge({id:`e${Math.random()}`,source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:h,target:u,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:l,data:{weight:0,minlen:i+o[a]}})},Fm=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},zm=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Gm="edge-label",Vm=(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 l,u,c;for(t.removeEdge(e.id),c=0,++i;i<a;++c,++i)e.data.points=[],u={originalEdge:e,width:0,height:0,rank:i},l=wm(t,"edge",u,"_d"),i===s&&(u.width=e.data.width,u.height=e.data.height,u.dummy=Gm,u.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:l,data:{weight:e.data.weight}}),0===c&&n.push(l),r=l;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},Wm=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},Hm=(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 l=Array(s).fill(0,0,s);let u=0;return null==o||o.forEach((t=>{if(t){let e=t.pos+a;l[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=l[e+1]),e=e-1>>1,l[e]+=t.weight;u+=t.weight*n}})),u},Ym=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=Hm(t,e[r-1],e[r]);return n},Um=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},$m=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)&&qm(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}))},qm=(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},Xm=(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},Km=(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},Zm=(t,e,n,r,i,o)=>{var a,s,l,u;let c=t.getChildren(e).map((t=>t.id));const h=t.getNode(e),d=h?h.data.borderLeft:void 0,f=h?h.data.borderRight:void 0,p={};d&&(c=null==c?void 0:c.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,c||[]);null==g||g.forEach((e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=Zm(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&Jm(e,i)}}));const v=((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 $m(a)})(g,n);Qm(v,p),null===(a=v.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 m=((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 l=0,u=0,c=0;null==o||o.sort(Km(!!e,!!n)),c=Xm(s,a,c),null==o||o.forEach((t=>{var e;c+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),l+=t.barycenter*t.weight,u+=t.weight,c=Xm(s,a,c)}));const h={vs:s.flat()};return u&&(h.barycenter=l/u,h.weight=u),h})(v,r,i,o);if(d&&(m.vs=[d,m.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){const e=t.getNode((null===(l=t.getPredecessors(d))||void 0===l?void 0:l[0].id)||""),n=t.getNode((null===(u=t.getPredecessors(f))||void 0===u?void 0:u[0].id)||"");m.hasOwnProperty("barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+e.data.order+n.data.order)/(m.weight+2),m.weight+=2}return m},Qm=(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()}))},Jm=(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)},ty=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Wm(t),i=new Yg({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))),ey=(t,e,n,r)=>{const i=new Yg;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Zm(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)}))},ny=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,n)=>{t.getNode(e).data.order=n}))}))},ry=(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 l=((t,e,n,r)=>{var i,o;const a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);let c,h;c=n;do{c=null===(i=t.getParent(c))||void 0===i?void 0:i.id,a.push(c)}while(c&&(e[c].low>l||u>e[c].lim));for(h=c,c=r;c&&c!==h;)s.push(c),c=null===(o=t.getParent(c))||void 0===o?void 0:o.id;return{lca:h,path:a.concat(s.reverse())}})(t,n,s.source,s.target),u=l.path,c=l.lca;let h=0,d=u[h],f=!0;for(;o!==s.target;){if(a=t.getNode(o),f){for(;d!==c&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)h++,d=u[h];d===c&&(f=!1)}if(!f){for(;h<u.length-1&&(null===(i=t.getNode(u[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=u[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},iy=(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,l;let u;for(let c=r;c<i;c++)u=e[c],(null===(s=t.getNode(u))||void 0===s?void 0:s.data.dummy)&&(null===(l=t.getPredecessors(u))||void 0===l||l.forEach((e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&ay(n,e.id,u)})))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,a=0;const s=new Map;return null==n||n.forEach(((l,u)=>{var c;if("border"===(null===(c=t.getNode(l))||void 0===c?void 0:c.data.dummy)){const e=t.getPredecessors(l)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,a,u,o,i],s),a=u,o=i)}r([n,a,n.length,i,e.length],s)})),n};return(null==e?void 0:e.length)&&e.reduce(i),n},oy=(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))},ay=(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},sy=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},ly=(t,e,n,r,i,o)=>{const a=new Yg,s=uy(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],l=a.getRelatedEdges(o,"out").find((t=>t.target===i));l?a.updateEdgeData(l.id,Object.assign(Object.assign({},l.data),{weight:Math.max(s(t,e,r),l.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 uy=(t,e,n)=>(r,i,o)=>{const a=r.getNode(i),s=r.getNode(o);let l=0,u=0;if(l+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":u=-a.data.width/2;break;case"r":u=a.data.width/2}if(u&&(l+=n?u:-u),u=0,l+=(a.data.dummy?e:t)/2,l+=(s.data.dummy?e:t)/2,l+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":u=s.data.width/2;break;case"r":u=-s.data.width/2}return u&&(l+=n?u:-u),u=0,l},cy=(t,e)=>t.getNode(e).data.width||0,hy=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e,o=Sm(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,l)=>{var u;const c=oy(t,e),h=c?t.getNode(c.id).data.order:a;(c||e===s)&&(null===(u=r.slice(o,l+1))||void 0===u||u.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||h<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||ay(n,r.id,e)}))})),o=l+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),iy(t,o)),s={};let l=[];["u","d"].forEach((e=>{l="u"===e?o:Object.values(o).reverse(),["l","r"].forEach((n=>{"r"===n&&(l=l.map((t=>Object.values(t).reverse())));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),u=((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 l=Math.floor(r),u=Math.ceil(r);l<=u;++l){const r=s[l];o[t]===t&&e<a[r]&&!sy(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=a[r])}}}))})),{root:i,align:o}})(0,l,a,o),c=((t,e,n,r,i,o,a)=>{var s;const l={},u=ly(t,e,n,i,o,a),c=a?"borderLeft":"borderRight",h=(t,e)=>{let n=u.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 h((t=>{l[t]=(u.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(l[e.source]||0)+e.data.weight)),0)}),u.getPredecessors.bind(u)),h((e=>{const n=(u.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(l[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==c&&(l[e]=Math.max(l[e],n))}),u.getSuccessors.bind(u)),null===(s=Object.values(r))||void 0===s||s.forEach((t=>{l[t]=l[n[t]]})),l})(t,l,u.root,u.align,r,i,"r"===n);"r"===n&&Object.keys(c).forEach((t=>c[t]=-c[t])),s[e+n]=c}))}));const u=((t,e)=>Tm(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=cy(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i})))(t,s);return u&&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 l;if(s===e)return;const u=Object.values(s);l="l"===o?r-Math.min(...u):i-Math.max(...u),l&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+l})))}))}))}(s,u),((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)},dy=(t,e)=>{var n;const r=km(t);((t,e)=>{const{ranksep:n=0}=e,r=Sm(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=hy(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},fy=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)))},py=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,gy=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||py(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},vy=(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&&py(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},my=(t,e)=>Tm(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?py(e,n):1/0)),yy=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},by=t=>{const e=(t=>{const e=new Yg;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);fy(e);const n=(t=>{const e=new Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);gy(e,t)<r;)i=my(e,t),o=e.hasNode(i.source)?py(t,i):-py(t,i),yy(e,t,o);return e})(e);let r,i;for(ky(n),xy(n,e);r=Sy(n);)i=Ny(n,e,r),Oy(n,e,r,i)},xy=(t,e)=>{let n=Cm(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{Ey(t,e,n)}))},Ey=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=wy(t,e,n)},wy=(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,l=e.data.weight;if(a+=r?l:-l,Ay(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},ky=(t,e=t.getAllNodes()[0].id)=>{My(t,{},1,e)},My=(t,e,n,r,i)=>{var o;const a=n;let s=n;const l=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((n=>{e[n.id]||(s=My(t,e,s,n.id,r))})),l.data.low=a,l.data.lim=s++,i?l.data.parent=i:delete l.data.parent,s},Sy=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),Ny=(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,l=!1;o.data.lim>a.data.lim&&(s=a,l=!0);const u=e.getAllEdges().filter((e=>l===Cy(t.getNode(e.source),s)&&l!==Cy(t.getNode(e.target),s)));return Tm(u,(t=>py(e,t)))},Oy=(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:{}}),ky(t),xy(t,e),Ty(t,e)},Ty=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=Cm(t,n,"pre");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))}))},Ay=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),Cy=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,Py=fy,Ry=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 Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);vy(e,t)<r;)i=my(e,t),o=e.hasNode(i.source)?py(t,i):-py(t,i),yy(e,t,o)})(t)},Dy=t=>{by(t)},Ly=(t,e)=>{const{acyclicer:n,ranker:r,rankdir:i="tb",nodeOrder:o,keepNodeOrder:a,align:s,nodesep:l=50,edgesep:u=20,ranksep:c=50}=e;Qy(t),xm(t,n);const{nestingRoot:h,nodeRankFactor:d}=(t=>{const e=wm(t,"root",{},"_root"),n=Fm(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=zm(t)+1;return t.getRoots().forEach((r=>{Bm(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":Dy(t);break;case"tight-tree":default:Ry(t);break;case"longest-path":Py(t)}})(km(t),r),Hy(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,h),(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),Yy(t),Uy(t);const f=[];((t,e)=>{t.getAllEdges().forEach((n=>Vm(t,n,e)))})(t,f),ry(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)Pm(t,"borderLeft","_bl",n,i,e),Pm(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)})).map((t=>t.data.rank)),r=Math.max(...n),i=[];for(let t=0;t<r+1;t++)i[t]=[];null==e||e.forEach((e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=i[n.data.rank].length,i[n.data.rank].push(e)))}))})(t,o),((t,e)=>{const n=Om(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=ty(t,r,"in"),a=ty(t,i,"out");let s=Um(t);ny(t,s);let l,u=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){ey(n%2?o:a,n%4>=2,!1,e),s=Sm(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}s=Um(t),ny(t,s);for(let n=0,r=0;r<4;++n,++r){ey(n%2?o:a,n%4>=2,!0,e),s=Sm(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}ny(t,l)})(t,a),Jy(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||Rm(t)})(t,i),dy(t,{align:s,nodesep:l,edgesep:u,ranksep:c}),tb(t),Zy(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===Gm&&(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),Xy(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||Lm(t),"lr"!==n&&"rl"!==n||(Im(t),Rm(t))})(t,i);const{width:p,height:g}=$y(t);return qy(t),Ky(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}},_y=(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}))},Iy=(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)}))},jy=["width","height","layer","fixorder"],By={width:0,height:0},Fy=["minlen","weight","width","height","labeloffset"],zy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Gy=["labelpos"],Vy=t=>{const e=new Yg({tree:[]});return t.getAllNodes().forEach((n=>{const r=nb(t.getNode(n.id).data),i=Object.assign(Object.assign({},By),r),o=eb(i,jy);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);Ut(a)||(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((n=>{const r=nb(t.getEdge(n.id).data),i={};null==Gy||Gy.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},zy,eb(r,Fy),i)})})),e},Wy=(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},Hy=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};wm(t,"edge-proxy",r,"_ep")}}))},Yy=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},Uy=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))}))},$y=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}={},l=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,l=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(l)||(void 0===r&&(r=a-l/2),r=Math.min(r,a-l/2),o=Math.max(o,a+l/2))};return t.getAllNodes().forEach((t=>{l(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&l(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}},qy=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(Mm(n.data,i)),e.data.points.push(Mm(r.data,o))}))},Xy=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}}))},Ky=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Zy=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]),l=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==l?void 0:l.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)}))},Qy=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)}}))},Jy=t=>{const e=Sm(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=>{wm(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},tb=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}}))},eb=(t,e)=>{const n={};return null==e||e.forEach((e=>{void 0!==t[e]&&(n[e]=+t[e])})),n},nb=(t={})=>{const e={};return Object.keys(t).forEach((n=>{e[n.toLowerCase()]=t[n]})),e},rb=Array.isArray,ib=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},ob=(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:e,target:n}=t,r=o[e],a=o[n];void 0!==r&&void 0!==a&&(i[r][a]=1,i[a][r]=1)})),i},ab=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),sb=(t,e,n,r="TB",i,o={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=o;for(let l=0;l<e.length;l++){const u=e[l];if(t.hasNode(u.id)&&!(null==a?void 0:a(u))){if(null==s?void 0:s(u))return;"TB"===r&&n(u),sb(t,t.getChildren(u.id,i),n,r,i,o),"TB"!==r&&n(u)}}},lb=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=>lb(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=lb(t[n])})),e}return t},ub=(t,e)=>{const n=lb(t);return n.data=n.data||{},e&&(ae(n.data.x)||(n.data.x=Math.random()*e[0]),ae(n.data.y)||(n.data.y=Math.random()*e[1])),n};function cb(t){if(!t)return[0,0,0];if(ae(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}function hb(t,e){let n;return n=Yt(e)?e:ae(e)?()=>e:()=>t,n}function db(t,e,n=!0){return e||0===e?Yt(e)?e:ae(e)?()=>e:Array.isArray(e)?()=>n?Math.max(...e)||t:e:qt(e)&&e.width&&e.height?()=>n?Math.max(e.width,e.height)||t:[e.width,e.height]:()=>t:e=>{const{size:r}=e.data||{};return r?Array.isArray(r)?n?Math.max(...r)||t:r:qt(r)&&r.width&&r.height?n?Math.max(r.width,r.height)||t:[r.width,r.height]:r:t}}const fb=(t,e,n=10)=>{let r;const i="function"==typeof e?e:()=>e||0;r=t?Array.isArray(t)?e=>t:Yt(t)?t:e=>t:t=>{var e,r,i;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return null===(r=t.data)||void 0===r?void 0:r.bboxSize;if(null===(i=t.data)||void 0===i?void 0:i.size){const e=t.data.size;return Array.isArray(e)?e:qt(e)?[e.width,e.height]:e}return n};return t=>{const e=r(t),n=i(t);return Math.max(...cb(e))+n}},pb={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class gb{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},pb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,e)}))}genericDagreLayout(t,e,n){return ze(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:l,ranksepFunc:u,nodesepFunc:c,edgeLabelSpace:h,ranker:d,nodeOrder:f,begin:p,controlPoints:g,radial:v,sortByCombo:m,preset:y}=r,b=new Yg({tree:[]}),x=hb(s||50,u),E=hb(l||50,c);let w=E,k=x;"LR"!==a&&"RL"!==a||(w=x,k=E);const M=db(10,i,!1),S=e.getAllNodes(),N=e.getAllEdges();let O;S.forEach((t=>{const e=cb(M(t)),n=k(t),r=w(t),i=e[0]+2*r,o=e[1]+2*n,a=t.data.layer;ae(a)?b.addNode({id:t.id,data:{width:i,height:o,layer:a}}):b.addNode({id:t.id,data:{width:i,height:o}})})),m&&(b.attachTreeStructure("combo"),S.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}))),N.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)&&(O=new Yg({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&_y(t,i);const s=Vy(t);let l;n&&(e.ranksep=Wy(s,{rankdir:o,ranksep:a}));try{l=Ly(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}Iy(t,s)})(b,{prevGraph:O,edgeLabelSpace:h,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:l,align:o});const T=[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)}))})),T[0]=p[0]-t,T[1]=p[1]-e}const A="LR"===a||"RL"===a;if(v);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+T[0],e.data.y=e.data.y+T[1],t.add(A?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=A?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=A?(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;h&&g&&"loop"!==t.data.type&&(t.data.controlPoints=vb(null===(o=t.data.points)||void 0===o?void 0:o.map((({x:t,y:e})=>({x:t+T[0],y:e+T[1]}))),b.getNode(t.source),b.getNode(t.target),n,A,r,i))}))}let C=[];C=b.getAllNodes().map((t=>ub(t)));const P=b.getAllEdges();t&&(C.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),P.forEach((t=>{e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:C,edges:P}}))}}const vb=(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:l}=e.data,{x:u,y:c}=n.data;if(i&&(t=e.data.y,l=e.data.x,u=n.data.y,c=n.data.x),c!==l&&t!==u){const h=r.indexOf(l),d=r[h+1];if(d){const t=s[0],e=i?{x:(l+d)/2,y:(null==t?void 0:t.y)||u}:{x:(null==t?void 0:t.x)||u,y:(l+d)/2};t&&!o(t,e)||s.unshift(e)}const f=r.indexOf(c),p=Math.abs(f-h);if(1===p)s=a(s,e.data,n.data),s.length||s.push(i?{x:(l+c)/2,y:t}:{x:t,y:(l+c)/2});else if(p>1){const e=r[f-1];if(e){const n=s[s.length-1],r=i?{x:(c+e)/2,y:(null==n?void 0:n.y)||u}:{x:(null==n?void 0:n.x)||t,y:(c+e)/2};n&&!o(n,r)||s.push(r)}}}}return s},mb=(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}}},yb={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class bb{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},yb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,e)}))}genericCircularLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,divisions:s,startAngle:l=0,endAngle:u=2*Math.PI,angleRatio:c,ordering:h,clockwise:d,nodeSpacing:f,nodeSize:p}=r,g=e.getAllNodes(),v=e.getAllEdges(),[m,y,b]=Eb(i,o,a),x=null==g?void 0:g.length;if(!x||1===x)return mb(e,t,b);const E=(u-l)/x;let{radius:w,startRadius:k,endRadius:M}=r;if(f){const t=hb(10,f),e=db(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)})),w=r/(2*Math.PI)}else w||k||M?!k&&M?k=M:k&&!M&&(M=k):w=Math.min(y,m)/2;const S=E*c;let N=[];N="topology"===h?xb(e,g):"topology-directed"===h?xb(e,g,!0):"degree"===h?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(ub(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>ub(t)));const O=Math.ceil(x/s);for(let t=0;t<x;++t){let e=w;e||null===k||null===M||(e=k+t*(M-k)/(x-1)),e||(e=10+100*t/(x-1));let n=l+t%O*S+2*Math.PI/s*Math.floor(t/O);d||(n=u-t%O*S-2*Math.PI/s*Math.floor(t/O)),N[t].data.x=b[0]+Math.cos(n)*e,N[t].data.y=b[1]+Math.sin(n)*e}t&&N.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:N,edges:v}}))}}const xb=(t,e,n=!1)=>{const r=[ub(e[0])],i={},o=e.length;i[e[0].id]=!0;let a=0;return e.forEach(((s,l)=>{if(0!==l)if(l!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[l+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){const l=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id);let u=!1;for(let e=0;e<l.length;e++){const n=l[e];if(t.getDegree(n.id)===t.getDegree(s.id)&&!i[n.id]){r.push(ub(n)),i[n.id]=!0,u=!0;break}}let c=0;for(;!u&&(i[e[c].id]||(r.push(ub(e[c])),i[e[c].id]=!0,u=!0),c++,c!==o););}else r.push(ub(s)),i[s.id]=!0,a++})),r};const Eb=(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]},wb={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class kb{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},wb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericConcentricLayout(!0,t,e)}))}genericConcentricLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a,sortBy:s,maxLevelDiff:l,sweep:u,clockwise:c,equidistant:h,preventOverlap:d,startAngle:f=1.5*Math.PI,nodeSize:p,nodeSpacing:g}=r,v=e.getAllNodes(),m=e.getAllEdges(),y=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,x=i||[y/2,b/2];if(!(null==v?void 0:v.length)||1===v.length)return mb(e,t,x);const E=[];let w,k=0;rb(p)?w=Math.max(p[0],p[1]):Yt(p)?(w=-1/0,v.forEach((t=>{const e=Math.max(...cb(p(t)));e>w&&(w=e)}))):w=p,rb(g)?k=Math.max(g[0],g[1]):ae(g)&&(k=g),v.forEach((t=>{const e=ub(t);E.push(e);let n=w;const{data:r}=e;rb(r.size)?n=Math.max(r.size[0],r.size[1]):ae(r.size)?n=r.size:qt(r.size)&&(n=Math.max(r.size.width,r.size.height)),w=Math.max(w,n),Yt(g)&&(k=Math.max(g(t),k))}));const M={};E.forEach(((t,e)=>{M[t.id]=e}));let S=s;ne(S)&&void 0!==E[0].data[S]||(S="degree"),"degree"===S?E.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):E.sort(((t,e)=>e.data[S]-t.data[S]));const N=E[0],O=(l||("degree"===S?e.getDegree(N.id,"both"):N.data[S]))/4,T=[{nodes:[]}];let A=T[0];E.forEach((t=>{if(A.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(A.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(A.nodes[0].data[S]-t.data[S]);O&&n>=O&&(A={nodes:[]},T.push(A))}A.nodes.push(t)}));let C=w+k;if(!d){const t=T.length>0&&T[0].nodes.length>1,e=(Math.min(y,b)/2-C)/(T.length+(t?1:0));C=Math.min(C,e)}let P=0;if(T.forEach((t=>{const e=void 0===u?2*Math.PI-2*Math.PI/t.nodes.length:u;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(C*C/(e*e+n*n));P=Math.max(r,P)}t.r=P,P+=C})),h){let t=0,e=0;for(let n=0;n<T.length;n++){const r=(T[n].r||0)-e;t=Math.max(t,r)}e=0,T.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}T.forEach((t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach(((t,r)=>{const i=f+(c?1:-1)*e*r;t.data.x=x[0]+n*Math.cos(i),t.data.y=x[1]+n*Math.sin(i)}))})),t&&E.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:E,edges:m}}))}}function Mb(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,l,u,c,h,d,f=t._root,p={data:r},g=t._x0,v=t._y0,m=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a,i=f,!(f=f[h=c<<1|u]))return i[h]=p,t;if(s=+t._x.call(null,f.data),l=+t._y.call(null,f.data),e===s&&n===l)return p.next=f,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a}while((h=c<<1|u)==(d=(l>=a)<<1|s>=o));return i[d]=f,i[h]=p,t}function Sb(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Nb(t){return t[0]}function Ob(t){return t[1]}function Tb(t,e,n){var r=new Ab(null==e?Nb:e,null==n?Ob:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Ab(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 Cb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Pb=Tb.prototype=Ab.prototype;function Rb(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,l,u,c,h,d,f,p,g,v,m=t._root,y={data:i},b=t._x0,x=t._y0,E=t._z0,w=t._x1,k=t._y1,M=t._z1;if(!m)return t._root=y,t;for(;m.length;)if((d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l,o=m,!(m=m[g=p<<2|f<<1|d]))return o[g]=y,t;if(u=+t._x.call(null,m.data),c=+t._y.call(null,m.data),h=+t._z.call(null,m.data),e===u&&n===c&&r===h)return y.next=m,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+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l}while((g=p<<2|f<<1|d)==(v=(h>=l)<<2|(c>=s)<<1|u>=a));return o[v]=m,o[g]=y,t}function Db(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}Pb.copy=function(){var t,e,n=new Ab(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=Cb(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]=Cb(e));return n},Pb.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Mb(this.cover(e,n),e,n,t)},Pb.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),l=1/0,u=1/0,c=-1/0,h=-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<l&&(l=r),r>c&&(c=r),i<u&&(u=i),i>h&&(h=i));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<o;++n)Mb(this,a[n],s[n],t[n]);return this},Pb.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,l=i-n||1,u=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=u,u=a,l*=2,s){case 0:i=n+l,o=r+l;break;case 1:n=i-l,o=r+l;break;case 2:i=n+l,r=o-l;break;case 3:n=i-l,r=o-l}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},Pb.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Pb.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]]},Pb.find=function(t,e,n){var r,i,o,a,s,l,u,c=this._x0,h=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new Sb(g,c,h,d,f)),null==n?n=1/0:(c=t-n,h=e-n,d=t+n,f=e+n,n*=n);l=p.pop();)if(!(!(g=l.node)||(i=l.x0)>d||(o=l.y0)>f||(a=l.x1)<c||(s=l.y1)<h))if(g.length){var v=(i+a)/2,m=(o+s)/2;p.push(new Sb(g[3],v,m,a,s),new Sb(g[2],i,m,v,s),new Sb(g[1],v,o,a,m),new Sb(g[0],i,o,v,m)),(u=(e>=m)<<1|t>=v)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-u],p[p.length-1-u]=l)}else{var y=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),x=y*y+b*b;if(x<n){var E=Math.sqrt(n=x);c=t-E,h=e-E,d=t+E,f=e+E,r=g.data}}return r},Pb.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,l,u,c,h,d,f=this._root,p=this._x0,g=this._y0,v=this._x1,m=this._y1;if(!f)return this;if(f.length)for(;;){if((u=o>=(s=(p+v)/2))?p=s:v=s,(c=a>=(l=(g+m)/2))?g=l:m=l,e=f,!(f=f[h=c<<1|u]))return this;if(!f.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}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[h]=i:delete e[h],(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)},Pb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Pb.root=function(){return this._root},Pb.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Pb.visit=function(t){var e,n,r,i,o,a,s=[],l=this._root;for(l&&s.push(new Sb(l,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&l.length){var u=(r+o)/2,c=(i+a)/2;(n=l[3])&&s.push(new Sb(n,u,c,o,a)),(n=l[2])&&s.push(new Sb(n,r,c,u,a)),(n=l[1])&&s.push(new Sb(n,u,i,o,c)),(n=l[0])&&s.push(new Sb(n,r,i,u,c))}return this},Pb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Sb(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,l=e.x1,u=e.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&n.push(new Sb(o,a,s,c,h)),(o=i[1])&&n.push(new Sb(o,c,s,l,h)),(o=i[2])&&n.push(new Sb(o,a,h,c,u)),(o=i[3])&&n.push(new Sb(o,c,h,l,u))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},Pb.x=function(t){return arguments.length?(this._x=t,this):this._x},Pb.y=function(t){return arguments.length?(this._y=t,this):this._y};const Lb=(t,e,n,r,i,o)=>Math.sqrt((t-r)**2+(e-i)**2+(n-o)**2);function _b(t){return t[0]}function Ib(t){return t[1]}function jb(t){return t[2]}function Bb(t,e,n,r){var i=new Fb(null==e?_b:e,null==n?Ib:n,null==r?jb:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function Fb(t,e,n,r,i,o,a,s,l){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=l,this._root=void 0}function zb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Gb=Bb.prototype=Fb.prototype;Gb.copy=function(){var t,e,n=new Fb(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=zb(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]=zb(e));return n},Gb.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Rb(this.cover(e,n,r),e,n,r,t)},Gb.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,l=-1/0,u=-1/0,c=-1/0;for(let h,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(f=+this._y.call(null,h))||isNaN(p=+this._z.call(null,h))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>l&&(l=d),f<a&&(a=f),f>u&&(u=f),p<s&&(s=p),p>c&&(c=p));if(o>l||a>u||s>c)return this;this.cover(o,a,s).cover(l,u,c);for(let o=0;o<e;++o)Rb(this,n[o],r[o],i[o],t[o]);return this},Gb.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,l=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,l=(o=Math.floor(n))+1;else{for(var u,c,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=l;)switch(c=(n<o)<<2|(e<i)<<1|t<r,(u=new Array(8))[c]=d,d=u,h*=2,c){case 0:a=r+h,s=i+h,l=o+h;break;case 1:r=a-h,s=i+h,l=o+h;break;case 2:a=r+h,i=s-h,l=o+h;break;case 3:r=a-h,i=s-h,l=o+h;break;case 4:a=r+h,s=i+h,o=l-h;break;case 5:r=a-h,s=i+h,o=l-h;break;case 6:a=r+h,i=s-h,o=l-h;break;case 7:r=a-h,i=s-h,o=l-h}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=l,this},Gb.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Gb.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]]},Gb.find=function(t,e,n,r){var i,o,a,s,l,u,c,h,d,f=this._x0,p=this._y0,g=this._z0,v=this._x1,m=this._y1,y=this._z1,b=[],x=this._root;for(x&&b.push(new Db(x,f,p,g,v,m,y)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,v=t+r,m=e+r,y=n+r,r*=r);h=b.pop();)if(!(!(x=h.node)||(o=h.x0)>v||(a=h.y0)>m||(s=h.z0)>y||(l=h.x1)<f||(u=h.y1)<p||(c=h.z1)<g))if(x.length){var E=(o+l)/2,w=(a+u)/2,k=(s+c)/2;b.push(new Db(x[7],E,w,k,l,u,c),new Db(x[6],o,w,k,E,u,c),new Db(x[5],E,a,k,l,w,c),new Db(x[4],o,a,k,E,w,c),new Db(x[3],E,w,s,l,u,k),new Db(x[2],o,w,s,E,u,k),new Db(x[1],E,a,s,l,w,k),new Db(x[0],o,a,s,E,w,k)),(d=(n>=k)<<2|(e>=w)<<1|t>=E)&&(h=b[b.length-1],b[b.length-1]=b[b.length-1-d],b[b.length-1-d]=h)}else{var M=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),N=n-+this._z.call(null,x.data),O=M*M+S*S+N*N;if(O<r){var T=Math.sqrt(r=O);f=t-T,p=e-T,g=n-T,v=t+T,m=e+T,y=n+T,i=x.data}}return i},Gb.findAllWithinRadius=function(t,e,n,r){const i=[],o=t-r,a=e-r,s=n-r,l=t+r,u=e+r,c=n+r;return this.visit(((h,d,f,p,g,v,m)=>{if(!h.length)do{const o=h.data;Lb(t,e,n,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(h=h.next);return d>l||f>u||p>c||g<o||v<a||m<s})),i},Gb.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,l,u,c,h,d,f,p,g,v=this._root,m=this._x0,y=this._y0,b=this._z0,x=this._x1,E=this._y1,w=this._z1;if(!v)return this;if(v.length)for(;;){if((h=o>=(l=(m+x)/2))?m=l:x=l,(d=a>=(u=(y+E)/2))?y=u:E=u,(f=s>=(c=(b+w)/2))?b=c:w=c,e=v,!(v=v[p=f<<2|d<<1|h]))return this;if(!v.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(;v.data!==t;)if(r=v,!(v=v.next))return this;return(i=v.next)&&delete v.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(n?n[g]=v:this._root=v),this):(this._root=i,this)},Gb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Gb.root=function(){return this._root},Gb.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Gb.visit=function(t){var e,n,r,i,o,a,s,l,u=[],c=this._root;for(c&&u.push(new Db(c,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=u.pop();)if(!t(c=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,l=e.z1)&&c.length){var h=(r+a)/2,d=(i+s)/2,f=(o+l)/2;(n=c[7])&&u.push(new Db(n,h,d,f,a,s,l)),(n=c[6])&&u.push(new Db(n,r,d,f,h,s,l)),(n=c[5])&&u.push(new Db(n,h,i,f,a,d,l)),(n=c[4])&&u.push(new Db(n,r,i,f,h,d,l)),(n=c[3])&&u.push(new Db(n,h,d,o,a,s,f)),(n=c[2])&&u.push(new Db(n,r,d,o,h,s,f)),(n=c[1])&&u.push(new Db(n,h,i,o,a,d,f)),(n=c[0])&&u.push(new Db(n,r,i,o,h,d,f))}return this},Gb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Db(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,l=e.z0,u=e.x1,c=e.y1,h=e.z1,d=(a+u)/2,f=(s+c)/2,p=(l+h)/2;(o=i[0])&&n.push(new Db(o,a,s,l,d,f,p)),(o=i[1])&&n.push(new Db(o,d,s,l,u,f,p)),(o=i[2])&&n.push(new Db(o,a,f,l,d,c,p)),(o=i[3])&&n.push(new Db(o,d,f,l,u,c,p)),(o=i[4])&&n.push(new Db(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new Db(o,d,s,p,u,f,h)),(o=i[6])&&n.push(new Db(o,a,f,p,d,c,h)),(o=i[7])&&n.push(new Db(o,d,f,p,u,c,h))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Gb.x=function(t){return arguments.length?(this._x=t,this):this._x},Gb.y=function(t){return arguments.length?(this._y=t,this):this._y},Gb.z=function(t){return arguments.length?(this._z=t,this):this._z};function Vb(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}})),l=(2===i?Tb(s,(t=>t.x),(t=>t.y)):Bb(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(Wb),u=new Map;return s.forEach((t=>{u.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>Hb(e,r,i,o,a,t,n)))}(t,l,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 Wb(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 Hb=(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 l=[n,r,i][a-1],u=o.x-t.x||.1,c=o.y-t.y||.1,h=o.z-t.z||.1,d=[u,c,h],f=l-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+=u*e,o.vy+=c*e,o.vz+=h*e,!0}if(t.length)return!1;if(t.data!==o){const e=t.data.weight/g;o.vx+=u*e,o.vy+=c*e,o.vz+=h*e}};const Yb={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 Ub{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Yb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield 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 ze(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:l,height:u,nodeSize:c,getMass:h,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:ae(t.data.x)?t.data.x:Math.random()*l,y:ae(t.data.y)?t.data.y:Math.random()*u,z:ae(t.data.z)?t.data.z:Math.random()*Math.sqrt(l*u),size:c(t)||30,mass:h(t),nodeStrength:d(t)})}))),v=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 m={};i.forEach(((t,e)=>{m[t.id]={x:0,y:0,z:0}}));const y=new Yg({nodes:g,edges:v});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:x,onTick:E}=a;if(this.lastLayoutNodes=g,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=m,"undefined"==typeof window)return;let w=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Zb(e,g),edges:o}),this.runOneStep(y,e,w,m,a),this.updatePosition(e,y,m,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==E||E({nodes:Zb(e,g),edges:o}),w++,(w>=b||this.judgingDistance<x)&&(window.clearInterval(this.timeInterval),n({nodes:Zb(e,g),edges:o}))}),0),this.running=!0}))}))}formatOptions(t,e){const n=Object.assign({},t),{width:r,height:i,getMass:o}=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;ae(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}),n.nodeSize=fb(t.nodeSize,t.nodeSpacing);const a=t.linkDistance?hb(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=a,n.nodeStrength=hb(1,t.nodeStrength),n.edgeStrength=hb(1,t.edgeStrength),n}formatCentripetal(t,e){const{dimensions:n,centripetalOptions:r,center:i,clusterNodeStrength:o,leafCluster:a,clustering:s,nodeClusterBy:l}=t,u=e.getAllNodes(),c=r||{leaf:2,single:2,others:1,center:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0})};let h,d;if("function"!=typeof o&&(t.clusterNodeStrength=t=>o),a&&l&&(h=$b(e,l),d=Array.from(new Set(null==u?void 0:u.map((t=>t.data[l]))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=h[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=[]}=h[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=Kb(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&&l){h||(h=$b(e,l)),d||(d=Array.from(new Set(u.map((t=>t.data[l]))))),d=d.filter((t=>void 0!==t));const n={};d.forEach((t=>{const r=u.filter((e=>e.data[l]===t)).map((t=>e.getNode(t.id)));n[t]=Kb(r)})),t.centripetalOptions=Object.assign(c,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[t.data[l]];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:l}=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),l){l({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:l=1}=e.data;n+=l*s*.5})),n}calRepulsive(t,e,n){const{dimensions:r,factor:i,coulombDisScale:o}=n;Vb(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,l=t.getNode(a),u=t.getNode(s);if(!l||!u)return;let c=u.data.x-l.data.x,h=u.data.y-l.data.y,d=3===r?u.data.z-l.data.z:0;c||h||(c=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));const f=Math.sqrt(c*c+h*h+d*d);if(f<i(l)+i(u))return;const p=c/f,g=h/f,v=d/f,{linkDistance:m=200,edgeStrength:y=200}=n.data||{},b=(m-f)*y,x=1/(l.data.mass||1),E=1/(u.data.mass||1),w=p*b,k=g*b,M=v*b;e[a].x-=w*x,e[a].y-=k*x,e[a].z-=M*x,e[s].x+=w*E,e[s].y+=k*E,e[s].z+=M*E}))}calGravity(t,e,n,r){const{getCenter:i}=r,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),{width:l,height:u,center:c,gravity:h,centripetalOptions:d}=r;o&&o.forEach((r=>{const{id:o,data:f}=r,{mass:p,x:g,y:v,z:m}=f,y=e.getNode(o);let b=0,x=0,E=0,w=h;const k=t.getDegree(o,"in"),M=t.getDegree(o,"out"),S=t.getDegree(o,"both"),N=null==i?void 0:i(y,S);if(N){const[t,e,n]=N;b=g-t,x=v-e,w=n}else b=g-c[0],x=v-c[1],E=m-c[2];if(w&&(n[o].x-=w*b/p,n[o].y-=w*x/p,n[o].z-=w*E/p),d){const{leaf:t,single:e,others:r,center:i}=d,{x:c,y:h,z:f,centerStrength:b}=(null==i?void 0:i(y,a,s,l,u))||{x:0,y:0,z:0,centerStrength:0};if(!ae(c)||!ae(h))return;const x=(g-c)/p,E=(v-h)/p,w=(m-f)/p;if(b&&(n[o].x-=b*x,n[o].y-=b*E,n[o].z-=b*w),0===S){const t=e(y);if(!t)return;return n[o].x-=t*x,n[o].y-=t*E,void(n[o].z-=t*w)}if(0===k||0===M){const e=t(y,a,s);if(!e)return;return n[o].x-=e*x,n[o].y-=e*E,void(n[o].z-=e*w)}const N=r(y);if(!N)return;n[o].x-=N*x,n[o].y-=N*E,n[o].z-=N*w}}))}updateVelocity(t,e,n,r){const{damping:i,maxSpeed:o,interval:a,dimensions:s}=r,l=t.getAllNodes();(null==l?void 0:l.length)&&l.forEach((t=>{const{id:r}=t;let l=(n[r].x+e[r].x*a)*i||.01,u=(n[r].y+e[r].y*a)*i||.01,c=3===s?(n[r].z+e[r].z*a)*i||.01:0;const h=Math.sqrt(l*l+u*u+c*c);if(h>o){const t=o/h;l*=t,u*=t,c*=t}n[r]={x:l,y:u,z:c}}))}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 l=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((r=>{const{id:s}=r,u=t.getNode(s);if(ae(u.data.fx)&&ae(u.data.fy))return void e.mergeNodeData(s,{x:u.data.fx,y:u.data.fy,z:3===a?u.data.fz:void 0});const c=n[s].x*o,h=n[s].y*o,d=3===a?n[s].z*o:0;e.mergeNodeData(s,{x:r.data.x+c,y:r.data.y+h,z:r.data.z+d});const f=Math.sqrt(c*c+h*h+d*d);switch(i){case"max":this.judgingDistance<f&&(this.judgingDistance=f);break;case"min":this.judgingDistance>f&&(this.judgingDistance=f);break;default:l+=f}})),i&&"mean"!==i||(this.judgingDistance=l/s.length)}}const $b=(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]=qb(t,"leaf",n,e))})),r},qb=(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:Xb(t,e,r,n,s)}},Xb=(t,e,n,r,i)=>{const o=r.data[n]||"";let a=(null==i?void 0:i.filter((t=>t.data[n]===o)))||[];return a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out"))),a},Kb=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}},Zb=(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 Qb={};const Jb=Object.prototype.toString;function tx(t){const e=Jb.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var ex=w(Object.freeze({__proto__:null,isAnyArray:tx}));var nx=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!tx(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(!tx(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(!tx(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(!tx(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,l=void 0===s?n.autoMinMax?i:1:s;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var u=(l-a)/(i-r),c=0;c<t.length;c++)e[c]=(t[c]-r)*u+a;return e}}),rx=w(nx);Object.defineProperty(Qb,"__esModule",{value:!0});var ix=ex,ox=rx;const ax=" ".repeat(2),sx=" ".repeat(4);function lx(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${ax}[\n${sx}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),l=Math.min(a,n),u=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<l;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<l;o++)n.push(ux(t.get(e,o),r,i));u.push(`${n.join(" ")}`)}l!==a&&(u[u.length-1]+=` ... ${a-n} more columns`);s!==o&&u.push(`... ${o-e} more rows`);return u.join(`\n${sx}`)}(t,n,r,i,o)}\n${ax}]\n${ax}rows: ${t.rows}\n${ax}columns: ${t.columns}\n}`}function ux(t,e,n){return(t>=0&&n?` ${cx(t,e-1)}`:cx(t,e)).padEnd(e)}function cx(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 hx(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 dx(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 fx(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 px(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 gx(t,e){if(!ix.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 vx(t,e){if(!ix.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 mx(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(bx("startRow",e),bx("endRow",n),bx("startColumn",r),bx("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 yx(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function bx(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function xx(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Ex{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new kx(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 kx(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 kx(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 kx(t,e)}static ones(t,e){return new kx(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 kx(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 kx(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 kx(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 Ex.isMatrix(t)?t:new kx(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 kx(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){hx(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return kx.rowVector(this.getRow(t))}setRow(t,e){hx(this,t),e=fx(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){hx(this,t),hx(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){dx(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return kx.columnVector(this.getColumn(t))}setColumn(t,e){dx(this,t),e=px(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){dx(this,t),dx(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=fx(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=fx(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=fx(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=fx(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=px(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=px(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=px(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=px(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){hx(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){dx(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(){xx(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(){xx(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(hx(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){hx(this,t),xx(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(hx(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){hx(this,t),xx(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(dx(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){dx(this,t),xx(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(dx(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){dx(this,t),xx(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){Ex.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=kx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new kx(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}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=kx.eye(this.rows),n=this;for(let r=t;r>1;r/=2)1&r&&(e=e.mmul(n)),n=n.mmul(n);return e}strassen2x2(t){t=kx.checkMatrix(t);let e=new kx(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),l=this.get(1,1),u=t.get(1,1),c=(n+l)*(r+u),h=(a+l)*r,d=n*(o-u),f=l*(s-r),p=(n+i)*u,g=c+f-p+(i-l)*(s+u),v=d+p,m=h+f,y=c-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,v),e.set(1,0,m),e.set(1,1,y),e}strassen3x3(t){t=kx.checkMatrix(t);let e=new kx(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),l=this.get(2,0),u=this.get(2,1),c=this.get(2,2),h=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),v=t.get(1,2),m=t.get(2,0),y=t.get(2,1),b=t.get(2,2),x=(n-o)*(-d+g),E=(-n+o+a)*(h-d+g),w=(o+a)*(-h+d),k=n*h,M=(-n+l+u)*(h-f+v),S=(-n+l)*(f-v),N=(l+u)*(-h+f),O=(-i+u+c)*(g+m-y),T=(i-c)*(g-y),A=i*m,C=(u+c)*(-m+y),P=(-i+a+s)*(v+m-b),R=(i-s)*(v-b),D=(a+s)*(-m+b),L=k+A+r*p,_=(n+r+i-o-a-u-c)*g+E+w+k+O+A+C,I=k+M+N+(n+r+i-a-s-l-u)*v+A+P+D,j=x+a*(-h+d+p-g-v-m+b)+E+k+A+P+R,B=x+E+w+k+s*y,F=A+P+R+D+o*f,z=k+M+S+u*(-h+f+p-g-v-m+y)+O+T+A,G=O+T+A+C+l*d,V=k+M+S+N+c*b;return e.set(0,0,L),e.set(0,1,_),e.set(0,2,I),e.set(1,0,j),e.set(1,1,B),e.set(1,2,F),e.set(2,0,z),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=kx.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=Ex.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),l=Math.max(r,o);return e=a(e,s,l),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),l=e.subMatrix(0,o-1,0,s-1),u=n.subMatrix(0,o-1,0,s-1),c=e.subMatrix(0,o-1,s,e.columns-1),h=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),v=t(Ex.add(l,p),Ex.add(u,g),o,s),m=t(Ex.add(d,p),u,o,s),y=t(l,Ex.sub(h,g),o,s),b=t(p,Ex.sub(f,u),o,s),x=t(Ex.add(l,c),g,o,s),E=t(Ex.sub(d,l),Ex.add(u,h),o,s),w=t(Ex.sub(c,p),Ex.add(f,g),o,s),k=Ex.add(v,b);k.sub(x),k.add(w);let M=Ex.add(y,x),S=Ex.add(m,b),N=Ex.sub(v,m);N.add(y),N.add(E);let O=Ex.zeros(2*k.rows,2*k.columns);return O=O.setSubMatrix(k,0,0),O=O.setSubMatrix(M,k.rows,0),O=O.setSubMatrix(S,0,k.columns),O=O.setSubMatrix(N,k.rows,k.columns),O.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,l),s,l)}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 kx(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&ox(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 kx(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&ox(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=kx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new kx(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=kx.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(kx.eye(n,n)),i=kx.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new kx(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=wx){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=wx){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){mx(this,t,e,n,r);let i=new kx(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 kx(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 kx(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=kx.checkMatrix(t)).isEmpty())return this;mx(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){gx(this,t),vx(this,e);let n=new kx(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 kx(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=yx(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=yx(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=yx(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=yx(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(!ix.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,l=0;for(let e=0;e<i;e++)l=t.get(a,e)-n[a],r+=l,s+=l*l;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!ix.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,l=0;for(let e=0;e<r;e++)l=t.get(e,a)-n[a],i+=l,s+=l*l;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,l=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)l=t.get(e,r)-n,a+=l,s+=l*l;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(!ix.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(!ix.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+=t.get(n,e)**2/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!ix.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+=t.get(e,n)**2/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!ix.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+=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 lx(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 wx(t,e){return t-e}Ex.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Ex.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return lx(this)}),Ex.random=Ex.rand,Ex.randomInt=Ex.randInt,Ex.diagonal=Ex.diag,Ex.prototype.diagonal=Ex.prototype.diag,Ex.identity=Ex.eye,Ex.prototype.negate=Ex.prototype.neg,Ex.prototype.tensorProduct=Ex.prototype.kroneckerProduct;let kx=class t extends Ex{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(!ix.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 hx(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),hx(this,t,!0),e=Float64Array.from(fx(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){dx(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),dx(this,t,!0),e=px(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,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,this.get(e,n)**t.get(e,n));return this}}(Ex,kx);class Mx extends Ex{#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 kx.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(),kx.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=kx.copy(t,new kx(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new kx(t,t);else if(this.#e=new kx(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new Mx(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new kx(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 Mx(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)}}}Mx.prototype.klassType="SymmetricMatrix";class Sx extends Mx{static isDistanceMatrix(t){return Mx.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 Mx(this)}clone(){const t=new Sx(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;if(0===e)return new this(0);const 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}}Sx.prototype.klassSubType="DistanceMatrix";class Nx extends Ex{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class Ox extends Nx{constructor(t,e,n){gx(t,e),vx(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 Tx extends Ex{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 Ax extends Ex{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 Cx{constructor(t){let e,n,r,i,o,a,s,l,u,c=(t=Ax.checkMatrix(t)).clone(),h=c.rows,d=c.columns,f=new Float64Array(h),p=1;for(e=0;e<h;e++)f[e]=e;for(l=new Float64Array(h),n=0;n<d;n++){for(e=0;e<h;e++)l[e]=c.get(e,n);for(e=0;e<h;e++){for(u=Math.min(e,n),o=0,r=0;r<u;r++)o+=c.get(e,r)*l[r];l[e]-=o,c.set(e,n,l[e])}for(i=n,e=n+1;e<h;e++)Math.abs(l[e])>Math.abs(l[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=c.get(i,r),c.set(i,r,c.get(n,r)),c.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<h&&0!==c.get(n,n))for(e=n+1;e<h;e++)c.set(e,n,c.get(e,n)/c.get(n,n))}this.LU=c,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=kx.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 kx(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 kx(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 Px(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 Rx{constructor(t){let e,n,r,i,o=(t=Ax.checkMatrix(t)).clone(),a=t.rows,s=t.columns,l=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=Px(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))}}l[r]=-t}this.QR=o,this.Rdiag=l}solve(t){t=kx.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,l=t.clone(),u=e.columns;for(o=0;o<u;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*l.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)l.set(r,i,l.get(r,i)+a*e.get(r,o))}for(o=u-1;o>=0;o--){for(i=0;i<s;i++)l.set(o,i,l.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)l.set(r,i,l.get(r,i)-l.get(o,i)*e.get(r,o))}return l.subMatrix(0,u-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 kx(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 kx(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 Dx=class{constructor(t,e={}){if((t=Ax.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,l=Boolean(i),u=Boolean(o),c=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,c=!0;let e=l;l=u,u=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 h=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new kx(n,h),g=new kx(r,r),v=new Float64Array(r),m=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,r),x=Math.max(0,Math.min(r-2,n)),E=Math.max(b,x);for(let t=0;t<E;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=Px(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))}v[e]=s.get(t,e)}if(l&&t<b)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<r;e++)v[t]=Px(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<r;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<n&&0!==v[t]){for(let e=t+1;e<n;e++)m[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)m[e]+=v[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-v[e]/v[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*m[i])}}if(u)for(let e=t+1;e<r;e++)g.set(e,t,v[e])}}let w=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<w&&(f[w-1]=0),x+1<w&&(v[x]=s.get(x,w-1)),v[w-1]=0,l){for(let t=b;t<h;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<h;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(u)for(let t=r-1;t>=0;t--){if(t<x&&0!==v[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 k=w-1,M=Number.EPSILON;for(;w>0;){let t,e;for(t=w-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+M*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===w-2)e=4;else{let n;for(n=w-1;n>=t&&n!==t;n--){let e=(n!==w?Math.abs(v[n]):0)+(n!==t+1?Math.abs(v[n-1]):0);if(Math.abs(f[n])<=M*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=v[w-2];v[w-2]=0;for(let n=w-2;n>=t;n--){let i=Px(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*v[n-1],v[n-1]=o*v[n-1]),u)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=v[t-1];v[t-1]=0;for(let r=t;r<w;r++){let i=Px(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*v[r],v[r]=o*v[r],l)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(v[w-2]),Math.abs(f[t]),Math.abs(v[t])),i=f[w-1]/e,o=f[w-2]/e,a=v[w-2]/e,s=f[t]/e,c=v[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let m=0;0===h&&0===d||(m=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),m=d/(h+m));let y=(s+i)*(s-i)+m,b=s*c;for(let e=t;e<w-1;e++){let i=Px(y,b);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=b/i;if(e!==t&&(v[e-1]=i),y=o*f[e]+a*v[e],v[e]=o*v[e]-a*f[e],b=a*f[e+1],f[e+1]=o*f[e+1],u)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=Px(y,b),0===i&&(i=Number.MIN_VALUE),o=y/i,a=b/i,f[e]=i,y=o*v[e]+a*f[e+1],f[e+1]=-a*v[e]+o*f[e+1],b=a*v[e+1],v[e+1]=o*v[e+1],l&&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)}v[w-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,u))for(let e=0;e<=k;e++)g.set(e,t,-g.get(e,t));for(;t<k&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(l&&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(c){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=kx.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),l=a.rows,u=o.rows,c=kx.zeros(l,u);for(let t=0;t<l;t++)for(let e=0;e<u;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);c.set(t,e,n)}return c.mmul(e)}solveForDiagonal(t){return this.solve(kx.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new kx(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,l=new kx(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);l.set(t,e,n)}return l}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 kx.diag(this.s)}};function Lx(t,e,n=!1){return t=Ax.checkMatrix(t),e=Ax.checkMatrix(e),n?new Dx(t).solve(e):t.isSquare()?new Cx(t).solve(e):new Rx(t).solve(e)}function _x(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function Ix(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 jx{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=Ax.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 kx(o,o),s=new Float64Array(o),l=new Float64Array(o),u=t,c=!1;if(c=!!n||t.isSymmetric(),c){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h;for(l=0;l<t;l++)n[l]=r.get(t-1,l);for(s=t-1;s>0;s--){for(h=0,a=0,u=0;u<s;u++)h+=Math.abs(n[u]);if(0===h)for(e[s]=n[s-1],l=0;l<s;l++)n[l]=r.get(s-1,l),r.set(s,l,0),r.set(l,s,0);else{for(u=0;u<s;u++)n[u]/=h,a+=n[u]*n[u];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=h*o,a-=i*o,n[s-1]=i-o,l=0;l<s;l++)e[l]=0;for(l=0;l<s;l++){for(i=n[l],r.set(l,s,i),o=e[l]+r.get(l,l)*i,u=l+1;u<=s-1;u++)o+=r.get(u,l)*n[u],e[u]+=r.get(u,l)*i;e[l]=o}for(i=0,l=0;l<s;l++)e[l]/=a,i+=e[l]*n[l];for(c=i/(a+a),l=0;l<s;l++)e[l]-=c*n[l];for(l=0;l<s;l++){for(i=n[l],o=e[l],u=l;u<=s-1;u++)r.set(u,l,r.get(u,l)-(i*e[u]+o*n[u]));n[l]=r.get(s-1,l),r.set(s,l,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(u=0;u<=s;u++)n[u]=r.get(u,s+1)/a;for(l=0;l<=s;l++){for(o=0,u=0;u<=s;u++)o+=r.get(u,s+1)*r.get(u,l);for(u=0;u<=s;u++)r.set(u,l,r.get(u,l)-o*n[u])}}for(u=0;u<=s;u++)r.set(u,s+1,0)}for(l=0;l<t;l++)n[l]=r.get(t-1,l),r.set(t-1,l,0);r.set(t-1,t-1,1),e[0]=0}(o,l,s,a),function(t,e,n,r){let i,o,a,s,l,u,c,h,d,f,p,g,v,m,y,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let x=0,E=0,w=Number.EPSILON;for(u=0;u<t;u++){for(E=Math.max(E,Math.abs(n[u])+Math.abs(e[u])),c=u;c<t&&!(Math.abs(e[c])<=w*E);)c++;if(c>u)do{for(i=n[u],h=(n[u+1]-i)/(2*e[u]),d=Px(h,1),h<0&&(d=-d),n[u]=e[u]/(h+d),n[u+1]=e[u]*(h+d),f=n[u+1],o=i-n[u],a=u+2;a<t;a++)n[a]-=o;for(x+=o,h=n[c],p=1,g=p,v=p,m=e[u+1],y=0,b=0,a=c-1;a>=u;a--)for(v=g,g=p,b=y,i=p*e[a],o=p*h,d=Px(h,e[a]),e[a+1]=y*d,y=e[a]/d,p=h/d,h=p*n[a]-y*i,n[a+1]=o+y*(p*i+y*n[a]),l=0;l<t;l++)o=r.get(l,a+1),r.set(l,a+1,y*r.get(l,a)+p*o),r.set(l,a,p*r.get(l,a)-y*o);h=-y*b*v*m*e[u]/f,e[u]=y*h,n[u]=p*h}while(Math.abs(e[u])>w*E);n[u]=n[u]+x,e[u]=0}for(a=0;a<t-1;a++){for(l=a,h=n[a],s=a+1;s<t;s++)n[s]<h&&(l=s,h=n[s]);if(l!==a)for(n[l]=n[a],n[a]=h,s=0;s<t;s++)h=r.get(s,a),r.set(s,a,r.get(s,l)),r.set(s,l,h)}}(o,l,s,a)}else{let t=new kx(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h=0,d=t-1;for(u=h+1;u<=d-1;u++){for(c=0,s=u;s<=d;s++)c+=Math.abs(e.get(s,u-1));if(0!==c){for(a=0,s=d;s>=u;s--)n[s]=e.get(s,u-1)/c,a+=n[s]*n[s];for(o=Math.sqrt(a),n[u]>0&&(o=-o),a-=n[u]*o,n[u]=n[u]-o,l=u;l<t;l++){for(i=0,s=d;s>=u;s--)i+=n[s]*e.get(s,l);for(i/=a,s=u;s<=d;s++)e.set(s,l,e.get(s,l)-i*n[s])}for(s=0;s<=d;s++){for(i=0,l=d;l>=u;l--)i+=n[l]*e.get(s,l);for(i/=a,l=u;l<=d;l++)e.set(s,l,e.get(s,l)-i*n[l])}n[u]=c*n[u],e.set(u,u-1,c*o)}}for(s=0;s<t;s++)for(l=0;l<t;l++)r.set(s,l,s===l?1:0);for(u=d-1;u>=h+1;u--)if(0!==e.get(u,u-1)){for(s=u+1;s<=d;s++)n[s]=e.get(s,u-1);for(l=u;l<=d;l++){for(o=0,s=u;s<=d;s++)o+=n[s]*r.get(s,l);for(o=o/n[u]/e.get(u,u-1),s=u;s<=d;s++)r.set(s,l,r.get(s,l)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,l,u,c,h,d,f,p,g,v,m,y,b,x=t-1,E=0,w=t-1,k=Number.EPSILON,M=0,S=0,N=0,O=0,T=0,A=0,C=0,P=0;for(o=0;o<t;o++)for((o<E||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>=E;){for(l=x;l>E&&(A=Math.abs(i.get(l-1,l-1))+Math.abs(i.get(l,l)),0===A&&(A=S),!(Math.abs(i.get(l,l-1))<k*A));)l--;if(l===x)i.set(x,x,i.get(x,x)+M),n[x]=i.get(x,x),e[x]=0,x--,P=0;else if(l===x-1){if(h=i.get(x,x-1)*i.get(x-1,x),N=(i.get(x-1,x-1)-i.get(x,x))/2,O=N*N+h,C=Math.sqrt(Math.abs(O)),i.set(x,x,i.get(x,x)+M),i.set(x-1,x-1,i.get(x-1,x-1)+M),d=i.get(x,x),O>=0){for(C=N>=0?N+C:N-C,n[x-1]=d+C,n[x]=n[x-1],0!==C&&(n[x]=d-h/C),e[x-1]=0,e[x]=0,d=i.get(x,x-1),A=Math.abs(d)+Math.abs(C),N=d/A,O=C/A,T=Math.sqrt(N*N+O*O),N/=T,O/=T,a=x-1;a<t;a++)C=i.get(x-1,a),i.set(x-1,a,O*C+N*i.get(x,a)),i.set(x,a,O*i.get(x,a)-N*C);for(o=0;o<=x;o++)C=i.get(o,x-1),i.set(o,x-1,O*C+N*i.get(o,x)),i.set(o,x,O*i.get(o,x)-N*C);for(o=E;o<=w;o++)C=r.get(o,x-1),r.set(o,x-1,O*C+N*r.get(o,x)),r.set(o,x,O*r.get(o,x)-N*C)}else n[x-1]=d+N,n[x]=d+N,e[x-1]=C,e[x]=-C;x-=2,P=0}else{if(d=i.get(x,x),f=0,h=0,l<x&&(f=i.get(x-1,x-1),h=i.get(x,x-1)*i.get(x-1,x)),10===P){for(M+=d,o=E;o<=x;o++)i.set(o,o,i.get(o,o)-d);A=Math.abs(i.get(x,x-1))+Math.abs(i.get(x-1,x-2)),d=f=.75*A,h=-.4375*A*A}if(30===P&&(A=(f-d)/2,A=A*A+h,A>0)){for(A=Math.sqrt(A),f<d&&(A=-A),A=d-h/((f-d)/2+A),o=E;o<=x;o++)i.set(o,o,i.get(o,o)-A);M+=A,d=f=h=.964}for(P+=1,u=x-2;u>=l&&(C=i.get(u,u),T=d-C,A=f-C,N=(T*A-h)/i.get(u+1,u)+i.get(u,u+1),O=i.get(u+1,u+1)-C-T-A,T=i.get(u+2,u+1),A=Math.abs(N)+Math.abs(O)+Math.abs(T),N/=A,O/=A,T/=A,u!==l)&&!(Math.abs(i.get(u,u-1))*(Math.abs(O)+Math.abs(T))<k*(Math.abs(N)*(Math.abs(i.get(u-1,u-1))+Math.abs(C)+Math.abs(i.get(u+1,u+1)))));)u--;for(o=u+2;o<=x;o++)i.set(o,o-2,0),o>u+2&&i.set(o,o-3,0);for(s=u;s<=x-1&&(y=s!==x-1,s!==u&&(N=i.get(s,s-1),O=i.get(s+1,s-1),T=y?i.get(s+2,s-1):0,d=Math.abs(N)+Math.abs(O)+Math.abs(T),0!==d&&(N/=d,O/=d,T/=d)),0!==d);s++)if(A=Math.sqrt(N*N+O*O+T*T),N<0&&(A=-A),0!==A){for(s!==u?i.set(s,s-1,-A*d):l!==u&&i.set(s,s-1,-i.get(s,s-1)),N+=A,d=N/A,f=O/A,C=T/A,O/=N,T/=N,a=s;a<t;a++)N=i.get(s,a)+O*i.get(s+1,a),y&&(N+=T*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-N*C)),i.set(s,a,i.get(s,a)-N*d),i.set(s+1,a,i.get(s+1,a)-N*f);for(o=0;o<=Math.min(x,s+3);o++)N=d*i.get(o,s)+f*i.get(o,s+1),y&&(N+=C*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-N*T)),i.set(o,s,i.get(o,s)-N),i.set(o,s+1,i.get(o,s+1)-N*O);for(o=E;o<=w;o++)N=d*r.get(o,s)+f*r.get(o,s+1),y&&(N+=C*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-N*T)),r.set(o,s,r.get(o,s)-N),r.set(o,s+1,r.get(o,s+1)-N*O)}}}if(0===S)return;for(x=t-1;x>=0;x--)if(N=n[x],O=e[x],0===O)for(l=x,i.set(x,x,1),o=x-1;o>=0;o--){for(h=i.get(o,o)-N,T=0,a=l;a<=x;a++)T+=i.get(o,a)*i.get(a,x);if(e[o]<0)C=h,A=T;else if(l=o,0===e[o]?i.set(o,x,0!==h?-T/h:-T/(k*S)):(d=i.get(o,o+1),f=i.get(o+1,o),O=(n[o]-N)*(n[o]-N)+e[o]*e[o],c=(d*A-C*T)/O,i.set(o,x,c),i.set(o+1,x,Math.abs(d)>Math.abs(C)?(-T-h*c)/d:(-A-f*c)/C)),c=Math.abs(i.get(o,x)),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x,i.get(a,x)/c)}else if(O<0)for(l=x-1,Math.abs(i.get(x,x-1))>Math.abs(i.get(x-1,x))?(i.set(x-1,x-1,O/i.get(x,x-1)),i.set(x-1,x,-(i.get(x,x)-N)/i.get(x,x-1))):(b=Bx(0,-i.get(x-1,x),i.get(x-1,x-1)-N,O),i.set(x-1,x-1,b[0]),i.set(x-1,x,b[1])),i.set(x,x-1,0),i.set(x,x,1),o=x-2;o>=0;o--){for(p=0,g=0,a=l;a<=x;a++)p+=i.get(o,a)*i.get(a,x-1),g+=i.get(o,a)*i.get(a,x);if(h=i.get(o,o)-N,e[o]<0)C=h,T=p,A=g;else if(l=o,0===e[o]?(b=Bx(-p,-g,h,O),i.set(o,x-1,b[0]),i.set(o,x,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),v=(n[o]-N)*(n[o]-N)+e[o]*e[o]-O*O,m=2*(n[o]-N)*O,0===v&&0===m&&(v=k*S*(Math.abs(h)+Math.abs(O)+Math.abs(d)+Math.abs(f)+Math.abs(C))),b=Bx(d*T-C*p+O*g,d*A-C*g-O*p,v,m),i.set(o,x-1,b[0]),i.set(o,x,b[1]),Math.abs(d)>Math.abs(C)+Math.abs(O)?(i.set(o+1,x-1,(-p-h*i.get(o,x-1)+O*i.get(o,x))/d),i.set(o+1,x,(-g-h*i.get(o,x)-O*i.get(o,x-1))/d)):(b=Bx(-T-f*i.get(o,x-1),-A-f*i.get(o,x),C,O),i.set(o+1,x-1,b[0]),i.set(o+1,x,b[1]))),c=Math.max(Math.abs(i.get(o,x-1)),Math.abs(i.get(o,x))),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x-1,i.get(a,x-1)/c),i.set(a,x,i.get(a,x)/c)}for(o=0;o<t;o++)if(o<E||o>w)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=E;a--)for(o=E;o<=w;o++){for(C=0,s=E;s<=Math.min(a,w);s++)C+=r.get(o,s)*i.get(s,a);r.set(o,a,C)}}(o,l,s,a,t)}this.n=o,this.e=l,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 kx(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 Bx(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 Fx{constructor(t){if(!(t=Ax.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new kx(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=s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=Ax.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 zx{constructor(t,e={}){t=Ax.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=ix.isAnyArray(n)&&"number"==typeof n[0]?kx.columnVector(n):Ax.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,l,u,c,h=1;for(let e=0;e<i&&h>o;e++)u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),s=t.mmul(u).div(u.transpose().mmul(u).get(0,0)),e>0&&(h=s.clone().sub(c).pow(2).sum()),c=s.clone(),n?(l=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),l=l.div(l.norm()),a=n.mmul(l).div(l.transpose().mmul(l).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(l.transpose()));this.t=s,this.p=e.transpose(),this.w=u.transpose(),this.q=l,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=u.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(u.transpose()))}}Qb.AbstractMatrix=Ex,Qb.CHO=Fx,Qb.CholeskyDecomposition=Fx,Qb.DistanceMatrix=Sx,Qb.EVD=jx,Qb.EigenvalueDecomposition=jx,Qb.LU=Cx,Qb.LuDecomposition=Cx;var Gx=Qb.Matrix=kx;Qb.MatrixColumnSelectionView=class extends Nx{constructor(t,e){vx(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])}},Qb.MatrixColumnView=class extends Nx{constructor(t,e){dx(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)}},Qb.MatrixFlipColumnView=class extends Nx{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)}},Qb.MatrixFlipRowView=class extends Nx{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)}},Qb.MatrixRowSelectionView=class extends Nx{constructor(t,e){gx(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)}},Qb.MatrixRowView=class extends Nx{constructor(t,e){hx(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)}},Qb.MatrixSelectionView=Ox,Qb.MatrixSubView=class extends Nx{constructor(t,e,n,r,i){mx(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)}},Qb.MatrixTransposeView=class extends Nx{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)}},Qb.NIPALS=zx,Qb.Nipals=zx,Qb.QR=Rx,Qb.QrDecomposition=Rx,Qb.SVD=Dx;var Vx=Qb.SingularValueDecomposition=Dx;Qb.SymmetricMatrix=Mx,Qb.WrapperMatrix1D=Tx,Qb.WrapperMatrix2D=Ax,Qb.correlation=function(t,e=t,n={}){t=new kx(t);let r=!1;if("object"!=typeof e||kx.isMatrix(e)||ix.isAnyArray(e)?e=new kx(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}),l=t.transpose().mmul(e);for(let e=0;e<l.rows;e++)for(let n=0;n<l.columns;n++)l.set(e,n,l.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return l},Qb.covariance=function(t,e=t,n={}){t=new kx(t);let r=!1;if("object"!=typeof e||kx.isMatrix(e)||ix.isAnyArray(e)?e=new kx(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 Wx=Qb.default=kx;Qb.determinant=function t(e){if((e=kx.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 Ox(e,[1,2],[1,2]),a=new Ox(e,[1,2],[0,2]),s=new Ox(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 Cx(e).determinant}throw Error("determinant can only be calculated for a square matrix")},Qb.inverse=function(t,e=!1){return t=Ax.checkMatrix(t),e?new Dx(t).inverse():Lx(t,kx.eye(t.rows))},Qb.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=kx.checkMatrix(t)).rows,o=new kx(i,i);for(let e=0;e<i;e++){let a=kx.columnVector(t.getRow(e)),s=t.subMatrixRow(_x(i,e)).transpose(),l=new Dx(s).solve(a),u=kx.sub(a,s.mmul(l)).abs().max();o.setRow(e,Ix(u,l,e,n,r))}return o},Qb.pseudoInverse=function(t,e=Number.EPSILON){if((t=kx.checkMatrix(t)).isEmpty())return t.transpose();let n=new Dx(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(kx.diag(o).mmul(r.transpose()))},Qb.solve=Lx,Qb.wrap=function(t,e){if(ix.isAnyArray(t))return t[0]&&ix.isAnyArray(t[0])?new Ax(t):new Tx(t,e);throw new Error("the argument is not an array")};const Hx=Gx,Yx=Vx;Wx.Matrix&&Wx.Matrix;const Ux={center:[0,0],linkDistance:50};class $x{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},Ux),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericMDSLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericMDSLayout(!0,t,e)}))}genericMDSLayout(t,e,n){return ze(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 mb(e,t,i);const l=ob({nodes:a,edges:s}),u=ib(l);qx(u);const c=((t,e)=>{const n=[];return t.forEach((t=>{const r=[];t.forEach((t=>{r.push(t*e)})),n.push(r)})),n})(u,o),h=Xx(c),d=[];h.forEach(((t,e)=>{const n=ub(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 qx=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)}))}))},Xx=t=>{const e=Hx.mul(Hx.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 Yx(e),a=Hx.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>Hx.mul([t],[a]).toJSON()[0].splice(0,2)))};function Kx(t){return!!t.tick&&!!t.stop}const Zx={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Qx={center:[0,0],comboPadding:10,treeKey:"combo"};class Jx{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},Qx),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,e)}))}genericComboCombinedLayout(t,e,n){return ze(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)),l=e.getAllNodes().filter((t=>t.data._isCombo)),u=e.getAllEdges(),c=null==s?void 0:s.length;if(!c||1===c)return mb(e,t,i);const h=[],d=new Map;s.forEach((t=>{d.set(t.id,t)}));const f=new Map;l.forEach((t=>{f.set(t.id,t)}));const p=new Map,g=this.getInnerGraphs(e,o,d,f,u,r,p);yield Promise.all(g);const v=new Map,m=[],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})};m.push(i),v.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,sb(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const x=[];let E;if(u.forEach((t=>{const e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&v.has(e)&&v.has(n)&&x.push({id:t.id,source:e,target:n,data:{}})})),null==m?void 0:m.length){if(1===m.length)m[0].data.x=i[0],m[0].data.y=i[1];else{const t=new Yg({nodes:m,edges:x}),e=a||new Ub;if(b&&Zx[e.id]){const e=m.length<100?new $x:new kb;yield e.assign(t)}const n=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}:{});E=yield tE(e,t,n)}p.forEach((t=>{var e;const n=E.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,h.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=>{h.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=h.find((e=>e.id===t.id));r.data.x+=e||0,r.data.y+=n||0}}))}))}t&&h.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:h,edges:u}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=ae(r)?()=>r:Yt(r)?r:()=>0,e.spacing=a,n)if(Yt(n))o=t=>{const e=n(t),r=a(t);if(rb(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(rb(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(rb(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(qt(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=ae(i)?()=>i:rb(i)?()=>Math.max.apply(null,i):Yt(i)?i:()=>0,e.comboPadding=s,e}getInnerGraphs(t,e,n,r,i,o,a){const{nodeSize:s,comboPadding:l,spacing:u,innerLayout:c}=o,h=c||new kb({}),d={center:[0,0],preventOverlap:!0,nodeSpacing:u},f=[],p=t=>{let e=(null==l?void 0:l(t))||10;return rb(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((o=>{a.set(o.id,{id:o.id,data:{nodes:[],size:p(o).size}});let l=Promise.resolve();sb(t,[o],(o=>{var u;if(!o.data._isCombo)return;const{size:c,padding:f}=p(o);if(null===(u=t.getChildren(o.id,e))||void 0===u?void 0:u.length){const u=a.get(o.id);a.set(o.id,{id:o.id,data:Object.assign({nodes:[]},null==u?void 0:u.data)});const c=new Map,p=t.getChildren(o.id,e).map((t=>{if(t.data._isCombo)return a.has(t.id)||a.set(t.id,{id:t.id,data:Object.assign({},t.data)}),c.set(t.id,!0),a.get(t.id);const e=n.get(t.id)||r.get(t.id);return c.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),g={nodes:p,edges:i.filter((t=>c.has(t.source)&&c.has(t.target)))};let v=1/0;p.forEach((t=>{var e;let{size:n}=t.data;n||(n=(null===(e=a.get(t.id))||void 0===e?void 0:e.data.size)||(null==s?void 0:s(t))||[30,30]),ae(n)&&(n=[n,n]);const[r,i]=n;v>r&&(v=r),v>i&&(v=i),t.data.size=n})),l=l.then((()=>ze(this,void 0,void 0,(function*(){const t=new Yg(g);yield tE(h,t,d,!0);const{minX:e,minY:n,maxX:r,maxY:i}=(t=>{let e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((t=>{let o=t.data.size;rb(o)?1===o.length&&(o=[o[0],o[0]]):ae(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],l=t.data.x+a[0],u=t.data.y-a[1],c=t.data.y+a[1];e>s&&(e=s),n>u&&(n=u),r<l&&(r=l),i<c&&(i=c)})),{minX:e,minY:n,maxX:r,maxY:i}})(p),s=(r+e)/2,l=(i+n)/2;g.nodes.forEach((t=>{t.data.x-=s,t.data.y-=l}));const u=[Math.max(r-e,v)+2*f,Math.max(i-n,v)+2*f];a.get(o.id).data.size=u,a.get(o.id).data.nodes=p}))))}else a.set(o.id,{id:o.id,data:Object.assign(Object.assign({},o.data),{size:c})});return!0}),"BT",e),f.push(l)})),f}}function tE(t,e,n,r){var i;return ze(this,void 0,void 0,(function*(){return Kx(t)?(t.execute(e,n),t.stop(),t.tick(null!==(i=n.iterations)&&void 0!==i?i:300)):r?yield t.assign(e,n):yield t.execute(e,n)}))}function eE(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,l=0;for(i=0;i<a;++i)s+=(o=n[i]).x,l+=o.y;for(s=(s/a-t)*r,l=(l/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=l}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}function nE(t){return function(){return t}}function rE(t){return 1e-6*(t()-.5)}function iE(t){return t.x+t.vx}function oE(t){return t.y+t.vy}function aE(t){var e,n,r,i=1,o=1;function a(){for(var t,a,l,u,c,h,d,f=e.length,p=0;p<o;++p)for(a=Tb(e,iE,oE).visitAfter(s),t=0;t<f;++t)l=e[t],h=n[l.index],d=h*h,u=l.x+l.vx,c=l.y+l.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=h+f;if(!s)return e>u+p||o<u-p||n>c+p||a<c-p;if(s.index>l.index){var g=u-s.x-s.vx,v=c-s.y-s.vy,m=g*g+v*v;m<p*p&&(0===g&&(m+=(g=rE(r))*g),0===v&&(m+=(v=rE(r))*v),m=(p-(m=Math.sqrt(m)))/m*i,l.vx+=(g*=m)*(p=(f*=f)/(d+f)),l.vy+=(v*=m)*p,s.vx-=g*(p=1-p),s.vy-=v*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 l(){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=nE(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,l()},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:nE(+e),l(),a):t},a}function sE(t){return t.index}function lE(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function uE(t){var e,n,r,i,o,a,s=sE,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},u=nE(30),c=1;function h(r){for(var i=0,s=t.length;i<c;++i)for(var l,u,h,d,f,p,g,v=0;v<s;++v)u=(l=t[v]).source,d=(h=l.target).x+h.vx-u.x-u.vx||rE(a),f=h.y+h.vy-u.y-u.vy||rE(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[v])/p*r*e[v],f*=p,h.vx-=d*(g=o[v]),h.vy-=f*g,u.vx+=d*(g=1-g),u.vy+=f*g}function d(){if(r){var a,l,u=r.length,c=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(u);a<c;++a)(l=t[a]).index=a,"object"!=typeof l.source&&(l.source=lE(h,l.source)),"object"!=typeof l.target&&(l.target=lE(h,l.target)),i[l.source.index]=(i[l.source.index]||0)+1,i[l.target.index]=(i[l.target.index]||0)+1;for(a=0,o=new Array(c);a<c;++a)l=t[a],o[a]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(c),f(),n=new Array(c),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+u(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,a=e,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(s=t,h):s},h.iterations=function(t){return arguments.length?(c=+t,h):c},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:nE(+t),f(),h):l},h.distance=function(t){return arguments.length?(u="function"==typeof t?t:nE(+t),p(),h):u},h}var cE={value:()=>{}};function hE(){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 dE(r)}function dE(t){this._=t}function fE(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function pE(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=cE,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}dE.prototype=hE.prototype={constructor:dE,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]=pE(i[n],t.name,e);else if(null==e)for(n in i)i[n]=pE(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=fE(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new dE(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 gE,vE,mE=0,yE=0,bE=0,xE=0,EE=0,wE=0,kE="object"==typeof performance&&performance.now?performance:Date,ME="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function SE(){return EE||(ME(NE),EE=kE.now()+wE)}function NE(){EE=0}function OE(){this._call=this._time=this._next=null}function TE(t,e,n){var r=new OE;return r.restart(t,e,n),r}function AE(){EE=(xE=kE.now())+wE,mE=yE=0;try{!function(){SE(),++mE;for(var t,e=gE;e;)(t=EE-e._time)>=0&&e._call.call(void 0,t),e=e._next;--mE}()}finally{mE=0,function(){var t,e,n=gE,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:gE=e);vE=t,PE(r)}(),EE=0}}function CE(){var t=kE.now(),e=t-xE;e>1e3&&(wE-=e,xE=t)}function PE(t){mE||(yE&&(yE=clearTimeout(yE)),t-EE>24?(t<1/0&&(yE=setTimeout(AE,t-kE.now()-wE)),bE&&(bE=clearInterval(bE))):(bE||(xE=kE.now(),bE=setInterval(CE,1e3)),mE=1,ME(AE)))}OE.prototype=TE.prototype={constructor:OE,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?SE():+n)+(null==e?0:+e),this._next||vE===this||(vE?vE._next=this:gE=this,vE=this),this._call=t,this._time=n,PE()},stop:function(){this._call&&(this._call=null,this._time=1/0,PE())}};const RE=4294967296;function DE(t){return t.x}function LE(t){return t.y}var _E=Math.PI*(3-Math.sqrt(5));function IE(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=TE(h),u=hE("tick","end"),c=function(){let t=1;return()=>(t=(1664525*t+1013904223)%RE)/RE}();function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(r){var l,u,c=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),l=0;l<c;++l)null==(u=t[l]).fx?u.x+=u.vx*=a:(u.x=u.fx,u.vx=0),null==u.fy?u.y+=u.vy*=a:(u.y=u.fy,u.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=10*Math.sqrt(.5+n),o=n*_E;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,c),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.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?(c=t,s.forEach(p),e):c},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,l,u=0,c=t.length;for(null==r?r=1/0:r*=r,u=0;u<c;++u)(a=(i=e-(s=t[u]).x)*i+(o=n-s.y)*o)<r&&(l=s,r=a);return l},on:function(t,n){return arguments.length>1?(u.on(t,n),e):u.on(t)}}}function jE(){var t,e,n,r,i,o=nE(-30),a=1,s=1/0,l=.81;function u(n){var i,o=t.length,a=Tb(t,DE,LE).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function c(){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 h(t){var e,n,r,o,a,s=0,l=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,l+=n,r+=n*e.x,o+=n*e.y);t.x=r/l,t.y=o/l}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,u,c){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,f=c-o,p=h*h+d*d;if(f*f/l<p)return p<s&&(0===h&&(p+=(h=rE(n))*h),0===d&&(p+=(d=rE(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=h*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===h&&(p+=(h=rE(n))*h),0===d&&(p+=(d=rE(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=h*f,e.vy+=d*f)}while(t=t.next)}}return u.initialize=function(e,r){t=e,n=r,c()},u.strength=function(t){return arguments.length?(o="function"==typeof t?t:nE(+t),c(),u):o},u.distanceMin=function(t){return arguments.length?(a=t*t,u):Math.sqrt(a)},u.distanceMax=function(t){return arguments.length?(s=t*t,u):Math.sqrt(s)},u.theta=function(t){return arguments.length?(l=t*t,u):Math.sqrt(l)},u}function BE(t,e,n){var r,i,o,a=nE(.1);function s(t){for(var a=0,s=r.length;a<s;++a){var l=r[a],u=l.x-e||1e-6,c=l.y-n||1e-6,h=Math.sqrt(u*u+c*c),d=(o[a]-h)*i[a]*t/h;l.vx+=u*d,l.vy+=c*d}}function l(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+a(r[e],e,r)}}return"function"!=typeof t&&(t=nE(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,l()},s.strength=function(t){return arguments.length?(a="function"==typeof t?t:nE(+t),l(),s):a},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:nE(+e),l(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}function FE(t){var e,n,r,i=nE(.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=nE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:nE(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:nE(+e),a(),o):t},o}function zE(t){var e,n,r,i=nE(.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=nE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:nE(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:nE(+e),a(),o):t},o}class GE{constructor(t){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:uE,manyBody:jE,center:eE,collide:aE,radial:BE,x:FE,y:zE},this.options={link:{id:t=>t.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},ke(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericLayout(!0,t,e)}))}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const n=this.context.nodes.find((e=>e.id===t));n&&e.forEach(((t,e)=>{if("number"==typeof t||null===t){n[["fx","fy","fz"][e]]=t}}))}getOptions(t){var e,n;const r=ke({},this.options,t);return r.collide&&void 0===(null===(e=r.collide)||void 0===e?void 0:e.radius)&&(r.collide=r.collide||{},r.collide.radius=null!==(n=r.nodeSize)&&void 0!==n?n:10),void 0===r.iterations&&(r.link&&void 0===r.link.iterations&&(r.iterations=r.link.iterations),r.collide&&void 0===r.collide.iterations&&(r.iterations=r.collide.iterations)),this.context.options=r,r}genericLayout(t,e,n){var r;return ze(this,void 0,void 0,(function*(){const i=this.getOptions(n),o=e.getAllNodes().map((({id:t,data:e})=>Object.assign(Object.assign({id:t},e),Ce(e.data,this.config.inputNodeAttrs)))),a=e.getAllEdges().map((t=>Object.assign({},t)));Object.assign(this.context,{assign:t,nodes:o,edges:a,graph:e});const s=new Promise((t=>{this.resolver=t})),l=this.setSimulation(i);return l.nodes(o),null===(r=l.force("link"))||void 0===r||r.links(a),s}))}getResult(){const{assign:t,nodes:e,edges:n,graph:r}=this.context,i=e.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),Ce(t,this.config.outputNodeAttrs))}))),o=n.map((({id:t,source:e,target:n,data:r})=>({id:t,source:"object"==typeof e?e.id:e,target:"object"==typeof n?n.id:n,data:r})));return t&&i.forEach((t=>r.mergeNodeData(t.id,t.data))),{nodes:i,edges:o}}initSimulation(){return IE()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",(()=>{var e;return null===(e=t.onTick)||void 0===e?void 0:e.call(t,this.getResult())})).on("end",(()=>{var t;return null===(t=this.resolver)||void 0===t?void 0:t.call(this,this.getResult())}))),VE(e,this.config.simulationAttrs.map((e=>[e,t[e]]))),Object.entries(this.forceMap).forEach((([n,r])=>{const i=n;if(t[n]){let n=e.force(i);n||(n=r(),e.force(i,n)),VE(n,Object.entries(t[i]))}else e.force(i,null)})),e}}const VE=(t,e)=>e.reduce(((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e),t);var WE,HE,YE,UE,$E,qE,XE,KE,ZE,QE,JE,tw,ew,nw,rw,iw,ow,aw,sw,lw,uw,cw,hw,dw,fw,pw,gw,vw,mw,yw,bw,xw,Ew,ww,kw,Mw,Sw,Nw,Ow,Tw,Aw,Cw,Pw,Rw,Dw,Lw,_w,Iw,jw,Bw,Fw,zw,Gw,Vw,Ww,Hw,Yw,Uw,$w,qw,Xw,Kw,Zw,Qw,Jw,tk,ek,nk,rk,ik,ok,ak,sk,lk,uk,ck,hk,dk,fk,pk,gk,vk,mk,yk,bk,xk,Ek,wk,kk,Mk,Sk,Nk,Ok,Tk,Ak,Ck,Pk,Rk,Dk,Lk,_k,Ik,jk,Bk,Fk,zk,Gk,Vk;function Wk(){if(UE)return YE;return UE=1,YE=function(t,e){return t===e||t!=t&&e!=e}}function Hk(){if(qE)return $E;qE=1;var t=Wk();return $E=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},$E}function Yk(){if(iw)return rw;iw=1;var t=HE?WE:(HE=1,WE=function(){this.__data__=[],this.size=0}),e=function(){if(KE)return XE;KE=1;var t=Hk(),e=Array.prototype.splice;return XE=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))},XE}(),n=function(){if(QE)return ZE;QE=1;var t=Hk();return ZE=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},ZE}(),r=function(){if(tw)return JE;tw=1;var t=Hk();return JE=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(nw)return ew;nw=1;var t=Hk();return ew=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},ew}();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,rw=o}function Uk(){if(pw)return fw;pw=1;var t="object"==typeof x&&x&&x.Object===Object&&x;return fw=t}function $k(){if(vw)return gw;vw=1;var t=Uk(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return gw=n}function qk(){if(yw)return mw;yw=1;var t=$k().Symbol;return mw=t}function Xk(){if(Mw)return kw;Mw=1;var t=qk(),e=function(){if(xw)return bw;xw=1;var t=qk(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return bw=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(ww)return Ew;ww=1;var t=Object.prototype.toString;return Ew=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return kw=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function Kk(){if(Nw)return Sw;return Nw=1,Sw=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Zk(){if(Tw)return Ow;Tw=1;var t=Xk(),e=Kk();return Ow=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 Qk(){if(Rw)return Pw;Rw=1;var t,e=function(){if(Cw)return Aw;Cw=1;var t=$k()["__core-js_shared__"];return Aw=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Pw=function(t){return!!n&&n in t}}function Jk(){if(Lw)return Dw;Lw=1;var t=Function.prototype.toString;return Dw=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function tM(){if(zw)return Fw;zw=1;var t=function(){if(Iw)return _w;Iw=1;var t=Zk(),e=Qk(),n=Kk(),r=Jk(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,l=a.hasOwnProperty,u=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return _w=function(o){return!(!n(o)||e(o))&&(t(o)?u:i).test(r(o))}}(),e=Bw?jw:(Bw=1,jw=function(t,e){return null==t?void 0:t[e]});return Fw=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function eM(){if(Vw)return Gw;Vw=1;var t=tM()($k(),"Map");return Gw=t}function nM(){if(Hw)return Ww;Hw=1;var t=tM()(Object,"create");return Ww=t}function rM(){if(nk)return ek;nk=1;var t=function(){if(Uw)return Yw;Uw=1;var t=nM();return Yw=function(){this.__data__=t?t(null):{},this.size=0}}(),e=qw?$w:(qw=1,$w=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(Kw)return Xw;Kw=1;var t=nM(),e=Object.prototype.hasOwnProperty;return Xw=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},Xw}(),r=function(){if(Qw)return Zw;Qw=1;var t=nM(),e=Object.prototype.hasOwnProperty;return Zw=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},Zw}(),i=function(){if(tk)return Jw;tk=1;var t=nM();return Jw=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},Jw}();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,ek=o}function iM(){if(lk)return sk;lk=1;var t=ak?ok:(ak=1,ok=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return sk=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},sk}function oM(){if(yk)return mk;yk=1;var t=function(){if(ik)return rk;ik=1;var t=rM(),e=Yk(),n=eM();return rk=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(ck)return uk;ck=1;var t=iM();return uk=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(dk)return hk;dk=1;var t=iM();return hk=function(e){return t(this,e).get(e)}}(),r=function(){if(pk)return fk;pk=1;var t=iM();return fk=function(e){return t(this,e).has(e)}}(),i=function(){if(vk)return gk;vk=1;var t=iM();return gk=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},gk}();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,mk=o}function aM(){if(wk)return Ek;wk=1;var t=Yk(),e=function(){if(aw)return ow;aw=1;var t=Yk();return ow=function(){this.__data__=new t,this.size=0}}(),n=(lw||(lw=1,sw=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),sw),r=cw?uw:(cw=1,uw=function(t){return this.__data__.get(t)}),i=dw?hw:(dw=1,hw=function(t){return this.__data__.has(t)}),o=function(){if(xk)return bk;xk=1;var t=Yk(),e=eM(),n=oM();return bk=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},bk}();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,Ek=a}function sM(){if(Mk)return kk;return Mk=1,kk=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},kk}function lM(){if(Nk)return Sk;Nk=1;var t=tM(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Sk=e}function uM(){if(Tk)return Ok;Tk=1;var t=lM();return Ok=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function cM(){if(Ck)return Ak;Ck=1;var t=uM(),e=Wk(),n=Object.prototype.hasOwnProperty;return Ak=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 hM(){if(Rk)return Pk;Rk=1;var t=cM(),e=uM();return Pk=function(n,r,i,o){var a=!i;i||(i={});for(var s=-1,l=r.length;++s<l;){var u=r[s],c=o?o(i[u],n[u],u,i,n):void 0;void 0===c&&(c=n[u]),a?e(i,u,c):t(i,u,c)}return i},Pk}function dM(){if(Ik)return _k;return Ik=1,_k=function(t){return null!=t&&"object"==typeof t}}function fM(){if(zk)return Fk;zk=1;var t=function(){if(Bk)return jk;Bk=1;var t=Xk(),e=dM();return jk=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=dM(),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 Fk=o}function pM(){if(Vk)return Gk;Vk=1;var t=Array.isArray;return Gk=t}var gM,vM,mM,yM,bM,xM,EM,wM,kM,MM,SM,NM={exports:{}};function OM(){return mM||(mM=1,function(t,e){var n=$k(),r=vM?gM:(vM=1,gM=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}(NM,NM.exports)),NM.exports}function TM(){if(bM)return yM;bM=1;var t=/^(?:0|[1-9]\d*)$/;return yM=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},yM}function AM(){if(EM)return xM;EM=1;return xM=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function CM(){if(SM)return MM;return SM=1,MM=function(t){return function(e){return t(e)}}}var PM,RM,DM,LM,_M,IM,jM,BM,FM,zM,GM,VM,WM,HM,YM,UM,$M,qM,XM,KM,ZM,QM,JM,tS,eS,nS,rS,iS={exports:{}};function oS(){return PM||(PM=1,function(t,e){var n=Uk(),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}(iS,iS.exports)),iS.exports}function aS(){if(DM)return RM;DM=1;var t=function(){if(kM)return wM;kM=1;var t=Xk(),e=AM(),n=dM(),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,wM=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=CM(),n=oS(),r=n&&n.isTypedArray,i=r?e(r):t;return RM=i}function sS(){if(_M)return LM;_M=1;var t=(Lk||(Lk=1,Dk=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),Dk),e=fM(),n=pM(),r=OM(),i=TM(),o=aS(),a=Object.prototype.hasOwnProperty;return LM=function(s,l){var u=n(s),c=!u&&e(s),h=!u&&!c&&r(s),d=!u&&!c&&!h&&o(s),f=u||c||h||d,p=f?t(s.length,String):[],g=p.length;for(var v in s)!l&&!a.call(s,v)||f&&("length"==v||h&&("offset"==v||"parent"==v)||d&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||i(v,g))||p.push(v);return p},LM}function lS(){if(jM)return IM;jM=1;var t=Object.prototype;return IM=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function uS(){if(FM)return BM;return FM=1,BM=function(t,e){return function(n){return t(e(n))}}}function cS(){if(WM)return VM;WM=1;var t=lS(),e=function(){if(GM)return zM;GM=1;var t=uS()(Object.keys,Object);return zM=t}(),n=Object.prototype.hasOwnProperty;return VM=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 hS(){if(YM)return HM;YM=1;var t=Zk(),e=AM();return HM=function(n){return null!=n&&e(n.length)&&!t(n)}}function dS(){if($M)return UM;$M=1;var t=sS(),e=cS(),n=hS();return UM=function(r){return n(r)?t(r):e(r)}}function fS(){if(JM)return QM;JM=1;var t=Kk(),e=lS(),n=ZM?KM:(ZM=1,KM=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return QM=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 pS(){if(eS)return tS;eS=1;var t=sS(),e=fS(),n=hS();return tS=function(r){return n(r)?t(r,!0):e(r)}}var gS,vS,mS,yS,bS,xS,ES,wS,kS,MS,SS,NS,OS,TS,AS,CS,PS,RS,DS,LS,_S,IS,jS,BS,FS,zS,GS,VS,WS,HS,YS,US,$S,qS,XS,KS,ZS,QS,JS,tN,eN,nN,rN,iN,oN,aN,sN,lN,uN,cN,hN,dN,fN,pN,gN,vN,mN,yN,bN,xN,EN,wN,kN,MN,SN,NN,ON,TN,AN,CN,PN,RN,DN,LN,_N,IN,jN,BN,FN,zN,GN,VN,WN,HN,YN,UN,$N,qN,XN,KN,ZN,QN,JN,tO,eO,nO,rO,iO,oO,aO,sO,lO,uO,cO,hO,dO,fO,pO,gO,vO,mO,yO,bO,xO,EO,wO,kO,MO,SO,NO,OO,TO,AO,CO,PO,RO,DO,LO,_O,IO,jO,BO,FO,zO,GO,VO,WO,HO,YO,UO,$O,qO,XO,KO,ZO,QO,JO,tT,eT,nT,rT,iT,oT,aT,sT,lT,uT,cT,hT,dT,fT,pT,gT,vT,mT,yT,bT,xT,ET,wT,kT,MT,ST,NT,OT,TT,AT,CT,PT,RT,DT,LT,_T,IT,jT,BT,FT,zT,GT,VT,WT,HT,YT,UT,$T,qT,XT,KT,ZT,QT,JT,tA,eA,nA,rA,iA,oA,aA,sA,lA,uA,cA,hA,dA,fA,pA,gA,vA,mA,yA,bA,xA,EA,wA,kA,MA,SA,NA,OA,TA,AA,CA,PA,RA,DA,LA,_A,IA,jA,BA,FA,zA,GA,VA,WA,HA,YA,UA,$A,qA,XA,KA,ZA,QA,JA,tC,eC,nC,rC,iC,oC,aC,sC,lC,uC,cC,hC,dC,fC,pC,gC,vC,mC,yC,bC,xC,EC,wC,kC,MC,SC={exports:{}};function NC(){return gS||(gS=1,function(t,e){var n=$k(),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}}(SC,SC.exports)),SC.exports}function OC(){if(mS)return vS;return mS=1,vS=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},vS}function TC(){if(bS)return yS;return bS=1,yS=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},yS}function AC(){if(ES)return xS;return ES=1,xS=function(){return[]}}function CC(){if(kS)return wS;kS=1;var t=TC(),e=AC(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return wS=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function PC(){if(OS)return NS;return OS=1,NS=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},NS}function RC(){if(AS)return TS;AS=1;var t=uS()(Object.getPrototypeOf,Object);return TS=t}function DC(){if(PS)return CS;PS=1;var t=PC(),e=RC(),n=CC(),r=AC(),i=Object.getOwnPropertySymbols;return CS=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function LC(){if(_S)return LS;_S=1;var t=PC(),e=pM();return LS=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function _C(){if(jS)return IS;jS=1;var t=LC(),e=CC(),n=dS();return IS=function(r){return t(r,n,e)}}function IC(){if(YS)return HS;YS=1;var t=tM()($k(),"Set");return HS=t}function jC(){if(XS)return qS;XS=1;var t=function(){if(GS)return zS;GS=1;var t=tM()($k(),"DataView");return zS=t}(),e=eM(),n=function(){if(WS)return VS;WS=1;var t=tM()($k(),"Promise");return VS=t}(),r=IC(),i=function(){if($S)return US;$S=1;var t=tM()($k(),"WeakMap");return US=t}(),o=Xk(),a=Jk(),s="[object Map]",l="[object Promise]",u="[object Set]",c="[object WeakMap]",h="[object DataView]",d=a(t),f=a(e),p=a(n),g=a(r),v=a(i),m=o;return(t&&m(new t(new ArrayBuffer(1)))!=h||e&&m(new e)!=s||n&&m(n.resolve())!=l||r&&m(new r)!=u||i&&m(new i)!=c)&&(m=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 h;case f:return s;case p:return l;case g:return u;case v:return c}return e}),qS=m}function BC(){if(JS)return QS;JS=1;var t=$k().Uint8Array;return QS=t}function FC(){if(eN)return tN;eN=1;var t=BC();return tN=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function zC(){if(uN)return lN;uN=1;var t=FC();return lN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function GC(){if(hN)return cN;hN=1;var t=FC(),e=function(){if(rN)return nN;rN=1;var t=FC();return nN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(oN)return iN;oN=1;var t=/\w*$/;return iN=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(sN)return aN;sN=1;var t=qk(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return aN=function(t){return n?Object(n.call(t)):{}}}(),i=zC();return cN=function(o,a,s){var l=o.constructor;switch(a){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new l(+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 l;case"[object Number]":case"[object String]":return new l(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function VC(){if(fN)return dN;fN=1;var t=Kk(),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 dN=n}function WC(){if(gN)return pN;gN=1;var t=VC(),e=RC(),n=lS();return pN=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function HC(){if(bN)return yN;bN=1;var t=function(){if(mN)return vN;mN=1;var t=jC(),e=dM();return vN=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=CM(),n=oS(),r=n&&n.isMap,i=r?e(r):t;return yN=i}function YC(){if(kN)return wN;kN=1;var t=function(){if(EN)return xN;EN=1;var t=jC(),e=dM();return xN=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=CM(),n=oS(),r=n&&n.isSet,i=r?e(r):t;return wN=i}function UC(){if(SN)return MN;SN=1;var t=aM(),e=sM(),n=cM(),r=function(){if(XM)return qM;XM=1;var t=hM(),e=dS();return qM=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(rS)return nS;rS=1;var t=hM(),e=pS();return nS=function(n,r){return n&&t(r,e(r),n)}}(),o=NC(),a=OC(),s=function(){if(SS)return MS;SS=1;var t=hM(),e=CC();return MS=function(n,r){return t(n,e(n),r)}}(),l=function(){if(DS)return RS;DS=1;var t=hM(),e=DC();return RS=function(n,r){return t(n,e(n),r)}}(),u=_C(),c=function(){if(FS)return BS;FS=1;var t=LC(),e=DC(),n=pS();return BS=function(r){return t(r,n,e)}}(),h=jC(),d=function(){if(ZS)return KS;ZS=1;var t=Object.prototype.hasOwnProperty;return KS=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},KS}(),f=GC(),p=WC(),g=pM(),v=OM(),m=HC(),y=Kk(),b=YC(),x=dS(),E=pS(),w="[object Arguments]",k="[object Function]",M="[object Object]",S={};return S[w]=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[M]=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[k]=S["[object WeakMap]"]=!1,MN=function N(O,T,A,C,P,R){var D,L=1&T,_=2&T,I=4&T;if(A&&(D=P?A(O,C,P,R):A(O)),void 0!==D)return D;if(!y(O))return O;var j=g(O);if(j){if(D=d(O),!L)return a(O,D)}else{var B=h(O),F=B==k||"[object GeneratorFunction]"==B;if(v(O))return o(O,L);if(B==M||B==w||F&&!P){if(D=_||F?{}:p(O),!L)return _?l(O,i(D,O)):s(O,r(D,O))}else{if(!S[B])return P?O:{};D=f(O,B,L)}}R||(R=new t);var z=R.get(O);if(z)return z;R.set(O,D),b(O)?O.forEach((function(t){D.add(N(t,T,A,t,O,R))})):m(O)&&O.forEach((function(t,e){D.set(e,N(t,T,A,e,O,R))}));var G=j?void 0:(I?_?c:u:_?E:x)(O);return e(G||O,(function(t,e){G&&(t=O[e=t]),n(D,e,N(t,T,A,e,O,R))})),D},MN}function $C(){if(ON)return NN;ON=1;var t=UC();return NN=function(e){return t(e,4)}}function qC(){if(AN)return TN;return AN=1,TN=function(t){return function(){return t}}}function XC(){if(DN)return RN;DN=1;var t=(PN||(PN=1,CN=function(t){return function(e,n,r){for(var i=-1,o=Object(e),a=r(e),s=a.length;s--;){var l=a[t?s:++i];if(!1===n(o[l],l,o))break}return e}}),CN),e=t();return RN=e}function KC(){if(_N)return LN;_N=1;var t=XC(),e=dS();return LN=function(n,r){return n&&t(n,r,e)}}function ZC(){if(FN)return BN;FN=1;var t=KC(),e=function(){if(jN)return IN;jN=1;var t=hS();return IN=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}},IN}(),n=e(t);return BN=n}function QC(){if(GN)return zN;return GN=1,zN=function(t){return t}}function JC(){if(WN)return VN;WN=1;var t=QC();return VN=function(e){return"function"==typeof e?e:t}}function tP(){if(YN)return HN;YN=1;var t=sM(),e=ZC(),n=JC(),r=pM();return HN=function(i,o){return(r(i)?t:e)(i,n(o))}}function eP(){return $N?UN:($N=1,UN=tP())}function nP(){if(eO)return tO;eO=1;var t=oM(),e=ZN?KN:(ZN=1,KN=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=JN?QN:(JN=1,QN=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,tO=r}function rP(){if(oO)return iO;return oO=1,iO=function(t,e){return t.has(e)}}function iP(){if(sO)return aO;sO=1;var t=nP(),e=(rO||(rO=1,nO=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}),nO),n=rP();return aO=function(r,i,o,a,s,l){var u=1&o,c=r.length,h=i.length;if(c!=h&&!(u&&h>c))return!1;var d=l.get(r),f=l.get(i);if(d&&f)return d==i&&f==r;var p=-1,g=!0,v=2&o?new t:void 0;for(l.set(r,i),l.set(i,r);++p<c;){var m=r[p],y=i[p];if(a)var b=u?a(y,m,p,i,r,l):a(m,y,p,r,i,l);if(void 0!==b){if(b)continue;g=!1;break}if(v){if(!e(i,(function(t,e){if(!n(v,e)&&(m===t||s(m,t,o,a,l)))return v.push(e)}))){g=!1;break}}else if(m!==y&&!s(m,y,o,a,l)){g=!1;break}}return l.delete(r),l.delete(i),g},aO}function oP(){if(hO)return cO;return hO=1,cO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},cO}function aP(){if(fO)return dO;fO=1;var t=qk(),e=BC(),n=Wk(),r=iP(),i=(uO||(uO=1,lO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),lO),o=oP(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return dO=function(t,a,l,u,c,h,d){switch(l){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||!h(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&u;if(f||(f=o),t.size!=a.size&&!p)return!1;var g=d.get(t);if(g)return g==a;u|=2,d.set(t,a);var v=r(f(t),f(a),u,c,h,d);return d.delete(t),v;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function sP(){if(mO)return vO;mO=1;var t=aM(),e=iP(),n=aP(),r=function(){if(gO)return pO;gO=1;var t=_C(),e=Object.prototype.hasOwnProperty;return pO=function(n,r,i,o,a,s){var l=1&i,u=t(n),c=u.length;if(c!=t(r).length&&!l)return!1;for(var h=c;h--;){var d=u[h];if(!(l?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 v=l;++h<c;){var m=n[d=u[h]],y=r[d];if(o)var b=l?o(y,m,d,r,n,s):o(m,y,d,n,r,s);if(!(void 0===b?m===y||a(m,y,i,o,s):b)){g=!1;break}v||(v="constructor"==d)}if(g&&!v){var x=n.constructor,E=r.constructor;x==E||!("constructor"in n)||!("constructor"in r)||"function"==typeof x&&x instanceof x&&"function"==typeof E&&E instanceof E||(g=!1)}return s.delete(n),s.delete(r),g},pO}(),i=jC(),o=pM(),a=OM(),s=aS(),l="[object Arguments]",u="[object Array]",c="[object Object]",h=Object.prototype.hasOwnProperty;return vO=function(d,f,p,g,v,m){var y=o(d),b=o(f),x=y?u:i(d),E=b?u:i(f),w=(x=x==l?c:x)==c,k=(E=E==l?c:E)==c,M=x==E;if(M&&a(d)){if(!a(f))return!1;y=!0,w=!1}if(M&&!w)return m||(m=new t),y||s(d)?e(d,f,p,g,v,m):n(d,f,x,p,g,v,m);if(!(1&p)){var S=w&&h.call(d,"__wrapped__"),N=k&&h.call(f,"__wrapped__");if(S||N){var O=S?d.value():d,T=N?f.value():f;return m||(m=new t),v(O,T,p,g,m)}}return!!M&&(m||(m=new t),r(d,f,p,g,v,m))}}function lP(){if(bO)return yO;bO=1;var t=sP(),e=dM();return yO=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))},yO}function uP(){if(kO)return wO;kO=1;var t=Kk();return wO=function(e){return e==e&&!t(e)}}function cP(){if(OO)return NO;return OO=1,NO=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function hP(){if(AO)return TO;AO=1;var t=function(){if(EO)return xO;EO=1;var t=aM(),e=lP();return xO=function(n,r,i,o){var a=i.length,s=a,l=!o;if(null==n)return!s;for(n=Object(n);a--;){var u=i[a];if(l&&u[2]?u[1]!==n[u[0]]:!(u[0]in n))return!1}for(;++a<s;){var c=(u=i[a])[0],h=n[c],d=u[1];if(l&&u[2]){if(void 0===h&&!(c in n))return!1}else{var f=new t;if(o)var p=o(h,d,c,n,r,f);if(!(void 0===p?e(d,h,3,o,f):p))return!1}}return!0},xO}(),e=function(){if(SO)return MO;SO=1;var t=uP(),e=dS();return MO=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},MO}(),n=cP();return TO=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 dP(){if(PO)return CO;PO=1;var t=Xk(),e=dM();return CO=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function fP(){if(DO)return RO;DO=1;var t=pM(),e=dP(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return RO=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 pP(){if(jO)return IO;jO=1;var t=function(){if(_O)return LO;_O=1;var t=oM();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,LO=e}();return IO=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function gP(){if(GO)return zO;return GO=1,zO=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},zO}function vP(){if(YO)return HO;YO=1;var t=function(){if(WO)return VO;WO=1;var t=qk(),e=gP(),n=pM(),r=dP(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return VO=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},VO}();return HO=function(e){return null==e?"":t(e)}}function mP(){if($O)return UO;$O=1;var t=pM(),e=fP(),n=function(){if(FO)return BO;FO=1;var t=pP(),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 BO=r}(),r=vP();return UO=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function yP(){if(XO)return qO;XO=1;var t=dP();return qO=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function bP(){if(ZO)return KO;ZO=1;var t=mP(),e=yP();return KO=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},KO}function xP(){if(rT)return nT;rT=1;var t=mP(),e=fM(),n=pM(),r=TM(),i=AM(),o=yP();return nT=function(a,s,l){for(var u=-1,c=(s=t(s,a)).length,h=!1;++u<c;){var d=o(s[u]);if(!(h=null!=a&&l(a,d)))break;a=a[d]}return h||++u!=c?h:!!(c=null==a?0:a.length)&&i(c)&&r(d,c)&&(n(a)||e(a))},nT}function EP(){if(oT)return iT;oT=1;var t=eT?tT:(eT=1,tT=function(t,e){return null!=t&&e in Object(t)}),e=xP();return iT=function(n,r){return null!=n&&e(n,r,t)}}function wP(){if(sT)return aT;sT=1;var t=lP(),e=function(){if(JO)return QO;JO=1;var t=bP();return QO=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=EP(),r=fP(),i=uP(),o=cP(),a=yP();return aT=function(s,l){return r(s)&&i(l)?o(a(s),l):function(r){var i=e(r,s);return void 0===i&&i===l?n(r,s):t(l,i,3)}}}function kP(){if(uT)return lT;return uT=1,lT=function(t){return function(e){return null==e?void 0:e[t]}}}function MP(){if(fT)return dT;fT=1;var t=kP(),e=function(){if(hT)return cT;hT=1;var t=bP();return cT=function(e){return function(n){return t(n,e)}}}(),n=fP(),r=yP();return dT=function(i){return n(i)?t(r(i)):e(i)}}function SP(){if(gT)return pT;gT=1;var t=hP(),e=wP(),n=QC(),r=pM(),i=MP();return pT=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 NP(){if(mT)return vT;mT=1;var t=TC(),e=function(){if(XN)return qN;XN=1;var t=ZC();return qN=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},qN}(),n=SP(),r=pM();return vT=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function OP(){if(ET)return xT;ET=1;var t=function(){if(bT)return yT;bT=1;var t=Object.prototype.hasOwnProperty;return yT=function(e,n){return null!=e&&t.call(e,n)}}(),e=xP();return xT=function(n,r){return null!=n&&e(n,r,t)}}function TP(){if(kT)return wT;kT=1;var t=cS(),e=jC(),n=fM(),r=pM(),i=hS(),o=OM(),a=lS(),s=aS(),l=Object.prototype.hasOwnProperty;return wT=function(u){if(null==u)return!0;if(i(u)&&(r(u)||"string"==typeof u||"function"==typeof u.splice||o(u)||s(u)||n(u)))return!u.length;var c=e(u);if("[object Map]"==c||"[object Set]"==c)return!u.size;if(a(u))return!t(u).length;for(var h in u)if(l.call(u,h))return!1;return!0}}function AP(){if(ST)return MT;return ST=1,MT=function(t){return void 0===t}}function CP(){if(OT)return NT;OT=1;var t=ZC(),e=hS();return NT=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},NT}function PP(){if(AT)return TT;AT=1;var t=gP(),e=SP(),n=CP(),r=pM();return TT=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function RP(){if(_T)return LT;_T=1;var t=(PT||(PT=1,CT=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}),CT),e=ZC(),n=SP(),r=(DT||(DT=1,RT=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),RT),i=pM();return LT=function(o,a,s){var l=i(o)?t:r,u=arguments.length<3;return l(o,n(a,4),s,u,e)},LT}function DP(){if(YT)return HT;YT=1;var t=function(){if(FT)return BT;FT=1;var t=kP()("length");return BT=t}(),e=function(){if(GT)return zT;GT=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return zT=function(e){return t.test(e)}}(),n=function(){if(WT)return VT;WT=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+")?",l="[\\ufe0e\\ufe0f]?",u=l+s+"(?:\\u200d(?:"+[i,o,a].join("|")+")"+l+s+")*",c="(?:"+[i+n+"?",n,o,a,e].join("|")+")",h=RegExp(r+"(?="+r+")|"+c+u,"g");return VT=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return HT=function(r){return e(r)?n(r):t(r)}}function LP(){if($T)return UT;$T=1;var t=cS(),e=jC(),n=hS(),r=function(){if(jT)return IT;jT=1;var t=Xk(),e=pM(),n=dM();return IT=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=DP();return UT=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 _P(){if(XT)return qT;XT=1;var t=sM(),e=VC(),n=KC(),r=SP(),i=RC(),o=pM(),a=OM(),s=Zk(),l=Kk(),u=aS();return qT=function(c,h,d){var f=o(c),p=f||a(c)||u(c);if(h=r(h,4),null==d){var g=c&&c.constructor;d=p?f?new g:[]:l(c)&&s(g)?e(i(c)):{}}return(p?t:n)(c,(function(t,e,n){return h(d,t,e,n)})),d},qT}function IP(){if(JT)return QT;JT=1;var t=PC(),e=function(){if(ZT)return KT;ZT=1;var t=qk(),e=fM(),n=pM(),r=t?t.isConcatSpreadable:void 0;return KT=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return QT=function n(r,i,o,a,s){var l=-1,u=r.length;for(o||(o=e),s||(s=[]);++l<u;){var c=r[l];i>0&&o(c)?i>1?n(c,i-1,o,a,s):t(s,c):a||(s[s.length]=c)}return s},QT}function jP(){if(rA)return nA;rA=1;var t=eA?tA:(eA=1,tA=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 nA=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),l=Array(s);++a<s;)l[a]=o[r+a];a=-1;for(var u=Array(r+1);++a<r;)u[a]=o[a];return u[r]=i(l),t(n,this,u)}},nA}function BP(){if(uA)return lA;uA=1;var t=function(){if(oA)return iA;oA=1;var t=qC(),e=lM(),n=QC();return iA=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(sA)return aA;sA=1;var t=Date.now;return aA=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)}},aA}(),n=e(t);return lA=n}function FP(){if(hA)return cA;hA=1;var t=QC(),e=jP(),n=BP();return cA=function(r,i){return n(e(r,i,t),r+"")}}function zP(){if(fA)return dA;return fA=1,dA=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},dA}function GP(){if(bA)return yA;bA=1;var t=zP(),e=gA?pA:(gA=1,pA=function(t){return t!=t}),n=(mA||(mA=1,vA=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),vA);return yA=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function VP(){if(OA)return NA;OA=1;var t=IC(),e=SA?MA:(SA=1,MA=function(){}),n=oP(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return NA=r}function WP(){if(AA)return TA;AA=1;var t=nP(),e=function(){if(EA)return xA;EA=1;var t=GP();return xA=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(kA||(kA=1,wA=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}),wA),r=rP(),i=VP(),o=oP();return TA=function(a,s,l){var u=-1,c=e,h=a.length,d=!0,f=[],p=f;if(l)d=!1,c=n;else if(h>=200){var g=s?null:i(a);if(g)return o(g);d=!1,c=r,p=new t}else p=s?[]:f;t:for(;++u<h;){var v=a[u],m=s?s(v):v;if(v=l||0!==v?v:0,d&&m==m){for(var y=p.length;y--;)if(p[y]===m)continue t;s&&p.push(m),f.push(v)}else c(p,m,l)||(p!==f&&p.push(m),f.push(v))}return f},TA}function HP(){if(PA)return CA;PA=1;var t=hS(),e=dM();return CA=function(n){return e(n)&&t(n)}}function YP(){if(DA)return RA;DA=1;var t=IP(),e=FP(),n=WP(),r=HP(),i=e((function(e){return n(t(e,1,r,!0))}));return RA=i}function UP(){if(jA)return IA;jA=1;var t=function(){if(_A)return LA;_A=1;var t=gP();return LA=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=dS();return IA=function(n){return null==n?[]:t(n,e(n))}}function $P(){if(FA)return BA;var t;FA=1;try{t={clone:$C(),constant:qC(),each:eP(),filter:NP(),has:OP(),isArray:pM(),isEmpty:TP(),isFunction:Zk(),isUndefined:AP(),keys:dS(),map:PP(),reduce:RP(),size:LP(),transform:_P(),union:YP(),values:UP()}}catch(t){}return t||(t=window._),BA=t}function qP(){if(GA)return zA;GA=1;var t=$P();zA=n;var e="\0";function n(n){this._isDirected=!t.has(n,"directed")||n.directed,this._isMultigraph=!!t.has(n,"multigraph")&&n.multigraph,this._isCompound=!!t.has(n,"compound")&&n.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function r(t,e){t[e]?t[e]++:t[e]=1}function i(t,e){--t[e]||delete t[e]}function o(e,n,r,i){var o=""+n,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}return o+""+a+""+(t.isUndefined(i)?"\0":i)}function a(t,e){return o(t,e.v,e.w,e.name)}return n.prototype._nodeCount=0,n.prototype._edgeCount=0,n.prototype.isDirected=function(){return this._isDirected},n.prototype.isMultigraph=function(){return this._isMultigraph},n.prototype.isCompound=function(){return this._isCompound},n.prototype.setGraph=function(t){return this._label=t,this},n.prototype.graph=function(){return this._label},n.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},n.prototype.nodeCount=function(){return this._nodeCount},n.prototype.nodes=function(){return t.keys(this._nodes)},n.prototype.sources=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._in[n])}))},n.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._out[n])}))},n.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},n.prototype.setNode=function(n,r){return t.has(this._nodes,n)?(arguments.length>1&&(this._nodes[n]=r),this):(this._nodes[n]=arguments.length>1?r:this._defaultNodeLabelFn(n),this._isCompound&&(this._parent[n]=e,this._children[n]={},this._children[e][n]=!0),this._in[n]={},this._preds[n]={},this._out[n]={},this._sucs[n]={},++this._nodeCount,this)},n.prototype.node=function(t){return this._nodes[t]},n.prototype.hasNode=function(e){return t.has(this._nodes,e)},n.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},n.prototype.setParent=function(n,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=e;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===n)throw new Error("Setting "+r+" as parent of "+n+" would create a cycle");this.setNode(r)}return this.setNode(n),this._removeFromParentsChildList(n),this._parent[n]=r,this._children[r][n]=!0,this},n.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},n.prototype.parent=function(t){if(this._isCompound){var n=this._parent[t];if(n!==e)return n}},n.prototype.children=function(n){if(t.isUndefined(n)&&(n=e),this._isCompound){var r=this._children[n];if(r)return t.keys(r)}else{if(n===e)return this.nodes();if(this.hasNode(n))return[]}},n.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},n.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},n.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},n.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},n.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},n.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},n.prototype.edgeCount=function(){return this._edgeCount},n.prototype.edges=function(){return t.values(this._edgeObjs)},n.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},n.prototype.setEdge=function(){var e,n,i,a,s=!1,l=arguments[0];"object"==typeof l&&null!==l&&"v"in l?(e=l.v,n=l.w,i=l.name,2===arguments.length&&(a=arguments[1],s=!0)):(e=l,n=arguments[1],i=arguments[3],arguments.length>2&&(a=arguments[2],s=!0)),e=""+e,n=""+n,t.isUndefined(i)||(i=""+i);var u=o(this._isDirected,e,n,i);if(t.has(this._edgeLabels,u))return s&&(this._edgeLabels[u]=a),this;if(!t.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[u]=s?a:this._defaultEdgeLabelFn(e,n,i);var c=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,i);return e=c.v,n=c.w,Object.freeze(c),this._edgeObjs[u]=c,r(this._preds[n],e),r(this._sucs[e],n),this._in[n][u]=c,this._out[e][u]=c,this._edgeCount++,this},n.prototype.edge=function(t,e,n){var r=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,t,e,n);return this._edgeLabels[r]},n.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},n.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,t,e,n),s=this._edgeObjs[r];return s&&(t=s.v,e=s.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[e],t),i(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},n.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}},n.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}},n.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},zA}function XP(){return YA?HA:(YA=1,HA={Graph:qP(),version:WA?VA:(WA=1,VA="2.1.8")})}function KP(){if($A)return UA;$A=1;var t=$P(),e=qP();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 UA={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 ZP(){if(XA)return qA;XA=1;var t=$P();return qA=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},qA}function QP(){if(ZA)return KA;ZA=1;var t=$P();function e(){this._arr=[],this._keyIndices={}}return KA=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},KA}function JP(){if(JA)return QA;JA=1;var t=$P(),e=QP();QA=function(t,r,i,o){return function(t,n,r,i){var o,a,s={},l=new e,u=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),u=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);u<n.distance&&(n.distance=u,n.predecessor=o,l.decrease(e,u))};t.nodes().forEach((function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},l.add(t,e)}));for(;l.size()>0&&(o=l.removeMin(),(a=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(u);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return QA}function tR(){if(eC)return tC;eC=1;var t=JP(),e=$P();return tC=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function eR(){if(rC)return nC;rC=1;var t=$P();return nC=function(e){var n=0,r=[],i={},o=[];function a(s){var l=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&&(l.lowlink=Math.min(l.lowlink,i[e].index)):(a(e),l.lowlink=Math.min(l.lowlink,i[e].lowlink))})),l.lowlink===l.index){var u,c=[];do{u=r.pop(),i[u].onStack=!1,c.push(u)}while(s!==u);o.push(c)}}return e.nodes().forEach((function(e){t.has(i,e)||a(e)})),o},nC}function nR(){if(oC)return iC;oC=1;var t=$P(),e=eR();return iC=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function rR(){if(sC)return aC;sC=1;var t=$P();aC=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 aC}function iR(){if(uC)return lC;uC=1;var t=$P();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 lC=e,e.CycleException=n,n.prototype=new Error,lC}function oR(){if(hC)return cC;hC=1;var t=iR();return cC=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function aR(){if(fC)return dC;fC=1;var t=$P();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 dC=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},dC}function sR(){if(gC)return pC;gC=1;var t=aR();return pC=function(e,n){return t(e,n,"post")}}function lR(){if(mC)return vC;mC=1;var t=aR();return vC=function(e,n){return t(e,n,"pre")}}function uR(){if(bC)return yC;bC=1;var t=$P(),e=qP(),n=QP();return yC=function(r,i){var o,a=new e,s={},l=new n;function u(t){var e=t.v===o?t.w:t.v,n=l.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,l.decrease(e,r))}}if(0===r.nodeCount())return a;t.each(r.nodes(),(function(t){l.add(t,Number.POSITIVE_INFINITY),a.setNode(t)})),l.decrease(r.nodes()[0],0);var c=!1;for(;l.size()>0;){if(o=l.removeMin(),t.has(s,o))a.setEdge(o,s[o]);else{if(c)throw new Error("Input graph is not connected: "+r);c=!0}r.nodeEdges(o).forEach(u)}return a}}try{MC=function(){if(kC)return wC;kC=1;var t=XP();return wC={Graph:t.Graph,json:KP(),alg:EC?xC:(EC=1,xC={components:ZP(),dijkstra:JP(),dijkstraAll:tR(),findCycles:nR(),floydWarshall:rR(),isAcyclic:oR(),postorder:sR(),preorder:lR(),prim:uR(),tarjan:eR(),topsort:iR()}),version:t.version}}()}catch(t){}MC||(MC=window.graphlib);var cR,hR,dR,fR,pR,gR,vR,mR,yR,bR,xR,ER,wR,kR,MR,SR,NR,OR,TR,AR,CR,PR,RR,DR,LR,_R,IR,jR,BR,FR,zR,GR,VR,WR,HR,YR,UR,$R,qR,XR,KR,ZR,QR,JR,tD,eD,nD,rD,iD,oD,aD,sD,lD,uD,cD,hD,dD,fD,pD,gD,vD,mD,yD,bD,xD,ED,wD,kD,MD,SD,ND,OD,TD,AD,CD,PD,RD,DD,LD,_D,ID,jD,BD,FD,zD,GD,VD,WD,HD,YD,UD,$D,qD,XD=MC;function KD(){if(fR)return dR;fR=1;var t=Wk(),e=hS(),n=TM(),r=Kk();return dR=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)},dR}function ZD(){if(ER)return xR;ER=1;var t=function(){if(bR)return yR;bR=1;var t=/\s/;return yR=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},yR}(),e=/^\s+/;return xR=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function QD(){if(SR)return MR;SR=1;var t=function(){if(kR)return wR;kR=1;var t=ZD(),e=Kk(),n=dP(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return wR=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var l="function"==typeof s.valueOf?s.valueOf():s;s=e(l)?l+"":l}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var u=i.test(s);return u||o.test(s)?a(s.slice(2),u?2:8):r.test(s)?NaN:+s}}(),e=1/0;return MR=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 JD(){if(AR)return TR;AR=1;var t=zP(),e=SP(),n=function(){if(OR)return NR;OR=1;var t=QD();return NR=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return TR=function(i,o,a){var s=null==i?0:i.length;if(!s)return-1;var l=null==a?0:n(a);return l<0&&(l=r(s+l,0)),t(i,e(o,3),l)},TR}function tL(){if(DR)return RR;DR=1;var t=IP();return RR=function(e){return(null==e?0:e.length)?t(e,1):[]}}function eL(){if(GR)return zR;GR=1;var t=dP();return zR=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===l?s==s&&!t(s):r(s,l)))var l=s,u=a}return u},zR}function nL(){if($R)return UR;$R=1;var t=uM(),e=Wk();return UR=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function rL(){if(ZR)return KR;return ZR=1,KR=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function iL(){if(eD)return tD;eD=1;var t=nL(),e=NC(),n=zC(),r=OC(),i=WC(),o=fM(),a=pM(),s=HP(),l=OM(),u=Zk(),c=Kk(),h=function(){if(XR)return qR;XR=1;var t=Xk(),e=RC(),n=dM(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return qR=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var l=a.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==s}}(),d=aS(),f=rL(),p=function(){if(JR)return QR;JR=1;var t=hM(),e=pS();return QR=function(n){return t(n,e(n))}}();return tD=function(g,v,m,y,b,x,E){var w=f(g,m),k=f(v,m),M=E.get(k);if(M)t(g,m,M);else{var S=x?x(w,k,m+"",g,v,E):void 0,N=void 0===S;if(N){var O=a(k),T=!O&&l(k),A=!O&&!T&&d(k);S=k,O||T||A?a(w)?S=w:s(w)?S=r(w):T?(N=!1,S=e(k,!0)):A?(N=!1,S=n(k,!0)):S=[]:h(k)||o(k)?(S=w,o(w)?S=p(w):c(w)&&!u(w)||(S=i(k))):N=!1}N&&(E.set(k,S),b(S,k,y,x,E),E.delete(k)),t(g,m,S)}}}function oL(){if(uD)return lD;return uD=1,lD=function(t,e){return t<e}}function aL(){if(bD)return yD;bD=1;var t=bP(),e=function(){if(mD)return vD;mD=1;var t=cM(),e=mP(),n=TM(),r=Kk(),i=yP();return vD=function(o,a,s,l){if(!r(o))return o;for(var u=-1,c=(a=e(a,o)).length,h=c-1,d=o;null!=d&&++u<c;){var f=i(a[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(u!=h){var g=d[f];void 0===(p=l?l(g,f,d):void 0)&&(p=r(g)?g:n(a[u+1])?[]:{})}t(d,f,p),d=d[f]}return o},vD}(),n=mP();return yD=function(r,i,o){for(var a=-1,s=i.length,l={};++a<s;){var u=i[a],c=t(r,u);o(c,u)&&e(l,n(u,r),c)}return l},yD}function sL(){if(AD)return TD;AD=1;var t=function(){if(OD)return ND;OD=1;var t=Math.ceil,e=Math.max;return ND=function(n,r,i,o){for(var a=-1,s=e(t((r-n)/(i||1)),0),l=Array(s);s--;)l[o?s:++a]=n,n+=i;return l},ND}(),e=KD(),n=QD();return TD=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)}},TD}function lL(){if(jD)return ID;jD=1;var t=function(){if(_D)return LD;_D=1;var t=dP();return LD=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,a=t(e),s=void 0!==n,l=null===n,u=n==n,c=t(n);if(!l&&!c&&!a&&e>n||a&&s&&u&&!l&&!c||i&&s&&u||!r&&u||!o)return 1;if(!i&&!a&&!c&&e<n||c&&r&&o&&!i&&!a||l&&r&&o||!s&&o||!u)return-1}return 0}}();return ID=function(e,n,r){for(var i=-1,o=e.criteria,a=n.criteria,s=o.length,l=r.length;++i<s;){var u=t(o[i],a[i]);if(u)return i>=l?u:u*("desc"==r[i]?-1:1)}return e.index-n.index},ID}function uL(){if(FD)return BD;FD=1;var t=gP(),e=bP(),n=SP(),r=CP(),i=(DD||(DD=1,RD=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),RD),o=CM(),a=lL(),s=QC(),l=pM();return BD=function(u,c,h){c=c.length?t(c,(function(t){return l(t)?function(n){return e(n,1===t.length?t[0]:t)}:t})):[s];var d=-1;c=t(c,o(n));var f=r(u,(function(e,n,r){return{criteria:t(c,(function(t){return t(e)})),index:++d,value:e}}));return i(f,(function(t,e){return a(t,e,h)}))},BD}try{qD={cloneDeep:function(){if(hR)return cR;hR=1;var t=UC();return cR=function(e){return t(e,5)}}(),constant:qC(),defaults:function(){if(gR)return pR;gR=1;var t=FP(),e=Wk(),n=KD(),r=pS(),i=Object.prototype,o=i.hasOwnProperty,a=t((function(t,a){t=Object(t);var s=-1,l=a.length,u=l>2?a[2]:void 0;for(u&&n(a[0],a[1],u)&&(l=1);++s<l;)for(var c=a[s],h=r(c),d=-1,f=h.length;++d<f;){var p=h[d],g=t[p];(void 0===g||e(g,i[p])&&!o.call(t,p))&&(t[p]=c[p])}return t}));return pR=a}(),each:eP(),filter:NP(),find:function(){if(PR)return CR;PR=1;var t=function(){if(mR)return vR;mR=1;var t=SP(),e=hS(),n=dS();return vR=function(r){return function(i,o,a){var s=Object(i);if(!e(i)){var l=t(o,3);i=n(i),o=function(t){return l(s[t],t,s)}}var u=r(i,o,a);return u>-1?s[l?i[u]:u]:void 0}},vR}(),e=t(JD());return CR=e}(),flatten:tL(),forEach:tP(),forIn:function(){if(_R)return LR;_R=1;var t=XC(),e=JC(),n=pS();return LR=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:OP(),isUndefined:AP(),last:(jR||(jR=1,IR=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),IR),map:PP(),mapValues:function(){if(FR)return BR;FR=1;var t=uM(),e=KC(),n=SP();return BR=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(YR)return HR;YR=1;var t=eL(),e=WR?VR:(WR=1,VR=function(t,e){return t>e}),n=QC();return HR=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(sD)return aD;sD=1;var t=function(){if(rD)return nD;rD=1;var t=aM(),e=nL(),n=XC(),r=iL(),i=Kk(),o=pS(),a=rL();return nD=function s(l,u,c,h,d){l!==u&&n(u,(function(n,o){if(d||(d=new t),i(n))r(l,u,o,c,s,h,d);else{var f=h?h(a(l,o),n,o+"",l,u,d):void 0;void 0===f&&(f=n),e(l,o,f)}}),o)},nD}(),e=function(){if(oD)return iD;oD=1;var t=FP(),e=KD();return iD=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 l=r[i];l&&n(t,l,i,a)}return t}))},iD}(),n=e((function(e,n,r){t(e,n,r)}));return aD=n}(),min:function(){if(hD)return cD;hD=1;var t=eL(),e=oL(),n=QC();return cD=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(fD)return dD;fD=1;var t=eL(),e=SP(),n=oL();return dD=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(gD)return pD;gD=1;var t=$k();return pD=function(){return t.Date.now()}}(),pick:function(){if(SD)return MD;SD=1;var t=function(){if(ED)return xD;ED=1;var t=aL(),e=EP();return xD=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(kD)return wD;kD=1;var t=tL(),e=jP(),n=BP();return wD=function(r){return n(e(r,void 0,t),r+"")}}()((function(e,n){return null==e?{}:t(e,n)}));return MD=e}(),range:function(){if(PD)return CD;PD=1;var t=sL()();return CD=t}(),reduce:RP(),sortBy:function(){if(GD)return zD;GD=1;var t=IP(),e=uL(),n=FP(),r=KD(),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 zD=i}(),uniqueId:function(){if(WD)return VD;WD=1;var t=vP(),e=0;return VD=function(n){var r=++e;return t(n)+r},VD}(),values:UP(),zipObject:function(){if($D)return UD;$D=1;var t=cM(),e=(YD||(YD=1,HD=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}),HD);return UD=function(n,r){return e(n||[],r||[],t)},UD}()}}catch(t){}qD||(qD=window._);var cL=qD,hL=dL;function dL(){var t={};t._next=t._prev=t,this._sentinel=t}function fL(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function pL(t,e){if("_next"!==t&&"_prev"!==t)return e}dL.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return fL(e),e},dL.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&fL(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},dL.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,pL)),n=n._prev;return"["+t.join(", ")+"]"};var gL=cL,vL=XD.Graph,mL=hL,yL=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new vL,r=0,i=0;gL.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),gL.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=gL.range(i+r+3).map((function(){return new mL})),a=r+1;return gL.forEach(n.nodes(),(function(t){EL(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||bL),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)xL(t,e,n,r);for(;r=o.dequeue();)xL(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(xL(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return gL.flatten(gL.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},bL=gL.constant(1);function xL(t,e,n,r,i){var o=i?[]:void 0;return gL.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,EL(e,n,s)})),gL.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,EL(e,n,a)})),t.removeNode(r.v),o}function EL(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 wL=cL,kL=yL,ML={run:function(t){var e="greedy"===t.graph().acyclicer?kL(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){wL.has(r,o)||(r[o]=!0,n[o]=!0,wL.forEach(t.outEdges(o),(function(t){wL.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return wL.forEach(t.nodes(),i),e}(t);wL.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,wL.uniqueId("rev"))}))},undo:function(t){wL.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 SL=cL,NL=XD.Graph,OL={addDummyNode:TL,simplify:function(t){var e=(new NL).setGraph(t.graph());return SL.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),SL.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 NL({multigraph:t.isMultigraph()}).setGraph(t.graph());return SL.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),SL.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=SL.map(t.nodes(),(function(e){var n={};return SL.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return SL.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=SL.map(t.nodes(),(function(e){var n={};return SL.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return SL.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,l=t.width/2,u=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*l>Math.abs(a)*u?(s<0&&(u=-u),n=u*a/s,r=u):(a<0&&(l=-l),n=l,r=l*s/a);return{x:i+n,y:o+r}},buildLayerMatrix:function(t){var e=SL.map(SL.range(AL(t)+1),(function(){return[]}));return SL.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;SL.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=SL.min(SL.map(t.nodes(),(function(e){return t.node(e).rank})));SL.forEach(t.nodes(),(function(n){var r=t.node(n);SL.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=SL.min(SL.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];SL.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;SL.forEach(n,(function(e,n){SL.isUndefined(e)&&n%i!=0?--r:r&&SL.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 TL(t,"border",i,e)},maxRank:AL,partition:function(t,e){var n={lhs:[],rhs:[]};return SL.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=SL.now();try{return e()}finally{console.log(t+" time: "+(SL.now()-n)+"ms")}},notime:function(t,e){return e()}};function TL(t,e,n,r){var i;do{i=SL.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function AL(t){return SL.max(SL.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!SL.isUndefined(n))return n})))}var CL=cL,PL=OL,RL={run:function(t){t.graph().dummyChains=[],CL.forEach(t.edges(),(function(e){!function(t,e){var n,r,i,o=e.v,a=t.node(o).rank,s=e.w,l=t.node(s).rank,u=e.name,c=t.edge(e),h=c.labelRank;if(l===a+1)return;for(t.removeEdge(e),i=0,++a;a<l;++i,++a)c.points=[],r={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},n=PL.addDummyNode(t,"edge",r,"_d"),a===h&&(r.width=c.width,r.height=c.height,r.dummy="edge-label",r.labelpos=c.labelpos),t.setEdge(o,n,{weight:c.weight},u),0===i&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,s,{weight:c.weight},u)}(t,e)}))},undo:function(t){CL.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 DL=cL,LL={longestPath:function(t){var e={};DL.forEach(t.sources(),(function n(r){var i=t.node(r);if(DL.has(e,r))return i.rank;e[r]=!0;var o=DL.min(DL.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 _L=cL,IL=XD.Graph,jL=LL.slack,BL=function(t){var e,n,r=new IL({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;FL(r,t)<o;)e=zL(r,t),n=r.hasNode(e.v)?jL(t,e):-jL(t,e),GL(r,t,n);return r};function FL(t,e){return _L.forEach(t.nodes(),(function n(r){_L.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||jL(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function zL(t,e){return _L.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return jL(e,n)}))}function GL(t,e,n){_L.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var VL=cL,WL=BL,HL=LL.slack,YL=LL.longestPath,UL=XD.alg.preorder,$L=XD.alg.postorder,qL=OL.simplify,XL=KL;function KL(t){t=qL(t),YL(t);var e,n=WL(t);for(JL(n),ZL(n,t);e=e_(n);)r_(n,t,e,n_(n,t,e))}function ZL(t,e){var n=$L(t,t.nodes());n=n.slice(0,n.length-1),VL.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=QL(t,e,n)}(t,e,n)}))}function QL(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,VL.forEach(e.nodeEdges(n),(function(o){var s,l,u=o.v===n,c=u?o.w:o.v;if(c!==r){var h=u===i,d=e.edge(o).weight;if(a+=h?d:-d,s=n,l=c,t.hasEdge(s,l)){var f=t.edge(n,c).cutvalue;a+=h?-f:f}}})),a}function JL(t,e){arguments.length<2&&(e=t.nodes()[0]),t_(t,{},1,e)}function t_(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,VL.forEach(t.neighbors(r),(function(i){VL.has(e,i)||(n=t_(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function e_(t){return VL.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function n_(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,l=!1;o.lim>a.lim&&(s=a,l=!0);var u=VL.filter(e.edges(),(function(e){return l===i_(t,t.node(e.v),s)&&l!==i_(t,t.node(e.w),s)}));return VL.minBy(u,(function(t){return HL(e,t)}))}function r_(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),JL(t),ZL(t,e),function(t,e){var n=VL.find(t.nodes(),(function(t){return!e.node(t).parent})),r=UL(t,n);r=r.slice(1),VL.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 i_(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}KL.initLowLimValues=JL,KL.initCutValues=ZL,KL.calcCutValue=QL,KL.leaveEdge=e_,KL.enterEdge=n_,KL.exchangeEdges=r_;var o_=LL.longestPath,a_=BL,s_=XL,l_=function(t){switch(t.graph().ranker){case"network-simplex":default:c_(t);break;case"tight-tree":!function(t){o_(t),a_(t)}(t);break;case"longest-path":u_(t)}};var u_=o_;function c_(t){s_(t)}var h_=cL,d_=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;h_.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return h_.forEach(t.children(),r),e}(t);h_.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=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),a.push(i)}while(i&&(e[i].low>l||u>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,l=0,u=a[l],c=!0;n!==i.w;){if(r=t.node(n),c){for(;(u=a[l])!==s&&t.node(u).maxRank<r.rank;)l++;u===s&&(c=!1)}if(!c){for(;l<a.length-1&&t.node(u=a[l+1]).minRank<=r.rank;)l++;u=a[l]}t.setParent(n,u),n=t.successors(n)[0]}}))};var f_=cL,p_=OL,g_={run:function(t){var e=p_.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&f_.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return f_.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=f_.max(f_.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,f_.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return f_.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;f_.forEach(t.children(),(function(a){v_(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,f_.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function v_(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var l=p_.addBorderNode(t,"_bt"),u=p_.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(l,a),c.borderTop=l,t.setParent(u,a),c.borderBottom=u,f_.forEach(s,(function(s){v_(t,e,n,r,i,o,s);var c=t.node(s),h=c.borderTop?c.borderTop:s,d=c.borderBottom?c.borderBottom:s,f=c.borderTop?r:2*r,p=h!==d?1:i-o[a]+1;t.setEdge(l,h,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(d,u,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,l,{weight:0,minlen:i+o[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:n})}var m_=cL,y_=OL,b_=function(t){m_.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&m_.forEach(r,e),m_.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)x_(t,"borderLeft","_bl",n,i,o),x_(t,"borderRight","_br",n,i,o)}}))};function x_(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],l=y_.addDummyNode(t,"border",a,n);i[e][o]=l,t.setParent(l,r),s&&t.setEdge(s,l,{weight:1})}var E_=cL,w_={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||k_(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){E_.forEach(t.nodes(),(function(e){S_(t.node(e))})),E_.forEach(t.edges(),(function(e){var n=t.edge(e);E_.forEach(n.points,S_),E_.has(n,"y")&&S_(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){E_.forEach(t.nodes(),(function(e){N_(t.node(e))})),E_.forEach(t.edges(),(function(e){var n=t.edge(e);E_.forEach(n.points,N_),E_.has(n,"x")&&N_(n)}))}(t),k_(t))}};function k_(t){E_.forEach(t.nodes(),(function(e){M_(t.node(e))})),E_.forEach(t.edges(),(function(e){M_(t.edge(e))}))}function M_(t){var e=t.width;t.width=t.height,t.height=e}function S_(t){t.y=-t.y}function N_(t){var e=t.x;t.x=t.y,t.y=e}var O_=cL,T_=function(t){var e={},n=O_.filter(t.nodes(),(function(e){return!t.children(e).length})),r=O_.max(O_.map(n,(function(e){return t.node(e).rank}))),i=O_.map(O_.range(r+1),(function(){return[]}));function o(n){if(!O_.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),O_.forEach(t.successors(n),o)}}var a=O_.sortBy(n,(function(e){return t.node(e).rank}));return O_.forEach(a,o),i};var A_=cL,C_=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=P_(t,e[r-1],e[r]);return n};function P_(t,e,n){for(var r=A_.zipObject(n,A_.map(n,(function(t,e){return e}))),i=A_.flatten(A_.map(e,(function(e){return A_.sortBy(A_.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=A_.map(new Array(a),(function(){return 0})),l=0;return A_.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;l+=t.weight*n}))),l}var R_=cL;var D_=cL,L_=function(t,e){var n={};return D_.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};D_.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),D_.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];D_.isUndefined(e)||D_.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(D_.isUndefined(e.barycenter)||D_.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),D_.forEach(i.in.reverse(),n(i)),D_.forEach(i.out,r(i))}return D_.map(D_.filter(e,(function(t){return!t.merged})),(function(t){return D_.pick(t,["vs","i","barycenter","weight"])}))}(D_.filter(n,(function(t){return!t.indegree})))};var __=cL,I_=OL;function j_(t,e,n){for(var r;e.length&&(r=__.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var B_=cL,F_=function(t,e){return R_.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=R_.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}}))},z_=L_,G_=function(t,e){var n=I_.partition(t,(function(t){return __.has(t,"barycenter")})),r=n.lhs,i=__.sortBy(n.rhs,(function(t){return-t.i})),o=[],a=0,s=0,l=0;r.sort((u=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:u?e.i-t.i:t.i-e.i})),l=j_(o,i,l),__.forEach(r,(function(t){l+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,l=j_(o,i,l)}));var u;var c={vs:__.flatten(o,!0)};s&&(c.barycenter=a/s,c.weight=s);return c},V_=function t(e,n,r,i){var o=e.children(n),a=e.node(n),s=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,u={};s&&(o=B_.filter(o,(function(t){return t!==s&&t!==l})));var c=F_(e,o);B_.forEach(c,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);u[n.v]=o,B_.has(o,"barycenter")&&(a=n,s=o,B_.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 h=z_(c,r);!function(t,e){B_.forEach(t,(function(t){t.vs=B_.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,u);var d=G_(h,i);if(s&&(d.vs=B_.flatten([s,d.vs,l],!0),e.predecessors(s).length)){var f=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(l)[0]);B_.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 W_=cL,H_=XD.Graph,Y_=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=W_.uniqueId("_root")););return e}(t),i=new H_({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return W_.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),W_.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=W_.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),W_.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var U_=cL;var $_=cL,q_=T_,X_=C_,K_=V_,Z_=Y_,Q_=function(t,e,n){var r,i={};U_.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}}))},J_=XD.Graph,tI=OL,eI=function(t){var e=tI.maxRank(t),n=nI(t,$_.range(1,e+1),"inEdges"),r=nI(t,$_.range(e-1,-1,-1),"outEdges"),i=q_(t);iI(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,l=0;l<4;++s,++l){rI(s%2?n:r,s%4>=2),i=tI.buildLayerMatrix(t);var u=X_(t,i);u<a&&(l=0,o=$_.cloneDeep(i),a=u)}iI(t,o)};function nI(t,e,n){return $_.map(e,(function(e){return Z_(t,e,n)}))}function rI(t,e){var n=new J_;$_.forEach(t,(function(t){var r=t.graph().root,i=K_(t,r,n,e);$_.forEach(i.vs,(function(e,n){t.node(e).order=n})),Q_(t,n,i.vs)}))}function iI(t,e){$_.forEach(e,(function(e){$_.forEach(e,(function(e,n){t.node(e).order=n}))}))}var oI=cL,aI=XD.Graph,sI=OL,lI=function(t){var e,n=sI.buildLayerMatrix(t),r=oI.merge(uI(t,n),cI(t,n)),i={};oI.forEach(["u","d"],(function(o){e="u"===o?n:oI.values(n).reverse(),oI.forEach(["l","r"],(function(n){"r"===n&&(e=oI.map(e,(function(t){return oI.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=fI(t,e,r,a),l=pI(t,e,s.root,s.align,"r"===n);"r"===n&&(l=oI.mapValues(l,(function(t){return-t}))),i[o+n]=l}))}));var o=gI(t,i);return vI(i,o),mI(i,t.graph().align)};function uI(t,e){var n={};return oI.reduce(e,(function(e,r){var i=0,o=0,a=e.length,s=oI.last(r);return oI.forEach(r,(function(e,l){var u=function(t,e){if(t.node(e).dummy)return oI.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=u?t.node(u).order:a;(u||e===s)&&(oI.forEach(r.slice(o,l+1),(function(e){oI.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||c<a)||o.dummy&&t.node(e).dummy||hI(n,r,e)}))})),o=l+1,i=c)})),r})),n}function cI(t,e){var n={};function r(e,r,i,o,a){var s;oI.forEach(oI.range(r,i),(function(r){s=e[r],t.node(s).dummy&&oI.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&hI(n,e,s)}))}))}return oI.reduce(e,(function(e,n){var i,o=-1,a=0;return oI.forEach(n,(function(s,l){if("border"===t.node(s).dummy){var u=t.predecessors(s);u.length&&(i=t.node(u[0]).order,r(n,a,l,o,i),a=l,o=i)}r(n,a,n.length,i,e.length)})),n})),n}function hI(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 dI(t,e,n){if(e>n){var r=e;e=n,n=r}return oI.has(t[e],n)}function fI(t,e,n,r){var i={},o={},a={};return oI.forEach(e,(function(t){oI.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),oI.forEach(e,(function(t){var e=-1;oI.forEach(t,(function(t){var s=r(t);if(s.length){s=oI.sortBy(s,(function(t){return a[t]}));for(var l=(s.length-1)/2,u=Math.floor(l),c=Math.ceil(l);u<=c;++u){var h=s[u];o[t]===t&&e<a[h]&&!dI(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}function pI(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new aI,o=t.graph(),a=function(t,e,n){return function(r,i,o){var a,s=r.node(i),l=r.node(o),u=0;if(u+=s.width/2,oI.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2}if(a&&(u+=n?a:-a),a=0,u+=(s.dummy?e:t)/2,u+=(l.dummy?e:t)/2,u+=l.width/2,oI.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2}return a&&(u+=n?a:-a),a=0,u}}(o.nodesep,o.edgesep,r);return oI.forEach(e,(function(e){var r;oI.forEach(e,(function(e){var o=n[e];if(i.setNode(o),r){var s=n[r],l=i.edge(s,o);i.setEdge(s,o,Math.max(a(t,e,r),l||0))}r=e}))})),i}(t,e,n,i),s=i?"borderLeft":"borderRight";function l(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 l((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)),l((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)),oI.forEach(r,(function(t){o[t]=o[n[t]]})),o}function gI(t,e){return oI.minBy(oI.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return oI.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 vI(t,e){var n=oI.values(e),r=oI.min(n),i=oI.max(n);oI.forEach(["u","d"],(function(n){oI.forEach(["l","r"],(function(o){var a,s=n+o,l=t[s];if(l!==e){var u=oI.values(l);(a="l"===o?r-oI.min(u):i-oI.max(u))&&(t[s]=oI.mapValues(l,(function(t){return t+a})))}}))}))}function mI(t,e){return oI.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=oI.sortBy(oI.map(t,r));return(i[1]+i[2])/2}))}var yI=cL,bI=OL,xI=lI,EI=function(t){(function(t){var e=bI.buildLayerMatrix(t),n=t.graph().ranksep,r=0;yI.forEach(e,(function(e){var i=yI.max(yI.map(e,(function(e){return t.node(e).height})));yI.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=bI.asNonCompoundGraph(t)),yI.forEach(xI(t),(function(e,n){t.node(n).x=e}))};var wI=cL,kI=ML,MI=RL,SI=l_,NI=OL.normalizeRanks,OI=d_,TI=OL.removeEmptyRanks,AI=g_,CI=b_,PI=w_,RI=eI,DI=EI,LI=OL,_I=XD.Graph,II=function(t,e){var n=e&&e.debugTiming?LI.time:LI.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new _I({multigraph:!0,compound:!0}),n=UI(t.graph());return e.setGraph(wI.merge({},BI,YI(n,jI),wI.pick(n,FI))),wI.forEach(t.nodes(),(function(n){var r=UI(t.node(n));e.setNode(n,wI.defaults(YI(r,zI),GI)),e.setParent(n,t.parent(n))})),wI.forEach(t.edges(),(function(n){var r=UI(t.edge(n));e.setEdge(n,wI.merge({},WI,YI(r,VI),wI.pick(r,HI)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,wI.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){wI.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(){kI.run(t)})),e(" nestingGraph.run",(function(){AI.run(t)})),e(" rank",(function(){SI(LI.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){wI.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};LI.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){TI(t)})),e(" nestingGraph.cleanup",(function(){AI.cleanup(t)})),e(" normalizeRanks",(function(){NI(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;wI.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=wI.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){wI.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(){MI.run(t)})),e(" parentDummyChains",(function(){OI(t)})),e(" addBorderSegments",(function(){CI(t)})),e(" order",(function(){RI(t)})),e(" insertSelfEdges",(function(){!function(t){var e=LI.buildLayerMatrix(t);wI.forEach(e,(function(e){var n=0;wI.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,wI.forEach(i.selfEdges,(function(e){LI.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(){PI.adjust(t)})),e(" position",(function(){DI(t)})),e(" positionSelfEdges",(function(){!function(t){wI.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){wI.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(wI.last(n.borderLeft)),a=t.node(wI.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}})),wI.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){MI.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){wI.forEach(t.edges(),(function(e){var n=t.edge(e);if(wI.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(){PI.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 l(t){var o=t.x,a=t.y,s=t.width,l=t.height;e=Math.min(e,o-s/2),n=Math.max(n,o+s/2),r=Math.min(r,a-l/2),i=Math.max(i,a+l/2)}wI.forEach(t.nodes(),(function(e){l(t.node(e))})),wI.forEach(t.edges(),(function(e){var n=t.edge(e);wI.has(n,"x")&&l(n)})),e-=a,r-=s,wI.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),wI.forEach(t.edges(),(function(n){var i=t.edge(n);wI.forEach(i.points,(function(t){t.x-=e,t.y-=r})),wI.has(i,"x")&&(i.x-=e),wI.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){wI.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(LI.intersectRect(o,n)),i.points.push(LI.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){wI.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){kI.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){wI.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))})),wI.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,wI.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 jI=["nodesep","edgesep","ranksep","marginx","marginy"],BI={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},FI=["acyclicer","ranker","rankdir","align"],zI=["width","height"],GI={width:0,height:0},VI=["minlen","weight","width","height","labeloffset"],WI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},HI=["labelpos"];function YI(t,e){return wI.mapValues(wI.pick(t,e),Number)}function UI(t){var e={};return wI.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var $I=cL,qI=OL,XI=XD.Graph,KI={debugOrdering:function(t){var e=qI.buildLayerMatrix(t),n=new XI({compound:!0,multigraph:!0}).setGraph({});return $I.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),$I.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),$I.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),$I.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var ZI={graphlib:XD,layout:II,debug:KI,util:{time:OL.time,notime:OL.notime},version:"0.8.5"},QI=E(ZI);class JI{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,JI.defaultOptions,t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{nodeSize:r}=n,i=new ZI.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>ae(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]=cb(Yt(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})})),QI.layout(i);const o={nodes:[],edges:[]};return i.nodes().forEach((n=>{const r=i.node(n);o.nodes.push({id:n,data:r}),t&&e.mergeNodeData(n,r)})),i.edges().forEach((n=>{const r=i.edge(n),{id:a}=r,s=Fe(r,["id"]),{v:l,w:u}=n;o.edges.push({id:a,source:l,target:u,data:s}),t&&e.mergeEdgeData(a,s)})),o}))}}JI.defaultOptions={};class tj{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 tj({rx:n,ry:r,mass:e,degree:i})}}class ej{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 ej({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 ej({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 ej({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 ej({xmid:t,ymid:e,length:n})}}class nj{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 nj(this.quad.NW()),this.NE=new nj(this.quad.NE()),this.SW=new nj(this.quad.SW()),this.SE=new nj(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 rj={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};class ij{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},rj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceAtlas2Layout(!0,t,e)}))}genericForceAtlas2Layout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),{width:a,height:s,prune:l,maxIteration:u,nodeSize:c,center:h}=o;if(!(null==i?void 0:i.length)||1===i.length)return mb(e,t,h);const d=i.map((t=>ub(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Yg({nodes:d,edges:f}),g=this.getSizes(p,c);if(this.run(p,e,u,g,t,o),l){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){const n=t.getAllNodes(),r={};for(let t=0;t<n.length;t+=1){const i=n[t];r[i.id]=fb(e,void 0)(i)}return r}formatOptions(t={},e){const n=Object.assign(Object.assign({},this.options),t),{center:r,width:i,height:o,barnesHut:a,prune:s,maxIteration:l,kr:u,kg:c}=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!==l||s?0===l&&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)),u||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n}run(t,e,n,r,i,o){const{kr:a,barnesHut:s,onTick:l}=o,u=t.getAllNodes();let c=0,h=n;const d={},f={},p={};for(let e=0;e<u.length;e+=1){const{data:n,id:r}=u[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 tj(i)}}for(;h>0;)c=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:c,forces:d,preForces:f,bodies:p,sizes:r},o),h--,null==l||l({nodes:u,edges:e.getAllEdges()});return t}oneStep(t,e,n){const{iter:r,preventOverlapIters:i,krPrime:o,sg:a,preForces:s,bodies:l,sizes:u}=e;let{forces:c}=e;const{preventOverlap:h,barnesHut:d}=n,f=t.getAllNodes();for(let t=0;t<f.length;t+=1){const{id:e}=f[t];s[e]=[...c[e]],c[e]=[0,0]}return c=this.getAttrForces(t,r,i,u,c,n),c=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,c,l,n):this.getRepGraForces(t,r,i,c,o,u,n),this.updatePos(t,c,s,a,n)}getAttrForces(t,e,n,r,i,o){const{preventOverlap:a,dissuadeHubs:s,mode:l,prune:u}=o,c=t.getAllEdges();for(let o=0;o<c.length;o+=1){const{source:h,target:d}=c[o],f=t.getNode(h),p=t.getNode(d),g=t.getDegree(h),v=t.getDegree(d);if(u&&(g<=1||v<=1))continue;const m=[p.data.x-f.data.x,p.data.y-f.data.y];let y=Math.hypot(m[0],m[1]);y=y<1e-4?1e-4:y,m[0]=m[0]/y,m[1]=m[1]/y,a&&e<n&&(y=y-r[h]-r[d]);let b=y,x=b;"linlog"===l&&(b=Math.log(1+y),x=b),s&&(b=y/g,x=y/v),a&&e<n&&y<=0?(b=0,x=0):a&&e<n&&y>0&&(b=y,x=y),i[h][0]+=b*m[0],i[d][0]-=x*m[0],i[h][1]+=b*m[1],i[d][1]-=x*m[1]}return i}getOptRepGraForces(t,e,n,r){const{kg:i,center:o,prune:a}=r,s=t.getAllNodes(),l=s.length;let u=9e10,c=-9e10,h=9e10,d=-9e10;for(let e=0;e<l;e+=1){const{id:r,data:i}=s[e];a&&t.getDegree(r)<=1||(n[r].setPos(i.x,i.y),i.x>=c&&(c=i.x),i.x<=u&&(u=i.x),i.y>=d&&(d=i.y),i.y<=h&&(h=i.y))}const f=Math.max(c-u,d-h),p=new ej({xmid:(c+u)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:l}),g=new nj(p);for(let e=0;e<l;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<l;r+=1){const{id:l,data:u}=s[r],c=t.getDegree(l);if(a&&c<=1)continue;n[l].resetForce(),g.updateForce(n[l]),e[l][0]-=n[l].fx,e[l][1]-=n[l].fy;const h=[u.x-o[0],u.y-o[1]];let d=Math.hypot(h[0],h[1]);d=d<1e-4?1e-4:d,h[0]=h[0]/d,h[1]=h[1]/d;const f=i*(c+1);e[l][0]-=f*h[0],e[l][1]-=f*h[1]}return e}getRepGraForces(t,e,n,r,i,o,a){const{preventOverlap:s,kr:l,kg:u,center:c,prune:h}=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 u=a+1;u<f;u+=1){const a=d[u],c=t.getDegree(a.id);if(h&&(g<=1||c<=1))continue;const f=[a.data.x-p.data.x,a.data.y-p.data.y];let v=Math.hypot(f[0],f[1]);v=v<1e-4?1e-4:v,f[0]=f[0]/v,f[1]=f[1]/v,s&&e<n&&(v=v-o[p.id]-o[a.id]);let m=l*(g+1)*(c+1)/v;s&&e<n&&v<0?m=i*(g+1)*(c+1):s&&e<n&&0===v?m=0:s&&e<n&&v>0&&(m=l*(g+1)*(c+1)/v),r[p.id][0]-=m*f[0],r[a.id][0]+=m*f[0],r[p.id][1]-=m*f[1],r[a.id][1]+=m*f[1]}const v=[p.data.x-c[0],p.data.y-c[1]],m=Math.hypot(v[0],v[1]);v[0]=v[0]/m,v[1]=v[1]/m;const y=u*(g+1);r[p.id][0]-=y*v[0],r[p.id][1]-=y*v[1]}return r}updatePos(t,e,n,r,i){const{ks:o,tao:a,prune:s,ksmax:l}=i,u=t.getAllNodes(),c=u.length,h=[],d=[];let f=0,p=0,g=r;for(let r=0;r<c;r+=1){const{id:i}=u[r],o=t.getDegree(i);if(s&&o<=1)continue;const a=[e[i][0]-n[i][0],e[i][1]-n[i][1]],l=Math.hypot(a[0],a[1]),c=[e[i][0]+n[i][0],e[i][1]+n[i][1]],g=Math.hypot(c[0],c[1]);h[r]=l,d[r]=g/2,f+=(o+1)*h[r],p+=(o+1)*d[r]}const v=g;g=a*p/f,0!==v&&(g=g>1.5*v?1.5*v:g);for(let n=0;n<c;n+=1){const{id:r,data:i}=u[n],a=t.getDegree(r);if(s&&a<=1)continue;if(ae(i.fx)&&ae(i.fy))continue;let c=o*g/(1+g*Math.sqrt(h[n])),d=Math.hypot(e[r][0],e[r][1]);d=d<1e-4?1e-4:d;const f=l/d;c=c>f?f:c;const p=c*e[r][0],v=c*e[r][1];t.mergeNodeData(r,{x:i.x+p,y:i.y+v})}return g}}const oj={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};class aj{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},oj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield 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 ze(this,void 0,void 0,(function*(){if(this.running)return;const r=this.formatOptions(n),{dimensions:i,width:o,height:a,center:s,clustering:l,nodeClusterBy:u,maxIteration:c,onTick:h}=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=>ub(t,[o,a]))),g=new Yg({nodes:p,edges:f}),v={};if(l&&p.forEach((t=>{const e=t.data[u];v[e]||(v[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=v,"undefined"==typeof window)return;let m=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(g,v,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==h||h({nodes:p,edges:f}),m++,m>=c&&(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:l,clustering:u,nodeClusterBy:c,clusterGravity:h}=n,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),v=Math.sqrt(g),m={};if(this.applyCalculate(t,m,v,g),u){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[c]];ae(n.x)&&(r.cx+=n.x),ae(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=h||a;p.forEach(((n,r)=>{const{id:i,data:o}=n;if(!ae(o.x)||!ae(o.y))return;const a=e[o[c]],s=Math.sqrt((o.x-a.cx)*(o.x-a.cx)+(o.y-a.cy)*(o.y-a.cy)),l=v*t;m[i].x-=l*(o.x-a.cx)/s,m[i].y-=l*(o.y-a.cy)/s}))}p.forEach(((t,e)=>{const{id:n,data:i}=t;if(!ae(i.x)||!ae(i.y))return;const o=.01*v*a;m[n].x-=o*(i.x-s[0]),m[n].y-=o*(i.y-s[1]),3===r&&(m[n].z-=o*(i.z-s[2]))})),p.forEach(((e,n)=>{const{id:i,data:o}=e;if(ae(o.fx)&&ae(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!ae(o.x)||!ae(o.y))return;const a=Math.sqrt(m[i].x*m[i].x+m[i].y*m[i].y+(3===r?m[i].z*m[i].z:0));if(a>0){const e=Math.min(f*(l/800),a);t.mergeNodeData(i,{x:o.x+m[i].x/a*e,y:o.y+m[i].y/a*e,z:3===r?o.z+m[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||!ae(t.x)||!ae(r.x)||!ae(t.y)||!ae(r.y))return;let l=t.x-r.x,u=t.y-r.y,c=3===this.options.dimensions?t.z-r.z:0,h=l*l+u*u+c*c;0===h&&(h=1,l=.01,u=.01,c=.01);const d=n/h,f=l*d,p=u*d,g=c*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(!(ae(s.x)&&ae(a.x)&&ae(s.y)&&ae(a.y)))return;const l=s.x-a.x,u=s.y-a.y,c=3===this.options.dimensions?s.z-a.z:0,h=Math.sqrt(l*l+u*u+c*c)/n,d=l*h,f=u*h,p=c*h;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)}))}}const sj={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};class lj{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},sj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericGridLayout(!0,t,e)}))}genericGridLayout(t,e,n){return ze(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:l,cols:u,nodeSpacing:c,nodeSize:h,width:d,height:f,position:p}=r;let{sortBy:g}=r;const v=e.getAllNodes(),m=e.getAllEdges(),y=null==v?void 0:v.length;if(!y||1===y)return mb(e,t,i);const b=v.map((t=>ub(t)));"id"===g||ne(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)=>ae(e.id)&&ae(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const x=d||"undefined"==typeof window?d:window.innerWidth,E=f||"undefined"==typeof window?f:window.innerHeight,w=y,k={rows:l,cols:u};if(null!=l&&null!=u)k.rows=l,k.cols=u;else if(null!=l&&null==u)k.rows=l,k.cols=Math.ceil(w/k.rows);else if(null==l&&null!=u)k.cols=u,k.rows=Math.ceil(w/k.cols);else{const t=Math.sqrt(w*E/x);k.rows=Math.round(t),k.cols=Math.round(x/E*t)}if(k.rows=Math.max(k.rows,1),k.cols=Math.max(k.cols,1),k.cols*k.rows>w){const t=uj(k),e=cj(k);(t-1)*e>=w?uj(k,t-1):(e-1)*t>=w&&cj(k,e-1)}else for(;k.cols*k.rows<w;){const t=uj(k),e=cj(k);(e+1)*t>=w?cj(k,e+1):uj(k,t+1)}let M=o?0:x/k.cols,S=o?0:E/k.rows;if(s||c){const t=hb(10,c),n=db(30,h,!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,s]=cb(n(i)||30),l=void 0!==t?t(r):a,u=o+l,c=s+l;M=Math.max(M,u),S=Math.max(S,c)}))}const N={},O={row:0,col:0},T={};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;hj(N,t);)t.col++;else if(void 0===t.row)for(t.row=0;hj(N,t);)t.row++;T[n.id]=t,dj(N,t)}pj(n,i,M,S,T,k,O,N)}const A={nodes:b,edges:m};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),A}))}}const uj=(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},cj=(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},hj=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,dj=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,fj=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},pj=(t,e,n,r,i,o,a,s)=>{let l,u;const c=i[t.id];if(c)l=c.col*n+n/2+e[0],u=c.row*r+r/2+e[1];else{for(;hj(s,a);)fj(o,a);l=a.col*n+n/2+e[0],u=a.row*r+r/2+e[1],dj(s,a),fj(o,a)}t.data.x=l,t.data.y=u},gj={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},vj=(t,e,n,r,i,o)=>{e.forEach(((a,s)=>{n[s]={x:0,y:0},e.forEach(((e,l)=>{if(s===l)return;if(i[s]!==i[l])return;let u=a.x-e.x,c=a.y-e.y,h=Math.sqrt(u*u+c*c);if(0===h){h=1;const t=s>l?1:-1;u=.01*t,c=.01*t}if(h<o(t[s])/2+o(t[l])/2){const t=r*r/h;n[s].x+=u/h*t,n[s].y+=c/h*t}}))}))},mj=(t,e,n,r,i,o,a,s)=>{const l=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,l=-r/a;const u=Math.sqrt(e.x*e.x+e.y*e.y);let c=Math.acos((s*e.x+l*e.y)/u);c>Math.PI/2&&(c-=Math.PI/2,s*=-1,l*=-1);const h=Math.cos(c)*u;e.x=s*h,e.y=l*h})),t.forEach(((o,a)=>{if(a===i)return;const u=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(u>0&&a!==i){const c=Math.min(l*(n/800),u);if(o.x+=e[a].x/u*c,o.y+=e[a].y/u*c,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},yj={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class bj{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},yj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRadialLayout(!0,t,e)}))}genericRadialLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,focusNode:s,unitRadius:l,nodeSize:u,nodeSpacing:c,strictRadial:h,preventOverlap:d,maxPreventOverlapIteration:f,sortBy:p,linkDistance:g=50,sortStrength:v=10,maxIteration:m=1e3}=r,y=e.getAllNodes(),b=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,E=o||"undefined"==typeof window?o:window.innerHeight,w=a||[x/2,E/2];if(!(null==y?void 0:y.length)||1===y.length)return mb(e,t,w);let k=y[0];if(ne(s)){for(let t=0;t<y.length;t++)if(y[t].id===s){k=y[t];break}}else k=s||y[0];const M=wj(y,k.id),S=ob({nodes:y,edges:b}),N=ib(S),O=Mj(N,M);kj(N,M,O+1);const T=N[M];let A=x-w[0]>w[0]?w[0]:x-w[0],C=E-w[1]>w[1]?w[1]:E-w[1];0===A&&(A=x/2),0===C&&(C=E/2);const P=Math.min(A,C),R=Math.max(...T),D=[],L=l||P/R;T.forEach(((t,e)=>{D[e]=t*L}));const _=xj(y,N,g,D,L,p,v),I=Ej(_),j=((t,e,n)=>{try{const n=Hx.mul(Hx.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 Yx(n),s=Hx.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>Hx.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,_,g);let B,F=j.map((([t,e])=>({x:(isNaN(t)?Math.random()*g:t)-j[M][0],y:(isNaN(e)?Math.random()*g:e)-j[M][1]})));if(this.run(m,F,I,_,D,M),d){B=fb(u,c);const t={nodes:y,nodeSizeFunc:B,positions:F,radii:D,height:E,width:x,strictRadial:Boolean(h),focusIdx:M,iterations:f||200,k:F.length/4.5};F=((t,e)=>{const n=Object.assign(Object.assign({},gj),e),{positions:r,iterations:i,width:o,k:a,speed:s=100,strictRadial:l,focusIdx:u,radii:c=[],nodeSizeFunc:h}=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}})),vj(d,r,f,a,c,h),mj(r,f,s,l,u,p,o,c);return r})(e,t)}const z=[];F.forEach(((t,e)=>{const n=ub(y[e]);n.data.x=t.x+w[0],n.data.y=t.y+w[1],z.push(n)})),t&&z.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:z,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,l)=>{const u=ab(s,{x:0,y:0}),c=0===u?0:1/u;if(l===o)return;let h=0,d=0,f=0;e.forEach(((t,e)=>{if(l===e)return;const n=ab(s,t),o=0===n?0:1/n,a=r[e][l];f+=i[l][e],h+=i[l][e]*(t.x+a*(s.x-t.x)*o),d+=i[l][e]*(t.y+a*(s.y-t.y)*o)}));const p=0===n[l]?0:1/n[l];f*=a,f+=t*p*p,h*=a,h+=t*p*s.x*c,s.x=h/f,d*=a,d+=t*p*s.y*c,s.y=d/f}))}}const xj=(t,e,n,r,i,o,a)=>{if(!t)return[];const s=[];{const l={};e.forEach(((e,u)=>{const c=[];e.forEach(((e,s)=>{var h,d;if(u===s)c.push(0);else if(r[u]===r[s])if("data"===o)c.push(e*(Math.abs(u-s)*a)/(r[u]/i));else if(o){let n,f;if(l[t[u].id])n=l[t[u].id];else{const e=("id"===o?t[u].id:null===(h=t[u].data)||void 0===h?void 0:h[o])||0;n=ne(e)?e.charCodeAt(0):e,l[t[u].id]=n}if(l[t[s].id])f=l[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=ne(e)?e.charCodeAt(0):e,l[t[s].id]=f}c.push(e*(Math.abs(n-f)*a)/(r[u]/i))}else c.push(e*n/(r[u]/i));else{const t=(n+i)/2;c.push(e*t)}})),s.push(c)}))}return s},Ej=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},wj=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},kj=(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}},Mj=(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},Sj={center:[0,0],width:300,height:300};class Nj{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},Sj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRandomLayout(!0,t,e)}))}genericRandomLayout(t,e,n){return ze(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(),l=o||"undefined"==typeof window?o:window.innerWidth,u=a||"undefined"==typeof window?a:window.innerHeight,c=i||[l/2,u/2],h=[];s&&s.forEach((t=>{h.push({id:t.id,data:{x:.9*(Math.random()-.5)*l+c[0],y:.9*(Math.random()-.5)*u+c[1]}})})),t&&h.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:h,edges:e.getAllEdges()}}))}}
66
+ */class Mp extends tf{constructor(t){super(Object.assign(Object.assign({},t),{style:Object.assign({},Mp.defaultStyleProps,t.style)})),this.rootPointerEvent=new Cs(null),this.forwardEvents=t=>{const e=this.context.canvas,n=e.context.renderingContext.root.ownerDocument.defaultView;this.normalizeToPointerEvent(t,n).forEach((r=>{const i=this.bootstrapEvent(this.rootPointerEvent,r,n,t);Te(e.context.eventService,"mappingTable.pointerupoutside",[]),e.context.eventService.mapEvent(i)}))}}get eventService(){return this.context.canvas.context.eventService}get events(){return[t.CommonEvent.CLICK,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_UP,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE]}getDomElement(){return this.getShape("key").getDomElement()}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.drawPortShapes(t,e)}getKeyStyle(t){const e=Ce(t,["dx","dy","innerHTML","pointerEvents","cursor"]),{dx:n=0,dy:r=0}=e,i=Fe(e,["dx","dy"]),[o,a]=this.getSize(t);return Object.assign(Object.assign({x:n,y:r},i),{width:o,height:a})}drawKeyShape(t,e){const n=this.getKeyStyle(t),{x:r,y:i,width:o=0,height:a=0}=n,s=this.upsert("key-container",Xl,{x:r,y:i,width:o,height:a,opacity:0},e);return this.upsert("key",Fl,n,s)}connectedCallback(){if(!(this.context.canvas.getRenderer("main")instanceof kp))return;const t=this.getDomElement();this.events.forEach((e=>{t.addEventListener(e,this.forwardEvents)}))}attributeChangedCallback(t,e,n){"zIndex"===t&&e!==n&&(this.getDomElement().style.zIndex=n)}destroy(){const t=this.getDomElement();this.events.forEach((e=>{t.removeEventListener(e,this.forwardEvents)})),super.destroy()}normalizeToPointerEvent(t,e){const n=[];if(e.isTouchEvent(t))for(let e=0;e<t.changedTouches.length;e++){const r=t.changedTouches[e];ve(r.button)&&(r.button=0),ve(r.buttons)&&(r.buttons=1),ve(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),ve(r.width)&&(r.width=r.radiusX||1),ve(r.height)&&(r.height=r.radiusY||1),ve(r.tiltX)&&(r.tiltX=0),ve(r.tiltY)&&(r.tiltY=0),ve(r.pointerType)&&(r.pointerType="touch"),ve(r.pointerId)&&(r.pointerId=r.identifier||0),ve(r.pressure)&&(r.pressure=r.force||.5),ve(r.twist)&&(r.twist=0),ve(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;ve(e.isPrimary)&&(e.isPrimary=!0),ve(e.width)&&(e.width=1),ve(e.height)&&(e.height=1),ve(e.tiltX)&&(e.tiltX=0),ve(e.tiltY)&&(e.tiltY=0),ve(e.pointerType)&&(e.pointerType="mouse"),ve(e.pointerId)&&(e.pointerId=1),ve(e.pressure)&&(e.pressure=.5),ve(e.twist)&&(e.twist=0),ve(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.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}bootstrapEvent(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);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const[a,s]=this.context.canvas.getCanvasByViewport([i,o]);return t.canvas.x=a,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:a}=t;if(Ut(r)||Ut(i)){const t=this.eventService.client2Viewport({x:o,y:a});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}onframe(){super.onframe();const{opacity:t}=this.attributes;this.getDomElement().style.opacity=`${t}`}}Mp.defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};let Sp=class t extends tf{constructor(e){super(Dd({style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t),r=super.getKeyStyle(t),{fillOpacity:i,opacity:o=i}=r,a=Fe(r,["fillOpacity","opacity"]);return Object.assign(Object.assign({opacity:o},a),{width:e,height:n,x:-e/2,y:-n/2})}getHaloStyle(t){if(!1===t.halo)return!1;Fe(this.getShape("key").attributes,["fill","stroke"]);const e=Td(this.getGraphicStyle(t),"halo"),n=Number(e.lineWidth),[r,i]=Ih(this.getSize(t),[n,n]);return Object.assign(Object.assign({},e),{width:r,height:i,fill:"transparent",x:-r/2,y:-i/2})}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&Object.assign({width:n*yd,height:r*yd},e)}drawKeyShape(t,e){const n=this.upsert("key",$d,this.getKeyStyle(t),e);return Kd(this),n}drawHaloShape(t,e){this.upsert("halo",Xl,this.getHaloStyle(t),e)}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Zd(this)}};Sp.defaultStyleProps={size:32};class Np extends tf{constructor(t){super(t)}getKeyStyle(t){const[e,n]=this.getSize(t);return Object.assign(Object.assign({},super.getKeyStyle(t)),{width:e,height:n,x:-e/2,y:-n/2})}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getShape("key").attributes;return!!e&&Object.assign({width:n*yd,height:r*yd},e)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}}class Op extends nf{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)*yd;return!!e&&Object.assign({width:n,height:n},e)}getPortXY(t,e){const{placement:n="top"}=e;return Mg(this.getShape("key").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)}}class Tp extends nf{constructor(t){super(Dd({style:Tp.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.getShape("key").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 Mg(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||Se(n||r))return!1;const o=Td(this.getGraphicStyle(t),"icon"),a=this.getShape("key").getLocalBounds(),[s,l]=function(t,e){const{center:n}=t,[r,i]=Xc(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),u=2*function(t,e){let[n,r]=Xc(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(Math.pow(r,2)-Math.pow(Math.sqrt(Math.pow(n/2,2)+Math.pow(r,2))-n/2,2))/(2*r)}(a,i)*yd;return Object.assign({x:s,y:l,width:u,height:u},o)}}Tp.defaultStyleProps={size:40,direction:"up"};class Ap extends tf{constructor(t){super(Dd({style:Ap.defaultStyleProps},t)),this.type="combo",this.updateComboPosition(this.parsedAttributes)}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]=Yc(e);return Ih(Pd(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Pd(t.collapsedSize)}getExpandedKeySize(t){const e=this.getContentBBox(t);return[$c(e),qc(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=e.map((t=>this.context.element.getElement(t))).filter(Boolean);if(0===r.length){const e=new Ur,{x:n=0,y:r=0,size:i}=t,[o,a]=Pd(i);return e.setMinMax([n-o/2,r-a/2,0],[n+o/2,r+a/2,0]),e}const i=Jc(r.map((t=>t.getBounds())));return n?Qc(i,n):i}drawCollapsedMarkerShape(t,e){const n=this.getCollapsedMarkerStyle(t);this.upsert("collapsed-marker",Qd,n,e),Kd(this)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const e=Td(this.getGraphicStyle(t),"collapsedMarker"),{type:n}=e,r=Fe(e,["type"]),i=this.getShape("key"),[o,a]=td(i.getLocalBounds(),"center"),s=Object.assign(Object.assign({},r),{x:o,y:a});if(n){const e=this.getCollapsedMarkerText(n,t);Object.assign(s,{text:e})}return s}getCollapsedMarkerText(t,e){const{childrenData:n=[]}=e,{model:r}=this.context;return"descendant-count"===t?r.getDescendantsData(this.id).length.toString():"child-count"===t?n.length.toString():"node-count"===t?r.getDescendantsData(this.id).filter((t=>"node"===r.getElementType(yh(t)))).length.toString():Yt(t)?t(n):""}getComboPosition(t){const{x:e=0,y:n=0,collapsed:r,childrenData:i=[]}=t;if(0===i.length)return[+e,+n,0];if(r){const{model:t}=this.context,r=t.getDescendantsData(this.id).filter((e=>!t.isCombo(yh(e))));if(r.length>0&&r.some(Jh)){return Fh(r.reduce(((t,e)=>Ih(t,Qh(e))),[0,0,0]),r.length)}return[+e,+n,0]}return this.getContentBBox(t).center}getComboStyle(t){const[e,n]=this.getComboPosition(t);return{x:e,y:n,transform:[["translate",e,n]]}}updateComboPosition(t){const e=this.getComboStyle(t);Object.assign(this.style,e);const{x:n,y:r}=e;this.context.model.syncNodeLikeDatum({id:this.id,style:{x:n,y:r}}),Zd(this)}render(t,e=this){super.render(t,e),this.drawCollapsedMarkerShape(t,e)}update(t={}){super.update(t),this.updateComboPosition(this.parsedAttributes)}onframe(){super.onframe(),this.attributes.collapsed||this.updateComboPosition(this.parsedAttributes),this.drawKeyShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(this.attributes.collapsed?t:t.map((t=>Fe(t,["x","y","z","transform"]))),e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then((()=>this.onframe())),Reflect.set(t,e,n))}):n}}Ap.defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};class Cp extends Ap{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Dl,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),[r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},n),e&&Td(n,"collapsed")),{r:r/2})}getCollapsedKeySize(t){const[e,n]=Pd(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){const e=this.getContentBBox(t),[n,r]=Xc(e),i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2))/2;return[2*i,2*i,0]}getIntersectPoint(t,e=!1){return ud(t,this.getShape("key").getBounds(),e)}}class Pp extends Ap{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},e),t.collapsed&&Td(e,"collapsed")),{width:n,height:r,x:-n/2,y:-r/2})}}const Rp={padding:10};function Dp(t,e,n,r,i,o){const{padding:a}=Object.assign(Rp,o),s=Kc(n,a),l=Kc(r,a),u=[t,...i,e];let c=null;const h=[];for(let t=0,e=u.length;t<e-1;t++){const n=t+1,r=u[t],i=u[n],o=od(d=r,f=i)||function(t,e){return t[0]===e[0]}(d,f);let p=null;if(0===t)if(n===e-1)if(s.intersects(l))p=Vp(r,i,s,l);else if(nh(r,s)||nh(i,l))o||(p=Gp(r,i,s,l));else{const t=ih(r,s),e=ih(i,l);p=Bp(t,e,Ip(t,e)),p.points.unshift(t),p.points.push(e)}else th(i,s)?p=Vp(r,i,s,Kc(i,a),c):o||(p=Fp(r,i,s));else n===e-1?th(r,l)?p=Vp(r,i,Kc(r,a),l,c):o||(p=zp(r,i,l,c)):o||(p=Bp(r,i,c));p?(h.push(...p.points),c=p.direction):c=Ip(r,i),n<e-1&&h.push(i)}var d,f;return h.map(Uh)}const Lp={N:"S",S:"N",W:"E",E:"W"},_p={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function Ip(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function jp(t,e){return"N"===e||"S"===e?qc(t):$c(t)}function Bp(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=Ip(t,r),a=Ip(t,i),s=n?Lp[n]:null,l=o===n||o!==s&&a!==n?r:i;return{points:[l],direction:Ip(l,e)}}function Fp(t,e,n){if(nh(t,n)){const r=Wp(t,e,n);return{points:[r],direction:Ip(r,e)}}{const r=ih(t,n),i=["left","right"].includes(rh(t,n))?[e[0],r[1]]:[r[0],e[1]];return{points:[i],direction:Ip(i,e)}}}function zp(t,e,n,r){const i=nh(e,n)?e:ih(e,n),o=[[i[0],t[1]],[t[0],i[1]]],a=o.filter((t=>function(t,e){return!th(t,e)}(t,n)&&!eh(t,n,!0))),s=a.filter((e=>Ip(e,t)!==r));if(s.length>0){const n=s.find((e=>Ip(t,e)===r))||s[0];return{points:[n],direction:Ip(n,e)}}{const i=id(e,Ht(o,a)[0],jp(n,r)/2);return{points:[Wp(i,t,n),i],direction:Ip(i,e)}}}function Gp(t,e,n,r){let i=Fp(t,e,n);const o=$h(i.points[0]);if(th(o,r)){i=Fp(e,t,r);const a=$h(i.points[0]);if(th(a,n)){const s=id(t,o,jp(n,Ip(t,o))/2),l=id(e,a,jp(r,Ip(e,a))/2),u=[(s[0]+l[0])/2,(s[1]+l[1])/2],c=Fp(t,u,n),h=zp(u,e,r,c.direction);i.points=[c.points[0],h.points[0]],i.direction=h.direction}}return i}function Vp(t,e,n,r,i){const o=Jc([n,r]),a=Gh(e,o.center)>Gh(t,o.center),[s,l]=a?[e,t]:[t,e],u=qc(o)+$c(o);let c;if(i){const t=[s[0]+u*Math.cos(_p[i]),s[1]+u*Math.sin(_p[i])];c=id(ih(t,o),t,.01)}else c=id(ih(s,o),s,-.01);let h=Wp(c,l,o),d=[rd(c,2),rd(h,2)];if(Ne(rd(c),rd(h))){const t=Hh(jh(c,s),[1,0,0])+Math.PI/2;h=[l[0]+u*Math.cos(t),l[1]+u*Math.sin(t),0],h=rd(id(ih(h,o),l,-.01),2);d=[c,Wp(c,h,o),h]}return{points:a?d.reverse():d,direction:Ip(a?c:h,e)}}function Wp(t,e,n){let r=[t[0],e[1]];return th(r,n)&&(r=[e[0],t[1]]),r}function Hp(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=ed(t.getPoint(o)),s=ed(t.getPoint(o+.01));let l="start"===e?"left":"end"===e?"right":"center";if(od(a,s)||!n){const[e,n]=Yp(t,o,r,i);return{transform:[["translate",e,n]],textAlign:l}}let u=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(l="center"===l?l:"left"===l?"right":"left",r*=-1,u+=Math.PI);const[c,h]=Yp(t,o,r,i,u);return{textAlign:l,transform:[["translate",c,h],["rotate",u/Math.PI*180]]}}function Yp(t,e,n,r,i){const[o,a]=ed(t.getPoint(e));let s=n,l=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),l=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+l]}function Up(t,e,n,r){if(Ne(t,e))return t;const i=jh(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=Wh(Yh(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function $p(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 qp(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,l=o[n+1]||i;if(!ad(s,t,l)&&e){const[n,r]=function(t,e,n,r){const i=Vh(t,e),o=Vh(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])],l=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,l]}(s,t,l,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]])})),a.push(["L",i[0],i[1]]),n&&a.push(["Z"]),a}function Xp(t,e,n,r,i){const o=Kc(t),a=t.getCenter();let s=r&&Og(r),l=i&&Og(i);if(!s||!l){const r=(t=>{const e=Math.PI/2,n=qc(t)/2,r=$c(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]}})(o),i=r[e][0],u=r[e][1],[c,h]=Xc(o),d=Math.max(c,h),f=Ih(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Ih(a,[d*Math.cos(u),d*Math.sin(u),0]);s=Pg(t,f),l=Pg(t,p),n||([s,l]=[l,s])}return[s,l]}function Kp(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[l,u]=Xp(t,e,n,a,s);const c=function(t,e,n,r){const i=t.getCenter();if(Ne(e,n)){const t=jh(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Ih(e,o),Ih(n,Bh(o,[1,-1,1]))]}return[id(i,e,Gh(i,e)+r),id(i,n,Gh(i,n)+r)]}(t,l,u,r);return a&&(l=Cg(a,c[0])),s&&(u=Cg(s,c[c.length-1])),$p(l,u,c)}function Zp(t,e,n,r,i,o,a){const s=Sg(t),l=s[o||a],u=s[a||o];let[c,h]=Xp(t,n,r,l,u);const d=function(t,e,n,r){const i=[],o=Kc(t);if(Ne(e,n)){switch(rh(e,o)){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=rh(e,o),a=rh(n,o);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]),l=s(t,e),u=s(a,n),c=Wp(l,u,o);i.push(l,c,u)}}return i}(t,c,h,i);return l&&(c=Cg(l,d[0])),u&&(h=Cg(u,d[d.length-1])),qp([c,...d,h],e)}function Qp(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)}}function Jp(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(yh(r));if(!t)break;r=t}if(n.some((t=>{var e;return null===(e=t.style)||void 0===e?void 0:e.collapsed}))){const t=n.reverse().findIndex(Sd);return n[t]||n.at(-1)}return t}const tg=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var eg=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",-t/2,0],["A",n,n,0,1,0,2*n-t/2,0],["A",n,n,0,1,0,-t/2,0],["Z"]]},diamond:(t,e)=>[["M",-t/2,0],["L",0,-e/2],["L",t/2,0],["L",0,e/2],["Z"]],rect:(t,e)=>[["M",-t/2,-e/2],["L",t/2,-e/2],["L",t/2,e/2],["L",-t/2,e/2],["Z"]],simple:(t,e)=>[["M",t/2,-e/2],["L",-t/2,0],["L",t/2,0],["L",-t/2,0],["L",t/2,e/2]],triangle:tg,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",-n,0],["L",0,-e/2],["L",0,e/2],["Z"],["M",i-n,-e/2],["L",i+r-n,-e/2],["L",i+r-n,e/2],["L",i-n,e/2],["Z"]]},vee:(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",4*t/5-t/2,0],["L",t/2,e/2],["Z"]]});class ng extends Jd{constructor(t){super(Dd({style:ng.defaultStyleProps},t)),this.type="edge"}get sourceNode(){const{sourceNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}get targetNode(){const{targetNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}getKeyStyle(t){const e=this.getGraphicStyle(t),{loop:n}=e,r=Fe(e,["loop"]),{sourceNode:i,targetNode:o}=this;var a,s;const l={d:n&&(s=o,(a=i)&&s&&a===s)?this.getLoopPath(t):this.getKeyPath(t)};return Hl.PARSED_STYLE_LIST.forEach((t=>{t in r&&(l[t]=r[t])})),l}getLoopPath(t){const{sourcePort:e,targetPort:n}=t,r=this.sourceNode,i=Kc(r),o=Math.max($c(i),qc(i)),{placement:a,clockwise:s,dist:l=o}=Td(this.getGraphicStyle(t),"loop");return Kp(r,a,s,l,e,n)}getEndpoints(t,e=!0,n=[]){const{sourcePort:r,targetPort:i}=t,{sourceNode:o,targetNode:a}=this,[s,l]=function(t,e,n,r){const i=Tg(t,e,n,r),o=Tg(e,t,r,n);return[i,o]}(o,a,r,i);if(!e){return[s?Og(s):o.getCenter(),l?Og(l):a.getCenter()]}const u="function"==typeof n?n():n;return[Ag(s||o,u[0]||l||a),Ag(l||a,u[u.length-1]||s||o)]}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),n=Td(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign({},e),n)}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Td(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a}=e,s=Fe(e,["placement","offsetX","offsetY","autoRotate","maxWidth"]),l=Hp(this.shapeMap.key,n,o,r,i),u=this.shapeMap.key.getLocalBounds(),c=function(t,e,n=1){return Id(Gh(t[0],t[1])*n,e)}([u.min,u.max],a);return Object.assign({wordWrapWidth:c},l,s)}getBadgeStyle(t){if(!1===t.badge||!t.badgeText)return!1;const e=Td(t,"badge"),{offsetX:n,offsetY:r,placement:i}=e,o=Fe(e,["offsetX","offsetY","placement"]);return Object.assign(o,function(t,e,n,r,i){var o,a;const s=2*(null===(o=t.badge)||void 0===o?void 0:o.getGeometryBounds().halfExtents[0])||0,l=2*(null===(a=t.label)||void 0===a?void 0:a.getGeometryBounds().halfExtents[0])||0;return Hp(t.key,n,!0,(l?(l/2+s/2)*("suffix"===e?1:-1):0)+r,i)}(this.shapeMap,i,t.labelPlacement,n,r))}drawArrow(t,e){var n;const r="start"===e,i=t["start"===e?"startArrow":"endArrow"],o=this.shapeMap.key;if(i){const e=this.getArrowStyle(t,r),[n,i,a]=r?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],s=o.parsedStyle[n];if(s)s.attr(e);else{const t=new(e.src?zl:Hl)({style:e});o.style[n]=t}o.style[i]=t[a]||e.width/2+ +e.lineWidth}else{const t=r?"markerStart":"markerEnd";null===(n=o.style[t])||void 0===n||n.destroy(),o.style[t]=null}}getArrowStyle(t,e){const n=this.getShape("key").attributes,r=e?"startArrow":"endArrow",i=Td(this.getGraphicStyle(t),r),{size:o,type:a}=i,s=Fe(i,["size","type"]),[l,u]=Pd(function(t,e){return e||(t<4?10:4===t?12:2.5*t)}(n.lineWidth,o)),c=(Yt(a)?a:eg[a]||tg)(l,u);return Object.assign(Ce(n,["stroke","strokeOpacity","fillOpacity"]),{width:l,height:u},Object.assign({},c&&{d:c,fill:"simple"===a?"":n.stroke}),s)}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Gd,n,e)}drawHaloShape(t,e){const n=this.getHaloStyle(t);this.upsert("halo",Hl,n,e)}drawBadgeShape(t,e){const n=this.getBadgeStyle(t);this.upsert("badge",Vd,n,e)}drawSourceArrow(t){this.drawArrow(t,"start")}drawTargetArrow(t){this.drawArrow(t,"end")}drawKeyShape(t,e){const n=this.getKeyStyle(t);return this.upsert("key",Hl,n,e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.getShape("key")&&(this.drawSourceArrow(t),this.drawTargetArrow(t),this.drawLabelShape(t,e),this.drawHaloShape(t,e),this.drawBadgeShape(t,e))}onframe(){this.drawKeyShape(this.parsedAttributes,this),this.drawSourceArrow(this.parsedAttributes),this.drawTargetArrow(this.parsedAttributes),this.drawHaloShape(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this),this.drawBadgeShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(t,e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then((()=>this.onframe())),Reflect.set(t,e,n))}):n}}ng.defaultStyleProps={badge:!0,badgeOffsetX:0,badgeOffsetY:0,badgePlacement:"suffix",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,loop:!0,startArrow:!1,startArrowLineDash:0,startArrowLineJoin:"round",startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"vee",endArrow:!1,endArrowLineDash:0,endArrowLineJoin:"round",endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"vee",loopPlacement:"top",loopClockwise:!0};class rg extends ng{constructor(t){super(Dd({style:rg.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 ae(t)?[t,1-t]:t}(i),function(t){return ae(t)?[t,-t]:t}(o),r);return $p(e,n,a)}getControlPoints(t,e,n,r,i){return 2===(null==i?void 0:i.length)?i:[Up(t,e,n[0],r[0]),Up(t,e,n[1],r[1])]}}rg.defaultStyleProps={curvePosition:.5,curveOffset:20};class ig extends rg{constructor(t){super(Dd({style:ig.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]]]}}ig.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};class og extends rg{constructor(t){super(Dd({style:og.defaultStyleProps},t))}get ref(){return this.context.model.getRootsData()[0]}getEndpoints(t){if(this.sourceNode.id===this.ref.id)return super.getEndpoints(t);const e=Qh(this.ref);return[this.sourceNode.getIntersectPoint(e,!0),this.targetNode.getIntersectPoint(e)]}toRadialCoordinate(t){const e=Qh(this.ref);return[Gh(t,e),qh(jh(t,e))]}getControlPoints(t,e,n,r){const[i,o]=this.toRadialCoordinate(t),[a]=this.toRadialCoordinate(e),s=a-i;return[[t[0]+(s*n[0]+r[0])*Math.cos(o),t[1]+(s*n[0]+r[0])*Math.sin(o)],[e[0]-(s*n[1]-r[0])*Math.cos(o),e[1]-(s*n[1]-r[0])*Math.sin(o)]]}}og.defaultStyleProps={curvePosition:.5,curveOffset:20};class ag extends rg{constructor(t){super(Dd({style:ag.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]]]}}ag.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};let sg=class t extends ng{constructor(e){super(Dd({style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};sg.defaultStyleProps={};const lg={enableObstacleAvoidance:!1,offset:10,maxAllowedDirectionChange:Math.PI/2,maximumLoops:3e3,gridSize:5,startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{right:{stepX:1,stepY:0},left:{stepX:-1,stepY:0},bottom:{stepX:0,stepY:1},top:{stepX:0,stepY:-1}},penalties:{0:0,90:0},distFunc:Vh},ug=t=>`${Math.round(t[0])}|||${Math.round(t[1])}`;function cg(t,e){const n=t=>Math.round(t/e);return ae(t)?n(t):t.map(n)}function hg(t,e){const n=e[0]-t[0],r=e[1]-t[1];return n||r?Math.atan2(r,n):0}function dg(t,e,n,r){const i=hg(t,e),o=n[ug(t)];return function(t,e){const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n}(hg(o||r,t),i)}function fg(t,e,n){return Math.min(...e.map((e=>n(t,e))))}const pg=(t,e,n,r)=>{if(!e)return[t];const{directionMap:i,offset:o}=r,a=Qc(e.getRenderBounds(),o),s=Object.keys(i).reduce(((e,r)=>{if(n.includes(r)){const n=i[r],[o,s]=Xc(a),l=[t[0]+n.stepX*o,t[1]+n.stepY*s],u=function(t){const{min:[e,n],max:[r,i]}=t,o=[e,i],a=[r,i],s=[r,n],l=[e,n];return[[o,a],[a,s],[s,l],[l,o]]}(a);for(let n=0;n<u.length;n++){const r=Kh([t,l],u[n]);r&&eh(r,a)&&e.push(r)}}return e}),[]);return th(t,a)||s.push(t),s.map((t=>cg(t,r.gridSize)))},gg=(t,e,n,r,i,o,a)=>{const s=[];let l=[o[0]===r[0]?r[0]:t[0]*a,o[1]===r[1]?r[1]:t[1]*a];s.unshift(l);let u=t,c=e[ug(u)];for(;c;){const t=c,r=u;dg(t,r,e,n)&&(l=[t[0]===r[0]?l[0]:t[0]*a,t[1]===r[1]?l[1]:t[1]*a],s.unshift(l)),c=e[ug(t)],u=t}const h=i.map((t=>[t[0]*a,t[1]*a])),d=function(t,e,n){let r=t[0],i=n(t[0],e);for(let o=0;o<t.length;o++){const a=t[o],s=n(a,e);s<i&&(r=a,i=s)}return r}(h,l,Vh);return s.unshift(d),s};function vg(t,e,n,r){const i=Uh(t.getCenter()),o=Uh(e.getCenter()),a=Object.assign(lg,r),{gridSize:s}=a,l=((t,e)=>{const{offset:n,gridSize:r}=e,i={};return t.forEach((t=>{if(!t||t.destroyed||!t.isVisible())return;const e=Qc(t.getRenderBounds(),n);for(let t=cg(e.min[0],r);t<=cg(e.max[0],r);t+=1)for(let n=cg(e.min[1],r);n<=cg(e.max[1],r);n+=1)i[`${t}|||${n}`]=!0})),i})(a.enableObstacleAvoidance?n:[t,e],a),u=cg(i,s),c=cg(o,s),h=pg(i,t,a.startDirections,a),d=pg(o,e,a.endDirections,a);h.forEach((t=>delete l[ug(t)])),d.forEach((t=>delete l[ug(t)]));const f={},p={},g={},v={},m={},y=new mg;for(let t=0;t<h.length;t++){const e=h[t],n=ug(e);f[n]=e,v[n]=0,m[n]=fg(e,d,a.distFunc),y.add({id:n,value:m[n]})}const b=d.map((t=>ug(t)));let x,E=a.maximumLoops,w=1/0;for(const[t,e]of Object.entries(f))m[t]<=w&&(w=m[t],x=e);for(;Object.keys(f).length>0&&E>0;){const t=y.minId(!1);if(!t)break;x=f[t];const e=ug(x);if(b.includes(e))return gg(x,g,u,o,h,c,s);delete f[e],y.remove(e),p[e]=!0;for(const t of Object.values(a.directionMap)){const n=Ih(x,[t.stepX,t.stepY]),r=ug(n);if(p[r])continue;const i=dg(x,n,g,u);if(i>a.maxAllowedDirectionChange)continue;if(l[r])continue;f[r]||(f[r]=n);const o=a.penalties[i],c=a.distFunc(x,n)+(isNaN(o)?s:o),h=v[e]+c,b=v[r];b&&h>=b||(g[r]=x,v[r]=h,m[r]=h+fg(n,d,a.distFunc),y.add({id:r,value:m[r]}))}E-=1}return[]}class mg{constructor(){this.arr=[],this.map={},this.arr=[],this.map={}}_innerAdd(t,e){let n=0,r=e-1;for(;r-n>1;){const e=Math.floor((n+r)/2);if(this.arr[e].value>t.value)r=e;else{if(!(this.arr[e].value<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n=e}}this.arr.splice(r,0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;if(!e||this.arr[e-1].value<t.value)return this.arr.push(t),void(this.map[t.id]=!0);this._innerAdd(t,e)}remove(t){this.map[t]&&delete this.map[t]}_clearAndGetMinId(){let t;for(let e=this.arr.length-1;e>=0;e--)this.map[this.arr[e].id]?t=this.arr[e].id:this.arr.splice(e,1);return t}_findFirstId(){for(;this.arr.length;){const t=this.arr.shift();if(this.map[t.id])return t.id}}minId(t){return t?this._clearAndGetMinId():this._findFirstId()}}class yg extends ng{constructor(t){super(Dd({style:yg.defaultStyleProps},t))}getControlPoints(t){const{router:e}=t,{sourceNode:n,targetNode:r}=this,[i,o]=this.getEndpoints(t,!1);let a=[];if(e)if("shortest-path"===e.type){a=vg(n,r,this.context.element.getNodes(),e),a.length||(a=Dp(i,o,n,r,t.controlPoints,{padding:e.offset}))}else"orth"===e.type&&(a=Dp(i,o,n,r,t.controlPoints,e));else a=t.controlPoints;return a}getPoints(t){const e=this.getControlPoints(t),[n,r]=this.getEndpoints(t,!0,e);return[n,...e,r]}getKeyPath(t){return qp(this.getPoints(t),t.radius)}getLoopPath(t){const{sourcePort:e,targetPort:n,radius:r}=t,i=this.sourceNode,o=Kc(i),a=Math.max($c(o),qc(o))/4,{placement:s,clockwise:l,dist:u=a}=Td(this.getGraphicStyle(t),"loop");return Zp(i,r,s,l,u,e,n)}}yg.defaultStyleProps={radius:0,controlPoints:[],router:!1};class bg extends ng{constructor(t){super(Dd({style:bg.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||Up(r,i,e,n))}}function xg(t){return t instanceof tf&&"node"===t.type}function Eg(t){return t instanceof ng}function wg(t){return t instanceof Ap}bg.defaultStyleProps={curvePosition:.5,curveOffset:30};const kg={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],default:[.5,.5]};function Mg(t,e,n=kg,r=!0){const i=[.5,.5],o=ne(e)?Oe(n,e.toLocaleLowerCase(),i):e;if(!r&&ne(e))return o;const[a,s]=o||i;return[t.min[0]+$c(t)*a,t.min[1]+qc(t)*s]}function Sg(t){if(!t)return{};const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{var i;const{key:o,placement:a}=n;Ng(n)&&(e[i=o||r]||(e[i]=td(t.getShape("key").getBounds(),a)))})),e}function Ng(t){const{r:e}=t;return!e||0===Number(e)}function Og(t){return Wc(t)?t:t.getPosition()}function Tg(t,e,n,r){const i=Sg(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>Og(t))),s=function(t,e){const n=Sg(t);if(e)return[Og(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>Og(t))):[t.getCenter()]}(e,r),[l]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=Gh(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>Og(t)===l))}function Ag(t,e){return wg(t)||xg(t)?Pg(t,e):Cg(t,e)}function Cg(t,e){if(!t||!e)return[0,0,0];if(Wc(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return ud(Wc(e)?e:xg(e)?e.getCenter():e.getPosition(),t.getBounds())}function Pg(t,e){if(!t||!e)return[0,0,0];const n=Wc(e)?e:xg(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function Rg(t,e="bottom",n=0,r=0,i=!1){const o=e.split("-"),[a,s]=td(t,e),l=o.includes("left")?"right":o.includes("right")?"left":"center";let u=o.includes("top")?"bottom":o.includes("bottom")?"top":"middle";return i&&(u="top"===u?"bottom":"bottom"===u?"top":u),{transform:[["translate",a+n,s+r]],textBaseline:u,textAlign:l}}function Dg(t,e){"update"in t?t.update(e):t.attr(e)}function Lg(t){return Oe(t,"__to_be_destroyed__",!1)}class _g extends Dh{constructor(t,e){super(t,Object.assign({},_g.defaultOptions,e)),this.onCollapseExpand=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{target:e}=t;if(!(xg(n=e)||Eg(n)||wg(n)))return;var n;const r=e.id,{model:i,graph:o}=this.context,a=i.getElementDataById(r);if(!a)return!1;const{onCollapse:s,onExpand:l,animation:u,align:c}=this.options;Sd(a)?(yield o.expandElement(r,{animation:u,align:c}),null==l||l(r)):(yield o.collapseElement(r,{animation:u,align:c}),null==s||s(r))})),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`node:${e}`,this.onCollapseExpand),t.on(`combo:${e}`,this.onCollapseExpand)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`node:${e}`,this.onCollapseExpand),t.off(`combo:${e}`,this.onCollapseExpand)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}_g.defaultOptions={enable:!0,animation:!0,trigger:t.CommonEvent.DBLCLICK,align:!0};const Ig="g6-create-edge-assist-node-id";class jg extends Dh{constructor(t,e){super(t,Object.assign({},jg.defaultOptions,e)),this.drop=t=>ze(this,void 0,void 0,(function*(){const{targetType:e}=t;["combo","node"].includes(e)&&this.source?yield this.handleCreateEdge(t):yield this.cancelEdge()})),this.handleCreateEdge=t=>ze(this,void 0,void 0,(function*(){var e,n,r;if(!this.validate(t))return;const{graph:i,canvas:o,batch:a,element:s}=this.context,{style:l}=this.options;if(this.source)return this.createEdge(t),void(yield this.cancelEdge());a.startBatch(),o.setCursor("crosshair"),this.source=this.getSelectedNodeIDs([t.target.id])[0];const u=i.getElementData(this.source);i.addNodeData([{id:Ig,style:{visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}],x:null===(e=u.style)||void 0===e?void 0:e.x,y:null===(n=u.style)||void 0===n?void 0:n.y}}]),i.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:Ig,style:Object.assign({pointerEvents:"none"},l)}]),yield null===(r=s.draw({animation:!1}))||void 0===r?void 0:r.finished})),this.updateAssistEdge=t=>ze(this,void 0,void 0,(function*(){var e;if(!this.source)return;const{model:n,element:r}=this.context;n.translateNodeTo(Ig,[t.canvas.x,t.canvas.y]),yield null===(e=r.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished})),this.createEdge=t=>{var e,n;const{graph:r}=this.context,{style:i,onFinish:o,onCreate:a}=this.options;if(void 0===(null===(e=t.target)||void 0===e?void 0:e.id)||void 0===this.source)return;const s=null===(n=this.getSelectedNodeIDs([t.target.id]))||void 0===n?void 0:n[0];var l;const u=a({id:`${this.source}-${s}-${De[l=l||"g"]?De[l]+=1:De[l]=1,l+De[l]}`,source:this.source,target:s,style:i});r.addEdgeData([u]),o(u)},this.cancelEdge=()=>ze(this,void 0,void 0,(function*(){var t;if(!this.source)return;const{graph:e,element:n,batch:r}=this.context;e.removeNodeData([Ig]),this.source=void 0,yield null===(t=n.draw({animation:!1}))||void 0===t?void 0:t.finished,r.endBatch()})),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context,{trigger:n}=this.options;this.unbindEvents(),"click"===n?(e.on(t.NodeEvent.CLICK,this.handleCreateEdge),e.on(t.ComboEvent.CLICK,this.handleCreateEdge),e.on(t.CanvasEvent.CLICK,this.cancelEdge),e.on(t.EdgeEvent.CLICK,this.cancelEdge)):(e.on(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.on(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.on(t.CommonEvent.POINTER_UP,this.drop)),e.on(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.CLICK,this.handleCreateEdge),e.off(t.ComboEvent.CLICK,this.handleCreateEdge),e.off(t.CanvasEvent.CLICK,this.cancelEdge),e.off(t.EdgeEvent.CLICK,this.cancelEdge),e.off(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.off(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.off(t.CommonEvent.POINTER_UP,this.drop),e.off(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}destroy(){this.unbindEvents(),super.destroy()}}jg.defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};class Bg extends Dh{constructor(t,e){super(t,Object.assign({},Bg.defaultOptions,e)),this.isDragging=!1,this.onDragStart=t=>{this.validate(t)&&(this.isDragging=!0,this.context.canvas.setCursor("grabbing"))},this.onDrag=t=>{if(!this.isDragging)return;const{x:e,y:n}=t.movement;e|n&&this.translate([e,n],!1)},this.onDragEnd=()=>{var t,e;this.isDragging=!1,this.context.canvas.setCursor(this.defaultCursor),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)},this.invokeOnFinish=ye((()=>{var t,e;null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)}),300),this.shortcut=new gd(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(qt(e)){const{up:t=[],down:n=[],left:r=[],right:i=[]}=e;this.shortcut.bind(t,(t=>this.onTranslate([0,1],t))),this.shortcut.bind(n,(t=>this.onTranslate([0,-1],t))),this.shortcut.bind(r,(t=>this.onTranslate([1,0],t))),this.shortcut.bind(i,(t=>this.onTranslate([-1,0],t)))}else{const{graph:e}=this.context;e.on(t.CommonEvent.DRAG_START,this.onDragStart),e.on(t.CommonEvent.DRAG,this.onDrag),e.on(t.CommonEvent.DRAG_END,this.onDragEnd)}}onTranslate(t,e){return ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;yield this.translate(Bh(t,r),this.options.animation),this.invokeOnFinish()}))}translate(t,e){return ze(this,void 0,void 0,(function*(){t=this.clampByDirection(t),t=this.clampByRange(t),yield this.context.graph.translateBy(t,e)}))}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[a,s,l,u]=Yc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return"function"==typeof e?e(t):!!e}unbindEvents(){this.shortcut.unbindAll();const{graph:e}=this.context;e.off(t.CommonEvent.DRAG_START,this.onDragStart),e.off(t.CommonEvent.DRAG,this.onDrag),e.off(t.CommonEvent.DRAG_END,this.onDragEnd)}destroy(){this.shortcut.destroy(),this.unbindEvents(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}Bg.defaultOptions={enable:t=>!("targetType"in t)||"canvas"===t.targetType,sensitivity:10,direction:"both",range:1/0};class Fg extends Dh{constructor(e,n){super(e,Object.assign({},Fg.defaultOptions,n)),this.enable=!1,this.enableElements=["node","combo"],this.target=[],this.shadowOrigin=[0,0],this.hiddenEdges=[],this.isDragging=!1,this.onDrop=t=>ze(this,void 0,void 0,(function*(){var e;if("link"!==this.options.dropEffect)return;const{model:n,element:r}=this.context,i=t.target.id;this.target.forEach((t=>{const e=n.getParentData(t,Ec);e&&yh(e)===i&&n.refreshComboData(i),n.setParent(t,i,Ec)})),yield null===(e=null==r?void 0:r.draw({animation:!0}))||void 0===e?void 0:e.finished})),this.setCursor=e=>{if(this.isDragging)return;const{type:n}=e,{canvas:r}=this.context,{cursor:i}=this.options;n===t.CommonEvent.POINTER_ENTER?r.setCursor((null==i?void 0:i.grab)||"grab"):r.setCursor((null==i?void 0:i.default)||"default")},this.onDragStart=this.onDragStart.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onDrop=this.onDrop.bind(this),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.addEventListener("blur",this.onDragEnd),r.addEventListener("contextmenu",this.onDragEnd)),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),e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)})),["link"].includes(this.options.dropEffect)&&(e.on(t.ComboEvent.DROP,this.onDrop),e.on(t.CanvasEvent.DROP,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}getDelta(t){const e=this.context.graph.getZoom();return Fh([t.dx,t.dy],e)}onDragStart(t){var e;if(this.enable=this.validate(t),!this.enable)return;const{batch:n,canvas:r,graph:i}=this.context;r.setCursor((null===(e=this.options.cursor)||void 0===e?void 0:e.grabbing)||"grabbing"),this.isDragging=!0,n.startBatch();const o=t.target.id;i.getElementState(o).includes(this.options.state)?this.target=this.getSelectedNodeIDs([o]):this.target=[o],this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target)}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.options.shadow?this.moveShadow(e):this.moveElement(this.target,e)}onDragEnd(){var t,e,n;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]=jh([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t,this.target);const{batch:r,canvas:i}=this.context;r.endBatch(),i.setCursor((null===(n=this.options.cursor)||void 0===n?void 0:n.grab)||"grab"),this.isDragging=!1,this.target=[]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}moveElement(t,e){return ze(this,void 0,void 0,(function*(){const{graph:n,model:r}=this.context,{dropEffect:i}=this.options;"move"===i&&t.forEach((t=>r.refreshComboData(t))),n.translateElementBy(Object.fromEntries(t.map((t=>[t,e]))),!1)}))}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=Td(this.options,"shadow"),n=Jc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Xc(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr(Object.assign(Object.assign(Object.assign({},e),s),{visibility:"visible"})):(this.shadow=new Xl({style:Object.assign(Object.assign(Object.assign({$layer:"transient"},e),s),{pointerEvents:"none"})}),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(yh):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(yh))).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.removeEventListener("blur",this.onDragEnd),r.removeEventListener("contextmenu",this.onDragEnd)),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(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)})),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){var t;this.unbindEvents(),null===(t=this.shadow)||void 0===t||t.destroy(),super.destroy()}}Fg.defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),dropEffect:"move",state:"selected",hideEdge:"none",shadow:!1,shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5],cursor:{default:"default",grab:"grab",grabbing:"grabbing"}};var zg=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 Gg(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 Vg(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)&&Vg(i,e,n,r))return!0;return!1}const Wg=()=>!0;class Hg{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||Wg,n=t.edgeFilter||Wg;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];Gg([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];Vg(this.getNode(t),new Set,e,r)}}let Yg=class t extends zg{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((n=>{n.childrenMap.get(t)?.forEach((t=>{n.parentMap.delete(t.id)}));const r=n.parentMap.get(t);r&&n.childrenMap.get(r.id)?.delete(e),n.parentMap.delete(t),n.childrenMap.delete(t)})),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.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);if(!r)return;const i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(null==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 Vg(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Gg([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 Gg([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 Vg(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 Hg({graph:this,...t})}};class Ug{constructor(t,e){this.context=t,this.options=e||{}}}function $g(t){const{nodes:e,edges:n}=t,r={nodes:[],edges:[],combos:[]};return e.forEach((t=>{const e=t.data._isCombo?r.combos:r.nodes,{x:n,y:i,z:o=0}=t.data;null==e||e.push({id:t.id,style:{x:n,y:i,z:o}})})),n.forEach((t=>{const{id:e,source:n,target:i,data:{points:o=[],controlPoints:a=o.slice(1,o.length-1)}}=t;r.edges.push({id:e,source:n,target:i,style:Object.assign({},(null==a?void 0:a.length)?{controlPoints:a.map(ed)}:{})})})),r}function qg(t,e,...n){if(e in t)return t[e](...n);if("instance"in t){const r=t.instance;if(e in r)return r[e](...n)}return null}function Xg(t,e){if(e in t)return t[e];if("instance"in t){const n=t.instance;if(e in n)return n[e]}return null}class Kg extends Fg{get forceLayoutInstance(){return this.context.layout.getLayoutInstance().find((t=>["d3-force","d3-force-3d"].includes(null==t?void 0:t.id)))}validate(t){return!!this.context.layout&&(this.forceLayoutInstance?super.validate(t):(Tc("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}moveElement(t,e){return ze(this,void 0,void 0,(function*(){const n=this.forceLayoutInstance;this.context.graph.getNodeData(t).forEach(((r,i)=>{const{x:o=0,y:a=0}=r.style||{};n&&qg(n,"setFixedPosition",t[i],[...Ih([+o,+a],e)])}))}))}onDragStart(t){if(this.enable=this.validate(t),!this.enable)return;this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target);const e=this.forceLayoutInstance;e&&Xg(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach((t=>{const{x:n=0,y:r=0}=t.style||{};e&&qg(e,"setFixedPosition",yh(t),[+n,+r])}))}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.moveElement(this.target,e)}onDragEnd(){const t=this.forceLayoutInstance;t&&Xg(t,"simulation").alphaTarget(0),this.options.fixed||this.context.graph.getNodeData(this.target).forEach((e=>{t&&qg(t,"setFixedPosition",yh(e),[null,null,null])}))}}class Zg extends Dh{constructor(t,e){super(t,Object.assign({},Zg.defaultOptions,e)),this.isZoomEvent=t=>Boolean(t.data&&"scale"in t.data),this.relatedEdgeToUpdate=new Set,this.zoom=this.context.graph.getZoom(),this.fixElementSize=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{graph:e}=this.context,{state:n,nodeFilter:r,edgeFilter:i,comboFilter:o}=this.options,a=(n?e.getElementDataByState("node",n):e.getNodeData()).filter(r),s=(n?e.getElementDataByState("edge",n):e.getEdgeData()).filter(i),l=(n?e.getElementDataByState("combo",n):e.getComboData()).filter(o),u=this.isZoomEvent(t)?this.zoom=Math.max(.01,Math.min(t.data.scale,10)):this.zoom,c=[...a,...l];c.length>0&&c.forEach((t=>this.fixNodeLike(t,u))),this.updateRelatedEdges(),s.length>0&&s.forEach((t=>this.fixEdge(t,u)))})),this.cachedStyles=new Map,this.getOriginalFieldValue=(t,e,n)=>{var r;const i=this.cachedStyles.get(t)||[],o=(null===(r=i.find((t=>t.shape===e)))||void 0===r?void 0:r.style)||{};return n in o||(o[n]=e.attributes[n],this.cachedStyles.set(t,[...i.filter((t=>t.shape!==e)),{shape:e,style:o}])),o[n]},this.scaleEntireElement=(t,e,n)=>{e.setLocalScale(1/n);const r=this.cachedStyles.get(t)||[];r.push({shape:e}),this.cachedStyles.set(t,r)},this.scaleSpecificShapes=(t,e,n)=>{const r=function(t){const e=[],n=t=>{(null==t?void 0:t.children.length)&&t.children.forEach((t=>{e.push(t),n(t)}))};return n(t),e}(t);(Array.isArray(n)?n:[n]).forEach((n=>{const{shape:i,fields:o}=n,a="function"==typeof i?i(r):t.getShape(i);a&&(o?o.forEach((n=>{const r=this.getOriginalFieldValue(t.id,a,n);ae(r)&&(a.style[n]=r/e)})):this.scaleEntireElement(t.id,a,e))}))},this.skipIfExceedViewport=t=>{const{viewport:e}=this.context;return!(null==e?void 0:e.isInViewport(t.getRenderBounds(),!1,30))},this.fixNodeLike=(t,e)=>{const n=yh(t),{element:r,model:i}=this.context,o=r.getElement(n);if(!o||this.skipIfExceedViewport(o))return;i.getRelatedEdgesData(n).forEach((t=>this.relatedEdgeToUpdate.add(yh(t))));const a=this.options[o.type];a?this.scaleSpecificShapes(o,e,a):this.scaleEntireElement(n,o,e)},this.fixEdge=(t,e)=>{const n=yh(t),r=this.context.element.getElement(n);if(!r||this.skipIfExceedViewport(r))return;const i=this.options.edge;if(!i)return r.style.transformOrigin="center",void this.scaleEntireElement(n,r,e);this.scaleSpecificShapes(r,e,i)},this.updateRelatedEdges=()=>{const{element:t}=this.context;this.relatedEdgeToUpdate.size>0&&this.relatedEdgeToUpdate.forEach((e=>{const n=t.getElement(e);null==n||n.update({})})),this.relatedEdgeToUpdate.clear()},this.resetTransform=t=>ze(this,void 0,void 0,(function*(){var e;(null===(e=t.data)||void 0===e?void 0:e.firstRender)||(this.options.reset?this.restoreCachedStyles():this.fixElementSize({data:{scale:this.zoom}}))})),this.bindEvents()}restoreCachedStyles(){if(this.cachedStyles.size>0){this.cachedStyles.forEach((t=>{t.forEach((({shape:t,style:e})=>{if(Se(e))t.setLocalScale(1);else{if(this.options.state)return;Object.entries(e).forEach((([e,n])=>t.style[e]=n))}}))}));const{graph:t,element:e}=this.context,n=Object.keys(Object.fromEntries(this.cachedStyles)).filter((e=>e&&"node"===t.getElementType(e)));if(n.length>0){const r=new Set;n.forEach((e=>{t.getRelatedEdgesData(e).forEach((t=>r.add(yh(t))))})),r.forEach((t=>{const n=null==e?void 0:e.getElement(t);null==n||n.update({})}))}}}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.on(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.off(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Zg.defaultOptions={enable:t=>t.data.scale<1,nodeFilter:()=>!0,edgeFilter:()=>!0,comboFilter:()=>!0,edge:[{shape:"key",fields:["lineWidth"]},{shape:"halo",fields:["lineWidth"]},{shape:"label"}],reset:!1};class Qg extends Dh{constructor(t,e){super(t,Object.assign({},Qg.defaultOptions,e)),this.focus=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{graph:e}=this.context;yield e.focusElement(t.target.id,this.options.animation)})),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),bd.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;bd.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}destroy(){this.unbindEvents(),super.destroy()}}Qg.defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};class Jg extends Dh{constructor(e,n){super(e,Object.assign({},Jg.defaultOptions,n)),this.isFrozen=!1,this.toggleFrozen=t=>{this.isFrozen="dragstart"===t.type},this.hoverElement=e=>{if(!this.validate(e))return;const n=e.type===t.CommonEvent.POINTER_ENTER;this.updateElementsState(e,n);const{onHover:r,onHoverEnd:i}=this.options;n?null==r||r(e):null==i||i(e)},this.updateElementsState=(t,e)=>{if(!this.options.state&&!this.options.inactiveState)return;const{graph:n}=this.context,{state:r,animation:i,inactiveState:o}=this.options,a=this.getActiveIds(t),s={};if(r&&Object.assign(s,this.getElementsState(a,r,e)),o){const t=xh(n.getData(),!0).filter((t=>!a.includes(t)));Object.assign(s,this.getElementsState(t,o,e))}n.setElementState(s,i)},this.getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach((t=>{const o=r.getElementState(t);i[t]=n?o.includes(e)?o:[...o,e]:o.filter((t=>t!==e))})),i},this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),bd.forEach((n=>{e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)}));const n=this.context.canvas.document;n.addEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.addEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}getActiveIds(t){const{graph:e}=this.context,{degree:n,direction:r}=this.options,i=t.target.id;return n?Ed(e,t.targetType,i,"function"==typeof n?n(t):n,r):[i]}validate(t){if(this.destroyed||this.isFrozen||Lg(t.target)||this.context.graph.isCollapsingExpanding)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;bd.forEach((n=>{e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)}));const n=this.context.canvas.document;n.removeEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.removeEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}destroy(){this.unbindEvents(),super.destroy()}}Jg.defaultOptions={animation:!1,enable:!0,degree:0,direction:"both",state:"active",inactiveState:void 0};class tv extends vd{onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e}=this.context;this.pathShape=new Hl({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[md(t)]}onPointerMove(t){var e;if(!this.points)return;const{immediately:n,mode:r}=this.options;this.points.push(md(t)),null===(e=this.pathShape)||void 0===e||e.setAttribute("d",function(t,e=!0){const n=[];return t.forEach(((t,e)=>{n.push([0===e?"M":"L",...t])})),e&&n.push(["Z"]),n}(this.points)),n&&"default"===r&&this.points.length>2&&super.updateElementsStates(this.points)}onPointerUp(){this.points&&(this.points.length<2||super.updateElementsStates(this.points),this.clearLasso())}clearLasso(){var t;null===(t=this.pathShape)||void 0===t||t.remove(),this.pathShape=void 0,this.points=void 0}}class ev extends Dh{constructor(t,e){super(t,Object.assign({},ev.defaultOptions,e)),this.hiddenShapes=[],this.isVisible=!0,this.setElementsVisibility=(t,e,n)=>{t.filter(Boolean).forEach((t=>{"hidden"!==e||t.isVisible()?"visible"===e&&this.hiddenShapes.includes(t)?this.hiddenShapes.splice(this.hiddenShapes.indexOf(t),1):Ch(t,e,n):this.hiddenShapes.push(t)}))},this.filterShapes=(t,e)=>{if(Yt(e))return n=>!e(t,n);const n=null==e?void 0:e[t];return t=>!t.className||!(null==n?void 0:n.includes(t.className))},this.hideShapes=t=>{if(!this.validate(t)||!this.isVisible)return;const{element:e}=this.context,{shapes:n={}}=this.options;this.setElementsVisibility(e.getNodes(),"hidden",this.filterShapes("node",n)),this.setElementsVisibility(e.getEdges(),"hidden",this.filterShapes("edge",n)),this.setElementsVisibility(e.getCombos(),"hidden",this.filterShapes("combo",n)),this.isVisible=!1},this.showShapes=ye((t=>{if(!this.validate(t)||this.isVisible)return;const{element:e}=this.context;this.setElementsVisibility(e.getNodes(),"visible"),this.setElementsVisibility(e.getEdges(),"visible"),this.setElementsVisibility(e.getCombos(),"visible"),this.isVisible=!0}),this.options.debounce),this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.on(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.off(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}ev.defaultOptions={enable:!0,debounce:200,shapes:t=>"node"===t};class nv extends Dh{constructor(t,e){super(t,Object.assign({},nv.defaultOptions,e)),this.onWheel=t=>ze(this,void 0,void 0,(function*(){this.options.preventDefault&&t.preventDefault();const e=t.deltaX,n=t.deltaY;yield this.scroll([-e,-n],t)})),this.shortcut=new gd(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e,n;const{trigger:r}=this.options;if(this.shortcut.unbindAll(),qt(r)){null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel);const{up:n=[],down:i=[],left:o=[],right:a=[]}=r;this.shortcut.bind(n,(t=>this.scroll([0,-10],t))),this.shortcut.bind(i,(t=>this.scroll([0,10],t))),this.shortcut.bind(o,(t=>this.scroll([-10,0],t))),this.shortcut.bind(a,(t=>this.scroll([10,0],t)))}else null===(n=this.graphDom)||void 0===n||n.addEventListener(t.CommonEvent.WHEEL,this.onWheel,{passive:!1})}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}formatDisplacement(t){const{sensitivity:e}=this.options;return t=Bh(t,e),t=this.clampByDirection(t),t=this.clampByRange(t)}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[a,s,l,u]=Yc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}scroll(t,e){return ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{onFinish:n}=this.options,r=this.context.graph,i=this.formatDisplacement(t);yield r.translateBy(i,!1),null==n||n()}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel),super.destroy()}}nv.defaultOptions={enable:!0,sensitivity:1,preventDefault:!0,range:1/0};class rv extends Dh{constructor(t,e){super(t,Object.assign({},rv.defaultOptions,e)),this.zoom=(t,e,n)=>ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{graph:r}=this.context;let i;"viewport"in e&&(i=ed(e.viewport));const{sensitivity:o,onFinish:a}=this.options,s=1+oe(t,-50,50)*o/100,l=r.getZoom();yield r.zoomTo(l*s,n,i),null==a||a()})),this.onReset=()=>ze(this,void 0,void 0,(function*(){yield this.context.graph.zoomTo(1,this.options.animation)})),this.preventDefault=t=>{this.options.preventDefault&&t.preventDefault()},this.shortcut=new gd(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e;const{trigger:n}=this.options;if(this.shortcut.unbindAll(),Array.isArray(n)&&(null===(e=this.context.canvas.getContainer())||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,this.preventDefault),this.shortcut.bind([...n,t.CommonEvent.WHEEL],(t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(null!=n?n:e),t,!1)}))),"object"==typeof n){const{zoomIn:t=[],zoomOut:e=[],reset:r=[]}=n;this.shortcut.bind(t,(t=>this.zoom(10,t,this.options.animation))),this.shortcut.bind(e,(t=>this.zoom(-10,t,this.options.animation))),this.shortcut.bind(r,this.onReset)}}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Yt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.context.canvas.getContainer())||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.preventDefault),super.destroy()}}rv.defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[],preventDefault:!0};var iv={assign:Object.assign,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},ov=iv,av={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 sv(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof sv)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}ov.assign(sv.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 lv=function(t,e,n){void 0===e&&(e={});var r,i=new sv(t,e=ov.assign({},av,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 l=0;l<s;l++){var u=new sv(a[l],e);r.children[l]=u,o.push(u),u.parent=r,u.depth=r.depth+1}}return i},uv=lv,cv=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=uv(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),hv=cv;function dv(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 fv(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){fv(t,e,n)}))}function pv(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(pv(t,e),n)})),n}function gv(t,e){fv(t,-pv(t,e),e)}function vv(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){vv(t,e.children[r],n)}))}function mv(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){mv(t,e,n)}))}dv.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(dv.fromNode(t,e))})),e?new dv(t.height,t.width,t.x,n):new dv(t.width,t.height,t.y,n)};var yv=lv,bv=function(t,e){for(var n=yv(t.data,e,!0),r=yv(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 l=t.children[s];"right"===a(l,s)?r.children.push(l):n.children.push(l)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},xv=bv,Ev=["LR","RL","TB","BT","H","V"],wv=["LR","RL","H"],kv=Ev[0],Mv=function(t,e,n){var r=e.direction||kv;if(e.isHorizontal=function(t){return wv.indexOf(t)>-1}(r),-1===Ev.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===Ev[0])n(t,e);else if(r===Ev[1])n(t,e),t.right2left();else if(r===Ev[2])n(t,e);else if(r===Ev[3])n(t,e),t.bottom2top();else if(r===Ev[4]||r===Ev[5]){var i=xv(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 l=e.fixedRoot;return void 0===l&&(l=!0),l&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){var n=e.isHorizontal?["x","y"]:["y","x"],r=n[0],i=n[1],o={x:1/0,y:1/0},a={x:-1/0,y:-1/0},s=0;t.DFTraverse((function(t){s++;var e=t.x,n=t.y;o.x=Math.min(o.x,e),o.y=Math.min(o.y,n),a.x=Math.max(a.x,e),a.y=Math.max(a.y,n)}));var l=a[i]-o[i];if(0===l)return;var u=2*Math.PI/s;t.DFTraverse((function(e){var n=(e[i]-o[i])/l*(2*Math.PI-u)+u,a=e[r]-t[r];e.x=Math.cos(n)*a,e.y=Math.sin(n)*a}))}}(t,e),t};function Sv(t,e){return Sv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Sv(t,e)}var Nv=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,u=t.c[e],c=u.mod;null!==r&&null!==u;){l(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(c+u.prelim);h>0&&(c+=h,o(t,e,n.index,h));var d=l(r),f=l(u);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(u=a(u))&&(c+=u.mod)}!r&&u?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,u,c):r&&!u&&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 l(t){return t.y+t.h}function u(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}mv(t,n);var c=dv.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=u(l(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=l(e.c[o].er);i(e,o,n),n=u(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)}(c),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)}(c,0),vv(c,t,n),gv(t,n),t},Ov=Mv,Tv=iv,Av=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Sv(n,r),e.prototype.execute=function(){return Ov(this.rootNode,this.options,Nv)},e}(hv),Cv={};var Pv=function(t,e){return e=Tv.assign({},Cv,e),new Av(t,e).execute()},Rv=iv;function Dv(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 Lv={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function _v(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){_v(t,e.children[r],n)}))}function Iv(t,e){return Iv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Iv(t,e)}var jv=function(t,e){void 0===e&&(e={}),e=Rv.assign({},Lv,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 Dv(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),_v(i,t,e.isHorizontal),t},Bv=Mv,Fv=iv,zv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Iv(n,r),e.prototype.execute=function(){var t=this;return t.rootNode.width=0,Bv(t.rootNode,t.options,jv)},e}(hv),Gv={};var Vv=function(t,e){return e=Fv.assign({},Gv,e),new zv(t,e).execute()},Wv=iv;function Hv(t,e){return Hv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Hv(t,e)}var Yv=hv,Uv=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+Wv.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+Wv.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},$v=bv,qv=iv,Xv=["LR","RL","H"],Kv=Xv[0],Zv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Hv(n,r),e.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?Kv:a,l=t.align;if(s&&-1===Xv.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Xv[0])Uv(e,r,o,l);else if(s===Xv[1])Uv(e,r,o,l),e.right2left();else if(s===Xv[2]){var u=$v(e,t),c=u.left,h=u.right;Uv(c,r,o,l),c.right2left(),Uv(h,r,o,l);var d=c.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},e}(Yv),Qv={};var Jv=function(t,e){return e=qv.assign({},Qv,e),new Zv(t,e).execute()},tm=iv;function em(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=em(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function nm(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){nm(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 rm={getSubTreeSep:function(){return 0}};function im(t,e){return im=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},im(t,e)}var om=function(t,e){void 0===e&&(e={}),e=tm.assign({},rm,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,em(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}}}})),nm(t)},am=Mv,sm=iv,lm=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,im(n,r),e.prototype.execute=function(){return am(this.rootNode,this.options,om)},e}(hv),um={};var cm=function(t,e){return e=sm.assign({},um,e),new lm(t,e).execute()},hm={compactBox:Pv,dendrogram:Vv,indented:Jv,mindmap:cm};const dm=(t,e)=>{if("next"!==t&&"prev"!==t)return e},fm=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let pm=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 fm(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&fm(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,dm)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},gm=class extends pm{};const vm=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)mm(t,e,n,a);for(;a=i.dequeue();)mm(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(mm(t,e,n,a,!0));break}}return r},mm=(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,bm(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,bm(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},ym=(t,e)=>{const n=new Yg;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 gm);const s=r+1;return n.getAllNodes().forEach((t=>{bm(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},bm=(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)},xm=(t,e)=>{const n="greedy"===e?((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=ym(t,e);return null===(n=vm(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)):Em(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)})}))},Em=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},wm=(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},km=t=>{const e=new Yg;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},Mm=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let a,s,l=Number(t.width)/2,u=Number(t.height)/2;return i||o?(Math.abs(o)*l>Math.abs(i)*u?(o<0&&(u=-u),a=u*i/o,s=u):(i<0&&(l=-l),a=l,s=l*o/i),{x:n+a,y:r+s}):{x:0,y:0}},Sm=t=>{const e=[],n=Om(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},Nm=(t,e,n,r)=>{const i={width:0,height:0};return ae(n)&&ae(r)&&(i.rank=n,i.order=r),wm(t,"border",i,e)},Om=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},Tm=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),Am=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>Am(t,e,n,r,i,o))),n&&o.push(e.id))},Cm=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>t.getNeighbors(e),a=[],s=[];return i.forEach((e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);Am(t,e,"post"===n,s,o,a)})),a},Pm=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],l=wm(t,"border",a,n);i.data[e][o]=l,t.setParent(l,r),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:l,data:{weight:1}})},Rm=t=>{t.getAllNodes().forEach((t=>{Dm(t)})),t.getAllEdges().forEach((t=>{Dm(t)}))},Dm=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},Lm=t=>{t.getAllNodes().forEach((t=>{_m(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>_m(t))),t.data.hasOwnProperty("y")&&_m(t.data)}))},_m=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},Im=t=>{t.getAllNodes().forEach((t=>{jm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>jm(t))),t.data.hasOwnProperty("x")&&jm(t.data)}))},jm=t=>{const e=t.x;t.x=t.y,t.y=e},Bm=(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 l=Nm(t,"_bt"),u=Nm(t,"_bb"),c=t.getNode(a);t.setParent(l,a),c.data.borderTop=l,t.setParent(u,a),c.data.borderBottom=u,null==s||s.forEach((s=>{Bm(t,e,n,r,i,o,s.id);const c=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=c!==h?1:i-o[a]+1;t.addEdge({id:`e${Math.random()}`,source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:h,target:u,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:l,data:{weight:0,minlen:i+o[a]}})},Fm=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},zm=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Gm="edge-label",Vm=(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 l,u,c;for(t.removeEdge(e.id),c=0,++i;i<a;++c,++i)e.data.points=[],u={originalEdge:e,width:0,height:0,rank:i},l=wm(t,"edge",u,"_d"),i===s&&(u.width=e.data.width,u.height=e.data.height,u.dummy=Gm,u.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:l,data:{weight:e.data.weight}}),0===c&&n.push(l),r=l;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},Wm=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},Hm=(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 l=Array(s).fill(0,0,s);let u=0;return null==o||o.forEach((t=>{if(t){let e=t.pos+a;l[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=l[e+1]),e=e-1>>1,l[e]+=t.weight;u+=t.weight*n}})),u},Ym=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=Hm(t,e[r-1],e[r]);return n},Um=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},$m=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)&&qm(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}))},qm=(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},Xm=(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},Km=(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},Zm=(t,e,n,r,i,o)=>{var a,s,l,u;let c=t.getChildren(e).map((t=>t.id));const h=t.getNode(e),d=h?h.data.borderLeft:void 0,f=h?h.data.borderRight:void 0,p={};d&&(c=null==c?void 0:c.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,c||[]);null==g||g.forEach((e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=Zm(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&Jm(e,i)}}));const v=((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 $m(a)})(g,n);Qm(v,p),null===(a=v.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 m=((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 l=0,u=0,c=0;null==o||o.sort(Km(!!e,!!n)),c=Xm(s,a,c),null==o||o.forEach((t=>{var e;c+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),l+=t.barycenter*t.weight,u+=t.weight,c=Xm(s,a,c)}));const h={vs:s.flat()};return u&&(h.barycenter=l/u,h.weight=u),h})(v,r,i,o);if(d&&(m.vs=[d,m.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){const e=t.getNode((null===(l=t.getPredecessors(d))||void 0===l?void 0:l[0].id)||""),n=t.getNode((null===(u=t.getPredecessors(f))||void 0===u?void 0:u[0].id)||"");m.hasOwnProperty("barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+e.data.order+n.data.order)/(m.weight+2),m.weight+=2}return m},Qm=(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()}))},Jm=(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)},ty=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Wm(t),i=new Yg({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))),ey=(t,e,n,r)=>{const i=new Yg;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Zm(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)}))},ny=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,n)=>{t.getNode(e).data.order=n}))}))},ry=(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 l=((t,e,n,r)=>{var i,o;const a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);let c,h;c=n;do{c=null===(i=t.getParent(c))||void 0===i?void 0:i.id,a.push(c)}while(c&&(e[c].low>l||u>e[c].lim));for(h=c,c=r;c&&c!==h;)s.push(c),c=null===(o=t.getParent(c))||void 0===o?void 0:o.id;return{lca:h,path:a.concat(s.reverse())}})(t,n,s.source,s.target),u=l.path,c=l.lca;let h=0,d=u[h],f=!0;for(;o!==s.target;){if(a=t.getNode(o),f){for(;d!==c&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)h++,d=u[h];d===c&&(f=!1)}if(!f){for(;h<u.length-1&&(null===(i=t.getNode(u[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=u[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},iy=(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,l;let u;for(let c=r;c<i;c++)u=e[c],(null===(s=t.getNode(u))||void 0===s?void 0:s.data.dummy)&&(null===(l=t.getPredecessors(u))||void 0===l||l.forEach((e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&ay(n,e.id,u)})))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,a=0;const s=new Map;return null==n||n.forEach(((l,u)=>{var c;if("border"===(null===(c=t.getNode(l))||void 0===c?void 0:c.data.dummy)){const e=t.getPredecessors(l)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,a,u,o,i],s),a=u,o=i)}r([n,a,n.length,i,e.length],s)})),n};return(null==e?void 0:e.length)&&e.reduce(i),n},oy=(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))},ay=(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},sy=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},ly=(t,e,n,r,i,o)=>{const a=new Yg,s=uy(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],l=a.getRelatedEdges(o,"out").find((t=>t.target===i));l?a.updateEdgeData(l.id,Object.assign(Object.assign({},l.data),{weight:Math.max(s(t,e,r),l.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 uy=(t,e,n)=>(r,i,o)=>{const a=r.getNode(i),s=r.getNode(o);let l=0,u=0;if(l+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":u=-a.data.width/2;break;case"r":u=a.data.width/2}if(u&&(l+=n?u:-u),u=0,l+=(a.data.dummy?e:t)/2,l+=(s.data.dummy?e:t)/2,l+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":u=s.data.width/2;break;case"r":u=-s.data.width/2}return u&&(l+=n?u:-u),u=0,l},cy=(t,e)=>t.getNode(e).data.width||0,hy=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e,o=Sm(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,l)=>{var u;const c=oy(t,e),h=c?t.getNode(c.id).data.order:a;(c||e===s)&&(null===(u=r.slice(o,l+1))||void 0===u||u.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||h<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||ay(n,r.id,e)}))})),o=l+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),iy(t,o)),s={};let l=[];["u","d"].forEach((e=>{l="u"===e?o:Object.values(o).reverse(),["l","r"].forEach((n=>{"r"===n&&(l=l.map((t=>Object.values(t).reverse())));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),u=((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 l=Math.floor(r),u=Math.ceil(r);l<=u;++l){const r=s[l];o[t]===t&&e<a[r]&&!sy(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=a[r])}}}))})),{root:i,align:o}})(0,l,a,o),c=((t,e,n,r,i,o,a)=>{var s;const l={},u=ly(t,e,n,i,o,a),c=a?"borderLeft":"borderRight",h=(t,e)=>{let n=u.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 h((t=>{l[t]=(u.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(l[e.source]||0)+e.data.weight)),0)}),u.getPredecessors.bind(u)),h((e=>{const n=(u.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(l[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==c&&(l[e]=Math.max(l[e],n))}),u.getSuccessors.bind(u)),null===(s=Object.values(r))||void 0===s||s.forEach((t=>{l[t]=l[n[t]]})),l})(t,l,u.root,u.align,r,i,"r"===n);"r"===n&&Object.keys(c).forEach((t=>c[t]=-c[t])),s[e+n]=c}))}));const u=((t,e)=>Tm(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=cy(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i})))(t,s);return u&&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 l;if(s===e)return;const u=Object.values(s);l="l"===o?r-Math.min(...u):i-Math.max(...u),l&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+l})))}))}))}(s,u),((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)},dy=(t,e)=>{var n;const r=km(t);((t,e)=>{const{ranksep:n=0}=e,r=Sm(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=hy(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},fy=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)))},py=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,gy=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||py(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},vy=(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&&py(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},my=(t,e)=>Tm(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?py(e,n):1/0)),yy=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},by=t=>{const e=(t=>{const e=new Yg;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);fy(e);const n=(t=>{const e=new Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);gy(e,t)<r;)i=my(e,t),o=e.hasNode(i.source)?py(t,i):-py(t,i),yy(e,t,o);return e})(e);let r,i;for(ky(n),xy(n,e);r=Sy(n);)i=Ny(n,e,r),Oy(n,e,r,i)},xy=(t,e)=>{let n=Cm(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{Ey(t,e,n)}))},Ey=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=wy(t,e,n)},wy=(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,l=e.data.weight;if(a+=r?l:-l,Ay(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},ky=(t,e=t.getAllNodes()[0].id)=>{My(t,{},1,e)},My=(t,e,n,r,i)=>{var o;const a=n;let s=n;const l=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((n=>{e[n.id]||(s=My(t,e,s,n.id,r))})),l.data.low=a,l.data.lim=s++,i?l.data.parent=i:delete l.data.parent,s},Sy=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),Ny=(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,l=!1;o.data.lim>a.data.lim&&(s=a,l=!0);const u=e.getAllEdges().filter((e=>l===Cy(t.getNode(e.source),s)&&l!==Cy(t.getNode(e.target),s)));return Tm(u,(t=>py(e,t)))},Oy=(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:{}}),ky(t),xy(t,e),Ty(t,e)},Ty=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=Cm(t,n,"pre");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))}))},Ay=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),Cy=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,Py=fy,Ry=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 Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);vy(e,t)<r;)i=my(e,t),o=e.hasNode(i.source)?py(t,i):-py(t,i),yy(e,t,o)})(t)},Dy=t=>{by(t)},Ly=(t,e)=>{const{acyclicer:n,ranker:r,rankdir:i="tb",nodeOrder:o,keepNodeOrder:a,align:s,nodesep:l=50,edgesep:u=20,ranksep:c=50}=e;Qy(t),xm(t,n);const{nestingRoot:h,nodeRankFactor:d}=(t=>{const e=wm(t,"root",{},"_root"),n=Fm(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=zm(t)+1;return t.getRoots().forEach((r=>{Bm(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":Dy(t);break;case"tight-tree":default:Ry(t);break;case"longest-path":Py(t)}})(km(t),r),Hy(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,h),(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),Yy(t),Uy(t);const f=[];((t,e)=>{t.getAllEdges().forEach((n=>Vm(t,n,e)))})(t,f),ry(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)Pm(t,"borderLeft","_bl",n,i,e),Pm(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)})).map((t=>t.data.rank)),r=Math.max(...n),i=[];for(let t=0;t<r+1;t++)i[t]=[];null==e||e.forEach((e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=i[n.data.rank].length,i[n.data.rank].push(e)))}))})(t,o),((t,e)=>{const n=Om(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=ty(t,r,"in"),a=ty(t,i,"out");let s=Um(t);ny(t,s);let l,u=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){ey(n%2?o:a,n%4>=2,!1,e),s=Sm(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}s=Um(t),ny(t,s);for(let n=0,r=0;r<4;++n,++r){ey(n%2?o:a,n%4>=2,!0,e),s=Sm(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}ny(t,l)})(t,a),Jy(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||Rm(t)})(t,i),dy(t,{align:s,nodesep:l,edgesep:u,ranksep:c}),tb(t),Zy(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===Gm&&(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),Xy(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||Lm(t),"lr"!==n&&"rl"!==n||(Im(t),Rm(t))})(t,i);const{width:p,height:g}=$y(t);return qy(t),Ky(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}},_y=(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}))},Iy=(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)}))},jy=["width","height","layer","fixorder"],By={width:0,height:0},Fy=["minlen","weight","width","height","labeloffset"],zy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Gy=["labelpos"],Vy=t=>{const e=new Yg({tree:[]});return t.getAllNodes().forEach((n=>{const r=nb(t.getNode(n.id).data),i=Object.assign(Object.assign({},By),r),o=eb(i,jy);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);Ut(a)||(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((n=>{const r=nb(t.getEdge(n.id).data),i={};null==Gy||Gy.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},zy,eb(r,Fy),i)})})),e},Wy=(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},Hy=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};wm(t,"edge-proxy",r,"_ep")}}))},Yy=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},Uy=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))}))},$y=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}={},l=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,l=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(l)||(void 0===r&&(r=a-l/2),r=Math.min(r,a-l/2),o=Math.max(o,a+l/2))};return t.getAllNodes().forEach((t=>{l(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&l(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}},qy=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(Mm(n.data,i)),e.data.points.push(Mm(r.data,o))}))},Xy=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}}))},Ky=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Zy=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]),l=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==l?void 0:l.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)}))},Qy=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)}}))},Jy=t=>{const e=Sm(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=>{wm(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},tb=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}}))},eb=(t,e)=>{const n={};return null==e||e.forEach((e=>{void 0!==t[e]&&(n[e]=+t[e])})),n},nb=(t={})=>{const e={};return Object.keys(t).forEach((n=>{e[n.toLowerCase()]=t[n]})),e},rb=Array.isArray,ib=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},ob=(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:e,target:n}=t,r=o[e],a=o[n];void 0!==r&&void 0!==a&&(i[r][a]=1,i[a][r]=1)})),i},ab=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),sb=(t,e,n,r="TB",i,o={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=o;for(let l=0;l<e.length;l++){const u=e[l];if(t.hasNode(u.id)&&!(null==a?void 0:a(u))){if(null==s?void 0:s(u))return;"TB"===r&&n(u),sb(t,t.getChildren(u.id,i),n,r,i,o),"TB"!==r&&n(u)}}},lb=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=>lb(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=lb(t[n])})),e}return t},ub=(t,e)=>{const n=lb(t);return n.data=n.data||{},e&&(ae(n.data.x)||(n.data.x=Math.random()*e[0]),ae(n.data.y)||(n.data.y=Math.random()*e[1])),n};function cb(t){if(!t)return[0,0,0];if(ae(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}function hb(t,e){let n;return n=Yt(e)?e:ae(e)?()=>e:()=>t,n}function db(t,e,n=!0){return e||0===e?Yt(e)?e:ae(e)?()=>e:Array.isArray(e)?()=>n?Math.max(...e)||t:e:qt(e)&&e.width&&e.height?()=>n?Math.max(e.width,e.height)||t:[e.width,e.height]:()=>t:e=>{const{size:r}=e.data||{};return r?Array.isArray(r)?n?Math.max(...r)||t:r:qt(r)&&r.width&&r.height?n?Math.max(r.width,r.height)||t:[r.width,r.height]:r:t}}const fb=(t,e,n=10)=>{let r;const i="function"==typeof e?e:()=>e||0;r=t?Array.isArray(t)?e=>t:Yt(t)?t:e=>t:t=>{var e,r,i;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return null===(r=t.data)||void 0===r?void 0:r.bboxSize;if(null===(i=t.data)||void 0===i?void 0:i.size){const e=t.data.size;return Array.isArray(e)?e:qt(e)?[e.width,e.height]:e}return n};return t=>{const e=r(t),n=i(t);return Math.max(...cb(e))+n}},pb={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class gb{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},pb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,e)}))}genericDagreLayout(t,e,n){return ze(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:l,ranksepFunc:u,nodesepFunc:c,edgeLabelSpace:h,ranker:d,nodeOrder:f,begin:p,controlPoints:g,radial:v,sortByCombo:m,preset:y}=r,b=new Yg({tree:[]}),x=hb(s||50,u),E=hb(l||50,c);let w=E,k=x;"LR"!==a&&"RL"!==a||(w=x,k=E);const M=db(10,i,!1),S=e.getAllNodes(),N=e.getAllEdges();let O;S.forEach((t=>{const e=cb(M(t)),n=k(t),r=w(t),i=e[0]+2*r,o=e[1]+2*n,a=t.data.layer;ae(a)?b.addNode({id:t.id,data:{width:i,height:o,layer:a}}):b.addNode({id:t.id,data:{width:i,height:o}})})),m&&(b.attachTreeStructure("combo"),S.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}))),N.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)&&(O=new Yg({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&_y(t,i);const s=Vy(t);let l;n&&(e.ranksep=Wy(s,{rankdir:o,ranksep:a}));try{l=Ly(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}Iy(t,s)})(b,{prevGraph:O,edgeLabelSpace:h,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:l,align:o});const T=[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)}))})),T[0]=p[0]-t,T[1]=p[1]-e}const A="LR"===a||"RL"===a;if(v);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+T[0],e.data.y=e.data.y+T[1],t.add(A?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=A?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=A?(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;h&&g&&"loop"!==t.data.type&&(t.data.controlPoints=vb(null===(o=t.data.points)||void 0===o?void 0:o.map((({x:t,y:e})=>({x:t+T[0],y:e+T[1]}))),b.getNode(t.source),b.getNode(t.target),n,A,r,i))}))}let C=[];C=b.getAllNodes().map((t=>ub(t)));const P=b.getAllEdges();t&&(C.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),P.forEach((t=>{e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:C,edges:P}}))}}const vb=(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:l}=e.data,{x:u,y:c}=n.data;if(i&&(t=e.data.y,l=e.data.x,u=n.data.y,c=n.data.x),c!==l&&t!==u){const h=r.indexOf(l),d=r[h+1];if(d){const t=s[0],e=i?{x:(l+d)/2,y:(null==t?void 0:t.y)||u}:{x:(null==t?void 0:t.x)||u,y:(l+d)/2};t&&!o(t,e)||s.unshift(e)}const f=r.indexOf(c),p=Math.abs(f-h);if(1===p)s=a(s,e.data,n.data),s.length||s.push(i?{x:(l+c)/2,y:t}:{x:t,y:(l+c)/2});else if(p>1){const e=r[f-1];if(e){const n=s[s.length-1],r=i?{x:(c+e)/2,y:(null==n?void 0:n.y)||u}:{x:(null==n?void 0:n.x)||t,y:(c+e)/2};n&&!o(n,r)||s.push(r)}}}}return s},mb=(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}}},yb={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class bb{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},yb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,e)}))}genericCircularLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,divisions:s,startAngle:l=0,endAngle:u=2*Math.PI,angleRatio:c,ordering:h,clockwise:d,nodeSpacing:f,nodeSize:p}=r,g=e.getAllNodes(),v=e.getAllEdges(),[m,y,b]=Eb(i,o,a),x=null==g?void 0:g.length;if(!x||1===x)return mb(e,t,b);const E=(u-l)/x;let{radius:w,startRadius:k,endRadius:M}=r;if(f){const t=hb(10,f),e=db(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)})),w=r/(2*Math.PI)}else w||k||M?!k&&M?k=M:k&&!M&&(M=k):w=Math.min(y,m)/2;const S=E*c;let N=[];N="topology"===h?xb(e,g):"topology-directed"===h?xb(e,g,!0):"degree"===h?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(ub(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>ub(t)));const O=Math.ceil(x/s);for(let t=0;t<x;++t){let e=w;e||null===k||null===M||(e=k+t*(M-k)/(x-1)),e||(e=10+100*t/(x-1));let n=l+t%O*S+2*Math.PI/s*Math.floor(t/O);d||(n=u-t%O*S-2*Math.PI/s*Math.floor(t/O)),N[t].data.x=b[0]+Math.cos(n)*e,N[t].data.y=b[1]+Math.sin(n)*e}t&&N.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:N,edges:v}}))}}const xb=(t,e,n=!1)=>{const r=[ub(e[0])],i={},o=e.length;i[e[0].id]=!0;let a=0;return e.forEach(((s,l)=>{if(0!==l)if(l!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[l+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){const l=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id);let u=!1;for(let e=0;e<l.length;e++){const n=l[e];if(t.getDegree(n.id)===t.getDegree(s.id)&&!i[n.id]){r.push(ub(n)),i[n.id]=!0,u=!0;break}}let c=0;for(;!u&&(i[e[c].id]||(r.push(ub(e[c])),i[e[c].id]=!0,u=!0),c++,c!==o););}else r.push(ub(s)),i[s.id]=!0,a++})),r};const Eb=(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]},wb={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class kb{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},wb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericConcentricLayout(!0,t,e)}))}genericConcentricLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a,sortBy:s,maxLevelDiff:l,sweep:u,clockwise:c,equidistant:h,preventOverlap:d,startAngle:f=1.5*Math.PI,nodeSize:p,nodeSpacing:g}=r,v=e.getAllNodes(),m=e.getAllEdges(),y=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,x=i||[y/2,b/2];if(!(null==v?void 0:v.length)||1===v.length)return mb(e,t,x);const E=[];let w,k=0;rb(p)?w=Math.max(p[0],p[1]):Yt(p)?(w=-1/0,v.forEach((t=>{const e=Math.max(...cb(p(t)));e>w&&(w=e)}))):w=p,rb(g)?k=Math.max(g[0],g[1]):ae(g)&&(k=g),v.forEach((t=>{const e=ub(t);E.push(e);let n=w;const{data:r}=e;rb(r.size)?n=Math.max(r.size[0],r.size[1]):ae(r.size)?n=r.size:qt(r.size)&&(n=Math.max(r.size.width,r.size.height)),w=Math.max(w,n),Yt(g)&&(k=Math.max(g(t),k))}));const M={};E.forEach(((t,e)=>{M[t.id]=e}));let S=s;ne(S)&&void 0!==E[0].data[S]||(S="degree"),"degree"===S?E.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):E.sort(((t,e)=>e.data[S]-t.data[S]));const N=E[0],O=(l||("degree"===S?e.getDegree(N.id,"both"):N.data[S]))/4,T=[{nodes:[]}];let A=T[0];E.forEach((t=>{if(A.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(A.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(A.nodes[0].data[S]-t.data[S]);O&&n>=O&&(A={nodes:[]},T.push(A))}A.nodes.push(t)}));let C=w+k;if(!d){const t=T.length>0&&T[0].nodes.length>1,e=(Math.min(y,b)/2-C)/(T.length+(t?1:0));C=Math.min(C,e)}let P=0;if(T.forEach((t=>{const e=void 0===u?2*Math.PI-2*Math.PI/t.nodes.length:u;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(C*C/(e*e+n*n));P=Math.max(r,P)}t.r=P,P+=C})),h){let t=0,e=0;for(let n=0;n<T.length;n++){const r=(T[n].r||0)-e;t=Math.max(t,r)}e=0,T.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}T.forEach((t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach(((t,r)=>{const i=f+(c?1:-1)*e*r;t.data.x=x[0]+n*Math.cos(i),t.data.y=x[1]+n*Math.sin(i)}))})),t&&E.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:E,edges:m}}))}}function Mb(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,l,u,c,h,d,f=t._root,p={data:r},g=t._x0,v=t._y0,m=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a,i=f,!(f=f[h=c<<1|u]))return i[h]=p,t;if(s=+t._x.call(null,f.data),l=+t._y.call(null,f.data),e===s&&n===l)return p.next=f,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a}while((h=c<<1|u)==(d=(l>=a)<<1|s>=o));return i[d]=f,i[h]=p,t}function Sb(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Nb(t){return t[0]}function Ob(t){return t[1]}function Tb(t,e,n){var r=new Ab(null==e?Nb:e,null==n?Ob:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Ab(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 Cb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Pb=Tb.prototype=Ab.prototype;function Rb(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,l,u,c,h,d,f,p,g,v,m=t._root,y={data:i},b=t._x0,x=t._y0,E=t._z0,w=t._x1,k=t._y1,M=t._z1;if(!m)return t._root=y,t;for(;m.length;)if((d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l,o=m,!(m=m[g=p<<2|f<<1|d]))return o[g]=y,t;if(u=+t._x.call(null,m.data),c=+t._y.call(null,m.data),h=+t._z.call(null,m.data),e===u&&n===c&&r===h)return y.next=m,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+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l}while((g=p<<2|f<<1|d)==(v=(h>=l)<<2|(c>=s)<<1|u>=a));return o[v]=m,o[g]=y,t}function Db(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}Pb.copy=function(){var t,e,n=new Ab(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=Cb(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]=Cb(e));return n},Pb.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Mb(this.cover(e,n),e,n,t)},Pb.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),l=1/0,u=1/0,c=-1/0,h=-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<l&&(l=r),r>c&&(c=r),i<u&&(u=i),i>h&&(h=i));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<o;++n)Mb(this,a[n],s[n],t[n]);return this},Pb.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,l=i-n||1,u=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=u,u=a,l*=2,s){case 0:i=n+l,o=r+l;break;case 1:n=i-l,o=r+l;break;case 2:i=n+l,r=o-l;break;case 3:n=i-l,r=o-l}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},Pb.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Pb.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]]},Pb.find=function(t,e,n){var r,i,o,a,s,l,u,c=this._x0,h=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new Sb(g,c,h,d,f)),null==n?n=1/0:(c=t-n,h=e-n,d=t+n,f=e+n,n*=n);l=p.pop();)if(!(!(g=l.node)||(i=l.x0)>d||(o=l.y0)>f||(a=l.x1)<c||(s=l.y1)<h))if(g.length){var v=(i+a)/2,m=(o+s)/2;p.push(new Sb(g[3],v,m,a,s),new Sb(g[2],i,m,v,s),new Sb(g[1],v,o,a,m),new Sb(g[0],i,o,v,m)),(u=(e>=m)<<1|t>=v)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-u],p[p.length-1-u]=l)}else{var y=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),x=y*y+b*b;if(x<n){var E=Math.sqrt(n=x);c=t-E,h=e-E,d=t+E,f=e+E,r=g.data}}return r},Pb.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,l,u,c,h,d,f=this._root,p=this._x0,g=this._y0,v=this._x1,m=this._y1;if(!f)return this;if(f.length)for(;;){if((u=o>=(s=(p+v)/2))?p=s:v=s,(c=a>=(l=(g+m)/2))?g=l:m=l,e=f,!(f=f[h=c<<1|u]))return this;if(!f.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}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[h]=i:delete e[h],(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)},Pb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Pb.root=function(){return this._root},Pb.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Pb.visit=function(t){var e,n,r,i,o,a,s=[],l=this._root;for(l&&s.push(new Sb(l,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&l.length){var u=(r+o)/2,c=(i+a)/2;(n=l[3])&&s.push(new Sb(n,u,c,o,a)),(n=l[2])&&s.push(new Sb(n,r,c,u,a)),(n=l[1])&&s.push(new Sb(n,u,i,o,c)),(n=l[0])&&s.push(new Sb(n,r,i,u,c))}return this},Pb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Sb(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,l=e.x1,u=e.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&n.push(new Sb(o,a,s,c,h)),(o=i[1])&&n.push(new Sb(o,c,s,l,h)),(o=i[2])&&n.push(new Sb(o,a,h,c,u)),(o=i[3])&&n.push(new Sb(o,c,h,l,u))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},Pb.x=function(t){return arguments.length?(this._x=t,this):this._x},Pb.y=function(t){return arguments.length?(this._y=t,this):this._y};const Lb=(t,e,n,r,i,o)=>Math.sqrt((t-r)**2+(e-i)**2+(n-o)**2);function _b(t){return t[0]}function Ib(t){return t[1]}function jb(t){return t[2]}function Bb(t,e,n,r){var i=new Fb(null==e?_b:e,null==n?Ib:n,null==r?jb:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function Fb(t,e,n,r,i,o,a,s,l){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=l,this._root=void 0}function zb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Gb=Bb.prototype=Fb.prototype;Gb.copy=function(){var t,e,n=new Fb(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=zb(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]=zb(e));return n},Gb.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Rb(this.cover(e,n,r),e,n,r,t)},Gb.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,l=-1/0,u=-1/0,c=-1/0;for(let h,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(f=+this._y.call(null,h))||isNaN(p=+this._z.call(null,h))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>l&&(l=d),f<a&&(a=f),f>u&&(u=f),p<s&&(s=p),p>c&&(c=p));if(o>l||a>u||s>c)return this;this.cover(o,a,s).cover(l,u,c);for(let o=0;o<e;++o)Rb(this,n[o],r[o],i[o],t[o]);return this},Gb.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,l=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,l=(o=Math.floor(n))+1;else{for(var u,c,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=l;)switch(c=(n<o)<<2|(e<i)<<1|t<r,(u=new Array(8))[c]=d,d=u,h*=2,c){case 0:a=r+h,s=i+h,l=o+h;break;case 1:r=a-h,s=i+h,l=o+h;break;case 2:a=r+h,i=s-h,l=o+h;break;case 3:r=a-h,i=s-h,l=o+h;break;case 4:a=r+h,s=i+h,o=l-h;break;case 5:r=a-h,s=i+h,o=l-h;break;case 6:a=r+h,i=s-h,o=l-h;break;case 7:r=a-h,i=s-h,o=l-h}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=l,this},Gb.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Gb.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]]},Gb.find=function(t,e,n,r){var i,o,a,s,l,u,c,h,d,f=this._x0,p=this._y0,g=this._z0,v=this._x1,m=this._y1,y=this._z1,b=[],x=this._root;for(x&&b.push(new Db(x,f,p,g,v,m,y)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,v=t+r,m=e+r,y=n+r,r*=r);h=b.pop();)if(!(!(x=h.node)||(o=h.x0)>v||(a=h.y0)>m||(s=h.z0)>y||(l=h.x1)<f||(u=h.y1)<p||(c=h.z1)<g))if(x.length){var E=(o+l)/2,w=(a+u)/2,k=(s+c)/2;b.push(new Db(x[7],E,w,k,l,u,c),new Db(x[6],o,w,k,E,u,c),new Db(x[5],E,a,k,l,w,c),new Db(x[4],o,a,k,E,w,c),new Db(x[3],E,w,s,l,u,k),new Db(x[2],o,w,s,E,u,k),new Db(x[1],E,a,s,l,w,k),new Db(x[0],o,a,s,E,w,k)),(d=(n>=k)<<2|(e>=w)<<1|t>=E)&&(h=b[b.length-1],b[b.length-1]=b[b.length-1-d],b[b.length-1-d]=h)}else{var M=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),N=n-+this._z.call(null,x.data),O=M*M+S*S+N*N;if(O<r){var T=Math.sqrt(r=O);f=t-T,p=e-T,g=n-T,v=t+T,m=e+T,y=n+T,i=x.data}}return i},Gb.findAllWithinRadius=function(t,e,n,r){const i=[],o=t-r,a=e-r,s=n-r,l=t+r,u=e+r,c=n+r;return this.visit(((h,d,f,p,g,v,m)=>{if(!h.length)do{const o=h.data;Lb(t,e,n,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(h=h.next);return d>l||f>u||p>c||g<o||v<a||m<s})),i},Gb.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,l,u,c,h,d,f,p,g,v=this._root,m=this._x0,y=this._y0,b=this._z0,x=this._x1,E=this._y1,w=this._z1;if(!v)return this;if(v.length)for(;;){if((h=o>=(l=(m+x)/2))?m=l:x=l,(d=a>=(u=(y+E)/2))?y=u:E=u,(f=s>=(c=(b+w)/2))?b=c:w=c,e=v,!(v=v[p=f<<2|d<<1|h]))return this;if(!v.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(;v.data!==t;)if(r=v,!(v=v.next))return this;return(i=v.next)&&delete v.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(n?n[g]=v:this._root=v),this):(this._root=i,this)},Gb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Gb.root=function(){return this._root},Gb.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Gb.visit=function(t){var e,n,r,i,o,a,s,l,u=[],c=this._root;for(c&&u.push(new Db(c,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=u.pop();)if(!t(c=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,l=e.z1)&&c.length){var h=(r+a)/2,d=(i+s)/2,f=(o+l)/2;(n=c[7])&&u.push(new Db(n,h,d,f,a,s,l)),(n=c[6])&&u.push(new Db(n,r,d,f,h,s,l)),(n=c[5])&&u.push(new Db(n,h,i,f,a,d,l)),(n=c[4])&&u.push(new Db(n,r,i,f,h,d,l)),(n=c[3])&&u.push(new Db(n,h,d,o,a,s,f)),(n=c[2])&&u.push(new Db(n,r,d,o,h,s,f)),(n=c[1])&&u.push(new Db(n,h,i,o,a,d,f)),(n=c[0])&&u.push(new Db(n,r,i,o,h,d,f))}return this},Gb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Db(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,l=e.z0,u=e.x1,c=e.y1,h=e.z1,d=(a+u)/2,f=(s+c)/2,p=(l+h)/2;(o=i[0])&&n.push(new Db(o,a,s,l,d,f,p)),(o=i[1])&&n.push(new Db(o,d,s,l,u,f,p)),(o=i[2])&&n.push(new Db(o,a,f,l,d,c,p)),(o=i[3])&&n.push(new Db(o,d,f,l,u,c,p)),(o=i[4])&&n.push(new Db(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new Db(o,d,s,p,u,f,h)),(o=i[6])&&n.push(new Db(o,a,f,p,d,c,h)),(o=i[7])&&n.push(new Db(o,d,f,p,u,c,h))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Gb.x=function(t){return arguments.length?(this._x=t,this):this._x},Gb.y=function(t){return arguments.length?(this._y=t,this):this._y},Gb.z=function(t){return arguments.length?(this._z=t,this):this._z};function Vb(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}})),l=(2===i?Tb(s,(t=>t.x),(t=>t.y)):Bb(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(Wb),u=new Map;return s.forEach((t=>{u.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>Hb(e,r,i,o,a,t,n)))}(t,l,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 Wb(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 Hb=(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 l=[n,r,i][a-1],u=o.x-t.x||.1,c=o.y-t.y||.1,h=o.z-t.z||.1,d=[u,c,h],f=l-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+=u*e,o.vy+=c*e,o.vz+=h*e,!0}if(t.length)return!1;if(t.data!==o){const e=t.data.weight/g;o.vx+=u*e,o.vy+=c*e,o.vz+=h*e}};const Yb={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 Ub{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Yb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield 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 ze(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:l,height:u,nodeSize:c,getMass:h,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:ae(t.data.x)?t.data.x:Math.random()*l,y:ae(t.data.y)?t.data.y:Math.random()*u,z:ae(t.data.z)?t.data.z:Math.random()*Math.sqrt(l*u),size:c(t)||30,mass:h(t),nodeStrength:d(t)})}))),v=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 m={};i.forEach(((t,e)=>{m[t.id]={x:0,y:0,z:0}}));const y=new Yg({nodes:g,edges:v});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:x,onTick:E}=a;if(this.lastLayoutNodes=g,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=m,"undefined"==typeof window)return;let w=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Zb(e,g),edges:o}),this.runOneStep(y,e,w,m,a),this.updatePosition(e,y,m,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==E||E({nodes:Zb(e,g),edges:o}),w++,(w>=b||this.judgingDistance<x)&&(window.clearInterval(this.timeInterval),n({nodes:Zb(e,g),edges:o}))}),0),this.running=!0}))}))}formatOptions(t,e){const n=Object.assign({},t),{width:r,height:i,getMass:o}=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;ae(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}),n.nodeSize=fb(t.nodeSize,t.nodeSpacing);const a=t.linkDistance?hb(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=a,n.nodeStrength=hb(1,t.nodeStrength),n.edgeStrength=hb(1,t.edgeStrength),n}formatCentripetal(t,e){const{dimensions:n,centripetalOptions:r,center:i,clusterNodeStrength:o,leafCluster:a,clustering:s,nodeClusterBy:l}=t,u=e.getAllNodes(),c=r||{leaf:2,single:2,others:1,center:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0})};let h,d;if("function"!=typeof o&&(t.clusterNodeStrength=t=>o),a&&l&&(h=$b(e,l),d=Array.from(new Set(null==u?void 0:u.map((t=>t.data[l]))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=h[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=[]}=h[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=Kb(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&&l){h||(h=$b(e,l)),d||(d=Array.from(new Set(u.map((t=>t.data[l]))))),d=d.filter((t=>void 0!==t));const n={};d.forEach((t=>{const r=u.filter((e=>e.data[l]===t)).map((t=>e.getNode(t.id)));n[t]=Kb(r)})),t.centripetalOptions=Object.assign(c,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[t.data[l]];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:l}=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),l){l({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:l=1}=e.data;n+=l*s*.5})),n}calRepulsive(t,e,n){const{dimensions:r,factor:i,coulombDisScale:o}=n;Vb(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,l=t.getNode(a),u=t.getNode(s);if(!l||!u)return;let c=u.data.x-l.data.x,h=u.data.y-l.data.y,d=3===r?u.data.z-l.data.z:0;c||h||(c=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));const f=Math.sqrt(c*c+h*h+d*d);if(f<i(l)+i(u))return;const p=c/f,g=h/f,v=d/f,{linkDistance:m=200,edgeStrength:y=200}=n.data||{},b=(m-f)*y,x=1/(l.data.mass||1),E=1/(u.data.mass||1),w=p*b,k=g*b,M=v*b;e[a].x-=w*x,e[a].y-=k*x,e[a].z-=M*x,e[s].x+=w*E,e[s].y+=k*E,e[s].z+=M*E}))}calGravity(t,e,n,r){const{getCenter:i}=r,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),{width:l,height:u,center:c,gravity:h,centripetalOptions:d}=r;o&&o.forEach((r=>{const{id:o,data:f}=r,{mass:p,x:g,y:v,z:m}=f,y=e.getNode(o);let b=0,x=0,E=0,w=h;const k=t.getDegree(o,"in"),M=t.getDegree(o,"out"),S=t.getDegree(o,"both"),N=null==i?void 0:i(y,S);if(N){const[t,e,n]=N;b=g-t,x=v-e,w=n}else b=g-c[0],x=v-c[1],E=m-c[2];if(w&&(n[o].x-=w*b/p,n[o].y-=w*x/p,n[o].z-=w*E/p),d){const{leaf:t,single:e,others:r,center:i}=d,{x:c,y:h,z:f,centerStrength:b}=(null==i?void 0:i(y,a,s,l,u))||{x:0,y:0,z:0,centerStrength:0};if(!ae(c)||!ae(h))return;const x=(g-c)/p,E=(v-h)/p,w=(m-f)/p;if(b&&(n[o].x-=b*x,n[o].y-=b*E,n[o].z-=b*w),0===S){const t=e(y);if(!t)return;return n[o].x-=t*x,n[o].y-=t*E,void(n[o].z-=t*w)}if(0===k||0===M){const e=t(y,a,s);if(!e)return;return n[o].x-=e*x,n[o].y-=e*E,void(n[o].z-=e*w)}const N=r(y);if(!N)return;n[o].x-=N*x,n[o].y-=N*E,n[o].z-=N*w}}))}updateVelocity(t,e,n,r){const{damping:i,maxSpeed:o,interval:a,dimensions:s}=r,l=t.getAllNodes();(null==l?void 0:l.length)&&l.forEach((t=>{const{id:r}=t;let l=(n[r].x+e[r].x*a)*i||.01,u=(n[r].y+e[r].y*a)*i||.01,c=3===s?(n[r].z+e[r].z*a)*i||.01:0;const h=Math.sqrt(l*l+u*u+c*c);if(h>o){const t=o/h;l*=t,u*=t,c*=t}n[r]={x:l,y:u,z:c}}))}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 l=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((r=>{const{id:s}=r,u=t.getNode(s);if(ae(u.data.fx)&&ae(u.data.fy))return void e.mergeNodeData(s,{x:u.data.fx,y:u.data.fy,z:3===a?u.data.fz:void 0});const c=n[s].x*o,h=n[s].y*o,d=3===a?n[s].z*o:0;e.mergeNodeData(s,{x:r.data.x+c,y:r.data.y+h,z:r.data.z+d});const f=Math.sqrt(c*c+h*h+d*d);switch(i){case"max":this.judgingDistance<f&&(this.judgingDistance=f);break;case"min":this.judgingDistance>f&&(this.judgingDistance=f);break;default:l+=f}})),i&&"mean"!==i||(this.judgingDistance=l/s.length)}}const $b=(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]=qb(t,"leaf",n,e))})),r},qb=(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:Xb(t,e,r,n,s)}},Xb=(t,e,n,r,i)=>{const o=r.data[n]||"";let a=(null==i?void 0:i.filter((t=>t.data[n]===o)))||[];return a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out"))),a},Kb=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}},Zb=(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 Qb={};const Jb=Object.prototype.toString;function tx(t){const e=Jb.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var ex=w(Object.freeze({__proto__:null,isAnyArray:tx}));var nx=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!tx(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(!tx(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(!tx(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(!tx(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,l=void 0===s?n.autoMinMax?i:1:s;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var u=(l-a)/(i-r),c=0;c<t.length;c++)e[c]=(t[c]-r)*u+a;return e}}),rx=w(nx);Object.defineProperty(Qb,"__esModule",{value:!0});var ix=ex,ox=rx;const ax=" ".repeat(2),sx=" ".repeat(4);function lx(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${ax}[\n${sx}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),l=Math.min(a,n),u=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<l;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<l;o++)n.push(ux(t.get(e,o),r,i));u.push(`${n.join(" ")}`)}l!==a&&(u[u.length-1]+=` ... ${a-n} more columns`);s!==o&&u.push(`... ${o-e} more rows`);return u.join(`\n${sx}`)}(t,n,r,i,o)}\n${ax}]\n${ax}rows: ${t.rows}\n${ax}columns: ${t.columns}\n}`}function ux(t,e,n){return(t>=0&&n?` ${cx(t,e-1)}`:cx(t,e)).padEnd(e)}function cx(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 hx(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 dx(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 fx(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 px(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 gx(t,e){if(!ix.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 vx(t,e){if(!ix.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 mx(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(bx("startRow",e),bx("endRow",n),bx("startColumn",r),bx("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 yx(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function bx(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function xx(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Ex{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new kx(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 kx(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 kx(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 kx(t,e)}static ones(t,e){return new kx(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 kx(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 kx(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 kx(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 Ex.isMatrix(t)?t:new kx(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 kx(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){hx(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return kx.rowVector(this.getRow(t))}setRow(t,e){hx(this,t),e=fx(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){hx(this,t),hx(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){dx(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return kx.columnVector(this.getColumn(t))}setColumn(t,e){dx(this,t),e=px(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){dx(this,t),dx(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=fx(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=fx(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=fx(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=fx(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=px(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=px(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=px(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=px(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){hx(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){dx(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(){xx(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(){xx(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(hx(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){hx(this,t),xx(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(hx(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){hx(this,t),xx(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(dx(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){dx(this,t),xx(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(dx(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){dx(this,t),xx(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){Ex.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=kx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new kx(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}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=kx.eye(this.rows),n=this;for(let r=t;r>1;r/=2)1&r&&(e=e.mmul(n)),n=n.mmul(n);return e}strassen2x2(t){t=kx.checkMatrix(t);let e=new kx(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),l=this.get(1,1),u=t.get(1,1),c=(n+l)*(r+u),h=(a+l)*r,d=n*(o-u),f=l*(s-r),p=(n+i)*u,g=c+f-p+(i-l)*(s+u),v=d+p,m=h+f,y=c-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,v),e.set(1,0,m),e.set(1,1,y),e}strassen3x3(t){t=kx.checkMatrix(t);let e=new kx(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),l=this.get(2,0),u=this.get(2,1),c=this.get(2,2),h=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),v=t.get(1,2),m=t.get(2,0),y=t.get(2,1),b=t.get(2,2),x=(n-o)*(-d+g),E=(-n+o+a)*(h-d+g),w=(o+a)*(-h+d),k=n*h,M=(-n+l+u)*(h-f+v),S=(-n+l)*(f-v),N=(l+u)*(-h+f),O=(-i+u+c)*(g+m-y),T=(i-c)*(g-y),A=i*m,C=(u+c)*(-m+y),P=(-i+a+s)*(v+m-b),R=(i-s)*(v-b),D=(a+s)*(-m+b),L=k+A+r*p,_=(n+r+i-o-a-u-c)*g+E+w+k+O+A+C,I=k+M+N+(n+r+i-a-s-l-u)*v+A+P+D,j=x+a*(-h+d+p-g-v-m+b)+E+k+A+P+R,B=x+E+w+k+s*y,F=A+P+R+D+o*f,z=k+M+S+u*(-h+f+p-g-v-m+y)+O+T+A,G=O+T+A+C+l*d,V=k+M+S+N+c*b;return e.set(0,0,L),e.set(0,1,_),e.set(0,2,I),e.set(1,0,j),e.set(1,1,B),e.set(1,2,F),e.set(2,0,z),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=kx.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=Ex.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),l=Math.max(r,o);return e=a(e,s,l),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),l=e.subMatrix(0,o-1,0,s-1),u=n.subMatrix(0,o-1,0,s-1),c=e.subMatrix(0,o-1,s,e.columns-1),h=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),v=t(Ex.add(l,p),Ex.add(u,g),o,s),m=t(Ex.add(d,p),u,o,s),y=t(l,Ex.sub(h,g),o,s),b=t(p,Ex.sub(f,u),o,s),x=t(Ex.add(l,c),g,o,s),E=t(Ex.sub(d,l),Ex.add(u,h),o,s),w=t(Ex.sub(c,p),Ex.add(f,g),o,s),k=Ex.add(v,b);k.sub(x),k.add(w);let M=Ex.add(y,x),S=Ex.add(m,b),N=Ex.sub(v,m);N.add(y),N.add(E);let O=Ex.zeros(2*k.rows,2*k.columns);return O=O.setSubMatrix(k,0,0),O=O.setSubMatrix(M,k.rows,0),O=O.setSubMatrix(S,0,k.columns),O=O.setSubMatrix(N,k.rows,k.columns),O.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,l),s,l)}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 kx(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&ox(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 kx(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&ox(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=kx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new kx(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=kx.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(kx.eye(n,n)),i=kx.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new kx(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=wx){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=wx){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){mx(this,t,e,n,r);let i=new kx(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 kx(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 kx(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=kx.checkMatrix(t)).isEmpty())return this;mx(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){gx(this,t),vx(this,e);let n=new kx(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 kx(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=yx(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=yx(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=yx(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=yx(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(!ix.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,l=0;for(let e=0;e<i;e++)l=t.get(a,e)-n[a],r+=l,s+=l*l;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!ix.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,l=0;for(let e=0;e<r;e++)l=t.get(e,a)-n[a],i+=l,s+=l*l;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,l=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)l=t.get(e,r)-n,a+=l,s+=l*l;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(!ix.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(!ix.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+=t.get(n,e)**2/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!ix.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+=t.get(e,n)**2/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!ix.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+=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 lx(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 wx(t,e){return t-e}Ex.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Ex.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return lx(this)}),Ex.random=Ex.rand,Ex.randomInt=Ex.randInt,Ex.diagonal=Ex.diag,Ex.prototype.diagonal=Ex.prototype.diag,Ex.identity=Ex.eye,Ex.prototype.negate=Ex.prototype.neg,Ex.prototype.tensorProduct=Ex.prototype.kroneckerProduct;let kx=class t extends Ex{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(!ix.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 hx(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),hx(this,t,!0),e=Float64Array.from(fx(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){dx(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),dx(this,t,!0),e=px(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,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,this.get(e,n)**t.get(e,n));return this}}(Ex,kx);class Mx extends Ex{#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 kx.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(),kx.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=kx.copy(t,new kx(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new kx(t,t);else if(this.#e=new kx(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new Mx(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new kx(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 Mx(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)}}}Mx.prototype.klassType="SymmetricMatrix";class Sx extends Mx{static isDistanceMatrix(t){return Mx.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 Mx(this)}clone(){const t=new Sx(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;if(0===e)return new this(0);const 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}}Sx.prototype.klassSubType="DistanceMatrix";class Nx extends Ex{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class Ox extends Nx{constructor(t,e,n){gx(t,e),vx(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 Tx extends Ex{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 Ax extends Ex{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 Cx{constructor(t){let e,n,r,i,o,a,s,l,u,c=(t=Ax.checkMatrix(t)).clone(),h=c.rows,d=c.columns,f=new Float64Array(h),p=1;for(e=0;e<h;e++)f[e]=e;for(l=new Float64Array(h),n=0;n<d;n++){for(e=0;e<h;e++)l[e]=c.get(e,n);for(e=0;e<h;e++){for(u=Math.min(e,n),o=0,r=0;r<u;r++)o+=c.get(e,r)*l[r];l[e]-=o,c.set(e,n,l[e])}for(i=n,e=n+1;e<h;e++)Math.abs(l[e])>Math.abs(l[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=c.get(i,r),c.set(i,r,c.get(n,r)),c.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<h&&0!==c.get(n,n))for(e=n+1;e<h;e++)c.set(e,n,c.get(e,n)/c.get(n,n))}this.LU=c,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=kx.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 kx(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 kx(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 Px(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 Rx{constructor(t){let e,n,r,i,o=(t=Ax.checkMatrix(t)).clone(),a=t.rows,s=t.columns,l=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=Px(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))}}l[r]=-t}this.QR=o,this.Rdiag=l}solve(t){t=kx.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,l=t.clone(),u=e.columns;for(o=0;o<u;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*l.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)l.set(r,i,l.get(r,i)+a*e.get(r,o))}for(o=u-1;o>=0;o--){for(i=0;i<s;i++)l.set(o,i,l.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)l.set(r,i,l.get(r,i)-l.get(o,i)*e.get(r,o))}return l.subMatrix(0,u-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 kx(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 kx(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 Dx=class{constructor(t,e={}){if((t=Ax.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,l=Boolean(i),u=Boolean(o),c=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,c=!0;let e=l;l=u,u=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 h=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new kx(n,h),g=new kx(r,r),v=new Float64Array(r),m=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,r),x=Math.max(0,Math.min(r-2,n)),E=Math.max(b,x);for(let t=0;t<E;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=Px(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))}v[e]=s.get(t,e)}if(l&&t<b)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<r;e++)v[t]=Px(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<r;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<n&&0!==v[t]){for(let e=t+1;e<n;e++)m[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)m[e]+=v[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-v[e]/v[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*m[i])}}if(u)for(let e=t+1;e<r;e++)g.set(e,t,v[e])}}let w=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<w&&(f[w-1]=0),x+1<w&&(v[x]=s.get(x,w-1)),v[w-1]=0,l){for(let t=b;t<h;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<h;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(u)for(let t=r-1;t>=0;t--){if(t<x&&0!==v[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 k=w-1,M=Number.EPSILON;for(;w>0;){let t,e;for(t=w-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+M*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===w-2)e=4;else{let n;for(n=w-1;n>=t&&n!==t;n--){let e=(n!==w?Math.abs(v[n]):0)+(n!==t+1?Math.abs(v[n-1]):0);if(Math.abs(f[n])<=M*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=v[w-2];v[w-2]=0;for(let n=w-2;n>=t;n--){let i=Px(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*v[n-1],v[n-1]=o*v[n-1]),u)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=v[t-1];v[t-1]=0;for(let r=t;r<w;r++){let i=Px(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*v[r],v[r]=o*v[r],l)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(v[w-2]),Math.abs(f[t]),Math.abs(v[t])),i=f[w-1]/e,o=f[w-2]/e,a=v[w-2]/e,s=f[t]/e,c=v[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let m=0;0===h&&0===d||(m=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),m=d/(h+m));let y=(s+i)*(s-i)+m,b=s*c;for(let e=t;e<w-1;e++){let i=Px(y,b);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=b/i;if(e!==t&&(v[e-1]=i),y=o*f[e]+a*v[e],v[e]=o*v[e]-a*f[e],b=a*f[e+1],f[e+1]=o*f[e+1],u)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=Px(y,b),0===i&&(i=Number.MIN_VALUE),o=y/i,a=b/i,f[e]=i,y=o*v[e]+a*f[e+1],f[e+1]=-a*v[e]+o*f[e+1],b=a*v[e+1],v[e+1]=o*v[e+1],l&&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)}v[w-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,u))for(let e=0;e<=k;e++)g.set(e,t,-g.get(e,t));for(;t<k&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(l&&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(c){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=kx.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),l=a.rows,u=o.rows,c=kx.zeros(l,u);for(let t=0;t<l;t++)for(let e=0;e<u;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);c.set(t,e,n)}return c.mmul(e)}solveForDiagonal(t){return this.solve(kx.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new kx(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,l=new kx(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);l.set(t,e,n)}return l}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 kx.diag(this.s)}};function Lx(t,e,n=!1){return t=Ax.checkMatrix(t),e=Ax.checkMatrix(e),n?new Dx(t).solve(e):t.isSquare()?new Cx(t).solve(e):new Rx(t).solve(e)}function _x(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function Ix(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 jx{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=Ax.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 kx(o,o),s=new Float64Array(o),l=new Float64Array(o),u=t,c=!1;if(c=!!n||t.isSymmetric(),c){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h;for(l=0;l<t;l++)n[l]=r.get(t-1,l);for(s=t-1;s>0;s--){for(h=0,a=0,u=0;u<s;u++)h+=Math.abs(n[u]);if(0===h)for(e[s]=n[s-1],l=0;l<s;l++)n[l]=r.get(s-1,l),r.set(s,l,0),r.set(l,s,0);else{for(u=0;u<s;u++)n[u]/=h,a+=n[u]*n[u];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=h*o,a-=i*o,n[s-1]=i-o,l=0;l<s;l++)e[l]=0;for(l=0;l<s;l++){for(i=n[l],r.set(l,s,i),o=e[l]+r.get(l,l)*i,u=l+1;u<=s-1;u++)o+=r.get(u,l)*n[u],e[u]+=r.get(u,l)*i;e[l]=o}for(i=0,l=0;l<s;l++)e[l]/=a,i+=e[l]*n[l];for(c=i/(a+a),l=0;l<s;l++)e[l]-=c*n[l];for(l=0;l<s;l++){for(i=n[l],o=e[l],u=l;u<=s-1;u++)r.set(u,l,r.get(u,l)-(i*e[u]+o*n[u]));n[l]=r.get(s-1,l),r.set(s,l,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(u=0;u<=s;u++)n[u]=r.get(u,s+1)/a;for(l=0;l<=s;l++){for(o=0,u=0;u<=s;u++)o+=r.get(u,s+1)*r.get(u,l);for(u=0;u<=s;u++)r.set(u,l,r.get(u,l)-o*n[u])}}for(u=0;u<=s;u++)r.set(u,s+1,0)}for(l=0;l<t;l++)n[l]=r.get(t-1,l),r.set(t-1,l,0);r.set(t-1,t-1,1),e[0]=0}(o,l,s,a),function(t,e,n,r){let i,o,a,s,l,u,c,h,d,f,p,g,v,m,y,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let x=0,E=0,w=Number.EPSILON;for(u=0;u<t;u++){for(E=Math.max(E,Math.abs(n[u])+Math.abs(e[u])),c=u;c<t&&!(Math.abs(e[c])<=w*E);)c++;if(c>u)do{for(i=n[u],h=(n[u+1]-i)/(2*e[u]),d=Px(h,1),h<0&&(d=-d),n[u]=e[u]/(h+d),n[u+1]=e[u]*(h+d),f=n[u+1],o=i-n[u],a=u+2;a<t;a++)n[a]-=o;for(x+=o,h=n[c],p=1,g=p,v=p,m=e[u+1],y=0,b=0,a=c-1;a>=u;a--)for(v=g,g=p,b=y,i=p*e[a],o=p*h,d=Px(h,e[a]),e[a+1]=y*d,y=e[a]/d,p=h/d,h=p*n[a]-y*i,n[a+1]=o+y*(p*i+y*n[a]),l=0;l<t;l++)o=r.get(l,a+1),r.set(l,a+1,y*r.get(l,a)+p*o),r.set(l,a,p*r.get(l,a)-y*o);h=-y*b*v*m*e[u]/f,e[u]=y*h,n[u]=p*h}while(Math.abs(e[u])>w*E);n[u]=n[u]+x,e[u]=0}for(a=0;a<t-1;a++){for(l=a,h=n[a],s=a+1;s<t;s++)n[s]<h&&(l=s,h=n[s]);if(l!==a)for(n[l]=n[a],n[a]=h,s=0;s<t;s++)h=r.get(s,a),r.set(s,a,r.get(s,l)),r.set(s,l,h)}}(o,l,s,a)}else{let t=new kx(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h=0,d=t-1;for(u=h+1;u<=d-1;u++){for(c=0,s=u;s<=d;s++)c+=Math.abs(e.get(s,u-1));if(0!==c){for(a=0,s=d;s>=u;s--)n[s]=e.get(s,u-1)/c,a+=n[s]*n[s];for(o=Math.sqrt(a),n[u]>0&&(o=-o),a-=n[u]*o,n[u]=n[u]-o,l=u;l<t;l++){for(i=0,s=d;s>=u;s--)i+=n[s]*e.get(s,l);for(i/=a,s=u;s<=d;s++)e.set(s,l,e.get(s,l)-i*n[s])}for(s=0;s<=d;s++){for(i=0,l=d;l>=u;l--)i+=n[l]*e.get(s,l);for(i/=a,l=u;l<=d;l++)e.set(s,l,e.get(s,l)-i*n[l])}n[u]=c*n[u],e.set(u,u-1,c*o)}}for(s=0;s<t;s++)for(l=0;l<t;l++)r.set(s,l,s===l?1:0);for(u=d-1;u>=h+1;u--)if(0!==e.get(u,u-1)){for(s=u+1;s<=d;s++)n[s]=e.get(s,u-1);for(l=u;l<=d;l++){for(o=0,s=u;s<=d;s++)o+=n[s]*r.get(s,l);for(o=o/n[u]/e.get(u,u-1),s=u;s<=d;s++)r.set(s,l,r.get(s,l)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,l,u,c,h,d,f,p,g,v,m,y,b,x=t-1,E=0,w=t-1,k=Number.EPSILON,M=0,S=0,N=0,O=0,T=0,A=0,C=0,P=0;for(o=0;o<t;o++)for((o<E||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>=E;){for(l=x;l>E&&(A=Math.abs(i.get(l-1,l-1))+Math.abs(i.get(l,l)),0===A&&(A=S),!(Math.abs(i.get(l,l-1))<k*A));)l--;if(l===x)i.set(x,x,i.get(x,x)+M),n[x]=i.get(x,x),e[x]=0,x--,P=0;else if(l===x-1){if(h=i.get(x,x-1)*i.get(x-1,x),N=(i.get(x-1,x-1)-i.get(x,x))/2,O=N*N+h,C=Math.sqrt(Math.abs(O)),i.set(x,x,i.get(x,x)+M),i.set(x-1,x-1,i.get(x-1,x-1)+M),d=i.get(x,x),O>=0){for(C=N>=0?N+C:N-C,n[x-1]=d+C,n[x]=n[x-1],0!==C&&(n[x]=d-h/C),e[x-1]=0,e[x]=0,d=i.get(x,x-1),A=Math.abs(d)+Math.abs(C),N=d/A,O=C/A,T=Math.sqrt(N*N+O*O),N/=T,O/=T,a=x-1;a<t;a++)C=i.get(x-1,a),i.set(x-1,a,O*C+N*i.get(x,a)),i.set(x,a,O*i.get(x,a)-N*C);for(o=0;o<=x;o++)C=i.get(o,x-1),i.set(o,x-1,O*C+N*i.get(o,x)),i.set(o,x,O*i.get(o,x)-N*C);for(o=E;o<=w;o++)C=r.get(o,x-1),r.set(o,x-1,O*C+N*r.get(o,x)),r.set(o,x,O*r.get(o,x)-N*C)}else n[x-1]=d+N,n[x]=d+N,e[x-1]=C,e[x]=-C;x-=2,P=0}else{if(d=i.get(x,x),f=0,h=0,l<x&&(f=i.get(x-1,x-1),h=i.get(x,x-1)*i.get(x-1,x)),10===P){for(M+=d,o=E;o<=x;o++)i.set(o,o,i.get(o,o)-d);A=Math.abs(i.get(x,x-1))+Math.abs(i.get(x-1,x-2)),d=f=.75*A,h=-.4375*A*A}if(30===P&&(A=(f-d)/2,A=A*A+h,A>0)){for(A=Math.sqrt(A),f<d&&(A=-A),A=d-h/((f-d)/2+A),o=E;o<=x;o++)i.set(o,o,i.get(o,o)-A);M+=A,d=f=h=.964}for(P+=1,u=x-2;u>=l&&(C=i.get(u,u),T=d-C,A=f-C,N=(T*A-h)/i.get(u+1,u)+i.get(u,u+1),O=i.get(u+1,u+1)-C-T-A,T=i.get(u+2,u+1),A=Math.abs(N)+Math.abs(O)+Math.abs(T),N/=A,O/=A,T/=A,u!==l)&&!(Math.abs(i.get(u,u-1))*(Math.abs(O)+Math.abs(T))<k*(Math.abs(N)*(Math.abs(i.get(u-1,u-1))+Math.abs(C)+Math.abs(i.get(u+1,u+1)))));)u--;for(o=u+2;o<=x;o++)i.set(o,o-2,0),o>u+2&&i.set(o,o-3,0);for(s=u;s<=x-1&&(y=s!==x-1,s!==u&&(N=i.get(s,s-1),O=i.get(s+1,s-1),T=y?i.get(s+2,s-1):0,d=Math.abs(N)+Math.abs(O)+Math.abs(T),0!==d&&(N/=d,O/=d,T/=d)),0!==d);s++)if(A=Math.sqrt(N*N+O*O+T*T),N<0&&(A=-A),0!==A){for(s!==u?i.set(s,s-1,-A*d):l!==u&&i.set(s,s-1,-i.get(s,s-1)),N+=A,d=N/A,f=O/A,C=T/A,O/=N,T/=N,a=s;a<t;a++)N=i.get(s,a)+O*i.get(s+1,a),y&&(N+=T*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-N*C)),i.set(s,a,i.get(s,a)-N*d),i.set(s+1,a,i.get(s+1,a)-N*f);for(o=0;o<=Math.min(x,s+3);o++)N=d*i.get(o,s)+f*i.get(o,s+1),y&&(N+=C*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-N*T)),i.set(o,s,i.get(o,s)-N),i.set(o,s+1,i.get(o,s+1)-N*O);for(o=E;o<=w;o++)N=d*r.get(o,s)+f*r.get(o,s+1),y&&(N+=C*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-N*T)),r.set(o,s,r.get(o,s)-N),r.set(o,s+1,r.get(o,s+1)-N*O)}}}if(0===S)return;for(x=t-1;x>=0;x--)if(N=n[x],O=e[x],0===O)for(l=x,i.set(x,x,1),o=x-1;o>=0;o--){for(h=i.get(o,o)-N,T=0,a=l;a<=x;a++)T+=i.get(o,a)*i.get(a,x);if(e[o]<0)C=h,A=T;else if(l=o,0===e[o]?i.set(o,x,0!==h?-T/h:-T/(k*S)):(d=i.get(o,o+1),f=i.get(o+1,o),O=(n[o]-N)*(n[o]-N)+e[o]*e[o],c=(d*A-C*T)/O,i.set(o,x,c),i.set(o+1,x,Math.abs(d)>Math.abs(C)?(-T-h*c)/d:(-A-f*c)/C)),c=Math.abs(i.get(o,x)),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x,i.get(a,x)/c)}else if(O<0)for(l=x-1,Math.abs(i.get(x,x-1))>Math.abs(i.get(x-1,x))?(i.set(x-1,x-1,O/i.get(x,x-1)),i.set(x-1,x,-(i.get(x,x)-N)/i.get(x,x-1))):(b=Bx(0,-i.get(x-1,x),i.get(x-1,x-1)-N,O),i.set(x-1,x-1,b[0]),i.set(x-1,x,b[1])),i.set(x,x-1,0),i.set(x,x,1),o=x-2;o>=0;o--){for(p=0,g=0,a=l;a<=x;a++)p+=i.get(o,a)*i.get(a,x-1),g+=i.get(o,a)*i.get(a,x);if(h=i.get(o,o)-N,e[o]<0)C=h,T=p,A=g;else if(l=o,0===e[o]?(b=Bx(-p,-g,h,O),i.set(o,x-1,b[0]),i.set(o,x,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),v=(n[o]-N)*(n[o]-N)+e[o]*e[o]-O*O,m=2*(n[o]-N)*O,0===v&&0===m&&(v=k*S*(Math.abs(h)+Math.abs(O)+Math.abs(d)+Math.abs(f)+Math.abs(C))),b=Bx(d*T-C*p+O*g,d*A-C*g-O*p,v,m),i.set(o,x-1,b[0]),i.set(o,x,b[1]),Math.abs(d)>Math.abs(C)+Math.abs(O)?(i.set(o+1,x-1,(-p-h*i.get(o,x-1)+O*i.get(o,x))/d),i.set(o+1,x,(-g-h*i.get(o,x)-O*i.get(o,x-1))/d)):(b=Bx(-T-f*i.get(o,x-1),-A-f*i.get(o,x),C,O),i.set(o+1,x-1,b[0]),i.set(o+1,x,b[1]))),c=Math.max(Math.abs(i.get(o,x-1)),Math.abs(i.get(o,x))),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x-1,i.get(a,x-1)/c),i.set(a,x,i.get(a,x)/c)}for(o=0;o<t;o++)if(o<E||o>w)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=E;a--)for(o=E;o<=w;o++){for(C=0,s=E;s<=Math.min(a,w);s++)C+=r.get(o,s)*i.get(s,a);r.set(o,a,C)}}(o,l,s,a,t)}this.n=o,this.e=l,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 kx(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 Bx(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 Fx{constructor(t){if(!(t=Ax.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new kx(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=s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=Ax.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 zx{constructor(t,e={}){t=Ax.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=ix.isAnyArray(n)&&"number"==typeof n[0]?kx.columnVector(n):Ax.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,l,u,c,h=1;for(let e=0;e<i&&h>o;e++)u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),s=t.mmul(u).div(u.transpose().mmul(u).get(0,0)),e>0&&(h=s.clone().sub(c).pow(2).sum()),c=s.clone(),n?(l=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),l=l.div(l.norm()),a=n.mmul(l).div(l.transpose().mmul(l).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(l.transpose()));this.t=s,this.p=e.transpose(),this.w=u.transpose(),this.q=l,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=u.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(u.transpose()))}}Qb.AbstractMatrix=Ex,Qb.CHO=Fx,Qb.CholeskyDecomposition=Fx,Qb.DistanceMatrix=Sx,Qb.EVD=jx,Qb.EigenvalueDecomposition=jx,Qb.LU=Cx,Qb.LuDecomposition=Cx;var Gx=Qb.Matrix=kx;Qb.MatrixColumnSelectionView=class extends Nx{constructor(t,e){vx(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])}},Qb.MatrixColumnView=class extends Nx{constructor(t,e){dx(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)}},Qb.MatrixFlipColumnView=class extends Nx{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)}},Qb.MatrixFlipRowView=class extends Nx{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)}},Qb.MatrixRowSelectionView=class extends Nx{constructor(t,e){gx(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)}},Qb.MatrixRowView=class extends Nx{constructor(t,e){hx(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)}},Qb.MatrixSelectionView=Ox,Qb.MatrixSubView=class extends Nx{constructor(t,e,n,r,i){mx(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)}},Qb.MatrixTransposeView=class extends Nx{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)}},Qb.NIPALS=zx,Qb.Nipals=zx,Qb.QR=Rx,Qb.QrDecomposition=Rx,Qb.SVD=Dx;var Vx=Qb.SingularValueDecomposition=Dx;Qb.SymmetricMatrix=Mx,Qb.WrapperMatrix1D=Tx,Qb.WrapperMatrix2D=Ax,Qb.correlation=function(t,e=t,n={}){t=new kx(t);let r=!1;if("object"!=typeof e||kx.isMatrix(e)||ix.isAnyArray(e)?e=new kx(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}),l=t.transpose().mmul(e);for(let e=0;e<l.rows;e++)for(let n=0;n<l.columns;n++)l.set(e,n,l.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return l},Qb.covariance=function(t,e=t,n={}){t=new kx(t);let r=!1;if("object"!=typeof e||kx.isMatrix(e)||ix.isAnyArray(e)?e=new kx(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 Wx=Qb.default=kx;Qb.determinant=function t(e){if((e=kx.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 Ox(e,[1,2],[1,2]),a=new Ox(e,[1,2],[0,2]),s=new Ox(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 Cx(e).determinant}throw Error("determinant can only be calculated for a square matrix")},Qb.inverse=function(t,e=!1){return t=Ax.checkMatrix(t),e?new Dx(t).inverse():Lx(t,kx.eye(t.rows))},Qb.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=kx.checkMatrix(t)).rows,o=new kx(i,i);for(let e=0;e<i;e++){let a=kx.columnVector(t.getRow(e)),s=t.subMatrixRow(_x(i,e)).transpose(),l=new Dx(s).solve(a),u=kx.sub(a,s.mmul(l)).abs().max();o.setRow(e,Ix(u,l,e,n,r))}return o},Qb.pseudoInverse=function(t,e=Number.EPSILON){if((t=kx.checkMatrix(t)).isEmpty())return t.transpose();let n=new Dx(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(kx.diag(o).mmul(r.transpose()))},Qb.solve=Lx,Qb.wrap=function(t,e){if(ix.isAnyArray(t))return t[0]&&ix.isAnyArray(t[0])?new Ax(t):new Tx(t,e);throw new Error("the argument is not an array")};const Hx=Gx,Yx=Vx;Wx.Matrix&&Wx.Matrix;const Ux={center:[0,0],linkDistance:50};class $x{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},Ux),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericMDSLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericMDSLayout(!0,t,e)}))}genericMDSLayout(t,e,n){return ze(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 mb(e,t,i);const l=ob({nodes:a,edges:s}),u=ib(l);qx(u);const c=((t,e)=>{const n=[];return t.forEach((t=>{const r=[];t.forEach((t=>{r.push(t*e)})),n.push(r)})),n})(u,o),h=Xx(c),d=[];h.forEach(((t,e)=>{const n=ub(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 qx=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)}))}))},Xx=t=>{const e=Hx.mul(Hx.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 Yx(e),a=Hx.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>Hx.mul([t],[a]).toJSON()[0].splice(0,2)))};function Kx(t){return!!t.tick&&!!t.stop}const Zx={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Qx={center:[0,0],comboPadding:10,treeKey:"combo"};class Jx{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},Qx),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,e)}))}genericComboCombinedLayout(t,e,n){return ze(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)),l=e.getAllNodes().filter((t=>t.data._isCombo)),u=e.getAllEdges(),c=null==s?void 0:s.length;if(!c||1===c)return mb(e,t,i);const h=[],d=new Map;s.forEach((t=>{d.set(t.id,t)}));const f=new Map;l.forEach((t=>{f.set(t.id,t)}));const p=new Map,g=this.getInnerGraphs(e,o,d,f,u,r,p);yield Promise.all(g);const v=new Map,m=[],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})};m.push(i),v.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,sb(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const x=[];let E;if(u.forEach((t=>{const e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&v.has(e)&&v.has(n)&&x.push({id:t.id,source:e,target:n,data:{}})})),null==m?void 0:m.length){if(1===m.length)m[0].data.x=i[0],m[0].data.y=i[1];else{const t=new Yg({nodes:m,edges:x}),e=a||new Ub;if(b&&Zx[e.id]){const e=m.length<100?new $x:new kb;yield e.assign(t)}const n=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}:{});E=yield tE(e,t,n)}p.forEach((t=>{var e;const n=E.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,h.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=>{h.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=h.find((e=>e.id===t.id));r.data.x+=e||0,r.data.y+=n||0}}))}))}t&&h.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:h,edges:u}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=ae(r)?()=>r:Yt(r)?r:()=>0,e.spacing=a,n)if(Yt(n))o=t=>{const e=n(t),r=a(t);if(rb(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(rb(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(rb(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(qt(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=ae(i)?()=>i:rb(i)?()=>Math.max.apply(null,i):Yt(i)?i:()=>0,e.comboPadding=s,e}getInnerGraphs(t,e,n,r,i,o,a){const{nodeSize:s,comboPadding:l,spacing:u,innerLayout:c}=o,h=c||new kb({}),d={center:[0,0],preventOverlap:!0,nodeSpacing:u},f=[],p=t=>{let e=(null==l?void 0:l(t))||10;return rb(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((o=>{a.set(o.id,{id:o.id,data:{nodes:[],size:p(o).size}});let l=Promise.resolve();sb(t,[o],(o=>{var u;if(!o.data._isCombo)return;const{size:c,padding:f}=p(o);if(null===(u=t.getChildren(o.id,e))||void 0===u?void 0:u.length){const u=a.get(o.id);a.set(o.id,{id:o.id,data:Object.assign({nodes:[]},null==u?void 0:u.data)});const c=new Map,p=t.getChildren(o.id,e).map((t=>{if(t.data._isCombo)return a.has(t.id)||a.set(t.id,{id:t.id,data:Object.assign({},t.data)}),c.set(t.id,!0),a.get(t.id);const e=n.get(t.id)||r.get(t.id);return c.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),g={nodes:p,edges:i.filter((t=>c.has(t.source)&&c.has(t.target)))};let v=1/0;p.forEach((t=>{var e;let{size:n}=t.data;n||(n=(null===(e=a.get(t.id))||void 0===e?void 0:e.data.size)||(null==s?void 0:s(t))||[30,30]),ae(n)&&(n=[n,n]);const[r,i]=n;v>r&&(v=r),v>i&&(v=i),t.data.size=n})),l=l.then((()=>ze(this,void 0,void 0,(function*(){const t=new Yg(g);yield tE(h,t,d,!0);const{minX:e,minY:n,maxX:r,maxY:i}=(t=>{let e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((t=>{let o=t.data.size;rb(o)?1===o.length&&(o=[o[0],o[0]]):ae(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],l=t.data.x+a[0],u=t.data.y-a[1],c=t.data.y+a[1];e>s&&(e=s),n>u&&(n=u),r<l&&(r=l),i<c&&(i=c)})),{minX:e,minY:n,maxX:r,maxY:i}})(p),s=(r+e)/2,l=(i+n)/2;g.nodes.forEach((t=>{t.data.x-=s,t.data.y-=l}));const u=[Math.max(r-e,v)+2*f,Math.max(i-n,v)+2*f];a.get(o.id).data.size=u,a.get(o.id).data.nodes=p}))))}else a.set(o.id,{id:o.id,data:Object.assign(Object.assign({},o.data),{size:c})});return!0}),"BT",e),f.push(l)})),f}}function tE(t,e,n,r){var i;return ze(this,void 0,void 0,(function*(){return Kx(t)?(t.execute(e,n),t.stop(),t.tick(null!==(i=n.iterations)&&void 0!==i?i:300)):r?yield t.assign(e,n):yield t.execute(e,n)}))}function eE(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,l=0;for(i=0;i<a;++i)s+=(o=n[i]).x,l+=o.y;for(s=(s/a-t)*r,l=(l/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=l}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}function nE(t){return function(){return t}}function rE(t){return 1e-6*(t()-.5)}function iE(t){return t.x+t.vx}function oE(t){return t.y+t.vy}function aE(t){var e,n,r,i=1,o=1;function a(){for(var t,a,l,u,c,h,d,f=e.length,p=0;p<o;++p)for(a=Tb(e,iE,oE).visitAfter(s),t=0;t<f;++t)l=e[t],h=n[l.index],d=h*h,u=l.x+l.vx,c=l.y+l.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=h+f;if(!s)return e>u+p||o<u-p||n>c+p||a<c-p;if(s.index>l.index){var g=u-s.x-s.vx,v=c-s.y-s.vy,m=g*g+v*v;m<p*p&&(0===g&&(m+=(g=rE(r))*g),0===v&&(m+=(v=rE(r))*v),m=(p-(m=Math.sqrt(m)))/m*i,l.vx+=(g*=m)*(p=(f*=f)/(d+f)),l.vy+=(v*=m)*p,s.vx-=g*(p=1-p),s.vy-=v*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 l(){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=nE(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,l()},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:nE(+e),l(),a):t},a}function sE(t){return t.index}function lE(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function uE(t){var e,n,r,i,o,a,s=sE,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},u=nE(30),c=1;function h(r){for(var i=0,s=t.length;i<c;++i)for(var l,u,h,d,f,p,g,v=0;v<s;++v)u=(l=t[v]).source,d=(h=l.target).x+h.vx-u.x-u.vx||rE(a),f=h.y+h.vy-u.y-u.vy||rE(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[v])/p*r*e[v],f*=p,h.vx-=d*(g=o[v]),h.vy-=f*g,u.vx+=d*(g=1-g),u.vy+=f*g}function d(){if(r){var a,l,u=r.length,c=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(u);a<c;++a)(l=t[a]).index=a,"object"!=typeof l.source&&(l.source=lE(h,l.source)),"object"!=typeof l.target&&(l.target=lE(h,l.target)),i[l.source.index]=(i[l.source.index]||0)+1,i[l.target.index]=(i[l.target.index]||0)+1;for(a=0,o=new Array(c);a<c;++a)l=t[a],o[a]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(c),f(),n=new Array(c),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+u(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,a=e,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(s=t,h):s},h.iterations=function(t){return arguments.length?(c=+t,h):c},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:nE(+t),f(),h):l},h.distance=function(t){return arguments.length?(u="function"==typeof t?t:nE(+t),p(),h):u},h}var cE={value:()=>{}};function hE(){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 dE(r)}function dE(t){this._=t}function fE(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function pE(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=cE,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}dE.prototype=hE.prototype={constructor:dE,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]=pE(i[n],t.name,e);else if(null==e)for(n in i)i[n]=pE(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=fE(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new dE(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 gE,vE,mE=0,yE=0,bE=0,xE=0,EE=0,wE=0,kE="object"==typeof performance&&performance.now?performance:Date,ME="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function SE(){return EE||(ME(NE),EE=kE.now()+wE)}function NE(){EE=0}function OE(){this._call=this._time=this._next=null}function TE(t,e,n){var r=new OE;return r.restart(t,e,n),r}function AE(){EE=(xE=kE.now())+wE,mE=yE=0;try{!function(){SE(),++mE;for(var t,e=gE;e;)(t=EE-e._time)>=0&&e._call.call(void 0,t),e=e._next;--mE}()}finally{mE=0,function(){var t,e,n=gE,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:gE=e);vE=t,PE(r)}(),EE=0}}function CE(){var t=kE.now(),e=t-xE;e>1e3&&(wE-=e,xE=t)}function PE(t){mE||(yE&&(yE=clearTimeout(yE)),t-EE>24?(t<1/0&&(yE=setTimeout(AE,t-kE.now()-wE)),bE&&(bE=clearInterval(bE))):(bE||(xE=kE.now(),bE=setInterval(CE,1e3)),mE=1,ME(AE)))}OE.prototype=TE.prototype={constructor:OE,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?SE():+n)+(null==e?0:+e),this._next||vE===this||(vE?vE._next=this:gE=this,vE=this),this._call=t,this._time=n,PE()},stop:function(){this._call&&(this._call=null,this._time=1/0,PE())}};const RE=4294967296;function DE(t){return t.x}function LE(t){return t.y}var _E=Math.PI*(3-Math.sqrt(5));function IE(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=TE(h),u=hE("tick","end"),c=function(){let t=1;return()=>(t=(1664525*t+1013904223)%RE)/RE}();function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(r){var l,u,c=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),l=0;l<c;++l)null==(u=t[l]).fx?u.x+=u.vx*=a:(u.x=u.fx,u.vx=0),null==u.fy?u.y+=u.vy*=a:(u.y=u.fy,u.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=10*Math.sqrt(.5+n),o=n*_E;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,c),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.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?(c=t,s.forEach(p),e):c},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,l,u=0,c=t.length;for(null==r?r=1/0:r*=r,u=0;u<c;++u)(a=(i=e-(s=t[u]).x)*i+(o=n-s.y)*o)<r&&(l=s,r=a);return l},on:function(t,n){return arguments.length>1?(u.on(t,n),e):u.on(t)}}}function jE(){var t,e,n,r,i,o=nE(-30),a=1,s=1/0,l=.81;function u(n){var i,o=t.length,a=Tb(t,DE,LE).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function c(){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 h(t){var e,n,r,o,a,s=0,l=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,l+=n,r+=n*e.x,o+=n*e.y);t.x=r/l,t.y=o/l}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,u,c){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,f=c-o,p=h*h+d*d;if(f*f/l<p)return p<s&&(0===h&&(p+=(h=rE(n))*h),0===d&&(p+=(d=rE(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=h*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===h&&(p+=(h=rE(n))*h),0===d&&(p+=(d=rE(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=h*f,e.vy+=d*f)}while(t=t.next)}}return u.initialize=function(e,r){t=e,n=r,c()},u.strength=function(t){return arguments.length?(o="function"==typeof t?t:nE(+t),c(),u):o},u.distanceMin=function(t){return arguments.length?(a=t*t,u):Math.sqrt(a)},u.distanceMax=function(t){return arguments.length?(s=t*t,u):Math.sqrt(s)},u.theta=function(t){return arguments.length?(l=t*t,u):Math.sqrt(l)},u}function BE(t,e,n){var r,i,o,a=nE(.1);function s(t){for(var a=0,s=r.length;a<s;++a){var l=r[a],u=l.x-e||1e-6,c=l.y-n||1e-6,h=Math.sqrt(u*u+c*c),d=(o[a]-h)*i[a]*t/h;l.vx+=u*d,l.vy+=c*d}}function l(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+a(r[e],e,r)}}return"function"!=typeof t&&(t=nE(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,l()},s.strength=function(t){return arguments.length?(a="function"==typeof t?t:nE(+t),l(),s):a},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:nE(+e),l(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}function FE(t){var e,n,r,i=nE(.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=nE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:nE(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:nE(+e),a(),o):t},o}function zE(t){var e,n,r,i=nE(.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=nE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:nE(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:nE(+e),a(),o):t},o}class GE{constructor(t){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:uE,manyBody:jE,center:eE,collide:aE,radial:BE,x:FE,y:zE},this.options={link:{id:t=>t.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},ke(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericLayout(!0,t,e)}))}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const n=this.context.nodes.find((e=>e.id===t));n&&e.forEach(((t,e)=>{if("number"==typeof t||null===t){n[["fx","fy","fz"][e]]=t}}))}getOptions(t){var e,n;const r=ke({},this.options,t);return r.collide&&void 0===(null===(e=r.collide)||void 0===e?void 0:e.radius)&&(r.collide=r.collide||{},r.collide.radius=null!==(n=r.nodeSize)&&void 0!==n?n:10),void 0===r.iterations&&(r.link&&void 0===r.link.iterations&&(r.iterations=r.link.iterations),r.collide&&void 0===r.collide.iterations&&(r.iterations=r.collide.iterations)),this.context.options=r,r}genericLayout(t,e,n){var r;return ze(this,void 0,void 0,(function*(){const i=this.getOptions(n),o=e.getAllNodes().map((({id:t,data:e})=>Object.assign(Object.assign({id:t},e),Ce(e.data,this.config.inputNodeAttrs)))),a=e.getAllEdges().map((t=>Object.assign({},t)));Object.assign(this.context,{assign:t,nodes:o,edges:a,graph:e});const s=new Promise((t=>{this.resolver=t})),l=this.setSimulation(i);return l.nodes(o),null===(r=l.force("link"))||void 0===r||r.links(a),s}))}getResult(){const{assign:t,nodes:e,edges:n,graph:r}=this.context,i=e.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),Ce(t,this.config.outputNodeAttrs))}))),o=n.map((({id:t,source:e,target:n,data:r})=>({id:t,source:"object"==typeof e?e.id:e,target:"object"==typeof n?n.id:n,data:r})));return t&&i.forEach((t=>r.mergeNodeData(t.id,t.data))),{nodes:i,edges:o}}initSimulation(){return IE()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",(()=>{var e;return null===(e=t.onTick)||void 0===e?void 0:e.call(t,this.getResult())})).on("end",(()=>{var t;return null===(t=this.resolver)||void 0===t?void 0:t.call(this,this.getResult())}))),VE(e,this.config.simulationAttrs.map((e=>[e,t[e]]))),Object.entries(this.forceMap).forEach((([n,r])=>{const i=n;if(t[n]){let n=e.force(i);n||(n=r(),e.force(i,n)),VE(n,Object.entries(t[i]))}else e.force(i,null)})),e}}const VE=(t,e)=>e.reduce(((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e),t);var WE,HE,YE,UE,$E,qE,XE,KE,ZE,QE,JE,tw,ew,nw,rw,iw,ow,aw,sw,lw,uw,cw,hw,dw,fw,pw,gw,vw,mw,yw,bw,xw,Ew,ww,kw,Mw,Sw,Nw,Ow,Tw,Aw,Cw,Pw,Rw,Dw,Lw,_w,Iw,jw,Bw,Fw,zw,Gw,Vw,Ww,Hw,Yw,Uw,$w,qw,Xw,Kw,Zw,Qw,Jw,tk,ek,nk,rk,ik,ok,ak,sk,lk,uk,ck,hk,dk,fk,pk,gk,vk,mk,yk,bk,xk,Ek,wk,kk,Mk,Sk,Nk,Ok,Tk,Ak,Ck,Pk,Rk,Dk,Lk,_k,Ik,jk,Bk,Fk,zk,Gk,Vk;function Wk(){if(UE)return YE;return UE=1,YE=function(t,e){return t===e||t!=t&&e!=e}}function Hk(){if(qE)return $E;qE=1;var t=Wk();return $E=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},$E}function Yk(){if(iw)return rw;iw=1;var t=HE?WE:(HE=1,WE=function(){this.__data__=[],this.size=0}),e=function(){if(KE)return XE;KE=1;var t=Hk(),e=Array.prototype.splice;return XE=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))},XE}(),n=function(){if(QE)return ZE;QE=1;var t=Hk();return ZE=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},ZE}(),r=function(){if(tw)return JE;tw=1;var t=Hk();return JE=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(nw)return ew;nw=1;var t=Hk();return ew=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},ew}();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,rw=o}function Uk(){if(pw)return fw;pw=1;var t="object"==typeof x&&x&&x.Object===Object&&x;return fw=t}function $k(){if(vw)return gw;vw=1;var t=Uk(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return gw=n}function qk(){if(yw)return mw;yw=1;var t=$k().Symbol;return mw=t}function Xk(){if(Mw)return kw;Mw=1;var t=qk(),e=function(){if(xw)return bw;xw=1;var t=qk(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return bw=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(ww)return Ew;ww=1;var t=Object.prototype.toString;return Ew=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return kw=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function Kk(){if(Nw)return Sw;return Nw=1,Sw=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Zk(){if(Tw)return Ow;Tw=1;var t=Xk(),e=Kk();return Ow=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 Qk(){if(Rw)return Pw;Rw=1;var t,e=function(){if(Cw)return Aw;Cw=1;var t=$k()["__core-js_shared__"];return Aw=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Pw=function(t){return!!n&&n in t}}function Jk(){if(Lw)return Dw;Lw=1;var t=Function.prototype.toString;return Dw=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function tM(){if(zw)return Fw;zw=1;var t=function(){if(Iw)return _w;Iw=1;var t=Zk(),e=Qk(),n=Kk(),r=Jk(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,l=a.hasOwnProperty,u=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return _w=function(o){return!(!n(o)||e(o))&&(t(o)?u:i).test(r(o))}}(),e=Bw?jw:(Bw=1,jw=function(t,e){return null==t?void 0:t[e]});return Fw=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function eM(){if(Vw)return Gw;Vw=1;var t=tM()($k(),"Map");return Gw=t}function nM(){if(Hw)return Ww;Hw=1;var t=tM()(Object,"create");return Ww=t}function rM(){if(nk)return ek;nk=1;var t=function(){if(Uw)return Yw;Uw=1;var t=nM();return Yw=function(){this.__data__=t?t(null):{},this.size=0}}(),e=qw?$w:(qw=1,$w=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(Kw)return Xw;Kw=1;var t=nM(),e=Object.prototype.hasOwnProperty;return Xw=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},Xw}(),r=function(){if(Qw)return Zw;Qw=1;var t=nM(),e=Object.prototype.hasOwnProperty;return Zw=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},Zw}(),i=function(){if(tk)return Jw;tk=1;var t=nM();return Jw=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},Jw}();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,ek=o}function iM(){if(lk)return sk;lk=1;var t=ak?ok:(ak=1,ok=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return sk=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},sk}function oM(){if(yk)return mk;yk=1;var t=function(){if(ik)return rk;ik=1;var t=rM(),e=Yk(),n=eM();return rk=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(ck)return uk;ck=1;var t=iM();return uk=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(dk)return hk;dk=1;var t=iM();return hk=function(e){return t(this,e).get(e)}}(),r=function(){if(pk)return fk;pk=1;var t=iM();return fk=function(e){return t(this,e).has(e)}}(),i=function(){if(vk)return gk;vk=1;var t=iM();return gk=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},gk}();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,mk=o}function aM(){if(wk)return Ek;wk=1;var t=Yk(),e=function(){if(aw)return ow;aw=1;var t=Yk();return ow=function(){this.__data__=new t,this.size=0}}(),n=(lw||(lw=1,sw=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),sw),r=cw?uw:(cw=1,uw=function(t){return this.__data__.get(t)}),i=dw?hw:(dw=1,hw=function(t){return this.__data__.has(t)}),o=function(){if(xk)return bk;xk=1;var t=Yk(),e=eM(),n=oM();return bk=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},bk}();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,Ek=a}function sM(){if(Mk)return kk;return Mk=1,kk=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},kk}function lM(){if(Nk)return Sk;Nk=1;var t=tM(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Sk=e}function uM(){if(Tk)return Ok;Tk=1;var t=lM();return Ok=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function cM(){if(Ck)return Ak;Ck=1;var t=uM(),e=Wk(),n=Object.prototype.hasOwnProperty;return Ak=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 hM(){if(Rk)return Pk;Rk=1;var t=cM(),e=uM();return Pk=function(n,r,i,o){var a=!i;i||(i={});for(var s=-1,l=r.length;++s<l;){var u=r[s],c=o?o(i[u],n[u],u,i,n):void 0;void 0===c&&(c=n[u]),a?e(i,u,c):t(i,u,c)}return i},Pk}function dM(){if(Ik)return _k;return Ik=1,_k=function(t){return null!=t&&"object"==typeof t}}function fM(){if(zk)return Fk;zk=1;var t=function(){if(Bk)return jk;Bk=1;var t=Xk(),e=dM();return jk=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=dM(),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 Fk=o}function pM(){if(Vk)return Gk;Vk=1;var t=Array.isArray;return Gk=t}var gM,vM,mM,yM,bM,xM,EM,wM,kM,MM,SM,NM={exports:{}};function OM(){return mM||(mM=1,function(t,e){var n=$k(),r=vM?gM:(vM=1,gM=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}(NM,NM.exports)),NM.exports}function TM(){if(bM)return yM;bM=1;var t=/^(?:0|[1-9]\d*)$/;return yM=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},yM}function AM(){if(EM)return xM;EM=1;return xM=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function CM(){if(SM)return MM;return SM=1,MM=function(t){return function(e){return t(e)}}}var PM,RM,DM,LM,_M,IM,jM,BM,FM,zM,GM,VM,WM,HM,YM,UM,$M,qM,XM,KM,ZM,QM,JM,tS,eS,nS,rS,iS={exports:{}};function oS(){return PM||(PM=1,function(t,e){var n=Uk(),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}(iS,iS.exports)),iS.exports}function aS(){if(DM)return RM;DM=1;var t=function(){if(kM)return wM;kM=1;var t=Xk(),e=AM(),n=dM(),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,wM=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=CM(),n=oS(),r=n&&n.isTypedArray,i=r?e(r):t;return RM=i}function sS(){if(_M)return LM;_M=1;var t=(Lk||(Lk=1,Dk=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),Dk),e=fM(),n=pM(),r=OM(),i=TM(),o=aS(),a=Object.prototype.hasOwnProperty;return LM=function(s,l){var u=n(s),c=!u&&e(s),h=!u&&!c&&r(s),d=!u&&!c&&!h&&o(s),f=u||c||h||d,p=f?t(s.length,String):[],g=p.length;for(var v in s)!l&&!a.call(s,v)||f&&("length"==v||h&&("offset"==v||"parent"==v)||d&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||i(v,g))||p.push(v);return p},LM}function lS(){if(jM)return IM;jM=1;var t=Object.prototype;return IM=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function uS(){if(FM)return BM;return FM=1,BM=function(t,e){return function(n){return t(e(n))}}}function cS(){if(WM)return VM;WM=1;var t=lS(),e=function(){if(GM)return zM;GM=1;var t=uS()(Object.keys,Object);return zM=t}(),n=Object.prototype.hasOwnProperty;return VM=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 hS(){if(YM)return HM;YM=1;var t=Zk(),e=AM();return HM=function(n){return null!=n&&e(n.length)&&!t(n)}}function dS(){if($M)return UM;$M=1;var t=sS(),e=cS(),n=hS();return UM=function(r){return n(r)?t(r):e(r)}}function fS(){if(JM)return QM;JM=1;var t=Kk(),e=lS(),n=ZM?KM:(ZM=1,KM=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return QM=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 pS(){if(eS)return tS;eS=1;var t=sS(),e=fS(),n=hS();return tS=function(r){return n(r)?t(r,!0):e(r)}}var gS,vS,mS,yS,bS,xS,ES,wS,kS,MS,SS,NS,OS,TS,AS,CS,PS,RS,DS,LS,_S,IS,jS,BS,FS,zS,GS,VS,WS,HS,YS,US,$S,qS,XS,KS,ZS,QS,JS,tN,eN,nN,rN,iN,oN,aN,sN,lN,uN,cN,hN,dN,fN,pN,gN,vN,mN,yN,bN,xN,EN,wN,kN,MN,SN,NN,ON,TN,AN,CN,PN,RN,DN,LN,_N,IN,jN,BN,FN,zN,GN,VN,WN,HN,YN,UN,$N,qN,XN,KN,ZN,QN,JN,tO,eO,nO,rO,iO,oO,aO,sO,lO,uO,cO,hO,dO,fO,pO,gO,vO,mO,yO,bO,xO,EO,wO,kO,MO,SO,NO,OO,TO,AO,CO,PO,RO,DO,LO,_O,IO,jO,BO,FO,zO,GO,VO,WO,HO,YO,UO,$O,qO,XO,KO,ZO,QO,JO,tT,eT,nT,rT,iT,oT,aT,sT,lT,uT,cT,hT,dT,fT,pT,gT,vT,mT,yT,bT,xT,ET,wT,kT,MT,ST,NT,OT,TT,AT,CT,PT,RT,DT,LT,_T,IT,jT,BT,FT,zT,GT,VT,WT,HT,YT,UT,$T,qT,XT,KT,ZT,QT,JT,tA,eA,nA,rA,iA,oA,aA,sA,lA,uA,cA,hA,dA,fA,pA,gA,vA,mA,yA,bA,xA,EA,wA,kA,MA,SA,NA,OA,TA,AA,CA,PA,RA,DA,LA,_A,IA,jA,BA,FA,zA,GA,VA,WA,HA,YA,UA,$A,qA,XA,KA,ZA,QA,JA,tC,eC,nC,rC,iC,oC,aC,sC,lC,uC,cC,hC,dC,fC,pC,gC,vC,mC,yC,bC,xC,EC,wC,kC,MC,SC={exports:{}};function NC(){return gS||(gS=1,function(t,e){var n=$k(),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}}(SC,SC.exports)),SC.exports}function OC(){if(mS)return vS;return mS=1,vS=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},vS}function TC(){if(bS)return yS;return bS=1,yS=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},yS}function AC(){if(ES)return xS;return ES=1,xS=function(){return[]}}function CC(){if(kS)return wS;kS=1;var t=TC(),e=AC(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return wS=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function PC(){if(OS)return NS;return OS=1,NS=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},NS}function RC(){if(AS)return TS;AS=1;var t=uS()(Object.getPrototypeOf,Object);return TS=t}function DC(){if(PS)return CS;PS=1;var t=PC(),e=RC(),n=CC(),r=AC(),i=Object.getOwnPropertySymbols;return CS=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function LC(){if(_S)return LS;_S=1;var t=PC(),e=pM();return LS=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function _C(){if(jS)return IS;jS=1;var t=LC(),e=CC(),n=dS();return IS=function(r){return t(r,n,e)}}function IC(){if(YS)return HS;YS=1;var t=tM()($k(),"Set");return HS=t}function jC(){if(XS)return qS;XS=1;var t=function(){if(GS)return zS;GS=1;var t=tM()($k(),"DataView");return zS=t}(),e=eM(),n=function(){if(WS)return VS;WS=1;var t=tM()($k(),"Promise");return VS=t}(),r=IC(),i=function(){if($S)return US;$S=1;var t=tM()($k(),"WeakMap");return US=t}(),o=Xk(),a=Jk(),s="[object Map]",l="[object Promise]",u="[object Set]",c="[object WeakMap]",h="[object DataView]",d=a(t),f=a(e),p=a(n),g=a(r),v=a(i),m=o;return(t&&m(new t(new ArrayBuffer(1)))!=h||e&&m(new e)!=s||n&&m(n.resolve())!=l||r&&m(new r)!=u||i&&m(new i)!=c)&&(m=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 h;case f:return s;case p:return l;case g:return u;case v:return c}return e}),qS=m}function BC(){if(JS)return QS;JS=1;var t=$k().Uint8Array;return QS=t}function FC(){if(eN)return tN;eN=1;var t=BC();return tN=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function zC(){if(uN)return lN;uN=1;var t=FC();return lN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function GC(){if(hN)return cN;hN=1;var t=FC(),e=function(){if(rN)return nN;rN=1;var t=FC();return nN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(oN)return iN;oN=1;var t=/\w*$/;return iN=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(sN)return aN;sN=1;var t=qk(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return aN=function(t){return n?Object(n.call(t)):{}}}(),i=zC();return cN=function(o,a,s){var l=o.constructor;switch(a){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new l(+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 l;case"[object Number]":case"[object String]":return new l(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function VC(){if(fN)return dN;fN=1;var t=Kk(),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 dN=n}function WC(){if(gN)return pN;gN=1;var t=VC(),e=RC(),n=lS();return pN=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function HC(){if(bN)return yN;bN=1;var t=function(){if(mN)return vN;mN=1;var t=jC(),e=dM();return vN=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=CM(),n=oS(),r=n&&n.isMap,i=r?e(r):t;return yN=i}function YC(){if(kN)return wN;kN=1;var t=function(){if(EN)return xN;EN=1;var t=jC(),e=dM();return xN=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=CM(),n=oS(),r=n&&n.isSet,i=r?e(r):t;return wN=i}function UC(){if(SN)return MN;SN=1;var t=aM(),e=sM(),n=cM(),r=function(){if(XM)return qM;XM=1;var t=hM(),e=dS();return qM=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(rS)return nS;rS=1;var t=hM(),e=pS();return nS=function(n,r){return n&&t(r,e(r),n)}}(),o=NC(),a=OC(),s=function(){if(SS)return MS;SS=1;var t=hM(),e=CC();return MS=function(n,r){return t(n,e(n),r)}}(),l=function(){if(DS)return RS;DS=1;var t=hM(),e=DC();return RS=function(n,r){return t(n,e(n),r)}}(),u=_C(),c=function(){if(FS)return BS;FS=1;var t=LC(),e=DC(),n=pS();return BS=function(r){return t(r,n,e)}}(),h=jC(),d=function(){if(ZS)return KS;ZS=1;var t=Object.prototype.hasOwnProperty;return KS=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},KS}(),f=GC(),p=WC(),g=pM(),v=OM(),m=HC(),y=Kk(),b=YC(),x=dS(),E=pS(),w="[object Arguments]",k="[object Function]",M="[object Object]",S={};return S[w]=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[M]=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[k]=S["[object WeakMap]"]=!1,MN=function N(O,T,A,C,P,R){var D,L=1&T,_=2&T,I=4&T;if(A&&(D=P?A(O,C,P,R):A(O)),void 0!==D)return D;if(!y(O))return O;var j=g(O);if(j){if(D=d(O),!L)return a(O,D)}else{var B=h(O),F=B==k||"[object GeneratorFunction]"==B;if(v(O))return o(O,L);if(B==M||B==w||F&&!P){if(D=_||F?{}:p(O),!L)return _?l(O,i(D,O)):s(O,r(D,O))}else{if(!S[B])return P?O:{};D=f(O,B,L)}}R||(R=new t);var z=R.get(O);if(z)return z;R.set(O,D),b(O)?O.forEach((function(t){D.add(N(t,T,A,t,O,R))})):m(O)&&O.forEach((function(t,e){D.set(e,N(t,T,A,e,O,R))}));var G=j?void 0:(I?_?c:u:_?E:x)(O);return e(G||O,(function(t,e){G&&(t=O[e=t]),n(D,e,N(t,T,A,e,O,R))})),D},MN}function $C(){if(ON)return NN;ON=1;var t=UC();return NN=function(e){return t(e,4)}}function qC(){if(AN)return TN;return AN=1,TN=function(t){return function(){return t}}}function XC(){if(DN)return RN;DN=1;var t=(PN||(PN=1,CN=function(t){return function(e,n,r){for(var i=-1,o=Object(e),a=r(e),s=a.length;s--;){var l=a[t?s:++i];if(!1===n(o[l],l,o))break}return e}}),CN),e=t();return RN=e}function KC(){if(_N)return LN;_N=1;var t=XC(),e=dS();return LN=function(n,r){return n&&t(n,r,e)}}function ZC(){if(FN)return BN;FN=1;var t=KC(),e=function(){if(jN)return IN;jN=1;var t=hS();return IN=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}},IN}(),n=e(t);return BN=n}function QC(){if(GN)return zN;return GN=1,zN=function(t){return t}}function JC(){if(WN)return VN;WN=1;var t=QC();return VN=function(e){return"function"==typeof e?e:t}}function tP(){if(YN)return HN;YN=1;var t=sM(),e=ZC(),n=JC(),r=pM();return HN=function(i,o){return(r(i)?t:e)(i,n(o))}}function eP(){return $N?UN:($N=1,UN=tP())}function nP(){if(eO)return tO;eO=1;var t=oM(),e=ZN?KN:(ZN=1,KN=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=JN?QN:(JN=1,QN=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,tO=r}function rP(){if(oO)return iO;return oO=1,iO=function(t,e){return t.has(e)}}function iP(){if(sO)return aO;sO=1;var t=nP(),e=(rO||(rO=1,nO=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}),nO),n=rP();return aO=function(r,i,o,a,s,l){var u=1&o,c=r.length,h=i.length;if(c!=h&&!(u&&h>c))return!1;var d=l.get(r),f=l.get(i);if(d&&f)return d==i&&f==r;var p=-1,g=!0,v=2&o?new t:void 0;for(l.set(r,i),l.set(i,r);++p<c;){var m=r[p],y=i[p];if(a)var b=u?a(y,m,p,i,r,l):a(m,y,p,r,i,l);if(void 0!==b){if(b)continue;g=!1;break}if(v){if(!e(i,(function(t,e){if(!n(v,e)&&(m===t||s(m,t,o,a,l)))return v.push(e)}))){g=!1;break}}else if(m!==y&&!s(m,y,o,a,l)){g=!1;break}}return l.delete(r),l.delete(i),g},aO}function oP(){if(hO)return cO;return hO=1,cO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},cO}function aP(){if(fO)return dO;fO=1;var t=qk(),e=BC(),n=Wk(),r=iP(),i=(uO||(uO=1,lO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),lO),o=oP(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return dO=function(t,a,l,u,c,h,d){switch(l){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||!h(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&u;if(f||(f=o),t.size!=a.size&&!p)return!1;var g=d.get(t);if(g)return g==a;u|=2,d.set(t,a);var v=r(f(t),f(a),u,c,h,d);return d.delete(t),v;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function sP(){if(mO)return vO;mO=1;var t=aM(),e=iP(),n=aP(),r=function(){if(gO)return pO;gO=1;var t=_C(),e=Object.prototype.hasOwnProperty;return pO=function(n,r,i,o,a,s){var l=1&i,u=t(n),c=u.length;if(c!=t(r).length&&!l)return!1;for(var h=c;h--;){var d=u[h];if(!(l?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 v=l;++h<c;){var m=n[d=u[h]],y=r[d];if(o)var b=l?o(y,m,d,r,n,s):o(m,y,d,n,r,s);if(!(void 0===b?m===y||a(m,y,i,o,s):b)){g=!1;break}v||(v="constructor"==d)}if(g&&!v){var x=n.constructor,E=r.constructor;x==E||!("constructor"in n)||!("constructor"in r)||"function"==typeof x&&x instanceof x&&"function"==typeof E&&E instanceof E||(g=!1)}return s.delete(n),s.delete(r),g},pO}(),i=jC(),o=pM(),a=OM(),s=aS(),l="[object Arguments]",u="[object Array]",c="[object Object]",h=Object.prototype.hasOwnProperty;return vO=function(d,f,p,g,v,m){var y=o(d),b=o(f),x=y?u:i(d),E=b?u:i(f),w=(x=x==l?c:x)==c,k=(E=E==l?c:E)==c,M=x==E;if(M&&a(d)){if(!a(f))return!1;y=!0,w=!1}if(M&&!w)return m||(m=new t),y||s(d)?e(d,f,p,g,v,m):n(d,f,x,p,g,v,m);if(!(1&p)){var S=w&&h.call(d,"__wrapped__"),N=k&&h.call(f,"__wrapped__");if(S||N){var O=S?d.value():d,T=N?f.value():f;return m||(m=new t),v(O,T,p,g,m)}}return!!M&&(m||(m=new t),r(d,f,p,g,v,m))}}function lP(){if(bO)return yO;bO=1;var t=sP(),e=dM();return yO=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))},yO}function uP(){if(kO)return wO;kO=1;var t=Kk();return wO=function(e){return e==e&&!t(e)}}function cP(){if(OO)return NO;return OO=1,NO=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function hP(){if(AO)return TO;AO=1;var t=function(){if(EO)return xO;EO=1;var t=aM(),e=lP();return xO=function(n,r,i,o){var a=i.length,s=a,l=!o;if(null==n)return!s;for(n=Object(n);a--;){var u=i[a];if(l&&u[2]?u[1]!==n[u[0]]:!(u[0]in n))return!1}for(;++a<s;){var c=(u=i[a])[0],h=n[c],d=u[1];if(l&&u[2]){if(void 0===h&&!(c in n))return!1}else{var f=new t;if(o)var p=o(h,d,c,n,r,f);if(!(void 0===p?e(d,h,3,o,f):p))return!1}}return!0},xO}(),e=function(){if(SO)return MO;SO=1;var t=uP(),e=dS();return MO=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},MO}(),n=cP();return TO=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 dP(){if(PO)return CO;PO=1;var t=Xk(),e=dM();return CO=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function fP(){if(DO)return RO;DO=1;var t=pM(),e=dP(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return RO=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 pP(){if(jO)return IO;jO=1;var t=function(){if(_O)return LO;_O=1;var t=oM();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,LO=e}();return IO=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function gP(){if(GO)return zO;return GO=1,zO=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},zO}function vP(){if(YO)return HO;YO=1;var t=function(){if(WO)return VO;WO=1;var t=qk(),e=gP(),n=pM(),r=dP(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return VO=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},VO}();return HO=function(e){return null==e?"":t(e)}}function mP(){if($O)return UO;$O=1;var t=pM(),e=fP(),n=function(){if(FO)return BO;FO=1;var t=pP(),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 BO=r}(),r=vP();return UO=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function yP(){if(XO)return qO;XO=1;var t=dP();return qO=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function bP(){if(ZO)return KO;ZO=1;var t=mP(),e=yP();return KO=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},KO}function xP(){if(rT)return nT;rT=1;var t=mP(),e=fM(),n=pM(),r=TM(),i=AM(),o=yP();return nT=function(a,s,l){for(var u=-1,c=(s=t(s,a)).length,h=!1;++u<c;){var d=o(s[u]);if(!(h=null!=a&&l(a,d)))break;a=a[d]}return h||++u!=c?h:!!(c=null==a?0:a.length)&&i(c)&&r(d,c)&&(n(a)||e(a))},nT}function EP(){if(oT)return iT;oT=1;var t=eT?tT:(eT=1,tT=function(t,e){return null!=t&&e in Object(t)}),e=xP();return iT=function(n,r){return null!=n&&e(n,r,t)}}function wP(){if(sT)return aT;sT=1;var t=lP(),e=function(){if(JO)return QO;JO=1;var t=bP();return QO=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=EP(),r=fP(),i=uP(),o=cP(),a=yP();return aT=function(s,l){return r(s)&&i(l)?o(a(s),l):function(r){var i=e(r,s);return void 0===i&&i===l?n(r,s):t(l,i,3)}}}function kP(){if(uT)return lT;return uT=1,lT=function(t){return function(e){return null==e?void 0:e[t]}}}function MP(){if(fT)return dT;fT=1;var t=kP(),e=function(){if(hT)return cT;hT=1;var t=bP();return cT=function(e){return function(n){return t(n,e)}}}(),n=fP(),r=yP();return dT=function(i){return n(i)?t(r(i)):e(i)}}function SP(){if(gT)return pT;gT=1;var t=hP(),e=wP(),n=QC(),r=pM(),i=MP();return pT=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 NP(){if(mT)return vT;mT=1;var t=TC(),e=function(){if(XN)return qN;XN=1;var t=ZC();return qN=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},qN}(),n=SP(),r=pM();return vT=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function OP(){if(ET)return xT;ET=1;var t=function(){if(bT)return yT;bT=1;var t=Object.prototype.hasOwnProperty;return yT=function(e,n){return null!=e&&t.call(e,n)}}(),e=xP();return xT=function(n,r){return null!=n&&e(n,r,t)}}function TP(){if(kT)return wT;kT=1;var t=cS(),e=jC(),n=fM(),r=pM(),i=hS(),o=OM(),a=lS(),s=aS(),l=Object.prototype.hasOwnProperty;return wT=function(u){if(null==u)return!0;if(i(u)&&(r(u)||"string"==typeof u||"function"==typeof u.splice||o(u)||s(u)||n(u)))return!u.length;var c=e(u);if("[object Map]"==c||"[object Set]"==c)return!u.size;if(a(u))return!t(u).length;for(var h in u)if(l.call(u,h))return!1;return!0}}function AP(){if(ST)return MT;return ST=1,MT=function(t){return void 0===t}}function CP(){if(OT)return NT;OT=1;var t=ZC(),e=hS();return NT=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},NT}function PP(){if(AT)return TT;AT=1;var t=gP(),e=SP(),n=CP(),r=pM();return TT=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function RP(){if(_T)return LT;_T=1;var t=(PT||(PT=1,CT=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}),CT),e=ZC(),n=SP(),r=(DT||(DT=1,RT=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),RT),i=pM();return LT=function(o,a,s){var l=i(o)?t:r,u=arguments.length<3;return l(o,n(a,4),s,u,e)},LT}function DP(){if(YT)return HT;YT=1;var t=function(){if(FT)return BT;FT=1;var t=kP()("length");return BT=t}(),e=function(){if(GT)return zT;GT=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return zT=function(e){return t.test(e)}}(),n=function(){if(WT)return VT;WT=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+")?",l="[\\ufe0e\\ufe0f]?",u=l+s+"(?:\\u200d(?:"+[i,o,a].join("|")+")"+l+s+")*",c="(?:"+[i+n+"?",n,o,a,e].join("|")+")",h=RegExp(r+"(?="+r+")|"+c+u,"g");return VT=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return HT=function(r){return e(r)?n(r):t(r)}}function LP(){if($T)return UT;$T=1;var t=cS(),e=jC(),n=hS(),r=function(){if(jT)return IT;jT=1;var t=Xk(),e=pM(),n=dM();return IT=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=DP();return UT=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 _P(){if(XT)return qT;XT=1;var t=sM(),e=VC(),n=KC(),r=SP(),i=RC(),o=pM(),a=OM(),s=Zk(),l=Kk(),u=aS();return qT=function(c,h,d){var f=o(c),p=f||a(c)||u(c);if(h=r(h,4),null==d){var g=c&&c.constructor;d=p?f?new g:[]:l(c)&&s(g)?e(i(c)):{}}return(p?t:n)(c,(function(t,e,n){return h(d,t,e,n)})),d},qT}function IP(){if(JT)return QT;JT=1;var t=PC(),e=function(){if(ZT)return KT;ZT=1;var t=qk(),e=fM(),n=pM(),r=t?t.isConcatSpreadable:void 0;return KT=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return QT=function n(r,i,o,a,s){var l=-1,u=r.length;for(o||(o=e),s||(s=[]);++l<u;){var c=r[l];i>0&&o(c)?i>1?n(c,i-1,o,a,s):t(s,c):a||(s[s.length]=c)}return s},QT}function jP(){if(rA)return nA;rA=1;var t=eA?tA:(eA=1,tA=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 nA=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),l=Array(s);++a<s;)l[a]=o[r+a];a=-1;for(var u=Array(r+1);++a<r;)u[a]=o[a];return u[r]=i(l),t(n,this,u)}},nA}function BP(){if(uA)return lA;uA=1;var t=function(){if(oA)return iA;oA=1;var t=qC(),e=lM(),n=QC();return iA=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(sA)return aA;sA=1;var t=Date.now;return aA=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)}},aA}(),n=e(t);return lA=n}function FP(){if(hA)return cA;hA=1;var t=QC(),e=jP(),n=BP();return cA=function(r,i){return n(e(r,i,t),r+"")}}function zP(){if(fA)return dA;return fA=1,dA=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},dA}function GP(){if(bA)return yA;bA=1;var t=zP(),e=gA?pA:(gA=1,pA=function(t){return t!=t}),n=(mA||(mA=1,vA=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),vA);return yA=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function VP(){if(OA)return NA;OA=1;var t=IC(),e=SA?MA:(SA=1,MA=function(){}),n=oP(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return NA=r}function WP(){if(AA)return TA;AA=1;var t=nP(),e=function(){if(EA)return xA;EA=1;var t=GP();return xA=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(kA||(kA=1,wA=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}),wA),r=rP(),i=VP(),o=oP();return TA=function(a,s,l){var u=-1,c=e,h=a.length,d=!0,f=[],p=f;if(l)d=!1,c=n;else if(h>=200){var g=s?null:i(a);if(g)return o(g);d=!1,c=r,p=new t}else p=s?[]:f;t:for(;++u<h;){var v=a[u],m=s?s(v):v;if(v=l||0!==v?v:0,d&&m==m){for(var y=p.length;y--;)if(p[y]===m)continue t;s&&p.push(m),f.push(v)}else c(p,m,l)||(p!==f&&p.push(m),f.push(v))}return f},TA}function HP(){if(PA)return CA;PA=1;var t=hS(),e=dM();return CA=function(n){return e(n)&&t(n)}}function YP(){if(DA)return RA;DA=1;var t=IP(),e=FP(),n=WP(),r=HP(),i=e((function(e){return n(t(e,1,r,!0))}));return RA=i}function UP(){if(jA)return IA;jA=1;var t=function(){if(_A)return LA;_A=1;var t=gP();return LA=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=dS();return IA=function(n){return null==n?[]:t(n,e(n))}}function $P(){if(FA)return BA;var t;FA=1;try{t={clone:$C(),constant:qC(),each:eP(),filter:NP(),has:OP(),isArray:pM(),isEmpty:TP(),isFunction:Zk(),isUndefined:AP(),keys:dS(),map:PP(),reduce:RP(),size:LP(),transform:_P(),union:YP(),values:UP()}}catch(t){}return t||(t=window._),BA=t}function qP(){if(GA)return zA;GA=1;var t=$P();zA=n;var e="\0";function n(n){this._isDirected=!t.has(n,"directed")||n.directed,this._isMultigraph=!!t.has(n,"multigraph")&&n.multigraph,this._isCompound=!!t.has(n,"compound")&&n.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function r(t,e){t[e]?t[e]++:t[e]=1}function i(t,e){--t[e]||delete t[e]}function o(e,n,r,i){var o=""+n,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}return o+""+a+""+(t.isUndefined(i)?"\0":i)}function a(t,e){return o(t,e.v,e.w,e.name)}return n.prototype._nodeCount=0,n.prototype._edgeCount=0,n.prototype.isDirected=function(){return this._isDirected},n.prototype.isMultigraph=function(){return this._isMultigraph},n.prototype.isCompound=function(){return this._isCompound},n.prototype.setGraph=function(t){return this._label=t,this},n.prototype.graph=function(){return this._label},n.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},n.prototype.nodeCount=function(){return this._nodeCount},n.prototype.nodes=function(){return t.keys(this._nodes)},n.prototype.sources=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._in[n])}))},n.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._out[n])}))},n.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},n.prototype.setNode=function(n,r){return t.has(this._nodes,n)?(arguments.length>1&&(this._nodes[n]=r),this):(this._nodes[n]=arguments.length>1?r:this._defaultNodeLabelFn(n),this._isCompound&&(this._parent[n]=e,this._children[n]={},this._children[e][n]=!0),this._in[n]={},this._preds[n]={},this._out[n]={},this._sucs[n]={},++this._nodeCount,this)},n.prototype.node=function(t){return this._nodes[t]},n.prototype.hasNode=function(e){return t.has(this._nodes,e)},n.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},n.prototype.setParent=function(n,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=e;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===n)throw new Error("Setting "+r+" as parent of "+n+" would create a cycle");this.setNode(r)}return this.setNode(n),this._removeFromParentsChildList(n),this._parent[n]=r,this._children[r][n]=!0,this},n.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},n.prototype.parent=function(t){if(this._isCompound){var n=this._parent[t];if(n!==e)return n}},n.prototype.children=function(n){if(t.isUndefined(n)&&(n=e),this._isCompound){var r=this._children[n];if(r)return t.keys(r)}else{if(n===e)return this.nodes();if(this.hasNode(n))return[]}},n.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},n.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},n.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},n.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},n.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},n.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},n.prototype.edgeCount=function(){return this._edgeCount},n.prototype.edges=function(){return t.values(this._edgeObjs)},n.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},n.prototype.setEdge=function(){var e,n,i,a,s=!1,l=arguments[0];"object"==typeof l&&null!==l&&"v"in l?(e=l.v,n=l.w,i=l.name,2===arguments.length&&(a=arguments[1],s=!0)):(e=l,n=arguments[1],i=arguments[3],arguments.length>2&&(a=arguments[2],s=!0)),e=""+e,n=""+n,t.isUndefined(i)||(i=""+i);var u=o(this._isDirected,e,n,i);if(t.has(this._edgeLabels,u))return s&&(this._edgeLabels[u]=a),this;if(!t.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[u]=s?a:this._defaultEdgeLabelFn(e,n,i);var c=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,i);return e=c.v,n=c.w,Object.freeze(c),this._edgeObjs[u]=c,r(this._preds[n],e),r(this._sucs[e],n),this._in[n][u]=c,this._out[e][u]=c,this._edgeCount++,this},n.prototype.edge=function(t,e,n){var r=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,t,e,n);return this._edgeLabels[r]},n.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},n.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,t,e,n),s=this._edgeObjs[r];return s&&(t=s.v,e=s.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[e],t),i(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},n.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}},n.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}},n.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},zA}function XP(){return YA?HA:(YA=1,HA={Graph:qP(),version:WA?VA:(WA=1,VA="2.1.8")})}function KP(){if($A)return UA;$A=1;var t=$P(),e=qP();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 UA={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 ZP(){if(XA)return qA;XA=1;var t=$P();return qA=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},qA}function QP(){if(ZA)return KA;ZA=1;var t=$P();function e(){this._arr=[],this._keyIndices={}}return KA=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},KA}function JP(){if(JA)return QA;JA=1;var t=$P(),e=QP();QA=function(t,r,i,o){return function(t,n,r,i){var o,a,s={},l=new e,u=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),u=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);u<n.distance&&(n.distance=u,n.predecessor=o,l.decrease(e,u))};t.nodes().forEach((function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},l.add(t,e)}));for(;l.size()>0&&(o=l.removeMin(),(a=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(u);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return QA}function tR(){if(eC)return tC;eC=1;var t=JP(),e=$P();return tC=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function eR(){if(rC)return nC;rC=1;var t=$P();return nC=function(e){var n=0,r=[],i={},o=[];function a(s){var l=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&&(l.lowlink=Math.min(l.lowlink,i[e].index)):(a(e),l.lowlink=Math.min(l.lowlink,i[e].lowlink))})),l.lowlink===l.index){var u,c=[];do{u=r.pop(),i[u].onStack=!1,c.push(u)}while(s!==u);o.push(c)}}return e.nodes().forEach((function(e){t.has(i,e)||a(e)})),o},nC}function nR(){if(oC)return iC;oC=1;var t=$P(),e=eR();return iC=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function rR(){if(sC)return aC;sC=1;var t=$P();aC=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 aC}function iR(){if(uC)return lC;uC=1;var t=$P();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 lC=e,e.CycleException=n,n.prototype=new Error,lC}function oR(){if(hC)return cC;hC=1;var t=iR();return cC=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function aR(){if(fC)return dC;fC=1;var t=$P();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 dC=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},dC}function sR(){if(gC)return pC;gC=1;var t=aR();return pC=function(e,n){return t(e,n,"post")}}function lR(){if(mC)return vC;mC=1;var t=aR();return vC=function(e,n){return t(e,n,"pre")}}function uR(){if(bC)return yC;bC=1;var t=$P(),e=qP(),n=QP();return yC=function(r,i){var o,a=new e,s={},l=new n;function u(t){var e=t.v===o?t.w:t.v,n=l.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,l.decrease(e,r))}}if(0===r.nodeCount())return a;t.each(r.nodes(),(function(t){l.add(t,Number.POSITIVE_INFINITY),a.setNode(t)})),l.decrease(r.nodes()[0],0);var c=!1;for(;l.size()>0;){if(o=l.removeMin(),t.has(s,o))a.setEdge(o,s[o]);else{if(c)throw new Error("Input graph is not connected: "+r);c=!0}r.nodeEdges(o).forEach(u)}return a}}try{MC=function(){if(kC)return wC;kC=1;var t=XP();return wC={Graph:t.Graph,json:KP(),alg:EC?xC:(EC=1,xC={components:ZP(),dijkstra:JP(),dijkstraAll:tR(),findCycles:nR(),floydWarshall:rR(),isAcyclic:oR(),postorder:sR(),preorder:lR(),prim:uR(),tarjan:eR(),topsort:iR()}),version:t.version}}()}catch(t){}MC||(MC=window.graphlib);var cR,hR,dR,fR,pR,gR,vR,mR,yR,bR,xR,ER,wR,kR,MR,SR,NR,OR,TR,AR,CR,PR,RR,DR,LR,_R,IR,jR,BR,FR,zR,GR,VR,WR,HR,YR,UR,$R,qR,XR,KR,ZR,QR,JR,tD,eD,nD,rD,iD,oD,aD,sD,lD,uD,cD,hD,dD,fD,pD,gD,vD,mD,yD,bD,xD,ED,wD,kD,MD,SD,ND,OD,TD,AD,CD,PD,RD,DD,LD,_D,ID,jD,BD,FD,zD,GD,VD,WD,HD,YD,UD,$D,qD,XD=MC;function KD(){if(fR)return dR;fR=1;var t=Wk(),e=hS(),n=TM(),r=Kk();return dR=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)},dR}function ZD(){if(ER)return xR;ER=1;var t=function(){if(bR)return yR;bR=1;var t=/\s/;return yR=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},yR}(),e=/^\s+/;return xR=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function QD(){if(SR)return MR;SR=1;var t=function(){if(kR)return wR;kR=1;var t=ZD(),e=Kk(),n=dP(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return wR=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var l="function"==typeof s.valueOf?s.valueOf():s;s=e(l)?l+"":l}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var u=i.test(s);return u||o.test(s)?a(s.slice(2),u?2:8):r.test(s)?NaN:+s}}(),e=1/0;return MR=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 JD(){if(AR)return TR;AR=1;var t=zP(),e=SP(),n=function(){if(OR)return NR;OR=1;var t=QD();return NR=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return TR=function(i,o,a){var s=null==i?0:i.length;if(!s)return-1;var l=null==a?0:n(a);return l<0&&(l=r(s+l,0)),t(i,e(o,3),l)},TR}function tL(){if(DR)return RR;DR=1;var t=IP();return RR=function(e){return(null==e?0:e.length)?t(e,1):[]}}function eL(){if(GR)return zR;GR=1;var t=dP();return zR=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===l?s==s&&!t(s):r(s,l)))var l=s,u=a}return u},zR}function nL(){if($R)return UR;$R=1;var t=uM(),e=Wk();return UR=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function rL(){if(ZR)return KR;return ZR=1,KR=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function iL(){if(eD)return tD;eD=1;var t=nL(),e=NC(),n=zC(),r=OC(),i=WC(),o=fM(),a=pM(),s=HP(),l=OM(),u=Zk(),c=Kk(),h=function(){if(XR)return qR;XR=1;var t=Xk(),e=RC(),n=dM(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return qR=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var l=a.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==s}}(),d=aS(),f=rL(),p=function(){if(JR)return QR;JR=1;var t=hM(),e=pS();return QR=function(n){return t(n,e(n))}}();return tD=function(g,v,m,y,b,x,E){var w=f(g,m),k=f(v,m),M=E.get(k);if(M)t(g,m,M);else{var S=x?x(w,k,m+"",g,v,E):void 0,N=void 0===S;if(N){var O=a(k),T=!O&&l(k),A=!O&&!T&&d(k);S=k,O||T||A?a(w)?S=w:s(w)?S=r(w):T?(N=!1,S=e(k,!0)):A?(N=!1,S=n(k,!0)):S=[]:h(k)||o(k)?(S=w,o(w)?S=p(w):c(w)&&!u(w)||(S=i(k))):N=!1}N&&(E.set(k,S),b(S,k,y,x,E),E.delete(k)),t(g,m,S)}}}function oL(){if(uD)return lD;return uD=1,lD=function(t,e){return t<e}}function aL(){if(bD)return yD;bD=1;var t=bP(),e=function(){if(mD)return vD;mD=1;var t=cM(),e=mP(),n=TM(),r=Kk(),i=yP();return vD=function(o,a,s,l){if(!r(o))return o;for(var u=-1,c=(a=e(a,o)).length,h=c-1,d=o;null!=d&&++u<c;){var f=i(a[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(u!=h){var g=d[f];void 0===(p=l?l(g,f,d):void 0)&&(p=r(g)?g:n(a[u+1])?[]:{})}t(d,f,p),d=d[f]}return o},vD}(),n=mP();return yD=function(r,i,o){for(var a=-1,s=i.length,l={};++a<s;){var u=i[a],c=t(r,u);o(c,u)&&e(l,n(u,r),c)}return l},yD}function sL(){if(AD)return TD;AD=1;var t=function(){if(OD)return ND;OD=1;var t=Math.ceil,e=Math.max;return ND=function(n,r,i,o){for(var a=-1,s=e(t((r-n)/(i||1)),0),l=Array(s);s--;)l[o?s:++a]=n,n+=i;return l},ND}(),e=KD(),n=QD();return TD=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)}},TD}function lL(){if(jD)return ID;jD=1;var t=function(){if(_D)return LD;_D=1;var t=dP();return LD=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,a=t(e),s=void 0!==n,l=null===n,u=n==n,c=t(n);if(!l&&!c&&!a&&e>n||a&&s&&u&&!l&&!c||i&&s&&u||!r&&u||!o)return 1;if(!i&&!a&&!c&&e<n||c&&r&&o&&!i&&!a||l&&r&&o||!s&&o||!u)return-1}return 0}}();return ID=function(e,n,r){for(var i=-1,o=e.criteria,a=n.criteria,s=o.length,l=r.length;++i<s;){var u=t(o[i],a[i]);if(u)return i>=l?u:u*("desc"==r[i]?-1:1)}return e.index-n.index},ID}function uL(){if(FD)return BD;FD=1;var t=gP(),e=bP(),n=SP(),r=CP(),i=(DD||(DD=1,RD=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),RD),o=CM(),a=lL(),s=QC(),l=pM();return BD=function(u,c,h){c=c.length?t(c,(function(t){return l(t)?function(n){return e(n,1===t.length?t[0]:t)}:t})):[s];var d=-1;c=t(c,o(n));var f=r(u,(function(e,n,r){return{criteria:t(c,(function(t){return t(e)})),index:++d,value:e}}));return i(f,(function(t,e){return a(t,e,h)}))},BD}try{qD={cloneDeep:function(){if(hR)return cR;hR=1;var t=UC();return cR=function(e){return t(e,5)}}(),constant:qC(),defaults:function(){if(gR)return pR;gR=1;var t=FP(),e=Wk(),n=KD(),r=pS(),i=Object.prototype,o=i.hasOwnProperty,a=t((function(t,a){t=Object(t);var s=-1,l=a.length,u=l>2?a[2]:void 0;for(u&&n(a[0],a[1],u)&&(l=1);++s<l;)for(var c=a[s],h=r(c),d=-1,f=h.length;++d<f;){var p=h[d],g=t[p];(void 0===g||e(g,i[p])&&!o.call(t,p))&&(t[p]=c[p])}return t}));return pR=a}(),each:eP(),filter:NP(),find:function(){if(PR)return CR;PR=1;var t=function(){if(mR)return vR;mR=1;var t=SP(),e=hS(),n=dS();return vR=function(r){return function(i,o,a){var s=Object(i);if(!e(i)){var l=t(o,3);i=n(i),o=function(t){return l(s[t],t,s)}}var u=r(i,o,a);return u>-1?s[l?i[u]:u]:void 0}},vR}(),e=t(JD());return CR=e}(),flatten:tL(),forEach:tP(),forIn:function(){if(_R)return LR;_R=1;var t=XC(),e=JC(),n=pS();return LR=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:OP(),isUndefined:AP(),last:(jR||(jR=1,IR=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),IR),map:PP(),mapValues:function(){if(FR)return BR;FR=1;var t=uM(),e=KC(),n=SP();return BR=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(YR)return HR;YR=1;var t=eL(),e=WR?VR:(WR=1,VR=function(t,e){return t>e}),n=QC();return HR=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(sD)return aD;sD=1;var t=function(){if(rD)return nD;rD=1;var t=aM(),e=nL(),n=XC(),r=iL(),i=Kk(),o=pS(),a=rL();return nD=function s(l,u,c,h,d){l!==u&&n(u,(function(n,o){if(d||(d=new t),i(n))r(l,u,o,c,s,h,d);else{var f=h?h(a(l,o),n,o+"",l,u,d):void 0;void 0===f&&(f=n),e(l,o,f)}}),o)},nD}(),e=function(){if(oD)return iD;oD=1;var t=FP(),e=KD();return iD=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 l=r[i];l&&n(t,l,i,a)}return t}))},iD}(),n=e((function(e,n,r){t(e,n,r)}));return aD=n}(),min:function(){if(hD)return cD;hD=1;var t=eL(),e=oL(),n=QC();return cD=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(fD)return dD;fD=1;var t=eL(),e=SP(),n=oL();return dD=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(gD)return pD;gD=1;var t=$k();return pD=function(){return t.Date.now()}}(),pick:function(){if(SD)return MD;SD=1;var t=function(){if(ED)return xD;ED=1;var t=aL(),e=EP();return xD=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(kD)return wD;kD=1;var t=tL(),e=jP(),n=BP();return wD=function(r){return n(e(r,void 0,t),r+"")}}()((function(e,n){return null==e?{}:t(e,n)}));return MD=e}(),range:function(){if(PD)return CD;PD=1;var t=sL()();return CD=t}(),reduce:RP(),sortBy:function(){if(GD)return zD;GD=1;var t=IP(),e=uL(),n=FP(),r=KD(),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 zD=i}(),uniqueId:function(){if(WD)return VD;WD=1;var t=vP(),e=0;return VD=function(n){var r=++e;return t(n)+r},VD}(),values:UP(),zipObject:function(){if($D)return UD;$D=1;var t=cM(),e=(YD||(YD=1,HD=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}),HD);return UD=function(n,r){return e(n||[],r||[],t)},UD}()}}catch(t){}qD||(qD=window._);var cL=qD,hL=dL;function dL(){var t={};t._next=t._prev=t,this._sentinel=t}function fL(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function pL(t,e){if("_next"!==t&&"_prev"!==t)return e}dL.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return fL(e),e},dL.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&fL(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},dL.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,pL)),n=n._prev;return"["+t.join(", ")+"]"};var gL=cL,vL=XD.Graph,mL=hL,yL=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new vL,r=0,i=0;gL.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),gL.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=gL.range(i+r+3).map((function(){return new mL})),a=r+1;return gL.forEach(n.nodes(),(function(t){EL(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||bL),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)xL(t,e,n,r);for(;r=o.dequeue();)xL(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(xL(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return gL.flatten(gL.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},bL=gL.constant(1);function xL(t,e,n,r,i){var o=i?[]:void 0;return gL.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,EL(e,n,s)})),gL.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,EL(e,n,a)})),t.removeNode(r.v),o}function EL(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 wL=cL,kL=yL,ML={run:function(t){var e="greedy"===t.graph().acyclicer?kL(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){wL.has(r,o)||(r[o]=!0,n[o]=!0,wL.forEach(t.outEdges(o),(function(t){wL.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return wL.forEach(t.nodes(),i),e}(t);wL.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,wL.uniqueId("rev"))}))},undo:function(t){wL.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 SL=cL,NL=XD.Graph,OL={addDummyNode:TL,simplify:function(t){var e=(new NL).setGraph(t.graph());return SL.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),SL.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 NL({multigraph:t.isMultigraph()}).setGraph(t.graph());return SL.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),SL.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=SL.map(t.nodes(),(function(e){var n={};return SL.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return SL.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=SL.map(t.nodes(),(function(e){var n={};return SL.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return SL.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,l=t.width/2,u=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*l>Math.abs(a)*u?(s<0&&(u=-u),n=u*a/s,r=u):(a<0&&(l=-l),n=l,r=l*s/a);return{x:i+n,y:o+r}},buildLayerMatrix:function(t){var e=SL.map(SL.range(AL(t)+1),(function(){return[]}));return SL.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;SL.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=SL.min(SL.map(t.nodes(),(function(e){return t.node(e).rank})));SL.forEach(t.nodes(),(function(n){var r=t.node(n);SL.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=SL.min(SL.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];SL.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;SL.forEach(n,(function(e,n){SL.isUndefined(e)&&n%i!=0?--r:r&&SL.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 TL(t,"border",i,e)},maxRank:AL,partition:function(t,e){var n={lhs:[],rhs:[]};return SL.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=SL.now();try{return e()}finally{console.log(t+" time: "+(SL.now()-n)+"ms")}},notime:function(t,e){return e()}};function TL(t,e,n,r){var i;do{i=SL.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function AL(t){return SL.max(SL.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!SL.isUndefined(n))return n})))}var CL=cL,PL=OL,RL={run:function(t){t.graph().dummyChains=[],CL.forEach(t.edges(),(function(e){!function(t,e){var n,r,i,o=e.v,a=t.node(o).rank,s=e.w,l=t.node(s).rank,u=e.name,c=t.edge(e),h=c.labelRank;if(l===a+1)return;for(t.removeEdge(e),i=0,++a;a<l;++i,++a)c.points=[],r={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},n=PL.addDummyNode(t,"edge",r,"_d"),a===h&&(r.width=c.width,r.height=c.height,r.dummy="edge-label",r.labelpos=c.labelpos),t.setEdge(o,n,{weight:c.weight},u),0===i&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,s,{weight:c.weight},u)}(t,e)}))},undo:function(t){CL.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 DL=cL,LL={longestPath:function(t){var e={};DL.forEach(t.sources(),(function n(r){var i=t.node(r);if(DL.has(e,r))return i.rank;e[r]=!0;var o=DL.min(DL.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 _L=cL,IL=XD.Graph,jL=LL.slack,BL=function(t){var e,n,r=new IL({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;FL(r,t)<o;)e=zL(r,t),n=r.hasNode(e.v)?jL(t,e):-jL(t,e),GL(r,t,n);return r};function FL(t,e){return _L.forEach(t.nodes(),(function n(r){_L.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||jL(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function zL(t,e){return _L.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return jL(e,n)}))}function GL(t,e,n){_L.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var VL=cL,WL=BL,HL=LL.slack,YL=LL.longestPath,UL=XD.alg.preorder,$L=XD.alg.postorder,qL=OL.simplify,XL=KL;function KL(t){t=qL(t),YL(t);var e,n=WL(t);for(JL(n),ZL(n,t);e=e_(n);)r_(n,t,e,n_(n,t,e))}function ZL(t,e){var n=$L(t,t.nodes());n=n.slice(0,n.length-1),VL.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=QL(t,e,n)}(t,e,n)}))}function QL(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,VL.forEach(e.nodeEdges(n),(function(o){var s,l,u=o.v===n,c=u?o.w:o.v;if(c!==r){var h=u===i,d=e.edge(o).weight;if(a+=h?d:-d,s=n,l=c,t.hasEdge(s,l)){var f=t.edge(n,c).cutvalue;a+=h?-f:f}}})),a}function JL(t,e){arguments.length<2&&(e=t.nodes()[0]),t_(t,{},1,e)}function t_(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,VL.forEach(t.neighbors(r),(function(i){VL.has(e,i)||(n=t_(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function e_(t){return VL.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function n_(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,l=!1;o.lim>a.lim&&(s=a,l=!0);var u=VL.filter(e.edges(),(function(e){return l===i_(t,t.node(e.v),s)&&l!==i_(t,t.node(e.w),s)}));return VL.minBy(u,(function(t){return HL(e,t)}))}function r_(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),JL(t),ZL(t,e),function(t,e){var n=VL.find(t.nodes(),(function(t){return!e.node(t).parent})),r=UL(t,n);r=r.slice(1),VL.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 i_(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}KL.initLowLimValues=JL,KL.initCutValues=ZL,KL.calcCutValue=QL,KL.leaveEdge=e_,KL.enterEdge=n_,KL.exchangeEdges=r_;var o_=LL.longestPath,a_=BL,s_=XL,l_=function(t){switch(t.graph().ranker){case"network-simplex":default:c_(t);break;case"tight-tree":!function(t){o_(t),a_(t)}(t);break;case"longest-path":u_(t)}};var u_=o_;function c_(t){s_(t)}var h_=cL,d_=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;h_.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return h_.forEach(t.children(),r),e}(t);h_.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=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),a.push(i)}while(i&&(e[i].low>l||u>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,l=0,u=a[l],c=!0;n!==i.w;){if(r=t.node(n),c){for(;(u=a[l])!==s&&t.node(u).maxRank<r.rank;)l++;u===s&&(c=!1)}if(!c){for(;l<a.length-1&&t.node(u=a[l+1]).minRank<=r.rank;)l++;u=a[l]}t.setParent(n,u),n=t.successors(n)[0]}}))};var f_=cL,p_=OL,g_={run:function(t){var e=p_.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&f_.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return f_.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=f_.max(f_.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,f_.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return f_.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;f_.forEach(t.children(),(function(a){v_(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,f_.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function v_(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var l=p_.addBorderNode(t,"_bt"),u=p_.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(l,a),c.borderTop=l,t.setParent(u,a),c.borderBottom=u,f_.forEach(s,(function(s){v_(t,e,n,r,i,o,s);var c=t.node(s),h=c.borderTop?c.borderTop:s,d=c.borderBottom?c.borderBottom:s,f=c.borderTop?r:2*r,p=h!==d?1:i-o[a]+1;t.setEdge(l,h,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(d,u,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,l,{weight:0,minlen:i+o[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:n})}var m_=cL,y_=OL,b_=function(t){m_.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&m_.forEach(r,e),m_.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)x_(t,"borderLeft","_bl",n,i,o),x_(t,"borderRight","_br",n,i,o)}}))};function x_(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],l=y_.addDummyNode(t,"border",a,n);i[e][o]=l,t.setParent(l,r),s&&t.setEdge(s,l,{weight:1})}var E_=cL,w_={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||k_(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){E_.forEach(t.nodes(),(function(e){S_(t.node(e))})),E_.forEach(t.edges(),(function(e){var n=t.edge(e);E_.forEach(n.points,S_),E_.has(n,"y")&&S_(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){E_.forEach(t.nodes(),(function(e){N_(t.node(e))})),E_.forEach(t.edges(),(function(e){var n=t.edge(e);E_.forEach(n.points,N_),E_.has(n,"x")&&N_(n)}))}(t),k_(t))}};function k_(t){E_.forEach(t.nodes(),(function(e){M_(t.node(e))})),E_.forEach(t.edges(),(function(e){M_(t.edge(e))}))}function M_(t){var e=t.width;t.width=t.height,t.height=e}function S_(t){t.y=-t.y}function N_(t){var e=t.x;t.x=t.y,t.y=e}var O_=cL,T_=function(t){var e={},n=O_.filter(t.nodes(),(function(e){return!t.children(e).length})),r=O_.max(O_.map(n,(function(e){return t.node(e).rank}))),i=O_.map(O_.range(r+1),(function(){return[]}));function o(n){if(!O_.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),O_.forEach(t.successors(n),o)}}var a=O_.sortBy(n,(function(e){return t.node(e).rank}));return O_.forEach(a,o),i};var A_=cL,C_=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=P_(t,e[r-1],e[r]);return n};function P_(t,e,n){for(var r=A_.zipObject(n,A_.map(n,(function(t,e){return e}))),i=A_.flatten(A_.map(e,(function(e){return A_.sortBy(A_.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=A_.map(new Array(a),(function(){return 0})),l=0;return A_.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;l+=t.weight*n}))),l}var R_=cL;var D_=cL,L_=function(t,e){var n={};return D_.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};D_.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),D_.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];D_.isUndefined(e)||D_.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(D_.isUndefined(e.barycenter)||D_.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),D_.forEach(i.in.reverse(),n(i)),D_.forEach(i.out,r(i))}return D_.map(D_.filter(e,(function(t){return!t.merged})),(function(t){return D_.pick(t,["vs","i","barycenter","weight"])}))}(D_.filter(n,(function(t){return!t.indegree})))};var __=cL,I_=OL;function j_(t,e,n){for(var r;e.length&&(r=__.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var B_=cL,F_=function(t,e){return R_.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=R_.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}}))},z_=L_,G_=function(t,e){var n=I_.partition(t,(function(t){return __.has(t,"barycenter")})),r=n.lhs,i=__.sortBy(n.rhs,(function(t){return-t.i})),o=[],a=0,s=0,l=0;r.sort((u=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:u?e.i-t.i:t.i-e.i})),l=j_(o,i,l),__.forEach(r,(function(t){l+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,l=j_(o,i,l)}));var u;var c={vs:__.flatten(o,!0)};s&&(c.barycenter=a/s,c.weight=s);return c},V_=function t(e,n,r,i){var o=e.children(n),a=e.node(n),s=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,u={};s&&(o=B_.filter(o,(function(t){return t!==s&&t!==l})));var c=F_(e,o);B_.forEach(c,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);u[n.v]=o,B_.has(o,"barycenter")&&(a=n,s=o,B_.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 h=z_(c,r);!function(t,e){B_.forEach(t,(function(t){t.vs=B_.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,u);var d=G_(h,i);if(s&&(d.vs=B_.flatten([s,d.vs,l],!0),e.predecessors(s).length)){var f=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(l)[0]);B_.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 W_=cL,H_=XD.Graph,Y_=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=W_.uniqueId("_root")););return e}(t),i=new H_({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return W_.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),W_.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=W_.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),W_.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var U_=cL;var $_=cL,q_=T_,X_=C_,K_=V_,Z_=Y_,Q_=function(t,e,n){var r,i={};U_.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}}))},J_=XD.Graph,tI=OL,eI=function(t){var e=tI.maxRank(t),n=nI(t,$_.range(1,e+1),"inEdges"),r=nI(t,$_.range(e-1,-1,-1),"outEdges"),i=q_(t);iI(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,l=0;l<4;++s,++l){rI(s%2?n:r,s%4>=2),i=tI.buildLayerMatrix(t);var u=X_(t,i);u<a&&(l=0,o=$_.cloneDeep(i),a=u)}iI(t,o)};function nI(t,e,n){return $_.map(e,(function(e){return Z_(t,e,n)}))}function rI(t,e){var n=new J_;$_.forEach(t,(function(t){var r=t.graph().root,i=K_(t,r,n,e);$_.forEach(i.vs,(function(e,n){t.node(e).order=n})),Q_(t,n,i.vs)}))}function iI(t,e){$_.forEach(e,(function(e){$_.forEach(e,(function(e,n){t.node(e).order=n}))}))}var oI=cL,aI=XD.Graph,sI=OL,lI=function(t){var e,n=sI.buildLayerMatrix(t),r=oI.merge(uI(t,n),cI(t,n)),i={};oI.forEach(["u","d"],(function(o){e="u"===o?n:oI.values(n).reverse(),oI.forEach(["l","r"],(function(n){"r"===n&&(e=oI.map(e,(function(t){return oI.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=fI(t,e,r,a),l=pI(t,e,s.root,s.align,"r"===n);"r"===n&&(l=oI.mapValues(l,(function(t){return-t}))),i[o+n]=l}))}));var o=gI(t,i);return vI(i,o),mI(i,t.graph().align)};function uI(t,e){var n={};return oI.reduce(e,(function(e,r){var i=0,o=0,a=e.length,s=oI.last(r);return oI.forEach(r,(function(e,l){var u=function(t,e){if(t.node(e).dummy)return oI.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=u?t.node(u).order:a;(u||e===s)&&(oI.forEach(r.slice(o,l+1),(function(e){oI.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||c<a)||o.dummy&&t.node(e).dummy||hI(n,r,e)}))})),o=l+1,i=c)})),r})),n}function cI(t,e){var n={};function r(e,r,i,o,a){var s;oI.forEach(oI.range(r,i),(function(r){s=e[r],t.node(s).dummy&&oI.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&hI(n,e,s)}))}))}return oI.reduce(e,(function(e,n){var i,o=-1,a=0;return oI.forEach(n,(function(s,l){if("border"===t.node(s).dummy){var u=t.predecessors(s);u.length&&(i=t.node(u[0]).order,r(n,a,l,o,i),a=l,o=i)}r(n,a,n.length,i,e.length)})),n})),n}function hI(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 dI(t,e,n){if(e>n){var r=e;e=n,n=r}return oI.has(t[e],n)}function fI(t,e,n,r){var i={},o={},a={};return oI.forEach(e,(function(t){oI.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),oI.forEach(e,(function(t){var e=-1;oI.forEach(t,(function(t){var s=r(t);if(s.length){s=oI.sortBy(s,(function(t){return a[t]}));for(var l=(s.length-1)/2,u=Math.floor(l),c=Math.ceil(l);u<=c;++u){var h=s[u];o[t]===t&&e<a[h]&&!dI(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}function pI(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new aI,o=t.graph(),a=function(t,e,n){return function(r,i,o){var a,s=r.node(i),l=r.node(o),u=0;if(u+=s.width/2,oI.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2}if(a&&(u+=n?a:-a),a=0,u+=(s.dummy?e:t)/2,u+=(l.dummy?e:t)/2,u+=l.width/2,oI.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2}return a&&(u+=n?a:-a),a=0,u}}(o.nodesep,o.edgesep,r);return oI.forEach(e,(function(e){var r;oI.forEach(e,(function(e){var o=n[e];if(i.setNode(o),r){var s=n[r],l=i.edge(s,o);i.setEdge(s,o,Math.max(a(t,e,r),l||0))}r=e}))})),i}(t,e,n,i),s=i?"borderLeft":"borderRight";function l(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 l((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)),l((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)),oI.forEach(r,(function(t){o[t]=o[n[t]]})),o}function gI(t,e){return oI.minBy(oI.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return oI.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 vI(t,e){var n=oI.values(e),r=oI.min(n),i=oI.max(n);oI.forEach(["u","d"],(function(n){oI.forEach(["l","r"],(function(o){var a,s=n+o,l=t[s];if(l!==e){var u=oI.values(l);(a="l"===o?r-oI.min(u):i-oI.max(u))&&(t[s]=oI.mapValues(l,(function(t){return t+a})))}}))}))}function mI(t,e){return oI.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=oI.sortBy(oI.map(t,r));return(i[1]+i[2])/2}))}var yI=cL,bI=OL,xI=lI,EI=function(t){(function(t){var e=bI.buildLayerMatrix(t),n=t.graph().ranksep,r=0;yI.forEach(e,(function(e){var i=yI.max(yI.map(e,(function(e){return t.node(e).height})));yI.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=bI.asNonCompoundGraph(t)),yI.forEach(xI(t),(function(e,n){t.node(n).x=e}))};var wI=cL,kI=ML,MI=RL,SI=l_,NI=OL.normalizeRanks,OI=d_,TI=OL.removeEmptyRanks,AI=g_,CI=b_,PI=w_,RI=eI,DI=EI,LI=OL,_I=XD.Graph,II=function(t,e){var n=e&&e.debugTiming?LI.time:LI.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new _I({multigraph:!0,compound:!0}),n=UI(t.graph());return e.setGraph(wI.merge({},BI,YI(n,jI),wI.pick(n,FI))),wI.forEach(t.nodes(),(function(n){var r=UI(t.node(n));e.setNode(n,wI.defaults(YI(r,zI),GI)),e.setParent(n,t.parent(n))})),wI.forEach(t.edges(),(function(n){var r=UI(t.edge(n));e.setEdge(n,wI.merge({},WI,YI(r,VI),wI.pick(r,HI)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,wI.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){wI.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(){kI.run(t)})),e(" nestingGraph.run",(function(){AI.run(t)})),e(" rank",(function(){SI(LI.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){wI.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};LI.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){TI(t)})),e(" nestingGraph.cleanup",(function(){AI.cleanup(t)})),e(" normalizeRanks",(function(){NI(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;wI.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=wI.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){wI.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(){MI.run(t)})),e(" parentDummyChains",(function(){OI(t)})),e(" addBorderSegments",(function(){CI(t)})),e(" order",(function(){RI(t)})),e(" insertSelfEdges",(function(){!function(t){var e=LI.buildLayerMatrix(t);wI.forEach(e,(function(e){var n=0;wI.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,wI.forEach(i.selfEdges,(function(e){LI.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(){PI.adjust(t)})),e(" position",(function(){DI(t)})),e(" positionSelfEdges",(function(){!function(t){wI.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){wI.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(wI.last(n.borderLeft)),a=t.node(wI.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}})),wI.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){MI.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){wI.forEach(t.edges(),(function(e){var n=t.edge(e);if(wI.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(){PI.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 l(t){var o=t.x,a=t.y,s=t.width,l=t.height;e=Math.min(e,o-s/2),n=Math.max(n,o+s/2),r=Math.min(r,a-l/2),i=Math.max(i,a+l/2)}wI.forEach(t.nodes(),(function(e){l(t.node(e))})),wI.forEach(t.edges(),(function(e){var n=t.edge(e);wI.has(n,"x")&&l(n)})),e-=a,r-=s,wI.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),wI.forEach(t.edges(),(function(n){var i=t.edge(n);wI.forEach(i.points,(function(t){t.x-=e,t.y-=r})),wI.has(i,"x")&&(i.x-=e),wI.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){wI.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(LI.intersectRect(o,n)),i.points.push(LI.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){wI.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){kI.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){wI.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))})),wI.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,wI.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 jI=["nodesep","edgesep","ranksep","marginx","marginy"],BI={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},FI=["acyclicer","ranker","rankdir","align"],zI=["width","height"],GI={width:0,height:0},VI=["minlen","weight","width","height","labeloffset"],WI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},HI=["labelpos"];function YI(t,e){return wI.mapValues(wI.pick(t,e),Number)}function UI(t){var e={};return wI.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var $I=cL,qI=OL,XI=XD.Graph,KI={debugOrdering:function(t){var e=qI.buildLayerMatrix(t),n=new XI({compound:!0,multigraph:!0}).setGraph({});return $I.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),$I.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),$I.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),$I.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var ZI={graphlib:XD,layout:II,debug:KI,util:{time:OL.time,notime:OL.notime},version:"0.8.5"},QI=E(ZI);class JI{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,JI.defaultOptions,t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{nodeSize:r}=n,i=new ZI.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>ae(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]=cb(Yt(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})})),QI.layout(i);const o={nodes:[],edges:[]};return i.nodes().forEach((n=>{const r=i.node(n);o.nodes.push({id:n,data:r}),t&&e.mergeNodeData(n,r)})),i.edges().forEach((n=>{const r=i.edge(n),{id:a}=r,s=Fe(r,["id"]),{v:l,w:u}=n;o.edges.push({id:a,source:l,target:u,data:s}),t&&e.mergeEdgeData(a,s)})),o}))}}JI.defaultOptions={};class tj{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 tj({rx:n,ry:r,mass:e,degree:i})}}class ej{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 ej({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 ej({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 ej({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 ej({xmid:t,ymid:e,length:n})}}class nj{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 nj(this.quad.NW()),this.NE=new nj(this.quad.NE()),this.SW=new nj(this.quad.SW()),this.SE=new nj(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 rj={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};class ij{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},rj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceAtlas2Layout(!0,t,e)}))}genericForceAtlas2Layout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),{width:a,height:s,prune:l,maxIteration:u,nodeSize:c,center:h}=o;if(!(null==i?void 0:i.length)||1===i.length)return mb(e,t,h);const d=i.map((t=>ub(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Yg({nodes:d,edges:f}),g=this.getSizes(p,c);if(this.run(p,e,u,g,t,o),l){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){const n=t.getAllNodes(),r={};for(let t=0;t<n.length;t+=1){const i=n[t];r[i.id]=fb(e,void 0)(i)}return r}formatOptions(t={},e){const n=Object.assign(Object.assign({},this.options),t),{center:r,width:i,height:o,barnesHut:a,prune:s,maxIteration:l,kr:u,kg:c}=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!==l||s?0===l&&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)),u||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n}run(t,e,n,r,i,o){const{kr:a,barnesHut:s,onTick:l}=o,u=t.getAllNodes();let c=0,h=n;const d={},f={},p={};for(let e=0;e<u.length;e+=1){const{data:n,id:r}=u[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 tj(i)}}for(;h>0;)c=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:c,forces:d,preForces:f,bodies:p,sizes:r},o),h--,null==l||l({nodes:u,edges:e.getAllEdges()});return t}oneStep(t,e,n){const{iter:r,preventOverlapIters:i,krPrime:o,sg:a,preForces:s,bodies:l,sizes:u}=e;let{forces:c}=e;const{preventOverlap:h,barnesHut:d}=n,f=t.getAllNodes();for(let t=0;t<f.length;t+=1){const{id:e}=f[t];s[e]=[...c[e]],c[e]=[0,0]}return c=this.getAttrForces(t,r,i,u,c,n),c=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,c,l,n):this.getRepGraForces(t,r,i,c,o,u,n),this.updatePos(t,c,s,a,n)}getAttrForces(t,e,n,r,i,o){const{preventOverlap:a,dissuadeHubs:s,mode:l,prune:u}=o,c=t.getAllEdges();for(let o=0;o<c.length;o+=1){const{source:h,target:d}=c[o],f=t.getNode(h),p=t.getNode(d),g=t.getDegree(h),v=t.getDegree(d);if(u&&(g<=1||v<=1))continue;const m=[p.data.x-f.data.x,p.data.y-f.data.y];let y=Math.hypot(m[0],m[1]);y=y<1e-4?1e-4:y,m[0]=m[0]/y,m[1]=m[1]/y,a&&e<n&&(y=y-r[h]-r[d]);let b=y,x=b;"linlog"===l&&(b=Math.log(1+y),x=b),s&&(b=y/g,x=y/v),a&&e<n&&y<=0?(b=0,x=0):a&&e<n&&y>0&&(b=y,x=y),i[h][0]+=b*m[0],i[d][0]-=x*m[0],i[h][1]+=b*m[1],i[d][1]-=x*m[1]}return i}getOptRepGraForces(t,e,n,r){const{kg:i,center:o,prune:a}=r,s=t.getAllNodes(),l=s.length;let u=9e10,c=-9e10,h=9e10,d=-9e10;for(let e=0;e<l;e+=1){const{id:r,data:i}=s[e];a&&t.getDegree(r)<=1||(n[r].setPos(i.x,i.y),i.x>=c&&(c=i.x),i.x<=u&&(u=i.x),i.y>=d&&(d=i.y),i.y<=h&&(h=i.y))}const f=Math.max(c-u,d-h),p=new ej({xmid:(c+u)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:l}),g=new nj(p);for(let e=0;e<l;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<l;r+=1){const{id:l,data:u}=s[r],c=t.getDegree(l);if(a&&c<=1)continue;n[l].resetForce(),g.updateForce(n[l]),e[l][0]-=n[l].fx,e[l][1]-=n[l].fy;const h=[u.x-o[0],u.y-o[1]];let d=Math.hypot(h[0],h[1]);d=d<1e-4?1e-4:d,h[0]=h[0]/d,h[1]=h[1]/d;const f=i*(c+1);e[l][0]-=f*h[0],e[l][1]-=f*h[1]}return e}getRepGraForces(t,e,n,r,i,o,a){const{preventOverlap:s,kr:l,kg:u,center:c,prune:h}=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 u=a+1;u<f;u+=1){const a=d[u],c=t.getDegree(a.id);if(h&&(g<=1||c<=1))continue;const f=[a.data.x-p.data.x,a.data.y-p.data.y];let v=Math.hypot(f[0],f[1]);v=v<1e-4?1e-4:v,f[0]=f[0]/v,f[1]=f[1]/v,s&&e<n&&(v=v-o[p.id]-o[a.id]);let m=l*(g+1)*(c+1)/v;s&&e<n&&v<0?m=i*(g+1)*(c+1):s&&e<n&&0===v?m=0:s&&e<n&&v>0&&(m=l*(g+1)*(c+1)/v),r[p.id][0]-=m*f[0],r[a.id][0]+=m*f[0],r[p.id][1]-=m*f[1],r[a.id][1]+=m*f[1]}const v=[p.data.x-c[0],p.data.y-c[1]],m=Math.hypot(v[0],v[1]);v[0]=v[0]/m,v[1]=v[1]/m;const y=u*(g+1);r[p.id][0]-=y*v[0],r[p.id][1]-=y*v[1]}return r}updatePos(t,e,n,r,i){const{ks:o,tao:a,prune:s,ksmax:l}=i,u=t.getAllNodes(),c=u.length,h=[],d=[];let f=0,p=0,g=r;for(let r=0;r<c;r+=1){const{id:i}=u[r],o=t.getDegree(i);if(s&&o<=1)continue;const a=[e[i][0]-n[i][0],e[i][1]-n[i][1]],l=Math.hypot(a[0],a[1]),c=[e[i][0]+n[i][0],e[i][1]+n[i][1]],g=Math.hypot(c[0],c[1]);h[r]=l,d[r]=g/2,f+=(o+1)*h[r],p+=(o+1)*d[r]}const v=g;g=a*p/f,0!==v&&(g=g>1.5*v?1.5*v:g);for(let n=0;n<c;n+=1){const{id:r,data:i}=u[n],a=t.getDegree(r);if(s&&a<=1)continue;if(ae(i.fx)&&ae(i.fy))continue;let c=o*g/(1+g*Math.sqrt(h[n])),d=Math.hypot(e[r][0],e[r][1]);d=d<1e-4?1e-4:d;const f=l/d;c=c>f?f:c;const p=c*e[r][0],v=c*e[r][1];t.mergeNodeData(r,{x:i.x+p,y:i.y+v})}return g}}const oj={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};class aj{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},oj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield 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 ze(this,void 0,void 0,(function*(){if(this.running)return;const r=this.formatOptions(n),{dimensions:i,width:o,height:a,center:s,clustering:l,nodeClusterBy:u,maxIteration:c,onTick:h}=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=>ub(t,[o,a]))),g=new Yg({nodes:p,edges:f}),v={};if(l&&p.forEach((t=>{const e=t.data[u];v[e]||(v[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=v,"undefined"==typeof window)return;let m=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(g,v,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==h||h({nodes:p,edges:f}),m++,m>=c&&(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:l,clustering:u,nodeClusterBy:c,clusterGravity:h}=n,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),v=Math.sqrt(g),m={};if(this.applyCalculate(t,m,v,g),u){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[c]];ae(n.x)&&(r.cx+=n.x),ae(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=h||a;p.forEach(((n,r)=>{const{id:i,data:o}=n;if(!ae(o.x)||!ae(o.y))return;const a=e[o[c]],s=Math.sqrt((o.x-a.cx)*(o.x-a.cx)+(o.y-a.cy)*(o.y-a.cy)),l=v*t;m[i].x-=l*(o.x-a.cx)/s,m[i].y-=l*(o.y-a.cy)/s}))}p.forEach(((t,e)=>{const{id:n,data:i}=t;if(!ae(i.x)||!ae(i.y))return;const o=.01*v*a;m[n].x-=o*(i.x-s[0]),m[n].y-=o*(i.y-s[1]),3===r&&(m[n].z-=o*(i.z-s[2]))})),p.forEach(((e,n)=>{const{id:i,data:o}=e;if(ae(o.fx)&&ae(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!ae(o.x)||!ae(o.y))return;const a=Math.sqrt(m[i].x*m[i].x+m[i].y*m[i].y+(3===r?m[i].z*m[i].z:0));if(a>0){const e=Math.min(f*(l/800),a);t.mergeNodeData(i,{x:o.x+m[i].x/a*e,y:o.y+m[i].y/a*e,z:3===r?o.z+m[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||!ae(t.x)||!ae(r.x)||!ae(t.y)||!ae(r.y))return;let l=t.x-r.x,u=t.y-r.y,c=3===this.options.dimensions?t.z-r.z:0,h=l*l+u*u+c*c;0===h&&(h=1,l=.01,u=.01,c=.01);const d=n/h,f=l*d,p=u*d,g=c*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(!(ae(s.x)&&ae(a.x)&&ae(s.y)&&ae(a.y)))return;const l=s.x-a.x,u=s.y-a.y,c=3===this.options.dimensions?s.z-a.z:0,h=Math.sqrt(l*l+u*u+c*c)/n,d=l*h,f=u*h,p=c*h;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)}))}}const sj={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};class lj{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},sj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericGridLayout(!0,t,e)}))}genericGridLayout(t,e,n){return ze(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:l,cols:u,nodeSpacing:c,nodeSize:h,width:d,height:f,position:p}=r;let{sortBy:g}=r;const v=e.getAllNodes(),m=e.getAllEdges(),y=null==v?void 0:v.length;if(!y||1===y)return mb(e,t,i);const b=v.map((t=>ub(t)));"id"===g||ne(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)=>ae(e.id)&&ae(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const x=d||"undefined"==typeof window?d:window.innerWidth,E=f||"undefined"==typeof window?f:window.innerHeight,w=y,k={rows:l,cols:u};if(null!=l&&null!=u)k.rows=l,k.cols=u;else if(null!=l&&null==u)k.rows=l,k.cols=Math.ceil(w/k.rows);else if(null==l&&null!=u)k.cols=u,k.rows=Math.ceil(w/k.cols);else{const t=Math.sqrt(w*E/x);k.rows=Math.round(t),k.cols=Math.round(x/E*t)}if(k.rows=Math.max(k.rows,1),k.cols=Math.max(k.cols,1),k.cols*k.rows>w){const t=uj(k),e=cj(k);(t-1)*e>=w?uj(k,t-1):(e-1)*t>=w&&cj(k,e-1)}else for(;k.cols*k.rows<w;){const t=uj(k),e=cj(k);(e+1)*t>=w?cj(k,e+1):uj(k,t+1)}let M=o?0:x/k.cols,S=o?0:E/k.rows;if(s||c){const t=hb(10,c),n=db(30,h,!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,s]=cb(n(i)||30),l=void 0!==t?t(r):a,u=o+l,c=s+l;M=Math.max(M,u),S=Math.max(S,c)}))}const N={},O={row:0,col:0},T={};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;hj(N,t);)t.col++;else if(void 0===t.row)for(t.row=0;hj(N,t);)t.row++;T[n.id]=t,dj(N,t)}pj(n,i,M,S,T,k,O,N)}const A={nodes:b,edges:m};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),A}))}}const uj=(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},cj=(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},hj=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,dj=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,fj=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},pj=(t,e,n,r,i,o,a,s)=>{let l,u;const c=i[t.id];if(c)l=c.col*n+n/2+e[0],u=c.row*r+r/2+e[1];else{for(;hj(s,a);)fj(o,a);l=a.col*n+n/2+e[0],u=a.row*r+r/2+e[1],dj(s,a),fj(o,a)}t.data.x=l,t.data.y=u},gj={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},vj=(t,e,n,r,i,o)=>{e.forEach(((a,s)=>{n[s]={x:0,y:0},e.forEach(((e,l)=>{if(s===l)return;if(i[s]!==i[l])return;let u=a.x-e.x,c=a.y-e.y,h=Math.sqrt(u*u+c*c);if(0===h){h=1;const t=s>l?1:-1;u=.01*t,c=.01*t}if(h<o(t[s])/2+o(t[l])/2){const t=r*r/h;n[s].x+=u/h*t,n[s].y+=c/h*t}}))}))},mj=(t,e,n,r,i,o,a,s)=>{const l=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,l=-r/a;const u=Math.sqrt(e.x*e.x+e.y*e.y);let c=Math.acos((s*e.x+l*e.y)/u);c>Math.PI/2&&(c-=Math.PI/2,s*=-1,l*=-1);const h=Math.cos(c)*u;e.x=s*h,e.y=l*h})),t.forEach(((o,a)=>{if(a===i)return;const u=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(u>0&&a!==i){const c=Math.min(l*(n/800),u);if(o.x+=e[a].x/u*c,o.y+=e[a].y/u*c,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},yj={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class bj{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},yj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRadialLayout(!0,t,e)}))}genericRadialLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,focusNode:s,unitRadius:l,nodeSize:u,nodeSpacing:c,strictRadial:h,preventOverlap:d,maxPreventOverlapIteration:f,sortBy:p,linkDistance:g=50,sortStrength:v=10,maxIteration:m=1e3}=r,y=e.getAllNodes(),b=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,E=o||"undefined"==typeof window?o:window.innerHeight,w=a||[x/2,E/2];if(!(null==y?void 0:y.length)||1===y.length)return mb(e,t,w);let k=y[0];if(ne(s)){for(let t=0;t<y.length;t++)if(y[t].id===s){k=y[t];break}}else k=s||y[0];const M=wj(y,k.id),S=ob({nodes:y,edges:b}),N=ib(S),O=Mj(N,M);kj(N,M,O+1);const T=N[M];let A=x-w[0]>w[0]?w[0]:x-w[0],C=E-w[1]>w[1]?w[1]:E-w[1];0===A&&(A=x/2),0===C&&(C=E/2);const P=Math.min(A,C),R=Math.max(...T),D=[],L=l||P/R;T.forEach(((t,e)=>{D[e]=t*L}));const _=xj(y,N,g,D,L,p,v),I=Ej(_),j=((t,e,n)=>{try{const n=Hx.mul(Hx.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 Yx(n),s=Hx.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>Hx.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,_,g);let B,F=j.map((([t,e])=>({x:(isNaN(t)?Math.random()*g:t)-j[M][0],y:(isNaN(e)?Math.random()*g:e)-j[M][1]})));if(this.run(m,F,I,_,D,M),d){B=fb(u,c);const t={nodes:y,nodeSizeFunc:B,positions:F,radii:D,height:E,width:x,strictRadial:Boolean(h),focusIdx:M,iterations:f||200,k:F.length/4.5};F=((t,e)=>{const n=Object.assign(Object.assign({},gj),e),{positions:r,iterations:i,width:o,k:a,speed:s=100,strictRadial:l,focusIdx:u,radii:c=[],nodeSizeFunc:h}=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}})),vj(d,r,f,a,c,h),mj(r,f,s,l,u,p,o,c);return r})(e,t)}const z=[];F.forEach(((t,e)=>{const n=ub(y[e]);n.data.x=t.x+w[0],n.data.y=t.y+w[1],z.push(n)})),t&&z.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:z,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,l)=>{const u=ab(s,{x:0,y:0}),c=0===u?0:1/u;if(l===o)return;let h=0,d=0,f=0;e.forEach(((t,e)=>{if(l===e)return;const n=ab(s,t),o=0===n?0:1/n,a=r[e][l];f+=i[l][e],h+=i[l][e]*(t.x+a*(s.x-t.x)*o),d+=i[l][e]*(t.y+a*(s.y-t.y)*o)}));const p=0===n[l]?0:1/n[l];f*=a,f+=t*p*p,h*=a,h+=t*p*s.x*c,s.x=h/f,d*=a,d+=t*p*s.y*c,s.y=d/f}))}}const xj=(t,e,n,r,i,o,a)=>{if(!t)return[];const s=[];{const l={};e.forEach(((e,u)=>{const c=[];e.forEach(((e,s)=>{var h,d;if(u===s)c.push(0);else if(r[u]===r[s])if("data"===o)c.push(e*(Math.abs(u-s)*a)/(r[u]/i));else if(o){let n,f;if(l[t[u].id])n=l[t[u].id];else{const e=("id"===o?t[u].id:null===(h=t[u].data)||void 0===h?void 0:h[o])||0;n=ne(e)?e.charCodeAt(0):e,l[t[u].id]=n}if(l[t[s].id])f=l[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=ne(e)?e.charCodeAt(0):e,l[t[s].id]=f}c.push(e*(Math.abs(n-f)*a)/(r[u]/i))}else c.push(e*n/(r[u]/i));else{const t=(n+i)/2;c.push(e*t)}})),s.push(c)}))}return s},Ej=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},wj=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},kj=(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}},Mj=(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},Sj={center:[0,0],width:300,height:300};class Nj{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},Sj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRandomLayout(!0,t,e)}))}genericRandomLayout(t,e,n){return ze(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(),l=o||"undefined"==typeof window?o:window.innerWidth,u=a||"undefined"==typeof window?a:window.innerHeight,c=i||[l/2,u/2],h=[];s&&s.forEach((t=>{h.push({id:t.id,data:{x:.9*(Math.random()-.5)*l+c[0],y:.9*(Math.random()-.5)*u+c[1]}})})),t&&h.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:h,edges:e.getAllEdges()}}))}}
67
67
  /**
68
68
  * @license
69
69
  * Copyright 2019 Google LLC
70
70
  * SPDX-License-Identifier: Apache-2.0
71
- */const Oj=Symbol("Comlink.proxy"),Tj=Symbol("Comlink.endpoint"),Aj=Symbol("Comlink.releaseProxy"),Cj=Symbol("Comlink.finalizer"),Pj=Symbol("Comlink.thrown"),Rj=t=>"object"==typeof t&&null!==t||"function"==typeof t,Dj=new Map([["proxy",{canHandle:t=>Rj(t)&&t[Oj],serialize(t){const{port1:e,port2:n}=new MessageChannel;return Lj(t,e),[n,[n]]},deserialize:t=>(t.start(),Ij(t))}],["throw",{canHandle:t=>Rj(t)&&Pj 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 Lj(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),l=(i.data.argumentList||[]).map(Yj);let u;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":u=n;break;case"SET":e[s.slice(-1)[0]]=Yj(i.data.value),u=!0;break;case"APPLY":u=n.apply(e,l);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[Oj]:!0})}(new n(...l));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;Lj(t,n),u=function(t,e){return Wj.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[Pj]:0}}Promise.resolve(u).catch((t=>({value:t,[Pj]:0}))).then((n=>{const[i,s]=Hj(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),_j(e),Cj in t&&"function"==typeof t[Cj]&&t[Cj]())})).catch((t=>{const[n,r]=Hj({value:new TypeError("Unserializable return value"),[Pj]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function _j(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function Ij(t,e){const n=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const r=n.get(e.id);if(r)try{r(e)}finally{n.delete(e.id)}})),Gj(t,n,[],e)}function jj(t){if(t)throw new Error("Proxy has been released and is not useable")}function Bj(t){return Uj(t,new Map,{type:"RELEASE"}).then((()=>{_j(t)}))}const Fj=new WeakMap,zj="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Fj.get(t)||0)-1;Fj.set(t,e),0===e&&Bj(t)}));function Gj(t,e,n=[],r=function(){}){let i=!1;const o=new Proxy(r,{get(r,a){if(jj(i),a===Aj)return()=>{!function(t){zj&&zj.unregister(t)}(o),Bj(t),e.clear(),i=!0};if("then"===a){if(0===n.length)return{then:()=>o};const r=Uj(t,e,{type:"GET",path:n.map((t=>t.toString()))}).then(Yj);return r.then.bind(r)}return Gj(t,e,[...n,a])},set(r,o,a){jj(i);const[s,l]=Hj(a);return Uj(t,e,{type:"SET",path:[...n,o].map((t=>t.toString())),value:s},l).then(Yj)},apply(r,o,a){jj(i);const s=n[n.length-1];if(s===Tj)return Uj(t,e,{type:"ENDPOINT"}).then(Yj);if("bind"===s)return Gj(t,e,n.slice(0,-1));const[l,u]=Vj(a);return Uj(t,e,{type:"APPLY",path:n.map((t=>t.toString())),argumentList:l},u).then(Yj)},construct(r,o){jj(i);const[a,s]=Vj(o);return Uj(t,e,{type:"CONSTRUCT",path:n.map((t=>t.toString())),argumentList:a},s).then(Yj)}});return function(t,e){const n=(Fj.get(e)||0)+1;Fj.set(e,n),zj&&zj.register(t,e,t)}(o,t),o}function Vj(t){const e=t.map(Hj);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const Wj=new WeakMap;function Hj(t){for(const[e,n]of Dj)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},Wj.get(t)||[]]}function Yj(t){switch(t.type){case"HANDLER":return Dj.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Uj(t,e,n,r){return new Promise((i=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(o,i),t.start&&t.start(),t.postMessage(Object.assign({id:o},n),r)}))}class $j extends zg{constructor(t,e,n){super(),this.graph=t,this.layout=e,this.options=n,this.spawnWorker()}spawnWorker(){this.proxy=Ij(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())}execute(){var t;return ze(this,void 0,void 0,(function*(){if(this.running)return this;this.running=!0;const e=Fe(this.layout.options,["onTick"]),n={};Object.keys(e).forEach((t=>{Yt(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]),[o]=yield this.proxy.calculateLayout(r,[i]);return o}))}stop(){return this.running=!1,this.proxy.stopLayout(),this}kill(){this.proxy[Aj]()}isRunning(){return this.running}}class qj extends Ug{constructor(){super(...arguments),this.id="fishbone"}getRoot(){const t=this.context.model.getRootsData();if(!(Se(t)||t.length>2))return t[0]}formatSize(t){const e="function"==typeof t?t:()=>t;return t=>Pd(e(t))}doLayout(t,e){const{hGap:n,getRibSep:r,vGap:i,nodeSize:o,height:a}=e,{model:s}=this.context,l=this.formatSize(o);let u=l(t)[0]+r(t);const c=(t,e=0)=>{var r;return e+=n*((t.children||[]).length+1),null===(r=t.children)||void 0===r||r.forEach((t=>{var n;null===(n=s.getNodeLikeDatum(t).children)||void 0===n||n.forEach((t=>{const n=s.getNodeLikeDatum(t);e=c(n,e)}))})),e},h=t=>{if(1===t.depth)return u;const e=s.getParentData(t.id,"tree");if(Zj(t)){const r=s.getParentData(e.id,"tree"),o=p(t)-p(r);return h(e)+o*n/i}{const n=(e.children||[]).indexOf(t.id),r=s.getNodeData((e.children||[]).slice(n));return d(e)-r.reduce(((t,e)=>t+c(e)),0)-l(e)[0]/2}},d=xe((t=>{if(Kj(t))return l(t)[0]/2;const e=s.getParentData(t.id,"tree");if(Zj(t))return h(t)+c(t)+l(t)[0]/2;{const r=p(t)-p(e),o=n/i;return h(t)+r*o}}),(t=>t.id)),f=t=>p(s.getParentData(t,"tree")),p=xe((t=>{if(Kj(t))return a/2;if(Zj(t)){const e=s.getParentData(t.id,"tree"),n=e.children.indexOf(t.id);if(0===n)return f(e.id)+i;const r=s.getNodeLikeDatum(e.children[n-1]);if(Se(r.children))return p(r)+i;const o=s.getDescendantsData(r.id);return Math.max(...o.map((t=>Zj(t)?f(t.id):p(t))))+i}{if(Se(t.children))return f(t.id)+i;const e=s.getNodeLikeDatum(t.children.slice(-1)[0]);if(Se(e.children))return p(e)+i;const n=s.getDescendantsData(t.id).slice(-1)[0];return(Zj(n)?f(n.id):p(n))+i}}),(t=>t.id));let g=0;const v={nodes:[],edges:[]},m=t=>{var e;null===(e=t.children)||void 0===e||e.forEach((t=>m(s.getNodeLikeDatum(t))));const n=p(t),i=d(t);if(v.nodes.push({id:t.id,x:i,y:n}),Kj(t))return;const o=s.getRelatedEdgesData(t.id,"in")[0],a=[h(t),Zj(t)?n:f(t.id)];v.edges.push({id:yh(o),controlPoints:[a],relatedNodeId:t.id}),g=Math.max(g,i+r(t)),1===t.depth&&(u=g)};return m(t),v}placeAlterative(t,e){const n=(e.children||[]).filter(((t,e)=>e%2!=0));if(0===n.length)return t;const{model:r}=this.context,i=t.nodes.find((t=>t.id===e.id)).y,o=t=>{const e=r.getAncestorsData(t,"tree");if(Se(e))return!1;const i=1===e.length?t:e[e.length-2].id;return n.includes(i)};t.nodes.forEach((t=>{o(t.id)&&(t.y=2*i-t.y)})),t.edges.forEach((t=>{o(t.relatedNodeId)&&(t.controlPoints=t.controlPoints.map((t=>[t[0],2*i-t[1]])))}))}rightToLeft(t,e){return t.nodes.forEach((t=>t.x=e.width-t.x)),t.edges.forEach((t=>{t.controlPoints=t.controlPoints.map((t=>[e.width-t[0],t[1]]))})),t}execute(t,e){return ze(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign(Object.assign({},qj.defaultOptions),this.options),e),{direction:r,nodeSize:i}=n,o=this.getRoot();if(!o)return t;const a=this.formatSize(i);n.vGap||(n.vGap=Math.max(...(t.nodes||[]).map((t=>a(t)[1])))),n.hGap||(n.hGap=Math.max(...(t.nodes||[]).map((t=>a(t)[0]))));let s=this.doLayout(o,n);this.placeAlterative(s,o),"RL"===r&&(s=this.rightToLeft(s,n));const{model:l}=this.context,u=[],c=[];return s.nodes.forEach((t=>{const{id:e,x:n,y:r}=t,i=l.getNodeLikeDatum(e);u.push(Xj(i,{x:n,y:r}))})),s.edges.forEach((t=>{const{id:e,controlPoints:n}=t,r=l.getEdgeDatum(e);c.push(Xj(r,{controlPoints:n}))})),{nodes:u,edges:c}}))}}qj.defaultOptions={direction:"RL",getRibSep:()=>60};const Xj=(t,e)=>Object.assign(Object.assign({},t),{style:Object.assign(Object.assign({},t.style||{}),e)}),Kj=t=>0===t.depth,Zj=t=>(t.depth||(t.depth=0))%2==0;class Qj extends Ug{constructor(){super(...arguments),this.id="snake"}formatSize(t,e){const n="function"==typeof e?e:()=>e;return t.reduce(((t,e)=>{const[r,i]=Pd(n(e))||[0,0];return[Math.max(t[0],r),Math.max(t[1],i)]}),[0,0])}validate(t){const{nodes:e=[],edges:n=[]}=t,r={},i={},o={};e.forEach((t=>{r[t.id]=0,i[t.id]=0,o[t.id]=[]})),n.forEach((t=>{r[t.target]++,i[t.source]++,o[t.source].push(t.target)}));const a=new Set,s=t=>{a.has(t)||(a.add(t),o[t].forEach(s))};if(s(e[0].id),a.size!==e.length)return!1;const l=e.filter((t=>0===r[t.id])),u=e.filter((t=>0===i[t.id]));if(1!==l.length||1!==u.length)return!1;return e.filter((t=>1===r[t.id]&&1===i[t.id])).length===e.length-2}execute(t,e){return ze(this,void 0,void 0,(function*(){var n;if(!this.validate(t))return t;const{nodeSize:r,padding:i,sortBy:o,cols:a,colGap:s,rowGap:l,clockwise:u,width:c,height:h}=Object.assign({},Qj.defaultOptions,this.options,e),[d,f,p,g]=Yc(i),v=this.formatSize(t.nodes||[],r),m=Math.ceil((t.nodes||[]).length/a);let y=s||(c-g-f-a*v[0])/(a-1),b=l||(h-d-p-m*v[1])/(m-1);(b===1/0||b<0)&&(b=0),(y===1/0||y<0)&&(y=0);const x=o?null===(n=t.nodes)||void 0===n?void 0:n.sort(o):function(t){const{nodes:e=[],edges:n=[]}=t,r={},i={};e.forEach((t=>{r[t.id]=0,i[t.id]=[]})),n.forEach((t=>{r[t.target]++,i[t.source].push(t.target)}));const o=[],a=[];e.forEach((t=>{0===r[t.id]&&o.push(t.id)}));for(;o.length>0;){const t=o.shift(),n=e.find((e=>e.id===t));a.push(n),i[t].forEach((t=>{r[t]--,0===r[t]&&o.push(t)}))}return a}(t),E=(x||[]).map(((t,e)=>{const n=Math.floor(e/a),r=e%a,i=g+(u?n%2==0?r:a-1-r:n%2==0?a-1-r:r)*(v[0]+y)+v[0]/2,o=d+n*(v[1]+b)+v[1]/2;return{id:t.id,style:{x:i,y:o}}}));return{nodes:E}}))}}Qj.defaultOptions={padding:0,cols:5,clockwise:!0};class Jj extends Rh{}function tB(t,e=!0,n){const r=document.createElement("div");return r.setAttribute("class",`g6-${t}`),Object.assign(r.style,{position:"absolute",display:"block"}),e&&Object.assign(r.style,{position:"unset",gridArea:"1 / 1 / 2 / 2",inset:"0px",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none"}),n&&Object.assign(r.style,n),r}function eB(t,e="div",n={},r="",i=document.body){const o=document.getElementById(t);o&&o.remove();const a=document.createElement(e);return a.innerHTML=r,a.id=t,Object.assign(a.style,n),i.appendChild(a),a}class nB extends Jj{constructor(t,e){super(t,Object.assign({},nB.defaultOptions,e)),this.$element=tB("background");this.context.canvas.getContainer().prepend(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(this,void 0,void 0,(function*(){e.update.call(this,t),Object.assign(this.$element.style,Pe(this.options,["key","type"]))}))}destroy(){super.destroy(),this.$element.remove()}}function rB(t,e,n,r,i,o){const a=n-t,s=r-e;let l=i-t,u=o-e,c=l*a+u*s,h=0;c<=0?h=0:(l=a-l,u=s-u,c=l*a+u*s,h=c<=0?0:c*c/(a*a+s*s));const d=l*l+u*u-h;return d<0?0:d}function iB(t,e,n,r){return(t-n)*(t-n)+(e-r)*(e-r)}function oB(t,e,n,r,i){return iB(t,e,n,r)<i*i}function aB(t){const e=Math.min(t.x1,t.x2),n=Math.max(t.x1,t.x2),r=Math.min(t.y1,t.y2),i=Math.max(t.y1,t.y2);return{x:e,y:r,x2:n,y2:i,width:n-e,height:i-r}}nB.defaultOptions={transition:"background 0.5s",backgroundSize:"cover",zIndex:"-1"};class sB{constructor(t,e,n,r){this.x1=t,this.y1=e,this.x2=n,this.y2=r}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}draw(t){t.moveTo(this.x1,this.y1),t.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(t){return new sB(t.x1,t.y1,t.x2,t.y2)}cuts(t,e){if(this.y1===this.y2)return!1;if(e<this.y1&&e<=this.y2||e>this.y1&&e>=this.y2)return!1;if(t>this.x1&&t>=this.x2)return!1;if(t<this.x1&&t<=this.x2)return!0;return t<=this.x1+(e-this.y1)*(this.x2-this.x1)/(this.y2-this.y1)}distSquare(t,e){return rB(this.x1,this.y1,this.x2,this.y2,t,e)}ptClose(t,e,n){if(this.x1<this.x2){if(t<this.x1-n||t>this.x2+n)return!1}else if(t<this.x2-n||t>this.x1+n)return!1;if(this.y1<this.y2){if(e<this.y1-n||e>this.y2+n)return!1}else if(e<this.y2-n||e>this.y1+n)return!1;return!0}}var lB,uB;!function(t){t[t.POINT=1]="POINT",t[t.PARALLEL=2]="PARALLEL",t[t.COINCIDENT=3]="COINCIDENT",t[t.NONE=4]="NONE"}(lB||(lB={}));class cB{constructor(t,e=0,n=0){this.state=t,this.x=e,this.y=n}}function hB(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const e=n/i,o=r/i;return 0<=e&&e<=1&&0<=o&&o<=1?new cB(lB.POINT,t.x1+e*(t.x2-t.x1),t.y1+e*(t.y2-t.y1)):new cB(lB.NONE)}return new cB(0===n||0===r?lB.COINCIDENT:lB.PARALLEL)}function dB(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const t=n/i,e=r/i;if(0<=t&&t<=1&&0<=e&&e<=1)return t}return Number.POSITIVE_INFINITY}function fB(t,e,n){const r=new Set;return t.width<=0?(r.add(uB.LEFT),r.add(uB.RIGHT)):e<t.x?r.add(uB.LEFT):e>t.x+t.width&&r.add(uB.RIGHT),t.height<=0?(r.add(uB.TOP),r.add(uB.BOTTOM)):n<t.y?r.add(uB.TOP):n>t.y+t.height&&r.add(uB.BOTTOM),r}function pB(t,e){let n=e.x1,r=e.y1;const i=e.x2,o=e.y2,a=Array.from(fB(t,i,o));if(0===a.length)return!0;let s=fB(t,n,r);for(;0!==s.size;){for(const t of a)if(s.has(t))return!1;if(s.has(uB.RIGHT)||s.has(uB.LEFT)){let e=t.x;s.has(uB.RIGHT)&&(e+=t.width),r+=(e-n)*(o-r)/(i-n),n=e}else{let e=t.y;s.has(uB.BOTTOM)&&(e+=t.height),n+=(e-r)*(i-n)/(o-r),r=e}s=fB(t,n,r)}return!0}function gB(t,e){let n=Number.POSITIVE_INFINITY,r=0;function i(t,i,o,a){let s=dB(e,new sB(t,i,o,a));s=Math.abs(s-.5),s>=0&&s<=1&&(r++,s<n&&(n=s))}return i(t.x,t.y,t.x2,t.y),i(t.x,t.y,t.x,t.y2),r>1?n:(i(t.x,t.y2,t.x2,t.y2),r>1?n:(i(t.x2,t.y,t.x2,t.y2),0===r?-1:n))}function vB(t,e){let n=0;const r=hB(t,new sB(e.x,e.y,e.x2,e.y));n+=r.state===lB.POINT?1:0;const i=hB(t,new sB(e.x,e.y,e.x,e.y2));n+=i.state===lB.POINT?1:0;const o=hB(t,new sB(e.x,e.y2,e.x2,e.y2));n+=o.state===lB.POINT?1:0;const a=hB(t,new sB(e.x2,e.y,e.x2,e.y2));return n+=a.state===lB.POINT?1:0,{top:r,left:i,bottom:o,right:a,count:n}}!function(t){t[t.LEFT=0]="LEFT",t[t.TOP=1]="TOP",t[t.RIGHT=2]="RIGHT",t[t.BOTTOM=3]="BOTTOM"}(uB||(uB={}));class mB{constructor(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(t){return new mB(t.x,t.y,t.width,t.height)}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}clone(){return new mB(this.x,this.y,this.width,this.height)}add(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x+t.width),i=Math.max(this.y2,t.y+t.height);this.x=e,this.y=n,this.width=r-e,this.height=i-n}addPoint(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x),i=Math.max(this.y2,t.y);this.x=e,this.y=n,this.width=r-e,this.height=i-n}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(t){t.rect(this.x,this.y,this.width,this.height)}containsPt(t,e){return t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}get area(){return this.width*this.height}intersects(t){return!(this.area<=0||t.width<=0||t.height<=0)&&(t.x+t.width>this.x&&t.y+t.height>this.y&&t.x<this.x2&&t.y<this.y2)}distSquare(t,e){if(this.containsPt(t,e))return 0;const n=fB(this,t,e);return n.has(uB.TOP)?n.has(uB.LEFT)?iB(t,e,this.x,this.y):n.has(uB.RIGHT)?iB(t,e,this.x2,this.y):(this.y-e)*(this.y-e):n.has(uB.BOTTOM)?n.has(uB.LEFT)?iB(t,e,this.x,this.y2):n.has(uB.RIGHT)?iB(t,e,this.x2,this.y2):(e-this.y2)*(e-this.y2):n.has(uB.LEFT)?(this.x-t)*(this.x-t):n.has(uB.RIGHT)?(t-this.x2)*(t-this.x2):0}}class yB{constructor(t,e,n){this.cx=t,this.cy=e,this.radius=n}get x(){return this.cx-this.radius}get x2(){return this.cx+this.radius}get width(){return 2*this.radius}get y(){return this.cy-this.radius}get y2(){return this.cy+this.radius}get height(){return 2*this.radius}static from(t){return new yB(t.cx,t.cy,t.radius)}containsPt(t,e){return iB(this.cx,this.cy,t,e)<this.radius*this.radius}distSquare(t,e){const n=iB(this.cx,this.cy,t,e);if(n<this.radius*this.radius)return 0;const r=Math.sqrt(n)-this.radius;return r*r}draw(t){t.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,2*Math.PI)}}class bB{constructor(t,e=0,n=0,r=0,i=0,o=10,a=10,s=new Float32Array(Math.max(0,o*a)).fill(0)){this.pixelGroup=t,this.i=e,this.j=n,this.pixelX=r,this.pixelY=i,this.width=o,this.height=a,this.area=s}createSub(t,e){return new bB(this.pixelGroup,t.x,t.y,e.x,e.y,t.width,t.height)}static fromPixelRegion(t,e){return new bB(e,0,0,t.x,t.y,Math.ceil(t.width/e),Math.ceil(t.height/e))}copy(t,e){return new bB(this.pixelGroup,this.scaleX(e.x),this.scaleY(e.y),e.x,e.y,t.width,t.height,t.area)}boundX(t){return t<this.i?this.i:t>=this.width?this.width-1:t}boundY(t){return t<this.j?this.j:t>=this.height?this.height-1:t}scaleX(t){return this.boundX(Math.floor((t-this.pixelX)/this.pixelGroup))}scaleY(t){return this.boundY(Math.floor((t-this.pixelY)/this.pixelGroup))}scale(t){const e=this.scaleX(t.x),n=this.scaleY(t.y),r=this.boundX(Math.ceil((t.x+t.width-this.pixelX)/this.pixelGroup)),i=this.boundY(Math.ceil((t.y+t.height-this.pixelY)/this.pixelGroup));return new mB(e,n,r-e,i-n)}invertScaleX(t){return Math.round(t*this.pixelGroup+this.pixelX)}invertScaleY(t){return Math.round(t*this.pixelGroup+this.pixelY)}addPadding(t,e){const n=Math.ceil(e/this.pixelGroup),r=this.boundX(t.x-n),i=this.boundY(t.y-n),o=this.boundX(t.x2+n),a=this.boundY(t.y2+n);return new mB(r,i,o-r,a-i)}get(t,e){return t<0||e<0||t>=this.width||e>=this.height?Number.NaN:this.area[t+e*this.width]}inc(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]+=n)}set(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]=n)}incArea(t,e){if(t.width<=0||t.height<=0||0===e)return;const n=this.width,r=t.width,i=Math.max(0,t.i),o=Math.max(0,t.j),a=Math.min(t.i+t.width,n),s=Math.min(t.j+t.height,this.height);if(!(s<=0||a<=0||i>=n||s>=this.height))for(let l=o;l<s;l++){const o=(l-t.j)*r,s=l*n;for(let n=i;n<a;n++){const r=t.area[n-t.i+o];0!==r&&(this.area[n+s]+=e*r)}}}fill(t){this.area.fill(t)}fillArea(t,e){const n=t.x+t.y*this.width;for(let r=0;r<t.height;r++){const i=n+r*this.width;this.area.fill(e,i,i+t.width)}}fillHorizontalLine(t,e,n,r){const i=t+e*this.width;this.area.fill(r,i,i+n)}fillVerticalLine(t,e,n,r){const i=t+e*this.width;for(let t=0;t<n;t++)this.area[i+t*this.width]=r}clear(){this.area.fill(0)}toString(){let t="";for(let e=0;e<this.height;e++){const n=e*this.width;for(let e=0;e<this.width;e++){t+=this.area[n+e].toFixed(1).padStart(6),t+=" "}t+="\n"}return t}draw(t,e=!0){if(this.width<=0||this.height<=0)return;t.save(),e&&t.translate(this.pixelX,this.pixelY);const n=this.area.reduce(((t,e)=>Math.min(t,e)),Number.POSITIVE_INFINITY),r=this.area.reduce(((t,e)=>Math.max(t,e)),Number.NEGATIVE_INFINITY),i=t=>(t-n)/(r-n);t.scale(this.pixelGroup,this.pixelGroup);for(let e=0;e<this.width;e++)for(let n=0;n<this.height;n++){const r=this.area[e+n*this.width];t.fillStyle=`rgba(0, 0, 0, ${i(r)})`,t.fillRect(e,n,1,1)}t.restore()}drawThreshold(t,e,n=!0){if(!(this.width<=0||this.height<=0)){t.save(),n&&t.translate(this.pixelX,this.pixelY),t.scale(this.pixelGroup,this.pixelGroup);for(let n=0;n<this.width;n++)for(let r=0;r<this.height;r++){const i=this.area[n+r*this.width];t.fillStyle=i>e?"black":"white",t.fillRect(n,r,1,1)}t.restore()}}}function xB(t,e){const n=t=>({x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e});return Array.isArray(t)?t.map(n):n(t)}function EB(t,e,n){return wB(Object.assign(aB(t),{distSquare:(e,n)=>rB(t.x1,t.y1,t.x2,t.y2,e,n)}),e,n)}function wB(t,e,n){const r=xB(t,n),i=e.scale(r),o=e.createSub(i,r);return function(t,e,n,r){const i=n*n;for(let o=0;o<t.height;o++)for(let a=0;a<t.width;a++){const s=r(e.invertScaleX(t.i+a),e.invertScaleY(t.j+o));if(0!==s){if(s<i){const e=n-Math.sqrt(s);t.set(a,o,e*e)}}else t.set(a,o,i)}}(o,e,n,((e,n)=>t.distSquare(e,n))),o}function kB(t,e){return{x:t,y:e}}function MB(t,e,n,r){if(0===t.length)return[];const i=function(t){if(t.length<2)return t;let e=0,n=0;return t.forEach((t=>{e+=t.cx,n+=t.cy})),e/=t.length,n/=t.length,t.map((t=>{const r=e-t.cx,i=n-t.cy;return[t,r*r+i*i]})).sort(((t,e)=>t[1]-e[1])).map((t=>t[0]))}(t);return i.map(((t,o)=>{const a=i.slice(0,o);return function(t,e,n,r,i){const o=kB(e.cx,e.cy),a=function(t,e,n){let r=Number.POSITIVE_INFINITY;return e.reduce(((e,i)=>{const o=iB(t.x,t.y,i.cx,i.cy);if(o>r)return e;const a=new sB(t.x,t.y,i.cx,i.cy),s=function(t,e){return t.reduce(((t,n)=>pB(n,e)&&function(t,e){function n(t,n,r,i){let o=dB(e,new sB(t,n,r,i));return o=Math.abs(o-.5),o>=0&&o<=1?1:0}let r=n(t.x,t.y,t.x2,t.y);return r+=n(t.x,t.y,t.x,t.y2),r>1||(r+=n(t.x,t.y2,t.x2,t.y2),r>1||(r+=n(t.x2,t.y,t.x2,t.y2),r>0))}(n,e)?t+1:t),0)}(n,a);return o*(s+1)*(s+1)<r&&(e=i,r=o*(s+1)*(s+1)),e}),null)}(o,n,t);if(null==a)return[];const s=function(t,e,n,r){const i=[],o=[];o.push(t);let a=!0;for(let t=0;t<n&&a;t++)for(a=!1;!a&&o.length>0;){const t=o.pop(),n=OB(e,t),s=n?vB(t,n):null;if(!n||!s||2!==s.count){a||i.push(t);continue}let l=r,u=TB(n,l,s,!0),c=NB(u,o)||NB(u,i),h=SB(u,e);for(;!c&&h&&l>=1;)l/=1.5,u=TB(n,l,s,!0),c=NB(u,o)||NB(u,i),h=SB(u,e);if(!u||c||h||(o.push(new sB(t.x1,t.y1,u.x,u.y)),o.push(new sB(u.x,u.y,t.x2,t.y2)),a=!0),a)continue;l=r,u=TB(n,l,s,!1);let d=NB(u,o)||NB(u,i);for(h=SB(u,e);!d&&h&&l>=1;)l/=1.5,u=TB(n,l,s,!1),d=NB(u,o)||NB(u,i),h=SB(u,e);u&&!d&&(o.push(new sB(t.x1,t.y1,u.x,u.y)),o.push(new sB(u.x,u.y,t.x2,t.y2)),a=!0),a||i.push(t)}for(;o.length>0;)i.push(o.pop());return i}(new sB(o.x,o.y,a.cx,a.cy),t,r,i);return function(t,e){const n=[];for(;t.length>0;){const r=t.pop();if(0===t.length){n.push(r);break}const i=t.pop(),o=new sB(r.x1,r.y1,i.x2,i.y2);OB(e,o)?(n.push(r),t.push(i)):t.push(o)}return n}(s,t)}(e,t,a,n,r)})).flat()}function SB(t,e){return e.some((e=>e.containsPt(t.x,t.y)))}function NB(t,e){return e.some((e=>!!oB(e.x1,e.y1,t.x,t.y,.001)||!!oB(e.x2,e.y2,t.x,t.y,.001)))}function OB(t,e){let n=Number.POSITIVE_INFINITY,r=null;for(const i of t){if(!pB(i,e))continue;const t=gB(i,e);t>=0&&t<n&&(r=i,n=t)}return r}function TB(t,e,n,r){const i=n.top,o=n.left,a=n.bottom,s=n.right;if(r){if(o.state===lB.POINT){if(i.state===lB.POINT)return kB(t.x-e,t.y-e);if(a.state===lB.POINT)return kB(t.x-e,t.y2+e);const n=t.width*t.height;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?kB(t.x-e,t.y-e):kB(t.x2+e,t.y-e):o.y<s.y?kB(t.x-e,t.y2+e):kB(t.x2+e,t.y2+e)}if(s.state===lB.POINT){if(i.state===lB.POINT)return kB(t.x2+e,t.y-e);if(a.state===lB.POINT)return kB(t.x2+e,t.y2+e)}const n=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*n?i.x>a.x?kB(t.x-e,t.y-e):kB(t.x-e,t.y2+e):i.x<a.x?kB(t.x2+e,t.y-e):kB(t.x2+e,t.y2+e)}if(o.state===lB.POINT){if(i.state===lB.POINT)return kB(t.x2+e,t.y2+e);if(a.state===lB.POINT)return kB(t.x2+e,t.y-e);const n=t.height*t.width;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?kB(t.x2+e,t.y2+e):kB(t.x-e,t.y2+e):o.y<s.y?kB(t.x2+e,t.y-e):kB(t.x-e,t.y-e)}if(s.state===lB.POINT){if(i.state===lB.POINT)return kB(t.x-e,t.y2+e);if(a.state===lB.POINT)return kB(t.x-e,t.y-e)}const l=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*l?i.x>a.x?kB(t.x2+e,t.y2+e):kB(t.x2+e,t.y-e):i.x<a.x?kB(t.x-e,t.y2+e):kB(t.x-e,t.y-e)}function AB(t,e,n,r){if(!(t.closed?n<t.length:n<t.length-1))return!1;const i=t.get(e),o=t.get(n+1);for(let a=e+1;a<=n;a++){const e=t.get(a);if(rB(i.x,i.y,o.x,o.y,e.x,e.y)>r)return!1}return!0}function CB(t,e){switch(t){case-2:return(((3-e)*e-3)*e+1)/6;case-1:return((3*e-6)*e*e+4)/6;case 0:return(((-3*e+3)*e+3)*e+1)/6;case 1:return e*e*e/6;default:throw new Error("unknown error")}}class PB{constructor(t=[],e=!0){this.points=t,this.closed=e}get(t){const e=t,n=this.points.length;return t<0?this.closed?this.get(t+n):this.points[0]:t>=n?this.closed?this.get(t-n):this.points[n-1]:this.points[e]}get length(){return this.points.length}toString(t=1/0){const e=this.points;if(0===e.length)return"";const n="function"==typeof t?t:function(t){if(!Number.isFinite(t))return t=>t;if(0===t)return Math.round;const e=Math.pow(10,t);return t=>Math.round(t*e)/e}(t);let r="M";for(const t of e)r+=`${n(t.x)},${n(t.y)} L`;return r=r.slice(0,-1),this.closed&&(r+=" Z"),r}draw(t){const e=this.points;if(0!==e.length){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(const n of e)t.lineTo(n.x,n.y);this.closed&&t.closePath()}}sample(t){return function(t=8){return e=>{let n=t,r=e.length;if(n>1)for(r=Math.floor(e.length/n);r<3&&n>1;)n-=1,r=Math.floor(e.length/n);const i=[];for(let t=0,o=0;o<r;o++,t+=n)i.push(e.get(t));return new PB(i)}}(t)(this)}simplify(t){return function(t=0){return e=>{if(t<0||e.length<3)return e;const n=[];let r=0;const i=t*t;for(;r<e.length;){let t=r+1;for(;AB(e,r,t,i);)t++;n.push(e.get(r)),r=t}return new PB(n)}}(t)(this)}bSplines(t){return function(t=6){function e(t,e,n){let r=0,i=0;for(let o=-2;o<=1;o++){const a=t.get(e+o),s=CB(o,n);r+=s*a.x,i+=s*a.y}return{x:r,y:i}}return n=>{if(n.length<3)return n;const r=[],i=n.closed,o=n.length+3-1+(i?0:2);r.push(e(n,2-(i?0:2),0));for(let a=2-(i?0:2);a<o;a++)for(let i=1;i<=t;i++)r.push(e(n,a,i/t));return new PB(r)}}(t)(this)}apply(t){return t(this)}containsElements(t){const e=function(t){if(0===t.length)return null;const e=t[0],n=new mB(e.x,e.y,0,0);for(const e of t)n.addPoint(e);return n}(this.points);return!!e&&t.every((t=>e.containsPt(t.cx,t.cy)&&this.withinArea(t.cx,t.cy)))}withinArea(t,e){if(0===this.length)return!1;let n=0;const r=this.points[0],i=new sB(r.x,r.y,r.x,r.y);for(let r=1;r<this.points.length;r++){const o=this.points[r];i.x1=i.x2,i.y1=i.y2,i.x2=o.x,i.y2=o.y,i.cuts(t,e)&&n++}return i.x1=i.x2,i.y1=i.y2,i.x2=r.x,i.y2=r.y,i.cuts(t,e)&&n++,n%2==1}}class RB{constructor(t=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=t}add(t){this.set.add(`${t.x}x${t.y}`),this.arr[this.count++]=t}contains(t){return this.set.has(`${t.x}x${t.y}`)}isFirst(t){if(0===this.count)return!1;const e=this.arr[0];return null!=e&&e.x===t.x&&e.y===t.y}path(){return new PB(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(t){return this.arr[t]}get length(){return this.count}}function DB(t,e){const n=2*(Math.floor(t.width)+Math.floor(t.height)),r=new RB(n);function i(n,r,i,o){const a=t.get(n,r);return Number.isNaN(a)?Number.NaN:a>e?i+o:i}function o(t,e){let n=0;return n=i(t,e,n,1),n=i(t+1,e,n,2),n=i(t,e+1,n,4),n=i(t+1,e+1,n,8),Number.isNaN(n)?-1:n}let a=1;function s(e,n){let i=e,s=n,l=t.invertScaleX(i),u=t.invertScaleY(s);for(let e=0;e<t.width*t.height;e++){const e={x:l,y:u};if(r.contains(e)){if(r.isFirst(e))return!0}else r.add(e);const n=o(i,s);switch(n){case-1:return!0;case 0:case 3:case 2:case 7:a=2;break;case 12:case 14:case 4:a=3;break;case 6:a=0===a?3:2;break;case 1:case 13:case 5:a=0;break;case 9:a=2===a?0:1;break;case 10:case 8:case 11:a=1;break;default:return console.warn("Marching squares invalid state: "+n),!0}switch(a){case 0:s--,u-=t.pixelGroup;break;case 1:s++,u+=t.pixelGroup;break;case 3:i--,l-=t.pixelGroup;break;case 2:i++,l+=t.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+n),!0}}return!0}for(let n=0;n<t.width;n++)for(let i=0;i<t.height;i++){if(t.get(n,i)<=e)continue;const a=o(n,i);if(!(a<0||15===a)&&s(n,i))return r.path()}return null}const LB={maxRoutingIterations:100,maxMarchingIterations:20,pixelGroup:4,edgeR0:10,edgeR1:20,nodeR0:15,nodeR1:50,morphBuffer:10,threshold:1,memberInfluenceFactor:1,edgeInfluenceFactor:1,nonMemberInfluenceFactor:-.8,virtualEdges:!0};function _B(t){return null!=t&&"number"==typeof t.radius}function IB(t,e){if(_B(t)!==_B(e))return!1;if(_B(t)){const n=e;return t.cx===n.cx&&t.cy===n.cy&&t.radius===n.radius}const n=e;return t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height}var jB;!function(t){t[t.MEMBERS=0]="MEMBERS",t[t.NON_MEMBERS=1]="NON_MEMBERS",t[t.EDGES=2]="EDGES"}(jB||(jB={}));let BB=class{constructor(t={}){this.dirty=new Set,this.members=[],this.nonMembers=[],this.virtualEdges=[],this.edges=[],this.activeRegion=new mB(0,0,0,0),this.potentialArea=new bB(1,0,0,0,0,0,0),this.o=Object.assign({},LB,t)}pushMember(...t){if(0!==t.length){this.dirty.add(jB.MEMBERS);for(const e of t)this.members.push({raw:e,obj:_B(e)?yB.from(e):mB.from(e),area:null})}}removeMember(t){const e=this.members.findIndex((e=>IB(e.raw,t)));return!(e<0)&&(this.members.splice(e,1),this.dirty.add(jB.MEMBERS),!0)}removeNonMember(t){const e=this.nonMembers.findIndex((e=>IB(e.raw,t)));return!(e<0)&&(this.nonMembers.splice(e,1),this.dirty.add(jB.NON_MEMBERS),!0)}removeEdge(t){const e=this.edges.findIndex((e=>e.obj.equals(t)));return!(e<0)&&(this.edges.splice(e,1),this.dirty.add(jB.NON_MEMBERS),!0)}pushNonMember(...t){if(0!==t.length){this.dirty.add(jB.NON_MEMBERS);for(const e of t)this.nonMembers.push({raw:e,obj:_B(e)?yB.from(e):mB.from(e),area:null})}}pushEdge(...t){if(0!==t.length){this.dirty.add(jB.EDGES);for(const e of t)this.edges.push({raw:e,obj:sB.from(e),area:null})}}update(){const t=this.dirty.has(jB.MEMBERS),e=this.dirty.has(jB.NON_MEMBERS);let n=this.dirty.has(jB.EDGES);this.dirty.clear();const r=this.members.map((t=>t.obj));if(this.o.virtualEdges&&(t||e)){const t=MB(r,this.nonMembers.map((t=>t.obj)),this.o.maxRoutingIterations,this.o.morphBuffer),e=new Map(this.virtualEdges.map((t=>[t.obj.toString(),t.area])));this.virtualEdges=t.map((t=>{var n;return{raw:t,obj:t,area:null!==(n=e.get(t.toString()))&&void 0!==n?n:null}})),n=!0}let i=!1;if(t||n){const t=function(t,e){if(0===t.length)return new mB(0,0,0,0);const n=mB.from(t[0]);for(const e of t)n.add(e);for(const t of e)n.add(aB(t));return n}(r,this.virtualEdges.concat(this.edges).map((t=>t.obj))),e=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,n=mB.from(xB(t,e));n.equals(this.activeRegion)||(i=!0,this.activeRegion=n)}if(i){const t=Math.ceil(this.activeRegion.width/this.o.pixelGroup),e=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=bB.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach((t=>t.area=null)),this.nonMembers.forEach((t=>t.area=null)),this.edges.forEach((t=>t.area=null)),this.virtualEdges.forEach((t=>t.area=null))):t===this.potentialArea.width&&e===this.potentialArea.height||(this.potentialArea=bB.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}const o=new Map,a=t=>{if(t.area){const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof mB?"R":"C"}`;o.set(e,t.area)}},s=t=>{if(t.area)return;const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof mB?"R":"C"}`;if(o.has(e)){const n=o.get(e);return void(t.area=this.potentialArea.copy(n,{x:t.obj.x-this.o.nodeR1,y:t.obj.y-this.o.nodeR1}))}const n=t.obj instanceof mB?function(t,e,n){const r=e.scale(t),i=e.addPadding(r,n),o=e.createSub(i,{x:t.x-n,y:t.y-n}),a=r.x-i.x,s=r.y-i.y,l=i.x2-r.x2,u=i.y2-r.y2,c=i.width-a-l,h=i.height-s-u,d=n*n;o.fillArea({x:a,y:s,width:c+1,height:h+1},d);const f=[0],p=Math.max(s,a,l,u);{const i=e.invertScaleX(r.x+r.width/2);for(let o=1;o<p;o++){const a=e.invertScaleY(r.y-o),s=t.distSquare(i,a);if(!(s<d))break;{const t=n-Math.sqrt(s);f.push(t*t)}}}const g=[],v=Math.max(a,l),m=Math.max(s,l);for(let i=1;i<v;i++){const o=e.invertScaleX(r.x-i),a=[];for(let i=1;i<m;i++){const s=e.invertScaleY(r.y-i),l=t.distSquare(o,s);if(l<d){const t=n-Math.sqrt(l);a.push(t*t)}else a.push(0)}g.push(a)}for(let t=1;t<Math.min(s,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s-t,c+1,e)}for(let t=1;t<Math.min(u,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s+h+t,c+1,e)}for(let t=1;t<Math.min(a,f.length);t++){const e=f[t];o.fillVerticalLine(a-t,s,h+1,e)}for(let t=1;t<Math.min(u,f.length);t++){const e=f[t];o.fillVerticalLine(a+c+t,s,h+1,e)}for(let t=1;t<a;t++){const e=g[t-1],n=a-t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<u;t++)o.set(n,s+h+t,e[t-1])}for(let t=1;t<l;t++){const e=g[t-1],n=a+c+t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<u;t++)o.set(n,s+h+t,e[t-1])}return o}(t.obj,this.potentialArea,this.o.nodeR1):wB(t.obj,this.potentialArea,this.o.nodeR1);t.area=n,o.set(e,n)};this.members.forEach(a),this.nonMembers.forEach(a),this.members.forEach(s),this.nonMembers.forEach((t=>{this.activeRegion.intersects(t.obj)?s(t):t.area=null})),this.edges.forEach((t=>{t.area||(t.area=EB(t.obj,this.potentialArea,this.o.edgeR1))})),this.virtualEdges.forEach((t=>{t.area||(t.area=EB(t.obj,this.potentialArea,this.o.edgeR1))}))}drawMembers(t){for(const e of this.members)e.obj.draw(t)}drawNonMembers(t){for(const e of this.nonMembers)e.obj.draw(t)}drawEdges(t){for(const e of this.edges)e.obj.draw(t)}drawPotentialArea(t,e=!0){this.potentialArea.draw(t,e)}compute(){if(0===this.members.length)return new PB([]);this.dirty.size>0&&this.update();const{o:t,potentialArea:e}=this,n=this.members.map((t=>t.area)),r=this.virtualEdges.concat(this.edges).map((t=>t.area)),i=this.nonMembers.filter((t=>null!=t.area)).map((t=>t.area)),o=this.members.map((t=>t.obj));return function(t,e,n,r,i,o={}){const a=Object.assign({},LB,o);let s=a.threshold,l=a.memberInfluenceFactor,u=a.edgeInfluenceFactor,c=a.nonMemberInfluenceFactor;const h=(a.nodeR0-a.nodeR1)*(a.nodeR0-a.nodeR1),d=(a.edgeR0-a.edgeR1)*(a.edgeR0-a.edgeR1);for(let o=0;o<a.maxMarchingIterations;o++){if(t.clear(),0!==l){const n=l/h;for(const r of e)t.incArea(r,n)}if(0!==u){const e=u/d;for(const r of n)t.incArea(r,e)}if(0!==c){const e=c/h;for(const n of r)t.incArea(n,e)}const f=DB(t,s);if(f&&i(f))return f;if(s*=.95,o<=.5*a.maxMarchingIterations)l*=1.2,u*=1.2;else{if(!(0!==c&&r.length>0))break;c*=.8}}return new PB([])}(e,n,r,i,(t=>t.containsElements(o)),t)}};class FB extends Jj{constructor(t,e){super(t,ke({},FB.defaultOptions,e)),this.members=new Map,this.avoidMembers=new Map,this.bubbleSetOptions={},this.drawBubbleSets=()=>{const{style:t,bubbleSetOptions:e}=this.parseOptions();Ne(this.bubbleSetOptions,e)||this.init(),this.bubbleSetOptions=Object.assign({},e);const n=Object.assign(Object.assign({},t),{d:this.getPath()});this.shape?this.shape.update(n):(this.shape=new Ud({style:n}),this.context.canvas.appendChild(this.shape))},this.updateBubbleSetsPath=t=>{if(!this.shape)return;const e=yh(t.data);[...this.options.members,...this.options.avoidMembers].includes(e)&&this.shape.update(Object.assign(Object.assign({},this.parseOptions().style),{d:this.getPath(e)}))},this.getPath=t=>{const{graph:e}=this.context,n=this.options.members,r=[...this.members.keys()],i=this.options.avoidMembers,o=[...this.avoidMembers.keys()];if(!t&&Ne(n,r)&&Ne(i,o))return this.path;const{enter:a=[],exit:s=[]}=Ah(r,n,(t=>t)),{enter:l=[],exit:u=[]}=Ah(o,i,(t=>t));t&&(s.push(t),a.push(t));const c=(t,n,r)=>{t.forEach((t=>{const i=r?this.members:this.avoidMembers,o=r?"pushMember":"pushNonMember",a=r?"removeMember":"removeNonMember";if(n){let n;"edge"===e.getElementType(t)?([n]=GB(e,t),this.bubbleSets.pushEdge(n)):([n]=zB(e,t),this.bubbleSets[o](n)),i.set(t,n)}else{const n=i.get(t);n&&("edge"===e.getElementType(t)?this.bubbleSets.removeEdge(n):this.bubbleSets[a](n),i.delete(t))}}))};c(s,!1,!0),c(a,!0,!0),c(u,!1,!1),c(l,!0,!1);const h=this.bubbleSets.compute().sample(8).simplify(0).bSplines().simplify(0);return this.path=Yd(h.points.map(ed)),this.path},this.bindEvents(),this.bubbleSets=new BB(this.options)}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath)}init(){this.bubbleSets=new BB(this.options),this.members=new Map,this.avoidMembers=new Map}parseOptions(){const t=this.options,{type:e,key:n,members:r,avoidMembers:i}=t,o=Fe(t,["type","key","members","avoidMembers"]),a=Object.keys(o).reduce(((t,e)=>(e in LB?t.bubbleSetOptions[e]=o[e]:t.style[e]=o[e],t)),{style:{},bubbleSetOptions:{}});return Object.assign({type:e,key:n,members:r,avoidMembers:i},a)}addMember(t){const e=Array.isArray(t)?t:[t];e.some((t=>this.options.avoidMembers.includes(t)))&&(this.options.avoidMembers=this.options.avoidMembers.filter((t=>!e.includes(t)))),this.options.members=[...new Set([...this.options.members,...e])],this.drawBubbleSets()}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter((t=>!e.includes(t))),this.drawBubbleSets()}updateMember(t){this.options.members=Yt(t)?t(this.options.members):t,this.drawBubbleSets()}getMember(){return this.options.members}addAvoidMember(t){const e=Array.isArray(t)?t:[t];e.some((t=>this.options.members.includes(t)))&&(this.options.members=this.options.members.filter((t=>!e.includes(t)))),this.options.avoidMembers=[...new Set([...this.options.avoidMembers,...e])],this.drawBubbleSets()}removeAvoidMember(t){const e=Array.isArray(t)?t:[t];this.options.avoidMembers.some((t=>e.includes(t)))&&(this.options.avoidMembers=this.options.avoidMembers.filter((t=>!e.includes(t))),this.drawBubbleSets())}updateAvoidMember(t){this.options.avoidMembers=Array.isArray(t)?t:[t],this.drawBubbleSets()}getAvoidMember(){return this.options.avoidMembers}destroy(){this.context.graph.off(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.off(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath),this.shape.destroy(),super.destroy()}}FB.defaultOptions=Object.assign({members:[],avoidMembers:[],fill:"lightblue",fillOpacity:.2,stroke:"blue",strokeOpacity:.2},LB);const zB=(t,e)=>(Array.isArray(e)?e:[e]).map((e=>{const n=t.getElementRenderBounds(e);return new mB(n.min[0],n.min[1],$c(n),qc(n))})),GB=(t,e)=>(Array.isArray(e)?e:[e]).map((e=>{const n=t.getEdgeData(e),r=t.getElementPosition(n.source),i=t.getElementPosition(n.target);return sB.from({x1:r[0],y1:r[1],x2:i[0],y2:i[1]})}));class VB extends Jj{constructor(t,e){super(t,Object.assign({},VB.defaultOptions,e)),this.targetElement=null,this.onTriggerEvent=t=>{var e;null===(e=t.preventDefault)||void 0===e||e.call(t),this.show(t)},this.onMenuItemClick=t=>{const{onClick:e,trigger:n}=this.options;if(t.target instanceof HTMLElement&&t.target.className.includes("g6-contextmenu-li")){const n=t.target.getAttribute("value");null==e||e(n,t.target,this.targetElement),this.hide()}"click"!==n&&this.hide()},this.initElement(),this.update(e)}initElement(){this.$element=tB("contextmenu",!1,{zIndex:"99"});const{className:t}=this.options;t&&this.$element.classList.add(t);this.context.canvas.getContainer().appendChild(this.$element),eB("g6-contextmenu-css","style",{},"\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",document.head)}show(t){return ze(this,void 0,void 0,(function*(){const{enable:e,offset:n}=this.options;if("function"==typeof e&&!e(t)||!e)return void this.hide();const r=yield this.getDOMContent(t);r instanceof HTMLElement?(this.$element.innerHTML="",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",this.targetElement=t.target}))}hide(){this.$element.style.display="none",this.targetElement=null}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy(),this.$element.remove()}getDOMContent(t){return ze(this,void 0,void 0,(function*(){const{getContent:e,getItems:n}=this.options;return n?`\n <ul class="g6-contextmenu-ul">\n ${(yield n(t)).map((t=>`<li class="g6-contextmenu-li" value="${t.value}">${t.name}</li>`)).join("")}\n </ul>\n `:yield 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)}}VB.defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'<div class="g6-contextmenu-loading">Loading...</div>',getContent:()=>"It is a empty context menu.",enable:()=>!0};class WB extends Jj{constructor(t,e){super(t,Object.assign({},WB.defaultOptions,e)),this.edgeBundles={},this.edgePoints={},this.onBundle=()=>{const{model:t,element:e}=this.context,n=t.getEdgeData();this.divideEdges(this.options.divisions);const{cycles:r,iterRate:i,divRate:o}=this.options;let{lambda:a,divisions:s,iterations:l}=this.options;for(let t=0;t<r;t++){for(let t=0;t<l;t++){const t={};n.forEach((e=>{var n;if(e.source===e.target)return;const r=yh(e);t[r]=this.getEdgeForces(e,s,a);for(let e=0;e<s+1;e++)(n=this.edgePoints)[r]||(n[r]=[]),this.edgePoints[r][e]=Ih(this.edgePoints[r][e],t[r][e])}))}a/=2,s*=o,l*=i,this.divideEdges(s)}n.forEach((t=>{const n=yh(t),r=e.getElement(n);null==r||r.update({d:qp(this.edgePoints[n])})}))},this.bindEvents()}get nodeMap(){const t=this.context.model.getNodeData();return Object.fromEntries(t.map((t=>[yh(t),Uh(Qh(t))])))}divideEdges(t){this.context.model.getEdgeData().forEach((e=>{var n;const r=yh(e);(n=this.edgePoints)[r]||(n[r]=[]);const i=this.nodeMap[e.source],o=this.nodeMap[e.target];if(1===t)this.edgePoints[r].push(i),this.edgePoints[r].push(Fh(Ih(i,o),2)),this.edgePoints[r].push(o);else{const e=(0===this.edgePoints[r].length?Gh(i,o):KB(this.edgePoints[r]))/(t+1);let n=e;const a=[i];for(let t=1;t<this.edgePoints[r].length;t++){const i=this.edgePoints[r][t-1],o=this.edgePoints[r][t];let s=Gh(o,i);for(;s>n;){const t=n/s,r=Ih(i,Bh(jh(o,i),t));a.push(r),s-=n,n=e}n-=s}a.push(o),this.edgePoints[r]=a}}))}getVectorPosition(t){const e=this.nodeMap[t.source],n=this.nodeMap[t.target],[r,i]=jh(n,e);return{source:e,target:n,vx:r,vy:i,length:Gh(e,n)}}measureEdgeCompatibility(t,e){const n=this.getVectorPosition(t),r=this.getVectorPosition(e);return HB(n,r)*YB(n,r)*UB(n,r)*XB(n,r)}getEdgeBundles(){const t={},e=this.options.bundleThreshold,n=this.context.model.getEdgeData();return n.forEach(((r,i)=>{n.forEach(((n,o)=>{var a,s;if(o<=i)return;this.measureEdgeCompatibility(r,n)>=e&&(t[a=yh(r)]||(t[a]=[]),t[yh(r)].push(n),t[s=yh(n)]||(t[s]=[]),t[yh(n)].push(r))}))})),t}getSpringForce(t,e){const{pre:n,cur:r,next:i}=t;return Bh(jh(Ih(n,i),Bh(r,2)),e)}getElectrostaticForce(t,e){Se(this.edgeBundles)&&(this.edgeBundles=this.getEdgeBundles());const n=this.edgeBundles[yh(e)];let r=[0,0];return null==n||n.forEach((n=>{const i=this.edgePoints[yh(n)][t],o=this.edgePoints[yh(e)][t],a=jh(i,o),s=Gh(i,o);r=Ih(r,Bh(a,1/s))})),r}getEdgeForces(t,e,n){const r=this.nodeMap[t.source],i=this.nodeMap[t.target],o=this.options.K/(Gh(r,i)*(e+1)),a=[[0,0]],s=yh(t);for(let r=1;r<e;r++){const e=this.getSpringForce({pre:this.edgePoints[s][r-1],cur:this.edgePoints[s][r],next:this.edgePoints[s][r+1]||[0,0]},o),i=this.getElectrostaticForce(r,t);a.push(Bh(Ih(e,i),n))}return a.push([0,0]),a}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_RENDER,this.onBundle)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_RENDER,this.onBundle)}destroy(){this.unbindEvents(),super.destroy()}}WB.defaultOptions={K:.1,lambda:.1,divisions:1,divRate:2,cycles:6,iterations:90,iterRate:2/3,bundleThreshold:.6};const HB=(t,e)=>Math.abs(function(t,e){return t.reduce(((t,n,r)=>t+n*e[r]),0)}([t.vx,t.vy],[e.vx,e.vy])/(t.length*e.length)),YB=(t,e)=>{const n=(t.length+e.length)/2;return 2/(n/Math.min(t.length,e.length)+Math.max(t.length,e.length)/n)},UB=(t,e)=>{const n=(t.length+e.length)/2;return n/(n+Gh(Fh(Ih(t.source,t.target),2),Fh(Ih(e.source,e.target),2)))},$B=(t,e)=>{if(e.source[0]===e.target[0])return[e.source[0],t[1]];if(e.source[1]===e.target[1])return[t[0],e.source[1]];const n=(e.source[1]-e.target[1])/(e.source[0]-e.target[0]),r=(n*n*e.source[0]+n*(t[1]-e.source[1])+t[0])/(n*n+1);return[r,n*(r-e.source[0])+e.source[1]]},qB=(t,e)=>{const n=$B(e.source,t),r=$B(e.target,t),i=Fh(Ih(n,r),2),o=Fh(Ih(t.source,t.target),2);return 0===Gh(n,r)?0:Math.max(0,1-2*Gh(o,i)/Gh(n,r))},XB=(t,e)=>Math.min(qB(t,e),qB(e,t)),KB=t=>{let e=0;for(let n=1;n<t.length;n++)e+=Gh(t[n],t[n-1]);return e},ZB={fill:"#fff",fillOpacity:1,lineWidth:1,stroke:"#000",strokeOpacity:.8,zIndex:-1/0};class QB extends Jj{constructor(t,e){super(t,Object.assign({},QB.defaultOptions,e)),this.shapes=new Map,this.r=this.options.r,this.onEdgeFilter=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=ed(t.canvas);this.renderLens(e),this.renderFocusElements()},this.renderLens=t=>{const e=Object.assign({},ZB,this.options.style);this.isLensOn||(this.lens=new ef({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,nd(t),{size:2*this.r}),this.lens.update(e)},this.getFilterData=()=>{const{filter:t}=this.options,{model:e}=this.context,n=e.getData();if(!t)return n;const{nodes:r,edges:i,combos:o}=n;return{nodes:r.filter((e=>t(yh(e),"node"))),edges:i.filter((e=>t(yh(e),"edge"))),combos:o.filter((e=>t(yh(e),"combo")))}},this.getFocusElements=t=>{const{nodes:e,edges:n}=this.getFilterData(),r=e.filter((e=>Gh(Qh(e),t)<this.r)),i=r.map((t=>yh(t)));return{nodes:r,edges:n.filter((t=>{const{source:e,target:n}=t,r=i.includes(e),o=i.includes(n);switch(this.options.nodeType){case"both":return r&&o;case"either":return r!==o;case"source":return r&&!o;case"target":return!r&&o;default:return!1}}))}},this.renderFocusElements=()=>{const{element:t,graph:e}=this.context;if(!this.isLensOn)return;const n=this.lens.getCenter(),{nodes:r,edges:i}=this.getFocusElements(n),o=new Set,a=n=>{const r=yh(n);o.add(r);const i=t.getElement(r);if(!i)return;const a=this.shapes.get(r)||i.cloneNode();a.setPosition(i.getPosition()),a.id=i.id,this.shapes.has(r)?Object.entries(i.attributes).forEach((([t,e])=>{a.style[t]!==e&&(a.style[t]=e)})):(this.canvas.appendChild(a),this.shapes.set(r,a));const s=e.getElementType(r),l=this.getElementStyle(s,n);a.update(l)};r.forEach(a),i.forEach(a),this.shapes.forEach(((t,e)=>{o.has(e)||(t.destroy(),this.shapes.delete(e))}))},this.scaleRByWheel=t=>{var e;this.options.preventDefault&&t.preventDefault();const{clientX:n,clientY:r,deltaX:i,deltaY:o}=t,{graph:a,canvas:s}=this.context,l=a.getCanvasByClient([n,r]),u=null===(e=this.lens)||void 0===e?void 0:e.getCenter();if(!this.isLensOn||Gh(l,u)>this.r)return;const{maxR:c,minR:h}=this.options,d=i+o>0?1/.95:.95,f=Math.min(...s.getSize())/2;this.r=Math.max(h||0,Math.min(c||f,this.r*d)),this.renderLens(u),this.renderFocusElements()},this.isLensDragging=!1,this.onDragStart=t=>{var e;const n=ed(t.canvas),r=null===(e=this.lens)||void 0===e?void 0:e.getCenter();!this.isLensOn||Gh(n,r)>this.r||(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=ed(t.canvas);this.renderLens(e),this.renderFocusElements()},this.onDragEnd=()=>{this.isLensDragging=!1},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}getElementStyle(t,e){const n="node"===t?this.options.nodeStyle:this.options.edgeStyle;return"function"==typeof n?n(e):n}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.addEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.addEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.addEventListener(t.CommonEvent.DRAG,this.onDrag),o.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel,{passive:!1}))}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.removeEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.removeEventListener(t.CommonEvent.DRAG,this.onDrag),o.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel))}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),this.isLensOn&&this.lens.destroy(),this.shapes.forEach(((t,e)=>{t.destroy(),this.shapes.delete(e)})),super.destroy()}}QB.defaultOptions={trigger:"pointermove",r:60,nodeType:"both",filter:()=>!0,style:{lineWidth:2},nodeStyle:{label:!1},edgeStyle:{label:!0},scaleRBy:"wheel",preventDefault:!0};const JB={fill:"#ccc",fillOpacity:.1,lineWidth:2,stroke:"#000",strokeOpacity:.8,labelFontSize:12};class tF extends Jj{constructor(t,e){super(t,Object.assign({},tF.defaultOptions,e)),this.r=this.options.r,this.d=this.options.d,this.onCreateFisheye=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=ed(t.canvas);this.onMagnify(e)},this.onMagnify=t=>{t.some(isNaN)||(this.renderLens(t),this.renderFocusElements())},this.renderLens=t=>{const e=Object.assign({},JB,this.options.style);this.isLensOn||(this.lens=new ef({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,nd(t),{size:2*this.r,label:this.options.showDPercent,labelText:this.getDPercent()}),this.lens.update(e)},this.getDPercent=()=>{const{minD:t,maxD:e}=this.options;return`${Math.round((this.d-t)/(e-t)*100)}%`},this.prevMagnifiedStyleMap=new Map,this.prevOriginStyleMap=new Map,this.renderFocusElements=()=>{if(!this.isLensOn)return;const{graph:t}=this.context,e=this.lens.getCenter(),n=(this.d+1)*this.r,r=new Map,i=new Map;t.getNodeData().forEach((o=>{const a=Qh(o),s=Gh(a,e);if(s>this.r)return;const l=n*s/(this.d*s+this.r),[u,c]=a,[h,d]=e,f=[h+l*((u-h)/s),d+l*((c-d)/s)],p=yh(o),g=this.getNodeStyle(o),v=Ce(t.getElementRenderStyle(p),Object.keys(g));r.set(p,Object.assign(Object.assign({},nd(f)),g)),i.set(p,Object.assign(Object.assign({},nd(a)),v))})),this.updateStyle(r,i)},this.getNodeStyle=t=>{const{nodeStyle:e}=this.options;return"function"==typeof e?e(t):e},this.updateStyle=(t,e)=>{const{graph:n,element:r}=this.context,{enter:i,exit:o,keep:a}=Ah(Array.from(this.prevMagnifiedStyleMap.keys()),Array.from(t.keys()),(t=>t)),s=new Set,l=(t,e)=>{const i=r.getElement(t);null==i||i.update(e),n.getRelatedEdgesData(t).forEach((t=>{s.add(yh(t))}))};[...i,...a].forEach((e=>{l(e,t.get(e))})),o.forEach((t=>{l(t,this.prevOriginStyleMap.get(t)),this.prevOriginStyleMap.delete(t)})),s.forEach((t=>{const e=r.getElement(t);null==e||e.update({})})),this.prevMagnifiedStyleMap=t,e.forEach(((t,e)=>{this.prevOriginStyleMap.has(e)||this.prevOriginStyleMap.set(e,t)}))},this.isWheelValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;const{clientX:e,clientY:n}=t;return!(Gh(this.context.graph.getCanvasByClient([e,n]),this.lens.getCenter())>this.r)},this.scaleR=t=>{const{maxR:e,minR:n}=this.options,r=t?1/.95:.95,i=Math.min(...this.context.canvas.getSize())/2;this.r=Math.max(n||0,Math.min(e||i,this.r*r))},this.scaleD=t=>{const{maxD:e,minD:n}=this.options,r=t?this.d+.1:this.d-.1;this.d=Math.max(n,Math.min(e,r))},this.scaleRByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleR(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleD(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.isDragValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;return!(Gh(ed(t.canvas),this.lens.getCenter())>this.r)},this.isLensDragging=!1,this.onDragStart=t=>{this.isDragValid(t)&&(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=ed(t.canvas);this.onMagnify(e)},this.onDragEnd=()=>{this.isLensDragging=!1},this.scaleRByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleR(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleD(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,a=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&a.addEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&a.addEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){a.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),a.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;a.addEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,n,{passive:!1})}}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,a=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&a.removeEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&a.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){a.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),a.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;a.removeEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,n)}}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){var t;this.unbindEvents(),this.isLensOn&&(null===(t=this.lens)||void 0===t||t.destroy()),this.prevMagnifiedStyleMap.clear(),this.prevOriginStyleMap.clear(),super.destroy()}}tF.defaultOptions={trigger:"pointermove",r:120,d:1.5,maxD:5,minD:0,showDPercent:!0,style:{},nodeStyle:{label:!0},preventDefault:!0};class eF extends Jj{constructor(t,e){super(t,Object.assign({},eF.defaultOptions,e)),this.$el=this.context.canvas.getContainer(),this.graphSize=[0,0],this.onFullscreenChange=()=>{var t,e,n,r;const i=!!document.fullscreenElement;this.options.autoFit&&this.setGraphSize(i),i?null===(e=(t=this.options).onEnter)||void 0===e||e.call(t):null===(r=(n=this.options).onExit)||void 0===r||r.call(n)},this.shortcut=new gd(t.graph),this.bindEvents(),this.style=document.createElement("style"),document.head.appendChild(this.style),this.style.innerHTML="\n :not(:root):fullscreen::backdrop {\n background: transparent;\n }\n "}bindEvents(){this.unbindEvents(),this.shortcut.unbindAll();const{request:t=[],exit:e=[]}=this.options.trigger;this.shortcut.bind(t,this.request),this.shortcut.bind(e,this.exit);["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach((t=>{document.addEventListener(t,this.onFullscreenChange,!1)}))}unbindEvents(){this.shortcut.unbindAll();["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach((t=>{document.removeEventListener(t,this.onFullscreenChange,!1)}))}setGraphSize(t=!0){var e,n;let r,i;t?(r=(null===(e=globalThis.screen)||void 0===e?void 0:e.width)||0,i=(null===(n=globalThis.screen)||void 0===n?void 0:n.height)||0,this.graphSize=this.context.graph.getSize()):[r,i]=this.graphSize,this.context.graph.setSize(r,i),this.context.graph.render()}request(){!document.fullscreenElement&&(document.fullscreenEnabled||Reflect.get(document,"webkitFullscreenEnabled")||Reflect.get(document,"mozFullscreenEnabled")||Reflect.get(document,"msFullscreenEnabled"))&&this.$el.requestFullscreen().catch((t=>{Tc(`Error attempting to enable full-screen: ${t.message} (${t.name})`)}))}exit(){document.fullscreenElement&&document.exitFullscreen()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.exit(),this.style.remove(),super.destroy()}}eF.defaultOptions={trigger:{},autoFit:!0};class nF extends Jj{constructor(t,e){super(t,Object.assign({},nF.defaultOptions,e)),this.$element=tB("grid-line",!0),this.offset=[0,0],this.onTransform=t=>{if(!this.options.follow)return;const{data:{translate:e}}=t;e&&this.updateOffset(e)};this.context.canvas.getContainer().prepend(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`,backgroundRepeat:"repeat"})}updateOffset(t){this.offset=function(t,e){return t.map((t=>t%e))}(Ih(this.offset,t),this.options.size),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}destroy(){this.context.graph.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform),this.$element.remove(),super.destroy()}}function rF(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=yh(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.Removed.has(i)||e.Updated.set(i,t);else"NodeRemoved"!==n&&"EdgeRemoved"!==n&&"ComboRemoved"!==n||(e.Added.has(i)?e.Added.delete(i):e.Updated.has(i)?(e.Updated.delete(i),e.Removed.set(i,t)):e.Removed.set(i,t))})),[...Array.from(e.Added.values()),...Array.from(e.Updated.values()),...Array.from(e.Removed.values())]}function iF(t){const{NodeAdded:e=[],NodeUpdated:n=[],NodeRemoved:r=[],EdgeAdded:i=[],EdgeUpdated:o=[],EdgeRemoved:a=[],ComboAdded:s=[],ComboUpdated:l=[],ComboRemoved:u=[]}=ie(t,(t=>t.type));return{add:{nodes:e,edges:i,combos:s},update:{nodes:n,edges:o,combos:l},remove:{nodes:r,edges:a,combos:u}}}function oF(t,e){for(const n in t)qt(t[n])&&!Array.isArray(t[n])&&null!==t[n]?(e[n]||(e[n]={}),oF(t[n],e[n])):void 0===e[n]&&(e[n]=Rc(n))}function aF(t,e=!1,n){const r={animation:e,current:{add:{},update:{},remove:{}},original:{add:{},update:{},remove:{}}},{add:i,update:o,remove:a}=iF(rF(t));return["nodes","edges","combos"].forEach((t=>{o[t]&&o[t].forEach((e=>{var i,o;const a=Object.assign({},e.value);let s=Object.assign({},e.original);if(n){const t=n.graph.getElementType(yh(e.original)),r="edge"===t?"stroke":"fill",i=n.element.getElementComputedStyle(t,e.original);s=Object.assign(Object.assign({},e.original),{style:Object.assign({[r]:i[r]},e.original.style)})}oF(a,s),(i=r.current.update)[t]||(i[t]=[]),r.current.update[t].push(a),(o=r.original.update)[t]||(o[t]=[]),r.original.update[t].push(s)})),i[t]&&i[t].forEach((e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.add)[t]||(n[t]=[]),r.current.add[t].push(o),(i=r.original.remove)[t]||(i[t]=[]),r.original.remove[t].push(o)})),a[t]&&a[t].forEach((e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.remove)[t]||(n[t]=[]),r.current.remove[t].push(o),(i=r.original.add)[t]||(i[t]=[]),r.original.add[t].push(o)}))})),r}nF.defaultOptions={border:!0,borderLineWidth:1,borderStroke:"#eee",borderStyle:"solid",lineWidth:1,size:20,stroke:"#eee"};class sF extends Jj{constructor(e,n){super(e,Object.assign({},sF.defaultOptions,n)),this.batchChanges=null,this.batchAnimation=!1,this.undoStack=[],this.redoStack=[],this.freezed=!1,this.executeCommand=(t,e=!0)=>{var n,r,i;this.freezed=!0,null===(r=(n=this.options).executeCommand)||void 0===r||r.call(n,t);const o=e?t.original:t.current;this.context.graph.addData(o.add),this.context.graph.updateData(o.update),this.context.graph.removeData(xh(o.remove,!1)),null===(i=this.context.element)||void 0===i||i.draw({silence:!0,animation:t.animation}),this.freezed=!1},this.addCommand=e=>{var n;if(!this.freezed){if(e.type===t.GraphEvent.AFTER_DRAW){const{dataChanges:t=[],animation:r=!0}=e.data;if(null===(n=this.context.batch)||void 0===n?void 0:n.isBatching){if(!this.batchChanges)return;return this.batchChanges.push(t),void(this.batchAnimation&&(this.batchAnimation=r))}this.batchChanges=[t],this.batchAnimation=r}this.undoStackPush(aF(this.batchChanges.flat(),this.batchAnimation,this.context)),this.notify(t.HistoryEvent.ADD,this.undoStack[this.undoStack.length-1])}},this.initBatchCommand=t=>{const{initiate:e}=t.data;if(this.batchAnimation=!1,e)this.batchChanges=[];else{this.undoStack.pop()||(this.batchChanges=null)}},this.emitter=new zg;const{graph:r}=this.context;r.on(t.GraphEvent.AFTER_DRAW,this.addCommand),r.on(t.GraphEvent.BATCH_START,this.initBatchCommand),r.on(t.GraphEvent.BATCH_END,this.addCommand)}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}undo(){var e,n,r,i;const o=this.undoStack.pop();if(o){this.executeCommand(o);if(!1===(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,o,!1)))return;this.redoStack.push(o),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,o,!1),this.notify(t.HistoryEvent.UNDO,o)}return this}redo(){const e=this.redoStack.pop();return e&&(this.executeCommand(e,!1),this.undoStackPush(e),this.notify(t.HistoryEvent.REDO,e)),this}undoAndCancel(){const e=this.undoStack.pop();return e&&(this.executeCommand(e,!1),this.redoStack=[],this.notify(t.HistoryEvent.CANCEL,e)),this}undoStackPush(t){var e,n,r,i;const{stackSize:o}=this.options;0!==o&&this.undoStack.length>=o&&this.undoStack.shift();!1!==(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,t,!0))&&(this.undoStack.push(t),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,t,!0))}clear(){this.undoStack=[],this.redoStack=[],this.batchChanges=null,this.batchAnimation=!1,this.notify(t.HistoryEvent.CLEAR,null)}notify(e,n){this.emitter.emit(e,{cmd:n}),this.emitter.emit(t.HistoryEvent.CHANGE,{cmd:n})}on(t,e){this.emitter.on(t,e)}destroy(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.addCommand),e.off(t.GraphEvent.BATCH_START,this.initBatchCommand),e.off(t.GraphEvent.BATCH_END,this.addCommand),this.emitter.off(),super.destroy(),this.undoStack=[],this.redoStack=[]}}function lF(t,e,n,r,i,o){const a=(o-e)*(n-t)-(r-e)*(i-t);return a>0||!(a<0)}sF.defaultOptions={stackSize:0};var uF=function(t,e){const n=t[0][0],r=t[0][1],i=t[1][0],o=t[1][1],a=e[0][0],s=e[0][1],l=e[1][0],u=e[1][1];return lF(n,r,a,s,l,u)!==lF(i,o,a,s,l,u)&&lF(n,r,i,o,a,s)!==lF(n,r,i,o,l,u)};function cF(t,e){this._cells=[],this._cellSize=e,this._reverseCellSize=1/e;for(let e=0;e<t.length;e++){const n=t[e],r=this.coordToCellNum(n[0]),i=this.coordToCellNum(n[1]);if(this._cells[r])this._cells[r][i]?this._cells[r][i].push(n):this._cells[r][i]=[n];else{const t=[];t[i]=[n],this._cells[r]=t}}}function hF(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}cF.prototype={cellPoints:function(t,e){return void 0!==this._cells[t]&&void 0!==this._cells[t][e]?this._cells[t][e]:[]},rangePoints:function(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this.coordToCellNum(t[2]),i=this.coordToCellNum(t[3]),o=[];for(let t=e;t<=r;t++)for(let e=n;e<=i;e++)for(let n=0;n<this.cellPoints(t,e).length;n++)o.push(this.cellPoints(t,e)[n]);return o},removePoint:function(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this._cells[e][n];let i;for(let e=0;e<r.length;e++)if(r[e][0]===t[0]&&r[e][1]===t[1]){i=e;break}return r.splice(i,1),r},trunc:Math.trunc||function(t){return t-t%1},coordToCellNum:function(t){return this.trunc(t*this._reverseCellSize)},extendBbox:function(t,e){return[t[0]-e*this._cellSize,t[1]-e*this._cellSize,t[2]+e*this._cellSize,t[3]+e*this._cellSize]}};var dF=function(t){const e=function(t){const e=[];for(let n=0;n<t.length;n++){for(;e.length>=2&&hF(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}return e.pop(),e}(t),n=function(t){const e=t.reverse(),n=[];for(let t=0;t<e.length;t++){for(;n.length>=2&&hF(n[n.length-2],n[n.length-1],e[t])<=0;)n.pop();n.push(e[t])}return n.pop(),n}(t),r=n.concat(e);return r.push(t[0]),r};const fF=uF,pF=function(t,e){return new cF(t,e)},gF={toXy:function(t,e){return void 0===e?t.slice():t.map((function(t){return new Function("pt","return [pt"+e[0]+",pt"+e[1]+"];")(t)}))},fromXy:function(t,e){return void 0===e?t.slice():t.map((function(t){return new Function("pt","const o = {}; o"+e[0]+"= pt[0]; o"+e[1]+"= pt[1]; return o;")(t)}))}},vF=dF;function mF(t,e){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function yF(t,e,n){const r=[e[0]-t[0],e[1]-t[1]],i=[n[0]-t[0],n[1]-t[1]],o=mF(t,e),a=mF(t,n);return(r[0]*i[0]+r[1]*i[1])/Math.sqrt(o*a)}function bF(t,e){for(let n=0;n<e.length-1;n++){const r=[e[n],e[n+1]];if(!(t[0][0]===r[0][0]&&t[0][1]===r[0][1]||t[0][0]===r[1][0]&&t[0][1]===r[1][1])&&fF(t,r))return!0}return!1}function xF(t){return[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])]}function EF(t,e,n){let r,i,o=null,a=kF,s=kF;for(let l=0;l<e.length;l++)r=yF(t[0],t[1],e[l]),i=yF(t[1],t[0],e[l]),r>a&&i>s&&!bF([t[0],e[l]],n)&&!bF([t[1],e[l]],n)&&(a=r,s=i,o=e[l]);return o}function wF(t,e,n,r,i){let o=!1;for(let a=0;a<t.length-1;a++){const s=[t[a],t[a+1]],l=s[0][0]+","+s[0][1]+","+s[1][0]+","+s[1][1];if(mF(s[0],s[1])<e||i.has(l))continue;let u,c,h,d=0,f=xF(s);do{f=r.extendBbox(f,d),u=f[2]-f[0],c=f[3]-f[1],h=EF(s,r.rangePoints(f),t),d++}while(null===h&&(n[0]>u||n[1]>c));u>=n[0]&&c>=n[1]&&i.add(l),null!==h&&(t.splice(a+1,0,h),r.removePoint(h),o=!0)}return o?wF(t,e,n,r,i):t}const kF=Math.cos(90/(180/Math.PI)),MF=.6;var SF=function(t,e,n){let r=e||20;const i=function(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];n[0]===i[0]&&n[1]===i[1]||e.push(i),n=i}return e}(function(t){return t.sort((function(t,e){return t[0]-e[0]||t[1]-e[1]}))}(gF.toXy(t,n)));if(i.length<4){const t=i.concat([i[0]]);return n?gF.fromXy(t,n):t}const o=function(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let o=t.length-1;o>=0;o--)t[o][0]<e&&(e=t[o][0]),t[o][1]<n&&(n=t[o][1]),t[o][0]>r&&(r=t[o][0]),t[o][1]>i&&(i=t[o][1]);return[r-e,i-n]}(i),a=[o[0]*MF,o[1]*MF],s=vF(i),l=i.filter((function(t){return s.indexOf(t)<0})),u=Math.ceil(1/(i.length/(o[0]*o[1]))),c=wF(s,Math.pow(r,2),a,pF(l,u),new Set);return n?gF.fromXy(c,n):c},NF=E(SF);const OF=(t,e,n)=>{if("sharp"===n)return[["M",t[0]-e,t[1]-e],["L",t[0]+e,t[1]-e],["L",t[0]+e,t[1]+e],["L",t[0]-e,t[1]+e],["Z"]];const r=[e,e,0,0,0];return[["M",t[0],t[1]-e],["A",...r,t[0],t[1]+e],["A",...r,t[0],t[1]-e]]},TF=(t,e,n)=>{const r=[e,e,0,0,0],i="sharp"===n?Ih(t[0],zh(Wh(jh(t[0],t[1])),e)):t[0],o="sharp"===n?Ih(t[1],zh(Wh(jh(t[1],t[0])),e)):t[1],a=zh(Wh(Yh(jh(i,o),!1)),e),s=zh(a,-1),l=Ih(i,a),u=Ih(o,a),c=Ih(o,s),h=Ih(i,s);return"sharp"===n?[["M",l[0],l[1]],["L",u[0],u[1]],["L",c[0],c[1]],["L",h[0],h[1]],["Z"]]:[["M",l[0],l[1]],["L",u[0],u[1]],["A",...r,c[0],c[1]],["L",h[0],h[1]],["A",...r,l[0],l[1]]]},AF=(t,e)=>{const n=dd(t).map(((n,r)=>{const i=(r-2+t.length)%t.length,o=(r-1+t.length)%t.length,a=(r+1)%t.length,s=t[i],l=t[o],u=t[a],c=jh(s,l),h=jh(l,n),d=jh(n,u),f=(t,e)=>Hh(t,e,!0)<Math.PI,p=f(c,h),g=f(h,d),v=t=>zh(Wh(Yh(t,!1)),e),m=v(h);return[{p:Uh(Ih(l,p?v(c):m)),concave:p&&l},{p:Uh(Ih(n,g?v(d):m)),concave:g&&n}]})),r=[e,e,0,0,0],i=n.findIndex(((t,e)=>!(n[(e-1+n.length)%n.length][0].concave||n[(e-1+n.length)%n.length][1].concave||t[0].concave||t[0].concave||t[1].concave))),o=n.slice(i).concat(n.slice(0,i));let a=[];return o.flatMap(((t,e)=>{const i=[],s=o[n.length-1];return 0===e&&i.push(["M",...s[1].p]),t[0].concave?a.push(t[0].p,t[1].p):i.push(["A",...r,...t[0].p]),t[1].concave?a.unshift(t[1].p):i.push(["L",...t[1].p]),3===a.length&&(i.pop(),i.push(["C",...a.flat()]),a=[]),i}))},CF=(t,e)=>{const n=dd(t).map(((e,n)=>({p:e,v:Wh(jh(t[(n+1)%t.length],e))})));return n.forEach(((r,i)=>{const o=i>0?i-1:t.length-1,a=n[o].v,s=Wh(Ih(a,zh(r.v,Hh(a,r.v,!0)<Math.PI?1:-1)));r.p=Ih(r.p,zh(s,e))})),Yd(n.map((t=>t.p)))},PF=(t,e)=>{const n=t.map(((n,r)=>{const i=t[0===r?t.length-1:r-1],o=$h(zh(Wh(Yh(jh(i,n),!1)),e));return[Ih(i,o),Ih(n,o)]})),r=n.flat();return r.map(((t,e)=>{if(e%2==0)return null;return Kh([r[(e-1)%r.length],r[e%r.length]],[r[(e+1)%r.length],r[(e+2)%r.length]],!0)})).filter(Boolean).map(((t,e)=>[0===e?"M":"L",t[0],t[1]])).concat([["Z"]])};class RF extends Jj{constructor(t,e){super(t,Object.assign({},RF.defaultOptions,e)),this.hullMemberIds=[],this.drawHull=()=>{if(this.shape){const t=!Ne(this.optionsCache,this.options);this.shape.update(this.getHullStyle(t))}else this.shape=new Ud({style:this.getHullStyle()}),this.context.canvas.appendChild(this.shape);this.optionsCache=Object.assign({},this.options)},this.updateHullPath=t=>{this.shape&&this.options.members.includes(yh(t.data))&&this.shape.update({d:this.getHullPath(!0)})},this.getHullPath=(t=!1)=>{const{graph:e}=this.context,n=this.getMember();if(0===n.length)return"";const r=n.map((t=>e.getNodeData(t))),i=NF(r.map(Qh),this.options.concavity).slice(1).reverse(),o=i.flatMap((t=>r.filter((e=>Ne(Qh(e),t))).map(yh)));return Ne(o,this.hullMemberIds)&&!t||(this.hullMemberIds=o,this.path=function(t,e,n){if(1===t.length)return OF(t[0],e,n);if(2===t.length)return TF(t,e,n);if(3===t.length){const[r,i,o]=dd(t);if(ad(r,i,o))return TF([r,o],e,n)}switch(n){case"smooth":return CF(t,e);case"sharp":return PF(t,e);default:return AF(t,e)}}(i,this.getPadding(),this.options.corner)),this.path},this.bindEvents()}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}getHullStyle(t){const e=Fe(this.options,["members","padding","corner"]);return Object.assign(Object.assign({},e),{d:this.getHullPath(t)})}getPadding(){const{graph:t}=this.context,e=this.hullMemberIds.reduce(((e,n)=>{const{halfExtents:r}=t.getElementRenderBounds(n),i=Math.max(r[0],r[1]);return Math.max(e,i)}),0);return e+this.options.padding}addMember(t){const e=Array.isArray(t)?t:[t];this.options.members=[...new Set([...this.options.members,...e])],this.shape.update({d:this.getHullPath()})}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter((t=>!e.includes(t))),e.some((t=>this.hullMemberIds.includes(t)))&&this.shape.update({d:this.getHullPath()})}updateMember(t){this.options.members=Yt(t)?t(this.options.members):t,this.shape.update(this.getHullStyle(!0))}getMember(){return this.options.members}destroy(){this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.drawHull),this.shape.destroy(),this.hullMemberIds=[],super.destroy()}}function DF(t,e){e(t),t.children&&t.children.forEach((function(t){t&&DF(t,e)}))}function LF(t){IF(t,!0)}function _F(t){IF(t,!1)}function IF(t,e){var n=e?"visible":"hidden";DF(t,(function(t){t.attr("visibility",n)}))}RF.defaultOptions={members:[],padding:10,corner:"rounded",concavity:1/0,fill:"lightblue",fillOpacity:.2,labelOpacity:1,stroke:"blue",strokeOpacity:.2};var jF=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,We([],Ve(e),!1))||this;return r.isMutationObserved=!0,r.addEventListener(Vs.INSERTED,(function(){_F(r)})),r}return je(e,t),e}(jl);function BF(t){var e=t.appendChild(new jF({class:"offscreen"}));return _F(e),e}var FF=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=Fe(e,["style"]);return t.call(this,Be({style:Be({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return je(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=BF(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(Zl);function zF(t){return t*Math.PI/180}function GF(t){return Number((180*t/Math.PI).toPrecision(5))}var VF=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}();function WF(t,e){return Yt(t)?t.apply(void 0,We([],Ve(e),!1)):t}var HF,YF=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map((function(t){var e=Ve(t,2),r=e[0],i=e[1],o=n(i);return[r,{name:o,class:".".concat(o),id:"#".concat(o),toString:function(){return o}}]})));return Object.assign(r,{prefix:n}),r},UF=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach((function(i){var o=Ve(i,2),a=o[0],s=o[1],l=t;Object.prototype.hasOwnProperty.call(e,a)&&(s?Jt(s)?(Jt(t[a])||(l[a]={}),n<r?UF(t[a],s,n+1,r):l[a]=e[a]):$t(s)?(l[a]=[],l[a]=l[a].concat(s)):l[a]=s:l[a]=s)}))},$F=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)UF(t,e[r]);return t},qF=function(t){return void 0!==t&&null!=t&&!Number.isNaN(t)},XF=xe((function(t,e){var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return HF||(HF=bl.offscreenCanvasCreator.getOrCreateContext(void 0)),HF.font=[o,a,i,"".concat(n,"px"),r].join(" "),HF.measureText(t).width}),(function(t,e){return[t,Object.values(e||KF(t)).join()].join("")}),4096),KF=function(t){var e=t.style.fontFamily||"sans-serif",n=t.style.fontWeight||"normal",r=t.style.fontStyle||"normal",i=t.style.fontVariant,o=t.style.fontSize;return{fontSize:o="object"==typeof o?o.value:o,fontFamily:e,fontWeight:n,fontStyle:r,fontVariant:i}};function ZF(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}function QF(t,e){var n=ZF(t);n&&n.attr(e)}function JF(t,e,n){void 0===n&&(n="..."),QF(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function tz(t){var e=t.canvas,n=t.touches,r=t.offsetX,i=t.offsetY;if(e)return[e.x,e.y];if(n){var o=n[0];return[o.clientX,o.clientY]}return r&&i?[r,i]:[0,0]}function ez(t){return"function"==typeof t?t():ne(t)||ae(t)?new FF({style:{text:String(t)}}):t}function nz(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=function(t){t.node().removeChildren()}),t?n(e):(r&&i(e),null)}function rz(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=!1),!!(r&&t===e||i&&t===n)||t>e&&t<n}function iz(t,e){return"number"==typeof t&&"number"==typeof e?function(t,e){return function(n){return t*(1-n)+e*n}}(t,e):Array.isArray(t)&&Array.isArray(e)?function(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0;return function(i){var o=new Array(r),a=new Array(n),s=0;for(s=0;s<r;++s)o[s]=iz(t[s],e[s]);for(;s<n;++s)a[s]=e[s];for(s=0;s<r;++s)a[s]=o[s](i);return a}}(t,e):"object"==typeof t&&"object"==typeof e?function(t,e){void 0===t&&(t={}),void 0===e&&(e={});var n={},r={};return Object.entries(e).forEach((function(e){var i=Ve(e,2),o=i[0],a=i[1];o in t?n[o]=iz(t[o],a):r[o]=a})),function(t){return Object.entries(n).forEach((function(e){var n=Ve(e,2),i=n[0],o=n[1];return r[i]=o(t)})),r}}(t,e):function(e){return t}}function oz(t,e){return[t[0]*e,t[1]*e]}function az(t,e){return[t[0]+e[0],t[1]+e[1]]}function sz(t,e){return[t[0]-e[0],t[1]-e[1]]}function lz(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1])]}function uz(t,e){return[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}function cz(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function hz(t){if(0===t[0]&&0===t[1])return[0,0];var e=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2));return[t[0]/e,t[1]/e]}function dz(t,e){return+t.toPrecision(e)}function fz(t,e){var n={},r=Array.isArray(e)?e:[e];for(var i in t)r.includes(i)||(n[i]=t[i]);return n}function pz(t,e,n){void 0===n&&(n=[[0,0],[1,1]]);for(var r=!!e,i=[],o=0,a=t.length;o<a;o+=2)i.push([t[o],t[o+1]]);var s,l,u,c=function(t,e,n,r){var i,o,a,s,l,u,c=[],h=!!r,d=[1/0,1/0],f=[-1/0,-1/0];if(h){d=(i=Ve(r,2))[0],f=i[1];for(var p=0,g=t.length;p<g;p+=1)d=lz(d,m=t[p]),f=uz(f,m)}p=0;for(var v=t.length;p<v;p+=1){var m=t[p];if(0!==p||n)if(p!==v-1||n){o=t[p-1];var y=[0,0];y=oz(y=sz(a=t[p+1],o),e);var b=cz(m,o),x=cz(m,a),E=b+x;0!==E&&(b/=E,x/=E);var w=oz(y,-b),k=oz(y,x);l=az(m,w),s=lz(s=az(m,k),uz(a,m)),s=uz(s,lz(a,m)),l=lz(l=az(m,w=oz(w=sz(s,m),-b/x)),uz(o,m)),s=az(m,k=oz(k=sz(m,l=uz(l,lz(o,m))),x/b)),h&&(l=lz(l=uz(l,d),f),s=lz(s=uz(s,d),f)),c.push(u),c.push(l),u=s}else l=m,c.push(u),c.push(l);else u=m}return c}(i,.4,r,n),h=i.length,d=[];for(o=0;o<h-1;o+=1)s=c[2*o],l=c[2*o+1],u=i[o+1],d.push(["C",s[0],s[1],l[0],l[1],u[0],u[1]]);return d}var gz=["$el","cx","cy","d","dx","dy","fill","fillOpacity","filter","fontFamily","fontSize","fontStyle","fontVariant","fontWeight","height","img","increasedLineWidthForHitTesting","innerHTML","isBillboard","billboardRotation","isSizeAttenuation","isClosed","isOverflowing","leading","letterSpacing","lineDash","lineHeight","lineWidth","markerEnd","markerEndOffset","markerMid","markerStart","markerStartOffset","maxLines","metrics","miterLimit","offsetX","offsetY","opacity","path","points","r","radius","rx","ry","shadowColor","src","stroke","strokeOpacity","text","textAlign","textBaseline","textDecorationColor","textDecorationLine","textDecorationStyle","textOverflow","textPath","textPathSide","textPathStartOffset","transform","transformOrigin","visibility","width","wordWrap","wordWrapWidth","x","x1","x2","y","y1","y2","z1","z2","zIndex"];function vz(t){return gz.includes(t)}function mz(t){var e={};for(var n in t)vz(n)&&(e[n]=t[n]);return e}function yz(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,a=e/Math.max(i,o);return t.style.transform="scale(".concat(a,")"),a}var bz=function(){function t(t,n,r,i,o,a,s){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=[null,null,null,null,null]),void 0===a&&(a=[]),void 0===s&&(s=[]),e.add(this),this._elements=Array.from(t),this._data=n,this._parent=r,this._document=i,this._enter=o[0],this._update=o[1],this._exit=o[2],this._merge=o[3],this._split=o[4],this._transitions=a,this._facetElements=s}var e,n,r;return t.prototype.selectAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(e,null,this._elements[0],this._document)},t.prototype.selectFacetAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(this._elements,null,this._parent,this._document,void 0,void 0,e)},t.prototype.select=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t)[0]||null:t;return new n([e],null,e,this._document)},t.prototype.append=function(t){var e=this,r="function"==typeof t?t:function(){return e.createElement(t)},i=[];if(null!==this._data){for(var o=0;o<this._data.length;o++){var a=this._data[o],s=Ve(Array.isArray(a)?a:[a,null],2),l=s[0],u=s[1];(h=r(l,o)).__data__=l,null!==u&&(h.__fromElements__=u),this._parent.appendChild(h),i.push(h)}return new n(i,null,this._parent,this._document)}for(o=0;o<this._elements.length;o++){var c=this._elements[o],h=r(l=c.__data__,o);c.appendChild(h),i.push(h)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=He(this,e,"m",r).call(this,"#"===t[0]?t:"#".concat(t),n);return i.attr("id",t),i},t.prototype.maybeAppendByClassName=function(t,n){var i=t.toString(),o=He(this,e,"m",r).call(this,"."===i[0]?i:".".concat(i),n);return o.attr("className",i),o},t.prototype.maybeAppendByName=function(t,n){var i=He(this,e,"m",r).call(this,'[name="'.concat(t,'"]'),n);return i.attr("name",t),i},t.prototype.data=function(t,e,r){var i,o;void 0===e&&(e=function(t){return t}),void 0===r&&(r=function(){return null});for(var a,s,l,u=[],c=[],h=new Set(this._elements),d=[],f=new Set,p=new Map(this._elements.map((function(t,n){return[e(t.__data__,n),t]}))),g=new Map(this._facetElements.map((function(t,n){return[e(t.__data__,n),t]}))),v=(a=this._elements,s=function(t){return r(t.__data__)},l=new Map,a.forEach((function(t){var e=s(t);l.has(e)||l.set(e,[]),l.get(e).push(t)})),l),m=0;m<t.length;m++){var y=t[m],b=e(y,m),x=r(y,m);if(p.has(b))(M=p.get(b)).__data__=y,M.__facet__=!1,c.push(M),h.delete(M),p.delete(b);else if(g.has(b)){(M=g.get(b)).__data__=y,M.__facet__=!0,c.push(M),g.delete(b)}else if(v.has(b)){var E=v.get(b);d.push([y,E]);try{for(var w=(i=void 0,Ge(E)),k=w.next();!k.done;k=w.next()){var M=k.value;h.delete(M)}}catch(t){i={error:t}}finally{try{k&&!k.done&&(o=w.return)&&o.call(w)}finally{if(i)throw i.error}}v.delete(b)}else if(p.has(x)){(M=p.get(x)).__toData__?M.__toData__.push(y):M.__toData__=[y],f.add(M),h.delete(M)}else u.push(y)}var S=[new n([],u,this._parent,this._document),new n(c,null,this._parent,this._document),new n(h,null,this._parent,this._document),new n([],d,this._parent,this._document),new n(f,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,S)},t.prototype.merge=function(t){var e=We(We([],Ve(this._elements),!1),Ve(t._elements),!1),r=We(We([],Ve(this._transitions),!1),Ve(t._transitions),!1);return new n(e,null,this._parent,this._document,void 0,r)},t.prototype.createElement=function(t){if(this._document)return this._document.createElement(t,{});var e=n.registry[t];return e?new e:function(t){throw new Error(t)}("Unknown node type: ".concat(t))},t.prototype.join=function(t,e,n,r,i){void 0===t&&(t=function(t){return t}),void 0===e&&(e=function(t){return t}),void 0===n&&(n=function(t){return t.remove()}),void 0===r&&(r=function(t){return t}),void 0===i&&(i=function(t){return t.remove()});var o=t(this._enter),a=e(this._update),s=n(this._exit),l=r(this._merge),u=i(this._split);return a.merge(o).merge(s).merge(l).merge(u)},t.prototype.remove=function(){for(var t=function(t){var n=e._elements[t],r=e._transitions[t];r?r.then((function(){return n.remove()})):n.remove()},e=this,r=0;r<this._elements.length;r++)t(r);return new n([],null,this._parent,this._document,void 0,this._transitions)},t.prototype.each=function(t){for(var e=0;e<this._elements.length;e++){var n=this._elements[e],r=n.__data__;t.call(n,r,e)}return this},t.prototype.attr=function(t,e){var n="function"!=typeof e?function(){return e}:e;return this.each((function(r,i){void 0!==e&&(this[t]=n.call(this,r,i))}))},t.prototype.style=function(t,e,n){void 0===n&&(n=!0);var r="function"==typeof e&&n?e:function(){return e};return this.each((function(n,i){void 0!==e&&(this.style[t]=r.call(this,n,i))}))},t.prototype.styles=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=!0),this.each((function(n,r){var i=this;Object.entries(t).forEach((function(t){var o=Ve(t,2),a=o[0],s=o[1],l="function"==typeof s&&e?s:function(){return s};void 0!==s&&i.attr(a,l.call(i,n,r))}))}))},t.prototype.update=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.maybeUpdate=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.transition=function(t){var e=this._transitions;return this.each((function(n,r){e[r]=t.call(this,n,r)}))},t.prototype.on=function(t,e){return this.each((function(){this.addEventListener(t,e)})),this},t.prototype.call=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return t.call.apply(t,We([this._parent,this],Ve(e),!1)),this},t.prototype.node=function(){return this._elements[0]},t.prototype.nodes=function(){return this._elements},t.prototype.transitions=function(){return this._transitions.filter((function(t){return!!t}))},t.prototype.parent=function(){return this._parent},n=t,e=new WeakSet,r=function(t,e){var r=this._elements[0],i=r.querySelector(t);if(i)return new n([i],null,this._parent,this._document);var o="string"==typeof e?this.createElement(e):e();return r.appendChild(o),new n([o],null,this._parent,this._document)},t.registry={g:jl,rect:Xl,circle:Dl,path:Hl,text:FF,ellipse:Il,image:zl,line:Vl,polygon:Ul,polyline:ql,html:Fl},t}();function xz(t){return new bz([t],null,t,t.ownerDocument)}function Ez(t){if(ae(t))return[t,t,t,t];if($t(t)){var e=t.length;if(1===e)return[t[0],t[0],t[0],t[0]];if(2===e)return[t[0],t[1],t[0],t[1]];if(3===e)return[t[0],t[1],t[2],t[1]];if(4===e)return t}return[0,0,0,0]}function wz(t){var e=t.getLocalBounds(),n=Ve([e.min,e.max],2),r=Ve(n[0],2),i=r[0],o=r[1],a=Ve(n[1],2),s=a[0],l=a[1];return{x:i,y:o,width:s-i,height:l-o,left:i,bottom:l,top:o,right:s}}function kz(t,e){var n=Ve(t,2),r=n[0],i=n[1],o=Ve(e,2),a=o[0],s=o[1];return r!==a&&i===s}function Mz(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function Sz(t,e,n){var r;void 0===n&&(n=!0);var i=e||(null===(r=t.match(/^([a-z][a-z0-9]+)/))||void 0===r?void 0:r[0])||"",o=t.replace(new RegExp("^(".concat(i,")")),"");return n?function(t){return t.toString().charAt(0).toLowerCase()+t.toString().slice(1)}(o):o}var Nz=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function Oz(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach((function(t){var i=Ve(t,2),o=i[0],a=i[1];if("className"===o||"class"===o);else if(Nz(o,"show")&&Nz(Sz(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(Mz(t))}(e,"show")?r[o]=a:r[o.replace(new RegExp(Mz(e)),"")]=a;else if(!Nz(o,"show")&&Nz(o,e)!==n){var s=Sz(o,e);"filter"===s&&"function"==typeof a||(r[s]=a)}})),r}function Tz(t,e){return Object.entries(t).reduce((function(t,n){var r=Ve(n,2),i=r[0],o=r[1];return i.startsWith("show")?t["show".concat(e).concat(i.slice(4))]=o:t["".concat(e).concat(Mz(i))]=o,t}),{})}function Az(t,e){void 0===e&&(e=["x","y","class","className"]);var n=["transform","transformOrigin","anchor","visibility","pointerEvents","zIndex","cursor","clipPath","clipPathTargets","offsetPath","offsetPathTargets","offsetDistance","draggable","droppable"],r={},i={};return Object.entries(t).forEach((function(t){var o=Ve(t,2),a=o[0],s=o[1];e.includes(a)||(-1!==n.indexOf(a)?i[a]=s:r[a]=s)})),[r,i]}function Cz(t,e){var n={YYYY:t.getFullYear(),MM:t.getMonth()+1,DD:t.getDate(),HH:t.getHours(),mm:t.getMinutes(),ss:t.getSeconds()},r=e;return Object.keys(n).forEach((function(t){var e=n[t];r=r.replace(t,"YYYY"===t?"".concat(e):"".concat(e).padStart(2,"0"))})),r}function Pz(t,e){if(e)try{var n=e.replace(/translate\(([+-]*[\d]+[%]*),[ ]*([+-]*[\d]+[%]*)\)/g,(function(e,n,r){return"translate(".concat(function(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,a=Ve([e,n].map((function(t,e){var n;return t.includes("%")?parseFloat((null===(n=t.match(/[+-]?([0-9]*[.])?[0-9]+/))||void 0===n?void 0:n[0])||"0")/100*(0===e?i:o):t})),2);return[a[0],a[1]]}(t,n,r),")")}));t.attr("transform",n)}catch(t){}}var Rz=function(t,e){null!=e?t.replaceChildren?Array.isArray(e)?t.replaceChildren.apply(t,We([],Ve(e),!1)):t.replaceChildren(e):(t.innerHTML="",Array.isArray(e)?e.forEach((function(e){return t.appendChild(e)})):t.appendChild(e)):t.innerHTML=""};function Dz(){IF(this,"hidden"!==this.attributes.visibility)}var Lz=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,$F({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return je(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=BF(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&&Dz.call(this)},e.prototype.update=function(t,e){var n;return this.attr($F({},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.prototype.getSubShapeStyle=function(t){return t.x,t.y,t.transform,t.transformOrigin,t.class,t.className,t.zIndex,Fe(t,["x","y","transform","transformOrigin","class","className","zIndex"])},e}(_l),_z=function(t,e,n){return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e],["Z"]]},Iz=_z,jz=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},Bz=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},Fz=Bz;var zz=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function Gz(t){var e=function(t){var e="default";if(qt(t)&&t instanceof Image)e="image";else if(Yt(t))e="symbol";else if(ne(t)){var n=new RegExp("data:(image|text)");e=t.match(n)?"base64":/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(t)?"url":"symbol"}return e}(t);return["base64","url","image"].includes(e)?"image":t&&"symbol"===e?"path":null}var Vz=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.render=function(t,n){var r=t.x,i=void 0===r?0:r,o=t.y,a=void 0===o?0:o,s=this.getSubShapeStyle(t),l=s.symbol,u=s.size,c=void 0===u?16:u,h=Fe(s,["symbol","size"]),d=Gz(l);nz(!!d,xz(n),(function(t){t.maybeAppendByClassName("marker",d).attr("className","marker ".concat(d,"-marker")).call((function(t){if("image"===d){var n=2*c;t.styles({img:l,width:n,height:n,x:i-c,y:a-c})}else{n=c/2;var r=Yt(l)?l:e.getSymbol(l);t.styles(Be({d:null==r?void 0:r(i,a,n)},h))}}))}))},e.MARKER_SYMBOL_MAP=new Map,e.registerSymbol=function(t,n){e.MARKER_SYMBOL_MAP.set(t,n)},e.getSymbol=function(t){return e.MARKER_SYMBOL_MAP.get(t)},e.getSymbols=function(){return Array.from(e.MARKER_SYMBOL_MAP.keys())},e}(Lz);function Wz(t,...e){return e.reduce(((t,e)=>n=>t(e(n))),t)}function Hz(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}Vz.registerSymbol("cross",(function(t,e,n){return[["M",t-n,e-n],["L",t+n,e+n],["M",t+n,e-n],["L",t-n,e+n]]})),Vz.registerSymbol("hyphen",(function(t,e,n){return[["M",t-n,e],["L",t+n,e]]})),Vz.registerSymbol("line",jz),Vz.registerSymbol("plus",(function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]})),Vz.registerSymbol("tick",(function(t,e,n){return[["M",t-n/2,e-n],["L",t+n/2,e-n],["M",t,e-n],["L",t,e+n],["M",t-n/2,e+n],["L",t+n/2,e+n]]})),Vz.registerSymbol("circle",_z),Vz.registerSymbol("point",Iz),Vz.registerSymbol("bowtie",(function(t,e,n){var r=n-1.5;return[["M",t-n,e-r],["L",t+n,e+r],["L",t+n,e-r],["L",t-n,e+r],["Z"]]})),Vz.registerSymbol("hexagon",(function(t,e,n){var r=n/2*Math.sqrt(3);return[["M",t,e-n],["L",t+r,e-n/2],["L",t+r,e+n/2],["L",t,e+n],["L",t-r,e+n/2],["L",t-r,e-n/2],["Z"]]})),Vz.registerSymbol("square",(function(t,e,n){return[["M",t-n,e-n],["L",t+n,e-n],["L",t+n,e+n],["L",t-n,e+n],["Z"]]})),Vz.registerSymbol("diamond",(function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]})),Vz.registerSymbol("triangle",(function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e+r],["L",t,e-r],["L",t+n,e+r],["Z"]]})),Vz.registerSymbol("triangle-down",(function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e-r],["L",t+n,e-r],["L",t,e+r],["Z"]]})),Vz.registerSymbol("line",jz),Vz.registerSymbol("dot",Bz),Vz.registerSymbol("dash",Fz),Vz.registerSymbol("smooth",(function(t,e,n){return[["M",t-n,e],["A",n/2,n/2,0,1,1,t,e],["A",n/2,n/2,0,1,0,t+n,e]]})),Vz.registerSymbol("hv",(function(t,e,n){return[["M",t-n-1,e-2.5],["L",t,e-2.5],["L",t,e+2.5],["L",t+n+1,e+2.5]]})),Vz.registerSymbol("vh",(function(t,e,n){return[["M",t-n-1,e+2.5],["L",t,e+2.5],["L",t,e-2.5],["L",t+n+1,e-2.5]]})),Vz.registerSymbol("hvh",(function(t,e,n){return[["M",t-(n+1),e+2.5],["L",t-n/2,e+2.5],["L",t-n/2,e-2.5],["L",t+n/2,e-2.5],["L",t+n/2,e+2.5],["L",t+n+1,e+2.5]]})),Vz.registerSymbol("vhv",(function(t,e){return[["M",t-5,e+2.5],["L",t-5,e],["L",t,e],["L",t,e-3],["L",t,e+3],["L",t+6.5,e+3]]}));const Yz=Math.sqrt(50),Uz=Math.sqrt(10),$z=Math.sqrt(2);function qz(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),o=r/10**i;return i>=0?(o>=Yz?10:o>=Uz?5:o>=$z?2:1)*10**i:-(10**-i)/(o>=Yz?10:o>=Uz?5:o>=$z?2:1)}const Xz=(t,e,n=5)=>{const r=[t,e];let i,o=0,a=r.length-1,s=r[o],l=r[a];return l<s&&([s,l]=[l,s],[o,a]=[a,o]),i=qz(s,l,n),i>0?(s=Math.floor(s/i)*i,l=Math.ceil(l/i)*i,i=qz(s,l,n)):i<0&&(s=Math.ceil(s*i)/i,l=Math.floor(l*i)/i,i=qz(s,l,n)),i>0?(r[o]=Math.floor(s/i)*i,r[a]=Math.ceil(l/i)*i):i<0&&(r[o]=Math.ceil(s*i)/i,r[a]=Math.floor(l*i)/i),r};function Kz(t){return!(ve(t)||(e=t,null===e)||Number.isNaN(t));var e}var Zz={exports:{}},Qz={exports:{}},Jz=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},tG=Array.prototype.concat,eG=Array.prototype.slice,nG=Qz.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];Jz(i)?e=tG.call(e,eG.call(i)):e.push(i)}return e};nG.wrap=function(t){return function(){return t(nG(arguments))}};var rG=Qz.exports,iG={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},oG=rG,aG=Object.hasOwnProperty,sG=Object.create(null);for(var lG in iG)aG.call(iG,lG)&&(sG[iG[lG]]=lG);var uG=Zz.exports={to:{},get:{}};function cG(t,e,n){return Math.min(Math.max(e,t),n)}function hG(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}uG.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=uG.get.hsl(t),n="hsl";break;case"hwb":e=uG.get.hwb(t),n="hwb";break;default:e=uG.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},uG.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;i[n]=parseInt(e.slice(o,o+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:aG.call(iG,e[1])?((i=iG[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=cG(i[n],0,255);return i[3]=cG(i[3],0,1),i},uG.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,cG(parseFloat(e[2]),0,100),cG(parseFloat(e[3]),0,100),cG(isNaN(n)?1:n,0,1)]}return null},uG.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,cG(parseFloat(e[2]),0,100),cG(parseFloat(e[3]),0,100),cG(isNaN(n)?1:n,0,1)]}return null},uG.to.hex=function(){var t=oG(arguments);return"#"+hG(t[0])+hG(t[1])+hG(t[2])+(t[3]<1?hG(Math.round(255*t[3])):"")},uG.to.rgb=function(){var t=oG(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},uG.to.rgb.percent=function(){var t=oG(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},uG.to.hsl=function(){var t=oG(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},uG.to.hwb=function(){var t=oG(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},uG.to.keyword=function(t){return sG[t.slice(0,3)]};var dG=E(Zz.exports);function fG(t,e,n){let r=n;return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function pG(t){const e=dG.get(t);if(!e)return null;const{model:n,value:r}=e;return"rgb"===n?r:"hsl"===n?function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100,i=t[3];if(0===n)return[255*r,255*r,255*r,i];const o=r<.5?r*(1+n):r+n-r*n,a=2*r-o;return[255*fG(a,o,e+1/3),255*fG(a,o,e),255*fG(a,o,e-1/3),i]}(r):null}const gG=(t,e)=>n=>t*(1-n)+e*n,vG=(t,e)=>"number"==typeof t&&"number"==typeof e?gG(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=pG(t),r=pG(e);return null===n||null===r?n?()=>t:()=>e:t=>{const e=new Array(4);for(let i=0;i<4;i+=1){const o=n[i],a=r[i];e[i]=o*(1-t)+a*t}const[i,o,a,s]=e;return`rgba(${Math.round(i)}, ${Math.round(o)}, ${Math.round(a)}, ${s})`}})(t,e):()=>t,mG=(t,e)=>{const n=gG(t,e);return t=>Math.round(n(t))};function yG({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function bG(t){return"object"==typeof t?t.valueOf():t}class xG extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=bG,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(yG({map:this.map,initKey:this.initKey},t))}has(t){return super.has(yG({map:this.map,initKey:this.initKey},t))}set(t,e){return super.set(function({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}({map:this.map,initKey:this.initKey},t),e)}delete(t){return super.delete(function({map:t,initKey:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}({map:this.map,initKey:this.initKey},t))}}class EG{constructor(t){this.options=ke({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=ke({},this.options,t),this.rescale(t)}rescale(t){}}const wG=Symbol("defaultUnknown");function kG(t,e,n){for(let r=0;r<e.length;r+=1)t.has(e[r])||t.set(n(e[r]),r)}function MG(t){const{value:e,from:n,to:r,mapper:i,notFoundReturn:o}=t;let a=i.get(e);if(void 0===a){if(o!==wG)return o;a=n.push(e)-1,i.set(e,a)}return r[a%r.length]}function SG(t){return t instanceof Date?t=>`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class NG extends EG{getDefaultOptions(){return{domain:[],range:[],unknown:wG}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&kG(this.domainIndexMap,this.getDomain(),this.domainKey),MG({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&kG(this.rangeIndexMap,this.getRange(),this.rangeKey),MG({value:this.rangeKey(t),mapper:this.rangeIndexMap,from:this.getRange(),to:this.getDomain(),notFoundReturn:this.options.unknown})}rescale(t){const[e]=this.options.domain,[n]=this.options.range;if(this.domainKey=SG(e),this.rangeKey=SG(n),!this.rangeIndexMap)return this.rangeIndexMap=new Map,void(this.domainIndexMap=new Map);t&&!t.range||this.rangeIndexMap.clear(),(!t||t.domain||t.compare)&&(this.domainIndexMap.clear(),this.sortedDomain=void 0)}clone(){return new NG(this.options)}getRange(){return this.options.range}getDomain(){if(this.sortedDomain)return this.sortedDomain;const{domain:t,compare:e}=this.options;return this.sortedDomain=e?[...t].sort(e):t,this.sortedDomain}}function OG(t){return Math.round(1e12*t)/1e12}function TG(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:a,align:s}=t,l=e.length,u=function(t,e){const n=e-t.length;return n>0?[...t,...new Array(n).fill(1)]:n<0?t.slice(0,e):t}(o,l),[c,h]=n,d=h-c,f=d/(2/l*r+1-1/l*i),p=f*i/l,g=f-l*p,v=function(t){const e=Math.min(...t);return t.map((t=>t/e))}(u),m=g/v.reduce(((t,e)=>t+e)),y=new xG(e.map(((t,e)=>{const n=v[e]*m;return[t,a?Math.floor(n):n]}))),b=new xG(e.map(((t,e)=>{const n=v[e]*m+p;return[t,a?Math.floor(n):n]}))),x=Array.from(b.values()).reduce(((t,e)=>t+e)),E=c+(d-(x-x/l*i))*s;let w=a?Math.round(E):E;const k=new Array(l);for(let t=0;t<l;t+=1){k[t]=OG(w);const n=e[t];w+=b.get(n)}return{valueBandWidth:y,valueStep:b,adjustedRange:k}}class AG extends NG{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:wG,flex:[]}}constructor(t){super(t)}clone(){return new AG(this.options)}getStep(t){return void 0===this.valueStep?1:"number"==typeof this.valueStep?this.valueStep:void 0===t?Array.from(this.valueStep.values())[0]:this.valueStep.get(t)}getBandWidth(t){return void 0===this.valueBandWidth?1:"number"==typeof this.valueBandWidth?this.valueBandWidth:void 0===t?Array.from(this.valueBandWidth.values())[0]:this.valueBandWidth.get(t)}getRange(){return this.adjustedRange}getPaddingInner(){const{padding:t,paddingInner:e}=this.options;return t>0?t:e}getPaddingOuter(){const{padding:t,paddingOuter:e}=this.options;return t>0?t:e}rescale(){super.rescale();const{align:t,domain:e,range:n,round:r,flex:i}=this.options,{adjustedRange:o,valueBandWidth:a,valueStep:s}=function(t){var e;const{domain:n}=t,r=n.length;if(0===r)return{valueBandWidth:void 0,valueStep:void 0,adjustedRange:[]};if(null===(e=t.flex)||void 0===e?void 0:e.length)return TG(t);const{range:i,paddingOuter:o,paddingInner:a,round:s,align:l}=t;let u,c,h=i[0];const d=i[1]-h,f=2*o,p=r-a;u=d/Math.max(1,f+p),s&&(u=Math.floor(u)),h+=(d-u*(r-a))*l,c=u*(1-a),s&&(h=Math.round(h),c=Math.round(c));const g=new Array(r).fill(0).map(((t,e)=>h+e*u));return{valueStep:u,valueBandWidth:c,adjustedRange:g}}({align:t,range:n,round:r,flex:i,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:e});this.valueStep=s,this.valueBandWidth=a,this.adjustedRange=o}}const CG=(t,e,n)=>{let r,i,o=t,a=e;if(o===a&&n>0)return[o];let s=qz(o,a,n);if(0===s||!Number.isFinite(s))return[];if(s>0){o=Math.ceil(o/s),a=Math.floor(a/s),i=new Array(r=Math.ceil(a-o+1));for(let t=0;t<r;t+=1)i[t]=(o+t)*s}else{s=-s,o=Math.ceil(o*s),a=Math.floor(a*s),i=new Array(r=Math.ceil(a-o+1));for(let t=0;t<r;t+=1)i[t]=(o+t)/s}return i},PG=(t,e,n)=>{const[r,i]=t,[o,a]=e;let s,l;return r<i?(s=Hz(r,i),l=n(o,a)):(s=Hz(i,r),l=n(a,o)),Wz(l,s)},RG=(t,e,n)=>{const r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),a=t[0]>t[r],s=a?[...t].reverse():t,l=a?[...e].reverse():e;for(let t=0;t<r;t+=1)i[t]=Hz(s[t],s[t+1]),o[t]=n(l[t],l[t+1]);return e=>{const n=function(t,e,n,r){let i=n||0,o=r||t.length;for(;i<o;){const n=Math.floor((i+o)/2);t[n]>e?o=n:i=n+1}return i}(t,e,1,r)-1,a=i[n];return Wz(o[n],a)(e)}},DG=(t,e,n,r)=>(Math.min(t.length,e.length)>2?RG:PG)(t,e,r?mG:n);class LG extends EG{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:gG,tickCount:5}}map(t){return Kz(t)?this.output(t):this.options.unknown}invert(t){return Kz(t)?this.input(t):this.options.unknown}nice(){if(!this.options.nice)return;const[t,e,n,...r]=this.getTickMethodOptions();this.options.domain=this.chooseNice()(t,e,n,...r)}getTicks(){const{tickMethod:t}=this.options,[e,n,r,...i]=this.getTickMethodOptions();return t(e,n,r,...i)}getTickMethodOptions(){const{domain:t,tickCount:e}=this.options;return[t[0],t[t.length-1],e]}chooseNice(){return Xz}rescale(){this.nice();const[t,e]=this.chooseTransforms();this.composeOutput(t,this.chooseClamp(t)),this.composeInput(t,e,this.chooseClamp(e))}chooseClamp(t){const{clamp:e,range:n}=this.options,r=this.options.domain.map(t),i=Math.min(r.length,n.length);return e?function(t,e){const n=e<t?e:t,r=t>e?t:e;return t=>Math.min(Math.max(n,t),r)}(r[0],r[i-1]):_e}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,a=DG(n.map(t),r,o,i);this.output=Wz(a,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=DG(i,r.map(t),gG);this.input=Wz(e,n,o)}}class _G extends LG{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:vG,tickMethod:CG,tickCount:5}}chooseTransforms(){return[_e,_e]}clone(){return new _G(this.options)}}var IG=function(t){function e(e){var n=this,r=e.style,i=Fe(e,["style"]);return(n=t.call(this,ke({},{type:"column"},Be({style:r},i)))||this).columnsGroup=new jl({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return je(e,t),e.prototype.render=function(){var t=this.attributes,e=t.columns,n=t.x,r=t.y;this.columnsGroup.style.transform="translate(".concat(n,", ").concat(r,")"),xz(this.columnsGroup).selectAll(".column").data(e.flat()).join((function(t){return t.append("rect").attr("className","column").each((function(t){this.attr(t)}))}),(function(t){return t.each((function(t){this.attr(t)}))}),(function(t){return t.remove()}))},e.prototype.update=function(t){this.attr($F({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(Rl),jG=function(t){function e(e){var n=this,r=e.style,i=Fe(e,["style"]);return(n=t.call(this,ke({},{type:"lines"},Be({style:r},i)))||this).linesGroup=n.appendChild(new jl),n.areasGroup=n.appendChild(new jl),n.render(),n}return je(e,t),e.prototype.render=function(){var t=this.attributes,e=t.lines,n=t.areas,r=t.x,i=t.y;this.style.transform="translate(".concat(r,", ").concat(i,")"),e&&this.renderLines(e),n&&this.renderAreas(n)},e.prototype.clear=function(){this.linesGroup.removeChildren(),this.areasGroup.removeChildren()},e.prototype.update=function(t){this.attr($F({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){xz(this.linesGroup).selectAll(".line").data(t).join((function(t){return t.append("path").attr("className","line").each((function(t){this.attr(t)}))}),(function(t){return t.each((function(t){this.attr(t)}))}),(function(t){return t.remove()}))},e.prototype.renderAreas=function(t){xz(this.linesGroup).selectAll(".area").data(t).join((function(t){return t.append("path").attr("className","area").each((function(t){this.attr(t)}))}),(function(t){return t.each((function(t){this.style(t)}))}),(function(t){return t.remove()}))},e}(Rl);function BG(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map((function(t,e){return We([e===n?"M":"L"],Ve(t),!1)}));return e?r.reverse():r}function FG(t,e){if(void 0===e&&(e=!1),t.length<=2)return BG(t);for(var n=[],r=t.length,i=0;i<r;i+=1){var o=e?t[r-i-1]:t[i];Ne(o,n.slice(-2))||n.push.apply(n,We([],Ve(o),!1))}var a=pz(n,!1);return e?a.unshift(We(["M"],Ve(t[r-1]),!1)):a.unshift(We(["M"],Ve(t[0]),!1)),a}function zG(t,e,n){var r=me(t);return r.push(["L",e,n],["L",0,n],["Z"]),r}function GG(t){return 0===t.length?[0,0]:[ee(ue(t,(function(t){return ee(t)||0}))),te(le(t,(function(t){return te(t)||0})))]}function VG(t){for(var e=me(t),n=e[0].length,r=Ve([Array(n).fill(0),Array(n).fill(0)],2),i=r[0],o=r[1],a=0;a<e.length;a+=1)for(var s=e[a],l=0;l<n;l+=1)s[l]>=0?(s[l]+=i[l],i[l]=s[l]):(s[l]+=o[l],o[l]=s[l]);return e}var WG=function(t){function e(e){return t.call(this,e,{type:"line",x:0,y:0,width:200,height:20,isStack:!1,color:["#83daad","#edbf45","#d2cef9","#e290b3","#6f63f4"],smooth:!0,lineLineWidth:1,areaOpacity:0,isGroup:!1,columnLineWidth:1,columnStroke:"#fff",scale:1,spacing:0})||this}return je(e,t),Object.defineProperty(e.prototype,"rawData",{get:function(){var t=this.attributes.data;if(!t||0===(null==t?void 0:t.length))return[[]];var e=me(t);return ae(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?VG(this.rawData):this.rawData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scales",{get:function(){return this.createScales(this.data)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseline",{get:function(){var t=this.scales.y,e=Ve(t.getOptions().domain||[0,0],2),n=e[0],r=e[1];return r<0?t.map(r):t.map(n<0?0:n)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"containerShape",{get:function(){var t=this.attributes;return{width:t.width,height:t.height}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesStyle",{get:function(){var t=this,e=this.attributes,n=e.type,r=e.isStack,i=e.smooth;if("line"!==n)throw new Error("linesStyle can only be used in line type");var o=Oz(this.attributes,"area"),a=Oz(this.attributes,"line"),s=this.containerShape.width,l=this.data;if(0===l[0].length)return{lines:[],areas:[]};var u=this.scales,c=function(t,e){var n,r=e.x,i=e.y,o=Ve(i.getOptions().range||[0,0],2),a=o[0],s=o[1];return s>a&&(n=Ve([a,s],2),s=n[0],a=n[1]),t.map((function(t){return t.map((function(t,e){return[r.map(e),oe(i.map(t),s,a)]}))}))}(l,{type:"line",x:u.x,y:u.y}),h=[],d=this.baseline;return h=r?i?function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=t[i],a=FG(o),s=void 0;if(0===i)s=zG(a,e,n);else{var l=FG(t[i-1],!0),u=o[0];l[0][0]="L",s=We(We(We([],Ve(a),!1),Ve(l),!1),[We(["M"],Ve(u),!1),["Z"]],!1)}r.push(s)}return r}(c,s,d):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=BG(t[i]),a=void 0;if(0===i)a=zG(o,e,n);else{var s=BG(t[i-1],!0);s[0][0]="L",a=We(We(We([],Ve(o),!1),Ve(s),!1),[["Z"]],!1)}r.push(a)}return r}(c,s,d):function(t,e,n,r){return t.map((function(t){return zG(e?FG(t):BG(t),n,r)}))}(c,i,s,d),{lines:c.map((function(e,n){return Be({stroke:t.getColor(n),d:i?FG(e):BG(e)},a)})),areas:h.map((function(e,n){return Be({d:e,fill:t.getColor(n)},o)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=Oz(this.attributes,"column"),n=this.attributes,r=n.isStack,i=n.type,o=n.scale;if("column"!==i)throw new Error("columnsStyle can only be used in column type");var a=this.containerShape.height,s=this.rawData;if(!s)return{columns:[]};r&&(s=VG(s));var l=this.createScales(s),u=l.x,c=l.y,h=Ve(GG(s),2),d=h[0],f=h[1],p=new _G({domain:[0,f-(d>0?0:d)],range:[0,a*o]}),g=u.getBandWidth(),v=this.rawData;return{columns:s.map((function(n,i){return n.map((function(n,o){var a=g/s.length;return Be(Be({fill:t.getColor(i)},e),r?{x:u.map(o),y:c.map(n),width:g,height:p.map(v[i][o])}:{x:u.map(o)+a*i,y:n>=0?c.map(n):c.map(0),width:a,height:p.map(Math.abs(n))})}))}))}},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){var n,r,i;(n=e,r=".container",i="rect",n.querySelector(r)?xz(n).select(r):xz(n).append(i)).attr("className","container").node();var o=t.type,a=t.x,s=t.y,l="spark".concat(o),u=Be({x:a,y:s},"line"===o?this.linesStyle:this.columnsStyle);xz(e).selectAll(".spark").data([o]).join((function(t){return t.append((function(t){return"line"===t?new jG({className:l,style:u}):new IG({className:l,style:u})})).attr("className","spark ".concat(l))}),(function(t){return t.update(u)}),(function(t){return t.remove()}))},e.prototype.getColor=function(t){var e=this.attributes.color;return $t(e)?e[t%e.length]:Yt(e)?e.call(null,t):e},e.prototype.createScales=function(t){var e,n,r=this.attributes,i=r.type,o=r.scale,a=r.range,s=void 0===a?[]:a,l=r.spacing,u=this.containerShape,c=u.width,h=u.height,d=Ve(GG(t),2),f=d[0],p=d[1],g=new _G({domain:[null!==(e=s[0])&&void 0!==e?e:f,null!==(n=s[1])&&void 0!==n?n:p],range:[h,h*(1-o)]});return"line"===i?{type:i,x:new _G({domain:[0,t[0].length-1],range:[0,c]}),y:g}:{type:i,x:new AG({domain:t[0].map((function(t,e){return e})),range:[0,c],paddingInner:l,paddingOuter:l/2,align:.5}),y:g}},e.tag="sparkline",e}(Lz);function HG(t){if(!t)return{enter:!1,update:!1,exit:!1};var e=["enter","update","exit"],n=Object.fromEntries(Object.entries(t).filter((function(t){var n=Ve(t,1)[0];return!e.includes(n)})));return Object.fromEntries(e.map((function(e){return function(t){return"boolean"!=typeof t&&"enter"in t&&"update"in t&&"exit"in t}(t)?!1===t[e]?[e,!1]:[e,Be(Be({},t[e]),n)]:[e,n]})))}function YG(t,e){t?t.finished.then(e):e()}function UG(t,e){"update"in t?t.update(e):t.attr(e)}function $G(t,e,n){return 0===e.length?null:n?t.animate(e,n):(UG(t,{style:e.slice(-1)[0]}),null)}function qG(t,e,n){var r={},i={};return Object.entries(e).forEach((function(e){var n=Ve(e,2),o=n[0],a=n[1];if(!Ut(a)){var s=t.style[o]||t.parsedStyle[o]||0;s!==a&&(r[o]=s,i[o]=a)}})),n?$G(t,[r,i],Be({fill:"both"},n)):(UG(t,i),null)}function XG(t,e){return t.style.opacity||(t.style.opacity=1),qG(t,{opacity:0},e)}var KG={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},ZG={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},QG={x:0,y:0,orientation:"horizontal",showLabel:!0,type:"start"},JG=YF({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),tV=YF({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),eV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.render=function(t,e){var n=t.x,r=t.y,i=t.size,o=void 0===i?10:i,a=t.radius,s=void 0===a?o/4:a,l=t.orientation,u=Fe(t,["x","y","size","radius","orientation"]),c=o,h=2.4*c,d=xz(e).maybeAppendByClassName(tV.iconRect,"rect").styles(Be(Be({},u),{width:c,height:h,radius:s,x:n-c/2,y:r-h/2,transformOrigin:"center"})),f=n+1/3*c-c/2,p=n+2/3*c-c/2,g=r+1/4*h-h/2,v=r+3/4*h-h/2;d.maybeAppendByClassName("".concat(tV.iconLine,"-1"),"line").styles(Be({x1:f,x2:f,y1:g,y2:v},u)),d.maybeAppendByClassName("".concat(tV.iconLine,"-2"),"line").styles(Be({x1:p,x2:p,y1:g,y2:v},u)),"vertical"===l&&(d.node().style.transform="rotate(90)")},e}(Lz),nV=function(t){function e(e){return t.call(this,e,QG)||this}return je(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.x,i=n.y,o=n.showLabel,a=Oz(this.attributes,"label"),s=a.x,l=void 0===s?0:s,u=a.y,c=void 0===u?0:u,h=a.transform,d=a.transformOrigin,f=Ve(Az(Fe(a,["x","y","transform","transformOrigin"]),[]),2),p=f[0],g=f[1],v=xz(t).maybeAppendByClassName(tV.labelGroup,"g").styles(g),m=Be(Be({},ZG),p),y=m.text,b=Fe(m,["text"]);nz(!!o,v,(function(t){e.label=t.maybeAppendByClassName(tV.label,"text").styles(Be(Be({},b),{x:r+l,y:i+c,transform:h,transformOrigin:d,text:"".concat(y)})),e.label.on("mousedown",(function(t){t.stopPropagation()})),e.label.on("touchstart",(function(t){t.stopPropagation()}))}))},e.prototype.renderIcon=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.orientation,o=e.type,a=Be(Be({x:n,y:r,orientation:i},KG),Oz(this.attributes,"icon")),s=this.attributes.iconShape,l=void 0===s?function(){return new eV({style:a})}:s;xz(t).maybeAppendByClassName(tV.iconGroup,"g").selectAll(tV.icon.class).data([l]).join((function(t){return t.append("string"==typeof l?l:function(){return l(o)}).attr("className",tV.icon.name)}),(function(t){return t.update(a)}),(function(t){return t.remove()}))},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(Lz),rV=function(t){function e(e){var n=t.call(this,e,Be(Be(Be({x:0,y:0,animate:{duration:100,fill:"both"},brushable:!0,formatter:function(t){return t.toString()},handleSpacing:2,orientation:"horizontal",padding:0,autoFitLabel:!0,scrollable:!0,selectionFill:"#5B8FF9",selectionFillOpacity:.45,selectionZIndex:2,showHandle:!0,showLabel:!0,slidable:!0,trackFill:"#416180",trackLength:200,trackOpacity:.05,trackSize:20,trackZIndex:-1,values:[0,1],type:"range",selectionType:"select",handleIconOffset:0},Tz(QG,"handle")),Tz(KG,"handleIcon")),Tz(ZG,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(tz(e));var r=n.availableSpace,i=r.x,o=r.y,a=n.getBBox(),s=a.x,l=a.y;n.selectionStartPos=n.getRatio(n.prevPos-n.getOrientVal([i,o])-n.getOrientVal([+s,+l])),n.selectionWidth=0,document.addEventListener("pointermove",n.onDragging),document.addEventListener("pointerup",n.onDragEnd)}},n.onDragging=function(t){var e=n.attributes,r=e.slidable,i=e.brushable,o=e.type;t.stopPropagation();var a=n.getOrientVal(tz(t)),s=a-n.prevPos;if(s){var l=n.getRatio(s);switch(n.target){case"start":r&&n.setValuesOffset(l);break;case"end":r&&n.setValuesOffset(0,l);break;case"selection":r&&n.setValuesOffset(l,l);break;case"track":if(!i)return;n.selectionWidth+=l,"range"===o?n.innerSetValues([n.selectionStartPos,n.selectionStartPos+n.selectionWidth].sort(),!0):n.innerSetValues([0,n.selectionStartPos+n.selectionWidth],!0)}n.prevPos=a}},n.onDragEnd=function(){document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointerup",n.onDragEnd),n.target="",n.updateHandlesPosition(!1)},n.onValueChange=function(t){var e=n.attributes,r=e.onChange,i=e.type,o="range"===i?t:t[1],a="range"===i?n.getValues():n.getValues()[1],s=new Rs("valuechange",{detail:{oldValue:o,value:a}});n.dispatchEvent(s),null==r||r(a)},n.selectionStartPos=0,n.selectionWidth=0,n.prevPos=0,n.target="",n}return je(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return this.attributes.values},set:function(t){this.attributes.values=this.clampValues(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sparklineStyle",{get:function(){if("horizontal"!==this.attributes.orientation)return null;var t=Oz(this.attributes,"sparkline");return Be(Be({zIndex:0},this.availableSpace),t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t=this.attributes,e=t.trackLength,n=t.trackSize,r=Ve(this.getOrientVal([[e,n],[n,e]]),2);return{width:r[0],height:r[1]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes;t.x,t.y;var e=Ve(Ez(t.padding),4),n=e[0],r=e[1],i=e[2],o=e[3],a=this.shape;return{x:o,y:n,width:a.width-(o+r),height:a.height-(n+i)}},enumerable:!1,configurable:!0}),e.prototype.getValues=function(){return this.values},e.prototype.setValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1),this.attributes.values=t;var n=!1!==e&&this.attributes.animate;this.updateSelectionArea(n),this.updateHandlesPosition(n)},e.prototype.updateSelectionArea=function(t){var e=this.calcSelectionArea();this.foregroundGroup.selectAll(JG.selection.class).each((function(n,r){qG(this,e[r],t)}))},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&qG(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&qG(this.endHandle,this.getHandleStyle("end"),t))},e.prototype.innerSetValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1);var n=this.values,r=this.clampValues(t);this.attributes.values=r,this.setValues(r),e&&this.onValueChange(n)},e.prototype.renderTrack=function(t){var e=this.attributes,n=e.x,r=e.y,i=Oz(this.attributes,"track");this.trackShape=xz(t).maybeAppendByClassName(JG.track,"rect").styles(Be(Be({x:n,y:r},this.shape),i))},e.prototype.renderBrushArea=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.brushable;this.brushArea=xz(t).maybeAppendByClassName(JG.brushArea,"rect").styles(Be({x:n,y:r,fill:"transparent",cursor:i?"crosshair":"default"},this.shape))},e.prototype.renderSparkline=function(t){var e=this,n=this.attributes,r=n.x,i=n.y;nz("horizontal"===n.orientation,xz(t).maybeAppendByClassName(JG.sparklineGroup,"g"),(function(t){var n=Be(Be({},e.sparklineStyle),{x:r,y:i});t.maybeAppendByClassName(JG.sparkline,(function(){return new WG({style:n})})).update(n)}))},e.prototype.renderHandles=function(){var t,e=this,n=this.attributes,r=n.showHandle,i=n.type,o=r?"range"===i?["start","end"]:["end"]:[],a=this;null===(t=this.foregroundGroup)||void 0===t||t.selectAll(JG.handle.class).data(o.map((function(t){return{type:t}})),(function(t){return t.type})).join((function(t){return t.append((function(t){var n=t.type;return new nV({style:e.getHandleStyle(n)})})).each((function(t){var e=t.type;this.attr("class","".concat(JG.handle.name," ").concat(e,"-handle"));var n="".concat(e,"Handle");a[n]=this,this.addEventListener("pointerdown",a.onDragStart(e))}))}),(function(t){return t.each((function(t){var e=t.type;this.update(a.getHandleStyle(e))}))}),(function(t){return t.each((function(t){var e=t.type,n="".concat(e,"Handle");a[n]=void 0})).remove()}))},e.prototype.renderSelection=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.type,o=e.selectionType;this.foregroundGroup=xz(t).maybeAppendByClassName(JG.foreground,"g");var a=Oz(this.attributes,"selection"),s=function(t){return t.style("visibility",(function(t){return t.show?"visible":"hidden"})).style("cursor",(function(t){return"select"===o?"grab":"invert"===o?"crosshair":"default"})).styles(Be(Be({},a),{transform:"translate(".concat(n,", ").concat(r,")")}))},l=this;this.foregroundGroup.selectAll(JG.selection.class).data("value"===i?[]:this.calcSelectionArea().map((function(t,e){return{style:Be({},t),index:e,show:"select"===o?1===e:1!==e}})),(function(t){return t.index})).join((function(t){return t.append("rect").attr("className",JG.selection.name).call(s).each((function(t,e){var n=this;1===e?(l.selectionShape=xz(this),this.on("pointerdown",(function(t){n.attr("cursor","grabbing"),l.onDragStart("selection")(t)})),l.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),l.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),l.dispatchCustomEvent(this,"click","selectionClick"),this.addEventListener("pointerdown",(function(){n.attr("cursor","grabbing")})),this.addEventListener("pointerup",(function(){n.attr("cursor","pointer")})),this.addEventListener("pointerover",(function(){n.attr("cursor","pointer")}))):this.on("pointerdown",l.onDragStart("track"))}))}),(function(t){return t.call(s)}),(function(t){return t.remove()})),this.updateSelectionArea(!1),this.renderHandles()},e.prototype.render=function(t,e){this.renderTrack(e),this.renderSparkline(e),this.renderBrushArea(e),this.renderSelection(e)},e.prototype.clampValues=function(t,e){var n;void 0===e&&(e=4);var r=Ve(this.range,2),i=r[0],o=r[1],a=Ve(this.getValues().map((function(t){return dz(t,e)})),2),s=a[0],l=a[1],u=Ve(((Array.isArray(t)?t:[s,null!=t?t:l])||[s,l]).map((function(t){return dz(t,e)})),2),c=u[0],h=u[1];if("value"===this.attributes.type)return[0,oe(h,i,o)];c>h&&(c=(n=Ve([h,c],2))[0],h=n[1]);var d=h-c;return d>o-i?[i,o]:c<i?s===i&&l===h?[i,h]:[i,d+i]:h>o?l===o&&s===c?[c,o]:[o-d,o]:[c,h]},e.prototype.calcSelectionArea=function(t){var e=Ve(this.clampValues(t),2),n=e[0],r=e[1],i=this.availableSpace,o=i.x,a=i.y,s=i.width,l=i.height;return this.getOrientVal([[{y:a,height:l,x:o,width:n*s},{y:a,height:l,x:n*s+o,width:(r-n)*s},{y:a,height:l,x:r*s,width:(1-r)*s}],[{x:o,width:s,y:a,height:n*l},{x:o,width:s,y:n*l+a,height:(r-n)*l},{x:o,width:s,y:r*l,height:(1-r)*l}]])},e.prototype.calcHandlePosition=function(t){var e=this.attributes.handleIconOffset,n=this.availableSpace,r=n.x,i=n.y,o=n.width,a=n.height,s=Ve(this.clampValues(),2),l=s[0],u=s[1],c="start"===t?-e:e,h=("start"===t?l:u)*this.getOrientVal([o,a])+c;return{x:r+this.getOrientVal([h,o/2]),y:i+this.getOrientVal([a/2,h])}},e.prototype.inferTextStyle=function(t){return"horizontal"===this.attributes.orientation?{}:"start"===t?{transformOrigin:"left center",transform:"rotate(90)",textAlign:"start"}:"end"===t?{transformOrigin:"right center",transform:"rotate(90)",textAlign:"end"}:{}},e.prototype.calcHandleText=function(t){var e,n=this.attributes,r=n.type,i=n.orientation,o=n.formatter,a=n.autoFitLabel,s=Oz(this.attributes,"handle"),l=Oz(s,"label"),u=s.spacing,c=this.getHandleSize(),h=this.clampValues(),d=o("start"===t?h[0]:h[1]),f=new FF({style:Be(Be(Be({},l),this.inferTextStyle(t)),{text:d})}),p=f.getBBox(),g=p.width,v=p.height;if(f.destroy(),!a){if("value"===r)return{text:d,x:0,y:-v-u};var m=u+c+("horizontal"===i?g/2:0);return(e={text:d})["horizontal"===i?"x":"y"]="start"===t?-m:m,e}var y=0,b=0,x=this.availableSpace,E=x.width,w=x.height,k=this.calcSelectionArea()[1],M=k.x,S=k.y,N=k.width,O=k.height,T=u+c;if("horizontal"===i){var A=T+g/2;if("start"===t)y=M-T-g>0?-A:A;else y=E-M-N-T>g?A:-A}else{var C=v+T;b="start"===t?S-c>v?-C:T:w-(S+O)-c>v?C:-T}return{x:y,y:b,text:d}},e.prototype.getHandleLabelStyle=function(t){var e=Oz(this.attributes,"handleLabel");return Be(Be(Be({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=Oz(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return Be({cursor:n,shape:t,size:r},e)},e.prototype.getHandleStyle=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.showLabel,o=e.showLabelOnInteraction,a=e.orientation,s=this.calcHandlePosition(t),l=s.x,u=s.y,c=this.calcHandleText(t),h=i;return!i&&o&&(h=!!this.target),Be(Be(Be({},Tz(this.getHandleIconStyle(),"icon")),Tz(Be(Be({},this.getHandleLabelStyle(t)),c),"label")),{transform:"translate(".concat(l+n,", ").concat(u+r,")"),orientation:a,showLabel:h,type:t,zIndex:3})},e.prototype.getHandleSize=function(){var t=this.attributes,e=t.handleIconSize,n=t.width,r=t.height;return e||Math.floor((this.getOrientVal([+r,+n])+4)/2.4)},e.prototype.getOrientVal=function(t){var e=Ve(t,2),n=e[0],r=e[1];return"horizontal"===this.attributes.orientation?n:r},e.prototype.setValuesOffset=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=!1);var r=this.attributes.type,i=Ve(this.getValues(),2),o=[i[0]+("range"===r?t:0),i[1]+e].sort();n?this.setValues(o):this.innerSetValues(o,!0)},e.prototype.getRatio=function(t){var e=this.availableSpace,n=e.width,r=e.height;return t/this.getOrientVal([n,r])},e.prototype.dispatchCustomEvent=function(t,e,n){var r=this;t.on(e,(function(t){t.stopPropagation(),r.dispatchEvent(new Rs(n,{detail:t}))}))},e.prototype.bindEvents=function(){this.addEventListener("wheel",this.onScroll);var t=this.brushArea;this.dispatchCustomEvent(t,"click","trackClick"),this.dispatchCustomEvent(t,"pointerenter","trackMouseenter"),this.dispatchCustomEvent(t,"pointerleave","trackMouseleave"),t.on("pointerdown",this.onDragStart("track"))},e.prototype.onScroll=function(t){if(this.attributes.scrollable){var e=t.deltaX,n=t.deltaY||e,r=this.getRatio(n);this.setValuesOffset(r,r,!0)}},e.tag="slider",e}(Lz),iV={data:[],animate:{enter:!1,update:{duration:100,easing:"ease-in-out-sine",fill:"both"},exit:{duration:100,fill:"both"}},showArrow:!0,showGrid:!0,showLabel:!0,showLine:!0,showTick:!0,showTitle:!0,showTrunc:!1,dataThreshold:100,lineLineWidth:1,lineStroke:"black",crossPadding:10,titleFill:"black",titleFontSize:12,titlePosition:"lb",titleSpacing:0,titleTextAlign:"center",titleTextBaseline:"middle",lineArrow:function(){return new Hl({style:{d:[["M",10,10],["L",-10,0],["L",10,-10],["L",0,0],["L",10,10],["Z"]],fill:"black",transformOrigin:"center"}})},labelAlign:"parallel",labelDirection:"positive",labelFontSize:12,labelSpacing:0,gridConnect:"line",gridControlAngles:[],gridDirection:"positive",gridLength:0,gridType:"segment",lineArrowOffset:15,lineArrowSize:10,tickDirection:"positive",tickLength:5,tickLineWidth:1,tickStroke:"black",labelOverlap:[]};ke({},iV,{style:{type:"arc"}}),ke({},iV,{style:{}});var oV=YF({mainGroup:"main-group",gridGroup:"grid-group",grid:"grid",lineGroup:"line-group",line:"line",tickGroup:"tick-group",tick:"tick",tickItem:"tick-item",labelGroup:"label-group",label:"label",labelItem:"label-item",titleGroup:"title-group",title:"title",lineFirst:"line-first",lineSecond:"line-second"},"axis"),aV=YF({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function sV(t){return t.reduce((function(t,e,n){return t.push(We([0===n?"M":"L"],Ve(e),!1)),t}),[])}function lV(t,e,n){return"surround"===e.type?function(t,e,n){var r=e.connect,i=void 0===r?"line":r,o=e.center;if("line"===i)return sV(t);if(!o)return[];var a=cz(t[0],o),s=n?0:1;return t.reduce((function(t,e,n){return 0===n?t.push(We(["M"],Ve(e),!1)):t.push(We(["A",a,a,0,0,s],Ve(e),!1)),t}),[])}(t,e,n):sV(t)}function uV(t,e,n){var r=n.type,i=n.connect,o=n.center,a=n.closed?[["Z"]]:[],s=Ve([lV(t,n),lV(e.slice().reverse(),n,!0)],2),l=s[0],u=s[1],c=Ve([t[0],e.slice(-1)[0]],2),h=c[0],d=c[1],f=function(t,e){return[l,t,u,e,a].flat()};if("line"===i||"surround"===r)return f([We(["L"],Ve(d),!1)],[We(["L"],Ve(h),!1)]);if(!o)throw new Error("Arc grid need to specified center");var p=Ve([cz(d,o),cz(h,o)],2),g=p[0],v=p[1];return f([We(["A",g,g,0,0,1],Ve(d),!1),We(["L"],Ve(d),!1)],[We(["A",v,v,0,0,0],Ve(h),!1),We(["L"],Ve(h),!1)])}var cV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=Fe(t,["type","center","areaFill","closed"]),r=function(t){var e=t.data,n=void 0===e?[]:e;return t.closed?n.map((function(t){var e=t.points,n=Ve(e,1)[0];return Be(Be({},t),{points:We(We([],Ve(e),!1),[n],!1)})})):n}(t),i=xz(e).maybeAppendByClassName(aV.lineGroup,"g"),o=xz(e).maybeAppendByClassName(aV.regionGroup,"g"),a=function(t,e,n,r){var i=n.animate,o=n.isBillboard,a=e.map((function(t,e){return{id:t.id||"grid-line-".concat(e),d:lV(t.points,n)}}));return t.selectAll(aV.line.class).data(a,(function(t){return t.id})).join((function(t){return t.append("path").each((function(t,e){var n=WF(mz(Be({d:t.d},r)),[t,e,a]);this.attr(Be({class:aV.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:o},n))}))}),(function(t){return t.transition((function(t,e){return qG(this,WF(mz(Be({d:t.d},r)),[t,e,a]),i.update)}))}),(function(t){return t.transition((function(){var t=this,e=XG(this,i.exit);return YG(e,(function(){return t.remove()})),e}))})).transitions()}(i,r,t,n),s=function(t,e,n){var r=n.animate,i=n.connect,o=n.areaFill;if(e.length<2||!o||!i)return[];for(var a=Array.isArray(o)?o:[o,"transparent"],s=function(t){return a[t%a.length]},l=[],u=0;u<e.length-1;u++){var c=Ve([e[u].points,e[u+1].points],2),h=uV(c[0],c[1],n);l.push({d:h,fill:s(u)})}return t.selectAll(aV.region.class).data(l,(function(t,e){return e})).join((function(t){return t.append("path").each((function(t,e){var n=WF(t,[t,e,l]);this.attr(n)})).attr("className",aV.region.name)}),(function(t){return t.transition((function(t,e){return qG(this,WF(t,[t,e,l]),r.update)}))}),(function(t){return t.transition((function(){var t=this,e=XG(this,r.exit);return YG(e,(function(){return t.remove()})),e}))})).transitions()}(o,r,t);return We(We([],Ve(a),!1),Ve(s),!1)},e}(Lz);function hV(t,e){return Object.fromEntries(Object.entries(t).map((function(t){var n=Ve(t,2);return[n[0],WF(n[1],e)]})))}function dV(t,e){return e&&Yt(e)?t.filter(e):t}function fV(t,e){var n=e.startAngle;return(e.endAngle-n)*t+n}function pV(t,e){if("linear"===e.type){var n=Ve(e.startPos,2),r=n[0],i=n[1],o=Ve(e.endPos,2),a=Ve([o[0]-r,o[1]-i],2);return hz([a[0],a[1]])}var s=zF(fV(t,e));return[-Math.sin(s),Math.cos(s)]}function gV(t,e,n){return function(t,e){return e?[t[1],-t[0]]:[-t[1],t[0]]}(pV(t,n),"positive"!==e)}function vV(t,e){return gV(t,e.labelDirection,e)}function mV(t,e){return"linear"===e.type?function(t,e){var n=Ve(e.startPos,2),r=n[0],i=n[1],o=Ve(e.endPos,2),a=Ve([o[0]-r,o[1]-i],2);return[r+a[0]*t,i+a[1]*t]}(t,e):function(t,e){var n=e.radius,r=Ve(e.center,2),i=r[0],o=r[1],a=zF(fV(t,e));return[i+n*Math.cos(a),o+n*Math.sin(a)]}(t,e)}function yV(t){return 0===pV(0,t)[1]}function bV(t){return 0===pV(0,t)[0]}function xV(t,e){return e-t==360}function EV(t,e,n,r,i){var o=e-t,a=Ve([i,i],2),s=a[0],l=a[1],u=Ve([zF(t),zF(e)],2),c=u[0],h=u[1],d=function(t){return[n+i*Math.cos(t),r+i*Math.sin(t)]},f=Ve(d(c),2),p=f[0],g=f[1],v=Ve(d(h),2),m=v[0],y=v[1];if(xV(t,e)){var b=Ve(d((h+c)/2),2);return[["M",p,g],["A",s,l,0,1,0,b[0],b[1]],["A",s,l,0,1,0,m,y]]}var x=o>180?1:0,E=t>e?0:1;return"M".concat(p,",").concat(g,",A").concat(s,",").concat(l,",0,").concat(x,",").concat(E,",").concat(m,",").concat(y)}function wV(t,e,n,r){var i=e.startAngle,o=e.endAngle,a=e.center,s=e.radius;return t.selectAll(oV.line.class).data([{d:EV.apply(void 0,We(We([i,o],Ve(a),!1),[s],!1))}],(function(t,e){return e})).join((function(t){return t.append("path").attr("className",oV.line.name).styles(e).styles({d:function(t){return t.d}})}),(function(t){return t.transition((function(){var t=this,e=function(t,e,n,r){if(!r)return t.attr("__keyframe_data__",n),null;var i=r.duration,o=void 0===i?0:i,a=iz(e,n),s=Math.ceil(+o/16),l=new Array(s).fill(0).map((function(t,e,n){return{__keyframe_data__:a(e/(n.length-1))}}));return t.animate(l,Be({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return We(We([n,r],Ve(i),!1),[o],!1)}(this),We(We([i,o],Ve(a),!1),[s],!1),r.update);if(e){var n=function(){var e=Oe(t.attributes,"__keyframe_data__");t.style.d=EV.apply(void 0,We([],Ve(e),!1))};e.onframe=n,e.onfinish=n}return e})).styles(e)}),(function(t){return t.remove()})).styles(n).transitions()}function kV(t){var e=Ve(t,2),n=Ve(e[0],2),r=n[0],i=n[1],o=Ve(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function MV(t,e,n,r){var i=e.showTrunc,o=e.startPos,a=e.endPos,s=e.truncRange,l=e.lineExtension,u=Ve([o,a],2),c=Ve(u[0],2),h=c[0],d=c[1],f=Ve(u[1],2),p=f[0],g=f[1],v=Ve(l?function(t,e,n){void 0===n&&(n=[0,0]);var r=Ve([t,e,n],3),i=Ve(r[0],2),o=i[0],a=i[1],s=Ve(r[1],2),l=s[0],u=s[1],c=Ve(r[2],2),h=c[0],d=c[1],f=Ve([l-o,u-a],2),p=f[0],g=f[1],v=Math.sqrt(Math.pow(p,2)+Math.pow(g,2)),m=Ve([-h/v,d/v],2),y=m[0],b=m[1];return[y*p,y*g,b*p,b*g]}(o,a,l):new Array(4).fill(0),4),m=v[0],y=v[1],b=v[2],x=v[3],E=function(e){return t.selectAll(oV.line.class).data(e,(function(t,e){return e})).join((function(t){return t.append("line").attr("className",(function(t){return"".concat(oV.line.name," ").concat(t.className)})).styles(n).transition((function(t){return qG(this,kV(t.line),!1)}))}),(function(t){return t.styles(n).transition((function(t){return qG(this,kV(t.line),r.update)}))}),(function(t){return t.remove()})).transitions()};if(!i||!s)return E([{line:[[h+m,d+y],[p+b,g+x]],className:oV.line.name}]);var w=Ve(s,2),k=w[0],M=w[1],S=p-h,N=g-d,O=Ve([h+S*k,d+N*k],2),T=O[0],A=O[1],C=Ve([h+S*M,d+N*M],2),P=C[0],R=C[1],D=E([{line:[[h+m,d+y],[T,A]],className:oV.lineFirst.name},{line:[[P,R],[p+b,g+x]],className:oV.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),D}function SV(t,e,n){var r,i=e.type,o=Oz(e,"line");return r="linear"===i?MV(t,e,fz(o,"arrow"),n):wV(t,e,fz(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,a=n.showTrunc,s=n.lineArrow,l=n.lineArrowOffset,u=n.lineArrowSize;if(i="arc"===e?t.select(oV.line.class):a?t.select(oV.lineSecond.class):t.select(oV.line.class),!o||!s||"arc"===n.type&&xV(n.startAngle,n.endAngle)){var c=i.node();c&&(c.style.markerEnd=void 0)}else{var h=ez(s);h.attr(r),yz(h,u),i.style("markerEnd",h).style("markerEndOffset",-l)}}(t,i,e,o),r}function NV(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function OV(t,e){var n=e.gridLength;return t.map((function(t,r){var i=t.value,o=Ve(mV(i,e),2),a=o[0],s=o[1],l=Ve(oz(function(t,e){return gV(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[a,s],[a+l[0],s+l[1]]]}}))}function TV(t,e,n,r){var i=Oz(n,"grid"),o=i.type,a=i.areaFill,s=NV(n),l=dV(e,n.gridFilter),u="segment"===o?OV(l,n):function(t,e){var n=e.gridControlAngles,r=NV(e);if(!r)throw new Error("grid center is not provide");if(t.length<2)throw new Error("Invalid grid data");if(!n||0===n.length)throw new Error("Invalid gridControlAngles");var i=Ve(r,2),o=i[0],a=i[1];return t.map((function(t,r){var i=Ve(mV(t.value,e),2),s=i[0],l=i[1],u=Ve([s-o,l-a],2),c=u[0],h=u[1],d=[];return n.forEach((function(t){var e=zF(t),n=Ve([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=c*r-h*i+o,l=c*i+h*r+a;d.push([s,l])})),{points:d,id:r}}))}(l,n),c=Be(Be({},i),{center:s,areaFill:Yt(a)?l.map((function(t,e){return WF(a,[t,e,l])})):a,animate:r,data:u});return t.selectAll(oV.grid.class).data([1]).join((function(t){return t.append((function(){return new cV({style:c})})).attr("className",oV.grid.name)}),(function(t){return t.transition((function(){return this.update(c)}))}),(function(t){return t.remove()})).transitions()}var AV=function(){function t(t,e,n,r){this.set(t,e,n,r)}return Object.defineProperty(t.prototype,"left",{get:function(){return this.x1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this.defined("x2")&&this.defined("x1")?this.x2-this.x1:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.defined("y2")&&this.defined("y1")?this.y2-this.y1:void 0},enumerable:!1,configurable:!0}),t.prototype.rotatedPoints=function(t,e,n){var r=this,i=r.x1,o=r.y1,a=r.x2,s=r.y2,l=Math.cos(t),u=Math.sin(t),c=e-e*l+n*u,h=n-e*u-n*l;return[[l*i-u*s+c,u*i+l*s+h],[l*a-u*s+c,u*a+l*s+h],[l*i-u*o+c,u*i+l*o+h],[l*a-u*o+c,u*a+l*o+h]]},t.prototype.set=function(t,e,n,r){return n<t?(this.x2=t,this.x1=n):(this.x1=t,this.x2=n),r<e?(this.y2=e,this.y1=r):(this.y1=e,this.y2=r),this},t.prototype.defined=function(t){return this[t]!==Number.MAX_VALUE&&this[t]!==-Number.MAX_VALUE},t}();function CV(t,e){var n=t.getEulerAngles()||0;t.setEulerAngles(0);var r=t.getBounds(),i=Ve(r.min,2),o=i[0],a=i[1],s=Ve(r.max,2),l=s[0],u=s[1],c=t.getBBox(),h=c.width,d=c.height,f=0,p=0,g=o,v=a,m=ZF(t);if(m){d-=1.5;var y=m.style.textAlign,b=m.style.textBaseline;"center"===y?g=(o+l)/2:"right"!==y&&"end"!==y||(g=l),"middle"===b?v=(a+u)/2:"bottom"===b&&(v=u)}var x=Ve(Ez(e),4),E=x[0],w=void 0===E?0:E,k=x[1],M=void 0===k?0:k,S=x[2],N=void 0===S?w:S,O=x[3],T=new AV((f+=o)-(void 0===O?M:O),(p+=a)-w,f+h+M,p+d+N);return t.setEulerAngles(n),T.rotatedPoints(zF(n),g,v)}function PV(t,e){return e[0]<=Math.max(t[0][0],t[1][0])&&e[0]<=Math.min(t[0][0],t[1][0])&&e[1]<=Math.max(t[0][1],t[1][1])&&e[1]<=Math.min(t[0][1],t[1][1])}function RV(t,e,n){var r=(e[1]-t[1])*(n[0]-e[0])-(e[0]-t[0])*(n[1]-e[1]);return 0===r?0:r<0?2:1}function DV(t,e){return e.every((function(e){return function(t,e){var n=t.length;if(n<3)return!1;var r,i,o,a,s,l,u=[e,[9999,e[1]]],c=0,h=0;do{var d=[t[h],t[(h+1)%n]];if(i=u,o=void 0,a=void 0,s=void 0,l=void 0,o=RV((r=d)[0],r[1],i[0]),a=RV(r[0],r[1],i[1]),s=RV(i[0],i[1],r[0]),l=RV(i[0],i[1],r[1]),o!==a&&s!==l||0===o&&PV(r,i[0])||0===a&&PV(r,i[1])||0===s&&PV(i,r[0])||0===l&&PV(i,r[1])){if(0===RV(d[0],e,d[1]))return PV(d,e);c++}h=(h+1)%n}while(0!==h);return!!(1&c)}(t,e)}))}function LV(t,e){return[[t[0],t[1],t[2],t[3]],[t[2],t[3],t[4],t[5]],[t[4],t[5],t[6],t[7]],[t[6],t[7],t[0],t[1]]].some((function(t){return function(t,e){var n=Ve(t,4),r=n[0],i=n[1],o=n[2],a=n[3],s=Ve(e,4),l=s[0],u=s[1],c=o-r,h=a-i,d=s[2]-l,f=s[3]-u,p=c*f-d*h;if(0===p)return!1;var g=p>0,v=r-l,m=i-u,y=c*m-h*v;if(y<0===g)return!1;var b=d*m-f*v;return b<0!==g&&y>p!==g&&b>p!==g}(e,t)}))}function _V(t,e,n){var r,i,o=e.crossPadding,a=new Set,s=null,l=function(t,e){var n=t.type,r=t.labelDirection,i=t.crossSize;if(!i)return!1;if("arc"===n){var o=t.center,a=t.radius,s=Ve(o,2),l=s[0],u=s[1],c="negative"===r?0:i,h=-a-c,d=a+c,f=Ve(Ez(e),4),p=f[0],g=f[1],v=f[2],m=f[3];return new AV(l+h-m,u+h-p,l+d+g,u+d+v)}var y=Ve(t.startPos,2),b=y[0],x=y[1],E=Ve(t.endPos,2),w=E[0],k=E[1],M=Ve(bV(t)?[-e,0,e,0]:[0,e,0,-e],4),S=M[0],N=M[1],O=M[2],T=M[3],A=oz(vV(0,t),i),C=new AV(b,x,w,k);return C.x1+=T,C.y1+=S,C.x2+=N+A[0],C.y2+=O+A[1],C}(e,o),u=function(t){return!l||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,a=t.y2;return DV([[r,o],[i,o],[i,a],[r,a]],CV(e,n))}(l,t)},c=function(t,e){return!t||!t.firstChild||!function(t,e,n){var r,i,o=CV(t,n).flat(1),a=CV(e,n).flat(1),s=[[o[0],o[1],o[2],o[3]],[o[0],o[1],o[4],o[5]],[o[4],o[5],o[6],o[7]],[o[2],o[3],o[6],o[7]]];try{for(var l=Ge(s),u=l.next();!u.done;u=l.next())if(LV(a,u.value))return!0}catch(t){r={error:t}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}return!1}(t.firstChild,e.firstChild,Ez(n))};try{for(var h=Ge(t),d=h.next();!d.done;d=h.next()){var f=d.value;u(f)?!s||c(s,f)?s=f:(a.add(s),a.add(f)):a.add(f)}}catch(t){r={error:t}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}return Array.from(a)}function IV(t,e){return void 0===e&&(e={}),Ut(t)?0:"number"==typeof t?t:Math.floor(XF(t,e))}var jV=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter((function(t,e){return!(e%r)||(_F(t),!1)}))};var BV=new Map([["hide",function(t,e,n,r){var i=t.length,o=e.keepHeader,a=e.keepTail;if(!(i<=1||2===i&&o&&a)){var s,l,u,c=jV,h=function(t){return t.forEach(r.show),t},d=2,f=t.slice(),p=t.slice(),g=Math.min.apply(Math,We([1],Ve(t.map((function(t){return t.getBBox().width}))),!1));if("linear"===n.type&&(yV(n)||bV(n))){var v=wz(t[0]).left,m=wz(t[i-1]).right,y=Math.abs(m-v)||1;d=Math.max(Math.floor(i*g/y),d)}for(o&&(s=f.splice(0,1)[0]),a&&(l=f.splice(-1,1)[0],f.reverse()),h(f);d<t.length&&_V((u=l?We(We([l],Ve(p),!1),[s],!1):We([s],Ve(p),!1),u.filter(qF)),n,null==e?void 0:e.margin).length;){if(l&&!s&&d%2==0)f.splice(0,1).forEach(r.hide);else if(l&&s){f.splice(0,1).forEach(r.hide)}p=c(h(f),{seq:d}),d++}}}],["rotate",function(t,e,n,r){var i,o,a=e.optionalAngles,s=void 0===a?[0,45,90]:a,l=e.margin,u=e.recoverWhenFailed,c=void 0===u||u,h=t.map((function(t){return t.getLocalEulerAngles()})),d=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.rotate(t,+i)}))};try{for(var f=Ge(s),p=f.next();!p.done;p=f.next()){if(d(p.value),_V(t,n,l).length<1)return}}catch(t){i={error:t}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}c&&d(h)}],["ellipsis",function(t,e,n,r){if(!(t.length<=1)){var i=e.suffix,o=void 0===i?"...":i,a=e.minLength,s=e.maxLength,l=void 0===s?1/0:s,u=e.step,c=void 0===u?" ":u,h=e.margin,d=void 0===h?[0,0,0,0]:h,f=KF(r.getTextShape(t[0])),p=IV(c,f),g=a?IV(a,f):p,v=IV(l,f);(Ut(v)||v===1/0)&&(v=Math.max.apply(null,t.map((function(t){return t.getBBox().width}))));var m=t.slice(),y=Ve(d,4);y[0],y[1],y[2],y[3];for(var b=function(e){if(m.forEach((function(t){r.ellipsis(r.getTextShape(t),e,o)})),(m=_V(t,n,d)).length<1)return{value:void 0}},x=v;x>g+p;x-=p){var E=b(x);if("object"==typeof E)return E.value}}}],["wrap",function(t,e,n,r){var i=e.wordWrapWidth,o=void 0===i?50:i,a=e.maxLines,s=void 0===a?3:a,l=e.recoverWhenFailed,u=void 0===l||l,c=e.margin,h=void 0===c?[0,0,0,0]:c,d=t.map((function(t){return t.attr("maxLines")||1})),f=Math.min.apply(Math,We([],Ve(d),!1)),p=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&yV(t)?"negative"===n?"bottom":"top":"middle"}(n),g=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.wrap(t,o,i,p)}))};if(!(f>s)){for(var v=f;v<=s;v++)if(g(v),_V(t,n,h).length<1)return;u&&g(d)}}]]);function FV(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.reduce((function(t,e){return t*function(t){return"positive"===t?-1:1}(e)}),1)}function zV(t){for(var e=t;e<0;)e+=360;return Math.round(e%360)}function GV(t,e){var n=Ve(t,2),r=n[0],i=n[1],o=Ve(e,2),a=o[0],s=o[1],l=Ve([r*a+i*s,r*s-i*a],2),u=l[0],c=l[1];return Math.atan2(c,u)}function VV(t,e,n){var r,i=n.labelAlign;if(null===(r=e.style.transform)||void 0===r?void 0:r.includes("rotate"))return e.getLocalEulerAngles();var o=vV(t.value,n),a=pV(t.value,n);return"horizontal"===i?0:function(t){var e=(t+360)%180;return rz(e,-90,90)||(e+=180),e}(GF("perpendicular"===i?GV([1,0],o):GV([a[0]<0?-1:1,0],a)))}function WV(t,e,n){var r=n.type,i=n.labelAlign,o=vV(t,n),a=zV(e),s=zV(GF(GV([1,0],o))),l="center",u="middle";return"linear"===r?[90,270].includes(s)&&0===a?(l="center",u=1===o[1]?"top":"bottom"):s%180||![90,270].includes(a)?0===s?(rz(a,0,90,!1,!0)||rz(a,0,90)||rz(a,270,360))&&(l="start"):90===s?rz(a,0,90,!1,!0)?l="start":(rz(a,90,180)||rz(a,270,360))&&(l="end"):270===s?rz(a,0,90,!1,!0)?l="end":(rz(a,90,180)||rz(a,270,360))&&(l="start"):180===s&&(90===a?l="start":(rz(a,0,90)||rz(a,270,360))&&(l="end")):l="center":"parallel"===i?u=rz(s,0,180,!0)?"top":"bottom":"horizontal"===i?rz(s,90,270,!1)?l="end":(rz(s,270,360,!1)||rz(s,0,90))&&(l="start"):"perpendicular"===i&&(l=rz(s,90,270)?"end":"start"),{textAlign:l,textBaseline:u}}function HV(t,e,n){var r=n.showTick,i=n.tickLength,o=n.tickDirection,a=n.labelDirection,s=n.labelSpacing,l=e.indexOf(t),u=WF(s,[t,l,e]),c=Ve([vV(t.value,n),FV(a,o)],2),h=Ve(az(oz(c[0],u+(1===c[1]?WF(r?i:0,[t,l,e]):0)),mV(t.value,n)),2);return{x:h[0],y:h[1]}}function YV(t,e){"text"===t.nodeName&&t.attr(e)}function UV(t){!function(t,e,n){var r=e.labelOverlap,i=void 0===r?[]:r;i.length&&i.forEach((function(r){var i=r.type,o=BV.get(i);(function(t,e,n){return!(e.labelOverlap.length<1)&&("hide"===n?!function(t){for(var e=t;e;){if("offscreen"===e.className)return!0;e=e.parent}return!1}(t[0]):"rotate"===n?!t.some((function(t){var e;return!!(null===(e=t.attr("transform"))||void 0===e?void 0:e.includes("rotate"))})):"ellipsis"!==n&&"wrap"!==n||t.filter((function(t){return t.querySelector("text")})).length>1)})(t,e,i)&&(null==o||o(t,r,e,n))}))}(this.node().childNodes,t,{hide:_F,show:LF,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=WV(e.__data__.value,t,n),i=e.querySelector(oV.labelItem.class);i&&YV(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&JF(t,e||1/0,n)},wrap:function(t,e,n){var r,i;t&&(void 0===(r=n)&&(r=2),void 0===i&&(i="top"),QF(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector("text")}})}function $V(t,e,n,r,i){var o=n.indexOf(e),a=xz(t).append(function(t,e,n,r){var i=r.labelFormatter;return Yt(i)?function(){return ez(WF(i,[t,e,n,vV(t.value,r)]))}:function(){return ez(t.label||"")}}(e,o,n,i)).attr("className",oV.labelItem.name).node(),s=Ve(Az(hV(r,[e,o,n])),2),l=s[0],u=s[1],c=u.transform,h=Fe(u,["transform"]);Pz(a,c);var d=VV(e,a,i);return a.getLocalEulerAngles()||a.setLocalEulerAngles(d),YV(a,Be(Be({},WV(e.value,d,i)),l)),t.attr(h),a}function qV(t,e,n,r){var i=dV(e,n.labelFilter),o=Oz(n,"label");return t.selectAll(oV.label.class).data(i,(function(t,e){return e})).join((function(r){return r.append("g").attr("className",oV.label.name).transition((function(t){$V(this,t,e,o,n);var r=HV(t,e,n),i=r.x,a=r.y;return this.style.transform="translate(".concat(i,", ").concat(a,")"),null})).call((function(){UV.call(t,n)}))}),(function(i){return i.transition((function(t){var i=function(t,e,n,r){if(void 0===r&&(r="destroy"),function(t,e){return"text"===t.nodeName&&"text"===e.nodeName&&t.attributes.text===e.attributes.text}(t,e))return t.remove(),[null];var i=function(){"destroy"===r?t.destroy():"hide"===r&&_F(t),e.isVisible()&&LF(e)};if(!n)return i(),[null];var o=n.duration,a=void 0===o?0:o,s=n.delay,l=void 0===s?0:s,u=Math.ceil(+a/2),c=+a/4,h=Ve(t.getGeometryBounds().center,2),d=h[0],f=h[1],p=Ve(e.getGeometryBounds().center,2),g=Ve([(d+p[0])/2-d,(f+p[1])/2-f],2),v=g[0],m=g[1],y=t.style.opacity,b=void 0===y?1:y,x=e.style.opacity,E=void 0===x?1:x,w=t.style.transform||"",k=e.style.transform||"",M=t.animate([{opacity:b,transform:"translate(0, 0) ".concat(w)},{opacity:0,transform:"translate(".concat(v,", ").concat(m,") ").concat(w)}],Be(Be({fill:"both"},n),{duration:l+u+c})),S=e.animate([{opacity:0,transform:"translate(".concat(-v,", ").concat(-m,") ").concat(k),offset:.01},{opacity:E,transform:"translate(0, 0) ".concat(k)}],Be(Be({fill:"both"},n),{duration:u+c,delay:l+u-c}));return YG(S,i),[M,S]}(this.querySelector(oV.labelItem.class),$V(this,t,e,o,n),r.update),a=HV(t,e,n),s=a.x,l=a.y,u=qG(this,{transform:"translate(".concat(s,", ").concat(l,")")},r.update);return We(We([],Ve(i),!1),[u],!1)})).call((function(e){var r,i,o=Oe(e,"_transitions").flat().filter(qF);i=function(){UV.call(t,n)},0===(r=o).length?i():Promise.all(r.map((function(t){return null==t?void 0:t.finished}))).then(i)}))}),(function(t){return t.transition((function(){var t=this,e=XG(this.childNodes[0],r.exit);return YG(e,(function(){return xz(t).remove()})),e}))})).transitions()}function XV(t,e){return gV(t,e.tickDirection,e)}function KV(t,e,n,r,i){var o=Ve(function(t,e){var n=Ve(t,2);return[[0,0],[n[0]*e,n[1]*e]]}(r,WF(i.tickLength,[t,e,n])),2),a=Ve(o[0],2),s=a[0],l=a[1],u=Ve(o[1],2);return{x1:s,x2:u[0],y1:l,y2:u[1]}}function ZV(t,e,n,r,i,o){var a=function(t,e,n,r,i){var o=i.tickFormatter,a=XV(e.value,i),s="line";return Yt(o)&&(s=function(){return WF(o,[e,n,r,a])}),t.append(s).attr("className",oV.tickItem.name)}(xz(this),t,e,n,r);!function(t,e,n,r,i,o,a){var s=XV(t.value,o),l=KV(t,e,n,s,o),u=l.x1,c=l.x2,h=l.y1,d=l.y2,f=Ve(Az(hV(a,[t,e,n,s])),2),p=f[0],g=f[1];"line"===r.node().nodeName&&r.styles(Be({x1:u,x2:c,y1:h,y2:d},p)),i.attr(g),r.styles(p)}(t,e,n,a,this,r,i);var s=Ve(mV(t.value,r),2),l=s[0],u=s[1];return qG(this,{transform:"translate(".concat(l,", ").concat(u,")")},o)}var QV=YF({text:"text"},"title");function JV(t){return/\S+-\S+/g.test(t)?t.split("-").map((function(t){return t[0]})):t.length>2?[t[0]]:t.split("")}function tW(t,e){var n=Object.entries(e).reduce((function(e,n){var r=Ve(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e}),{});t.styles(n)}var eW=function(t){function e(e){return t.call(this,e,{text:"",width:0,height:0,fill:"#4a505a",fontWeight:"bold",fontSize:12,fontFamily:"sans-serif",inset:0,spacing:0,position:"top-left"})||this}return je(e,t),e.prototype.getAvailableSpace=function(){var t=this.attributes,e=t.width,n=t.height,r=t.position,i=t.spacing,o=t.inset,a=this.querySelector(QV.text.class);if(!a)return new VF(0,0,+e,+n);var s=a.getBBox(),l=s.width,u=s.height,c=Ve(Ez(i),4),h=c[0],d=c[1],f=c[2],p=c[3],g=Ve([0,0,+e,+n],4),v=g[0],m=g[1],y=g[2],b=g[3],x=JV(r);if(x.includes("i"))return new VF(v,m,y,b);x.forEach((function(t,r){var i,o,a,s;"t"===t&&(i=Ve(0===r?[u+f,+n-u-f]:[0,+n],2),m=i[0],b=i[1]),"r"===t&&(o=Ve([+e-l-p],1),y=o[0]),"b"===t&&(a=Ve([+n-u-h],1),b=a[0]),"l"===t&&(s=Ve(0===r?[l+d,+e-l-d]:[0,+e],2),v=s[0],y=s[1])}));var E=Ve(Ez(o),4),w=E[0],k=E[1],M=E[2],S=E[3],N=Ve([S+k,w+M],2),O=N[0],T=N[1];return new VF(v+S,m+w,y-O,b-T)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new VF(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=Fe(t,["width","height","position","spacing"]),i=Ve(Az(r),1)[0],o=function(t){var e,n,r,i,o=t,a=o.width,s=o.height,l=o.position,u=Ve([+a/2,+s/2],2),c=Ve([+u[0],+u[1],"center","middle"],4),h=c[0],d=c[1],f=c[2],p=c[3],g=JV(l);return g.includes("l")&&(h=(e=Ve([0,"start"],2))[0],f=e[1]),g.includes("r")&&(h=(n=Ve([+a,"end"],2))[0],f=n[1]),g.includes("t")&&(d=(r=Ve([0,"top"],2))[0],p=r[1]),g.includes("b")&&(d=(i=Ve([+s,"bottom"],2))[0],p=i[1]),{x:h,y:d,textAlign:f,textBaseline:p}}(t),a=o.x,s=o.y,l=o.textAlign,u=o.textBaseline;nz(!!r.text,xz(e),(function(t){n.title=t.maybeAppendByClassName(QV.text,"text").styles(i).call(tW,{x:a,y:s,textAlign:l,textBaseline:u}).node()}))},e}(Lz);function nW(t,e,n,r,i){var o=Ve(Az(Oz(r,"title")),2),a=o[0],s=o[1],l=s.transform,u=s.transformOrigin,c=Fe(s,["transform","transformOrigin"]);e.styles(c);var h=l||function(t,e,n){var r=2*t.getGeometryBounds().halfExtents[1];if("vertical"===e){if("left"===n)return"rotate(-90) translate(0, ".concat(r/2,")");if("right"===n)return"rotate(-90) translate(0, -".concat(r/2,")")}return""}(t.node(),a.direction,a.position);t.styles(Be(Be({},a),{transformOrigin:u})),Pz(t.node(),h);var d=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,a=JV(i),s=t.node().getLocalBounds(),l=Ve(s.min,2),u=l[0],c=l[1],h=Ve(s.halfExtents,2),d=h[0],f=h[1],p=Ve(e.node().getLocalBounds().halfExtents,2),g=p[0],v=p[1],m=Ve([u+d,c+f],2),y=m[0],b=m[1],x=Ve(Ez(o),4),E=x[0],w=x[1],k=x[2],M=x[3];if(["start","end"].includes(i)&&"linear"===n.type){var S=n.startPos,N=n.endPos,O=Ve("start"===i?[S,N]:[N,S],2),T=O[0],A=O[1],C=Ve(oz(hz([-A[0]+T[0],-A[1]+T[1]]),E),2),P=C[0],R=C[1];return{x:T[0]+P,y:T[1]+R}}return a.includes("t")&&(b-=f+v+E),a.includes("r")&&(y+=d+g+w),a.includes("l")&&(y-=d+g+M),a.includes("b")&&(b+=f+v+k),{x:y,y:b}}(xz(n._offscreen||n.querySelector(oV.mainGroup.class)),e,r),f=d.x,p=d.y;return qG(e.node(),{transform:"translate(".concat(f,", ").concat(p,")")},i)}function rW(t,e,n,r){var i=t.showLine,o=t.showTick,a=t.showLabel,s=nz(i,e.maybeAppendByClassName(oV.lineGroup,"g"),(function(e){return SV(e,t,r)}))||[],l=nz(o,e.maybeAppendByClassName(oV.tickGroup,"g"),(function(e){return function(t,e,n,r){var i=dV(e,n.tickFilter),o=Oz(n,"tick");return t.selectAll(oV.tick.class).data(i,(function(t){return t.id||t.label})).join((function(t){return t.append("g").attr("className",oV.tick.name).transition((function(t,e){return ZV.call(this,t,e,i,n,o,!1)}))}),(function(t){return t.transition((function(t,e){return this.removeChildren(),ZV.call(this,t,e,i,n,o,r.update)}))}),(function(t){return t.transition((function(){var t=this,e=XG(this.childNodes[0],r.exit);return YG(e,(function(){return t.remove()})),e}))})).transitions()}(e,n,t,r)}))||[],u=nz(a,e.maybeAppendByClassName(oV.labelGroup,"g"),(function(e){return qV(e,n,t,r)}))||[];return We(We(We([],Ve(s),!1),Ve(l),!1),Ve(u),!1).filter((function(t){return!!t}))}var iW=function(t){function e(e){return t.call(this,e,iV)||this}return je(e,t),e.prototype.render=function(t,e,n){var r=this,i=t.titleText,o=t.data,a=t.animate,s=t.showTitle,l=t.showGrid,u=t.dataThreshold,c=t.truncRange,h=function(t,e){if(t.length<=e)return t;for(var n=Math.floor(t.length/e),r=[],i=0;i<t.length;i+=n)r.push(t[i]);return r}(o,u).filter((function(t){var e=t.value;return!(c&&e>c[0]&&e<c[1])})),d=HG(void 0===n?a:n),f=nz(l,xz(e).maybeAppendByClassName(oV.gridGroup,"g"),(function(e){return TV(e,h,t,d)}))||[],p=xz(e).maybeAppendByClassName(oV.mainGroup,"g");i&&(!this.initialized&&d.enter||this.initialized&&d.update)&&rW(t,xz(this.offscreenGroup),h,HG(!1));var g=rW(t,xz(p.node()),h,d),v=nz(s,xz(e).maybeAppendByClassName(oV.titleGroup,"g"),(function(e){return function(t,e,n,r){var i=n.titleText;return t.selectAll(oV.title.class).data([{title:i}].filter((function(t){return!!t.title})),(function(t,e){return t.title})).join((function(o){return o.append((function(){return ez(i)})).attr("className",oV.title.name).transition((function(){return nW(xz(this),t,e,n,r.enter)}))}),(function(i){return i.transition((function(){return nW(xz(this),t,e,n,r.update)}))}),(function(t){return t.remove()})).transitions()}(e,r,t,d)}))||[];return We(We(We([],Ve(f),!1),Ve(g),!1),Ve(v),!1).flat().filter((function(t){return!!t}))},e}(Lz),oW=YF({prevBtnGroup:"prev-btn-group",prevBtn:"prev-btn",nextBtnGroup:"next-btn-group",nextBtn:"next-btn",pageInfoGroup:"page-info-group",pageInfo:"page-info",playWindow:"play-window",contentGroup:"content-group",controller:"controller",clipPath:"clip-path"},"navigator"),aW=function(t){function e(e){var n=t.call(this,e,{x:0,y:0,animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonD:zz(0,0,6),buttonSize:12,controllerPadding:5,controllerSpacing:5,formatter:function(t,e){return"".concat(t,"/").concat(e)},defaultPage:0,loop:!1,orientation:"horizontal",pageNumFill:"black",pageNumFontSize:12,pageNumTextAlign:"start",pageNumTextBaseline:"middle"})||this;return n.playState="idle",n.contentGroup=n.appendChild(new jl({class:oW.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new jl({class:oW.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return je(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return oe(t,0,Math.max(this.pageViews.length-1,0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.playWindow.children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"controllerShape",{get:function(){return this.totalPages>1?{width:55,height:0}:{width:0,height:0}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageShape",{get:function(){var t=Ve(function(t){var e;return(null===(e=t[0])||void 0===e?void 0:e.map((function(e,n){return t.map((function(t){return t[n]}))})))||[]}(this.pageViews.map((function(t){var e=t.getBBox();return[e.width,e.height]}))).map((function(t){return Math.max.apply(Math,We([],Ve(t),!1))})),2),e=t[0],n=t[1],r=this.attributes,i=r.pageWidth,o=void 0===i?e:i,a=r.pageHeight;return{pageWidth:o,pageHeight:void 0===a?n:a}},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.playWindow},Object.defineProperty(e.prototype,"totalPages",{get:function(){return this.pageViews.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currPage",{get:function(){return this.innerCurrPage},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e=t.prototype.getBBox.call(this),n=e.x,r=e.y,i=this.controllerShape,o=this.pageShape,a=o.pageWidth,s=o.pageHeight;return new VF(n,r,a+i.width,s)},e.prototype.goTo=function(t){var e=this,n=this.attributes.animate,r=this,i=r.currPage,o=r.playState,a=r.playWindow,s=r.pageViews;if("idle"!==o||t<0||s.length<=0||t>=s.length)return null;s[i].setLocalPosition(0,0),this.prepareFollowingPage(t);var l=Ve(this.getFollowingPageDiff(t),2),u=l[0],c=l[1];this.playState="running";var h=$G(a,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-u,", ").concat(-c,")")}],n);return YG(h,(function(){e.innerCurrPage=t,e.playState="idle",e.setVisiblePages([t]),e.updatePageInfo()})),h},e.prototype.prev=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n<=0)return null;var r=t?(n-1+e)%e:oe(n-1,0,e);return this.goTo(r)},e.prototype.next=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n>=e-1)return null;var r=t?(n+1)%e:oe(n+1,0,e);return this.goTo(r)},e.prototype.renderClipPath=function(t){var e=this.pageShape,n=e.pageWidth,r=e.pageHeight;n&&r?(this.clipPath=t.maybeAppendByClassName(oW.clipPath,"rect").styles({width:n,height:r}),this.contentGroup.attr("clipPath",this.clipPath.node())):this.contentGroup.style.clipPath=void 0},e.prototype.setVisiblePages=function(t){this.playWindow.children.forEach((function(e,n){t.includes(n)?LF(e):_F(e)}))},e.prototype.adjustControllerLayout=function(){var t=this,e=t.prevBtnGroup,n=t.nextBtnGroup,r=t.pageInfoGroup,i=this.attributes,o=i.orientation,a=i.controllerPadding,s=r.getBBox(),l=s.width;s.height;var u=Ve("horizontal"===o?[-180,0]:[-90,90],2),c=u[0],h=u[1];e.setLocalEulerAngles(c),n.setLocalEulerAngles(h);var d=e.getBBox(),f=d.width,p=d.height,g=n.getBBox(),v=g.width,m=g.height,y=Math.max(f,l,v),b="horizontal"===o?{offset:[[0,0],[f/2+a,0],[f+l+2*a,0]],textAlign:"start"}:{offset:[[y/2,-p-a],[y/2,0],[y/2,m+a]],textAlign:"center"},x=Ve(b.offset,3),E=Ve(x[0],2),w=E[0],k=E[1],M=Ve(x[1],2),S=M[0],N=M[1],O=Ve(x[2],2),T=O[0],A=O[1],C=b.textAlign,P=r.querySelector("text");P&&(P.style.textAlign=C),e.setLocalPosition(w,k),r.setLocalPosition(S,N),n.setLocalPosition(T,A)},e.prototype.updatePageInfo=function(){var t,e=this,n=e.currPage,r=e.pageViews,i=e.attributes.formatter;r.length<2||(null===(t=this.pageInfoGroup.querySelector(oW.pageInfo.class))||void 0===t||t.attr("text",i(n+1,r.length)),this.adjustControllerLayout())},e.prototype.getFollowingPageDiff=function(t){var e=this.currPage;if(e===t)return[0,0];var n=this.attributes.orientation,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,a=t<e?-1:1;return"horizontal"===n?[a*i,0]:[0,a*o]},e.prototype.prepareFollowingPage=function(t){var e=this.currPage,n=this.pageViews;if(this.setVisiblePages([t,e]),t!==e){var r=Ve(this.getFollowingPageDiff(t),2),i=r[0],o=r[1];n[t].setLocalPosition(i,o)}},e.prototype.renderController=function(t){var e=this,n=this.attributes.controllerSpacing,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,a=this.pageViews.length>=2,s=t.maybeAppendByClassName(oW.controller,"g");if(IF(s.node(),a),a){var l=Oz(this.attributes,"button"),u=Oz(this.attributes,"pageNum"),c=Ve(Az(l),2),h=c[0],d=c[1],f=h.size,p=Fe(h,["size"]),g=!s.select(oW.prevBtnGroup.class).node(),v=s.maybeAppendByClassName(oW.prevBtnGroup,"g").styles(d);this.prevBtnGroup=v.node();var m=v.maybeAppendByClassName(oW.prevBtn,"path"),y=s.maybeAppendByClassName(oW.nextBtnGroup,"g").styles(d);this.nextBtnGroup=y.node(),[m,y.maybeAppendByClassName(oW.nextBtn,"path")].forEach((function(t){t.styles(Be(Be({},p),{transformOrigin:"center"})),yz(t.node(),f)}));var b=s.maybeAppendByClassName(oW.pageInfoGroup,"g");this.pageInfoGroup=b.node(),b.maybeAppendByClassName(oW.pageInfo,"text").styles(u),this.updatePageInfo(),s.node().setLocalPosition(i+n,o/2),g&&(this.prevBtnGroup.addEventListener("click",(function(){e.prev()})),this.nextBtnGroup.addEventListener("click",(function(){e.next()})))}},e.prototype.render=function(t,e){var n=t.x,r=void 0===n?0:n,i=t.y,o=void 0===i?0:i;this.attr("transform","translate(".concat(r,", ").concat(o,")"));var a=xz(e);this.renderClipPath(a),this.renderController(a),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=ye((function(){return t.render(t.attributes,t)}),50);this.playWindow.addEventListener(Vs.INSERTED,e),this.playWindow.addEventListener(Vs.REMOVED,e)},e}(Lz);function sW(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}Vz.registerSymbol("hiddenHandle",(function(t,e,n){var r=1.4*n;return[["M",t-n,e-r],["L",t+n,e-r],["L",t+n,e+r],["L",t-n,e+r],["Z"]]})),Vz.registerSymbol("verticalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=t+.4*r;return[["M",t,e],["L",a,e+i],["L",t+r,e+i],["L",t+r,e-i],["L",a,e-i],["Z"],["M",a,e+o],["L",t+r-2,e+o],["M",a,e-o],["L",t+r-2,e-o]]})),Vz.registerSymbol("horizontalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=e+.4*r;return[["M",t,e],["L",t-i,a],["L",t-i,e+r],["L",t+i,e+r],["L",t+i,a],["Z"],["M",t-o,a],["L",t-o,e+r-2],["M",t+o,a],["L",t+o,e+r-2]]}));var lW=YF({layout:"flex",markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label",valueGroup:"value-group",value:"value",backgroundGroup:"background-group",background:"background"},"legend-category-item");var uW=function(t){function e(e){return t.call(this,e,{span:[1,1],marker:function(){return new Dl({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this}return je(e,t),Object.defineProperty(e.prototype,"showValue",{get:function(){var t=this.attributes.valueText;return!!t&&("string"==typeof t||"number"==typeof t?""!==t:"function"==typeof t||""!==t.attr("text"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"actualSpace",{get:function(){var t=this.labelGroup,e=this.valueGroup,n=this.attributes.markerSize,r=t.node().getBBox(),i=r.width,o=r.height,a=e.node().getBBox(),s=a.width,l=a.height;return{markerWidth:n,labelWidth:i,valueWidth:s,height:Math.max(n,o,l)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"span",{get:function(){var t=this.attributes.span;if(!t)return[1,1];var e=Ve(Ez(t),2),n=e[0],r=e[1],i=this.showValue?r:0,o=n+i;return[n/o,i/o]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t,e=this.attributes,n=e.markerSize,r=e.width,i=this.actualSpace,o=i.markerWidth,a=i.height,s=this.actualSpace,l=s.labelWidth,u=s.valueWidth,c=Ve(this.spacing,2),h=c[0],d=c[1];if(r){var f=r-n-h-d,p=Ve(this.span,2);l=(t=Ve([p[0]*f,p[1]*f],2))[0],u=t[1]}return{width:o+l+u+h+d,height:a,markerWidth:o,labelWidth:l,valueWidth:u}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes.spacing;if(!t)return[0,0];var e=Ve(Ez(t),2),n=e[0],r=e[1];return this.showValue?[n,r]:[n,0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layout",{get:function(){var t=this.shape,e=t.markerWidth,n=t.labelWidth,r=t.valueWidth,i=t.width,o=t.height,a=Ve(this.spacing,2),s=a[0];return{height:o,width:i,markerWidth:e,labelWidth:n,valueWidth:r,position:[e/2,e+s,e+n+s+a[1]]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleSize",{get:function(){var t=function(t){var e=t.querySelector(lW.marker.class);return e?e.style:{}}(this.markerGroup.node()),e=this.attributes,n=e.markerSize,r=e.markerStrokeWidth,i=void 0===r?t.strokeWidth:r,o=e.markerLineWidth,a=void 0===o?t.lineWidth:o,s=e.markerStroke,l=void 0===s?t.stroke:s,u=+(i||a||(l?1:0))*Math.sqrt(2),c=this.markerGroup.node().getBBox(),h=c.width,d=c.height;return(1-u/Math.max(h,d))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes.marker,r=Oz(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(lW.markerGroup,"g").style("zIndex",0),nz(!!n,this.markerGroup,(function(){var t,i=e.markerGroup.node(),o=null===(t=i.childNodes)||void 0===t?void 0:t[0],a="string"==typeof n?new Vz({style:{symbol:n},className:lW.marker.name}):n();o?a.nodeName===o.nodeName?o instanceof Vz?o.update(Be(Be({},r),{symbol:n})):(!function(t,e){var n,r,i=e.attributes;try{for(var o=Ge(Object.entries(i)),a=o.next();!a.done;a=o.next()){var s=Ve(a.value,2),l=s[0],u=s[1];"id"!==l&&"className"!==l&&t.attr(l,u)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(o,a),xz(o).styles(r)):(o.remove(),xz(a).attr("className",lW.marker.name).styles(r),i.appendChild(a)):(a instanceof Vz||xz(a).attr("className",lW.marker.name).styles(r),i.appendChild(a)),e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]);var s=yz(e.markerGroup.node(),e.scaleSize);e.markerGroup.node().style._transform="scale(".concat(s,")")}))},e.prototype.renderLabel=function(t){var e=Oz(this.attributes,"label"),n=e.text,r=Fe(e,["text"]);this.labelGroup=t.maybeAppendByClassName(lW.labelGroup,"g").style("zIndex",0),this.labelGroup.maybeAppendByClassName(lW.label,(function(){return ez(n)})).styles(r)},e.prototype.renderValue=function(t){var e=this,n=Oz(this.attributes,"value"),r=n.text,i=Fe(n,["text"]);this.valueGroup=t.maybeAppendByClassName(lW.valueGroup,"g").style("zIndex",0),nz(this.showValue,this.valueGroup,(function(){e.valueGroup.maybeAppendByClassName(lW.value,(function(){return ez(r)})).styles(i)}))},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,i=Oz(this.attributes,"background");this.background=t.maybeAppendByClassName(lW.backgroundGroup,"g").style("zIndex",-1),this.background.maybeAppendByClassName(lW.background,"rect").styles(Be({width:n,height:r},i))},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=Ve(t.position,3),o=i[0],a=i[1],s=i[2],l=r/2;this.markerGroup.styles({transform:"translate(".concat(o,", ").concat(l,")").concat(this.markerGroup.node().style._transform)}),this.labelGroup.styles({transform:"translate(".concat(a,", ").concat(l,")")}),JF(this.labelGroup.select(lW.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({transform:"translate(".concat(s,", ").concat(l,")")}),JF(this.valueGroup.select(lW.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=xz(e),r=t.x,i=void 0===r?0:r,o=t.y,a=void 0===o?0:o;n.styles({transform:"translate(".concat(i,", ").concat(a,")")}),this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.adjustLayout()},e}(Lz),cW=YF({page:"item-page",navigator:"navigator",item:"item"},"items"),hW=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},dW=function(t){function e(e){var n=t.call(this,e,{data:[],gridRow:1/0,gridCol:void 0,padding:0,width:1e3,height:100,rowPadding:0,colPadding:0,layout:"flex",orientation:"horizontal",click:Le,mouseenter:Le,mouseleave:Le})||this;return n.navigatorShape=[0,0],n}return je(e,t),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.navigator.getContainer()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){var t=this.attributes,e=t.gridRow,n=t.gridCol,r=t.data;if(!e&&!n)throw new Error("gridRow and gridCol can not be set null at the same time");return e&&n?[e,n]:e?[e,r.length]:[r.length,n]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderData",{get:function(){var t=this.attributes,e=t.data,n=t.layout,r=Oz(this.attributes,"item"),i=e.map((function(t,i){var o=t.id,a=void 0===o?i:o,s=t.label,l=t.value;return{id:"".concat(a),index:i,style:Be({layout:n,labelText:s,valueText:l},Object.fromEntries(Object.entries(r).map((function(n){var r=Ve(n,2);return[r[0],WF(r[1],[t,i,e])]}))))}}));return i},enumerable:!1,configurable:!0}),e.prototype.getGridLayout=function(){var t=this,e=this.attributes,n=e.orientation,r=e.width,i=e.rowPadding,o=e.colPadding,a=Ve(this.navigatorShape,1)[0],s=Ve(this.grid,2),l=s[0],u=s[1],c=u*l,h=0;return this.pageViews.children.map((function(e,s){var d,f,p=Math.floor(s/c),g=s%c,v=t.ifHorizontal(u,l),m=[Math.floor(g/v),g%v];"vertical"===n&&m.reverse();var y=Ve(m,2),b=y[0],x=y[1],E=(r-a-(u-1)*o)/u,w=e.getBBox().height,k=Ve([0,0],2),M=k[0],S=k[1];return"horizontal"===n?(M=(d=Ve([h,b*(w+i)],2))[0],S=d[1],h=x===u-1?0:h+E+o):(M=(f=Ve([x*(E+o),h],2))[0],S=f[1],h=b===l-1?0:h+w+i),{page:p,index:s,row:b,col:x,pageIndex:g,width:E,height:w,x:M,y:S}}))},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=Ve(this.navigatorShape,1)[0],a=Ve(this.grid,2),s=a[0],l=a[1],u=Ve([e-o,n],2),c=u[0],h=u[1],d=Ve([0,0,0,0,0,0,0,0],8),f=d[0],p=d[1],g=d[2],v=d[3],m=d[4],y=d[5],b=d[6],x=d[7];return this.pageViews.children.map((function(t,e){var n,o,a,u,d=t.getBBox(),E=d.width,w=d.height,k=0===b?0:i,M=b+k+E;return M<=c&&hW(m,(function(t){return t<l}))?(n=Ve([b+k,x,M],3),f=n[0],p=n[1],b=n[2],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}):(o=Ve([y+1,0,0,x+w+r],4),y=o[0],m=o[1],b=o[2],(x=o[3])+w<=h&&hW(y,(function(t){return t<s}))?(a=Ve([b,x,E],3),f=a[0],p=a[1],b=a[2],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}):(u=Ve([0,0,E,0,g+1,0,0,0],8),f=u[0],p=u[1],b=u[2],x=u[3],g=u[4],v=u[5],y=u[6],m=u[7],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}))}))},Object.defineProperty(e.prototype,"itemsLayout",{get:function(){this.navigatorShape=[0,0];var t="grid"===this.attributes.layout?this.getGridLayout:this.getFlexLayout,e=t.call(this);return e.slice(-1)[0].page>0?(this.navigatorShape=[55,0],t.call(this)):e},enumerable:!1,configurable:!0}),e.prototype.ifHorizontal=function(t,e){return sW(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(cW.item.class).forEach((function(e){t.appendChild(e)})),t.querySelectorAll(cW.page.class).forEach((function(e){t.removeChild(e).destroy()}))},e.prototype.renderItems=function(t){var e=this.attributes,n=e.click,r=e.mouseenter,i=e.mouseleave;this.flattenPage(t);var o=this.dispatchCustomEvent.bind(this);xz(t).selectAll(cW.item.class).data(this.renderData,(function(t){return t.id})).join((function(t){return t.append((function(t){var e=t.style;return new uW({style:e})})).attr("className",cW.item.name).on("click",(function(){null==n||n(this),o("itemClick",{item:this})})).on("pointerenter",(function(){null==r||r(this),o("itemMouseenter",{item:this})})).on("pointerleave",(function(){null==i||i(this),o("itemMouseleave",{item:this})}))}),(function(t){return t.each((function(t){var e=t.style;this.update(e)}))}),(function(t){return t.remove()}))},e.prototype.relayoutNavigator=function(){var t,e=this.attributes,n=e.layout,r=e.width,i=(null===(t=this.pageViews.children[0])||void 0===t?void 0:t.getBBox().height)||0,o=Ve(this.navigatorShape,2),a=o[0],s=o[1];this.navigator.update("grid"===n?{pageWidth:r-a,pageHeight:i-s}:{})},e.prototype.adjustLayout=function(){var t,e,n=this,r=Object.entries((t=this.itemsLayout,e="page",t.reduce((function(t,n){return(t[n[e]]=t[n[e]]||[]).push(n),t}),{}))).map((function(t){var e=Ve(t,2);return{page:e[0],layouts:e[1]}})),i=We([],Ve(this.navigator.getContainer().children),!1);r.forEach((function(t){var e=t.layouts,r=n.pageViews.appendChild(new jl({className:cW.page.name}));e.forEach((function(t){var e=t.x,n=t.y,o=t.index,a=t.width,s=t.height,l=i[o];r.appendChild(l),Te(l,"__layout__",t),l.update({x:e,y:n,width:a,height:s})}))})),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes.orientation,n=Oz(this.attributes,"nav"),r=$F({orientation:e},n),i=this;return t.selectAll(cW.navigator.class).data(["nav"]).join((function(t){return t.append((function(){return new aW({style:r})})).attr("className",cW.navigator.name).each((function(){i.navigator=this}))}),(function(t){return t.each((function(){this.update(r)}))}),(function(t){return t.remove()})),this.navigator},e.prototype.getBBox=function(){return this.navigator.getBBox()},e.prototype.render=function(t,e){var n=this.attributes.data;if(n&&0!==n.length){var r=this.renderNavigator(xz(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new Rs(t,{detail:e});this.dispatchEvent(n)},e}(Lz),fW=YF({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),pW={showLabel:!0,formatter:function(t){return t.toString()},markerSize:25,markerStroke:"#c5c5c5",markerFill:"#fff",markerLineWidth:1,labelFontSize:12,labelFill:"#c5c5c5",labelText:"",orientation:"vertical",spacing:0};!function(t){function e(e){return t.call(this,e,pW)||this}je(e,t),e.prototype.render=function(t,e){var n=xz(e).maybeAppendByClassName(fW.markerGroup,"g");this.renderMarker(n);var r=xz(e).maybeAppendByClassName(fW.labelGroup,"g");this.renderLabel(r)},e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.orientation,i=n.markerSymbol,o=void 0===i?sW(r,"horizontalHandle","verticalHandle"):i;nz(!!o,t,(function(t){var n=Oz(e.attributes,"marker"),r=Be({symbol:o},n);e.marker=t.maybeAppendByClassName(fW.marker,(function(){return new Vz({style:r})})).update(r)}))},e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.showLabel,i=n.orientation,o=n.spacing,a=void 0===o?0:o,s=n.formatter;nz(r,t,(function(t){var n,r=Oz(e.attributes,"label"),o=r.text,l=Fe(r,["text"]),u=(null===(n=t.select(fW.marker.class))||void 0===n?void 0:n.node().getBBox())||{},c=u.width,h=void 0===c?0:c,d=u.height,f=Ve(sW(i,[0,(void 0===d?0:d)+a,"center","top"],[h+a,0,"start","middle"]),4),p=f[0],g=f[1],v=f[2],m=f[3];t.maybeAppendByClassName(fW.label,"text").styles(Be(Be({},l),{x:p,y:g,text:s(o).toString(),textAlign:v,textBaseline:m}))}))}}(Lz);var gW={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},vW=$F({},gW,{});$F({},gW,Tz(pW,"handle"),{color:["#d0e3fa","#acc7f6","#8daaf2","#6d8eea","#4d73cd","#325bb1","#5a3e75","#8c3c79","#e23455","#e7655b"],indicatorBackgroundFill:"#262626",indicatorLabelFill:"white",indicatorLabelFontSize:12,indicatorVisibility:"hidden",labelAlign:"value",labelDirection:"positive",labelSpacing:5,showHandle:!0,showIndicator:!0,showLabel:!0,slidable:!0,titleText:"",type:"continuous"});var mW=YF({title:"title",titleGroup:"title-group",items:"items",itemsGroup:"items-group",contentGroup:"content-group",ribbonGroup:"ribbon-group",ribbon:"ribbon",handlesGroup:"handles-group",handle:"handle",startHandle:"start-handle",endHandle:"end-handle",labelGroup:"label-group",label:"label",indicator:"indicator"},"legend"),yW=function(t){function e(e){return t.call(this,e,vW)||this}return je(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,i=r.showTitle,o=r.titleText,a=Ve(Az(Oz(this.attributes,"title")),2),s=a[0],l=a[1];this.titleGroup=t.maybeAppendByClassName(mW.titleGroup,"g").styles(l);var u=Be(Be({width:e,height:n},s),{text:i?o:""});this.title=this.titleGroup.maybeAppendByClassName(mW.title,(function(){return new eW({style:u})})).update(u)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,i=e.width,o=e.height,a=Ve(Az(Oz(this.attributes,"title",!0)),2),s=a[0],l=a[1],u=Be(Be({},s),{width:i,height:o,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName(mW.itemsGroup,"g").styles(Be(Be({},l),{transform:"translate(".concat(n,", ").concat(r,")")}));var c=this;this.itemsGroup.selectAll(mW.items.class).data(["items"]).join((function(t){return t.append((function(){return new dW({style:u})})).attr("className",mW.items.name).each((function(){c.items=xz(this)}))}),(function(t){return t.update(u)}),(function(t){return t.remove()}))},e.prototype.adjustLayout=function(){if(this.attributes.showTitle){var t=this.title.node().getAvailableSpace(),e=t.x,n=t.y;this.itemsGroup.node().style.transform="translate(".concat(e,", ").concat(n,")")}},Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes,e=t.showTitle,n=t.width,r=t.height;return e?this.title.node().getAvailableSpace():new VF(0,0,n,r)},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e,n,r=null===(e=this.title)||void 0===e?void 0:e.node(),i=null===(n=this.items)||void 0===n?void 0:n.node();return r&&i?function(t,e){var n=t.attributes,r=n.position,i=n.spacing,o=n.inset,a=n.text,s=t.getBBox(),l=e.getBBox(),u=JV(r),c=Ve(Ez(a?i:0),4),h=c[0],d=c[1],f=c[2],p=c[3],g=Ve(Ez(o),4),v=g[0],m=g[1],y=g[2],b=g[3],x=Ve([p+d,h+f],2),E=x[0],w=x[1],k=Ve([b+m,v+y],2),M=k[0],S=k[1];if("l"===u[0])return new VF(s.x,s.y,l.width+s.width+E+M,Math.max(l.height+S,s.height));if("t"===u[0])return new VF(s.x,s.y,Math.max(l.width+M,s.width),l.height+s.height+w+S);var N=Ve([e.attributes.width||l.width,e.attributes.height||l.height],2),O=N[0],T=N[1];return new VF(l.x,l.y,O+s.width+E+M,T+s.height+w+S)}(r,i):t.prototype.getBBox.call(this)},e.prototype.render=function(t,e){var n=this.attributes,r=n.width,i=n.height,o=n.x,a=void 0===o?0:o,s=n.y,l=void 0===s?0:s,u=xz(e);e.style.transform="translate(".concat(a,", ").concat(l,")"),this.renderTitle(u,r,i),this.renderItems(u,this.availableSpace),this.adjustLayout()},e}(Lz),bW={backgroundFill:"#262626",backgroundLineCap:"round",backgroundLineWidth:1,backgroundStroke:"#333",backgroundZIndex:-1,formatter:function(t){return t.toString()},labelFill:"#fff",labelFontSize:12,labelTextBaseline:"middle",padding:[2,4],position:"right",radius:0,zIndex:999},xW=YF({background:"background",labelGroup:"label-group",label:"label"},"indicator"),EW=function(t){function e(e){var n=t.call(this,e,bW)||this;return n.point=[0,0],n.group=n.appendChild(new jl({})),n.isMutationObserved=!0,n}return je(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=Ve(Ez(t.padding),4),r=n[0],i=n[1],o=n[2],a=n[3],s=this.label.node().getLocalBounds(),l=s.min,u=s.max,c=new VF(l[0]-a,l[1]-r,u[0]+i-l[0]+a,u[1]+o-l[1]+r),h=this.getPath(e,c),d=Oz(this.attributes,"background");this.background=xz(this.group).maybeAppendByClassName(xW.background,"path").styles(Be(Be({},d),{d:h})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=Ve(Az(Oz(this.attributes,"label")),2),i=r[0],o=r[1];i.text;var a=Fe(i,["text"]);(this.label=xz(this.group).maybeAppendByClassName(xW.labelGroup,"g").styles(o),n)&&this.label.maybeAppendByClassName(xW.label,(function(){return ez(e(n))})).style("text",e(n).toString()).selectAll("text").styles(a)},e.prototype.adjustLayout=function(){var t=Ve(this.point,2),e=t[0],n=t[1],r=this.attributes,i=r.x,o=r.y;this.group.attr("transform","translate(".concat(i-e,", ").concat(o-n,")"))},e.prototype.getPath=function(t,e){var n=this.attributes.radius,r=e.x,i=e.y,o=e.width,a=e.height,s=[["M",r+n,i],["L",r+o-n,i],["A",n,n,0,0,1,r+o,i+n],["L",r+o,i+a-n],["A",n,n,0,0,1,r+o-n,i+a],["L",r+n,i+a],["A",n,n,0,0,1,r,i+a-n],["L",r,i+n],["A",n,n,0,0,1,r+n,i],["Z"]],l={top:4,right:6,bottom:0,left:2}[t],u=this.createCorner([s[l].slice(-2),s[l+1].slice(-2)]);return s.splice.apply(s,We([l+1,1],Ve(u),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=kz.apply(void 0,We([],Ve(t),!1)),r=Ve(t,2),i=Ve(r[0],2),o=i[0],a=i[1],s=Ve(r[1],2),l=s[0],u=s[1],c=Ve(n?[l-o,[o,l]]:[u-a,[a,u]],2),h=c[0],d=Ve(c[1],2),f=d[0],p=d[1],g=h/2,v=e*(h/Math.abs(h)),m=v/2,y=v*Math.sqrt(3)/2*.8,b=Ve([f,f+g-m,f+g,f+g+m,p],5),x=b[0],E=b[1],w=b[2],k=b[3],M=b[4];return n?(this.point=[w,a-y],[["L",x,a],["L",E,a],["L",w,a-y],["L",k,a],["L",M,a]]):(this.point=[o+y,w],[["L",o,x],["L",o,E],["L",o+y,w],["L",o,k],["L",o,M]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?_F(this):LF(this)},e.prototype.bindEvents=function(){this.label.on(Vs.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(Lz);function wW(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 kW={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function MW(t){var e;void 0===t&&(t="");var n=wW(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)]=Be({flex:1},kW),e[".".concat(n.VALUE)]=Be({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},kW),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 SW=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=wW(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:MW(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return je(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,i=void 0===r?"":r,o=t.color,a=void 0===o?"black":o,s=t.index,l=Fe(t,["name","color","index"]),u=Be({name:i,color:a,index:null!=s?s:e},l);return An(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,u))}))},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=An(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:Rz(this.element,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,l=wW(r.prefixCls),u=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(u.innerHTML=r.title,u.getElementsByClassName(l.TITLE)[0].innerHTML=i):null===(e=null===(t=u.getElementsByClassName(l.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var c=this.HTMLTooltipItemsElements,h=document.createElement("ul");h.className=l.LIST,Rz(h,c);var d=this.element.querySelector(".".concat(l.LIST));d?d.replaceWith(h):u.appendChild(h)}!function(t,e){Object.entries(e).forEach((function(e){var n=Ve(e,2),r=n[0],i=n[1];We([t],Ve(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(":"),";")}),""))}))}))}(u,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,l=a.height,u=[-s/2,-l/2];return i.forEach((function(t){var e=Ve(u,2),n=e[0],i=e[1],a=Ve(o[t],2),c=a[0],h=a[1];u=[n+(s/2+r[0])*c,i+(l/2+r[1])*h]})),u},e.prototype.setOffsetPosition=function(t){var e=Ve(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=void 0===o?0:o,s=i.y,l=void 0===s?0:s,u=i.container,c=u.x,h=u.y;this.element.style.left="".concat(+a+c+n,"px"),this.element.style.top="".concat(+l+h+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=Ve(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=i.y,s=i.bounding,l=i.position;if(!s)return[n,r];var u=this.element,c=u.offsetWidth,h=u.offsetHeight,d=Ve([+o+n,+a+r],2),f=d[0],p=d[1],g={left:"right",right:"left",top:"bottom",bottom:"top"},v=s.x,m=s.y,y={left:f<v,right:f+c>v+s.width,top:p<m,bottom:p+h>m+s.height},b=[];l.split("-").forEach((function(t){y[t]?b.push(g[t]):b.push(t)}));var x=b.join("-");return this.getRelativeOffsetFromCursor(x)},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 VF(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}(Lz),NW=function(t){function e(n){var r=t.call(this,$F({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new Xl({})),r.label=r.background.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Ez(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=Oz(this.attributes,"label");xz(this.label).maybeAppend(".label",(function(){return ez(e)})).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=Ve(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3],a=t.width,s=t.height,l=a+o+r,u=s+n+i,c=Oz(this.attributes,"background"),h=this.style,d=h.width,f=void 0===d?0:d,p=h.height,g=void 0===p?0:p,v=h.selected;this.background.attr(Be(Be({},c),{width:Math.max(l,f),height:Math.max(u,g),fill:v?this.selectedColor:"#fff"})),this.label.attr({transform:"translate(".concat(o,", ").concat((u-s)/2,")")})},e.prototype.render=function(){this.renderLabel(),this.renderBackground()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("pointerenter",(function(){t.style.selected||t.background.attr("fill",t.hoverColor)})),this.addEventListener("pointerleave",(function(){t.style.selected||t.background.attr("fill",t.style.backgroundFill)}));var e=this;this.addEventListener("click",(function(){var n=t.style,r=n.label,i=n.value,o=n.onClick;null==o||o(i,{label:r,value:i},e)}))},e.defaultOptions={style:{value:"",label:"",cursor:"pointer"}},e}(Lz),OW=function(t){function e(n){var r,i,o=t.call(this,$F({},e.defaultOptions,n))||this;o.currentValue=null===(r=e.defaultOptions.style)||void 0===r?void 0:r.defaultValue,o.isPointerInSelect=!1,o.select=o.appendChild(new Xl({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new Xl({className:"dropdown"}));var a=o.style.defaultValue;return a&&(null===(i=o.style.options)||void 0===i?void 0:i.some((function(t){return t.value===a})))&&(o.currentValue=a),o}return je(e,t),e.prototype.setValue=function(t){this.currentValue=t,this.render()},e.prototype.getValue=function(){return this.currentValue},Object.defineProperty(e.prototype,"dropdownPadding",{get:function(){return Ez(this.style.dropdownPadding)},enumerable:!1,configurable:!0}),e.prototype.renderSelect=function(){var t,e=this,n=this.style,r=n.x,i=n.y,o=n.width,a=n.height,s=n.bordered,l=n.showDropdownIcon,u=Oz(this.attributes,"select"),c=Oz(this.attributes,"placeholder");this.select.attr(Be(Be({x:r,y:i,width:o,height:a},u),{fill:"#fff",strokeWidth:s?1:0}));var h=this.dropdownPadding;l&&xz(this.select).maybeAppend(".dropdown-icon","path").style("d","M-5,-3.5 L0,3.5 L5,-3.5").style("transform","translate(".concat(r+o-10-h[1]-h[3],", ").concat(i+a/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var d=null===(t=this.style.options)||void 0===t?void 0:t.find((function(t){return t.value===e.currentValue})),f=Be({x:r+h[3]},c);xz(this.select).selectAll(".placeholder").data(d?[]:[1]).join((function(t){return t.append("text").attr("className","placeholder").styles(f).style("y",(function(){var t=this.getBBox();return i+(a-t.height)/2}))}),(function(t){return t.styles(f)}),(function(t){return t.remove()}));var p=Oz(this.attributes,"optionLabel"),g=Be({x:r+h[3]},p);xz(this.select).selectAll(".value").data(d?[d]:[]).join((function(t){return t.append((function(t){return ez(t.label)})).attr("className","value").styles(g).style("y",(function(){var t=this.getBBox();return i+(a-t.height)/2}))}),(function(t){return t.styles(g)}),(function(t){return t.remove()}))},e.prototype.renderDropdown=function(){var t,e,n=this,r=this.style,i=r.x,o=r.y,a=r.width,s=r.height,l=r.options,u=r.onSelect,c=r.open,h=Oz(this.attributes,"dropdown"),d=Oz(this.attributes,"option"),f=this.dropdownPadding;xz(this.dropdown).maybeAppend(".dropdown-container","g").attr("className","dropdown-container").selectAll(".dropdown-item").data(l,(function(t){return t.value})).join((function(t){return t.append((function(t){return new NW({className:"dropdown-item",style:Be(Be(Be({},t),d),{width:a-f[1]-f[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==u||u(t,e,r),n.dispatchEvent(new Rs("change",{detail:{value:t,option:e,item:r}})),_F(n.dropdown)}})})})).each((function(t,e){var n,r=(null===(n=this.parentNode)||void 0===n?void 0:n.children).reduce((function(t,n,r){return r<e&&(t+=n.getBBox().height),t}),0);this.attr("transform","translate(".concat(f[3],", ").concat(f[0]+r,")"))}))}),(function(t){return t.update((function(t){return{selected:t.value===n.currentValue}}))}),(function(t){return t.remove()}));var p=null===(e=null===(t=this.dropdown.getElementsByClassName("dropdown-container"))||void 0===t?void 0:t[0])||void 0===e?void 0:e.getBBox(),g=h.spacing;this.dropdown.attr(Be({transform:"translate(".concat(i,", ").concat(o+s+g,")"),width:p.width+f[1]+f[3],height:p.height+f[0]+f[2]},h)),!c&&_F(this.dropdown)},e.prototype.render=function(){this.renderSelect(),this.renderDropdown()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("click",(function(t){t.stopPropagation()})),this.select.addEventListener("click",(function(){"visible"===t.dropdown.style.visibility?_F(t.dropdown):LF(t.dropdown)})),this.addEventListener("pointerenter",(function(){t.isPointerInSelect=!0})),this.addEventListener("pointerleave",(function(){t.isPointerInSelect=!1})),null===document||void 0===document||document.addEventListener("click",(function(){t.isPointerInSelect||_F(t.dropdown)}))},e.defaultOptions={style:{x:0,y:0,width:140,height:32,options:[],bordered:!0,defaultValue:"",selectRadius:8,selectStroke:"#d9d9d9",showDropdownIcon:!0,placeholderText:"请选择",placeholderFontSize:12,placeholderTextBaseline:"top",placeholderFill:"#c2c2c2",dropdownFill:"#fff",dropdownStroke:"#d9d9d9",dropdownRadius:8,dropdownShadowBlur:4,dropdownShadowColor:"rgba(0, 0, 0, 0.08)",dropdownPadding:8,dropdownSpacing:10,optionPadding:[8,12],optionFontSize:12,optionTextBaseline:"top",optionBackgroundFill:"#fff",optionBackgroundRadius:4,optionLabelFontSize:12,optionLabelTextBaseline:"top"}},e}(Lz),TW=function(t){function e(n){var r=t.call(this,$F({},{style:{backgroundOpacity:e.backgroundOpacities.default}},e.defaultOptions,n))||this;return r.showBackground=!0,r.background=r.appendChild(new Xl({})),r.icon=r.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"BaseIcon"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineWidth",{get:function(){return Math.log10(this.attributes.size)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return Ez(this.attributes.size/5)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"iconSize",{get:function(){var t=this.attributes.size,e=Ve(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3];return Math.max(t-Math.max(o+r,n+i),2*this.lineWidth+1)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.size,i=r/2,o=Oz(this.attributes,"background");this.background.attr(Be({x:e-i,y:n-i,width:r,height:r},o))},e.prototype.showIndicator=function(){if(this.label){var t=this.attributes.size,e=this.background.getBBox(),n=e.x,r=e.y;this.indicator.update({x:n+t/2,y:r-5,labelText:this.label,visibility:"visible"})}},e.prototype.hideIndicator=function(){this.indicator.update({visibility:"hidden"})},e.prototype.connectedCallback=function(){var e;t.prototype.connectedCallback.call(this);var n=this.attributes.size,r=this.background.getBBox(),i=r.x,o=r.y,a=null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView;a&&(this.indicator=a.appendChild(new EW({style:{x:i+n/2,y:o-n/2,visibility:"hidden",position:"top",radius:3,zIndex:100}})))},e.prototype.disconnectedCallback=function(){this.indicator.destroy()},e.prototype.render=function(){this.renderIcon(),this.showBackground&&this.renderBackground()},e.prototype.bindEvents=function(){var t=this,n=this.attributes.onClick;if(this.addEventListener("click",(function(){null==n||n(t)})),this.showBackground){var r=function(){return t.background.attr({opacity:e.backgroundOpacities.default})};this.addEventListener("pointerenter",(function(){t.background.attr({opacity:e.backgroundOpacities.hover}),t.showIndicator()})),this.addEventListener("pointerleave",(function(){r(),t.hideIndicator()})),this.addEventListener("pointerdown",(function(){t.background.attr({opacity:e.backgroundOpacities.active})})),this.addEventListener("pointerup",(function(){r()}))}},e.tag="IconBase",e.defaultOptions={style:{x:0,y:0,size:10,color:"#565758",backgroundRadius:4,backgroundFill:"#e2e2e2"}},e.backgroundOpacities={default:0,hover:.8,active:1},e}(Lz),AW=function(t,e){return void 0===e&&(e="#565758"),new Hl({style:{fill:e,d:"M ".concat(t,",").concat(t," L -").concat(t,",0 L ").concat(t,",-").concat(t," Z"),transformOrigin:"center"}})},CW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.arcPath=function(t,e,n){var r=Ve([n,n],2),i=r[0],o=r[1],a=function(r){return[t+n*Math.cos(r),e+n*Math.sin(r)]},s=Ve(a(-5/4*Math.PI),2),l=s[0],u=s[1],c=Ve(a(1/4*Math.PI),2),h=c[0],d=c[1];return"M".concat(l,",").concat(u,",A").concat(i,",").concat(o,",0,1,1,").concat(h,",").concat(d)},Object.defineProperty(e.prototype,"label",{get:function(){return"重置"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o+.5;xz(this.icon).maybeAppend(".reset","path").styles({stroke:r,lineWidth:o,d:this.arcPath(e,n,i/2-o),markerStart:AW(a,r)})},e}(TW),PW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快退"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e-o,n],[e,n+a],[e,n],[e+o,n-a],[e+o,n+a],[e,n]];xz(this.icon).maybeAppend(".backward","polygon").styles({points:s,fill:r})},e}(TW),RW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快进"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e+o,n],[e,n+a],[e,n],[e-o,n-a],[e-o,n+a],[e,n]];xz(this.icon).maybeAppend(".forward","polygon").styles({points:s,fill:r})},e}(TW),DW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"播放"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3*Math.pow(3,.5)*.8,a=[[e+o,n],[e-o/2,n-i/2*.8],[e-o/2,n+i/2*.8],[e+o,n]];xz(this.icon).maybeAppend(".play","polygon").styles({points:a,fill:r})},e}(TW),LW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"暂停"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3,a=[[e-o,n-i/2],[e-o,n+i/2],[e-o/2,n+i/2],[e-o/2,n-i/2],[e-o,n-i/2],[e+o/2,n-i/2],[e+o/2,n+i/2],[e+o,n+i/2],[e+o,n-i/2]];xz(this.icon).maybeAppend(".pause","polygon").styles({points:a,fill:r})},e}(TW),_W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"范围时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o;xz(this.icon).maybeAppend(".left-line","line").styles({x1:e-i/2,y1:n-i/2,x2:e-i/2,y2:n+i/2,stroke:r,lineWidth:o}),xz(this.icon).maybeAppend(".right-line","line").styles({x1:e+i/2,y1:n-i/2,x2:e+i/2,y2:n+i/2,stroke:r,lineWidth:o}),xz(this.icon).maybeAppend(".left-arrow","line").styles({x1:e,y1:n,x2:e-i/2+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:AW(2*o,r)}),xz(this.icon).maybeAppend(".right-arrow","line").styles({x1:e,y1:n,x2:e+i/2-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:AW(2*o,r)})},e}(TW),IW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"单一时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;xz(this.icon).maybeAppend(".line","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o});var a=o;xz(this.icon).maybeAppend(".left-arrow","line").styles({x1:e-i/2-2*a,y1:n,x2:e-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:AW(2*o,r)}),xz(this.icon).maybeAppend(".right-arrow","line").styles({x1:e+i/2+2*a,y1:n,x2:e+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:AW(2*o,r)})},e}(TW),jW=function(t){return[[-t/2,-t/2],[-t/2,t/2],[t/2,t/2]]},BW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"折线图"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=(i-2*o-o)/4,s=(i-2*o-o)/2,l=Ve([e-i/2+o,n+i/2-2*o],2),u=l[0],c=l[1];xz(this.icon).maybeAppend(".coordinate","polyline").styles({points:jW(i).map((function(t){var r=Ve(t,2),i=r[0],o=r[1];return[i+e,o+n]})),stroke:r,lineWidth:o}),xz(this.icon).maybeAppend(".line","polyline").styles({points:[[u,c],[u+a,c-s],[u+2*a,c],[u+4*a,c-2*s]],stroke:r,lineWidth:o})},e}(TW),FW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"条形图"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return[1,4,2,4,3]},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.data,e=this.attributes,n=e.x,r=e.y,i=e.color,o=this.iconSize,a=this.lineWidth,s=a,l=(o-s)/t.length,u=(o-2*s)/4,c=Ve([n-o/2+2*s,r+o/2-s],2),h=c[0],d=c[1];xz(this.icon).maybeAppend(".coordinate","polyline").styles({points:jW(o).map((function(t){var e=Ve(t,2),i=e[0],o=e[1];return[i+n,o+r]})),stroke:i,lineWidth:a}),xz(this.icon).maybeAppend(".bars","g").selectAll(".column").data(this.data.map((function(t,e){return{value:t,index:e}}))).join((function(t){return t.append("line").attr("className","column").style("x1",(function(t){var e=t.index;return h+l*e})).style("y1",d).style("x2",(function(t){var e=t.index;return h+l*e})).style("y2",(function(t){var e=t.value;return d-u*e})).styles({y1:d,stroke:i,lineWidth:a})}))},e}(TW),zW=function(t){function e(e){var n=t.call(this,$F({},{style:{color:"#d8d9d9"}},e))||this;return n.showBackground=!1,n}return je(e,t),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;xz(this.icon).maybeAppend(".split","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o})},e}(TW),GW=function(t){function e(){var e=t.apply(this,We([],Ve(arguments),!1))||this;return e.showBackground=!1,e}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Ez(0)},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.iconSize,e=this.attributes,n=e.x,r=e.y,i=e.speed,o=void 0===i?1:i,a=Pe(this.attributes,["x","y","transform","transformOrigin","width","height","size","color","speed"]),s=oe(t,20,1/0),l=Be(Be({},a),{x:n-s/2,y:r-10,width:s,height:20,defaultValue:o,bordered:!1,showDropdownIcon:!1,selectRadius:2,dropdownPadding:this.padding,dropdownRadius:2,dropdownSpacing:t/5,placeholderFontSize:t/2,optionPadding:0,optionLabelFontSize:t/2,optionBackgroundRadius:1,options:[{label:"1x",value:1},{label:"1.5x",value:1.5},{label:"2x",value:2}]});xz(this.icon).maybeAppend(".speed",(function(){return new OW({style:l})})).attr("className","speed").each((function(){this.update(l)}))},e.tag="SpeedSelect",e}(TW),VW=function(t){function e(e){var n=t.call(this,e)||this;return n.icon=n.appendChild(new jl({})),n.currentType=n.attributes.type,n}return je(e,t),e.prototype.getType=function(){return this.currentType},e.prototype.render=function(){var t=this,e=this.attributes;e.onChange;var n=Fe(e,["onChange"]);xz(this.icon).selectAll(".icon").data([this.currentType]).join((function(e){return e.append((function(e){var n,r=null===(n=t.toggles.find((function(t){return Ve(t,1)[0]===e})))||void 0===n?void 0:n[1];if(!r)throw new Error("Invalid type: ".concat(e));return new r({})})).attr("className","icon").styles(n,!1).update({})}),(function(t){return t.styles({restStyles:n}).update({})}),(function(t){return t.remove()}))},e.prototype.bindEvents=function(){var t=this,e=this.attributes.onChange;this.addEventListener("click",(function(n){n.preventDefault(),n.stopPropagation();var r=(t.toggles.findIndex((function(e){return Ve(e,1)[0]===t.currentType}))+1)%t.toggles.length,i=t.toggles[r][0];null==e||e(t.currentType),t.currentType=i,t.render()}))},e.tag="ToggleIcon",e}(Lz),WW=function(t){function e(e){var n=t.call(this,$F({},{style:{type:"play"}},e))||this;return n.toggles=[["play",DW],["pause",LW]],n}return je(e,t),e}(VW),HW=function(t){function e(e){var n=t.call(this,$F({},{style:{type:"range"}},e))||this;return n.toggles=[["range",_W],["value",IW]],n}return je(e,t),e}(VW),YW=function(t){function e(e){var n=t.call(this,$F({},{style:{type:"column"}},e))||this;return n.toggles=[["line",BW],["column",FW]],n}return je(e,t),e}(VW),UW={reset:CW,speed:GW,backward:PW,playPause:WW,forward:RW,selectionType:HW,chartType:YW,split:zW},$W=function(t){function e(n){var r=t.call(this,$F({},e.defaultOptions,n))||this;return r.background=r.appendChild(new Xl({})),r.functions=r.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Ez(this.attributes.padding)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.style,e=t.x,n=t.y,r=t.width,i=t.height,o=Oz(this.attributes,"background");this.background.attr(Be({x:e,y:n,width:r,height:i},o))},e.prototype.renderFunctions=function(){var t,e=this,n=this.attributes,r=n.functions,i=n.iconSize,o=n.iconSpacing,a=n.x,s=n.y,l=n.width,u=n.height,c=n.align,h=Ve(this.padding,4),d=h[1],f=h[3],p=r.reduce((function(t,e){return t.length&&e.length?t.concat.apply(t,We(["split"],Ve(e),!1)):t.concat.apply(t,We([],Ve(e),!1))}),[]),g=p.length*(i+o)-o,v={left:f+i/2,center:(l-g)/2+i/2,right:l-g-f-d+i/2}[c]||0;null===(t=this.speedSelect)||void 0===t||t.destroy(),this.functions.removeChildren(),p.forEach((function(t,n){var r,l=UW[t],c={x:a+n*(i+o)+v,y:s+u/2,size:i};if(l===GW?(c.speed=e.attributes.speed,c.onSelect=function(n){return e.handleFunctionChange(t,{value:n})}):[WW,HW,YW].includes(l)?(c.onChange=function(n){return e.handleFunctionChange(t,{value:n})},l===WW&&(c.type="play"===e.attributes.state?"pause":"play"),l===HW&&(c.type="range"===e.attributes.selectionType?"value":"range"),l===YW&&(c.type="line"===e.attributes.chartType?"column":"line")):c.onClick=function(){return e.handleFunctionChange(t,{value:t})},l===GW){var h=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView;h&&(e.speedSelect=new l({style:Be(Be({},c),{zIndex:100})}),h.appendChild(e.speedSelect))}else e.functions.appendChild(new l({style:c}))}))},e.prototype.disconnectedCallback=function(){var e;t.prototype.disconnectedCallback.call(this),null===(e=this.speedSelect)||void 0===e||e.destroy()},e.prototype.render=function(){this.renderBackground(),this.renderFunctions()},e.prototype.handleFunctionChange=function(t,e){var n=this.attributes.onChange;null==n||n(t,e)},e.defaultOptions={style:{x:0,y:0,width:300,height:40,padding:0,align:"center",iconSize:25,iconSpacing:0,speed:1,state:"pause",chartType:"line",selectionType:"range",backgroundFill:"#fbfdff",backgroundStroke:"#ebedf0",functions:[["reset","speed"],["backward","playPause","forward"],["selectionType","chartType"]]}},e}(Lz),qW=function(t){function e(n){var r=t.call(this,$F({},e.defaultOptions,n))||this;return r.bindEvents(),r}return je(e,t),e.prototype.bindEvents=function(){var t=this;this.addEventListener("mouseenter",(function(){t.attr("lineWidth",Math.ceil(+(t.style.r||0)/2))})),this.addEventListener("mouseleave",(function(){t.attr("lineWidth",0)}))},e.defaultOptions={style:{r:5,fill:"#3f7cf7",lineWidth:0,stroke:"#3f7cf7",strokeOpacity:.5,cursor:"pointer"}},e}(Dl),XW=function(t){function e(n){return t.call(this,$F({},e.defaultOptions,n))||this}return je(e,t),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=Oz(this.attributes,"background");xz(this).maybeAppend("background","rect").attr("className","background").styles(Be({x:e-r/2,y:n-i/2,width:r,height:i},o))},e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.iconSize,i=Oz(this.attributes,"icon"),o=r/2;xz(this).maybeAppend("icon-left-line","line").attr("className","icon-left-line").styles(Be({x1:e-1,y1:n-o,x2:e-1,y2:n+o},i)),xz(this).maybeAppend("icon-right-line","line").attr("className","icon-right-line").styles(Be({x1:e+1,y1:n-o,x2:e+1,y2:n+o},i))},e.prototype.renderBorder=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,a=Oz(this.attributes,"border"),s="start"===o?+r/2:-r/2;xz(this).maybeAppend("border","line").attr("className","border").styles(Be({x1:s+e,y1:n-i/2,x2:s+e,y2:n+i/2},a))},e.prototype.render=function(){this.renderBackground(),this.renderIcon(),this.renderBorder()},e.defaultOptions={style:{x:0,y:0,width:10,height:50,iconSize:10,type:"start",backgroundFill:"#fff",backgroundFillOpacity:.5,iconStroke:"#9a9a9a",iconLineWidth:1,borderStroke:"#e8e8e8",borderLineWidth:1}},e}(Lz);function KW(t,e){return"number"==typeof t?ZW(t):function(t,e){var n=new Date(t);switch(e){case"half-hour":case"hour":case"four-hour":return[0,6,12,18].includes(n.getHours())&&0===n.getMinutes()?Cz(n,"HH:mm\nYYYY-MM-DD"):Cz(n,"HH:mm");case"half-day":return n.getHours()<12?"AM\n".concat(Cz(n,"YYYY-MM-DD")):"PM";case"day":return[1,10,20].includes(n.getDate())?Cz(n,"DD\nYYYY-MM"):Cz(n,"DD");case"week":return n.getDate()<=7?Cz(n,"DD\nYYYY-MM"):Cz(n,"DD");case"month":return[0,6].includes(n.getMonth())?Cz(n,"MM月\nYYYY"):Cz(n,"MM月");case"season":return[0].includes(n.getMonth())?Cz(n,"MM月\nYYYY"):Cz(n,"MM月");case"year":return Cz(n,"YYYY");default:return Cz(n,"YYYY-MM-DD HH:mm")}}(t,e)}function ZW(t){var e=String(Math.floor(t/3600)).padStart(2,"0"),n=String(Math.floor(t%3600/60)).padStart(2,"0"),r=String(Math.floor(t%60)).padStart(2,"0");return t<3600?"".concat(n,":").concat(r):"".concat(e,":").concat(n,":").concat(r)}var QW=function(t){function e(n){var r=t.call(this,$F({},e.defaultOptions,n))||this;r.axis=r.appendChild(new iW({style:{type:"linear",startPos:[0,0],endPos:[0,0],data:[],showArrow:!1,animate:!1}})),r.timeline=r.appendChild(new rV({style:{onChange:function(t){r.handleSliderChange(t)}}})),r.controller=r.appendChild(new $W({})),r.states={},r.handleSliderChange=function(t){var e,n=(e=r.states.values,Array.isArray(e)?We([],Ve(e),!1):e);r.setBySliderValues(t),r.dispatchOnChange(n)};var i=r.attributes,o=i.selectionType,a=i.chartType,s=i.speed,l=i.state,u=i.playMode,c=i.values;return r.states={chartType:a,playMode:u,selectionType:o,speed:s,state:l},r.setByTimebarValues(c),r}return je(e,t),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.data.sort((function(t,e){return t.time<e.time?-1:t.time>e.time?1:0}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"space",{get:function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,a=t.controllerHeight,s=oe(+i-a,0,+i),l=new VF(e,n+ +i-a,+r,a),u=0,c="time"===o?10:s;return{axisBBox:"chart"===o?new VF(e,n+s-(u=35),+r,u):new VF,controllerBBox:l,timelineBBox:new VF(e,n+("time"===o?s:s-c),+r,c-u)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=Ve(Array.isArray(t)?t:[0,t],2),o=i[0],a=i[1],s=r.length,l=r[Math.floor(o*s)],u=r[Math.ceil(a*s)-(Array.isArray(t)?0:1)];this.states.values=[null!==(e=null==l?void 0:l.time)&&void 0!==e?e:r[0].time,null!==(n=null==u?void 0:u.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=Ve(Array.isArray(t)?t:[void 0,t],2),a=o[0],s=o[1],l=i.find((function(t){return t.time===a})),u=i.find((function(t){return t.time===s}));this.states.values=[null!==(e=null==l?void 0:l.time)&&void 0!==e?e:null===(n=i[0])||void 0===n?void 0:n.time,null!==(r=null==u?void 0:u.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,a=Ve(t,2),s=a[0],l=a[1];this.states.values=[null!==(n=null===(e=o[s])||void 0===e?void 0:e.time)&&void 0!==n?n:o[0].time,null!==(i=null===(r=this.data[l])||void 0===r?void 0:r.time)&&void 0!==i?i:1/0]},Object.defineProperty(e.prototype,"sliderValues",{get:function(){var t,e=this.states,n=e.values,r=e.selectionType,i=Ve(Array.isArray(n)?n:[void 0,n],2),o=i[0],a=i[1],s=this.data,l=s.length,u="value"===r;return[(t=s.findIndex((function(t){return t.time===o})),u?0:t>-1?t/l:0),function(){if(a===1/0)return 1;var t=s.findIndex((function(t){return t.time===a}));return t>-1?t/l:u?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=Ve(Array.isArray(e)?e:[this.data[0].time,e],2),i=r[0],o=r[1];return"value"===n?o:[i,o]},enumerable:!1,configurable:!0}),e.prototype.getDatumByRatio=function(t){var e=this.data,n=e.length;return e[Math.floor(t*(n-1))]},Object.defineProperty(e.prototype,"chartHandleIconShape",{get:function(){var t=this.states.selectionType,e=this.space.timelineBBox.height;return"range"===t?function(t){return new XW({style:{type:t,height:e,iconSize:e/6}})}:function(){return new Vl({style:{x1:0,y1:-e/2,x2:0,y2:e/2,lineWidth:2,stroke:"#c8c8c8"}})}},enumerable:!1,configurable:!0}),e.prototype.getChartStyle=function(t){var e=this,n=t.x,r=t.y,i=t.width,o=t.height,a=this.states,s=a.selectionType,l=a.chartType,u=this.data,c=this.attributes,h=c.type,d=c.labelFormatter,f=Oz(this.attributes,"chart");f.type;var p=Fe(f,["type"]),g="range"===s;if("time"===h)return Be({handleIconShape:function(){return new qW({})},selectionFill:"#2e7ff8",selectionFillOpacity:1,showLabelOnInteraction:!0,handleLabelDy:g?-15:0,autoFitLabel:g,handleSpacing:g?-15:0,trackFill:"#edeeef",trackLength:i,trackOpacity:.5,trackRadius:o/2,trackSize:o/2,type:s,values:this.sliderValues,formatter:function(t){if(d)return d(t);var n=e.getDatumByRatio(t).time;return"number"==typeof n?ZW(n):Cz(n,"YYYY-MM-DD HH:mm:ss")},transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},p);var v="range"===s?5:0,m=u.map((function(t){return t.value}));return Be({handleIconOffset:v,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:m,sparklineType:l,sparklineScale:.8,trackLength:i,trackSize:o,type:s,values:this.sliderValues,transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},p)},e.prototype.renderChart=function(t){void 0===t&&(t=this.space.timelineBBox),this.timeline.update(this.getChartStyle(t))},e.prototype.updateSelection=function(){this.timeline.setValues(this.sliderValues,!0),this.handleSliderChange(this.sliderValues)},e.prototype.getAxisStyle=function(t){var e=this.data,n=this.attributes,r=n.interval,i=n.labelFormatter,o=Oz(this.attributes,"axis"),a=t.x,s=t.y,l=t.width,u=We(We([],Ve(e),!1),[{time:0}],!1).map((function(t,e,n){var r=t.time;return{label:"".concat(r),value:e/(n.length-1),time:r}})),c=Be({startPos:[a,s],endPos:[a+l,s],data:u,labelFilter:function(t,e){return e<u.length-1},labelFormatter:function(t){var e=t.time;return i?i(e):KW(e,r)}},o);return c},e.prototype.renderAxis=function(t){void 0===t&&(t=this.space.axisBBox),"chart"===this.attributes.type&&this.axis.update(this.getAxisStyle(t))},e.prototype.renderController=function(t){void 0===t&&(t=this.space.controllerBBox);var e=this.attributes.type,n=this.states,r=n.state,i=n.speed,o=n.selectionType,a=n.chartType,s=Oz(this.attributes,"controller"),l=this,u=Be(Be(Be({},t),{iconSize:20,speed:i,state:r,selectionType:o,chartType:a,onChange:function(t,e){var n=e.value;switch(t){case"reset":l.internalReset();break;case"speed":l.handleSpeedChange(n);break;case"backward":l.internalBackward();break;case"playPause":"play"===n?l.internalPlay():l.internalPause();break;case"forward":l.internalForward();break;case"selectionType":l.handleSelectionTypeChange(n);break;case"chartType":l.handleChartTypeChange(n)}}}),s);"time"===e&&(u.functions=[["reset","speed"],["backward","playPause","forward"],["selectionType"]]),this.controller.update(u)},e.prototype.dispatchOnChange=function(t){var e=this.data,n=this.attributes.onChange,r=this.states,i=r.values,o=r.selectionType,a=Ve(i,2),s=a[0],l=a[1],u=l===1/0?e.at(-1).time:l;t&&function(t,e){if(Array.isArray(t)){if(!Array.isArray(e))return!1;if(t[0]===e[0]){if(t[1]===e[1])return!0;if(t[1]===1/0||e[1]===1/0)return!0}return!1}return!Array.isArray(e)&&t===e}(t,"range"===o?[s,u]:u)||null==n||n("range"===o?[s,u]:u)},e.prototype.internalReset=function(t){var e,n,r=this.states.selectionType;this.internalPause(),this.setBySliderValues("range"===r?[0,1]:[0,0]),this.renderController(),this.updateSelection(),t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onReset)||void 0===n||n.call(e),this.dispatchOnChange())},e.prototype.reset=function(){this.internalReset()},e.prototype.moveSelection=function(t,e){var n=this.data,r=n.length,i=this.states,o=i.values,a=i.selectionType,s=i.playMode,l=Ve(o,2),u=l[0],c=l[1],h=n.findIndex((function(t){return t.time===u})),d=n.findIndex((function(t){return t.time===c}));-1===d&&(d=r);var f,p="backward"===t?-1:1;"range"===a?"acc"===s?(f=[h,d+p],-1===p&&h===d&&(f=[h,r])):f=[h+p,d+p]:f=[h,d+p];var g=function(t){var e=Ve(t.sort((function(t,e){return t-e})),2),n=e[0],i=e[1],o=function(t){return oe(t,0,r)};return i>r?"value"===a?[0,0]:"acc"===s?[o(n),o(n)]:[0,o(i-n)]:n<0?"acc"===s?[0,o(i)]:[o(n+r-i),r]:[o(n),o(i)]}(f);return this.setByIndex(g),this.updateSelection(),g},e.prototype.internalBackward=function(t){var e,n,r=this.moveSelection("backward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onBackward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.backward=function(){this.internalBackward()},e.prototype.internalPlay=function(t){var e,n,r=this,i=this.data,o=this.attributes.loop,a=this.states.speed,s=void 0===a?1:a;this.playInterval=window.setInterval((function(){r.internalForward()[1]!==i.length||o||(r.internalPause(),r.renderController())}),1e3/s),this.states.state="play",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPlay)||void 0===n||n.call(e))},e.prototype.play=function(){this.internalPlay()},e.prototype.internalPause=function(t){var e,n;clearInterval(this.playInterval),this.states.state="pause",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPause)||void 0===n||n.call(e))},e.prototype.pause=function(){this.internalPause()},e.prototype.internalForward=function(t){var e,n,r=this.moveSelection("forward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onForward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.forward=function(){this.internalForward()},e.prototype.handleSpeedChange=function(t){var e,n;this.states.speed=t,"play"===this.states.state&&(this.internalPause(!0),this.internalPlay(!0)),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSpeedChange)||void 0===n||n.call(e,t)},e.prototype.handleSelectionTypeChange=function(t){var e,n;this.states.selectionType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSelectionTypeChange)||void 0===n||n.call(e,t)},e.prototype.handleChartTypeChange=function(t){var e,n;this.states.chartType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onChartTypeChange)||void 0===n||n.call(e,t)},e.prototype.render=function(){var t=this.space,e=t.axisBBox,n=t.controllerBBox,r=t.timelineBBox;this.renderController(n),this.renderAxis(e),this.renderChart(r),"play"===this.states.state&&this.internalPlay()},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.internalPause(!0)},e.defaultOptions={style:{x:0,y:0,axisLabelFill:"#6e6e6e",axisLabelTextAlign:"left",axisLabelTextBaseline:"top",axisLabelTransform:"translate(5, -12)",axisLineLineWidth:1,axisLineStroke:"#cacdd1",axisTickLength:15,axisTickLineWidth:1,axisTickStroke:"#cacdd1",chartShowLabel:!1,chartType:"line",controllerAlign:"center",controllerHeight:40,data:[],interval:"day",loop:!1,playMode:"acc",selectionType:"range",type:"time"}},e}(Lz);function JW(t){const{width:e,height:n,renderer:r}=t,i=function(t){var e;const{container:n,className:r,graphCanvas:i}=t;if(n)return"string"==typeof n?document.getElementById(n):n;const o=tB(r,!1),{width:a,height:s,containerStyle:l}=t,[u,c]=function(t){const{width:e,height:n,placement:r,graphCanvas:i}=t,[o,a]=i.getSize(),[s,l]=Zh(r);return[s*(o-e),l*(a-n)]}(t);return Object.assign(o.style,Object.assign({position:"absolute",left:u+"px",top:c+"px",width:a+"px",height:s+"px"},l)),null===(e=i.getContainer())||void 0===e||e.appendChild(o),o}(t);return[i,new hu({width:e,height:n,container:i,renderer:r||new kp})]}class tH extends Jj{constructor(e,n){super(e,Object.assign({},tH.defaultOptions,n)),this.typePrefix="__data__",this.draw=!1,this.fieldMap={node:new Map,edge:new Map,combo:new Map},this.selectedItems=[],this.bindEvents=()=>{const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.createElement)},this.changeState=(t,e)=>{const{graph:n}=this.context,{typePrefix:r}=this,i=Oe(t,[r,"id"]),o=Oe(t,[r,"style","labelText"]),[a]=i.split("__"),s=this.fieldMap[a].get(o)||[];n.setElementState(Object.fromEntries(null==s?void 0:s.map((t=>[t,e]))))},this.click=t=>{if("hover"===this.options.trigger)return;const e=Oe(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?(this.selectedItems=this.selectedItems.filter((t=>t!==e)),this.changeState(t,[])):(this.selectedItems.push(e),this.changeState(t,"selected"))},this.mouseleave=t=>{"click"!==this.options.trigger&&(this.selectedItems=[],this.changeState(t,[]))},this.mouseenter=t=>{if("click"===this.options.trigger)return;const e=Oe(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?this.selectedItems=this.selectedItems.filter((t=>t!==e)):(this.selectedItems.push(e),this.changeState(t,"active"))},this.setFieldMap=(t,e,n)=>{if(!t)return;const r=this.fieldMap[n];if(r)if(r.has(t)){const n=r.get(t);n&&(n.push(e),r.set(t,n))}else r.set(t,[e])},this.getEvents=()=>({mouseenter:this.mouseenter,mouseleave:this.mouseleave,click:this.click}),this.getMarkerData=(t,e)=>{if(!t)return[];const{model:n,element:r}=this.context,{nodes:i,edges:o,combos:a}=n.getData(),s={},l=e=>Yt(t)?t(e):t,u={node:"circle",edge:"line",combo:"rect"},c={circle:"circle",ellipse:"circle",image:"bowtie",rect:"square",star:"cross",triangle:"triangle",diamond:"diamond",cubic:"dot",line:"hyphen",polyline:"hyphen",quadratic:"hv","cubic-horizontal":"hyphen","cubic-vertical":"line"},h=(t,e)=>{t.forEach((t=>{const{id:n}=t,i=Oe(t,["data",l(t)]),o=(null==r?void 0:r.getElementType(e,t))||"circle",a=((t,e)=>null==r?void 0:r.getElementComputedStyle(t,e))(e,t),h=("edge"===e?null==a?void 0:a.stroke:null==a?void 0:a.fill)||"#1783ff";n&&i&&i.replace(/\s+/g,"")&&(this.setFieldMap(i,n,e),s[i]||(s[i]={id:`${e}__${n}`,label:i,marker:c[o]||u[e],elementType:e,lineWidth:1,stroke:h,fill:h}))}))};switch(e){case"node":h(i,"node");break;case"edge":h(o,"edge");break;case"combo":h(a,"combo");break;default:return[]}return Object.values(s)},this.createElement=()=>{if(this.draw)return void this.updateElement();const t=this.options,{width:e,height:n,nodeField:r,edgeField:i,comboField:o,trigger:a,position:s,container:l,containerStyle:u,className:c}=t,h=Fe(t,["width","height","nodeField","edgeField","comboField","trigger","position","container","containerStyle","className"]),d=this.getMarkerData(r,"node"),f=this.getMarkerData(i,"edge"),p=this.getMarkerData(o,"combo"),g=[...d,...p,...f],v=Object.assign({width:e,height:n,data:g,itemMarkerLineWidth:({lineWidth:t})=>t,itemMarker:({marker:t})=>t,itemMarkerStroke:({stroke:t})=>t,itemMarkerFill:({fill:t})=>t,gridCol:d.length},h,this.getEvents()),m=new yW({className:"legend",style:v});this.category=m;this.upsertCanvas().appendChild(m),this.draw=!0},this.bindEvents()}update(t){super.update(t),this.clear(),this.createElement()}clear(){var t,e;null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.container)||void 0===e||e.remove(),this.canvas=void 0,this.container=void 0,this.draw=!1}updateElement(){this.category&&this.category.update({itemMarkerOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5,itemLabelOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5})}upsertCanvas(){if(this.canvas)return this.canvas;const t=this.context.canvas,[e,n]=t.getSize(),{width:r=e,height:i=n,position:o,container:a,containerStyle:s,className:l}=this.options,[u,c]=JW({width:r,height:i,graphCanvas:t,container:a,containerStyle:s,placement:o,className:"legend"});return this.container=u,l&&u.classList.add(l),this.canvas=c,this.canvas}destroy(){this.clear(),this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.createElement),super.destroy()}}tH.defaultOptions={position:"bottom",trigger:"hover",orientation:"horizontal",layout:"flex",itemSpacing:4,rowPadding:10,colPadding:10,itemMarkerSize:16,itemLabelFontSize:16,width:240,height:160};class eH extends Jj{constructor(t,e){super(t,Object.assign({},eH.defaultOptions,e)),this.onDraw=t=>{var e;(null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.render)||this.onRender()},this.shapes=new Map,this.landmarkMap=new Map,this.mask=null,this.isMaskDragging=!1,this.onMaskDragStart=t=>{this.mask&&(this.isMaskDragging=!0,this.mask.setPointerCapture(t.pointerId),this.mask.addEventListener("pointermove",this.onMaskDrag),this.mask.addEventListener("pointerup",this.onMaskDragEnd),this.mask.addEventListener("pointercancel",this.onMaskDragEnd))},this.onMaskDrag=t=>{if(!this.mask||!this.isMaskDragging)return;const{size:[e,n]}=this.options,{movementX:r,movementY:i}=t,{left:o,top:a,width:s,height:l}=this.mask.style,[,,u,c]=this.maskBBox;let h=parseInt(o)+r,d=parseInt(a)+i,f=parseInt(s),p=parseInt(l);h<0&&(h=0),d<0&&(d=0),h+f>e&&(h=rH(e-f,0)),d+p>n&&(d=rH(n-p,0)),f<u&&(r>0?(h=rH(h-r,0),f=nH(f+r,e)):r<0&&(f=nH(f-r,e))),p<c&&(i>0?(d=rH(d-i,0),p=nH(p+i,n)):i<0&&(p=nH(p-i,n))),Object.assign(this.mask.style,{left:h+"px",top:d+"px",width:f+"px",height:p+"px"});const g=parseInt(o)-h,v=parseInt(a)-d;if(0===g&&0===v)return;const m=this.context.canvas.getCamera().getZoom()/this.canvas.getCamera().getZoom();this.context.graph.translateBy([g*m,v*m],!1)},this.onMaskDragEnd=t=>{this.mask&&(this.isMaskDragging=!1,this.mask.releasePointerCapture(t.pointerId),this.mask.removeEventListener("pointermove",this.onMaskDrag),this.mask.removeEventListener("pointerup",this.onMaskDragEnd),this.mask.removeEventListener("pointercancel",this.onMaskDragEnd))},this.onTransform=Re((()=>{this.isMaskDragging||(this.updateMask(),this.setCamera())}),32,{leading:!0}),this.setOnRender(),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),"delay"in t&&this.setOnRender(),this.bindEvents()}setOnRender(){this.onRender=ye((()=>{this.renderMinimap(),this.renderMask()}),this.options.delay,!0)}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.onDraw),e.on(t.GraphEvent.AFTER_RENDER,this.onRender),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.onDraw),e.off(t.GraphEvent.AFTER_RENDER,this.onRender),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}renderMinimap(){const t=this.getElements(),e=this.initCanvas();this.setShapes(e,t)}getElements(){const{filter:t}=this.options,{model:e}=this.context,n=e.getData();if(!t)return n;const{nodes:r,edges:i,combos:o}=n;return{nodes:r.filter((e=>t(yh(e),"node"))),edges:i.filter((e=>t(yh(e),"edge"))),combos:o.filter((e=>t(yh(e),"combo")))}}setShapes(t,e){const{nodes:n,edges:r,combos:i}=e,{shape:o}=this.options,{element:a}=this.context;if("key"===o){const e=new Set,o=n=>{const r=yh(n);e.add(r);const i=a.getElement(r);if(!i)return;const o=i.getShape("key"),s=this.shapes.get(r)||o.cloneNode();s.setPosition(o.getPosition()),i.style.zIndex&&(s.style.zIndex=i.style.zIndex),s.id=i.id,this.shapes.has(r)?Object.entries(o.attributes).forEach((([t,e])=>{s.style[t]!==e&&(s.style[t]=e)})):(t.appendChild(s),this.shapes.set(r,s))};return r.forEach(o),i.forEach(o),n.forEach(o),void this.shapes.forEach(((n,r)=>{e.has(r)||(t.removeChild(n),this.shapes.delete(r))}))}const s=(t,e)=>{const n=a.getElement(t).getPosition();return e.setPosition(n),e};t.removeChildren(),r.forEach((e=>t.appendChild(o(yh(e),"edge")))),i.forEach((e=>{t.appendChild(s(yh(e),o(yh(e),"combo")))})),n.forEach((e=>{t.appendChild(s(yh(e),o(yh(e),"node")))}))}initCanvas(){const{renderer:t,size:[e,n]}=this.options;if(this.canvas){const{width:r,height:i}=this.canvas.getConfig();e===r&&n===i||this.canvas.resize(e,n),t&&this.canvas.setRenderer(t)}else{const{className:r,position:i,container:o,containerStyle:a}=this.options,[s,l]=JW({renderer:t,width:e,height:n,placement:i,className:"minimap",container:o,containerStyle:a,graphCanvas:this.context.canvas});r&&s.classList.add(r),this.container=s,this.canvas=l}return this.setCamera(),this.canvas}createLandmark(t,e,n){const r=`${t.join(",")}-${e.join(",")}-${n}`;if(this.landmarkMap.has(r))return this.landmarkMap.get(r);const i=this.canvas.getCamera().createLandmark(r,{position:t,focalPoint:e,zoom:n});return this.landmarkMap.set(r,i),i}setCamera(){var t;const{canvas:e}=this.context,n=null===(t=this.canvas)||void 0===t?void 0:t.getCamera();if(!n)return;const{size:[r,i],padding:o}=this.options,[a,s,l,u]=Yc(o),{min:c,max:h,center:d}=e.getBounds("elements"),f=(r-u-s)/(h[0]-c[0]),p=(i-a-l)/(h[1]-c[1]),g=Math.min(f,p),v=this.createLandmark(d,d,g);n.gotoLandmark(v,0)}get maskBBox(){const{canvas:t}=this.context,e=t.getSize(),n=t.getCanvasByViewport([0,0]),r=t.getCanvasByViewport(e),i=this.canvas.canvas2Viewport(nd(n)),o=this.canvas.canvas2Viewport(nd(r)),a=o.x-i.x,s=o.y-i.y;return[i.x,i.y,a,s]}calculateMaskBBox(){const{size:[t,e]}=this.options;let[n,r,i,o]=this.maskBBox;return n<0&&(i=nH(i+n,t),n=0),r<0&&(o=nH(o+r,e),r=0),n+i>t&&(i=rH(t-n,0)),r+o>e&&(o=rH(e-r,0)),[nH(n,t),nH(r,e),rH(i,0),rH(o,0)]}renderMask(){const{maskStyle:t}=this.options;this.mask||(this.mask=document.createElement("div"),this.mask.addEventListener("pointerdown",this.onMaskDragStart)),this.container.appendChild(this.mask),Object.assign(this.mask.style,Object.assign(Object.assign({},t),{cursor:"move",position:"absolute",pointerEvents:"auto"})),this.updateMask()}updateMask(){if(!this.mask)return;const[t,e,n,r]=this.calculateMaskBBox();Object.assign(this.mask.style,{top:e+"px",left:t+"px",width:n+"px",height:r+"px"})}destroy(){var t;this.unbindEvents(),this.canvas.destroy(),null===(t=this.mask)||void 0===t||t.remove(),super.destroy()}}eH.defaultOptions={size:[240,160],shape:"key",padding:10,position:"right-bottom",maskStyle:{border:"1px solid #ddd",background:"rgba(0, 0, 0, 0.1)"},containerStyle:{border:"1px solid #ddd",background:"#fff"},delay:128};const nH=(t,e)=>Math.min(t,e),rH=(t,e)=>Math.max(t,e),iH={x1:0,y1:0,x2:0,y2:0,visibility:"hidden"};class oH extends Jj{constructor(t,e){super(t,Object.assign({},oH.defaultOptions,e)),this.initSnapline=()=>{const t=this.context.canvas.getLayer("transient");this.horizontalLine||(this.horizontalLine=t.appendChild(new Vl({style:Object.assign(Object.assign({},iH),this.options.horizontalLineStyle)}))),this.verticalLine||(this.verticalLine=t.appendChild(new Vl({style:Object.assign(Object.assign({},iH),this.options.verticalLineStyle)})))},this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!0,this.autoSnapToLine=(t,e,n)=>ze(this,void 0,void 0,(function*(){const{verticalX:r,horizontalY:i}=n,{tolerance:o}=this.options,{min:[a,s],max:[l,u],center:[c,h]}=e;let d=0,f=0;null!==r&&(aH(l,r)<o&&(d=r-l),aH(a,r)<o&&(d=r-a),aH(c,r)<o&&(d=r-c),0!==d&&(this.isVerticalSticking=!0)),null!==i&&(aH(u,i)<o&&(f=i-u),aH(s,i)<o&&(f=i-s),aH(h,i)<o&&(f=i-h),0!==f&&(this.isHorizontalSticking=!0)),0===d&&0===f||(yield this.context.graph.translateElementBy({[t]:[d,f]},!1))})),this.enableSnap=t=>{const{target:e}=t,n=.5;if(this.isHorizontalSticking||this.isVerticalSticking){const[r,i]=this.getDelta(t);if(this.isHorizontalSticking&&this.isVerticalSticking&&Math.abs(r)<=n&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,-i]},!1),!1;if(this.isHorizontalSticking&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[0,-i]},!1),!1;if(this.isVerticalSticking&&Math.abs(r)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,0]},!1),!1;this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!1,setTimeout((()=>{this.enableStick=!0}),200)}return this.enableStick},this.calcSnaplineMetadata=(t,e)=>{const{tolerance:n,shape:r}=this.options,{min:[i,o],max:[a,s],center:[l,u]}=e;let c=null,h=null,d=null,f=null,p=null,g=null;return this.getNodes().some((e=>{if(Ne(t.id,e.id))return!1;const v=sH(e,r).getRenderBounds(),{min:[m,y],max:[b,x],center:[E,w]}=v;return null===c&&(aH(E,l)<n?c=E:aH(m,i)<n||aH(m,a)<n?c=m:(aH(b,a)<n||aH(b,i)<n)&&(c=b),null!==c&&(h=Math.min(y,o),d=Math.max(x,s))),null===f&&(aH(w,u)<n?f=w:aH(y,o)<n||aH(y,s)<n?f=y:(aH(x,s)<n||aH(x,o)<n)&&(f=x),null!==f&&(p=Math.min(m,i),g=Math.max(b,a))),null!==c&&null!==f})),{verticalX:c,verticalMinY:h,verticalMaxY:d,horizontalY:f,horizontalMinX:p,horizontalMaxX:g}},this.onDragStart=()=>{this.initSnapline()},this.onDrag=t=>ze(this,void 0,void 0,(function*(){const{target:e}=t;if(this.options.autoSnap){if(!this.enableSnap(t))return}const n=sH(e,this.options.shape).getRenderBounds(),r=this.calcSnaplineMetadata(e,n);this.hideSnapline(),null===r.verticalX&&null===r.horizontalY||this.updateSnapline(r),this.options.autoSnap&&(yield this.autoSnapToLine(e.id,n,r))})),this.onDragEnd=()=>{this.hideSnapline()},this.bindEvents()}getNodes(){var t;const{filter:e}=this.options,n=((null===(t=this.context.element)||void 0===t?void 0:t.getNodes())||[]).filter((t=>{var e;return"hidden"!==Oe(t,["style","visibility"])&&(null===(e=this.context.viewport)||void 0===e?void 0:e.isInViewport(t.getRenderBounds()))}));return e?n.filter((t=>e(t))):n}hideSnapline(){this.horizontalLine.style.visibility="hidden",this.verticalLine.style.visibility="hidden"}getLineWidth(t){const{lineWidth:e}=this.options[`${t}LineStyle`];return+(e||iH.lineWidth||1)/this.context.graph.getZoom()}updateSnapline(t){const{verticalX:e,verticalMinY:n,verticalMaxY:r,horizontalY:i,horizontalMinX:o,horizontalMaxX:a}=t,[s,l]=this.context.canvas.getSize(),{offset:u}=this.options;null!==i?Object.assign(this.horizontalLine.style,{x1:u===1/0?0:o-u,y1:i,x2:u===1/0?s:a+u,y2:i,visibility:"visible",lineWidth:this.getLineWidth("horizontal")}):this.horizontalLine.style.visibility="hidden",null!==e?Object.assign(this.verticalLine.style,{x1:e,y1:u===1/0?0:n-u,x2:e,y2:u===1/0?l:r+u,visibility:"visible",lineWidth:this.getLineWidth("vertical")}):this.verticalLine.style.visibility="hidden"}getDelta(t){const e=this.context.graph.getZoom();return Fh([t.dx,t.dy],e)}bindEvents(){return ze(this,void 0,void 0,(function*(){const{graph:e}=this.context;e.on(t.NodeEvent.DRAG_START,this.onDragStart),e.on(t.NodeEvent.DRAG,this.onDrag),e.on(t.NodeEvent.DRAG_END,this.onDragEnd)}))}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.DRAG_START,this.onDragStart),e.off(t.NodeEvent.DRAG,this.onDrag),e.off(t.NodeEvent.DRAG_END,this.onDragEnd)}destroyElements(){var t,e;null===(t=this.horizontalLine)||void 0===t||t.destroy(),null===(e=this.verticalLine)||void 0===e||e.destroy()}destroy(){this.destroyElements(),this.unbindEvents(),super.destroy()}}oH.defaultOptions={tolerance:5,offset:20,autoSnap:!0,shape:"key",verticalLineStyle:{stroke:"#1783FF"},horizontalLineStyle:{stroke:"#1783FF"},filter:()=>!0};const aH=(t,e)=>Math.abs(t-e),sH=(t,e)=>"function"==typeof e?e(t):t.getShape(e),lH=["timestamp","time","date","datetime"];class uH extends Jj{get padding(){return Yc(this.options.padding)}constructor(t,e){super(t,Object.assign({},uH.defaultOptions,e)),this.backup(),this.upsertTimebar()}play(){var t;null===(t=this.timebar)||void 0===t||t.play()}pause(){var t;null===(t=this.timebar)||void 0===t||t.pause()}forward(){var t;null===(t=this.timebar)||void 0===t||t.forward()}backward(){var t;null===(t=this.timebar)||void 0===t||t.backward()}reset(){var t;null===(t=this.timebar)||void 0===t||t.reset()}update(t){super.update(t),this.backup(),this.upsertTimebar()}backup(){this.originalData=cH(this.context.graph.getData())}upsertTimebar(){const{canvas:t}=this.context,e=this.options,{onChange:n,timebarType:r,data:i,x:o,y:a,width:s,height:l,mode:u}=e,c=Fe(e,["onChange","timebarType","data","x","y","width","height","mode"]),h=t.getSize(),[d]=this.padding;this.upsertCanvas().ready.then((()=>{var t;const e=Object.assign(Object.assign({x:h[0]/2-s/2,y:d,onChange:t=>{const e=($t(t)?t:[t,t]).map((t=>function(t){return t instanceof Date}(t)?t.getTime():t));"modify"===this.options.mode?this.filterElements(e):this.hiddenElements(e),null==n||n(e)}},c),{data:i.map((t=>ae(t)?{time:t,value:0}:t)),width:s,height:l,type:r});this.timebar?this.timebar.update(e):(this.timebar=new QW({style:e}),null===(t=this.canvas)||void 0===t||t.appendChild(this.timebar))}))}upsertCanvas(){if(this.canvas)return this.canvas;const{className:t,height:e,position:n}=this.options,r=this.context.canvas,[i]=r.getSize(),[o,,a]=this.padding,[s,l]=JW({width:i,height:e+o+a,graphCanvas:r,className:"timebar",placement:n});return this.container=s,t&&s.classList.add(t),this.canvas=l,this.canvas}filterElements(t){return ze(this,void 0,void 0,(function*(){var e;if(!this.originalData)return;const{elementTypes:n,getTime:r}=this.options,{graph:i,element:o}=this.context,a=cH(this.originalData);n.forEach((e=>{const n=`${e}s`;a[n]=(this.originalData[n]||[]).filter((e=>{const n=r(e);return!!hH(n,t)}))}));const s=[...a.nodes,...a.combos].map((t=>yh(t)));a.edges=a.edges.filter((t=>{const e=t.source,n=t.target;return s.includes(e)&&s.includes(n)})),i.setData(a),yield null===(e=o.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished}))}hiddenElements(t){const{graph:e}=this.context,{elementTypes:n,getTime:r}=this.options,i=[],o=[];n.forEach((e=>{var n;const a=`${e}s`;((null===(n=this.originalData)||void 0===n?void 0:n[a])||[]).forEach((e=>{const n=yh(e),a=r(e);hH(a,t)?o.push(n):i.push(n)}))})),e.hideElement(i,!1),e.showElement(o,!1)}destroy(){var t,e,n;const{graph:r}=this.context;this.originalData&&r.setData(Object.assign({},this.originalData)),null===(t=this.timebar)||void 0===t||t.destroy(),null===(e=this.canvas)||void 0===e||e.destroy(),null===(n=this.container)||void 0===n||n.remove(),this.originalData=void 0,this.container=void 0,this.timebar=void 0,this.canvas=void 0,super.destroy()}}uH.defaultOptions={position:"bottom",enable:!0,timebarType:"time",className:"g6-timebar",width:450,height:60,zIndex:3,elementTypes:["node"],padding:10,mode:"modify",getTime:t=>dH(t,lH,void 0),loop:!1};const cH=t=>{const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e],edges:[...n],combos:[...r]}},hH=(t,e)=>{if(ae(e))return t===e;const[n,r]=e;return t>=n&&t<=r},dH=(t,e,n)=>{var r;for(let n=0;n<e.length;n++){const i=e[n],o=null===(r=t.data)||void 0===r?void 0:r[i];if(o)return o}return n};class fH extends Jj{constructor(t,e){super(t,Object.assign({},fH.defaultOptions,e)),this.$element=tB("toolbar",!1),this.onToolbarItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof Element&&t.target.className.includes("g6-toolbar-item")){const n=t.target.getAttribute("value");null==e||e(n,t.target)}};const n=this.context.canvas.getContainer();this.$element.style.display="flex",n.appendChild(this.$element),eB("g6-toolbar-css","style",{},"\n .g6-toolbar {\n position: absolute;\n z-index: 100;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);\n opacity: 0.65;\n }\n .g6-toolbar .g6-toolbar-item {\n display: inline-block;\n width: 16px;\n height: 16px;\n padding: 4px;\n cursor: pointer;\n box-sizing: content-box;\n }\n\n .g6-toolbar .g6-toolbar-item:hover {\n background-color: #f0f0f0;\n }\n\n .g6-toolbar .g6-toolbar-item svg {\n display: inline-block;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n",document.head),eB("g6-toolbar-svgicon","div",{display:"none"},'\n <svg>\n <symbol id="zoom-in" viewBox="64 64 896 896">\n <path d="M637 443H519V309c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v134H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h118v134c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V519h118c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="zoom-out" viewBox="64 64 896 896">\n <path d="M637 443H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h312c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="edit" viewBox="64 64 896 896">\n <path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>\n </symbol>\n <symbol id="delete" viewBox="64 64 896 896">\n <path d="M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"></path>\n </symbol>\n <symbol id="redo" viewBox="64 64 896 896">\n <path d="M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 00-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z"></path>\n </symbol>\n <symbol id="undo" viewBox="64 64 896 896">\n <path d="M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z"></path>\n </symbol>\n <symbol id="export" viewBox="64 64 896 896">\n <path d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"></path>\n </symbol>\n <symbol id="auto-fit" viewBox="64 64 896 896">\n <path d="M952 474H829.8C812.5 327.6 696.4 211.5 550 194.2V72c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v122.2C327.6 211.5 211.5 327.6 194.2 474H72c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h122.2C211.5 696.4 327.6 812.5 474 829.8V952c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V829.8C696.4 812.5 812.5 696.4 829.8 550H952c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM512 756c-134.8 0-244-109.2-244-244s109.2-244 244-244 244 109.2 244 244-109.2 244-244 244z"></path>\n <path d="M512 392c-32.1 0-62.1 12.4-84.8 35.2-22.7 22.7-35.2 52.7-35.2 84.8s12.5 62.1 35.2 84.8C449.9 619.4 480 632 512 632s62.1-12.5 84.8-35.2C619.4 574.1 632 544 632 512s-12.5-62.1-35.2-84.8A118.57 118.57 0 00512 392z"></path>\n </symbol>\n <symbol id="reset" viewBox="64 64 896 896">\n <path d="M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"></path>\n </symbol>\n <symbol id="exit-fullscreen" viewBox="0 0 1024 1024">\n <path d="M418.13333333 361.43786666c0 0.2048-0.13653333 0.4096-0.13653334 0.68266667C417.99679999 362.32533333 418.13333333 362.53013333 418.13333333 362.73493333 418.13333333 371.54133333 414.44693333 379.392 408.78079999 385.39946666 408.43946666 385.7408 408.30293333 386.21866666 408.02986666 386.49173333c-1.09226667 1.09226667-2.59413333 1.77493333-3.82293333 2.73066667C398.40426666 393.65973333 391.64586666 396.8 383.93173333 396.8 383.72693333 396.8 383.59039999 396.73173333 383.38559999 396.73173333S382.97599999 396.8 382.77119999 396.8L112.29866666 396.8C92.50133333 396.8 76.79999999 381.50826666 76.79999999 362.66666666 76.66346666 343.89333333 92.63786666 328.53333333 112.16213333 328.53333333l189.44 0L87.44959999 114.51733333C73.59146666 100.59093333 73.25013333 78.5408 86.63039999 65.29706666c13.17546667-13.44853333 35.36213333-12.97066667 49.152 0.88746667l214.08426667 214.08426667L349.86666666 90.89706666C349.79839999 71.23626666 365.22666666 55.46666666 383.99999999 55.46666666 402.77333333 55.33013333 418.13333333 71.30453333 418.13333333 90.8288L418.13333333 361.43786666zM928.90453333 328.53333333l-189.44 0 214.15253333-214.08426667c13.85813333-13.9264 14.19946667-35.90826667 0.88746667-49.22026666-13.17546667-13.44853333-35.36213333-12.97066667-49.152 0.88746666l-214.08426667 214.08426667L691.26826666 90.89706666C691.26826666 71.23626666 675.83999999 55.46666666 657.06666666 55.46666666 638.29333333 55.33013333 622.93333333 71.30453333 622.93333333 90.8288l0 270.60906666c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 362.32533333 622.93333333 362.53013333 622.93333333 362.73493333 622.93333333 371.54133333 626.61973333 379.392 632.28586666 385.39946666c0.34133333 0.34133333 0.47786667 0.8192 0.8192 1.09226667 1.09226667 1.09226667 2.59413333 1.77493333 3.8912 2.73066667C642.66239999 393.65973333 649.42079999 396.8 657.13493333 396.8c0.2048 0 0.34133333-0.06826667 0.54613333-0.06826667S658.09066666 396.8 658.29546666 396.8l270.5408 0C948.56533333 396.8 964.26666666 381.50826666 964.26666666 362.66666666 964.40319999 343.89333333 948.42879999 328.53333333 928.90453333 328.53333333zM418.13333333 635.73333333c0-8.8064-3.6864-16.5888-9.35253334-22.66453333C408.43946666 612.72746666 408.30293333 612.2496 408.02986666 611.90826666 406.86933333 610.88426666 405.43573333 610.2016 404.20693333 609.24586666 398.47253333 604.80853333 391.64586666 601.6 383.93173333 601.6 383.72693333 601.6 383.59039999 601.73653333 383.38559999 601.73653333S382.97599999 601.6 382.77119999 601.6L112.29866666 601.6C92.50133333 601.6 76.79999999 616.96 76.79999999 635.73333333 76.66346666 654.50666666 92.63786666 669.86666666 112.16213333 669.86666666l189.44 0-214.15253334 214.15253334c-13.85813333 13.85813333-14.19946667 35.84-0.88746666 49.22026666 13.17546667 13.44853333 35.36213333 12.9024 49.152-0.95573333l214.08426666-214.08426667 0 189.37173334c0 19.59253333 15.42826667 35.49866667 34.2016 35.36213333C402.77333333 943.2064 418.13333333 927.232 418.13333333 907.5712L418.13333333 637.09866666c0-0.27306667-0.13653333-0.47786667-0.13653334-0.68266666C417.99679999 636.14293333 418.13333333 635.93813333 418.13333333 635.73333333zM739.46453333 669.86666666l189.44 0c19.456 0 35.49866667-15.36 35.36213333-34.13333333C964.26666666 616.96 948.56533333 601.6 928.76799999 601.6L658.29546666 601.6C658.09066666 601.6 657.88586666 601.73653333 657.68106666 601.73653333S657.33973333 601.6 657.13493333 601.6C649.42079999 601.6 642.59413333 604.80853333 636.85973333 609.24586666 635.63093333 610.2016 634.19733333 610.88426666 633.03679999 611.90826666 632.76373333 612.2496 632.62719999 612.72746666 632.28586666 613.0688 626.61973333 619.14453333 622.93333333 626.92693333 622.93333333 635.73333333c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 636.6208 622.93333333 636.8256 622.93333333 637.09866666l0 270.5408C622.93333333 927.232 638.29333333 943.2064 657.06666666 942.93333333c18.77333333 0.13653333 34.2016-15.70133333 34.2016-35.36213333l0-189.37173334 214.08426667 214.08426667c13.78986667 13.85813333 35.90826667 14.40426667 49.152 0.95573333 13.312-13.312 12.97066667-35.36213333-0.88746667-49.22026666L739.46453333 669.86666666z" ></path></symbol>\n <symbol id="request-fullscreen" viewBox="0 0 1024 1024">\n <path d="M69.818182 87.598545v273.128728a34.909091 34.909091 0 0 0 69.818182 0V163.653818l221.928727 222.021818a33.512727 33.512727 0 0 0 47.383273-47.383272L186.926545 116.363636h197.073455a34.909091 34.909091 0 0 0 0-69.818181H110.871273C85.364364 46.545455 69.818182 59.671273 69.818182 87.598545zM938.542545 46.545455H665.413818a34.909091 34.909091 0 0 0 0 69.818181h197.073455L640.465455 338.292364a33.512727 33.512727 0 0 0 47.383272 47.383272l221.928728-222.021818v197.073455a34.909091 34.909091 0 0 0 69.818181 0V87.598545c0-27.927273-15.453091-41.053091-40.96-41.05309z m-827.671272 907.636363h273.128727a34.909091 34.909091 0 0 0 0-69.818182H186.926545l222.021819-221.928727a33.512727 33.512727 0 0 0-47.383273-47.383273L139.636364 837.073455V640a34.909091 34.909091 0 0 0-69.818182 0v273.128727c0 27.927273 15.546182 41.053091 41.053091 41.053091z m868.724363-41.053091V640a34.909091 34.909091 0 0 0-69.818181 0v197.073455L687.941818 615.051636a33.512727 33.512727 0 0 0-47.383273 47.383273L862.487273 884.363636H665.413818a34.909091 34.909091 0 0 0 0 69.818182h273.128727c25.6 0 41.053091-13.125818 41.053091-41.053091z" ></path></symbol>\n </svg>\n'),this.$element.addEventListener("click",this.onToolbarItemClick),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(this,void 0,void 0,(function*(){e.update.call(this,t);const{className:n,position:r,style:i}=this.options;this.$element.className=`g6-toolbar ${n||""}`,Object.assign(this.$element.style,i,function(t){const e={top:"unset",right:"unset",bottom:"unset",left:"unset"};return t.split("-").forEach((t=>{e[t]="8px"})),e.flexDirection=t.startsWith("top")||t.startsWith("bottom")?"row":"column",e}(r)),this.$element.innerHTML=yield this.getDOMContent()}))}destroy(){this.$element.removeEventListener("click",this.onToolbarItemClick),this.$element.remove(),super.destroy()}getDOMContent(){return ze(this,void 0,void 0,(function*(){return(yield this.options.getItems()).map((t=>`\n <div class="g6-toolbar-item" value="${t.value}">\n <svg aria-hidden="true" focusable="false">\n <use xlink:href="#${t.id}"></use>\n </svg>\n </div>`)).join("")}))}}fH.defaultOptions={position:"top-left"};class pH extends Jj{constructor(t,e){super(t,Object.assign({},pH.defaultOptions,e)),this.currentTarget=null,this.tooltipElement=null,this.container=null,this.isEnable=(t,e)=>{const{enable:n}=this.options;return"function"==typeof n?n(t,e):n},this.onClick=t=>{const{target:{id:e}}=t;this.currentTarget===e?this.hide(t):this.show(t)},this.onPointerMove=t=>{const{target:e}=t;this.currentTarget&&e.id!==this.currentTarget&&this.show(t)},this.onPointerLeave=t=>{this.hide(t)},this.onCanvasMove=t=>{this.hide(t)},this.onPointerEnter=t=>{this.show(t)},this.showById=t=>ze(this,void 0,void 0,(function*(){const e={target:{id:t}};yield this.show(e)})),this.getElementData=(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[]}},this.show=t=>ze(this,void 0,void 0,(function*(){var e,n;const{client:r,target:{id:i}}=t;if(Lg(t.target))return;const o=this.context.graph.getElementType(i),{getContent:a,title:s}=this.options,l=this.getElementData(i,o);if(!this.tooltipElement||!this.isEnable(t,l))return;let u,c,h={};if(a){if(h.content=yield a(t,l),!h.content)return}else{const t=this.context.graph.getElementRenderStyle(i),e="node"===o?t.fill:t.stroke;h={title:s||o,data:l.map((t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:e})))}}if(this.currentTarget=i,r)u=r.x,c=r.y;else{const t=Oe(l,"0.style",{x:0,y:0});u=t.x,c=t.y}null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!0),this.tooltipElement.update(Object.assign(Object.assign(Object.assign({},this.tooltipStyleProps),{x:u,y:c,style:{".tooltip":{visibility:"visible"}}}),h))})),this.hide=t=>{var e,n,r,i,o;if(!t)return null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!1),null===(r=this.tooltipElement)||void 0===r||r.hide(),void(this.currentTarget=null);if(!this.tooltipElement)return;if(!this.currentTarget)return;const{client:{x:a,y:s}}=t;null===(o=(i=this.options).onOpenChange)||void 0===o||o.call(i,!1),this.tooltipElement.hide(a,s),this.currentTarget=null},this.initTooltip=()=>{var t;const e=new SW({className:"tooltip",style:this.tooltipStyleProps});return null===(t=this.container)||void 0===t||t.appendChild(e.HTMLTooltipElement),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,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){var e;this.unbindEvents(),super.update(t),this.tooltipElement&&(null===(e=this.container)||void 0===e||e.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())}unbindEvents(){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])}))}get tooltipStyleProps(){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:l={x:-i,y:-r},title:u,offset:c}=this.options,[h,d]=e,[f,p]=t.getSize();return{x:h,y:d,container:l,title:u,bounding:{x:0,y:0,width:f,height:p},position:a,enterable:s,offset:c,style:o}}destroy(){var t;this.unbindEvents(),this.tooltipElement&&(null===(t=this.container)||void 0===t||t.removeChild(this.tooltipElement.HTMLTooltipElement)),super.destroy()}}let gH;function vH(t,e){gH||(gH=document.createElement("canvas")),gH.width=t,gH.height=e;return gH.getContext("2d").clearRect(0,0,t,e),gH}pH.defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};class mH extends Jj{constructor(t,e){super(t,Object.assign({},mH.defaultOptions,e)),this.$element=tB("watermark");this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(this,void 0,void 0,(function*(){e.update.call(this,t);const n=this.options,{width:r,height:i,text:o,imageURL:a}=n,s=Fe(n,["width","height","text","imageURL"]);Object.keys(s).forEach((e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])}));const l=a?yield function(t,e,n,r){return ze(this,void 0,void 0,(function*(){const i=vH(t,e),o=i.getContext("2d"),{rotate:a,opacity:s}=r;a&&o.rotate(a),s&&(o.globalAlpha=s);const l=new Image;return l.crossOrigin="anonymous",l.src=n,new Promise((n=>{l.onload=function(){const r=t>l.width?(t-l.width)/2:0,a=e>l.height?(e-l.height)/2:0;o.drawImage(l,0,0,l.width,l.height,r,a,t-2*r,e-2*a),n(i.toDataURL())}}))}))}(r,i,a,s):yield function(t,e,n,r){return ze(this,void 0,void 0,(function*(){const i=vH(t,e),o=i.getContext("2d"),{rotate:a,opacity:s,textFill:l,textFontSize:u,textFontFamily:c,textFontVariant:h,textFontWeight:d,textAlign:f,textBaseline:p}=r;return o.textAlign=f,o.textBaseline=p,o.translate(t/2,e/2),o.font=`${u}px ${c} ${h} ${d}`,a&&o.rotate(a),s&&(o.globalAlpha=s),l&&(o.fillStyle=l,o.fillText(`${n}`,0,0)),i.toDataURL()}))}(r,i,o,s);this.$element.style.backgroundImage=`url(${l})`}))}destroy(){super.destroy(),this.$element.remove()}}mH.defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};const yH=["#7E92B5","#F4664A","#FFBE3A"],bH={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},xH={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function EH(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeHaloStrokeOpacityActive:a=.15,nodeHaloStrokeOpacitySelected:s=.25,nodeOpacityDisabled:l=.06,nodeIconOpacityInactive:u=.85,nodeOpacityInactive:c=.25,nodeBadgePalette:h=yH,nodePaletteOptions:d=bH,edgeColor:f,edgeColorDisabled:p,edgePaletteOptions:g=xH,comboColor:v,comboColorDisabled:m,comboStroke:y,comboStrokeDisabled:b,edgeColorInactive:x}=t;return{background:e,node:{palette:d,style:{donutOpacity:1,badgeBackgroundOpacity:1,badgeFill:"#fff",badgeFontSize:8,badgePadding:[0,4],badgePalette:h,fill:r,fillOpacity:1,halo:!1,iconFill:"#fff",iconOpacity:1,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelFill:n,labelFillOpacity:.85,labelLineHeight:16,labelPadding:[0,2],labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelOffsetY:2,lineWidth:0,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65,size:32,stroke:o,strokeOpacity:1,zIndex:2},state:{selected:{halo:!0,haloLineWidth:24,haloStrokeOpacity:s,labelFontSize:12,labelFontWeight:"bold",lineWidth:4,stroke:o},active:{halo:!0,haloLineWidth:12,haloStrokeOpacity:a},highlight:{labelFontWeight:"bold",lineWidth:4,stroke:o,strokeOpacity:.85},inactive:{badgeBackgroundOpacity:c,donutOpacity:c,fillOpacity:c,iconOpacity:u,labelFill:n,labelFillOpacity:c,strokeOpacity:c},disabled:{badgeBackgroundOpacity:.25,donutOpacity:l,fill:i,fillOpacity:l,iconFill:i,iconOpacity:.25,labelFill:n,labelFillOpacity:.25,strokeOpacity:l}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"node-expand",collapse:"node-collapse",update:[{fields:["x","y","fill","stroke"]}],translate:[{fields:["x","y"]}]}},edge:{palette:g,style:{badgeBackgroundFill:f,badgeFill:"#fff",badgeFontSize:8,badgeOffsetX:10,fillOpacity:1,halo:!1,haloLineWidth:12,haloStrokeOpacity:1,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1,stroke:f,strokeOpacity:1,zIndex:1},state:{selected:{halo:!0,haloStrokeOpacity:.25,labelFontSize:14,labelFontWeight:"bold",lineWidth:3},active:{halo:!0,haloStrokeOpacity:.15},highlight:{labelFontWeight:"bold",lineWidth:3},inactive:{stroke:x,fillOpacity:.08,labelOpacity:.25,strokeOpacity:.08,badgeBackgroundOpacity:.25},disabled:{stroke:p,fillOpacity:.45,strokeOpacity:.45,labelOpacity:.25,badgeBackgroundOpacity:.45}},animation:{enter:"fade",exit:"fade",expand:"path-in",collapse:"path-out",show:"fade",hide:"fade",update:[{fields:["sourceNode","targetNode"]},{fields:["stroke"],shape:"key"}],translate:[{fields:["sourceNode","targetNode"]}]}},combo:{style:{collapsedMarkerFill:e,collapsedMarkerFontSize:12,collapsedMarkerFillOpacity:1,collapsedSize:32,collapsedFillOpacity:1,fill:v,halo:!1,haloLineWidth:12,haloStroke:y,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineDash:0,lineWidth:1,fillOpacity:.04,strokeOpacity:1,padding:10,stroke:y},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{fillOpacity:.65,labelOpacity:.25,strokeOpacity:.65},disabled:{fill:m,fillOpacity:.25,labelOpacity:.25,stroke:b,strokeOpacity:.25}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"combo-expand",collapse:"combo-collapse",update:[{fields:["x","y"]},{fields:["fill","stroke","lineWidth"],shape:"key"}],translate:[{fields:["x","y"]}]}}}}const wH=EH({bgColor:"#000000",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696",edgeColor:"#637088",edgeColorDisabled:"#637088",edgeColorInactive:"#D0E4FF",edgePaletteOptions:{type:"group",color:["#637088","#0F55A6","#008383","#9C5D38","#8B53A6","#4E40A6","#8F6608","#3E801D","#A65383","#175E75","#0F8248"]},nodeColor:"#1783ff",nodeColorDisabled:"#D0E4FF",nodeHaloStrokeOpacityActive:.25,nodeHaloStrokeOpacitySelected:.45,nodeIconOpacityInactive:.45,nodeOpacityDisabled:.25,nodeOpacityInactive:.45,nodeStroke:"#d0e4ff",textColor:"#ffffff"}),kH=EH({bgColor:"#ffffff",comboColor:"#99ADD1",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",edgeColorInactive:"#1B324F",nodeColor:"#1783ff",nodeColorDisabled:"#1B324F",nodeHaloStrokeOpacityActive:.15,nodeHaloStrokeOpacitySelected:.25,nodeIconOpacityInactive:.85,nodeOpacityDisabled:.06,nodeOpacityInactive:.25,nodeStroke:"#000000",textColor:"#000000"});class MH extends Rh{beforeDraw(t,e){return t}afterLayout(t,e){}}function SH(t,e,n,r,i){const o=yh(r),a=`${n}s`,s=i?r:t.add[a].get(o)||t.update[a].get(o)||t.remove[a].get(o)||r;Object.entries(t).forEach((([t,n])=>{e===t?n[a].set(o,s):n[a].delete(o)}))}function NH(t,e){return Object.keys(t).every((n=>t[n]===e[n]))}const OH=(t,e,n,r)=>{const i=`${n}s`,o=yh(r);t.add[i].has(o)||t.update[i].has(o)||t[e][i].set(yh(r),r)};const TH=new WeakMap;const AH=(t,e,n=2)=>{if("object"!=typeof t||"object"!=typeof e)return t===e;const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const i of r){const r=t[i],o=e[i];if(n>1&&"object"==typeof r&&"object"==typeof o){if(!AH(r,o,n-1))return!1}else if(r!==o)return!1}return!0};function CH(t,e,n,r=!1){const i=Mc[t][e];!r&&i?i!==n&&Tc(`The extension ${e} of ${t} has been registered before.`):Object.assign(Mc[t],{[e]:n})}
71
+ */const Oj=Symbol("Comlink.proxy"),Tj=Symbol("Comlink.endpoint"),Aj=Symbol("Comlink.releaseProxy"),Cj=Symbol("Comlink.finalizer"),Pj=Symbol("Comlink.thrown"),Rj=t=>"object"==typeof t&&null!==t||"function"==typeof t,Dj=new Map([["proxy",{canHandle:t=>Rj(t)&&t[Oj],serialize(t){const{port1:e,port2:n}=new MessageChannel;return Lj(t,e),[n,[n]]},deserialize:t=>(t.start(),Ij(t))}],["throw",{canHandle:t=>Rj(t)&&Pj 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 Lj(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),l=(i.data.argumentList||[]).map(Yj);let u;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":u=n;break;case"SET":e[s.slice(-1)[0]]=Yj(i.data.value),u=!0;break;case"APPLY":u=n.apply(e,l);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[Oj]:!0})}(new n(...l));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;Lj(t,n),u=function(t,e){return Wj.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[Pj]:0}}Promise.resolve(u).catch((t=>({value:t,[Pj]:0}))).then((n=>{const[i,s]=Hj(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),_j(e),Cj in t&&"function"==typeof t[Cj]&&t[Cj]())})).catch((t=>{const[n,r]=Hj({value:new TypeError("Unserializable return value"),[Pj]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function _j(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function Ij(t,e){const n=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const r=n.get(e.id);if(r)try{r(e)}finally{n.delete(e.id)}})),Gj(t,n,[],e)}function jj(t){if(t)throw new Error("Proxy has been released and is not useable")}function Bj(t){return Uj(t,new Map,{type:"RELEASE"}).then((()=>{_j(t)}))}const Fj=new WeakMap,zj="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Fj.get(t)||0)-1;Fj.set(t,e),0===e&&Bj(t)}));function Gj(t,e,n=[],r=function(){}){let i=!1;const o=new Proxy(r,{get(r,a){if(jj(i),a===Aj)return()=>{!function(t){zj&&zj.unregister(t)}(o),Bj(t),e.clear(),i=!0};if("then"===a){if(0===n.length)return{then:()=>o};const r=Uj(t,e,{type:"GET",path:n.map((t=>t.toString()))}).then(Yj);return r.then.bind(r)}return Gj(t,e,[...n,a])},set(r,o,a){jj(i);const[s,l]=Hj(a);return Uj(t,e,{type:"SET",path:[...n,o].map((t=>t.toString())),value:s},l).then(Yj)},apply(r,o,a){jj(i);const s=n[n.length-1];if(s===Tj)return Uj(t,e,{type:"ENDPOINT"}).then(Yj);if("bind"===s)return Gj(t,e,n.slice(0,-1));const[l,u]=Vj(a);return Uj(t,e,{type:"APPLY",path:n.map((t=>t.toString())),argumentList:l},u).then(Yj)},construct(r,o){jj(i);const[a,s]=Vj(o);return Uj(t,e,{type:"CONSTRUCT",path:n.map((t=>t.toString())),argumentList:a},s).then(Yj)}});return function(t,e){const n=(Fj.get(e)||0)+1;Fj.set(e,n),zj&&zj.register(t,e,t)}(o,t),o}function Vj(t){const e=t.map(Hj);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const Wj=new WeakMap;function Hj(t){for(const[e,n]of Dj)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},Wj.get(t)||[]]}function Yj(t){switch(t.type){case"HANDLER":return Dj.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Uj(t,e,n,r){return new Promise((i=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(o,i),t.start&&t.start(),t.postMessage(Object.assign({id:o},n),r)}))}class $j extends zg{constructor(t,e,n){super(),this.graph=t,this.layout=e,this.options=n,this.spawnWorker()}spawnWorker(){this.proxy=Ij(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())}execute(){var t;return ze(this,void 0,void 0,(function*(){if(this.running)return this;this.running=!0;const e=Fe(this.layout.options,["onTick"]),n={};Object.keys(e).forEach((t=>{Yt(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]),[o]=yield this.proxy.calculateLayout(r,[i]);return o}))}stop(){return this.running=!1,this.proxy.stopLayout(),this}kill(){this.proxy[Aj]()}isRunning(){return this.running}}class qj extends Ug{constructor(){super(...arguments),this.id="fishbone"}getRoot(){const t=this.context.model.getRootsData();if(!(Se(t)||t.length>2))return t[0]}formatSize(t){const e="function"==typeof t?t:()=>t;return t=>Pd(e(t))}doLayout(t,e){const{hGap:n,getRibSep:r,vGap:i,nodeSize:o,height:a}=e,{model:s}=this.context,l=this.formatSize(o);let u=l(t)[0]+r(t);const c=(t,e=0)=>{var r;return e+=n*((t.children||[]).length+1),null===(r=t.children)||void 0===r||r.forEach((t=>{var n;null===(n=s.getNodeLikeDatum(t).children)||void 0===n||n.forEach((t=>{const n=s.getNodeLikeDatum(t);e=c(n,e)}))})),e},h=t=>{if(1===t.depth)return u;const e=s.getParentData(t.id,"tree");if(Zj(t)){const r=s.getParentData(e.id,"tree"),o=p(t)-p(r);return h(e)+o*n/i}{const n=(e.children||[]).indexOf(t.id),r=s.getNodeData((e.children||[]).slice(n));return d(e)-r.reduce(((t,e)=>t+c(e)),0)-l(e)[0]/2}},d=xe((t=>{if(Kj(t))return l(t)[0]/2;const e=s.getParentData(t.id,"tree");if(Zj(t))return h(t)+c(t)+l(t)[0]/2;{const r=p(t)-p(e),o=n/i;return h(t)+r*o}}),(t=>t.id)),f=t=>p(s.getParentData(t,"tree")),p=xe((t=>{if(Kj(t))return a/2;if(Zj(t)){const e=s.getParentData(t.id,"tree"),n=e.children.indexOf(t.id);if(0===n)return f(e.id)+i;const r=s.getNodeLikeDatum(e.children[n-1]);if(Se(r.children))return p(r)+i;const o=s.getDescendantsData(r.id);return Math.max(...o.map((t=>Zj(t)?f(t.id):p(t))))+i}{if(Se(t.children))return f(t.id)+i;const e=s.getNodeLikeDatum(t.children.slice(-1)[0]);if(Se(e.children))return p(e)+i;const n=s.getDescendantsData(t.id).slice(-1)[0];return(Zj(n)?f(n.id):p(n))+i}}),(t=>t.id));let g=0;const v={nodes:[],edges:[]},m=t=>{var e;null===(e=t.children)||void 0===e||e.forEach((t=>m(s.getNodeLikeDatum(t))));const n=p(t),i=d(t);if(v.nodes.push({id:t.id,x:i,y:n}),Kj(t))return;const o=s.getRelatedEdgesData(t.id,"in")[0],a=[h(t),Zj(t)?n:f(t.id)];v.edges.push({id:yh(o),controlPoints:[a],relatedNodeId:t.id}),g=Math.max(g,i+r(t)),1===t.depth&&(u=g)};return m(t),v}placeAlterative(t,e){const n=(e.children||[]).filter(((t,e)=>e%2!=0));if(0===n.length)return t;const{model:r}=this.context,i=t.nodes.find((t=>t.id===e.id)).y,o=t=>{const e=r.getAncestorsData(t,"tree");if(Se(e))return!1;const i=1===e.length?t:e[e.length-2].id;return n.includes(i)};t.nodes.forEach((t=>{o(t.id)&&(t.y=2*i-t.y)})),t.edges.forEach((t=>{o(t.relatedNodeId)&&(t.controlPoints=t.controlPoints.map((t=>[t[0],2*i-t[1]])))}))}rightToLeft(t,e){return t.nodes.forEach((t=>t.x=e.width-t.x)),t.edges.forEach((t=>{t.controlPoints=t.controlPoints.map((t=>[e.width-t[0],t[1]]))})),t}execute(t,e){return ze(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign(Object.assign({},qj.defaultOptions),this.options),e),{direction:r,nodeSize:i}=n,o=this.getRoot();if(!o)return t;const a=this.formatSize(i);n.vGap||(n.vGap=Math.max(...(t.nodes||[]).map((t=>a(t)[1])))),n.hGap||(n.hGap=Math.max(...(t.nodes||[]).map((t=>a(t)[0]))));let s=this.doLayout(o,n);this.placeAlterative(s,o),"RL"===r&&(s=this.rightToLeft(s,n));const{model:l}=this.context,u=[],c=[];return s.nodes.forEach((t=>{const{id:e,x:n,y:r}=t,i=l.getNodeLikeDatum(e);u.push(Xj(i,{x:n,y:r}))})),s.edges.forEach((t=>{const{id:e,controlPoints:n}=t,r=l.getEdgeDatum(e);c.push(Xj(r,{controlPoints:n}))})),{nodes:u,edges:c}}))}}qj.defaultOptions={direction:"RL",getRibSep:()=>60};const Xj=(t,e)=>Object.assign(Object.assign({},t),{style:Object.assign(Object.assign({},t.style||{}),e)}),Kj=t=>0===t.depth,Zj=t=>(t.depth||(t.depth=0))%2==0;class Qj extends Ug{constructor(){super(...arguments),this.id="snake"}formatSize(t,e){const n="function"==typeof e?e:()=>e;return t.reduce(((t,e)=>{const[r,i]=Pd(n(e))||[0,0];return[Math.max(t[0],r),Math.max(t[1],i)]}),[0,0])}validate(t){const{nodes:e=[],edges:n=[]}=t,r={},i={},o={};e.forEach((t=>{r[t.id]=0,i[t.id]=0,o[t.id]=[]})),n.forEach((t=>{r[t.target]++,i[t.source]++,o[t.source].push(t.target)}));const a=new Set,s=t=>{a.has(t)||(a.add(t),o[t].forEach(s))};if(s(e[0].id),a.size!==e.length)return!1;const l=e.filter((t=>0===r[t.id])),u=e.filter((t=>0===i[t.id]));if(1!==l.length||1!==u.length)return!1;return e.filter((t=>1===r[t.id]&&1===i[t.id])).length===e.length-2}execute(t,e){return ze(this,void 0,void 0,(function*(){var n;if(!this.validate(t))return t;const{nodeSize:r,padding:i,sortBy:o,cols:a,colGap:s,rowGap:l,clockwise:u,width:c,height:h}=Object.assign({},Qj.defaultOptions,this.options,e),[d,f,p,g]=Yc(i),v=this.formatSize(t.nodes||[],r),m=Math.ceil((t.nodes||[]).length/a);let y=s||(c-g-f-a*v[0])/(a-1),b=l||(h-d-p-m*v[1])/(m-1);(b===1/0||b<0)&&(b=0),(y===1/0||y<0)&&(y=0);const x=o?null===(n=t.nodes)||void 0===n?void 0:n.sort(o):function(t){const{nodes:e=[],edges:n=[]}=t,r={},i={};e.forEach((t=>{r[t.id]=0,i[t.id]=[]})),n.forEach((t=>{r[t.target]++,i[t.source].push(t.target)}));const o=[],a=[];e.forEach((t=>{0===r[t.id]&&o.push(t.id)}));for(;o.length>0;){const t=o.shift(),n=e.find((e=>e.id===t));a.push(n),i[t].forEach((t=>{r[t]--,0===r[t]&&o.push(t)}))}return a}(t),E=(x||[]).map(((t,e)=>{const n=Math.floor(e/a),r=e%a,i=g+(u?n%2==0?r:a-1-r:n%2==0?a-1-r:r)*(v[0]+y)+v[0]/2,o=d+n*(v[1]+b)+v[1]/2;return{id:t.id,style:{x:i,y:o}}}));return{nodes:E}}))}}Qj.defaultOptions={padding:0,cols:5,clockwise:!0};class Jj extends Rh{}function tB(t,e=!0,n){const r=document.createElement("div");return r.setAttribute("class",`g6-${t}`),Object.assign(r.style,{position:"absolute",display:"block"}),e&&Object.assign(r.style,{position:"unset",gridArea:"1 / 1 / 2 / 2",inset:"0px",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none"}),n&&Object.assign(r.style,n),r}function eB(t,e="div",n={},r="",i=document.body){const o=document.getElementById(t);o&&o.remove();const a=document.createElement(e);return a.innerHTML=r,a.id=t,Object.assign(a.style,n),i.appendChild(a),a}class nB extends Jj{constructor(t,e){super(t,Object.assign({},nB.defaultOptions,e)),this.$element=tB("background");this.context.canvas.getContainer().prepend(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(this,void 0,void 0,(function*(){e.update.call(this,t),Object.assign(this.$element.style,Pe(this.options,["key","type"]))}))}destroy(){super.destroy(),this.$element.remove()}}function rB(t,e,n,r,i,o){const a=n-t,s=r-e;let l=i-t,u=o-e,c=l*a+u*s,h=0;c<=0?h=0:(l=a-l,u=s-u,c=l*a+u*s,h=c<=0?0:c*c/(a*a+s*s));const d=l*l+u*u-h;return d<0?0:d}function iB(t,e,n,r){return(t-n)*(t-n)+(e-r)*(e-r)}function oB(t,e,n,r,i){return iB(t,e,n,r)<i*i}function aB(t){const e=Math.min(t.x1,t.x2),n=Math.max(t.x1,t.x2),r=Math.min(t.y1,t.y2),i=Math.max(t.y1,t.y2);return{x:e,y:r,x2:n,y2:i,width:n-e,height:i-r}}nB.defaultOptions={transition:"background 0.5s",backgroundSize:"cover",zIndex:"-1"};class sB{constructor(t,e,n,r){this.x1=t,this.y1=e,this.x2=n,this.y2=r}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}draw(t){t.moveTo(this.x1,this.y1),t.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(t){return new sB(t.x1,t.y1,t.x2,t.y2)}cuts(t,e){if(this.y1===this.y2)return!1;if(e<this.y1&&e<=this.y2||e>this.y1&&e>=this.y2)return!1;if(t>this.x1&&t>=this.x2)return!1;if(t<this.x1&&t<=this.x2)return!0;return t<=this.x1+(e-this.y1)*(this.x2-this.x1)/(this.y2-this.y1)}distSquare(t,e){return rB(this.x1,this.y1,this.x2,this.y2,t,e)}ptClose(t,e,n){if(this.x1<this.x2){if(t<this.x1-n||t>this.x2+n)return!1}else if(t<this.x2-n||t>this.x1+n)return!1;if(this.y1<this.y2){if(e<this.y1-n||e>this.y2+n)return!1}else if(e<this.y2-n||e>this.y1+n)return!1;return!0}}var lB,uB;!function(t){t[t.POINT=1]="POINT",t[t.PARALLEL=2]="PARALLEL",t[t.COINCIDENT=3]="COINCIDENT",t[t.NONE=4]="NONE"}(lB||(lB={}));class cB{constructor(t,e=0,n=0){this.state=t,this.x=e,this.y=n}}function hB(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const e=n/i,o=r/i;return 0<=e&&e<=1&&0<=o&&o<=1?new cB(lB.POINT,t.x1+e*(t.x2-t.x1),t.y1+e*(t.y2-t.y1)):new cB(lB.NONE)}return new cB(0===n||0===r?lB.COINCIDENT:lB.PARALLEL)}function dB(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const t=n/i,e=r/i;if(0<=t&&t<=1&&0<=e&&e<=1)return t}return Number.POSITIVE_INFINITY}function fB(t,e,n){const r=new Set;return t.width<=0?(r.add(uB.LEFT),r.add(uB.RIGHT)):e<t.x?r.add(uB.LEFT):e>t.x+t.width&&r.add(uB.RIGHT),t.height<=0?(r.add(uB.TOP),r.add(uB.BOTTOM)):n<t.y?r.add(uB.TOP):n>t.y+t.height&&r.add(uB.BOTTOM),r}function pB(t,e){let n=e.x1,r=e.y1;const i=e.x2,o=e.y2,a=Array.from(fB(t,i,o));if(0===a.length)return!0;let s=fB(t,n,r);for(;0!==s.size;){for(const t of a)if(s.has(t))return!1;if(s.has(uB.RIGHT)||s.has(uB.LEFT)){let e=t.x;s.has(uB.RIGHT)&&(e+=t.width),r+=(e-n)*(o-r)/(i-n),n=e}else{let e=t.y;s.has(uB.BOTTOM)&&(e+=t.height),n+=(e-r)*(i-n)/(o-r),r=e}s=fB(t,n,r)}return!0}function gB(t,e){let n=Number.POSITIVE_INFINITY,r=0;function i(t,i,o,a){let s=dB(e,new sB(t,i,o,a));s=Math.abs(s-.5),s>=0&&s<=1&&(r++,s<n&&(n=s))}return i(t.x,t.y,t.x2,t.y),i(t.x,t.y,t.x,t.y2),r>1?n:(i(t.x,t.y2,t.x2,t.y2),r>1?n:(i(t.x2,t.y,t.x2,t.y2),0===r?-1:n))}function vB(t,e){let n=0;const r=hB(t,new sB(e.x,e.y,e.x2,e.y));n+=r.state===lB.POINT?1:0;const i=hB(t,new sB(e.x,e.y,e.x,e.y2));n+=i.state===lB.POINT?1:0;const o=hB(t,new sB(e.x,e.y2,e.x2,e.y2));n+=o.state===lB.POINT?1:0;const a=hB(t,new sB(e.x2,e.y,e.x2,e.y2));return n+=a.state===lB.POINT?1:0,{top:r,left:i,bottom:o,right:a,count:n}}!function(t){t[t.LEFT=0]="LEFT",t[t.TOP=1]="TOP",t[t.RIGHT=2]="RIGHT",t[t.BOTTOM=3]="BOTTOM"}(uB||(uB={}));class mB{constructor(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(t){return new mB(t.x,t.y,t.width,t.height)}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}clone(){return new mB(this.x,this.y,this.width,this.height)}add(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x+t.width),i=Math.max(this.y2,t.y+t.height);this.x=e,this.y=n,this.width=r-e,this.height=i-n}addPoint(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x),i=Math.max(this.y2,t.y);this.x=e,this.y=n,this.width=r-e,this.height=i-n}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(t){t.rect(this.x,this.y,this.width,this.height)}containsPt(t,e){return t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}get area(){return this.width*this.height}intersects(t){return!(this.area<=0||t.width<=0||t.height<=0)&&(t.x+t.width>this.x&&t.y+t.height>this.y&&t.x<this.x2&&t.y<this.y2)}distSquare(t,e){if(this.containsPt(t,e))return 0;const n=fB(this,t,e);return n.has(uB.TOP)?n.has(uB.LEFT)?iB(t,e,this.x,this.y):n.has(uB.RIGHT)?iB(t,e,this.x2,this.y):(this.y-e)*(this.y-e):n.has(uB.BOTTOM)?n.has(uB.LEFT)?iB(t,e,this.x,this.y2):n.has(uB.RIGHT)?iB(t,e,this.x2,this.y2):(e-this.y2)*(e-this.y2):n.has(uB.LEFT)?(this.x-t)*(this.x-t):n.has(uB.RIGHT)?(t-this.x2)*(t-this.x2):0}}class yB{constructor(t,e,n){this.cx=t,this.cy=e,this.radius=n}get x(){return this.cx-this.radius}get x2(){return this.cx+this.radius}get width(){return 2*this.radius}get y(){return this.cy-this.radius}get y2(){return this.cy+this.radius}get height(){return 2*this.radius}static from(t){return new yB(t.cx,t.cy,t.radius)}containsPt(t,e){return iB(this.cx,this.cy,t,e)<this.radius*this.radius}distSquare(t,e){const n=iB(this.cx,this.cy,t,e);if(n<this.radius*this.radius)return 0;const r=Math.sqrt(n)-this.radius;return r*r}draw(t){t.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,2*Math.PI)}}class bB{constructor(t,e=0,n=0,r=0,i=0,o=10,a=10,s=new Float32Array(Math.max(0,o*a)).fill(0)){this.pixelGroup=t,this.i=e,this.j=n,this.pixelX=r,this.pixelY=i,this.width=o,this.height=a,this.area=s}createSub(t,e){return new bB(this.pixelGroup,t.x,t.y,e.x,e.y,t.width,t.height)}static fromPixelRegion(t,e){return new bB(e,0,0,t.x,t.y,Math.ceil(t.width/e),Math.ceil(t.height/e))}copy(t,e){return new bB(this.pixelGroup,this.scaleX(e.x),this.scaleY(e.y),e.x,e.y,t.width,t.height,t.area)}boundX(t){return t<this.i?this.i:t>=this.width?this.width-1:t}boundY(t){return t<this.j?this.j:t>=this.height?this.height-1:t}scaleX(t){return this.boundX(Math.floor((t-this.pixelX)/this.pixelGroup))}scaleY(t){return this.boundY(Math.floor((t-this.pixelY)/this.pixelGroup))}scale(t){const e=this.scaleX(t.x),n=this.scaleY(t.y),r=this.boundX(Math.ceil((t.x+t.width-this.pixelX)/this.pixelGroup)),i=this.boundY(Math.ceil((t.y+t.height-this.pixelY)/this.pixelGroup));return new mB(e,n,r-e,i-n)}invertScaleX(t){return Math.round(t*this.pixelGroup+this.pixelX)}invertScaleY(t){return Math.round(t*this.pixelGroup+this.pixelY)}addPadding(t,e){const n=Math.ceil(e/this.pixelGroup),r=this.boundX(t.x-n),i=this.boundY(t.y-n),o=this.boundX(t.x2+n),a=this.boundY(t.y2+n);return new mB(r,i,o-r,a-i)}get(t,e){return t<0||e<0||t>=this.width||e>=this.height?Number.NaN:this.area[t+e*this.width]}inc(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]+=n)}set(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]=n)}incArea(t,e){if(t.width<=0||t.height<=0||0===e)return;const n=this.width,r=t.width,i=Math.max(0,t.i),o=Math.max(0,t.j),a=Math.min(t.i+t.width,n),s=Math.min(t.j+t.height,this.height);if(!(s<=0||a<=0||i>=n||s>=this.height))for(let l=o;l<s;l++){const o=(l-t.j)*r,s=l*n;for(let n=i;n<a;n++){const r=t.area[n-t.i+o];0!==r&&(this.area[n+s]+=e*r)}}}fill(t){this.area.fill(t)}fillArea(t,e){const n=t.x+t.y*this.width;for(let r=0;r<t.height;r++){const i=n+r*this.width;this.area.fill(e,i,i+t.width)}}fillHorizontalLine(t,e,n,r){const i=t+e*this.width;this.area.fill(r,i,i+n)}fillVerticalLine(t,e,n,r){const i=t+e*this.width;for(let t=0;t<n;t++)this.area[i+t*this.width]=r}clear(){this.area.fill(0)}toString(){let t="";for(let e=0;e<this.height;e++){const n=e*this.width;for(let e=0;e<this.width;e++){t+=this.area[n+e].toFixed(1).padStart(6),t+=" "}t+="\n"}return t}draw(t,e=!0){if(this.width<=0||this.height<=0)return;t.save(),e&&t.translate(this.pixelX,this.pixelY);const n=this.area.reduce(((t,e)=>Math.min(t,e)),Number.POSITIVE_INFINITY),r=this.area.reduce(((t,e)=>Math.max(t,e)),Number.NEGATIVE_INFINITY),i=t=>(t-n)/(r-n);t.scale(this.pixelGroup,this.pixelGroup);for(let e=0;e<this.width;e++)for(let n=0;n<this.height;n++){const r=this.area[e+n*this.width];t.fillStyle=`rgba(0, 0, 0, ${i(r)})`,t.fillRect(e,n,1,1)}t.restore()}drawThreshold(t,e,n=!0){if(!(this.width<=0||this.height<=0)){t.save(),n&&t.translate(this.pixelX,this.pixelY),t.scale(this.pixelGroup,this.pixelGroup);for(let n=0;n<this.width;n++)for(let r=0;r<this.height;r++){const i=this.area[n+r*this.width];t.fillStyle=i>e?"black":"white",t.fillRect(n,r,1,1)}t.restore()}}}function xB(t,e){const n=t=>({x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e});return Array.isArray(t)?t.map(n):n(t)}function EB(t,e,n){return wB(Object.assign(aB(t),{distSquare:(e,n)=>rB(t.x1,t.y1,t.x2,t.y2,e,n)}),e,n)}function wB(t,e,n){const r=xB(t,n),i=e.scale(r),o=e.createSub(i,r);return function(t,e,n,r){const i=n*n;for(let o=0;o<t.height;o++)for(let a=0;a<t.width;a++){const s=r(e.invertScaleX(t.i+a),e.invertScaleY(t.j+o));if(0!==s){if(s<i){const e=n-Math.sqrt(s);t.set(a,o,e*e)}}else t.set(a,o,i)}}(o,e,n,((e,n)=>t.distSquare(e,n))),o}function kB(t,e){return{x:t,y:e}}function MB(t,e,n,r){if(0===t.length)return[];const i=function(t){if(t.length<2)return t;let e=0,n=0;return t.forEach((t=>{e+=t.cx,n+=t.cy})),e/=t.length,n/=t.length,t.map((t=>{const r=e-t.cx,i=n-t.cy;return[t,r*r+i*i]})).sort(((t,e)=>t[1]-e[1])).map((t=>t[0]))}(t);return i.map(((t,o)=>{const a=i.slice(0,o);return function(t,e,n,r,i){const o=kB(e.cx,e.cy),a=function(t,e,n){let r=Number.POSITIVE_INFINITY;return e.reduce(((e,i)=>{const o=iB(t.x,t.y,i.cx,i.cy);if(o>r)return e;const a=new sB(t.x,t.y,i.cx,i.cy),s=function(t,e){return t.reduce(((t,n)=>pB(n,e)&&function(t,e){function n(t,n,r,i){let o=dB(e,new sB(t,n,r,i));return o=Math.abs(o-.5),o>=0&&o<=1?1:0}let r=n(t.x,t.y,t.x2,t.y);return r+=n(t.x,t.y,t.x,t.y2),r>1||(r+=n(t.x,t.y2,t.x2,t.y2),r>1||(r+=n(t.x2,t.y,t.x2,t.y2),r>0))}(n,e)?t+1:t),0)}(n,a);return o*(s+1)*(s+1)<r&&(e=i,r=o*(s+1)*(s+1)),e}),null)}(o,n,t);if(null==a)return[];const s=function(t,e,n,r){const i=[],o=[];o.push(t);let a=!0;for(let t=0;t<n&&a;t++)for(a=!1;!a&&o.length>0;){const t=o.pop(),n=OB(e,t),s=n?vB(t,n):null;if(!n||!s||2!==s.count){a||i.push(t);continue}let l=r,u=TB(n,l,s,!0),c=NB(u,o)||NB(u,i),h=SB(u,e);for(;!c&&h&&l>=1;)l/=1.5,u=TB(n,l,s,!0),c=NB(u,o)||NB(u,i),h=SB(u,e);if(!u||c||h||(o.push(new sB(t.x1,t.y1,u.x,u.y)),o.push(new sB(u.x,u.y,t.x2,t.y2)),a=!0),a)continue;l=r,u=TB(n,l,s,!1);let d=NB(u,o)||NB(u,i);for(h=SB(u,e);!d&&h&&l>=1;)l/=1.5,u=TB(n,l,s,!1),d=NB(u,o)||NB(u,i),h=SB(u,e);u&&!d&&(o.push(new sB(t.x1,t.y1,u.x,u.y)),o.push(new sB(u.x,u.y,t.x2,t.y2)),a=!0),a||i.push(t)}for(;o.length>0;)i.push(o.pop());return i}(new sB(o.x,o.y,a.cx,a.cy),t,r,i);return function(t,e){const n=[];for(;t.length>0;){const r=t.pop();if(0===t.length){n.push(r);break}const i=t.pop(),o=new sB(r.x1,r.y1,i.x2,i.y2);OB(e,o)?(n.push(r),t.push(i)):t.push(o)}return n}(s,t)}(e,t,a,n,r)})).flat()}function SB(t,e){return e.some((e=>e.containsPt(t.x,t.y)))}function NB(t,e){return e.some((e=>!!oB(e.x1,e.y1,t.x,t.y,.001)||!!oB(e.x2,e.y2,t.x,t.y,.001)))}function OB(t,e){let n=Number.POSITIVE_INFINITY,r=null;for(const i of t){if(!pB(i,e))continue;const t=gB(i,e);t>=0&&t<n&&(r=i,n=t)}return r}function TB(t,e,n,r){const i=n.top,o=n.left,a=n.bottom,s=n.right;if(r){if(o.state===lB.POINT){if(i.state===lB.POINT)return kB(t.x-e,t.y-e);if(a.state===lB.POINT)return kB(t.x-e,t.y2+e);const n=t.width*t.height;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?kB(t.x-e,t.y-e):kB(t.x2+e,t.y-e):o.y<s.y?kB(t.x-e,t.y2+e):kB(t.x2+e,t.y2+e)}if(s.state===lB.POINT){if(i.state===lB.POINT)return kB(t.x2+e,t.y-e);if(a.state===lB.POINT)return kB(t.x2+e,t.y2+e)}const n=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*n?i.x>a.x?kB(t.x-e,t.y-e):kB(t.x-e,t.y2+e):i.x<a.x?kB(t.x2+e,t.y-e):kB(t.x2+e,t.y2+e)}if(o.state===lB.POINT){if(i.state===lB.POINT)return kB(t.x2+e,t.y2+e);if(a.state===lB.POINT)return kB(t.x2+e,t.y-e);const n=t.height*t.width;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?kB(t.x2+e,t.y2+e):kB(t.x-e,t.y2+e):o.y<s.y?kB(t.x2+e,t.y-e):kB(t.x-e,t.y-e)}if(s.state===lB.POINT){if(i.state===lB.POINT)return kB(t.x-e,t.y2+e);if(a.state===lB.POINT)return kB(t.x-e,t.y-e)}const l=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*l?i.x>a.x?kB(t.x2+e,t.y2+e):kB(t.x2+e,t.y-e):i.x<a.x?kB(t.x-e,t.y2+e):kB(t.x-e,t.y-e)}function AB(t,e,n,r){if(!(t.closed?n<t.length:n<t.length-1))return!1;const i=t.get(e),o=t.get(n+1);for(let a=e+1;a<=n;a++){const e=t.get(a);if(rB(i.x,i.y,o.x,o.y,e.x,e.y)>r)return!1}return!0}function CB(t,e){switch(t){case-2:return(((3-e)*e-3)*e+1)/6;case-1:return((3*e-6)*e*e+4)/6;case 0:return(((-3*e+3)*e+3)*e+1)/6;case 1:return e*e*e/6;default:throw new Error("unknown error")}}class PB{constructor(t=[],e=!0){this.points=t,this.closed=e}get(t){const e=t,n=this.points.length;return t<0?this.closed?this.get(t+n):this.points[0]:t>=n?this.closed?this.get(t-n):this.points[n-1]:this.points[e]}get length(){return this.points.length}toString(t=1/0){const e=this.points;if(0===e.length)return"";const n="function"==typeof t?t:function(t){if(!Number.isFinite(t))return t=>t;if(0===t)return Math.round;const e=Math.pow(10,t);return t=>Math.round(t*e)/e}(t);let r="M";for(const t of e)r+=`${n(t.x)},${n(t.y)} L`;return r=r.slice(0,-1),this.closed&&(r+=" Z"),r}draw(t){const e=this.points;if(0!==e.length){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(const n of e)t.lineTo(n.x,n.y);this.closed&&t.closePath()}}sample(t){return function(t=8){return e=>{let n=t,r=e.length;if(n>1)for(r=Math.floor(e.length/n);r<3&&n>1;)n-=1,r=Math.floor(e.length/n);const i=[];for(let t=0,o=0;o<r;o++,t+=n)i.push(e.get(t));return new PB(i)}}(t)(this)}simplify(t){return function(t=0){return e=>{if(t<0||e.length<3)return e;const n=[];let r=0;const i=t*t;for(;r<e.length;){let t=r+1;for(;AB(e,r,t,i);)t++;n.push(e.get(r)),r=t}return new PB(n)}}(t)(this)}bSplines(t){return function(t=6){function e(t,e,n){let r=0,i=0;for(let o=-2;o<=1;o++){const a=t.get(e+o),s=CB(o,n);r+=s*a.x,i+=s*a.y}return{x:r,y:i}}return n=>{if(n.length<3)return n;const r=[],i=n.closed,o=n.length+3-1+(i?0:2);r.push(e(n,2-(i?0:2),0));for(let a=2-(i?0:2);a<o;a++)for(let i=1;i<=t;i++)r.push(e(n,a,i/t));return new PB(r)}}(t)(this)}apply(t){return t(this)}containsElements(t){const e=function(t){if(0===t.length)return null;const e=t[0],n=new mB(e.x,e.y,0,0);for(const e of t)n.addPoint(e);return n}(this.points);return!!e&&t.every((t=>e.containsPt(t.cx,t.cy)&&this.withinArea(t.cx,t.cy)))}withinArea(t,e){if(0===this.length)return!1;let n=0;const r=this.points[0],i=new sB(r.x,r.y,r.x,r.y);for(let r=1;r<this.points.length;r++){const o=this.points[r];i.x1=i.x2,i.y1=i.y2,i.x2=o.x,i.y2=o.y,i.cuts(t,e)&&n++}return i.x1=i.x2,i.y1=i.y2,i.x2=r.x,i.y2=r.y,i.cuts(t,e)&&n++,n%2==1}}class RB{constructor(t=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=t}add(t){this.set.add(`${t.x}x${t.y}`),this.arr[this.count++]=t}contains(t){return this.set.has(`${t.x}x${t.y}`)}isFirst(t){if(0===this.count)return!1;const e=this.arr[0];return null!=e&&e.x===t.x&&e.y===t.y}path(){return new PB(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(t){return this.arr[t]}get length(){return this.count}}function DB(t,e){const n=2*(Math.floor(t.width)+Math.floor(t.height)),r=new RB(n);function i(n,r,i,o){const a=t.get(n,r);return Number.isNaN(a)?Number.NaN:a>e?i+o:i}function o(t,e){let n=0;return n=i(t,e,n,1),n=i(t+1,e,n,2),n=i(t,e+1,n,4),n=i(t+1,e+1,n,8),Number.isNaN(n)?-1:n}let a=1;function s(e,n){let i=e,s=n,l=t.invertScaleX(i),u=t.invertScaleY(s);for(let e=0;e<t.width*t.height;e++){const e={x:l,y:u};if(r.contains(e)){if(r.isFirst(e))return!0}else r.add(e);const n=o(i,s);switch(n){case-1:return!0;case 0:case 3:case 2:case 7:a=2;break;case 12:case 14:case 4:a=3;break;case 6:a=0===a?3:2;break;case 1:case 13:case 5:a=0;break;case 9:a=2===a?0:1;break;case 10:case 8:case 11:a=1;break;default:return console.warn("Marching squares invalid state: "+n),!0}switch(a){case 0:s--,u-=t.pixelGroup;break;case 1:s++,u+=t.pixelGroup;break;case 3:i--,l-=t.pixelGroup;break;case 2:i++,l+=t.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+n),!0}}return!0}for(let n=0;n<t.width;n++)for(let i=0;i<t.height;i++){if(t.get(n,i)<=e)continue;const a=o(n,i);if(!(a<0||15===a)&&s(n,i))return r.path()}return null}const LB={maxRoutingIterations:100,maxMarchingIterations:20,pixelGroup:4,edgeR0:10,edgeR1:20,nodeR0:15,nodeR1:50,morphBuffer:10,threshold:1,memberInfluenceFactor:1,edgeInfluenceFactor:1,nonMemberInfluenceFactor:-.8,virtualEdges:!0};function _B(t){return null!=t&&"number"==typeof t.radius}function IB(t,e){if(_B(t)!==_B(e))return!1;if(_B(t)){const n=e;return t.cx===n.cx&&t.cy===n.cy&&t.radius===n.radius}const n=e;return t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height}var jB;!function(t){t[t.MEMBERS=0]="MEMBERS",t[t.NON_MEMBERS=1]="NON_MEMBERS",t[t.EDGES=2]="EDGES"}(jB||(jB={}));let BB=class{constructor(t={}){this.dirty=new Set,this.members=[],this.nonMembers=[],this.virtualEdges=[],this.edges=[],this.activeRegion=new mB(0,0,0,0),this.potentialArea=new bB(1,0,0,0,0,0,0),this.o=Object.assign({},LB,t)}pushMember(...t){if(0!==t.length){this.dirty.add(jB.MEMBERS);for(const e of t)this.members.push({raw:e,obj:_B(e)?yB.from(e):mB.from(e),area:null})}}removeMember(t){const e=this.members.findIndex((e=>IB(e.raw,t)));return!(e<0)&&(this.members.splice(e,1),this.dirty.add(jB.MEMBERS),!0)}removeNonMember(t){const e=this.nonMembers.findIndex((e=>IB(e.raw,t)));return!(e<0)&&(this.nonMembers.splice(e,1),this.dirty.add(jB.NON_MEMBERS),!0)}removeEdge(t){const e=this.edges.findIndex((e=>e.obj.equals(t)));return!(e<0)&&(this.edges.splice(e,1),this.dirty.add(jB.NON_MEMBERS),!0)}pushNonMember(...t){if(0!==t.length){this.dirty.add(jB.NON_MEMBERS);for(const e of t)this.nonMembers.push({raw:e,obj:_B(e)?yB.from(e):mB.from(e),area:null})}}pushEdge(...t){if(0!==t.length){this.dirty.add(jB.EDGES);for(const e of t)this.edges.push({raw:e,obj:sB.from(e),area:null})}}update(){const t=this.dirty.has(jB.MEMBERS),e=this.dirty.has(jB.NON_MEMBERS);let n=this.dirty.has(jB.EDGES);this.dirty.clear();const r=this.members.map((t=>t.obj));if(this.o.virtualEdges&&(t||e)){const t=MB(r,this.nonMembers.map((t=>t.obj)),this.o.maxRoutingIterations,this.o.morphBuffer),e=new Map(this.virtualEdges.map((t=>[t.obj.toString(),t.area])));this.virtualEdges=t.map((t=>{var n;return{raw:t,obj:t,area:null!==(n=e.get(t.toString()))&&void 0!==n?n:null}})),n=!0}let i=!1;if(t||n){const t=function(t,e){if(0===t.length)return new mB(0,0,0,0);const n=mB.from(t[0]);for(const e of t)n.add(e);for(const t of e)n.add(aB(t));return n}(r,this.virtualEdges.concat(this.edges).map((t=>t.obj))),e=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,n=mB.from(xB(t,e));n.equals(this.activeRegion)||(i=!0,this.activeRegion=n)}if(i){const t=Math.ceil(this.activeRegion.width/this.o.pixelGroup),e=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=bB.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach((t=>t.area=null)),this.nonMembers.forEach((t=>t.area=null)),this.edges.forEach((t=>t.area=null)),this.virtualEdges.forEach((t=>t.area=null))):t===this.potentialArea.width&&e===this.potentialArea.height||(this.potentialArea=bB.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}const o=new Map,a=t=>{if(t.area){const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof mB?"R":"C"}`;o.set(e,t.area)}},s=t=>{if(t.area)return;const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof mB?"R":"C"}`;if(o.has(e)){const n=o.get(e);return void(t.area=this.potentialArea.copy(n,{x:t.obj.x-this.o.nodeR1,y:t.obj.y-this.o.nodeR1}))}const n=t.obj instanceof mB?function(t,e,n){const r=e.scale(t),i=e.addPadding(r,n),o=e.createSub(i,{x:t.x-n,y:t.y-n}),a=r.x-i.x,s=r.y-i.y,l=i.x2-r.x2,u=i.y2-r.y2,c=i.width-a-l,h=i.height-s-u,d=n*n;o.fillArea({x:a,y:s,width:c+1,height:h+1},d);const f=[0],p=Math.max(s,a,l,u);{const i=e.invertScaleX(r.x+r.width/2);for(let o=1;o<p;o++){const a=e.invertScaleY(r.y-o),s=t.distSquare(i,a);if(!(s<d))break;{const t=n-Math.sqrt(s);f.push(t*t)}}}const g=[],v=Math.max(a,l),m=Math.max(s,l);for(let i=1;i<v;i++){const o=e.invertScaleX(r.x-i),a=[];for(let i=1;i<m;i++){const s=e.invertScaleY(r.y-i),l=t.distSquare(o,s);if(l<d){const t=n-Math.sqrt(l);a.push(t*t)}else a.push(0)}g.push(a)}for(let t=1;t<Math.min(s,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s-t,c+1,e)}for(let t=1;t<Math.min(u,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s+h+t,c+1,e)}for(let t=1;t<Math.min(a,f.length);t++){const e=f[t];o.fillVerticalLine(a-t,s,h+1,e)}for(let t=1;t<Math.min(u,f.length);t++){const e=f[t];o.fillVerticalLine(a+c+t,s,h+1,e)}for(let t=1;t<a;t++){const e=g[t-1],n=a-t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<u;t++)o.set(n,s+h+t,e[t-1])}for(let t=1;t<l;t++){const e=g[t-1],n=a+c+t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<u;t++)o.set(n,s+h+t,e[t-1])}return o}(t.obj,this.potentialArea,this.o.nodeR1):wB(t.obj,this.potentialArea,this.o.nodeR1);t.area=n,o.set(e,n)};this.members.forEach(a),this.nonMembers.forEach(a),this.members.forEach(s),this.nonMembers.forEach((t=>{this.activeRegion.intersects(t.obj)?s(t):t.area=null})),this.edges.forEach((t=>{t.area||(t.area=EB(t.obj,this.potentialArea,this.o.edgeR1))})),this.virtualEdges.forEach((t=>{t.area||(t.area=EB(t.obj,this.potentialArea,this.o.edgeR1))}))}drawMembers(t){for(const e of this.members)e.obj.draw(t)}drawNonMembers(t){for(const e of this.nonMembers)e.obj.draw(t)}drawEdges(t){for(const e of this.edges)e.obj.draw(t)}drawPotentialArea(t,e=!0){this.potentialArea.draw(t,e)}compute(){if(0===this.members.length)return new PB([]);this.dirty.size>0&&this.update();const{o:t,potentialArea:e}=this,n=this.members.map((t=>t.area)),r=this.virtualEdges.concat(this.edges).map((t=>t.area)),i=this.nonMembers.filter((t=>null!=t.area)).map((t=>t.area)),o=this.members.map((t=>t.obj));return function(t,e,n,r,i,o={}){const a=Object.assign({},LB,o);let s=a.threshold,l=a.memberInfluenceFactor,u=a.edgeInfluenceFactor,c=a.nonMemberInfluenceFactor;const h=(a.nodeR0-a.nodeR1)*(a.nodeR0-a.nodeR1),d=(a.edgeR0-a.edgeR1)*(a.edgeR0-a.edgeR1);for(let o=0;o<a.maxMarchingIterations;o++){if(t.clear(),0!==l){const n=l/h;for(const r of e)t.incArea(r,n)}if(0!==u){const e=u/d;for(const r of n)t.incArea(r,e)}if(0!==c){const e=c/h;for(const n of r)t.incArea(n,e)}const f=DB(t,s);if(f&&i(f))return f;if(s*=.95,o<=.5*a.maxMarchingIterations)l*=1.2,u*=1.2;else{if(!(0!==c&&r.length>0))break;c*=.8}}return new PB([])}(e,n,r,i,(t=>t.containsElements(o)),t)}};class FB extends Jj{constructor(t,e){super(t,ke({},FB.defaultOptions,e)),this.members=new Map,this.avoidMembers=new Map,this.bubbleSetOptions={},this.drawBubbleSets=()=>{const{style:t,bubbleSetOptions:e}=this.parseOptions();Ne(this.bubbleSetOptions,e)||this.init(),this.bubbleSetOptions=Object.assign({},e);const n=Object.assign(Object.assign({},t),{d:this.getPath()});this.shape?this.shape.update(n):(this.shape=new Ud({style:n}),this.context.canvas.appendChild(this.shape))},this.updateBubbleSetsPath=t=>{if(!this.shape)return;const e=yh(t.data);[...this.options.members,...this.options.avoidMembers].includes(e)&&this.shape.update(Object.assign(Object.assign({},this.parseOptions().style),{d:this.getPath(e)}))},this.getPath=t=>{const{graph:e}=this.context,n=this.options.members,r=[...this.members.keys()],i=this.options.avoidMembers,o=[...this.avoidMembers.keys()];if(!t&&Ne(n,r)&&Ne(i,o))return this.path;const{enter:a=[],exit:s=[]}=Ah(r,n,(t=>t)),{enter:l=[],exit:u=[]}=Ah(o,i,(t=>t));t&&(s.push(t),a.push(t));const c=(t,n,r)=>{t.forEach((t=>{const i=r?this.members:this.avoidMembers,o=r?"pushMember":"pushNonMember",a=r?"removeMember":"removeNonMember";if(n){let n;"edge"===e.getElementType(t)?([n]=GB(e,t),this.bubbleSets.pushEdge(n)):([n]=zB(e,t),this.bubbleSets[o](n)),i.set(t,n)}else{const n=i.get(t);n&&("edge"===e.getElementType(t)?this.bubbleSets.removeEdge(n):this.bubbleSets[a](n),i.delete(t))}}))};c(s,!1,!0),c(a,!0,!0),c(u,!1,!1),c(l,!0,!1);const h=this.bubbleSets.compute().sample(8).simplify(0).bSplines().simplify(0);return this.path=Yd(h.points.map(ed)),this.path},this.bindEvents(),this.bubbleSets=new BB(this.options)}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath)}init(){this.bubbleSets=new BB(this.options),this.members=new Map,this.avoidMembers=new Map}parseOptions(){const t=this.options,{type:e,key:n,members:r,avoidMembers:i}=t,o=Fe(t,["type","key","members","avoidMembers"]),a=Object.keys(o).reduce(((t,e)=>(e in LB?t.bubbleSetOptions[e]=o[e]:t.style[e]=o[e],t)),{style:{},bubbleSetOptions:{}});return Object.assign({type:e,key:n,members:r,avoidMembers:i},a)}addMember(t){const e=Array.isArray(t)?t:[t];e.some((t=>this.options.avoidMembers.includes(t)))&&(this.options.avoidMembers=this.options.avoidMembers.filter((t=>!e.includes(t)))),this.options.members=[...new Set([...this.options.members,...e])],this.drawBubbleSets()}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter((t=>!e.includes(t))),this.drawBubbleSets()}updateMember(t){this.options.members=Yt(t)?t(this.options.members):t,this.drawBubbleSets()}getMember(){return this.options.members}addAvoidMember(t){const e=Array.isArray(t)?t:[t];e.some((t=>this.options.members.includes(t)))&&(this.options.members=this.options.members.filter((t=>!e.includes(t)))),this.options.avoidMembers=[...new Set([...this.options.avoidMembers,...e])],this.drawBubbleSets()}removeAvoidMember(t){const e=Array.isArray(t)?t:[t];this.options.avoidMembers.some((t=>e.includes(t)))&&(this.options.avoidMembers=this.options.avoidMembers.filter((t=>!e.includes(t))),this.drawBubbleSets())}updateAvoidMember(t){this.options.avoidMembers=Array.isArray(t)?t:[t],this.drawBubbleSets()}getAvoidMember(){return this.options.avoidMembers}destroy(){this.context.graph.off(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.off(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath),this.shape.destroy(),super.destroy()}}FB.defaultOptions=Object.assign({members:[],avoidMembers:[],fill:"lightblue",fillOpacity:.2,stroke:"blue",strokeOpacity:.2},LB);const zB=(t,e)=>(Array.isArray(e)?e:[e]).map((e=>{const n=t.getElementRenderBounds(e);return new mB(n.min[0],n.min[1],$c(n),qc(n))})),GB=(t,e)=>(Array.isArray(e)?e:[e]).map((e=>{const n=t.getEdgeData(e),r=t.getElementPosition(n.source),i=t.getElementPosition(n.target);return sB.from({x1:r[0],y1:r[1],x2:i[0],y2:i[1]})}));class VB extends Jj{constructor(t,e){super(t,Object.assign({},VB.defaultOptions,e)),this.targetElement=null,this.onTriggerEvent=t=>{var e;null===(e=t.preventDefault)||void 0===e||e.call(t),this.show(t)},this.onMenuItemClick=t=>{const{onClick:e,trigger:n}=this.options;if(t.target instanceof HTMLElement&&t.target.className.includes("g6-contextmenu-li")){const n=t.target.getAttribute("value");null==e||e(n,t.target,this.targetElement),this.hide()}"click"!==n&&this.hide()},this.initElement(),this.update(e)}initElement(){this.$element=tB("contextmenu",!1,{zIndex:"99"});const{className:t}=this.options;t&&this.$element.classList.add(t);this.context.canvas.getContainer().appendChild(this.$element),eB("g6-contextmenu-css","style",{},"\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",document.head)}show(t){return ze(this,void 0,void 0,(function*(){const{enable:e,offset:n}=this.options;if("function"==typeof e&&!e(t)||!e)return void this.hide();const r=yield this.getDOMContent(t);r instanceof HTMLElement?(this.$element.innerHTML="",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",this.targetElement=t.target}))}hide(){this.$element.style.display="none",this.targetElement=null}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy(),this.$element.remove()}getDOMContent(t){return ze(this,void 0,void 0,(function*(){const{getContent:e,getItems:n}=this.options;return n?`\n <ul class="g6-contextmenu-ul">\n ${(yield n(t)).map((t=>`<li class="g6-contextmenu-li" value="${t.value}">${t.name}</li>`)).join("")}\n </ul>\n `:yield 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)}}VB.defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'<div class="g6-contextmenu-loading">Loading...</div>',getContent:()=>"It is a empty context menu.",enable:()=>!0};class WB extends Jj{constructor(t,e){super(t,Object.assign({},WB.defaultOptions,e)),this.edgeBundles={},this.edgePoints={},this.onBundle=()=>{const{model:t,element:e}=this.context,n=t.getEdgeData();this.divideEdges(this.options.divisions);const{cycles:r,iterRate:i,divRate:o}=this.options;let{lambda:a,divisions:s,iterations:l}=this.options;for(let t=0;t<r;t++){for(let t=0;t<l;t++){const t={};n.forEach((e=>{var n;if(e.source===e.target)return;const r=yh(e);t[r]=this.getEdgeForces(e,s,a);for(let e=0;e<s+1;e++)(n=this.edgePoints)[r]||(n[r]=[]),this.edgePoints[r][e]=Ih(this.edgePoints[r][e],t[r][e])}))}a/=2,s*=o,l*=i,this.divideEdges(s)}n.forEach((t=>{const n=yh(t),r=e.getElement(n);null==r||r.update({d:qp(this.edgePoints[n])})}))},this.bindEvents()}get nodeMap(){const t=this.context.model.getNodeData();return Object.fromEntries(t.map((t=>[yh(t),Uh(Qh(t))])))}divideEdges(t){this.context.model.getEdgeData().forEach((e=>{var n;const r=yh(e);(n=this.edgePoints)[r]||(n[r]=[]);const i=this.nodeMap[e.source],o=this.nodeMap[e.target];if(1===t)this.edgePoints[r].push(i),this.edgePoints[r].push(Fh(Ih(i,o),2)),this.edgePoints[r].push(o);else{const e=(0===this.edgePoints[r].length?Gh(i,o):KB(this.edgePoints[r]))/(t+1);let n=e;const a=[i];for(let t=1;t<this.edgePoints[r].length;t++){const i=this.edgePoints[r][t-1],o=this.edgePoints[r][t];let s=Gh(o,i);for(;s>n;){const t=n/s,r=Ih(i,Bh(jh(o,i),t));a.push(r),s-=n,n=e}n-=s}a.push(o),this.edgePoints[r]=a}}))}getVectorPosition(t){const e=this.nodeMap[t.source],n=this.nodeMap[t.target],[r,i]=jh(n,e);return{source:e,target:n,vx:r,vy:i,length:Gh(e,n)}}measureEdgeCompatibility(t,e){const n=this.getVectorPosition(t),r=this.getVectorPosition(e);return HB(n,r)*YB(n,r)*UB(n,r)*XB(n,r)}getEdgeBundles(){const t={},e=this.options.bundleThreshold,n=this.context.model.getEdgeData();return n.forEach(((r,i)=>{n.forEach(((n,o)=>{var a,s;if(o<=i)return;this.measureEdgeCompatibility(r,n)>=e&&(t[a=yh(r)]||(t[a]=[]),t[yh(r)].push(n),t[s=yh(n)]||(t[s]=[]),t[yh(n)].push(r))}))})),t}getSpringForce(t,e){const{pre:n,cur:r,next:i}=t;return Bh(jh(Ih(n,i),Bh(r,2)),e)}getElectrostaticForce(t,e){Se(this.edgeBundles)&&(this.edgeBundles=this.getEdgeBundles());const n=this.edgeBundles[yh(e)];let r=[0,0];return null==n||n.forEach((n=>{const i=this.edgePoints[yh(n)][t],o=this.edgePoints[yh(e)][t],a=jh(i,o),s=Gh(i,o);r=Ih(r,Bh(a,1/s))})),r}getEdgeForces(t,e,n){const r=this.nodeMap[t.source],i=this.nodeMap[t.target],o=this.options.K/(Gh(r,i)*(e+1)),a=[[0,0]],s=yh(t);for(let r=1;r<e;r++){const e=this.getSpringForce({pre:this.edgePoints[s][r-1],cur:this.edgePoints[s][r],next:this.edgePoints[s][r+1]||[0,0]},o),i=this.getElectrostaticForce(r,t);a.push(Bh(Ih(e,i),n))}return a.push([0,0]),a}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_RENDER,this.onBundle)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_RENDER,this.onBundle)}destroy(){this.unbindEvents(),super.destroy()}}WB.defaultOptions={K:.1,lambda:.1,divisions:1,divRate:2,cycles:6,iterations:90,iterRate:2/3,bundleThreshold:.6};const HB=(t,e)=>Math.abs(function(t,e){return t.reduce(((t,n,r)=>t+n*e[r]),0)}([t.vx,t.vy],[e.vx,e.vy])/(t.length*e.length)),YB=(t,e)=>{const n=(t.length+e.length)/2;return 2/(n/Math.min(t.length,e.length)+Math.max(t.length,e.length)/n)},UB=(t,e)=>{const n=(t.length+e.length)/2;return n/(n+Gh(Fh(Ih(t.source,t.target),2),Fh(Ih(e.source,e.target),2)))},$B=(t,e)=>{if(e.source[0]===e.target[0])return[e.source[0],t[1]];if(e.source[1]===e.target[1])return[t[0],e.source[1]];const n=(e.source[1]-e.target[1])/(e.source[0]-e.target[0]),r=(n*n*e.source[0]+n*(t[1]-e.source[1])+t[0])/(n*n+1);return[r,n*(r-e.source[0])+e.source[1]]},qB=(t,e)=>{const n=$B(e.source,t),r=$B(e.target,t),i=Fh(Ih(n,r),2),o=Fh(Ih(t.source,t.target),2);return 0===Gh(n,r)?0:Math.max(0,1-2*Gh(o,i)/Gh(n,r))},XB=(t,e)=>Math.min(qB(t,e),qB(e,t)),KB=t=>{let e=0;for(let n=1;n<t.length;n++)e+=Gh(t[n],t[n-1]);return e},ZB={fill:"#fff",fillOpacity:1,lineWidth:1,stroke:"#000",strokeOpacity:.8,zIndex:-1/0};class QB extends Jj{constructor(t,e){super(t,Object.assign({},QB.defaultOptions,e)),this.shapes=new Map,this.r=this.options.r,this.onEdgeFilter=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=ed(t.canvas);this.renderLens(e),this.renderFocusElements()},this.renderLens=t=>{const e=Object.assign({},ZB,this.options.style);this.isLensOn||(this.lens=new ef({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,nd(t),{size:2*this.r}),this.lens.update(e)},this.getFilterData=()=>{const{filter:t}=this.options,{model:e}=this.context,n=e.getData();if(!t)return n;const{nodes:r,edges:i,combos:o}=n;return{nodes:r.filter((e=>t(yh(e),"node"))),edges:i.filter((e=>t(yh(e),"edge"))),combos:o.filter((e=>t(yh(e),"combo")))}},this.getFocusElements=t=>{const{nodes:e,edges:n}=this.getFilterData(),r=e.filter((e=>Gh(Qh(e),t)<this.r)),i=r.map((t=>yh(t)));return{nodes:r,edges:n.filter((t=>{const{source:e,target:n}=t,r=i.includes(e),o=i.includes(n);switch(this.options.nodeType){case"both":return r&&o;case"either":return r!==o;case"source":return r&&!o;case"target":return!r&&o;default:return!1}}))}},this.renderFocusElements=()=>{const{element:t,graph:e}=this.context;if(!this.isLensOn)return;const n=this.lens.getCenter(),{nodes:r,edges:i}=this.getFocusElements(n),o=new Set,a=n=>{const r=yh(n);o.add(r);const i=t.getElement(r);if(!i)return;const a=this.shapes.get(r)||i.cloneNode();a.setPosition(i.getPosition()),a.id=i.id,this.shapes.has(r)?Object.entries(i.attributes).forEach((([t,e])=>{a.style[t]!==e&&(a.style[t]=e)})):(this.canvas.appendChild(a),this.shapes.set(r,a));const s=e.getElementType(r),l=this.getElementStyle(s,n);a.update(l)};r.forEach(a),i.forEach(a),this.shapes.forEach(((t,e)=>{o.has(e)||(t.destroy(),this.shapes.delete(e))}))},this.scaleRByWheel=t=>{var e;this.options.preventDefault&&t.preventDefault();const{clientX:n,clientY:r,deltaX:i,deltaY:o}=t,{graph:a,canvas:s}=this.context,l=a.getCanvasByClient([n,r]),u=null===(e=this.lens)||void 0===e?void 0:e.getCenter();if(!this.isLensOn||Gh(l,u)>this.r)return;const{maxR:c,minR:h}=this.options,d=i+o>0?1/.95:.95,f=Math.min(...s.getSize())/2;this.r=Math.max(h||0,Math.min(c||f,this.r*d)),this.renderLens(u),this.renderFocusElements()},this.isLensDragging=!1,this.onDragStart=t=>{var e;const n=ed(t.canvas),r=null===(e=this.lens)||void 0===e?void 0:e.getCenter();!this.isLensOn||Gh(n,r)>this.r||(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=ed(t.canvas);this.renderLens(e),this.renderFocusElements()},this.onDragEnd=()=>{this.isLensDragging=!1},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}getElementStyle(t,e){const n="node"===t?this.options.nodeStyle:this.options.edgeStyle;return"function"==typeof n?n(e):n}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.addEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.addEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.addEventListener(t.CommonEvent.DRAG,this.onDrag),o.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel,{passive:!1}))}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.removeEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.removeEventListener(t.CommonEvent.DRAG,this.onDrag),o.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel))}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),this.isLensOn&&this.lens.destroy(),this.shapes.forEach(((t,e)=>{t.destroy(),this.shapes.delete(e)})),super.destroy()}}QB.defaultOptions={trigger:"pointermove",r:60,nodeType:"both",filter:()=>!0,style:{lineWidth:2},nodeStyle:{label:!1},edgeStyle:{label:!0},scaleRBy:"wheel",preventDefault:!0};const JB={fill:"#ccc",fillOpacity:.1,lineWidth:2,stroke:"#000",strokeOpacity:.8,labelFontSize:12};class tF extends Jj{constructor(t,e){super(t,Object.assign({},tF.defaultOptions,e)),this.r=this.options.r,this.d=this.options.d,this.onCreateFisheye=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=ed(t.canvas);this.onMagnify(e)},this.onMagnify=t=>{t.some(isNaN)||(this.renderLens(t),this.renderFocusElements())},this.renderLens=t=>{const e=Object.assign({},JB,this.options.style);this.isLensOn||(this.lens=new ef({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,nd(t),{size:2*this.r,label:this.options.showDPercent,labelText:this.getDPercent()}),this.lens.update(e)},this.getDPercent=()=>{const{minD:t,maxD:e}=this.options;return`${Math.round((this.d-t)/(e-t)*100)}%`},this.prevMagnifiedStyleMap=new Map,this.prevOriginStyleMap=new Map,this.renderFocusElements=()=>{if(!this.isLensOn)return;const{graph:t}=this.context,e=this.lens.getCenter(),n=(this.d+1)*this.r,r=new Map,i=new Map;t.getNodeData().forEach((o=>{const a=Qh(o),s=Gh(a,e);if(s>this.r)return;const l=n*s/(this.d*s+this.r),[u,c]=a,[h,d]=e,f=[h+l*((u-h)/s),d+l*((c-d)/s)],p=yh(o),g=this.getNodeStyle(o),v=Ce(t.getElementRenderStyle(p),Object.keys(g));r.set(p,Object.assign(Object.assign({},nd(f)),g)),i.set(p,Object.assign(Object.assign({},nd(a)),v))})),this.updateStyle(r,i)},this.getNodeStyle=t=>{const{nodeStyle:e}=this.options;return"function"==typeof e?e(t):e},this.updateStyle=(t,e)=>{const{graph:n,element:r}=this.context,{enter:i,exit:o,keep:a}=Ah(Array.from(this.prevMagnifiedStyleMap.keys()),Array.from(t.keys()),(t=>t)),s=new Set,l=(t,e)=>{const i=r.getElement(t);null==i||i.update(e),n.getRelatedEdgesData(t).forEach((t=>{s.add(yh(t))}))};[...i,...a].forEach((e=>{l(e,t.get(e))})),o.forEach((t=>{l(t,this.prevOriginStyleMap.get(t)),this.prevOriginStyleMap.delete(t)})),s.forEach((t=>{const e=r.getElement(t);null==e||e.update({})})),this.prevMagnifiedStyleMap=t,e.forEach(((t,e)=>{this.prevOriginStyleMap.has(e)||this.prevOriginStyleMap.set(e,t)}))},this.isWheelValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;const{clientX:e,clientY:n}=t;return!(Gh(this.context.graph.getCanvasByClient([e,n]),this.lens.getCenter())>this.r)},this.scaleR=t=>{const{maxR:e,minR:n}=this.options,r=t?1/.95:.95,i=Math.min(...this.context.canvas.getSize())/2;this.r=Math.max(n||0,Math.min(e||i,this.r*r))},this.scaleD=t=>{const{maxD:e,minD:n}=this.options,r=t?this.d+.1:this.d-.1;this.d=Math.max(n,Math.min(e,r))},this.scaleRByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleR(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleD(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.isDragValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;return!(Gh(ed(t.canvas),this.lens.getCenter())>this.r)},this.isLensDragging=!1,this.onDragStart=t=>{this.isDragValid(t)&&(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=ed(t.canvas);this.onMagnify(e)},this.onDragEnd=()=>{this.isLensDragging=!1},this.scaleRByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleR(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleD(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,a=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&a.addEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&a.addEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){a.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),a.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;a.addEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,n,{passive:!1})}}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,a=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&a.removeEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&a.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){a.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),a.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;a.removeEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,n)}}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){var t;this.unbindEvents(),this.isLensOn&&(null===(t=this.lens)||void 0===t||t.destroy()),this.prevMagnifiedStyleMap.clear(),this.prevOriginStyleMap.clear(),super.destroy()}}tF.defaultOptions={trigger:"pointermove",r:120,d:1.5,maxD:5,minD:0,showDPercent:!0,style:{},nodeStyle:{label:!0},preventDefault:!0};class eF extends Jj{constructor(t,e){super(t,Object.assign({},eF.defaultOptions,e)),this.$el=this.context.canvas.getContainer(),this.graphSize=[0,0],this.onFullscreenChange=()=>{var t,e,n,r;const i=!!document.fullscreenElement;this.options.autoFit&&this.setGraphSize(i),i?null===(e=(t=this.options).onEnter)||void 0===e||e.call(t):null===(r=(n=this.options).onExit)||void 0===r||r.call(n)},this.shortcut=new gd(t.graph),this.bindEvents(),this.style=document.createElement("style"),document.head.appendChild(this.style),this.style.innerHTML="\n :not(:root):fullscreen::backdrop {\n background: transparent;\n }\n "}bindEvents(){this.unbindEvents(),this.shortcut.unbindAll();const{request:t=[],exit:e=[]}=this.options.trigger;this.shortcut.bind(t,this.request),this.shortcut.bind(e,this.exit);["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach((t=>{document.addEventListener(t,this.onFullscreenChange,!1)}))}unbindEvents(){this.shortcut.unbindAll();["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach((t=>{document.removeEventListener(t,this.onFullscreenChange,!1)}))}setGraphSize(t=!0){var e,n;let r,i;t?(r=(null===(e=globalThis.screen)||void 0===e?void 0:e.width)||0,i=(null===(n=globalThis.screen)||void 0===n?void 0:n.height)||0,this.graphSize=this.context.graph.getSize()):[r,i]=this.graphSize,this.context.graph.setSize(r,i),this.context.graph.render()}request(){!document.fullscreenElement&&(document.fullscreenEnabled||Reflect.get(document,"webkitFullscreenEnabled")||Reflect.get(document,"mozFullscreenEnabled")||Reflect.get(document,"msFullscreenEnabled"))&&this.$el.requestFullscreen().catch((t=>{Tc(`Error attempting to enable full-screen: ${t.message} (${t.name})`)}))}exit(){document.fullscreenElement&&document.exitFullscreen()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.exit(),this.style.remove(),super.destroy()}}eF.defaultOptions={trigger:{},autoFit:!0};class nF extends Jj{constructor(t,e){super(t,Object.assign({},nF.defaultOptions,e)),this.$element=tB("grid-line",!0),this.offset=[0,0],this.onTransform=t=>{if(!this.options.follow)return;const{data:{translate:e}}=t;e&&this.updateOffset(e)};this.context.canvas.getContainer().prepend(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`,backgroundRepeat:"repeat"})}updateOffset(t){this.offset=function(t,e){return t.map((t=>t%e))}(Ih(this.offset,t),this.options.size),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}destroy(){this.context.graph.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform),this.$element.remove(),super.destroy()}}function rF(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=yh(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.Removed.has(i)||e.Updated.set(i,t);else"NodeRemoved"!==n&&"EdgeRemoved"!==n&&"ComboRemoved"!==n||(e.Added.has(i)?e.Added.delete(i):e.Updated.has(i)?(e.Updated.delete(i),e.Removed.set(i,t)):e.Removed.set(i,t))})),[...Array.from(e.Added.values()),...Array.from(e.Updated.values()),...Array.from(e.Removed.values())]}function iF(t){const{NodeAdded:e=[],NodeUpdated:n=[],NodeRemoved:r=[],EdgeAdded:i=[],EdgeUpdated:o=[],EdgeRemoved:a=[],ComboAdded:s=[],ComboUpdated:l=[],ComboRemoved:u=[]}=ie(t,(t=>t.type));return{add:{nodes:e,edges:i,combos:s},update:{nodes:n,edges:o,combos:l},remove:{nodes:r,edges:a,combos:u}}}function oF(t,e){for(const n in t)qt(t[n])&&!Array.isArray(t[n])&&null!==t[n]?(e[n]||(e[n]={}),oF(t[n],e[n])):void 0===e[n]&&(e[n]=Rc(n))}function aF(t,e=!1,n){const r={animation:e,current:{add:{},update:{},remove:{}},original:{add:{},update:{},remove:{}}},{add:i,update:o,remove:a}=iF(rF(t));return["nodes","edges","combos"].forEach((t=>{o[t]&&o[t].forEach((e=>{var i,o;const a=Object.assign({},e.value);let s=Object.assign({},e.original);if(n){const t=n.graph.getElementType(yh(e.original)),r="edge"===t?"stroke":"fill",i=n.element.getElementComputedStyle(t,e.original);s=Object.assign(Object.assign({},e.original),{style:Object.assign({[r]:i[r]},e.original.style)})}oF(a,s),(i=r.current.update)[t]||(i[t]=[]),r.current.update[t].push(a),(o=r.original.update)[t]||(o[t]=[]),r.original.update[t].push(s)})),i[t]&&i[t].forEach((e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.add)[t]||(n[t]=[]),r.current.add[t].push(o),(i=r.original.remove)[t]||(i[t]=[]),r.original.remove[t].push(o)})),a[t]&&a[t].forEach((e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.remove)[t]||(n[t]=[]),r.current.remove[t].push(o),(i=r.original.add)[t]||(i[t]=[]),r.original.add[t].push(o)}))})),r}nF.defaultOptions={border:!0,borderLineWidth:1,borderStroke:"#eee",borderStyle:"solid",lineWidth:1,size:20,stroke:"#eee"};class sF extends Jj{constructor(e,n){super(e,Object.assign({},sF.defaultOptions,n)),this.batchChanges=null,this.batchAnimation=!1,this.undoStack=[],this.redoStack=[],this.freezed=!1,this.executeCommand=(t,e=!0)=>{var n,r,i;this.freezed=!0,null===(r=(n=this.options).executeCommand)||void 0===r||r.call(n,t);const o=e?t.original:t.current;this.context.graph.addData(o.add),this.context.graph.updateData(o.update),this.context.graph.removeData(xh(o.remove,!1)),null===(i=this.context.element)||void 0===i||i.draw({silence:!0,animation:t.animation}),this.freezed=!1},this.addCommand=e=>{var n;if(!this.freezed){if(e.type===t.GraphEvent.AFTER_DRAW){const{dataChanges:t=[],animation:r=!0}=e.data;if(null===(n=this.context.batch)||void 0===n?void 0:n.isBatching){if(!this.batchChanges)return;return this.batchChanges.push(t),void(this.batchAnimation&&(this.batchAnimation=r))}this.batchChanges=[t],this.batchAnimation=r}this.undoStackPush(aF(this.batchChanges.flat(),this.batchAnimation,this.context)),this.notify(t.HistoryEvent.ADD,this.undoStack[this.undoStack.length-1])}},this.initBatchCommand=t=>{const{initiate:e}=t.data;if(this.batchAnimation=!1,e)this.batchChanges=[];else{this.undoStack.pop()||(this.batchChanges=null)}},this.emitter=new zg;const{graph:r}=this.context;r.on(t.GraphEvent.AFTER_DRAW,this.addCommand),r.on(t.GraphEvent.BATCH_START,this.initBatchCommand),r.on(t.GraphEvent.BATCH_END,this.addCommand)}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}undo(){var e,n,r,i;const o=this.undoStack.pop();if(o){this.executeCommand(o);if(!1===(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,o,!1)))return;this.redoStack.push(o),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,o,!1),this.notify(t.HistoryEvent.UNDO,o)}return this}redo(){const e=this.redoStack.pop();return e&&(this.executeCommand(e,!1),this.undoStackPush(e),this.notify(t.HistoryEvent.REDO,e)),this}undoAndCancel(){const e=this.undoStack.pop();return e&&(this.executeCommand(e,!1),this.redoStack=[],this.notify(t.HistoryEvent.CANCEL,e)),this}undoStackPush(t){var e,n,r,i;const{stackSize:o}=this.options;0!==o&&this.undoStack.length>=o&&this.undoStack.shift();!1!==(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,t,!0))&&(this.undoStack.push(t),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,t,!0))}clear(){this.undoStack=[],this.redoStack=[],this.batchChanges=null,this.batchAnimation=!1,this.notify(t.HistoryEvent.CLEAR,null)}notify(e,n){this.emitter.emit(e,{cmd:n}),this.emitter.emit(t.HistoryEvent.CHANGE,{cmd:n})}on(t,e){this.emitter.on(t,e)}destroy(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.addCommand),e.off(t.GraphEvent.BATCH_START,this.initBatchCommand),e.off(t.GraphEvent.BATCH_END,this.addCommand),this.emitter.off(),super.destroy(),this.undoStack=[],this.redoStack=[]}}function lF(t,e,n,r,i,o){const a=(o-e)*(n-t)-(r-e)*(i-t);return a>0||!(a<0)}sF.defaultOptions={stackSize:0};var uF=function(t,e){const n=t[0][0],r=t[0][1],i=t[1][0],o=t[1][1],a=e[0][0],s=e[0][1],l=e[1][0],u=e[1][1];return lF(n,r,a,s,l,u)!==lF(i,o,a,s,l,u)&&lF(n,r,i,o,a,s)!==lF(n,r,i,o,l,u)};function cF(t,e){this._cells=[],this._cellSize=e,this._reverseCellSize=1/e;for(let e=0;e<t.length;e++){const n=t[e],r=this.coordToCellNum(n[0]),i=this.coordToCellNum(n[1]);if(this._cells[r])this._cells[r][i]?this._cells[r][i].push(n):this._cells[r][i]=[n];else{const t=[];t[i]=[n],this._cells[r]=t}}}function hF(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}cF.prototype={cellPoints:function(t,e){return void 0!==this._cells[t]&&void 0!==this._cells[t][e]?this._cells[t][e]:[]},rangePoints:function(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this.coordToCellNum(t[2]),i=this.coordToCellNum(t[3]),o=[];for(let t=e;t<=r;t++)for(let e=n;e<=i;e++)for(let n=0;n<this.cellPoints(t,e).length;n++)o.push(this.cellPoints(t,e)[n]);return o},removePoint:function(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this._cells[e][n];let i;for(let e=0;e<r.length;e++)if(r[e][0]===t[0]&&r[e][1]===t[1]){i=e;break}return r.splice(i,1),r},trunc:Math.trunc||function(t){return t-t%1},coordToCellNum:function(t){return this.trunc(t*this._reverseCellSize)},extendBbox:function(t,e){return[t[0]-e*this._cellSize,t[1]-e*this._cellSize,t[2]+e*this._cellSize,t[3]+e*this._cellSize]}};var dF=function(t){const e=function(t){const e=[];for(let n=0;n<t.length;n++){for(;e.length>=2&&hF(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}return e.pop(),e}(t),n=function(t){const e=t.reverse(),n=[];for(let t=0;t<e.length;t++){for(;n.length>=2&&hF(n[n.length-2],n[n.length-1],e[t])<=0;)n.pop();n.push(e[t])}return n.pop(),n}(t),r=n.concat(e);return r.push(t[0]),r};const fF=uF,pF=function(t,e){return new cF(t,e)},gF={toXy:function(t,e){return void 0===e?t.slice():t.map((function(t){return new Function("pt","return [pt"+e[0]+",pt"+e[1]+"];")(t)}))},fromXy:function(t,e){return void 0===e?t.slice():t.map((function(t){return new Function("pt","const o = {}; o"+e[0]+"= pt[0]; o"+e[1]+"= pt[1]; return o;")(t)}))}},vF=dF;function mF(t,e){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function yF(t,e,n){const r=[e[0]-t[0],e[1]-t[1]],i=[n[0]-t[0],n[1]-t[1]],o=mF(t,e),a=mF(t,n);return(r[0]*i[0]+r[1]*i[1])/Math.sqrt(o*a)}function bF(t,e){for(let n=0;n<e.length-1;n++){const r=[e[n],e[n+1]];if(!(t[0][0]===r[0][0]&&t[0][1]===r[0][1]||t[0][0]===r[1][0]&&t[0][1]===r[1][1])&&fF(t,r))return!0}return!1}function xF(t){return[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])]}function EF(t,e,n){let r,i,o=null,a=kF,s=kF;for(let l=0;l<e.length;l++)r=yF(t[0],t[1],e[l]),i=yF(t[1],t[0],e[l]),r>a&&i>s&&!bF([t[0],e[l]],n)&&!bF([t[1],e[l]],n)&&(a=r,s=i,o=e[l]);return o}function wF(t,e,n,r,i){let o=!1;for(let a=0;a<t.length-1;a++){const s=[t[a],t[a+1]],l=s[0][0]+","+s[0][1]+","+s[1][0]+","+s[1][1];if(mF(s[0],s[1])<e||i.has(l))continue;let u,c,h,d=0,f=xF(s);do{f=r.extendBbox(f,d),u=f[2]-f[0],c=f[3]-f[1],h=EF(s,r.rangePoints(f),t),d++}while(null===h&&(n[0]>u||n[1]>c));u>=n[0]&&c>=n[1]&&i.add(l),null!==h&&(t.splice(a+1,0,h),r.removePoint(h),o=!0)}return o?wF(t,e,n,r,i):t}const kF=Math.cos(90/(180/Math.PI)),MF=.6;var SF=function(t,e,n){let r=e||20;const i=function(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];n[0]===i[0]&&n[1]===i[1]||e.push(i),n=i}return e}(function(t){return t.sort((function(t,e){return t[0]-e[0]||t[1]-e[1]}))}(gF.toXy(t,n)));if(i.length<4){const t=i.concat([i[0]]);return n?gF.fromXy(t,n):t}const o=function(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let o=t.length-1;o>=0;o--)t[o][0]<e&&(e=t[o][0]),t[o][1]<n&&(n=t[o][1]),t[o][0]>r&&(r=t[o][0]),t[o][1]>i&&(i=t[o][1]);return[r-e,i-n]}(i),a=[o[0]*MF,o[1]*MF],s=vF(i),l=i.filter((function(t){return s.indexOf(t)<0})),u=Math.ceil(1/(i.length/(o[0]*o[1]))),c=wF(s,Math.pow(r,2),a,pF(l,u),new Set);return n?gF.fromXy(c,n):c},NF=E(SF);const OF=(t,e,n)=>{if("sharp"===n)return[["M",t[0]-e,t[1]-e],["L",t[0]+e,t[1]-e],["L",t[0]+e,t[1]+e],["L",t[0]-e,t[1]+e],["Z"]];const r=[e,e,0,0,0];return[["M",t[0],t[1]-e],["A",...r,t[0],t[1]+e],["A",...r,t[0],t[1]-e]]},TF=(t,e,n)=>{const r=[e,e,0,0,0],i="sharp"===n?Ih(t[0],zh(Wh(jh(t[0],t[1])),e)):t[0],o="sharp"===n?Ih(t[1],zh(Wh(jh(t[1],t[0])),e)):t[1],a=zh(Wh(Yh(jh(i,o),!1)),e),s=zh(a,-1),l=Ih(i,a),u=Ih(o,a),c=Ih(o,s),h=Ih(i,s);return"sharp"===n?[["M",l[0],l[1]],["L",u[0],u[1]],["L",c[0],c[1]],["L",h[0],h[1]],["Z"]]:[["M",l[0],l[1]],["L",u[0],u[1]],["A",...r,c[0],c[1]],["L",h[0],h[1]],["A",...r,l[0],l[1]]]},AF=(t,e)=>{const n=dd(t).map(((n,r)=>{const i=(r-2+t.length)%t.length,o=(r-1+t.length)%t.length,a=(r+1)%t.length,s=t[i],l=t[o],u=t[a],c=jh(s,l),h=jh(l,n),d=jh(n,u),f=(t,e)=>Hh(t,e,!0)<Math.PI,p=f(c,h),g=f(h,d),v=t=>zh(Wh(Yh(t,!1)),e),m=v(h);return[{p:Uh(Ih(l,p?v(c):m)),concave:p&&l},{p:Uh(Ih(n,g?v(d):m)),concave:g&&n}]})),r=[e,e,0,0,0],i=n.findIndex(((t,e)=>!(n[(e-1+n.length)%n.length][0].concave||n[(e-1+n.length)%n.length][1].concave||t[0].concave||t[0].concave||t[1].concave))),o=n.slice(i).concat(n.slice(0,i));let a=[];return o.flatMap(((t,e)=>{const i=[],s=o[n.length-1];return 0===e&&i.push(["M",...s[1].p]),t[0].concave?a.push(t[0].p,t[1].p):i.push(["A",...r,...t[0].p]),t[1].concave?a.unshift(t[1].p):i.push(["L",...t[1].p]),3===a.length&&(i.pop(),i.push(["C",...a.flat()]),a=[]),i}))},CF=(t,e)=>{const n=dd(t).map(((e,n)=>({p:e,v:Wh(jh(t[(n+1)%t.length],e))})));return n.forEach(((r,i)=>{const o=i>0?i-1:t.length-1,a=n[o].v,s=Wh(Ih(a,zh(r.v,Hh(a,r.v,!0)<Math.PI?1:-1)));r.p=Ih(r.p,zh(s,e))})),Yd(n.map((t=>t.p)))},PF=(t,e)=>{const n=t.map(((n,r)=>{const i=t[0===r?t.length-1:r-1],o=$h(zh(Wh(Yh(jh(i,n),!1)),e));return[Ih(i,o),Ih(n,o)]})),r=n.flat();return r.map(((t,e)=>{if(e%2==0)return null;return Kh([r[(e-1)%r.length],r[e%r.length]],[r[(e+1)%r.length],r[(e+2)%r.length]],!0)})).filter(Boolean).map(((t,e)=>[0===e?"M":"L",t[0],t[1]])).concat([["Z"]])};class RF extends Jj{constructor(t,e){super(t,Object.assign({},RF.defaultOptions,e)),this.hullMemberIds=[],this.drawHull=()=>{if(this.shape){const t=!Ne(this.optionsCache,this.options);this.shape.update(this.getHullStyle(t))}else this.shape=new Ud({style:this.getHullStyle()}),this.context.canvas.appendChild(this.shape);this.optionsCache=Object.assign({},this.options)},this.updateHullPath=t=>{this.shape&&this.options.members.includes(yh(t.data))&&this.shape.update({d:this.getHullPath(!0)})},this.getHullPath=(t=!1)=>{const{graph:e}=this.context,n=this.getMember();if(0===n.length)return"";const r=n.map((t=>e.getNodeData(t))),i=NF(r.map(Qh),this.options.concavity).slice(1).reverse(),o=i.flatMap((t=>r.filter((e=>Ne(Qh(e),t))).map(yh)));return Ne(o,this.hullMemberIds)&&!t||(this.hullMemberIds=o,this.path=function(t,e,n){if(1===t.length)return OF(t[0],e,n);if(2===t.length)return TF(t,e,n);if(3===t.length){const[r,i,o]=dd(t);if(ad(r,i,o))return TF([r,o],e,n)}switch(n){case"smooth":return CF(t,e);case"sharp":return PF(t,e);default:return AF(t,e)}}(i,this.getPadding(),this.options.corner)),this.path},this.bindEvents()}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}getHullStyle(t){const e=Fe(this.options,["members","padding","corner"]);return Object.assign(Object.assign({},e),{d:this.getHullPath(t)})}getPadding(){const{graph:t}=this.context,e=this.hullMemberIds.reduce(((e,n)=>{const{halfExtents:r}=t.getElementRenderBounds(n),i=Math.max(r[0],r[1]);return Math.max(e,i)}),0);return e+this.options.padding}addMember(t){const e=Array.isArray(t)?t:[t];this.options.members=[...new Set([...this.options.members,...e])],this.shape.update({d:this.getHullPath()})}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter((t=>!e.includes(t))),e.some((t=>this.hullMemberIds.includes(t)))&&this.shape.update({d:this.getHullPath()})}updateMember(t){this.options.members=Yt(t)?t(this.options.members):t,this.shape.update(this.getHullStyle(!0))}getMember(){return this.options.members}destroy(){this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.drawHull),this.shape.destroy(),this.hullMemberIds=[],super.destroy()}}function DF(t,e){e(t),t.children&&t.children.forEach((function(t){t&&DF(t,e)}))}function LF(t){IF(t,!0)}function _F(t){IF(t,!1)}function IF(t,e){var n=e?"visible":"hidden";DF(t,(function(t){t.attr("visibility",n)}))}RF.defaultOptions={members:[],padding:10,corner:"rounded",concavity:1/0,fill:"lightblue",fillOpacity:.2,labelOpacity:1,stroke:"blue",strokeOpacity:.2};var jF=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,We([],Ve(e),!1))||this;return r.isMutationObserved=!0,r.addEventListener(Vs.INSERTED,(function(){_F(r)})),r}return je(e,t),e}(jl);function BF(t){var e=t.appendChild(new jF({class:"offscreen"}));return _F(e),e}var FF=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=Fe(e,["style"]);return t.call(this,Be({style:Be({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return je(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=BF(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(Zl);function zF(t){return t*Math.PI/180}function GF(t){return Number((180*t/Math.PI).toPrecision(5))}var VF=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}();function WF(t,e){return Yt(t)?t.apply(void 0,We([],Ve(e),!1)):t}var HF,YF=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map((function(t){var e=Ve(t,2),r=e[0],i=e[1],o=n(i);return[r,{name:o,class:".".concat(o),id:"#".concat(o),toString:function(){return o}}]})));return Object.assign(r,{prefix:n}),r},UF=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach((function(i){var o=Ve(i,2),a=o[0],s=o[1],l=t;Object.prototype.hasOwnProperty.call(e,a)&&(s?Jt(s)?(Jt(t[a])||(l[a]={}),n<r?UF(t[a],s,n+1,r):l[a]=e[a]):$t(s)?(l[a]=[],l[a]=l[a].concat(s)):l[a]=s:l[a]=s)}))},$F=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)UF(t,e[r]);return t},qF=function(t){return void 0!==t&&null!=t&&!Number.isNaN(t)},XF=xe((function(t,e){var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return HF||(HF=bl.offscreenCanvasCreator.getOrCreateContext(void 0)),HF.font=[o,a,i,"".concat(n,"px"),r].join(" "),HF.measureText(t).width}),(function(t,e){return[t,Object.values(e||KF(t)).join()].join("")}),4096),KF=function(t){var e=t.style.fontFamily||"sans-serif",n=t.style.fontWeight||"normal",r=t.style.fontStyle||"normal",i=t.style.fontVariant,o=t.style.fontSize;return{fontSize:o="object"==typeof o?o.value:o,fontFamily:e,fontWeight:n,fontStyle:r,fontVariant:i}};function ZF(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}function QF(t,e){var n=ZF(t);n&&n.attr(e)}function JF(t,e,n){void 0===n&&(n="..."),QF(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function tz(t){var e=t.canvas,n=t.touches,r=t.offsetX,i=t.offsetY;if(e)return[e.x,e.y];if(n){var o=n[0];return[o.clientX,o.clientY]}return r&&i?[r,i]:[0,0]}function ez(t){return"function"==typeof t?t():ne(t)||ae(t)?new FF({style:{text:String(t)}}):t}function nz(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=function(t){t.node().removeChildren()}),t?n(e):(r&&i(e),null)}function rz(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=!1),!!(r&&t===e||i&&t===n)||t>e&&t<n}function iz(t,e){return"number"==typeof t&&"number"==typeof e?function(t,e){return function(n){return t*(1-n)+e*n}}(t,e):Array.isArray(t)&&Array.isArray(e)?function(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0;return function(i){var o=new Array(r),a=new Array(n),s=0;for(s=0;s<r;++s)o[s]=iz(t[s],e[s]);for(;s<n;++s)a[s]=e[s];for(s=0;s<r;++s)a[s]=o[s](i);return a}}(t,e):"object"==typeof t&&"object"==typeof e?function(t,e){void 0===t&&(t={}),void 0===e&&(e={});var n={},r={};return Object.entries(e).forEach((function(e){var i=Ve(e,2),o=i[0],a=i[1];o in t?n[o]=iz(t[o],a):r[o]=a})),function(t){return Object.entries(n).forEach((function(e){var n=Ve(e,2),i=n[0],o=n[1];return r[i]=o(t)})),r}}(t,e):function(e){return t}}function oz(t,e){return[t[0]*e,t[1]*e]}function az(t,e){return[t[0]+e[0],t[1]+e[1]]}function sz(t,e){return[t[0]-e[0],t[1]-e[1]]}function lz(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1])]}function uz(t,e){return[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}function cz(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function hz(t){if(0===t[0]&&0===t[1])return[0,0];var e=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2));return[t[0]/e,t[1]/e]}function dz(t,e){return+t.toPrecision(e)}function fz(t,e){var n={},r=Array.isArray(e)?e:[e];for(var i in t)r.includes(i)||(n[i]=t[i]);return n}function pz(t,e,n){void 0===n&&(n=[[0,0],[1,1]]);for(var r=[],i=0,o=t.length;i<o;i+=2)r.push([t[i],t[i+1]]);var a,s,l,u=function(t,e,n,r){var i,o,a,s,l,u,c=[],h=!!r,d=[1/0,1/0],f=[-1/0,-1/0];if(h){d=(i=Ve(r,2))[0],f=i[1];for(var p=0,g=t.length;p<g;p+=1)d=lz(d,m=t[p]),f=uz(f,m)}p=0;for(var v=t.length;p<v;p+=1){var m=t[p];if(0===p)u=m;else if(p===v-1)l=m,c.push(u),c.push(l);else{o=t[p-1];var y=[0,0];y=oz(y=sz(a=t[p+1],o),e);var b=cz(m,o),x=cz(m,a),E=b+x;0!==E&&(b/=E,x/=E);var w=oz(y,-b),k=oz(y,x);l=az(m,w),s=lz(s=az(m,k),uz(a,m)),s=uz(s,lz(a,m)),l=lz(l=az(m,w=oz(w=sz(s,m),-b/x)),uz(o,m)),s=az(m,k=oz(k=sz(m,l=uz(l,lz(o,m))),x/b)),h&&(l=lz(l=uz(l,d),f),s=lz(s=uz(s,d),f)),c.push(u),c.push(l),u=s}}return c}(r,.4,0,n),c=r.length,h=[];for(i=0;i<c-1;i+=1)a=u[2*i],s=u[2*i+1],l=r[i+1],h.push(["C",a[0],a[1],s[0],s[1],l[0],l[1]]);return h}var gz=["$el","cx","cy","d","dx","dy","fill","fillOpacity","filter","fontFamily","fontSize","fontStyle","fontVariant","fontWeight","height","img","increasedLineWidthForHitTesting","innerHTML","isBillboard","billboardRotation","isSizeAttenuation","isClosed","isOverflowing","leading","letterSpacing","lineDash","lineHeight","lineWidth","markerEnd","markerEndOffset","markerMid","markerStart","markerStartOffset","maxLines","metrics","miterLimit","offsetX","offsetY","opacity","path","points","r","radius","rx","ry","shadowColor","src","stroke","strokeOpacity","text","textAlign","textBaseline","textDecorationColor","textDecorationLine","textDecorationStyle","textOverflow","textPath","textPathSide","textPathStartOffset","transform","transformOrigin","visibility","width","wordWrap","wordWrapWidth","x","x1","x2","y","y1","y2","z1","z2","zIndex"];function vz(t){return gz.includes(t)}function mz(t){var e={};for(var n in t)vz(n)&&(e[n]=t[n]);return e}function yz(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,a=e/Math.max(i,o);return t.style.transform="scale(".concat(a,")"),a}var bz=function(){function t(t,n,r,i,o,a,s){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=[null,null,null,null,null]),void 0===a&&(a=[]),void 0===s&&(s=[]),e.add(this),this._elements=Array.from(t),this._data=n,this._parent=r,this._document=i,this._enter=o[0],this._update=o[1],this._exit=o[2],this._merge=o[3],this._split=o[4],this._transitions=a,this._facetElements=s}var e,n,r;return t.prototype.selectAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(e,null,this._elements[0],this._document)},t.prototype.selectFacetAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(this._elements,null,this._parent,this._document,void 0,void 0,e)},t.prototype.select=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t)[0]||null:t;return new n([e],null,e,this._document)},t.prototype.append=function(t){var e=this,r="function"==typeof t?t:function(){return e.createElement(t)},i=[];if(null!==this._data){for(var o=0;o<this._data.length;o++){var a=this._data[o],s=Ve(Array.isArray(a)?a:[a,null],2),l=s[0],u=s[1];(h=r(l,o)).__data__=l,null!==u&&(h.__fromElements__=u),this._parent.appendChild(h),i.push(h)}return new n(i,null,this._parent,this._document)}for(o=0;o<this._elements.length;o++){var c=this._elements[o],h=r(l=c.__data__,o);c.appendChild(h),i.push(h)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=He(this,e,"m",r).call(this,"#"===t[0]?t:"#".concat(t),n);return i.attr("id",t),i},t.prototype.maybeAppendByClassName=function(t,n){var i=t.toString(),o=He(this,e,"m",r).call(this,"."===i[0]?i:".".concat(i),n);return o.attr("className",i),o},t.prototype.maybeAppendByName=function(t,n){var i=He(this,e,"m",r).call(this,'[name="'.concat(t,'"]'),n);return i.attr("name",t),i},t.prototype.data=function(t,e,r){var i,o;void 0===e&&(e=function(t){return t}),void 0===r&&(r=function(){return null});for(var a,s,l,u=[],c=[],h=new Set(this._elements),d=[],f=new Set,p=new Map(this._elements.map((function(t,n){return[e(t.__data__,n),t]}))),g=new Map(this._facetElements.map((function(t,n){return[e(t.__data__,n),t]}))),v=(a=this._elements,s=function(t){return r(t.__data__)},l=new Map,a.forEach((function(t){var e=s(t);l.has(e)||l.set(e,[]),l.get(e).push(t)})),l),m=0;m<t.length;m++){var y=t[m],b=e(y,m),x=r(y,m);if(p.has(b))(M=p.get(b)).__data__=y,M.__facet__=!1,c.push(M),h.delete(M),p.delete(b);else if(g.has(b)){(M=g.get(b)).__data__=y,M.__facet__=!0,c.push(M),g.delete(b)}else if(v.has(b)){var E=v.get(b);d.push([y,E]);try{for(var w=(i=void 0,Ge(E)),k=w.next();!k.done;k=w.next()){var M=k.value;h.delete(M)}}catch(t){i={error:t}}finally{try{k&&!k.done&&(o=w.return)&&o.call(w)}finally{if(i)throw i.error}}v.delete(b)}else if(p.has(x)){(M=p.get(x)).__toData__?M.__toData__.push(y):M.__toData__=[y],f.add(M),h.delete(M)}else u.push(y)}var S=[new n([],u,this._parent,this._document),new n(c,null,this._parent,this._document),new n(h,null,this._parent,this._document),new n([],d,this._parent,this._document),new n(f,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,S)},t.prototype.merge=function(t){var e=We(We([],Ve(this._elements),!1),Ve(t._elements),!1),r=We(We([],Ve(this._transitions),!1),Ve(t._transitions),!1);return new n(e,null,this._parent,this._document,void 0,r)},t.prototype.createElement=function(t){if(this._document)return this._document.createElement(t,{});var e=n.registry[t];return e?new e:function(t){throw new Error(t)}("Unknown node type: ".concat(t))},t.prototype.join=function(t,e,n,r,i){void 0===t&&(t=function(t){return t}),void 0===e&&(e=function(t){return t}),void 0===n&&(n=function(t){return t.remove()}),void 0===r&&(r=function(t){return t}),void 0===i&&(i=function(t){return t.remove()});var o=t(this._enter),a=e(this._update),s=n(this._exit),l=r(this._merge),u=i(this._split);return a.merge(o).merge(s).merge(l).merge(u)},t.prototype.remove=function(){for(var t=function(t){var n=e._elements[t],r=e._transitions[t];r?r.then((function(){return n.remove()})):n.remove()},e=this,r=0;r<this._elements.length;r++)t(r);return new n([],null,this._parent,this._document,void 0,this._transitions)},t.prototype.each=function(t){for(var e=0;e<this._elements.length;e++){var n=this._elements[e],r=n.__data__;t.call(n,r,e)}return this},t.prototype.attr=function(t,e){var n="function"!=typeof e?function(){return e}:e;return this.each((function(r,i){void 0!==e&&(this[t]=n.call(this,r,i))}))},t.prototype.style=function(t,e,n){void 0===n&&(n=!0);var r="function"==typeof e&&n?e:function(){return e};return this.each((function(n,i){void 0!==e&&(this.style[t]=r.call(this,n,i))}))},t.prototype.styles=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=!0),this.each((function(n,r){var i=this;Object.entries(t).forEach((function(t){var o=Ve(t,2),a=o[0],s=o[1],l="function"==typeof s&&e?s:function(){return s};void 0!==s&&i.attr(a,l.call(i,n,r))}))}))},t.prototype.update=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.maybeUpdate=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.transition=function(t){var e=this._transitions;return this.each((function(n,r){e[r]=t.call(this,n,r)}))},t.prototype.on=function(t,e){return this.each((function(){this.addEventListener(t,e)})),this},t.prototype.call=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return t.call.apply(t,We([this._parent,this],Ve(e),!1)),this},t.prototype.node=function(){return this._elements[0]},t.prototype.nodes=function(){return this._elements},t.prototype.transitions=function(){return this._transitions.filter((function(t){return!!t}))},t.prototype.parent=function(){return this._parent},n=t,e=new WeakSet,r=function(t,e){var r=this._elements[0],i=r.querySelector(t);if(i)return new n([i],null,this._parent,this._document);var o="string"==typeof e?this.createElement(e):e();return r.appendChild(o),new n([o],null,this._parent,this._document)},t.registry={g:jl,rect:Xl,circle:Dl,path:Hl,text:FF,ellipse:Il,image:zl,line:Vl,polygon:Ul,polyline:ql,html:Fl},t}();function xz(t){return new bz([t],null,t,t.ownerDocument)}function Ez(t){if(ae(t))return[t,t,t,t];if($t(t)){var e=t.length;if(1===e)return[t[0],t[0],t[0],t[0]];if(2===e)return[t[0],t[1],t[0],t[1]];if(3===e)return[t[0],t[1],t[2],t[1]];if(4===e)return t}return[0,0,0,0]}function wz(t){var e=t.getLocalBounds(),n=Ve([e.min,e.max],2),r=Ve(n[0],2),i=r[0],o=r[1],a=Ve(n[1],2),s=a[0],l=a[1];return{x:i,y:o,width:s-i,height:l-o,left:i,bottom:l,top:o,right:s}}function kz(t,e){var n=Ve(t,2),r=n[0],i=n[1],o=Ve(e,2),a=o[0],s=o[1];return r!==a&&i===s}function Mz(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function Sz(t,e,n){var r;void 0===n&&(n=!0);var i=e||(null===(r=t.match(/^([a-z][a-z0-9]+)/))||void 0===r?void 0:r[0])||"",o=t.replace(new RegExp("^(".concat(i,")")),"");return n?function(t){return t.toString().charAt(0).toLowerCase()+t.toString().slice(1)}(o):o}var Nz=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function Oz(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach((function(t){var i=Ve(t,2),o=i[0],a=i[1];if("className"===o||"class"===o);else if(Nz(o,"show")&&Nz(Sz(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(Mz(t))}(e,"show")?r[o]=a:r[o.replace(new RegExp(Mz(e)),"")]=a;else if(!Nz(o,"show")&&Nz(o,e)!==n){var s=Sz(o,e);"filter"===s&&"function"==typeof a||(r[s]=a)}})),r}function Tz(t,e){return Object.entries(t).reduce((function(t,n){var r=Ve(n,2),i=r[0],o=r[1];return i.startsWith("show")?t["show".concat(e).concat(i.slice(4))]=o:t["".concat(e).concat(Mz(i))]=o,t}),{})}function Az(t,e){void 0===e&&(e=["x","y","class","className"]);var n=["transform","transformOrigin","anchor","visibility","pointerEvents","zIndex","cursor","clipPath","clipPathTargets","offsetPath","offsetPathTargets","offsetDistance","draggable","droppable"],r={},i={};return Object.entries(t).forEach((function(t){var o=Ve(t,2),a=o[0],s=o[1];e.includes(a)||(-1!==n.indexOf(a)?i[a]=s:r[a]=s)})),[r,i]}function Cz(t,e){var n={YYYY:t.getFullYear(),MM:t.getMonth()+1,DD:t.getDate(),HH:t.getHours(),mm:t.getMinutes(),ss:t.getSeconds()},r=e;return Object.keys(n).forEach((function(t){var e=n[t];r=r.replace(t,"YYYY"===t?"".concat(e):"".concat(e).padStart(2,"0"))})),r}function Pz(t,e){if(e)try{var n=e.replace(/translate\(([+-]*[\d]+[%]*),[ ]*([+-]*[\d]+[%]*)\)/g,(function(e,n,r){return"translate(".concat(function(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,a=Ve([e,n].map((function(t,e){var n;return t.includes("%")?parseFloat((null===(n=t.match(/[+-]?([0-9]*[.])?[0-9]+/))||void 0===n?void 0:n[0])||"0")/100*(0===e?i:o):t})),2);return[a[0],a[1]]}(t,n,r),")")}));t.attr("transform",n)}catch(t){}}var Rz=function(t,e){null!=e?t.replaceChildren?Array.isArray(e)?t.replaceChildren.apply(t,We([],Ve(e),!1)):t.replaceChildren(e):(t.innerHTML="",Array.isArray(e)?e.forEach((function(e){return t.appendChild(e)})):t.appendChild(e)):t.innerHTML=""};function Dz(){IF(this,"hidden"!==this.attributes.visibility)}var Lz=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,$F({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return je(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=BF(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&&Dz.call(this)},e.prototype.update=function(t,e){var n;return this.attr($F({},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.prototype.getSubShapeStyle=function(t){return t.x,t.y,t.transform,t.transformOrigin,t.class,t.className,t.zIndex,Fe(t,["x","y","transform","transformOrigin","class","className","zIndex"])},e}(_l),_z=function(t,e,n){return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e],["Z"]]},Iz=_z,jz=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},Bz=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},Fz=Bz;var zz=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function Gz(t){var e=function(t){var e="default";if(qt(t)&&t instanceof Image)e="image";else if(Yt(t))e="symbol";else if(ne(t)){var n=new RegExp("data:(image|text)");e=t.match(n)?"base64":/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(t)?"url":"symbol"}return e}(t);return["base64","url","image"].includes(e)?"image":t&&"symbol"===e?"path":null}var Vz=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.render=function(t,n){var r=t.x,i=void 0===r?0:r,o=t.y,a=void 0===o?0:o,s=this.getSubShapeStyle(t),l=s.symbol,u=s.size,c=void 0===u?16:u,h=Fe(s,["symbol","size"]),d=Gz(l);nz(!!d,xz(n),(function(t){t.maybeAppendByClassName("marker",d).attr("className","marker ".concat(d,"-marker")).call((function(t){if("image"===d){var n=2*c;t.styles({img:l,width:n,height:n,x:i-c,y:a-c})}else{n=c/2;var r=Yt(l)?l:e.getSymbol(l);t.styles(Be({d:null==r?void 0:r(i,a,n)},h))}}))}))},e.MARKER_SYMBOL_MAP=new Map,e.registerSymbol=function(t,n){e.MARKER_SYMBOL_MAP.set(t,n)},e.getSymbol=function(t){return e.MARKER_SYMBOL_MAP.get(t)},e.getSymbols=function(){return Array.from(e.MARKER_SYMBOL_MAP.keys())},e}(Lz);function Wz(t,...e){return e.reduce(((t,e)=>n=>t(e(n))),t)}function Hz(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}Vz.registerSymbol("cross",(function(t,e,n){return[["M",t-n,e-n],["L",t+n,e+n],["M",t+n,e-n],["L",t-n,e+n]]})),Vz.registerSymbol("hyphen",(function(t,e,n){return[["M",t-n,e],["L",t+n,e]]})),Vz.registerSymbol("line",jz),Vz.registerSymbol("plus",(function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]})),Vz.registerSymbol("tick",(function(t,e,n){return[["M",t-n/2,e-n],["L",t+n/2,e-n],["M",t,e-n],["L",t,e+n],["M",t-n/2,e+n],["L",t+n/2,e+n]]})),Vz.registerSymbol("circle",_z),Vz.registerSymbol("point",Iz),Vz.registerSymbol("bowtie",(function(t,e,n){var r=n-1.5;return[["M",t-n,e-r],["L",t+n,e+r],["L",t+n,e-r],["L",t-n,e+r],["Z"]]})),Vz.registerSymbol("hexagon",(function(t,e,n){var r=n/2*Math.sqrt(3);return[["M",t,e-n],["L",t+r,e-n/2],["L",t+r,e+n/2],["L",t,e+n],["L",t-r,e+n/2],["L",t-r,e-n/2],["Z"]]})),Vz.registerSymbol("square",(function(t,e,n){return[["M",t-n,e-n],["L",t+n,e-n],["L",t+n,e+n],["L",t-n,e+n],["Z"]]})),Vz.registerSymbol("diamond",(function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]})),Vz.registerSymbol("triangle",(function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e+r],["L",t,e-r],["L",t+n,e+r],["Z"]]})),Vz.registerSymbol("triangle-down",(function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e-r],["L",t+n,e-r],["L",t,e+r],["Z"]]})),Vz.registerSymbol("line",jz),Vz.registerSymbol("dot",Bz),Vz.registerSymbol("dash",Fz),Vz.registerSymbol("smooth",(function(t,e,n){return[["M",t-n,e],["A",n/2,n/2,0,1,1,t,e],["A",n/2,n/2,0,1,0,t+n,e]]})),Vz.registerSymbol("hv",(function(t,e,n){return[["M",t-n-1,e-2.5],["L",t,e-2.5],["L",t,e+2.5],["L",t+n+1,e+2.5]]})),Vz.registerSymbol("vh",(function(t,e,n){return[["M",t-n-1,e+2.5],["L",t,e+2.5],["L",t,e-2.5],["L",t+n+1,e-2.5]]})),Vz.registerSymbol("hvh",(function(t,e,n){return[["M",t-(n+1),e+2.5],["L",t-n/2,e+2.5],["L",t-n/2,e-2.5],["L",t+n/2,e-2.5],["L",t+n/2,e+2.5],["L",t+n+1,e+2.5]]})),Vz.registerSymbol("vhv",(function(t,e){return[["M",t-5,e+2.5],["L",t-5,e],["L",t,e],["L",t,e-3],["L",t,e+3],["L",t+6.5,e+3]]}));const Yz=Math.sqrt(50),Uz=Math.sqrt(10),$z=Math.sqrt(2);function qz(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),o=r/10**i;return i>=0?(o>=Yz?10:o>=Uz?5:o>=$z?2:1)*10**i:-(10**-i)/(o>=Yz?10:o>=Uz?5:o>=$z?2:1)}const Xz=(t,e,n=5)=>{const r=[t,e];let i,o=0,a=r.length-1,s=r[o],l=r[a];return l<s&&([s,l]=[l,s],[o,a]=[a,o]),i=qz(s,l,n),i>0?(s=Math.floor(s/i)*i,l=Math.ceil(l/i)*i,i=qz(s,l,n)):i<0&&(s=Math.ceil(s*i)/i,l=Math.floor(l*i)/i,i=qz(s,l,n)),i>0?(r[o]=Math.floor(s/i)*i,r[a]=Math.ceil(l/i)*i):i<0&&(r[o]=Math.ceil(s*i)/i,r[a]=Math.floor(l*i)/i),r};function Kz(t){return!(ve(t)||(e=t,null===e)||Number.isNaN(t));var e}var Zz={exports:{}},Qz={exports:{}},Jz=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},tG=Array.prototype.concat,eG=Array.prototype.slice,nG=Qz.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];Jz(i)?e=tG.call(e,eG.call(i)):e.push(i)}return e};nG.wrap=function(t){return function(){return t(nG(arguments))}};var rG=Qz.exports,iG={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},oG=rG,aG=Object.hasOwnProperty,sG=Object.create(null);for(var lG in iG)aG.call(iG,lG)&&(sG[iG[lG]]=lG);var uG=Zz.exports={to:{},get:{}};function cG(t,e,n){return Math.min(Math.max(e,t),n)}function hG(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}uG.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=uG.get.hsl(t),n="hsl";break;case"hwb":e=uG.get.hwb(t),n="hwb";break;default:e=uG.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},uG.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;i[n]=parseInt(e.slice(o,o+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:aG.call(iG,e[1])?((i=iG[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=cG(i[n],0,255);return i[3]=cG(i[3],0,1),i},uG.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,cG(parseFloat(e[2]),0,100),cG(parseFloat(e[3]),0,100),cG(isNaN(n)?1:n,0,1)]}return null},uG.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,cG(parseFloat(e[2]),0,100),cG(parseFloat(e[3]),0,100),cG(isNaN(n)?1:n,0,1)]}return null},uG.to.hex=function(){var t=oG(arguments);return"#"+hG(t[0])+hG(t[1])+hG(t[2])+(t[3]<1?hG(Math.round(255*t[3])):"")},uG.to.rgb=function(){var t=oG(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},uG.to.rgb.percent=function(){var t=oG(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},uG.to.hsl=function(){var t=oG(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},uG.to.hwb=function(){var t=oG(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},uG.to.keyword=function(t){return sG[t.slice(0,3)]};var dG=E(Zz.exports);function fG(t,e,n){let r=n;return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function pG(t){const e=dG.get(t);if(!e)return null;const{model:n,value:r}=e;return"rgb"===n?r:"hsl"===n?function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100,i=t[3];if(0===n)return[255*r,255*r,255*r,i];const o=r<.5?r*(1+n):r+n-r*n,a=2*r-o;return[255*fG(a,o,e+1/3),255*fG(a,o,e),255*fG(a,o,e-1/3),i]}(r):null}const gG=(t,e)=>n=>t*(1-n)+e*n,vG=(t,e)=>"number"==typeof t&&"number"==typeof e?gG(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=pG(t),r=pG(e);return null===n||null===r?n?()=>t:()=>e:t=>{const e=new Array(4);for(let i=0;i<4;i+=1){const o=n[i],a=r[i];e[i]=o*(1-t)+a*t}const[i,o,a,s]=e;return`rgba(${Math.round(i)}, ${Math.round(o)}, ${Math.round(a)}, ${s})`}})(t,e):()=>t,mG=(t,e)=>{const n=gG(t,e);return t=>Math.round(n(t))};function yG({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function bG(t){return"object"==typeof t?t.valueOf():t}class xG extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=bG,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(yG({map:this.map,initKey:this.initKey},t))}has(t){return super.has(yG({map:this.map,initKey:this.initKey},t))}set(t,e){return super.set(function({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}({map:this.map,initKey:this.initKey},t),e)}delete(t){return super.delete(function({map:t,initKey:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}({map:this.map,initKey:this.initKey},t))}}class EG{constructor(t){this.options=ke({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=ke({},this.options,t),this.rescale(t)}rescale(t){}}const wG=Symbol("defaultUnknown");function kG(t,e,n){for(let r=0;r<e.length;r+=1)t.has(e[r])||t.set(n(e[r]),r)}function MG(t){const{value:e,from:n,to:r,mapper:i,notFoundReturn:o}=t;let a=i.get(e);if(void 0===a){if(o!==wG)return o;a=n.push(e)-1,i.set(e,a)}return r[a%r.length]}function SG(t){return t instanceof Date?t=>`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class NG extends EG{getDefaultOptions(){return{domain:[],range:[],unknown:wG}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&kG(this.domainIndexMap,this.getDomain(),this.domainKey),MG({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&kG(this.rangeIndexMap,this.getRange(),this.rangeKey),MG({value:this.rangeKey(t),mapper:this.rangeIndexMap,from:this.getRange(),to:this.getDomain(),notFoundReturn:this.options.unknown})}rescale(t){const[e]=this.options.domain,[n]=this.options.range;if(this.domainKey=SG(e),this.rangeKey=SG(n),!this.rangeIndexMap)return this.rangeIndexMap=new Map,void(this.domainIndexMap=new Map);t&&!t.range||this.rangeIndexMap.clear(),(!t||t.domain||t.compare)&&(this.domainIndexMap.clear(),this.sortedDomain=void 0)}clone(){return new NG(this.options)}getRange(){return this.options.range}getDomain(){if(this.sortedDomain)return this.sortedDomain;const{domain:t,compare:e}=this.options;return this.sortedDomain=e?[...t].sort(e):t,this.sortedDomain}}function OG(t){return Math.round(1e12*t)/1e12}function TG(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:a,align:s}=t,l=e.length,u=function(t,e){const n=e-t.length;return n>0?[...t,...new Array(n).fill(1)]:n<0?t.slice(0,e):t}(o,l),[c,h]=n,d=h-c,f=d/(2/l*r+1-1/l*i),p=f*i/l,g=f-l*p,v=function(t){const e=Math.min(...t);return t.map((t=>t/e))}(u),m=g/v.reduce(((t,e)=>t+e)),y=new xG(e.map(((t,e)=>{const n=v[e]*m;return[t,a?Math.floor(n):n]}))),b=new xG(e.map(((t,e)=>{const n=v[e]*m+p;return[t,a?Math.floor(n):n]}))),x=Array.from(b.values()).reduce(((t,e)=>t+e)),E=c+(d-(x-x/l*i))*s;let w=a?Math.round(E):E;const k=new Array(l);for(let t=0;t<l;t+=1){k[t]=OG(w);const n=e[t];w+=b.get(n)}return{valueBandWidth:y,valueStep:b,adjustedRange:k}}class AG extends NG{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:wG,flex:[]}}constructor(t){super(t)}clone(){return new AG(this.options)}getStep(t){return void 0===this.valueStep?1:"number"==typeof this.valueStep?this.valueStep:void 0===t?Array.from(this.valueStep.values())[0]:this.valueStep.get(t)}getBandWidth(t){return void 0===this.valueBandWidth?1:"number"==typeof this.valueBandWidth?this.valueBandWidth:void 0===t?Array.from(this.valueBandWidth.values())[0]:this.valueBandWidth.get(t)}getRange(){return this.adjustedRange}getPaddingInner(){const{padding:t,paddingInner:e}=this.options;return t>0?t:e}getPaddingOuter(){const{padding:t,paddingOuter:e}=this.options;return t>0?t:e}rescale(){super.rescale();const{align:t,domain:e,range:n,round:r,flex:i}=this.options,{adjustedRange:o,valueBandWidth:a,valueStep:s}=function(t){var e;const{domain:n}=t,r=n.length;if(0===r)return{valueBandWidth:void 0,valueStep:void 0,adjustedRange:[]};if(null===(e=t.flex)||void 0===e?void 0:e.length)return TG(t);const{range:i,paddingOuter:o,paddingInner:a,round:s,align:l}=t;let u,c,h=i[0];const d=i[1]-h,f=2*o,p=r-a;u=d/Math.max(1,f+p),s&&(u=Math.floor(u)),h+=(d-u*(r-a))*l,c=u*(1-a),s&&(h=Math.round(h),c=Math.round(c));const g=new Array(r).fill(0).map(((t,e)=>h+e*u));return{valueStep:u,valueBandWidth:c,adjustedRange:g}}({align:t,range:n,round:r,flex:i,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:e});this.valueStep=s,this.valueBandWidth=a,this.adjustedRange=o}}const CG=(t,e,n)=>{let r,i,o=t,a=e;if(o===a&&n>0)return[o];let s=qz(o,a,n);if(0===s||!Number.isFinite(s))return[];if(s>0){o=Math.ceil(o/s),a=Math.floor(a/s),i=new Array(r=Math.ceil(a-o+1));for(let t=0;t<r;t+=1)i[t]=(o+t)*s}else{s=-s,o=Math.ceil(o*s),a=Math.floor(a*s),i=new Array(r=Math.ceil(a-o+1));for(let t=0;t<r;t+=1)i[t]=(o+t)/s}return i},PG=(t,e,n)=>{const[r,i]=t,[o,a]=e;let s,l;return r<i?(s=Hz(r,i),l=n(o,a)):(s=Hz(i,r),l=n(a,o)),Wz(l,s)},RG=(t,e,n)=>{const r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),a=t[0]>t[r],s=a?[...t].reverse():t,l=a?[...e].reverse():e;for(let t=0;t<r;t+=1)i[t]=Hz(s[t],s[t+1]),o[t]=n(l[t],l[t+1]);return e=>{const n=function(t,e,n,r){let i=n||0,o=r||t.length;for(;i<o;){const n=Math.floor((i+o)/2);t[n]>e?o=n:i=n+1}return i}(t,e,1,r)-1,a=i[n];return Wz(o[n],a)(e)}},DG=(t,e,n,r)=>(Math.min(t.length,e.length)>2?RG:PG)(t,e,r?mG:n);class LG extends EG{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:gG,tickCount:5}}map(t){return Kz(t)?this.output(t):this.options.unknown}invert(t){return Kz(t)?this.input(t):this.options.unknown}nice(){if(!this.options.nice)return;const[t,e,n,...r]=this.getTickMethodOptions();this.options.domain=this.chooseNice()(t,e,n,...r)}getTicks(){const{tickMethod:t}=this.options,[e,n,r,...i]=this.getTickMethodOptions();return t(e,n,r,...i)}getTickMethodOptions(){const{domain:t,tickCount:e}=this.options;return[t[0],t[t.length-1],e]}chooseNice(){return Xz}rescale(){this.nice();const[t,e]=this.chooseTransforms();this.composeOutput(t,this.chooseClamp(t)),this.composeInput(t,e,this.chooseClamp(e))}chooseClamp(t){const{clamp:e,range:n}=this.options,r=this.options.domain.map(t),i=Math.min(r.length,n.length);return e?function(t,e){const n=e<t?e:t,r=t>e?t:e;return t=>Math.min(Math.max(n,t),r)}(r[0],r[i-1]):_e}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,a=DG(n.map(t),r,o,i);this.output=Wz(a,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=DG(i,r.map(t),gG);this.input=Wz(e,n,o)}}class _G extends LG{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:vG,tickMethod:CG,tickCount:5}}chooseTransforms(){return[_e,_e]}clone(){return new _G(this.options)}}var IG=function(t){function e(e){var n=this,r=e.style,i=Fe(e,["style"]);return(n=t.call(this,ke({},{type:"column"},Be({style:r},i)))||this).columnsGroup=new jl({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return je(e,t),e.prototype.render=function(){var t=this.attributes,e=t.columns,n=t.x,r=t.y;this.columnsGroup.style.transform="translate(".concat(n,", ").concat(r,")"),xz(this.columnsGroup).selectAll(".column").data(e.flat()).join((function(t){return t.append("rect").attr("className","column").each((function(t){this.attr(t)}))}),(function(t){return t.each((function(t){this.attr(t)}))}),(function(t){return t.remove()}))},e.prototype.update=function(t){this.attr($F({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(Rl),jG=function(t){function e(e){var n=this,r=e.style,i=Fe(e,["style"]);return(n=t.call(this,ke({},{type:"lines"},Be({style:r},i)))||this).linesGroup=n.appendChild(new jl),n.areasGroup=n.appendChild(new jl),n.render(),n}return je(e,t),e.prototype.render=function(){var t=this.attributes,e=t.lines,n=t.areas,r=t.x,i=t.y;this.style.transform="translate(".concat(r,", ").concat(i,")"),e&&this.renderLines(e),n&&this.renderAreas(n)},e.prototype.clear=function(){this.linesGroup.removeChildren(),this.areasGroup.removeChildren()},e.prototype.update=function(t){this.attr($F({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){xz(this.linesGroup).selectAll(".line").data(t).join((function(t){return t.append("path").attr("className","line").each((function(t){this.attr(t)}))}),(function(t){return t.each((function(t){this.attr(t)}))}),(function(t){return t.remove()}))},e.prototype.renderAreas=function(t){xz(this.linesGroup).selectAll(".area").data(t).join((function(t){return t.append("path").attr("className","area").each((function(t){this.attr(t)}))}),(function(t){return t.each((function(t){this.style(t)}))}),(function(t){return t.remove()}))},e}(Rl);function BG(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map((function(t,e){return We([e===n?"M":"L"],Ve(t),!1)}));return e?r.reverse():r}function FG(t,e){if(void 0===e&&(e=!1),t.length<=2)return BG(t);for(var n=[],r=t.length,i=0;i<r;i+=1){var o=e?t[r-i-1]:t[i];Ne(o,n.slice(-2))||n.push.apply(n,We([],Ve(o),!1))}var a=pz(n);return e?a.unshift(We(["M"],Ve(t[r-1]),!1)):a.unshift(We(["M"],Ve(t[0]),!1)),a}function zG(t,e,n){var r=me(t);return r.push(["L",e,n],["L",0,n],["Z"]),r}function GG(t){return 0===t.length?[0,0]:[ee(ue(t,(function(t){return ee(t)||0}))),te(le(t,(function(t){return te(t)||0})))]}function VG(t){for(var e=me(t),n=e[0].length,r=Ve([Array(n).fill(0),Array(n).fill(0)],2),i=r[0],o=r[1],a=0;a<e.length;a+=1)for(var s=e[a],l=0;l<n;l+=1)s[l]>=0?(s[l]+=i[l],i[l]=s[l]):(s[l]+=o[l],o[l]=s[l]);return e}var WG=function(t){function e(e){return t.call(this,e,{type:"line",x:0,y:0,width:200,height:20,isStack:!1,color:["#83daad","#edbf45","#d2cef9","#e290b3","#6f63f4"],smooth:!0,lineLineWidth:1,areaOpacity:0,isGroup:!1,columnLineWidth:1,columnStroke:"#fff",scale:1,spacing:0})||this}return je(e,t),Object.defineProperty(e.prototype,"rawData",{get:function(){var t=this.attributes.data;if(!t||0===(null==t?void 0:t.length))return[[]];var e=me(t);return ae(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?VG(this.rawData):this.rawData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scales",{get:function(){return this.createScales(this.data)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseline",{get:function(){var t=this.scales.y,e=Ve(t.getOptions().domain||[0,0],2),n=e[0],r=e[1];return r<0?t.map(r):t.map(n<0?0:n)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"containerShape",{get:function(){var t=this.attributes;return{width:t.width,height:t.height}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesStyle",{get:function(){var t=this,e=this.attributes,n=e.type,r=e.isStack,i=e.smooth;if("line"!==n)throw new Error("linesStyle can only be used in line type");var o=Oz(this.attributes,"area"),a=Oz(this.attributes,"line"),s=this.containerShape.width,l=this.data;if(0===l[0].length)return{lines:[],areas:[]};var u=this.scales,c=function(t,e){var n,r=e.x,i=e.y,o=Ve(i.getOptions().range||[0,0],2),a=o[0],s=o[1];return s>a&&(n=Ve([a,s],2),s=n[0],a=n[1]),t.map((function(t){return t.map((function(t,e){return[r.map(e),oe(i.map(t),s,a)]}))}))}(l,{type:"line",x:u.x,y:u.y}),h=[],d=this.baseline;return h=r?i?function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=t[i],a=FG(o),s=void 0;if(0===i)s=zG(a,e,n);else{var l=FG(t[i-1],!0),u=o[0];l[0][0]="L",s=We(We(We([],Ve(a),!1),Ve(l),!1),[We(["M"],Ve(u),!1),["Z"]],!1)}r.push(s)}return r}(c,s,d):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=BG(t[i]),a=void 0;if(0===i)a=zG(o,e,n);else{var s=BG(t[i-1],!0);s[0][0]="L",a=We(We(We([],Ve(o),!1),Ve(s),!1),[["Z"]],!1)}r.push(a)}return r}(c,s,d):function(t,e,n,r){return t.map((function(t){return zG(e?FG(t):BG(t),n,r)}))}(c,i,s,d),{lines:c.map((function(e,n){return Be({stroke:t.getColor(n),d:i?FG(e):BG(e)},a)})),areas:h.map((function(e,n){return Be({d:e,fill:t.getColor(n)},o)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=Oz(this.attributes,"column"),n=this.attributes,r=n.isStack,i=n.type,o=n.scale;if("column"!==i)throw new Error("columnsStyle can only be used in column type");var a=this.containerShape.height,s=this.rawData;if(!s)return{columns:[]};r&&(s=VG(s));var l=this.createScales(s),u=l.x,c=l.y,h=Ve(GG(s),2),d=h[0],f=h[1],p=new _G({domain:[0,f-(d>0?0:d)],range:[0,a*o]}),g=u.getBandWidth(),v=this.rawData;return{columns:s.map((function(n,i){return n.map((function(n,o){var a=g/s.length;return Be(Be({fill:t.getColor(i)},e),r?{x:u.map(o),y:c.map(n),width:g,height:p.map(v[i][o])}:{x:u.map(o)+a*i,y:n>=0?c.map(n):c.map(0),width:a,height:p.map(Math.abs(n))})}))}))}},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){var n,r,i;(n=e,r=".container",i="rect",n.querySelector(r)?xz(n).select(r):xz(n).append(i)).attr("className","container").node();var o=t.type,a=t.x,s=t.y,l="spark".concat(o),u=Be({x:a,y:s},"line"===o?this.linesStyle:this.columnsStyle);xz(e).selectAll(".spark").data([o]).join((function(t){return t.append((function(t){return"line"===t?new jG({className:l,style:u}):new IG({className:l,style:u})})).attr("className","spark ".concat(l))}),(function(t){return t.update(u)}),(function(t){return t.remove()}))},e.prototype.getColor=function(t){var e=this.attributes.color;return $t(e)?e[t%e.length]:Yt(e)?e.call(null,t):e},e.prototype.createScales=function(t){var e,n,r=this.attributes,i=r.type,o=r.scale,a=r.range,s=void 0===a?[]:a,l=r.spacing,u=this.containerShape,c=u.width,h=u.height,d=Ve(GG(t),2),f=d[0],p=d[1],g=new _G({domain:[null!==(e=s[0])&&void 0!==e?e:f,null!==(n=s[1])&&void 0!==n?n:p],range:[h,h*(1-o)]});return"line"===i?{type:i,x:new _G({domain:[0,t[0].length-1],range:[0,c]}),y:g}:{type:i,x:new AG({domain:t[0].map((function(t,e){return e})),range:[0,c],paddingInner:l,paddingOuter:l/2,align:.5}),y:g}},e.tag="sparkline",e}(Lz);function HG(t){if(!t)return{enter:!1,update:!1,exit:!1};var e=["enter","update","exit"],n=Object.fromEntries(Object.entries(t).filter((function(t){var n=Ve(t,1)[0];return!e.includes(n)})));return Object.fromEntries(e.map((function(e){return function(t){return"boolean"!=typeof t&&"enter"in t&&"update"in t&&"exit"in t}(t)?!1===t[e]?[e,!1]:[e,Be(Be({},t[e]),n)]:[e,n]})))}function YG(t,e){t?t.finished.then(e):e()}function UG(t,e){"update"in t?t.update(e):t.attr(e)}function $G(t,e,n){return 0===e.length?null:n?t.animate(e,n):(UG(t,{style:e.slice(-1)[0]}),null)}function qG(t,e,n){var r={},i={};return Object.entries(e).forEach((function(e){var n=Ve(e,2),o=n[0],a=n[1];if(!Ut(a)){var s=t.style[o]||t.parsedStyle[o]||0;s!==a&&(r[o]=s,i[o]=a)}})),n?$G(t,[r,i],Be({fill:"both"},n)):(UG(t,i),null)}function XG(t,e){return t.style.opacity||(t.style.opacity=1),qG(t,{opacity:0},e)}var KG={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},ZG={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},QG={x:0,y:0,orientation:"horizontal",showLabel:!0,type:"start"},JG=YF({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),tV=YF({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),eV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.render=function(t,e){var n=t.x,r=t.y,i=t.size,o=void 0===i?10:i,a=t.radius,s=void 0===a?o/4:a,l=t.orientation,u=Fe(t,["x","y","size","radius","orientation"]),c=o,h=2.4*c,d=xz(e).maybeAppendByClassName(tV.iconRect,"rect").styles(Be(Be({},u),{width:c,height:h,radius:s,x:n-c/2,y:r-h/2,transformOrigin:"center"})),f=n+1/3*c-c/2,p=n+2/3*c-c/2,g=r+1/4*h-h/2,v=r+3/4*h-h/2;d.maybeAppendByClassName("".concat(tV.iconLine,"-1"),"line").styles(Be({x1:f,x2:f,y1:g,y2:v},u)),d.maybeAppendByClassName("".concat(tV.iconLine,"-2"),"line").styles(Be({x1:p,x2:p,y1:g,y2:v},u)),"vertical"===l&&(d.node().style.transform="rotate(90)")},e}(Lz),nV=function(t){function e(e){return t.call(this,e,QG)||this}return je(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.x,i=n.y,o=n.showLabel,a=Oz(this.attributes,"label"),s=a.x,l=void 0===s?0:s,u=a.y,c=void 0===u?0:u,h=a.transform,d=a.transformOrigin,f=Ve(Az(Fe(a,["x","y","transform","transformOrigin"]),[]),2),p=f[0],g=f[1],v=xz(t).maybeAppendByClassName(tV.labelGroup,"g").styles(g),m=Be(Be({},ZG),p),y=m.text,b=Fe(m,["text"]);nz(!!o,v,(function(t){e.label=t.maybeAppendByClassName(tV.label,"text").styles(Be(Be({},b),{x:r+l,y:i+c,transform:h,transformOrigin:d,text:"".concat(y)})),e.label.on("mousedown",(function(t){t.stopPropagation()})),e.label.on("touchstart",(function(t){t.stopPropagation()}))}))},e.prototype.renderIcon=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.orientation,o=e.type,a=Be(Be({x:n,y:r,orientation:i},KG),Oz(this.attributes,"icon")),s=this.attributes.iconShape,l=void 0===s?function(){return new eV({style:a})}:s;xz(t).maybeAppendByClassName(tV.iconGroup,"g").selectAll(tV.icon.class).data([l]).join((function(t){return t.append("string"==typeof l?l:function(){return l(o)}).attr("className",tV.icon.name)}),(function(t){return t.update(a)}),(function(t){return t.remove()}))},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(Lz),rV=function(t){function e(e){var n=t.call(this,e,Be(Be(Be({x:0,y:0,animate:{duration:100,fill:"both"},brushable:!0,formatter:function(t){return t.toString()},handleSpacing:2,orientation:"horizontal",padding:0,autoFitLabel:!0,scrollable:!0,selectionFill:"#5B8FF9",selectionFillOpacity:.45,selectionZIndex:2,showHandle:!0,showLabel:!0,slidable:!0,trackFill:"#416180",trackLength:200,trackOpacity:.05,trackSize:20,trackZIndex:-1,values:[0,1],type:"range",selectionType:"select",handleIconOffset:0},Tz(QG,"handle")),Tz(KG,"handleIcon")),Tz(ZG,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(tz(e));var r=n.availableSpace,i=r.x,o=r.y,a=n.getBBox(),s=a.x,l=a.y;n.selectionStartPos=n.getRatio(n.prevPos-n.getOrientVal([i,o])-n.getOrientVal([+s,+l])),n.selectionWidth=0,document.addEventListener("pointermove",n.onDragging),document.addEventListener("pointerup",n.onDragEnd)}},n.onDragging=function(t){var e=n.attributes,r=e.slidable,i=e.brushable,o=e.type;t.stopPropagation();var a=n.getOrientVal(tz(t)),s=a-n.prevPos;if(s){var l=n.getRatio(s);switch(n.target){case"start":r&&n.setValuesOffset(l);break;case"end":r&&n.setValuesOffset(0,l);break;case"selection":r&&n.setValuesOffset(l,l);break;case"track":if(!i)return;n.selectionWidth+=l,"range"===o?n.innerSetValues([n.selectionStartPos,n.selectionStartPos+n.selectionWidth].sort(),!0):n.innerSetValues([0,n.selectionStartPos+n.selectionWidth],!0)}n.prevPos=a}},n.onDragEnd=function(){document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointerup",n.onDragEnd),n.target="",n.updateHandlesPosition(!1)},n.onValueChange=function(t){var e=n.attributes,r=e.onChange,i=e.type,o="range"===i?t:t[1],a="range"===i?n.getValues():n.getValues()[1],s=new Rs("valuechange",{detail:{oldValue:o,value:a}});n.dispatchEvent(s),null==r||r(a)},n.selectionStartPos=0,n.selectionWidth=0,n.prevPos=0,n.target="",n}return je(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return this.attributes.values},set:function(t){this.attributes.values=this.clampValues(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sparklineStyle",{get:function(){if("horizontal"!==this.attributes.orientation)return null;var t=Oz(this.attributes,"sparkline");return Be(Be({zIndex:0},this.availableSpace),t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t=this.attributes,e=t.trackLength,n=t.trackSize,r=Ve(this.getOrientVal([[e,n],[n,e]]),2);return{width:r[0],height:r[1]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes;t.x,t.y;var e=Ve(Ez(t.padding),4),n=e[0],r=e[1],i=e[2],o=e[3],a=this.shape;return{x:o,y:n,width:a.width-(o+r),height:a.height-(n+i)}},enumerable:!1,configurable:!0}),e.prototype.getValues=function(){return this.values},e.prototype.setValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1),this.attributes.values=t;var n=!1!==e&&this.attributes.animate;this.updateSelectionArea(n),this.updateHandlesPosition(n)},e.prototype.updateSelectionArea=function(t){var e=this.calcSelectionArea();this.foregroundGroup.selectAll(JG.selection.class).each((function(n,r){qG(this,e[r],t)}))},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&qG(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&qG(this.endHandle,this.getHandleStyle("end"),t))},e.prototype.innerSetValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1);var n=this.values,r=this.clampValues(t);this.attributes.values=r,this.setValues(r),e&&this.onValueChange(n)},e.prototype.renderTrack=function(t){var e=this.attributes,n=e.x,r=e.y,i=Oz(this.attributes,"track");this.trackShape=xz(t).maybeAppendByClassName(JG.track,"rect").styles(Be(Be({x:n,y:r},this.shape),i))},e.prototype.renderBrushArea=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.brushable;this.brushArea=xz(t).maybeAppendByClassName(JG.brushArea,"rect").styles(Be({x:n,y:r,fill:"transparent",cursor:i?"crosshair":"default"},this.shape))},e.prototype.renderSparkline=function(t){var e=this,n=this.attributes,r=n.x,i=n.y;nz("horizontal"===n.orientation,xz(t).maybeAppendByClassName(JG.sparklineGroup,"g"),(function(t){var n=Be(Be({},e.sparklineStyle),{x:r,y:i});t.maybeAppendByClassName(JG.sparkline,(function(){return new WG({style:n})})).update(n)}))},e.prototype.renderHandles=function(){var t,e=this,n=this.attributes,r=n.showHandle,i=n.type,o=r?"range"===i?["start","end"]:["end"]:[],a=this;null===(t=this.foregroundGroup)||void 0===t||t.selectAll(JG.handle.class).data(o.map((function(t){return{type:t}})),(function(t){return t.type})).join((function(t){return t.append((function(t){var n=t.type;return new nV({style:e.getHandleStyle(n)})})).each((function(t){var e=t.type;this.attr("class","".concat(JG.handle.name," ").concat(e,"-handle"));var n="".concat(e,"Handle");a[n]=this,this.addEventListener("pointerdown",a.onDragStart(e))}))}),(function(t){return t.each((function(t){var e=t.type;this.update(a.getHandleStyle(e))}))}),(function(t){return t.each((function(t){var e=t.type,n="".concat(e,"Handle");a[n]=void 0})).remove()}))},e.prototype.renderSelection=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.type,o=e.selectionType;this.foregroundGroup=xz(t).maybeAppendByClassName(JG.foreground,"g");var a=Oz(this.attributes,"selection"),s=function(t){return t.style("visibility",(function(t){return t.show?"visible":"hidden"})).style("cursor",(function(t){return"select"===o?"grab":"invert"===o?"crosshair":"default"})).styles(Be(Be({},a),{transform:"translate(".concat(n,", ").concat(r,")")}))},l=this;this.foregroundGroup.selectAll(JG.selection.class).data("value"===i?[]:this.calcSelectionArea().map((function(t,e){return{style:Be({},t),index:e,show:"select"===o?1===e:1!==e}})),(function(t){return t.index})).join((function(t){return t.append("rect").attr("className",JG.selection.name).call(s).each((function(t,e){var n=this;1===e?(l.selectionShape=xz(this),this.on("pointerdown",(function(t){n.attr("cursor","grabbing"),l.onDragStart("selection")(t)})),l.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),l.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),l.dispatchCustomEvent(this,"click","selectionClick"),this.addEventListener("pointerdown",(function(){n.attr("cursor","grabbing")})),this.addEventListener("pointerup",(function(){n.attr("cursor","pointer")})),this.addEventListener("pointerover",(function(){n.attr("cursor","pointer")}))):this.on("pointerdown",l.onDragStart("track"))}))}),(function(t){return t.call(s)}),(function(t){return t.remove()})),this.updateSelectionArea(!1),this.renderHandles()},e.prototype.render=function(t,e){this.renderTrack(e),this.renderSparkline(e),this.renderBrushArea(e),this.renderSelection(e)},e.prototype.clampValues=function(t,e){var n;void 0===e&&(e=4);var r=Ve(this.range,2),i=r[0],o=r[1],a=Ve(this.getValues().map((function(t){return dz(t,e)})),2),s=a[0],l=a[1],u=Ve(((Array.isArray(t)?t:[s,null!=t?t:l])||[s,l]).map((function(t){return dz(t,e)})),2),c=u[0],h=u[1];if("value"===this.attributes.type)return[0,oe(h,i,o)];c>h&&(c=(n=Ve([h,c],2))[0],h=n[1]);var d=h-c;return d>o-i?[i,o]:c<i?s===i&&l===h?[i,h]:[i,d+i]:h>o?l===o&&s===c?[c,o]:[o-d,o]:[c,h]},e.prototype.calcSelectionArea=function(t){var e=Ve(this.clampValues(t),2),n=e[0],r=e[1],i=this.availableSpace,o=i.x,a=i.y,s=i.width,l=i.height;return this.getOrientVal([[{y:a,height:l,x:o,width:n*s},{y:a,height:l,x:n*s+o,width:(r-n)*s},{y:a,height:l,x:r*s,width:(1-r)*s}],[{x:o,width:s,y:a,height:n*l},{x:o,width:s,y:n*l+a,height:(r-n)*l},{x:o,width:s,y:r*l,height:(1-r)*l}]])},e.prototype.calcHandlePosition=function(t){var e=this.attributes.handleIconOffset,n=this.availableSpace,r=n.x,i=n.y,o=n.width,a=n.height,s=Ve(this.clampValues(),2),l=s[0],u=s[1],c="start"===t?-e:e,h=("start"===t?l:u)*this.getOrientVal([o,a])+c;return{x:r+this.getOrientVal([h,o/2]),y:i+this.getOrientVal([a/2,h])}},e.prototype.inferTextStyle=function(t){return"horizontal"===this.attributes.orientation?{}:"start"===t?{transformOrigin:"left center",transform:"rotate(90)",textAlign:"start"}:"end"===t?{transformOrigin:"right center",transform:"rotate(90)",textAlign:"end"}:{}},e.prototype.calcHandleText=function(t){var e,n=this.attributes,r=n.type,i=n.orientation,o=n.formatter,a=n.autoFitLabel,s=Oz(this.attributes,"handle"),l=Oz(s,"label"),u=s.spacing,c=this.getHandleSize(),h=this.clampValues(),d=o("start"===t?h[0]:h[1]),f=new FF({style:Be(Be(Be({},l),this.inferTextStyle(t)),{text:d})}),p=f.getBBox(),g=p.width,v=p.height;if(f.destroy(),!a){if("value"===r)return{text:d,x:0,y:-v-u};var m=u+c+("horizontal"===i?g/2:0);return(e={text:d})["horizontal"===i?"x":"y"]="start"===t?-m:m,e}var y=0,b=0,x=this.availableSpace,E=x.width,w=x.height,k=this.calcSelectionArea()[1],M=k.x,S=k.y,N=k.width,O=k.height,T=u+c;if("horizontal"===i){var A=T+g/2;if("start"===t)y=M-T-g>0?-A:A;else y=E-M-N-T>g?A:-A}else{var C=v+T;b="start"===t?S-c>v?-C:T:w-(S+O)-c>v?C:-T}return{x:y,y:b,text:d}},e.prototype.getHandleLabelStyle=function(t){var e=Oz(this.attributes,"handleLabel");return Be(Be(Be({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=Oz(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return Be({cursor:n,shape:t,size:r},e)},e.prototype.getHandleStyle=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.showLabel,o=e.showLabelOnInteraction,a=e.orientation,s=this.calcHandlePosition(t),l=s.x,u=s.y,c=this.calcHandleText(t),h=i;return!i&&o&&(h=!!this.target),Be(Be(Be({},Tz(this.getHandleIconStyle(),"icon")),Tz(Be(Be({},this.getHandleLabelStyle(t)),c),"label")),{transform:"translate(".concat(l+n,", ").concat(u+r,")"),orientation:a,showLabel:h,type:t,zIndex:3})},e.prototype.getHandleSize=function(){var t=this.attributes,e=t.handleIconSize,n=t.width,r=t.height;return e||Math.floor((this.getOrientVal([+r,+n])+4)/2.4)},e.prototype.getOrientVal=function(t){var e=Ve(t,2),n=e[0],r=e[1];return"horizontal"===this.attributes.orientation?n:r},e.prototype.setValuesOffset=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=!1);var r=this.attributes.type,i=Ve(this.getValues(),2),o=[i[0]+("range"===r?t:0),i[1]+e].sort();n?this.setValues(o):this.innerSetValues(o,!0)},e.prototype.getRatio=function(t){var e=this.availableSpace,n=e.width,r=e.height;return t/this.getOrientVal([n,r])},e.prototype.dispatchCustomEvent=function(t,e,n){var r=this;t.on(e,(function(t){t.stopPropagation(),r.dispatchEvent(new Rs(n,{detail:t}))}))},e.prototype.bindEvents=function(){this.addEventListener("wheel",this.onScroll);var t=this.brushArea;this.dispatchCustomEvent(t,"click","trackClick"),this.dispatchCustomEvent(t,"pointerenter","trackMouseenter"),this.dispatchCustomEvent(t,"pointerleave","trackMouseleave"),t.on("pointerdown",this.onDragStart("track"))},e.prototype.onScroll=function(t){if(this.attributes.scrollable){var e=t.deltaX,n=t.deltaY||e,r=this.getRatio(n);this.setValuesOffset(r,r,!0)}},e.tag="slider",e}(Lz),iV={data:[],animate:{enter:!1,update:{duration:100,easing:"ease-in-out-sine",fill:"both"},exit:{duration:100,fill:"both"}},showArrow:!0,showGrid:!0,showLabel:!0,showLine:!0,showTick:!0,showTitle:!0,showTrunc:!1,dataThreshold:100,lineLineWidth:1,lineStroke:"black",crossPadding:10,titleFill:"black",titleFontSize:12,titlePosition:"lb",titleSpacing:0,titleTextAlign:"center",titleTextBaseline:"middle",lineArrow:function(){return new Hl({style:{d:[["M",10,10],["L",-10,0],["L",10,-10],["L",0,0],["L",10,10],["Z"]],fill:"black",transformOrigin:"center"}})},labelAlign:"parallel",labelDirection:"positive",labelFontSize:12,labelSpacing:0,gridConnect:"line",gridControlAngles:[],gridDirection:"positive",gridLength:0,gridType:"segment",lineArrowOffset:15,lineArrowSize:10,tickDirection:"positive",tickLength:5,tickLineWidth:1,tickStroke:"black",labelOverlap:[]};ke({},iV,{style:{type:"arc"}}),ke({},iV,{style:{}});var oV=YF({mainGroup:"main-group",gridGroup:"grid-group",grid:"grid",lineGroup:"line-group",line:"line",tickGroup:"tick-group",tick:"tick",tickItem:"tick-item",labelGroup:"label-group",label:"label",labelItem:"label-item",titleGroup:"title-group",title:"title",lineFirst:"line-first",lineSecond:"line-second"},"axis"),aV=YF({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function sV(t){return t.reduce((function(t,e,n){return t.push(We([0===n?"M":"L"],Ve(e),!1)),t}),[])}function lV(t,e,n){return"surround"===e.type?function(t,e,n){var r=e.connect,i=void 0===r?"line":r,o=e.center;if("line"===i)return sV(t);if(!o)return[];var a=cz(t[0],o),s=n?0:1;return t.reduce((function(t,e,n){return 0===n?t.push(We(["M"],Ve(e),!1)):t.push(We(["A",a,a,0,0,s],Ve(e),!1)),t}),[])}(t,e,n):sV(t)}function uV(t,e,n){var r=n.type,i=n.connect,o=n.center,a=n.closed?[["Z"]]:[],s=Ve([lV(t,n),lV(e.slice().reverse(),n,!0)],2),l=s[0],u=s[1],c=Ve([t[0],e.slice(-1)[0]],2),h=c[0],d=c[1],f=function(t,e){return[l,t,u,e,a].flat()};if("line"===i||"surround"===r)return f([We(["L"],Ve(d),!1)],[We(["L"],Ve(h),!1)]);if(!o)throw new Error("Arc grid need to specified center");var p=Ve([cz(d,o),cz(h,o)],2),g=p[0],v=p[1];return f([We(["A",g,g,0,0,1],Ve(d),!1),We(["L"],Ve(d),!1)],[We(["A",v,v,0,0,0],Ve(h),!1),We(["L"],Ve(h),!1)])}var cV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=Fe(t,["type","center","areaFill","closed"]),r=function(t){var e=t.data,n=void 0===e?[]:e;return t.closed?n.map((function(t){var e=t.points,n=Ve(e,1)[0];return Be(Be({},t),{points:We(We([],Ve(e),!1),[n],!1)})})):n}(t),i=xz(e).maybeAppendByClassName(aV.lineGroup,"g"),o=xz(e).maybeAppendByClassName(aV.regionGroup,"g"),a=function(t,e,n,r){var i=n.animate,o=n.isBillboard,a=e.map((function(t,e){return{id:t.id||"grid-line-".concat(e),d:lV(t.points,n)}}));return t.selectAll(aV.line.class).data(a,(function(t){return t.id})).join((function(t){return t.append("path").each((function(t,e){var n=WF(mz(Be({d:t.d},r)),[t,e,a]);this.attr(Be({class:aV.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:o},n))}))}),(function(t){return t.transition((function(t,e){return qG(this,WF(mz(Be({d:t.d},r)),[t,e,a]),i.update)}))}),(function(t){return t.transition((function(){var t=this,e=XG(this,i.exit);return YG(e,(function(){return t.remove()})),e}))})).transitions()}(i,r,t,n),s=function(t,e,n){var r=n.animate,i=n.connect,o=n.areaFill;if(e.length<2||!o||!i)return[];for(var a=Array.isArray(o)?o:[o,"transparent"],s=function(t){return a[t%a.length]},l=[],u=0;u<e.length-1;u++){var c=Ve([e[u].points,e[u+1].points],2),h=uV(c[0],c[1],n);l.push({d:h,fill:s(u)})}return t.selectAll(aV.region.class).data(l,(function(t,e){return e})).join((function(t){return t.append("path").each((function(t,e){var n=WF(t,[t,e,l]);this.attr(n)})).attr("className",aV.region.name)}),(function(t){return t.transition((function(t,e){return qG(this,WF(t,[t,e,l]),r.update)}))}),(function(t){return t.transition((function(){var t=this,e=XG(this,r.exit);return YG(e,(function(){return t.remove()})),e}))})).transitions()}(o,r,t);return We(We([],Ve(a),!1),Ve(s),!1)},e}(Lz);function hV(t,e){return Object.fromEntries(Object.entries(t).map((function(t){var n=Ve(t,2);return[n[0],WF(n[1],e)]})))}function dV(t,e){return e&&Yt(e)?t.filter(e):t}function fV(t,e){var n=e.startAngle;return(e.endAngle-n)*t+n}function pV(t,e){if("linear"===e.type){var n=Ve(e.startPos,2),r=n[0],i=n[1],o=Ve(e.endPos,2),a=Ve([o[0]-r,o[1]-i],2);return hz([a[0],a[1]])}var s=zF(fV(t,e));return[-Math.sin(s),Math.cos(s)]}function gV(t,e,n){return function(t,e){return e?[t[1],-t[0]]:[-t[1],t[0]]}(pV(t,n),"positive"!==e)}function vV(t,e){return gV(t,e.labelDirection,e)}function mV(t,e){return"linear"===e.type?function(t,e){var n=Ve(e.startPos,2),r=n[0],i=n[1],o=Ve(e.endPos,2),a=Ve([o[0]-r,o[1]-i],2);return[r+a[0]*t,i+a[1]*t]}(t,e):function(t,e){var n=e.radius,r=Ve(e.center,2),i=r[0],o=r[1],a=zF(fV(t,e));return[i+n*Math.cos(a),o+n*Math.sin(a)]}(t,e)}function yV(t){return 0===pV(0,t)[1]}function bV(t){return 0===pV(0,t)[0]}function xV(t,e){return e-t==360}function EV(t,e,n,r,i){var o=e-t,a=Ve([i,i],2),s=a[0],l=a[1],u=Ve([zF(t),zF(e)],2),c=u[0],h=u[1],d=function(t){return[n+i*Math.cos(t),r+i*Math.sin(t)]},f=Ve(d(c),2),p=f[0],g=f[1],v=Ve(d(h),2),m=v[0],y=v[1];if(xV(t,e)){var b=Ve(d((h+c)/2),2);return[["M",p,g],["A",s,l,0,1,0,b[0],b[1]],["A",s,l,0,1,0,m,y]]}var x=o>180?1:0,E=t>e?0:1;return"M".concat(p,",").concat(g,",A").concat(s,",").concat(l,",0,").concat(x,",").concat(E,",").concat(m,",").concat(y)}function wV(t,e,n,r){var i=e.startAngle,o=e.endAngle,a=e.center,s=e.radius;return t.selectAll(oV.line.class).data([{d:EV.apply(void 0,We(We([i,o],Ve(a),!1),[s],!1))}],(function(t,e){return e})).join((function(t){return t.append("path").attr("className",oV.line.name).styles(e).styles({d:function(t){return t.d}})}),(function(t){return t.transition((function(){var t=this,e=function(t,e,n,r){if(!r)return t.attr("__keyframe_data__",n),null;var i=r.duration,o=void 0===i?0:i,a=iz(e,n),s=Math.ceil(+o/16),l=new Array(s).fill(0).map((function(t,e,n){return{__keyframe_data__:a(e/(n.length-1))}}));return t.animate(l,Be({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return We(We([n,r],Ve(i),!1),[o],!1)}(this),We(We([i,o],Ve(a),!1),[s],!1),r.update);if(e){var n=function(){var e=Oe(t.attributes,"__keyframe_data__");t.style.d=EV.apply(void 0,We([],Ve(e),!1))};e.onframe=n,e.onfinish=n}return e})).styles(e)}),(function(t){return t.remove()})).styles(n).transitions()}function kV(t){var e=Ve(t,2),n=Ve(e[0],2),r=n[0],i=n[1],o=Ve(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function MV(t,e,n,r){var i=e.showTrunc,o=e.startPos,a=e.endPos,s=e.truncRange,l=e.lineExtension,u=Ve([o,a],2),c=Ve(u[0],2),h=c[0],d=c[1],f=Ve(u[1],2),p=f[0],g=f[1],v=Ve(l?function(t,e,n){void 0===n&&(n=[0,0]);var r=Ve([t,e,n],3),i=Ve(r[0],2),o=i[0],a=i[1],s=Ve(r[1],2),l=s[0],u=s[1],c=Ve(r[2],2),h=c[0],d=c[1],f=Ve([l-o,u-a],2),p=f[0],g=f[1],v=Math.sqrt(Math.pow(p,2)+Math.pow(g,2)),m=Ve([-h/v,d/v],2),y=m[0],b=m[1];return[y*p,y*g,b*p,b*g]}(o,a,l):new Array(4).fill(0),4),m=v[0],y=v[1],b=v[2],x=v[3],E=function(e){return t.selectAll(oV.line.class).data(e,(function(t,e){return e})).join((function(t){return t.append("line").attr("className",(function(t){return"".concat(oV.line.name," ").concat(t.className)})).styles(n).transition((function(t){return qG(this,kV(t.line),!1)}))}),(function(t){return t.styles(n).transition((function(t){return qG(this,kV(t.line),r.update)}))}),(function(t){return t.remove()})).transitions()};if(!i||!s)return E([{line:[[h+m,d+y],[p+b,g+x]],className:oV.line.name}]);var w=Ve(s,2),k=w[0],M=w[1],S=p-h,N=g-d,O=Ve([h+S*k,d+N*k],2),T=O[0],A=O[1],C=Ve([h+S*M,d+N*M],2),P=C[0],R=C[1],D=E([{line:[[h+m,d+y],[T,A]],className:oV.lineFirst.name},{line:[[P,R],[p+b,g+x]],className:oV.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),D}function SV(t,e,n){var r,i=e.type,o=Oz(e,"line");return r="linear"===i?MV(t,e,fz(o,"arrow"),n):wV(t,e,fz(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,a=n.showTrunc,s=n.lineArrow,l=n.lineArrowOffset,u=n.lineArrowSize;if(i="arc"===e?t.select(oV.line.class):a?t.select(oV.lineSecond.class):t.select(oV.line.class),!o||!s||"arc"===n.type&&xV(n.startAngle,n.endAngle)){var c=i.node();c&&(c.style.markerEnd=void 0)}else{var h=ez(s);h.attr(r),yz(h,u),i.style("markerEnd",h).style("markerEndOffset",-l)}}(t,i,e,o),r}function NV(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function OV(t,e){var n=e.gridLength;return t.map((function(t,r){var i=t.value,o=Ve(mV(i,e),2),a=o[0],s=o[1],l=Ve(oz(function(t,e){return gV(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[a,s],[a+l[0],s+l[1]]]}}))}function TV(t,e,n,r){var i=Oz(n,"grid"),o=i.type,a=i.areaFill,s=NV(n),l=dV(e,n.gridFilter),u="segment"===o?OV(l,n):function(t,e){var n=e.gridControlAngles,r=NV(e);if(!r)throw new Error("grid center is not provide");if(t.length<2)throw new Error("Invalid grid data");if(!n||0===n.length)throw new Error("Invalid gridControlAngles");var i=Ve(r,2),o=i[0],a=i[1];return t.map((function(t,r){var i=Ve(mV(t.value,e),2),s=i[0],l=i[1],u=Ve([s-o,l-a],2),c=u[0],h=u[1],d=[];return n.forEach((function(t){var e=zF(t),n=Ve([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=c*r-h*i+o,l=c*i+h*r+a;d.push([s,l])})),{points:d,id:r}}))}(l,n),c=Be(Be({},i),{center:s,areaFill:Yt(a)?l.map((function(t,e){return WF(a,[t,e,l])})):a,animate:r,data:u});return t.selectAll(oV.grid.class).data([1]).join((function(t){return t.append((function(){return new cV({style:c})})).attr("className",oV.grid.name)}),(function(t){return t.transition((function(){return this.update(c)}))}),(function(t){return t.remove()})).transitions()}var AV=function(){function t(t,e,n,r){this.set(t,e,n,r)}return Object.defineProperty(t.prototype,"left",{get:function(){return this.x1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this.defined("x2")&&this.defined("x1")?this.x2-this.x1:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.defined("y2")&&this.defined("y1")?this.y2-this.y1:void 0},enumerable:!1,configurable:!0}),t.prototype.rotatedPoints=function(t,e,n){var r=this,i=r.x1,o=r.y1,a=r.x2,s=r.y2,l=Math.cos(t),u=Math.sin(t),c=e-e*l+n*u,h=n-e*u-n*l;return[[l*i-u*s+c,u*i+l*s+h],[l*a-u*s+c,u*a+l*s+h],[l*i-u*o+c,u*i+l*o+h],[l*a-u*o+c,u*a+l*o+h]]},t.prototype.set=function(t,e,n,r){return n<t?(this.x2=t,this.x1=n):(this.x1=t,this.x2=n),r<e?(this.y2=e,this.y1=r):(this.y1=e,this.y2=r),this},t.prototype.defined=function(t){return this[t]!==Number.MAX_VALUE&&this[t]!==-Number.MAX_VALUE},t}();function CV(t,e){var n=t.getEulerAngles()||0;t.setEulerAngles(0);var r=t.getBounds(),i=Ve(r.min,2),o=i[0],a=i[1],s=Ve(r.max,2),l=s[0],u=s[1],c=t.getBBox(),h=c.width,d=c.height,f=0,p=0,g=o,v=a,m=ZF(t);if(m){d-=1.5;var y=m.style.textAlign,b=m.style.textBaseline;"center"===y?g=(o+l)/2:"right"!==y&&"end"!==y||(g=l),"middle"===b?v=(a+u)/2:"bottom"===b&&(v=u)}var x=Ve(Ez(e),4),E=x[0],w=void 0===E?0:E,k=x[1],M=void 0===k?0:k,S=x[2],N=void 0===S?w:S,O=x[3],T=new AV((f+=o)-(void 0===O?M:O),(p+=a)-w,f+h+M,p+d+N);return t.setEulerAngles(n),T.rotatedPoints(zF(n),g,v)}function PV(t,e){return e[0]<=Math.max(t[0][0],t[1][0])&&e[0]<=Math.min(t[0][0],t[1][0])&&e[1]<=Math.max(t[0][1],t[1][1])&&e[1]<=Math.min(t[0][1],t[1][1])}function RV(t,e,n){var r=(e[1]-t[1])*(n[0]-e[0])-(e[0]-t[0])*(n[1]-e[1]);return 0===r?0:r<0?2:1}function DV(t,e){return e.every((function(e){return function(t,e){var n=t.length;if(n<3)return!1;var r,i,o,a,s,l,u=[e,[9999,e[1]]],c=0,h=0;do{var d=[t[h],t[(h+1)%n]];if(i=u,o=void 0,a=void 0,s=void 0,l=void 0,o=RV((r=d)[0],r[1],i[0]),a=RV(r[0],r[1],i[1]),s=RV(i[0],i[1],r[0]),l=RV(i[0],i[1],r[1]),o!==a&&s!==l||0===o&&PV(r,i[0])||0===a&&PV(r,i[1])||0===s&&PV(i,r[0])||0===l&&PV(i,r[1])){if(0===RV(d[0],e,d[1]))return PV(d,e);c++}h=(h+1)%n}while(0!==h);return!!(1&c)}(t,e)}))}function LV(t,e){return[[t[0],t[1],t[2],t[3]],[t[2],t[3],t[4],t[5]],[t[4],t[5],t[6],t[7]],[t[6],t[7],t[0],t[1]]].some((function(t){return function(t,e){var n=Ve(t,4),r=n[0],i=n[1],o=n[2],a=n[3],s=Ve(e,4),l=s[0],u=s[1],c=o-r,h=a-i,d=s[2]-l,f=s[3]-u,p=c*f-d*h;if(0===p)return!1;var g=p>0,v=r-l,m=i-u,y=c*m-h*v;if(y<0===g)return!1;var b=d*m-f*v;return b<0!==g&&y>p!==g&&b>p!==g}(e,t)}))}function _V(t,e,n){var r,i,o=e.crossPadding,a=new Set,s=null,l=function(t,e){var n=t.type,r=t.labelDirection,i=t.crossSize;if(!i)return!1;if("arc"===n){var o=t.center,a=t.radius,s=Ve(o,2),l=s[0],u=s[1],c="negative"===r?0:i,h=-a-c,d=a+c,f=Ve(Ez(e),4),p=f[0],g=f[1],v=f[2],m=f[3];return new AV(l+h-m,u+h-p,l+d+g,u+d+v)}var y=Ve(t.startPos,2),b=y[0],x=y[1],E=Ve(t.endPos,2),w=E[0],k=E[1],M=Ve(bV(t)?[-e,0,e,0]:[0,e,0,-e],4),S=M[0],N=M[1],O=M[2],T=M[3],A=oz(vV(0,t),i),C=new AV(b,x,w,k);return C.x1+=T,C.y1+=S,C.x2+=N+A[0],C.y2+=O+A[1],C}(e,o),u=function(t){return!l||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,a=t.y2;return DV([[r,o],[i,o],[i,a],[r,a]],CV(e,n))}(l,t)},c=function(t,e){return!t||!t.firstChild||!function(t,e,n){var r,i,o=CV(t,n).flat(1),a=CV(e,n).flat(1),s=[[o[0],o[1],o[2],o[3]],[o[0],o[1],o[4],o[5]],[o[4],o[5],o[6],o[7]],[o[2],o[3],o[6],o[7]]];try{for(var l=Ge(s),u=l.next();!u.done;u=l.next())if(LV(a,u.value))return!0}catch(t){r={error:t}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}return!1}(t.firstChild,e.firstChild,Ez(n))};try{for(var h=Ge(t),d=h.next();!d.done;d=h.next()){var f=d.value;u(f)?!s||c(s,f)?s=f:(a.add(s),a.add(f)):a.add(f)}}catch(t){r={error:t}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}return Array.from(a)}function IV(t,e){return void 0===e&&(e={}),Ut(t)?0:"number"==typeof t?t:Math.floor(XF(t,e))}var jV=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter((function(t,e){return!(e%r)||(_F(t),!1)}))};var BV=new Map([["hide",function(t,e,n,r){var i=t.length,o=e.keepHeader,a=e.keepTail;if(!(i<=1||2===i&&o&&a)){var s,l,u,c=jV,h=function(t){return t.forEach(r.show),t},d=2,f=t.slice(),p=t.slice(),g=Math.min.apply(Math,We([1],Ve(t.map((function(t){return t.getBBox().width}))),!1));if("linear"===n.type&&(yV(n)||bV(n))){var v=wz(t[0]).left,m=wz(t[i-1]).right,y=Math.abs(m-v)||1;d=Math.max(Math.floor(i*g/y),d)}for(o&&(s=f.splice(0,1)[0]),a&&(l=f.splice(-1,1)[0],f.reverse()),h(f);d<t.length&&_V((u=l?We(We([l],Ve(p),!1),[s],!1):We([s],Ve(p),!1),u.filter(qF)),n,null==e?void 0:e.margin).length;){if(l&&!s&&d%2==0)f.splice(0,1).forEach(r.hide);else if(l&&s){f.splice(0,1).forEach(r.hide)}p=c(h(f),{seq:d}),d++}}}],["rotate",function(t,e,n,r){var i,o,a=e.optionalAngles,s=void 0===a?[0,45,90]:a,l=e.margin,u=e.recoverWhenFailed,c=void 0===u||u,h=t.map((function(t){return t.getLocalEulerAngles()})),d=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.rotate(t,+i)}))};try{for(var f=Ge(s),p=f.next();!p.done;p=f.next()){if(d(p.value),_V(t,n,l).length<1)return}}catch(t){i={error:t}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}c&&d(h)}],["ellipsis",function(t,e,n,r){if(!(t.length<=1)){var i=e.suffix,o=void 0===i?"...":i,a=e.minLength,s=e.maxLength,l=void 0===s?1/0:s,u=e.step,c=void 0===u?" ":u,h=e.margin,d=void 0===h?[0,0,0,0]:h,f=KF(r.getTextShape(t[0])),p=IV(c,f),g=a?IV(a,f):p,v=IV(l,f);(Ut(v)||v===1/0)&&(v=Math.max.apply(null,t.map((function(t){return t.getBBox().width}))));var m=t.slice(),y=Ve(d,4);y[0],y[1],y[2],y[3];for(var b=function(e){if(m.forEach((function(t){r.ellipsis(r.getTextShape(t),e,o)})),(m=_V(t,n,d)).length<1)return{value:void 0}},x=v;x>g+p;x-=p){var E=b(x);if("object"==typeof E)return E.value}}}],["wrap",function(t,e,n,r){var i=e.wordWrapWidth,o=void 0===i?50:i,a=e.maxLines,s=void 0===a?3:a,l=e.recoverWhenFailed,u=void 0===l||l,c=e.margin,h=void 0===c?[0,0,0,0]:c,d=t.map((function(t){return t.attr("maxLines")||1})),f=Math.min.apply(Math,We([],Ve(d),!1)),p=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&yV(t)?"negative"===n?"bottom":"top":"middle"}(n),g=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.wrap(t,o,i,p)}))};if(!(f>s)){for(var v=f;v<=s;v++)if(g(v),_V(t,n,h).length<1)return;u&&g(d)}}]]);function FV(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.reduce((function(t,e){return t*function(t){return"positive"===t?-1:1}(e)}),1)}function zV(t){for(var e=t;e<0;)e+=360;return Math.round(e%360)}function GV(t,e){var n=Ve(t,2),r=n[0],i=n[1],o=Ve(e,2),a=o[0],s=o[1],l=Ve([r*a+i*s,r*s-i*a],2),u=l[0],c=l[1];return Math.atan2(c,u)}function VV(t,e,n){var r,i=n.labelAlign;if(null===(r=e.style.transform)||void 0===r?void 0:r.includes("rotate"))return e.getLocalEulerAngles();var o=vV(t.value,n),a=pV(t.value,n);return"horizontal"===i?0:function(t){var e=(t+360)%180;return rz(e,-90,90)||(e+=180),e}(GF("perpendicular"===i?GV([1,0],o):GV([a[0]<0?-1:1,0],a)))}function WV(t,e,n){var r=n.type,i=n.labelAlign,o=vV(t,n),a=zV(e),s=zV(GF(GV([1,0],o))),l="center",u="middle";return"linear"===r?[90,270].includes(s)&&0===a?(l="center",u=1===o[1]?"top":"bottom"):s%180||![90,270].includes(a)?0===s?(rz(a,0,90,!1,!0)||rz(a,0,90)||rz(a,270,360))&&(l="start"):90===s?rz(a,0,90,!1,!0)?l="start":(rz(a,90,180)||rz(a,270,360))&&(l="end"):270===s?rz(a,0,90,!1,!0)?l="end":(rz(a,90,180)||rz(a,270,360))&&(l="start"):180===s&&(90===a?l="start":(rz(a,0,90)||rz(a,270,360))&&(l="end")):l="center":"parallel"===i?u=rz(s,0,180,!0)?"top":"bottom":"horizontal"===i?rz(s,90,270,!1)?l="end":(rz(s,270,360,!1)||rz(s,0,90))&&(l="start"):"perpendicular"===i&&(l=rz(s,90,270)?"end":"start"),{textAlign:l,textBaseline:u}}function HV(t,e,n){var r=n.showTick,i=n.tickLength,o=n.tickDirection,a=n.labelDirection,s=n.labelSpacing,l=e.indexOf(t),u=WF(s,[t,l,e]),c=Ve([vV(t.value,n),FV(a,o)],2),h=Ve(az(oz(c[0],u+(1===c[1]?WF(r?i:0,[t,l,e]):0)),mV(t.value,n)),2);return{x:h[0],y:h[1]}}function YV(t,e){"text"===t.nodeName&&t.attr(e)}function UV(t){!function(t,e,n){var r=e.labelOverlap,i=void 0===r?[]:r;i.length&&i.forEach((function(r){var i=r.type,o=BV.get(i);(function(t,e,n){return!(e.labelOverlap.length<1)&&("hide"===n?!function(t){for(var e=t;e;){if("offscreen"===e.className)return!0;e=e.parent}return!1}(t[0]):"rotate"===n?!t.some((function(t){var e;return!!(null===(e=t.attr("transform"))||void 0===e?void 0:e.includes("rotate"))})):"ellipsis"!==n&&"wrap"!==n||t.filter((function(t){return t.querySelector("text")})).length>1)})(t,e,i)&&(null==o||o(t,r,e,n))}))}(this.node().childNodes,t,{hide:_F,show:LF,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=WV(e.__data__.value,t,n),i=e.querySelector(oV.labelItem.class);i&&YV(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&JF(t,e||1/0,n)},wrap:function(t,e,n){var r,i;t&&(void 0===(r=n)&&(r=2),void 0===i&&(i="top"),QF(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector("text")}})}function $V(t,e,n,r,i){var o=n.indexOf(e),a=xz(t).append(function(t,e,n,r){var i=r.labelFormatter;return Yt(i)?function(){return ez(WF(i,[t,e,n,vV(t.value,r)]))}:function(){return ez(t.label||"")}}(e,o,n,i)).attr("className",oV.labelItem.name).node(),s=Ve(Az(hV(r,[e,o,n])),2),l=s[0],u=s[1],c=u.transform,h=Fe(u,["transform"]);Pz(a,c);var d=VV(e,a,i);return a.getLocalEulerAngles()||a.setLocalEulerAngles(d),YV(a,Be(Be({},WV(e.value,d,i)),l)),t.attr(h),a}function qV(t,e,n,r){var i=dV(e,n.labelFilter),o=Oz(n,"label");return t.selectAll(oV.label.class).data(i,(function(t,e){return e})).join((function(r){return r.append("g").attr("className",oV.label.name).transition((function(t){$V(this,t,e,o,n);var r=HV(t,e,n),i=r.x,a=r.y;return this.style.transform="translate(".concat(i,", ").concat(a,")"),null})).call((function(){UV.call(t,n)}))}),(function(i){return i.transition((function(t){var i=function(t,e,n,r){if(void 0===r&&(r="destroy"),function(t,e){return"text"===t.nodeName&&"text"===e.nodeName&&t.attributes.text===e.attributes.text}(t,e))return t.remove(),[null];var i=function(){"destroy"===r?t.destroy():"hide"===r&&_F(t),e.isVisible()&&LF(e)};if(!n)return i(),[null];var o=n.duration,a=void 0===o?0:o,s=n.delay,l=void 0===s?0:s,u=Math.ceil(+a/2),c=+a/4,h=Ve(t.getGeometryBounds().center,2),d=h[0],f=h[1],p=Ve(e.getGeometryBounds().center,2),g=Ve([(d+p[0])/2-d,(f+p[1])/2-f],2),v=g[0],m=g[1],y=t.style.opacity,b=void 0===y?1:y,x=e.style.opacity,E=void 0===x?1:x,w=t.style.transform||"",k=e.style.transform||"",M=t.animate([{opacity:b,transform:"translate(0, 0) ".concat(w)},{opacity:0,transform:"translate(".concat(v,", ").concat(m,") ").concat(w)}],Be(Be({fill:"both"},n),{duration:l+u+c})),S=e.animate([{opacity:0,transform:"translate(".concat(-v,", ").concat(-m,") ").concat(k),offset:.01},{opacity:E,transform:"translate(0, 0) ".concat(k)}],Be(Be({fill:"both"},n),{duration:u+c,delay:l+u-c}));return YG(S,i),[M,S]}(this.querySelector(oV.labelItem.class),$V(this,t,e,o,n),r.update),a=HV(t,e,n),s=a.x,l=a.y,u=qG(this,{transform:"translate(".concat(s,", ").concat(l,")")},r.update);return We(We([],Ve(i),!1),[u],!1)})).call((function(e){var r,i,o=Oe(e,"_transitions").flat().filter(qF);i=function(){UV.call(t,n)},0===(r=o).length?i():Promise.all(r.map((function(t){return null==t?void 0:t.finished}))).then(i)}))}),(function(t){return t.transition((function(){var t=this,e=XG(this.childNodes[0],r.exit);return YG(e,(function(){return xz(t).remove()})),e}))})).transitions()}function XV(t,e){return gV(t,e.tickDirection,e)}function KV(t,e,n,r,i){var o=Ve(function(t,e){var n=Ve(t,2);return[[0,0],[n[0]*e,n[1]*e]]}(r,WF(i.tickLength,[t,e,n])),2),a=Ve(o[0],2),s=a[0],l=a[1],u=Ve(o[1],2);return{x1:s,x2:u[0],y1:l,y2:u[1]}}function ZV(t,e,n,r,i,o){var a=function(t,e,n,r,i){var o=i.tickFormatter,a=XV(e.value,i),s="line";return Yt(o)&&(s=function(){return WF(o,[e,n,r,a])}),t.append(s).attr("className",oV.tickItem.name)}(xz(this),t,e,n,r);!function(t,e,n,r,i,o,a){var s=XV(t.value,o),l=KV(t,e,n,s,o),u=l.x1,c=l.x2,h=l.y1,d=l.y2,f=Ve(Az(hV(a,[t,e,n,s])),2),p=f[0],g=f[1];"line"===r.node().nodeName&&r.styles(Be({x1:u,x2:c,y1:h,y2:d},p)),i.attr(g),r.styles(p)}(t,e,n,a,this,r,i);var s=Ve(mV(t.value,r),2),l=s[0],u=s[1];return qG(this,{transform:"translate(".concat(l,", ").concat(u,")")},o)}var QV=YF({text:"text"},"title");function JV(t){return/\S+-\S+/g.test(t)?t.split("-").map((function(t){return t[0]})):t.length>2?[t[0]]:t.split("")}function tW(t,e){var n=Object.entries(e).reduce((function(e,n){var r=Ve(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e}),{});t.styles(n)}var eW=function(t){function e(e){return t.call(this,e,{text:"",width:0,height:0,fill:"#4a505a",fontWeight:"bold",fontSize:12,fontFamily:"sans-serif",inset:0,spacing:0,position:"top-left"})||this}return je(e,t),e.prototype.getAvailableSpace=function(){var t=this.attributes,e=t.width,n=t.height,r=t.position,i=t.spacing,o=t.inset,a=this.querySelector(QV.text.class);if(!a)return new VF(0,0,+e,+n);var s=a.getBBox(),l=s.width,u=s.height,c=Ve(Ez(i),4),h=c[0],d=c[1],f=c[2],p=c[3],g=Ve([0,0,+e,+n],4),v=g[0],m=g[1],y=g[2],b=g[3],x=JV(r);if(x.includes("i"))return new VF(v,m,y,b);x.forEach((function(t,r){var i,o,a,s;"t"===t&&(i=Ve(0===r?[u+f,+n-u-f]:[0,+n],2),m=i[0],b=i[1]),"r"===t&&(o=Ve([+e-l-p],1),y=o[0]),"b"===t&&(a=Ve([+n-u-h],1),b=a[0]),"l"===t&&(s=Ve(0===r?[l+d,+e-l-d]:[0,+e],2),v=s[0],y=s[1])}));var E=Ve(Ez(o),4),w=E[0],k=E[1],M=E[2],S=E[3],N=Ve([S+k,w+M],2),O=N[0],T=N[1];return new VF(v+S,m+w,y-O,b-T)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new VF(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=Fe(t,["width","height","position","spacing"]),i=Ve(Az(r),1)[0],o=function(t){var e,n,r,i,o=t,a=o.width,s=o.height,l=o.position,u=Ve([+a/2,+s/2],2),c=Ve([+u[0],+u[1],"center","middle"],4),h=c[0],d=c[1],f=c[2],p=c[3],g=JV(l);return g.includes("l")&&(h=(e=Ve([0,"start"],2))[0],f=e[1]),g.includes("r")&&(h=(n=Ve([+a,"end"],2))[0],f=n[1]),g.includes("t")&&(d=(r=Ve([0,"top"],2))[0],p=r[1]),g.includes("b")&&(d=(i=Ve([+s,"bottom"],2))[0],p=i[1]),{x:h,y:d,textAlign:f,textBaseline:p}}(t),a=o.x,s=o.y,l=o.textAlign,u=o.textBaseline;nz(!!r.text,xz(e),(function(t){n.title=t.maybeAppendByClassName(QV.text,"text").styles(i).call(tW,{x:a,y:s,textAlign:l,textBaseline:u}).node()}))},e}(Lz);function nW(t,e,n,r,i){var o=Ve(Az(Oz(r,"title")),2),a=o[0],s=o[1],l=s.transform,u=s.transformOrigin,c=Fe(s,["transform","transformOrigin"]);e.styles(c);var h=l||function(t,e,n){var r=2*t.getGeometryBounds().halfExtents[1];if("vertical"===e){if("left"===n)return"rotate(-90) translate(0, ".concat(r/2,")");if("right"===n)return"rotate(-90) translate(0, -".concat(r/2,")")}return""}(t.node(),a.direction,a.position);t.styles(Be(Be({},a),{transformOrigin:u})),Pz(t.node(),h);var d=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,a=JV(i),s=t.node().getLocalBounds(),l=Ve(s.min,2),u=l[0],c=l[1],h=Ve(s.halfExtents,2),d=h[0],f=h[1],p=Ve(e.node().getLocalBounds().halfExtents,2),g=p[0],v=p[1],m=Ve([u+d,c+f],2),y=m[0],b=m[1],x=Ve(Ez(o),4),E=x[0],w=x[1],k=x[2],M=x[3];if(["start","end"].includes(i)&&"linear"===n.type){var S=n.startPos,N=n.endPos,O=Ve("start"===i?[S,N]:[N,S],2),T=O[0],A=O[1],C=Ve(oz(hz([-A[0]+T[0],-A[1]+T[1]]),E),2),P=C[0],R=C[1];return{x:T[0]+P,y:T[1]+R}}return a.includes("t")&&(b-=f+v+E),a.includes("r")&&(y+=d+g+w),a.includes("l")&&(y-=d+g+M),a.includes("b")&&(b+=f+v+k),{x:y,y:b}}(xz(n._offscreen||n.querySelector(oV.mainGroup.class)),e,r),f=d.x,p=d.y;return qG(e.node(),{transform:"translate(".concat(f,", ").concat(p,")")},i)}function rW(t,e,n,r){var i=t.showLine,o=t.showTick,a=t.showLabel,s=nz(i,e.maybeAppendByClassName(oV.lineGroup,"g"),(function(e){return SV(e,t,r)}))||[],l=nz(o,e.maybeAppendByClassName(oV.tickGroup,"g"),(function(e){return function(t,e,n,r){var i=dV(e,n.tickFilter),o=Oz(n,"tick");return t.selectAll(oV.tick.class).data(i,(function(t){return t.id||t.label})).join((function(t){return t.append("g").attr("className",oV.tick.name).transition((function(t,e){return ZV.call(this,t,e,i,n,o,!1)}))}),(function(t){return t.transition((function(t,e){return this.removeChildren(),ZV.call(this,t,e,i,n,o,r.update)}))}),(function(t){return t.transition((function(){var t=this,e=XG(this.childNodes[0],r.exit);return YG(e,(function(){return t.remove()})),e}))})).transitions()}(e,n,t,r)}))||[],u=nz(a,e.maybeAppendByClassName(oV.labelGroup,"g"),(function(e){return qV(e,n,t,r)}))||[];return We(We(We([],Ve(s),!1),Ve(l),!1),Ve(u),!1).filter((function(t){return!!t}))}var iW=function(t){function e(e){return t.call(this,e,iV)||this}return je(e,t),e.prototype.render=function(t,e,n){var r=this,i=t.titleText,o=t.data,a=t.animate,s=t.showTitle,l=t.showGrid,u=t.dataThreshold,c=t.truncRange,h=function(t,e){if(t.length<=e)return t;for(var n=Math.floor(t.length/e),r=[],i=0;i<t.length;i+=n)r.push(t[i]);return r}(o,u).filter((function(t){var e=t.value;return!(c&&e>c[0]&&e<c[1])})),d=HG(void 0===n?a:n),f=nz(l,xz(e).maybeAppendByClassName(oV.gridGroup,"g"),(function(e){return TV(e,h,t,d)}))||[],p=xz(e).maybeAppendByClassName(oV.mainGroup,"g");i&&(!this.initialized&&d.enter||this.initialized&&d.update)&&rW(t,xz(this.offscreenGroup),h,HG(!1));var g=rW(t,xz(p.node()),h,d),v=nz(s,xz(e).maybeAppendByClassName(oV.titleGroup,"g"),(function(e){return function(t,e,n,r){var i=n.titleText;return t.selectAll(oV.title.class).data([{title:i}].filter((function(t){return!!t.title})),(function(t,e){return t.title})).join((function(o){return o.append((function(){return ez(i)})).attr("className",oV.title.name).transition((function(){return nW(xz(this),t,e,n,r.enter)}))}),(function(i){return i.transition((function(){return nW(xz(this),t,e,n,r.update)}))}),(function(t){return t.remove()})).transitions()}(e,r,t,d)}))||[];return We(We(We([],Ve(f),!1),Ve(g),!1),Ve(v),!1).flat().filter((function(t){return!!t}))},e}(Lz),oW=YF({prevBtnGroup:"prev-btn-group",prevBtn:"prev-btn",nextBtnGroup:"next-btn-group",nextBtn:"next-btn",pageInfoGroup:"page-info-group",pageInfo:"page-info",playWindow:"play-window",contentGroup:"content-group",controller:"controller",clipPath:"clip-path"},"navigator"),aW=function(t){function e(e){var n=t.call(this,e,{x:0,y:0,animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonD:zz(0,0,6),buttonSize:12,controllerPadding:5,controllerSpacing:5,formatter:function(t,e){return"".concat(t,"/").concat(e)},defaultPage:0,loop:!1,orientation:"horizontal",pageNumFill:"black",pageNumFontSize:12,pageNumTextAlign:"start",pageNumTextBaseline:"middle"})||this;return n.playState="idle",n.contentGroup=n.appendChild(new jl({class:oW.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new jl({class:oW.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return je(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return oe(t,0,Math.max(this.pageViews.length-1,0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.playWindow.children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"controllerShape",{get:function(){return this.totalPages>1?{width:55,height:0}:{width:0,height:0}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageShape",{get:function(){var t=Ve(function(t){var e;return(null===(e=t[0])||void 0===e?void 0:e.map((function(e,n){return t.map((function(t){return t[n]}))})))||[]}(this.pageViews.map((function(t){var e=t.getBBox();return[e.width,e.height]}))).map((function(t){return Math.max.apply(Math,We([],Ve(t),!1))})),2),e=t[0],n=t[1],r=this.attributes,i=r.pageWidth,o=void 0===i?e:i,a=r.pageHeight;return{pageWidth:o,pageHeight:void 0===a?n:a}},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.playWindow},Object.defineProperty(e.prototype,"totalPages",{get:function(){return this.pageViews.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currPage",{get:function(){return this.innerCurrPage},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e=t.prototype.getBBox.call(this),n=e.x,r=e.y,i=this.controllerShape,o=this.pageShape,a=o.pageWidth,s=o.pageHeight;return new VF(n,r,a+i.width,s)},e.prototype.goTo=function(t){var e=this,n=this.attributes.animate,r=this,i=r.currPage,o=r.playState,a=r.playWindow,s=r.pageViews;if("idle"!==o||t<0||s.length<=0||t>=s.length)return null;s[i].setLocalPosition(0,0),this.prepareFollowingPage(t);var l=Ve(this.getFollowingPageDiff(t),2),u=l[0],c=l[1];this.playState="running";var h=$G(a,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-u,", ").concat(-c,")")}],n);return YG(h,(function(){e.innerCurrPage=t,e.playState="idle",e.setVisiblePages([t]),e.updatePageInfo()})),h},e.prototype.prev=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n<=0)return null;var r=t?(n-1+e)%e:oe(n-1,0,e);return this.goTo(r)},e.prototype.next=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n>=e-1)return null;var r=t?(n+1)%e:oe(n+1,0,e);return this.goTo(r)},e.prototype.renderClipPath=function(t){var e=this.pageShape,n=e.pageWidth,r=e.pageHeight;n&&r?(this.clipPath=t.maybeAppendByClassName(oW.clipPath,"rect").styles({width:n,height:r}),this.contentGroup.attr("clipPath",this.clipPath.node())):this.contentGroup.style.clipPath=void 0},e.prototype.setVisiblePages=function(t){this.playWindow.children.forEach((function(e,n){t.includes(n)?LF(e):_F(e)}))},e.prototype.adjustControllerLayout=function(){var t=this,e=t.prevBtnGroup,n=t.nextBtnGroup,r=t.pageInfoGroup,i=this.attributes,o=i.orientation,a=i.controllerPadding,s=r.getBBox(),l=s.width;s.height;var u=Ve("horizontal"===o?[-180,0]:[-90,90],2),c=u[0],h=u[1];e.setLocalEulerAngles(c),n.setLocalEulerAngles(h);var d=e.getBBox(),f=d.width,p=d.height,g=n.getBBox(),v=g.width,m=g.height,y=Math.max(f,l,v),b="horizontal"===o?{offset:[[0,0],[f/2+a,0],[f+l+2*a,0]],textAlign:"start"}:{offset:[[y/2,-p-a],[y/2,0],[y/2,m+a]],textAlign:"center"},x=Ve(b.offset,3),E=Ve(x[0],2),w=E[0],k=E[1],M=Ve(x[1],2),S=M[0],N=M[1],O=Ve(x[2],2),T=O[0],A=O[1],C=b.textAlign,P=r.querySelector("text");P&&(P.style.textAlign=C),e.setLocalPosition(w,k),r.setLocalPosition(S,N),n.setLocalPosition(T,A)},e.prototype.updatePageInfo=function(){var t,e=this,n=e.currPage,r=e.pageViews,i=e.attributes.formatter;r.length<2||(null===(t=this.pageInfoGroup.querySelector(oW.pageInfo.class))||void 0===t||t.attr("text",i(n+1,r.length)),this.adjustControllerLayout())},e.prototype.getFollowingPageDiff=function(t){var e=this.currPage;if(e===t)return[0,0];var n=this.attributes.orientation,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,a=t<e?-1:1;return"horizontal"===n?[a*i,0]:[0,a*o]},e.prototype.prepareFollowingPage=function(t){var e=this.currPage,n=this.pageViews;if(this.setVisiblePages([t,e]),t!==e){var r=Ve(this.getFollowingPageDiff(t),2),i=r[0],o=r[1];n[t].setLocalPosition(i,o)}},e.prototype.renderController=function(t){var e=this,n=this.attributes.controllerSpacing,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,a=this.pageViews.length>=2,s=t.maybeAppendByClassName(oW.controller,"g");if(IF(s.node(),a),a){var l=Oz(this.attributes,"button"),u=Oz(this.attributes,"pageNum"),c=Ve(Az(l),2),h=c[0],d=c[1],f=h.size,p=Fe(h,["size"]),g=!s.select(oW.prevBtnGroup.class).node(),v=s.maybeAppendByClassName(oW.prevBtnGroup,"g").styles(d);this.prevBtnGroup=v.node();var m=v.maybeAppendByClassName(oW.prevBtn,"path"),y=s.maybeAppendByClassName(oW.nextBtnGroup,"g").styles(d);this.nextBtnGroup=y.node(),[m,y.maybeAppendByClassName(oW.nextBtn,"path")].forEach((function(t){t.styles(Be(Be({},p),{transformOrigin:"center"})),yz(t.node(),f)}));var b=s.maybeAppendByClassName(oW.pageInfoGroup,"g");this.pageInfoGroup=b.node(),b.maybeAppendByClassName(oW.pageInfo,"text").styles(u),this.updatePageInfo(),s.node().setLocalPosition(i+n,o/2),g&&(this.prevBtnGroup.addEventListener("click",(function(){e.prev()})),this.nextBtnGroup.addEventListener("click",(function(){e.next()})))}},e.prototype.render=function(t,e){var n=t.x,r=void 0===n?0:n,i=t.y,o=void 0===i?0:i;this.attr("transform","translate(".concat(r,", ").concat(o,")"));var a=xz(e);this.renderClipPath(a),this.renderController(a),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=ye((function(){return t.render(t.attributes,t)}),50);this.playWindow.addEventListener(Vs.INSERTED,e),this.playWindow.addEventListener(Vs.REMOVED,e)},e}(Lz);function sW(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}Vz.registerSymbol("hiddenHandle",(function(t,e,n){var r=1.4*n;return[["M",t-n,e-r],["L",t+n,e-r],["L",t+n,e+r],["L",t-n,e+r],["Z"]]})),Vz.registerSymbol("verticalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=t+.4*r;return[["M",t,e],["L",a,e+i],["L",t+r,e+i],["L",t+r,e-i],["L",a,e-i],["Z"],["M",a,e+o],["L",t+r-2,e+o],["M",a,e-o],["L",t+r-2,e-o]]})),Vz.registerSymbol("horizontalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=e+.4*r;return[["M",t,e],["L",t-i,a],["L",t-i,e+r],["L",t+i,e+r],["L",t+i,a],["Z"],["M",t-o,a],["L",t-o,e+r-2],["M",t+o,a],["L",t+o,e+r-2]]}));var lW=YF({layout:"flex",markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label",valueGroup:"value-group",value:"value",backgroundGroup:"background-group",background:"background"},"legend-category-item");var uW=function(t){function e(e){return t.call(this,e,{span:[1,1],marker:function(){return new Dl({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this}return je(e,t),Object.defineProperty(e.prototype,"showValue",{get:function(){var t=this.attributes.valueText;return!!t&&("string"==typeof t||"number"==typeof t?""!==t:"function"==typeof t||""!==t.attr("text"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"actualSpace",{get:function(){var t=this.labelGroup,e=this.valueGroup,n=this.attributes.markerSize,r=t.node().getBBox(),i=r.width,o=r.height,a=e.node().getBBox(),s=a.width,l=a.height;return{markerWidth:n,labelWidth:i,valueWidth:s,height:Math.max(n,o,l)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"span",{get:function(){var t=this.attributes.span;if(!t)return[1,1];var e=Ve(Ez(t),2),n=e[0],r=e[1],i=this.showValue?r:0,o=n+i;return[n/o,i/o]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t,e=this.attributes,n=e.markerSize,r=e.width,i=this.actualSpace,o=i.markerWidth,a=i.height,s=this.actualSpace,l=s.labelWidth,u=s.valueWidth,c=Ve(this.spacing,2),h=c[0],d=c[1];if(r){var f=r-n-h-d,p=Ve(this.span,2);l=(t=Ve([p[0]*f,p[1]*f],2))[0],u=t[1]}return{width:o+l+u+h+d,height:a,markerWidth:o,labelWidth:l,valueWidth:u}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes.spacing;if(!t)return[0,0];var e=Ve(Ez(t),2),n=e[0],r=e[1];return this.showValue?[n,r]:[n,0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layout",{get:function(){var t=this.shape,e=t.markerWidth,n=t.labelWidth,r=t.valueWidth,i=t.width,o=t.height,a=Ve(this.spacing,2),s=a[0];return{height:o,width:i,markerWidth:e,labelWidth:n,valueWidth:r,position:[e/2,e+s,e+n+s+a[1]]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleSize",{get:function(){var t=function(t){var e=t.querySelector(lW.marker.class);return e?e.style:{}}(this.markerGroup.node()),e=this.attributes,n=e.markerSize,r=e.markerStrokeWidth,i=void 0===r?t.strokeWidth:r,o=e.markerLineWidth,a=void 0===o?t.lineWidth:o,s=e.markerStroke,l=void 0===s?t.stroke:s,u=+(i||a||(l?1:0))*Math.sqrt(2),c=this.markerGroup.node().getBBox(),h=c.width,d=c.height;return(1-u/Math.max(h,d))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes.marker,r=Oz(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(lW.markerGroup,"g").style("zIndex",0),nz(!!n,this.markerGroup,(function(){var t,i=e.markerGroup.node(),o=null===(t=i.childNodes)||void 0===t?void 0:t[0],a="string"==typeof n?new Vz({style:{symbol:n},className:lW.marker.name}):n();o?a.nodeName===o.nodeName?o instanceof Vz?o.update(Be(Be({},r),{symbol:n})):(!function(t,e){var n,r,i=e.attributes;try{for(var o=Ge(Object.entries(i)),a=o.next();!a.done;a=o.next()){var s=Ve(a.value,2),l=s[0],u=s[1];"id"!==l&&"className"!==l&&t.attr(l,u)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(o,a),xz(o).styles(r)):(o.remove(),xz(a).attr("className",lW.marker.name).styles(r),i.appendChild(a)):(a instanceof Vz||xz(a).attr("className",lW.marker.name).styles(r),i.appendChild(a)),e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]);var s=yz(e.markerGroup.node(),e.scaleSize);e.markerGroup.node().style._transform="scale(".concat(s,")")}))},e.prototype.renderLabel=function(t){var e=Oz(this.attributes,"label"),n=e.text,r=Fe(e,["text"]);this.labelGroup=t.maybeAppendByClassName(lW.labelGroup,"g").style("zIndex",0),this.labelGroup.maybeAppendByClassName(lW.label,(function(){return ez(n)})).styles(r)},e.prototype.renderValue=function(t){var e=this,n=Oz(this.attributes,"value"),r=n.text,i=Fe(n,["text"]);this.valueGroup=t.maybeAppendByClassName(lW.valueGroup,"g").style("zIndex",0),nz(this.showValue,this.valueGroup,(function(){e.valueGroup.maybeAppendByClassName(lW.value,(function(){return ez(r)})).styles(i)}))},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,i=Oz(this.attributes,"background");this.background=t.maybeAppendByClassName(lW.backgroundGroup,"g").style("zIndex",-1),this.background.maybeAppendByClassName(lW.background,"rect").styles(Be({width:n,height:r},i))},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=Ve(t.position,3),o=i[0],a=i[1],s=i[2],l=r/2;this.markerGroup.styles({transform:"translate(".concat(o,", ").concat(l,")").concat(this.markerGroup.node().style._transform)}),this.labelGroup.styles({transform:"translate(".concat(a,", ").concat(l,")")}),JF(this.labelGroup.select(lW.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({transform:"translate(".concat(s,", ").concat(l,")")}),JF(this.valueGroup.select(lW.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=xz(e),r=t.x,i=void 0===r?0:r,o=t.y,a=void 0===o?0:o;n.styles({transform:"translate(".concat(i,", ").concat(a,")")}),this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.adjustLayout()},e}(Lz),cW=YF({page:"item-page",navigator:"navigator",item:"item"},"items"),hW=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},dW=function(t){function e(e){var n=t.call(this,e,{data:[],gridRow:1/0,gridCol:void 0,padding:0,width:1e3,height:100,rowPadding:0,colPadding:0,layout:"flex",orientation:"horizontal",click:Le,mouseenter:Le,mouseleave:Le})||this;return n.navigatorShape=[0,0],n}return je(e,t),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.navigator.getContainer()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){var t=this.attributes,e=t.gridRow,n=t.gridCol,r=t.data;if(!e&&!n)throw new Error("gridRow and gridCol can not be set null at the same time");return e&&n?[e,n]:e?[e,r.length]:[r.length,n]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderData",{get:function(){var t=this.attributes,e=t.data,n=t.layout,r=Oz(this.attributes,"item"),i=e.map((function(t,i){var o=t.id,a=void 0===o?i:o,s=t.label,l=t.value;return{id:"".concat(a),index:i,style:Be({layout:n,labelText:s,valueText:l},Object.fromEntries(Object.entries(r).map((function(n){var r=Ve(n,2);return[r[0],WF(r[1],[t,i,e])]}))))}}));return i},enumerable:!1,configurable:!0}),e.prototype.getGridLayout=function(){var t=this,e=this.attributes,n=e.orientation,r=e.width,i=e.rowPadding,o=e.colPadding,a=Ve(this.navigatorShape,1)[0],s=Ve(this.grid,2),l=s[0],u=s[1],c=u*l,h=0;return this.pageViews.children.map((function(e,s){var d,f,p=Math.floor(s/c),g=s%c,v=t.ifHorizontal(u,l),m=[Math.floor(g/v),g%v];"vertical"===n&&m.reverse();var y=Ve(m,2),b=y[0],x=y[1],E=(r-a-(u-1)*o)/u,w=e.getBBox().height,k=Ve([0,0],2),M=k[0],S=k[1];return"horizontal"===n?(M=(d=Ve([h,b*(w+i)],2))[0],S=d[1],h=x===u-1?0:h+E+o):(M=(f=Ve([x*(E+o),h],2))[0],S=f[1],h=b===l-1?0:h+w+i),{page:p,index:s,row:b,col:x,pageIndex:g,width:E,height:w,x:M,y:S}}))},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=Ve(this.navigatorShape,1)[0],a=Ve(this.grid,2),s=a[0],l=a[1],u=Ve([e-o,n],2),c=u[0],h=u[1],d=Ve([0,0,0,0,0,0,0,0],8),f=d[0],p=d[1],g=d[2],v=d[3],m=d[4],y=d[5],b=d[6],x=d[7];return this.pageViews.children.map((function(t,e){var n,o,a,u,d=t.getBBox(),E=d.width,w=d.height,k=0===b?0:i,M=b+k+E;return M<=c&&hW(m,(function(t){return t<l}))?(n=Ve([b+k,x,M],3),f=n[0],p=n[1],b=n[2],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}):(o=Ve([y+1,0,0,x+w+r],4),y=o[0],m=o[1],b=o[2],(x=o[3])+w<=h&&hW(y,(function(t){return t<s}))?(a=Ve([b,x,E],3),f=a[0],p=a[1],b=a[2],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}):(u=Ve([0,0,E,0,g+1,0,0,0],8),f=u[0],p=u[1],b=u[2],x=u[3],g=u[4],v=u[5],y=u[6],m=u[7],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}))}))},Object.defineProperty(e.prototype,"itemsLayout",{get:function(){this.navigatorShape=[0,0];var t="grid"===this.attributes.layout?this.getGridLayout:this.getFlexLayout,e=t.call(this);return e.slice(-1)[0].page>0?(this.navigatorShape=[55,0],t.call(this)):e},enumerable:!1,configurable:!0}),e.prototype.ifHorizontal=function(t,e){return sW(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(cW.item.class).forEach((function(e){t.appendChild(e)})),t.querySelectorAll(cW.page.class).forEach((function(e){t.removeChild(e).destroy()}))},e.prototype.renderItems=function(t){var e=this.attributes,n=e.click,r=e.mouseenter,i=e.mouseleave;this.flattenPage(t);var o=this.dispatchCustomEvent.bind(this);xz(t).selectAll(cW.item.class).data(this.renderData,(function(t){return t.id})).join((function(t){return t.append((function(t){var e=t.style;return new uW({style:e})})).attr("className",cW.item.name).on("click",(function(){null==n||n(this),o("itemClick",{item:this})})).on("pointerenter",(function(){null==r||r(this),o("itemMouseenter",{item:this})})).on("pointerleave",(function(){null==i||i(this),o("itemMouseleave",{item:this})}))}),(function(t){return t.each((function(t){var e=t.style;this.update(e)}))}),(function(t){return t.remove()}))},e.prototype.relayoutNavigator=function(){var t,e=this.attributes,n=e.layout,r=e.width,i=(null===(t=this.pageViews.children[0])||void 0===t?void 0:t.getBBox().height)||0,o=Ve(this.navigatorShape,2),a=o[0],s=o[1];this.navigator.update("grid"===n?{pageWidth:r-a,pageHeight:i-s}:{})},e.prototype.adjustLayout=function(){var t,e,n=this,r=Object.entries((t=this.itemsLayout,e="page",t.reduce((function(t,n){return(t[n[e]]=t[n[e]]||[]).push(n),t}),{}))).map((function(t){var e=Ve(t,2);return{page:e[0],layouts:e[1]}})),i=We([],Ve(this.navigator.getContainer().children),!1);r.forEach((function(t){var e=t.layouts,r=n.pageViews.appendChild(new jl({className:cW.page.name}));e.forEach((function(t){var e=t.x,n=t.y,o=t.index,a=t.width,s=t.height,l=i[o];r.appendChild(l),Te(l,"__layout__",t),l.update({x:e,y:n,width:a,height:s})}))})),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes.orientation,n=Oz(this.attributes,"nav"),r=$F({orientation:e},n),i=this;return t.selectAll(cW.navigator.class).data(["nav"]).join((function(t){return t.append((function(){return new aW({style:r})})).attr("className",cW.navigator.name).each((function(){i.navigator=this}))}),(function(t){return t.each((function(){this.update(r)}))}),(function(t){return t.remove()})),this.navigator},e.prototype.getBBox=function(){return this.navigator.getBBox()},e.prototype.render=function(t,e){var n=this.attributes.data;if(n&&0!==n.length){var r=this.renderNavigator(xz(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new Rs(t,{detail:e});this.dispatchEvent(n)},e}(Lz),fW=YF({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),pW={showLabel:!0,formatter:function(t){return t.toString()},markerSize:25,markerStroke:"#c5c5c5",markerFill:"#fff",markerLineWidth:1,labelFontSize:12,labelFill:"#c5c5c5",labelText:"",orientation:"vertical",spacing:0};!function(t){function e(e){return t.call(this,e,pW)||this}je(e,t),e.prototype.render=function(t,e){var n=xz(e).maybeAppendByClassName(fW.markerGroup,"g");this.renderMarker(n);var r=xz(e).maybeAppendByClassName(fW.labelGroup,"g");this.renderLabel(r)},e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.orientation,i=n.markerSymbol,o=void 0===i?sW(r,"horizontalHandle","verticalHandle"):i;nz(!!o,t,(function(t){var n=Oz(e.attributes,"marker"),r=Be({symbol:o},n);e.marker=t.maybeAppendByClassName(fW.marker,(function(){return new Vz({style:r})})).update(r)}))},e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.showLabel,i=n.orientation,o=n.spacing,a=void 0===o?0:o,s=n.formatter;nz(r,t,(function(t){var n,r=Oz(e.attributes,"label"),o=r.text,l=Fe(r,["text"]),u=(null===(n=t.select(fW.marker.class))||void 0===n?void 0:n.node().getBBox())||{},c=u.width,h=void 0===c?0:c,d=u.height,f=Ve(sW(i,[0,(void 0===d?0:d)+a,"center","top"],[h+a,0,"start","middle"]),4),p=f[0],g=f[1],v=f[2],m=f[3];t.maybeAppendByClassName(fW.label,"text").styles(Be(Be({},l),{x:p,y:g,text:s(o).toString(),textAlign:v,textBaseline:m}))}))}}(Lz);var gW={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},vW=$F({},gW,{});$F({},gW,Tz(pW,"handle"),{color:["#d0e3fa","#acc7f6","#8daaf2","#6d8eea","#4d73cd","#325bb1","#5a3e75","#8c3c79","#e23455","#e7655b"],indicatorBackgroundFill:"#262626",indicatorLabelFill:"white",indicatorLabelFontSize:12,indicatorVisibility:"hidden",labelAlign:"value",labelDirection:"positive",labelSpacing:5,showHandle:!0,showIndicator:!0,showLabel:!0,slidable:!0,titleText:"",type:"continuous"});var mW=YF({title:"title",titleGroup:"title-group",items:"items",itemsGroup:"items-group",contentGroup:"content-group",ribbonGroup:"ribbon-group",ribbon:"ribbon",handlesGroup:"handles-group",handle:"handle",startHandle:"start-handle",endHandle:"end-handle",labelGroup:"label-group",label:"label",indicator:"indicator"},"legend"),yW=function(t){function e(e){return t.call(this,e,vW)||this}return je(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,i=r.showTitle,o=r.titleText,a=Ve(Az(Oz(this.attributes,"title")),2),s=a[0],l=a[1];this.titleGroup=t.maybeAppendByClassName(mW.titleGroup,"g").styles(l);var u=Be(Be({width:e,height:n},s),{text:i?o:""});this.title=this.titleGroup.maybeAppendByClassName(mW.title,(function(){return new eW({style:u})})).update(u)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,i=e.width,o=e.height,a=Ve(Az(Oz(this.attributes,"title",!0)),2),s=a[0],l=a[1],u=Be(Be({},s),{width:i,height:o,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName(mW.itemsGroup,"g").styles(Be(Be({},l),{transform:"translate(".concat(n,", ").concat(r,")")}));var c=this;this.itemsGroup.selectAll(mW.items.class).data(["items"]).join((function(t){return t.append((function(){return new dW({style:u})})).attr("className",mW.items.name).each((function(){c.items=xz(this)}))}),(function(t){return t.update(u)}),(function(t){return t.remove()}))},e.prototype.adjustLayout=function(){if(this.attributes.showTitle){var t=this.title.node().getAvailableSpace(),e=t.x,n=t.y;this.itemsGroup.node().style.transform="translate(".concat(e,", ").concat(n,")")}},Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes,e=t.showTitle,n=t.width,r=t.height;return e?this.title.node().getAvailableSpace():new VF(0,0,n,r)},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e,n,r=null===(e=this.title)||void 0===e?void 0:e.node(),i=null===(n=this.items)||void 0===n?void 0:n.node();return r&&i?function(t,e){var n=t.attributes,r=n.position,i=n.spacing,o=n.inset,a=n.text,s=t.getBBox(),l=e.getBBox(),u=JV(r),c=Ve(Ez(a?i:0),4),h=c[0],d=c[1],f=c[2],p=c[3],g=Ve(Ez(o),4),v=g[0],m=g[1],y=g[2],b=g[3],x=Ve([p+d,h+f],2),E=x[0],w=x[1],k=Ve([b+m,v+y],2),M=k[0],S=k[1];if("l"===u[0])return new VF(s.x,s.y,l.width+s.width+E+M,Math.max(l.height+S,s.height));if("t"===u[0])return new VF(s.x,s.y,Math.max(l.width+M,s.width),l.height+s.height+w+S);var N=Ve([e.attributes.width||l.width,e.attributes.height||l.height],2),O=N[0],T=N[1];return new VF(l.x,l.y,O+s.width+E+M,T+s.height+w+S)}(r,i):t.prototype.getBBox.call(this)},e.prototype.render=function(t,e){var n=this.attributes,r=n.width,i=n.height,o=n.x,a=void 0===o?0:o,s=n.y,l=void 0===s?0:s,u=xz(e);e.style.transform="translate(".concat(a,", ").concat(l,")"),this.renderTitle(u,r,i),this.renderItems(u,this.availableSpace),this.adjustLayout()},e}(Lz),bW={backgroundFill:"#262626",backgroundLineCap:"round",backgroundLineWidth:1,backgroundStroke:"#333",backgroundZIndex:-1,formatter:function(t){return t.toString()},labelFill:"#fff",labelFontSize:12,labelTextBaseline:"middle",padding:[2,4],position:"right",radius:0,zIndex:999},xW=YF({background:"background",labelGroup:"label-group",label:"label"},"indicator"),EW=function(t){function e(e){var n=t.call(this,e,bW)||this;return n.point=[0,0],n.group=n.appendChild(new jl({})),n.isMutationObserved=!0,n}return je(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=Ve(Ez(t.padding),4),r=n[0],i=n[1],o=n[2],a=n[3],s=this.label.node().getLocalBounds(),l=s.min,u=s.max,c=new VF(l[0]-a,l[1]-r,u[0]+i-l[0]+a,u[1]+o-l[1]+r),h=this.getPath(e,c),d=Oz(this.attributes,"background");this.background=xz(this.group).maybeAppendByClassName(xW.background,"path").styles(Be(Be({},d),{d:h})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=Ve(Az(Oz(this.attributes,"label")),2),i=r[0],o=r[1];i.text;var a=Fe(i,["text"]);(this.label=xz(this.group).maybeAppendByClassName(xW.labelGroup,"g").styles(o),n)&&this.label.maybeAppendByClassName(xW.label,(function(){return ez(e(n))})).style("text",e(n).toString()).selectAll("text").styles(a)},e.prototype.adjustLayout=function(){var t=Ve(this.point,2),e=t[0],n=t[1],r=this.attributes,i=r.x,o=r.y;this.group.attr("transform","translate(".concat(i-e,", ").concat(o-n,")"))},e.prototype.getPath=function(t,e){var n=this.attributes.radius,r=e.x,i=e.y,o=e.width,a=e.height,s=[["M",r+n,i],["L",r+o-n,i],["A",n,n,0,0,1,r+o,i+n],["L",r+o,i+a-n],["A",n,n,0,0,1,r+o-n,i+a],["L",r+n,i+a],["A",n,n,0,0,1,r,i+a-n],["L",r,i+n],["A",n,n,0,0,1,r+n,i],["Z"]],l={top:4,right:6,bottom:0,left:2}[t],u=this.createCorner([s[l].slice(-2),s[l+1].slice(-2)]);return s.splice.apply(s,We([l+1,1],Ve(u),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=kz.apply(void 0,We([],Ve(t),!1)),r=Ve(t,2),i=Ve(r[0],2),o=i[0],a=i[1],s=Ve(r[1],2),l=s[0],u=s[1],c=Ve(n?[l-o,[o,l]]:[u-a,[a,u]],2),h=c[0],d=Ve(c[1],2),f=d[0],p=d[1],g=h/2,v=e*(h/Math.abs(h)),m=v/2,y=v*Math.sqrt(3)/2*.8,b=Ve([f,f+g-m,f+g,f+g+m,p],5),x=b[0],E=b[1],w=b[2],k=b[3],M=b[4];return n?(this.point=[w,a-y],[["L",x,a],["L",E,a],["L",w,a-y],["L",k,a],["L",M,a]]):(this.point=[o+y,w],[["L",o,x],["L",o,E],["L",o+y,w],["L",o,k],["L",o,M]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?_F(this):LF(this)},e.prototype.bindEvents=function(){this.label.on(Vs.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(Lz);function wW(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 kW={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function MW(t){var e;void 0===t&&(t="");var n=wW(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)]=Be({flex:1},kW),e[".".concat(n.VALUE)]=Be({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},kW),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 SW=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=wW(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:MW(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return je(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,i=void 0===r?"":r,o=t.color,a=void 0===o?"black":o,s=t.index,l=Fe(t,["name","color","index"]),u=Be({name:i,color:a,index:null!=s?s:e},l);return An(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,u))}))},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=An(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:Rz(this.element,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,l=wW(r.prefixCls),u=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(u.innerHTML=r.title,u.getElementsByClassName(l.TITLE)[0].innerHTML=i):null===(e=null===(t=u.getElementsByClassName(l.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var c=this.HTMLTooltipItemsElements,h=document.createElement("ul");h.className=l.LIST,Rz(h,c);var d=this.element.querySelector(".".concat(l.LIST));d?d.replaceWith(h):u.appendChild(h)}!function(t,e){Object.entries(e).forEach((function(e){var n=Ve(e,2),r=n[0],i=n[1];We([t],Ve(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(":"),";")}),""))}))}))}(u,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,l=a.height,u=[-s/2,-l/2];return i.forEach((function(t){var e=Ve(u,2),n=e[0],i=e[1],a=Ve(o[t],2),c=a[0],h=a[1];u=[n+(s/2+r[0])*c,i+(l/2+r[1])*h]})),u},e.prototype.setOffsetPosition=function(t){var e=Ve(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=void 0===o?0:o,s=i.y,l=void 0===s?0:s,u=i.container,c=u.x,h=u.y;this.element.style.left="".concat(+a+c+n,"px"),this.element.style.top="".concat(+l+h+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=Ve(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=i.y,s=i.bounding,l=i.position;if(!s)return[n,r];var u=this.element,c=u.offsetWidth,h=u.offsetHeight,d=Ve([+o+n,+a+r],2),f=d[0],p=d[1],g={left:"right",right:"left",top:"bottom",bottom:"top"},v=s.x,m=s.y,y={left:f<v,right:f+c>v+s.width,top:p<m,bottom:p+h>m+s.height},b=[];l.split("-").forEach((function(t){y[t]?b.push(g[t]):b.push(t)}));var x=b.join("-");return this.getRelativeOffsetFromCursor(x)},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 VF(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}(Lz),NW=function(t){function e(n){var r=t.call(this,$F({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new Xl({})),r.label=r.background.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Ez(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=Oz(this.attributes,"label");xz(this.label).maybeAppend(".label",(function(){return ez(e)})).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=Ve(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3],a=t.width,s=t.height,l=a+o+r,u=s+n+i,c=Oz(this.attributes,"background"),h=this.style,d=h.width,f=void 0===d?0:d,p=h.height,g=void 0===p?0:p,v=h.selected;this.background.attr(Be(Be({},c),{width:Math.max(l,f),height:Math.max(u,g),fill:v?this.selectedColor:"#fff"})),this.label.attr({transform:"translate(".concat(o,", ").concat((u-s)/2,")")})},e.prototype.render=function(){this.renderLabel(),this.renderBackground()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("pointerenter",(function(){t.style.selected||t.background.attr("fill",t.hoverColor)})),this.addEventListener("pointerleave",(function(){t.style.selected||t.background.attr("fill",t.style.backgroundFill)}));var e=this;this.addEventListener("click",(function(){var n=t.style,r=n.label,i=n.value,o=n.onClick;null==o||o(i,{label:r,value:i},e)}))},e.defaultOptions={style:{value:"",label:"",cursor:"pointer"}},e}(Lz),OW=function(t){function e(n){var r,i,o=t.call(this,$F({},e.defaultOptions,n))||this;o.currentValue=null===(r=e.defaultOptions.style)||void 0===r?void 0:r.defaultValue,o.isPointerInSelect=!1,o.select=o.appendChild(new Xl({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new Xl({className:"dropdown"}));var a=o.style.defaultValue;return a&&(null===(i=o.style.options)||void 0===i?void 0:i.some((function(t){return t.value===a})))&&(o.currentValue=a),o}return je(e,t),e.prototype.setValue=function(t){this.currentValue=t,this.render()},e.prototype.getValue=function(){return this.currentValue},Object.defineProperty(e.prototype,"dropdownPadding",{get:function(){return Ez(this.style.dropdownPadding)},enumerable:!1,configurable:!0}),e.prototype.renderSelect=function(){var t,e=this,n=this.style,r=n.x,i=n.y,o=n.width,a=n.height,s=n.bordered,l=n.showDropdownIcon,u=Oz(this.attributes,"select"),c=Oz(this.attributes,"placeholder");this.select.attr(Be(Be({x:r,y:i,width:o,height:a},u),{fill:"#fff",strokeWidth:s?1:0}));var h=this.dropdownPadding;l&&xz(this.select).maybeAppend(".dropdown-icon","path").style("d","M-5,-3.5 L0,3.5 L5,-3.5").style("transform","translate(".concat(r+o-10-h[1]-h[3],", ").concat(i+a/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var d=null===(t=this.style.options)||void 0===t?void 0:t.find((function(t){return t.value===e.currentValue})),f=Be({x:r+h[3]},c);xz(this.select).selectAll(".placeholder").data(d?[]:[1]).join((function(t){return t.append("text").attr("className","placeholder").styles(f).style("y",(function(){var t=this.getBBox();return i+(a-t.height)/2}))}),(function(t){return t.styles(f)}),(function(t){return t.remove()}));var p=Oz(this.attributes,"optionLabel"),g=Be({x:r+h[3]},p);xz(this.select).selectAll(".value").data(d?[d]:[]).join((function(t){return t.append((function(t){return ez(t.label)})).attr("className","value").styles(g).style("y",(function(){var t=this.getBBox();return i+(a-t.height)/2}))}),(function(t){return t.styles(g)}),(function(t){return t.remove()}))},e.prototype.renderDropdown=function(){var t,e,n=this,r=this.style,i=r.x,o=r.y,a=r.width,s=r.height,l=r.options,u=r.onSelect,c=r.open,h=Oz(this.attributes,"dropdown"),d=Oz(this.attributes,"option"),f=this.dropdownPadding;xz(this.dropdown).maybeAppend(".dropdown-container","g").attr("className","dropdown-container").selectAll(".dropdown-item").data(l,(function(t){return t.value})).join((function(t){return t.append((function(t){return new NW({className:"dropdown-item",style:Be(Be(Be({},t),d),{width:a-f[1]-f[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==u||u(t,e,r),n.dispatchEvent(new Rs("change",{detail:{value:t,option:e,item:r}})),_F(n.dropdown)}})})})).each((function(t,e){var n,r=(null===(n=this.parentNode)||void 0===n?void 0:n.children).reduce((function(t,n,r){return r<e&&(t+=n.getBBox().height),t}),0);this.attr("transform","translate(".concat(f[3],", ").concat(f[0]+r,")"))}))}),(function(t){return t.update((function(t){return{selected:t.value===n.currentValue}}))}),(function(t){return t.remove()}));var p=null===(e=null===(t=this.dropdown.getElementsByClassName("dropdown-container"))||void 0===t?void 0:t[0])||void 0===e?void 0:e.getBBox(),g=h.spacing;this.dropdown.attr(Be({transform:"translate(".concat(i,", ").concat(o+s+g,")"),width:p.width+f[1]+f[3],height:p.height+f[0]+f[2]},h)),!c&&_F(this.dropdown)},e.prototype.render=function(){this.renderSelect(),this.renderDropdown()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("click",(function(t){t.stopPropagation()})),this.select.addEventListener("click",(function(){"visible"===t.dropdown.style.visibility?_F(t.dropdown):LF(t.dropdown)})),this.addEventListener("pointerenter",(function(){t.isPointerInSelect=!0})),this.addEventListener("pointerleave",(function(){t.isPointerInSelect=!1})),null===document||void 0===document||document.addEventListener("click",(function(){t.isPointerInSelect||_F(t.dropdown)}))},e.defaultOptions={style:{x:0,y:0,width:140,height:32,options:[],bordered:!0,defaultValue:"",selectRadius:8,selectStroke:"#d9d9d9",showDropdownIcon:!0,placeholderText:"请选择",placeholderFontSize:12,placeholderTextBaseline:"top",placeholderFill:"#c2c2c2",dropdownFill:"#fff",dropdownStroke:"#d9d9d9",dropdownRadius:8,dropdownShadowBlur:4,dropdownShadowColor:"rgba(0, 0, 0, 0.08)",dropdownPadding:8,dropdownSpacing:10,optionPadding:[8,12],optionFontSize:12,optionTextBaseline:"top",optionBackgroundFill:"#fff",optionBackgroundRadius:4,optionLabelFontSize:12,optionLabelTextBaseline:"top"}},e}(Lz),TW=function(t){function e(n){var r=t.call(this,$F({},{style:{backgroundOpacity:e.backgroundOpacities.default}},e.defaultOptions,n))||this;return r.showBackground=!0,r.background=r.appendChild(new Xl({})),r.icon=r.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"BaseIcon"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineWidth",{get:function(){return Math.log10(this.attributes.size)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return Ez(this.attributes.size/5)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"iconSize",{get:function(){var t=this.attributes.size,e=Ve(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3];return Math.max(t-Math.max(o+r,n+i),2*this.lineWidth+1)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.size,i=r/2,o=Oz(this.attributes,"background");this.background.attr(Be({x:e-i,y:n-i,width:r,height:r},o))},e.prototype.showIndicator=function(){if(this.label){var t=this.attributes.size,e=this.background.getBBox(),n=e.x,r=e.y;this.indicator.update({x:n+t/2,y:r-5,labelText:this.label,visibility:"visible"})}},e.prototype.hideIndicator=function(){this.indicator.update({visibility:"hidden"})},e.prototype.connectedCallback=function(){var e;t.prototype.connectedCallback.call(this);var n=this.attributes.size,r=this.background.getBBox(),i=r.x,o=r.y,a=null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView;a&&(this.indicator=a.appendChild(new EW({style:{x:i+n/2,y:o-n/2,visibility:"hidden",position:"top",radius:3,zIndex:100}})))},e.prototype.disconnectedCallback=function(){this.indicator.destroy()},e.prototype.render=function(){this.renderIcon(),this.showBackground&&this.renderBackground()},e.prototype.bindEvents=function(){var t=this,n=this.attributes.onClick;if(this.addEventListener("click",(function(){null==n||n(t)})),this.showBackground){var r=function(){return t.background.attr({opacity:e.backgroundOpacities.default})};this.addEventListener("pointerenter",(function(){t.background.attr({opacity:e.backgroundOpacities.hover}),t.showIndicator()})),this.addEventListener("pointerleave",(function(){r(),t.hideIndicator()})),this.addEventListener("pointerdown",(function(){t.background.attr({opacity:e.backgroundOpacities.active})})),this.addEventListener("pointerup",(function(){r()}))}},e.tag="IconBase",e.defaultOptions={style:{x:0,y:0,size:10,color:"#565758",backgroundRadius:4,backgroundFill:"#e2e2e2"}},e.backgroundOpacities={default:0,hover:.8,active:1},e}(Lz),AW=function(t,e){return void 0===e&&(e="#565758"),new Hl({style:{fill:e,d:"M ".concat(t,",").concat(t," L -").concat(t,",0 L ").concat(t,",-").concat(t," Z"),transformOrigin:"center"}})},CW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.arcPath=function(t,e,n){var r=Ve([n,n],2),i=r[0],o=r[1],a=function(r){return[t+n*Math.cos(r),e+n*Math.sin(r)]},s=Ve(a(-5/4*Math.PI),2),l=s[0],u=s[1],c=Ve(a(1/4*Math.PI),2),h=c[0],d=c[1];return"M".concat(l,",").concat(u,",A").concat(i,",").concat(o,",0,1,1,").concat(h,",").concat(d)},Object.defineProperty(e.prototype,"label",{get:function(){return"重置"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o+.5;xz(this.icon).maybeAppend(".reset","path").styles({stroke:r,lineWidth:o,d:this.arcPath(e,n,i/2-o),markerStart:AW(a,r)})},e}(TW),PW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快退"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e-o,n],[e,n+a],[e,n],[e+o,n-a],[e+o,n+a],[e,n]];xz(this.icon).maybeAppend(".backward","polygon").styles({points:s,fill:r})},e}(TW),RW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快进"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e+o,n],[e,n+a],[e,n],[e-o,n-a],[e-o,n+a],[e,n]];xz(this.icon).maybeAppend(".forward","polygon").styles({points:s,fill:r})},e}(TW),DW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"播放"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3*Math.pow(3,.5)*.8,a=[[e+o,n],[e-o/2,n-i/2*.8],[e-o/2,n+i/2*.8],[e+o,n]];xz(this.icon).maybeAppend(".play","polygon").styles({points:a,fill:r})},e}(TW),LW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"暂停"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3,a=[[e-o,n-i/2],[e-o,n+i/2],[e-o/2,n+i/2],[e-o/2,n-i/2],[e-o,n-i/2],[e+o/2,n-i/2],[e+o/2,n+i/2],[e+o,n+i/2],[e+o,n-i/2]];xz(this.icon).maybeAppend(".pause","polygon").styles({points:a,fill:r})},e}(TW),_W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"范围时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o;xz(this.icon).maybeAppend(".left-line","line").styles({x1:e-i/2,y1:n-i/2,x2:e-i/2,y2:n+i/2,stroke:r,lineWidth:o}),xz(this.icon).maybeAppend(".right-line","line").styles({x1:e+i/2,y1:n-i/2,x2:e+i/2,y2:n+i/2,stroke:r,lineWidth:o}),xz(this.icon).maybeAppend(".left-arrow","line").styles({x1:e,y1:n,x2:e-i/2+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:AW(2*o,r)}),xz(this.icon).maybeAppend(".right-arrow","line").styles({x1:e,y1:n,x2:e+i/2-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:AW(2*o,r)})},e}(TW),IW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"单一时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;xz(this.icon).maybeAppend(".line","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o});var a=o;xz(this.icon).maybeAppend(".left-arrow","line").styles({x1:e-i/2-2*a,y1:n,x2:e-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:AW(2*o,r)}),xz(this.icon).maybeAppend(".right-arrow","line").styles({x1:e+i/2+2*a,y1:n,x2:e+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:AW(2*o,r)})},e}(TW),jW=function(t){return[[-t/2,-t/2],[-t/2,t/2],[t/2,t/2]]},BW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"折线图"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=(i-2*o-o)/4,s=(i-2*o-o)/2,l=Ve([e-i/2+o,n+i/2-2*o],2),u=l[0],c=l[1];xz(this.icon).maybeAppend(".coordinate","polyline").styles({points:jW(i).map((function(t){var r=Ve(t,2),i=r[0],o=r[1];return[i+e,o+n]})),stroke:r,lineWidth:o}),xz(this.icon).maybeAppend(".line","polyline").styles({points:[[u,c],[u+a,c-s],[u+2*a,c],[u+4*a,c-2*s]],stroke:r,lineWidth:o})},e}(TW),FW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"条形图"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return[1,4,2,4,3]},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.data,e=this.attributes,n=e.x,r=e.y,i=e.color,o=this.iconSize,a=this.lineWidth,s=a,l=(o-s)/t.length,u=(o-2*s)/4,c=Ve([n-o/2+2*s,r+o/2-s],2),h=c[0],d=c[1];xz(this.icon).maybeAppend(".coordinate","polyline").styles({points:jW(o).map((function(t){var e=Ve(t,2),i=e[0],o=e[1];return[i+n,o+r]})),stroke:i,lineWidth:a}),xz(this.icon).maybeAppend(".bars","g").selectAll(".column").data(this.data.map((function(t,e){return{value:t,index:e}}))).join((function(t){return t.append("line").attr("className","column").style("x1",(function(t){var e=t.index;return h+l*e})).style("y1",d).style("x2",(function(t){var e=t.index;return h+l*e})).style("y2",(function(t){var e=t.value;return d-u*e})).styles({y1:d,stroke:i,lineWidth:a})}))},e}(TW),zW=function(t){function e(e){var n=t.call(this,$F({},{style:{color:"#d8d9d9"}},e))||this;return n.showBackground=!1,n}return je(e,t),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;xz(this.icon).maybeAppend(".split","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o})},e}(TW),GW=function(t){function e(){var e=t.apply(this,We([],Ve(arguments),!1))||this;return e.showBackground=!1,e}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Ez(0)},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.iconSize,e=this.attributes,n=e.x,r=e.y,i=e.speed,o=void 0===i?1:i,a=Pe(this.attributes,["x","y","transform","transformOrigin","width","height","size","color","speed"]),s=oe(t,20,1/0),l=Be(Be({},a),{x:n-s/2,y:r-10,width:s,height:20,defaultValue:o,bordered:!1,showDropdownIcon:!1,selectRadius:2,dropdownPadding:this.padding,dropdownRadius:2,dropdownSpacing:t/5,placeholderFontSize:t/2,optionPadding:0,optionLabelFontSize:t/2,optionBackgroundRadius:1,options:[{label:"1x",value:1},{label:"1.5x",value:1.5},{label:"2x",value:2}]});xz(this.icon).maybeAppend(".speed",(function(){return new OW({style:l})})).attr("className","speed").each((function(){this.update(l)}))},e.tag="SpeedSelect",e}(TW),VW=function(t){function e(e){var n=t.call(this,e)||this;return n.icon=n.appendChild(new jl({})),n.currentType=n.attributes.type,n}return je(e,t),e.prototype.getType=function(){return this.currentType},e.prototype.render=function(){var t=this,e=this.attributes;e.onChange;var n=Fe(e,["onChange"]);xz(this.icon).selectAll(".icon").data([this.currentType]).join((function(e){return e.append((function(e){var n,r=null===(n=t.toggles.find((function(t){return Ve(t,1)[0]===e})))||void 0===n?void 0:n[1];if(!r)throw new Error("Invalid type: ".concat(e));return new r({})})).attr("className","icon").styles(n,!1).update({})}),(function(t){return t.styles({restStyles:n}).update({})}),(function(t){return t.remove()}))},e.prototype.bindEvents=function(){var t=this,e=this.attributes.onChange;this.addEventListener("click",(function(n){n.preventDefault(),n.stopPropagation();var r=(t.toggles.findIndex((function(e){return Ve(e,1)[0]===t.currentType}))+1)%t.toggles.length,i=t.toggles[r][0];null==e||e(t.currentType),t.currentType=i,t.render()}))},e.tag="ToggleIcon",e}(Lz),WW=function(t){function e(e){var n=t.call(this,$F({},{style:{type:"play"}},e))||this;return n.toggles=[["play",DW],["pause",LW]],n}return je(e,t),e}(VW),HW=function(t){function e(e){var n=t.call(this,$F({},{style:{type:"range"}},e))||this;return n.toggles=[["range",_W],["value",IW]],n}return je(e,t),e}(VW),YW=function(t){function e(e){var n=t.call(this,$F({},{style:{type:"column"}},e))||this;return n.toggles=[["line",BW],["column",FW]],n}return je(e,t),e}(VW),UW={reset:CW,speed:GW,backward:PW,playPause:WW,forward:RW,selectionType:HW,chartType:YW,split:zW},$W=function(t){function e(n){var r=t.call(this,$F({},e.defaultOptions,n))||this;return r.background=r.appendChild(new Xl({})),r.functions=r.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Ez(this.attributes.padding)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.style,e=t.x,n=t.y,r=t.width,i=t.height,o=Oz(this.attributes,"background");this.background.attr(Be({x:e,y:n,width:r,height:i},o))},e.prototype.renderFunctions=function(){var t,e=this,n=this.attributes,r=n.functions,i=n.iconSize,o=n.iconSpacing,a=n.x,s=n.y,l=n.width,u=n.height,c=n.align,h=Ve(this.padding,4),d=h[1],f=h[3],p=r.reduce((function(t,e){return t.length&&e.length?t.concat.apply(t,We(["split"],Ve(e),!1)):t.concat.apply(t,We([],Ve(e),!1))}),[]),g=p.length*(i+o)-o,v={left:f+i/2,center:(l-g)/2+i/2,right:l-g-f-d+i/2}[c]||0;null===(t=this.speedSelect)||void 0===t||t.destroy(),this.functions.removeChildren(),p.forEach((function(t,n){var r,l=UW[t],c={x:a+n*(i+o)+v,y:s+u/2,size:i};if(l===GW?(c.speed=e.attributes.speed,c.onSelect=function(n){return e.handleFunctionChange(t,{value:n})}):[WW,HW,YW].includes(l)?(c.onChange=function(n){return e.handleFunctionChange(t,{value:n})},l===WW&&(c.type="play"===e.attributes.state?"pause":"play"),l===HW&&(c.type="range"===e.attributes.selectionType?"value":"range"),l===YW&&(c.type="line"===e.attributes.chartType?"column":"line")):c.onClick=function(){return e.handleFunctionChange(t,{value:t})},l===GW){var h=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView;h&&(e.speedSelect=new l({style:Be(Be({},c),{zIndex:100})}),h.appendChild(e.speedSelect))}else e.functions.appendChild(new l({style:c}))}))},e.prototype.disconnectedCallback=function(){var e;t.prototype.disconnectedCallback.call(this),null===(e=this.speedSelect)||void 0===e||e.destroy()},e.prototype.render=function(){this.renderBackground(),this.renderFunctions()},e.prototype.handleFunctionChange=function(t,e){var n=this.attributes.onChange;null==n||n(t,e)},e.defaultOptions={style:{x:0,y:0,width:300,height:40,padding:0,align:"center",iconSize:25,iconSpacing:0,speed:1,state:"pause",chartType:"line",selectionType:"range",backgroundFill:"#fbfdff",backgroundStroke:"#ebedf0",functions:[["reset","speed"],["backward","playPause","forward"],["selectionType","chartType"]]}},e}(Lz),qW=function(t){function e(n){var r=t.call(this,$F({},e.defaultOptions,n))||this;return r.bindEvents(),r}return je(e,t),e.prototype.bindEvents=function(){var t=this;this.addEventListener("mouseenter",(function(){t.attr("lineWidth",Math.ceil(+(t.style.r||0)/2))})),this.addEventListener("mouseleave",(function(){t.attr("lineWidth",0)}))},e.defaultOptions={style:{r:5,fill:"#3f7cf7",lineWidth:0,stroke:"#3f7cf7",strokeOpacity:.5,cursor:"pointer"}},e}(Dl),XW=function(t){function e(n){return t.call(this,$F({},e.defaultOptions,n))||this}return je(e,t),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=Oz(this.attributes,"background");xz(this).maybeAppend("background","rect").attr("className","background").styles(Be({x:e-r/2,y:n-i/2,width:r,height:i},o))},e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.iconSize,i=Oz(this.attributes,"icon"),o=r/2;xz(this).maybeAppend("icon-left-line","line").attr("className","icon-left-line").styles(Be({x1:e-1,y1:n-o,x2:e-1,y2:n+o},i)),xz(this).maybeAppend("icon-right-line","line").attr("className","icon-right-line").styles(Be({x1:e+1,y1:n-o,x2:e+1,y2:n+o},i))},e.prototype.renderBorder=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,a=Oz(this.attributes,"border"),s="start"===o?+r/2:-r/2;xz(this).maybeAppend("border","line").attr("className","border").styles(Be({x1:s+e,y1:n-i/2,x2:s+e,y2:n+i/2},a))},e.prototype.render=function(){this.renderBackground(),this.renderIcon(),this.renderBorder()},e.defaultOptions={style:{x:0,y:0,width:10,height:50,iconSize:10,type:"start",backgroundFill:"#fff",backgroundFillOpacity:.5,iconStroke:"#9a9a9a",iconLineWidth:1,borderStroke:"#e8e8e8",borderLineWidth:1}},e}(Lz);function KW(t,e){return"number"==typeof t?ZW(t):function(t,e){var n=new Date(t);switch(e){case"half-hour":case"hour":case"four-hour":return[0,6,12,18].includes(n.getHours())&&0===n.getMinutes()?Cz(n,"HH:mm\nYYYY-MM-DD"):Cz(n,"HH:mm");case"half-day":return n.getHours()<12?"AM\n".concat(Cz(n,"YYYY-MM-DD")):"PM";case"day":return[1,10,20].includes(n.getDate())?Cz(n,"DD\nYYYY-MM"):Cz(n,"DD");case"week":return n.getDate()<=7?Cz(n,"DD\nYYYY-MM"):Cz(n,"DD");case"month":return[0,6].includes(n.getMonth())?Cz(n,"MM月\nYYYY"):Cz(n,"MM月");case"season":return[0].includes(n.getMonth())?Cz(n,"MM月\nYYYY"):Cz(n,"MM月");case"year":return Cz(n,"YYYY");default:return Cz(n,"YYYY-MM-DD HH:mm")}}(t,e)}function ZW(t){var e=String(Math.floor(t/3600)).padStart(2,"0"),n=String(Math.floor(t%3600/60)).padStart(2,"0"),r=String(Math.floor(t%60)).padStart(2,"0");return t<3600?"".concat(n,":").concat(r):"".concat(e,":").concat(n,":").concat(r)}var QW=function(t){function e(n){var r=t.call(this,$F({},e.defaultOptions,n))||this;r.axis=r.appendChild(new iW({style:{type:"linear",startPos:[0,0],endPos:[0,0],data:[],showArrow:!1,animate:!1}})),r.timeline=r.appendChild(new rV({style:{onChange:function(t){r.handleSliderChange(t)}}})),r.controller=r.appendChild(new $W({})),r.states={},r.handleSliderChange=function(t){var e,n=(e=r.states.values,Array.isArray(e)?We([],Ve(e),!1):e);r.setBySliderValues(t),r.dispatchOnChange(n)};var i=r.attributes,o=i.selectionType,a=i.chartType,s=i.speed,l=i.state,u=i.playMode,c=i.values;return r.states={chartType:a,playMode:u,selectionType:o,speed:s,state:l},r.setByTimebarValues(c),r}return je(e,t),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.data.sort((function(t,e){return t.time<e.time?-1:t.time>e.time?1:0}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"space",{get:function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,a=t.controllerHeight,s=oe(+i-a,0,+i),l=new VF(e,n+ +i-a,+r,a),u=0,c="time"===o?10:s;return{axisBBox:"chart"===o?new VF(e,n+s-(u=35),+r,u):new VF,controllerBBox:l,timelineBBox:new VF(e,n+("time"===o?s:s-c),+r,c-u)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=Ve(Array.isArray(t)?t:[0,t],2),o=i[0],a=i[1],s=r.length,l=r[Math.floor(o*s)],u=r[Math.ceil(a*s)-(Array.isArray(t)?0:1)];this.states.values=[null!==(e=null==l?void 0:l.time)&&void 0!==e?e:r[0].time,null!==(n=null==u?void 0:u.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=Ve(Array.isArray(t)?t:[void 0,t],2),a=o[0],s=o[1],l=i.find((function(t){return t.time===a})),u=i.find((function(t){return t.time===s}));this.states.values=[null!==(e=null==l?void 0:l.time)&&void 0!==e?e:null===(n=i[0])||void 0===n?void 0:n.time,null!==(r=null==u?void 0:u.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,a=Ve(t,2),s=a[0],l=a[1];this.states.values=[null!==(n=null===(e=o[s])||void 0===e?void 0:e.time)&&void 0!==n?n:o[0].time,null!==(i=null===(r=this.data[l])||void 0===r?void 0:r.time)&&void 0!==i?i:1/0]},Object.defineProperty(e.prototype,"sliderValues",{get:function(){var t,e=this.states,n=e.values,r=e.selectionType,i=Ve(Array.isArray(n)?n:[void 0,n],2),o=i[0],a=i[1],s=this.data,l=s.length,u="value"===r;return[(t=s.findIndex((function(t){return t.time===o})),u?0:t>-1?t/l:0),function(){if(a===1/0)return 1;var t=s.findIndex((function(t){return t.time===a}));return t>-1?t/l:u?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=Ve(Array.isArray(e)?e:[this.data[0].time,e],2),i=r[0],o=r[1];return"value"===n?o:[i,o]},enumerable:!1,configurable:!0}),e.prototype.getDatumByRatio=function(t){var e=this.data,n=e.length;return e[Math.floor(t*(n-1))]},Object.defineProperty(e.prototype,"chartHandleIconShape",{get:function(){var t=this.states.selectionType,e=this.space.timelineBBox.height;return"range"===t?function(t){return new XW({style:{type:t,height:e,iconSize:e/6}})}:function(){return new Vl({style:{x1:0,y1:-e/2,x2:0,y2:e/2,lineWidth:2,stroke:"#c8c8c8"}})}},enumerable:!1,configurable:!0}),e.prototype.getChartStyle=function(t){var e=this,n=t.x,r=t.y,i=t.width,o=t.height,a=this.states,s=a.selectionType,l=a.chartType,u=this.data,c=this.attributes,h=c.type,d=c.labelFormatter,f=Oz(this.attributes,"chart");f.type;var p=Fe(f,["type"]),g="range"===s;if("time"===h)return Be({handleIconShape:function(){return new qW({})},selectionFill:"#2e7ff8",selectionFillOpacity:1,showLabelOnInteraction:!0,handleLabelDy:g?-15:0,autoFitLabel:g,handleSpacing:g?-15:0,trackFill:"#edeeef",trackLength:i,trackOpacity:.5,trackRadius:o/2,trackSize:o/2,type:s,values:this.sliderValues,formatter:function(t){if(d)return d(t);var n=e.getDatumByRatio(t).time;return"number"==typeof n?ZW(n):Cz(n,"YYYY-MM-DD HH:mm:ss")},transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},p);var v="range"===s?5:0,m=u.map((function(t){return t.value}));return Be({handleIconOffset:v,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:m,sparklineType:l,sparklineScale:.8,trackLength:i,trackSize:o,type:s,values:this.sliderValues,transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},p)},e.prototype.renderChart=function(t){void 0===t&&(t=this.space.timelineBBox),this.timeline.update(this.getChartStyle(t))},e.prototype.updateSelection=function(){this.timeline.setValues(this.sliderValues,!0),this.handleSliderChange(this.sliderValues)},e.prototype.getAxisStyle=function(t){var e=this.data,n=this.attributes,r=n.interval,i=n.labelFormatter,o=Oz(this.attributes,"axis"),a=t.x,s=t.y,l=t.width,u=We(We([],Ve(e),!1),[{time:0}],!1).map((function(t,e,n){var r=t.time;return{label:"".concat(r),value:e/(n.length-1),time:r}})),c=Be({startPos:[a,s],endPos:[a+l,s],data:u,labelFilter:function(t,e){return e<u.length-1},labelFormatter:function(t){var e=t.time;return i?i(e):KW(e,r)}},o);return c},e.prototype.renderAxis=function(t){void 0===t&&(t=this.space.axisBBox),"chart"===this.attributes.type&&this.axis.update(this.getAxisStyle(t))},e.prototype.renderController=function(t){void 0===t&&(t=this.space.controllerBBox);var e=this.attributes.type,n=this.states,r=n.state,i=n.speed,o=n.selectionType,a=n.chartType,s=Oz(this.attributes,"controller"),l=this,u=Be(Be(Be({},t),{iconSize:20,speed:i,state:r,selectionType:o,chartType:a,onChange:function(t,e){var n=e.value;switch(t){case"reset":l.internalReset();break;case"speed":l.handleSpeedChange(n);break;case"backward":l.internalBackward();break;case"playPause":"play"===n?l.internalPlay():l.internalPause();break;case"forward":l.internalForward();break;case"selectionType":l.handleSelectionTypeChange(n);break;case"chartType":l.handleChartTypeChange(n)}}}),s);"time"===e&&(u.functions=[["reset","speed"],["backward","playPause","forward"],["selectionType"]]),this.controller.update(u)},e.prototype.dispatchOnChange=function(t){var e=this.data,n=this.attributes.onChange,r=this.states,i=r.values,o=r.selectionType,a=Ve(i,2),s=a[0],l=a[1],u=l===1/0?e.at(-1).time:l;t&&function(t,e){if(Array.isArray(t)){if(!Array.isArray(e))return!1;if(t[0]===e[0]){if(t[1]===e[1])return!0;if(t[1]===1/0||e[1]===1/0)return!0}return!1}return!Array.isArray(e)&&t===e}(t,"range"===o?[s,u]:u)||null==n||n("range"===o?[s,u]:u)},e.prototype.internalReset=function(t){var e,n,r=this.states.selectionType;this.internalPause(),this.setBySliderValues("range"===r?[0,1]:[0,0]),this.renderController(),this.updateSelection(),t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onReset)||void 0===n||n.call(e),this.dispatchOnChange())},e.prototype.reset=function(){this.internalReset()},e.prototype.moveSelection=function(t,e){var n=this.data,r=n.length,i=this.states,o=i.values,a=i.selectionType,s=i.playMode,l=Ve(o,2),u=l[0],c=l[1],h=n.findIndex((function(t){return t.time===u})),d=n.findIndex((function(t){return t.time===c}));-1===d&&(d=r);var f,p="backward"===t?-1:1;"range"===a?"acc"===s?(f=[h,d+p],-1===p&&h===d&&(f=[h,r])):f=[h+p,d+p]:f=[h,d+p];var g=function(t){var e=Ve(t.sort((function(t,e){return t-e})),2),n=e[0],i=e[1],o=function(t){return oe(t,0,r)};return i>r?"value"===a?[0,0]:"acc"===s?[o(n),o(n)]:[0,o(i-n)]:n<0?"acc"===s?[0,o(i)]:[o(n+r-i),r]:[o(n),o(i)]}(f);return this.setByIndex(g),this.updateSelection(),g},e.prototype.internalBackward=function(t){var e,n,r=this.moveSelection("backward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onBackward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.backward=function(){this.internalBackward()},e.prototype.internalPlay=function(t){var e,n,r=this,i=this.data,o=this.attributes.loop,a=this.states.speed,s=void 0===a?1:a;this.playInterval=window.setInterval((function(){r.internalForward()[1]!==i.length||o||(r.internalPause(),r.renderController())}),1e3/s),this.states.state="play",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPlay)||void 0===n||n.call(e))},e.prototype.play=function(){this.internalPlay()},e.prototype.internalPause=function(t){var e,n;clearInterval(this.playInterval),this.states.state="pause",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPause)||void 0===n||n.call(e))},e.prototype.pause=function(){this.internalPause()},e.prototype.internalForward=function(t){var e,n,r=this.moveSelection("forward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onForward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.forward=function(){this.internalForward()},e.prototype.handleSpeedChange=function(t){var e,n;this.states.speed=t,"play"===this.states.state&&(this.internalPause(!0),this.internalPlay(!0)),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSpeedChange)||void 0===n||n.call(e,t)},e.prototype.handleSelectionTypeChange=function(t){var e,n;this.states.selectionType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSelectionTypeChange)||void 0===n||n.call(e,t)},e.prototype.handleChartTypeChange=function(t){var e,n;this.states.chartType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onChartTypeChange)||void 0===n||n.call(e,t)},e.prototype.render=function(){var t=this.space,e=t.axisBBox,n=t.controllerBBox,r=t.timelineBBox;this.renderController(n),this.renderAxis(e),this.renderChart(r),"play"===this.states.state&&this.internalPlay()},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.internalPause(!0)},e.defaultOptions={style:{x:0,y:0,axisLabelFill:"#6e6e6e",axisLabelTextAlign:"left",axisLabelTextBaseline:"top",axisLabelTransform:"translate(5, -12)",axisLineLineWidth:1,axisLineStroke:"#cacdd1",axisTickLength:15,axisTickLineWidth:1,axisTickStroke:"#cacdd1",chartShowLabel:!1,chartType:"line",controllerAlign:"center",controllerHeight:40,data:[],interval:"day",loop:!1,playMode:"acc",selectionType:"range",type:"time"}},e}(Lz);function JW(t){const{width:e,height:n,renderer:r}=t,i=function(t){var e;const{container:n,className:r,graphCanvas:i}=t;if(n)return"string"==typeof n?document.getElementById(n):n;const o=tB(r,!1),{width:a,height:s,containerStyle:l}=t,[u,c]=function(t){const{width:e,height:n,placement:r,graphCanvas:i}=t,[o,a]=i.getSize(),[s,l]=Zh(r);return[s*(o-e),l*(a-n)]}(t);return Object.assign(o.style,Object.assign({position:"absolute",left:u+"px",top:c+"px",width:a+"px",height:s+"px"},l)),null===(e=i.getContainer())||void 0===e||e.appendChild(o),o}(t);return[i,new hu({width:e,height:n,container:i,renderer:r||new kp})]}class tH extends Jj{constructor(e,n){super(e,Object.assign({},tH.defaultOptions,n)),this.typePrefix="__data__",this.draw=!1,this.fieldMap={node:new Map,edge:new Map,combo:new Map},this.selectedItems=[],this.bindEvents=()=>{const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.createElement)},this.changeState=(t,e)=>{const{graph:n}=this.context,{typePrefix:r}=this,i=Oe(t,[r,"id"]),o=Oe(t,[r,"style","labelText"]),[a]=i.split("__"),s=this.fieldMap[a].get(o)||[];n.setElementState(Object.fromEntries(null==s?void 0:s.map((t=>[t,e]))))},this.click=t=>{if("hover"===this.options.trigger)return;const e=Oe(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?(this.selectedItems=this.selectedItems.filter((t=>t!==e)),this.changeState(t,[])):(this.selectedItems.push(e),this.changeState(t,"selected"))},this.mouseleave=t=>{"click"!==this.options.trigger&&(this.selectedItems=[],this.changeState(t,[]))},this.mouseenter=t=>{if("click"===this.options.trigger)return;const e=Oe(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?this.selectedItems=this.selectedItems.filter((t=>t!==e)):(this.selectedItems.push(e),this.changeState(t,"active"))},this.setFieldMap=(t,e,n)=>{if(!t)return;const r=this.fieldMap[n];if(r)if(r.has(t)){const n=r.get(t);n&&(n.push(e),r.set(t,n))}else r.set(t,[e])},this.getEvents=()=>({mouseenter:this.mouseenter,mouseleave:this.mouseleave,click:this.click}),this.getMarkerData=(t,e)=>{if(!t)return[];const{model:n,element:r}=this.context,{nodes:i,edges:o,combos:a}=n.getData(),s={},l=e=>Yt(t)?t(e):t,u={node:"circle",edge:"line",combo:"rect"},c={circle:"circle",ellipse:"circle",image:"bowtie",rect:"square",star:"cross",triangle:"triangle",diamond:"diamond",cubic:"dot",line:"hyphen",polyline:"hyphen",quadratic:"hv","cubic-horizontal":"hyphen","cubic-vertical":"line"},h=(t,e)=>{t.forEach((t=>{const{id:n}=t,i=Oe(t,["data",l(t)]),o=(null==r?void 0:r.getElementType(e,t))||"circle",a=((t,e)=>null==r?void 0:r.getElementComputedStyle(t,e))(e,t),h=("edge"===e?null==a?void 0:a.stroke:null==a?void 0:a.fill)||"#1783ff";n&&i&&i.replace(/\s+/g,"")&&(this.setFieldMap(i,n,e),s[i]||(s[i]={id:`${e}__${n}`,label:i,marker:c[o]||u[e],elementType:e,lineWidth:1,stroke:h,fill:h}))}))};switch(e){case"node":h(i,"node");break;case"edge":h(o,"edge");break;case"combo":h(a,"combo");break;default:return[]}return Object.values(s)},this.createElement=()=>{if(this.draw)return void this.updateElement();const t=this.options,{width:e,height:n,nodeField:r,edgeField:i,comboField:o,trigger:a,position:s,container:l,containerStyle:u,className:c}=t,h=Fe(t,["width","height","nodeField","edgeField","comboField","trigger","position","container","containerStyle","className"]),d=this.getMarkerData(r,"node"),f=this.getMarkerData(i,"edge"),p=this.getMarkerData(o,"combo"),g=[...d,...p,...f],v=Object.assign({width:e,height:n,data:g,itemMarkerLineWidth:({lineWidth:t})=>t,itemMarker:({marker:t})=>t,itemMarkerStroke:({stroke:t})=>t,itemMarkerFill:({fill:t})=>t,gridCol:d.length},h,this.getEvents()),m=new yW({className:"legend",style:v});this.category=m;this.upsertCanvas().appendChild(m),this.draw=!0},this.bindEvents()}update(t){super.update(t),this.clear(),this.createElement()}clear(){var t,e;null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.container)||void 0===e||e.remove(),this.canvas=void 0,this.container=void 0,this.draw=!1}updateElement(){this.category&&this.category.update({itemMarkerOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5,itemLabelOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5})}upsertCanvas(){if(this.canvas)return this.canvas;const t=this.context.canvas,[e,n]=t.getSize(),{width:r=e,height:i=n,position:o,container:a,containerStyle:s,className:l}=this.options,[u,c]=JW({width:r,height:i,graphCanvas:t,container:a,containerStyle:s,placement:o,className:"legend"});return this.container=u,l&&u.classList.add(l),this.canvas=c,this.canvas}destroy(){this.clear(),this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.createElement),super.destroy()}}tH.defaultOptions={position:"bottom",trigger:"hover",orientation:"horizontal",layout:"flex",itemSpacing:4,rowPadding:10,colPadding:10,itemMarkerSize:16,itemLabelFontSize:16,width:240,height:160};class eH extends Jj{constructor(t,e){super(t,Object.assign({},eH.defaultOptions,e)),this.onDraw=t=>{var e;(null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.render)||this.onRender()},this.shapes=new Map,this.landmarkMap=new Map,this.mask=null,this.isMaskDragging=!1,this.onMaskDragStart=t=>{this.mask&&(this.isMaskDragging=!0,this.mask.setPointerCapture(t.pointerId),this.mask.addEventListener("pointermove",this.onMaskDrag),this.mask.addEventListener("pointerup",this.onMaskDragEnd),this.mask.addEventListener("pointercancel",this.onMaskDragEnd))},this.onMaskDrag=t=>{if(!this.mask||!this.isMaskDragging)return;const{size:[e,n]}=this.options,{movementX:r,movementY:i}=t,{left:o,top:a,width:s,height:l}=this.mask.style,[,,u,c]=this.maskBBox;let h=parseInt(o)+r,d=parseInt(a)+i,f=parseInt(s),p=parseInt(l);h<0&&(h=0),d<0&&(d=0),h+f>e&&(h=rH(e-f,0)),d+p>n&&(d=rH(n-p,0)),f<u&&(r>0?(h=rH(h-r,0),f=nH(f+r,e)):r<0&&(f=nH(f-r,e))),p<c&&(i>0?(d=rH(d-i,0),p=nH(p+i,n)):i<0&&(p=nH(p-i,n))),Object.assign(this.mask.style,{left:h+"px",top:d+"px",width:f+"px",height:p+"px"});const g=parseInt(o)-h,v=parseInt(a)-d;if(0===g&&0===v)return;const m=this.context.canvas.getCamera().getZoom()/this.canvas.getCamera().getZoom();this.context.graph.translateBy([g*m,v*m],!1)},this.onMaskDragEnd=t=>{this.mask&&(this.isMaskDragging=!1,this.mask.releasePointerCapture(t.pointerId),this.mask.removeEventListener("pointermove",this.onMaskDrag),this.mask.removeEventListener("pointerup",this.onMaskDragEnd),this.mask.removeEventListener("pointercancel",this.onMaskDragEnd))},this.onTransform=Re((()=>{this.isMaskDragging||(this.updateMask(),this.setCamera())}),32,{leading:!0}),this.setOnRender(),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),"delay"in t&&this.setOnRender(),this.bindEvents()}setOnRender(){this.onRender=ye((()=>{this.renderMinimap(),this.renderMask()}),this.options.delay,!0)}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.onDraw),e.on(t.GraphEvent.AFTER_RENDER,this.onRender),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.onDraw),e.off(t.GraphEvent.AFTER_RENDER,this.onRender),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}renderMinimap(){const t=this.getElements(),e=this.initCanvas();this.setShapes(e,t)}getElements(){const{filter:t}=this.options,{model:e}=this.context,n=e.getData();if(!t)return n;const{nodes:r,edges:i,combos:o}=n;return{nodes:r.filter((e=>t(yh(e),"node"))),edges:i.filter((e=>t(yh(e),"edge"))),combos:o.filter((e=>t(yh(e),"combo")))}}setShapes(t,e){const{nodes:n,edges:r,combos:i}=e,{shape:o}=this.options,{element:a}=this.context;if("key"===o){const e=new Set,o=n=>{const r=yh(n);e.add(r);const i=a.getElement(r);if(!i)return;const o=i.getShape("key"),s=this.shapes.get(r)||o.cloneNode();s.setPosition(o.getPosition()),i.style.zIndex&&(s.style.zIndex=i.style.zIndex),s.id=i.id,this.shapes.has(r)?Object.entries(o.attributes).forEach((([t,e])=>{s.style[t]!==e&&(s.style[t]=e)})):(t.appendChild(s),this.shapes.set(r,s))};return r.forEach(o),i.forEach(o),n.forEach(o),void this.shapes.forEach(((n,r)=>{e.has(r)||(t.removeChild(n),this.shapes.delete(r))}))}const s=(t,e)=>{const n=a.getElement(t).getPosition();return e.setPosition(n),e};t.removeChildren(),r.forEach((e=>t.appendChild(o(yh(e),"edge")))),i.forEach((e=>{t.appendChild(s(yh(e),o(yh(e),"combo")))})),n.forEach((e=>{t.appendChild(s(yh(e),o(yh(e),"node")))}))}initCanvas(){const{renderer:t,size:[e,n]}=this.options;if(this.canvas){const{width:r,height:i}=this.canvas.getConfig();e===r&&n===i||this.canvas.resize(e,n),t&&this.canvas.setRenderer(t)}else{const{className:r,position:i,container:o,containerStyle:a}=this.options,[s,l]=JW({renderer:t,width:e,height:n,placement:i,className:"minimap",container:o,containerStyle:a,graphCanvas:this.context.canvas});r&&s.classList.add(r),this.container=s,this.canvas=l}return this.setCamera(),this.canvas}createLandmark(t,e,n){const r=`${t.join(",")}-${e.join(",")}-${n}`;if(this.landmarkMap.has(r))return this.landmarkMap.get(r);const i=this.canvas.getCamera().createLandmark(r,{position:t,focalPoint:e,zoom:n});return this.landmarkMap.set(r,i),i}setCamera(){var t;const{canvas:e}=this.context,n=null===(t=this.canvas)||void 0===t?void 0:t.getCamera();if(!n)return;const{size:[r,i],padding:o}=this.options,[a,s,l,u]=Yc(o),{min:c,max:h,center:d}=e.getBounds("elements"),f=(r-u-s)/(h[0]-c[0]),p=(i-a-l)/(h[1]-c[1]),g=Math.min(f,p),v=this.createLandmark(d,d,g);n.gotoLandmark(v,0)}get maskBBox(){const{canvas:t}=this.context,e=t.getSize(),n=t.getCanvasByViewport([0,0]),r=t.getCanvasByViewport(e),i=this.canvas.canvas2Viewport(nd(n)),o=this.canvas.canvas2Viewport(nd(r)),a=o.x-i.x,s=o.y-i.y;return[i.x,i.y,a,s]}calculateMaskBBox(){const{size:[t,e]}=this.options;let[n,r,i,o]=this.maskBBox;return n<0&&(i=nH(i+n,t),n=0),r<0&&(o=nH(o+r,e),r=0),n+i>t&&(i=rH(t-n,0)),r+o>e&&(o=rH(e-r,0)),[nH(n,t),nH(r,e),rH(i,0),rH(o,0)]}renderMask(){const{maskStyle:t}=this.options;this.mask||(this.mask=document.createElement("div"),this.mask.addEventListener("pointerdown",this.onMaskDragStart)),this.container.appendChild(this.mask),Object.assign(this.mask.style,Object.assign(Object.assign({},t),{cursor:"move",position:"absolute",pointerEvents:"auto"})),this.updateMask()}updateMask(){if(!this.mask)return;const[t,e,n,r]=this.calculateMaskBBox();Object.assign(this.mask.style,{top:e+"px",left:t+"px",width:n+"px",height:r+"px"})}destroy(){var t;this.unbindEvents(),this.canvas.destroy(),null===(t=this.mask)||void 0===t||t.remove(),super.destroy()}}eH.defaultOptions={size:[240,160],shape:"key",padding:10,position:"right-bottom",maskStyle:{border:"1px solid #ddd",background:"rgba(0, 0, 0, 0.1)"},containerStyle:{border:"1px solid #ddd",background:"#fff"},delay:128};const nH=(t,e)=>Math.min(t,e),rH=(t,e)=>Math.max(t,e),iH={x1:0,y1:0,x2:0,y2:0,visibility:"hidden"};class oH extends Jj{constructor(t,e){super(t,Object.assign({},oH.defaultOptions,e)),this.initSnapline=()=>{const t=this.context.canvas.getLayer("transient");this.horizontalLine||(this.horizontalLine=t.appendChild(new Vl({style:Object.assign(Object.assign({},iH),this.options.horizontalLineStyle)}))),this.verticalLine||(this.verticalLine=t.appendChild(new Vl({style:Object.assign(Object.assign({},iH),this.options.verticalLineStyle)})))},this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!0,this.autoSnapToLine=(t,e,n)=>ze(this,void 0,void 0,(function*(){const{verticalX:r,horizontalY:i}=n,{tolerance:o}=this.options,{min:[a,s],max:[l,u],center:[c,h]}=e;let d=0,f=0;null!==r&&(aH(l,r)<o&&(d=r-l),aH(a,r)<o&&(d=r-a),aH(c,r)<o&&(d=r-c),0!==d&&(this.isVerticalSticking=!0)),null!==i&&(aH(u,i)<o&&(f=i-u),aH(s,i)<o&&(f=i-s),aH(h,i)<o&&(f=i-h),0!==f&&(this.isHorizontalSticking=!0)),0===d&&0===f||(yield this.context.graph.translateElementBy({[t]:[d,f]},!1))})),this.enableSnap=t=>{const{target:e}=t,n=.5;if(this.isHorizontalSticking||this.isVerticalSticking){const[r,i]=this.getDelta(t);if(this.isHorizontalSticking&&this.isVerticalSticking&&Math.abs(r)<=n&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,-i]},!1),!1;if(this.isHorizontalSticking&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[0,-i]},!1),!1;if(this.isVerticalSticking&&Math.abs(r)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,0]},!1),!1;this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!1,setTimeout((()=>{this.enableStick=!0}),200)}return this.enableStick},this.calcSnaplineMetadata=(t,e)=>{const{tolerance:n,shape:r}=this.options,{min:[i,o],max:[a,s],center:[l,u]}=e;let c=null,h=null,d=null,f=null,p=null,g=null;return this.getNodes().some((e=>{if(Ne(t.id,e.id))return!1;const v=sH(e,r).getRenderBounds(),{min:[m,y],max:[b,x],center:[E,w]}=v;return null===c&&(aH(E,l)<n?c=E:aH(m,i)<n||aH(m,a)<n?c=m:(aH(b,a)<n||aH(b,i)<n)&&(c=b),null!==c&&(h=Math.min(y,o),d=Math.max(x,s))),null===f&&(aH(w,u)<n?f=w:aH(y,o)<n||aH(y,s)<n?f=y:(aH(x,s)<n||aH(x,o)<n)&&(f=x),null!==f&&(p=Math.min(m,i),g=Math.max(b,a))),null!==c&&null!==f})),{verticalX:c,verticalMinY:h,verticalMaxY:d,horizontalY:f,horizontalMinX:p,horizontalMaxX:g}},this.onDragStart=()=>{this.initSnapline()},this.onDrag=t=>ze(this,void 0,void 0,(function*(){const{target:e}=t;if(this.options.autoSnap){if(!this.enableSnap(t))return}const n=sH(e,this.options.shape).getRenderBounds(),r=this.calcSnaplineMetadata(e,n);this.hideSnapline(),null===r.verticalX&&null===r.horizontalY||this.updateSnapline(r),this.options.autoSnap&&(yield this.autoSnapToLine(e.id,n,r))})),this.onDragEnd=()=>{this.hideSnapline()},this.bindEvents()}getNodes(){var t;const{filter:e}=this.options,n=((null===(t=this.context.element)||void 0===t?void 0:t.getNodes())||[]).filter((t=>{var e;return"hidden"!==Oe(t,["style","visibility"])&&(null===(e=this.context.viewport)||void 0===e?void 0:e.isInViewport(t.getRenderBounds()))}));return e?n.filter((t=>e(t))):n}hideSnapline(){this.horizontalLine.style.visibility="hidden",this.verticalLine.style.visibility="hidden"}getLineWidth(t){const{lineWidth:e}=this.options[`${t}LineStyle`];return+(e||iH.lineWidth||1)/this.context.graph.getZoom()}updateSnapline(t){const{verticalX:e,verticalMinY:n,verticalMaxY:r,horizontalY:i,horizontalMinX:o,horizontalMaxX:a}=t,[s,l]=this.context.canvas.getSize(),{offset:u}=this.options;null!==i?Object.assign(this.horizontalLine.style,{x1:u===1/0?0:o-u,y1:i,x2:u===1/0?s:a+u,y2:i,visibility:"visible",lineWidth:this.getLineWidth("horizontal")}):this.horizontalLine.style.visibility="hidden",null!==e?Object.assign(this.verticalLine.style,{x1:e,y1:u===1/0?0:n-u,x2:e,y2:u===1/0?l:r+u,visibility:"visible",lineWidth:this.getLineWidth("vertical")}):this.verticalLine.style.visibility="hidden"}getDelta(t){const e=this.context.graph.getZoom();return Fh([t.dx,t.dy],e)}bindEvents(){return ze(this,void 0,void 0,(function*(){const{graph:e}=this.context;e.on(t.NodeEvent.DRAG_START,this.onDragStart),e.on(t.NodeEvent.DRAG,this.onDrag),e.on(t.NodeEvent.DRAG_END,this.onDragEnd)}))}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.DRAG_START,this.onDragStart),e.off(t.NodeEvent.DRAG,this.onDrag),e.off(t.NodeEvent.DRAG_END,this.onDragEnd)}destroyElements(){var t,e;null===(t=this.horizontalLine)||void 0===t||t.destroy(),null===(e=this.verticalLine)||void 0===e||e.destroy()}destroy(){this.destroyElements(),this.unbindEvents(),super.destroy()}}oH.defaultOptions={tolerance:5,offset:20,autoSnap:!0,shape:"key",verticalLineStyle:{stroke:"#1783FF"},horizontalLineStyle:{stroke:"#1783FF"},filter:()=>!0};const aH=(t,e)=>Math.abs(t-e),sH=(t,e)=>"function"==typeof e?e(t):t.getShape(e),lH=["timestamp","time","date","datetime"];class uH extends Jj{get padding(){return Yc(this.options.padding)}constructor(t,e){super(t,Object.assign({},uH.defaultOptions,e)),this.backup(),this.upsertTimebar()}play(){var t;null===(t=this.timebar)||void 0===t||t.play()}pause(){var t;null===(t=this.timebar)||void 0===t||t.pause()}forward(){var t;null===(t=this.timebar)||void 0===t||t.forward()}backward(){var t;null===(t=this.timebar)||void 0===t||t.backward()}reset(){var t;null===(t=this.timebar)||void 0===t||t.reset()}update(t){super.update(t),this.backup(),this.upsertTimebar()}backup(){this.originalData=cH(this.context.graph.getData())}upsertTimebar(){const{canvas:t}=this.context,e=this.options,{onChange:n,timebarType:r,data:i,x:o,y:a,width:s,height:l,mode:u}=e,c=Fe(e,["onChange","timebarType","data","x","y","width","height","mode"]),h=t.getSize(),[d]=this.padding;this.upsertCanvas().ready.then((()=>{var t;const e=Object.assign(Object.assign({x:h[0]/2-s/2,y:d,onChange:t=>{const e=($t(t)?t:[t,t]).map((t=>function(t){return t instanceof Date}(t)?t.getTime():t));"modify"===this.options.mode?this.filterElements(e):this.hiddenElements(e),null==n||n(e)}},c),{data:i.map((t=>ae(t)?{time:t,value:0}:t)),width:s,height:l,type:r});this.timebar?this.timebar.update(e):(this.timebar=new QW({style:e}),null===(t=this.canvas)||void 0===t||t.appendChild(this.timebar))}))}upsertCanvas(){if(this.canvas)return this.canvas;const{className:t,height:e,position:n}=this.options,r=this.context.canvas,[i]=r.getSize(),[o,,a]=this.padding,[s,l]=JW({width:i,height:e+o+a,graphCanvas:r,className:"timebar",placement:n});return this.container=s,t&&s.classList.add(t),this.canvas=l,this.canvas}filterElements(t){return ze(this,void 0,void 0,(function*(){var e;if(!this.originalData)return;const{elementTypes:n,getTime:r}=this.options,{graph:i,element:o}=this.context,a=cH(this.originalData);n.forEach((e=>{const n=`${e}s`;a[n]=(this.originalData[n]||[]).filter((e=>{const n=r(e);return!!hH(n,t)}))}));const s=[...a.nodes,...a.combos].map((t=>yh(t)));a.edges=a.edges.filter((t=>{const e=t.source,n=t.target;return s.includes(e)&&s.includes(n)})),i.setData(a),yield null===(e=o.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished}))}hiddenElements(t){const{graph:e}=this.context,{elementTypes:n,getTime:r}=this.options,i=[],o=[];n.forEach((e=>{var n;const a=`${e}s`;((null===(n=this.originalData)||void 0===n?void 0:n[a])||[]).forEach((e=>{const n=yh(e),a=r(e);hH(a,t)?o.push(n):i.push(n)}))})),e.hideElement(i,!1),e.showElement(o,!1)}destroy(){var t,e,n;const{graph:r}=this.context;this.originalData&&r.setData(Object.assign({},this.originalData)),null===(t=this.timebar)||void 0===t||t.destroy(),null===(e=this.canvas)||void 0===e||e.destroy(),null===(n=this.container)||void 0===n||n.remove(),this.originalData=void 0,this.container=void 0,this.timebar=void 0,this.canvas=void 0,super.destroy()}}uH.defaultOptions={position:"bottom",enable:!0,timebarType:"time",className:"g6-timebar",width:450,height:60,zIndex:3,elementTypes:["node"],padding:10,mode:"modify",getTime:t=>dH(t,lH,void 0),loop:!1};const cH=t=>{const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e],edges:[...n],combos:[...r]}},hH=(t,e)=>{if(ae(e))return t===e;const[n,r]=e;return t>=n&&t<=r},dH=(t,e,n)=>{var r;for(let n=0;n<e.length;n++){const i=e[n],o=null===(r=t.data)||void 0===r?void 0:r[i];if(o)return o}return n};class fH extends Jj{constructor(t,e){super(t,Object.assign({},fH.defaultOptions,e)),this.$element=tB("toolbar",!1),this.onToolbarItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof Element&&t.target.className.includes("g6-toolbar-item")){const n=t.target.getAttribute("value");null==e||e(n,t.target)}};const n=this.context.canvas.getContainer();this.$element.style.display="flex",n.appendChild(this.$element),eB("g6-toolbar-css","style",{},"\n .g6-toolbar {\n position: absolute;\n z-index: 100;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);\n opacity: 0.65;\n }\n .g6-toolbar .g6-toolbar-item {\n display: inline-block;\n width: 16px;\n height: 16px;\n padding: 4px;\n cursor: pointer;\n box-sizing: content-box;\n }\n\n .g6-toolbar .g6-toolbar-item:hover {\n background-color: #f0f0f0;\n }\n\n .g6-toolbar .g6-toolbar-item svg {\n display: inline-block;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n",document.head),eB("g6-toolbar-svgicon","div",{display:"none"},'\n <svg>\n <symbol id="zoom-in" viewBox="64 64 896 896">\n <path d="M637 443H519V309c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v134H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h118v134c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V519h118c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="zoom-out" viewBox="64 64 896 896">\n <path d="M637 443H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h312c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="edit" viewBox="64 64 896 896">\n <path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>\n </symbol>\n <symbol id="delete" viewBox="64 64 896 896">\n <path d="M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"></path>\n </symbol>\n <symbol id="redo" viewBox="64 64 896 896">\n <path d="M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 00-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z"></path>\n </symbol>\n <symbol id="undo" viewBox="64 64 896 896">\n <path d="M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z"></path>\n </symbol>\n <symbol id="export" viewBox="64 64 896 896">\n <path d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"></path>\n </symbol>\n <symbol id="auto-fit" viewBox="64 64 896 896">\n <path d="M952 474H829.8C812.5 327.6 696.4 211.5 550 194.2V72c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v122.2C327.6 211.5 211.5 327.6 194.2 474H72c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h122.2C211.5 696.4 327.6 812.5 474 829.8V952c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V829.8C696.4 812.5 812.5 696.4 829.8 550H952c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM512 756c-134.8 0-244-109.2-244-244s109.2-244 244-244 244 109.2 244 244-109.2 244-244 244z"></path>\n <path d="M512 392c-32.1 0-62.1 12.4-84.8 35.2-22.7 22.7-35.2 52.7-35.2 84.8s12.5 62.1 35.2 84.8C449.9 619.4 480 632 512 632s62.1-12.5 84.8-35.2C619.4 574.1 632 544 632 512s-12.5-62.1-35.2-84.8A118.57 118.57 0 00512 392z"></path>\n </symbol>\n <symbol id="reset" viewBox="64 64 896 896">\n <path d="M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"></path>\n </symbol>\n <symbol id="exit-fullscreen" viewBox="0 0 1024 1024">\n <path d="M418.13333333 361.43786666c0 0.2048-0.13653333 0.4096-0.13653334 0.68266667C417.99679999 362.32533333 418.13333333 362.53013333 418.13333333 362.73493333 418.13333333 371.54133333 414.44693333 379.392 408.78079999 385.39946666 408.43946666 385.7408 408.30293333 386.21866666 408.02986666 386.49173333c-1.09226667 1.09226667-2.59413333 1.77493333-3.82293333 2.73066667C398.40426666 393.65973333 391.64586666 396.8 383.93173333 396.8 383.72693333 396.8 383.59039999 396.73173333 383.38559999 396.73173333S382.97599999 396.8 382.77119999 396.8L112.29866666 396.8C92.50133333 396.8 76.79999999 381.50826666 76.79999999 362.66666666 76.66346666 343.89333333 92.63786666 328.53333333 112.16213333 328.53333333l189.44 0L87.44959999 114.51733333C73.59146666 100.59093333 73.25013333 78.5408 86.63039999 65.29706666c13.17546667-13.44853333 35.36213333-12.97066667 49.152 0.88746667l214.08426667 214.08426667L349.86666666 90.89706666C349.79839999 71.23626666 365.22666666 55.46666666 383.99999999 55.46666666 402.77333333 55.33013333 418.13333333 71.30453333 418.13333333 90.8288L418.13333333 361.43786666zM928.90453333 328.53333333l-189.44 0 214.15253333-214.08426667c13.85813333-13.9264 14.19946667-35.90826667 0.88746667-49.22026666-13.17546667-13.44853333-35.36213333-12.97066667-49.152 0.88746666l-214.08426667 214.08426667L691.26826666 90.89706666C691.26826666 71.23626666 675.83999999 55.46666666 657.06666666 55.46666666 638.29333333 55.33013333 622.93333333 71.30453333 622.93333333 90.8288l0 270.60906666c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 362.32533333 622.93333333 362.53013333 622.93333333 362.73493333 622.93333333 371.54133333 626.61973333 379.392 632.28586666 385.39946666c0.34133333 0.34133333 0.47786667 0.8192 0.8192 1.09226667 1.09226667 1.09226667 2.59413333 1.77493333 3.8912 2.73066667C642.66239999 393.65973333 649.42079999 396.8 657.13493333 396.8c0.2048 0 0.34133333-0.06826667 0.54613333-0.06826667S658.09066666 396.8 658.29546666 396.8l270.5408 0C948.56533333 396.8 964.26666666 381.50826666 964.26666666 362.66666666 964.40319999 343.89333333 948.42879999 328.53333333 928.90453333 328.53333333zM418.13333333 635.73333333c0-8.8064-3.6864-16.5888-9.35253334-22.66453333C408.43946666 612.72746666 408.30293333 612.2496 408.02986666 611.90826666 406.86933333 610.88426666 405.43573333 610.2016 404.20693333 609.24586666 398.47253333 604.80853333 391.64586666 601.6 383.93173333 601.6 383.72693333 601.6 383.59039999 601.73653333 383.38559999 601.73653333S382.97599999 601.6 382.77119999 601.6L112.29866666 601.6C92.50133333 601.6 76.79999999 616.96 76.79999999 635.73333333 76.66346666 654.50666666 92.63786666 669.86666666 112.16213333 669.86666666l189.44 0-214.15253334 214.15253334c-13.85813333 13.85813333-14.19946667 35.84-0.88746666 49.22026666 13.17546667 13.44853333 35.36213333 12.9024 49.152-0.95573333l214.08426666-214.08426667 0 189.37173334c0 19.59253333 15.42826667 35.49866667 34.2016 35.36213333C402.77333333 943.2064 418.13333333 927.232 418.13333333 907.5712L418.13333333 637.09866666c0-0.27306667-0.13653333-0.47786667-0.13653334-0.68266666C417.99679999 636.14293333 418.13333333 635.93813333 418.13333333 635.73333333zM739.46453333 669.86666666l189.44 0c19.456 0 35.49866667-15.36 35.36213333-34.13333333C964.26666666 616.96 948.56533333 601.6 928.76799999 601.6L658.29546666 601.6C658.09066666 601.6 657.88586666 601.73653333 657.68106666 601.73653333S657.33973333 601.6 657.13493333 601.6C649.42079999 601.6 642.59413333 604.80853333 636.85973333 609.24586666 635.63093333 610.2016 634.19733333 610.88426666 633.03679999 611.90826666 632.76373333 612.2496 632.62719999 612.72746666 632.28586666 613.0688 626.61973333 619.14453333 622.93333333 626.92693333 622.93333333 635.73333333c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 636.6208 622.93333333 636.8256 622.93333333 637.09866666l0 270.5408C622.93333333 927.232 638.29333333 943.2064 657.06666666 942.93333333c18.77333333 0.13653333 34.2016-15.70133333 34.2016-35.36213333l0-189.37173334 214.08426667 214.08426667c13.78986667 13.85813333 35.90826667 14.40426667 49.152 0.95573333 13.312-13.312 12.97066667-35.36213333-0.88746667-49.22026666L739.46453333 669.86666666z" ></path></symbol>\n <symbol id="request-fullscreen" viewBox="0 0 1024 1024">\n <path d="M69.818182 87.598545v273.128728a34.909091 34.909091 0 0 0 69.818182 0V163.653818l221.928727 222.021818a33.512727 33.512727 0 0 0 47.383273-47.383272L186.926545 116.363636h197.073455a34.909091 34.909091 0 0 0 0-69.818181H110.871273C85.364364 46.545455 69.818182 59.671273 69.818182 87.598545zM938.542545 46.545455H665.413818a34.909091 34.909091 0 0 0 0 69.818181h197.073455L640.465455 338.292364a33.512727 33.512727 0 0 0 47.383272 47.383272l221.928728-222.021818v197.073455a34.909091 34.909091 0 0 0 69.818181 0V87.598545c0-27.927273-15.453091-41.053091-40.96-41.05309z m-827.671272 907.636363h273.128727a34.909091 34.909091 0 0 0 0-69.818182H186.926545l222.021819-221.928727a33.512727 33.512727 0 0 0-47.383273-47.383273L139.636364 837.073455V640a34.909091 34.909091 0 0 0-69.818182 0v273.128727c0 27.927273 15.546182 41.053091 41.053091 41.053091z m868.724363-41.053091V640a34.909091 34.909091 0 0 0-69.818181 0v197.073455L687.941818 615.051636a33.512727 33.512727 0 0 0-47.383273 47.383273L862.487273 884.363636H665.413818a34.909091 34.909091 0 0 0 0 69.818182h273.128727c25.6 0 41.053091-13.125818 41.053091-41.053091z" ></path></symbol>\n </svg>\n'),this.$element.addEventListener("click",this.onToolbarItemClick),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(this,void 0,void 0,(function*(){e.update.call(this,t);const{className:n,position:r,style:i}=this.options;this.$element.className=`g6-toolbar ${n||""}`,Object.assign(this.$element.style,i,function(t){const e={top:"unset",right:"unset",bottom:"unset",left:"unset"};return t.split("-").forEach((t=>{e[t]="8px"})),e.flexDirection=t.startsWith("top")||t.startsWith("bottom")?"row":"column",e}(r)),this.$element.innerHTML=yield this.getDOMContent()}))}destroy(){this.$element.removeEventListener("click",this.onToolbarItemClick),this.$element.remove(),super.destroy()}getDOMContent(){return ze(this,void 0,void 0,(function*(){return(yield this.options.getItems()).map((t=>`\n <div class="g6-toolbar-item" value="${t.value}">\n <svg aria-hidden="true" focusable="false">\n <use xlink:href="#${t.id}"></use>\n </svg>\n </div>`)).join("")}))}}fH.defaultOptions={position:"top-left"};class pH extends Jj{constructor(t,e){super(t,Object.assign({},pH.defaultOptions,e)),this.currentTarget=null,this.tooltipElement=null,this.container=null,this.isEnable=(t,e)=>{const{enable:n}=this.options;return"function"==typeof n?n(t,e):n},this.onClick=t=>{const{target:{id:e}}=t;this.currentTarget===e?this.hide(t):this.show(t)},this.onPointerMove=t=>{const{target:e}=t;this.currentTarget&&e.id!==this.currentTarget&&this.show(t)},this.onPointerLeave=t=>{this.hide(t)},this.onCanvasMove=t=>{this.hide(t)},this.onPointerEnter=t=>{this.show(t)},this.showById=t=>ze(this,void 0,void 0,(function*(){const e={target:{id:t}};yield this.show(e)})),this.getElementData=(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[]}},this.show=t=>ze(this,void 0,void 0,(function*(){var e,n;const{client:r,target:{id:i}}=t;if(Lg(t.target))return;const o=this.context.graph.getElementType(i),{getContent:a,title:s}=this.options,l=this.getElementData(i,o);if(!this.tooltipElement||!this.isEnable(t,l))return;let u,c,h={};if(a){if(h.content=yield a(t,l),!h.content)return}else{const t=this.context.graph.getElementRenderStyle(i),e="node"===o?t.fill:t.stroke;h={title:s||o,data:l.map((t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:e})))}}if(this.currentTarget=i,r)u=r.x,c=r.y;else{const t=Oe(l,"0.style",{x:0,y:0});u=t.x,c=t.y}null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!0),this.tooltipElement.update(Object.assign(Object.assign(Object.assign({},this.tooltipStyleProps),{x:u,y:c,style:{".tooltip":{visibility:"visible"}}}),h))})),this.hide=t=>{var e,n,r,i,o;if(!t)return null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!1),null===(r=this.tooltipElement)||void 0===r||r.hide(),void(this.currentTarget=null);if(!this.tooltipElement)return;if(!this.currentTarget)return;const{client:{x:a,y:s}}=t;null===(o=(i=this.options).onOpenChange)||void 0===o||o.call(i,!1),this.tooltipElement.hide(a,s),this.currentTarget=null},this.initTooltip=()=>{var t;const e=new SW({className:"tooltip",style:this.tooltipStyleProps});return null===(t=this.container)||void 0===t||t.appendChild(e.HTMLTooltipElement),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,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){var e;this.unbindEvents(),super.update(t),this.tooltipElement&&(null===(e=this.container)||void 0===e||e.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())}unbindEvents(){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])}))}get tooltipStyleProps(){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:l={x:-i,y:-r},title:u,offset:c}=this.options,[h,d]=e,[f,p]=t.getSize();return{x:h,y:d,container:l,title:u,bounding:{x:0,y:0,width:f,height:p},position:a,enterable:s,offset:c,style:o}}destroy(){var t;this.unbindEvents(),this.tooltipElement&&(null===(t=this.container)||void 0===t||t.removeChild(this.tooltipElement.HTMLTooltipElement)),super.destroy()}}let gH;function vH(t,e){gH||(gH=document.createElement("canvas")),gH.width=t,gH.height=e;return gH.getContext("2d").clearRect(0,0,t,e),gH}pH.defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};class mH extends Jj{constructor(t,e){super(t,Object.assign({},mH.defaultOptions,e)),this.$element=tB("watermark");this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(this,void 0,void 0,(function*(){e.update.call(this,t);const n=this.options,{width:r,height:i,text:o,imageURL:a}=n,s=Fe(n,["width","height","text","imageURL"]);Object.keys(s).forEach((e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])}));const l=a?yield function(t,e,n,r){return ze(this,void 0,void 0,(function*(){const i=vH(t,e),o=i.getContext("2d"),{rotate:a,opacity:s}=r;a&&o.rotate(a),s&&(o.globalAlpha=s);const l=new Image;return l.crossOrigin="anonymous",l.src=n,new Promise((n=>{l.onload=function(){const r=t>l.width?(t-l.width)/2:0,a=e>l.height?(e-l.height)/2:0;o.drawImage(l,0,0,l.width,l.height,r,a,t-2*r,e-2*a),n(i.toDataURL())}}))}))}(r,i,a,s):yield function(t,e,n,r){return ze(this,void 0,void 0,(function*(){const i=vH(t,e),o=i.getContext("2d"),{rotate:a,opacity:s,textFill:l,textFontSize:u,textFontFamily:c,textFontVariant:h,textFontWeight:d,textAlign:f,textBaseline:p}=r;return o.textAlign=f,o.textBaseline=p,o.translate(t/2,e/2),o.font=`${u}px ${c} ${h} ${d}`,a&&o.rotate(a),s&&(o.globalAlpha=s),l&&(o.fillStyle=l,o.fillText(`${n}`,0,0)),i.toDataURL()}))}(r,i,o,s);this.$element.style.backgroundImage=`url(${l})`}))}destroy(){super.destroy(),this.$element.remove()}}mH.defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};const yH=["#7E92B5","#F4664A","#FFBE3A"],bH={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},xH={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function EH(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeHaloStrokeOpacityActive:a=.15,nodeHaloStrokeOpacitySelected:s=.25,nodeOpacityDisabled:l=.06,nodeIconOpacityInactive:u=.85,nodeOpacityInactive:c=.25,nodeBadgePalette:h=yH,nodePaletteOptions:d=bH,edgeColor:f,edgeColorDisabled:p,edgePaletteOptions:g=xH,comboColor:v,comboColorDisabled:m,comboStroke:y,comboStrokeDisabled:b,edgeColorInactive:x}=t;return{background:e,node:{palette:d,style:{donutOpacity:1,badgeBackgroundOpacity:1,badgeFill:"#fff",badgeFontSize:8,badgePadding:[0,4],badgePalette:h,fill:r,fillOpacity:1,halo:!1,iconFill:"#fff",iconOpacity:1,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelFill:n,labelFillOpacity:.85,labelLineHeight:16,labelPadding:[0,2],labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelOffsetY:2,lineWidth:0,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65,size:32,stroke:o,strokeOpacity:1,zIndex:2},state:{selected:{halo:!0,haloLineWidth:24,haloStrokeOpacity:s,labelFontSize:12,labelFontWeight:"bold",lineWidth:4,stroke:o},active:{halo:!0,haloLineWidth:12,haloStrokeOpacity:a},highlight:{labelFontWeight:"bold",lineWidth:4,stroke:o,strokeOpacity:.85},inactive:{badgeBackgroundOpacity:c,donutOpacity:c,fillOpacity:c,iconOpacity:u,labelFill:n,labelFillOpacity:c,strokeOpacity:c},disabled:{badgeBackgroundOpacity:.25,donutOpacity:l,fill:i,fillOpacity:l,iconFill:i,iconOpacity:.25,labelFill:n,labelFillOpacity:.25,strokeOpacity:l}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"node-expand",collapse:"node-collapse",update:[{fields:["x","y","fill","stroke"]}],translate:[{fields:["x","y"]}]}},edge:{palette:g,style:{badgeBackgroundFill:f,badgeFill:"#fff",badgeFontSize:8,badgeOffsetX:10,fillOpacity:1,halo:!1,haloLineWidth:12,haloStrokeOpacity:1,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1,stroke:f,strokeOpacity:1,zIndex:1},state:{selected:{halo:!0,haloStrokeOpacity:.25,labelFontSize:14,labelFontWeight:"bold",lineWidth:3},active:{halo:!0,haloStrokeOpacity:.15},highlight:{labelFontWeight:"bold",lineWidth:3},inactive:{stroke:x,fillOpacity:.08,labelOpacity:.25,strokeOpacity:.08,badgeBackgroundOpacity:.25},disabled:{stroke:p,fillOpacity:.45,strokeOpacity:.45,labelOpacity:.25,badgeBackgroundOpacity:.45}},animation:{enter:"fade",exit:"fade",expand:"path-in",collapse:"path-out",show:"fade",hide:"fade",update:[{fields:["sourceNode","targetNode"]},{fields:["stroke"],shape:"key"}],translate:[{fields:["sourceNode","targetNode"]}]}},combo:{style:{collapsedMarkerFill:e,collapsedMarkerFontSize:12,collapsedMarkerFillOpacity:1,collapsedSize:32,collapsedFillOpacity:1,fill:v,halo:!1,haloLineWidth:12,haloStroke:y,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineDash:0,lineWidth:1,fillOpacity:.04,strokeOpacity:1,padding:10,stroke:y},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{fillOpacity:.65,labelOpacity:.25,strokeOpacity:.65},disabled:{fill:m,fillOpacity:.25,labelOpacity:.25,stroke:b,strokeOpacity:.25}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"combo-expand",collapse:"combo-collapse",update:[{fields:["x","y"]},{fields:["fill","stroke","lineWidth"],shape:"key"}],translate:[{fields:["x","y"]}]}}}}const wH=EH({bgColor:"#000000",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696",edgeColor:"#637088",edgeColorDisabled:"#637088",edgeColorInactive:"#D0E4FF",edgePaletteOptions:{type:"group",color:["#637088","#0F55A6","#008383","#9C5D38","#8B53A6","#4E40A6","#8F6608","#3E801D","#A65383","#175E75","#0F8248"]},nodeColor:"#1783ff",nodeColorDisabled:"#D0E4FF",nodeHaloStrokeOpacityActive:.25,nodeHaloStrokeOpacitySelected:.45,nodeIconOpacityInactive:.45,nodeOpacityDisabled:.25,nodeOpacityInactive:.45,nodeStroke:"#d0e4ff",textColor:"#ffffff"}),kH=EH({bgColor:"#ffffff",comboColor:"#99ADD1",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",edgeColorInactive:"#1B324F",nodeColor:"#1783ff",nodeColorDisabled:"#1B324F",nodeHaloStrokeOpacityActive:.15,nodeHaloStrokeOpacitySelected:.25,nodeIconOpacityInactive:.85,nodeOpacityDisabled:.06,nodeOpacityInactive:.25,nodeStroke:"#000000",textColor:"#000000"});class MH extends Rh{beforeDraw(t,e){return t}afterLayout(t,e){}}function SH(t,e,n,r,i){const o=yh(r),a=`${n}s`,s=i?r:t.add[a].get(o)||t.update[a].get(o)||t.remove[a].get(o)||r;Object.entries(t).forEach((([t,n])=>{e===t?n[a].set(o,s):n[a].delete(o)}))}function NH(t,e){return Object.keys(t).every((n=>t[n]===e[n]))}const OH=(t,e,n,r)=>{const i=`${n}s`,o=yh(r);t.add[i].has(o)||t.update[i].has(o)||t[e][i].set(yh(r),r)};const TH=new WeakMap;const AH=(t,e,n=2)=>{if("object"!=typeof t||"object"!=typeof e)return t===e;const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const i of r){const r=t[i],o=e[i];if(n>1&&"object"==typeof r&&"object"==typeof o){if(!AH(r,o,n-1))return!1}else if(r!==o)return!1}return!0};function CH(t,e,n,r=!1){const i=Mc[t][e];!r&&i?i!==n&&Tc(`The extension ${e} of ${t} has been registered before.`):Object.assign(Mc[t],{[e]:n})}
72
72
  /*!
73
73
  * @antv/g-plugin-dragndrop
74
74
  * @description A G plugin for Drag n Drop implemented with PointerEvents
@@ -76,4 +76,4 @@ var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).
76
76
  * @date 1/2/2025, 2:55:43 AM
77
77
  * @author AntVis
78
78
  * @docs https://g.antv.antgroup.com/
79
- */var PH=function(){function t(e){s(this,t),this.dragndropPluginOptions=e}return u(t,[{key:"apply",value:function(e){var n=this,r=e.renderingService,i=e.renderingContext.root.ownerDocument,o=i.defaultView,a=function(t){var e=t.target,r=e===i,a=r&&n.dragndropPluginOptions.isDocumentDraggable?i:e.closest&&e.closest("[draggable=true]");if(a){var s=!1,l=t.timeStamp,u=[t.clientX,t.clientY],c=null,h=[t.clientX,t.clientY],d=function(){var t=Pr(Ar().mark((function t(o){var d,f,p,g,v,m;return Ar().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s){t.next=8;break}if(d=o.timeStamp-l,f=gn([o.clientX,o.clientY],u),!(d<=n.dragndropPluginOptions.dragstartTimeThreshold||f<=n.dragndropPluginOptions.dragstartDistanceThreshold)){t.next=5;break}return t.abrupt("return");case 5:o.type="dragstart",a.dispatchEvent(o),s=!0;case 8:if(o.type="drag",o.dx=o.clientX-h[0],o.dy=o.clientY-h[1],a.dispatchEvent(o),h=[o.clientX,o.clientY],r){t.next=21;break}return p="pointer"===n.dragndropPluginOptions.overlap?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=17,i.elementsFromPoint(p[0],p[1]);case 17:g=t.sent,v=g[g.indexOf(e)+1],m=(null==v?void 0:v.closest("[droppable=true]"))||(n.dragndropPluginOptions.isDocumentDroppable?i:null),c!==m&&(c&&(o.type="dragleave",o.target=c,c.dispatchEvent(o)),m&&(o.type="dragenter",o.target=m,m.dispatchEvent(o)),(c=m)&&(o.type="dragover",o.target=c,c.dispatchEvent(o)));case 21:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();o.addEventListener("pointermove",d);var f=function(t){if(s){t.detail={preventClick:!0};var e=t.clone();c&&(e.type="drop",e.target=c,c.dispatchEvent(e)),e.type="dragend",a.dispatchEvent(e),s=!1}o.removeEventListener("pointermove",d)};e.addEventListener("pointerup",f,{once:!0}),e.addEventListener("pointerupoutside",f,{once:!0})}};r.hooks.init.tap(t.tag,(function(){o.addEventListener("pointerdown",a)})),r.hooks.destroy.tap(t.tag,(function(){o.removeEventListener("pointerdown",a)}))}}])}();PH.tag="Dragndrop";var RH=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,e),(t=v(this,e)).name="dragndrop",t.options=n,t}return y(e,t),u(e,[{key:"init",value:function(){this.addRenderingPlugin(new PH(a({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}},{key:"setOptions",value:function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)}}])}(Br);const DH=["main"],LH=["background","main","label","transient"];class _H{getConfig(){return this.config}getLayer(t="main"){return this.extends.layers[t]||this.getLayers().main}getLayers(){return this.extends.layers}getRenderer(t){return this.extends.renderers[t]}getCamera(t="main"){return this.getLayer(t).getCamera()}getRoot(t="main"){return this.getLayer(t).getRoot()}getContextService(t="main"){return this.getLayer(t).getContextService()}setCursor(t){this.config.cursor=t,this.getLayer().setCursor(t)}get document(){return this.getLayer().document}get context(){return this.getLayer().context}constructor(t){this.config={enableMultiLayer:!0},Object.assign(this.config,t);const e=this.config,{renderer:n,background:r,cursor:i,enableMultiLayer:o}=e,a=Fe(e,["renderer","background","cursor","enableMultiLayer"]),s=o?LH:DH,l=IH(n,s),u=Object.fromEntries(s.map((t=>[t,new hu(Object.assign(Object.assign({},a),{supportsMutipleCanvasesInOneContainer:o,renderer:l[t],background:o?"background"===t?r:void 0:r}))])));jH(u),this.extends={config:this.config,renderer:n,renderers:l,layers:u}}get ready(){return Promise.all(Object.entries(this.getLayers()).map((([,t])=>t.ready)))}resize(t,e){Object.assign(this.extends.config,{width:t,height:e}),Object.values(this.getLayers()).forEach((n=>{const r=n.getCamera(),i=r.getPosition(),o=r.getFocalPoint();n.resize(t,e),r.setPosition(i),r.setFocalPoint(o)}))}getBounds(t){return Jc(Object.values(this.getLayers()).map((e=>t?e.getRoot().childNodes.find((e=>e.classList.includes(t))):e.getRoot())).filter((t=>(null==t?void 0:t.childNodes.length)>0)).map((t=>t.getBounds())))}getContainer(){const t=this.extends.config.container;return"string"==typeof t?document.getElementById(t):t}getSize(){return[this.extends.config.width||0,this.extends.config.height||0]}appendChild(t,e){var n;const r=(null===(n=t.style)||void 0===n?void 0:n.$layer)||"main";return this.getLayer(r).appendChild(t,e)}setRenderer(t){if(t===this.extends.renderer)return;const e=IH(t,this.config.enableMultiLayer?LH:DH);this.extends.renderers=e,Object.entries(e).forEach((([t,e])=>this.getLayer(t).setRenderer(e))),jH(this.getLayers())}getCanvasByViewport(t){return ed(this.getLayer().viewport2Canvas(nd(t)))}getViewportByCanvas(t){return ed(this.getLayer().canvas2Viewport(nd(t)))}getViewportByClient(t){return ed(this.getLayer().client2Viewport(nd(t)))}getClientByViewport(t){return ed(this.getLayer().viewport2Client(nd(t)))}getClientByCanvas(t){return this.getClientByViewport(this.getViewportByCanvas(t))}getCanvasByClient(t){const e=this.getLayer(),n=e.client2Viewport(nd(t));return ed(e.viewport2Canvas(n))}toDataURL(){return ze(this,arguments,void 0,(function*(t={}){const e=globalThis.devicePixelRatio||1,{mode:n="viewport"}=t,r=Fe(t,["mode"]);let[i,o,a,s]=[0,0,0,0];if("viewport"===n)[a,s]=this.getSize();else if("overall"===n){const t=this.getBounds(),e=Xc(t);[i,o]=t.min,[a,s]=e}const l=An('<div id="virtual-image"></div>'),u=new hu({width:a,height:s,renderer:new kp,devicePixelRatio:e,container:l,background:this.extends.config.background});yield u.ready,u.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),u.appendChild(this.getRoot().cloneNode(!0));const c=this.getLayer("label").getRoot().cloneNode(!0),h=u.viewport2Canvas({x:0,y:0}),d=this.getCanvasByViewport([0,0]);c.translate([d[0]-h.x,d[1]-h.y]),c.scale(1/this.getCamera().getZoom()),u.appendChild(c),u.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const f=this.getCamera(),p=u.getCamera();if("viewport"===n)p.setZoom(f.getZoom()),p.setPosition(f.getPosition()),p.setFocalPoint(f.getFocalPoint());else if("overall"===n){const[t,e,n]=p.getPosition(),[r,a,s]=p.getFocalPoint();p.setPosition([t+i,e+o,n]),p.setFocalPoint([r+i,a+o,s])}const g=u.getContextService();return new Promise((t=>{u.addEventListener(ou.RERENDER,(()=>ze(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,300)));const e=yield g.toDataURL(r);t(e)}))))}))}))}destroy(){Object.values(this.getLayers()).forEach((t=>{t.getCamera().cancelLandmarkAnimation(),t.destroy()}))}}function IH(t,e){return Object.fromEntries(e.map((e=>{const n=(null==t?void 0:t(e))||new kp;return"main"===e?n.registerPlugin(new RH({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):n.unregisterPlugin(n.getPlugin("dom-interaction")),[e,n]})))}function jH(t){Object.entries(t).forEach((([t,e])=>{const n=e.getContextService().getDomElement();(null==n?void 0:n.style)&&(n.style.gridArea="1 / 1 / 2 / 2",n.style.outline="none",n.tabIndex=1,"main"!==t&&(n.style.pointerEvents="none")),(null==n?void 0:n.parentElement)&&(n.parentElement.style.display="grid")}))}const BH=t=>t?parseInt(t):0;function FH(t){if(!t)return[0,0];let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||BH(e.width),r=t.clientHeight||BH(e.height);return[n-(BH(e.paddingLeft)+BH(e.paddingRight)),r-(BH(e.paddingTop)+BH(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(ae(e)?e:1,1),Math.max(ae(n)?n:1,1)]}class zH{constructor(t){this.type=t}}class GH extends zH{constructor(t,e){super(t),this.data=e}}class VH extends zH{constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class WH extends zH{constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class HH extends zH{constructor(t,e){super(t),this.data=e}}function YH(t,e){t.emit(e.type,e)}function UH(t){var e;return(null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0}const $H="cachedStyle",qH=t=>`__${t}__`;function XH(t,e){return Oe(t,[$H,qH(e)])}class KH{constructor(t){this.tasks=[],this.animations=new Set,this.context=t}getTasks(){const t=[...this.tasks];return this.tasks=[],t}add(t,e){this.tasks.push([t,e])}animate(t,e,n){var r,i,o;null===(r=null==e?void 0:e.before)||void 0===r||r.call(e);const a=this.getTasks().map((([e,r])=>{var i,o,a;const{element:s,elementType:l,stage:u}=e,c=Lc(this.context.options,l,u,t);null===(i=null==r?void 0:r.before)||void 0===i||i.call(r);const h=c.length?Ic(s,this.inferStyle(e,n),c):null;return h?(null===(o=null==r?void 0:r.beforeAnimate)||void 0===o||o.call(r,h),h.finished.then((()=>{var t,e;null===(t=null==r?void 0:r.afterAnimate)||void 0===t||t.call(r,h),null===(e=null==r?void 0:r.after)||void 0===e||e.call(r),this.animations.delete(h)}))):null===(a=null==r?void 0:r.after)||void 0===a||a.call(r),h})).filter(Boolean);a.forEach((t=>this.animations.add(t)));const s=Cc(a);return s?(null===(i=null==e?void 0:e.beforeAnimate)||void 0===i||i.call(e,s),s.finished.then((()=>{var t,n;null===(t=null==e?void 0:e.afterAnimate)||void 0===t||t.call(e,s),null===(n=null==e?void 0:e.after)||void 0===n||n.call(e),this.release()}))):null===(o=null==e?void 0:e.after)||void 0===o||o.call(e),s}inferStyle(t,e){var n,r;const{element:i,elementType:o,stage:a,originalStyle:s,updatedStyle:l={}}=t;t.modifiedStyle||(t.modifiedStyle=Object.assign(Object.assign({},s),l));const{modifiedStyle:u}=t,c={},h={};if("enter"===a)Object.assign(c,{opacity:0});else if("exit"===a)Object.assign(h,{opacity:0});else if("show"===a)Object.assign(c,{opacity:0}),Object.assign(h,{opacity:null!==(n=XH(i,"opacity"))&&void 0!==n?n:Rc("opacity")});else if("hide"===a)Object.assign(c,{opacity:null!==(r=XH(i,"opacity"))&&void 0!==r?r:Rc("opacity")}),Object.assign(h,{opacity:0});else if("collapse"===a){const{collapse:t}=e||{},{target:n,descendants:r,position:a}=t;if("node"===o){if(r.includes(i.id)){const[t,e,n]=a;Object.assign(h,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e]=a;Object.assign(h,{x:t,y:e,childrenNode:s.childrenNode})}}else"edge"===o&&Object.assign(h,{sourceNode:u.sourceNode,targetNode:u.targetNode})}else if("expand"===a){const{expand:t}=e||{},{target:n,descendants:r,position:a}=t;if("node"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=a;Object.assign(c,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=a;Object.assign(c,{x:t,y:e,z:n,childrenNode:u.childrenNode})}}else"edge"===o&&Object.assign(c,{sourceNode:u.sourceNode,targetNode:u.targetNode})}return[Object.keys(c).length>0?Object.assign({},s,c):s,Object.keys(h).length>0?Object.assign({},u,h):u]}stop(){this.animations.forEach((t=>t.cancel()))}clear(){this.tasks=[]}release(){var t,e;const{canvas:n}=this.context,r=null===(e=null===(t=n.document)||void 0===t?void 0:t.timeline)||void 0===e?void 0:e.animationsWithPromises;r&&(n.document.timeline.animationsWithPromises=r.filter((t=>"finished"!==t.playState)))}destroy(){this.stop(),this.animations.clear(),this.tasks=[]}}class ZH{constructor(t){this.batchCount=0,this.context=t}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}startBatch(e=!0){this.batchCount++,1===this.batchCount&&this.emit(new GH(t.GraphEvent.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,0===this.batchCount&&this.emit(new GH(t.GraphEvent.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class QH extends Ph{constructor(e){super(e),this.currentTarget=null,this.currentTargetType=null,this.category="behavior",this.forwardCanvasEvents=e=>{const{target:n}=e,r=function(t){if(!t)return null;if(t instanceof Jl)return{type:"canvas",element:t};let e=t;for(;e;){if(xg(e))return{type:"node",element:e};if(Eg(e))return{type:"edge",element:e};if(wg(e))return{type:"combo",element:e};e=e.parentElement}return null}(n);if(!r)return;const{graph:i,canvas:o}=this.context,{type:a,element:s}=r;if("destroyed"in s&&(Lg(s)||s.destroyed))return;const{type:l,detail:u,button:c}=e,h=Object.assign(Object.assign({},e),{target:s,targetType:a,originalTarget:n});l===t.CommonEvent.POINTER_MOVE&&(this.currentTarget!==s&&(this.currentTarget&&i.emit(`${this.currentTargetType}:${t.CommonEvent.POINTER_LEAVE}`,Object.assign(Object.assign({},h),{type:t.CommonEvent.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),s&&(Object.assign(h,{type:t.CommonEvent.POINTER_ENTER}),i.emit(`${a}:${t.CommonEvent.POINTER_ENTER}`,h))),this.currentTarget=s,this.currentTargetType=a),l===t.CommonEvent.CLICK&&2===c||(i.emit(`${a}:${l}`,h),i.emit(l,h)),l===t.CommonEvent.CLICK&&2===u&&(Object.assign(h,{type:t.CommonEvent.DBLCLICK}),i.emit(`${a}:${t.CommonEvent.DBLCLICK}`,h),i.emit(t.CommonEvent.DBLCLICK,h)),l===t.CommonEvent.POINTER_DOWN&&2===c&&(Object.assign(h,{type:t.CommonEvent.CONTEXT_MENU,preventDefault:()=>{var e;null===(e=o.getContainer())||void 0===e||e.addEventListener(t.CommonEvent.CONTEXT_MENU,(t=>t.preventDefault()),{once:!0})}}),i.emit(`${a}:${t.CommonEvent.CONTEXT_MENU}`,h),i.emit(t.CommonEvent.CONTEXT_MENU,h))},this.forwardContainerEvents=t=>{this.context.graph.emit(t.type,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)}));const n=this.context.canvas.document;n&&[t.CommonEvent.CLICK,t.CommonEvent.DBLCLICK,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE,t.CommonEvent.POINTER_ENTER,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_OUT,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_UP,t.CommonEvent.CONTEXT_MENU,t.CommonEvent.DRAG_START,t.CommonEvent.DRAG,t.CommonEvent.DRAG_END,t.CommonEvent.DRAG_ENTER,t.CommonEvent.DRAG_OVER,t.CommonEvent.DRAG_LEAVE,t.CommonEvent.DROP,t.CommonEvent.WHEEL].forEach((t=>{n.addEventListener(t,this.forwardCanvasEvents)}))}destroy(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach((t=>{e.removeEventListener(t,this.forwardContainerEvents)})),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}function JH(t,e){const{data:n,style:r}=t,i=Fe(t,["data","style"]),{data:o,style:a}=e,s=Fe(e,["data","style"]),l=Object.assign(Object.assign({},i),s);return(n||o)&&Object.assign(l,{data:Object.assign(Object.assign({},n),o)}),(r||a)&&Object.assign(l,{style:Object.assign(Object.assign({},r),a)}),l}function tY(t){const{data:e,style:n}=t,r=Fe(t,["data","style"]);return e&&(r.data=Object.assign({},e)),n&&(r.style=Object.assign({},n)),r}function eY(t={},e={}){const{states:n=[],data:r={},style:i={},children:o=[]}=t,a=Fe(t,["states","data","style","children"]),{states:s=[],data:l={},style:u={},children:c=[]}=e,h=(t,e)=>t.length===e.length&&t.every(((t,n)=>t===e[n])),d=(t,e)=>{const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every((n=>t[n]===e[n]))};return!!d(a,Fe(e,["states","data","style","children"]))&&(!!h(o,c)&&(!!h(n,s)&&(!!d(r,l)&&!!d(i,u))))}function nY(t){const{id:e=yh(t),style:n,data:r}=t,i=Fe(t,["id","style","data"]),o=Object.assign(Object.assign({},t),{style:Object.assign({},n),data:Object.assign({},r)});return function(t){return"source"in t&&"target"in t}(t)?Object.assign({id:e,data:o},i):{id:e,data:o}}function rY(t){return t.data}class iY{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new Yg}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===dc.NodeUpdated||e===dc.EdgeUpdated||e===dc.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:tY(n),original:tY(r),type:e})}else this.changes.push({value:tY(t.value),type:e})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}isBatching(){return this.batchCount>0}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=rY(n);return this.isCombo(yh(r))||(void 0===t||t.includes(yh(r)))&&e.push(r),e}),[])}getEdgeDatum(t){return rY(this.model.getEdge(t))}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=rY(n);return(void 0===t||t.includes(yh(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=rY(n);return this.isCombo(yh(r))?((void 0===t||t.includes(yh(r)))&&e.push(r),e):e}),[])}getRootsData(t=wc){return this.model.getRoots(t).map(rY)}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(rY):[]}getDescendantsData(t){const e=this.getElementDataById(t),n=[];return xd(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(yh(t))),"TB"),n}getParentData(t,e){const{model:n}=this;if(!e)return void Tc("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?rY(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?wc:Ec,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(rY):[]}getElementsDataByType(t){return"node"===t?this.getNodeData():"edge"===t?this.getEdgeData():"combo"===t?this.getComboData():[]}getElementDataById(t){return"edge"===this.getElementType(t)?this.getEdgeDatum(t):this.getNodeLikeDatum(t)}getNodeLikeDatum(t){return rY(this.model.getNode(t))}getNodeLikeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=rY(n);return t?t.includes(yh(r))&&e.push(r):e.push(r),e}),[])}getElementDataByState(t,e){return this.getElementsDataByType(t).filter((t=>{var n;return null===(n=t.states)||void 0===n?void 0:n.includes(e)}))}getElementState(t){var e;return(null===(e=this.getElementDataById(t))||void 0===e?void 0:e.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(rY)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(rY)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i,edges:o,combos:a}=this.getData(),s=Ah(i,e,(t=>yh(t)),eY),l=Ah(o,n,(t=>yh(t)),eY),u=Ah(a,r,(t=>yh(t)),eY);this.batch((()=>{const t={nodes:s.enter,edges:l.enter,combos:u.enter};this.addData(t),this.computeZIndex(t,"add",!0);const e={nodes:s.update,edges:l.update,combos:u.update};this.updateData(e),this.computeZIndex(e,"update",!0);const n={nodes:s.exit.map(yh),edges:l.exit.map(yh),combos:u.exit.map(yh)};this.removeData(n)}))}addData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.addComboData(r),this.addNodeData(e),this.addEdgeData(n)})),this.computeZIndex(t,"add")}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map((t=>(this.pushChange({value:t,type:dc.NodeAdded}),nY(t))))),this.updateNodeLikeHierarchy(t),this.computeZIndex({nodes:t},"add"))}addEdgeData(t=[]){t.length&&(this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:dc.EdgeAdded}),nY(t))))),this.computeZIndex({edges:t},"add"))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(Ec)||e.attachTreeStructure(Ec),e.addNodes(t.map((t=>(this.comboIds.add(yh(t)),this.pushChange({value:t,type:dc.ComboAdded}),nY(t))))),this.updateNodeLikeHierarchy(t),this.computeZIndex({combos:t},"add")}addChildrenData(t,e){const n=this.getNodeLikeDatum(t),r=e.map(yh);this.addNodeData(e),this.updateNodeData([{id:t,children:[...n.children||[],...r]}]),this.addEdgeData(r.map((e=>({source:t,target:e}))))}computeZIndex(t,e,n=!1){!n&&this.isBatching()||this.batch((()=>{const{nodes:n=[],edges:r=[],combos:i=[]}=t;i.forEach((t=>{var n,r,i;const o=yh(t);if("add"===e&&ae(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t))return;const a=this.getParentData(o,Ec),s=a?(null!==(i=null===(r=a.style)||void 0===r?void 0:r.zIndex)&&void 0!==i?i:0)+1:0;this.preventUpdateNodeLikeHierarchy((()=>{this.updateComboData([{id:o,style:{zIndex:s}}])}))})),n.forEach((t=>{var n,r,i;const o=yh(t);if("add"===e&&ae(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t)&&!("children"in t))return;let a=0;const s=this.getParentData(o,Ec);if(s)a=((null===(r=s.style)||void 0===r?void 0:r.zIndex)||0)+1;else{const t=this.getParentData(o,wc);t&&(a=(null===(i=null==t?void 0:t.style)||void 0===i?void 0:i.zIndex)||0)}this.preventUpdateNodeLikeHierarchy((()=>{this.updateNodeData([{id:o,style:{zIndex:a}}])}))})),r.forEach((t=>{var e,n,r,i,o;if(ae(null===(e=t.style)||void 0===e?void 0:e.zIndex))return;let{id:a,source:s,target:l}=t;if(a){const t=this.getEdgeDatum(a);s=t.source,l=t.target}else a=yh(t);if(!s||!l)return;const u=(null===(r=null===(n=this.getNodeLikeDatum(s))||void 0===n?void 0:n.style)||void 0===r?void 0:r.zIndex)||0,c=(null===(o=null===(i=this.getNodeLikeDatum(l))||void 0===i?void 0:i.style)||void 0===o?void 0:o.zIndex)||0;this.updateEdgeData([{id:yh(t),style:{zIndex:Math.max(u,c)-1}}])}))}))}getFrontZIndex(t){var e;const n=this.getElementType(t),r=this.getElementDataById(t),i=this.getData();if(Object.assign(i,{[`${n}s`]:i[`${n}s`].filter((e=>yh(e)!==t))}),"combo"===n&&!Sd(r)){const e=new Set(this.getAncestorsData(t,Ec).map(yh));i.nodes=i.nodes.filter((t=>!e.has(yh(t)))),i.combos=i.combos.filter((t=>!e.has(yh(t)))),i.edges=i.edges.filter((({source:t,target:n})=>!e.has(t)&&!e.has(n)))}return Math.max((null===(e=r.style)||void 0===e?void 0:e.zIndex)||0,0,...Object.values(i).flat().map((t=>{var e;return((null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0)+1})))}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach((t=>{const n=yh(t),r=bh(t);void 0!==r&&(e.hasTreeStructure(Ec)||e.attachTreeStructure(Ec),null===r&&this.refreshComboData(n),this.setParent(n,bh(t),Ec));const i=t.children||[];if(i.length){e.hasTreeStructure(wc)||e.attachTreeStructure(wc);const t=i.filter((t=>e.hasNode(t)));t.forEach((t=>this.setParent(t,n,wc))),t.length!==i.length&&this.updateNodeData([{id:n,children:t}])}}))}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)})),this.computeZIndex(t,"update")}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{const n=[];t.forEach((t=>{const r=yh(t),i=rY(e.getNode(r));if(eY(i,t))return;const o=JH(i,t);this.pushChange({value:o,original:i,type:dc.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)})),this.computeZIndex({nodes:t},"update")}refreshData(){const{nodes:t,edges:e,combos:n}=this.getData();t.forEach((t=>{this.pushChange({value:t,original:t,type:dc.NodeUpdated})})),e.forEach((t=>{this.pushChange({value:t,original:t,type:dc.EdgeUpdated})})),n.forEach((t=>{this.pushChange({value:t,original:t,type:dc.ComboUpdated})}))}syncNodeLikeDatum(t){const{model:e}=this,n=yh(t);if(!e.hasNode(n))return;const r=JH(rY(e.getNode(n)),t);e.mergeNodeData(n,r)}syncEdgeDatum(t){const{model:e}=this,n=yh(t);if(!e.hasEdge(n))return;const r=JH(rY(e.getEdge(n)),t);e.mergeEdgeData(n,r)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{t.forEach((t=>{const n=yh(t),r=rY(e.getEdge(n));if(eY(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=JH(r,t);this.pushChange({value:i,original:r,type:dc.EdgeUpdated}),e.mergeEdgeData(n,i)}))})),this.computeZIndex({edges:t},"update")}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch((()=>{const n=[];t.forEach((t=>{const r=yh(t),i=rY(e.getNode(r));if(eY(i,t))return;const o=JH(i,t);this.pushChange({value:o,original:i,type:dc.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)})),this.computeZIndex({combos:t},"update")}setParent(t,e,n,r=!0){if(t===e)return;const i=bh(this.getNodeLikeDatum(t));if(i!==e&&n===Ec){const n={id:t,combo:e};this.isCombo(t),this.syncNodeLikeDatum(n)}this.model.setParent(t,e,n),r&&n===Ec&&function(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}([i,e]).forEach((t=>{void 0!==t&&this.refreshComboData(t)}))}refreshComboData(t){const e=this.getComboData([t])[0],n=this.getAncestorsData(t,Ec);e&&this.pushChange({value:e,original:e,type:dc.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:dc.ComboUpdated})}))}getElementPosition(t){return Qh(this.getElementDataById(t))}translateNodeLikeBy(t,e){this.isCombo(t)?this.translateComboBy(t,e):this.translateNodeBy(t,e)}translateNodeLikeTo(t,e){this.isCombo(t)?this.translateComboTo(t,e):this.translateNodeTo(t,e)}translateNodeBy(t,e){const n=Ih(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];if(!o)return;const a=new Set;xd(o,(t=>{const e=yh(t);if(a.has(e))return;a.add(e);const[o,s,l]=Qh(t),u=JH(t,{style:{x:o+n,y:s+r,z:l+i}});this.pushChange({value:u,original:t,type:this.isCombo(e)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(e,u)}),(t=>this.getChildrenData(yh(t))),"BT")}translateComboTo(t,e){var n;if(e.some(isNaN))return;const[r=0,i=0,o=0]=e,a=null===(n=this.getComboData([t]))||void 0===n?void 0:n[0];if(!a)return;const[s,l,u]=Qh(a),c=r-s,h=i-l,d=o-u;xd(a,(t=>{const e=yh(t),[n,r,i]=Qh(t),o=JH(t,{style:{x:n+c,y:r+h,z:i+d}});this.pushChange({value:o,original:t,type:this.isCombo(e)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(yh(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(yh)),this.pushChange({value:this.getNodeData([t])[0],type:dc.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:dc.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:dc.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(Ec)){const e=bh(this.getNodeLikeDatum(t));this.setParent(t,void 0,Ec,!1),this.model.getChildren(t,Ec).forEach((t=>{const n=rY(t),r=yh(n);this.setParent(yh(n),e,Ec,!1);const i=JH(n,{id:yh(n),combo:e});this.pushChange({value:i,original:n,type:this.isCombo(r)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(yh(n),i)})),Ut(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(Oc(`Unknown element type of id: ${t}`))}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))),this.context={}}}class oY{constructor(t){this.elementMap={},this.shapeTypeMap={},this.paletteStyle={},this.defaultStyle={},this.stateStyle={},this.visibilityCache=new WeakMap,this.context=t}init(){if(!this.container){const{canvas:t}=this.context;this.container=t.appendChild(new jl({className:"elements"}))}}emit(t,e){e.silence||YH(this.context.graph,t)}forEachElementData(t){bd.forEach((e=>{const n=this.context.model.getElementsDataByType(e);t(e,n)}))}getElementType(t,e){var n;const{options:r,graph:i}=this.context,o=(null===(n=r[t])||void 0===n?void 0:n.type)||e.type;return o?"string"==typeof o?o:o.call(i,e):"edge"===t?"line":"circle"}getTheme(t){return Ac(this.context.options)[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]||{})))}computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData(((e,n)=>{var r,i;const o=Object.assign({},Ld(null===(r=this.getTheme(e))||void 0===r?void 0:r.palette),Ld(null===(i=t[e])||void 0===i?void 0:i.palette));(null==o?void 0:o.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="string"==typeof r?Sc("palette",r):r;if("function"==typeof e){const n={};return t.forEach((([t,r])=>{n[t]=e(o?1-r:r)})),n}if(Array.isArray(e)){const n=o?[...e].reverse():e,r={};return t.forEach((([t,i])=>{r[t]=n[i%e.length]})),r}return{}},s=(t,e)=>{var n;return"string"==typeof t?null===(n=e.data)||void 0===n?void 0:n[t]:null==t?void 0:t(e)};if("group"===n){const e=ie(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[yh(e)]=n[t]}))})),r}if("value"===n){const[e,n]=t.reduce((([t,e],n)=>{const r=s(i,n);if("number"!=typeof r)throw new Error(Oc(`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,o))}))}getPaletteStyle(t,e){const n=this.paletteStyle[e];return n?"edge"===t?{stroke:n}:{fill:n}:{}}computeElementDefaultStyle(t,e){var n;const{options:r}=this.context,i=(null===(n=r[t])||void 0===n?void 0:n.style)||{};"transform"in i&&Array.isArray(i.transform)&&(i.transform=[...i.transform]),this.defaultStyle[yh(e.datum)]=Rd(i,e)}computeElementsDefaultStyle(t){const{graph:e}=this.context;this.forEachElementData(((n,r)=>{const i=r.length;for(let o=0;o<i;o++){const i=r[o];(void 0===t||t.includes(yh(i)))&&this.computeElementDefaultStyle(n,{datum:i,graph:e})}}))}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch(t){return[]}}getElementStateStyle(t,e,n){var r,i;const{options:o}=this.context;return Rd((null===(i=null===(r=o[t])||void 0===r?void 0:r.state)||void 0===i?void 0:i[e])||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[yh(n.datum)]=Object.assign({},...e.map((e=>this.getElementStateStyle(t,e,n))))}computeElementsStatesStyle(t){const{graph:e}=this.context;this.forEachElementData(((n,r)=>{const i=r.length;for(let o=0;o<i;o++){const i=r[o];if(void 0===t||t.includes(yh(i))){const t=this.getElementState(yh(i));this.computeElementStatesStyle(n,t,{datum:i,graph:e})}}}))}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t,e){t&&["translate","zIndex"].includes(t)||(this.computePaletteStyle(),this.computeElementsDefaultStyle(e),this.computeElementsStatesStyle(e))}getElement(t){return this.elementMap[t]}getNodes(){return this.context.model.getNodeData().map((({id:t})=>this.elementMap[t]))}getEdges(){return this.context.model.getEdgeData().map((t=>this.elementMap[yh(t)]))}getCombos(){return this.context.model.getComboData().map((({id:t})=>this.elementMap[t]))}getElementComputedStyle(t,e){const n=yh(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(t,n),o=e.style||{},a=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),l=this.getStateStyle(n),u=Object.assign({},r,i,o,a,s,l);if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!u.collapsed?[]:t.map(yh).filter((t=>this.getElement(t)));Object.assign(u,{childrenNode:e,childrenData:t})}return u}getDrawData(t){this.init();const e=this.computeChangesAndDrawData(t);if(!e)return null;const{type:n="draw",stage:r=n}=t;return this.markDestroyElement(e.drawData),this.computeStyle(r),{type:n,stage:r,data:e}}draw(t={animation:!0}){const e=this.getDrawData(t);if(!e)return;const{data:{drawData:{add:n,update:r,remove:i}}}=e;return this.destroyElements(i,t),this.createElements(n,t),this.updateElements(r,t),this.setAnimationTask(t,e)}preLayoutDraw(){return ze(this,arguments,void 0,(function*(t={animation:!0}){var e,n;const r=this.getDrawData(t);if(!r)return;const{data:{drawData:i}}=r;yield null===(n=null===(e=this.context.layout)||void 0===e?void 0:e.preLayout)||void 0===n?void 0:n.call(e,i);const{add:o,update:a,remove:s}=i;return this.destroyElements(s,t),this.createElements(o,t),this.updateElements(a,t),this.setAnimationTask(t,r)}))}setAnimationTask(e,n){const{animation:r,silence:i}=e,{data:{dataChanges:o,drawData:a},stage:s,type:l}=n;return this.context.animation.animate(r,i?{}:{before:()=>this.emit(new GH(t.GraphEvent.BEFORE_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===l}),e),beforeAnimate:n=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.DRAW,n,a),e),afterAnimate:n=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.DRAW,n,a),e),after:()=>this.emit(new GH(t.GraphEvent.AFTER_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===l,firstRender:!1===this.context.graph.rendered}),e)})}computeChangesAndDrawData(t){const{model:e}=this.context,n=e.getChanges(),r=rF(n);if(0===r.length)return null;const{NodeAdded:i=[],NodeUpdated:o=[],NodeRemoved:a=[],EdgeAdded:s=[],EdgeUpdated:l=[],EdgeRemoved:u=[],ComboAdded:c=[],ComboUpdated:h=[],ComboRemoved:d=[]}=ie(r,(t=>t.type)),f=t=>new Map(t.map((t=>{const e=t.value;return[yh(e),e]}))),p={add:{nodes:f(i),edges:f(s),combos:f(c)},update:{nodes:f(o),edges:f(l),combos:f(h)},remove:{nodes:f(a),edges:f(u),combos:f(d)}},g=this.transformData(p,t);return e.clearChanges(),{dataChanges:n,drawData:g}}transformData(t,e){const n=this.context.transform.getTransformInstance();return Object.values(n).reduce(((t,n)=>n.beforeDraw(t,e)),t)}createElement(e,n,r){var i;const o=yh(n);if(this.getElement(o))return;const a=this.getElementType(e,n),s=this.getElementComputedStyle(e,n),l=Sc(e,a);if(!l)return Tc(`The element ${a} of ${e} is not registered.`);this.emit(new WH(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n),r);const u=this.container.appendChild(new l({id:o,context:this.context,style:s}));this.shapeTypeMap[o]=a,this.elementMap[o]=u;const{stage:c="enter"}=r;null===(i=this.context.animation)||void 0===i||i.add({element:u,elementType:e,stage:c,originalStyle:Object.assign({},u.attributes),updatedStyle:s},{after:()=>{var i;this.emit(new WH(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n),r),null===(i=u.onCreate)||void 0===i||i.call(u)}})}createElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach((([t,n])=>{n.forEach((n=>this.createElement(t,n,e)))}))}getUpdateStageStyle(t,e,n){const{stage:r="update"}=n;if("translate"===r){if("node"===t||"combo"===t){const{style:{x:t=0,y:n=0,z:r=0}={}}=e;return{x:t,y:n,z:r}}return{}}return this.getElementComputedStyle(t,e)}updateElement(e,n,r){var i;const o=yh(n),{stage:a="update"}=r,s=this.getElement(o);if(!s)return()=>null;this.emit(new WH(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n),r);const l=this.getElementType(e,n),u=this.getUpdateStageStyle(e,n,r);this.shapeTypeMap[o]!==l&&(s.destroy(),delete this.shapeTypeMap[o],delete this.elementMap[o],this.createElement(e,n,{animation:!1,silence:!0}));const c="visibility"!==a?a:"hidden"===u.visibility?"hide":"show";"hide"===c&&delete u.visibility,null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:c,originalStyle:Object.assign({},s.attributes),updatedStyle:u},{before:()=>{const t=this.elementMap[o];"collapse"!==a&&Dg(t,u),"visibility"===a&&(function(t,e){return qH(e)in(Oe(t,$H)||{})}(t,"opacity")||function(t,e){const n=Array.isArray(e)?e:[e];Oe(t,$H)||Te(t,$H,{}),n.forEach((e=>{Te(Oe(t,$H),qH(e),t.attributes[e])}))}(t,"opacity"),this.visibilityCache.set(t,"show"===c?"visible":"hidden"),"show"===c&&Ch(t,"visible"))},after:()=>{var i;const s=this.elementMap[o];"collapse"===a&&Dg(s,u),"hide"===c&&Ch(s,this.visibilityCache.get(s)),this.emit(new WH(t.GraphEvent.AFTER_ELEMENT_UPDATE,e,n),r),null===(i=s.onUpdate)||void 0===i||i.call(s)}})}updateElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach((([t,n])=>{n.forEach((n=>this.updateElement(t,n,e)))}))}markDestroyElement(t){Object.values(t.remove).forEach((t=>{t.forEach((t=>{const e=yh(t),n=this.getElement(e);n&&function(t){Te(t,"__to_be_destroyed__",!0)}(n)}))}))}destroyElement(e,n,r){var i;const{stage:o="exit"}=r,a=yh(n),s=this.elementMap[a];if(!s)return()=>null;this.emit(new WH(t.GraphEvent.BEFORE_ELEMENT_DESTROY,e,n),r),null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:o,originalStyle:Object.assign({},s.attributes),updatedStyle:{}},{after:()=>{var i;this.clearElement(a),s.destroy(),null===(i=s.onDestroy)||void 0===i||i.call(s),this.emit(new WH(t.GraphEvent.AFTER_ELEMENT_DESTROY,e,n),r)}})}destroyElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["combo",i],["edge",r],["node",n]].forEach((([t,n])=>{n.forEach((n=>this.destroyElement(t,n,e)))}))}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}alignLayoutResultToElement(t,e){var n,r;const i=null===(n=t.nodes)||void 0===n?void 0:n.find((t=>yh(t)===e));if(i){const n=jh(Qh(this.context.model.getNodeLikeDatum(e)),Qh(i));null===(r=t.nodes)||void 0===r||r.forEach((t=>{var e,r,i;(null===(e=t.style)||void 0===e?void 0:e.x)&&(t.style.x+=n[0]),(null===(r=t.style)||void 0===r?void 0:r.y)&&(t.style.y+=n[1]),(null===(i=t.style)||void 0===i?void 0:i.z)&&(t.style.z+=n[2]||0)}))}}collapseNode(e,n){return ze(this,void 0,void 0,(function*(){var r;const{animation:i,align:o}=n,{model:a,layout:s}=this.context,l=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!l)return;this.markDestroyElement(l.drawData);const u=yield s.simulate();o&&this.alignLayoutResultToElement(u,e),a.updateData(u);const c=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!c)return;const{drawData:h}=c,{add:d,remove:f,update:p}=h;this.markDestroyElement(h);const g={animation:i,stage:"collapse",data:h};this.destroyElements(f,g),this.createElements(d,g),this.updateElements(p,g),yield null===(r=this.context.animation.animate(i,{beforeAnimate:e=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.COLLAPSE,e,h),g),afterAnimate:e=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.COLLAPSE,e,h),g)},{collapse:{target:e,descendants:Array.from(f.nodes).map((([,t])=>yh(t))),position:Qh(p.nodes.get(e))}}))||void 0===r?void 0:r.finished}))}expandNode(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i,layout:o}=this.context,{animation:a,align:s}=n,l=Qh(i.getNodeData([e])[0]),u=this.computeChangesAndDrawData({stage:"expand",animation:a});if(!u)return;const{drawData:{add:c}}=u;this.createElements(c,{animation:!1,stage:"expand",target:e}),this.context.animation.clear();const h=yield o.simulate();s&&this.alignLayoutResultToElement(h,e),i.updateData(h),this.computeStyle("expand");const d=this.computeChangesAndDrawData({stage:"collapse",animation:a});if(!d)return;const{drawData:f}=d,{update:p}=f,g={animation:a,stage:"expand",data:f};c.edges.forEach((t=>p.edges.set(yh(t),t))),c.nodes.forEach((t=>p.nodes.set(yh(t),t))),this.updateElements(p,g),yield null===(r=this.context.animation.animate(a,{beforeAnimate:e=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.EXPAND,e,f),g),afterAnimate:e=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.EXPAND,e,f),g)},{expand:{target:e,descendants:Array.from(c.nodes).map((([,t])=>yh(t))),position:l}}))||void 0===r?void 0:r.finished}))}collapseCombo(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i,element:o}=this.context;if(i.getAncestorsData(e,Ec).some((t=>Sd(t))))return;const a=o.getElement(e),s=a.getComboPosition(Object.assign(Object.assign({},a.attributes),{collapsed:!0})),l=this.computeChangesAndDrawData({stage:"collapse",animation:n});if(!l)return;const{dataChanges:u,drawData:c}=l;this.markDestroyElement(c);const{update:h,remove:d}=c,f={animation:n,stage:"collapse",data:c};this.destroyElements(d,f),this.updateElements(h,f);const p=t=>Array.from(t).map((([,t])=>yh(t)));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new GH(t.GraphEvent.BEFORE_DRAW,{dataChanges:u,animation:n}),f),beforeAnimate:e=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.COLLAPSE,e,c),f),afterAnimate:e=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.COLLAPSE,e,c),f),after:()=>this.emit(new GH(t.GraphEvent.AFTER_DRAW,{dataChanges:u,animation:n}),f)},{collapse:{target:e,descendants:[...p(d.nodes),...p(d.combos)],position:s}}))||void 0===r?void 0:r.finished}))}expandCombo(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i}=this.context,o=Qh(i.getComboData([e])[0]);this.computeStyle("expand");const a=this.computeChangesAndDrawData({stage:"expand",animation:n});if(!a)return;const{dataChanges:s,drawData:l}=a,{add:u,update:c}=l,h={animation:n,stage:"expand",data:l,target:e};this.createElements(u,h),this.updateElements(c,h);const d=t=>Array.from(t).map((([,t])=>yh(t)));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new GH(t.GraphEvent.BEFORE_DRAW,{dataChanges:s,animation:n}),h),beforeAnimate:e=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.EXPAND,e,l),h),afterAnimate:e=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.EXPAND,e,l),h),after:()=>this.emit(new GH(t.GraphEvent.AFTER_DRAW,{dataChanges:s,animation:n}),h)},{expand:{target:e,descendants:[...d(u.nodes),...d(u.combos)],position:o}}))||void 0===r?void 0:r.finished}))}destroy(){this.container.destroy(),this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={},this.context={}}}class aY{get presetOptions(){return{animation:!!Dc(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.instances=[],this.context=t}getLayoutInstance(){return this.instances}preLayout(e){return ze(this,void 0,void 0,(function*(){var n,r,i,o;const{graph:a,model:s}=this.context,{add:l}=e;YH(a,new GH(t.GraphEvent.BEFORE_LAYOUT,{type:"pre"}));const u=yield null===(n=this.context.layout)||void 0===n?void 0:n.simulate();null===(r=null==u?void 0:u.nodes)||void 0===r||r.forEach((t=>{const e=yh(t),n=l.nodes.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)})),null===(i=null==u?void 0:u.edges)||void 0===i||i.forEach((t=>{const e=yh(t),n=l.edges.get(e);s.syncEdgeDatum(t),n&&Object.assign(n.style,t.style)})),null===(o=null==u?void 0:u.combos)||void 0===o||o.forEach((t=>{const e=yh(t),n=l.combos.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)})),YH(a,new GH(t.GraphEvent.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",e)}))}postLayout(){return ze(this,void 0,void 0,(function*(){if(!this.options)return;const e=Array.isArray(this.options)?this.options:[this.options],{graph:n}=this.context;YH(n,new GH(t.GraphEvent.BEFORE_LAYOUT,{type:"post"}));for(const r of e){const i=e.indexOf(r),o=this.getLayoutData(r),a=Object.assign(Object.assign({},this.presetOptions),r);YH(n,new GH(t.GraphEvent.BEFORE_STAGE_LAYOUT,{options:a,index:i}));const s=yield this.stepLayout(o,a,i);YH(n,new GH(t.GraphEvent.AFTER_STAGE_LAYOUT,{options:a,index:i})),r.animation||this.updateElementPosition(s,!1)}YH(n,new GH(t.GraphEvent.AFTER_LAYOUT,{type:"post"})),this.transformDataAfterLayout("post")}))}transformDataAfterLayout(t,e){const n=this.context.transform.getTransformInstance();Object.values(n).forEach((n=>n.afterLayout(t,e)))}simulate(){return ze(this,void 0,void 0,(function*(){if(!this.options)return{};const t=Array.isArray(this.options)?this.options:[this.options];let e={};for(const n of t){const r=t.indexOf(n),i=this.getLayoutData(n);e=yield this.stepLayout(i,Object.assign(Object.assign(Object.assign({},this.presetOptions),n),{animation:!1}),r)}return e}))}stepLayout(t,e,n){return ze(this,void 0,void 0,(function*(){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?yield this.treeLayout(t,e,n):yield this.graphLayout(t,e,n)}))}graphLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{animation:r,enableWorker:i,iterations:o=300}=e,a=this.initGraphLayout(e);if(!a)return{};if(this.instances[n]=a,this.instance=a,i){const e=a;return this.supervisor=new $j(e.graphData2LayoutModel(t),e.instance,{iterations:o}),$g(yield this.supervisor.execute())}if(Kx(a))return r?yield a.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(a.execute(t),a.stop(),a.tick(o));const s=yield a.execute(t);if(r){const t=this.updateElementPosition(s,r);yield null==t?void 0:t.finished}return s}))}treeLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{type:n,animation:r}=e,i=Sc("layout",n);if(!i)return{};const{nodes:o=[],edges:a=[]}=t,s=new Yg({nodes:o.map((t=>({id:yh(t),data:t.data||{}}))),edges:a.map((t=>({id:yh(t),source:t.source,target:t.target,data:t.data||{}})))});!function(t){if(t.hasTreeStructure(wc))return;t.attachTreeStructure(wc);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,wc)}}(s);const l={nodes:[],edges:[]},u={nodes:[],edges:[]};s.getRoots(wc).forEach((t=>{xd(t,(t=>{t.children=s.getSuccessors(t.id)}),(t=>s.getSuccessors(t.id)),"TB");const n=i(t,e),{x:r,y:o,z:a=0}=n;xd(n,(t=>{const{id:e,x:n,y:i,z:s=0}=t;l.nodes.push({id:e,style:{x:r,y:o,z:a}}),u.nodes.push({id:e,style:{x:n,y:i,z:s}})}),(t=>t.children),"TB")}));const c=this.inferTreeLayoutOffset(u);if(sY(u,c),r){sY(l,c),this.updateElementPosition(l,!1);const t=this.updateElementPosition(u,r);yield null==t?void 0:t.finished}return u}))}inferTreeLayoutOffset(t){var e;let[n,r]=[1/0,-1/0],[i,o]=[1/0,-1/0];null===(e=t.nodes)||void 0===e||e.forEach((t=>{const{x:e=0,y:a=0}=t.style||{};n=Math.min(n,e),r=Math.max(r,e),i=Math.min(i,a),o=Math.max(o,a)}));const{canvas:a}=this.context,s=a.getSize(),[l,u]=a.getCanvasByViewport([0,0]),[c,h]=a.getCanvasByViewport(s);if(n>=l&&r<=c&&i>=u&&o<=h)return[0,0];return[(l+c)/2-(n+r)/2,(u+h)/2-(i+o)/2]}stopLayout(){this.instance&&Kx(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)}getLayoutData(t){const{nodeFilter:e=()=>!0,preLayout:n=!1,isLayoutInvisibleNodes:r=!1}=t,{nodes:i,edges:o,combos:a}=this.context.model.getData(),{element:s,model:l}=this.context,u=t=>s.getElement(t),c=n?t=>{var n;if(!r){if("hidden"===(null===(n=t.style)||void 0===n?void 0:n.visibility))return!1;if(l.getAncestorsData(t.id,wc).some(Sd))return!1;if(l.getAncestorsData(t.id,Ec).some(Sd))return!1}return e(t)}:t=>{const n=yh(t),r=u(n);return!!r&&(!Lg(r)&&e(t))},h=i.filter(c),d=new Map(h.map((t=>[yh(t),t])));return{nodes:h,edges:o.filter((t=>{const{source:e,target:n}=t;return!(!d.has(e)||!d.has(n))})),combos:a}}initGraphLayout(t){var e;const{element:n,viewport:r}=this.context,{type:i,enableWorker:o,animation:a,iterations:s}=t,l=Fe(t,["type","enableWorker","animation","iterations"]),[u,c]=r.getCanvasSize(),h=[u/2,c/2],d=null!==(e=null==t?void 0:t.nodeSize)&&void 0!==e?e:t=>{const e=null==n?void 0:n.getElement(t.id);return e?e.attributes.size:null==n?void 0:n.getElementComputedStyle("node",t).size},f=Sc("layout",i);if(!f)return Tc(`The layout of ${i} is not registered.`);const p=Object.getPrototypeOf(f.prototype)===Ug.prototype?f:function(t,e){return class extends Ug{constructor(e,n){if(super(e,n),this.instance=new t({}),this.id=this.instance.id,"stop"in this.instance&&"tick"in this.instance){const t=this.instance;this.stop=t.stop.bind(t),this.tick=e=>$g(t.tick(e))}}execute(t,e){return ze(this,void 0,void 0,(function*(){return $g(yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(ke({},this.options,e))))}))}transformOptions(t){const{onTick:e}=t;return e?(t.onTick=t=>e($g(t)),t):t}graphData2LayoutModel(t){const{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.map((t=>{const e=yh(t),{data:n,style:r,combo:i}=t,o=Fe(t,["data","style","combo"]),a={id:e,data:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n),{data:n}),i?{parentId:i}:{}),{style:r}),o)};return(null==r?void 0:r.x)&&Object.assign(a.data,{x:r.x}),(null==r?void 0:r.y)&&Object.assign(a.data,{y:r.y}),(null==r?void 0:r.z)&&Object.assign(a.data,{z:r.z}),a})),a=new Map(o.map((t=>[t.id,t]))),s=r.filter((t=>{const{source:e,target:n}=t;return a.has(e)&&a.has(n)})).map((t=>{const{source:e,target:n,data:r,style:i}=t;return{id:yh(t),source:e,target:n,data:Object.assign({},r),style:Object.assign({},i)}})),l=i.map((t=>({id:yh(t),data:Object.assign({_isCombo:!0},t.data),style:Object.assign({},t.style)}))),u=new Yg({nodes:[...o,...l],edges:s});return e.model.model.hasTreeStructure(Ec)&&(u.attachTreeStructure(Ec),o.forEach((t=>{const n=e.model.model.getParent(t.id,Ec);n&&u.hasNode(n.id)&&u.setParent(t.id,n.id,Ec)}))),u}}}(f,this.context),g=new p(this.context),v={nodeSize:d,width:u,height:c,center:h};switch(g.id){case"d3-force":case"d3-force-3d":Object.assign(v,{center:{x:u/2,y:c/2,z:0}})}return ke(g.options,v,l),g}updateElementPosition(t,e){const{model:n,element:r}=this.context;return r?(n.updateData(t),r.draw({animation:e,silence:!0})):null}destroy(){var t;this.stopLayout(),this.context={},null===(t=this.supervisor)||void 0===t||t.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}const sY=(t,e)=>{var n;const[r,i]=e;null===(n=t.nodes)||void 0===n||n.forEach((t=>{if(t.style){const{x:e=0,y:n=0}=t.style;t.style.x=e+r,t.style.y=n+i}else t.style={x:r,y:i}}))};function lY(t){return t.layout?(Array.isArray(t.layout)||"preLayout"in t.layout||["antv-dagre","combo-combined","compact-box","circular","concentric","dagre","fishbone","grid","indented","mds","radial","random","snake","dendrogram","mindmap"].includes(t.layout.type)&&(t.layout.preLayout=!0),t):t}class uY extends Ph{constructor(t){super(t),this.category="plugin",this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){const e=this.extensionMap[t];if(e)return e;Tc(`Cannot find the plugin ${t}, will try to find it by type.`);const n=this.extensions.find((e=>e.type===t));return n?this.extensionMap[n.key]:void 0}}const cY=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class hY extends Ph{constructor(t){super(t),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(t){this.setExtensions([...cY.slice(0,cY.length-1),...t,cY[cY.length-1]])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}class dY{get padding(){return Yc(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.landmarkCounter=0,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(){const{canvas:t}=this.context;return new Proxy(t.getCamera(),{get:(e,n)=>{const r=Object.entries(t.getLayers()).filter((([t])=>!["main"].includes(t))),i=r.map((([,t])=>t.getCamera())),o=e[n];if("function"==typeof o)return(...t)=>{const r=o.apply(e,t);return i.forEach((e=>{e[n].apply(e,t)})),r}}})}createLandmark(t){return this.camera.createLandmark("landmark-"+this.landmarkCounter++,t)}getAnimation(t){const e=Dc(this.context.options,t);return!!e&&Ce(Object.assign({},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()}getTranslateOptions(t){const{camera:e}=this,{mode:n,translate:r=[]}=t,i=this.getZoom(),o=e.getPosition(),a=e.getFocalPoint(),[s,l]=this.getCanvasCenter(),[u=0,c=0,h=0]=r,d=Fh([-u,-c,-h],i);return"relative"===n?{position:Ih(o,d),focalPoint:Ih(a,d)}:{position:Ih([s,l,o[2]],d),focalPoint:Ih([s,l,a[2]],d)}}getRotateOptions(t){const{mode:e,rotate:n=0}=t;return{roll:"relative"===e?this.camera.getRoll()+n:n}}getZoomOptions(t){const{zoomRange:e}=this.context.options,n=this.camera.getZoom(),{mode:r,scale:i=1}=t;return oe("relative"===r?n*i:i,...e)}transform(e,n){return ze(this,void 0,void 0,(function*(){const{graph:r}=this.context,{translate:i,rotate:o,scale:a,origin:s}=e;this.cancelAnimation();const l=this.getAnimation(n);if(YH(r,new HH(t.GraphEvent.BEFORE_TRANSFORM,e)),!o&&a&&!i&&s&&!l)return this.camera.setZoomByViewportPoint(this.getZoomOptions(e),s),void YH(r,new HH(t.GraphEvent.AFTER_TRANSFORM,e));const u={};if(i&&Object.assign(u,this.getTranslateOptions(e)),ae(o)&&Object.assign(u,this.getRotateOptions(e)),ae(a)&&Object.assign(u,{zoom:this.getZoomOptions(e)}),l)return YH(r,new VH(t.GraphEvent.BEFORE_ANIMATE,fc.TRANSFORM,null,e)),new Promise((n=>{this.transformResolver=n,this.camera.gotoLandmark(this.createLandmark(u),Object.assign(Object.assign({},l),{onfinish:()=>{YH(r,new VH(t.GraphEvent.AFTER_ANIMATE,fc.TRANSFORM,null,e)),YH(r,new HH(t.GraphEvent.AFTER_TRANSFORM,e)),this.transformResolver=void 0,n()}}))}));this.camera.gotoLandmark(this.createLandmark(u),{duration:0}),YH(r,new HH(t.GraphEvent.AFTER_TRANSFORM,e))}))}fitView(t,e){return ze(this,void 0,void 0,(function*(){const[n,r,i,o]=this.padding,{when:a="always",direction:s="both"}=t||{},[l,u]=this.context.canvas.getSize(),c=l-o-r,h=u-n-i,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[p,g]=Xc(f);if("overflow"===a&&!("x"===s&&p>=c||"y"===s&&g>=h||"both"===s&&p>=c&&g>=h))return yield this.fitCenter({animation:e});const v=c/p,m=h/g,y="x"===s?v:"y"===s?m:Math.min(v,m),b=this.getAnimation(e);yield this.transform({mode:"relative",scale:y,translate:Ih(jh(this.getCanvasCenter(),this.getBBoxInViewport(d).center),Fh(this.paddingOffset,y))},b)}))}fitCenter(t){return ze(this,void 0,void 0,(function*(){const e=this.context.canvas.getBounds();yield this.focus(e,t)}))}focusElements(t){return ze(this,arguments,void 0,(function*(t,e={}){const{element:n}=this.context;if(!n)return;const r=Jc(t.map((t=>{return r=n.getElement(t),e.shapes?r.getShape(e.shapes).getRenderBounds():r.getRenderBounds();var r})));yield this.focus(r,e)}))}focus(t,e){return ze(this,void 0,void 0,(function*(){const n=this.context.graph.getViewportByCanvas(t.center),r=jh(e.position||this.getCanvasCenter(),n);yield this.transform({mode:"relative",translate:Ih(r,this.paddingOffset)},e.animation)}))}getBBoxInViewport(t){const{min:e,max:n}=t,{graph:r}=this.context,[i,o]=r.getViewportByCanvas(e),[a,s]=r.getViewportByCanvas(n),l=new Ur;return l.setMinMax([i,o,0],[a,s,0]),l}isInViewport(t,e=!1,n=0){const{graph:r}=this.context,i=this.getCanvasSize(),[o,a]=r.getCanvasByViewport([0,0]),[s,l]=r.getCanvasByViewport(i);let u=new Ur;return u.setMinMax([o,a,0],[s,l,0]),n&&(u=Qc(u,n)),Wc(t)?th(t,u):e?function(t,e){const[n,r]=t.min,[i,o]=t.max,[a,s]=e.min,[l,u]=e.max;return n>=a&&i<=l&&r>=s&&o<=u}(t,u):u.intersects(t)}cancelAnimation(){var t,e;(null===(t=this.camera.landmarks)||void 0===t?void 0:t.length)&&this.camera.cancelLandmarkAnimation(),null===(e=this.transformResolver)||void 0===e||e.call(this)}}class fY extends zg{constructor(t){var e;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new iY},this.isCollapsingExpanding=!1,this.onResize=ye((()=>{this.resize()}),300),this._setOptions(Object.assign({},fY.defaultOptions,t),!0),this.context.graph=this,this.options.autoResize&&(null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize))}getOptions(){return this.options}setOptions(t){this._setOptions(t,!1)}_setOptions(t,e){if(this.updateCanvas(t),Object.assign(this.options,function(t){return[lY].reduce(((t,e)=>e(t)),t)}(t)),e){const{data:e}=t;return void(e&&this.addData(e))}const{behaviors:n,combo:r,data:i,edge:o,layout:a,node:s,plugins:l,theme:u,transforms:c}=t;n&&this.setBehaviors(n),i&&this.setData(i),s&&this.setNode(s),o&&this.setEdge(o),r&&this.setCombo(r),a&&this.setLayout(a),u&&this.setTheme(u),l&&this.setPlugins(l),c&&this.setTransforms(c)}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){t&&(this.options.width=t),e&&(this.options.height=e),this.resize(t,e)}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t,this.context.model.refreshData()}setEdge(t){this.options.edge=t,this.context.model.refreshData()}setCombo(t){this.options.combo=t,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(t){this.options.theme=Yt(t)?t(this.getTheme()):t}setLayout(t){this.options.layout=Yt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){var e;this.options.behaviors=Yt(t)?t(this.getBehaviors()):t,null===(e=this.context.behavior)||void 0===e||e.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors((e=>e.map((e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){var e;this.options.plugins=Yt(t)?t(this.getPlugins()):t,null===(e=this.context.plugin)||void 0===e||e.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins((e=>e.map((e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))))}getPlugins(){return this.options.plugins||[]}getPluginInstance(t){return this.context.plugin.getPluginInstance(t)}setTransforms(t){var e;this.options.transforms=Yt(t)?t(this.getTransforms()):t,null===(e=this.context.transform)||void 0===e||e.setTransforms(this.options.transforms)}updateTransform(t){this.setTransforms((e=>e.map((e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e)))),this.context.model.refreshData()}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}getElementData(t){return Array.isArray(t)?t.map((t=>this.context.model.getElementDataById(t))):this.context.model.getElementDataById(t)}getNodeData(t){var e;return void 0===t?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):null===(e=this.context.model.getNodeData([t]))||void 0===e?void 0:e[0]}getEdgeData(t){var e;return void 0===t?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):null===(e=this.context.model.getEdgeData([t]))||void 0===e?void 0:e[0]}getComboData(t){var e;return void 0===t?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):null===(e=this.context.model.getComboData([t]))||void 0===e?void 0:e[0]}setData(t){this.context.model.setData(Yt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Yt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Yt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Yt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Yt(t)?t(this.getComboData()):t)}addChildrenData(t,e){this.context.model.addChildrenData(t,e)}updateData(t){this.context.model.updateData(Yt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Yt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Yt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Yt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Yt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Yt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Yt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Yt(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)}getDescendantsData(t){return this.context.model.getDescendantsData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}initCanvas(){return ze(this,void 0,void 0,(function*(){var e;if(this.context.canvas)return yield this.context.canvas.ready;const{container:n="container",width:r,height:i,renderer:o,cursor:a,background:s,canvas:l,devicePixelRatio:u=(null!==(e=globalThis.devicePixelRatio)&&void 0!==e?e:1)}=this.options;if(n instanceof _H)this.context.canvas=n,a&&n.setCursor(a),o&&n.setRenderer(o),yield n.ready;else{const e=ne(n)?document.getElementById(n):n,c=FH(e);this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:e,width:r,height:i});const h=Object.assign(Object.assign({},l),{container:e,width:r||c[0],height:i||c[1],background:s,renderer:o,cursor:a,devicePixelRatio:u}),d=new _H(h);this.context.canvas=d,yield d.ready,this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:d})}}))}updateCanvas(e){var n,r;const{renderer:i,cursor:o,height:a,width:s}=e,l=this.context.canvas;l&&(i&&(this.emit(t.GraphEvent.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),l.setRenderer(i),this.emit(t.GraphEvent.AFTER_RENDERER_CHANGE,{renderer:i})),o&&l.setCursor(o),(ae(s)||ae(a))&&this.setSize(null!==(n=null!=s?s:this.options.width)&&void 0!==n?n:0,null!==(r=null!=a?a:this.options.height)&&void 0!==r?r:0))}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new ZH(this.context)),this.context.plugin||(this.context.plugin=new uY(this.context)),this.context.viewport||(this.context.viewport=new dY(this.context)),this.context.transform||(this.context.transform=new hY(this.context)),this.context.element||(this.context.element=new oY(this.context)),this.context.animation||(this.context.animation=new KH(this.context)),this.context.layout||(this.context.layout=new aY(this.context)),this.context.behavior||(this.context.behavior=new QH(this.context))}prepare(){return ze(this,void 0,void 0,(function*(){if(yield Promise.resolve(),this.destroyed)throw new Error(Oc("The graph instance has been destroyed"));yield this.initCanvas(),this.initRuntime()}))}render(){return ze(this,void 0,void 0,(function*(){if(yield this.prepare(),YH(this,new GH(t.GraphEvent.BEFORE_RENDER)),this.options.layout)if(this.rendered||(e=this.options.layout,Array.isArray(e)||!(null==e?void 0:e.preLayout))){const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.context.layout.postLayout()]),yield this.autoFit()}else{const t=yield this.context.element.preLayoutDraw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}else{const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}var e;this.rendered=!0,YH(this,new GH(t.GraphEvent.AFTER_RENDER))}))}draw(){return ze(this,void 0,void 0,(function*(){var t;yield this.prepare(),yield null===(t=this.context.element.draw())||void 0===t?void 0:t.finished}))}layout(){return ze(this,void 0,void 0,(function*(){yield this.context.layout.postLayout()}))}stopLayout(){this.context.layout.stopLayout()}clear(){return ze(this,void 0,void 0,(function*(){this.context.model.setData({}),yield this.draw()}))}destroy(){var e;YH(this,new GH(t.GraphEvent.BEFORE_DESTROY));const{layout:n,animation:r,element:i,model:o,canvas:a,behavior:s,plugin:l}=this.context;null==l||l.destroy(),null==s||s.destroy(),null==n||n.destroy(),null==r||r.destroy(),null==i||i.destroy(),o.destroy(),null==a||a.destroy(),this.options={},this.context={},this.off(),null===(e=globalThis.removeEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize),this.destroyed=!0,YH(this,new GH(t.GraphEvent.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,n){var r;const i=FH(null===(r=this.context.canvas)||void 0===r?void 0:r.getContainer()),o=[e||i[0],n||i[1]];if(!this.context.canvas)return;const a=this.context.canvas.getSize();Ne(o,a)||(YH(this,new GH(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:o})),this.context.canvas.resize(...o),YH(this,new GH(t.GraphEvent.AFTER_SIZE_CHANGE,{size:o})))}fitView(t,e){return ze(this,void 0,void 0,(function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.fitView(t,e)}))}fitCenter(t){return ze(this,void 0,void 0,(function*(){var e;yield null===(e=this.context.viewport)||void 0===e?void 0:e.fitCenter({animation:t})}))}autoFit(){return ze(this,void 0,void 0,(function*(){const{autoFit:t}=this.context.options;if(t)if(ne(t))"view"===t?yield this.fitView():"center"===t&&(yield this.fitCenter());else{const{type:e,animation:n}=t;"view"===e?yield this.fitView(t.options,n):"center"===e&&(yield this.fitCenter(n))}}))}focusElement(t,e){return ze(this,void 0,void 0,(function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.focusElements(Array.isArray(t)?t:[t],{animation:e})}))}zoomBy(t,e,n){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)}))}zoomTo(t,e,n){return ze(this,void 0,void 0,(function*(){this.context.viewport.transform({mode:"absolute",scale:t,origin:n},e)}))}getZoom(){return this.context.viewport.getZoom()}rotateBy(t,e,n){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)}))}rotateTo(t,e,n){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"absolute",rotate:t,origin:n},e)}))}getRotation(){return this.context.viewport.getRotation()}translateBy(t,e){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",translate:t},e)}))}translateTo(t,e){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"absolute",translate:t},e)}))}getPosition(){return jh([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach((([t,e])=>this.context.model.translateNodeLikeBy(t,e))),yield null===(i=this.context.element.draw({animation:a,stage:"translate"}))||void 0===i?void 0:i.finished}))}translateElementTo(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach((([t,e])=>this.context.model.translateNodeLikeTo(t,e))),yield null===(i=this.context.element.draw({animation:a,stage:"translate"}))||void 0===i?void 0:i.finished}))}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return Pe(this.context.element.getElement(t).attributes,["context"])}setElementVisibility(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach((([t,e])=>{const n=this.getElementType(t);s[`${n}s`].push({id:t,style:{visibility:e}})}));const{model:l,element:u}=this.context;l.preventUpdateNodeLikeHierarchy((()=>{l.updateData(s)})),yield null===(i=u.draw({animation:a,stage:"visibility"}))||void 0===i?void 0:i.finished}))}showElement(t,e){return ze(this,void 0,void 0,(function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"visible"]))),e)}))}hideElement(t,e){return ze(this,void 0,void 0,(function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"hidden"]))),e)}))}getElementVisibility(t){var e,n;const r=this.context.element.getElement(t);return null!==(n=null===(e=null==r?void 0:r.style)||void 0===e?void 0:e.visibility)&&void 0!==n?n:"visible"}setElementZIndex(t,e){return ze(this,void 0,void 0,(function*(){var n;const r={nodes:[],edges:[],combos:[]},i=qt(t)?t:{[t]:e};Object.entries(i).forEach((([t,e])=>{const n=this.getElementType(t);r[`${n}s`].push({id:t,style:{zIndex:e}})}));const{model:o,element:a}=this.context;o.preventUpdateNodeLikeHierarchy((()=>o.updateData(r))),yield null===(n=a.draw({animation:!1,stage:"zIndex"}))||void 0===n?void 0:n.finished}))}frontElement(t){return ze(this,void 0,void 0,(function*(){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,Ec).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(yh(i))],a=e-UH(i);o.forEach((t=>{r[yh(t)]=this.getElementZIndex(yh(t))+a}));const{internal:s}=Qp(o.map(yh),(t=>n.getRelatedEdgesData(t)));s.forEach((t=>{const e=yh(t);r[e]=this.getElementZIndex(e)+a}))}else r[t]=e})),yield this.setElementZIndex(r)}))}getElementZIndex(t){return UH(this.context.model.getElementDataById(t))}setElementState(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach((([t,e])=>{const n=this.getElementType(t);var r;s[`${n}s`].push({id:t,states:(r=e,r?Array.isArray(r)?r:[r]:[])})})),this.updateData(s),yield null===(i=this.context.element.draw({animation:a,stage:"state"}))||void 0===i?void 0:i.finished}))}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}collapseElement(t){return ze(this,arguments,void 0,(function*(t,e=!0){const{model:n,element:r}=this.context;if(Sd(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!0});const i=n.getElementType(t);yield this.frontElement(t),this.isCollapsingExpanding=!0,this.setElementCollapsibility(t,!0),"node"===i?yield r.collapseNode(t,e):"combo"===i&&(yield r.collapseCombo(t,!!e.animation)),this.isCollapsingExpanding=!1}))}expandElement(t){return ze(this,arguments,void 0,(function*(t,e=!0){const{model:n,element:r}=this.context;if(!Sd(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!0});const i=n.getElementType(t);this.isCollapsingExpanding=!0,this.setElementCollapsibility(t,!1),"node"===i?yield r.expandNode(t,e):"combo"===i&&(yield r.expandCombo(t,!!e.animation)),this.isCollapsingExpanding=!1}))}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}}])}toDataURL(){return ze(this,arguments,void 0,(function*(t={}){return this.context.canvas.toDataURL(t)}))}getCanvasByViewport(t){return this.context.canvas.getCanvasByViewport(t)}getViewportByCanvas(t){return this.context.canvas.getViewportByCanvas(t)}getClientByCanvas(t){return this.context.canvas.getClientByCanvas(t)}getCanvasByClient(t){return this.context.canvas.getCanvasByClient(t)}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}on(t,e,n){return super.on(t,e,n)}once(t,e){return super.once(t,e)}off(t,e){return super.off(t,e)}}fY.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};const pY=(t,e)=>{const{source:n,target:r}=e,i=t.getElementDataById(n),o=t.getElementDataById(r),a=Jp(i,(e=>t.getParentData(e,Ec))),s=Jp(o,(e=>t.getParentData(e,Ec))),l={sourceNode:yh(a),targetNode:yh(s)};return e.style?Object.assign(e.style,l):e.style=l,e};class gY extends MH{constructor(t,e){super(t,ke({},gY.defaultOptions,e)),this.assignSizeByCentrality=(t,e,n,r,i,o)=>{const a=[e,n],s=[r[0],i[0]],l=[r[1],i[1]],u=[r[2],i[2]],c=(t,e)=>{if("function"==typeof o)return o(t,a,e);switch(o){case"linear":return((t,e,n)=>{const[r,i]=e,[o,a]=n;return i===r?o:o+(t-r)/(i-r)*(a-o)})(t,a,e);case"log":return((t,e,n)=>{const[r,i]=e,[o,a]=n;return o+Math.log(t-r+1)/Math.log(i-r+1)*(a-o)})(t,a,e);case"pow":return((t,e,n,r=2)=>{const[i,o]=e,[a,s]=n;return a+Math.pow((t-i)/(o-i),r)*(s-a)})(t,a,e,2);case"sqrt":return((t,e,n)=>{const[r,i]=e,[o,a]=n;return o+Math.sqrt((t-r)/(i-r))*(a-o)})(t,a,e);default:return e[0]}};return[c(t,s),c(t,l),c(t,u)]}}beforeDraw(t){const{model:e}=this.context,n=e.getNodeData(),r=Pd(this.options.maxSize),i=Pd(this.options.minSize),o=this.getCentralities(this.options.centrality),a=o.size>0?Math.max(...o.values()):0,s=o.size>0?Math.min(...o.values()):0;return n.forEach((e=>{var n;const l=this.assignSizeByCentrality(o.get(yh(e))||0,s,a,i,r,this.options.scale),u=null===(n=this.context.element)||void 0===n?void 0:n.getElement(yh(e)),c={size:l};this.assignLabelStyle(c,l,e,u),u&&NH(c,u.attributes)||SH(t,u?"update":"add","node",ke(e,{style:c}),!0)})),t}assignLabelStyle(t,e,n,r){var i;const o=r?r.config.style:null===(i=this.context.element)||void 0===i?void 0:i.getElementComputedStyle("node",n);if(Object.assign(t,Ce(o,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const n=this.getLabelSizeByNodeSize(e,1/0,Number(t.labelFontSize));Object.assign(t,{labelFontSize:n,labelLineHeight:n+Uc(t.labelPadding)})}return t}getLabelSizeByNodeSize(t,e,n){const r=Math.min(...t)/2,[i,o]=Array.isArray(this.options.mapLabelSize)?this.options.mapLabelSize:[n,e];return Math.min(o,Math.max(r,i))}getCentralities(t){const{model:e}=this.context,n=e.getData();if("function"==typeof t)return t(n);const r=e.getRelatedEdgesData.bind(e);return Eh(n,r,t)}}gY.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};class vY extends MH{constructor(t,e){super(t,Object.assign({},vY.defaultOptions,e))}get ref(){return this.context.model.getRootsData()[0]}afterLayout(){var t;const e=Qh(this.ref),{graph:n,model:r}=this.context;null===(t=r.getData().nodes)||void 0===t||t.forEach((t=>{var i;if(yh(t)===yh(this.ref))return;const o=qh(jh(Qh(t),e)),a=Math.abs(o)>Math.PI/2,s=!t.children||0===t.children.length,l=yh(t),u=null===(i=this.context.element)||void 0===i?void 0:i.getElement(l);if(!u||!u.isVisible())return;const c=(s?1:-1)*(Pd(n.getElementRenderStyle(l).size)[0]/2+this.options.offset),h=[["translate",c*Math.cos(o),c*Math.sin(o)],["rotate",a?ai(o)+180:ai(o)]];r.updateNodeData([{id:yh(t),style:{labelTextAlign:a===s?"right":"left",labelTextBaseline:"middle",labelTransform:h}}])})),n.draw()}}vY.defaultOptions={offset:5};const mY=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class yY extends MH{constructor(t,e){super(t,Object.assign({},yY.defaultOptions,e)),this.cacheMergeStyle=new Map,this.getAffectedParallelEdges=t=>{const{add:{edges:e},update:{nodes:n,edges:r,combos:i},remove:{edges:o}}=t,{model:a}=this.context,s=new Map,l=(t,e)=>{a.getRelatedEdgesData(e).forEach((t=>!s.has(yh(t))&&s.set(yh(t),t)))};n.forEach(l),i.forEach(l);const u=t=>{const e=a.getEdgeData().map((t=>pY(a,t)));xY(t,e).forEach((t=>!s.has(yh(t))&&s.set(yh(t),t)))};if(o.size&&o.forEach(u),e.size&&e.forEach(u),r.size){const t=iF(rF(a.getChanges())).update.edges;r.forEach((e=>{var n;u(e);const r=null===(n=t.find((t=>yh(t.value)===yh(e))))||void 0===n?void 0:n.original;r&&!EY(e,r)&&u(r)}))}Se(this.options.edges)||s.forEach(((t,e)=>!this.options.edges.includes(e)&&s.delete(e)));const c=a.getEdgeData().map(yh);return new Map([...s].sort(((t,e)=>c.indexOf(t[0])-c.indexOf(e[0]))))},this.applyBundlingStyle=(t,e,n)=>{const{edgeMap:r,reverses:i}=bY(e);r.forEach((e=>{e.forEach(((e,r,o)=>{var a;const s=o.length,l=e.style||{};if(e.source===e.target){const t=mY.length;l.loopPlacement=mY[r%t],l.loopDist=Math.floor(r/t)*n+50}else if(1===s)l.curveOffset=0;else{const t=(r%2==0?1:-1)*(i[`${e.source}|${e.target}|${r}`]?-1:1);l.curveOffset=s%2==1?t*Math.ceil(r/2)*n*2:t*(Math.floor(r/2)*n*2+n)}const u=Object.assign(e,{type:"quadratic",style:l}),c=null===(a=this.context.element)||void 0===a?void 0:a.getElement(yh(e));c&&NH(u.style,c.attributes)||SH(t,c?"update":"add","edge",u,!0)}))}))},this.resetEdgeStyle=t=>{const e=t.style||{},n=this.cacheMergeStyle.get(yh(t))||{};return Object.keys(n).forEach((r=>{Ne(e[r],n[r])&&(t[r]?e[r]=t[r]:delete e[r])})),Object.assign(t,{style:e})},this.applyMergingStyle=(t,e)=>{const{edgeMap:n,reverses:r}=bY(e);n.forEach((e=>{var n;if(1===e.length){const r=e[0],i=null===(n=this.context.element)||void 0===n?void 0:n.getElement(yh(r)),o=this.resetEdgeStyle(r);return void(i&&NH(o,i.attributes)||SH(t,i?"update":"add","edge",o))}const i=e.map((({source:t,target:e,style:n={}},i)=>{const{startArrow:o,endArrow:a}=n,s={},[l,u]=r[`${t}|${e}|${i}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return pe(o)&&(s[l]=o),pe(a)&&(s[u]=a),s})).reduce(((t,e)=>Object.assign(Object.assign({},t),e)),{});e.forEach(((e,n,r)=>{var o;if(0!==n)return void SH(t,"remove","edge",e);const a=Object.assign({},Yt(this.options.style)?this.options.style(r):this.options.style,{childrenData:r});this.cacheMergeStyle.set(yh(e),a);const s=Object.assign(Object.assign({},e),{type:"line",style:Object.assign(Object.assign(Object.assign({},e.style),i),a)}),l=null===(o=this.context.element)||void 0===o?void 0:o.getElement(yh(e));l&&NH(s.style,l.attributes)||SH(t,l?"update":"add","edge",s,!0)}))}))}}beforeDraw(t){const e=this.getAffectedParallelEdges(t);return 0===e.size||("bundle"===this.options.mode?this.applyBundlingStyle(t,e,this.options.distance):this.applyMergingStyle(t,e)),t}}yY.defaultOptions={mode:"bundle",distance:15};const bY=t=>{const e=new Map,n=new Set,r={};for(const[i,o]of t){if(n.has(i))continue;const{source:a,target:s}=o,l=`${a}-${s}`;e.has(l)||e.set(l,[]),e.get(l).push(o),n.add(i);for(const[i,u]of t)n.has(i)||EY(o,u)&&(e.get(l).push(u),n.add(i),a===u.target&&s===u.source&&(r[`${u.source}|${u.target}|${e.get(l).length-1}`]=!0))}return{edgeMap:e,reverses:r}},xY=(t,e,n)=>e.filter((e=>EY(e,t))),EY=(t,e)=>{const{sourceNode:n,targetNode:r}=t.style||{},{sourceNode:i,targetNode:o}=e.style||{};return n===i&&r===o||n===o&&r===i};const wY={animation:{"combo-collapse":Gc,"combo-expand":Vc,"node-collapse":jc,"node-expand":Bc,"path-in":Fc,"path-out":zc,fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}]},behavior:{"brush-select":vd,"click-select":Md,"collapse-expand":_g,"create-edge":jg,"drag-canvas":Bg,"drag-element-force":Kg,"drag-element":Fg,"fix-element-size":Zg,"focus-element":Qg,"hover-activate":Jg,"lasso-select":tv,"auto-adapt-label":Lh,"optimize-viewport-transform":ev,"scroll-canvas":nv,"zoom-canvas":rv},combo:{circle:Cp,rect:Pp},edge:{cubic:rg,line:sg,polyline:yg,quadratic:bg,"cubic-horizontal":ig,"cubic-radial":og,"cubic-vertical":ag},layout:{"antv-dagre":gb,"combo-combined":Jx,"compact-box":hm.compactBox,"d3-force":GE,"force-atlas2":ij,circular:bb,concentric:kb,dagre:JI,dendrogram:hm.dendrogram,fishbone:qj,force:Ub,fruchterman:aj,grid:lj,indented:hm.indented,mds:$x,mindmap:hm.mindmap,radial:bj,random:Nj,snake:Qj},node:{circle:ef,diamond:rf,ellipse:lf,hexagon:uf,html:Mp,image:Sp,rect:Np,star:Op,donut:of,triangle:Tp},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)"],tableau:["rgb(78, 121, 167)","rgb(242, 142, 44)","rgb(225, 87, 89)","rgb(118, 183, 178)","rgb(89, 161, 79)","rgb(237, 201, 73)","rgb(175, 122, 161)","rgb(255, 157, 167)","rgb(156, 117, 95)","rgb(186, 176, 171)"],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:wH,light:kH},plugin:{"bubble-sets":FB,"edge-bundling":WB,"edge-filter-lens":QB,"grid-line":nF,background:nB,contextmenu:VB,fisheye:tF,fullscreen:eF,history:sF,hull:RF,legend:tH,minimap:eH,snapline:oH,timebar:uH,toolbar:fH,tooltip:pH,watermark:mH},transform:{"arrange-draw-order":class extends MH{beforeDraw(t){const{model:e}=this.context,n=t.add.combos,r=t=>{const n=[];return t.forEach(((t,r)=>{const i=e.getAncestorsData(r,"combo").map((t=>yh(t))).reverse();n.push([r,t,i.length])})),new Map(n.sort((([,,t],[,,e])=>e-t)).map((([t,e])=>[t,e])))};return t.add.combos=r(n),t.update.combos=r(t.update.combos),t}},"collapse-expand-combo":class extends MH{beforeDraw(t,e){if("visibility"===e.stage)return t;if(!this.context.model.model.hasTreeStructure(Ec))return t;const{model:n}=this.context,{add:r,update:i}=t,o=[...t.update.combos.entries(),...t.add.combos.entries()];for(;o.length;){const[e,a]=o.pop();if(Sd(a)){const a=n.getDescendantsData(e),s=a.map(yh),{internal:l,external:u}=Qp(s,(t=>n.getRelatedEdgesData(t)));a.forEach((e=>{const r=yh(e),i=o.findIndex((([t])=>t===r));-1!==i&&o.splice(i,1);const a=n.getElementType(r);SH(t,"remove",a,e)})),l.forEach((e=>SH(t,"remove","edge",e))),u.forEach((t=>{var e;const n=yh(t);(null===(e=this.context.element)||void 0===e?void 0:e.getElement(n))?i.edges.set(n,t):r.edges.set(n,t)}))}else{const r=n.getChildrenData(e),i=r.map(yh),{edges:a}=Qp(i,(t=>n.getRelatedEdgesData(t)));[...r,...a].forEach((e=>{var r;const i=yh(e),a=n.getElementType(i),s=null===(r=this.context.element)||void 0===r?void 0:r.getElement(i);SH(t,s?"update":"add",a,e),"combo"===a&&o.push([i,e])}))}}return t}},"collapse-expand-node":class extends MH{getElement(t){return this.context.element.getElement(t)}handleExpand(t,e){if(OH(e,"add","node",t),Sd(t))return;const n=yh(t);OH(e,"add","node",t);this.context.model.getRelatedEdgesData(n,"out").forEach((t=>{SH(e,"add","edge",t)}));this.context.model.getChildrenData(n).forEach((t=>{this.handleExpand(t,e)}))}beforeDraw(t){const{graph:e,model:n}=this.context;if(!n.model.hasTreeStructure(wc))return t;const{add:{nodes:r,edges:i},update:{nodes:o}}=t,a=new Map,s=new Map;r.forEach(((t,e)=>{Sd(t)&&a.set(e,t)})),i.forEach((t=>{if("node"!==e.getElementType(t.source))return;const n=e.getNodeData(t.source);Sd(n)&&a.set(t.source,n)})),o.forEach(((t,e)=>{const n=this.getElement(e);if(!n)return;const r=n.attributes.collapsed;Sd(t)?r||a.set(e,t):r&&s.set(e,t)}));const l=new Set;return a.forEach(((e,r)=>{n.getDescendantsData(r).forEach((e=>{const r=yh(e);if(l.has(r))return;SH(t,"remove","node",e);n.getRelatedEdgesData(r).forEach((e=>{SH(t,"remove","edge",e)})),l.add(r)}))})),s.forEach(((e,r)=>{n.getAncestorsData(r,wc).some(Sd)?SH(t,"remove","node",e):this.handleExpand(e,t)})),t}},"get-edge-actual-ends":class extends MH{beforeDraw(t){const{add:e,update:n}=t,{model:r}=this.context;return[...e.edges.entries(),...n.edges.entries()].forEach((([,t])=>{pY(r,t)})),t}},"map-node-size":gY,"place-radial-labels":vY,"process-parallel-edges":yY,"update-related-edges":class extends MH{beforeDraw(t,e){const{stage:n}=e;if("visibility"===n)return t;const{model:r}=this.context,{update:{nodes:i,edges:o,combos:a}}=t,s=(t,e)=>{r.getRelatedEdgesData(e).forEach((t=>!o.has(yh(t))&&o.set(yh(t),t)))};return i.forEach(s),a.forEach(s),t}}},shape:{circle:Dl,ellipse:Il,group:jl,html:Fl,image:$d,line:Vl,path:Hl,polygon:Ul,polyline:ql,rect:Xl,text:Zl,label:Gd,badge:Vd}};Object.entries(wY).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{CH(t,e,n)}))}));t.AntVDagreLayout=gb,t.AutoAdaptLabel=Lh,t.Background=nB,t.Badge=Vd,t.BaseBehavior=Dh,t.BaseCombo=Ap,t.BaseEdge=ng,t.BaseLayout=Ug,t.BaseNode=tf,t.BasePlugin=Jj,t.BaseShape=Bd,t.BaseTransform=MH,t.BrushSelect=vd,t.BubbleSets=FB,t.CameraSetting=class extends Jj{constructor(t,e){super(t,e),this.setOptions=t=>{const e=(t,e)=>{switch(t){case"projectionMode":return"perspective"===e?1:0;case"cameraType":return{orbiting:0,exploring:1,tracking:2}[e];case"aspect":return"number"==typeof e?e:this.getCanvasAspect();default:return e}};Object.entries({cameraType:"setType",near:"setNear",far:"setFar",fov:"setFov",aspect:"setAspect",projectionMode:"setProjectionMode",distance:"setDistance",minDistance:"setMinDistance",maxDistance:"setMaxDistance",roll:"setRoll",elevation:"setElevation",azimuth:"setAzimuth"}).forEach((([n,r])=>{const i=t[n];if(void 0!==i){const t=e(n,i);this.context.canvas.getCamera()[r](t)}}))},this.bindEvents()}update(t){this.setOptions(t),super.update(t)}bindEvents(){this.context.graph.once(t.GraphEvent.BEFORE_DRAW,(()=>this.setOptions(this.options)))}getCanvasAspect(){const[t,e]=this.context.viewport.getCanvasSize();return t/e}},t.Canvas=_H,t.Circle=ef,t.CircleCombo=Cp,t.CircularLayout=bb,t.ClickSelect=Md,t.CollapseExpand=_g,t.ComboCombinedLayout=Jx,t.CompactBoxLayout=hm.compactBox,t.ConcentricLayout=kb,t.Contextmenu=VB,t.CreateEdge=jg,t.Cubic=rg,t.CubicHorizontal=ig,t.CubicRadial=og,t.CubicVertical=ag,t.D3ForceLayout=GE,t.DagreLayout=JI,t.DendrogramLayout=hm.dendrogram,t.Diamond=rf,t.Donut=of,t.DragCanvas=Bg,t.DragElement=Fg,t.DragElementForce=Kg,t.EdgeBundling=WB,t.EdgeFilterLens=QB,t.Ellipse=lf,t.FishboneLayout=qj,t.Fisheye=tF,t.FixElementSize=Zg,t.FocusElement=Qg,t.ForceAtlas2Layout=ij,t.ForceLayout=Ub,t.FruchtermanLayout=aj,t.Fullscreen=eF,t.Graph=fY,t.GridLayout=lj,t.GridLine=nF,t.HTML=Mp,t.Hexagon=uf,t.History=sF,t.HoverActivate=Jg,t.Hull=RF,t.Icon=Qd,t.Image=Sp,t.IndentedLayout=hm.indented,t.Label=Gd,t.LassoSelect=tv,t.Legend=tH,t.Line=sg,t.MDSLayout=$x,t.MapNodeSize=gY,t.MindmapLayout=hm.mindmap,t.Minimap=eH,t.OptimizeViewportTransform=ev,t.PlaceRadialLabels=vY,t.Polyline=yg,t.ProcessParallelEdges=yY,t.Quadratic=bg,t.RadialLayout=bj,t.RandomLayout=Nj,t.Rect=Np,t.RectCombo=Pp,t.ScrollCanvas=nv,t.Shortcut=gd,t.SnakeLayout=Qj,t.Snapline=oH,t.Star=Op,t.Timebar=uH,t.Toolbar=fH,t.Tooltip=pH,t.Triangle=Tp,t.Watermark=mH,t.ZoomCanvas=rv,t.effect=function(t,e,n){TH.has(t)||TH.set(t,{});const r=TH.get(t);if(!r[e])return r[e]=n,!0;const i=r[e];return!AH(i,n)&&(r[e]=n,!0)},t.getExtension=Sc,t.getExtensions=function(t){return Mc[t]},t.iconfont={css:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.css",js:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.js"},t.idOf=yh,t.invokeLayoutMethod=qg,t.isCollapsed=Sd,t.omitStyleProps=Cd,t.parseSize=Pd,t.positionOf=Qh,t.register=CH,t.setVisibility=Ch,t.subStyleProps=Td,t.treeToGraphData=function(t,e){const{getNodeData:n=(t,e)=>{if(t.depth=e,!t.children)return t;const{children:n}=t,r=Fe(t,["children"]);return Object.assign(Object.assign({},r),{children:n.map((t=>t.id))})},getEdgeData:r=(t,e)=>({source:t.id,target:e.id}),getChildren:i=t=>t.children||[]}=e||{},o=[],a=[];return xd(t,((t,e)=>{o.push(n(t,e));const s=i(t);for(const e of s)a.push(r(t,e))}),(t=>i(t)),"TB"),{nodes:o,edges:a}},t.version=Nc}));
79
+ */var PH=function(){function t(e){s(this,t),this.dragndropPluginOptions=e}return u(t,[{key:"apply",value:function(e){var n=this,r=e.renderingService,i=e.renderingContext.root.ownerDocument,o=i.defaultView,a=function(t){var e=t.target,r=e===i,a=r&&n.dragndropPluginOptions.isDocumentDraggable?i:e.closest&&e.closest("[draggable=true]");if(a){var s=!1,l=t.timeStamp,u=[t.clientX,t.clientY],c=null,h=[t.clientX,t.clientY],d=function(){var t=Pr(Ar().mark((function t(o){var d,f,p,g,v,m;return Ar().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s){t.next=8;break}if(d=o.timeStamp-l,f=gn([o.clientX,o.clientY],u),!(d<=n.dragndropPluginOptions.dragstartTimeThreshold||f<=n.dragndropPluginOptions.dragstartDistanceThreshold)){t.next=5;break}return t.abrupt("return");case 5:o.type="dragstart",a.dispatchEvent(o),s=!0;case 8:if(o.type="drag",o.dx=o.clientX-h[0],o.dy=o.clientY-h[1],a.dispatchEvent(o),h=[o.clientX,o.clientY],r){t.next=21;break}return p="pointer"===n.dragndropPluginOptions.overlap?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=17,i.elementsFromPoint(p[0],p[1]);case 17:g=t.sent,v=g[g.indexOf(e)+1],m=(null==v?void 0:v.closest("[droppable=true]"))||(n.dragndropPluginOptions.isDocumentDroppable?i:null),c!==m&&(c&&(o.type="dragleave",o.target=c,c.dispatchEvent(o)),m&&(o.type="dragenter",o.target=m,m.dispatchEvent(o)),(c=m)&&(o.type="dragover",o.target=c,c.dispatchEvent(o)));case 21:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();o.addEventListener("pointermove",d);var f=function(t){if(s){t.detail={preventClick:!0};var e=t.clone();c&&(e.type="drop",e.target=c,c.dispatchEvent(e)),e.type="dragend",a.dispatchEvent(e),s=!1}o.removeEventListener("pointermove",d)};e.addEventListener("pointerup",f,{once:!0}),e.addEventListener("pointerupoutside",f,{once:!0})}};r.hooks.init.tap(t.tag,(function(){o.addEventListener("pointerdown",a)})),r.hooks.destroy.tap(t.tag,(function(){o.removeEventListener("pointerdown",a)}))}}])}();PH.tag="Dragndrop";var RH=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,e),(t=v(this,e)).name="dragndrop",t.options=n,t}return y(e,t),u(e,[{key:"init",value:function(){this.addRenderingPlugin(new PH(a({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}},{key:"setOptions",value:function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)}}])}(Br);const DH=["main"],LH=["background","main","label","transient"];class _H{getConfig(){return this.config}getLayer(t="main"){return this.extends.layers[t]||this.getLayers().main}getLayers(){return this.extends.layers}getRenderer(t){return this.extends.renderers[t]}getCamera(t="main"){return this.getLayer(t).getCamera()}getRoot(t="main"){return this.getLayer(t).getRoot()}getContextService(t="main"){return this.getLayer(t).getContextService()}setCursor(t){this.config.cursor=t,this.getLayer().setCursor(t)}get document(){return this.getLayer().document}get context(){return this.getLayer().context}constructor(t){this.config={enableMultiLayer:!0},Object.assign(this.config,t);const e=this.config,{renderer:n,background:r,cursor:i,enableMultiLayer:o}=e,a=Fe(e,["renderer","background","cursor","enableMultiLayer"]),s=o?LH:DH,l=IH(n,s),u=Object.fromEntries(s.map((t=>[t,new hu(Object.assign(Object.assign({},a),{supportsMutipleCanvasesInOneContainer:o,renderer:l[t],background:o?"background"===t?r:void 0:r}))])));jH(u),this.extends={config:this.config,renderer:n,renderers:l,layers:u}}get ready(){return Promise.all(Object.entries(this.getLayers()).map((([,t])=>t.ready)))}resize(t,e){Object.assign(this.extends.config,{width:t,height:e}),Object.values(this.getLayers()).forEach((n=>{const r=n.getCamera(),i=r.getPosition(),o=r.getFocalPoint();n.resize(t,e),r.setPosition(i),r.setFocalPoint(o)}))}getBounds(t){return Jc(Object.values(this.getLayers()).map((e=>t?e.getRoot().childNodes.find((e=>e.classList.includes(t))):e.getRoot())).filter((t=>(null==t?void 0:t.childNodes.length)>0)).map((t=>t.getBounds())))}getContainer(){const t=this.extends.config.container;return"string"==typeof t?document.getElementById(t):t}getSize(){return[this.extends.config.width||0,this.extends.config.height||0]}appendChild(t,e){var n;const r=(null===(n=t.style)||void 0===n?void 0:n.$layer)||"main";return this.getLayer(r).appendChild(t,e)}setRenderer(t){if(t===this.extends.renderer)return;const e=IH(t,this.config.enableMultiLayer?LH:DH);this.extends.renderers=e,Object.entries(e).forEach((([t,e])=>this.getLayer(t).setRenderer(e))),jH(this.getLayers())}getCanvasByViewport(t){return ed(this.getLayer().viewport2Canvas(nd(t)))}getViewportByCanvas(t){return ed(this.getLayer().canvas2Viewport(nd(t)))}getViewportByClient(t){return ed(this.getLayer().client2Viewport(nd(t)))}getClientByViewport(t){return ed(this.getLayer().viewport2Client(nd(t)))}getClientByCanvas(t){return this.getClientByViewport(this.getViewportByCanvas(t))}getCanvasByClient(t){const e=this.getLayer(),n=e.client2Viewport(nd(t));return ed(e.viewport2Canvas(n))}toDataURL(){return ze(this,arguments,void 0,(function*(t={}){const e=globalThis.devicePixelRatio||1,{mode:n="viewport"}=t,r=Fe(t,["mode"]);let[i,o,a,s]=[0,0,0,0];if("viewport"===n)[a,s]=this.getSize();else if("overall"===n){const t=this.getBounds(),e=Xc(t);[i,o]=t.min,[a,s]=e}const l=An('<div id="virtual-image"></div>'),u=new hu({width:a,height:s,renderer:new kp,devicePixelRatio:e,container:l,background:this.extends.config.background});yield u.ready,u.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),u.appendChild(this.getRoot().cloneNode(!0));const c=this.getLayer("label").getRoot().cloneNode(!0),h=u.viewport2Canvas({x:0,y:0}),d=this.getCanvasByViewport([0,0]);c.translate([d[0]-h.x,d[1]-h.y]),c.scale(1/this.getCamera().getZoom()),u.appendChild(c),u.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const f=this.getCamera(),p=u.getCamera();if("viewport"===n)p.setZoom(f.getZoom()),p.setPosition(f.getPosition()),p.setFocalPoint(f.getFocalPoint());else if("overall"===n){const[t,e,n]=p.getPosition(),[r,a,s]=p.getFocalPoint();p.setPosition([t+i,e+o,n]),p.setFocalPoint([r+i,a+o,s])}const g=u.getContextService();return new Promise((t=>{u.addEventListener(ou.RERENDER,(()=>ze(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,300)));const e=yield g.toDataURL(r);t(e)}))))}))}))}destroy(){Object.values(this.getLayers()).forEach((t=>{t.getCamera().cancelLandmarkAnimation(),t.destroy()}))}}function IH(t,e){return Object.fromEntries(e.map((e=>{const n=(null==t?void 0:t(e))||new kp;return"main"===e?n.registerPlugin(new RH({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):n.unregisterPlugin(n.getPlugin("dom-interaction")),[e,n]})))}function jH(t){Object.entries(t).forEach((([t,e])=>{const n=e.getContextService().getDomElement();(null==n?void 0:n.style)&&(n.style.gridArea="1 / 1 / 2 / 2",n.style.outline="none",n.tabIndex=1,"main"!==t&&(n.style.pointerEvents="none")),(null==n?void 0:n.parentElement)&&(n.parentElement.style.display="grid")}))}const BH=t=>t?parseInt(t):0;function FH(t){if(!t)return[0,0];let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||BH(e.width),r=t.clientHeight||BH(e.height);return[n-(BH(e.paddingLeft)+BH(e.paddingRight)),r-(BH(e.paddingTop)+BH(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(ae(e)?e:1,1),Math.max(ae(n)?n:1,1)]}class zH{constructor(t){this.type=t}}class GH extends zH{constructor(t,e){super(t),this.data=e}}class VH extends zH{constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class WH extends zH{constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class HH extends zH{constructor(t,e){super(t),this.data=e}}function YH(t,e){t.emit(e.type,e)}function UH(t){var e;return(null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0}const $H="cachedStyle",qH=t=>`__${t}__`;function XH(t,e){return Oe(t,[$H,qH(e)])}class KH{constructor(t){this.tasks=[],this.animations=new Set,this.context=t}getTasks(){const t=[...this.tasks];return this.tasks=[],t}add(t,e){this.tasks.push([t,e])}animate(t,e,n){var r,i,o;null===(r=null==e?void 0:e.before)||void 0===r||r.call(e);const a=this.getTasks().map((([e,r])=>{var i,o,a;const{element:s,elementType:l,stage:u}=e,c=Lc(this.context.options,l,u,t);null===(i=null==r?void 0:r.before)||void 0===i||i.call(r);const h=c.length?Ic(s,this.inferStyle(e,n),c):null;return h?(null===(o=null==r?void 0:r.beforeAnimate)||void 0===o||o.call(r,h),h.finished.then((()=>{var t,e;null===(t=null==r?void 0:r.afterAnimate)||void 0===t||t.call(r,h),null===(e=null==r?void 0:r.after)||void 0===e||e.call(r),this.animations.delete(h)}))):null===(a=null==r?void 0:r.after)||void 0===a||a.call(r),h})).filter(Boolean);a.forEach((t=>this.animations.add(t)));const s=Cc(a);return s?(null===(i=null==e?void 0:e.beforeAnimate)||void 0===i||i.call(e,s),s.finished.then((()=>{var t,n;null===(t=null==e?void 0:e.afterAnimate)||void 0===t||t.call(e,s),null===(n=null==e?void 0:e.after)||void 0===n||n.call(e),this.release()}))):null===(o=null==e?void 0:e.after)||void 0===o||o.call(e),s}inferStyle(t,e){var n,r;const{element:i,elementType:o,stage:a,originalStyle:s,updatedStyle:l={}}=t;t.modifiedStyle||(t.modifiedStyle=Object.assign(Object.assign({},s),l));const{modifiedStyle:u}=t,c={},h={};if("enter"===a)Object.assign(c,{opacity:0});else if("exit"===a)Object.assign(h,{opacity:0});else if("show"===a)Object.assign(c,{opacity:0}),Object.assign(h,{opacity:null!==(n=XH(i,"opacity"))&&void 0!==n?n:Rc("opacity")});else if("hide"===a)Object.assign(c,{opacity:null!==(r=XH(i,"opacity"))&&void 0!==r?r:Rc("opacity")}),Object.assign(h,{opacity:0});else if("collapse"===a){const{collapse:t}=e||{},{target:n,descendants:r,position:a}=t;if("node"===o){if(r.includes(i.id)){const[t,e,n]=a;Object.assign(h,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e]=a;Object.assign(h,{x:t,y:e,childrenNode:s.childrenNode})}}else"edge"===o&&Object.assign(h,{sourceNode:u.sourceNode,targetNode:u.targetNode})}else if("expand"===a){const{expand:t}=e||{},{target:n,descendants:r,position:a}=t;if("node"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=a;Object.assign(c,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=a;Object.assign(c,{x:t,y:e,z:n,childrenNode:u.childrenNode})}}else"edge"===o&&Object.assign(c,{sourceNode:u.sourceNode,targetNode:u.targetNode})}return[Object.keys(c).length>0?Object.assign({},s,c):s,Object.keys(h).length>0?Object.assign({},u,h):u]}stop(){this.animations.forEach((t=>t.cancel()))}clear(){this.tasks=[]}release(){var t,e;const{canvas:n}=this.context,r=null===(e=null===(t=n.document)||void 0===t?void 0:t.timeline)||void 0===e?void 0:e.animationsWithPromises;r&&(n.document.timeline.animationsWithPromises=r.filter((t=>"finished"!==t.playState)))}destroy(){this.stop(),this.animations.clear(),this.tasks=[]}}class ZH{constructor(t){this.batchCount=0,this.context=t}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}startBatch(e=!0){this.batchCount++,1===this.batchCount&&this.emit(new GH(t.GraphEvent.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,0===this.batchCount&&this.emit(new GH(t.GraphEvent.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class QH extends Ph{constructor(e){super(e),this.currentTarget=null,this.currentTargetType=null,this.category="behavior",this.forwardCanvasEvents=e=>{const{target:n}=e,r=function(t){if(!t)return null;if(t instanceof Jl)return{type:"canvas",element:t};let e=t;for(;e;){if(xg(e))return{type:"node",element:e};if(Eg(e))return{type:"edge",element:e};if(wg(e))return{type:"combo",element:e};e=e.parentElement}return null}(n);if(!r)return;const{graph:i,canvas:o}=this.context,{type:a,element:s}=r;if("destroyed"in s&&(Lg(s)||s.destroyed))return;const{type:l,detail:u,button:c}=e,h=Object.assign(Object.assign({},e),{target:s,targetType:a,originalTarget:n});l===t.CommonEvent.POINTER_MOVE&&(this.currentTarget!==s&&(this.currentTarget&&i.emit(`${this.currentTargetType}:${t.CommonEvent.POINTER_LEAVE}`,Object.assign(Object.assign({},h),{type:t.CommonEvent.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),s&&(Object.assign(h,{type:t.CommonEvent.POINTER_ENTER}),i.emit(`${a}:${t.CommonEvent.POINTER_ENTER}`,h))),this.currentTarget=s,this.currentTargetType=a),l===t.CommonEvent.CLICK&&2===c||(i.emit(`${a}:${l}`,h),i.emit(l,h)),l===t.CommonEvent.CLICK&&2===u&&(Object.assign(h,{type:t.CommonEvent.DBLCLICK}),i.emit(`${a}:${t.CommonEvent.DBLCLICK}`,h),i.emit(t.CommonEvent.DBLCLICK,h)),l===t.CommonEvent.POINTER_DOWN&&2===c&&(Object.assign(h,{type:t.CommonEvent.CONTEXT_MENU,preventDefault:()=>{var e;null===(e=o.getContainer())||void 0===e||e.addEventListener(t.CommonEvent.CONTEXT_MENU,(t=>t.preventDefault()),{once:!0})}}),i.emit(`${a}:${t.CommonEvent.CONTEXT_MENU}`,h),i.emit(t.CommonEvent.CONTEXT_MENU,h))},this.forwardContainerEvents=t=>{this.context.graph.emit(t.type,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)}));const n=this.context.canvas.document;n&&[t.CommonEvent.CLICK,t.CommonEvent.DBLCLICK,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE,t.CommonEvent.POINTER_ENTER,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_OUT,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_UP,t.CommonEvent.CONTEXT_MENU,t.CommonEvent.DRAG_START,t.CommonEvent.DRAG,t.CommonEvent.DRAG_END,t.CommonEvent.DRAG_ENTER,t.CommonEvent.DRAG_OVER,t.CommonEvent.DRAG_LEAVE,t.CommonEvent.DROP,t.CommonEvent.WHEEL].forEach((t=>{n.addEventListener(t,this.forwardCanvasEvents)}))}destroy(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach((t=>{e.removeEventListener(t,this.forwardContainerEvents)})),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}function JH(t,e){const{data:n,style:r}=t,i=Fe(t,["data","style"]),{data:o,style:a}=e,s=Fe(e,["data","style"]),l=Object.assign(Object.assign({},i),s);return(n||o)&&Object.assign(l,{data:Object.assign(Object.assign({},n),o)}),(r||a)&&Object.assign(l,{style:Object.assign(Object.assign({},r),a)}),l}function tY(t){const{data:e,style:n}=t,r=Fe(t,["data","style"]);return e&&(r.data=Object.assign({},e)),n&&(r.style=Object.assign({},n)),r}function eY(t={},e={}){const{states:n=[],data:r={},style:i={},children:o=[]}=t,a=Fe(t,["states","data","style","children"]),{states:s=[],data:l={},style:u={},children:c=[]}=e,h=(t,e)=>t.length===e.length&&t.every(((t,n)=>t===e[n])),d=(t,e)=>{const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every((n=>t[n]===e[n]))};return!!d(a,Fe(e,["states","data","style","children"]))&&(!!h(o,c)&&(!!h(n,s)&&(!!d(r,l)&&!!d(i,u))))}function nY(t){const{id:e=yh(t),style:n,data:r}=t,i=Fe(t,["id","style","data"]),o=Object.assign(Object.assign({},t),{style:Object.assign({},n),data:Object.assign({},r)});return function(t){return"source"in t&&"target"in t}(t)?Object.assign({id:e,data:o},i):{id:e,data:o}}function rY(t){return t.data}class iY{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new Yg}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===dc.NodeUpdated||e===dc.EdgeUpdated||e===dc.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:tY(n),original:tY(r),type:e})}else this.changes.push({value:tY(t.value),type:e})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}isBatching(){return this.batchCount>0}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=rY(n);return this.isCombo(yh(r))||(void 0===t||t.includes(yh(r)))&&e.push(r),e}),[])}getEdgeDatum(t){return rY(this.model.getEdge(t))}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=rY(n);return(void 0===t||t.includes(yh(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=rY(n);return this.isCombo(yh(r))?((void 0===t||t.includes(yh(r)))&&e.push(r),e):e}),[])}getRootsData(t=wc){return this.model.getRoots(t).map(rY)}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(rY):[]}getDescendantsData(t){const e=this.getElementDataById(t),n=[];return xd(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(yh(t))),"TB"),n}getParentData(t,e){const{model:n}=this;if(!e)return void Tc("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?rY(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?wc:Ec,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(rY):[]}getElementsDataByType(t){return"node"===t?this.getNodeData():"edge"===t?this.getEdgeData():"combo"===t?this.getComboData():[]}getElementDataById(t){return"edge"===this.getElementType(t)?this.getEdgeDatum(t):this.getNodeLikeDatum(t)}getNodeLikeDatum(t){return rY(this.model.getNode(t))}getNodeLikeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=rY(n);return t?t.includes(yh(r))&&e.push(r):e.push(r),e}),[])}getElementDataByState(t,e){return this.getElementsDataByType(t).filter((t=>{var n;return null===(n=t.states)||void 0===n?void 0:n.includes(e)}))}getElementState(t){var e;return(null===(e=this.getElementDataById(t))||void 0===e?void 0:e.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(rY)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(rY)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i,edges:o,combos:a}=this.getData(),s=Ah(i,e,(t=>yh(t)),eY),l=Ah(o,n,(t=>yh(t)),eY),u=Ah(a,r,(t=>yh(t)),eY);this.batch((()=>{const t={nodes:s.enter,edges:l.enter,combos:u.enter};this.addData(t),this.computeZIndex(t,"add",!0);const e={nodes:s.update,edges:l.update,combos:u.update};this.updateData(e),this.computeZIndex(e,"update",!0);const n={nodes:s.exit.map(yh),edges:l.exit.map(yh),combos:u.exit.map(yh)};this.removeData(n)}))}addData(t){const{nodes:e,edges:n,combos:r}=t;this.batch((()=>{this.addComboData(r),this.addNodeData(e),this.addEdgeData(n)})),this.computeZIndex(t,"add")}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map((t=>(this.pushChange({value:t,type:dc.NodeAdded}),nY(t))))),this.updateNodeLikeHierarchy(t),this.computeZIndex({nodes:t},"add"))}addEdgeData(t=[]){t.length&&(this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:dc.EdgeAdded}),nY(t))))),this.computeZIndex({edges:t},"add"))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(Ec)||e.attachTreeStructure(Ec),e.addNodes(t.map((t=>(this.comboIds.add(yh(t)),this.pushChange({value:t,type:dc.ComboAdded}),nY(t))))),this.updateNodeLikeHierarchy(t),this.computeZIndex({combos:t},"add")}addChildrenData(t,e){const n=this.getNodeLikeDatum(t),r=e.map(yh);this.addNodeData(e),this.updateNodeData([{id:t,children:[...n.children||[],...r]}]),this.addEdgeData(r.map((e=>({source:t,target:e}))))}computeZIndex(t,e,n=!1){!n&&this.isBatching()||this.batch((()=>{const{nodes:n=[],edges:r=[],combos:i=[]}=t;i.forEach((t=>{var n,r,i;const o=yh(t);if("add"===e&&ae(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t))return;const a=this.getParentData(o,Ec),s=a?(null!==(i=null===(r=a.style)||void 0===r?void 0:r.zIndex)&&void 0!==i?i:0)+1:0;this.preventUpdateNodeLikeHierarchy((()=>{this.updateComboData([{id:o,style:{zIndex:s}}])}))})),n.forEach((t=>{var n,r,i;const o=yh(t);if("add"===e&&ae(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t)&&!("children"in t))return;let a=0;const s=this.getParentData(o,Ec);if(s)a=((null===(r=s.style)||void 0===r?void 0:r.zIndex)||0)+1;else{const t=this.getParentData(o,wc);t&&(a=(null===(i=null==t?void 0:t.style)||void 0===i?void 0:i.zIndex)||0)}this.preventUpdateNodeLikeHierarchy((()=>{this.updateNodeData([{id:o,style:{zIndex:a}}])}))})),r.forEach((t=>{var e,n,r,i,o;if(ae(null===(e=t.style)||void 0===e?void 0:e.zIndex))return;let{id:a,source:s,target:l}=t;if(a){const t=this.getEdgeDatum(a);s=t.source,l=t.target}else a=yh(t);if(!s||!l)return;const u=(null===(r=null===(n=this.getNodeLikeDatum(s))||void 0===n?void 0:n.style)||void 0===r?void 0:r.zIndex)||0,c=(null===(o=null===(i=this.getNodeLikeDatum(l))||void 0===i?void 0:i.style)||void 0===o?void 0:o.zIndex)||0;this.updateEdgeData([{id:yh(t),style:{zIndex:Math.max(u,c)-1}}])}))}))}getFrontZIndex(t){var e;const n=this.getElementType(t),r=this.getElementDataById(t),i=this.getData();if(Object.assign(i,{[`${n}s`]:i[`${n}s`].filter((e=>yh(e)!==t))}),"combo"===n&&!Sd(r)){const e=new Set(this.getAncestorsData(t,Ec).map(yh));i.nodes=i.nodes.filter((t=>!e.has(yh(t)))),i.combos=i.combos.filter((t=>!e.has(yh(t)))),i.edges=i.edges.filter((({source:t,target:n})=>!e.has(t)&&!e.has(n)))}return Math.max((null===(e=r.style)||void 0===e?void 0:e.zIndex)||0,0,...Object.values(i).flat().map((t=>{var e;return((null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0)+1})))}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach((t=>{const n=yh(t),r=bh(t);void 0!==r&&(e.hasTreeStructure(Ec)||e.attachTreeStructure(Ec),null===r&&this.refreshComboData(n),this.setParent(n,bh(t),Ec));const i=t.children||[];if(i.length){e.hasTreeStructure(wc)||e.attachTreeStructure(wc);const t=i.filter((t=>e.hasNode(t)));t.forEach((t=>this.setParent(t,n,wc))),t.length!==i.length&&this.updateNodeData([{id:n,children:t}])}}))}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)})),this.computeZIndex(t,"update")}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{const n=[];t.forEach((t=>{const r=yh(t),i=rY(e.getNode(r));if(eY(i,t))return;const o=JH(i,t);this.pushChange({value:o,original:i,type:dc.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)})),this.computeZIndex({nodes:t},"update")}refreshData(){const{nodes:t,edges:e,combos:n}=this.getData();t.forEach((t=>{this.pushChange({value:t,original:t,type:dc.NodeUpdated})})),e.forEach((t=>{this.pushChange({value:t,original:t,type:dc.EdgeUpdated})})),n.forEach((t=>{this.pushChange({value:t,original:t,type:dc.ComboUpdated})}))}syncNodeLikeDatum(t){const{model:e}=this,n=yh(t);if(!e.hasNode(n))return;const r=JH(rY(e.getNode(n)),t);e.mergeNodeData(n,r)}syncEdgeDatum(t){const{model:e}=this,n=yh(t);if(!e.hasEdge(n))return;const r=JH(rY(e.getEdge(n)),t);e.mergeEdgeData(n,r)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch((()=>{t.forEach((t=>{const n=yh(t),r=rY(e.getEdge(n));if(eY(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=JH(r,t);this.pushChange({value:i,original:r,type:dc.EdgeUpdated}),e.mergeEdgeData(n,i)}))})),this.computeZIndex({edges:t},"update")}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch((()=>{const n=[];t.forEach((t=>{const r=yh(t),i=rY(e.getNode(r));if(eY(i,t))return;const o=JH(i,t);this.pushChange({value:o,original:i,type:dc.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)})),this.updateNodeLikeHierarchy(n)})),this.computeZIndex({combos:t},"update")}setParent(t,e,n,r=!0){if(t===e)return;const i=bh(this.getNodeLikeDatum(t));if(i!==e&&n===Ec){const n={id:t,combo:e};this.isCombo(t),this.syncNodeLikeDatum(n)}this.model.setParent(t,e,n),r&&n===Ec&&function(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}([i,e]).forEach((t=>{void 0!==t&&this.refreshComboData(t)}))}refreshComboData(t){const e=this.getComboData([t])[0],n=this.getAncestorsData(t,Ec);e&&this.pushChange({value:e,original:e,type:dc.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:dc.ComboUpdated})}))}getElementPosition(t){return Qh(this.getElementDataById(t))}translateNodeLikeBy(t,e){this.isCombo(t)?this.translateComboBy(t,e):this.translateNodeBy(t,e)}translateNodeLikeTo(t,e){this.isCombo(t)?this.translateComboTo(t,e):this.translateNodeTo(t,e)}translateNodeBy(t,e){const n=Ih(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];if(!o)return;const a=new Set;xd(o,(t=>{const e=yh(t);if(a.has(e))return;a.add(e);const[o,s,l]=Qh(t),u=JH(t,{style:{x:o+n,y:s+r,z:l+i}});this.pushChange({value:u,original:t,type:this.isCombo(e)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(e,u)}),(t=>this.getChildrenData(yh(t))),"BT")}translateComboTo(t,e){var n;if(e.some(isNaN))return;const[r=0,i=0,o=0]=e,a=null===(n=this.getComboData([t]))||void 0===n?void 0:n[0];if(!a)return;const[s,l,u]=Qh(a),c=r-s,h=i-l,d=o-u;xd(a,(t=>{const e=yh(t),[n,r,i]=Qh(t),o=JH(t,{style:{x:n+c,y:r+h,z:i+d}});this.pushChange({value:o,original:t,type:this.isCombo(e)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(yh(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(yh)),this.pushChange({value:this.getNodeData([t])[0],type:dc.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:dc.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:dc.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(Ec)){const e=bh(this.getNodeLikeDatum(t));this.setParent(t,void 0,Ec,!1),this.model.getChildren(t,Ec).forEach((t=>{const n=rY(t),r=yh(n);this.setParent(yh(n),e,Ec,!1);const i=JH(n,{id:yh(n),combo:e});this.pushChange({value:i,original:n,type:this.isCombo(r)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(yh(n),i)})),Ut(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(Oc(`Unknown element type of id: ${t}`))}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))),this.context={}}}class oY{constructor(t){this.elementMap={},this.shapeTypeMap={},this.paletteStyle={},this.defaultStyle={},this.stateStyle={},this.visibilityCache=new WeakMap,this.context=t}init(){if(!this.container){const{canvas:t}=this.context;this.container=t.appendChild(new jl({className:"elements"}))}}emit(t,e){e.silence||YH(this.context.graph,t)}forEachElementData(t){bd.forEach((e=>{const n=this.context.model.getElementsDataByType(e);t(e,n)}))}getElementType(t,e){var n;const{options:r,graph:i}=this.context,o=(null===(n=r[t])||void 0===n?void 0:n.type)||e.type;return o?"string"==typeof o?o:o.call(i,e):"edge"===t?"line":"circle"}getTheme(t){return Ac(this.context.options)[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]||{})))}computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData(((e,n)=>{var r,i;const o=Object.assign({},Ld(null===(r=this.getTheme(e))||void 0===r?void 0:r.palette),Ld(null===(i=t[e])||void 0===i?void 0:i.palette));(null==o?void 0:o.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="string"==typeof r?Sc("palette",r):r;if("function"==typeof e){const n={};return t.forEach((([t,r])=>{n[t]=e(o?1-r:r)})),n}if(Array.isArray(e)){const n=o?[...e].reverse():e,r={};return t.forEach((([t,i])=>{r[t]=n[i%e.length]})),r}return{}},s=(t,e)=>{var n;return"string"==typeof t?null===(n=e.data)||void 0===n?void 0:n[t]:null==t?void 0:t(e)};if("group"===n){const e=ie(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[yh(e)]=n[t]}))})),r}if("value"===n){const[e,n]=t.reduce((([t,e],n)=>{const r=s(i,n);if("number"!=typeof r)throw new Error(Oc(`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,o))}))}getPaletteStyle(t,e){const n=this.paletteStyle[e];return n?"edge"===t?{stroke:n}:{fill:n}:{}}computeElementDefaultStyle(t,e){var n;const{options:r}=this.context,i=(null===(n=r[t])||void 0===n?void 0:n.style)||{};"transform"in i&&Array.isArray(i.transform)&&(i.transform=[...i.transform]),this.defaultStyle[yh(e.datum)]=Rd(i,e)}computeElementsDefaultStyle(t){const{graph:e}=this.context;this.forEachElementData(((n,r)=>{const i=r.length;for(let o=0;o<i;o++){const i=r[o];(void 0===t||t.includes(yh(i)))&&this.computeElementDefaultStyle(n,{datum:i,graph:e})}}))}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch(t){return[]}}getElementStateStyle(t,e,n){var r,i;const{options:o}=this.context;return Rd((null===(i=null===(r=o[t])||void 0===r?void 0:r.state)||void 0===i?void 0:i[e])||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[yh(n.datum)]=Object.assign({},...e.map((e=>this.getElementStateStyle(t,e,n))))}computeElementsStatesStyle(t){const{graph:e}=this.context;this.forEachElementData(((n,r)=>{const i=r.length;for(let o=0;o<i;o++){const i=r[o];if(void 0===t||t.includes(yh(i))){const t=this.getElementState(yh(i));this.computeElementStatesStyle(n,t,{datum:i,graph:e})}}}))}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t,e){t&&["translate","zIndex"].includes(t)||(this.computePaletteStyle(),this.computeElementsDefaultStyle(e),this.computeElementsStatesStyle(e))}getElement(t){return this.elementMap[t]}getNodes(){return this.context.model.getNodeData().map((({id:t})=>this.elementMap[t]))}getEdges(){return this.context.model.getEdgeData().map((t=>this.elementMap[yh(t)]))}getCombos(){return this.context.model.getComboData().map((({id:t})=>this.elementMap[t]))}getElementComputedStyle(t,e){const n=yh(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(t,n),o=e.style||{},a=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),l=this.getStateStyle(n),u=Object.assign({},r,i,o,a,s,l);if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!u.collapsed?[]:t.map(yh).filter((t=>this.getElement(t)));Object.assign(u,{childrenNode:e,childrenData:t})}return u}getDrawData(t){this.init();const e=this.computeChangesAndDrawData(t);if(!e)return null;const{type:n="draw",stage:r=n}=t;return this.markDestroyElement(e.drawData),this.computeStyle(r),{type:n,stage:r,data:e}}draw(t={animation:!0}){const e=this.getDrawData(t);if(!e)return;const{data:{drawData:{add:n,update:r,remove:i}}}=e;return this.destroyElements(i,t),this.createElements(n,t),this.updateElements(r,t),this.setAnimationTask(t,e)}preLayoutDraw(){return ze(this,arguments,void 0,(function*(t={animation:!0}){var e,n;const r=this.getDrawData(t);if(!r)return;const{data:{drawData:i}}=r;yield null===(n=null===(e=this.context.layout)||void 0===e?void 0:e.preLayout)||void 0===n?void 0:n.call(e,i);const{add:o,update:a,remove:s}=i;return this.destroyElements(s,t),this.createElements(o,t),this.updateElements(a,t),this.setAnimationTask(t,r)}))}setAnimationTask(e,n){const{animation:r,silence:i}=e,{data:{dataChanges:o,drawData:a},stage:s,type:l}=n;return this.context.animation.animate(r,i?{}:{before:()=>this.emit(new GH(t.GraphEvent.BEFORE_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===l}),e),beforeAnimate:n=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.DRAW,n,a),e),afterAnimate:n=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.DRAW,n,a),e),after:()=>this.emit(new GH(t.GraphEvent.AFTER_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===l,firstRender:!1===this.context.graph.rendered}),e)})}computeChangesAndDrawData(t){const{model:e}=this.context,n=e.getChanges(),r=rF(n);if(0===r.length)return null;const{NodeAdded:i=[],NodeUpdated:o=[],NodeRemoved:a=[],EdgeAdded:s=[],EdgeUpdated:l=[],EdgeRemoved:u=[],ComboAdded:c=[],ComboUpdated:h=[],ComboRemoved:d=[]}=ie(r,(t=>t.type)),f=t=>new Map(t.map((t=>{const e=t.value;return[yh(e),e]}))),p={add:{nodes:f(i),edges:f(s),combos:f(c)},update:{nodes:f(o),edges:f(l),combos:f(h)},remove:{nodes:f(a),edges:f(u),combos:f(d)}},g=this.transformData(p,t);return e.clearChanges(),{dataChanges:n,drawData:g}}transformData(t,e){const n=this.context.transform.getTransformInstance();return Object.values(n).reduce(((t,n)=>n.beforeDraw(t,e)),t)}createElement(e,n,r){var i;const o=yh(n);if(this.getElement(o))return;const a=this.getElementType(e,n),s=this.getElementComputedStyle(e,n),l=Sc(e,a);if(!l)return Tc(`The element ${a} of ${e} is not registered.`);this.emit(new WH(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n),r);const u=this.container.appendChild(new l({id:o,context:this.context,style:s}));this.shapeTypeMap[o]=a,this.elementMap[o]=u;const{stage:c="enter"}=r;null===(i=this.context.animation)||void 0===i||i.add({element:u,elementType:e,stage:c,originalStyle:Object.assign({},u.attributes),updatedStyle:s},{after:()=>{var i;this.emit(new WH(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n),r),null===(i=u.onCreate)||void 0===i||i.call(u)}})}createElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach((([t,n])=>{n.forEach((n=>this.createElement(t,n,e)))}))}getUpdateStageStyle(t,e,n){const{stage:r="update"}=n;if("translate"===r){if("node"===t||"combo"===t){const{style:{x:t=0,y:n=0,z:r=0}={}}=e;return{x:t,y:n,z:r}}return{}}return this.getElementComputedStyle(t,e)}updateElement(e,n,r){var i;const o=yh(n),{stage:a="update"}=r,s=this.getElement(o);if(!s)return()=>null;this.emit(new WH(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n),r);const l=this.getElementType(e,n),u=this.getUpdateStageStyle(e,n,r);this.shapeTypeMap[o]!==l&&(s.destroy(),delete this.shapeTypeMap[o],delete this.elementMap[o],this.createElement(e,n,{animation:!1,silence:!0}));const c="visibility"!==a?a:"hidden"===u.visibility?"hide":"show";"hide"===c&&delete u.visibility,null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:c,originalStyle:Object.assign({},s.attributes),updatedStyle:u},{before:()=>{const t=this.elementMap[o];"collapse"!==a&&Dg(t,u),"visibility"===a&&(function(t,e){return qH(e)in(Oe(t,$H)||{})}(t,"opacity")||function(t,e){const n=Array.isArray(e)?e:[e];Oe(t,$H)||Te(t,$H,{}),n.forEach((e=>{Te(Oe(t,$H),qH(e),t.attributes[e])}))}(t,"opacity"),this.visibilityCache.set(t,"show"===c?"visible":"hidden"),"show"===c&&Ch(t,"visible"))},after:()=>{var i;const s=this.elementMap[o];"collapse"===a&&Dg(s,u),"hide"===c&&Ch(s,this.visibilityCache.get(s)),this.emit(new WH(t.GraphEvent.AFTER_ELEMENT_UPDATE,e,n),r),null===(i=s.onUpdate)||void 0===i||i.call(s)}})}updateElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach((([t,n])=>{n.forEach((n=>this.updateElement(t,n,e)))}))}markDestroyElement(t){Object.values(t.remove).forEach((t=>{t.forEach((t=>{const e=yh(t),n=this.getElement(e);n&&function(t){Te(t,"__to_be_destroyed__",!0)}(n)}))}))}destroyElement(e,n,r){var i;const{stage:o="exit"}=r,a=yh(n),s=this.elementMap[a];if(!s)return()=>null;this.emit(new WH(t.GraphEvent.BEFORE_ELEMENT_DESTROY,e,n),r),null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:o,originalStyle:Object.assign({},s.attributes),updatedStyle:{}},{after:()=>{var i;this.clearElement(a),s.destroy(),null===(i=s.onDestroy)||void 0===i||i.call(s),this.emit(new WH(t.GraphEvent.AFTER_ELEMENT_DESTROY,e,n),r)}})}destroyElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["combo",i],["edge",r],["node",n]].forEach((([t,n])=>{n.forEach((n=>this.destroyElement(t,n,e)))}))}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}alignLayoutResultToElement(t,e){var n,r;const i=null===(n=t.nodes)||void 0===n?void 0:n.find((t=>yh(t)===e));if(i){const n=jh(Qh(this.context.model.getNodeLikeDatum(e)),Qh(i));null===(r=t.nodes)||void 0===r||r.forEach((t=>{var e,r,i;(null===(e=t.style)||void 0===e?void 0:e.x)&&(t.style.x+=n[0]),(null===(r=t.style)||void 0===r?void 0:r.y)&&(t.style.y+=n[1]),(null===(i=t.style)||void 0===i?void 0:i.z)&&(t.style.z+=n[2]||0)}))}}collapseNode(e,n){return ze(this,void 0,void 0,(function*(){var r;const{animation:i,align:o}=n,{model:a,layout:s}=this.context,l=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!l)return;this.markDestroyElement(l.drawData);const u=yield s.simulate();o&&this.alignLayoutResultToElement(u,e),a.updateData(u);const c=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!c)return;const{drawData:h}=c,{add:d,remove:f,update:p}=h;this.markDestroyElement(h);const g={animation:i,stage:"collapse",data:h};this.destroyElements(f,g),this.createElements(d,g),this.updateElements(p,g),yield null===(r=this.context.animation.animate(i,{beforeAnimate:e=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.COLLAPSE,e,h),g),afterAnimate:e=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.COLLAPSE,e,h),g)},{collapse:{target:e,descendants:Array.from(f.nodes).map((([,t])=>yh(t))),position:Qh(p.nodes.get(e))}}))||void 0===r?void 0:r.finished}))}expandNode(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i,layout:o}=this.context,{animation:a,align:s}=n,l=Qh(i.getNodeData([e])[0]),u=this.computeChangesAndDrawData({stage:"expand",animation:a});if(!u)return;const{drawData:{add:c}}=u;this.createElements(c,{animation:!1,stage:"expand",target:e}),this.context.animation.clear();const h=yield o.simulate();s&&this.alignLayoutResultToElement(h,e),i.updateData(h),this.computeStyle("expand");const d=this.computeChangesAndDrawData({stage:"collapse",animation:a});if(!d)return;const{drawData:f}=d,{update:p}=f,g={animation:a,stage:"expand",data:f};c.edges.forEach((t=>p.edges.set(yh(t),t))),c.nodes.forEach((t=>p.nodes.set(yh(t),t))),this.updateElements(p,g),yield null===(r=this.context.animation.animate(a,{beforeAnimate:e=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.EXPAND,e,f),g),afterAnimate:e=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.EXPAND,e,f),g)},{expand:{target:e,descendants:Array.from(c.nodes).map((([,t])=>yh(t))),position:l}}))||void 0===r?void 0:r.finished}))}collapseCombo(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i,element:o}=this.context;if(i.getAncestorsData(e,Ec).some((t=>Sd(t))))return;const a=o.getElement(e),s=a.getComboPosition(Object.assign(Object.assign({},a.attributes),{collapsed:!0})),l=this.computeChangesAndDrawData({stage:"collapse",animation:n});if(!l)return;const{dataChanges:u,drawData:c}=l;this.markDestroyElement(c);const{update:h,remove:d}=c,f={animation:n,stage:"collapse",data:c};this.destroyElements(d,f),this.updateElements(h,f);const p=t=>Array.from(t).map((([,t])=>yh(t)));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new GH(t.GraphEvent.BEFORE_DRAW,{dataChanges:u,animation:n}),f),beforeAnimate:e=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.COLLAPSE,e,c),f),afterAnimate:e=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.COLLAPSE,e,c),f),after:()=>this.emit(new GH(t.GraphEvent.AFTER_DRAW,{dataChanges:u,animation:n}),f)},{collapse:{target:e,descendants:[...p(d.nodes),...p(d.combos)],position:s}}))||void 0===r?void 0:r.finished}))}expandCombo(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i}=this.context,o=Qh(i.getComboData([e])[0]);this.computeStyle("expand");const a=this.computeChangesAndDrawData({stage:"expand",animation:n});if(!a)return;const{dataChanges:s,drawData:l}=a,{add:u,update:c}=l,h={animation:n,stage:"expand",data:l,target:e};this.createElements(u,h),this.updateElements(c,h);const d=t=>Array.from(t).map((([,t])=>yh(t)));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new GH(t.GraphEvent.BEFORE_DRAW,{dataChanges:s,animation:n}),h),beforeAnimate:e=>this.emit(new VH(t.GraphEvent.BEFORE_ANIMATE,fc.EXPAND,e,l),h),afterAnimate:e=>this.emit(new VH(t.GraphEvent.AFTER_ANIMATE,fc.EXPAND,e,l),h),after:()=>this.emit(new GH(t.GraphEvent.AFTER_DRAW,{dataChanges:s,animation:n}),h)},{expand:{target:e,descendants:[...d(u.nodes),...d(u.combos)],position:o}}))||void 0===r?void 0:r.finished}))}clear(){this.container.children.forEach((t=>t.destroy())),this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={}}destroy(){this.clear(),this.container.destroy(),this.context={}}}class aY{get presetOptions(){return{animation:!!Dc(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.instances=[],this.context=t}getLayoutInstance(){return this.instances}preLayout(e){return ze(this,void 0,void 0,(function*(){var n,r,i,o;const{graph:a,model:s}=this.context,{add:l}=e;YH(a,new GH(t.GraphEvent.BEFORE_LAYOUT,{type:"pre"}));const u=yield null===(n=this.context.layout)||void 0===n?void 0:n.simulate();null===(r=null==u?void 0:u.nodes)||void 0===r||r.forEach((t=>{const e=yh(t),n=l.nodes.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)})),null===(i=null==u?void 0:u.edges)||void 0===i||i.forEach((t=>{const e=yh(t),n=l.edges.get(e);s.syncEdgeDatum(t),n&&Object.assign(n.style,t.style)})),null===(o=null==u?void 0:u.combos)||void 0===o||o.forEach((t=>{const e=yh(t),n=l.combos.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)})),YH(a,new GH(t.GraphEvent.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",e)}))}postLayout(){return ze(this,void 0,void 0,(function*(){if(!this.options)return;const e=Array.isArray(this.options)?this.options:[this.options],{graph:n}=this.context;YH(n,new GH(t.GraphEvent.BEFORE_LAYOUT,{type:"post"}));for(const r of e){const i=e.indexOf(r),o=this.getLayoutData(r),a=Object.assign(Object.assign({},this.presetOptions),r);YH(n,new GH(t.GraphEvent.BEFORE_STAGE_LAYOUT,{options:a,index:i}));const s=yield this.stepLayout(o,a,i);YH(n,new GH(t.GraphEvent.AFTER_STAGE_LAYOUT,{options:a,index:i})),r.animation||this.updateElementPosition(s,!1)}YH(n,new GH(t.GraphEvent.AFTER_LAYOUT,{type:"post"})),this.transformDataAfterLayout("post")}))}transformDataAfterLayout(t,e){const n=this.context.transform.getTransformInstance();Object.values(n).forEach((n=>n.afterLayout(t,e)))}simulate(){return ze(this,void 0,void 0,(function*(){if(!this.options)return{};const t=Array.isArray(this.options)?this.options:[this.options];let e={};for(const n of t){const r=t.indexOf(n),i=this.getLayoutData(n);e=yield this.stepLayout(i,Object.assign(Object.assign(Object.assign({},this.presetOptions),n),{animation:!1}),r)}return e}))}stepLayout(t,e,n){return ze(this,void 0,void 0,(function*(){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?yield this.treeLayout(t,e,n):yield this.graphLayout(t,e,n)}))}graphLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{animation:r,enableWorker:i,iterations:o=300}=e,a=this.initGraphLayout(e);if(!a)return{};if(this.instances[n]=a,this.instance=a,i){const e=a;return this.supervisor=new $j(e.graphData2LayoutModel(t),e.instance,{iterations:o}),$g(yield this.supervisor.execute())}if(Kx(a))return r?yield a.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(a.execute(t),a.stop(),a.tick(o));const s=yield a.execute(t);if(r){const t=this.updateElementPosition(s,r);yield null==t?void 0:t.finished}return s}))}treeLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{type:n,animation:r}=e,i=Sc("layout",n);if(!i)return{};const{nodes:o=[],edges:a=[]}=t,s=new Yg({nodes:o.map((t=>({id:yh(t),data:t.data||{}}))),edges:a.map((t=>({id:yh(t),source:t.source,target:t.target,data:t.data||{}})))});!function(t){if(t.hasTreeStructure(wc))return;t.attachTreeStructure(wc);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,wc)}}(s);const l={nodes:[],edges:[]},u={nodes:[],edges:[]};s.getRoots(wc).forEach((t=>{xd(t,(t=>{t.children=s.getSuccessors(t.id)}),(t=>s.getSuccessors(t.id)),"TB");const n=i(t,e),{x:r,y:o,z:a=0}=n;xd(n,(t=>{const{id:e,x:n,y:i,z:s=0}=t;l.nodes.push({id:e,style:{x:r,y:o,z:a}}),u.nodes.push({id:e,style:{x:n,y:i,z:s}})}),(t=>t.children),"TB")}));const c=this.inferTreeLayoutOffset(u);if(sY(u,c),r){sY(l,c),this.updateElementPosition(l,!1);const t=this.updateElementPosition(u,r);yield null==t?void 0:t.finished}return u}))}inferTreeLayoutOffset(t){var e;let[n,r]=[1/0,-1/0],[i,o]=[1/0,-1/0];null===(e=t.nodes)||void 0===e||e.forEach((t=>{const{x:e=0,y:a=0}=t.style||{};n=Math.min(n,e),r=Math.max(r,e),i=Math.min(i,a),o=Math.max(o,a)}));const{canvas:a}=this.context,s=a.getSize(),[l,u]=a.getCanvasByViewport([0,0]),[c,h]=a.getCanvasByViewport(s);if(n>=l&&r<=c&&i>=u&&o<=h)return[0,0];return[(l+c)/2-(n+r)/2,(u+h)/2-(i+o)/2]}stopLayout(){this.instance&&Kx(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)}getLayoutData(t){const{nodeFilter:e=()=>!0,preLayout:n=!1,isLayoutInvisibleNodes:r=!1}=t,{nodes:i,edges:o,combos:a}=this.context.model.getData(),{element:s,model:l}=this.context,u=t=>s.getElement(t),c=n?t=>{var n;if(!r){if("hidden"===(null===(n=t.style)||void 0===n?void 0:n.visibility))return!1;if(l.getAncestorsData(t.id,wc).some(Sd))return!1;if(l.getAncestorsData(t.id,Ec).some(Sd))return!1}return e(t)}:t=>{const n=yh(t),r=u(n);return!!r&&(!Lg(r)&&e(t))},h=i.filter(c),d=new Map(h.map((t=>[yh(t),t])));a.forEach((t=>d.set(yh(t),t)));return{nodes:h,edges:o.filter((({source:t,target:e})=>d.has(t)&&d.has(e))),combos:a}}initGraphLayout(t){var e;const{element:n,viewport:r}=this.context,{type:i,enableWorker:o,animation:a,iterations:s}=t,l=Fe(t,["type","enableWorker","animation","iterations"]),[u,c]=r.getCanvasSize(),h=[u/2,c/2],d=null!==(e=null==t?void 0:t.nodeSize)&&void 0!==e?e:t=>{const e=null==n?void 0:n.getElement(t.id);return e?e.attributes.size:null==n?void 0:n.getElementComputedStyle("node",t).size},f=Sc("layout",i);if(!f)return Tc(`The layout of ${i} is not registered.`);const p=Object.getPrototypeOf(f.prototype)===Ug.prototype?f:function(t,e){return class extends Ug{constructor(e,n){if(super(e,n),this.instance=new t({}),this.id=this.instance.id,"stop"in this.instance&&"tick"in this.instance){const t=this.instance;this.stop=t.stop.bind(t),this.tick=e=>$g(t.tick(e))}}execute(t,e){return ze(this,void 0,void 0,(function*(){return $g(yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(ke({},this.options,e))))}))}transformOptions(t){const{onTick:e}=t;return e?(t.onTick=t=>e($g(t)),t):t}graphData2LayoutModel(t){const{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.map((t=>{const e=yh(t),{data:n,style:r,combo:i}=t,o=Fe(t,["data","style","combo"]),a={id:e,data:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n),{data:n}),i?{parentId:i}:{}),{style:r}),o)};return(null==r?void 0:r.x)&&Object.assign(a.data,{x:r.x}),(null==r?void 0:r.y)&&Object.assign(a.data,{y:r.y}),(null==r?void 0:r.z)&&Object.assign(a.data,{z:r.z}),a})),a=new Map(o.map((t=>[t.id,t]))),s=r.filter((t=>{const{source:e,target:n}=t;return a.has(e)&&a.has(n)})).map((t=>{const{source:e,target:n,data:r,style:i}=t;return{id:yh(t),source:e,target:n,data:Object.assign({},r),style:Object.assign({},i)}})),l=i.map((t=>({id:yh(t),data:Object.assign({_isCombo:!0},t.data),style:Object.assign({},t.style)}))),u=new Yg({nodes:[...o,...l],edges:s});return e.model.model.hasTreeStructure(Ec)&&(u.attachTreeStructure(Ec),o.forEach((t=>{const n=e.model.model.getParent(t.id,Ec);n&&u.hasNode(n.id)&&u.setParent(t.id,n.id,Ec)}))),u}}}(f,this.context),g=new p(this.context),v={nodeSize:d,width:u,height:c,center:h};switch(g.id){case"d3-force":case"d3-force-3d":Object.assign(v,{center:{x:u/2,y:c/2,z:0}})}return ke(g.options,v,l),g}updateElementPosition(t,e){const{model:n,element:r}=this.context;return r?(n.updateData(t),r.draw({animation:e,silence:!0})):null}destroy(){var t;this.stopLayout(),this.context={},null===(t=this.supervisor)||void 0===t||t.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}const sY=(t,e)=>{var n;const[r,i]=e;null===(n=t.nodes)||void 0===n||n.forEach((t=>{if(t.style){const{x:e=0,y:n=0}=t.style;t.style.x=e+r,t.style.y=n+i}else t.style={x:r,y:i}}))};function lY(t){return t.layout?(Array.isArray(t.layout)||"preLayout"in t.layout||["antv-dagre","combo-combined","compact-box","circular","concentric","dagre","fishbone","grid","indented","mds","radial","random","snake","dendrogram","mindmap"].includes(t.layout.type)&&(t.layout.preLayout=!0),t):t}class uY extends Ph{constructor(t){super(t),this.category="plugin",this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){const e=this.extensionMap[t];if(e)return e;Tc(`Cannot find the plugin ${t}, will try to find it by type.`);const n=this.extensions.find((e=>e.type===t));return n?this.extensionMap[n.key]:void 0}}const cY=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class hY extends Ph{constructor(t){super(t),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(t){this.setExtensions([...cY.slice(0,cY.length-1),...t,cY[cY.length-1]])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}class dY{get padding(){return Yc(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.landmarkCounter=0,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(){const{canvas:t}=this.context;return new Proxy(t.getCamera(),{get:(e,n)=>{const r=Object.entries(t.getLayers()).filter((([t])=>!["main"].includes(t))),i=r.map((([,t])=>t.getCamera())),o=e[n];if("function"==typeof o)return(...t)=>{const r=o.apply(e,t);return i.forEach((e=>{e[n].apply(e,t)})),r}}})}createLandmark(t){return this.camera.createLandmark("landmark-"+this.landmarkCounter++,t)}getAnimation(t){const e=Dc(this.context.options,t);return!!e&&Ce(Object.assign({},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()}getTranslateOptions(t){const{camera:e}=this,{mode:n,translate:r=[]}=t,i=this.getZoom(),o=e.getPosition(),a=e.getFocalPoint(),[s,l]=this.getCanvasCenter(),[u=0,c=0,h=0]=r,d=Fh([-u,-c,-h],i);return"relative"===n?{position:Ih(o,d),focalPoint:Ih(a,d)}:{position:Ih([s,l,o[2]],d),focalPoint:Ih([s,l,a[2]],d)}}getRotateOptions(t){const{mode:e,rotate:n=0}=t;return{roll:"relative"===e?this.camera.getRoll()+n:n}}getZoomOptions(t){const{zoomRange:e}=this.context.options,n=this.camera.getZoom(),{mode:r,scale:i=1}=t;return oe("relative"===r?n*i:i,...e)}transform(e,n){return ze(this,void 0,void 0,(function*(){const{graph:r}=this.context,{translate:i,rotate:o,scale:a,origin:s}=e;this.cancelAnimation();const l=this.getAnimation(n);if(YH(r,new HH(t.GraphEvent.BEFORE_TRANSFORM,e)),!o&&a&&!i&&s&&!l)return this.camera.setZoomByViewportPoint(this.getZoomOptions(e),s),void YH(r,new HH(t.GraphEvent.AFTER_TRANSFORM,e));const u={};if(i&&Object.assign(u,this.getTranslateOptions(e)),ae(o)&&Object.assign(u,this.getRotateOptions(e)),ae(a)&&Object.assign(u,{zoom:this.getZoomOptions(e)}),l)return YH(r,new VH(t.GraphEvent.BEFORE_ANIMATE,fc.TRANSFORM,null,e)),new Promise((n=>{this.transformResolver=n,this.camera.gotoLandmark(this.createLandmark(u),Object.assign(Object.assign({},l),{onfinish:()=>{YH(r,new VH(t.GraphEvent.AFTER_ANIMATE,fc.TRANSFORM,null,e)),YH(r,new HH(t.GraphEvent.AFTER_TRANSFORM,e)),this.transformResolver=void 0,n()}}))}));this.camera.gotoLandmark(this.createLandmark(u),{duration:0}),YH(r,new HH(t.GraphEvent.AFTER_TRANSFORM,e))}))}fitView(t,e){return ze(this,void 0,void 0,(function*(){const[n,r,i,o]=this.padding,{when:a="always",direction:s="both"}=t||{},[l,u]=this.context.canvas.getSize(),c=l-o-r,h=u-n-i,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[p,g]=Xc(f);if("overflow"===a&&!("x"===s&&p>=c||"y"===s&&g>=h||"both"===s&&p>=c&&g>=h))return yield this.fitCenter({animation:e});const v=c/p,m=h/g,y="x"===s?v:"y"===s?m:Math.min(v,m),b=this.getAnimation(e);yield this.transform({mode:"relative",scale:y,translate:Ih(jh(this.getCanvasCenter(),this.getBBoxInViewport(d).center),Fh(this.paddingOffset,y))},b)}))}fitCenter(t){return ze(this,void 0,void 0,(function*(){const e=this.context.canvas.getBounds();yield this.focus(e,t)}))}focusElements(t){return ze(this,arguments,void 0,(function*(t,e={}){const{element:n}=this.context;if(!n)return;const r=Jc(t.map((t=>{return r=n.getElement(t),e.shapes?r.getShape(e.shapes).getRenderBounds():r.getRenderBounds();var r})));yield this.focus(r,e)}))}focus(t,e){return ze(this,void 0,void 0,(function*(){const n=this.context.graph.getViewportByCanvas(t.center),r=jh(e.position||this.getCanvasCenter(),n);yield this.transform({mode:"relative",translate:Ih(r,this.paddingOffset)},e.animation)}))}getBBoxInViewport(t){const{min:e,max:n}=t,{graph:r}=this.context,[i,o]=r.getViewportByCanvas(e),[a,s]=r.getViewportByCanvas(n),l=new Ur;return l.setMinMax([i,o,0],[a,s,0]),l}isInViewport(t,e=!1,n=0){const{graph:r}=this.context,i=this.getCanvasSize(),[o,a]=r.getCanvasByViewport([0,0]),[s,l]=r.getCanvasByViewport(i);let u=new Ur;return u.setMinMax([o,a,0],[s,l,0]),n&&(u=Qc(u,n)),Wc(t)?th(t,u):e?function(t,e){const[n,r]=t.min,[i,o]=t.max,[a,s]=e.min,[l,u]=e.max;return n>=a&&i<=l&&r>=s&&o<=u}(t,u):u.intersects(t)}cancelAnimation(){var t,e;(null===(t=this.camera.landmarks)||void 0===t?void 0:t.length)&&this.camera.cancelLandmarkAnimation(),null===(e=this.transformResolver)||void 0===e||e.call(this)}}class fY extends zg{constructor(t){var e;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new iY},this.isCollapsingExpanding=!1,this.onResize=ye((()=>{this.resize()}),300),this._setOptions(Object.assign({},fY.defaultOptions,t),!0),this.context.graph=this,this.options.autoResize&&(null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize))}getOptions(){return this.options}setOptions(t){this._setOptions(t,!1)}_setOptions(t,e){if(this.updateCanvas(t),Object.assign(this.options,function(t){return[lY].reduce(((t,e)=>e(t)),t)}(t)),e){const{data:e}=t;return void(e&&this.addData(e))}const{behaviors:n,combo:r,data:i,edge:o,layout:a,node:s,plugins:l,theme:u,transforms:c}=t;n&&this.setBehaviors(n),i&&this.setData(i),s&&this.setNode(s),o&&this.setEdge(o),r&&this.setCombo(r),a&&this.setLayout(a),u&&this.setTheme(u),l&&this.setPlugins(l),c&&this.setTransforms(c)}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){t&&(this.options.width=t),e&&(this.options.height=e),this.resize(t,e)}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t,this.context.model.refreshData()}setEdge(t){this.options.edge=t,this.context.model.refreshData()}setCombo(t){this.options.combo=t,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(t){this.options.theme=Yt(t)?t(this.getTheme()):t}setLayout(t){this.options.layout=Yt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){var e;this.options.behaviors=Yt(t)?t(this.getBehaviors()):t,null===(e=this.context.behavior)||void 0===e||e.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors((e=>e.map((e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){var e;this.options.plugins=Yt(t)?t(this.getPlugins()):t,null===(e=this.context.plugin)||void 0===e||e.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins((e=>e.map((e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))))}getPlugins(){return this.options.plugins||[]}getPluginInstance(t){return this.context.plugin.getPluginInstance(t)}setTransforms(t){var e;this.options.transforms=Yt(t)?t(this.getTransforms()):t,null===(e=this.context.transform)||void 0===e||e.setTransforms(this.options.transforms)}updateTransform(t){this.setTransforms((e=>e.map((e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e)))),this.context.model.refreshData()}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}getElementData(t){return Array.isArray(t)?t.map((t=>this.context.model.getElementDataById(t))):this.context.model.getElementDataById(t)}getNodeData(t){var e;return void 0===t?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):null===(e=this.context.model.getNodeData([t]))||void 0===e?void 0:e[0]}getEdgeData(t){var e;return void 0===t?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):null===(e=this.context.model.getEdgeData([t]))||void 0===e?void 0:e[0]}getComboData(t){var e;return void 0===t?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):null===(e=this.context.model.getComboData([t]))||void 0===e?void 0:e[0]}setData(t){this.context.model.setData(Yt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Yt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Yt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Yt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Yt(t)?t(this.getComboData()):t)}addChildrenData(t,e){this.context.model.addChildrenData(t,e)}updateData(t){this.context.model.updateData(Yt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Yt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Yt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Yt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Yt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Yt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Yt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Yt(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)}getDescendantsData(t){return this.context.model.getDescendantsData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}initCanvas(){return ze(this,void 0,void 0,(function*(){var e;if(this.context.canvas)return yield this.context.canvas.ready;const{container:n="container",width:r,height:i,renderer:o,cursor:a,background:s,canvas:l,devicePixelRatio:u=(null!==(e=globalThis.devicePixelRatio)&&void 0!==e?e:1)}=this.options;if(n instanceof _H)this.context.canvas=n,a&&n.setCursor(a),o&&n.setRenderer(o),yield n.ready;else{const e=ne(n)?document.getElementById(n):n,c=FH(e);this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:e,width:r,height:i});const h=Object.assign(Object.assign({},l),{container:e,width:r||c[0],height:i||c[1],background:s,renderer:o,cursor:a,devicePixelRatio:u}),d=new _H(h);this.context.canvas=d,yield d.ready,this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:d})}}))}updateCanvas(e){var n,r;const{renderer:i,cursor:o,height:a,width:s}=e,l=this.context.canvas;l&&(i&&(this.emit(t.GraphEvent.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),l.setRenderer(i),this.emit(t.GraphEvent.AFTER_RENDERER_CHANGE,{renderer:i})),o&&l.setCursor(o),(ae(s)||ae(a))&&this.setSize(null!==(n=null!=s?s:this.options.width)&&void 0!==n?n:0,null!==(r=null!=a?a:this.options.height)&&void 0!==r?r:0))}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new ZH(this.context)),this.context.plugin||(this.context.plugin=new uY(this.context)),this.context.viewport||(this.context.viewport=new dY(this.context)),this.context.transform||(this.context.transform=new hY(this.context)),this.context.element||(this.context.element=new oY(this.context)),this.context.animation||(this.context.animation=new KH(this.context)),this.context.layout||(this.context.layout=new aY(this.context)),this.context.behavior||(this.context.behavior=new QH(this.context))}prepare(){return ze(this,void 0,void 0,(function*(){if(yield Promise.resolve(),this.destroyed)throw new Error(Oc("The graph instance has been destroyed"));yield this.initCanvas(),this.initRuntime()}))}render(){return ze(this,void 0,void 0,(function*(){if(yield this.prepare(),YH(this,new GH(t.GraphEvent.BEFORE_RENDER)),this.options.layout)if(this.rendered||(e=this.options.layout,Array.isArray(e)||!(null==e?void 0:e.preLayout))){const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.context.layout.postLayout()]),yield this.autoFit()}else{const t=yield this.context.element.preLayoutDraw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}else{const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}var e;this.rendered=!0,YH(this,new GH(t.GraphEvent.AFTER_RENDER))}))}draw(){return ze(this,void 0,void 0,(function*(){var t;yield this.prepare(),yield null===(t=this.context.element.draw())||void 0===t?void 0:t.finished}))}layout(){return ze(this,void 0,void 0,(function*(){yield this.context.layout.postLayout()}))}stopLayout(){this.context.layout.stopLayout()}clear(){return ze(this,void 0,void 0,(function*(){const{model:t,element:e}=this.context;t.setData({}),t.clearChanges(),null==e||e.clear()}))}destroy(){var e;YH(this,new GH(t.GraphEvent.BEFORE_DESTROY));const{layout:n,animation:r,element:i,model:o,canvas:a,behavior:s,plugin:l}=this.context;null==l||l.destroy(),null==s||s.destroy(),null==n||n.destroy(),null==r||r.destroy(),null==i||i.destroy(),o.destroy(),null==a||a.destroy(),this.options={},this.context={},this.off(),null===(e=globalThis.removeEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize),this.destroyed=!0,YH(this,new GH(t.GraphEvent.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,n){var r;const i=FH(null===(r=this.context.canvas)||void 0===r?void 0:r.getContainer()),o=[e||i[0],n||i[1]];if(!this.context.canvas)return;const a=this.context.canvas.getSize();Ne(o,a)||(YH(this,new GH(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:o})),this.context.canvas.resize(...o),YH(this,new GH(t.GraphEvent.AFTER_SIZE_CHANGE,{size:o})))}fitView(t,e){return ze(this,void 0,void 0,(function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.fitView(t,e)}))}fitCenter(t){return ze(this,void 0,void 0,(function*(){var e;yield null===(e=this.context.viewport)||void 0===e?void 0:e.fitCenter({animation:t})}))}autoFit(){return ze(this,void 0,void 0,(function*(){const{autoFit:t}=this.context.options;if(t)if(ne(t))"view"===t?yield this.fitView():"center"===t&&(yield this.fitCenter());else{const{type:e,animation:n}=t;"view"===e?yield this.fitView(t.options,n):"center"===e&&(yield this.fitCenter(n))}}))}focusElement(t,e){return ze(this,void 0,void 0,(function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.focusElements(Array.isArray(t)?t:[t],{animation:e})}))}zoomBy(t,e,n){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)}))}zoomTo(t,e,n){return ze(this,void 0,void 0,(function*(){this.context.viewport.transform({mode:"absolute",scale:t,origin:n},e)}))}getZoom(){return this.context.viewport.getZoom()}rotateBy(t,e,n){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)}))}rotateTo(t,e,n){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"absolute",rotate:t,origin:n},e)}))}getRotation(){return this.context.viewport.getRotation()}translateBy(t,e){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",translate:t},e)}))}translateTo(t,e){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"absolute",translate:t},e)}))}getPosition(){return jh([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach((([t,e])=>this.context.model.translateNodeLikeBy(t,e))),yield null===(i=this.context.element.draw({animation:a,stage:"translate"}))||void 0===i?void 0:i.finished}))}translateElementTo(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach((([t,e])=>this.context.model.translateNodeLikeTo(t,e))),yield null===(i=this.context.element.draw({animation:a,stage:"translate"}))||void 0===i?void 0:i.finished}))}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return Pe(this.context.element.getElement(t).attributes,["context"])}setElementVisibility(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach((([t,e])=>{const n=this.getElementType(t);s[`${n}s`].push({id:t,style:{visibility:e}})}));const{model:l,element:u}=this.context;l.preventUpdateNodeLikeHierarchy((()=>{l.updateData(s)})),yield null===(i=u.draw({animation:a,stage:"visibility"}))||void 0===i?void 0:i.finished}))}showElement(t,e){return ze(this,void 0,void 0,(function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"visible"]))),e)}))}hideElement(t,e){return ze(this,void 0,void 0,(function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map((t=>[t,"hidden"]))),e)}))}getElementVisibility(t){var e,n;const r=this.context.element.getElement(t);return null!==(n=null===(e=null==r?void 0:r.style)||void 0===e?void 0:e.visibility)&&void 0!==n?n:"visible"}setElementZIndex(t,e){return ze(this,void 0,void 0,(function*(){var n;const r={nodes:[],edges:[],combos:[]},i=qt(t)?t:{[t]:e};Object.entries(i).forEach((([t,e])=>{const n=this.getElementType(t);r[`${n}s`].push({id:t,style:{zIndex:e}})}));const{model:o,element:a}=this.context;o.preventUpdateNodeLikeHierarchy((()=>o.updateData(r))),yield null===(n=a.draw({animation:!1,stage:"zIndex"}))||void 0===n?void 0:n.finished}))}frontElement(t){return ze(this,void 0,void 0,(function*(){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,Ec).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(yh(i))],a=e-UH(i);o.forEach((t=>{r[yh(t)]=this.getElementZIndex(yh(t))+a}));const{internal:s}=Qp(o.map(yh),(t=>n.getRelatedEdgesData(t)));s.forEach((t=>{const e=yh(t);r[e]=this.getElementZIndex(e)+a}))}else r[t]=e})),yield this.setElementZIndex(r)}))}getElementZIndex(t){return UH(this.context.model.getElementDataById(t))}setElementState(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach((([t,e])=>{const n=this.getElementType(t);var r;s[`${n}s`].push({id:t,states:(r=e,r?Array.isArray(r)?r:[r]:[])})})),this.updateData(s),yield null===(i=this.context.element.draw({animation:a,stage:"state"}))||void 0===i?void 0:i.finished}))}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}collapseElement(t){return ze(this,arguments,void 0,(function*(t,e=!0){const{model:n,element:r}=this.context;if(Sd(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!0});const i=n.getElementType(t);yield this.frontElement(t),this.isCollapsingExpanding=!0,this.setElementCollapsibility(t,!0),"node"===i?yield r.collapseNode(t,e):"combo"===i&&(yield r.collapseCombo(t,!!e.animation)),this.isCollapsingExpanding=!1}))}expandElement(t){return ze(this,arguments,void 0,(function*(t,e=!0){const{model:n,element:r}=this.context;if(!Sd(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!0});const i=n.getElementType(t);this.isCollapsingExpanding=!0,this.setElementCollapsibility(t,!1),"node"===i?yield r.expandNode(t,e):"combo"===i&&(yield r.expandCombo(t,!!e.animation)),this.isCollapsingExpanding=!1}))}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}}])}toDataURL(){return ze(this,arguments,void 0,(function*(t={}){return this.context.canvas.toDataURL(t)}))}getCanvasByViewport(t){return this.context.canvas.getCanvasByViewport(t)}getViewportByCanvas(t){return this.context.canvas.getViewportByCanvas(t)}getClientByCanvas(t){return this.context.canvas.getClientByCanvas(t)}getCanvasByClient(t){return this.context.canvas.getCanvasByClient(t)}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}on(t,e,n){return super.on(t,e,n)}once(t,e){return super.once(t,e)}off(t,e){return super.off(t,e)}}fY.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};const pY=(t,e)=>{const{source:n,target:r}=e,i=t.getElementDataById(n),o=t.getElementDataById(r),a=Jp(i,(e=>t.getParentData(e,Ec))),s=Jp(o,(e=>t.getParentData(e,Ec))),l={sourceNode:yh(a),targetNode:yh(s)};return e.style?Object.assign(e.style,l):e.style=l,e};class gY extends MH{constructor(t,e){super(t,ke({},gY.defaultOptions,e)),this.assignSizeByCentrality=(t,e,n,r,i,o)=>{const a=[e,n],s=[r[0],i[0]],l=[r[1],i[1]],u=[r[2],i[2]],c=(t,e)=>{if("function"==typeof o)return o(t,a,e);switch(o){case"linear":return((t,e,n)=>{const[r,i]=e,[o,a]=n;return i===r?o:o+(t-r)/(i-r)*(a-o)})(t,a,e);case"log":return((t,e,n)=>{const[r,i]=e,[o,a]=n;return o+Math.log(t-r+1)/Math.log(i-r+1)*(a-o)})(t,a,e);case"pow":return((t,e,n,r=2)=>{const[i,o]=e,[a,s]=n;return a+Math.pow((t-i)/(o-i),r)*(s-a)})(t,a,e,2);case"sqrt":return((t,e,n)=>{const[r,i]=e,[o,a]=n;return o+Math.sqrt((t-r)/(i-r))*(a-o)})(t,a,e);default:return e[0]}};return[c(t,s),c(t,l),c(t,u)]}}beforeDraw(t){const{model:e}=this.context,n=e.getNodeData(),r=Pd(this.options.maxSize),i=Pd(this.options.minSize),o=this.getCentralities(this.options.centrality),a=o.size>0?Math.max(...o.values()):0,s=o.size>0?Math.min(...o.values()):0;return n.forEach((e=>{var n;const l=this.assignSizeByCentrality(o.get(yh(e))||0,s,a,i,r,this.options.scale),u=null===(n=this.context.element)||void 0===n?void 0:n.getElement(yh(e)),c={size:l};this.assignLabelStyle(c,l,e,u),u&&NH(c,u.attributes)||SH(t,u?"update":"add","node",ke(e,{style:c}),!0)})),t}assignLabelStyle(t,e,n,r){var i;const o=r?r.config.style:null===(i=this.context.element)||void 0===i?void 0:i.getElementComputedStyle("node",n);if(Object.assign(t,Ce(o,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const n=this.getLabelSizeByNodeSize(e,1/0,Number(t.labelFontSize));Object.assign(t,{labelFontSize:n,labelLineHeight:n+Uc(t.labelPadding)})}return t}getLabelSizeByNodeSize(t,e,n){const r=Math.min(...t)/2,[i,o]=Array.isArray(this.options.mapLabelSize)?this.options.mapLabelSize:[n,e];return Math.min(o,Math.max(r,i))}getCentralities(t){const{model:e}=this.context,n=e.getData();if("function"==typeof t)return t(n);const r=e.getRelatedEdgesData.bind(e);return Eh(n,r,t)}}gY.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};class vY extends MH{constructor(t,e){super(t,Object.assign({},vY.defaultOptions,e))}get ref(){return this.context.model.getRootsData()[0]}afterLayout(){var t;const e=Qh(this.ref),{graph:n,model:r}=this.context;null===(t=r.getData().nodes)||void 0===t||t.forEach((t=>{var i;if(yh(t)===yh(this.ref))return;const o=qh(jh(Qh(t),e)),a=Math.abs(o)>Math.PI/2,s=!t.children||0===t.children.length,l=yh(t),u=null===(i=this.context.element)||void 0===i?void 0:i.getElement(l);if(!u||!u.isVisible())return;const c=(s?1:-1)*(Pd(n.getElementRenderStyle(l).size)[0]/2+this.options.offset),h=[["translate",c*Math.cos(o),c*Math.sin(o)],["rotate",a?ai(o)+180:ai(o)]];r.updateNodeData([{id:yh(t),style:{labelTextAlign:a===s?"right":"left",labelTextBaseline:"middle",labelTransform:h}}])})),n.draw()}}vY.defaultOptions={offset:5};const mY=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class yY extends MH{constructor(t,e){super(t,Object.assign({},yY.defaultOptions,e)),this.cacheMergeStyle=new Map,this.getAffectedParallelEdges=t=>{const{add:{edges:e},update:{nodes:n,edges:r,combos:i},remove:{edges:o}}=t,{model:a}=this.context,s=new Map,l=(t,e)=>{a.getRelatedEdgesData(e).forEach((t=>!s.has(yh(t))&&s.set(yh(t),t)))};n.forEach(l),i.forEach(l);const u=t=>{const e=a.getEdgeData().map((t=>pY(a,t)));xY(t,e).forEach((t=>!s.has(yh(t))&&s.set(yh(t),t)))};if(o.size&&o.forEach(u),e.size&&e.forEach(u),r.size){const t=iF(rF(a.getChanges())).update.edges;r.forEach((e=>{var n;u(e);const r=null===(n=t.find((t=>yh(t.value)===yh(e))))||void 0===n?void 0:n.original;r&&!EY(e,r)&&u(r)}))}Se(this.options.edges)||s.forEach(((t,e)=>!this.options.edges.includes(e)&&s.delete(e)));const c=a.getEdgeData().map(yh);return new Map([...s].sort(((t,e)=>c.indexOf(t[0])-c.indexOf(e[0]))))},this.applyBundlingStyle=(t,e,n)=>{const{edgeMap:r,reverses:i}=bY(e);r.forEach((e=>{e.forEach(((e,r,o)=>{var a;const s=o.length,l=e.style||{};if(e.source===e.target){const t=mY.length;l.loopPlacement=mY[r%t],l.loopDist=Math.floor(r/t)*n+50}else if(1===s)l.curveOffset=0;else{const t=(r%2==0?1:-1)*(i[`${e.source}|${e.target}|${r}`]?-1:1);l.curveOffset=s%2==1?t*Math.ceil(r/2)*n*2:t*(Math.floor(r/2)*n*2+n)}const u=Object.assign(e,{type:"quadratic",style:l}),c=null===(a=this.context.element)||void 0===a?void 0:a.getElement(yh(e));c&&NH(u.style,c.attributes)||SH(t,c?"update":"add","edge",u,!0)}))}))},this.resetEdgeStyle=t=>{const e=t.style||{},n=this.cacheMergeStyle.get(yh(t))||{};return Object.keys(n).forEach((r=>{Ne(e[r],n[r])&&(t[r]?e[r]=t[r]:delete e[r])})),Object.assign(t,{style:e})},this.applyMergingStyle=(t,e)=>{const{edgeMap:n,reverses:r}=bY(e);n.forEach((e=>{var n;if(1===e.length){const r=e[0],i=null===(n=this.context.element)||void 0===n?void 0:n.getElement(yh(r)),o=this.resetEdgeStyle(r);return void(i&&NH(o,i.attributes)||SH(t,i?"update":"add","edge",o))}const i=e.map((({source:t,target:e,style:n={}},i)=>{const{startArrow:o,endArrow:a}=n,s={},[l,u]=r[`${t}|${e}|${i}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return pe(o)&&(s[l]=o),pe(a)&&(s[u]=a),s})).reduce(((t,e)=>Object.assign(Object.assign({},t),e)),{});e.forEach(((e,n,r)=>{var o;if(0!==n)return void SH(t,"remove","edge",e);const a=Object.assign({},Yt(this.options.style)?this.options.style(r):this.options.style,{childrenData:r});this.cacheMergeStyle.set(yh(e),a);const s=Object.assign(Object.assign({},e),{type:"line",style:Object.assign(Object.assign(Object.assign({},e.style),i),a)}),l=null===(o=this.context.element)||void 0===o?void 0:o.getElement(yh(e));l&&NH(s.style,l.attributes)||SH(t,l?"update":"add","edge",s,!0)}))}))}}beforeDraw(t){const e=this.getAffectedParallelEdges(t);return 0===e.size||("bundle"===this.options.mode?this.applyBundlingStyle(t,e,this.options.distance):this.applyMergingStyle(t,e)),t}}yY.defaultOptions={mode:"bundle",distance:15};const bY=t=>{const e=new Map,n=new Set,r={};for(const[i,o]of t){if(n.has(i))continue;const{source:a,target:s}=o,l=`${a}-${s}`;e.has(l)||e.set(l,[]),e.get(l).push(o),n.add(i);for(const[i,u]of t)n.has(i)||EY(o,u)&&(e.get(l).push(u),n.add(i),a===u.target&&s===u.source&&(r[`${u.source}|${u.target}|${e.get(l).length-1}`]=!0))}return{edgeMap:e,reverses:r}},xY=(t,e,n)=>e.filter((e=>EY(e,t))),EY=(t,e)=>{const{sourceNode:n,targetNode:r}=t.style||{},{sourceNode:i,targetNode:o}=e.style||{};return n===i&&r===o||n===o&&r===i};const wY={animation:{"combo-collapse":Gc,"combo-expand":Vc,"node-collapse":jc,"node-expand":Bc,"path-in":Fc,"path-out":zc,fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}]},behavior:{"brush-select":vd,"click-select":Md,"collapse-expand":_g,"create-edge":jg,"drag-canvas":Bg,"drag-element-force":Kg,"drag-element":Fg,"fix-element-size":Zg,"focus-element":Qg,"hover-activate":Jg,"lasso-select":tv,"auto-adapt-label":Lh,"optimize-viewport-transform":ev,"scroll-canvas":nv,"zoom-canvas":rv},combo:{circle:Cp,rect:Pp},edge:{cubic:rg,line:sg,polyline:yg,quadratic:bg,"cubic-horizontal":ig,"cubic-radial":og,"cubic-vertical":ag},layout:{"antv-dagre":gb,"combo-combined":Jx,"compact-box":hm.compactBox,"d3-force":GE,"force-atlas2":ij,circular:bb,concentric:kb,dagre:JI,dendrogram:hm.dendrogram,fishbone:qj,force:Ub,fruchterman:aj,grid:lj,indented:hm.indented,mds:$x,mindmap:hm.mindmap,radial:bj,random:Nj,snake:Qj},node:{circle:ef,diamond:rf,ellipse:lf,hexagon:uf,html:Mp,image:Sp,rect:Np,star:Op,donut:of,triangle:Tp},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)"],tableau:["rgb(78, 121, 167)","rgb(242, 142, 44)","rgb(225, 87, 89)","rgb(118, 183, 178)","rgb(89, 161, 79)","rgb(237, 201, 73)","rgb(175, 122, 161)","rgb(255, 157, 167)","rgb(156, 117, 95)","rgb(186, 176, 171)"],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:wH,light:kH},plugin:{"bubble-sets":FB,"edge-bundling":WB,"edge-filter-lens":QB,"grid-line":nF,background:nB,contextmenu:VB,fisheye:tF,fullscreen:eF,history:sF,hull:RF,legend:tH,minimap:eH,snapline:oH,timebar:uH,toolbar:fH,tooltip:pH,watermark:mH},transform:{"arrange-draw-order":class extends MH{beforeDraw(t){const{model:e}=this.context,n=t.add.combos,r=t=>{const n=[];return t.forEach(((t,r)=>{const i=e.getAncestorsData(r,"combo").map((t=>yh(t))).reverse();n.push([r,t,i.length])})),new Map(n.sort((([,,t],[,,e])=>e-t)).map((([t,e])=>[t,e])))};return t.add.combos=r(n),t.update.combos=r(t.update.combos),t}},"collapse-expand-combo":class extends MH{beforeDraw(t,e){if("visibility"===e.stage)return t;if(!this.context.model.model.hasTreeStructure(Ec))return t;const{model:n}=this.context,{add:r,update:i}=t,o=[...t.update.combos.entries(),...t.add.combos.entries()];for(;o.length;){const[e,a]=o.pop();if(Sd(a)){const a=n.getDescendantsData(e),s=a.map(yh),{internal:l,external:u}=Qp(s,(t=>n.getRelatedEdgesData(t)));a.forEach((e=>{const r=yh(e),i=o.findIndex((([t])=>t===r));-1!==i&&o.splice(i,1);const a=n.getElementType(r);SH(t,"remove",a,e)})),l.forEach((e=>SH(t,"remove","edge",e))),u.forEach((t=>{var e;const n=yh(t);(null===(e=this.context.element)||void 0===e?void 0:e.getElement(n))?i.edges.set(n,t):r.edges.set(n,t)}))}else{const r=n.getChildrenData(e),i=r.map(yh),{edges:a}=Qp(i,(t=>n.getRelatedEdgesData(t)));[...r,...a].forEach((e=>{var r;const i=yh(e),a=n.getElementType(i),s=null===(r=this.context.element)||void 0===r?void 0:r.getElement(i);SH(t,s?"update":"add",a,e),"combo"===a&&o.push([i,e])}))}}return t}},"collapse-expand-node":class extends MH{getElement(t){return this.context.element.getElement(t)}handleExpand(t,e){if(OH(e,"add","node",t),Sd(t))return;const n=yh(t);OH(e,"add","node",t);this.context.model.getRelatedEdgesData(n,"out").forEach((t=>{SH(e,"add","edge",t)}));this.context.model.getChildrenData(n).forEach((t=>{this.handleExpand(t,e)}))}beforeDraw(t){const{graph:e,model:n}=this.context;if(!n.model.hasTreeStructure(wc))return t;const{add:{nodes:r,edges:i},update:{nodes:o}}=t,a=new Map,s=new Map;r.forEach(((t,e)=>{Sd(t)&&a.set(e,t)})),i.forEach((t=>{if("node"!==e.getElementType(t.source))return;const n=e.getNodeData(t.source);Sd(n)&&a.set(t.source,n)})),o.forEach(((t,e)=>{const n=this.getElement(e);if(!n)return;const r=n.attributes.collapsed;Sd(t)?r||a.set(e,t):r&&s.set(e,t)}));const l=new Set;return a.forEach(((e,r)=>{n.getDescendantsData(r).forEach((e=>{const r=yh(e);if(l.has(r))return;SH(t,"remove","node",e);n.getRelatedEdgesData(r).forEach((e=>{SH(t,"remove","edge",e)})),l.add(r)}))})),s.forEach(((e,r)=>{n.getAncestorsData(r,wc).some(Sd)?SH(t,"remove","node",e):this.handleExpand(e,t)})),t}},"get-edge-actual-ends":class extends MH{beforeDraw(t){const{add:e,update:n}=t,{model:r}=this.context;return[...e.edges.entries(),...n.edges.entries()].forEach((([,t])=>{pY(r,t)})),t}},"map-node-size":gY,"place-radial-labels":vY,"process-parallel-edges":yY,"update-related-edges":class extends MH{beforeDraw(t,e){const{stage:n}=e;if("visibility"===n)return t;const{model:r}=this.context,{update:{nodes:i,edges:o,combos:a}}=t,s=(t,e)=>{r.getRelatedEdgesData(e).forEach((t=>!o.has(yh(t))&&o.set(yh(t),t)))};return i.forEach(s),a.forEach(s),t}}},shape:{circle:Dl,ellipse:Il,group:jl,html:Fl,image:$d,line:Vl,path:Hl,polygon:Ul,polyline:ql,rect:Xl,text:Zl,label:Gd,badge:Vd}};Object.entries(wY).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{CH(t,e,n)}))}));t.AntVDagreLayout=gb,t.AutoAdaptLabel=Lh,t.Background=nB,t.Badge=Vd,t.BaseBehavior=Dh,t.BaseCombo=Ap,t.BaseEdge=ng,t.BaseLayout=Ug,t.BaseNode=tf,t.BasePlugin=Jj,t.BaseShape=Bd,t.BaseTransform=MH,t.BrushSelect=vd,t.BubbleSets=FB,t.CameraSetting=class extends Jj{constructor(t,e){super(t,e),this.setOptions=t=>{const e=(t,e)=>{switch(t){case"projectionMode":return"perspective"===e?1:0;case"cameraType":return{orbiting:0,exploring:1,tracking:2}[e];case"aspect":return"number"==typeof e?e:this.getCanvasAspect();default:return e}};Object.entries({cameraType:"setType",near:"setNear",far:"setFar",fov:"setFov",aspect:"setAspect",projectionMode:"setProjectionMode",distance:"setDistance",minDistance:"setMinDistance",maxDistance:"setMaxDistance",roll:"setRoll",elevation:"setElevation",azimuth:"setAzimuth"}).forEach((([n,r])=>{const i=t[n];if(void 0!==i){const t=e(n,i);this.context.canvas.getCamera()[r](t)}}))},this.bindEvents()}update(t){this.setOptions(t),super.update(t)}bindEvents(){this.context.graph.once(t.GraphEvent.BEFORE_DRAW,(()=>this.setOptions(this.options)))}getCanvasAspect(){const[t,e]=this.context.viewport.getCanvasSize();return t/e}},t.Canvas=_H,t.Circle=ef,t.CircleCombo=Cp,t.CircularLayout=bb,t.ClickSelect=Md,t.CollapseExpand=_g,t.ComboCombinedLayout=Jx,t.CompactBoxLayout=hm.compactBox,t.ConcentricLayout=kb,t.Contextmenu=VB,t.CreateEdge=jg,t.Cubic=rg,t.CubicHorizontal=ig,t.CubicRadial=og,t.CubicVertical=ag,t.D3ForceLayout=GE,t.DagreLayout=JI,t.DendrogramLayout=hm.dendrogram,t.Diamond=rf,t.Donut=of,t.DragCanvas=Bg,t.DragElement=Fg,t.DragElementForce=Kg,t.EdgeBundling=WB,t.EdgeFilterLens=QB,t.Ellipse=lf,t.FishboneLayout=qj,t.Fisheye=tF,t.FixElementSize=Zg,t.FocusElement=Qg,t.ForceAtlas2Layout=ij,t.ForceLayout=Ub,t.FruchtermanLayout=aj,t.Fullscreen=eF,t.Graph=fY,t.GridLayout=lj,t.GridLine=nF,t.HTML=Mp,t.Hexagon=uf,t.History=sF,t.HoverActivate=Jg,t.Hull=RF,t.Icon=Qd,t.Image=Sp,t.IndentedLayout=hm.indented,t.Label=Gd,t.LassoSelect=tv,t.Legend=tH,t.Line=sg,t.MDSLayout=$x,t.MapNodeSize=gY,t.MindmapLayout=hm.mindmap,t.Minimap=eH,t.OptimizeViewportTransform=ev,t.PlaceRadialLabels=vY,t.Polyline=yg,t.ProcessParallelEdges=yY,t.Quadratic=bg,t.RadialLayout=bj,t.RandomLayout=Nj,t.Rect=Np,t.RectCombo=Pp,t.ScrollCanvas=nv,t.Shortcut=gd,t.SnakeLayout=Qj,t.Snapline=oH,t.Star=Op,t.Timebar=uH,t.Toolbar=fH,t.Tooltip=pH,t.Triangle=Tp,t.Watermark=mH,t.ZoomCanvas=rv,t.effect=function(t,e,n){TH.has(t)||TH.set(t,{});const r=TH.get(t);if(!r[e])return r[e]=n,!0;const i=r[e];return!AH(i,n)&&(r[e]=n,!0)},t.getExtension=Sc,t.getExtensions=function(t){return Mc[t]},t.iconfont={css:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.css",js:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.js"},t.idOf=yh,t.invokeLayoutMethod=qg,t.isCollapsed=Sd,t.omitStyleProps=Cd,t.parseSize=Pd,t.positionOf=Qh,t.register=CH,t.setVisibility=Ch,t.subStyleProps=Td,t.treeToGraphData=function(t,e){const{getNodeData:n=(t,e)=>{if(t.depth=e,!t.children)return t;const{children:n}=t,r=Fe(t,["children"]);return Object.assign(Object.assign({},r),{children:n.map((t=>t.id))})},getEdgeData:r=(t,e)=>({source:t.id,target:e.id}),getChildren:i=t=>t.children||[]}=e||{},o=[],a=[];return xd(t,((t,e)=>{o.push(n(t,e));const s=i(t);for(const e of s)a.push(r(t,e))}),(t=>i(t)),"TB"),{nodes:o,edges:a}},t.version=Nc}));