Files
mrb-netbox-topology-views/netbox_topology_views/static/netbox_topology_views/js/app.js
T

105 lines
342 KiB
JavaScript

(()=>{var In=Object.create;var kt=Object.defineProperty,Pn=Object.defineProperties,Mn=Object.getOwnPropertyDescriptor,Dn=Object.getOwnPropertyDescriptors,Fn=Object.getOwnPropertyNames,Ui=Object.getOwnPropertySymbols,Nn=Object.getPrototypeOf,Yi=Object.prototype.hasOwnProperty,Bn=Object.prototype.propertyIsEnumerable;var Jt=(n,e,t)=>e in n?kt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,de=(n,e)=>{for(var t in e||(e={}))Yi.call(e,t)&&Jt(n,t,e[t]);if(Ui)for(var t of Ui(e))Bn.call(e,t)&&Jt(n,t,e[t]);return n},Be=(n,e)=>Pn(n,Dn(e)),An=n=>kt(n,"__esModule",{value:!0});var ei=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var zn=(n,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Fn(e))!Yi.call(n,i)&&i!=="default"&&kt(n,i,{get:()=>e[i],enumerable:!(t=Mn(e,i))||t.enumerable});return n},ti=n=>zn(An(kt(n!=null?In(Nn(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var $=(n,e,t)=>(Jt(n,typeof e!="symbol"?e+"":e,t),t);var Xi=(n,e,t)=>new Promise((i,s)=>{var o=d=>{try{a(t.next(d))}catch(h){s(h)}},r=d=>{try{a(t.throw(d))}catch(h){s(h)}},a=d=>d.done?i(d.value):Promise.resolve(d.value).then(o,r);a((t=t.apply(n,e)).next())});var si=ei((Va,ii)=>{typeof ii!="undefined"&&(ii.exports=ne);function ne(n){if(n)return Ln(n)}function Ln(n){for(var e in ne.prototype)n[e]=ne.prototype[e];return n}ne.prototype.on=ne.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};ne.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};ne.prototype.off=ne.prototype.removeListener=ne.prototype.removeAllListeners=ne.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,s=0;s<t.length;s++)if(i=t[s],i===e||i.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+n],this};ne.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(t){t=t.slice(0);for(var i=0,s=t.length;i<s;++i)t[i].apply(this,e)}return this};ne.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};ne.prototype.hasListeners=function(n){return!!this.listeners(n).length}});var io=ei(Ut=>{(function(n,e){if(typeof define=="function"&&define.amd)define("timsort",["exports"],e);else if(typeof Ut!="undefined")e(Ut);else{var t={exports:{}};e(t.exports),n.timsort=t.exports}})(Ut,function(n){"use strict";n.__esModule=!0,n.sort=C;function e(f,g){if(!(f instanceof g))throw new TypeError("Cannot call a class as a function")}var t=32,i=7,s=256,o=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function r(f){return f<1e5?f<100?f<10?0:1:f<1e4?f<1e3?2:3:4:f<1e7?f<1e6?5:6:f<1e9?f<1e8?7:8:9}function a(f,g){if(f===g)return 0;if(~~f===f&&~~g===g){if(f===0||g===0)return f<g?-1:1;if(f<0||g<0){if(g>=0)return-1;if(f>=0)return 1;f=-f,g=-g}var m=r(f),v=r(g),_=0;return m<v?(f*=o[v-m-1],g/=10,_=-1):m>v&&(g*=o[m-v-1],f/=10,_=1),f===g?_:f<g?-1:1}var E=String(f),T=String(g);return E===T?0:E<T?-1:1}function d(f){for(var g=0;f>=t;)g|=f&1,f>>=1;return f+g}function h(f,g,m,v){var _=g+1;if(_===m)return 1;if(v(f[_++],f[g])<0){for(;_<m&&v(f[_],f[_-1])<0;)_++;l(f,g,_)}else for(;_<m&&v(f[_],f[_-1])>=0;)_++;return _-g}function l(f,g,m){for(m--;g<m;){var v=f[g];f[g++]=f[m],f[m--]=v}}function c(f,g,m,v,_){for(v===g&&v++;v<m;v++){for(var E=f[v],T=g,x=v;T<x;){var w=T+x>>>1;_(E,f[w])<0?x=w:T=w+1}var k=v-T;switch(k){case 3:f[T+3]=f[T+2];case 2:f[T+2]=f[T+1];case 1:f[T+1]=f[T];break;default:for(;k>0;)f[T+k]=f[T+k-1],k--}f[T]=E}}function u(f,g,m,v,_,E){var T=0,x=0,w=1;if(E(f,g[m+_])>0){for(x=v-_;w<x&&E(f,g[m+_+w])>0;)T=w,w=(w<<1)+1,w<=0&&(w=x);w>x&&(w=x),T+=_,w+=_}else{for(x=_+1;w<x&&E(f,g[m+_-w])<=0;)T=w,w=(w<<1)+1,w<=0&&(w=x);w>x&&(w=x);var k=T;T=_-w,w=_-k}for(T++;T<w;){var N=T+(w-T>>>1);E(f,g[m+N])>0?T=N+1:w=N}return w}function p(f,g,m,v,_,E){var T=0,x=0,w=1;if(E(f,g[m+_])<0){for(x=_+1;w<x&&E(f,g[m+_-w])<0;)T=w,w=(w<<1)+1,w<=0&&(w=x);w>x&&(w=x);var k=T;T=_-w,w=_-k}else{for(x=v-_;w<x&&E(f,g[m+_+w])>=0;)T=w,w=(w<<1)+1,w<=0&&(w=x);w>x&&(w=x),T+=_,w+=_}for(T++;T<w;){var N=T+(w-T>>>1);E(f,g[m+N])<0?w=N:T=N+1}return w}var b=function(){function f(g,m){e(this,f),this.array=null,this.compare=null,this.minGallop=i,this.length=0,this.tmpStorageLength=s,this.stackLength=0,this.runStart=null,this.runLength=null,this.stackSize=0,this.array=g,this.compare=m,this.length=g.length,this.length<2*s&&(this.tmpStorageLength=this.length>>>1),this.tmp=new Array(this.tmpStorageLength),this.stackLength=this.length<120?5:this.length<1542?10:this.length<119151?19:40,this.runStart=new Array(this.stackLength),this.runLength=new Array(this.stackLength)}return f.prototype.pushRun=function(m,v){this.runStart[this.stackSize]=m,this.runLength[this.stackSize]=v,this.stackSize+=1},f.prototype.mergeRuns=function(){for(;this.stackSize>1;){var m=this.stackSize-2;if(m>=1&&this.runLength[m-1]<=this.runLength[m]+this.runLength[m+1]||m>=2&&this.runLength[m-2]<=this.runLength[m]+this.runLength[m-1])this.runLength[m-1]<this.runLength[m+1]&&m--;else if(this.runLength[m]>this.runLength[m+1])break;this.mergeAt(m)}},f.prototype.forceMergeRuns=function(){for(;this.stackSize>1;){var m=this.stackSize-2;m>0&&this.runLength[m-1]<this.runLength[m+1]&&m--,this.mergeAt(m)}},f.prototype.mergeAt=function(m){var v=this.compare,_=this.array,E=this.runStart[m],T=this.runLength[m],x=this.runStart[m+1],w=this.runLength[m+1];this.runLength[m]=T+w,m===this.stackSize-3&&(this.runStart[m+1]=this.runStart[m+2],this.runLength[m+1]=this.runLength[m+2]),this.stackSize--;var k=p(_[x],_,E,T,0,v);E+=k,T-=k,T!==0&&(w=u(_[E+T-1],_,x,w,w-1,v),w!==0&&(T<=w?this.mergeLow(E,T,x,w):this.mergeHigh(E,T,x,w)))},f.prototype.mergeLow=function(m,v,_,E){var T=this.compare,x=this.array,w=this.tmp,k=0;for(k=0;k<v;k++)w[k]=x[m+k];var N=0,W=_,L=m;if(x[L++]=x[W++],--E==0){for(k=0;k<v;k++)x[L+k]=w[N+k];return}if(v===1){for(k=0;k<E;k++)x[L+k]=x[W+k];x[L+E]=w[N];return}for(var R=this.minGallop;;){var B=0,F=0,D=!1;do if(T(x[W],w[N])<0){if(x[L++]=x[W++],F++,B=0,--E==0){D=!0;break}}else if(x[L++]=w[N++],B++,F=0,--v==1){D=!0;break}while((B|F)<R);if(D)break;do{if(B=p(x[W],w,N,v,0,T),B!==0){for(k=0;k<B;k++)x[L+k]=w[N+k];if(L+=B,N+=B,v-=B,v<=1){D=!0;break}}if(x[L++]=x[W++],--E==0){D=!0;break}if(F=u(w[N],x,W,E,0,T),F!==0){for(k=0;k<F;k++)x[L+k]=x[W+k];if(L+=F,W+=F,E-=F,E===0){D=!0;break}}if(x[L++]=w[N++],--v==1){D=!0;break}R--}while(B>=i||F>=i);if(D)break;R<0&&(R=0),R+=2}if(this.minGallop=R,R<1&&(this.minGallop=1),v===1){for(k=0;k<E;k++)x[L+k]=x[W+k];x[L+E]=w[N]}else{if(v===0)throw new Error("mergeLow preconditions were not respected");for(k=0;k<v;k++)x[L+k]=w[N+k]}},f.prototype.mergeHigh=function(m,v,_,E){var T=this.compare,x=this.array,w=this.tmp,k=0;for(k=0;k<E;k++)w[k]=x[_+k];var N=m+v-1,W=E-1,L=_+E-1,R=0,B=0;if(x[L--]=x[N--],--v==0){for(R=L-(E-1),k=0;k<E;k++)x[R+k]=w[k];return}if(E===1){for(L-=v,N-=v,B=L+1,R=N+1,k=v-1;k>=0;k--)x[B+k]=x[R+k];x[L]=w[W];return}for(var F=this.minGallop;;){var D=0,H=0,Y=!1;do if(T(w[W],x[N])<0){if(x[L--]=x[N--],D++,H=0,--v==0){Y=!0;break}}else if(x[L--]=w[W--],H++,D=0,--E==1){Y=!0;break}while((D|H)<F);if(Y)break;do{if(D=v-p(w[W],x,m,v,v-1,T),D!==0){for(L-=D,N-=D,v-=D,B=L+1,R=N+1,k=D-1;k>=0;k--)x[B+k]=x[R+k];if(v===0){Y=!0;break}}if(x[L--]=w[W--],--E==1){Y=!0;break}if(H=E-u(x[N],w,0,E,E-1,T),H!==0){for(L-=H,W-=H,E-=H,B=L+1,R=W+1,k=0;k<H;k++)x[B+k]=w[R+k];if(E<=1){Y=!0;break}}if(x[L--]=x[N--],--v==0){Y=!0;break}F--}while(D>=i||H>=i);if(Y)break;F<0&&(F=0),F+=2}if(this.minGallop=F,F<1&&(this.minGallop=1),E===1){for(L-=v,N-=v,B=L+1,R=N+1,k=v-1;k>=0;k--)x[B+k]=x[R+k];x[L]=w[W]}else{if(E===0)throw new Error("mergeHigh preconditions were not respected");for(R=L-(E-1),k=0;k<E;k++)x[R+k]=w[k]}},f}();function C(f,g,m,v){if(!Array.isArray(f))throw new TypeError("Can only sort arrays");g?typeof g!="function"&&(v=m,m=g,g=a):g=a,m||(m=0),v||(v=f.length);var _=v-m;if(!(_<2)){var E=0;if(_<t){E=h(f,m,v,g),c(f,m,v,m+E,g);return}var T=new b(f,g),x=d(_);do{if(E=h(f,m,v,g),E<x){var w=_;w>x&&(w=x),c(f,m,m+w,m+E,g),E=w}T.pushRun(m,E),T.mergeRuns(),_-=E,m+=E}while(_!==0);T.forceMergeRuns()}}})});var oo=ei((gd,so)=>{so.exports=io()});var Ps=ti(si());function fe(){return fe=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},fe.apply(this,arguments)}function he(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e}function St(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}var oi;typeof Object.assign!="function"?oi=function(e){if(e==null)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i<arguments.length;i++){var s=arguments[i];if(s!=null)for(var o in s)s.hasOwnProperty(o)&&(t[o]=s[o])}return t}:oi=Object.assign;var Ae=oi,Gi=["","webkit","Moz","MS","ms","o"],Rn=typeof document=="undefined"?{style:{}}:document.createElement("div"),Hn="function",Ze=Math.round,ze=Math.abs,ni=Date.now;function Ot(n,e){for(var t,i,s=e[0].toUpperCase()+e.slice(1),o=0;o<Gi.length;){if(t=Gi[o],i=t?t+s:e,i in n)return i;o++}}var ye;typeof window=="undefined"?ye={}:ye=window;var Ki=Ot(Rn.style,"touchAction"),Zi=Ki!==void 0;function jn(){if(!Zi)return!1;var n={},e=ye.CSS&&ye.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(t){return n[t]=e?ye.CSS.supports("touch-action",t):!0}),n}var Qi="compute",$i="auto",ri="manipulation",Le="none",nt="pan-x",rt="pan-y",It=jn(),Wn=/mobile|tablet|ip(ad|hone|od)|android/i,Ji="ontouchstart"in ye,Vn=Ot(ye,"PointerEvent")!==void 0,qn=Ji&&Wn.test(navigator.userAgent),at="touch",Un="pen",ai="mouse",Yn="kinect",Xn=25,ee=1,Re=2,K=4,se=8,Pt=1,dt=2,ht=4,lt=8,Qe=16,pe=dt|ht,He=lt|Qe,es=pe|He,ts=["x","y"],Mt=["clientX","clientY"];function be(n,e,t){var i;if(!!n)if(n.forEach)n.forEach(e,t);else if(n.length!==void 0)for(i=0;i<n.length;)e.call(t,n[i],i,n),i++;else for(i in n)n.hasOwnProperty(i)&&e.call(t,n[i],i,n)}function Dt(n,e){return typeof n===Hn?n.apply(e&&e[0]||void 0,e):n}function je(n,e){return n.indexOf(e)>-1}function Gn(n){if(je(n,Le))return Le;var e=je(n,nt),t=je(n,rt);return e&&t?Le:e||t?e?nt:rt:je(n,ri)?ri:$i}var is=function(){function n(t,i){this.manager=t,this.set(i)}var e=n.prototype;return e.set=function(i){i===Qi&&(i=this.compute()),Zi&&this.manager.element.style&&It[i]&&(this.manager.element.style[Ki]=i),this.actions=i.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var i=[];return be(this.manager.recognizers,function(s){Dt(s.options.enable,[s])&&(i=i.concat(s.getTouchAction()))}),Gn(i.join(" "))},e.preventDefaults=function(i){var s=i.srcEvent,o=i.offsetDirection;if(this.manager.session.prevented){s.preventDefault();return}var r=this.actions,a=je(r,Le)&&!It[Le],d=je(r,rt)&&!It[rt],h=je(r,nt)&&!It[nt];if(a){var l=i.pointers.length===1,c=i.distance<2,u=i.deltaTime<250;if(l&&c&&u)return}if(!(h&&d)&&(a||d&&o&pe||h&&o&He))return this.preventSrc(s)},e.preventSrc=function(i){this.manager.session.prevented=!0,i.preventDefault()},n}();function di(n,e){for(;n;){if(n===e)return!0;n=n.parentNode}return!1}function ss(n){var e=n.length;if(e===1)return{x:Ze(n[0].clientX),y:Ze(n[0].clientY)};for(var t=0,i=0,s=0;s<e;)t+=n[s].clientX,i+=n[s].clientY,s++;return{x:Ze(t/e),y:Ze(i/e)}}function os(n){for(var e=[],t=0;t<n.pointers.length;)e[t]={clientX:Ze(n.pointers[t].clientX),clientY:Ze(n.pointers[t].clientY)},t++;return{timeStamp:ni(),pointers:e,center:ss(e),deltaX:n.deltaX,deltaY:n.deltaY}}function Ft(n,e,t){t||(t=ts);var i=e[t[0]]-n[t[0]],s=e[t[1]]-n[t[1]];return Math.sqrt(i*i+s*s)}function hi(n,e,t){t||(t=ts);var i=e[t[0]]-n[t[0]],s=e[t[1]]-n[t[1]];return Math.atan2(s,i)*180/Math.PI}function ns(n,e){return n===e?Pt:ze(n)>=ze(e)?n<0?dt:ht:e<0?lt:Qe}function Kn(n,e){var t=e.center,i=n.offsetDelta||{},s=n.prevDelta||{},o=n.prevInput||{};(e.eventType===ee||o.eventType===K)&&(s=n.prevDelta={x:o.deltaX||0,y:o.deltaY||0},i=n.offsetDelta={x:t.x,y:t.y}),e.deltaX=s.x+(t.x-i.x),e.deltaY=s.y+(t.y-i.y)}function rs(n,e,t){return{x:e/n||0,y:t/n||0}}function Zn(n,e){return Ft(e[0],e[1],Mt)/Ft(n[0],n[1],Mt)}function Qn(n,e){return hi(e[1],e[0],Mt)+hi(n[1],n[0],Mt)}function $n(n,e){var t=n.lastInterval||e,i=e.timeStamp-t.timeStamp,s,o,r,a;if(e.eventType!==se&&(i>Xn||t.velocity===void 0)){var d=e.deltaX-t.deltaX,h=e.deltaY-t.deltaY,l=rs(i,d,h);o=l.x,r=l.y,s=ze(l.x)>ze(l.y)?l.x:l.y,a=ns(d,h),n.lastInterval=e}else s=t.velocity,o=t.velocityX,r=t.velocityY,a=t.direction;e.velocity=s,e.velocityX=o,e.velocityY=r,e.direction=a}function Jn(n,e){var t=n.session,i=e.pointers,s=i.length;t.firstInput||(t.firstInput=os(e)),s>1&&!t.firstMultiple?t.firstMultiple=os(e):s===1&&(t.firstMultiple=!1);var o=t.firstInput,r=t.firstMultiple,a=r?r.center:o.center,d=e.center=ss(i);e.timeStamp=ni(),e.deltaTime=e.timeStamp-o.timeStamp,e.angle=hi(a,d),e.distance=Ft(a,d),Kn(t,e),e.offsetDirection=ns(e.deltaX,e.deltaY);var h=rs(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=h.x,e.overallVelocityY=h.y,e.overallVelocity=ze(h.x)>ze(h.y)?h.x:h.y,e.scale=r?Zn(r.pointers,i):1,e.rotation=r?Qn(r.pointers,i):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length,$n(t,e);var l=n.element,c=e.srcEvent,u;c.composedPath?u=c.composedPath()[0]:c.path?u=c.path[0]:u=c.target,di(u,l)&&(l=u),e.target=l}function er(n,e,t){var i=t.pointers.length,s=t.changedPointers.length,o=e&ee&&i-s==0,r=e&(K|se)&&i-s==0;t.isFirst=!!o,t.isFinal=!!r,o&&(n.session={}),t.eventType=e,Jn(n,t),n.emit("hammer.input",t),n.recognize(t),n.session.prevInput=t}function ct(n){return n.trim().split(/\s+/g)}function ut(n,e,t){be(ct(e),function(i){n.addEventListener(i,t,!1)})}function ft(n,e,t){be(ct(e),function(i){n.removeEventListener(i,t,!1)})}function as(n){var e=n.ownerDocument||n;return e.defaultView||e.parentWindow||window}var $e=function(){function n(t,i){var s=this;this.manager=t,this.callback=i,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(o){Dt(t.options.enable,[t])&&s.handler(o)},this.init()}var e=n.prototype;return e.handler=function(){},e.init=function(){this.evEl&&ut(this.element,this.evEl,this.domHandler),this.evTarget&&ut(this.target,this.evTarget,this.domHandler),this.evWin&&ut(as(this.element),this.evWin,this.domHandler)},e.destroy=function(){this.evEl&&ft(this.element,this.evEl,this.domHandler),this.evTarget&&ft(this.target,this.evTarget,this.domHandler),this.evWin&&ft(as(this.element),this.evWin,this.domHandler)},n}();function We(n,e,t){if(n.indexOf&&!t)return n.indexOf(e);for(var i=0;i<n.length;){if(t&&n[i][t]==e||!t&&n[i]===e)return i;i++}return-1}var tr={pointerdown:ee,pointermove:Re,pointerup:K,pointercancel:se,pointerout:se},ir={2:at,3:Un,4:ai,5:Yn},ds="pointerdown",hs="pointermove pointerup pointercancel";ye.MSPointerEvent&&!ye.PointerEvent&&(ds="MSPointerDown",hs="MSPointerMove MSPointerUp MSPointerCancel");var ls=function(n){he(e,n);function e(){var i,s=e.prototype;return s.evEl=ds,s.evWin=hs,i=n.apply(this,arguments)||this,i.store=i.manager.session.pointerEvents=[],i}var t=e.prototype;return t.handler=function(s){var o=this.store,r=!1,a=s.type.toLowerCase().replace("ms",""),d=tr[a],h=ir[s.pointerType]||s.pointerType,l=h===at,c=We(o,s.pointerId,"pointerId");d&ee&&(s.button===0||l)?c<0&&(o.push(s),c=o.length-1):d&(K|se)&&(r=!0),!(c<0)&&(o[c]=s,this.callback(this.manager,d,{pointers:o,changedPointers:[s],pointerType:h,srcEvent:s}),r&&o.splice(c,1))},e}($e);function pt(n){return Array.prototype.slice.call(n,0)}function li(n,e,t){for(var i=[],s=[],o=0;o<n.length;){var r=e?n[o][e]:n[o];We(s,r)<0&&i.push(n[o]),s[o]=r,o++}return t&&(e?i=i.sort(function(a,d){return a[e]>d[e]}):i=i.sort()),i}var sr={touchstart:ee,touchmove:Re,touchend:K,touchcancel:se},or="touchstart touchmove touchend touchcancel",ci=function(n){he(e,n);function e(){var i;return e.prototype.evTarget=or,i=n.apply(this,arguments)||this,i.targetIds={},i}var t=e.prototype;return t.handler=function(s){var o=sr[s.type],r=nr.call(this,s,o);!r||this.callback(this.manager,o,{pointers:r[0],changedPointers:r[1],pointerType:at,srcEvent:s})},e}($e);function nr(n,e){var t=pt(n.touches),i=this.targetIds;if(e&(ee|Re)&&t.length===1)return i[t[0].identifier]=!0,[t,t];var s,o,r=pt(n.changedTouches),a=[],d=this.target;if(o=t.filter(function(h){return di(h.target,d)}),e===ee)for(s=0;s<o.length;)i[o[s].identifier]=!0,s++;for(s=0;s<r.length;)i[r[s].identifier]&&a.push(r[s]),e&(K|se)&&delete i[r[s].identifier],s++;if(!!a.length)return[li(o.concat(a),"identifier",!0),a]}var rr={mousedown:ee,mousemove:Re,mouseup:K},ar="mousedown",dr="mousemove mouseup",ui=function(n){he(e,n);function e(){var i,s=e.prototype;return s.evEl=ar,s.evWin=dr,i=n.apply(this,arguments)||this,i.pressed=!1,i}var t=e.prototype;return t.handler=function(s){var o=rr[s.type];o&ee&&s.button===0&&(this.pressed=!0),o&Re&&s.which!==1&&(o=K),!!this.pressed&&(o&K&&(this.pressed=!1),this.callback(this.manager,o,{pointers:[s],changedPointers:[s],pointerType:ai,srcEvent:s}))},e}($e),hr=2500,cs=25;function us(n){var e=n.changedPointers,t=e[0];if(t.identifier===this.primaryTouch){var i={x:t.clientX,y:t.clientY},s=this.lastTouches;this.lastTouches.push(i);var o=function(){var a=s.indexOf(i);a>-1&&s.splice(a,1)};setTimeout(o,hr)}}function lr(n,e){n&ee?(this.primaryTouch=e.changedPointers[0].identifier,us.call(this,e)):n&(K|se)&&us.call(this,e)}function cr(n){for(var e=n.srcEvent.clientX,t=n.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var s=this.lastTouches[i],o=Math.abs(e-s.x),r=Math.abs(t-s.y);if(o<=cs&&r<=cs)return!0}return!1}var fs=function(){var n=function(e){he(t,e);function t(s,o){var r;return r=e.call(this,s,o)||this,r.handler=function(a,d,h){var l=h.pointerType===at,c=h.pointerType===ai;if(!(c&&h.sourceCapabilities&&h.sourceCapabilities.firesTouchEvents)){if(l)lr.call(St(St(r)),d,h);else if(c&&cr.call(St(St(r)),h))return;r.callback(a,d,h)}},r.touch=new ci(r.manager,r.handler),r.mouse=new ui(r.manager,r.handler),r.primaryTouch=null,r.lastTouches=[],r}var i=t.prototype;return i.destroy=function(){this.touch.destroy(),this.mouse.destroy()},t}($e);return n}();function ur(n){var e,t=n.options.inputClass;return t?e=t:Vn?e=ls:qn?e=ci:Ji?e=fs:e=ui,new e(n,er)}function Je(n,e,t){return Array.isArray(n)?(be(n,t[e],t),!0):!1}var Nt=1,le=2,et=4,Oe=8,ve=Oe,gt=16,ge=32,fr=1;function pr(){return fr++}function Bt(n,e){var t=e.manager;return t?t.get(n):n}function ps(n){return n&gt?"cancel":n&Oe?"end":n&et?"move":n&le?"start":""}var mt=function(){function n(t){t===void 0&&(t={}),this.options=fe({enable:!0},t),this.id=pr(),this.manager=null,this.state=Nt,this.simultaneous={},this.requireFail=[]}var e=n.prototype;return e.set=function(i){return Ae(this.options,i),this.manager&&this.manager.touchAction.update(),this},e.recognizeWith=function(i){if(Je(i,"recognizeWith",this))return this;var s=this.simultaneous;return i=Bt(i,this),s[i.id]||(s[i.id]=i,i.recognizeWith(this)),this},e.dropRecognizeWith=function(i){return Je(i,"dropRecognizeWith",this)?this:(i=Bt(i,this),delete this.simultaneous[i.id],this)},e.requireFailure=function(i){if(Je(i,"requireFailure",this))return this;var s=this.requireFail;return i=Bt(i,this),We(s,i)===-1&&(s.push(i),i.requireFailure(this)),this},e.dropRequireFailure=function(i){if(Je(i,"dropRequireFailure",this))return this;i=Bt(i,this);var s=We(this.requireFail,i);return s>-1&&this.requireFail.splice(s,1),this},e.hasRequireFailures=function(){return this.requireFail.length>0},e.canRecognizeWith=function(i){return!!this.simultaneous[i.id]},e.emit=function(i){var s=this,o=this.state;function r(a){s.manager.emit(a,i)}o<Oe&&r(s.options.event+ps(o)),r(s.options.event),i.additionalEvent&&r(i.additionalEvent),o>=Oe&&r(s.options.event+ps(o))},e.tryEmit=function(i){if(this.canEmit())return this.emit(i);this.state=ge},e.canEmit=function(){for(var i=0;i<this.requireFail.length;){if(!(this.requireFail[i].state&(ge|Nt)))return!1;i++}return!0},e.recognize=function(i){var s=Ae({},i);if(!Dt(this.options.enable,[this,s])){this.reset(),this.state=ge;return}this.state&(ve|gt|ge)&&(this.state=Nt),this.state=this.process(s),this.state&(le|et|Oe|gt)&&this.tryEmit(s)},e.process=function(i){},e.getTouchAction=function(){},e.reset=function(){},n}(),fi=function(n){he(e,n);function e(i){var s;return i===void 0&&(i={}),s=n.call(this,fe({event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},i))||this,s.pTime=!1,s.pCenter=!1,s._timer=null,s._input=null,s.count=0,s}var t=e.prototype;return t.getTouchAction=function(){return[ri]},t.process=function(s){var o=this,r=this.options,a=s.pointers.length===r.pointers,d=s.distance<r.threshold,h=s.deltaTime<r.time;if(this.reset(),s.eventType&ee&&this.count===0)return this.failTimeout();if(d&&h&&a){if(s.eventType!==K)return this.failTimeout();var l=this.pTime?s.timeStamp-this.pTime<r.interval:!0,c=!this.pCenter||Ft(this.pCenter,s.center)<r.posThreshold;this.pTime=s.timeStamp,this.pCenter=s.center,!c||!l?this.count=1:this.count+=1,this._input=s;var u=this.count%r.taps;if(u===0)return this.hasRequireFailures()?(this._timer=setTimeout(function(){o.state=ve,o.tryEmit()},r.interval),le):ve}return ge},t.failTimeout=function(){var s=this;return this._timer=setTimeout(function(){s.state=ge},this.options.interval),ge},t.reset=function(){clearTimeout(this._timer)},t.emit=function(){this.state===ve&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))},e}(mt),tt=function(n){he(e,n);function e(i){return i===void 0&&(i={}),n.call(this,fe({pointers:1},i))||this}var t=e.prototype;return t.attrTest=function(s){var o=this.options.pointers;return o===0||s.pointers.length===o},t.process=function(s){var o=this.state,r=s.eventType,a=o&(le|et),d=this.attrTest(s);return a&&(r&se||!d)?o|gt:a||d?r&K?o|Oe:o&le?o|et:le:ge},e}(mt);function gs(n){return n===Qe?"down":n===lt?"up":n===dt?"left":n===ht?"right":""}var pi=function(n){he(e,n);function e(i){var s;return i===void 0&&(i={}),s=n.call(this,fe({event:"pan",threshold:10,pointers:1,direction:es},i))||this,s.pX=null,s.pY=null,s}var t=e.prototype;return t.getTouchAction=function(){var s=this.options.direction,o=[];return s&pe&&o.push(rt),s&He&&o.push(nt),o},t.directionTest=function(s){var o=this.options,r=!0,a=s.distance,d=s.direction,h=s.deltaX,l=s.deltaY;return d&o.direction||(o.direction&pe?(d=h===0?Pt:h<0?dt:ht,r=h!==this.pX,a=Math.abs(s.deltaX)):(d=l===0?Pt:l<0?lt:Qe,r=l!==this.pY,a=Math.abs(s.deltaY))),s.direction=d,r&&a>o.threshold&&d&o.direction},t.attrTest=function(s){return tt.prototype.attrTest.call(this,s)&&(this.state&le||!(this.state&le)&&this.directionTest(s))},t.emit=function(s){this.pX=s.deltaX,this.pY=s.deltaY;var o=gs(s.direction);o&&(s.additionalEvent=this.options.event+o),n.prototype.emit.call(this,s)},e}(tt),ms=function(n){he(e,n);function e(i){return i===void 0&&(i={}),n.call(this,fe({event:"swipe",threshold:10,velocity:.3,direction:pe|He,pointers:1},i))||this}var t=e.prototype;return t.getTouchAction=function(){return pi.prototype.getTouchAction.call(this)},t.attrTest=function(s){var o=this.options.direction,r;return o&(pe|He)?r=s.overallVelocity:o&pe?r=s.overallVelocityX:o&He&&(r=s.overallVelocityY),n.prototype.attrTest.call(this,s)&&o&s.offsetDirection&&s.distance>this.options.threshold&&s.maxPointers===this.options.pointers&&ze(r)>this.options.velocity&&s.eventType&K},t.emit=function(s){var o=gs(s.offsetDirection);o&&this.manager.emit(this.options.event+o,s),this.manager.emit(this.options.event,s)},e}(tt),ys=function(n){he(e,n);function e(i){return i===void 0&&(i={}),n.call(this,fe({event:"pinch",threshold:0,pointers:2},i))||this}var t=e.prototype;return t.getTouchAction=function(){return[Le]},t.attrTest=function(s){return n.prototype.attrTest.call(this,s)&&(Math.abs(s.scale-1)>this.options.threshold||this.state&le)},t.emit=function(s){if(s.scale!==1){var o=s.scale<1?"in":"out";s.additionalEvent=this.options.event+o}n.prototype.emit.call(this,s)},e}(tt),bs=function(n){he(e,n);function e(i){return i===void 0&&(i={}),n.call(this,fe({event:"rotate",threshold:0,pointers:2},i))||this}var t=e.prototype;return t.getTouchAction=function(){return[Le]},t.attrTest=function(s){return n.prototype.attrTest.call(this,s)&&(Math.abs(s.rotation)>this.options.threshold||this.state&le)},e}(tt),vs=function(n){he(e,n);function e(i){var s;return i===void 0&&(i={}),s=n.call(this,fe({event:"press",pointers:1,time:251,threshold:9},i))||this,s._timer=null,s._input=null,s}var t=e.prototype;return t.getTouchAction=function(){return[$i]},t.process=function(s){var o=this,r=this.options,a=s.pointers.length===r.pointers,d=s.distance<r.threshold,h=s.deltaTime>r.time;if(this._input=s,!d||!a||s.eventType&(K|se)&&!h)this.reset();else if(s.eventType&ee)this.reset(),this._timer=setTimeout(function(){o.state=ve,o.tryEmit()},r.time);else if(s.eventType&K)return ve;return ge},t.reset=function(){clearTimeout(this._timer)},t.emit=function(s){this.state===ve&&(s&&s.eventType&K?this.manager.emit(this.options.event+"up",s):(this._input.timeStamp=ni(),this.manager.emit(this.options.event,this._input)))},e}(mt),ws={domEvents:!1,touchAction:Qi,enable:!0,inputTarget:null,inputClass:null,cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}},_s=[[bs,{enable:!1}],[ys,{enable:!1},["rotate"]],[ms,{direction:pe}],[pi,{direction:pe},["swipe"]],[fi],[fi,{event:"doubletap",taps:2},["tap"]],[vs]],gr=1,Es=2;function xs(n,e){var t=n.element;if(!!t.style){var i;be(n.options.cssProps,function(s,o){i=Ot(t.style,o),e?(n.oldCssProps[i]=t.style[i],t.style[i]=s):t.style[i]=n.oldCssProps[i]||""}),e||(n.oldCssProps={})}}function mr(n,e){var t=document.createEvent("Event");t.initEvent(n,!0,!0),t.gesture=e,e.target.dispatchEvent(t)}var Cs=function(){function n(t,i){var s=this;this.options=Ae({},ws,i||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=ur(this),this.touchAction=new is(this,this.options.touchAction),xs(this,!0),be(this.options.recognizers,function(o){var r=s.add(new o[0](o[1]));o[2]&&r.recognizeWith(o[2]),o[3]&&r.requireFailure(o[3])},this)}var e=n.prototype;return e.set=function(i){return Ae(this.options,i),i.touchAction&&this.touchAction.update(),i.inputTarget&&(this.input.destroy(),this.input.target=i.inputTarget,this.input.init()),this},e.stop=function(i){this.session.stopped=i?Es:gr},e.recognize=function(i){var s=this.session;if(!s.stopped){this.touchAction.preventDefaults(i);var o,r=this.recognizers,a=s.curRecognizer;(!a||a&&a.state&ve)&&(s.curRecognizer=null,a=null);for(var d=0;d<r.length;)o=r[d],s.stopped!==Es&&(!a||o===a||o.canRecognizeWith(a))?o.recognize(i):o.reset(),!a&&o.state&(le|et|Oe)&&(s.curRecognizer=o,a=o),d++}},e.get=function(i){if(i instanceof mt)return i;for(var s=this.recognizers,o=0;o<s.length;o++)if(s[o].options.event===i)return s[o];return null},e.add=function(i){if(Je(i,"add",this))return this;var s=this.get(i.options.event);return s&&this.remove(s),this.recognizers.push(i),i.manager=this,this.touchAction.update(),i},e.remove=function(i){if(Je(i,"remove",this))return this;var s=this.get(i);if(i){var o=this.recognizers,r=We(o,s);r!==-1&&(o.splice(r,1),this.touchAction.update())}return this},e.on=function(i,s){if(i===void 0||s===void 0)return this;var o=this.handlers;return be(ct(i),function(r){o[r]=o[r]||[],o[r].push(s)}),this},e.off=function(i,s){if(i===void 0)return this;var o=this.handlers;return be(ct(i),function(r){s?o[r]&&o[r].splice(We(o[r],s),1):delete o[r]}),this},e.emit=function(i,s){this.options.domEvents&&mr(i,s);var o=this.handlers[i]&&this.handlers[i].slice();if(!(!o||!o.length)){s.type=i,s.preventDefault=function(){s.srcEvent.preventDefault()};for(var r=0;r<o.length;)o[r](s),r++}},e.destroy=function(){this.element&&xs(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null},n}(),yr={touchstart:ee,touchmove:Re,touchend:K,touchcancel:se},br="touchstart",vr="touchstart touchmove touchend touchcancel",wr=function(n){he(e,n);function e(){var i,s=e.prototype;return s.evTarget=br,s.evWin=vr,i=n.apply(this,arguments)||this,i.started=!1,i}var t=e.prototype;return t.handler=function(s){var o=yr[s.type];if(o===ee&&(this.started=!0),!!this.started){var r=_r.call(this,s,o);o&(K|se)&&r[0].length-r[1].length==0&&(this.started=!1),this.callback(this.manager,o,{pointers:r[0],changedPointers:r[1],pointerType:at,srcEvent:s})}},e}($e);function _r(n,e){var t=pt(n.touches),i=pt(n.changedTouches);return e&(K|se)&&(t=li(t.concat(i),"identifier",!0)),[t,i]}function Ts(n,e,t){var i="DEPRECATED METHOD: "+e+`
`+t+` AT
`;return function(){var s=new Error("get-stack-trace"),o=s&&s.stack?s.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=window.console&&(window.console.warn||window.console.log);return r&&r.call(window.console,i,o),n.apply(this,arguments)}}var ks=Ts(function(n,e,t){for(var i=Object.keys(e),s=0;s<i.length;)(!t||t&&n[i[s]]===void 0)&&(n[i[s]]=e[i[s]]),s++;return n},"extend","Use `assign`."),Er=Ts(function(n,e){return ks(n,e,!0)},"merge","Use `assign`.");function xr(n,e,t){var i=e.prototype,s;s=n.prototype=Object.create(i),s.constructor=n,s._super=i,t&&Ae(s,t)}function Ss(n,e){return function(){return n.apply(e,arguments)}}var Os=function(){var n=function(t,i){return i===void 0&&(i={}),new Cs(t,fe({recognizers:_s.concat()},i))};return n.VERSION="2.0.17-rc",n.DIRECTION_ALL=es,n.DIRECTION_DOWN=Qe,n.DIRECTION_LEFT=dt,n.DIRECTION_RIGHT=ht,n.DIRECTION_UP=lt,n.DIRECTION_HORIZONTAL=pe,n.DIRECTION_VERTICAL=He,n.DIRECTION_NONE=Pt,n.DIRECTION_DOWN=Qe,n.INPUT_START=ee,n.INPUT_MOVE=Re,n.INPUT_END=K,n.INPUT_CANCEL=se,n.STATE_POSSIBLE=Nt,n.STATE_BEGAN=le,n.STATE_CHANGED=et,n.STATE_ENDED=Oe,n.STATE_RECOGNIZED=ve,n.STATE_CANCELLED=gt,n.STATE_FAILED=ge,n.Manager=Cs,n.Input=$e,n.TouchAction=is,n.TouchInput=ci,n.MouseInput=ui,n.PointerEventInput=ls,n.TouchMouseInput=fs,n.SingleTouchInput=wr,n.Recognizer=mt,n.AttrRecognizer=tt,n.Tap=fi,n.Pan=pi,n.Swipe=ms,n.Pinch=ys,n.Rotate=bs,n.Press=vs,n.on=ut,n.off=ft,n.each=be,n.merge=Er,n.extend=ks,n.bindFn=Ss,n.assign=Ae,n.inherit=xr,n.bindFn=Ss,n.prefixed=Ot,n.toArray=pt,n.inArray=We,n.uniqueArray=li,n.splitStr=ct,n.boolOrFn=Dt,n.hasParent=di,n.addEventListeners=ut,n.removeEventListeners=ft,n.defaults=Ae({},ws,{preset:_s}),n}(),qa=Os.defaults,Is=Os;var gi=Symbol("DELETE");function Ms(n,...e){return Ds({},n,...e)}function Ds(...n){let e=At(...n);return Ns(e),e}function At(...n){if(n.length<2)return n[0];if(n.length>2)return At(Ds(n[0],n[1]),...n.slice(2));let e=n[0],t=n[1];for(let i of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,i)&&(t[i]===gi?delete e[i]:e[i]!==null&&t[i]!==null&&typeof e[i]=="object"&&typeof t[i]=="object"&&!Array.isArray(e[i])&&!Array.isArray(t[i])?e[i]=At(e[i],t[i]):e[i]=Fs(t[i]));return e}function Fs(n){return Array.isArray(n)?n.map(e=>Fs(e)):typeof n=="object"&&n!==null?At({},n):n}function Ns(n){for(let e of Object.keys(n))n[e]===gi?delete n[e]:typeof n[e]=="object"&&n[e]!==null&&Ns(n[e])}function yt(...n){return Cr(n.length?n:[Date.now()])}function Cr(n){let[e,t,i]=Tr(n),s=1,o=()=>{let r=2091639*e+s*23283064365386963e-26;return e=t,t=i,i=r-(s=r|0)};return o.uint32=()=>o()*4294967296,o.fract53=()=>o()+(o()*2097152|0)*11102230246251565e-32,o.algorithm="Alea",o.seed=n,o.version="0.9",o}function Tr(...n){let e=kr(),t=e(" "),i=e(" "),s=e(" ");for(let o=0;o<n.length;o++)t-=e(n[o]),t<0&&(t+=1),i-=e(n[o]),i<0&&(i+=1),s-=e(n[o]),s<0&&(s+=1);return[t,i,s]}function kr(){let n=4022871197;return function(e){let t=e.toString();for(let i=0;i<t.length;i++){n+=t.charCodeAt(i);let s=.02519603282416938*n;n=s>>>0,s-=n,s*=n,n=s>>>0,s-=n,n+=s*4294967296}return(n>>>0)*23283064365386963e-26}}function Sr(){let n=()=>{};return{on:n,off:n,destroy:n,emit:n,get(){return{set:n}}}}var mi=typeof window!="undefined"?window.Hammer||Is:function(){return Sr()};function me(n){this._cleanupQueue=[],this.active=!1,this._dom={container:n,overlay:document.createElement("div")},this._dom.overlay.classList.add("vis-overlay"),this._dom.container.appendChild(this._dom.overlay),this._cleanupQueue.push(()=>{this._dom.overlay.parentNode.removeChild(this._dom.overlay)});let e=mi(this._dom.overlay);e.on("tap",this._onTapOverlay.bind(this)),this._cleanupQueue.push(()=>{e.destroy()}),["tap","doubletap","press","pinch","pan","panstart","panmove","panend"].forEach(i=>{e.on(i,s=>{s.srcEvent.stopPropagation()})}),document&&document.body&&(this._onClick=i=>{Or(i.target,n)||this.deactivate()},document.body.addEventListener("click",this._onClick),this._cleanupQueue.push(()=>{document.body.removeEventListener("click",this._onClick)})),this._escListener=i=>{("key"in i?i.key==="Escape":i.keyCode===27)&&this.deactivate()}}(0,Ps.default)(me.prototype);me.current=null;me.prototype.destroy=function(){this.deactivate();for(let n of this._cleanupQueue.splice(0).reverse())n()};me.prototype.activate=function(){me.current&&me.current.deactivate(),me.current=this,this.active=!0,this._dom.overlay.style.display="none",this._dom.container.classList.add("vis-active"),this.emit("change"),this.emit("activate"),document.body.addEventListener("keydown",this._escListener)};me.prototype.deactivate=function(){this.active=!1,this._dom.overlay.style.display="block",this._dom.container.classList.remove("vis-active"),document.body.removeEventListener("keydown",this._escListener),this.emit("change"),this.emit("deactivate")};me.prototype._onTapOverlay=function(n){this.activate(),n.srcEvent.stopPropagation()};function Or(n,e){for(;n;){if(n===e)return!0;n=n.parentNode}return!1}var Ir=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Pr=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,Mr=/^rgb\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *\)$/i,Dr=/^rgba\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *([01]|0?\.\d+) *\)$/i;function we(n){if(n)for(;n.hasChildNodes()===!0;){let e=n.firstChild;e&&(we(e),n.removeChild(e))}}function _e(n){return n instanceof String||typeof n=="string"}function Bs(n){return typeof n=="object"&&n!==null}function Ve(n,e,t,i){let s=!1;i===!0&&(s=e[t]===null&&n[t]!==void 0),s?delete n[t]:n[t]=e[t]}function yi(n,e,t=!1){for(let i in n)if(e[i]!==void 0)if(e[i]===null||typeof e[i]!="object")Ve(n,e,i,t);else{let s=n[i],o=e[i];Bs(s)&&Bs(o)&&yi(s,o,t)}}function qe(n,e,t,i=!1){if(Array.isArray(t))throw new TypeError("Arrays are not supported by deepExtend");for(let s=0;s<n.length;s++){let o=n[s];if(Object.prototype.hasOwnProperty.call(t,o))if(t[o]&&t[o].constructor===Object)e[o]===void 0&&(e[o]={}),e[o].constructor===Object?j(e[o],t[o],!1,i):Ve(e,t,o,i);else{if(Array.isArray(t[o]))throw new TypeError("Arrays are not supported by deepExtend");Ve(e,t,o,i)}}return e}function bt(n,e,t,i=!1){if(Array.isArray(t))throw new TypeError("Arrays are not supported by deepExtend");for(let s in t)if(!!Object.prototype.hasOwnProperty.call(t,s)&&!n.includes(s))if(t[s]&&t[s].constructor===Object)e[s]===void 0&&(e[s]={}),e[s].constructor===Object?j(e[s],t[s]):Ve(e,t,s,i);else if(Array.isArray(t[s])){e[s]=[];for(let o=0;o<t[s].length;o++)e[s].push(t[s][o])}else Ve(e,t,s,i);return e}function j(n,e,t=!1,i=!1){for(let s in e)(Object.prototype.hasOwnProperty.call(e,s)||t===!0)&&(typeof e[s]=="object"&&e[s]!==null&&Object.getPrototypeOf(e[s])===Object.prototype?n[s]===void 0?n[s]=j({},e[s],t):typeof n[s]=="object"&&n[s]!==null&&Object.getPrototypeOf(n[s])===Object.prototype?j(n[s],e[s],t):Ve(n,e,s,i):Array.isArray(e[s])?n[s]=e[s].slice():Ve(n,e,s,i));return n}function zt(n,e){return[...n,e]}function Fr(n){return n.slice()}function As(n){return n.getBoundingClientRect().left}function zs(n){return n.getBoundingClientRect().top}function A(n,e){if(Array.isArray(n)){let t=n.length;for(let i=0;i<t;i++)e(n[i],i,n)}else for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(n[t],t,n)}function Ls(n,e,t,i){n.addEventListener?(i===void 0&&(i=!1),e==="mousewheel"&&navigator.userAgent.includes("Firefox")&&(e="DOMMouseScroll"),n.addEventListener(e,t,i)):n.attachEvent("on"+e,t)}function Rs(n,e,t,i){n.removeEventListener?(i===void 0&&(i=!1),e==="mousewheel"&&navigator.userAgent.includes("Firefox")&&(e="DOMMouseScroll"),n.removeEventListener(e,t,i)):n.detachEvent("on"+e,t)}function bi(n){let e;switch(n.length){case 3:case 4:return e=Pr.exec(n),e?{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16)}:null;case 6:case 7:return e=Ir.exec(n),e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null;default:return null}}function re(n,e){if(n.includes("rgba"))return n;if(n.includes("rgb")){let t=n.substr(n.indexOf("(")+1).replace(")","").split(",");return"rgba("+t[0]+","+t[1]+","+t[2]+","+e+")"}else{let t=bi(n);return t==null?n:"rgba("+t.r+","+t.g+","+t.b+","+e+")"}}function Hs(n,e,t){return"#"+((1<<24)+(n<<16)+(e<<8)+t).toString(16).slice(1)}function Lt(n,e){if(_e(n)){let t=n;if(Ws(t)){let i=t.substr(4).substr(0,t.length-5).split(",").map(function(s){return parseInt(s)});t=Hs(i[0],i[1],i[2])}if(js(t)===!0){let i=Nr(t),s={h:i.h,s:i.s*.8,v:Math.min(1,i.v*1.02)},o={h:i.h,s:Math.min(1,i.s*1.25),v:i.v*.8},r=Ht(o.h,o.s,o.v),a=Ht(s.h,s.s,s.v);return{background:t,border:r,highlight:{background:a,border:r},hover:{background:a,border:r}}}else return{background:t,border:t,highlight:{background:t,border:t},hover:{background:t,border:t}}}else return e?{background:n.background||e.background,border:n.border||e.border,highlight:_e(n.highlight)?{border:n.highlight,background:n.highlight}:{background:n.highlight&&n.highlight.background||e.highlight.background,border:n.highlight&&n.highlight.border||e.highlight.border},hover:_e(n.hover)?{border:n.hover,background:n.hover}:{border:n.hover&&n.hover.border||e.hover.border,background:n.hover&&n.hover.background||e.hover.background}}:{background:n.background||void 0,border:n.border||void 0,highlight:_e(n.highlight)?{border:n.highlight,background:n.highlight}:{background:n.highlight&&n.highlight.background||void 0,border:n.highlight&&n.highlight.border||void 0},hover:_e(n.hover)?{border:n.hover,background:n.hover}:{border:n.hover&&n.hover.border||void 0,background:n.hover&&n.hover.background||void 0}}}function vt(n,e,t){n=n/255,e=e/255,t=t/255;let i=Math.min(n,Math.min(e,t)),s=Math.max(n,Math.max(e,t));if(i===s)return{h:0,s:0,v:i};let o=n===i?e-t:t===i?n-e:t-n,a=60*((n===i?3:t===i?1:5)-o/(s-i))/360,d=(s-i)/s;return{h:a,s:d,v:s}}function Rt(n,e,t){let i,s,o,r=Math.floor(n*6),a=n*6-r,d=t*(1-e),h=t*(1-a*e),l=t*(1-(1-a)*e);switch(r%6){case 0:i=t,s=l,o=d;break;case 1:i=h,s=t,o=d;break;case 2:i=d,s=t,o=l;break;case 3:i=d,s=h,o=t;break;case 4:i=l,s=d,o=t;break;case 5:i=t,s=d,o=h;break}return{r:Math.floor(i*255),g:Math.floor(s*255),b:Math.floor(o*255)}}function Ht(n,e,t){let i=Rt(n,e,t);return Hs(i.r,i.g,i.b)}function Nr(n){let e=bi(n);if(!e)throw new TypeError(`'${n}' is not a valid color.`);return vt(e.r,e.g,e.b)}function js(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)}function Ws(n){return Mr.test(n)}function Br(n){return Dr.test(n)}function Ee(n){if(n===null||typeof n!="object")return null;if(n instanceof Element)return n;let e=Object.create(n);for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&typeof n[t]=="object"&&(e[t]=Ee(n[t]));return e}function ae(n,e,t,i={}){let s=function(p){return p!=null},o=function(p){return p!==null&&typeof p=="object"},r=function(p){for(let b in p)if(Object.prototype.hasOwnProperty.call(p,b))return!1;return!0};if(!o(n))throw new Error("Parameter mergeTarget must be an object");if(!o(e))throw new Error("Parameter options must be an object");if(!s(t))throw new Error("Parameter option must have a value");if(!o(i))throw new Error("Parameter globalOptions must be an object");let a=function(p,b,C){o(p[C])||(p[C]={});let f=b[C],g=p[C];for(let m in f)Object.prototype.hasOwnProperty.call(f,m)&&(g[m]=f[m])},d=e[t],l=o(i)&&!r(i)?i[t]:void 0,c=l?l.enabled:void 0;if(d===void 0)return;if(typeof d=="boolean"){o(n[t])||(n[t]={}),n[t].enabled=d;return}if(d===null&&!o(n[t]))if(s(l))n[t]=Object.create(l);else return;if(!o(d))return;let u=!0;d.enabled!==void 0?u=d.enabled:c!==void 0&&(u=l.enabled),a(n,e,t),n[t].enabled=u}var Vs={linear(n){return n},easeInQuad(n){return n*n},easeOutQuad(n){return n*(2-n)},easeInOutQuad(n){return n<.5?2*n*n:-1+(4-2*n)*n},easeInCubic(n){return n*n*n},easeOutCubic(n){return--n*n*n+1},easeInOutCubic(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},easeInQuart(n){return n*n*n*n},easeOutQuart(n){return 1- --n*n*n*n},easeInOutQuart(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},easeInQuint(n){return n*n*n*n*n},easeOutQuint(n){return 1+--n*n*n*n*n},easeInOutQuint(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n}};function xe(n,e){let t;Array.isArray(e)||(e=[e]);for(let i of n)if(i){t=i[e[0]];for(let s=1;s<e.length;s++)t&&(t=t[e[s]]);if(typeof t!="undefined")break}return t}var Ar={black:"#000000",navy:"#000080",darkblue:"#00008B",mediumblue:"#0000CD",blue:"#0000FF",darkgreen:"#006400",green:"#008000",teal:"#008080",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",lime:"#00FF00",springgreen:"#00FF7F",aqua:"#00FFFF",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",mediumaquamarine:"#66CDAA",dimgray:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",lightslategray:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",maroon:"#800000",purple:"#800080",olive:"#808000",gray:"#808080",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370D8",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",silver:"#C0C0C0",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgrey:"#D3D3D3",palevioletred:"#D87093",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",red:"#FF0000",fuchsia:"#FF00FF",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",yellow:"#FFFF00",lightyellow:"#FFFFE0",ivory:"#FFFFF0",white:"#FFFFFF"},qs=class{constructor(e=1){this.pixelRatio=e,this.generated=!1,this.centerCoordinates={x:289/2,y:289/2},this.r=289*.49,this.color={r:255,g:255,b:255,a:1},this.hueCircle=void 0,this.initialColor={r:255,g:255,b:255,a:1},this.previousColor=void 0,this.applied=!1,this.updateCallback=()=>{},this.closeCallback=()=>{},this._create()}insertTo(e){this.hammer!==void 0&&(this.hammer.destroy(),this.hammer=void 0),this.container=e,this.container.appendChild(this.frame),this._bindHammer(),this._setSize()}setUpdateCallback(e){if(typeof e=="function")this.updateCallback=e;else throw new Error("Function attempted to set as colorPicker update callback is not a function.")}setCloseCallback(e){if(typeof e=="function")this.closeCallback=e;else throw new Error("Function attempted to set as colorPicker closing callback is not a function.")}_isColorString(e){if(typeof e=="string")return Ar[e]}setColor(e,t=!0){if(e==="none")return;let i,s=this._isColorString(e);if(s!==void 0&&(e=s),_e(e)===!0){if(Ws(e)===!0){let o=e.substr(4).substr(0,e.length-5).split(",");i={r:o[0],g:o[1],b:o[2],a:1}}else if(Br(e)===!0){let o=e.substr(5).substr(0,e.length-6).split(",");i={r:o[0],g:o[1],b:o[2],a:o[3]}}else if(js(e)===!0){let o=bi(e);i={r:o.r,g:o.g,b:o.b,a:1}}}else if(e instanceof Object&&e.r!==void 0&&e.g!==void 0&&e.b!==void 0){let o=e.a!==void 0?e.a:"1.0";i={r:e.r,g:e.g,b:e.b,a:o}}if(i===void 0)throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: "+JSON.stringify(e));this._setColor(i,t)}show(){this.closeCallback!==void 0&&(this.closeCallback(),this.closeCallback=void 0),this.applied=!1,this.frame.style.display="block",this._generateHueCircle()}_hide(e=!0){e===!0&&(this.previousColor=Object.assign({},this.color)),this.applied===!0&&this.updateCallback(this.initialColor),this.frame.style.display="none",setTimeout(()=>{this.closeCallback!==void 0&&(this.closeCallback(),this.closeCallback=void 0)},0)}_save(){this.updateCallback(this.color),this.applied=!1,this._hide()}_apply(){this.applied=!0,this.updateCallback(this.color),this._updatePicker(this.color)}_loadLast(){this.previousColor!==void 0?this.setColor(this.previousColor,!1):alert("There is no last color to load...")}_setColor(e,t=!0){t===!0&&(this.initialColor=Object.assign({},e)),this.color=e;let i=vt(e.r,e.g,e.b),s=2*Math.PI,o=this.r*i.s,r=this.centerCoordinates.x+o*Math.sin(s*i.h),a=this.centerCoordinates.y+o*Math.cos(s*i.h);this.colorPickerSelector.style.left=r-.5*this.colorPickerSelector.clientWidth+"px",this.colorPickerSelector.style.top=a-.5*this.colorPickerSelector.clientHeight+"px",this._updatePicker(e)}_setOpacity(e){this.color.a=e/100,this._updatePicker(this.color)}_setBrightness(e){let t=vt(this.color.r,this.color.g,this.color.b);t.v=e/100;let i=Rt(t.h,t.s,t.v);i.a=this.color.a,this.color=i,this._updatePicker()}_updatePicker(e=this.color){let t=vt(e.r,e.g,e.b),i=this.colorPickerCanvas.getContext("2d");this.pixelRation===void 0&&(this.pixelRatio=(window.devicePixelRatio||1)/(i.webkitBackingStorePixelRatio||i.mozBackingStorePixelRatio||i.msBackingStorePixelRatio||i.oBackingStorePixelRatio||i.backingStorePixelRatio||1)),i.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);let s=this.colorPickerCanvas.clientWidth,o=this.colorPickerCanvas.clientHeight;i.clearRect(0,0,s,o),i.putImageData(this.hueCircle,0,0),i.fillStyle="rgba(0,0,0,"+(1-t.v)+")",i.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),i.fill(),this.brightnessRange.value=100*t.v,this.opacityRange.value=100*e.a,this.initialColorDiv.style.backgroundColor="rgba("+this.initialColor.r+","+this.initialColor.g+","+this.initialColor.b+","+this.initialColor.a+")",this.newColorDiv.style.backgroundColor="rgba("+this.color.r+","+this.color.g+","+this.color.b+","+this.color.a+")"}_setSize(){this.colorPickerCanvas.style.width="100%",this.colorPickerCanvas.style.height="100%",this.colorPickerCanvas.width=289*this.pixelRatio,this.colorPickerCanvas.height=289*this.pixelRatio}_create(){if(this.frame=document.createElement("div"),this.frame.className="vis-color-picker",this.colorPickerDiv=document.createElement("div"),this.colorPickerSelector=document.createElement("div"),this.colorPickerSelector.className="vis-selector",this.colorPickerDiv.appendChild(this.colorPickerSelector),this.colorPickerCanvas=document.createElement("canvas"),this.colorPickerDiv.appendChild(this.colorPickerCanvas),this.colorPickerCanvas.getContext){let t=this.colorPickerCanvas.getContext("2d");this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}else{let t=document.createElement("DIV");t.style.color="red",t.style.fontWeight="bold",t.style.padding="10px",t.innerText="Error: your browser does not support HTML canvas",this.colorPickerCanvas.appendChild(t)}this.colorPickerDiv.className="vis-color",this.opacityDiv=document.createElement("div"),this.opacityDiv.className="vis-opacity",this.brightnessDiv=document.createElement("div"),this.brightnessDiv.className="vis-brightness",this.arrowDiv=document.createElement("div"),this.arrowDiv.className="vis-arrow",this.opacityRange=document.createElement("input");try{this.opacityRange.type="range",this.opacityRange.min="0",this.opacityRange.max="100"}catch(t){}this.opacityRange.value="100",this.opacityRange.className="vis-range",this.brightnessRange=document.createElement("input");try{this.brightnessRange.type="range",this.brightnessRange.min="0",this.brightnessRange.max="100"}catch(t){}this.brightnessRange.value="100",this.brightnessRange.className="vis-range",this.opacityDiv.appendChild(this.opacityRange),this.brightnessDiv.appendChild(this.brightnessRange);let e=this;this.opacityRange.onchange=function(){e._setOpacity(this.value)},this.opacityRange.oninput=function(){e._setOpacity(this.value)},this.brightnessRange.onchange=function(){e._setBrightness(this.value)},this.brightnessRange.oninput=function(){e._setBrightness(this.value)},this.brightnessLabel=document.createElement("div"),this.brightnessLabel.className="vis-label vis-brightness",this.brightnessLabel.innerText="brightness:",this.opacityLabel=document.createElement("div"),this.opacityLabel.className="vis-label vis-opacity",this.opacityLabel.innerText="opacity:",this.newColorDiv=document.createElement("div"),this.newColorDiv.className="vis-new-color",this.newColorDiv.innerText="new",this.initialColorDiv=document.createElement("div"),this.initialColorDiv.className="vis-initial-color",this.initialColorDiv.innerText="initial",this.cancelButton=document.createElement("div"),this.cancelButton.className="vis-button vis-cancel",this.cancelButton.innerText="cancel",this.cancelButton.onclick=this._hide.bind(this,!1),this.applyButton=document.createElement("div"),this.applyButton.className="vis-button vis-apply",this.applyButton.innerText="apply",this.applyButton.onclick=this._apply.bind(this),this.saveButton=document.createElement("div"),this.saveButton.className="vis-button vis-save",this.saveButton.innerText="save",this.saveButton.onclick=this._save.bind(this),this.loadButton=document.createElement("div"),this.loadButton.className="vis-button vis-load",this.loadButton.innerText="load last",this.loadButton.onclick=this._loadLast.bind(this),this.frame.appendChild(this.colorPickerDiv),this.frame.appendChild(this.arrowDiv),this.frame.appendChild(this.brightnessLabel),this.frame.appendChild(this.brightnessDiv),this.frame.appendChild(this.opacityLabel),this.frame.appendChild(this.opacityDiv),this.frame.appendChild(this.newColorDiv),this.frame.appendChild(this.initialColorDiv),this.frame.appendChild(this.cancelButton),this.frame.appendChild(this.applyButton),this.frame.appendChild(this.saveButton),this.frame.appendChild(this.loadButton)}_bindHammer(){this.drag={},this.pinch={},this.hammer=new mi(this.colorPickerCanvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.on("hammer.input",e=>{e.isFirst&&this._moveSelector(e)}),this.hammer.on("tap",e=>{this._moveSelector(e)}),this.hammer.on("panstart",e=>{this._moveSelector(e)}),this.hammer.on("panmove",e=>{this._moveSelector(e)}),this.hammer.on("panend",e=>{this._moveSelector(e)})}_generateHueCircle(){if(this.generated===!1){let e=this.colorPickerCanvas.getContext("2d");this.pixelRation===void 0&&(this.pixelRatio=(window.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1)),e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);let t=this.colorPickerCanvas.clientWidth,i=this.colorPickerCanvas.clientHeight;e.clearRect(0,0,t,i);let s,o,r,a;this.centerCoordinates={x:t*.5,y:i*.5},this.r=.49*t;let d=2*Math.PI/360,h=1/360,l=1/this.r,c;for(r=0;r<360;r++)for(a=0;a<this.r;a++)s=this.centerCoordinates.x+a*Math.sin(d*r),o=this.centerCoordinates.y+a*Math.cos(d*r),c=Rt(r*h,a*l,1),e.fillStyle="rgb("+c.r+","+c.g+","+c.b+")",e.fillRect(s-.5,o-.5,2,2);e.strokeStyle="rgba(0,0,0,1)",e.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),e.stroke(),this.hueCircle=e.getImageData(0,0,t,i)}this.generated=!0}_moveSelector(e){let t=this.colorPickerDiv.getBoundingClientRect(),i=e.center.x-t.left,s=e.center.y-t.top,o=.5*this.colorPickerDiv.clientHeight,r=.5*this.colorPickerDiv.clientWidth,a=i-r,d=s-o,h=Math.atan2(a,d),l=.98*Math.min(Math.sqrt(a*a+d*d),r),c=Math.cos(h)*l+o,u=Math.sin(h)*l+r;this.colorPickerSelector.style.top=c-.5*this.colorPickerSelector.clientHeight+"px",this.colorPickerSelector.style.left=u-.5*this.colorPickerSelector.clientWidth+"px";let p=h/(2*Math.PI);p=p<0?p+1:p;let b=l/this.r,C=vt(this.color.r,this.color.g,this.color.b);C.h=p,C.s=b;let f=Rt(C.h,C.s,C.v);f.a=this.color.a,this.color=f,this.initialColorDiv.style.backgroundColor="rgba("+this.initialColor.r+","+this.initialColor.g+","+this.initialColor.b+","+this.initialColor.a+")",this.newColorDiv.style.backgroundColor="rgba("+this.color.r+","+this.color.g+","+this.color.b+","+this.color.a+")"}};function vi(...n){if(n.length<1)throw new TypeError("Invalid arguments.");if(n.length===1)return document.createTextNode(n[0]);{let e=document.createElement(n[0]);return e.appendChild(vi(...n.slice(1))),e}}var Us=class{constructor(e,t,i,s=1,o=()=>!1){this.parent=e,this.changedOptions=[],this.container=t,this.allowCreation=!1,this.hideOption=o,this.options={},this.initialized=!1,this.popupCounter=0,this.defaultOptions={enabled:!1,filter:!0,container:void 0,showButton:!0},Object.assign(this.options,this.defaultOptions),this.configureOptions=i,this.moduleOptions={},this.domElements=[],this.popupDiv={},this.popupLimit=5,this.popupHistory={},this.colorPicker=new qs(s),this.wrapper=void 0}setOptions(e){if(e!==void 0){this.popupHistory={},this._removePopup();let t=!0;if(typeof e=="string")this.options.filter=e;else if(Array.isArray(e))this.options.filter=e.join();else if(typeof e=="object"){if(e==null)throw new TypeError("options cannot be null");e.container!==void 0&&(this.options.container=e.container),e.filter!==void 0&&(this.options.filter=e.filter),e.showButton!==void 0&&(this.options.showButton=e.showButton),e.enabled!==void 0&&(t=e.enabled)}else typeof e=="boolean"?(this.options.filter=!0,t=e):typeof e=="function"&&(this.options.filter=e,t=!0);this.options.filter===!1&&(t=!1),this.options.enabled=t}this._clean()}setModuleOptions(e){this.moduleOptions=e,this.options.enabled===!0&&(this._clean(),this.options.container!==void 0&&(this.container=this.options.container),this._create())}_create(){this._clean(),this.changedOptions=[];let e=this.options.filter,t=0,i=!1;for(let s in this.configureOptions)Object.prototype.hasOwnProperty.call(this.configureOptions,s)&&(this.allowCreation=!1,i=!1,typeof e=="function"?(i=e(s,[]),i=i||this._handleObject(this.configureOptions[s],[s],!0)):(e===!0||e.indexOf(s)!==-1)&&(i=!0),i!==!1&&(this.allowCreation=!0,t>0&&this._makeItem([]),this._makeHeader(s),this._handleObject(this.configureOptions[s],[s])),t++);this._makeButton(),this._push()}_push(){this.wrapper=document.createElement("div"),this.wrapper.className="vis-configuration-wrapper",this.container.appendChild(this.wrapper);for(let e=0;e<this.domElements.length;e++)this.wrapper.appendChild(this.domElements[e]);this._showPopupIfNeeded()}_clean(){for(let e=0;e<this.domElements.length;e++)this.wrapper.removeChild(this.domElements[e]);this.wrapper!==void 0&&(this.container.removeChild(this.wrapper),this.wrapper=void 0),this.domElements=[],this._removePopup()}_getValue(e){let t=this.moduleOptions;for(let i=0;i<e.length;i++)if(t[e[i]]!==void 0)t=t[e[i]];else{t=void 0;break}return t}_makeItem(e,...t){if(this.allowCreation===!0){let i=document.createElement("div");return i.className="vis-configuration vis-config-item vis-config-s"+e.length,t.forEach(s=>{i.appendChild(s)}),this.domElements.push(i),this.domElements.length}return 0}_makeHeader(e){let t=document.createElement("div");t.className="vis-configuration vis-config-header",t.innerText=e,this._makeItem([],t)}_makeLabel(e,t,i=!1){let s=document.createElement("div");if(s.className="vis-configuration vis-config-label vis-config-s"+t.length,i===!0){for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(vi("i","b",e))}else s.innerText=e+":";return s}_makeDropdown(e,t,i){let s=document.createElement("select");s.className="vis-configuration vis-config-select";let o=0;t!==void 0&&e.indexOf(t)!==-1&&(o=e.indexOf(t));for(let d=0;d<e.length;d++){let h=document.createElement("option");h.value=e[d],d===o&&(h.selected="selected"),h.innerText=e[d],s.appendChild(h)}let r=this;s.onchange=function(){r._update(this.value,i)};let a=this._makeLabel(i[i.length-1],i);this._makeItem(i,a,s)}_makeRange(e,t,i){let s=e[0],o=e[1],r=e[2],a=e[3],d=document.createElement("input");d.className="vis-configuration vis-config-range";try{d.type="range",d.min=o,d.max=r}catch(C){}d.step=a;let h="",l=0;if(t!==void 0){let C=1.2;t<0&&t*C<o?(d.min=Math.ceil(t*C),l=d.min,h="range increased"):t/C<o&&(d.min=Math.ceil(t/C),l=d.min,h="range increased"),t*C>r&&r!==1&&(d.max=Math.ceil(t*C),l=d.max,h="range increased"),d.value=t}else d.value=s;let c=document.createElement("input");c.className="vis-configuration vis-config-rangeinput",c.value=d.value;let u=this;d.onchange=function(){c.value=this.value,u._update(Number(this.value),i)},d.oninput=function(){c.value=this.value};let p=this._makeLabel(i[i.length-1],i),b=this._makeItem(i,p,d,c);h!==""&&this.popupHistory[b]!==l&&(this.popupHistory[b]=l,this._setupPopup(h,b))}_makeButton(){if(this.options.showButton===!0){let e=document.createElement("div");e.className="vis-configuration vis-config-button",e.innerText="generate options",e.onclick=()=>{this._printOptions()},e.onmouseover=()=>{e.className="vis-configuration vis-config-button hover"},e.onmouseout=()=>{e.className="vis-configuration vis-config-button"},this.optionsContainer=document.createElement("div"),this.optionsContainer.className="vis-configuration vis-config-option-container",this.domElements.push(this.optionsContainer),this.domElements.push(e)}}_setupPopup(e,t){if(this.initialized===!0&&this.allowCreation===!0&&this.popupCounter<this.popupLimit){let i=document.createElement("div");i.id="vis-configuration-popup",i.className="vis-configuration-popup",i.innerText=e,i.onclick=()=>{this._removePopup()},this.popupCounter+=1,this.popupDiv={html:i,index:t}}}_removePopup(){this.popupDiv.html!==void 0&&(this.popupDiv.html.parentNode.removeChild(this.popupDiv.html),clearTimeout(this.popupDiv.hideTimeout),clearTimeout(this.popupDiv.deleteTimeout),this.popupDiv={})}_showPopupIfNeeded(){if(this.popupDiv.html!==void 0){let t=this.domElements[this.popupDiv.index].getBoundingClientRect();this.popupDiv.html.style.left=t.left+"px",this.popupDiv.html.style.top=t.top-30+"px",document.body.appendChild(this.popupDiv.html),this.popupDiv.hideTimeout=setTimeout(()=>{this.popupDiv.html.style.opacity=0},1500),this.popupDiv.deleteTimeout=setTimeout(()=>{this._removePopup()},1800)}}_makeCheckbox(e,t,i){let s=document.createElement("input");s.type="checkbox",s.className="vis-configuration vis-config-checkbox",s.checked=e,t!==void 0&&(s.checked=t,t!==e&&(typeof e=="object"?t!==e.enabled&&this.changedOptions.push({path:i,value:t}):this.changedOptions.push({path:i,value:t})));let o=this;s.onchange=function(){o._update(this.checked,i)};let r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,s)}_makeTextInput(e,t,i){let s=document.createElement("input");s.type="text",s.className="vis-configuration vis-config-text",s.value=t,t!==e&&this.changedOptions.push({path:i,value:t});let o=this;s.onchange=function(){o._update(this.value,i)};let r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,s)}_makeColorField(e,t,i){let s=e[1],o=document.createElement("div");t=t===void 0?s:t,t!=="none"?(o.className="vis-configuration vis-config-colorBlock",o.style.backgroundColor=t):o.className="vis-configuration vis-config-colorBlock none",t=t===void 0?s:t,o.onclick=()=>{this._showColorPicker(t,o,i)};let r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,o)}_showColorPicker(e,t,i){t.onclick=function(){},this.colorPicker.insertTo(t),this.colorPicker.show(),this.colorPicker.setColor(e),this.colorPicker.setUpdateCallback(s=>{let o="rgba("+s.r+","+s.g+","+s.b+","+s.a+")";t.style.backgroundColor=o,this._update(o,i)}),this.colorPicker.setCloseCallback(()=>{t.onclick=()=>{this._showColorPicker(e,t,i)}})}_handleObject(e,t=[],i=!1){let s=!1,o=this.options.filter,r=!1;for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)){s=!0;let d=e[a],h=zt(t,a);if(typeof o=="function"&&(s=o(a,t),s===!1&&!Array.isArray(d)&&typeof d!="string"&&typeof d!="boolean"&&d instanceof Object&&(this.allowCreation=!1,s=this._handleObject(d,h,!0),this.allowCreation=i===!1)),s!==!1){r=!0;let l=this._getValue(h);if(Array.isArray(d))this._handleArray(d,l,h);else if(typeof d=="string")this._makeTextInput(d,l,h);else if(typeof d=="boolean")this._makeCheckbox(d,l,h);else if(d instanceof Object){if(!this.hideOption(t,a,this.moduleOptions))if(d.enabled!==void 0){let c=zt(h,"enabled"),u=this._getValue(c);if(u===!0){let p=this._makeLabel(a,h,!0);this._makeItem(h,p),r=this._handleObject(d,h)||r}else this._makeCheckbox(d,u,h)}else{let c=this._makeLabel(a,h,!0);this._makeItem(h,c),r=this._handleObject(d,h)||r}}else console.error("dont know how to handle",d,a,h)}}return r}_handleArray(e,t,i){typeof e[0]=="string"&&e[0]==="color"?(this._makeColorField(e,t,i),e[1]!==t&&this.changedOptions.push({path:i,value:t})):typeof e[0]=="string"?(this._makeDropdown(e,t,i),e[0]!==t&&this.changedOptions.push({path:i,value:t})):typeof e[0]=="number"&&(this._makeRange(e,t,i),e[0]!==t&&this.changedOptions.push({path:i,value:Number(t)}))}_update(e,t){let i=this._constructOptions(e,t);this.parent.body&&this.parent.body.emitter&&this.parent.body.emitter.emit&&this.parent.body.emitter.emit("configChange",i),this.initialized=!0,this.parent.setOptions(i)}_constructOptions(e,t,i={}){let s=i;e=e==="true"?!0:e,e=e==="false"?!1:e;for(let o=0;o<t.length;o++)t[o]!=="global"&&(s[t[o]]===void 0&&(s[t[o]]={}),o!==t.length-1?s=s[t[o]]:s[t[o]]=e);return i}_printOptions(){let e=this.getOptions();for(;this.optionsContainer.firstChild;)this.optionsContainer.removeChild(this.optionsContainer.firstChild);this.optionsContainer.appendChild(vi("pre","const options = "+JSON.stringify(e,null,2)))}getOptions(){let e={};for(let t=0;t<this.changedOptions.length;t++)this._constructOptions(this.changedOptions[t].value,this.changedOptions[t].path,e);return e}},Ys=class{constructor(e,t){this.container=e,this.overflowMethod=t||"cap",this.x=0,this.y=0,this.padding=5,this.hidden=!1,this.frame=document.createElement("div"),this.frame.className="vis-tooltip",this.container.appendChild(this.frame)}setPosition(e,t){this.x=parseInt(e),this.y=parseInt(t)}setText(e){if(e instanceof Element){for(;this.frame.firstChild;)this.frame.removeChild(this.frame.firstChild);this.frame.appendChild(e)}else this.frame.innerText=e}show(e){if(e===void 0&&(e=!0),e===!0){let t=this.frame.clientHeight,i=this.frame.clientWidth,s=this.frame.parentNode.clientHeight,o=this.frame.parentNode.clientWidth,r=0,a=0;if(this.overflowMethod=="flip"){let d=!1,h=!0;this.y-t<this.padding&&(h=!1),this.x+i>o-this.padding&&(d=!0),d?r=this.x-i:r=this.x,h?a=this.y-t:a=this.y}else a=this.y-t,a+t+this.padding>s&&(a=s-t-this.padding),a<this.padding&&(a=this.padding),r=this.x,r+i+this.padding>o&&(r=o-i-this.padding),r<this.padding&&(r=this.padding);this.frame.style.left=r+"px",this.frame.style.top=a+"px",this.frame.style.visibility="visible",this.hidden=!1}else this.hide()}hide(){this.hidden=!0,this.frame.style.left="0",this.frame.style.top="0",this.frame.style.visibility="hidden"}destroy(){this.frame.parentNode.removeChild(this.frame)}},wt=!1,Xs,wi="background: #FFeeee; color: #dd0000",X=class{static validate(e,t,i){wt=!1,Xs=t;let s=t;return i!==void 0&&(s=t[i]),X.parse(e,s,[]),wt}static parse(e,t,i){for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&X.check(s,e,t,i)}static check(e,t,i,s){if(i[e]===void 0&&i.__any__===void 0){X.getSuggestion(e,i,s);return}let o=e,r=!0;i[e]===void 0&&i.__any__!==void 0&&(o="__any__",r=X.getType(t[e])==="object");let a=i[o];r&&a.__type__!==void 0&&(a=a.__type__),X.checkFields(e,t,i,o,a,s)}static checkFields(e,t,i,s,o,r){let a=function(l){console.error("%c"+l+X.printLocation(r,e),wi)},d=X.getType(t[e]),h=o[d];h!==void 0?X.getType(h)==="array"&&h.indexOf(t[e])===-1?(a('Invalid option detected in "'+e+'". Allowed values are:'+X.print(h)+' not "'+t[e]+'". '),wt=!0):d==="object"&&s!=="__any__"&&(r=zt(r,e),X.parse(t[e],i[s],r)):o.any===void 0&&(a('Invalid type received for "'+e+'". Expected: '+X.print(Object.keys(o))+". Received ["+d+'] "'+t[e]+'"'),wt=!0)}static getType(e){let t=typeof e;return t==="object"?e===null?"null":e instanceof Boolean?"boolean":e instanceof Number?"number":e instanceof String?"string":Array.isArray(e)?"array":e instanceof Date?"date":e.nodeType!==void 0?"dom":e._isAMomentObject===!0?"moment":"object":t==="number"?"number":t==="boolean"?"boolean":t==="string"?"string":t===void 0?"undefined":t}static getSuggestion(e,t,i){let s=X.findInOptions(e,t,i,!1),o=X.findInOptions(e,Xs,[],!0),r=8,a=4,d;s.indexMatch!==void 0?d=" in "+X.printLocation(s.path,e,"")+'Perhaps it was incomplete? Did you mean: "'+s.indexMatch+`"?
`:o.distance<=a&&s.distance>o.distance?d=" in "+X.printLocation(s.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+X.printLocation(o.path,o.closestMatch,""):s.distance<=r?d='. Did you mean "'+s.closestMatch+'"?'+X.printLocation(s.path,e):d=". Did you mean one of these: "+X.print(Object.keys(t))+X.printLocation(i,e),console.error('%cUnknown option detected: "'+e+'"'+d,wi),wt=!0}static findInOptions(e,t,i,s=!1){let o=1e9,r="",a=[],d=e.toLowerCase(),h;for(let l in t){let c;if(t[l].__type__!==void 0&&s===!0){let u=X.findInOptions(e,t[l],zt(i,l));o>u.distance&&(r=u.closestMatch,a=u.path,o=u.distance,h=u.indexMatch)}else l.toLowerCase().indexOf(d)!==-1&&(h=l),c=X.levenshteinDistance(e,l),o>c&&(r=l,a=Fr(i),o=c)}return{closestMatch:r,path:a,distance:o,indexMatch:h}}static printLocation(e,t,i=`Problem value found at:
`){let s=`
`+i+`options = {
`;for(let o=0;o<e.length;o++){for(let r=0;r<o+1;r++)s+=" ";s+=e[o]+`: {
`}for(let o=0;o<e.length+1;o++)s+=" ";s+=t+`
`;for(let o=0;o<e.length+1;o++){for(let r=0;r<e.length-o;r++)s+=" ";s+=`}
`}return s+`
`}static print(e){return JSON.stringify(e).replace(/(")|(\[)|(\])|(,"__type__")/g,"").replace(/(,)/g,", ")}static levenshteinDistance(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let i=[],s;for(s=0;s<=t.length;s++)i[s]=[s];let o;for(o=0;o<=e.length;o++)i[0][o]=o;for(s=1;s<=t.length;s++)for(o=1;o<=e.length;o++)t.charAt(s-1)==e.charAt(o-1)?i[s][o]=i[s-1][o-1]:i[s][o]=Math.min(i[s-1][o-1]+1,Math.min(i[s][o-1]+1,i[s-1][o]+1));return i[t.length][e.length]}},Gs=me;var Ks=Us,Ue=mi,Zs=Ys,_i=wi,Qs=X;var jt,zr=new Uint8Array(16);function Ei(){if(!jt&&(jt=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!jt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return jt(zr)}var $s=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Lr(n){return typeof n=="string"&&$s.test(n)}var Js=Lr;var Q=[];for(Wt=0;Wt<256;++Wt)Q.push((Wt+256).toString(16).substr(1));var Wt;function Rr(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(Q[n[e+0]]+Q[n[e+1]]+Q[n[e+2]]+Q[n[e+3]]+"-"+Q[n[e+4]]+Q[n[e+5]]+"-"+Q[n[e+6]]+Q[n[e+7]]+"-"+Q[n[e+8]]+Q[n[e+9]]+"-"+Q[n[e+10]]+Q[n[e+11]]+Q[n[e+12]]+Q[n[e+13]]+Q[n[e+14]]+Q[n[e+15]]).toLowerCase();if(!Js(t))throw TypeError("Stringified UUID is invalid");return t}var eo=Rr;function Hr(n,e,t){n=n||{};var i=n.random||(n.rng||Ei)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=i[s];return e}return eo(i)}var Ce=Hr;function to(n){return typeof n=="string"||typeof n=="number"}var Vt=class{constructor(e){$(this,"delay");$(this,"max");$(this,"_queue",[]);$(this,"_timeout",null);$(this,"_extended",null);this.delay=null,this.max=1/0,this.setOptions(e)}setOptions(e){e&&typeof e.delay!="undefined"&&(this.delay=e.delay),e&&typeof e.max!="undefined"&&(this.max=e.max),this._flushIfNeeded()}static extend(e,t){let i=new Vt(t);if(e.flush!==void 0)throw new Error("Target object already has a property flush");e.flush=()=>{i.flush()};let s=[{name:"flush",original:void 0}];if(t&&t.replace)for(let o=0;o<t.replace.length;o++){let r=t.replace[o];s.push({name:r,original:e[r]}),i.replace(e,r)}return i._extended={object:e,methods:s},i}destroy(){if(this.flush(),this._extended){let e=this._extended.object,t=this._extended.methods;for(let i=0;i<t.length;i++){let s=t[i];s.original?e[s.name]=s.original:delete e[s.name]}this._extended=null}}replace(e,t){let i=this,s=e[t];if(!s)throw new Error("Method "+t+" undefined");e[t]=function(...o){i.queue({args:o,fn:s,context:this})}}queue(e){typeof e=="function"?this._queue.push({fn:e}):this._queue.push(e),this._flushIfNeeded()}_flushIfNeeded(){this._queue.length>this.max&&this.flush(),this._timeout!=null&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&typeof this.delay=="number"&&(this._timeout=setTimeout(()=>{this.flush()},this.delay))}flush(){this._queue.splice(0).forEach(e=>{e.fn.apply(e.context||e.fn,e.args||[])})}},_t=class{constructor(){$(this,"_subscribers",{"*":[],add:[],remove:[],update:[]});$(this,"subscribe",_t.prototype.on);$(this,"unsubscribe",_t.prototype.off)}_trigger(e,t,i){if(e==="*")throw new Error("Cannot trigger event *");[...this._subscribers[e],...this._subscribers["*"]].forEach(s=>{s(e,t,i!=null?i:null)})}on(e,t){typeof t=="function"&&this._subscribers[e].push(t)}off(e,t){this._subscribers[e]=this._subscribers[e].filter(i=>i!==t)}},Ie=class{constructor(e){$(this,"_pairs");this._pairs=e}*[Symbol.iterator](){for(let[e,t]of this._pairs)yield[e,t]}*entries(){for(let[e,t]of this._pairs)yield[e,t]}*keys(){for(let[e]of this._pairs)yield e}*values(){for(let[,e]of this._pairs)yield e}toIdArray(){return[...this._pairs].map(e=>e[0])}toItemArray(){return[...this._pairs].map(e=>e[1])}toEntryArray(){return[...this._pairs]}toObjectMap(){let e=Object.create(null);for(let[t,i]of this._pairs)e[t]=i;return e}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new Ie([...this._pairs])}distinct(e){let t=new Set;for(let[i,s]of this._pairs)t.add(e(s,i));return t}filter(e){let t=this._pairs;return new Ie({*[Symbol.iterator](){for(let[i,s]of t)e(s,i)&&(yield[i,s])}})}forEach(e){for(let[t,i]of this._pairs)e(i,t)}map(e){let t=this._pairs;return new Ie({*[Symbol.iterator](){for(let[i,s]of t)yield[i,e(s,i)]}})}max(e){let t=this._pairs[Symbol.iterator](),i=t.next();if(i.done)return null;let s=i.value[1],o=e(i.value[1],i.value[0]);for(;!(i=t.next()).done;){let[r,a]=i.value,d=e(a,r);d>o&&(o=d,s=a)}return s}min(e){let t=this._pairs[Symbol.iterator](),i=t.next();if(i.done)return null;let s=i.value[1],o=e(i.value[1],i.value[0]);for(;!(i=t.next()).done;){let[r,a]=i.value,d=e(a,r);d<o&&(o=d,s=a)}return s}reduce(e,t){for(let[i,s]of this._pairs)t=e(t,s,i);return t}sort(e){return new Ie({[Symbol.iterator]:()=>[...this._pairs].sort(([t,i],[s,o])=>e(i,o,t,s))[Symbol.iterator]()})}};function jr(n,e){return n[e]==null&&(n[e]=Ce()),n}var Te=class extends _t{constructor(e,t){super();$(this,"flush");$(this,"length");$(this,"_options");$(this,"_data");$(this,"_idProp");$(this,"_queue",null);e&&!Array.isArray(e)&&(t=e,e=[]),this._options=t||{},this._data=new Map,this.length=0,this._idProp=this._options.fieldId||"id",e&&e.length&&this.add(e),this.setOptions(t)}get idProp(){return this._idProp}setOptions(e){e&&e.queue!==void 0&&(e.queue===!1?this._queue&&(this._queue.destroy(),this._queue=null):(this._queue||(this._queue=Vt.extend(this,{replace:["add","update","remove"]})),e.queue&&typeof e.queue=="object"&&this._queue.setOptions(e.queue)))}add(e,t){let i=[],s;if(Array.isArray(e)){if(e.map(r=>r[this._idProp]).some(r=>this._data.has(r)))throw new Error("A duplicate id was found in the parameter array.");for(let r=0,a=e.length;r<a;r++)s=this._addItem(e[r]),i.push(s)}else if(e&&typeof e=="object")s=this._addItem(e),i.push(s);else throw new Error("Unknown dataType");return i.length&&this._trigger("add",{items:i},t),i}update(e,t){let i=[],s=[],o=[],r=[],a=this._idProp,d=h=>{let l=h[a];if(l!=null&&this._data.has(l)){let c=h,u=Object.assign({},this._data.get(l)),p=this._updateItem(c);s.push(p),r.push(c),o.push(u)}else{let c=this._addItem(h);i.push(c)}};if(Array.isArray(e))for(let h=0,l=e.length;h<l;h++)e[h]&&typeof e[h]=="object"?d(e[h]):console.warn("Ignoring input item, which is not an object at index "+h);else if(e&&typeof e=="object")d(e);else throw new Error("Unknown dataType");if(i.length&&this._trigger("add",{items:i},t),s.length){let h={items:s,oldData:o,data:r};this._trigger("update",h,t)}return i.concat(s)}updateOnly(e,t){Array.isArray(e)||(e=[e]);let i=e.map(s=>{let o=this._data.get(s[this._idProp]);if(o==null)throw new Error("Updating non-existent items is not allowed.");return{oldData:o,update:s}}).map(({oldData:s,update:o})=>{let r=s[this._idProp],a=Ms(s,o);return this._data.set(r,a),{id:r,oldData:s,updatedData:a}});if(i.length){let s={items:i.map(o=>o.id),oldData:i.map(o=>o.oldData),data:i.map(o=>o.updatedData)};return this._trigger("update",s,t),s.items}else return[]}get(e,t){let i,s,o;to(e)?(i=e,o=t):Array.isArray(e)?(s=e,o=t):o=e;let r=o&&o.returnType==="Object"?"Object":"Array",a=o&&o.filter,d=[],h,l,c;if(i!=null)h=this._data.get(i),h&&a&&!a(h)&&(h=void 0);else if(s!=null)for(let u=0,p=s.length;u<p;u++)h=this._data.get(s[u]),h!=null&&(!a||a(h))&&d.push(h);else{l=[...this._data.keys()];for(let u=0,p=l.length;u<p;u++)c=l[u],h=this._data.get(c),h!=null&&(!a||a(h))&&d.push(h)}if(o&&o.order&&i==null&&this._sort(d,o.order),o&&o.fields){let u=o.fields;if(i!=null&&h!=null)h=this._filterFields(h,u);else for(let p=0,b=d.length;p<b;p++)d[p]=this._filterFields(d[p],u)}if(r=="Object"){let u={};for(let p=0,b=d.length;p<b;p++){let C=d[p],f=C[this._idProp];u[f]=C}return u}else return i!=null?h!=null?h:null:d}getIds(e){let t=this._data,i=e&&e.filter,s=e&&e.order,o=[...t.keys()],r=[];if(i)if(s){let a=[];for(let d=0,h=o.length;d<h;d++){let l=o[d],c=this._data.get(l);c!=null&&i(c)&&a.push(c)}this._sort(a,s);for(let d=0,h=a.length;d<h;d++)r.push(a[d][this._idProp])}else for(let a=0,d=o.length;a<d;a++){let h=o[a],l=this._data.get(h);l!=null&&i(l)&&r.push(l[this._idProp])}else if(s){let a=[];for(let d=0,h=o.length;d<h;d++){let l=o[d];a.push(t.get(l))}this._sort(a,s);for(let d=0,h=a.length;d<h;d++)r.push(a[d][this._idProp])}else for(let a=0,d=o.length;a<d;a++){let h=o[a],l=t.get(h);l!=null&&r.push(l[this._idProp])}return r}getDataSet(){return this}forEach(e,t){let i=t&&t.filter,o=[...this._data.keys()];if(t&&t.order){let r=this.get(t);for(let a=0,d=r.length;a<d;a++){let h=r[a],l=h[this._idProp];e(h,l)}}else for(let r=0,a=o.length;r<a;r++){let d=o[r],h=this._data.get(d);h!=null&&(!i||i(h))&&e(h,d)}}map(e,t){let i=t&&t.filter,s=[],r=[...this._data.keys()];for(let a=0,d=r.length;a<d;a++){let h=r[a],l=this._data.get(h);l!=null&&(!i||i(l))&&s.push(e(l,h))}return t&&t.order&&this._sort(s,t.order),s}_filterFields(e,t){return e&&(Array.isArray(t)?t:Object.keys(t)).reduce((i,s)=>(i[s]=e[s],i),{})}_sort(e,t){if(typeof t=="string"){let i=t;e.sort((s,o)=>{let r=s[i],a=o[i];return r>a?1:r<a?-1:0})}else if(typeof t=="function")e.sort(t);else throw new TypeError("Order must be a function or a string")}remove(e,t){let i=[],s=[],o=Array.isArray(e)?e:[e];for(let r=0,a=o.length;r<a;r++){let d=this._remove(o[r]);if(d){let h=d[this._idProp];h!=null&&(i.push(h),s.push(d))}}return i.length&&this._trigger("remove",{items:i,oldData:s},t),i}_remove(e){let t;if(to(e)?t=e:e&&typeof e=="object"&&(t=e[this._idProp]),t!=null&&this._data.has(t)){let i=this._data.get(t)||null;return this._data.delete(t),--this.length,i}return null}clear(e){let t=[...this._data.keys()],i=[];for(let s=0,o=t.length;s<o;s++)i.push(this._data.get(t[s]));return this._data.clear(),this.length=0,this._trigger("remove",{items:t,oldData:i},e),t}max(e){let t=null,i=null;for(let s of this._data.values()){let o=s[e];typeof o=="number"&&(i==null||o>i)&&(t=s,i=o)}return t||null}min(e){let t=null,i=null;for(let s of this._data.values()){let o=s[e];typeof o=="number"&&(i==null||o<i)&&(t=s,i=o)}return t||null}distinct(e){let t=this._data,i=[...t.keys()],s=[],o=0;for(let r=0,a=i.length;r<a;r++){let d=i[r],l=t.get(d)[e],c=!1;for(let u=0;u<o;u++)if(s[u]==l){c=!0;break}!c&&l!==void 0&&(s[o]=l,o++)}return s}_addItem(e){let t=jr(e,this._idProp),i=t[this._idProp];if(this._data.has(i))throw new Error("Cannot add item: item with id "+i+" already exists");return this._data.set(i,t),++this.length,i}_updateItem(e){let t=e[this._idProp];if(t==null)throw new Error("Cannot update item: item has no id (item: "+JSON.stringify(e)+")");let i=this._data.get(t);if(!i)throw new Error("Cannot update item: no item with id "+t+" found");return this._data.set(t,de(de({},i),e)),t}stream(e){if(e){let t=this._data;return new Ie({*[Symbol.iterator](){for(let i of e){let s=t.get(i);s!=null&&(yield[i,s])}}})}else return new Ie({[Symbol.iterator]:this._data.entries.bind(this._data)})}};function Wr(n,e){return typeof e=="object"&&e!==null&&n===e.idProp&&typeof e.add=="function"&&typeof e.clear=="function"&&typeof e.distinct=="function"&&typeof e.forEach=="function"&&typeof e.get=="function"&&typeof e.getDataSet=="function"&&typeof e.getIds=="function"&&typeof e.length=="number"&&typeof e.map=="function"&&typeof e.max=="function"&&typeof e.min=="function"&&typeof e.off=="function"&&typeof e.on=="function"&&typeof e.remove=="function"&&typeof e.setOptions=="function"&&typeof e.stream=="function"&&typeof e.update=="function"&&typeof e.updateOnly=="function"}function xi(n,e){return typeof e=="object"&&e!==null&&n===e.idProp&&typeof e.forEach=="function"&&typeof e.get=="function"&&typeof e.getDataSet=="function"&&typeof e.getIds=="function"&&typeof e.length=="number"&&typeof e.map=="function"&&typeof e.off=="function"&&typeof e.on=="function"&&typeof e.stream=="function"&&Wr(n,e.getDataSet())}var no=ti(si());function qt(n){var e=n&&n.preventDefault||!1,t=n&&n.container||window,i={},s={keydown:{},keyup:{}},o={},r;for(r=97;r<=122;r++)o[String.fromCharCode(r)]={code:65+(r-97),shift:!1};for(r=65;r<=90;r++)o[String.fromCharCode(r)]={code:r,shift:!0};for(r=0;r<=9;r++)o[""+r]={code:48+r,shift:!1};for(r=1;r<=12;r++)o["F"+r]={code:111+r,shift:!1};for(r=0;r<=9;r++)o["num"+r]={code:96+r,shift:!1};o["num*"]={code:106,shift:!1},o["num+"]={code:107,shift:!1},o["num-"]={code:109,shift:!1},o["num/"]={code:111,shift:!1},o["num."]={code:110,shift:!1},o.left={code:37,shift:!1},o.up={code:38,shift:!1},o.right={code:39,shift:!1},o.down={code:40,shift:!1},o.space={code:32,shift:!1},o.enter={code:13,shift:!1},o.shift={code:16,shift:void 0},o.esc={code:27,shift:!1},o.backspace={code:8,shift:!1},o.tab={code:9,shift:!1},o.ctrl={code:17,shift:!1},o.alt={code:18,shift:!1},o.delete={code:46,shift:!1},o.pageup={code:33,shift:!1},o.pagedown={code:34,shift:!1},o["="]={code:187,shift:!1},o["-"]={code:189,shift:!1},o["]"]={code:221,shift:!1},o["["]={code:219,shift:!1};var a=function(l){h(l,"keydown")},d=function(l){h(l,"keyup")},h=function(l,c){if(s[c][l.keyCode]!==void 0){for(var u=s[c][l.keyCode],p=0;p<u.length;p++)(u[p].shift===void 0||u[p].shift==!0&&l.shiftKey==!0||u[p].shift==!1&&l.shiftKey==!1)&&u[p].fn(l);e==!0&&l.preventDefault()}};return i.bind=function(l,c,u){if(u===void 0&&(u="keydown"),o[l]===void 0)throw new Error("unsupported key: "+l);s[u][o[l].code]===void 0&&(s[u][o[l].code]=[]),s[u][o[l].code].push({fn:c,shift:o[l].shift})},i.bindAll=function(l,c){c===void 0&&(c="keydown");for(var u in o)o.hasOwnProperty(u)&&i.bind(u,l,c)},i.getKey=function(l){for(var c in o)if(o.hasOwnProperty(c)){if(l.shiftKey==!0&&o[c].shift==!0&&l.keyCode==o[c].code)return c;if(l.shiftKey==!1&&o[c].shift==!1&&l.keyCode==o[c].code)return c;if(l.keyCode==o[c].code&&c=="shift")return c}return"unknown key, currently not supported"},i.unbind=function(l,c,u){if(u===void 0&&(u="keydown"),o[l]===void 0)throw new Error("unsupported key: "+l);if(c!==void 0){var p=[],b=s[u][o[l].code];if(b!==void 0)for(var C=0;C<b.length;C++)b[C].fn==c&&b[C].shift==o[l].shift||p.push(s[u][o[l].code][C]);s[u][o[l].code]=p}else s[u][o[l].code]=[]},i.reset=function(){s={keydown:{},keyup:{}}},i.destroy=function(){s={keydown:{},keyup:{}},t.removeEventListener("keydown",a,!0),t.removeEventListener("keyup",d,!0)},t.addEventListener("keydown",a,!0),t.addEventListener("keyup",d,!0),i}var Et=ti(oo());function Ci(n,e,t,i){n.beginPath(),n.arc(e,t,i,0,2*Math.PI,!1),n.closePath()}function Vr(n,e,t,i){n.beginPath(),n.rect(e-i,t-i,i*2,i*2),n.closePath()}function qr(n,e,t,i){n.beginPath(),i*=1.15,t+=.275*i;let s=i*2,o=s/2,r=Math.sqrt(3)/6*s,a=Math.sqrt(s*s-o*o);n.moveTo(e,t-(a-r)),n.lineTo(e+o,t+r),n.lineTo(e-o,t+r),n.lineTo(e,t-(a-r)),n.closePath()}function Ur(n,e,t,i){n.beginPath(),i*=1.15,t-=.275*i;let s=i*2,o=s/2,r=Math.sqrt(3)/6*s,a=Math.sqrt(s*s-o*o);n.moveTo(e,t+(a-r)),n.lineTo(e+o,t-r),n.lineTo(e-o,t-r),n.lineTo(e,t+(a-r)),n.closePath()}function Yr(n,e,t,i){n.beginPath(),i*=.82,t+=.1*i;for(let s=0;s<10;s++){let o=s%2==0?i*1.3:i*.5;n.lineTo(e+o*Math.sin(s*2*Math.PI/10),t-o*Math.cos(s*2*Math.PI/10))}n.closePath()}function Xr(n,e,t,i){n.beginPath(),n.lineTo(e,t+i),n.lineTo(e+i,t),n.lineTo(e,t-i),n.lineTo(e-i,t),n.closePath()}function ro(n,e,t,i,s,o){let r=Math.PI/180;i-2*o<0&&(o=i/2),s-2*o<0&&(o=s/2),n.beginPath(),n.moveTo(e+o,t),n.lineTo(e+i-o,t),n.arc(e+i-o,t+o,o,r*270,r*360,!1),n.lineTo(e+i,t+s-o),n.arc(e+i-o,t+s-o,o,0,r*90,!1),n.lineTo(e+o,t+s),n.arc(e+o,t+s-o,o,r*90,r*180,!1),n.lineTo(e,t+o),n.arc(e+o,t+o,o,r*180,r*270,!1),n.closePath()}function Ti(n,e,t,i,s){let o=.5522848,r=i/2*o,a=s/2*o,d=e+i,h=t+s,l=e+i/2,c=t+s/2;n.beginPath(),n.moveTo(e,c),n.bezierCurveTo(e,c-a,l-r,t,l,t),n.bezierCurveTo(l+r,t,d,c-a,d,c),n.bezierCurveTo(d,c+a,l+r,h,l,h),n.bezierCurveTo(l-r,h,e,c+a,e,c),n.closePath()}function ao(n,e,t,i,s){let o=1/3,r=i,a=s*o,d=.5522848,h=r/2*d,l=a/2*d,c=e+r,u=t+a,p=e+r/2,b=t+a/2,C=t+(s-a/2),f=t+s;n.beginPath(),n.moveTo(c,b),n.bezierCurveTo(c,b+l,p+h,u,p,u),n.bezierCurveTo(p-h,u,e,b+l,e,b),n.bezierCurveTo(e,b-l,p-h,t,p,t),n.bezierCurveTo(p+h,t,c,b-l,c,b),n.lineTo(c,C),n.bezierCurveTo(c,C+l,p+h,f,p,f),n.bezierCurveTo(p-h,f,e,C+l,e,C),n.lineTo(e,b)}function ho(n,e,t,i,s,o){n.beginPath(),n.moveTo(e,t);let r=o.length,a=i-e,d=s-t,h=d/a,l=Math.sqrt(a*a+d*d),c=0,u=!0,p=0,b=+o[0];for(;l>=.1;)b=+o[c++%r],b>l&&(b=l),p=Math.sqrt(b*b/(1+h*h)),p=a<0?-p:p,e+=p,t+=h*p,u===!0?n.lineTo(e,t):n.moveTo(e,t),l-=b,u=!u}function Gr(n,e,t,i){n.beginPath();let s=6,o=Math.PI*2/s;n.moveTo(e+i,t);for(let r=1;r<s;r++)n.lineTo(e+i*Math.cos(o*r),t+i*Math.sin(o*r));n.closePath()}var lo={circle:Ci,dashedLine:ho,database:ao,diamond:Xr,ellipse:Ti,ellipse_vis:Ti,hexagon:Gr,roundRect:ro,square:Vr,star:Yr,triangle:qr,triangleDown:Ur};function Kr(n){return Object.prototype.hasOwnProperty.call(lo,n)?lo[n]:function(e,...t){CanvasRenderingContext2D.prototype[n].call(e,t)}}function Zr(n){return Pe=n,ea()}var co={fontsize:"font.size",fontcolor:"font.color",labelfontcolor:"font.color",fontname:"font.face",color:["color.border","color.background"],fillcolor:"color.background",tooltip:"title",labeltooltip:"title"},ki=Object.create(co);ki.color="color.color";ki.style="dashes";var te={NULL:0,DELIMITER:1,IDENTIFIER:2,UNKNOWN:3},uo={"{":!0,"}":!0,"[":!0,"]":!0,";":!0,"=":!0,",":!0,"->":!0,"--":!0},Pe="",it=0,z="",M="",oe=te.NULL;function Qr(){it=0,z=Pe.charAt(0)}function Z(){it++,z=Pe.charAt(it)}function st(){return Pe.charAt(it+1)}function fo(n){var e=n.charCodeAt(0);return e<47?e===35||e===46:e<59?e>47:e<91?e>64:e<96?e===95:e<123?e>96:!1}function Me(n,e){if(n||(n={}),e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function $r(n,e,t){for(var i=e.split("."),s=n;i.length;){var o=i.shift();i.length?(s[o]||(s[o]={}),s=s[o]):s[o]=t}}function po(n,e){for(var t,i,s=null,o=[n],r=n;r.parent;)o.push(r.parent),r=r.parent;if(r.nodes){for(t=0,i=r.nodes.length;t<i;t++)if(e.id===r.nodes[t].id){s=r.nodes[t];break}}for(s||(s={id:e.id},n.node&&(s.attr=Me(s.attr,n.node))),t=o.length-1;t>=0;t--){var a=o[t];a.nodes||(a.nodes=[]),a.nodes.indexOf(s)===-1&&a.nodes.push(s)}e.attr&&(s.attr=Me(s.attr,e.attr))}function Jr(n,e){if(n.edges||(n.edges=[]),n.edges.push(e),n.edge){var t=Me({},n.edge);e.attr=Me(t,e.attr)}}function go(n,e,t,i,s){var o={from:e,to:t,type:i};return n.edge&&(o.attr=Me({},n.edge)),o.attr=Me(o.attr||{},s),s!=null&&s.hasOwnProperty("arrows")&&s.arrows!=null&&(o.arrows={to:{enabled:!0,type:s.arrows.type}},s.arrows=null),o}function V(){for(oe=te.NULL,M="";z===" "||z===" "||z===`
`||z==="\r";)Z();do{var n=!1;if(z==="#"){for(var e=it-1;Pe.charAt(e)===" "||Pe.charAt(e)===" ";)e--;if(Pe.charAt(e)===`
`||Pe.charAt(e)===""){for(;z!=""&&z!=`
`;)Z();n=!0}}if(z==="/"&&st()==="/"){for(;z!=""&&z!=`
`;)Z();n=!0}if(z==="/"&&st()==="*"){for(;z!="";)if(z==="*"&&st()==="/"){Z(),Z();break}else Z();n=!0}for(;z===" "||z===" "||z===`
`||z==="\r";)Z()}while(n);if(z===""){oe=te.DELIMITER;return}var t=z+st();if(uo[t]){oe=te.DELIMITER,M=t,Z(),Z();return}if(uo[z]){oe=te.DELIMITER,M=z,Z();return}if(fo(z)||z==="-"){for(M+=z,Z();fo(z);)M+=z,Z();M==="false"?M=!1:M==="true"?M=!0:isNaN(Number(M))||(M=Number(M)),oe=te.IDENTIFIER;return}if(z==='"'){for(Z();z!=""&&(z!='"'||z==='"'&&st()==='"');)z==='"'?(M+=z,Z()):z==="\\"&&st()==="n"?(M+=`
`,Z()):M+=z,Z();if(z!='"')throw ie('End of string " expected');Z(),oe=te.IDENTIFIER;return}for(oe=te.UNKNOWN;z!="";)M+=z,Z();throw new SyntaxError('Syntax error in part "'+vo(M,30)+'"')}function ea(){var n={};if(Qr(),V(),M==="strict"&&(n.strict=!0,V()),(M==="graph"||M==="digraph")&&(n.type=M,V()),oe===te.IDENTIFIER&&(n.id=M,V()),M!="{")throw ie("Angle bracket { expected");if(V(),mo(n),M!="}")throw ie("Angle bracket } expected");if(V(),M!=="")throw ie("End of file expected");return V(),delete n.node,delete n.edge,delete n.graph,n}function mo(n){for(;M!==""&&M!="}";)ta(n),M===";"&&V()}function ta(n){var e=yo(n);if(e){bo(n,e);return}var t=ia(n);if(!t){if(oe!=te.IDENTIFIER)throw ie("Identifier expected");var i=M;if(V(),M==="="){if(V(),oe!=te.IDENTIFIER)throw ie("Identifier expected");n[i]=M,V()}else sa(n,i)}}function yo(n){var e=null;if(M==="subgraph"&&(e={},e.type="subgraph",V(),oe===te.IDENTIFIER&&(e.id=M,V())),M==="{"){if(V(),e||(e={}),e.parent=n,e.node=n.node,e.edge=n.edge,e.graph=n.graph,mo(e),M!="}")throw ie("Angle bracket } expected");V(),delete e.node,delete e.edge,delete e.graph,delete e.parent,n.subgraphs||(n.subgraphs=[]),n.subgraphs.push(e)}return e}function ia(n){return M==="node"?(V(),n.node=xt(),"node"):M==="edge"?(V(),n.edge=xt(),"edge"):M==="graph"?(V(),n.graph=xt(),"graph"):null}function sa(n,e){var t={id:e},i=xt();i&&(t.attr=i),po(n,t),bo(n,e)}function bo(n,e){for(;M==="->"||M==="--";){var t,i=M;V();var s=yo(n);if(s)t=s;else{if(oe!=te.IDENTIFIER)throw ie("Identifier or subgraph expected");t=M,po(n,{id:t}),V()}var o=xt(),r=go(n,e,t,i,o);Jr(n,r),e=t}}function xt(){for(var n,e=null,t={dashed:!0,solid:!1,dotted:[1,5]},i={dot:"circle",box:"box",crow:"crow",curve:"curve",icurve:"inv_curve",normal:"triangle",inv:"inv_triangle",diamond:"diamond",tee:"bar",vee:"vee"},s=new Array,o=new Array;M==="[";){for(V(),e={};M!==""&&M!="]";){if(oe!=te.IDENTIFIER)throw ie("Attribute name expected");var r=M;if(V(),M!="=")throw ie("Equal sign = expected");if(V(),oe!=te.IDENTIFIER)throw ie("Attribute value expected");var a=M;r==="style"&&(a=t[a]);var d;r==="arrowhead"&&(d=i[a],r="arrows",a={to:{enabled:!0,type:d}}),r==="arrowtail"&&(d=i[a],r="arrows",a={from:{enabled:!0,type:d}}),s.push({attr:e,name:r,value:a}),o.push(r),V(),M==","&&V()}if(M!="]")throw ie("Bracket ] expected");V()}if(o.includes("dir")){var h={};for(h.arrows={},n=0;n<s.length;n++)if(s[n].name==="arrows")if(s[n].value.to!=null)h.arrows.to=n;else if(s[n].value.from!=null)h.arrows.from=n;else throw ie("Invalid value of arrows");else s[n].name==="dir"&&(h.dir=n);var l=s[h.dir].value;if(!o.includes("arrows"))if(l==="both")s.push({attr:s[h.dir].attr,name:"arrows",value:{to:{enabled:!0}}}),h.arrows.to=s.length-1,s.push({attr:s[h.dir].attr,name:"arrows",value:{from:{enabled:!0}}}),h.arrows.from=s.length-1;else if(l==="forward")s.push({attr:s[h.dir].attr,name:"arrows",value:{to:{enabled:!0}}}),h.arrows.to=s.length-1;else if(l==="back")s.push({attr:s[h.dir].attr,name:"arrows",value:{from:{enabled:!0}}}),h.arrows.from=s.length-1;else if(l==="none")s.push({attr:s[h.dir].attr,name:"arrows",value:""}),h.arrows.to=s.length-1;else throw ie('Invalid dir type "'+l+'"');var c,u;if(l==="both")h.arrows.to&&h.arrows.from?(u=s[h.arrows.to].value.to.type,c=s[h.arrows.from].value.from.type,s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}},s.splice(h.arrows.from,1)):h.arrows.to?(u=s[h.arrows.to].value.to.type,c="arrow",s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.from&&(u="arrow",c=s[h.arrows.from].value.from.type,s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}});else if(l==="back")h.arrows.to&&h.arrows.from?(u="",c=s[h.arrows.from].value.from.type,s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.to?(u="",c="arrow",h.arrows.from=h.arrows.to,s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.from&&(u="",c=s[h.arrows.from].value.from.type,s[h.arrows.to]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}),s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{from:{enabled:!0,type:s[h.arrows.from].value.from.type}}};else if(l==="none"){var p;h.arrows.to?p=h.arrows.to:p=h.arrows.from,s[p]={attr:s[p].attr,name:s[p].name,value:""}}else if(l==="forward")h.arrows.to&&h.arrows.from?(u=s[h.arrows.to].value.to.type,c="",s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.to?(u=s[h.arrows.to].value.to.type,c="",s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.from&&(u="arrow",c="",h.arrows.to=h.arrows.from,s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}),s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:s[h.arrows.to].value.to.type}}};else throw ie('Invalid dir type "'+l+'"');s.splice(h.dir,1)}var b;if(o.includes("penwidth")){var C=[];for(b=s.length,n=0;n<b;n++)s[n].name!=="width"&&(s[n].name==="penwidth"&&(s[n].name="width"),C.push(s[n]));s=C}for(b=s.length,n=0;n<b;n++)$r(s[n].attr,s[n].name,s[n].value);return e}function ie(n){return new SyntaxError(n+', got "'+vo(M,30)+'" (char '+it+")")}function vo(n,e){return n.length<=e?n:n.substr(0,27)+"..."}function oa(n,e,t){Array.isArray(n)?n.forEach(function(i){Array.isArray(e)?e.forEach(function(s){t(i,s)}):t(i,e)}):Array.isArray(e)?e.forEach(function(i){t(n,i)}):t(n,e)}function Si(n,e,t){for(var i=e.split("."),s=i.pop(),o=n,r=0;r<i.length;r++){var a=i[r];a in o||(o[a]={}),o=o[a]}return o[s]=t,n}function wo(n,e){var t={};for(var i in n)if(n.hasOwnProperty(i)){var s=e[i];Array.isArray(s)?s.forEach(function(o){Si(t,o,n[i])}):typeof s=="string"?Si(t,s,n[i]):Si(t,i,n[i])}return t}function na(n){var e=Zr(n),t={nodes:[],edges:[],options:{}};if(e.nodes&&e.nodes.forEach(function(s){var o={id:s.id,label:String(s.label||s.id)};Me(o,wo(s.attr,co)),o.image&&(o.shape="image"),t.nodes.push(o)}),e.edges){var i=function(s){var o={from:s.from,to:s.to};return Me(o,wo(s.attr,ki)),o.arrows==null&&s.type==="->"&&(o.arrows="to"),o};e.edges.forEach(function(s){var o,r;s.from instanceof Object?o=s.from.nodes:o={id:s.from},s.to instanceof Object?r=s.to.nodes:r={id:s.to},s.from instanceof Object&&s.from.edges&&s.from.edges.forEach(function(a){var d=i(a);t.edges.push(d)}),oa(o,r,function(a,d){var h=go(t,a.id,d.id,s.type,s.attr),l=i(h);t.edges.push(l)}),s.to instanceof Object&&s.to.edges&&s.to.edges.forEach(function(a){var d=i(a);t.edges.push(d)})})}return e.attr&&(t.options=e.attr),t}function ra(n,e){let t={edges:{inheritColor:!1},nodes:{fixed:!1,parseColor:!1}};e!=null&&(e.fixed!=null&&(t.nodes.fixed=e.fixed),e.parseColor!=null&&(t.nodes.parseColor=e.parseColor),e.inheritColor!=null&&(t.edges.inheritColor=e.inheritColor));let s=n.edges.map(r=>{let a={from:r.source,id:r.id,to:r.target};return r.attributes!=null&&(a.attributes=r.attributes),r.label!=null&&(a.label=r.label),r.attributes!=null&&r.attributes.title!=null&&(a.title=r.attributes.title),r.type==="Directed"&&(a.arrows="to"),r.color&&t.edges.inheritColor===!1&&(a.color=r.color),a});return{nodes:n.nodes.map(r=>{let a={id:r.id,fixed:t.nodes.fixed&&r.x!=null&&r.y!=null};return r.attributes!=null&&(a.attributes=r.attributes),r.label!=null&&(a.label=r.label),r.size!=null&&(a.size=r.size),r.attributes!=null&&r.attributes.title!=null&&(a.title=r.attributes.title),r.title!=null&&(a.title=r.title),r.x!=null&&(a.x=r.x),r.y!=null&&(a.y=r.y),r.color!=null&&(t.nodes.parseColor===!0?a.color=r.color:a.color={background:r.color,border:r.color,highlight:{background:r.color,border:r.color},hover:{background:r.color,border:r.color}}),a}),edges:s}}var aa={addDescription:"Click in an empty space to place a new node.",addEdge:"Add Edge",addNode:"Add Node",back:"Back",close:"Close",createEdgeError:"Cannot link edges to a cluster.",del:"Delete selected",deleteClusterError:"Clusters cannot be deleted.",edgeDescription:"Click on a node and drag the edge to another node to connect them.",edit:"Edit",editClusterError:"Clusters cannot be edited.",editEdge:"Edit Edge",editEdgeDescription:"Click on the control points and drag them to a node to connect to it.",editNode:"Edit Node"},da={addDescription:"Klicke auf eine freie Stelle, um einen neuen Knoten zu plazieren.",addEdge:"Kante hinzuf\xFCgen",addNode:"Knoten hinzuf\xFCgen",back:"Zur\xFCck",close:"Schlie\xDFen",createEdgeError:"Es ist nicht m\xF6glich, Kanten mit Clustern zu verbinden.",del:"L\xF6sche Auswahl",deleteClusterError:"Cluster k\xF6nnen nicht gel\xF6scht werden.",edgeDescription:"Klicke auf einen Knoten und ziehe die Kante zu einem anderen Knoten, um diese zu verbinden.",edit:"Editieren",editClusterError:"Cluster k\xF6nnen nicht editiert werden.",editEdge:"Kante editieren",editEdgeDescription:"Klicke auf die Verbindungspunkte und ziehe diese auf einen Knoten, um sie zu verbinden.",editNode:"Knoten editieren"},ha={addDescription:"Haga clic en un lugar vac\xEDo para colocar un nuevo nodo.",addEdge:"A\xF1adir arista",addNode:"A\xF1adir nodo",back:"Atr\xE1s",close:"Cerrar",createEdgeError:"No se puede conectar una arista a un grupo.",del:"Eliminar selecci\xF3n",deleteClusterError:"No es posible eliminar grupos.",edgeDescription:"Haga clic en un nodo y arrastre la arista hacia otro nodo para conectarlos.",edit:"Editar",editClusterError:"No es posible editar grupos.",editEdge:"Editar arista",editEdgeDescription:"Haga clic en un punto de control y arrastrelo a un nodo para conectarlo.",editNode:"Editar nodo"},la={addDescription:"Clicca per aggiungere un nuovo nodo",addEdge:"Aggiungi un vertice",addNode:"Aggiungi un nodo",back:"Indietro",close:"Chiudere",createEdgeError:"Non si possono collegare vertici ad un cluster",del:"Cancella la selezione",deleteClusterError:"I cluster non possono essere cancellati",edgeDescription:"Clicca su un nodo e trascinalo ad un altro nodo per connetterli.",edit:"Modifica",editClusterError:"I clusters non possono essere modificati.",editEdge:"Modifica il vertice",editEdgeDescription:"Clicca sui Punti di controllo e trascinali ad un nodo per connetterli.",editNode:"Modifica il nodo"},ca={addDescription:"Klik op een leeg gebied om een nieuwe node te maken.",addEdge:"Link toevoegen",addNode:"Node toevoegen",back:"Terug",close:"Sluiten",createEdgeError:"Kan geen link maken naar een cluster.",del:"Selectie verwijderen",deleteClusterError:"Clusters kunnen niet worden verwijderd.",edgeDescription:"Klik op een node en sleep de link naar een andere node om ze te verbinden.",edit:"Wijzigen",editClusterError:"Clusters kunnen niet worden aangepast.",editEdge:"Link wijzigen",editEdgeDescription:"Klik op de verbindingspunten en sleep ze naar een node om daarmee te verbinden.",editNode:"Node wijzigen"},ua={addDescription:"Clique em um espa\xE7o em branco para adicionar um novo n\xF3",addEdge:"Adicionar aresta",addNode:"Adicionar n\xF3",back:"Voltar",close:"Fechar",createEdgeError:"N\xE3o foi poss\xEDvel linkar arestas a um cluster.",del:"Remover selecionado",deleteClusterError:"Clusters n\xE3o puderam ser removidos.",edgeDescription:"Clique em um n\xF3 e arraste a aresta at\xE9 outro n\xF3 para conect\xE1-los",edit:"Editar",editClusterError:"Clusters n\xE3o puderam ser editados.",editEdge:"Editar aresta",editEdgeDescription:"Clique nos pontos de controle e os arraste para um n\xF3 para conect\xE1-los",editNode:"Editar n\xF3"},fa={addDescription:"\u041A\u043B\u0438\u043A\u043D\u0438\u0442\u0435 \u0432 \u0441\u0432\u043E\u0431\u043E\u0434\u043D\u043E\u0435 \u043C\u0435\u0441\u0442\u043E, \u0447\u0442\u043E\u0431\u044B \u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043D\u043E\u0432\u044B\u0439 \u0443\u0437\u0435\u043B.",addEdge:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0440\u0435\u0431\u0440\u043E",addNode:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0443\u0437\u0435\u043B",back:"\u041D\u0430\u0437\u0430\u0434",close:"\u0417\u0430\u043A\u0440\u044B\u0432\u0430\u0442\u044C",createEdgeError:"\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0441\u043E\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u0440\u0435\u0431\u0440\u0430 \u0432 \u043A\u043B\u0430\u0441\u0442\u0435\u0440.",del:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u0435",deleteClusterError:"\u041A\u043B\u0430\u0441\u0442\u0435\u0440\u044B \u043D\u0435 \u043C\u043E\u0433\u0443\u0442 \u0431\u044B\u0442\u044C \u0443\u0434\u0430\u043B\u0435\u043D\u044B",edgeDescription:"\u041A\u043B\u0438\u043A\u043D\u0438\u0442\u0435 \u043D\u0430 \u0443\u0437\u0435\u043B \u0438 \u043F\u0440\u043E\u0442\u044F\u043D\u0438\u0442\u0435 \u0440\u0435\u0431\u0440\u043E \u043A \u0434\u0440\u0443\u0433\u043E\u043C\u0443 \u0443\u0437\u043B\u0443, \u0447\u0442\u043E\u0431\u044B \u0441\u043E\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u0438\u0445.",edit:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",editClusterError:"\u041A\u043B\u0430\u0441\u0442\u0435\u0440\u044B \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F.",editEdge:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0440\u0435\u0431\u0440\u043E",editEdgeDescription:"\u041A\u043B\u0438\u043A\u043D\u0438\u0442\u0435 \u043D\u0430 \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044C\u043D\u044B\u0435 \u0442\u043E\u0447\u043A\u0438 \u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0438\u0445 \u0432 \u0443\u0437\u0435\u043B, \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043A \u043D\u0435\u043C\u0443.",editNode:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0443\u0437\u0435\u043B"},pa={addDescription:"\u5355\u51FB\u7A7A\u767D\u5904\u653E\u7F6E\u65B0\u8282\u70B9\u3002",addEdge:"\u6DFB\u52A0\u8FDE\u63A5\u7EBF",addNode:"\u6DFB\u52A0\u8282\u70B9",back:"\u8FD4\u56DE",close:"\u95DC\u9589",createEdgeError:"\u65E0\u6CD5\u5C06\u8FDE\u63A5\u7EBF\u8FDE\u63A5\u5230\u7FA4\u96C6\u3002",del:"\u5220\u9664\u9009\u5B9A",deleteClusterError:"\u65E0\u6CD5\u5220\u9664\u7FA4\u96C6\u3002",edgeDescription:"\u5355\u51FB\u67D0\u4E2A\u8282\u70B9\u5E76\u5C06\u8BE5\u8FDE\u63A5\u7EBF\u62D6\u52A8\u5230\u53E6\u4E00\u4E2A\u8282\u70B9\u4EE5\u8FDE\u63A5\u5B83\u4EEC\u3002",edit:"\u7F16\u8F91",editClusterError:"\u65E0\u6CD5\u7F16\u8F91\u7FA4\u96C6\u3002",editEdge:"\u7F16\u8F91\u8FDE\u63A5\u7EBF",editEdgeDescription:"\u5355\u51FB\u63A7\u5236\u8282\u70B9\u5E76\u5C06\u5B83\u4EEC\u62D6\u5230\u8282\u70B9\u4E0A\u8FDE\u63A5\u3002",editNode:"\u7F16\u8F91\u8282\u70B9"},ga={addDescription:"K\u043B\u0456\u043A\u043D\u0456\u0442\u044C \u043D\u0430 \u0432\u0456\u043B\u044C\u043D\u0435 \u043C\u0456\u0441\u0446\u0435, \u0449\u043E\u0431 \u0434\u043E\u0434\u0430\u0442\u0438 \u043D\u043E\u0432\u0438\u0439 \u0432\u0443\u0437\u043E\u043B.",addEdge:"\u0414\u043E\u0434\u0430\u0442\u0438 \u043A\u0440\u0430\u0439",addNode:"\u0414\u043E\u0434\u0430\u0442\u0438 \u0432\u0443\u0437\u043E\u043B",back:"\u041D\u0430\u0437\u0430\u0434",close:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438",createEdgeError:"\u041D\u0435 \u043C\u043E\u0436\u043B\u0438\u0432\u043E \u043E\u0431'\u0454\u0434\u043D\u0430\u0442\u0438 \u043A\u0440\u0430\u0457 \u0432 \u0433\u0440\u0443\u043F\u0443.",del:"\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u043E\u0431\u0440\u0430\u043D\u0435",deleteClusterError:"\u0413\u0440\u0443\u043F\u0438 \u043D\u0435 \u043C\u043E\u0436\u0443\u0442\u044C \u0431\u0443\u0442\u0438 \u0432\u0438\u0434\u0430\u043B\u0435\u043D\u0456.",edgeDescription:"\u041A\u043B\u0456\u043A\u043D\u0456\u0442\u044C \u043D\u0430 \u0432\u0443\u0437\u043E\u043B \u0456 \u043F\u0435\u0440\u0435\u0442\u044F\u0433\u043D\u0456\u0442\u044C \u043A\u0440\u0430\u0439 \u0434\u043E \u0456\u043D\u0448\u043E\u0433\u043E \u0432\u0443\u0437\u043B\u0430, \u0449\u043E\u0431 \u0457\u0445 \u0437'\u0454\u0434\u043D\u0430\u0442\u0438.",edit:"\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438",editClusterError:"\u0413\u0440\u0443\u043F\u0438 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0456 \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043D\u043D\u044F.",editEdge:"\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438 \u043A\u0440\u0430\u0439",editEdgeDescription:"\u041A\u043B\u0456\u043A\u043D\u0456\u0442\u044C \u043D\u0430 \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044C\u043D\u0456 \u0442\u043E\u0447\u043A\u0438 \u0456 \u043F\u0435\u0440\u0435\u0442\u044F\u0433\u043D\u0456\u0442\u044C \u0457\u0445 \u0443 \u0432\u0443\u0437\u043E\u043B, \u0449\u043E\u0431 \u043F\u0456\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F \u0434\u043E \u043D\u044C\u043E\u0433\u043E.",editNode:"\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438 \u0432\u0443\u0437\u043E\u043B"},ma={addDescription:"Cliquez dans un endroit vide pour placer un n\u0153ud.",addEdge:"Ajouter un lien",addNode:"Ajouter un n\u0153ud",back:"Retour",close:"Fermer",createEdgeError:"Impossible de cr\xE9er un lien vers un cluster.",del:"Effacer la s\xE9lection",deleteClusterError:"Les clusters ne peuvent pas \xEAtre effac\xE9s.",edgeDescription:"Cliquez sur un n\u0153ud et glissez le lien vers un autre n\u0153ud pour les connecter.",edit:"\xC9diter",editClusterError:"Les clusters ne peuvent pas \xEAtre \xE9dit\xE9s.",editEdge:"\xC9diter le lien",editEdgeDescription:"Cliquez sur les points de contr\xF4le et glissez-les pour connecter un n\u0153ud.",editNode:"\xC9diter le n\u0153ud"},ya={addDescription:"Kluknut\xEDm do pr\xE1zdn\xE9ho prostoru m\u016F\u017Eete p\u0159idat nov\xFD vrchol.",addEdge:"P\u0159idat hranu",addNode:"P\u0159idat vrchol",back:"Zp\u011Bt",close:"Zav\u0159\xEDt",createEdgeError:"Nelze p\u0159ipojit hranu ke shluku.",del:"Smazat v\xFDb\u011Br",deleteClusterError:"Nelze mazat shluky.",edgeDescription:"P\u0159eta\u017Een\xEDm z jednoho vrcholu do druh\xE9ho m\u016F\u017Eete spojit tyto vrcholy novou hranou.",edit:"Upravit",editClusterError:"Nelze upravovat shluky.",editEdge:"Upravit hranu",editEdgeDescription:"P\u0159eta\u017Een\xEDm kontroln\xEDho vrcholu hrany ji m\u016F\u017Eete p\u0159ipojit k jin\xE9mu vrcholu.",editNode:"Upravit vrchol"},ba=Object.freeze({__proto__:null,cn:pa,cs:ya,de:da,en:aa,es:ha,fr:ma,it:la,nl:ca,pt:ua,ru:fa,uk:ga});function va(n,e){try{let[t,i]=e.split(/[-_ /]/,2),s=t!=null?t.toLowerCase():null,o=i!=null?i.toUpperCase():null;if(s&&o){let r=s+"-"+o;if(Object.prototype.hasOwnProperty.call(n,r))return r;console.warn(`Unknown variant ${o} of language ${s}.`)}if(s){let r=s;if(Object.prototype.hasOwnProperty.call(n,r))return r;console.warn(`Unknown language ${s}`)}return console.warn(`Unknown locale ${e}, falling back to English.`),"en"}catch(t){return console.error(t),console.warn(`Unexpected error while normalizing locale ${e}, falling back to English.`),"en"}}var _o=class{constructor(){this.NUM_ITERATIONS=4,this.image=new Image,this.canvas=document.createElement("canvas")}init(){if(this.initialized())return;this.src=this.image.src;let e=this.image.width,t=this.image.height;this.width=e,this.height=t;let i=Math.floor(t/2),s=Math.floor(t/4),o=Math.floor(t/8),r=Math.floor(t/16),a=Math.floor(e/2),d=Math.floor(e/4),h=Math.floor(e/8),l=Math.floor(e/16);this.canvas.width=3*d,this.canvas.height=i,this.coordinates=[[0,0,a,i],[a,0,d,s],[a,s,h,o],[5*h,s,l,r]],this._fillMipMap()}initialized(){return this.coordinates!==void 0}_fillMipMap(){let e=this.canvas.getContext("2d"),t=this.coordinates[0];e.drawImage(this.image,t[0],t[1],t[2],t[3]);for(let i=1;i<this.NUM_ITERATIONS;i++){let s=this.coordinates[i-1],o=this.coordinates[i];e.drawImage(this.canvas,s[0],s[1],s[2],s[3],o[0],o[1],o[2],o[3])}}drawImageAtPosition(e,t,i,s,o,r){if(!!this.initialized())if(t>2){t*=.5;let a=0;for(;t>2&&a<this.NUM_ITERATIONS;)t*=.5,a+=1;a>=this.NUM_ITERATIONS&&(a=this.NUM_ITERATIONS-1);let d=this.coordinates[a];e.drawImage(this.canvas,d[0],d[1],d[2],d[3],i,s,o,r)}else e.drawImage(this.image,i,s,o,r)}},Eo=class{constructor(e){this.images={},this.imageBroken={},this.callback=e}_tryloadBrokenUrl(e,t,i){if(!(e===void 0||i===void 0)){if(t===void 0){console.warn("No broken url image defined");return}i.image.onerror=()=>{console.error("Could not load brokenImage:",t)},i.image.src=t}}_redrawWithImage(e){this.callback&&this.callback(e)}load(e,t){let i=this.images[e];if(i)return i;let s=new _o;return this.images[e]=s,s.image.onload=()=>{this._fixImageCoordinates(s.image),s.init(),this._redrawWithImage(s)},s.image.onerror=()=>{console.error("Could not load image:",e),this._tryloadBrokenUrl(e,t,s)},s.image.src=e,s}_fixImageCoordinates(e){e.width===0&&(document.body.appendChild(e),e.width=e.offsetWidth,e.height=e.offsetHeight,document.body.removeChild(e))}},xo=class{constructor(){this.clear(),this._defaultIndex=0,this._groupIndex=0,this._defaultGroups=[{border:"#2B7CE9",background:"#97C2FC",highlight:{border:"#2B7CE9",background:"#D2E5FF"},hover:{border:"#2B7CE9",background:"#D2E5FF"}},{border:"#FFA500",background:"#FFFF00",highlight:{border:"#FFA500",background:"#FFFFA3"},hover:{border:"#FFA500",background:"#FFFFA3"}},{border:"#FA0A10",background:"#FB7E81",highlight:{border:"#FA0A10",background:"#FFAFB1"},hover:{border:"#FA0A10",background:"#FFAFB1"}},{border:"#41A906",background:"#7BE141",highlight:{border:"#41A906",background:"#A1EC76"},hover:{border:"#41A906",background:"#A1EC76"}},{border:"#E129F0",background:"#EB7DF4",highlight:{border:"#E129F0",background:"#F0B3F5"},hover:{border:"#E129F0",background:"#F0B3F5"}},{border:"#7C29F0",background:"#AD85E4",highlight:{border:"#7C29F0",background:"#D3BDF0"},hover:{border:"#7C29F0",background:"#D3BDF0"}},{border:"#C37F00",background:"#FFA807",highlight:{border:"#C37F00",background:"#FFCA66"},hover:{border:"#C37F00",background:"#FFCA66"}},{border:"#4220FB",background:"#6E6EFD",highlight:{border:"#4220FB",background:"#9B9BFD"},hover:{border:"#4220FB",background:"#9B9BFD"}},{border:"#FD5A77",background:"#FFC0CB",highlight:{border:"#FD5A77",background:"#FFD1D9"},hover:{border:"#FD5A77",background:"#FFD1D9"}},{border:"#4AD63A",background:"#C2FABC",highlight:{border:"#4AD63A",background:"#E6FFE3"},hover:{border:"#4AD63A",background:"#E6FFE3"}},{border:"#990000",background:"#EE0000",highlight:{border:"#BB0000",background:"#FF3333"},hover:{border:"#BB0000",background:"#FF3333"}},{border:"#FF6000",background:"#FF6000",highlight:{border:"#FF6000",background:"#FF6000"},hover:{border:"#FF6000",background:"#FF6000"}},{border:"#97C2FC",background:"#2B7CE9",highlight:{border:"#D2E5FF",background:"#2B7CE9"},hover:{border:"#D2E5FF",background:"#2B7CE9"}},{border:"#399605",background:"#255C03",highlight:{border:"#399605",background:"#255C03"},hover:{border:"#399605",background:"#255C03"}},{border:"#B70054",background:"#FF007E",highlight:{border:"#B70054",background:"#FF007E"},hover:{border:"#B70054",background:"#FF007E"}},{border:"#AD85E4",background:"#7C29F0",highlight:{border:"#D3BDF0",background:"#7C29F0"},hover:{border:"#D3BDF0",background:"#7C29F0"}},{border:"#4557FA",background:"#000EA1",highlight:{border:"#6E6EFD",background:"#000EA1"},hover:{border:"#6E6EFD",background:"#000EA1"}},{border:"#FFC0CB",background:"#FD5A77",highlight:{border:"#FFD1D9",background:"#FD5A77"},hover:{border:"#FFD1D9",background:"#FD5A77"}},{border:"#C2FABC",background:"#74D66A",highlight:{border:"#E6FFE3",background:"#74D66A"},hover:{border:"#E6FFE3",background:"#74D66A"}},{border:"#EE0000",background:"#990000",highlight:{border:"#FF3333",background:"#BB0000"},hover:{border:"#FF3333",background:"#BB0000"}}],this.options={},this.defaultOptions={useDefaultGroups:!0},Object.assign(this.options,this.defaultOptions)}setOptions(e){let t=["useDefaultGroups"];if(e!==void 0){for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)===-1){let s=e[i];this.add(i,s)}}}clear(){this._groups=new Map,this._groupNames=[]}get(e,t=!0){let i=this._groups.get(e);if(i===void 0&&t)if(this.options.useDefaultGroups===!1&&this._groupNames.length>0){let s=this._groupIndex%this._groupNames.length;++this._groupIndex,i={},i.color=this._groups.get(this._groupNames[s]),this._groups.set(e,i)}else{let s=this._defaultIndex%this._defaultGroups.length;this._defaultIndex++,i={},i.color=this._defaultGroups[s],this._groups.set(e,i)}return i}add(e,t){return this._groups.has(e)||this._groupNames.push(e),this._groups.set(e,t),t}};function Oi(n,e){let t=["node","edge","label"],i=!0,s=xe(e,"chosen");if(typeof s=="boolean")i=s;else if(typeof s=="object"){if(t.indexOf(n)===-1)throw new Error("choosify: subOption '"+n+"' should be one of '"+t.join("', '")+"'");let o=xe(e,["chosen",n]);(typeof o=="boolean"||typeof o=="function")&&(i=o)}return i}function Ii(n,e,t){if(n.width<=0||n.height<=0)return!1;if(t!==void 0){let o={x:e.x-t.x,y:e.y-t.y};if(t.angle!==0){let r=-t.angle;e={x:Math.cos(r)*o.x-Math.sin(r)*o.y,y:Math.sin(r)*o.x+Math.cos(r)*o.y}}else e=o}let i=n.x+n.width,s=n.y+n.width;return n.left<e.x&&i>e.x&&n.top<e.y&&s>e.y}function Yt(n){return typeof n=="string"&&n!==""}function Co(n,e,t,i){let s=i.x,o=i.y;if(typeof i.distanceToBorder=="function"){let r=i.distanceToBorder(n,e),a=Math.sin(e)*r,d=Math.cos(e)*r;d===r?(s+=r,o=i.y):a===r?(s=i.x,o-=r):(s+=d,o-=a)}else i.shape.width>i.shape.height?(s=i.x+i.shape.width*.5,o=i.y-t):(s=i.x+t,o=i.y-i.shape.height*.5);return{x:s,y:o}}var To=class{constructor(e){this.measureText=e,this.current=0,this.width=0,this.height=0,this.lines=[]}_add(e,t,i="normal"){this.lines[e]===void 0&&(this.lines[e]={width:0,height:0,blocks:[]});let s=t;(t===void 0||t==="")&&(s=" ");let o=this.measureText(s,i),r=Object.assign({},o.values);r.text=t,r.width=o.width,r.mod=i,(t===void 0||t==="")&&(r.width=0),this.lines[e].blocks.push(r),this.lines[e].width+=r.width}curWidth(){let e=this.lines[this.current];return e===void 0?0:e.width}append(e,t="normal"){this._add(this.current,e,t)}newLine(e,t="normal"){this._add(this.current,e,t),this.current++}determineLineHeights(){for(let e=0;e<this.lines.length;e++){let t=this.lines[e],i=0;if(t.blocks!==void 0)for(let s=0;s<t.blocks.length;s++){let o=t.blocks[s];i<o.height&&(i=o.height)}t.height=i}}determineLabelSize(){let e=0,t=0;for(let i=0;i<this.lines.length;i++){let s=this.lines[i];s.width>e&&(e=s.width),t+=s.height}this.width=e,this.height=t}removeEmptyBlocks(){let e=[];for(let t=0;t<this.lines.length;t++){let i=this.lines[t];if(i.blocks.length===0||t===this.lines.length-1&&i.width===0)continue;let s={};Object.assign(s,i),s.blocks=[];let o,r=[];for(let a=0;a<i.blocks.length;a++){let d=i.blocks[a];d.width!==0?r.push(d):o===void 0&&(o=d)}r.length===0&&o!==void 0&&r.push(o),s.blocks=r,e.push(s)}return e}finalize(){this.determineLineHeights(),this.determineLabelSize();let e=this.removeEmptyBlocks();return{width:this.width,height:this.height,lines:e}}},wa={"<b>":/<b>/,"<i>":/<i>/,"<code>":/<code>/,"</b>":/<\/b>/,"</i>":/<\/i>/,"</code>":/<\/code>/,"*":/\*/,_:/_/,"`":/`/,afterBold:/[^*]/,afterItal:/[^_]/,afterMono:/[^`]/},Pi=class{constructor(e){this.text=e,this.bold=!1,this.ital=!1,this.mono=!1,this.spacing=!1,this.position=0,this.buffer="",this.modStack=[],this.blocks=[]}mod(){return this.modStack.length===0?"normal":this.modStack[0]}modName(){if(this.modStack.length===0)return"normal";if(this.modStack[0]==="mono")return"mono";if(this.bold&&this.ital)return"boldital";if(this.bold)return"bold";if(this.ital)return"ital"}emitBlock(){this.spacing&&(this.add(" "),this.spacing=!1),this.buffer.length>0&&(this.blocks.push({text:this.buffer,mod:this.modName()}),this.buffer="")}add(e){e===" "&&(this.spacing=!0),this.spacing&&(this.buffer+=" ",this.spacing=!1),e!=" "&&(this.buffer+=e)}parseWS(e){return/[ \t]/.test(e)?(this.mono?this.add(e):this.spacing=!0,!0):!1}setTag(e){this.emitBlock(),this[e]=!0,this.modStack.unshift(e)}unsetTag(e){this.emitBlock(),this[e]=!1,this.modStack.shift()}parseStartTag(e,t){return!this.mono&&!this[e]&&this.match(t)?(this.setTag(e),!0):!1}match(e,t=!0){let[i,s]=this.prepareRegExp(e),o=i.test(this.text.substr(this.position,s));return o&&t&&(this.position+=s-1),o}parseEndTag(e,t,i){let s=this.mod()===e;return e==="mono"?s=s&&this.mono:s=s&&!this.mono,s&&this.match(t)?(i!==void 0?(this.position===this.text.length-1||this.match(i,!1))&&this.unsetTag(e):this.unsetTag(e),!0):!1}replace(e,t){return this.match(e)?(this.add(t),this.position+=length-1,!0):!1}prepareRegExp(e){let t,i;if(e instanceof RegExp)i=e,t=1;else{let s=wa[e];s!==void 0?i=s:i=new RegExp(e),t=e.length}return[i,t]}},ko=class{constructor(e,t,i,s){this.ctx=e,this.parent=t,this.selected=i,this.hover=s;let o=(r,a)=>{if(r===void 0)return 0;let d=this.parent.getFormattingValues(e,i,s,a),h=0;return r!==""&&(h=this.ctx.measureText(r).width),{width:h,values:d}};this.lines=new To(o)}process(e){if(!Yt(e))return this.lines.finalize();let t=this.parent.fontOptions;e=e.replace(/\r\n/g,`
`),e=e.replace(/\r/g,`
`);let i=String(e).split(`
`),s=i.length;if(t.multi)for(let o=0;o<s;o++){let r=this.splitBlocks(i[o],t.multi);if(r!==void 0){if(r.length===0){this.lines.newLine("");continue}if(t.maxWdt>0)for(let a=0;a<r.length;a++){let d=r[a].mod,h=r[a].text;this.splitStringIntoLines(h,d,!0)}else for(let a=0;a<r.length;a++){let d=r[a].mod,h=r[a].text;this.lines.append(h,d)}this.lines.newLine()}}else if(t.maxWdt>0)for(let o=0;o<s;o++)this.splitStringIntoLines(i[o]);else for(let o=0;o<s;o++)this.lines.newLine(i[o]);return this.lines.finalize()}decodeMarkupSystem(e){let t="none";return e==="markdown"||e==="md"?t="markdown":(e===!0||e==="html")&&(t="html"),t}splitHtmlBlocks(e){let t=new Pi(e),i=s=>/&/.test(s)?(t.replace(t.text,"&lt;","<")||t.replace(t.text,"&amp;","&")||t.add("&"),!0):!1;for(;t.position<t.text.length;){let s=t.text.charAt(t.position);t.parseWS(s)||/</.test(s)&&(t.parseStartTag("bold","<b>")||t.parseStartTag("ital","<i>")||t.parseStartTag("mono","<code>")||t.parseEndTag("bold","</b>")||t.parseEndTag("ital","</i>")||t.parseEndTag("mono","</code>"))||i(s)||t.add(s),t.position++}return t.emitBlock(),t.blocks}splitMarkdownBlocks(e){let t=new Pi(e),i=!0,s=o=>/\\/.test(o)?(t.position<this.text.length+1&&(t.position++,o=this.text.charAt(t.position),/ \t/.test(o)?t.spacing=!0:(t.add(o),i=!1)),!0):!1;for(;t.position<t.text.length;){let o=t.text.charAt(t.position);t.parseWS(o)||s(o)||(i||t.spacing)&&(t.parseStartTag("bold","*")||t.parseStartTag("ital","_")||t.parseStartTag("mono","`"))||t.parseEndTag("bold","*","afterBold")||t.parseEndTag("ital","_","afterItal")||t.parseEndTag("mono","`","afterMono")||(t.add(o),i=!1),t.position++}return t.emitBlock(),t.blocks}splitBlocks(e,t){let i=this.decodeMarkupSystem(t);if(i==="none")return[{text:e,mod:"normal"}];if(i==="markdown")return this.splitMarkdownBlocks(e);if(i==="html")return this.splitHtmlBlocks(e)}overMaxWidth(e){let t=this.ctx.measureText(e).width;return this.lines.curWidth()+t>this.parent.fontOptions.maxWdt}getLongestFit(e){let t="",i=0;for(;i<e.length;){let o=t+(t===""?"":" ")+e[i];if(this.overMaxWidth(o))break;t=o,i++}return i}getLongestFitWord(e){let t=0;for(;t<e.length&&!this.overMaxWidth(e.slice(0,t));)t++;return t}splitStringIntoLines(e,t="normal",i=!1){this.parent.getFormattingValues(this.ctx,this.selected,this.hover,t),e=e.replace(/^( +)/g,"$1\r"),e=e.replace(/([^\r][^ ]*)( +)/g,"$1\r$2\r");let s=e.split("\r");for(;s.length>0;){let o=this.getLongestFit(s);if(o===0){let r=s[0],a=this.getLongestFitWord(r);this.lines.newLine(r.slice(0,a),t),s[0]=r.slice(a)}else{let r=o;s[o-1]===" "?o--:s[r]===" "&&r++;let a=s.slice(0,o).join("");o==s.length&&i?this.lines.append(a,t):this.lines.newLine(a,t),s=s.slice(r)}}}},Xt=["bold","ital","boldital","mono"],Ye=class{constructor(e,t,i=!1){this.body=e,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(t),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=i}setOptions(e){if(this.elementOptions=e,this.initFontOptions(e.font),Yt(e.label)?this.labelDirty=!0:e.label=void 0,e.font!==void 0&&e.font!==null){if(typeof e.font=="string")this.baseSize=this.fontOptions.size;else if(typeof e.font=="object"){let t=e.font.size;t!==void 0&&(this.baseSize=t)}}}initFontOptions(e){if(A(Xt,t=>{this.fontOptions[t]={}}),Ye.parseFontString(this.fontOptions,e)){this.fontOptions.vadjust=0;return}A(e,(t,i)=>{t!=null&&typeof t!="object"&&(this.fontOptions[i]=t)})}static parseFontString(e,t){if(!t||typeof t!="string")return!1;let i=t.split(" ");return e.size=+i[0].replace("px",""),e.face=i[1],e.color=i[2],!0}constrain(e){let t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},i=xe(e,"widthConstraint");if(typeof i=="number")t.maxWdt=Number(i),t.minWdt=Number(i);else if(typeof i=="object"){let o=xe(e,["widthConstraint","maximum"]);typeof o=="number"&&(t.maxWdt=Number(o));let r=xe(e,["widthConstraint","minimum"]);typeof r=="number"&&(t.minWdt=Number(r))}let s=xe(e,"heightConstraint");if(typeof s=="number")t.minHgt=Number(s);else if(typeof s=="object"){let o=xe(e,["heightConstraint","minimum"]);typeof o=="number"&&(t.minHgt=Number(o));let r=xe(e,["heightConstraint","valign"]);typeof r=="string"&&(r==="top"||r==="bottom")&&(t.valign=r)}return t}update(e,t){this.setOptions(e,!0),this.propagateFonts(t),j(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=Oi("label",t)}adjustSizes(e){let t=e?e.right+e.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);let i=e?e.top+e.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=i)}addFontOptionsToPile(e,t){for(let i=0;i<t.length;++i)this.addFontToPile(e,t[i])}addFontToPile(e,t){if(t===void 0||t.font===void 0||t.font===null)return;let i=t.font;e.push(i)}getBasicOptions(e){let t={};for(let i=0;i<e.length;++i){let s=e[i],o={};Ye.parseFontString(o,s)&&(s=o),A(s,(r,a)=>{r!==void 0&&(Object.prototype.hasOwnProperty.call(t,a)||(Xt.indexOf(a)!==-1?t[a]={}:t[a]=r))})}return t}getFontOption(e,t,i){let s;for(let o=0;o<e.length;++o){let r=e[o];if(Object.prototype.hasOwnProperty.call(r,t)){if(s=r[t],s==null)continue;let a={};if(Ye.parseFontString(a,s)&&(s=a),Object.prototype.hasOwnProperty.call(s,i))return s[i]}}if(Object.prototype.hasOwnProperty.call(this.fontOptions,i))return this.fontOptions[i];throw new Error("Did not find value for multi-font for property: '"+i+"'")}getFontOptions(e,t){let i={},s=["color","size","face","mod","vadjust"];for(let o=0;o<s.length;++o){let r=s[o];i[r]=this.getFontOption(e,t,r)}return i}propagateFonts(e){let t=[];this.addFontOptionsToPile(t,e),this.fontOptions=this.getBasicOptions(t);for(let i=0;i<Xt.length;++i){let s=Xt[i],o=this.fontOptions[s],r=this.getFontOptions(t,s);A(r,(a,d)=>{o[d]=a}),o.size=Number(o.size),o.vadjust=Number(o.vadjust)}}draw(e,t,i,s,o,r="middle"){if(this.elementOptions.label===void 0)return;let a=this.fontOptions.size*this.body.view.scale;this.elementOptions.label&&a<this.elementOptions.scaling.label.drawThreshold-1||(a>=this.elementOptions.scaling.label.maxVisible&&(a=Number(this.elementOptions.scaling.label.maxVisible)/this.body.view.scale),this.calculateLabelSize(e,s,o,t,i,r),this._drawBackground(e),this._drawText(e,t,this.size.yLine,r,a))}_drawBackground(e){if(this.fontOptions.background!==void 0&&this.fontOptions.background!=="none"){e.fillStyle=this.fontOptions.background;let t=this.getSize();e.fillRect(t.left,t.top,t.width,t.height)}}_drawText(e,t,i,s="middle",o){[t,i]=this._setAlignment(e,t,i,s),e.textAlign="left",t=t-this.size.width/2,this.fontOptions.valign&&this.size.height>this.size.labelHeight&&(this.fontOptions.valign==="top"&&(i-=(this.size.height-this.size.labelHeight)/2),this.fontOptions.valign==="bottom"&&(i+=(this.size.height-this.size.labelHeight)/2));for(let r=0;r<this.lineCount;r++){let a=this.lines[r];if(a&&a.blocks){let d=0;this.isEdgeLabel||this.fontOptions.align==="center"?d+=(this.size.width-a.width)/2:this.fontOptions.align==="right"&&(d+=this.size.width-a.width);for(let h=0;h<a.blocks.length;h++){let l=a.blocks[h];e.font=l.font;let[c,u]=this._getColor(l.color,o,l.strokeColor);l.strokeWidth>0&&(e.lineWidth=l.strokeWidth,e.strokeStyle=u,e.lineJoin="round"),e.fillStyle=c,l.strokeWidth>0&&e.strokeText(l.text,t+d,i+l.vadjust),e.fillText(l.text,t+d,i+l.vadjust),d+=l.width}i+=a.height}}}_setAlignment(e,t,i,s){if(this.isEdgeLabel&&this.fontOptions.align!=="horizontal"&&this.pointToSelf===!1){t=0,i=0;let o=2;this.fontOptions.align==="top"?(e.textBaseline="alphabetic",i-=2*o):this.fontOptions.align==="bottom"?(e.textBaseline="hanging",i+=2*o):e.textBaseline="middle"}else e.textBaseline=s;return[t,i]}_getColor(e,t,i){let s=e||"#000000",o=i||"#ffffff";if(t<=this.elementOptions.scaling.label.drawThreshold){let r=Math.max(0,Math.min(1,1-(this.elementOptions.scaling.label.drawThreshold-t)));s=re(s,r),o=re(o,r)}return[s,o]}getTextSize(e,t=!1,i=!1){return this._processLabel(e,t,i),{width:this.size.width,height:this.size.height,lineCount:this.lineCount}}getSize(){let e=2,t=this.size.left,i=this.size.top-.5*e;if(this.isEdgeLabel){let o=-this.size.width*.5;switch(this.fontOptions.align){case"middle":t=o,i=-this.size.height*.5;break;case"top":t=o,i=-(this.size.height+e);break;case"bottom":t=o,i=e;break}}return{left:t,top:i,width:this.size.width,height:this.size.height}}calculateLabelSize(e,t,i,s=0,o=0,r="middle"){this._processLabel(e,t,i),this.size.left=s-this.size.width*.5,this.size.top=o-this.size.height*.5,this.size.yLine=o+(1-this.lineCount)*.5*this.fontOptions.size,r==="hanging"&&(this.size.top+=.5*this.fontOptions.size,this.size.top+=4,this.size.yLine+=4)}getFormattingValues(e,t,i,s){let o=function(d,h,l){return h==="normal"?l==="mod"?"":d[l]:d[h][l]!==void 0?d[h][l]:d[l]},r={color:o(this.fontOptions,s,"color"),size:o(this.fontOptions,s,"size"),face:o(this.fontOptions,s,"face"),mod:o(this.fontOptions,s,"mod"),vadjust:o(this.fontOptions,s,"vadjust"),strokeWidth:this.fontOptions.strokeWidth,strokeColor:this.fontOptions.strokeColor};(t||i)&&(s==="normal"&&this.fontOptions.chooser===!0&&this.elementOptions.labelHighlightBold?r.mod="bold":typeof this.fontOptions.chooser=="function"&&this.fontOptions.chooser(r,this.elementOptions.id,t,i));let a="";return r.mod!==void 0&&r.mod!==""&&(a+=r.mod+" "),a+=r.size+"px "+r.face,e.font=a.replace(/"/g,""),r.font=e.font,r.height=r.size,r}differentState(e,t){return e!==this.selectedState||t!==this.hoverState}_processLabelText(e,t,i,s){return new ko(e,this,t,i).process(s)}_processLabel(e,t,i){if(this.labelDirty===!1&&!this.differentState(t,i))return;let s=this._processLabelText(e,t,i,this.elementOptions.label);this.fontOptions.minWdt>0&&s.width<this.fontOptions.minWdt&&(s.width=this.fontOptions.minWdt),this.size.labelHeight=s.height,this.fontOptions.minHgt>0&&s.height<this.fontOptions.minHgt&&(s.height=this.fontOptions.minHgt),this.lines=s.lines,this.lineCount=s.lines.length,this.size.width=s.width,this.size.height=s.height,this.selectedState=t,this.hoverState=i,this.labelDirty=!1}visible(){return!(this.size.width===0||this.size.height===0||this.elementOptions.label===void 0||this.fontOptions.size*this.body.view.scale<this.elementOptions.scaling.label.drawThreshold-1)}},De=class{constructor(e,t,i){this.body=t,this.labelModule=i,this.setOptions(e),this.top=void 0,this.left=void 0,this.height=void 0,this.width=void 0,this.radius=void 0,this.margin=void 0,this.refreshNeeded=!0,this.boundingBox={top:0,left:0,right:0,bottom:0}}setOptions(e){this.options=e}_setMargins(e){this.margin={},this.options.margin&&(typeof this.options.margin=="object"?(this.margin.top=this.options.margin.top,this.margin.right=this.options.margin.right,this.margin.bottom=this.options.margin.bottom,this.margin.left=this.options.margin.left):(this.margin.top=this.options.margin,this.margin.right=this.options.margin,this.margin.bottom=this.options.margin,this.margin.left=this.options.margin)),e.adjustSizes(this.margin)}_distanceToBorder(e,t){let i=this.options.borderWidth;return e&&this.resize(e),Math.min(Math.abs(this.width/2/Math.cos(t)),Math.abs(this.height/2/Math.sin(t)))+i}enableShadow(e,t){t.shadow&&(e.shadowColor=t.shadowColor,e.shadowBlur=t.shadowSize,e.shadowOffsetX=t.shadowX,e.shadowOffsetY=t.shadowY)}disableShadow(e,t){t.shadow&&(e.shadowColor="rgba(0,0,0,0)",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0)}enableBorderDashes(e,t){if(t.borderDashes!==!1)if(e.setLineDash!==void 0){let i=t.borderDashes;i===!0&&(i=[5,15]),e.setLineDash(i)}else console.warn("setLineDash is not supported in this browser. The dashed borders cannot be used."),this.options.shapeProperties.borderDashes=!1,t.borderDashes=!1}disableBorderDashes(e,t){t.borderDashes!==!1&&(e.setLineDash!==void 0?e.setLineDash([0]):(console.warn("setLineDash is not supported in this browser. The dashed borders cannot be used."),this.options.shapeProperties.borderDashes=!1,t.borderDashes=!1))}needsRefresh(e,t){return this.refreshNeeded===!0?(this.refreshNeeded=!1,!0):this.width===void 0||this.labelModule.differentState(e,t)}initContextForDraw(e,t){let i=t.borderWidth/this.body.view.scale;e.lineWidth=Math.min(this.width,i),e.strokeStyle=t.borderColor,e.fillStyle=t.color}performStroke(e,t){let i=t.borderWidth/this.body.view.scale;e.save(),i>0&&(this.enableBorderDashes(e,t),e.stroke(),this.disableBorderDashes(e,t)),e.restore()}performFill(e,t){e.save(),e.fillStyle=t.color,this.enableShadow(e,t),e.fill(),this.disableShadow(e,t),e.restore(),this.performStroke(e,t)}_addBoundingBoxMargin(e){this.boundingBox.left-=e,this.boundingBox.top-=e,this.boundingBox.bottom+=e,this.boundingBox.right+=e}_updateBoundingBox(e,t,i,s,o){i!==void 0&&this.resize(i,s,o),this.left=e-this.width/2,this.top=t-this.height/2,this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width}updateBoundingBox(e,t,i,s,o){this._updateBoundingBox(e,t,i,s,o)}getDimensionsFromLabel(e,t,i){this.textSize=this.labelModule.getTextSize(e,t,i);let s=this.textSize.width,o=this.textSize.height,r=14;return s===0&&(s=r,o=r),{width:s,height:o}}},_a=class extends De{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t=this.selected,i=this.hover){if(this.needsRefresh(t,i)){let s=this.getDimensionsFromLabel(e,t,i);this.width=s.width+this.margin.right+this.margin.left,this.height=s.height+this.margin.top+this.margin.bottom,this.radius=this.width/2}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this.initContextForDraw(e,r),ro(e,this.left,this.top,this.width,this.height,r.borderRadius),this.performFill(e,r),this.updateBoundingBox(t,i,e,s,o),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,s,o)}updateBoundingBox(e,t,i,s,o){this._updateBoundingBox(e,t,i,s,o);let r=this.options.shapeProperties.borderRadius;this._addBoundingBoxMargin(r)}distanceToBorder(e,t){e&&this.resize(e);let i=this.options.borderWidth;return Math.min(Math.abs(this.width/2/Math.cos(t)),Math.abs(this.height/2/Math.sin(t)))+i}},Gt=class extends De{constructor(e,t,i){super(e,t,i);this.labelOffset=0,this.selected=!1}setOptions(e,t,i){this.options=e,t===void 0&&i===void 0||this.setImages(t,i)}setImages(e,t){t&&this.selected?(this.imageObj=t,this.imageObjAlt=e):(this.imageObj=e,this.imageObjAlt=t)}switchImages(e){let t=e&&!this.selected||!e&&this.selected;if(this.selected=e,this.imageObjAlt!==void 0&&t){let i=this.imageObj;this.imageObj=this.imageObjAlt,this.imageObjAlt=i}}_getImagePadding(){let e={top:0,right:0,bottom:0,left:0};if(this.options.imagePadding){let t=this.options.imagePadding;typeof t=="object"?(e.top=t.top,e.right=t.right,e.bottom=t.bottom,e.left=t.left):(e.top=t,e.right=t,e.bottom=t,e.left=t)}return e}_resizeImage(){let e,t;if(this.options.shapeProperties.useImageSize===!1){let i=1,s=1;this.imageObj.width&&this.imageObj.height&&(this.imageObj.width>this.imageObj.height?i=this.imageObj.width/this.imageObj.height:s=this.imageObj.height/this.imageObj.width),e=this.options.size*2*i,t=this.options.size*2*s}else{let i=this._getImagePadding();e=this.imageObj.width+i.left+i.right,t=this.imageObj.height+i.top+i.bottom}this.width=e,this.height=t,this.radius=.5*this.width}_drawRawCircle(e,t,i,s){this.initContextForDraw(e,s),Ci(e,t,i,s.size),this.performFill(e,s)}_drawImageAtPosition(e,t){if(this.imageObj.width!=0){e.globalAlpha=t.opacity!==void 0?t.opacity:1,this.enableShadow(e,t);let i=1;this.options.shapeProperties.interpolation===!0&&(i=this.imageObj.width/this.width/this.body.view.scale);let s=this._getImagePadding(),o=this.left+s.left,r=this.top+s.top,a=this.width-s.left-s.right,d=this.height-s.top-s.bottom;this.imageObj.drawImageAtPosition(e,i,o,r,a,d),this.disableShadow(e,t)}}_drawImageLabel(e,t,i,s,o){let r=0;if(this.height!==void 0){r=this.height*.5;let d=this.labelModule.getTextSize(e,s,o);d.lineCount>=1&&(r+=d.height/2)}let a=i+r;this.options.label&&(this.labelOffset=r),this.labelModule.draw(e,t,a,s,o,"hanging")}},Ea=class extends Gt{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t=this.selected,i=this.hover){if(this.needsRefresh(t,i)){let s=this.getDimensionsFromLabel(e,t,i),o=Math.max(s.width+this.margin.right+this.margin.left,s.height+this.margin.top+this.margin.bottom);this.options.size=o/2,this.width=o,this.height=o,this.radius=this.width/2}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this._drawRawCircle(e,t,i,r),this.updateBoundingBox(t,i),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,i,s,o)}updateBoundingBox(e,t){this.boundingBox.top=t-this.options.size,this.boundingBox.left=e-this.options.size,this.boundingBox.right=e+this.options.size,this.boundingBox.bottom=t+this.options.size}distanceToBorder(e){return e&&this.resize(e),this.width*.5}},So=class extends Gt{constructor(e,t,i,s,o){super(e,t,i);this.setImages(s,o)}resize(e,t=this.selected,i=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let o=this.options.size*2;this.width=o,this.height=o,this.radius=.5*this.width;return}this.needsRefresh(t,i)&&this._resizeImage()}draw(e,t,i,s,o,r){this.switchImages(s),this.resize();let a=t,d=i;this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=i,a+=this.width/2,d+=this.height/2):(this.left=t-this.width/2,this.top=i-this.height/2),this._drawRawCircle(e,a,d,r),e.save(),e.clip(),this._drawImageAtPosition(e,r),e.restore(),this._drawImageLabel(e,a,d,s,o),this.updateBoundingBox(t,i)}updateBoundingBox(e,t){this.options.shapeProperties.coordinateOrigin==="top-left"?(this.boundingBox.top=t,this.boundingBox.left=e,this.boundingBox.right=e+this.options.size*2,this.boundingBox.bottom=t+this.options.size*2):(this.boundingBox.top=t-this.options.size,this.boundingBox.left=e-this.options.size,this.boundingBox.right=e+this.options.size,this.boundingBox.bottom=t+this.options.size),this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset)}distanceToBorder(e){return e&&this.resize(e),this.width*.5}},ke=class extends De{constructor(e,t,i){super(e,t,i)}resize(e,t=this.selected,i=this.hover,s={size:this.options.size}){var o,r;if(this.needsRefresh(t,i)){this.labelModule.getTextSize(e,t,i);let a=2*s.size;this.width=(o=this.customSizeWidth)!=null?o:a,this.height=(r=this.customSizeHeight)!=null?r:a,this.radius=.5*this.width}}_drawShape(e,t,i,s,o,r,a,d){return this.resize(e,r,a,d),this.left=s-this.width/2,this.top=o-this.height/2,this.initContextForDraw(e,d),Kr(t)(e,s,o,d.size),this.performFill(e,d),this.options.icon!==void 0&&this.options.icon.code!==void 0&&(e.font=(r?"bold ":"")+this.height/2+"px "+(this.options.icon.face||"FontAwesome"),e.fillStyle=this.options.icon.color||"black",e.textAlign="center",e.textBaseline="middle",e.fillText(this.options.icon.code,s,o)),{drawExternalLabel:()=>{if(this.options.label!==void 0){this.labelModule.calculateLabelSize(e,r,a,s,o,"hanging");let h=o+.5*this.height+.5*this.labelModule.size.height;this.labelModule.draw(e,s,h,r,a,"hanging")}this.updateBoundingBox(s,o)}}}updateBoundingBox(e,t){this.boundingBox.top=t-this.options.size,this.boundingBox.left=e-this.options.size,this.boundingBox.right=e+this.options.size,this.boundingBox.bottom=t+this.options.size,this.options.label!==void 0&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height))}},Oo=class extends ke{constructor(e,t,i,s){super(e,t,i,s);this.ctxRenderer=s}draw(e,t,i,s,o,r){this.resize(e,s,o,r),this.left=t-this.width/2,this.top=i-this.height/2,e.save();let a=this.ctxRenderer({ctx:e,id:this.options.id,x:t,y:i,state:{selected:s,hover:o},style:de({},r),label:this.options.label});if(a.drawNode!=null&&a.drawNode(),e.restore(),a.drawExternalLabel){let d=a.drawExternalLabel;a.drawExternalLabel=()=>{e.save(),d(),e.restore()}}return a.nodeDimensions&&(this.customSizeWidth=a.nodeDimensions.width,this.customSizeHeight=a.nodeDimensions.height),a}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Io=class extends De{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t,i){if(this.needsRefresh(t,i)){let o=this.getDimensionsFromLabel(e,t,i).width+this.margin.right+this.margin.left;this.width=o,this.height=o,this.radius=this.width/2}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this.initContextForDraw(e,r),ao(e,t-this.width/2,i-this.height/2,this.width,this.height),this.performFill(e,r),this.updateBoundingBox(t,i,e,s,o),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,s,o)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},xa=class extends ke{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"diamond",4,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Po=class extends ke{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"circle",2,t,i,s,o,r)}distanceToBorder(e){return e&&this.resize(e),this.options.size}},Mi=class extends De{constructor(e,t,i){super(e,t,i)}resize(e,t=this.selected,i=this.hover){if(this.needsRefresh(t,i)){let s=this.getDimensionsFromLabel(e,t,i);this.height=s.height*2,this.width=s.width+s.height,this.radius=.5*this.width}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width*.5,this.top=i-this.height*.5,this.initContextForDraw(e,r),Ti(e,this.left,this.top,this.width,this.height),this.performFill(e,r),this.updateBoundingBox(t,i,e,s,o),this.labelModule.draw(e,t,i,s,o)}distanceToBorder(e,t){e&&this.resize(e);let i=this.width*.5,s=this.height*.5,o=Math.sin(t)*i,r=Math.cos(t)*s;return i*s/Math.sqrt(o*o+r*r)}},Mo=class extends De{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t,i){this.needsRefresh(t,i)&&(this.iconSize={width:Number(this.options.icon.size),height:Number(this.options.icon.size)},this.width=this.iconSize.width+this.margin.right+this.margin.left,this.height=this.iconSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}draw(e,t,i,s,o,r){return this.resize(e,s,o),this.options.icon.size=this.options.icon.size||50,this.left=t-this.width/2,this.top=i-this.height/2,this._icon(e,t,i,s,o,r),{drawExternalLabel:()=>{if(this.options.label!==void 0){let a=5;this.labelModule.draw(e,this.left+this.iconSize.width/2+this.margin.left,i+this.height/2+a,s)}this.updateBoundingBox(t,i)}}}updateBoundingBox(e,t){if(this.boundingBox.top=t-this.options.icon.size*.5,this.boundingBox.left=e-this.options.icon.size*.5,this.boundingBox.right=e+this.options.icon.size*.5,this.boundingBox.bottom=t+this.options.icon.size*.5,this.options.label!==void 0&&this.labelModule.size.width>0){let i=5;this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height+i)}}_icon(e,t,i,s,o,r){let a=Number(this.options.icon.size);this.options.icon.code!==void 0?(e.font=[this.options.icon.weight!=null?this.options.icon.weight:s?"bold":"",(this.options.icon.weight!=null&&s?5:0)+a+"px",this.options.icon.face].join(" "),e.fillStyle=this.options.icon.color||"black",e.textAlign="center",e.textBaseline="middle",this.enableShadow(e,r),e.fillText(this.options.icon.code,t,i),this.disableShadow(e,r)):console.error("When using the icon shape, you need to define the code in the icon options object. This can be done per node or globally.")}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ca=class extends Gt{constructor(e,t,i,s,o){super(e,t,i);this.setImages(s,o)}resize(e,t=this.selected,i=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let o=this.options.size*2;this.width=o,this.height=o;return}this.needsRefresh(t,i)&&this._resizeImage()}draw(e,t,i,s,o,r){e.save(),this.switchImages(s),this.resize();let a=t,d=i;if(this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=i,a+=this.width/2,d+=this.height/2):(this.left=t-this.width/2,this.top=i-this.height/2),this.options.shapeProperties.useBorderWithImage===!0){let h=this.options.borderWidth,l=this.options.borderWidthSelected||2*this.options.borderWidth,c=(s?l:h)/this.body.view.scale;e.lineWidth=Math.min(this.width,c),e.beginPath();let u=s?this.options.color.highlight.border:o?this.options.color.hover.border:this.options.color.border,p=s?this.options.color.highlight.background:o?this.options.color.hover.background:this.options.color.background;r.opacity!==void 0&&(u=re(u,r.opacity),p=re(p,r.opacity)),e.strokeStyle=u,e.fillStyle=p,e.rect(this.left-.5*e.lineWidth,this.top-.5*e.lineWidth,this.width+e.lineWidth,this.height+e.lineWidth),e.fill(),this.performStroke(e,r),e.closePath()}this._drawImageAtPosition(e,r),this._drawImageLabel(e,a,d,s,o),this.updateBoundingBox(t,i),e.restore()}updateBoundingBox(e,t){this.resize(),this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=e,this.top=t):(this.left=e-this.width/2,this.top=t-this.height/2),this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width,this.options.label!==void 0&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset))}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Do=class extends ke{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"square",2,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Fo=class extends ke{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"hexagon",4,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},No=class extends ke{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"star",4,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Bo=class extends De{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t,i){this.needsRefresh(t,i)&&(this.textSize=this.labelModule.getTextSize(e,t,i),this.width=this.textSize.width+this.margin.right+this.margin.left,this.height=this.textSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this.enableShadow(e,r),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,s,o),this.disableShadow(e,r),this.updateBoundingBox(t,i,e,s,o)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ta=class extends ke{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"triangle",3,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ao=class extends ke{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"triangleDown",3,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},U=class{constructor(e,t,i,s,o,r){this.options=Ee(o),this.globalOptions=o,this.defaultOptions=r,this.body=t,this.edges=[],this.id=void 0,this.imagelist=i,this.grouplist=s,this.x=void 0,this.y=void 0,this.baseSize=this.options.size,this.baseFontSize=this.options.font.size,this.predefinedPosition=!1,this.selected=!1,this.hover=!1,this.labelModule=new Ye(this.body,this.options,!1),this.setOptions(e)}attachEdge(e){this.edges.indexOf(e)===-1&&this.edges.push(e)}detachEdge(e){let t=this.edges.indexOf(e);t!=-1&&this.edges.splice(t,1)}setOptions(e){let t=this.options.shape;if(!e)return;if(typeof e.color!="undefined"&&(this._localColor=e.color),e.id!==void 0&&(this.id=e.id),this.id===void 0)throw new Error("Node must have an id");U.checkMass(e,this.id),e.x!==void 0&&(e.x===null?(this.x=void 0,this.predefinedPosition=!1):(this.x=parseInt(e.x),this.predefinedPosition=!0)),e.y!==void 0&&(e.y===null?(this.y=void 0,this.predefinedPosition=!1):(this.y=parseInt(e.y),this.predefinedPosition=!0)),e.size!==void 0&&(this.baseSize=e.size),e.value!==void 0&&(e.value=parseFloat(e.value)),U.parseOptions(this.options,e,!0,this.globalOptions,this.grouplist);let i=[e,this.options,this.defaultOptions];return this.chooser=Oi("node",i),this._load_images(),this.updateLabelModule(e),e.opacity!==void 0&&U.checkOpacity(e.opacity)&&(this.options.opacity=e.opacity),this.updateShape(t),e.hidden!==void 0||e.physics!==void 0}_load_images(){if((this.options.shape==="circularImage"||this.options.shape==="image")&&this.options.image===void 0)throw new Error("Option image must be defined for node type '"+this.options.shape+"'");if(this.options.image!==void 0){if(this.imagelist===void 0)throw new Error("Internal Error: No images provided");if(typeof this.options.image=="string")this.imageObj=this.imagelist.load(this.options.image,this.options.brokenImage,this.id);else{if(this.options.image.unselected===void 0)throw new Error("No unselected image provided");this.imageObj=this.imagelist.load(this.options.image.unselected,this.options.brokenImage,this.id),this.options.image.selected!==void 0?this.imageObjAlt=this.imagelist.load(this.options.image.selected,this.options.brokenImage,this.id):this.imageObjAlt=void 0}}}static checkOpacity(e){return 0<=e&&e<=1}static checkCoordinateOrigin(e){return e===void 0||e==="center"||e==="top-left"}static updateGroupOptions(e,t,i){if(i===void 0)return;let s=e.group;if(t!==void 0&&t.group!==void 0&&s!==t.group)throw new Error("updateGroupOptions: group values in options don't match.");if(!(typeof s=="number"||typeof s=="string"&&s!=""))return;let r=i.get(s);r.opacity!==void 0&&t.opacity===void 0&&(U.checkOpacity(r.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+r.opacity),r.opacity=void 0));let a=Object.getOwnPropertyNames(t).filter(d=>t[d]!=null);a.push("font"),bt(a,e,r),e.color=Lt(e.color)}static parseOptions(e,t,i=!1,s={},o){if(bt(["color","fixed","shadow"],e,t,i),U.checkMass(t),e.opacity!==void 0&&(U.checkOpacity(e.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+e.opacity),e.opacity=void 0)),t.opacity!==void 0&&(U.checkOpacity(t.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+t.opacity),t.opacity=void 0)),t.shapeProperties&&!U.checkCoordinateOrigin(t.shapeProperties.coordinateOrigin)&&console.error("Invalid option for node coordinateOrigin, found: "+t.shapeProperties.coordinateOrigin),ae(e,t,"shadow",s),t.color!==void 0&&t.color!==null){let a=Lt(t.color);yi(e.color,a)}else i===!0&&t.color===null&&(e.color=Ee(s.color));t.fixed!==void 0&&t.fixed!==null&&(typeof t.fixed=="boolean"?(e.fixed.x=t.fixed,e.fixed.y=t.fixed):(t.fixed.x!==void 0&&typeof t.fixed.x=="boolean"&&(e.fixed.x=t.fixed.x),t.fixed.y!==void 0&&typeof t.fixed.y=="boolean"&&(e.fixed.y=t.fixed.y))),i===!0&&t.font===null&&(e.font=Ee(s.font)),U.updateGroupOptions(e,t,o),t.scaling!==void 0&&ae(e.scaling,t.scaling,"label",s.scaling)}getFormattingValues(){let e={color:this.options.color.background,opacity:this.options.opacity,borderWidth:this.options.borderWidth,borderColor:this.options.color.border,size:this.options.size,borderDashes:this.options.shapeProperties.borderDashes,borderRadius:this.options.shapeProperties.borderRadius,shadow:this.options.shadow.enabled,shadowColor:this.options.shadow.color,shadowSize:this.options.shadow.size,shadowX:this.options.shadow.x,shadowY:this.options.shadow.y};if(this.selected||this.hover?this.chooser===!0?this.selected?(this.options.borderWidthSelected!=null?e.borderWidth=this.options.borderWidthSelected:e.borderWidth*=2,e.color=this.options.color.highlight.background,e.borderColor=this.options.color.highlight.border,e.shadow=this.options.shadow.enabled):this.hover&&(e.color=this.options.color.hover.background,e.borderColor=this.options.color.hover.border,e.shadow=this.options.shadow.enabled):typeof this.chooser=="function"&&(this.chooser(e,this.options.id,this.selected,this.hover),e.shadow===!1&&(e.shadowColor!==this.options.shadow.color||e.shadowSize!==this.options.shadow.size||e.shadowX!==this.options.shadow.x||e.shadowY!==this.options.shadow.y)&&(e.shadow=!0)):e.shadow=this.options.shadow.enabled,this.options.opacity!==void 0){let t=this.options.opacity;e.borderColor=re(e.borderColor,t),e.color=re(e.color,t),e.shadowColor=re(e.shadowColor,t)}return e}updateLabelModule(e){(this.options.label===void 0||this.options.label===null)&&(this.options.label=""),U.updateGroupOptions(this.options,Be(de({},e),{color:e&&e.color||this._localColor||void 0}),this.grouplist);let t=this.grouplist.get(this.options.group,!1),i=[e,this.options,t,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,i),this.labelModule.baseSize!==void 0&&(this.baseFontSize=this.labelModule.baseSize)}updateShape(e){if(e===this.options.shape&&this.shape)this.shape.setOptions(this.options,this.imageObj,this.imageObjAlt);else switch(this.options.shape){case"box":this.shape=new _a(this.options,this.body,this.labelModule);break;case"circle":this.shape=new Ea(this.options,this.body,this.labelModule);break;case"circularImage":this.shape=new So(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"custom":this.shape=new Oo(this.options,this.body,this.labelModule,this.options.ctxRenderer);break;case"database":this.shape=new Io(this.options,this.body,this.labelModule);break;case"diamond":this.shape=new xa(this.options,this.body,this.labelModule);break;case"dot":this.shape=new Po(this.options,this.body,this.labelModule);break;case"ellipse":this.shape=new Mi(this.options,this.body,this.labelModule);break;case"icon":this.shape=new Mo(this.options,this.body,this.labelModule);break;case"image":this.shape=new Ca(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"square":this.shape=new Do(this.options,this.body,this.labelModule);break;case"hexagon":this.shape=new Fo(this.options,this.body,this.labelModule);break;case"star":this.shape=new No(this.options,this.body,this.labelModule);break;case"text":this.shape=new Bo(this.options,this.body,this.labelModule);break;case"triangle":this.shape=new Ta(this.options,this.body,this.labelModule);break;case"triangleDown":this.shape=new Ao(this.options,this.body,this.labelModule);break;default:this.shape=new Mi(this.options,this.body,this.labelModule);break}this.needsRefresh()}select(){this.selected=!0,this.needsRefresh()}unselect(){this.selected=!1,this.needsRefresh()}needsRefresh(){this.shape.refreshNeeded=!0}getTitle(){return this.options.title}distanceToBorder(e,t){return this.shape.distanceToBorder(e,t)}isFixed(){return this.options.fixed.x&&this.options.fixed.y}isSelected(){return this.selected}getValue(){return this.options.value}getLabelSize(){return this.labelModule.size()}setValueRange(e,t,i){if(this.options.value!==void 0){let s=this.options.scaling.customScalingFunction(e,t,i,this.options.value),o=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let r=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+s*r}this.options.size=this.options.scaling.min+s*o}else this.options.size=this.baseSize,this.options.font.size=this.baseFontSize;this.updateLabelModule()}draw(e){let t=this.getFormattingValues();return this.shape.draw(e,this.x,this.y,this.selected,this.hover,t)||{}}updateBoundingBox(e){this.shape.updateBoundingBox(this.x,this.y,e)}resize(e){let t=this.getFormattingValues();this.shape.resize(e,this.selected,this.hover,t)}getItemsOnPoint(e){let t=[];return this.labelModule.visible()&&Ii(this.labelModule.getSize(),e)&&t.push({nodeId:this.id,labelId:0}),Ii(this.shape.boundingBox,e)&&t.push({nodeId:this.id}),t}isOverlappingWith(e){return this.shape.left<e.right&&this.shape.left+this.shape.width>e.left&&this.shape.top<e.bottom&&this.shape.top+this.shape.height>e.top}isBoundingBoxOverlappingWith(e){return this.shape.boundingBox.left<e.right&&this.shape.boundingBox.right>e.left&&this.shape.boundingBox.top<e.bottom&&this.shape.boundingBox.bottom>e.top}static checkMass(e,t){if(e.mass!==void 0&&e.mass<=0){let i="";t!==void 0&&(i=" in node id: "+t),console.error("%cNegative or zero mass disallowed"+i+", setting mass to 1.",_i),e.mass=1}}},zo=class{constructor(e,t,i,s){if(this.body=e,this.images=t,this.groups=i,this.layoutEngine=s,this.body.functions.createNode=this.create.bind(this),this.nodesListeners={add:(o,r)=>{this.add(r.items)},update:(o,r)=>{this.update(r.items,r.data,r.oldData)},remove:(o,r)=>{this.remove(r.items)}},this.defaultOptions={borderWidth:1,borderWidthSelected:void 0,brokenImage:void 0,color:{border:"#2B7CE9",background:"#97C2FC",highlight:{border:"#2B7CE9",background:"#D2E5FF"},hover:{border:"#2B7CE9",background:"#D2E5FF"}},opacity:void 0,fixed:{x:!1,y:!1},font:{color:"#343434",size:14,face:"arial",background:"none",strokeWidth:0,strokeColor:"#ffffff",align:"center",vadjust:0,multi:!1,bold:{mod:"bold"},boldital:{mod:"bold italic"},ital:{mod:"italic"},mono:{mod:"",size:15,face:"monospace",vadjust:2}},group:void 0,hidden:!1,icon:{face:"FontAwesome",code:void 0,size:50,color:"#2B7CE9"},image:void 0,imagePadding:{top:0,right:0,bottom:0,left:0},label:void 0,labelHighlightBold:!0,level:void 0,margin:{top:5,right:5,bottom:5,left:5},mass:1,physics:!0,scaling:{min:10,max:30,label:{enabled:!1,min:14,max:30,maxVisible:30,drawThreshold:5},customScalingFunction:function(o,r,a,d){if(r===o)return .5;{let h=1/(r-o);return Math.max(0,(d-o)*h)}}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:10,x:5,y:5},shape:"ellipse",shapeProperties:{borderDashes:!1,borderRadius:6,interpolation:!0,useImageSize:!1,useBorderWithImage:!1,coordinateOrigin:"center"},size:25,title:void 0,value:void 0,x:void 0,y:void 0},this.defaultOptions.mass<=0)throw"Internal error: mass in defaultOptions of NodesHandler may not be zero or negative";this.options=Ee(this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("refreshNodes",this.refresh.bind(this)),this.body.emitter.on("refresh",this.refresh.bind(this)),this.body.emitter.on("destroy",()=>{A(this.nodesListeners,(e,t)=>{this.body.data.nodes&&this.body.data.nodes.off(t,e)}),delete this.body.functions.createNode,delete this.nodesListeners.add,delete this.nodesListeners.update,delete this.nodesListeners.remove,delete this.nodesListeners})}setOptions(e){if(e!==void 0){if(U.parseOptions(this.options,e),e.opacity!==void 0&&(Number.isNaN(e.opacity)||!Number.isFinite(e.opacity)||e.opacity<0||e.opacity>1?console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+e.opacity):this.options.opacity=e.opacity),e.shape!==void 0)for(let t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&this.body.nodes[t].updateShape();if(typeof e.font!="undefined"||typeof e.widthConstraint!="undefined"||typeof e.heightConstraint!="undefined")for(let t of Object.keys(this.body.nodes))this.body.nodes[t].updateLabelModule(),this.body.nodes[t].needsRefresh();if(e.size!==void 0)for(let t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&this.body.nodes[t].needsRefresh();(e.hidden!==void 0||e.physics!==void 0)&&this.body.emitter.emit("_dataChanged")}}setData(e,t=!1){let i=this.body.data.nodes;if(xi("id",e))this.body.data.nodes=e;else if(Array.isArray(e))this.body.data.nodes=new Te,this.body.data.nodes.add(e);else if(!e)this.body.data.nodes=new Te;else throw new TypeError("Array or DataSet expected");if(i&&A(this.nodesListeners,function(s,o){i.off(o,s)}),this.body.nodes={},this.body.data.nodes){let s=this;A(this.nodesListeners,function(r,a){s.body.data.nodes.on(a,r)});let o=this.body.data.nodes.getIds();this.add(o,!0)}t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let i,s=[];for(let o=0;o<e.length;o++){i=e[o];let r=this.body.data.nodes.get(i),a=this.create(r);s.push(a),this.body.nodes[i]=a}this.layoutEngine.positionInitially(s),t===!1&&this.body.emitter.emit("_dataChanged")}update(e,t,i){let s=this.body.nodes,o=!1;for(let r=0;r<e.length;r++){let a=e[r],d=s[a],h=t[r];d!==void 0?d.setOptions(h)&&(o=!0):(o=!0,d=this.create(h),s[a]=d)}!o&&i!==void 0&&(o=t.some(function(r,a){let d=i[a];return d&&d.level!==r.level})),o===!0?this.body.emitter.emit("_dataChanged"):this.body.emitter.emit("_dataUpdated")}remove(e){let t=this.body.nodes;for(let i=0;i<e.length;i++){let s=e[i];delete t[s]}this.body.emitter.emit("_dataChanged")}create(e,t=U){return new t(e,this.body,this.images,this.groups,this.options,this.defaultOptions)}refresh(e=!1){A(this.body.nodes,(t,i)=>{let s=this.body.data.nodes.get(i);s!==void 0&&(e===!0&&t.setOptions({x:null,y:null}),t.setOptions({fixed:!1}),t.setOptions(s))})}getPositions(e){let t={};if(e!==void 0){if(Array.isArray(e)===!0){for(let i=0;i<e.length;i++)if(this.body.nodes[e[i]]!==void 0){let s=this.body.nodes[e[i]];t[e[i]]={x:Math.round(s.x),y:Math.round(s.y)}}}else if(this.body.nodes[e]!==void 0){let i=this.body.nodes[e];t[e]={x:Math.round(i.x),y:Math.round(i.y)}}}else for(let i=0;i<this.body.nodeIndices.length;i++){let s=this.body.nodes[this.body.nodeIndices[i]];t[this.body.nodeIndices[i]]={x:Math.round(s.x),y:Math.round(s.y)}}return t}getPosition(e){if(e==null)throw new TypeError("No id was specified for getPosition method.");if(this.body.nodes[e]==null)throw new ReferenceError(`NodeId provided for getPosition does not exist. Provided: ${e}`);return{x:Math.round(this.body.nodes[e].x),y:Math.round(this.body.nodes[e].y)}}storePositions(){let e=[],t=this.body.data.nodes.getDataSet();for(let i of t.get()){let s=i.id,o=this.body.nodes[s],r=Math.round(o.x),a=Math.round(o.y);(i.x!==r||i.y!==a)&&e.push({id:s,x:r,y:a})}t.update(e)}getBoundingBox(e){if(this.body.nodes[e]!==void 0)return this.body.nodes[e].shape.boundingBox}getConnectedNodes(e,t){let i=[];if(this.body.nodes[e]!==void 0){let s=this.body.nodes[e],o={};for(let r=0;r<s.edges.length;r++){let a=s.edges[r];t!=="to"&&a.toId==s.id?o[a.fromId]===void 0&&(i.push(a.fromId),o[a.fromId]=!0):t!=="from"&&a.fromId==s.id&&o[a.toId]===void 0&&(i.push(a.toId),o[a.toId]=!0)}}return i}getConnectedEdges(e){let t=[];if(this.body.nodes[e]!==void 0){let i=this.body.nodes[e];for(let s=0;s<i.edges.length;s++)t.push(i.edges[s].id)}else console.error("NodeId provided for getConnectedEdges does not exist. Provided: ",e);return t}moveNode(e,t,i){this.body.nodes[e]!==void 0?(this.body.nodes[e].x=Number(t),this.body.nodes[e].y=Number(i),setTimeout(()=>{this.body.emitter.emit("startSimulation")},0)):console.error("Node id supplied to moveNode does not exist. Provided: ",e)}},G=class{static transform(e,t){Array.isArray(e)||(e=[e]);let i=t.point.x,s=t.point.y,o=t.angle,r=t.length;for(let a=0;a<e.length;++a){let d=e[a],h=d.x*Math.cos(o)-d.y*Math.sin(o),l=d.x*Math.sin(o)+d.y*Math.cos(o);d.x=i+r*h,d.y=s+r*l}}static drawPath(e,t){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;++i)e.lineTo(t[i].x,t[i].y);e.closePath()}},ka=class extends G{static draw(e,t){if(t.image){e.save(),e.translate(t.point.x,t.point.y),e.rotate(Math.PI/2+t.angle);let i=t.imageWidth!=null?t.imageWidth:t.image.width,s=t.imageHeight!=null?t.imageHeight:t.image.height;t.image.drawImageAtPosition(e,1,-i/2,0,i,s),e.restore()}return!1}},Lo=class extends G{static draw(e,t){let i=[{x:0,y:0},{x:-1,y:.3},{x:-.9,y:0},{x:-1,y:-.3}];return G.transform(i,t),G.drawPath(e,i),!0}},Ro=class{static draw(e,t){let i=[{x:-1,y:0},{x:0,y:.3},{x:-.4,y:0},{x:0,y:-.3}];return G.transform(i,t),G.drawPath(e,i),!0}},Ho=class{static draw(e,t){let i={x:-.4,y:0};G.transform(i,t),e.strokeStyle=e.fillStyle,e.fillStyle="rgba(0, 0, 0, 0)";let s=Math.PI,o=t.angle-s/2,r=t.angle+s/2;return e.beginPath(),e.arc(i.x,i.y,t.length*.4,o,r,!1),e.stroke(),!0}},jo=class{static draw(e,t){let i={x:-.3,y:0};G.transform(i,t),e.strokeStyle=e.fillStyle,e.fillStyle="rgba(0, 0, 0, 0)";let s=Math.PI,o=t.angle+s/2,r=t.angle+3*s/2;return e.beginPath(),e.arc(i.x,i.y,t.length*.4,o,r,!1),e.stroke(),!0}},Wo=class{static draw(e,t){let i=[{x:.02,y:0},{x:-1,y:.3},{x:-1,y:-.3}];return G.transform(i,t),G.drawPath(e,i),!0}},Vo=class{static draw(e,t){let i=[{x:0,y:.3},{x:0,y:-.3},{x:-1,y:0}];return G.transform(i,t),G.drawPath(e,i),!0}},qo=class{static draw(e,t){let i={x:-.4,y:0};return G.transform(i,t),Ci(e,i.x,i.y,t.length*.4),!0}},Uo=class{static draw(e,t){let i=[{x:0,y:.5},{x:0,y:-.5},{x:-.15,y:-.5},{x:-.15,y:.5}];return G.transform(i,t),G.drawPath(e,i),!0}},Yo=class{static draw(e,t){let i=[{x:0,y:.3},{x:0,y:-.3},{x:-.6,y:-.3},{x:-.6,y:.3}];return G.transform(i,t),G.drawPath(e,i),!0}},Xo=class{static draw(e,t){let i=[{x:0,y:0},{x:-.5,y:-.3},{x:-1,y:0},{x:-.5,y:.3}];return G.transform(i,t),G.drawPath(e,i),!0}},Go=class{static draw(e,t){let i=[{x:-1,y:.3},{x:-.5,y:0},{x:-1,y:-.3},{x:0,y:0}];return G.transform(i,t),G.drawPath(e,i),!0}},Di=class{static draw(e,t){let i;switch(t.type&&(i=t.type.toLowerCase()),i){case"image":return ka.draw(e,t);case"circle":return qo.draw(e,t);case"box":return Yo.draw(e,t);case"crow":return Ro.draw(e,t);case"curve":return Ho.draw(e,t);case"diamond":return Xo.draw(e,t);case"inv_curve":return jo.draw(e,t);case"triangle":return Wo.draw(e,t);case"inv_triangle":return Vo.draw(e,t);case"bar":return Uo.draw(e,t);case"vee":return Go.draw(e,t);case"arrow":default:return Lo.draw(e,t)}}},Fi=class{constructor(e,t,i){this._body=t,this._labelModule=i,this.color={},this.colorDirty=!0,this.hoverWidth=1.5,this.selectionWidth=2,this.setOptions(e),this.fromPoint=this.from,this.toPoint=this.to}connect(){this.from=this._body.nodes[this.options.from],this.to=this._body.nodes[this.options.to]}cleanup(){return!1}setOptions(e){this.options=e,this.from=this._body.nodes[this.options.from],this.to=this._body.nodes[this.options.to],this.id=this.options.id}drawLine(e,t,i,s,o=this.getViaNode()){e.strokeStyle=this.getColor(e,t),e.lineWidth=t.width,t.dashes!==!1?this._drawDashedLine(e,t,o):this._drawLine(e,t,o)}_drawLine(e,t,i,s,o){if(this.from!=this.to)this._line(e,t,i,s,o);else{let[r,a,d]=this._getCircleData(e);this._circle(e,t,r,a,d)}}_drawDashedLine(e,t,i,s,o){e.lineCap="round";let r=Array.isArray(t.dashes)?t.dashes:[5,5];if(e.setLineDash!==void 0){if(e.save(),e.setLineDash(r),e.lineDashOffset=0,this.from!=this.to)this._line(e,t,i);else{let[a,d,h]=this._getCircleData(e);this._circle(e,t,a,d,h)}e.setLineDash([0]),e.lineDashOffset=0,e.restore()}else{if(this.from!=this.to)ho(e,this.from.x,this.from.y,this.to.x,this.to.y,r);else{let[a,d,h]=this._getCircleData(e);this._circle(e,t,a,d,h)}this.enableShadow(e,t),e.stroke(),this.disableShadow(e,t)}}findBorderPosition(e,t,i){return this.from!=this.to?this._findBorderPosition(e,t,i):this._findBorderPositionCircle(e,t,i)}findBorderPositions(e){if(this.from!=this.to)return{from:this._findBorderPosition(this.from,e),to:this._findBorderPosition(this.to,e)};{let[t,i]=this._getCircleData(e).slice(0,2);return{from:this._findBorderPositionCircle(this.from,e,{x:t,y:i,low:.25,high:.6,direction:-1}),to:this._findBorderPositionCircle(this.from,e,{x:t,y:i,low:.6,high:.8,direction:1})}}}_getCircleData(e){let t=this.options.selfReference.size;e!==void 0&&this.from.shape.width===void 0&&this.from.shape.resize(e);let i=Co(e,this.options.selfReference.angle,t,this.from);return[i.x,i.y,t]}_pointOnCircle(e,t,i,s){let o=s*2*Math.PI;return{x:e+i*Math.cos(o),y:t-i*Math.sin(o)}}_findBorderPositionCircle(e,t,i){let s=i.x,o=i.y,r=i.low,a=i.high,d=i.direction,h=10,l=this.options.selfReference.size,c=.05,u,p=(r+a)*.5,b=0;this.options.arrowStrikethrough===!0&&(d===-1?b=this.options.endPointOffset.from:d===1&&(b=this.options.endPointOffset.to));let C=0;do{p=(r+a)*.5,u=this._pointOnCircle(s,o,l,p);let f=Math.atan2(e.y-u.y,e.x-u.x),g=e.distanceToBorder(t,f)+b,m=Math.sqrt(Math.pow(u.x-e.x,2)+Math.pow(u.y-e.y,2)),v=g-m;if(Math.abs(v)<c)break;v>0?d>0?r=p:a=p:d>0?a=p:r=p,++C}while(r<=a&&C<h);return Be(de({},u),{t:p})}getLineWidth(e,t){return e===!0?Math.max(this.selectionWidth,.3/this._body.view.scale):t===!0?Math.max(this.hoverWidth,.3/this._body.view.scale):Math.max(this.options.width,.3/this._body.view.scale)}getColor(e,t){if(t.inheritsColor!==!1){if(t.inheritsColor==="both"&&this.from.id!==this.to.id){let i=e.createLinearGradient(this.from.x,this.from.y,this.to.x,this.to.y),s=this.from.options.color.highlight.border,o=this.to.options.color.highlight.border;return this.from.selected===!1&&this.to.selected===!1?(s=re(this.from.options.color.border,t.opacity),o=re(this.to.options.color.border,t.opacity)):this.from.selected===!0&&this.to.selected===!1?o=this.to.options.color.border:this.from.selected===!1&&this.to.selected===!0&&(s=this.from.options.color.border),i.addColorStop(0,s),i.addColorStop(1,o),i}return t.inheritsColor==="to"?re(this.to.options.color.border,t.opacity):re(this.from.options.color.border,t.opacity)}else return re(t.color,t.opacity)}_circle(e,t,i,s,o){this.enableShadow(e,t);let r=0,a=Math.PI*2;if(!this.options.selfReference.renderBehindTheNode){let d=this.options.selfReference.angle,h=this.options.selfReference.angle+Math.PI,l=this._findBorderPositionCircle(this.from,e,{x:i,y:s,low:d,high:h,direction:-1}),c=this._findBorderPositionCircle(this.from,e,{x:i,y:s,low:d,high:h,direction:1});r=Math.atan2(l.y-s,l.x-i),a=Math.atan2(c.y-s,c.x-i)}e.beginPath(),e.arc(i,s,o,r,a,!1),e.stroke(),this.disableShadow(e,t)}getDistanceToEdge(e,t,i,s,o,r){if(this.from!=this.to)return this._getDistanceToEdge(e,t,i,s,o,r);{let[a,d,h]=this._getCircleData(void 0),l=a-o,c=d-r;return Math.abs(Math.sqrt(l*l+c*c)-h)}}_getDistanceToLine(e,t,i,s,o,r){let a=i-e,d=s-t,h=a*a+d*d,l=((o-e)*a+(r-t)*d)/h;l>1?l=1:l<0&&(l=0);let c=e+l*a,u=t+l*d,p=c-o,b=u-r;return Math.sqrt(p*p+b*b)}getArrowData(e,t,i,s,o,r){let a,d,h,l,c,u,p,b=r.width;t==="from"?(h=this.from,l=this.to,c=r.fromArrowScale<0,u=Math.abs(r.fromArrowScale),p=r.fromArrowType):t==="to"?(h=this.to,l=this.from,c=r.toArrowScale<0,u=Math.abs(r.toArrowScale),p=r.toArrowType):(h=this.to,l=this.from,c=r.middleArrowScale<0,u=Math.abs(r.middleArrowScale),p=r.middleArrowType);let C=15*u+3*b;if(h!=l){let v=Math.hypot(h.x-l.x,h.y-l.y),_=C/v;if(t!=="middle")if(this.options.smooth.enabled===!0){let E=this._findBorderPosition(h,e,{via:i}),T=this.getPoint(E.t+_*(t==="from"?1:-1),i);a=Math.atan2(E.y-T.y,E.x-T.x),d=E}else a=Math.atan2(h.y-l.y,h.x-l.x),d=this._findBorderPosition(h,e);else{let E=(c?-_:_)/2,T=this.getPoint(.5+E,i),x=this.getPoint(.5-E,i);a=Math.atan2(T.y-x.y,T.x-x.x),d=this.getPoint(.5,i)}}else{let[v,_,E]=this._getCircleData(e);if(t==="from"){let T=this.options.selfReference.angle,x=this.options.selfReference.angle+Math.PI,w=this._findBorderPositionCircle(this.from,e,{x:v,y:_,low:T,high:x,direction:-1});a=w.t*-2*Math.PI+1.5*Math.PI+.1*Math.PI,d=w}else if(t==="to"){let T=this.options.selfReference.angle,x=this.options.selfReference.angle+Math.PI,w=this._findBorderPositionCircle(this.from,e,{x:v,y:_,low:T,high:x,direction:1});a=w.t*-2*Math.PI+1.5*Math.PI-1.1*Math.PI,d=w}else{let T=this.options.selfReference.angle/(2*Math.PI);d=this._pointOnCircle(v,_,E,T),a=T*-2*Math.PI+1.5*Math.PI+.1*Math.PI}}let f=d.x-C*.9*Math.cos(a),g=d.y-C*.9*Math.sin(a);return{point:d,core:{x:f,y:g},angle:a,length:C,type:p}}drawArrowHead(e,t,i,s,o){e.strokeStyle=this.getColor(e,t),e.fillStyle=e.strokeStyle,e.lineWidth=t.width,Di.draw(e,o)&&(this.enableShadow(e,t),e.fill(),this.disableShadow(e,t))}enableShadow(e,t){t.shadow===!0&&(e.shadowColor=t.shadowColor,e.shadowBlur=t.shadowSize,e.shadowOffsetX=t.shadowX,e.shadowOffsetY=t.shadowY)}disableShadow(e,t){t.shadow===!0&&(e.shadowColor="rgba(0,0,0,0)",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0)}drawBackground(e,t){if(t.background!==!1){let i={strokeStyle:e.strokeStyle,lineWidth:e.lineWidth,dashes:e.dashes};e.strokeStyle=t.backgroundColor,e.lineWidth=t.backgroundSize,this.setStrokeDashed(e,t.backgroundDashes),e.stroke(),e.strokeStyle=i.strokeStyle,e.lineWidth=i.lineWidth,e.dashes=i.dashes,this.setStrokeDashed(e,t.dashes)}}setStrokeDashed(e,t){if(t!==!1)if(e.setLineDash!==void 0){let i=Array.isArray(t)?t:[5,5];e.setLineDash(i)}else console.warn("setLineDash is not supported in this browser. The dashed stroke cannot be used.");else e.setLineDash!==void 0?e.setLineDash([]):console.warn("setLineDash is not supported in this browser. The dashed stroke cannot be used.")}},Kt=class extends Fi{constructor(e,t,i){super(e,t,i)}_findBorderPositionBezier(e,t,i=this._getViaCoordinates()){let s=10,o=.2,r=!1,a=1,d=0,h=this.to,l,c,u=this.options.endPointOffset?this.options.endPointOffset.to:0;e.id===this.from.id&&(h=this.from,r=!0,u=this.options.endPointOffset?this.options.endPointOffset.from:0),this.options.arrowStrikethrough===!1&&(u=0);let p=0;do{c=(d+a)*.5,l=this.getPoint(c,i);let b=Math.atan2(h.y-l.y,h.x-l.x),C=h.distanceToBorder(t,b)+u,f=Math.sqrt(Math.pow(l.x-h.x,2)+Math.pow(l.y-h.y,2)),g=C-f;if(Math.abs(g)<o)break;g<0?r===!1?d=c:a=c:r===!1?a=c:d=c,++p}while(d<=a&&p<s);return Be(de({},l),{t:c})}_getDistanceToBezierEdge(e,t,i,s,o,r,a){let d=1e9,h,l,c,u,p,b=e,C=t;for(l=1;l<10;l++)c=.1*l,u=Math.pow(1-c,2)*e+2*c*(1-c)*a.x+Math.pow(c,2)*i,p=Math.pow(1-c,2)*t+2*c*(1-c)*a.y+Math.pow(c,2)*s,l>0&&(h=this._getDistanceToLine(b,C,u,p,o,r),d=h<d?h:d),b=u,C=p;return d}_bezierCurve(e,t,i,s){e.beginPath(),e.moveTo(this.fromPoint.x,this.fromPoint.y),i!=null&&i.x!=null?s!=null&&s.x!=null?e.bezierCurveTo(i.x,i.y,s.x,s.y,this.toPoint.x,this.toPoint.y):e.quadraticCurveTo(i.x,i.y,this.toPoint.x,this.toPoint.y):e.lineTo(this.toPoint.x,this.toPoint.y),this.drawBackground(e,t),this.enableShadow(e,t),e.stroke(),this.disableShadow(e,t)}getViaNode(){return this._getViaCoordinates()}},Ni=class extends Kt{constructor(e,t,i){super(e,t,i);this.via=this.via,this._boundFunction=()=>{this.positionBezierNode()},this._body.emitter.on("_repositionBezierNodes",this._boundFunction)}setOptions(e){super.setOptions(e);let t=!1;this.options.physics!==e.physics&&(t=!0),this.options=e,this.id=this.options.id,this.from=this._body.nodes[this.options.from],this.to=this._body.nodes[this.options.to],this.setupSupportNode(),this.connect(),t===!0&&(this.via.setOptions({physics:this.options.physics}),this.positionBezierNode())}connect(){this.from=this._body.nodes[this.options.from],this.to=this._body.nodes[this.options.to],this.from===void 0||this.to===void 0||this.options.physics===!1?this.via.setOptions({physics:!1}):this.from.id===this.to.id?this.via.setOptions({physics:!1}):this.via.setOptions({physics:!0})}cleanup(){return this._body.emitter.off("_repositionBezierNodes",this._boundFunction),this.via!==void 0?(delete this._body.nodes[this.via.id],this.via=void 0,!0):!1}setupSupportNode(){if(this.via===void 0){let e="edgeId:"+this.id,t=this._body.functions.createNode({id:e,shape:"circle",physics:!0,hidden:!0});this._body.nodes[e]=t,this.via=t,this.via.parentEdgeId=this.id,this.positionBezierNode()}}positionBezierNode(){this.via!==void 0&&this.from!==void 0&&this.to!==void 0?(this.via.x=.5*(this.from.x+this.to.x),this.via.y=.5*(this.from.y+this.to.y)):this.via!==void 0&&(this.via.x=0,this.via.y=0)}_line(e,t,i){this._bezierCurve(e,t,i)}_getViaCoordinates(){return this.via}getViaNode(){return this.via}getPoint(e,t=this.via){if(this.from===this.to){let[i,s,o]=this._getCircleData(),r=2*Math.PI*(1-e);return{x:i+o*Math.sin(r),y:s+o-o*(1-Math.cos(r))}}else return{x:Math.pow(1-e,2)*this.fromPoint.x+2*e*(1-e)*t.x+Math.pow(e,2)*this.toPoint.x,y:Math.pow(1-e,2)*this.fromPoint.y+2*e*(1-e)*t.y+Math.pow(e,2)*this.toPoint.y}}_findBorderPosition(e,t){return this._findBorderPositionBezier(e,t,this.via)}_getDistanceToEdge(e,t,i,s,o,r){return this._getDistanceToBezierEdge(e,t,i,s,o,r,this.via)}},Bi=class extends Kt{constructor(e,t,i){super(e,t,i)}_line(e,t,i){this._bezierCurve(e,t,i)}getViaNode(){return this._getViaCoordinates()}_getViaCoordinates(){let e=this.options.smooth.roundness,t=this.options.smooth.type,i=Math.abs(this.from.x-this.to.x),s=Math.abs(this.from.y-this.to.y);if(t==="discrete"||t==="diagonalCross"){let o,r;i<=s?o=r=e*s:o=r=e*i,this.from.x>this.to.x&&(o=-o),this.from.y>=this.to.y&&(r=-r);let a=this.from.x+o,d=this.from.y+r;return t==="discrete"&&(i<=s?a=i<e*s?this.from.x:a:d=s<e*i?this.from.y:d),{x:a,y:d}}else if(t==="straightCross"){let o=(1-e)*i,r=(1-e)*s;return i<=s?(o=0,this.from.y<this.to.y&&(r=-r)):(this.from.x<this.to.x&&(o=-o),r=0),{x:this.to.x+o,y:this.to.y+r}}else if(t==="horizontal"){let o=(1-e)*i;return this.from.x<this.to.x&&(o=-o),{x:this.to.x+o,y:this.from.y}}else if(t==="vertical"){let o=(1-e)*s;return this.from.y<this.to.y&&(o=-o),{x:this.from.x,y:this.to.y+o}}else if(t==="curvedCW"){i=this.to.x-this.from.x,s=this.from.y-this.to.y;let o=Math.sqrt(i*i+s*s),r=Math.PI,d=(Math.atan2(s,i)+(e*.5+.5)*r)%(2*r);return{x:this.from.x+(e*.5+.5)*o*Math.sin(d),y:this.from.y+(e*.5+.5)*o*Math.cos(d)}}else if(t==="curvedCCW"){i=this.to.x-this.from.x,s=this.from.y-this.to.y;let o=Math.sqrt(i*i+s*s),r=Math.PI,d=(Math.atan2(s,i)+(-e*.5+.5)*r)%(2*r);return{x:this.from.x+(e*.5+.5)*o*Math.sin(d),y:this.from.y+(e*.5+.5)*o*Math.cos(d)}}else{let o,r;i<=s?o=r=e*s:o=r=e*i,this.from.x>this.to.x&&(o=-o),this.from.y>=this.to.y&&(r=-r);let a=this.from.x+o,d=this.from.y+r;return i<=s?this.from.x<=this.to.x?a=this.to.x<a?this.to.x:a:a=this.to.x>a?this.to.x:a:this.from.y>=this.to.y?d=this.to.y>d?this.to.y:d:d=this.to.y<d?this.to.y:d,{x:a,y:d}}}_findBorderPosition(e,t,i={}){return this._findBorderPositionBezier(e,t,i.via)}_getDistanceToEdge(e,t,i,s,o,r,a=this._getViaCoordinates()){return this._getDistanceToBezierEdge(e,t,i,s,o,r,a)}getPoint(e,t=this._getViaCoordinates()){let i=e,s=Math.pow(1-i,2)*this.fromPoint.x+2*i*(1-i)*t.x+Math.pow(i,2)*this.toPoint.x,o=Math.pow(1-i,2)*this.fromPoint.y+2*i*(1-i)*t.y+Math.pow(i,2)*this.toPoint.y;return{x:s,y:o}}},Ko=class extends Kt{constructor(e,t,i){super(e,t,i)}_getDistanceToBezierEdge2(e,t,i,s,o,r,a,d){let h=1e9,l=e,c=t,u=[0,0,0,0];for(let p=1;p<10;p++){let b=.1*p;u[0]=Math.pow(1-b,3),u[1]=3*b*Math.pow(1-b,2),u[2]=3*Math.pow(b,2)*(1-b),u[3]=Math.pow(b,3);let C=u[0]*e+u[1]*a.x+u[2]*d.x+u[3]*i,f=u[0]*t+u[1]*a.y+u[2]*d.y+u[3]*s;if(p>0){let g=this._getDistanceToLine(l,c,C,f,o,r);h=g<h?g:h}l=C,c=f}return h}},Ai=class extends Ko{constructor(e,t,i){super(e,t,i)}_line(e,t,i){let s=i[0],o=i[1];this._bezierCurve(e,t,s,o)}_getViaCoordinates(){let e=this.from.x-this.to.x,t=this.from.y-this.to.y,i,s,o,r,a=this.options.smooth.roundness;return(Math.abs(e)>Math.abs(t)||this.options.smooth.forceDirection===!0||this.options.smooth.forceDirection==="horizontal")&&this.options.smooth.forceDirection!=="vertical"?(s=this.from.y,r=this.to.y,i=this.from.x-a*e,o=this.to.x+a*e):(s=this.from.y-a*t,r=this.to.y+a*t,i=this.from.x,o=this.to.x),[{x:i,y:s},{x:o,y:r}]}getViaNode(){return this._getViaCoordinates()}_findBorderPosition(e,t){return this._findBorderPositionBezier(e,t)}_getDistanceToEdge(e,t,i,s,o,r,[a,d]=this._getViaCoordinates()){return this._getDistanceToBezierEdge2(e,t,i,s,o,r,a,d)}getPoint(e,[t,i]=this._getViaCoordinates()){let s=e,o=[Math.pow(1-s,3),3*s*Math.pow(1-s,2),3*Math.pow(s,2)*(1-s),Math.pow(s,3)],r=o[0]*this.fromPoint.x+o[1]*t.x+o[2]*i.x+o[3]*this.toPoint.x,a=o[0]*this.fromPoint.y+o[1]*t.y+o[2]*i.y+o[3]*this.toPoint.y;return{x:r,y:a}}},zi=class extends Fi{constructor(e,t,i){super(e,t,i)}_line(e,t){e.beginPath(),e.moveTo(this.fromPoint.x,this.fromPoint.y),e.lineTo(this.toPoint.x,this.toPoint.y),this.enableShadow(e,t),e.stroke(),this.disableShadow(e,t)}getViaNode(){}getPoint(e){return{x:(1-e)*this.fromPoint.x+e*this.toPoint.x,y:(1-e)*this.fromPoint.y+e*this.toPoint.y}}_findBorderPosition(e,t){let i=this.to,s=this.from;e.id===this.from.id&&(i=this.from,s=this.to);let o=Math.atan2(i.y-s.y,i.x-s.x),r=i.x-s.x,a=i.y-s.y,d=Math.sqrt(r*r+a*a),h=e.distanceToBorder(t,o),l=(d-h)/d;return{x:(1-l)*s.x+l*i.x,y:(1-l)*s.y+l*i.y,t:0}}_getDistanceToEdge(e,t,i,s,o,r){return this._getDistanceToLine(e,t,i,s,o,r)}},Se=class{constructor(e,t,i,s,o){if(t===void 0)throw new Error("No body provided");this.options=Ee(s),this.globalOptions=s,this.defaultOptions=o,this.body=t,this.imagelist=i,this.id=void 0,this.fromId=void 0,this.toId=void 0,this.selected=!1,this.hover=!1,this.labelDirty=!0,this.baseWidth=this.options.width,this.baseFontSize=this.options.font.size,this.from=void 0,this.to=void 0,this.edgeType=void 0,this.connected=!1,this.labelModule=new Ye(this.body,this.options,!0),this.setOptions(e)}setOptions(e){if(!e)return;let t=typeof e.physics!="undefined"&&this.options.physics!==e.physics||typeof e.hidden!="undefined"&&(this.options.hidden||!1)!==(e.hidden||!1)||typeof e.from!="undefined"&&this.options.from!==e.from||typeof e.to!="undefined"&&this.options.to!==e.to;Se.parseOptions(this.options,e,!0,this.globalOptions),e.id!==void 0&&(this.id=e.id),e.from!==void 0&&(this.fromId=e.from),e.to!==void 0&&(this.toId=e.to),e.title!==void 0&&(this.title=e.title),e.value!==void 0&&(e.value=parseFloat(e.value));let i=[e,this.options,this.defaultOptions];return this.chooser=Oi("edge",i),this.updateLabelModule(e),t=this.updateEdgeType()||t,this._setInteractionWidths(),this.connect(),t}static parseOptions(e,t,i=!1,s={},o=!1){if(qe(["endPointOffset","arrowStrikethrough","id","from","hidden","hoverWidth","labelHighlightBold","length","line","opacity","physics","scaling","selectionWidth","selfReferenceSize","selfReference","to","title","value","width","font","chosen","widthConstraint"],e,t,i),t.endPointOffset!==void 0&&t.endPointOffset.from!==void 0&&(Number.isFinite(t.endPointOffset.from)?e.endPointOffset.from=t.endPointOffset.from:(e.endPointOffset.from=s.endPointOffset.from!==void 0?s.endPointOffset.from:0,console.error("endPointOffset.from is not a valid number"))),t.endPointOffset!==void 0&&t.endPointOffset.to!==void 0&&(Number.isFinite(t.endPointOffset.to)?e.endPointOffset.to=t.endPointOffset.to:(e.endPointOffset.to=s.endPointOffset.to!==void 0?s.endPointOffset.to:0,console.error("endPointOffset.to is not a valid number"))),Yt(t.label)?e.label=t.label:Yt(e.label)||(e.label=void 0),ae(e,t,"smooth",s),ae(e,t,"shadow",s),ae(e,t,"background",s),t.dashes!==void 0&&t.dashes!==null?e.dashes=t.dashes:i===!0&&t.dashes===null&&(e.dashes=Object.create(s.dashes)),t.scaling!==void 0&&t.scaling!==null?(t.scaling.min!==void 0&&(e.scaling.min=t.scaling.min),t.scaling.max!==void 0&&(e.scaling.max=t.scaling.max),ae(e.scaling,t.scaling,"label",s.scaling)):i===!0&&t.scaling===null&&(e.scaling=Object.create(s.scaling)),t.arrows!==void 0&&t.arrows!==null)if(typeof t.arrows=="string"){let a=t.arrows.toLowerCase();e.arrows.to.enabled=a.indexOf("to")!=-1,e.arrows.middle.enabled=a.indexOf("middle")!=-1,e.arrows.from.enabled=a.indexOf("from")!=-1}else if(typeof t.arrows=="object")ae(e.arrows,t.arrows,"to",s.arrows),ae(e.arrows,t.arrows,"middle",s.arrows),ae(e.arrows,t.arrows,"from",s.arrows);else throw new Error("The arrow newOptions can only be an object or a string. Refer to the documentation. You used:"+JSON.stringify(t.arrows));else i===!0&&t.arrows===null&&(e.arrows=Object.create(s.arrows));if(t.color!==void 0&&t.color!==null){let a=_e(t.color)?{color:t.color,highlight:t.color,hover:t.color,inherit:!1,opacity:1}:t.color,d=e.color;if(o)j(d,s.color,!1,i);else for(let h in d)Object.prototype.hasOwnProperty.call(d,h)&&delete d[h];if(_e(d))d.color=d,d.highlight=d,d.hover=d,d.inherit=!1,a.opacity===void 0&&(d.opacity=1);else{let h=!1;a.color!==void 0&&(d.color=a.color,h=!0),a.highlight!==void 0&&(d.highlight=a.highlight,h=!0),a.hover!==void 0&&(d.hover=a.hover,h=!0),a.inherit!==void 0&&(d.inherit=a.inherit),a.opacity!==void 0&&(d.opacity=Math.min(1,Math.max(0,a.opacity))),h===!0?d.inherit=!1:d.inherit===void 0&&(d.inherit="from")}}else i===!0&&t.color===null&&(e.color=Ee(s.color));i===!0&&t.font===null&&(e.font=Ee(s.font)),Object.prototype.hasOwnProperty.call(t,"selfReferenceSize")&&(console.warn("The selfReferenceSize property has been deprecated. Please use selfReference property instead. The selfReference can be set like thise selfReference:{size:30, angle:Math.PI / 4}"),e.selfReference.size=t.selfReferenceSize)}getFormattingValues(){let e=this.options.arrows.to===!0||this.options.arrows.to.enabled===!0,t=this.options.arrows.from===!0||this.options.arrows.from.enabled===!0,i=this.options.arrows.middle===!0||this.options.arrows.middle.enabled===!0,s=this.options.color.inherit,o={toArrow:e,toArrowScale:this.options.arrows.to.scaleFactor,toArrowType:this.options.arrows.to.type,toArrowSrc:this.options.arrows.to.src,toArrowImageWidth:this.options.arrows.to.imageWidth,toArrowImageHeight:this.options.arrows.to.imageHeight,middleArrow:i,middleArrowScale:this.options.arrows.middle.scaleFactor,middleArrowType:this.options.arrows.middle.type,middleArrowSrc:this.options.arrows.middle.src,middleArrowImageWidth:this.options.arrows.middle.imageWidth,middleArrowImageHeight:this.options.arrows.middle.imageHeight,fromArrow:t,fromArrowScale:this.options.arrows.from.scaleFactor,fromArrowType:this.options.arrows.from.type,fromArrowSrc:this.options.arrows.from.src,fromArrowImageWidth:this.options.arrows.from.imageWidth,fromArrowImageHeight:this.options.arrows.from.imageHeight,arrowStrikethrough:this.options.arrowStrikethrough,color:s?void 0:this.options.color.color,inheritsColor:s,opacity:this.options.color.opacity,hidden:this.options.hidden,length:this.options.length,shadow:this.options.shadow.enabled,shadowColor:this.options.shadow.color,shadowSize:this.options.shadow.size,shadowX:this.options.shadow.x,shadowY:this.options.shadow.y,dashes:this.options.dashes,width:this.options.width,background:this.options.background.enabled,backgroundColor:this.options.background.color,backgroundSize:this.options.background.size,backgroundDashes:this.options.background.dashes};if(this.selected||this.hover)if(this.chooser===!0){if(this.selected){let r=this.options.selectionWidth;typeof r=="function"?o.width=r(o.width):typeof r=="number"&&(o.width+=r),o.width=Math.max(o.width,.3/this.body.view.scale),o.color=this.options.color.highlight,o.shadow=this.options.shadow.enabled}else if(this.hover){let r=this.options.hoverWidth;typeof r=="function"?o.width=r(o.width):typeof r=="number"&&(o.width+=r),o.width=Math.max(o.width,.3/this.body.view.scale),o.color=this.options.color.hover,o.shadow=this.options.shadow.enabled}}else typeof this.chooser=="function"&&(this.chooser(o,this.options.id,this.selected,this.hover),o.color!==void 0&&(o.inheritsColor=!1),o.shadow===!1&&(o.shadowColor!==this.options.shadow.color||o.shadowSize!==this.options.shadow.size||o.shadowX!==this.options.shadow.x||o.shadowY!==this.options.shadow.y)&&(o.shadow=!0));else o.shadow=this.options.shadow.enabled,o.width=Math.max(o.width,.3/this.body.view.scale);return o}updateLabelModule(e){let t=[e,this.options,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,t),this.labelModule.baseSize!==void 0&&(this.baseFontSize=this.labelModule.baseSize)}updateEdgeType(){let e=this.options.smooth,t=!1,i=!0;return this.edgeType!==void 0&&((this.edgeType instanceof Ni&&e.enabled===!0&&e.type==="dynamic"||this.edgeType instanceof Ai&&e.enabled===!0&&e.type==="cubicBezier"||this.edgeType instanceof Bi&&e.enabled===!0&&e.type!=="dynamic"&&e.type!=="cubicBezier"||this.edgeType instanceof zi&&e.type.enabled===!1)&&(i=!1),i===!0&&(t=this.cleanup())),i===!0?e.enabled===!0?e.type==="dynamic"?(t=!0,this.edgeType=new Ni(this.options,this.body,this.labelModule)):e.type==="cubicBezier"?this.edgeType=new Ai(this.options,this.body,this.labelModule):this.edgeType=new Bi(this.options,this.body,this.labelModule):this.edgeType=new zi(this.options,this.body,this.labelModule):this.edgeType.setOptions(this.options),t}connect(){this.disconnect(),this.from=this.body.nodes[this.fromId]||void 0,this.to=this.body.nodes[this.toId]||void 0,this.connected=this.from!==void 0&&this.to!==void 0,this.connected===!0?(this.from.attachEdge(this),this.to.attachEdge(this)):(this.from&&this.from.detachEdge(this),this.to&&this.to.detachEdge(this)),this.edgeType.connect()}disconnect(){this.from&&(this.from.detachEdge(this),this.from=void 0),this.to&&(this.to.detachEdge(this),this.to=void 0),this.connected=!1}getTitle(){return this.title}isSelected(){return this.selected}getValue(){return this.options.value}setValueRange(e,t,i){if(this.options.value!==void 0){let s=this.options.scaling.customScalingFunction(e,t,i,this.options.value),o=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let r=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+s*r}this.options.width=this.options.scaling.min+s*o}else this.options.width=this.baseWidth,this.options.font.size=this.baseFontSize;this._setInteractionWidths(),this.updateLabelModule()}_setInteractionWidths(){typeof this.options.hoverWidth=="function"?this.edgeType.hoverWidth=this.options.hoverWidth(this.options.width):this.edgeType.hoverWidth=this.options.hoverWidth+this.options.width,typeof this.options.selectionWidth=="function"?this.edgeType.selectionWidth=this.options.selectionWidth(this.options.width):this.edgeType.selectionWidth=this.options.selectionWidth+this.options.width}draw(e){let t=this.getFormattingValues();if(t.hidden)return;let i=this.edgeType.getViaNode();this.edgeType.drawLine(e,t,this.selected,this.hover,i),this.drawLabel(e,i)}drawArrows(e){let t=this.getFormattingValues();if(t.hidden)return;let i=this.edgeType.getViaNode(),s={};this.edgeType.fromPoint=this.edgeType.from,this.edgeType.toPoint=this.edgeType.to,t.fromArrow&&(s.from=this.edgeType.getArrowData(e,"from",i,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.fromPoint=s.from.core),t.fromArrowSrc&&(s.from.image=this.imagelist.load(t.fromArrowSrc)),t.fromArrowImageWidth&&(s.from.imageWidth=t.fromArrowImageWidth),t.fromArrowImageHeight&&(s.from.imageHeight=t.fromArrowImageHeight)),t.toArrow&&(s.to=this.edgeType.getArrowData(e,"to",i,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.toPoint=s.to.core),t.toArrowSrc&&(s.to.image=this.imagelist.load(t.toArrowSrc)),t.toArrowImageWidth&&(s.to.imageWidth=t.toArrowImageWidth),t.toArrowImageHeight&&(s.to.imageHeight=t.toArrowImageHeight)),t.middleArrow&&(s.middle=this.edgeType.getArrowData(e,"middle",i,this.selected,this.hover,t),t.middleArrowSrc&&(s.middle.image=this.imagelist.load(t.middleArrowSrc)),t.middleArrowImageWidth&&(s.middle.imageWidth=t.middleArrowImageWidth),t.middleArrowImageHeight&&(s.middle.imageHeight=t.middleArrowImageHeight)),t.fromArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,s.from),t.middleArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,s.middle),t.toArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,s.to)}drawLabel(e,t){if(this.options.label!==void 0){let i=this.from,s=this.to;this.labelModule.differentState(this.selected,this.hover)&&this.labelModule.getTextSize(e,this.selected,this.hover);let o;if(i.id!=s.id){this.labelModule.pointToSelf=!1,o=this.edgeType.getPoint(.5,t),e.save();let r=this._getRotation(e);r.angle!=0&&(e.translate(r.x,r.y),e.rotate(r.angle)),this.labelModule.draw(e,o.x,o.y,this.selected,this.hover),e.restore()}else{this.labelModule.pointToSelf=!0;let r=Co(e,this.options.selfReference.angle,this.options.selfReference.size,i);o=this._pointOnCircle(r.x,r.y,this.options.selfReference.size,this.options.selfReference.angle),this.labelModule.draw(e,o.x,o.y,this.selected,this.hover)}}}getItemsOnPoint(e){let t=[];if(this.labelModule.visible()){let s=this._getRotation();Ii(this.labelModule.getSize(),e,s)&&t.push({edgeId:this.id,labelId:0})}let i={left:e.x,top:e.y};return this.isOverlappingWith(i)&&t.push({edgeId:this.id}),t}isOverlappingWith(e){if(this.connected){let t=10,i=this.from.x,s=this.from.y,o=this.to.x,r=this.to.y,a=e.left,d=e.top;return this.edgeType.getDistanceToEdge(i,s,o,r,a,d)<t}else return!1}_getRotation(e){let t=this.edgeType.getViaNode(),i=this.edgeType.getPoint(.5,t);e!==void 0&&this.labelModule.calculateLabelSize(e,this.selected,this.hover,i.x,i.y);let s={x:i.x,y:this.labelModule.size.yLine,angle:0};if(!this.labelModule.visible()||this.options.font.align==="horizontal")return s;let o=this.from.y-this.to.y,r=this.from.x-this.to.x,a=Math.atan2(o,r);return(a<-1&&r<0||a>0&&r<0)&&(a+=Math.PI),s.angle=a,s}_pointOnCircle(e,t,i,s){return{x:e+i*Math.cos(s),y:t-i*Math.sin(s)}}select(){this.selected=!0}unselect(){this.selected=!1}cleanup(){return this.edgeType.cleanup()}remove(){this.cleanup(),this.disconnect(),delete this.body.edges[this.id]}endPointsValid(){return this.body.nodes[this.fromId]!==void 0&&this.body.nodes[this.toId]!==void 0}},Zo=class{constructor(e,t,i){this.body=e,this.images=t,this.groups=i,this.body.functions.createEdge=this.create.bind(this),this.edgesListeners={add:(s,o)=>{this.add(o.items)},update:(s,o)=>{this.update(o.items)},remove:(s,o)=>{this.remove(o.items)}},this.options={},this.defaultOptions={arrows:{to:{enabled:!1,scaleFactor:1,type:"arrow"},middle:{enabled:!1,scaleFactor:1,type:"arrow"},from:{enabled:!1,scaleFactor:1,type:"arrow"}},endPointOffset:{from:0,to:0},arrowStrikethrough:!0,color:{color:"#848484",highlight:"#848484",hover:"#848484",inherit:"from",opacity:1},dashes:!1,font:{color:"#343434",size:14,face:"arial",background:"none",strokeWidth:2,strokeColor:"#ffffff",align:"horizontal",multi:!1,vadjust:0,bold:{mod:"bold"},boldital:{mod:"bold italic"},ital:{mod:"italic"},mono:{mod:"",size:15,face:"courier new",vadjust:2}},hidden:!1,hoverWidth:1.5,label:void 0,labelHighlightBold:!0,length:void 0,physics:!0,scaling:{min:1,max:15,label:{enabled:!0,min:14,max:30,maxVisible:30,drawThreshold:5},customScalingFunction:function(s,o,r,a){if(o===s)return .5;{let d=1/(o-s);return Math.max(0,(a-s)*d)}}},selectionWidth:1.5,selfReference:{size:20,angle:Math.PI/4,renderBehindTheNode:!0},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:10,x:5,y:5},background:{enabled:!1,color:"rgba(111,111,111,1)",size:10,dashes:!1},smooth:{enabled:!0,type:"dynamic",forceDirection:"none",roundness:.5},title:void 0,width:1,value:void 0},j(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("_forceDisableDynamicCurves",(e,t=!0)=>{e==="dynamic"&&(e="continuous");let i=!1;for(let s in this.body.edges)if(Object.prototype.hasOwnProperty.call(this.body.edges,s)){let o=this.body.edges[s],r=this.body.data.edges.get(s);if(r!=null){let a=r.smooth;a!==void 0&&a.enabled===!0&&a.type==="dynamic"&&(e===void 0?o.setOptions({smooth:!1}):o.setOptions({smooth:{type:e}}),i=!0)}}t===!0&&i===!0&&this.body.emitter.emit("_dataChanged")}),this.body.emitter.on("_dataUpdated",()=>{this.reconnectEdges()}),this.body.emitter.on("refreshEdges",this.refresh.bind(this)),this.body.emitter.on("refresh",this.refresh.bind(this)),this.body.emitter.on("destroy",()=>{A(this.edgesListeners,(e,t)=>{this.body.data.edges&&this.body.data.edges.off(t,e)}),delete this.body.functions.createEdge,delete this.edgesListeners.add,delete this.edgesListeners.update,delete this.edgesListeners.remove,delete this.edgesListeners})}setOptions(e){if(e!==void 0){Se.parseOptions(this.options,e,!0,this.defaultOptions,!0);let t=!1;if(e.smooth!==void 0)for(let i in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,i)&&(t=this.body.edges[i].updateEdgeType()||t);if(e.font!==void 0)for(let i in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,i)&&this.body.edges[i].updateLabelModule();(e.hidden!==void 0||e.physics!==void 0||t===!0)&&this.body.emitter.emit("_dataChanged")}}setData(e,t=!1){let i=this.body.data.edges;if(xi("id",e))this.body.data.edges=e;else if(Array.isArray(e))this.body.data.edges=new Te,this.body.data.edges.add(e);else if(!e)this.body.data.edges=new Te;else throw new TypeError("Array or DataSet expected");if(i&&A(this.edgesListeners,(s,o)=>{i.off(o,s)}),this.body.edges={},this.body.data.edges){A(this.edgesListeners,(o,r)=>{this.body.data.edges.on(r,o)});let s=this.body.data.edges.getIds();this.add(s,!0)}this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let i=this.body.edges,s=this.body.data.edges;for(let o=0;o<e.length;o++){let r=e[o],a=i[r];a&&a.disconnect();let d=s.get(r,{showInternalIds:!0});i[r]=this.create(d)}this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),t===!1&&this.body.emitter.emit("_dataChanged")}update(e){let t=this.body.edges,i=this.body.data.edges,s=!1;for(let o=0;o<e.length;o++){let r=e[o],a=i.get(r),d=t[r];d!==void 0?(d.disconnect(),s=d.setOptions(a)||s,d.connect()):(this.body.edges[r]=this.create(a),s=!0)}s===!0?(this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),this.body.emitter.emit("_dataChanged")):this.body.emitter.emit("_dataUpdated")}remove(e,t=!0){if(e.length===0)return;let i=this.body.edges;A(e,s=>{let o=i[s];o!==void 0&&o.remove()}),t&&this.body.emitter.emit("_dataChanged")}refresh(){A(this.body.edges,(e,t)=>{let i=this.body.data.edges.get(t);i!==void 0&&e.setOptions(i)})}create(e){return new Se(e,this.body,this.images,this.options,this.defaultOptions)}reconnectEdges(){let e,t=this.body.nodes,i=this.body.edges;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&(t[e].edges=[]);for(e in i)if(Object.prototype.hasOwnProperty.call(i,e)){let s=i[e];s.from=null,s.to=null,s.connect()}}getConnectedNodes(e){let t=[];if(this.body.edges[e]!==void 0){let i=this.body.edges[e];i.fromId!==void 0&&t.push(i.fromId),i.toId!==void 0&&t.push(i.toId)}return t}_updateState(){this._addMissingEdges(),this._removeInvalidEdges()}_removeInvalidEdges(){let e=[];A(this.body.edges,(t,i)=>{let s=this.body.nodes[t.toId],o=this.body.nodes[t.fromId];s!==void 0&&s.isCluster===!0||o!==void 0&&o.isCluster===!0||(s===void 0||o===void 0)&&e.push(i)}),this.remove(e,!1)}_addMissingEdges(){let e=this.body.data.edges;if(e==null)return;let t=this.body.edges,i=[];e.forEach((s,o)=>{t[o]===void 0&&i.push(o)}),this.add(i,!0)}},Li=class{constructor(e,t,i){this.body=e,this.physicsBody=t,this.barnesHutTree,this.setOptions(i),this._rng=yt("BARNES HUT SOLVER")}setOptions(e){this.options=e,this.thetaInversed=1/this.options.theta,this.overlapAvoidanceFactor=1-Math.max(0,Math.min(1,this.options.avoidOverlap))}solve(){if(this.options.gravitationalConstant!==0&&this.physicsBody.physicsNodeIndices.length>0){let e,t=this.body.nodes,i=this.physicsBody.physicsNodeIndices,s=i.length,o=this._formBarnesHutTree(t,i);this.barnesHutTree=o;for(let r=0;r<s;r++)e=t[i[r]],e.options.mass>0&&this._getForceContributions(o.root,e)}}_getForceContributions(e,t){this._getForceContribution(e.children.NW,t),this._getForceContribution(e.children.NE,t),this._getForceContribution(e.children.SW,t),this._getForceContribution(e.children.SE,t)}_getForceContribution(e,t){if(e.childrenCount>0){let i=e.centerOfMass.x-t.x,s=e.centerOfMass.y-t.y,o=Math.sqrt(i*i+s*s);o*e.calcSize>this.thetaInversed?this._calculateForces(o,i,s,t,e):e.childrenCount===4?this._getForceContributions(e,t):e.children.data.id!=t.id&&this._calculateForces(o,i,s,t,e)}}_calculateForces(e,t,i,s,o){e===0&&(e=.1,t=e),this.overlapAvoidanceFactor<1&&s.shape.radius&&(e=Math.max(.1+this.overlapAvoidanceFactor*s.shape.radius,e-s.shape.radius));let r=this.options.gravitationalConstant*o.mass*s.options.mass/Math.pow(e,3),a=t*r,d=i*r;this.physicsBody.forces[s.id].x+=a,this.physicsBody.forces[s.id].y+=d}_formBarnesHutTree(e,t){let i,s=t.length,o=e[t[0]].x,r=e[t[0]].y,a=e[t[0]].x,d=e[t[0]].y;for(let f=1;f<s;f++){let g=e[t[f]],m=g.x,v=g.y;g.options.mass>0&&(m<o&&(o=m),m>a&&(a=m),v<r&&(r=v),v>d&&(d=v))}let h=Math.abs(a-o)-Math.abs(d-r);h>0?(r-=.5*h,d+=.5*h):(o+=.5*h,a-=.5*h);let c=Math.max(1e-5,Math.abs(a-o)),u=.5*c,p=.5*(o+a),b=.5*(r+d),C={root:{centerOfMass:{x:0,y:0},mass:0,range:{minX:p-u,maxX:p+u,minY:b-u,maxY:b+u},size:c,calcSize:1/c,children:{data:null},maxWidth:0,level:0,childrenCount:4}};this._splitBranch(C.root);for(let f=0;f<s;f++)i=e[t[f]],i.options.mass>0&&this._placeInTree(C.root,i);return C}_updateBranchMass(e,t){let i=e.centerOfMass,s=e.mass+t.options.mass,o=1/s;i.x=i.x*e.mass+t.x*t.options.mass,i.x*=o,i.y=i.y*e.mass+t.y*t.options.mass,i.y*=o,e.mass=s;let r=Math.max(Math.max(t.height,t.radius),t.width);e.maxWidth=e.maxWidth<r?r:e.maxWidth}_placeInTree(e,t,i){(i!=!0||i===void 0)&&this._updateBranchMass(e,t);let s=e.children.NW.range,o;s.maxX>t.x?s.maxY>t.y?o="NW":o="SW":s.maxY>t.y?o="NE":o="SE",this._placeInRegion(e,t,o)}_placeInRegion(e,t,i){let s=e.children[i];switch(s.childrenCount){case 0:s.children.data=t,s.childrenCount=1,this._updateBranchMass(s,t);break;case 1:s.children.data.x===t.x&&s.children.data.y===t.y?(t.x+=this._rng(),t.y+=this._rng()):(this._splitBranch(s),this._placeInTree(s,t));break;case 4:this._placeInTree(s,t);break}}_splitBranch(e){let t=null;e.childrenCount===1&&(t=e.children.data,e.mass=0,e.centerOfMass.x=0,e.centerOfMass.y=0),e.childrenCount=4,e.children.data=null,this._insertRegion(e,"NW"),this._insertRegion(e,"NE"),this._insertRegion(e,"SW"),this._insertRegion(e,"SE"),t!=null&&this._placeInTree(e,t)}_insertRegion(e,t){let i,s,o,r,a=.5*e.size;switch(t){case"NW":i=e.range.minX,s=e.range.minX+a,o=e.range.minY,r=e.range.minY+a;break;case"NE":i=e.range.minX+a,s=e.range.maxX,o=e.range.minY,r=e.range.minY+a;break;case"SW":i=e.range.minX,s=e.range.minX+a,o=e.range.minY+a,r=e.range.maxY;break;case"SE":i=e.range.minX+a,s=e.range.maxX,o=e.range.minY+a,r=e.range.maxY;break}e.children[t]={centerOfMass:{x:0,y:0},mass:0,range:{minX:i,maxX:s,minY:o,maxY:r},size:.5*e.size,calcSize:2*e.calcSize,children:{data:null},maxWidth:0,level:e.level+1,childrenCount:0}}_debug(e,t){this.barnesHutTree!==void 0&&(e.lineWidth=1,this._drawBranch(this.barnesHutTree.root,e,t))}_drawBranch(e,t,i){i===void 0&&(i="#FF0000"),e.childrenCount===4&&(this._drawBranch(e.children.NW,t),this._drawBranch(e.children.NE,t),this._drawBranch(e.children.SE,t),this._drawBranch(e.children.SW,t)),t.strokeStyle=i,t.beginPath(),t.moveTo(e.range.minX,e.range.minY),t.lineTo(e.range.maxX,e.range.minY),t.stroke(),t.beginPath(),t.moveTo(e.range.maxX,e.range.minY),t.lineTo(e.range.maxX,e.range.maxY),t.stroke(),t.beginPath(),t.moveTo(e.range.maxX,e.range.maxY),t.lineTo(e.range.minX,e.range.maxY),t.stroke(),t.beginPath(),t.moveTo(e.range.minX,e.range.maxY),t.lineTo(e.range.minX,e.range.minY),t.stroke()}},Qo=class{constructor(e,t,i){this._rng=yt("REPULSION SOLVER"),this.body=e,this.physicsBody=t,this.setOptions(i)}setOptions(e){this.options=e}solve(){let e,t,i,s,o,r,a,d,h=this.body.nodes,l=this.physicsBody.physicsNodeIndices,c=this.physicsBody.forces,u=this.options.nodeDistance,p=-2/3/u,b=4/3;for(let C=0;C<l.length-1;C++){a=h[l[C]];for(let f=C+1;f<l.length;f++)d=h[l[f]],e=d.x-a.x,t=d.y-a.y,i=Math.sqrt(e*e+t*t),i===0&&(i=.1*this._rng(),e=i),i<2*u&&(i<.5*u?r=1:r=p*i+b,r=r/i,s=e*r,o=t*r,c[a.id].x-=s,c[a.id].y-=o,c[d.id].x+=s,c[d.id].y+=o)}}},$o=class{constructor(e,t,i){this.body=e,this.physicsBody=t,this.setOptions(i)}setOptions(e){this.options=e,this.overlapAvoidanceFactor=Math.max(0,Math.min(1,this.options.avoidOverlap||0))}solve(){let e=this.body.nodes,t=this.physicsBody.physicsNodeIndices,i=this.physicsBody.forces,s=this.options.nodeDistance;for(let o=0;o<t.length-1;o++){let r=e[t[o]];for(let a=o+1;a<t.length;a++){let d=e[t[a]];if(r.level===d.level){let h=s+this.overlapAvoidanceFactor*((r.shape.radius||0)/2+(d.shape.radius||0)/2),l=d.x-r.x,c=d.y-r.y,u=Math.sqrt(l*l+c*c),p=.05,b;u<h?b=-Math.pow(p*u,2)+Math.pow(p*h,2):b=0,u!==0&&(b=b/u);let C=l*b,f=c*b;i[r.id].x-=C,i[r.id].y-=f,i[d.id].x+=C,i[d.id].y+=f}}}}},Zt=class{constructor(e,t,i){this.body=e,this.physicsBody=t,this.setOptions(i)}setOptions(e){this.options=e}solve(){let e,t,i=this.physicsBody.physicsEdgeIndices,s=this.body.edges,o,r,a;for(let d=0;d<i.length;d++)t=s[i[d]],t.connected===!0&&t.toId!==t.fromId&&this.body.nodes[t.toId]!==void 0&&this.body.nodes[t.fromId]!==void 0&&(t.edgeType.via!==void 0?(e=t.options.length===void 0?this.options.springLength:t.options.length,o=t.to,r=t.edgeType.via,a=t.from,this._calculateSpringForce(o,r,.5*e),this._calculateSpringForce(r,a,.5*e)):(e=t.options.length===void 0?this.options.springLength*1.5:t.options.length,this._calculateSpringForce(t.from,t.to,e)))}_calculateSpringForce(e,t,i){let s=e.x-t.x,o=e.y-t.y,r=Math.max(Math.sqrt(s*s+o*o),.01),a=this.options.springConstant*(i-r)/r,d=s*a,h=o*a;this.physicsBody.forces[e.id]!==void 0&&(this.physicsBody.forces[e.id].x+=d,this.physicsBody.forces[e.id].y+=h),this.physicsBody.forces[t.id]!==void 0&&(this.physicsBody.forces[t.id].x-=d,this.physicsBody.forces[t.id].y-=h)}},Jo=class{constructor(e,t,i){this.body=e,this.physicsBody=t,this.setOptions(i)}setOptions(e){this.options=e}solve(){let e,t,i,s,o,r,a,d,h=this.body.edges,l=.5,c=this.physicsBody.physicsEdgeIndices,u=this.physicsBody.physicsNodeIndices,p=this.physicsBody.forces;for(let _=0;_<u.length;_++){let E=u[_];p[E].springFx=0,p[E].springFy=0}for(let _=0;_<c.length;_++)t=h[c[_]],t.connected===!0&&(e=t.options.length===void 0?this.options.springLength:t.options.length,i=t.from.x-t.to.x,s=t.from.y-t.to.y,d=Math.sqrt(i*i+s*s),d=d===0?.01:d,a=this.options.springConstant*(e-d)/d,o=i*a,r=s*a,t.to.level!=t.from.level?(p[t.toId]!==void 0&&(p[t.toId].springFx-=o,p[t.toId].springFy-=r),p[t.fromId]!==void 0&&(p[t.fromId].springFx+=o,p[t.fromId].springFy+=r)):(p[t.toId]!==void 0&&(p[t.toId].x-=l*o,p[t.toId].y-=l*r),p[t.fromId]!==void 0&&(p[t.fromId].x+=l*o,p[t.fromId].y+=l*r)));a=1;let b,C;for(let _=0;_<u.length;_++){let E=u[_];b=Math.min(a,Math.max(-a,p[E].springFx)),C=Math.min(a,Math.max(-a,p[E].springFy)),p[E].x+=b,p[E].y+=C}let f=0,g=0;for(let _=0;_<u.length;_++){let E=u[_];f+=p[E].x,g+=p[E].y}let m=f/u.length,v=g/u.length;for(let _=0;_<u.length;_++){let E=u[_];p[E].x-=m,p[E].y-=v}}},Ct=class{constructor(e,t,i){this.body=e,this.physicsBody=t,this.setOptions(i)}setOptions(e){this.options=e}solve(){let e,t,i,s,o=this.body.nodes,r=this.physicsBody.physicsNodeIndices,a=this.physicsBody.forces;for(let d=0;d<r.length;d++){let h=r[d];s=o[h],e=-s.x,t=-s.y,i=Math.sqrt(e*e+t*t),this._calculateForces(i,e,t,a,s)}}_calculateForces(e,t,i,s,o){let r=e===0?0:this.options.centralGravity/e;s[o.id].x=t*r,s[o.id].y=i*r}},en=class extends Li{constructor(e,t,i){super(e,t,i);this._rng=yt("FORCE ATLAS 2 BASED REPULSION SOLVER")}_calculateForces(e,t,i,s,o){e===0&&(e=.1*this._rng(),t=e),this.overlapAvoidanceFactor<1&&s.shape.radius&&(e=Math.max(.1+this.overlapAvoidanceFactor*s.shape.radius,e-s.shape.radius));let r=s.edges.length+1,a=this.options.gravitationalConstant*o.mass*s.options.mass*r/Math.pow(e,2),d=t*a,h=i*a;this.physicsBody.forces[s.id].x+=d,this.physicsBody.forces[s.id].y+=h}},tn=class extends Ct{constructor(e,t,i){super(e,t,i)}_calculateForces(e,t,i,s,o){if(e>0){let r=o.edges.length+1,a=this.options.centralGravity*r*o.options.mass;s[o.id].x=t*a,s[o.id].y=i*a}}},sn=class{constructor(e){this.body=e,this.physicsBody={physicsNodeIndices:[],physicsEdgeIndices:[],forces:{},velocities:{}},this.physicsEnabled=!0,this.simulationInterval=1e3/60,this.requiresTimeout=!0,this.previousStates={},this.referenceState={},this.freezeCache={},this.renderTimer=void 0,this.adaptiveTimestep=!1,this.adaptiveTimestepEnabled=!1,this.adaptiveCounter=0,this.adaptiveInterval=3,this.stabilized=!1,this.startedStabilization=!1,this.stabilizationIterations=0,this.ready=!1,this.options={},this.defaultOptions={enabled:!0,barnesHut:{theta:.5,gravitationalConstant:-2e3,centralGravity:.3,springLength:95,springConstant:.04,damping:.09,avoidOverlap:0},forceAtlas2Based:{theta:.5,gravitationalConstant:-50,centralGravity:.01,springConstant:.08,springLength:100,damping:.4,avoidOverlap:0},repulsion:{centralGravity:.2,springLength:200,springConstant:.05,nodeDistance:100,damping:.09,avoidOverlap:0},hierarchicalRepulsion:{centralGravity:0,springLength:100,springConstant:.01,nodeDistance:120,damping:.09},maxVelocity:50,minVelocity:.75,solver:"barnesHut",stabilization:{enabled:!0,iterations:1e3,updateInterval:50,onlyDynamicEdges:!1,fit:!0},timestep:.5,adaptiveTimestep:!0,wind:{x:0,y:0}},Object.assign(this.options,this.defaultOptions),this.timestep=.5,this.layoutFailed=!1,this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("initPhysics",()=>{this.initPhysics()}),this.body.emitter.on("_layoutFailed",()=>{this.layoutFailed=!0}),this.body.emitter.on("resetPhysics",()=>{this.stopSimulation(),this.ready=!1}),this.body.emitter.on("disablePhysics",()=>{this.physicsEnabled=!1,this.stopSimulation()}),this.body.emitter.on("restorePhysics",()=>{this.setOptions(this.options),this.ready===!0&&this.startSimulation()}),this.body.emitter.on("startSimulation",()=>{this.ready===!0&&this.startSimulation()}),this.body.emitter.on("stopSimulation",()=>{this.stopSimulation()}),this.body.emitter.on("destroy",()=>{this.stopSimulation(!1),this.body.emitter.off()}),this.body.emitter.on("_dataChanged",()=>{this.updatePhysicsData()})}setOptions(e){if(e!==void 0)if(e===!1)this.options.enabled=!1,this.physicsEnabled=!1,this.stopSimulation();else if(e===!0)this.options.enabled=!0,this.physicsEnabled=!0,this.startSimulation();else{this.physicsEnabled=!0,bt(["stabilization"],this.options,e),ae(this.options,e,"stabilization"),e.enabled===void 0&&(this.options.enabled=!0),this.options.enabled===!1&&(this.physicsEnabled=!1,this.stopSimulation());let t=this.options.wind;t&&((typeof t.x!="number"||Number.isNaN(t.x))&&(t.x=0),(typeof t.y!="number"||Number.isNaN(t.y))&&(t.y=0)),this.timestep=this.options.timestep}this.init()}init(){let e;this.options.solver==="forceAtlas2Based"?(e=this.options.forceAtlas2Based,this.nodesSolver=new en(this.body,this.physicsBody,e),this.edgesSolver=new Zt(this.body,this.physicsBody,e),this.gravitySolver=new tn(this.body,this.physicsBody,e)):this.options.solver==="repulsion"?(e=this.options.repulsion,this.nodesSolver=new Qo(this.body,this.physicsBody,e),this.edgesSolver=new Zt(this.body,this.physicsBody,e),this.gravitySolver=new Ct(this.body,this.physicsBody,e)):this.options.solver==="hierarchicalRepulsion"?(e=this.options.hierarchicalRepulsion,this.nodesSolver=new $o(this.body,this.physicsBody,e),this.edgesSolver=new Jo(this.body,this.physicsBody,e),this.gravitySolver=new Ct(this.body,this.physicsBody,e)):(e=this.options.barnesHut,this.nodesSolver=new Li(this.body,this.physicsBody,e),this.edgesSolver=new Zt(this.body,this.physicsBody,e),this.gravitySolver=new Ct(this.body,this.physicsBody,e)),this.modelOptions=e}initPhysics(){this.physicsEnabled===!0&&this.options.enabled===!0?this.options.stabilization.enabled===!0?this.stabilize():(this.stabilized=!1,this.ready=!0,this.body.emitter.emit("fit",{},this.layoutFailed),this.startSimulation()):(this.ready=!0,this.body.emitter.emit("fit"))}startSimulation(){this.physicsEnabled===!0&&this.options.enabled===!0?(this.stabilized=!1,this.adaptiveTimestep=!1,this.body.emitter.emit("_resizeNodes"),this.viewFunction===void 0&&(this.viewFunction=this.simulationStep.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))):this.body.emitter.emit("_redraw")}stopSimulation(e=!0){this.stabilized=!0,e===!0&&this._emitStabilized(),this.viewFunction!==void 0&&(this.body.emitter.off("initRedraw",this.viewFunction),this.viewFunction=void 0,e===!0&&this.body.emitter.emit("_stopRendering"))}simulationStep(){let e=Date.now();this.physicsTick(),(Date.now()-e<.4*this.simulationInterval||this.runDoubleSpeed===!0)&&this.stabilized===!1&&(this.physicsTick(),this.runDoubleSpeed=!0),this.stabilized===!0&&this.stopSimulation()}_emitStabilized(e=this.stabilizationIterations){(this.stabilizationIterations>1||this.startedStabilization===!0)&&setTimeout(()=>{this.body.emitter.emit("stabilized",{iterations:e}),this.startedStabilization=!1,this.stabilizationIterations=0},0)}physicsStep(){this.gravitySolver.solve(),this.nodesSolver.solve(),this.edgesSolver.solve(),this.moveNodes()}adjustTimeStep(){let e=1.2;this._evaluateStepQuality()===!0?this.timestep=e*this.timestep:this.timestep/e<this.options.timestep?this.timestep=this.options.timestep:(this.adaptiveCounter=-1,this.timestep=Math.max(this.options.timestep,this.timestep/e))}physicsTick(){this._startStabilizing(),this.stabilized!==!0&&(this.adaptiveTimestep===!0&&this.adaptiveTimestepEnabled===!0?(this.adaptiveCounter%this.adaptiveInterval==0?(this.timestep=2*this.timestep,this.physicsStep(),this.revert(),this.timestep=.5*this.timestep,this.physicsStep(),this.physicsStep(),this.adjustTimeStep()):this.physicsStep(),this.adaptiveCounter+=1):(this.timestep=this.options.timestep,this.physicsStep()),this.stabilized===!0&&this.revert(),this.stabilizationIterations++)}updatePhysicsData(){this.physicsBody.forces={},this.physicsBody.physicsNodeIndices=[],this.physicsBody.physicsEdgeIndices=[];let e=this.body.nodes,t=this.body.edges;for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&e[i].options.physics===!0&&this.physicsBody.physicsNodeIndices.push(e[i].id);for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&t[i].options.physics===!0&&this.physicsBody.physicsEdgeIndices.push(t[i].id);for(let i=0;i<this.physicsBody.physicsNodeIndices.length;i++){let s=this.physicsBody.physicsNodeIndices[i];this.physicsBody.forces[s]={x:0,y:0},this.physicsBody.velocities[s]===void 0&&(this.physicsBody.velocities[s]={x:0,y:0})}for(let i in this.physicsBody.velocities)e[i]===void 0&&delete this.physicsBody.velocities[i]}revert(){let e=Object.keys(this.previousStates),t=this.body.nodes,i=this.physicsBody.velocities;this.referenceState={};for(let s=0;s<e.length;s++){let o=e[s];t[o]!==void 0?t[o].options.physics===!0&&(this.referenceState[o]={positions:{x:t[o].x,y:t[o].y}},i[o].x=this.previousStates[o].vx,i[o].y=this.previousStates[o].vy,t[o].x=this.previousStates[o].x,t[o].y=this.previousStates[o].y):delete this.previousStates[o]}}_evaluateStepQuality(){let e,t,i,s=this.body.nodes,o=this.referenceState,r=.3;for(let a in this.referenceState)if(Object.prototype.hasOwnProperty.call(this.referenceState,a)&&s[a]!==void 0&&(e=s[a].x-o[a].positions.x,t=s[a].y-o[a].positions.y,i=Math.sqrt(Math.pow(e,2)+Math.pow(t,2)),i>r))return!1;return!0}moveNodes(){let e=this.physicsBody.physicsNodeIndices,t=0,i=0,s=5;for(let o=0;o<e.length;o++){let r=e[o],a=this._performStep(r);t=Math.max(t,a),i+=a}this.adaptiveTimestepEnabled=i/e.length<s,this.stabilized=t<this.options.minVelocity}calculateComponentVelocity(e,t,i){let s=this.modelOptions.damping*e;e+=(t-s)/i*this.timestep;let r=this.options.maxVelocity||1e9;return Math.abs(e)>r&&(e=e>0?r:-r),e}_performStep(e){let t=this.body.nodes[e],i=this.physicsBody.forces[e];this.options.wind&&(i.x+=this.options.wind.x,i.y+=this.options.wind.y);let s=this.physicsBody.velocities[e];return this.previousStates[e]={x:t.x,y:t.y,vx:s.x,vy:s.y},t.options.fixed.x===!1?(s.x=this.calculateComponentVelocity(s.x,i.x,t.options.mass),t.x+=s.x*this.timestep):(i.x=0,s.x=0),t.options.fixed.y===!1?(s.y=this.calculateComponentVelocity(s.y,i.y,t.options.mass),t.y+=s.y*this.timestep):(i.y=0,s.y=0),Math.sqrt(Math.pow(s.x,2)+Math.pow(s.y,2))}_freezeNodes(){let e=this.body.nodes;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t].x&&e[t].y){let i=e[t].options.fixed;this.freezeCache[t]={x:i.x,y:i.y},i.x=!0,i.y=!0}}_restoreFrozenNodes(){let e=this.body.nodes;for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.freezeCache[t]!==void 0&&(e[t].options.fixed.x=this.freezeCache[t].x,e[t].options.fixed.y=this.freezeCache[t].y);this.freezeCache={}}stabilize(e=this.options.stabilization.iterations){if(typeof e!="number"&&(e=this.options.stabilization.iterations,console.error("The stabilize method needs a numeric amount of iterations. Switching to default: ",e)),this.physicsBody.physicsNodeIndices.length===0){this.ready=!0;return}this.adaptiveTimestep=this.options.adaptiveTimestep,this.body.emitter.emit("_resizeNodes"),this.stopSimulation(),this.stabilized=!1,this.body.emitter.emit("_blockRedraw"),this.targetIterations=e,this.options.stabilization.onlyDynamicEdges===!0&&this._freezeNodes(),this.stabilizationIterations=0,setTimeout(()=>this._stabilizationBatch(),0)}_startStabilizing(){return this.startedStabilization===!0?!1:(this.body.emitter.emit("startStabilizing"),this.startedStabilization=!0,!0)}_stabilizationBatch(){let e=()=>this.stabilized===!1&&this.stabilizationIterations<this.targetIterations,t=()=>{this.body.emitter.emit("stabilizationProgress",{iterations:this.stabilizationIterations,total:this.targetIterations})};this._startStabilizing()&&t();let i=0;for(;e()&&i<this.options.stabilization.updateInterval;)this.physicsTick(),i++;t(),e()?setTimeout(this._stabilizationBatch.bind(this),0):this._finalizeStabilization()}_finalizeStabilization(){this.body.emitter.emit("_allowRedraw"),this.options.stabilization.fit===!0&&this.body.emitter.emit("fit"),this.options.stabilization.onlyDynamicEdges===!0&&this._restoreFrozenNodes(),this.body.emitter.emit("stabilizationIterationsDone"),this.body.emitter.emit("_requestRedraw"),this.stabilized===!0?this._emitStabilized():this.startSimulation(),this.ready=!0}_drawForces(e){for(let t=0;t<this.physicsBody.physicsNodeIndices.length;t++){let i=this.physicsBody.physicsNodeIndices[t],s=this.body.nodes[i],o=this.physicsBody.forces[i],r=20,a=.03,d=Math.sqrt(Math.pow(o.x,2)+Math.pow(o.x,2)),h=Math.min(Math.max(5,d),15),l=3*h,c=Ht((180-Math.min(1,Math.max(0,a*d))*180)/360,1,1),u={x:s.x+r*o.x,y:s.y+r*o.y};e.lineWidth=h,e.strokeStyle=c,e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(u.x,u.y),e.stroke();let p=Math.atan2(o.y,o.x);e.fillStyle=c,Di.draw(e,{type:"arrow",point:u,angle:p,length:l}),e.fill()}}},J=class{constructor(){}static getRange(e,t=[]){let i=1e9,s=-1e9,o=1e9,r=-1e9,a;if(t.length>0)for(let d=0;d<t.length;d++)a=e[t[d]],o>a.shape.boundingBox.left&&(o=a.shape.boundingBox.left),r<a.shape.boundingBox.right&&(r=a.shape.boundingBox.right),i>a.shape.boundingBox.top&&(i=a.shape.boundingBox.top),s<a.shape.boundingBox.bottom&&(s=a.shape.boundingBox.bottom);return o===1e9&&r===-1e9&&i===1e9&&s===-1e9&&(i=0,s=0,o=0,r=0),{minX:o,maxX:r,minY:i,maxY:s}}static getRangeCore(e,t=[]){let i=1e9,s=-1e9,o=1e9,r=-1e9,a;if(t.length>0)for(let d=0;d<t.length;d++)a=e[t[d]],o>a.x&&(o=a.x),r<a.x&&(r=a.x),i>a.y&&(i=a.y),s<a.y&&(s=a.y);return o===1e9&&r===-1e9&&i===1e9&&s===-1e9&&(i=0,s=0,o=0,r=0),{minX:o,maxX:r,minY:i,maxY:s}}static findCenter(e){return{x:.5*(e.maxX+e.minX),y:.5*(e.maxY+e.minY)}}static cloneOptions(e,t){let i={};return t===void 0||t==="node"?(j(i,e.options,!0),i.x=e.x,i.y=e.y,i.amountOfConnections=e.edges.length):j(i,e.options,!0),i}},on=class extends U{constructor(e,t,i,s,o,r){super(e,t,i,s,o,r);this.isCluster=!0,this.containedNodes={},this.containedEdges={}}_openChildCluster(e){let t=this.body.nodes[e];if(this.containedNodes[e]===void 0)throw new Error("node with id: "+e+" not in current cluster");if(!t.isCluster)throw new Error("node with id: "+e+" is not a cluster");delete this.containedNodes[e],A(t.edges,i=>{delete this.containedEdges[i.id]}),A(t.containedNodes,(i,s)=>{this.containedNodes[s]=i}),t.containedNodes={},A(t.containedEdges,(i,s)=>{this.containedEdges[s]=i}),t.containedEdges={},A(t.edges,i=>{A(this.edges,s=>{let o=s.clusteringEdgeReplacingIds.indexOf(i.id);o!==-1&&(A(i.clusteringEdgeReplacingIds,r=>{s.clusteringEdgeReplacingIds.push(r),this.body.edges[r].edgeReplacedById=s.id}),s.clusteringEdgeReplacingIds.splice(o,1))})}),t.edges=[]}},nn=class{constructor(e){this.body=e,this.clusteredNodes={},this.clusteredEdges={},this.options={},this.defaultOptions={},Object.assign(this.options,this.defaultOptions),this.body.emitter.on("_resetData",()=>{this.clusteredNodes={},this.clusteredEdges={}})}clusterByHubsize(e,t){e===void 0?e=this._getHubSize():typeof e=="object"&&(t=this._checkOptions(e),e=this._getHubSize());let i=[];for(let s=0;s<this.body.nodeIndices.length;s++){let o=this.body.nodes[this.body.nodeIndices[s]];o.edges.length>=e&&i.push(o.id)}for(let s=0;s<i.length;s++)this.clusterByConnection(i[s],t,!0);this.body.emitter.emit("_dataChanged")}cluster(e={},t=!0){if(e.joinCondition===void 0)throw new Error("Cannot call clusterByNodeData without a joinCondition function in the options.");e=this._checkOptions(e);let i={},s={};A(this.body.nodes,(o,r)=>{o.options&&e.joinCondition(o.options)===!0&&(i[r]=o,A(o.edges,a=>{this.clusteredEdges[a.id]===void 0&&(s[a.id]=a)}))}),this._cluster(i,s,e,t)}clusterByEdgeCount(e,t,i=!0){t=this._checkOptions(t);let s=[],o={},r,a,d;for(let h=0;h<this.body.nodeIndices.length;h++){let l={},c={},u=this.body.nodeIndices[h],p=this.body.nodes[u];if(o[u]===void 0){d=0,a=[];for(let b=0;b<p.edges.length;b++)r=p.edges[b],this.clusteredEdges[r.id]===void 0&&(r.toId!==r.fromId&&d++,a.push(r));if(d===e){let b=function(f){if(t.joinCondition===void 0||t.joinCondition===null)return!0;let g=J.cloneOptions(f);return t.joinCondition(g)},C=!0;for(let f=0;f<a.length;f++){r=a[f];let g=this._getConnectedId(r,u);if(b(p))c[r.id]=r,l[u]=p,l[g]=this.body.nodes[g],o[u]=!0;else{C=!1;break}}if(Object.keys(l).length>0&&Object.keys(c).length>0&&C===!0){let g=function(){for(let m=0;m<s.length;++m)for(let v in l)if(s[m].nodes[v]!==void 0)return s[m]}();if(g!==void 0){for(let m in l)g.nodes[m]===void 0&&(g.nodes[m]=l[m]);for(let m in c)g.edges[m]===void 0&&(g.edges[m]=c[m])}else s.push({nodes:l,edges:c})}}}}for(let h=0;h<s.length;h++)this._cluster(s[h].nodes,s[h].edges,t,!1);i===!0&&this.body.emitter.emit("_dataChanged")}clusterOutliers(e,t=!0){this.clusterByEdgeCount(1,e,t)}clusterBridges(e,t=!0){this.clusterByEdgeCount(2,e,t)}clusterByConnection(e,t,i=!0){if(e===void 0)throw new Error("No nodeId supplied to clusterByConnection!");if(this.body.nodes[e]===void 0)throw new Error("The nodeId given to clusterByConnection does not exist!");let s=this.body.nodes[e];t=this._checkOptions(t,s),t.clusterNodeProperties.x===void 0&&(t.clusterNodeProperties.x=s.x),t.clusterNodeProperties.y===void 0&&(t.clusterNodeProperties.y=s.y),t.clusterNodeProperties.fixed===void 0&&(t.clusterNodeProperties.fixed={},t.clusterNodeProperties.fixed.x=s.options.fixed.x,t.clusterNodeProperties.fixed.y=s.options.fixed.y);let o={},r={},a=s.id,d=J.cloneOptions(s);o[a]=s;for(let l=0;l<s.edges.length;l++){let c=s.edges[l];if(this.clusteredEdges[c.id]===void 0){let u=this._getConnectedId(c,a);if(this.clusteredNodes[u]===void 0)if(u!==a)if(t.joinCondition===void 0)r[c.id]=c,o[u]=this.body.nodes[u];else{let p=J.cloneOptions(this.body.nodes[u]);t.joinCondition(d,p)===!0&&(r[c.id]=c,o[u]=this.body.nodes[u])}else r[c.id]=c}}let h=Object.keys(o).map(function(l){return o[l].id});for(let l in o){if(!Object.prototype.hasOwnProperty.call(o,l))continue;let c=o[l];for(let u=0;u<c.edges.length;u++){let p=c.edges[u];h.indexOf(this._getConnectedId(p,c.id))>-1&&(r[p.id]=p)}}this._cluster(o,r,t,i)}_createClusterEdges(e,t,i,s){let o,r,a,d,h,l,c=Object.keys(e),u=[];for(let C=0;C<c.length;C++){r=c[C],a=e[r];for(let f=0;f<a.edges.length;f++)o=a.edges[f],this.clusteredEdges[o.id]===void 0&&(o.toId==o.fromId?t[o.id]=o:o.toId==r?(d=i.id,h=o.fromId,l=h):(d=o.toId,h=i.id,l=d),e[l]===void 0&&u.push({edge:o,fromId:h,toId:d}))}let p=[],b=function(C){for(let f=0;f<p.length;f++){let g=p[f],m=C.fromId===g.fromId&&C.toId===g.toId,v=C.fromId===g.toId&&C.toId===g.fromId;if(m||v)return g}return null};for(let C=0;C<u.length;C++){let f=u[C],g=f.edge,m=b(f);m===null?(m=this._createClusteredEdge(f.fromId,f.toId,g,s),p.push(m)):m.clusteringEdgeReplacingIds.push(g.id),this.body.edges[g.id].edgeReplacedById=m.id,this._backupEdgeOptions(g),g.setOptions({physics:!1})}}_checkOptions(e={}){return e.clusterEdgeProperties===void 0&&(e.clusterEdgeProperties={}),e.clusterNodeProperties===void 0&&(e.clusterNodeProperties={}),e}_cluster(e,t,i,s=!0){let o=[];for(let l in e)Object.prototype.hasOwnProperty.call(e,l)&&this.clusteredNodes[l]!==void 0&&o.push(l);for(let l=0;l<o.length;++l)delete e[o[l]];if(Object.keys(e).length==0||Object.keys(e).length==1&&i.clusterNodeProperties.allowSingleNodeCluster!=!0)return;let r=j({},i.clusterNodeProperties);if(i.processProperties!==void 0){let l=[];for(let u in e)if(Object.prototype.hasOwnProperty.call(e,u)){let p=J.cloneOptions(e[u]);l.push(p)}let c=[];for(let u in t)if(Object.prototype.hasOwnProperty.call(t,u)&&u.substr(0,12)!=="clusterEdge:"){let p=J.cloneOptions(t[u],"edge");c.push(p)}if(r=i.processProperties(r,l,c),!r)throw new Error("The processProperties function does not return properties!")}r.id===void 0&&(r.id="cluster:"+Ce());let a=r.id;r.label===void 0&&(r.label="cluster");let d;r.x===void 0&&(d=this._getClusterPosition(e),r.x=d.x),r.y===void 0&&(d===void 0&&(d=this._getClusterPosition(e)),r.y=d.y),r.id=a;let h=this.body.functions.createNode(r,on);h.containedNodes=e,h.containedEdges=t,h.clusterEdgeProperties=i.clusterEdgeProperties,this.body.nodes[r.id]=h,this._clusterEdges(e,t,r,i.clusterEdgeProperties),r.id=void 0,s===!0&&this.body.emitter.emit("_dataChanged")}_backupEdgeOptions(e){this.clusteredEdges[e.id]===void 0&&(this.clusteredEdges[e.id]={physics:e.options.physics})}_restoreEdge(e){let t=this.clusteredEdges[e.id];t!==void 0&&(e.setOptions({physics:t.physics}),delete this.clusteredEdges[e.id])}isCluster(e){return this.body.nodes[e]!==void 0?this.body.nodes[e].isCluster===!0:(console.error("Node does not exist."),!1)}_getClusterPosition(e){let t=Object.keys(e),i=e[t[0]].x,s=e[t[0]].x,o=e[t[0]].y,r=e[t[0]].y,a;for(let d=1;d<t.length;d++)a=e[t[d]],i=a.x<i?a.x:i,s=a.x>s?a.x:s,o=a.y<o?a.y:o,r=a.y>r?a.y:r;return{x:.5*(i+s),y:.5*(o+r)}}openCluster(e,t,i=!0){if(e===void 0)throw new Error("No clusterNodeId supplied to openCluster.");let s=this.body.nodes[e];if(s===void 0)throw new Error("The clusterNodeId supplied to openCluster does not exist.");if(s.isCluster!==!0||s.containedNodes===void 0||s.containedEdges===void 0)throw new Error("The node:"+e+" is not a valid cluster.");let o=this.findNode(e),r=o.indexOf(e)-1;if(r>=0){let l=o[r];this.body.nodes[l]._openChildCluster(e),delete this.body.nodes[e],i===!0&&this.body.emitter.emit("_dataChanged");return}let a=s.containedNodes,d=s.containedEdges;if(t!==void 0&&t.releaseFunction!==void 0&&typeof t.releaseFunction=="function"){let l={},c={x:s.x,y:s.y};for(let p in a)if(Object.prototype.hasOwnProperty.call(a,p)){let b=this.body.nodes[p];l[p]={x:b.x,y:b.y}}let u=t.releaseFunction(c,l);for(let p in a)if(Object.prototype.hasOwnProperty.call(a,p)){let b=this.body.nodes[p];u[p]!==void 0&&(b.x=u[p].x===void 0?s.x:u[p].x,b.y=u[p].y===void 0?s.y:u[p].y)}}else A(a,function(l){l.options.fixed.x===!1&&(l.x=s.x),l.options.fixed.y===!1&&(l.y=s.y)});for(let l in a)if(Object.prototype.hasOwnProperty.call(a,l)){let c=this.body.nodes[l];c.vx=s.vx,c.vy=s.vy,c.setOptions({physics:!0}),delete this.clusteredNodes[l]}let h=[];for(let l=0;l<s.edges.length;l++)h.push(s.edges[l]);for(let l=0;l<h.length;l++){let c=h[l],u=this._getConnectedId(c,e),p=this.clusteredNodes[u];for(let b=0;b<c.clusteringEdgeReplacingIds.length;b++){let C=c.clusteringEdgeReplacingIds[b],f=this.body.edges[C];if(f!==void 0)if(p!==void 0){let g=this.body.nodes[p.clusterId];g.containedEdges[f.id]=f,delete d[f.id];let m=f.fromId,v=f.toId;f.toId==u?v=p.clusterId:m=p.clusterId,this._createClusteredEdge(m,v,f,g.clusterEdgeProperties,{hidden:!1,physics:!0})}else this._restoreEdge(f)}c.remove()}for(let l in d)Object.prototype.hasOwnProperty.call(d,l)&&this._restoreEdge(d[l]);delete this.body.nodes[e],i===!0&&this.body.emitter.emit("_dataChanged")}getNodesInCluster(e){let t=[];if(this.isCluster(e)===!0){let i=this.body.nodes[e].containedNodes;for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&t.push(this.body.nodes[s].id)}return t}findNode(e){let t=[],i=100,s=0,o;for(;this.clusteredNodes[e]!==void 0&&s<i;){if(o=this.body.nodes[e],o===void 0)return[];t.push(o.id),e=this.clusteredNodes[e].clusterId,s++}return o=this.body.nodes[e],o===void 0?[]:(t.push(o.id),t.reverse(),t)}updateClusteredNode(e,t){if(e===void 0)throw new Error("No clusteredNodeId supplied to updateClusteredNode.");if(t===void 0)throw new Error("No newOptions supplied to updateClusteredNode.");if(this.body.nodes[e]===void 0)throw new Error("The clusteredNodeId supplied to updateClusteredNode does not exist.");this.body.nodes[e].setOptions(t),this.body.emitter.emit("_dataChanged")}updateEdge(e,t){if(e===void 0)throw new Error("No startEdgeId supplied to updateEdge.");if(t===void 0)throw new Error("No newOptions supplied to updateEdge.");if(this.body.edges[e]===void 0)throw new Error("The startEdgeId supplied to updateEdge does not exist.");let i=this.getClusteredEdges(e);for(let s=0;s<i.length;s++)this.body.edges[i[s]].setOptions(t);this.body.emitter.emit("_dataChanged")}getClusteredEdges(e){let t=[],i=100,s=0;for(;e!==void 0&&this.body.edges[e]!==void 0&&s<i;)t.push(this.body.edges[e].id),e=this.body.edges[e].edgeReplacedById,s++;return t.reverse(),t}getBaseEdge(e){return this.getBaseEdges(e)[0]}getBaseEdges(e){let t=[e],i=[],s=[],o=100,r=0;for(;t.length>0&&r<o;){let a=t.pop();if(a===void 0)continue;let d=this.body.edges[a];if(d===void 0)continue;r++;let h=d.clusteringEdgeReplacingIds;if(h===void 0)s.push(a);else for(let l=0;l<h.length;++l){let c=h[l];t.indexOf(h)!==-1||i.indexOf(h)!==-1||t.push(c)}i.push(a)}return s}_getConnectedId(e,t){return e.toId!=t?e.toId:(e.fromId!=t,e.fromId)}_getHubSize(){let e=0,t=0,i=0,s=0;for(let d=0;d<this.body.nodeIndices.length;d++){let h=this.body.nodes[this.body.nodeIndices[d]];h.edges.length>s&&(s=h.edges.length),e+=h.edges.length,t+=Math.pow(h.edges.length,2),i+=1}e=e/i,t=t/i;let o=t-Math.pow(e,2),r=Math.sqrt(o),a=Math.floor(e+2*r);return a>s&&(a=s),a}_createClusteredEdge(e,t,i,s,o){let r=J.cloneOptions(i,"edge");j(r,s),r.from=e,r.to=t,r.id="clusterEdge:"+Ce(),o!==void 0&&j(r,o);let a=this.body.functions.createEdge(r);return a.clusteringEdgeReplacingIds=[i.id],a.connect(),this.body.edges[a.id]=a,a}_clusterEdges(e,t,i,s){if(t instanceof Se){let o=t,r={};r[o.id]=o,t=r}if(e instanceof U){let o=e,r={};r[o.id]=o,e=r}if(i==null)throw new Error("_clusterEdges: parameter clusterNode required");s===void 0&&(s=i.clusterEdgeProperties),this._createClusterEdges(e,t,i,s);for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&this.body.edges[o]!==void 0){let r=this.body.edges[o];this._backupEdgeOptions(r),r.setOptions({physics:!1})}for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(this.clusteredNodes[o]={clusterId:i.id,node:this.body.nodes[o]},this.body.nodes[o].setOptions({physics:!1}))}_getClusterNodeForNode(e){if(e===void 0)return;let t=this.clusteredNodes[e];if(t===void 0)return;let i=t.clusterId;if(i!==void 0)return this.body.nodes[i]}_filter(e,t){let i=[];return A(e,s=>{t(s)&&i.push(s)}),i}_updateState(){let e,t=[],i={},s=d=>{A(this.body.nodes,h=>{h.isCluster===!0&&d(h)})};for(e in this.clusteredNodes){if(!Object.prototype.hasOwnProperty.call(this.clusteredNodes,e))continue;this.body.nodes[e]===void 0&&t.push(e)}s(function(d){for(let h=0;h<t.length;h++)delete d.containedNodes[t[h]]});for(let d=0;d<t.length;d++)delete this.clusteredNodes[t[d]];A(this.clusteredEdges,d=>{let h=this.body.edges[d];(h===void 0||!h.endPointsValid())&&(i[d]=d)}),s(function(d){A(d.containedEdges,(h,l)=>{!h.endPointsValid()&&!i[l]&&(i[l]=l)})}),A(this.body.edges,(d,h)=>{let l=!0,c=d.clusteringEdgeReplacingIds;if(c!==void 0){let u=0;A(c,p=>{let b=this.body.edges[p];b!==void 0&&b.endPointsValid()&&(u+=1)}),l=u>0}(!d.endPointsValid()||!l)&&(i[h]=h)}),s(d=>{A(i,h=>{delete d.containedEdges[h],A(d.edges,(l,c)=>{if(l.id===h){d.edges[c]=null;return}l.clusteringEdgeReplacingIds=this._filter(l.clusteringEdgeReplacingIds,function(u){return!i[u]})}),d.edges=this._filter(d.edges,function(l){return l!==null})})}),A(i,d=>{delete this.clusteredEdges[d]}),A(i,d=>{delete this.body.edges[d]});let o=Object.keys(this.body.edges);A(o,d=>{let h=this.body.edges[d],l=this._isClusteredNode(h.fromId)||this._isClusteredNode(h.toId);if(l!==this._isClusteredEdge(h.id))if(l){let c=this._getClusterNodeForNode(h.fromId);c!==void 0&&this._clusterEdges(this.body.nodes[h.fromId],h,c);let u=this._getClusterNodeForNode(h.toId);u!==void 0&&this._clusterEdges(this.body.nodes[h.toId],h,u)}else delete this._clusterEdges[d],this._restoreEdge(h)});let r=!1,a=!0;for(;a;){let d=[];s(function(h){let l=Object.keys(h.containedNodes).length,c=h.options.allowSingleNodeCluster===!0;(c&&l<1||!c&&l<2)&&d.push(h.id)});for(let h=0;h<d.length;++h)this.openCluster(d[h],{},!1);a=d.length>0,r=r||a}r&&this._updateState()}_isClusteredNode(e){return this.clusteredNodes[e]!==void 0}_isClusteredEdge(e){return this.clusteredEdges[e]!==void 0}};function Sa(){let n;window!==void 0&&(n=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),n===void 0?window.requestAnimationFrame=function(e){e()}:window.requestAnimationFrame=n}var rn=class{constructor(e,t){Sa(),this.body=e,this.canvas=t,this.redrawRequested=!1,this.renderTimer=void 0,this.requiresTimeout=!0,this.renderingActive=!1,this.renderRequests=0,this.allowRedraw=!0,this.dragging=!1,this.zooming=!1,this.options={},this.defaultOptions={hideEdgesOnDrag:!1,hideEdgesOnZoom:!1,hideNodesOnDrag:!1},Object.assign(this.options,this.defaultOptions),this._determineBrowserMethod(),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("dragStart",()=>{this.dragging=!0}),this.body.emitter.on("dragEnd",()=>{this.dragging=!1}),this.body.emitter.on("zoom",()=>{this.zooming=!0,window.clearTimeout(this.zoomTimeoutId),this.zoomTimeoutId=window.setTimeout(()=>{this.zooming=!1,this._requestRedraw.bind(this)()},250)}),this.body.emitter.on("_resizeNodes",()=>{this._resizeNodes()}),this.body.emitter.on("_redraw",()=>{this.renderingActive===!1&&this._redraw()}),this.body.emitter.on("_blockRedraw",()=>{this.allowRedraw=!1}),this.body.emitter.on("_allowRedraw",()=>{this.allowRedraw=!0,this.redrawRequested=!1}),this.body.emitter.on("_requestRedraw",this._requestRedraw.bind(this)),this.body.emitter.on("_startRendering",()=>{this.renderRequests+=1,this.renderingActive=!0,this._startRendering()}),this.body.emitter.on("_stopRendering",()=>{this.renderRequests-=1,this.renderingActive=this.renderRequests>0,this.renderTimer=void 0}),this.body.emitter.on("destroy",()=>{this.renderRequests=0,this.allowRedraw=!1,this.renderingActive=!1,this.requiresTimeout===!0?clearTimeout(this.renderTimer):window.cancelAnimationFrame(this.renderTimer),this.body.emitter.off()})}setOptions(e){e!==void 0&&qe(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag"],this.options,e)}_requestNextFrame(e,t){if(typeof window=="undefined")return;let i,s=window;return this.requiresTimeout===!0?i=s.setTimeout(e,t):s.requestAnimationFrame&&(i=s.requestAnimationFrame(e)),i}_startRendering(){this.renderingActive===!0&&this.renderTimer===void 0&&(this.renderTimer=this._requestNextFrame(this._renderStep.bind(this),this.simulationInterval))}_renderStep(){this.renderingActive===!0&&(this.renderTimer=void 0,this.requiresTimeout===!0&&this._startRendering(),this._redraw(),this.requiresTimeout===!1&&this._startRendering())}redraw(){this.body.emitter.emit("setSize"),this._redraw()}_requestRedraw(){this.redrawRequested!==!0&&this.renderingActive===!1&&this.allowRedraw===!0&&(this.redrawRequested=!0,this._requestNextFrame(()=>{this._redraw(!1)},0))}_redraw(e=!1){if(this.allowRedraw===!0){this.body.emitter.emit("initRedraw"),this.redrawRequested=!1;let t={drawExternalLabels:null};(this.canvas.frame.canvas.width===0||this.canvas.frame.canvas.height===0)&&this.canvas.setSize(),this.canvas.setTransform();let i=this.canvas.getContext(),s=this.canvas.frame.canvas.clientWidth,o=this.canvas.frame.canvas.clientHeight;if(i.clearRect(0,0,s,o),this.canvas.frame.clientWidth===0)return;if(i.save(),i.translate(this.body.view.translation.x,this.body.view.translation.y),i.scale(this.body.view.scale,this.body.view.scale),i.beginPath(),this.body.emitter.emit("beforeDrawing",i),i.closePath(),e===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&(this.zooming===!1||this.zooming===!0&&this.options.hideEdgesOnZoom===!1)&&this._drawEdges(i),this.dragging===!1||this.dragging===!0&&this.options.hideNodesOnDrag===!1){let{drawExternalLabels:r}=this._drawNodes(i,e);t.drawExternalLabels=r}e===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&(this.zooming===!1||this.zooming===!0&&this.options.hideEdgesOnZoom===!1)&&this._drawArrows(i),t.drawExternalLabels!=null&&t.drawExternalLabels(),e===!1&&this._drawSelectionBox(i),i.beginPath(),this.body.emitter.emit("afterDrawing",i),i.closePath(),i.restore(),e===!0&&i.clearRect(0,0,s,o)}}_resizeNodes(){this.canvas.setTransform();let e=this.canvas.getContext();e.save(),e.translate(this.body.view.translation.x,this.body.view.translation.y),e.scale(this.body.view.scale,this.body.view.scale);let t=this.body.nodes,i;for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i=t[s],i.resize(e),i.updateBoundingBox(e,i.selected));e.restore()}_drawNodes(e,t=!1){let i=this.body.nodes,s=this.body.nodeIndices,o,r=[],a=[],d=20,h=this.canvas.DOMtoCanvas({x:-d,y:-d}),l=this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth+d,y:this.canvas.frame.canvas.clientHeight+d}),c={top:h.y,left:h.x,bottom:l.y,right:l.x},u=[];for(let f=0;f<s.length;f++)if(o=i[s[f]],o.hover)a.push(s[f]);else if(o.isSelected())r.push(s[f]);else if(t===!0){let g=o.draw(e);g.drawExternalLabel!=null&&u.push(g.drawExternalLabel)}else if(o.isBoundingBoxOverlappingWith(c)===!0){let g=o.draw(e);g.drawExternalLabel!=null&&u.push(g.drawExternalLabel)}else o.updateBoundingBox(e,o.selected);let p,b=r.length,C=a.length;for(p=0;p<b;p++){o=i[r[p]];let f=o.draw(e);f.drawExternalLabel!=null&&u.push(f.drawExternalLabel)}for(p=0;p<C;p++){o=i[a[p]];let f=o.draw(e);f.drawExternalLabel!=null&&u.push(f.drawExternalLabel)}return{drawExternalLabels:()=>{for(let f of u)f()}}}_drawEdges(e){let t=this.body.edges,i=this.body.edgeIndices;for(let s=0;s<i.length;s++){let o=t[i[s]];o.connected===!0&&o.draw(e)}}_drawArrows(e){let t=this.body.edges,i=this.body.edgeIndices;for(let s=0;s<i.length;s++){let o=t[i[s]];o.connected===!0&&o.drawArrows(e)}}_determineBrowserMethod(){if(typeof window!="undefined"){let e=navigator.userAgent.toLowerCase();this.requiresTimeout=!1,e.indexOf("msie 9.0")!=-1?this.requiresTimeout=!0:e.indexOf("safari")!=-1&&e.indexOf("chrome")<=-1&&(this.requiresTimeout=!0)}else this.requiresTimeout=!0}_drawSelectionBox(e){if(this.body.selectionBox.show){e.beginPath();let t=this.body.selectionBox.position.end.x-this.body.selectionBox.position.start.x,i=this.body.selectionBox.position.end.y-this.body.selectionBox.position.start.y;e.rect(this.body.selectionBox.position.start.x,this.body.selectionBox.position.start.y,t,i),e.fillStyle="rgba(151, 194, 252, 0.2)",e.fillRect(this.body.selectionBox.position.start.x,this.body.selectionBox.position.start.y,t,i),e.strokeStyle="rgba(151, 194, 252, 1)",e.stroke()}else e.closePath()}};function Qt(n,e){e.inputHandler=function(t){t.isFirst&&e(t)},n.on("hammer.input",e.inputHandler)}function an(n,e){return e.inputHandler=function(t){t.isFinal&&e(t)},n.on("hammer.input",e.inputHandler)}var dn=class{constructor(e){this.body=e,this.pixelRatio=1,this.cameraState={},this.initialized=!1,this.canvasViewCenter={},this._cleanupCallbacks=[],this.options={},this.defaultOptions={autoResize:!0,height:"100%",width:"100%"},Object.assign(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.once("resize",e=>{e.width!==0&&(this.body.view.translation.x=e.width*.5),e.height!==0&&(this.body.view.translation.y=e.height*.5)}),this.body.emitter.on("setSize",this.setSize.bind(this)),this.body.emitter.on("destroy",()=>{this.hammerFrame.destroy(),this.hammer.destroy(),this._cleanUp()})}setOptions(e){if(e!==void 0&&qe(["width","height","autoResize"],this.options,e),this._cleanUp(),this.options.autoResize===!0){if(window.ResizeObserver){let i=new ResizeObserver(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")}),{frame:s}=this;i.observe(s),this._cleanupCallbacks.push(()=>{i.unobserve(s)})}else{let i=setInterval(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")},1e3);this._cleanupCallbacks.push(()=>{clearInterval(i)})}let t=this._onResize.bind(this);Ls(window,"resize",t),this._cleanupCallbacks.push(()=>{Rs(window,"resize",t)})}}_cleanUp(){this._cleanupCallbacks.splice(0).reverse().forEach(e=>{try{e()}catch(t){console.error(t)}})}_onResize(){this.setSize(),this.body.emitter.emit("_redraw")}_getCameraState(e=this.pixelRatio){this.initialized===!0&&(this.cameraState.previousWidth=this.frame.canvas.width/e,this.cameraState.previousHeight=this.frame.canvas.height/e,this.cameraState.scale=this.body.view.scale,this.cameraState.position=this.DOMtoCanvas({x:.5*this.frame.canvas.width/e,y:.5*this.frame.canvas.height/e}))}_setCameraState(){if(this.cameraState.scale!==void 0&&this.frame.canvas.clientWidth!==0&&this.frame.canvas.clientHeight!==0&&this.pixelRatio!==0&&this.cameraState.previousWidth>0&&this.cameraState.previousHeight>0){let e=this.frame.canvas.width/this.pixelRatio/this.cameraState.previousWidth,t=this.frame.canvas.height/this.pixelRatio/this.cameraState.previousHeight,i=this.cameraState.scale;e!=1&&t!=1?i=this.cameraState.scale*.5*(e+t):e!=1?i=this.cameraState.scale*e:t!=1&&(i=this.cameraState.scale*t),this.body.view.scale=i;let s=this.DOMtoCanvas({x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight}),o={x:s.x-this.cameraState.position.x,y:s.y-this.cameraState.position.y};this.body.view.translation.x+=o.x*this.body.view.scale,this.body.view.translation.y+=o.y*this.body.view.scale}}_prepareValue(e){if(typeof e=="number")return e+"px";if(typeof e=="string"){if(e.indexOf("%")!==-1||e.indexOf("px")!==-1)return e;if(e.indexOf("%")===-1)return e+"px"}throw new Error("Could not use the value supplied for width or height:"+e)}_create(){for(;this.body.container.hasChildNodes();)this.body.container.removeChild(this.body.container.firstChild);if(this.frame=document.createElement("div"),this.frame.className="vis-network",this.frame.style.position="relative",this.frame.style.overflow="hidden",this.frame.tabIndex=0,this.frame.canvas=document.createElement("canvas"),this.frame.canvas.style.position="relative",this.frame.appendChild(this.frame.canvas),this.frame.canvas.getContext)this._setPixelRatio(),this.setTransform();else{let e=document.createElement("DIV");e.style.color="red",e.style.fontWeight="bold",e.style.padding="10px",e.innerText="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(e)}this.body.container.appendChild(this.frame),this.body.view.scale=1,this.body.view.translation={x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight},this._bindHammer()}_bindHammer(){this.hammer!==void 0&&this.hammer.destroy(),this.drag={},this.pinch={},this.hammer=new Ue(this.frame.canvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:Ue.DIRECTION_ALL}),Qt(this.hammer,e=>{this.body.eventListeners.onTouch(e)}),this.hammer.on("tap",e=>{this.body.eventListeners.onTap(e)}),this.hammer.on("doubletap",e=>{this.body.eventListeners.onDoubleTap(e)}),this.hammer.on("press",e=>{this.body.eventListeners.onHold(e)}),this.hammer.on("panstart",e=>{this.body.eventListeners.onDragStart(e)}),this.hammer.on("panmove",e=>{this.body.eventListeners.onDrag(e)}),this.hammer.on("panend",e=>{this.body.eventListeners.onDragEnd(e)}),this.hammer.on("pinch",e=>{this.body.eventListeners.onPinch(e)}),this.frame.canvas.addEventListener("wheel",e=>{this.body.eventListeners.onMouseWheel(e)}),this.frame.canvas.addEventListener("mousemove",e=>{this.body.eventListeners.onMouseMove(e)}),this.frame.canvas.addEventListener("contextmenu",e=>{this.body.eventListeners.onContext(e)}),this.hammerFrame=new Ue(this.frame),an(this.hammerFrame,e=>{this.body.eventListeners.onRelease(e)})}setSize(e=this.options.width,t=this.options.height){e=this._prepareValue(e),t=this._prepareValue(t);let i=!1,s=this.frame.canvas.width,o=this.frame.canvas.height,r=this.pixelRatio;if(this._setPixelRatio(),e!=this.options.width||t!=this.options.height||this.frame.style.width!=e||this.frame.style.height!=t)this._getCameraState(r),this.frame.style.width=e,this.frame.style.height=t,this.frame.canvas.style.width="100%",this.frame.canvas.style.height="100%",this.frame.canvas.width=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),this.frame.canvas.height=Math.round(this.frame.canvas.clientHeight*this.pixelRatio),this.options.width=e,this.options.height=t,this.canvasViewCenter={x:.5*this.frame.clientWidth,y:.5*this.frame.clientHeight},i=!0;else{let a=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),d=Math.round(this.frame.canvas.clientHeight*this.pixelRatio);(this.frame.canvas.width!==a||this.frame.canvas.height!==d)&&this._getCameraState(r),this.frame.canvas.width!==a&&(this.frame.canvas.width=a,i=!0),this.frame.canvas.height!==d&&(this.frame.canvas.height=d,i=!0)}return i===!0&&(this.body.emitter.emit("resize",{width:Math.round(this.frame.canvas.width/this.pixelRatio),height:Math.round(this.frame.canvas.height/this.pixelRatio),oldWidth:Math.round(s/this.pixelRatio),oldHeight:Math.round(o/this.pixelRatio)}),this._setCameraState()),this.initialized=!0,i}getContext(){return this.frame.canvas.getContext("2d")}_determinePixelRatio(){let e=this.getContext();if(e===void 0)throw new Error("Could not get canvax context");let t=1;typeof window!="undefined"&&(t=window.devicePixelRatio||1);let i=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return t/i}_setPixelRatio(){this.pixelRatio=this._determinePixelRatio()}setTransform(){let e=this.getContext();if(e===void 0)throw new Error("Could not get canvax context");e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}_XconvertDOMtoCanvas(e){return(e-this.body.view.translation.x)/this.body.view.scale}_XconvertCanvasToDOM(e){return e*this.body.view.scale+this.body.view.translation.x}_YconvertDOMtoCanvas(e){return(e-this.body.view.translation.y)/this.body.view.scale}_YconvertCanvasToDOM(e){return e*this.body.view.scale+this.body.view.translation.y}canvasToDOM(e){return{x:this._XconvertCanvasToDOM(e.x),y:this._YconvertCanvasToDOM(e.y)}}DOMtoCanvas(e){return{x:this._XconvertDOMtoCanvas(e.x),y:this._YconvertDOMtoCanvas(e.y)}}};function Oa(n,e){let t=Object.assign({nodes:e,minZoomLevel:Number.MIN_VALUE,maxZoomLevel:1},n!=null?n:{});if(!Array.isArray(t.nodes))throw new TypeError("Nodes has to be an array of ids.");if(t.nodes.length===0&&(t.nodes=e),!(typeof t.minZoomLevel=="number"&&t.minZoomLevel>0))throw new TypeError("Min zoom level has to be a number higher than zero.");if(!(typeof t.maxZoomLevel=="number"&&t.minZoomLevel<=t.maxZoomLevel))throw new TypeError("Max zoom level has to be a number higher than min zoom level.");return t}var hn=class{constructor(e,t){this.body=e,this.canvas=t,this.animationSpeed=1/this.renderRefreshRate,this.animationEasingFunction="easeInOutQuint",this.easingTime=0,this.sourceScale=0,this.targetScale=0,this.sourceTranslation=0,this.targetTranslation=0,this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0,this.touchTime=0,this.viewFunction=void 0,this.body.emitter.on("fit",this.fit.bind(this)),this.body.emitter.on("animationFinished",()=>{this.body.emitter.emit("_stopRendering")}),this.body.emitter.on("unlockNode",this.releaseNode.bind(this))}setOptions(e={}){this.options=e}fit(e,t=!1){e=Oa(e,this.body.nodeIndices);let i=this.canvas.frame.canvas.clientWidth,s=this.canvas.frame.canvas.clientHeight,o,r;if(i===0||s===0)r=1,o=J.getRange(this.body.nodes,e.nodes);else if(t===!0){let h=0;for(let u in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,u)&&this.body.nodes[u].predefinedPosition===!0&&(h+=1);if(h>.5*this.body.nodeIndices.length){this.fit(e,!1);return}o=J.getRange(this.body.nodes,e.nodes);let l=this.body.nodeIndices.length;r=12.662/(l+7.4147)+.0964822,r*=Math.min(i/600,s/600)}else{this.body.emitter.emit("_resizeNodes"),o=J.getRange(this.body.nodes,e.nodes);let h=Math.abs(o.maxX-o.minX)*1.1,l=Math.abs(o.maxY-o.minY)*1.1,c=i/h,u=s/l;r=c<=u?c:u}r>e.maxZoomLevel?r=e.maxZoomLevel:r<e.minZoomLevel&&(r=e.minZoomLevel);let d={position:J.findCenter(o),scale:r,animation:e.animation};this.moveTo(d)}focus(e,t={}){if(this.body.nodes[e]!==void 0){let i={x:this.body.nodes[e].x,y:this.body.nodes[e].y};t.position=i,t.lockedOnNode=e,this.moveTo(t)}else console.error("Node: "+e+" cannot be found.")}moveTo(e){if(e===void 0){e={};return}if(e.offset!=null){if(e.offset.x!=null){if(e.offset.x=+e.offset.x,!Number.isFinite(e.offset.x))throw new TypeError('The option "offset.x" has to be a finite number.')}else e.offset.x=0;if(e.offset.y!=null){if(e.offset.y=+e.offset.y,!Number.isFinite(e.offset.y))throw new TypeError('The option "offset.y" has to be a finite number.')}else e.offset.x=0}else e.offset={x:0,y:0};if(e.position!=null){if(e.position.x!=null){if(e.position.x=+e.position.x,!Number.isFinite(e.position.x))throw new TypeError('The option "position.x" has to be a finite number.')}else e.position.x=0;if(e.position.y!=null){if(e.position.y=+e.position.y,!Number.isFinite(e.position.y))throw new TypeError('The option "position.y" has to be a finite number.')}else e.position.x=0}else e.position=this.getViewPosition();if(e.scale!=null){if(e.scale=+e.scale,!(e.scale>0))throw new TypeError('The option "scale" has to be a number greater than zero.')}else e.scale=this.body.view.scale;e.animation===void 0&&(e.animation={duration:0}),e.animation===!1&&(e.animation={duration:0}),e.animation===!0&&(e.animation={}),e.animation.duration===void 0&&(e.animation.duration=1e3),e.animation.easingFunction===void 0&&(e.animation.easingFunction="easeInOutQuad"),this.animateView(e)}animateView(e){if(e===void 0)return;this.animationEasingFunction=e.animation.easingFunction,this.releaseNode(),e.locked===!0&&(this.lockedOnNodeId=e.lockedOnNode,this.lockedOnNodeOffset=e.offset),this.easingTime!=0&&this._transitionRedraw(!0),this.sourceScale=this.body.view.scale,this.sourceTranslation=this.body.view.translation,this.targetScale=e.scale,this.body.view.scale=this.targetScale;let t=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:t.x-e.position.x,y:t.y-e.position.y};this.targetTranslation={x:this.sourceTranslation.x+i.x*this.targetScale+e.offset.x,y:this.sourceTranslation.y+i.y*this.targetScale+e.offset.y},e.animation.duration===0?this.lockedOnNodeId!=null?(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)):(this.body.view.scale=this.targetScale,this.body.view.translation=this.targetTranslation,this.body.emitter.emit("_requestRedraw")):(this.animationSpeed=1/(60*e.animation.duration*.001)||1/60,this.animationEasingFunction=e.animation.easingFunction,this.viewFunction=this._transitionRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))}_lockedRedraw(){let e={x:this.body.nodes[this.lockedOnNodeId].x,y:this.body.nodes[this.lockedOnNodeId].y},t=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:t.x-e.x,y:t.y-e.y},s=this.body.view.translation,o={x:s.x+i.x*this.body.view.scale+this.lockedOnNodeOffset.x,y:s.y+i.y*this.body.view.scale+this.lockedOnNodeOffset.y};this.body.view.translation=o}releaseNode(){this.lockedOnNodeId!==void 0&&this.viewFunction!==void 0&&(this.body.emitter.off("initRedraw",this.viewFunction),this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0)}_transitionRedraw(e=!1){this.easingTime+=this.animationSpeed,this.easingTime=e===!0?1:this.easingTime;let t=Vs[this.animationEasingFunction](this.easingTime);this.body.view.scale=this.sourceScale+(this.targetScale-this.sourceScale)*t,this.body.view.translation={x:this.sourceTranslation.x+(this.targetTranslation.x-this.sourceTranslation.x)*t,y:this.sourceTranslation.y+(this.targetTranslation.y-this.sourceTranslation.y)*t},this.easingTime>=1&&(this.body.emitter.off("initRedraw",this.viewFunction),this.easingTime=0,this.lockedOnNodeId!=null&&(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)),this.body.emitter.emit("animationFinished"))}getScale(){return this.body.view.scale}getViewPosition(){return this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight})}},ln=class{constructor(e,t){this.body=e,this.canvas=t,this.iconsCreated=!1,this.navigationHammers=[],this.boundFunctions={},this.touchTime=0,this.activated=!1,this.body.emitter.on("activate",()=>{this.activated=!0,this.configureKeyboardBindings()}),this.body.emitter.on("deactivate",()=>{this.activated=!1,this.configureKeyboardBindings()}),this.body.emitter.on("destroy",()=>{this.keycharm!==void 0&&this.keycharm.destroy()}),this.options={}}setOptions(e){e!==void 0&&(this.options=e,this.create())}create(){this.options.navigationButtons===!0?this.iconsCreated===!1&&this.loadNavigationElements():this.iconsCreated===!0&&this.cleanNavigation(),this.configureKeyboardBindings()}cleanNavigation(){if(this.navigationHammers.length!=0){for(let e=0;e<this.navigationHammers.length;e++)this.navigationHammers[e].destroy();this.navigationHammers=[]}this.navigationDOM&&this.navigationDOM.wrapper&&this.navigationDOM.wrapper.parentNode&&this.navigationDOM.wrapper.parentNode.removeChild(this.navigationDOM.wrapper),this.iconsCreated=!1}loadNavigationElements(){this.cleanNavigation(),this.navigationDOM={};let e=["up","down","left","right","zoomIn","zoomOut","zoomExtends"],t=["_moveUp","_moveDown","_moveLeft","_moveRight","_zoomIn","_zoomOut","_fit"];this.navigationDOM.wrapper=document.createElement("div"),this.navigationDOM.wrapper.className="vis-navigation",this.canvas.frame.appendChild(this.navigationDOM.wrapper);for(let s=0;s<e.length;s++){this.navigationDOM[e[s]]=document.createElement("div"),this.navigationDOM[e[s]].className="vis-button vis-"+e[s],this.navigationDOM.wrapper.appendChild(this.navigationDOM[e[s]]);let o=new Ue(this.navigationDOM[e[s]]);t[s]==="_fit"?Qt(o,this._fit.bind(this)):Qt(o,this.bindToRedraw.bind(this,t[s])),this.navigationHammers.push(o)}let i=new Ue(this.canvas.frame);an(i,()=>{this._stopMovement()}),this.navigationHammers.push(i),this.iconsCreated=!0}bindToRedraw(e){this.boundFunctions[e]===void 0&&(this.boundFunctions[e]=this[e].bind(this),this.body.emitter.on("initRedraw",this.boundFunctions[e]),this.body.emitter.emit("_startRendering"))}unbindFromRedraw(e){this.boundFunctions[e]!==void 0&&(this.body.emitter.off("initRedraw",this.boundFunctions[e]),this.body.emitter.emit("_stopRendering"),delete this.boundFunctions[e])}_fit(){new Date().valueOf()-this.touchTime>700&&(this.body.emitter.emit("fit",{duration:700}),this.touchTime=new Date().valueOf())}_stopMovement(){for(let e in this.boundFunctions)Object.prototype.hasOwnProperty.call(this.boundFunctions,e)&&(this.body.emitter.off("initRedraw",this.boundFunctions[e]),this.body.emitter.emit("_stopRendering"));this.boundFunctions={}}_moveUp(){this.body.view.translation.y+=this.options.keyboard.speed.y}_moveDown(){this.body.view.translation.y-=this.options.keyboard.speed.y}_moveLeft(){this.body.view.translation.x+=this.options.keyboard.speed.x}_moveRight(){this.body.view.translation.x-=this.options.keyboard.speed.x}_zoomIn(){let e=this.body.view.scale,t=this.body.view.scale*(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,s=t/e,o=(1-s)*this.canvas.canvasViewCenter.x+i.x*s,r=(1-s)*this.canvas.canvasViewCenter.y+i.y*s;this.body.view.scale=t,this.body.view.translation={x:o,y:r},this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale,pointer:null})}_zoomOut(){let e=this.body.view.scale,t=this.body.view.scale/(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,s=t/e,o=(1-s)*this.canvas.canvasViewCenter.x+i.x*s,r=(1-s)*this.canvas.canvasViewCenter.y+i.y*s;this.body.view.scale=t,this.body.view.translation={x:o,y:r},this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale,pointer:null})}configureKeyboardBindings(){this.keycharm!==void 0&&this.keycharm.destroy(),this.options.keyboard.enabled===!0&&(this.options.keyboard.bindToWindow===!0?this.keycharm=qt({container:window,preventDefault:!0}):this.keycharm=qt({container:this.canvas.frame,preventDefault:!0}),this.keycharm.reset(),this.activated===!0&&(this.keycharm.bind("up",()=>{this.bindToRedraw("_moveUp")},"keydown"),this.keycharm.bind("down",()=>{this.bindToRedraw("_moveDown")},"keydown"),this.keycharm.bind("left",()=>{this.bindToRedraw("_moveLeft")},"keydown"),this.keycharm.bind("right",()=>{this.bindToRedraw("_moveRight")},"keydown"),this.keycharm.bind("=",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num+",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num-",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("-",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("[",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("]",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pageup",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pagedown",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("up",()=>{this.unbindFromRedraw("_moveUp")},"keyup"),this.keycharm.bind("down",()=>{this.unbindFromRedraw("_moveDown")},"keyup"),this.keycharm.bind("left",()=>{this.unbindFromRedraw("_moveLeft")},"keyup"),this.keycharm.bind("right",()=>{this.unbindFromRedraw("_moveRight")},"keyup"),this.keycharm.bind("=",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num+",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num-",()=>{this.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("-",()=>{this.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("[",()=>{this.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("]",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pageup",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pagedown",()=>{this.unbindFromRedraw("_zoomOut")},"keyup")))}},cn=class{constructor(e,t,i){this.body=e,this.canvas=t,this.selectionHandler=i,this.navigationHandler=new ln(e,t),this.body.eventListeners.onTap=this.onTap.bind(this),this.body.eventListeners.onTouch=this.onTouch.bind(this),this.body.eventListeners.onDoubleTap=this.onDoubleTap.bind(this),this.body.eventListeners.onHold=this.onHold.bind(this),this.body.eventListeners.onDragStart=this.onDragStart.bind(this),this.body.eventListeners.onDrag=this.onDrag.bind(this),this.body.eventListeners.onDragEnd=this.onDragEnd.bind(this),this.body.eventListeners.onMouseWheel=this.onMouseWheel.bind(this),this.body.eventListeners.onPinch=this.onPinch.bind(this),this.body.eventListeners.onMouseMove=this.onMouseMove.bind(this),this.body.eventListeners.onRelease=this.onRelease.bind(this),this.body.eventListeners.onContext=this.onContext.bind(this),this.touchTime=0,this.drag={},this.pinch={},this.popup=void 0,this.popupObj=void 0,this.popupTimer=void 0,this.body.functions.getPointer=this.getPointer.bind(this),this.options={},this.defaultOptions={dragNodes:!0,dragView:!0,hover:!1,keyboard:{enabled:!1,speed:{x:10,y:10,zoom:.02},bindToWindow:!0,autoFocus:!0},navigationButtons:!1,tooltipDelay:300,zoomView:!0,zoomSpeed:1},Object.assign(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("destroy",()=>{clearTimeout(this.popupTimer),delete this.body.functions.getPointer})}setOptions(e){e!==void 0&&(bt(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag","keyboard","multiselect","selectable","selectConnectedEdges"],this.options,e),ae(this.options,e,"keyboard"),e.tooltip&&(Object.assign(this.options.tooltip,e.tooltip),e.tooltip.color&&(this.options.tooltip.color=Lt(e.tooltip.color)))),this.navigationHandler.setOptions(this.options)}getPointer(e){return{x:e.x-As(this.canvas.frame.canvas),y:e.y-zs(this.canvas.frame.canvas)}}onTouch(e){new Date().valueOf()-this.touchTime>50&&(this.drag.pointer=this.getPointer(e.center),this.drag.pinched=!1,this.pinch.scale=this.body.view.scale,this.touchTime=new Date().valueOf())}onTap(e){let t=this.getPointer(e.center),i=this.selectionHandler.options.multiselect&&(e.changedPointers[0].ctrlKey||e.changedPointers[0].metaKey);this.checkSelectionChanges(t,i),this.selectionHandler.commitAndEmit(t,e),this.selectionHandler.generateClickEvent("click",e,t)}onDoubleTap(e){let t=this.getPointer(e.center);this.selectionHandler.generateClickEvent("doubleClick",e,t)}onHold(e){let t=this.getPointer(e.center),i=this.selectionHandler.options.multiselect;this.checkSelectionChanges(t,i),this.selectionHandler.commitAndEmit(t,e),this.selectionHandler.generateClickEvent("click",e,t),this.selectionHandler.generateClickEvent("hold",e,t)}onRelease(e){if(new Date().valueOf()-this.touchTime>10){let t=this.getPointer(e.center);this.selectionHandler.generateClickEvent("release",e,t),this.touchTime=new Date().valueOf()}}onContext(e){let t=this.getPointer({x:e.clientX,y:e.clientY});this.selectionHandler.generateClickEvent("oncontext",e,t)}checkSelectionChanges(e,t=!1){t===!0?this.selectionHandler.selectAdditionalOnPoint(e):this.selectionHandler.selectOnPoint(e)}_determineDifference(e,t){let i=function(s,o){let r=[];for(let a=0;a<s.length;a++){let d=s[a];o.indexOf(d)===-1&&r.push(d)}return r};return{nodes:i(e.nodes,t.nodes),edges:i(e.edges,t.edges)}}onDragStart(e){if(this.drag.dragging)return;this.drag.pointer===void 0&&this.onTouch(e);let t=this.selectionHandler.getNodeAt(this.drag.pointer);if(this.drag.dragging=!0,this.drag.selection=[],this.drag.translation=Object.assign({},this.body.view.translation),this.drag.nodeId=void 0,e.srcEvent.shiftKey){this.body.selectionBox.show=!0;let i=this.getPointer(e.center);this.body.selectionBox.position.start={x:this.canvas._XconvertDOMtoCanvas(i.x),y:this.canvas._YconvertDOMtoCanvas(i.y)},this.body.selectionBox.position.end={x:this.canvas._XconvertDOMtoCanvas(i.x),y:this.canvas._YconvertDOMtoCanvas(i.y)}}else if(t!==void 0&&this.options.dragNodes===!0){this.drag.nodeId=t.id,t.isSelected()===!1&&this.selectionHandler.setSelection({nodes:[t.id]}),this.selectionHandler.generateClickEvent("dragStart",e,this.drag.pointer);for(let i of this.selectionHandler.getSelectedNodes()){let s={id:i.id,node:i,x:i.x,y:i.y,xFixed:i.options.fixed.x,yFixed:i.options.fixed.y};i.options.fixed.x=!0,i.options.fixed.y=!0,this.drag.selection.push(s)}}else this.selectionHandler.generateClickEvent("dragStart",e,this.drag.pointer,void 0,!0)}onDrag(e){if(this.drag.pinched===!0)return;this.body.emitter.emit("unlockNode");let t=this.getPointer(e.center),i=this.drag.selection;if(i&&i.length&&this.options.dragNodes===!0){this.selectionHandler.generateClickEvent("dragging",e,t);let s=t.x-this.drag.pointer.x,o=t.y-this.drag.pointer.y;i.forEach(r=>{let a=r.node;r.xFixed===!1&&(a.x=this.canvas._XconvertDOMtoCanvas(this.canvas._XconvertCanvasToDOM(r.x)+s)),r.yFixed===!1&&(a.y=this.canvas._YconvertDOMtoCanvas(this.canvas._YconvertCanvasToDOM(r.y)+o))}),this.body.emitter.emit("startSimulation")}else{if(e.srcEvent.shiftKey){if(this.selectionHandler.generateClickEvent("dragging",e,t,void 0,!0),this.drag.pointer===void 0){this.onDragStart(e);return}this.body.selectionBox.position.end={x:this.canvas._XconvertDOMtoCanvas(t.x),y:this.canvas._YconvertDOMtoCanvas(t.y)},this.body.emitter.emit("_requestRedraw")}if(this.options.dragView===!0&&!e.srcEvent.shiftKey){if(this.selectionHandler.generateClickEvent("dragging",e,t,void 0,!0),this.drag.pointer===void 0){this.onDragStart(e);return}let s=t.x-this.drag.pointer.x,o=t.y-this.drag.pointer.y;this.body.view.translation={x:this.drag.translation.x+s,y:this.drag.translation.y+o},this.body.emitter.emit("_requestRedraw")}}}onDragEnd(e){if(this.drag.dragging=!1,this.body.selectionBox.show){this.body.selectionBox.show=!1;let t=this.body.selectionBox.position,i={minX:Math.min(t.start.x,t.end.x),minY:Math.min(t.start.y,t.end.y),maxX:Math.max(t.start.x,t.end.x),maxY:Math.max(t.start.y,t.end.y)};this.body.nodeIndices.filter(r=>{let a=this.body.nodes[r];return a.x>=i.minX&&a.x<=i.maxX&&a.y>=i.minY&&a.y<=i.maxY}).forEach(r=>this.selectionHandler.selectObject(this.body.nodes[r]));let o=this.getPointer(e.center);this.selectionHandler.commitAndEmit(o,e),this.selectionHandler.generateClickEvent("dragEnd",e,this.getPointer(e.center),void 0,!0),this.body.emitter.emit("_requestRedraw")}else{let t=this.drag.selection;t&&t.length?(t.forEach(function(i){i.node.options.fixed.x=i.xFixed,i.node.options.fixed.y=i.yFixed}),this.selectionHandler.generateClickEvent("dragEnd",e,this.getPointer(e.center)),this.body.emitter.emit("startSimulation")):(this.selectionHandler.generateClickEvent("dragEnd",e,this.getPointer(e.center),void 0,!0),this.body.emitter.emit("_requestRedraw"))}}onPinch(e){let t=this.getPointer(e.center);this.drag.pinched=!0,this.pinch.scale===void 0&&(this.pinch.scale=1);let i=this.pinch.scale*e.scale;this.zoom(i,t)}zoom(e,t){if(this.options.zoomView===!0){let i=this.body.view.scale;e<1e-5&&(e=1e-5),e>10&&(e=10);let s;this.drag!==void 0&&this.drag.dragging===!0&&(s=this.canvas.DOMtoCanvas(this.drag.pointer));let o=this.body.view.translation,r=e/i,a=(1-r)*t.x+o.x*r,d=(1-r)*t.y+o.y*r;if(this.body.view.scale=e,this.body.view.translation={x:a,y:d},s!=null){let h=this.canvas.canvasToDOM(s);this.drag.pointer.x=h.x,this.drag.pointer.y=h.y}this.body.emitter.emit("_requestRedraw"),i<e?this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale,pointer:t}):this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale,pointer:t})}}onMouseWheel(e){if(this.options.zoomView===!0){if(e.deltaY!==0){let t=this.body.view.scale;t*=1+(e.deltaY<0?1:-1)*(this.options.zoomSpeed*.1);let i=this.getPointer({x:e.clientX,y:e.clientY});this.zoom(t,i)}e.preventDefault()}}onMouseMove(e){let t=this.getPointer({x:e.clientX,y:e.clientY}),i=!1;this.popup!==void 0&&(this.popup.hidden===!1&&this._checkHidePopup(t),this.popup.hidden===!1&&(i=!0,this.popup.setPosition(t.x+3,t.y-5),this.popup.show())),this.options.keyboard.autoFocus&&this.options.keyboard.bindToWindow===!1&&this.options.keyboard.enabled===!0&&this.canvas.frame.focus(),i===!1&&(this.popupTimer!==void 0&&(clearInterval(this.popupTimer),this.popupTimer=void 0),this.drag.dragging||(this.popupTimer=setTimeout(()=>this._checkShowPopup(t),this.options.tooltipDelay))),this.options.hover===!0&&this.selectionHandler.hoverObject(e,t)}_checkShowPopup(e){let t=this.canvas._XconvertDOMtoCanvas(e.x),i=this.canvas._YconvertDOMtoCanvas(e.y),s={left:t,top:i,right:t,bottom:i},o=this.popupObj===void 0?void 0:this.popupObj.id,r=!1,a="node";if(this.popupObj===void 0){let d=this.body.nodeIndices,h=this.body.nodes,l,c=[];for(let u=0;u<d.length;u++)l=h[d[u]],l.isOverlappingWith(s)===!0&&(r=!0,l.getTitle()!==void 0&&c.push(d[u]));c.length>0&&(this.popupObj=h[c[c.length-1]],r=!0)}if(this.popupObj===void 0&&r===!1){let d=this.body.edgeIndices,h=this.body.edges,l,c=[];for(let u=0;u<d.length;u++)l=h[d[u]],l.isOverlappingWith(s)===!0&&l.connected===!0&&l.getTitle()!==void 0&&c.push(d[u]);c.length>0&&(this.popupObj=h[c[c.length-1]],a="edge")}this.popupObj!==void 0?this.popupObj.id!==o&&(this.popup===void 0&&(this.popup=new Zs(this.canvas.frame)),this.popup.popupTargetType=a,this.popup.popupTargetId=this.popupObj.id,this.popup.setPosition(e.x+3,e.y-5),this.popup.setText(this.popupObj.getTitle()),this.popup.show(),this.body.emitter.emit("showPopup",this.popupObj.id)):this.popup!==void 0&&(this.popup.hide(),this.body.emitter.emit("hidePopup"))}_checkHidePopup(e){let t=this.selectionHandler._pointerToPositionObject(e),i=!1;if(this.popup.popupTargetType==="node"){if(this.body.nodes[this.popup.popupTargetId]!==void 0&&(i=this.body.nodes[this.popup.popupTargetId].isOverlappingWith(t),i===!0)){let s=this.selectionHandler.getNodeAt(e);i=s===void 0?!1:s.id===this.popup.popupTargetId}}else this.selectionHandler.getNodeAt(e)===void 0&&this.body.edges[this.popup.popupTargetId]!==void 0&&(i=this.body.edges[this.popup.popupTargetId].isOverlappingWith(t));i===!1&&(this.popupObj=void 0,this.popup.hide(),this.body.emitter.emit("hidePopup"))}};function q(n,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!i:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(n):i?i.value:e.get(n)}function Ri(n,e,t,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(n,t):s?s.value=t:e.set(n,t),t}var Xe,ce,Fe,Ne,$t;function un(n,e){let t=new Set;for(let i of e)n.has(i)||t.add(i);return t}var Hi=class{constructor(){Xe.set(this,new Set),ce.set(this,new Set)}get size(){return q(this,ce,"f").size}add(...e){for(let t of e)q(this,ce,"f").add(t)}delete(...e){for(let t of e)q(this,ce,"f").delete(t)}clear(){q(this,ce,"f").clear()}getSelection(){return[...q(this,ce,"f")]}getChanges(){return{added:[...un(q(this,Xe,"f"),q(this,ce,"f"))],deleted:[...un(q(this,ce,"f"),q(this,Xe,"f"))],previous:[...new Set(q(this,Xe,"f"))],current:[...new Set(q(this,ce,"f"))]}}commit(){let e=this.getChanges();Ri(this,Xe,q(this,ce,"f"),"f"),Ri(this,ce,new Set(q(this,Xe,"f")),"f");for(let t of e.added)t.select();for(let t of e.deleted)t.unselect();return e}};Xe=new WeakMap,ce=new WeakMap;var fn=class{constructor(e=()=>{}){Fe.set(this,new Hi),Ne.set(this,new Hi),$t.set(this,void 0),Ri(this,$t,e,"f")}get sizeNodes(){return q(this,Fe,"f").size}get sizeEdges(){return q(this,Ne,"f").size}getNodes(){return q(this,Fe,"f").getSelection()}getEdges(){return q(this,Ne,"f").getSelection()}addNodes(...e){q(this,Fe,"f").add(...e)}addEdges(...e){q(this,Ne,"f").add(...e)}deleteNodes(e){q(this,Fe,"f").delete(e)}deleteEdges(e){q(this,Ne,"f").delete(e)}clear(){q(this,Fe,"f").clear(),q(this,Ne,"f").clear()}commit(...e){let t={nodes:q(this,Fe,"f").commit(),edges:q(this,Ne,"f").commit()};return q(this,$t,"f").call(this,t,...e),t}};Fe=new WeakMap,Ne=new WeakMap,$t=new WeakMap;var pn=class{constructor(e,t){this.body=e,this.canvas=t,this._selectionAccumulator=new fn,this.hoverObj={nodes:{},edges:{}},this.options={},this.defaultOptions={multiselect:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0},Object.assign(this.options,this.defaultOptions),this.body.emitter.on("_dataChanged",()=>{this.updateSelection()})}setOptions(e){e!==void 0&&qe(["multiselect","hoverConnectedEdges","selectable","selectConnectedEdges"],this.options,e)}selectOnPoint(e){let t=!1;if(this.options.selectable===!0){let i=this.getNodeAt(e)||this.getEdgeAt(e);this.unselectAll(),i!==void 0&&(t=this.selectObject(i)),this.body.emitter.emit("_requestRedraw")}return t}selectAdditionalOnPoint(e){let t=!1;if(this.options.selectable===!0){let i=this.getNodeAt(e)||this.getEdgeAt(e);i!==void 0&&(t=!0,i.isSelected()===!0?this.deselectObject(i):this.selectObject(i),this.body.emitter.emit("_requestRedraw"))}return t}_initBaseEvent(e,t){let i={};return i.pointer={DOM:{x:t.x,y:t.y},canvas:this.canvas.DOMtoCanvas(t)},i.event=e,i}generateClickEvent(e,t,i,s,o=!1){let r=this._initBaseEvent(t,i);if(o===!0)r.nodes=[],r.edges=[];else{let a=this.getSelection();r.nodes=a.nodes,r.edges=a.edges}s!==void 0&&(r.previousSelection=s),e=="click"&&(r.items=this.getClickedItems(i)),t.controlEdge!==void 0&&(r.controlEdge=t.controlEdge),this.body.emitter.emit(e,r)}selectObject(e,t=this.options.selectConnectedEdges){return e!==void 0?(e instanceof U?(t===!0&&this._selectionAccumulator.addEdges(...e.edges),this._selectionAccumulator.addNodes(e)):this._selectionAccumulator.addEdges(e),!0):!1}deselectObject(e){e.isSelected()===!0&&(e.selected=!1,this._removeFromSelection(e))}_getAllNodesOverlappingWith(e){let t=[],i=this.body.nodes;for(let s=0;s<this.body.nodeIndices.length;s++){let o=this.body.nodeIndices[s];i[o].isOverlappingWith(e)&&t.push(o)}return t}_pointerToPositionObject(e){let t=this.canvas.DOMtoCanvas(e);return{left:t.x-1,top:t.y+1,right:t.x+1,bottom:t.y-1}}getNodeAt(e,t=!0){let i=this._pointerToPositionObject(e),s=this._getAllNodesOverlappingWith(i);if(s.length>0)return t===!0?this.body.nodes[s[s.length-1]]:s[s.length-1]}_getEdgesOverlappingWith(e,t){let i=this.body.edges;for(let s=0;s<this.body.edgeIndices.length;s++){let o=this.body.edgeIndices[s];i[o].isOverlappingWith(e)&&t.push(o)}}_getAllEdgesOverlappingWith(e){let t=[];return this._getEdgesOverlappingWith(e,t),t}getEdgeAt(e,t=!0){let i=this.canvas.DOMtoCanvas(e),s=10,o=null,r=this.body.edges;for(let a=0;a<this.body.edgeIndices.length;a++){let d=this.body.edgeIndices[a],h=r[d];if(h.connected){let l=h.from.x,c=h.from.y,u=h.to.x,p=h.to.y,b=h.edgeType.getDistanceToEdge(l,c,u,p,i.x,i.y);b<s&&(o=d,s=b)}}if(o!==null)return t===!0?this.body.edges[o]:o}_addToHover(e){e instanceof U?this.hoverObj.nodes[e.id]=e:this.hoverObj.edges[e.id]=e}_removeFromSelection(e){e instanceof U?(this._selectionAccumulator.deleteNodes(e),this._selectionAccumulator.deleteEdges(...e.edges)):this._selectionAccumulator.deleteEdges(e)}unselectAll(){this._selectionAccumulator.clear()}getSelectedNodeCount(){return this._selectionAccumulator.sizeNodes}getSelectedEdgeCount(){return this._selectionAccumulator.sizeEdges}_hoverConnectedEdges(e){for(let t=0;t<e.edges.length;t++){let i=e.edges[t];i.hover=!0,this._addToHover(i)}}emitBlurEvent(e,t,i){let s=this._initBaseEvent(e,t);i.hover===!0&&(i.hover=!1,i instanceof U?(s.node=i.id,this.body.emitter.emit("blurNode",s)):(s.edge=i.id,this.body.emitter.emit("blurEdge",s)))}emitHoverEvent(e,t,i){let s=this._initBaseEvent(e,t),o=!1;return i.hover===!1&&(i.hover=!0,this._addToHover(i),o=!0,i instanceof U?(s.node=i.id,this.body.emitter.emit("hoverNode",s)):(s.edge=i.id,this.body.emitter.emit("hoverEdge",s))),o}hoverObject(e,t){let i=this.getNodeAt(t);i===void 0&&(i=this.getEdgeAt(t));let s=!1;for(let o in this.hoverObj.nodes)Object.prototype.hasOwnProperty.call(this.hoverObj.nodes,o)&&(i===void 0||i instanceof U&&i.id!=o||i instanceof Se)&&(this.emitBlurEvent(e,t,this.hoverObj.nodes[o]),delete this.hoverObj.nodes[o],s=!0);for(let o in this.hoverObj.edges)Object.prototype.hasOwnProperty.call(this.hoverObj.edges,o)&&(s===!0?(this.hoverObj.edges[o].hover=!1,delete this.hoverObj.edges[o]):(i===void 0||i instanceof Se&&i.id!=o||i instanceof U&&!i.hover)&&(this.emitBlurEvent(e,t,this.hoverObj.edges[o]),delete this.hoverObj.edges[o],s=!0));if(i!==void 0){let o=Object.keys(this.hoverObj.edges).length,r=Object.keys(this.hoverObj.nodes).length,a=i instanceof Se&&o===0&&r===0,d=i instanceof U&&o===0&&r===0;(s||a||d)&&(s=this.emitHoverEvent(e,t,i)),i instanceof U&&this.options.hoverConnectedEdges===!0&&this._hoverConnectedEdges(i)}s===!0&&this.body.emitter.emit("_requestRedraw")}commitWithoutEmitting(){this._selectionAccumulator.commit()}commitAndEmit(e,t){let i=!1,s=this._selectionAccumulator.commit(),o={nodes:s.nodes.previous,edges:s.edges.previous};s.edges.deleted.length>0&&(this.generateClickEvent("deselectEdge",t,e,o),i=!0),s.nodes.deleted.length>0&&(this.generateClickEvent("deselectNode",t,e,o),i=!0),s.nodes.added.length>0&&(this.generateClickEvent("selectNode",t,e),i=!0),s.edges.added.length>0&&(this.generateClickEvent("selectEdge",t,e),i=!0),i===!0&&this.generateClickEvent("select",t,e)}getSelection(){return{nodes:this.getSelectedNodeIds(),edges:this.getSelectedEdgeIds()}}getSelectedNodes(){return this._selectionAccumulator.getNodes()}getSelectedEdges(){return this._selectionAccumulator.getEdges()}getSelectedNodeIds(){return this._selectionAccumulator.getNodes().map(e=>e.id)}getSelectedEdgeIds(){return this._selectionAccumulator.getEdges().map(e=>e.id)}setSelection(e,t={}){if(!e||!e.nodes&&!e.edges)throw new TypeError("Selection must be an object with nodes and/or edges properties");if((t.unselectAll||t.unselectAll===void 0)&&this.unselectAll(),e.nodes)for(let i of e.nodes){let s=this.body.nodes[i];if(!s)throw new RangeError('Node with id "'+i+'" not found');this.selectObject(s,t.highlightEdges)}if(e.edges)for(let i of e.edges){let s=this.body.edges[i];if(!s)throw new RangeError('Edge with id "'+i+'" not found');this.selectObject(s)}this.body.emitter.emit("_requestRedraw"),this._selectionAccumulator.commit()}selectNodes(e,t=!0){if(!e||e.length===void 0)throw"Selection must be an array with ids";this.setSelection({nodes:e},{highlightEdges:t})}selectEdges(e){if(!e||e.length===void 0)throw"Selection must be an array with ids";this.setSelection({edges:e})}updateSelection(){for(let e in this._selectionAccumulator.getNodes())Object.prototype.hasOwnProperty.call(this.body.nodes,e.id)||this._selectionAccumulator.deleteNodes(e);for(let e in this._selectionAccumulator.getEdges())Object.prototype.hasOwnProperty.call(this.body.edges,e.id)||this._selectionAccumulator.deleteEdges(e)}getClickedItems(e){let t=this.canvas.DOMtoCanvas(e),i=[],s=this.body.nodeIndices,o=this.body.nodes;for(let d=s.length-1;d>=0;d--){let l=o[s[d]].getItemsOnPoint(t);i.push.apply(i,l)}let r=this.body.edgeIndices,a=this.body.edges;for(let d=r.length-1;d>=0;d--){let l=a[r[d]].getItemsOnPoint(t);i.push.apply(i,l)}return i}},ji=class{abstract(){throw new Error("Can't instantiate abstract class!")}fake_use(){}curveType(){return this.abstract()}getPosition(e){return this.fake_use(e),this.abstract()}setPosition(e,t,i=void 0){this.fake_use(e,t,i),this.abstract()}getTreeSize(e){return this.fake_use(e),this.abstract()}sort(e){this.fake_use(e),this.abstract()}fix(e,t){this.fake_use(e,t),this.abstract()}shift(e,t){this.fake_use(e,t),this.abstract()}},gn=class extends ji{constructor(e){super();this.layout=e}curveType(){return"horizontal"}getPosition(e){return e.x}setPosition(e,t,i=void 0){i!==void 0&&this.layout.hierarchical.addToOrdering(e,i),e.x=t}getTreeSize(e){let t=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,e);return{min:t.min_x,max:t.max_x}}sort(e){(0,Et.sort)(e,function(t,i){return t.x-i.x})}fix(e,t){e.y=this.layout.options.hierarchical.levelSeparation*t,e.options.fixed.y=!0}shift(e,t){this.layout.body.nodes[e].x+=t}},mn=class extends ji{constructor(e){super();this.layout=e}curveType(){return"vertical"}getPosition(e){return e.y}setPosition(e,t,i=void 0){i!==void 0&&this.layout.hierarchical.addToOrdering(e,i),e.y=t}getTreeSize(e){let t=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,e);return{min:t.min_y,max:t.max_y}}sort(e){(0,Et.sort)(e,function(t,i){return t.y-i.y})}fix(e,t){e.x=this.layout.options.hierarchical.levelSeparation*t,e.options.fixed.x=!0}shift(e,t){this.layout.body.nodes[e].y+=t}};function Ia(n,e){let t=new Set;return n.forEach(i=>{i.edges.forEach(s=>{s.connected&&t.add(s)})}),t.forEach(i=>{let s=i.from.id,o=i.to.id;e[s]==null&&(e[s]=0),(e[o]==null||e[s]>=e[o])&&(e[o]=e[s]+1)}),e}function Pa(n){return yn(e=>e.edges.filter(t=>n.has(t.toId)).every(t=>t.to===e),(e,t)=>t>e,"from",n)}function Ma(n){return yn(e=>e.edges.filter(t=>n.has(t.toId)).every(t=>t.from===e),(e,t)=>t<e,"to",n)}function yn(n,e,t,i){let s=Object.create(null),o=[...i.values()].reduce((d,h)=>d+1+h.edges.length,0),r=t+"Id",a=t==="to"?1:-1;for(let[d,h]of i){if(!i.has(d)||!n(h))continue;s[d]=0;let l=[h],c=0,u;for(;u=l.pop();){if(!i.has(d))continue;let p=s[u.id]+a;if(u.edges.filter(b=>b.connected&&b.to!==b.from&&b[t]!==u&&i.has(b.toId)&&i.has(b.fromId)).forEach(b=>{let C=b[r],f=s[C];(f==null||e(p,f))&&(s[C]=p,l.push(b[t]))}),c>o)return Ia(i,s);++c}}return s}var bn=class{constructor(){this.childrenReference={},this.parentReference={},this.trees={},this.distributionOrdering={},this.levels={},this.distributionIndex={},this.isTree=!1,this.treeIndex=-1}addRelation(e,t){this.childrenReference[e]===void 0&&(this.childrenReference[e]=[]),this.childrenReference[e].push(t),this.parentReference[t]===void 0&&(this.parentReference[t]=[]),this.parentReference[t].push(e)}checkIfTree(){for(let e in this.parentReference)if(this.parentReference[e].length>1){this.isTree=!1;return}this.isTree=!0}numTrees(){return this.treeIndex+1}setTreeIndex(e,t){t!==void 0&&this.trees[e.id]===void 0&&(this.trees[e.id]=t,this.treeIndex=Math.max(t,this.treeIndex))}ensureLevel(e){this.levels[e]===void 0&&(this.levels[e]=0)}getMaxLevel(e){let t={},i=s=>{if(t[s]!==void 0)return t[s];let o=this.levels[s];if(this.childrenReference[s]){let r=this.childrenReference[s];if(r.length>0)for(let a=0;a<r.length;a++)o=Math.max(o,i(r[a]))}return t[s]=o,o};return i(e)}levelDownstream(e,t){this.levels[t.id]===void 0&&(this.levels[e.id]===void 0&&(this.levels[e.id]=0),this.levels[t.id]=this.levels[e.id]+1)}setMinLevelToZero(e){let t=1e9;for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&this.levels[i]!==void 0&&(t=Math.min(this.levels[i],t));for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&this.levels[i]!==void 0&&(this.levels[i]-=t)}getTreeSize(e,t){let i=1e9,s=-1e9,o=1e9,r=-1e9;for(let a in this.trees)if(Object.prototype.hasOwnProperty.call(this.trees,a)&&this.trees[a]===t){let d=e[a];i=Math.min(d.x,i),s=Math.max(d.x,s),o=Math.min(d.y,o),r=Math.max(d.y,r)}return{min_x:i,max_x:s,min_y:o,max_y:r}}hasSameParent(e,t){let i=this.parentReference[e.id],s=this.parentReference[t.id];if(i===void 0||s===void 0)return!1;for(let o=0;o<i.length;o++)for(let r=0;r<s.length;r++)if(i[o]==s[r])return!0;return!1}inSameSubNetwork(e,t){return this.trees[e.id]===this.trees[t.id]}getLevels(){return Object.keys(this.distributionOrdering)}addToOrdering(e,t){this.distributionOrdering[t]===void 0&&(this.distributionOrdering[t]=[]);let i=!1,s=this.distributionOrdering[t];for(let o in s)if(s[o]===e){i=!0;break}i||(this.distributionOrdering[t].push(e),this.distributionIndex[e.id]=this.distributionOrdering[t].length-1)}},vn=class{constructor(e){this.body=e,this._resetRNG(Math.random()+":"+Date.now()),this.setPhysics=!1,this.options={},this.optionsBackup={physics:{}},this.defaultOptions={randomSeed:void 0,improvedLayout:!0,clusterThreshold:150,hierarchical:{enabled:!1,levelSeparation:150,nodeSpacing:100,treeSpacing:200,blockShifting:!0,edgeMinimization:!0,parentCentralization:!0,direction:"UD",sortMethod:"hubsize"}},Object.assign(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("_dataChanged",()=>{this.setupHierarchicalLayout()}),this.body.emitter.on("_dataLoaded",()=>{this.layoutNetwork()}),this.body.emitter.on("_resetHierarchicalLayout",()=>{this.setupHierarchicalLayout()}),this.body.emitter.on("_adjustEdgesForHierarchicalLayout",()=>{if(this.options.hierarchical.enabled!==!0)return;let e=this.direction.curveType();this.body.emitter.emit("_forceDisableDynamicCurves",e,!1)})}setOptions(e,t){if(e!==void 0){let i=this.options.hierarchical,s=i.enabled;if(qe(["randomSeed","improvedLayout","clusterThreshold"],this.options,e),ae(this.options,e,"hierarchical"),e.randomSeed!==void 0&&this._resetRNG(e.randomSeed),i.enabled===!0)return s===!0&&this.body.emitter.emit("refresh",!0),i.direction==="RL"||i.direction==="DU"?i.levelSeparation>0&&(i.levelSeparation*=-1):i.levelSeparation<0&&(i.levelSeparation*=-1),this.setDirectionStrategy(),this.body.emitter.emit("_resetHierarchicalLayout"),this.adaptAllOptionsForHierarchicalLayout(t);if(s===!0)return this.body.emitter.emit("refresh"),j(t,this.optionsBackup)}return t}_resetRNG(e){this.initialRandomSeed=e,this._rng=yt(this.initialRandomSeed)}adaptAllOptionsForHierarchicalLayout(e){if(this.options.hierarchical.enabled===!0){let t=this.optionsBackup.physics;e.physics===void 0||e.physics===!0?(e.physics={enabled:t.enabled===void 0?!0:t.enabled,solver:"hierarchicalRepulsion"},t.enabled=t.enabled===void 0?!0:t.enabled,t.solver=t.solver||"barnesHut"):typeof e.physics=="object"?(t.enabled=e.physics.enabled===void 0?!0:e.physics.enabled,t.solver=e.physics.solver||"barnesHut",e.physics.solver="hierarchicalRepulsion"):e.physics!==!1&&(t.solver="barnesHut",e.physics={solver:"hierarchicalRepulsion"});let i=this.direction.curveType();if(e.edges===void 0)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},e.edges={smooth:!1};else if(e.edges.smooth===void 0)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},e.edges.smooth=!1;else if(typeof e.edges.smooth=="boolean")this.optionsBackup.edges={smooth:e.edges.smooth},e.edges.smooth={enabled:e.edges.smooth,type:i};else{let s=e.edges.smooth;s.type!==void 0&&s.type!=="dynamic"&&(i=s.type),this.optionsBackup.edges={smooth:{enabled:s.enabled===void 0?!0:s.enabled,type:s.type===void 0?"dynamic":s.type,roundness:s.roundness===void 0?.5:s.roundness,forceDirection:s.forceDirection===void 0?!1:s.forceDirection}},e.edges.smooth={enabled:s.enabled===void 0?!0:s.enabled,type:i,roundness:s.roundness===void 0?.5:s.roundness,forceDirection:s.forceDirection===void 0?!1:s.forceDirection}}this.body.emitter.emit("_forceDisableDynamicCurves",i)}return e}positionInitially(e){if(this.options.hierarchical.enabled!==!0){this._resetRNG(this.initialRandomSeed);let t=e.length+50;for(let i=0;i<e.length;i++){let s=e[i],o=2*Math.PI*this._rng();s.x===void 0&&(s.x=t*Math.cos(o)),s.y===void 0&&(s.y=t*Math.sin(o))}}}layoutNetwork(){if(this.options.hierarchical.enabled!==!0&&this.options.improvedLayout===!0){let e=this.body.nodeIndices,t=0;for(let i=0;i<e.length;i++)this.body.nodes[e[i]].predefinedPosition===!0&&(t+=1);if(t<.5*e.length){let i=10,s=0,o=this.options.clusterThreshold,r={clusterNodeProperties:{shape:"ellipse",label:"",group:"",font:{multi:!1}},clusterEdgeProperties:{label:"",font:{multi:!1},smooth:{enabled:!1}}};if(e.length>o){let d=e.length;for(;e.length>o&&s<=i;){s+=1;let h=e.length;s%3==0?this.body.modules.clustering.clusterBridges(r):this.body.modules.clustering.clusterOutliers(r);let l=e.length;if(h==l&&s%3!=0){this._declusterAll(),this.body.emitter.emit("_layoutFailed"),console.info("This network could not be positioned by this version of the improved layout algorithm. Please disable improvedLayout for better performance.");return}}this.body.modules.kamadaKawai.setOptions({springLength:Math.max(150,2*d)})}s>i&&console.info("The clustering didn't succeed within the amount of interations allowed, progressing with partial result."),this.body.modules.kamadaKawai.solve(e,this.body.edgeIndices,!0),this._shiftToCenter();let a=70;for(let d=0;d<e.length;d++){let h=this.body.nodes[e[d]];h.predefinedPosition===!1&&(h.x+=(.5-this._rng())*a,h.y+=(.5-this._rng())*a)}this._declusterAll(),this.body.emitter.emit("_repositionBezierNodes")}}}_shiftToCenter(){let e=J.getRangeCore(this.body.nodes,this.body.nodeIndices),t=J.findCenter(e);for(let i=0;i<this.body.nodeIndices.length;i++){let s=this.body.nodes[this.body.nodeIndices[i]];s.x-=t.x,s.y-=t.y}}_declusterAll(){let e=!0;for(;e===!0;){e=!1;for(let t=0;t<this.body.nodeIndices.length;t++)this.body.nodes[this.body.nodeIndices[t]].isCluster===!0&&(e=!0,this.body.modules.clustering.openCluster(this.body.nodeIndices[t],{},!1));e===!0&&this.body.emitter.emit("_dataChanged")}}getSeed(){return this.initialRandomSeed}setupHierarchicalLayout(){if(this.options.hierarchical.enabled===!0&&this.body.nodeIndices.length>0){let e,t,i=!1,s=!1;this.lastNodeOnLevel={},this.hierarchical=new bn;for(t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&(e=this.body.nodes[t],e.options.level!==void 0?(i=!0,this.hierarchical.levels[t]=e.options.level):s=!0);if(s===!0&&i===!0)throw new Error("To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.");{if(s===!0){let r=this.options.hierarchical.sortMethod;r==="hubsize"?this._determineLevelsByHubsize():r==="directed"?this._determineLevelsDirected():r==="custom"&&this._determineLevelsCustomCallback()}for(let r in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,r)&&this.hierarchical.ensureLevel(r);let o=this._getDistribution();this._generateMap(),this._placeNodesByHierarchy(o),this._condenseHierarchy(),this._shiftToCenter()}}}_condenseHierarchy(){let e=!1,t={},i=()=>{let f=o(),g=0;for(let m=0;m<f.length-1;m++)g+=f[m].max-f[m+1].min+this.options.hierarchical.treeSpacing,s(m+1,g)},s=(f,g)=>{let m=this.hierarchical.trees;for(let v in m)Object.prototype.hasOwnProperty.call(m,v)&&m[v]===f&&this.direction.shift(v,g)},o=()=>{let f=[];for(let g=0;g<this.hierarchical.numTrees();g++)f.push(this.direction.getTreeSize(g));return f},r=(f,g)=>{if(!g[f.id]&&(g[f.id]=!0,this.hierarchical.childrenReference[f.id])){let m=this.hierarchical.childrenReference[f.id];if(m.length>0)for(let v=0;v<m.length;v++)r(this.body.nodes[m[v]],g)}},a=(f,g=1e9)=>{let m=1e9,v=1e9,_=1e9,E=-1e9;for(let T in f)if(Object.prototype.hasOwnProperty.call(f,T)){let x=this.body.nodes[T],w=this.hierarchical.levels[x.id],k=this.direction.getPosition(x),[N,W]=this._getSpaceAroundNode(x,f);m=Math.min(N,m),v=Math.min(W,v),w<=g&&(_=Math.min(k,_),E=Math.max(k,E))}return[_,E,m,v]},d=(f,g)=>{let m=this.hierarchical.getMaxLevel(f.id),v=this.hierarchical.getMaxLevel(g.id);return Math.min(m,v)},h=(f,g,m)=>{let v=this.hierarchical;for(let _=0;_<g.length;_++){let E=g[_],T=v.distributionOrdering[E];if(T.length>1)for(let x=0;x<T.length-1;x++){let w=T[x],k=T[x+1];v.hasSameParent(w,k)&&v.inSameSubNetwork(w,k)&&f(w,k,m)}}},l=(f,g,m=!1)=>{let v=this.direction.getPosition(f),_=this.direction.getPosition(g),E=Math.abs(_-v),T=this.options.hierarchical.nodeSpacing;if(E>T){let x={},w={};r(f,x),r(g,w);let k=d(f,g),N=a(x,k),W=a(w,k),L=N[1],R=W[0],B=W[2];if(Math.abs(L-R)>T){let D=L-R+T;D<-B+T&&(D=-B+T),D<0&&(this._shiftBlock(g.id,D),e=!0,m===!0&&this._centerParent(g))}}},c=(f,g)=>{let m=g.id,v=g.edges,_=this.hierarchical.levels[g.id],E=this.options.hierarchical.levelSeparation*this.options.hierarchical.levelSeparation,T={},x=[];for(let B=0;B<v.length;B++){let F=v[B];if(F.toId!=F.fromId){let D=F.toId==m?F.from:F.to;T[v[B].id]=D,this.hierarchical.levels[D.id]<_&&x.push(F)}}let w=(B,F)=>{let D=0;for(let H=0;H<F.length;H++)if(T[F[H].id]!==void 0){let Y=this.direction.getPosition(T[F[H].id])-B;D+=Y/Math.sqrt(Y*Y+E)}return D},k=(B,F)=>{let D=0;for(let H=0;H<F.length;H++)if(T[F[H].id]!==void 0){let Y=this.direction.getPosition(T[F[H].id])-B;D-=E*Math.pow(Y*Y+E,-1.5)}return D},N=(B,F)=>{let D=this.direction.getPosition(g),H={};for(let Y=0;Y<B;Y++){let ue=w(D,F),Ke=k(D,F),ot=40,On=Math.max(-ot,Math.min(ot,Math.round(ue/Ke)));if(D=D-On,H[D]!==void 0)break;H[D]=Y}return D},W=B=>{let F=this.direction.getPosition(g);if(t[g.id]===void 0){let ot={};r(g,ot),t[g.id]=ot}let D=a(t[g.id]),H=D[2],Y=D[3],ue=B-F,Ke=0;ue>0?Ke=Math.min(ue,Y-this.options.hierarchical.nodeSpacing):ue<0&&(Ke=-Math.min(-ue,H-this.options.hierarchical.nodeSpacing)),Ke!=0&&(this._shiftBlock(g.id,Ke),e=!0)},L=B=>{let F=this.direction.getPosition(g),[D,H]=this._getSpaceAroundNode(g),Y=B-F,ue=F;Y>0?ue=Math.min(F+(H-this.options.hierarchical.nodeSpacing),B):Y<0&&(ue=Math.max(F-(D-this.options.hierarchical.nodeSpacing),B)),ue!==F&&(this.direction.setPosition(g,ue),e=!0)},R=N(f,x);W(R),R=N(f,v),L(R)},u=f=>{let g=this.hierarchical.getLevels();g=g.reverse();for(let m=0;m<f;m++){e=!1;for(let v=0;v<g.length;v++){let _=g[v],E=this.hierarchical.distributionOrdering[_];for(let T=0;T<E.length;T++)c(1e3,E[T])}if(e!==!0)break}},p=f=>{let g=this.hierarchical.getLevels();g=g.reverse();for(let m=0;m<f&&(e=!1,h(l,g,!0),e===!0);m++);},b=()=>{for(let f in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,f)&&this._centerParent(this.body.nodes[f])},C=()=>{let f=this.hierarchical.getLevels();f=f.reverse();for(let g=0;g<f.length;g++){let m=f[g],v=this.hierarchical.distributionOrdering[m];for(let _=0;_<v.length;_++)this._centerParent(v[_])}};this.options.hierarchical.blockShifting===!0&&(p(5),b()),this.options.hierarchical.edgeMinimization===!0&&u(20),this.options.hierarchical.parentCentralization===!0&&C(),i()}_getSpaceAroundNode(e,t){let i=!0;t===void 0&&(i=!1);let s=this.hierarchical.levels[e.id];if(s!==void 0){let o=this.hierarchical.distributionIndex[e.id],r=this.direction.getPosition(e),a=this.hierarchical.distributionOrdering[s],d=1e9,h=1e9;if(o!==0){let l=a[o-1];if(i===!0&&t[l.id]===void 0||i===!1){let c=this.direction.getPosition(l);d=r-c}}if(o!=a.length-1){let l=a[o+1];if(i===!0&&t[l.id]===void 0||i===!1){let c=this.direction.getPosition(l);h=Math.min(h,c-r)}}return[d,h]}else return[0,0]}_centerParent(e){if(this.hierarchical.parentReference[e.id]){let t=this.hierarchical.parentReference[e.id];for(let i=0;i<t.length;i++){let s=t[i],o=this.body.nodes[s],r=this.hierarchical.childrenReference[s];if(r!==void 0){let a=this._getCenterPosition(r),d=this.direction.getPosition(o),[h,l]=this._getSpaceAroundNode(o),c=d-a;(c<0&&Math.abs(c)<l-this.options.hierarchical.nodeSpacing||c>0&&Math.abs(c)<h-this.options.hierarchical.nodeSpacing)&&this.direction.setPosition(o,a)}}}}_placeNodesByHierarchy(e){this.positionedNodes={};for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let i=Object.keys(e[t]);i=this._indexArrayToNodes(i),this.direction.sort(i);let s=0;for(let o=0;o<i.length;o++){let r=i[o];if(this.positionedNodes[r.id]===void 0){let a=this.options.hierarchical.nodeSpacing,d=a*s;s>0&&(d=this.direction.getPosition(i[o-1])+a),this.direction.setPosition(r,d,t),this._validatePositionAndContinue(r,t,d),s++}}}}_placeBranchNodes(e,t){let i=this.hierarchical.childrenReference[e];if(i===void 0)return;let s=[];for(let r=0;r<i.length;r++)s.push(this.body.nodes[i[r]]);this.direction.sort(s);for(let r=0;r<s.length;r++){let a=s[r],d=this.hierarchical.levels[a.id];if(d>t&&this.positionedNodes[a.id]===void 0){let h=this.options.hierarchical.nodeSpacing,l;r===0?l=this.direction.getPosition(this.body.nodes[e]):l=this.direction.getPosition(s[r-1])+h,this.direction.setPosition(a,l,d),this._validatePositionAndContinue(a,d,l)}else return}let o=this._getCenterPosition(s);this.direction.setPosition(this.body.nodes[e],o,t)}_validatePositionAndContinue(e,t,i){if(!!this.hierarchical.isTree){if(this.lastNodeOnLevel[t]!==void 0){let s=this.direction.getPosition(this.body.nodes[this.lastNodeOnLevel[t]]);if(i-s<this.options.hierarchical.nodeSpacing){let o=s+this.options.hierarchical.nodeSpacing-i,r=this._findCommonParent(this.lastNodeOnLevel[t],e.id);this._shiftBlock(r.withChild,o)}}this.lastNodeOnLevel[t]=e.id,this.positionedNodes[e.id]=!0,this._placeBranchNodes(e.id,t)}}_indexArrayToNodes(e){let t=[];for(let i=0;i<e.length;i++)t.push(this.body.nodes[e[i]]);return t}_getDistribution(){let e={},t,i;for(t in this.body.nodes)if(Object.prototype.hasOwnProperty.call(this.body.nodes,t)){i=this.body.nodes[t];let s=this.hierarchical.levels[t]===void 0?0:this.hierarchical.levels[t];this.direction.fix(i,s),e[s]===void 0&&(e[s]={}),e[s][t]=i}return e}_getActiveEdges(e){let t=[];return A(e.edges,i=>{this.body.edgeIndices.indexOf(i.id)!==-1&&t.push(i)}),t}_getHubSizes(){let e={},t=this.body.nodeIndices;A(t,s=>{let o=this.body.nodes[s],r=this._getActiveEdges(o).length;e[r]=!0});let i=[];return A(e,s=>{i.push(Number(s))}),Et.default.sort(i,function(s,o){return o-s}),i}_determineLevelsByHubsize(){let e=(i,s)=>{this.hierarchical.levelDownstream(i,s)},t=this._getHubSizes();for(let i=0;i<t.length;++i){let s=t[i];if(s===0)break;A(this.body.nodeIndices,o=>{let r=this.body.nodes[o];s===this._getActiveEdges(r).length&&this._crawlNetwork(e,o)})}}_determineLevelsCustomCallback(){let e=1e5,t=function(s,o,r){},i=(s,o,r)=>{let a=this.hierarchical.levels[s.id];a===void 0&&(a=this.hierarchical.levels[s.id]=e);let d=t(J.cloneOptions(s,"node"),J.cloneOptions(o,"node"),J.cloneOptions(r,"edge"));this.hierarchical.levels[o.id]=a+d};this._crawlNetwork(i),this.hierarchical.setMinLevelToZero(this.body.nodes)}_determineLevelsDirected(){let e=this.body.nodeIndices.reduce((t,i)=>(t.set(i,this.body.nodes[i]),t),new Map);this.options.hierarchical.shakeTowards==="roots"?this.hierarchical.levels=Ma(e):this.hierarchical.levels=Pa(e),this.hierarchical.setMinLevelToZero(this.body.nodes)}_generateMap(){let e=(t,i)=>{this.hierarchical.levels[i.id]>this.hierarchical.levels[t.id]&&this.hierarchical.addRelation(t.id,i.id)};this._crawlNetwork(e),this.hierarchical.checkIfTree()}_crawlNetwork(e=function(){},t){let i={},s=(o,r)=>{if(i[o.id]===void 0){this.hierarchical.setTreeIndex(o,r),i[o.id]=!0;let a,d=this._getActiveEdges(o);for(let h=0;h<d.length;h++){let l=d[h];l.connected===!0&&(l.toId==o.id?a=l.from:a=l.to,o.id!=a.id&&(e(o,a,l),s(a,r)))}}};if(t===void 0){let o=0;for(let r=0;r<this.body.nodeIndices.length;r++){let a=this.body.nodeIndices[r];if(i[a]===void 0){let d=this.body.nodes[a];s(d,o),o+=1}}}else{let o=this.body.nodes[t];if(o===void 0){console.error("Node not found:",t);return}s(o)}}_shiftBlock(e,t){let i={},s=o=>{if(i[o])return;i[o]=!0,this.direction.shift(o,t);let r=this.hierarchical.childrenReference[o];if(r!==void 0)for(let a=0;a<r.length;a++)s(r[a])};s(e)}_findCommonParent(e,t){let i={},s=(r,a)=>{let d=this.hierarchical.parentReference[a];if(d!==void 0)for(let h=0;h<d.length;h++){let l=d[h];r[l]=!0,s(r,l)}},o=(r,a)=>{let d=this.hierarchical.parentReference[a];if(d!==void 0)for(let h=0;h<d.length;h++){let l=d[h];if(r[l]!==void 0)return{foundParent:l,withChild:a};let c=o(r,l);if(c.foundParent!==null)return c}return{foundParent:null,withChild:a}};return s(i,e),o(i,t)}setDirectionStrategy(){this.options.hierarchical.direction==="UD"||this.options.hierarchical.direction==="DU"?this.direction=new gn(this):this.direction=new mn(this)}_getCenterPosition(e){let t=1e9,i=-1e9;for(let s=0;s<e.length;s++){let o;if(e[s].id!==void 0)o=e[s];else{let a=e[s];o=this.body.nodes[a]}let r=this.direction.getPosition(o);t=Math.min(t,r),i=Math.max(i,r)}return .5*(t+i)}},wn=class{constructor(e,t,i,s){this.body=e,this.canvas=t,this.selectionHandler=i,this.interactionHandler=s,this.editMode=!1,this.manipulationDiv=void 0,this.editModeDiv=void 0,this.closeDiv=void 0,this._domEventListenerCleanupQueue=[],this.temporaryUIFunctions={},this.temporaryEventFunctions=[],this.touchTime=0,this.temporaryIds={nodes:[],edges:[]},this.guiEnabled=!1,this.inMode=!1,this.selectedControlNode=void 0,this.options={},this.defaultOptions={enabled:!1,initiallyActive:!1,addNode:!0,addEdge:!0,editNode:void 0,editEdge:!0,deleteNode:!0,deleteEdge:!0,controlNodeStyle:{shape:"dot",size:6,color:{background:"#ff0000",border:"#3c3c3c",highlight:{background:"#07f968",border:"#3c3c3c"}},borderWidth:2,borderWidthSelected:2}},Object.assign(this.options,this.defaultOptions),this.body.emitter.on("destroy",()=>{this._clean()}),this.body.emitter.on("_dataChanged",this._restore.bind(this)),this.body.emitter.on("_resetData",this._restore.bind(this))}_restore(){this.inMode!==!1&&(this.options.initiallyActive===!0?this.enableEditMode():this.disableEditMode())}setOptions(e,t,i){t!==void 0&&(t.locale!==void 0?this.options.locale=t.locale:this.options.locale=i.locale,t.locales!==void 0?this.options.locales=t.locales:this.options.locales=i.locales),e!==void 0&&(typeof e=="boolean"?this.options.enabled=e:(this.options.enabled=!0,j(this.options,e)),this.options.initiallyActive===!0&&(this.editMode=!0),this._setup())}toggleEditMode(){this.editMode===!0?this.disableEditMode():this.enableEditMode()}enableEditMode(){this.editMode=!0,this._clean(),this.guiEnabled===!0&&(this.manipulationDiv.style.display="block",this.closeDiv.style.display="block",this.editModeDiv.style.display="none",this.showManipulatorToolbar())}disableEditMode(){this.editMode=!1,this._clean(),this.guiEnabled===!0&&(this.manipulationDiv.style.display="none",this.closeDiv.style.display="none",this.editModeDiv.style.display="block",this._createEditButton())}showManipulatorToolbar(){if(this._clean(),this.manipulationDOM={},this.guiEnabled===!0){this.editMode=!0,this.manipulationDiv.style.display="block",this.closeDiv.style.display="block";let e=this.selectionHandler.getSelectedNodeCount(),t=this.selectionHandler.getSelectedEdgeCount(),i=e+t,s=this.options.locales[this.options.locale],o=!1;this.options.addNode!==!1&&(this._createAddNodeButton(s),o=!0),this.options.addEdge!==!1&&(o===!0?this._createSeperator(1):o=!0,this._createAddEdgeButton(s)),e===1&&typeof this.options.editNode=="function"?(o===!0?this._createSeperator(2):o=!0,this._createEditNodeButton(s)):t===1&&e===0&&this.options.editEdge!==!1&&(o===!0?this._createSeperator(3):o=!0,this._createEditEdgeButton(s)),i!==0&&(e>0&&this.options.deleteNode!==!1?(o===!0&&this._createSeperator(4),this._createDeleteButton(s)):e===0&&this.options.deleteEdge!==!1&&(o===!0&&this._createSeperator(4),this._createDeleteButton(s))),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this)),this._temporaryBindEvent("select",this.showManipulatorToolbar.bind(this))}this.body.emitter.emit("_redraw")}addNodeMode(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addNode",this.guiEnabled===!0){let e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.addDescription||this.options.locales.en.addDescription),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindEvent("click",this._performAddNode.bind(this))}editNode(){this.editMode!==!0&&this.enableEditMode(),this._clean();let e=this.selectionHandler.getSelectedNodes()[0];if(e!==void 0)if(this.inMode="editNode",typeof this.options.editNode=="function")if(e.isCluster!==!0){let t=j({},e.options,!1);if(t.x=e.x,t.y=e.y,this.options.editNode.length===2)this.options.editNode(t,i=>{i!=null&&this.inMode==="editNode"&&this.body.data.nodes.getDataSet().update(i),this.showManipulatorToolbar()});else throw new Error("The function for edit does not support two arguments (data, callback)")}else alert(this.options.locales[this.options.locale].editClusterError||this.options.locales.en.editClusterError);else throw new Error("No function has been configured to handle the editing of nodes.");else this.showManipulatorToolbar()}addEdgeMode(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addEdge",this.guiEnabled===!0){let e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.edgeDescription||this.options.locales.en.edgeDescription),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindUI("onTouch",this._handleConnect.bind(this)),this._temporaryBindUI("onDragEnd",this._finishConnect.bind(this)),this._temporaryBindUI("onDrag",this._dragControlNode.bind(this)),this._temporaryBindUI("onRelease",this._finishConnect.bind(this)),this._temporaryBindUI("onDragStart",this._dragStartEdge.bind(this)),this._temporaryBindUI("onHold",()=>{})}editEdgeMode(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="editEdge",typeof this.options.editEdge=="object"&&typeof this.options.editEdge.editWithoutDrag=="function"&&(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],this.edgeBeingEditedId!==void 0)){let e=this.body.edges[this.edgeBeingEditedId];this._performEditEdge(e.from.id,e.to.id);return}if(this.guiEnabled===!0){let e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.editEdgeDescription||this.options.locales.en.editEdgeDescription),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this))}if(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],this.edgeBeingEditedId!==void 0){let e=this.body.edges[this.edgeBeingEditedId],t=this._getNewTargetNode(e.from.x,e.from.y),i=this._getNewTargetNode(e.to.x,e.to.y);this.temporaryIds.nodes.push(t.id),this.temporaryIds.nodes.push(i.id),this.body.nodes[t.id]=t,this.body.nodeIndices.push(t.id),this.body.nodes[i.id]=i,this.body.nodeIndices.push(i.id),this._temporaryBindUI("onTouch",this._controlNodeTouch.bind(this)),this._temporaryBindUI("onTap",()=>{}),this._temporaryBindUI("onHold",()=>{}),this._temporaryBindUI("onDragStart",this._controlNodeDragStart.bind(this)),this._temporaryBindUI("onDrag",this._controlNodeDrag.bind(this)),this._temporaryBindUI("onDragEnd",this._controlNodeDragEnd.bind(this)),this._temporaryBindUI("onMouseMove",()=>{}),this._temporaryBindEvent("beforeDrawing",s=>{let o=e.edgeType.findBorderPositions(s);t.selected===!1&&(t.x=o.from.x,t.y=o.from.y),i.selected===!1&&(i.x=o.to.x,i.y=o.to.y)}),this.body.emitter.emit("_redraw")}else this.showManipulatorToolbar()}deleteSelected(){this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="delete";let e=this.selectionHandler.getSelectedNodeIds(),t=this.selectionHandler.getSelectedEdgeIds(),i;if(e.length>0){for(let s=0;s<e.length;s++)if(this.body.nodes[e[s]].isCluster===!0){alert(this.options.locales[this.options.locale].deleteClusterError||this.options.locales.en.deleteClusterError);return}typeof this.options.deleteNode=="function"&&(i=this.options.deleteNode)}else t.length>0&&typeof this.options.deleteEdge=="function"&&(i=this.options.deleteEdge);if(typeof i=="function"){let s={nodes:e,edges:t};if(i.length===2)i(s,o=>{o!=null&&this.inMode==="delete"?(this.body.data.edges.getDataSet().remove(o.edges),this.body.data.nodes.getDataSet().remove(o.nodes),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()):(this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar())});else throw new Error("The function for delete does not support two arguments (data, callback)")}else this.body.data.edges.getDataSet().remove(t),this.body.data.nodes.getDataSet().remove(e),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()}_setup(){this.options.enabled===!0?(this.guiEnabled=!0,this._createWrappers(),this.editMode===!1?this._createEditButton():this.showManipulatorToolbar()):(this._removeManipulationDOM(),this.guiEnabled=!1)}_createWrappers(){var e,t;this.manipulationDiv===void 0&&(this.manipulationDiv=document.createElement("div"),this.manipulationDiv.className="vis-manipulation",this.editMode===!0?this.manipulationDiv.style.display="block":this.manipulationDiv.style.display="none",this.canvas.frame.appendChild(this.manipulationDiv)),this.editModeDiv===void 0&&(this.editModeDiv=document.createElement("div"),this.editModeDiv.className="vis-edit-mode",this.editMode===!0?this.editModeDiv.style.display="none":this.editModeDiv.style.display="block",this.canvas.frame.appendChild(this.editModeDiv)),this.closeDiv===void 0&&(this.closeDiv=document.createElement("button"),this.closeDiv.className="vis-close",this.closeDiv.setAttribute("aria-label",(t=(e=this.options.locales[this.options.locale])==null?void 0:e.close)!=null?t:this.options.locales.en.close),this.closeDiv.style.display=this.manipulationDiv.style.display,this.canvas.frame.appendChild(this.closeDiv))}_getNewTargetNode(e,t){let i=j({},this.options.controlNodeStyle);i.id="targetNode"+Ce(),i.hidden=!1,i.physics=!1,i.x=e,i.y=t;let s=this.body.functions.createNode(i);return s.shape.boundingBox={left:e,right:e,top:t,bottom:t},s}_createEditButton(){this._clean(),this.manipulationDOM={},we(this.editModeDiv);let e=this.options.locales[this.options.locale],t=this._createButton("editMode","vis-edit vis-edit-mode",e.edit||this.options.locales.en.edit);this.editModeDiv.appendChild(t),this._bindElementEvents(t,this.toggleEditMode.bind(this))}_clean(){this.inMode=!1,this.guiEnabled===!0&&(we(this.editModeDiv),we(this.manipulationDiv),this._cleanupDOMEventListeners()),this._cleanupTemporaryNodesAndEdges(),this._unbindTemporaryUIs(),this._unbindTemporaryEvents(),this.body.emitter.emit("restorePhysics")}_cleanupDOMEventListeners(){for(let e of this._domEventListenerCleanupQueue.splice(0))e()}_removeManipulationDOM(){this._clean(),we(this.manipulationDiv),we(this.editModeDiv),we(this.closeDiv),this.manipulationDiv&&this.canvas.frame.removeChild(this.manipulationDiv),this.editModeDiv&&this.canvas.frame.removeChild(this.editModeDiv),this.closeDiv&&this.canvas.frame.removeChild(this.closeDiv),this.manipulationDiv=void 0,this.editModeDiv=void 0,this.closeDiv=void 0}_createSeperator(e=1){this.manipulationDOM["seperatorLineDiv"+e]=document.createElement("div"),this.manipulationDOM["seperatorLineDiv"+e].className="vis-separator-line",this.manipulationDiv.appendChild(this.manipulationDOM["seperatorLineDiv"+e])}_createAddNodeButton(e){let t=this._createButton("addNode","vis-add",e.addNode||this.options.locales.en.addNode);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.addNodeMode.bind(this))}_createAddEdgeButton(e){let t=this._createButton("addEdge","vis-connect",e.addEdge||this.options.locales.en.addEdge);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.addEdgeMode.bind(this))}_createEditNodeButton(e){let t=this._createButton("editNode","vis-edit",e.editNode||this.options.locales.en.editNode);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.editNode.bind(this))}_createEditEdgeButton(e){let t=this._createButton("editEdge","vis-edit",e.editEdge||this.options.locales.en.editEdge);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.editEdgeMode.bind(this))}_createDeleteButton(e){let t;this.options.rtl?t="vis-delete-rtl":t="vis-delete";let i=this._createButton("delete",t,e.del||this.options.locales.en.del);this.manipulationDiv.appendChild(i),this._bindElementEvents(i,this.deleteSelected.bind(this))}_createBackButton(e){let t=this._createButton("back","vis-back",e.back||this.options.locales.en.back);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.showManipulatorToolbar.bind(this))}_createButton(e,t,i,s="vis-label"){return this.manipulationDOM[e+"Div"]=document.createElement("button"),this.manipulationDOM[e+"Div"].className="vis-button "+t,this.manipulationDOM[e+"Label"]=document.createElement("div"),this.manipulationDOM[e+"Label"].className=s,this.manipulationDOM[e+"Label"].innerText=i,this.manipulationDOM[e+"Div"].appendChild(this.manipulationDOM[e+"Label"]),this.manipulationDOM[e+"Div"]}_createDescription(e){this.manipulationDOM.descriptionLabel=document.createElement("div"),this.manipulationDOM.descriptionLabel.className="vis-none",this.manipulationDOM.descriptionLabel.innerText=e,this.manipulationDiv.appendChild(this.manipulationDOM.descriptionLabel)}_temporaryBindEvent(e,t){this.temporaryEventFunctions.push({event:e,boundFunction:t}),this.body.emitter.on(e,t)}_temporaryBindUI(e,t){if(this.body.eventListeners[e]!==void 0)this.temporaryUIFunctions[e]=this.body.eventListeners[e],this.body.eventListeners[e]=t;else throw new Error("This UI function does not exist. Typo? You tried: "+e+" possible are: "+JSON.stringify(Object.keys(this.body.eventListeners)))}_unbindTemporaryUIs(){for(let e in this.temporaryUIFunctions)Object.prototype.hasOwnProperty.call(this.temporaryUIFunctions,e)&&(this.body.eventListeners[e]=this.temporaryUIFunctions[e],delete this.temporaryUIFunctions[e]);this.temporaryUIFunctions={}}_unbindTemporaryEvents(){for(let e=0;e<this.temporaryEventFunctions.length;e++){let t=this.temporaryEventFunctions[e].event,i=this.temporaryEventFunctions[e].boundFunction;this.body.emitter.off(t,i)}this.temporaryEventFunctions=[]}_bindElementEvents(e,t){let i=new Ue(e,{});Qt(i,t),this._domEventListenerCleanupQueue.push(()=>{i.destroy()});let s=({keyCode:o,key:r})=>{(r==="Enter"||r===" "||o===13||o===32)&&t()};e.addEventListener("keyup",s,!1),this._domEventListenerCleanupQueue.push(()=>{e.removeEventListener("keyup",s,!1)})}_cleanupTemporaryNodesAndEdges(){for(let e=0;e<this.temporaryIds.edges.length;e++){this.body.edges[this.temporaryIds.edges[e]].disconnect(),delete this.body.edges[this.temporaryIds.edges[e]];let t=this.body.edgeIndices.indexOf(this.temporaryIds.edges[e]);t!==-1&&this.body.edgeIndices.splice(t,1)}for(let e=0;e<this.temporaryIds.nodes.length;e++){delete this.body.nodes[this.temporaryIds.nodes[e]];let t=this.body.nodeIndices.indexOf(this.temporaryIds.nodes[e]);t!==-1&&this.body.nodeIndices.splice(t,1)}this.temporaryIds={nodes:[],edges:[]}}_controlNodeTouch(e){this.selectionHandler.unselectAll(),this.lastTouch=this.body.functions.getPointer(e.center),this.lastTouch.translation=Object.assign({},this.body.view.translation)}_controlNodeDragStart(){let e=this.lastTouch,t=this.selectionHandler._pointerToPositionObject(e),i=this.body.nodes[this.temporaryIds.nodes[0]],s=this.body.nodes[this.temporaryIds.nodes[1]],o=this.body.edges[this.edgeBeingEditedId];this.selectedControlNode=void 0;let r=i.isOverlappingWith(t),a=s.isOverlappingWith(t);r===!0?(this.selectedControlNode=i,o.edgeType.from=i):a===!0&&(this.selectedControlNode=s,o.edgeType.to=s),this.selectedControlNode!==void 0&&this.selectionHandler.selectObject(this.selectedControlNode),this.body.emitter.emit("_redraw")}_controlNodeDrag(e){this.body.emitter.emit("disablePhysics");let t=this.body.functions.getPointer(e.center),i=this.canvas.DOMtoCanvas(t);this.selectedControlNode!==void 0?(this.selectedControlNode.x=i.x,this.selectedControlNode.y=i.y):this.interactionHandler.onDrag(e),this.body.emitter.emit("_redraw")}_controlNodeDragEnd(e){let t=this.body.functions.getPointer(e.center),i=this.selectionHandler._pointerToPositionObject(t),s=this.body.edges[this.edgeBeingEditedId];if(this.selectedControlNode===void 0)return;this.selectionHandler.unselectAll();let o=this.selectionHandler._getAllNodesOverlappingWith(i),r;for(let a=o.length-1;a>=0;a--)if(o[a]!==this.selectedControlNode.id){r=this.body.nodes[o[a]];break}if(r!==void 0&&this.selectedControlNode!==void 0)if(r.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let a=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===a.id?this._performEditEdge(r.id,s.to.id):this._performEditEdge(s.from.id,r.id)}else s.updateEdgeType(),this.body.emitter.emit("restorePhysics");this.body.emitter.emit("_redraw")}_handleConnect(e){if(new Date().valueOf()-this.touchTime>100){this.lastTouch=this.body.functions.getPointer(e.center),this.lastTouch.translation=Object.assign({},this.body.view.translation),this.interactionHandler.drag.pointer=this.lastTouch,this.interactionHandler.drag.translation=this.lastTouch.translation;let t=this.lastTouch,i=this.selectionHandler.getNodeAt(t);if(i!==void 0)if(i.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let s=this._getNewTargetNode(i.x,i.y);this.body.nodes[s.id]=s,this.body.nodeIndices.push(s.id);let o=this.body.functions.createEdge({id:"connectionEdge"+Ce(),from:i.id,to:s.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[o.id]=o,this.body.edgeIndices.push(o.id),this.temporaryIds.nodes.push(s.id),this.temporaryIds.edges.push(o.id)}this.touchTime=new Date().valueOf()}}_dragControlNode(e){let t=this.body.functions.getPointer(e.center),i=this.selectionHandler._pointerToPositionObject(t),s;this.temporaryIds.edges[0]!==void 0&&(s=this.body.edges[this.temporaryIds.edges[0]].fromId);let o=this.selectionHandler._getAllNodesOverlappingWith(i),r;for(let a=o.length-1;a>=0;a--)if(this.temporaryIds.nodes.indexOf(o[a])===-1){r=this.body.nodes[o[a]];break}if(e.controlEdge={from:s,to:r?r.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragging",e,t),this.temporaryIds.nodes[0]!==void 0){let a=this.body.nodes[this.temporaryIds.nodes[0]];a.x=this.canvas._XconvertDOMtoCanvas(t.x),a.y=this.canvas._YconvertDOMtoCanvas(t.y),this.body.emitter.emit("_redraw")}else this.interactionHandler.onDrag(e)}_finishConnect(e){let t=this.body.functions.getPointer(e.center),i=this.selectionHandler._pointerToPositionObject(t),s;this.temporaryIds.edges[0]!==void 0&&(s=this.body.edges[this.temporaryIds.edges[0]].fromId);let o=this.selectionHandler._getAllNodesOverlappingWith(i),r;for(let a=o.length-1;a>=0;a--)if(this.temporaryIds.nodes.indexOf(o[a])===-1){r=this.body.nodes[o[a]];break}this._cleanupTemporaryNodesAndEdges(),r!==void 0&&(r.isCluster===!0?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):this.body.nodes[s]!==void 0&&this.body.nodes[r.id]!==void 0&&this._performAddEdge(s,r.id)),e.controlEdge={from:s,to:r?r.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragEnd",e,t),this.body.emitter.emit("_redraw")}_dragStartEdge(e){let t=this.lastTouch;this.selectionHandler.generateClickEvent("dragStart",e,t,void 0,!0)}_performAddNode(e){let t={id:Ce(),x:e.pointer.canvas.x,y:e.pointer.canvas.y,label:"new"};if(typeof this.options.addNode=="function")if(this.options.addNode.length===2)this.options.addNode(t,i=>{i!=null&&this.inMode==="addNode"&&this.body.data.nodes.getDataSet().add(i),this.showManipulatorToolbar()});else throw this.showManipulatorToolbar(),new Error("The function for add does not support two arguments (data,callback)");else this.body.data.nodes.getDataSet().add(t),this.showManipulatorToolbar()}_performAddEdge(e,t){let i={from:e,to:t};if(typeof this.options.addEdge=="function")if(this.options.addEdge.length===2)this.options.addEdge(i,s=>{s!=null&&this.inMode==="addEdge"&&(this.body.data.edges.getDataSet().add(s),this.selectionHandler.unselectAll(),this.showManipulatorToolbar())});else throw new Error("The function for connect does not support two arguments (data,callback)");else this.body.data.edges.getDataSet().add(i),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}_performEditEdge(e,t){let i={id:this.edgeBeingEditedId,from:e,to:t,label:this.body.data.edges.get(this.edgeBeingEditedId).label},s=this.options.editEdge;if(typeof s=="object"&&(s=s.editWithoutDrag),typeof s=="function")if(s.length===2)s(i,o=>{o==null||this.inMode!=="editEdge"?(this.body.edges[i.id].updateEdgeType(),this.body.emitter.emit("_redraw"),this.showManipulatorToolbar()):(this.body.data.edges.getDataSet().update(o),this.selectionHandler.unselectAll(),this.showManipulatorToolbar())});else throw new Error("The function for edit does not support two arguments (data, callback)");else this.body.data.edges.getDataSet().update(i),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},O="string",S="boolean",y="number",Tt="array",P="object",_n="dom",Da="any",Wi=["arrow","bar","box","circle","crow","curve","diamond","image","inv_curve","inv_triangle","triangle","vee"],Vi={borderWidth:{number:y},borderWidthSelected:{number:y,undefined:"undefined"},brokenImage:{string:O,undefined:"undefined"},chosen:{label:{boolean:S,function:"function"},node:{boolean:S,function:"function"},__type__:{object:P,boolean:S}},color:{border:{string:O},background:{string:O},highlight:{border:{string:O},background:{string:O},__type__:{object:P,string:O}},hover:{border:{string:O},background:{string:O},__type__:{object:P,string:O}},__type__:{object:P,string:O}},opacity:{number:y,undefined:"undefined"},fixed:{x:{boolean:S},y:{boolean:S},__type__:{object:P,boolean:S}},font:{align:{string:O},color:{string:O},size:{number:y},face:{string:O},background:{string:O},strokeWidth:{number:y},strokeColor:{string:O},vadjust:{number:y},multi:{boolean:S,string:O},bold:{color:{string:O},size:{number:y},face:{string:O},mod:{string:O},vadjust:{number:y},__type__:{object:P,string:O}},boldital:{color:{string:O},size:{number:y},face:{string:O},mod:{string:O},vadjust:{number:y},__type__:{object:P,string:O}},ital:{color:{string:O},size:{number:y},face:{string:O},mod:{string:O},vadjust:{number:y},__type__:{object:P,string:O}},mono:{color:{string:O},size:{number:y},face:{string:O},mod:{string:O},vadjust:{number:y},__type__:{object:P,string:O}},__type__:{object:P,string:O}},group:{string:O,number:y,undefined:"undefined"},heightConstraint:{minimum:{number:y},valign:{string:O},__type__:{object:P,boolean:S,number:y}},hidden:{boolean:S},icon:{face:{string:O},code:{string:O},size:{number:y},color:{string:O},weight:{string:O,number:y},__type__:{object:P}},id:{string:O,number:y},image:{selected:{string:O,undefined:"undefined"},unselected:{string:O,undefined:"undefined"},__type__:{object:P,string:O}},imagePadding:{top:{number:y},right:{number:y},bottom:{number:y},left:{number:y},__type__:{object:P,number:y}},label:{string:O,undefined:"undefined"},labelHighlightBold:{boolean:S},level:{number:y,undefined:"undefined"},margin:{top:{number:y},right:{number:y},bottom:{number:y},left:{number:y},__type__:{object:P,number:y}},mass:{number:y},physics:{boolean:S},scaling:{min:{number:y},max:{number:y},label:{enabled:{boolean:S},min:{number:y},max:{number:y},maxVisible:{number:y},drawThreshold:{number:y},__type__:{object:P,boolean:S}},customScalingFunction:{function:"function"},__type__:{object:P}},shadow:{enabled:{boolean:S},color:{string:O},size:{number:y},x:{number:y},y:{number:y},__type__:{object:P,boolean:S}},shape:{string:["custom","ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon","hexagon"]},ctxRenderer:{function:"function"},shapeProperties:{borderDashes:{boolean:S,array:Tt},borderRadius:{number:y},interpolation:{boolean:S},useImageSize:{boolean:S},useBorderWithImage:{boolean:S},coordinateOrigin:{string:["center","top-left"]},__type__:{object:P}},size:{number:y},title:{string:O,dom:_n,undefined:"undefined"},value:{number:y,undefined:"undefined"},widthConstraint:{minimum:{number:y},maximum:{number:y},__type__:{object:P,boolean:S,number:y}},x:{number:y},y:{number:y},__type__:{object:P}},Fa={configure:{enabled:{boolean:S},filter:{boolean:S,string:O,array:Tt,function:"function"},container:{dom:_n},showButton:{boolean:S},__type__:{object:P,boolean:S,string:O,array:Tt,function:"function"}},edges:{arrows:{to:{enabled:{boolean:S},scaleFactor:{number:y},type:{string:Wi},imageHeight:{number:y},imageWidth:{number:y},src:{string:O},__type__:{object:P,boolean:S}},middle:{enabled:{boolean:S},scaleFactor:{number:y},type:{string:Wi},imageWidth:{number:y},imageHeight:{number:y},src:{string:O},__type__:{object:P,boolean:S}},from:{enabled:{boolean:S},scaleFactor:{number:y},type:{string:Wi},imageWidth:{number:y},imageHeight:{number:y},src:{string:O},__type__:{object:P,boolean:S}},__type__:{string:["from","to","middle"],object:P}},endPointOffset:{from:{number:y},to:{number:y},__type__:{object:P,number:y}},arrowStrikethrough:{boolean:S},background:{enabled:{boolean:S},color:{string:O},size:{number:y},dashes:{boolean:S,array:Tt},__type__:{object:P,boolean:S}},chosen:{label:{boolean:S,function:"function"},edge:{boolean:S,function:"function"},__type__:{object:P,boolean:S}},color:{color:{string:O},highlight:{string:O},hover:{string:O},inherit:{string:["from","to","both"],boolean:S},opacity:{number:y},__type__:{object:P,string:O}},dashes:{boolean:S,array:Tt},font:{color:{string:O},size:{number:y},face:{string:O},background:{string:O},strokeWidth:{number:y},strokeColor:{string:O},align:{string:["horizontal","top","middle","bottom"]},vadjust:{number:y},multi:{boolean:S,string:O},bold:{color:{string:O},size:{number:y},face:{string:O},mod:{string:O},vadjust:{number:y},__type__:{object:P,string:O}},boldital:{color:{string:O},size:{number:y},face:{string:O},mod:{string:O},vadjust:{number:y},__type__:{object:P,string:O}},ital:{color:{string:O},size:{number:y},face:{string:O},mod:{string:O},vadjust:{number:y},__type__:{object:P,string:O}},mono:{color:{string:O},size:{number:y},face:{string:O},mod:{string:O},vadjust:{number:y},__type__:{object:P,string:O}},__type__:{object:P,string:O}},hidden:{boolean:S},hoverWidth:{function:"function",number:y},label:{string:O,undefined:"undefined"},labelHighlightBold:{boolean:S},length:{number:y,undefined:"undefined"},physics:{boolean:S},scaling:{min:{number:y},max:{number:y},label:{enabled:{boolean:S},min:{number:y},max:{number:y},maxVisible:{number:y},drawThreshold:{number:y},__type__:{object:P,boolean:S}},customScalingFunction:{function:"function"},__type__:{object:P}},selectionWidth:{function:"function",number:y},selfReferenceSize:{number:y},selfReference:{size:{number:y},angle:{number:y},renderBehindTheNode:{boolean:S},__type__:{object:P}},shadow:{enabled:{boolean:S},color:{string:O},size:{number:y},x:{number:y},y:{number:y},__type__:{object:P,boolean:S}},smooth:{enabled:{boolean:S},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:y},forceDirection:{string:["horizontal","vertical","none"],boolean:S},__type__:{object:P,boolean:S}},title:{string:O,undefined:"undefined"},width:{number:y},widthConstraint:{maximum:{number:y},__type__:{object:P,boolean:S,number:y}},value:{number:y,undefined:"undefined"},__type__:{object:P}},groups:{useDefaultGroups:{boolean:S},__any__:Vi,__type__:{object:P}},interaction:{dragNodes:{boolean:S},dragView:{boolean:S},hideEdgesOnDrag:{boolean:S},hideEdgesOnZoom:{boolean:S},hideNodesOnDrag:{boolean:S},hover:{boolean:S},keyboard:{enabled:{boolean:S},speed:{x:{number:y},y:{number:y},zoom:{number:y},__type__:{object:P}},bindToWindow:{boolean:S},autoFocus:{boolean:S},__type__:{object:P,boolean:S}},multiselect:{boolean:S},navigationButtons:{boolean:S},selectable:{boolean:S},selectConnectedEdges:{boolean:S},hoverConnectedEdges:{boolean:S},tooltipDelay:{number:y},zoomView:{boolean:S},zoomSpeed:{number:y},__type__:{object:P}},layout:{randomSeed:{undefined:"undefined",number:y,string:O},improvedLayout:{boolean:S},clusterThreshold:{number:y},hierarchical:{enabled:{boolean:S},levelSeparation:{number:y},nodeSpacing:{number:y},treeSpacing:{number:y},blockShifting:{boolean:S},edgeMinimization:{boolean:S},parentCentralization:{boolean:S},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},shakeTowards:{string:["leaves","roots"]},__type__:{object:P,boolean:S}},__type__:{object:P}},manipulation:{enabled:{boolean:S},initiallyActive:{boolean:S},addNode:{boolean:S,function:"function"},addEdge:{boolean:S,function:"function"},editNode:{function:"function"},editEdge:{editWithoutDrag:{function:"function"},__type__:{object:P,boolean:S,function:"function"}},deleteNode:{boolean:S,function:"function"},deleteEdge:{boolean:S,function:"function"},controlNodeStyle:Vi,__type__:{object:P,boolean:S}},nodes:Vi,physics:{enabled:{boolean:S},barnesHut:{theta:{number:y},gravitationalConstant:{number:y},centralGravity:{number:y},springLength:{number:y},springConstant:{number:y},damping:{number:y},avoidOverlap:{number:y},__type__:{object:P}},forceAtlas2Based:{theta:{number:y},gravitationalConstant:{number:y},centralGravity:{number:y},springLength:{number:y},springConstant:{number:y},damping:{number:y},avoidOverlap:{number:y},__type__:{object:P}},repulsion:{centralGravity:{number:y},springLength:{number:y},springConstant:{number:y},nodeDistance:{number:y},damping:{number:y},__type__:{object:P}},hierarchicalRepulsion:{centralGravity:{number:y},springLength:{number:y},springConstant:{number:y},nodeDistance:{number:y},damping:{number:y},avoidOverlap:{number:y},__type__:{object:P}},maxVelocity:{number:y},minVelocity:{number:y},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{boolean:S},iterations:{number:y},updateInterval:{number:y},onlyDynamicEdges:{boolean:S},fit:{boolean:S},__type__:{object:P,boolean:S}},timestep:{number:y},adaptiveTimestep:{boolean:S},wind:{x:{number:y},y:{number:y},__type__:{object:P}},__type__:{object:P,boolean:S}},autoResize:{boolean:S},clickToUse:{boolean:S},locale:{string:O},locales:{__any__:{any:Da},__type__:{object:P}},height:{string:O},width:{string:O},__type__:{object:P}},En={nodes:{borderWidth:[1,0,10,1],borderWidthSelected:[2,0,10,1],color:{border:["color","#2B7CE9"],background:["color","#97C2FC"],highlight:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]},hover:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]}},opacity:[0,0,1,.1],fixed:{x:!1,y:!1},font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[0,0,50,1],strokeColor:["color","#ffffff"]},hidden:!1,labelHighlightBold:!0,physics:!0,scaling:{min:[10,0,200,1],max:[30,0,200,1],label:{enabled:!1,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},shape:["ellipse","box","circle","database","diamond","dot","square","star","text","triangle","triangleDown","hexagon"],shapeProperties:{borderDashes:!1,borderRadius:[6,0,20,1],interpolation:!0,useImageSize:!1},size:[25,0,200,1]},edges:{arrows:{to:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},middle:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},from:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"}},endPointOffset:{from:[0,-10,10,1],to:[0,-10,10,1]},arrowStrikethrough:!0,color:{color:["color","#848484"],highlight:["color","#848484"],hover:["color","#848484"],inherit:["from","to","both",!0,!1],opacity:[1,0,1,.05]},dashes:!1,font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[2,0,50,1],strokeColor:["color","#ffffff"],align:["horizontal","top","middle","bottom"]},hidden:!1,hoverWidth:[1.5,0,5,.1],labelHighlightBold:!0,physics:!0,scaling:{min:[1,0,100,1],max:[15,0,100,1],label:{enabled:!0,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},selectionWidth:[1.5,0,5,.1],selfReferenceSize:[20,0,200,1],selfReference:{size:[20,0,200,1],angle:[Math.PI/2,-6*Math.PI,6*Math.PI,Math.PI/8],renderBehindTheNode:!0},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},smooth:{enabled:!0,type:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"],forceDirection:["horizontal","vertical","none"],roundness:[.5,0,1,.05]},width:[1,0,30,1]},layout:{hierarchical:{enabled:!1,levelSeparation:[150,20,500,5],nodeSpacing:[100,20,500,5],treeSpacing:[200,20,500,5],blockShifting:!0,edgeMinimization:!0,parentCentralization:!0,direction:["UD","DU","LR","RL"],sortMethod:["hubsize","directed"],shakeTowards:["leaves","roots"]}},interaction:{dragNodes:!0,dragView:!0,hideEdgesOnDrag:!1,hideEdgesOnZoom:!1,hideNodesOnDrag:!1,hover:!1,keyboard:{enabled:!1,speed:{x:[10,0,40,1],y:[10,0,40,1],zoom:[.02,0,.1,.005]},bindToWindow:!0,autoFocus:!0},multiselect:!1,navigationButtons:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0,tooltipDelay:[300,0,1e3,25],zoomView:!0,zoomSpeed:[1,.1,2,.1]},manipulation:{enabled:!1,initiallyActive:!1},physics:{enabled:!0,barnesHut:{theta:[.5,.1,1,.05],gravitationalConstant:[-2e3,-3e4,0,50],centralGravity:[.3,0,10,.05],springLength:[95,0,500,5],springConstant:[.04,0,1.2,.005],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},forceAtlas2Based:{theta:[.5,.1,1,.05],gravitationalConstant:[-50,-500,0,1],centralGravity:[.01,0,1,.005],springLength:[95,0,500,5],springConstant:[.08,0,1.2,.005],damping:[.4,0,1,.01],avoidOverlap:[0,0,1,.01]},repulsion:{centralGravity:[.2,0,10,.05],springLength:[200,0,500,5],springConstant:[.05,0,1.2,.005],nodeDistance:[100,0,500,5],damping:[.09,0,1,.01]},hierarchicalRepulsion:{centralGravity:[.2,0,10,.05],springLength:[100,0,500,5],springConstant:[.01,0,1.2,.005],nodeDistance:[120,0,500,5],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},maxVelocity:[50,0,150,1],minVelocity:[.1,.01,.5,.01],solver:["barnesHut","forceAtlas2Based","repulsion","hierarchicalRepulsion"],timestep:[.5,.01,1,.01],wind:{x:[0,-10,10,.1],y:[0,-10,10,.1]}}},Na=(n,e,t)=>!!(n.includes("physics")&&En.physics.solver.includes(e)&&t.physics.solver!==e&&e!=="wind");var xn=class{constructor(){}getDistances(e,t,i){let s={},o=e.edges;for(let a=0;a<t.length;a++){let d=t[a],h={};s[d]=h;for(let l=0;l<t.length;l++)h[t[l]]=a==l?0:1e9}for(let a=0;a<i.length;a++){let d=o[i[a]];d.connected===!0&&s[d.fromId]!==void 0&&s[d.toId]!==void 0&&(s[d.fromId][d.toId]=1,s[d.toId][d.fromId]=1)}let r=t.length;for(let a=0;a<r;a++){let d=t[a],h=s[d];for(let l=0;l<r-1;l++){let c=t[l],u=s[c];for(let p=l+1;p<r;p++){let b=t[p],C=s[b],f=Math.min(u[b],u[d]+h[b]);u[b]=f,C[c]=f}}}return s}},Cn=class{constructor(e,t,i){this.body=e,this.springLength=t,this.springConstant=i,this.distanceSolver=new xn}setOptions(e){e&&(e.springLength&&(this.springLength=e.springLength),e.springConstant&&(this.springConstant=e.springConstant))}solve(e,t,i=!1){let s=this.distanceSolver.getDistances(this.body,e,t);this._createL_matrix(s),this._createK_matrix(s),this._createE_matrix();let o=.01,r=1,a=0,d=Math.max(1e3,Math.min(10*this.body.nodeIndices.length,6e3)),h=5,l=1e9,c=0,u=0,p=0,b=0,C=0;for(;l>o&&a<d;)for(a+=1,[c,l,u,p]=this._getHighestEnergyNode(i),b=l,C=0;b>r&&C<h;)C+=1,this._moveNode(c,u,p),[b,u,p]=this._getEnergy(c)}_getHighestEnergyNode(e){let t=this.body.nodeIndices,i=this.body.nodes,s=0,o=t[0],r=0,a=0;for(let d=0;d<t.length;d++){let h=t[d];if(i[h].predefinedPosition!==!0||i[h].isCluster===!0&&e===!0||i[h].options.fixed.x!==!0||i[h].options.fixed.y!==!0){let[l,c,u]=this._getEnergy(h);s<l&&(s=l,o=h,r=c,a=u)}}return[o,s,r,a]}_getEnergy(e){let[t,i]=this.E_sums[e];return[Math.sqrt(t**2+i**2),t,i]}_moveNode(e,t,i){let s=this.body.nodeIndices,o=this.body.nodes,r=0,a=0,d=0,h=o[e].x,l=o[e].y,c=this.K_matrix[e],u=this.L_matrix[e];for(let _=0;_<s.length;_++){let E=s[_];if(E!==e){let T=o[E].x,x=o[E].y,w=c[E],k=u[E],N=1/((h-T)**2+(l-x)**2)**1.5;r+=w*(1-k*(l-x)**2*N),a+=w*(k*(h-T)*(l-x)*N),d+=w*(1-k*(h-T)**2*N)}}let p=r,b=a,C=t,f=d,g=i,m=(C/p+g/b)/(b/p-f/b),v=-(b*m+C)/p;o[e].x+=v,o[e].y+=m,this._updateE_matrix(e)}_createL_matrix(e){let t=this.body.nodeIndices,i=this.springLength;this.L_matrix=[];for(let s=0;s<t.length;s++){this.L_matrix[t[s]]={};for(let o=0;o<t.length;o++)this.L_matrix[t[s]][t[o]]=i*e[t[s]][t[o]]}}_createK_matrix(e){let t=this.body.nodeIndices,i=this.springConstant;this.K_matrix=[];for(let s=0;s<t.length;s++){this.K_matrix[t[s]]={};for(let o=0;o<t.length;o++)this.K_matrix[t[s]][t[o]]=i*e[t[s]][t[o]]**-2}}_createE_matrix(){let e=this.body.nodeIndices,t=this.body.nodes;this.E_matrix={},this.E_sums={};for(let i=0;i<e.length;i++)this.E_matrix[e[i]]=[];for(let i=0;i<e.length;i++){let s=e[i],o=t[s].x,r=t[s].y,a=0,d=0;for(let h=i;h<e.length;h++){let l=e[h];if(l!==s){let c=t[l].x,u=t[l].y,p=1/Math.sqrt((o-c)**2+(r-u)**2);this.E_matrix[s][h]=[this.K_matrix[s][l]*(o-c-this.L_matrix[s][l]*(o-c)*p),this.K_matrix[s][l]*(r-u-this.L_matrix[s][l]*(r-u)*p)],this.E_matrix[l][i]=this.E_matrix[s][h],a+=this.E_matrix[s][h][0],d+=this.E_matrix[s][h][1]}}this.E_sums[s]=[a,d]}}_updateE_matrix(e){let t=this.body.nodeIndices,i=this.body.nodes,s=this.E_matrix[e],o=this.K_matrix[e],r=this.L_matrix[e],a=i[e].x,d=i[e].y,h=0,l=0;for(let c=0;c<t.length;c++){let u=t[c];if(u!==e){let p=s[c],b=p[0],C=p[1],f=i[u].x,g=i[u].y,m=1/Math.sqrt((a-f)**2+(d-g)**2),v=o[u]*(a-f-r[u]*(a-f)*m),_=o[u]*(d-g-r[u]*(d-g)*m);s[c]=[v,_],h+=v,l+=_;let E=this.E_sums[u];E[0]+=v-b,E[1]+=_-C}}this.E_sums[e]=[h,l]}};function I(n,e,t){if(!(this instanceof I))throw new SyntaxError("Constructor must be called with the new operator");this.options={},this.defaultOptions={locale:"en",locales:ba,clickToUse:!1},Object.assign(this.options,this.defaultOptions),this.body={container:n,nodes:{},nodeIndices:[],edges:{},edgeIndices:[],emitter:{on:this.on.bind(this),off:this.off.bind(this),emit:this.emit.bind(this),once:this.once.bind(this)},eventListeners:{onTap:function(){},onTouch:function(){},onDoubleTap:function(){},onHold:function(){},onDragStart:function(){},onDrag:function(){},onDragEnd:function(){},onMouseWheel:function(){},onPinch:function(){},onMouseMove:function(){},onRelease:function(){},onContext:function(){}},data:{nodes:null,edges:null},functions:{createNode:function(){},createEdge:function(){},getPointer:function(){}},modules:{},view:{scale:1,translation:{x:0,y:0}},selectionBox:{show:!1,position:{start:{x:0,y:0},end:{x:0,y:0}}}},this.bindEventListeners(),this.images=new Eo(()=>this.body.emitter.emit("_requestRedraw")),this.groups=new xo,this.canvas=new dn(this.body),this.selectionHandler=new pn(this.body,this.canvas),this.interactionHandler=new cn(this.body,this.canvas,this.selectionHandler),this.view=new hn(this.body,this.canvas),this.renderer=new rn(this.body,this.canvas),this.physics=new sn(this.body),this.layoutEngine=new vn(this.body),this.clustering=new nn(this.body),this.manipulation=new wn(this.body,this.canvas,this.selectionHandler,this.interactionHandler),this.nodesHandler=new zo(this.body,this.images,this.groups,this.layoutEngine),this.edgesHandler=new Zo(this.body,this.images,this.groups),this.body.modules.kamadaKawai=new Cn(this.body,150,.05),this.body.modules.clustering=this.clustering,this.canvas._create(),this.setOptions(t),this.setData(e)}(0,no.default)(I.prototype);I.prototype.setOptions=function(n){if(n===null&&(n=void 0),n!==void 0){if(Qs.validate(n,Fa)===!0&&console.error("%cErrors have been found in the supplied options object.",_i),qe(["locale","locales","clickToUse"],this.options,n),n.locale!==void 0&&(n.locale=va(n.locales||this.options.locales,n.locale)),n=this.layoutEngine.setOptions(n.layout,n),this.canvas.setOptions(n),this.groups.setOptions(n.groups),this.nodesHandler.setOptions(n.nodes),this.edgesHandler.setOptions(n.edges),this.physics.setOptions(n.physics),this.manipulation.setOptions(n.manipulation,n,this.options),this.interactionHandler.setOptions(n.interaction),this.renderer.setOptions(n.interaction),this.selectionHandler.setOptions(n.interaction),n.groups!==void 0&&this.body.emitter.emit("refreshNodes"),"configure"in n&&(this.configurator||(this.configurator=new Ks(this,this.body.container,En,this.canvas.pixelRatio,Na)),this.configurator.setOptions(n.configure)),this.configurator&&this.configurator.options.enabled===!0){let i={nodes:{},edges:{},layout:{},interaction:{},manipulation:{},physics:{},global:{}};j(i.nodes,this.nodesHandler.options),j(i.edges,this.edgesHandler.options),j(i.layout,this.layoutEngine.options),j(i.interaction,this.selectionHandler.options),j(i.interaction,this.renderer.options),j(i.interaction,this.interactionHandler.options),j(i.manipulation,this.manipulation.options),j(i.physics,this.physics.options),j(i.global,this.canvas.options),j(i.global,this.options),this.configurator.setModuleOptions(i)}n.clickToUse!==void 0?n.clickToUse===!0?this.activator===void 0&&(this.activator=new Gs(this.canvas.frame),this.activator.on("change",()=>{this.body.emitter.emit("activate")})):(this.activator!==void 0&&(this.activator.destroy(),delete this.activator),this.body.emitter.emit("activate")):this.body.emitter.emit("activate"),this.canvas.setSize(),this.body.emitter.emit("startSimulation")}};I.prototype._updateVisibleIndices=function(){let n=this.body.nodes,e=this.body.edges;this.body.nodeIndices=[],this.body.edgeIndices=[];for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&!this.clustering._isClusteredNode(t)&&n[t].options.hidden===!1&&this.body.nodeIndices.push(n[t].id);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let i=e[t],s=n[i.fromId],o=n[i.toId],r=s!==void 0&&o!==void 0;!this.clustering._isClusteredEdge(t)&&i.options.hidden===!1&&r&&s.options.hidden===!1&&o.options.hidden===!1&&this.body.edgeIndices.push(i.id)}};I.prototype.bindEventListeners=function(){this.body.emitter.on("_dataChanged",()=>{this.edgesHandler._updateState(),this.body.emitter.emit("_dataUpdated")}),this.body.emitter.on("_dataUpdated",()=>{this.clustering._updateState(),this._updateVisibleIndices(),this._updateValueRange(this.body.nodes),this._updateValueRange(this.body.edges),this.body.emitter.emit("startSimulation"),this.body.emitter.emit("_requestRedraw")})};I.prototype.setData=function(n){if(this.body.emitter.emit("resetPhysics"),this.body.emitter.emit("_resetData"),this.selectionHandler.unselectAll(),n&&n.dot&&(n.nodes||n.edges))throw new SyntaxError('Data must contain either parameter "dot" or parameter pair "nodes" and "edges", but not both.');if(this.setOptions(n&&n.options),n&&n.dot){console.warn("The dot property has been deprecated. Please use the static convertDot method to convert DOT into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertDot(dotString);");let e=na(n.dot);this.setData(e);return}else if(n&&n.gephi){console.warn("The gephi property has been deprecated. Please use the static convertGephi method to convert gephi into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertGephi(gephiJson);");let e=ra(n.gephi);this.setData(e);return}else this.nodesHandler.setData(n&&n.nodes,!0),this.edgesHandler.setData(n&&n.edges,!0);this.body.emitter.emit("_dataChanged"),this.body.emitter.emit("_dataLoaded"),this.body.emitter.emit("initPhysics")};I.prototype.destroy=function(){this.body.emitter.emit("destroy"),this.body.emitter.off(),this.off(),delete this.groups,delete this.canvas,delete this.selectionHandler,delete this.interactionHandler,delete this.view,delete this.renderer,delete this.physics,delete this.layoutEngine,delete this.clustering,delete this.manipulation,delete this.nodesHandler,delete this.edgesHandler,delete this.configurator,delete this.images;for(let n in this.body.nodes)!Object.prototype.hasOwnProperty.call(this.body.nodes,n)||delete this.body.nodes[n];for(let n in this.body.edges)!Object.prototype.hasOwnProperty.call(this.body.edges,n)||delete this.body.edges[n];we(this.body.container)};I.prototype._updateValueRange=function(n){let e,t,i,s=0;for(e in n)if(Object.prototype.hasOwnProperty.call(n,e)){let o=n[e].getValue();o!==void 0&&(t=t===void 0?o:Math.min(o,t),i=i===void 0?o:Math.max(o,i),s+=o)}if(t!==void 0&&i!==void 0)for(e in n)Object.prototype.hasOwnProperty.call(n,e)&&n[e].setValueRange(t,i,s)};I.prototype.isActive=function(){return!this.activator||this.activator.active};I.prototype.setSize=function(){return this.canvas.setSize.apply(this.canvas,arguments)};I.prototype.canvasToDOM=function(){return this.canvas.canvasToDOM.apply(this.canvas,arguments)};I.prototype.DOMtoCanvas=function(){return this.canvas.DOMtoCanvas.apply(this.canvas,arguments)};I.prototype.findNode=function(){return this.clustering.findNode.apply(this.clustering,arguments)};I.prototype.isCluster=function(){return this.clustering.isCluster.apply(this.clustering,arguments)};I.prototype.openCluster=function(){return this.clustering.openCluster.apply(this.clustering,arguments)};I.prototype.cluster=function(){return this.clustering.cluster.apply(this.clustering,arguments)};I.prototype.getNodesInCluster=function(){return this.clustering.getNodesInCluster.apply(this.clustering,arguments)};I.prototype.clusterByConnection=function(){return this.clustering.clusterByConnection.apply(this.clustering,arguments)};I.prototype.clusterByHubsize=function(){return this.clustering.clusterByHubsize.apply(this.clustering,arguments)};I.prototype.updateClusteredNode=function(){return this.clustering.updateClusteredNode.apply(this.clustering,arguments)};I.prototype.getClusteredEdges=function(){return this.clustering.getClusteredEdges.apply(this.clustering,arguments)};I.prototype.getBaseEdge=function(){return this.clustering.getBaseEdge.apply(this.clustering,arguments)};I.prototype.getBaseEdges=function(){return this.clustering.getBaseEdges.apply(this.clustering,arguments)};I.prototype.updateEdge=function(){return this.clustering.updateEdge.apply(this.clustering,arguments)};I.prototype.clusterOutliers=function(){return this.clustering.clusterOutliers.apply(this.clustering,arguments)};I.prototype.getSeed=function(){return this.layoutEngine.getSeed.apply(this.layoutEngine,arguments)};I.prototype.enableEditMode=function(){return this.manipulation.enableEditMode.apply(this.manipulation,arguments)};I.prototype.disableEditMode=function(){return this.manipulation.disableEditMode.apply(this.manipulation,arguments)};I.prototype.addNodeMode=function(){return this.manipulation.addNodeMode.apply(this.manipulation,arguments)};I.prototype.editNode=function(){return this.manipulation.editNode.apply(this.manipulation,arguments)};I.prototype.editNodeMode=function(){return console.warn("Deprecated: Please use editNode instead of editNodeMode."),this.manipulation.editNode.apply(this.manipulation,arguments)};I.prototype.addEdgeMode=function(){return this.manipulation.addEdgeMode.apply(this.manipulation,arguments)};I.prototype.editEdgeMode=function(){return this.manipulation.editEdgeMode.apply(this.manipulation,arguments)};I.prototype.deleteSelected=function(){return this.manipulation.deleteSelected.apply(this.manipulation,arguments)};I.prototype.getPositions=function(){return this.nodesHandler.getPositions.apply(this.nodesHandler,arguments)};I.prototype.getPosition=function(){return this.nodesHandler.getPosition.apply(this.nodesHandler,arguments)};I.prototype.storePositions=function(){return this.nodesHandler.storePositions.apply(this.nodesHandler,arguments)};I.prototype.moveNode=function(){return this.nodesHandler.moveNode.apply(this.nodesHandler,arguments)};I.prototype.getBoundingBox=function(){return this.nodesHandler.getBoundingBox.apply(this.nodesHandler,arguments)};I.prototype.getConnectedNodes=function(n){return this.body.nodes[n]!==void 0?this.nodesHandler.getConnectedNodes.apply(this.nodesHandler,arguments):this.edgesHandler.getConnectedNodes.apply(this.edgesHandler,arguments)};I.prototype.getConnectedEdges=function(){return this.nodesHandler.getConnectedEdges.apply(this.nodesHandler,arguments)};I.prototype.startSimulation=function(){return this.physics.startSimulation.apply(this.physics,arguments)};I.prototype.stopSimulation=function(){return this.physics.stopSimulation.apply(this.physics,arguments)};I.prototype.stabilize=function(){return this.physics.stabilize.apply(this.physics,arguments)};I.prototype.getSelection=function(){return this.selectionHandler.getSelection.apply(this.selectionHandler,arguments)};I.prototype.setSelection=function(){return this.selectionHandler.setSelection.apply(this.selectionHandler,arguments)};I.prototype.getSelectedNodes=function(){return this.selectionHandler.getSelectedNodeIds.apply(this.selectionHandler,arguments)};I.prototype.getSelectedEdges=function(){return this.selectionHandler.getSelectedEdgeIds.apply(this.selectionHandler,arguments)};I.prototype.getNodeAt=function(){let n=this.selectionHandler.getNodeAt.apply(this.selectionHandler,arguments);return n!==void 0&&n.id!==void 0?n.id:n};I.prototype.getEdgeAt=function(){let n=this.selectionHandler.getEdgeAt.apply(this.selectionHandler,arguments);return n!==void 0&&n.id!==void 0?n.id:n};I.prototype.selectNodes=function(){return this.selectionHandler.selectNodes.apply(this.selectionHandler,arguments)};I.prototype.selectEdges=function(){return this.selectionHandler.selectEdges.apply(this.selectionHandler,arguments)};I.prototype.unselectAll=function(){this.selectionHandler.unselectAll.apply(this.selectionHandler,arguments),this.selectionHandler.commitWithoutEmitting.apply(this.selectionHandler),this.redraw()};I.prototype.redraw=function(){return this.renderer.redraw.apply(this.renderer,arguments)};I.prototype.getScale=function(){return this.view.getScale.apply(this.view,arguments)};I.prototype.getViewPosition=function(){return this.view.getViewPosition.apply(this.view,arguments)};I.prototype.fit=function(){return this.view.fit.apply(this.view,arguments)};I.prototype.moveTo=function(){return this.view.moveTo.apply(this.view,arguments)};I.prototype.focus=function(){return this.view.focus.apply(this.view,arguments)};I.prototype.releaseNode=function(){return this.view.releaseNode.apply(this.view,arguments)};I.prototype.getOptionsFromConfigurator=function(){let n={};return this.configurator&&(n=this.configurator.getOptions.apply(this.configurator)),n};var Tn=n=>{if(!document.cookie)return;let e=null,t=document.cookie.split(";");for(let i=0;i<t.length;i++){let s=t[i].trim();if(s.substring(0,n.length+1)===n+"="){e=decodeURIComponent(s.substring(n.length+1));break}}return e};var qi={interaction:{hover:!0,hoverConnectedEdges:!0,multiselect:!0},nodes:{shape:"image",brokenImage:brokenImage!=null?brokenImage:"",size:35,font:{multi:"md",face:"helvetica",color:document.documentElement.dataset.netboxColorMode==="dark"?"#fff":"#000"}},edges:{length:100,width:2,font:{face:"helvetica"},shadow:{enabled:!0}},physics:{solver:"forceAtlas2Based"}},Ba=Tn("csrftoken"),Ge=null,kn=document.querySelector("#visgraph"),Sn=document.querySelector("#id_save_coords");(function(){if(!topologyData)return;function e(s){let o=document.createElement("div");return o.innerHTML=s,o}let t=new Te(topologyData.nodes.map(s=>Be(de({},s),{title:e(s.title)})));window.nodes=t;let i=new Te(topologyData.edges.map(s=>Be(de({},s),{title:e(s.title)})));Ge=new I(kn,{nodes:t,edges:i},qi),Ge.fit(),Ge.on("dragEnd",s=>{Sn!=null&&(!Sn.checked||Promise.allSettled(Object.entries(Ge.getPositions(s.nodes)).map(a=>Xi(this,[a],function*([o,r]){window.nodes.update({id:parseInt(o),physics:!1,x:r.x,y:r.y});let d=yield fetch("/"+basePath+"api/plugins/netbox_topology_views/save-coords/save_coords/",{method:"PATCH",headers:{"X-CSRFToken":Ba,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({node_id:o,x:r.x,y:r.y,group:topologyData.group})});console.log(o,d.status,d.statusText)}))))}),Ge.on("doubleClick",s=>{s.nodes.length>0?s.nodes.forEach(o=>{window.open(t.get(o).href,"_blank")}):s.edges.forEach(o=>{window.open(i.get(o).href,"_blank")})})})();var Aa="image/png",za=document.querySelector("#btnDownloadImage");za.addEventListener("click",n=>{La()});function La(){let n=kn.querySelector("canvas"),e=document.createElement("a"),t=n.toDataURL(Aa);e.href=t,e.download="topology",document.body.appendChild(e),e.click(),document.body.removeChild(e)}var Ra=document.querySelector("#btnDownloadXml");Ra.addEventListener("click",n=>{Ha()});function Ha(){let n=document.createElement("a"),e="";if(typeof is_htmx!="undefined"){var t=window.location.href;let o="/sites/",r="/locations/";if(t.includes(o)){var i=t.split(o)[1];i=i.split("/")[0],e="site_id="+i+"&show_cables=on&show_unconnected=on"}else if(t.includes(r)){var s=t.split(r)[1];s=s.split("/")[0],e="location_id="+s+"&show_cables=on&show_unconnected=on"}}else e=new URLSearchParams(window.location.search);fetch("/"+basePath+"api/plugins/netbox_topology_views/xml-export/?"+e).then(o=>o.text()).then(o=>{var r=new Blob([o],{type:"text/plain"});n.setAttribute("href",window.URL.createObjectURL(r)),n.setAttribute("download","topology.xml"),n.dataset.downloadurl=["text/plain",n.download,n.href].join(":"),n.click()})}var ja=new MutationObserver(n=>n.forEach(e=>{if(!Ge||e.type!=="attributes"||e.attributeName!=="data-netbox-color-mode"||!(e.target instanceof HTMLElement))return;let{netboxColorMode:t}=e.target.dataset;qi.nodes.font.color=t==="dark"?"#fff":"#000",Ge.setOptions(qi)}));ja.observe(document.documentElement,{attributes:!0,attributeFilter:["data-netbox-color-mode"]});})();
/*! Hammer.JS - v2.0.17-rc - 2019-12-16
* http://naver.github.io/egjs
*
* Forked By Naver egjs
* Copyright (c) hammerjs
* Licensed under the MIT license */
/**
* vis-data
* http://visjs.org/
*
* Manage unstructured data using DataSet. Add, update, and remove data, and listen for changes in the data.
*
* @version 7.1.6
* @date 2023-03-22T11:39:37.256Z
*
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
*
* @license
* vis.js is dual licensed under both
*
* 1. The Apache 2.0 License
* http://www.apache.org/licenses/LICENSE-2.0
*
* and
*
* 2. The MIT License
* http://opensource.org/licenses/MIT
*
* vis.js may be distributed under either license.
*/
/**
* vis-network
* https://visjs.github.io/vis-network/
*
* A dynamic, browser-based visualization library.
*
* @version 9.1.6
* @date 2023-03-23T21:31:19.223Z
*
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
*
* @license
* vis.js is dual licensed under both
*
* 1. The Apache 2.0 License
* http://www.apache.org/licenses/LICENSE-2.0
*
* and
*
* 2. The MIT License
* http://opensource.org/licenses/MIT
*
* vis.js may be distributed under either license.
*/
/**
* vis-util
* https://github.com/visjs/vis-util
*
* utilitie collection for visjs
*
* @version 5.0.3
* @date 2022-03-04T18:53:16.725Z
*
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
*
* @license
* vis.js is dual licensed under both
*
* 1. The Apache 2.0 License
* http://www.apache.org/licenses/LICENSE-2.0
*
* and
*
* 2. The MIT License
* http://opensource.org/licenses/MIT
*
* vis.js may be distributed under either license.
*/