mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-08 08:05:03 +00:00
24 lines
322 KiB
JavaScript
24 lines
322 KiB
JavaScript
/**
|
|
* Copyright (c) 2016-2019, The Cytoscape Consortium.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
* this software and associated documentation files (the “Software”), to deal in
|
|
* the Software without restriction, including without limitation the rights to
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
* of the Software, and to permit persons to whom the Software is furnished to do
|
|
* so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.cytoscape=t()}(this,function(){"use strict";function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var w="undefined"==typeof window?null:window,k=w?w.navigator:null,n=(w&&w.document,E("")),a=E({}),o=E(function(){}),l="undefined"==typeof HTMLElement?"undefined":E(HTMLElement),u=function(e){return e&&e.instanceString&&X(e.instanceString)?e.instanceString():null},K=function(e){return null!=e&&E(e)==n},X=function(e){return null!=e&&E(e)===o},G=function(e){return Array.isArray?Array.isArray(e):null!=e&&e instanceof Array},B=function(e){return null!=e&&E(e)===a&&!G(e)&&e.constructor===Object},$t=function(e){return null!=e&&E(e)===E(1)&&!isNaN(e)},c=function(e){return"undefined"===l?void 0:null!=e&&e instanceof HTMLElement},Z=function(e){return v(e)||h(e)},v=function(e){return"collection"===u(e)&&e._private.single},h=function(e){return"collection"===u(e)&&!e._private.single},y=function(e){return"core"===u(e)},d=function(e){return"stylesheet"===u(e)},L=function(e){return null==e||!(""!==e&&!e.match(/^\s+$/))},p=function(e){return null!=(t=e)&&E(t)===a&&X(e.then);var t},m=function(a,o){o||(o=function(){if(1===arguments.length)return arguments[0];if(0===arguments.length)return"undefined";for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);return e.join("$")});var e=function e(){var t,n=arguments,r=o.apply(this,n),i=e.cache;return(t=i[r])||(t=i[r]=a.apply(this,n)),t};return e.cache={},e},j=m(function(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),C=m(function(e){return e.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),f=m(function(e,t){return e+t[0].toUpperCase()+t.substring(1)},function(e,t){return e+"$"+t}),e=function(e){return L(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},W="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",U=function(e,t){return e<t?-1:t<e?1:0},S=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n<t.length;n++){var r=t[n];if(null!=r)for(var i=Object.keys(r),a=0;a<i.length;a++){var o=i[a];e[o]=r[o]}}return e},H=function(e){return(G(e)?e:null)||g[e.toLowerCase()]||function(e){if((4===e.length||7===e.length)&&"#"===e[0]){var t,n,r;return r=4===e.length?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)):(t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),parseInt(e[5]+e[6],16)),[t,n,r]}}(e)||function(e){var t,n=new RegExp("^rgb[a]?\\(((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%]?)\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%]?)\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%]?)(?:\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))))?\\)$").exec(e);if(n){t=[];for(var r=[],i=1;i<=3;i++){var a=n[i];if("%"===a[a.length-1]&&(r[i]=!0),a=parseFloat(a),r[i]&&(a=a/100*255),a<0||255<a)return;t.push(Math.floor(a))}var o=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(o&&!s)return;var l=n[4];if(void 0!==l){if((l=parseFloat(l))<0||1<l)return;t.push(l)}}return t}(e)||function(e){var t,n,r,i,a,o,s,l;function u(e,t,n){return n<0&&(n+=1),1<n&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var c=new RegExp("^hsl[a]?\\(((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?)))\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])(?:\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))))?\\)$").exec(e);if(c){if((n=parseInt(c[1]))<0?n=(360- -1*n%360)%360:360<n&&(n%=360),n/=360,(r=parseFloat(c[2]))<0||100<r)return;if(r/=100,(i=parseFloat(c[3]))<0||100<i)return;if(i/=100,void 0!==(a=c[4])&&((a=parseFloat(a))<0||1<a))return;if(0===r)o=s=l=Math.round(255*i);else{var h=i<.5?i*(1+r):i+r-i*r,d=2*i-h;o=Math.round(255*u(d,h,n+1/3)),s=Math.round(255*u(d,h,n)),l=Math.round(255*u(d,h,n-1/3))}t=[o,s,l,a]}return t}(e)},g={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},D=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var a=n[i];if(B(a))throw Error("Tried to set map with object key");i<n.length-1?(null==t[a]&&(t[a]={}),t=t[a]):t[a]=e.value}},b=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var a=n[i];if(B(a))throw Error("Tried to get map with object key");if(null==(t=t[a]))return t}return t},x="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var T=NaN,P="[object Symbol]",M=/^\s+|\s+$/g,_=/^[-+]0x[0-9a-f]+$/i,N=/^0b[01]+$/i,I=/^0o[0-7]+$/i,A=parseInt,z="object"==typeof x&&x&&x.Object===Object&&x,O="object"==typeof self&&self&&self.Object===Object&&self,R=z||O||Function("return this")(),F=Object.prototype.toString,V=Math.max,q=Math.min,Y=function(){return R.Date.now()};function $(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Q(e){if("number"==typeof e)return e;if("symbol"==typeof(t=e)||(n=t)&&"object"==typeof n&&F.call(t)==P)return T;var t,n;if($(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=$(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(M,"");var i=N.test(e);return i||I.test(e)?A(e.slice(2),i?2:8):_.test(e)?T:+e}var ae=function(r,i,e){var a,o,s,l,u,c,h=0,d=!1,p=!1,t=!0;if("function"!=typeof r)throw new TypeError("Expected a function");function f(e){var t=a,n=o;return a=o=void 0,h=e,l=r.apply(n,t)}function g(e){var t=e-c;return void 0===c||i<=t||t<0||p&&s<=e-h}function v(){var e,t,n=Y();if(g(n))return y(n);u=setTimeout(v,(t=i-((e=n)-c),p?q(t,s-(e-h)):t))}function y(e){return u=void 0,t&&a?f(e):(a=o=void 0,l)}function n(){var e,t=Y(),n=g(t);if(a=arguments,o=this,c=t,n){if(void 0===u)return h=e=c,u=setTimeout(v,i),d?f(e):l;if(p)return u=setTimeout(v,i),f(c)}return void 0===u&&(u=setTimeout(v,i)),l}return i=Q(i)||0,$(e)&&(d=!!e.leading,s=(p="maxWait"in e)?V(Q(e.maxWait)||0,i):s,t="trailing"in e?!!e.trailing:t),n.cancel=function(){void 0!==u&&clearTimeout(u),a=c=o=u=void(h=0)},n.flush=function(){return void 0===u?l:y(Y())},n},J=w?w.performance:null,ee=J&&J.now?function(){return J.now()}:function(){return Date.now()},te=function(){if(w){if(w.requestAnimationFrame)return function(e){w.requestAnimationFrame(e)};if(w.mozRequestAnimationFrame)return function(e){w.mozRequestAnimationFrame(e)};if(w.webkitRequestAnimationFrame)return function(e){w.webkitRequestAnimationFrame(e)};if(w.msRequestAnimationFrame)return function(e){w.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout(function(){e(ee())},1e3/60)}}(),ne=function(e){return te(e)},re=ee,ie=function(e){for(var t,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:5381;!(t=e.next()).done;)n=33*n^t.value;return n>>>0},oe=function(e){return(33*(1<arguments.length&&void 0!==arguments[1]?arguments[1]:5381)^e)>>>0},se=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return ie({next:function(){return r<i?n.value=e[r++]:n.done=!0,n}},t)},le=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return ie({next:function(){return r<i?n.value=e.charCodeAt(r++):n.done=!0,n}},t)},ue=function(){return ce(arguments)},ce=function(e){for(var t,n=0;n<e.length;n++){var r=e[n];t=0===n?le(r):le(r,t)}return t},he=null!=console.warn,de=null!=console.trace,pe=Number.MAX_SAFE_INTEGER||9007199254740991,fe=function(){return!0},ge=function(){return!1},ve=function(){return 0},ye=function(){},me=function(e){throw new Error(e)},be=function(e){he?console.warn(e):(console.log(e),de&&console.trace())},xe=function(e){return null==e?e:G(e)?e.slice():B(e)?S({},e):e},we=function(e,t){for(t=e="";e++<36;t+=51*e&52?(15^e?8^Math.random()*(20^e?16:4):4).toString(16):"-");return t},Ee={},ke=function(){return Ee},Ce=function(a){var o=Object.keys(a);return function(e){for(var t={},n=0;n<o.length;n++){var r=o[n],i=null==e?void 0:e[r];t[r]=void 0===i?a[r]:i}return t}},Se=function(e,t,n){for(var r=e.length;0<=r&&(e[r]!==t||(e.splice(r,1),n));r--);},Qt=function(e){e.splice(0,e.length)},De=function(e,t,n){return n&&(t=f(n,t)),e[t]},Te=function(e,t,n,r){n&&(t=f(n,t)),e[t]=r},Pe="undefined"!=typeof Map?Map:function(){function e(){i(this,e),this._obj={}}return t(e,[{key:"set",value:function(e,t){return this._obj[e]=t,this}},{key:"delete",value:function(e){return this._obj[e]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(e){return void 0!==this._obj[e]}},{key:"get",value:function(e){return this._obj[e]}}]),e}(),Me=function(){function r(e){if(i(this,r),this._obj=Object.create(null),this.size=0,null!=e){var t;t=null!=e.instanceString&&e.instanceString()===this.instanceString()?e.toArray():e;for(var n=0;n<t.length;n++)this.add(t[n])}}return t(r,[{key:"instanceString",value:function(){return"set"}},{key:"add",value:function(e){var t=this._obj;1!==t[e]&&(t[e]=1,this.size++)}},{key:"delete",value:function(e){var t=this._obj;1===t[e]&&(t[e]=0,this.size--)}},{key:"clear",value:function(){this._obj=Object.create(null)}},{key:"has",value:function(e){return 1===this._obj[e]}},{key:"toArray",value:function(){var t=this;return Object.keys(this._obj).filter(function(e){return t.has(e)})}},{key:"forEach",value:function(e,t){return this.toArray().forEach(e,t)}}]),r}(),_e="undefined"!==("undefined"==typeof Set?"undefined":E(Set))?Set:Me,Be=function(e,t,n){if(n=!(void 0!==n&&!n),void 0!==e&&void 0!==t&&y(e)){var r=t.group;if(null==r&&(r=t.data&&null!=t.data.source&&null!=t.data.target?"edges":"nodes"),"nodes"===r||"edges"===r){this.length=1;var i=(this[0]=this)._private={cy:e,single:!0,data:t.data||{},position:t.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:r,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:void 0===t.selectable||!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:void 0===t.grabbable||!!t.grabbable,active:!1,classes:new _e,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0}};if(null==i.position.x&&(i.position.x=0),null==i.position.y&&(i.position.y=0),t.renderedPosition){var a=t.renderedPosition,o=e.pan(),s=e.zoom();i.position={x:(a.x-o.x)/s,y:(a.y-o.y)/s}}var l=[];G(t.classes)?l=t.classes:K(t.classes)&&(l=t.classes.split(/\s+/));for(var u=0,c=l.length;u<c;u++){var h=l[u];h&&""!==h&&i.classes.add(h)}var d=t.style||t.css;d&&(be("Setting a `style` bypass at element creation is deprecated"),e.style().applyBypass(this,d)),this.createEmitter(),(void 0===n||n)&&this.restore()}else me("An element must be of type `nodes` or `edges`; you specified `"+r+"`")}else me("An element must have a core reference and parameters set")},Ne=function(C){return C={bfs:C.bfs||!C.dfs,dfs:C.dfs||!C.bfs},function(e,p,f){var t;B(e)&&!Z(e)&&(e=(t=e).roots||t.root,p=t.visit,f=t.directed),f=2!==arguments.length||X(p)?f:p,p=X(p)?p:function(){};for(var g,n=this._private.cy,r=e=K(e)?this.filter(e):e,v=[],y=[],m={},b={},x={},w=0,i=this.byGroup(),E=i.nodes,k=i.edges,a=0;a<r.length;a++){var o=r[a],s=o.id();o.isNode()&&(v.unshift(o),C.bfs&&(x[s]=!0,y.push(o)),b[s]=0)}var l=function(){var t=C.bfs?v.shift():v.pop(),e=t.id();if(C.dfs){if(x[e])return"continue";x[e]=!0,y.push(t)}var n,r=b[e],i=m[e],a=null!=i?i.source():null,o=null!=i?i.target():null,s=null==i?void 0:t.same(a)?o[0]:a[0];if(!0===(n=p(t,i,s,w++,r)))return g=t,"break";if(!1===n)return"break";for(var l=t.connectedEdges().filter(function(e){return(!f||e.source().same(t))&&k.has(e)}),u=0;u<l.length;u++){var c=l[u],h=c.connectedNodes().filter(function(e){return!e.same(t)&&E.has(e)}),d=h.id();0===h.length||x[d]||(h=h[0],v.push(h),C.bfs&&(x[d]=!0,y.push(h)),m[d]=c,b[d]=b[e]+1)}};e:for(;0!==v.length;){switch(l()){case"continue":continue;case"break":break e}}for(var u=n.collection(),c=0;c<y.length;c++){var h=y[c],d=m[h.id()];null!=d&&u.merge(d),u.merge(h)}return{path:n.collection(u),found:n.collection(g)}}},Ie={breadthFirstSearch:Ne({bfs:!0}),depthFirstSearch:Ne({dfs:!0})};Ie.bfs=Ie.breadthFirstSearch,Ie.dfs=Ie.depthFirstSearch;var Ae,Le=(function(t,e){(function(){var e,d,l,p,f,n,u,r,g,v,i,a,o,c,h;l=Math.floor,v=Math.min,d=function(e,t){return e<t?-1:t<e?1:0},g=function(e,t,n,r,i){var a;if(null==n&&(n=0),null==i&&(i=d),n<0)throw new Error("lo must be non-negative");for(null==r&&(r=e.length);n<r;)i(t,e[a=l((n+r)/2)])<0?r=a:n=a+1;return[].splice.apply(e,[n,n-n].concat(t)),t},n=function(e,t,n){return null==n&&(n=d),e.push(t),c(e,0,e.length-1,n)},f=function(e,t){var n,r;return null==t&&(t=d),n=e.pop(),e.length?(r=e[0],e[0]=n,h(e,0,t)):r=n,r},r=function(e,t,n){var r;return null==n&&(n=d),r=e[0],e[0]=t,h(e,0,n),r},u=function(e,t,n){var r;return null==n&&(n=d),e.length&&n(e[0],t)<0&&(t=(r=[e[0],t])[0],e[0]=r[1],h(e,0,n)),t},p=function(n,e){var t,r,i,a,o,s;for(null==e&&(e=d),o=[],r=0,i=(a=function(){s=[];for(var e=0,t=l(n.length/2);0<=t?e<t:t<e;0<=t?e++:e--)s.push(e);return s}.apply(this).reverse()).length;r<i;r++)t=a[r],o.push(h(n,t,e));return o},o=function(e,t,n){var r;if(null==n&&(n=d),-1!==(r=e.indexOf(t)))return c(e,0,r,n),h(e,r,n)},i=function(e,t,n){var r,i,a,o,s;if(null==n&&(n=d),!(i=e.slice(0,t)).length)return i;for(p(i,n),a=0,o=(s=e.slice(t)).length;a<o;a++)r=s[a],u(i,r,n);return i.sort(n).reverse()},a=function(e,t,n){var r,i,a,o,s,l,u,c,h;if(null==n&&(n=d),10*t<=e.length){if(!(a=e.slice(0,t).sort(n)).length)return a;for(i=a[a.length-1],o=0,l=(u=e.slice(t)).length;o<l;o++)n(r=u[o],i)<0&&(g(a,r,0,null,n),a.pop(),i=a[a.length-1]);return a}for(p(e,n),h=[],s=0,c=v(t,e.length);0<=c?s<c:c<s;0<=c?++s:--s)h.push(f(e,n));return h},c=function(e,t,n,r){var i,a,o;for(null==r&&(r=d),i=e[n];t<n&&r(i,a=e[o=n-1>>1])<0;)e[n]=a,n=o;return e[n]=i},h=function(e,t,n){var r,i,a,o,s;for(null==n&&(n=d),i=e.length,a=e[s=t],r=2*t+1;r<i;)(o=r+1)<i&&!(n(e[r],e[o])<0)&&(r=o),e[t]=e[r],r=2*(t=r)+1;return e[t]=a,c(e,s,t,n)},e=function(){function t(e){this.cmp=null!=e?e:d,this.nodes=[]}return t.push=n,t.pop=f,t.replace=r,t.pushpop=u,t.heapify=p,t.updateItem=o,t.nlargest=i,t.nsmallest=a,t.prototype.push=function(e){return n(this.nodes,e,this.cmp)},t.prototype.pop=function(){return f(this.nodes,this.cmp)},t.prototype.peek=function(){return this.nodes[0]},t.prototype.contains=function(e){return-1!==this.nodes.indexOf(e)},t.prototype.replace=function(e){return r(this.nodes,e,this.cmp)},t.prototype.pushpop=function(e){return u(this.nodes,e,this.cmp)},t.prototype.heapify=function(){return p(this.nodes,this.cmp)},t.prototype.updateItem=function(e){return o(this.nodes,e,this.cmp)},t.prototype.clear=function(){return this.nodes=[]},t.prototype.empty=function(){return 0===this.nodes.length},t.prototype.size=function(){return this.nodes.length},t.prototype.clone=function(){var e;return(e=new t).nodes=this.nodes.slice(0),e},t.prototype.toArray=function(){return this.nodes.slice(0)},t.prototype.insert=t.prototype.push,t.prototype.top=t.prototype.peek,t.prototype.front=t.prototype.peek,t.prototype.has=t.prototype.contains,t.prototype.copy=t.prototype.clone,t}(),t.exports=e}).call(x)}(Ae={exports:{}},Ae.exports),Ae.exports),ze=Ce({root:null,weight:function(e){return 1},directed:!1}),Oe={dijkstra:function(e){if(!B(e)){var t=arguments;e={root:t[0],weight:t[1],directed:t[2]}}var n=ze(e),r=n.root,i=n.weight,l=n.directed,o=this,u=i,a=K(r)?this.filter(r)[0]:r[0],s={},c={},h={},d=this.byGroup(),p=d.nodes,f=d.edges;f.unmergeBy(function(e){return e.isLoop()});for(var g=function(e){return s[e.id()]},v=new Le(function(e,t){return g(e)-g(t)}),y=0;y<p.length;y++){var m=p[y];s[m.id()]=m.same(a)?0:1/0,v.push(m)}for(var b,x,w=function(e,t){for(var n,r=(l?e.edgesTo(t):e.edgesWith(t)).intersect(f),i=1/0,a=0;a<r.length;a++){var o=r[a],s=u(o);(s<i||!n)&&(i=s,n=o)}return{edge:n,dist:i}};0<v.size();){var E=v.pop(),k=g(E),C=E.id();if((h[C]=k)!==1/0)for(var S=E.neighborhood().intersect(p),D=0;D<S.length;D++){var T=S[D],P=T.id(),M=w(E,T),_=k+M.dist;_<g(T)&&(x=_,s[(b=T).id()]=x,v.updateItem(b),c[P]={node:E,edge:M.edge})}}return{distanceTo:function(e){var t=K(e)?p.filter(e)[0]:e[0];return h[t.id()]},pathTo:function(e){var t=K(e)?p.filter(e)[0]:e[0],n=[],r=t,i=r.id();if(0<t.length)for(n.unshift(t);c[i];){var a=c[i];n.unshift(a.edge),n.unshift(a.node),i=(r=a.node).id()}return o.spawn(n)}}}},Re={kruskal:function(n){n=n||function(e){return 1};for(var e=this.byGroup(),t=e.nodes,r=e.edges,i=t.length,a=new Array(i),o=t,s=function(e){for(var t=0;t<a.length;t++){if(a[t].has(e))return t}},l=0;l<i;l++)a[l]=this.spawn(t[l]);for(var u=r.sort(function(e,t){return n(e)-n(t)}),c=0;c<u.length;c++){var h=u[c],d=h.source()[0],p=h.target()[0],f=s(d),g=s(p),v=a[f],y=a[g];f!==g&&(o.merge(h),v.merge(y),a.splice(g,1))}return o}},Fe=Ce({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),Ve={aStar:function(e){var t=this.cy(),n=Fe(e),r=n.root,i=n.goal,a=n.heuristic,o=n.directed,s=n.weight;r=t.collection(r)[0],i=t.collection(i)[0];var l,u,c=r.id(),h=i.id(),d={},p={},f={},g=new Le(function(e,t){return p[e.id()]-p[t.id()]}),v=new _e,y={},m={},b=function(e,t){g.push(e),v.add(t)};b(r,c),d[c]=0,p[c]=a(r);for(var x,w=0;0<g.size();){if(l=g.pop(),u=l.id(),v.delete(u),w++,u===h){for(var E=[],k=i,C=h,S=m[C];E.unshift(k),null!=S&&E.unshift(S),null!=(k=y[C]);)S=m[C=k.id()];return{found:!0,distance:d[u],path:this.spawn(E),steps:w}}f[u]=!0;for(var D=l._private.edges,T=0;T<D.length;T++){var P=D[T];if(this.hasElementWithId(P.id())&&(!o||P.data("source")===u)){var M=P.source(),_=P.target(),B=M.id()!==u?M:_,N=B.id();if(this.hasElementWithId(N)&&!f[N]){var I=d[u]+s(P);x=N,v.has(x)?I<d[N]&&(d[N]=I,p[N]=I+a(B),y[N]=l):(d[N]=I,p[N]=I+a(B),b(B,N),y[N]=l,m[N]=P)}}}}return{found:!1,distance:void 0,path:void 0,steps:w}}},qe=Ce({weight:function(e){return 1},directed:!1}),Ye={floydWarshall:function(e){for(var l=this.cy(),t=qe(e),n=t.weight,r=t.directed,i=n,a=this.byGroup(),o=a.nodes,s=a.edges,u=o.length,c=u*u,h=function(e){return o.indexOf(e)},d=function(e){return o[e]},p=new Array(c),f=0;f<c;f++){var g=f%u,v=(f-g)/u;p[f]=v===g?0:1/0}for(var y=new Array(c),m=new Array(c),b=0;b<s.length;b++){var x=s[b],w=x.source()[0],E=x.target()[0];if(w!==E){var k=h(w),C=h(E),S=k*u+C,D=i(x);if(p[S]>D&&(p[S]=D,y[S]=C,m[S]=x),!r){var T=C*u+k;!r&&p[T]>D&&(p[T]=D,y[T]=k,m[T]=x)}}}for(var P=0;P<u;P++)for(var M=0;M<u;M++)for(var _=M*u+P,B=0;B<u;B++){var N=M*u+B,I=P*u+B;p[_]+p[I]<p[N]&&(p[N]=p[_]+p[I],y[N]=y[_])}var A=function(e){return h((K(t=e)?l.filter(t):t)[0]);var t};return{distance:function(e,t){var n=A(e),r=A(t);return p[n*u+r]},path:function(e,t){var n=A(e),r=A(t),i=d(n);if(n===r)return i.collection();if(null==y[n*u+r])return l.collection();var a,o=l.collection(),s=n;for(o.merge(i);n!==r;)n=y[(s=n)*u+r],a=m[s*u+n],o.merge(a),o.merge(d(n));return o}}}},Xe=Ce({weight:function(e){return 1},directed:!1,root:null}),je={bellmanFord:function(e){var s=this,t=Xe(e),n=t.weight,r=t.directed,l=t.root,i=n,u=this,a=this.cy(),o=this.byGroup(),c=o.edges,h=o.nodes,d=h.length,p=new Pe,f=!1;l=a.collection(l)[0],c.unmergeBy(function(e){return e.isLoop()});for(var g=c.length,v=function(e){var t=p.get(e.id());return t||(t={},p.set(e.id(),t)),t},y=function(e){return(K(e)?a.$(e):e)[0]},m=0;m<d;m++){var b=h[m],x=v(b);b.same(l)?x.dist=0:x.dist=1/0,x.pred=null,x.edge=null}for(var w=!1,E=function(e,t,n,r,i,a){var o=r.dist+a;o<i.dist&&!n.same(r.edge)&&(i.dist=o,i.pred=e,i.edge=n,w=!0)},k=1;k<d;k++){w=!1;for(var C=0;C<g;C++){var S=c[C],D=S.source(),T=S.target(),P=i(S),M=v(D),_=v(T);E(D,0,S,M,_,P),r||E(T,0,S,_,M,P)}if(!w)break}if(w)for(var B=0;B<g;B++){var N=c[B],I=N.source(),A=N.target(),L=i(N),z=v(I).dist,O=v(A).dist;if(z+L<O||!r&&O+L<z){be("Graph contains a negative weight cycle for Bellman-Ford"),f=!0;break}}return{distanceTo:function(e){return v(y(e)).dist},pathTo:function(e){for(var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:l,n=[],r=y(e);;){if(null==r)return s.spawn();var i=v(r),a=i.edge,o=i.pred;if(n.unshift(r[0]),r.same(t)&&0<n.length)break;null!=a&&n.unshift(a),r=o}return u.spawn(n)},hasNegativeWeightCycle:f,negativeWeightCycles:[]}}},We=Math.sqrt(2),He=function(e,t,n){0===n.length&&me("Karger-Stein must be run on a connected (sub)graph");for(var r=n[e],i=r[1],a=r[2],o=t[i],s=t[a],l=n,u=l.length-1;0<=u;u--){var c=l[u],h=c[1],d=c[2];(t[h]===o&&t[d]===s||t[h]===s&&t[d]===o)&&l.splice(u,1)}for(var p=0;p<l.length;p++){var f=l[p];f[1]===s?(l[p]=f.slice(),l[p][1]=o):f[2]===s&&(l[p]=f.slice(),l[p][2]=o)}for(var g=0;g<t.length;g++)t[g]===s&&(t[g]=o);return l},Ke=function(e,t,n,r){for(;r<n;){var i=Math.floor(Math.random()*t.length);t=He(i,e,t),n--}return t},Ge={kargerStein:function(){var e=this.byGroup(),t=e.nodes,n=e.edges;n.unmergeBy(function(e){return e.isLoop()});var r=t.length,i=n.length,a=Math.ceil(Math.pow(Math.log(r)/Math.LN2,2)),o=Math.floor(r/We);if(!(r<2)){for(var s=[],l=0;l<i;l++){var u=n[l];s.push([l,t.indexOf(u.source()),t.indexOf(u.target())])}for(var c=1/0,h=[],d=new Array(r),p=new Array(r),f=new Array(r),g=function(e,t){for(var n=0;n<r;n++)t[n]=e[n]},v=0;v<=a;v++){for(var y=0;y<r;y++)p[y]=y;var m=Ke(p,s.slice(),r,o),b=m.slice();g(p,f);var x=Ke(p,m,o,2),w=Ke(f,b,o,2);x.length<=w.length&&x.length<c?(c=x.length,h=x,g(p,d)):w.length<=x.length&&w.length<c&&(c=w.length,h=w,g(f,d))}for(var E=this.spawn(h.map(function(e){return n[e[0]]})),k=this.spawn(),C=this.spawn(),S=d[0],D=0;D<d.length;D++){var T=d[D],P=t[D];T===S?k.merge(P):C.merge(P)}return{cut:E,partition1:k,partition2:C}}me("At least 2 nodes are required for Karger-Stein algorithm")}},Ze=function(e,t,n){return{x:e.x*t+n.x,y:e.y*t+n.y}},Ue=function(e,t,n){return{x:(e.x-n.x)/t,y:(e.y-n.y)/t}},$e=function(e){return{x:e[0],y:e[1]}},Qe=function(e,t){return Math.atan2(t,e)-Math.PI/2},Je=Math.log2||function(e){return Math.log(e)/Math.log(2)},Jt=function(e,t){return Math.sqrt(et(e,t))},et=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},tt=function(e){for(var t=e.length,n=0,r=0;r<t;r++)n+=e[r];for(var i=0;i<t;i++)e[i]=e[i]/n;return e},nt=function(e,t,n,r){return(1-r)*(1-r)*e+2*(1-r)*r*t+r*r*n},rt=function(e,t,n,r){return{x:nt(e.x,t.x,n.x,r),y:nt(e.y,t.y,n.y,r)}},it=function(e,t,n){return Math.max(e,Math.min(n,t))},at=function(e){if(null==e)return{x1:1/0,y1:1/0,x2:-1/0,y2:-1/0,w:0,h:0};if(null!=e.x1&&null!=e.y1){if(null!=e.x2&&null!=e.y2&&e.x2>=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(null!=e.w&&null!=e.h&&0<=e.w&&0<=e.h)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},ot=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},st=function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},lt=function(e,t){e.x1+=t.x,e.x2+=t.x,e.y1+=t.y,e.y2+=t.y},ut=function(e,t){return!(e.x1>t.x2)&&(!(t.x1>e.x2)&&(!(e.x2<t.x1)&&(!(t.x2<e.x1)&&(!(e.y2<t.y1)&&(!(t.y2<e.y1)&&(!(e.y1>t.y2)&&!(t.y1>e.y2)))))))},ct=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},ht=function(e,t){return ct(e,t.x1,t.y1)&&ct(e,t.x2,t.y2)},dt=function(e,t,n,r,i,a,o){var s,l=Tt(i,a),u=i/2,c=a/2,h=r-c-o;if(0<(s=wt(e,t,n,r,n-u+l-o,h,n+u-l+o,h,!1)).length)return s;var d=n+u+o;if(0<(s=wt(e,t,n,r,d,r-c+l-o,d,r+c-l+o,!1)).length)return s;var p=r+c+o;if(0<(s=wt(e,t,n,r,n-u+l-o,p,n+u-l+o,p,!1)).length)return s;var f,g=n-u-o;if(0<(s=wt(e,t,n,r,g,r-c+l-o,g,r+c-l+o,!1)).length)return s;var v=n-u+l,y=r-c+l;if(0<(f=bt(e,t,n,r,v,y,l+o)).length&&f[0]<=v&&f[1]<=y)return[f[0],f[1]];var m=n+u-l,b=r-c+l;if(0<(f=bt(e,t,n,r,m,b,l+o)).length&&f[0]>=m&&f[1]<=b)return[f[0],f[1]];var x=n+u-l,w=r+c-l;if(0<(f=bt(e,t,n,r,x,w,l+o)).length&&f[0]>=x&&f[1]>=w)return[f[0],f[1]];var E=n-u+l,k=r+c-l;return 0<(f=bt(e,t,n,r,E,k,l+o)).length&&f[0]<=E&&f[1]>=k?[f[0],f[1]]:[]},pt=function(e,t,n,r,i,a,o,s){var l,u,c,h,d,p,f,g,v,y,m,b,x,w=[];u=9*n*i-3*n*n-3*n*o-6*i*i+3*i*o+9*r*a-3*r*r-3*r*s-6*a*a+3*a*s,c=3*n*n-6*n*i+n*o-n*e+2*i*i+2*i*e-o*e+3*r*r-6*r*a+r*s-r*t+2*a*a+2*a*t-s*t,h=1*n*i-n*n+n*e-i*e+r*a-r*r+r*t-a*t,g=-27*(h/=l=1*n*n-4*n*i+2*n*o+4*i*i-4*i*o+o*o+r*r-4*r*a+2*r*s+4*a*a-4*a*s+s*s)+(u/=l)*(9*(c/=l)-u*u*2),p=(f=(3*c-u*u)/9)*f*f+(g/=54)*g,b=u/3,((d=w)[1]=0)<p?(y=(y=g+Math.sqrt(p))<0?-Math.pow(-y,1/3):Math.pow(y,1/3),m=(m=g-Math.sqrt(p))<0?-Math.pow(-m,1/3):Math.pow(m,1/3),d[0]=-b+y+m,b+=(y+m)/2,d[4]=d[2]=-b,b=Math.sqrt(3)*(-m+y)/2,d[3]=b,d[5]=-b):(d[5]=d[3]=0,d[4]=0===p?(x=g<0?-Math.pow(-g,1/3):Math.pow(g,1/3),d[0]=2*x-b,d[2]=-(x+b)):(v=(f=-f)*f*f,v=Math.acos(g/Math.sqrt(v)),x=2*Math.sqrt(f),d[0]=-b+x*Math.cos(v/3),d[2]=-b+x*Math.cos((v+2*Math.PI)/3),-b+x*Math.cos((v+4*Math.PI)/3)));for(var E=[],k=0;k<6;k+=2)Math.abs(w[k+1])<1e-7&&0<=w[k]&&w[k]<=1&&E.push(w[k]);E.push(1),E.push(0);for(var C,S,D,T=-1,P=0;P<E.length;P++)C=Math.pow(1-E[P],2)*n+2*(1-E[P])*E[P]*i+E[P]*E[P]*o,S=Math.pow(1-E[P],2)*r+2*(1-E[P])*E[P]*a+E[P]*E[P]*s,D=Math.pow(C-e,2)+Math.pow(S-t,2),0<=T?D<T&&(T=D):T=D;return T},ft=function(e,t,n){for(var r,i,a,o,s=0,l=0;l<n.length/2;l++)if(r=n[2*l],i=n[2*l+1],o=l+1<n.length/2?(a=n[2*(l+1)],n[2*(l+1)+1]):(a=n[2*(l+1-n.length/2)],n[2*(l+1-n.length/2)+1]),r==e&&a==e);else{if(!(e<=r&&a<=e||r<=e&&e<=a))continue;t<(e-r)/(a-r)*(o-i)+i&&s++}return s%2!=0},gt=function(e,t,n,r,i,a,o,s,l){var u,c=new Array(n.length);null!=s[0]?(u=Math.atan(s[1]/s[0]),s[0]<0?u+=Math.PI/2:u=-u-Math.PI/2):u=s;for(var h,d=Math.cos(-u),p=Math.sin(-u),f=0;f<c.length/2;f++)c[2*f]=a/2*(n[2*f]*d-n[2*f+1]*p),c[2*f+1]=o/2*(n[2*f+1]*d+n[2*f]*p),c[2*f]+=r,c[2*f+1]+=i;if(0<l){var g=yt(c,-l);h=vt(g)}else h=c;return ft(e,t,h)},vt=function(e){for(var t,n,r,i,a,o,s,l,u=new Array(e.length/2),c=0;c<e.length/4;c++){t=e[4*c],n=e[4*c+1],r=e[4*c+2],i=e[4*c+3],l=c<e.length/4-1?(a=e[4*(c+1)],o=e[4*(c+1)+1],s=e[4*(c+1)+2],e[4*(c+1)+3]):(a=e[0],o=e[1],s=e[2],e[3]);var h=wt(t,n,r,i,a,o,s,l,!0);u[2*c]=h[0],u[2*c+1]=h[1]}return u},yt=function(e,t){for(var n,r,i,a,o=new Array(2*e.length),s=0;s<e.length/2;s++){n=e[2*s],r=e[2*s+1];var l=(a=s<e.length/2-1?(i=e[2*(s+1)],e[2*(s+1)+1]):(i=e[0],e[1]))-r,u=-(i-n),c=Math.sqrt(l*l+u*u),h=l/c,d=u/c;o[4*s]=n+h*t,o[4*s+1]=r+d*t,o[4*s+2]=i+h*t,o[4*s+3]=a+d*t}return o},mt=function(e,t,n,r,i,a,o){return e-=i,t-=a,(e/=n/2+o)*e+(t/=r/2+o)*t<=1},bt=function(e,t,n,r,i,a,o){var s=[n-e,r-t],l=[e-i,t-a],u=s[0]*s[0]+s[1]*s[1],c=2*(l[0]*s[0]+l[1]*s[1]),h=c*c-4*u*(l[0]*l[0]+l[1]*l[1]-o*o);if(h<0)return[];var d=(-c+Math.sqrt(h))/(2*u),p=(-c-Math.sqrt(h))/(2*u),f=Math.min(d,p),g=Math.max(d,p),v=[];if(0<=f&&f<=1&&v.push(f),0<=g&&g<=1&&v.push(g),0===v.length)return[];var y=v[0]*s[0]+e,m=v[0]*s[1]+t;return 1<v.length?v[0]==v[1]?[y,m]:[y,m,v[1]*s[0]+e,v[1]*s[1]+t]:[y,m]},xt=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},wt=function(e,t,n,r,i,a,o,s,l){var u=e-i,c=n-e,h=o-i,d=t-a,p=r-t,f=s-a,g=h*d-f*u,v=c*d-p*u,y=f*c-h*p;if(0===y)return 0===g||0===v?xt(e,n,o)===o?[o,s]:xt(e,n,i)===i?[i,a]:xt(i,o,n)===n?[n,r]:[]:[];var m=g/y,b=v/y;return-.001<=m&&m<=1.001&&-.001<=b&&b<=1.001?[e+m*c,t+m*p]:l?[e+m*c,t+m*p]:[]},Et=function(e,t,n,r,i,a,o,s){var l,u,c,h,d,p,f=[],g=new Array(n.length),v=!0;if(null==a&&(v=!1),v){for(var y=0;y<g.length/2;y++)g[2*y]=n[2*y]*a+r,g[2*y+1]=n[2*y+1]*o+i;if(0<s){var m=yt(g,-s);u=vt(m)}else u=g}else u=n;for(var b=0;b<u.length/2;b++)c=u[2*b],h=u[2*b+1],p=b<u.length/2-1?(d=u[2*(b+1)],u[2*(b+1)+1]):(d=u[0],u[1]),0!==(l=wt(e,t,r,i,c,h,d,p)).length&&f.push(l[0],l[1]);return f},kt=function(e,t,n){var r=[e[0]-t[0],e[1]-t[1]],i=Math.sqrt(r[0]*r[0]+r[1]*r[1]),a=(i-n)/i;return a<0&&(a=1e-5),[t[0]+a*r[0],t[1]+a*r[1]]},Ct=function(e,t){var n=Dt(e,t);return n=St(n)},St=function(e){for(var t,n,r=e.length/2,i=1/0,a=1/0,o=-1/0,s=-1/0,l=0;l<r;l++)t=e[2*l],n=e[2*l+1],i=Math.min(i,t),o=Math.max(o,t),a=Math.min(a,n),s=Math.max(s,n);for(var u=2/(o-i),c=2/(s-a),h=0;h<r;h++)t=e[2*h]=e[2*h]*u,n=e[2*h+1]=e[2*h+1]*c,i=Math.min(i,t),o=Math.max(o,t),a=Math.min(a,n),s=Math.max(s,n);if(a<-1)for(var d=0;d<r;d++)n=e[2*d+1]=e[2*d+1]+(-1-a);return e},Dt=function(e,t){var n=1/e*2*Math.PI,r=e%2==0?Math.PI/2+n/2:Math.PI/2;r+=t;for(var i,a=new Array(2*e),o=0;o<e;o++)i=o*n+r,a[2*o]=Math.cos(i),a[2*o+1]=Math.sin(-i);return a},Tt=function(e,t){return Math.min(e/4,t/4,8)},Pt=function(e,t){return{heightOffset:Math.min(15,.05*t),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}},Mt=Ce({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),_t={pageRank:function(e){for(var t=Mt(e),n=t.dampingFactor,r=t.precision,i=t.iterations,a=t.weight,o=this._private.cy,s=this.byGroup(),l=s.nodes,u=s.edges,c=l.length,h=c*c,d=u.length,p=new Array(h),f=new Array(c),g=(1-n)/c,v=0;v<c;v++){for(var y=0;y<c;y++){p[v*c+y]=0}f[v]=0}for(var m=0;m<d;m++){var b=u[m],x=b.data("source"),w=b.data("target");if(x!==w){var E=l.indexOfId(x),k=l.indexOfId(w),C=a(b);p[k*c+E]+=C,f[E]+=C}}for(var S=1/c+g,D=0;D<c;D++)if(0===f[D])for(var T=0;T<c;T++){p[T*c+D]=S}else for(var P=0;P<c;P++){var M=P*c+D;p[M]=p[M]/f[D]+g}for(var _,B=new Array(c),N=new Array(c),I=0;I<c;I++)B[I]=1;for(var A=0;A<i;A++){for(var L=0;L<c;L++)N[L]=0;for(var z=0;z<c;z++)for(var O=0;O<c;O++){var R=z*c+O;N[z]+=p[R]*B[O]}tt(N),_=B,B=N,N=_;for(var F=0,V=0;V<c;V++){var q=_[V]-B[V];F+=q*q}if(F<r)break}return{rank:function(e){return e=o.collection(e)[0],B[l.indexOf(e)]}}}},Bt=Ce({root:null,weight:function(e){return 1},directed:!1,alpha:0}),Nt={degreeCentralityNormalized:function(e){e=Bt(e);var t=this.cy(),n=this.nodes(),r=n.length;if(e.directed){for(var i={},a={},o=0,s=0,l=0;l<r;l++){var u=n[l],c=u.id();e.root=u;var h=this.degreeCentrality(e);o<h.indegree&&(o=h.indegree),s<h.outdegree&&(s=h.outdegree),i[c]=h.indegree,a[c]=h.outdegree}return{indegree:function(e){return 0==o?0:(K(e)&&(e=t.filter(e)),i[e.id()]/o)},outdegree:function(e){return 0===s?0:(K(e)&&(e=t.filter(e)),a[e.id()]/s)}}}for(var d={},p=0,f=0;f<r;f++){var g=n[f];e.root=g;var v=this.degreeCentrality(e);p<v.degree&&(p=v.degree),d[g.id()]=v.degree}return{degree:function(e){return 0===p?0:(K(e)&&(e=t.filter(e)),d[e.id()]/p)}}},degreeCentrality:function(e){e=Bt(e);var t=this.cy(),n=this,r=e,i=r.root,a=r.weight,o=r.directed,s=r.alpha;if(i=t.collection(i)[0],o){for(var l=i.connectedEdges(),u=l.filter(function(e){return e.target().same(i)&&n.has(e)}),c=l.filter(function(e){return e.source().same(i)&&n.has(e)}),h=u.length,d=c.length,p=0,f=0,g=0;g<u.length;g++)p+=a(u[g]);for(var v=0;v<c.length;v++)f+=a(c[v]);return{indegree:Math.pow(h,1-s)*Math.pow(p,s),outdegree:Math.pow(d,1-s)*Math.pow(f,s)}}for(var y=i.connectedEdges().intersection(n),m=y.length,b=0,x=0;x<y.length;x++)b+=a(y[x]);return{degree:Math.pow(m,1-s)*Math.pow(b,s)}}};Nt.dc=Nt.degreeCentrality,Nt.dcn=Nt.degreeCentralityNormalised=Nt.degreeCentralityNormalized;var It=Ce({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),At={closenessCentralityNormalized:function(e){for(var t=It(e),n=t.harmonic,r=t.weight,i=t.directed,a=this.cy(),o={},s=0,l=this.nodes(),u=this.floydWarshall({weight:r,directed:i}),c=0;c<l.length;c++){for(var h=0,d=l[c],p=0;p<l.length;p++)if(c!==p){var f=u.distance(d,l[p]);h+=n?1/f:f}n||(h=1/h),s<h&&(s=h),o[d.id()]=h}return{closeness:function(e){return 0==s?0:(e=K(e)?a.filter(e)[0].id():e.id(),o[e]/s)}}},closenessCentrality:function(e){var t=It(e),n=t.root,r=t.weight,i=t.directed,a=t.harmonic;n=this.filter(n)[0];for(var o=this.dijkstra({root:n,weight:r,directed:i}),s=0,l=this.nodes(),u=0;u<l.length;u++){var c=l[u];if(!c.same(n)){var h=o.distanceTo(c);s+=a?1/h:h}}return a?s:1/s}};At.cc=At.closenessCentrality,At.ccn=At.closenessCentralityNormalised=At.closenessCentralityNormalized;var Lt=Ce({weight:null,directed:!1}),zt={betweennessCentrality:function(e){for(var t=Lt(e),n=t.directed,E=t.weight,k=null!=E,C=this.cy(),S=this.nodes(),D={},r={},i=0,T=function(e,t){r[e]=t,i<t&&(i=t)},P=function(e){return r[e]},a=0;a<S.length;a++){var o=S[a],s=o.id();D[s]=n?o.outgoers().nodes():o.openNeighborhood().nodes(),T(s,0)}for(var l=function(e){for(var t=S[e].id(),n=[],r={},i={},a={},o=new Le(function(e,t){return a[e]-a[t]}),s=0;s<S.length;s++){var l=S[s].id();r[l]=[],i[l]=0,a[l]=1/0}for(i[t]=1,a[t]=0,o.push(t);!o.empty();){var u=o.pop();if(n.push(u),k)for(var c=0;c<D[u].length;c++){var h=D[u][c],d=C.getElementById(u),p=void 0;p=0<d.edgesTo(h).length?d.edgesTo(h)[0]:h.edgesTo(d)[0];var f=E(p);h=h.id(),a[h]>a[u]+f&&(a[h]=a[u]+f,o.nodes.indexOf(h)<0?o.push(h):o.updateItem(h),i[h]=0,r[h]=[]),a[h]==a[u]+f&&(i[h]=i[h]+i[u],r[h].push(u))}else for(var g=0;g<D[u].length;g++){var v=D[u][g].id();a[v]==1/0&&(o.push(v),a[v]=a[u]+1),a[v]==a[u]+1&&(i[v]=i[v]+i[u],r[v].push(u))}}for(var y={},m=0;m<S.length;m++)y[S[m].id()]=0;for(;0<n.length;)for(var b=n.pop(),x=0;x<r[b].length;x++){var w=r[b][x];y[w]=y[w]+i[w]/i[b]*(1+y[b]),b!=S[e].id()&&T(b,P(b)+y[b])}},u=0;u<S.length;u++)l(u);var c={betweenness:function(e){var t=C.collection(e).id();return P(t)},betweennessNormalized:function(e){if(0==i)return 0;var t=C.collection(e).id();return P(t)/i}};return c.betweennessNormalised=c.betweennessNormalized,c}};zt.bc=zt.betweennessCentrality;var Ot=Ce({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(e){return 1}]}),Rt=function(e,t){for(var n=0,r=0;r<t.length;r++)n+=t[r](e);return n},Ft=function(e,t){for(var n,r=0;r<t;r++){for(var i=n=0;i<t;i++)n+=e[i*t+r];for(var a=0;a<t;a++)e[a*t+r]=e[a*t+r]/n}},Vt=function(e,t,n){for(var r=new Array(n*n),i=0;i<n;i++){for(var a=0;a<n;a++)r[i*n+a]=0;for(var o=0;o<n;o++)for(var s=0;s<n;s++)r[i*n+s]+=e[i*n+o]*t[o*n+s]}return r},qt=function(e,t,n){for(var r=e.slice(0),i=1;i<n;i++)e=Vt(e,r,t);return e},Yt=function(e,t,n){for(var r=new Array(t*t),i=0;i<t*t;i++)r[i]=Math.pow(e[i],n);return Ft(r,t),r},Xt=function(e,t,n,r){for(var i=0;i<n;i++){if(Math.round(e[i]*Math.pow(10,r))/Math.pow(10,r)!==Math.round(t[i]*Math.pow(10,r))/Math.pow(10,r))return!1}return!0},jt=function(e,t){for(var n=0;n<e.length;n++)if(!t[n]||e[n].id()!==t[n].id())return!1;return!0},Wt=function(e){for(var t=this.nodes(),n=this.edges(),r=this.cy(),i=Ot(e),a={},o=0;o<t.length;o++)a[t[o].id()]=o;for(var s,l=t.length,u=l*l,c=new Array(u),h=0;h<u;h++)c[h]=0;for(var d=0;d<n.length;d++){var p=n[d],f=a[p.source().id()],g=a[p.target().id()],v=Rt(p,i.attributes);c[f*l+g]+=v,c[g*l+f]+=v}!function(e,t,n){for(var r=0;r<t;r++)e[r*t+r]=n}(c,l,i.multFactor),Ft(c,l);for(var y=!0,m=0;y&&m<i.maxIterations;)y=!1,s=qt(c,l,i.expandFactor),c=Yt(s,l,i.inflateFactor),Xt(c,s,u,4)||(y=!0),m++;var b=function(e,t,n,r){for(var i=[],a=0;a<t;a++){for(var o=[],s=0;s<t;s++)0<Math.round(1e3*e[a*t+s])/1e3&&o.push(n[s]);0!==o.length&&i.push(r.collection(o))}return i}(c,l,t,r);return b=function(e){for(var t=0;t<e.length;t++)for(var n=0;n<e.length;n++)t!=n&&jt(e[t],e[n])&&e.splice(n,1);return e}(b)},Ht={markovClustering:Wt,mcl:Wt},Kt=function(e){return e},Gt=function(e,t){return Math.abs(t-e)},Zt=function(e,t,n){return e+Gt(t,n)},Ut=function(e,t,n){return e+Math.pow(n-t,2)},en=function(e){return Math.sqrt(e)},tn=function(e,t,n){return Math.max(e,Gt(t,n))},nn=function(e,t,n,r,i){for(var a=5<arguments.length&&void 0!==arguments[5]?arguments[5]:Kt,o=r,s=0;s<e;s++)o=i(o,t(s),n(s));return a(o)},rn={euclidean:function(e,t,n){return 2<=e?nn(e,t,n,0,Ut,en):nn(e,t,n,0,Zt)},squaredEuclidean:function(e,t,n){return nn(e,t,n,0,Ut)},manhattan:function(e,t,n){return nn(e,t,n,0,Zt)},max:function(e,t,n){return nn(e,t,n,-1/0,tn)}};function an(e,t,n,r,i,a){var o;return o=X(e)?e:rn[e]||rn.euclidean,0===t&&X(e)?o(i,a):o(t,n,r,i,a)}rn["squared-euclidean"]=rn.squaredEuclidean,rn.squaredeuclidean=rn.squaredEuclidean;var on=Ce({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),sn=function(e){return on(e)},ln=function(e,t,n,r,i){var a="kMedoids"===i?function(e){return r[e](n)}:function(e){return n[e]};return an(e,r.length,a,function(e){return r[e](t)})},un=function(e,t,n){for(var r=n.length,i=new Array(r),a=new Array(r),o=new Array(t),s=null,l=0;l<r;l++)i[l]=e.min(n[l]).value,a[l]=e.max(n[l]).value;for(var u=0;u<t;u++){s=[];for(var c=0;c<r;c++)s[c]=Math.random()*(a[c]-i[c])+i[c];o[u]=s}return o},cn=function(e,t,n,r,i){for(var a=1/0,o=0,s=0;s<t.length;s++){var l=ln(n,e,t[s],r,i);l<a&&(a=l,o=s)}return o},hn=function(e,t,n){for(var r=[],i=null,a=0;a<t.length;a++)n[(i=t[a]).id()]===e&&r.push(i);return r},dn=function(e,t,n){for(var r=0;r<e.length;r++)for(var i=0;i<e[r].length;i++){if(n<Math.abs(e[r][i]-t[r][i]))return!1}return!0},pn=function(e,t,n){for(var r=0;r<n;r++)if(e===t[r])return!0;return!1},fn=function(e,t){var n=new Array(t);if(e.length<50)for(var r=0;r<t;r++){for(var i=e[Math.floor(Math.random()*e.length)];pn(i,n,r);)i=e[Math.floor(Math.random()*e.length)];n[r]=i}else for(var a=0;a<t;a++)n[a]=e[Math.floor(Math.random()*e.length)];return n},gn=function(e,t,n){for(var r=0,i=0;i<t.length;i++)r+=ln("manhattan",t[i],e,n,"kMedoids");return r},vn=function(e,t,n,r,i){for(var a,o,s=0;s<t.length;s++)for(var l=0;l<e.length;l++)r[s][l]=Math.pow(n[s][l],i.m);for(var u=0;u<e.length;u++)for(var c=0;c<i.attributes.length;c++){for(var h=o=a=0;h<t.length;h++)a+=r[h][u]*i.attributes[c](t[h]),o+=r[h][u];e[u][c]=a/o}},yn=function(e,t,n,r,i){for(var a=0;a<e.length;a++)t[a]=e[a].slice();for(var o,s,l,u=2/(i.m-1),c=0;c<n.length;c++)for(var h=0;h<r.length;h++){for(var d=o=0;d<n.length;d++)s=ln(i.distance,r[h],n[c],i.attributes,"cmeans"),l=ln(i.distance,r[h],n[d],i.attributes,"cmeans"),o+=Math.pow(s/l,u);e[h][c]=1/o}},mn=function(e){var t,n,r,i,a=this.cy(),o=this.nodes(),s=sn(e);r=new Array(o.length);for(var l=0;l<o.length;l++)r[l]=new Array(s.k);n=new Array(o.length);for(var u=0;u<o.length;u++)n[u]=new Array(s.k);for(var c=0;c<o.length;c++){for(var h=0,d=0;d<s.k;d++)n[c][d]=Math.random(),h+=n[c][d];for(var p=0;p<s.k;p++)n[c][p]=n[c][p]/h}t=new Array(s.k);for(var f=0;f<s.k;f++)t[f]=new Array(s.attributes.length);i=new Array(o.length);for(var g=0;g<o.length;g++)i[g]=new Array(s.k);for(var v=!0,y=0;v&&y<s.maxIterations;)v=!1,vn(t,o,n,i,s),yn(n,r,t,o,s),dn(n,r,s.sensitivityThreshold)||(v=!0),y++;return{clusters:function(e,t,n,r){for(var i,a,o=new Array(n.k),s=0;s<o.length;s++)o[s]=[];for(var l=0;l<t.length;l++){i=-1/0,a=-1;for(var u=0;u<t[0].length;u++)t[l][u]>i&&(i=t[l][u],a=u);o[a].push(e[l])}for(var c=0;c<o.length;c++)o[c]=r.collection(o[c]);return o}(o,n,s,a),degreeOfMembership:n}},bn={kMeans:function(e){var t,n=this.cy(),r=this.nodes(),i=null,a=sn(e),o=new Array(a.k),s={};t=a.testMode?"number"==typeof a.testCentroids?(a.testCentroids,un(r,a.k,a.attributes)):"object"===E(a.testCentroids)?a.testCentroids:un(r,a.k,a.attributes):un(r,a.k,a.attributes);for(var l,u,c,h=!0,d=0;h&&d<a.maxIterations;){for(var p=0;p<r.length;p++)s[(i=r[p]).id()]=cn(i,t,a.distance,a.attributes,"kMeans");h=!1;for(var f=0;f<a.k;f++){var g=hn(f,r,s);if(0!==g.length){for(var v=a.attributes.length,y=t[f],m=new Array(v),b=new Array(v),x=0;x<v;x++){for(var w=b[x]=0;w<g.length;w++)i=g[w],b[x]+=a.attributes[x](i);m[x]=b[x]/g.length,l=m[x],u=y[x],c=a.sensitivityThreshold,Math.abs(u-l)<=c||(h=!0)}t[f]=m,o[f]=n.collection(g)}}d++}return o},kMedoids:function(e){var t,n,r=this.cy(),i=this.nodes(),a=null,o=sn(e),s=new Array(o.k),l={},u=new Array(o.k);o.testMode?"number"==typeof o.testCentroids||(t="object"===E(o.testCentroids)?o.testCentroids:fn(i,o.k)):t=fn(i,o.k);for(var c=!0,h=0;c&&h<o.maxIterations;){for(var d=0;d<i.length;d++)l[(a=i[d]).id()]=cn(a,t,o.distance,o.attributes,"kMedoids");c=!1;for(var p=0;p<t.length;p++){var f=hn(p,i,l);if(0!==f.length){u[p]=gn(t[p],f,o.attributes);for(var g=0;g<f.length;g++)(n=gn(f[g],f,o.attributes))<u[p]&&(u[p]=n,t[p]=f[g],c=!0);s[p]=r.collection(f)}}h++}return s},fuzzyCMeans:mn,fcm:mn},xn=Ce({distance:"euclidean",linkage:"min",mode:"threshold",threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),wn={single:"min",complete:"max"},En=function(e,t,n,r,i){for(var a,o=0,s=1/0,l=i.attributes,u=function(t,n){return an(i.distance,l.length,function(e){return l[e](t)},function(e){return l[e](n)})},c=0;c<e.length;c++){var h=e[c].key,d=n[h][r[h]];d<s&&(o=h,s=d)}if("threshold"===i.mode&&s>=i.threshold||"dendrogram"===i.mode&&1===e.length)return!1;var p,f=t[o],g=t[r[o]];p="dendrogram"===i.mode?{left:f,right:g,key:f.key}:{value:f.value.concat(g.value),key:f.key},e[f.index]=p,e.splice(g.index,1),t[f.key]=p;for(var v=0;v<e.length;v++){var y=e[v];f.key===y.key?a=1/0:"min"===i.linkage?(a=n[f.key][y.key],n[f.key][y.key]>n[g.key][y.key]&&(a=n[g.key][y.key])):"max"===i.linkage?(a=n[f.key][y.key],n[f.key][y.key]<n[g.key][y.key]&&(a=n[g.key][y.key])):a="mean"===i.linkage?(n[f.key][y.key]*f.size+n[g.key][y.key]*g.size)/(f.size+g.size):"dendrogram"===i.mode?u(y.value,f.value):u(y.value[0],f.value[0]),n[f.key][y.key]=n[y.key][f.key]=a}for(var m=0;m<e.length;m++){var b=e[m].key;if(r[b]===f.key||r[b]===g.key){for(var x=b,w=0;w<e.length;w++){var E=e[w].key;n[b][E]<n[b][x]&&(x=E)}r[b]=x}e[m].index=m}return f.key=g.key=f.index=g.index=null,!0},kn=function e(t,n,r){t&&(t.value?n.push(t.value):(t.left&&e(t.left,n,r),t.right&&e(t.right,n,r)))},Cn=function(e){for(var t,n,r=this.cy(),i=this.nodes(),a=(t=xn(e),null!=(n=wn[t.linkage])&&(t.linkage=n),t),o=a.attributes,s=function(t,n){return an(a.distance,o.length,function(e){return o[e](t)},function(e){return o[e](n)})},l=[],u=[],c=[],h=[],d=0;d<i.length;d++){var p={value:"dendrogram"===a.mode?i[d]:[i[d]],key:d,index:d};l[d]=p,h[d]=p,u[d]=[],c[d]=0}for(var f=0;f<l.length;f++)for(var g=0;g<=f;g++){var v=void 0;v="dendrogram"===a.mode?f===g?1/0:s(l[f].value,l[g].value):f===g?1/0:s(l[f].value[0],l[g].value[0]),u[f][g]=v,(u[g][f]=v)<u[f][c[f]]&&(c[f]=g)}for(var y,m=En(l,h,u,c,a);m;)m=En(l,h,u,c,a);return"dendrogram"===a.mode?(y=function e(t,n,r){if(!t)return[];var i=[],a=[],o=[];return 0===n?(t.left&&kn(t.left,i,r),t.right&&kn(t.right,a,r),o=i.concat(a),[r.collection(o)]):1===n?t.value?[r.collection(t.value)]:(t.left&&kn(t.left,i,r),t.right&&kn(t.right,a,r),[r.collection(i),r.collection(a)]):t.value?[r.collection(t.value)]:(t.left&&(i=e(t.left,n-1,r)),t.right&&(a=e(t.right,n-1,r)),i.concat(a))}(l[0],a.dendrogramDepth,r),a.addDendrogram&&function e(t,n){if(!t)return"";if(t.left&&t.right){var r=e(t.left,n),i=e(t.right,n),a=n.add({group:"nodes",data:{id:r+","+i}});return n.add({group:"edges",data:{source:r,target:a.id()}}),n.add({group:"edges",data:{source:i,target:a.id()}}),a.id()}return t.value?t.value.id():void 0}(l[0],r)):(y=new Array(l.length),l.forEach(function(e,t){e.key=e.index=null,y[t]=r.collection(e.value)})),y},Sn={hierarchicalClustering:Cn,hca:Cn},Dn=Ce({distance:"euclidean",preference:"median",damping:.8,maxIterations:1e3,minIterations:100,attributes:[]}),Tn=function(e,t,n,r){var i=function(e,t){return r[t](e)};return-an(e,r.length,function(e){return i(t,e)},function(e){return i(n,e)},t,n)},Pn=function(e,t){return"median"===t?function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:e.length,r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],i=!(4<arguments.length&&void 0!==arguments[4])||arguments[4],a=!(5<arguments.length&&void 0!==arguments[5])||arguments[5];r?e=e.slice(t,n):(n<e.length&&e.splice(n,e.length-n),0<t&&e.splice(0,t));for(var o=0,s=e.length-1;0<=s;s--){var l=e[s];a?isFinite(l)||(e[s]=-1/0,o++):e.splice(s,1)}i&&e.sort(function(e,t){return e-t});var u=e.length,c=Math.floor(u/2);return u%2!=0?e[c+1+o]:(e[c-1+o]+e[c+o])/2}(e):"mean"===t?function(e){for(var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:e.length,r=0,i=0,a=t;a<n;a++){var o=e[a];isFinite(o)&&(r+=o,i++)}return r/i}(e):"min"===t?function(e){for(var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:e.length,r=1/0,i=t;i<n;i++){var a=e[i];isFinite(a)&&(r=Math.min(a,r))}return r}(e):"max"===t?function(e){for(var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:e.length,r=-1/0,i=t;i<n;i++){var a=e[i];isFinite(a)&&(r=Math.max(a,r))}return r}(e):t},Mn=function(e,t,n){for(var r=[],i=0;i<e;i++){for(var a=-1,o=-1/0,s=0;s<n.length;s++){var l=n[s];t[i*e+l]>o&&(o=t[i*e+(a=l)])}0<a&&r.push(a)}for(var u=0;u<n.length;u++)r[n[u]]=n[u];return r},_n=function(e){for(var t,n,r,i,a,o,s=this.cy(),l=this.nodes(),u=function(e){var t=e.damping,n=e.preference;.5<=t&&t<1||me("Damping must range on [0.5, 1). Got: ".concat(t));var r=["median","mean","min","max"];return r.some(function(e){return e===n})||$t(n)||me("Preference must be one of [".concat(r.map(function(e){return"'".concat(e,"'")}).join(", "),"] or a number. Got: ").concat(n)),Dn(e)}(e),c={},h=0;h<l.length;h++)c[l[h].id()]=h;n=(t=l.length)*t,r=new Array(n);for(var d=0;d<n;d++)r[d]=-1/0;for(var p=0;p<t;p++)for(var f=0;f<t;f++)p!==f&&(r[p*t+f]=Tn(u.distance,l[p],l[f],u.attributes));i=Pn(r,u.preference);for(var g=0;g<t;g++)r[g*t+g]=i;a=new Array(n);for(var v=0;v<n;v++)a[v]=0;o=new Array(n);for(var y=0;y<n;y++)o[y]=0;for(var m=new Array(t),b=new Array(t),x=new Array(t),w=0;w<t;w++)m[w]=0,b[w]=0,x[w]=0;for(var E,k=new Array(t*u.minIterations),C=0;C<k.length;C++)k[C]=0;for(E=0;E<u.maxIterations;E++){for(var S=0;S<t;S++){for(var D=-1/0,T=-1/0,P=-1,M=0,_=0;_<t;_++)m[_]=a[S*t+_],D<=(M=o[S*t+_]+r[S*t+_])?(T=D,D=M,P=_):T<M&&(T=M);for(var B=0;B<t;B++)a[S*t+B]=(1-u.damping)*(r[S*t+B]-D)+u.damping*m[B];a[S*t+P]=(1-u.damping)*(r[S*t+P]-T)+u.damping*m[P]}for(var N=0;N<t;N++){for(var I=0,A=0;A<t;A++)m[A]=o[A*t+N],b[A]=Math.max(0,a[A*t+N]),I+=b[A];I-=b[N],b[N]=a[N*t+N],I+=b[N];for(var L=0;L<t;L++)o[L*t+N]=(1-u.damping)*Math.min(0,I-b[L])+u.damping*m[L];o[N*t+N]=(1-u.damping)*(I-b[N])+u.damping*m[N]}for(var z=0,O=0;O<t;O++){var R=0<o[O*t+O]+a[O*t+O]?1:0;z+=k[E%u.minIterations*t+O]=R}if(0<z&&(E>=u.minIterations-1||E==u.maxIterations-1)){for(var F=0,V=0;V<t;V++){for(var q=x[V]=0;q<u.minIterations;q++)x[V]+=k[q*t+V];0!==x[V]&&x[V]!==u.minIterations||F++}if(F===t)break}}for(var Y=function(e,t,n){for(var r=[],i=0;i<e;i++)0<t[i*e+i]+n[i*e+i]&&r.push(i);return r}(t,a,o),X=function(e,t,n){for(var r=Mn(e,t,n),i=0;i<n.length;i++){for(var a=[],o=0;o<r.length;o++)r[o]===n[i]&&a.push(o);for(var s=-1,l=-1/0,u=0;u<a.length;u++){for(var c=0,h=0;h<a.length;h++)c+=t[a[h]*e+a[u]];l<c&&(s=u,l=c)}n[i]=a[s]}return r=Mn(e,t,n)}(t,r,Y),j={},W=0;W<Y.length;W++)j[Y[W]]=[];for(var H=0;H<l.length;H++){var K=X[c[l[H].id()]];null!=K&&j[K].push(l[H])}for(var G=new Array(Y.length),Z=0;Z<Y.length;Z++)G[Z]=s.collection(j[Y[Z]]);return G},Bn={};[Ie,Oe,Re,Ve,Ye,je,Ge,_t,Nt,At,zt,Ht,bn,Sn,{affinityPropagation:_n,ap:_n}].forEach(function(e){S(Bn,e)});var Nn=function e(t){if(!(this instanceof e))return new e(t);this.id="Thenable/1.0.7",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof t&&t.call(this,this.fulfill.bind(this),this.reject.bind(this))};Nn.prototype={fulfill:function(e){return In(this,1,"fulfillValue",e)},reject:function(e){return In(this,2,"rejectReason",e)},then:function(e,t){var n=new Nn;return this.onFulfilled.push(zn(e,n,"fulfill")),this.onRejected.push(zn(t,n,"reject")),An(this),n.proxy}};var In=function(e,t,n,r){return 0===e.state&&(e.state=t,e[n]=r,An(e)),e},An=function(e){1===e.state?Ln(e,"onFulfilled",e.fulfillValue):2===e.state&&Ln(e,"onRejected",e.rejectReason)},Ln=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var i=function(){for(var e=0;e<r.length;e++)r[e](n)};"function"==typeof setImmediate?setImmediate(i):setTimeout(i,0)}},zn=function(n,r,i){return function(e){if("function"!=typeof n)r[i].call(r,e);else{var t;try{t=n(e)}catch(e){return void r.reject(e)}On(r,t)}}},On=function t(n,r){if(n!==r&&n.proxy!==r){var e;if("object"===E(r)&&null!==r||"function"==typeof r)try{e=r.then}catch(e){return void n.reject(e)}if("function"!=typeof e)n.fulfill(r);else{var i=!1;try{e.call(r,function(e){i||(i=!0,e===r?n.reject(new TypeError("circular thenable chain")):t(n,e))},function(e){i||(i=!0,n.reject(e))})}catch(e){i||n.reject(e)}}}else n.reject(new TypeError("cannot resolve promise with itself"))};Nn.all=function(s){return new Nn(function(n,r){for(var i=new Array(s.length),a=0,o=function(e,t){i[e]=t,++a===s.length&&n(i)},e=0;e<s.length;e++)!function(t){var e=s[t];null!=e&&null!=e.then?e.then(function(e){o(t,e)},function(e){r(e)}):o(t,e)}(e)})},Nn.resolve=function(n){return new Nn(function(e,t){e(n)})},Nn.reject=function(n){return new Nn(function(e,t){t(n)})};var Rn="undefined"!=typeof Promise?Promise:Nn,Fn=function(e,t,n){var r=this._private=S({duration:1e3},t,n);r.target=e,r.style=r.style||r.css,r.started=!1,r.playing=!1,r.hooked=!1,r.applying=!1,r.progress=0,r.completes=[],r.frames=[],r.complete&&X(r.complete)&&r.completes.push(r.complete),this.length=1,this[0]=this},Vn=Fn.prototype;S(Vn,{instanceString:function(){return"animation"},hook:function(){var e=this._private;if(!e.hooked){var t=e.target._private.animation;(e.queue?t.queue:t.current).push(this),Z(e.target)&&e.target.cy().addToAnimationPool(e.target),e.hooked=!0}return this},play:function(){var e=this._private;return 1===e.progress&&(e.progress=0),e.playing=!0,e.started=!1,e.stopped=!1,this.hook(),this},playing:function(){return this._private.playing},apply:function(){var e=this._private;return e.applying=!0,e.started=!1,e.stopped=!1,this.hook(),this},applying:function(){return this._private.applying},pause:function(){var e=this._private;return e.playing=!1,e.started=!1,this},stop:function(){var e=this._private;return e.playing=!1,e.started=!1,e.stopped=!0,this},rewind:function(){return this.progress(0)},fastforward:function(){return this.progress(1)},time:function(e){var t=this._private;return void 0===e?t.progress*t.duration:this.progress(e/t.duration)},progress:function(e){var t=this._private,n=t.playing;return void 0===e?t.progress:(n&&this.pause(),t.progress=e,t.started=!1,n&&this.play(),this)},completed:function(){return 1===this._private.progress},reverse:function(){var r=this._private,e=r.playing;e&&this.pause(),r.progress=1-r.progress,r.started=!1;var t=function(e,t){var n=r[e];null!=n&&(r[e]=r[t],r[t]=n)};if(t("zoom","startZoom"),t("pan","startPan"),t("position","startPosition"),r.style)for(var n=0;n<r.style.length;n++){var i=r.style[n],a=i.name,o=r.startStyle[a];r.startStyle[a]=i,r.style[n]=o}return e&&this.play(),this},promise:function(e){var n,t=this._private;switch(e){case"frame":n=t.frames;break;default:case"complete":case"completed":n=t.completes}return new Rn(function(e,t){n.push(function(){e()})})}}),Vn.complete=Vn.completed,Vn.run=Vn.play,Vn.running=Vn.playing;var qn={};[{animated:function(){return function(){var e=void 0!==this.length?this:[this];if(!(this._private.cy||this).styleEnabled())return!1;var t=e[0];return t?0<t._private.animation.current.length:void 0}},clearQueue:function(){return function(){var e=void 0!==this.length?this:[this];if(!(this._private.cy||this).styleEnabled())return this;for(var t=0;t<e.length;t++){e[t]._private.animation.queue=[]}return this}},delay:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animate({delay:e,duration:e,complete:t}):this}},delayAnimation:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animation({delay:e,duration:e,complete:t}):this}},animation:function(){return function(e,t){var n=void 0!==this.length,r=n?this:[this],i=this._private.cy||this,a=!n,o=!a;if(!i.styleEnabled())return this;var s=i.style();if(e=S({},e,t),0===Object.keys(e).length)return new Fn(r[0],e);switch(void 0===e.duration&&(e.duration=400),e.duration){case"slow":e.duration=600;break;case"fast":e.duration=200}if(o&&(e.style=s.getPropsList(e.style||e.css),e.css=void 0),o&&null!=e.renderedPosition){var l=e.renderedPosition,u=i.pan(),c=i.zoom();e.position=Ue(l,c,u)}if(a&&null!=e.panBy){var h=e.panBy,d=i.pan();e.pan={x:d.x+h.x,y:d.y+h.y}}var p=e.center||e.centre;if(a&&null!=p){var f=i.getCenterPan(p.eles,e.zoom);null!=f&&(e.pan=f)}if(a&&null!=e.fit){var g=e.fit,v=i.getFitViewport(g.eles||g.boundingBox,g.padding);null!=v&&(e.pan=v.pan,e.zoom=v.zoom)}if(a&&B(e.zoom)){var y=i.getZoomedViewport(e.zoom);null!=y&&(y.zoomed&&(e.zoom=y.zoom),y.panned&&(e.pan=y.pan))}return new Fn(r[0],e)}},animate:function(){return function(e,t){var n=void 0!==this.length?this:[this];if(!(this._private.cy||this).styleEnabled())return this;t&&(e=S({},e,t));for(var r=0;r<n.length;r++){var i=n[r],a=i.animated()&&(void 0===e.queue||e.queue);i.animation(e,a?{queue:!0}:void 0).play()}return this}},stop:function(){return function(e,t){var n=void 0!==this.length?this:[this],r=this._private.cy||this;if(!r.styleEnabled())return this;for(var i=0;i<n.length;i++){for(var a=n[i]._private,o=a.animation.current,s=0;s<o.length;s++){var l=o[s]._private;t&&(l.duration=0)}e&&(a.animation.queue=[]),t||(a.animation.current=[])}return r.notify("draw"),this}}},{data:function(C){return C=S({},{field:"data",bindingEvent:"data",allowBinding:!1,allowSetting:!1,allowGetting:!1,settingEvent:"data",settingTriggersEvent:!1,triggerFnName:"trigger",immutableKeys:{},updateStyle:!1,beforeGet:function(e){},beforeSet:function(e,t){},onSet:function(e){},canSet:function(e){return!0}},C),function(e,t){var n,r,i,a=C,o=this,s=void 0!==o.length,l=s?o:[o],u=s?o[0]:o;if(K(e)){var c;if(a.allowGetting&&void 0===t)return u&&(a.beforeGet(u),c=u._private[a.field][e]),c;if(a.allowSetting&&void 0!==t&&!a.immutableKeys[e]){var h=(i=t,(r=e)in(n={})?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,n);a.beforeSet(o,h);for(var d=0,p=l.length;d<p;d++){var f=l[d];a.canSet(f)&&(f._private[a.field][e]=t)}a.updateStyle&&o.updateStyle(),a.onSet(o),a.settingTriggersEvent&&o[a.triggerFnName](a.settingEvent)}}else if(a.allowSetting&&B(e)){var g,v,y=e,m=Object.keys(y);a.beforeSet(o,y);for(var b=0;b<m.length;b++){if(v=y[g=m[b]],!a.immutableKeys[g])for(var x=0;x<l.length;x++){var w=l[x];a.canSet(w)&&(w._private[a.field][g]=v)}}a.updateStyle&&o.updateStyle(),a.onSet(o),a.settingTriggersEvent&&o[a.triggerFnName](a.settingEvent)}else if(a.allowBinding&&X(e)){var E=e;o.on(a.bindingEvent,E)}else if(a.allowGetting&&void 0===e){var k;return u&&(a.beforeGet(u),k=u._private[a.field]),k}return o}},removeData:function(v){return v=S({},{field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!1,immutableKeys:{}},v),function(e){var t=v,n=this,r=void 0!==n.length?n:[n];if(K(e)){for(var i=e.split(/\s+/),a=i.length,o=0;o<a;o++){var s=i[o];if(!L(s))if(!t.immutableKeys[s])for(var l=0,u=r.length;l<u;l++)r[l]._private[t.field][s]=void 0}t.triggerEvent&&n[t.triggerFnName](t.event)}else if(void 0===e){for(var c=0,h=r.length;c<h;c++)for(var d=r[c]._private[t.field],p=Object.keys(d),f=0;f<p.length;f++){var g=p[f];!t.immutableKeys[g]&&(d[g]=void 0)}t.triggerEvent&&n[t.triggerFnName](t.event)}return n}}},{eventAliasesOn:function(e){var t=e;t.addListener=t.listen=t.bind=t.on,t.unlisten=t.unbind=t.off=t.removeListener,t.trigger=t.emit,t.pon=t.promiseOn=function(e,t){var i=this,a=Array.prototype.slice.call(arguments,0);return new Rn(function(t,e){var n=a.concat([function(e){i.off.apply(i,r),t(e)}]),r=n.concat([]);i.on.apply(i,n)})}}}].forEach(function(e){S(qn,e)});var Yn={animate:qn.animate(),animation:qn.animation(),animated:qn.animated(),clearQueue:qn.clearQueue(),delay:qn.delay(),delayAnimation:qn.delayAnimation(),stop:qn.stop()},Xn={classes:function(e){G(e)||(e=(e||"").match(/\S+/g)||[]);for(var t=[],n=new _e(e),r=0;r<this.length;r++){for(var i=this[r],a=i._private,o=a.classes,s=!1,l=0;l<e.length;l++){var u=e[l];if(!o.has(u)){s=!0;break}}s||(s=o.size!==e.length),s&&(a.classes=n,t.push(i))}return 0<t.length&&this.spawn(t).updateStyle().emit("class"),this},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return null!=t&&t._private.classes.has(e)},toggleClass:function(e,t){G(e)||(e=e.match(/\S+/g)||[]);for(var n=void 0===t,r=[],i=0,a=this.length;i<a;i++)for(var o=this[i],s=o._private.classes,l=!1,u=0;u<e.length;u++){var c=e[u],h=s.has(c),d=!1;t||n&&!h?(s.add(c),d=!0):(!t||n&&h)&&(s.delete(c),d=!0),!l&&d&&(r.push(o),l=!0)}return 0<r.length&&this.spawn(r).updateStyle().emit("class"),this},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var n=this;if(null==t)t=250;else if(0===t)return n;return n.addClass(e),setTimeout(function(){n.removeClass(e)},t),n}},jn={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:'"(?:\\\\"|[^"])*"|'+"'(?:\\\\'|[^'])*'",number:W,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};jn.variable="(?:[\\w-]|(?:\\\\"+jn.metaChar+"))+",jn.value=jn.string+"|"+jn.number,jn.className=jn.variable,jn.id=jn.variable,function(){var e,t,n;for(e=jn.comparatorOp.split("|"),n=0;n<e.length;n++)t=e[n],jn.comparatorOp+="|@"+t;for(e=jn.comparatorOp.split("|"),n=0;n<e.length;n++)0<=(t=e[n]).indexOf("!")||"="!==t&&(jn.comparatorOp+="|\\!"+t)}();var Wn=0,Hn=1,Kn=2,Gn=3,Zn=4,Un=5,$n=6,Qn=7,Jn=8,er=9,tr=10,nr=11,rr=12,ir=13,ar=14,or=15,sr=16,lr=17,ur=18,cr=19,hr=20,dr=[{selector:":selected",matches:function(e){return e.selected()}},{selector:":unselected",matches:function(e){return!e.selected()}},{selector:":selectable",matches:function(e){return e.selectable()}},{selector:":unselectable",matches:function(e){return!e.selectable()}},{selector:":locked",matches:function(e){return e.locked()}},{selector:":unlocked",matches:function(e){return!e.locked()}},{selector:":visible",matches:function(e){return e.visible()}},{selector:":hidden",matches:function(e){return!e.visible()}},{selector:":transparent",matches:function(e){return e.transparent()}},{selector:":grabbed",matches:function(e){return e.grabbed()}},{selector:":free",matches:function(e){return!e.grabbed()}},{selector:":removed",matches:function(e){return e.removed()}},{selector:":inside",matches:function(e){return!e.removed()}},{selector:":grabbable",matches:function(e){return e.grabbable()}},{selector:":ungrabbable",matches:function(e){return!e.grabbable()}},{selector:":animated",matches:function(e){return e.animated()}},{selector:":unanimated",matches:function(e){return!e.animated()}},{selector:":parent",matches:function(e){return e.isParent()}},{selector:":childless",matches:function(e){return e.isChildless()}},{selector:":child",matches:function(e){return e.isChild()}},{selector:":orphan",matches:function(e){return e.isOrphan()}},{selector:":nonorphan",matches:function(e){return e.isChild()}},{selector:":compound",matches:function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()}},{selector:":loop",matches:function(e){return e.isLoop()}},{selector:":simple",matches:function(e){return e.isSimple()}},{selector:":active",matches:function(e){return e.active()}},{selector:":inactive",matches:function(e){return!e.active()}},{selector:":backgrounding",matches:function(e){return e.backgrounding()}},{selector:":nonbackgrounding",matches:function(e){return!e.backgrounding()}}].sort(function(e,t){return n=e.selector,r=t.selector,-1*U(n,r);var n,r}),pr=function(){for(var e,t={},n=0;n<dr.length;n++)t[(e=dr[n]).selector]=e.matches;return t}(),fr="("+dr.map(function(e){return e.selector}).join("|")+")",gr=function(e){return e.replace(new RegExp("\\\\("+jn.metaChar+")","g"),function(e,t){return t})},vr=function(e,t,n){e[e.length-1]=n},yr=[{name:"group",query:!0,regex:"("+jn.group+")",populate:function(e,t,n){var r=s(n,1)[0];t.checks.push({type:Wn,value:"*"===r?r:r+"s"})}},{name:"state",query:!0,regex:fr,populate:function(e,t,n){var r=s(n,1)[0];t.checks.push({type:Qn,value:r})}},{name:"id",query:!0,regex:"\\#("+jn.id+")",populate:function(e,t,n){var r=s(n,1)[0];t.checks.push({type:Jn,value:gr(r)})}},{name:"className",query:!0,regex:"\\.("+jn.className+")",populate:function(e,t,n){var r=s(n,1)[0];t.checks.push({type:er,value:gr(r)})}},{name:"dataExists",query:!0,regex:"\\[\\s*("+jn.variable+")\\s*\\]",populate:function(e,t,n){var r=s(n,1)[0];t.checks.push({type:Zn,field:gr(r)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+jn.variable+")\\s*("+jn.comparatorOp+")\\s*("+jn.value+")\\s*\\]",populate:function(e,t,n){var r=s(n,3),i=r[0],a=r[1],o=r[2];o=null!=new RegExp("^"+jn.string+"$").exec(o)?o.substring(1,o.length-1):parseFloat(o),t.checks.push({type:Gn,field:gr(i),operator:a,value:o})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+jn.boolOp+")\\s*("+jn.variable+")\\s*\\]",populate:function(e,t,n){var r=s(n,2),i=r[0],a=r[1];t.checks.push({type:Un,field:gr(a),operator:i})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+jn.meta+")\\s*("+jn.comparatorOp+")\\s*("+jn.number+")\\s*\\]\\]",populate:function(e,t,n){var r=s(n,3),i=r[0],a=r[1],o=r[2];t.checks.push({type:$n,field:gr(i),operator:a,value:parseFloat(o)})}},{name:"nextQuery",separator:!0,regex:jn.separator,populate:function(e,t){var n=e.currentSubject,r=e.edgeCount,i=e.compoundCount,a=e[e.length-1];return null!=n&&(a.subject=n,e.currentSubject=null),a.edgeCount=r,a.compoundCount=i,e.edgeCount=0,e.compoundCount=0,e[e.length++]={checks:[]}}},{name:"directedEdge",separator:!0,regex:jn.directedEdge,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r=t,i={checks:[]};return n.checks.push({type:nr,source:r,target:i}),vr(e,0,n),e.edgeCount++,i}var a={checks:[]},o=t,s={checks:[]};return a.checks.push({type:rr,source:o,target:s}),vr(e,0,a),e.edgeCount++,s}},{name:"undirectedEdge",separator:!0,regex:jn.undirectedEdge,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r=t,i={checks:[]};return n.checks.push({type:tr,nodes:[r,i]}),vr(e,0,n),e.edgeCount++,i}var a={checks:[]},o=t,s={checks:[]};return a.checks.push({type:ar,node:o,neighbor:s}),vr(e,0,a),s}},{name:"child",separator:!0,regex:jn.child,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r={checks:[]},i=e[e.length-1];return n.checks.push({type:or,parent:i,child:r}),vr(e,0,n),e.compoundCount++,r}if(e.currentSubject===t){var a={checks:[]},o=e[e.length-1],s={checks:[]},l={checks:[]},u={checks:[]},c={checks:[]};return a.checks.push({type:cr,left:o,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:hr}],c.checks.push({type:hr}),s.checks.push({type:lr,parent:c,child:u}),vr(e,0,a),e.currentSubject=l,e.compoundCount++,u}var h={checks:[]},d={checks:[]},p=[{type:lr,parent:h,child:d}];return h.checks=t.checks,t.checks=p,e.compoundCount++,d}},{name:"descendant",separator:!0,regex:jn.descendant,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r={checks:[]},i=e[e.length-1];return n.checks.push({type:sr,ancestor:i,descendant:r}),vr(e,0,n),e.compoundCount++,r}if(e.currentSubject===t){var a={checks:[]},o=e[e.length-1],s={checks:[]},l={checks:[]},u={checks:[]},c={checks:[]};return a.checks.push({type:cr,left:o,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:hr}],c.checks.push({type:hr}),s.checks.push({type:ur,ancestor:c,descendant:u}),vr(e,0,a),e.currentSubject=l,e.compoundCount++,u}var h={checks:[]},d={checks:[]},p=[{type:ur,ancestor:h,descendant:d}];return h.checks=t.checks,t.checks=p,e.compoundCount++,d}},{name:"subject",modifier:!0,regex:jn.subject,populate:function(e,t){if(null!=e.currentSubject&&e.currentSubject!==t)return be("Redefinition of subject in selector `"+e.toString()+"`"),!1;e.currentSubject=t;var n=e[e.length-1].checks[0],r=null==n?null:n.type;r===nr?n.type=ir:r===tr&&(n.type=ar,n.node=n.nodes[1],n.neighbor=n.nodes[0],n.nodes=null)}}];yr.forEach(function(e){return e.regexObj=new RegExp("^"+e.regex)});var mr=function(e){for(var t,n,r,i=0;i<yr.length;i++){var a=yr[i],o=a.name,s=e.match(a.regexObj);if(null!=s){t=a,r=o;var l=(n=s)[0];e=e.substring(l.length);break}}return{expr:t,match:n,name:r,remaining:e}},br={parse:function(e){var t=this,n=t.inputText=e,r=t[0]={checks:[]};for(t.length=1,n=function(e){var t=e.match(/^\s+/);if(t){var n=t[0];e=e.substring(n.length)}return e}(n);;){var i=mr(n);if(null==i.expr)return be("The selector `"+e+"`is invalid"),!1;var a=i.match.slice(1),o=i.expr.populate(t,r,a);if(!1===o)return!1;if(null!=o&&(r=o),(n=i.remaining).match(/^\s*$/))break}var s=t[t.length-1];null!=t.currentSubject&&(s.subject=t.currentSubject),s.edgeCount=t.edgeCount,s.compoundCount=t.compoundCount;for(var l=0;l<t.length;l++){var u=t[l];if(0<u.compoundCount&&0<u.edgeCount)return be("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(1<u.edgeCount)return be("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===u.edgeCount&&be("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},toString:function(){if(null!=this.toStringCache)return this.toStringCache;for(var p=function(e){return null==e?"":e},f=function(e){return K(e)?'"'+e+'"':p(e)},g=function(e){return" "+e+" "},v=function(r,i){return r.checks.reduce(function(e,t,n){return e+(i===r&&0===n?"$":"")+function(e,t){var n=e.type,r=e.value;switch(n){case Wn:var i=p(r);return i.substring(0,i.length-1);case Gn:var a=e.field,o=e.operator;return"["+a+g(p(o))+f(r)+"]";case Un:var s=e.operator,l=e.field;return"["+p(s)+l+"]";case Zn:return"["+e.field+"]";case $n:var u=e.operator;return"[["+e.field+g(p(u))+f(r)+"]]";case Qn:return r;case Jn:return"#"+r;case er:return"."+r;case lr:case or:return v(e.parent,t)+g(">")+v(e.child,t);case ur:case sr:return v(e.ancestor,t)+" "+v(e.descendant,t);case cr:var c=v(e.left,t),h=v(e.subject,t),d=v(e.right,t);return c+(0<c.length?" ":"")+h+d;case hr:return""}}(t,i)},"")},e="",t=0;t<this.length;t++){var n=this[t];e+=v(n,n.subject),1<this.length&&t<this.length-1&&(e+=", ")}return this.toStringCache=e}},xr=function(e,t,n){var r,i,a,o=K(e),s=$t(e),l=K(n),u=!1,c=!1,h=!1;switch(0<=t.indexOf("!")&&(t=t.replace("!",""),c=!0),0<=t.indexOf("@")&&(t=t.replace("@",""),u=!0),(o||l||u)&&(i=o||s?""+e:"",a=""+n),u&&(e=i=i.toLowerCase(),n=a=a.toLowerCase()),t){case"*=":r=0<=i.indexOf(a);break;case"$=":r=0<=i.indexOf(a,i.length-a.length);break;case"^=":r=0===i.indexOf(a);break;case"=":r=e===n;break;case">":h=!0,r=n<e;break;case">=":h=!0,r=n<=e;break;case"<":h=!0,r=e<n;break;case"<=":h=!0,r=e<=n;break;default:r=!1}return!c||null==e&&h||(r=!r),r},wr=function(e,t){return e.data(t)},Er=[],kr=function(e,t){return e.checks.every(function(e){return Er[e.type](e,t)})};Er[Wn]=function(e,t){var n=e.value;return"*"===n||n===t.group()},Er[Qn]=function(e,t){var n,r=e.value;return n=t,pr[r](n)},Er[Jn]=function(e,t){var n=e.value;return t.id()===n},Er[er]=function(e,t){var n=e.value;return t.hasClass(n)},Er[$n]=function(e,t){var n=e.field,r=e.operator,i=e.value;return xr(t[n](),r,i)},Er[Gn]=function(e,t){var n=e.field,r=e.operator,i=e.value;return xr(wr(t,n),r,i)},Er[Un]=function(e,t){var n=e.field,r=e.operator;return function(e,t){switch(t){case"?":return!!e;case"!":return!e;case"^":return void 0===e}}(wr(t,n),r)},Er[Zn]=function(e,t){var n=e.field;e.operator;return void 0!==wr(t,n)},Er[tr]=function(e,t){var n=e.nodes[0],r=e.nodes[1],i=t.source(),a=t.target();return kr(n,i)&&kr(r,a)||kr(r,i)&&kr(n,a)},Er[ar]=function(t,e){return kr(t.node,e)&&e.neighborhood().some(function(e){return e.isNode()&&kr(t.neighbor,e)})},Er[nr]=function(e,t){return kr(e.source,t.source())&&kr(e.target,t.target())},Er[rr]=function(t,e){return kr(t.source,e)&&e.outgoers().some(function(e){return e.isNode()&&kr(t.target,e)})},Er[ir]=function(t,e){return kr(t.target,e)&&e.incomers().some(function(e){return e.isNode()&&kr(t.source,e)})},Er[or]=function(e,t){return kr(e.child,t)&&kr(e.parent,t.parent())},Er[lr]=function(t,e){return kr(t.parent,e)&&e.children().some(function(e){return kr(t.child,e)})},Er[sr]=function(t,e){return kr(t.descendant,e)&&e.ancestors().some(function(e){return kr(t.ancestor,e)})},Er[ur]=function(t,e){return kr(t.ancestor,e)&&e.descendants().some(function(e){return kr(t.descendant,e)})},Er[cr]=function(e,t){return kr(e.subject,t)&&kr(e.left,t)&&kr(e.right,t)},Er[hr]=function(){return!0},Er[Hn]=function(e,t){return e.value.has(t)},Er[Kn]=function(e,t){return(0,e.value)(t)};var Cr=function(e){this.inputText=e,this.currentSubject=null,this.compoundCount=0,this.edgeCount=0,this.length=0,null==e||K(e)&&e.match(/^\s*$/)||(Z(e)?this.addQuery({checks:[{type:Hn,value:e.collection()}]}):X(e)?this.addQuery({checks:[{type:Kn,value:e}]}):K(e)?this.parse(e)||(this.invalid=!0):me("A selector must be created from a string; found "))},Sr=Cr.prototype;[br,{matches:function(e){for(var t=0;t<this.length;t++){var n=this[t];if(kr(n,e))return!0}return!1},filter:function(e){var r=this;if(1===r.length&&1===r[0].checks.length&&r[0].checks[0].type===Jn)return e.getElementById(r[0].checks[0].value).collection();var t=function(e){for(var t=0;t<r.length;t++){var n=r[t];if(kr(n,e))return!0}return!1};return null==r.text()&&(t=function(){return!0}),e.filter(t)}}].forEach(function(e){return S(Sr,e)}),Sr.text=function(){return this.inputText},Sr.size=function(){return this.length},Sr.eq=function(e){return this[e]},Sr.sameText=function(e){return!this.invalid&&!e.invalid&&this.text()===e.text()},Sr.addQuery=function(e){this[this.length++]=e},Sr.selector=Sr.toString;var Dr={allAre:function(e){var t=new Cr(e);return this.every(function(e){return t.matches(e)})},is:function(e){var t=new Cr(e);return this.some(function(e){return t.matches(e)})},some:function(e,t){for(var n=0;n<this.length;n++){if(t?e.apply(t,[this[n],n,this]):e(this[n],n,this))return!0}return!1},every:function(e,t){for(var n=0;n<this.length;n++){if(!(t?e.apply(t,[this[n],n,this]):e(this[n],n,this)))return!1}return!0},same:function(t){if(this===t)return!0;t=this.cy().collection(t);var e=this.length;return e===t.length&&(1===e?this[0]===t[0]:this.every(function(e){return t.hasElementWithId(e.id())}))},anySame:function(t){return t=this.cy().collection(t),this.some(function(e){return t.hasElementWithId(e.id())})},allAreNeighbors:function(e){e=this.cy().collection(e);var t=this.neighborhood();return e.every(function(e){return t.hasElementWithId(e.id())})},contains:function(e){e=this.cy().collection(e);var t=this;return e.every(function(e){return t.hasElementWithId(e.id())})}};Dr.allAreNeighbours=Dr.allAreNeighbors,Dr.has=Dr.contains,Dr.equal=Dr.equals=Dr.same;var Tr,Pr,Mr=function(h,d){return function(e,t,n,r){var i,a=e;if(null==a?i="":Z(a)&&1===a.length&&(i=a.id()),1===this.length&&i){var o=this[0]._private,s=o.traversalCache=o.traversalCache||{},l=s[d]=s[d]||[],u=le(i),c=l[u];return c||(l[u]=h.call(this,e,t,n,r))}return h.call(this,e,t,n,r)}},_r={parent:function(e){var t=[];if(1===this.length){var n=this[0]._private.parent;if(n)return n}for(var r=0;r<this.length;r++){var i=this[r]._private.parent;i&&t.push(i)}return this.spawn(t,{unique:!0}).filter(e)},parents:function(e){for(var t=[],n=this.parent();n.nonempty();){for(var r=0;r<n.length;r++){var i=n[r];t.push(i)}n=n.parent()}return this.spawn(t,{unique:!0}).filter(e)},commonAncestors:function(e){for(var t,n=0;n<this.length;n++){var r=this[n].parents();t=(t=t||r).intersect(r)}return t.filter(e)},orphans:function(e){return this.stdFilter(function(e){return e.isOrphan()}).filter(e)},nonorphans:function(e){return this.stdFilter(function(e){return e.isChild()}).filter(e)},children:Mr(function(e){for(var t=[],n=0;n<this.length;n++)for(var r=this[n]._private.children,i=0;i<r.length;i++)t.push(r[i]);return this.spawn(t,{unique:!0}).filter(e)},"children"),siblings:function(e){return this.parent().children().not(this).filter(e)},isParent:function(){var e=this[0];if(e)return e.isNode()&&0!==e._private.children.length},isChildless:function(){var e=this[0];if(e)return e.isNode()&&0===e._private.children.length},isChild:function(){var e=this[0];if(e)return e.isNode()&&null!=e._private.parent},isOrphan:function(){var e=this[0];if(e)return e.isNode()&&null==e._private.parent},descendants:function(e){var i=[];return function e(t){for(var n=0;n<t.length;n++){var r=t[n];i.push(r),r.children().nonempty()&&e(r.children())}}(this.children()),this.spawn(i,{unique:!0}).filter(e)}};function Br(e,t,n,r){for(var i=[],a=new _e,o=e.cy().hasCompoundNodes(),s=0;s<e.length;s++){var l=e[s];n?i.push(l):o&&r(i,a,l)}for(;0<i.length;){var u=i.shift();t(u),a.add(u.id()),o&&r(i,a,u)}return e}function Nr(e,t,n){if(n.isParent())for(var r=n._private.children,i=0;i<r.length;i++){var a=r[i];t.has(a.id())||e.push(a)}}function Ir(e,t,n){if(n.isChild()){var r=n._private.parent;t.has(r.id())||e.push(r)}}function Ar(e,t,n){Ir(e,t,n),Nr(e,t,n)}_r.forEachDown=function(e){return Br(this,e,!(1<arguments.length&&void 0!==arguments[1])||arguments[1],Nr)},_r.forEachUp=function(e){return Br(this,e,!(1<arguments.length&&void 0!==arguments[1])||arguments[1],Ir)},_r.forEachUpAndDown=function(e){return Br(this,e,!(1<arguments.length&&void 0!==arguments[1])||arguments[1],Ar)},_r.ancestors=_r.parents,(Tr=Pr={data:qn.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:qn.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:qn.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:qn.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:qn.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:qn.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}}).attr=Tr.data,Tr.removeAttr=Tr.removeData;var Lr,zr,Or=Pr,Rr={};function Fr(o){return function(e){if(void 0===e&&(e=!0),0!==this.length&&this.isNode()&&!this.removed()){for(var t=0,n=this[0],r=n._private.edges,i=0;i<r.length;i++){var a=r[i];!e&&a.isLoop()||(t+=o(n,a))}return t}}}function Vr(a,o){return function(e){for(var t,n=this.nodes(),r=0;r<n.length;r++){var i=n[r][a](e);void 0===i||void 0!==t&&!o(i,t)||(t=i)}return t}}S(Rr,{degree:Fr(function(e,t){return t.source().same(t.target())?2:1}),indegree:Fr(function(e,t){return t.target().same(e)?1:0}),outdegree:Fr(function(e,t){return t.source().same(e)?1:0})}),S(Rr,{minDegree:Vr("degree",function(e,t){return e<t}),maxDegree:Vr("degree",function(e,t){return t<e}),minIndegree:Vr("indegree",function(e,t){return e<t}),maxIndegree:Vr("indegree",function(e,t){return t<e}),minOutdegree:Vr("outdegree",function(e,t){return e<t}),maxOutdegree:Vr("outdegree",function(e,t){return t<e})}),S(Rr,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r<n.length;r++)t+=n[r].degree(e);return t}});var qr=function(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(!i.locked()){var a=i._private.position,o={x:null!=t.x?t.x-a.x:0,y:null!=t.y?t.y-a.y:0};!i.isParent()||0===o.x&&0===o.y||i.children().shift(o,n),i.shiftCachedBoundingBox(o)}}},Yr={field:"position",bindingEvent:"position",allowBinding:!0,allowSetting:!0,settingEvent:"position",settingTriggersEvent:!0,triggerFnName:"emitAndNotify",allowGetting:!0,validKeys:["x","y"],beforeGet:function(e){e.updateCompoundBounds()},beforeSet:function(e,t){qr(e,t,!1)},onSet:function(e){e.dirtyCompoundBoundsCache()},canSet:function(e){return!e.locked()}};(Lr=zr={position:qn.data(Yr),silentPosition:qn.data(S({},Yr,{allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!1,beforeSet:function(e,t){qr(e,t,!0)}})),positions:function(e,t){if(B(e))t?this.silentPosition(e):this.position(e);else if(X(e)){var n=e,r=this.cy();r.startBatch();for(var i=0;i<this.length;i++){var a,o=this[i];(a=n(o,i))&&(t?o.silentPosition(a):o.position(a))}r.endBatch()}return this},silentPositions:function(e){return this.positions(e,!0)},shift:function(e,t,n){var r;if(B(e)?(r=e,n=t):K(e)&&$t(t)&&((r={x:0,y:0})[e]=t),null!=r){var i=this.cy();i.startBatch();for(var a=0;a<this.length;a++){var o=this[a],s=o.position(),l={x:s.x+r.x,y:s.y+r.y};n?o.silentPosition(l):o.position(l)}i.endBatch()}return this},silentShift:function(e,t){return B(e)?this.shift(e,!0):K(e)&&$t(t)&&this.shift(e,t,!0),this},renderedPosition:function(e,t){var n=this[0],r=this.cy(),i=r.zoom(),a=r.pan(),o=B(e)?e:void 0,s=void 0!==o||void 0!==t&&K(e);if(n&&n.isNode()){if(!s){var l=n.position();return o=Ze(l,i,a),void 0===e?o:o[e]}for(var u=0;u<this.length;u++){var c=this[u];void 0!==t?c.position(e,(t-a[e])/i):void 0!==o&&c.position(Ue(o,i,a))}}else if(!s)return;return this},relativePosition:function(e,t){var n=this[0],r=this.cy(),i=B(e)?e:void 0,a=void 0!==i||void 0!==t&&K(e),o=r.hasCompoundNodes();if(n&&n.isNode()){if(!a){var s=n.position(),l=o?n.parent():null,u=l&&0<l.length,c=u;u&&(l=l[0]);var h=c?l.position():{x:0,y:0};return i={x:s.x-h.x,y:s.y-h.y},void 0===e?i:i[e]}for(var d=0;d<this.length;d++){var p=this[d],f=o?p.parent():null,g=f&&0<f.length,v=g;g&&(f=f[0]);var y=v?f.position():{x:0,y:0};void 0!==t?p.position(e,t+y[e]):void 0!==i&&p.position({x:i.x+y.x,y:i.y+y.y})}}else if(!a)return;return this}}).modelPosition=Lr.point=Lr.position,Lr.modelPositions=Lr.points=Lr.positions,Lr.renderedPoint=Lr.renderedPosition,Lr.relativePoint=Lr.relativePosition;var Xr,jr,Wr=zr;Xr=jr={},jr.renderedBoundingBox=function(e){var t=this.boundingBox(e),n=this.cy(),r=n.zoom(),i=n.pan(),a=t.x1*r+i.x,o=t.x2*r+i.x,s=t.y1*r+i.y,l=t.y2*r+i.y;return{x1:a,x2:o,y1:s,y2:l,w:o-a,h:l-s}},jr.dirtyCompoundBoundsCache=function(){var e=this.cy();return e.styleEnabled()&&e.hasCompoundNodes()&&this.forEachUp(function(e){if(e.isParent()){var t=e._private;t.compoundBoundsClean=!1,t.bbCache=null,e.emitAndNotify("bounds")}}),this},jr.updateCompoundBounds=function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=this.cy();if(!t.styleEnabled()||!t.hasCompoundNodes())return this;if(!e&&t.batching())return this;function n(e){if(e.isParent()){var t=e._private,n=e.children(),r="include"===e.pstyle("compound-sizing-wrt-labels").value,i={width:{val:e.pstyle("min-width").pfValue,left:e.pstyle("min-width-bias-left"),right:e.pstyle("min-width-bias-right")},height:{val:e.pstyle("min-height").pfValue,top:e.pstyle("min-height-bias-top"),bottom:e.pstyle("min-height-bias-bottom")}},a=n.boundingBox({includeLabels:r,includeOverlays:!1,useCache:!1}),o=t.position;0!==a.w&&0!==a.h||((a={w:e.pstyle("width").pfValue,h:e.pstyle("height").pfValue}).x1=o.x-a.w/2,a.x2=o.x+a.w/2,a.y1=o.y-a.h/2,a.y2=o.y+a.h/2);var s=i.width.left.value;"px"===i.width.left.units&&0<i.width.val&&(s=100*s/i.width.val);var l=i.width.right.value;"px"===i.width.right.units&&0<i.width.val&&(l=100*l/i.width.val);var u=i.height.top.value;"px"===i.height.top.units&&0<i.height.val&&(u=100*u/i.height.val);var c=i.height.bottom.value;"px"===i.height.bottom.units&&0<i.height.val&&(c=100*c/i.height.val);var h=y(i.width.val-a.w,s,l),d=h.biasDiff,p=h.biasComplementDiff,f=y(i.height.val-a.h,u,c),g=f.biasDiff,v=f.biasComplementDiff;t.autoPadding=function(e,t,n,r){if("%"!==n.units)return"px"===n.units?n.pfValue:0;switch(r){case"width":return 0<e?n.pfValue*e:0;case"height":return 0<t?n.pfValue*t:0;case"average":return 0<e&&0<t?n.pfValue*(e+t)/2:0;case"min":return 0<e&&0<t?t<e?n.pfValue*t:n.pfValue*e:0;case"max":return 0<e&&0<t?t<e?n.pfValue*e:n.pfValue*t:0;default:return 0}}(a.w,a.h,e.pstyle("padding"),e.pstyle("padding-relative-to").value),t.autoWidth=Math.max(a.w,i.width.val),o.x=(-d+a.x1+a.x2+p)/2,t.autoHeight=Math.max(a.h,i.height.val),o.y=(-g+a.y1+a.y2+v)/2}function y(e,t,n){var r=0,i=0,a=t+n;return 0<e&&0<a&&(r=t/a*e,i=n/a*e),{biasDiff:r,biasComplementDiff:i}}}for(var r=0;r<this.length;r++){var i=this[r],a=i._private;a.compoundBoundsClean||(n(i),t.batching()||(a.compoundBoundsClean=!0))}return this};var Hr=function(e){return e===1/0||e===-1/0?0:e},Kr=function(e,t,n,r,i){r-t!=0&&i-n!=0&&null!=t&&null!=n&&null!=r&&null!=i&&(e.x1=t<e.x1?t:e.x1,e.x2=r>e.x2?r:e.x2,e.y1=n<e.y1?n:e.y1,e.y2=i>e.y2?i:e.y2)},Gr=function(e,t){return Kr(e,t.x1,t.y1,t.x2,t.y2)},Zr=function(e,t,n){return De(e,t,n)},Ur=function(e,t,n){if(!t.cy().headless()){var r,i,a=t._private,o=a.rstyle,s=o.arrowWidth/2;if("none"!==t.pstyle(n+"-arrow-shape").value){i="source"===n?(r=o.srcX,o.srcY):"target"===n?(r=o.tgtX,o.tgtY):(r=o.midX,o.midY);var l=a.arrowBounds=a.arrowBounds||{},u=l[n]=l[n]||{};u.x1=r-s,u.y1=i-s,u.x2=r+s,u.y2=i+s,u.w=u.x2-u.x1,u.h=u.y2-u.y1,ot(u,1),Kr(e,u.x1,u.y1,u.x2,u.y2)}}},$r=function(e,t,n){if(!t.cy().headless()){var r;r=n?n+"-":"";var i=t._private,a=i.rstyle;if(t.pstyle(r+"label").strValue){var o,s,l,u,c=t.pstyle("text-halign"),h=t.pstyle("text-valign"),d=Zr(a,"labelWidth",n),p=Zr(a,"labelHeight",n),f=Zr(a,"labelX",n),g=Zr(a,"labelY",n),v=t.pstyle(r+"text-margin-x").pfValue,y=t.pstyle(r+"text-margin-y").pfValue,m=t.isEdge(),b=t.pstyle(r+"text-rotation"),x=t.pstyle("text-outline-width").pfValue,w=t.pstyle("text-border-width").pfValue/2,E=t.pstyle("text-background-padding").pfValue,k=p+2*E,C=d+2*E,S=C/2,D=k/2;if(m)o=f-S,s=f+S,l=g-D,u=g+D;else{switch(c.value){case"left":o=f-C,s=f;break;case"center":o=f-S,s=f+S;break;case"right":s=(o=f)+C}switch(h.value){case"top":l=g-k,u=g;break;case"center":l=g-D,u=g+D;break;case"bottom":u=(l=g)+k}}o+=v-Math.max(x,w),s+=v+Math.max(x,w),l+=y-Math.max(x,w),u+=y+Math.max(x,w);var T=n||"main",P=i.labelBounds,M=P[T]=P[T]||{};M.x1=o,M.y1=l,M.x2=s,M.y2=u,M.w=s-o,M.h=u-l,ot(M,1);var _=m&&"autorotate"===b.strValue,B=null!=b.pfValue&&0!==b.pfValue;if(_||B){var N=_?Zr(i.rstyle,"labelAngle",n):b.pfValue,I=Math.cos(N),A=Math.sin(N),L=(o+s)/2,z=(l+u)/2;if(!m){switch(c.value){case"left":L=s;break;case"right":L=o}switch(h.value){case"top":z=u;break;case"bottom":z=l}}var O=function(e,t){return{x:(e-=L)*I-(t-=z)*A+L,y:e*A+t*I+z}},R=O(o,l),F=O(o,u),V=O(s,l),q=O(s,u);o=Math.min(R.x,F.x,V.x,q.x),s=Math.max(R.x,F.x,V.x,q.x),l=Math.min(R.y,F.y,V.y,q.y),u=Math.max(R.y,F.y,V.y,q.y)}Kr(e,o,l,s,u),Kr(i.labelBounds.all,o,l,s,u)}return e}},Qr=function(e){var t=0,n=function(e){return(e?1:0)<<t++},r=0;return r+=n(e.incudeNodes),r+=n(e.includeEdges),r+=n(e.includeLabels),r+=n(e.includeOverlays)},Jr=function(e){if(e.isEdge()){var t=e.source().position(),n=e.target().position(),r=function(e){return Math.round(e)};return se([r(t.x),r(t.y),r(n.x),r(n.y)])}return 0},ei=function(e,t){var n,r=e._private,i=(null==t?ni:Qr(t))===ni,a=Jr(e),o=r.bbCachePosKey===a,s=!(t.useCache&&o)||null==r.bbCache;if(s?(o||e.recalculateRenderedStyle(!1),n=function(e,t){var n,r,i,a,o,s,l,u=e._private.cy,c=u.styleEnabled(),h=u.headless(),d=at(),p=e._private,f=c?e.pstyle("display").value:"element",g=e.isNode(),v=e.isEdge(),y="none"!==f,m=p.rstyle;if(y){var b=0;c&&t.includeOverlays&&0!==e.pstyle("overlay-opacity").value&&(b=e.pstyle("overlay-padding").value);var x=0;if(c&&(x=e.pstyle("width").pfValue/2),g&&t.includeNodes){var w=e.position();o=w.x,s=w.y;var E=e.outerWidth()/2,k=e.outerHeight()/2;Kr(d,n=o-E,i=s-k,r=o+E,a=s+k)}else if(v&&t.includeEdges)if(c&&!h&&(n=Math.min(m.srcX,m.midX,m.tgtX),r=Math.max(m.srcX,m.midX,m.tgtX),i=Math.min(m.srcY,m.midY,m.tgtY),a=Math.max(m.srcY,m.midY,m.tgtY),Kr(d,n-=x,i-=x,r+=x,a+=x)),c&&!h&&"haystack"===e.pstyle("curve-style").strValue){var C=m.haystackPts||[];if(n=C[0].x,i=C[0].y,(r=C[1].x)<n){var S=n;n=r,r=S}if((a=C[1].y)<i){var D=i;i=a,a=D}Kr(d,n-x,i-x,r+x,a+x)}else{for(var T=m.bezierPts||m.linePts||[],P=0;P<T.length;P++){var M=T[P];n=M.x-x,r=M.x+x,i=M.y-x,a=M.y+x,Kr(d,n,i,r,a)}if(0===T.length){var _=e.source().position(),B=e.target().position();if(n=_.x,r=B.x,i=_.y,r<n){var N=n;n=r,r=N}if((a=B.y)<i){var I=i;i=a,a=I}Kr(d,n-=x,i-=x,r+=x,a+=x)}}if(c&&t.includeEdges&&v&&(Ur(d,e,"mid-source"),Ur(d,e,"mid-target"),Ur(d,e,"source"),Ur(d,e,"target")),c&&"yes"===e.pstyle("ghost").value){var A=e.pstyle("ghost-offset-x").pfValue,L=e.pstyle("ghost-offset-y").pfValue;Kr(d,d.x1+A,d.y1+L,d.x2+A,d.y2+L)}var z=p.bodyBounds=p.bodyBounds||{};st(z,d),ot(z,1),c&&(n=d.x1,r=d.x2,i=d.y1,a=d.y2,Kr(d,n-b,i-b,r+b,a+b));var O=p.overlayBounds=p.overlayBounds||{};st(O,d),ot(O,1);var R=p.labelBounds=p.labelBounds||{};if(null!=R.all?((l=R.all).x1=1/0,l.y1=1/0,l.x2=-1/0,l.y2=-1/0,l.w=0,l.h=0):R.all=at(),c&&t.includeLabels){$r(d,e,null),v&&($r(d,e,"source"),$r(d,e,"target"));var F=R.all;F.w=F.x2-F.x1,F.h=F.y2-F.y1}}return d.x1=Hr(d.x1),d.y1=Hr(d.y1),d.x2=Hr(d.x2),d.y2=Hr(d.y2),d.w=Hr(d.x2-d.x1),d.h=Hr(d.y2-d.y1),ot(d,0<d.w&&0<d.h&&y?1:0),d}(e,ti),r.bbCache=n,r.bbCacheShift.x=r.bbCacheShift.y=0,r.bbCachePosKey=a):n=r.bbCache,!s&&(0!==r.bbCacheShift.x||0!==r.bbCacheShift.y)){var l=lt,u=r.bbCacheShift,c=function(e,t){null!=e&&l(e,t)};l(n,u);var h=r.bodyBounds,d=r.overlayBounds,p=r.labelBounds,f=r.arrowBounds;c(h,u),c(d,u),null!=f&&(c(f.source,u),c(f.target,u),c(f["mid-source"],u),c(f["mid-target"],u)),null!=p&&(c(p.main,u),c(p.all,u),c(p.source,u),c(p.target,u))}if(r.bbCacheShift.x=r.bbCacheShift.y=0,!i){var g=e.isNode();n=at(),(t.includeNodes&&g||t.includeEdges&&!g)&&(t.includeOverlays?Gr(n,r.overlayBounds):Gr(n,r.bodyBounds)),t.includeLabels&&Gr(n,r.labelBounds.all),n.w=n.x2-n.x1,n.h=n.y2-n.y1}return n},ti={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeOverlays:!0,useCache:!0},ni=Qr(ti),ri=Ce(ti);jr.boundingBox=function(e){if(1===this.length&&null!=this[0]._private.bbCache&&(void 0===e||void 0===e.useCache||!0===e.useCache))return e=void 0===e?ti:ri(e),ei(this[0],e);var t=at(),n=ri(e=e||ti);if(this.cy().styleEnabled())for(var r=0;r<this.length;r++){var i=this[r],a=i._private,o=Jr(i),s=a.bbCachePosKey===o,l=n.useCache&&s;i.recalculateRenderedStyle(l)}this.updateCompoundBounds();for(var u=0;u<this.length;u++){var c=this[u];Gr(t,ei(c,n))}return t.x1=Hr(t.x1),t.y1=Hr(t.y1),t.x2=Hr(t.x2),t.y2=Hr(t.y2),t.w=Hr(t.x2-t.x1),t.h=Hr(t.y2-t.y1),t},jr.dirtyBoundingBoxCache=function(){for(var e=0;e<this.length;e++){var t=this[e]._private;t.bbCache=null,t.bbCacheShift.x=t.bbCacheShift.y=0,t.bbCachePosKey=null}return this.emitAndNotify("bounds"),this},jr.shiftCachedBoundingBox=function(e){for(var t=0;t<this.length;t++){var n=this[t]._private;null!=n.bbCache&&(n.bbCacheShift.x+=e.x,n.bbCacheShift.y+=e.y)}return this.emitAndNotify("bounds"),this},jr.boundingBoxAt=function(n){var e=this.nodes(),t=this.cy(),r=t.hasCompoundNodes();if(r&&(e=e.filter(function(e){return!e.isParent()})),B(n)){var i=n;n=function(){return i}}t.startBatch(),e.forEach(function(e,t){return e._private.bbAtOldPos=n(e,t)}).silentPositions(n),r&&this.updateCompoundBounds(!0);var a=this.boundingBox({useCache:!1});return e.silentPositions(function(e){return e._private.bbAtOldPos}),t.endBatch(),a},Xr.boundingbox=Xr.bb=Xr.boundingBox,Xr.renderedBoundingbox=Xr.renderedBoundingBox;var ii,ai,oi=jr;ii=ai={};var si=function(i){i.uppercaseName=e(i.name),i.autoName="auto"+i.uppercaseName,i.labelName="label"+i.uppercaseName,i.outerName="outer"+i.uppercaseName,i.uppercaseOuterName=e(i.outerName),ii[i.name]=function(){var e=this[0],t=e._private,n=t.cy._private.styleEnabled;if(e){if(!n)return 1;if(e.isParent())return e.updateCompoundBounds(),t[i.autoName]||0;var r=e.pstyle(i.name);switch(r.strValue){case"label":return e.recalculateRenderedStyle(),t.rstyle[i.labelName]||0;default:return r.pfValue}}},ii["outer"+i.uppercaseName]=function(){var e=this[0],t=e._private.cy._private.styleEnabled;if(e)return t?e[i.name]()+e.pstyle("border-width").pfValue+2*e.padding():1},ii["rendered"+i.uppercaseName]=function(){var e=this[0];if(e)return e[i.name]()*this.cy().zoom()},ii["rendered"+i.uppercaseOuterName]=function(){var e=this[0];if(e)return e[i.outerName]()*this.cy().zoom()}};si({name:"width"}),si({name:"height"}),ai.padding=function(){var e=this[0],t=e._private;return e.isParent()?(e.updateCompoundBounds(),void 0!==t.autoPadding?t.autoPadding:e.pstyle("padding").pfValue):e.pstyle("padding").pfValue};var li=ai,ui={controlPoints:{get:function(e){return e.renderer().getControlPoints(e)},mult:!0},segmentPoints:{get:function(e){return e.renderer().getSegmentPoints(e)},mult:!0},sourceEndpoint:{get:function(e){return e.renderer().getSourceEndpoint(e)}},targetEndpoint:{get:function(e){return e.renderer().getTargetEndpoint(e)}},midpoint:{get:function(e){return e.renderer().getEdgeMidpoint(e)}}},ci=Object.keys(ui).reduce(function(e,t){var n,r=ui[t],i="rendered"+(n=t)[0].toUpperCase()+n.substr(1);return e[t]=function(){return function(e,t){if(e.isEdge())return t(e)}(this,r.get)},r.mult?e[i]=function(){return function(e,t){if(e.isEdge()){var n=e.cy(),r=n.pan(),i=n.zoom();return t(e).map(function(e){return Ze(e,i,r)})}}(this,r.get)}:e[i]=function(){return function(e,t){if(e.isEdge()){var n=e.cy();return Ze(t(e),n.zoom(),n.pan())}}(this,r.get)},e},{}),hi=S({},Wr,oi,li,ci),di=function(e,t){this.recycle(e,t)};function pi(){return!1}function fi(){return!0}di.prototype={instanceString:function(){return"event"},recycle:function(e,t){if(this.isImmediatePropagationStopped=this.isPropagationStopped=this.isDefaultPrevented=pi,null!=e&&e.preventDefault?(this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?fi:pi):null!=e&&e.type?t=e:this.type=e,null!=t&&(this.originalEvent=t.originalEvent,this.type=null!=t.type?t.type:this.type,this.cy=t.cy,this.target=t.target,this.position=t.position,this.renderedPosition=t.renderedPosition,this.namespace=t.namespace,this.layout=t.layout),null!=this.cy&&null!=this.position&&null==this.renderedPosition){var n=this.position,r=this.cy.zoom(),i=this.cy.pan();this.renderedPosition={x:n.x*r+i.x,y:n.y*r+i.y}}this.timeStamp=e&&e.timeStamp||Date.now()},preventDefault:function(){this.isDefaultPrevented=fi;var e=this.originalEvent;e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){this.isPropagationStopped=fi;var e=this.originalEvent;e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=fi,this.stopPropagation()},isDefaultPrevented:pi,isPropagationStopped:pi,isImmediatePropagationStopped:pi};var gi=/^([^.]+)(\.(?:[^.]+))?$/,vi={qualifierCompare:function(e,t){return e===t},eventMatches:function(){return!0},addEventFields:function(){},callbackContext:function(e){return e},beforeEmit:function(){},afterEmit:function(){},bubble:function(){return!1},parent:function(){return null},context:null},yi=Object.keys(vi);function mi(e,t){for(var n=0;n<yi.length;n++){var r=yi[n];this[r]=e[r]||vi[r]}this.context=t||this.context,this.listeners=[],this.emitting=0}var bi=mi.prototype,xi=function(e,t,n,r,i,a,o){X(r)&&(i=r,r=null),o&&(a=null==a?o:S({},a,o));for(var s=n.split(/\s+/),l=0;l<s.length;l++){var u=s[l];if(!L(u)){var c=u.match(gi);if(c)if(!1===t(e,u,c[1],c[2]?c[2]:null,r,i,a))break}}},wi=function(e,t){return e.addEventFields(e.context,t),new di(t.type,t)},Ei=function(e,t,n){if("event"!==u(n))if(B(n))t(e,wi(e,n));else for(var r=n.split(/\s+/),i=0;i<r.length;i++){var a=r[i];if(!L(a)){var o=a.match(gi);if(o){var s=o[1],l=o[2]?o[2]:null;t(e,wi(e,{type:s,namespace:l,target:e.context}))}}}else t(e,n)};bi.on=bi.addListener=function(e,t,n,r,i){return xi(this,function(e,t,n,r,i,a,o){X(a)&&e.listeners.push({event:t,callback:a,type:n,namespace:r,qualifier:i,conf:o})},e,t,n,r,i),this},bi.one=function(e,t,n,r){return this.on(e,t,n,r,{one:!0})},bi.removeListener=bi.off=function(e,t,n,r){var i=this;0!==this.emitting&&(this.listeners=this.listeners.slice());for(var l=this.listeners,a=function(o){var s=l[o];xi(i,function(e,t,n,r,i,a){if(s.type===n&&(!r||s.namespace===r)&&(!i||e.qualifierCompare(s.qualifier,i))&&(!a||s.callback===a))return l.splice(o,1),!1},e,t,n,r)},o=l.length-1;0<=o;o--)a(o);return this},bi.emit=bi.trigger=function(e,s,n){var l=this.listeners,r=l.length;return this.emitting++,G(s)||(s=[s]),Ei(this,function(a,o){null!=n&&(l=[{event:o.event,type:o.type,namespace:o.namespace,callback:n}],r=l.length);for(var e=function(e){var t=l[e];if(t.type===o.type&&(!t.namespace||t.namespace===o.namespace||".*"===t.namespace)&&a.eventMatches(a.context,t,o)){var n=[o];null!=s&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.push(r)}}(n,s),a.beforeEmit(a.context,t,o),t.conf&&t.conf.one&&(a.listeners=a.listeners.filter(function(e){return e!==t}));var r=a.callbackContext(a.context,t,o),i=t.callback.apply(r,n);a.afterEmit(a.context,t,o),!1===i&&(o.stopPropagation(),o.preventDefault())}},t=0;t<r;t++)e(t);a.bubble(a.context)&&!o.isPropagationStopped()&&a.parent(a.context).emit(o,s)},e),this.emitting--,this};var ki={qualifierCompare:function(e,t){return null==e||null==t?null==e&&null==t:e.sameText(t)},eventMatches:function(e,t,n){var r=t.qualifier;return null==r||e!==n.target&&v(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e.cy(),t.target=e},callbackContext:function(e,t,n){return null!=t.qualifier?n.target:e},beforeEmit:function(e,t){t.conf&&t.conf.once&&t.conf.onceCollection.removeListener(t.event,t.qualifier,t.callback)},bubble:function(){return!0},parent:function(e){return e.isChild()?e.parent():e.cy()}},Ci=function(e){return K(e)?new Cr(e):e},Si={createEmitter:function(){for(var e=0;e<this.length;e++){var t=this[e],n=t._private;n.emitter||(n.emitter=new mi(ki,t))}return this},emitter:function(){return this._private.emitter},on:function(e,t,n){for(var r=0;r<this.length;r++){this[r].emitter().on(e,Ci(t),n)}return this},removeListener:function(e,t,n){for(var r=0;r<this.length;r++){this[r].emitter().removeListener(e,Ci(t),n)}return this},one:function(e,t,n){for(var r=0;r<this.length;r++){this[r].emitter().one(e,Ci(t),n)}return this},once:function(e,t,n){for(var r=0;r<this.length;r++){this[r].emitter().on(e,Ci(t),n,{once:!0,onceCollection:this})}},emit:function(e,t){for(var n=0;n<this.length;n++){this[n].emitter().emit(e,t)}return this},emitAndNotify:function(e,t){if(0!==this.length)return this.cy().notify(e,this),this.emit(e,t),this}};qn.eventAliasesOn(Si);var Di={nodes:function(e){return this.filter(function(e){return e.isNode()}).filter(e)},edges:function(e){return this.filter(function(e){return e.isEdge()}).filter(e)},byGroup:function(){for(var e=this.spawn(),t=this.spawn(),n=0;n<this.length;n++){var r=this[n];r.isNode()?e.merge(r):t.merge(r)}return{nodes:e,edges:t}},filter:function(e,t){if(void 0===e)return this;if(K(e)||Z(e))return new Cr(e).filter(this);if(X(e)){for(var n=this.spawn(),r=0;r<this.length;r++){var i=this[r];(t?e.apply(t,[i,r,this]):e(i,r,this))&&n.merge(i)}return n}return this.spawn()},not:function(e){if(e){K(e)&&(e=this.filter(e));for(var t=[],n=e._private.map,r=0;r<this.length;r++){var i=this[r];n.has(i.id())||t.push(i)}return this.spawn(t)}return this},absoluteComplement:function(){return this.cy().mutableElements().not(this)},intersect:function(e){if(K(e)){var t=e;return this.filter(t)}for(var n=[],r=e,i=this.length<e.length,a=i?r._private.map:this._private.map,o=i?this:r,s=0;s<o.length;s++){var l=o[s]._private.data.id,u=a.get(l);u&&n.push(u.ele)}return this.spawn(n)},xor:function(e){var t=this._private.cy;K(e)&&(e=t.$(e));var a=[],n=e,r=function(e,t){for(var n=0;n<e.length;n++){var r=e[n],i=r._private.data.id;t.hasElementWithId(i)||a.push(r)}};return r(this,n),r(n,this),this.spawn(a)},diff:function(e){var t=this._private.cy;K(e)&&(e=t.$(e));var n=[],r=[],o=[],i=e,a=function(e,t,n){for(var r=0;r<e.length;r++){var i=e[r],a=i._private.data.id;t.hasElementWithId(a)?o.push(i):n.push(i)}};return a(this,i,n),a(i,this,r),{left:this.spawn(n,{unique:!0}),right:this.spawn(r,{unique:!0}),both:this.spawn(o,{unique:!0})}},add:function(e){var t=this._private.cy;if(!e)return this;if(K(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=[],i=0;i<this.length;i++)r.push(this[i]);for(var a=this._private.map,o=0;o<e.length;o++){var s=!a.has(e[o].id());s&&r.push(e[o])}return this.spawn(r)},merge:function(e){var t=this._private,n=t.cy;if(!e)return this;if(e&&K(e)){var r=e;e=n.mutableElements().filter(r)}for(var i=t.map,a=0;a<e.length;a++){var o=e[a],s=o._private.data.id;if(!i.has(s)){var l=this.length++;this[l]=o,i.set(s,{ele:o,index:l})}else{var u=i.get(s).index;this[u]=o,i.set(s,{ele:o,index:u})}}return this},unmergeAt:function(e){var t=this[e].id(),n=this._private.map;this[e]=void 0,n.delete(t);var r=e===this.length-1;if(1<this.length&&!r){var i=this.length-1,a=this[i],o=a._private.data.id;this[i]=void 0,this[e]=a,n.set(o,{ele:a,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,n=e._private.data.id,r=t.map.get(n);if(!r)return this;var i=r.index;return this.unmergeAt(i),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&K(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=0;r<e.length;r++)this.unmergeOne(e[r]);return this},unmergeBy:function(e){for(var t=this.length-1;0<=t;t--){e(this[t])&&this.unmergeAt(t)}return this},map:function(e,t){for(var n=[],r=0;r<this.length;r++){var i=this[r],a=t?e.apply(t,[i,r,this]):e(i,r,this);n.push(a)}return n},reduce:function(e,t){for(var n=t,r=0;r<this.length;r++)n=e(n,this[r],r,this);return n},max:function(e,t){for(var n,r=-1/0,i=0;i<this.length;i++){var a=this[i],o=t?e.apply(t,[a,i,this]):e(a,i,this);r<o&&(r=o,n=a)}return{value:r,ele:n}},min:function(e,t){for(var n,r=1/0,i=0;i<this.length;i++){var a=this[i],o=t?e.apply(t,[a,i,this]):e(a,i,this);o<r&&(r=o,n=a)}return{value:r,ele:n}}},Ti=Di;Ti.u=Ti["|"]=Ti["+"]=Ti.union=Ti.or=Ti.add,Ti["\\"]=Ti["!"]=Ti["-"]=Ti.difference=Ti.relativeComplement=Ti.subtract=Ti.not,Ti.n=Ti["&"]=Ti["."]=Ti.and=Ti.intersection=Ti.intersect,Ti["^"]=Ti["(+)"]=Ti["(-)"]=Ti.symmetricDifference=Ti.symdiff=Ti.xor,Ti.fnFilter=Ti.filterFn=Ti.stdFilter=Ti.filter,Ti.complement=Ti.abscomp=Ti.absoluteComplement;var Pi=function(e,t){var n=e.cy().hasCompoundNodes();function r(e){var t=e.pstyle("z-compound-depth");return"auto"===t.value?n?e.zDepth():0:"bottom"===t.value?-1:"top"===t.value?pe:0}var i=r(e)-r(t);if(0!==i)return i;function a(e){return"auto"===e.pstyle("z-index-compare").value&&e.isNode()?1:0}var o=a(e)-a(t);if(0!==o)return o;var s=e.pstyle("z-index").value-t.pstyle("z-index").value;return 0!==s?s:e.poolIndex()-t.poolIndex()},Mi={forEach:function(e,t){if(X(e))for(var n=0;n<this.length;n++){var r=this[n];if(!1===(t?e.apply(t,[r,n,this]):e(r,n,this)))break}return this},toArray:function(){for(var e=[],t=0;t<this.length;t++)e.push(this[t]);return e},slice:function(e,t){var n=[],r=this.length;null==t&&(t=r),null==e&&(e=0),e<0&&(e=r+e),t<0&&(t=r+t);for(var i=e;0<=i&&i<t&&i<r;i++)n.push(this[i]);return this.spawn(n)},size:function(){return this.length},eq:function(e){return this[e]||this.spawn()},first:function(){return this[0]||this.spawn()},last:function(){return this[this.length-1]||this.spawn()},empty:function(){return 0===this.length},nonempty:function(){return!this.empty()},sort:function(e){if(!X(e))return this;var t=this.toArray().sort(e);return this.spawn(t)},sortByZIndex:function(){return this.sort(Pi)},zDepth:function(){var e=this[0];if(e){var t=e._private;if("nodes"===t.group){var n=t.data.parent?e.parents().size():0;return e.isParent()?n:pe-1}var r=t.source,i=t.target,a=r.zDepth(),o=i.zDepth();return Math.max(a,o,0)}}};Mi.each=Mi.forEach;var _i=Ce({nodeDimensionsIncludeLabels:!1}),Bi={layoutDimensions:function(e){if((e=_i(e)).nodeDimensionsIncludeLabels){var t=this.boundingBox();return{w:t.w,h:t.h}}return{w:this.outerWidth(),h:this.outerHeight()}},layoutPositions:function(e,u,t){var s=this.nodes(),n=this.cy(),r=u.eles,i=function(e,t){return e.id()+"$"+t},c=m(t,i);e.emit({type:"layoutstart",layout:e}),e.animations=[];var h=u.spacingFactor&&1!==u.spacingFactor,d=function(){if(!h)return null;for(var e,t,n,r=at(),i=0;i<s.length;i++){var a=s[i],o=c(a,i);e=r,t=o.x,n=o.y,e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1}return r}(),a=m(function(e,t){var n,r,i,a,o,s=c(e,t);if(h){var l=Math.abs(u.spacingFactor);n=l,i=s,a=(r=d).x1+r.w/2,o=r.y1+r.h/2,s={x:a+(i.x-a)*n,y:o+(i.y-o)*n}}return null!=u.transform&&(s=u.transform(e,s)),s},i);if(u.animate){for(var o=0;o<s.length;o++){var l=s[o],p=a(l,o);if(null==u.animateFilter||u.animateFilter(l,o)){var f=l.animation({position:p,duration:u.animationDuration,easing:u.animationEasing});e.animations.push(f)}else l.position(p)}if(u.fit){var g=n.animation({fit:{boundingBox:r.boundingBoxAt(a),padding:u.padding},duration:u.animationDuration,easing:u.animationEasing});e.animations.push(g)}else if(void 0!==u.zoom&&void 0!==u.pan){var v=n.animation({zoom:u.zoom,pan:u.pan,duration:u.animationDuration,easing:u.animationEasing});e.animations.push(v)}e.animations.forEach(function(e){return e.play()}),e.one("layoutready",u.ready),e.emit({type:"layoutready",layout:e}),Rn.all(e.animations.map(function(e){return e.promise()})).then(function(){e.one("layoutstop",u.stop),e.emit({type:"layoutstop",layout:e})})}else s.positions(a),u.fit&&n.fit(u.eles,u.padding),null!=u.zoom&&n.zoom(u.zoom),u.pan&&n.pan(u.pan),e.one("layoutready",u.ready),e.emit({type:"layoutready",layout:e}),e.one("layoutstop",u.stop),e.emit({type:"layoutstop",layout:e});return this},layout:function(e){return this.cy().makeLayout(S({},e,{eles:this}))}};function Ni(e,t,n){var r,i=n._private,a=i.styleCache=i.styleCache||[];return null!=(r=a[e])?r:r=a[e]=t(n)}function Ii(t,n){return t=le(t),function(e){return Ni(t,n,e)}}function Ai(t,n){t=le(t);var r=function(e){return n.call(e)};return function(){var e=this[0];if(e)return Ni(t,r,e)}}Bi.createLayout=Bi.makeLayout=Bi.layout;var Li={recalculateRenderedStyle:function(e){var t=this.cy(),n=t.renderer(),r=t.styleEnabled();return n&&r&&n.recalculateRenderedStyle(this,e),this},dirtyStyleCache:function(){var e,t=this.cy(),n=function(e){return e._private.styleCache=null};t.hasCompoundNodes()?((e=this.spawnSelf().merge(this.descendants()).merge(this.parents())).merge(e.connectedEdges()),e.forEach(n)):this.forEach(function(e){n(e),e.connectedEdges().forEach(n)});return this},updateStyle:function(e){var t=this._private.cy;if(!t.styleEnabled())return this;if(t.batching())return t._private.batchStyleEles.merge(this),this;var n=t.hasCompoundNodes(),r=t.style(),i=this;e=!(!e&&void 0!==e),n&&(i=this.spawnSelf().merge(this.descendants()).merge(this.parents()));var a=r.apply(i);return e?a.emitAndNotify("style"):a.emit("style"),this},updateMappers:function(e){var t=this._private.cy,n=t.style();if(e=!(!e&&void 0!==e),!t.styleEnabled())return this;var r=n.updateMappers(this);return e?r.emitAndNotify("style"):r.emit("style"),this},parsedStyle:function(e){var t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=this[0],r=n.cy();if(r.styleEnabled()&&n){var i=n._private.style[e];return null!=i?i:t?r.style().getDefaultProperty(e):null}},numericStyle:function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var n=t.pstyle(e);return void 0!==n.pfValue?n.pfValue:n.value}},numericStyleUnits:function(e){var t=this[0];if(t.cy().styleEnabled())return t?t.pstyle(e).units:void 0},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=this[0];return n?t.style().getRenderedStyle(n,e):void 0},style:function(e,t){var n=this.cy();if(!n.styleEnabled())return this;var r=n.style();if(B(e)){var i=e;r.applyBypass(this,i,!1),this.emitAndNotify("style")}else if(K(e)){if(void 0===t){var a=this[0];return a?r.getStylePropertyValue(a,e):void 0}r.applyBypass(this,e,t,!1),this.emitAndNotify("style")}else if(void 0===e){var o=this[0];return o?r.getRawStyle(o):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=t.style();if(void 0===e)for(var r=0;r<this.length;r++){var i=this[r];n.removeAllBypasses(i,!1)}else{e=e.split(/\s+/);for(var a=0;a<this.length;a++){var o=this[a];n.removeBypasses(o,e,!1)}}return this.emitAndNotify("style"),this},show:function(){return this.css("display","element"),this},hide:function(){return this.css("display","none"),this},effectiveOpacity:function(){var e=this.cy();if(!e.styleEnabled())return 1;var t=e.hasCompoundNodes(),n=this[0];if(n){var r=n._private,i=n.pstyle("opacity").value;if(!t)return i;var a=r.data.parent?n.parents():null;if(a)for(var o=0;o<a.length;o++){i*=a[o].pstyle("opacity").value}return i}},transparent:function(){if(!this.cy().styleEnabled())return!1;var e=this[0],t=e.cy().hasCompoundNodes();return e?t?0===e.effectiveOpacity():0===e.pstyle("opacity").value:void 0},backgrounding:function(){return!!this.cy().styleEnabled()&&!!this[0]._private.backgrounding}};function zi(e,t){var n=e._private.data.parent?e.parents():null;if(n)for(var r=0;r<n.length;r++){if(!t(n[r]))return!1}return!0}function Oi(e){var o=e.ok,s=e.edgeOkViaNode||e.ok,l=e.parentOk||e.ok;return function(){var e=this.cy();if(!e.styleEnabled())return!0;var t=this[0],n=e.hasCompoundNodes();if(t){var r=t._private;if(!o(t))return!1;if(t.isNode())return!n||zi(t,l);var i=r.source,a=r.target;return s(i)&&(!n||zi(i,s))&&(i===a||s(a)&&(!n||zi(a,s)))}}}var Ri=Ii("eleTakesUpSpace",function(e){return"element"===e.pstyle("display").value&&0!==e.width()&&(!e.isNode()||0!==e.height())});Li.takesUpSpace=Ai("takesUpSpace",Oi({ok:Ri}));var Fi=Ii("eleInteractive",function(e){return"yes"===e.pstyle("events").value&&"visible"===e.pstyle("visibility").value&&Ri(e)}),Vi=Ii("parentInteractive",function(e){return"visible"===e.pstyle("visibility").value&&Ri(e)});Li.interactive=Ai("interactive",Oi({ok:Fi,parentOk:Vi,edgeOkViaNode:Ri})),Li.noninteractive=function(){var e=this[0];if(e)return!e.interactive()};var qi=Ii("eleVisible",function(e){return"visible"===e.pstyle("visibility").value&&0!==e.pstyle("opacity").pfValue&&Ri(e)}),Yi=Ri;Li.visible=Ai("visible",Oi({ok:qi,edgeOkViaNode:Yi})),Li.hidden=function(){var e=this[0];if(e)return!e.visible()},Li.bypass=Li.css=Li.style,Li.renderedCss=Li.renderedStyle,Li.removeBypass=Li.removeCss=Li.removeStyle,Li.pstyle=Li.parsedStyle;var Xi={};function ji(h){return function(){var e=arguments,t=[];if(2===e.length){var n=e[0],r=e[1];this.on(h.event,n,r)}else if(1===e.length){var i=e[0];this.on(h.event,i)}else if(0===e.length){for(var a=0;a<this.length;a++){var o=this[a],s=!h.ableField||o._private[h.ableField],l=o._private[h.field]!=h.value;if(h.overrideAble){var u=h.overrideAble(o);if(void 0!==u&&!(s=u))return this}s&&(o._private[h.field]=h.value,l&&t.push(o))}var c=this.spawn(t);c.updateStyle(),c.emit(h.event)}return this}}function Wi(n){Xi[n.field]=function(){var e=this[0];if(e){if(n.overrideField){var t=n.overrideField(e);if(void 0!==t)return t}return e._private[n.field]}},Xi[n.on]=ji({event:n.on,field:n.field,ableField:n.ableField,overrideAble:n.overrideAble,value:!0}),Xi[n.off]=ji({event:n.off,field:n.field,ableField:n.ableField,overrideAble:n.overrideAble,value:!1})}Wi({field:"locked",overrideField:function(e){return!!e.cy().autolock()||void 0},on:"lock",off:"unlock"}),Wi({field:"grabbable",overrideField:function(e){return!e.cy().autoungrabify()&&void 0},on:"grabify",off:"ungrabify"}),Wi({field:"selected",ableField:"selectable",overrideAble:function(e){return!e.cy().autounselectify()&&void 0},on:"select",off:"unselect"}),Wi({field:"selectable",overrideField:function(e){return!e.cy().autounselectify()&&void 0},on:"selectify",off:"unselectify"}),Xi.deselect=Xi.unselect,Xi.grabbed=function(){var e=this[0];if(e)return e._private.grabbed},Wi({field:"active",on:"activate",off:"unactivate"}),Xi.inactive=function(){var e=this[0];if(e)return!e._private.active};var Hi={},Ki=function(c){return function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];if(r.isNode()){for(var i=!1,a=r.connectedEdges(),o=0;o<a.length;o++){var s=a[o],l=s.source(),u=s.target();if(c.noIncomingEdges&&u===r&&l!==r||c.noOutgoingEdges&&l===r&&u!==r){i=!0;break}}i||t.push(r)}}return this.spawn(t,{unique:!0}).filter(e)}},Gi=function(u){return function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];if(r.isNode())for(var i=r.connectedEdges(),a=0;a<i.length;a++){var o=i[a],s=o.source(),l=o.target();u.outgoing&&s===r?(t.push(o),t.push(l)):u.incoming&&l===r&&(t.push(o),t.push(s))}}return this.spawn(t,{unique:!0}).filter(e)}},Zi=function(u){return function(e){for(var t=this,n=[],r={};;){var i=u.outgoing?t.outgoers():t.incomers();if(0===i.length)break;for(var a=!1,o=0;o<i.length;o++){var s=i[o],l=s.id();r[l]||(r[l]=!0,n.push(s),a=!0)}if(!a)break;t=i}return this.spawn(n,{unique:!0}).filter(e)}};function Ui(i){return function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n]._private[i.attr];r&&t.push(r)}return this.spawn(t,{unique:!0}).filter(e)}}function $i(h){return function(e){var t=[],n=this._private.cy,r=h||{};K(e)&&(e=n.$(e));for(var i=0;i<e.length;i++)for(var a=e[i]._private.edges,o=0;o<a.length;o++){var s=a[o],l=s._private.data,u=this.hasElementWithId(l.source)&&e.hasElementWithId(l.target),c=e.hasElementWithId(l.source)&&this.hasElementWithId(l.target);if(u||c){if(r.thisIsSrc||r.thisIsTgt){if(r.thisIsSrc&&!u)continue;if(r.thisIsTgt&&!c)continue}t.push(s)}}return this.spawn(t,{unique:!0})}}function Qi(y){return y=S({},{codirected:!1},y),function(e){for(var t=[],n=this.edges(),r=y,i=0;i<n.length;i++)for(var a=n[i]._private,o=a.source,s=o._private.data.id,l=a.data.target,u=o._private.edges,c=0;c<u.length;c++){var h=u[c],d=h._private.data,p=d.target,f=d.source,g=p===l&&f===s,v=s===p&&l===f;(r.codirected&&g||!r.codirected&&(g||v))&&t.push(h)}return this.spawn(t,{unique:!0}).filter(e)}}Hi.clearTraversalCache=function(){for(var e=0;e<this.length;e++)this[e]._private.traversalCache=null},S(Hi,{roots:Ki({noIncomingEdges:!0}),leaves:Ki({noOutgoingEdges:!0}),outgoers:Mr(Gi({outgoing:!0}),"outgoers"),successors:Zi({outgoing:!0}),incomers:Mr(Gi({incoming:!0}),"incomers"),predecessors:Zi({incoming:!0})}),S(Hi,{neighborhood:Mr(function(e){for(var t=[],n=this.nodes(),r=0;r<n.length;r++)for(var i=n[r],a=i.connectedEdges(),o=0;o<a.length;o++){var s=a[o],l=s.source(),u=s.target(),c=i===l?u:l;0<c.length&&t.push(c[0]),t.push(s[0])}return this.spawn(t,{unique:!0}).filter(e)},"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),Hi.neighbourhood=Hi.neighborhood,Hi.closedNeighbourhood=Hi.closedNeighborhood,Hi.openNeighbourhood=Hi.openNeighborhood,S(Hi,{source:Mr(function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t},"source"),target:Mr(function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t},"target"),sources:Ui({attr:"source"}),targets:Ui({attr:"target"})}),S(Hi,{edgesWith:Mr($i(),"edgesWith"),edgesTo:Mr($i({thisIsSrc:!0}),"edgesTo")}),S(Hi,{connectedEdges:Mr(function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];if(r.isNode())for(var i=r._private.edges,a=0;a<i.length;a++){var o=i[a];t.push(o)}}return this.spawn(t,{unique:!0}).filter(e)},"connectedEdges"),connectedNodes:Mr(function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];r.isEdge()&&(t.push(r.source()[0]),t.push(r.target()[0]))}return this.spawn(t,{unique:!0}).filter(e)},"connectedNodes"),parallelEdges:Mr(Qi(),"parallelEdges"),codirectedEdges:Mr(Qi({codirected:!0}),"codirectedEdges")}),S(Hi,{components:function(){var t=this,n=t.cy(),r=t.spawn(),i=t.nodes().spawnSelf(),o=[],s=function(e,t){r.merge(e),i.unmerge(e),t.merge(e)};if(i.empty())return t.spawn();for(var e=function(){var a=n.collection();o.push(a);var e=i[0];s(e,a),t.bfs({directed:!1,roots:e,visit:function(e,t,n,r,i){s(e,a)}})};e(),0<i.length;);return o.map(function(t){var e=t.connectedEdges().stdFilter(function(e){return t.anySame(e.source())&&t.anySame(e.target())});return t.union(e)})}});var Ji=function(e,t,n){for(var r=null!=n?n:we();e.hasElementWithId(r);)r=we();return r},ea=function(e,t,n){if(void 0!==e&&y(e)){var r=new Pe,i=!1;if(t){if(0<t.length&&B(t[0])&&!v(t[0])){i=!0;for(var a=[],o=new _e,s=0,l=t.length;s<l;s++){var u=t[s];null==u.data&&(u.data={});var c=u.data;if(null==c.id)c.id=Ji(e,u);else if(e.hasElementWithId(c.id)||o.has(c.id))continue;var h=new Be(e,u,!1);a.push(h),o.add(c.id)}t=a}}else t=[];for(var d=this.length=0,p=t.length;d<p;d++){var f=t[d];if(null!=f){var g=f._private.data.id;(null==n||n.unique&&!r.has(g))&&(r.set(g,{index:this.length,ele:f}),this[this.length]=f,this.length++)}}this._private={cy:e,map:r},i&&this.restore()}else me("A collection must have a reference to the core")},ta=Be.prototype=ea.prototype;ta.instanceString=function(){return"collection"},ta.spawn=function(e,t,n){return y(e)||(n=t,t=e,e=this.cy()),new ea(e,t,n)},ta.spawnSelf=function(){return this.spawn(this)},ta.cy=function(){return this._private.cy},ta.renderer=function(){return this._private.cy.renderer()},ta.element=function(){return this[0]},ta.collection=function(){return h(this)?this:new ea(this._private.cy,[this])},ta.unique=function(){return new ea(this._private.cy,this,{unique:!0})},ta.hasElementWithId=function(e){return this._private.map.has(e)},ta.getElementById=function(e){var t=this._private.cy,n=this._private.map.get(e);return n?n.ele:new ea(t)},ta.$id=ta.getElementById,ta.poolIndex=function(){var e=this._private.cy._private.elements,t=this[0]._private.data.id;return e._private.map.get(t).index},ta.indexOf=function(e){var t=e[0]._private.data.id;return this._private.map.get(t).index},ta.indexOfId=function(e){return this._private.map.get(e).index},ta.json=function(i){var a=this.element(),e=this.cy();if(null==a&&i)return this;if(null!=a){var o=a._private;if(B(i)){if(e.startBatch(),i.data){a.data(i.data);var t=o.data;if(a.isEdge()){var n=!1,r={},s=i.data.source,l=i.data.target;null!=s&&s!==t.source&&(r.source=s,n=!0),null!=l&&l!==t.target&&(r.target=l,n=!0),n&&(a=a.move(r))}else{var u=i.data.parent;null==u&&null==t.parent||u===t.parent||(void 0===u&&(u=null),a=a.move({parent:u}))}}i.position&&a.position(i.position);var c=function(e,t,n){var r=i[e];null!=r&&r!==o[e]&&(r?a[t]():a[n]())};return c("removed","remove","restore"),c("selected","select","unselect"),c("selectable","selectify","unselectify"),c("locked","lock","unlock"),c("grabbable","grabify","ungrabify"),null!=i.classes&&a.classes(i.classes),e.endBatch(),this}if(void 0===i){var h={data:xe(o.data),position:xe(o.position),group:o.group,removed:o.removed,selected:o.selected,selectable:o.selectable,locked:o.locked,grabbable:o.grabbable,classes:null};h.classes="";var d=0;return o.classes.forEach(function(e){return h.classes+=0==d++?e:" "+e}),h}}},ta.jsons=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t].json();e.push(n)}return e},ta.clone=function(){for(var e=this.cy(),t=[],n=0;n<this.length;n++){var r=this[n].json(),i=new Be(e,r,!1);t.push(i)}return new ea(e,t)},ta.copy=ta.clone,ta.restore=function(e){var t=this.cy(),n=t._private;void 0===e&&(e=!0);for(var r,i,a=[],o=[],s=0,l=this.length;s<l;s++){var u=this[s];u.removed()&&(u.isNode()?a.push(u):o.push(u))}r=a.concat(o);var c=function(){r.splice(i,1),i--};for(i=0;i<r.length;i++){var h=r[i],d=h._private,p=d.data;if(h.clearTraversalCache(),void 0===p.id)p.id=Ji(t,h);else if($t(p.id))p.id=""+p.id;else{if(L(p.id)||!K(p.id)){me("Can not create element with invalid string ID `"+p.id+"`"),c();continue}if(t.hasElementWithId(p.id)){me("Can not create second element with ID `"+p.id+"`"),c();continue}}var f=p.id;if(h.isNode()){var g=d.position;null==g.x&&(g.x=0),null==g.y&&(g.y=0)}if(h.isEdge()){for(var v=h,y=["source","target"],m=y.length,b=!1,x=0;x<m;x++){var w=y[x],E=p[w];$t(E)&&(E=p[w]=""+p[w]),null==E||""===E?(me("Can not create edge `"+f+"` with unspecified "+w),b=!0):t.hasElementWithId(E)||(me("Can not create edge `"+f+"` with nonexistant "+w+" `"+E+"`"),b=!0)}if(b){c();continue}var k=t.getElementById(p.source),C=t.getElementById(p.target);k._private.edges.push(v),C._private.edges.push(v),v._private.source=k,v._private.target=C}d.map=new Pe,d.map.set(f,{ele:h,index:0}),d.removed=!1,t.addToPool(h)}for(var S=0;S<a.length;S++){var D=a[S],T=D._private.data;$t(T.parent)&&(T.parent=""+T.parent);var P=T.parent;if(null!=P){var M=t.getElementById(P);if(M.empty())T.parent=void 0;else{for(var _=!1,B=M;!B.empty();){if(D.same(B)){_=!0,T.parent=void 0;break}B=B.parent()}_||(M[0]._private.children.push(D),D._private.parent=M[0],n.hasCompoundNodes=!0)}}}if(0<r.length){for(var N=new ea(t,r),I=0;I<N.length;I++){var A=N[I];A.isNode()||(A.parallelEdges().clearTraversalCache(),A.source().clearTraversalCache(),A.target().clearTraversalCache())}(n.hasCompoundNodes?t.collection().merge(N).merge(N.connectedNodes()).merge(N.parent()):N).dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(e),e?N.emitAndNotify("add"):N.emit("add")}return this},ta.removed=function(){var e=this[0];return e&&e._private.removed},ta.inside=function(){var e=this[0];return e&&!e._private.removed},ta.remove=function(e){var t=[],n=[],r={},i=this._private.cy;function a(e){var t=r[e.id()];e.removed()||t||(r[e.id()]=!0,e.isNode()?(n.push(e),function(e){for(var t=e._private.edges,n=0;n<t.length;n++)a(t[n])}(e),function(e){for(var t=e._private.children,n=0;n<t.length;n++)a(t[n])}(e)):n.unshift(e))}void 0===e&&(e=!0);for(var o=0,s=this.length;o<s;o++){a(this[o])}function l(e,t){var n=e._private.edges;Se(n,t),e.clearTraversalCache()}var u=[];function c(e,t){t=t[0];var n=(e=e[0])._private.children,r=e.id();Se(n,t),u.ids[r]||(u.ids[r]=!0,u.push(e))}u.ids={},this.dirtyCompoundBoundsCache(),i.removeFromPool(n);for(var h=0;h<n.length;h++){var d=n[h];if(d._private.removed=!0,t.push(d),d.isEdge()){var p=d.source()[0],f=d.target()[0];l(p,d),l(f,d),d.parallelEdges().clearTraversalCache()}else{var g=d.parent();0!==g.length&&c(g,d)}}var v=i._private.elements;i._private.hasCompoundNodes=!1;for(var y=0;y<v.length;y++){if(v[y].isParent()){i._private.hasCompoundNodes=!0;break}}var m=new ea(this.cy(),t);0<m.size()&&(e?m.emitAndNotify("remove"):m.emit("remove"));for(var b=0;b<u.length;b++){var x=u[b];x.removed()||x.updateStyle()}return new ea(i,t)},ta.move=function(e){var t=this._private.cy;if(void 0!==e.source||void 0!==e.target){var n=e.source,r=e.target,i=t.hasElementWithId(n),a=t.hasElementWithId(r);if(i||a){var o=this.jsons();this.remove();for(var s=0;s<o.length;s++){var l=o[s],u=this[s];"edges"===l.group&&(i&&(l.data.source=n),a&&(l.data.target=r),l.scratch=u._private.scratch)}return t.add(o)}}else if(void 0!==e.parent){var c=e.parent;if(null===c||t.hasElementWithId(c)){var h=this.jsons(),d=this.descendants(),p=d.union(d.union(this).connectedEdges()).jsons();this.remove();for(var f=0;f<h.length;f++){var g=h[f],v=this[f];"nodes"===g.group&&(g.data.parent=null===c?void 0:c,g.scratch=v._private.scratch)}return t.add(h.concat(p))}}return this},[Bn,Yn,Xn,Dr,_r,Or,Rr,hi,Si,Di,{isNode:function(){return"nodes"===this.group()},isEdge:function(){return"edges"===this.group()},isLoop:function(){return this.isEdge()&&this.source()[0]===this.target()[0]},isSimple:function(){return this.isEdge()&&this.source()[0]!==this.target()[0]},group:function(){var e=this[0];if(e)return e._private.group}},Mi,Bi,Li,Xi,Hi].forEach(function(e){S(ta,e)});var na={add:function(e){var t;if(Z(e)){var n=e;if(n._private.cy===this)t=n.restore();else{for(var r=[],i=0;i<n.length;i++){var a=n[i];r.push(a.json())}t=new ea(this,r)}}else if(G(e)){t=new ea(this,e)}else if(B(e)&&(G(e.nodes)||G(e.edges))){for(var o=e,s=[],l=["nodes","edges"],u=0,c=l.length;u<c;u++){var h=l[u],d=o[h];if(G(d))for(var p=0,f=d.length;p<f;p++){var g=S({group:h},d[p]);s.push(g)}}t=new ea(this,s)}else{t=new Be(this,e).collection()}return t},remove:function(e){if(Z(e));else if(K(e)){var t=e;e=this.$(t)}return e.remove()}};function ra(o,t,s,n){var l=4,u=1e-7,c=10,h=11,d=1/(h-1),e="undefined"!=typeof Float32Array;if(4!==arguments.length)return!1;for(var r=0;r<4;++r)if("number"!=typeof arguments[r]||isNaN(arguments[r])||!isFinite(arguments[r]))return!1;o=Math.min(o,1),s=Math.min(s,1),o=Math.max(o,0),s=Math.max(s,0);var p=e?new Float32Array(h):new Array(h);function i(e,t){return 1-3*t+3*e}function a(e,t){return 3*t-6*e}function f(e){return 3*e}function g(e,t,n){return((i(t,n)*e+a(t,n))*e+f(t))*e}function v(e,t,n){return 3*i(t,n)*e*e+2*a(t,n)*e+f(t)}function y(e){for(var t=0,n=1,r=h-1;n!==r&&p[n]<=e;++n)t+=d;var i=t+(e-p[--n])/(p[n+1]-p[n])*d,a=v(i,o,s);return.001<=a?function(e,t){for(var n=0;n<l;++n){var r=v(t,o,s);if(0===r)return t;t-=(g(t,o,s)-e)/r}return t}(e,i):0===a?i:function(e,t,n){for(var r,i,a=0;0<(r=g(i=t+(n-t)/2,o,s)-e)?n=i:t=i,Math.abs(r)>u&&++a<c;);return i}(e,t,t+d)}var m=!1;function b(){m=!0,o===t&&s===n||function(){for(var e=0;e<h;++e)p[e]=g(e*d,o,s)}()}var x=function(e){return m||b(),o===t&&s===n?e:0===e?0:1===e?1:g(y(e),t,n)};x.getControlPoints=function(){return[{x:o,y:t},{x:s,y:n}]};var w="generateBezier("+[o,t,s,n]+")";return x.toString=function(){return w},x}var ia=function(){function m(e){return-e.tension*e.x-e.friction*e.v}function b(e,t,n){var r={x:e.x+n.dx*t,v:e.v+n.dv*t,tension:e.tension,friction:e.friction};return{dx:r.v,dv:m(r)}}return function e(t,n,r){var i,a,o,s,l,u,c,h,d,p,f,g={x:-1,v:0,tension:null,friction:null},v=[0],y=0;for(t=parseFloat(t)||500,n=parseFloat(n)||20,r=r||null,g.tension=t,g.friction=n,a=(i=null!==r)?(y=e(t,n))/r*.016:.016;l=a,void 0,u={dx:(s=o||g).v,dv:m(s)},c=b(s,.5*l,u),h=b(s,.5*l,c),d=b(s,l,h),p=1/6*(u.dx+2*(c.dx+h.dx)+d.dx),f=1/6*(u.dv+2*(c.dv+h.dv)+d.dv),s.x=s.x+p*l,s.v=s.v+f*l,o=s,v.push(1+o.x),y+=16,1e-4<Math.abs(o.x)&&1e-4<Math.abs(o.v););return i?function(e){return v[e*(v.length-1)|0]}:y}}(),aa=function(e,t,n,r){var i=ra(e,t,n,r);return function(e,t,n){return e+(t-e)*i(n)}},oa={linear:function(e,t,n){return e+(t-e)*n},ease:aa(.25,.1,.25,1),"ease-in":aa(.42,0,1,1),"ease-out":aa(0,0,.58,1),"ease-in-out":aa(.42,0,.58,1),"ease-in-sine":aa(.47,0,.745,.715),"ease-out-sine":aa(.39,.575,.565,1),"ease-in-out-sine":aa(.445,.05,.55,.95),"ease-in-quad":aa(.55,.085,.68,.53),"ease-out-quad":aa(.25,.46,.45,.94),"ease-in-out-quad":aa(.455,.03,.515,.955),"ease-in-cubic":aa(.55,.055,.675,.19),"ease-out-cubic":aa(.215,.61,.355,1),"ease-in-out-cubic":aa(.645,.045,.355,1),"ease-in-quart":aa(.895,.03,.685,.22),"ease-out-quart":aa(.165,.84,.44,1),"ease-in-out-quart":aa(.77,0,.175,1),"ease-in-quint":aa(.755,.05,.855,.06),"ease-out-quint":aa(.23,1,.32,1),"ease-in-out-quint":aa(.86,0,.07,1),"ease-in-expo":aa(.95,.05,.795,.035),"ease-out-expo":aa(.19,1,.22,1),"ease-in-out-expo":aa(1,0,0,1),"ease-in-circ":aa(.6,.04,.98,.335),"ease-out-circ":aa(.075,.82,.165,1),"ease-in-out-circ":aa(.785,.135,.15,.86),spring:function(e,t,n){if(0===n)return oa.linear;var r=ia(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":aa};function sa(e,t,n,r,i){if(1===r)return n;var a=i(t,n,r);return null==e||((e.roundValue||e.color)&&(a=Math.round(a)),void 0!==e.min&&(a=Math.max(a,e.min)),void 0!==e.max&&(a=Math.min(a,e.max))),a}function la(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function ua(e,t,n,r,i){var a=null!=i?i.type:null;n<0?n=0:1<n&&(n=1);var o=la(e,i),s=la(t,i);if($t(o)&&$t(s))return sa(a,o,s,n,r);if(G(o)&&G(s)){for(var l=[],u=0;u<s.length;u++){var c=o[u],h=s[u];if(null!=c&&null!=h){var d=sa(a,c,h,n,r);l.push(d)}else l.push(h)}return l}}function ca(e,t,n,r){var i=!r,a=e._private,o=t._private,s=o.easing,l=o.startTime,u=(r?e:e.cy()).style();if(!o.easingImpl)if(null==s)o.easingImpl=oa.linear;else{var c,h,d;if(K(s))c=u.parse("transition-timing-function",s).value;else c=s;0<(d=K(c)?(h=c,[]):(h=c[1],c.slice(2).map(function(e){return+e}))).length?("spring"===h&&d.push(o.duration),o.easingImpl=oa[h].apply(null,d)):o.easingImpl=oa[h]}var p,f=o.easingImpl;if(p=0===o.duration?1:(n-l)/o.duration,o.applying&&(p=o.progress),p<0?p=0:1<p&&(p=1),null==o.delay){var g=o.startPosition,v=o.position;if(v&&i&&!e.locked()){var y={};ha(g.x,v.x)&&(y.x=ua(g.x,v.x,p,f)),ha(g.y,v.y)&&(y.y=ua(g.y,v.y,p,f)),e.position(y)}var m=o.startPan,b=o.pan,x=a.pan,w=null!=b&&r;w&&(ha(m.x,b.x)&&(x.x=ua(m.x,b.x,p,f)),ha(m.y,b.y)&&(x.y=ua(m.y,b.y,p,f)),e.emit("pan"));var E=o.startZoom,k=o.zoom,C=null!=k&&r;C&&(ha(E,k)&&(a.zoom=ua(E,k,p,f)),e.emit("zoom")),(w||C)&&e.emit("viewport");var S=o.style;if(S&&0<S.length&&i){for(var D=0;D<S.length;D++){var T=S[D],P=T.name,M=T,_=o.startStyle[P],B=ua(_,M,p,f,u.properties[_.name]);u.overrideBypass(e,P,B)}e.emit("style")}}return o.progress=p}function ha(e,t){return null!=e&&null!=t&&(!(!$t(e)||!$t(t))||!(!e||!t))}function da(e,t,n,r){var i=!r,a=e,o=t._private,s=r?e:e.cy(),l=s.style();if(i){var u=a.position();o.startPosition=o.startPosition||{x:u.x,y:u.y},o.startStyle=o.startStyle||l.getAnimationStartStyle(a,o.style)}if(r){var c=s._private.pan;o.startPan=o.startPan||{x:c.x,y:c.y},o.startZoom=null!=o.startZoom?o.startZoom:s._private.zoom}o.started=!0,o.startTime=n-o.progress*o.duration}function pa(d,e){var t=e._private.aniEles,p=[];function n(e,t){var n=e._private,r=n.animation.current,i=n.animation.queue,a=!1;if(!t&&"none"===e.pstyle("display").value){r=r.splice(0,r.length).concat(i.splice(0,i.length));for(var o=0;o<r.length;o++)r[o].stop()}if(0===r.length){var s=i.shift();s&&r.push(s)}for(var l=function(e){for(var t=e.length-1;0<=t;t--){(0,e[t])()}e.splice(0,e.length)},u=r.length-1;0<=u;u--){var c=r[u],h=c._private;h.stopped?(r.splice(u,1),h.hooked=!1,h.playing=!1,h.started=!1,l(h.frames)):(h.playing||h.applying)&&(h.playing&&h.applying&&(h.applying=!1),h.started||da(e,c,d,t),ca(e,c,d,t),h.applying&&(h.applying=!1),l(h.frames),null!=h.step&&h.step(d),c.completed()&&(r.splice(u,1),h.hooked=!1,h.playing=!1,h.started=!1,l(h.completes)),a=!0)}return t||0!==r.length||0!==i.length||p.push(e),a}for(var r=!1,i=0;i<t.length;i++){var a=n(t[i]);r=r||a}var o=n(e,!0);(r||o)&&(0<t.length?e.notify("draw",t):e.notify("draw")),t.unmerge(p),e.emit("step")}var fa={animate:qn.animate(),animation:qn.animation(),animated:qn.animated(),clearQueue:qn.clearQueue(),delay:qn.delay(),delayAnimation:qn.delayAnimation(),stop:qn.stop(),addToAnimationPool:function(e){this.styleEnabled()&&this._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var n=this;if(n._private.animationsRunning=!0,n.styleEnabled()){var e=n.renderer();e&&e.beforeRender?e.beforeRender(function(e,t){pa(t,n)},e.beforeRenderPriorities.animations):function t(){n._private.animationsRunning&&ne(function(e){pa(e,n),t()})}()}}},ga={qualifierCompare:function(e,t){return null==e||null==t?null==e&&null==t:e.sameText(t)},eventMatches:function(e,t,n){var r=t.qualifier;return null==r||e!==n.target&&v(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e,t.target=e},callbackContext:function(e,t,n){return null!=t.qualifier?n.target:e}},va=function(e){return K(e)?new Cr(e):e},ya={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new mi(ga,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,va(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,va(t),n),this},one:function(e,t,n){return this.emitter().one(e,va(t),n),this},once:function(e,t,n){return this.emitter().one(e,va(t),n),this},emit:function(e,t){return this.emitter().emit(e,t),this},emitAndNotify:function(e,t){return this.emit(e),this.notify(e,t),this}};qn.eventAliasesOn(ya);var ma={png:function(e){return e=e||{},this._private.renderer.png(e)},jpg:function(e){var t=this._private.renderer;return(e=e||{}).bg=e.bg||"#fff",t.jpg(e)}};ma.jpeg=ma.jpg;var ba={layout:function(e){if(null!=e)if(null!=e.name){var t=e.name,n=this.extension("layout",t);if(null!=n){var r;r=K(e.eles)?this.$(e.eles):null!=e.eles?e.eles:this.$();var i=new n(S({},e,{cy:this,eles:r}));return i}me("No such layout `"+t+"` found. Did you forget to import it and `cytoscape.use()` it?")}else me("A `name` must be specified to make a layout");else me("Layout options must be specified to make a layout")}};ba.createLayout=ba.makeLayout=ba.layout;var xa={notify:function(e,t){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var r=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();null!=t&&r.merge(t)}else if(n.notificationsEnabled){var i=this.renderer();!this.isDestroyed()&&i&&i.notify(e,t)}},notifications:function(e){var t=this._private;return void 0===e?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return 0<this._private.batchCount},startBatch:function(){var e=this._private;return null==e.batchCount&&(e.batchCount=0),0===e.batchCount&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var n=this._private;if(0===n.batchCount)return this;if(n.batchCount--,0===n.batchCount){n.batchStyleEles.updateStyle();var r=this.renderer();Object.keys(n.batchNotifications).forEach(function(e){var t=n.batchNotifications[e];t.empty()?r.notify(e):r.notify(e,t)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(i){var a=this;return this.batch(function(){for(var e=Object.keys(i),t=0;t<e.length;t++){var n=e[t],r=i[n];a.getElementById(n).data(r)}})}},wa=Ce({motionBlur:!1,motionBlurOpacity:.05,pixelRatio:void 0,desktopTapThreshold:4,touchTapThreshold:8,wheelSensitivity:1}),Ea={renderTo:function(e,t,n,r){return this._private.renderer.renderTo(e,t,n,r),this},renderer:function(){return this._private.renderer},forceRender:function(){return this.notify("draw"),this},resize:function(){return this.invalidateSize(),this.emitAndNotify("resize"),this},initRenderer:function(e){var t=this.extension("renderer",e.name);if(null!=t){void 0!==e.wheelSensitivity&&be("You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.");var n=wa(e);(n.cy=this)._private.renderer=new t(n),this.notify("init")}else me("Can not initialise: No such renderer `".concat(e.name,"` found. Did you forget to import it and `cytoscape.use()` it?"))},destroyRenderer:function(){this.notify("destroy");var e=this.container();if(e)for(e._cyreg=null;0<e.childNodes.length;)e.removeChild(e.childNodes[0]);this._private.renderer=null,this.mutableElements().forEach(function(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]})},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};Ea.invalidateDimensions=Ea.resize;var ka={collection:function(e,t){return K(e)?this.$(e):Z(e)?e.collection():G(e)?new ea(this,e,t):new ea(this)},nodes:function(e){var t=this.$(function(e){return e.isNode()});return e?t.filter(e):t},edges:function(e){var t=this.$(function(e){return e.isEdge()});return e?t.filter(e):t},$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};ka.elements=ka.filter=ka.$;var Ca={};Ca.apply=function(e){var t=this._private,n=t.cy.collection();t.newStyle&&(t.contextStyles={},t.propDiffs={},this.cleanElements(e,!0));for(var r=0;r<e.length;r++){var i=e[r],a=this.getContextMeta(i);if(!a.empty){var o=this.getContextStyle(a),s=this.applyContextStyle(a,o,i);t.newStyle||this.updateTransitions(i,s.diffProps),this.updateStyleHints(i)&&n.merge(i)}}return t.newStyle=!1,n},Ca.getPropertiesDiff=function(e,t){var n=this._private.propDiffs=this._private.propDiffs||{},r=e+"-"+t,i=n[r];if(i)return i;for(var a=[],o={},s=0;s<this.length;s++){var l=this[s],u="t"===e[s]!==("t"===t[s]),c=0<l.mappedProperties.length;if(u||c){var h=void 0;u&&c?h=l.properties:u?h=l.properties:c&&(h=l.mappedProperties);for(var d=0;d<h.length;d++){for(var p=h[d],f=p.name,g=!1,v=s+1;v<this.length;v++){var y=this[v];if("t"===t[v]&&(g=null!=y.properties[p.name]))break}o[f]||g||(o[f]=!0,a.push(f))}}}return n[r]=a},Ca.getContextMeta=function(e){var t,n="",r=e._private.styleCxtKey||"";this._private.newStyle&&(r="");for(var i=0;i<this.length;i++){var a=this[i];n+=a.selector&&a.selector.matches(e)?"t":"f"}return t=this.getPropertiesDiff(r,n),{key:e._private.styleCxtKey=n,diffPropNames:t,empty:0===t.length}},Ca.getContextStyle=function(e){var t=e.key,n=this._private.contextStyles=this._private.contextStyles||{};if(n[t])return n[t];for(var r={_private:{key:t}},i=0;i<this.length;i++){var a=this[i];if("t"===t[i])for(var o=0;o<a.properties.length;o++){var s=a.properties[o];r[s.name]=s}}return n[t]=r},Ca.applyContextStyle=function(e,t,n){for(var r=e.diffPropNames,i={},a=0;a<r.length;a++){var o=r[a],s=t[o],l=n.pstyle(o);if(!s){if(!l)continue;s=l.bypass?{name:o,deleteBypassed:!0}:{name:o,delete:!0}}if(l!==s){var u=i[o]={prev:l};this.applyParsedProperty(n,s),u.next=n.pstyle(o),u.next&&u.next.bypass&&(u.next=u.next.bypassed)}}return{diffProps:i}},Ca.updateStyleHints=function(e){var n=e._private,r=this,t=r.propertyGroupNames,i=r.propertyGroupKeys,a=function(e,t,n){return r.getPropertiesHash(e,t,n)},o=n.styleKey;if(e.removed())return!1;var s="nodes"===n.group,l=e._private.style;t=Object.keys(l);for(var u=0;u<i.length;u++){var c=i[u];n.styleKeys[c]=0}for(var h=function(e,t){return n.styleKeys[t]=oe(e,n.styleKeys[t])},d=function(e){return-128<e&&e<128&&Math.floor(e)!==e?-(1024*e|0):e},p=0;p<t.length;p++){var f=t[p],g=l[f];if(null!=g){var v=this.properties[f],y=v.type,m=v.groupKey;if(y.number){var b=null!=g.pfValue?g.pfValue:g.value;if(y.multiple)for(var x=0;x<b.length;x++)h(d(b[x]),m);else h(d(b),m)}else for(var w=g.strValue,E=0;E<w.length;E++)h(w.charCodeAt(E),m)}}for(var k=0,C=0;C<i.length;C++){var S=i[C],D=n.styleKeys[S];k=oe(D,k)}n.styleKey=k;var T=n.labelDimsKey=n.styleKeys.labelDimensions;if(n.labelKey=a(e,["label"],T),n.labelStyleKey=oe(n.styleKeys.commonLabel,n.labelKey),s||(n.sourceLabelKey=a(e,["source-label"],T),n.sourceLabelStyleKey=oe(n.styleKeys.commonLabel,n.sourceLabelKey),n.targetLabelKey=a(e,["target-label"],T),n.targetLabelStyleKey=oe(n.styleKeys.commonLabel,n.targetLabelKey)),s){var P=n.styleKeys,M=P.nodeBody,_=P.nodeBorder,B=P.backgroundImage,N=P.compound,I=P.pie;n.nodeKey=se([_,B,N,I],M),n.hasPie=0!=I}return o!==n.styleKey},Ca.clearStyleHints=function(e){var t=e._private;t.styleKeys={},t.styleKey=null,t.labelKey=null,t.labelStyleKey=null,t.sourceLabelKey=null,t.sourceLabelStyleKey=null,t.targetLabelKey=null,t.targetLabelStyleKey=null,t.nodeKey=null,t.hasPie=null},Ca.applyParsedProperty=function(n,e){var t,r=this,i=e,a=n._private.style,o=r.types,s=r.properties[i.name].type,l=i.bypass,u=a[i.name],c=u&&u.bypass,h=n._private,d="mapping",p=function(e){return null==e?null:null!=e.pfValue?e.pfValue:e.value},f=function(){var e=p(u),t=p(i);r.checkTriggers(n,i.name,e,t)};if("curve-style"===e.name&&n.isEdge()&&("bezier"!==e.value&&n.isLoop()||"haystack"===e.value&&(n.source().isParent()||n.target().isParent()))&&(i=e=this.parse(e.name,"bezier",l)),i.delete)return a[i.name]=void 0,f(),!0;if(i.deleteBypassed)return u?!!u.bypass&&(u.bypassed=void 0,f(),!0):(f(),!0);if(i.deleteBypass)return u?!!u.bypass&&(a[i.name]=u.bypassed,f(),!0):(f(),!0);var g=function(){be("Do not assign mappings to elements without corresponding data (i.e. ele `"+n.id()+"` has no mapping for property `"+i.name+"` with data field `"+i.field+"`); try a `["+i.field+"]` selector to limit scope to elements with `"+i.field+"` defined")};switch(i.mapped){case o.mapData:for(var v,y=i.field.split("."),m=h.data,b=0;b<y.length&&m;b++){m=m[y[b]]}if(null==m)return g(),!1;if(!$t(m))return be("Do not use continuous mappers without specifying numeric data (i.e. `"+i.field+": "+m+"` for `"+n.id()+"` is non-numeric)"),!1;var x=i.fieldMax-i.fieldMin;if((v=0===x?0:(m-i.fieldMin)/x)<0?v=0:1<v&&(v=1),s.color){var w=i.valueMin[0],E=i.valueMax[0],k=i.valueMin[1],C=i.valueMax[1],S=i.valueMin[2],D=i.valueMax[2],T=null==i.valueMin[3]?1:i.valueMin[3],P=null==i.valueMax[3]?1:i.valueMax[3],M=[Math.round(w+(E-w)*v),Math.round(k+(C-k)*v),Math.round(S+(D-S)*v),Math.round(T+(P-T)*v)];t={bypass:i.bypass,name:i.name,value:M,strValue:"rgb("+M[0]+", "+M[1]+", "+M[2]+")"}}else{if(!s.number)return!1;var _=i.valueMin+(i.valueMax-i.valueMin)*v;t=this.parse(i.name,_,i.bypass,d)}if(!t)return g(),!1;t.mapping=i,i=t;break;case o.data:for(var B=i.field.split("."),N=h.data,I=0;I<B.length&&N;I++){N=N[B[I]]}if(null!=N&&(t=this.parse(i.name,N,i.bypass,d)),!t)return g(),!1;t.mapping=i,i=t;break;case o.fn:var A=(0,i.value)(n);if(null==A)return be("Custom function mappers may not return null (i.e. `"+i.name+"` for ele `"+n.id()+"` is null)"),!1;if(!(t=this.parse(i.name,A,i.bypass,d)))return be("Custom function mappers may not return invalid values for the property type (i.e. `"+i.name+"` for ele `"+n.id()+"` is invalid)"),!1;t.mapping=i,i=t;break;case void 0:break;default:return!1}return l?(i.bypassed=c?u.bypassed:u,a[i.name]=i):c?u.bypassed=i:a[i.name]=i,f(),!0},Ca.cleanElements=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(this.clearStyleHints(r),r.dirtyCompoundBoundsCache(),r.dirtyBoundingBoxCache(),t)for(var i=r._private.style,a=Object.keys(i),o=0;o<a.length;o++){var s=a[o],l=i[s];null!=l&&(l.bypass?l.bypassed=null:i[s]=null)}else r._private.style={}}},Ca.update=function(){this._private.cy.mutableElements().updateStyle()},Ca.updateMappers=function(e){for(var t=this._private.cy.collection(),n=0;n<e.length;n++){for(var r=e[n],i=r._private.style,a=!1,o=Object.keys(i),s=0;s<o.length;s++){var l=i[o[s]];if(null!=l&&l.mapping){var u=l.mapping;this.applyParsedProperty(r,u),a=!0}}if(a)this.updateStyleHints(r)&&t.merge(r)}return t},Ca.updateTransitions=function(t,e){var n=this,r=t._private,i=t.pstyle("transition-property").value,a=t.pstyle("transition-duration").pfValue,o=t.pstyle("transition-delay").pfValue;if(0<i.length&&0<a){for(var s={},l=!1,u=0;u<i.length;u++){var c=i[u],h=t.pstyle(c),d=e[c];if(d){var p=d.prev,f=null!=d.next?d.next:h,g=!1,v=void 0;p&&($t(p.pfValue)&&$t(f.pfValue)?(g=f.pfValue-p.pfValue,v=p.pfValue+1e-6*g):$t(p.value)&&$t(f.value)?(g=f.value-p.value,v=p.value+1e-6*g):G(p.value)&&G(f.value)&&(g=p.value[0]!==f.value[0]||p.value[1]!==f.value[1]||p.value[2]!==f.value[2],v=p.strValue),g&&(s[c]=f.strValue,this.applyBypass(t,c,v),l=!0))}}if(!l)return;r.transitioning=!0,new Rn(function(e){0<o?t.delayAnimation(o).play().promise().then(e):e()}).then(function(){return t.animation({style:s,duration:a,easing:t.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){n.removeBypasses(t,i),t.emitAndNotify("style"),r.transitioning=!1})}else r.transitioning&&(this.removeBypasses(t,i),t.emitAndNotify("style"),r.transitioning=!1)},Ca.checkTrigger=function(e,t,n,r,i,a){var o=i(this.properties[t]);null!=o&&o(n,r)&&a()},Ca.checkZOrderTrigger=function(e,t,n,r){var i=this;this.checkTrigger(e,t,n,r,function(e){return e.triggersZOrder},function(){i._private.cy.notify("zorder",e)})},Ca.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBounds},function(){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()})},Ca.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r)};var Sa={applyBypass:function(e,t,n,r){var i=[];if("*"===t||"**"===t){if(void 0!==n)for(var a=0;a<this.properties.length;a++){var o=this.properties[a].name,s=this.parse(o,n,!0);s&&i.push(s)}}else if(K(t)){var l=this.parse(t,n,!0);l&&i.push(l)}else{if(!B(t))return!1;var u=t;r=n;for(var c=Object.keys(u),h=0;h<c.length;h++){var d=c[h],p=u[d];if(void 0===p&&(p=u[C(d)]),void 0!==p){var f=this.parse(d,p,!0);f&&i.push(f)}}}if(0===i.length)return!1;for(var g=!1,v=0;v<e.length;v++){for(var y=e[v],m={},b=void 0,x=0;x<i.length;x++){var w=i[x];if(r){var E=y.pstyle(w.name);b=m[w.name]={prev:E}}g=this.applyParsedProperty(y,w)||g,r&&(b.next=y.pstyle(w.name))}g&&this.updateStyleHints(y),r&&this.updateTransitions(y,m,!0)}return g},overrideBypass:function(e,t,n){t=j(t);for(var r=0;r<e.length;r++){var i=e[r],a=i._private.style[t],o=this.properties[t].type,s=o.color,l=o.mutiple,u=a?null!=a.pfValue?a.pfValue:a.value:null;a&&a.bypass?(a.value=n,null!=a.pfValue&&(a.pfValue=n),a.strValue=s?"rgb("+n.join(",")+")":l?n.join(" "):""+n,this.updateStyleHints(i)):this.applyBypass(i,t,n),this.checkTriggers(i,t,u,n)}},removeAllBypasses:function(e,t){return this.removeBypasses(e,this.propertyNames,t)},removeBypasses:function(e,t,n){for(var r=0;r<e.length;r++){for(var i=e[r],a={},o=0;o<t.length;o++){var s=t[o],l=this.properties[s],u=i.pstyle(l.name);if(u&&u.bypass){var c=this.parse(s,"",!0),h=a[l.name]={prev:u};this.applyParsedProperty(i,c),h.next=i.pstyle(l.name)}}this.updateStyleHints(i),n&&this.updateTransitions(i,a,!0)}}},Da={getEmSizeInPixels:function(){var e=this.containerCss("font-size");return null!=e?parseFloat(e):1},containerCss:function(e){var t=this._private.cy.container();if(w&&t&&w.getComputedStyle)return w.getComputedStyle(t).getPropertyValue(e)}},Ta={getRenderedStyle:function(e,t){return t?this.getStylePropertyValue(e,t,!0):this.getRawStyle(e,!0)},getRawStyle:function(e,t){if(e=e[0]){for(var n={},r=0;r<this.properties.length;r++){var i=this.properties[r],a=this.getStylePropertyValue(e,i.name,t);null!=a&&(n[i.name]=a,n[C(i.name)]=a)}return n}},getIndexedStyle:function(e,t,n,r){var i=e.pstyle(t)[n][r];return null!=i?i:e.cy().style().getDefaultProperty(t)[n][0]},getStylePropertyValue:function(e,t,n){if(e=e[0]){var r=this.properties[t];r.alias&&(r=r.pointsTo);var i=r.type,a=e.pstyle(r.name);if(a){var o=a.value,s=a.units,l=a.strValue;if(n&&i.number&&null!=o&&$t(o)){var u=e.cy().zoom(),c=function(e){return e*u},h=function(e,t){return c(e)+t},d=G(o);return(d?s.every(function(e){return null!=e}):null!=s)?d?o.map(function(e,t){return h(e,s[t])}).join(" "):h(o,s):d?o.map(function(e){return K(e)?e:""+c(e)}).join(" "):""+c(o)}if(null!=l)return l}return null}},getAnimationStartStyle:function(e,t){for(var n={},r=0;r<t.length;r++){var i=t[r].name,a=e.pstyle(i);void 0!==a&&(a=B(a)?this.parse(i,a.strValue):this.parse(i,a)),a&&(n[i]=a)}return n},getPropsList:function(e){var t=[],n=e,r=this.properties;if(n)for(var i=Object.keys(n),a=0;a<i.length;a++){var o=i[a],s=n[o],l=r[o]||r[j(o)],u=this.parse(l.name,s);u&&t.push(u)}return t},getNonDefaultPropertiesHash:function(e,t,n){var r,i,a,o,s,l,u=n;for(s=0;s<t.length;s++)if(r=t[s],null!=(i=e.pstyle(r,!1)))if(null!=i.pfValue)u=oe(o,u);else for(a=i.strValue,l=0;l<a.length;l++)o=a.charCodeAt(l),u=oe(o,u);return u}};Ta.getPropertiesHash=Ta.getNonDefaultPropertiesHash;var Pa={appendFromJson:function(e){for(var t=0;t<e.length;t++){var n=e[t],r=n.selector,i=n.style||n.css,a=Object.keys(i);this.selector(r);for(var o=0;o<a.length;o++){var s=a[o],l=i[s];this.css(s,l)}}return this},fromJson:function(e){return this.resetToDefault(),this.appendFromJson(e),this},json:function(){for(var e=[],t=this.defaultLength;t<this.length;t++){for(var n=this[t],r=n.selector,i=n.properties,a={},o=0;o<i.length;o++){var s=i[o];a[s.name]=s.strValue}e.push({selector:r?r.toString():"core",style:a})}return e}},Ma={appendFromString:function(e){var t,n,r,i=""+e;function a(){i=i.length>t.length?i.substr(t.length):""}function o(){n=n.length>r.length?n.substr(r.length):""}for(i=i.replace(/[/][*](\s|.)+?[*][/]/g,"");;){if(i.match(/^\s*$/))break;var s=i.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!s){be("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+i);break}t=s[0];var l=s[1];if("core"!==l)if(new Cr(l).invalid){be("Skipping parsing of block: Invalid selector found in string stylesheet: "+l),a();continue}var u=s[2],c=!1;n=u;for(var h=[];;){if(n.match(/^\s*$/))break;var d=n.match(/^\s*(.+?)\s*:\s*(.+?)\s*;/);if(!d){be("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+u),c=!0;break}r=d[0];var p=d[1],f=d[2];if(this.properties[p])this.parse(p,f)?h.push({name:p,val:f}):be("Skipping property: Invalid property definition in: "+r),o();else be("Skipping property: Invalid property name in: "+r),o()}if(c){a();break}this.selector(l);for(var g=0;g<h.length;g++){var v=h[g];this.css(v.name,v.val)}a()}return this},fromString:function(e){return this.resetToDefault(),this.appendFromString(e),this}},_a={};!function(){var n=W,e=function(e){return"^"+e+"\\s*\\(\\s*([\\w\\.]+)\\s*\\)$"},t=function(e){var t=n+"|\\w+|rgb[a]?\\((?:(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%]?)\\s*,\\s*(?:(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%]?)\\s*,\\s*(?:(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%]?)(?:\\s*,\\s*(?:(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))))?\\)|hsl[a]?\\((?:(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?)))\\s*,\\s*(?:(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])\\s*,\\s*(?:(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])(?:\\s*,\\s*(?:(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))))?\\)|\\#[0-9a-fA-F]{3}|\\#[0-9a-fA-F]{6}";return"^"+e+"\\s*\\(([\\w\\.]+)\\s*\\,\\s*("+n+")\\s*\\,\\s*("+n+")\\s*,\\s*("+t+")\\s*\\,\\s*("+t+")\\)$"},r=["^url\\s*\\(\\s*['\"]?(.+?)['\"]?\\s*\\)$","^(none)$","^(.+)$"];_a.types={time:{number:!0,min:0,units:"s|ms",implicitUnits:"ms"},percent:{number:!0,min:0,max:100,units:"%",implicitUnits:"%"},percentages:{number:!0,min:0,max:100,units:"%",implicitUnits:"%",multiple:!0},zeroOneNumber:{number:!0,min:0,max:1,unitless:!0},zeroOneNumbers:{number:!0,min:0,max:1,unitless:!0,multiple:!0},nOneOneNumber:{number:!0,min:-1,max:1,unitless:!0},nonNegativeInt:{number:!0,min:0,integer:!0,unitless:!0},position:{enums:["parent","origin"]},nodeSize:{number:!0,min:0,enums:["label"]},number:{number:!0,unitless:!0},numbers:{number:!0,unitless:!0,multiple:!0},positiveNumber:{number:!0,unitless:!0,min:0,strictMin:!0},size:{number:!0,min:0},bidirectionalSize:{number:!0},bidirectionalSizes:{number:!0,multiple:!0},sizeMaybePercent:{number:!0,min:0,allowPercent:!0},paddingRelativeTo:{enums:["width","height","average","min","max"]},bgWH:{number:!0,min:0,allowPercent:!0,enums:["auto"],multiple:!0},bgPos:{number:!0,allowPercent:!0,multiple:!0},bgRelativeTo:{enums:["inner","include-padding"],multiple:!0},bgRepeat:{enums:["repeat","repeat-x","repeat-y","no-repeat"],multiple:!0},bgFit:{enums:["none","contain","cover"],multiple:!0},bgCrossOrigin:{enums:["anonymous","use-credentials"],multiple:!0},bgClip:{enums:["none","node"]},color:{color:!0},colors:{color:!0,multiple:!0},fill:{enums:["solid","linear-gradient","radial-gradient"]},bool:{enums:["yes","no"]},lineStyle:{enums:["solid","dotted","dashed"]},lineCap:{enums:["butt","round","square"]},borderStyle:{enums:["solid","dotted","dashed","double"]},curveStyle:{enums:["bezier","unbundled-bezier","haystack","segments","straight"]},fontFamily:{regex:'^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$'},fontStyle:{enums:["italic","normal","oblique"]},fontWeight:{enums:["normal","bold","bolder","lighter","100","200","300","400","500","600","800","900",100,200,300,400,500,600,700,800,900]},textDecoration:{enums:["none","underline","overline","line-through"]},textTransform:{enums:["none","uppercase","lowercase"]},textWrap:{enums:["none","wrap","ellipsis"]},textBackgroundShape:{enums:["rectangle","roundrectangle","round-rectangle"]},nodeShape:{enums:["rectangle","roundrectangle","round-rectangle","cutrectangle","cut-rectangle","bottomroundrectangle","bottom-round-rectangle","barrel","ellipse","triangle","square","pentagon","hexagon","concavehexagon","concave-hexagon","heptagon","octagon","tag","star","diamond","vee","rhomboid","polygon"]},compoundIncludeLabels:{enums:["include","exclude"]},arrowShape:{enums:["tee","triangle","triangle-tee","triangle-cross","triangle-backcurve","vee","square","circle","diamond","chevron","none"]},arrowFill:{enums:["filled","hollow"]},display:{enums:["element","none"]},visibility:{enums:["hidden","visible"]},zCompoundDepth:{enums:["bottom","orphan","auto","top"]},zIndexCompare:{enums:["auto","manual"]},valign:{enums:["top","center","bottom"]},halign:{enums:["left","center","right"]},text:{string:!0},data:{mapping:!0,regex:e("data")},layoutData:{mapping:!0,regex:e("layoutData")},scratch:{mapping:!0,regex:e("scratch")},mapData:{mapping:!0,regex:t("mapData")},mapLayoutData:{mapping:!0,regex:t("mapLayoutData")},mapScratch:{mapping:!0,regex:t("mapScratch")},fn:{mapping:!0,fn:!0},url:{regexes:r,singleRegexMatchValue:!0},urls:{regexes:r,singleRegexMatchValue:!0,multiple:!0},propList:{propList:!0},angle:{number:!0,units:"deg|rad",implicitUnits:"rad"},textRotation:{number:!0,units:"deg|rad",implicitUnits:"rad",enums:["none","autorotate"]},polygonPointList:{number:!0,multiple:!0,evenMultiple:!0,min:-1,max:1,unitless:!0},edgeDistances:{enums:["intersection","node-position"]},edgeEndpoint:{number:!0,multiple:!0,units:"%|px|em|deg|rad",implicitUnits:"px",enums:["inside-to-node","outside-to-node","outside-to-node-or-label","outside-to-line","outside-to-line-or-label"],singleEnum:!0,validate:function(e,t){switch(e.length){case 2:return"deg"!==t[0]&&"rad"!==t[0]&&"deg"!==t[1]&&"rad"!==t[1];case 1:return K(e[0])||"deg"===t[0]||"rad"===t[0];default:return!1}}},easing:{regexes:["^(spring)\\s*\\(\\s*("+n+")\\s*,\\s*("+n+")\\s*\\)$","^(cubic-bezier)\\s*\\(\\s*("+n+")\\s*,\\s*("+n+")\\s*,\\s*("+n+")\\s*,\\s*("+n+")\\s*\\)$"],enums:["linear","ease","ease-in","ease-out","ease-in-out","ease-in-sine","ease-out-sine","ease-in-out-sine","ease-in-quad","ease-out-quad","ease-in-out-quad","ease-in-cubic","ease-out-cubic","ease-in-out-cubic","ease-in-quart","ease-out-quart","ease-in-out-quart","ease-in-quint","ease-out-quint","ease-in-out-quint","ease-in-expo","ease-out-expo","ease-in-out-expo","ease-in-circ","ease-out-circ","ease-in-out-circ"]},gradientDirection:{enums:["to-bottom","to-top","to-left","to-right","to-bottom-right","to-bottom-left","to-top-right","to-top-left","to-right-bottom","to-left-bottom","to-right-top","to-left-top"]}};var i={zeroNonZero:function(e,t){return(null==e||null==t)&&e!==t||(0==e&&0!=t||0!=e&&0==t)},any:function(e,t){return e!=t}},a=_a.types,o=[{name:"label",type:a.text,triggersBounds:i.any},{name:"text-rotation",type:a.textRotation,triggersBounds:i.any},{name:"text-margin-x",type:a.bidirectionalSize,triggersBounds:i.any},{name:"text-margin-y",type:a.bidirectionalSize,triggersBounds:i.any}],s=[{name:"source-label",type:a.text,triggersBounds:i.any},{name:"source-text-rotation",type:a.textRotation,triggersBounds:i.any},{name:"source-text-margin-x",type:a.bidirectionalSize,triggersBounds:i.any},{name:"source-text-margin-y",type:a.bidirectionalSize,triggersBounds:i.any},{name:"source-text-offset",type:a.size,triggersBounds:i.any}],l=[{name:"target-label",type:a.text,triggersBounds:i.any},{name:"target-text-rotation",type:a.textRotation,triggersBounds:i.any},{name:"target-text-margin-x",type:a.bidirectionalSize,triggersBounds:i.any},{name:"target-text-margin-y",type:a.bidirectionalSize,triggersBounds:i.any},{name:"target-text-offset",type:a.size,triggersBounds:i.any}],u=[{name:"font-family",type:a.fontFamily,triggersBounds:i.any},{name:"font-style",type:a.fontStyle,triggersBounds:i.any},{name:"font-weight",type:a.fontWeight,triggersBounds:i.any},{name:"font-size",type:a.size,triggersBounds:i.any},{name:"text-transform",type:a.textTransform,triggersBounds:i.any},{name:"text-wrap",type:a.textWrap,triggersBounds:i.any},{name:"text-max-width",type:a.size,triggersBounds:i.any},{name:"text-outline-width",type:a.size,triggersBounds:i.any}],c=[{name:"text-valign",type:a.valign,triggersBounds:i.any},{name:"text-halign",type:a.halign,triggersBounds:i.any},{name:"color",type:a.color},{name:"text-outline-color",type:a.color},{name:"text-outline-opacity",type:a.zeroOneNumber},{name:"text-background-color",type:a.color},{name:"text-background-opacity",type:a.zeroOneNumber},{name:"text-background-padding",type:a.size,triggersBounds:i.any},{name:"text-border-opacity",type:a.zeroOneNumber},{name:"text-border-color",type:a.color},{name:"text-border-width",type:a.size,triggersBounds:i.any},{name:"text-border-style",type:a.borderStyle,triggersBounds:i.any},{name:"text-background-shape",type:a.textBackgroundShape,triggersBounds:i.any}],h=[{name:"events",type:a.bool},{name:"text-events",type:a.bool}],d=[{name:"display",type:a.display,triggersZOrder:i.any,triggersBounds:i.any},{name:"visibility",type:a.visibility,triggersZOrder:i.any},{name:"opacity",type:a.zeroOneNumber,triggersZOrder:i.zeroNonZero},{name:"text-opacity",type:a.zeroOneNumber},{name:"min-zoomed-font-size",type:a.size},{name:"z-compound-depth",type:a.zCompoundDepth,triggersZOrder:i.any},{name:"z-index-compare",type:a.zIndexCompare,triggersZOrder:i.any},{name:"z-index",type:a.nonNegativeInt,triggersZOrder:i.any}],p=[{name:"overlay-padding",type:a.size,triggersBounds:i.any},{name:"overlay-color",type:a.color},{name:"overlay-opacity",type:a.zeroOneNumber,triggersBounds:i.zeroNonZero}],f=[{name:"transition-property",type:a.propList},{name:"transition-duration",type:a.time},{name:"transition-delay",type:a.time},{name:"transition-timing-function",type:a.easing}],g=[{name:"height",type:a.nodeSize,triggersBounds:i.any},{name:"width",type:a.nodeSize,triggersBounds:i.any},{name:"shape",type:a.nodeShape,triggersBounds:i.any},{name:"shape-polygon-points",type:a.polygonPointList,triggersBounds:i.any},{name:"background-color",type:a.color},{name:"background-fill",type:a.fill},{name:"background-opacity",type:a.zeroOneNumber},{name:"background-blacken",type:a.nOneOneNumber},{name:"background-gradient-stop-colors",type:a.colors},{name:"background-gradient-stop-positions",type:a.percentages},{name:"background-gradient-direction",type:a.gradientDirection},{name:"padding",type:a.sizeMaybePercent,triggersBounds:i.any},{name:"padding-relative-to",type:a.paddingRelativeTo,triggersBounds:i.any}],v=[{name:"border-color",type:a.color},{name:"border-opacity",type:a.zeroOneNumber},{name:"border-width",type:a.size,triggersBounds:i.any},{name:"border-style",type:a.borderStyle}],y=[{name:"background-image",type:a.urls},{name:"background-image-crossorigin",type:a.bgCrossOrigin},{name:"background-image-opacity",type:a.zeroOneNumbers},{name:"background-position-x",type:a.bgPos},{name:"background-position-y",type:a.bgPos},{name:"background-width-relative-to",type:a.bgRelativeTo},{name:"background-height-relative-to",type:a.bgRelativeTo},{name:"background-repeat",type:a.bgRepeat},{name:"background-fit",type:a.bgFit},{name:"background-clip",type:a.bgClip},{name:"background-width",type:a.bgWH},{name:"background-height",type:a.bgWH}],m=[{name:"position",type:a.position,triggersBounds:i.any},{name:"compound-sizing-wrt-labels",type:a.compoundIncludeLabels,triggersBounds:i.any},{name:"min-width",type:a.size,triggersBounds:i.any},{name:"min-width-bias-left",type:a.sizeMaybePercent,triggersBounds:i.any},{name:"min-width-bias-right",type:a.sizeMaybePercent,triggersBounds:i.any},{name:"min-height",type:a.size,triggersBounds:i.any},{name:"min-height-bias-top",type:a.sizeMaybePercent,triggersBounds:i.any},{name:"min-height-bias-bottom",type:a.sizeMaybePercent,triggersBounds:i.any}],b=[{name:"line-style",type:a.lineStyle},{name:"line-color",type:a.color},{name:"line-fill",type:a.fill},{name:"line-cap",type:a.lineCap},{name:"line-dash-pattern",type:a.numbers},{name:"line-dash-offset",type:a.number},{name:"line-gradient-stop-colors",type:a.colors},{name:"line-gradient-stop-positions",type:a.percentages},{name:"curve-style",type:a.curveStyle,triggersBounds:i.any},{name:"haystack-radius",type:a.zeroOneNumber,triggersBounds:i.any},{name:"source-endpoint",type:a.edgeEndpoint,triggersBounds:i.any},{name:"target-endpoint",type:a.edgeEndpoint,triggersBounds:i.any},{name:"control-point-step-size",type:a.size,triggersBounds:i.any},{name:"control-point-distances",type:a.bidirectionalSizes,triggersBounds:i.any},{name:"control-point-weights",type:a.numbers,triggersBounds:i.any},{name:"segment-distances",type:a.bidirectionalSizes,triggersBounds:i.any},{name:"segment-weights",type:a.numbers,triggersBounds:i.any},{name:"edge-distances",type:a.edgeDistances,triggersBounds:i.any},{name:"arrow-scale",type:a.positiveNumber,triggersBounds:i.any},{name:"loop-direction",type:a.angle,triggersBounds:i.any},{name:"loop-sweep",type:a.angle,triggersBounds:i.any},{name:"source-distance-from-node",type:a.size,triggersBounds:i.any},{name:"target-distance-from-node",type:a.size,triggersBounds:i.any}],x=[{name:"ghost",type:a.bool,triggersBounds:i.any},{name:"ghost-offset-x",type:a.bidirectionalSize,triggersBounds:i.any},{name:"ghost-offset-y",type:a.bidirectionalSize,triggersBounds:i.any},{name:"ghost-opacity",type:a.zeroOneNumber}],w=[{name:"selection-box-color",type:a.color},{name:"selection-box-opacity",type:a.zeroOneNumber},{name:"selection-box-border-color",type:a.color},{name:"selection-box-border-width",type:a.size},{name:"active-bg-color",type:a.color},{name:"active-bg-opacity",type:a.zeroOneNumber},{name:"active-bg-size",type:a.size},{name:"outside-texture-bg-color",type:a.color},{name:"outside-texture-bg-opacity",type:a.zeroOneNumber}],E=[];_a.pieBackgroundN=16,E.push({name:"pie-size",type:a.sizeMaybePercent});for(var k=1;k<=_a.pieBackgroundN;k++)E.push({name:"pie-"+k+"-background-color",type:a.color}),E.push({name:"pie-"+k+"-background-size",type:a.percent}),E.push({name:"pie-"+k+"-background-opacity",type:a.zeroOneNumber});var C=[],S=_a.arrowPrefixes=["source","mid-source","target","mid-target"];[{name:"arrow-shape",type:a.arrowShape},{name:"arrow-color",type:a.color},{name:"arrow-fill",type:a.arrowFill}].forEach(function(r){S.forEach(function(e){var t=e+"-"+r.name,n=r.type;C.push({name:t,type:n})})},{});var D=_a.properties=h.concat(f,d,p,x,c,u,o,s,l,g,v,y,E,m,b,C,w),T=_a.propertyGroups={behavior:h,transition:f,visibility:d,overlay:p,ghost:x,commonLabel:c,labelDimensions:u,mainLabel:o,sourceLabel:s,targetLabel:l,nodeBody:g,nodeBorder:v,backgroundImage:y,pie:E,compound:m,edgeLine:b,edgeArrow:C,core:w},P=_a.propertyGroupNames={};(_a.propertyGroupKeys=Object.keys(T)).forEach(function(t){P[t]=T[t].map(function(e){return e.name}),T[t].forEach(function(e){return e.groupKey=t})});var M=_a.aliases=[{name:"content",pointsTo:"label"},{name:"control-point-distance",pointsTo:"control-point-distances"},{name:"control-point-weight",pointsTo:"control-point-weights"},{name:"edge-text-rotation",pointsTo:"text-rotation"},{name:"padding-left",pointsTo:"padding"},{name:"padding-right",pointsTo:"padding"},{name:"padding-top",pointsTo:"padding"},{name:"padding-bottom",pointsTo:"padding"}];_a.propertyNames=D.map(function(e){return e.name});for(var _=0;_<D.length;_++){var B=D[_];D[B.name]=B}for(var N=0;N<M.length;N++){var I=M[N],A=D[I.pointsTo],L={name:I.name,alias:!0,pointsTo:A};D.push(L),D[I.name]=L}}(),_a.getDefaultProperty=function(e){return this.getDefaultProperties()[e]},_a.getDefaultProperties=function(){var e=this._private;if(null!=e.defaultProperties)return e.defaultProperties;for(var t=S({"selection-box-color":"#ddd","selection-box-opacity":.65,"selection-box-border-color":"#aaa","selection-box-border-width":1,"active-bg-color":"black","active-bg-opacity":.15,"active-bg-size":30,"outside-texture-bg-color":"#000","outside-texture-bg-opacity":.125,events:"yes","text-events":"no","text-valign":"top","text-halign":"center",color:"#000","text-outline-color":"#000","text-outline-width":0,"text-outline-opacity":1,"text-opacity":1,"text-decoration":"none","text-transform":"none","text-wrap":"none","text-max-width":9999,"text-background-color":"#000","text-background-opacity":0,"text-background-shape":"rectangle","text-background-padding":0,"text-border-opacity":0,"text-border-width":0,"text-border-style":"solid","text-border-color":"#000","font-family":"Helvetica Neue, Helvetica, sans-serif","font-style":"normal","font-weight":"normal","font-size":16,"min-zoomed-font-size":0,"text-rotation":"none","source-text-rotation":"none","target-text-rotation":"none",visibility:"visible",display:"element",opacity:1,"z-compound-depth":"auto","z-index-compare":"auto","z-index":0,label:"","text-margin-x":0,"text-margin-y":0,"source-label":"","source-text-offset":0,"source-text-margin-x":0,"source-text-margin-y":0,"target-label":"","target-text-offset":0,"target-text-margin-x":0,"target-text-margin-y":0,"overlay-opacity":0,"overlay-color":"#000","overlay-padding":10,"transition-property":"none","transition-duration":0,"transition-delay":0,"transition-timing-function":"linear","background-blacken":0,"background-color":"#999","background-fill":"solid","background-opacity":1,"background-image":"none","background-image-crossorigin":"anonymous","background-image-opacity":1,"background-position-x":"50%","background-position-y":"50%","background-width-relative-to":"include-padding","background-height-relative-to":"include-padding","background-repeat":"no-repeat","background-fit":"none","background-clip":"node","background-width":"auto","background-height":"auto","border-color":"#000","border-opacity":1,"border-width":0,"border-style":"solid",height:30,width:30,shape:"ellipse","shape-polygon-points":"-1, -1, 1, -1, 1, 1, -1, 1","background-gradient-direction":"to-bottom","background-gradient-stop-colors":"#999","background-gradient-stop-positions":"0%",ghost:"no","ghost-offset-y":0,"ghost-offset-x":0,"ghost-opacity":0,padding:0,"padding-relative-to":"width",position:"origin","compound-sizing-wrt-labels":"include","min-width":0,"min-width-bias-left":0,"min-width-bias-right":0,"min-height":0,"min-height-bias-top":0,"min-height-bias-bottom":0},{"pie-size":"100%"},[{name:"pie-{{i}}-background-color",value:"black"},{name:"pie-{{i}}-background-size",value:"0%"},{name:"pie-{{i}}-background-opacity",value:1}].reduce(function(e,t){for(var n=1;n<=_a.pieBackgroundN;n++){var r=t.name.replace("{{i}}",n),i=t.value;e[r]=i}return e},{}),{"line-style":"solid","line-color":"#999","line-fill":"solid","line-cap":"butt","line-gradient-stop-colors":"#999","line-gradient-stop-positions":"0%","control-point-step-size":40,"control-point-weights":.5,"segment-weights":.5,"segment-distances":20,"edge-distances":"intersection","curve-style":"haystack","haystack-radius":0,"arrow-scale":1,"loop-direction":"-45deg","loop-sweep":"-90deg","source-distance-from-node":0,"target-distance-from-node":0,"source-endpoint":"outside-to-node","target-endpoint":"outside-to-node","line-dash-pattern":[6,3],"line-dash-offset":0},[{name:"arrow-shape",value:"none"},{name:"arrow-color",value:"#999"},{name:"arrow-fill",value:"filled"}].reduce(function(r,i){return _a.arrowPrefixes.forEach(function(e){var t=e+"-"+i.name,n=i.value;r[t]=n}),r},{})),n={},r=0;r<this.properties.length;r++){var i=this.properties[r];if(!i.pointsTo){var a=i.name,o=t[a],s=this.parse(a,o);n[a]=s}}return e.defaultProperties=n,e.defaultProperties},_a.addDefaultStylesheet=function(){this.selector(":parent").css({shape:"rectangle",padding:10,"background-color":"#eee","border-color":"#ccc","border-width":1}).selector("edge").css({width:3}).selector(":loop").css({"curve-style":"bezier"}).selector("edge:compound").css({"curve-style":"bezier","source-endpoint":"outside-to-line","target-endpoint":"outside-to-line"}).selector(":selected").css({"background-color":"#0169D9","line-color":"#0169D9","source-arrow-color":"#0169D9","target-arrow-color":"#0169D9","mid-source-arrow-color":"#0169D9","mid-target-arrow-color":"#0169D9"}).selector(":parent:selected").css({"background-color":"#CCE1F9","border-color":"#aec8e5"}).selector(":active").css({"overlay-color":"black","overlay-padding":10,"overlay-opacity":.25}),this.defaultLength=this.length};var Ba={parse:function(e,t,n,r){if(X(t))return this.parseImplWarn(e,t,n,r);var i,a=ue(e,""+t,n?"t":"f","mapping"===r||!0===r||!1===r||null==r?"dontcare":r),o=this.propCache=this.propCache||[];return(i=o[a])||(i=o[a]=this.parseImplWarn(e,t,n,r)),(n||"mapping"===r)&&(i=xe(i))&&(i.value=xe(i.value)),i},parseImplWarn:function(e,t,n,r){var i=this.parseImpl(e,t,n,r);return i||null==t||be("The style property `".concat(e,": ").concat(t,"` is invalid")),i}};Ba.parseImpl=function(t,n,r,e){t=j(t);var i=this.properties[t],a=n,o=this.types;if(!i)return null;if(void 0===n)return null;i.alias&&(i=i.pointsTo,t=i.name);var s=K(n);s&&(n=n.trim());var l,u,c=i.type;if(!c)return null;if(r&&(""===n||null===n))return{name:t,value:n,bypass:!0,deleteBypass:!0};if(X(n))return{name:t,value:n,strValue:"fn",mapped:o.fn,bypass:r};if(!s||e||n.length<7||"a"!==n[1]);else{if(7<=n.length&&"d"===n[0]&&(l=new RegExp(o.data.regex).exec(n))){if(r)return!1;var h=o.data;return{name:t,value:l,strValue:""+n,mapped:h,field:l[1],bypass:r}}if(10<=n.length&&"m"===n[0]&&(u=new RegExp(o.mapData.regex).exec(n))){if(r)return!1;if(c.multiple)return!1;var d=o.mapData;if(!c.color&&!c.number)return!1;var p=this.parse(t,u[4]);if(!p||p.mapped)return!1;var f=this.parse(t,u[5]);if(!f||f.mapped)return!1;if(p.pfValue===f.pfValue||p.strValue===f.strValue)return be("`"+t+": "+n+"` is not a valid mapper because the output range is zero; converting to `"+t+": "+p.strValue+"`"),this.parse(t,p.strValue);if(c.color){var g=p.value,v=f.value;if(!(g[0]!==v[0]||g[1]!==v[1]||g[2]!==v[2]||g[3]!==v[3]&&(null!=g[3]&&1!==g[3]||null!=v[3]&&1!==v[3])))return!1}return{name:t,value:u,strValue:""+n,mapped:d,field:u[1],fieldMin:parseFloat(u[2]),fieldMax:parseFloat(u[3]),valueMin:p.value,valueMax:f.value,bypass:r}}}if(c.multiple&&"multiple"!==e){var y;if(y=s?n.split(/\s+/):G(n)?n:[n],c.evenMultiple&&y.length%2!=0)return null;for(var m=[],b=[],x=[],w="",E=!1,k=0;k<y.length;k++){var C=this.parse(t,y[k],r,"multiple");E=E||K(C.value),m.push(C.value),x.push(null!=C.pfValue?C.pfValue:C.value),b.push(C.units),w+=(0<k?" ":"")+C.strValue}return c.validate&&!c.validate(m,b)?null:c.singleEnum&&E?1===m.length&&K(m[0])?{name:t,value:m[0],strValue:m[0],bypass:r}:null:{name:t,value:m,pfValue:x,strValue:w,bypass:r,units:b}}var S,D,T=function(){for(var e=0;e<c.enums.length;e++){if(c.enums[e]===n)return{name:t,value:n,strValue:""+n,bypass:r}}return null};if(c.number){var P,M="px";if(c.units&&(P=c.units),c.implicitUnits&&(M=c.implicitUnits),!c.unitless)if(s){var _="px|em"+(c.allowPercent?"|\\%":"");P&&(_=P);var B=n.match("^("+W+")("+_+")?$");B&&(n=B[1],P=B[2]||M)}else P&&!c.implicitUnits||(P=M);if(n=parseFloat(n),isNaN(n)&&void 0===c.enums)return null;if(isNaN(n)&&void 0!==c.enums)return n=a,T();if(c.integer&&(!$t(D=n)||Math.floor(D)!==D))return null;if(void 0!==c.min&&(n<c.min||c.strictMin&&n===c.min)||void 0!==c.max&&(n>c.max||c.strictMax&&n===c.max))return null;var N={name:t,value:n,strValue:""+n+(P||""),units:P,bypass:r};return c.unitless||"px"!==P&&"em"!==P?N.pfValue=n:N.pfValue="px"!==P&&P?this.getEmSizeInPixels()*n:n,"ms"!==P&&"s"!==P||(N.pfValue="ms"===P?n:1e3*n),"deg"!==P&&"rad"!==P||(N.pfValue="rad"===P?n:(S=n,Math.PI*S/180)),"%"===P&&(N.pfValue=n/100),N}if(c.propList){var I=[],A=""+n;if("none"===A);else{for(var L=A.split(/\s*,\s*|\s+/),z=0;z<L.length;z++){var O=L[z].trim();this.properties[O]?I.push(O):be("`"+O+"` is not a valid property name")}if(0===I.length)return null}return{name:t,value:I,strValue:0===I.length?"none":I.join(" "),bypass:r}}if(c.color){var R=H(n);return R?{name:t,value:R,pfValue:R,strValue:"rgb("+R[0]+","+R[1]+","+R[2]+")",bypass:r}:null}if(c.regex||c.regexes){if(c.enums){var F=T();if(F)return F}for(var V=c.regexes?c.regexes:[c.regex],q=0;q<V.length;q++){var Y=new RegExp(V[q]).exec(n);if(Y)return{name:t,value:c.singleRegexMatchValue?Y[1]:Y,strValue:""+n,bypass:r}}return null}return c.string?{name:t,value:""+n,strValue:""+n,bypass:r}:c.enums?T():null};var Na=function e(t){if(!(this instanceof e))return new e(t);y(t)?(this._private={cy:t,coreStyle:{}},this.length=0,this.resetToDefault()):me("A style must have a core reference")},Ia=Na.prototype;Ia.instanceString=function(){return"style"},Ia.clear=function(){for(var e=0;e<this.length;e++)this[e]=void 0;return this.length=0,this._private.newStyle=!0,this},Ia.resetToDefault=function(){return this.clear(),this.addDefaultStylesheet(),this},Ia.core=function(e){return this._private.coreStyle[e]||this.getDefaultProperty(e)},Ia.selector=function(e){var t="core"===e?null:new Cr(e),n=this.length++;return this[n]={selector:t,properties:[],mappedProperties:[],index:n},this},Ia.css=function(){var e=arguments;if(1===e.length)for(var t=e[0],n=0;n<this.properties.length;n++){var r=this.properties[n],i=t[r.name];void 0===i&&(i=t[C(r.name)]),void 0!==i&&this.cssRule(r.name,i)}else 2===e.length&&this.cssRule(e[0],e[1]);return this},Ia.style=Ia.css,Ia.cssRule=function(e,t){var n=this.parse(e,t);if(n){var r=this.length-1;this[r].properties.push(n),(this[r].properties[n.name]=n).name.match(/pie-(\d+)-background-size/)&&n.value&&(this._private.hasPie=!0),n.mapped&&this[r].mappedProperties.push(n),!this[r].selector&&(this._private.coreStyle[n.name]=n)}return this},Ia.append=function(e){return d(e)?e.appendToStyle(this):G(e)?this.appendFromJson(e):K(e)&&this.appendFromString(e),this},Na.fromJson=function(e,t){var n=new Na(e);return n.fromJson(t),n},Na.fromString=function(e,t){return new Na(e).fromString(t)},[Ca,Sa,Da,Ta,Pa,Ma,_a,Ba].forEach(function(e){S(Ia,e)}),Na.types=Ia.types,Na.properties=Ia.properties,Na.propertyGroups=Ia.propertyGroups,Na.propertyGroupNames=Ia.propertyGroupNames,Na.propertyGroupKeys=Ia.propertyGroupKeys;var Aa={style:function(e){e&&this.setStyle(e).update();return this._private.style},setStyle:function(e){var t=this._private;return d(e)?t.style=e.generateStyle(this):G(e)?t.style=Na.fromJson(this,e):K(e)?t.style=Na.fromString(this,e):t.style=Na(this),t.style}},La={autolock:function(e){return void 0===e?this._private.autolock:(this._private.autolock=!!e,this)},autoungrabify:function(e){return void 0===e?this._private.autoungrabify:(this._private.autoungrabify=!!e,this)},autounselectify:function(e){return void 0===e?this._private.autounselectify:(this._private.autounselectify=!!e,this)},selectionType:function(e){var t=this._private;return null==t.selectionType&&(t.selectionType="single"),void 0===e?t.selectionType:("additive"!==e&&"single"!==e||(t.selectionType=e),this)},panningEnabled:function(e){return void 0===e?this._private.panningEnabled:(this._private.panningEnabled=!!e,this)},userPanningEnabled:function(e){return void 0===e?this._private.userPanningEnabled:(this._private.userPanningEnabled=!!e,this)},zoomingEnabled:function(e){return void 0===e?this._private.zoomingEnabled:(this._private.zoomingEnabled=!!e,this)},userZoomingEnabled:function(e){return void 0===e?this._private.userZoomingEnabled:(this._private.userZoomingEnabled=!!e,this)},boxSelectionEnabled:function(e){return void 0===e?this._private.boxSelectionEnabled:(this._private.boxSelectionEnabled=!!e,this)},pan:function(){var e,t,n,r,i,a=arguments,o=this._private.pan;switch(a.length){case 0:return o;case 1:if(K(a[0]))return o[e=a[0]];if(B(a[0])){if(!this._private.panningEnabled)return this;r=(n=a[0]).x,i=n.y,$t(r)&&(o.x=r),$t(i)&&(o.y=i),this.emit("pan viewport")}break;case 2:if(!this._private.panningEnabled)return this;e=a[0],t=a[1],"x"!==e&&"y"!==e||!$t(t)||(o[e]=t),this.emit("pan viewport")}return this.notify("viewport"),this},panBy:function(e,t){var n,r,i,a,o,s=arguments,l=this._private.pan;if(!this._private.panningEnabled)return this;switch(s.length){case 1:B(e)&&(a=(i=s[0]).x,o=i.y,$t(a)&&(l.x+=a),$t(o)&&(l.y+=o),this.emit("pan viewport"));break;case 2:r=t,"x"!==(n=e)&&"y"!==n||!$t(r)||(l[n]+=r),this.emit("pan viewport")}return this.notify("viewport"),this},fit:function(e,t){var n=this.getFitViewport(e,t);if(n){var r=this._private;r.zoom=n.zoom,r.pan=n.pan,this.emit("pan zoom viewport"),this.notify("viewport")}return this},getFitViewport:function(e,t){if($t(e)&&void 0===t&&(t=e,e=void 0),this._private.panningEnabled&&this._private.zoomingEnabled){var n,r;if(K(e)){var i=e;e=this.$(i)}else if(B(r=e)&&$t(r.x1)&&$t(r.x2)&&$t(r.y1)&&$t(r.y2)){var a=e;(n={x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2}).w=n.x2-n.x1,n.h=n.y2-n.y1}else Z(e)||(e=this.mutableElements());if(!Z(e)||!e.empty()){n=n||e.boundingBox();var o,s=this.width(),l=this.height();if(t=$t(t)?t:0,!isNaN(s)&&!isNaN(l)&&0<s&&0<l&&!isNaN(n.w)&&!isNaN(n.h)&&0<n.w&&0<n.h)return{zoom:o=(o=(o=Math.min((s-2*t)/n.w,(l-2*t)/n.h))>this._private.maxZoom?this._private.maxZoom:o)<this._private.minZoom?this._private.minZoom:o,pan:{x:(s-o*(n.x1+n.x2))/2,y:(l-o*(n.y1+n.y2))/2}}}}},zoomRange:function(e,t){var n=this._private;if(null==t){var r=e;e=r.min,t=r.max}return $t(e)&&$t(t)&&e<=t?(n.minZoom=e,n.maxZoom=t):$t(e)&&void 0===t&&e<=n.maxZoom?n.minZoom=e:$t(t)&&void 0===e&&t>=n.minZoom&&(n.maxZoom=t),this},minZoom:function(e){return void 0===e?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return void 0===e?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var t,n,r=this._private,i=r.pan,a=r.zoom,o=!1;if(r.zoomingEnabled||(o=!0),$t(e)?n=e:B(e)&&(n=e.level,null!=e.position?t=Ze(e.position,a,i):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||r.panningEnabled||(o=!0)),n=(n=n>r.maxZoom?r.maxZoom:n)<r.minZoom?r.minZoom:n,o||!$t(n)||n===a||null!=t&&(!$t(t.x)||!$t(t.y)))return null;if(null==t)return{zoomed:!0,panned:!1,zoom:n,pan:i};var s=i,l=a,u=n;return{zoomed:!0,panned:!0,zoom:u,pan:{x:-u/l*(t.x-s.x)+t.x,y:-u/l*(t.y-s.y)+t.y}}},zoom:function(e){if(void 0===e)return this._private.zoom;var t=this.getZoomedViewport(e),n=this._private;return null!=t&&t.zoomed&&(n.zoom=t.zoom,t.panned&&(n.pan.x=t.pan.x,n.pan.y=t.pan.y),this.emit("zoom"+(t.panned?" pan":"")+" viewport"),this.notify("viewport")),this},viewport:function(e){var t=this._private,n=!0,r=!0,i=[],a=!1,o=!1;if(!e)return this;if($t(e.zoom)||(n=!1),B(e.pan)||(r=!1),!n&&!r)return this;if(n){var s=e.zoom;s<t.minZoom||s>t.maxZoom||!t.zoomingEnabled?a=!0:(t.zoom=s,i.push("zoom"))}if(r&&(!a||!e.cancelOnFailedZoom)&&t.panningEnabled){var l=e.pan;$t(l.x)&&(t.pan.x=l.x,o=!1),$t(l.y)&&(t.pan.y=l.y,o=!1),o||i.push("pan")}return 0<i.length&&(i.push("viewport"),this.emit(i.join(" ")),this.notify("viewport")),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,t){if(this._private.panningEnabled){if(K(e)){var n=e;e=this.mutableElements().filter(n)}else Z(e)||(e=this.mutableElements());if(0!==e.length){var r=e.boundingBox(),i=this.width(),a=this.height();return{x:(i-(t=void 0===t?this._private.zoom:t)*(r.x1+r.x2))/2,y:(a-t*(r.y1+r.y2))/2}}}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled&&this.viewport({pan:{x:0,y:0},zoom:1}),this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var t,e,n=this._private,r=n.container;return n.sizeCache=n.sizeCache||(r?(t=w.getComputedStyle(r),e=function(e){return parseFloat(t.getPropertyValue(e))},{width:r.clientWidth-e("padding-left")-e("padding-right"),height:r.clientHeight-e("padding-top")-e("padding-bottom")}):{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,t=this._private.zoom,n=this.renderedExtent(),r={x1:(n.x1-e.x)/t,x2:(n.x2-e.x)/t,y1:(n.y1-e.y)/t,y2:(n.y2-e.y)/t};return r.w=r.x2-r.x1,r.h=r.y2-r.y1,r},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}}};La.centre=La.center,La.autolockNodes=La.autolock,La.autoungrabifyNodes=La.autoungrabify;var za=function(e){var a=this,t=(e=S({},e)).container;t&&!c(t)&&c(t[0])&&(t=t[0]);var r=t?t._cyreg:null;(r=r||{})&&r.cy&&(r.cy.destroy(),r={});var i=r.readies=r.readies||[];t&&(t._cyreg=r),r.cy=a;var n=void 0!==w&&void 0!==t&&!e.headless,o=e;o.layout=S({name:n?"grid":"null"},o.layout),o.renderer=S({name:n?"canvas":"null"},o.renderer);var s=function(e,t,n){return void 0!==t?t:void 0!==n?n:e},l=this._private={container:t,ready:!1,options:o,elements:new ea(this),listeners:[],aniEles:new ea(this),scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:s(!0,o.zoomingEnabled),userZoomingEnabled:s(!0,o.userZoomingEnabled),panningEnabled:s(!0,o.panningEnabled),userPanningEnabled:s(!0,o.userPanningEnabled),boxSelectionEnabled:s(!0,o.boxSelectionEnabled),autolock:s(!1,o.autolock,o.autolockNodes),autoungrabify:s(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:s(!1,o.autounselectify),styleEnabled:void 0===o.styleEnabled?n:o.styleEnabled,zoom:$t(o.zoom)?o.zoom:1,pan:{x:B(o.pan)&&$t(o.pan.x)?o.pan.x:0,y:B(o.pan)&&$t(o.pan.y)?o.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom});l.styleEnabled&&a.setStyle([]);var u=S({},o,o.renderer);a.initRenderer(u);!function(e,t){if(e.some(p))return Rn.all(e).then(t);t(e)}([o.style,o.elements],function(e){var t=e[0],n=e[1];l.styleEnabled&&a.style().append(t),function(e,t,n){a.notifications(!1);var r=a.mutableElements();0<r.length&&r.remove(),null!=e&&(B(e)||G(e))&&a.add(e),a.one("layoutready",function(e){a.notifications(!0),a.emit(e),a.one("load",t),a.emitAndNotify("load")}).one("layoutstop",function(){a.one("done",n),a.emit("done")});var i=S({},a._private.options.layout);i.eles=a.elements(),a.layout(i).run()}(n,function(){a.startAnimationLoop(),l.ready=!0,X(o.ready)&&a.on("ready",o.ready);for(var e=0;e<i.length;e++){var t=i[e];a.on("ready",t)}r&&(r.readies=[]),a.emit("ready")},o.done)})},Oa=za.prototype;S(Oa,{instanceString:function(){return"core"},isReady:function(){return this._private.ready},isDestroyed:function(){return this._private.destroyed},ready:function(e){return this.isReady()?this.emitter().emit("ready",[],e):this.on("ready",e),this},destroy:function(){if(!this.isDestroyed())return this.stopAnimationLoop(),this.destroyRenderer(),this.emit("destroy"),this._private.destroyed=!0,this},hasElementWithId:function(e){return this._private.elements.hasElementWithId(e)},getElementById:function(e){return this._private.elements.getElementById(e)},hasCompoundNodes:function(){return this._private.hasCompoundNodes},headless:function(){return this._private.renderer.isHeadless()},styleEnabled:function(){return this._private.styleEnabled},addToPool:function(e){return this._private.elements.merge(e),this},removeFromPool:function(e){return this._private.elements.unmerge(e),this},container:function(){return this._private.container||null},mount:function(e,t){if(null!=e){var n=this._private,r=n.options,i=t||{name:"canvas"};return r.renderer=i,!c(e)&&c(e[0])&&(e=e[0]),this.stopAnimationLoop(),this.destroyRenderer(),n.container=e,n.styleEnabled=!0,this.initRenderer(i),this.startAnimationLoop(),this.style(r.style),this.emit("mount"),this}},unmount:function(){return this.stopAnimationLoop(),this.destroyRenderer(),this.initRenderer({name:"null"}),this.emit("unmount"),this},options:function(){return xe(this._private.options)},json:function(e){var d=this,t=d._private,n=d.mutableElements();if(B(e)){if(d.startBatch(),e.elements){var p={},r=function(e,t){for(var n=[],r=[],i=0;i<e.length;i++){var a=e[i],o=a.data.id,s=d.getElementById(o);p[o]=!0,0!==s.length?r.push({ele:s,json:a}):(t&&(a.group=t),n.push(a))}d.add(n);for(var l=0;l<r.length;l++){var u=r[l],c=u.ele,h=u.json;c.json(h)}};if(G(e.elements))r(e.elements);else for(var i=["nodes","edges"],a=0;a<i.length;a++){var o=i[a],s=e.elements[o];G(s)&&r(s,o)}var l=d.collection();n.filter(function(e){return!p[e.id()]}).forEach(function(e){e.isParent()?l.merge(e):e.remove()}),l.forEach(function(e){return e.children().move({parent:null})}),l.forEach(function(e){return(t=e,d.getElementById(t.id())).remove();var t})}e.style&&d.style(e.style),null!=e.zoom&&e.zoom!==t.zoom&&d.zoom(e.zoom),e.pan&&(e.pan.x===t.pan.x&&e.pan.y===t.pan.y||d.pan(e.pan));for(var u=["minZoom","maxZoom","zoomingEnabled","userZoomingEnabled","panningEnabled","userPanningEnabled","boxSelectionEnabled","autolock","autoungrabify","autounselectify"],c=0;c<u.length;c++){var h=u[c];null!=e[h]&&d[h](e[h])}return d.endBatch(),this}var f={};!!e?f.elements=this.elements().map(function(e){return e.json()}):(f.elements={},n.forEach(function(e){var t=e.group();f.elements[t]||(f.elements[t]=[]),f.elements[t].push(e.json())})),this._private.styleEnabled&&(f.style=d.style().json());var g=t.options;return f.zoomingEnabled=t.zoomingEnabled,f.userZoomingEnabled=t.userZoomingEnabled,f.zoom=t.zoom,f.minZoom=t.minZoom,f.maxZoom=t.maxZoom,f.panningEnabled=t.panningEnabled,f.userPanningEnabled=t.userPanningEnabled,f.pan=xe(t.pan),f.boxSelectionEnabled=t.boxSelectionEnabled,f.renderer=xe(g.renderer),f.hideEdgesOnViewport=g.hideEdgesOnViewport,f.textureOnViewport=g.textureOnViewport,f.wheelSensitivity=g.wheelSensitivity,f.motionBlur=g.motionBlur,f},scratch:qn.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0}),removeScratch:qn.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0})}),Oa.$id=Oa.getElementById,[na,fa,ya,ma,ba,xa,Ea,ka,Aa,La].forEach(function(e){S(Oa,e)});var Ra={fit:!0,directed:!1,padding:30,circle:!1,grid:!1,spacingFactor:1.75,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,roots:void 0,maximal:!1,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}},Fa=function(e){return e.scratch("breadthfirst")},Va=function(e,t){return e.scratch("breadthfirst",t)};function qa(e){this.options=S({},Ra,e)}var Ya={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!(qa.prototype.run=function(){var i,e=this.options,c=e,t=e.cy,f=c.eles,h=f.nodes().filter(function(e){return!e.isParent()}),n=f,r=c.directed,a=c.maximal||0<c.maximalAdjustments,d=at(c.boundingBox?c.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});if(Z(c.roots))i=c.roots;else if(G(c.roots)){for(var o=[],s=0;s<c.roots.length;s++){var l=c.roots[s],u=t.getElementById(l);o.push(u)}i=t.collection(o)}else if(K(c.roots))i=t.$(c.roots);else if(r)i=h.roots();else{var p=f.components();i=t.collection();for(var g=function(e){var t=p[e],n=t.maxDegree(!1),r=t.filter(function(e){return e.degree(!1)===n});i=i.add(r)},v=0;v<p.length;v++)g(v)}var y=[],m={},b=function(e,t){null==y[t]&&(y[t]=[]);var n=y[t].length;y[t].push(e),Va(e,{index:n,depth:t})};n.bfs({roots:i,directed:c.directed,visit:function(e,t,n,r,i){var a=e[0],o=a.id();b(a,i),m[o]=!0}});for(var x=[],w=0;w<h.length;w++){var E=h[w];m[E.id()]||x.push(E)}var k=function(e){for(var t=y[e],n=0;n<t.length;n++){var r=t[n];null!=r?Va(r,{depth:e,index:n}):(t.splice(n,1),n--)}},C=function(){for(var e=0;e<y.length;e++)k(e)},S=function(e,t){for(var n,r,i,a,o,s=Fa(e),l=e.incomers().filter(function(e){return e.isNode()&&f.has(e)}),u=-1,c=e.id(),h=0;h<l.length;h++){var d=l[h],p=Fa(d);u=Math.max(u,p.depth)}return s.depth<=u&&(t[c]?null:(r=u+1,i=Fa(n=e),a=i.depth,o=i.index,y[a][o]=null,b(n,r),t[c]=!0))};if(r&&a){var D=[],T={},P=function(e){return D.push(e)};for(h.forEach(function(e){return D.push(e)});0<D.length;){var M=D.shift(),_=S(M,T);if(_)M.outgoers().filter(function(e){return e.isNode()&&f.has(e)}).forEach(P);else if(null===_){be("Detected double maximal shift for node `"+M.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}C();var B=0;if(c.avoidOverlap)for(var N=0;N<h.length;N++){var I=h[N].layoutDimensions(c),A=I.w,L=I.h;B=Math.max(B,A,L)}for(var z={},O=function(e){if(z[e.id()])return z[e.id()];for(var t=Fa(e).depth,n=e.neighborhood(),r=0,i=0,a=0;a<n.length;a++){var o=n[a];if(!o.isEdge()&&!o.isParent()&&h.has(o)){var s=Fa(o),l=s.index,u=s.depth;if(null!=l&&null!=u){var c=y[u].length;u<t&&(r+=l/(c-1),i++)}}}return r/=i=Math.max(1,i),0===i&&(r=0),z[e.id()]=r},R=function(e,t){var n=O(e)-O(t);return 0===n?U(e.id(),t.id()):n},F=0;F<y.length;F++)y[F].sort(R),k(F);for(var V=[],q=0;q<x.length;q++)V.push(x[q]);y.unshift(V),C();for(var Y=0,X=0;X<y.length;X++)Y=Math.max(y[X].length,Y);var j=d.x1+d.w/2,W=d.x1+d.h/2,H=y.reduce(function(e,t){return Math.max(e,t.length)},0);return h.layoutPositions(this,c,function(e){var t=Fa(e),n=t.depth,r=t.index,i=y[n].length,a=Math.max(d.w/((c.grid?H:i)+1),B),o=Math.max(d.h/(y.length+1),B),s=Math.min(d.w/2/y.length,d.h/2/y.length);if(s=Math.max(s,B),c.circle){var l=s*n+s-(0<y.length&&y[0].length<=3?s/2:0),u=2*Math.PI/y[n].length*r;return 0===n&&1===y[0].length&&(l=1),{x:j+l*Math.cos(u),y:W+l*Math.sin(u)}}return{x:j+(r+1-(i+1)/2)*a,y:(n+1)*o}}),this}),spacingFactor:void 0,radius:void 0,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function Xa(e){this.options=S({},Ya,e)}Xa.prototype.run=function(){var e=this.options,a=e,t=e.cy,n=a.eles,o=void 0!==a.counterclockwise?!a.counterclockwise:a.clockwise,r=n.nodes().not(":parent");a.sort&&(r=r.sort(a.sort));for(var s,i=at(a.boundingBox?a.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()}),l=i.x1+i.w/2,u=i.y1+i.h/2,c=(void 0===a.sweep?2*Math.PI-2*Math.PI/r.length:a.sweep)/Math.max(1,r.length-1),h=0,d=0;d<r.length;d++){var p=r[d].layoutDimensions(a),f=p.w,g=p.h;h=Math.max(h,f,g)}if(s=$t(a.radius)?a.radius:r.length<=1?0:Math.min(i.h,i.w)/2-h,1<r.length&&a.avoidOverlap){h*=1.75;var v=Math.cos(c)-Math.cos(0),y=Math.sin(c)-Math.sin(0),m=Math.sqrt(h*h/(v*v+y*y));s=Math.max(m,s)}return r.layoutPositions(this,a,function(e,t){var n=a.startAngle+t*c*(o?1:-1),r=s*Math.cos(n),i=s*Math.sin(n);return{x:l+r,y:u+i}}),this};var ja,Wa={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function Ha(e){this.options=S({},Wa,e)}var Ka={ready:function(){},stop:function(){},animate:!0,animationEasing:void 0,animationDuration:void 0,animateFilter:function(e,t){return!0},animationThreshold:250,refresh:20,fit:!0,padding:30,boundingBox:void 0,nodeDimensionsIncludeLabels:!(Ha.prototype.run=function(){for(var e=this.options,t=e,n=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,r=e.cy,i=t.eles.nodes().not(":parent"),a=at(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),o=a.x1+a.w/2,s=a.y1+a.h/2,l=[],u=0,c=0;c<i.length;c++){var h,d=i[c];h=t.concentric(d),l.push({value:h,node:d}),d._private.scratch.concentric=h}i.updateStyle();for(var p=0;p<i.length;p++){var f=i[p].layoutDimensions(t);u=Math.max(u,f.w,f.h)}l.sort(function(e,t){return t.value-e.value});for(var g=t.levelWidth(i),v=[[]],y=v[0],m=0;m<l.length;m++){var b=l[m];if(0<y.length)g<=Math.abs(y[0].value-b.value)&&(y=[],v.push(y));y.push(b)}var x=u+t.minNodeSpacing;if(!t.avoidOverlap){var w=0<v.length&&1<v[0].length,E=(Math.min(a.w,a.h)/2-x)/(v.length+w?1:0);x=Math.min(x,E)}for(var k=0,C=0;C<v.length;C++){var S=v[C],D=void 0===t.sweep?2*Math.PI-2*Math.PI/S.length:t.sweep,T=S.dTheta=D/Math.max(1,S.length-1);if(1<S.length&&t.avoidOverlap){var P=Math.cos(T)-Math.cos(0),M=Math.sin(T)-Math.sin(0),_=Math.sqrt(x*x/(P*P+M*M));k=Math.max(_,k)}S.r=k,k+=x}if(t.equidistant){for(var B=0,N=0,I=0;I<v.length;I++){var A=v[I].r-N;B=Math.max(B,A)}for(var L=N=0;L<v.length;L++){var z=v[L];0===L&&(N=z.r),z.r=N,N+=B}}for(var O={},R=0;R<v.length;R++)for(var F=v[R],V=F.dTheta,q=F.r,Y=0;Y<F.length;Y++){var X=F[Y],j=t.startAngle+(n?1:-1)*V*Y,W={x:o+q*Math.cos(j),y:s+q*Math.sin(j)};O[X.node.id()]=W}return i.layoutPositions(this,t,function(e){var t=e.id();return O[t]}),this}),randomize:!1,componentSpacing:40,nodeRepulsion:function(e){return 2048},nodeOverlap:4,idealEdgeLength:function(e){return 32},edgeElasticity:function(e){return 32},nestingFactor:1.2,gravity:1,numIter:1e3,initialTemp:1e3,coolingFactor:.99,minTemp:1,weaver:!1};function Ga(e){this.options=S({},Ka,e),this.options.layout=this}Ga.prototype.run=function(){var t=this.options,n=t.cy,e=this,r=this.thread,i=t.weaver?t.weaver.Thread:null,x={listeners:[],on:function(e,t){return this.listeners.push({event:e,callback:t}),this},trigger:function(t){K(t)&&(t={type:t});var e=function(e){e.callback(t)};return this.listeners.filter(function(e){return e.event===t.type}).forEach(e),this},pass:function(e){return this.pass=e,this},run:function(t){var n=this.pass;return new Rn(function(e){e(t(n))})},stop:function(){return this},stopped:function(){return!0}};r&&!r.stopped()||(r=this.thread=i?new i:x),!(e.stopped=!1)!==t.animate&&!1!==t.animate||e.emit({type:"layoutstart",layout:e}),ja=!0===t.debug;var a=Za(n,e,t);ja&&(void 0)(a),t.randomize&&Qa(a,n);var o=Date.now(),s=!1,l=function(e){e=e||{},s&&!e.next||!e.force&&Date.now()-o<t.animationThreshold||(s=!0,ne(function(){Ja(a,n,t),!0===t.fit&&n.fit(t.padding),s=!1,e.next&&e.next()}))};r.on("message",function(e){var t=e.message;a.layoutNodes=t,l()}),r.pass({layoutInfo:a,options:{animate:t.animate,refresh:t.refresh,componentSpacing:t.componentSpacing,nodeOverlap:t.nodeOverlap,nestingFactor:t.nestingFactor,gravity:t.gravity,numIter:t.numIter,initialTemp:t.initialTemp,coolingFactor:t.coolingFactor,minTemp:t.minTemp}}).run(function(e){var t,n,v=e.layoutInfo,r=e.options,i=function(e,t){for(var n=0;n<e.graphSet.length;n++)for(var r=e.graphSet[n],i=r.length,a=0;a<i;a++)for(var o=e.layoutNodes[e.idToIndex[r[a]]],s=a+1;s<i;s++){var l=e.layoutNodes[e.idToIndex[r[s]]];u(o,l,e,t)}},y=function(e){return-e+2*e*Math.random()},u=function(e,t,n,r){if(e.cmptId===t.cmptId||n.isCompound){var i=t.positionX-e.positionX,a=t.positionY-e.positionY;0===i&&0===a&&(i=y(1),a=y(1));var o=m(e,t,i,a);if(0<o)var s=(u=r.nodeOverlap*o)*i/(g=Math.sqrt(i*i+a*a)),l=u*a/g;else{var u,c=b(e,i,a),h=b(t,-1*i,-1*a),d=h.x-c.x,p=h.y-c.y,f=d*d+p*p,g=Math.sqrt(f);s=(u=(e.nodeRepulsion+t.nodeRepulsion)/f)*d/g,l=u*p/g}e.isLocked||(e.offsetX-=s,e.offsetY-=l),t.isLocked||(t.offsetX+=s,t.offsetY+=l)}},m=function(e,t,n,r){if(0<n)var i=e.maxX-t.minX;else i=t.maxX-e.minX;if(0<r)var a=e.maxY-t.minY;else a=t.maxY-e.minY;return 0<=i&&0<=a?Math.sqrt(i*i+a*a):0},b=function(e,t,n){var r=e.positionX,i=e.positionY,a=e.height||1,o=e.width||1,s=n/t,l=a/o,u={};return 0===t&&0<n?(u.x=r,u.y=i+a/2):0===t&&n<0?(u.x=r,u.y=i+a/2):0<t&&-1*l<=s&&s<=l?(u.x=r+o/2,u.y=i+o*n/2/t):t<0&&-1*l<=s&&s<=l?(u.x=r-o/2,u.y=i-o*n/2/t):0<n&&(s<=-1*l||l<=s)?(u.x=r+a*t/2/n,u.y=i+a/2):n<0&&(s<=-1*l||l<=s)&&(u.x=r-a*t/2/n,u.y=i-a/2),u},a=function(e,t){for(var n=0;n<e.edgeSize;n++){var r=e.layoutEdges[n],i=e.idToIndex[r.sourceId],a=e.layoutNodes[i],o=e.idToIndex[r.targetId],s=e.layoutNodes[o],l=s.positionX-a.positionX,u=s.positionY-a.positionY;if(0!==l||0!==u){var c=b(a,l,u),h=b(s,-1*l,-1*u),d=h.x-c.x,p=h.y-c.y,f=Math.sqrt(d*d+p*p),g=Math.pow(r.idealLength-f,2)/r.elasticity;if(0!==f)var v=g*d/f,y=g*p/f;else v=0,y=0;a.isLocked||(a.offsetX+=v,a.offsetY+=y),s.isLocked||(s.offsetX-=v,s.offsetY-=y)}}},o=function(e,t){for(var n=0;n<e.graphSet.length;n++){var r=e.graphSet[n],i=r.length;if(0===n)var a=e.clientHeight/2,o=e.clientWidth/2;else{var s=e.layoutNodes[e.idToIndex[r[0]]],l=e.layoutNodes[e.idToIndex[s.parentId]];a=l.positionX,o=l.positionY}for(var u=0;u<i;u++){var c=e.layoutNodes[e.idToIndex[r[u]]];if(!c.isLocked){var h=a-c.positionX,d=o-c.positionY,p=Math.sqrt(h*h+d*d);if(1<p){var f=t.gravity*h/p,g=t.gravity*d/p;c.offsetX+=f,c.offsetY+=g}}}}},s=function(e,t){var n=[],r=0,i=-1;for(n.push.apply(n,e.graphSet[0]),i+=e.graphSet[0].length;r<=i;){var a=n[r++],o=e.idToIndex[a],s=e.layoutNodes[o],l=s.children;if(0<l.length&&!s.isLocked){for(var u=s.offsetX,c=s.offsetY,h=0;h<l.length;h++){var d=e.layoutNodes[e.idToIndex[l[h]]];d.offsetX+=u,d.offsetY+=c,n[++i]=l[h]}s.offsetX=0,s.offsetY=0}}},l=function(e,t){for(var n=0;n<e.nodeSize;n++){0<(i=e.layoutNodes[n]).children.length&&(i.maxX=void 0,i.minX=void 0,i.maxY=void 0,i.minY=void 0)}for(n=0;n<e.nodeSize;n++){if(!(0<(i=e.layoutNodes[n]).children.length||i.isLocked)){var r=c(i.offsetX,i.offsetY,e.temperature);i.positionX+=r.x,i.positionY+=r.y,i.offsetX=0,i.offsetY=0,i.minX=i.positionX-i.width,i.maxX=i.positionX+i.width,i.minY=i.positionY-i.height,i.maxY=i.positionY+i.height,h(i,e)}}for(n=0;n<e.nodeSize;n++){var i;0<(i=e.layoutNodes[n]).children.length&&!i.isLocked&&(i.positionX=(i.maxX+i.minX)/2,i.positionY=(i.maxY+i.minY)/2,i.width=i.maxX-i.minX,i.height=i.maxY-i.minY)}},c=function(e,t,n){var r=Math.sqrt(e*e+t*t);if(n<r)var i={x:n*e/r,y:n*t/r};else i={x:e,y:t};return i},h=function e(t,n){var r=t.parentId;if(null!=r){var i=n.layoutNodes[n.idToIndex[r]],a=!1;return(null==i.maxX||t.maxX+i.padRight>i.maxX)&&(i.maxX=t.maxX+i.padRight,a=!0),(null==i.minX||t.minX-i.padLeft<i.minX)&&(i.minX=t.minX-i.padLeft,a=!0),(null==i.maxY||t.maxY+i.padBottom>i.maxY)&&(i.maxY=t.maxY+i.padBottom,a=!0),(null==i.minY||t.minY-i.padTop<i.minY)&&(i.minY=t.minY-i.padTop,a=!0),a?e(i,n):void 0}},d=function(e){var t,n;return i(t=v,n=r),a(t,n),o(t,n),s(t,n),l(t,n),v.temperature=v.temperature*r.coolingFactor,!(v.temperature<r.minTemp)},p=0;do{for(var f=0;(f<r.refresh||0===r.refresh)&&p<r.numIter;){var g;if(!(g=d()))break;f++,p++}!0===r.animate&&(t=v.layoutNodes,void 0,n={type:"message",message:t},x.trigger(n))}while(g&&p+1<r.numIter);return function(e,t){for(var n=v.layoutNodes,r=[],i=0;i<n.length;i++){var a=n[i],o=a.cmptId;(r[o]=r[o]||[]).push(a)}var s=0;for(i=0;i<r.length;i++)if(g=r[i]){g.x1=1/0,g.x2=-1/0,g.y1=1/0,g.y2=-1/0;for(var l=0;l<g.length;l++){var u=g[l];g.x1=Math.min(g.x1,u.positionX-u.width/2),g.x2=Math.max(g.x2,u.positionX+u.width/2),g.y1=Math.min(g.y1,u.positionY-u.height/2),g.y2=Math.max(g.y2,u.positionY+u.height/2)}g.w=g.x2-g.x1,g.h=g.y2-g.y1,s+=g.w*g.h}r.sort(function(e,t){return t.w*t.h-e.w*e.h});var c=0,h=0,d=0,p=0,f=Math.sqrt(s)*v.clientWidth/v.clientHeight;for(i=0;i<r.length;i++){var g;if(g=r[i]){for(l=0;l<g.length;l++)(u=g[l]).isLocked||(u.positionX+=c,u.positionY+=h);c+=g.w+t.componentSpacing,d+=g.w+t.componentSpacing,p=Math.max(p,g.h),f<d&&(h+=p+t.componentSpacing,p=d=c=0)}}}(0,r),v}).then(function(e){a.layoutNodes=e.layoutNodes,r.stop(),u()});var u=function(){!0===t.animate||!1===t.animate?l({force:!0,next:function(){e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e})}}):t.eles.nodes().layoutPositions(e,t,function(e){var t=a.layoutNodes[a.idToIndex[e.data("id")]];return{x:t.positionX,y:t.positionY}})};return this},Ga.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this};var Za=function(e,t,n){for(var r=n.eles.edges(),i=n.eles.nodes(),a={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:r.size(),temperature:n.initialTemp,clientWidth:e.width(),clientHeight:e.width(),boundingBox:at(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()})},o=n.eles.components(),s={},l=0;l<o.length;l++)for(var u=o[l],c=0;c<u.length;c++){s[u[c].id()]=l}for(l=0;l<a.nodeSize;l++){var h=(v=i[l]).layoutDimensions(n);(N={}).isLocked=v.locked(),N.id=v.data("id"),N.parentId=v.data("parent"),N.cmptId=s[v.id()],N.children=[],N.positionX=v.position("x"),N.positionY=v.position("y"),N.offsetX=0,N.offsetY=0,N.height=h.w,N.width=h.h,N.maxX=N.positionX+N.width/2,N.minX=N.positionX-N.width/2,N.maxY=N.positionY+N.height/2,N.minY=N.positionY-N.height/2,N.padLeft=parseFloat(v.style("padding")),N.padRight=parseFloat(v.style("padding")),N.padTop=parseFloat(v.style("padding")),N.padBottom=parseFloat(v.style("padding")),N.nodeRepulsion=X(n.nodeRepulsion)?n.nodeRepulsion(v):n.nodeRepulsion,a.layoutNodes.push(N),a.idToIndex[N.id]=l}var d=[],p=0,f=-1,g=[];for(l=0;l<a.nodeSize;l++){var v,y=(v=a.layoutNodes[l]).parentId;null!=y?a.layoutNodes[a.idToIndex[y]].children.push(v.id):(d[++f]=v.id,g.push(v.id))}for(a.graphSet.push(g);p<=f;){var m=d[p++],b=a.idToIndex[m],x=a.layoutNodes[b].children;if(0<x.length){a.graphSet.push(x);for(l=0;l<x.length;l++)d[++f]=x[l]}}for(l=0;l<a.graphSet.length;l++){var w=a.graphSet[l];for(c=0;c<w.length;c++){var E=a.idToIndex[w[c]];a.indexToGraph[E]=l}}for(l=0;l<a.edgeSize;l++){var k=r[l],C={};C.id=k.data("id"),C.sourceId=k.data("source"),C.targetId=k.data("target");var S=X(n.idealEdgeLength)?n.idealEdgeLength(k):n.idealEdgeLength,D=X(n.edgeElasticity)?n.edgeElasticity(k):n.edgeElasticity,T=a.idToIndex[C.sourceId],P=a.idToIndex[C.targetId];if(a.indexToGraph[T]!=a.indexToGraph[P]){for(var M=Ua(C.sourceId,C.targetId,a),_=a.graphSet[M],B=0,N=a.layoutNodes[T];-1===_.indexOf(N.id);)N=a.layoutNodes[a.idToIndex[N.parentId]],B++;for(N=a.layoutNodes[P];-1===_.indexOf(N.id);)N=a.layoutNodes[a.idToIndex[N.parentId]],B++;S*=B*n.nestingFactor}C.idealLength=S,C.elasticity=D,a.layoutEdges.push(C)}return a},Ua=function(e,t,n){var r=$a(e,t,0,n);return r.count<2?0:r.graph},$a=function e(t,n,r,i){var a=i.graphSet[r];if(-1<a.indexOf(t)&&-1<a.indexOf(n))return{count:2,graph:r};for(var o=0,s=0;s<a.length;s++){var l=a[s],u=i.idToIndex[l],c=i.layoutNodes[u].children;if(0!==c.length){var h=e(t,n,i.indexToGraph[i.idToIndex[c[0]]],i);if(0!==h.count){if(1!==h.count)return h;if(2===++o)break}}}return{count:o,graph:r}},Qa=function(e,t){for(var n=e.clientWidth,r=e.clientHeight,i=0;i<e.nodeSize;i++){var a=e.layoutNodes[i];0!==a.children.length||a.isLocked||(a.positionX=Math.random()*n,a.positionY=Math.random()*r)}},Ja=function(a,e,o){var t=o.layout,n=o.eles.nodes(),s=a.boundingBox,l={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0};o.boundingBox&&(n.forEach(function(e){var t=a.layoutNodes[a.idToIndex[e.data("id")]];l.x1=Math.min(l.x1,t.positionX),l.x2=Math.max(l.x2,t.positionX),l.y1=Math.min(l.y1,t.positionY),l.y2=Math.max(l.y2,t.positionY)}),l.w=l.x2-l.x1,l.h=l.y2-l.y1),n.positions(function(e,t){var n=a.layoutNodes[a.idToIndex[e.data("id")]];if(o.boundingBox){var r=(n.positionX-l.x1)/l.w,i=(n.positionY-l.y1)/l.h;return{x:s.x1+r*s.w,y:s.y1+i*s.h}}return{x:n.positionX,y:n.positionY}}),!0!==a.ready&&(a.ready=!0,t.one("layoutready",o.ready),t.emit({type:"layoutready",layout:this}))},eo={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!(Ga.prototype.destroy=function(){return this.thread&&this.thread.stop(),this}),spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function to(e){this.options=S({},eo,e)}to.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles.nodes().not(":parent");t.sort&&(r=r.sort(t.sort));var a=at(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(0===a.h||0===a.w)r.layoutPositions(this,t,function(e){return{x:a.x1,y:a.y1}});else{var i=r.size(),o=Math.sqrt(i*a.h/a.w),s=Math.round(o),l=Math.round(a.w/a.h*o),u=function(e){if(null==e)return Math.min(s,l);Math.min(s,l)==s?s=e:l=e},c=function(e){if(null==e)return Math.max(s,l);Math.max(s,l)==s?s=e:l=e},h=t.rows,d=null!=t.cols?t.cols:t.columns;if(null!=h&&null!=d)s=h,l=d;else if(null!=h&&null==d)s=h,l=Math.ceil(i/s);else if(null==h&&null!=d)l=d,s=Math.ceil(i/l);else if(i<l*s){var p=u(),f=c();i<=(p-1)*f?u(p-1):i<=(f-1)*p&&c(f-1)}else for(;l*s<i;){var g=u(),v=c();i<=(v+1)*g?c(v+1):u(g+1)}var y=a.w/l,m=a.h/s;if(t.condense&&(m=y=0),t.avoidOverlap)for(var b=0;b<r.length;b++){var x=r[b],w=x._private.position;null!=w.x&&null!=w.y||(w.x=0,w.y=0);var E=x.layoutDimensions(t),k=t.avoidOverlapPadding,C=E.w+k,S=E.h+k;y=Math.max(y,C),m=Math.max(m,S)}for(var D={},T=function(e,t){return!!D["c-"+e+"-"+t]},P=function(e,t){D["c-"+e+"-"+t]=!0},M=0,_=0,B=function(){l<=++_&&(_=0,M++)},N={},I=0;I<r.length;I++){var A=r[I],L=t.position(A);if(L&&(void 0!==L.row||void 0!==L.col)){var z={row:L.row,col:L.col};if(void 0===z.col)for(z.col=0;T(z.row,z.col);)z.col++;else if(void 0===z.row)for(z.row=0;T(z.row,z.col);)z.row++;N[A.id()]=z,P(z.row,z.col)}}r.layoutPositions(this,t,function(e,t){var n,r;if(e.locked()||e.isParent())return!1;var i=N[e.id()];if(i)n=i.col*y+y/2+a.x1,r=i.row*m+m/2+a.y1;else{for(;T(M,_);)B();n=_*y+y/2+a.x1,r=M*m+m/2+a.y1,P(M,_),B()}return{x:n,y:r}})}return this};var no={ready:function(){},stop:function(){}};function ro(e){this.options=S({},no,e)}ro.prototype.run=function(){var e=this.options,t=e.eles;e.cy;return this.emit("layoutstart"),t.nodes().positions(function(){return{x:0,y:0}}),this.one("layoutready",e.ready),this.emit("layoutready"),this.one("layoutstop",e.stop),this.emit("layoutstop"),this};var io={positions:void 0,zoom:void 0,pan:void 0,fit:!0,padding:30,animate:!(ro.prototype.stop=function(){return this}),animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function ao(e){this.options=S({},io,e)}var oo={fit:!0,padding:30,boundingBox:void 0,animate:!(ao.prototype.run=function(){var r=this.options,e=r.eles.nodes(),i=X(r.positions);return e.layoutPositions(this,r,function(e,t){var n=function(e){if(null==r.positions)return null;if(i)return r.positions(e);var t=r.positions[e._private.data.id];return null==t?null:t}(e);return!e.locked()&&null!=n&&n}),this}),animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function so(e){this.options=S({},oo,e)}so.prototype.run=function(){var e=this.options,t=e.cy,n=e.eles.nodes().not(":parent"),r=at(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});return n.layoutPositions(this,e,function(e,t){return{x:r.x1+Math.round(Math.random()*r.w),y:r.y1+Math.round(Math.random()*r.h)}}),this};var lo=[{name:"breadthfirst",impl:qa},{name:"circle",impl:Xa},{name:"concentric",impl:Ha},{name:"cose",impl:Ga},{name:"grid",impl:to},{name:"null",impl:ro},{name:"preset",impl:ao},{name:"random",impl:so}];function uo(e){this.options=e,this.notifications=0}var co=function(){};uo.prototype={recalculateRenderedStyle:co,notify:function(){this.notifications++},init:co,isHeadless:function(){return!0}};var ho={arrowShapeWidth:.3,registerArrowShapes:function(){var n=this.arrowShapes={},l=this,r=function(e,t,n,r,i,a,o){var s=i.x-n/2-o,l=i.x+n/2+o,u=i.y-n/2-o,c=i.y+n/2+o;return s<=e&&e<=l&&u<=t&&t<=c},u=function(e,t,n,r,i){var a=e*Math.cos(r)-t*Math.sin(r),o=(e*Math.sin(r)+t*Math.cos(r))*n;return{x:a*n+i.x,y:o+i.y}},c=function(e,t,n,r){for(var i=[],a=0;a<e.length;a+=2){var o=e[a],s=e[a+1];i.push(u(o,s,t,n,r))}return i},h=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r.x,r.y)}return t},i=function(e){return e.pstyle("width").pfValue*e.pstyle("arrow-scale").pfValue*2},e=function(e,t){K(t)&&(t=n[t]),n[e]=S({name:e,points:[-.15,-.3,.15,-.3,.15,.3,-.15,.3],collide:function(e,t,n,r,i,a){var o=h(c(this.points,n+2*a,r,i));return ft(e,t,o)},roughCollide:r,draw:function(e,t,n,r){var i=c(this.points,t,n,r);l.arrowShapeImpl("polygon")(e,i)},spacing:function(e){return 0},gap:i},t)};e("none",{collide:ge,roughCollide:ge,draw:ye,spacing:ve,gap:ve}),e("triangle",{points:[-.15,-.3,0,0,.15,-.3]}),e("arrow","triangle"),e("triangle-backcurve",{points:n.triangle.points,controlPoint:[0,-.15],roughCollide:r,draw:function(e,t,n,r,i){var a=c(this.points,t,n,r),o=this.controlPoint,s=u(o[0],o[1],t,n,r);l.arrowShapeImpl(this.name)(e,a,s)},gap:function(e){return.8*i(e)}}),e("triangle-tee",{points:[0,0,.15,-.3,-.15,-.3,0,0],pointsTee:[-.15,-.4,-.15,-.5,.15,-.5,.15,-.4],collide:function(e,t,n,r,i,a,o){var s=h(c(this.points,n+2*o,r,i)),l=h(c(this.pointsTee,n+2*o,r,i));return ft(e,t,s)||ft(e,t,l)},draw:function(e,t,n,r,i){var a=c(this.points,t,n,r),o=c(this.pointsTee,t,n,r);l.arrowShapeImpl(this.name)(e,a,o)}}),e("triangle-cross",{points:[0,0,.15,-.3,-.15,-.3,0,0],baseCrossLinePts:[-.15,-.4,-.15,-.4,.15,-.4,.15,-.4],crossLinePts:function(e,t){var n=this.baseCrossLinePts.slice(),r=t/e;return n[3]=n[3]-r,n[5]=n[5]-r,n},collide:function(e,t,n,r,i,a,o){var s=h(c(this.points,n+2*o,r,i)),l=h(c(this.crossLinePts(n,a),n+2*o,r,i));return ft(e,t,s)||ft(e,t,l)},draw:function(e,t,n,r,i){var a=c(this.points,t,n,r),o=c(this.crossLinePts(t,i),t,n,r);l.arrowShapeImpl(this.name)(e,a,o)}}),e("vee",{points:[-.15,-.3,0,0,.15,-.3,0,-.15],gap:function(e){return.525*i(e)}}),e("circle",{radius:.15,collide:function(e,t,n,r,i,a,o){var s=i;return Math.pow(s.x-e,2)+Math.pow(s.y-t,2)<=Math.pow((n+2*o)*this.radius,2)},draw:function(e,t,n,r,i){l.arrowShapeImpl(this.name)(e,r.x,r.y,this.radius*t)},spacing:function(e){return l.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.radius}}),e("tee",{points:[-.15,0,-.15,-.1,.15,-.1,.15,0],spacing:function(e){return 1},gap:function(e){return 1}}),e("square",{points:[-.15,0,.15,0,.15,-.3,-.15,-.3]}),e("diamond",{points:[-.15,-.15,0,-.3,.15,-.15,0,0],gap:function(e){return e.pstyle("width").pfValue*e.pstyle("arrow-scale").value}}),e("chevron",{points:[0,0,-.15,-.15,-.1,-.2,0,-.1,.1,-.2,.15,-.15],gap:function(e){return.95*e.pstyle("width").pfValue*e.pstyle("arrow-scale").value}})}},po={projectIntoViewport:function(e,t){var n=this.cy,r=this.findContainerClientCoords(),i=r[0],a=r[1],o=r[4],s=n.pan(),l=n.zoom();return[((e-i)/o-s.x)/l,((t-a)/o-s.y)/l]},findContainerClientCoords:function(){if(this.containerBB)return this.containerBB;var e=this.container,t=e.getBoundingClientRect(),n=w.getComputedStyle(e),r=function(e){return parseFloat(n.getPropertyValue(e))},i=r("padding-left"),a=r("padding-right"),o=r("padding-top"),s=r("padding-bottom"),l=r("border-left-width"),u=r("border-right-width"),c=r("border-top-width"),h=(r("border-bottom-width"),e.clientWidth),d=e.clientHeight,p=i+a,f=o+s,g=l+u,v=t.width/(h+g),y=h-p,m=d-f,b=t.left+i+l,x=t.top+o+c;return this.containerBB=[b,x,y,m,v]},invalidateContainerClientCoordsCache:function(){this.containerBB=null},findNearestElement:function(e,t,n,r){return this.findNearestElements(e,t,n,r)[0]},findNearestElements:function(ee,te,e,t){var r,i,ne=this,re=this,n=re.getCachedZSortedEles(),ie=[],a=re.cy.zoom(),ae=re.cy.hasCompoundNodes(),oe=(t?24:8)/a,o=(t?8:2)/a,D=(t?8:2)/a,s=1/0;function se(e,t){if(e.isNode()){if(i)return;i=e,ie.push(e)}if(e.isEdge()&&(null==t||t<s))if(r){if(r.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value&&r.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value)for(var n=0;n<ie.length;n++)if(ie[n].isEdge()){ie[n]=e,r=e,s=null!=t?t:s;break}}else ie.push(e),r=e,s=null!=t?t:s}function le(e){var t=e.outerWidth()+2*o,n=e.outerHeight()+2*o,r=t/2,i=n/2,a=e.position();if(a.x-r<=ee&&ee<=a.x+r&&a.y-i<=te&&te<=a.y+i&&re.nodeShapes[ne.getNodeShape(e)].checkPoint(ee,te,0,t,n,a.x,a.y))return se(e,0),!0}function l(e){var t,n,r,i,a,o,s,l,u,c,h,d,p,f,g,v,y,m,b,x,w,E,k,C,S,D,T,P,M,_,B,N,I,A,L,z,O,R=e._private,F=R.rscratch,V=e.pstyle("width").pfValue,q=e.pstyle("arrow-scale").value,Y=V/2+oe,X=Y*Y,j=2*Y,W=R.source,H=R.target;if("segments"===F.edgeType||"straight"===F.edgeType||"haystack"===F.edgeType){for(var K=F.allpts,G=0;G+3<K.length;G+=2)if(T=ee,P=te,M=K[G],_=K[G+1],B=K[G+2],N=K[G+3],I=void 0,I=j,A=Math.min(M,B),L=Math.max(M,B),z=Math.min(_,N),O=Math.max(_,N),A-I<=T&&T<=L+I&&z-I<=P&&P<=O+I&&X>(g=ee,v=te,y=K[G],m=K[G+1],b=K[G+2],x=K[G+3],void 0,C=(w=[g-y,v-m])[0]*w[0]+w[1]*w[1],D=(S=w[0]*(E=[b-y,x-m])[0]+w[1]*E[1])*S/(k=E[0]*E[0]+E[1]*E[1]),t=S<0?C:k<D?(g-b)*(g-b)+(v-x)*(v-x):C-D))return se(e,t),!0}else if("bezier"===F.edgeType||"multibezier"===F.edgeType||"self"===F.edgeType||"compound"===F.edgeType)for(K=F.allpts,G=0;G+5<F.allpts.length;G+=4)if(n=ee,r=te,i=K[G],a=K[G+1],o=K[G+2],s=K[G+3],l=K[G+4],u=K[G+5],c=j,f=p=d=h=void 0,h=Math.min(i,l,o)-c,d=Math.max(i,l,o)+c,p=Math.min(a,u,s)-c,f=Math.max(a,u,s)+c,!(n<h||d<n||r<p||f<r)&&X>(t=pt(ee,te,K[G],K[G+1],K[G+2],K[G+3],K[G+4],K[G+5])))return se(e,t),!0;W=W||R.source,H=H||R.target;var Z=ne.getArrowWidth(V,q),U=[{name:"source",x:F.arrowStartX,y:F.arrowStartY,angle:F.srcArrowAngle},{name:"target",x:F.arrowEndX,y:F.arrowEndY,angle:F.tgtArrowAngle},{name:"mid-source",x:F.midX,y:F.midY,angle:F.midsrcArrowAngle},{name:"mid-target",x:F.midX,y:F.midY,angle:F.midtgtArrowAngle}];for(G=0;G<U.length;G++){var $=U[G],Q=re.arrowShapes[e.pstyle($.name+"-arrow-shape").value],J=e.pstyle("width").pfValue;if(Q.roughCollide(ee,te,Z,$.angle,{x:$.x,y:$.y},J,oe)&&Q.collide(ee,te,Z,$.angle,{x:$.x,y:$.y},J,oe))return se(e),!0}ae&&0<ie.length&&(le(W),le(H))}function T(e,t,n){return De(e,t,n)}function u(e,t){var n,r=e._private,i=D;n=t?t+"-":"";var a=e.pstyle(n+"label").value;if("yes"===e.pstyle("text-events").strValue&&a){var o=r.rstyle,s=e.pstyle("text-border-width").pfValue,l=e.pstyle("text-background-padding").pfValue,u=T(o,"labelWidth",t)+s+2*i+2*l,c=T(o,"labelHeight",t)+s+2*i+2*l,h=T(o,"labelX",t),d=T(o,"labelY",t),p=T(r.rscratch,"labelAngle",t),f=h-u/2,g=h+u/2,v=d-c/2,y=d+c/2;if(p){var m=Math.cos(p),b=Math.sin(p),x=function(e,t){return{x:(e-=h)*m-(t-=d)*b+h,y:e*b+t*m+d}},w=x(f,v),E=x(f,y),k=x(g,v),C=x(g,y),S=[w.x,w.y,k.x,k.y,C.x,C.y,E.x,E.y];if(ft(ee,te,S))return se(e),!0}else{if(ct({w:u,h:c,x1:f,x2:g,y1:v,y2:y},ee,te))return se(e),!0}}}e&&(n=n.interactive);for(var c=n.length-1;0<=c;c--){var h=n[c];h.isNode()?le(h)||u(h):l(h)||u(h)||u(h,"source")||u(h,"target")}return ie},getAllInBox:function(e,t,n,r){for(var i,a,o=this.getCachedZSortedEles().interactive,s=[],l=Math.min(e,n),u=Math.max(e,n),c=Math.min(t,r),h=Math.max(t,r),d=at({x1:e=l,y1:t=c,x2:n=u,y2:r=h}),p=0;p<o.length;p++){var f=o[p];if(f.isNode()){var g=f,v=g.boundingBox({includeNodes:!0,includeEdges:!1,includeLabels:!1});ut(d,v)&&!ht(v,d)&&s.push(g)}else{var y=f,m=y._private,b=m.rscratch;if(null!=b.startX&&null!=b.startY&&!ct(d,b.startX,b.startY))continue;if(null!=b.endX&&null!=b.endY&&!ct(d,b.endX,b.endY))continue;if("bezier"===b.edgeType||"multibezier"===b.edgeType||"self"===b.edgeType||"compound"===b.edgeType||"segments"===b.edgeType||"haystack"===b.edgeType){for(var x=m.rstyle.bezierPts||m.rstyle.linePts||m.rstyle.haystackPts,w=!0,E=0;E<x.length;E++)if(i=d,a=x[E],!ct(i,a.x,a.y)){w=!1;break}w&&s.push(y)}else"haystack"!==b.edgeType&&"straight"!==b.edgeType||s.push(y)}}return s}},fo={calculateArrowAngles:function(e){var t,n,r,i,a,o,s=e._private.rscratch,l="haystack"===s.edgeType,u="bezier"===s.edgeType,c="multibezier"===s.edgeType,h="segments"===s.edgeType,d="compound"===s.edgeType,p="self"===s.edgeType;if(o=l?(r=s.haystackPts[0],i=s.haystackPts[1],a=s.haystackPts[2],s.haystackPts[3]):(r=s.arrowStartX,i=s.arrowStartY,a=s.arrowEndX,s.arrowEndY),g=s.midX,v=s.midY,h)t=r-s.segpts[0],n=i-s.segpts[1];else if(c||d||p||u){var f=s.allpts;t=r-nt(f[0],f[2],f[4],.1),n=i-nt(f[1],f[3],f[5],.1)}else t=r-g,n=i-v;s.srcArrowAngle=Qe(t,n);var g=s.midX,v=s.midY;if(l&&(g=(r+a)/2,v=(i+o)/2),t=a-r,n=o-i,h)if((f=s.allpts).length/2%2==0){var y=(m=f.length/2)-2;t=f[m]-f[y],n=f[m+1]-f[y+1]}else{y=(m=f.length/2-1)-2;var m,b=m+2;t=f[m]-f[y],n=f[m+1]-f[y+1]}else if(c||d||p){var x,w,E,k,f=s.allpts;if(s.ctrlpts.length/2%2==0){var C=(S=(D=f.length/2-1)+2)+2;x=nt(f[D],f[S],f[C],0),w=nt(f[D+1],f[S+1],f[C+1],0),E=nt(f[D],f[S],f[C],1e-4),k=nt(f[D+1],f[S+1],f[C+1],1e-4)}else{var S,D;C=(S=f.length/2-1)+2;x=nt(f[D=S-2],f[S],f[C],.4999),w=nt(f[D+1],f[S+1],f[C+1],.4999),E=nt(f[D],f[S],f[C],.5),k=nt(f[D+1],f[S+1],f[C+1],.5)}t=E-x,n=k-w}(s.midtgtArrowAngle=Qe(t,n),s.midDispX=t,s.midDispY=n,t*=-1,n*=-1,h)&&((f=s.allpts).length/2%2==0||(t=-(f[b=(m=f.length/2-1)+2]-f[m]),n=-(f[b+1]-f[m+1])));if(s.midsrcArrowAngle=Qe(t,n),h)t=a-s.segpts[s.segpts.length-2],n=o-s.segpts[s.segpts.length-1];else if(c||d||p||u){var T=(f=s.allpts).length;t=a-nt(f[T-6],f[T-4],f[T-2],.9),n=o-nt(f[T-5],f[T-3],f[T-1],.9)}else t=a-g,n=o-v;s.tgtArrowAngle=Qe(t,n)}};fo.getArrowWidth=fo.getArrowHeight=function(e,t){var n=this.arrowWidthCache=this.arrowWidthCache||{},r=n[e+", "+t];return r||(r=Math.max(Math.pow(13.37*e,.9),29)*t,n[e+", "+t]=r)};var go={};function vo(e){var t=[];if(null!=e){for(var n=0;n<e.length;n+=2){var r=e[n],i=e[n+1];t.push({x:r,y:i})}return t}}go.findHaystackPoints=function(e){for(var t=0;t<e.length;t++){var n=e[t],r=n._private,i=r.rscratch;if(!i.haystack){var a=2*Math.random()*Math.PI;i.source={x:Math.cos(a),y:Math.sin(a)};a=2*Math.random()*Math.PI;i.target={x:Math.cos(a),y:Math.sin(a)}}var o=r.source,s=r.target,l=o.position(),u=s.position(),c=o.width(),h=s.width(),d=o.height(),p=s.height(),f=n.pstyle("haystack-radius").value/2;i.haystackPts=i.allpts=[i.source.x*c*f+l.x,i.source.y*d*f+l.y,i.target.x*h*f+u.x,i.target.y*p*f+u.y],i.midX=(i.allpts[0]+i.allpts[2])/2,i.midY=(i.allpts[1]+i.allpts[3])/2,i.edgeType=i.lastCurveStyle="haystack",i.haystack=!0,this.storeEdgeProjections(n),this.calculateArrowAngles(n),this.recalculateEdgeLabelProjections(n),this.calculateLabelAngles(n)}},go.storeAllpts=function(e){var t=e._private.rscratch;if("multibezier"===t.edgeType||"bezier"===t.edgeType||"self"===t.edgeType||"compound"===t.edgeType){t.allpts=[],t.allpts.push(t.startX,t.startY);for(var n=0;n+1<t.ctrlpts.length;n+=2)t.allpts.push(t.ctrlpts[n],t.ctrlpts[n+1]),n+3<t.ctrlpts.length&&t.allpts.push((t.ctrlpts[n]+t.ctrlpts[n+2])/2,(t.ctrlpts[n+1]+t.ctrlpts[n+3])/2);var r;t.allpts.push(t.endX,t.endY),t.ctrlpts.length/2%2==0?(r=t.allpts.length/2-1,t.midX=t.allpts[r],t.midY=t.allpts[r+1]):(r=t.allpts.length/2-3,.5,t.midX=nt(t.allpts[r],t.allpts[r+2],t.allpts[r+4],.5),t.midY=nt(t.allpts[r+1],t.allpts[r+3],t.allpts[r+5],.5))}else if("straight"===t.edgeType)t.allpts=[t.startX,t.startY,t.endX,t.endY],t.midX=(t.startX+t.endX+t.arrowStartX+t.arrowEndX)/4,t.midY=(t.startY+t.endY+t.arrowStartY+t.arrowEndY)/4;else if("segments"===t.edgeType)if(t.allpts=[],t.allpts.push(t.startX,t.startY),t.allpts.push.apply(t.allpts,t.segpts),t.allpts.push(t.endX,t.endY),t.segpts.length%4==0){var i=t.segpts.length/2,a=i-2;t.midX=(t.segpts[a]+t.segpts[i])/2,t.midY=(t.segpts[a+1]+t.segpts[i+1])/2}else{a=t.segpts.length/2-1;t.midX=t.segpts[a],t.midY=t.segpts[a+1]}},go.checkForInvalidEdgeWarning=function(e){var t=e._private.rscratch;$t(t.startX)&&$t(t.startY)&&$t(t.endX)&&$t(t.endY)?t.loggedErr=!1:t.loggedErr||(t.loggedErr=!0,be("Edge `"+e.id()+"` has invalid endpoints and so it is impossible to draw. Adjust your edge style (e.g. control points) accordingly or use an alternative edge type. This is expected behaviour when the source node and the target node overlap."))},go.findEdgeControlPoints=function(e){if(e&&0!==e.length){for(var t,n,r,i,a,o,s,l,u,c,h,d,p,f,g=this.cy.hasCompoundNodes(),v={},y=[],m=[],b=0;b<e.length;b++){var x=(T=e[b])._private.data,w="unbundled-bezier"===(Y=T.pstyle("curve-style").value)||"segments"===Y||"straight"===Y,E="unbundled-bezier"===Y||"bezier"===Y;if("none"!==T.pstyle("display").value)if("haystack"!==Y){var k=x.source,C=x.target;t=C<k?C+"$-$"+k:k+"$-$"+C,w&&(t="unbundled$-$"+x.id);var S=v[t];null==S&&(S=v[t]=[],y.push(t)),S.push(T),w&&(S.hasUnbundled=!0),E&&(S.hasBezier=!0)}else m.push(T)}for(var D=0;D<y.length;D++){var T,P,M=v[t=y[D]];if(!M.hasUnbundled){var _=M[0].parallelEdges();Qt(M),_.forEach(function(e){return M.push(e)}),M.sort(function(e,t){return e.poolIndex()-t.poolIndex()})}if(n=M[0]._private.source,r=M[0]._private.target,!M.hasUnbundled&&n.id()>r.id()){var B=n;n=r,r=B}i=n.position(),a=r.position(),o=n.outerWidth(),s=n.outerHeight(),l=r.outerWidth(),u=r.outerHeight(),c=this.nodeShapes[this.getNodeShape(n)],h=this.nodeShapes[this.getNodeShape(r)],p=!1;var N={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0},I=i.x,A=i.y,L=o,z=s,O=a.x,R=a.y,F=l,V=u,q=M.length;for(b=0;b<M.length;b++){var Y,X,j=(P=(T=M[b])._private.rscratch).lastEdgeIndex,W=b,H=P.lastNumEdges,K=(w="unbundled-bezier"===(Y=T.pstyle("curve-style").value)||"segments"===Y,n.id()!==T.source().id()),G=T.pstyle("control-point-distances"),Z=T.pstyle("loop-direction").pfValue,U=T.pstyle("loop-sweep").pfValue,$=T.pstyle("control-point-weights"),Q=G&&$?Math.min(G.value.length,$.value.length):1,J=T.pstyle("control-point-step-size").pfValue,ee=G?G.pfValue[0]:void 0,te=$.value[0],ne=T.pstyle("edge-distances").value,re=T.pstyle("source-distance-from-node").pfValue,ie=T.pstyle("target-distance-from-node").pfValue,ae=T.pstyle("segment-weights"),oe=T.pstyle("segment-distances"),se=Math.min(ae.pfValue.length,oe.pfValue.length),le=T.pstyle("source-endpoint").value,ue=T.pstyle("target-endpoint").value,ce=T.pstyle("source-arrow-shape").value,he=T.pstyle("target-arrow-shape").value,de=T.pstyle("arrow-scale").value,pe=T.pstyle("width").pfValue,fe=P.lastSrcCtlPtX,ge=P.lastSrcCtlPtY,ve=P.lastSrcCtlPtW,ye=P.lastSrcCtlPtH,me=P.lastTgtCtlPtX,be=P.lastTgtCtlPtY,xe=P.lastTgtCtlPtW,we=P.lastTgtCtlPtH,Ee=P.lastCurveStyle,ke=Y,Ce=P.lastCtrlptDists,Se=G?G.strValue:null,De=P.lastCtrlptWs,Te=$.strValue,Pe=P.lastSegmentWs,Me=ae.strValue,_e=P.lastSegmentDs,Be=oe.strValue,Ne=P.lastStepSize,Ie=J,Ae=P.lastLoopDir,Le=Z,ze=P.lastLoopSwp,Oe=U,Re=P.lastEdgeDistances,Fe=ne,Ve=P.lastSrcDistFNode,qe=re,Ye=P.lastTgtDistFNode,Xe=ie,je=P.lastSrcEndpt,We=le,He=P.lastTgtEndpt,Ke=ue,Ge=P.lastSrcArr,Ze=ce,Ue=P.lastTgtArr,$e=he,Qe=P.lastLineW,Je=pe,et=P.lastArrScl,tt=de;if(P.badBezier=!!p,fe===I&&ge===A&&ve===L&&ye===z&&me===O&&be===R&&xe===F&&we===V&&Ee===ke&&Ce===Se&&De===Te&&Pe===Me&&_e===Be&&Ne===Ie&&Ae===Le&&ze===Oe&&Re===Fe&&Ve===qe&&Ye===Xe&&je===We&&He===Ke&&Ge===Ze&&Ue===$e&&Qe===Je&&et===tt&&(j===W&&H===q||w)?X=!0:(X=!1,P.lastSrcCtlPtX=I,P.lastSrcCtlPtY=A,P.lastSrcCtlPtW=L,P.lastSrcCtlPtH=z,P.lastTgtCtlPtX=O,P.lastTgtCtlPtY=R,P.lastTgtCtlPtW=F,P.lastTgtCtlPtH=V,P.lastEdgeIndex=W,P.lastNumEdges=q,P.lastCurveStyle=ke,P.lastCtrlptDists=Se,P.lastCtrlptWs=Te,P.lastSegmentDs=Be,P.lastSegmentWs=Me,P.lastStepSize=Ie,P.lastLoopDir=Le,P.lastLoopSwp=Oe,P.lastEdgeDistances=Fe,P.lastSrcDistFNode=qe,P.lastTgtDistFNode=Xe,P.lastSrcEndpt=We,P.lastTgtEndpt=Ke,P.lastSrcArr=Ze,P.lastTgtArr=$e,P.lastLineW=Je,P.lastArrScl=tt),!X){if(!M.calculatedIntersection&&n!==r&&(M.hasBezier||M.hasUnbundled)){M.calculatedIntersection=!0;var nt=c.intersectLine(i.x,i.y,o,s,a.x,a.y,0);M.srcIntn=nt;var rt=h.intersectLine(a.x,a.y,l,u,i.x,i.y,0);M.tgtIntn=rt;var it={x1:nt[0],x2:rt[0],y1:nt[1],y2:rt[1]},at={x1:i.x,x2:a.x,y1:i.y,y2:a.y},ot=rt[1]-nt[1],st=rt[0]-nt[0],lt=Math.sqrt(st*st+ot*ot),ut={x:st/lt,y:ot/lt};d={x:-ut.y,y:ut.x},h.checkPoint(nt[0],nt[1],0,l,u,a.x,a.y)&&c.checkPoint(rt[0],rt[1],0,o,s,i.x,i.y)&&(d={},p=!0)}if(P.tgtIntn=K?(P.srcIntn=M.tgtIntn,M.srcIntn):(P.srcIntn=M.srcIntn,M.tgtIntn),n===r){P.edgeType="self";var ct=b,ht=J;w&&(ct=0,ht=ee);var dt=Z-Math.PI/2,pt=dt-U/2,ft=dt+U/2,gt=String(Z+"_"+U);ct=void 0===N[gt]?N[gt]=0:++N[gt],P.ctrlpts=[i.x+1.4*Math.cos(pt)*ht*(ct/3+1),i.y+1.4*Math.sin(pt)*ht*(ct/3+1),i.x+1.4*Math.cos(ft)*ht*(ct/3+1),i.y+1.4*Math.sin(ft)*ht*(ct/3+1)]}else if(g&&(n.isParent()||n.isChild()||r.isParent()||r.isChild())&&(n.parents().anySame(r)||r.parents().anySame(n))){P.edgeType="compound",P.badBezier=!1;ct=b,ht=J;w&&(ct=0,ht=ee);var vt={x:i.x-o/2,y:i.y-s/2},yt={x:a.x-l/2,y:a.y-u/2},mt={x:Math.min(vt.x,yt.x),y:Math.min(vt.y,yt.y)},bt=Math.max(.5,Math.log(.01*o)),xt=Math.max(.5,Math.log(.01*l));P.ctrlpts=[mt.x,mt.y-(1+Math.pow(50,1.12)/100)*ht*(ct/3+1)*bt,mt.x-(1+Math.pow(50,1.12)/100)*ht*(ct/3+1)*xt,mt.y]}else if("segments"===Y){P.edgeType="segments",P.segpts=[];for(var wt=0;wt<se;wt++){var Et=ae.pfValue[wt],kt=oe.pfValue[wt],Ct=1-Et,St=Et,Dt={x:(It="node-position"===ne?at:it).x1*Ct+It.x2*St,y:It.y1*Ct+It.y2*St};P.segpts.push(Dt.x+d.x*kt,Dt.y+d.y*kt)}}else if(M.length%2!=1||b!==Math.floor(M.length/2)||w){var Tt=w;P.edgeType=Tt?"multibezier":"bezier",P.ctrlpts=[];for(var Pt=0;Pt<Q;Pt++){var Mt,_t=(.5-M.length/2+b)*J,Bt=0<(f=_t)?1:f<0?-1:0;Tt&&(ee=G?G.pfValue[Pt]:J,te=$.value[Pt]);var Nt=void 0!==(Mt=w?ee:void 0!==ee?Bt*ee:void 0)?Mt:_t;Ct=1-te,St=te;if(K){B=Ct;Ct=St,St=B}var It;Dt={x:(It="node-position"===ne?at:it).x1*Ct+It.x2*St,y:It.y1*Ct+It.y2*St};P.ctrlpts.push(Dt.x+d.x*Nt,Dt.y+d.y*Nt)}}else P.edgeType="straight";this.findEndpoints(T);var At=!$t(P.startX)||!$t(P.startY),Lt=!$t(P.arrowStartX)||!$t(P.arrowStartY),zt=!$t(P.endX)||!$t(P.endY),Ot=!$t(P.arrowEndX)||!$t(P.arrowEndY),Rt=3*(this.getArrowWidth(T.pstyle("width").pfValue,T.pstyle("arrow-scale").value)*this.arrowShapeWidth);if("bezier"===P.edgeType){var Ft=Jt({x:P.ctrlpts[0],y:P.ctrlpts[1]},{x:P.startX,y:P.startY}),Vt=Ft<Rt,qt=Jt({x:P.ctrlpts[0],y:P.ctrlpts[1]},{x:P.endX,y:P.endY}),Yt=qt<Rt,Xt=!1;if(At||Lt||Vt){Xt=!0;var jt={x:P.ctrlpts[0]-i.x,y:P.ctrlpts[1]-i.y},Wt=Math.sqrt(jt.x*jt.x+jt.y*jt.y),Ht={x:jt.x/Wt,y:jt.y/Wt},Kt=Math.max(o,s),Gt={x:P.ctrlpts[0]+2*Ht.x*Kt,y:P.ctrlpts[1]+2*Ht.y*Kt},Zt=c.intersectLine(i.x,i.y,o,s,Gt.x,Gt.y,0);P.ctrlpts[1]=Vt?(P.ctrlpts[0]=P.ctrlpts[0]+Ht.x*(Rt-Ft),P.ctrlpts[1]+Ht.y*(Rt-Ft)):(P.ctrlpts[0]=Zt[0]+Ht.x*Rt,Zt[1]+Ht.y*Rt)}if(zt||Ot||Yt){Xt=!0;jt={x:P.ctrlpts[0]-a.x,y:P.ctrlpts[1]-a.y},Wt=Math.sqrt(jt.x*jt.x+jt.y*jt.y),Ht={x:jt.x/Wt,y:jt.y/Wt},Kt=Math.max(o,s),Gt={x:P.ctrlpts[0]+2*Ht.x*Kt,y:P.ctrlpts[1]+2*Ht.y*Kt};var Ut=h.intersectLine(a.x,a.y,l,u,Gt.x,Gt.y,0);P.ctrlpts[1]=Yt?(P.ctrlpts[0]=P.ctrlpts[0]+Ht.x*(Rt-qt),P.ctrlpts[1]+Ht.y*(Rt-qt)):(P.ctrlpts[0]=Ut[0]+Ht.x*Rt,Ut[1]+Ht.y*Rt)}Xt&&this.findEndpoints(T)}this.checkForInvalidEdgeWarning(T),this.storeAllpts(T),this.storeEdgeProjections(T),this.calculateArrowAngles(T)}this.recalculateEdgeLabelProjections(T),this.calculateLabelAngles(T)}}this.findHaystackPoints(m)}},go.getSegmentPoints=function(e){var t=e[0]._private.rscratch;if("segments"===t.edgeType)return this.recalculateRenderedStyle(e),vo(t.segpts)},go.getControlPoints=function(e){var t=e[0]._private.rscratch,n=t.edgeType;if("bezier"===n||"multibezier"===n||"self"===n||"compound"===n)return this.recalculateRenderedStyle(e),vo(t.ctrlpts)},go.getEdgeMidpoint=function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),{x:t.midX,y:t.midY}};var yo={manualEndptToPx:function(e,t){var n=e.position(),r=e.outerWidth(),i=e.outerHeight();if(2===t.value.length){var a=[t.pfValue[0],t.pfValue[1]];return"%"===t.units[0]&&(a[0]=a[0]*r),"%"===t.units[1]&&(a[1]=a[1]*i),a[0]+=n.x,a[1]+=n.y,a}var o=t.pfValue[0];o=-Math.PI/2+o;var s=2*Math.max(r,i),l=[n.x+Math.cos(o)*s,n.y+Math.sin(o)*s];return this.nodeShapes[this.getNodeShape(e)].intersectLine(n.x,n.y,r,i,l[0],l[1],0)},findEndpoints:function(e){var t,n,r,i,a,o=e.source()[0],s=e.target()[0],l=o.position(),u=s.position(),c=e.pstyle("target-arrow-shape").value,h=e.pstyle("source-arrow-shape").value,d=e.pstyle("target-distance-from-node").pfValue,p=e.pstyle("source-distance-from-node").pfValue,f=e._private.rscratch,g=f.edgeType,v="self"===g||"compound"===g,y="bezier"===g||"multibezier"===g||v,m="bezier"!==g,b="straight"===g||"segments"===g,x="segments"===g,w=y||m||b,E=e.pstyle("source-endpoint"),k=v?"outside-to-node":E.value,C=e.pstyle("target-endpoint"),S=v?"outside-to-node":C.value;if(f.srcManEndpt=E,f.tgtManEndpt=C,y){var D=[f.ctrlpts[0],f.ctrlpts[1]];n=m?[f.ctrlpts[f.ctrlpts.length-2],f.ctrlpts[f.ctrlpts.length-1]]:D,r=D}else if(b){var T=x?f.segpts.slice(0,2):[u.x,u.y];n=x?f.segpts.slice(f.segpts.length-2):[l.x,l.y],r=T}if("inside-to-node"===S)t=[u.x,u.y];else if(C.units)t=this.manualEndptToPx(s,C);else if("outside-to-line"===S)t=f.tgtIntn;else if("outside-to-node"===S||"outside-to-node-or-label"===S?i=n:"outside-to-line"!==S&&"outside-to-line-or-label"!==S||(i=[l.x,l.y]),t=this.nodeShapes[this.getNodeShape(s)].intersectLine(u.x,u.y,s.outerWidth(),s.outerHeight(),i[0],i[1],0),"outside-to-node-or-label"===S||"outside-to-line-or-label"===S){var P=s._private.rscratch,M=P.labelWidth,_=P.labelHeight,B=P.labelX,N=P.labelY,I=s.pstyle("text-valign").value;"top"===I?N-=_/2:"bottom"===I&&(N+=_/2);var A=s.pstyle("text-halign").value;"left"===A?B-=M/2:"right"===A&&(B+=M/2);var L=this.nodeShapes.rectangle.intersectLine(B,N,M,_,i[0],i[1],0),z=l,O=et(z,$e(t));et(z,$e(L))<O&&(t=L)}var R=kt(t,n,this.arrowShapes[c].spacing(e)+d),F=kt(t,n,this.arrowShapes[c].gap(e)+d);if(f.endX=F[0],f.endY=F[1],f.arrowEndX=R[0],f.arrowEndY=R[1],"inside-to-node"===k)t=[l.x,l.y];else if(E.units)t=this.manualEndptToPx(o,E);else if("outside-to-line"===k)t=f.srcIntn;else if("outside-to-node"===k||"outside-to-node-or-label"===k?a=r:"outside-to-line"!==k&&"outside-to-line-or-label"!==k||(a=[u.x,u.y]),t=this.nodeShapes[this.getNodeShape(o)].intersectLine(l.x,l.y,o.outerWidth(),o.outerHeight(),a[0],a[1],0),"outside-to-node-or-label"===k||"outside-to-line-or-label"===k){var V=o._private.rscratch,q=V.labelWidth,Y=V.labelHeight,X=V.labelX,j=V.labelY,W=o.pstyle("text-valign").value;"top"===W?j-=Y/2:"bottom"===W&&(j+=Y/2);var H=o.pstyle("text-halign").value;"left"===H?X-=q/2:"right"===H&&(X+=q/2);var K=this.nodeShapes.rectangle.intersectLine(X,j,q,Y,a[0],a[1],0),G=u,Z=et(G,$e(t));et(G,$e(K))<Z&&(t=K)}var U=kt(t,r,this.arrowShapes[h].spacing(e)+p),$=kt(t,r,this.arrowShapes[h].gap(e)+p);f.startX=$[0],f.startY=$[1],f.arrowStartX=U[0],f.arrowStartY=U[1],w&&($t(f.startX)&&$t(f.startY)&&$t(f.endX)&&$t(f.endY)?f.badLine=!1:f.badLine=!0)},getSourceEndpoint:function(e){var t=e[0]._private.rscratch;switch(this.recalculateRenderedStyle(e),t.edgeType){case"haystack":return{x:t.haystackPts[0],y:t.haystackPts[1]};default:return{x:t.arrowStartX,y:t.arrowStartY}}},getTargetEndpoint:function(e){var t=e[0]._private.rscratch;switch(this.recalculateRenderedStyle(e),t.edgeType){case"haystack":return{x:t.haystackPts[2],y:t.haystackPts[3]};default:return{x:t.arrowEndX,y:t.arrowEndY}}}},mo={};function bo(e,t,n){for(var r=function(e,t,n,r){return nt(e,t,n,r)},i=t._private.rstyle.bezierPts,a=0;a<e.bezierProjPcts.length;a++){var o=e.bezierProjPcts[a];i.push({x:r(n[0],n[2],n[4],o),y:r(n[1],n[3],n[5],o)})}}mo.storeEdgeProjections=function(e){var t=e._private,n=t.rscratch,r=n.edgeType;if(t.rstyle.bezierPts=null,t.rstyle.linePts=null,t.rstyle.haystackPts=null,"multibezier"===r||"bezier"===r||"self"===r||"compound"===r){t.rstyle.bezierPts=[];for(var i=0;i+5<n.allpts.length;i+=4)bo(this,e,n.allpts.slice(i,i+6))}else if("segments"===r){var a=t.rstyle.linePts=[];for(i=0;i+1<n.allpts.length;i+=2)a.push({x:n.allpts[i],y:n.allpts[i+1]})}else if("haystack"===r){var o=n.haystackPts;t.rstyle.haystackPts=[{x:o[0],y:o[1]},{x:o[2],y:o[3]}]}t.rstyle.arrowWidth=this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth},mo.recalculateEdgeProjections=function(e){this.findEdgeControlPoints(e)};var xo={recalculateNodeLabelProjection:function(e){var t=e.pstyle("label").strValue;if(!L(t)){var n,r,i=e._private,a=e.width(),o=e.height(),s=e.padding(),l=e.position(),u=e.pstyle("text-halign").strValue,c=e.pstyle("text-valign").strValue,h=i.rscratch,d=i.rstyle;switch(u){case"left":n=l.x-a/2-s;break;case"right":n=l.x+a/2+s;break;default:n=l.x}switch(c){case"top":r=l.y-o/2-s;break;case"bottom":r=l.y+o/2+s;break;default:r=l.y}h.labelX=n,h.labelY=r,d.labelX=n,d.labelY=r,this.applyLabelDimensions(e)}}},wo=function(e,t){var n=Math.atan(t/e);return 0===e&&n<0&&(n*=-1),n},Eo=function(e,t){var n=t.x-e.x,r=t.y-e.y;return wo(n,r)};xo.recalculateEdgeLabelProjections=function(F){var V,q=F._private,Y=q.rscratch,X=this,j={mid:F.pstyle("label").strValue,source:F.pstyle("source-label").strValue,target:F.pstyle("target-label").strValue};if(j.mid||j.source||j.target){V={x:Y.midX,y:Y.midY};var W=function(e,t,n){Te(q.rscratch,e,t,n),Te(q.rstyle,e,t,n)};W("labelX",null,V.x),W("labelY",null,V.y);var e=wo(Y.midDispX,Y.midDispY);W("labelAutoAngle",null,e);var t=function(e){var t,n="source"===e;if(j[e]){var r,i,a,o,s,l,u,c,h,d,p,f,g,v,y,m,b,x=F.pstyle(e+"-text-offset").pfValue;switch(Y.edgeType){case"self":case"compound":case"bezier":case"multibezier":for(var w,E=function e(){if(e.cache)return e.cache;for(var t=[],n=0;n+5<Y.allpts.length;n+=4){var r={x:Y.allpts[n],y:Y.allpts[n+1]},i={x:Y.allpts[n+2],y:Y.allpts[n+3]},a={x:Y.allpts[n+4],y:Y.allpts[n+5]};t.push({p0:r,p1:i,p2:a,startDist:0,length:0,segments:[]})}var o=q.rstyle.bezierPts,s=X.bezierProjPcts.length;function l(e,t,n,r,i){var a=Jt(t,n),o=e.segments[e.segments.length-1],s={p0:t,p1:n,t0:r,t1:i,startDist:o?o.startDist+o.length:0,length:a};e.segments.push(s),e.length+=a}for(n=0;n<t.length;n++){var u=t[n],c=t[n-1];c&&(u.startDist=c.startDist+c.length),l(u,u.p0,o[n*s],0,X.bezierProjPcts[0]);for(var h=0;h<s-1;h++)l(u,o[n*s+h],o[n*s+h+1],X.bezierProjPcts[h],X.bezierProjPcts[h+1]);l(u,o[n*s+s-1],u.p2,X.bezierProjPcts[s-1],1)}return e.cache=t}(),k=0,C=0,S=0;S<E.length;S++){for(var D=E[n?S:E.length-1-S],T=0;T<D.segments.length;T++){var P=D.segments[n?T:D.segments.length-1-T],M=S===E.length-1&&T===D.segments.length-1;if(k=C,x<=(C+=P.length)||M){w={cp:D,segment:P};break}}if(w)break}D=w.cp;var _=(x-k)/(P=w.segment).length,B=P.t1-P.t0,N=n?P.t0+B*_:P.t1-B*_;N=it(0,N,1),V=rt(D.p0,D.p1,D.p2,N),d=D.p0,p=D.p1,f=D.p2,v=it(0,(g=N)-.001,1),y=it(0,g+.001,1),m=rt(d,p,f,v),b=rt(d,p,f,y),t=Eo(m,b);break;case"straight":case"segments":case"haystack":var I,A,L,z,O=0,R=Y.allpts.length;for(S=0;S+3<R&&(z=n?(L={x:Y.allpts[S],y:Y.allpts[S+1]},{x:Y.allpts[S+2],y:Y.allpts[S+3]}):(L={x:Y.allpts[R-2-S],y:Y.allpts[R-1-S]},{x:Y.allpts[R-4-S],y:Y.allpts[R-3-S]}),A=O,!(x<=(O+=I=Jt(L,z))));S+=2);N=it(0,N=(x-A)/I,1),r=L,a=N,s=(i=z).x-r.x,l=i.y-r.y,u=Jt(r,i),c=s/u,h=l/u,a=null==a?0:a,o=null!=o?o:a*u,V={x:r.x+c*o,y:r.y+h*o},t=Eo(L,z)}W("labelX",e,V.x),W("labelY",e,V.y),W("labelAutoAngle",e,t)}};t("source"),t("target"),this.applyLabelDimensions(F)}},xo.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},xo.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),i=this.calculateLabelDimensions(e,r);Te(n.rstyle,"labelWidth",t,i.width),Te(n.rscratch,"labelWidth",t,i.width),Te(n.rstyle,"labelHeight",t,i.height),Te(n.rscratch,"labelHeight",t,i.height)},xo.getLabelText=function(e,n){var r=e._private,t=n?n+"-":"",i=e.pstyle(t+"label").strValue,a=e.pstyle("text-transform").value,o=function(e,t){return t?(Te(r.rscratch,e,n,t),t):De(r.rscratch,e,n)};if(!i)return"";"none"==a||("uppercase"==a?i=i.toUpperCase():"lowercase"==a&&(i=i.toLowerCase()));var s=e.pstyle("text-wrap").value;if("wrap"===s){var l=o("labelKey");if(null!=l&&o("labelWrapKey")===l)return o("labelWrapCachedText");for(var u=i.split("\n"),c=e.pstyle("text-max-width").pfValue,h=[],d=0;d<u.length;d++){var p=u[d];if(c<this.calculateLabelDimensions(e,p).width){for(var f=p.split(/\s+/),g="",v=0;v<f.length;v++){var y=f[v],m=0===g.length?y:g+" "+y;this.calculateLabelDimensions(e,m).width<=c?g+=y+" ":(h.push(g),g=y+" ")}g.match(/^\s+$/)||h.push(g)}else h.push(p)}o("labelWrapCachedLines",h),i=o("labelWrapCachedText",h.join("\n")),o("labelWrapKey",l)}else if("ellipsis"===s){c=e.pstyle("text-max-width").pfValue;for(var b="",x=!1,w=0;w<i.length;w++){if(c<this.calculateLabelDimensions(e,b+i[w]+"…").width)break;b+=i[w],w===i.length-1&&(x=!0)}return x||(b+="…"),b}return i},xo.calculateLabelDimensions=function(e,t){var n=le(t,e._private.labelDimsKey),r=this.labelDimCache||(this.labelDimCache=[]),i=r[n];if(null!=i)return i;var a=e.pstyle("font-style").strValue,o=1*e.pstyle("font-size").pfValue+"px",s=e.pstyle("font-family").strValue,l=e.pstyle("font-weight").strValue,u=this.labelCalcDiv;u||(u=this.labelCalcDiv=document.createElement("div"),document.body.appendChild(u));var c=u.style;return c.fontFamily=s,c.fontStyle=a,c.fontSize=o,c.fontWeight=l,c.position="absolute",c.left="-9999px",c.top="-9999px",c.zIndex="-1",c.visibility="hidden",c.pointerEvents="none",c.padding="0",c.lineHeight="1","wrap"===e.pstyle("text-wrap").value?c.whiteSpace="pre":c.whiteSpace="normal",u.textContent=t,r[n]={width:Math.ceil(u.clientWidth/1),height:Math.ceil(u.clientHeight/1)}},xo.calculateLabelAngles=function(e){var t=e._private.rscratch,n=e.isEdge(),r=e.pstyle("text-rotation"),i=r.strValue;"none"===i?t.labelAngle=t.sourceLabelAngle=t.targetLabelAngle=0:n&&"autorotate"===i?(t.labelAngle=t.labelAutoAngle,t.sourceLabelAngle=t.sourceLabelAutoAngle,t.targetLabelAngle=t.targetLabelAutoAngle):t.labelAngle=t.sourceLabelAngle=t.targetLabelAngle="autorotate"===i?0:r.pfValue};var ko={},Co=!1;ko.getNodeShape=function(e){var t=e.pstyle("shape").value;if("cutrectangle"===t&&(e.width()<28||e.height()<28))return Co||(be("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),Co=!0),"rectangle";if(e.isParent())return"rectangle"===t||"roundrectangle"===t||"cutrectangle"===t||"barrel"===t?t:"rectangle";if("polygon"!==t)return t;var n=e.pstyle("shape-polygon-points").value;return this.nodeShapes.makePolygon(n).name};var So={registerCalculationListeners:function(){var r=this.cy,i=r.collection(),a=this,o=function(e){var t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(i.merge(e),t)for(var n=0;n<e.length;n++){e[n]._private.rstyle.clean=!1}};a.binder(r).on("bounds.* dirty.*",function(e){var t=e.target;o(t)}).on("style.* background.*",function(e){var t=e.target;o(t,!1)});a.beforeRender(function(e){if(e){for(var t=a.onUpdateEleCalcsFns,n=0;n<i.length;n++)o(i[n].connectedEdges());if(t)for(n=0;n<t.length;n++)(0,t[n])(e,i);a.recalculateRenderedStyle(i),i=r.collection()}},a.beforeRenderPriorities.eleCalcs)},onUpdateEleCalcs:function(e){(this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[]).push(e)},recalculateRenderedStyle:function(e,t){var n=[],r=[];if(!this.destroyed){void 0===t&&(t=!0);for(var i=0;i<e.length;i++){var a=(l=(s=e[i])._private).rstyle;t&&a.clean||s.removed()||"none"!==s.pstyle("display").value&&("nodes"===l.group?r.push(s):n.push(s),a.clean=!0)}for(i=0;i<r.length;i++){a=(l=(s=r[i])._private).rstyle;var o=s.position();this.recalculateNodeLabelProjection(s),a.nodeX=o.x,a.nodeY=o.y,a.nodeW=s.pstyle("width").pfValue,a.nodeH=s.pstyle("height").pfValue}this.recalculateEdgeProjections(n);for(i=0;i<n.length;i++){a=(l=(s=n[i])._private).rstyle;var s,l,u=l.rscratch;this.recalculateEdgeLabelProjections(s),a.srcX=u.arrowStartX,a.srcY=u.arrowStartY,a.tgtX=u.arrowEndX,a.tgtY=u.arrowEndY,a.midX=u.midX,a.midY=u.midY,a.labelAngle=u.labelAngle,a.sourceLabelAngle=u.sourceLabelAngle,a.targetLabelAngle=u.targetLabelAngle}}}},Do={updateCachedGrabbedEles:function(){var e=this.cachedZSortedEles;if(e){e.drag=[],e.nondrag=[];for(var t=[],n=0;n<e.length;n++){var r=(i=e[n])._private.rscratch;i.grabbed()&&!i.isParent()?t.push(i):r.inDragLayer?e.drag.push(i):e.nondrag.push(i)}for(n=0;n<t.length;n++){var i=t[n];e.drag.push(i)}}},invalidateCachedZSortedEles:function(){this.cachedZSortedEles=null},getCachedZSortedEles:function(e){if(e||!this.cachedZSortedEles){var t=this.cy.mutableElements().toArray();t.sort(Pi),t.interactive=t.filter(function(e){return e.interactive()}),this.cachedZSortedEles=t,this.updateCachedGrabbedEles()}else t=this.cachedZSortedEles;return t}},To={};[po,fo,go,yo,mo,xo,ko,So,Do].forEach(function(e){S(To,e)});var Po={getCachedImage:function(e,t,n){var r=this.imageCache=this.imageCache||{},i=r[e];if(i)return i.image.complete||i.image.addEventListener("load",n),i.image;var a=(i=r[e]=r[e]||{}).image=new Image;a.addEventListener("load",n),a.addEventListener("error",function(){a.error=!0});return"data:"===e.substring(0,"data:".length).toLowerCase()||(a.crossOrigin=t),a.src=e,a}},Mo={registerBinding:function(e,t,n,r){var i=Array.prototype.slice.apply(arguments,[1]),a=this.binder(e);return a.on.apply(a,i)}};Mo.binder=function(i){var e,a=this,o=i===window||i===document||i===document.body||(e=i,"undefined"!=typeof HTMLElement&&e instanceof HTMLElement);if(null==a.supportsPassiveEvents){var t=!1;try{var n=Object.defineProperty({},"passive",{get:function(){return t=!0}});window.addEventListener("test",null,n)}catch(e){}a.supportsPassiveEvents=t}var r=function(e,t,n){var r=Array.prototype.slice.call(arguments);return o&&a.supportsPassiveEvents&&(r[2]={capture:null!=n&&n,passive:!1,once:!1}),a.bindings.push({target:i,args:r}),(i.addEventListener||i.on).apply(i,r),this};return{on:r,addEventListener:r,addListener:r,bind:r}},Mo.nodeIsDraggable=function(e){return e&&e.isNode()&&!e.locked()&&e.grabbable()},Mo.nodeIsGrabbable=function(e){return this.nodeIsDraggable(e)&&e.interactive()},Mo.load=function(){var q=this,b=function(e){return e.selected()},Y=function(e,t,n,r){null==e&&(e=q.cy);for(var i=0;i<t.length;i++){var a=t[i];e.emit({originalEvent:n,type:a,position:r})}},B=function(e){return e.shiftKey||e.metaKey||e.ctrlKey},X=function(e,t){var n=!0;if(q.cy.hasCompoundNodes()&&e&&e.isEdge())for(var r=0;t&&r<t.length;r++){if((e=t[r]).isNode()&&e.isParent()){n=!1;break}}else n=!0;return n},a=function(e){e[0]._private.rscratch.inDragLayer=!0},m=function(e){e[0]._private.rscratch.isGrabTarget=!0},o=function(e,t){var n=t.addToList;n.has(e)||(n.merge(e),e[0]._private.grabbed=!0)},j=function(e,t){t=t||{};var n=e.cy().hasCompoundNodes();t.inDragLayer&&(e.forEach(a),e.neighborhood().stdFilter(function(e){return!n||e.isEdge()}).forEach(a)),t.addToList&&e.forEach(function(e){o(e,t)}),function(e,t){if(e.cy().hasCompoundNodes()&&(null!=t.inDragLayer||null!=t.addToList)){var n=e.descendants();t.inDragLayer&&(n.forEach(a),n.connectedEdges().forEach(a)),t.addToList&&t.addToList.unmerge(n)}}(e,t),r(e,{inDragLayer:t.inDragLayer}),q.updateCachedGrabbedEles()},x=j,W=function(e){e&&(q.getCachedZSortedEles().forEach(function(e){e[0]._private.grabbed=!1,e[0]._private.rscratch.inDragLayer=!1,e[0]._private.rscratch.isGrabTarget=!1}),q.updateCachedGrabbedEles())},r=function(e,t){if((null!=t.inDragLayer||null!=t.addToList)&&e.cy().hasCompoundNodes()){var n=e.ancestors().orphans();if(!n.same(e)){var r=n.descendants().spawnSelf().merge(n).unmerge(e).unmerge(e.descendants()),i=r.connectedEdges();t.inDragLayer&&(i.forEach(a),r.forEach(a)),t.addToList&&r.forEach(function(e){o(e,t)})}}},w=function(){null!=document.activeElement&&null!=document.activeElement.blur&&document.activeElement.blur()},e="undefined"!=typeof MutationObserver;e?(q.removeObserver=new MutationObserver(function(e){for(var t=0;t<e.length;t++){var n=e[t].removedNodes;if(n)for(var r=0;r<n.length;r++){if(n[r]===q.container){q.destroy();break}}}}),q.container.parentNode&&q.removeObserver.observe(q.container.parentNode,{childList:!0})):q.registerBinding(q.container,"DOMNodeRemoved",function(e){q.destroy()});var t=ae(function(){q.cy.resize()},100);e&&(q.styleObserver=new MutationObserver(t),q.styleObserver.observe(q.container,{attributes:!0})),q.registerBinding(window,"resize",t);var n=function(){q.invalidateContainerClientCoordsCache()};!function(e,t){for(;null!=e;)t(e),e=e.parentNode}(q.container,function(e){q.registerBinding(e,"transitionend",n),q.registerBinding(e,"animationend",n),q.registerBinding(e,"scroll",n)}),q.registerBinding(q.container,"contextmenu",function(e){e.preventDefault()});var H=function(e){for(var t=q.findContainerClientCoords(),n=t[0],r=t[1],i=t[2],a=t[3],o=e.touches?e.touches:[e],s=!1,l=0;l<o.length;l++){var u=o[l];if(n<=u.clientX&&u.clientX<=n+i&&r<=u.clientY&&u.clientY<=r+a){s=!0;break}}if(!s)return!1;for(var c=q.container,h=e.target.parentNode,d=!1;h;){if(h===c){d=!0;break}h=h.parentNode}return!!d};q.registerBinding(q.container,"mousedown",function(t){if(H(t)){t.preventDefault(),w(),q.hoverData.capture=!0,q.hoverData.which=t.which;var n=q.cy,e=[t.clientX,t.clientY],r=q.projectIntoViewport(e[0],e[1]),i=q.selection,a=q.findNearestElements(r[0],r[1],!0,!1),o=a[0],s=q.dragData.possibleDragElements;q.hoverData.mdownPos=r,q.hoverData.mdownGPos=e;if(3==t.which){q.hoverData.cxtStarted=!0;var l={originalEvent:t,type:"cxttapstart",position:{x:r[0],y:r[1]}};o?(o.activate(),o.emit(l),q.hoverData.down=o):n.emit(l),q.hoverData.downTime=(new Date).getTime(),q.hoverData.cxtDragged=!1}else if(1==t.which){if(o&&o.activate(),null!=o&&q.nodeIsGrabbable(o)){var u=function(e){return{originalEvent:t,type:e,position:{x:r[0],y:r[1]}}};if(m(o),o.selected()){s=q.dragData.possibleDragElements=n.collection();var c=n.$(function(e){return e.isNode()&&e.selected()&&q.nodeIsGrabbable(e)});j(c,{addToList:s}),o.emit(u("grabon")),c.forEach(function(e){e.emit(u("grab"))})}else s=q.dragData.possibleDragElements=n.collection(),x(o,{addToList:s}),o.emit(u("grabon")).emit(u("grab"));q.redrawHint("eles",!0),q.redrawHint("drag",!0)}q.hoverData.down=o,q.hoverData.downs=a,q.hoverData.downTime=(new Date).getTime(),Y(o,["mousedown","tapstart","vmousedown"],t,{x:r[0],y:r[1]}),null==o?(i[4]=1,q.data.bgActivePosistion={x:r[0],y:r[1]},q.redrawHint("select",!0),q.redraw()):o.isEdge()&&(i[4]=1),q.hoverData.tapholdCancelled=!1,clearTimeout(q.hoverData.tapholdTimeout),q.hoverData.tapholdTimeout=setTimeout(function(){if(!q.hoverData.tapholdCancelled){var e=q.hoverData.down;e?e.emit({originalEvent:t,type:"taphold",position:{x:r[0],y:r[1]}}):n.emit({originalEvent:t,type:"taphold",position:{x:r[0],y:r[1]}})}},q.tapholdDuration)}i[0]=i[2]=r[0],i[1]=i[3]=r[1]}},!1),q.registerBinding(window,"mousemove",function(e){if(q.hoverData.capture||H(e)){var t=!1,n=q.cy,r=n.zoom(),i=[e.clientX,e.clientY],a=q.projectIntoViewport(i[0],i[1]),o=q.hoverData.mdownPos,s=q.hoverData.mdownGPos,l=q.selection,u=null;q.hoverData.draggingEles||q.hoverData.dragging||q.hoverData.selecting||(u=q.findNearestElement(a[0],a[1],!0,!1));var c,h=q.hoverData.last,d=q.hoverData.down,p=[a[0]-l[2],a[1]-l[3]],f=q.dragData.possibleDragElements;if(s){var g=i[0]-s[0],v=g*g,y=i[1]-s[1],m=v+y*y;q.hoverData.isOverThresholdDrag=c=m>=q.desktopTapThreshold2}var b=B(e);c&&(q.hoverData.tapholdCancelled=!0);t=!0,Y(u,["mousemove","vmousemove","tapdrag"],e,{x:a[0],y:a[1]});var x,w=function(){q.data.bgActivePosistion=void 0,q.hoverData.selecting||n.emit({originalEvent:e,type:"boxstart",position:{x:a[0],y:a[1]}}),l[4]=1,q.hoverData.selecting=!0,q.redrawHint("select",!0),q.redraw()};if(3===q.hoverData.which){if(c){var E={originalEvent:e,type:"cxtdrag",position:{x:a[0],y:a[1]}};d?d.emit(E):n.emit(E),q.hoverData.cxtDragged=!0,q.hoverData.cxtOver&&u===q.hoverData.cxtOver||(q.hoverData.cxtOver&&q.hoverData.cxtOver.emit({originalEvent:e,type:"cxtdragout",position:{x:a[0],y:a[1]}}),(q.hoverData.cxtOver=u)&&u.emit({originalEvent:e,type:"cxtdragover",position:{x:a[0],y:a[1]}}))}}else if(q.hoverData.dragging){if(t=!0,n.panningEnabled()&&n.userPanningEnabled()){var k;if(q.hoverData.justStartedPan){var C=q.hoverData.mdownPos;k={x:(a[0]-C[0])*r,y:(a[1]-C[1])*r},q.hoverData.justStartedPan=!1}else k={x:p[0]*r,y:p[1]*r};n.panBy(k),q.hoverData.dragged=!0}a=q.projectIntoViewport(e.clientX,e.clientY)}else if(1!=l[4]||null!=d&&!d.isEdge()){if(d&&d.isEdge()&&d.active()&&d.unactivate(),d&&d.grabbed()||u==h||(h&&Y(h,["mouseout","tapdragout"],e,{x:a[0],y:a[1]}),u&&Y(u,["mouseover","tapdragover"],e,{x:a[0],y:a[1]}),q.hoverData.last=u),d)if(c){if(n.boxSelectionEnabled()&&b)d&&d.grabbed()&&(W(f),d.emit("freeon"),f.emit("free"),q.dragData.didDrag&&(d.emit("dragfreeon"),f.emit("dragfree"))),w();else if(d&&d.grabbed()&&q.nodeIsDraggable(d)){var S=!q.dragData.didDrag;S&&q.redrawHint("eles",!0),q.dragData.didDrag=!0;var D=n.collection();q.hoverData.draggingEles||j(f,{inDragLayer:!0});var T={x:0,y:0};if($t(p[0])&&$t(p[1])&&(T.x+=p[0],T.y+=p[1],S)){var P=q.hoverData.dragDelta;P&&$t(P[0])&&$t(P[1])&&(T.x+=P[0],T.y+=P[1])}for(var M=0;M<f.length;M++){var _=f[M];q.nodeIsDraggable(_)&&_.grabbed()&&D.merge(_)}q.hoverData.draggingEles=!0,D.silentShift(T).emit("position drag"),q.redrawHint("drag",!0),q.redraw()}}else 0===(x=q.hoverData.dragDelta=q.hoverData.dragDelta||[]).length?(x.push(p[0]),x.push(p[1])):(x[0]+=p[0],x[1]+=p[1]);t=!0}else if(c){if(q.hoverData.dragging||!n.boxSelectionEnabled()||!b&&n.panningEnabled()&&n.userPanningEnabled()){if(!q.hoverData.selecting&&n.panningEnabled()&&n.userPanningEnabled()){X(d,q.hoverData.downs)&&(q.hoverData.dragging=!0,q.hoverData.justStartedPan=!0,l[4]=0,q.data.bgActivePosistion=$e(o),q.redrawHint("select",!0),q.redraw())}}else w();d&&d.isEdge()&&d.active()&&d.unactivate()}return l[2]=a[0],l[3]=a[1],t?(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),!1):void 0}},!1),q.registerBinding(window,"mouseup",function(e){if(q.hoverData.capture){q.hoverData.capture=!1;var t=q.cy,n=q.projectIntoViewport(e.clientX,e.clientY),r=q.selection,i=q.findNearestElement(n[0],n[1],!0,!1),a=q.dragData.possibleDragElements,o=q.hoverData.down,s=B(e);if(q.data.bgActivePosistion&&(q.redrawHint("select",!0),q.redraw()),q.hoverData.tapholdCancelled=!0,q.data.bgActivePosistion=void 0,o&&o.unactivate(),3===q.hoverData.which){var l={originalEvent:e,type:"cxttapend",position:{x:n[0],y:n[1]}};if(o?o.emit(l):t.emit(l),!q.hoverData.cxtDragged){var u={originalEvent:e,type:"cxttap",position:{x:n[0],y:n[1]}};o?o.emit(u):t.emit(u)}q.hoverData.cxtDragged=!1,q.hoverData.which=null}else if(1===q.hoverData.which){if(null!=o||q.dragData.didDrag||q.hoverData.selecting||q.hoverData.dragged||B(e)||(t.$(b).unselect(),0<a.length&&q.redrawHint("eles",!0),q.dragData.possibleDragElements=a=t.collection()),Y(i,["mouseup","tapend","vmouseup"],e,{x:n[0],y:n[1]}),q.dragData.didDrag||q.hoverData.dragged||q.hoverData.selecting||q.hoverData.isOverThresholdDrag||Y(o,["click","tap","vclick"],e,{x:n[0],y:n[1]}),i!=o||q.dragData.didDrag||q.hoverData.selecting||null!=i&&i._private.selectable&&(q.hoverData.dragging||("additive"===t.selectionType()||s?i.selected()?i.unselect():i.select():s||(t.$(b).unmerge(i).unselect(),i.select())),q.redrawHint("eles",!0)),q.hoverData.selecting){var c=t.collection(q.getAllInBox(r[0],r[1],r[2],r[3]));q.redrawHint("select",!0),0<c.length&&q.redrawHint("eles",!0),t.emit({type:"boxend",originalEvent:e,position:{x:n[0],y:n[1]}});var h=function(e){return e.selectable()&&!e.selected()};"additive"===t.selectionType()||s||t.$(b).unmerge(c).unselect(),c.emit("box").stdFilter(h).select().emit("boxselect"),q.redraw()}if(q.hoverData.dragging&&(q.hoverData.dragging=!1,q.redrawHint("select",!0),q.redrawHint("eles",!0),q.redraw()),!r[4]){q.redrawHint("drag",!0),q.redrawHint("eles",!0);var d=o&&o.grabbed();W(a),d&&(o.emit("freeon"),a.emit("free"),q.dragData.didDrag&&(o.emit("dragfreeon"),a.emit("dragfree")))}}r[4]=0,q.hoverData.down=null,q.hoverData.cxtStarted=!1,q.hoverData.draggingEles=!1,q.hoverData.selecting=!1,q.hoverData.isOverThresholdDrag=!1,q.dragData.didDrag=!1,q.hoverData.dragged=!1,q.hoverData.dragDelta=[],q.hoverData.mdownPos=null,q.hoverData.mdownGPos=null}},!1);var K,G,Z,U,$,Q,E,J,ee,te,k,C,ne;q.registerBinding(q.container,"wheel",function(e){if(!q.scrollingPage){var t,n=q.cy,r=q.projectIntoViewport(e.clientX,e.clientY),i=[r[0]*n.zoom()+n.pan().x,r[1]*n.zoom()+n.pan().y];q.hoverData.draggingEles||q.hoverData.dragging||q.hoverData.cxtStarted||0!==q.selection[4]?e.preventDefault():n.panningEnabled()&&n.userPanningEnabled()&&n.zoomingEnabled()&&n.userZoomingEnabled()&&(e.preventDefault(),q.data.wheelZooming=!0,clearTimeout(q.data.wheelTimeout),q.data.wheelTimeout=setTimeout(function(){q.data.wheelZooming=!1,q.redrawHint("eles",!0),q.redraw()},150),t=null!=e.deltaY?e.deltaY/-250:null!=e.wheelDeltaY?e.wheelDeltaY/1e3:e.wheelDelta/1e3,t*=q.wheelSensitivity,1===e.deltaMode&&(t*=33),n.zoom({level:n.zoom()*Math.pow(10,t),renderedPosition:{x:i[0],y:i[1]}}))}},!0),q.registerBinding(window,"scroll",function(e){q.scrollingPage=!0,clearTimeout(q.scrollingPageTimeout),q.scrollingPageTimeout=setTimeout(function(){q.scrollingPage=!1},250)},!0),q.registerBinding(q.container,"mouseout",function(e){var t=q.projectIntoViewport(e.clientX,e.clientY);q.cy.emit({originalEvent:e,type:"mouseout",position:{x:t[0],y:t[1]}})},!1),q.registerBinding(q.container,"mouseover",function(e){var t=q.projectIntoViewport(e.clientX,e.clientY);q.cy.emit({originalEvent:e,type:"mouseover",position:{x:t[0],y:t[1]}})},!1);var i,s,l,u,re=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},ie=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)};if(q.registerBinding(q.container,"touchstart",i=function(t){if(H(t)){w(),q.touchData.capture=!0,q.data.bgActivePosistion=void 0;var e=q.cy,n=q.touchData.now,r=q.touchData.earlier;if(t.touches[0]){var i=q.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);n[0]=i[0],n[1]=i[1]}if(t.touches[1]){i=q.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);n[2]=i[0],n[3]=i[1]}if(t.touches[2]){i=q.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);n[4]=i[0],n[5]=i[1]}if(t.touches[1]){W(q.dragData.touchDragEles);var a=q.findContainerClientCoords();ee=a[0],te=a[1],k=a[2],C=a[3],K=t.touches[0].clientX-ee,G=t.touches[0].clientY-te,Z=t.touches[1].clientX-ee,U=t.touches[1].clientY-te,ne=0<=K&&K<=k&&0<=Z&&Z<=k&&0<=G&&G<=C&&0<=U&&U<=C;var o=e.pan(),s=e.zoom();$=re(K,G,Z,U),Q=ie(K,G,Z,U),J=[((E=[(K+Z)/2,(G+U)/2])[0]-o.x)/s,(E[1]-o.y)/s];if(Q<4e4&&!t.touches[2]){var l=q.findNearestElement(n[0],n[1],!0,!0),u=q.findNearestElement(n[2],n[3],!0,!0);return l&&l.isNode()?(l.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:n[0],y:n[1]}}),q.touchData.start=l):u&&u.isNode()?(u.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:n[0],y:n[1]}}),q.touchData.start=u):e.emit({originalEvent:t,type:"cxttapstart",position:{x:n[0],y:n[1]}}),q.touchData.start&&(q.touchData.start._private.grabbed=!1),q.touchData.cxt=!0,q.touchData.cxtDragged=!1,q.data.bgActivePosistion=void 0,void q.redraw()}}if(t.touches[2]);else if(t.touches[1]);else if(t.touches[0]){var c=q.findNearestElements(n[0],n[1],!0,!0),h=c[0];if(null!=h&&(h.activate(),q.touchData.start=h,q.touchData.starts=c,q.nodeIsGrabbable(h))){var d=q.dragData.touchDragEles=e.collection(),p=null;q.redrawHint("eles",!0),q.redrawHint("drag",!0),h.selected()?(p=e.$(function(e){return e.selected()&&q.nodeIsGrabbable(e)}),j(p,{addToList:d})):x(h,{addToList:d}),m(h);var f=function(e){return{originalEvent:t,type:e,position:{x:n[0],y:n[1]}}};h.emit(f("grabon")),p?p.forEach(function(e){e.emit(f("grab"))}):h.emit(f("grab"))}Y(h,["touchstart","tapstart","vmousedown"],t,{x:n[0],y:n[1]}),null==h&&(q.data.bgActivePosistion={x:i[0],y:i[1]},q.redrawHint("select",!0),q.redraw()),q.touchData.singleTouchMoved=!1,q.touchData.singleTouchStartTime=+new Date,clearTimeout(q.touchData.tapholdTimeout),q.touchData.tapholdTimeout=setTimeout(function(){!1!==q.touchData.singleTouchMoved||q.pinching||q.touchData.selecting||Y(q.touchData.start,["taphold"],t,{x:n[0],y:n[1]})},q.tapholdDuration)}if(1<=t.touches.length){for(var g=q.touchData.startPosition=[],v=0;v<n.length;v++)g[v]=r[v]=n[v];var y=t.touches[0];q.touchData.startGPosition=[y.clientX,y.clientY]}}},!1),q.registerBinding(window,"touchmove",s=function(e){var t=q.touchData.capture;if(t||H(e)){var n=q.selection,r=q.cy,i=q.touchData.now,a=q.touchData.earlier,o=r.zoom();if(e.touches[0]){var s=q.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);i[0]=s[0],i[1]=s[1]}if(e.touches[1]){s=q.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);i[2]=s[0],i[3]=s[1]}if(e.touches[2]){s=q.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);i[4]=s[0],i[5]=s[1]}var l,u=q.touchData.startGPosition;if(t&&e.touches[0]&&u){for(var c=[],h=0;h<i.length;h++)c[h]=i[h]-a[h];var d=e.touches[0].clientX-u[0],p=d*d,f=e.touches[0].clientY-u[1];l=p+f*f>=q.touchTapThreshold2}if(t&&q.touchData.cxt){e.preventDefault();var g=e.touches[0].clientX-ee,v=e.touches[0].clientY-te,y=e.touches[1].clientX-ee,m=e.touches[1].clientY-te,b=ie(g,v,y,m);if(2.25<=b/Q||22500<=b){q.touchData.cxt=!1,q.data.bgActivePosistion=void 0,q.redrawHint("select",!0);var x={originalEvent:e,type:"cxttapend",position:{x:i[0],y:i[1]}};q.touchData.start?(q.touchData.start.unactivate().emit(x),q.touchData.start=null):r.emit(x)}}if(t&&q.touchData.cxt){x={originalEvent:e,type:"cxtdrag",position:{x:i[0],y:i[1]}};q.data.bgActivePosistion=void 0,q.redrawHint("select",!0),q.touchData.start?q.touchData.start.emit(x):r.emit(x),q.touchData.start&&(q.touchData.start._private.grabbed=!1),q.touchData.cxtDragged=!0;var w=q.findNearestElement(i[0],i[1],!0,!0);q.touchData.cxtOver&&w===q.touchData.cxtOver||(q.touchData.cxtOver&&q.touchData.cxtOver.emit({originalEvent:e,type:"cxtdragout",position:{x:i[0],y:i[1]}}),(q.touchData.cxtOver=w)&&w.emit({originalEvent:e,type:"cxtdragover",position:{x:i[0],y:i[1]}}))}else if(t&&e.touches[2]&&r.boxSelectionEnabled())e.preventDefault(),q.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,q.touchData.selecting||r.emit({originalEvent:e,type:"boxstart",position:{x:i[0],y:i[1]}}),q.touchData.selecting=!0,q.redrawHint("select",!0),n&&0!==n.length&&void 0!==n[0]?(n[2]=(i[0]+i[2]+i[4])/3,n[3]=(i[1]+i[3]+i[5])/3):(n[0]=(i[0]+i[2]+i[4])/3,n[1]=(i[1]+i[3]+i[5])/3,n[2]=(i[0]+i[2]+i[4])/3+1,n[3]=(i[1]+i[3]+i[5])/3+1),n[4]=1,q.touchData.selecting=!0,q.redraw();else if(t&&e.touches[1]&&r.zoomingEnabled()&&r.panningEnabled()&&r.userZoomingEnabled()&&r.userPanningEnabled()){if(e.preventDefault(),q.data.bgActivePosistion=void 0,q.redrawHint("select",!0),L=q.dragData.touchDragEles){q.redrawHint("drag",!0);for(var E=0;E<L.length;E++){var k=L[E]._private;k.grabbed=!1,k.rscratch.inDragLayer=!1}}var C=q.touchData.start,S=(g=e.touches[0].clientX-ee,v=e.touches[0].clientY-te,y=e.touches[1].clientX-ee,m=e.touches[1].clientY-te,re(g,v,y,m)),D=S/$;if(ne){var T=(g-K+(y-Z))/2,P=(v-G+(m-U))/2,M=r.zoom(),_=M*D,B=r.pan(),N=J[0]*M+B.x,I=J[1]*M+B.y,A={x:-_/M*(N-B.x-T)+N,y:-_/M*(I-B.y-P)+I};if(C&&C.active()){var L=q.dragData.touchDragEles;W(L),q.redrawHint("drag",!0),q.redrawHint("eles",!0),C.unactivate().emit("freeon"),L.emit("free"),q.dragData.didDrag&&(C.emit("dragfreeon"),L.emit("dragfree"))}r.viewport({zoom:_,pan:A,cancelOnFailedZoom:!0}),$=S,K=g,G=v,Z=y,U=m,q.pinching=!0}if(e.touches[0]){s=q.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);i[0]=s[0],i[1]=s[1]}if(e.touches[1]){s=q.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);i[2]=s[0],i[3]=s[1]}if(e.touches[2]){s=q.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);i[4]=s[0],i[5]=s[1]}}else if(e.touches[0]){var z=q.touchData.start,O=q.touchData.last;if(q.hoverData.draggingEles||q.swipePanning||(w=q.findNearestElement(i[0],i[1],!0,!0)),t&&null!=z&&e.preventDefault(),t&&null!=z&&q.nodeIsDraggable(z))if(l){L=q.dragData.touchDragEles;var R=!q.dragData.didDrag;R&&j(L,{inDragLayer:!0}),q.dragData.didDrag=!0;var F={x:0,y:0};if($t(c[0])&&$t(c[1]))if(F.x+=c[0],F.y+=c[1],R)q.redrawHint("eles",!0),(V=q.touchData.dragDelta)&&$t(V[0])&&$t(V[1])&&(F.x+=V[0],F.y+=V[1]);q.hoverData.draggingEles=!0,L.silentShift(F).emit("position drag"),q.redrawHint("drag",!0),q.touchData.startPosition[0]==a[0]&&q.touchData.startPosition[1]==a[1]&&q.redrawHint("eles",!0),q.redraw()}else{var V;0===(V=q.touchData.dragDelta=q.touchData.dragDelta||[]).length?(V.push(c[0]),V.push(c[1])):(V[0]+=c[0],V[1]+=c[1])}if(Y(z||w,["touchmove","tapdrag","vmousemove"],e,{x:i[0],y:i[1]}),z&&z.grabbed()||w==O||(O&&O.emit({originalEvent:e,type:"tapdragout",position:{x:i[0],y:i[1]}}),w&&w.emit({originalEvent:e,type:"tapdragover",position:{x:i[0],y:i[1]}})),q.touchData.last=w,t)for(E=0;E<i.length;E++)i[E]&&q.touchData.startPosition[E]&&l&&(q.touchData.singleTouchMoved=!0);if(t&&(null==z||z.isEdge())&&r.panningEnabled()&&r.userPanningEnabled()){X(z,q.touchData.starts)&&(e.preventDefault(),q.swipePanning?r.panBy({x:c[0]*o,y:c[1]*o}):l&&(q.swipePanning=!0,r.panBy({x:d*o,y:f*o}),z&&(z.unactivate(),q.data.bgActivePosistion||(q.data.bgActivePosistion=$e(q.touchData.startPosition)),q.redrawHint("select",!0),q.touchData.start=null)));s=q.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);i[0]=s[0],i[1]=s[1]}}for(h=0;h<i.length;h++)a[h]=i[h];t&&0<e.touches.length&&!q.hoverData.draggingEles&&!q.swipePanning&&null!=q.data.bgActivePosistion&&(q.data.bgActivePosistion=void 0,q.redrawHint("select",!0),q.redraw())}},!1),q.registerBinding(window,"touchcancel",l=function(e){var t=q.touchData.start;q.touchData.capture=!1,t&&t.unactivate()}),q.registerBinding(window,"touchend",u=function(e){var t=q.touchData.start;if(q.touchData.capture){0===e.touches.length&&(q.touchData.capture=!1),e.preventDefault();var n=q.selection;q.swipePanning=!1,q.hoverData.draggingEles=!1;var r,i=q.cy,a=i.zoom(),o=q.touchData.now,s=q.touchData.earlier;if(e.touches[0]){var l=q.projectIntoViewport(e.touches[0].clientX,e.touches[0].clientY);o[0]=l[0],o[1]=l[1]}if(e.touches[1]){l=q.projectIntoViewport(e.touches[1].clientX,e.touches[1].clientY);o[2]=l[0],o[3]=l[1]}if(e.touches[2]){l=q.projectIntoViewport(e.touches[2].clientX,e.touches[2].clientY);o[4]=l[0],o[5]=l[1]}if(t&&t.unactivate(),q.touchData.cxt){if(r={originalEvent:e,type:"cxttapend",position:{x:o[0],y:o[1]}},t?t.emit(r):i.emit(r),!q.touchData.cxtDragged){var u={originalEvent:e,type:"cxttap",position:{x:o[0],y:o[1]}};t?t.emit(u):i.emit(u)}return q.touchData.start&&(q.touchData.start._private.grabbed=!1),q.touchData.cxt=!1,q.touchData.start=null,void q.redraw()}if(!e.touches[2]&&i.boxSelectionEnabled()&&q.touchData.selecting){q.touchData.selecting=!1;var c=i.collection(q.getAllInBox(n[0],n[1],n[2],n[3]));n[0]=void 0,n[1]=void 0,n[2]=void 0,n[3]=void 0,n[4]=0,q.redrawHint("select",!0),i.emit({type:"boxend",originalEvent:e,position:{x:o[0],y:o[1]}});c.emit("box").stdFilter(function(e){return e.selectable()&&!e.selected()}).select().emit("boxselect"),c.nonempty()&&q.redrawHint("eles",!0),q.redraw()}if(null!=t&&t.unactivate(),e.touches[2])q.data.bgActivePosistion=void 0,q.redrawHint("select",!0);else if(e.touches[1]);else if(e.touches[0]);else if(!e.touches[0]){q.data.bgActivePosistion=void 0,q.redrawHint("select",!0);var h=q.dragData.touchDragEles;if(null!=t){var d=t._private.grabbed;W(h),q.redrawHint("drag",!0),q.redrawHint("eles",!0),d&&(t.emit("freeon"),h.emit("free"),q.dragData.didDrag&&(t.emit("dragfreeon"),h.emit("dragfree"))),Y(t,["touchend","tapend","vmouseup","tapdragout"],e,{x:o[0],y:o[1]}),t.unactivate(),q.touchData.start=null}else{var p=q.findNearestElement(o[0],o[1],!0,!0);Y(p,["touchend","tapend","vmouseup","tapdragout"],e,{x:o[0],y:o[1]})}var f=q.touchData.startPosition[0]-o[0],g=f*f,v=q.touchData.startPosition[1]-o[1],y=(g+v*v)*a*a;null!=t&&!q.dragData.didDrag&&t._private.selectable&&y<q.touchTapThreshold2&&!q.pinching&&("single"===i.selectionType()?(i.$(b).unmerge(t).unselect(),t.select()):t.selected()?t.unselect():t.select(),q.redrawHint("eles",!0)),q.touchData.singleTouchMoved||(Y(t,["tap","vclick"],e,{x:o[0],y:o[1]}),t||i.$(":selected").unselect()),q.touchData.singleTouchMoved=!0}for(var m=0;m<o.length;m++)s[m]=o[m];q.dragData.didDrag=!1,0===e.touches.length&&(q.touchData.dragDelta=[],q.touchData.startPosition=null,q.touchData.startGPosition=null),e.touches.length<2&&(q.pinching=!1,q.redrawHint("eles",!0),q.redraw())}},!1),"undefined"==typeof TouchEvent){var c=[],h=function(e){return{clientX:e.clientX,clientY:e.clientY,force:1,identifier:e.pointerId,pageX:e.pageX,pageY:e.pageY,radiusX:e.width/2,radiusY:e.height/2,screenX:e.screenX,screenY:e.screenY,target:e.target}},d=function(e){var t;c.push({event:t=e,touch:h(t)})},p=function(e){for(var t=0;t<c.length;t++){if(c[t].event.pointerId===e.pointerId)return void c.splice(t,1)}},f=function(e){e.touches=c.map(function(e){return e.touch})},g=function(e){return"mouse"===e.pointerType||4===e.pointerType};q.registerBinding(q.container,"pointerdown",function(e){g(e)||(e.preventDefault(),d(e),f(e),i(e))}),q.registerBinding(q.container,"pointerup",function(e){g(e)||(p(e),f(e),u(e))}),q.registerBinding(q.container,"pointercancel",function(e){g(e)||(p(e),f(e),l())}),q.registerBinding(q.container,"pointermove",function(e){var t,n;g(e)||(e.preventDefault(),t=e,(n=c.filter(function(e){return e.event.pointerId===t.pointerId})[0]).event=t,n.touch=h(t),f(e),s(e))})}};var _o={generatePolygon:function(e,t){return this.nodeShapes[e]={renderer:this,name:e,points:t,draw:function(e,t,n,r,i){this.renderer.nodeShapeImpl("polygon",e,t,n,r,i,this.points)},intersectLine:function(e,t,n,r,i,a,o){return Et(i,a,this.points,e,t,n/2,r/2,o)},checkPoint:function(e,t,n,r,i,a,o){return gt(e,t,this.points,a,o,r,i,[0,-1],n)}}}};_o.generateEllipse=function(){return this.nodeShapes.ellipse={renderer:this,name:"ellipse",draw:function(e,t,n,r,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,a,o){return function(e,t,n,r,i,a){var o=n-e,s=r-t;o/=i,s/=a;var l=Math.sqrt(o*o+s*s),u=l-1;if(u<0)return[];var c=u/l;return[(n-e)*c+e,(r-t)*c+t]}(i,a,e,t,n/2+o,r/2+o)},checkPoint:function(e,t,n,r,i,a,o){return mt(e,t,r,i,a,o,n)}}},_o.generateRoundRectangle=function(){return this.nodeShapes["round-rectangle"]=this.nodeShapes.roundrectangle={renderer:this,name:"round-rectangle",points:Ct(4,0),draw:function(e,t,n,r,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,a,o){return dt(i,a,e,t,n,r,o)},checkPoint:function(e,t,n,r,i,a,o){var s=Tt(r,i),l=2*s;return!!gt(e,t,this.points,a,o,r,i-l,[0,-1],n)||(!!gt(e,t,this.points,a,o,r-l,i,[0,-1],n)||(!!mt(e,t,l,l,a-r/2+s,o-i/2+s,n)||(!!mt(e,t,l,l,a+r/2-s,o-i/2+s,n)||(!!mt(e,t,l,l,a+r/2-s,o+i/2-s,n)||!!mt(e,t,l,l,a-r/2+s,o+i/2-s,n)))))}}},_o.generateCutRectangle=function(){return this.nodeShapes["cut-rectangle"]=this.nodeShapes.cutrectangle={renderer:this,name:"cut-rectangle",cornerLength:8,points:Ct(4,0),draw:function(e,t,n,r,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},generateCutTrianglePts:function(e,t,n,r){var i=this.cornerLength,a=t/2,o=e/2,s=n-o,l=n+o,u=r-a,c=r+a;return{topLeft:[s,u+i,s+i,u,s+i,u+i],topRight:[l-i,u,l,u+i,l-i,u+i],bottomRight:[l,c-i,l-i,c,l-i,c-i],bottomLeft:[s+i,c,s,c-i,s+i,c-i]}},intersectLine:function(e,t,n,r,i,a,o){var s=this.generateCutTrianglePts(n+2*o,r+2*o,e,t),l=[].concat.apply([],[s.topLeft.splice(0,4),s.topRight.splice(0,4),s.bottomRight.splice(0,4),s.bottomLeft.splice(0,4)]);return Et(i,a,l,e,t)},checkPoint:function(e,t,n,r,i,a,o){if(gt(e,t,this.points,a,o,r,i-2*this.cornerLength,[0,-1],n))return!0;if(gt(e,t,this.points,a,o,r-2*this.cornerLength,i,[0,-1],n))return!0;var s=this.generateCutTrianglePts(r,i,a,o);return ft(e,t,s.topLeft)||ft(e,t,s.topRight)||ft(e,t,s.bottomRight)||ft(e,t,s.bottomLeft)}}},_o.generateBarrel=function(){return this.nodeShapes.barrel={renderer:this,name:"barrel",points:Ct(4,0),draw:function(e,t,n,r,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,a,o){var s=this.generateBarrelBezierPts(n+2*o,r+2*o,e,t),l=function(e){var t=rt({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.15),n=rt({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.5),r=rt({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.85);return[e[0],e[1],t.x,t.y,n.x,n.y,r.x,r.y,e[4],e[5]]},u=[].concat(l(s.topLeft),l(s.topRight),l(s.bottomRight),l(s.bottomLeft));return Et(i,a,u,e,t)},generateBarrelBezierPts:function(e,t,n,r){var i=t/2,a=e/2,o=n-a,s=n+a,l=r-i,u=r+i,c=Pt(e,t),h=c.heightOffset,d=c.widthOffset,p=c.ctrlPtOffsetPct*e,f={topLeft:[o,l+h,o+p,l,o+d,l],topRight:[s-d,l,s-p,l,s,l+h],bottomRight:[s,u-h,s-p,u,s-d,u],bottomLeft:[o+d,u,o+p,u,o,u-h]};return f.topLeft.isTop=!0,f.topRight.isTop=!0,f.bottomLeft.isBottom=!0,f.bottomRight.isBottom=!0,f},checkPoint:function(e,t,n,r,i,a,o){var s=Pt(r,i),l=s.heightOffset,u=s.widthOffset;if(gt(e,t,this.points,a,o,r,i-2*l,[0,-1],n))return!0;if(gt(e,t,this.points,a,o,r-2*u,i,[0,-1],n))return!0;for(var c=this.generateBarrelBezierPts(r,i,a,o),h=function(e,t,n){var r,i,a=n[4],o=n[2],s=n[0],l=n[5],u=n[1],c=Math.min(a,s),h=Math.max(a,s),d=Math.min(l,u),p=Math.max(l,u);if(c<=e&&e<=h&&d<=t&&t<=p){var f=[(r=a)-2*(i=o)+s,2*(i-r),r],g=function(e,t,n,r){var i=t*t-4*e*(n-=r);if(i<0)return[];var a=Math.sqrt(i),o=2*e;return[(-t+a)/o,(-t-a)/o]}(f[0],f[1],f[2],e).filter(function(e){return 0<=e&&e<=1});if(0<g.length)return g[0]}return null},d=Object.keys(c),p=0;p<d.length;p++){var f=c[d[p]],g=h(e,t,f);if(null!=g){var v=f[5],y=f[3],m=f[1],b=nt(v,y,m,g);if(f.isTop&&b<=t)return!0;if(f.isBottom&&t<=b)return!0}}return!1}}},_o.generateBottomRoundrectangle=function(){return this.nodeShapes["bottom-round-rectangle"]=this.nodeShapes.bottomroundrectangle={renderer:this,name:"bottom-round-rectangle",points:Ct(4,0),draw:function(e,t,n,r,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,a,o){var s=t-(r/2+o),l=wt(i,a,e,t,e-(n/2+o),s,e+(n/2+o),s,!1);return 0<l.length?l:dt(i,a,e,t,n,r,o)},checkPoint:function(e,t,n,r,i,a,o){var s=Tt(r,i),l=2*s;if(gt(e,t,this.points,a,o,r,i-l,[0,-1],n))return!0;if(gt(e,t,this.points,a,o,r-l,i,[0,-1],n))return!0;var u=r/2+2*n,c=i/2+2*n;return!!ft(e,t,[a-u,o-c,a-u,o,a+u,o,a+u,o-c])||(!!mt(e,t,l,l,a+r/2-s,o+i/2-s,n)||!!mt(e,t,l,l,a-r/2+s,o+i/2-s,n))}}},_o.registerNodeShapes=function(){var e=this.nodeShapes={},r=this;this.generateEllipse(),this.generatePolygon("triangle",Ct(3,0)),this.generatePolygon("rectangle",Ct(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle(),this.generatePolygon("diamond",[0,1,1,0,0,-1,-1,0]),this.generatePolygon("pentagon",Ct(5,0)),this.generatePolygon("hexagon",Ct(6,0)),this.generatePolygon("heptagon",Ct(7,0)),this.generatePolygon("octagon",Ct(8,0));var t=new Array(20),n=Dt(5,0),i=Dt(5,Math.PI/5),a=.5*(3-Math.sqrt(5));a*=1.57;for(var o=0;o<i.length/2;o++)i[2*o]*=a,i[2*o+1]*=a;for(o=0;o<5;o++)t[4*o]=n[2*o],t[4*o+1]=n[2*o+1],t[4*o+2]=i[2*o],t[4*o+3]=i[2*o+1];t=St(t),this.generatePolygon("star",t),this.generatePolygon("vee",[-1,-1,0,-.333,1,-1,0,1]),this.generatePolygon("rhomboid",[-1,-1,.333,-1,1,1,-.333,1]),this.nodeShapes.concavehexagon=this.generatePolygon("concave-hexagon",[-1,-.95,-.75,0,-1,.95,1,.95,.75,0,1,-.95]),this.generatePolygon("tag",[-1,-1,.25,-1,1,0,.25,1,-1,1]),e.makePolygon=function(e){var t,n="polygon-"+e.join("$");return(t=this[n])?t:r.generatePolygon(n,e)}};var Bo={timeToRender:function(){return this.redrawTotalTime/this.redrawCount},redraw:function(e){e=e||ke();void 0===this.averageRedrawTime&&(this.averageRedrawTime=0),void 0===this.lastRedrawTime&&(this.lastRedrawTime=0),void 0===this.lastDrawTime&&(this.lastDrawTime=0),this.requestedFrame=!0,this.renderOptions=e},beforeRender:function(e,t){if(!this.destroyed){t=t||0;var n=this.beforeRenderCallbacks;n.push({fn:e,priority:t}),n.sort(function(e,t){return t.priority-e.priority})}}},No=function(e,t,n){for(var r=e.beforeRenderCallbacks,i=0;i<r.length;i++)r[i].fn(t,n)};Bo.startRenderLoop=function(){var a=this;if(!a.renderLoopStarted){a.renderLoopStarted=!0;ne(function e(t){if(!a.destroyed){if(a.requestedFrame&&!a.skipFrame){No(a,!0,t);var n=re();a.render(a.renderOptions);var r=a.lastDrawTime=re();void 0===a.averageRedrawTime&&(a.averageRedrawTime=r-n),void 0===a.redrawCount&&(a.redrawCount=0),a.redrawCount++,void 0===a.redrawTotalTime&&(a.redrawTotalTime=0);var i=r-n;a.redrawTotalTime+=i,a.lastRedrawTime=i,a.averageRedrawTime=a.averageRedrawTime/2+i/2,a.requestedFrame=!1}else No(a,!1,t);a.skipFrame=!1,ne(e)}})}};var Io=function(e){this.init(e)},Ao=Io.prototype;Ao.clientFunctions=["redrawHint","render","renderTo","matchCanvasSize","nodeShapeImpl","arrowShapeImpl"],Ao.init=function(e){var t=this;t.options=e,t.cy=e.cy;var n=t.container=e.cy.container();if(w){var r=w.document,i=r.head,a="__________cytoscape_stylesheet",o="__________cytoscape_container",s=null!=r.getElementById(a);if(n.className.indexOf(o)<0&&(n.className=(n.className||"")+" "+o),!s){var l=r.createElement("style");l.id=a,l.innerHTML="."+o+" { position: relative; }",i.insertBefore(l,i.children[0])}"static"===w.getComputedStyle(n).getPropertyValue("position")&&be("A Cytoscape container has style position:static and so can not use UI extensions properly")}t.selection=[void 0,void 0,void 0,void 0,0],t.bezierProjPcts=[.05,.225,.4,.5,.6,.775,.95],t.hoverData={down:null,last:null,downTime:null,triggerMode:null,dragging:!1,initialPan:[null,null],capture:!1},t.dragData={possibleDragElements:[]},t.touchData={start:null,capture:!1,startPosition:[null,null,null,null,null,null],singleTouchStartTime:null,singleTouchMoved:!0,now:[null,null,null,null,null,null],earlier:[null,null,null,null,null,null]},t.redraws=0,t.showFps=e.showFps,t.debug=e.debug,t.hideEdgesOnViewport=e.hideEdgesOnViewport,t.hideLabelsOnViewport=e.hideLabelsOnViewport,t.textureOnViewport=e.textureOnViewport,t.wheelSensitivity=e.wheelSensitivity,t.motionBlurEnabled=e.motionBlur,t.forcedPixelRatio=e.pixelRatio,t.motionBlur=e.motionBlur,t.motionBlurOpacity=e.motionBlurOpacity,t.motionBlurTransparency=1-t.motionBlurOpacity,t.motionBlurPxRatio=1,t.mbPxRBlurry=1,t.minMbLowQualFrames=4,t.fullQualityMb=!1,t.clearedForMotionBlur=[],t.desktopTapThreshold=e.desktopTapThreshold,t.desktopTapThreshold2=e.desktopTapThreshold*e.desktopTapThreshold,t.touchTapThreshold=e.touchTapThreshold,t.touchTapThreshold2=e.touchTapThreshold*e.touchTapThreshold,t.tapholdDuration=500,t.bindings=[],t.beforeRenderCallbacks=[],t.beforeRenderPriorities={animations:400,eleCalcs:300,eleTxrDeq:200,lyrTxrDeq:100},t.registerNodeShapes(),t.registerArrowShapes(),t.registerCalculationListeners()},Ao.notify=function(e,t){this.destroyed||("init"!==e?"destroy"!==e?("add"!==e&&"remove"!==e&&"load"!==e&&"zorder"!==e&&"mount"!==e||this.invalidateCachedZSortedEles(),"viewport"===e&&this.redrawHint("select",!0),"load"!==e&&"resize"!==e&&"mount"!==e||(this.invalidateContainerClientCoordsCache(),this.matchCanvasSize(this.container)),this.redrawHint("eles",!0),this.redrawHint("drag",!0),this.startRenderLoop(),this.redraw()):this.destroy():this.load())},Ao.destroy=function(){var e=this;e.destroyed=!0,e.cy.stopAnimationLoop();for(var t=0;t<e.bindings.length;t++){var n=e.bindings[t],r=n.target;(r.off||r.removeEventListener).apply(r,n.args)}if(e.bindings=[],e.beforeRenderCallbacks=[],e.onUpdateEleCalcsFns=[],e.removeObserver&&e.removeObserver.disconnect(),e.styleObserver&&e.styleObserver.disconnect(),e.labelCalcDiv)try{document.body.removeChild(e.labelCalcDiv)}catch(e){}},Ao.isHeadless=function(){return!1},[ho,To,Po,Mo,_o,Bo].forEach(function(e){S(Ao,e)});var Lo=1e3/60,zo=function(y){return function(){var f=this,g=this.renderer;if(!f.dequeueingSetup){f.dequeueingSetup=!0;var v=ae(function(){g.redrawHint("eles",!0),g.redrawHint("drag",!0),g.redraw()},y.deqRedrawThreshold),e=y.priority||ye;g.beforeRender(function(e,t){for(var n=re(),r=g.averageRedrawTime,i=g.lastRedrawTime,a=[],o=g.cy.extent(),s=g.getPixelRatio();;){var l=re(),u=l-n,c=l-t;if(i<Lo){var h=Lo-(e?r:0);if(c>=y.deqFastCost*h)break}else if(e){if(u>=y.deqCost*i||u>=y.deqAvgCost*r)break}else if(c>=y.deqNoDrawCost*Lo)break;var d=y.deq(f,s,o);if(!(0<d.length))break;for(var p=0;p<d.length;p++)a.push(d[p])}0<a.length&&(y.onDeqd(f,a),!e&&y.shouldRedraw(f,a,s,o)&&v())},e(f))}}},Oo=function(){function n(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:ge;i(this,n),this.idsByKey=new Pe,this.keyForId=new Pe,this.cachesByLvl=new Pe,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=t}return t(n,[{key:"getIdsFor",value:function(e){null==e&&me("Can not get id list for null key");var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new _e,t.set(e,n)),n}},{key:"addIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).add(t)}},{key:"deleteIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).delete(t)}},{key:"getNumberOfIdsForKey",value:function(e){return null==e?0:this.getIdsFor(e).size}},{key:"updateKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t),r=this.getKey(e);this.deleteIdForKey(n,t),this.addIdForKey(r,t),this.keyForId.set(t,r)}},{key:"deleteKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteIdForKey(n,t),this.keyForId.delete(t)}},{key:"keyHasChangedFor",value:function(e){var t=e.id();return this.keyForId.get(t)!==this.getKey(e)}},{key:"isInvalid",value:function(e){return this.keyHasChangedFor(e)||this.doesEleInvalidateKey(e)}},{key:"getCachesAt",value:function(e){var t=this.cachesByLvl,n=this.lvls,r=t.get(e);return r||(r=new Pe,t.set(e,r),n.push(e)),r}},{key:"getCache",value:function(e,t){return this.getCachesAt(t).get(e)}},{key:"get",value:function(e,t){var n=this.getKey(e),r=this.getCache(n,t);return null!=r&&this.updateKeyMappingFor(e),r}},{key:"getForCachedKey",value:function(e,t){var n=this.keyForId.get(e.id());return this.getCache(n,t)}},{key:"hasCache",value:function(e,t){return this.getCachesAt(t).has(e)}},{key:"has",value:function(e,t){var n=this.getKey(e);return this.hasCache(n,t)}},{key:"setCache",value:function(e,t,n){n.key=e,this.getCachesAt(t).set(e,n)}},{key:"set",value:function(e,t,n){var r=this.getKey(e);this.setCache(r,t,n),this.updateKeyMappingFor(e)}},{key:"deleteCache",value:function(e,t){this.getCachesAt(t).delete(e)}},{key:"delete",value:function(e,t){var n=this.getKey(e);this.deleteCache(n,t)}},{key:"invalidateKey",value:function(t){var n=this;this.lvls.forEach(function(e){return n.deleteCache(t,e)})}},{key:"invalidate",value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteKeyMappingFor(e);var r=this.doesEleInvalidateKey(e);return r&&this.invalidateKey(n),r||0===this.getNumberOfIdsForKey(n)}}]),n}(),Ro={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},Fo=Ce({getKey:null,doesEleInvalidateKey:ge,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:fe,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),Vo=function(e,t){this.renderer=e,this.onDequeues=[];var n=Fo(t);S(this,n),this.lookup=new Oo(n.getKey,n.doesEleInvalidateKey),this.setupDequeueing()},qo=Vo.prototype;qo.reasons=Ro,qo.getTextureQueue=function(e){return this.eleImgCaches=this.eleImgCaches||{},this.eleImgCaches[e]=this.eleImgCaches[e]||[]},qo.getRetiredTextureQueue=function(e){var t=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return t[e]=t[e]||[]},qo.getElementQueue=function(){return this.eleCacheQueue=this.eleCacheQueue||new Le(function(e,t){return t.reqs-e.reqs})},qo.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},qo.getElement=function(e,t,n,r,i){var a=this,o=this.renderer,s=o.cy.zoom(),l=this.lookup;if(0===t.w||0===t.h||isNaN(t.w)||isNaN(t.h)||!e.visible())return null;if(!a.allowEdgeTxrCaching&&e.isEdge()||!a.allowParentTxrCaching&&e.isParent())return null;if(null==r&&(r=Math.ceil(Je(s*n))),r<-4)r=-4;else if(7.99<=s||3<r)return null;var u=Math.pow(2,r),c=t.h*u,h=t.w*u,d=o.eleTextBiggerThanMin(e,u);if(!this.isVisible(e,d))return null;var p,f=l.get(e,r);if(f&&f.invalidated&&(f.invalidated=!1,f.texture.invalidatedWidth-=f.width),f)return f;if(p=c<=25?25:c<=50?50:50*Math.ceil(c/50),1024<c||1024<h)return null;var g=a.getTextureQueue(p),v=g[g.length-2],y=function(){return a.recycleTexture(p,h)||a.addTexture(p,h)};v||(v=g[g.length-1]),v||(v=y()),v.width-v.usedWidth<h&&(v=y());for(var m,b=function(e){return e&&e.scaledLabelShown===d},x=i&&i===Ro.dequeue,w=i&&i===Ro.highQuality,E=i&&i===Ro.downscale,k=r+1;k<=3;k++){var C=l.get(e,k);if(C){m=C;break}}var S=m&&m.level===r+1?m:null,D=function(){v.context.drawImage(S.texture.canvas,S.x,0,S.width,S.height,v.usedWidth,0,h,c)};if(v.context.setTransform(1,0,0,1,0,0),v.context.clearRect(v.usedWidth,0,h,p),b(S))D();else if(b(m)){if(!w)return a.queueElement(e,m.level-1),m;for(var T=m.level;r<T;T--)S=a.getElement(e,t,n,T,Ro.downscale);D()}else{var P;if(!x&&!w&&!E)for(var M=r-1;-4<=M;M--){var _=l.get(e,M);if(_){P=_;break}}if(b(P))return a.queueElement(e,r),P;v.context.translate(v.usedWidth,0),v.context.scale(u,u),this.drawElement(v.context,e,t,d,!1),v.context.scale(1/u,1/u),v.context.translate(-v.usedWidth,0)}return f={x:v.usedWidth,texture:v,level:r,scale:u,width:h,height:c,scaledLabelShown:d},v.usedWidth+=Math.ceil(h+8),v.eleCaches.push(f),l.set(e,r,f),a.checkTextureFullness(v),f},qo.invalidateElements=function(e){for(var t=0;t<e.length;t++)this.invalidateElement(e[t])},qo.invalidateElement=function(e){var t=this.lookup,n=[];if(t.isInvalid(e)){for(var r=-4;r<=3;r++){var i=t.getForCachedKey(e,r);i&&n.push(i)}if(t.invalidate(e))for(var a=0;a<n.length;a++){var o=n[a],s=o.texture;s.invalidatedWidth+=o.width,o.invalidated=!0,this.checkTextureUtility(s)}this.removeFromQueue(e)}},qo.checkTextureUtility=function(e){e.invalidatedWidth>=.2*e.width&&this.retireTexture(e)},qo.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);.8<e.usedWidth/e.width&&10<=e.fullnessChecks?Se(t,e):e.fullnessChecks++},qo.retireTexture=function(e){var t=e.height,n=this.getTextureQueue(t),r=this.lookup;Se(n,e),e.retired=!0;for(var i=e.eleCaches,a=0;a<i.length;a++){var o=i[a];r.deleteCache(o.key,o.level)}Qt(i),this.getRetiredTextureQueue(t).push(e)},qo.addTexture=function(e,t){var n={};return this.getTextureQueue(e).push(n),n.eleCaches=[],n.height=e,n.width=Math.max(1024,t),n.usedWidth=0,n.invalidatedWidth=0,n.fullnessChecks=0,n.canvas=this.renderer.makeOffscreenCanvas(n.width,n.height),n.context=n.canvas.getContext("2d"),n},qo.recycleTexture=function(e,t){for(var n=this.getTextureQueue(e),r=this.getRetiredTextureQueue(e),i=0;i<r.length;i++){var a=r[i];if(a.width>=t)return a.retired=!1,a.usedWidth=0,a.invalidatedWidth=0,a.fullnessChecks=0,Qt(a.eleCaches),a.context.setTransform(1,0,0,1,0,0),a.context.clearRect(0,0,a.width,a.height),Se(r,a),n.push(a),a}},qo.queueElement=function(e,t){var n=this.getElementQueue(),r=this.getElementKeyToQueue(),i=this.getKey(e),a=r[i];if(a)a.level=Math.max(a.level,t),a.eles.merge(e),a.reqs++,n.updateItem(a);else{var o={eles:e.spawn().merge(e),level:t,reqs:1,key:i};n.push(o),r[i]=o}},qo.dequeue=function(e){for(var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=[],i=this.lookup,a=0;a<1&&0<t.size();a++){var o=t.pop(),s=o.key,l=o.eles[0],u=i.hasCache(l,o.level);if(n[s]=null,!u){r.push(o);var c=this.getBoundingBox(l);this.getElement(l,c,e,o.level,Ro.dequeue)}}return r},qo.removeFromQueue=function(e){var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=this.getKey(e),i=n[r];null!=i&&(1===i.eles.length?(i.reqs=pe,t.updateItem(i),t.pop(),n[r]=null):i.eles.unmerge(e))},qo.onDequeue=function(e){this.onDequeues.push(e)},qo.offDequeue=function(e){Se(this.onDequeues,e)},qo.setupDequeueing=zo({deqRedrawThreshold:100,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n<e.onDequeues.length;n++){(0,e.onDequeues[n])(t)}},shouldRedraw:function(e,t,n,r){for(var i=0;i<t.length;i++)for(var a=t[i].eles,o=0;o<a.length;o++){var s=a[o].boundingBox();if(ut(s,r))return!0}return!1},priority:function(e){return e.renderer.beforeRenderPriorities.eleTxrDeq}});var Yo=function(e){var n=this,t=n.renderer=e,r=t.cy;n.layersByLevel={},n.firstGet=!0,n.lastInvalidationTime=re()-500,n.skipping=!1,n.eleTxrDeqs=r.collection(),n.scheduleElementRefinement=ae(function(){n.refineElementTextures(n.eleTxrDeqs),n.eleTxrDeqs.unmerge(n.eleTxrDeqs)},50),t.beforeRender(function(e,t){t-n.lastInvalidationTime<=250?n.skipping=!0:n.skipping=!1});n.layersQueue=new Le(function(e,t){return t.reqs-e.reqs}),n.setupDequeueing()},Xo=Yo.prototype,jo=0,Wo=Math.pow(2,53)-1;Xo.makeLayer=function(e,t){var n=Math.pow(2,t),r=Math.ceil(e.w*n),i=Math.ceil(e.h*n),a=this.renderer.makeOffscreenCanvas(r,i),o={id:jo=++jo%Wo,bb:e,level:t,width:r,height:i,canvas:a,context:a.getContext("2d"),eles:[],elesQueue:[],reqs:0},s=o.context,l=-o.bb.x1,u=-o.bb.y1;return s.scale(n,n),s.translate(l,u),o},Xo.getLayers=function(i,e,a){var o=this,t=o.renderer.cy.zoom(),n=o.firstGet;if(o.firstGet=!1,null==a)if((a=Math.ceil(Je(t*e)))<-4)a=-4;else if(3.99<=t||2<a)return null;o.validateLayersElesOrdering(a,i);var s,l,u=o.layersByLevel,c=Math.pow(2,a),h=u[a]=u[a]||[];if(o.levelIsComplete(a,i))return h;!function(){var n=function(e){if(o.validateLayersElesOrdering(e,i),o.levelIsComplete(e,i))return l=u[e],!0},e=function(e){if(!l)for(var t=a+e;-4<=t&&t<=2&&!n(t);t+=e);};e(1),e(-1);for(var t=h.length-1;0<=t;t--){var r=h[t];r.invalid&&Se(h,r)}}();var r=function(e){var t=(e=e||{}).after;if(function(){if(!s){s=at();for(var e=0;e<i.length;e++)t=s,n=i[e].boundingBox(),t.x1=Math.min(t.x1,n.x1),t.x2=Math.max(t.x2,n.x2),t.w=t.x2-t.x1,t.y1=Math.min(t.y1,n.y1),t.y2=Math.max(t.y2,n.y2),t.h=t.y2-t.y1}var t,n}(),16e6<s.w*c*(s.h*c))return null;var n=o.makeLayer(s,a);if(null!=t){var r=h.indexOf(t)+1;h.splice(r,0,n)}else(void 0===e.insert||e.insert)&&h.unshift(n);return n};if(o.skipping&&!n)return null;for(var d=null,p=i.length/1,f=!n,g=0;g<i.length;g++){var v=i[g],y=v._private.rscratch,m=y.imgLayerCaches=y.imgLayerCaches||{},b=m[a];if(b)d=b;else{if((!d||d.eles.length>=p||!ht(d.bb,v.boundingBox()))&&!(d=r({insert:!0,after:d})))return null;l||f?o.queueLayer(d,v):o.drawEleInLayer(d,v,a,e),d.eles.push(v),m[a]=d}}return l||(f?null:h)},Xo.getEleLevelForLayerLevel=function(e,t){return e},Xo.drawEleInLayer=function(e,t,n,r){var i=this.renderer,a=e.context,o=t.boundingBox();0!==o.w&&0!==o.h&&t.visible()&&(n=this.getEleLevelForLayerLevel(n,r),i.setImgSmoothing(a,!1),i.drawCachedElement(a,t,null,null,n,!0),i.setImgSmoothing(a,!0))},Xo.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||0===n.length)return!1;for(var r=0,i=0;i<n.length;i++){var a=n[i];if(0<a.reqs)return!1;if(a.invalid)return!1;r+=a.eles.length}return r===t.length},Xo.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r<n.length;r++){for(var i=n[r],a=-1,o=0;o<t.length;o++)if(i.eles[0]===t[o]){a=o;break}if(a<0)this.invalidateLayer(i);else{var s=a;for(o=0;o<i.eles.length;o++)if(i.eles[o]!==t[s+o]){this.invalidateLayer(i);break}}}},Xo.updateElementsInLayers=function(e,t){for(var n=v(e[0]),r=0;r<e.length;r++)for(var i=n?null:e[r],a=n?e[r]:e[r].ele,o=a._private.rscratch,s=o.imgLayerCaches=o.imgLayerCaches||{},l=-4;l<=2;l++){var u=s[l];u&&(i&&this.getEleLevelForLayerLevel(u.level)!==i.level||t(u,a,i))}},Xo.haveLayers=function(){for(var e=!1,t=-4;t<=2;t++){var n=this.layersByLevel[t];if(n&&0<n.length){e=!0;break}}return e},Xo.invalidateElements=function(e){var r=this;0!==e.length&&(r.lastInvalidationTime=re(),0!==e.length&&r.haveLayers()&&r.updateElementsInLayers(e,function(e,t,n){r.invalidateLayer(e)}))},Xo.invalidateLayer=function(e){if(this.lastInvalidationTime=re(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];Se(r,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var i=0;i<n.length;i++){var a=n[i]._private.rscratch.imgLayerCaches;a&&(a[t]=null)}}},Xo.refineElementTextures=function(e){var a=this;a.updateElementsInLayers(e,function(e,t,n){var r=e.replacement;if(r||((r=e.replacement=a.makeLayer(e.bb,e.level)).replaces=e,r.eles=e.eles),!r.reqs)for(var i=0;i<r.eles.length;i++)a.queueLayer(r,r.eles[i])})},Xo.enqueueElementRefinement=function(e){this.eleTxrDeqs.merge(e),this.scheduleElementRefinement()},Xo.queueLayer=function(e,t){var n=this.layersQueue,r=e.elesQueue,i=r.hasId=r.hasId||{};if(!e.replacement){if(t){if(i[t.id()])return;r.push(t),i[t.id()]=!0}e.reqs?(e.reqs++,n.updateItem(e)):(e.reqs=1,n.push(e))}},Xo.dequeue=function(e){for(var t=this.layersQueue,n=[],r=0;r<1&&0!==t.size();){var i=t.peek();if(i.replacement)t.pop();else if(i.replaces&&i!==i.replaces.replacement)t.pop();else if(i.invalid)t.pop();else{var a=i.elesQueue.shift();a&&(this.drawEleInLayer(i,a,i.level,e),r++),0===n.length&&n.push(!0),0===i.elesQueue.length&&(t.pop(),i.reqs=0,i.replaces&&this.applyLayerReplacement(i),this.requestRedraw())}}return n},Xo.applyLayerReplacement=function(e){var t=this.layersByLevel[e.level],n=e.replaces,r=t.indexOf(n);if(!(r<0||n.invalid)){t[r]=e;for(var i=0;i<e.eles.length;i++){var a=e.eles[i]._private,o=a.imgLayerCaches=a.imgLayerCaches||{};o&&(o[e.level]=e)}this.requestRedraw()}},Xo.requestRedraw=ae(function(){var e=this.renderer;e.redrawHint("eles",!0),e.redrawHint("drag",!0),e.redraw()},100),Xo.setupDequeueing=zo({deqRedrawThreshold:50,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t){return e.dequeue(t)},onDeqd:ye,shouldRedraw:fe,priority:function(e){return e.renderer.beforeRenderPriorities.lyrTxrDeq}});var Ho,Ko={};function Go(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.lineTo(r.x,r.y)}}function Zo(e,t,n){for(var r,i=0;i<t.length;i++){var a=t[i];0===i&&(r=a),e.lineTo(a.x,a.y)}e.quadraticCurveTo(n.x,n.y,r.x,r.y)}function Uo(e,t,n){e.beginPath&&e.beginPath();for(var r=t,i=0;i<r.length;i++){var a=r[i];e.lineTo(a.x,a.y)}var o=n,s=n[0];e.moveTo(s.x,s.y);for(i=1;i<o.length;i++){a=o[i];e.lineTo(a.x,a.y)}e.closePath&&e.closePath()}function $o(e,t,n,r){e.arc(t,n,r,0,2*Math.PI,!1)}Ko.arrowShapeImpl=function(e){return(Ho||(Ho={polygon:Go,"triangle-backcurve":Zo,"triangle-tee":Uo,"triangle-cross":Uo,circle:$o}))[e]};var Qo={drawElement:function(e,t,n,r,i,a){t.isNode()?this.drawNode(e,t,n,r,i,a):this.drawEdge(e,t,n,r,i,a)},drawElementOverlay:function(e,t){t.isNode()?this.drawNodeOverlay(e,t):this.drawEdgeOverlay(e,t)},drawCachedElementPortion:function(e,t,n,r,i,a,o){var s=n.getBoundingBox(t);if(0!==s.w&&0!==s.h){var l=n.getElement(t,s,r,i,a);if(null!=l){var u=t.pstyle("opacity").pfValue;if(0===u)return;var c,h,d,p,f,g,v=o(this,t),y=s.x1,m=s.y1,b=s.w,x=s.h;if(0!==v){var w=n.getRotationPoint(t);d=w.x,p=w.y,e.translate(d,p),e.rotate(v),(f=this.getImgSmoothing(e))||this.setImgSmoothing(e,!0);var E=n.getRotationOffset(t);c=E.x,h=E.y}else c=y,h=m;1!==u&&(g=e.globalAlpha,e.globalAlpha=g*u),e.drawImage(l.texture.canvas,l.x,0,l.width,l.height,c,h,b,x),1!==u&&(e.globalAlpha=g),0!==v&&(e.rotate(-v),e.translate(-d,-p),f||this.setImgSmoothing(e,!1))}else n.drawElement(e,t)}}},Jo=function(){return 0},es=function(e,t){return e.getTextAngle(t,null)},ts=function(e,t){return e.getTextAngle(t,"source")},ns=function(e,t){return e.getTextAngle(t,"target")};Qo.drawCachedElement=function(e,t,n,r,i,a){var o=this.data,s=o.eleTxrCache,l=o.lblTxrCache,u=o.slbTxrCache,c=o.tlbTxrCache,h=t.boundingBox(),d=!0===a?s.reasons.highQuality:null;0!==h.w&&0!==h.h&&t.visible()&&(r&&!ut(h,r)||(this.drawCachedElementPortion(e,t,s,n,i,d,Jo),this.drawCachedElementPortion(e,t,l,n,i,d,es),t.isEdge()&&(this.drawCachedElementPortion(e,t,u,n,i,d,ts),this.drawCachedElementPortion(e,t,c,n,i,d,ns)),this.drawElementOverlay(e,t)))},Qo.drawElements=function(e,t){for(var n=0;n<t.length;n++){var r=t[n];this.drawElement(e,r)}},Qo.drawCachedElements=function(e,t,n,r){for(var i=0;i<t.length;i++){var a=t[i];this.drawCachedElement(e,a,n,r)}},Qo.drawCachedNodes=function(e,t,n,r){for(var i=0;i<t.length;i++){var a=t[i];a.isNode()&&this.drawCachedElement(e,a,n,r)}},Qo.drawLayeredElements=function(e,t,n,r){var i=this.data.lyrTxrCache.getLayers(t,n);if(i)for(var a=0;a<i.length;a++){var o=i[a],s=o.bb;0!==s.w&&0!==s.h&&e.drawImage(o.canvas,s.x1,s.y1,s.w,s.h)}else this.drawCachedElements(e,t,n,r)};var rs={drawEdge:function(t,n,e){var r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],i=!(4<arguments.length&&void 0!==arguments[4])||arguments[4],a=!(5<arguments.length&&void 0!==arguments[5])||arguments[5],o=this,s=n._private.rscratch;if(n.visible()&&!s.badLine&&null!=s.allpts&&!isNaN(s.allpts[0])){var l;e&&(l=e,t.translate(-l.x1,-l.y1));var u=a?n.pstyle("opacity").value:1,c=n.pstyle("line-style").value,h=n.pstyle("width").pfValue,d=n.pstyle("line-cap").value,p=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:u;t.lineWidth=h,t.lineCap=d,o.eleStrokeStyle(t,n,e),o.drawEdgePath(n,t,s.allpts,c),t.lineCap="butt"},f=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:u;o.drawArrowheads(t,n,e)};if(t.lineJoin="round","yes"===n.pstyle("ghost").value){var g=n.pstyle("ghost-offset-x").pfValue,v=n.pstyle("ghost-offset-y").pfValue,y=n.pstyle("ghost-opacity").value,m=u*y;t.translate(g,v),p(m),f(m),t.translate(-g,-v)}p(),f(),i&&o.drawEdgeOverlay(t,n),o.drawElementText(t,n,null,r),e&&t.translate(l.x1,l.y1)}},drawEdgeOverlay:function(e,t){if(t.visible()){var n=t.pstyle("overlay-opacity").value;if(0!==n){var r=this.usePaths(),i=t._private.rscratch,a=2*t.pstyle("overlay-padding").pfValue,o=t.pstyle("overlay-color").value;e.lineWidth=a,"self"!==i.edgeType||r?e.lineCap="round":e.lineCap="butt",this.colorStrokeStyle(e,o[0],o[1],o[2],n),this.drawEdgePath(t,e,i.allpts,"solid")}}},drawEdgePath:function(e,t,n,r){var i,a=e._private.rscratch,o=t,s=!1,l=this.usePaths(),u=e.pstyle("line-dash-pattern").pfValue,c=e.pstyle("line-dash-offset").pfValue;if(l){var h=n.join("$");a.pathCacheKey&&a.pathCacheKey===h?(i=t=a.pathCache,s=!0):(i=t=new Path2D,a.pathCacheKey=h,a.pathCache=i)}if(o.setLineDash)switch(r){case"dotted":o.setLineDash([1,1]);break;case"dashed":o.setLineDash(u),o.lineDashOffset=c;break;case"solid":o.setLineDash([])}if(!s&&!a.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),a.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var d=2;d+3<n.length;d+=4)t.quadraticCurveTo(n[d],n[d+1],n[d+2],n[d+3]);break;case"straight":case"segments":case"haystack":for(var p=2;p+1<n.length;p+=2)t.lineTo(n[p],n[p+1])}t=o,l?t.stroke(i):t.stroke(),t.setLineDash&&t.setLineDash([])},drawArrowheads:function(e,t,n){var r=t._private.rscratch,i="haystack"===r.edgeType;i||this.drawArrowhead(e,t,"source",r.arrowStartX,r.arrowStartY,r.srcArrowAngle,n),this.drawArrowhead(e,t,"mid-target",r.midX,r.midY,r.midtgtArrowAngle,n),this.drawArrowhead(e,t,"mid-source",r.midX,r.midY,r.midsrcArrowAngle,n),i||this.drawArrowhead(e,t,"target",r.arrowEndX,r.arrowEndY,r.tgtArrowAngle,n)},drawArrowhead:function(e,t,n,r,i,a,o){if(!(isNaN(r)||null==r||isNaN(i)||null==i||isNaN(a)||null==a)){var s=t.pstyle(n+"-arrow-shape").value;if("none"!==s){var l="hollow"===t.pstyle(n+"-arrow-fill").value?"both":"filled",u=t.pstyle(n+"-arrow-fill").value,c=t.pstyle("width").pfValue,h=t.pstyle("opacity").value;void 0===o&&(o=h);var d=e.globalCompositeOperation;1===o&&"hollow"!==u||(e.globalCompositeOperation="destination-out",this.colorFillStyle(e,255,255,255,1),this.colorStrokeStyle(e,255,255,255,1),this.drawArrowShape(t,e,l,c,s,r,i,a),e.globalCompositeOperation=d);var p=t.pstyle(n+"-arrow-color").value;this.colorFillStyle(e,p[0],p[1],p[2],o),this.colorStrokeStyle(e,p[0],p[1],p[2],o),this.drawArrowShape(t,e,u,c,s,r,i,a)}}},drawArrowShape:function(e,t,n,r,i,a,o,s){var l,u=this.usePaths()&&"triangle-cross"!==i,c=!1,h=t,d={x:a,y:o},p=e.pstyle("arrow-scale").value,f=this.getArrowWidth(r,p),g=this.arrowShapes[i];if(u){var v=this.arrowPathCache=this.arrowPathCache||[],y=le(i),m=v[y];null!=m?(l=t=m,c=!0):(l=t=new Path2D,v[y]=l)}t.beginPath&&t.beginPath(),c||(u?g.draw(t,1,0,{x:0,y:0},1):g.draw(t,f,s,d,r)),t.closePath&&t.closePath(),t=h,u&&(t.translate(a,o),t.rotate(s),t.scale(f,f)),"filled"!==n&&"both"!==n||(u?t.fill(l):t.fill()),"hollow"!==n&&"both"!==n||(t.lineWidth=(g.matchEdgeWidth?r:1)/(u?f:1),t.lineJoin="miter",u?t.stroke(l):t.stroke()),u&&(t.scale(1/f,1/f),t.rotate(-s),t.translate(-a,-o))}},is={safeDrawImage:function(e,t,n,r,i,a,o,s,l,u){i<=0||a<=0||l<=0||u<=0||e.drawImage(t,n,r,i,a,o,s,l,u)},drawInscribedImage:function(e,t,n,r,i){var a=n.position(),o=a.x,s=a.y,l=n.cy().style(),u=l.getIndexedStyle.bind(l),c=u(n,"background-fit","value",r),h=u(n,"background-repeat","value",r),d=n.width(),p=n.height(),f=2*n.padding(),g=d+("inner"===u(n,"background-width-relative-to","value",r)?0:f),v=p+("inner"===u(n,"background-height-relative-to","value",r)?0:f),y=n._private.rscratch,m="node"===n.pstyle("background-clip").value,b=u(n,"background-image-opacity","value",r)*i,x=t.width||t.cachedW,w=t.height||t.cachedH;null!=x&&null!=w||(document.body.appendChild(t),x=t.cachedW=t.width||t.offsetWidth,w=t.cachedH=t.height||t.offsetHeight,document.body.removeChild(t));var E=x,k=w;if("auto"!==u(n,"background-width","value",r)&&(E="%"===u(n,"background-width","units",r)?u(n,"background-width","pfValue",r)*g:u(n,"background-width","pfValue",r)),"auto"!==u(n,"background-height","value",r)&&(k="%"===u(n,"background-height","units",r)?u(n,"background-height","pfValue",r)*v:u(n,"background-height","pfValue",r)),0!==E&&0!==k){if("contain"===c)E*=C=Math.min(g/E,v/k),k*=C;else if("cover"===c){var C;E*=C=Math.max(g/E,v/k),k*=C}var S=o-g/2;"%"===u(n,"background-position-x","units",r)?S+=(g-E)*u(n,"background-position-x","pfValue",r):S+=u(n,"background-position-x","pfValue",r);var D=s-v/2;"%"===u(n,"background-position-y","units",r)?D+=(v-k)*u(n,"background-position-y","pfValue",r):D+=u(n,"background-position-y","pfValue",r),y.pathCache&&(S-=o,D-=s,s=o=0);var T=e.globalAlpha;if(e.globalAlpha=b,"no-repeat"===h)m&&(e.save(),y.pathCache?e.clip(y.pathCache):(this.nodeShapes[this.getNodeShape(n)].draw(e,o,s,g,v),e.clip())),this.safeDrawImage(e,t,0,0,x,w,S,D,E,k),m&&e.restore();else{var P=e.createPattern(t,h);e.fillStyle=P,this.nodeShapes[this.getNodeShape(n)].draw(e,o,s,g,v),e.translate(S,D),e.fill(),e.translate(-S,-D)}e.globalAlpha=T}}},as={};as.eleTextBiggerThanMin=function(e,t){if(!t){var n=e.cy().zoom(),r=this.getPixelRatio(),i=Math.ceil(Je(n*r));t=Math.pow(2,i)}return!(e.pstyle("font-size").pfValue*t<e.pstyle("min-zoomed-font-size").pfValue)},as.drawElementText=function(e,t,n,r,i){var a=!(5<arguments.length&&void 0!==arguments[5])||arguments[5];if(null==r){if(!this.eleTextBiggerThanMin(t))return}else if(!1===r)return;if(t.isNode()){if(!(o=t.pstyle("label"))||!o.value)return;switch(t.pstyle("text-halign").strValue){case"left":e.textAlign="right";break;case"right":e.textAlign="left";break;default:e.textAlign="center"}e.textBaseline="bottom"}else{var o=t.pstyle("label"),s=t.pstyle("source-label"),l=t.pstyle("target-label");if(!(o&&o.value||s&&s.value||l&&l.value))return;e.textAlign="center",e.textBaseline="bottom"}var u,c=!n;n&&(u=n,e.translate(-u.x1,-u.y1)),null==i?(this.drawText(e,t,null,c,a),t.isEdge()&&(this.drawText(e,t,"source",c,a),this.drawText(e,t,"target",c,a))):this.drawText(e,t,i,c,a),n&&e.translate(u.x1,u.y1)},as.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n<this.fontCaches.length;n++)if((t=this.fontCaches[n]).context===e)return t;return t={context:e},this.fontCaches.push(t),t},as.setupTextStyle=function(e,t){var n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],r=t.pstyle("font-style").strValue,i=t.pstyle("font-size").pfValue+"px",a=t.pstyle("font-family").strValue,o=t.pstyle("font-weight").strValue,s=t.pstyle("text-opacity").value*(n?t.effectiveOpacity():1),l=t.pstyle("text-outline-opacity").value*s,u=t.pstyle("color").value,c=t.pstyle("text-outline-color").value;e.font=r+" "+o+" "+i+" "+a,e.lineJoin="round",this.colorFillStyle(e,u[0],u[1],u[2],s),this.colorStrokeStyle(e,c[0],c[1],c[2],l)},as.getTextAngle=function(e,t){var n=e._private.rscratch,r=t?t+"-":"",i=e.pstyle(r+"text-rotation"),a=De(n,"labelAngle",t);return"autorotate"===i.strValue?e.isEdge()?a:0:"none"===i.strValue?0:i.pfValue},as.drawText=function(e,t,n){var r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],i=!(4<arguments.length&&void 0!==arguments[4])||arguments[4],a=t._private.rscratch,o=i?t.effectiveOpacity():1;if(0!==o&&0!==t.pstyle("text-opacity").value){"main"===n&&(n=null);var s,l,u,c,h,d,p=De(a,"labelX",n),f=De(a,"labelY",n),g=this.getLabelText(t,n);if(null!=g&&""!==g&&!isNaN(p)&&!isNaN(f)){this.setupTextStyle(e,t,i);var v,y=n?n+"-":"",m=De(a,"labelWidth",n),b=De(a,"labelHeight",n),x=t.pstyle(y+"text-margin-x").pfValue,w=t.pstyle(y+"text-margin-y").pfValue,E=t.isEdge(),k=t.pstyle("text-halign").value,C=t.pstyle("text-valign").value;if(E&&(C=k="center"),p+=x,f+=w,0!==(v=r?this.getTextAngle(t,n):0)){var S=p,D=f;e.translate(S,D),e.rotate(v),f=p=0}switch(C){case"top":break;case"center":f+=b/2;break;case"bottom":f+=b}var T=t.pstyle("text-background-opacity").value,P=t.pstyle("text-border-opacity").value,M=t.pstyle("text-border-width").pfValue,_=t.pstyle("text-background-padding").pfValue;if(0<T||0<M&&0<P){var B=p-_;switch(k){case"left":B-=m;break;case"center":B-=m/2}var N=f-b-_,I=m+2*_,A=b+2*_;if(0<T){var L=e.fillStyle,z=t.pstyle("text-background-color").value;e.fillStyle="rgba("+z[0]+","+z[1]+","+z[2]+","+T*o+")","roundrectangle"==t.pstyle("text-background-shape").strValue?(l=B,u=N,c=I,h=A,d=(d=2)||5,(s=e).beginPath(),s.moveTo(l+d,u),s.lineTo(l+c-d,u),s.quadraticCurveTo(l+c,u,l+c,u+d),s.lineTo(l+c,u+h-d),s.quadraticCurveTo(l+c,u+h,l+c-d,u+h),s.lineTo(l+d,u+h),s.quadraticCurveTo(l,u+h,l,u+h-d),s.lineTo(l,u+d),s.quadraticCurveTo(l,u,l+d,u),s.closePath(),s.fill()):e.fillRect(B,N,I,A),e.fillStyle=L}if(0<M&&0<P){var O=e.strokeStyle,R=e.lineWidth,F=t.pstyle("text-border-color").value,V=t.pstyle("text-border-style").value;if(e.strokeStyle="rgba("+F[0]+","+F[1]+","+F[2]+","+P*o+")",e.lineWidth=M,e.setLineDash)switch(V){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=M/4,e.setLineDash([]);break;case"solid":e.setLineDash([])}if(e.strokeRect(B,N,I,A),"double"===V){var q=M/2;e.strokeRect(B+q,N+q,I-2*q,A-2*q)}e.setLineDash&&e.setLineDash([]),e.lineWidth=R,e.strokeStyle=O}}var Y=2*t.pstyle("text-outline-width").pfValue;if(0<Y&&(e.lineWidth=Y),"wrap"===t.pstyle("text-wrap").value){var X=De(a,"labelWrapCachedLines",n),j=b/X.length;switch(C){case"top":f-=(X.length-1)*j;break;case"center":case"bottom":f-=(X.length-1)*j}for(var W=0;W<X.length;W++)0<Y&&e.strokeText(X[W],p,f),e.fillText(X[W],p,f),f+=j}else 0<Y&&e.strokeText(g,p,f),e.fillText(g,p,f);0!==v&&(e.rotate(-v),e.translate(-S,-D))}}};var os={drawNode:function(i,a,e){var n,r,t=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],o=!(4<arguments.length&&void 0!==arguments[4])||arguments[4],s=!(5<arguments.length&&void 0!==arguments[5])||arguments[5],l=this,u=a._private,c=u.rscratch,h=a.position();if($t(h.x)&&$t(h.y)&&a.visible()){var d,p,f=s?a.effectiveOpacity():1,g=l.usePaths(),v=!1,y=a.padding();n=a.width()+2*y,r=a.height()+2*y,e&&(p=e,i.translate(-p.x1,-p.y1));for(var m=a.pstyle("background-image").value,b=new Array(m.length),x=new Array(m.length),w=0,E=0;E<m.length;E++){var k=m[E];if(b[E]=null!=k&&"none"!==k){var C=a.cy().style().getIndexedStyle(a,"background-image-crossorigin","value",E);w++,x[E]=l.getCachedImage(k,C,function(){u.backgroundTimestamp=Date.now(),a.emitAndNotify("background")})}}var S=a.pstyle("background-blacken").value,D=a.pstyle("border-width").pfValue,T=a.pstyle("background-opacity").value*f,P=a.pstyle("border-color").value,M=a.pstyle("border-style").value,_=a.pstyle("border-opacity").value*f;i.lineJoin="miter";var B=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:T;l.eleFillStyle(i,a,e)},N=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:_;l.colorStrokeStyle(i,P[0],P[1],P[2],e)},I=a.pstyle("shape").strValue,A=a.pstyle("shape-polygon-points").pfValue;if(g){i.translate(h.x,h.y);var L=l.nodePathCache=l.nodePathCache||[],z=ue("polygon"===I?I+","+A.join(","):I,""+r,""+n),O=L[z];null!=O?(d=O,v=!0,c.pathCache=d):(d=new Path2D,L[z]=c.pathCache=d)}var R=function(){if(!v){var e=h;g&&(e={x:0,y:0}),l.nodeShapes[l.getNodeShape(a)].draw(d||i,e.x,e.y,n,r)}g?i.fill(d):i.fill()},F=function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:f,t=u.backgrounding,n=0,r=0;r<x.length;r++)b[r]&&x[r].complete&&!x[r].error&&(n++,l.drawInscribedImage(i,x[r],a,r,e));u.backgrounding=!(n===w),t!==u.backgrounding&&a.updateStyle(!1)},V=function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:f;l.hasPie(a)&&(l.drawPie(i,a,t),e&&(g||l.nodeShapes[l.getNodeShape(a)].draw(i,h.x,h.y,n,r)))},q=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:f,t=(0<S?S:-S)*e,n=0<S?0:255;0!==S&&(l.colorFillStyle(i,n,n,n,t),g?i.fill(d):i.fill())},Y=function(){if(0<D){if(i.lineWidth=D,i.lineCap="butt",i.setLineDash)switch(M){case"dotted":i.setLineDash([1,1]);break;case"dashed":i.setLineDash([4,2]);break;case"solid":case"double":i.setLineDash([])}if(g?i.stroke(d):i.stroke(),"double"===M){i.lineWidth=D/3;var e=i.globalCompositeOperation;i.globalCompositeOperation="destination-out",g?i.stroke(d):i.stroke(),i.globalCompositeOperation=e}i.setLineDash&&i.setLineDash([])}};if("yes"===a.pstyle("ghost").value){var X=a.pstyle("ghost-offset-x").pfValue,j=a.pstyle("ghost-offset-y").pfValue,W=a.pstyle("ghost-opacity").value,H=W*f;i.translate(X,j),B(W*T),R(),F(H),V(0!==S||0!==D),q(H),N(W*_),Y(),i.translate(-X,-j)}B(),R(),F(),V(0!==S||0!==D),q(),N(),Y(),g&&i.translate(-h.x,-h.y),l.drawElementText(i,a,null,t),o&&l.drawNodeOverlay(i,a,h,n,r),e&&i.translate(p.x1,p.y1)}},drawNodeOverlay:function(e,t,n,r,i){if(t.visible()){var a=t.pstyle("overlay-padding").pfValue,o=t.pstyle("overlay-opacity").value,s=t.pstyle("overlay-color").value;if(0<o){if(n=n||t.position(),null==r||null==i){var l=t.padding();r=t.width()+2*l,i=t.height()+2*l}this.colorFillStyle(e,s[0],s[1],s[2],o),this.nodeShapes.roundrectangle.draw(e,n.x,n.y,r+2*a,i+2*a),e.fill()}}},hasPie:function(e){return(e=e[0])._private.hasPie},drawPie:function(e,t,n,r){t=t[0],r=r||t.position();var i=t.cy().style(),a=t.pstyle("pie-size"),o=r.x,s=r.y,l=t.width(),u=t.height(),c=Math.min(l,u)/2,h=0;this.usePaths()&&(s=o=0),"%"===a.units?c*=a.pfValue:void 0!==a.pfValue&&(c=a.pfValue/2);for(var d=1;d<=i.pieBackgroundN;d++){var p=t.pstyle("pie-"+d+"-background-size").value,f=t.pstyle("pie-"+d+"-background-color").value,g=t.pstyle("pie-"+d+"-background-opacity").value*n,v=p/100;1<v+h&&(v=1-h);var y=1.5*Math.PI+2*Math.PI*h,m=y+2*Math.PI*v;0===p||1<=h||1<h+v||(e.beginPath(),e.moveTo(o,s),e.arc(o,s,c,y,m),e.closePath(),this.colorFillStyle(e,f[0],f[1],f[2],g),e.fill(),h+=v)}}},ss={};ss.getPixelRatio=function(){var e=this.data.contexts[0];if(null!=this.forcedPixelRatio)return this.forcedPixelRatio;var t=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/t},ss.paintCache=function(e){for(var t,n=this.paintCaches=this.paintCaches||[],r=!0,i=0;i<n.length;i++)if((t=n[i]).context===e){r=!1;break}return r&&(t={context:e},n.push(t)),t},ss.createGradientStyleFor=function(e,t,n,r,i){var a,o=this.usePaths(),s=n.pstyle(t+"-gradient-stop-colors").value,l=n.pstyle(t+"-gradient-stop-positions").pfValue;if("radial-gradient"===r)if(n.isEdge()){var u=n.sourceEndpoint(),c=n.targetEndpoint(),h=n.midpoint(),d=Jt(u,h),p=Jt(c,h);a=e.createRadialGradient(h.x,h.y,0,h.x,h.y,Math.max(d,p))}else{var f=o?{x:0,y:0}:n.position(),g=n.width(),v=n.height();a=e.createRadialGradient(f.x,f.y,0,f.x,f.y,Math.max(g,v))}else if(n.isEdge()){var y=n.sourceEndpoint(),m=n.targetEndpoint();a=e.createLinearGradient(y.x,y.y,m.x,m.y)}else{var b=o?{x:0,y:0}:n.position(),x=n.width()/2,w=n.height()/2;switch(n.pstyle("background-gradient-direction").value){case"to-bottom":a=e.createLinearGradient(b.x,b.y-w,b.x,b.y+w);break;case"to-top":a=e.createLinearGradient(b.x,b.y+w,b.x,b.y-w);break;case"to-left":a=e.createLinearGradient(b.x-x,b.y,b.x+x,b.y);break;case"to-right":a=e.createLinearGradient(b.x+x,b.y,b.x-x,b.y);break;case"to-bottom-right":case"to-right-bottom":a=e.createLinearGradient(b.x-x,b.y-w,b.x+x,b.y+w);break;case"to-top-right":case"to-right-top":a=e.createLinearGradient(b.x-x,b.y+w,b.x+x,b.y-w);break;case"to-bottom-left":case"to-left-bottom":a=e.createLinearGradient(b.x+x,b.y-w,b.x-x,b.y+w);break;case"to-top-left":case"to-left-top":a=e.createLinearGradient(b.x+x,b.y+w,b.x-x,b.y-w)}}if(!a)return null;for(var E=l.length===s.length,k=s.length,C=0;C<k;C++)a.addColorStop(E?l[C]:C/(k-1),"rgba("+s[C][0]+","+s[C][1]+","+s[C][2]+","+i+")");return a},ss.gradientFillStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,"background",t,n,r);if(!i)return null;e.fillStyle=i},ss.colorFillStyle=function(e,t,n,r,i){e.fillStyle="rgba("+t+","+n+","+r+","+i+")"},ss.eleFillStyle=function(e,t,n){var r=t.pstyle("background-fill").value;if("linear-gradient"===r||"radial-gradient"===r)this.gradientFillStyle(e,t,r,n);else{var i=t.pstyle("background-color").value;this.colorFillStyle(e,i[0],i[1],i[2],n)}},ss.gradientStrokeStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,"line",t,n,r);if(!i)return null;e.strokeStyle=i},ss.colorStrokeStyle=function(e,t,n,r,i){e.strokeStyle="rgba("+t+","+n+","+r+","+i+")"},ss.eleStrokeStyle=function(e,t,n){var r=t.pstyle("line-fill").value;if("linear-gradient"===r||"radial-gradient"===r)this.gradientStrokeStyle(e,t,r,n);else{var i=t.pstyle("line-color").value;this.colorStrokeStyle(e,i[0],i[1],i[2],n)}},ss.matchCanvasSize=function(e){var t=this,n=t.data,r=t.findContainerClientCoords(),i=r[2],a=r[3],o=t.getPixelRatio(),s=t.motionBlurPxRatio;e!==t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE]&&e!==t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG]||(o=s);var l,u=i*o,c=a*o;if(u!==t.canvasWidth||c!==t.canvasHeight){t.fontCaches=null;var h=n.canvasContainer;h.style.width=i+"px",h.style.height=a+"px";for(var d=0;d<t.CANVAS_LAYERS;d++)(l=n.canvases[d]).width=u,l.height=c,l.style.width=i+"px",l.style.height=a+"px";for(d=0;d<t.BUFFER_COUNT;d++)(l=n.bufferCanvases[d]).width=u,l.height=c,l.style.width=i+"px",l.style.height=a+"px";o<=(t.textureMult=1)&&(l=n.bufferCanvases[t.TEXTURE_BUFFER],t.textureMult=2,l.width=u*t.textureMult,l.height=c*t.textureMult),t.canvasWidth=u,t.canvasHeight=c}},ss.renderTo=function(e,t,n,r){this.render({forcedContext:e,forcedZoom:t,forcedPan:n,drawAllLayers:!0,forcedPxRatio:r})},ss.render=function(e){var o=(e=e||ke()).forcedContext,s=e.drawAllLayers,t=e.drawOnlyNodeLayer,l=e.forcedZoom,u=e.forcedPan,c=this,n=void 0===e.forcedPxRatio?this.getPixelRatio():e.forcedPxRatio,r=c.cy,h=c.data,i=h.canvasNeedsRedraw,a=c.textureOnViewport&&!o&&(c.pinching||c.hoverData.dragging||c.swipePanning||c.data.wheelZooming),d=void 0!==e.motionBlur?e.motionBlur:c.motionBlur,p=c.motionBlurPxRatio,f=r.hasCompoundNodes(),g=c.hoverData.draggingEles,v=!(!c.hoverData.selecting&&!c.touchData.selecting),y=d=d&&!o&&c.motionBlurEnabled&&!v;o||(c.prevPxRatio!==n&&(c.invalidateContainerClientCoordsCache(),c.matchCanvasSize(c.container),c.redrawHint("eles",!0),c.redrawHint("drag",!0)),c.prevPxRatio=n),!o&&c.motionBlurTimeout&&clearTimeout(c.motionBlurTimeout),d&&(null==c.mbFrames&&(c.mbFrames=0),c.mbFrames++,c.mbFrames<3&&(y=!1),c.mbFrames>c.minMbLowQualFrames&&(c.motionBlurPxRatio=c.mbPxRBlurry)),c.clearingMotionBlur&&(c.motionBlurPxRatio=1),c.textureDrawLastFrame&&!a&&(i[c.NODE]=!0,i[c.SELECT_BOX]=!0);var m=r.style(),b=r.zoom(),x=void 0!==l?l:b,w=r.pan(),E={x:w.x,y:w.y},k={zoom:b,pan:{x:w.x,y:w.y}},C=c.prevViewport;void 0===C||k.zoom!==C.zoom||k.pan.x!==C.pan.x||k.pan.y!==C.pan.y||g&&!f||(c.motionBlurPxRatio=1),u&&(E=u),x*=n,E.x*=n,E.y*=n;var S=c.getCachedZSortedEles();function D(e,t,n,r,i){var a=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",c.colorFillStyle(e,255,255,255,c.motionBlurTransparency),e.fillRect(t,n,r,i),e.globalCompositeOperation=a}function T(e,t){var n,r,i,a;a=c.clearingMotionBlur||e!==h.bufferContexts[c.MOTIONBLUR_BUFFER_NODE]&&e!==h.bufferContexts[c.MOTIONBLUR_BUFFER_DRAG]?(n=E,r=x,i=c.canvasWidth,c.canvasHeight):(n={x:w.x*p,y:w.y*p},r=b*p,i=c.canvasWidth*p,c.canvasHeight*p),e.setTransform(1,0,0,1,0,0),"motionBlur"===t?D(e,0,0,i,a):o||void 0!==t&&!t||e.clearRect(0,0,i,a),s||(e.translate(n.x,n.y),e.scale(r,r)),u&&e.translate(u.x,u.y),l&&e.scale(l,l)}if(a||(c.textureDrawLastFrame=!1),a){if(c.textureDrawLastFrame=!0,!c.textureCache){c.textureCache={},c.textureCache.bb=r.mutableElements().boundingBox(),c.textureCache.texture=c.data.bufferCanvases[c.TEXTURE_BUFFER];var P=c.data.bufferContexts[c.TEXTURE_BUFFER];P.setTransform(1,0,0,1,0,0),P.clearRect(0,0,c.canvasWidth*c.textureMult,c.canvasHeight*c.textureMult),c.render({forcedContext:P,drawOnlyNodeLayer:!0,forcedPxRatio:n*c.textureMult}),(k=c.textureCache.viewport={zoom:r.zoom(),pan:r.pan(),width:c.canvasWidth,height:c.canvasHeight}).mpan={x:(0-k.pan.x)/k.zoom,y:(0-k.pan.y)/k.zoom}}i[c.DRAG]=!1,i[c.NODE]=!1;var M=h.contexts[c.NODE],_=c.textureCache.texture;k=c.textureCache.viewport;M.setTransform(1,0,0,1,0,0),d?D(M,0,0,k.width,k.height):M.clearRect(0,0,k.width,k.height);var B=m.core("outside-texture-bg-color").value,N=m.core("outside-texture-bg-opacity").value;c.colorFillStyle(M,B[0],B[1],B[2],N),M.fillRect(0,0,k.width,k.height);b=r.zoom();T(M,!1),M.clearRect(k.mpan.x,k.mpan.y,k.width/k.zoom/n,k.height/k.zoom/n),M.drawImage(_,k.mpan.x,k.mpan.y,k.width/k.zoom/n,k.height/k.zoom/n)}else c.textureOnViewport&&!o&&(c.textureCache=null);var I=r.extent(),A=c.pinching||c.hoverData.dragging||c.swipePanning||c.data.wheelZooming||c.hoverData.draggingEles,L=c.hideEdgesOnViewport&&A,z=[];if(z[c.NODE]=!i[c.NODE]&&d&&!c.clearedForMotionBlur[c.NODE]||c.clearingMotionBlur,z[c.NODE]&&(c.clearedForMotionBlur[c.NODE]=!0),z[c.DRAG]=!i[c.DRAG]&&d&&!c.clearedForMotionBlur[c.DRAG]||c.clearingMotionBlur,z[c.DRAG]&&(c.clearedForMotionBlur[c.DRAG]=!0),i[c.NODE]||s||t||z[c.NODE]){var O=d&&!z[c.NODE]&&1!==p;T(M=o||(O?c.data.bufferContexts[c.MOTIONBLUR_BUFFER_NODE]:h.contexts[c.NODE]),d&&!O?"motionBlur":void 0),L?c.drawCachedNodes(M,S.nondrag,n,I):c.drawLayeredElements(M,S.nondrag,n,I),c.debug&&c.drawDebugPoints(M,S.nondrag),s||d||(i[c.NODE]=!1)}if(!t&&(i[c.DRAG]||s||z[c.DRAG])){O=d&&!z[c.DRAG]&&1!==p;T(M=o||(O?c.data.bufferContexts[c.MOTIONBLUR_BUFFER_DRAG]:h.contexts[c.DRAG]),d&&!O?"motionBlur":void 0),L?c.drawCachedNodes(M,S.drag,n,I):c.drawCachedElements(M,S.drag,n,I),c.debug&&c.drawDebugPoints(M,S.drag),s||d||(i[c.DRAG]=!1)}if(c.showFps||!t&&i[c.SELECT_BOX]&&!s){if(T(M=o||h.contexts[c.SELECT_BOX]),1==c.selection[4]&&(c.hoverData.selecting||c.touchData.selecting)){b=c.cy.zoom();var R=m.core("selection-box-border-width").value/b;M.lineWidth=R,M.fillStyle="rgba("+m.core("selection-box-color").value[0]+","+m.core("selection-box-color").value[1]+","+m.core("selection-box-color").value[2]+","+m.core("selection-box-opacity").value+")",M.fillRect(c.selection[0],c.selection[1],c.selection[2]-c.selection[0],c.selection[3]-c.selection[1]),0<R&&(M.strokeStyle="rgba("+m.core("selection-box-border-color").value[0]+","+m.core("selection-box-border-color").value[1]+","+m.core("selection-box-border-color").value[2]+","+m.core("selection-box-opacity").value+")",M.strokeRect(c.selection[0],c.selection[1],c.selection[2]-c.selection[0],c.selection[3]-c.selection[1]))}if(h.bgActivePosistion&&!c.hoverData.selecting){b=c.cy.zoom();var F=h.bgActivePosistion;M.fillStyle="rgba("+m.core("active-bg-color").value[0]+","+m.core("active-bg-color").value[1]+","+m.core("active-bg-color").value[2]+","+m.core("active-bg-opacity").value+")",M.beginPath(),M.arc(F.x,F.y,m.core("active-bg-size").pfValue/b,0,2*Math.PI),M.fill()}var V=c.lastRedrawTime;if(c.showFps&&V){V=Math.round(V);var q=Math.round(1e3/V);M.setTransform(1,0,0,1,0,0),M.fillStyle="rgba(255, 0, 0, 0.75)",M.strokeStyle="rgba(255, 0, 0, 0.75)",M.lineWidth=1,M.fillText("1 frame = "+V+" ms = "+q+" fps",0,20);M.strokeRect(0,30,250,20),M.fillRect(0,30,250*Math.min(q/60,1),20)}s||(i[c.SELECT_BOX]=!1)}if(d&&1!==p){var Y=h.contexts[c.NODE],X=c.data.bufferCanvases[c.MOTIONBLUR_BUFFER_NODE],j=h.contexts[c.DRAG],W=c.data.bufferCanvases[c.MOTIONBLUR_BUFFER_DRAG],H=function(e,t,n){e.setTransform(1,0,0,1,0,0),n||!y?e.clearRect(0,0,c.canvasWidth,c.canvasHeight):D(e,0,0,c.canvasWidth,c.canvasHeight);var r=p;e.drawImage(t,0,0,c.canvasWidth*r,c.canvasHeight*r,0,0,c.canvasWidth,c.canvasHeight)};(i[c.NODE]||z[c.NODE])&&(H(Y,X,z[c.NODE]),i[c.NODE]=!1),(i[c.DRAG]||z[c.DRAG])&&(H(j,W,z[c.DRAG]),i[c.DRAG]=!1)}c.prevViewport=k,c.clearingMotionBlur&&(c.clearingMotionBlur=!1,c.motionBlurCleared=!0,c.motionBlur=!0),d&&(c.motionBlurTimeout=setTimeout(function(){c.motionBlurTimeout=null,c.clearedForMotionBlur[c.NODE]=!1,c.clearedForMotionBlur[c.DRAG]=!1,c.motionBlur=!1,c.clearingMotionBlur=!a,c.mbFrames=0,i[c.NODE]=!0,i[c.DRAG]=!0,c.redraw()},100)),o||r.emit("render")};for(var ls={drawPolygonPath:function(e,t,n,r,i,a){var o=r/2,s=i/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*a[0],n+s*a[1]);for(var l=1;l<a.length/2;l++)e.lineTo(t+o*a[2*l],n+s*a[2*l+1]);e.closePath()},drawRoundRectanglePath:function(e,t,n,r,i){var a=r/2,o=i/2,s=Tt(r,i);e.beginPath&&e.beginPath(),e.moveTo(t,n-o),e.arcTo(t+a,n-o,t+a,n,s),e.arcTo(t+a,n+o,t,n+o,s),e.arcTo(t-a,n+o,t-a,n,s),e.arcTo(t-a,n-o,t,n-o,s),e.lineTo(t,n-o),e.closePath()},drawBottomRoundRectanglePath:function(e,t,n,r,i){var a=r/2,o=i/2,s=Tt(r,i);e.beginPath&&e.beginPath(),e.moveTo(t,n-o),e.lineTo(t+a,n-o),e.lineTo(t+a,n),e.arcTo(t+a,n+o,t,n+o,s),e.arcTo(t-a,n+o,t-a,n,s),e.lineTo(t-a,n-o),e.lineTo(t,n-o),e.closePath()},drawCutRectanglePath:function(e,t,n,r,i){var a=r/2,o=i/2;e.beginPath&&e.beginPath(),e.moveTo(t-a+8,n-o),e.lineTo(t+a-8,n-o),e.lineTo(t+a,n-o+8),e.lineTo(t+a,n+o-8),e.lineTo(t+a-8,n+o),e.lineTo(t-a+8,n+o),e.lineTo(t-a,n+o-8),e.lineTo(t-a,n-o+8),e.closePath()},drawBarrelPath:function(e,t,n,r,i){var a=r/2,o=i/2,s=t-a,l=t+a,u=n-o,c=n+o,h=Pt(r,i),d=h.widthOffset,p=h.heightOffset,f=h.ctrlPtOffsetPct*d;e.beginPath&&e.beginPath(),e.moveTo(s,u+p),e.lineTo(s,c-p),e.quadraticCurveTo(s+f,c,s+d,c),e.lineTo(l-d,c),e.quadraticCurveTo(l-f,c,l,c-p),e.lineTo(l,u+p),e.quadraticCurveTo(l-f,u,l-d,u),e.lineTo(s+d,u),e.quadraticCurveTo(s+f,u,s,u+p),e.closePath()}},us=Math.sin(0),cs=Math.cos(0),hs={},ds={},ps=Math.PI/40,fs=0*Math.PI;fs<2*Math.PI;fs+=ps)hs[fs]=Math.sin(fs),ds[fs]=Math.cos(fs);ls.drawEllipsePath=function(e,t,n,r,i){if(e.beginPath&&e.beginPath(),e.ellipse)e.ellipse(t,n,r/2,i/2,0,0,2*Math.PI);else for(var a,o,s=r/2,l=i/2,u=0*Math.PI;u<2*Math.PI;u+=ps)a=t-s*hs[u]*us+s*ds[u]*cs,o=n+l*ds[u]*us+l*hs[u]*cs,0===u?e.moveTo(a,o):e.lineTo(a,o);e.closePath()};var gs={};function vs(e){var t=e.indexOf(",");return e.substr(t+1)}function ys(e,t,n){var r=t.toDataURL(n,e.quality);switch(e.output){case"blob":return function(e,t){for(var n=atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r),a=0;a<n.length;a++)i[a]=n.charCodeAt(a);return new Blob([r],{type:t})}(vs(r),n);case"base64":return vs(r);case"base64uri":default:return r}}gs.createBuffer=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,[n,n.getContext("2d")]},gs.bufferCanvasImage=function(e){var t=this.cy,n=t.mutableElements().boundingBox(),r=this.findContainerClientCoords(),i=e.full?Math.ceil(n.w):r[2],a=e.full?Math.ceil(n.h):r[3],o=$t(e.maxWidth)||$t(e.maxHeight),s=this.getPixelRatio(),l=1;if(void 0!==e.scale)i*=e.scale,a*=e.scale,l=e.scale;else if(o){var u=1/0,c=1/0;$t(e.maxWidth)&&(u=l*e.maxWidth/i),$t(e.maxHeight)&&(c=l*e.maxHeight/a),i*=l=Math.min(u,c),a*=l}o||(i*=s,a*=s,l*=s);var h=document.createElement("canvas");h.width=i,h.height=a,h.style.width=i+"px",h.style.height=a+"px";var d=h.getContext("2d");if(0<i&&0<a){d.clearRect(0,0,i,a),d.globalCompositeOperation="source-over";var p=this.getCachedZSortedEles();if(e.full)d.translate(-n.x1*l,-n.y1*l),d.scale(l,l),this.drawElements(d,p),d.scale(1/l,1/l),d.translate(n.x1*l,n.y1*l);else{var f=t.pan(),g={x:f.x*l,y:f.y*l};l*=t.zoom(),d.translate(g.x,g.y),d.scale(l,l),this.drawElements(d,p),d.scale(1/l,1/l),d.translate(-g.x,-g.y)}e.bg&&(d.globalCompositeOperation="destination-over",d.fillStyle=e.bg,d.rect(0,0,i,a),d.fill())}return h},gs.png=function(e){return ys(e,this.bufferCanvasImage(e),"image/png")},gs.jpg=function(e){return ys(e,this.bufferCanvasImage(e),"image/jpeg")};var ms={nodeShapeImpl:function(e,t,n,r,i,a,o){switch(e){case"ellipse":return this.drawEllipsePath(t,n,r,i,a);case"polygon":return this.drawPolygonPath(t,n,r,i,a,o);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(t,n,r,i,a);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(t,n,r,i,a);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(t,n,r,i,a);case"barrel":return this.drawBarrelPath(t,n,r,i,a)}}},bs=ws,xs=ws.prototype;function ws(e){var a=this;a.data={canvases:new Array(xs.CANVAS_LAYERS),contexts:new Array(xs.CANVAS_LAYERS),canvasNeedsRedraw:new Array(xs.CANVAS_LAYERS),bufferCanvases:new Array(xs.BUFFER_COUNT),bufferContexts:new Array(xs.CANVAS_LAYERS)};var t="-webkit-tap-highlight-color: rgba(0,0,0,0);";a.data.canvasContainer=document.createElement("div");var n=a.data.canvasContainer.style;a.data.canvasContainer.setAttribute("style",t),n.position="relative",n.zIndex="0",n.overflow="hidden";var r=e.cy.container();r.appendChild(a.data.canvasContainer),(r.getAttribute("style")||"").indexOf(t)<0&&r.setAttribute("style",(r.getAttribute("style")||"")+t);for(var i=0;i<xs.CANVAS_LAYERS;i++){var o=a.data.canvases[i]=document.createElement("canvas");a.data.contexts[i]=o.getContext("2d"),o.setAttribute("style","-webkit-user-select: none; -moz-user-select: -moz-none; user-select: none; -webkit-tap-highlight-color: rgba(0,0,0,0); outline-style: none;"+(k&&k.userAgent.match(/msie|trident|edge/i)?" -ms-touch-action: none; touch-action: none; ":"")),o.style.position="absolute",o.setAttribute("data-id","layer"+i),o.style.zIndex=String(xs.CANVAS_LAYERS-i),a.data.canvasContainer.appendChild(o),a.data.canvasNeedsRedraw[i]=!1}a.data.topCanvas=a.data.canvases[0],a.data.canvases[xs.NODE].setAttribute("data-id","layer"+xs.NODE+"-node"),a.data.canvases[xs.SELECT_BOX].setAttribute("data-id","layer"+xs.SELECT_BOX+"-selectbox"),a.data.canvases[xs.DRAG].setAttribute("data-id","layer"+xs.DRAG+"-drag");for(i=0;i<xs.BUFFER_COUNT;i++)a.data.bufferCanvases[i]=document.createElement("canvas"),a.data.bufferContexts[i]=a.data.bufferCanvases[i].getContext("2d"),a.data.bufferCanvases[i].style.position="absolute",a.data.bufferCanvases[i].setAttribute("data-id","buffer"+i),a.data.bufferCanvases[i].style.zIndex=String(-i-1),a.data.bufferCanvases[i].style.visibility="hidden";a.pathsEnabled=!0;var s=at(),l=function(e){return{x:-e.w/2,y:-e.h/2}},u=function(e){return e.boundingBox(),e[0]._private.bodyBounds},c=function(e){return e.boundingBox(),e[0]._private.labelBounds.main||s},h=function(e){return e.boundingBox(),e[0]._private.labelBounds.source||s},d=function(e){return e.boundingBox(),e[0]._private.labelBounds.target||s},p=function(e,t){return t},f=function(e,t){return{x:e.x+t.pstyle("text-margin-x").pfValue,y:e.y+t.pstyle("text-margin-y").pfValue}},g=function(e,t,n){var r=e[0]._private.rscratch;return{x:r[t],y:r[n]}},v=a.data.eleTxrCache=new Vo(a,{getKey:function(e){return e[0]._private.nodeKey},doesEleInvalidateKey:function(e){var t=e[0]._private;return!(t.oldBackgroundTimestamp===t.backgroundTimestamp)},drawElement:function(e,t,n,r,i){return a.drawElement(e,t,n,!1,!1,i)},getBoundingBox:u,getRotationPoint:function(e){return{x:((t=u(e)).x1+t.x2)/2,y:(t.y1+t.y2)/2};var t},getRotationOffset:function(e){return l(u(e))},allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),y=a.data.lblTxrCache=new Vo(a,{getKey:function(e){return e[0]._private.labelStyleKey},drawElement:function(e,t,n,r,i){return a.drawElementText(e,t,n,r,"main",i)},getBoundingBox:c,getRotationPoint:function(e){return f(g(e,"labelX","labelY"),e)},getRotationOffset:function(e){var t=c(e),n=l(c(e));if(e.isNode()){switch(e.pstyle("text-halign").value){case"left":n.x=-t.w;break;case"right":n.x=0}switch(e.pstyle("text-valign").value){case"top":n.y=-t.h;break;case"bottom":n.y=0}}return n},isVisible:p}),m=a.data.slbTxrCache=new Vo(a,{getKey:function(e){return e[0]._private.sourceLabelStyleKey},drawElement:function(e,t,n,r,i){return a.drawElementText(e,t,n,r,"source",i)},getBoundingBox:h,getRotationPoint:function(e){return f(g(e,"sourceLabelX","sourceLabelY"),e)},getRotationOffset:function(e){return l(h(e))},isVisible:p}),b=a.data.tlbTxrCache=new Vo(a,{getKey:function(e){return e[0]._private.targetLabelStyleKey},drawElement:function(e,t,n,r,i){return a.drawElementText(e,t,n,r,"target",i)},getBoundingBox:d,getRotationPoint:function(e){return f(g(e,"sourceLabelX","sourceLabelY"),e)},getRotationOffset:function(e){return l(d(e))},isVisible:p}),x=a.data.lyrTxrCache=new Yo(a);a.onUpdateEleCalcs(function(e,t){v.invalidateElements(t),y.invalidateElements(t),m.invalidateElements(t),b.invalidateElements(t),x.invalidateElements(t);for(var n=0;n<t.length;n++){var r=t[n]._private;r.oldBackgroundTimestamp=r.backgroundTimestamp}});var w=function(e){for(var t=0;t<e.length;t++)x.enqueueElementRefinement(e[t].ele)};v.onDequeue(w),y.onDequeue(w),m.onDequeue(w),b.onDequeue(w)}xs.CANVAS_LAYERS=3,xs.SELECT_BOX=0,xs.DRAG=1,xs.NODE=2,xs.BUFFER_COUNT=3,xs.TEXTURE_BUFFER=0,xs.MOTIONBLUR_BUFFER_NODE=1,xs.MOTIONBLUR_BUFFER_DRAG=2,xs.redrawHint=function(e,t){switch(e){case"eles":this.data.canvasNeedsRedraw[xs.NODE]=t;break;case"drag":this.data.canvasNeedsRedraw[xs.DRAG]=t;break;case"select":this.data.canvasNeedsRedraw[xs.SELECT_BOX]=t}};var Es="undefined"!=typeof Path2D;xs.path2dEnabled=function(e){if(void 0===e)return this.pathsEnabled;this.pathsEnabled=!!e},xs.usePaths=function(){return Es&&this.pathsEnabled},xs.setImgSmoothing=function(e,t){null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled=t:(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t)},xs.getImgSmoothing=function(e){return null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled:e.webkitImageSmoothingEnabled||e.mozImageSmoothingEnabled||e.msImageSmoothingEnabled},xs.makeOffscreenCanvas=function(e,t){var n;return"undefined"!==("undefined"==typeof OffscreenCanvas?"undefined":E(OffscreenCanvas))?n=new OffscreenCanvas(e,t):((n=document.createElement("canvas")).width=e,n.height=t),n},[Ko,Qo,rs,is,as,os,ss,ls,gs,ms].forEach(function(e){S(xs,e)});var ks=[{type:"layout",extensions:lo},{type:"renderer",extensions:[{name:"null",impl:uo},{name:"base",impl:Io},{name:"canvas",impl:bs}]}],Cs={},Ss={};function Ds(t,n,r){var e=r,i=function(e){me("Can not register `"+n+"` for `"+t+"` since `"+e+"` already exists in the prototype and can not be overridden")};if("core"===t){if(za.prototype[n])return i(n);za.prototype[n]=r}else if("collection"===t){if(ea.prototype[n])return i(n);ea.prototype[n]=r}else if("layout"===t){for(var a=function(e){this.options=e,r.call(this,e),B(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},o=a.prototype=Object.create(r.prototype),s=[],l=0;l<s.length;l++){var u=s[l];o[u]=o[u]||function(){return this}}o.start&&!o.run?o.run=function(){return this.start(),this}:!o.start&&o.run&&(o.start=function(){return this.run(),this});var c=r.prototype.stop;o.stop=function(){var e=this.options;if(e&&e.animate){var t=this.animations;if(t)for(var n=0;n<t.length;n++)t[n].stop()}return c?c.call(this):this.emit("layoutstop"),this},o.destroy||(o.destroy=function(){return this}),o.cy=function(){return this._private.cy};var h=function(e){return e._private.cy},d={addEventFields:function(e,t){t.layout=e,t.cy=h(e),t.target=e},bubble:function(){return!0},parent:function(e){return h(e)}};S(o,{createEmitter:function(){return this._private.emitter=new mi(d,this),this},emitter:function(){return this._private.emitter},on:function(e,t){return this.emitter().on(e,t),this},one:function(e,t){return this.emitter().one(e,t),this},once:function(e,t){return this.emitter().one(e,t),this},removeListener:function(e,t){return this.emitter().removeListener(e,t),this},emit:function(e,t){return this.emitter().emit(e,t),this}}),qn.eventAliasesOn(o),e=a}else if("renderer"===t&&"null"!==n&&"base"!==n){var p=Ts("renderer","base"),f=p.prototype,g=r,v=r.prototype,y=function(){p.apply(this,arguments),g.apply(this,arguments)},m=y.prototype;for(var b in f){var x=f[b];if(null!=v[b])return i(b);m[b]=x}for(var w in v)m[w]=v[w];f.clientFunctions.forEach(function(e){m[e]=m[e]||function(){me("Renderer does not implement `renderer."+e+"()` on its prototype")}}),e=y}return D({map:Cs,keys:[t,n],value:e})}function Ts(e,t){return b({map:Cs,keys:[e,t]})}var Ps=function(){return 2===arguments.length?Ts.apply(null,arguments):3===arguments.length?Ds.apply(null,arguments):4===arguments.length?function(e,t,n,r){return b({map:Ss,keys:[e,t,n,r]})}.apply(null,arguments):5===arguments.length?function(e,t,n,r,i){return D({map:Ss,keys:[e,t,n,r],value:i})}.apply(null,arguments):void me("Invalid extension access syntax")};za.prototype.extension=Ps,ks.forEach(function(t){t.extensions.forEach(function(e){Ds(t.type,e.name,e.impl)})});var Ms=function e(){if(!(this instanceof e))return new e;this.length=0},_s=Ms.prototype;_s.instanceString=function(){return"stylesheet"},_s.selector=function(e){var t=this.length++;return this[t]={selector:e,properties:[]},this},_s.css=function(e,t){var n=this.length-1;if(K(e))this[n].properties.push({name:e,value:t});else if(B(e))for(var r=e,i=Object.keys(r),a=0;a<i.length;a++){var o=i[a],s=r[o];if(null!=s){var l=Na.properties[o]||Na.properties[C(o)];if(null!=l){var u=l.name,c=s;this[n].properties.push({name:u,value:c})}}}return this},_s.style=_s.css,_s.generateStyle=function(e){var t=new Na(e);return this.appendToStyle(t)},_s.appendToStyle=function(e){for(var t=0;t<this.length;t++){var n=this[t],r=n.selector,i=n.properties;e.selector(r);for(var a=0;a<i.length;a++){var o=i[a];e.css(o.name,o.value)}}return e};var Bs=function(e){return void 0===e&&(e={}),B(e)?new za(e):K(e)?Ps.apply(Ps,arguments):void 0};return Bs.use=function(e){var t=Array.prototype.slice.call(arguments,1);return t.unshift(Bs),e.apply(null,t),this},Bs.version="3.3.2",Bs.stylesheet=Bs.Stylesheet=Ms,Bs});
|