From 9d4ef31bdd95ae9d4a81c23341441819f0a3fe2e Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 10 Mar 2026 09:34:45 +0100 Subject: [PATCH] Closes #701: Option to always show cable/interface labels on edges (#707) * Added draw termination labels --- netbox_topology_views/api/serializers.py | 2 +- netbox_topology_views/api/views.py | 6 ++- netbox_topology_views/forms.py | 18 ++++++- ...dividualoptions_draw_termination_labels.py | 18 +++++++ netbox_topology_views/models.py | 3 ++ .../static/netbox_topology_views/js/app.js | 12 ++--- netbox_topology_views/static_dev/js/home.js | 54 ++++++++++++++++++- .../static_dev/package-lock.json | 4 +- netbox_topology_views/utils.py | 7 ++- netbox_topology_views/views.py | 20 ++++++- 10 files changed, 127 insertions(+), 17 deletions(-) create mode 100644 netbox_topology_views/migrations/0012_individualoptions_draw_termination_labels.py diff --git a/netbox_topology_views/api/serializers.py b/netbox_topology_views/api/serializers.py index 27219a5..823f3c7 100644 --- a/netbox_topology_views/api/serializers.py +++ b/netbox_topology_views/api/serializers.py @@ -50,4 +50,4 @@ class PowerFeedCoordinateSerializer(NetBoxModelSerializer): class IndividualOptionsSerializer(NetBoxModelSerializer): class Meta: model = IndividualOptions - fields = ("ignore_cable_type", "save_coords", "show_unconnected", "show_cables", "show_logical_connections", "show_single_cable_logical_conns", "show_neighbors", "show_circuit", "show_power", "show_wireless", "group_sites", "group_locations", "group_racks", "group_virtualchassis", "draw_default_layout", "straight_cables", "grid_size", "node_label_items") + fields = ("ignore_cable_type", "save_coords", "show_unconnected", "show_cables", "show_logical_connections", "show_single_cable_logical_conns", "show_neighbors", "show_circuit", "show_power", "show_wireless", "group_sites", "group_locations", "group_racks", "group_virtualchassis", "draw_default_layout", "straight_cables", "draw_termination_labels", "grid_size", "node_label_items") diff --git a/netbox_topology_views/api/views.py b/netbox_topology_views/api/views.py index 0600bdd..d9a6841 100644 --- a/netbox_topology_views/api/views.py +++ b/netbox_topology_views/api/views.py @@ -114,7 +114,7 @@ class ExportTopoToXML(BaseViewSet, ViewSet): if request.GET: - filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, grid_size, node_label_items = get_query_settings(request) + filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, draw_termination_labels, grid_size, node_label_items = get_query_settings(request) # Read options from saved filters as NetBox does not handle custom plugin filters if "filter_id" in request.GET and request.GET["filter_id"] != '': @@ -136,7 +136,8 @@ class ExportTopoToXML(BaseViewSet, ViewSet): if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks'] if group_virtualchassis == False and 'group_virtualchassis' in saved_filter_params: group_virtualchassis = saved_filter_params['group_virtualchassis'] if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors'] - if straight_cables == False and 'straight_cables' in saved_filter_params: show_neighbors = saved_filter_params['straight_cables'] + if straight_cables == False and 'straight_cables' in saved_filter_params: straight_cables = saved_filter_params['straight_cables'] + if draw_termination_labels == False and 'draw_termination_labels' in saved_filter_params: draw_termination_labels = saved_filter_params['draw_termination_labels'] if grid_size == 0 and 'grid_size' in saved_filter_params: grid_size = saved_filter_params['grid_size'] if node_label_items == () and 'node_label_items' in saved_filter_params: node_label_items = saved_filter_params['node_label_items'] except SavedFilter.DoesNotExist: # filter_id not found @@ -170,6 +171,7 @@ class ExportTopoToXML(BaseViewSet, ViewSet): group_virtualchassis=group_virtualchassis, group_id=group_id, straight_cables=straight_cables, + draw_termination_labels=draw_termination_labels, grid_size=grid_size, node_label_items=node_label_items, ) diff --git a/netbox_topology_views/forms.py b/netbox_topology_views/forms.py index 315500b..0044397 100644 --- a/netbox_topology_views/forms.py +++ b/netbox_topology_views/forms.py @@ -37,7 +37,7 @@ class DeviceFilterForm( FieldSet( 'group', 'ignore_cable_type', 'save_coords', 'show_unconnected', 'show_cables', 'show_wireless', 'show_logical_connections', 'show_single_cable_logical_conns', 'show_neighbors', - 'group_sites', 'group_locations', 'group_racks', 'group_virtualchassis', 'straight_cables', 'grid_size', 'node_label_items', name=_("Options") + 'group_sites', 'group_locations', 'group_racks', 'group_virtualchassis', 'straight_cables', 'draw_termination_labels', 'grid_size', 'node_label_items', name=_("Options") ), FieldSet( 'show_circuit', 'show_power', name=_("Additional filter-independent types (non-devices)") @@ -318,6 +318,12 @@ class DeviceFilterForm( choices=BOOLEAN_WITH_BLANK_CHOICES ) ) + draw_termination_labels = forms.BooleanField( + label=_('Termination Labels'), required=False, initial=False, + widget=forms.Select( + choices=BOOLEAN_WITH_BLANK_CHOICES + ) + ) grid_size = forms.IntegerField( label=_('Grid Size'), required=False, @@ -538,6 +544,7 @@ class IndividualOptionsForm(NetBoxModelForm): 'group_virtualchassis', 'draw_default_layout', 'straight_cables', + 'draw_termination_labels', 'grid_size', 'node_label_items', ), @@ -672,6 +679,13 @@ class IndividualOptionsForm(NetBoxModelForm): help_text=_('Enable this option if you want to draw cables as straight lines ' 'instead of curves.') ) + draw_termination_labels = forms.BooleanField( + label=('Termination Labels'), + required=False, + initial=False, + help_text=_('Enable this option if you want to draw a label on each ' + 'cable end.') + ) grid_size = forms.IntegerField( label=_('Grid Size'), required=True, @@ -713,6 +727,6 @@ class IndividualOptionsForm(NetBoxModelForm): 'save_coords', 'show_unconnected', 'show_cables', 'show_wireless', 'show_logical_connections', 'show_single_cable_logical_conns', 'show_neighbors', 'group_sites', 'group_locations', 'group_racks', 'group_virtualchassis', - 'draw_default_layout', 'straight_cables', 'grid_size', 'node_label_items', + 'draw_default_layout', 'straight_cables', 'draw_termination_labels', 'grid_size', 'node_label_items', 'show_circuit', 'show_power' ] diff --git a/netbox_topology_views/migrations/0012_individualoptions_draw_termination_labels.py b/netbox_topology_views/migrations/0012_individualoptions_draw_termination_labels.py new file mode 100644 index 0000000..aadd37a --- /dev/null +++ b/netbox_topology_views/migrations/0012_individualoptions_draw_termination_labels.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.9 on 2026-02-19 18:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('netbox_topology_views', '0011_individualoptions_node_label_items'), + ] + + operations = [ + migrations.AddField( + model_name='individualoptions', + name='draw_termination_labels', + field=models.BooleanField(default=False), + ), + ] diff --git a/netbox_topology_views/models.py b/netbox_topology_views/models.py index 68e7368..4d7be19 100644 --- a/netbox_topology_views/models.py +++ b/netbox_topology_views/models.py @@ -405,6 +405,9 @@ class IndividualOptions(NetBoxModel): straight_cables = models.BooleanField( default=False ) + draw_termination_labels = models.BooleanField( + default=False + ) grid_size = models.PositiveSmallIntegerField( default=0 ) diff --git a/netbox_topology_views/static/netbox_topology_views/js/app.js b/netbox_topology_views/static/netbox_topology_views/js/app.js index 9bea476..d3eef1a 100644 --- a/netbox_topology_views/static/netbox_topology_views/js/app.js +++ b/netbox_topology_views/static/netbox_topology_views/js/app.js @@ -1,8 +1,8 @@ -(()=>{var Tn=Object.create;var ci=Object.defineProperty,Cn=Object.defineProperties,kn=Object.getOwnPropertyDescriptor,On=Object.getOwnPropertyDescriptors,Sn=Object.getOwnPropertyNames,Vs=Object.getOwnPropertySymbols,In=Object.getPrototypeOf,qs=Object.prototype.hasOwnProperty,Pn=Object.prototype.propertyIsEnumerable;var li=(r,e,t)=>e in r?ci(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,be=(r,e)=>{for(var t in e||(e={}))qs.call(e,t)&&li(r,t,e[t]);if(Vs)for(var t of Vs(e))Pn.call(e,t)&&li(r,t,e[t]);return r},je=(r,e)=>Cn(r,On(e));var Mn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Dn=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Sn(e))!qs.call(r,o)&&o!==t&&ci(r,o,{get:()=>e[o],enumerable:!(s=kn(e,o))||s.enumerable});return r};var Ys=(r,e,t)=>(t=r!=null?Tn(In(r)):{},Dn(e||!r||!r.__esModule?ci(t,"default",{value:r,enumerable:!0}):t,r));var se=(r,e,t)=>li(r,typeof e!="symbol"?e+"":e,t);var Us=(r,e,t)=>new Promise((s,o)=>{var n=h=>{try{d(t.next(h))}catch(l){o(l)}},a=h=>{try{d(t.throw(h))}catch(l){o(l)}},d=h=>h.done?s(h.value):Promise.resolve(h.value).then(n,a);d((t=t.apply(r,e)).next())});var fi=Mn((ja,ui)=>{typeof ui!="undefined"&&(ui.exports=ce);function ce(r){if(r)return Nn(r)}function Nn(r){for(var e in ce.prototype)r[e]=ce.prototype[e];return r}ce.prototype.on=ce.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};ce.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};ce.prototype.off=ce.prototype.removeListener=ce.prototype.removeAllListeners=ce.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var s,o=0;o-1}function Vn(r){if(We(r,Ve))return Ve;var e=We(r,ct),t=We(r,ut);return e&&t?Ve:e||t?e?ct:ut:We(r,gi)?gi:ao}var uo=function(){function r(t,s){this.manager=t,this.set(s)}var e=r.prototype;return e.set=function(s){s===ro&&(s=this.compute()),no&&this.manager.element.style&&Mt[s]&&(this.manager.element.style[oo]=s),this.actions=s.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var s=[];return Oe(this.manager.recognizers,function(o){Rt(o.options.enable,[o])&&(s=s.concat(o.getTouchAction()))}),Vn(s.join(" "))},e.preventDefaults=function(s){var o=s.srcEvent,n=s.offsetDirection;if(this.manager.session.prevented){o.preventDefault();return}var a=this.actions,d=We(a,Ve)&&!Mt[Ve],h=We(a,ut)&&!Mt[ut],l=We(a,ct)&&!Mt[ct];if(d){var c=s.pointers.length===1,u=s.distance<2,f=s.deltaTime<250;if(c&&u&&f)return}if(!(l&&h)&&(d||h&&n&Ee||l&&n&qe))return this.preventSrc(o)},e.preventSrc=function(s){this.manager.session.prevented=!0,s.preventDefault()},r}();function wi(r,e){for(;r;){if(r===e)return!0;r=r.parentNode}return!1}function fo(r){var e=r.length;if(e===1)return{x:Je(r[0].clientX),y:Je(r[0].clientY)};for(var t=0,s=0,o=0;o=Ue(e)?r<0?yt:bt:e<0?vt:tt}function qn(r,e){var t=e.center,s=r.offsetDelta||{},o=r.prevDelta||{},n=r.prevInput||{};(e.eventType===oe||n.eventType===Q)&&(o=r.prevDelta={x:n.deltaX||0,y:n.deltaY||0},s=r.offsetDelta={x:t.x,y:t.y}),e.deltaX=o.x+(t.x-s.x),e.deltaY=o.y+(t.y-s.y)}function go(r,e,t){return{x:e/r||0,y:t/r||0}}function Yn(r,e){return At(e[0],e[1],Bt)/At(r[0],r[1],Bt)}function Un(r,e){return mi(e[1],e[0],Bt)+mi(r[1],r[0],Bt)}function Xn(r,e){var t=r.lastInterval||e,s=e.timeStamp-t.timeStamp,o,n,a,d;if(e.eventType!==de&&(s>Wn||t.velocity===void 0)){var h=e.deltaX-t.deltaX,l=e.deltaY-t.deltaY,c=go(s,h,l);n=c.x,a=c.y,o=Ue(c.x)>Ue(c.y)?c.x:c.y,d=po(h,l),r.lastInterval=e}else o=t.velocity,n=t.velocityX,a=t.velocityY,d=t.direction;e.velocity=o,e.velocityX=n,e.velocityY=a,e.direction=d}function Gn(r,e){var t=r.session,s=e.pointers,o=s.length;t.firstInput||(t.firstInput=Gs(e)),o>1&&!t.firstMultiple?t.firstMultiple=Gs(e):o===1&&(t.firstMultiple=!1);var n=t.firstInput,a=t.firstMultiple,d=a?a.center:n.center,h=e.center=fo(s);e.timeStamp=bi(),e.deltaTime=e.timeStamp-n.timeStamp,e.angle=mi(d,h),e.distance=At(d,h),qn(t,e),e.offsetDirection=po(e.deltaX,e.deltaY);var l=go(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=l.x,e.overallVelocityY=l.y,e.overallVelocity=Ue(l.x)>Ue(l.y)?l.x:l.y,e.scale=a?Yn(a.pointers,s):1,e.rotation=a?Un(a.pointers,s):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length,Xn(t,e);var c=r.element,u=e.srcEvent,f;u.composedPath?f=u.composedPath()[0]:u.path?f=u.path[0]:f=u.target,wi(f,c)&&(c=f),e.target=c}function Kn(r,e,t){var s=t.pointers.length,o=t.changedPointers.length,n=e&oe&&s-o===0,a=e&(Q|de)&&s-o===0;t.isFirst=!!n,t.isFinal=!!a,n&&(r.session={}),t.eventType=e,Gn(r,t),r.emit("hammer.input",t),r.recognize(t),r.session.prevInput=t}function ft(r){return r.trim().split(/\s+/g)}function ht(r,e,t){Oe(ft(e),function(s){r.addEventListener(s,t,!1)})}function lt(r,e,t){Oe(ft(e),function(s){r.removeEventListener(s,t,!1)})}function Ks(r){var e=r.ownerDocument||r;return e.defaultView||e.parentWindow||window}var ot=function(){function r(t,s){var o=this;this.manager=t,this.callback=s,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(n){Rt(t.options.enable,[t])&&o.handler(n)},this.init()}var e=r.prototype;return e.handler=function(){},e.init=function(){this.evEl&&ht(this.element,this.evEl,this.domHandler),this.evTarget&&ht(this.target,this.evTarget,this.domHandler),this.evWin&&ht(Ks(this.element),this.evWin,this.domHandler)},e.destroy=function(){this.evEl&<(this.element,this.evEl,this.domHandler),this.evTarget&<(this.target,this.evTarget,this.domHandler),this.evWin&<(Ks(this.element),this.evWin,this.domHandler)},r}();function Xe(r,e,t){if(r.indexOf&&!t)return r.indexOf(e);for(var s=0;sh[e]}):s=s.sort()),s}var Qn={touchstart:oe,touchmove:Ge,touchend:Q,touchcancel:de},Jn="touchstart touchmove touchend touchcancel",Ei=function(r){me(e,r);function e(){var s;return e.prototype.evTarget=Jn,s=r.apply(this,arguments)||this,s.targetIds={},s}var t=e.prototype;return t.handler=function(o){var n=Qn[o.type],a=er.call(this,o,n);a&&this.callback(this.manager,n,{pointers:a[0],changedPointers:a[1],pointerType:mt,srcEvent:o})},e}(ot);function er(r,e){var t=pt(r.touches),s=this.targetIds;if(e&(oe|Ge)&&t.length===1)return s[t[0].identifier]=!0,[t,t];var o,n,a=pt(r.changedTouches),d=[],h=this.target;if(n=t.filter(function(l){return wi(l.target,h)}),e===oe)for(o=0;o-1&&o.splice(d,1)};setTimeout(n,or)}}function nr(r,e){r&oe?(this.primaryTouch=e.changedPointers[0].identifier,Zs.call(this,e)):r&(Q|de)&&Zs.call(this,e)}function rr(r){for(var e=r.srcEvent.clientX,t=r.srcEvent.clientY,s=0;s-1&&this.requireFail.splice(o,1),this},e.hasRequireFailures=function(){return this.requireFail.length>0},e.canRecognizeWith=function(s){return!!this.simultaneous[s.id]},e.emit=function(s){var o=this,n=this.state;function a(d){o.manager.emit(d,s)}n=Be&&a(o.options.event+Qs(n))},e.tryEmit=function(s){if(this.canEmit())return this.emit(s);this.state=_e},e.canEmit=function(){for(var s=0;sn.threshold&&h&n.direction},t.attrTest=function(o){return st.prototype.attrTest.call(this,o)&&(this.state&ge||!(this.state&ge)&&this.directionTest(o))},t.emit=function(o){this.pX=o.deltaX,this.pY=o.deltaY;var n=wo(o.direction);n&&(o.additionalEvent=this.options.event+n),r.prototype.emit.call(this,o)},e}(st),_o=function(r){me(e,r);function e(s){return s===void 0&&(s={}),r.call(this,ve({event:"swipe",threshold:10,velocity:.3,direction:Ee|qe,pointers:1},s))||this}var t=e.prototype;return t.getTouchAction=function(){return Ti.prototype.getTouchAction.call(this)},t.attrTest=function(o){var n=this.options.direction,a;return n&(Ee|qe)?a=o.overallVelocity:n&Ee?a=o.overallVelocityX:n&qe&&(a=o.overallVelocityY),r.prototype.attrTest.call(this,o)&&n&o.offsetDirection&&o.distance>this.options.threshold&&o.maxPointers===this.options.pointers&&Ue(a)>this.options.velocity&&o.eventType&Q},t.emit=function(o){var n=wo(o.offsetDirection);n&&this.manager.emit(this.options.event+n,o),this.manager.emit(this.options.event,o)},e}(st),Eo=function(r){me(e,r);function e(s){return s===void 0&&(s={}),r.call(this,ve({event:"pinch",threshold:0,pointers:2},s))||this}var t=e.prototype;return t.getTouchAction=function(){return[Ve]},t.attrTest=function(o){return r.prototype.attrTest.call(this,o)&&(Math.abs(o.scale-1)>this.options.threshold||this.state&ge)},t.emit=function(o){if(o.scale!==1){var n=o.scale<1?"in":"out";o.additionalEvent=this.options.event+n}r.prototype.emit.call(this,o)},e}(st),xo=function(r){me(e,r);function e(s){return s===void 0&&(s={}),r.call(this,ve({event:"rotate",threshold:0,pointers:2},s))||this}var t=e.prototype;return t.getTouchAction=function(){return[Ve]},t.attrTest=function(o){return r.prototype.attrTest.call(this,o)&&(Math.abs(o.rotation)>this.options.threshold||this.state&ge)},e}(st),To=function(r){me(e,r);function e(s){var o;return s===void 0&&(s={}),o=r.call(this,ve({event:"press",pointers:1,time:251,threshold:9},s))||this,o._timer=null,o._input=null,o}var t=e.prototype;return t.getTouchAction=function(){return[ao]},t.process=function(o){var n=this,a=this.options,d=o.pointers.length===a.pointers,h=o.distancea.time;if(this._input=o,!h||!d||o.eventType&(Q|de)&&!l)this.reset();else if(o.eventType&oe)this.reset(),this._timer=setTimeout(function(){n.state=Se,n.tryEmit()},a.time);else if(o.eventType&Q)return Se;return _e},t.reset=function(){clearTimeout(this._timer)},t.emit=function(o){this.state===Se&&(o&&o.eventType&Q?this.manager.emit(this.options.event+"up",o):(this._input.timeStamp=bi(),this.manager.emit(this.options.event,this._input)))},e}(wt),Co={domEvents:!1,touchAction:ro,enable:!0,inputTarget:null,inputClass:null,cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Js=[[xo,{enable:!1}],[Eo,{enable:!1},["rotate"]],[_o,{direction:Ee}],[Ti,{direction:Ee},["swipe"]],[yi],[yi,{event:"doubletap",taps:2},["tap"]],[To]],lr=1,eo=2;function to(r,e){var t=r.element;if(t.style){var s;Oe(r.options.cssProps,function(o,n){s=zt(t.style,n),e?(r.oldCssProps[s]=t.style[s],t.style[s]=o):t.style[s]=r.oldCssProps[s]||""}),e||(r.oldCssProps={})}}function cr(r,e){var t=document.createEvent("Event");t.initEvent(r,!0,!0),t.gesture=e,e.target.dispatchEvent(t)}var io=function(){function r(t,s){var o=this;this.options=Ye({},Co,s||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=ar(this),this.touchAction=new uo(this,this.options.touchAction),to(this,!0),Oe(this.options.recognizers,function(n){var a=o.add(new n[0](n[1]));n[2]&&a.recognizeWith(n[2]),n[3]&&a.requireFailure(n[3])},this)}var e=r.prototype;return e.set=function(s){return Ye(this.options,s),s.touchAction&&this.touchAction.update(),s.inputTarget&&(this.input.destroy(),this.input.target=s.inputTarget,this.input.init()),this},e.stop=function(s){this.session.stopped=s?eo:lr},e.recognize=function(s){var o=this.session;if(!o.stopped){this.touchAction.preventDefaults(s);var n,a=this.recognizers,d=o.curRecognizer;(!d||d&&d.state&Se)&&(o.curRecognizer=null,d=null);for(var h=0;h{var Cn=Object.create;var ci=Object.defineProperty,kn=Object.defineProperties,On=Object.getOwnPropertyDescriptor,Sn=Object.getOwnPropertyDescriptors,In=Object.getOwnPropertyNames,Vs=Object.getOwnPropertySymbols,Pn=Object.getPrototypeOf,qs=Object.prototype.hasOwnProperty,Mn=Object.prototype.propertyIsEnumerable;var li=(r,e,t)=>e in r?ci(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ge=(r,e)=>{for(var t in e||(e={}))qs.call(e,t)&&li(r,t,e[t]);if(Vs)for(var t of Vs(e))Mn.call(e,t)&&li(r,t,e[t]);return r},je=(r,e)=>kn(r,Sn(e));var Dn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Nn=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of In(e))!qs.call(r,o)&&o!==t&&ci(r,o,{get:()=>e[o],enumerable:!(s=On(e,o))||s.enumerable});return r};var Ys=(r,e,t)=>(t=r!=null?Cn(Pn(r)):{},Nn(e||!r||!r.__esModule?ci(t,"default",{value:r,enumerable:!0}):t,r));var se=(r,e,t)=>li(r,typeof e!="symbol"?e+"":e,t);var Xs=(r,e,t)=>new Promise((s,o)=>{var n=h=>{try{d(t.next(h))}catch(l){o(l)}},a=h=>{try{d(t.throw(h))}catch(l){o(l)}},d=h=>h.done?s(h.value):Promise.resolve(h.value).then(n,a);d((t=t.apply(r,e)).next())});var fi=Dn((Wa,ui)=>{typeof ui!="undefined"&&(ui.exports=ce);function ce(r){if(r)return Fn(r)}function Fn(r){for(var e in ce.prototype)r[e]=ce.prototype[e];return r}ce.prototype.on=ce.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};ce.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};ce.prototype.off=ce.prototype.removeListener=ce.prototype.removeAllListeners=ce.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var s,o=0;o-1}function qn(r){if(We(r,Ve))return Ve;var e=We(r,ct),t=We(r,ut);return e&&t?Ve:e||t?e?ct:ut:We(r,gi)?gi:ao}var uo=function(){function r(t,s){this.manager=t,this.set(s)}var e=r.prototype;return e.set=function(s){s===ro&&(s=this.compute()),no&&this.manager.element.style&&Mt[s]&&(this.manager.element.style[oo]=s),this.actions=s.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var s=[];return Oe(this.manager.recognizers,function(o){Rt(o.options.enable,[o])&&(s=s.concat(o.getTouchAction()))}),qn(s.join(" "))},e.preventDefaults=function(s){var o=s.srcEvent,n=s.offsetDirection;if(this.manager.session.prevented){o.preventDefault();return}var a=this.actions,d=We(a,Ve)&&!Mt[Ve],h=We(a,ut)&&!Mt[ut],l=We(a,ct)&&!Mt[ct];if(d){var c=s.pointers.length===1,u=s.distance<2,f=s.deltaTime<250;if(c&&u&&f)return}if(!(l&&h)&&(d||h&&n&Ee||l&&n&qe))return this.preventSrc(o)},e.preventSrc=function(s){this.manager.session.prevented=!0,s.preventDefault()},r}();function wi(r,e){for(;r;){if(r===e)return!0;r=r.parentNode}return!1}function fo(r){var e=r.length;if(e===1)return{x:Je(r[0].clientX),y:Je(r[0].clientY)};for(var t=0,s=0,o=0;o=Xe(e)?r<0?yt:bt:e<0?vt:tt}function Yn(r,e){var t=e.center,s=r.offsetDelta||{},o=r.prevDelta||{},n=r.prevInput||{};(e.eventType===oe||n.eventType===Q)&&(o=r.prevDelta={x:n.deltaX||0,y:n.deltaY||0},s=r.offsetDelta={x:t.x,y:t.y}),e.deltaX=o.x+(t.x-s.x),e.deltaY=o.y+(t.y-s.y)}function go(r,e,t){return{x:e/r||0,y:t/r||0}}function Xn(r,e){return At(e[0],e[1],Bt)/At(r[0],r[1],Bt)}function Un(r,e){return mi(e[1],e[0],Bt)+mi(r[1],r[0],Bt)}function Gn(r,e){var t=r.lastInterval||e,s=e.timeStamp-t.timeStamp,o,n,a,d;if(e.eventType!==de&&(s>Vn||t.velocity===void 0)){var h=e.deltaX-t.deltaX,l=e.deltaY-t.deltaY,c=go(s,h,l);n=c.x,a=c.y,o=Xe(c.x)>Xe(c.y)?c.x:c.y,d=po(h,l),r.lastInterval=e}else o=t.velocity,n=t.velocityX,a=t.velocityY,d=t.direction;e.velocity=o,e.velocityX=n,e.velocityY=a,e.direction=d}function Kn(r,e){var t=r.session,s=e.pointers,o=s.length;t.firstInput||(t.firstInput=Gs(e)),o>1&&!t.firstMultiple?t.firstMultiple=Gs(e):o===1&&(t.firstMultiple=!1);var n=t.firstInput,a=t.firstMultiple,d=a?a.center:n.center,h=e.center=fo(s);e.timeStamp=bi(),e.deltaTime=e.timeStamp-n.timeStamp,e.angle=mi(d,h),e.distance=At(d,h),Yn(t,e),e.offsetDirection=po(e.deltaX,e.deltaY);var l=go(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=l.x,e.overallVelocityY=l.y,e.overallVelocity=Xe(l.x)>Xe(l.y)?l.x:l.y,e.scale=a?Xn(a.pointers,s):1,e.rotation=a?Un(a.pointers,s):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length,Gn(t,e);var c=r.element,u=e.srcEvent,f;u.composedPath?f=u.composedPath()[0]:u.path?f=u.path[0]:f=u.target,wi(f,c)&&(c=f),e.target=c}function $n(r,e,t){var s=t.pointers.length,o=t.changedPointers.length,n=e&oe&&s-o===0,a=e&(Q|de)&&s-o===0;t.isFirst=!!n,t.isFinal=!!a,n&&(r.session={}),t.eventType=e,Kn(r,t),r.emit("hammer.input",t),r.recognize(t),r.session.prevInput=t}function ft(r){return r.trim().split(/\s+/g)}function ht(r,e,t){Oe(ft(e),function(s){r.addEventListener(s,t,!1)})}function lt(r,e,t){Oe(ft(e),function(s){r.removeEventListener(s,t,!1)})}function Ks(r){var e=r.ownerDocument||r;return e.defaultView||e.parentWindow||window}var ot=function(){function r(t,s){var o=this;this.manager=t,this.callback=s,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(n){Rt(t.options.enable,[t])&&o.handler(n)},this.init()}var e=r.prototype;return e.handler=function(){},e.init=function(){this.evEl&&ht(this.element,this.evEl,this.domHandler),this.evTarget&&ht(this.target,this.evTarget,this.domHandler),this.evWin&&ht(Ks(this.element),this.evWin,this.domHandler)},e.destroy=function(){this.evEl&<(this.element,this.evEl,this.domHandler),this.evTarget&<(this.target,this.evTarget,this.domHandler),this.evWin&<(Ks(this.element),this.evWin,this.domHandler)},r}();function Ue(r,e,t){if(r.indexOf&&!t)return r.indexOf(e);for(var s=0;sh[e]}):s=s.sort()),s}var Jn={touchstart:oe,touchmove:Ge,touchend:Q,touchcancel:de},er="touchstart touchmove touchend touchcancel",Ei=function(r){ye(e,r);function e(){var s;return e.prototype.evTarget=er,s=r.apply(this,arguments)||this,s.targetIds={},s}var t=e.prototype;return t.handler=function(o){var n=Jn[o.type],a=tr.call(this,o,n);a&&this.callback(this.manager,n,{pointers:a[0],changedPointers:a[1],pointerType:mt,srcEvent:o})},e}(ot);function tr(r,e){var t=pt(r.touches),s=this.targetIds;if(e&(oe|Ge)&&t.length===1)return s[t[0].identifier]=!0,[t,t];var o,n,a=pt(r.changedTouches),d=[],h=this.target;if(n=t.filter(function(l){return wi(l.target,h)}),e===oe)for(o=0;o-1&&o.splice(d,1)};setTimeout(n,nr)}}function rr(r,e){r&oe?(this.primaryTouch=e.changedPointers[0].identifier,Zs.call(this,e)):r&(Q|de)&&Zs.call(this,e)}function ar(r){for(var e=r.srcEvent.clientX,t=r.srcEvent.clientY,s=0;s-1&&this.requireFail.splice(o,1),this},e.hasRequireFailures=function(){return this.requireFail.length>0},e.canRecognizeWith=function(s){return!!this.simultaneous[s.id]},e.emit=function(s){var o=this,n=this.state;function a(d){o.manager.emit(d,s)}n=Be&&a(o.options.event+Qs(n))},e.tryEmit=function(s){if(this.canEmit())return this.emit(s);this.state=_e},e.canEmit=function(){for(var s=0;sn.threshold&&h&n.direction},t.attrTest=function(o){return st.prototype.attrTest.call(this,o)&&(this.state&me||!(this.state&me)&&this.directionTest(o))},t.emit=function(o){this.pX=o.deltaX,this.pY=o.deltaY;var n=wo(o.direction);n&&(o.additionalEvent=this.options.event+n),r.prototype.emit.call(this,o)},e}(st),_o=function(r){ye(e,r);function e(s){return s===void 0&&(s={}),r.call(this,ve({event:"swipe",threshold:10,velocity:.3,direction:Ee|qe,pointers:1},s))||this}var t=e.prototype;return t.getTouchAction=function(){return Ti.prototype.getTouchAction.call(this)},t.attrTest=function(o){var n=this.options.direction,a;return n&(Ee|qe)?a=o.overallVelocity:n&Ee?a=o.overallVelocityX:n&qe&&(a=o.overallVelocityY),r.prototype.attrTest.call(this,o)&&n&o.offsetDirection&&o.distance>this.options.threshold&&o.maxPointers===this.options.pointers&&Xe(a)>this.options.velocity&&o.eventType&Q},t.emit=function(o){var n=wo(o.offsetDirection);n&&this.manager.emit(this.options.event+n,o),this.manager.emit(this.options.event,o)},e}(st),Eo=function(r){ye(e,r);function e(s){return s===void 0&&(s={}),r.call(this,ve({event:"pinch",threshold:0,pointers:2},s))||this}var t=e.prototype;return t.getTouchAction=function(){return[Ve]},t.attrTest=function(o){return r.prototype.attrTest.call(this,o)&&(Math.abs(o.scale-1)>this.options.threshold||this.state&me)},t.emit=function(o){if(o.scale!==1){var n=o.scale<1?"in":"out";o.additionalEvent=this.options.event+n}r.prototype.emit.call(this,o)},e}(st),xo=function(r){ye(e,r);function e(s){return s===void 0&&(s={}),r.call(this,ve({event:"rotate",threshold:0,pointers:2},s))||this}var t=e.prototype;return t.getTouchAction=function(){return[Ve]},t.attrTest=function(o){return r.prototype.attrTest.call(this,o)&&(Math.abs(o.rotation)>this.options.threshold||this.state&me)},e}(st),To=function(r){ye(e,r);function e(s){var o;return s===void 0&&(s={}),o=r.call(this,ve({event:"press",pointers:1,time:251,threshold:9},s))||this,o._timer=null,o._input=null,o}var t=e.prototype;return t.getTouchAction=function(){return[ao]},t.process=function(o){var n=this,a=this.options,d=o.pointers.length===a.pointers,h=o.distancea.time;if(this._input=o,!h||!d||o.eventType&(Q|de)&&!l)this.reset();else if(o.eventType&oe)this.reset(),this._timer=setTimeout(function(){n.state=Se,n.tryEmit()},a.time);else if(o.eventType&Q)return Se;return _e},t.reset=function(){clearTimeout(this._timer)},t.emit=function(o){this.state===Se&&(o&&o.eventType&Q?this.manager.emit(this.options.event+"up",o):(this._input.timeStamp=bi(),this.manager.emit(this.options.event,this._input)))},e}(wt),Co={domEvents:!1,touchAction:ro,enable:!0,inputTarget:null,inputClass:null,cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Js=[[xo,{enable:!1}],[Eo,{enable:!1},["rotate"]],[_o,{direction:Ee}],[Ti,{direction:Ee},["swipe"]],[yi],[yi,{event:"doubletap",taps:2},["tap"]],[To]],cr=1,eo=2;function to(r,e){var t=r.element;if(t.style){var s;Oe(r.options.cssProps,function(o,n){s=zt(t.style,n),e?(r.oldCssProps[s]=t.style[s],t.style[s]=o):t.style[s]=r.oldCssProps[s]||""}),e||(r.oldCssProps={})}}function ur(r,e){var t=document.createEvent("Event");t.initEvent(r,!0,!0),t.gesture=e,e.target.dispatchEvent(t)}var io=function(){function r(t,s){var o=this;this.options=Ye({},Co,s||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=dr(this),this.touchAction=new uo(this,this.options.touchAction),to(this,!0),Oe(this.options.recognizers,function(n){var a=o.add(new n[0](n[1]));n[2]&&a.recognizeWith(n[2]),n[3]&&a.requireFailure(n[3])},this)}var e=r.prototype;return e.set=function(s){return Ye(this.options,s),s.touchAction&&this.touchAction.update(),s.inputTarget&&(this.input.destroy(),this.input.target=s.inputTarget,this.input.init()),this},e.stop=function(s){this.session.stopped=s?eo:cr},e.recognize=function(s){var o=this.session;if(!o.stopped){this.touchAction.preventDefaults(s);var n,a=this.recognizers,d=o.curRecognizer;(!d||d&&d.state&Se)&&(o.curRecognizer=null,d=null);for(var h=0;h\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",a=window.console&&(window.console.warn||window.console.log);return a&&a.call(window.console,s,n),r.apply(this,arguments)}}var Oo=ko(function(r,e,t){for(var s=Object.keys(e),o=0;o2)return Ht(Fo(r[0],r[1]),...r.slice(2));let e=r[0],t=r[1];if(e instanceof Date&&t instanceof Date)return e.setTime(t.getTime()),e;for(let s of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,s)&&(t[s]===Oi?delete e[s]:e[s]!==null&&t[s]!==null&&typeof e[s]=="object"&&typeof t[s]=="object"&&!Array.isArray(e[s])&&!Array.isArray(t[s])?e[s]=Ht(e[s],t[s]):e[s]=Bo(t[s]));return e}function Bo(r){return Array.isArray(r)?r.map(e=>Bo(e)):typeof r=="object"&&r!==null?r instanceof Date?new Date(r.getTime()):Ht({},r):r}function Ao(r){for(let e of Object.keys(r))r[e]===Oi?delete r[e]:typeof r[e]=="object"&&r[e]!==null&&Ao(r[e])}function xt(...r){return vr(r.length?r:[Date.now()])}function vr(r){let[e,t,s]=wr(r),o=1,n=()=>{let a=2091639*e+o*23283064365386963e-26;return e=t,t=s,s=a-(o=a|0)};return n.uint32=()=>n()*4294967296,n.fract53=()=>n()+(n()*2097152|0)*11102230246251565e-32,n.algorithm="Alea",n.seed=r,n.version="0.9",n}function wr(...r){let e=_r(),t=e(" "),s=e(" "),o=e(" ");for(let n=0;n>>0,o-=r,o*=r,r=o>>>0,o-=r,r+=o*4294967296}return(r>>>0)*23283064365386963e-26}}function Er(){let r=()=>{};return{on:r,off:r,destroy:r,emit:r,get(){return{set:r}}}}var Si=typeof window!="undefined"?window.Hammer||Io:function(){return Er()};function xe(r){this._cleanupQueue=[],this.active=!1,this._dom={container:r,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=Si(this._dom.overlay);e.on("tap",this._onTapOverlay.bind(this)),this._cleanupQueue.push(()=>{e.destroy()}),["tap","doubletap","press","pinch","pan","panstart","panmove","panend"].forEach(s=>{e.on(s,o=>{o.srcEvent.stopPropagation()})}),document&&document.body&&(this._onClick=s=>{xr(s.target,r)||this.deactivate()},document.body.addEventListener("click",this._onClick),this._cleanupQueue.push(()=>{document.body.removeEventListener("click",this._onClick)})),this._escListener=s=>{("key"in s?s.key==="Escape":s.keyCode===27)&&this.deactivate()}}(0,Do.default)(xe.prototype);xe.current=null;xe.prototype.destroy=function(){this.deactivate();for(let r of this._cleanupQueue.splice(0).reverse())r()};xe.prototype.activate=function(){xe.current&&xe.current.deactivate(),xe.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)};xe.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")};xe.prototype._onTapOverlay=function(r){this.activate(),r.srcEvent.stopPropagation()};function xr(r,e){for(;r;){if(r===e)return!0;r=r.parentNode}return!1}var Tr=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Cr=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,kr=/^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,Or=/^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 Pe(r){if(r)for(;r.hasChildNodes()===!0;){let e=r.firstChild;e&&(Pe(e),r.removeChild(e))}}function Ie(r){return r instanceof String||typeof r=="string"}function Po(r){return typeof r=="object"&&r!==null}function Ke(r,e,t,s){let o=!1;s===!0&&(o=e[t]===null&&r[t]!==void 0),o?delete r[t]:r[t]=e[t]}function Ii(r,e,t=!1){for(let s in r)if(e[s]!==void 0)if(e[s]===null||typeof e[s]!="object")Ke(r,e,s,t);else{let o=r[s],n=e[s];Po(o)&&Po(n)&&Ii(o,n,t)}}function $e(r,e,t,s=!1){if(Array.isArray(t))throw new TypeError("Arrays are not supported by deepExtend");for(let o=0;o{},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 Mr[e]}setColor(e,t=!0){if(e==="none")return;let s,o=this._isColorString(e);if(o!==void 0&&(e=o),Ie(e)===!0){if(jo(e)===!0){let n=e.substr(4).substr(0,e.length-5).split(",");s={r:n[0],g:n[1],b:n[2],a:1}}else if(Pr(e)===!0){let n=e.substr(5).substr(0,e.length-6).split(",");s={r:n[0],g:n[1],b:n[2],a:n[3]}}else if(Ho(e)===!0){let n=Pi(e);s={r:n.r,g:n.g,b:n.b,a:1}}}else if(e instanceof Object&&e.r!==void 0&&e.g!==void 0&&e.b!==void 0){let n=e.a!==void 0?e.a:"1.0";s={r:e.r,g:e.g,b:e.b,a:n}}if(s===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(s,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 s=Et(e.r,e.g,e.b),o=2*Math.PI,n=this.r*s.s,a=this.centerCoordinates.x+n*Math.sin(o*s.h),d=this.centerCoordinates.y+n*Math.cos(o*s.h);this.colorPickerSelector.style.left=a-.5*this.colorPickerSelector.clientWidth+"px",this.colorPickerSelector.style.top=d-.5*this.colorPickerSelector.clientHeight+"px",this._updatePicker(e)}_setOpacity(e){this.color.a=e/100,this._updatePicker(this.color)}_setBrightness(e){let t=Et(this.color.r,this.color.g,this.color.b);t.v=e/100;let s=Lt(t.h,t.s,t.v);s.a=this.color.a,this.color=s,this._updatePicker()}_updatePicker(e=this.color){let t=Et(e.r,e.g,e.b),s=this.colorPickerCanvas.getContext("2d");this.pixelRation===void 0&&(this.pixelRatio=(window.devicePixelRatio||1)/(s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1)),s.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);let o=this.colorPickerCanvas.clientWidth,n=this.colorPickerCanvas.clientHeight;s.clearRect(0,0,o,n),s.putImageData(this.hueCircle,0,0),s.fillStyle="rgba(0,0,0,"+(1-t.v)+")",s.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),s.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 Si(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,s=this.colorPickerCanvas.clientHeight;e.clearRect(0,0,t,s);let o,n,a,d;this.centerCoordinates={x:t*.5,y:s*.5},this.r=.49*t;let h=2*Math.PI/360,l=1/360,c=1/this.r,u;for(a=0;a<360;a++)for(d=0;d!1){this.parent=e,this.changedOptions=[],this.container=t,this.allowCreation=!1,this.hideOption=n,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=s,this.moduleOptions={},this.domElements=[],this.popupDiv={},this.popupLimit=5,this.popupHistory={},this.colorPicker=new Dr(o),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,s=!1;for(let o in this.configureOptions)Object.prototype.hasOwnProperty.call(this.configureOptions,o)&&(this.allowCreation=!1,s=!1,typeof e=="function"?(s=e(o,[]),s=s||this._handleObject(this.configureOptions[o],[o],!0)):(e===!0||e.indexOf(o)!==-1)&&(s=!0),s!==!1&&(this.allowCreation=!0,t>0&&this._makeItem([]),this._makeHeader(o),this._handleObject(this.configureOptions[o],[o])),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{s.appendChild(o)}),this.domElements.push(s),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,s=!1){let o=document.createElement("div");if(o.className="vis-configuration vis-config-label vis-config-s"+t.length,s===!0){for(;o.firstChild;)o.removeChild(o.firstChild);o.appendChild(Ci("i","b",e))}else o.innerText=e+":";return o}_makeDropdown(e,t,s){let o=document.createElement("select");o.className="vis-configuration vis-config-select";let n=0;t!==void 0&&e.indexOf(t)!==-1&&(n=e.indexOf(t));for(let h=0;ha&&a!==1&&(h.max=Math.ceil(t*1.2),c=h.max,l="range increased"),h.value=t):h.value=o;let u=document.createElement("input");u.className="vis-configuration vis-config-rangeinput",u.value=h.value;let f=this;h.onchange=function(){u.value=this.value,f._update(Number(this.value),s)},h.oninput=function(){u.value=this.value};let p=this._makeLabel(s[s.length-1],s),g=this._makeItem(s,p,h,u);l!==""&&this.popupHistory[g]!==c&&(this.popupHistory[g]=c,this._setupPopup(l,g))}_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._removePopup()},this.popupCounter+=1,this.popupDiv={html:s,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,s){let o=document.createElement("input");o.type="checkbox",o.className="vis-configuration vis-config-checkbox",o.checked=e,t!==void 0&&(o.checked=t,t!==e&&(typeof e=="object"?t!==e.enabled&&this.changedOptions.push({path:s,value:t}):this.changedOptions.push({path:s,value:t})));let n=this;o.onchange=function(){n._update(this.checked,s)};let a=this._makeLabel(s[s.length-1],s);this._makeItem(s,a,o)}_makeTextInput(e,t,s){let o=document.createElement("input");o.type="text",o.className="vis-configuration vis-config-text",o.value=t,t!==e&&this.changedOptions.push({path:s,value:t});let n=this;o.onchange=function(){n._update(this.value,s)};let a=this._makeLabel(s[s.length-1],s);this._makeItem(s,a,o)}_makeColorField(e,t,s){let o=e[1],n=document.createElement("div");t=t===void 0?o:t,t!=="none"?(n.className="vis-configuration vis-config-colorBlock",n.style.backgroundColor=t):n.className="vis-configuration vis-config-colorBlock none",t=t===void 0?o:t,n.onclick=()=>{this._showColorPicker(t,n,s)};let a=this._makeLabel(s[s.length-1],s);this._makeItem(s,a,n)}_showColorPicker(e,t,s){t.onclick=function(){},this.colorPicker.insertTo(t),this.colorPicker.show(),this.colorPicker.setColor(e),this.colorPicker.setUpdateCallback(o=>{let n="rgba("+o.r+","+o.g+","+o.b+","+o.a+")";t.style.backgroundColor=n,this._update(n,s)}),this.colorPicker.setCloseCallback(()=>{t.onclick=()=>{this._showColorPicker(e,t,s)}})}_handleObject(e,t=[],s=!1){let o=!1,n=this.options.filter,a=!1;for(let d in e)if(Object.prototype.hasOwnProperty.call(e,d)){o=!0;let h=e[d],l=jt(t,d);if(typeof n=="function"&&(o=n(d,t),o===!1&&!Array.isArray(h)&&typeof h!="string"&&typeof h!="boolean"&&h instanceof Object&&(this.allowCreation=!1,o=this._handleObject(h,l,!0),this.allowCreation=s===!1)),o!==!1){a=!0;let c=this._getValue(l);if(Array.isArray(h))this._handleArray(h,c,l);else if(typeof h=="string")this._makeTextInput(h,c,l);else if(typeof h=="boolean")this._makeCheckbox(h,c,l);else if(h instanceof Object){if(!this.hideOption(t,d,this.moduleOptions))if(h.enabled!==void 0){let u=jt(l,"enabled"),f=this._getValue(u);if(f===!0){let p=this._makeLabel(d,l,!0);this._makeItem(l,p),a=this._handleObject(h,l)||a}else this._makeCheckbox(h,f,l)}else{let u=this._makeLabel(d,l,!0);this._makeItem(l,u),a=this._handleObject(h,l)||a}}else console.error("dont know how to handle",h,d,l)}}return a}_handleArray(e,t,s){typeof e[0]=="string"&&e[0]==="color"?(this._makeColorField(e,t,s),e[1]!==t&&this.changedOptions.push({path:s,value:t})):typeof e[0]=="string"?(this._makeDropdown(e,t,s),e[0]!==t&&this.changedOptions.push({path:s,value:t})):typeof e[0]=="number"&&(this._makeRange(e,t,s),e[0]!==t&&this.changedOptions.push({path:s,value:Number(t)}))}_update(e,t){let s=this._constructOptions(e,t);this.parent.body&&this.parent.body.emitter&&this.parent.body.emitter.emit&&this.parent.body.emitter.emit("configChange",s),this.initialized=!0,this.parent.setOptions(s)}_constructOptions(e,t,s={}){let o=s;e=e==="true"?!0:e,e=e==="false"?!1:e;for(let n=0;nn-this.padding&&(h=!0),h?a=this.x-s:a=this.x,l?d=this.y-t:d=this.y}else d=this.y-t,d+t+this.padding>o&&(d=o-t-this.padding),dn&&(a=n-s-this.padding),a\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",a=window.console&&(window.console.warn||window.console.log);return a&&a.call(window.console,s,n),r.apply(this,arguments)}}var Oo=ko(function(r,e,t){for(var s=Object.keys(e),o=0;o2)return Ht(Fo(r[0],r[1]),...r.slice(2));let e=r[0],t=r[1];if(e instanceof Date&&t instanceof Date)return e.setTime(t.getTime()),e;for(let s of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,s)&&(t[s]===Oi?delete e[s]:e[s]!==null&&t[s]!==null&&typeof e[s]=="object"&&typeof t[s]=="object"&&!Array.isArray(e[s])&&!Array.isArray(t[s])?e[s]=Ht(e[s],t[s]):e[s]=Bo(t[s]));return e}function Bo(r){return Array.isArray(r)?r.map(e=>Bo(e)):typeof r=="object"&&r!==null?r instanceof Date?new Date(r.getTime()):Ht({},r):r}function Ao(r){for(let e of Object.keys(r))r[e]===Oi?delete r[e]:typeof r[e]=="object"&&r[e]!==null&&Ao(r[e])}function xt(...r){return wr(r.length?r:[Date.now()])}function wr(r){let[e,t,s]=_r(r),o=1,n=()=>{let a=2091639*e+o*23283064365386963e-26;return e=t,t=s,s=a-(o=a|0)};return n.uint32=()=>n()*4294967296,n.fract53=()=>n()+(n()*2097152|0)*11102230246251565e-32,n.algorithm="Alea",n.seed=r,n.version="0.9",n}function _r(...r){let e=Er(),t=e(" "),s=e(" "),o=e(" ");for(let n=0;n>>0,o-=r,o*=r,r=o>>>0,o-=r,r+=o*4294967296}return(r>>>0)*23283064365386963e-26}}function xr(){let r=()=>{};return{on:r,off:r,destroy:r,emit:r,get(){return{set:r}}}}var Si=typeof window!="undefined"?window.Hammer||Io:function(){return xr()};function xe(r){this._cleanupQueue=[],this.active=!1,this._dom={container:r,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=Si(this._dom.overlay);e.on("tap",this._onTapOverlay.bind(this)),this._cleanupQueue.push(()=>{e.destroy()}),["tap","doubletap","press","pinch","pan","panstart","panmove","panend"].forEach(s=>{e.on(s,o=>{o.srcEvent.stopPropagation()})}),document&&document.body&&(this._onClick=s=>{Tr(s.target,r)||this.deactivate()},document.body.addEventListener("click",this._onClick),this._cleanupQueue.push(()=>{document.body.removeEventListener("click",this._onClick)})),this._escListener=s=>{("key"in s?s.key==="Escape":s.keyCode===27)&&this.deactivate()}}(0,Do.default)(xe.prototype);xe.current=null;xe.prototype.destroy=function(){this.deactivate();for(let r of this._cleanupQueue.splice(0).reverse())r()};xe.prototype.activate=function(){xe.current&&xe.current.deactivate(),xe.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)};xe.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")};xe.prototype._onTapOverlay=function(r){this.activate(),r.srcEvent.stopPropagation()};function Tr(r,e){for(;r;){if(r===e)return!0;r=r.parentNode}return!1}var Cr=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,kr=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,Or=/^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,Sr=/^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 Pe(r){if(r)for(;r.hasChildNodes()===!0;){let e=r.firstChild;e&&(Pe(e),r.removeChild(e))}}function Ie(r){return r instanceof String||typeof r=="string"}function Po(r){return typeof r=="object"&&r!==null}function Ke(r,e,t,s){let o=!1;s===!0&&(o=e[t]===null&&r[t]!==void 0),o?delete r[t]:r[t]=e[t]}function Ii(r,e,t=!1){for(let s in r)if(e[s]!==void 0)if(e[s]===null||typeof e[s]!="object")Ke(r,e,s,t);else{let o=r[s],n=e[s];Po(o)&&Po(n)&&Ii(o,n,t)}}function $e(r,e,t,s=!1){if(Array.isArray(t))throw new TypeError("Arrays are not supported by deepExtend");for(let o=0;o{},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 Dr[e]}setColor(e,t=!0){if(e==="none")return;let s,o=this._isColorString(e);if(o!==void 0&&(e=o),Ie(e)===!0){if(jo(e)===!0){let n=e.substr(4).substr(0,e.length-5).split(",");s={r:n[0],g:n[1],b:n[2],a:1}}else if(Mr(e)===!0){let n=e.substr(5).substr(0,e.length-6).split(",");s={r:n[0],g:n[1],b:n[2],a:n[3]}}else if(Ho(e)===!0){let n=Pi(e);s={r:n.r,g:n.g,b:n.b,a:1}}}else if(e instanceof Object&&e.r!==void 0&&e.g!==void 0&&e.b!==void 0){let n=e.a!==void 0?e.a:"1.0";s={r:e.r,g:e.g,b:e.b,a:n}}if(s===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(s,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 s=Et(e.r,e.g,e.b),o=2*Math.PI,n=this.r*s.s,a=this.centerCoordinates.x+n*Math.sin(o*s.h),d=this.centerCoordinates.y+n*Math.cos(o*s.h);this.colorPickerSelector.style.left=a-.5*this.colorPickerSelector.clientWidth+"px",this.colorPickerSelector.style.top=d-.5*this.colorPickerSelector.clientHeight+"px",this._updatePicker(e)}_setOpacity(e){this.color.a=e/100,this._updatePicker(this.color)}_setBrightness(e){let t=Et(this.color.r,this.color.g,this.color.b);t.v=e/100;let s=Lt(t.h,t.s,t.v);s.a=this.color.a,this.color=s,this._updatePicker()}_updatePicker(e=this.color){let t=Et(e.r,e.g,e.b),s=this.colorPickerCanvas.getContext("2d");this.pixelRation===void 0&&(this.pixelRatio=(window.devicePixelRatio||1)/(s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1)),s.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);let o=this.colorPickerCanvas.clientWidth,n=this.colorPickerCanvas.clientHeight;s.clearRect(0,0,o,n),s.putImageData(this.hueCircle,0,0),s.fillStyle="rgba(0,0,0,"+(1-t.v)+")",s.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),s.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 Si(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,s=this.colorPickerCanvas.clientHeight;e.clearRect(0,0,t,s);let o,n,a,d;this.centerCoordinates={x:t*.5,y:s*.5},this.r=.49*t;let h=2*Math.PI/360,l=1/360,c=1/this.r,u;for(a=0;a<360;a++)for(d=0;d!1){this.parent=e,this.changedOptions=[],this.container=t,this.allowCreation=!1,this.hideOption=n,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=s,this.moduleOptions={},this.domElements=[],this.popupDiv={},this.popupLimit=5,this.popupHistory={},this.colorPicker=new Nr(o),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,s=!1;for(let o in this.configureOptions)Object.prototype.hasOwnProperty.call(this.configureOptions,o)&&(this.allowCreation=!1,s=!1,typeof e=="function"?(s=e(o,[]),s=s||this._handleObject(this.configureOptions[o],[o],!0)):(e===!0||e.indexOf(o)!==-1)&&(s=!0),s!==!1&&(this.allowCreation=!0,t>0&&this._makeItem([]),this._makeHeader(o),this._handleObject(this.configureOptions[o],[o])),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{s.appendChild(o)}),this.domElements.push(s),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,s=!1){let o=document.createElement("div");if(o.className="vis-configuration vis-config-label vis-config-s"+t.length,s===!0){for(;o.firstChild;)o.removeChild(o.firstChild);o.appendChild(Ci("i","b",e))}else o.innerText=e+":";return o}_makeDropdown(e,t,s){let o=document.createElement("select");o.className="vis-configuration vis-config-select";let n=0;t!==void 0&&e.indexOf(t)!==-1&&(n=e.indexOf(t));for(let h=0;ha&&a!==1&&(h.max=Math.ceil(t*1.2),c=h.max,l="range increased"),h.value=t):h.value=o;let u=document.createElement("input");u.className="vis-configuration vis-config-rangeinput",u.value=h.value;let f=this;h.onchange=function(){u.value=this.value,f._update(Number(this.value),s)},h.oninput=function(){u.value=this.value};let p=this._makeLabel(s[s.length-1],s),g=this._makeItem(s,p,h,u);l!==""&&this.popupHistory[g]!==c&&(this.popupHistory[g]=c,this._setupPopup(l,g))}_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._removePopup()},this.popupCounter+=1,this.popupDiv={html:s,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,s){let o=document.createElement("input");o.type="checkbox",o.className="vis-configuration vis-config-checkbox",o.checked=e,t!==void 0&&(o.checked=t,t!==e&&(typeof e=="object"?t!==e.enabled&&this.changedOptions.push({path:s,value:t}):this.changedOptions.push({path:s,value:t})));let n=this;o.onchange=function(){n._update(this.checked,s)};let a=this._makeLabel(s[s.length-1],s);this._makeItem(s,a,o)}_makeTextInput(e,t,s){let o=document.createElement("input");o.type="text",o.className="vis-configuration vis-config-text",o.value=t,t!==e&&this.changedOptions.push({path:s,value:t});let n=this;o.onchange=function(){n._update(this.value,s)};let a=this._makeLabel(s[s.length-1],s);this._makeItem(s,a,o)}_makeColorField(e,t,s){let o=e[1],n=document.createElement("div");t=t===void 0?o:t,t!=="none"?(n.className="vis-configuration vis-config-colorBlock",n.style.backgroundColor=t):n.className="vis-configuration vis-config-colorBlock none",t=t===void 0?o:t,n.onclick=()=>{this._showColorPicker(t,n,s)};let a=this._makeLabel(s[s.length-1],s);this._makeItem(s,a,n)}_showColorPicker(e,t,s){t.onclick=function(){},this.colorPicker.insertTo(t),this.colorPicker.show(),this.colorPicker.setColor(e),this.colorPicker.setUpdateCallback(o=>{let n="rgba("+o.r+","+o.g+","+o.b+","+o.a+")";t.style.backgroundColor=n,this._update(n,s)}),this.colorPicker.setCloseCallback(()=>{t.onclick=()=>{this._showColorPicker(e,t,s)}})}_handleObject(e,t=[],s=!1){let o=!1,n=this.options.filter,a=!1;for(let d in e)if(Object.prototype.hasOwnProperty.call(e,d)){o=!0;let h=e[d],l=jt(t,d);if(typeof n=="function"&&(o=n(d,t),o===!1&&!Array.isArray(h)&&typeof h!="string"&&typeof h!="boolean"&&h instanceof Object&&(this.allowCreation=!1,o=this._handleObject(h,l,!0),this.allowCreation=s===!1)),o!==!1){a=!0;let c=this._getValue(l);if(Array.isArray(h))this._handleArray(h,c,l);else if(typeof h=="string")this._makeTextInput(h,c,l);else if(typeof h=="boolean")this._makeCheckbox(h,c,l);else if(h instanceof Object){if(!this.hideOption(t,d,this.moduleOptions))if(h.enabled!==void 0){let u=jt(l,"enabled"),f=this._getValue(u);if(f===!0){let p=this._makeLabel(d,l,!0);this._makeItem(l,p),a=this._handleObject(h,l)||a}else this._makeCheckbox(h,f,l)}else{let u=this._makeLabel(d,l,!0);this._makeItem(l,u),a=this._handleObject(h,l)||a}}else console.error("dont know how to handle",h,d,l)}}return a}_handleArray(e,t,s){typeof e[0]=="string"&&e[0]==="color"?(this._makeColorField(e,t,s),e[1]!==t&&this.changedOptions.push({path:s,value:t})):typeof e[0]=="string"?(this._makeDropdown(e,t,s),e[0]!==t&&this.changedOptions.push({path:s,value:t})):typeof e[0]=="number"&&(this._makeRange(e,t,s),e[0]!==t&&this.changedOptions.push({path:s,value:Number(t)}))}_update(e,t){let s=this._constructOptions(e,t);this.parent.body&&this.parent.body.emitter&&this.parent.body.emitter.emit&&this.parent.body.emitter.emit("configChange",s),this.initialized=!0,this.parent.setOptions(s)}_constructOptions(e,t,s={}){let o=s;e=e==="true"?!0:e,e=e==="false"?!1:e;for(let n=0;nn-this.padding&&(h=!0),h?a=this.x-s:a=this.x,l?d=this.y-t:d=this.y}else d=this.y-t,d+t+this.padding>o&&(d=o-t-this.padding),dn&&(a=n-s-this.padding),an.distance?h=" in "+G.printLocation(o.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+G.printLocation(n.path,n.closestMatch,""):o.distance<=a?h='. Did you mean "'+o.closestMatch+'"?'+G.printLocation(o.path,e):h=". Did you mean one of these: "+G.print(Object.keys(t))+G.printLocation(s,e),console.error('%cUnknown option detected: "'+e+'"'+h,ki),_t=!0}static findInOptions(e,t,s,o=!1){let n=1e9,a="",d=[],h=e.toLowerCase(),l;for(let c in t){let u;if(t[c].__type__!==void 0&&o===!0){let f=G.findInOptions(e,t[c],jt(s,c));n>f.distance&&(a=f.closestMatch,d=f.path,n=f.distance,l=f.indexMatch)}else c.toLowerCase().indexOf(h)!==-1&&(l=c),u=G.levenshteinDistance(e,c),n>u&&(a=c,d=Sr(s),n=u)}return{closestMatch:a,path:d,distance:n,indexMatch:l}}static printLocation(e,t,s=`Problem value found at: +`:n.distance<=d&&o.distance>n.distance?h=" in "+G.printLocation(o.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+G.printLocation(n.path,n.closestMatch,""):o.distance<=a?h='. Did you mean "'+o.closestMatch+'"?'+G.printLocation(o.path,e):h=". Did you mean one of these: "+G.print(Object.keys(t))+G.printLocation(s,e),console.error('%cUnknown option detected: "'+e+'"'+h,ki),_t=!0}static findInOptions(e,t,s,o=!1){let n=1e9,a="",d=[],h=e.toLowerCase(),l;for(let c in t){let u;if(t[c].__type__!==void 0&&o===!0){let f=G.findInOptions(e,t[c],jt(s,c));n>f.distance&&(a=f.closestMatch,d=f.path,n=f.distance,l=f.indexMatch)}else c.toLowerCase().indexOf(h)!==-1&&(l=c),u=G.levenshteinDistance(e,c),n>u&&(a=c,d=Ir(s),n=u)}return{closestMatch:a,path:d,distance:n,indexMatch:l}}static printLocation(e,t,s=`Problem value found at: `){let o=` `+s+`options = { @@ -11,16 +11,16 @@ `;for(let n=0;n1&&arguments[1]!==void 0?arguments[1]:0,t=(ee[r[e+0]]+ee[r[e+1]]+ee[r[e+2]]+ee[r[e+3]]+"-"+ee[r[e+4]]+ee[r[e+5]]+"-"+ee[r[e+6]]+ee[r[e+7]]+"-"+ee[r[e+8]]+ee[r[e+9]]+"-"+ee[r[e+10]]+ee[r[e+11]]+ee[r[e+12]]+ee[r[e+13]]+ee[r[e+14]]+ee[r[e+15]]).toLowerCase();if(!Go(t))throw TypeError("Stringified UUID is invalid");return t}var Ko=Rr;function Lr(r,e,t){r=r||{};var s=r.random||(r.rng||Di)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(var o=0;o<16;++o)e[t+o]=s[o];return e}return Ko(s)}var Ne=Lr;function $o(r){return typeof r=="string"||typeof r=="number"}var Ni=class r{constructor(e){se(this,"delay");se(this,"max");se(this,"_queue",[]);se(this,"_timeout",null);se(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 s=new r(t);if(e.flush!==void 0)throw new Error("Target object already has a property flush");e.flush=()=>{s.flush()};let o=[{name:"flush",original:void 0}];if(t&&t.replace)for(let n=0;nthis.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||[])})}},Fi=class r{constructor(){se(this,"_subscribers",{"*":[],add:[],remove:[],update:[]});se(this,"subscribe",r.prototype.on);se(this,"unsubscribe",r.prototype.off)}_trigger(e,t,s){if(e==="*")throw new Error("Cannot trigger event *");[...this._subscribers[e],...this._subscribers["*"]].forEach(o=>{o(e,t,s!=null?s:null)})}on(e,t){typeof t=="function"&&this._subscribers[e].push(t)}off(e,t){this._subscribers[e]=this._subscribers[e].filter(s=>s!==t)}},Ut=class r{constructor(e){se(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,s]of this._pairs)e[t]=s;return e}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new r([...this._pairs])}distinct(e){let t=new Set;for(let[s,o]of this._pairs)t.add(e(o,s));return t}filter(e){let t=this._pairs;return new r({*[Symbol.iterator](){for(let[s,o]of t)e(o,s)&&(yield[s,o])}})}forEach(e){for(let[t,s]of this._pairs)e(s,t)}map(e){let t=this._pairs;return new r({*[Symbol.iterator](){for(let[s,o]of t)yield[s,e(o,s)]}})}max(e){let t=this._pairs[Symbol.iterator](),s=t.next();if(s.done)return null;let o=s.value[1],n=e(s.value[1],s.value[0]);for(;!(s=t.next()).done;){let[a,d]=s.value,h=e(d,a);h>n&&(n=h,o=d)}return o}min(e){let t=this._pairs[Symbol.iterator](),s=t.next();if(s.done)return null;let o=s.value[1],n=e(s.value[1],s.value[0]);for(;!(s=t.next()).done;){let[a,d]=s.value,h=e(d,a);h[...this._pairs].sort(([t,s],[o,n])=>e(s,n,t,o))[Symbol.iterator]()})}};function Hr(r,e){return r[e]==null&&(r[e]=Ne()),r}var Te=class extends Fi{constructor(t,s){super();se(this,"flush");se(this,"length");se(this,"_options");se(this,"_data");se(this,"_idProp");se(this,"_queue",null);t&&!Array.isArray(t)&&(s=t,t=[]),this._options=s||{},this._data=new Map,this.length=0,this._idProp=this._options.fieldId||"id",t&&t.length&&this.add(t),this.setOptions(s)}get idProp(){return this._idProp}setOptions(t){t&&t.queue!==void 0&&(t.queue===!1?this._queue&&(this._queue.destroy(),this._queue=null):(this._queue||(this._queue=Ni.extend(this,{replace:["add","update","remove"]})),t.queue&&typeof t.queue=="object"&&this._queue.setOptions(t.queue)))}add(t,s){let o=[],n;if(Array.isArray(t)){if(t.map(d=>d[this._idProp]).some(d=>this._data.has(d)))throw new Error("A duplicate id was found in the parameter array.");for(let d=0,h=t.length;d{let u=c[h];if(u!=null&&this._data.has(u)){let f=c,p=Object.assign({},this._data.get(u)),g=this._updateItem(f);n.push(g),d.push(f),a.push(p)}else{let f=this._addItem(c);o.push(f)}};if(Array.isArray(t))for(let c=0,u=t.length;c{let a=this._data.get(n[this._idProp]);if(a==null)throw new Error("Updating non-existent items is not allowed.");return{oldData:a,update:n}}).map(({oldData:n,update:a})=>{let d=n[this._idProp],h=No(n,a);return this._data.set(d,h),{id:d,oldData:n,updatedData:h}});if(o.length){let n={items:o.map(a=>a.id),oldData:o.map(a=>a.oldData),data:o.map(a=>a.updatedData)};return this._trigger("update",n,s),n.items}else return[]}get(t,s){let o,n,a;$o(t)?(o=t,a=s):Array.isArray(t)?(n=t,a=s):a=t;let d=a&&a.returnType==="Object"?"Object":"Array",h=a&&a.filter,l=[],c,u,f;if(o!=null)c=this._data.get(o),c&&h&&!h(c)&&(c=void 0);else if(n!=null)for(let p=0,g=n.length;p(o[n]=t[n],o),{})}_sort(t,s){if(typeof s=="string"){let o=s;t.sort((n,a)=>{let d=n[o],h=a[o];return d>h?1:do)&&(s=n,o=a)}return s||null}min(t){let s=null,o=null;for(let n of this._data.values()){let a=n[t];typeof a=="number"&&(o==null||a=.1;)g=+n[u++%a],g>c&&(g=c),p=Math.sqrt(g*g/(1+l*l)),p=d<0?-p:p,e+=p,t+=l*p,f===!0?r.lineTo(e,t):r.moveTo(e,t),c-=g,f=!f}function Xr(r,e,t,s){r.beginPath();let o=6,n=Math.PI*2/o;r.moveTo(e+s,t);for(let a=1;a":!0,"--":!0},Re="",at=0,B="",M="",he=re.NULL;function $r(){at=0,B=Re.charAt(0)}function J(){at++,B=Re.charAt(at)}function nt(){return Re.charAt(at+1)}function Jo(r){var e=r.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 He(r,e){if(r||(r={}),e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function Zr(r,e,t){for(var s=e.split("."),o=r;s.length;){var n=s.shift();s.length?(o[n]||(o[n]={}),o=o[n]):o[n]=t}}function dn(r,e){for(var t,s,o=null,n=[r],a=r;a.parent;)n.push(a.parent),a=a.parent;if(a.nodes){for(t=0,s=a.nodes.length;t=0;t--){var d=n[t];d.nodes||(d.nodes=[]),d.nodes.indexOf(o)===-1&&d.nodes.push(o)}e.attr&&(o.attr=He(o.attr,e.attr))}function Qr(r,e){if(r.edges||(r.edges=[]),r.edges.push(e),r.edge){var t=He({},r.edge);e.attr=He(t,e.attr)}}function hn(r,e,t,s,o){var n={from:e,to:t,type:s};return r.edge&&(n.attr=He({},r.edge)),n.attr=He(n.attr||{},o),o!=null&&o.hasOwnProperty("arrows")&&o.arrows!=null&&(n.arrows={to:{enabled:!0,type:o.arrows.type}},o.arrows=null),n}function Y(){for(he=re.NULL,M="";B===" "||B===" "||B===` +`}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 s=[],o;for(o=0;o<=t.length;o++)s[o]=[o];let n;for(n=0;n<=e.length;n++)s[0][n]=n;for(o=1;o<=t.length;o++)for(n=1;n<=e.length;n++)t.charAt(o-1)==e.charAt(n-1)?s[o][n]=s[o-1][n-1]:s[o][n]=Math.min(s[o-1][n-1]+1,Math.min(s[o][n-1]+1,s[o-1][n]+1));return s[t.length][e.length]}},Vo=xe;var qo=Fr,Ze=Si,Yo=Br,Mi=ki,Xo=Ar;var qt,zr=new Uint8Array(16);function Di(){if(!qt&&(qt=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!qt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qt(zr)}var Uo=/^(?:[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 Rr(r){return typeof r=="string"&&Uo.test(r)}var Go=Rr;var ee=[];for(Yt=0;Yt<256;++Yt)ee.push((Yt+256).toString(16).substr(1));var Yt;function Lr(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(ee[r[e+0]]+ee[r[e+1]]+ee[r[e+2]]+ee[r[e+3]]+"-"+ee[r[e+4]]+ee[r[e+5]]+"-"+ee[r[e+6]]+ee[r[e+7]]+"-"+ee[r[e+8]]+ee[r[e+9]]+"-"+ee[r[e+10]]+ee[r[e+11]]+ee[r[e+12]]+ee[r[e+13]]+ee[r[e+14]]+ee[r[e+15]]).toLowerCase();if(!Go(t))throw TypeError("Stringified UUID is invalid");return t}var Ko=Lr;function Hr(r,e,t){r=r||{};var s=r.random||(r.rng||Di)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(var o=0;o<16;++o)e[t+o]=s[o];return e}return Ko(s)}var Ne=Hr;function $o(r){return typeof r=="string"||typeof r=="number"}var Ni=class r{constructor(e){se(this,"delay");se(this,"max");se(this,"_queue",[]);se(this,"_timeout",null);se(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 s=new r(t);if(e.flush!==void 0)throw new Error("Target object already has a property flush");e.flush=()=>{s.flush()};let o=[{name:"flush",original:void 0}];if(t&&t.replace)for(let n=0;nthis.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||[])})}},Fi=class r{constructor(){se(this,"_subscribers",{"*":[],add:[],remove:[],update:[]});se(this,"subscribe",r.prototype.on);se(this,"unsubscribe",r.prototype.off)}_trigger(e,t,s){if(e==="*")throw new Error("Cannot trigger event *");[...this._subscribers[e],...this._subscribers["*"]].forEach(o=>{o(e,t,s!=null?s:null)})}on(e,t){typeof t=="function"&&this._subscribers[e].push(t)}off(e,t){this._subscribers[e]=this._subscribers[e].filter(s=>s!==t)}},Xt=class r{constructor(e){se(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,s]of this._pairs)e[t]=s;return e}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new r([...this._pairs])}distinct(e){let t=new Set;for(let[s,o]of this._pairs)t.add(e(o,s));return t}filter(e){let t=this._pairs;return new r({*[Symbol.iterator](){for(let[s,o]of t)e(o,s)&&(yield[s,o])}})}forEach(e){for(let[t,s]of this._pairs)e(s,t)}map(e){let t=this._pairs;return new r({*[Symbol.iterator](){for(let[s,o]of t)yield[s,e(o,s)]}})}max(e){let t=this._pairs[Symbol.iterator](),s=t.next();if(s.done)return null;let o=s.value[1],n=e(s.value[1],s.value[0]);for(;!(s=t.next()).done;){let[a,d]=s.value,h=e(d,a);h>n&&(n=h,o=d)}return o}min(e){let t=this._pairs[Symbol.iterator](),s=t.next();if(s.done)return null;let o=s.value[1],n=e(s.value[1],s.value[0]);for(;!(s=t.next()).done;){let[a,d]=s.value,h=e(d,a);h[...this._pairs].sort(([t,s],[o,n])=>e(s,n,t,o))[Symbol.iterator]()})}};function jr(r,e){return r[e]==null&&(r[e]=Ne()),r}var Te=class extends Fi{constructor(t,s){super();se(this,"flush");se(this,"length");se(this,"_options");se(this,"_data");se(this,"_idProp");se(this,"_queue",null);t&&!Array.isArray(t)&&(s=t,t=[]),this._options=s||{},this._data=new Map,this.length=0,this._idProp=this._options.fieldId||"id",t&&t.length&&this.add(t),this.setOptions(s)}get idProp(){return this._idProp}setOptions(t){t&&t.queue!==void 0&&(t.queue===!1?this._queue&&(this._queue.destroy(),this._queue=null):(this._queue||(this._queue=Ni.extend(this,{replace:["add","update","remove"]})),t.queue&&typeof t.queue=="object"&&this._queue.setOptions(t.queue)))}add(t,s){let o=[],n;if(Array.isArray(t)){if(t.map(d=>d[this._idProp]).some(d=>this._data.has(d)))throw new Error("A duplicate id was found in the parameter array.");for(let d=0,h=t.length;d{let u=c[h];if(u!=null&&this._data.has(u)){let f=c,p=Object.assign({},this._data.get(u)),g=this._updateItem(f);n.push(g),d.push(f),a.push(p)}else{let f=this._addItem(c);o.push(f)}};if(Array.isArray(t))for(let c=0,u=t.length;c{let a=this._data.get(n[this._idProp]);if(a==null)throw new Error("Updating non-existent items is not allowed.");return{oldData:a,update:n}}).map(({oldData:n,update:a})=>{let d=n[this._idProp],h=No(n,a);return this._data.set(d,h),{id:d,oldData:n,updatedData:h}});if(o.length){let n={items:o.map(a=>a.id),oldData:o.map(a=>a.oldData),data:o.map(a=>a.updatedData)};return this._trigger("update",n,s),n.items}else return[]}get(t,s){let o,n,a;$o(t)?(o=t,a=s):Array.isArray(t)?(n=t,a=s):a=t;let d=a&&a.returnType==="Object"?"Object":"Array",h=a&&a.filter,l=[],c,u,f;if(o!=null)c=this._data.get(o),c&&h&&!h(c)&&(c=void 0);else if(n!=null)for(let p=0,g=n.length;p(o[n]=t[n],o),{})}_sort(t,s){if(typeof s=="string"){let o=s;t.sort((n,a)=>{let d=n[o],h=a[o];return d>h?1:do)&&(s=n,o=a)}return s||null}min(t){let s=null,o=null;for(let n of this._data.values()){let a=n[t];typeof a=="number"&&(o==null||a=.1;)g=+n[u++%a],g>c&&(g=c),p=Math.sqrt(g*g/(1+l*l)),p=d<0?-p:p,e+=p,t+=l*p,f===!0?r.lineTo(e,t):r.moveTo(e,t),c-=g,f=!f}function Gr(r,e,t,s){r.beginPath();let o=6,n=Math.PI*2/o;r.moveTo(e+s,t);for(let a=1;a":!0,"--":!0},Re="",at=0,B="",M="",he=re.NULL;function Zr(){at=0,B=Re.charAt(0)}function J(){at++,B=Re.charAt(at)}function nt(){return Re.charAt(at+1)}function Jo(r){var e=r.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 He(r,e){if(r||(r={}),e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function Qr(r,e,t){for(var s=e.split("."),o=r;s.length;){var n=s.shift();s.length?(o[n]||(o[n]={}),o=o[n]):o[n]=t}}function dn(r,e){for(var t,s,o=null,n=[r],a=r;a.parent;)n.push(a.parent),a=a.parent;if(a.nodes){for(t=0,s=a.nodes.length;t=0;t--){var d=n[t];d.nodes||(d.nodes=[]),d.nodes.indexOf(o)===-1&&d.nodes.push(o)}e.attr&&(o.attr=He(o.attr,e.attr))}function Jr(r,e){if(r.edges||(r.edges=[]),r.edges.push(e),r.edge){var t=He({},r.edge);e.attr=He(t,e.attr)}}function hn(r,e,t,s,o){var n={from:e,to:t,type:s};return r.edge&&(n.attr=He({},r.edge)),n.attr=He(n.attr||{},o),o!=null&&o.hasOwnProperty("arrows")&&o.arrows!=null&&(n.arrows={to:{enabled:!0,type:o.arrows.type}},o.arrows=null),n}function Y(){for(he=re.NULL,M="";B===" "||B===" "||B===` `||B==="\r";)J();do{var r=!1;if(B==="#"){for(var e=at-1;Re.charAt(e)===" "||Re.charAt(e)===" ";)e--;if(Re.charAt(e)===` `||Re.charAt(e)===""){for(;B!=""&&B!=` `;)J();r=!0}}if(B==="/"&&nt()==="/"){for(;B!=""&&B!=` `;)J();r=!0}if(B==="/"&&nt()==="*"){for(;B!="";)if(B==="*"&&nt()==="/"){J(),J();break}else J();r=!0}for(;B===" "||B===" "||B===` `||B==="\r";)J()}while(r);if(B===""){he=re.DELIMITER;return}var t=B+nt();if(Qo[t]){he=re.DELIMITER,M=t,J(),J();return}if(Qo[B]){he=re.DELIMITER,M=B,J();return}if(Jo(B)||B==="-"){for(M+=B,J();Jo(B);)M+=B,J();M==="false"?M=!1:M==="true"?M=!0:isNaN(Number(M))||(M=Number(M)),he=re.IDENTIFIER;return}if(B==='"'){for(J();B!=""&&(B!='"'||B==='"'&&nt()==='"');)B==='"'?(M+=B,J()):B==="\\"&&nt()==="n"?(M+=` -`,J()):M+=B,J();if(B!='"')throw ae('End of string " expected');J(),he=re.IDENTIFIER;return}for(he=re.UNKNOWN;B!="";)M+=B,J();throw new SyntaxError('Syntax error in part "'+fn(M,30)+'"')}function Jr(){var r={};if($r(),Y(),M==="strict"&&(r.strict=!0,Y()),(M==="graph"||M==="digraph")&&(r.type=M,Y()),he===re.IDENTIFIER&&(r.id=M,Y()),M!="{")throw ae("Angle bracket { expected");if(Y(),ln(r),M!="}")throw ae("Angle bracket } expected");if(Y(),M!=="")throw ae("End of file expected");return Y(),delete r.node,delete r.edge,delete r.graph,r}function ln(r){for(;M!==""&&M!="}";)ea(r),M===";"&&Y()}function ea(r){var e=cn(r);if(e){un(r,e);return}var t=ta(r);if(!t){if(he!=re.IDENTIFIER)throw ae("Identifier expected");var s=M;if(Y(),M==="="){if(Y(),he!=re.IDENTIFIER)throw ae("Identifier expected");r[s]=M,Y()}else ia(r,s)}}function cn(r){var e=null;if(M==="subgraph"&&(e={},e.type="subgraph",Y(),he===re.IDENTIFIER&&(e.id=M,Y())),M==="{"){if(Y(),e||(e={}),e.parent=r,e.node=r.node,e.edge=r.edge,e.graph=r.graph,ln(e),M!="}")throw ae("Angle bracket } expected");Y(),delete e.node,delete e.edge,delete e.graph,delete e.parent,r.subgraphs||(r.subgraphs=[]),r.subgraphs.push(e)}return e}function ta(r){return M==="node"?(Y(),r.node=kt(),"node"):M==="edge"?(Y(),r.edge=kt(),"edge"):M==="graph"?(Y(),r.graph=kt(),"graph"):null}function ia(r,e){var t={id:e},s=kt();s&&(t.attr=s),dn(r,t),un(r,e)}function un(r,e){for(;M==="->"||M==="--";){var t,s=M;Y();var o=cn(r);if(o)t=o;else{if(he!=re.IDENTIFIER)throw ae("Identifier or subgraph expected");t=M,dn(r,{id:t}),Y()}var n=kt(),a=hn(r,e,t,s,n);Qr(r,a),e=t}}function kt(){for(var r,e=null,t={dashed:!0,solid:!1,dotted:[1,5]},s={dot:"circle",box:"box",crow:"crow",curve:"curve",icurve:"inv_curve",normal:"triangle",inv:"inv_triangle",diamond:"diamond",tee:"bar",vee:"vee"},o=new Array,n=new Array;M==="[";){for(Y(),e={};M!==""&&M!="]";){if(he!=re.IDENTIFIER)throw ae("Attribute name expected");var a=M;if(Y(),M!="=")throw ae("Equal sign = expected");if(Y(),he!=re.IDENTIFIER)throw ae("Attribute value expected");var d=M;a==="style"&&(d=t[d]);var h;a==="arrowhead"&&(h=s[d],a="arrows",d={to:{enabled:!0,type:h}}),a==="arrowtail"&&(h=s[d],a="arrows",d={from:{enabled:!0,type:h}}),o.push({attr:e,name:a,value:d}),n.push(a),Y(),M==","&&Y()}if(M!="]")throw ae("Bracket ] expected");Y()}if(n.includes("dir")){var l={};for(l.arrows={},r=0;r"&&(n.arrows="to"),n};e.edges.forEach(function(o){var n,a;o.from instanceof Object?n=o.from.nodes:n={id:o.from},o.to instanceof Object?a=o.to.nodes:a={id:o.to},o.from instanceof Object&&o.from.edges&&o.from.edges.forEach(function(d){var h=s(d);t.edges.push(h)}),sa(n,a,function(d,h){var l=hn(t,d.id,h.id,o.type,o.attr),c=s(l);t.edges.push(c)}),o.to instanceof Object&&o.to.edges&&o.to.edges.forEach(function(d){var h=s(d);t.edges.push(h)})})}return e.attr&&(t.options=e.attr),t}function na(r,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 o=r.edges.map(a=>{let d={from:a.source,id:a.id,to:a.target};return a.attributes!=null&&(d.attributes=a.attributes),a.label!=null&&(d.label=a.label),a.attributes!=null&&a.attributes.title!=null&&(d.title=a.attributes.title),a.type==="Directed"&&(d.arrows="to"),a.color&&t.edges.inheritColor===!1&&(d.color=a.color),d});return{nodes:r.nodes.map(a=>{let d={id:a.id,fixed:t.nodes.fixed&&a.x!=null&&a.y!=null};return a.attributes!=null&&(d.attributes=a.attributes),a.label!=null&&(d.label=a.label),a.size!=null&&(d.size=a.size),a.attributes!=null&&a.attributes.title!=null&&(d.title=a.attributes.title),a.title!=null&&(d.title=a.title),a.x!=null&&(d.x=a.x),a.y!=null&&(d.y=a.y),a.color!=null&&(t.nodes.parseColor===!0?d.color=a.color:d.color={background:a.color,border:a.color,highlight:{background:a.color,border:a.color},hover:{background:a.color,border:a.color}}),d}),edges:o}}var ra={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"},aa={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"},da={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"},ha={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"},la={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"},ca={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"},ua={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"},fa={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"},pa={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"},ga={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"},ma={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"},ya=Object.freeze({__proto__:null,cn:fa,cs:ma,de:aa,en:ra,es:da,fr:ga,it:ha,nl:la,pt:ca,ru:ua,uk:pa});function ba(r,e){try{let[t,s]=e.split(/[-_ /]/,2),o=t!=null?t.toLowerCase():null,n=s!=null?s.toUpperCase():null;if(o&&n){let a=o+"-"+n;if(Object.prototype.hasOwnProperty.call(r,a))return a;console.warn(`Unknown variant ${n} of language ${o}.`)}if(o){let a=o;if(Object.prototype.hasOwnProperty.call(r,a))return a;console.warn(`Unknown language ${o}`)}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 Hi=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 s=Math.floor(t/2),o=Math.floor(t/4),n=Math.floor(t/8),a=Math.floor(t/16),d=Math.floor(e/2),h=Math.floor(e/4),l=Math.floor(e/8),c=Math.floor(e/16);this.canvas.width=3*h,this.canvas.height=s,this.coordinates=[[0,0,d,s],[d,0,h,o],[d,o,l,n],[5*l,o,c,a]],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 s=1;s2){t*=.5;let d=0;for(;t>2&&d=this.NUM_ITERATIONS&&(d=this.NUM_ITERATIONS-1);let h=this.coordinates[d];e.drawImage(this.canvas,h[0],h[1],h[2],h[3],s,o,n,a)}else e.drawImage(this.image,s,o,n,a)}},ji=class{constructor(e){this.images={},this.imageBroken={},this.callback=e}_tryloadBrokenUrl(e,t,s){if(!(e===void 0||s===void 0)){if(t===void 0){console.warn("No broken url image defined");return}s.image.onerror=()=>{console.error("Could not load brokenImage:",t)},s.image.src=t}}_redrawWithImage(e){this.callback&&this.callback(e)}load(e,t){let s=this.images[e];if(s)return s;let o=new Hi;return this.images[e]=o,o.image.onload=()=>{this._fixImageCoordinates(o.image),o.init(),this._redrawWithImage(o)},o.image.onerror=()=>{console.error("Could not load image:",e),this._tryloadBrokenUrl(e,t,o)},o.image.src=e,o}_fixImageCoordinates(e){e.width===0&&(document.body.appendChild(e),e.width=e.offsetWidth,e.height=e.offsetHeight,document.body.removeChild(e))}},Wi=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 s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)===-1){let o=e[s];this.add(s,o)}}}clear(){this._groups=new Map,this._groupNames=[]}get(e,t=!0){let s=this._groups.get(e);if(s===void 0&&t)if(this.options.useDefaultGroups===!1&&this._groupNames.length>0){let o=this._groupIndex%this._groupNames.length;++this._groupIndex,s={},s.color=this._groups.get(this._groupNames[o]),this._groups.set(e,s)}else{let o=this._defaultIndex%this._defaultGroups.length;this._defaultIndex++,s={},s.color=this._defaultGroups[o],this._groups.set(e,s)}return s}add(e,t){return this._groups.has(e)||this._groupNames.push(e),this._groups.set(e,t),t}};function js(r,e){let t=["node","edge","label"],s=!0,o=De(e,"chosen");if(typeof o=="boolean")s=o;else if(typeof o=="object"){if(t.indexOf(r)===-1)throw new Error("choosify: subOption '"+r+"' should be one of '"+t.join("', '")+"'");let n=De(e,["chosen",r]);(typeof n=="boolean"||typeof n=="function")&&(s=n)}return s}function Vi(r,e,t){if(r.width<=0||r.height<=0)return!1;if(t!==void 0){let n={x:e.x-t.x,y:e.y-t.y};if(t.angle!==0){let a=-t.angle;e={x:Math.cos(a)*n.x-Math.sin(a)*n.y,y:Math.sin(a)*n.x+Math.cos(a)*n.y}}else e=n}let s=r.x+r.width,o=r.y+r.width;return r.lefte.x&&r.tope.y}function $t(r){return typeof r=="string"&&r!==""}function pn(r,e,t,s){let o=s.x,n=s.y;if(typeof s.distanceToBorder=="function"){let a=s.distanceToBorder(r,e),d=Math.sin(e)*a,h=Math.cos(e)*a;h===a?(o+=a,n=s.y):d===a?(o=s.x,n-=a):(o+=h,n-=d)}else s.shape.width>s.shape.height?(o=s.x+s.shape.width*.5,n=s.y-t):(o=s.x+t,n=s.y-s.shape.height*.5);return{x:o,y:n}}var qi=class{constructor(e){this.measureText=e,this.current=0,this.width=0,this.height=0,this.lines=[]}_add(e,t,s="normal"){this.lines[e]===void 0&&(this.lines[e]={width:0,height:0,blocks:[]});let o=t;(t===void 0||t==="")&&(o=" ");let n=this.measureText(o,s),a=Object.assign({},n.values);a.text=t,a.width=n.width,a.mod=s,(t===void 0||t==="")&&(a.width=0),this.lines[e].blocks.push(a),this.lines[e].width+=a.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;ee&&(e=o.width),t+=o.height}this.width=e,this.height=t}removeEmptyBlocks(){let e=[];for(let t=0;t"://,""://,""://,"":/<\/b>/,"":/<\/i>/,"":/<\/code>/,"*":/\*/,_:/_/,"`":/`/,afterBold:/[^*]/,afterItal:/[^_]/,afterMono:/[^`]/},Zt=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[s,o]=this.prepareRegExp(e),n=s.test(this.text.substr(this.position,o));return n&&t&&(this.position+=o-1),n}parseEndTag(e,t,s){let o=this.mod()===e;return e==="mono"?o=o&&this.mono:o=o&&!this.mono,o&&this.match(t)?(s!==void 0?(this.position===this.text.length-1||this.match(s,!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,s;if(e instanceof RegExp)s=e,t=1;else{let o=va[e];o!==void 0?s=o:s=new RegExp(e),t=e.length}return[s,t]}},Yi=class{constructor(e,t,s,o){this.ctx=e,this.parent=t,this.selected=s,this.hover=o;let n=(a,d)=>{if(a===void 0)return 0;let h=this.parent.getFormattingValues(e,s,o,d),l=0;return a!==""&&(l=this.ctx.measureText(a).width),{width:l,values:h}};this.lines=new qi(n)}process(e){if(!$t(e))return this.lines.finalize();let t=this.parent.fontOptions;e=e.replace(/\r\n/g,` +`,J()):M+=B,J();if(B!='"')throw ae('End of string " expected');J(),he=re.IDENTIFIER;return}for(he=re.UNKNOWN;B!="";)M+=B,J();throw new SyntaxError('Syntax error in part "'+fn(M,30)+'"')}function ea(){var r={};if(Zr(),Y(),M==="strict"&&(r.strict=!0,Y()),(M==="graph"||M==="digraph")&&(r.type=M,Y()),he===re.IDENTIFIER&&(r.id=M,Y()),M!="{")throw ae("Angle bracket { expected");if(Y(),ln(r),M!="}")throw ae("Angle bracket } expected");if(Y(),M!=="")throw ae("End of file expected");return Y(),delete r.node,delete r.edge,delete r.graph,r}function ln(r){for(;M!==""&&M!="}";)ta(r),M===";"&&Y()}function ta(r){var e=cn(r);if(e){un(r,e);return}var t=ia(r);if(!t){if(he!=re.IDENTIFIER)throw ae("Identifier expected");var s=M;if(Y(),M==="="){if(Y(),he!=re.IDENTIFIER)throw ae("Identifier expected");r[s]=M,Y()}else sa(r,s)}}function cn(r){var e=null;if(M==="subgraph"&&(e={},e.type="subgraph",Y(),he===re.IDENTIFIER&&(e.id=M,Y())),M==="{"){if(Y(),e||(e={}),e.parent=r,e.node=r.node,e.edge=r.edge,e.graph=r.graph,ln(e),M!="}")throw ae("Angle bracket } expected");Y(),delete e.node,delete e.edge,delete e.graph,delete e.parent,r.subgraphs||(r.subgraphs=[]),r.subgraphs.push(e)}return e}function ia(r){return M==="node"?(Y(),r.node=kt(),"node"):M==="edge"?(Y(),r.edge=kt(),"edge"):M==="graph"?(Y(),r.graph=kt(),"graph"):null}function sa(r,e){var t={id:e},s=kt();s&&(t.attr=s),dn(r,t),un(r,e)}function un(r,e){for(;M==="->"||M==="--";){var t,s=M;Y();var o=cn(r);if(o)t=o;else{if(he!=re.IDENTIFIER)throw ae("Identifier or subgraph expected");t=M,dn(r,{id:t}),Y()}var n=kt(),a=hn(r,e,t,s,n);Jr(r,a),e=t}}function kt(){for(var r,e=null,t={dashed:!0,solid:!1,dotted:[1,5]},s={dot:"circle",box:"box",crow:"crow",curve:"curve",icurve:"inv_curve",normal:"triangle",inv:"inv_triangle",diamond:"diamond",tee:"bar",vee:"vee"},o=new Array,n=new Array;M==="[";){for(Y(),e={};M!==""&&M!="]";){if(he!=re.IDENTIFIER)throw ae("Attribute name expected");var a=M;if(Y(),M!="=")throw ae("Equal sign = expected");if(Y(),he!=re.IDENTIFIER)throw ae("Attribute value expected");var d=M;a==="style"&&(d=t[d]);var h;a==="arrowhead"&&(h=s[d],a="arrows",d={to:{enabled:!0,type:h}}),a==="arrowtail"&&(h=s[d],a="arrows",d={from:{enabled:!0,type:h}}),o.push({attr:e,name:a,value:d}),n.push(a),Y(),M==","&&Y()}if(M!="]")throw ae("Bracket ] expected");Y()}if(n.includes("dir")){var l={};for(l.arrows={},r=0;r"&&(n.arrows="to"),n};e.edges.forEach(function(o){var n,a;o.from instanceof Object?n=o.from.nodes:n={id:o.from},o.to instanceof Object?a=o.to.nodes:a={id:o.to},o.from instanceof Object&&o.from.edges&&o.from.edges.forEach(function(d){var h=s(d);t.edges.push(h)}),oa(n,a,function(d,h){var l=hn(t,d.id,h.id,o.type,o.attr),c=s(l);t.edges.push(c)}),o.to instanceof Object&&o.to.edges&&o.to.edges.forEach(function(d){var h=s(d);t.edges.push(h)})})}return e.attr&&(t.options=e.attr),t}function ra(r,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 o=r.edges.map(a=>{let d={from:a.source,id:a.id,to:a.target};return a.attributes!=null&&(d.attributes=a.attributes),a.label!=null&&(d.label=a.label),a.attributes!=null&&a.attributes.title!=null&&(d.title=a.attributes.title),a.type==="Directed"&&(d.arrows="to"),a.color&&t.edges.inheritColor===!1&&(d.color=a.color),d});return{nodes:r.nodes.map(a=>{let d={id:a.id,fixed:t.nodes.fixed&&a.x!=null&&a.y!=null};return a.attributes!=null&&(d.attributes=a.attributes),a.label!=null&&(d.label=a.label),a.size!=null&&(d.size=a.size),a.attributes!=null&&a.attributes.title!=null&&(d.title=a.attributes.title),a.title!=null&&(d.title=a.title),a.x!=null&&(d.x=a.x),a.y!=null&&(d.y=a.y),a.color!=null&&(t.nodes.parseColor===!0?d.color=a.color:d.color={background:a.color,border:a.color,highlight:{background:a.color,border:a.color},hover:{background:a.color,border:a.color}}),d}),edges:o}}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(r,e){try{let[t,s]=e.split(/[-_ /]/,2),o=t!=null?t.toLowerCase():null,n=s!=null?s.toUpperCase():null;if(o&&n){let a=o+"-"+n;if(Object.prototype.hasOwnProperty.call(r,a))return a;console.warn(`Unknown variant ${n} of language ${o}.`)}if(o){let a=o;if(Object.prototype.hasOwnProperty.call(r,a))return a;console.warn(`Unknown language ${o}`)}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 Hi=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 s=Math.floor(t/2),o=Math.floor(t/4),n=Math.floor(t/8),a=Math.floor(t/16),d=Math.floor(e/2),h=Math.floor(e/4),l=Math.floor(e/8),c=Math.floor(e/16);this.canvas.width=3*h,this.canvas.height=s,this.coordinates=[[0,0,d,s],[d,0,h,o],[d,o,l,n],[5*l,o,c,a]],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 s=1;s2){t*=.5;let d=0;for(;t>2&&d=this.NUM_ITERATIONS&&(d=this.NUM_ITERATIONS-1);let h=this.coordinates[d];e.drawImage(this.canvas,h[0],h[1],h[2],h[3],s,o,n,a)}else e.drawImage(this.image,s,o,n,a)}},ji=class{constructor(e){this.images={},this.imageBroken={},this.callback=e}_tryloadBrokenUrl(e,t,s){if(!(e===void 0||s===void 0)){if(t===void 0){console.warn("No broken url image defined");return}s.image.onerror=()=>{console.error("Could not load brokenImage:",t)},s.image.src=t}}_redrawWithImage(e){this.callback&&this.callback(e)}load(e,t){let s=this.images[e];if(s)return s;let o=new Hi;return this.images[e]=o,o.image.onload=()=>{this._fixImageCoordinates(o.image),o.init(),this._redrawWithImage(o)},o.image.onerror=()=>{console.error("Could not load image:",e),this._tryloadBrokenUrl(e,t,o)},o.image.src=e,o}_fixImageCoordinates(e){e.width===0&&(document.body.appendChild(e),e.width=e.offsetWidth,e.height=e.offsetHeight,document.body.removeChild(e))}},Wi=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 s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)===-1){let o=e[s];this.add(s,o)}}}clear(){this._groups=new Map,this._groupNames=[]}get(e,t=!0){let s=this._groups.get(e);if(s===void 0&&t)if(this.options.useDefaultGroups===!1&&this._groupNames.length>0){let o=this._groupIndex%this._groupNames.length;++this._groupIndex,s={},s.color=this._groups.get(this._groupNames[o]),this._groups.set(e,s)}else{let o=this._defaultIndex%this._defaultGroups.length;this._defaultIndex++,s={},s.color=this._defaultGroups[o],this._groups.set(e,s)}return s}add(e,t){return this._groups.has(e)||this._groupNames.push(e),this._groups.set(e,t),t}};function js(r,e){let t=["node","edge","label"],s=!0,o=De(e,"chosen");if(typeof o=="boolean")s=o;else if(typeof o=="object"){if(t.indexOf(r)===-1)throw new Error("choosify: subOption '"+r+"' should be one of '"+t.join("', '")+"'");let n=De(e,["chosen",r]);(typeof n=="boolean"||typeof n=="function")&&(s=n)}return s}function Vi(r,e,t){if(r.width<=0||r.height<=0)return!1;if(t!==void 0){let n={x:e.x-t.x,y:e.y-t.y};if(t.angle!==0){let a=-t.angle;e={x:Math.cos(a)*n.x-Math.sin(a)*n.y,y:Math.sin(a)*n.x+Math.cos(a)*n.y}}else e=n}let s=r.x+r.width,o=r.y+r.width;return r.lefte.x&&r.tope.y}function $t(r){return typeof r=="string"&&r!==""}function pn(r,e,t,s){let o=s.x,n=s.y;if(typeof s.distanceToBorder=="function"){let a=s.distanceToBorder(r,e),d=Math.sin(e)*a,h=Math.cos(e)*a;h===a?(o+=a,n=s.y):d===a?(o=s.x,n-=a):(o+=h,n-=d)}else s.shape.width>s.shape.height?(o=s.x+s.shape.width*.5,n=s.y-t):(o=s.x+t,n=s.y-s.shape.height*.5);return{x:o,y:n}}var qi=class{constructor(e){this.measureText=e,this.current=0,this.width=0,this.height=0,this.lines=[]}_add(e,t,s="normal"){this.lines[e]===void 0&&(this.lines[e]={width:0,height:0,blocks:[]});let o=t;(t===void 0||t==="")&&(o=" ");let n=this.measureText(o,s),a=Object.assign({},n.values);a.text=t,a.width=n.width,a.mod=s,(t===void 0||t==="")&&(a.width=0),this.lines[e].blocks.push(a),this.lines[e].width+=a.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;ee&&(e=o.width),t+=o.height}this.width=e,this.height=t}removeEmptyBlocks(){let e=[];for(let t=0;t"://,""://,""://,"":/<\/b>/,"":/<\/i>/,"":/<\/code>/,"*":/\*/,_:/_/,"`":/`/,afterBold:/[^*]/,afterItal:/[^_]/,afterMono:/[^`]/},Zt=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[s,o]=this.prepareRegExp(e),n=s.test(this.text.substr(this.position,o));return n&&t&&(this.position+=o-1),n}parseEndTag(e,t,s){let o=this.mod()===e;return e==="mono"?o=o&&this.mono:o=o&&!this.mono,o&&this.match(t)?(s!==void 0?(this.position===this.text.length-1||this.match(s,!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,s;if(e instanceof RegExp)s=e,t=1;else{let o=wa[e];o!==void 0?s=o:s=new RegExp(e),t=e.length}return[s,t]}},Yi=class{constructor(e,t,s,o){this.ctx=e,this.parent=t,this.selected=s,this.hover=o;let n=(a,d)=>{if(a===void 0)return 0;let h=this.parent.getFormattingValues(e,s,o,d),l=0;return a!==""&&(l=this.ctx.measureText(a).width),{width:l,values:h}};this.lines=new qi(n)}process(e){if(!$t(e))return this.lines.finalize();let t=this.parent.fontOptions;e=e.replace(/\r\n/g,` `),e=e.replace(/\r/g,` `);let s=String(e).split(` -`),o=s.length;if(t.multi)for(let n=0;n0)for(let d=0;d0)for(let n=0;n/&/.test(o)?(t.replace(t.text,"<","<")||t.replace(t.text,"&","&")||t.add("&"),!0):!1;for(;t.position")||t.parseStartTag("ital","")||t.parseStartTag("mono","")||t.parseEndTag("bold","")||t.parseEndTag("ital","")||t.parseEndTag("mono",""))||s(o)||t.add(o),t.position++}return t.emitBlock(),t.blocks}splitMarkdownBlocks(e){let t=new Zt(e),s=!0,o=n=>/\\/.test(n)?(t.positionthis.parent.fontOptions.maxWdt}getLongestFit(e){let t="",s=0;for(;s0;){let n=this.getLongestFit(o);if(n===0){let a=o[0],d=this.getLongestFitWord(a);this.lines.newLine(a.slice(0,d),t),o[0]=a.slice(d)}else{let a=n;o[n-1]===" "?n--:o[a]===" "&&a++;let d=o.slice(0,n).join("");n==o.length&&s?this.lines.append(d,t):this.lines.newLine(d,t),o=o.slice(a)}}}},Gt=["bold","ital","boldital","mono"],Qt=class r{constructor(e,t,s=!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=s}setOptions(e){if(this.elementOptions=e,this.initFontOptions(e.font),$t(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(F(Gt,t=>{this.fontOptions[t]={}}),r.parseFontString(this.fontOptions,e)){this.fontOptions.vadjust=0;return}F(e,(t,s)=>{t!=null&&typeof t!="object"&&(this.fontOptions[s]=t)})}static parseFontString(e,t){if(!t||typeof t!="string")return!1;let s=t.split(" ");return e.size=+s[0].replace("px",""),e.face=s[1],e.color=s[2],!0}constrain(e){let t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},s=De(e,"widthConstraint");if(typeof s=="number")t.maxWdt=Number(s),t.minWdt=Number(s);else if(typeof s=="object"){let n=De(e,["widthConstraint","maximum"]);typeof n=="number"&&(t.maxWdt=Number(n));let a=De(e,["widthConstraint","minimum"]);typeof a=="number"&&(t.minWdt=Number(a))}let o=De(e,"heightConstraint");if(typeof o=="number")t.minHgt=Number(o);else if(typeof o=="object"){let n=De(e,["heightConstraint","minimum"]);typeof n=="number"&&(t.minHgt=Number(n));let a=De(e,["heightConstraint","valign"]);typeof a=="string"&&(a==="top"||a==="bottom")&&(t.valign=a)}return t}update(e,t){this.setOptions(e,!0),this.propagateFonts(t),V(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=js("label",t)}adjustSizes(e){let t=e?e.right+e.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);let s=e?e.top+e.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=s)}addFontOptionsToPile(e,t){for(let s=0;s{a!==void 0&&(Object.prototype.hasOwnProperty.call(t,d)||(Gt.indexOf(d)!==-1?t[d]={}:t[d]=a))})}return t}getFontOption(e,t,s){let o;for(let n=0;n{n[h]=d}),n.size=Number(n.size),n.vadjust=Number(n.vadjust)}}draw(e,t,s,o,n,a="middle"){if(this.elementOptions.label===void 0)return;let d=this.fontOptions.size*this.body.view.scale;this.elementOptions.label&&d=this.elementOptions.scaling.label.maxVisible&&(d=Number(this.elementOptions.scaling.label.maxVisible)/this.body.view.scale),this.calculateLabelSize(e,o,n,t,s,a),this._drawBackground(e),this._drawText(e,t,this.size.yLine,a,d))}_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,s,o="middle",n){[t,s]=this._setAlignment(e,t,s,o),e.textAlign="left",t=t-this.size.width/2,this.fontOptions.valign&&this.size.height>this.size.labelHeight&&(this.fontOptions.valign==="top"&&(s-=(this.size.height-this.size.labelHeight)/2),this.fontOptions.valign==="bottom"&&(s+=(this.size.height-this.size.labelHeight)/2));for(let a=0;a0&&(e.lineWidth=c.strokeWidth,e.strokeStyle=f,e.lineJoin="round"),e.fillStyle=u,c.strokeWidth>0&&e.strokeText(c.text,t+h,s+c.vadjust),e.fillText(c.text,t+h,s+c.vadjust),h+=c.width}s+=d.height}}}_setAlignment(e,t,s,o){if(this.isEdgeLabel&&this.fontOptions.align!=="horizontal"&&this.pointToSelf===!1){t=0,s=0;let n=2;this.fontOptions.align==="top"?(e.textBaseline="alphabetic",s-=2*n):this.fontOptions.align==="bottom"?(e.textBaseline="hanging",s+=2*n):e.textBaseline="middle"}else e.textBaseline=o;return[t,s]}_getColor(e,t,s){let o=e||"#000000",n=s||"#ffffff";if(t<=this.elementOptions.scaling.label.drawThreshold){let a=Math.max(0,Math.min(1,1-(this.elementOptions.scaling.label.drawThreshold-t)));o=ue(o,a),n=ue(n,a)}return[o,n]}getTextSize(e,t=!1,s=!1){return this._processLabel(e,t,s),{width:this.size.width,height:this.size.height,lineCount:this.lineCount}}getSize(){let t=this.size.left,s=this.size.top-.5*2;if(this.isEdgeLabel){let n=-this.size.width*.5;switch(this.fontOptions.align){case"middle":t=n,s=-this.size.height*.5;break;case"top":t=n,s=-(this.size.height+2);break;case"bottom":t=n,s=2;break}}return{left:t,top:s,width:this.size.width,height:this.size.height}}calculateLabelSize(e,t,s,o=0,n=0,a="middle"){this._processLabel(e,t,s),this.size.left=o-this.size.width*.5,this.size.top=n-this.size.height*.5,this.size.yLine=n+(1-this.lineCount)*.5*this.fontOptions.size,a==="hanging"&&(this.size.top+=.5*this.fontOptions.size,this.size.top+=4,this.size.yLine+=4)}getFormattingValues(e,t,s,o){let n=function(h,l,c){return l==="normal"?c==="mod"?"":h[c]:h[l][c]!==void 0?h[l][c]:h[c]},a={color:n(this.fontOptions,o,"color"),size:n(this.fontOptions,o,"size"),face:n(this.fontOptions,o,"face"),mod:n(this.fontOptions,o,"mod"),vadjust:n(this.fontOptions,o,"vadjust"),strokeWidth:this.fontOptions.strokeWidth,strokeColor:this.fontOptions.strokeColor};(t||s)&&(o==="normal"&&this.fontOptions.chooser===!0&&this.elementOptions.labelHighlightBold?a.mod="bold":typeof this.fontOptions.chooser=="function"&&this.fontOptions.chooser(a,this.elementOptions.id,t,s));let d="";return a.mod!==void 0&&a.mod!==""&&(d+=a.mod+" "),d+=a.size+"px "+a.face,e.font=d.replace(/"/g,""),a.font=e.font,a.height=a.size,a}differentState(e,t){return e!==this.selectedState||t!==this.hoverState}_processLabelText(e,t,s,o){return new Yi(e,this,t,s).process(o)}_processLabel(e,t,s){if(this.labelDirty===!1&&!this.differentState(t,s))return;let o=this._processLabelText(e,t,s,this.elementOptions.label);this.fontOptions.minWdt>0&&o.width0&&o.height0&&(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,s,o,n){s!==void 0&&this.resize(s,o,n),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,s,o,n){this._updateBoundingBox(e,t,s,o,n)}getDimensionsFromLabel(e,t,s){this.textSize=this.labelModule.getTextSize(e,t,s);let o=this.textSize.width,n=this.textSize.height,a=14;return o===0&&(o=a,n=a),{width:o,height:n}}},wa=class extends Fe{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t=this.selected,s=this.hover){if(this.needsRefresh(t,s)){let o=this.getDimensionsFromLabel(e,t,s);this.width=o.width+this.margin.right+this.margin.left,this.height=o.height+this.margin.top+this.margin.bottom,this.radius=this.width/2}}draw(e,t,s,o,n,a){this.resize(e,o,n),this.left=t-this.width/2,this.top=s-this.height/2,this.initContextForDraw(e,a),on(e,this.left,this.top,this.width,this.height,a.borderRadius),this.performFill(e,a),this.updateBoundingBox(t,s,e,o,n),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,o,n)}updateBoundingBox(e,t,s,o,n){this._updateBoundingBox(e,t,s,o,n);let a=this.options.shapeProperties.borderRadius;this._addBoundingBoxMargin(a)}distanceToBorder(e,t){e&&this.resize(e);let s=this.options.borderWidth;return Math.min(Math.abs(this.width/2/Math.cos(t)),Math.abs(this.height/2/Math.sin(t)))+s}},St=class extends Fe{constructor(e,t,s){super(e,t,s),this.labelOffset=0,this.selected=!1}setOptions(e,t,s){this.options=e,t===void 0&&s===void 0||this.setImages(t,s)}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 s=this.imageObj;this.imageObj=this.imageObjAlt,this.imageObjAlt=s}}_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 s=1,o=1;this.imageObj.width&&this.imageObj.height&&(this.imageObj.width>this.imageObj.height?s=this.imageObj.width/this.imageObj.height:o=this.imageObj.height/this.imageObj.width),e=this.options.size*2*s,t=this.options.size*2*o}else{let s=this._getImagePadding();e=this.imageObj.width+s.left+s.right,t=this.imageObj.height+s.top+s.bottom}this.width=e,this.height=t,this.radius=.5*this.width}_drawRawCircle(e,t,s,o){this.initContextForDraw(e,o),Ls(e,t,s,o.size),this.performFill(e,o)}_drawImageAtPosition(e,t){if(this.imageObj.width!=0){e.globalAlpha=t.opacity!==void 0?t.opacity:1,this.enableShadow(e,t);let s=1;this.options.shapeProperties.interpolation===!0&&(s=this.imageObj.width/this.width/this.body.view.scale);let o=this._getImagePadding(),n=this.left+o.left,a=this.top+o.top,d=this.width-o.left-o.right,h=this.height-o.top-o.bottom;this.imageObj.drawImageAtPosition(e,s,n,a,d,h),this.disableShadow(e,t)}}_drawImageLabel(e,t,s,o,n){let a=0;if(this.height!==void 0){a=this.height*.5;let h=this.labelModule.getTextSize(e,o,n);h.lineCount>=1&&(a+=h.height/2)}let d=s+a;this.options.label&&(this.labelOffset=a),this.labelModule.draw(e,t,d,o,n,"hanging")}},_a=class extends St{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t=this.selected,s=this.hover){if(this.needsRefresh(t,s)){let o=this.getDimensionsFromLabel(e,t,s),n=Math.max(o.width+this.margin.right+this.margin.left,o.height+this.margin.top+this.margin.bottom);this.options.size=n/2,this.width=n,this.height=n,this.radius=this.width/2}}draw(e,t,s,o,n,a){this.resize(e,o,n),this.left=t-this.width/2,this.top=s-this.height/2,this._drawRawCircle(e,t,s,a),this.updateBoundingBox(t,s),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,s,o,n)}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}},Ui=class extends St{constructor(e,t,s,o,n){super(e,t,s),this.setImages(o,n)}resize(e,t=this.selected,s=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let n=this.options.size*2;this.width=n,this.height=n,this.radius=.5*this.width;return}this.needsRefresh(t,s)&&this._resizeImage()}draw(e,t,s,o,n,a){this.switchImages(o),this.resize();let d=t,h=s;this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=s,d+=this.width/2,h+=this.height/2):(this.left=t-this.width/2,this.top=s-this.height/2),this._drawRawCircle(e,d,h,a),e.save(),e.clip(),this._drawImageAtPosition(e,a),e.restore(),this._drawImageLabel(e,d,h,o,n),this.updateBoundingBox(t,s)}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}},Ce=class extends Fe{constructor(e,t,s){super(e,t,s)}resize(e,t=this.selected,s=this.hover,o={size:this.options.size}){var n,a;if(this.needsRefresh(t,s)){this.labelModule.getTextSize(e,t,s);let d=2*o.size;this.width=(n=this.customSizeWidth)!=null?n:d,this.height=(a=this.customSizeHeight)!=null?a:d,this.radius=.5*this.width}}_drawShape(e,t,s,o,n,a,d,h){return this.resize(e,a,d,h),this.left=o-this.width/2,this.top=n-this.height/2,this.initContextForDraw(e,h),Gr(t)(e,o,n,h.size),this.performFill(e,h),this.options.icon!==void 0&&this.options.icon.code!==void 0&&(e.font=(a?"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,o,n)),{drawExternalLabel:()=>{if(this.options.label!==void 0){this.labelModule.calculateLabelSize(e,a,d,o,n,"hanging");let l=n+.5*this.height+.5*this.labelModule.size.height;this.labelModule.draw(e,o,l,a,d,"hanging")}this.updateBoundingBox(o,n)}}}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))}},Xi=class extends Ce{constructor(e,t,s,o){super(e,t,s,o),this.ctxRenderer=o}draw(e,t,s,o,n,a){this.resize(e,o,n,a),this.left=t-this.width/2,this.top=s-this.height/2,e.save();let d=this.ctxRenderer({ctx:e,id:this.options.id,x:t,y:s,state:{selected:o,hover:n},style:be({},a),label:this.options.label});if(d.drawNode!=null&&d.drawNode(),e.restore(),d.drawExternalLabel){let h=d.drawExternalLabel;d.drawExternalLabel=()=>{e.save(),h(),e.restore()}}return d.nodeDimensions&&(this.customSizeWidth=d.nodeDimensions.width,this.customSizeHeight=d.nodeDimensions.height),d}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Gi=class extends Fe{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t,s){if(this.needsRefresh(t,s)){let n=this.getDimensionsFromLabel(e,t,s).width+this.margin.right+this.margin.left;this.width=n,this.height=n,this.radius=this.width/2}}draw(e,t,s,o,n,a){this.resize(e,o,n),this.left=t-this.width/2,this.top=s-this.height/2,this.initContextForDraw(e,a),nn(e,t-this.width/2,s-this.height/2,this.width,this.height),this.performFill(e,a),this.updateBoundingBox(t,s,e,o,n),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,o,n)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ea=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"diamond",4,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ki=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"circle",2,t,s,o,n,a)}distanceToBorder(e){return e&&this.resize(e),this.options.size}},Jt=class extends Fe{constructor(e,t,s){super(e,t,s)}resize(e,t=this.selected,s=this.hover){if(this.needsRefresh(t,s)){let o=this.getDimensionsFromLabel(e,t,s);this.height=o.height*2,this.width=o.width+o.height,this.radius=.5*this.width}}draw(e,t,s,o,n,a){this.resize(e,o,n),this.left=t-this.width*.5,this.top=s-this.height*.5,this.initContextForDraw(e,a),Li(e,this.left,this.top,this.width,this.height),this.performFill(e,a),this.updateBoundingBox(t,s,e,o,n),this.labelModule.draw(e,t,s,o,n)}distanceToBorder(e,t){e&&this.resize(e);let s=this.width*.5,o=this.height*.5,n=Math.sin(t)*s,a=Math.cos(t)*o;return s*o/Math.sqrt(n*n+a*a)}},$i=class extends Fe{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t,s){this.needsRefresh(t,s)&&(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,s,o,n,a){return this.resize(e,o,n),this.options.icon.size=this.options.icon.size||50,this.left=t-this.width/2,this.top=s-this.height/2,this._icon(e,t,s,o,n,a),{drawExternalLabel:()=>{this.options.label!==void 0&&this.labelModule.draw(e,this.left+this.iconSize.width/2+this.margin.left,s+this.height/2+5,o),this.updateBoundingBox(t,s)}}}updateBoundingBox(e,t){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&&(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+5))}_icon(e,t,s,o,n,a){let d=Number(this.options.icon.size);this.options.icon.code!==void 0?(e.font=[this.options.icon.weight!=null?this.options.icon.weight:o?"bold":"",(this.options.icon.weight!=null&&o?5:0)+d+"px",this.options.icon.face].join(" "),e.fillStyle=this.options.icon.color||"black",e.textAlign="center",e.textBaseline="middle",this.enableShadow(e,a),e.fillText(this.options.icon.code,t,s),this.disableShadow(e,a)):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)}},xa=class extends St{constructor(e,t,s,o,n){super(e,t,s),this.setImages(o,n)}resize(e,t=this.selected,s=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let n=this.options.size*2;this.width=n,this.height=n;return}this.needsRefresh(t,s)&&this._resizeImage()}draw(e,t,s,o,n,a){e.save(),this.switchImages(o),this.resize();let d=t,h=s;if(this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=s,d+=this.width/2,h+=this.height/2):(this.left=t-this.width/2,this.top=s-this.height/2),this.options.shapeProperties.useBorderWithImage===!0){let l=this.options.borderWidth,c=this.options.borderWidthSelected||2*this.options.borderWidth,u=(o?c:l)/this.body.view.scale;e.lineWidth=Math.min(this.width,u),e.beginPath();let f=o?this.options.color.highlight.border:n?this.options.color.hover.border:this.options.color.border,p=o?this.options.color.highlight.background:n?this.options.color.hover.background:this.options.color.background;a.opacity!==void 0&&(f=ue(f,a.opacity),p=ue(p,a.opacity)),e.strokeStyle=f,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,a),e.closePath()}this._drawImageAtPosition(e,a),this._drawImageLabel(e,d,h,o,n),this.updateBoundingBox(t,s),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)}},Zi=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"square",2,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Qi=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"hexagon",4,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ji=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"star",4,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},es=class extends Fe{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t,s){this.needsRefresh(t,s)&&(this.textSize=this.labelModule.getTextSize(e,t,s),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,s,o,n,a){this.resize(e,o,n),this.left=t-this.width/2,this.top=s-this.height/2,this.enableShadow(e,a),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,o,n),this.disableShadow(e,a),this.updateBoundingBox(t,s,e,o,n)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ta=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"triangle",3,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},ts=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"triangleDown",3,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},ne=class r{constructor(e,t,s,o,n,a){this.options=Me(n),this.globalOptions=n,this.defaultOptions=a,this.body=t,this.edges=[],this.id=void 0,this.imagelist=s,this.grouplist=o,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 Qt(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");r.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)),r.parseOptions(this.options,e,!0,this.globalOptions,this.grouplist);let s=[e,this.options,this.defaultOptions];return this.chooser=js("node",s),this._load_images(),this.updateLabelModule(e),e.opacity!==void 0&&r.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,s){if(s===void 0)return;let o=e.group;if(t!==void 0&&t.group!==void 0&&o!==t.group)throw new Error("updateGroupOptions: group values in options don't match.");if(!(typeof o=="number"||typeof o=="string"&&o!=""))return;let a=s.get(o);a.opacity!==void 0&&t.opacity===void 0&&(r.checkOpacity(a.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+a.opacity),a.opacity=void 0));let d=Object.getOwnPropertyNames(t).filter(h=>t[h]!=null);d.push("font"),Tt(d,e,a),e.color=Vt(e.color)}static parseOptions(e,t,s=!1,o={},n){if(Tt(["color","fixed","shadow"],e,t,s),r.checkMass(t),e.opacity!==void 0&&(r.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&&(r.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&&!r.checkCoordinateOrigin(t.shapeProperties.coordinateOrigin)&&console.error("Invalid option for node coordinateOrigin, found: "+t.shapeProperties.coordinateOrigin),fe(e,t,"shadow",o),t.color!==void 0&&t.color!==null){let d=Vt(t.color);Ii(e.color,d)}else s===!0&&t.color===null&&(e.color=Me(o.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))),s===!0&&t.font===null&&(e.font=Me(o.font)),r.updateGroupOptions(e,t,n),t.scaling!==void 0&&fe(e.scaling,t.scaling,"label",o.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=ue(e.borderColor,t),e.color=ue(e.color,t),e.shadowColor=ue(e.shadowColor,t)}return e}updateLabelModule(e){(this.options.label===void 0||this.options.label===null)&&(this.options.label=""),r.updateGroupOptions(this.options,je(be({},e),{color:e&&e.color||this._localColor||void 0}),this.grouplist);let t=this.grouplist.get(this.options.group,!1),s=[e,this.options,t,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,s),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 wa(this.options,this.body,this.labelModule);break;case"circle":this.shape=new _a(this.options,this.body,this.labelModule);break;case"circularImage":this.shape=new Ui(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"custom":this.shape=new Xi(this.options,this.body,this.labelModule,this.options.ctxRenderer);break;case"database":this.shape=new Gi(this.options,this.body,this.labelModule);break;case"diamond":this.shape=new Ea(this.options,this.body,this.labelModule);break;case"dot":this.shape=new Ki(this.options,this.body,this.labelModule);break;case"ellipse":this.shape=new Jt(this.options,this.body,this.labelModule);break;case"icon":this.shape=new $i(this.options,this.body,this.labelModule);break;case"image":this.shape=new xa(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"square":this.shape=new Zi(this.options,this.body,this.labelModule);break;case"hexagon":this.shape=new Qi(this.options,this.body,this.labelModule);break;case"star":this.shape=new Ji(this.options,this.body,this.labelModule);break;case"text":this.shape=new es(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 ts(this.options,this.body,this.labelModule);break;default:this.shape=new Jt(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,s){if(this.options.value!==void 0){let o=this.options.scaling.customScalingFunction(e,t,s,this.options.value),n=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let a=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+o*a}this.options.size=this.options.scaling.min+o*n}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()&&Vi(this.labelModule.getSize(),e)&&t.push({nodeId:this.id,labelId:0}),Vi(this.shape.boundingBox,e)&&t.push({nodeId:this.id}),t}isOverlappingWith(e){return this.shape.lefte.left&&this.shape.tope.top}isBoundingBoxOverlappingWith(e){return this.shape.boundingBox.lefte.left&&this.shape.boundingBox.tope.top}static checkMass(e,t){if(e.mass!==void 0&&e.mass<=0){let s="";t!==void 0&&(s=" in node id: "+t),console.error("%cNegative or zero mass disallowed"+s+", setting mass to 1.",Mi),e.mass=1}}},is=class{constructor(e,t,s,o){if(this.body=e,this.images=t,this.groups=s,this.layoutEngine=o,this.body.functions.createNode=this.create.bind(this),this.nodesListeners={add:(n,a)=>{this.add(a.items)},update:(n,a)=>{this.update(a.items,a.data,a.oldData)},remove:(n,a)=>{this.remove(a.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(n,a,d,h){if(a===n)return .5;{let l=1/(a-n);return Math.max(0,(h-n)*l)}}},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=Me(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",()=>{F(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(ne.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 s=this.body.data.nodes;if(Bi("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(s&&F(this.nodesListeners,function(o,n){s.off(n,o)}),this.body.nodes={},this.body.data.nodes){let o=this;F(this.nodesListeners,function(a,d){o.body.data.nodes.on(d,a)});let n=this.body.data.nodes.getIds();this.add(n,!0)}t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let s,o=[];for(let n=0;n{let o=this.body.data.nodes.get(s);o!==void 0&&(e===!0&&t.setOptions({x:null,y:null}),t.setOptions({fixed:!1}),t.setOptions(o))})}getPositions(e){let t={};if(e!==void 0){if(Array.isArray(e)===!0){for(let s=0;s{this.body.emitter.emit("startSimulation")},0)):console.error("Node id supplied to moveNode does not exist. Provided: ",e)}},U=class{static transform(e,t){Array.isArray(e)||(e=[e]);let s=t.point.x,o=t.point.y,n=t.angle,a=t.length;for(let d=0;d0?h>0?a=p:d=p:h>0?d=p:a=p,++_}while(a<=d&&_1?c=1:c<0&&(c=0);let u=e+c*d,f=t+c*h,p=u-n,g=f-a;return Math.sqrt(p*p+g*g)}getArrowData(e,t,s,o,n,a){let d,h,l,c,u,f,p,g=a.width;t==="from"?(l=this.from,c=this.to,u=a.fromArrowScale<0,f=Math.abs(a.fromArrowScale),p=a.fromArrowType):t==="to"?(l=this.to,c=this.from,u=a.toArrowScale<0,f=Math.abs(a.toArrowScale),p=a.toArrowType):(l=this.to,c=this.from,u=a.middleArrowScale<0,f=Math.abs(a.middleArrowScale),p=a.middleArrowType);let _=15*f+3*g;if(l!=c){let O=Math.hypot(l.x-c.x,l.y-c.y),P=_/O;if(t!=="middle")if(this.options.smooth.enabled===!0){let D=this._findBorderPosition(l,e,{via:s}),N=this.getPoint(D.t+P*(t==="from"?1:-1),s);d=Math.atan2(D.y-N.y,D.x-N.x),h=D}else d=Math.atan2(l.y-c.y,l.x-c.x),h=this._findBorderPosition(l,e);else{let D=(u?-P:P)/2,N=this.getPoint(.5+D,s),W=this.getPoint(.5-D,s);d=Math.atan2(N.y-W.y,N.x-W.x),h=this.getPoint(.5,s)}}else{let[O,P,D]=this._getCircleData(e);if(t==="from"){let N=this.options.selfReference.angle,W=this.options.selfReference.angle+Math.PI,X=this._findBorderPositionCircle(this.from,e,{x:O,y:P,low:N,high:W,direction:-1});d=X.t*-2*Math.PI+1.5*Math.PI+.1*Math.PI,h=X}else if(t==="to"){let N=this.options.selfReference.angle,W=this.options.selfReference.angle+Math.PI,X=this._findBorderPositionCircle(this.from,e,{x:O,y:P,low:N,high:W,direction:1});d=X.t*-2*Math.PI+1.5*Math.PI-1.1*Math.PI,h=X}else{let N=this.options.selfReference.angle/(2*Math.PI);h=this._pointOnCircle(O,P,D,N),d=N*-2*Math.PI+1.5*Math.PI+.1*Math.PI}}let m=h.x-_*.9*Math.cos(d),v=h.y-_*.9*Math.sin(d);return{point:h,core:{x:m,y:v},angle:d,length:_,type:p}}drawArrowHead(e,t,s,o,n){e.strokeStyle=this.getColor(e,t),e.fillStyle=e.strokeStyle,e.lineWidth=t.width,ei.draw(e,n)&&(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 s={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=s.strokeStyle,e.lineWidth=s.lineWidth,e.dashes=s.dashes,this.setStrokeDashed(e,t.dashes)}}setStrokeDashed(e,t){if(t!==!1)if(e.setLineDash!==void 0){let s=Array.isArray(t)?t:[5,5];e.setLineDash(s)}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.")}},It=class extends ti{constructor(e,t,s){super(e,t,s)}_findBorderPositionBezier(e,t,s=this._getViaCoordinates()){let a=!1,d=1,h=0,l=this.to,c,u,f=this.options.endPointOffset?this.options.endPointOffset.to:0;e.id===this.from.id&&(l=this.from,a=!0,f=this.options.endPointOffset?this.options.endPointOffset.from:0),this.options.arrowStrikethrough===!1&&(f=0);let p=0;do{u=(h+d)*.5,c=this.getPoint(u,s);let g=Math.atan2(l.y-c.y,l.x-c.x),_=l.distanceToBorder(t,g)+f,m=Math.sqrt(Math.pow(c.x-l.x,2)+Math.pow(c.y-l.y,2)),v=_-m;if(Math.abs(v)<.2)break;v<0?a===!1?h=u:d=u:a===!1?d=u:h=u,++p}while(h<=d&&p<10);return je(be({},c),{t:u})}_getDistanceToBezierEdge(e,t,s,o,n,a,d){let h=1e9,l,c,u,f,p,g=e,_=t;for(c=1;c<10;c++)u=.1*c,f=Math.pow(1-u,2)*e+2*u*(1-u)*d.x+Math.pow(u,2)*s,p=Math.pow(1-u,2)*t+2*u*(1-u)*d.y+Math.pow(u,2)*o,c>0&&(l=this._getDistanceToLine(g,_,f,p,n,a),h=l{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,s){this._bezierCurve(e,t,s)}_getViaCoordinates(){return this.via}getViaNode(){return this.via}getPoint(e,t=this.via){if(this.from===this.to){let[s,o,n]=this._getCircleData(),a=2*Math.PI*(1-e);return{x:s+n*Math.sin(a),y:o+n-n*(1-Math.cos(a))}}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,s,o,n,a){return this._getDistanceToBezierEdge(e,t,s,o,n,a,this.via)}},si=class extends It{constructor(e,t,s){super(e,t,s)}_line(e,t,s){this._bezierCurve(e,t,s)}getViaNode(){return this._getViaCoordinates()}_getViaCoordinates(){let e=this.options.smooth.roundness,t=this.options.smooth.type,s=Math.abs(this.from.x-this.to.x),o=Math.abs(this.from.y-this.to.y);if(t==="discrete"||t==="diagonalCross"){let n,a;s<=o?n=a=e*o:n=a=e*s,this.from.x>this.to.x&&(n=-n),this.from.y>=this.to.y&&(a=-a);let d=this.from.x+n,h=this.from.y+a;return t==="discrete"&&(s<=o?d=sthis.to.x&&(n=-n),this.from.y>=this.to.y&&(a=-a);let d=this.from.x+n,h=this.from.y+a;return s<=o?this.from.x<=this.to.x?d=this.to.xd?this.to.x:d:this.from.y>=this.to.y?h=this.to.y>h?this.to.y:h:h=this.to.y0){let v=this._getDistanceToLine(c,u,_,m,n,a);l=vMath.abs(t)||this.options.smooth.forceDirection===!0||this.options.smooth.forceDirection==="horizontal")&&this.options.smooth.forceDirection!=="vertical"?(o=this.from.y,a=this.to.y,s=this.from.x-d*e,n=this.to.x+d*e):(o=this.from.y-d*t,a=this.to.y+d*t,s=this.from.x,n=this.to.x),[{x:s,y:o},{x:n,y:a}]}getViaNode(){return this._getViaCoordinates()}_findBorderPosition(e,t){return this._findBorderPositionBezier(e,t)}_getDistanceToEdge(e,t,s,o,n,a,[d,h]=this._getViaCoordinates()){return this._getDistanceToBezierEdge2(e,t,s,o,n,a,d,h)}getPoint(e,[t,s]=this._getViaCoordinates()){let o=e,n=[Math.pow(1-o,3),3*o*Math.pow(1-o,2),3*Math.pow(o,2)*(1-o),Math.pow(o,3)],a=n[0]*this.fromPoint.x+n[1]*t.x+n[2]*s.x+n[3]*this.toPoint.x,d=n[0]*this.fromPoint.y+n[1]*t.y+n[2]*s.y+n[3]*this.toPoint.y;return{x:a,y:d}}},ni=class extends ti{constructor(e,t,s){super(e,t,s)}_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 s=this.to,o=this.from;e.id===this.from.id&&(s=this.from,o=this.to);let n=Math.atan2(s.y-o.y,s.x-o.x),a=s.x-o.x,d=s.y-o.y,h=Math.sqrt(a*a+d*d),l=e.distanceToBorder(t,n),c=(h-l)/h;return{x:(1-c)*o.x+c*s.x,y:(1-c)*o.y+c*s.y,t:0}}_getDistanceToEdge(e,t,s,o,n,a){return this._getDistanceToLine(e,t,s,o,n,a)}},Le=class r{constructor(e,t,s,o,n){if(t===void 0)throw new Error("No body provided");this.options=Me(o),this.globalOptions=o,this.defaultOptions=n,this.body=t,this.imagelist=s,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 Qt(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;r.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 s=[e,this.options,this.defaultOptions];return this.chooser=js("edge",s),this.updateLabelModule(e),t=this.updateEdgeType()||t,this._setInteractionWidths(),this.connect(),t}static parseOptions(e,t,s=!1,o={},n=!1){if($e(["endPointOffset","arrowStrikethrough","id","from","hidden","hoverWidth","labelHighlightBold","length","line","opacity","physics","scaling","selectionWidth","selfReferenceSize","selfReference","to","title","value","width","font","chosen","widthConstraint"],e,t,s),t.endPointOffset!==void 0&&t.endPointOffset.from!==void 0&&(Number.isFinite(t.endPointOffset.from)?e.endPointOffset.from=t.endPointOffset.from:(e.endPointOffset.from=o.endPointOffset.from!==void 0?o.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=o.endPointOffset.to!==void 0?o.endPointOffset.to:0,console.error("endPointOffset.to is not a valid number"))),$t(t.label)?e.label=t.label:$t(e.label)||(e.label=void 0),fe(e,t,"smooth",o),fe(e,t,"shadow",o),fe(e,t,"background",o),t.dashes!==void 0&&t.dashes!==null?e.dashes=t.dashes:s===!0&&t.dashes===null&&(e.dashes=Object.create(o.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),fe(e.scaling,t.scaling,"label",o.scaling)):s===!0&&t.scaling===null&&(e.scaling=Object.create(o.scaling)),t.arrows!==void 0&&t.arrows!==null)if(typeof t.arrows=="string"){let d=t.arrows.toLowerCase();e.arrows.to.enabled=d.indexOf("to")!=-1,e.arrows.middle.enabled=d.indexOf("middle")!=-1,e.arrows.from.enabled=d.indexOf("from")!=-1}else if(typeof t.arrows=="object")fe(e.arrows,t.arrows,"to",o.arrows),fe(e.arrows,t.arrows,"middle",o.arrows),fe(e.arrows,t.arrows,"from",o.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 s===!0&&t.arrows===null&&(e.arrows=Object.create(o.arrows));if(t.color!==void 0&&t.color!==null){let d=Ie(t.color)?{color:t.color,highlight:t.color,hover:t.color,inherit:!1,opacity:1}:t.color,h=e.color;if(n)V(h,o.color,!1,s);else for(let l in h)Object.prototype.hasOwnProperty.call(h,l)&&delete h[l];if(Ie(h))h.color=h,h.highlight=h,h.hover=h,h.inherit=!1,d.opacity===void 0&&(h.opacity=1);else{let l=!1;d.color!==void 0&&(h.color=d.color,l=!0),d.highlight!==void 0&&(h.highlight=d.highlight,l=!0),d.hover!==void 0&&(h.hover=d.hover,l=!0),d.inherit!==void 0&&(h.inherit=d.inherit),d.opacity!==void 0&&(h.opacity=Math.min(1,Math.max(0,d.opacity))),l===!0?h.inherit=!1:h.inherit===void 0&&(h.inherit="from")}}else s===!0&&t.color===null&&(e.color=Me(o.color));s===!0&&t.font===null&&(e.font=Me(o.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,s=this.options.arrows.middle===!0||this.options.arrows.middle.enabled===!0,o=this.options.color.inherit,n={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:s,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:o?void 0:this.options.color.color,inheritsColor:o,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 a=this.options.selectionWidth;typeof a=="function"?n.width=a(n.width):typeof a=="number"&&(n.width+=a),n.width=Math.max(n.width,.3/this.body.view.scale),n.color=this.options.color.highlight,n.shadow=this.options.shadow.enabled}else if(this.hover){let a=this.options.hoverWidth;typeof a=="function"?n.width=a(n.width):typeof a=="number"&&(n.width+=a),n.width=Math.max(n.width,.3/this.body.view.scale),n.color=this.options.color.hover,n.shadow=this.options.shadow.enabled}}else typeof this.chooser=="function"&&(this.chooser(n,this.options.id,this.selected,this.hover),n.color!==void 0&&(n.inheritsColor=!1),n.shadow===!1&&(n.shadowColor!==this.options.shadow.color||n.shadowSize!==this.options.shadow.size||n.shadowX!==this.options.shadow.x||n.shadowY!==this.options.shadow.y)&&(n.shadow=!0));else n.shadow=this.options.shadow.enabled,n.width=Math.max(n.width,.3/this.body.view.scale);return n}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,s=!0;return this.edgeType!==void 0&&((this.edgeType instanceof ii&&e.enabled===!0&&e.type==="dynamic"||this.edgeType instanceof oi&&e.enabled===!0&&e.type==="cubicBezier"||this.edgeType instanceof si&&e.enabled===!0&&e.type!=="dynamic"&&e.type!=="cubicBezier"||this.edgeType instanceof ni&&e.type.enabled===!1)&&(s=!1),s===!0&&(t=this.cleanup())),s===!0?e.enabled===!0?e.type==="dynamic"?(t=!0,this.edgeType=new ii(this.options,this.body,this.labelModule)):e.type==="cubicBezier"?this.edgeType=new oi(this.options,this.body,this.labelModule):this.edgeType=new si(this.options,this.body,this.labelModule):this.edgeType=new ni(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,s){if(this.options.value!==void 0){let o=this.options.scaling.customScalingFunction(e,t,s,this.options.value),n=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let a=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+o*a}this.options.width=this.options.scaling.min+o*n}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 s=this.edgeType.getViaNode();this.edgeType.drawLine(e,t,this.selected,this.hover,s),this.drawLabel(e,s)}drawArrows(e){let t=this.getFormattingValues();if(t.hidden)return;let s=this.edgeType.getViaNode(),o={};this.edgeType.fromPoint=this.edgeType.from,this.edgeType.toPoint=this.edgeType.to,t.fromArrow&&(o.from=this.edgeType.getArrowData(e,"from",s,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.fromPoint=o.from.core),t.fromArrowSrc&&(o.from.image=this.imagelist.load(t.fromArrowSrc)),t.fromArrowImageWidth&&(o.from.imageWidth=t.fromArrowImageWidth),t.fromArrowImageHeight&&(o.from.imageHeight=t.fromArrowImageHeight)),t.toArrow&&(o.to=this.edgeType.getArrowData(e,"to",s,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.toPoint=o.to.core),t.toArrowSrc&&(o.to.image=this.imagelist.load(t.toArrowSrc)),t.toArrowImageWidth&&(o.to.imageWidth=t.toArrowImageWidth),t.toArrowImageHeight&&(o.to.imageHeight=t.toArrowImageHeight)),t.middleArrow&&(o.middle=this.edgeType.getArrowData(e,"middle",s,this.selected,this.hover,t),t.middleArrowSrc&&(o.middle.image=this.imagelist.load(t.middleArrowSrc)),t.middleArrowImageWidth&&(o.middle.imageWidth=t.middleArrowImageWidth),t.middleArrowImageHeight&&(o.middle.imageHeight=t.middleArrowImageHeight)),t.fromArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,o.from),t.middleArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,o.middle),t.toArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,o.to)}drawLabel(e,t){if(this.options.label!==void 0){let s=this.from,o=this.to;this.labelModule.differentState(this.selected,this.hover)&&this.labelModule.getTextSize(e,this.selected,this.hover);let n;if(s.id!=o.id){this.labelModule.pointToSelf=!1,n=this.edgeType.getPoint(.5,t),e.save();let a=this._getRotation(e);a.angle!=0&&(e.translate(a.x,a.y),e.rotate(a.angle)),this.labelModule.draw(e,n.x,n.y,this.selected,this.hover),e.restore()}else{this.labelModule.pointToSelf=!0;let a=pn(e,this.options.selfReference.angle,this.options.selfReference.size,s);n=this._pointOnCircle(a.x,a.y,this.options.selfReference.size,this.options.selfReference.angle),this.labelModule.draw(e,n.x,n.y,this.selected,this.hover)}}}getItemsOnPoint(e){let t=[];if(this.labelModule.visible()){let o=this._getRotation();Vi(this.labelModule.getSize(),e,o)&&t.push({edgeId:this.id,labelId:0})}let s={left:e.x,top:e.y};return this.isOverlappingWith(s)&&t.push({edgeId:this.id}),t}isOverlappingWith(e){if(this.connected){let s=this.from.x,o=this.from.y,n=this.to.x,a=this.to.y,d=e.left,h=e.top;return this.edgeType.getDistanceToEdge(s,o,n,a,d,h)<10}else return!1}_getRotation(e){let t=this.edgeType.getViaNode(),s=this.edgeType.getPoint(.5,t);e!==void 0&&this.labelModule.calculateLabelSize(e,this.selected,this.hover,s.x,s.y);let o={x:s.x,y:this.labelModule.size.yLine,angle:0};if(!this.labelModule.visible()||this.options.font.align==="horizontal")return o;let n=this.from.y-this.to.y,a=this.from.x-this.to.x,d=Math.atan2(n,a);return(d<-1&&a<0||d>0&&a<0)&&(d+=Math.PI),o.angle=d,o}_pointOnCircle(e,t,s,o){return{x:e+s*Math.cos(o),y:t-s*Math.sin(o)}}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}},gs=class{constructor(e,t,s){this.body=e,this.images=t,this.groups=s,this.body.functions.createEdge=this.create.bind(this),this.edgesListeners={add:(o,n)=>{this.add(n.items)},update:(o,n)=>{this.update(n.items)},remove:(o,n)=>{this.remove(n.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(o,n,a,d){if(n===o)return .5;{let h=1/(n-o);return Math.max(0,(d-o)*h)}}},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},V(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("_forceDisableDynamicCurves",(e,t=!0)=>{e==="dynamic"&&(e="continuous");let s=!1;for(let o in this.body.edges)if(Object.prototype.hasOwnProperty.call(this.body.edges,o)){let n=this.body.edges[o],a=this.body.data.edges.get(o);if(a!=null){let d=a.smooth;d!==void 0&&d.enabled===!0&&d.type==="dynamic"&&(e===void 0?n.setOptions({smooth:!1}):n.setOptions({smooth:{type:e}}),s=!0)}}t===!0&&s===!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",()=>{F(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){Le.parseOptions(this.options,e,!0,this.defaultOptions,!0);let t=!1;if(e.smooth!==void 0)for(let s in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,s)&&(t=this.body.edges[s].updateEdgeType()||t);if(e.font!==void 0)for(let s in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,s)&&this.body.edges[s].updateLabelModule();(e.hidden!==void 0||e.physics!==void 0||t===!0)&&this.body.emitter.emit("_dataChanged")}}setData(e,t=!1){let s=this.body.data.edges;if(Bi("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(s&&F(this.edgesListeners,(o,n)=>{s.off(n,o)}),this.body.edges={},this.body.data.edges){F(this.edgesListeners,(n,a)=>{this.body.data.edges.on(a,n)});let o=this.body.data.edges.getIds();this.add(o,!0)}this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let s=this.body.edges,o=this.body.data.edges;for(let n=0;n{let n=s[o];n!==void 0&&n.remove()}),t&&this.body.emitter.emit("_dataChanged")}refresh(){F(this.body.edges,(e,t)=>{let s=this.body.data.edges.get(t);s!==void 0&&e.setOptions(s)})}create(e){return new Le(e,this.body,this.images,this.options,this.defaultOptions)}reconnectEdges(){let e,t=this.body.nodes,s=this.body.edges;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&(t[e].edges=[]);for(e in s)if(Object.prototype.hasOwnProperty.call(s,e)){let o=s[e];o.from=null,o.to=null,o.connect()}}getConnectedNodes(e){let t=[];if(this.body.edges[e]!==void 0){let s=this.body.edges[e];s.fromId!==void 0&&t.push(s.fromId),s.toId!==void 0&&t.push(s.toId)}return t}_updateState(){this._addMissingEdges(),this._removeInvalidEdges()}_removeInvalidEdges(){let e=[];F(this.body.edges,(t,s)=>{let o=this.body.nodes[t.toId],n=this.body.nodes[t.fromId];o!==void 0&&o.isCluster===!0||n!==void 0&&n.isCluster===!0||(o===void 0||n===void 0)&&e.push(s)}),this.remove(e,!1)}_addMissingEdges(){let e=this.body.data.edges;if(e==null)return;let t=this.body.edges,s=[];e.forEach((o,n)=>{t[n]===void 0&&s.push(n)}),this.add(s,!0)}},ri=class{constructor(e,t,s){this.body=e,this.physicsBody=t,this.barnesHutTree,this.setOptions(s),this._rng=xt("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,s=this.physicsBody.physicsNodeIndices,o=s.length,n=this._formBarnesHutTree(t,s);this.barnesHutTree=n;for(let a=0;a0&&this._getForceContributions(n.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 s=e.centerOfMass.x-t.x,o=e.centerOfMass.y-t.y,n=Math.sqrt(s*s+o*o);n*e.calcSize>this.thetaInversed?this._calculateForces(n,s,o,t,e):e.childrenCount===4?this._getForceContributions(e,t):e.children.data.id!=t.id&&this._calculateForces(n,s,o,t,e)}}_calculateForces(e,t,s,o,n){e===0&&(e=.1,t=e),this.overlapAvoidanceFactor<1&&o.shape.radius&&(e=Math.max(.1+this.overlapAvoidanceFactor*o.shape.radius,e-o.shape.radius));let a=this.options.gravitationalConstant*n.mass*o.options.mass/Math.pow(e,3),d=t*a,h=s*a;this.physicsBody.forces[o.id].x+=d,this.physicsBody.forces[o.id].y+=h}_formBarnesHutTree(e,t){let s,o=t.length,n=e[t[0]].x,a=e[t[0]].y,d=e[t[0]].x,h=e[t[0]].y;for(let m=1;m0&&(Cd&&(d=C),Oh&&(h=O))}let l=Math.abs(d-n)-Math.abs(h-a);l>0?(a-=.5*l,h+=.5*l):(n+=.5*l,d-=.5*l);let u=Math.max(1e-5,Math.abs(d-n)),f=.5*u,p=.5*(n+d),g=.5*(a+h),_={root:{centerOfMass:{x:0,y:0},mass:0,range:{minX:p-f,maxX:p+f,minY:g-f,maxY:g+f},size:u,calcSize:1/u,children:{data:null},maxWidth:0,level:0,childrenCount:4}};this._splitBranch(_.root);for(let m=0;m0&&this._placeInTree(_.root,s);return _}_updateBranchMass(e,t){let s=e.centerOfMass,o=e.mass+t.options.mass,n=1/o;s.x=s.x*e.mass+t.x*t.options.mass,s.x*=n,s.y=s.y*e.mass+t.y*t.options.mass,s.y*=n,e.mass=o;let a=Math.max(Math.max(t.height,t.radius),t.width);e.maxWidth=e.maxWidtht.x?o.maxY>t.y?n="NW":n="SW":o.maxY>t.y?n="NE":n="SE",this._placeInRegion(e,t,n)}_placeInRegion(e,t,s){let o=e.children[s];switch(o.childrenCount){case 0:o.children.data=t,o.childrenCount=1,this._updateBranchMass(o,t);break;case 1:o.children.data.x===t.x&&o.children.data.y===t.y?(t.x+=this._rng(),t.y+=this._rng()):(this._splitBranch(o),this._placeInTree(o,t));break;case 4:this._placeInTree(o,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 s,o,n,a,d=.5*e.size;switch(t){case"NW":s=e.range.minX,o=e.range.minX+d,n=e.range.minY,a=e.range.minY+d;break;case"NE":s=e.range.minX+d,o=e.range.maxX,n=e.range.minY,a=e.range.minY+d;break;case"SW":s=e.range.minX,o=e.range.minX+d,n=e.range.minY+d,a=e.range.maxY;break;case"SE":s=e.range.minX+d,o=e.range.maxX,n=e.range.minY+d,a=e.range.maxY;break}e.children[t]={centerOfMass:{x:0,y:0},mass:0,range:{minX:s,maxX:o,minY:n,maxY:a},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,s){s===void 0&&(s="#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=s,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()}},ms=class{constructor(e,t,s){this._rng=xt("REPULSION SOLVER"),this.body=e,this.physicsBody=t,this.setOptions(s)}setOptions(e){this.options=e}solve(){let e,t,s,o,n,a,d,h,l=this.body.nodes,c=this.physicsBody.physicsNodeIndices,u=this.physicsBody.forces,f=this.options.nodeDistance,p=-2/3/f,g=4/3;for(let _=0;_0){let a=n.edges.length+1,d=this.options.centralGravity*a*n.options.mass;o[n.id].x=t*d,o[n.id].y=s*d}}},_s=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,Tt(["stabilization"],this.options,e),fe(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 vs(this.body,this.physicsBody,e),this.edgesSolver=new Ot(this.body,this.physicsBody,e),this.gravitySolver=new ws(this.body,this.physicsBody,e)):this.options.solver==="repulsion"?(e=this.options.repulsion,this.nodesSolver=new ms(this.body,this.physicsBody,e),this.edgesSolver=new Ot(this.body,this.physicsBody,e),this.gravitySolver=new rt(this.body,this.physicsBody,e)):this.options.solver==="hierarchicalRepulsion"?(e=this.options.hierarchicalRepulsion,this.nodesSolver=new ys(this.body,this.physicsBody,e),this.edgesSolver=new bs(this.body,this.physicsBody,e),this.gravitySolver=new rt(this.body,this.physicsBody,e)):(e=this.options.barnesHut,this.nodesSolver=new ri(this.body,this.physicsBody,e),this.edgesSolver=new Ot(this.body,this.physicsBody,e),this.gravitySolver=new rt(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(){this._evaluateStepQuality()===!0?this.timestep=1.2*this.timestep:this.timestep/1.2a))return!1;return!0}moveNodes(){let e=this.physicsBody.physicsNodeIndices,t=0,s=0,o=5;for(let n=0;na&&(e=e>0?a:-a),e}_performStep(e){let t=this.body.nodes[e],s=this.physicsBody.forces[e];this.options.wind&&(s.x+=this.options.wind.x,s.y+=this.options.wind.y);let o=this.physicsBody.velocities[e];return this.previousStates[e]={x:t.x,y:t.y,vx:o.x,vy:o.y},t.options.fixed.x===!1?(o.x=this.calculateComponentVelocity(o.x,s.x,t.options.mass),t.x+=o.x*this.timestep):(s.x=0,o.x=0),t.options.fixed.y===!1?(o.y=this.calculateComponentVelocity(o.y,s.y,t.options.mass),t.y+=o.y*this.timestep):(s.y=0,o.y=0),Math.sqrt(Math.pow(o.x,2)+Math.pow(o.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 s=e[t].options.fixed;this.freezeCache[t]={x:s.x,y:s.y},s.x=!0,s.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.body.emitter.emit("stabilizationProgress",{iterations:this.stabilizationIterations,total:this.targetIterations})};this._startStabilizing()&&t();let s=0;for(;e()&&s0)for(let h=0;hd.shape.boundingBox.left&&(n=d.shape.boundingBox.left),ad.shape.boundingBox.top&&(s=d.shape.boundingBox.top),o0)for(let h=0;hd.x&&(n=d.x),ad.y&&(s=d.y),o{delete this.containedEdges[s.id]}),F(t.containedNodes,(s,o)=>{this.containedNodes[o]=s}),t.containedNodes={},F(t.containedEdges,(s,o)=>{this.containedEdges[o]=s}),t.containedEdges={},F(t.edges,s=>{F(this.edges,o=>{let n=o.clusteringEdgeReplacingIds.indexOf(s.id);n!==-1&&(F(s.clusteringEdgeReplacingIds,a=>{o.clusteringEdgeReplacingIds.push(a),this.body.edges[a].edgeReplacedById=o.id}),o.clusteringEdgeReplacingIds.splice(n,1))})}),t.edges=[]}},xs=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 s=[];for(let o=0;o=e&&s.push(n.id)}for(let o=0;o{n.options&&e.joinCondition(n.options)===!0&&(s[a]=n,F(n.edges,d=>{this.clusteredEdges[d.id]===void 0&&(o[d.id]=d)}))}),this._cluster(s,o,e,t)}clusterByEdgeCount(e,t,s=!0){t=this._checkOptions(t);let o=[],n={},a,d,h;for(let l=0;l0&&Object.keys(u).length>0&&_===!0){let v=function(){for(let C=0;C-1&&(a[p.id]=p)}}this._cluster(n,a,t,s)}_createClusterEdges(e,t,s,o){let n,a,d,h,l,c,u=Object.keys(e),f=[];for(let _=0;_o?d.x:o,n=d.ya?d.y:a;return{x:.5*(s+o),y:.5*(n+a)}}openCluster(e,t,s=!0){if(e===void 0)throw new Error("No clusterNodeId supplied to openCluster.");let o=this.body.nodes[e];if(o===void 0)throw new Error("The clusterNodeId supplied to openCluster does not exist.");if(o.isCluster!==!0||o.containedNodes===void 0||o.containedEdges===void 0)throw new Error("The node:"+e+" is not a valid cluster.");let n=this.findNode(e),a=n.indexOf(e)-1;if(a>=0){let c=n[a];this.body.nodes[c]._openChildCluster(e),delete this.body.nodes[e],s===!0&&this.body.emitter.emit("_dataChanged");return}let d=o.containedNodes,h=o.containedEdges;if(t!==void 0&&t.releaseFunction!==void 0&&typeof t.releaseFunction=="function"){let c={},u={x:o.x,y:o.y};for(let p in d)if(Object.prototype.hasOwnProperty.call(d,p)){let g=this.body.nodes[p];c[p]={x:g.x,y:g.y}}let f=t.releaseFunction(u,c);for(let p in d)if(Object.prototype.hasOwnProperty.call(d,p)){let g=this.body.nodes[p];f[p]!==void 0&&(g.x=f[p].x===void 0?o.x:f[p].x,g.y=f[p].y===void 0?o.y:f[p].y)}}else F(d,function(c){c.options.fixed.x===!1&&(c.x=o.x),c.options.fixed.y===!1&&(c.y=o.y)});for(let c in d)if(Object.prototype.hasOwnProperty.call(d,c)){let u=this.body.nodes[c];u.vx=o.vx,u.vy=o.vy,u.setOptions({physics:!0}),delete this.clusteredNodes[c]}let l=[];for(let c=0;c0&&ao&&(o=l.edges.length),e+=l.edges.length,t+=Math.pow(l.edges.length,2),s+=1}e=e/s,t=t/s;let n=t-Math.pow(e,2),a=Math.sqrt(n),d=Math.floor(e+2*a);return d>o&&(d=o),d}_createClusteredEdge(e,t,s,o,n){let a=te.cloneOptions(s,"edge");V(a,o),a.from=e,a.to=t,a.id="clusterEdge:"+Ne(),n!==void 0&&V(a,n);let d=this.body.functions.createEdge(a);return d.clusteringEdgeReplacingIds=[s.id],d.connect(),this.body.edges[d.id]=d,d}_clusterEdges(e,t,s,o){if(t instanceof Le){let n=t,a={};a[n.id]=n,t=a}if(e instanceof ne){let n=e,a={};a[n.id]=n,e=a}if(s==null)throw new Error("_clusterEdges: parameter clusterNode required");o===void 0&&(o=s.clusterEdgeProperties),this._createClusterEdges(e,t,s,o);for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&this.body.edges[n]!==void 0){let a=this.body.edges[n];this._backupEdgeOptions(a),a.setOptions({physics:!1})}for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(this.clusteredNodes[n]={clusterId:s.id,node:this.body.nodes[n]},this.body.nodes[n].setOptions({physics:!1}))}_getClusterNodeForNode(e){if(e===void 0)return;let t=this.clusteredNodes[e];if(t===void 0)return;let s=t.clusterId;if(s!==void 0)return this.body.nodes[s]}_filter(e,t){let s=[];return F(e,o=>{t(o)&&s.push(o)}),s}_updateState(){let e,t=[],s={},o=h=>{F(this.body.nodes,l=>{l.isCluster===!0&&h(l)})};for(e in this.clusteredNodes){if(!Object.prototype.hasOwnProperty.call(this.clusteredNodes,e))continue;this.body.nodes[e]===void 0&&t.push(e)}o(function(h){for(let l=0;l{let l=this.body.edges[h];(l===void 0||!l.endPointsValid())&&(s[h]=h)}),o(function(h){F(h.containedEdges,(l,c)=>{!l.endPointsValid()&&!s[c]&&(s[c]=c)})}),F(this.body.edges,(h,l)=>{let c=!0,u=h.clusteringEdgeReplacingIds;if(u!==void 0){let f=0;F(u,p=>{let g=this.body.edges[p];g!==void 0&&g.endPointsValid()&&(f+=1)}),c=f>0}(!h.endPointsValid()||!c)&&(s[l]=l)}),o(h=>{F(s,l=>{delete h.containedEdges[l],F(h.edges,(c,u)=>{if(c.id===l){h.edges[u]=null;return}c.clusteringEdgeReplacingIds=this._filter(c.clusteringEdgeReplacingIds,function(f){return!s[f]})}),h.edges=this._filter(h.edges,function(c){return c!==null})})}),F(s,h=>{delete this.clusteredEdges[h]}),F(s,h=>{delete this.body.edges[h]});let n=Object.keys(this.body.edges);F(n,h=>{let l=this.body.edges[h],c=this._isClusteredNode(l.fromId)||this._isClusteredNode(l.toId);if(c!==this._isClusteredEdge(l.id))if(c){let u=this._getClusterNodeForNode(l.fromId);u!==void 0&&this._clusterEdges(this.body.nodes[l.fromId],l,u);let f=this._getClusterNodeForNode(l.toId);f!==void 0&&this._clusterEdges(this.body.nodes[l.toId],l,f)}else delete this._clusterEdges[h],this._restoreEdge(l)});let a=!1,d=!0;for(;d;){let h=[];o(function(l){let c=Object.keys(l.containedNodes).length,u=l.options.allowSingleNodeCluster===!0;(u&&c<1||!u&&c<2)&&h.push(l.id)});for(let l=0;l0,a=a||d}a&&this._updateState()}_isClusteredNode(e){return this.clusteredNodes[e]!==void 0}_isClusteredEdge(e){return this.clusteredEdges[e]!==void 0}};function ka(){let r;window!==void 0&&(r=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),r===void 0?window.requestAnimationFrame=function(e){e()}:window.requestAnimationFrame=r}var Ts=class{constructor(e,t){ka(),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&&$e(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag"],this.options,e)}_requestNextFrame(e,t){if(typeof window=="undefined")return;let s,o=window;return this.requiresTimeout===!0?s=o.setTimeout(e,t):o.requestAnimationFrame&&(s=o.requestAnimationFrame(e)),s}_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 s=this.canvas.getContext(),o=this.canvas.frame.canvas.clientWidth,n=this.canvas.frame.canvas.clientHeight;if(s.clearRect(0,0,o,n),this.canvas.frame.clientWidth===0)return;if(s.save(),s.translate(this.body.view.translation.x,this.body.view.translation.y),s.scale(this.body.view.scale,this.body.view.scale),s.beginPath(),this.body.emitter.emit("beforeDrawing",s),s.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(s),this.dragging===!1||this.dragging===!0&&this.options.hideNodesOnDrag===!1){let{drawExternalLabels:a}=this._drawNodes(s,e);t.drawExternalLabels=a}e===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&(this.zooming===!1||this.zooming===!0&&this.options.hideEdgesOnZoom===!1)&&this._drawArrows(s),t.drawExternalLabels!=null&&t.drawExternalLabels(),e===!1&&this._drawSelectionBox(s),s.beginPath(),this.body.emitter.emit("afterDrawing",s),s.closePath(),s.restore(),e===!0&&s.clearRect(0,0,o,n)}}_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,s;for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&(s=t[o],s.resize(e),s.updateBoundingBox(e,s.selected));e.restore()}_drawNodes(e,t=!1){let s=this.body.nodes,o=this.body.nodeIndices,n,a=[],d=[],h=20,l=this.canvas.DOMtoCanvas({x:-h,y:-h}),c=this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth+h,y:this.canvas.frame.canvas.clientHeight+h}),u={top:l.y,left:l.x,bottom:c.y,right:c.x},f=[];for(let m=0;m{for(let m of f)m()}}}_drawEdges(e){let t=this.body.edges,s=this.body.edgeIndices;for(let o=0;o{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&&$e(["width","height","autoResize"],this.options,e),this._cleanUp(),this.options.autoResize===!0){if(window.ResizeObserver){let s=new ResizeObserver(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")}),{frame:o}=this;s.observe(o),this._cleanupCallbacks.push(()=>{s.unobserve(o)})}else{let s=setInterval(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")},1e3);this._cleanupCallbacks.push(()=>{clearInterval(s)})}let t=this._onResize.bind(this);window.addEventListener("resize",t),this._cleanupCallbacks.push(()=>{window.removeEventListener("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,s=this.cameraState.scale;e!=1&&t!=1?s=this.cameraState.scale*.5*(e+t):e!=1?s=this.cameraState.scale*e:t!=1&&(s=this.cameraState.scale*t),this.body.view.scale=s;let o=this.DOMtoCanvas({x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight}),n={x:o.x-this.cameraState.position.x,y:o.y-this.cameraState.position.y};this.body.view.translation.x+=n.x*this.body.view.scale,this.body.view.translation.y+=n.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 Ze(this.frame.canvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:Ze.DIRECTION_ALL}),ai(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 Ze(this.frame),gn(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 s=!1,o=this.frame.canvas.width,n=this.frame.canvas.height,a=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(a),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},s=!0;else{let d=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),h=Math.round(this.frame.canvas.clientHeight*this.pixelRatio);(this.frame.canvas.width!==d||this.frame.canvas.height!==h)&&this._getCameraState(a),this.frame.canvas.width!==d&&(this.frame.canvas.width=d,s=!0),this.frame.canvas.height!==h&&(this.frame.canvas.height=h,s=!0)}return s===!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(o/this.pixelRatio),oldHeight:Math.round(n/this.pixelRatio)}),this._setCameraState()),this.initialized=!0,s}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 s=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return t/s}_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(r,e){let t=Object.assign({nodes:e,minZoomLevel:Number.MIN_VALUE,maxZoomLevel:1},r!=null?r:{});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 ks=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 s=this.canvas.frame.canvas.clientWidth,o=this.canvas.frame.canvas.clientHeight,n,a;if(s===0||o===0)a=1,n=te.getRange(this.body.nodes,e.nodes);else if(t===!0){let l=0;for(let f in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,f)&&this.body.nodes[f].predefinedPosition===!0&&(l+=1);if(l>.5*this.body.nodeIndices.length){this.fit(e,!1);return}n=te.getRange(this.body.nodes,e.nodes),a=12.662/(this.body.nodeIndices.length+7.4147)+.0964822;let u=Math.min(s/600,o/600);a*=u}else{this.body.emitter.emit("_resizeNodes"),n=te.getRange(this.body.nodes,e.nodes);let l=Math.abs(n.maxX-n.minX)*1.1,c=Math.abs(n.maxY-n.minY)*1.1,u=s/l,f=o/c;a=u<=f?u:f}a>e.maxZoomLevel?a=e.maxZoomLevel:a0))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}),s={x:t.x-e.position.x,y:t.y-e.position.y};this.targetTranslation={x:this.sourceTranslation.x+s.x*this.targetScale+e.offset.x,y:this.sourceTranslation.y+s.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}),s={x:t.x-e.x,y:t.y-e.y},o=this.body.view.translation,n={x:o.x+s.x*this.body.view.scale+this.lockedOnNodeOffset.x,y:o.y+s.y*this.body.view.scale+this.lockedOnNodeOffset.y};this.body.view.translation=n}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=Wo[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})}},Os=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._stopMovement()}),this.navigationHammers.push(s),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),s=this.body.view.translation,o=t/e,n=(1-o)*this.canvas.canvasViewCenter.x+s.x*o,a=(1-o)*this.canvas.canvasViewCenter.y+s.y*o;this.body.view.scale=t,this.body.view.translation={x:n,y:a},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),s=this.body.view.translation,o=t/e,n=(1-o)*this.canvas.canvasViewCenter.x+s.x*o,a=(1-o)*this.canvas.canvasViewCenter.y+s.y*o;this.body.view.scale=t,this.body.view.translation={x:n,y:a},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=Xt({container:window,preventDefault:!0}):this.keycharm=Xt({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")))}},Ss=class{constructor(e,t,s){this.body=e,this.canvas=t,this.selectionHandler=s,this.navigationHandler=new Os(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&&(Tt(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag","keyboard","multiselect","selectable","selectConnectedEdges"],this.options,e),fe(this.options,e,"keyboard"),e.tooltip&&(Object.assign(this.options.tooltip,e.tooltip),e.tooltip.color&&(this.options.tooltip.color=Vt(e.tooltip.color)))),this.navigationHandler.setOptions(this.options)}getPointer(e){return{x:e.x-zo(this.canvas.frame.canvas),y:e.y-Ro(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),s=this.selectionHandler.options.multiselect&&(e.changedPointers[0].ctrlKey||e.changedPointers[0].metaKey);this.checkSelectionChanges(t,s),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),s=this.selectionHandler.options.multiselect;this.checkSelectionChanges(t,s),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 s=function(o,n){let a=[];for(let d=0;d{let d=a.node;a.xFixed===!1&&(d.x=this.canvas._XconvertDOMtoCanvas(this.canvas._XconvertCanvasToDOM(a.x)+o)),a.yFixed===!1&&(d.y=this.canvas._YconvertDOMtoCanvas(this.canvas._YconvertCanvasToDOM(a.y)+n))}),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 o=t.x-this.drag.pointer.x,n=t.y-this.drag.pointer.y;this.body.view.translation={x:this.drag.translation.x+o,y:this.drag.translation.y+n},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,s={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(a=>{let d=this.body.nodes[a];return d.x>=s.minX&&d.x<=s.maxX&&d.y>=s.minY&&d.y<=s.maxY}).forEach(a=>this.selectionHandler.selectObject(this.body.nodes[a]));let n=this.getPointer(e.center);this.selectionHandler.commitAndEmit(n,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(s){s.node.options.fixed.x=s.xFixed,s.node.options.fixed.y=s.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 s=this.pinch.scale*e.scale;this.zoom(s,t)}zoom(e,t){if(this.options.zoomView===!0){let s=this.body.view.scale;e<1e-5&&(e=1e-5),e>10&&(e=10);let o;this.drag!==void 0&&this.drag.dragging===!0&&(o=this.canvas.DOMtoCanvas(this.drag.pointer));let n=this.body.view.translation,a=e/s,d=(1-a)*t.x+n.x*a,h=(1-a)*t.y+n.y*a;if(this.body.view.scale=e,this.body.view.translation={x:d,y:h},o!=null){let l=this.canvas.canvasToDOM(o);this.drag.pointer.x=l.x,this.drag.pointer.y=l.y}this.body.emitter.emit("_requestRedraw"),sthis._checkShowPopup(t),this.options.tooltipDelay))),this.options.hover===!0&&this.selectionHandler.hoverObject(e,t)}_checkShowPopup(e){let t=this.canvas._XconvertDOMtoCanvas(e.x),s=this.canvas._YconvertDOMtoCanvas(e.y),o={left:t,top:s,right:t,bottom:s},n=this.popupObj===void 0?void 0:this.popupObj.id,a=!1,d="node";if(this.popupObj===void 0){let h=this.body.nodeIndices,l=this.body.nodes,c,u=[];for(let f=0;f0&&(this.popupObj=l[u[u.length-1]],a=!0)}if(this.popupObj===void 0&&a===!1){let h=this.body.edgeIndices,l=this.body.edges,c,u=[];for(let f=0;f0&&(this.popupObj=l[u[u.length-1]],d="edge")}this.popupObj!==void 0?this.popupObj.id!==n&&(this.popup===void 0&&(this.popup=new Yo(this.canvas.frame)),this.popup.popupTargetType=d,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),s=!1;if(this.popup.popupTargetType==="node"){if(this.body.nodes[this.popup.popupTargetId]!==void 0&&(s=this.body.nodes[this.popup.popupTargetId].isOverlappingWith(t),s===!0)){let o=this.selectionHandler.getNodeAt(e);s=o===void 0?!1:o.id===this.popup.popupTargetId}}else this.selectionHandler.getNodeAt(e)===void 0&&this.body.edges[this.popup.popupTargetId]!==void 0&&(s=this.body.edges[this.popup.popupTargetId].isOverlappingWith(t));s===!1&&(this.popupObj=void 0,this.popup.hide(),this.body.emitter.emit("hidePopup"))}};function q(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)}function Is(r,e,t,s,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t}var Qe,ye,Ae,ze,Kt;function tn(r,e){let t=new Set;for(let s of e)r.has(s)||t.add(s);return t}var di=class{constructor(){Qe.set(this,new Set),ye.set(this,new Set)}get size(){return q(this,ye,"f").size}add(...e){for(let t of e)q(this,ye,"f").add(t)}delete(...e){for(let t of e)q(this,ye,"f").delete(t)}clear(){q(this,ye,"f").clear()}getSelection(){return[...q(this,ye,"f")]}getChanges(){return{added:[...tn(q(this,Qe,"f"),q(this,ye,"f"))],deleted:[...tn(q(this,ye,"f"),q(this,Qe,"f"))],previous:[...new Set(q(this,Qe,"f"))],current:[...new Set(q(this,ye,"f"))]}}commit(){let e=this.getChanges();Is(this,Qe,q(this,ye,"f"),"f"),Is(this,ye,new Set(q(this,Qe,"f")),"f");for(let t of e.added)t.select();for(let t of e.deleted)t.unselect();return e}};Qe=new WeakMap,ye=new WeakMap;var Ps=class{constructor(e=()=>{}){Ae.set(this,new di),ze.set(this,new di),Kt.set(this,void 0),Is(this,Kt,e,"f")}get sizeNodes(){return q(this,Ae,"f").size}get sizeEdges(){return q(this,ze,"f").size}getNodes(){return q(this,Ae,"f").getSelection()}getEdges(){return q(this,ze,"f").getSelection()}addNodes(...e){q(this,Ae,"f").add(...e)}addEdges(...e){q(this,ze,"f").add(...e)}deleteNodes(e){q(this,Ae,"f").delete(e)}deleteEdges(e){q(this,ze,"f").delete(e)}clear(){q(this,Ae,"f").clear(),q(this,ze,"f").clear()}commit(...e){let t={nodes:q(this,Ae,"f").commit(),edges:q(this,ze,"f").commit()};return q(this,Kt,"f").call(this,t,...e),t}};Ae=new WeakMap,ze=new WeakMap,Kt=new WeakMap;var Ms=class{constructor(e,t){this.body=e,this.canvas=t,this._selectionAccumulator=new Ps,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&&$e(["multiselect","hoverConnectedEdges","selectable","selectConnectedEdges"],this.options,e)}selectOnPoint(e){let t=!1;if(this.options.selectable===!0){let s=this.getNodeAt(e)||this.getEdgeAt(e);this.unselectAll(),s!==void 0&&(t=this.selectObject(s)),this.body.emitter.emit("_requestRedraw")}return t}selectAdditionalOnPoint(e){let t=!1;if(this.options.selectable===!0){let s=this.getNodeAt(e)||this.getEdgeAt(e);s!==void 0&&(t=!0,s.isSelected()===!0?this.deselectObject(s):this.selectObject(s),this.body.emitter.emit("_requestRedraw"))}return t}_initBaseEvent(e,t){let s={};return s.pointer={DOM:{x:t.x,y:t.y},canvas:this.canvas.DOMtoCanvas(t)},s.event=e,s}generateClickEvent(e,t,s,o,n=!1){let a=this._initBaseEvent(t,s);if(n===!0)a.nodes=[],a.edges=[];else{let d=this.getSelection();a.nodes=d.nodes,a.edges=d.edges}o!==void 0&&(a.previousSelection=o),e=="click"&&(a.items=this.getClickedItems(s)),t.controlEdge!==void 0&&(a.controlEdge=t.controlEdge),this.body.emitter.emit(e,a)}selectObject(e,t=this.options.selectConnectedEdges){return e!==void 0?(e instanceof ne?(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=[],s=this.body.nodes;for(let o=0;o0)return t===!0?this.body.nodes[o[o.length-1]]:o[o.length-1]}_getEdgesOverlappingWith(e,t){let s=this.body.edges;for(let o=0;o0&&(this.generateClickEvent("deselectEdge",t,e,n),s=!0),o.nodes.deleted.length>0&&(this.generateClickEvent("deselectNode",t,e,n),s=!0),o.nodes.added.length>0&&(this.generateClickEvent("selectNode",t,e),s=!0),o.edges.added.length>0&&(this.generateClickEvent("selectEdge",t,e),s=!0),s===!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 s of e.nodes){let o=this.body.nodes[s];if(!o)throw new RangeError('Node with id "'+s+'" not found');this.selectObject(o,t.highlightEdges)}if(e.edges)for(let s of e.edges){let o=this.body.edges[s];if(!o)throw new RangeError('Edge with id "'+s+'" not found');this.selectObject(o)}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),s=[],o=this.body.nodeIndices,n=this.body.nodes;for(let h=o.length-1;h>=0;h--){let c=n[o[h]].getItemsOnPoint(t);s.push.apply(s,c)}let a=this.body.edgeIndices,d=this.body.edges;for(let h=a.length-1;h>=0;h--){let c=d[a[h]].getItemsOnPoint(t);s.push.apply(s,c)}return s}},hi=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,s=void 0){this.fake_use(e,t,s),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()}},Ds=class extends hi{constructor(e){super(),this.layout=e}curveType(){return"horizontal"}getPosition(e){return e.x}setPosition(e,t,s=void 0){s!==void 0&&this.layout.hierarchical.addToOrdering(e,s),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){e.sort(function(t,s){return t.x-s.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}},Ns=class extends hi{constructor(e){super(),this.layout=e}curveType(){return"vertical"}getPosition(e){return e.y}setPosition(e,t,s=void 0){s!==void 0&&this.layout.hierarchical.addToOrdering(e,s),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){e.sort(function(t,s){return t.y-s.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 Sa(r,e){let t=new Set;return r.forEach(s=>{s.edges.forEach(o=>{o.connected&&t.add(o)})}),t.forEach(s=>{let o=s.from.id,n=s.to.id;e[o]==null&&(e[o]=0),(e[n]==null||e[o]>=e[n])&&(e[n]=e[o]+1)}),e}function Ia(r){return mn(e=>e.edges.filter(t=>r.has(t.toId)).every(t=>t.to===e),(e,t)=>t>e,"from",r)}function Pa(r){return mn(e=>e.edges.filter(t=>r.has(t.toId)).every(t=>t.from===e),(e,t)=>th+1+l.edges.length,0),a=t+"Id",d=t==="to"?1:-1;for(let[h,l]of s){if(!s.has(h)||!r(l))continue;o[h]=0;let c=[l],u=0,f;for(;f=c.pop();){if(!s.has(h))continue;let p=o[f.id]+d;if(f.edges.filter(g=>g.connected&&g.to!==g.from&&g[t]!==f&&s.has(g.toId)&&s.has(g.fromId)).forEach(g=>{let _=g[a],m=o[_];(m==null||e(p,m))&&(o[_]=p,c.push(g[t]))}),u>n)return Sa(s,o);++u}}return o}var Fs=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={},s=o=>{if(t[o]!==void 0)return t[o];let n=this.levels[o];if(this.childrenReference[o]){let a=this.childrenReference[o];if(a.length>0)for(let d=0;d{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 s=this.options.hierarchical,o=s.enabled;if($e(["randomSeed","improvedLayout","clusterThreshold"],this.options,e),fe(this.options,e,"hierarchical"),e.randomSeed!==void 0&&this._resetRNG(e.randomSeed),s.enabled===!0)return o===!0&&this.body.emitter.emit("refresh",!0),s.direction==="RL"||s.direction==="DU"?s.levelSeparation>0&&(s.levelSeparation*=-1):s.levelSeparation<0&&(s.levelSeparation*=-1),this.setDirectionStrategy(),this.body.emitter.emit("_resetHierarchicalLayout"),this.adaptAllOptionsForHierarchicalLayout(t);if(o===!0)return this.body.emitter.emit("refresh"),V(t,this.optionsBackup)}return t}_resetRNG(e){this.initialRandomSeed=e,this._rng=xt(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 s=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:s};else{let o=e.edges.smooth;o.type!==void 0&&o.type!=="dynamic"&&(s=o.type),this.optionsBackup.edges={smooth:{enabled:o.enabled===void 0?!0:o.enabled,type:o.type===void 0?"dynamic":o.type,roundness:o.roundness===void 0?.5:o.roundness,forceDirection:o.forceDirection===void 0?!1:o.forceDirection}},e.edges.smooth={enabled:o.enabled===void 0?!0:o.enabled,type:s,roundness:o.roundness===void 0?.5:o.roundness,forceDirection:o.forceDirection===void 0?!1:o.forceDirection}}this.body.emitter.emit("_forceDisableDynamicCurves",s)}return e}positionInitially(e){if(this.options.hierarchical.enabled!==!0){this._resetRNG(this.initialRandomSeed);let t=e.length+50;for(let s=0;sn){let h=e.length;for(;e.length>n&&o<=10;){o+=1;let l=e.length;o%3===0?this.body.modules.clustering.clusterBridges(a):this.body.modules.clustering.clusterOutliers(a);let c=e.length;if(l==c&&o%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*h)})}o>10&&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 d=70;for(let h=0;h0){let e,t,s=!1,o=!1;this.lastNodeOnLevel={},this.hierarchical=new Fs;for(t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&(e=this.body.nodes[t],e.options.level!==void 0?(s=!0,this.hierarchical.levels[t]=e.options.level):o=!0);if(o===!0&&s===!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(o===!0){let a=this.options.hierarchical.sortMethod;a==="hubsize"?this._determineLevelsByHubsize():a==="directed"?this._determineLevelsDirected():a==="custom"&&this._determineLevelsCustomCallback()}for(let a in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,a)&&this.hierarchical.ensureLevel(a);let n=this._getDistribution();this._generateMap(),this._placeNodesByHierarchy(n),this._condenseHierarchy(),this._shiftToCenter()}}}_condenseHierarchy(){let e=!1,t={},s=()=>{let m=n(),v=0;for(let C=0;C{let C=this.hierarchical.trees;for(let O in C)Object.prototype.hasOwnProperty.call(C,O)&&C[O]===m&&this.direction.shift(O,v)},n=()=>{let m=[];for(let v=0;v{if(!v[m.id]&&(v[m.id]=!0,this.hierarchical.childrenReference[m.id])){let C=this.hierarchical.childrenReference[m.id];if(C.length>0)for(let O=0;O{let C=1e9,O=1e9,P=1e9,D=-1e9;for(let N in m)if(Object.prototype.hasOwnProperty.call(m,N)){let W=this.body.nodes[N],X=this.hierarchical.levels[W.id],w=this.direction.getPosition(W),[k,L]=this._getSpaceAroundNode(W,m);C=Math.min(k,C),O=Math.min(L,O),X<=v&&(P=Math.min(w,P),D=Math.max(w,D))}return[P,D,C,O]},h=(m,v)=>{let C=this.hierarchical.getMaxLevel(m.id),O=this.hierarchical.getMaxLevel(v.id);return Math.min(C,O)},l=(m,v,C)=>{let O=this.hierarchical;for(let P=0;P1)for(let W=0;W{let O=this.direction.getPosition(m),P=this.direction.getPosition(v),D=Math.abs(P-O),N=this.options.hierarchical.nodeSpacing;if(D>N){let W={},X={};a(m,W),a(v,X);let w=h(m,v),k=d(W,w),L=d(X,w),K=k[1],H=L[0],R=L[2];if(Math.abs(K-H)>N){let j=K-H+N;j<-R+N&&(j=-R+N),j<0&&(this._shiftBlock(v.id,j),e=!0,C===!0&&this._centerParent(v))}}},u=(m,v)=>{let C=v.id,O=v.edges,P=this.hierarchical.levels[v.id],D=this.options.hierarchical.levelSeparation*this.options.hierarchical.levelSeparation,N={},W=[];for(let R=0;R{let j=0;for(let Z=0;Z{let j=0;for(let Z=0;Z{let j=this.direction.getPosition(v),Z={};for(let $=0;${let z=this.direction.getPosition(v);if(t[v.id]===void 0){let we={};a(v,we),t[v.id]=we}let j=d(t[v.id]),Z=j[2],$=j[3],ie=R-z,pe=0;ie>0?pe=Math.min(ie,$-this.options.hierarchical.nodeSpacing):ie<0&&(pe=-Math.min(-ie,Z-this.options.hierarchical.nodeSpacing)),pe!=0&&(this._shiftBlock(v.id,pe),e=!0)},K=R=>{let z=this.direction.getPosition(v),[j,Z]=this._getSpaceAroundNode(v),$=R-z,ie=z;$>0?ie=Math.min(z+(Z-this.options.hierarchical.nodeSpacing),R):$<0&&(ie=Math.max(z-(j-this.options.hierarchical.nodeSpacing),R)),ie!==z&&(this.direction.setPosition(v,ie),e=!0)},H=k(m,W);L(H),H=k(m,O),K(H)},f=m=>{let v=this.hierarchical.getLevels();v=v.reverse();for(let C=0;C{let v=this.hierarchical.getLevels();v=v.reverse();for(let C=0;C{for(let m in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,m)&&this._centerParent(this.body.nodes[m])},_=()=>{let m=this.hierarchical.getLevels();m=m.reverse();for(let v=0;v0&&Math.abs(u)0&&(h=this.direction.getPosition(s[n-1])+d),this.direction.setPosition(a,h,t),this._validatePositionAndContinue(a,t,h),o++}}}}_placeBranchNodes(e,t){let s=this.hierarchical.childrenReference[e];if(s===void 0)return;let o=[];for(let a=0;at&&this.positionedNodes[d.id]===void 0){let l=this.options.hierarchical.nodeSpacing,c;a===0?c=this.direction.getPosition(this.body.nodes[e]):c=this.direction.getPosition(o[a-1])+l,this.direction.setPosition(d,c,h),this._validatePositionAndContinue(d,h,c)}else return}let n=this._getCenterPosition(o);this.direction.setPosition(this.body.nodes[e],n,t)}_validatePositionAndContinue(e,t,s){if(this.hierarchical.isTree){if(this.lastNodeOnLevel[t]!==void 0){let o=this.direction.getPosition(this.body.nodes[this.lastNodeOnLevel[t]]);if(s-o{this.body.edgeIndices.indexOf(s.id)!==-1&&t.push(s)}),t}_getHubSizes(){let e={},t=this.body.nodeIndices;F(t,o=>{let n=this.body.nodes[o],a=this._getActiveEdges(n).length;e[a]=!0});let s=[];return F(e,o=>{s.push(Number(o))}),s.sort(function(o,n){return n-o}),s}_determineLevelsByHubsize(){let e=(s,o)=>{this.hierarchical.levelDownstream(s,o)},t=this._getHubSizes();for(let s=0;s{let a=this.body.nodes[n];o===this._getActiveEdges(a).length&&this._crawlNetwork(e,n)})}}_determineLevelsCustomCallback(){let t=function(o,n,a){},s=(o,n,a)=>{let d=this.hierarchical.levels[o.id];d===void 0&&(d=this.hierarchical.levels[o.id]=1e5);let h=t(te.cloneOptions(o,"node"),te.cloneOptions(n,"node"),te.cloneOptions(a,"edge"));this.hierarchical.levels[n.id]=d+h};this._crawlNetwork(s),this.hierarchical.setMinLevelToZero(this.body.nodes)}_determineLevelsDirected(){let e=this.body.nodeIndices.reduce((t,s)=>(t.set(s,this.body.nodes[s]),t),new Map);this.options.hierarchical.shakeTowards==="roots"?this.hierarchical.levels=Pa(e):this.hierarchical.levels=Ia(e),this.hierarchical.setMinLevelToZero(this.body.nodes)}_generateMap(){let e=(t,s)=>{this.hierarchical.levels[s.id]>this.hierarchical.levels[t.id]&&this.hierarchical.addRelation(t.id,s.id)};this._crawlNetwork(e),this.hierarchical.checkIfTree()}_crawlNetwork(e=function(){},t){let s={},o=(n,a)=>{if(s[n.id]===void 0){this.hierarchical.setTreeIndex(n,a),s[n.id]=!0;let d,h=this._getActiveEdges(n);for(let l=0;l{if(s[n])return;s[n]=!0,this.direction.shift(n,t);let a=this.hierarchical.childrenReference[n];if(a!==void 0)for(let d=0;d{let h=this.hierarchical.parentReference[d];if(h!==void 0)for(let l=0;l{let h=this.hierarchical.parentReference[d];if(h!==void 0)for(let l=0;l{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,s){t!==void 0&&(t.locale!==void 0?this.options.locale=t.locale:this.options.locale=s.locale,t.locales!==void 0?this.options.locales=t.locales:this.options.locales=s.locales),e!==void 0&&(typeof e=="boolean"?this.options.enabled=e:(this.options.enabled=!0,V(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(),s=e+t,o=this.options.locales[this.options.locale],n=!1;this.options.addNode!==!1&&(this._createAddNodeButton(o),n=!0),this.options.addEdge!==!1&&(n===!0?this._createSeperator(1):n=!0,this._createAddEdgeButton(o)),e===1&&typeof this.options.editNode=="function"?(n===!0?this._createSeperator(2):n=!0,this._createEditNodeButton(o)):t===1&&e===0&&this.options.editEdge!==!1&&(n===!0?this._createSeperator(3):n=!0,this._createEditEdgeButton(o)),s!==0&&(e>0&&this.options.deleteNode!==!1?(n===!0&&this._createSeperator(4),this._createDeleteButton(o)):e===0&&this.options.deleteEdge!==!1&&(n===!0&&this._createSeperator(4),this._createDeleteButton(o))),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=V({},e.options,!1);if(t.x=e.x,t.y=e.y,this.options.editNode.length===2)this.options.editNode(t,s=>{s!=null&&this.inMode==="editNode"&&this.body.data.nodes.getDataSet().update(s),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),s=this._getNewTargetNode(e.to.x,e.to.y);this.temporaryIds.nodes.push(t.id),this.temporaryIds.nodes.push(s.id),this.body.nodes[t.id]=t,this.body.nodeIndices.push(t.id),this.body.nodes[s.id]=s,this.body.nodeIndices.push(s.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",o=>{let n=e.edgeType.findBorderPositions(o);t.selected===!1&&(t.x=n.from.x,t.y=n.from.y),s.selected===!1&&(s.x=n.to.x,s.y=n.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(),s;if(e.length>0){for(let o=0;o0&&typeof this.options.deleteEdge=="function"&&(s=this.options.deleteEdge);if(typeof s=="function"){let o={nodes:e,edges:t};if(s.length===2)s(o,n=>{n!=null&&this.inMode==="delete"?(this.body.data.edges.getDataSet().remove(n.edges),this.body.data.nodes.getDataSet().remove(n.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 s=V({},this.options.controlNodeStyle);s.id="targetNode"+Ne(),s.hidden=!1,s.physics=!1,s.x=e,s.y=t;let o=this.body.functions.createNode(s);return o.shape.boundingBox={left:e,right:e,top:t,bottom:t},o}_createEditButton(){this._clean(),this.manipulationDOM={},Pe(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&&(Pe(this.editModeDiv),Pe(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(),Pe(this.manipulationDiv),Pe(this.editModeDiv),Pe(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 s=this._createButton("delete",t,e.del||this.options.locales.en.del);this.manipulationDiv.appendChild(s),this._bindElementEvents(s,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,s,o="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=o,this.manipulationDOM[e+"Label"].innerText=s,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{s.destroy()});let o=({keyCode:n,key:a})=>{(a==="Enter"||a===" "||n===13||n===32)&&t()};e.addEventListener("keyup",o,!1),this._domEventListenerCleanupQueue.push(()=>{e.removeEventListener("keyup",o,!1)})}_cleanupTemporaryNodesAndEdges(){for(let e=0;e=0;d--)if(n[d]!==this.selectedControlNode.id){a=this.body.nodes[n[d]];break}if(a!==void 0&&this.selectedControlNode!==void 0)if(a.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let d=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===d.id?this._performEditEdge(a.id,o.to.id):this._performEditEdge(o.from.id,a.id)}else o.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,s=this.selectionHandler.getNodeAt(t);if(s!==void 0)if(s.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let o=this._getNewTargetNode(s.x,s.y);this.body.nodes[o.id]=o,this.body.nodeIndices.push(o.id);let n=this.body.functions.createEdge({id:"connectionEdge"+Ne(),from:s.id,to:o.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[n.id]=n,this.body.edgeIndices.push(n.id),this.temporaryIds.nodes.push(o.id),this.temporaryIds.edges.push(n.id)}this.touchTime=new Date().valueOf()}}_dragControlNode(e){let t=this.body.functions.getPointer(e.center),s=this.selectionHandler._pointerToPositionObject(t),o;this.temporaryIds.edges[0]!==void 0&&(o=this.body.edges[this.temporaryIds.edges[0]].fromId);let n=this.selectionHandler._getAllNodesOverlappingWith(s),a;for(let d=n.length-1;d>=0;d--)if(this.temporaryIds.nodes.indexOf(n[d])===-1){a=this.body.nodes[n[d]];break}if(e.controlEdge={from:o,to:a?a.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragging",e,t),this.temporaryIds.nodes[0]!==void 0){let d=this.body.nodes[this.temporaryIds.nodes[0]];d.x=this.canvas._XconvertDOMtoCanvas(t.x),d.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),s=this.selectionHandler._pointerToPositionObject(t),o;this.temporaryIds.edges[0]!==void 0&&(o=this.body.edges[this.temporaryIds.edges[0]].fromId);let n=this.selectionHandler._getAllNodesOverlappingWith(s),a;for(let d=n.length-1;d>=0;d--)if(this.temporaryIds.nodes.indexOf(n[d])===-1){a=this.body.nodes[n[d]];break}this._cleanupTemporaryNodesAndEdges(),a!==void 0&&(a.isCluster===!0?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):this.body.nodes[o]!==void 0&&this.body.nodes[a.id]!==void 0&&this._performAddEdge(o,a.id)),e.controlEdge={from:o,to:a?a.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:Ne(),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,s=>{s!=null&&this.inMode==="addNode"&&this.body.data.nodes.getDataSet().add(s),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 s={from:e,to:t};if(typeof this.options.addEdge=="function")if(this.options.addEdge.length===2)this.options.addEdge(s,o=>{o!=null&&this.inMode==="addEdge"&&(this.body.data.edges.getDataSet().add(o),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(s),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}_performEditEdge(e,t){let s={id:this.edgeBeingEditedId,from:e,to:t,label:this.body.data.edges.get(this.edgeBeingEditedId).label},o=this.options.editEdge;if(typeof o=="object"&&(o=o.editWithoutDrag),typeof o=="function")if(o.length===2)o(s,n=>{n==null||this.inMode!=="editEdge"?(this.body.edges[s.id].updateEdgeType(),this.body.emitter.emit("_redraw"),this.showManipulatorToolbar()):(this.body.data.edges.getDataSet().update(n),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(s),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},T="string",E="boolean",b="number",Ct="array",I="object",yn="dom",Ma="any",zi=["arrow","bar","box","circle","crow","curve","diamond","image","inv_curve","inv_triangle","triangle","vee"],Ri={borderWidth:{number:b},borderWidthSelected:{number:b,undefined:"undefined"},brokenImage:{string:T,undefined:"undefined"},chosen:{label:{boolean:E,function:"function"},node:{boolean:E,function:"function"},__type__:{object:I,boolean:E}},color:{border:{string:T},background:{string:T},highlight:{border:{string:T},background:{string:T},__type__:{object:I,string:T}},hover:{border:{string:T},background:{string:T},__type__:{object:I,string:T}},__type__:{object:I,string:T}},opacity:{number:b,undefined:"undefined"},fixed:{x:{boolean:E},y:{boolean:E},__type__:{object:I,boolean:E}},font:{align:{string:T},color:{string:T},size:{number:b},face:{string:T},background:{string:T},strokeWidth:{number:b},strokeColor:{string:T},vadjust:{number:b},multi:{boolean:E,string:T},bold:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},boldital:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},ital:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},mono:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},__type__:{object:I,string:T}},group:{string:T,number:b,undefined:"undefined"},heightConstraint:{minimum:{number:b},valign:{string:T},__type__:{object:I,boolean:E,number:b}},hidden:{boolean:E},icon:{face:{string:T},code:{string:T},size:{number:b},color:{string:T},weight:{string:T,number:b},__type__:{object:I}},id:{string:T,number:b},image:{selected:{string:T,undefined:"undefined"},unselected:{string:T,undefined:"undefined"},__type__:{object:I,string:T}},imagePadding:{top:{number:b},right:{number:b},bottom:{number:b},left:{number:b},__type__:{object:I,number:b}},label:{string:T,undefined:"undefined"},labelHighlightBold:{boolean:E},level:{number:b,undefined:"undefined"},margin:{top:{number:b},right:{number:b},bottom:{number:b},left:{number:b},__type__:{object:I,number:b}},mass:{number:b},physics:{boolean:E},scaling:{min:{number:b},max:{number:b},label:{enabled:{boolean:E},min:{number:b},max:{number:b},maxVisible:{number:b},drawThreshold:{number:b},__type__:{object:I,boolean:E}},customScalingFunction:{function:"function"},__type__:{object:I}},shadow:{enabled:{boolean:E},color:{string:T},size:{number:b},x:{number:b},y:{number:b},__type__:{object:I,boolean:E}},shape:{string:["custom","ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon","hexagon"]},ctxRenderer:{function:"function"},shapeProperties:{borderDashes:{boolean:E,array:Ct},borderRadius:{number:b},interpolation:{boolean:E},useImageSize:{boolean:E},useBorderWithImage:{boolean:E},coordinateOrigin:{string:["center","top-left"]},__type__:{object:I}},size:{number:b},title:{string:T,dom:yn,undefined:"undefined"},value:{number:b,undefined:"undefined"},widthConstraint:{minimum:{number:b},maximum:{number:b},__type__:{object:I,boolean:E,number:b}},x:{number:b},y:{number:b},__type__:{object:I}},Da={configure:{enabled:{boolean:E},filter:{boolean:E,string:T,array:Ct,function:"function"},container:{dom:yn},showButton:{boolean:E},__type__:{object:I,boolean:E,string:T,array:Ct,function:"function"}},edges:{arrows:{to:{enabled:{boolean:E},scaleFactor:{number:b},type:{string:zi},imageHeight:{number:b},imageWidth:{number:b},src:{string:T},__type__:{object:I,boolean:E}},middle:{enabled:{boolean:E},scaleFactor:{number:b},type:{string:zi},imageWidth:{number:b},imageHeight:{number:b},src:{string:T},__type__:{object:I,boolean:E}},from:{enabled:{boolean:E},scaleFactor:{number:b},type:{string:zi},imageWidth:{number:b},imageHeight:{number:b},src:{string:T},__type__:{object:I,boolean:E}},__type__:{string:["from","to","middle"],object:I}},endPointOffset:{from:{number:b},to:{number:b},__type__:{object:I,number:b}},arrowStrikethrough:{boolean:E},background:{enabled:{boolean:E},color:{string:T},size:{number:b},dashes:{boolean:E,array:Ct},__type__:{object:I,boolean:E}},chosen:{label:{boolean:E,function:"function"},edge:{boolean:E,function:"function"},__type__:{object:I,boolean:E}},color:{color:{string:T},highlight:{string:T},hover:{string:T},inherit:{string:["from","to","both"],boolean:E},opacity:{number:b},__type__:{object:I,string:T}},dashes:{boolean:E,array:Ct},font:{color:{string:T},size:{number:b},face:{string:T},background:{string:T},strokeWidth:{number:b},strokeColor:{string:T},align:{string:["horizontal","top","middle","bottom"]},vadjust:{number:b},multi:{boolean:E,string:T},bold:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},boldital:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},ital:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},mono:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},__type__:{object:I,string:T}},hidden:{boolean:E},hoverWidth:{function:"function",number:b},label:{string:T,undefined:"undefined"},labelHighlightBold:{boolean:E},length:{number:b,undefined:"undefined"},physics:{boolean:E},scaling:{min:{number:b},max:{number:b},label:{enabled:{boolean:E},min:{number:b},max:{number:b},maxVisible:{number:b},drawThreshold:{number:b},__type__:{object:I,boolean:E}},customScalingFunction:{function:"function"},__type__:{object:I}},selectionWidth:{function:"function",number:b},selfReferenceSize:{number:b},selfReference:{size:{number:b},angle:{number:b},renderBehindTheNode:{boolean:E},__type__:{object:I}},shadow:{enabled:{boolean:E},color:{string:T},size:{number:b},x:{number:b},y:{number:b},__type__:{object:I,boolean:E}},smooth:{enabled:{boolean:E},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:b},forceDirection:{string:["horizontal","vertical","none"],boolean:E},__type__:{object:I,boolean:E}},title:{string:T,undefined:"undefined"},width:{number:b},widthConstraint:{maximum:{number:b},__type__:{object:I,boolean:E,number:b}},value:{number:b,undefined:"undefined"},__type__:{object:I}},groups:{useDefaultGroups:{boolean:E},__any__:Ri,__type__:{object:I}},interaction:{dragNodes:{boolean:E},dragView:{boolean:E},hideEdgesOnDrag:{boolean:E},hideEdgesOnZoom:{boolean:E},hideNodesOnDrag:{boolean:E},hover:{boolean:E},keyboard:{enabled:{boolean:E},speed:{x:{number:b},y:{number:b},zoom:{number:b},__type__:{object:I}},bindToWindow:{boolean:E},autoFocus:{boolean:E},__type__:{object:I,boolean:E}},multiselect:{boolean:E},navigationButtons:{boolean:E},selectable:{boolean:E},selectConnectedEdges:{boolean:E},hoverConnectedEdges:{boolean:E},tooltipDelay:{number:b},zoomView:{boolean:E},zoomSpeed:{number:b},__type__:{object:I}},layout:{randomSeed:{undefined:"undefined",number:b,string:T},improvedLayout:{boolean:E},clusterThreshold:{number:b},hierarchical:{enabled:{boolean:E},levelSeparation:{number:b},nodeSpacing:{number:b},treeSpacing:{number:b},blockShifting:{boolean:E},edgeMinimization:{boolean:E},parentCentralization:{boolean:E},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},shakeTowards:{string:["leaves","roots"]},__type__:{object:I,boolean:E}},__type__:{object:I}},manipulation:{enabled:{boolean:E},initiallyActive:{boolean:E},addNode:{boolean:E,function:"function"},addEdge:{boolean:E,function:"function"},editNode:{function:"function"},editEdge:{editWithoutDrag:{function:"function"},__type__:{object:I,boolean:E,function:"function"}},deleteNode:{boolean:E,function:"function"},deleteEdge:{boolean:E,function:"function"},controlNodeStyle:Ri,__type__:{object:I,boolean:E}},nodes:Ri,physics:{enabled:{boolean:E},barnesHut:{theta:{number:b},gravitationalConstant:{number:b},centralGravity:{number:b},springLength:{number:b},springConstant:{number:b},damping:{number:b},avoidOverlap:{number:b},__type__:{object:I}},forceAtlas2Based:{theta:{number:b},gravitationalConstant:{number:b},centralGravity:{number:b},springLength:{number:b},springConstant:{number:b},damping:{number:b},avoidOverlap:{number:b},__type__:{object:I}},repulsion:{centralGravity:{number:b},springLength:{number:b},springConstant:{number:b},nodeDistance:{number:b},damping:{number:b},__type__:{object:I}},hierarchicalRepulsion:{centralGravity:{number:b},springLength:{number:b},springConstant:{number:b},nodeDistance:{number:b},damping:{number:b},avoidOverlap:{number:b},__type__:{object:I}},maxVelocity:{number:b},minVelocity:{number:b},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{boolean:E},iterations:{number:b},updateInterval:{number:b},onlyDynamicEdges:{boolean:E},fit:{boolean:E},__type__:{object:I,boolean:E}},timestep:{number:b},adaptiveTimestep:{boolean:E},wind:{x:{number:b},y:{number:b},__type__:{object:I}},__type__:{object:I,boolean:E}},autoResize:{boolean:E},clickToUse:{boolean:E},locale:{string:T},locales:{__any__:{any:Ma},__type__:{object:I}},height:{string:T},width:{string:T},__type__:{object:I}},bn={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=(r,e,t)=>!!(r.includes("physics")&&bn.physics.solver.includes(e)&&t.physics.solver!==e&&e!=="wind");var zs=class{constructor(){}getDistances(e,t,s){let o={},n=e.edges;for(let d=0;dn&&da&&_this.body.emitter.emit("_requestRedraw")),this.groups=new Wi,this.canvas=new Cs(this.body),this.selectionHandler=new Ms(this.body,this.canvas),this.interactionHandler=new Ss(this.body,this.canvas,this.selectionHandler),this.view=new ks(this.body,this.canvas),this.renderer=new Ts(this.body,this.canvas),this.physics=new _s(this.body),this.layoutEngine=new Bs(this.body),this.clustering=new xs(this.body),this.manipulation=new As(this.body,this.canvas,this.selectionHandler,this.interactionHandler),this.nodesHandler=new is(this.body,this.images,this.groups,this.layoutEngine),this.edgesHandler=new gs(this.body,this.images,this.groups),this.body.modules.kamadaKawai=new Rs(this.body,150,.05),this.body.modules.clustering=this.clustering,this.canvas._create(),this.setOptions(t),this.setData(e)}(0,sn.default)(S.prototype);S.prototype.setOptions=function(r){if(r===null&&(r=void 0),r!==void 0){if(Uo.validate(r,Da)===!0&&console.error("%cErrors have been found in the supplied options object.",Mi),$e(["locale","locales","clickToUse"],this.options,r),r.locale!==void 0&&(r.locale=ba(r.locales||this.options.locales,r.locale)),r=this.layoutEngine.setOptions(r.layout,r),this.canvas.setOptions(r),this.groups.setOptions(r.groups),this.nodesHandler.setOptions(r.nodes),this.edgesHandler.setOptions(r.edges),this.physics.setOptions(r.physics),this.manipulation.setOptions(r.manipulation,r,this.options),this.interactionHandler.setOptions(r.interaction),this.renderer.setOptions(r.interaction),this.selectionHandler.setOptions(r.interaction),r.groups!==void 0&&this.body.emitter.emit("refreshNodes"),"configure"in r&&(this.configurator||(this.configurator=new qo(this,this.body.container,bn,this.canvas.pixelRatio,Na)),this.configurator.setOptions(r.configure)),this.configurator&&this.configurator.options.enabled===!0){let s={nodes:{},edges:{},layout:{},interaction:{},manipulation:{},physics:{},global:{}};V(s.nodes,this.nodesHandler.options),V(s.edges,this.edgesHandler.options),V(s.layout,this.layoutEngine.options),V(s.interaction,this.selectionHandler.options),V(s.interaction,this.renderer.options),V(s.interaction,this.interactionHandler.options),V(s.manipulation,this.manipulation.options),V(s.physics,this.physics.options),V(s.global,this.canvas.options),V(s.global,this.options),this.configurator.setModuleOptions(s)}r.clickToUse!==void 0?r.clickToUse===!0?this.activator===void 0&&(this.activator=new Vo(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")}};S.prototype._updateVisibleIndices=function(){let r=this.body.nodes,e=this.body.edges;this.body.nodeIndices=[],this.body.edgeIndices=[];for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&!this.clustering._isClusteredNode(t)&&r[t].options.hidden===!1&&this.body.nodeIndices.push(r[t].id);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let s=e[t],o=r[s.fromId],n=r[s.toId],a=o!==void 0&&n!==void 0;!this.clustering._isClusteredEdge(t)&&s.options.hidden===!1&&a&&o.options.hidden===!1&&n.options.hidden===!1&&this.body.edgeIndices.push(s.id)}};S.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")})};S.prototype.setData=function(r){if(this.body.emitter.emit("resetPhysics"),this.body.emitter.emit("_resetData"),this.selectionHandler.unselectAll(),r&&r.dot&&(r.nodes||r.edges))throw new SyntaxError('Data must contain either parameter "dot" or parameter pair "nodes" and "edges", but not both.');if(this.setOptions(r&&r.options),r&&r.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=oa(r.dot);this.setData(e);return}else if(r&&r.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=na(r.gephi);this.setData(e);return}else this.nodesHandler.setData(r&&r.nodes,!0),this.edgesHandler.setData(r&&r.edges,!0);this.body.emitter.emit("_dataChanged"),this.body.emitter.emit("_dataLoaded"),this.body.emitter.emit("initPhysics")};S.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 r in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,r)&&delete this.body.nodes[r];for(let r in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,r)&&delete this.body.edges[r];Pe(this.body.container)};S.prototype._updateValueRange=function(r){let e,t,s,o=0;for(e in r)if(Object.prototype.hasOwnProperty.call(r,e)){let n=r[e].getValue();n!==void 0&&(t=t===void 0?n:Math.min(n,t),s=s===void 0?n:Math.max(n,s),o+=n)}if(t!==void 0&&s!==void 0)for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&r[e].setValueRange(t,s,o)};S.prototype.isActive=function(){return!this.activator||this.activator.active};S.prototype.setSize=function(){return this.canvas.setSize.apply(this.canvas,arguments)};S.prototype.canvasToDOM=function(){return this.canvas.canvasToDOM.apply(this.canvas,arguments)};S.prototype.DOMtoCanvas=function(){return this.canvas.DOMtoCanvas.apply(this.canvas,arguments)};S.prototype.findNode=function(){return this.clustering.findNode.apply(this.clustering,arguments)};S.prototype.isCluster=function(){return this.clustering.isCluster.apply(this.clustering,arguments)};S.prototype.openCluster=function(){return this.clustering.openCluster.apply(this.clustering,arguments)};S.prototype.cluster=function(){return this.clustering.cluster.apply(this.clustering,arguments)};S.prototype.getNodesInCluster=function(){return this.clustering.getNodesInCluster.apply(this.clustering,arguments)};S.prototype.clusterByConnection=function(){return this.clustering.clusterByConnection.apply(this.clustering,arguments)};S.prototype.clusterByHubsize=function(){return this.clustering.clusterByHubsize.apply(this.clustering,arguments)};S.prototype.updateClusteredNode=function(){return this.clustering.updateClusteredNode.apply(this.clustering,arguments)};S.prototype.getClusteredEdges=function(){return this.clustering.getClusteredEdges.apply(this.clustering,arguments)};S.prototype.getBaseEdge=function(){return this.clustering.getBaseEdge.apply(this.clustering,arguments)};S.prototype.getBaseEdges=function(){return this.clustering.getBaseEdges.apply(this.clustering,arguments)};S.prototype.updateEdge=function(){return this.clustering.updateEdge.apply(this.clustering,arguments)};S.prototype.clusterOutliers=function(){return this.clustering.clusterOutliers.apply(this.clustering,arguments)};S.prototype.getSeed=function(){return this.layoutEngine.getSeed.apply(this.layoutEngine,arguments)};S.prototype.enableEditMode=function(){return this.manipulation.enableEditMode.apply(this.manipulation,arguments)};S.prototype.disableEditMode=function(){return this.manipulation.disableEditMode.apply(this.manipulation,arguments)};S.prototype.addNodeMode=function(){return this.manipulation.addNodeMode.apply(this.manipulation,arguments)};S.prototype.editNode=function(){return this.manipulation.editNode.apply(this.manipulation,arguments)};S.prototype.editNodeMode=function(){return console.warn("Deprecated: Please use editNode instead of editNodeMode."),this.manipulation.editNode.apply(this.manipulation,arguments)};S.prototype.addEdgeMode=function(){return this.manipulation.addEdgeMode.apply(this.manipulation,arguments)};S.prototype.editEdgeMode=function(){return this.manipulation.editEdgeMode.apply(this.manipulation,arguments)};S.prototype.deleteSelected=function(){return this.manipulation.deleteSelected.apply(this.manipulation,arguments)};S.prototype.getPositions=function(){return this.nodesHandler.getPositions.apply(this.nodesHandler,arguments)};S.prototype.getPosition=function(){return this.nodesHandler.getPosition.apply(this.nodesHandler,arguments)};S.prototype.storePositions=function(){return this.nodesHandler.storePositions.apply(this.nodesHandler,arguments)};S.prototype.moveNode=function(){return this.nodesHandler.moveNode.apply(this.nodesHandler,arguments)};S.prototype.getBoundingBox=function(){return this.nodesHandler.getBoundingBox.apply(this.nodesHandler,arguments)};S.prototype.getConnectedNodes=function(r){return this.body.nodes[r]!==void 0?this.nodesHandler.getConnectedNodes.apply(this.nodesHandler,arguments):this.edgesHandler.getConnectedNodes.apply(this.edgesHandler,arguments)};S.prototype.getConnectedEdges=function(){return this.nodesHandler.getConnectedEdges.apply(this.nodesHandler,arguments)};S.prototype.startSimulation=function(){return this.physics.startSimulation.apply(this.physics,arguments)};S.prototype.stopSimulation=function(){return this.physics.stopSimulation.apply(this.physics,arguments)};S.prototype.stabilize=function(){return this.physics.stabilize.apply(this.physics,arguments)};S.prototype.getSelection=function(){return this.selectionHandler.getSelection.apply(this.selectionHandler,arguments)};S.prototype.setSelection=function(){return this.selectionHandler.setSelection.apply(this.selectionHandler,arguments)};S.prototype.getSelectedNodes=function(){return this.selectionHandler.getSelectedNodeIds.apply(this.selectionHandler,arguments)};S.prototype.getSelectedEdges=function(){return this.selectionHandler.getSelectedEdgeIds.apply(this.selectionHandler,arguments)};S.prototype.getNodeAt=function(){let r=this.selectionHandler.getNodeAt.apply(this.selectionHandler,arguments);return r!==void 0&&r.id!==void 0?r.id:r};S.prototype.getEdgeAt=function(){let r=this.selectionHandler.getEdgeAt.apply(this.selectionHandler,arguments);return r!==void 0&&r.id!==void 0?r.id:r};S.prototype.selectNodes=function(){return this.selectionHandler.selectNodes.apply(this.selectionHandler,arguments)};S.prototype.selectEdges=function(){return this.selectionHandler.selectEdges.apply(this.selectionHandler,arguments)};S.prototype.unselectAll=function(){this.selectionHandler.unselectAll.apply(this.selectionHandler,arguments),this.selectionHandler.commitWithoutEmitting.apply(this.selectionHandler),this.redraw()};S.prototype.redraw=function(){return this.renderer.redraw.apply(this.renderer,arguments)};S.prototype.getScale=function(){return this.view.getScale.apply(this.view,arguments)};S.prototype.getViewPosition=function(){return this.view.getViewPosition.apply(this.view,arguments)};S.prototype.fit=function(){return this.view.fit.apply(this.view,arguments)};S.prototype.moveTo=function(){return this.view.moveTo.apply(this.view,arguments)};S.prototype.focus=function(){return this.view.focus.apply(this.view,arguments)};S.prototype.releaseNode=function(){return this.view.releaseNode.apply(this.view,arguments)};S.prototype.getOptionsFromConfigurator=function(){let r={};return this.configurator&&(r=this.configurator.getOptions.apply(this.configurator)),r};var Ws={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"}},A=null,wn=document.querySelector("#visgraph"),vn=document.querySelector("#id_save_coords");(function(){if(!topologyData)return;function e(w){let k=document.createElement("div");return k.innerHTML=w,k}let t=new Te(topologyData.nodes.map(w=>je(be({},w),{title:e(w.title)})));window.nodes=t;let s=new Te(topologyData.edges.map(w=>je(be({},w),{title:e(w.title)}))),o=topologyData.options.group_sites,n=topologyData.options.group_locations,a=topologyData.options.group_racks,d=topologyData.options.group_virtualchassis,h=parseInt(topologyData.options.grid_size[0]);var l=!1;A=new S(wn,{nodes:t,edges:s},Ws),A.fit();function c(w,k){return x=A.getPosition(w).x,y=A.getPosition(w).y,x>=0?x%k>k/2&&(x+=k):-x%k>k/2&&(x-=k),x=x-x%k,y>=0?y%k>k/2&&(y+=k):-y%k>k/2&&(y-=k),y=y-y%k,{x,y}}function u(w){let k=A.getScale()*window.devicePixelRatio,L=w.canvas.width/k,K=w.canvas.height/k,H=A.getViewPosition(),R=H.x-H.x%h,z=H.y-H.y%h,j=L/2-L/2%h+h,Z=K/2-K/2%h+h,$=R-h-j,ie=R+h+j,pe=z-h-Z,we=z+h+Z;w.beginPath();for(let le=$;le0&&l==!0&&A.getSelectedNodes().length>0)for(i=0;i{l=!0}),A.on("dragEnd",w=>{if(l=!1,h>0&&A.getSelectedNodes().length>0)for(i=0;iUs(null,[K],function*([k,L]){isNaN(parseInt(k))?nodeKey=k:nodeKey=parseInt(k);try{window.nodes.update({id:nodeKey,physics:!1,x:L.x,y:L.y})}catch(R){console.log(["Error while executing window.nodes.update()","nodeId: "+k,"nodeKey: "+nodeKey,"x: "+L.x,"y: "+L.y]),console.log(R)}let H=yield fetch("/"+basePath+"api/plugins/netbox_topology_views/save-coords/save_coords/",{method:"PATCH",headers:{"X-CSRFToken":window.CSRF_TOKEN,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({node_id:k,x:L.x,y:L.y,group:topologyData.group})})})))}),A.on("doubleClick",w=>{w.nodes.length>0?w.nodes.forEach(k=>{window.open(t.get(k).href,"_blank")}):w.edges.forEach(k=>{window.open(s.get(k).href,"_blank")})}),A.on("beforeDrawing",w=>{h>0&&u(w)}),A.on("afterDrawing",w=>{g=[],o!=null&&o=="on"&&m(w,v,C),n!=null&&n=="on"&&m(w,O,P),a!=null&&a=="on"&&m(w,D,N),d!=null&&d=="on"&&m(w,W,X),f(w)}),A.on("click",w=>{g.forEach(k=>{if(w.pointer.canvas.x>k.x1-k.border/2-3&&w.pointer.canvas.xk.y1-k.border/2-3&&w.pointer.canvas.yk.x2-k.border/2-3||w.pointer.canvas.yk.y2-k.border/2-3)){let L=[];k.category=="Site"&&v.forEach(K=>{K.forEach(H=>{H[1]==k.id&&L.push(H[0])})}),k.category=="Location"&&O.forEach(K=>{K.forEach(H=>{H[1]===k.id&&L.push(H[0])})}),k.category=="Rack"&&D.forEach(K=>{K.forEach(H=>{H[1]===k.id&&L.push(H[0])})}),k.category=="Virtual Chassis"&&W.forEach(K=>{K.forEach(H=>{H[1]===k.id&&L.push(H[0])})}),A.selectNodes(L)}})});function p(w,k){let L=[];for(let[H,R]of t._data)R[w]!=null&&L.push([R.id,R[w],R[k],R.label_num_lines]);let K=L.reduce((H,R)=>{let z=R[1];return H[z]=H[z]||[],H[z].push(R),H},{});return Object.values(K)}var g=[];function _(w){w.ctx.beginPath(),w.ctx.lineWidth=w.lineWidth,w.ctx.strokeStyle=w.color,w.ctx.rect(w.x,w.y,w.width,w.height),w.ctx.stroke(),w.ctx.font=w.font,w.ctx.fillStyle=w.color,w.ctx.fillText(w.text,w.x+w.textPaddingX,w.y+w.textPaddingY),g.push({category:w.category,id:w.id,x1:w.x,y1:w.y,x2:w.x+w.width,y2:w.y+w.height,border:w.lineWidth})}function m(w,k,L){for(let K of Object.entries(k)){let H=[],R=[],z=[],j=[];for(let dt of K[1])R.push(A.getPosition(dt[0]).x),z.push(A.getPosition(dt[0]).y),j.push(z[z.length-1]+dt[3]*16);let $=Math.min(...R),ie=Math.max(...R),pe=Math.min(...z),we=Math.max(...j),le=$-L.paddingX,_n=pe-L.paddingY,En=ie-$+2*L.paddingX,xn=we-pe+2*L.paddingY;H.push({ctx:w,x:le,y:_n,width:En,height:xn,lineWidth:L.lineWidth,color:L.color,text:K[1][0][2],textPaddingX:L.textPaddingX,textPaddingY:L.textPaddingY,font:L.font,id:K[1][0][1],category:L.category}),H.forEach(function(dt){_(dt)})}}let v=p("site_id","site"),C={lineWidth:"5",color:"red",paddingX:84,paddingY:84,textPaddingX:8,textPaddingY:-8,font:"14px helvetica",category:"Site"},O=p("location_id","location"),P={lineWidth:"5",color:"#337ab7",paddingX:77,paddingY:77,textPaddingX:22,textPaddingY:29,font:"14px helvetica",category:"Location"},D=p("rack_id","rack"),N={lineWidth:"5",color:"green",paddingX:70,paddingY:70,textPaddingX:15,textPaddingY:36,font:"14px helvetica",category:"Rack"},W=p("virtual_chassis_id","virtual_chassis"),X={lineWidth:"5",color:"orange",paddingX:63,paddingY:63,textPaddingX:8,textPaddingY:43,font:"14px helvetica",category:"Virtual Chassis"}})();var Fa="image/png",Ba=document.querySelector("#btnDownloadImage");Ba.addEventListener("click",r=>{Aa()});function Aa(){let r=wn.querySelector("canvas"),e=document.createElement("a"),t=r.toDataURL(Fa);e.href=t,e.download="topology",document.body.appendChild(e),e.click(),document.body.removeChild(e)}var za=document.querySelector("#btnDownloadXml");za.addEventListener("click",r=>{Ra()});function Ra(){let r=document.createElement("a"),e="";if(typeof is_htmx!="undefined"){var t=window.location.href;let n="/sites/",a="/locations/";if(t.includes(n)){var s=t.split(n)[1];s=s.split("/")[0],e="site_id="+s+"&show_cables=True&show_unconnected=True"}else if(t.includes(a)){var o=t.split(a)[1];o=o.split("/")[0],e="location_id="+o+"&show_cables=True&show_unconnected=True"}}else e=new URLSearchParams(window.location.search);fetch("/"+basePath+"api/plugins/netbox_topology_views/xml-export/?"+e).then(n=>n.text()).then(n=>{var a=new Blob([n],{type:"text/plain"});r.setAttribute("href",window.URL.createObjectURL(a)),r.setAttribute("download","topology.xml"),r.dataset.downloadurl=["text/plain",r.download,r.href].join(":"),r.click()})}var La=new MutationObserver(r=>r.forEach(e=>{if(!A||e.type!=="attributes"||e.attributeName!=="data-bs-theme"||!(e.target instanceof HTMLElement))return;let t=e.target.dataset.bsTheme;Ws.nodes.font.color=t==="dark"?"#fff":"#000",A.setOptions(Ws)}));La.observe(document.body,{attributes:!0,attributeFilter:["data-bs-theme"]});})(); +`),o=s.length;if(t.multi)for(let n=0;n0)for(let d=0;d0)for(let n=0;n/&/.test(o)?(t.replace(t.text,"<","<")||t.replace(t.text,"&","&")||t.add("&"),!0):!1;for(;t.position")||t.parseStartTag("ital","")||t.parseStartTag("mono","")||t.parseEndTag("bold","")||t.parseEndTag("ital","")||t.parseEndTag("mono",""))||s(o)||t.add(o),t.position++}return t.emitBlock(),t.blocks}splitMarkdownBlocks(e){let t=new Zt(e),s=!0,o=n=>/\\/.test(n)?(t.positionthis.parent.fontOptions.maxWdt}getLongestFit(e){let t="",s=0;for(;s0;){let n=this.getLongestFit(o);if(n===0){let a=o[0],d=this.getLongestFitWord(a);this.lines.newLine(a.slice(0,d),t),o[0]=a.slice(d)}else{let a=n;o[n-1]===" "?n--:o[a]===" "&&a++;let d=o.slice(0,n).join("");n==o.length&&s?this.lines.append(d,t):this.lines.newLine(d,t),o=o.slice(a)}}}},Gt=["bold","ital","boldital","mono"],Qt=class r{constructor(e,t,s=!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=s}setOptions(e){if(this.elementOptions=e,this.initFontOptions(e.font),$t(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(F(Gt,t=>{this.fontOptions[t]={}}),r.parseFontString(this.fontOptions,e)){this.fontOptions.vadjust=0;return}F(e,(t,s)=>{t!=null&&typeof t!="object"&&(this.fontOptions[s]=t)})}static parseFontString(e,t){if(!t||typeof t!="string")return!1;let s=t.split(" ");return e.size=+s[0].replace("px",""),e.face=s[1],e.color=s[2],!0}constrain(e){let t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},s=De(e,"widthConstraint");if(typeof s=="number")t.maxWdt=Number(s),t.minWdt=Number(s);else if(typeof s=="object"){let n=De(e,["widthConstraint","maximum"]);typeof n=="number"&&(t.maxWdt=Number(n));let a=De(e,["widthConstraint","minimum"]);typeof a=="number"&&(t.minWdt=Number(a))}let o=De(e,"heightConstraint");if(typeof o=="number")t.minHgt=Number(o);else if(typeof o=="object"){let n=De(e,["heightConstraint","minimum"]);typeof n=="number"&&(t.minHgt=Number(n));let a=De(e,["heightConstraint","valign"]);typeof a=="string"&&(a==="top"||a==="bottom")&&(t.valign=a)}return t}update(e,t){this.setOptions(e,!0),this.propagateFonts(t),V(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=js("label",t)}adjustSizes(e){let t=e?e.right+e.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);let s=e?e.top+e.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=s)}addFontOptionsToPile(e,t){for(let s=0;s{a!==void 0&&(Object.prototype.hasOwnProperty.call(t,d)||(Gt.indexOf(d)!==-1?t[d]={}:t[d]=a))})}return t}getFontOption(e,t,s){let o;for(let n=0;n{n[h]=d}),n.size=Number(n.size),n.vadjust=Number(n.vadjust)}}draw(e,t,s,o,n,a="middle"){if(this.elementOptions.label===void 0)return;let d=this.fontOptions.size*this.body.view.scale;this.elementOptions.label&&d=this.elementOptions.scaling.label.maxVisible&&(d=Number(this.elementOptions.scaling.label.maxVisible)/this.body.view.scale),this.calculateLabelSize(e,o,n,t,s,a),this._drawBackground(e),this._drawText(e,t,this.size.yLine,a,d))}_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,s,o="middle",n){[t,s]=this._setAlignment(e,t,s,o),e.textAlign="left",t=t-this.size.width/2,this.fontOptions.valign&&this.size.height>this.size.labelHeight&&(this.fontOptions.valign==="top"&&(s-=(this.size.height-this.size.labelHeight)/2),this.fontOptions.valign==="bottom"&&(s+=(this.size.height-this.size.labelHeight)/2));for(let a=0;a0&&(e.lineWidth=c.strokeWidth,e.strokeStyle=f,e.lineJoin="round"),e.fillStyle=u,c.strokeWidth>0&&e.strokeText(c.text,t+h,s+c.vadjust),e.fillText(c.text,t+h,s+c.vadjust),h+=c.width}s+=d.height}}}_setAlignment(e,t,s,o){if(this.isEdgeLabel&&this.fontOptions.align!=="horizontal"&&this.pointToSelf===!1){t=0,s=0;let n=2;this.fontOptions.align==="top"?(e.textBaseline="alphabetic",s-=2*n):this.fontOptions.align==="bottom"?(e.textBaseline="hanging",s+=2*n):e.textBaseline="middle"}else e.textBaseline=o;return[t,s]}_getColor(e,t,s){let o=e||"#000000",n=s||"#ffffff";if(t<=this.elementOptions.scaling.label.drawThreshold){let a=Math.max(0,Math.min(1,1-(this.elementOptions.scaling.label.drawThreshold-t)));o=ue(o,a),n=ue(n,a)}return[o,n]}getTextSize(e,t=!1,s=!1){return this._processLabel(e,t,s),{width:this.size.width,height:this.size.height,lineCount:this.lineCount}}getSize(){let t=this.size.left,s=this.size.top-.5*2;if(this.isEdgeLabel){let n=-this.size.width*.5;switch(this.fontOptions.align){case"middle":t=n,s=-this.size.height*.5;break;case"top":t=n,s=-(this.size.height+2);break;case"bottom":t=n,s=2;break}}return{left:t,top:s,width:this.size.width,height:this.size.height}}calculateLabelSize(e,t,s,o=0,n=0,a="middle"){this._processLabel(e,t,s),this.size.left=o-this.size.width*.5,this.size.top=n-this.size.height*.5,this.size.yLine=n+(1-this.lineCount)*.5*this.fontOptions.size,a==="hanging"&&(this.size.top+=.5*this.fontOptions.size,this.size.top+=4,this.size.yLine+=4)}getFormattingValues(e,t,s,o){let n=function(h,l,c){return l==="normal"?c==="mod"?"":h[c]:h[l][c]!==void 0?h[l][c]:h[c]},a={color:n(this.fontOptions,o,"color"),size:n(this.fontOptions,o,"size"),face:n(this.fontOptions,o,"face"),mod:n(this.fontOptions,o,"mod"),vadjust:n(this.fontOptions,o,"vadjust"),strokeWidth:this.fontOptions.strokeWidth,strokeColor:this.fontOptions.strokeColor};(t||s)&&(o==="normal"&&this.fontOptions.chooser===!0&&this.elementOptions.labelHighlightBold?a.mod="bold":typeof this.fontOptions.chooser=="function"&&this.fontOptions.chooser(a,this.elementOptions.id,t,s));let d="";return a.mod!==void 0&&a.mod!==""&&(d+=a.mod+" "),d+=a.size+"px "+a.face,e.font=d.replace(/"/g,""),a.font=e.font,a.height=a.size,a}differentState(e,t){return e!==this.selectedState||t!==this.hoverState}_processLabelText(e,t,s,o){return new Yi(e,this,t,s).process(o)}_processLabel(e,t,s){if(this.labelDirty===!1&&!this.differentState(t,s))return;let o=this._processLabelText(e,t,s,this.elementOptions.label);this.fontOptions.minWdt>0&&o.width0&&o.height0&&(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,s,o,n){s!==void 0&&this.resize(s,o,n),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,s,o,n){this._updateBoundingBox(e,t,s,o,n)}getDimensionsFromLabel(e,t,s){this.textSize=this.labelModule.getTextSize(e,t,s);let o=this.textSize.width,n=this.textSize.height,a=14;return o===0&&(o=a,n=a),{width:o,height:n}}},_a=class extends Fe{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t=this.selected,s=this.hover){if(this.needsRefresh(t,s)){let o=this.getDimensionsFromLabel(e,t,s);this.width=o.width+this.margin.right+this.margin.left,this.height=o.height+this.margin.top+this.margin.bottom,this.radius=this.width/2}}draw(e,t,s,o,n,a){this.resize(e,o,n),this.left=t-this.width/2,this.top=s-this.height/2,this.initContextForDraw(e,a),on(e,this.left,this.top,this.width,this.height,a.borderRadius),this.performFill(e,a),this.updateBoundingBox(t,s,e,o,n),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,o,n)}updateBoundingBox(e,t,s,o,n){this._updateBoundingBox(e,t,s,o,n);let a=this.options.shapeProperties.borderRadius;this._addBoundingBoxMargin(a)}distanceToBorder(e,t){e&&this.resize(e);let s=this.options.borderWidth;return Math.min(Math.abs(this.width/2/Math.cos(t)),Math.abs(this.height/2/Math.sin(t)))+s}},St=class extends Fe{constructor(e,t,s){super(e,t,s),this.labelOffset=0,this.selected=!1}setOptions(e,t,s){this.options=e,t===void 0&&s===void 0||this.setImages(t,s)}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 s=this.imageObj;this.imageObj=this.imageObjAlt,this.imageObjAlt=s}}_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 s=1,o=1;this.imageObj.width&&this.imageObj.height&&(this.imageObj.width>this.imageObj.height?s=this.imageObj.width/this.imageObj.height:o=this.imageObj.height/this.imageObj.width),e=this.options.size*2*s,t=this.options.size*2*o}else{let s=this._getImagePadding();e=this.imageObj.width+s.left+s.right,t=this.imageObj.height+s.top+s.bottom}this.width=e,this.height=t,this.radius=.5*this.width}_drawRawCircle(e,t,s,o){this.initContextForDraw(e,o),Ls(e,t,s,o.size),this.performFill(e,o)}_drawImageAtPosition(e,t){if(this.imageObj.width!=0){e.globalAlpha=t.opacity!==void 0?t.opacity:1,this.enableShadow(e,t);let s=1;this.options.shapeProperties.interpolation===!0&&(s=this.imageObj.width/this.width/this.body.view.scale);let o=this._getImagePadding(),n=this.left+o.left,a=this.top+o.top,d=this.width-o.left-o.right,h=this.height-o.top-o.bottom;this.imageObj.drawImageAtPosition(e,s,n,a,d,h),this.disableShadow(e,t)}}_drawImageLabel(e,t,s,o,n){let a=0;if(this.height!==void 0){a=this.height*.5;let h=this.labelModule.getTextSize(e,o,n);h.lineCount>=1&&(a+=h.height/2)}let d=s+a;this.options.label&&(this.labelOffset=a),this.labelModule.draw(e,t,d,o,n,"hanging")}},Ea=class extends St{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t=this.selected,s=this.hover){if(this.needsRefresh(t,s)){let o=this.getDimensionsFromLabel(e,t,s),n=Math.max(o.width+this.margin.right+this.margin.left,o.height+this.margin.top+this.margin.bottom);this.options.size=n/2,this.width=n,this.height=n,this.radius=this.width/2}}draw(e,t,s,o,n,a){this.resize(e,o,n),this.left=t-this.width/2,this.top=s-this.height/2,this._drawRawCircle(e,t,s,a),this.updateBoundingBox(t,s),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,s,o,n)}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}},Xi=class extends St{constructor(e,t,s,o,n){super(e,t,s),this.setImages(o,n)}resize(e,t=this.selected,s=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let n=this.options.size*2;this.width=n,this.height=n,this.radius=.5*this.width;return}this.needsRefresh(t,s)&&this._resizeImage()}draw(e,t,s,o,n,a){this.switchImages(o),this.resize();let d=t,h=s;this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=s,d+=this.width/2,h+=this.height/2):(this.left=t-this.width/2,this.top=s-this.height/2),this._drawRawCircle(e,d,h,a),e.save(),e.clip(),this._drawImageAtPosition(e,a),e.restore(),this._drawImageLabel(e,d,h,o,n),this.updateBoundingBox(t,s)}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}},Ce=class extends Fe{constructor(e,t,s){super(e,t,s)}resize(e,t=this.selected,s=this.hover,o={size:this.options.size}){var n,a;if(this.needsRefresh(t,s)){this.labelModule.getTextSize(e,t,s);let d=2*o.size;this.width=(n=this.customSizeWidth)!=null?n:d,this.height=(a=this.customSizeHeight)!=null?a:d,this.radius=.5*this.width}}_drawShape(e,t,s,o,n,a,d,h){return this.resize(e,a,d,h),this.left=o-this.width/2,this.top=n-this.height/2,this.initContextForDraw(e,h),Kr(t)(e,o,n,h.size),this.performFill(e,h),this.options.icon!==void 0&&this.options.icon.code!==void 0&&(e.font=(a?"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,o,n)),{drawExternalLabel:()=>{if(this.options.label!==void 0){this.labelModule.calculateLabelSize(e,a,d,o,n,"hanging");let l=n+.5*this.height+.5*this.labelModule.size.height;this.labelModule.draw(e,o,l,a,d,"hanging")}this.updateBoundingBox(o,n)}}}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))}},Ui=class extends Ce{constructor(e,t,s,o){super(e,t,s,o),this.ctxRenderer=o}draw(e,t,s,o,n,a){this.resize(e,o,n,a),this.left=t-this.width/2,this.top=s-this.height/2,e.save();let d=this.ctxRenderer({ctx:e,id:this.options.id,x:t,y:s,state:{selected:o,hover:n},style:ge({},a),label:this.options.label});if(d.drawNode!=null&&d.drawNode(),e.restore(),d.drawExternalLabel){let h=d.drawExternalLabel;d.drawExternalLabel=()=>{e.save(),h(),e.restore()}}return d.nodeDimensions&&(this.customSizeWidth=d.nodeDimensions.width,this.customSizeHeight=d.nodeDimensions.height),d}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Gi=class extends Fe{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t,s){if(this.needsRefresh(t,s)){let n=this.getDimensionsFromLabel(e,t,s).width+this.margin.right+this.margin.left;this.width=n,this.height=n,this.radius=this.width/2}}draw(e,t,s,o,n,a){this.resize(e,o,n),this.left=t-this.width/2,this.top=s-this.height/2,this.initContextForDraw(e,a),nn(e,t-this.width/2,s-this.height/2,this.width,this.height),this.performFill(e,a),this.updateBoundingBox(t,s,e,o,n),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,o,n)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},xa=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"diamond",4,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ki=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"circle",2,t,s,o,n,a)}distanceToBorder(e){return e&&this.resize(e),this.options.size}},Jt=class extends Fe{constructor(e,t,s){super(e,t,s)}resize(e,t=this.selected,s=this.hover){if(this.needsRefresh(t,s)){let o=this.getDimensionsFromLabel(e,t,s);this.height=o.height*2,this.width=o.width+o.height,this.radius=.5*this.width}}draw(e,t,s,o,n,a){this.resize(e,o,n),this.left=t-this.width*.5,this.top=s-this.height*.5,this.initContextForDraw(e,a),Li(e,this.left,this.top,this.width,this.height),this.performFill(e,a),this.updateBoundingBox(t,s,e,o,n),this.labelModule.draw(e,t,s,o,n)}distanceToBorder(e,t){e&&this.resize(e);let s=this.width*.5,o=this.height*.5,n=Math.sin(t)*s,a=Math.cos(t)*o;return s*o/Math.sqrt(n*n+a*a)}},$i=class extends Fe{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t,s){this.needsRefresh(t,s)&&(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,s,o,n,a){return this.resize(e,o,n),this.options.icon.size=this.options.icon.size||50,this.left=t-this.width/2,this.top=s-this.height/2,this._icon(e,t,s,o,n,a),{drawExternalLabel:()=>{this.options.label!==void 0&&this.labelModule.draw(e,this.left+this.iconSize.width/2+this.margin.left,s+this.height/2+5,o),this.updateBoundingBox(t,s)}}}updateBoundingBox(e,t){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&&(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+5))}_icon(e,t,s,o,n,a){let d=Number(this.options.icon.size);this.options.icon.code!==void 0?(e.font=[this.options.icon.weight!=null?this.options.icon.weight:o?"bold":"",(this.options.icon.weight!=null&&o?5:0)+d+"px",this.options.icon.face].join(" "),e.fillStyle=this.options.icon.color||"black",e.textAlign="center",e.textBaseline="middle",this.enableShadow(e,a),e.fillText(this.options.icon.code,t,s),this.disableShadow(e,a)):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)}},Ta=class extends St{constructor(e,t,s,o,n){super(e,t,s),this.setImages(o,n)}resize(e,t=this.selected,s=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let n=this.options.size*2;this.width=n,this.height=n;return}this.needsRefresh(t,s)&&this._resizeImage()}draw(e,t,s,o,n,a){e.save(),this.switchImages(o),this.resize();let d=t,h=s;if(this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=s,d+=this.width/2,h+=this.height/2):(this.left=t-this.width/2,this.top=s-this.height/2),this.options.shapeProperties.useBorderWithImage===!0){let l=this.options.borderWidth,c=this.options.borderWidthSelected||2*this.options.borderWidth,u=(o?c:l)/this.body.view.scale;e.lineWidth=Math.min(this.width,u),e.beginPath();let f=o?this.options.color.highlight.border:n?this.options.color.hover.border:this.options.color.border,p=o?this.options.color.highlight.background:n?this.options.color.hover.background:this.options.color.background;a.opacity!==void 0&&(f=ue(f,a.opacity),p=ue(p,a.opacity)),e.strokeStyle=f,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,a),e.closePath()}this._drawImageAtPosition(e,a),this._drawImageLabel(e,d,h,o,n),this.updateBoundingBox(t,s),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)}},Zi=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"square",2,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Qi=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"hexagon",4,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ji=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"star",4,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},es=class extends Fe{constructor(e,t,s){super(e,t,s),this._setMargins(s)}resize(e,t,s){this.needsRefresh(t,s)&&(this.textSize=this.labelModule.getTextSize(e,t,s),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,s,o,n,a){this.resize(e,o,n),this.left=t-this.width/2,this.top=s-this.height/2,this.enableShadow(e,a),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,o,n),this.disableShadow(e,a),this.updateBoundingBox(t,s,e,o,n)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ca=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"triangle",3,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},ts=class extends Ce{constructor(e,t,s){super(e,t,s)}draw(e,t,s,o,n,a){return this._drawShape(e,"triangleDown",3,t,s,o,n,a)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},ne=class r{constructor(e,t,s,o,n,a){this.options=Me(n),this.globalOptions=n,this.defaultOptions=a,this.body=t,this.edges=[],this.id=void 0,this.imagelist=s,this.grouplist=o,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 Qt(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");r.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)),r.parseOptions(this.options,e,!0,this.globalOptions,this.grouplist);let s=[e,this.options,this.defaultOptions];return this.chooser=js("node",s),this._load_images(),this.updateLabelModule(e),e.opacity!==void 0&&r.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,s){if(s===void 0)return;let o=e.group;if(t!==void 0&&t.group!==void 0&&o!==t.group)throw new Error("updateGroupOptions: group values in options don't match.");if(!(typeof o=="number"||typeof o=="string"&&o!=""))return;let a=s.get(o);a.opacity!==void 0&&t.opacity===void 0&&(r.checkOpacity(a.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+a.opacity),a.opacity=void 0));let d=Object.getOwnPropertyNames(t).filter(h=>t[h]!=null);d.push("font"),Tt(d,e,a),e.color=Vt(e.color)}static parseOptions(e,t,s=!1,o={},n){if(Tt(["color","fixed","shadow"],e,t,s),r.checkMass(t),e.opacity!==void 0&&(r.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&&(r.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&&!r.checkCoordinateOrigin(t.shapeProperties.coordinateOrigin)&&console.error("Invalid option for node coordinateOrigin, found: "+t.shapeProperties.coordinateOrigin),fe(e,t,"shadow",o),t.color!==void 0&&t.color!==null){let d=Vt(t.color);Ii(e.color,d)}else s===!0&&t.color===null&&(e.color=Me(o.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))),s===!0&&t.font===null&&(e.font=Me(o.font)),r.updateGroupOptions(e,t,n),t.scaling!==void 0&&fe(e.scaling,t.scaling,"label",o.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=ue(e.borderColor,t),e.color=ue(e.color,t),e.shadowColor=ue(e.shadowColor,t)}return e}updateLabelModule(e){(this.options.label===void 0||this.options.label===null)&&(this.options.label=""),r.updateGroupOptions(this.options,je(ge({},e),{color:e&&e.color||this._localColor||void 0}),this.grouplist);let t=this.grouplist.get(this.options.group,!1),s=[e,this.options,t,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,s),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 Xi(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"custom":this.shape=new Ui(this.options,this.body,this.labelModule,this.options.ctxRenderer);break;case"database":this.shape=new Gi(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 Ki(this.options,this.body,this.labelModule);break;case"ellipse":this.shape=new Jt(this.options,this.body,this.labelModule);break;case"icon":this.shape=new $i(this.options,this.body,this.labelModule);break;case"image":this.shape=new Ta(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"square":this.shape=new Zi(this.options,this.body,this.labelModule);break;case"hexagon":this.shape=new Qi(this.options,this.body,this.labelModule);break;case"star":this.shape=new Ji(this.options,this.body,this.labelModule);break;case"text":this.shape=new es(this.options,this.body,this.labelModule);break;case"triangle":this.shape=new Ca(this.options,this.body,this.labelModule);break;case"triangleDown":this.shape=new ts(this.options,this.body,this.labelModule);break;default:this.shape=new Jt(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,s){if(this.options.value!==void 0){let o=this.options.scaling.customScalingFunction(e,t,s,this.options.value),n=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let a=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+o*a}this.options.size=this.options.scaling.min+o*n}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()&&Vi(this.labelModule.getSize(),e)&&t.push({nodeId:this.id,labelId:0}),Vi(this.shape.boundingBox,e)&&t.push({nodeId:this.id}),t}isOverlappingWith(e){return this.shape.lefte.left&&this.shape.tope.top}isBoundingBoxOverlappingWith(e){return this.shape.boundingBox.lefte.left&&this.shape.boundingBox.tope.top}static checkMass(e,t){if(e.mass!==void 0&&e.mass<=0){let s="";t!==void 0&&(s=" in node id: "+t),console.error("%cNegative or zero mass disallowed"+s+", setting mass to 1.",Mi),e.mass=1}}},is=class{constructor(e,t,s,o){if(this.body=e,this.images=t,this.groups=s,this.layoutEngine=o,this.body.functions.createNode=this.create.bind(this),this.nodesListeners={add:(n,a)=>{this.add(a.items)},update:(n,a)=>{this.update(a.items,a.data,a.oldData)},remove:(n,a)=>{this.remove(a.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(n,a,d,h){if(a===n)return .5;{let l=1/(a-n);return Math.max(0,(h-n)*l)}}},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=Me(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",()=>{F(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(ne.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 s=this.body.data.nodes;if(Bi("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(s&&F(this.nodesListeners,function(o,n){s.off(n,o)}),this.body.nodes={},this.body.data.nodes){let o=this;F(this.nodesListeners,function(a,d){o.body.data.nodes.on(d,a)});let n=this.body.data.nodes.getIds();this.add(n,!0)}t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let s,o=[];for(let n=0;n{let o=this.body.data.nodes.get(s);o!==void 0&&(e===!0&&t.setOptions({x:null,y:null}),t.setOptions({fixed:!1}),t.setOptions(o))})}getPositions(e){let t={};if(e!==void 0){if(Array.isArray(e)===!0){for(let s=0;s{this.body.emitter.emit("startSimulation")},0)):console.error("Node id supplied to moveNode does not exist. Provided: ",e)}},X=class{static transform(e,t){Array.isArray(e)||(e=[e]);let s=t.point.x,o=t.point.y,n=t.angle,a=t.length;for(let d=0;d0?h>0?a=p:d=p:h>0?d=p:a=p,++_}while(a<=d&&_1?c=1:c<0&&(c=0);let u=e+c*d,f=t+c*h,p=u-n,g=f-a;return Math.sqrt(p*p+g*g)}getArrowData(e,t,s,o,n,a){let d,h,l,c,u,f,p,g=a.width;t==="from"?(l=this.from,c=this.to,u=a.fromArrowScale<0,f=Math.abs(a.fromArrowScale),p=a.fromArrowType):t==="to"?(l=this.to,c=this.from,u=a.toArrowScale<0,f=Math.abs(a.toArrowScale),p=a.toArrowType):(l=this.to,c=this.from,u=a.middleArrowScale<0,f=Math.abs(a.middleArrowScale),p=a.middleArrowType);let _=15*f+3*g;if(l!=c){let O=Math.hypot(l.x-c.x,l.y-c.y),P=_/O;if(t!=="middle")if(this.options.smooth.enabled===!0){let D=this._findBorderPosition(l,e,{via:s}),N=this.getPoint(D.t+P*(t==="from"?1:-1),s);d=Math.atan2(D.y-N.y,D.x-N.x),h=D}else d=Math.atan2(l.y-c.y,l.x-c.x),h=this._findBorderPosition(l,e);else{let D=(u?-P:P)/2,N=this.getPoint(.5+D,s),W=this.getPoint(.5-D,s);d=Math.atan2(N.y-W.y,N.x-W.x),h=this.getPoint(.5,s)}}else{let[O,P,D]=this._getCircleData(e);if(t==="from"){let N=this.options.selfReference.angle,W=this.options.selfReference.angle+Math.PI,U=this._findBorderPositionCircle(this.from,e,{x:O,y:P,low:N,high:W,direction:-1});d=U.t*-2*Math.PI+1.5*Math.PI+.1*Math.PI,h=U}else if(t==="to"){let N=this.options.selfReference.angle,W=this.options.selfReference.angle+Math.PI,U=this._findBorderPositionCircle(this.from,e,{x:O,y:P,low:N,high:W,direction:1});d=U.t*-2*Math.PI+1.5*Math.PI-1.1*Math.PI,h=U}else{let N=this.options.selfReference.angle/(2*Math.PI);h=this._pointOnCircle(O,P,D,N),d=N*-2*Math.PI+1.5*Math.PI+.1*Math.PI}}let m=h.x-_*.9*Math.cos(d),v=h.y-_*.9*Math.sin(d);return{point:h,core:{x:m,y:v},angle:d,length:_,type:p}}drawArrowHead(e,t,s,o,n){e.strokeStyle=this.getColor(e,t),e.fillStyle=e.strokeStyle,e.lineWidth=t.width,ei.draw(e,n)&&(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 s={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=s.strokeStyle,e.lineWidth=s.lineWidth,e.dashes=s.dashes,this.setStrokeDashed(e,t.dashes)}}setStrokeDashed(e,t){if(t!==!1)if(e.setLineDash!==void 0){let s=Array.isArray(t)?t:[5,5];e.setLineDash(s)}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.")}},It=class extends ti{constructor(e,t,s){super(e,t,s)}_findBorderPositionBezier(e,t,s=this._getViaCoordinates()){let a=!1,d=1,h=0,l=this.to,c,u,f=this.options.endPointOffset?this.options.endPointOffset.to:0;e.id===this.from.id&&(l=this.from,a=!0,f=this.options.endPointOffset?this.options.endPointOffset.from:0),this.options.arrowStrikethrough===!1&&(f=0);let p=0;do{u=(h+d)*.5,c=this.getPoint(u,s);let g=Math.atan2(l.y-c.y,l.x-c.x),_=l.distanceToBorder(t,g)+f,m=Math.sqrt(Math.pow(c.x-l.x,2)+Math.pow(c.y-l.y,2)),v=_-m;if(Math.abs(v)<.2)break;v<0?a===!1?h=u:d=u:a===!1?d=u:h=u,++p}while(h<=d&&p<10);return je(ge({},c),{t:u})}_getDistanceToBezierEdge(e,t,s,o,n,a,d){let h=1e9,l,c,u,f,p,g=e,_=t;for(c=1;c<10;c++)u=.1*c,f=Math.pow(1-u,2)*e+2*u*(1-u)*d.x+Math.pow(u,2)*s,p=Math.pow(1-u,2)*t+2*u*(1-u)*d.y+Math.pow(u,2)*o,c>0&&(l=this._getDistanceToLine(g,_,f,p,n,a),h=l{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,s){this._bezierCurve(e,t,s)}_getViaCoordinates(){return this.via}getViaNode(){return this.via}getPoint(e,t=this.via){if(this.from===this.to){let[s,o,n]=this._getCircleData(),a=2*Math.PI*(1-e);return{x:s+n*Math.sin(a),y:o+n-n*(1-Math.cos(a))}}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,s,o,n,a){return this._getDistanceToBezierEdge(e,t,s,o,n,a,this.via)}},si=class extends It{constructor(e,t,s){super(e,t,s)}_line(e,t,s){this._bezierCurve(e,t,s)}getViaNode(){return this._getViaCoordinates()}_getViaCoordinates(){let e=this.options.smooth.roundness,t=this.options.smooth.type,s=Math.abs(this.from.x-this.to.x),o=Math.abs(this.from.y-this.to.y);if(t==="discrete"||t==="diagonalCross"){let n,a;s<=o?n=a=e*o:n=a=e*s,this.from.x>this.to.x&&(n=-n),this.from.y>=this.to.y&&(a=-a);let d=this.from.x+n,h=this.from.y+a;return t==="discrete"&&(s<=o?d=sthis.to.x&&(n=-n),this.from.y>=this.to.y&&(a=-a);let d=this.from.x+n,h=this.from.y+a;return s<=o?this.from.x<=this.to.x?d=this.to.xd?this.to.x:d:this.from.y>=this.to.y?h=this.to.y>h?this.to.y:h:h=this.to.y0){let v=this._getDistanceToLine(c,u,_,m,n,a);l=vMath.abs(t)||this.options.smooth.forceDirection===!0||this.options.smooth.forceDirection==="horizontal")&&this.options.smooth.forceDirection!=="vertical"?(o=this.from.y,a=this.to.y,s=this.from.x-d*e,n=this.to.x+d*e):(o=this.from.y-d*t,a=this.to.y+d*t,s=this.from.x,n=this.to.x),[{x:s,y:o},{x:n,y:a}]}getViaNode(){return this._getViaCoordinates()}_findBorderPosition(e,t){return this._findBorderPositionBezier(e,t)}_getDistanceToEdge(e,t,s,o,n,a,[d,h]=this._getViaCoordinates()){return this._getDistanceToBezierEdge2(e,t,s,o,n,a,d,h)}getPoint(e,[t,s]=this._getViaCoordinates()){let o=e,n=[Math.pow(1-o,3),3*o*Math.pow(1-o,2),3*Math.pow(o,2)*(1-o),Math.pow(o,3)],a=n[0]*this.fromPoint.x+n[1]*t.x+n[2]*s.x+n[3]*this.toPoint.x,d=n[0]*this.fromPoint.y+n[1]*t.y+n[2]*s.y+n[3]*this.toPoint.y;return{x:a,y:d}}},ni=class extends ti{constructor(e,t,s){super(e,t,s)}_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 s=this.to,o=this.from;e.id===this.from.id&&(s=this.from,o=this.to);let n=Math.atan2(s.y-o.y,s.x-o.x),a=s.x-o.x,d=s.y-o.y,h=Math.sqrt(a*a+d*d),l=e.distanceToBorder(t,n),c=(h-l)/h;return{x:(1-c)*o.x+c*s.x,y:(1-c)*o.y+c*s.y,t:0}}_getDistanceToEdge(e,t,s,o,n,a){return this._getDistanceToLine(e,t,s,o,n,a)}},Le=class r{constructor(e,t,s,o,n){if(t===void 0)throw new Error("No body provided");this.options=Me(o),this.globalOptions=o,this.defaultOptions=n,this.body=t,this.imagelist=s,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 Qt(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;r.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 s=[e,this.options,this.defaultOptions];return this.chooser=js("edge",s),this.updateLabelModule(e),t=this.updateEdgeType()||t,this._setInteractionWidths(),this.connect(),t}static parseOptions(e,t,s=!1,o={},n=!1){if($e(["endPointOffset","arrowStrikethrough","id","from","hidden","hoverWidth","labelHighlightBold","length","line","opacity","physics","scaling","selectionWidth","selfReferenceSize","selfReference","to","title","value","width","font","chosen","widthConstraint"],e,t,s),t.endPointOffset!==void 0&&t.endPointOffset.from!==void 0&&(Number.isFinite(t.endPointOffset.from)?e.endPointOffset.from=t.endPointOffset.from:(e.endPointOffset.from=o.endPointOffset.from!==void 0?o.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=o.endPointOffset.to!==void 0?o.endPointOffset.to:0,console.error("endPointOffset.to is not a valid number"))),$t(t.label)?e.label=t.label:$t(e.label)||(e.label=void 0),fe(e,t,"smooth",o),fe(e,t,"shadow",o),fe(e,t,"background",o),t.dashes!==void 0&&t.dashes!==null?e.dashes=t.dashes:s===!0&&t.dashes===null&&(e.dashes=Object.create(o.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),fe(e.scaling,t.scaling,"label",o.scaling)):s===!0&&t.scaling===null&&(e.scaling=Object.create(o.scaling)),t.arrows!==void 0&&t.arrows!==null)if(typeof t.arrows=="string"){let d=t.arrows.toLowerCase();e.arrows.to.enabled=d.indexOf("to")!=-1,e.arrows.middle.enabled=d.indexOf("middle")!=-1,e.arrows.from.enabled=d.indexOf("from")!=-1}else if(typeof t.arrows=="object")fe(e.arrows,t.arrows,"to",o.arrows),fe(e.arrows,t.arrows,"middle",o.arrows),fe(e.arrows,t.arrows,"from",o.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 s===!0&&t.arrows===null&&(e.arrows=Object.create(o.arrows));if(t.color!==void 0&&t.color!==null){let d=Ie(t.color)?{color:t.color,highlight:t.color,hover:t.color,inherit:!1,opacity:1}:t.color,h=e.color;if(n)V(h,o.color,!1,s);else for(let l in h)Object.prototype.hasOwnProperty.call(h,l)&&delete h[l];if(Ie(h))h.color=h,h.highlight=h,h.hover=h,h.inherit=!1,d.opacity===void 0&&(h.opacity=1);else{let l=!1;d.color!==void 0&&(h.color=d.color,l=!0),d.highlight!==void 0&&(h.highlight=d.highlight,l=!0),d.hover!==void 0&&(h.hover=d.hover,l=!0),d.inherit!==void 0&&(h.inherit=d.inherit),d.opacity!==void 0&&(h.opacity=Math.min(1,Math.max(0,d.opacity))),l===!0?h.inherit=!1:h.inherit===void 0&&(h.inherit="from")}}else s===!0&&t.color===null&&(e.color=Me(o.color));s===!0&&t.font===null&&(e.font=Me(o.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,s=this.options.arrows.middle===!0||this.options.arrows.middle.enabled===!0,o=this.options.color.inherit,n={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:s,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:o?void 0:this.options.color.color,inheritsColor:o,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 a=this.options.selectionWidth;typeof a=="function"?n.width=a(n.width):typeof a=="number"&&(n.width+=a),n.width=Math.max(n.width,.3/this.body.view.scale),n.color=this.options.color.highlight,n.shadow=this.options.shadow.enabled}else if(this.hover){let a=this.options.hoverWidth;typeof a=="function"?n.width=a(n.width):typeof a=="number"&&(n.width+=a),n.width=Math.max(n.width,.3/this.body.view.scale),n.color=this.options.color.hover,n.shadow=this.options.shadow.enabled}}else typeof this.chooser=="function"&&(this.chooser(n,this.options.id,this.selected,this.hover),n.color!==void 0&&(n.inheritsColor=!1),n.shadow===!1&&(n.shadowColor!==this.options.shadow.color||n.shadowSize!==this.options.shadow.size||n.shadowX!==this.options.shadow.x||n.shadowY!==this.options.shadow.y)&&(n.shadow=!0));else n.shadow=this.options.shadow.enabled,n.width=Math.max(n.width,.3/this.body.view.scale);return n}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,s=!0;return this.edgeType!==void 0&&((this.edgeType instanceof ii&&e.enabled===!0&&e.type==="dynamic"||this.edgeType instanceof oi&&e.enabled===!0&&e.type==="cubicBezier"||this.edgeType instanceof si&&e.enabled===!0&&e.type!=="dynamic"&&e.type!=="cubicBezier"||this.edgeType instanceof ni&&e.type.enabled===!1)&&(s=!1),s===!0&&(t=this.cleanup())),s===!0?e.enabled===!0?e.type==="dynamic"?(t=!0,this.edgeType=new ii(this.options,this.body,this.labelModule)):e.type==="cubicBezier"?this.edgeType=new oi(this.options,this.body,this.labelModule):this.edgeType=new si(this.options,this.body,this.labelModule):this.edgeType=new ni(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,s){if(this.options.value!==void 0){let o=this.options.scaling.customScalingFunction(e,t,s,this.options.value),n=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let a=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+o*a}this.options.width=this.options.scaling.min+o*n}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 s=this.edgeType.getViaNode();this.edgeType.drawLine(e,t,this.selected,this.hover,s),this.drawLabel(e,s)}drawArrows(e){let t=this.getFormattingValues();if(t.hidden)return;let s=this.edgeType.getViaNode(),o={};this.edgeType.fromPoint=this.edgeType.from,this.edgeType.toPoint=this.edgeType.to,t.fromArrow&&(o.from=this.edgeType.getArrowData(e,"from",s,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.fromPoint=o.from.core),t.fromArrowSrc&&(o.from.image=this.imagelist.load(t.fromArrowSrc)),t.fromArrowImageWidth&&(o.from.imageWidth=t.fromArrowImageWidth),t.fromArrowImageHeight&&(o.from.imageHeight=t.fromArrowImageHeight)),t.toArrow&&(o.to=this.edgeType.getArrowData(e,"to",s,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.toPoint=o.to.core),t.toArrowSrc&&(o.to.image=this.imagelist.load(t.toArrowSrc)),t.toArrowImageWidth&&(o.to.imageWidth=t.toArrowImageWidth),t.toArrowImageHeight&&(o.to.imageHeight=t.toArrowImageHeight)),t.middleArrow&&(o.middle=this.edgeType.getArrowData(e,"middle",s,this.selected,this.hover,t),t.middleArrowSrc&&(o.middle.image=this.imagelist.load(t.middleArrowSrc)),t.middleArrowImageWidth&&(o.middle.imageWidth=t.middleArrowImageWidth),t.middleArrowImageHeight&&(o.middle.imageHeight=t.middleArrowImageHeight)),t.fromArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,o.from),t.middleArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,o.middle),t.toArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,o.to)}drawLabel(e,t){if(this.options.label!==void 0){let s=this.from,o=this.to;this.labelModule.differentState(this.selected,this.hover)&&this.labelModule.getTextSize(e,this.selected,this.hover);let n;if(s.id!=o.id){this.labelModule.pointToSelf=!1,n=this.edgeType.getPoint(.5,t),e.save();let a=this._getRotation(e);a.angle!=0&&(e.translate(a.x,a.y),e.rotate(a.angle)),this.labelModule.draw(e,n.x,n.y,this.selected,this.hover),e.restore()}else{this.labelModule.pointToSelf=!0;let a=pn(e,this.options.selfReference.angle,this.options.selfReference.size,s);n=this._pointOnCircle(a.x,a.y,this.options.selfReference.size,this.options.selfReference.angle),this.labelModule.draw(e,n.x,n.y,this.selected,this.hover)}}}getItemsOnPoint(e){let t=[];if(this.labelModule.visible()){let o=this._getRotation();Vi(this.labelModule.getSize(),e,o)&&t.push({edgeId:this.id,labelId:0})}let s={left:e.x,top:e.y};return this.isOverlappingWith(s)&&t.push({edgeId:this.id}),t}isOverlappingWith(e){if(this.connected){let s=this.from.x,o=this.from.y,n=this.to.x,a=this.to.y,d=e.left,h=e.top;return this.edgeType.getDistanceToEdge(s,o,n,a,d,h)<10}else return!1}_getRotation(e){let t=this.edgeType.getViaNode(),s=this.edgeType.getPoint(.5,t);e!==void 0&&this.labelModule.calculateLabelSize(e,this.selected,this.hover,s.x,s.y);let o={x:s.x,y:this.labelModule.size.yLine,angle:0};if(!this.labelModule.visible()||this.options.font.align==="horizontal")return o;let n=this.from.y-this.to.y,a=this.from.x-this.to.x,d=Math.atan2(n,a);return(d<-1&&a<0||d>0&&a<0)&&(d+=Math.PI),o.angle=d,o}_pointOnCircle(e,t,s,o){return{x:e+s*Math.cos(o),y:t-s*Math.sin(o)}}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}},gs=class{constructor(e,t,s){this.body=e,this.images=t,this.groups=s,this.body.functions.createEdge=this.create.bind(this),this.edgesListeners={add:(o,n)=>{this.add(n.items)},update:(o,n)=>{this.update(n.items)},remove:(o,n)=>{this.remove(n.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(o,n,a,d){if(n===o)return .5;{let h=1/(n-o);return Math.max(0,(d-o)*h)}}},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},V(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("_forceDisableDynamicCurves",(e,t=!0)=>{e==="dynamic"&&(e="continuous");let s=!1;for(let o in this.body.edges)if(Object.prototype.hasOwnProperty.call(this.body.edges,o)){let n=this.body.edges[o],a=this.body.data.edges.get(o);if(a!=null){let d=a.smooth;d!==void 0&&d.enabled===!0&&d.type==="dynamic"&&(e===void 0?n.setOptions({smooth:!1}):n.setOptions({smooth:{type:e}}),s=!0)}}t===!0&&s===!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",()=>{F(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){Le.parseOptions(this.options,e,!0,this.defaultOptions,!0);let t=!1;if(e.smooth!==void 0)for(let s in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,s)&&(t=this.body.edges[s].updateEdgeType()||t);if(e.font!==void 0)for(let s in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,s)&&this.body.edges[s].updateLabelModule();(e.hidden!==void 0||e.physics!==void 0||t===!0)&&this.body.emitter.emit("_dataChanged")}}setData(e,t=!1){let s=this.body.data.edges;if(Bi("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(s&&F(this.edgesListeners,(o,n)=>{s.off(n,o)}),this.body.edges={},this.body.data.edges){F(this.edgesListeners,(n,a)=>{this.body.data.edges.on(a,n)});let o=this.body.data.edges.getIds();this.add(o,!0)}this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let s=this.body.edges,o=this.body.data.edges;for(let n=0;n{let n=s[o];n!==void 0&&n.remove()}),t&&this.body.emitter.emit("_dataChanged")}refresh(){F(this.body.edges,(e,t)=>{let s=this.body.data.edges.get(t);s!==void 0&&e.setOptions(s)})}create(e){return new Le(e,this.body,this.images,this.options,this.defaultOptions)}reconnectEdges(){let e,t=this.body.nodes,s=this.body.edges;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&(t[e].edges=[]);for(e in s)if(Object.prototype.hasOwnProperty.call(s,e)){let o=s[e];o.from=null,o.to=null,o.connect()}}getConnectedNodes(e){let t=[];if(this.body.edges[e]!==void 0){let s=this.body.edges[e];s.fromId!==void 0&&t.push(s.fromId),s.toId!==void 0&&t.push(s.toId)}return t}_updateState(){this._addMissingEdges(),this._removeInvalidEdges()}_removeInvalidEdges(){let e=[];F(this.body.edges,(t,s)=>{let o=this.body.nodes[t.toId],n=this.body.nodes[t.fromId];o!==void 0&&o.isCluster===!0||n!==void 0&&n.isCluster===!0||(o===void 0||n===void 0)&&e.push(s)}),this.remove(e,!1)}_addMissingEdges(){let e=this.body.data.edges;if(e==null)return;let t=this.body.edges,s=[];e.forEach((o,n)=>{t[n]===void 0&&s.push(n)}),this.add(s,!0)}},ri=class{constructor(e,t,s){this.body=e,this.physicsBody=t,this.barnesHutTree,this.setOptions(s),this._rng=xt("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,s=this.physicsBody.physicsNodeIndices,o=s.length,n=this._formBarnesHutTree(t,s);this.barnesHutTree=n;for(let a=0;a0&&this._getForceContributions(n.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 s=e.centerOfMass.x-t.x,o=e.centerOfMass.y-t.y,n=Math.sqrt(s*s+o*o);n*e.calcSize>this.thetaInversed?this._calculateForces(n,s,o,t,e):e.childrenCount===4?this._getForceContributions(e,t):e.children.data.id!=t.id&&this._calculateForces(n,s,o,t,e)}}_calculateForces(e,t,s,o,n){e===0&&(e=.1,t=e),this.overlapAvoidanceFactor<1&&o.shape.radius&&(e=Math.max(.1+this.overlapAvoidanceFactor*o.shape.radius,e-o.shape.radius));let a=this.options.gravitationalConstant*n.mass*o.options.mass/Math.pow(e,3),d=t*a,h=s*a;this.physicsBody.forces[o.id].x+=d,this.physicsBody.forces[o.id].y+=h}_formBarnesHutTree(e,t){let s,o=t.length,n=e[t[0]].x,a=e[t[0]].y,d=e[t[0]].x,h=e[t[0]].y;for(let m=1;m0&&(Cd&&(d=C),Oh&&(h=O))}let l=Math.abs(d-n)-Math.abs(h-a);l>0?(a-=.5*l,h+=.5*l):(n+=.5*l,d-=.5*l);let u=Math.max(1e-5,Math.abs(d-n)),f=.5*u,p=.5*(n+d),g=.5*(a+h),_={root:{centerOfMass:{x:0,y:0},mass:0,range:{minX:p-f,maxX:p+f,minY:g-f,maxY:g+f},size:u,calcSize:1/u,children:{data:null},maxWidth:0,level:0,childrenCount:4}};this._splitBranch(_.root);for(let m=0;m0&&this._placeInTree(_.root,s);return _}_updateBranchMass(e,t){let s=e.centerOfMass,o=e.mass+t.options.mass,n=1/o;s.x=s.x*e.mass+t.x*t.options.mass,s.x*=n,s.y=s.y*e.mass+t.y*t.options.mass,s.y*=n,e.mass=o;let a=Math.max(Math.max(t.height,t.radius),t.width);e.maxWidth=e.maxWidtht.x?o.maxY>t.y?n="NW":n="SW":o.maxY>t.y?n="NE":n="SE",this._placeInRegion(e,t,n)}_placeInRegion(e,t,s){let o=e.children[s];switch(o.childrenCount){case 0:o.children.data=t,o.childrenCount=1,this._updateBranchMass(o,t);break;case 1:o.children.data.x===t.x&&o.children.data.y===t.y?(t.x+=this._rng(),t.y+=this._rng()):(this._splitBranch(o),this._placeInTree(o,t));break;case 4:this._placeInTree(o,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 s,o,n,a,d=.5*e.size;switch(t){case"NW":s=e.range.minX,o=e.range.minX+d,n=e.range.minY,a=e.range.minY+d;break;case"NE":s=e.range.minX+d,o=e.range.maxX,n=e.range.minY,a=e.range.minY+d;break;case"SW":s=e.range.minX,o=e.range.minX+d,n=e.range.minY+d,a=e.range.maxY;break;case"SE":s=e.range.minX+d,o=e.range.maxX,n=e.range.minY+d,a=e.range.maxY;break}e.children[t]={centerOfMass:{x:0,y:0},mass:0,range:{minX:s,maxX:o,minY:n,maxY:a},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,s){s===void 0&&(s="#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=s,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()}},ms=class{constructor(e,t,s){this._rng=xt("REPULSION SOLVER"),this.body=e,this.physicsBody=t,this.setOptions(s)}setOptions(e){this.options=e}solve(){let e,t,s,o,n,a,d,h,l=this.body.nodes,c=this.physicsBody.physicsNodeIndices,u=this.physicsBody.forces,f=this.options.nodeDistance,p=-2/3/f,g=4/3;for(let _=0;_0){let a=n.edges.length+1,d=this.options.centralGravity*a*n.options.mass;o[n.id].x=t*d,o[n.id].y=s*d}}},_s=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,Tt(["stabilization"],this.options,e),fe(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 vs(this.body,this.physicsBody,e),this.edgesSolver=new Ot(this.body,this.physicsBody,e),this.gravitySolver=new ws(this.body,this.physicsBody,e)):this.options.solver==="repulsion"?(e=this.options.repulsion,this.nodesSolver=new ms(this.body,this.physicsBody,e),this.edgesSolver=new Ot(this.body,this.physicsBody,e),this.gravitySolver=new rt(this.body,this.physicsBody,e)):this.options.solver==="hierarchicalRepulsion"?(e=this.options.hierarchicalRepulsion,this.nodesSolver=new ys(this.body,this.physicsBody,e),this.edgesSolver=new bs(this.body,this.physicsBody,e),this.gravitySolver=new rt(this.body,this.physicsBody,e)):(e=this.options.barnesHut,this.nodesSolver=new ri(this.body,this.physicsBody,e),this.edgesSolver=new Ot(this.body,this.physicsBody,e),this.gravitySolver=new rt(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(){this._evaluateStepQuality()===!0?this.timestep=1.2*this.timestep:this.timestep/1.2a))return!1;return!0}moveNodes(){let e=this.physicsBody.physicsNodeIndices,t=0,s=0,o=5;for(let n=0;na&&(e=e>0?a:-a),e}_performStep(e){let t=this.body.nodes[e],s=this.physicsBody.forces[e];this.options.wind&&(s.x+=this.options.wind.x,s.y+=this.options.wind.y);let o=this.physicsBody.velocities[e];return this.previousStates[e]={x:t.x,y:t.y,vx:o.x,vy:o.y},t.options.fixed.x===!1?(o.x=this.calculateComponentVelocity(o.x,s.x,t.options.mass),t.x+=o.x*this.timestep):(s.x=0,o.x=0),t.options.fixed.y===!1?(o.y=this.calculateComponentVelocity(o.y,s.y,t.options.mass),t.y+=o.y*this.timestep):(s.y=0,o.y=0),Math.sqrt(Math.pow(o.x,2)+Math.pow(o.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 s=e[t].options.fixed;this.freezeCache[t]={x:s.x,y:s.y},s.x=!0,s.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.body.emitter.emit("stabilizationProgress",{iterations:this.stabilizationIterations,total:this.targetIterations})};this._startStabilizing()&&t();let s=0;for(;e()&&s0)for(let h=0;hd.shape.boundingBox.left&&(n=d.shape.boundingBox.left),ad.shape.boundingBox.top&&(s=d.shape.boundingBox.top),o0)for(let h=0;hd.x&&(n=d.x),ad.y&&(s=d.y),o{delete this.containedEdges[s.id]}),F(t.containedNodes,(s,o)=>{this.containedNodes[o]=s}),t.containedNodes={},F(t.containedEdges,(s,o)=>{this.containedEdges[o]=s}),t.containedEdges={},F(t.edges,s=>{F(this.edges,o=>{let n=o.clusteringEdgeReplacingIds.indexOf(s.id);n!==-1&&(F(s.clusteringEdgeReplacingIds,a=>{o.clusteringEdgeReplacingIds.push(a),this.body.edges[a].edgeReplacedById=o.id}),o.clusteringEdgeReplacingIds.splice(n,1))})}),t.edges=[]}},xs=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 s=[];for(let o=0;o=e&&s.push(n.id)}for(let o=0;o{n.options&&e.joinCondition(n.options)===!0&&(s[a]=n,F(n.edges,d=>{this.clusteredEdges[d.id]===void 0&&(o[d.id]=d)}))}),this._cluster(s,o,e,t)}clusterByEdgeCount(e,t,s=!0){t=this._checkOptions(t);let o=[],n={},a,d,h;for(let l=0;l0&&Object.keys(u).length>0&&_===!0){let v=function(){for(let C=0;C-1&&(a[p.id]=p)}}this._cluster(n,a,t,s)}_createClusterEdges(e,t,s,o){let n,a,d,h,l,c,u=Object.keys(e),f=[];for(let _=0;_o?d.x:o,n=d.ya?d.y:a;return{x:.5*(s+o),y:.5*(n+a)}}openCluster(e,t,s=!0){if(e===void 0)throw new Error("No clusterNodeId supplied to openCluster.");let o=this.body.nodes[e];if(o===void 0)throw new Error("The clusterNodeId supplied to openCluster does not exist.");if(o.isCluster!==!0||o.containedNodes===void 0||o.containedEdges===void 0)throw new Error("The node:"+e+" is not a valid cluster.");let n=this.findNode(e),a=n.indexOf(e)-1;if(a>=0){let c=n[a];this.body.nodes[c]._openChildCluster(e),delete this.body.nodes[e],s===!0&&this.body.emitter.emit("_dataChanged");return}let d=o.containedNodes,h=o.containedEdges;if(t!==void 0&&t.releaseFunction!==void 0&&typeof t.releaseFunction=="function"){let c={},u={x:o.x,y:o.y};for(let p in d)if(Object.prototype.hasOwnProperty.call(d,p)){let g=this.body.nodes[p];c[p]={x:g.x,y:g.y}}let f=t.releaseFunction(u,c);for(let p in d)if(Object.prototype.hasOwnProperty.call(d,p)){let g=this.body.nodes[p];f[p]!==void 0&&(g.x=f[p].x===void 0?o.x:f[p].x,g.y=f[p].y===void 0?o.y:f[p].y)}}else F(d,function(c){c.options.fixed.x===!1&&(c.x=o.x),c.options.fixed.y===!1&&(c.y=o.y)});for(let c in d)if(Object.prototype.hasOwnProperty.call(d,c)){let u=this.body.nodes[c];u.vx=o.vx,u.vy=o.vy,u.setOptions({physics:!0}),delete this.clusteredNodes[c]}let l=[];for(let c=0;c0&&ao&&(o=l.edges.length),e+=l.edges.length,t+=Math.pow(l.edges.length,2),s+=1}e=e/s,t=t/s;let n=t-Math.pow(e,2),a=Math.sqrt(n),d=Math.floor(e+2*a);return d>o&&(d=o),d}_createClusteredEdge(e,t,s,o,n){let a=te.cloneOptions(s,"edge");V(a,o),a.from=e,a.to=t,a.id="clusterEdge:"+Ne(),n!==void 0&&V(a,n);let d=this.body.functions.createEdge(a);return d.clusteringEdgeReplacingIds=[s.id],d.connect(),this.body.edges[d.id]=d,d}_clusterEdges(e,t,s,o){if(t instanceof Le){let n=t,a={};a[n.id]=n,t=a}if(e instanceof ne){let n=e,a={};a[n.id]=n,e=a}if(s==null)throw new Error("_clusterEdges: parameter clusterNode required");o===void 0&&(o=s.clusterEdgeProperties),this._createClusterEdges(e,t,s,o);for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&this.body.edges[n]!==void 0){let a=this.body.edges[n];this._backupEdgeOptions(a),a.setOptions({physics:!1})}for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(this.clusteredNodes[n]={clusterId:s.id,node:this.body.nodes[n]},this.body.nodes[n].setOptions({physics:!1}))}_getClusterNodeForNode(e){if(e===void 0)return;let t=this.clusteredNodes[e];if(t===void 0)return;let s=t.clusterId;if(s!==void 0)return this.body.nodes[s]}_filter(e,t){let s=[];return F(e,o=>{t(o)&&s.push(o)}),s}_updateState(){let e,t=[],s={},o=h=>{F(this.body.nodes,l=>{l.isCluster===!0&&h(l)})};for(e in this.clusteredNodes){if(!Object.prototype.hasOwnProperty.call(this.clusteredNodes,e))continue;this.body.nodes[e]===void 0&&t.push(e)}o(function(h){for(let l=0;l{let l=this.body.edges[h];(l===void 0||!l.endPointsValid())&&(s[h]=h)}),o(function(h){F(h.containedEdges,(l,c)=>{!l.endPointsValid()&&!s[c]&&(s[c]=c)})}),F(this.body.edges,(h,l)=>{let c=!0,u=h.clusteringEdgeReplacingIds;if(u!==void 0){let f=0;F(u,p=>{let g=this.body.edges[p];g!==void 0&&g.endPointsValid()&&(f+=1)}),c=f>0}(!h.endPointsValid()||!c)&&(s[l]=l)}),o(h=>{F(s,l=>{delete h.containedEdges[l],F(h.edges,(c,u)=>{if(c.id===l){h.edges[u]=null;return}c.clusteringEdgeReplacingIds=this._filter(c.clusteringEdgeReplacingIds,function(f){return!s[f]})}),h.edges=this._filter(h.edges,function(c){return c!==null})})}),F(s,h=>{delete this.clusteredEdges[h]}),F(s,h=>{delete this.body.edges[h]});let n=Object.keys(this.body.edges);F(n,h=>{let l=this.body.edges[h],c=this._isClusteredNode(l.fromId)||this._isClusteredNode(l.toId);if(c!==this._isClusteredEdge(l.id))if(c){let u=this._getClusterNodeForNode(l.fromId);u!==void 0&&this._clusterEdges(this.body.nodes[l.fromId],l,u);let f=this._getClusterNodeForNode(l.toId);f!==void 0&&this._clusterEdges(this.body.nodes[l.toId],l,f)}else delete this._clusterEdges[h],this._restoreEdge(l)});let a=!1,d=!0;for(;d;){let h=[];o(function(l){let c=Object.keys(l.containedNodes).length,u=l.options.allowSingleNodeCluster===!0;(u&&c<1||!u&&c<2)&&h.push(l.id)});for(let l=0;l0,a=a||d}a&&this._updateState()}_isClusteredNode(e){return this.clusteredNodes[e]!==void 0}_isClusteredEdge(e){return this.clusteredEdges[e]!==void 0}};function Oa(){let r;window!==void 0&&(r=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),r===void 0?window.requestAnimationFrame=function(e){e()}:window.requestAnimationFrame=r}var Ts=class{constructor(e,t){Oa(),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&&$e(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag"],this.options,e)}_requestNextFrame(e,t){if(typeof window=="undefined")return;let s,o=window;return this.requiresTimeout===!0?s=o.setTimeout(e,t):o.requestAnimationFrame&&(s=o.requestAnimationFrame(e)),s}_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 s=this.canvas.getContext(),o=this.canvas.frame.canvas.clientWidth,n=this.canvas.frame.canvas.clientHeight;if(s.clearRect(0,0,o,n),this.canvas.frame.clientWidth===0)return;if(s.save(),s.translate(this.body.view.translation.x,this.body.view.translation.y),s.scale(this.body.view.scale,this.body.view.scale),s.beginPath(),this.body.emitter.emit("beforeDrawing",s),s.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(s),this.dragging===!1||this.dragging===!0&&this.options.hideNodesOnDrag===!1){let{drawExternalLabels:a}=this._drawNodes(s,e);t.drawExternalLabels=a}e===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&(this.zooming===!1||this.zooming===!0&&this.options.hideEdgesOnZoom===!1)&&this._drawArrows(s),t.drawExternalLabels!=null&&t.drawExternalLabels(),e===!1&&this._drawSelectionBox(s),s.beginPath(),this.body.emitter.emit("afterDrawing",s),s.closePath(),s.restore(),e===!0&&s.clearRect(0,0,o,n)}}_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,s;for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&(s=t[o],s.resize(e),s.updateBoundingBox(e,s.selected));e.restore()}_drawNodes(e,t=!1){let s=this.body.nodes,o=this.body.nodeIndices,n,a=[],d=[],h=20,l=this.canvas.DOMtoCanvas({x:-h,y:-h}),c=this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth+h,y:this.canvas.frame.canvas.clientHeight+h}),u={top:l.y,left:l.x,bottom:c.y,right:c.x},f=[];for(let m=0;m{for(let m of f)m()}}}_drawEdges(e){let t=this.body.edges,s=this.body.edgeIndices;for(let o=0;o{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&&$e(["width","height","autoResize"],this.options,e),this._cleanUp(),this.options.autoResize===!0){if(window.ResizeObserver){let s=new ResizeObserver(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")}),{frame:o}=this;s.observe(o),this._cleanupCallbacks.push(()=>{s.unobserve(o)})}else{let s=setInterval(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")},1e3);this._cleanupCallbacks.push(()=>{clearInterval(s)})}let t=this._onResize.bind(this);window.addEventListener("resize",t),this._cleanupCallbacks.push(()=>{window.removeEventListener("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,s=this.cameraState.scale;e!=1&&t!=1?s=this.cameraState.scale*.5*(e+t):e!=1?s=this.cameraState.scale*e:t!=1&&(s=this.cameraState.scale*t),this.body.view.scale=s;let o=this.DOMtoCanvas({x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight}),n={x:o.x-this.cameraState.position.x,y:o.y-this.cameraState.position.y};this.body.view.translation.x+=n.x*this.body.view.scale,this.body.view.translation.y+=n.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 Ze(this.frame.canvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:Ze.DIRECTION_ALL}),ai(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 Ze(this.frame),gn(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 s=!1,o=this.frame.canvas.width,n=this.frame.canvas.height,a=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(a),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},s=!0;else{let d=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),h=Math.round(this.frame.canvas.clientHeight*this.pixelRatio);(this.frame.canvas.width!==d||this.frame.canvas.height!==h)&&this._getCameraState(a),this.frame.canvas.width!==d&&(this.frame.canvas.width=d,s=!0),this.frame.canvas.height!==h&&(this.frame.canvas.height=h,s=!0)}return s===!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(o/this.pixelRatio),oldHeight:Math.round(n/this.pixelRatio)}),this._setCameraState()),this.initialized=!0,s}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 s=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return t/s}_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 Sa(r,e){let t=Object.assign({nodes:e,minZoomLevel:Number.MIN_VALUE,maxZoomLevel:1},r!=null?r:{});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 ks=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=Sa(e,this.body.nodeIndices);let s=this.canvas.frame.canvas.clientWidth,o=this.canvas.frame.canvas.clientHeight,n,a;if(s===0||o===0)a=1,n=te.getRange(this.body.nodes,e.nodes);else if(t===!0){let l=0;for(let f in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,f)&&this.body.nodes[f].predefinedPosition===!0&&(l+=1);if(l>.5*this.body.nodeIndices.length){this.fit(e,!1);return}n=te.getRange(this.body.nodes,e.nodes),a=12.662/(this.body.nodeIndices.length+7.4147)+.0964822;let u=Math.min(s/600,o/600);a*=u}else{this.body.emitter.emit("_resizeNodes"),n=te.getRange(this.body.nodes,e.nodes);let l=Math.abs(n.maxX-n.minX)*1.1,c=Math.abs(n.maxY-n.minY)*1.1,u=s/l,f=o/c;a=u<=f?u:f}a>e.maxZoomLevel?a=e.maxZoomLevel:a0))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}),s={x:t.x-e.position.x,y:t.y-e.position.y};this.targetTranslation={x:this.sourceTranslation.x+s.x*this.targetScale+e.offset.x,y:this.sourceTranslation.y+s.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}),s={x:t.x-e.x,y:t.y-e.y},o=this.body.view.translation,n={x:o.x+s.x*this.body.view.scale+this.lockedOnNodeOffset.x,y:o.y+s.y*this.body.view.scale+this.lockedOnNodeOffset.y};this.body.view.translation=n}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=Wo[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})}},Os=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._stopMovement()}),this.navigationHammers.push(s),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),s=this.body.view.translation,o=t/e,n=(1-o)*this.canvas.canvasViewCenter.x+s.x*o,a=(1-o)*this.canvas.canvasViewCenter.y+s.y*o;this.body.view.scale=t,this.body.view.translation={x:n,y:a},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),s=this.body.view.translation,o=t/e,n=(1-o)*this.canvas.canvasViewCenter.x+s.x*o,a=(1-o)*this.canvas.canvasViewCenter.y+s.y*o;this.body.view.scale=t,this.body.view.translation={x:n,y:a},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=Ut({container:window,preventDefault:!0}):this.keycharm=Ut({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")))}},Ss=class{constructor(e,t,s){this.body=e,this.canvas=t,this.selectionHandler=s,this.navigationHandler=new Os(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&&(Tt(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag","keyboard","multiselect","selectable","selectConnectedEdges"],this.options,e),fe(this.options,e,"keyboard"),e.tooltip&&(Object.assign(this.options.tooltip,e.tooltip),e.tooltip.color&&(this.options.tooltip.color=Vt(e.tooltip.color)))),this.navigationHandler.setOptions(this.options)}getPointer(e){return{x:e.x-zo(this.canvas.frame.canvas),y:e.y-Ro(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),s=this.selectionHandler.options.multiselect&&(e.changedPointers[0].ctrlKey||e.changedPointers[0].metaKey);this.checkSelectionChanges(t,s),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),s=this.selectionHandler.options.multiselect;this.checkSelectionChanges(t,s),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 s=function(o,n){let a=[];for(let d=0;d{let d=a.node;a.xFixed===!1&&(d.x=this.canvas._XconvertDOMtoCanvas(this.canvas._XconvertCanvasToDOM(a.x)+o)),a.yFixed===!1&&(d.y=this.canvas._YconvertDOMtoCanvas(this.canvas._YconvertCanvasToDOM(a.y)+n))}),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 o=t.x-this.drag.pointer.x,n=t.y-this.drag.pointer.y;this.body.view.translation={x:this.drag.translation.x+o,y:this.drag.translation.y+n},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,s={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(a=>{let d=this.body.nodes[a];return d.x>=s.minX&&d.x<=s.maxX&&d.y>=s.minY&&d.y<=s.maxY}).forEach(a=>this.selectionHandler.selectObject(this.body.nodes[a]));let n=this.getPointer(e.center);this.selectionHandler.commitAndEmit(n,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(s){s.node.options.fixed.x=s.xFixed,s.node.options.fixed.y=s.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 s=this.pinch.scale*e.scale;this.zoom(s,t)}zoom(e,t){if(this.options.zoomView===!0){let s=this.body.view.scale;e<1e-5&&(e=1e-5),e>10&&(e=10);let o;this.drag!==void 0&&this.drag.dragging===!0&&(o=this.canvas.DOMtoCanvas(this.drag.pointer));let n=this.body.view.translation,a=e/s,d=(1-a)*t.x+n.x*a,h=(1-a)*t.y+n.y*a;if(this.body.view.scale=e,this.body.view.translation={x:d,y:h},o!=null){let l=this.canvas.canvasToDOM(o);this.drag.pointer.x=l.x,this.drag.pointer.y=l.y}this.body.emitter.emit("_requestRedraw"),sthis._checkShowPopup(t),this.options.tooltipDelay))),this.options.hover===!0&&this.selectionHandler.hoverObject(e,t)}_checkShowPopup(e){let t=this.canvas._XconvertDOMtoCanvas(e.x),s=this.canvas._YconvertDOMtoCanvas(e.y),o={left:t,top:s,right:t,bottom:s},n=this.popupObj===void 0?void 0:this.popupObj.id,a=!1,d="node";if(this.popupObj===void 0){let h=this.body.nodeIndices,l=this.body.nodes,c,u=[];for(let f=0;f0&&(this.popupObj=l[u[u.length-1]],a=!0)}if(this.popupObj===void 0&&a===!1){let h=this.body.edgeIndices,l=this.body.edges,c,u=[];for(let f=0;f0&&(this.popupObj=l[u[u.length-1]],d="edge")}this.popupObj!==void 0?this.popupObj.id!==n&&(this.popup===void 0&&(this.popup=new Yo(this.canvas.frame)),this.popup.popupTargetType=d,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),s=!1;if(this.popup.popupTargetType==="node"){if(this.body.nodes[this.popup.popupTargetId]!==void 0&&(s=this.body.nodes[this.popup.popupTargetId].isOverlappingWith(t),s===!0)){let o=this.selectionHandler.getNodeAt(e);s=o===void 0?!1:o.id===this.popup.popupTargetId}}else this.selectionHandler.getNodeAt(e)===void 0&&this.body.edges[this.popup.popupTargetId]!==void 0&&(s=this.body.edges[this.popup.popupTargetId].isOverlappingWith(t));s===!1&&(this.popupObj=void 0,this.popup.hide(),this.body.emitter.emit("hidePopup"))}};function q(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)}function Is(r,e,t,s,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t}var Qe,be,Ae,ze,Kt;function tn(r,e){let t=new Set;for(let s of e)r.has(s)||t.add(s);return t}var di=class{constructor(){Qe.set(this,new Set),be.set(this,new Set)}get size(){return q(this,be,"f").size}add(...e){for(let t of e)q(this,be,"f").add(t)}delete(...e){for(let t of e)q(this,be,"f").delete(t)}clear(){q(this,be,"f").clear()}getSelection(){return[...q(this,be,"f")]}getChanges(){return{added:[...tn(q(this,Qe,"f"),q(this,be,"f"))],deleted:[...tn(q(this,be,"f"),q(this,Qe,"f"))],previous:[...new Set(q(this,Qe,"f"))],current:[...new Set(q(this,be,"f"))]}}commit(){let e=this.getChanges();Is(this,Qe,q(this,be,"f"),"f"),Is(this,be,new Set(q(this,Qe,"f")),"f");for(let t of e.added)t.select();for(let t of e.deleted)t.unselect();return e}};Qe=new WeakMap,be=new WeakMap;var Ps=class{constructor(e=()=>{}){Ae.set(this,new di),ze.set(this,new di),Kt.set(this,void 0),Is(this,Kt,e,"f")}get sizeNodes(){return q(this,Ae,"f").size}get sizeEdges(){return q(this,ze,"f").size}getNodes(){return q(this,Ae,"f").getSelection()}getEdges(){return q(this,ze,"f").getSelection()}addNodes(...e){q(this,Ae,"f").add(...e)}addEdges(...e){q(this,ze,"f").add(...e)}deleteNodes(e){q(this,Ae,"f").delete(e)}deleteEdges(e){q(this,ze,"f").delete(e)}clear(){q(this,Ae,"f").clear(),q(this,ze,"f").clear()}commit(...e){let t={nodes:q(this,Ae,"f").commit(),edges:q(this,ze,"f").commit()};return q(this,Kt,"f").call(this,t,...e),t}};Ae=new WeakMap,ze=new WeakMap,Kt=new WeakMap;var Ms=class{constructor(e,t){this.body=e,this.canvas=t,this._selectionAccumulator=new Ps,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&&$e(["multiselect","hoverConnectedEdges","selectable","selectConnectedEdges"],this.options,e)}selectOnPoint(e){let t=!1;if(this.options.selectable===!0){let s=this.getNodeAt(e)||this.getEdgeAt(e);this.unselectAll(),s!==void 0&&(t=this.selectObject(s)),this.body.emitter.emit("_requestRedraw")}return t}selectAdditionalOnPoint(e){let t=!1;if(this.options.selectable===!0){let s=this.getNodeAt(e)||this.getEdgeAt(e);s!==void 0&&(t=!0,s.isSelected()===!0?this.deselectObject(s):this.selectObject(s),this.body.emitter.emit("_requestRedraw"))}return t}_initBaseEvent(e,t){let s={};return s.pointer={DOM:{x:t.x,y:t.y},canvas:this.canvas.DOMtoCanvas(t)},s.event=e,s}generateClickEvent(e,t,s,o,n=!1){let a=this._initBaseEvent(t,s);if(n===!0)a.nodes=[],a.edges=[];else{let d=this.getSelection();a.nodes=d.nodes,a.edges=d.edges}o!==void 0&&(a.previousSelection=o),e=="click"&&(a.items=this.getClickedItems(s)),t.controlEdge!==void 0&&(a.controlEdge=t.controlEdge),this.body.emitter.emit(e,a)}selectObject(e,t=this.options.selectConnectedEdges){return e!==void 0?(e instanceof ne?(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=[],s=this.body.nodes;for(let o=0;o0)return t===!0?this.body.nodes[o[o.length-1]]:o[o.length-1]}_getEdgesOverlappingWith(e,t){let s=this.body.edges;for(let o=0;o0&&(this.generateClickEvent("deselectEdge",t,e,n),s=!0),o.nodes.deleted.length>0&&(this.generateClickEvent("deselectNode",t,e,n),s=!0),o.nodes.added.length>0&&(this.generateClickEvent("selectNode",t,e),s=!0),o.edges.added.length>0&&(this.generateClickEvent("selectEdge",t,e),s=!0),s===!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 s of e.nodes){let o=this.body.nodes[s];if(!o)throw new RangeError('Node with id "'+s+'" not found');this.selectObject(o,t.highlightEdges)}if(e.edges)for(let s of e.edges){let o=this.body.edges[s];if(!o)throw new RangeError('Edge with id "'+s+'" not found');this.selectObject(o)}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),s=[],o=this.body.nodeIndices,n=this.body.nodes;for(let h=o.length-1;h>=0;h--){let c=n[o[h]].getItemsOnPoint(t);s.push.apply(s,c)}let a=this.body.edgeIndices,d=this.body.edges;for(let h=a.length-1;h>=0;h--){let c=d[a[h]].getItemsOnPoint(t);s.push.apply(s,c)}return s}},hi=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,s=void 0){this.fake_use(e,t,s),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()}},Ds=class extends hi{constructor(e){super(),this.layout=e}curveType(){return"horizontal"}getPosition(e){return e.x}setPosition(e,t,s=void 0){s!==void 0&&this.layout.hierarchical.addToOrdering(e,s),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){e.sort(function(t,s){return t.x-s.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}},Ns=class extends hi{constructor(e){super(),this.layout=e}curveType(){return"vertical"}getPosition(e){return e.y}setPosition(e,t,s=void 0){s!==void 0&&this.layout.hierarchical.addToOrdering(e,s),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){e.sort(function(t,s){return t.y-s.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(r,e){let t=new Set;return r.forEach(s=>{s.edges.forEach(o=>{o.connected&&t.add(o)})}),t.forEach(s=>{let o=s.from.id,n=s.to.id;e[o]==null&&(e[o]=0),(e[n]==null||e[o]>=e[n])&&(e[n]=e[o]+1)}),e}function Pa(r){return mn(e=>e.edges.filter(t=>r.has(t.toId)).every(t=>t.to===e),(e,t)=>t>e,"from",r)}function Ma(r){return mn(e=>e.edges.filter(t=>r.has(t.toId)).every(t=>t.from===e),(e,t)=>th+1+l.edges.length,0),a=t+"Id",d=t==="to"?1:-1;for(let[h,l]of s){if(!s.has(h)||!r(l))continue;o[h]=0;let c=[l],u=0,f;for(;f=c.pop();){if(!s.has(h))continue;let p=o[f.id]+d;if(f.edges.filter(g=>g.connected&&g.to!==g.from&&g[t]!==f&&s.has(g.toId)&&s.has(g.fromId)).forEach(g=>{let _=g[a],m=o[_];(m==null||e(p,m))&&(o[_]=p,c.push(g[t]))}),u>n)return Ia(s,o);++u}}return o}var Fs=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={},s=o=>{if(t[o]!==void 0)return t[o];let n=this.levels[o];if(this.childrenReference[o]){let a=this.childrenReference[o];if(a.length>0)for(let d=0;d{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 s=this.options.hierarchical,o=s.enabled;if($e(["randomSeed","improvedLayout","clusterThreshold"],this.options,e),fe(this.options,e,"hierarchical"),e.randomSeed!==void 0&&this._resetRNG(e.randomSeed),s.enabled===!0)return o===!0&&this.body.emitter.emit("refresh",!0),s.direction==="RL"||s.direction==="DU"?s.levelSeparation>0&&(s.levelSeparation*=-1):s.levelSeparation<0&&(s.levelSeparation*=-1),this.setDirectionStrategy(),this.body.emitter.emit("_resetHierarchicalLayout"),this.adaptAllOptionsForHierarchicalLayout(t);if(o===!0)return this.body.emitter.emit("refresh"),V(t,this.optionsBackup)}return t}_resetRNG(e){this.initialRandomSeed=e,this._rng=xt(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 s=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:s};else{let o=e.edges.smooth;o.type!==void 0&&o.type!=="dynamic"&&(s=o.type),this.optionsBackup.edges={smooth:{enabled:o.enabled===void 0?!0:o.enabled,type:o.type===void 0?"dynamic":o.type,roundness:o.roundness===void 0?.5:o.roundness,forceDirection:o.forceDirection===void 0?!1:o.forceDirection}},e.edges.smooth={enabled:o.enabled===void 0?!0:o.enabled,type:s,roundness:o.roundness===void 0?.5:o.roundness,forceDirection:o.forceDirection===void 0?!1:o.forceDirection}}this.body.emitter.emit("_forceDisableDynamicCurves",s)}return e}positionInitially(e){if(this.options.hierarchical.enabled!==!0){this._resetRNG(this.initialRandomSeed);let t=e.length+50;for(let s=0;sn){let h=e.length;for(;e.length>n&&o<=10;){o+=1;let l=e.length;o%3===0?this.body.modules.clustering.clusterBridges(a):this.body.modules.clustering.clusterOutliers(a);let c=e.length;if(l==c&&o%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*h)})}o>10&&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 d=70;for(let h=0;h0){let e,t,s=!1,o=!1;this.lastNodeOnLevel={},this.hierarchical=new Fs;for(t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&(e=this.body.nodes[t],e.options.level!==void 0?(s=!0,this.hierarchical.levels[t]=e.options.level):o=!0);if(o===!0&&s===!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(o===!0){let a=this.options.hierarchical.sortMethod;a==="hubsize"?this._determineLevelsByHubsize():a==="directed"?this._determineLevelsDirected():a==="custom"&&this._determineLevelsCustomCallback()}for(let a in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,a)&&this.hierarchical.ensureLevel(a);let n=this._getDistribution();this._generateMap(),this._placeNodesByHierarchy(n),this._condenseHierarchy(),this._shiftToCenter()}}}_condenseHierarchy(){let e=!1,t={},s=()=>{let m=n(),v=0;for(let C=0;C{let C=this.hierarchical.trees;for(let O in C)Object.prototype.hasOwnProperty.call(C,O)&&C[O]===m&&this.direction.shift(O,v)},n=()=>{let m=[];for(let v=0;v{if(!v[m.id]&&(v[m.id]=!0,this.hierarchical.childrenReference[m.id])){let C=this.hierarchical.childrenReference[m.id];if(C.length>0)for(let O=0;O{let C=1e9,O=1e9,P=1e9,D=-1e9;for(let N in m)if(Object.prototype.hasOwnProperty.call(m,N)){let W=this.body.nodes[N],U=this.hierarchical.levels[W.id],w=this.direction.getPosition(W),[k,L]=this._getSpaceAroundNode(W,m);C=Math.min(k,C),O=Math.min(L,O),U<=v&&(P=Math.min(w,P),D=Math.max(w,D))}return[P,D,C,O]},h=(m,v)=>{let C=this.hierarchical.getMaxLevel(m.id),O=this.hierarchical.getMaxLevel(v.id);return Math.min(C,O)},l=(m,v,C)=>{let O=this.hierarchical;for(let P=0;P1)for(let W=0;W{let O=this.direction.getPosition(m),P=this.direction.getPosition(v),D=Math.abs(P-O),N=this.options.hierarchical.nodeSpacing;if(D>N){let W={},U={};a(m,W),a(v,U);let w=h(m,v),k=d(W,w),L=d(U,w),K=k[1],H=L[0],R=L[2];if(Math.abs(K-H)>N){let j=K-H+N;j<-R+N&&(j=-R+N),j<0&&(this._shiftBlock(v.id,j),e=!0,C===!0&&this._centerParent(v))}}},u=(m,v)=>{let C=v.id,O=v.edges,P=this.hierarchical.levels[v.id],D=this.options.hierarchical.levelSeparation*this.options.hierarchical.levelSeparation,N={},W=[];for(let R=0;R{let j=0;for(let Z=0;Z{let j=0;for(let Z=0;Z{let j=this.direction.getPosition(v),Z={};for(let $=0;${let z=this.direction.getPosition(v);if(t[v.id]===void 0){let we={};a(v,we),t[v.id]=we}let j=d(t[v.id]),Z=j[2],$=j[3],ie=R-z,pe=0;ie>0?pe=Math.min(ie,$-this.options.hierarchical.nodeSpacing):ie<0&&(pe=-Math.min(-ie,Z-this.options.hierarchical.nodeSpacing)),pe!=0&&(this._shiftBlock(v.id,pe),e=!0)},K=R=>{let z=this.direction.getPosition(v),[j,Z]=this._getSpaceAroundNode(v),$=R-z,ie=z;$>0?ie=Math.min(z+(Z-this.options.hierarchical.nodeSpacing),R):$<0&&(ie=Math.max(z-(j-this.options.hierarchical.nodeSpacing),R)),ie!==z&&(this.direction.setPosition(v,ie),e=!0)},H=k(m,W);L(H),H=k(m,O),K(H)},f=m=>{let v=this.hierarchical.getLevels();v=v.reverse();for(let C=0;C{let v=this.hierarchical.getLevels();v=v.reverse();for(let C=0;C{for(let m in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,m)&&this._centerParent(this.body.nodes[m])},_=()=>{let m=this.hierarchical.getLevels();m=m.reverse();for(let v=0;v0&&Math.abs(u)0&&(h=this.direction.getPosition(s[n-1])+d),this.direction.setPosition(a,h,t),this._validatePositionAndContinue(a,t,h),o++}}}}_placeBranchNodes(e,t){let s=this.hierarchical.childrenReference[e];if(s===void 0)return;let o=[];for(let a=0;at&&this.positionedNodes[d.id]===void 0){let l=this.options.hierarchical.nodeSpacing,c;a===0?c=this.direction.getPosition(this.body.nodes[e]):c=this.direction.getPosition(o[a-1])+l,this.direction.setPosition(d,c,h),this._validatePositionAndContinue(d,h,c)}else return}let n=this._getCenterPosition(o);this.direction.setPosition(this.body.nodes[e],n,t)}_validatePositionAndContinue(e,t,s){if(this.hierarchical.isTree){if(this.lastNodeOnLevel[t]!==void 0){let o=this.direction.getPosition(this.body.nodes[this.lastNodeOnLevel[t]]);if(s-o{this.body.edgeIndices.indexOf(s.id)!==-1&&t.push(s)}),t}_getHubSizes(){let e={},t=this.body.nodeIndices;F(t,o=>{let n=this.body.nodes[o],a=this._getActiveEdges(n).length;e[a]=!0});let s=[];return F(e,o=>{s.push(Number(o))}),s.sort(function(o,n){return n-o}),s}_determineLevelsByHubsize(){let e=(s,o)=>{this.hierarchical.levelDownstream(s,o)},t=this._getHubSizes();for(let s=0;s{let a=this.body.nodes[n];o===this._getActiveEdges(a).length&&this._crawlNetwork(e,n)})}}_determineLevelsCustomCallback(){let t=function(o,n,a){},s=(o,n,a)=>{let d=this.hierarchical.levels[o.id];d===void 0&&(d=this.hierarchical.levels[o.id]=1e5);let h=t(te.cloneOptions(o,"node"),te.cloneOptions(n,"node"),te.cloneOptions(a,"edge"));this.hierarchical.levels[n.id]=d+h};this._crawlNetwork(s),this.hierarchical.setMinLevelToZero(this.body.nodes)}_determineLevelsDirected(){let e=this.body.nodeIndices.reduce((t,s)=>(t.set(s,this.body.nodes[s]),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,s)=>{this.hierarchical.levels[s.id]>this.hierarchical.levels[t.id]&&this.hierarchical.addRelation(t.id,s.id)};this._crawlNetwork(e),this.hierarchical.checkIfTree()}_crawlNetwork(e=function(){},t){let s={},o=(n,a)=>{if(s[n.id]===void 0){this.hierarchical.setTreeIndex(n,a),s[n.id]=!0;let d,h=this._getActiveEdges(n);for(let l=0;l{if(s[n])return;s[n]=!0,this.direction.shift(n,t);let a=this.hierarchical.childrenReference[n];if(a!==void 0)for(let d=0;d{let h=this.hierarchical.parentReference[d];if(h!==void 0)for(let l=0;l{let h=this.hierarchical.parentReference[d];if(h!==void 0)for(let l=0;l{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,s){t!==void 0&&(t.locale!==void 0?this.options.locale=t.locale:this.options.locale=s.locale,t.locales!==void 0?this.options.locales=t.locales:this.options.locales=s.locales),e!==void 0&&(typeof e=="boolean"?this.options.enabled=e:(this.options.enabled=!0,V(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(),s=e+t,o=this.options.locales[this.options.locale],n=!1;this.options.addNode!==!1&&(this._createAddNodeButton(o),n=!0),this.options.addEdge!==!1&&(n===!0?this._createSeperator(1):n=!0,this._createAddEdgeButton(o)),e===1&&typeof this.options.editNode=="function"?(n===!0?this._createSeperator(2):n=!0,this._createEditNodeButton(o)):t===1&&e===0&&this.options.editEdge!==!1&&(n===!0?this._createSeperator(3):n=!0,this._createEditEdgeButton(o)),s!==0&&(e>0&&this.options.deleteNode!==!1?(n===!0&&this._createSeperator(4),this._createDeleteButton(o)):e===0&&this.options.deleteEdge!==!1&&(n===!0&&this._createSeperator(4),this._createDeleteButton(o))),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=V({},e.options,!1);if(t.x=e.x,t.y=e.y,this.options.editNode.length===2)this.options.editNode(t,s=>{s!=null&&this.inMode==="editNode"&&this.body.data.nodes.getDataSet().update(s),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),s=this._getNewTargetNode(e.to.x,e.to.y);this.temporaryIds.nodes.push(t.id),this.temporaryIds.nodes.push(s.id),this.body.nodes[t.id]=t,this.body.nodeIndices.push(t.id),this.body.nodes[s.id]=s,this.body.nodeIndices.push(s.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",o=>{let n=e.edgeType.findBorderPositions(o);t.selected===!1&&(t.x=n.from.x,t.y=n.from.y),s.selected===!1&&(s.x=n.to.x,s.y=n.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(),s;if(e.length>0){for(let o=0;o0&&typeof this.options.deleteEdge=="function"&&(s=this.options.deleteEdge);if(typeof s=="function"){let o={nodes:e,edges:t};if(s.length===2)s(o,n=>{n!=null&&this.inMode==="delete"?(this.body.data.edges.getDataSet().remove(n.edges),this.body.data.nodes.getDataSet().remove(n.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 s=V({},this.options.controlNodeStyle);s.id="targetNode"+Ne(),s.hidden=!1,s.physics=!1,s.x=e,s.y=t;let o=this.body.functions.createNode(s);return o.shape.boundingBox={left:e,right:e,top:t,bottom:t},o}_createEditButton(){this._clean(),this.manipulationDOM={},Pe(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&&(Pe(this.editModeDiv),Pe(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(),Pe(this.manipulationDiv),Pe(this.editModeDiv),Pe(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 s=this._createButton("delete",t,e.del||this.options.locales.en.del);this.manipulationDiv.appendChild(s),this._bindElementEvents(s,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,s,o="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=o,this.manipulationDOM[e+"Label"].innerText=s,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{s.destroy()});let o=({keyCode:n,key:a})=>{(a==="Enter"||a===" "||n===13||n===32)&&t()};e.addEventListener("keyup",o,!1),this._domEventListenerCleanupQueue.push(()=>{e.removeEventListener("keyup",o,!1)})}_cleanupTemporaryNodesAndEdges(){for(let e=0;e=0;d--)if(n[d]!==this.selectedControlNode.id){a=this.body.nodes[n[d]];break}if(a!==void 0&&this.selectedControlNode!==void 0)if(a.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let d=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===d.id?this._performEditEdge(a.id,o.to.id):this._performEditEdge(o.from.id,a.id)}else o.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,s=this.selectionHandler.getNodeAt(t);if(s!==void 0)if(s.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let o=this._getNewTargetNode(s.x,s.y);this.body.nodes[o.id]=o,this.body.nodeIndices.push(o.id);let n=this.body.functions.createEdge({id:"connectionEdge"+Ne(),from:s.id,to:o.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[n.id]=n,this.body.edgeIndices.push(n.id),this.temporaryIds.nodes.push(o.id),this.temporaryIds.edges.push(n.id)}this.touchTime=new Date().valueOf()}}_dragControlNode(e){let t=this.body.functions.getPointer(e.center),s=this.selectionHandler._pointerToPositionObject(t),o;this.temporaryIds.edges[0]!==void 0&&(o=this.body.edges[this.temporaryIds.edges[0]].fromId);let n=this.selectionHandler._getAllNodesOverlappingWith(s),a;for(let d=n.length-1;d>=0;d--)if(this.temporaryIds.nodes.indexOf(n[d])===-1){a=this.body.nodes[n[d]];break}if(e.controlEdge={from:o,to:a?a.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragging",e,t),this.temporaryIds.nodes[0]!==void 0){let d=this.body.nodes[this.temporaryIds.nodes[0]];d.x=this.canvas._XconvertDOMtoCanvas(t.x),d.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),s=this.selectionHandler._pointerToPositionObject(t),o;this.temporaryIds.edges[0]!==void 0&&(o=this.body.edges[this.temporaryIds.edges[0]].fromId);let n=this.selectionHandler._getAllNodesOverlappingWith(s),a;for(let d=n.length-1;d>=0;d--)if(this.temporaryIds.nodes.indexOf(n[d])===-1){a=this.body.nodes[n[d]];break}this._cleanupTemporaryNodesAndEdges(),a!==void 0&&(a.isCluster===!0?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):this.body.nodes[o]!==void 0&&this.body.nodes[a.id]!==void 0&&this._performAddEdge(o,a.id)),e.controlEdge={from:o,to:a?a.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:Ne(),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,s=>{s!=null&&this.inMode==="addNode"&&this.body.data.nodes.getDataSet().add(s),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 s={from:e,to:t};if(typeof this.options.addEdge=="function")if(this.options.addEdge.length===2)this.options.addEdge(s,o=>{o!=null&&this.inMode==="addEdge"&&(this.body.data.edges.getDataSet().add(o),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(s),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}_performEditEdge(e,t){let s={id:this.edgeBeingEditedId,from:e,to:t,label:this.body.data.edges.get(this.edgeBeingEditedId).label},o=this.options.editEdge;if(typeof o=="object"&&(o=o.editWithoutDrag),typeof o=="function")if(o.length===2)o(s,n=>{n==null||this.inMode!=="editEdge"?(this.body.edges[s.id].updateEdgeType(),this.body.emitter.emit("_redraw"),this.showManipulatorToolbar()):(this.body.data.edges.getDataSet().update(n),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(s),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},T="string",E="boolean",b="number",Ct="array",I="object",yn="dom",Da="any",zi=["arrow","bar","box","circle","crow","curve","diamond","image","inv_curve","inv_triangle","triangle","vee"],Ri={borderWidth:{number:b},borderWidthSelected:{number:b,undefined:"undefined"},brokenImage:{string:T,undefined:"undefined"},chosen:{label:{boolean:E,function:"function"},node:{boolean:E,function:"function"},__type__:{object:I,boolean:E}},color:{border:{string:T},background:{string:T},highlight:{border:{string:T},background:{string:T},__type__:{object:I,string:T}},hover:{border:{string:T},background:{string:T},__type__:{object:I,string:T}},__type__:{object:I,string:T}},opacity:{number:b,undefined:"undefined"},fixed:{x:{boolean:E},y:{boolean:E},__type__:{object:I,boolean:E}},font:{align:{string:T},color:{string:T},size:{number:b},face:{string:T},background:{string:T},strokeWidth:{number:b},strokeColor:{string:T},vadjust:{number:b},multi:{boolean:E,string:T},bold:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},boldital:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},ital:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},mono:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},__type__:{object:I,string:T}},group:{string:T,number:b,undefined:"undefined"},heightConstraint:{minimum:{number:b},valign:{string:T},__type__:{object:I,boolean:E,number:b}},hidden:{boolean:E},icon:{face:{string:T},code:{string:T},size:{number:b},color:{string:T},weight:{string:T,number:b},__type__:{object:I}},id:{string:T,number:b},image:{selected:{string:T,undefined:"undefined"},unselected:{string:T,undefined:"undefined"},__type__:{object:I,string:T}},imagePadding:{top:{number:b},right:{number:b},bottom:{number:b},left:{number:b},__type__:{object:I,number:b}},label:{string:T,undefined:"undefined"},labelHighlightBold:{boolean:E},level:{number:b,undefined:"undefined"},margin:{top:{number:b},right:{number:b},bottom:{number:b},left:{number:b},__type__:{object:I,number:b}},mass:{number:b},physics:{boolean:E},scaling:{min:{number:b},max:{number:b},label:{enabled:{boolean:E},min:{number:b},max:{number:b},maxVisible:{number:b},drawThreshold:{number:b},__type__:{object:I,boolean:E}},customScalingFunction:{function:"function"},__type__:{object:I}},shadow:{enabled:{boolean:E},color:{string:T},size:{number:b},x:{number:b},y:{number:b},__type__:{object:I,boolean:E}},shape:{string:["custom","ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon","hexagon"]},ctxRenderer:{function:"function"},shapeProperties:{borderDashes:{boolean:E,array:Ct},borderRadius:{number:b},interpolation:{boolean:E},useImageSize:{boolean:E},useBorderWithImage:{boolean:E},coordinateOrigin:{string:["center","top-left"]},__type__:{object:I}},size:{number:b},title:{string:T,dom:yn,undefined:"undefined"},value:{number:b,undefined:"undefined"},widthConstraint:{minimum:{number:b},maximum:{number:b},__type__:{object:I,boolean:E,number:b}},x:{number:b},y:{number:b},__type__:{object:I}},Na={configure:{enabled:{boolean:E},filter:{boolean:E,string:T,array:Ct,function:"function"},container:{dom:yn},showButton:{boolean:E},__type__:{object:I,boolean:E,string:T,array:Ct,function:"function"}},edges:{arrows:{to:{enabled:{boolean:E},scaleFactor:{number:b},type:{string:zi},imageHeight:{number:b},imageWidth:{number:b},src:{string:T},__type__:{object:I,boolean:E}},middle:{enabled:{boolean:E},scaleFactor:{number:b},type:{string:zi},imageWidth:{number:b},imageHeight:{number:b},src:{string:T},__type__:{object:I,boolean:E}},from:{enabled:{boolean:E},scaleFactor:{number:b},type:{string:zi},imageWidth:{number:b},imageHeight:{number:b},src:{string:T},__type__:{object:I,boolean:E}},__type__:{string:["from","to","middle"],object:I}},endPointOffset:{from:{number:b},to:{number:b},__type__:{object:I,number:b}},arrowStrikethrough:{boolean:E},background:{enabled:{boolean:E},color:{string:T},size:{number:b},dashes:{boolean:E,array:Ct},__type__:{object:I,boolean:E}},chosen:{label:{boolean:E,function:"function"},edge:{boolean:E,function:"function"},__type__:{object:I,boolean:E}},color:{color:{string:T},highlight:{string:T},hover:{string:T},inherit:{string:["from","to","both"],boolean:E},opacity:{number:b},__type__:{object:I,string:T}},dashes:{boolean:E,array:Ct},font:{color:{string:T},size:{number:b},face:{string:T},background:{string:T},strokeWidth:{number:b},strokeColor:{string:T},align:{string:["horizontal","top","middle","bottom"]},vadjust:{number:b},multi:{boolean:E,string:T},bold:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},boldital:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},ital:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},mono:{color:{string:T},size:{number:b},face:{string:T},mod:{string:T},vadjust:{number:b},__type__:{object:I,string:T}},__type__:{object:I,string:T}},hidden:{boolean:E},hoverWidth:{function:"function",number:b},label:{string:T,undefined:"undefined"},labelHighlightBold:{boolean:E},length:{number:b,undefined:"undefined"},physics:{boolean:E},scaling:{min:{number:b},max:{number:b},label:{enabled:{boolean:E},min:{number:b},max:{number:b},maxVisible:{number:b},drawThreshold:{number:b},__type__:{object:I,boolean:E}},customScalingFunction:{function:"function"},__type__:{object:I}},selectionWidth:{function:"function",number:b},selfReferenceSize:{number:b},selfReference:{size:{number:b},angle:{number:b},renderBehindTheNode:{boolean:E},__type__:{object:I}},shadow:{enabled:{boolean:E},color:{string:T},size:{number:b},x:{number:b},y:{number:b},__type__:{object:I,boolean:E}},smooth:{enabled:{boolean:E},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:b},forceDirection:{string:["horizontal","vertical","none"],boolean:E},__type__:{object:I,boolean:E}},title:{string:T,undefined:"undefined"},width:{number:b},widthConstraint:{maximum:{number:b},__type__:{object:I,boolean:E,number:b}},value:{number:b,undefined:"undefined"},__type__:{object:I}},groups:{useDefaultGroups:{boolean:E},__any__:Ri,__type__:{object:I}},interaction:{dragNodes:{boolean:E},dragView:{boolean:E},hideEdgesOnDrag:{boolean:E},hideEdgesOnZoom:{boolean:E},hideNodesOnDrag:{boolean:E},hover:{boolean:E},keyboard:{enabled:{boolean:E},speed:{x:{number:b},y:{number:b},zoom:{number:b},__type__:{object:I}},bindToWindow:{boolean:E},autoFocus:{boolean:E},__type__:{object:I,boolean:E}},multiselect:{boolean:E},navigationButtons:{boolean:E},selectable:{boolean:E},selectConnectedEdges:{boolean:E},hoverConnectedEdges:{boolean:E},tooltipDelay:{number:b},zoomView:{boolean:E},zoomSpeed:{number:b},__type__:{object:I}},layout:{randomSeed:{undefined:"undefined",number:b,string:T},improvedLayout:{boolean:E},clusterThreshold:{number:b},hierarchical:{enabled:{boolean:E},levelSeparation:{number:b},nodeSpacing:{number:b},treeSpacing:{number:b},blockShifting:{boolean:E},edgeMinimization:{boolean:E},parentCentralization:{boolean:E},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},shakeTowards:{string:["leaves","roots"]},__type__:{object:I,boolean:E}},__type__:{object:I}},manipulation:{enabled:{boolean:E},initiallyActive:{boolean:E},addNode:{boolean:E,function:"function"},addEdge:{boolean:E,function:"function"},editNode:{function:"function"},editEdge:{editWithoutDrag:{function:"function"},__type__:{object:I,boolean:E,function:"function"}},deleteNode:{boolean:E,function:"function"},deleteEdge:{boolean:E,function:"function"},controlNodeStyle:Ri,__type__:{object:I,boolean:E}},nodes:Ri,physics:{enabled:{boolean:E},barnesHut:{theta:{number:b},gravitationalConstant:{number:b},centralGravity:{number:b},springLength:{number:b},springConstant:{number:b},damping:{number:b},avoidOverlap:{number:b},__type__:{object:I}},forceAtlas2Based:{theta:{number:b},gravitationalConstant:{number:b},centralGravity:{number:b},springLength:{number:b},springConstant:{number:b},damping:{number:b},avoidOverlap:{number:b},__type__:{object:I}},repulsion:{centralGravity:{number:b},springLength:{number:b},springConstant:{number:b},nodeDistance:{number:b},damping:{number:b},__type__:{object:I}},hierarchicalRepulsion:{centralGravity:{number:b},springLength:{number:b},springConstant:{number:b},nodeDistance:{number:b},damping:{number:b},avoidOverlap:{number:b},__type__:{object:I}},maxVelocity:{number:b},minVelocity:{number:b},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{boolean:E},iterations:{number:b},updateInterval:{number:b},onlyDynamicEdges:{boolean:E},fit:{boolean:E},__type__:{object:I,boolean:E}},timestep:{number:b},adaptiveTimestep:{boolean:E},wind:{x:{number:b},y:{number:b},__type__:{object:I}},__type__:{object:I,boolean:E}},autoResize:{boolean:E},clickToUse:{boolean:E},locale:{string:T},locales:{__any__:{any:Da},__type__:{object:I}},height:{string:T},width:{string:T},__type__:{object:I}},bn={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]}}},Fa=(r,e,t)=>!!(r.includes("physics")&&bn.physics.solver.includes(e)&&t.physics.solver!==e&&e!=="wind");var zs=class{constructor(){}getDistances(e,t,s){let o={},n=e.edges;for(let d=0;dn&&da&&_this.body.emitter.emit("_requestRedraw")),this.groups=new Wi,this.canvas=new Cs(this.body),this.selectionHandler=new Ms(this.body,this.canvas),this.interactionHandler=new Ss(this.body,this.canvas,this.selectionHandler),this.view=new ks(this.body,this.canvas),this.renderer=new Ts(this.body,this.canvas),this.physics=new _s(this.body),this.layoutEngine=new Bs(this.body),this.clustering=new xs(this.body),this.manipulation=new As(this.body,this.canvas,this.selectionHandler,this.interactionHandler),this.nodesHandler=new is(this.body,this.images,this.groups,this.layoutEngine),this.edgesHandler=new gs(this.body,this.images,this.groups),this.body.modules.kamadaKawai=new Rs(this.body,150,.05),this.body.modules.clustering=this.clustering,this.canvas._create(),this.setOptions(t),this.setData(e)}(0,sn.default)(S.prototype);S.prototype.setOptions=function(r){if(r===null&&(r=void 0),r!==void 0){if(Xo.validate(r,Na)===!0&&console.error("%cErrors have been found in the supplied options object.",Mi),$e(["locale","locales","clickToUse"],this.options,r),r.locale!==void 0&&(r.locale=va(r.locales||this.options.locales,r.locale)),r=this.layoutEngine.setOptions(r.layout,r),this.canvas.setOptions(r),this.groups.setOptions(r.groups),this.nodesHandler.setOptions(r.nodes),this.edgesHandler.setOptions(r.edges),this.physics.setOptions(r.physics),this.manipulation.setOptions(r.manipulation,r,this.options),this.interactionHandler.setOptions(r.interaction),this.renderer.setOptions(r.interaction),this.selectionHandler.setOptions(r.interaction),r.groups!==void 0&&this.body.emitter.emit("refreshNodes"),"configure"in r&&(this.configurator||(this.configurator=new qo(this,this.body.container,bn,this.canvas.pixelRatio,Fa)),this.configurator.setOptions(r.configure)),this.configurator&&this.configurator.options.enabled===!0){let s={nodes:{},edges:{},layout:{},interaction:{},manipulation:{},physics:{},global:{}};V(s.nodes,this.nodesHandler.options),V(s.edges,this.edgesHandler.options),V(s.layout,this.layoutEngine.options),V(s.interaction,this.selectionHandler.options),V(s.interaction,this.renderer.options),V(s.interaction,this.interactionHandler.options),V(s.manipulation,this.manipulation.options),V(s.physics,this.physics.options),V(s.global,this.canvas.options),V(s.global,this.options),this.configurator.setModuleOptions(s)}r.clickToUse!==void 0?r.clickToUse===!0?this.activator===void 0&&(this.activator=new Vo(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")}};S.prototype._updateVisibleIndices=function(){let r=this.body.nodes,e=this.body.edges;this.body.nodeIndices=[],this.body.edgeIndices=[];for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&!this.clustering._isClusteredNode(t)&&r[t].options.hidden===!1&&this.body.nodeIndices.push(r[t].id);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let s=e[t],o=r[s.fromId],n=r[s.toId],a=o!==void 0&&n!==void 0;!this.clustering._isClusteredEdge(t)&&s.options.hidden===!1&&a&&o.options.hidden===!1&&n.options.hidden===!1&&this.body.edgeIndices.push(s.id)}};S.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")})};S.prototype.setData=function(r){if(this.body.emitter.emit("resetPhysics"),this.body.emitter.emit("_resetData"),this.selectionHandler.unselectAll(),r&&r.dot&&(r.nodes||r.edges))throw new SyntaxError('Data must contain either parameter "dot" or parameter pair "nodes" and "edges", but not both.');if(this.setOptions(r&&r.options),r&&r.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(r.dot);this.setData(e);return}else if(r&&r.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(r.gephi);this.setData(e);return}else this.nodesHandler.setData(r&&r.nodes,!0),this.edgesHandler.setData(r&&r.edges,!0);this.body.emitter.emit("_dataChanged"),this.body.emitter.emit("_dataLoaded"),this.body.emitter.emit("initPhysics")};S.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 r in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,r)&&delete this.body.nodes[r];for(let r in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,r)&&delete this.body.edges[r];Pe(this.body.container)};S.prototype._updateValueRange=function(r){let e,t,s,o=0;for(e in r)if(Object.prototype.hasOwnProperty.call(r,e)){let n=r[e].getValue();n!==void 0&&(t=t===void 0?n:Math.min(n,t),s=s===void 0?n:Math.max(n,s),o+=n)}if(t!==void 0&&s!==void 0)for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&r[e].setValueRange(t,s,o)};S.prototype.isActive=function(){return!this.activator||this.activator.active};S.prototype.setSize=function(){return this.canvas.setSize.apply(this.canvas,arguments)};S.prototype.canvasToDOM=function(){return this.canvas.canvasToDOM.apply(this.canvas,arguments)};S.prototype.DOMtoCanvas=function(){return this.canvas.DOMtoCanvas.apply(this.canvas,arguments)};S.prototype.findNode=function(){return this.clustering.findNode.apply(this.clustering,arguments)};S.prototype.isCluster=function(){return this.clustering.isCluster.apply(this.clustering,arguments)};S.prototype.openCluster=function(){return this.clustering.openCluster.apply(this.clustering,arguments)};S.prototype.cluster=function(){return this.clustering.cluster.apply(this.clustering,arguments)};S.prototype.getNodesInCluster=function(){return this.clustering.getNodesInCluster.apply(this.clustering,arguments)};S.prototype.clusterByConnection=function(){return this.clustering.clusterByConnection.apply(this.clustering,arguments)};S.prototype.clusterByHubsize=function(){return this.clustering.clusterByHubsize.apply(this.clustering,arguments)};S.prototype.updateClusteredNode=function(){return this.clustering.updateClusteredNode.apply(this.clustering,arguments)};S.prototype.getClusteredEdges=function(){return this.clustering.getClusteredEdges.apply(this.clustering,arguments)};S.prototype.getBaseEdge=function(){return this.clustering.getBaseEdge.apply(this.clustering,arguments)};S.prototype.getBaseEdges=function(){return this.clustering.getBaseEdges.apply(this.clustering,arguments)};S.prototype.updateEdge=function(){return this.clustering.updateEdge.apply(this.clustering,arguments)};S.prototype.clusterOutliers=function(){return this.clustering.clusterOutliers.apply(this.clustering,arguments)};S.prototype.getSeed=function(){return this.layoutEngine.getSeed.apply(this.layoutEngine,arguments)};S.prototype.enableEditMode=function(){return this.manipulation.enableEditMode.apply(this.manipulation,arguments)};S.prototype.disableEditMode=function(){return this.manipulation.disableEditMode.apply(this.manipulation,arguments)};S.prototype.addNodeMode=function(){return this.manipulation.addNodeMode.apply(this.manipulation,arguments)};S.prototype.editNode=function(){return this.manipulation.editNode.apply(this.manipulation,arguments)};S.prototype.editNodeMode=function(){return console.warn("Deprecated: Please use editNode instead of editNodeMode."),this.manipulation.editNode.apply(this.manipulation,arguments)};S.prototype.addEdgeMode=function(){return this.manipulation.addEdgeMode.apply(this.manipulation,arguments)};S.prototype.editEdgeMode=function(){return this.manipulation.editEdgeMode.apply(this.manipulation,arguments)};S.prototype.deleteSelected=function(){return this.manipulation.deleteSelected.apply(this.manipulation,arguments)};S.prototype.getPositions=function(){return this.nodesHandler.getPositions.apply(this.nodesHandler,arguments)};S.prototype.getPosition=function(){return this.nodesHandler.getPosition.apply(this.nodesHandler,arguments)};S.prototype.storePositions=function(){return this.nodesHandler.storePositions.apply(this.nodesHandler,arguments)};S.prototype.moveNode=function(){return this.nodesHandler.moveNode.apply(this.nodesHandler,arguments)};S.prototype.getBoundingBox=function(){return this.nodesHandler.getBoundingBox.apply(this.nodesHandler,arguments)};S.prototype.getConnectedNodes=function(r){return this.body.nodes[r]!==void 0?this.nodesHandler.getConnectedNodes.apply(this.nodesHandler,arguments):this.edgesHandler.getConnectedNodes.apply(this.edgesHandler,arguments)};S.prototype.getConnectedEdges=function(){return this.nodesHandler.getConnectedEdges.apply(this.nodesHandler,arguments)};S.prototype.startSimulation=function(){return this.physics.startSimulation.apply(this.physics,arguments)};S.prototype.stopSimulation=function(){return this.physics.stopSimulation.apply(this.physics,arguments)};S.prototype.stabilize=function(){return this.physics.stabilize.apply(this.physics,arguments)};S.prototype.getSelection=function(){return this.selectionHandler.getSelection.apply(this.selectionHandler,arguments)};S.prototype.setSelection=function(){return this.selectionHandler.setSelection.apply(this.selectionHandler,arguments)};S.prototype.getSelectedNodes=function(){return this.selectionHandler.getSelectedNodeIds.apply(this.selectionHandler,arguments)};S.prototype.getSelectedEdges=function(){return this.selectionHandler.getSelectedEdgeIds.apply(this.selectionHandler,arguments)};S.prototype.getNodeAt=function(){let r=this.selectionHandler.getNodeAt.apply(this.selectionHandler,arguments);return r!==void 0&&r.id!==void 0?r.id:r};S.prototype.getEdgeAt=function(){let r=this.selectionHandler.getEdgeAt.apply(this.selectionHandler,arguments);return r!==void 0&&r.id!==void 0?r.id:r};S.prototype.selectNodes=function(){return this.selectionHandler.selectNodes.apply(this.selectionHandler,arguments)};S.prototype.selectEdges=function(){return this.selectionHandler.selectEdges.apply(this.selectionHandler,arguments)};S.prototype.unselectAll=function(){this.selectionHandler.unselectAll.apply(this.selectionHandler,arguments),this.selectionHandler.commitWithoutEmitting.apply(this.selectionHandler),this.redraw()};S.prototype.redraw=function(){return this.renderer.redraw.apply(this.renderer,arguments)};S.prototype.getScale=function(){return this.view.getScale.apply(this.view,arguments)};S.prototype.getViewPosition=function(){return this.view.getViewPosition.apply(this.view,arguments)};S.prototype.fit=function(){return this.view.fit.apply(this.view,arguments)};S.prototype.moveTo=function(){return this.view.moveTo.apply(this.view,arguments)};S.prototype.focus=function(){return this.view.focus.apply(this.view,arguments)};S.prototype.releaseNode=function(){return this.view.releaseNode.apply(this.view,arguments)};S.prototype.getOptionsFromConfigurator=function(){let r={};return this.configurator&&(r=this.configurator.getOptions.apply(this.configurator)),r};function vn(r){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","text"),s="helvetica",o=14;t.textContent=r,t.setAttribute("font-family",s),t.setAttribute("font-size",o+"px"),e.appendChild(t),document.body.appendChild(e);let n=t.getComputedTextLength();t.remove(),e.remove();let a=2,d=2,h=d/2,l=d/2,c=n+d+a*2,u=o+d+a*2,f=u+l+d/2,p=c+h+d/2,g=p/2,_=f/2;return"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(''+r+"")}var Ws={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"}},A=null,_n=document.querySelector("#visgraph"),wn=document.querySelector("#id_save_coords");(function(){if(!topologyData)return;function e(w){let k=document.createElement("div");return k.innerHTML=w,k}let t=new Te(topologyData.nodes.map(w=>je(ge({},w),{title:e(w.title)})));window.nodes=t;let s=new Te(topologyData.edges.map(w=>ge(je(ge({},w),{title:e(w.title)}),w.drawTerminationLabel&&{arrows:{from:{enabled:!0,type:"image",src:vn(w.cable_a_name)},to:{enabled:!0,type:"image",src:vn(w.cable_b_name)}}}))),o=topologyData.options.group_sites,n=topologyData.options.group_locations,a=topologyData.options.group_racks,d=topologyData.options.group_virtualchassis,h=parseInt(topologyData.options.grid_size[0]);var l=!1;A=new S(_n,{nodes:t,edges:s},Ws),A.fit();function c(w,k){return x=A.getPosition(w).x,y=A.getPosition(w).y,x>=0?x%k>k/2&&(x+=k):-x%k>k/2&&(x-=k),x=x-x%k,y>=0?y%k>k/2&&(y+=k):-y%k>k/2&&(y-=k),y=y-y%k,{x,y}}function u(w){let k=A.getScale()*window.devicePixelRatio,L=w.canvas.width/k,K=w.canvas.height/k,H=A.getViewPosition(),R=H.x-H.x%h,z=H.y-H.y%h,j=L/2-L/2%h+h,Z=K/2-K/2%h+h,$=R-h-j,ie=R+h+j,pe=z-h-Z,we=z+h+Z;w.beginPath();for(let le=$;le0&&l==!0&&A.getSelectedNodes().length>0)for(i=0;i{l=!0}),A.on("dragEnd",w=>{if(l=!1,h>0&&A.getSelectedNodes().length>0)for(i=0;iXs(null,[K],function*([k,L]){isNaN(parseInt(k))?nodeKey=k:nodeKey=parseInt(k);try{window.nodes.update({id:nodeKey,physics:!1,x:L.x,y:L.y})}catch(R){console.log(["Error while executing window.nodes.update()","nodeId: "+k,"nodeKey: "+nodeKey,"x: "+L.x,"y: "+L.y]),console.log(R)}let H=yield fetch("/"+basePath+"api/plugins/netbox_topology_views/save-coords/save_coords/",{method:"PATCH",headers:{"X-CSRFToken":window.CSRF_TOKEN,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({node_id:k,x:L.x,y:L.y,group:topologyData.group})})})))}),A.on("doubleClick",w=>{w.nodes.length>0?w.nodes.forEach(k=>{window.open(t.get(k).href,"_blank")}):w.edges.forEach(k=>{window.open(s.get(k).href,"_blank")})}),A.on("beforeDrawing",w=>{h>0&&u(w)}),A.on("afterDrawing",w=>{g=[],o!=null&&o=="on"&&m(w,v,C),n!=null&&n=="on"&&m(w,O,P),a!=null&&a=="on"&&m(w,D,N),d!=null&&d=="on"&&m(w,W,U),f(w)}),A.on("click",w=>{g.forEach(k=>{if(w.pointer.canvas.x>k.x1-k.border/2-3&&w.pointer.canvas.xk.y1-k.border/2-3&&w.pointer.canvas.yk.x2-k.border/2-3||w.pointer.canvas.yk.y2-k.border/2-3)){let L=[];k.category=="Site"&&v.forEach(K=>{K.forEach(H=>{H[1]==k.id&&L.push(H[0])})}),k.category=="Location"&&O.forEach(K=>{K.forEach(H=>{H[1]===k.id&&L.push(H[0])})}),k.category=="Rack"&&D.forEach(K=>{K.forEach(H=>{H[1]===k.id&&L.push(H[0])})}),k.category=="Virtual Chassis"&&W.forEach(K=>{K.forEach(H=>{H[1]===k.id&&L.push(H[0])})}),A.selectNodes(L)}})});function p(w,k){let L=[];for(let[H,R]of t._data)R[w]!=null&&L.push([R.id,R[w],R[k],R.label_num_lines]);let K=L.reduce((H,R)=>{let z=R[1];return H[z]=H[z]||[],H[z].push(R),H},{});return Object.values(K)}var g=[];function _(w){w.ctx.beginPath(),w.ctx.lineWidth=w.lineWidth,w.ctx.strokeStyle=w.color,w.ctx.rect(w.x,w.y,w.width,w.height),w.ctx.stroke(),w.ctx.font=w.font,w.ctx.fillStyle=w.color,w.ctx.fillText(w.text,w.x+w.textPaddingX,w.y+w.textPaddingY),g.push({category:w.category,id:w.id,x1:w.x,y1:w.y,x2:w.x+w.width,y2:w.y+w.height,border:w.lineWidth})}function m(w,k,L){for(let K of Object.entries(k)){let H=[],R=[],z=[],j=[];for(let dt of K[1])R.push(A.getPosition(dt[0]).x),z.push(A.getPosition(dt[0]).y),j.push(z[z.length-1]+dt[3]*16);let $=Math.min(...R),ie=Math.max(...R),pe=Math.min(...z),we=Math.max(...j),le=$-L.paddingX,En=pe-L.paddingY,xn=ie-$+2*L.paddingX,Tn=we-pe+2*L.paddingY;H.push({ctx:w,x:le,y:En,width:xn,height:Tn,lineWidth:L.lineWidth,color:L.color,text:K[1][0][2],textPaddingX:L.textPaddingX,textPaddingY:L.textPaddingY,font:L.font,id:K[1][0][1],category:L.category}),H.forEach(function(dt){_(dt)})}}let v=p("site_id","site"),C={lineWidth:"5",color:"red",paddingX:84,paddingY:84,textPaddingX:8,textPaddingY:-8,font:"14px helvetica",category:"Site"},O=p("location_id","location"),P={lineWidth:"5",color:"#337ab7",paddingX:77,paddingY:77,textPaddingX:22,textPaddingY:29,font:"14px helvetica",category:"Location"},D=p("rack_id","rack"),N={lineWidth:"5",color:"green",paddingX:70,paddingY:70,textPaddingX:15,textPaddingY:36,font:"14px helvetica",category:"Rack"},W=p("virtual_chassis_id","virtual_chassis"),U={lineWidth:"5",color:"orange",paddingX:63,paddingY:63,textPaddingX:8,textPaddingY:43,font:"14px helvetica",category:"Virtual Chassis"}})();var Ba="image/png",Aa=document.querySelector("#btnDownloadImage");Aa.addEventListener("click",r=>{za()});function za(){let r=_n.querySelector("canvas"),e=document.createElement("a"),t=r.toDataURL(Ba);e.href=t,e.download="topology",document.body.appendChild(e),e.click(),document.body.removeChild(e)}var Ra=document.querySelector("#btnDownloadXml");Ra.addEventListener("click",r=>{La()});function La(){let r=document.createElement("a"),e="";if(typeof is_htmx!="undefined"){var t=window.location.href;let n="/sites/",a="/locations/";if(t.includes(n)){var s=t.split(n)[1];s=s.split("/")[0],e="site_id="+s+"&show_cables=True&show_unconnected=True"}else if(t.includes(a)){var o=t.split(a)[1];o=o.split("/")[0],e="location_id="+o+"&show_cables=True&show_unconnected=True"}}else e=new URLSearchParams(window.location.search);fetch("/"+basePath+"api/plugins/netbox_topology_views/xml-export/?"+e).then(n=>n.text()).then(n=>{var a=new Blob([n],{type:"text/plain"});r.setAttribute("href",window.URL.createObjectURL(a)),r.setAttribute("download","topology.xml"),r.dataset.downloadurl=["text/plain",r.download,r.href].join(":"),r.click()})}var Ha=new MutationObserver(r=>r.forEach(e=>{if(!A||e.type!=="attributes"||e.attributeName!=="data-bs-theme"||!(e.target instanceof HTMLElement))return;let t=e.target.dataset.bsTheme;Ws.nodes.font.color=t==="dark"?"#fff":"#000",A.setOptions(Ws)}));Ha.observe(document.body,{attributes:!0,attributeFilter:["data-bs-theme"]});})(); /*! Bundled license information: @egjs/hammerjs/dist/hammer.esm.js: diff --git a/netbox_topology_views/static_dev/js/home.js b/netbox_topology_views/static_dev/js/home.js index c5850ab..ed84a67 100644 --- a/netbox_topology_views/static_dev/js/home.js +++ b/netbox_topology_views/static_dev/js/home.js @@ -1,6 +1,44 @@ import { DataSet } from 'vis-data/esnext' import { Network } from 'vis-network/esnext' +function generatePortSVG(text) { + // pre-calculate text width + const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + const textEl = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + + const fontFamily = 'helvetica'; + const fontSize = 14; + textEl.textContent = text; + textEl.setAttribute('font-family', fontFamily); + textEl.setAttribute('font-size', fontSize + 'px'); + svg.appendChild(textEl); + document.body.appendChild(svg); + + const textWidth = textEl.getComputedTextLength(); + textEl.remove(); + svg.remove(); + + const rectPadding = 2; + const rectBorderWidth = 2; + const rectX = rectBorderWidth / 2; + const rectY = rectBorderWidth / 2; + const rectWidth = textWidth + rectBorderWidth + rectPadding * 2; + const rectHeight = fontSize + rectBorderWidth + rectPadding * 2; + const svgHeight = rectHeight + rectY + rectBorderWidth / 2; + const svgWidth = rectWidth + rectX + rectBorderWidth / 2; + const textX = svgWidth / 2 ; + const textY = svgHeight / 2; + + // generate SVG + return 'data:image/svg+xml;charset=utf-8,' + + encodeURIComponent( + '' + + '' + + '' + text + '' + + '' + ) +} + const options = { interaction: { hover: true, @@ -62,7 +100,21 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords') const edges = new DataSet( topologyData.edges.map((node) => ({ ...node, - title: htmlTitle(node.title) + title: htmlTitle(node.title), + ...(node.drawTerminationLabel && { + arrows: { + from: { + enabled: true, + type: "image", + src: generatePortSVG(node.cable_a_name) + }, + to: { + enabled: true, + type: "image", + src: generatePortSVG(node.cable_b_name) + } + } + }) })) ) diff --git a/netbox_topology_views/static_dev/package-lock.json b/netbox_topology_views/static_dev/package-lock.json index a287b5a..0ab2825 100644 --- a/netbox_topology_views/static_dev/package-lock.json +++ b/netbox_topology_views/static_dev/package-lock.json @@ -1,12 +1,12 @@ { "name": "netbox_topology_views", - "version": "4.3.0", + "version": "4.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "netbox_topology_views", - "version": "4.3.0", + "version": "4.5.0", "dependencies": { "vis-data": "^7.1.9", "vis-network": "^9.1.9", diff --git a/netbox_topology_views/utils.py b/netbox_topology_views/utils.py index e0edccc..000fed3 100644 --- a/netbox_topology_views/utils.py +++ b/netbox_topology_views/utils.py @@ -196,6 +196,11 @@ def get_query_settings(request): if request.GET["straight_cables"] == "True": straight_cables = True + draw_termination_labels = False + if "draw_termination_labels" in request.GET: + if request.GET["draw_termination_labels"] == "True": + draw_termination_labels = True + grid_size = 0 if "grid_size" in request.GET: grid_size = request.GET.getlist('grid_size') @@ -204,7 +209,7 @@ def get_query_settings(request): if "node_label_items" in request.GET: node_label_items = request.GET.getlist('node_label_items') - return filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, grid_size, node_label_items + return filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, draw_termination_labels, grid_size, node_label_items class LinePattern(): wireless = [2, 10, 2, 10] diff --git a/netbox_topology_views/views.py b/netbox_topology_views/views.py index b4ffff8..18e0057 100644 --- a/netbox_topology_views/views.py +++ b/netbox_topology_views/views.py @@ -269,6 +269,7 @@ def create_edge( termination_a: Dict, termination_b: Dict, straight_cables: bool, + draw_termination_labels: bool, circuit: Optional[Dict] = None, cable: Optional[Cable] = None, wireless: Optional[Dict] = None, @@ -339,6 +340,12 @@ def create_edge( # if straight_cables == True: edge["smooth"] = False edge["smooth"] = not straight_cables + if draw_termination_labels is True: + edge["drawTerminationLabel"] = True + edge["cable_a_name"] = cable_a_name + edge["cable_b_name"] = cable_b_name + + return edge @@ -381,6 +388,7 @@ def get_topology_data( group_virtualchassis: bool, group_id, straight_cables: bool, + draw_termination_labels: bool, grid_size: list, node_label_items: list, ): @@ -479,6 +487,7 @@ def get_topology_data( termination_a=termination_a, termination_b=termination_b, straight_cables=straight_cables, + draw_termination_labels=draw_termination_labels, ) ) @@ -549,6 +558,7 @@ def get_topology_data( termination_b=termination_b, power=True, straight_cables=straight_cables, + draw_termination_labels=draw_termination_labels, ) ) @@ -587,7 +597,7 @@ def get_topology_data( edge_ids += 1 termination_a = { "termination_name": interface.name, "termination_device_name": interface.device.name, "device_id": interface.device.id } termination_b = { "termination_name": destination.name, "termination_device_name": destination.device.name, "device_id": destination.device.id } - edges.append(create_edge(edge_id=edge_ids, termination_a=termination_a, termination_b=termination_b, interface=interface, straight_cables=straight_cables)) + edges.append(create_edge(edge_id=edge_ids, termination_a=termination_a, termination_b=termination_b, interface=interface, straight_cables=straight_cables, draw_termination_labels=draw_termination_labels)) nodes_devices[interface.device.id] = interface.device nodes_devices[destination.device.id] = destination.device @@ -668,6 +678,7 @@ def get_topology_data( termination_a=termination_a, termination_b=termination_b, straight_cables=straight_cables, + draw_termination_labels=draw_termination_labels, ) ) @@ -708,6 +719,7 @@ def get_topology_data( termination_b=termination_b, wireless=wireless, straight_cables=straight_cables, + draw_termination_labels=draw_termination_labels, ) ) @@ -762,7 +774,7 @@ class TopologyHomeView(PermissionRequiredMixin, View): if request.GET: - filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, grid_size, node_label_items = get_query_settings(request) + filter_id, ignore_cable_type, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, group_virtualchassis, group, show_neighbors, straight_cables, draw_termination_labels, grid_size, node_label_items = get_query_settings(request) filter_required = True empty_result = False @@ -788,6 +800,7 @@ class TopologyHomeView(PermissionRequiredMixin, View): if group_virtualchassis == False and 'group_virtualchassis' in saved_filter_params: group_virtualchassis = saved_filter_params['group_virtualchassis'] if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors'] if straight_cables == False and 'straight_cables' in saved_filter_params: straight_cables = saved_filter_params['straight_cables'] + if draw_termination_labels == False and 'draw_termination_labels' in saved_filter_params: draw_termination_labels = saved_filter_params['draw_termination_labels'] if grid_size == 0 and 'grid_size' in saved_filter_params: grid_size = saved_filter_params['grid_size'] if node_label_items == () and 'node_label_items' in saved_filter_params: node_label_items = saved_filter_params['node_label_items'] except SavedFilter.DoesNotExist: # filter_id not found @@ -825,6 +838,7 @@ class TopologyHomeView(PermissionRequiredMixin, View): group_virtualchassis=group_virtualchassis, group_id=group_id, straight_cables=straight_cables, + draw_termination_labels=draw_termination_labels, grid_size=grid_size, node_label_items=node_label_items, ) @@ -858,6 +872,7 @@ class TopologyHomeView(PermissionRequiredMixin, View): if individualOptions.group_racks: q['group_racks'] = "True" if individualOptions.group_virtualchassis: q['group_virtualchassis'] = "True" if individualOptions.straight_cables: q['straight_cables'] = "True" + if individualOptions.draw_termination_labels: q['draw_termination_labels'] = "True" if individualOptions.grid_size: q['grid_size'] = individualOptions.grid_size node_label_items = IndividualOptions.objects.get(id=individualOptions.id).node_label_items.translate({ord(i): None for i in '[]\''}).split(', ') if node_label_items == ['']: node_label_items = [] @@ -1211,6 +1226,7 @@ class TopologyIndividualOptionsView(PermissionRequiredMixin, View): 'group_virtualchassis': queryset.group_virtualchassis, 'draw_default_layout': queryset.draw_default_layout, 'straight_cables': queryset.straight_cables, + 'draw_termination_labels': queryset.draw_termination_labels, 'grid_size': queryset.grid_size, 'node_label_items': tuple(queryset.node_label_items.translate({ord(i): None for i in '[]\''}).split(', ')), },