text: (function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["cyeditor"]=t():e["cyeditor"]=t()})("undefined"!==typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="fb15")}({"0ab7":function(e,t,n){e.exports=n.p+"img/diamond.a60ee67c.svg"},1248:function(e,t,n){var r,i,a;(function(){var n,o,s,l,u,c,d,h,p,f,g,v,y,m,b;s=Math.floor,f=Math.min,o=function(e,t){return e<t?-1:e>t?1:0},p=function(e,t,n,r,i){var a;if(null==n&&(n=0),null==i&&(i=o),n<0)throw new Error("lo must be non-negative");null==r&&(r=e.length);while(n<r)a=s((n+r)/2),i(t,e[a])<0?r=a:n=a+1;return[].splice.apply(e,[n,n-n].concat(t)),t},c=function(e,t,n){return null==n&&(n=o),e.push(t),m(e,0,e.length-1,n)},u=function(e,t){var n,r;return null==t&&(t=o),n=e.pop(),e.length?(r=e[0],e[0]=n,b(e,0,t)):r=n,r},h=function(e,t,n){var r;return null==n&&(n=o),r=e[0],e[0]=t,b(e,0,n),r},d=function(e,t,n){var r;return null==n&&(n=o),e.length&&n(e[0],t)<0&&(r=[e[0],t],t=r[0],e[0]=r[1],b(e,0,n)),t},l=function(e,t){var n,r,i,a,l,u;for(null==t&&(t=o),a=function(){u=[];for(var t=0,n=s(e.length/2);0<=n?t<n:t>n;0<=n?t++:t--)u.push(t);return u}.apply(this).reverse(),l=[],r=0,i=a.length;r<i;r++)n=a[r],l.push(b(e,n,t));return l},y=function(e,t,n){var r;if(null==n&&(n=o),r=e.indexOf(t),-1!==r)return m(e,0,r,n),b(e,r,n)},g=function(e,t,n){var r,i,a,s,u;if(null==n&&(n=o),i=e.slice(0,t),!i.length)return i;for(l(i,n),u=e.slice(t),a=0,s=u.length;a<s;a++)r=u[a],d(i,r,n);return i.sort(n).reverse()},v=function(e,t,n){var r,i,a,s,c,d,h,g,v;if(null==n&&(n=o),10*t<=e.length){if(a=e.slice(0,t).sort(n),!a.length)return a;for(i=a[a.length-1],h=e.slice(t),s=0,d=h.length;s<d;s++)r=h[s],n(r,i)<0&&(p(a,r,0,null,n),a.pop(),i=a[a.length-1]);return a}for(l(e,n),v=[],c=0,g=f(t,e.length);0<=g?c<g:c>g;0<=g?++c:--c)v.push(u(e,n));return v},m=function(e,t,n,r){var i,a,s;null==r&&(r=o),i=e[n];while(n>t){if(s=n-1>>1,a=e[s],!(r(i,a)<0))break;e[n]=a,n=s}return e[n]=i},b=function(e,t,n){var r,i,a,s,l;null==n&&(n=o),i=e.length,l=t,a=e[t],r=2*t+1;while(r<i)s=r+1,s<i&&!(n(e[r],e[s])<0)&&(r=s),e[t]=e[r],t=r,r=2*t+1;return e[t]=a,m(e,l,t,n)},n=function(){function e(e){this.cmp=null!=e?e:o,this.nodes=[]}return e.push=c,e.pop=u,e.replace=h,e.pushpop=d,e.heapify=l,e.updateItem=y,e.nlargest=g,e.nsmallest=v,e.prototype.push=function(e){return c(this.nodes,e,this.cmp)},e.prototype.pop=function(){return u(this.nodes,this.cmp)},e.prototype.peek=function(){return this.nodes[0]},e.prototype.contains=function(e){return-1!==this.nodes.indexOf(e)},e.prototype.replace=function(e){return h(this.nodes,e,this.cmp)},e.prototype.pushpop=function(e){return d(this.nodes,e,this.cmp)},e.prototype.heapify=function(){return l(this.nodes,this.cmp)},e.prototype.updateItem=function(e){return y(this.nodes,e,this.cmp)},e.prototype.clear=function(){return this.nodes=[]},e.prototype.empty=function(){return 0===this.nodes.length},e.prototype.size=function(){return this.nodes.length},e.prototype.clone=function(){var t;return t=new e,t.nodes=this.nodes.slice(0),t},e.prototype.toArray=function(){return this.nodes.slice(0)},e.prototype.insert=e.prototype.push,e.prototype.top=e.prototype.peek,e.prototype.front=e.prototype.peek,e.prototype.has=e.prototype.contains,e.prototype.copy=e.prototype.clone,e}(),function(n,o){i=[],r=o,a="function"===typeof r?r.apply(t,i):r,void 0!==a&&(e.exports=a)}(0,function(){return n})}).call(this)},"175a":function(e,t,n){e.exports=n("1248")},"1d67":function(e,t,n){e.exports=n.p+"img/polygon.58cab152.svg"},"24aa":function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(r){"object"===typeof window&&(n=window)}e.exports=n},"2a38":function(e,t,n){e.exports=n.p+"img/tag.247a67c3.svg"},"320b":function(e,t,n){e.exports=n.p+"img/round-rectangle.6e6408f1.svg"},"44e1":function(e,t,n){"use strict";function r(e){return e&&"object"===typeof e&&"default"in e?e["default"]:e}var i=r(n("f7fe")),a=r(n("175a"));function o(e){return o="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},o(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(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 u(e,t,n){return t&&l(e.prototype,t),n&&l(e,n),e}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e,t){return h(e)||p(e,t)||f()}function h(e){if(Array.isArray(e))return e}function p(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0)if(n.push(o.value),t&&n.length===t)break}catch(l){i=!0,a=l}finally{try{r||null==s["return"]||s["return"]()}finally{if(i)throw a}}return n}function f(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var g="undefined"===typeof window?null:window,v=g?g.navigator:null,y=(g&&g.document,o("")),m=o({}),b=o(function(){}),x="undefined"===typeof HTMLElement?"undefined":o(HTMLElement),w=function(e){return e&&e.instanceString&&_(e.instanceString)?e.instanceString():null},E=function(e){return null!=e&&o(e)==y},_=function(e){return null!=e&&o(e)===b},k=function(e){return Array.isArray?Array.isArray(e):null!=e&&e instanceof Array},C=function(e){return null!=e&&o(e)===m&&!k(e)&&e.constructor===Object},T=function(e){return null!=e&&o(e)===m},S=function(e){return null!=e&&o(e)===o(1)&&!isNaN(e)},D=function(e){return S(e)&&Math.floor(e)===e},P=function(e){return"undefined"===x?void 0:null!=e&&e instanceof HTMLElement},M=function(e){return N(e)||z(e)},N=function(e){return"collection"===w(e)&&e._private.single},z=function(e){return"collection"===w(e)&&!e._private.single},B=function(e){return"core"===w(e)},O=function(e){return"stylesheet"===w(e)},L=function(e){return"event"===w(e)},A=function(e){return void 0===e||null===e||!(""!==e&&!e.match(/^\s+$/))},I=function(e){return"undefined"!==typeof HTMLElement&&e instanceof HTMLElement},R=function(e){return C(e)&&S(e.x1)&&S(e.x2)&&S(e.y1)&&S(e.y2)},F=function(e){return T(e)&&_(e.then)},V=function(){return v&&v.userAgent.match(/msie|trident|edge/i)},j=function(e,t){t||(t=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 n=function n(){var r,i=this,a=arguments,o=t.apply(i,a),s=n.cache;return(r=s[o])||(r=s[o]=e.apply(i,a)),r};return n.cache={},n},q=j(function(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),X=j(function(e){return e.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),Y=j(function(e,t){return e+t[0].toUpperCase()+t.substring(1)},function(e,t){return e+"$"+t}),H=function(e){return A(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},G="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",W="rgb[a]?\\(("+G+"[%]?)\\s*,\\s*("+G+"[%]?)\\s*,\\s*("+G+"[%]?)(?:\\s*,\\s*("+G+"))?\\)",$="rgb[a]?\\((?:"+G+"[%]?)\\s*,\\s*(?:"+G+"[%]?)\\s*,\\s*(?:"+G+"[%]?)(?:\\s*,\\s*(?:"+G+"))?\\)",U="hsl[a]?\\(("+G+")\\s*,\\s*("+G+"[%])\\s*,\\s*("+G+"[%])(?:\\s*,\\s*("+G+"))?\\)",K="hsl[a]?\\((?:"+G+")\\s*,\\s*(?:"+G+"[%])\\s*,\\s*(?:"+G+"[%])(?:\\s*,\\s*(?:"+G+"))?\\)",Z="\\#[0-9a-fA-F]{3}",Q="\\#[0-9a-fA-F]{6}",J=function(e,t){return e<t?-1:e>t?1:0},ee=function(e,t){return-1*J(e,t)},te=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},ne=function(e){if((4===e.length||7===e.length)&&"#"===e[0]){var t,n,r,i=4===e.length,a=16;return i?(t=parseInt(e[1]+e[1],a),n=parseInt(e[2]+e[2],a),r=parseInt(e[3]+e[3],a)):(t=parseInt(e[1]+e[2],a),n=parseInt(e[3]+e[4],a),r=parseInt(e[5]+e[6],a)),[t,n,r]}},re=function(e){var t,n,r,i,a,o,s,l;function u(e,t,n){return n<0&&(n+=1),n>1&&(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("^"+U+"$").exec(e);if(c){if(n=parseInt(c[1]),n<0?n=(360- -1*n%360)%360:n>360&&(n%=360),n/=360,r=parseFloat(c[2]),r<0||r>100)return;if(r/=100,i=parseFloat(c[3]),i<0||i>100)return;if(i/=100,a=c[4],void 0!==a&&(a=parseFloat(a),a<0||a>1))return;if(0===r)o=s=l=Math.round(255*i);else{var d=i<.5?i*(1+r):i+r-i*r,h=2*i-d;o=Math.round(255*u(h,d,n+1/3)),s=Math.round(255*u(h,d,n)),l=Math.round(255*u(h,d,n-1/3))}t=[o,s,l,a]}return t},ie=function(e){var t,n=new RegExp("^"+W+"$").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||a>255)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),l<0||l>1)return;t.push(l)}}return t},ae=function(e){return se[e.toLowerCase()]},oe=function(e){return(k(e)?e:null)||ae(e)||ne(e)||ie(e)||re(e)},se={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]},le=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var a=n[i];if(C(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}},ue=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var a=n[i];if(C(a))throw Error("Tried to get map with object key");if(t=t[a],null==t)return t}return t},ce=g?g.performance:null,de=ce&&ce.now?function(){return ce.now()}:function(){return Date.now()},he=function(){if(g){if(g.requestAnimationFrame)return function(e){g.requestAnimationFrame(e)};if(g.mozRequestAnimationFrame)return function(e){g.mozRequestAnimationFrame(e)};if(g.webkitRequestAnimationFrame)return function(e){g.webkitRequestAnimationFrame(e)};if(g.msRequestAnimationFrame)return function(e){g.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout(function(){e(de())},1e3/60)}}(),pe=function(e){return he(e)},fe=de,ge=function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5381,r=n;;){if(t=e.next(),t.done)break;r=33*r^t.value}return r>>>0},ve=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5381;return(33*t^e)>>>0},ye=function(e,t){var n={value:0,done:!1},r=0,i=e.length,a={next:function(){return r<i?n.value=e[r++]:n.done=!0,n}};return ge(a,t)},me=function(e,t){var n={value:0,done:!1},r=0,i=e.length,a={next:function(){return r<i?n.value=e.charCodeAt(r++):n.done=!0,n}};return ge(a,t)},be=function(){return xe(arguments)},xe=function(e){for(var t,n=0;n<e.length;n++){var r=e[n];t=0===n?me(r):me(r,t)}return t},we=!0,Ee=null!=console.warn,_e=null!=console.trace,ke=Number.MAX_SAFE_INTEGER||9007199254740991,Ce=function(){return!0},Te=function(){return!1},Se=function(){return 0},De=function(){},Pe=function(e){throw new Error(e)},Me=function(e){if(void 0===e)return we;we=!!e},Ne=function(e){Me()&&(Ee?console.warn(e):(console.log(e),_e&&console.trace()))},ze=function(e){return te({},e)},Be=function(e){return null==e?e:k(e)?e.slice():C(e)?ze(e):e},Oe=function(e){return e.slice()},Le=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},Ae={},Ie=function(){return Ae},Re=function(e){var t=Object.keys(e);return function(n){for(var r={},i=0;i<t.length;i++){var a=t[i],o=null==n?void 0:n[a];r[a]=void 0===o?e[a]:o}return r}},Fe=function(e,t,n){for(var r=e.length;r>=0;r--)if(e[r]===t&&(e.splice(r,1),!n))break},Ve=function(e){e.splice(0,e.length)},je=function(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.push(r)}},qe=function(e,t,n){return n&&(t=Y(n,t)),e[t]},Xe=function(e,t,n,r){n&&(t=Y(n,t)),e[t]=r},Ye=function(){function e(){s(this,e),this._obj={}}return u(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}(),He="undefined"!==typeof Map?Map:Ye,Ge="undefined",We=function(){function e(t){if(s(this,e),this._obj=Object.create(null),this.size=0,null!=t){var n;n=null!=t.instanceString&&t.instanceString()===this.instanceString()?t.toArray():t;for(var r=0;r<n.length;r++)this.add(n[r])}}return u(e,[{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 e=this;return Object.keys(this._obj).filter(function(t){return e.has(t)})}},{key:"forEach",value:function(e,t){return this.toArray().forEach(e,t)}}]),e}(),$e=("undefined"===typeof Set?"undefined":o(Set))!==Ge?Set:We,Ue=function(e,t,n){if(n=!(void 0!==n&&!n),void 0!==e&&void 0!==t&&B(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,this[0]=this;var i=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,pannable:void 0===t.pannable?"edges"===r:!!t.pannable,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},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null}};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=[];k(t.classes)?l=t.classes:E(t.classes)&&(l=t.classes.split(/\s+/));for(var u=0,c=l.length;u<c;u++){var d=l[u];d&&""!==d&&i.classes.add(d)}this.createEmitter();var h=t.style||t.css;h&&(Ne("Setting a `style` bypass at element creation is deprecated"),this.style(h)),(void 0===n||n)&&this.restore()}else Pe("An element must be of type `nodes` or `edges`; you specified `"+r+"`")}else Pe("An element must have a core reference and parameters set")},Ke=function(e){return e={bfs:e.bfs||!e.dfs,dfs:e.dfs||!e.bfs},function(t,n,r){var i;C(t)&&!M(t)&&(i=t,t=i.roots||i.root,n=i.visit,r=i.directed),r=2!==arguments.length||_(n)?r:n,n=_(n)?n:function(){};for(var a,o=this._private.cy,s=t=E(t)?this.filter(t):t,l=[],u=[],c={},d={},h={},p=0,f=this.byGroup(),g=f.nodes,v=f.edges,y=0;y<s.length;y++){var m=s[y],b=m.id();m.isNode()&&(l.unshift(m),e.bfs&&(h[b]=!0,u.push(m)),d[b]=0)}var x=function(){var t=e.bfs?l.shift():l.pop(),i=t.id();if(e.dfs){if(h[i])return"continue";h[i]=!0,u.push(t)}var o=d[i],s=c[i],f=null!=s?s.source():null,y=null!=s?s.target():null,m=null==s?void 0:t.same(f)?y[0]:f[0],b=void 0;if(b=n(t,s,m,p++,o),!0===b)return a=t,"break";if(!1===b)return"break";for(var x=t.connectedEdges().filter(function(e){return(!r||e.source().same(t))&&v.has(e)}),w=0;w<x.length;w++){var E=x[w],_=E.connectedNodes().filter(function(e){return!e.same(t)&&g.has(e)}),k=_.id();0===_.length||h[k]||(_=_[0],l.push(_),e.bfs&&(h[k]=!0,u.push(_)),c[k]=E,d[k]=d[i]+1)}};e:while(0!==l.length){var w=x();switch(w){case"continue":continue;case"break":break e}}for(var k=o.collection(),T=0;T<u.length;T++){var S=u[T],D=c[S.id()];null!=D&&k.merge(D),k.merge(S)}return{path:o.collection(k),found:o.collection(a)}}},Ze={breadthFirstSearch:Ke({bfs:!0}),depthFirstSearch:Ke({dfs:!0})};Ze.bfs=Ze.breadthFirstSearch,Ze.dfs=Ze.depthFirstSearch;var Qe=Re({root:null,weight:function(e){return 1},directed:!1}),Je={dijkstra:function(e){if(!C(e)){var t=arguments;e={root:t[0],weight:t[1],directed:t[2]}}var n=Qe(e),r=n.root,i=n.weight,o=n.directed,s=this,l=i,u=E(r)?this.filter(r)[0]:r[0],c={},d={},h={},p=this.byGroup(),f=p.nodes,g=p.edges;g.unmergeBy(function(e){return e.isLoop()});for(var v=function(e){return c[e.id()]},y=function(e,t){c[e.id()]=t,m.updateItem(e)},m=new a(function(e,t){return v(e)-v(t)}),b=0;b<f.length;b++){var x=f[b];c[x.id()]=x.same(u)?0:1/0,m.push(x)}var w=function(e,t){for(var n,r=(o?e.edgesTo(t):e.edgesWith(t)).intersect(g),i=1/0,a=0;a<r.length;a++){var s=r[a],u=l(s);(u<i||!n)&&(i=u,n=s)}return{edge:n,dist:i}};while(m.size()>0){var _=m.pop(),k=v(_),T=_.id();if(h[T]=k,k!==1/0)for(var S=_.neighborhood().intersect(f),D=0;D<S.length;D++){var P=S[D],M=P.id(),N=w(_,P),z=k+N.dist;z<v(P)&&(y(P,z),d[M]={node:_,edge:N.edge})}}return{distanceTo:function(e){var t=E(e)?f.filter(e)[0]:e[0];return h[t.id()]},pathTo:function(e){var t=E(e)?f.filter(e)[0]:e[0],n=[],r=t,i=r.id();if(t.length>0){n.unshift(t);while(d[i]){var a=d[i];n.unshift(a.edge),n.unshift(a.node),r=a.node,i=r.id()}}return s.spawn(n)}}}},et={kruskal:function(e){e=e||function(e){return 1};for(var t=this.byGroup(),n=t.nodes,r=t.edges,i=n.length,a=new Array(i),o=n,s=function(e){for(var t=0;t<a.length;t++){var n=a[t];if(n.has(e))return t}},l=0;l<i;l++)a[l]=this.spawn(n[l]);for(var u=r.sort(function(t,n){return e(t)-e(n)}),c=0;c<u.length;c++){var d=u[c],h=d.source()[0],p=d.target()[0],f=s(h),g=s(p),v=a[f],y=a[g];f!==g&&(o.merge(d),v.merge(y),a.splice(g,1))}return o}},tt=Re({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),nt={aStar:function(e){var t=this.cy(),n=tt(e),r=n.root,i=n.goal,o=n.heuristic,s=n.directed,l=n.weight;r=t.collection(r)[0],i=t.collection(i)[0];var u,c,d=r.id(),h=i.id(),p={},f={},g={},v=new a(function(e,t){return f[e.id()]-f[t.id()]}),y=new $e,m={},b={},x=function(e,t){v.push(e),y.add(t)},w=function(){u=v.pop(),c=u.id(),y.delete(c)},E=function(e){return y.has(e)};x(r,d),p[d]=0,f[d]=o(r);var _=0;while(v.size()>0){if(w(),_++,c===h){for(var k=[],C=i,T=h,S=b[T];;){if(k.unshift(C),null!=S&&k.unshift(S),C=m[T],null==C)break;T=C.id(),S=b[T]}return{found:!0,distance:p[c],path:this.spawn(k),steps:_}}g[c]=!0;for(var D=u._private.edges,P=0;P<D.length;P++){var M=D[P];if(this.hasElementWithId(M.id())&&(!s||M.data("source")===c)){var N=M.source(),z=M.target(),B=N.id()!==c?N:z,O=B.id();if(this.hasElementWithId(O)&&!g[O]){var L=p[c]+l(M);E(O)?L<p[O]&&(p[O]=L,f[O]=L+o(B),m[O]=u):(p[O]=L,f[O]=L+o(B),x(B,O),m[O]=u,b[O]=M)}}}}return{found:!1,distance:void 0,path:void 0,steps:_}}},rt=Re({weight:function(e){return 1},directed:!1}),it={floydWarshall:function(e){for(var t=this.cy(),n=rt(e),r=n.weight,i=n.directed,a=r,o=this.byGroup(),s=o.nodes,l=o.edges,u=s.length,c=u*u,d=function(e){return s.indexOf(e)},h=function(e){return s[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<l.length;b++){var x=l[b],w=x.source()[0],_=x.target()[0];if(w!==_){var k=d(w),C=d(_),T=k*u+C,S=a(x);if(p[T]>S&&(p[T]=S,y[T]=C,m[T]=x),!i){var D=C*u+k;!i&&p[D]>S&&(p[D]=S,y[D]=k,m[D]=x)}}}for(var P=0;P<u;P++)for(var M=0;M<u;M++)for(var N=M*u+P,z=0;z<u;z++){var B=M*u+z,O=P*u+z;p[N]+p[O]<p[B]&&(p[B]=p[N]+p[O],y[B]=y[N])}var L=function(e){return(E(e)?t.filter(e):e)[0]},A=function(e){return d(L(e))},I={distance:function(e,t){var n=A(e),r=A(t);return p[n*u+r]},path:function(e,n){var r=A(e),i=A(n),a=h(r);if(r===i)return a.collection();if(null==y[r*u+i])return t.collection();var o,s=t.collection(),l=r;s.merge(a);while(r!==i)l=r,r=y[r*u+i],o=m[l*u+r],s.merge(o),s.merge(h(r));return s}};return I}},at=Re({weight:function(e){return 1},directed:!1,root:null}),ot={bellmanFord:function(e){var t=this,n=at(e),r=n.weight,i=n.directed,a=n.root,o=r,s=this,l=this.cy(),u=this.byGroup(),c=u.edges,d=u.nodes,h=d.length,p=new He,f=!1,g=[];a=l.collection(a)[0],c.unmergeBy(function(e){return e.isLoop()});for(var v=c.length,y=function(e){var t=p.get(e.id());return t||(t={},p.set(e.id(),t)),t},m=function(e){return(E(e)?l.$(e):e)[0]},b=function(e){return y(m(e)).dist},x=function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,r=m(e),i=[],o=r;;){if(null==o)return t.spawn();var l=y(o),u=l.edge,c=l.pred;if(i.unshift(o[0]),o.same(n)&&i.length>0)break;null!=u&&i.unshift(u),o=c}return s.spawn(i)},w=0;w<h;w++){var _=d[w],k=y(_);_.same(a)?k.dist=0:k.dist=1/0,k.pred=null,k.edge=null}for(var C=!1,T=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,C=!0)},S=1;S<h;S++){C=!1;for(var D=0;D<v;D++){var P=c[D],M=P.source(),N=P.target(),z=o(P),B=y(M),O=y(N);T(M,N,P,B,O,z),i||T(N,M,P,O,B,z)}if(!C)break}if(C)for(var L=0;L<v;L++){var A=c[L],I=A.source(),R=A.target(),F=o(A),V=y(I).dist,j=y(R).dist;if(V+F<j||!i&&j+F<V){Ne("Graph contains a negative weight cycle for Bellman-Ford"),f=!0;break}}return{distanceTo:b,pathTo:x,hasNegativeWeightCycle:f,negativeWeightCycles:g}}},st=Math.sqrt(2),lt=function(e,t,n){0===n.length&&Pe("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;u>=0;u--){var c=l[u],d=c[1],h=c[2];(t[d]===o&&t[h]===s||t[d]===s&&t[h]===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},ut=function(e,t,n,r){while(n>r){var i=Math.floor(Math.random()*t.length);t=lt(i,e,t),n--}return t},ct={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/st);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,d=[],h=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=ut(p,s.slice(),r,o),b=m.slice();g(p,f);var x=ut(p,m,o,2),w=ut(f,b,o,2);x.length<=w.length&&x.length<c?(c=x.length,d=x,g(p,h)):w.length<=x.length&&w.length<c&&(c=w.length,d=w,g(f,h))}for(var E=this.spawn(d.map(function(e){return n[e[0]]})),_=this.spawn(),k=this.spawn(),C=h[0],T=0;T<h.length;T++){var S=h[T],D=t[T];S===C?_.merge(D):k.merge(D)}var P={cut:E,partition1:_,partition2:k};return P}Pe("At least 2 nodes are required for Karger-Stein algorithm")}},dt=function(e){return{x:e.x,y:e.y}},ht=function(e,t,n){return{x:e.x*t+n.x,y:e.y*t+n.y}},pt=function(e,t,n){return{x:(e.x-n.x)/t,y:(e.y-n.y)/t}},ft=function(e){return{x:e[0],y:e[1]}},gt=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&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},vt=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&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},yt=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&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},mt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];r?e=e.slice(t,n):(n<e.length&&e.splice(n,e.length-n),t>0&&e.splice(0,t));for(var o=0,s=e.length-1;s>=0;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},bt=function(e){return Math.PI*e/180},xt=function(e,t){return Math.atan2(t,e)-Math.PI/2},wt=Math.log2||function(e){return Math.log(e)/Math.log(2)},Et=function(e){return e>0?1:e<0?-1:0},_t=function(e,t){return Math.sqrt(kt(e,t))},kt=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},Ct=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},Tt=function(e,t,n,r){return(1-r)*(1-r)*e+2*(1-r)*r*t+r*r*n},St=function(e,t,n,r){return{x:Tt(e.x,t.x,n.x,r),y:Tt(e.y,t.y,n.y,r)}},Dt=function(e,t,n,r){var i={x:t.x-e.x,y:t.y-e.y},a=_t(e,t),o={x:i.x/a,y:i.y/a};return n=null==n?0:n,r=null!=r?r:n*a,{x:e.x+o.x*r,y:e.y+o.y*r}},Pt=function(e,t,n){return Math.max(e,Math.min(n,t))},Mt=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&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},Nt=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},zt=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},Bt=function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},Ot=function(e,t,n){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},Lt=function(e){var t=arguments.length>1&&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},At=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},It=function(e,t){e.x1+=t.x,e.x2+=t.x,e.y1+=t.y,e.y2+=t.y},Rt=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)))))))},Ft=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},Vt=function(e,t){return Ft(e,t.x,t.y)},jt=function(e,t){return Ft(e,t.x1,t.y1)&&Ft(e,t.x2,t.y2)},qt=function(e,t,n,r,i,a,o){var s,l=cn(i,a),u=i/2,c=a/2,d=n-u+l-o,h=r-c-o,p=n+u-l+o,f=h;if(s=rn(e,t,n,r,d,h,p,f,!1),s.length>0)return s;var g=n+u+o,v=r-c+l-o,y=g,m=r+c-l+o;if(s=rn(e,t,n,r,g,v,y,m,!1),s.length>0)return s;var b=n-u+l-o,x=r+c+o,w=n+u-l+o,E=x;if(s=rn(e,t,n,r,b,x,w,E,!1),s.length>0)return s;var _,k=n-u-o,C=r-c+l-o,T=k,S=r+c-l+o;if(s=rn(e,t,n,r,k,C,T,S,!1),s.length>0)return s;var D=n-u+l,P=r-c+l;if(_=tn(e,t,n,r,D,P,l+o),_.length>0&&_[0]<=D&&_[1]<=P)return[_[0],_[1]];var M=n+u-l,N=r-c+l;if(_=tn(e,t,n,r,M,N,l+o),_.length>0&&_[0]>=M&&_[1]<=N)return[_[0],_[1]];var z=n+u-l,B=r+c-l;if(_=tn(e,t,n,r,z,B,l+o),_.length>0&&_[0]>=z&&_[1]>=B)return[_[0],_[1]];var O=n-u+l,L=r+c-l;return _=tn(e,t,n,r,O,L,l+o),_.length>0&&_[0]<=O&&_[1]>=L?[_[0],_[1]]:[]},Xt=function(e,t,n,r,i,a,o){var s=o,l=Math.min(n,i),u=Math.max(n,i),c=Math.min(r,a),d=Math.max(r,a);return l-s<=e&&e<=u+s&&c-s<=t&&t<=d+s},Yt=function(e,t,n,r,i,a,o,s,l){var u={x1:Math.min(n,o,i)-l,x2:Math.max(n,o,i)+l,y1:Math.min(r,s,a)-l,y2:Math.max(r,s,a)+l};return!(e<u.x1||e>u.x2||t<u.y1||t>u.y2)},Ht=function(e,t,n,r){n-=r;var i=t*t-4*e*n;if(i<0)return[];var a=Math.sqrt(i),o=2*e,s=(-t+a)/o,l=(-t-a)/o;return[s,l]},Gt=function(e,t,n,r,i){var a,o,s,l,u,c,d,h;return t/=e,n/=e,r/=e,o=(3*n-t*t)/9,s=-27*r+t*(9*n-t*t*2),s/=54,a=o*o*o+s*s,i[1]=0,d=t/3,a>0?(u=s+Math.sqrt(a),u=u<0?-Math.pow(-u,1/3):Math.pow(u,1/3),c=s-Math.sqrt(a),c=c<0?-Math.pow(-c,1/3):Math.pow(c,1/3),i[0]=-d+u+c,d+=(u+c)/2,i[4]=i[2]=-d,d=Math.sqrt(3)*(-c+u)/2,i[3]=d,void(i[5]=-d)):(i[5]=i[3]=0,0===a?(h=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),i[0]=2*h-d,void(i[4]=i[2]=-(h+d))):(o=-o,l=o*o*o,l=Math.acos(s/Math.sqrt(l)),h=2*Math.sqrt(o),i[0]=-d+h*Math.cos(l/3),i[2]=-d+h*Math.cos((l+2*Math.PI)/3),void(i[4]=-d+h*Math.cos((l+4*Math.PI)/3))))},Wt=function(e,t,n,r,i,a,o,s){var 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=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,d=1*n*i-n*n+n*e-i*e+r*a-r*r+r*t-a*t,h=[];Gt(l,u,c,d,h);for(var p=1e-7,f=[],g=0;g<6;g+=2)Math.abs(h[g+1])<p&&h[g]>=0&&h[g]<=1&&f.push(h[g]);f.push(1),f.push(0);for(var v,y,m,b=-1,x=0;x<f.length;x++)v=Math.pow(1-f[x],2)*n+2*(1-f[x])*f[x]*i+f[x]*f[x]*o,y=Math.pow(1-f[x],2)*r+2*(1-f[x])*f[x]*a+f[x]*f[x]*s,m=Math.pow(v-e,2)+Math.pow(y-t,2),b>=0?m<b&&(b=m):b=m;return b},$t=function(e,t,n,r,i,a){var o=[e-n,t-r],s=[i-n,a-r],l=s[0]*s[0]+s[1]*s[1],u=o[0]*o[0]+o[1]*o[1],c=o[0]*s[0]+o[1]*s[1],d=c*c/l;return c<0?u:d>l?(e-i)*(e-i)+(t-a)*(t-a):u-d},Ut=function(e,t,n){for(var r,i,a,o,s,l=0,u=0;u<n.length/2;u++)if(r=n[2*u],i=n[2*u+1],u+1<n.length/2?(a=n[2*(u+1)],o=n[2*(u+1)+1]):(a=n[2*(u+1-n.length/2)],o=n[2*(u+1-n.length/2)+1]),r==e&&a==e);else{if(!(r>=e&&e>=a||r<=e&&e<=a))continue;s=(e-r)/(a-r)*(o-i)+i,s>t&&l++}return l%2!==0},Kt=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 d,h=Math.cos(-u),p=Math.sin(-u),f=0;f<c.length/2;f++)c[2*f]=a/2*(n[2*f]*h-n[2*f+1]*p),c[2*f+1]=o/2*(n[2*f+1]*h+n[2*f]*p),c[2*f]+=r,c[2*f+1]+=i;if(l>0){var g=Qt(c,-l);d=Zt(g)}else d=c;return Ut(e,t,d)},Zt=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],c<e.length/4-1?(a=e[4*(c+1)],o=e[4*(c+1)+1],s=e[4*(c+1)+2],l=e[4*(c+1)+3]):(a=e[0],o=e[1],s=e[2],l=e[3]);var d=rn(t,n,r,i,a,o,s,l,!0);u[2*c]=d[0],u[2*c+1]=d[1]}return u},Qt=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],s<e.length/2-1?(i=e[2*(s+1)],a=e[2*(s+1)+1]):(i=e[0],a=e[1]);var l=a-r,u=-(i-n),c=Math.sqrt(l*l+u*u),d=l/c,h=u/c;o[4*s]=n+d*t,o[4*s+1]=r+h*t,o[4*s+2]=i+d*t,o[4*s+3]=a+h*t}return o},Jt=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]},en=function(e,t,n,r,i,a,o){return e-=i,t-=a,e/=n/2+o,t/=r/2+o,e*e+t*t<=1},tn=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]),d=l[0]*l[0]+l[1]*l[1]-o*o,h=c*c-4*u*d;if(h<0)return[];var p=(-c+Math.sqrt(h))/(2*u),f=(-c-Math.sqrt(h))/(2*u),g=Math.min(p,f),v=Math.max(p,f),y=[];if(g>=0&&g<=1&&y.push(g),v>=0&&v<=1&&y.push(v),0===y.length)return[];var m=y[0]*s[0]+e,b=y[0]*s[1]+t;if(y.length>1){if(y[0]==y[1])return[m,b];var x=y[1]*s[0]+e,w=y[1]*s[1]+t;return[m,b,x,w]}return[m,b]},nn=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},rn=function(e,t,n,r,i,a,o,s,l){var u=e-i,c=n-e,d=o-i,h=t-a,p=r-t,f=s-a,g=d*h-f*u,v=c*h-p*u,y=f*c-d*p;if(0!==y){var m=g/y,b=v/y,x=.001,w=0-x,E=1+x;return w<=m&&m<=E&&w<=b&&b<=E?[e+m*c,t+m*p]:l?[e+m*c,t+m*p]:[]}return 0===g||0===v?nn(e,n,o)===o?[o,s]:nn(e,n,i)===i?[i,a]:nn(i,o,n)===n?[n,r]:[]:[]},an=function(e,t,n,r,i,a,o,s){var l,u,c,d,h,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(s>0){var m=Qt(g,-s);u=Zt(m)}else u=g}else u=n;for(var b=0;b<u.length/2;b++)c=u[2*b],d=u[2*b+1],b<u.length/2-1?(h=u[2*(b+1)],p=u[2*(b+1)+1]):(h=u[0],p=u[1]),l=rn(e,t,r,i,c,d,h,p),0!==l.length&&f.push(l[0],l[1]);return f},on=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]]},sn=function(e,t){var n=un(e,t);return n=ln(n),n},ln=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),d=0;d<r;d++)t=e[2*d]=e[2*d]*u,n=e[2*d+1]=e[2*d+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 h=0;h<r;h++)n=e[2*h+1]=e[2*h+1]+(-1-a);return e},un=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},cn=function(e,t){return Math.min(e/4,t/4,8)},dn=function(){return 8},hn=function(e,t,n){return[e-2*t+n,2*(t-e),e]},pn=function(e,t){return{heightOffset:Math.min(15,.05*t),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}},fn=Re({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),gn={pageRank:function(e){for(var t=fn(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,d=c*c,h=u.length,p=new Array(d),f=new Array(c),g=(1-n)/c,v=0;v<c;v++){for(var y=0;y<c;y++){var m=v*c+y;p[m]=0}f[v]=0}for(var b=0;b<h;b++){var x=u[b],w=x.data("source"),E=x.data("target");if(w!==E){var _=l.indexOfId(w),k=l.indexOfId(E),C=a(x),T=k*c+_;p[T]+=C,f[_]+=C}}for(var S=1/c+g,D=0;D<c;D++)if(0===f[D])for(var P=0;P<c;P++){var M=P*c+D;p[M]=S}else for(var N=0;N<c;N++){var z=N*c+D;p[z]=p[z]/f[D]+g}for(var B,O=new Array(c),L=new Array(c),A=0;A<c;A++)O[A]=1;for(var I=0;I<i;I++){for(var R=0;R<c;R++)L[R]=0;for(var F=0;F<c;F++)for(var V=0;V<c;V++){var j=F*c+V;L[F]+=p[j]*O[V]}Ct(L),B=O,O=L,L=B;for(var q=0,X=0;X<c;X++){var Y=B[X]-O[X];q+=Y*Y}if(q<r)break}var H={rank:function(e){return e=o.collection(e)[0],O[l.indexOf(e)]}};return H}},vn=Re({root:null,weight:function(e){return 1},directed:!1,alpha:0}),yn={degreeCentralityNormalized:function(e){e=vn(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 d=this.degreeCentrality(e);o<d.indegree&&(o=d.indegree),s<d.outdegree&&(s=d.outdegree),i[c]=d.indegree,a[c]=d.outdegree}return{indegree:function(e){return 0==o?0:(E(e)&&(e=t.filter(e)),i[e.id()]/o)},outdegree:function(e){return 0===s?0:(E(e)&&(e=t.filter(e)),a[e.id()]/s)}}}for(var h={},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),h[g.id()]=v.degree}return{degree:function(e){return 0===p?0:(E(e)&&(e=t.filter(e)),h[e.id()]/p)}}},degreeCentrality:function(e){e=vn(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)}),d=u.length,h=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(d,1-s)*Math.pow(p,s),outdegree:Math.pow(h,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)}}};yn.dc=yn.degreeCentrality,yn.dcn=yn.degreeCentralityNormalised=yn.degreeCentralityNormalized;var mn=Re({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),bn={closenessCentralityNormalized:function(e){for(var t=mn(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 d=0,h=l[c],p=0;p<l.length;p++)if(c!==p){var f=u.distance(h,l[p]);d+=n?1/f:f}n||(d=1/d),s<d&&(s=d),o[h.id()]=d}return{closeness:function(e){return 0==s?0:(e=E(e)?a.filter(e)[0].id():e.id(),o[e]/s)}}},closenessCentrality:function(e){var t=mn(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 d=o.distanceTo(c);s+=a?1/d:d}}return a?s:1/s}};bn.cc=bn.closenessCentrality,bn.ccn=bn.closenessCentralityNormalised=bn.closenessCentralityNormalized;var xn=Re({weight:null,directed:!1}),wn={betweennessCentrality:function(e){for(var t=xn(e),n=t.directed,r=t.weight,i=null!=r,o=this.cy(),s=this.nodes(),l={},u={},c=0,d={set:function(e,t){u[e]=t,t>c&&(c=t)},get:function(e){return u[e]}},h=0;h<s.length;h++){var p=s[h],f=p.id();l[f]=n?p.outgoers().nodes():p.openNeighborhood().nodes(),d.set(f,0)}for(var g=function(e){for(var t=s[e].id(),n=[],u={},c={},h={},p=new a(function(e,t){return h[e]-h[t]}),f=0;f<s.length;f++){var g=s[f].id();u[g]=[],c[g]=0,h[g]=1/0}c[t]=1,h[t]=0,p.push(t);while(!p.empty()){var v=p.pop();if(n.push(v),i)for(var y=0;y<l[v].length;y++){var m=l[v][y],b=o.getElementById(v),x=void 0;x=b.edgesTo(m).length>0?b.edgesTo(m)[0]:m.edgesTo(b)[0];var w=r(x);m=m.id(),h[m]>h[v]+w&&(h[m]=h[v]+w,p.nodes.indexOf(m)<0?p.push(m):p.updateItem(m),c[m]=0,u[m]=[]),h[m]==h[v]+w&&(c[m]=c[m]+c[v],u[m].push(v))}else for(var E=0;E<l[v].length;E++){var _=l[v][E].id();h[_]==1/0&&(p.push(_),h[_]=h[v]+1),h[_]==h[v]+1&&(c[_]=c[_]+c[v],u[_].push(v))}}for(var k={},C=0;C<s.length;C++)k[s[C].id()]=0;while(n.length>0)for(var T=n.pop(),S=0;S<u[T].length;S++){var D=u[T][S];k[D]=k[D]+c[D]/c[T]*(1+k[T]),T!=s[e].id()&&d.set(T,d.get(T)+k[T])}},v=0;v<s.length;v++)g(v);var y={betweenness:function(e){var t=o.collection(e).id();return d.get(t)},betweennessNormalized:function(e){if(0==c)return 0;var t=o.collection(e).id();return d.get(t)/c}};return y.betweennessNormalised=y.betweennessNormalized,y}};wn.bc=wn.betweennessCentrality;var En=Re({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(e){return 1}]}),_n=function(e){return En(e)},kn=function(e,t){for(var n=0,r=0;r<t.length;r++)n+=t[r](e);return n},Cn=function(e,t,n){for(var r=0;r<t;r++)e[r*t+r]=n},Tn=function(e,t){for(var n,r=0;r<t;r++){n=0;for(var i=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}},Sn=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},Dn=function(e,t,n){for(var r=e.slice(0),i=1;i<n;i++)e=Sn(e,r,t);return e},Pn=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 Tn(r,t),r},Mn=function(e,t,n,r){for(var i=0;i<n;i++){var a=Math.round(e[i]*Math.pow(10,r))/Math.pow(10,r),o=Math.round(t[i]*Math.pow(10,r))/Math.pow(10,r);if(a!==o)return!1}return!0},Nn=function(e,t,n,r){for(var i=[],a=0;a<t;a++){for(var o=[],s=0;s<t;s++)Math.round(1e3*e[a*t+s])/1e3>0&&o.push(n[s]);0!==o.length&&i.push(r.collection(o))}return i},zn=function(e,t){for(var n=0;n<e.length;n++)if(!t[n]||e[n].id()!==t[n].id())return!1;return!0},Bn=function(e){for(var t=0;t<e.length;t++)for(var n=0;n<e.length;n++)t!=n&&zn(e[t],e[n])&&e.splice(n,1);return e},On=function(e){for(var t=this.nodes(),n=this.edges(),r=this.cy(),i=_n(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),d=0;d<u;d++)c[d]=0;for(var h=0;h<n.length;h++){var p=n[h],f=a[p.source().id()],g=a[p.target().id()],v=kn(p,i.attributes);c[f*l+g]+=v,c[g*l+f]+=v}Cn(c,l,i.multFactor),Tn(c,l);var y=!0,m=0;while(y&&m<i.maxIterations)y=!1,s=Dn(c,l,i.expandFactor),c=Pn(s,l,i.inflateFactor),Mn(c,s,u,4)||(y=!0),m++;var b=Nn(c,l,t,r);return b=Bn(b),b},Ln={markovClustering:On,mcl:On},An=function(e){return e},In=function(e,t){return Math.abs(t-e)},Rn=function(e,t,n){return e+In(t,n)},Fn=function(e,t,n){return e+Math.pow(n-t,2)},Vn=function(e){return Math.sqrt(e)},jn=function(e,t,n){return Math.max(e,In(t,n))},qn=function(e,t,n,r,i){for(var a,o,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:An,l=r,u=0;u<e;u++)a=t(u),o=n(u),l=i(l,a,o);return s(l)},Xn={euclidean:function(e,t,n){return e>=2?qn(e,t,n,0,Fn,Vn):qn(e,t,n,0,Rn)},squaredEuclidean:function(e,t,n){return qn(e,t,n,0,Fn)},manhattan:function(e,t,n){return qn(e,t,n,0,Rn)},max:function(e,t,n){return qn(e,t,n,-1/0,jn)}};function Yn(e,t,n,r,i,a){var o;return o=_(e)?e:Xn[e]||Xn.euclidean,0===t&&_(e)?o(i,a):o(t,n,r,i,a)}Xn["squared-euclidean"]=Xn["squaredEuclidean"],Xn["squaredeuclidean"]=Xn["squaredEuclidean"];var Hn=Re({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),Gn=function(e){return Hn(e)},Wn=function(e,t,n,r,i){var a="kMedoids"!==i,o=a?function(e){return n[e]}:function(e){return r[e](n)},s=function(e){return r[e](t)},l=n,u=t;return Yn(e,r.length,o,s,l,u)},$n=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},Un=function(e,t,n,r,i){for(var a=1/0,o=0,s=0;s<t.length;s++){var l=Wn(n,e,t[s],r,i);l<a&&(a=l,o=s)}return o},Kn=function(e,t,n){for(var r=[],i=null,a=0;a<t.length;a++)i=t[a],n[i.id()]===e&&r.push(i);return r},Zn=function(e,t,n){return Math.abs(t-e)<=n},Qn=function(e,t,n){for(var r=0;r<e.length;r++)for(var i=0;i<e[r].length;i++){var a=Math.abs(e[r][i]-t[r][i]);if(a>n)return!1}return!0},Jn=function(e,t,n){for(var r=0;r<n;r++)if(e===t[r])return!0;return!1},er=function(e,t){var n=new Array(t);if(e.length<50)for(var r=0;r<t;r++){var i=e[Math.floor(Math.random()*e.length)];while(Jn(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},tr=function(e,t,n){for(var r=0,i=0;i<t.length;i++)r+=Wn("manhattan",t[i],e,n,"kMedoids");return r},nr=function(e){var t,n=this.cy(),r=this.nodes(),i=null,a=Gn(e),s=new Array(a.k),l={};if(a.testMode)if("number"===typeof a.testCentroids){var u=a.testCentroids;t=$n(r,a.k,a.attributes,u)}else t="object"===o(a.testCentroids)?a.testCentroids:$n(r,a.k,a.attributes);else t=$n(r,a.k,a.attributes);var c=!0,d=0;while(c&&d<a.maxIterations){for(var h=0;h<r.length;h++)i=r[h],l[i.id()]=Un(i,t,a.distance,a.attributes,"kMeans");c=!1;for(var p=0;p<a.k;p++){var f=Kn(p,r,l);if(0!==f.length){for(var g=a.attributes.length,v=t[p],y=new Array(g),m=new Array(g),b=0;b<g;b++){m[b]=0;for(var x=0;x<f.length;x++)i=f[x],m[b]+=a.attributes[b](i);y[b]=m[b]/f.length,Zn(y[b],v[b],a.sensitivityThreshold)||(c=!0)}t[p]=y,s[p]=n.collection(f)}}d++}return s},rr=function(e){var t,n,r=this.cy(),i=this.nodes(),a=null,s=Gn(e),l=new Array(s.k),u={},c=new Array(s.k);s.testMode?"number"===typeof s.testCentroids||(t="object"===o(s.testCentroids)?s.testCentroids:er(i,s.k)):t=er(i,s.k);var d=!0,h=0;while(d&&h<s.maxIterations){for(var p=0;p<i.length;p++)a=i[p],u[a.id()]=Un(a,t,s.distance,s.attributes,"kMedoids");d=!1;for(var f=0;f<t.length;f++){var g=Kn(f,i,u);if(0!==g.length){c[f]=tr(t[f],g,s.attributes);for(var v=0;v<g.length;v++)n=tr(g[v],g,s.attributes),n<c[f]&&(c[f]=n,t[f]=g[v],d=!0);l[f]=r.collection(g)}}h++}return l},ir=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++){a=0,o=0;for(var d=0;d<t.length;d++)a+=r[d][u]*i.attributes[c](t[d]),o+=r[d][u];e[u][c]=a/o}},ar=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 d=0;d<r.length;d++){o=0;for(var h=0;h<n.length;h++)s=Wn(i.distance,r[d],n[c],i.attributes,"cmeans"),l=Wn(i.distance,r[d],n[h],i.attributes,"cmeans"),o+=Math.pow(s/l,u);e[d][c]=1/o}},or=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},sr=function(e){var t,n,r,i,a,o=this.cy(),s=this.nodes(),l=Gn(e);i=new Array(s.length);for(var u=0;u<s.length;u++)i[u]=new Array(l.k);r=new Array(s.length);for(var c=0;c<s.length;c++)r[c]=new Array(l.k);for(var d=0;d<s.length;d++){for(var h=0,p=0;p<l.k;p++)r[d][p]=Math.random(),h+=r[d][p];for(var f=0;f<l.k;f++)r[d][f]=r[d][f]/h}n=new Array(l.k);for(var g=0;g<l.k;g++)n[g]=new Array(l.attributes.length);a=new Array(s.length);for(var v=0;v<s.length;v++)a[v]=new Array(l.k);var y=!0,m=0;while(y&&m<l.maxIterations)y=!1,ir(n,s,r,a,l),ar(r,i,n,s,l),Qn(r,i,l.sensitivityThreshold)||(y=!0),m++;return t=or(s,r,l,o),{clusters:t,degreeOfMembership:r}},lr={kMeans:nr,kMedoids:rr,fuzzyCMeans:sr,fcm:sr},ur=Re({distance:"euclidean",linkage:"min",mode:"threshold",threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),cr={single:"min",complete:"max"},dr=function(e){var t=ur(e),n=cr[t.linkage];return null!=n&&(t.linkage=n),t},hr=function(e,t,n,r,i){for(var a,o=0,s=1/0,l=i.attributes,u=function(e,t){return Yn(i.distance,l.length,function(t){return l[t](e)},function(e){return l[e](t)},e,t)},c=0;c<e.length;c++){var d=e[c].key,h=n[d][r[d]];h<s&&(o=d,s=h)}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},pr=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)))},fr=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},gr=function e(t,n,r){if(!t)return[];var i=[],a=[],o=[];return 0===n?(t.left&&pr(t.left,i,r),t.right&&pr(t.right,a,r),o=i.concat(a),[r.collection(o)]):1===n?t.value?[r.collection(t.value)]:(t.left&&pr(t.left,i,r),t.right&&pr(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))},vr=function(e){for(var t=this.cy(),n=this.nodes(),r=dr(e),i=r.attributes,a=function(e,t){return Yn(r.distance,i.length,function(t){return i[t](e)},function(e){return i[e](t)},e,t)},o=[],s=[],l=[],u=[],c=0;c<n.length;c++){var d={value:"dendrogram"===r.mode?n[c]:[n[c]],key:c,index:c};o[c]=d,u[c]=d,s[c]=[],l[c]=0}for(var h=0;h<o.length;h++)for(var p=0;p<=h;p++){var f=void 0;f="dendrogram"===r.mode?h===p?1/0:a(o[h].value,o[p].value):h===p?1/0:a(o[h].value[0],o[p].value[0]),s[h][p]=f,s[p][h]=f,f<s[h][l[h]]&&(l[h]=p)}var g,v=hr(o,u,s,l,r);while(v)v=hr(o,u,s,l,r);return"dendrogram"===r.mode?(g=gr(o[0],r.dendrogramDepth,t),r.addDendrogram&&fr(o[0],t)):(g=new Array(o.length),o.forEach(function(e,n){e.key=e.index=null,g[n]=t.collection(e.value)})),g},yr={hierarchicalClustering:vr,hca:vr},mr=Re({distance:"euclidean",preference:"median",damping:.8,maxIterations:1e3,minIterations:100,attributes:[]}),br=function(e){var t=e.damping,n=e.preference;.5<=t&&t<1||Pe("Damping must range on [0.5, 1).  Got: ".concat(t));var r=["median","mean","min","max"];return r.some(function(e){return e===n})||S(n)||Pe("Preference must be one of [".concat(r.map(function(e){return"'".concat(e,"'")}).join(", "),"] or a number.  Got: ").concat(n)),mr(e)},xr=function(e,t,n,r){var i=function(e,t){return r[t](e)};return-Yn(e,r.length,function(e){return i(t,e)},function(e){return i(n,e)},t,n)},wr=function(e,t){var n=null;return n="median"===t?mt(e):"mean"===t?yt(e):"min"===t?gt(e):"max"===t?vt(e):t,n},Er=function(e,t,n){for(var r=[],i=0;i<e;i++)t[i*e+i]+n[i*e+i]>0&&r.push(i);return r},_r=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&&(a=l,o=t[i*e+l])}a>0&&r.push(a)}for(var u=0;u<n.length;u++)r[n[u]]=n[u];return r},kr=function(e,t,n){for(var r=_r(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,d=0;d<a.length;d++)c+=t[a[d]*e+a[u]];c>l&&(s=u,l=c)}n[i]=a[s]}return r=_r(e,t,n),r},Cr=function(e){for(var t,n,r,i,a,o,s=this.cy(),l=this.nodes(),u=br(e),c={},d=0;d<l.length;d++)c[l[d].id()]=d;t=l.length,n=t*t,r=new Array(n);for(var h=0;h<n;h++)r[h]=-1/0;for(var p=0;p<t;p++)for(var f=0;f<t;f++)p!==f&&(r[p*t+f]=xr(u.distance,l[p],l[f],u.attributes));i=wr(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,_=new Array(t*u.minIterations),k=0;k<_.length;k++)_[k]=0;for(E=0;E<u.maxIterations;E++){for(var C=0;C<t;C++){for(var T=-1/0,S=-1/0,D=-1,P=0,M=0;M<t;M++)m[M]=a[C*t+M],P=o[C*t+M]+r[C*t+M],P>=T?(S=T,T=P,D=M):P>S&&(S=P);for(var N=0;N<t;N++)a[C*t+N]=(1-u.damping)*(r[C*t+N]-T)+u.damping*m[N];a[C*t+D]=(1-u.damping)*(r[C*t+D]-S)+u.damping*m[D]}for(var z=0;z<t;z++){for(var B=0,O=0;O<t;O++)m[O]=o[O*t+z],b[O]=Math.max(0,a[O*t+z]),B+=b[O];B-=b[z],b[z]=a[z*t+z],B+=b[z];for(var L=0;L<t;L++)o[L*t+z]=(1-u.damping)*Math.min(0,B-b[L])+u.damping*m[L];o[z*t+z]=(1-u.damping)*(B-b[z])+u.damping*m[z]}for(var A=0,I=0;I<t;I++){var R=o[I*t+I]+a[I*t+I]>0?1:0;_[E%u.minIterations*t+I]=R,A+=R}if(A>0&&(E>=u.minIterations-1||E==u.maxIterations-1)){for(var F=0,V=0;V<t;V++){x[V]=0;for(var j=0;j<u.minIterations;j++)x[V]+=_[j*t+V];0!==x[V]&&x[V]!==u.minIterations||F++}if(F===t)break}}for(var q=Er(t,a,o),X=kr(t,r,q,l,c),Y={},H=0;H<q.length;H++)Y[q[H]]=[];for(var G=0;G<l.length;G++){var W=c[l[G].id()],$=X[W];null!=$&&Y[$].push(l[G])}for(var U=new Array(q.length),K=0;K<q.length;K++)U[K]=s.collection(Y[q[K]]);return U},Tr={affinityPropagation:Cr,ap:Cr},Sr={};[Ze,Je,et,nt,it,ot,ct,gn,yn,bn,wn,Ln,lr,yr,Tr].forEach(function(e){te(Sr,e)});
  /*!
  Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
  Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
  Licensed under The MIT License (http://opensource.org/licenses/MIT)
  */
  var Dr=0,Pr=1,Mr=2,Nr=function e(t){if(!(this instanceof e))return new e(t);this.id="Thenable/1.0.7",this.state=Dr,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))};Nr.prototype={fulfill:function(e){return zr(this,Pr,"fulfillValue",e)},reject:function(e){return zr(this,Mr,"rejectReason",e)},then:function(e,t){var n=this,r=new Nr;return n.onFulfilled.push(Lr(e,r,"fulfill")),n.onRejected.push(Lr(t,r,"reject")),Br(n),r.proxy}};var zr=function(e,t,n,r){return e.state===Dr&&(e.state=t,e[n]=r,Br(e)),e},Br=function(e){e.state===Pr?Or(e,"onFulfilled",e.fulfillValue):e.state===Mr&&Or(e,"onRejected",e.rejectReason)},Or=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)}},Lr=function(e,t,n){return function(r){if("function"!==typeof e)t[n].call(t,r);else{var i;try{i=e(r)}catch(a){return void t.reject(a)}Ar(t,i)}}},Ar=function e(t,n){if(t!==n&&t.proxy!==n){var r;if("object"===o(n)&&null!==n||"function"===typeof n)try{r=n.then}catch(a){return void t.reject(a)}if("function"!==typeof r)t.fulfill(n);else{var i=!1;try{r.call(n,function(r){i||(i=!0,r===n?t.reject(new TypeError("circular thenable chain")):e(t,r))},function(e){i||(i=!0,t.reject(e))})}catch(a){i||t.reject(a)}}}else t.reject(new TypeError("cannot resolve promise with itself"))};Nr.all=function(e){return new Nr(function(t,n){for(var r=new Array(e.length),i=0,a=function(n,a){r[n]=a,i++,i===e.length&&t(r)},o=0;o<e.length;o++)(function(t){var r=e[t],i=null!=r&&null!=r.then;if(i)r.then(function(e){a(t,e)},function(e){n(e)});else{var o=r;a(t,o)}})(o)})},Nr.resolve=function(e){return new Nr(function(t,n){t(e)})},Nr.reject=function(e){return new Nr(function(t,n){n(e)})};var Ir="undefined"!==typeof Promise?Promise:Nr,Rr=function(e,t,n){var r=B(e),i=!r,a=this._private=te({duration:1e3},t,n);if(a.target=e,a.style=a.style||a.css,a.started=!1,a.playing=!1,a.hooked=!1,a.applying=!1,a.progress=0,a.completes=[],a.frames=[],a.complete&&_(a.complete)&&a.completes.push(a.complete),i){var o=e.position();a.startPosition=a.startPosition||{x:o.x,y:o.y},a.startStyle=a.startStyle||e.cy().style().getAnimationStartStyle(e,a.style)}if(r){var s=e.pan();a.startPan={x:s.x,y:s.y},a.startZoom=e.zoom()}this.length=1,this[0]=this},Fr=Rr.prototype;te(Fr,{instanceString:function(){return"animation"},hook:function(){var e=this._private;if(!e.hooked){var t,n=e.target._private.animation;t=e.queue?n.queue:n.current,t.push(this),M(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 e=this._private,t=e.playing;t&&this.pause(),e.progress=1-e.progress,e.started=!1;var n=function(t,n){var r=e[t];null!=r&&(e[t]=e[n],e[n]=r)};if(n("zoom","startZoom"),n("pan","startPan"),n("position","startPosition"),e.style)for(var r=0;r<e.style.length;r++){var i=e.style[r],a=i.name,o=e.startStyle[a];e.startStyle[a]=i,e.style[r]=o}return t&&this.play(),this},promise:function(e){var t,n=this._private;switch(e){case"frame":t=n.frames;break;default:case"complete":case"completed":t=n.completes}return new Ir(function(e,n){t.push(function(){e()})})}}),Fr.complete=Fr.completed,Fr.run=Fr.play,Fr.running=Fr.playing;var Vr={animated:function(){return function(){var e=this,t=void 0!==e.length,n=t?e:[e],r=this._private.cy||this;if(!r.styleEnabled())return!1;var i=n[0];return i?i._private.animation.current.length>0:void 0}},clearQueue:function(){return function(){var e=this,t=void 0!==e.length,n=t?e:[e],r=this._private.cy||this;if(!r.styleEnabled())return this;for(var i=0;i<n.length;i++){var a=n[i];a._private.animation.queue=[]}return this}},delay:function(){return function(e,t){var n=this._private.cy||this;return n.styleEnabled()?this.animate({delay:e,duration:e,complete:t}):this}},delayAnimation:function(){return function(e,t){var n=this._private.cy||this;return n.styleEnabled()?this.animation({delay:e,duration:e,complete:t}):this}},animation:function(){return function(e,t){var n=this,r=void 0!==n.length,i=r?n:[n],a=this._private.cy||this,o=!r,s=!o;if(!a.styleEnabled())return this;var l=a.style();e=te({},e,t);var u=0===Object.keys(e).length;if(u)return new Rr(i[0],e);switch(void 0===e.duration&&(e.duration=400),e.duration){case"slow":e.duration=600;break;case"fast":e.duration=200;break}if(s&&(e.style=l.getPropsList(e.style||e.css),e.css=void 0),s&&null!=e.renderedPosition){var c=e.renderedPosition,d=a.pan(),h=a.zoom();e.position=pt(c,h,d)}if(o&&null!=e.panBy){var p=e.panBy,f=a.pan();e.pan={x:f.x+p.x,y:f.y+p.y}}var g=e.center||e.centre;if(o&&null!=g){var v=a.getCenterPan(g.eles,e.zoom);null!=v&&(e.pan=v)}if(o&&null!=e.fit){var y=e.fit,m=a.getFitViewport(y.eles||y.boundingBox,y.padding);null!=m&&(e.pan=m.pan,e.zoom=m.zoom)}if(o&&C(e.zoom)){var b=a.getZoomedViewport(e.zoom);null!=b&&(b.zoomed&&(e.zoom=b.zoom),b.panned&&(e.pan=b.pan))}return new Rr(i[0],e)}},animate:function(){return function(e,t){var n=this,r=void 0!==n.length,i=r?n:[n],a=this._private.cy||this;if(!a.styleEnabled())return this;t&&(e=te({},e,t));for(var o=0;o<i.length;o++){var s=i[o],l=s.animated()&&(void 0===e.queue||e.queue),u=s.animation(e,l?{queue:!0}:void 0);u.play()}return this}},stop:function(){return function(e,t){var n=this,r=void 0!==n.length,i=r?n:[n],a=this._private.cy||this;if(!a.styleEnabled())return this;for(var o=0;o<i.length;o++){for(var s=i[o],l=s._private,u=l.animation.current,c=0;c<u.length;c++){var d=u[c],h=d._private;t&&(h.duration=0)}e&&(l.animation.queue=[]),t||(l.animation.current=[])}return a.notify("draw"),this}}},jr={data:function(e){var t={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}};return e=te({},t,e),function(t,n){var r=e,i=this,a=void 0!==i.length,o=a?i:[i],s=a?i[0]:i;if(E(t)){var l;if(r.allowGetting&&void 0===n)return s&&(r.beforeGet(s),l=s._private[r.field][t]),l;if(r.allowSetting&&void 0!==n){var u=!r.immutableKeys[t];if(u){var d=c({},t,n);r.beforeSet(i,d);for(var h=0,p=o.length;h<p;h++){var f=o[h];r.canSet(f)&&(f._private[r.field][t]=n)}r.updateStyle&&i.updateStyle(),r.onSet(i),r.settingTriggersEvent&&i[r.triggerFnName](r.settingEvent)}}}else if(r.allowSetting&&C(t)){var g,v,y=t,m=Object.keys(y);r.beforeSet(i,y);for(var b=0;b<m.length;b++){g=m[b],v=y[g];var x=!r.immutableKeys[g];if(x)for(var w=0;w<o.length;w++){var k=o[w];r.canSet(k)&&(k._private[r.field][g]=v)}}r.updateStyle&&i.updateStyle(),r.onSet(i),r.settingTriggersEvent&&i[r.triggerFnName](r.settingEvent)}else if(r.allowBinding&&_(t)){var T=t;i.on(r.bindingEvent,T)}else if(r.allowGetting&&void 0===t){var S;return s&&(r.beforeGet(s),S=s._private[r.field]),S}return i}},removeData:function(e){var t={field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!1,immutableKeys:{}};return e=te({},t,e),function(t){var n=e,r=this,i=void 0!==r.length,a=i?r:[r];if(E(t)){for(var o=t.split(/\s+/),s=o.length,l=0;l<s;l++){var u=o[l];if(!A(u)){var c=!n.immutableKeys[u];if(c)for(var d=0,h=a.length;d<h;d++)a[d]._private[n.field][u]=void 0}}n.triggerEvent&&r[n.triggerFnName](n.event)}else if(void 0===t){for(var p=0,f=a.length;p<f;p++)for(var g=a[p]._private[n.field],v=Object.keys(g),y=0;y<v.length;y++){var m=v[y],b=!n.immutableKeys[m];b&&(g[m]=void 0)}n.triggerEvent&&r[n.triggerFnName](n.event)}return r}}},qr={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 n=this,r=Array.prototype.slice.call(arguments,0);return new Ir(function(e,t){var i=function(t){n.off.apply(n,o),e(t)},a=r.concat([i]),o=a.concat([]);n.on.apply(n,a)})}}},Xr={};[Vr,jr,qr].forEach(function(e){te(Xr,e)});var Yr={animate:Xr.animate(),animation:Xr.animation(),animated:Xr.animated(),clearQueue:Xr.clearQueue(),delay:Xr.delay(),delayAnimation:Xr.delayAnimation(),stop:Xr.stop()},Hr={classes:function(e){var t=this;if(void 0===e){var n=[];return t[0]._private.classes.forEach(function(e){return n.push(e)}),n}k(e)||(e=(e||"").match(/\S+/g)||[]);for(var r=[],i=new $e(e),a=0;a<t.length;a++){for(var o=t[a],s=o._private,l=s.classes,u=!1,c=0;c<e.length;c++){var d=e[c],h=l.has(d);if(!h){u=!0;break}}u||(u=l.size!==e.length),u&&(s.classes=i,r.push(o))}return r.length>0&&this.spawn(r).updateStyle().emit("class"),t},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){k(e)||(e=e.match(/\S+/g)||[]);for(var n=this,r=void 0===t,i=[],a=0,o=n.length;a<o;a++)for(var s=n[a],l=s._private.classes,u=!1,c=0;c<e.length;c++){var d=e[c],h=l.has(d),p=!1;t||r&&!h?(l.add(d),p=!0):(!t||r&&h)&&(l.delete(d),p=!0),!u&&p&&(i.push(s),u=!0)}return i.length>0&&this.spawn(i).updateStyle().emit("class"),n},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}};Hr.className=Hr.classNames=Hr.classes;var Gr={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:'"(?:\\\\"|[^"])*"|'+"'(?:\\\\'|[^'])*'",number:G,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};Gr.variable="(?:[\\w-]|(?:\\\\"+Gr.metaChar+"))+",Gr.value=Gr.string+"|"+Gr.number,Gr.className=Gr.variable,Gr.id=Gr.variable,function(){var e,t,n;for(e=Gr.comparatorOp.split("|"),n=0;n<e.length;n++)t=e[n],Gr.comparatorOp+="|@"+t;for(e=Gr.comparatorOp.split("|"),n=0;n<e.length;n++)t=e[n],t.indexOf("!")>=0||"="!==t&&(Gr.comparatorOp+="|\\!"+t)}();var Wr=function(){return{checks:[]}},$r={GROUP:0,COLLECTION:1,FILTER:2,DATA_COMPARE:3,DATA_EXIST:4,DATA_BOOL:5,META_COMPARE:6,STATE:7,ID:8,CLASS:9,UNDIRECTED_EDGE:10,DIRECTED_EDGE:11,NODE_SOURCE:12,NODE_TARGET:13,NODE_NEIGHBOR:14,CHILD:15,DESCENDANT:16,PARENT:17,ANCESTOR:18,COMPOUND_SPLIT:19,TRUE:20},Ur=[{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 ee(e.selector,t.selector)}),Kr=function(){for(var e,t={},n=0;n<Ur.length;n++)e=Ur[n],t[e.selector]=e.matches;return t}(),Zr=function(e,t){return Kr[e](t)},Qr="("+Ur.map(function(e){return e.selector}).join("|")+")",Jr=function(e){return e.replace(new RegExp("\\\\("+Gr.metaChar+")","g"),function(e,t){return t})},ei=function(e,t,n){e[e.length-1]=n},ti=[{name:"group",query:!0,regex:"("+Gr.group+")",populate:function(e,t,n){var r=d(n,1),i=r[0];t.checks.push({type:$r.GROUP,value:"*"===i?i:i+"s"})}},{name:"state",query:!0,regex:Qr,populate:function(e,t,n){var r=d(n,1),i=r[0];t.checks.push({type:$r.STATE,value:i})}},{name:"id",query:!0,regex:"\\#("+Gr.id+")",populate:function(e,t,n){var r=d(n,1),i=r[0];t.checks.push({type:$r.ID,value:Jr(i)})}},{name:"className",query:!0,regex:"\\.("+Gr.className+")",populate:function(e,t,n){var r=d(n,1),i=r[0];t.checks.push({type:$r.CLASS,value:Jr(i)})}},{name:"dataExists",query:!0,regex:"\\[\\s*("+Gr.variable+")\\s*\\]",populate:function(e,t,n){var r=d(n,1),i=r[0];t.checks.push({type:$r.DATA_EXIST,field:Jr(i)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+Gr.variable+")\\s*("+Gr.comparatorOp+")\\s*("+Gr.value+")\\s*\\]",populate:function(e,t,n){var r=d(n,3),i=r[0],a=r[1],o=r[2],s=null!=new RegExp("^"+Gr.string+"$").exec(o);o=s?o.substring(1,o.length-1):parseFloat(o),t.checks.push({type:$r.DATA_COMPARE,field:Jr(i),operator:a,value:o})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+Gr.boolOp+")\\s*("+Gr.variable+")\\s*\\]",populate:function(e,t,n){var r=d(n,2),i=r[0],a=r[1];t.checks.push({type:$r.DATA_BOOL,field:Jr(a),operator:i})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+Gr.meta+")\\s*("+Gr.comparatorOp+")\\s*("+Gr.number+")\\s*\\]\\]",populate:function(e,t,n){var r=d(n,3),i=r[0],a=r[1],o=r[2];t.checks.push({type:$r.META_COMPARE,field:Jr(i),operator:a,value:parseFloat(o)})}},{name:"nextQuery",separator:!0,regex:Gr.separator,populate:function(e,t){var n=e.currentSubject,r=e.edgeCount,i=e.compoundCount,a=e[e.length-1];null!=n&&(a.subject=n,e.currentSubject=null),a.edgeCount=r,a.compoundCount=i,e.edgeCount=0,e.compoundCount=0;var o=e[e.length++]=Wr();return o}},{name:"directedEdge",separator:!0,regex:Gr.directedEdge,populate:function(e,t){if(null==e.currentSubject){var n=Wr(),r=t,i=Wr();return n.checks.push({type:$r.DIRECTED_EDGE,source:r,target:i}),ei(e,t,n),e.edgeCount++,i}var a=Wr(),o=t,s=Wr();return a.checks.push({type:$r.NODE_SOURCE,source:o,target:s}),ei(e,t,a),e.edgeCount++,s}},{name:"undirectedEdge",separator:!0,regex:Gr.undirectedEdge,populate:function(e,t){if(null==e.currentSubject){var n=Wr(),r=t,i=Wr();return n.checks.push({type:$r.UNDIRECTED_EDGE,nodes:[r,i]}),ei(e,t,n),e.edgeCount++,i}var a=Wr(),o=t,s=Wr();return a.checks.push({type:$r.NODE_NEIGHBOR,node:o,neighbor:s}),ei(e,t,a),s}},{name:"child",separator:!0,regex:Gr.child,populate:function(e,t){if(null==e.currentSubject){var n=Wr(),r=Wr(),i=e[e.length-1];return n.checks.push({type:$r.CHILD,parent:i,child:r}),ei(e,t,n),e.compoundCount++,r}if(e.currentSubject===t){var a=Wr(),o=e[e.length-1],s=Wr(),l=Wr(),u=Wr(),c=Wr();return a.checks.push({type:$r.COMPOUND_SPLIT,left:o,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:$r.TRUE}],c.checks.push({type:$r.TRUE}),s.checks.push({type:$r.PARENT,parent:c,child:u}),ei(e,o,a),e.currentSubject=l,e.compoundCount++,u}var d=Wr(),h=Wr(),p=[{type:$r.PARENT,parent:d,child:h}];return d.checks=t.checks,t.checks=p,e.compoundCount++,h}},{name:"descendant",separator:!0,regex:Gr.descendant,populate:function(e,t){if(null==e.currentSubject){var n=Wr(),r=Wr(),i=e[e.length-1];return n.checks.push({type:$r.DESCENDANT,ancestor:i,descendant:r}),ei(e,t,n),e.compoundCount++,r}if(e.currentSubject===t){var a=Wr(),o=e[e.length-1],s=Wr(),l=Wr(),u=Wr(),c=Wr();return a.checks.push({type:$r.COMPOUND_SPLIT,left:o,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:$r.TRUE}],c.checks.push({type:$r.TRUE}),s.checks.push({type:$r.ANCESTOR,ancestor:c,descendant:u}),ei(e,o,a),e.currentSubject=l,e.compoundCount++,u}var d=Wr(),h=Wr(),p=[{type:$r.ANCESTOR,ancestor:d,descendant:h}];return d.checks=t.checks,t.checks=p,e.compoundCount++,h}},{name:"subject",modifier:!0,regex:Gr.subject,populate:function(e,t){if(null!=e.currentSubject&&e.currentSubject!==t)return Ne("Redefinition of subject in selector `"+e.toString()+"`"),!1;e.currentSubject=t;var n=e[e.length-1],r=n.checks[0],i=null==r?null:r.type;i===$r.DIRECTED_EDGE?r.type=$r.NODE_TARGET:i===$r.UNDIRECTED_EDGE&&(r.type=$r.NODE_NEIGHBOR,r.node=r.nodes[1],r.neighbor=r.nodes[0],r.nodes=null)}}];ti.forEach(function(e){return e.regexObj=new RegExp("^"+e.regex)});var ni=function(e){for(var t,n,r,i=0;i<ti.length;i++){var a=ti[i],o=a.name,s=e.match(a.regexObj);if(null!=s){n=s,t=a,r=o;var l=s[0];e=e.substring(l.length);break}}return{expr:t,match:n,name:r,remaining:e}},ri=function(e){var t=e.match(/^\s+/);if(t){var n=t[0];e=e.substring(n.length)}return e},ii=function(e){var t=this,n=t.inputText=e,r=t[0]=Wr();for(t.length=1,n=ri(n);;){var i=ni(n);if(null==i.expr)return Ne("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,n.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(u.compoundCount>0&&u.edgeCount>0)return Ne("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(u.edgeCount>1)return Ne("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===u.edgeCount&&Ne("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},ai=function(){if(null!=this.toStringCache)return this.toStringCache;for(var e=function(e){return null==e?"":e},t=function(t){return E(t)?'"'+t+'"':e(t)},n=function(e){return" "+e+" "},r=function(r,a){var o=r.type,s=r.value;switch(o){case $r.GROUP:var l=e(s);return l.substring(0,l.length-1);case $r.DATA_COMPARE:var u=r.field,c=r.operator;return"["+u+n(e(c))+t(s)+"]";case $r.DATA_BOOL:var d=r.operator,h=r.field;return"["+e(d)+h+"]";case $r.DATA_EXIST:var p=r.field;return"["+p+"]";case $r.META_COMPARE:var f=r.operator,g=r.field;return"[["+g+n(e(f))+t(s)+"]]";case $r.STATE:return s;case $r.ID:return"#"+s;case $r.CLASS:return"."+s;case $r.PARENT:case $r.CHILD:return i(r.parent,a)+n(">")+i(r.child,a);case $r.ANCESTOR:case $r.DESCENDANT:return i(r.ancestor,a)+" "+i(r.descendant,a);case $r.COMPOUND_SPLIT:var v=i(r.left,a),y=i(r.subject,a),m=i(r.right,a);return v+(v.length>0?" ":"")+y+m;case $r.TRUE:return""}},i=function(e,t){return e.checks.reduce(function(n,i,a){return n+(t===e&&0===a?"$":"")+r(i,t)},"")},a="",o=0;o<this.length;o++){var s=this[o];a+=i(s,s.subject),this.length>1&&o<this.length-1&&(a+=", ")}return this.toStringCache=a,a},oi={parse:ii,toString:ai},si=function(e,t,n){var r,i,a,o=E(e),s=S(e),l=E(n),u=!1,c=!1,d=!1;switch(t.indexOf("!")>=0&&(t=t.replace("!",""),c=!0),t.indexOf("@")>=0&&(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=i.indexOf(a)>=0;break;case"$=":r=i.indexOf(a,i.length-a.length)>=0;break;case"^=":r=0===i.indexOf(a);break;case"=":r=e===n;break;case">":d=!0,r=e>n;break;case">=":d=!0,r=e>=n;break;case"<":d=!0,r=e<n;break;case"<=":d=!0,r=e<=n;break;default:r=!1;break}return!c||null==e&&d||(r=!r),r},li=function(e,t){switch(t){case"?":return!!e;case"!":return!e;case"^":return void 0===e}},ui=function(e){return void 0!==e},ci=function(e,t){return e.data(t)},di=function(e,t){return e[t]()},hi=[],pi=function(e,t){return e.checks.every(function(e){return hi[e.type](e,t)})};hi[$r.GROUP]=function(e,t){var n=e.value;return"*"===n||n===t.group()},hi[$r.STATE]=function(e,t){var n=e.value;return Zr(n,t)},hi[$r.ID]=function(e,t){var n=e.value;return t.id()===n},hi[$r.CLASS]=function(e,t){var n=e.value;return t.hasClass(n)},hi[$r.META_COMPARE]=function(e,t){var n=e.field,r=e.operator,i=e.value;return si(di(t,n),r,i)},hi[$r.DATA_COMPARE]=function(e,t){var n=e.field,r=e.operator,i=e.value;return si(ci(t,n),r,i)},hi[$r.DATA_BOOL]=function(e,t){var n=e.field,r=e.operator;return li(ci(t,n),r)},hi[$r.DATA_EXIST]=function(e,t){var n=e.field,r=e.operator;return ui(ci(t,n),r)},hi[$r.UNDIRECTED_EDGE]=function(e,t){var n=e.nodes[0],r=e.nodes[1],i=t.source(),a=t.target();return pi(n,i)&&pi(r,a)||pi(r,i)&&pi(n,a)},hi[$r.NODE_NEIGHBOR]=function(e,t){return pi(e.node,t)&&t.neighborhood().some(function(t){return t.isNode()&&pi(e.neighbor,t)})},hi[$r.DIRECTED_EDGE]=function(e,t){return pi(e.source,t.source())&&pi(e.target,t.target())},hi[$r.NODE_SOURCE]=function(e,t){return pi(e.source,t)&&t.outgoers().some(function(t){return t.isNode()&&pi(e.target,t)})},hi[$r.NODE_TARGET]=function(e,t){return pi(e.target,t)&&t.incomers().some(function(t){return t.isNode()&&pi(e.source,t)})},hi[$r.CHILD]=function(e,t){return pi(e.child,t)&&pi(e.parent,t.parent())},hi[$r.PARENT]=function(e,t){return pi(e.parent,t)&&t.children().some(function(t){return pi(e.child,t)})},hi[$r.DESCENDANT]=function(e,t){return pi(e.descendant,t)&&t.ancestors().some(function(t){return pi(e.ancestor,t)})},hi[$r.ANCESTOR]=function(e,t){return pi(e.ancestor,t)&&t.descendants().some(function(t){return pi(e.descendant,t)})},hi[$r.COMPOUND_SPLIT]=function(e,t){return pi(e.subject,t)&&pi(e.left,t)&&pi(e.right,t)},hi[$r.TRUE]=function(){return!0},hi[$r.COLLECTION]=function(e,t){var n=e.value;return n.has(t)},hi[$r.FILTER]=function(e,t){var n=e.value;return n(t)};var fi=function(e){var t=this;if(1===t.length&&1===t[0].checks.length&&t[0].checks[0].type===$r.ID)return e.getElementById(t[0].checks[0].value).collection();var n=function(e){for(var n=0;n<t.length;n++){var r=t[n];if(pi(r,e))return!0}return!1};return null==t.text()&&(n=function(){return!0}),e.filter(n)},gi=function(e){for(var t=this,n=0;n<t.length;n++){var r=t[n];if(pi(r,e))return!0}return!1},vi={matches:gi,filter:fi},yi=function(e){this.inputText=e,this.currentSubject=null,this.compoundCount=0,this.edgeCount=0,this.length=0,null==e||E(e)&&e.match(/^\s*$/)||(M(e)?this.addQuery({checks:[{type:$r.COLLECTION,value:e.collection()}]}):_(e)?this.addQuery({checks:[{type:$r.FILTER,value:e}]}):E(e)?this.parse(e)||(this.invalid=!0):Pe("A selector must be created from a string; found ",e))},mi=yi.prototype;[oi,vi].forEach(function(e){return te(mi,e)}),mi.text=function(){return this.inputText},mi.size=function(){return this.length},mi.eq=function(e){return this[e]},mi.sameText=function(e){return!this.invalid&&!e.invalid&&this.text()===e.text()},mi.addQuery=function(e){this[this.length++]=e},mi.selector=mi.toString;var bi={allAre:function(e){var t=new yi(e);return this.every(function(e){return t.matches(e)})},is:function(e){var t=new yi(e);return this.some(function(e){return t.matches(e)})},some:function(e,t){for(var n=0;n<this.length;n++){var r=t?e.apply(t,[this[n],n,this]):e(this[n],n,this);if(r)return!0}return!1},every:function(e,t){for(var n=0;n<this.length;n++){var r=t?e.apply(t,[this[n],n,this]):e(this[n],n,this);if(!r)return!1}return!0},same:function(e){if(this===e)return!0;e=this.cy().collection(e);var t=this.length,n=e.length;return t===n&&(1===t?this[0]===e[0]:this.every(function(t){return e.hasElementWithId(t.id())}))},anySame:function(e){return e=this.cy().collection(e),this.some(function(t){return e.hasElementWithId(t.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())})}};bi.allAreNeighbours=bi.allAreNeighbors,bi.has=bi.contains,bi.equal=bi.equals=bi.same;var xi,wi,Ei=function(e,t){return function(n,r,i,a){var o,s=n,l=this;if(null==s?o="":M(s)&&1===s.length&&(o=s.id()),1===l.length&&o){var u=l[0]._private,c=u.traversalCache=u.traversalCache||{},d=c[t]=c[t]||[],h=me(o),p=d[h];return p||(d[h]=e.call(l,n,r,i,a))}return e.call(l,n,r,i,a)}},_i={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],a=i._private.parent;a&&t.push(a)}return this.spawn(t,{unique:!0}).filter(e)},parents:function(e){var t=[],n=this.parent();while(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],i=r.parents();t=t||i,t=t.intersect(i)}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:Ei(function(e){for(var t=[],n=0;n<this.length;n++)for(var r=this[n],i=r._private.children,a=0;a<i.length;a++)t.push(i[a]);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 t=[];function n(e){for(var r=0;r<e.length;r++){var i=e[r];t.push(i),i.children().nonempty()&&n(i.children())}}return n(this.children()),this.spawn(t,{unique:!0}).filter(e)}};function ki(e,t,n,r){for(var i=[],a=new $e,o=e.cy(),s=o.hasCompoundNodes(),l=0;l<e.length;l++){var u=e[l];n?i.push(u):s&&r(i,a,u)}while(i.length>0){var c=i.shift();t(c),a.add(c.id()),s&&r(i,a,c)}return e}function Ci(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 Ti(e,t,n){if(n.isChild()){var r=n._private.parent;t.has(r.id())||e.push(r)}}function Si(e,t,n){Ti(e,t,n),Ci(e,t,n)}_i.forEachDown=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return ki(this,e,t,Ci)},_i.forEachUp=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return ki(this,e,t,Ti)},_i.forEachUpAndDown=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return ki(this,e,t,Si)},_i.ancestors=_i.parents,xi=wi={data:Xr.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:Xr.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Xr.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Xr.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Xr.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Xr.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}},xi.attr=xi.data,xi.removeAttr=xi.removeData;var Di,Pi,Mi=wi,Ni={};function zi(e){return function(t){var n=this;if(void 0===t&&(t=!0),0!==n.length&&n.isNode()&&!n.removed()){for(var r=0,i=n[0],a=i._private.edges,o=0;o<a.length;o++){var s=a[o];!t&&s.isLoop()||(r+=e(i,s))}return r}}}function Bi(e,t){return function(n){for(var r,i=this.nodes(),a=0;a<i.length;a++){var o=i[a],s=o[e](n);void 0===s||void 0!==r&&!t(s,r)||(r=s)}return r}}te(Ni,{degree:zi(function(e,t){return t.source().same(t.target())?2:1}),indegree:zi(function(e,t){return t.target().same(e)?1:0}),outdegree:zi(function(e,t){return t.source().same(e)?1:0})}),te(Ni,{minDegree:Bi("degree",function(e,t){return e<t}),maxDegree:Bi("degree",function(e,t){return e>t}),minIndegree:Bi("indegree",function(e,t){return e<t}),maxIndegree:Bi("indegree",function(e,t){return e>t}),minOutdegree:Bi("outdegree",function(e,t){return e<t}),maxOutdegree:Bi("outdegree",function(e,t){return e>t})}),te(Ni,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r<n.length;r++)t+=n[r].degree(e);return t}});var Oi=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)}}},Li={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){Oi(e,t,!1)},onSet:function(e){e.dirtyCompoundBoundsCache()},canSet:function(e){return!e.locked()}};Di=Pi={position:Xr.data(Li),silentPosition:Xr.data(te({},Li,{allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!1,beforeSet:function(e,t){Oi(e,t,!0)}})),positions:function(e,t){if(C(e))t?this.silentPosition(e):this.position(e);else if(_(e)){var n=e,r=this.cy();r.startBatch();for(var i=0;i<this.length;i++){var a=this[i],o=void 0;(o=n(a,i))&&(t?a.silentPosition(o):a.position(o))}r.endBatch()}return this},silentPositions:function(e){return this.positions(e,!0)},shift:function(e,t,n){var r;if(C(e)?(r={x:S(e.x)?e.x:0,y:S(e.y)?e.y:0},n=t):E(e)&&S(t)&&(r={x:0,y:0},r[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 C(e)?this.shift(e,!0):E(e)&&S(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=C(e)?e:void 0,s=void 0!==o||void 0!==t&&E(e);if(n&&n.isNode()){if(!s){var l=n.position();return o=ht(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(pt(o,i,a))}}else if(!s)return;return this},relativePosition:function(e,t){var n=this[0],r=this.cy(),i=C(e)?e:void 0,a=void 0!==i||void 0!==t&&E(e),o=r.hasCompoundNodes();if(n&&n.isNode()){if(!a){var s=n.position(),l=o?n.parent():null,u=l&&l.length>0,c=u;u&&(l=l[0]);var d=c?l.position():{x:0,y:0};return i={x:s.x-d.x,y:s.y-d.y},void 0===e?i:i[e]}for(var h=0;h<this.length;h++){var p=this[h],f=o?p.parent():null,g=f&&f.length>0,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}},Di.modelPosition=Di.point=Di.position,Di.modelPositions=Di.points=Di.positions,Di.renderedPoint=Di.renderedPosition,Di.relativePoint=Di.relativePosition;var Ai,Ii,Ri=Pi;Ai=Ii={},Ii.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}},Ii.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):this},Ii.updateCompoundBounds=function(){var e=arguments.length>0&&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=function(e){return"element"===e.pstyle("display").value},o=n.filter(a).boundingBox({includeLabels:r,includeOverlays:!1,useCache:!1}),s=t.position;0!==o.w&&0!==o.h||(o={w:e.pstyle("width").pfValue,h:e.pstyle("height").pfValue},o.x1=s.x-o.w/2,o.x2=s.x+o.w/2,o.y1=s.y-o.h/2,o.y2=s.y+o.h/2);var l=i.width.left.value;"px"===i.width.left.units&&i.width.val>0&&(l=100*l/i.width.val);var u=i.width.right.value;"px"===i.width.right.units&&i.width.val>0&&(u=100*u/i.width.val);var c=i.height.top.value;"px"===i.height.top.units&&i.height.val>0&&(c=100*c/i.height.val);var d=i.height.bottom.value;"px"===i.height.bottom.units&&i.height.val>0&&(d=100*d/i.height.val);var h=m(i.width.val-o.w,l,u),p=h.biasDiff,f=h.biasComplementDiff,g=m(i.height.val-o.h,c,d),v=g.biasDiff,y=g.biasComplementDiff;t.autoPadding=b(o.w,o.h,e.pstyle("padding"),e.pstyle("padding-relative-to").value),t.autoWidth=Math.max(o.w,i.width.val),s.x=(-p+o.x1+o.x2+f)/2,t.autoHeight=Math.max(o.h,i.height.val),s.y=(-v+o.y1+o.y2+y)/2}function m(e,t,n){var r=0,i=0,a=t+n;return e>0&&a>0&&(r=t/a*e,i=n/a*e),{biasDiff:r,biasComplementDiff:i}}function b(e,t,n,r){if("%"!==n.units)return"px"===n.units?n.pfValue:0;switch(r){case"width":return e>0?n.pfValue*e:0;case"height":return t>0?n.pfValue*t:0;case"average":return e>0&&t>0?n.pfValue*(e+t)/2:0;case"min":return e>0&&t>0?e>t?n.pfValue*t:n.pfValue*e:0;case"max":return e>0&&t>0?e>t?n.pfValue*e:n.pfValue*t:0;default:return 0}}}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 Fi=function(e){return e===1/0||e===-1/0?0:e},Vi=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,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},ji=function(e,t){return null==t?e:Vi(e,t.x1,t.y1,t.x2,t.y2)},qi=function(e,t,n){return qe(e,t,n)},Xi=function(e,t,n){if(!t.cy().headless()){var r,i,a=t._private,o=a.rstyle,s=o.arrowWidth/2,l=t.pstyle(n+"-arrow-shape").value;if("none"!==l){"source"===n?(r=o.srcX,i=o.srcY):"target"===n?(r=o.tgtX,i=o.tgtY):(r=o.midX,i=o.midY);var u=a.arrowBounds=a.arrowBounds||{},c=u[n]=u[n]||{};c.x1=r-s,c.y1=i-s,c.x2=r+s,c.y2=i+s,c.w=c.x2-c.x1,c.h=c.y2-c.y1,Lt(c,1),Vi(e,c.x1,c.y1,c.x2,c.y2)}}},Yi=function(e,t,n){if(!t.cy().headless()){var r;r=n?n+"-":"";var i=t._private,a=i.rstyle,o=t.pstyle(r+"label").strValue;if(o){var s,l,u,c,d=t.pstyle("text-halign"),h=t.pstyle("text-valign"),p=qi(a,"labelWidth",n),f=qi(a,"labelHeight",n),g=qi(a,"labelX",n),v=qi(a,"labelY",n),y=t.pstyle(r+"text-margin-x").pfValue,m=t.pstyle(r+"text-margin-y").pfValue,b=t.isEdge(),x=t.pstyle(r+"text-rotation"),w=t.pstyle("text-outline-width").pfValue,E=t.pstyle("text-border-width").pfValue,_=E/2,k=t.pstyle("text-background-padding").pfValue,C=f,T=p,S=T/2,D=C/2;if(b)s=g-S,l=g+S,u=v-D,c=v+D;else{switch(d.value){case"left":s=g-T,l=g;break;case"center":s=g-S,l=g+S;break;case"right":s=g,l=g+T;break}switch(h.value){case"top":u=v-C,c=v;break;case"center":u=v-D,c=v+D;break;case"bottom":u=v,c=v+C;break}}s+=y-Math.max(w,_)-k,l+=y+Math.max(w,_)+k,u+=m-Math.max(w,_)-k,c+=m+Math.max(w,_)+k;var P=n||"main",M=i.labelBounds,N=M[P]=M[P]||{};N.x1=s,N.y1=u,N.x2=l,N.y2=c,N.w=l-s,N.h=c-u,Lt(N,1);var z=b&&"autorotate"===x.strValue,B=null!=x.pfValue&&0!==x.pfValue;if(z||B){var O=z?qi(i.rstyle,"labelAngle",n):x.pfValue,L=Math.cos(O),A=Math.sin(O),I=(s+l)/2,R=(u+c)/2;if(!b){switch(d.value){case"left":I=l;break;case"right":I=s;break}switch(h.value){case"top":R=c;break;case"bottom":R=u;break}}var F=function(e,t){return e-=I,t-=R,{x:e*L-t*A+I,y:e*A+t*L+R}},V=F(s,u),j=F(s,c),q=F(l,u),X=F(l,c);s=Math.min(V.x,j.x,q.x,X.x),l=Math.max(V.x,j.x,q.x,X.x),u=Math.min(V.y,j.y,q.y,X.y),c=Math.max(V.y,j.y,q.y,X.y)}Vi(e,s,u,l,c),Vi(i.labelBounds.all,s,u,l,c)}return e}},Hi=function(e,t){var n,r,i,a,o,s,l=e._private.cy,u=l.styleEnabled(),c=l.headless(),d=Mt(),h=e._private,p=u?e.pstyle("display").value:"element",f=e.isNode(),g=e.isEdge(),v="none"!==p,y=h.rstyle,m=f&&u?e.pstyle("bounds-expansion").pfValue:0;if(v){var b=0,x=0;u&&t.includeOverlays&&(b=e.pstyle("overlay-opacity").value,0!==b&&(x=e.pstyle("overlay-padding").value));var w=0,E=0;if(u&&(w=e.pstyle("width").pfValue,E=w/2),f&&t.includeNodes){var _=e.position();o=_.x,s=_.y;var k=e.outerWidth(),C=k/2,T=e.outerHeight(),S=T/2;n=o-C,r=o+C,i=s-S,a=s+S,Vi(d,n,i,r,a)}else if(g&&t.includeEdges)if(u&&!c&&(n=Math.min(y.srcX,y.midX,y.tgtX),r=Math.max(y.srcX,y.midX,y.tgtX),i=Math.min(y.srcY,y.midY,y.tgtY),a=Math.max(y.srcY,y.midY,y.tgtY),n-=E,r+=E,i-=E,a+=E,Vi(d,n,i,r,a)),u&&!c&&"haystack"===e.pstyle("curve-style").strValue){var D=y.haystackPts||[];if(n=D[0].x,i=D[0].y,r=D[1].x,a=D[1].y,n>r){var P=n;n=r,r=P}if(i>a){var M=i;i=a,a=M}Vi(d,n-E,i-E,r+E,a+E)}else{for(var N=y.bezierPts||y.linePts||[],z=0;z<N.length;z++){var B=N[z];n=B.x-E,r=B.x+E,i=B.y-E,a=B.y+E,Vi(d,n,i,r,a)}if(0===N.length){var O=e.source(),L=O.position(),A=e.target(),I=A.position();if(n=L.x,r=I.x,i=L.y,a=I.y,n>r){var R=n;n=r,r=R}if(i>a){var F=i;i=a,a=F}n-=E,r+=E,i-=E,a+=E,Vi(d,n,i,r,a)}}if(u&&t.includeEdges&&g&&(Xi(d,e,"mid-source",t),Xi(d,e,"mid-target",t),Xi(d,e,"source",t),Xi(d,e,"target",t)),u){var V="yes"===e.pstyle("ghost").value;if(V){var j=e.pstyle("ghost-offset-x").pfValue,q=e.pstyle("ghost-offset-y").pfValue;Vi(d,d.x1+j,d.y1+q,d.x2+j,d.y2+q)}}var X=h.bodyBounds=h.bodyBounds||{};At(X,d),Lt(X,m),Lt(X,1),u&&(n=d.x1,r=d.x2,i=d.y1,a=d.y2,Vi(d,n-x,i-x,r+x,a+x));var Y=h.overlayBounds=h.overlayBounds||{};At(Y,d),Lt(Y,m),Lt(Y,1);var H=h.labelBounds=h.labelBounds||{};null!=H.all?zt(H.all):H.all=Mt(),u&&t.includeLabels&&(Yi(d,e,null,t),g&&(Yi(d,e,"source",t),Yi(d,e,"target",t)))}return d.x1=Fi(d.x1),d.y1=Fi(d.y1),d.x2=Fi(d.x2),d.y2=Fi(d.y2),d.w=Fi(d.x2-d.x1),d.h=Fi(d.y2-d.y1),d.w>0&&d.h>0&&v&&(Lt(d,m),Lt(d,1)),d},Gi=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),r},Wi=function(e){if(e.isEdge()){var t=e.source().position(),n=e.target().position(),r=function(e){return Math.round(e)};return ye([r(t.x),r(t.y),r(n.x),r(n.y)])}return 0},$i=function(e,t){var n,r=e._private,i=null==t?Ki:Gi(t),a=i===Ki,o=Wi(e),s=r.bbCachePosKey===o,l=t.useCache&&s,u=!l||null==r.bbCache;if(u?(s||e.recalculateRenderedStyle(),n=Hi(e,Ui),r.bbCache=n,r.bbCacheShift.x=r.bbCacheShift.y=0,r.bbCachePosKey=o):n=r.bbCache,!u&&(0!==r.bbCacheShift.x||0!==r.bbCacheShift.y)){var c=It,d=r.bbCacheShift,h=function(e,t){null!=e&&c(e,t)};c(n,d);var p=r.bodyBounds,f=r.overlayBounds,g=r.labelBounds,v=r.arrowBounds;h(p,d),h(f,d),null!=v&&(h(v.source,d),h(v.target,d),h(v["mid-source"],d),h(v["mid-target"],d)),null!=g&&(h(g.main,d),h(g.all,d),h(g.source,d),h(g.target,d))}if(r.bbCacheShift.x=r.bbCacheShift.y=0,!a){var y=e.isNode();n=Mt(),(t.includeNodes&&y||t.includeEdges&&!y)&&(t.includeOverlays?ji(n,r.overlayBounds):ji(n,r.bodyBounds)),t.includeLabels&&ji(n,r.labelBounds.all),n.w=n.x2-n.x1,n.h=n.y2-n.y1}return n},Ui={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeOverlays:!0,useCache:!0},Ki=Gi(Ui),Zi=Re(Ui);Ii.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?Ui:Zi(e),$i(this[0],e);var t=Mt();e=e||Ui;var n=Zi(e),r=this,i=r.cy(),a=i.styleEnabled();if(a)for(var o=0;o<r.length;o++){var s=r[o],l=s._private,u=Wi(s),c=l.bbCachePosKey===u,d=n.useCache&&c;s.recalculateRenderedStyle(d)}this.updateCompoundBounds();for(var h=0;h<r.length;h++){var p=r[h];ji(t,$i(p,n))}return t.x1=Fi(t.x1),t.y1=Fi(t.y1),t.x2=Fi(t.x2),t.y2=Fi(t.y2),t.w=Fi(t.x2-t.x1),t.h=Fi(t.y2-t.y1),t},Ii.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},Ii.shiftCachedBoundingBox=function(e){for(var t=0;t<this.length;t++){var n=this[t],r=n._private,i=r.bbCache;null!=i&&(r.bbCacheShift.x+=e.x,r.bbCacheShift.y+=e.y)}return this.emitAndNotify("bounds"),this},Ii.boundingBoxAt=function(e){var t=this.nodes(),n=this.cy(),r=n.hasCompoundNodes();if(r&&(t=t.filter(function(e){return!e.isParent()})),C(e)){var i=e;e=function(){return i}}var a=function(t,n){return t._private.bbAtOldPos=e(t,n)},o=function(e){return e._private.bbAtOldPos};n.startBatch(),t.forEach(a).silentPositions(e),r&&this.updateCompoundBounds(!0);var s=Nt(this.boundingBox({useCache:!1}));return t.silentPositions(o),n.endBatch(),s},Ai.boundingbox=Ai.bb=Ai.boundingBox,Ai.renderedBoundingbox=Ai.renderedBoundingBox;var Qi,Ji,ea=Ii;Qi=Ji={};var ta=function(e){e.uppercaseName=H(e.name),e.autoName="auto"+e.uppercaseName,e.labelName="label"+e.uppercaseName,e.outerName="outer"+e.uppercaseName,e.uppercaseOuterName=H(e.outerName),Qi[e.name]=function(){var t=this[0],n=t._private,r=n.cy,i=r._private.styleEnabled;if(t){if(!i)return 1;if(t.isParent())return t.updateCompoundBounds(),n[e.autoName]||0;var a=t.pstyle(e.name);switch(a.strValue){case"label":return t.recalculateRenderedStyle(),n.rstyle[e.labelName]||0;default:return a.pfValue}}},Qi["outer"+e.uppercaseName]=function(){var t=this[0],n=t._private,r=n.cy,i=r._private.styleEnabled;if(t){if(i){var a=t[e.name](),o=t.pstyle("border-width").pfValue,s=2*t.padding();return a+o+s}return 1}},Qi["rendered"+e.uppercaseName]=function(){var t=this[0];if(t){var n=t[e.name]();return n*this.cy().zoom()}},Qi["rendered"+e.uppercaseOuterName]=function(){var t=this[0];if(t){var n=t[e.outerName]();return n*this.cy().zoom()}}};ta({name:"width"}),ta({name:"height"}),Ji.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 na=Ji,ra=function(e,t){if(e.isEdge())return t(e)},ia=function(e,t){if(e.isEdge()){var n=e.cy();return ht(t(e),n.zoom(),n.pan())}},aa=function(e,t){if(e.isEdge()){var n=e.cy(),r=n.pan(),i=n.zoom();return t(e).map(function(e){return ht(e,i,r)})}},oa=function(e){return e.renderer().getControlPoints(e)},sa=function(e){return e.renderer().getSegmentPoints(e)},la=function(e){return e.renderer().getSourceEndpoint(e)},ua=function(e){return e.renderer().getTargetEndpoint(e)},ca=function(e){return e.renderer().getEdgeMidpoint(e)},da={controlPoints:{get:oa,mult:!0},segmentPoints:{get:sa,mult:!0},sourceEndpoint:{get:la},targetEndpoint:{get:ua},midpoint:{get:ca}},ha=function(e){return"rendered"+e[0].toUpperCase()+e.substr(1)},pa=Object.keys(da).reduce(function(e,t){var n=da[t],r=ha(t);return e[t]=function(){return ra(this,n.get)},n.mult?e[r]=function(){return aa(this,n.get)}:e[r]=function(){return ia(this,n.get)},e},{}),fa=te({},Ri,ea,na,pa),ga=function(e,t){this.recycle(e,t)};function va(){return!1}function ya(){return!0}ga.prototype={instanceString:function(){return"event"},recycle:function(e,t){if(this.isImmediatePropagationStopped=this.isPropagationStopped=this.isDefaultPrevented=va,null!=e&&e.preventDefault?(this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?ya:va):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=ya;var e=this.originalEvent;e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){this.isPropagationStopped=ya;var e=this.originalEvent;e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=ya,this.stopPropagation()},isDefaultPrevented:va,isPropagationStopped:va,isImmediatePropagationStopped:va};var ma=/^([^.]+)(\.(?:[^.]+))?$/,ba=".*",xa={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},wa=Object.keys(xa),Ea={};function _a(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ea,t=arguments.length>1?arguments[1]:void 0,n=0;n<wa.length;n++){var r=wa[n];this[r]=e[r]||xa[r]}this.context=t||this.context,this.listeners=[],this.emitting=0}var ka=_a.prototype,Ca=function(e,t,n,r,i,a,o){_(r)&&(i=r,r=null),o&&(a=null==a?o:te({},a,o));for(var s=k(n)?n:n.split(/\s+/),l=0;l<s.length;l++){var u=s[l];if(!A(u)){var c=u.match(ma);if(c){var d=c[1],h=c[2]?c[2]:null,p=t(e,u,d,h,r,i,a);if(!1===p)break}}}},Ta=function(e,t){return e.addEventFields(e.context,t),new ga(t.type,t)},Sa=function(e,t,n){if(L(n))t(e,n);else if(C(n))t(e,Ta(e,n));else for(var r=k(n)?n:n.split(/\s+/),i=0;i<r.length;i++){var a=r[i];if(!A(a)){var o=a.match(ma);if(o){var s=o[1],l=o[2]?o[2]:null,u=Ta(e,{type:s,namespace:l,target:e.context});t(e,u)}}}};ka.on=ka.addListener=function(e,t,n,r,i){return Ca(this,function(e,t,n,r,i,a,o){_(a)&&e.listeners.push({event:t,callback:a,type:n,namespace:r,qualifier:i,conf:o})},e,t,n,r,i),this},ka.one=function(e,t,n,r){return this.on(e,t,n,r,{one:!0})},ka.removeListener=ka.off=function(e,t,n,r){var i=this;0!==this.emitting&&(this.listeners=Oe(this.listeners));for(var a=this.listeners,o=function(o){var s=a[o];Ca(i,function(t,n,r,i,l,u){if((s.type===r||"*"===e)&&(!i&&".*"!==s.namespace||s.namespace===i)&&(!l||t.qualifierCompare(s.qualifier,l))&&(!u||s.callback===u))return a.splice(o,1),!1},e,t,n,r)},s=a.length-1;s>=0;s--)o(s);return this},ka.removeAllListeners=function(){return this.removeListener("*")},ka.emit=ka.trigger=function(e,t,n){var r=this.listeners,i=r.length;return this.emitting++,k(t)||(t=[t]),Sa(this,function(e,a){null!=n&&(r=[{event:a.event,type:a.type,namespace:a.namespace,callback:n}],i=r.length);for(var o=function(n){var i=r[n];if(i.type===a.type&&(!i.namespace||i.namespace===a.namespace||i.namespace===ba)&&e.eventMatches(e.context,i,a)){var o=[a];null!=t&&je(o,t),e.beforeEmit(e.context,i,a),i.conf&&i.conf.one&&(e.listeners=e.listeners.filter(function(e){return e!==i}));var s=e.callbackContext(e.context,i,a),l=i.callback.apply(s,o);e.afterEmit(e.context,i,a),!1===l&&(a.stopPropagation(),a.preventDefault())}},s=0;s<i;s++)o(s);e.bubble(e.context)&&!a.isPropagationStopped()&&e.parent(e.context).emit(a,t)},e),this.emitting--,this};var Da={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&&N(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()}},Pa=function(e){return E(e)?new yi(e):e},Ma={createEmitter:function(){for(var e=0;e<this.length;e++){var t=this[e],n=t._private;n.emitter||(n.emitter=new _a(Da,t))}return this},emitter:function(){return this._private.emitter},on:function(e,t,n){for(var r=Pa(t),i=0;i<this.length;i++){var a=this[i];a.emitter().on(e,r,n)}return this},removeListener:function(e,t,n){for(var r=Pa(t),i=0;i<this.length;i++){var a=this[i];a.emitter().removeListener(e,r,n)}return this},removeAllListeners:function(){for(var e=0;e<this.length;e++){var t=this[e];t.emitter().removeAllListeners()}return this},one:function(e,t,n){for(var r=Pa(t),i=0;i<this.length;i++){var a=this[i];a.emitter().one(e,r,n)}return this},once:function(e,t,n){for(var r=Pa(t),i=0;i<this.length;i++){var a=this[i];a.emitter().on(e,r,n,{once:!0,onceCollection:this})}},emit:function(e,t){for(var n=0;n<this.length;n++){var r=this[n];r.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}};Xr.eventAliasesOn(Ma);var Na={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(E(e)||M(e))return new yi(e).filter(this);if(_(e)){for(var n=this.spawn(),r=this,i=0;i<r.length;i++){var a=r[i],o=t?e.apply(t,[a,i,r]):e(a,i,r);o&&n.merge(a)}return n}return this.spawn()},not:function(e){if(e){E(e)&&(e=this.filter(e));for(var t=[],n=e._private.map,r=0;r<this.length;r++){var i=this[r],a=n.has(i.id());a||t.push(i)}return this.spawn(t)}return this},absoluteComplement:function(){var e=this.cy();return e.mutableElements().not(this)},intersect:function(e){if(E(e)){var t=e;return this.filter(t)}for(var n=[],r=this,i=e,a=this.length<e.length,o=a?i._private.map:r._private.map,s=a?r:i,l=0;l<s.length;l++){var u=s[l]._private.data.id,c=o.get(u);c&&n.push(c.ele)}return this.spawn(n)},xor:function(e){var t=this._private.cy;E(e)&&(e=t.$(e));var n=[],r=this,i=e,a=function(e,t){for(var r=0;r<e.length;r++){var i=e[r],a=i._private.data.id,o=t.hasElementWithId(a);o||n.push(i)}};return a(r,i),a(i,r),this.spawn(n)},diff:function(e){var t=this._private.cy;E(e)&&(e=t.$(e));var n=[],r=[],i=[],a=this,o=e,s=function(e,t,n){for(var r=0;r<e.length;r++){var a=e[r],o=a._private.data.id,s=t.hasElementWithId(o);s?i.push(a):n.push(a)}};return s(a,o,n),s(o,a,r),{left:this.spawn(n,{unique:!0}),right:this.spawn(r,{unique:!0}),both:this.spawn(i,{unique:!0})}},add:function(e){var t=this._private.cy;if(!e)return this;if(E(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&&E(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,l=!i.has(s);if(l){var u=this.length++;this[u]=o,i.set(s,{ele:o,index:u})}else{var c=i.get(s).index;this[c]=o,i.set(s,{ele:o,index:c})}}return this},unmergeAt:function(e){var t=this[e],n=t.id(),r=this._private,i=r.map;this[e]=void 0,i.delete(n);var a=e===this.length-1;if(this.length>1&&!a){var o=this.length-1,s=this[o],l=s._private.data.id;this[o]=void 0,this[e]=s,i.set(l,{ele:s,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,n=e._private.data.id,r=t.map,i=r.get(n);if(!i)return this;var a=i.index;return this.unmergeAt(a),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&E(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;t>=0;t--){var n=this[t];e(n)&&this.unmergeAt(t)}return this},map:function(e,t){for(var n=[],r=this,i=0;i<r.length;i++){var a=r[i],o=t?e.apply(t,[a,i,r]):e(a,i,r);n.push(o)}return n},reduce:function(e,t){for(var n=t,r=this,i=0;i<r.length;i++)n=e(n,r[i],i,r);return n},max:function(e,t){for(var n,r=-1/0,i=this,a=0;a<i.length;a++){var o=i[a],s=t?e.apply(t,[o,a,i]):e(o,a,i);s>r&&(r=s,n=o)}return{value:r,ele:n}},min:function(e,t){for(var n,r=1/0,i=this,a=0;a<i.length;a++){var o=i[a],s=t?e.apply(t,[o,a,i]):e(o,a,i);s<r&&(r=s,n=o)}return{value:r,ele:n}}},za=Na;za["u"]=za["|"]=za["+"]=za.union=za.or=za.add,za["\\"]=za["!"]=za["-"]=za.difference=za.relativeComplement=za.subtract=za.not,za["n"]=za["&"]=za["."]=za.and=za.intersection=za.intersect,za["^"]=za["(+)"]=za["(-)"]=za.symmetricDifference=za.symdiff=za.xor,za.fnFilter=za.filterFn=za.stdFilter=za.filter,za.complement=za.abscomp=za.absoluteComplement;var Ba={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}},Oa=function(e,t){var n=e.cy(),r=n.hasCompoundNodes();function i(e){var t=e.pstyle("z-compound-depth");return"auto"===t.value?r?e.zDepth():0:"bottom"===t.value?-1:"top"===t.value?ke:0}var a=i(e)-i(t);if(0!==a)return a;function o(e){var t=e.pstyle("z-index-compare");return"auto"===t.value&&e.isNode()?1:0}var s=o(e)-o(t);if(0!==s)return s;var l=e.pstyle("z-index").value-t.pstyle("z-index").value;return 0!==l?l:e.poolIndex()-t.poolIndex()},La={forEach:function(e,t){if(_(e))for(var n=this.length,r=0;r<n;r++){var i=this[r],a=t?e.apply(t,[i,r,this]):e(i,r,this);if(!1===a)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;i>=0&&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(!_(e))return this;var t=this.toArray().sort(e);return this.spawn(t)},sortByZIndex:function(){return this.sort(Oa)},zDepth:function(){var e=this[0];if(e){var t=e._private,n=t.group;if("nodes"===n){var r=t.data.parent?e.parents().size():0;return e.isParent()?r:ke-1}var i=t.source,a=t.target,o=i.zDepth(),s=a.zDepth();return Math.max(o,s,0)}}};La.each=La.forEach;var Aa=Re({nodeDimensionsIncludeLabels:!1}),Ia={layoutDimensions:function(e){if(e=Aa(e),e.nodeDimensionsIncludeLabels){var t=this.boundingBox();return{w:t.w,h:t.h}}return{w:this.outerWidth(),h:this.outerHeight()}},layoutPositions:function(e,t,n){var r=this.nodes(),i=this.cy(),a=t.eles,o=function(e){return e.id()},s=j(n,o);e.emit({type:"layoutstart",layout:e}),e.animations=[];var l=function(e,t,n){var r={x:t.x1+t.w/2,y:t.y1+t.h/2},i={x:(n.x-r.x)*e,y:(n.y-r.y)*e};return{x:r.x+i.x,y:r.y+i.y}},u=t.spacingFactor&&1!==t.spacingFactor,c=function(){if(!u)return null;for(var e=Mt(),t=0;t<r.length;t++){var n=r[t],i=s(n,t);Ot(e,i.x,i.y)}return e},d=c(),h=j(function(e,n){var r=s(e,n);if(u){var i=Math.abs(t.spacingFactor);r=l(i,d,r)}return null!=t.transform&&(r=t.transform(e,r)),r},o);if(t.animate){for(var p=0;p<r.length;p++){var f=r[p],g=h(f,p),v=null==t.animateFilter||t.animateFilter(f,p);if(v){var y=f.animation({position:g,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(y)}else f.position(g)}if(t.fit){var m=i.animation({fit:{boundingBox:a.boundingBoxAt(h),padding:t.padding},duration:t.animationDuration,easing:t.animationEasing});e.animations.push(m)}else if(void 0!==t.zoom&&void 0!==t.pan){var b=i.animation({zoom:t.zoom,pan:t.pan,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(b)}e.animations.forEach(function(e){return e.play()}),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),Ir.all(e.animations.map(function(e){return e.promise()})).then(function(){e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e})})}else r.positions(h),t.fit&&i.fit(t.eles,t.padding),null!=t.zoom&&i.zoom(t.zoom),t.pan&&i.pan(t.pan),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e});return this},layout:function(e){var t=this.cy();return t.makeLayout(te({},e,{eles:this}))}};function Ra(e,t,n){var r,i=n._private,a=i.styleCache=i.styleCache||[];return null!=(r=a[e])?r:(r=a[e]=t(n),r)}function Fa(e,t){return e=me(e),function(n){return Ra(e,t,n)}}function Va(e,t){e=me(e);var n=function(e){return t.call(e)};return function(){var t=this[0];if(t)return Ra(e,n,t)}}Ia.createLayout=Ia.makeLayout=Ia.layout;var ja={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()),e.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()){var n=t._private.batchStyleEles;return n.merge(this),this}var r=t.hasCompoundNodes(),i=t.style(),a=this;e=!(!e&&void 0!==e),r&&(a=this.spawnSelf().merge(this.descendants()).merge(this.parents()));var o=i.apply(a);return e?o.emitAndNotify("style"):o.emit("style"),this},parsedStyle:function(e){var t=!(arguments.length>1&&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=!1,i=n.style();if(C(e)){var a=e;i.applyBypass(this,a,r),this.emitAndNotify("style")}else if(E(e)){if(void 0===t){var o=this[0];return o?i.getStylePropertyValue(o,e):void 0}i.applyBypass(this,e,t,r),this.emitAndNotify("style")}else if(void 0===e){var s=this[0];return s?i.getRawStyle(s):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=!1,r=t.style(),i=this;if(void 0===e)for(var a=0;a<i.length;a++){var o=i[a];r.removeAllBypasses(o,n)}else{e=e.split(/\s+/);for(var s=0;s<i.length;s++){var l=i[s];r.removeBypasses(l,e,n)}}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++){var s=a[o],l=s.pstyle("opacity").value;i*=l}return i}},transparent:function(){var e=this.cy();if(!e.styleEnabled())return!1;var t=this[0],n=t.cy().hasCompoundNodes();return t?n?0===t.effectiveOpacity():0===t.pstyle("opacity").value:void 0},backgrounding:function(){var e=this.cy();if(!e.styleEnabled())return!1;var t=this[0];return!!t._private.backgrounding}};function qa(e,t){var n=e._private,r=n.data.parent?e.parents():null;if(r)for(var i=0;i<r.length;i++){var a=r[i];if(!t(a))return!1}return!0}function Xa(e){var t=e.ok,n=e.edgeOkViaNode||e.ok,r=e.parentOk||e.ok;return function(){var e=this.cy();if(!e.styleEnabled())return!0;var i=this[0],a=e.hasCompoundNodes();if(i){var o=i._private;if(!t(i))return!1;if(i.isNode())return!a||qa(i,r);var s=o.source,l=o.target;return n(s)&&(!a||qa(s,n))&&(s===l||n(l)&&(!a||qa(l,n)))}}}var Ya=Fa("eleTakesUpSpace",function(e){return"element"===e.pstyle("display").value&&0!==e.width()&&(!e.isNode()||0!==e.height())});ja.takesUpSpace=Va("takesUpSpace",Xa({ok:Ya}));var Ha=Fa("eleInteractive",function(e){return"yes"===e.pstyle("events").value&&"visible"===e.pstyle("visibility").value&&Ya(e)}),Ga=Fa("parentInteractive",function(e){return"visible"===e.pstyle("visibility").value&&Ya(e)});ja.interactive=Va("interactive",Xa({ok:Ha,parentOk:Ga,edgeOkViaNode:Ya})),ja.noninteractive=function(){var e=this[0];if(e)return!e.interactive()};var Wa=Fa("eleVisible",function(e){return"visible"===e.pstyle("visibility").value&&0!==e.pstyle("opacity").pfValue&&Ya(e)}),$a=Ya;ja.visible=Va("visible",Xa({ok:Wa,edgeOkViaNode:$a})),ja.hidden=function(){var e=this[0];if(e)return!e.visible()},ja.isBundledBezier=Va("isBundledBezier",function(){return!!this.cy().styleEnabled()&&(!this.removed()&&"bezier"===this.pstyle("curve-style").value&&this.takesUpSpace())}),ja.bypass=ja.css=ja.style,ja.renderedCss=ja.renderedStyle,ja.removeBypass=ja.removeCss=ja.removeStyle,ja.pstyle=ja.parsedStyle;var Ua={};function Ka(e){return function(){var t=arguments,n=[];if(2===t.length){var r=t[0],i=t[1];this.on(e.event,r,i)}else if(1===t.length&&_(t[0])){var a=t[0];this.on(e.event,a)}else if(0===t.length||1===t.length&&k(t[0])){for(var o=1===t.length?t[0]:null,s=0;s<this.length;s++){var l=this[s],u=!e.ableField||l._private[e.ableField],c=l._private[e.field]!=e.value;if(e.overrideAble){var d=e.overrideAble(l);if(void 0!==d&&(u=d,!d))return this}u&&(l._private[e.field]=e.value,c&&n.push(l))}var h=this.spawn(n);h.updateStyle(),h.emit(e.event),o&&h.emit(o)}return this}}function Za(e){Ua[e.field]=function(){var t=this[0];if(t){if(e.overrideField){var n=e.overrideField(t);if(void 0!==n)return n}return t._private[e.field]}},Ua[e.on]=Ka({event:e.on,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!0}),Ua[e.off]=Ka({event:e.off,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!1})}Za({field:"locked",overrideField:function(e){return!!e.cy().autolock()||void 0},on:"lock",off:"unlock"}),Za({field:"grabbable",overrideField:function(e){return!e.cy().autoungrabify()&&!e.pannable()&&void 0},on:"grabify",off:"ungrabify"}),Za({field:"selected",ableField:"selectable",overrideAble:function(e){return!e.cy().autounselectify()&&void 0},on:"select",off:"unselect"}),Za({field:"selectable",overrideField:function(e){return!e.cy().autounselectify()&&void 0},on:"selectify",off:"unselectify"}),Ua.deselect=Ua.unselect,Ua.grabbed=function(){var e=this[0];if(e)return e._private.grabbed},Za({field:"active",on:"activate",off:"unactivate"}),Za({field:"pannable",on:"panify",off:"unpanify"}),Ua.inactive=function(){var e=this[0];if(e)return!e._private.active};var Qa={},Ja=function(e){return function(t){for(var n=this,r=[],i=0;i<n.length;i++){var a=n[i];if(a.isNode()){for(var o=!1,s=a.connectedEdges(),l=0;l<s.length;l++){var u=s[l],c=u.source(),d=u.target();if(e.noIncomingEdges&&d===a&&c!==a||e.noOutgoingEdges&&c===a&&d!==a){o=!0;break}}o||r.push(a)}}return this.spawn(r,{unique:!0}).filter(t)}},eo=function(e){return function(t){for(var n=this,r=[],i=0;i<n.length;i++){var a=n[i];if(a.isNode())for(var o=a.connectedEdges(),s=0;s<o.length;s++){var l=o[s],u=l.source(),c=l.target();e.outgoing&&u===a?(r.push(l),r.push(c)):e.incoming&&c===a&&(r.push(l),r.push(u))}}return this.spawn(r,{unique:!0}).filter(t)}},to=function(e){return function(t){for(var n=this,r=[],i={};;){var a=e.outgoing?n.outgoers():n.incomers();if(0===a.length)break;for(var o=!1,s=0;s<a.length;s++){var l=a[s],u=l.id();i[u]||(i[u]=!0,r.push(l),o=!0)}if(!o)break;n=a}return this.spawn(r,{unique:!0}).filter(t)}};function no(e){return function(t){for(var n=[],r=0;r<this.length;r++){var i=this[r],a=i._private[e.attr];a&&n.push(a)}return this.spawn(n,{unique:!0}).filter(t)}}function ro(e){return function(t){var n=[],r=this._private.cy,i=e||{};E(t)&&(t=r.$(t));for(var a=0;a<t.length;a++)for(var o=t[a]._private.edges,s=0;s<o.length;s++){var l=o[s],u=l._private.data,c=this.hasElementWithId(u.source)&&t.hasElementWithId(u.target),d=t.hasElementWithId(u.source)&&this.hasElementWithId(u.target),h=c||d;if(h){if(i.thisIsSrc||i.thisIsTgt){if(i.thisIsSrc&&!c)continue;if(i.thisIsTgt&&!d)continue}n.push(l)}}return this.spawn(n,{unique:!0})}}function io(e){var t={codirected:!1};return e=te({},t,e),function(t){for(var n=[],r=this.edges(),i=e,a=0;a<r.length;a++)for(var o=r[a],s=o._private,l=s.source,u=l._private.data.id,c=s.data.target,d=l._private.edges,h=0;h<d.length;h++){var p=d[h],f=p._private.data,g=f.target,v=f.source,y=g===c&&v===u,m=u===g&&c===v;(i.codirected&&y||!i.codirected&&(y||m))&&n.push(p)}return this.spawn(n,{unique:!0}).filter(t)}}Qa.clearTraversalCache=function(){for(var e=0;e<this.length;e++)this[e]._private.traversalCache=null},te(Qa,{roots:Ja({noIncomingEdges:!0}),leaves:Ja({noOutgoingEdges:!0}),outgoers:Ei(eo({outgoing:!0}),"outgoers"),successors:to({outgoing:!0}),incomers:Ei(eo({incoming:!0}),"incomers"),predecessors:to({incoming:!0})}),te(Qa,{neighborhood:Ei(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;c.length>0&&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)}}),Qa.neighbourhood=Qa.neighborhood,Qa.closedNeighbourhood=Qa.closedNeighborhood,Qa.openNeighbourhood=Qa.openNeighborhood,te(Qa,{source:Ei(function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t},"source"),target:Ei(function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t},"target"),sources:no({attr:"source"}),targets:no({attr:"target"})}),te(Qa,{edgesWith:Ei(ro(),"edgesWith"),edgesTo:Ei(ro({thisIsSrc:!0}),"edgesTo")}),te(Qa,{connectedEdges:Ei(function(e){for(var t=[],n=this,r=0;r<n.length;r++){var i=n[r];if(i.isNode())for(var a=i._private.edges,o=0;o<a.length;o++){var s=a[o];t.push(s)}}return this.spawn(t,{unique:!0}).filter(e)},"connectedEdges"),connectedNodes:Ei(function(e){for(var t=[],n=this,r=0;r<n.length;r++){var i=n[r];i.isEdge()&&(t.push(i.source()[0]),t.push(i.target()[0]))}return this.spawn(t,{unique:!0}).filter(e)},"connectedNodes"),parallelEdges:Ei(io(),"parallelEdges"),codirectedEdges:Ei(io({codirected:!0}),"codirectedEdges")}),te(Qa,{components:function(e){var t=this,n=t.cy(),r=n.collection(),i=null==e?t.nodes():e.nodes(),a=[];null!=e&&i.empty()&&(i=e.sources());var o=function(e,t){r.merge(e),i.unmerge(e),t.merge(e)};if(i.empty())return t.spawn();var s=function(){var e=n.collection();a.push(e);var r=i[0];o(r,e),t.bfs({directed:!1,roots:r,visit:function(t){return o(t,e)}}),e.forEach(function(t){t.connectedEdges().forEach(function(t){e.has(t.source())&&e.has(t.target())&&e.merge(t)})})};do{s()}while(i.length>0);return a},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),Qa.componentsOf=Qa.components;var ao={generate:function(e,t,n){var r=null!=n?n:Le();while(e.hasElementWithId(r))r=Le();return r}},oo=function(e,t,n){if(void 0!==e&&B(e)){var r=new He,i=!1;if(t){if(t.length>0&&C(t[0])&&!N(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=ao.generate(e,u);else if(e.hasElementWithId(c.id)||o.has(c.id))continue;var d=new Ue(e,u,!1);a.push(d),o.add(c.id)}t=a}}else t=[];this.length=0;for(var h=0,p=t.length;h<p;h++){var f=t[h][0];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 Pe("A collection must have a reference to the core")},so=Ue.prototype=oo.prototype;so.instanceString=function(){return"collection"},so.spawn=function(e,t,n){return B(e)||(n=t,t=e,e=this.cy()),new oo(e,t,n)},so.spawnSelf=function(){return this.spawn(this)},so.cy=function(){return this._private.cy},so.renderer=function(){return this._private.cy.renderer()},so.element=function(){return this[0]},so.collection=function(){return z(this)?this:new oo(this._private.cy,[this])},so.unique=function(){return new oo(this._private.cy,this,{unique:!0})},so.hasElementWithId=function(e){return e=""+e,this._private.map.has(e)},so.getElementById=function(e){e=""+e;var t=this._private.cy,n=this._private.map.get(e);return n?n.ele:new oo(t)},so.$id=so.getElementById,so.poolIndex=function(){var e=this._private.cy,t=e._private.elements,n=this[0]._private.data.id;return t._private.map.get(n).index},so.indexOf=function(e){var t=e[0]._private.data.id;return this._private.map.get(t).index},so.indexOfId=function(e){return e=""+e,this._private.map.get(e).index},so.json=function(e){var t=this.element(),n=this.cy();if(null==t&&e)return this;if(null!=t){var r=t._private;if(C(e)){if(n.startBatch(),e.data){t.data(e.data);var i=r.data;if(t.isEdge()){var a=!1,o={},s=e.data.source,l=e.data.target;null!=s&&s!=i.source&&(o.source=""+s,a=!0),null!=l&&l!=i.target&&(o.target=""+l,a=!0),a&&(t=t.move(o))}else{var u=e.data.parent;null==u&&null==i.parent||u==i.parent||(void 0===u&&(u=null),null!=u&&(u=""+u),t=t.move({parent:u}))}}e.position&&t.position(e.position);var c=function(n,i,a){var o=e[n];null!=o&&o!==r[n]&&(o?t[i]():t[a]())};return c("removed","remove","restore"),c("selected","select","unselect"),c("selectable","selectify","unselectify"),c("locked","lock","unlock"),c("grabbable","grabify","ungrabify"),c("pannable","panify","unpanify"),null!=e.classes&&t.classes(e.classes),n.endBatch(),this}if(void 0===e){var d={data:Be(r.data),position:Be(r.position),group:r.group,removed:r.removed,selected:r.selected,selectable:r.selectable,locked:r.locked,grabbable:r.grabbable,pannable:r.pannable,classes:null};d.classes="";var h=0;return r.classes.forEach(function(e){return d.classes+=0===h++?e:" "+e}),d}}},so.jsons=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t],r=n.json();e.push(r)}return e},so.clone=function(){for(var e=this.cy(),t=[],n=0;n<this.length;n++){var r=this[n],i=r.json(),a=new Ue(e,i,!1);t.push(a)}return new oo(e,t)},so.copy=so.clone,so.restore=function(){for(var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this,a=i.cy(),o=a._private,s=[],l=[],u=0,c=i.length;u<c;u++){var d=i[u];r&&!d.removed()||(d.isNode()?s.push(d):l.push(d))}e=s.concat(l);var h=function(){e.splice(t,1),t--};for(t=0;t<e.length;t++){var p=e[t],f=p._private,g=f.data;if(p.clearTraversalCache(),r||f.removed)if(void 0===g.id)g.id=ao.generate(a,p);else if(S(g.id))g.id=""+g.id;else{if(A(g.id)||!E(g.id)){Pe("Can not create element with invalid string ID `"+g.id+"`"),h();continue}if(a.hasElementWithId(g.id)){Pe("Can not create second element with ID `"+g.id+"`"),h();continue}}else;var v=g.id;if(p.isNode()){var y=f.position;null==y.x&&(y.x=0),null==y.y&&(y.y=0)}if(p.isEdge()){for(var m=p,b=["source","target"],x=b.length,w=!1,_=0;_<x;_++){var k=b[_],C=g[k];S(C)&&(C=g[k]=""+g[k]),null==C||""===C?(Pe("Can not create edge `"+v+"` with unspecified "+k),w=!0):a.hasElementWithId(C)||(Pe("Can not create edge `"+v+"` with nonexistant "+k+" `"+C+"`"),w=!0)}if(w){h();continue}var T=a.getElementById(g.source),D=a.getElementById(g.target);T.same(D)?T._private.edges.push(m):(T._private.edges.push(m),D._private.edges.push(m)),m._private.source=T,m._private.target=D}f.map=new He,f.map.set(v,{ele:p,index:0}),f.removed=!1,r&&a.addToPool(p)}for(var P=0;P<s.length;P++){var M=s[P],N=M._private.data;S(N.parent)&&(N.parent=""+N.parent);var z=N.parent,B=null!=z;if(B){var O=a.getElementById(z);if(O.empty())N.parent=void 0;else{var L=!1,I=O;while(!I.empty()){if(M.same(I)){L=!0,N.parent=void 0;break}I=I.parent()}L||(O[0]._private.children.push(M),M._private.parent=O[0],o.hasCompoundNodes=!0)}}}if(e.length>0){for(var R,F=new oo(a,e),V=0;V<F.length;V++){var j=F[V];j.isNode()||(j.parallelEdges().clearTraversalCache(),j.source().clearTraversalCache(),j.target().clearTraversalCache())}R=o.hasCompoundNodes?a.collection().merge(F).merge(F.connectedNodes()).merge(F.parent()):F,R.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(n),n?F.emitAndNotify("add"):r&&F.emit("add")}return i},so.removed=function(){var e=this[0];return e&&e._private.removed},so.inside=function(){var e=this[0];return e&&!e._private.removed},so.remove=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this,r=[],i={},a=n._private.cy;function o(e){for(var t=e._private.edges,n=0;n<t.length;n++)l(t[n])}function s(e){for(var t=e._private.children,n=0;n<t.length;n++)l(t[n])}function l(e){var n=i[e.id()];t&&e.removed()||n||(i[e.id()]=!0,e.isNode()?(r.push(e),o(e),s(e)):r.unshift(e))}for(var u=0,c=n.length;u<c;u++){var d=n[u];l(d)}function h(e,t){var n=e._private.edges;Fe(n,t),e.clearTraversalCache()}function p(e){e.clearTraversalCache()}var f=[];function g(e,t){t=t[0],e=e[0];var n=e._private.children,r=e.id();Fe(n,t),t._private.parent=null,f.ids[r]||(f.ids[r]=!0,f.push(e))}f.ids={},n.dirtyCompoundBoundsCache(),t&&a.removeFromPool(r);for(var v=0;v<r.length;v++){var y=r[v];if(y.isEdge()){var m=y.source()[0],b=y.target()[0];h(m,y),h(b,y);for(var x=y.parallelEdges(),w=0;w<x.length;w++){var E=x[w];p(E),E.isBundledBezier()&&E.dirtyBoundingBoxCache()}}else{var _=y.parent();0!==_.length&&g(_,y)}t&&(y._private.removed=!0)}var k=a._private.elements;a._private.hasCompoundNodes=!1;for(var C=0;C<k.length;C++){var T=k[C];if(T.isParent()){a._private.hasCompoundNodes=!0;break}}var S=new oo(this.cy(),r);S.size()>0&&(e?S.emitAndNotify("remove"):t&&S.emit("remove"));for(var D=0;D<f.length;D++){var P=f[D];t&&P.removed()||P.updateStyle()}return S},so.move=function(e){var t=this._private.cy,n=this,r=!1,i=!1,a=function(e){return null==e?e:""+e};if(void 0!==e.source||void 0!==e.target){var o=a(e.source),s=a(e.target),l=null!=o&&t.hasElementWithId(o),u=null!=s&&t.hasElementWithId(s);(l||u)&&(t.batch(function(){n.remove(r,i),n.emitAndNotify("moveout");for(var e=0;e<n.length;e++){var t=n[e],a=t._private.data;t.isEdge()&&(l&&(a.source=o),u&&(a.target=s))}n.restore(r,i)}),n.emitAndNotify("move"))}else if(void 0!==e.parent){var c=a(e.parent),d=null===c||t.hasElementWithId(c);if(d){var h=null===c?void 0:c;t.batch(function(){var e=n.remove(r,i);e.emitAndNotify("moveout");for(var t=0;t<n.length;t++){var a=n[t],o=a._private.data;a.isNode()&&(o.parent=h)}e.restore(r,i)}),n.emitAndNotify("move")}}return this},[Sr,Yr,Hr,bi,_i,Mi,Ni,fa,Ma,Na,Ba,La,Ia,ja,Ua,Qa].forEach(function(e){te(so,e)});var lo={add:function(e){var t,n=this;if(M(e)){var r=e;if(r._private.cy===n)t=r.restore();else{for(var i=[],a=0;a<r.length;a++){var o=r[a];i.push(o.json())}t=new oo(n,i)}}else if(k(e)){var s=e;t=new oo(n,s)}else if(C(e)&&(k(e.nodes)||k(e.edges))){for(var l=e,u=[],c=["nodes","edges"],d=0,h=c.length;d<h;d++){var p=c[d],f=l[p];if(k(f))for(var g=0,v=f.length;g<v;g++){var y=te({group:p},f[g]);u.push(y)}}t=new oo(n,u)}else{var m=e;t=new Ue(n,m).collection()}return t},remove:function(e){if(M(e));else if(E(e)){var t=e;e=this.$(t)}return e.remove()}};
  /*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */function uo(e,t,n,r){var i=4,a=.001,o=1e-7,s=10,l=11,u=1/(l-1),c="undefined"!==typeof Float32Array;if(4!==arguments.length)return!1;for(var d=0;d<4;++d)if("number"!==typeof arguments[d]||isNaN(arguments[d])||!isFinite(arguments[d]))return!1;e=Math.min(e,1),n=Math.min(n,1),e=Math.max(e,0),n=Math.max(n,0);var h=c?new Float32Array(l):new Array(l);function p(e,t){return 1-3*t+3*e}function f(e,t){return 3*t-6*e}function g(e){return 3*e}function v(e,t,n){return((p(t,n)*e+f(t,n))*e+g(t))*e}function y(e,t,n){return 3*p(t,n)*e*e+2*f(t,n)*e+g(t)}function m(t,r){for(var a=0;a<i;++a){var o=y(r,e,n);if(0===o)return r;var s=v(r,e,n)-t;r-=s/o}return r}function b(){for(var t=0;t<l;++t)h[t]=v(t*u,e,n)}function x(t,r,i){var a,l,u=0;do{l=r+(i-r)/2,a=v(l,e,n)-t,a>0?i=l:r=l}while(Math.abs(a)>o&&++u<s);return l}function w(t){for(var r=0,i=1,o=l-1;i!==o&&h[i]<=t;++i)r+=u;--i;var s=(t-h[i])/(h[i+1]-h[i]),c=r+s*u,d=y(c,e,n);return d>=a?m(t,c):0===d?c:x(t,r,r+u)}var E=!1;function _(){E=!0,e===t&&n===r||b()}var k=function(i){return E||_(),e===t&&n===r?i:0===i?0:1===i?1:v(w(i),t,r)};k.getControlPoints=function(){return[{x:e,y:t},{x:n,y:r}]};var C="generateBezier("+[e,t,n,r]+")";return k.toString=function(){return C},k}
  /*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var co=function(){function e(e){return-e.tension*e.x-e.friction*e.v}function t(t,n,r){var i={x:t.x+r.dx*n,v:t.v+r.dv*n,tension:t.tension,friction:t.friction};return{dx:i.v,dv:e(i)}}function n(n,r){var i={dx:n.v,dv:e(n)},a=t(n,.5*r,i),o=t(n,.5*r,a),s=t(n,r,o),l=1/6*(i.dx+2*(a.dx+o.dx)+s.dx),u=1/6*(i.dv+2*(a.dv+o.dv)+s.dv);return n.x=n.x+l*r,n.v=n.v+u*r,n}return function e(t,r,i){var a,o,s,l={x:-1,v:0,tension:null,friction:null},u=[0],c=0,d=1e-4,h=.016;for(t=parseFloat(t)||500,r=parseFloat(r)||20,i=i||null,l.tension=t,l.friction=r,a=null!==i,a?(c=e(t,r),o=c/i*h):o=h;;)if(s=n(s||l,o),u.push(1+s.x),c+=16,!(Math.abs(s.x)>d&&Math.abs(s.v)>d))break;return a?function(e){return u[e*(u.length-1)|0]}:c}}(),ho=function(e,t,n,r){var i=uo(e,t,n,r);return function(e,t,n){return e+(t-e)*i(n)}},po={linear:function(e,t,n){return e+(t-e)*n},ease:ho(.25,.1,.25,1),"ease-in":ho(.42,0,1,1),"ease-out":ho(0,0,.58,1),"ease-in-out":ho(.42,0,.58,1),"ease-in-sine":ho(.47,0,.745,.715),"ease-out-sine":ho(.39,.575,.565,1),"ease-in-out-sine":ho(.445,.05,.55,.95),"ease-in-quad":ho(.55,.085,.68,.53),"ease-out-quad":ho(.25,.46,.45,.94),"ease-in-out-quad":ho(.455,.03,.515,.955),"ease-in-cubic":ho(.55,.055,.675,.19),"ease-out-cubic":ho(.215,.61,.355,1),"ease-in-out-cubic":ho(.645,.045,.355,1),"ease-in-quart":ho(.895,.03,.685,.22),"ease-out-quart":ho(.165,.84,.44,1),"ease-in-out-quart":ho(.77,0,.175,1),"ease-in-quint":ho(.755,.05,.855,.06),"ease-out-quint":ho(.23,1,.32,1),"ease-in-out-quint":ho(.86,0,.07,1),"ease-in-expo":ho(.95,.05,.795,.035),"ease-out-expo":ho(.19,1,.22,1),"ease-in-out-expo":ho(1,0,0,1),"ease-in-circ":ho(.6,.04,.98,.335),"ease-out-circ":ho(.075,.82,.165,1),"ease-in-out-circ":ho(.785,.135,.15,.86),spring:function(e,t,n){if(0===n)return po.linear;var r=co(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":ho};function fo(e,t,n,r,i){if(1===r)return n;var a=i(t,n,r);return null==e?a:((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 go(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function vo(e,t,n,r,i){var a=null!=i?i.type:null;n<0?n=0:n>1&&(n=1);var o=go(e,i),s=go(t,i);if(S(o)&&S(s))return fo(a,o,s,n,r);if(k(o)&&k(s)){for(var l=[],u=0;u<s.length;u++){var c=o[u],d=s[u];if(null!=c&&null!=d){var h=fo(a,c,d,n,r);l.push(h)}else l.push(d)}return l}}function yo(e,t,n,r){var i=!r,a=e._private,o=t._private,s=o.easing,l=o.startTime,u=r?e:e.cy(),c=u.style();if(!o.easingImpl)if(null==s)o.easingImpl=po["linear"];else{var d,h,p;if(E(s)){var f=c.parse("transition-timing-function",s);d=f.value}else d=s;E(d)?(h=d,p=[]):(h=d[1],p=d.slice(2).map(function(e){return+e})),p.length>0?("spring"===h&&p.push(o.duration),o.easingImpl=po[h].apply(null,p)):o.easingImpl=po[h]}var g,v=o.easingImpl;if(g=0===o.duration?1:(n-l)/o.duration,o.applying&&(g=o.progress),g<0?g=0:g>1&&(g=1),null==o.delay){var y=o.startPosition,m=o.position;if(m&&i&&!e.locked()){var b={};mo(y.x,m.x)&&(b.x=vo(y.x,m.x,g,v)),mo(y.y,m.y)&&(b.y=vo(y.y,m.y,g,v)),e.position(b)}var x=o.startPan,w=o.pan,_=a.pan,k=null!=w&&r;k&&(mo(x.x,w.x)&&(_.x=vo(x.x,w.x,g,v)),mo(x.y,w.y)&&(_.y=vo(x.y,w.y,g,v)),e.emit("pan"));var C=o.startZoom,T=o.zoom,S=null!=T&&r;S&&(mo(C,T)&&(a.zoom=Pt(a.minZoom,vo(C,T,g,v),a.maxZoom)),e.emit("zoom")),(k||S)&&e.emit("viewport");var D=o.style;if(D&&D.length>0&&i){for(var P=0;P<D.length;P++){var M=D[P],N=M.name,z=M,B=o.startStyle[N],O=c.properties[B.name],L=vo(B,z,g,v,O);c.overrideBypass(e,N,L)}e.emit("style")}}return o.progress=g,g}function mo(e,t){return null!=e&&null!=t&&(!(!S(e)||!S(t))||!(!e||!t))}function bo(e,t,n,r){var i=t._private;i.started=!0,i.startTime=n-i.progress*i.duration}function xo(e,t){var n=t._private.aniEles,r=[];function i(t,n){var i=t._private,a=i.animation.current,o=i.animation.queue,s=!1;if(!n&&"none"===t.pstyle("display").value){a=a.splice(0,a.length).concat(o.splice(0,o.length));for(var l=0;l<a.length;l++)a[l].stop()}if(0===a.length){var u=o.shift();u&&a.push(u)}for(var c=function(e){for(var t=e.length-1;t>=0;t--){var n=e[t];n()}e.splice(0,e.length)},d=a.length-1;d>=0;d--){var h=a[d],p=h._private;p.stopped?(a.splice(d,1),p.hooked=!1,p.playing=!1,p.started=!1,c(p.frames)):(p.playing||p.applying)&&(p.playing&&p.applying&&(p.applying=!1),p.started||bo(t,h,e,n),yo(t,h,e,n),p.applying&&(p.applying=!1),c(p.frames),null!=p.step&&p.step(e),h.completed()&&(a.splice(d,1),p.hooked=!1,p.playing=!1,p.started=!1,c(p.completes)),s=!0)}return n||0!==a.length||0!==o.length||r.push(t),s}for(var a=!1,o=0;o<n.length;o++){var s=n[o],l=i(s);a=a||l}var u=i(t,!0);(a||u)&&(n.length>0?t.notify("draw",n):t.notify("draw")),n.unmerge(r),t.emit("step")}var wo={animate:Xr.animate(),animation:Xr.animation(),animated:Xr.animated(),clearQueue:Xr.clearQueue(),delay:Xr.delay(),delayAnimation:Xr.delayAnimation(),stop:Xr.stop(),addToAnimationPool:function(e){var t=this;t.styleEnabled()&&t._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,e.styleEnabled()){var t=e.renderer();t&&t.beforeRender?t.beforeRender(function(t,n){xo(n,e)},t.beforeRenderPriorities.animations):n()}function n(){e._private.animationsRunning&&pe(function(t){xo(t,e),n()})}}},Eo={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&&N(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}},_o=function(e){return E(e)?new yi(e):e},ko={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new _a(Eo,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,_o(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,_o(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,_o(t),n),this},once:function(e,t,n){return this.emitter().one(e,_o(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}};Xr.eventAliasesOn(ko);var Co={png:function(e){var t=this._private.renderer;return e=e||{},t.png(e)},jpg:function(e){var t=this._private.renderer;return e=e||{},e.bg=e.bg||"#fff",t.jpg(e)}};Co.jpeg=Co.jpg;var To={layout:function(e){var t=this;if(null!=e)if(null!=e.name){var n=e.name,r=t.extension("layout",n);if(null!=r){var i;i=E(e.eles)?t.$(e.eles):null!=e.eles?e.eles:t.$();var a=new r(te({},e,{cy:t,eles:i}));return a}Pe("No such layout `"+n+"` found.  Did you forget to import it and `cytoscape.use()` it?")}else Pe("A `name` must be specified to make a layout");else Pe("Layout options must be specified to make a layout")}};To.createLayout=To.makeLayout=To.layout;var So={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.destroyed()&&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 this._private.batchCount>0},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 e=this._private;if(0===e.batchCount)return this;if(e.batchCount--,0===e.batchCount){e.batchStyleEles.updateStyle();var t=this.renderer();Object.keys(e.batchNotifications).forEach(function(n){var r=e.batchNotifications[n];r.empty()?t.notify(n):t.notify(n,r)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var t=this;return this.batch(function(){for(var n=Object.keys(e),r=0;r<n.length;r++){var i=n[r],a=e[i],o=t.getElementById(i);o.data(a)}})}},Do=Re({hideEdgesOnViewport:!1,textureOnViewport:!1,motionBlur:!1,motionBlurOpacity:.05,pixelRatio:void 0,desktopTapThreshold:4,touchTapThreshold:8,wheelSensitivity:1,debug:!1,showFps:!1}),Po={renderTo:function(e,t,n,r){var i=this._private.renderer;return i.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,n=t.extension("renderer",e.name);if(null!=n){void 0!==e.wheelSensitivity&&Ne("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 r=Do(e);r.cy=t,t._private.renderer=new n(r),this.notify("init")}else Pe("Can not initialise: No such renderer `".concat(e.name,"` found. Did you forget to import it and `cytoscape.use()` it?"))},destroyRenderer:function(){var e=this;e.notify("destroy");var t=e.container();if(t){t._cyreg=null;while(t.childNodes.length>0)t.removeChild(t.childNodes[0])}e._private.renderer=null,e.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)}};Po.invalidateDimensions=Po.resize;var Mo={collection:function(e,t){return E(e)?this.$(e):M(e)?e.collection():k(e)?new oo(this,e,t):new oo(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}};Mo.elements=Mo.filter=Mo.$;var No={},zo="t",Bo="f";No.apply=function(e){var t=this,n=t._private,r=n.cy,i=r.collection();n.newStyle&&(n.contextStyles={},n.propDiffs={},t.cleanElements(e,!0));for(var a=0;a<e.length;a++){var o=e[a],s=t.getContextMeta(o);if(!s.empty){var l=t.getContextStyle(s),u=t.applyContextStyle(s,l,o);n.newStyle||t.updateTransitions(o,u.diffProps);var c=t.updateStyleHints(o);c&&i.merge(o)}}return n.newStyle=!1,i},No.getPropertiesDiff=function(e,t){var n=this,r=n._private.propDiffs=n._private.propDiffs||{},i=e+"-"+t,a=r[i];if(a)return a;for(var o=[],s={},l=0;l<n.length;l++){var u=n[l],c=e[l]===zo,d=t[l]===zo,h=c!==d,p=u.mappedProperties.length>0;if(h||d&&p){var f=void 0;h&&p?f=u.properties:h?f=u.properties:p&&(f=u.mappedProperties);for(var g=0;g<f.length;g++){for(var v=f[g],y=v.name,m=!1,b=l+1;b<n.length;b++){var x=n[b],w=t[b]===zo;if(w&&(m=null!=x.properties[v.name],m))break}s[y]||m||(s[y]=!0,o.push(y))}}}return r[i]=o,o},No.getContextMeta=function(e){var t,n=this,r="",i=e._private.styleCxtKey||"";n._private.newStyle&&(i="");for(var a=0;a<n.length;a++){var o=n[a],s=o.selector&&o.selector.matches(e);r+=s?zo:Bo}return t=n.getPropertiesDiff(i,r),e._private.styleCxtKey=r,{key:r,diffPropNames:t,empty:0===t.length}},No.getContextStyle=function(e){var t=e.key,n=this,r=this._private.contextStyles=this._private.contextStyles||{};if(r[t])return r[t];for(var i={_private:{key:t}},a=0;a<n.length;a++){var o=n[a],s=t[a]===zo;if(s)for(var l=0;l<o.properties.length;l++){var u=o.properties[l];i[u.name]=u}}return r[t]=i,i},No.applyContextStyle=function(e,t,n){for(var r=this,i=e.diffPropNames,a={},o=r.types,s=0;s<i.length;s++){var l=i[s],u=t[l],c=n.pstyle(l);if(!u){if(!c)continue;u=c.bypass?{name:l,deleteBypassed:!0}:{name:l,delete:!0}}if(c!==u){if(u.mapped===o.fn&&null!=c&&null!=c.mapping&&c.mapping.value===u.value){var d=c.mapping,h=d.fnValue=u.value(n);if(h===d.prevFnValue)continue}var p=a[l]={prev:c};r.applyParsedProperty(n,u),p.next=n.pstyle(l),p.next&&p.next.bypass&&(p.next=p.next.bypassed)}}return{diffProps:a}},No.updateStyleHints=function(e){var t=e._private,n=this,r=n.propertyGroupNames,i=n.propertyGroupKeys,a=function(e,t,r){return n.getPropertiesHash(e,t,r)},o=t.styleKey;if(e.removed())return!1;var s="nodes"===t.group,l=e._private.style;r=Object.keys(l);for(var u=0;u<i.length;u++){var c=i[u];t.styleKeys[c]=0}for(var d=function(e,n){return t.styleKeys[n]=ve(e,t.styleKeys[n])},h=function(e,t){for(var n=0;n<e.length;n++)d(e.charCodeAt(n),t)},p=function(e){return-128<e&&e<128&&Math.floor(e)!==e?-(1024*e|0):e},f=0;f<r.length;f++){var g=r[f],v=l[g];if(null!=v){var y=this.properties[g],m=y.type,b=y.groupKey,x=void 0;null!=y.hashOverride?x=y.hashOverride(e,v):null!=v.pfValue&&(x=v.pfValue);var w=null==y.enums?v.value:null,E=null!=x,_=null!=w,k=E||_,C=v.units;if(m.number&&k){var T=E?x:w;if(m.multiple)for(var S=0;S<T.length;S++)d(p(T[S]),b);else d(p(T),b);E||null==C||h(C,b)}else h(v.strValue,b)}}for(var D=0,P=0;P<i.length;P++){var M=i[P],N=t.styleKeys[M];D=ve(N,D)}t.styleKey=D;var z=t.labelDimsKey=t.styleKeys.labelDimensions;if(t.labelKey=a(e,["label"],z),t.labelStyleKey=ve(t.styleKeys.commonLabel,t.labelKey),s||(t.sourceLabelKey=a(e,["source-label"],z),t.sourceLabelStyleKey=ve(t.styleKeys.commonLabel,t.sourceLabelKey),t.targetLabelKey=a(e,["target-label"],z),t.targetLabelStyleKey=ve(t.styleKeys.commonLabel,t.targetLabelKey)),s){var B=t.styleKeys,O=B.nodeBody,L=B.nodeBorder,A=B.backgroundImage,I=B.compound,R=B.pie;t.nodeKey=ye([L,A,I,R],O),t.hasPie=0!=R}return o!==t.styleKey},No.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},No.applyParsedProperty=function(e,t){var n,r=this,i=t,a=e._private.style,o=r.types,s=r.properties[i.name].type,l=i.bypass,u=a[i.name],c=u&&u.bypass,d=e._private,h="mapping",p=function(e){return null==e?null:null!=e.pfValue?e.pfValue:e.value},f=function(){var t=p(u),n=p(i);r.checkTriggers(e,i.name,t,n)};if("curve-style"===t.name&&e.isEdge()&&("bezier"!==t.value&&e.isLoop()||"haystack"===t.value&&(e.source().isParent()||e.target().isParent()))&&(i=t=this.parse(t.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(){Ne("Do not assign mappings to elements without corresponding data (i.e. ele `"+e.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=d.data,b=0;b<y.length&&m;b++){var x=y[b];m=m[x]}if(null==m)return g(),!1;if(!S(m))return Ne("Do not use continuous mappers without specifying numeric data (i.e. `"+i.field+": "+m+"` for `"+e.id()+"` is non-numeric)"),!1;var w=i.fieldMax-i.fieldMin;if(v=0===w?0:(m-i.fieldMin)/w,v<0?v=0:v>1&&(v=1),s.color){var E=i.valueMin[0],_=i.valueMax[0],k=i.valueMin[1],C=i.valueMax[1],T=i.valueMin[2],D=i.valueMax[2],P=null==i.valueMin[3]?1:i.valueMin[3],M=null==i.valueMax[3]?1:i.valueMax[3],N=[Math.round(E+(_-E)*v),Math.round(k+(C-k)*v),Math.round(T+(D-T)*v),Math.round(P+(M-P)*v)];n={bypass:i.bypass,name:i.name,value:N,strValue:"rgb("+N[0]+", "+N[1]+", "+N[2]+")"}}else{if(!s.number)return!1;var z=i.valueMin+(i.valueMax-i.valueMin)*v;n=this.parse(i.name,z,i.bypass,h)}if(!n)return g(),!1;n.mapping=i,i=n;break;case o.data:for(var B=i.field.split("."),O=d.data,L=0;L<B.length&&O;L++){var A=B[L];O=O[A]}if(null!=O&&(n=this.parse(i.name,O,i.bypass,h)),!n)return g(),!1;n.mapping=i,i=n;break;case o.fn:var I=i.value,R=null!=i.fnValue?i.fnValue:I(e);if(i.prevFnValue=R,null==R)return Ne("Custom function mappers may not return null (i.e. `"+i.name+"` for ele `"+e.id()+"` is null)"),!1;if(n=this.parse(i.name,R,i.bypass,h),!n)return Ne("Custom function mappers may not return invalid values for the property type (i.e. `"+i.name+"` for ele `"+e.id()+"` is invalid)"),!1;n.mapping=Be(i),i=n;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},No.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={}}},No.update=function(){var e=this._private.cy,t=e.mutableElements();t.updateStyle()},No.updateTransitions=function(e,t){var n=this,r=e._private,i=e.pstyle("transition-property").value,a=e.pstyle("transition-duration").pfValue,o=e.pstyle("transition-delay").pfValue;if(i.length>0&&a>0){for(var s={},l=!1,u=0;u<i.length;u++){var c=i[u],d=e.pstyle(c),h=t[c];if(h){var p=h.prev,f=p,g=null!=h.next?h.next:d,v=!1,y=void 0,m=1e-6;f&&(S(f.pfValue)&&S(g.pfValue)?(v=g.pfValue-f.pfValue,y=f.pfValue+m*v):S(f.value)&&S(g.value)?(v=g.value-f.value,y=f.value+m*v):k(f.value)&&k(g.value)&&(v=f.value[0]!==g.value[0]||f.value[1]!==g.value[1]||f.value[2]!==g.value[2],y=f.strValue),v&&(s[c]=g.strValue,this.applyBypass(e,c,y),l=!0))}}if(!l)return;r.transitioning=!0,new Ir(function(t){o>0?e.delayAnimation(o).play().promise().then(t):t()}).then(function(){return e.animation({style:s,duration:a,easing:e.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){n.removeBypasses(e,i),e.emitAndNotify("style"),r.transitioning=!1})}else r.transitioning&&(this.removeBypasses(e,i),e.emitAndNotify("style"),r.transitioning=!1)},No.checkTrigger=function(e,t,n,r,i,a){var o=this.properties[t],s=i(o);null!=s&&s(n,r)&&a(o)},No.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)})},No.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBounds},function(i){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache(),"bezier"!==e.pstyle("curve-style").value&&("curve-style"!==t||"bezier"!==n&&"bezier"!==r)||!i.triggersBoundsOfParallelBeziers||e.parallelEdges().forEach(function(e){e.isBundledBezier()&&e.dirtyBoundingBoxCache()})})},No.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r)};var Oo={applyBypass:function(e,t,n,r){var i=this,a=[],o=!0;if("*"===t||"**"===t){if(void 0!==n)for(var s=0;s<i.properties.length;s++){var l=i.properties[s],u=l.name,c=this.parse(u,n,!0);c&&a.push(c)}}else if(E(t)){var d=this.parse(t,n,!0);d&&a.push(d)}else{if(!C(t))return!1;var h=t;r=n;for(var p=Object.keys(h),f=0;f<p.length;f++){var g=p[f],v=h[g];if(void 0===v&&(v=h[X(g)]),void 0!==v){var y=this.parse(g,v,!0);y&&a.push(y)}}}if(0===a.length)return!1;for(var m=!1,b=0;b<e.length;b++){for(var x=e[b],w={},_=void 0,k=0;k<a.length;k++){var T=a[k];if(r){var S=x.pstyle(T.name);_=w[T.name]={prev:S}}m=this.applyParsedProperty(x,T)||m,r&&(_.next=x.pstyle(T.name))}m&&this.updateStyleHints(x),r&&this.updateTransitions(x,w,o)}return m},overrideBypass:function(e,t,n){t=q(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,i=0;i<e.length;i++){for(var a=e[i],o={},s=0;s<t.length;s++){var l=t[s],u=this.properties[l],c=a.pstyle(u.name);if(c&&c.bypass){var d="",h=this.parse(l,d,!0),p=o[u.name]={prev:c};this.applyParsedProperty(a,h),p.next=a.pstyle(u.name)}}this.updateStyleHints(a),n&&this.updateTransitions(a,o,r)}}},Lo={getEmSizeInPixels:function(){var e=this.containerCss("font-size");return null!=e?parseFloat(e):1},containerCss:function(e){var t=this._private.cy,n=t.container();if(g&&n&&g.getComputedStyle)return g.getComputedStyle(n).getPropertyValue(e)}},Ao={getRenderedStyle:function(e,t){return t?this.getStylePropertyValue(e,t,!0):this.getRawStyle(e,!0)},getRawStyle:function(e,t){var n=this;if(e=e[0],e){for(var r={},i=0;i<n.properties.length;i++){var a=n.properties[i],o=n.getStylePropertyValue(e,a.name,t);null!=o&&(r[a.name]=o,r[X(a.name)]=o)}return r}},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){var r=this;if(e=e[0],e){var i=r.properties[t];i.alias&&(i=i.pointsTo);var a=i.type,o=e.pstyle(i.name);if(o){var s=o.value,l=o.units,u=o.strValue;if(n&&a.number&&null!=s&&S(s)){var c=e.cy().zoom(),d=function(e){return e*c},h=function(e,t){return d(e)+t},p=k(s),f=p?l.every(function(e){return null!=e}):null!=l;return f?p?s.map(function(e,t){return h(e,l[t])}).join(" "):h(s,l):p?s.map(function(e){return E(e)?e:""+d(e)}).join(" "):""+d(s)}if(null!=u)return u}return null}},getAnimationStartStyle:function(e,t){for(var n={},r=0;r<t.length;r++){var i=t[r],a=i.name,o=e.pstyle(a);void 0!==o&&(o=C(o)?this.parse(a,o.strValue):this.parse(a,o)),o&&(n[a]=o)}return n},getPropsList:function(e){var t=this,n=[],r=e,i=t.properties;if(r)for(var a=Object.keys(r),o=0;o<a.length;o++){var s=a[o],l=r[s],u=i[s]||i[q(s)],c=this.parse(u.name,l);c&&n.push(c)}return n},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],i=e.pstyle(r,!1),null!=i)if(null!=i.pfValue)u=ve(o,u);else for(a=i.strValue,l=0;l<a.length;l++)o=a.charCodeAt(l),u=ve(o,u);return u}};Ao.getPropertiesHash=Ao.getNonDefaultPropertiesHash;var Io={appendFromJson:function(e){for(var t=this,n=0;n<e.length;n++){var r=e[n],i=r.selector,a=r.style||r.css,o=Object.keys(a);t.selector(i);for(var s=0;s<o.length;s++){var l=o[s],u=a[l];t.css(l,u)}}return t},fromJson:function(e){var t=this;return t.resetToDefault(),t.appendFromJson(e),t},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}},Ro={appendFromString:function(e){var t,n,r,i=this,a=this,o=""+e;function s(){o=o.length>t.length?o.substr(t.length):""}function l(){n=n.length>r.length?n.substr(r.length):""}for(o=o.replace(/[\/][*](\s|.)+?[*][\/]/g,"");;){var u=o.match(/^\s*$/);if(u)break;var c=o.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!c){Ne("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+o);break}t=c[0];var d=c[1];if("core"!==d){var h=new yi(d);if(h.invalid){Ne("Skipping parsing of block: Invalid selector found in string stylesheet: "+d),s();continue}}var p=c[2],f=!1;n=p;for(var g=[];;){var v=n.match(/^\s*$/);if(v)break;var y=n.match(/^\s*(.+?)\s*:\s*(.+?)\s*;/);if(!y){Ne("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+p),f=!0;break}r=y[0];var m=y[1],b=y[2],x=i.properties[m];if(x){var w=a.parse(m,b);w?(g.push({name:m,val:b}),l()):(Ne("Skipping property: Invalid property definition in: "+r),l())}else Ne("Skipping property: Invalid property name in: "+r),l()}if(f){s();break}a.selector(d);for(var E=0;E<g.length;E++){var _=g[E];a.css(_.name,_.val)}s()}return a},fromString:function(e){var t=this;return t.resetToDefault(),t.appendFromString(e),t}},Fo={};(function(){var e=G,t=$,n=K,r=Z,i=Q,a=function(e){return"^"+e+"\\s*\\(\\s*([\\w\\.]+)\\s*\\)$"},o=function(a){var o=e+"|\\w+|"+t+"|"+n+"|"+r+"|"+i;return"^"+a+"\\s*\\(([\\w\\.]+)\\s*\\,\\s*("+e+")\\s*\\,\\s*("+e+")\\s*,\\s*("+o+")\\s*\\,\\s*("+o+")\\)$"},s=["^url\\s*\\(\\s*['\"]?(.+?)['\"]?\\s*\\)$","^(none)$","^(.+)$"];Fo.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},axisDirection:{enums:["horizontal","leftward","rightward","vertical","upward","downward","auto"]},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","taxi"]},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"]},textOverflowWrap:{enums:["whitespace","anywhere"]},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"]},justification:{enums:["left","center","right","auto"]},text:{string:!0},data:{mapping:!0,regex:a("data")},layoutData:{mapping:!0,regex:a("layoutData")},scratch:{mapping:!0,regex:a("scratch")},mapData:{mapping:!0,regex:o("mapData")},mapLayoutData:{mapping:!0,regex:o("mapLayoutData")},mapScratch:{mapping:!0,regex:o("mapScratch")},fn:{mapping:!0,fn:!0},url:{regexes:s,singleRegexMatchValue:!0},urls:{regexes:s,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 E(e[0])||"deg"===t[0]||"rad"===t[0];default:return!1}}},easing:{regexes:["^(spring)\\s*\\(\\s*("+e+")\\s*,\\s*("+e+")\\s*\\)$","^(cubic-bezier)\\s*\\(\\s*("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")\\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 l={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}},u=Fo.types,c=[{name:"label",type:u.text,triggersBounds:l.any},{name:"text-rotation",type:u.textRotation,triggersBounds:l.any},{name:"text-margin-x",type:u.bidirectionalSize,triggersBounds:l.any},{name:"text-margin-y",type:u.bidirectionalSize,triggersBounds:l.any}],d=[{name:"source-label",type:u.text,triggersBounds:l.any},{name:"source-text-rotation",type:u.textRotation,triggersBounds:l.any},{name:"source-text-margin-x",type:u.bidirectionalSize,triggersBounds:l.any},{name:"source-text-margin-y",type:u.bidirectionalSize,triggersBounds:l.any},{name:"source-text-offset",type:u.size,triggersBounds:l.any}],h=[{name:"target-label",type:u.text,triggersBounds:l.any},{name:"target-text-rotation",type:u.textRotation,triggersBounds:l.any},{name:"target-text-margin-x",type:u.bidirectionalSize,triggersBounds:l.any},{name:"target-text-margin-y",type:u.bidirectionalSize,triggersBounds:l.any},{name:"target-text-offset",type:u.size,triggersBounds:l.any}],p=[{name:"font-family",type:u.fontFamily,triggersBounds:l.any},{name:"font-style",type:u.fontStyle,triggersBounds:l.any},{name:"font-weight",type:u.fontWeight,triggersBounds:l.any},{name:"font-size",type:u.size,triggersBounds:l.any},{name:"text-transform",type:u.textTransform,triggersBounds:l.any},{name:"text-wrap",type:u.textWrap,triggersBounds:l.any},{name:"text-overflow-wrap",type:u.textOverflowWrap,triggersBounds:l.any},{name:"text-max-width",type:u.size,triggersBounds:l.any},{name:"text-outline-width",type:u.size,triggersBounds:l.any},{name:"line-height",type:u.positiveNumber,triggersBounds:l.any}],f=[{name:"text-valign",type:u.valign,triggersBounds:l.any},{name:"text-halign",type:u.halign,triggersBounds:l.any},{name:"color",type:u.color},{name:"text-outline-color",type:u.color},{name:"text-outline-opacity",type:u.zeroOneNumber},{name:"text-background-color",type:u.color},{name:"text-background-opacity",type:u.zeroOneNumber},{name:"text-background-padding",type:u.size,triggersBounds:l.any},{name:"text-border-opacity",type:u.zeroOneNumber},{name:"text-border-color",type:u.color},{name:"text-border-width",type:u.size,triggersBounds:l.any},{name:"text-border-style",type:u.borderStyle,triggersBounds:l.any},{name:"text-background-shape",type:u.textBackgroundShape,triggersBounds:l.any},{name:"text-justification",type:u.justification}],g=[{name:"events",type:u.bool},{name:"text-events",type:u.bool}],v=[{name:"display",type:u.display,triggersZOrder:l.any,triggersBounds:l.any,triggersBoundsOfParallelBeziers:!0},{name:"visibility",type:u.visibility,triggersZOrder:l.any},{name:"opacity",type:u.zeroOneNumber,triggersZOrder:l.zeroNonZero},{name:"text-opacity",type:u.zeroOneNumber},{name:"min-zoomed-font-size",type:u.size},{name:"z-compound-depth",type:u.zCompoundDepth,triggersZOrder:l.any},{name:"z-index-compare",type:u.zIndexCompare,triggersZOrder:l.any},{name:"z-index",type:u.nonNegativeInt,triggersZOrder:l.any}],y=[{name:"overlay-padding",type:u.size,triggersBounds:l.any},{name:"overlay-color",type:u.color},{name:"overlay-opacity",type:u.zeroOneNumber,triggersBounds:l.zeroNonZero}],m=[{name:"transition-property",type:u.propList},{name:"transition-duration",type:u.time},{name:"transition-delay",type:u.time},{name:"transition-timing-function",type:u.easing}],b=function(e,t){return"label"===t.value?-e.poolIndex():t.pfValue},x=[{name:"height",type:u.nodeSize,triggersBounds:l.any,hashOverride:b},{name:"width",type:u.nodeSize,triggersBounds:l.any,hashOverride:b},{name:"shape",type:u.nodeShape,triggersBounds:l.any},{name:"shape-polygon-points",type:u.polygonPointList,triggersBounds:l.any},{name:"background-color",type:u.color},{name:"background-fill",type:u.fill},{name:"background-opacity",type:u.zeroOneNumber},{name:"background-blacken",type:u.nOneOneNumber},{name:"background-gradient-stop-colors",type:u.colors},{name:"background-gradient-stop-positions",type:u.percentages},{name:"background-gradient-direction",type:u.gradientDirection},{name:"padding",type:u.sizeMaybePercent,triggersBounds:l.any},{name:"padding-relative-to",type:u.paddingRelativeTo,triggersBounds:l.any},{name:"bounds-expansion",type:u.size,triggersBounds:l.any}],w=[{name:"border-color",type:u.color},{name:"border-opacity",type:u.zeroOneNumber},{name:"border-width",type:u.size,triggersBounds:l.any},{name:"border-style",type:u.borderStyle}],_=[{name:"background-image",type:u.urls},{name:"background-image-crossorigin",type:u.bgCrossOrigin},{name:"background-image-opacity",type:u.zeroOneNumbers},{name:"background-position-x",type:u.bgPos},{name:"background-position-y",type:u.bgPos},{name:"background-width-relative-to",type:u.bgRelativeTo},{name:"background-height-relative-to",type:u.bgRelativeTo},{name:"background-repeat",type:u.bgRepeat},{name:"background-fit",type:u.bgFit},{name:"background-clip",type:u.bgClip},{name:"background-width",type:u.bgWH},{name:"background-height",type:u.bgWH},{name:"background-offset-x",type:u.bgPos},{name:"background-offset-y",type:u.bgPos}],k=[{name:"position",type:u.position,triggersBounds:l.any},{name:"compound-sizing-wrt-labels",type:u.compoundIncludeLabels,triggersBounds:l.any},{name:"min-width",type:u.size,triggersBounds:l.any},{name:"min-width-bias-left",type:u.sizeMaybePercent,triggersBounds:l.any},{name:"min-width-bias-right",type:u.sizeMaybePercent,triggersBounds:l.any},{name:"min-height",type:u.size,triggersBounds:l.any},{name:"min-height-bias-top",type:u.sizeMaybePercent,triggersBounds:l.any},{name:"min-height-bias-bottom",type:u.sizeMaybePercent,triggersBounds:l.any}],C=[{name:"line-style",type:u.lineStyle},{name:"line-color",type:u.color},{name:"line-fill",type:u.fill},{name:"line-cap",type:u.lineCap},{name:"line-dash-pattern",type:u.numbers},{name:"line-dash-offset",type:u.number},{name:"line-gradient-stop-colors",type:u.colors},{name:"line-gradient-stop-positions",type:u.percentages},{name:"curve-style",type:u.curveStyle,triggersBounds:l.any,triggersBoundsOfParallelBeziers:!0},{name:"haystack-radius",type:u.zeroOneNumber,triggersBounds:l.any},{name:"source-endpoint",type:u.edgeEndpoint,triggersBounds:l.any},{name:"target-endpoint",type:u.edgeEndpoint,triggersBounds:l.any},{name:"control-point-step-size",type:u.size,triggersBounds:l.any},{name:"control-point-distances",type:u.bidirectionalSizes,triggersBounds:l.any},{name:"control-point-weights",type:u.numbers,triggersBounds:l.any},{name:"segment-distances",type:u.bidirectionalSizes,triggersBounds:l.any},{name:"segment-weights",type:u.numbers,triggersBounds:l.any},{name:"taxi-turn",type:u.sizeMaybePercent,triggersBounds:l.any},{name:"taxi-turn-min-distance",type:u.size,triggersBounds:l.any},{name:"taxi-direction",type:u.axisDirection,triggersBounds:l.any},{name:"edge-distances",type:u.edgeDistances,triggersBounds:l.any},{name:"arrow-scale",type:u.positiveNumber,triggersBounds:l.any},{name:"loop-direction",type:u.angle,triggersBounds:l.any},{name:"loop-sweep",type:u.angle,triggersBounds:l.any},{name:"source-distance-from-node",type:u.size,triggersBounds:l.any},{name:"target-distance-from-node",type:u.size,triggersBounds:l.any}],T=[{name:"ghost",type:u.bool,triggersBounds:l.any},{name:"ghost-offset-x",type:u.bidirectionalSize,triggersBounds:l.any},{name:"ghost-offset-y",type:u.bidirectionalSize,triggersBounds:l.any},{name:"ghost-opacity",type:u.zeroOneNumber}],S=[{name:"selection-box-color",type:u.color},{name:"selection-box-opacity",type:u.zeroOneNumber},{name:"selection-box-border-color",type:u.color},{name:"selection-box-border-width",type:u.size},{name:"active-bg-color",type:u.color},{name:"active-bg-opacity",type:u.zeroOneNumber},{name:"active-bg-size",type:u.size},{name:"outside-texture-bg-color",type:u.color},{name:"outside-texture-bg-opacity",type:u.zeroOneNumber}],D=[];Fo.pieBackgroundN=16,D.push({name:"pie-size",type:u.sizeMaybePercent});for(var P=1;P<=Fo.pieBackgroundN;P++)D.push({name:"pie-"+P+"-background-color",type:u.color}),D.push({name:"pie-"+P+"-background-size",type:u.percent}),D.push({name:"pie-"+P+"-background-opacity",type:u.zeroOneNumber});var M=[],N=Fo.arrowPrefixes=["source","mid-source","target","mid-target"];[{name:"arrow-shape",type:u.arrowShape,triggersBounds:l.any},{name:"arrow-color",type:u.color},{name:"arrow-fill",type:u.arrowFill}].forEach(function(e){N.forEach(function(t){var n=t+"-"+e.name,r=e.type,i=e.triggersBounds;M.push({name:n,type:r,triggersBounds:i})})},{});var z=Fo.properties=[].concat(g,m,v,y,T,f,p,c,d,h,x,w,_,D,k,C,M,S),B=Fo.propertyGroups={behavior:g,transition:m,visibility:v,overlay:y,ghost:T,commonLabel:f,labelDimensions:p,mainLabel:c,sourceLabel:d,targetLabel:h,nodeBody:x,nodeBorder:w,backgroundImage:_,pie:D,compound:k,edgeLine:C,edgeArrow:M,core:S},O=Fo.propertyGroupNames={},L=Fo.propertyGroupKeys=Object.keys(B);L.forEach(function(e){O[e]=B[e].map(function(e){return e.name}),B[e].forEach(function(t){return t.groupKey=e})});var A=Fo.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"}];Fo.propertyNames=z.map(function(e){return e.name});for(var I=0;I<z.length;I++){var R=z[I];z[R.name]=R}for(var F=0;F<A.length;F++){var V=A[F],j=z[V.pointsTo],q={name:V.name,alias:!0,pointsTo:j};z.push(q),z[V.name]=q}})(),Fo.getDefaultProperty=function(e){return this.getDefaultProperties()[e]},Fo.getDefaultProperties=function(){var e=this._private;if(null!=e.defaultProperties)return e.defaultProperties;for(var t=te({"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","text-justification":"auto","line-height":1,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-overflow-wrap":"whitespace","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-offset-x":0,"background-offset-y":0,"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","bounds-expansion":0,"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<=Fo.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,"taxi-turn":"50%","taxi-turn-min-distance":10,"taxi-direction":"auto","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(e,t){return Fo.arrowPrefixes.forEach(function(n){var r=n+"-"+t.name,i=t.value;e[r]=i}),e},{})),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},Fo.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 Vo={parse:function(e,t,n,r){var i=this;if(_(t))return i.parseImplWarn(e,t,n,r);var a,o="mapping"===r||!0===r||!1===r||null==r?"dontcare":r,s=n?"t":"f",l=""+t,u=be(e,l,s,o),c=i.propCache=i.propCache||[];return(a=c[u])||(a=c[u]=i.parseImplWarn(e,t,n,r)),(n||"mapping"===r)&&(a=Be(a),a&&(a.value=Be(a.value))),a},parseImplWarn:function(e,t,n,r){var i=this.parseImpl(e,t,n,r);return i||null==t||Ne("The style property `".concat(e,": ").concat(t,"` is invalid")),i},parseImpl:function(e,t,n,r){var i=this;e=q(e);var a=i.properties[e],o=t,s=i.types;if(!a)return null;if(void 0===t)return null;a.alias&&(a=a.pointsTo,e=a.name);var l=E(t);l&&(t=t.trim());var u,c,d=a.type;if(!d)return null;if(n&&(""===t||null===t))return{name:e,value:t,bypass:!0,deleteBypass:!0};if(_(t))return{name:e,value:t,strValue:"fn",mapped:s.fn,bypass:n};if(!l||r||t.length<7||"a"!==t[1]);else{if(t.length>=7&&"d"===t[0]&&(u=new RegExp(s.data.regex).exec(t))){if(n)return!1;var h=s.data;return{name:e,value:u,strValue:""+t,mapped:h,field:u[1],bypass:n}}if(t.length>=10&&"m"===t[0]&&(c=new RegExp(s.mapData.regex).exec(t))){if(n)return!1;if(d.multiple)return!1;var p=s.mapData;if(!d.color&&!d.number)return!1;var f=this.parse(e,c[4]);if(!f||f.mapped)return!1;var g=this.parse(e,c[5]);if(!g||g.mapped)return!1;if(f.pfValue===g.pfValue||f.strValue===g.strValue)return Ne("`"+e+": "+t+"` is not a valid mapper because the output range is zero; converting to `"+e+": "+f.strValue+"`"),this.parse(e,f.strValue);if(d.color){var v=f.value,y=g.value,m=v[0]===y[0]&&v[1]===y[1]&&v[2]===y[2]&&(v[3]===y[3]||(null==v[3]||1===v[3])&&(null==y[3]||1===y[3]));if(m)return!1}return{name:e,value:c,strValue:""+t,mapped:p,field:c[1],fieldMin:parseFloat(c[2]),fieldMax:parseFloat(c[3]),valueMin:f.value,valueMax:g.value,bypass:n}}}if(d.multiple&&"multiple"!==r){var b;if(b=l?t.split(/\s+/):k(t)?t:[t],d.evenMultiple&&b.length%2!==0)return null;for(var x=[],w=[],C=[],T="",S=!1,P=0;P<b.length;P++){var M=i.parse(e,b[P],n,"multiple");S=S||E(M.value),x.push(M.value),C.push(null!=M.pfValue?M.pfValue:M.value),w.push(M.units),T+=(P>0?" ":"")+M.strValue}return d.validate&&!d.validate(x,w)?null:d.singleEnum&&S?1===x.length&&E(x[0])?{name:e,value:x[0],strValue:x[0],bypass:n}:null:{name:e,value:x,pfValue:C,strValue:T,bypass:n,units:w}}var N=function(){for(var r=0;r<d.enums.length;r++){var i=d.enums[r];if(i===t)return{name:e,value:t,strValue:""+t,bypass:n}}return null};if(d.number){var z,B="px";if(d.units&&(z=d.units),d.implicitUnits&&(B=d.implicitUnits),!d.unitless)if(l){var O="px|em"+(d.allowPercent?"|\\%":"");z&&(O=z);var L=t.match("^("+G+")("+O+")?$");L&&(t=L[1],z=L[2]||B)}else z&&!d.implicitUnits||(z=B);if(t=parseFloat(t),isNaN(t)&&void 0===d.enums)return null;if(isNaN(t)&&void 0!==d.enums)return t=o,N();if(d.integer&&!D(t))return null;if(void 0!==d.min&&(t<d.min||d.strictMin&&t===d.min)||void 0!==d.max&&(t>d.max||d.strictMax&&t===d.max))return null;var A={name:e,value:t,strValue:""+t+(z||""),units:z,bypass:n};return d.unitless||"px"!==z&&"em"!==z?A.pfValue=t:A.pfValue="px"!==z&&z?this.getEmSizeInPixels()*t:t,"ms"!==z&&"s"!==z||(A.pfValue="ms"===z?t:1e3*t),"deg"!==z&&"rad"!==z||(A.pfValue="rad"===z?t:bt(t)),"%"===z&&(A.pfValue=t/100),A}if(d.propList){var I=[],R=""+t;if("none"===R);else{for(var F=R.split(/\s*,\s*|\s+/),V=0;V<F.length;V++){var j=F[V].trim();i.properties[j]?I.push(j):Ne("`"+j+"` is not a valid property name")}if(0===I.length)return null}return{name:e,value:I,strValue:0===I.length?"none":I.join(" "),bypass:n}}if(d.color){var X=oe(t);return X?{name:e,value:X,pfValue:X,strValue:"rgb("+X[0]+","+X[1]+","+X[2]+")",bypass:n}:null}if(d.regex||d.regexes){if(d.enums){var Y=N();if(Y)return Y}for(var H=d.regexes?d.regexes:[d.regex],W=0;W<H.length;W++){var $=new RegExp(H[W]),U=$.exec(t);if(U)return{name:e,value:d.singleRegexMatchValue?U[1]:U,strValue:""+t,bypass:n}}return null}return d.string?{name:e,value:""+t,strValue:""+t,bypass:n}:d.enums?N():null}},jo=function e(t){if(!(this instanceof e))return new e(t);B(t)?(this._private={cy:t,coreStyle:{}},this.length=0,this.resetToDefault()):Pe("A style must have a core reference")},qo=jo.prototype;qo.instanceString=function(){return"style"},qo.clear=function(){for(var e=0;e<this.length;e++)this[e]=void 0;this.length=0;var t=this._private;return t.newStyle=!0,this},qo.resetToDefault=function(){return this.clear(),this.addDefaultStylesheet(),this},qo.core=function(e){return this._private.coreStyle[e]||this.getDefaultProperty(e)},qo.selector=function(e){var t="core"===e?null:new yi(e),n=this.length++;return this[n]={selector:t,properties:[],mappedProperties:[],index:n},this},qo.css=function(){var e=this,t=arguments;if(1===t.length)for(var n=t[0],r=0;r<e.properties.length;r++){var i=e.properties[r],a=n[i.name];void 0===a&&(a=n[X(i.name)]),void 0!==a&&this.cssRule(i.name,a)}else 2===t.length&&this.cssRule(t[0],t[1]);return this},qo.style=qo.css,qo.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,n.name.match(/pie-(\d+)-background-size/)&&n.value&&(this._private.hasPie=!0),n.mapped&&this[r].mappedProperties.push(n);var i=!this[r].selector;i&&(this._private.coreStyle[n.name]=n)}return this},qo.append=function(e){return O(e)?e.appendToStyle(this):k(e)?this.appendFromJson(e):E(e)&&this.appendFromString(e),this},jo.fromJson=function(e,t){var n=new jo(e);return n.fromJson(t),n},jo.fromString=function(e,t){return new jo(e).fromString(t)},[No,Oo,Lo,Ao,Io,Ro,Fo,Vo].forEach(function(e){te(qo,e)}),jo.types=qo.types,jo.properties=qo.properties,jo.propertyGroups=qo.propertyGroups,jo.propertyGroupNames=qo.propertyGroupNames,jo.propertyGroupKeys=qo.propertyGroupKeys;var Xo={style:function(e){if(e){var t=this.setStyle(e);t.update()}return this._private.style},setStyle:function(e){var t=this._private;return O(e)?t.style=e.generateStyle(this):k(e)?t.style=jo.fromJson(this,e):E(e)?t.style=jo.fromString(this,e):t.style=jo(this),t.style}},Yo="single",Ho={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=Yo),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(E(a[0]))return e=a[0],o[e];if(C(a[0])){if(!this._private.panningEnabled)return this;n=a[0],r=n.x,i=n.y,S(r)&&(o.x=r),S(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||!S(t)||(o[e]=t),this.emit("pan viewport");break;default:break}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:C(e)&&(i=s[0],a=i.x,o=i.y,S(a)&&(l.x+=a),S(o)&&(l.y+=o),this.emit("pan viewport"));break;case 2:n=e,r=t,"x"!==n&&"y"!==n||!S(r)||(l[n]+=r),this.emit("pan viewport");break;default:break}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(S(e)&&void 0===t&&(t=e,e=void 0),this._private.panningEnabled&&this._private.zoomingEnabled){var n;if(E(e)){var r=e;e=this.$(r)}else if(R(e)){var i=e;n={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2},n.w=n.x2-n.x1,n.h=n.y2-n.y1}else M(e)||(e=this.mutableElements());if(!M(e)||!e.empty()){n=n||e.boundingBox();var a,o=this.width(),s=this.height();if(t=S(t)?t:0,!isNaN(o)&&!isNaN(s)&&o>0&&s>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0){a=Math.min((o-2*t)/n.w,(s-2*t)/n.h),a=a>this._private.maxZoom?this._private.maxZoom:a,a=a<this._private.minZoom?this._private.minZoom:a;var l={x:(o-a*(n.x1+n.x2))/2,y:(s-a*(n.y1+n.y2))/2};return{zoom:a,pan:l}}}}},zoomRange:function(e,t){var n=this._private;if(null==t){var r=e;e=r.min,t=r.max}return S(e)&&S(t)&&e<=t?(n.minZoom=e,n.maxZoom=t):S(e)&&void 0===t&&e<=n.maxZoom?n.minZoom=e:S(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),S(e)?n=e:C(e)&&(n=e.level,null!=e.position?t=ht(e.position,a,i):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||r.panningEnabled||(o=!0)),n=n>r.maxZoom?r.maxZoom:n,n=n<r.minZoom?r.minZoom:n,o||!S(n)||n===a||null!=t&&(!S(t.x)||!S(t.y)))return null;if(null!=t){var s=i,l=a,u=n,c={x:-u/l*(t.x-s.x)+t.x,y:-u/l*(t.y-s.y)+t.y};return{zoomed:!0,panned:!0,zoom:u,pan:c}}return{zoomed:!0,panned:!1,zoom:n,pan:i}},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):this},viewport:function(e){var t=this._private,n=!0,r=!0,i=[],a=!1,o=!1;if(!e)return this;if(S(e.zoom)||(n=!1),C(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;S(l.x)&&(t.pan.x=l.x,o=!1),S(l.y)&&(t.pan.y=l.y,o=!1),o||i.push("pan")}return i.length>0&&(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(E(e)){var n=e;e=this.mutableElements().filter(n)}else M(e)||(e=this.mutableElements());if(0!==e.length){var r=e.boundingBox(),i=this.width(),a=this.height();t=void 0===t?this._private.zoom:t;var o={x:(i-t*(r.x1+r.x2))/2,y:(a-t*(r.y1+r.y2))/2};return o}}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled?(this.viewport({pan:{x:0,y:0},zoom:1}),this):this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e=this._private,t=e.container;return e.sizeCache=e.sizeCache||(t?function(){var e=g.getComputedStyle(t),n=function(t){return parseFloat(e.getPropertyValue(t))};return{width:t.clientWidth-n("padding-left")-n("padding-right"),height:t.clientHeight-n("padding-top")-n("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}}};Ho.centre=Ho.center,Ho.autolockNodes=Ho.autolock,Ho.autoungrabifyNodes=Ho.autoungrabify;var Go={data:Xr.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0}),removeData:Xr.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0}),scratch:Xr.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0}),removeScratch:Xr.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0})};Go.attr=Go.data,Go.removeAttr=Go.removeData;var Wo=function(e){var t=this;e=te({},e);var n=e.container;n&&!P(n)&&P(n[0])&&(n=n[0]);var r=n?n._cyreg:null;r=r||{},r&&r.cy&&(r.cy.destroy(),r={});var i=r.readies=r.readies||[];n&&(n._cyreg=r),r.cy=t;var a=void 0!==g&&void 0!==n&&!e.headless,o=e;o.layout=te({name:a?"grid":"null"},o.layout),o.renderer=te({name:a?"canvas":"null"},o.renderer);var s=function(e,t,n){return void 0!==t?t:void 0!==n?n:e},l=this._private={container:n,ready:!1,options:o,elements:new oo(this),listeners:[],aniEles:new oo(this),data:{},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?a:o.styleEnabled,zoom:S(o.zoom)?o.zoom:1,pan:{x:C(o.pan)&&S(o.pan.x)?o.pan.x:0,y:C(o.pan)&&S(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});var u=function(e,t){var n=e.some(F);if(n)return Ir.all(e).then(t);t(e)};l.styleEnabled&&t.setStyle([]);var c=te({},o,o.renderer);t.initRenderer(c);var d=function(e,n,r){t.notifications(!1);var i=t.mutableElements();i.length>0&&i.remove(),null!=e&&(C(e)||k(e))&&t.add(e),t.one("layoutready",function(e){t.notifications(!0),t.emit(e),t.one("load",n),t.emitAndNotify("load")}).one("layoutstop",function(){t.one("done",r),t.emit("done")});var a=te({},t._private.options.layout);a.eles=t.elements(),t.layout(a).run()};u([o.style,o.elements],function(e){var n=e[0],a=e[1];l.styleEnabled&&t.style().append(n),d(a,function(){t.startAnimationLoop(),l.ready=!0,_(o.ready)&&t.on("ready",o.ready);for(var e=0;e<i.length;e++){var n=i[e];t.on("ready",n)}r&&(r.readies=[]),t.emit("ready")},o.done)})},$o=Wo.prototype;te($o,{instanceString:function(){return"core"},isReady:function(){return this._private.ready},destroyed:function(){return this._private.destroyed},ready:function(e){return this.isReady()?this.emitter().emit("ready",[],e):this.on("ready",e),this},destroy:function(){var e=this;if(!e.destroyed())return e.stopAnimationLoop(),e.destroyRenderer(),this.emit("destroy"),e._private.destroyed=!0,e},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){if(null!=e){var t=this,n=t._private,r=n.options;return!P(e)&&P(e[0])&&(e=e[0]),t.stopAnimationLoop(),t.destroyRenderer(),n.container=e,n.styleEnabled=!0,t.invalidateSize(),t.initRenderer(te({},r,r.renderer,{name:"null"===r.renderer.name?"canvas":r.renderer.name})),t.startAnimationLoop(),t.style(r.style),t.emit("mount"),t}},unmount:function(){var e=this;return e.stopAnimationLoop(),e.destroyRenderer(),e.initRenderer({name:"null"}),e.emit("unmount"),e},options:function(){return Be(this._private.options)},json:function(e){var t=this,n=t._private,r=t.mutableElements(),i=function(e){return t.getElementById(e.id())};if(C(e)){if(t.startBatch(),e.elements){var a={},o=function(e,n){for(var r=[],i=[],o=0;o<e.length;o++){var s=e[o],l=""+s.data.id,u=t.getElementById(l);a[l]=!0,0!==u.length?i.push({ele:u,json:s}):n?(s.group=n,r.push(s)):r.push(s)}t.add(r);for(var c=0;c<i.length;c++){var d=i[c],h=d.ele,p=d.json;h.json(p)}};if(k(e.elements))o(e.elements);else for(var s=["nodes","edges"],l=0;l<s.length;l++){var u=s[l],c=e.elements[u];k(c)&&o(c,u)}var d=t.collection();r.filter(function(e){return!a[e.id()]}).forEach(function(e){e.isParent()?d.merge(e):e.remove()}),d.forEach(function(e){return e.children().move({parent:null})}),d.forEach(function(e){return i(e).remove()})}e.style&&t.style(e.style),null!=e.zoom&&e.zoom!==n.zoom&&t.zoom(e.zoom),e.pan&&(e.pan.x===n.pan.x&&e.pan.y===n.pan.y||t.pan(e.pan)),e.data&&t.data(e.data);for(var h=["minZoom","maxZoom","zoomingEnabled","userZoomingEnabled","panningEnabled","userPanningEnabled","boxSelectionEnabled","autolock","autoungrabify","autounselectify"],p=0;p<h.length;p++){var f=h[p];null!=e[f]&&t[f](e[f])}return t.endBatch(),this}var g=!!e,v={};g?v.elements=this.elements().map(function(e){return e.json()}):(v.elements={},r.forEach(function(e){var t=e.group();v.elements[t]||(v.elements[t]=[]),v.elements[t].push(e.json())})),this._private.styleEnabled&&(v.style=t.style().json()),v.data=Be(t.data());var y=n.options;return v.zoomingEnabled=n.zoomingEnabled,v.userZoomingEnabled=n.userZoomingEnabled,v.zoom=n.zoom,v.minZoom=n.minZoom,v.maxZoom=n.maxZoom,v.panningEnabled=n.panningEnabled,v.userPanningEnabled=n.userPanningEnabled,v.pan=Be(n.pan),v.boxSelectionEnabled=n.boxSelectionEnabled,v.renderer=Be(y.renderer),v.hideEdgesOnViewport=y.hideEdgesOnViewport,v.textureOnViewport=y.textureOnViewport,v.wheelSensitivity=y.wheelSensitivity,v.motionBlur=y.motionBlur,v}}),$o.$id=$o.getElementById,[lo,wo,ko,Co,To,So,Po,Mo,Xo,Ho,Go].forEach(function(e){te($o,e)});var Uo={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}},Ko=function(e){return e.scratch("breadthfirst")},Zo=function(e,t){return e.scratch("breadthfirst",t)};function Qo(e){this.options=te({},Uo,e)}Qo.prototype.run=function(){var e,t=this.options,n=t,r=t.cy,i=n.eles,a=i.nodes().filter(function(e){return!e.isParent()}),o=i,s=n.directed,l=n.maximal||n.maximalAdjustments>0,u=Mt(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()});if(M(n.roots))e=n.roots;else if(k(n.roots)){for(var c=[],d=0;d<n.roots.length;d++){var h=n.roots[d],p=r.getElementById(h);c.push(p)}e=r.collection(c)}else if(E(n.roots))e=r.$(n.roots);else if(s)e=a.roots();else{var f=i.components();e=r.collection();for(var g=function(t){var n=f[t],r=n.maxDegree(!1),i=n.filter(function(e){return e.degree(!1)===r});e=e.add(i)},v=0;v<f.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),Zo(e,{index:n,depth:t})},x=function(e,t){var n=Ko(e),r=n.depth,i=n.index;y[r][i]=null,b(e,t)};o.bfs({roots:e,directed:n.directed,visit:function(e,t,n,r,i){var a=e[0],o=a.id();b(a,i),m[o]=!0}});for(var w=[],_=0;_<a.length;_++){var C=a[_];m[C.id()]||w.push(C)}var T=function(e){for(var t=y[e],n=0;n<t.length;n++){var r=t[n];null!=r?Zo(r,{depth:e,index:n}):(t.splice(n,1),n--)}},S=function(){for(var e=0;e<y.length;e++)T(e)},D=function(e,t){for(var n=Ko(e),r=e.incomers().filter(function(e){return e.isNode()&&i.has(e)}),a=-1,o=e.id(),s=0;s<r.length;s++){var l=r[s],u=Ko(l);a=Math.max(a,u.depth)}return n.depth<=a&&(t[o]?null:(x(e,a+1),t[o]=!0,!0))};if(s&&l){var P=[],N={},z=function(e){return P.push(e)},B=function(){return P.shift()};a.forEach(function(e){return P.push(e)});while(P.length>0){var O=B(),L=D(O,N);if(L)O.outgoers().filter(function(e){return e.isNode()&&i.has(e)}).forEach(z);else if(null===L){Ne("Detected double maximal shift for node `"+O.id()+"`.  Bailing maximal adjustment due to cycle.  Use `options.maximal: true` only on DAGs.");break}}}S();var A=0;if(n.avoidOverlap)for(var I=0;I<a.length;I++){var R=a[I],F=R.layoutDimensions(n),V=F.w,j=F.h;A=Math.max(A,V,j)}for(var q={},X=function(e){if(q[e.id()])return q[e.id()];for(var t=Ko(e).depth,n=e.neighborhood(),r=0,i=0,o=0;o<n.length;o++){var s=n[o];if(!s.isEdge()&&!s.isParent()&&a.has(s)){var l=Ko(s),u=l.index,c=l.depth;if(null!=u&&null!=c){var d=y[c].length;c<t&&(r+=u/(d-1),i++)}}}return i=Math.max(1,i),r/=i,0===i&&(r=0),q[e.id()]=r,r},Y=function(e,t){var n=X(e),r=X(t),i=n-r;return 0===i?J(e.id(),t.id()):i},H=0;H<y.length;H++)y[H].sort(Y),T(H);for(var G=[],W=0;W<w.length;W++)G.push(w[W]);y.unshift(G),S();for(var $=0,U=0;U<y.length;U++)$=Math.max(y[U].length,$);var K={x:u.x1+u.w/2,y:u.x1+u.h/2},Z=y.reduce(function(e,t){return Math.max(e,t.length)},0),Q=function(e){var t=Ko(e),r=t.depth,i=t.index,a=y[r].length,o=Math.max(u.w/((n.grid?Z:a)+1),A),s=Math.max(u.h/(y.length+1),A),l=Math.min(u.w/2/y.length,u.h/2/y.length);if(l=Math.max(l,A),n.circle){var c=l*r+l-(y.length>0&&y[0].length<=3?l/2:0),d=2*Math.PI/y[r].length*i;return 0===r&&1===y[0].length&&(c=1),{x:K.x+c*Math.cos(d),y:K.y+c*Math.sin(d)}}var h={x:K.x+(i+1-(a+1)/2)*o,y:(r+1)*s};return h};return a.layoutPositions(this,n,Q),this};var Jo={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,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 es(e){this.options=te({},Jo,e)}es.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,i=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,a=r.nodes().not(":parent");t.sort&&(a=a.sort(t.sort));for(var o,s=Mt(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),l={x:s.x1+s.w/2,y:s.y1+s.h/2},u=void 0===t.sweep?2*Math.PI-2*Math.PI/a.length:t.sweep,c=u/Math.max(1,a.length-1),d=0,h=0;h<a.length;h++){var p=a[h],f=p.layoutDimensions(t),g=f.w,v=f.h;d=Math.max(d,g,v)}if(o=S(t.radius)?t.radius:a.length<=1?0:Math.min(s.h,s.w)/2-d,a.length>1&&t.avoidOverlap){d*=1.75;var y=Math.cos(c)-Math.cos(0),m=Math.sin(c)-Math.sin(0),b=Math.sqrt(d*d/(y*y+m*m));o=Math.max(b,o)}var x=function(e,n){var r=t.startAngle+n*c*(i?1:-1),a=o*Math.cos(r),s=o*Math.sin(r),u={x:l.x+a,y:l.y+s};return u};return a.layoutPositions(this,t,x),this};var ts,ns={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 rs(e){this.options=te({},ns,e)}rs.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,a=i.nodes().not(":parent"),o=Mt(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},l=[],u=0,c=0;c<a.length;c++){var d=a[c],h=void 0;h=t.concentric(d),l.push({value:h,node:d}),d._private.scratch.concentric=h}a.updateStyle();for(var p=0;p<a.length;p++){var f=a[p],g=f.layoutDimensions(t);u=Math.max(u,g.w,g.h)}l.sort(function(e,t){return t.value-e.value});for(var v=t.levelWidth(a),y=[[]],m=y[0],b=0;b<l.length;b++){var x=l[b];if(m.length>0){var w=Math.abs(m[0].value-x.value);w>=v&&(m=[],y.push(m))}m.push(x)}var E=u+t.minNodeSpacing;if(!t.avoidOverlap){var _=y.length>0&&y[0].length>1,k=Math.min(o.w,o.h)/2-E,C=k/(y.length+_?1:0);E=Math.min(E,C)}for(var T=0,S=0;S<y.length;S++){var D=y[S],P=void 0===t.sweep?2*Math.PI-2*Math.PI/D.length:t.sweep,M=D.dTheta=P/Math.max(1,D.length-1);if(D.length>1&&t.avoidOverlap){var N=Math.cos(M)-Math.cos(0),z=Math.sin(M)-Math.sin(0),B=Math.sqrt(E*E/(N*N+z*z));T=Math.max(B,T)}D.r=T,T+=E}if(t.equidistant){for(var O=0,L=0,A=0;A<y.length;A++){var I=y[A],R=I.r-L;O=Math.max(O,R)}L=0;for(var F=0;F<y.length;F++){var V=y[F];0===F&&(L=V.r),V.r=L,L+=O}}for(var j={},q=0;q<y.length;q++)for(var X=y[q],Y=X.dTheta,H=X.r,G=0;G<X.length;G++){var W=X[G],$=t.startAngle+(n?1:-1)*Y*G,U={x:s.x+H*Math.cos($),y:s.y+H*Math.sin($)};j[W.node.id()]=U}return a.layoutPositions(this,t,function(e){var t=e.id();return j[t]}),this};var is={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:!1,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};function as(e){this.options=te({},is,e),this.options.layout=this}as.prototype.run=function(){var e=this.options,t=e.cy,n=this;n.stopped=!1,!0!==e.animate&&!1!==e.animate||n.emit({type:"layoutstart",layout:n}),ts=!0===e.debug;var r=ss(t,n,e);ts&&os(r),e.randomize&&cs(r,t);var i=fe(),a=function(){hs(r,t,e),!0===e.fit&&t.fit(e.padding)},o=function(t){return!(n.stopped||t>=e.numIter)&&(ps(r,e,t),r.temperature=r.temperature*e.coolingFactor,!(r.temperature<e.minTemp))},s=function(){if(!0===e.animate||!1===e.animate)a(),n.one("layoutstop",e.stop),n.emit({type:"layoutstop",layout:n});else{var t=e.eles.nodes(),i=ds(r,e,t);t.layoutPositions(n,e,i)}},l=0,u=!0;if(!0===e.animate){var c=function t(){var n=0;while(u&&n<e.refresh)u=o(l),l++,n++;if(u){var c=fe();c-i>=e.animationThreshold&&a(),pe(t)}else Cs(r,e),s()};c()}else{while(u)u=o(l),l++;Cs(r,e),s()}return this},as.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},as.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var os,ss=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:Mt(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++){var d=u[c];s[d.id()]=l}for(l=0;l<a.nodeSize;l++){var h=i[l],p=h.layoutDimensions(n),f={};f.isLocked=h.locked(),f.id=h.data("id"),f.parentId=h.data("parent"),f.cmptId=s[h.id()],f.children=[],f.positionX=h.position("x"),f.positionY=h.position("y"),f.offsetX=0,f.offsetY=0,f.height=p.w,f.width=p.h,f.maxX=f.positionX+f.width/2,f.minX=f.positionX-f.width/2,f.maxY=f.positionY+f.height/2,f.minY=f.positionY-f.height/2,f.padLeft=parseFloat(h.style("padding")),f.padRight=parseFloat(h.style("padding")),f.padTop=parseFloat(h.style("padding")),f.padBottom=parseFloat(h.style("padding")),f.nodeRepulsion=_(n.nodeRepulsion)?n.nodeRepulsion(h):n.nodeRepulsion,a.layoutNodes.push(f),a.idToIndex[f.id]=l}var g=[],v=0,y=-1,m=[];for(l=0;l<a.nodeSize;l++){h=a.layoutNodes[l];var b=h.parentId;null!=b?a.layoutNodes[a.idToIndex[b]].children.push(h.id):(g[++y]=h.id,m.push(h.id))}a.graphSet.push(m);while(v<=y){var x=g[v++],w=a.idToIndex[x],E=(d=a.layoutNodes[w],d.children);if(E.length>0){a.graphSet.push(E);for(l=0;l<E.length;l++)g[++y]=E[l]}}for(l=0;l<a.graphSet.length;l++){var k=a.graphSet[l];for(c=0;c<k.length;c++){var C=a.idToIndex[k[c]];a.indexToGraph[C]=l}}for(l=0;l<a.edgeSize;l++){var T=r[l],S={};S.id=T.data("id"),S.sourceId=T.data("source"),S.targetId=T.data("target");var D=_(n.idealEdgeLength)?n.idealEdgeLength(T):n.idealEdgeLength,P=_(n.edgeElasticity)?n.edgeElasticity(T):n.edgeElasticity,M=a.idToIndex[S.sourceId],N=a.idToIndex[S.targetId],z=a.indexToGraph[M],B=a.indexToGraph[N];if(z!=B){var O=ls(S.sourceId,S.targetId,a),L=a.graphSet[O],A=0;f=a.layoutNodes[M];while(-1===L.indexOf(f.id))f=a.layoutNodes[a.idToIndex[f.parentId]],A++;f=a.layoutNodes[N];while(-1===L.indexOf(f.id))f=a.layoutNodes[a.idToIndex[f.parentId]],A++;D*=A*n.nestingFactor}S.idealLength=D,S.elasticity=P,a.layoutEdges.push(S)}return a},ls=function(e,t,n){var r=us(e,t,0,n);return 2>r.count?0:r.graph},us=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 d=i.indexToGraph[i.idToIndex[c[0]]],h=e(t,n,d,i);if(0!==h.count){if(1!==h.count)return h;if(o++,2===o)break}}}return{count:o,graph:r}},cs=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)}},ds=function(e,t,n){var r=e.boundingBox,i={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0};return t.boundingBox&&(n.forEach(function(t){var n=e.layoutNodes[e.idToIndex[t.data("id")]];i.x1=Math.min(i.x1,n.positionX),i.x2=Math.max(i.x2,n.positionX),i.y1=Math.min(i.y1,n.positionY),i.y2=Math.max(i.y2,n.positionY)}),i.w=i.x2-i.x1,i.h=i.y2-i.y1),function(n,a){var o=e.layoutNodes[e.idToIndex[n.data("id")]];if(t.boundingBox){var s=(o.positionX-i.x1)/i.w,l=(o.positionY-i.y1)/i.h;return{x:r.x1+s*r.w,y:r.y1+l*r.h}}return{x:o.positionX,y:o.positionY}}},hs=function(e,t,n){var r=n.layout,i=n.eles.nodes(),a=ds(e,n,i);i.positions(a),!0!==e.ready&&(e.ready=!0,r.one("layoutready",n.ready),r.emit({type:"layoutready",layout:this}))},ps=function(e,t,n){fs(e,t),bs(e,t),xs(e,t),ws(e,t),Es(e,t)},fs=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]]];vs(o,l,e,t)}},gs=function(e){return-e+2*e*Math.random()},vs=function(e,t,n,r){var i=e.cmptId,a=t.cmptId;if(i===a||n.isCompound){var o=t.positionX-e.positionX,s=t.positionY-e.positionY,l=1;0===o&&0===s&&(o=gs(l),s=gs(l));var u=ys(e,t,o,s);if(u>0)var c=r.nodeOverlap*u,d=Math.sqrt(o*o+s*s),h=c*o/d,p=c*s/d;else{var f=ms(e,o,s),g=ms(t,-1*o,-1*s),v=g.x-f.x,y=g.y-f.y,m=v*v+y*y;d=Math.sqrt(m),c=(e.nodeRepulsion+t.nodeRepulsion)/m,h=c*v/d,p=c*y/d}e.isLocked||(e.offsetX-=h,e.offsetY-=p),t.isLocked||(t.offsetX+=h,t.offsetY+=p)}},ys=function(e,t,n,r){if(n>0)var i=e.maxX-t.minX;else i=t.maxX-e.minX;if(r>0)var a=e.maxY-t.minY;else a=t.maxY-e.minY;return i>=0&&a>=0?Math.sqrt(i*i+a*a):0},ms=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,u):0===t&&0>n?(u.x=r,u.y=i+a/2,u):0<t&&-1*l<=s&&s<=l?(u.x=r+o/2,u.y=i+o*n/2/t,u):0>t&&-1*l<=s&&s<=l?(u.x=r-o/2,u.y=i-o*n/2/t,u):0<n&&(s<=-1*l||s>=l)?(u.x=r+a*t/2/n,u.y=i+a/2,u):0>n&&(s<=-1*l||s>=l)?(u.x=r-a*t/2/n,u.y=i-a/2,u):u},bs=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=ms(a,l,u),d=ms(s,-1*l,-1*u),h=d.x-c.x,p=d.y-c.y,f=Math.sqrt(h*h+p*p),g=Math.pow(r.idealLength-f,2)/r.elasticity;if(0!==f)var v=g*h/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)}}},xs=function(e,t){for(var n=1,r=0;r<e.graphSet.length;r++){var i=e.graphSet[r],a=i.length;if(0===r)var o=e.clientHeight/2,s=e.clientWidth/2;else{var l=e.layoutNodes[e.idToIndex[i[0]]],u=e.layoutNodes[e.idToIndex[l.parentId]];o=u.positionX,s=u.positionY}for(var c=0;c<a;c++){var d=e.layoutNodes[e.idToIndex[i[c]]];if(!d.isLocked){var h=o-d.positionX,p=s-d.positionY,f=Math.sqrt(h*h+p*p);if(f>n){var g=t.gravity*h/f,v=t.gravity*p/f;d.offsetX+=g,d.offsetY+=v}}}}},ws=function(e,t){var n=[],r=0,i=-1;n.push.apply(n,e.graphSet[0]),i+=e.graphSet[0].length;while(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,d=0;d<l.length;d++){var h=e.layoutNodes[e.idToIndex[l[d]]];h.offsetX+=u,h.offsetY+=c,n[++i]=l[d]}s.offsetX=0,s.offsetY=0}}},Es=function(e,t){for(var n=0;n<e.nodeSize;n++){var r=e.layoutNodes[n];0<r.children.length&&(r.maxX=void 0,r.minX=void 0,r.maxY=void 0,r.minY=void 0)}for(n=0;n<e.nodeSize;n++){r=e.layoutNodes[n];if(!(0<r.children.length||r.isLocked)){var i=_s(r.offsetX,r.offsetY,e.temperature);r.positionX+=i.x,r.positionY+=i.y,r.offsetX=0,r.offsetY=0,r.minX=r.positionX-r.width,r.maxX=r.positionX+r.width,r.minY=r.positionY-r.height,r.maxY=r.positionY+r.height,ks(r,e)}}for(n=0;n<e.nodeSize;n++){r=e.layoutNodes[n];0<r.children.length&&!r.isLocked&&(r.positionX=(r.maxX+r.minX)/2,r.positionY=(r.maxY+r.minY)/2,r.width=r.maxX-r.minX,r.height=r.maxY-r.minY)}},_s=function(e,t,n){var r=Math.sqrt(e*e+t*t);if(r>n)var i={x:n*e/r,y:n*t/r};else i={x:e,y:t};return i},ks=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}},Cs=function(e,t){for(var n=e.layoutNodes,r=[],i=0;i<n.length;i++){var a=n[i],o=a.cmptId,s=r[o]=r[o]||[];s.push(a)}var l=0;for(i=0;i<r.length;i++){var u=r[i];if(u){u.x1=1/0,u.x2=-1/0,u.y1=1/0,u.y2=-1/0;for(var c=0;c<u.length;c++){var d=u[c];u.x1=Math.min(u.x1,d.positionX-d.width/2),u.x2=Math.max(u.x2,d.positionX+d.width/2),u.y1=Math.min(u.y1,d.positionY-d.height/2),u.y2=Math.max(u.y2,d.positionY+d.height/2)}u.w=u.x2-u.x1,u.h=u.y2-u.y1,l+=u.w*u.h}}r.sort(function(e,t){return t.w*t.h-e.w*e.h});var h=0,p=0,f=0,g=0,v=Math.sqrt(l)*e.clientWidth/e.clientHeight;for(i=0;i<r.length;i++){u=r[i];if(u){for(c=0;c<u.length;c++){d=u[c];d.isLocked||(d.positionX+=h,d.positionY+=p)}h+=u.w+t.componentSpacing,f+=u.w+t.componentSpacing,g=Math.max(g,u.h),f>v&&(p+=g+t.componentSpacing,h=0,f=0,g=0)}}},Ts={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,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 Ss(e){this.options=te({},Ts,e)}Ss.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,i=r.nodes().not(":parent");t.sort&&(i=i.sort(t.sort));var a=Mt(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(0===a.h||0===a.w)i.layoutPositions(this,t,function(e){return{x:a.x1,y:a.y1}});else{var o=i.size(),s=Math.sqrt(o*a.h/a.w),l=Math.round(s),u=Math.round(a.w/a.h*s),c=function(e){if(null==e)return Math.min(l,u);var t=Math.min(l,u);t==l?l=e:u=e},d=function(e){if(null==e)return Math.max(l,u);var t=Math.max(l,u);t==l?l=e:u=e},h=t.rows,p=null!=t.cols?t.cols:t.columns;if(null!=h&&null!=p)l=h,u=p;else if(null!=h&&null==p)l=h,u=Math.ceil(o/l);else if(null==h&&null!=p)u=p,l=Math.ceil(o/u);else if(u*l>o){var f=c(),g=d();(f-1)*g>=o?c(f-1):(g-1)*f>=o&&d(g-1)}else while(u*l<o){var v=c(),y=d();(y+1)*v>=o?d(y+1):c(v+1)}var m=a.w/u,b=a.h/l;if(t.condense&&(m=0,b=0),t.avoidOverlap)for(var x=0;x<i.length;x++){var w=i[x],E=w._private.position;null!=E.x&&null!=E.y||(E.x=0,E.y=0);var _=w.layoutDimensions(t),k=t.avoidOverlapPadding,C=_.w+k,T=_.h+k;m=Math.max(m,C),b=Math.max(b,T)}for(var S={},D=function(e,t){return!!S["c-"+e+"-"+t]},P=function(e,t){S["c-"+e+"-"+t]=!0},M=0,N=0,z=function(){N++,N>=u&&(N=0,M++)},B={},O=0;O<i.length;O++){var L=i[O],A=t.position(L);if(A&&(void 0!==A.row||void 0!==A.col)){var I={row:A.row,col:A.col};if(void 0===I.col){I.col=0;while(D(I.row,I.col))I.col++}else if(void 0===I.row){I.row=0;while(D(I.row,I.col))I.row++}B[L.id()]=I,P(I.row,I.col)}}var R=function(e,t){var n,r;if(e.locked()||e.isParent())return!1;var i=B[e.id()];if(i)n=i.col*m+m/2+a.x1,r=i.row*b+b/2+a.y1;else{while(D(M,N))z();n=N*m+m/2+a.x1,r=M*b+b/2+a.y1,P(M,N),z()}return{x:n,y:r}};i.layoutPositions(this,t,R)}return this};var Ds={ready:function(){},stop:function(){}};function Ps(e){this.options=te({},Ds,e)}Ps.prototype.run=function(){var e=this.options,t=e.eles,n=this;e.cy;return n.emit("layoutstart"),t.nodes().positions(function(){return{x:0,y:0}}),n.one("layoutready",e.ready),n.emit("layoutready"),n.one("layoutstop",e.stop),n.emit("layoutstop"),this},Ps.prototype.stop=function(){return this};var Ms={positions:void 0,zoom:void 0,pan:void 0,fit:!0,padding:30,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 Ns(e){this.options=te({},Ms,e)}Ns.prototype.run=function(){var e=this.options,t=e.eles,n=t.nodes(),r=_(e.positions);function i(t){if(null==e.positions)return dt(t.position());if(r)return e.positions(t);var n=e.positions[t._private.data.id];return null==n?null:n}return n.layoutPositions(this,e,function(e,t){var n=i(e);return!e.locked()&&null!=n&&n}),this};var zs={fit:!0,padding:30,boundingBox: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 Bs(e){this.options=te({},zs,e)}Bs.prototype.run=function(){var e=this.options,t=e.cy,n=e.eles,r=n.nodes().not(":parent"),i=Mt(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()}),a=function(e,t){return{x:i.x1+Math.round(Math.random()*i.w),y:i.y1+Math.round(Math.random()*i.h)}};return r.layoutPositions(this,e,a),this};var Os=[{name:"breadthfirst",impl:Qo},{name:"circle",impl:es},{name:"concentric",impl:rs},{name:"cose",impl:as},{name:"grid",impl:Ss},{name:"null",impl:Ps},{name:"preset",impl:Ns},{name:"random",impl:Bs}];function Ls(e){this.options=e,this.notifications=0}var As=function(){};Ls.prototype={recalculateRenderedStyle:As,notify:function(){this.notifications++},init:As,isHeadless:function(){return!0}};var Is={arrowShapeWidth:.3,registerArrowShapes:function(){var e=this.arrowShapes={},t=this,n=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,d=s<=e&&e<=l&&u<=t&&t<=c;return d},r=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),s=a*n,l=o*n,u=s+i.x,c=l+i.y;return{x:u,y:c}},i=function(e,t,n,i){for(var a=[],o=0;o<e.length;o+=2){var s=e[o],l=e[o+1];a.push(r(s,l,t,n,i))}return a},a=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r.x,r.y)}return t},o=function(e){return e.pstyle("width").pfValue*e.pstyle("arrow-scale").pfValue*2},s=function(r,s){E(s)&&(s=e[s]),e[r]=te({name:r,points:[-.15,-.3,.15,-.3,.15,.3,-.15,.3],collide:function(e,t,n,r,o,s){var l=a(i(this.points,n+2*s,r,o)),u=Ut(e,t,l);return u},roughCollide:n,draw:function(e,n,r,a){var o=i(this.points,n,r,a);t.arrowShapeImpl("polygon")(e,o)},spacing:function(e){return 0},gap:o},s)};s("none",{collide:Te,roughCollide:Te,draw:De,spacing:Se,gap:Se}),s("triangle",{points:[-.15,-.3,0,0,.15,-.3]}),s("arrow","triangle"),s("triangle-backcurve",{points:e["triangle"].points,controlPoint:[0,-.15],roughCollide:n,draw:function(e,n,a,o,s){var l=i(this.points,n,a,o),u=this.controlPoint,c=r(u[0],u[1],n,a,o);t.arrowShapeImpl(this.name)(e,l,c)},gap:function(e){return.8*o(e)}}),s("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,o,s,l){var u=a(i(this.points,n+2*l,r,o)),c=a(i(this.pointsTee,n+2*l,r,o)),d=Ut(e,t,u)||Ut(e,t,c);return d},draw:function(e,n,r,a,o){var s=i(this.points,n,r,a),l=i(this.pointsTee,n,r,a);t.arrowShapeImpl(this.name)(e,s,l)}}),s("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,i=3,a=5;return n[i]=n[i]-r,n[a]=n[a]-r,n},collide:function(e,t,n,r,o,s,l){var u=a(i(this.points,n+2*l,r,o)),c=a(i(this.crossLinePts(n,s),n+2*l,r,o)),d=Ut(e,t,u)||Ut(e,t,c);return d},draw:function(e,n,r,a,o){var s=i(this.points,n,r,a),l=i(this.crossLinePts(n,o),n,r,a);t.arrowShapeImpl(this.name)(e,s,l)}}),s("vee",{points:[-.15,-.3,0,0,.15,-.3,0,-.15],gap:function(e){return.525*o(e)}}),s("circle",{radius:.15,collide:function(e,t,n,r,i,a,o){var s=i,l=Math.pow(s.x-e,2)+Math.pow(s.y-t,2)<=Math.pow((n+2*o)*this.radius,2);return l},draw:function(e,n,r,i,a){t.arrowShapeImpl(this.name)(e,i.x,i.y,this.radius*n)},spacing:function(e){return t.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.radius}}),s("tee",{points:[-.15,0,-.15,-.1,.15,-.1,.15,0],spacing:function(e){return 1},gap:function(e){return 1}}),s("square",{points:[-.15,0,.15,0,.15,-.3,-.15,-.3]}),s("diamond",{points:[-.15,-.15,0,-.3,.15,-.15,0,0],gap:function(e){return e.pstyle("width").pfValue*e.pstyle("arrow-scale").value}}),s("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}})}},Rs={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(),u=((e-i)/o-s.x)/l,c=((t-a)/o-s.y)/l;return[u,c]},findContainerClientCoords:function(){if(this.containerBB)return this.containerBB;var e=this.container,t=e.getBoundingClientRect(),n=g.getComputedStyle(e),r=function(e){return parseFloat(n.getPropertyValue(e))},i={left:r("padding-left"),right:r("padding-right"),top:r("padding-top"),bottom:r("padding-bottom")},a={left:r("border-left-width"),right:r("border-right-width"),top:r("border-top-width"),bottom:r("border-bottom-width")},o=e.clientWidth,s=e.clientHeight,l=i.left+i.right,u=i.top+i.bottom,c=a.left+a.right,d=t.width/(o+c),h=o-l,p=s-u,f=t.left+i.left+a.left,v=t.top+i.top+a.top;return this.containerBB=[f,v,h,p,d]},invalidateContainerClientCoordsCache:function(){this.containerBB=null},findNearestElement:function(e,t,n,r){return this.findNearestElements(e,t,n,r)[0]},findNearestElements:function(e,t,n,r){var i,a,o=this,s=this,l=s.getCachedZSortedEles(),u=[],c=s.cy.zoom(),d=s.cy.hasCompoundNodes(),h=(r?24:8)/c,p=(r?8:2)/c,f=(r?8:2)/c,g=1/0;function v(e,t){if(e.isNode()){if(a)return;a=e,u.push(e)}if(e.isEdge()&&(null==t||t<g))if(i){if(i.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value&&i.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value)for(var n=0;n<u.length;n++)if(u[n].isEdge()){u[n]=e,i=e,g=null!=t?t:g;break}}else u.push(e),i=e,g=null!=t?t:g}function y(n){var r=n.outerWidth()+2*p,i=n.outerHeight()+2*p,a=r/2,l=i/2,u=n.position();if(u.x-a<=e&&e<=u.x+a&&u.y-l<=t&&t<=u.y+l){var c=s.nodeShapes[o.getNodeShape(n)];if(c.checkPoint(e,t,0,r,i,u.x,u.y))return v(n,0),!0}}function m(n){var r,i=n._private,a=i.rscratch,l=n.pstyle("width").pfValue,c=n.pstyle("arrow-scale").value,p=l/2+h,f=p*p,g=2*p,m=i.source,b=i.target;if("segments"===a.edgeType||"straight"===a.edgeType||"haystack"===a.edgeType){for(var x=a.allpts,w=0;w+3<x.length;w+=2)if(Xt(e,t,x[w],x[w+1],x[w+2],x[w+3],g)&&f>(r=$t(e,t,x[w],x[w+1],x[w+2],x[w+3])))return v(n,r),!0}else if("bezier"===a.edgeType||"multibezier"===a.edgeType||"self"===a.edgeType||"compound"===a.edgeType)for(x=a.allpts,w=0;w+5<a.allpts.length;w+=4)if(Yt(e,t,x[w],x[w+1],x[w+2],x[w+3],x[w+4],x[w+5],g)&&f>(r=Wt(e,t,x[w],x[w+1],x[w+2],x[w+3],x[w+4],x[w+5])))return v(n,r),!0;m=m||i.source,b=b||i.target;var E=o.getArrowWidth(l,c),_=[{name:"source",x:a.arrowStartX,y:a.arrowStartY,angle:a.srcArrowAngle},{name:"target",x:a.arrowEndX,y:a.arrowEndY,angle:a.tgtArrowAngle},{name:"mid-source",x:a.midX,y:a.midY,angle:a.midsrcArrowAngle},{name:"mid-target",x:a.midX,y:a.midY,angle:a.midtgtArrowAngle}];for(w=0;w<_.length;w++){var k=_[w],C=s.arrowShapes[n.pstyle(k.name+"-arrow-shape").value],T=n.pstyle("width").pfValue;if(C.roughCollide(e,t,E,k.angle,{x:k.x,y:k.y},T,h)&&C.collide(e,t,E,k.angle,{x:k.x,y:k.y},T,h))return v(n),!0}d&&u.length>0&&(y(m),y(b))}function b(e,t,n){return qe(e,t,n)}function x(n,r){var i,a=n._private,o=f;i=r?r+"-":"";var s=a.labelBounds[r||"main"],l=n.pstyle(i+"label").value,u="yes"===n.pstyle("text-events").strValue;if(u&&l){var c=a.rstyle,d=b(c,"labelX",r),h=b(c,"labelY",r),p=b(a.rscratch,"labelAngle",r),g=s.x1-o,y=s.x2+o,m=s.y1-o,x=s.y2+o;if(p){var w=Math.cos(p),E=Math.sin(p),_=function(e,t){return e-=d,t-=h,{x:e*w-t*E+d,y:e*E+t*w+h}},k=_(g,m),C=_(g,x),T=_(y,m),S=_(y,x),D=[k.x,k.y,T.x,T.y,S.x,S.y,C.x,C.y];if(Ut(e,t,D))return v(n),!0}else if(Ft(s,e,t))return v(n),!0}}n&&(l=l.interactive);for(var w=l.length-1;w>=0;w--){var E=l[w];E.isNode()?y(E)||x(E):m(E)||x(E)||x(E,"source")||x(E,"target")}return u},getAllInBox:function(e,t,n,r){var i=this.getCachedZSortedEles().interactive,a=[],o=Math.min(e,n),s=Math.max(e,n),l=Math.min(t,r),u=Math.max(t,r);e=o,n=s,t=l,r=u;for(var c=Mt({x1:e,y1:t,x2:n,y2:r}),d=0;d<i.length;d++){var h=i[d];if(h.isNode()){var p=h,f=p.boundingBox({includeNodes:!0,includeEdges:!1,includeLabels:!1});Rt(c,f)&&!jt(f,c)&&a.push(p)}else{var g=h,v=g._private,y=v.rscratch;if(null!=y.startX&&null!=y.startY&&!Ft(c,y.startX,y.startY))continue;if(null!=y.endX&&null!=y.endY&&!Ft(c,y.endX,y.endY))continue;if("bezier"===y.edgeType||"multibezier"===y.edgeType||"self"===y.edgeType||"compound"===y.edgeType||"segments"===y.edgeType||"haystack"===y.edgeType){for(var m=v.rstyle.bezierPts||v.rstyle.linePts||v.rstyle.haystackPts,b=!0,x=0;x<m.length;x++)if(!Vt(c,m[x])){b=!1;break}b&&a.push(g)}else"haystack"!==y.edgeType&&"straight"!==y.edgeType||a.push(g)}}return a}},Fs={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,d="segments"===s.edgeType,h="compound"===s.edgeType,p="self"===s.edgeType;if(l?(r=s.haystackPts[0],i=s.haystackPts[1],a=s.haystackPts[2],o=s.haystackPts[3]):(r=s.arrowStartX,i=s.arrowStartY,a=s.arrowEndX,o=s.arrowEndY),y=s.midX,m=s.midY,d)t=r-s.segpts[0],n=i-s.segpts[1];else if(c||h||p||u){var f=s.allpts,g=Tt(f[0],f[2],f[4],.1),v=Tt(f[1],f[3],f[5],.1);t=r-g,n=i-v}else t=r-y,n=i-m;s.srcArrowAngle=xt(t,n);var y=s.midX,m=s.midY;if(l&&(y=(r+a)/2,m=(i+o)/2),t=a-r,n=o-i,d){f=s.allpts;if(f.length/2%2===0){var b=f.length/2,x=b-2;t=f[b]-f[x],n=f[b+1]-f[x+1]}else{b=f.length/2-1,x=b-2;var w=b+2;t=f[b]-f[x],n=f[b+1]-f[x+1]}}else if(c||h||p){f=s.allpts;var E,_,k,C,T=s.ctrlpts;if(T.length/2%2===0){var S=f.length/2-1,D=S+2,P=D+2;E=Tt(f[S],f[D],f[P],0),_=Tt(f[S+1],f[D+1],f[P+1],0),k=Tt(f[S],f[D],f[P],1e-4),C=Tt(f[S+1],f[D+1],f[P+1],1e-4)}else{D=f.length/2-1,S=D-2,P=D+2;E=Tt(f[S],f[D],f[P],.4999),_=Tt(f[S+1],f[D+1],f[P+1],.4999),k=Tt(f[S],f[D],f[P],.5),C=Tt(f[S+1],f[D+1],f[P+1],.5)}t=k-E,n=C-_}if(s.midtgtArrowAngle=xt(t,n),s.midDispX=t,s.midDispY=n,t*=-1,n*=-1,d){f=s.allpts;if(f.length/2%2===0);else{b=f.length/2-1,w=b+2;t=-(f[w]-f[b]),n=-(f[w+1]-f[b+1])}}if(s.midsrcArrowAngle=xt(t,n),d)t=a-s.segpts[s.segpts.length-2],n=o-s.segpts[s.segpts.length-1];else if(c||h||p||u){f=s.allpts;var M=f.length;g=Tt(f[M-6],f[M-4],f[M-2],.9),v=Tt(f[M-5],f[M-3],f[M-1],.9);t=a-g,n=o-v}else t=a-y,n=o-m;s.tgtArrowAngle=xt(t,n)}};Fs.getArrowWidth=Fs.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,r)};var Vs={};function js(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}}Vs.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(),d=s.width(),h=o.height(),p=s.height(),f=n.pstyle("haystack-radius").value,g=f/2;i.haystackPts=i.allpts=[i.source.x*c*g+l.x,i.source.y*h*g+l.y,i.target.x*d*g+u.x,i.target.y*p*g+u.y],i.midX=(i.allpts[0]+i.allpts[2])/2,i.midY=(i.allpts[1]+i.allpts[3])/2,i.edgeType="haystack",i.haystack=!0,this.storeEdgeProjections(n),this.calculateArrowAngles(n),this.recalculateEdgeLabelProjections(n),this.calculateLabelAngles(n)}},Vs.findSegmentsPoints=function(e,t){var n=e._private.rscratch,r=t.posPts,i=t.intersectionPts,a=t.vectorNormInverse,o=e.pstyle("edge-distances").value,s=e.pstyle("segment-weights"),l=e.pstyle("segment-distances"),u=Math.min(s.pfValue.length,l.pfValue.length);n.edgeType="segments",n.segpts=[];for(var c=0;c<u;c++){var d=s.pfValue[c],h=l.pfValue[c],p=1-d,f=d,g="node-position"===o?r:i,v={x:g.x1*p+g.x2*f,y:g.y1*p+g.y2*f};n.segpts.push(v.x+a.x*h,v.y+a.y*h)}},Vs.findLoopPoints=function(e,t,n,r){var i=e._private.rscratch,a=t.dirCounts,o=t.srcPos,s=e.pstyle("control-point-distances"),l=s?s.pfValue[0]:void 0,u=e.pstyle("loop-direction").pfValue,c=e.pstyle("loop-sweep").pfValue,d=e.pstyle("control-point-step-size").pfValue;i.edgeType="self";var h=n,p=d;r&&(h=0,p=l);var f=u-Math.PI/2,g=f-c/2,v=f+c/2,y=String(u+"_"+c);h=void 0===a[y]?a[y]=0:++a[y],i.ctrlpts=[o.x+1.4*Math.cos(g)*p*(h/3+1),o.y+1.4*Math.sin(g)*p*(h/3+1),o.x+1.4*Math.cos(v)*p*(h/3+1),o.y+1.4*Math.sin(v)*p*(h/3+1)]},Vs.findCompoundLoopPoints=function(e,t,n,r){var i=e._private.rscratch;i.edgeType="compound";var a=t.srcPos,o=t.tgtPos,s=t.srcW,l=t.srcH,u=t.tgtW,c=t.tgtH,d=e.pstyle("control-point-step-size").pfValue,h=e.pstyle("control-point-distances"),p=h?h.pfValue[0]:void 0,f=n,g=d;r&&(f=0,g=p);var v=50,y={x:a.x-s/2,y:a.y-l/2},m={x:o.x-u/2,y:o.y-c/2},b={x:Math.min(y.x,m.x),y:Math.min(y.y,m.y)},x=.5,w=Math.max(x,Math.log(.01*s)),E=Math.max(x,Math.log(.01*u));i.ctrlpts=[b.x,b.y-(1+Math.pow(v,1.12)/100)*g*(f/3+1)*w,b.x-(1+Math.pow(v,1.12)/100)*g*(f/3+1)*E,b.y]},Vs.findStraightEdgePoints=function(e){e._private.rscratch.edgeType="straight"},Vs.findBezierPoints=function(e,t,n,r,i){var a=e._private.rscratch,o=t.vectorNormInverse,s=t.posPts,l=t.intersectionPts,u=e.pstyle("edge-distances").value,c=e.pstyle("control-point-step-size").pfValue,d=e.pstyle("control-point-distances"),h=e.pstyle("control-point-weights"),p=d&&h?Math.min(d.value.length,h.value.length):1,f=d?d.pfValue[0]:void 0,g=h.value[0],v=r;a.edgeType=v?"multibezier":"bezier",a.ctrlpts=[];for(var y=0;y<p;y++){var m=(.5-t.eles.length/2+n)*c*(i?-1:1),b=void 0,x=Et(m);v&&(f=d?d.pfValue[y]:c,g=h.value[y]),b=r?f:void 0!==f?x*f:void 0;var w=void 0!==b?b:m,E=1-g,_=g,k="node-position"===u?s:l,C={x:k.x1*E+k.x2*_,y:k.y1*E+k.y2*_};a.ctrlpts.push(C.x+o.x*w,C.y+o.y*w)}},Vs.findTaxiPoints=function(e,t){var n=e._private.rscratch;n.edgeType="segments";var r="vertical",i="horizontal",a="leftward",o="rightward",s="downward",l="upward",u="auto",c=t.posPts,d=t.srcW,h=t.srcH,p=t.tgtW,f=t.tgtH,g=e.pstyle("edge-distances").value,v="node-position"!==g,y=e.pstyle("taxi-direction").value,m=y,b=e.pstyle("taxi-turn"),x=b.pfValue,w=e.pstyle("taxi-turn-min-distance").pfValue,E="%"===b.units,_=v?(d+p)/2:0,k=v?(h+f)/2:0,C=c.x2-c.x1,T=c.y2-c.y1,S=function(e,t){return e>0?Math.max(e-t,0):Math.min(e+t,0)},D=S(C,_),P=S(T,k),M=!1;y===u?y=Math.abs(D)>Math.abs(P)?i:r:y===l||y===s?(y=r,M=!0):y!==a&&y!==o||(y=i,M=!0);var N=y===r,z=N?P:D,B=N?T:C,O=Et(B),L=!1;M&&E||!(m===s&&B<0||m===l&&B>0||m===a&&B>0||m===o&&B<0)||(O*=-1,z=O*Math.abs(z),L=!0);var A=E?x*z:x*O,I=function(e){return Math.abs(e)<w||Math.abs(e)>=Math.abs(z)},R=I(A),F=I(z-A),V=R||F;if(V&&!L)if(N){var j=Math.abs(B)<=h/2,q=Math.abs(C)<=p/2;if(j){var X=(c.x1+c.x2)/2,Y=c.y1,H=c.y2;n.segpts=[X,Y,X,H]}else if(q){var G=(c.y1+c.y2)/2,W=c.x1,$=c.x2;n.segpts=[W,G,$,G]}else n.segpts=[c.x1,c.y2]}else{var U=Math.abs(B)<=d/2,K=Math.abs(T)<=f/2;if(U){var Z=(c.y1+c.y2)/2,Q=c.x1,J=c.x2;n.segpts=[Q,Z,J,Z]}else if(K){var ee=(c.x1+c.x2)/2,te=c.y1,ne=c.y2;n.segpts=[ee,te,ee,ne]}else n.segpts=[c.x2,c.y1]}else if(N){var re=c.y1+A+(v?h/2*O:0),ie=c.x1,ae=c.x2;n.segpts=[ie,re,ae,re]}else{var oe=c.x1+A+(v?d/2*O:0),se=c.y1,le=c.y2;n.segpts=[oe,se,oe,le]}},Vs.tryToCorrectInvalidPoints=function(e,t){var n=e._private.rscratch;if("bezier"===n.edgeType){var r=t.srcPos,i=t.tgtPos,a=t.srcW,o=t.srcH,s=t.tgtW,l=t.tgtH,u=t.srcShape,c=t.tgtShape,d=!S(n.startX)||!S(n.startY),h=!S(n.arrowStartX)||!S(n.arrowStartY),p=!S(n.endX)||!S(n.endY),f=!S(n.arrowEndX)||!S(n.arrowEndY),g=3,v=this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth,y=g*v,m=_t({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),b=m<y,x=_t({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.endX,y:n.endY}),w=x<y,E=!1;if(d||h||b){E=!0;var _={x:n.ctrlpts[0]-r.x,y:n.ctrlpts[1]-r.y},k=Math.sqrt(_.x*_.x+_.y*_.y),C={x:_.x/k,y:_.y/k},T=Math.max(a,o),D={x:n.ctrlpts[0]+2*C.x*T,y:n.ctrlpts[1]+2*C.y*T},P=u.intersectLine(r.x,r.y,a,o,D.x,D.y,0);b?(n.ctrlpts[0]=n.ctrlpts[0]+C.x*(y-m),n.ctrlpts[1]=n.ctrlpts[1]+C.y*(y-m)):(n.ctrlpts[0]=P[0]+C.x*y,n.ctrlpts[1]=P[1]+C.y*y)}if(p||f||w){E=!0;var M={x:n.ctrlpts[0]-i.x,y:n.ctrlpts[1]-i.y},N=Math.sqrt(M.x*M.x+M.y*M.y),z={x:M.x/N,y:M.y/N},B=Math.max(a,o),O={x:n.ctrlpts[0]+2*z.x*B,y:n.ctrlpts[1]+2*z.y*B},L=c.intersectLine(i.x,i.y,s,l,O.x,O.y,0);w?(n.ctrlpts[0]=n.ctrlpts[0]+z.x*(y-x),n.ctrlpts[1]=n.ctrlpts[1]+z.y*(y-x)):(n.ctrlpts[0]=L[0]+z.x*y,n.ctrlpts[1]=L[1]+z.y*y)}E&&this.findEndpoints(e)}},Vs.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,i;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,i=.5,t.midX=Tt(t.allpts[r],t.allpts[r+2],t.allpts[r+4],i),t.midY=Tt(t.allpts[r+1],t.allpts[r+3],t.allpts[r+5],i))}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 a=t.segpts.length/2,o=a-2;t.midX=(t.segpts[o]+t.segpts[a])/2,t.midY=(t.segpts[o+1]+t.segpts[a+1])/2}else{var s=t.segpts.length/2-1;t.midX=t.segpts[s],t.midY=t.segpts[s+1]}},Vs.checkForInvalidEdgeWarning=function(e){var t=e[0]._private.rscratch;t.nodesOverlap||S(t.startX)&&S(t.startY)&&S(t.endX)&&S(t.endY)?t.loggedErr=!1:t.loggedErr||(t.loggedErr=!0,Ne("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."))},Vs.findEdgeControlPoints=function(e){var t=this;if(e&&0!==e.length){for(var n=this,r=n.cy,i=r.hasCompoundNodes(),a=new He,o=[],s=[],l=0;l<e.length;l++){var u=e[l],c=u._private,d=u.pstyle("curve-style").value;if(!u.removed()&&u.takesUpSpace())if("haystack"!==d){var h="unbundled-bezier"===d||"segments"===d||"straight"===d||"taxi"===d,p="unbundled-bezier"===d||"bezier"===d,f=c.source.poolIndex(),g=c.target.poolIndex(),v=(h?-1:1)*ye([f,g].sort()),y=v,m=a.get(y);null==m&&(m={eles:[]},a.set(y,m),o.push(y)),m.eles.push(u),h&&(m.hasUnbundled=!0),p&&(m.hasBezier=!0)}else s.push(u)}for(var b=function(e){var r=o[e],s=a.get(r),l=void 0;if(!s.hasUnbundled){var u=s.eles[0].parallelEdges().filter(function(e){return e.isBundledBezier()});Ve(s.eles),u.forEach(function(e){return s.eles.push(e)}),s.eles.sort(function(e,t){return e.poolIndex()-t.poolIndex()})}var c=s.eles[0],d=c.source(),h=c.target();if(d.poolIndex()>h.poolIndex()){var p=d;d=h,h=p}var f=s.srcPos=d.position(),g=s.tgtPos=h.position(),v=s.srcW=d.outerWidth(),y=s.srcH=d.outerHeight(),m=s.tgtW=h.outerWidth(),b=s.tgtH=h.outerHeight(),x=s.srcShape=n.nodeShapes[t.getNodeShape(d)],w=s.tgtShape=n.nodeShapes[t.getNodeShape(h)];s.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var E=0;E<s.eles.length;E++){var _=s.eles[E],k=_[0]._private.rscratch,C=_.pstyle("curve-style").value,T="unbundled-bezier"===C||"segments"===C||"taxi"===C,D=!d.same(_.source());if(!s.calculatedIntersection&&d!==h&&(s.hasBezier||s.hasUnbundled)){s.calculatedIntersection=!0;var P=x.intersectLine(f.x,f.y,v,y,g.x,g.y,0),M=s.srcIntn=P,N=w.intersectLine(g.x,g.y,m,b,f.x,f.y,0),z=s.tgtIntn=N,B=s.intersectionPts={x1:P[0],x2:N[0],y1:P[1],y2:N[1]},O=s.posPts={x1:f.x,x2:g.x,y1:f.y,y2:g.y},L=N[1]-P[1],A=N[0]-P[0],I=Math.sqrt(A*A+L*L),R=s.vector={x:A,y:L},F=s.vectorNorm={x:R.x/I,y:R.y/I},V={x:-F.y,y:F.x};s.nodesOverlap=!S(I)||w.checkPoint(P[0],P[1],0,m,b,g.x,g.y)||x.checkPoint(N[0],N[1],0,v,y,f.x,f.y),s.vectorNormInverse=V,l={nodesOverlap:s.nodesOverlap,dirCounts:s.dirCounts,calculatedIntersection:!0,hasBezier:s.hasBezier,hasUnbundled:s.hasUnbundled,eles:s.eles,srcPos:g,tgtPos:f,srcW:m,srcH:b,tgtW:v,tgtH:y,srcIntn:z,tgtIntn:M,srcShape:w,tgtShape:x,posPts:{x1:O.x2,y1:O.y2,x2:O.x1,y2:O.y1},intersectionPts:{x1:B.x2,y1:B.y2,x2:B.x1,y2:B.y1},vector:{x:-R.x,y:-R.y},vectorNorm:{x:-F.x,y:-F.y},vectorNormInverse:{x:-V.x,y:-V.y}}}var j=D?l:s;k.nodesOverlap=j.nodesOverlap,k.srcIntn=j.srcIntn,k.tgtIntn=j.tgtIntn,i&&(d.isParent()||d.isChild()||h.isParent()||h.isChild())&&(d.parents().anySame(h)||h.parents().anySame(d)||d.same(h))?t.findCompoundLoopPoints(_,j,E,T):d===h?t.findLoopPoints(_,j,E,T):"segments"===C?t.findSegmentsPoints(_,j):"taxi"===C?t.findTaxiPoints(_,j):"straight"===C||!T&&s.eles.length%2===1&&E===Math.floor(s.eles.length/2)?t.findStraightEdgePoints(_):t.findBezierPoints(_,j,E,T,D),t.findEndpoints(_),t.tryToCorrectInvalidPoints(_,j),t.checkForInvalidEdgeWarning(_),t.storeAllpts(_),t.storeEdgeProjections(_),t.calculateArrowAngles(_),t.recalculateEdgeLabelProjections(_),t.calculateLabelAngles(_)}},x=0;x<o.length;x++)b(x);this.findHaystackPoints(s)}},Vs.getSegmentPoints=function(e){var t=e[0]._private.rscratch,n=t.edgeType;if("segments"===n)return this.recalculateRenderedStyle(e),js(t.segpts)},Vs.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),js(t.ctrlpts)},Vs.getEdgeMidpoint=function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),{x:t.midX,y:t.midY}};var qs={manualEndptToPx:function(e,t){var n=this,r=e.position(),i=e.outerWidth(),a=e.outerHeight();if(2===t.value.length){var o=[t.pfValue[0],t.pfValue[1]];return"%"===t.units[0]&&(o[0]=o[0]*i),"%"===t.units[1]&&(o[1]=o[1]*a),o[0]+=r.x,o[1]+=r.y,o}var s=t.pfValue[0];s=-Math.PI/2+s;var l=2*Math.max(i,a),u=[r.x+Math.cos(s)*l,r.y+Math.sin(s)*l];return n.nodeShapes[this.getNodeShape(e)].intersectLine(r.x,r.y,i,a,u[0],u[1],0)},findEndpoints:function(e){var t,n,r,i,a,o=this,s=e.source()[0],l=e.target()[0],u=s.position(),c=l.position(),d=e.pstyle("target-arrow-shape").value,h=e.pstyle("source-arrow-shape").value,p=e.pstyle("target-distance-from-node").pfValue,f=e.pstyle("source-distance-from-node").pfValue,g=e.pstyle("curve-style").value,v=e._private.rscratch,y=v.edgeType,m="taxi"===g,b="self"===y||"compound"===y,x="bezier"===y||"multibezier"===y||b,w="bezier"!==y,E="straight"===y||"segments"===y,_="segments"===y,k=x||w||E,C=b||m,T=e.pstyle("source-endpoint"),D=C?"outside-to-node":T.value,P=e.pstyle("target-endpoint"),M=C?"outside-to-node":P.value;if(v.srcManEndpt=T,v.tgtManEndpt=P,x){var N=[v.ctrlpts[0],v.ctrlpts[1]],z=w?[v.ctrlpts[v.ctrlpts.length-2],v.ctrlpts[v.ctrlpts.length-1]]:N;n=z,r=N}else if(E){var B=_?v.segpts.slice(0,2):[c.x,c.y],O=_?v.segpts.slice(v.segpts.length-2):[u.x,u.y];n=O,r=B}if("inside-to-node"===M)t=[c.x,c.y];else if(P.units)t=this.manualEndptToPx(l,P);else if("outside-to-line"===M)t=v.tgtIntn;else if("outside-to-node"===M||"outside-to-node-or-label"===M?i=n:"outside-to-line"!==M&&"outside-to-line-or-label"!==M||(i=[u.x,u.y]),t=o.nodeShapes[this.getNodeShape(l)].intersectLine(c.x,c.y,l.outerWidth(),l.outerHeight(),i[0],i[1],0),"outside-to-node-or-label"===M||"outside-to-line-or-label"===M){var L=l._private.rscratch,A=L.labelWidth,I=L.labelHeight,R=L.labelX,F=L.labelY,V=l.pstyle("text-valign").value;"top"===V?F-=I/2:"bottom"===V&&(F+=I/2);var j=l.pstyle("text-halign").value;"left"===j?R-=A/2:"right"===j&&(R+=A/2);var q=o.nodeShapes["rectangle"].intersectLine(R,F,A,I,i[0],i[1],0),X=u,Y=kt(X,ft(t)),H=kt(X,ft(q));H<Y&&(t=q)}var G=on(t,n,o.arrowShapes[d].spacing(e)+p),W=on(t,n,o.arrowShapes[d].gap(e)+p);if(v.endX=W[0],v.endY=W[1],v.arrowEndX=G[0],v.arrowEndY=G[1],"inside-to-node"===D)t=[u.x,u.y];else if(T.units)t=this.manualEndptToPx(s,T);else if("outside-to-line"===D)t=v.srcIntn;else if("outside-to-node"===D||"outside-to-node-or-label"===D?a=r:"outside-to-line"!==D&&"outside-to-line-or-label"!==D||(a=[c.x,c.y]),t=o.nodeShapes[this.getNodeShape(s)].intersectLine(u.x,u.y,s.outerWidth(),s.outerHeight(),a[0],a[1],0),"outside-to-node-or-label"===D||"outside-to-line-or-label"===D){var $=s._private.rscratch,U=$.labelWidth,K=$.labelHeight,Z=$.labelX,Q=$.labelY,J=s.pstyle("text-valign").value;"top"===J?Q-=K/2:"bottom"===J&&(Q+=K/2);var ee=s.pstyle("text-halign").value;"left"===ee?Z-=U/2:"right"===ee&&(Z+=U/2);var te=o.nodeShapes["rectangle"].intersectLine(Z,Q,U,K,a[0],a[1],0),ne=c,re=kt(ne,ft(t)),ie=kt(ne,ft(te));ie<re&&(t=te)}var ae=on(t,r,o.arrowShapes[h].spacing(e)+f),oe=on(t,r,o.arrowShapes[h].gap(e)+f);v.startX=oe[0],v.startY=oe[1],v.arrowStartX=ae[0],v.arrowStartY=ae[1],k&&(S(v.startX)&&S(v.startY)&&S(v.endX)&&S(v.endY)?v.badLine=!1:v.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}}}},Xs={};function Ys(e,t,n){for(var r=function(e,t,n,r){return Tt(e,t,n,r)},i=t._private,a=i.rstyle.bezierPts,o=0;o<e.bezierProjPcts.length;o++){var s=e.bezierProjPcts[o];a.push({x:r(n[0],n[2],n[4],s),y:r(n[1],n[3],n[5],s)})}}Xs.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)Ys(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},Xs.recalculateEdgeProjections=function(e){this.findEdgeControlPoints(e)};var Hs={recalculateNodeLabelProjection:function(e){var t=e.pstyle("label").strValue;if(!A(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,d=i.rscratch,h=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}d.labelX=n,d.labelY=r,h.labelX=n,h.labelY=r,this.applyLabelDimensions(e)}}},Gs=function(e,t){var n=Math.atan(t/e);return 0===e&&n<0&&(n*=-1),n},Ws=function(e,t){var n=t.x-e.x,r=t.y-e.y;return Gs(n,r)},$s=function(e,t,n,r){var i=Pt(0,r-.001,1),a=Pt(0,r+.001,1),o=St(e,t,n,i),s=St(e,t,n,a);return Ws(o,s)};Hs.recalculateEdgeLabelProjections=function(e){var t,n=e._private,r=n.rscratch,i=this,a={mid:e.pstyle("label").strValue,source:e.pstyle("source-label").strValue,target:e.pstyle("target-label").strValue};if(a.mid||a.source||a.target){t={x:r.midX,y:r.midY};var o=function(e,t,r){Xe(n.rscratch,e,t,r),Xe(n.rstyle,e,t,r)};o("labelX",null,t.x),o("labelY",null,t.y);var s=Gs(r.midDispX,r.midDispY);o("labelAutoAngle",null,s);var l=function e(){if(e.cache)return e.cache;for(var t=[],a=0;a+5<r.allpts.length;a+=4){var o={x:r.allpts[a],y:r.allpts[a+1]},s={x:r.allpts[a+2],y:r.allpts[a+3]},l={x:r.allpts[a+4],y:r.allpts[a+5]};t.push({p0:o,p1:s,p2:l,startDist:0,length:0,segments:[]})}var u=n.rstyle.bezierPts,c=i.bezierProjPcts.length;function d(e,t,n,r,i){var a=_t(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(var h=0;h<t.length;h++){var p=t[h],f=t[h-1];f&&(p.startDist=f.startDist+f.length),d(p,p.p0,u[h*c],0,i.bezierProjPcts[0]);for(var g=0;g<c-1;g++)d(p,u[h*c+g],u[h*c+g+1],i.bezierProjPcts[g],i.bezierProjPcts[g+1]);d(p,u[h*c+c-1],p.p2,i.bezierProjPcts[c-1],1)}return e.cache=t},u=function(n){var i,s="source"===n;if(a[n]){var u=e.pstyle(n+"-text-offset").pfValue;switch(r.edgeType){case"self":case"compound":case"bezier":case"multibezier":for(var c,d=l(),h=0,p=0,f=0;f<d.length;f++){for(var g=d[s?f:d.length-1-f],v=0;v<g.segments.length;v++){var y=g.segments[s?v:g.segments.length-1-v],m=f===d.length-1&&v===g.segments.length-1;if(h=p,p+=y.length,p>=u||m){c={cp:g,segment:y};break}}if(c)break}var b=c.cp,x=c.segment,w=(u-h)/x.length,E=x.t1-x.t0,_=s?x.t0+E*w:x.t1-E*w;_=Pt(0,_,1),t=St(b.p0,b.p1,b.p2,_),i=$s(b.p0,b.p1,b.p2,_,t);break;case"straight":case"segments":case"haystack":for(var k,C,T,S,D=0,P=r.allpts.length,M=0;M+3<P;M+=2)if(s?(T={x:r.allpts[M],y:r.allpts[M+1]},S={x:r.allpts[M+2],y:r.allpts[M+3]}):(T={x:r.allpts[P-2-M],y:r.allpts[P-1-M]},S={x:r.allpts[P-4-M],y:r.allpts[P-3-M]}),k=_t(T,S),C=D,D+=k,D>=u)break;var N=u-C,z=N/k;z=Pt(0,z,1),t=Dt(T,S,z),i=Ws(T,S);break}o("labelX",n,t.x),o("labelY",n,t.y),o("labelAutoAngle",n,i)}};u("source"),u("target"),this.applyLabelDimensions(e)}},Hs.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},Hs.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),i=this.calculateLabelDimensions(e,r),a=e.pstyle("line-height").pfValue,o=e.pstyle("text-wrap").strValue,s=qe(n.rscratch,"labelWrapCachedLines",t)||[],l="wrap"!==o?1:Math.max(s.length,1),u=i.height/l,c=u*a,d=i.width,h=i.height+(l-1)*(a-1)*u;Xe(n.rstyle,"labelWidth",t,d),Xe(n.rscratch,"labelWidth",t,d),Xe(n.rstyle,"labelHeight",t,h),Xe(n.rscratch,"labelHeight",t,h),Xe(n.rscratch,"labelLineHeight",t,c)},Hs.getLabelText=function(e,t){var n=e._private,r=t?t+"-":"",i=e.pstyle(r+"label").strValue,a=e.pstyle("text-transform").value,o=function(e,r){return r?(Xe(n.rscratch,e,t,r),r):qe(n.rscratch,e,t)};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="​",c=i.split("\n"),d=e.pstyle("text-max-width").pfValue,h=e.pstyle("text-overflow-wrap").value,p="anywhere"===h,f=[],g=/[\s\u200b]+/,v=p?"":" ",y=0;y<c.length;y++){var m=c[y],b=this.calculateLabelDimensions(e,m),x=b.width;if(p){var w=m.split("").join(u);m=w}if(x>d){for(var E=m.split(g),_="",k=0;k<E.length;k++){var C=E[k],T=0===_.length?C:_+v+C,S=this.calculateLabelDimensions(e,T),D=S.width;D<=d?_+=C+v:(f.push(_),_=C+v)}_.match(/^[\s\u200b]+$/)||f.push(_)}else f.push(m)}o("labelWrapCachedLines",f),i=o("labelWrapCachedText",f.join("\n")),o("labelWrapKey",l)}else if("ellipsis"===s){for(var P=e.pstyle("text-max-width").pfValue,M="",N="…",z=!1,B=0;B<i.length;B++){var O=this.calculateLabelDimensions(e,M+i[B]+N).width;if(O>P)break;M+=i[B],B===i.length-1&&(z=!0)}return z||(M+=N),M}return i},Hs.getLabelJustification=function(e){var t=e.pstyle("text-justification").strValue,n=e.pstyle("text-halign").strValue;if("auto"!==t)return t;if(!e.isNode())return"center";switch(n){case"left":return"right";case"right":return"left";default:return"center"}},Hs.calculateLabelDimensions=function(e,t){var n=this,r=me(t,e._private.labelDimsKey),i=n.labelDimCache||(n.labelDimCache=[]),a=i[r];if(null!=a)return a;var o=1,s=e.pstyle("font-style").strValue,l=o*e.pstyle("font-size").pfValue+"px",u=e.pstyle("font-family").strValue,c=e.pstyle("font-weight").strValue,d=this.labelCalcDiv;d||(d=this.labelCalcDiv=document.createElement("div"),document.body.appendChild(d));var h=d.style;return h.fontFamily=u,h.fontStyle=s,h.fontSize=l,h.fontWeight=c,h.position="absolute",h.left="-9999px",h.top="-9999px",h.zIndex="-1",h.visibility="hidden",h.pointerEvents="none",h.padding="0",h.lineHeight="1","wrap"===e.pstyle("text-wrap").value?h.whiteSpace="pre":h.whiteSpace="normal",d.textContent=t,i[r]={width:Math.ceil(d.clientWidth/o),height:Math.ceil(d.clientHeight/o)}},Hs.calculateLabelAngle=function(e,t){var n=e._private,r=n.rscratch,i=e.isEdge(),a=t?t+"-":"",o=e.pstyle(a+"text-rotation"),s=o.strValue;return"none"===s?0:i&&"autorotate"===s?r.labelAutoAngle:"autorotate"===s?0:o.pfValue},Hs.calculateLabelAngles=function(e){var t=this,n=e.isEdge(),r=e._private,i=r.rscratch;i.labelAngle=t.calculateLabelAngle(e),n&&(i.sourceLabelAngle=t.calculateLabelAngle(e,"source"),i.targetLabelAngle=t.calculateLabelAngle(e,"target"))};var Us={},Ks=28,Zs=!1;Us.getNodeShape=function(e){var t=this,n=e.pstyle("shape").value;if("cutrectangle"===n&&(e.width()<Ks||e.height()<Ks))return Zs||(Ne("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),Zs=!0),"rectangle";if(e.isParent())return"rectangle"===n||"roundrectangle"===n||"cutrectangle"===n||"barrel"===n?n:"rectangle";if("polygon"===n){var r=e.pstyle("shape-polygon-points").value;return t.nodeShapes.makePolygon(r).name}return n};var Qs={registerCalculationListeners:function(){var e=this.cy,t=e.collection(),n=this,r=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.merge(e),n)for(var r=0;r<e.length;r++){var i=e[r],a=i._private,o=a.rstyle;o.clean=!1}};n.binder(e).on("bounds.* dirty.*",function(e){var t=e.target;r(t)}).on("style.* background.*",function(e){var t=e.target;r(t,!1)});var i=function(i){if(i){for(var a=n.onUpdateEleCalcsFns,o=0;o<t.length;o++){var s=t[o];s.isNode()&&!s._private.rstyle.clean&&r(s.connectedEdges())}if(a)for(o=0;o<a.length;o++){var l=a[o];l(i,t)}n.recalculateRenderedStyle(t),t=e.collection()}};n.flushRenderedStyleQueue=function(){i(!0)},n.beforeRender(i,n.beforeRenderPriorities.eleCalcs)},onUpdateEleCalcs:function(e){var t=this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[];t.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=e[i],o=a._private,s=o.rstyle;t&&s.clean||a.removed()||"none"!==a.pstyle("display").value&&("nodes"===o.group?r.push(a):n.push(a),s.clean=!0)}for(i=0;i<r.length;i++){a=r[i],o=a._private,s=o.rstyle;var l=a.position();this.recalculateNodeLabelProjection(a),s.nodeX=l.x,s.nodeY=l.y,s.nodeW=a.pstyle("width").pfValue,s.nodeH=a.pstyle("height").pfValue}this.recalculateEdgeProjections(n);for(i=0;i<n.length;i++){a=n[i],o=a._private,s=o.rstyle;var u=o.rscratch;s.srcX=u.arrowStartX,s.srcY=u.arrowStartY,s.tgtX=u.arrowEndX,s.tgtY=u.arrowEndY,s.midX=u.midX,s.midY=u.midY,s.labelAngle=u.labelAngle,s.sourceLabelAngle=u.sourceLabelAngle,s.targetLabelAngle=u.targetLabelAngle}}}},Js={updateCachedGrabbedEles:function(){var e=this.cachedZSortedEles;if(e){e.drag=[],e.nondrag=[];for(var t=[],n=0;n<e.length;n++){var r=e[n],i=r._private.rscratch;r.grabbed()&&!r.isParent()?t.push(r):i.inDragLayer?e.drag.push(r):e.nondrag.push(r)}for(n=0;n<t.length;n++){r=t[n];e.drag.push(r)}}},invalidateCachedZSortedEles:function(){this.cachedZSortedEles=null},getCachedZSortedEles:function(e){if(e||!this.cachedZSortedEles){var t=this.cy.mutableElements().toArray();t.sort(Oa),t.interactive=t.filter(function(e){return e.interactive()}),this.cachedZSortedEles=t,this.updateCachedGrabbedEles()}else t=this.cachedZSortedEles;return t}},el={};[Rs,Fs,Vs,qs,Xs,Hs,Us,Qs,Js].forEach(function(e){te(el,e)});var tl={getCachedImage:function(e,t,n){var r=this,i=r.imageCache=r.imageCache||{},a=i[e];if(a)return a.image.complete||a.image.addEventListener("load",n),a.image;a=i[e]=i[e]||{};var o=a.image=new Image;o.addEventListener("load",n),o.addEventListener("error",function(){o.error=!0});var s="data:",l=e.substring(0,s.length).toLowerCase()===s;return l||(o.crossOrigin=t),o.src=e,o}},nl={registerBinding:function(e,t,n,r){var i=Array.prototype.slice.apply(arguments,[1]),a=this.binder(e);return a.on.apply(a,i)},binder:function(e){var t=this,n=e===window||e===document||e===document.body||I(e);if(null==t.supportsPassiveEvents){var r=!1;try{var i=Object.defineProperty({},"passive",{get:function(){return r=!0,!0}});window.addEventListener("test",null,i)}catch(o){}t.supportsPassiveEvents=r}var a=function(r,i,a){var o=Array.prototype.slice.call(arguments);return n&&t.supportsPassiveEvents&&(o[2]={capture:null!=a&&a,passive:!1,once:!1}),t.bindings.push({target:e,args:o}),(e.addEventListener||e.on).apply(e,o),this};return{on:a,addEventListener:a,addListener:a,bind:a}},nodeIsDraggable:function(e){return e&&e.isNode()&&!e.locked()&&e.grabbable()},nodeIsGrabbable:function(e){return this.nodeIsDraggable(e)&&e.interactive()},load:function(){var e=this,t=function(e){return e.selected()},n=function(t,n,r,i){null==t&&(t=e.cy);for(var a=0;a<n.length;a++){var o=n[a];t.emit({originalEvent:r,type:o,position:i})}},r=function(e){return e.shiftKey||e.metaKey||e.ctrlKey},a=function(t,n){var r=!0;if(e.cy.hasCompoundNodes()&&t&&t.pannable())for(var i=0;n&&i<n.length;i++){t=n[i];if(t.isNode()&&t.isParent()){r=!1;break}}else r=!0;return r},o=function(e){e[0]._private.grabbed=!0},s=function(e){e[0]._private.grabbed=!1},l=function(e){e[0]._private.rscratch.inDragLayer=!0},u=function(e){e[0]._private.rscratch.inDragLayer=!1},c=function(e){e[0]._private.rscratch.isGrabTarget=!0},d=function(e){e[0]._private.rscratch.isGrabTarget=!1},h=function(e,t){var n=t.addToList,r=n.has(e);r||(n.merge(e),o(e))},p=function(e,t){if(e.cy().hasCompoundNodes()&&(null!=t.inDragLayer||null!=t.addToList)){var n=e.descendants();t.inDragLayer&&(n.forEach(l),n.connectedEdges().forEach(l)),t.addToList&&t.addToList.unmerge(n)}},f=function(t,n){n=n||{};var r=t.cy().hasCompoundNodes();n.inDragLayer&&(t.forEach(l),t.neighborhood().stdFilter(function(e){return!r||e.isEdge()}).forEach(l)),n.addToList&&t.forEach(function(e){h(e,n)}),p(t,n),y(t,{inDragLayer:n.inDragLayer}),e.updateCachedGrabbedEles()},g=f,v=function(t){t&&(e.getCachedZSortedEles().forEach(function(e){s(e),u(e),d(e)}),e.updateCachedGrabbedEles())},y=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(l),r.forEach(l)),t.addToList&&r.forEach(function(e){h(e,t)})}}},m=function(){null!=document.activeElement&&null!=document.activeElement.blur&&document.activeElement.blur()},b="undefined"!==typeof MutationObserver;b?(e.removeObserver=new MutationObserver(function(t){for(var n=0;n<t.length;n++){var r=t[n],i=r.removedNodes;if(i)for(var a=0;a<i.length;a++){var o=i[a];if(o===e.container){e.destroy();break}}}}),e.container.parentNode&&e.removeObserver.observe(e.container.parentNode,{childList:!0})):e.registerBinding(e.container,"DOMNodeRemoved",function(t){e.destroy()});var x=i(function(){e.cy.resize()},100);b&&(e.styleObserver=new MutationObserver(x),e.styleObserver.observe(e.container,{attributes:!0})),e.registerBinding(window,"resize",x);var w=function(e,t){while(null!=e)t(e),e=e.parentNode},E=function(){e.invalidateContainerClientCoordsCache()};w(e.container,function(t){e.registerBinding(t,"transitionend",E),e.registerBinding(t,"animationend",E),e.registerBinding(t,"scroll",E)}),e.registerBinding(e.container,"contextmenu",function(e){e.preventDefault()});var _=function(){return 0!==e.selection[4]},k=function(t){for(var n=e.findContainerClientCoords(),r=n[0],i=n[1],a=n[2],o=n[3],s=t.touches?t.touches:[t],l=!1,u=0;u<s.length;u++){var c=s[u];if(r<=c.clientX&&c.clientX<=r+a&&i<=c.clientY&&c.clientY<=i+o){l=!0;break}}if(!l)return!1;var d=e.container,h=t.target,p=h.parentNode,f=!1;while(p){if(p===d){f=!0;break}p=p.parentNode}return!!f};e.registerBinding(e.container,"mousedown",function(t){if(k(t)){t.preventDefault(),m(),e.hoverData.capture=!0,e.hoverData.which=t.which;var r=e.cy,i=[t.clientX,t.clientY],a=e.projectIntoViewport(i[0],i[1]),o=e.selection,s=e.findNearestElements(a[0],a[1],!0,!1),l=s[0],u=e.dragData.possibleDragElements;e.hoverData.mdownPos=a,e.hoverData.mdownGPos=i;var d=function(){e.hoverData.tapholdCancelled=!1,clearTimeout(e.hoverData.tapholdTimeout),e.hoverData.tapholdTimeout=setTimeout(function(){if(!e.hoverData.tapholdCancelled){var n=e.hoverData.down;n?n.emit({originalEvent:t,type:"taphold",position:{x:a[0],y:a[1]}}):r.emit({originalEvent:t,type:"taphold",position:{x:a[0],y:a[1]}})}},e.tapholdDuration)};if(3==t.which){e.hoverData.cxtStarted=!0;var h={originalEvent:t,type:"cxttapstart",position:{x:a[0],y:a[1]}};l?(l.activate(),l.emit(h),e.hoverData.down=l):r.emit(h),e.hoverData.downTime=(new Date).getTime(),e.hoverData.cxtDragged=!1}else if(1==t.which){if(l&&l.activate(),null!=l&&e.nodeIsGrabbable(l)){var p=function(e){return{originalEvent:t,type:e,position:{x:a[0],y:a[1]}}},v=function(e){e.emit(p("grab"))};if(c(l),l.selected()){u=e.dragData.possibleDragElements=r.collection();var y=r.$(function(t){return t.isNode()&&t.selected()&&e.nodeIsGrabbable(t)});f(y,{addToList:u}),l.emit(p("grabon")),y.forEach(v)}else u=e.dragData.possibleDragElements=r.collection(),g(l,{addToList:u}),l.emit(p("grabon")).emit(p("grab"));e.redrawHint("eles",!0),e.redrawHint("drag",!0)}e.hoverData.down=l,e.hoverData.downs=s,e.hoverData.downTime=(new Date).getTime(),n(l,["mousedown","tapstart","vmousedown"],t,{x:a[0],y:a[1]}),null==l?(o[4]=1,e.data.bgActivePosistion={x:a[0],y:a[1]},e.redrawHint("select",!0),e.redraw()):l.pannable()&&(o[4]=1),d()}o[0]=o[2]=a[0],o[1]=o[3]=a[1]}},!1),e.registerBinding(window,"mousemove",function(t){var i=e.hoverData.capture;if(i||k(t)){var o=!1,s=e.cy,l=s.zoom(),u=[t.clientX,t.clientY],c=e.projectIntoViewport(u[0],u[1]),d=e.hoverData.mdownPos,h=e.hoverData.mdownGPos,p=e.selection,g=null;e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.selecting||(g=e.findNearestElement(c[0],c[1],!0,!1));var y,m=e.hoverData.last,b=e.hoverData.down,x=[c[0]-p[2],c[1]-p[3]],w=e.dragData.possibleDragElements;if(h){var E=u[0]-h[0],_=E*E,C=u[1]-h[1],T=C*C,D=_+T;e.hoverData.isOverThresholdDrag=y=D>=e.desktopTapThreshold2}var P=r(t);y&&(e.hoverData.tapholdCancelled=!0);var M=function(){var t=e.hoverData.dragDelta=e.hoverData.dragDelta||[];0===t.length?(t.push(x[0]),t.push(x[1])):(t[0]+=x[0],t[1]+=x[1])};o=!0,n(g,["mousemove","vmousemove","tapdrag"],t,{x:c[0],y:c[1]});var N=function(){e.data.bgActivePosistion=void 0,e.hoverData.selecting||s.emit({originalEvent:t,type:"boxstart",position:{x:c[0],y:c[1]}}),p[4]=1,e.hoverData.selecting=!0,e.redrawHint("select",!0),e.redraw()};if(3===e.hoverData.which){if(y){var z={originalEvent:t,type:"cxtdrag",position:{x:c[0],y:c[1]}};b?b.emit(z):s.emit(z),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&g===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:c[0],y:c[1]}}),e.hoverData.cxtOver=g,g&&g.emit({originalEvent:t,type:"cxtdragover",position:{x:c[0],y:c[1]}}))}}else if(e.hoverData.dragging){if(o=!0,s.panningEnabled()&&s.userPanningEnabled()){var B;if(e.hoverData.justStartedPan){var O=e.hoverData.mdownPos;B={x:(c[0]-O[0])*l,y:(c[1]-O[1])*l},e.hoverData.justStartedPan=!1}else B={x:x[0]*l,y:x[1]*l};s.panBy(B),e.hoverData.dragged=!0}c=e.projectIntoViewport(t.clientX,t.clientY)}else if(1!=p[4]||null!=b&&!b.pannable()){if(b&&b.pannable()&&b.active()&&b.unactivate(),b&&b.grabbed()||g==m||(m&&n(m,["mouseout","tapdragout"],t,{x:c[0],y:c[1]}),g&&n(g,["mouseover","tapdragover"],t,{x:c[0],y:c[1]}),e.hoverData.last=g),b)if(y){if(s.boxSelectionEnabled()&&P)b&&b.grabbed()&&(v(w),b.emit("freeon"),w.emit("free"),e.dragData.didDrag&&(b.emit("dragfreeon"),w.emit("dragfree"))),N();else if(b&&b.grabbed()&&e.nodeIsDraggable(b)){var L=!e.dragData.didDrag;L&&e.redrawHint("eles",!0),e.dragData.didDrag=!0;var A=s.collection();e.hoverData.draggingEles||f(w,{inDragLayer:!0});var I={x:0,y:0};if(S(x[0])&&S(x[1])&&(I.x+=x[0],I.y+=x[1],L)){var R=e.hoverData.dragDelta;R&&S(R[0])&&S(R[1])&&(I.x+=R[0],I.y+=R[1])}for(var F=0;F<w.length;F++){var V=w[F];e.nodeIsDraggable(V)&&V.grabbed()&&A.merge(V)}e.hoverData.draggingEles=!0,A.silentShift(I).emit("position drag"),e.redrawHint("drag",!0),e.redraw()}}else M();o=!0}else if(y){if(e.hoverData.dragging||!s.boxSelectionEnabled()||!P&&s.panningEnabled()&&s.userPanningEnabled()){if(!e.hoverData.selecting&&s.panningEnabled()&&s.userPanningEnabled()){var j=a(b,e.hoverData.downs);j&&(e.hoverData.dragging=!0,e.hoverData.justStartedPan=!0,p[4]=0,e.data.bgActivePosistion=ft(d),e.redrawHint("select",!0),e.redraw())}}else N();b&&b.pannable()&&b.active()&&b.unactivate()}return p[2]=c[0],p[3]=c[1],o?(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),!1):void 0}},!1),e.registerBinding(window,"mouseup",function(i){var a=e.hoverData.capture;if(a){e.hoverData.capture=!1;var o=e.cy,s=e.projectIntoViewport(i.clientX,i.clientY),l=e.selection,u=e.findNearestElement(s[0],s[1],!0,!1),c=e.dragData.possibleDragElements,d=e.hoverData.down,h=r(i);if(e.data.bgActivePosistion&&(e.redrawHint("select",!0),e.redraw()),e.hoverData.tapholdCancelled=!0,e.data.bgActivePosistion=void 0,d&&d.unactivate(),3===e.hoverData.which){var p={originalEvent:i,type:"cxttapend",position:{x:s[0],y:s[1]}};if(d?d.emit(p):o.emit(p),!e.hoverData.cxtDragged){var f={originalEvent:i,type:"cxttap",position:{x:s[0],y:s[1]}};d?d.emit(f):o.emit(f)}e.hoverData.cxtDragged=!1,e.hoverData.which=null}else if(1===e.hoverData.which){if(n(u,["mouseup","tapend","vmouseup"],i,{x:s[0],y:s[1]}),e.dragData.didDrag||e.hoverData.dragged||e.hoverData.selecting||e.hoverData.isOverThresholdDrag||n(d,["click","tap","vclick"],i,{x:s[0],y:s[1]}),null!=d||e.dragData.didDrag||e.hoverData.selecting||e.hoverData.dragged||r(i)||(o.$(t).unselect(["tapunselect"]),c.length>0&&e.redrawHint("eles",!0),e.dragData.possibleDragElements=c=o.collection()),u!=d||e.dragData.didDrag||e.hoverData.selecting||null!=u&&u._private.selectable&&(e.hoverData.dragging||("additive"===o.selectionType()||h?u.selected()?u.unselect(["tapunselect"]):u.select(["tapselect"]):h||(o.$(t).unmerge(u).unselect(["tapunselect"]),u.select(["tapselect"]))),e.redrawHint("eles",!0)),e.hoverData.selecting){var g=o.collection(e.getAllInBox(l[0],l[1],l[2],l[3]));e.redrawHint("select",!0),g.length>0&&e.redrawHint("eles",!0),o.emit({type:"boxend",originalEvent:i,position:{x:s[0],y:s[1]}});var y=function(e){return e.selectable()&&!e.selected()};"additive"===o.selectionType()?g.emit("box").stdFilter(y).select().emit("boxselect"):(h||o.$(t).unmerge(g).unselect(),g.emit("box").stdFilter(y).select().emit("boxselect")),e.redraw()}if(e.hoverData.dragging&&(e.hoverData.dragging=!1,e.redrawHint("select",!0),e.redrawHint("eles",!0),e.redraw()),!l[4]){e.redrawHint("drag",!0),e.redrawHint("eles",!0);var m=d&&d.grabbed();v(c),m&&(d.emit("freeon"),c.emit("free"),e.dragData.didDrag&&(d.emit("dragfreeon"),c.emit("dragfree")))}}l[4]=0,e.hoverData.down=null,e.hoverData.cxtStarted=!1,e.hoverData.draggingEles=!1,e.hoverData.selecting=!1,e.hoverData.isOverThresholdDrag=!1,e.dragData.didDrag=!1,e.hoverData.dragged=!1,e.hoverData.dragDelta=[],e.hoverData.mdownPos=null,e.hoverData.mdownGPos=null}},!1);var C,T,D,P,M,N,z,B,O,L,A,I,R,F=function(t){if(!e.scrollingPage){var n=e.cy,r=e.projectIntoViewport(t.clientX,t.clientY),i=[r[0]*n.zoom()+n.pan().x,r[1]*n.zoom()+n.pan().y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||_())t.preventDefault();else if(n.panningEnabled()&&n.userPanningEnabled()&&n.zoomingEnabled()&&n.userZoomingEnabled()){var a;t.preventDefault(),e.data.wheelZooming=!0,clearTimeout(e.data.wheelTimeout),e.data.wheelTimeout=setTimeout(function(){e.data.wheelZooming=!1,e.redrawHint("eles",!0),e.redraw()},150),a=null!=t.deltaY?t.deltaY/-250:null!=t.wheelDeltaY?t.wheelDeltaY/1e3:t.wheelDelta/1e3,a*=e.wheelSensitivity;var o=1===t.deltaMode;o&&(a*=33),n.zoom({level:n.zoom()*Math.pow(10,a),renderedPosition:{x:i[0],y:i[1]}})}}};e.registerBinding(e.container,"wheel",F,!0),e.registerBinding(window,"scroll",function(t){e.scrollingPage=!0,clearTimeout(e.scrollingPageTimeout),e.scrollingPageTimeout=setTimeout(function(){e.scrollingPage=!1},250)},!0),e.registerBinding(e.container,"mouseout",function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:"mouseout",position:{x:n[0],y:n[1]}})},!1),e.registerBinding(e.container,"mouseover",function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:"mouseover",position:{x:n[0],y:n[1]}})},!1);var V,j,q,X,Y=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},H=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)};if(e.registerBinding(e.container,"touchstart",V=function(t){if(k(t)){m(),e.touchData.capture=!0,e.data.bgActivePosistion=void 0;var r=e.cy,i=e.touchData.now,a=e.touchData.earlier;if(t.touches[0]){var o=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);i[0]=o[0],i[1]=o[1]}if(t.touches[1]){o=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);i[2]=o[0],i[3]=o[1]}if(t.touches[2]){o=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);i[4]=o[0],i[5]=o[1]}if(t.touches[1]){v(e.dragData.touchDragEles);var s=e.findContainerClientCoords();O=s[0],L=s[1],A=s[2],I=s[3],C=t.touches[0].clientX-O,T=t.touches[0].clientY-L,D=t.touches[1].clientX-O,P=t.touches[1].clientY-L,R=0<=C&&C<=A&&0<=D&&D<=A&&0<=T&&T<=I&&0<=P&&P<=I;var l=r.pan(),u=r.zoom();M=Y(C,T,D,P),N=H(C,T,D,P),z=[(C+D)/2,(T+P)/2],B=[(z[0]-l.x)/u,(z[1]-l.y)/u];var d=200,h=d*d;if(N<h&&!t.touches[2]){var p=e.findNearestElement(i[0],i[1],!0,!0),y=e.findNearestElement(i[2],i[3],!0,!0);return p&&p.isNode()?(p.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:i[0],y:i[1]}}),e.touchData.start=p):y&&y.isNode()?(y.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:i[0],y:i[1]}}),e.touchData.start=y):r.emit({originalEvent:t,type:"cxttapstart",position:{x:i[0],y:i[1]}}),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!0,e.touchData.cxtDragged=!1,e.data.bgActivePosistion=void 0,void e.redraw()}}if(t.touches[2]);else if(t.touches[1]);else if(t.touches[0]){var b=e.findNearestElements(i[0],i[1],!0,!0),x=b[0];if(null!=x&&(x.activate(),e.touchData.start=x,e.touchData.starts=b,e.nodeIsGrabbable(x))){var w=e.dragData.touchDragEles=r.collection(),E=null;e.redrawHint("eles",!0),e.redrawHint("drag",!0),x.selected()?(E=r.$(function(t){return t.selected()&&e.nodeIsGrabbable(t)}),f(E,{addToList:w})):g(x,{addToList:w}),c(x);var _=function(e){return{originalEvent:t,type:e,position:{x:i[0],y:i[1]}}};x.emit(_("grabon")),E?E.forEach(function(e){e.emit(_("grab"))}):x.emit(_("grab"))}n(x,["touchstart","tapstart","vmousedown"],t,{x:i[0],y:i[1]}),null==x&&(e.data.bgActivePosistion={x:o[0],y:o[1]},e.redrawHint("select",!0),e.redraw()),e.touchData.singleTouchMoved=!1,e.touchData.singleTouchStartTime=+new Date,clearTimeout(e.touchData.tapholdTimeout),e.touchData.tapholdTimeout=setTimeout(function(){!1!==e.touchData.singleTouchMoved||e.pinching||e.touchData.selecting||n(e.touchData.start,["taphold"],t,{x:i[0],y:i[1]})},e.tapholdDuration)}if(t.touches.length>=1){for(var S=e.touchData.startPosition=[],F=0;F<i.length;F++)S[F]=a[F]=i[F];var V=t.touches[0];e.touchData.startGPosition=[V.clientX,V.clientY]}}},!1),e.registerBinding(window,"touchmove",j=function(t){var r=e.touchData.capture;if(r||k(t)){var i=e.selection,o=e.cy,s=e.touchData.now,l=e.touchData.earlier,u=o.zoom();if(t.touches[0]){var c=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=c[0],s[1]=c[1]}if(t.touches[1]){c=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);s[2]=c[0],s[3]=c[1]}if(t.touches[2]){c=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);s[4]=c[0],s[5]=c[1]}var d,h=e.touchData.startGPosition;if(r&&t.touches[0]&&h){for(var p=[],g=0;g<s.length;g++)p[g]=s[g]-l[g];var y=t.touches[0].clientX-h[0],m=y*y,b=t.touches[0].clientY-h[1],x=b*b,w=m+x;d=w>=e.touchTapThreshold2}if(r&&e.touchData.cxt){t.preventDefault();var E=t.touches[0].clientX-O,_=t.touches[0].clientY-L,z=t.touches[1].clientX-O,A=t.touches[1].clientY-L,I=H(E,_,z,A),F=I/N,V=150,j=V*V,q=1.5,X=q*q;if(F>=X||I>=j){e.touchData.cxt=!1,e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var G={originalEvent:t,type:"cxttapend",position:{x:s[0],y:s[1]}};e.touchData.start?(e.touchData.start.unactivate().emit(G),e.touchData.start=null):o.emit(G)}}if(r&&e.touchData.cxt){G={originalEvent:t,type:"cxtdrag",position:{x:s[0],y:s[1]}};e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.touchData.start?e.touchData.start.emit(G):o.emit(G),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var W=e.findNearestElement(s[0],s[1],!0,!0);e.touchData.cxtOver&&W===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:s[0],y:s[1]}}),e.touchData.cxtOver=W,W&&W.emit({originalEvent:t,type:"cxtdragover",position:{x:s[0],y:s[1]}}))}else if(r&&t.touches[2]&&o.boxSelectionEnabled())t.preventDefault(),e.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,e.touchData.selecting||o.emit({originalEvent:t,type:"boxstart",position:{x:s[0],y:s[1]}}),e.touchData.selecting=!0,e.redrawHint("select",!0),i&&0!==i.length&&void 0!==i[0]?(i[2]=(s[0]+s[2]+s[4])/3,i[3]=(s[1]+s[3]+s[5])/3):(i[0]=(s[0]+s[2]+s[4])/3,i[1]=(s[1]+s[3]+s[5])/3,i[2]=(s[0]+s[2]+s[4])/3+1,i[3]=(s[1]+s[3]+s[5])/3+1),i[4]=1,e.touchData.selecting=!0,e.redraw();else if(r&&t.touches[1]&&o.zoomingEnabled()&&o.panningEnabled()&&o.userZoomingEnabled()&&o.userPanningEnabled()){t.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var $=e.dragData.touchDragEles;if($){e.redrawHint("drag",!0);for(var U=0;U<$.length;U++){var K=$[U]._private;K.grabbed=!1,K.rscratch.inDragLayer=!1}}var Z=e.touchData.start,Q=(E=t.touches[0].clientX-O,_=t.touches[0].clientY-L,z=t.touches[1].clientX-O,A=t.touches[1].clientY-L,Y(E,_,z,A)),J=Q/M;if(R){var ee=E-C,te=_-T,ne=z-D,re=A-P,ie=(ee+ne)/2,ae=(te+re)/2,oe=o.zoom(),se=oe*J,le=o.pan(),ue=B[0]*oe+le.x,ce=B[1]*oe+le.y,de={x:-se/oe*(ue-le.x-ie)+ue,y:-se/oe*(ce-le.y-ae)+ce};if(Z&&Z.active()){$=e.dragData.touchDragEles;v($),e.redrawHint("drag",!0),e.redrawHint("eles",!0),Z.unactivate().emit("freeon"),$.emit("free"),e.dragData.didDrag&&(Z.emit("dragfreeon"),$.emit("dragfree"))}o.viewport({zoom:se,pan:de,cancelOnFailedZoom:!0}),M=Q,C=E,T=_,D=z,P=A,e.pinching=!0}if(t.touches[0]){c=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=c[0],s[1]=c[1]}if(t.touches[1]){c=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);s[2]=c[0],s[3]=c[1]}if(t.touches[2]){c=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);s[4]=c[0],s[5]=c[1]}}else if(t.touches[0]){var he=e.touchData.start,pe=e.touchData.last;if(e.hoverData.draggingEles||e.swipePanning||(W=e.findNearestElement(s[0],s[1],!0,!0)),r&&null!=he&&t.preventDefault(),r&&null!=he&&e.nodeIsDraggable(he))if(d){$=e.dragData.touchDragEles;var fe=!e.dragData.didDrag;fe&&f($,{inDragLayer:!0}),e.dragData.didDrag=!0;var ge={x:0,y:0};if(S(p[0])&&S(p[1])&&(ge.x+=p[0],ge.y+=p[1],fe)){e.redrawHint("eles",!0);var ve=e.touchData.dragDelta;ve&&S(ve[0])&&S(ve[1])&&(ge.x+=ve[0],ge.y+=ve[1])}e.hoverData.draggingEles=!0,$.silentShift(ge).emit("position drag"),e.redrawHint("drag",!0),e.touchData.startPosition[0]==l[0]&&e.touchData.startPosition[1]==l[1]&&e.redrawHint("eles",!0),e.redraw()}else{ve=e.touchData.dragDelta=e.touchData.dragDelta||[];0===ve.length?(ve.push(p[0]),ve.push(p[1])):(ve[0]+=p[0],ve[1]+=p[1])}if(n(he||W,["touchmove","tapdrag","vmousemove"],t,{x:s[0],y:s[1]}),he&&he.grabbed()||W==pe||(pe&&pe.emit({originalEvent:t,type:"tapdragout",position:{x:s[0],y:s[1]}}),W&&W.emit({originalEvent:t,type:"tapdragover",position:{x:s[0],y:s[1]}})),e.touchData.last=W,r)for(U=0;U<s.length;U++)s[U]&&e.touchData.startPosition[U]&&d&&(e.touchData.singleTouchMoved=!0);if(r&&(null==he||he.pannable())&&o.panningEnabled()&&o.userPanningEnabled()){var ye=a(he,e.touchData.starts);ye&&(t.preventDefault(),e.swipePanning?o.panBy({x:p[0]*u,y:p[1]*u}):d&&(e.swipePanning=!0,o.panBy({x:y*u,y:b*u}),he&&(he.unactivate(),e.data.bgActivePosistion||(e.data.bgActivePosistion=ft(e.touchData.startPosition)),e.redrawHint("select",!0),e.touchData.start=null)));c=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=c[0],s[1]=c[1]}}for(g=0;g<s.length;g++)l[g]=s[g];r&&t.touches.length>0&&!e.hoverData.draggingEles&&!e.swipePanning&&null!=e.data.bgActivePosistion&&(e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.redraw())}},!1),e.registerBinding(window,"touchcancel",q=function(t){var n=e.touchData.start;e.touchData.capture=!1,n&&n.unactivate()}),e.registerBinding(window,"touchend",X=function(r){var i=e.touchData.start,a=e.touchData.capture;if(a){0===r.touches.length&&(e.touchData.capture=!1),r.preventDefault();var o=e.selection;e.swipePanning=!1,e.hoverData.draggingEles=!1;var s,l=e.cy,u=l.zoom(),c=e.touchData.now,d=e.touchData.earlier;if(r.touches[0]){var h=e.projectIntoViewport(r.touches[0].clientX,r.touches[0].clientY);c[0]=h[0],c[1]=h[1]}if(r.touches[1]){h=e.projectIntoViewport(r.touches[1].clientX,r.touches[1].clientY);c[2]=h[0],c[3]=h[1]}if(r.touches[2]){h=e.projectIntoViewport(r.touches[2].clientX,r.touches[2].clientY);c[4]=h[0],c[5]=h[1]}if(i&&i.unactivate(),e.touchData.cxt){if(s={originalEvent:r,type:"cxttapend",position:{x:c[0],y:c[1]}},i?i.emit(s):l.emit(s),!e.touchData.cxtDragged){var p={originalEvent:r,type:"cxttap",position:{x:c[0],y:c[1]}};i?i.emit(p):l.emit(p)}return e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!1,e.touchData.start=null,void e.redraw()}if(!r.touches[2]&&l.boxSelectionEnabled()&&e.touchData.selecting){e.touchData.selecting=!1;var f=l.collection(e.getAllInBox(o[0],o[1],o[2],o[3]));o[0]=void 0,o[1]=void 0,o[2]=void 0,o[3]=void 0,o[4]=0,e.redrawHint("select",!0),l.emit({type:"boxend",originalEvent:r,position:{x:c[0],y:c[1]}});var g=function(e){return e.selectable()&&!e.selected()};f.emit("box").stdFilter(g).select().emit("boxselect"),f.nonempty()&&e.redrawHint("eles",!0),e.redraw()}if(null!=i&&i.unactivate(),r.touches[2])e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);else if(r.touches[1]);else if(r.touches[0]);else if(!r.touches[0]){e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var y=e.dragData.touchDragEles;if(null!=i){var m=i._private.grabbed;v(y),e.redrawHint("drag",!0),e.redrawHint("eles",!0),m&&(i.emit("freeon"),y.emit("free"),e.dragData.didDrag&&(i.emit("dragfreeon"),y.emit("dragfree"))),n(i,["touchend","tapend","vmouseup","tapdragout"],r,{x:c[0],y:c[1]}),i.unactivate(),e.touchData.start=null}else{var b=e.findNearestElement(c[0],c[1],!0,!0);n(b,["touchend","tapend","vmouseup","tapdragout"],r,{x:c[0],y:c[1]})}var x=e.touchData.startPosition[0]-c[0],w=x*x,E=e.touchData.startPosition[1]-c[1],_=E*E,k=w+_,C=k*u*u;e.touchData.singleTouchMoved||(i||l.$(":selected").unselect(["tapunselect"]),n(i,["tap","vclick"],r,{x:c[0],y:c[1]})),null!=i&&!e.dragData.didDrag&&i._private.selectable&&C<e.touchTapThreshold2&&!e.pinching&&("single"===l.selectionType()?(l.$(t).unmerge(i).unselect(["tapunselect"]),i.select(["tapselect"])):i.selected()?i.unselect(["tapunselect"]):i.select(["tapselect"]),e.redrawHint("eles",!0)),e.touchData.singleTouchMoved=!0}for(var T=0;T<c.length;T++)d[T]=c[T];e.dragData.didDrag=!1,0===r.touches.length&&(e.touchData.dragDelta=[],e.touchData.startPosition=null,e.touchData.startGPosition=null),r.touches.length<2&&(e.pinching=!1,e.redrawHint("eles",!0),e.redraw())}},!1),"undefined"===typeof TouchEvent){var G=[],W=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}},$=function(e){return{event:e,touch:W(e)}},U=function(e){G.push($(e))},K=function(e){for(var t=0;t<G.length;t++){var n=G[t];if(n.event.pointerId===e.pointerId)return void G.splice(t,1)}},Z=function(e){var t=G.filter(function(t){return t.event.pointerId===e.pointerId})[0];t.event=e,t.touch=W(e)},Q=function(e){e.touches=G.map(function(e){return e.touch})},J=function(e){return"mouse"===e.pointerType||4===e.pointerType};e.registerBinding(e.container,"pointerdown",function(e){J(e)||(e.preventDefault(),U(e),Q(e),V(e))}),e.registerBinding(e.container,"pointerup",function(e){J(e)||(K(e),Q(e),X(e))}),e.registerBinding(e.container,"pointercancel",function(e){J(e)||(K(e),Q(e),q(e))}),e.registerBinding(e.container,"pointermove",function(e){J(e)||(e.preventDefault(),Z(e),Q(e),j(e))})}}},rl={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 an(i,a,this.points,e,t,n/2,r/2,o)},checkPoint:function(e,t,n,r,i,a,o){return Kt(e,t,this.points,a,o,r,i,[0,-1],n)}}},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 Jt(i,a,e,t,n/2+o,r/2+o)},checkPoint:function(e,t,n,r,i,a,o){return en(e,t,r,i,a,o,n)}}},generateRoundRectangle:function(){return this.nodeShapes["round-rectangle"]=this.nodeShapes["roundrectangle"]={renderer:this,name:"round-rectangle",points:sn(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 qt(i,a,e,t,n,r,o)},checkPoint:function(e,t,n,r,i,a,o){var s=cn(r,i),l=2*s;return!!Kt(e,t,this.points,a,o,r,i-l,[0,-1],n)||(!!Kt(e,t,this.points,a,o,r-l,i,[0,-1],n)||(!!en(e,t,l,l,a-r/2+s,o-i/2+s,n)||(!!en(e,t,l,l,a+r/2-s,o-i/2+s,n)||(!!en(e,t,l,l,a+r/2-s,o+i/2-s,n)||!!en(e,t,l,l,a-r/2+s,o+i/2-s,n)))))}}},generateCutRectangle:function(){return this.nodeShapes["cut-rectangle"]=this.nodeShapes["cutrectangle"]={renderer:this,name:"cut-rectangle",cornerLength:dn(),points:sn(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 an(i,a,l,e,t)},checkPoint:function(e,t,n,r,i,a,o){if(Kt(e,t,this.points,a,o,r,i-2*this.cornerLength,[0,-1],n))return!0;if(Kt(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 Ut(e,t,s.topLeft)||Ut(e,t,s.topRight)||Ut(e,t,s.bottomRight)||Ut(e,t,s.bottomLeft)}}},generateBarrel:function(){return this.nodeShapes["barrel"]={renderer:this,name:"barrel",points:sn(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=.15,l=.5,u=.85,c=this.generateBarrelBezierPts(n+2*o,r+2*o,e,t),d=function(e){var t=St({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},s),n=St({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},l),r=St({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},u);return[e[0],e[1],t.x,t.y,n.x,n.y,r.x,r.y,e[4],e[5]]},h=[].concat(d(c.topLeft),d(c.topRight),d(c.bottomRight),d(c.bottomLeft));return an(i,a,h,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=pn(e,t),d=c.heightOffset,h=c.widthOffset,p=c.ctrlPtOffsetPct*e,f={topLeft:[o,l+d,o+p,l,o+h,l],topRight:[s-h,l,s-p,l,s,l+d],bottomRight:[s,u-d,s-p,u,s-h,u],bottomLeft:[o+h,u,o+p,u,o,u-d]};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=pn(r,i),l=s.heightOffset,u=s.widthOffset;if(Kt(e,t,this.points,a,o,r,i-2*l,[0,-1],n))return!0;if(Kt(e,t,this.points,a,o,r-2*u,i,[0,-1],n))return!0;for(var c=this.generateBarrelBezierPts(r,i,a,o),d=function(e,t,n){var r=n[4],i=n[2],a=n[0],o=n[5],s=n[1],l=Math.min(r,a),u=Math.max(r,a),c=Math.min(o,s),d=Math.max(o,s);if(l<=e&&e<=u&&c<=t&&t<=d){var h=hn(r,i,a),p=Ht(h[0],h[1],h[2],e),f=p.filter(function(e){return 0<=e&&e<=1});if(f.length>0)return f[0]}return null},h=Object.keys(c),p=0;p<h.length;p++){var f=h[p],g=c[f],v=d(e,t,g);if(null!=v){var y=g[5],m=g[3],b=g[1],x=Tt(y,m,b,v);if(g.isTop&&x<=t)return!0;if(g.isBottom&&t<=x)return!0}}return!1}}},generateBottomRoundrectangle:function(){return this.nodeShapes["bottom-round-rectangle"]=this.nodeShapes["bottomroundrectangle"]={renderer:this,name:"bottom-round-rectangle",points:sn(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=e-(n/2+o),l=t-(r/2+o),u=l,c=e+(n/2+o),d=rn(i,a,e,t,s,l,c,u,!1);return d.length>0?d:qt(i,a,e,t,n,r,o)},checkPoint:function(e,t,n,r,i,a,o){var s=cn(r,i),l=2*s;if(Kt(e,t,this.points,a,o,r,i-l,[0,-1],n))return!0;if(Kt(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,d=[a-u,o-c,a-u,o,a+u,o,a+u,o-c];return!!Ut(e,t,d)||(!!en(e,t,l,l,a+r/2-s,o+i/2-s,n)||!!en(e,t,l,l,a-r/2+s,o+i/2-s,n))}}},registerNodeShapes:function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",sn(3,0)),this.generatePolygon("rectangle",sn(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",sn(5,0)),this.generatePolygon("hexagon",sn(6,0)),this.generatePolygon("heptagon",sn(7,0)),this.generatePolygon("octagon",sn(8,0));var n=new Array(20),r=un(5,0),i=un(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++)n[4*o]=r[2*o],n[4*o+1]=r[2*o+1],n[4*o+2]=i[2*o],n[4*o+3]=i[2*o+1];n=ln(n),this.generatePolygon("star",n),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 n,r=e.join("$"),i="polygon-"+r;return(n=this[i])?n:t.generatePolygon(i,e)}}},il={timeToRender:function(){return this.redrawTotalTime/this.redrawCount},redraw:function(e){e=e||Ie();var t=this;void 0===t.averageRedrawTime&&(t.averageRedrawTime=0),void 0===t.lastRedrawTime&&(t.lastRedrawTime=0),void 0===t.lastDrawTime&&(t.lastDrawTime=0),t.requestedFrame=!0,t.renderOptions=e},beforeRender:function(e,t){if(!this.destroyed){null==t&&Pe("Priority is not optional for beforeRender");var n=this.beforeRenderCallbacks;n.push({fn:e,priority:t}),n.sort(function(e,t){return t.priority-e.priority})}}},al=function(e,t,n){for(var r=e.beforeRenderCallbacks,i=0;i<r.length;i++)r[i].fn(t,n)};il.startRenderLoop=function(){var e=this,t=e.cy;if(!e.renderLoopStarted){e.renderLoopStarted=!0;var n=function n(r){if(!e.destroyed){if(t.batching());else if(e.requestedFrame&&!e.skipFrame){al(e,!0,r);var i=fe();e.render(e.renderOptions);var a=e.lastDrawTime=fe();void 0===e.averageRedrawTime&&(e.averageRedrawTime=a-i),void 0===e.redrawCount&&(e.redrawCount=0),e.redrawCount++,void 0===e.redrawTotalTime&&(e.redrawTotalTime=0);var o=a-i;e.redrawTotalTime+=o,e.lastRedrawTime=o,e.averageRedrawTime=e.averageRedrawTime/2+o/2,e.requestedFrame=!1}else al(e,!1,r);e.skipFrame=!1,pe(n)}};pe(n)}};var ol=function(e){this.init(e)},sl=ol,ll=sl.prototype;ll.clientFunctions=["redrawHint","render","renderTo","matchCanvasSize","nodeShapeImpl","arrowShapeImpl"],ll.init=function(e){var t=this;t.options=e,t.cy=e.cy;var n=t.container=e.cy.container();if(g){var r=g.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])}var u=g.getComputedStyle(n),c=u.getPropertyValue("position");"static"===c&&Ne("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=S(e.pixelRatio)?e.pixelRatio:null,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:150,lyrTxrSkip:100},t.registerNodeShapes(),t.registerArrowShapes(),t.registerCalculationListeners()},ll.notify=function(e,t){var n=this,r=n.cy;this.destroyed||("init"!==e?"destroy"!==e?(("add"===e||"remove"===e||"move"===e&&r.hasCompoundNodes()||"load"===e||"zorder"===e||"mount"===e)&&n.invalidateCachedZSortedEles(),"viewport"===e&&n.redrawHint("select",!0),"load"!==e&&"resize"!==e&&"mount"!==e||(n.invalidateContainerClientCoordsCache(),n.matchCanvasSize(n.container)),n.redrawHint("eles",!0),n.redrawHint("drag",!0),this.startRenderLoop(),this.redraw()):n.destroy():n.load())},ll.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,i=r.target;(i.off||i.removeEventListener).apply(i,r.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(a){}},ll.isHeadless=function(){return!1},[Is,el,tl,nl,rl,il].forEach(function(e){te(ll,e)});var ul=1e3/60,cl={setupDequeueing:function(e){return function(){var t=this,n=this.renderer;if(!t.dequeueingSetup){t.dequeueingSetup=!0;var r=i(function(){n.redrawHint("eles",!0),n.redrawHint("drag",!0),n.redraw()},e.deqRedrawThreshold),a=function(i,a){var o=fe(),s=n.averageRedrawTime,l=n.lastRedrawTime,u=[],c=n.cy.extent(),d=n.getPixelRatio();i||n.flushRenderedStyleQueue();while(1){var h=fe(),p=h-o,f=h-a;if(l<ul){var g=ul-(i?s:0);if(f>=e.deqFastCost*g)break}else if(i){if(p>=e.deqCost*l||p>=e.deqAvgCost*s)break}else if(f>=e.deqNoDrawCost*ul)break;var v=e.deq(t,d,c);if(!(v.length>0))break;for(var y=0;y<v.length;y++)u.push(v[y])}u.length>0&&(e.onDeqd(t,u),!i&&e.shouldRedraw(t,u,d,c)&&r())},o=e.priority||De;n.beforeRender(a,o(t))}}}},dl=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Te;s(this,e),this.idsByKey=new He,this.keyForId=new He,this.cachesByLvl=new He,this.lvls=[],this.getKey=t,this.doesEleInvalidateKey=n}return u(e,[{key:"getIdsFor",value:function(e){null==e&&Pe("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(),n=this.keyForId.get(t),r=this.getKey(e);return n!==r}},{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 He,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()),r=this.getCache(n,t);return r}},{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(e){var t=this;this.lvls.forEach(function(n){return t.deleteCache(e,n)})}},{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)}}]),e}(),hl=25,pl=50,fl=-4,gl=3,vl=7.99,yl=8,ml=1024,bl=1024,xl=1024,wl=.2,El=.8,_l=10,kl=.15,Cl=.1,Tl=.9,Sl=.9,Dl=100,Pl=1,Ml={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},Nl=Re({getKey:null,doesEleInvalidateKey:Te,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Ce,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),zl=function(e,t){var n=this;n.renderer=e,n.onDequeues=[];var r=Nl(t);te(n,r),n.lookup=new dl(r.getKey,r.doesEleInvalidateKey),n.setupDequeueing()},Bl=zl.prototype;Bl.reasons=Ml,Bl.getTextureQueue=function(e){var t=this;return t.eleImgCaches=t.eleImgCaches||{},t.eleImgCaches[e]=t.eleImgCaches[e]||[]},Bl.getRetiredTextureQueue=function(e){var t=this,n=t.eleImgCaches.retired=t.eleImgCaches.retired||{},r=n[e]=n[e]||[];return r},Bl.getElementQueue=function(){var e=this,t=e.eleCacheQueue=e.eleCacheQueue||new a(function(e,t){return t.reqs-e.reqs});return t},Bl.getElementKeyToQueue=function(){var e=this,t=e.eleKeyToCacheQueue=e.eleKeyToCacheQueue||{};return t},Bl.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(wt(s*n))),r<fl)r=fl;else if(s>=vl||r>gl)return null;var u=Math.pow(2,r),c=t.h*u,d=t.w*u,h=o.eleTextBiggerThanMin(e,u);if(!this.isVisible(e,h))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<=hl?hl:c<=pl?pl:Math.ceil(c/pl)*pl,c>xl||d>bl)return null;var g=a.getTextureQueue(p),v=g[g.length-2],y=function(){return a.recycleTexture(p,d)||a.addTexture(p,d)};v||(v=g[g.length-1]),v||(v=y()),v.width-v.usedWidth<d&&(v=y());for(var m,b=function(e){return e&&e.scaledLabelShown===h},x=i&&i===Ml.dequeue,w=i&&i===Ml.highQuality,E=i&&i===Ml.downscale,_=r+1;_<=gl;_++){var k=l.get(e,_);if(k){m=k;break}}var C=m&&m.level===r+1?m:null,T=function(){v.context.drawImage(C.texture.canvas,C.x,0,C.width,C.height,v.usedWidth,0,d,c)};if(v.context.setTransform(1,0,0,1,0,0),v.context.clearRect(v.usedWidth,0,d,p),b(C))T();else if(b(m)){if(!w)return a.queueElement(e,m.level-1),m;for(var S=m.level;S>r;S--)C=a.getElement(e,t,n,S,Ml.downscale);T()}else{var D;if(!x&&!w&&!E)for(var P=r-1;P>=fl;P--){var M=l.get(e,P);if(M){D=M;break}}if(b(D))return a.queueElement(e,r),D;v.context.translate(v.usedWidth,0),v.context.scale(u,u),this.drawElement(v.context,e,t,h,!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:d,height:c,scaledLabelShown:h},v.usedWidth+=Math.ceil(d+yl),v.eleCaches.push(f),l.set(e,r,f),a.checkTextureFullness(v),f},Bl.invalidateElements=function(e){for(var t=0;t<e.length;t++)this.invalidateElement(e[t])},Bl.invalidateElement=function(e){var t=this,n=t.lookup,r=[],i=n.isInvalid(e);if(i){for(var a=fl;a<=gl;a++){var o=n.getForCachedKey(e,a);o&&r.push(o)}var s=n.invalidate(e);if(s)for(var l=0;l<r.length;l++){var u=r[l],c=u.texture;c.invalidatedWidth+=u.width,u.invalidated=!0,t.checkTextureUtility(c)}t.removeFromQueue(e)}},Bl.checkTextureUtility=function(e){e.invalidatedWidth>=wl*e.width&&this.retireTexture(e)},Bl.checkTextureFullness=function(e){var t=this,n=t.getTextureQueue(e.height);e.usedWidth/e.width>El&&e.fullnessChecks>=_l?Fe(n,e):e.fullnessChecks++},Bl.retireTexture=function(e){var t=this,n=e.height,r=t.getTextureQueue(n),i=this.lookup;Fe(r,e),e.retired=!0;for(var a=e.eleCaches,o=0;o<a.length;o++){var s=a[o];i.deleteCache(s.key,s.level)}Ve(a);var l=t.getRetiredTextureQueue(n);l.push(e)},Bl.addTexture=function(e,t){var n=this,r=n.getTextureQueue(e),i={};return r.push(i),i.eleCaches=[],i.height=e,i.width=Math.max(ml,t),i.usedWidth=0,i.invalidatedWidth=0,i.fullnessChecks=0,i.canvas=n.renderer.makeOffscreenCanvas(i.width,i.height),i.context=i.canvas.getContext("2d"),i},Bl.recycleTexture=function(e,t){for(var n=this,r=n.getTextureQueue(e),i=n.getRetiredTextureQueue(e),a=0;a<i.length;a++){var o=i[a];if(o.width>=t)return o.retired=!1,o.usedWidth=0,o.invalidatedWidth=0,o.fullnessChecks=0,Ve(o.eleCaches),o.context.setTransform(1,0,0,1,0,0),o.context.clearRect(0,0,o.width,o.height),Fe(i,o),r.push(o),o}},Bl.queueElement=function(e,t){var n=this,r=n.getElementQueue(),i=n.getElementKeyToQueue(),a=this.getKey(e),o=i[a];if(o)o.level=Math.max(o.level,t),o.eles.merge(e),o.reqs++,r.updateItem(o);else{var s={eles:e.spawn().merge(e),level:t,reqs:1,key:a};r.push(s),i[a]=s}},Bl.dequeue=function(e){for(var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),i=[],a=t.lookup,o=0;o<Pl;o++){if(!(n.size()>0))break;var s=n.pop(),l=s.key,u=s.eles[0],c=a.hasCache(u,s.level);if(r[l]=null,!c){i.push(s);var d=t.getBoundingBox(u);t.getElement(u,d,e,s.level,Ml.dequeue)}}return i},Bl.removeFromQueue=function(e){var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),i=this.getKey(e),a=r[i];null!=a&&(1===a.eles.length?(a.reqs=ke,n.updateItem(a),n.pop(),r[i]=null):a.eles.unmerge(e))},Bl.onDequeue=function(e){this.onDequeues.push(e)},Bl.offDequeue=function(e){Fe(this.onDequeues,e)},Bl.setupDequeueing=cl.setupDequeueing({deqRedrawThreshold:Dl,deqCost:kl,deqAvgCost:Cl,deqNoDrawCost:Tl,deqFastCost:Sl,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n<e.onDequeues.length;n++){var r=e.onDequeues[n];r(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(Rt(s,r))return!0}return!1},priority:function(e){return e.renderer.beforeRenderPriorities.eleTxrDeq}});var Ol=1,Ll=-4,Al=2,Il=3.99,Rl=50,Fl=50,Vl=.15,jl=.1,ql=.9,Xl=.9,Yl=1,Hl=250,Gl=16e6,Wl=!0,$l=function(e){var t=this,n=t.renderer=e,r=n.cy;t.layersByLevel={},t.firstGet=!0,t.lastInvalidationTime=fe()-2*Hl,t.skipping=!1,t.eleTxrDeqs=r.collection(),t.scheduleElementRefinement=i(function(){t.refineElementTextures(t.eleTxrDeqs),t.eleTxrDeqs.unmerge(t.eleTxrDeqs)},Fl),n.beforeRender(function(e,n){n-t.lastInvalidationTime<=Hl?t.skipping=!0:t.skipping=!1},n.beforeRenderPriorities.lyrTxrSkip);var o=function(e,t){return t.reqs-e.reqs};t.layersQueue=new a(o),t.setupDequeueing()},Ul=$l.prototype,Kl=0,Zl=Math.pow(2,53)-1;Ul.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:Kl=++Kl%Zl,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},Ul.getLayers=function(e,t,n){var r=this,i=r.renderer,a=i.cy,o=a.zoom(),s=r.firstGet;if(r.firstGet=!1,null==n)if(n=Math.ceil(wt(o*t)),n<Ll)n=Ll;else if(o>=Il||n>Al)return null;r.validateLayersElesOrdering(n,e);var l,u,c=r.layersByLevel,d=Math.pow(2,n),h=c[n]=c[n]||[],p=r.levelIsComplete(n,e),f=function(){var t=function(t){if(r.validateLayersElesOrdering(t,e),r.levelIsComplete(t,e))return u=c[t],!0},i=function(e){if(!u)for(var r=n+e;Ll<=r&&r<=Al;r+=e)if(t(r))break};i(1),i(-1);for(var a=h.length-1;a>=0;a--){var o=h[a];o.invalid&&Fe(h,o)}};if(p)return h;f();var g=function(){if(!l){l=Mt();for(var t=0;t<e.length;t++)Bt(l,e[t].boundingBox())}return l},v=function(e){e=e||{};var t=e.after;g();var i=l.w*d*(l.h*d);if(i>Gl)return null;var a=r.makeLayer(l,n);if(null!=t){var o=h.indexOf(t)+1;h.splice(o,0,a)}else(void 0===e.insert||e.insert)&&h.unshift(a);return a};if(r.skipping&&!s)return null;for(var y=null,m=e.length/Ol,b=!s,x=0;x<e.length;x++){var w=e[x],E=w._private.rscratch,_=E.imgLayerCaches=E.imgLayerCaches||{},k=_[n];if(k)y=k;else{if((!y||y.eles.length>=m||!jt(y.bb,w.boundingBox()))&&(y=v({insert:!0,after:y}),!y))return null;u||b?r.queueLayer(y,w):r.drawEleInLayer(y,w,n,t),y.eles.push(w),_[n]=y}}return u||(b?null:h)},Ul.getEleLevelForLayerLevel=function(e,t){return e},Ul.drawEleInLayer=function(e,t,n,r){var i=this,a=this.renderer,o=e.context,s=t.boundingBox();0!==s.w&&0!==s.h&&t.visible()&&(n=i.getEleLevelForLayerLevel(n,r),a.setImgSmoothing(o,!1),a.drawCachedElement(o,t,null,null,n,Wl),a.setImgSmoothing(o,!0))},Ul.levelIsComplete=function(e,t){var n=this,r=n.layersByLevel[e];if(!r||0===r.length)return!1;for(var i=0,a=0;a<r.length;a++){var o=r[a];if(o.reqs>0)return!1;if(o.invalid)return!1;i+=o.eles.length}return i===t.length},Ul.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}}}},Ul.updateElementsInLayers=function(e,t){for(var n=this,r=N(e[0]),i=0;i<e.length;i++)for(var a=r?null:e[i],o=r?e[i]:e[i].ele,s=o._private.rscratch,l=s.imgLayerCaches=s.imgLayerCaches||{},u=Ll;u<=Al;u++){var c=l[u];c&&(a&&n.getEleLevelForLayerLevel(c.level)!==a.level||t(c,o,a))}},Ul.haveLayers=function(){for(var e=this,t=!1,n=Ll;n<=Al;n++){var r=e.layersByLevel[n];if(r&&r.length>0){t=!0;break}}return t},Ul.invalidateElements=function(e){var t=this;0!==e.length&&(t.lastInvalidationTime=fe(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,function(e,n,r){t.invalidateLayer(e)}))},Ul.invalidateLayer=function(e){if(this.lastInvalidationTime=fe(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];Fe(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)}}},Ul.refineElementTextures=function(e){var t=this;t.updateElementsInLayers(e,function(e,n,r){var i=e.replacement;if(i||(i=e.replacement=t.makeLayer(e.bb,e.level),i.replaces=e,i.eles=e.eles),!i.reqs)for(var a=0;a<i.eles.length;a++)t.queueLayer(i,i.eles[a])})},Ul.enqueueElementRefinement=function(e){this.eleTxrDeqs.merge(e),this.scheduleElementRefinement()},Ul.queueLayer=function(e,t){var n=this,r=n.layersQueue,i=e.elesQueue,a=i.hasId=i.hasId||{};if(!e.replacement){if(t){if(a[t.id()])return;i.push(t),a[t.id()]=!0}e.reqs?(e.reqs++,r.updateItem(e)):(e.reqs=1,r.push(e))}},Ul.dequeue=function(e){var t=this,n=t.layersQueue,r=[],i=0;while(i<Yl){if(0===n.size())break;var a=n.peek();if(a.replacement)n.pop();else if(a.replaces&&a!==a.replaces.replacement)n.pop();else if(a.invalid)n.pop();else{var o=a.elesQueue.shift();o&&(t.drawEleInLayer(a,o,a.level,e),i++),0===r.length&&r.push(!0),0===a.elesQueue.length&&(n.pop(),a.reqs=0,a.replaces&&t.applyLayerReplacement(a),t.requestRedraw())}}return r},Ul.applyLayerReplacement=function(e){var t=this,n=t.layersByLevel[e.level],r=e.replaces,i=n.indexOf(r);if(!(i<0||r.invalid)){n[i]=e;for(var a=0;a<e.eles.length;a++){var o=e.eles[a]._private,s=o.imgLayerCaches=o.imgLayerCaches||{};s&&(s[e.level]=e)}t.requestRedraw()}},Ul.requestRedraw=i(function(){var e=this.renderer;e.redrawHint("eles",!0),e.redrawHint("drag",!0),e.redraw()},100),Ul.setupDequeueing=cl.setupDequeueing({deqRedrawThreshold:Rl,deqCost:Vl,deqAvgCost:jl,deqNoDrawCost:ql,deqFastCost:Xl,deq:function(e,t){return e.dequeue(t)},onDeqd:De,shouldRedraw:Ce,priority:function(e){return e.renderer.beforeRenderPriorities.lyrTxrDeq}});var Ql,Jl={};function eu(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.lineTo(r.x,r.y)}}function tu(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 nu(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 ru(e,t,n,r){e.arc(t,n,r,0,2*Math.PI,!1)}Jl.arrowShapeImpl=function(e){return(Ql||(Ql={polygon:eu,"triangle-backcurve":tu,"triangle-tee":nu,"triangle-cross":nu,circle:ru}))[e]};var iu={drawElement:function(e,t,n,r,i,a){var o=this;t.isNode()?o.drawNode(e,t,n,r,i,a):o.drawEdge(e,t,n,r,i,a)},drawElementOverlay:function(e,t){var n=this;t.isNode()?n.drawNodeOverlay(e,t):n.drawEdgeOverlay(e,t)},drawCachedElementPortion:function(e,t,n,r,i,a,o){var s=this,l=n.getBoundingBox(t);if(0!==l.w&&0!==l.h){var u=n.getElement(t,l,r,i,a);if(null!=u){var c=t.effectiveOpacity();if(0===c)return;var d,h,p,f,g,v,y=o(s,t),m=l.x1,b=l.y1,x=l.w,w=l.h;if(0!==y){var E=n.getRotationPoint(t);p=E.x,f=E.y,e.translate(p,f),e.rotate(y),g=s.getImgSmoothing(e),g||s.setImgSmoothing(e,!0);var _=n.getRotationOffset(t);d=_.x,h=_.y}else d=m,h=b;1!==c&&(v=e.globalAlpha,e.globalAlpha=v*c),e.drawImage(u.texture.canvas,u.x,0,u.width,u.height,d,h,x,w),1!==c&&(e.globalAlpha=v),0!==y&&(e.rotate(-y),e.translate(-p,-f),g||s.setImgSmoothing(e,!1))}else n.drawElement(e,t)}}},au=function(){return 0},ou=function(e,t){return e.getTextAngle(t,null)},su=function(e,t){return e.getTextAngle(t,"source")},lu=function(e,t){return e.getTextAngle(t,"target")};iu.drawCachedElement=function(e,t,n,r,i,a){var o=this,s=o.data,l=s.eleTxrCache,u=s.lblTxrCache,c=s.slbTxrCache,d=s.tlbTxrCache,h=t.boundingBox(),p=!0===a?l.reasons.highQuality:null;0!==h.w&&0!==h.h&&t.visible()&&(r&&!Rt(h,r)||(o.drawCachedElementPortion(e,t,l,n,i,p,au),o.drawCachedElementPortion(e,t,u,n,i,p,ou),t.isEdge()&&(o.drawCachedElementPortion(e,t,c,n,i,p,su),o.drawCachedElementPortion(e,t,d,n,i,p,lu)),o.drawElementOverlay(e,t)))},iu.drawElements=function(e,t){for(var n=this,r=0;r<t.length;r++){var i=t[r];n.drawElement(e,i)}},iu.drawCachedElements=function(e,t,n,r){for(var i=this,a=0;a<t.length;a++){var o=t[a];i.drawCachedElement(e,o,n,r)}},iu.drawCachedNodes=function(e,t,n,r){for(var i=this,a=0;a<t.length;a++){var o=t[a];o.isNode()&&i.drawCachedElement(e,o,n,r)}},iu.drawLayeredElements=function(e,t,n,r){var i=this,a=i.data.lyrTxrCache.getLayers(t,n);if(a)for(var o=0;o<a.length;o++){var s=a[o],l=s.bb;0!==l.w&&0!==l.h&&e.drawImage(s.canvas,l.x1,l.y1,l.w,l.h)}else i.drawCachedElements(e,t,n,r)};var uu={drawEdge:function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],o=this,s=t._private.rscratch;if(t.visible()&&!s.badLine&&null!=s.allpts&&!isNaN(s.allpts[0])){var l;n&&(l=n,e.translate(-l.x1,-l.y1));var u=a?t.pstyle("opacity").value:1,c=t.pstyle("line-style").value,d=t.pstyle("width").pfValue,h=t.pstyle("line-cap").value,p=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;e.lineWidth=d,e.lineCap=h,o.eleStrokeStyle(e,t,n),o.drawEdgePath(t,e,s.allpts,c),e.lineCap="butt"},f=function(){i&&o.drawEdgeOverlay(e,t)},g=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;o.drawArrowheads(e,t,n)},v=function(){o.drawElementText(e,t,null,r)};e.lineJoin="round";var y="yes"===t.pstyle("ghost").value;if(y){var m=t.pstyle("ghost-offset-x").pfValue,b=t.pstyle("ghost-offset-y").pfValue,x=t.pstyle("ghost-opacity").value,w=u*x;e.translate(m,b),p(w),g(w),e.translate(-m,-b)}p(),g(),f(),v(),n&&e.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,i=r.usePaths(),a=t._private.rscratch,o=t.pstyle("overlay-padding").pfValue,s=2*o,l=t.pstyle("overlay-color").value;e.lineWidth=s,"self"!==a.edgeType||i?e.lineCap="round":e.lineCap="butt",r.colorStrokeStyle(e,l[0],l[1],l[2],n),r.drawEdgePath(t,e,a.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 d=n.join("$"),h=a.pathCacheKey&&a.pathCacheKey===d;h?(i=t=a.pathCache,s=!0):(i=t=new Path2D,a.pathCacheKey=d,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([]);break}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 p=2;p+3<n.length;p+=4)t.quadraticCurveTo(n[p],n[p+1],n[p+2],n[p+3]);break;case"straight":case"segments":case"haystack":for(var f=2;f+1<n.length;f+=2)t.lineTo(n[f],n[f+1]);break}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=this,l=t.pstyle(n+"-arrow-shape").value;if("none"!==l){var u="hollow"===t.pstyle(n+"-arrow-fill").value?"both":"filled",c=t.pstyle(n+"-arrow-fill").value,d=t.pstyle("width").pfValue,h=t.pstyle("opacity").value;void 0===o&&(o=h);var p=e.globalCompositeOperation;1===o&&"hollow"!==c||(e.globalCompositeOperation="destination-out",s.colorFillStyle(e,255,255,255,1),s.colorStrokeStyle(e,255,255,255,1),s.drawArrowShape(t,e,u,d,l,r,i,a),e.globalCompositeOperation=p);var f=t.pstyle(n+"-arrow-color").value;s.colorFillStyle(e,f[0],f[1],f[2],o),s.colorStrokeStyle(e,f[0],f[1],f[2],o),s.drawArrowShape(t,e,c,d,l,r,i,a)}}},drawArrowShape:function(e,t,n,r,i,a,o,s){var l,u=this,c=this.usePaths()&&"triangle-cross"!==i,d=!1,h=t,p={x:a,y:o},f=e.pstyle("arrow-scale").value,g=this.getArrowWidth(r,f),v=u.arrowShapes[i];if(c){var y=u.arrowPathCache=u.arrowPathCache||[],m=me(i),b=y[m];null!=b?(l=t=b,d=!0):(l=t=new Path2D,y[m]=l)}t.beginPath&&t.beginPath(),d||(c?v.draw(t,1,0,{x:0,y:0},1):v.draw(t,g,s,p,r)),t.closePath&&t.closePath(),t=h,c&&(t.translate(a,o),t.rotate(s),t.scale(g,g)),"filled"!==n&&"both"!==n||(c?t.fill(l):t.fill()),"hollow"!==n&&"both"!==n||(t.lineWidth=(v.matchEdgeWidth?r:1)/(c?g:1),t.lineJoin="miter",c?t.stroke(l):t.stroke()),c&&(t.scale(1/g,1/g),t.rotate(-s),t.translate(-a,-o))}},cu={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=this,o=n.position(),s=o.x,l=o.y,u=n.cy().style(),c=u.getIndexedStyle.bind(u),d=c(n,"background-fit","value",r),h=c(n,"background-repeat","value",r),p=n.width(),f=n.height(),g=2*n.padding(),v=p+("inner"===c(n,"background-width-relative-to","value",r)?0:g),y=f+("inner"===c(n,"background-height-relative-to","value",r)?0:g),m=n._private.rscratch,b=n.pstyle("background-clip").value,x="node"===b,w=c(n,"background-image-opacity","value",r)*i,E=t.width||t.cachedW,_=t.height||t.cachedH;null!=E&&null!=_||(document.body.appendChild(t),E=t.cachedW=t.width||t.offsetWidth,_=t.cachedH=t.height||t.offsetHeight,document.body.removeChild(t));var k=E,C=_;if("auto"!==c(n,"background-width","value",r)&&(k="%"===c(n,"background-width","units",r)?c(n,"background-width","pfValue",r)*v:c(n,"background-width","pfValue",r)),"auto"!==c(n,"background-height","value",r)&&(C="%"===c(n,"background-height","units",r)?c(n,"background-height","pfValue",r)*y:c(n,"background-height","pfValue",r)),0!==k&&0!==C){if("contain"===d){var T=Math.min(v/k,y/C);k*=T,C*=T}else if("cover"===d){T=Math.max(v/k,y/C);k*=T,C*=T}var S=s-v/2,D=c(n,"background-position-x","units",r),P=c(n,"background-position-x","pfValue",r);S+="%"===D?(v-k)*P:P;var M=c(n,"background-offset-x","units",r),N=c(n,"background-offset-x","pfValue",r);S+="%"===M?(v-k)*N:N;var z=l-y/2,B=c(n,"background-position-y","units",r),O=c(n,"background-position-y","pfValue",r);z+="%"===B?(y-C)*O:O;var L=c(n,"background-offset-y","units",r),A=c(n,"background-offset-y","pfValue",r);z+="%"===L?(y-C)*A:A,m.pathCache&&(S-=s,z-=l,s=0,l=0);var I=e.globalAlpha;if(e.globalAlpha=w,"no-repeat"===h)x&&(e.save(),m.pathCache?e.clip(m.pathCache):(a.nodeShapes[a.getNodeShape(n)].draw(e,s,l,v,y),e.clip())),a.safeDrawImage(e,t,0,0,E,_,S,z,k,C),x&&e.restore();else{var R=e.createPattern(t,h);e.fillStyle=R,a.nodeShapes[a.getNodeShape(n)].draw(e,s,l,v,y),e.translate(S,z),e.fill(),e.translate(-S,-z)}e.globalAlpha=I}}},du={};function hu(e,t,n,r,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:5;e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath(),e.fill()}du.eleTextBiggerThanMin=function(e,t){if(!t){var n=e.cy().zoom(),r=this.getPixelRatio(),i=Math.ceil(wt(n*r));t=Math.pow(2,i)}var a=e.pstyle("font-size").pfValue*t,o=e.pstyle("min-zoomed-font-size").pfValue;return!(a<o)},du.drawElementText=function(e,t,n,r,i){var a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],o=this;if(null==r){if(!o.eleTextBiggerThanMin(t))return}else if(!1===r)return;if(t.isNode()){var s=t.pstyle("label");if(!s||!s.value)return;var l=o.getLabelJustification(t);e.textAlign=l,e.textBaseline="bottom"}else{var u=t.pstyle("label"),c=t.pstyle("source-label"),d=t.pstyle("target-label");if((!u||!u.value)&&(!c||!c.value)&&(!d||!d.value))return;e.textAlign="center",e.textBaseline="bottom"}var h,p=!n;n&&(h=n,e.translate(-h.x1,-h.y1)),null==i?(o.drawText(e,t,null,p,a),t.isEdge()&&(o.drawText(e,t,"source",p,a),o.drawText(e,t,"target",p,a))):o.drawText(e,t,i,p,a),n&&e.translate(h.x1,h.y1)},du.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n<this.fontCaches.length;n++)if(t=this.fontCaches[n],t.context===e)return t;return t={context:e},this.fontCaches.push(t),t},du.setupTextStyle=function(e,t){var n=!(arguments.length>2&&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)},du.getTextAngle=function(e,t){var n,r=e._private,i=r.rscratch,a=t?t+"-":"",o=e.pstyle(a+"text-rotation"),s=qe(i,"labelAngle",t);return n="autorotate"===o.strValue?e.isEdge()?s:0:"none"===o.strValue?0:o.pfValue,n},du.drawText=function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=t._private,o=a.rscratch,s=i?t.effectiveOpacity():1;if(0!==s&&0!==t.pstyle("text-opacity").value){"main"===n&&(n=null);var l,u,c=qe(o,"labelX",n),d=qe(o,"labelY",n),h=this.getLabelText(t,n);if(null!=h&&""!==h&&!isNaN(c)&&!isNaN(d)){this.setupTextStyle(e,t,i);var p,f=n?n+"-":"",g=qe(o,"labelWidth",n),v=qe(o,"labelHeight",n),y=t.pstyle(f+"text-margin-x").pfValue,m=t.pstyle(f+"text-margin-y").pfValue,b=t.isEdge(),x=t.pstyle("text-halign").value,w=t.pstyle("text-valign").value;switch(b&&(x="center",w="center"),c+=y,d+=m,p=r?this.getTextAngle(t,n):0,0!==p&&(l=c,u=d,e.translate(l,u),e.rotate(p),c=0,d=0),w){case"top":break;case"center":d+=v/2;break;case"bottom":d+=v;break}var E=t.pstyle("text-background-opacity").value,_=t.pstyle("text-border-opacity").value,k=t.pstyle("text-border-width").pfValue,C=t.pstyle("text-background-padding").pfValue;if(E>0||k>0&&_>0){var T=c-C;switch(x){case"left":T-=g;break;case"center":T-=g/2;break;case"right":break}var S=d-v-C,D=g+2*C,P=v+2*C;if(E>0){var M=e.fillStyle,N=t.pstyle("text-background-color").value;e.fillStyle="rgba("+N[0]+","+N[1]+","+N[2]+","+E*s+")";var z=t.pstyle("text-background-shape").strValue;"roundrectangle"==z?hu(e,T,S,D,P,2):e.fillRect(T,S,D,P),e.fillStyle=M}if(k>0&&_>0){var B=e.strokeStyle,O=e.lineWidth,L=t.pstyle("text-border-color").value,A=t.pstyle("text-border-style").value;if(e.strokeStyle="rgba("+L[0]+","+L[1]+","+L[2]+","+_*s+")",e.lineWidth=k,e.setLineDash)switch(A){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=k/4,e.setLineDash([]);break;case"solid":e.setLineDash([]);break}if(e.strokeRect(T,S,D,P),"double"===A){var I=k/2;e.strokeRect(T+I,S+I,D-2*I,P-2*I)}e.setLineDash&&e.setLineDash([]),e.lineWidth=O,e.strokeStyle=B}}var R=2*t.pstyle("text-outline-width").pfValue;if(R>0&&(e.lineWidth=R),"wrap"===t.pstyle("text-wrap").value){var F=qe(o,"labelWrapCachedLines",n),V=qe(o,"labelLineHeight",n),j=g/2,q=this.getLabelJustification(t);switch("auto"===q||("left"===x?"left"===q?c+=-g:"center"===q&&(c+=-j):"center"===x?"left"===q?c+=-j:"right"===q&&(c+=j):"right"===x&&("center"===q?c+=j:"right"===q&&(c+=g))),w){case"top":d-=(F.length-1)*V;break;case"center":case"bottom":d-=(F.length-1)*V;break}for(var X=0;X<F.length;X++)R>0&&e.strokeText(F[X],c,d),e.fillText(F[X],c,d),d+=V}else R>0&&e.strokeText(h,c,d),e.fillText(h,c,d);0!==p&&(e.rotate(-p),e.translate(-l,-u))}}};var pu={drawNode:function(e,t,n){var r,i,a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],l=this,u=t._private,c=u.rscratch,d=t.position();if(S(d.x)&&S(d.y)&&t.visible()){var h,p,f=s?t.effectiveOpacity():1,g=l.usePaths(),v=!1,y=t.padding();r=t.width()+2*y,i=t.height()+2*y,n&&(p=n,e.translate(-p.x1,-p.y1));for(var m=t.pstyle("background-image"),b=m.value,x=new Array(b.length),w=new Array(b.length),E=0,_=0;_<b.length;_++){var k=b[_],C=x[_]=null!=k&&"none"!==k;if(C){var T=t.cy().style().getIndexedStyle(t,"background-image-crossorigin","value",_);E++,w[_]=l.getCachedImage(k,T,function(){u.backgroundTimestamp=Date.now(),t.emitAndNotify("background")})}}var D=t.pstyle("background-blacken").value,P=t.pstyle("border-width").pfValue,M=t.pstyle("background-opacity").value*f,N=t.pstyle("border-color").value,z=t.pstyle("border-style").value,B=t.pstyle("border-opacity").value*f;e.lineJoin="miter";var O=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:M;l.eleFillStyle(e,t,n)},L=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:B;l.colorStrokeStyle(e,N[0],N[1],N[2],t)},A=t.pstyle("shape").strValue,I=t.pstyle("shape-polygon-points").pfValue;if(g){e.translate(d.x,d.y);var R=l.nodePathCache=l.nodePathCache||[],F=be("polygon"===A?A+","+I.join(","):A,""+i,""+r),V=R[F];null!=V?(h=V,v=!0,c.pathCache=h):(h=new Path2D,R[F]=c.pathCache=h)}var j=function(){if(!v){var n=d;g&&(n={x:0,y:0}),l.nodeShapes[l.getNodeShape(t)].draw(h||e,n.x,n.y,r,i)}g?e.fill(h):e.fill()},q=function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f,r=u.backgrounding,i=0,a=0;a<w.length;a++)x[a]&&w[a].complete&&!w[a].error&&(i++,l.drawInscribedImage(e,w[a],t,a,n));u.backgrounding=!(i===E),r!==u.backgrounding&&t.updateStyle(!1)},X=function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f;l.hasPie(t)&&(l.drawPie(e,t,a),n&&(g||l.nodeShapes[l.getNodeShape(t)].draw(e,d.x,d.y,r,i)))},Y=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f,n=(D>0?D:-D)*t,r=D>0?0:255;0!==D&&(l.colorFillStyle(e,r,r,r,n),g?e.fill(h):e.fill())},H=function(){if(P>0){if(e.lineWidth=P,e.lineCap="butt",e.setLineDash)switch(z){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([]);break}if(g?e.stroke(h):e.stroke(),"double"===z){e.lineWidth=P/3;var t=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",g?e.stroke(h):e.stroke(),e.globalCompositeOperation=t}e.setLineDash&&e.setLineDash([])}},G=function(){o&&l.drawNodeOverlay(e,t,d,r,i)},W=function(){l.drawElementText(e,t,null,a)},$="yes"===t.pstyle("ghost").value;if($){var U=t.pstyle("ghost-offset-x").pfValue,K=t.pstyle("ghost-offset-y").pfValue,Z=t.pstyle("ghost-opacity").value,Q=Z*f;e.translate(U,K),O(Z*M),j(),q(Q),X(0!==D||0!==P),Y(Q),L(Z*B),H(),e.translate(-U,-K)}O(),j(),q(),X(0!==D||0!==P),Y(),L(),H(),g&&e.translate(-d.x,-d.y),W(),G(),n&&e.translate(p.x1,p.y1)}},drawNodeOverlay:function(e,t,n,r,i){var a=this;if(t.visible()){var o=t.pstyle("overlay-padding").pfValue,s=t.pstyle("overlay-opacity").value,l=t.pstyle("overlay-color").value;if(s>0){if(n=n||t.position(),null==r||null==i){var u=t.padding();r=t.width()+2*u,i=t.height()+2*u}a.colorFillStyle(e,l[0],l[1],l[2],s),a.nodeShapes["roundrectangle"].draw(e,n.x,n.y,r+2*o,i+2*o),e.fill()}}},hasPie:function(e){return e=e[0],e._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,d=0,h=this.usePaths();h&&(o=0,s=0),"%"===a.units?c*=a.pfValue:void 0!==a.pfValue&&(c=a.pfValue/2);for(var p=1;p<=i.pieBackgroundN;p++){var f=t.pstyle("pie-"+p+"-background-size").value,g=t.pstyle("pie-"+p+"-background-color").value,v=t.pstyle("pie-"+p+"-background-opacity").value*n,y=f/100;y+d>1&&(y=1-d);var m=1.5*Math.PI+2*Math.PI*d,b=2*Math.PI*y,x=m+b;0===f||d>=1||d+y>1||(e.beginPath(),e.moveTo(o,s),e.arc(o,s,c,m,x),e.closePath(),this.colorFillStyle(e,g[0],g[1],g[2],v),e.fill(),d+=y)}}},fu={},gu=100;fu.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},fu.paintCache=function(e){for(var t,n=this.paintCaches=this.paintCaches||[],r=!0,i=0;i<n.length;i++)if(t=n[i],t.context===e){r=!1;break}return r&&(t={context:e},n.push(t)),t},fu.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(),d=n.midpoint(),h=_t(u,d),p=_t(c,d);a=e.createRadialGradient(d.x,d.y,0,d.x,d.y,Math.max(h,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(),w=n.height(),E=x/2,_=w/2,k=n.pstyle("background-gradient-direction").value;switch(k){case"to-bottom":a=e.createLinearGradient(b.x,b.y-_,b.x,b.y+_);break;case"to-top":a=e.createLinearGradient(b.x,b.y+_,b.x,b.y-_);break;case"to-left":a=e.createLinearGradient(b.x-E,b.y,b.x+E,b.y);break;case"to-right":a=e.createLinearGradient(b.x+E,b.y,b.x-E,b.y);break;case"to-bottom-right":case"to-right-bottom":a=e.createLinearGradient(b.x-E,b.y-_,b.x+E,b.y+_);break;case"to-top-right":case"to-right-top":a=e.createLinearGradient(b.x-E,b.y+_,b.x+E,b.y-_);break;case"to-bottom-left":case"to-left-bottom":a=e.createLinearGradient(b.x+E,b.y-_,b.x-E,b.y+_);break;case"to-top-left":case"to-left-top":a=e.createLinearGradient(b.x+E,b.y+_,b.x-E,b.y-_);break}}if(!a)return null;for(var C=l.length===s.length,T=s.length,S=0;S<T;S++)a.addColorStop(C?l[S]:S/(T-1),"rgba("+s[S][0]+","+s[S][1]+","+s[S][2]+","+i+")");return a},fu.gradientFillStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,"background",t,n,r);if(!i)return null;e.fillStyle=i},fu.colorFillStyle=function(e,t,n,r,i){e.fillStyle="rgba("+t+","+n+","+r+","+i+")"},fu.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)}},fu.gradientStrokeStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,"line",t,n,r);if(!i)return null;e.strokeStyle=i},fu.colorStrokeStyle=function(e,t,n,r,i){e.strokeStyle="rgba("+t+","+n+","+r+","+i+")"},fu.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)}},fu.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 d=n.canvasContainer;d.style.width=i+"px",d.style.height=a+"px";for(var h=0;h<t.CANVAS_LAYERS;h++)l=n.canvases[h],l.width=u,l.height=c,l.style.width=i+"px",l.style.height=a+"px";for(h=0;h<t.BUFFER_COUNT;h++)l=n.bufferCanvases[h],l.width=u,l.height=c,l.style.width=i+"px",l.style.height=a+"px";t.textureMult=1,o<=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}},fu.renderTo=function(e,t,n,r){this.render({forcedContext:e,forcedZoom:t,forcedPan:n,drawAllLayers:!0,forcedPxRatio:r})},fu.render=function(e){e=e||Ie();var t=e.forcedContext,n=e.drawAllLayers,r=e.drawOnlyNodeLayer,i=e.forcedZoom,a=e.forcedPan,o=this,s=void 0===e.forcedPxRatio?this.getPixelRatio():e.forcedPxRatio,l=o.cy,u=o.data,c=u.canvasNeedsRedraw,d=o.textureOnViewport&&!t&&(o.pinching||o.hoverData.dragging||o.swipePanning||o.data.wheelZooming),h=void 0!==e.motionBlur?e.motionBlur:o.motionBlur,p=o.motionBlurPxRatio,f=l.hasCompoundNodes(),g=o.hoverData.draggingEles,v=!(!o.hoverData.selecting&&!o.touchData.selecting);h=h&&!t&&o.motionBlurEnabled&&!v;var y=h;t||(o.prevPxRatio!==s&&(o.invalidateContainerClientCoordsCache(),o.matchCanvasSize(o.container),o.redrawHint("eles",!0),o.redrawHint("drag",!0)),o.prevPxRatio=s),!t&&o.motionBlurTimeout&&clearTimeout(o.motionBlurTimeout),h&&(null==o.mbFrames&&(o.mbFrames=0),o.mbFrames++,o.mbFrames<3&&(y=!1),o.mbFrames>o.minMbLowQualFrames&&(o.motionBlurPxRatio=o.mbPxRBlurry)),o.clearingMotionBlur&&(o.motionBlurPxRatio=1),o.textureDrawLastFrame&&!d&&(c[o.NODE]=!0,c[o.SELECT_BOX]=!0);var m=l.style(),b=l.zoom(),x=void 0!==i?i:b,w=l.pan(),E={x:w.x,y:w.y},_={zoom:b,pan:{x:w.x,y:w.y}},k=o.prevViewport,C=void 0===k||_.zoom!==k.zoom||_.pan.x!==k.pan.x||_.pan.y!==k.pan.y;C||g&&!f||(o.motionBlurPxRatio=1),a&&(E=a),x*=s,E.x*=s,E.y*=s;var T=o.getCachedZSortedEles();function S(e,t,n,r,i){var a=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",o.colorFillStyle(e,255,255,255,o.motionBlurTransparency),e.fillRect(t,n,r,i),e.globalCompositeOperation=a}function D(e,r){var s,l,c,d;o.clearingMotionBlur||e!==u.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]&&e!==u.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]?(s=E,l=x,c=o.canvasWidth,d=o.canvasHeight):(s={x:w.x*p,y:w.y*p},l=b*p,c=o.canvasWidth*p,d=o.canvasHeight*p),e.setTransform(1,0,0,1,0,0),"motionBlur"===r?S(e,0,0,c,d):t||void 0!==r&&!r||e.clearRect(0,0,c,d),n||(e.translate(s.x,s.y),e.scale(l,l)),a&&e.translate(a.x,a.y),i&&e.scale(i,i)}if(d||(o.textureDrawLastFrame=!1),d){if(o.textureDrawLastFrame=!0,!o.textureCache){o.textureCache={},o.textureCache.bb=l.mutableElements().boundingBox(),o.textureCache.texture=o.data.bufferCanvases[o.TEXTURE_BUFFER];var P=o.data.bufferContexts[o.TEXTURE_BUFFER];P.setTransform(1,0,0,1,0,0),P.clearRect(0,0,o.canvasWidth*o.textureMult,o.canvasHeight*o.textureMult),o.render({forcedContext:P,drawOnlyNodeLayer:!0,forcedPxRatio:s*o.textureMult});_=o.textureCache.viewport={zoom:l.zoom(),pan:l.pan(),width:o.canvasWidth,height:o.canvasHeight};_.mpan={x:(0-_.pan.x)/_.zoom,y:(0-_.pan.y)/_.zoom}}c[o.DRAG]=!1,c[o.NODE]=!1;var M=u.contexts[o.NODE],N=o.textureCache.texture;_=o.textureCache.viewport;M.setTransform(1,0,0,1,0,0),h?S(M,0,0,_.width,_.height):M.clearRect(0,0,_.width,_.height);var z=m.core("outside-texture-bg-color").value,B=m.core("outside-texture-bg-opacity").value;o.colorFillStyle(M,z[0],z[1],z[2],B),M.fillRect(0,0,_.width,_.height);b=l.zoom();D(M,!1),M.clearRect(_.mpan.x,_.mpan.y,_.width/_.zoom/s,_.height/_.zoom/s),M.drawImage(N,_.mpan.x,_.mpan.y,_.width/_.zoom/s,_.height/_.zoom/s)}else o.textureOnViewport&&!t&&(o.textureCache=null);var O=l.extent(),L=o.pinching||o.hoverData.dragging||o.swipePanning||o.data.wheelZooming||o.hoverData.draggingEles,A=o.hideEdgesOnViewport&&L,I=[];if(I[o.NODE]=!c[o.NODE]&&h&&!o.clearedForMotionBlur[o.NODE]||o.clearingMotionBlur,I[o.NODE]&&(o.clearedForMotionBlur[o.NODE]=!0),I[o.DRAG]=!c[o.DRAG]&&h&&!o.clearedForMotionBlur[o.DRAG]||o.clearingMotionBlur,I[o.DRAG]&&(o.clearedForMotionBlur[o.DRAG]=!0),c[o.NODE]||n||r||I[o.NODE]){var R=h&&!I[o.NODE]&&1!==p,F=(M=t||(R?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]:u.contexts[o.NODE]),h&&!R?"motionBlur":void 0);D(M,F),A?o.drawCachedNodes(M,T.nondrag,s,O):o.drawLayeredElements(M,T.nondrag,s,O),o.debug&&o.drawDebugPoints(M,T.nondrag),n||h||(c[o.NODE]=!1)}if(!r&&(c[o.DRAG]||n||I[o.DRAG])){R=h&&!I[o.DRAG]&&1!==p,M=t||(R?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]:u.contexts[o.DRAG]);D(M,h&&!R?"motionBlur":void 0),A?o.drawCachedNodes(M,T.drag,s,O):o.drawCachedElements(M,T.drag,s,O),o.debug&&o.drawDebugPoints(M,T.drag),n||h||(c[o.DRAG]=!1)}if(o.showFps||!r&&c[o.SELECT_BOX]&&!n){M=t||u.contexts[o.SELECT_BOX];if(D(M),1==o.selection[4]&&(o.hoverData.selecting||o.touchData.selecting)){b=o.cy.zoom();var V=m.core("selection-box-border-width").value/b;M.lineWidth=V,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(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]),V>0&&(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(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]))}if(u.bgActivePosistion&&!o.hoverData.selecting){b=o.cy.zoom();var j=u.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(j.x,j.y,m.core("active-bg-size").pfValue/b,0,2*Math.PI),M.fill()}var q=o.lastRedrawTime;if(o.showFps&&q){q=Math.round(q);var X=Math.round(1e3/q);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 = "+q+" ms = "+X+" fps",0,20);var Y=60;M.strokeRect(0,30,250,20),M.fillRect(0,30,250*Math.min(X/Y,1),20)}n||(c[o.SELECT_BOX]=!1)}if(h&&1!==p){var H=u.contexts[o.NODE],G=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_NODE],W=u.contexts[o.DRAG],$=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_DRAG],U=function(e,t,n){e.setTransform(1,0,0,1,0,0),n||!y?e.clearRect(0,0,o.canvasWidth,o.canvasHeight):S(e,0,0,o.canvasWidth,o.canvasHeight);var r=p;e.drawImage(t,0,0,o.canvasWidth*r,o.canvasHeight*r,0,0,o.canvasWidth,o.canvasHeight)};(c[o.NODE]||I[o.NODE])&&(U(H,G,I[o.NODE]),c[o.NODE]=!1),(c[o.DRAG]||I[o.DRAG])&&(U(W,$,I[o.DRAG]),c[o.DRAG]=!1)}o.prevViewport=_,o.clearingMotionBlur&&(o.clearingMotionBlur=!1,o.motionBlurCleared=!0,o.motionBlur=!0),h&&(o.motionBlurTimeout=setTimeout(function(){o.motionBlurTimeout=null,o.clearedForMotionBlur[o.NODE]=!1,o.clearedForMotionBlur[o.DRAG]=!1,o.motionBlur=!1,o.clearingMotionBlur=!d,o.mbFrames=0,c[o.NODE]=!0,c[o.DRAG]=!0,o.redraw()},gu)),t||l.emit("render")};for(var vu={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=cn(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=cn(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,s=dn();e.beginPath&&e.beginPath(),e.moveTo(t-a+s,n-o),e.lineTo(t+a-s,n-o),e.lineTo(t+a,n-o+s),e.lineTo(t+a,n+o-s),e.lineTo(t+a-s,n+o),e.lineTo(t-a+s,n+o),e.lineTo(t-a,n+o-s),e.lineTo(t-a,n-o+s),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,d=pn(r,i),h=d.widthOffset,p=d.heightOffset,f=d.ctrlPtOffsetPct*h;e.beginPath&&e.beginPath(),e.moveTo(s,u+p),e.lineTo(s,c-p),e.quadraticCurveTo(s+f,c,s+h,c),e.lineTo(l-h,c),e.quadraticCurveTo(l-f,c,l,c-p),e.lineTo(l,u+p),e.quadraticCurveTo(l-f,u,l-h,u),e.lineTo(s+h,u),e.quadraticCurveTo(s+f,u,s,u+p),e.closePath()}},yu=Math.sin(0),mu=Math.cos(0),bu={},xu={},wu=Math.PI/40,Eu=0*Math.PI;Eu<2*Math.PI;Eu+=wu)bu[Eu]=Math.sin(Eu),xu[Eu]=Math.cos(Eu);vu.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+=wu)a=t-s*bu[u]*yu+s*xu[u]*mu,o=n+l*xu[u]*yu+l*bu[u]*mu,0===u?e.moveTo(a,o):e.lineTo(a,o);e.closePath()};var _u={};function ku(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})}function Cu(e){var t=e.indexOf(",");return e.substr(t+1)}function Tu(e,t,n){var r=function(){return t.toDataURL(n,e.quality)};switch(e.output){case"blob-promise":return new Ir(function(r,i){try{t.toBlob(function(e){null!=e?r(e):i(new Error("`canvas.toBlob()` sent a null value in its callback"))},n,e.quality)}catch(a){i(a)}});case"blob":return ku(Cu(r()),n);case"base64":return Cu(r());case"base64uri":default:return r()}}_u.createBuffer=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,[n,n.getContext("2d")]},_u.bufferCanvasImage=function(e){var t=this.cy,n=t.mutableElements(),r=n.boundingBox(),i=this.findContainerClientCoords(),a=e.full?Math.ceil(r.w):i[2],o=e.full?Math.ceil(r.h):i[3],s=S(e.maxWidth)||S(e.maxHeight),l=this.getPixelRatio(),u=1;if(void 0!==e.scale)a*=e.scale,o*=e.scale,u=e.scale;else if(s){var c=1/0,d=1/0;S(e.maxWidth)&&(c=u*e.maxWidth/a),S(e.maxHeight)&&(d=u*e.maxHeight/o),u=Math.min(c,d),a*=u,o*=u}s||(a*=l,o*=l,u*=l);var h=document.createElement("canvas");h.width=a,h.height=o,h.style.width=a+"px",h.style.height=o+"px";var p=h.getContext("2d");if(a>0&&o>0){p.clearRect(0,0,a,o),p.globalCompositeOperation="source-over";var f=this.getCachedZSortedEles();if(e.full)p.translate(-r.x1*u,-r.y1*u),p.scale(u,u),this.drawElements(p,f),p.scale(1/u,1/u),p.translate(r.x1*u,r.y1*u);else{var g=t.pan(),v={x:g.x*u,y:g.y*u};u*=t.zoom(),p.translate(v.x,v.y),p.scale(u,u),this.drawElements(p,f),p.scale(1/u,1/u),p.translate(-v.x,-v.y)}e.bg&&(p.globalCompositeOperation="destination-over",p.fillStyle=e.bg,p.rect(0,0,a,o),p.fill())}return h},_u.png=function(e){return Tu(e,this.bufferCanvasImage(e),"image/png")},_u.jpg=function(e){return Tu(e,this.bufferCanvasImage(e),"image/jpeg")};var Su={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)}}},Du=Mu,Pu=Mu.prototype;function Mu(e){var t=this;t.data={canvases:new Array(Pu.CANVAS_LAYERS),contexts:new Array(Pu.CANVAS_LAYERS),canvasNeedsRedraw:new Array(Pu.CANVAS_LAYERS),bufferCanvases:new Array(Pu.BUFFER_COUNT),bufferContexts:new Array(Pu.CANVAS_LAYERS)};var n="-webkit-tap-highlight-color",r="rgba(0,0,0,0)";t.data.canvasContainer=document.createElement("div");var i=t.data.canvasContainer.style;t.data.canvasContainer.style[n]=r,i.position="relative",i.zIndex="0",i.overflow="hidden";var a=e.cy.container();a.appendChild(t.data.canvasContainer),a.style[n]=r;var o={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};V()&&(o["-ms-touch-action"]="none",o["touch-action"]="none");for(var s=0;s<Pu.CANVAS_LAYERS;s++){var l=t.data.canvases[s]=document.createElement("canvas");t.data.contexts[s]=l.getContext("2d"),Object.keys(o).forEach(function(e){l.style[e]=o[e]}),l.style.position="absolute",l.setAttribute("data-id","layer"+s),l.style.zIndex=String(Pu.CANVAS_LAYERS-s),t.data.canvasContainer.appendChild(l),t.data.canvasNeedsRedraw[s]=!1}t.data.topCanvas=t.data.canvases[0],t.data.canvases[Pu.NODE].setAttribute("data-id","layer"+Pu.NODE+"-node"),t.data.canvases[Pu.SELECT_BOX].setAttribute("data-id","layer"+Pu.SELECT_BOX+"-selectbox"),t.data.canvases[Pu.DRAG].setAttribute("data-id","layer"+Pu.DRAG+"-drag");for(s=0;s<Pu.BUFFER_COUNT;s++)t.data.bufferCanvases[s]=document.createElement("canvas"),t.data.bufferContexts[s]=t.data.bufferCanvases[s].getContext("2d"),t.data.bufferCanvases[s].style.position="absolute",t.data.bufferCanvases[s].setAttribute("data-id","buffer"+s),t.data.bufferCanvases[s].style.zIndex=String(-s-1),t.data.bufferCanvases[s].style.visibility="hidden";t.pathsEnabled=!0;var u=Mt(),c=function(e){return{x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2}},d=function(e){return{x:-e.w/2,y:-e.h/2}},h=function(e){var t=e[0]._private,n=t.oldBackgroundTimestamp===t.backgroundTimestamp;return!n},p=function(e){return e[0]._private.nodeKey},f=function(e){return e[0]._private.labelStyleKey},g=function(e){return e[0]._private.sourceLabelStyleKey},v=function(e){return e[0]._private.targetLabelStyleKey},y=function(e,n,r,i,a){return t.drawElement(e,n,r,!1,!1,a)},m=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,"main",a)},b=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,"source",a)},x=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,"target",a)},w=function(e){return e.boundingBox(),e[0]._private.bodyBounds},E=function(e){return e.boundingBox(),e[0]._private.labelBounds.main||u},_=function(e){return e.boundingBox(),e[0]._private.labelBounds.source||u},k=function(e){return e.boundingBox(),e[0]._private.labelBounds.target||u},C=function(e,t){return t},T=function(e){return c(w(e))},S=function(e,t){return{x:e.x+t.pstyle("text-margin-x").pfValue,y:e.y+t.pstyle("text-margin-y").pfValue}},D=function(e,t,n){var r=e[0]._private.rscratch;return{x:r[t],y:r[n]}},P=function(e){return S(D(e,"labelX","labelY"),e)},M=function(e){return S(D(e,"sourceLabelX","sourceLabelY"),e)},N=function(e){return S(D(e,"targetLabelX","targetLabelY"),e)},z=function(e){return d(w(e))},B=function(e){return d(_(e))},O=function(e){return d(k(e))},L=function(e){var t=E(e),n=d(E(e));if(e.isNode()){switch(e.pstyle("text-halign").value){case"left":n.x=-t.w;break;case"right":n.x=0;break}switch(e.pstyle("text-valign").value){case"top":n.y=-t.h;break;case"bottom":n.y=0;break}}return n},A=t.data.eleTxrCache=new zl(t,{getKey:p,doesEleInvalidateKey:h,drawElement:y,getBoundingBox:w,getRotationPoint:T,getRotationOffset:z,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),I=t.data.lblTxrCache=new zl(t,{getKey:f,drawElement:m,getBoundingBox:E,getRotationPoint:P,getRotationOffset:L,isVisible:C}),R=t.data.slbTxrCache=new zl(t,{getKey:g,drawElement:b,getBoundingBox:_,getRotationPoint:M,getRotationOffset:B,isVisible:C}),F=t.data.tlbTxrCache=new zl(t,{getKey:v,drawElement:x,getBoundingBox:k,getRotationPoint:N,getRotationOffset:O,isVisible:C}),j=t.data.lyrTxrCache=new $l(t);t.onUpdateEleCalcs(function(e,t){A.invalidateElements(t),I.invalidateElements(t),R.invalidateElements(t),F.invalidateElements(t),j.invalidateElements(t);for(var n=0;n<t.length;n++){var r=t[n]._private;r.oldBackgroundTimestamp=r.backgroundTimestamp}});var q=function(e){for(var t=0;t<e.length;t++)j.enqueueElementRefinement(e[t].ele)};A.onDequeue(q),I.onDequeue(q),R.onDequeue(q),F.onDequeue(q)}Pu.CANVAS_LAYERS=3,Pu.SELECT_BOX=0,Pu.DRAG=1,Pu.NODE=2,Pu.BUFFER_COUNT=3,Pu.TEXTURE_BUFFER=0,Pu.MOTIONBLUR_BUFFER_NODE=1,Pu.MOTIONBLUR_BUFFER_DRAG=2,Pu.redrawHint=function(e,t){var n=this;switch(e){case"eles":n.data.canvasNeedsRedraw[Pu.NODE]=t;break;case"drag":n.data.canvasNeedsRedraw[Pu.DRAG]=t;break;case"select":n.data.canvasNeedsRedraw[Pu.SELECT_BOX]=t;break}};var Nu="undefined"!==typeof Path2D;Pu.path2dEnabled=function(e){if(void 0===e)return this.pathsEnabled;this.pathsEnabled=!!e},Pu.usePaths=function(){return Nu&&this.pathsEnabled},Pu.setImgSmoothing=function(e,t){null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled=t:(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t)},Pu.getImgSmoothing=function(e){return null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled:e.webkitImageSmoothingEnabled||e.mozImageSmoothingEnabled||e.msImageSmoothingEnabled},Pu.makeOffscreenCanvas=function(e,t){var n;return"undefined"!==("undefined"===typeof OffscreenCanvas?"undefined":o(OffscreenCanvas))?n=new OffscreenCanvas(e,t):(n=document.createElement("canvas"),n.width=e,n.height=t),n},[Jl,iu,uu,cu,du,pu,fu,vu,_u,Su].forEach(function(e){te(Pu,e)});var zu=[{name:"null",impl:Ls},{name:"base",impl:sl},{name:"canvas",impl:Du}],Bu=[{type:"layout",extensions:Os},{type:"renderer",extensions:zu}],Ou={},Lu={};function Au(e,t,n){var r=n,i=function(n){Pe("Can not register `"+t+"` for `"+e+"` since `"+n+"` already exists in the prototype and can not be overridden")};if("core"===e){if(Wo.prototype[t])return i(t);Wo.prototype[t]=n}else if("collection"===e){if(oo.prototype[t])return i(t);oo.prototype[t]=n}else if("layout"===e){for(var a=function(e){this.options=e,n.call(this,e),C(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},o=a.prototype=Object.create(n.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=n.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 d=function(e){return e._private.cy},h={addEventFields:function(e,t){t.layout=e,t.cy=d(e),t.target=e},bubble:function(){return!0},parent:function(e){return d(e)}};te(o,{createEmitter:function(){return this._private.emitter=new _a(h,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},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(e,t){return this.emitter().emit(e,t),this}}),Xr.eventAliasesOn(o),r=a}else if("renderer"===e&&"null"!==t&&"base"!==t){var p=Iu("renderer","base"),f=p.prototype,g=n,v=n.prototype,y=function(){p.apply(this,arguments),g.apply(this,arguments)},m=y.prototype;for(var b in f){var x=f[b],w=null!=v[b];if(w)return i(b);m[b]=x}for(var E in v)m[E]=v[E];f.clientFunctions.forEach(function(e){m[e]=m[e]||function(){Pe("Renderer does not implement `renderer."+e+"()` on its prototype")}}),r=y}return le({map:Ou,keys:[e,t],value:r})}function Iu(e,t){return ue({map:Ou,keys:[e,t]})}function Ru(e,t,n,r,i){return le({map:Lu,keys:[e,t,n,r],value:i})}function Fu(e,t,n,r){return ue({map:Lu,keys:[e,t,n,r]})}var Vu=function(){return 2===arguments.length?Iu.apply(null,arguments):3===arguments.length?Au.apply(null,arguments):4===arguments.length?Fu.apply(null,arguments):5===arguments.length?Ru.apply(null,arguments):void Pe("Invalid extension access syntax")};Wo.prototype.extension=Vu,Bu.forEach(function(e){e.extensions.forEach(function(t){Au(e.type,t.name,t.impl)})});var ju=function e(){if(!(this instanceof e))return new e;this.length=0},qu=ju.prototype;qu.instanceString=function(){return"stylesheet"},qu.selector=function(e){var t=this.length++;return this[t]={selector:e,properties:[]},this},qu.css=function(e,t){var n=this.length-1;if(E(e))this[n].properties.push({name:e,value:t});else if(C(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=jo.properties[o]||jo.properties[X(o)];if(null!=l){var u=l.name,c=s;this[n].properties.push({name:u,value:c})}}}return this},qu.style=qu.css,qu.generateStyle=function(e){var t=new jo(e);return this.appendToStyle(t)},qu.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 Xu="3.7.1",Yu=function(e){return void 0===e&&(e={}),C(e)?new Wo(e):E(e)?Vu.apply(Vu,arguments):void 0};Yu.use=function(e){var t=Array.prototype.slice.call(arguments,1);return t.unshift(Yu),e.apply(null,t),this},Yu.warnings=function(e){return Me(e)},Yu.version=Xu,Yu.stylesheet=Yu.Stylesheet=ju,e.exports=Yu},"4ea4":function(e,t,n){e.exports=n.p+"img/ellipse.5d2931d6.svg"},a6ac:function(e,t,n){e.exports=n.p+"img/pentagon.ab8426d3.svg"},bb21:function(e,t,n){(function(t){var n="Expected a function",r="__lodash_hash_undefined__",i="[object Function]",a="[object GeneratorFunction]",o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,l="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,c=l||u||Function("return this")();function d(e,t){return null==e?void 0:e[t]}function h(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(n){}return t}var p=Array.prototype,f=Function.prototype,g=Object.prototype,v=c["__core-js_shared__"],y=function(){var e=/[^.]+$/.exec(v&&v.keys&&v.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),m=f.toString,b=g.hasOwnProperty,x=g.toString,w=RegExp("^"+m.call(b).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=p.splice,_=G(c,"Map"),k=G(Object,"create");function C(e){var t=-1,n=e?e.length:0;this.clear();while(++t<n){var r=e[t];this.set(r[0],r[1])}}function T(){this.__data__=k?k(null):{}}function S(e){return this.has(e)&&delete this.__data__[e]}function D(e){var t=this.__data__;if(k){var n=t[e];return n===r?void 0:n}return b.call(t,e)?t[e]:void 0}function P(e){var t=this.__data__;return k?void 0!==t[e]:b.call(t,e)}function M(e,t){var n=this.__data__;return n[e]=k&&void 0===t?r:t,this}function N(e){var t=-1,n=e?e.length:0;this.clear();while(++t<n){var r=e[t];this.set(r[0],r[1])}}function z(){this.__data__=[]}function B(e){var t=this.__data__,n=X(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():E.call(t,n,1),!0}function O(e){var t=this.__data__,n=X(t,e);return n<0?void 0:t[n][1]}function L(e){return X(this.__data__,e)>-1}function A(e,t){var n=this.__data__,r=X(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}function I(e){var t=-1,n=e?e.length:0;this.clear();while(++t<n){var r=e[t];this.set(r[0],r[1])}}function R(){this.__data__={hash:new C,map:new(_||N),string:new C}}function F(e){return H(this,e)["delete"](e)}function V(e){return H(this,e).get(e)}function j(e){return H(this,e).has(e)}function q(e,t){return H(this,e).set(e,t),this}function X(e,t){var n=e.length;while(n--)if(Z(e[n][0],t))return n;return-1}function Y(e){if(!J(e)||$(e))return!1;var t=Q(e)||h(e)?w:s;return t.test(U(e))}function H(e,t){var n=e.__data__;return W(t)?n["string"==typeof t?"string":"hash"]:n.map}function G(e,t){var n=d(e,t);return Y(n)?n:void 0}function W(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function $(e){return!!y&&y in e}function U(e){if(null!=e){try{return m.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function K(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(n);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var o=e.apply(this,n);return r.cache=a.set(i,o),o};return r.cache=new(K.Cache||I),r}function Z(e,t){return e===t||e!==e&&t!==t}function Q(e){var t=J(e)?x.call(e):"";return t==i||t==a}function J(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}C.prototype.clear=T,C.prototype["delete"]=S,C.prototype.get=D,C.prototype.has=P,C.prototype.set=M,N.prototype.clear=z,N.prototype["delete"]=B,N.prototype.get=O,N.prototype.has=L,N.prototype.set=A,I.prototype.clear=R,I.prototype["delete"]=F,I.prototype.get=V,I.prototype.has=j,I.prototype.set=q,K.Cache=I,e.exports=K}).call(this,n("24aa"))},ca2d:function(e,t,n){e.exports=n.p+"img/hexagon.824c4bcf.svg"},d940:function(e,t,n){},f7fe:function(e,t,n){(function(t){var n="Expected a function",r=NaN,i="[object Symbol]",a=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt,c="object"==typeof t&&t&&t.Object===Object&&t,d="object"==typeof self&&self&&self.Object===Object&&self,h=c||d||Function("return this")(),p=Object.prototype,f=p.toString,g=Math.max,v=Math.min,y=function(){return h.Date.now()};function m(e,t,r){var i,a,o,s,l,u,c=0,d=!1,h=!1,p=!0;if("function"!=typeof e)throw new TypeError(n);function f(t){var n=i,r=a;return i=a=void 0,c=t,s=e.apply(r,n),s}function m(e){return c=e,l=setTimeout(_,t),d?f(e):s}function x(e){var n=e-u,r=e-c,i=t-n;return h?v(i,o-r):i}function w(e){var n=e-u,r=e-c;return void 0===u||n>=t||n<0||h&&r>=o}function _(){var e=y();if(w(e))return k(e);l=setTimeout(_,x(e))}function k(e){return l=void 0,p&&i?f(e):(i=a=void 0,s)}function C(){void 0!==l&&clearTimeout(l),c=0,i=u=a=l=void 0}function T(){return void 0===l?s:k(y())}function S(){var e=y(),n=w(e);if(i=arguments,a=this,u=e,n){if(void 0===l)return m(u);if(h)return l=setTimeout(_,t),f(u)}return void 0===l&&(l=setTimeout(_,t)),s}return t=E(t)||0,b(r)&&(d=!!r.leading,h="maxWait"in r,o=h?g(E(r.maxWait)||0,t):o,p="trailing"in r?!!r.trailing:p),S.cancel=C,S.flush=T,S}function b(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function x(e){return!!e&&"object"==typeof e}function w(e){return"symbol"==typeof e||x(e)&&f.call(e)==i}function E(e){if("number"==typeof e)return e;if(w(e))return r;if(b(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=b(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(a,"");var n=s.test(e);return n||l.test(e)?u(e.slice(2),n?2:8):o.test(e)?r:+e}e.exports=m}).call(this,n("24aa"))},fb15:function(e,t,n){"use strict";var r;(n.r(t),"undefined"!==typeof window)&&((r=window.document.currentScript)&&(r=r.src.match(/(.+\/)[^\/]+\.js(\?.*)?$/))&&(n.p=r[1]));n("d940");var i=n("44e1"),a=n.n(i);function o(e){var t=-1,n=null==e?0:e.length;this.clear();while(++t<n){var r=e[t];this.set(r[0],r[1])}}function s(){this.size=0,this.__data__={hash:new Hash,map:new(Map||ListCache),string:new Hash}}function l(e){var t=getMapData(this,e)["delete"](e);return this.size-=t?1:0,t}function u(e){return getMapData(this,e).get(e)}function c(e){return getMapData(this,e).has(e)}function d(e,t){var n=getMapData(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}o.prototype.clear=s,o.prototype["delete"]=l,o.prototype.get=u,o.prototype.has=c,o.prototype.set=d;const h="Expected a function";function p(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(h);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(p.Cache||o),n}p.Cache=o;var f=p;const g=function(){var e="Expected a function",t=Math.max,n=Date.now,r=n||function(){return(new Date).getTime()};function i(n,i,o){var s,l,u,c,d,h,p,f=0,g=!1,v=!0;if("function"!==typeof n)throw new TypeError(e);if(i=i<0?0:+i||0,!0===o){var y=!0;v=!1}else a(o)&&(y=!!o.leading,g="maxWait"in o&&t(+o.maxWait||0,i),v="trailing"in o?!!o.trailing:v);function m(){h&&clearTimeout(h),l&&clearTimeout(l),f=0,l=h=p=void 0}function b(e,t){t&&clearTimeout(t),l=h=p=void 0,e&&(f=r(),u=n.apply(d,s),h||l||(s=d=void 0))}function x(){var e=i-(r()-c);e<=0||e>i?b(p,l):h=setTimeout(x,e)}function w(){b(v,h)}function E(){if(s=arguments,c=r(),d=this,p=v&&(h||!y),!1===g)var e=y&&!h;else{l||y||(f=c);var t=g-(c-f),a=t<=0||t>g;a?(l&&(l=clearTimeout(l)),f=c,u=n.apply(d,s)):l||(l=setTimeout(w,t))}return a&&h?h=clearTimeout(h):h||i===g||(h=setTimeout(x,i)),e&&(a=!0,u=n.apply(d,s)),!a||h||l||(s=d=void 0),u}return E.cancel=m,E}function a(e){var t=typeof e;return!!e&&("object"===t||"function"===t)}return i}();var v=g;const y=function(e,t,n){var r=!0,i=!0;return!1===n?r=!1:typeof n===typeof{}&&(r="leading"in n?n.leading:r,i="trailing"in n?n.trailing:i),n=n||{},n.leading=r,n.maxWait=t,n.trailing=i,v(e,t,n)};var m=y;const b={},x=Object.getPrototypeOf,w=b.toString,E=b.hasOwnProperty,_=E.toString,k=_.call(Object),C=function(e){return"function"===typeof e&&"number"!==typeof e.nodeType},T=(e,t,n)=>((e<<16)+(t<<8)+n).toString(16).padStart(6,"0"),S=document.querySelectorAll.bind(document);function D(e){let t,n;return!(!e||"[object Object]"!==w.call(e))&&(t=x(e),!t||(n=E.call(t,"constructor")&&t.constructor,"function"===typeof n&&_.call(n)===k))}function P(){let e,t,n,r,i,a,o=arguments[0]||{},s=1,l=arguments.length,u=!1;for("boolean"===typeof o&&(u=o,o=arguments[s]||{},s++),"object"===typeof o||C(o)||(o={}),s===l&&(o=this,s--);s<l;s++)if(null!=(e=arguments[s]))for(t in e)n=o[t],r=e[t],o!==r&&(u&&r&&(D(r)||(i=Array.isArray(r)))?(i?(i=!1,a=n&&Array.isArray(n)?n:[]):a=n&&D(n)?n:{},o[t]=P(u,a,r)):void 0!==r&&(o[t]=r));return o}function M(e){return document.getElementById(e)}function N(e,t,n){const r=function(){n(),e.removeEventListener(t,r)};e.addEventListener(t,r)}function z(e){if(e&&1===e.nodeType&&window.Node&&e instanceof Node)return!0}function B(e,t){if("string"===typeof t){var n=e.ownerDocument.defaultView;return n.getComputedStyle(e,null)[t]}if("object"===typeof t)for(var r in t)e.style[r]=t[r]}function O(e,t){e.classList.add(t)}function L(e,t){e.classList.remove(t)}function A(e,t){return e.classList.contains(t)}function I(e){const t=e.getBoundingClientRect();return{top:t.top+window.pageYOffset-document.documentElement.clientTop,left:t.left+window.pageXOffset-document.documentElement.clientLeft}}function R(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}var F={hasOwn:E,isFunction:C,query:S,isPlainObject:D,extend:P,css:B,addClass:O,removeClass:L,hasClass:A,offset:I,once:N,$:M,isNode:z,debounce:v,throttle:m,RGBToHex:T,memoize:f,guid:R};class V{constructor(){this.events={}}on(e,t,n,...r){"undefined"===typeof this.events[e]&&(this.events[e]=[]),this.events[e].push({scope:n,callback:t,args:r})}off(e,t,n){if("undefined"===typeof this.events[e])return;const r=e=>e.scope!==n||e.callback!==t;this.events[e]=this.events[e].filter(r)}has(e,t,n){if("undefined"===typeof this.events[e])return!1;let r=this.events[e].length;if(void 0===t&&void 0===n)return r>0;const i=e=>{const r=!n||e.scope===n,i=e.callback===t;if(r&&i)return!0};return this.events[e].some(i)}emit(e,t,...n){if("undefined"===typeof this.events[e])return;let r={type:e,target:t};const i=this.events[e].slice();for(const a of i)a&&a.callback&&a.callback.apply(a.scope,[r,...n,...a.args])}debug(){let e="";for(const[t,n]of Object.entries(this.events))for(const r of n){let n=r.scope&&r.scope.constructor.name||"Anonymous";e+=`${n} listening for "${t}"\n`}return e}}var j=V;let q={container:!1,commands:[{command:"undo",icon:"icon-undo",disabled:!0,title:"撤销"},{command:"redo",icon:"icon-Redo",disabled:!0,title:"重做"},{command:"zoomin",icon:"icon-zoomin",disabled:!1,title:"放大",separator:!0},{command:"zoomout",icon:"icon-zoom",disabled:!1,title:"缩小"},{command:"boxselect",icon:"icon-selection",disabled:!1,title:"框选",selected:!1},{command:"copy",icon:"icon-copy",disabled:!0,title:"复制",separator:!0},{command:"paste",icon:"icon-paste",disabled:!0,title:"粘贴"},{command:"delete",icon:"icon-delete",disabled:!0,title:"删除"},{command:"leveldown",icon:"icon-arrow-to-bottom",disabled:!0,title:"层级后置"},{command:"levelup",icon:"icon-top-arrow-from-top",disabled:!0,title:"层级前置"},{command:"line-straight",icon:"icon-Line-Tool",disabled:!1,title:"直线",selected:!1,separator:!0},{command:"line-taxi",icon:"icon-gongzuoliuchengtu",disabled:!1,title:"折线",selected:!1},{command:"line-bezier",icon:"icon-Bezier-",disabled:!1,title:"曲线",selected:!1},{command:"gridon",icon:"icon-grid",disabled:!1,title:"表格辅助",selected:!1,separator:!0},{command:"fit",icon:"icon-fullscreen",disabled:!1,title:"适应画布"},{command:"save",icon:"icon-save",disabled:!1,title:"保存",separator:!0}]};class X{constructor(e,t){this.cy=e,this._init(t),this._listeners={},this._initEvents()}_init(e){this._options=Object.assign({},q,e),Array.isArray(this._options.toolbar)&&(this._options.commands=this._options.commands.filter(e=>this._options.toolbar.indexOf(e.command)>-1)),this._initShapePanel()}_initEvents(){this._listeners.command=(e=>{let t=e.target.getAttribute("data-command");if(!t)return;let n=this._options.commands.find(e=>e.command===t);["boxselect","gridon"].indexOf(t)>-1?this.rerender(t,{selected:!n.selected}):["line-straight","line-bezier","line-taxi"].indexOf(t)>-1?(this.rerender("line-straight",{selected:"line-straight"===t}),this.rerender("line-bezier",{selected:"line-bezier"===t}),this.rerender("line-taxi",{selected:"line-taxi"===t})):"fit"===t&&this.rerender("fit",{icon:"icon-fullscreen"===n.icon?"icon-fullscreen-exit":"icon-fullscreen"}),n&&this.cy.trigger("cyeditor.toolbar-command",n)}),this._panel.addEventListener("click",this._listeners.command),this._listeners.select=this._selectChange.bind(this),this.cy.on("select unselect",this._listeners.select)}_selectChange(){let e=this.cy.$(":selected");if(e&&e.length!==this._last_selected_length){let t=e.length>0;this._options.commands.forEach(e=>{["delete","copy","leveldown","levelup"].indexOf(e.command)>-1&&(e.disabled=!t)}),this._panelHtml()}this._last_selected_length=e}_initShapePanel(){let{_options:e}=this;if(e.container){if("string"===typeof e.container?this._panel=F.query(e.container)[0]:F.isNode(e.container)&&(this._panel=e.container),!this._panel)return void console.error("There is no any element matching your container")}else this._panel=document.createElement("div"),document.body.appendChild(this._panel);this._panelHtml()}_panelHtml(){let e="";this._options.commands.forEach(({command:t,title:n,icon:r,disabled:i,selected:a,separator:o})=>{let s=`${r} ${i?"disable":""} ${!0===a?"selected":""}`;o&&(e+='<span class="separator"></span>'),e+=`<i data-command="${t}" class="iconfont command ${s}" title="${n}"></i>`}),this._panel.innerHTML=e}rerender(e,t={}){let n=this._options.commands.find(t=>t.command===e),r=Object.assign(n,t);if(r){let t=F.query(`i[data-command=${e}]`);t.forEach(e=>{e.parentNode===this._panel&&(r.icon&&(e.className=`iconfont command ${r.icon}`),r.disabled?F.addClass(e,"disable"):F.removeClass(e,"disable"),r.selected?F.addClass(e,"selected"):F.removeClass(e,"selected"))})}}}var Y=e=>{e&&e("core","toolbar",function(e){return new X(this,e)})};class H{constructor(e,t){this.cy=e;let n={stackOrder:-1,gridSpacing:35,strokeStyle:"#CCCCCC",lineWidth:1,lineDash:[5,8],zoomDash:!0,panGrid:!0,snapToGrid:!0,drawGrid:!0};this._options=F.extend(!0,{},n,t),this._init(),this._initEvents()}_init(){this._container=this.cy.container(),this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this._container.append(this.canvas)}_initEvents(){window.addEventListener("resize",()=>this._resizeCanvas()),this.cy.ready(()=>{this._resizeCanvas(),this._options.snapToGrid&&this.snapAll(),this.cy.on("zoom",()=>this._drawGrid()),this.cy.on("pan",()=>this._drawGrid()),this.cy.on("free",e=>this._nodeFreed(e)),this.cy.on("add",e=>this._nodeAdded(e))})}_resizeCanvas(){let e=this._container.getBoundingClientRect();this.canvas.height=e.height,this.canvas.width=e.width,this.canvas.style.position="absolute",this.canvas.style.top=0,this.canvas.style.left=0,this.canvas.style.zIndex=this._options.stackOrder,setTimeout(()=>{let e=F.offset(this.canvas),t=F.offset(this._container);this.canvas.style.top=-(e.top-t.top),this.canvas.style.left=-(e.left-t.left),this._drawGrid()},0)}_drawGrid(){if(this.clear(),!this._options.drawGrid)return;let e=this.cy.zoom(),t=this._container.getBoundingClientRect(),n=t.width,r=t.height,i=this._options.gridSpacing*e,a=this.cy.pan(),o=a.x%i,s=a.y%i;if(this.ctx.strokeStyle=this._options.strokeStyle,this.ctx.lineWidth=this._options.lineWidth,this._options.zoomDash){let t=this._options.lineDash.slice();for(let n=0;n<t.length;n++)t[n]=this._options.lineDash[n]*e;this.ctx.setLineDash(t)}else this.ctx.setLineDash(this._options.lineDash);this._options.panGrid?this.ctx.lineDashOffset=-a.y:this.ctx.lineDashOffset=0;for(let l=o;l<n;l+=i)this.ctx.beginPath(),this.ctx.moveTo(l,0),this.ctx.lineTo(l,r),this.ctx.stroke();this._options.panGrid?this.ctx.lineDashOffset=-a.x:this.ctx.lineDashOffset=0;for(let l=s;l<r;l+=i)this.ctx.beginPath(),this.ctx.moveTo(0,l),this.ctx.lineTo(n,l),this.ctx.stroke()}_nodeFreed(e){this._options.snapToGrid&&this.snapNode(e.target)}_nodeAdded(e){this._options.snapToGrid&&this.snapNode(e.target)}snapNode(e){let t=e.position(),n=Math.floor(t.x/this._options.gridSpacing),r=Math.floor(t.y/this._options.gridSpacing);e.position({x:(n+.5)*this._options.gridSpacing,y:(r+.5)*this._options.gridSpacing})}snapAll(){this.cy.nodes().each(e=>{this.snapNode(e)})}refresh(){this._resizeCanvas()}snapOn(){this._options.snapToGrid=!0,this.snapAll(),this.cy.trigger("cyeditor.snapgridon")}snapOff(){this._options.snapToGrid=!1,this.cy.trigger("cyeditor.snapgridoff")}gridOn(){this._options.drawGrid=!0,this._drawGrid(),this.cy.trigger("cyeditor.gridon")}gridOff(){this._options.drawGrid=!1,this._drawGrid(),this.cy.trigger("cyeditor.gridoff")}clear(){let e=this._container.getBoundingClientRect(),t=e.width,n=e.height;this.ctx.clearRect(0,0,t,n)}}var G=e=>{e&&e("core","snapToGrid",function(e){return new H(this,e)})};function W(e,t){void 0===e.scratch("_undoRedo")&&e.scratch("_undoRedo",{});let n=e.scratch("_undoRedo");return void 0===t?n:n[t]}function $(e,t,n){let r=W(e);r[t]=n,e.scratch("_undoRedo",r)}function U(e){let t={options:{isDebug:!1,actions:{},undoableDrag:!0,stackSizeLimit:void 0},actions:{},undoStack:[],redoStack:[],reset:function(e,t){this.undoStack=e||[],this.redoStack=e||[]},undo:function(){if(!this.isUndoStackEmpty()){let t=this.undoStack.pop();e.trigger("cyeditor.beforeUndo",[t.name,t.args]);let n=this.actions[t.name]._undo(t.args);return this.redoStack.push({name:t.name,args:n}),e.trigger("cyeditor.afterUndo",[t.name,t.args,n]),this.options.isDebug&&console.log(this.redoStack,this.undoStack),n}this.options.isDebug&&console.log("Undoing cannot be done because undo stack is empty!")},redo:function(){if(!this.isRedoStackEmpty()){let t=this.redoStack.pop();e.trigger(t.firstTime?"cyeditor.beforeDo":"cyeditor.beforeRedo",[t.name,t.args]),t.args||(t.args={}),t.args.firstTime=!!t.firstTime;let n=this.actions[t.name]._do(t.args);return this.undoStack.push({name:t.name,args:n}),void 0!==this.options.stackSizeLimit&&this.undoStack.length>this.options.stackSizeLimit&&this.undoStack.shift(),e.trigger(t.firstTime?"cyeditor.afterDo":"cyeditor.afterRedo",[t.name,t.args,n]),this.options.isDebug&&console.log(this.redoStack,this.undoStack),n}this.options.isDebug&&console.log("Redoing cannot be done because redo stack is empty!")},do:function(e,t){return this.redoStack.length=0,this.redoStack.push({name:e,args:t,firstTime:!0}),this.redo()},undoAll:function(){while(!this.isUndoStackEmpty())this.undo()},redoAll:function(){while(!this.isRedoStackEmpty())this.redo()},action:function(e,t,n){return this.actions[e]={_do:t,_undo:n},this},removeAction:function(e){delete this.actions[e]},isUndoStackEmpty:function(){return 0===this.undoStack.length},isRedoStackEmpty:function(){return 0===this.redoStack.length},getUndoStack:function(){return this.undoStack},getRedoStack:function(){return this.redoStack}};return t}function K(e,t){let n=null;e.on("grab","node",function(){("function"===typeof t?t.call(this):t)&&(n={},n.lastMouseDownPosition={x:this.position("x"),y:this.position("y")},n.node=this)}),e.on("free","node",function(){let r=W(e,"instance");if("function"===typeof t?t.call(this):t){if(null===n)return;let t=n.node,i=n.lastMouseDownPosition,a={x:t.position("x"),y:t.position("y")};if(a.x!==i.x||a.y!==i.y){let o,s={x:a.x-i.x,y:a.y-i.y};o=t.selected()?e.nodes(":visible").filter(":selected"):e.collection([t]);let l={positionDiff:s,nodes:o,move:!1};r.do("drag",l),n=null}}})}function Z(e){function t(e){let t={};for(let r=0;r<e.length;r++)t[e[r].id()]=!0;let n=e.filter(function(e,n){"number"===typeof e&&(e=n);let r=e.parent()[0];while(null!==r&&r){if(r&&t[r.id()])return!1;r=r.parent()[0]}return!0});return n}function n(e,r,i){let a=i?r:t(r);for(let t=0;t<a.length;t++){let r=a[t],i=r.position("x"),o=r.position("y");r.isParent()||r.position({x:i+e.x,y:o+e.y});let s=r.children();n(e,s,!0)}}function r(t){return"string"===typeof t?e.$(t):t}function i(e){return r(e).restore()}function a(t){let n={};return e.nodes().positions(function(e,r){"number"===typeof e&&(e=r),n[e.id()]={x:e.position("x"),y:e.position("y")};let i=t[e.id()];return{x:i.x,y:i.y}}),n}function o(){let t={},n=e.nodes();for(let e=0;e<n.length;e++){let r=n[e];t[r.id()]={x:r.position("x"),y:r.position("y")}}return t}function s(e){let t={};if(e.firstTime){let r=void 0===e.parentData?null:e.parentData,i=e.nodes.union(e.nodes.descendants());t.elesToRestore=i.union(i.connectedEdges()),t.movedEles=e.nodes.move({parent:r});let a={x:e.posDiffX,y:e.posDiffY};n(a,t.movedEles)}else t.elesToRestore=e.movedEles.remove(),t.movedEles=e.elesToRestore.restore();return e.callback&&(t.callback=e.callback,e.callback(t.movedEles)),t}function l(t,n){let r=[],i=W(e,"instance"),a=i.actions;for(let e=0;e<t.length;e++){let n=t[e];a.hasOwnProperty(n.name)||console.error("Action "+n.name+" does not exist as an undoable function")}for(let e=0;e<t.length;e++){let i,o=t[e];o.param.firstTime=t.firstTime,i="undo"===n?a[o.name]._undo(o.param):a[o.name]._do(o.param),r.unshift({name:o.name,param:i})}return r}return{add:{_do:function(t){return t.firstTime?e.add(t):i(t)},_undo:e.remove},remove:{_do:e.remove,_undo:i},restore:{_do:i,_undo:e.remove},select:{_do:function(e){return r(e).select()},_undo:function(e){return r(e).unselect()}},unselect:{_do:function(e){return r(e).unselect()},_undo:function(e){return r(e).select()}},move:{_do:function(e){let t=r(e.eles),n=t.nodes(),i=t.edges();return{oldNodes:n,newNodes:n.move(e.location),oldEdges:i,newEdges:i.move(e.location)}},_undo:function(t){let n=e.collection(),r={};if(t.newNodes.length>0){r.parent=t.newNodes[0].parent();for(let e=0;e<t.newNodes.length;e++){let r=t.newNodes[e].move({parent:t.oldNodes[e].parent()});n.union(r)}}else{r.source=r.newEdges[0].source(),r.target=r.newEdges[0].target();for(let e=0;e<t.newEdges.length;e++){let r=t.newEdges[e].move({source:t.oldEdges[e].source(),target:t.oldEdges[e].target()});n.union(r)}}return{eles:n,location:r}}},drag:{_do:function(e){return e.move&&n(e.positionDiff,e.nodes),e},_undo:function(e){let t={x:-1*e.positionDiff.x,y:-1*e.positionDiff.y},r={positionDiff:e.positionDiff,nodes:e.nodes,move:!0};return n(t,e.nodes),r}},layout:{_do:function(t){if(t.firstTime){let n,i=o();return n=t.eles?r(t.eles).layout(t.options):e.layout(t.options),n&&n.run&&n.run(),i}return a(t)},_undo:function(e){return a(e)}},changeParent:{_do:function(e){return s(e)},_undo:function(e){return s(e)}},batch:{_do:function(e){return l(e,"do")},_undo:function(e){return l(e,"undo")}}}}var Q=e=>{e&&e("core","undoRedo",function(e,t){let n=this,r=W(n,"instance")||U(n);if($(n,"instance",r),e){for(let t in e)r.options.hasOwnProperty(t)&&(r.options[t]=e[t]);if(e.actions)for(let t in e.actions)r.actions[t]=e.actions[t]}if(!W(n,"isInitialized")&&!t){let e=Z(n);for(let t in e)r.actions[t]=e[t];K(n,r.options.undoableDrag),$(n,"isInitialized",!0)}return r})};let J={clipboardSize:0,beforeCopy:null,afterCopy:null,beforePaste:null,afterPaste:null};class ee{constructor(e,t){return this.cy=e,this._options=Object.assign({},J,t),this._counter=0,this._listeners={},this._init()}_init(){let e=this._getScratch();if(this._oldIdToNewId={},!e.isInitialized){e.isInitialized=!0;let t={};e.instance={copy:(e,n)=>{let r=n||this._getItemId();e.unselect();let i=e.nodes().descendants(),a=e.nodes().union(i).filter(":visible"),o=a.edgesWith(a).filter(":visible");return this._options.beforeCopy&&this._options.beforeCopy(a.union(o)),t[r]={nodes:a.jsons(),edges:o.jsons()},this._options.afterCopy&&this._options.afterCopy(t[r]),this._targetPos=a[0]?a[0].position():{x:0,y:0},r},paste:e=>{let n=e||this._getItemId(!0),r=this.cy.collection();if(this._options.beforePaste&&this._options.beforePaste(t[n]),t[n]){let e=this.changeIds(t[n].nodes),i=this.changeIds(t[n].edges);this._oldIdToNewId={},this.cy.batch(()=>{r=this.cy.add(e).union(this.cy.add(i)),r.select()})}return this._options.afterPaste&&this._options.afterPaste(r),this.cy.trigger("cyeditor.paste"),r}}}return e.instance}_getItemId(e){return e?"item_"+this._counter:"item_"+ ++this._counter}changeIds(e){e=F.extend(!0,[],e);for(let t=0;t<e.length;t++){let n=e[t],r=F.guid();this._oldIdToNewId[n.data.id]=r,n.data.id=r}for(let t=0;t<e.length;t++){let n=e[t],r=["source","target","parent"];for(let e=0;e<r.length;e++){let t=r[e];n.data[t]&&this._oldIdToNewId[n.data[t]]&&(n.data[t]=this._oldIdToNewId[n.data[t]])}n.position.x&&(n.position.x+=50,n.position.y+=50)}return e}_getScratch(){return this.cy.scratch("_clipboard")||this.cy.scratch("_clipboard",{}),this.cy.scratch("_clipboard")}destroy(){this.cy.off("mousemove",this._listeners.onmousemove)}}var te=e=>{e&&e("core","clipboard",function(e){return new ee(this,e)})};let ne={container:!1,viewLiveFramerate:0,dblClickDelay:200,removeCustomContainer:!0,rerenderDelay:500};class re{constructor(e,t){this.cy=e,this._options=F.extend({},ne,t),this._init(e,t)}_init(){this._cyListeners=[],this._contianer=this.cy.container(),this.boundingBox=this.bb();let e=this._contianer.getBoundingClientRect();this.width=e.width,this.height=e.height,this._initPanel(),this._initThumbnail(),this._initView(),this._initOverlay()}_addCyListener(e,t){this._cyListeners.push({events:e,handler:t}),this.cy.on(e,t)}_removeCyListeners(){let e=this.cy;this._cyListeners.forEach(function(t){e.off(t.events,t.handler)}),e.offRender(this._onRenderHandler)}_initPanel(){let e=this._options;if(e.container){if("string"===typeof e.container?this.$panel=F.query(e.container)[0]:F.isNode(e.container)&&(this.$panel=e.container),!this.$panel)return void console.error("There is no any element matching your container")}else this.$panel=document.createElement("div"),document.body.appendChild(this.$panel);this.$panel.classList.add("cytoscape-navigator"),this._setupPanel(),this._addCyListener("resize",this.resize.bind(this))}_setupPanel(){let e=this.$panel.getBoundingClientRect();this.panelWidth=e.width,this.panelHeight=e.height}_initThumbnail(){this.$thumbnail=document.createElement("img"),this.$panel.appendChild(this.$thumbnail),this._setupThumbnailSizes(),this._updateThumbnailImage()}_setupThumbnailSizes(){this.boundingBox=this.bb(),this.thumbnailZoom=Math.min(this.panelHeight/this.boundingBox.h,this.panelWidth/this.boundingBox.w),this.thumbnailPan={x:(this.panelWidth-this.thumbnailZoom*(this.boundingBox.x1+this.boundingBox.x2))/2,y:(this.panelHeight-this.thumbnailZoom*(this.boundingBox.y1+this.boundingBox.y2))/2}}_checkThumbnailSizesAndUpdate(){let e=this.thumbnailZoom,t=this.thumbnailPan.x,n=this.thumbnailPan.y;this._setupThumbnailSizes(),this._updateThumbnailImage(),e===this.thumbnailZoom&&t===this.thumbnailPan.x&&n===this.thumbnailPan.y||this._setupView()}_initView(){this.$view=document.createElement("div"),this.$view.className="cytoscape-navigatorView",this.$panel.appendChild(this.$view);let e=window.getComputedStyle(this.$view);this.viewBorderTop=parseInt(e["border-top-width"],10),this.viewBorderRight=parseInt(e["border-right-width"],10),this.viewBorderBottom=parseInt(e["border-bottom-width"],10),this.viewBorderLeft=parseInt(e["border-left-width"],10),this.viewBorderHorizontal=this.viewBorderLeft+this.viewBorderRight,this.viewBorderVertical=this.viewBorderTop+this.viewBorderBottom,this._setupView(),this._addCyListener("zoom pan",this._setupView.bind(this))}_setupView(){if(this.viewLocked)return;let e=this.cy.zoom(),t=this.cy.pan();this.viewW=this.width/e*this.thumbnailZoom,this.viewX=-t.x*this.viewW/this.width+this.thumbnailPan.x-this.viewBorderLeft,this.viewH=this.height/e*this.thumbnailZoom,this.viewY=-t.y*this.viewH/this.height+this.thumbnailPan.y-this.viewBorderTop,this.$view.style.width=this.viewW+"px",this.$view.style.height=this.viewH+"px",this.$view.style.position="absolute",this.$view.style.left=this.viewX+"px",this.$view.style.top=this.viewY+"px"}_initOverlay(){this.$overlay=document.createElement("div"),this.$overlay.className="cytoscape-navigatorOverlay",this.$panel.appendChild(this.$overlay),this.overlayHookPointX=0,this.overlayHookPointY=0,this._initEventsHandling()}_initEventsHandling(){let e=["mousedown","mousewheel","DOMMouseScroll","touchstart"],t=["mouseup","mouseout","mousemove","touchmove","touchend"],n=e=>{let t=F.extend({},e);if("touchstart"===t.type&&(t.offsetX=this.viewX+this.viewW/2,t.offsetY=this.viewY+this.viewH/2),void 0===t.offsetX||void 0===t.offsetY){let e=F.offset(t.target);t.offsetX=t.pageX-e.left,t.offsetY=t.pageY-e.top}return"mousedown"===t.type||"touchstart"===t.type?this._eventMoveStart(t):"mousewheel"!==t.type&&"DOMMouseScroll"!==t.type||this._eventZoom(t),e.preventDefault(),!1},r=e=>{let t=F.extend({},e);if(this.overlayInMovement){if("touchend"===t.type?(t.offsetX=this.viewX+this.viewW/2,t.offsetY=this.viewY+this.viewH/2):"touchmove"===t.type&&(t.pageX=t.touches[0].pageX,t.pageY=t.touches[0].pageY),t.target&&(void 0===t.offsetX||void 0===t.offsetY)){let e=F.offset(t.target);t.offsetX=t.pageX-e.left,t.offsetY=t.pageY-e.top}if(t.target&&t.target!==this.$overlay){let e=F.offset(t.target),n=F.offset(this.$overlay);if(!e||!n)return!1;t.offsetX=t.offsetX-n.left+e.left,t.offsetY=t.offsetY-n.top+e.top}return"mousemove"===t.type||"touchmove"===t.type?this._eventMove(t):"mouseup"!==t.type&&"touchend"!==t.type||this._eventMoveEnd(t),e.preventDefault(),!1}};e.forEach(e=>{this.$overlay.addEventListener(e,n)}),t.forEach(e=>{window.addEventListener(e,r)}),this._removeEventsHandling=(()=>{t.forEach(e=>{window.removeEventListener(e,r)}),e.forEach(e=>{this.$overlay.addEventListener(e,n)})})}_eventMoveStart(e){let t=(new Date).getTime();this.overlayLastMoveStartTime&&this.overlayLastMoveStartTime+this._options.dblClickDelay>t?(this.overlayLastMoveStartTime=0,this.overlayInMovement=!0,this.overlayHookPointX=this.viewW/2,this.overlayHookPointY=this.viewH/2,!1!==this._options.viewLiveFramerate?this._eventMove({offsetX:this.panelWidth/2,offsetY:this.panelHeight/2}):this._eventMoveEnd({offsetX:this.panelWidth/2,offsetY:this.panelHeight/2}),this.cy.reset(),this.overlayInMovement=!1):(this.overlayLastMoveStartTime=t,this.overlayInMovement=!0,this.viewLocked=!0,e.offsetX>=this.viewX&&e.offsetX<=this.viewX+this.viewW&&e.offsetY>=this.viewY&&e.offsetY<=this.viewY+this.viewH?(this.overlayHookPointX=e.offsetX-this.viewX,this.overlayHookPointY=e.offsetY-this.viewY):(this.overlayHookPointX=this.viewW/2,this.overlayHookPointY=this.viewH/2,this._eventMove(e)))}_eventMove(e){this._checkMousePosition(e),this.overlayInMovement&&(this.viewX=e.offsetX-this.overlayHookPointX,this.viewY=e.offsetY-this.overlayHookPointY,this.$view.style.left=this.viewX+"px",this.$view.style.top=this.viewY+"px",!1!==this._options.viewLiveFramerate&&(0===this._options.viewLiveFramerate?this._moveCy():this.overlayTimeout||(this.overlayTimeout=setTimeout(()=>{this._moveCy(),this.overlayTimeout=!1},1e3/this._options.viewLiveFramerate))))}_checkMousePosition(e){e.offsetX>this.viewX&&e.offsetX<this.viewX+this.viewBorderHorizontal+this.viewW&&e.offsetY>this.viewY&&e.offsetY<this.viewY+this.viewBorderVertical+this.viewH?this.$panel.classList.add("mouseover-view"):this.$panel.classList.remove("mouseover-view")}_eventMoveEnd(e){this.viewLocked=!1,this.$panel.classList.remove("mouseover-view"),this.overlayInMovement&&(this._eventMove(e),!1===this._options.viewLiveFramerate&&this._moveCy(),this.overlayInMovement=!1)}_eventZoom(e){let t=Math.pow(10,e.wheelDeltaY/1e3||e.wheelDelta/1e3||e.detail/-32),n={left:e.offsetX,top:e.offsetY};this.cy.zoomingEnabled()&&this._zoomCy(t,n)}_updateThumbnailImage(){if(this._thumbnailUpdating)return;this._thumbnailUpdating=!0;let e=()=>{this._checkThumbnailSizesAndUpdate(),this._setupView();let e=this.$thumbnail;if(!e)return;let t=this.panelWidth,n=this.panelHeight,r=this.boundingBox,i=Math.min(t/r.w,n/r.h),a={x:(t-i*r.w)/2,y:(n-i*r.h)/2},o=this.cy.png({full:!0,scale:i});o.indexOf("image/png")<0?e.removeAttribute("src"):e.setAttribute("src",o),e.style.position="absolute",e.style.left=a.x+"px",e.style.top=a.y+"px"};this._onRenderHandler=F.throttle(e,this._options.rerenderDelay),this.cy.onRender(this._onRenderHandler)}_moveCy(){this.cy.pan({x:-(this.viewX+this.viewBorderLeft-this.thumbnailPan.x)*this.width/this.viewW,y:-(this.viewY+this.viewBorderLeft-this.thumbnailPan.y)*this.height/this.viewH})}_zoomCy(e){let t={x:this.width/2,y:this.height/2};this.cy.zoom({level:this.cy.zoom()*e,renderedPosition:t})}destroy(){if(this._removeCyListeners(),this._removeEventsHandling(),this._options.container&&!this._options.removeCustomContainer){let e=this.$panel.childNodes;for(let t=e.length-1;t>=0;t--)this.$panel.removeChild(e[t])}else this.$panel.parentNode.removeChild(this.$panel)}resize(){let e=this._contianer.getBoundingClientRect();this.width=e.width,this.height=e.height,this._setupPanel(),this._checkThumbnailSizesAndUpdate(),this._setupView()}bb(){let e=this.cy.elements().boundingBox();return 0===e.w||0===e.h?{x1:0,x2:1/0,y1:0,y2:1/0,w:1/0,h:1/0}:e}}var ie=e=>{e&&e("core","navigator",function(e){return new re(this,e)})},ae={preview:!0,hoverDelay:150,handleNodes:"node",snap:!1,snapThreshold:50,snapFrequency:15,noEdgeEventsInDraw:!1,disableBrowserGestures:!0,handlePosition:function(e){return"middle top"},handleInDrawMode:!1,edgeType:function(e,t){return"flat"},loopAllowed:function(e){return!1},nodeLoopOffset:-50,nodeParams:function(e,t){return{}},edgeParams:function(e,t,n){return{}},ghostEdgeParams:function(){return{}},show:function(e){},hide:function(e){},start:function(e){},complete:function(e,t,n){},stop:function(e){},cancel:function(e,t){},hoverover:function(e,t){},hoverout:function(e,t){},previewon:function(e,t,n){},previewoff:function(e,t,n){},drawon:function(){},drawoff:function(){}};function oe(){if(this.saveGestureState(),this.cy.zoomingEnabled(!1).panningEnabled(!1).boxSelectionEnabled(!1),this.options.disableBrowserGestures){let e=this.windowListenerOptions;window.addEventListener("touchstart",this.preventDefault,e),window.addEventListener("touchmove",this.preventDefault,e),window.addEventListener("wheel",this.preventDefault,e)}return this}function se(){if(this.cy.zoomingEnabled(this.lastZoomingEnabled).panningEnabled(this.lastPanningEnabled).boxSelectionEnabled(this.lastBoxSelectionEnabled),this.options.disableBrowserGestures){let e=this.windowListenerOptions;window.removeEventListener("touchstart",this.preventDefault,e),window.removeEventListener("touchmove",this.preventDefault,e),window.removeEventListener("wheel",this.preventDefault,e)}return this}function le(){let{cy:e}=this;return this.lastPanningEnabled=e.panningEnabled(),this.lastZoomingEnabled=e.zoomingEnabled(),this.lastBoxSelectionEnabled=e.boxSelectionEnabled(),this}var ue={disableGestures:oe,resetGestures:se,saveGestureState:le};function ce(){let{cy:e,options:t}=this;return this.addListener(e,"drag",()=>{this.grabbingNode=!0}),this.addListener(e,"free",()=>{this.grabbingNode=!1}),this.addListener(e,"mouseover","node",e=>{this.show(e.target)}),this.addListener(e,"tap","node",e=>{let t=e.target;t.same(this.handleNode)||this.show(t)}),this.addListener(e,"position","node",e=>{e.target.same(this.sourceNode)&&this.hide()}),this.addListener(e,"tapstart","node",e=>{let t=e.target;t.same(this.handleNode)?this.start(this.sourceNode):this.drawMode?this.start(t):t.same(this.sourceNode)&&this.hide()}),this.addListener(e,"tapdrag",e=>{this.update(e.position)}),this.addListener(e,"tapdragover","node",e=>{this.preview(e.target)}),this.addListener(e,"tapdragout","node",e=>{t.snap&&e.target.same(this.targetNode)||this.unpreview(e.target)}),this.addListener(e,"tapend",()=>{this.stop()}),this.addListener(e,"remove",e=>{e.target.same(this.sourceNode)&&this.hide()}),this}var de={addCytoscapeListeners:ce};const he=e=>"string"===typeof e;function pe(e,t,n){let r={};return Object.assign(r,t,e),Object.assign(r.data,t.data,e.data),he(t.classes)?r.classes=t.classes+" "+n:Array.isArray(t.classes)?r.classes=t.classes.join(" ")+" "+n:r.classes=n,r}function fe(e=!1){let{cy:t,options:n,presumptiveTargets:r,previewEles:i,active:a}=this,o=this.sourceNode,s=this.targetNode,l=e?"eh-preview":"",u=t.collection(),c=n.edgeType(o,s);if(!a)return;if(!c)return;if(e&&!n.preview)return;if(!s||0===s.size())return i.remove(),void this.emit("cancel",this.mp(),o,r);if(!e&&n.preview)return i.removeClass("eh-preview").style("events",""),void this.emit("complete",this.mp(),o,s,i);let d,h=o.position(),p=s.position();if(d=o.same(s)?{x:h.x+n.nodeLoopOffset,y:h.y+n.nodeLoopOffset}:{x:(h.x+p.x)/2,y:(h.y+p.y)/2},"node"===c){let e=t.add(pe({group:"nodes",position:d},n.nodeParams(o,s),l)),r=t.add(pe({group:"edges",data:{source:o.id(),target:e.id()}},n.edgeParams(o,s,0),l)),i=t.add(pe({group:"edges",data:{source:e.id(),target:s.id()}},n.edgeParams(o,s,1),l));u=u.merge(e).merge(r).merge(i)}else{let e=t.add(pe({group:"edges",data:{source:o.id(),target:s.id()}},n.edgeParams(o,s,0),l));u=u.merge(e)}return e?(this.previewEles=u,u.style("events","no")):(u.style("events",""),this.emit("complete",this.mp(),o,s,u)),this}function ge(){return this.makeEdges(!0),this}function ve(){return this.previewEles.nonempty()&&this.previewEles.inside()}function ye(){return this.previewShown()&&this.previewEles.remove(),this}function me(){return this.handleNode.nonempty()&&this.handleNode.inside()}function be(){return this.handleShown()&&this.handleNode.remove(),this}function xe(e){let{options:t,cy:n}=this,r="string"===typeof t.handlePosition?()=>t.handlePosition:t.handlePosition,i=e.position(),a=e.outerHeight(),o=e.outerWidth(),s=0,l=0,u=r(e).toLowerCase().split(/\s+/),c=u[0],d=u[1];"left"===c?s=-o/2:"right"===c&&(s=o/2),"top"===d?l=-a/2:"bottom"===d&&(l=a/2);let h=this.hx=i.x+s,p=this.hy=i.y+l,f={x:h,y:p};return this.handleShown()?this.handleNode.position(f):n.batch(()=>{this.handleNode=n.add({classes:"eh-handle",position:f,grabbable:!1,selectable:!1}),this.handleNode.style("z-index",9007199254740991)}),this}function we(){let e,t,{sourceNode:n,ghostNode:r,cy:i,mx:a,my:o,options:s}=this,l=a,u=o;if(n)return r&&0!==r.length&&!r.removed()||(t=this.ghostEles=i.collection(),i.batch(()=>{r=this.ghostNode=i.add({group:"nodes",classes:"eh-ghost eh-ghost-node",position:{x:0,y:0}}),r.style({"background-color":"blue",width:1e-4,height:1e-4,opacity:0,events:"no"});let t=s.ghostEdgeParams();e=i.add(Object.assign({},t,{group:"edges",data:Object.assign({},t.data,{source:n.id(),target:r.id()})})),e.addClass("eh-ghost eh-ghost-edge"),e.style({events:"no"})}),t.merge(r).merge(e)),r.position({x:l,y:u}),this}var Ee={makeEdges:fe,makePreview:ge,removePreview:ye,previewShown:ve,updateEdge:we,handleShown:me,setHandleFor:xe,removeHandle:be};const _e=n("bb21");function ke(e){const{options:t,previewEles:n,ghostEles:r,handleNode:i}=this,a=e=>n.anySame(e),o=e=>r.anySame(e),s=e=>e.filter(t.handleNodes).length>0,l=e=>i.same(e),u=e=>a(e)||l(e)||o(e),{enabled:c,active:d,grabbingNode:h}=this;return c&&!d&&!h&&(null==e||!u(e)&&s(e))}function Ce(e){return this.canStartOn(e)&&this.drawMode}function Te(e){return this.canStartOn(e)&&!this.drawMode}function Se(e){let{options:t,drawMode:n}=this;if(this.canStartOn(e)&&(!n||t.handleInDrawMode))return this.sourceNode=e,this.setHandleFor(e),this.emit("show",this.hp(),this.sourceNode),this}function De(){return this.removeHandle(),this.emit("hide",this.hp(),this.sourceNode),this}function Pe(e){this.canStartOn(e)&&(this.active=!0,this.sourceNode=e,this.sourceNode.addClass("eh-source"),this.disableGestures(),this.disableEdgeEvents(),this.emit("start",this.hp(),e))}function Me(e){if(!this.active)return;let t=e;return this.mx=t.x,this.my=t.y,this.updateEdge(),this.throttledSnap(),this}function Ne(){if(!this.active||!this.options.snap)return!1;let e=this.cy,t=this.targetNode,n=this.options.snapThreshold,r=e=>{let t=o(e),r=t+n;return r*r},i=this.mp(),a=(e,t)=>(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y),o=e=>(e.outerWidth()+e.outerHeight())/4,s=_e(e=>a(e.position(),i),e=>e.id()),l=e=>s(e)<=r(e),u=(e,t)=>s(e)-s(t),c=!1,d=e.nodes(l).sort(u),h=!1;t.nonempty()&&!l(t)&&this.unpreview(t);for(let p=0;p<d.length;p++){let e=d[p];if(e.same(t)||this.preview(e,c)){h=!0;break}}return h}function ze(e,t=!0){let{options:n,sourceNode:r,ghostNode:i,ghostEles:a,presumptiveTargets:o,previewEles:s,active:l}=this,u=r,c=e.same(u),d=n.loopAllowed(e),h=e.same(i),p=!n.edgeType(u,e),f=e.same(this.handleNode),g=e.same(this.targetNode);if(!l||f||h||p||g||c&&!d)return!1;this.targetNode.nonempty()&&this.unpreview(this.targetNode),clearTimeout(this.previewTimeout);let v=()=>{this.targetNode=e,o.merge(e),e.addClass("eh-presumptive-target"),e.addClass("eh-target"),this.emit("hoverover",this.mp(),u,e),n.preview&&(e.addClass("eh-preview"),a.addClass("eh-preview-active"),r.addClass("eh-preview-active"),e.addClass("eh-preview-active"),this.makePreview(),this.emit("previewon",this.mp(),u,e,s))};return t&&n.hoverDelay>0?this.previewTimeout=setTimeout(v,n.hoverDelay):v(),!0}function Be(e){if(!this.active||e.same(this.handleNode))return;let{previewTimeout:t,sourceNode:n,previewEles:r,ghostEles:i,cy:a}=this;clearTimeout(t),this.previewTimeout=null;let o=n;return e.removeClass("eh-preview eh-target eh-presumptive-target eh-preview-active"),i.removeClass("eh-preview-active"),n.removeClass("eh-preview-active"),this.targetNode=a.collection(),this.removePreview(o,e),this.emit("hoverout",this.mp(),o,e),this.emit("previewoff",this.mp(),o,e,r),this}function Oe(){if(!this.active)return;let{sourceNode:e,targetNode:t,ghostEles:n,presumptiveTargets:r}=this;return clearTimeout(this.previewTimeout),e.removeClass("eh-source"),t.removeClass("eh-target eh-preview eh-hover"),r.removeClass("eh-presumptive-target"),this.makeEdges(),this.removeHandle(),n.remove(),this.clearCollections(),this.resetGestures(),this.enableEdgeEvents(),this.active=!1,this.emit("stop",this.mp(),e),this}var Le={show:Se,hide:De,start:Pe,update:Me,preview:ze,unpreview:Be,stop:Oe,snap:Ne,canStartOn:ke,canStartDrawModeOn:Ce,canStartNonDrawModeOn:Te};function Ae(){return this.addCytoscapeListeners(),this.addListener(this.cy,"destroy",()=>this.destroy()),this}function Ie(){for(let e=this.listeners.length-1;e>=0;e--){let t=this.listeners[e];this.removeListener(t.target,t.event,t.selector,t.callback,t.options)}return this}function Re(e,t,n,r,i){return"string"!==typeof n&&(r=n,i=r,n=null),null==i&&(i=!1),{target:e,event:t,selector:n,callback:r,options:i}}function Fe(e){return e instanceof Element}function Ve(e,t,n,r,i){let a=Re(e,t,n,r,i);return this.listeners.push(a),Fe(a.target)?a.target.addEventListener(a.event,a.callback,a.options):a.selector?a.target.addListener(a.event,a.selector,a.callback,a.options):a.target.addListener(a.event,a.callback,a.options),this}function je(e,t,n,r,i){let a=Re(e,t,n,r,i);for(let o=this.listeners.length-1;o>=0;o--){let e=this.listeners[o];if(a.target===e.target&&a.event===e.event&&(null==a.selector||a.selector===e.selector)&&(null==a.callback||a.callback===e.callback)){this.listeners.splice(o,1),Fe(a.target)?a.target.removeEventListener(a.event,a.callback,a.options):a.selector?a.target.removeListener(a.event,a.selector,a.callback,a.options):a.target.removeListener(a.event,a.callback,a.options);break}}return this}function qe(e,t,...n){let{options:r,cy:i}=this;i.emit({type:`eh${e}`,position:t},n);let a=r[e];return null!=a&&a(...n),this}var Xe={addListener:Ve,addListeners:Ae,removeListener:je,removeListeners:Ie,emit:qe};class Ye{constructor(e,t){this.cy=e,this.listeners=[],this.enabled=!0,this.drawMode=!1,this.active=!1,this.grabbingNode=!1,this.handleNode=e.collection(),this.clearCollections(),this.hx=0,this.hy=0,this.hr=0,this.mx=0,this.my=0,this.options=Object.assign({},ae,t),this.saveGestureState(),this.addListeners(),this.throttledSnap=F.throttle(this.snap.bind(this),1e3/t.snapFrequency),this.preventDefault=(e=>e.preventDefault());let n=!1;try{let e=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("test",null,e)}catch(r){}this.windowListenerOptions=!n||{capture:!0,passive:!1}}destroy(){this.removeListeners()}setOptions(e){Object.assign(this.options,e)}mp(){return{x:this.mx,y:this.my}}hp(){return{x:this.hx,y:this.hy}}clearCollections(){this.previewEles=this.cy.collection(),this.ghostEles=this.cy.collection(),this.ghostNode=this.cy.collection(),this.sourceNode=this.cy.collection(),this.targetNode=this.cy.collection(),this.presumptiveTargets=this.cy.collection()}enable(){return this.enabled=!0,this.emit("enable"),this}disable(){return this.enabled=!1,this.emit("disable"),this}toggleDrawMode(e){let{cy:t,options:n}=this;return this.drawMode=null!=e?e:!this.drawMode,this.drawMode?(this.prevUngrabifyState=t.autoungrabify(),t.autoungrabify(!0),!n.handleInDrawMode&&this.handleShown()&&this.hide(),this.emit("drawon")):(t.autoungrabify(this.prevUngrabifyState),this.emit("drawoff")),this}enableDrawMode(){return this.toggleDrawMode(!0)}disableDrawMode(){return this.toggleDrawMode(!1)}disableEdgeEvents(){return this.options.noEdgeEventsInDraw&&this.cy.edges().style("events","no"),this}enableEdgeEvents(){return this.options.noEdgeEventsInDraw&&this.cy.edges().style("events",""),this}}let He=Ye.prototype,Ge=e=>Object.assign(He,e);const We=[ue,de,Ee,Le,Xe];We.forEach(Ge);var $e=Ye,Ue=e=>{e&&e("core","edgehandles",function(e){return new $e(this,e)})};let Ke={handleColor:"#000000",enabled:!0,minNodeWidth:30,minNodeHeight:30,triangleSize:10,selector:"node",lines:3,padding:5,start:function(e){},complete:function(e,t,n){},stop:function(e){}};function Ze(e,t,n,r){let i=.5*(-n.y*r.x+t.y*(-n.x+r.x)+t.x*(n.y-r.y)+n.x*r.y),a=i<0?-1:1,o=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*a,s=(t.x*n.y-t.y*n.x+(t.y-n.y)*e.x+(n.x-t.x)*e.y)*a;return o>0&&s>0&&o+s<2*i*a}class Qe{constructor(e,t){this.cy=e,this._container=this.cy.container(),this._listeners={},this._drawMode=!1,this._drawsClear=!0,this._options={},this._init(t)}destroy(){let e=this._options;e&&(e.unbind(),this._options={})}disable(){this._options.enabled=!1,this._options.disabled=!0}enable(){this._options.enabled=!0,this._options.disabled=!1}resize(){this.cy.trigger("cyeditor.noderesize-resize")}drawon(){this._drawMode=!0,this._prevUngrabifyState=this.cy.autoungrabify(),this.cy.autoungrabify(!0),this.cy.trigger("cyeditor.noderesize-drawon")}drawoff(){this._drawMode=!1,this.cy.autoungrabify(this._prevUngrabifyState),this.cy.trigger("cyeditor.noderesize-drawoff")}_init(e){this._options=F.extend(!0,{},Ke,e),this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this._container.append(this.canvas),this._listeners._sizeCanvas=F.debounce(this._sizeCanvas,250).bind(this),this._listeners._sizeCanvas(),this._initEvents()}_sizeCanvas(){let e=this._container.getBoundingClientRect();this.canvas.width=e.width,this.canvas.height=e.height,F.css(this.canvas,{position:"absolute",top:0,left:0,zIndex:"999"}),setTimeout(()=>{let e=F.offset(this.canvas),t=F.offset(this._container);F.css(this.canvas,{top:-(e.top-t.top)+"px",left:-(e.left-t.left)+"px"})},0)}clearDraws(){if(this._drawsClear)return;let e=this._container.getBoundingClientRect(),t=e.width,n=e.height;this.canvas.getContext("2d").clearRect(0,0,t,n),this._drawsClear=!0}_disableGestures(){this._lastPanningEnabled=this.cy.panningEnabled(),this._lastZoomingEnabled=this.cy.zoomingEnabled(),this._lastBoxSelectionEnabled=this.cy.boxSelectionEnabled(),this.cy.zoomingEnabled(!1).panningEnabled(!1).boxSelectionEnabled(!1)}_resetGestures(){this.cy.zoomingEnabled(this._lastZoomingEnabled).panningEnabled(this._lastPanningEnabled).boxSelectionEnabled(this._lastBoxSelectionEnabled)}_resetToDefaultState(){this.clearDraws(),this.sourceNode=null,this._resetGestures()}_drawHandle(e){this.ctx.fillStyle=this._options.handleColor,this.ctx.strokeStyle=this._options.handleColor;let t=this._options.padding*this.cy.zoom(),n=e.renderedPosition(),r=e.renderedOuterWidth()+2*t,i=e.renderedOuterHeight()+2*t,a=this._options.triangleSize*this.cy.zoom(),o=n.x+r/2-a,s=n.y+i/2,l=n.x+r/2,u=n.y+i/2-a,c=this._options.lines,d=a/c,h=a/c,p=1.5*this.cy.zoom();for(let f=0;f<c-1;f++)this.ctx.beginPath(),this.ctx.moveTo(o,s),this.ctx.lineTo(l,u),this.ctx.lineTo(l,u+p),this.ctx.lineTo(o+p,s),this.ctx.lineTo(o,s),this.ctx.closePath(),this.ctx.fill(),o+=d,u+=h;this.ctx.beginPath(),this.ctx.moveTo(l,s),this.ctx.lineTo(l,u),this.ctx.lineTo(o,s),this.ctx.closePath(),this.ctx.fill(),this._drawsClear=!1}_initEvents(){let e;window.addEventListener("resize",this._listeners._sizeCanvas),this.cy.on("cyeditor.noderesize-resize",this._listeners._sizeCanvas),this._grabbingNode=!1,this._lastPanningEnabled=this.cy.panningEnabled(),this._lastZoomingEnabled=this.cy.zoomingEnabled(),this._lastBoxSelectionEnabled=this.cy.boxSelectionEnabled(),this.cy.style().selector(".noderesize-resized").css({width:"data(width)",height:"data(height)"}),this._listeners.transformHandler=(()=>{this.clearDraws()}),this._listeners._startHandler=this._startHandler.bind(this),this.cy.bind("zoom pan",this._listeners.transformHandler);let t=()=>{if(!this._options.disabledd&&!this._drawMode)return!this._mdownOnHandle&&void 0},n=()=>{this._drawMode||this._mdownOnHandle&&clearTimeout(e)},r=()=>{this._grabbingNode=!1},i=()=>{this._drawMode||setTimeout(()=>this.clearDraws(),50)},a=e=>{let t=e.target.id();t===this._lastActiveId&&setTimeout(()=>{this._resetToDefaultState()},16)},o=e=>{let t=e.target;this.sourceNode||setTimeout(()=>{this.clearDraws(),this._drawHandle(t),t.trigger("cyeditor.noderesize-showhandle")},16)},s=()=>{this._grabbingNode=!0},l=()=>{this.clearDraws()},u=this._options.selector;this.cy.on("mouseover tap",u,this._listeners._startHandler).on("mouseover tapdragover",u,t).on("mouseout tapdragout",u,n).on("drag position",u,i).on("grab",u,l).on("drag",u,s).on("free",u,r).on("remove",u,a).on("tap",u,o),this._options.unbind=(()=>{window.removeEventListener("resize",this._listeners._sizeCanvas),this.cy.off("mouseover",u,this._listeners._startHandler).off("mouseover",u,t).off("mouseout",u,n).off("drag position",u,i).off("grab",u,l).off("free",u,r).off("remove",u,a).off("tap",u,o),this.cy.unbind("zoom pan",this._listeners.transformHandler)})}_startHandler(e){let t=e.target;if(this._options.disabledd||this._drawMode||this._mdownOnHandle||this._grabbingNode||t.isParent())return;this._listeners.lastMdownHandler&&(this._container.removeEventListener("mousedown",this._listeners.lastMdownHandler,!0),this._container.removeEventListener("touchstart",this._listeners.lastMdownHandler,!0)),this._lastActiveId=t.id(),this.clearDraws(),this._drawHandle(t),t.trigger("cyeditor.noderesize-showhandle");let n={},r=e=>{this._container.removeEventListener("mousedown",r,!0),this._container.removeEventListener("touchstart",r,!0);let a=e.touches?e.touches[0].pageX:e.pageX,o=e.touches?e.touches[0].pageY:e.pageY,s=a-F.offset(this._container).left,l=o-F.offset(this._container).top;if(n.x=s,n.y=l,0!==e.button&&!e.touches)return;let u=this._options.padding,c=t.renderedPosition(),d=t.renderedOuterWidth()+2*u,h=t.renderedOuterHeight()+2*u,p=this._options.triangleSize*this.cy.zoom(),f=c.x+d/2-p,g=c.y+h/2,v=c.x+d/2,y=c.y+h/2-p,m={x:s,y:l},b={x:f,y:g},x={x:v,y:y},w={x:c.x+d/2,y:c.y+h/2};if(!Ze(m,b,x,w))return;t.addClass("noderesize-resized"),this._mdownOnHandle=!0,e.preventDefault(),e.stopPropagation(),this.sourceNode=t,t.trigger("cyeditor.noderesize-start");let E={width:t.width(),height:t.height()},_=e=>{this._mdownOnHandle&&(this._mdownOnHandle=!1,window.removeEventListener("mousemove",i),window.removeEventListener("touchmove",i),this._resetToDefaultState(),this._options.stop(t),t.trigger("cyeditor.noderesize-stop"),this.cy.trigger("cyeditor.noderesize-resized",[t,E,{width:t.width(),height:t.height()}]))};return["mouseup","touchend","touchcancel","blur"].forEach(function(e){F.once(window,e,_)}),window.addEventListener("mousemove",i),window.addEventListener("touchmove",i),this._disableGestures(),this._options.start(t),!1},i=e=>{let r=e.touches?e.touches[0].pageX:e.pageX,i=e.touches?e.touches[0].pageY:e.pageY,a=r-F.offset(this._container).left,o=i-F.offset(this._container).top,s=a-n.x,l=o-n.y;n.x=a,n.y=o;let u=e.ctrlKey,c=t.data("width")||t.width(),d=t.data("height")||t.height();if(u){let e=c/d;0===l?l=s*=e:s=l=(l<0?Math.min(s,l):Math.max(s,l))*e}return s/=this.cy.zoom(),l/=this.cy.zoom(),t.data("width",Math.max(c+2*s,this._options.minNodeWidth)),t.data("height",Math.max(d+2*l,this._options.minNodeHeight)),this.cy.trigger("cyeditor.noderesize-resizing",[t,{width:t.width(),height:t.height()}]),this.clearDraws(),this._drawHandle(t),!1};this._container.addEventListener("mousedown",r,!0),this._container.addEventListener("touchstart",r,!0),this._listeners.lastMdownHandler=r}}var Je=e=>{e&&e("core","noderesize",function(e){return new Qe(this,e)})};const et={container:!1,attrs:["name","height","width","color","background-color"]};class tt{constructor(e,t){this.cy=e,this._options=Object.assign({},et,t),this._infos={},this.selected=[],this._initPanel(),this._initEvents()}_initEvents(){this._panel.addEventListener("input",e=>{this._options.attrs.indexOf(e.target.name)>-1&&(this._infos[e.target.name]=e.target.value,this._changeElementInfo(e.target.name,e.target.value))}),this.cy.on("select unselect",()=>{this.showElementsInfo()})}_initPanel(){let{_options:e}=this;if(e.container){if("string"===typeof e.container?this._panel=F.query(e.container)[0]:F.isNode(e.container)&&(this._panel=e.container),!this._panel)return void console.error("There is no any element matching your container")}else this._panel=document.createElement("div"),document.body.appendChild(this._panel);this._panelHtml(),this._panel.style.display="none"}_panelHtml(e={showName:!0,showBgColor:!0,showColor:!0,showRect:!0,colorTitle:"文字"}){this._panel.innerHTML=`<div class="panel-title">元素${e.titile||""}</div>\n              <div class="panel-body" id="info-items">\n                <div class="info-item-wrap" style="${e.showName?"":"display:none"}">名称：\n                    <input class="input info-item" name="name" type="text" value="">\n                </div>\n                <div class="info-item-wrap" style="${e.showRect?"":"display:none"}">尺寸：\n                    <div class="info-item">\n                        <input class="input width" name="width" autocomplete="off" type="number" step="1" value="">\n                        <input class="input height" name="height" autocomplete="off" type="number" step="1" value="">\n                    </div>\n                </div>\n                <div class="info-item-wrap" style="${e.showColor?"":"display:none"}">${e.colorTitle}：\n                    <div class="info-item">\n                        <input class="input color-input" name="color" autocomplete="off" type="color">\n                    </div>\n                </div>\n                <div class="info-item-wrap" style="${e.showBgColor?"":"display:none"}">背景：\n                    <div class="info-item">\n                        <input class="input color-input" name="background-color" autocomplete="off" type="color">\n                    </div>\n                </div>\n            </div>`}_changeElementInfo(e,t){"name"!==e?this.selected.forEach(n=>{n.isEdge()&&"color"===e&&(e="lineColor"),"background-color"===e&&(e="bg"),n.data({[e]:t})}):this.selected[0].data({name:t})}showElementsInfo(){let e=this.cy.$(":selected");this.selected=e;let t=e.every(e=>e.isNode()),n={showName:t,showBgColor:t,showColor:!0,showRect:t,colorTitle:t?"文字":"颜色"};if(e.length>1)this._infos.name="",this._panelHtml(n);else if(1===e.length){this._panelHtml(n),this._panel.style.display="block";let t=e[0];this._options.attrs.forEach(e=>{if("name"===e)this._infos[e]=t.data("name");else if("color"===e||"background-color"===e){let n=t.numericStyle(e);this._infos[e]="#"+F.RGBToHex(...n)}else this._infos[e]=t.numericStyle(e)})}else this._panel.style.display="none";this._options.attrs.filter(e=>this._infos[e]).forEach(e=>{let t=F.query(`#info-items input[name=${e}`);t.length&&(t[0].value=this._infos[e])})}}var nt=e=>{e&&e("core","editElements",function(e){return new tt(this,e)})};const rt={container:!1,addWhenDrop:!0,nodeTypes:[]};class it{constructor(e,t){this.cy=e,this._options=Object.assign({},rt,t),this._options.nodeTypes.forEach(e=>{e.width=e.width||76,e.height=e.height||76,e.category=e.category||"other"}),this._options.nodeTypes.length<1||(this._initShapePanel(),this._initShapeItems(),this._initEvents())}_initShapeItems(){let e=this._options.nodeTypes.filter(e=>e.type&&e.src);e.forEach(e=>{e._id=F.guid()});let t={},n=[];e.forEach(e=>{e.category?t[e.category]?t[e.category].push(e):t[e.category]=[e]:n.push(e)}),n.length&&(t.other=n);let r=Object.keys(t).map(e=>{let n=t[e].map(e=>{return`<img src="${e.src}"  class="shape-item" draggable="true" data-id="${e._id}" />`}).join("");return`<div class="category">\n                  <div class="title">${e}</div>\n                  <div class="shapes">${n}</div>\n                </div>`}).join("");this._shapePanel.innerHTML=r}_initEvents(){let e=this.cy.container(),t=e=>{e.preventDefault()};F.query(".shape-item").forEach(e=>{e.addEventListener("dragstart",e=>{e.dataTransfer.setData("id",e.target.getAttribute("data-id"))})}),e.addEventListener("drop",t=>{let n=t.dataTransfer.getData("id"),r=t.target.compareDocumentPosition(e);if(10===r){let e={x:t.offsetX,y:t.offsetY};if(n){const t=this._options.nodeTypes.find(e=>e._id===n);this._addNodeToCy(t,e)}}}),e.addEventListener("dragenter",t),e.addEventListener("dragover",t)}_addNodeToCy({type:e,width:t,height:n,bg:r,resize:i,name:a="",points:o,buildIn:s=!1,src:l},u){let c={type:e,name:a,resize:i,bg:r,width:t,height:n};s||(c.image=l);let d={group:"nodes",data:c,position:u};o&&(d.data.points=o),this._options.addWhenDrop&&this.cy.trigger("cyeditor.addnode",d)}_initShapePanel(){let{_options:e}=this;e.container?("string"===typeof e.container?this._shapePanel=F.query(e.container)[0]:F.isNode(e.container)&&(this._shapePanel=e.container),this._shapePanel||console.error("There is no any element matching your container")):(this._shapePanel=document.createElement("div"),document.body.appendChild(this._shapePanel))}}var at=e=>{e&&e("core","dragAddNodes",function(e){return new it(this,e)})};const ot={menus:[{id:"remove",content:"remove",disabled:!1,divider:!0},{id:"hide",content:"hide",disabled:!1}],beforeShow:()=>{return!0},beforeClose:()=>{return!0}};class st{constructor(e,t){this.cy=e,this._options=Object.assign({},ot,t),this._listeners={},this._init()}_init(){this._initContainer(),this._initDom(),this._initEvents()}_initContainer(){this._container=this.cy.container(),this.ctxmenu=document.createElement("div"),this.ctxmenu.className="cy-editor-ctx-menu",this._container.append(this.ctxmenu)}_initDom(){let e="";this._options.menus.forEach(t=>{e+=`<div class="ctx-menu-item ${t.disabled?"ctx-menu-item-disabled":""}" data-menu-item="${t.id}">${t.content}</div>`,t.divider&&(e+='<div class="ctx-menu-divider" ></div>')}),this.ctxmenu.innerHTML=e}_initEvents(){this._listeners.eventCyTap=(e=>{let t=e.renderedPosition||e.cyRenderedPosition,n=t.x,r=t.y;F.css(this.ctxmenu,{top:r+"px",left:n+"px"}),this.show(e)}),this._listeners.eventTapstart=(e=>{this.close(e)}),this._listeners.click=(e=>{const t=e.target.getAttribute("data-menu-item"),n=this._options.menus.find(e=>e.id===t);this.cy.trigger("cyeditor.ctxmenu",n)}),this.ctxmenu.addEventListener("mousedown",this._listeners.click),this.cy.on("cxttap",this._listeners.eventCyTap),this.cy.on("tapstart",this._listeners.eventTapstart)}disable(e,t=!0){const n=F.query(`.cy-editor-ctx-menu [data-menu-item=${e}]`);n.forEach(e=>{t?F.addClass(e,"ctx-menu-item-disabled"):F.removeClass(e,"ctx-menu-item-disabled")})}changeMenus(e){this._options.menus=e,this._initDom()}show(e){if("function"===typeof this._options.beforeShow&&!this.isShow){const t=this._options.beforeShow(e,this._options.menus.slice(0));!0===t?(F.css(this.ctxmenu,{display:"block"}),this.isShow=!0):t.then&&t.then(()=>{F.css(this.ctxmenu,{display:"block"}),this.isShow=!0})}}close(e){if("function"===typeof this._options.beforeShow&&this.isShow){const t=this._options.beforeClose(e);!0===t?(F.css(this.ctxmenu,{display:"none"}),this.isShow=!1):t.then&&t.then(()=>{F.css(this.ctxmenu,{display:"none"}),this.isShow=!1})}}destroyCxtMenu(){this.ctxmenu.removeEventListener("mousedown",this._listeners.click),this.cy.off("tapstart",this._listeners.eventTapstart),this.cy.off("cxttap",this._listeners.eventCyTap)}}var lt=e=>{e&&e("core","contextMenu",function(e){return new st(this,e)})};const ut=[{selector:".eh-handle",style:{"background-color":"red",width:12,height:12,shape:"ellipse","overlay-opacity":0,"border-width":12,"border-opacity":0,"background-opacity":.5}},{selector:".eh-hover",style:{"background-color":"red","background-opacity":.5}},{selector:".eh-source",style:{"border-width":2,"border-color":"red"}},{selector:".eh-target",style:{"border-width":2,"border-color":"red"}},{selector:".eh-preview, .eh-ghost-edge",style:{"background-color":"red","line-color":"red","target-arrow-color":"red","source-arrow-color":"red"}},{selector:".eh-ghost-edge.eh-preview-active",style:{opacity:0}}];var ct=ut,dt=n("320b"),ht=n.n(dt),pt=n("4ea4"),ft=n.n(pt),gt=n("ca2d"),vt=n.n(gt),yt=n("fc21"),mt=n.n(yt),bt=n("a6ac"),xt=n.n(bt),wt=n("0ab7"),Et=n.n(wt),_t=n("2a38"),kt=n.n(_t),Ct=n("1d67"),Tt=n.n(Ct);const St=[{type:"ellipse",src:ft.a,bg:"#FFC069",resize:!0,width:76,height:76,category:"基础形状",buildIn:!0},{type:"round-rectangle",src:ht.a,bg:"#1890FF",resize:!0,width:76,height:56,category:"基础形状",buildIn:!0},{type:"diamond",src:Et.a,bg:"#5CDBD3",resize:!0,width:76,height:76,category:"基础形状",buildIn:!0},{type:"pentagon",src:xt.a,bg:"#722ed1",resize:!0,width:76,height:76,category:"基础形状",buildIn:!0},{type:"tag",src:kt.a,bg:"#efbae4",resize:!0,width:70,height:76,category:"基础形状",buildIn:!0},{type:"star",src:mt.a,bg:"#00e217",resize:!0,width:76,height:76,category:"基础形状",buildIn:!0},{type:"hexagon",src:vt.a,bg:"#ea9f00",resize:!0,width:76,height:70,category:"基础形状",buildIn:!0},{type:"polygon",src:Tt.a,bg:"#f7130e",resize:!0,width:76,height:76,points:[-.33,-1,.33,-1,.33,-.33,1,-.33,1,.33,.33,.33,.33,1,-.33,1,-.33,.33,-1,.33,-1,-.33,-.33,-.33],category:"基础形状",buildIn:!0}],Dt=[{selector:"node[type]",style:{shape:"data(type)",label:"data(type)",height:"data(height)",width:"data(width)","text-valign":"center","text-halign":"center"}},{selector:"node[points]",style:{"shape-polygon-points":"data(points)",label:"polygon\n(custom points)","text-wrap":"wrap"}},{selector:"node[name]",style:{content:"data(name)"}},{selector:"node[image]",style:{"background-opacity":0,"background-fit":"cover","background-image":e=>{return e.data("image")||{value:""}}}},{selector:"node[bg]",style:{"background-opacity":.45,"background-color":"data(bg)","border-width":1,"border-opacity":.8,"border-color":"data(bg)"}},{selector:"node:active",style:{"overlay-color":"#0169D9","overlay-padding":12,"overlay-opacity":.25}},{selector:"node:selected",style:{"overlay-color":"#0169D9","overlay-padding":12,"overlay-opacity":.25}}],Pt=[{selector:"edge",style:{"curve-style":"bezier","target-arrow-shape":"triangle",width:2}},{selector:"edge[lineType]",style:{"curve-style":"data(lineType)"}},{selector:"edge[lineColor]",style:{"target-arrow-shape":"triangle",width:2,"line-color":"data(lineColor)","source-arrow-color":"data(lineColor)","target-arrow-color":"data(lineColor)","mid-source-arrow-color":"data(lineColor)","mid-target-arrow-color":"data(lineColor)"}},{selector:"edge[lineColor]:active",style:{"overlay-color":"#0169D9","overlay-padding":3,"overlay-opacity":.25,"line-color":"data(lineColor)","source-arrow-color":"data(lineColor)","target-arrow-color":"data(lineColor)","mid-source-arrow-color":"data(lineColor)","mid-target-arrow-color":"data(lineColor)"}},{selector:"edge[lineColor]:selected",style:{"overlay-color":"#0169D9","overlay-padding":3,"overlay-opacity":.25,"line-color":"data(lineColor)","source-arrow-color":"data(lineColor)","target-arrow-color":"data(lineColor)","mid-source-arrow-color":"data(lineColor)","mid-target-arrow-color":"data(lineColor)"}}];var Mt={cy:{layout:{name:"concentric",fit:!1,concentric:function(e){return 0},minNodeSpacing:100},styleEnabled:!0,style:[...Pt,...Dt,...ct],minZoom:.1,maxZoom:10},editor:{container:"",zoomRate:.2,lineType:"bezier",noderesize:!0,dragAddNodes:!0,elementsInfo:!0,toolbar:!0,snapGrid:!0,contextMenu:!0,navigator:!0,useDefaultNodeTypes:!0,nodeTypes:St,autoSave:!0,beforeAdd(e){return!0},afterAdd(e){}}};const Nt={node:{type:"rectangle",bg:"#999",resize:!0,name:"",width:80,height:80,image:""},edge:{lineColor:"#999"}};a.a.use(Ue),a.a.use(ie),a.a.use(G),a.a.use(Je),a.a.use(at),a.a.use(nt),a.a.use(Y),a.a.use(te),a.a.use(Q),a.a.use(lt);class zt extends j{constructor(e=Mt){super(),this._plugins={},this._listeners={},this._init(e)}_init(e){this._initOptions(e),this._initDom(),this._initCy(),this._initPlugin(),this._initEvents()}_verifyParams(e){const t=(t,n)=>{let r=!0;return t.forEach(t=>{const i=typeof e[t];i!==n&&(console.warn(`'editor.${t}' must be ${n}`),r=!1)}),r},{zoomRate:n,toolbar:r,nodeTypes:i}=e;t(["noderesize","dragAddNodes","elementsInfo","snapGrid","navigator","useDefaultNodeTypes","autoSave"],"boolean"),t(["beforeAdd","afterAdd"],"function"),(n<=0||n>=1||"number"!==typeof n)&&console.warn("'editor.zoomRate' must be < 1 and > 0"),"boolean"===typeof r||Array.isArray(r)||console.warn("'editor.nodeTypes' must be boolean or array"),Array.isArray(i)||console.warn("'editor.nodeTypes' must be array")}_initOptions(e={}){this.editorOptions=Object.assign({},Mt.editor,e.editor),this._verifyParams(this.editorOptions);const{useDefaultNodeTypes:t,zoomRate:n}=this.editorOptions;this._handleOptonsChange={snapGrid:this._snapGridChange,lineType:this._lineTypeChange},e.editor&&e.editor.nodeTypes&&t&&this.setOption("nodeTypes",St.concat(e.editor.nodeTypes)),(n<=0||n>=1)&&console.error("zoomRate must be float number, greater than 0 and less than 1"),this.cyOptions=Object.assign({},Mt.cy,e.cy);const{elements:r}=this.cyOptions;r&&(Array.isArray(r.nodes)&&r.nodes.forEach(e=>{e.data=Object.assign({},Nt.node,e.data)}),Array.isArray(r.edges)&&r.edges.forEach(e=>{e.data=Object.assign({},Nt.edge,e.data)}))}_initCy(){this.cyOptions.container="#cy","string"===typeof this.cyOptions.container&&(this.cyOptions.container=F.query(this.cyOptions.container)[0]),this.cyOptions.container?this.cy=a()(this.cyOptions):console.error("There is no any element matching your container")}_initDom(){let e,{dragAddNodes:t,navigator:n,elementsInfo:r,toolbar:i,container:a}=this.editorOptions,o=t?'<div class="left"></div>':"",s=n?'<div class="panel-title">导航器</div><div id="thumb"></div>':"",l=r?'<div id="info"></div>':"",u=i?'<div id="toolbar"></div>':"",c="";if((n||r)&&(c=`<div class="right">\n                ${s}\n                ${l}\n              </div>`),u+=`<div id="editor">\n                ${o}\n                <div id="cy"></div>\n                ${c}\n              </div>`,a){if("string"===typeof a?e=F.query(a)[0]:F.isNode(a)&&(e=a),!e)return void console.error("There is no any element matching your container")}else e=document.createElement("div"),e.className="cy-editor-container",document.body.appendChild(e);e.innerHTML=u}_initEvents(){const{editElements:e,edgehandles:t,noderesize:n,undoRedo:r}=this._plugins;this._listeners.showElementInfo=(()=>{e&&e.showElementsInfo()}),this._listeners.handleCommand=this._handleCommand.bind(this),this._listeners.hoverout=(e=>{t&&(t.active=!0,t.stop(e)),n&&n.clearDraws()}),this._listeners.select=(e=>{"select"!==this._doAction&&r&&this._undoRedoAction("select",e.target)}),this._listeners.addEles=((e,t)=>{t.firstTime=!0,this._hook("beforeAdd",t,!0)&&(r?this._undoRedoAction("add",t):this.cy.add(t),this._hook("afterAdd",t),this.emit("change",t,this))}),this._listeners._changeUndoRedo=this._changeUndoRedo.bind(this),this.cy.on("cyeditor.noderesize-resized cyeditor.noderesize-resizing",this._listeners.showElementInfo).on("cyeditor.toolbar-command",this._listeners.handleCommand).on("click",this._listeners.hoverout).on("select",this._listeners.select).on("cyeditor.addnode",this._listeners.addEles).on("cyeditor.afterDo cyeditor.afterRedo cyeditor.afterUndo",this._listeners._changeUndoRedo),this.emit("ready")}_initPlugin(){const{dragAddNodes:e,elementsInfo:t,toolbar:n,contextMenu:r,snapGrid:i,navigator:a,noderesize:o}=this.editorOptions;this._plugins.edgehandles=this.cy.edgehandles({snap:!1,handlePosition(){return"middle middle"},edgeParams:this._edgeParams.bind(this)}),e&&(this._plugins.dragAddNodes=this.cy.dragAddNodes({container:".left",nodeTypes:this.editorOptions.nodeTypes})),t&&(this._plugins.editElements=this.cy.editElements({container:"#info"})),(Array.isArray(n)||!0===n)&&(this._plugins.toolbar=this.cy.toolbar({container:"#toolbar",toolbar:n}),(!0===n||n.indexOf("gridon")>-1)&&this.setOption("snapGrid",!0));let s=!0===n,l=!0===n;Array.isArray(n)&&(s=n.indexOf("undo")>-1||n.indexOf("redo")>-1,l=n.indexOf("copy")>-1||n.indexOf("paset")>-1),l&&(this._plugins.clipboard=this.cy.clipboard()),s&&(this._plugins.undoRedo=this.cy.undoRedo()),i&&(this._plugins.cySnapToGrid=this.cy.snapToGrid()),a&&this.cy.navigator({container:"#thumb"}),o&&(this._plugins.noderesize=this.cy.noderesize({selector:"node[resize]"})),r&&(this._plugins.contextMenu=this.cy.contextMenu())}_snapGridChange(){this._plugins.cySnapToGrid&&(this.editorOptions.snapGrid?(this._plugins.cySnapToGrid.gridOn(),this._plugins.cySnapToGrid.snapOn()):(this._plugins.cySnapToGrid.gridOff(),this._plugins.cySnapToGrid.snapOff()))}_edgeParams(){return{data:{lineType:this.editorOptions.lineType}}}_lineTypeChange(e){let t=this.cy.$("edge:selected");t.length<1&&(t=this.cy.$("edge")),t.forEach(t=>{t.data({lineType:e})})}_handleCommand(e,t){switch(t.command){case"undo":this.undo();break;case"redo":this.redo();break;case"gridon":this.toggleGrid();break;case"zoomin":this.zoom(1);break;case"zoomout":this.zoom(-1);break;case"levelup":this.changeLevel(1);break;case"leveldown":this.changeLevel(-1);break;case"copy":this.copy();break;case"paste":this.paste();break;case"fit":this.fit();break;case"save":this.save();break;case"delete":this.deleteSelected();break;case"line-bezier":this.setOption("lineType","bezier");break;case"line-taxi":this.setOption("lineType","taxi");break;case"line-straight":this.setOption("lineType","straight");break;case"boxselect":this.cy.userPanningEnabled(!t.selected),this.cy.boxSelectionEnabled(t.selected);break;default:break}}_changeUndoRedo(){if(!this._plugins.undoRedo||!this._plugins.toolbar)return;let e=this._plugins.undoRedo.isRedoStackEmpty(),t=this._plugins.undoRedo.isUndoStackEmpty();e===this.lastCanRedo&&t===this.lastCanUndo||(this._plugins.toolbar.rerender("undo",{disabled:t}),this._plugins.toolbar.rerender("redo",{disabled:e})),this.lastCanRedo=e,this.lastCanUndo=t}_undoRedoAction(e,t){this._doAction=e,this._plugins.undoRedo.do(e,t)}_hook(e,t,n=!1){if("function"===typeof this.editorOptions[e]){const r=this.editorOptions[e](t);return!n||r}}setOption(e,t){"string"===typeof e?(this.editorOptions[e]=t,"function"===typeof this._handleOptonsChange[e]&&this._handleOptonsChange[e].call(this,t)):"object"===typeof e&&Object.assign(this.editorOptions,e)}undo(){if(this._plugins.undoRedo){let e=this._plugins.undoRedo.getRedoStack();e.length&&(this._doAction=e[e.length-1].action),this._plugins.undoRedo.undo()}else console.warn("Can not `undo`, please check the initialize option `editor.toolbar`")}redo(){if(this._plugins.undoRedo){let e=this._plugins.undoRedo.getUndoStack();e.length&&(this._doAction=e[e.length-1].action),this._plugins.undoRedo.redo()}else console.warn("Can not `redo`, please check the initialize option `editor.toolbar`")}copy(){if(this._plugins.clipboard){let e=this.cy.$(":selected");e.length&&(this._cpids=this._plugins.clipboard.copy(e),this._cpids&&this._plugins.toolbar&&this._plugins.toolbar.rerender("paste",{disabled:!1}))}else console.warn("Can not `copy`, please check the initialize option `editor.toolbar`")}paste(){this._plugins.clipboard?this._cpids&&this._plugins.clipboard.paste(this._cpids):console.warn("Can not `paste`, please check the initialize option `editor.toolbar`")}changeLevel(e=0){let t=this.cy.$(":selected");t.length&&t.forEach(t=>{let n=t.style();t.style("z-index",n.zIndex-0+e>-1?n.zIndex-0+e:0)})}deleteSelected(){let e=this.cy.$(":selected");e.length&&(this._plugins.undoRedo&&this._undoRedoAction("remove",e),this.cy.remove(e))}async save(){try{let t=await this.cy.png({output:"blob-promise"});if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(t,`chart-${Date.now()}.png`);else{let e=document.createElement("a");e.download=`chart-${Date.now()}.png`,e.href=window.URL.createObjectURL(t),e.click()}}catch(e){console.log(e)}}fit(){this._fit_status?(this.cy.viewport({zoom:this._fit_status.zoom,pan:this._fit_status.pan}),this._fit_status=null):(this._fit_status={pan:this.cy.pan(),zoom:this.cy.zoom()},this.cy.fit())}zoom(e=1,t){t=t||this.editorOptions.zoomRate;let n=this.cy.width(),r=this.cy.height(),i=this.cy.zoom()+t*e,a=this.cy.pan();a.x=a.x+-1*n*t*e/2,a.y=a.y+-1*r*t*e/2,this.cy.viewport({zoom:i,pan:a})}toggleGrid(){this._plugins.cySnapToGrid?this.setOption("snapGrid",!this.editorOptions.snapGrid):console.warn("Can not `toggleGrid`, please check the initialize option")}jpg(e={}){return this.cy.png(e)}png(e){return this.cy.png(e)}json(e=!1,t){t=t||["boxSelectionEnabled","elements","pan","panningEnabled","userPanningEnabled","userZoomingEnabled","zoom","zoomingEnabled"];let n={};if("boolean"===typeof e){let r=this.cy.json(e);return t.forEach(e=>{n[e]=r[e]}),n}return"object"===typeof e&&(n={},t.forEach(t=>{n[t]=e[t]})),this.cy.json(n)}data(e,t){return this.cy.data(e,t)}removeData(e){this.cy.removeData(e)}destroy(){this.cy.off("cyeditor.noderesize-resized cyeditor.noderesize-resizing",this._listeners.showElementInfo).off("cyeditor.toolbar-command",this._listeners.handleCommand)}}var Bt=zt,Ot=Bt;t["default"]=Ot},fc21:function(e,t,n){e.exports=n.p+"img/star.a1743878.svg"}})});
  //# sourceMappingURL=cyeditor.umd.min.js.map