diff --git a/cytoscape.3.4.0-snapshot.umd.js b/cytoscape.3.4.0-snapshot.umd.js deleted file mode 100644 index a9bd491..0000000 --- a/cytoscape.3.4.0-snapshot.umd.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016-2019, The Cytoscape Consortium. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the “Software”), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cytoscape=t()}(this,function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;nt?1:0},I=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n255)return;t.push(Math.floor(a))}var o=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(o&&!s)return;var l=n[4];if(void 0!==l){if((l=parseFloat(l))<0||l>1)return;t.push(l)}}return t}(e)||function(e){var t,n,r,i,a,o,s,l;function u(e,t,n){return n<0&&(n+=1),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("^hsl[a]?\\(((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?)))\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])(?:\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))))?\\)$").exec(e);if(c){if((n=parseInt(c[1]))<0?n=(360- -1*n%360)%360:n>360&&(n%=360),n/=360,(r=parseFloat(c[2]))<0||r>100)return;if(r/=100,(i=parseFloat(c[3]))<0||i>100)return;if(i/=100,void 0!==(a=c[4])&&((a=parseFloat(a))<0||a>1))return;if(0===r)o=s=l=Math.round(255*i);else{var h=i<.5?i*(1+r):i+r-i*r,d=2*i-h;o=Math.round(255*u(d,h,n+1/3)),s=Math.round(255*u(d,h,n)),l=Math.round(255*u(d,h,n-1/3))}t=[o,s,l,a]}return t}(e)},z={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]},L=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i=t||n<0||h&&e-u>=a}function g(){var e=J();if(f(e))return v(e);s=setTimeout(g,function(e){var n=t-(e-l);return h?Q(n,a-(e-u)):n}(e))}function v(e){return s=void 0,d&&r?p(e):(r=i=void 0,o)}function y(){var e=J(),n=f(e);if(r=arguments,i=this,l=e,n){if(void 0===s)return function(e){return u=e,s=setTimeout(g,t),c?p(e):o}(l);if(h)return s=setTimeout(g,t),p(l)}return void 0===s&&(s=setTimeout(g,t)),o}return t=te(t)||0,ee(n)&&(c=!!n.leading,a=(h="maxWait"in n)?$(te(n.maxWait)||0,t):a,d="trailing"in n?!!n.trailing:d),y.cancel=function(){void 0!==s&&clearTimeout(s),u=0,r=l=i=s=void 0},y.flush=function(){return void 0===s?o:v(J())},y},re=a?a.performance:null,ie=re&&re.now?function(){return re.now()}:function(){return Date.now()},ae=function(){if(a){if(a.requestAnimationFrame)return function(e){a.requestAnimationFrame(e)};if(a.mozRequestAnimationFrame)return function(e){a.mozRequestAnimationFrame(e)};if(a.webkitRequestAnimationFrame)return function(e){a.webkitRequestAnimationFrame(e)};if(a.msRequestAnimationFrame)return function(e){a.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout(function(){e(ie())},1e3/60)}}(),oe=function(e){return ae(e)},se=ie,le=function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5381;!(t=e.next()).done;)n=33*n^t.value;return n>>>0},ue=function(e){return(33*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:5381)^e)>>>0},ce=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return le({next:function(){return r=0&&(e[r]!==t||(e.splice(r,1),n));r--);},Me=function(e){e.splice(0,e.length)},_e=function(e,t,n){return n&&(t=M(n,t)),e[t]},Be=function(e,t,n,r){n&&(t=M(n,t)),e[t]=r},Ne="undefined"!=typeof Map?Map:function(){function e(){t(this,e),this._obj={}}return r(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}(),Ie=function(){function e(n){if(t(this,e),this._obj=Object.create(null),this.size=0,null!=n){var r;r=null!=n.instanceString&&n.instanceString()===this.instanceString()?n.toArray():n;for(var i=0;it?1:0},u=function(e,t,i,a,o){var s;if(null==i&&(i=0),null==o&&(o=n),i<0)throw new Error("lo must be non-negative");for(null==a&&(a=e.length);in;0<=n?t++:t--)u.push(t);return u}.apply(this).reverse()).length;ag;0<=g?++d:--d)v.push(a(e,r));return v},f=function(e,t,r,i){var a,o,s;for(null==i&&(i=n),a=e[r];r>t&&i(a,o=e[s=r-1>>1])<0;)e[r]=o,r=s;return e[r]=a},g=function(e,t,r){var i,a,o,s,l;for(null==r&&(r=n),a=e.length,l=t,o=e[t],i=2*t+1;i0;){var k=b.pop(),C=y(k),S=k.id();if(h[S]=C,C!==1/0)for(var D=k.neighborhood().intersect(f),T=0;T0)for(n.unshift(t);c[i];){var a=c[i];n.unshift(a.edge),n.unshift(a.node),i=(r=a.node).id()}return o.spawn(n)}}}},qe={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;t0;){if(l=g.pop(),u=l.id(),v.delete(u),w++,u===h){for(var E=[],k=i,C=h,S=m[C];E.unshift(k),null!=S&&E.unshift(S),null!=(k=y[C]);)S=m[C=k.id()];return{found:!0,distance:d[u],path:this.spawn(E),steps:w}}f[u]=!0;for(var D=l._private.edges,T=0;TT&&(f[D]=T,m[D]=S,b[D]=w),!i){var P=S*u+C;!i&&f[P]>T&&(f[P]=T,m[P]=C,b[P]=w)}}}for(var M=0;M1&&void 0!==arguments[1]?arguments[1]:a,r=[],i=m(e);;){if(null==i)return t.spawn();var o=y(i),l=o.edge,u=o.pred;if(r.unshift(i[0]),i.same(n)&&r.length>0)break;null!=l&&r.unshift(l),i=u}return s.spawn(r)},hasNegativeWeightCycle:g,negativeWeightCycles:[]}}},Ge=Math.sqrt(2),Ze=function(e,t,n){0===n.length&&we("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],h=c[1],d=c[2];(t[h]===o&&t[d]===s||t[h]===s&&t[d]===o)&&l.splice(u,1)}for(var p=0;pr;){var i=Math.floor(Math.random()*t.length);t=Ze(i,e,t),n--}return t},$e={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/Ge);if(!(r<2)){for(var s=[],l=0;l=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}}},ct=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},ht=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},dt=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},pt=function(e,t){e.x1+=t.x,e.x2+=t.x,e.y1+=t.y,e.y2+=t.y},ft=function(e,t){return!(e.x1>t.x2)&&(!(t.x1>e.x2)&&(!(e.x2t.y2)&&!(t.y1>e.y2)))))))},gt=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},vt=function(e,t){return gt(e,t.x1,t.y1)&>(e,t.x2,t.y2)},yt=function(e,t,n,r,i,a,o){var s,l=zt(i,a),u=i/2,c=a/2,h=r-c-o;if((s=Mt(e,t,n,r,n-u+l-o,h,n+u-l+o,h,!1)).length>0)return s;var d=n+u+o;if((s=Mt(e,t,n,r,d,r-c+l-o,d,r+c-l+o,!1)).length>0)return s;var p=r+c+o;if((s=Mt(e,t,n,r,n-u+l-o,p,n+u-l+o,p,!1)).length>0)return s;var f,g=n-u-o;if((s=Mt(e,t,n,r,g,r-c+l-o,g,r+c-l+o,!1)).length>0)return s;var v=n-u+l,y=r-c+l;if((f=Tt(e,t,n,r,v,y,l+o)).length>0&&f[0]<=v&&f[1]<=y)return[f[0],f[1]];var m=n+u-l,b=r-c+l;if((f=Tt(e,t,n,r,m,b,l+o)).length>0&&f[0]>=m&&f[1]<=b)return[f[0],f[1]];var x=n+u-l,w=r+c-l;if((f=Tt(e,t,n,r,x,w,l+o)).length>0&&f[0]>=x&&f[1]>=w)return[f[0],f[1]];var E=n-u+l,k=r+c-l;return(f=Tt(e,t,n,r,E,k,l+o)).length>0&&f[0]<=E&&f[1]>=k?[f[0],f[1]]:[]},mt=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),h=Math.max(r,a);return l-s<=e&&e<=u+s&&c-s<=t&&t<=h+s},bt=function(e,t,n,r,i,a,o,s,l){var u=Math.min(n,o,i)-l,c=Math.max(n,o,i)+l,h=Math.min(r,s,a)-l,d=Math.max(r,s,a)+l;return!(ec||td)},xt=function(e,t,n,r,i,a,o,s){var l=[];!function(e,t,n,r,i){var a,o,s,l,u,c,h,d;s=-27*(r/=e)+(t/=e)*(9*(n/=e)-t*t*2),a=(o=(3*n-t*t)/9)*o*o+(s/=54)*s,i[1]=0,h=t/3,a>0?(u=(u=s+Math.sqrt(a))<0?-Math.pow(-u,1/3):Math.pow(u,1/3),c=(c=s-Math.sqrt(a))<0?-Math.pow(-c,1/3):Math.pow(c,1/3),i[0]=-h+u+c,h+=(u+c)/2,i[4]=i[2]=-h,h=Math.sqrt(3)*(-c+u)/2,i[3]=h,i[5]=-h):(i[5]=i[3]=0,0===a?(d=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),i[0]=2*d-h,i[4]=i[2]=-(d+h)):(l=(o=-o)*o*o,l=Math.acos(s/Math.sqrt(l)),d=2*Math.sqrt(o),i[0]=-h+d*Math.cos(l/3),i[2]=-h+d*Math.cos((l+2*Math.PI)/3),i[4]=-h+d*Math.cos((l+4*Math.PI)/3)))}(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,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,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,1*n*i-n*n+n*e-i*e+r*a-r*r+r*t-a*t,l);for(var u=[],c=0;c<6;c+=2)Math.abs(l[c+1])<1e-7&&l[c]>=0&&l[c]<=1&&u.push(l[c]);u.push(1),u.push(0);for(var h,d,p,f=-1,g=0;g=0?pl?(e-i)*(e-i)+(t-a)*(t-a):u-h},Et=function(e,t,n){for(var r,i,a,o,s=0,l=0;l=e&&e>=a||r<=e&&e<=a))continue;(e-r)/(a-r)*(o-i)+i>t&&s++}return s%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 h,d=Math.cos(-u),p=Math.sin(-u),f=0;f0){var g=St(c,-l);h=Ct(g)}else h=c;return Et(e,t,h)},Ct=function(e){for(var t,n,r,i,a,o,s,l,u=new Array(e.length/2),c=0;c=0&&f<=1&&v.push(f),g>=0&&g<=1&&v.push(g),0===v.length)return[];var y=v[0]*s[0]+e,m=v[0]*s[1]+t;return v.length>1?v[0]==v[1]?[y,m]:[y,m,v[1]*s[0]+e,v[1]*s[1]+t]:[y,m]},Pt=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},Mt=function(e,t,n,r,i,a,o,s,l){var u=e-i,c=n-e,h=o-i,d=t-a,p=r-t,f=s-a,g=h*d-f*u,v=c*d-p*u,y=f*c-h*p;if(0!==y){var m=g/y,b=v/y;return-.001<=m&&m<=1.001&&-.001<=b&&b<=1.001?[e+m*c,t+m*p]:l?[e+m*c,t+m*p]:[]}return 0===g||0===v?Pt(e,n,o)===o?[o,s]:Pt(e,n,i)===i?[i,a]:Pt(i,o,n)===n?[n,r]:[]:[]},_t=function(e,t,n,r,i,a,o,s){var l,u,c,h,d,p,f=[],g=new Array(n.length),v=!0;if(null==a&&(v=!1),v){for(var y=0;y0){var m=St(g,-s);u=Ct(m)}else u=g}else u=n;for(var b=0;bu&&(u=t)},h=function(e){return l[e]},d=0;d0?b.edgesTo(m)[0]:m.edgesTo(b)[0];var w=r(x);m=m.id(),d[m]>d[v]+w&&(d[m]=d[v]+w,p.nodes.indexOf(m)<0?p.push(m):p.updateItem(m),u[m]=0,l[m]=[]),d[m]==d[v]+w&&(u[m]=u[m]+u[v],l[m].push(v))}else for(var E=0;E0;)for(var D=n.pop(),T=0;T0&&o.push(n[s]);0!==o.length&&i.push(r.collection(o))}return i}(c,l,t,r);return b=function(e){for(var t=0;t5&&void 0!==arguments[5]?arguments[5]:tn,o=r,s=0;s=2?ln(e,t,n,0,an,on):ln(e,t,n,0,rn)},squaredEuclidean:function(e,t,n){return ln(e,t,n,0,an)},manhattan:function(e,t,n){return ln(e,t,n,0,rn)},max:function(e,t,n){return ln(e,t,n,-1/0,sn)}};function cn(e,t,n,r,i,a){var o;return o=p(e)?e:un[e]||un.euclidean,0===t&&p(e)?o(i,a):o(t,n,r,i,a)}un["squared-euclidean"]=un.squaredEuclidean,un.squaredeuclidean=un.squaredEuclidean;var hn=Te({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),dn=function(e){return hn(e)},pn=function(e,t,n,r,i){var a="kMedoids"===i?function(e){return r[e](n)}:function(e){return n[e]};return cn(e,r.length,a,function(e){return r[e](t)})},fn=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;ln)return!1}return!0},mn=function(e,t,n){for(var r=0;ri&&(i=t[l][u],a=u);o[a].push(e[l])}for(var c=0;c=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;vn[g.key][y.key]&&(a=n[g.key][y.key])):"max"===i.linkage?(a=n[f.key][y.key],n[f.key][y.key]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):(n0&&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}(e):"mean"===t?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;a1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=1/0,i=t;i1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=-1/0,i=t;io&&(a=l,o=t[i*e+l])}a>0&&r.push(a)}for(var u=0;u=T?(P=T,T=_,M=B):_>P&&(P=_);for(var N=0;N0?1:0;C[k%u.minIterations*t+R]=F,O+=F}if(O>0&&(k>=u.minIterations-1||k==u.maxIterations-1)){for(var V=0,q=0;q0&&r.push(i);return r}(t,a,o),j=function(e,t,n){for(var r=An(e,t,n),i=0;il&&(s=u,l=c)}n[i]=a[s]}return r=An(e,t,n)}(t,r,X),W={},H=0;H0:void 0}},clearQueue:function(){return function(){var e=void 0!==this.length?this:[this];if(!(this._private.cy||this).styleEnabled())return this;for(var t=0;t0&&this.spawn(t).updateStyle().emit("class"),this},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return null!=t&&t._private.classes.has(e)},toggleClass:function(e,t){f(e)||(e=e.match(/\S+/g)||[]);for(var n=void 0===t,r=[],i=0,a=this.length;i0&&this.spawn(r).updateStyle().emit("class"),this},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var n=this;if(null==t)t=250;else if(0===t)return n;return n.addClass(e),setTimeout(function(){n.removeClass(e)},t),n}},Zn={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:'"(?:\\\\"|[^"])*"|'+"'(?:\\\\'|[^'])*'",number:B,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};Zn.variable="(?:[\\w-]|(?:\\\\"+Zn.metaChar+"))+",Zn.value=Zn.string+"|"+Zn.number,Zn.className=Zn.variable,Zn.id=Zn.variable,function(){var e,t,n;for(e=Zn.comparatorOp.split("|"),n=0;n=0||"="!==t&&(Zn.comparatorOp+="|\\!"+t)}();var Un=0,$n=1,Qn=2,Jn=3,er=4,tr=5,nr=6,rr=7,ir=8,ar=9,or=10,sr=11,lr=12,ur=13,cr=14,hr=15,dr=16,pr=17,fr=18,gr=19,vr=20,yr=[{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 function(e,t){return-1*N(e,t)}(e.selector,t.selector)}),mr=function(){for(var e,t={},n=0;n0&&l.edgeCount>0)return Ee("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(l.edgeCount>1)return Ee("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===l.edgeCount&&Ee("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},toString:function(){if(null!=this.toStringCache)return this.toStringCache;for(var e=function(e){return null==e?"":e},t=function(t){return d(t)?'"'+t+'"':e(t)},n=function(e){return" "+e+" "},r=function(r,a){var o=r.type,s=r.value;switch(o){case Un:var l=e(s);return l.substring(0,l.length-1);case Jn:var u=r.field,c=r.operator;return"["+u+n(e(c))+t(s)+"]";case tr:var h=r.operator,d=r.field;return"["+e(h)+d+"]";case er:return"["+r.field+"]";case nr:var p=r.operator;return"[["+r.field+n(e(p))+t(s)+"]]";case rr:return s;case ir:return"#"+s;case ar:return"."+s;case pr:case hr:return i(r.parent,a)+n(">")+i(r.child,a);case fr:case dr:return i(r.ancestor,a)+" "+i(r.descendant,a);case gr:var f=i(r.left,a),g=i(r.subject,a),v=i(r.right,a);return f+(f.length>0?" ":"")+g+v;case vr: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;o1&&o=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">":h=!0,r=e>n;break;case">=":h=!0,r=e>=n;break;case"<":h=!0,r=e0;){var u=i.shift();t(u),a.add(u.id()),o&&r(i,a,u)}return e}function Or(e,t,n){if(n.isParent())for(var r=n._private.children,i=0;i1&&void 0!==arguments[1])||arguments[1],Or)},zr.forEachUp=function(e){return Lr(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],Rr)},zr.forEachUpAndDown=function(e){return Lr(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],Fr)},zr.ancestors=zr.parents,(Nr=Ir={data:Hn.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:Hn.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Hn.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Hn.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Hn.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Hn.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}}).attr=Nr.data,Nr.removeAttr=Nr.removeData;var Vr,qr,Yr=Ir,Xr={};function jr(e){return function(t){if(void 0===t&&(t=!0),0!==this.length&&this.isNode()&&!this.removed()){for(var n=0,r=this[0],i=r._private.edges,a=0;at}),minIndegree:Wr("indegree",function(e,t){return et}),minOutdegree:Wr("outdegree",function(e,t){return et})}),I(Xr,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r0,c=u;u&&(l=l[0]);var h=c?l.position():{x:0,y:0};return i={x:s.x-h.x,y:s.y-h.y},void 0===e?i:i[e]}for(var p=0;p0,m=y;y&&(v=v[0]);var b=m?v.position():{x:0,y:0};void 0!==t?f.position(e,t+b[e]):void 0!==i&&f.position({x:i.x+b.x,y:i.y+b.y})}}else if(!a)return;return this}}).modelPosition=Vr.point=Vr.position,Vr.modelPositions=Vr.points=Vr.positions,Vr.renderedPoint=Vr.renderedPosition,Vr.relativePoint=Vr.relativePosition;var Gr,Zr,Ur=qr;Gr=Zr={},Zr.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}},Zr.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},Zr.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=n.boundingBox({includeLabels:r,includeOverlays:!1,useCache:!1}),o=t.position;0!==a.w&&0!==a.h||((a={w:e.pstyle("width").pfValue,h:e.pstyle("height").pfValue}).x1=o.x-a.w/2,a.x2=o.x+a.w/2,a.y1=o.y-a.h/2,a.y2=o.y+a.h/2);var s=i.width.left.value;"px"===i.width.left.units&&i.width.val>0&&(s=100*s/i.width.val);var l=i.width.right.value;"px"===i.width.right.units&&i.width.val>0&&(l=100*l/i.width.val);var u=i.height.top.value;"px"===i.height.top.units&&i.height.val>0&&(u=100*u/i.height.val);var c=i.height.bottom.value;"px"===i.height.bottom.units&&i.height.val>0&&(c=100*c/i.height.val);var h=y(i.width.val-a.w,s,l),d=h.biasDiff,p=h.biasComplementDiff,f=y(i.height.val-a.h,u,c),g=f.biasDiff,v=f.biasComplementDiff;t.autoPadding=function(e,t,n,r){if("%"!==n.units)return"px"===n.units?n.pfValue:0;switch(r){case"width":return 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}}(a.w,a.h,e.pstyle("padding"),e.pstyle("padding-relative-to").value),t.autoWidth=Math.max(a.w,i.width.val),o.x=(-d+a.x1+a.x2+p)/2,t.autoHeight=Math.max(a.h,i.height.val),o.y=(-g+a.y1+a.y2+v)/2}function y(e,t,n){var r=0,i=0,a=t+n;return e>0&&a>0&&(r=t/a*e,i=n/a*e),{biasDiff:r,biasComplementDiff:i}}}for(var r=0;re.x2?r:e.x2,e.y1=ne.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},Jr=function(e,t){return Qr(e,t.x1,t.y1,t.x2,t.y2)},ei=function(e,t,n){return _e(e,t,n)},ti=function(e,t,n){if(!t.cy().headless()){var r,i,a=t._private,o=a.rstyle,s=o.arrowWidth/2;if("none"!==t.pstyle(n+"-arrow-shape").value){"source"===n?(r=o.srcX,i=o.srcY):"target"===n?(r=o.tgtX,i=o.tgtY):(r=o.midX,i=o.midY);var l=a.arrowBounds=a.arrowBounds||{},u=l[n]=l[n]||{};u.x1=r-s,u.y1=i-s,u.x2=r+s,u.y2=i+s,u.w=u.x2-u.x1,u.h=u.y2-u.y1,ht(u,1),Qr(e,u.x1,u.y1,u.x2,u.y2)}}},ni=function(e,t,n){if(!t.cy().headless()){var r;r=n?n+"-":"";var i=t._private,a=i.rstyle;if(t.pstyle(r+"label").strValue){var o,s,l,u,c=t.pstyle("text-halign"),h=t.pstyle("text-valign"),d=ei(a,"labelWidth",n),p=ei(a,"labelHeight",n),f=ei(a,"labelX",n),g=ei(a,"labelY",n),v=t.pstyle(r+"text-margin-x").pfValue,y=t.pstyle(r+"text-margin-y").pfValue,m=t.isEdge(),b=t.pstyle(r+"text-rotation"),x=t.pstyle("text-outline-width").pfValue,w=t.pstyle("text-border-width").pfValue/2,E=t.pstyle("text-background-padding").pfValue,k=p+2*E,C=d+2*E,S=C/2,D=k/2;if(m)o=f-S,s=f+S,l=g-D,u=g+D;else{switch(c.value){case"left":o=f-C,s=f;break;case"center":o=f-S,s=f+S;break;case"right":o=f,s=f+C}switch(h.value){case"top":l=g-k,u=g;break;case"center":l=g-D,u=g+D;break;case"bottom":l=g,u=g+k}}o+=v-Math.max(x,w),s+=v+Math.max(x,w),l+=y-Math.max(x,w),u+=y+Math.max(x,w);var T=n||"main",P=i.labelBounds,M=P[T]=P[T]||{};M.x1=o,M.y1=l,M.x2=s,M.y2=u,M.w=s-o,M.h=u-l,ht(M,1);var _=m&&"autorotate"===b.strValue,B=null!=b.pfValue&&0!==b.pfValue;if(_||B){var N=_?ei(i.rstyle,"labelAngle",n):b.pfValue,I=Math.cos(N),A=Math.sin(N),z=(o+s)/2,L=(l+u)/2;if(!m){switch(c.value){case"left":z=s;break;case"right":z=o}switch(h.value){case"top":L=u;break;case"bottom":L=l}}var O=function(e,t){return{x:(e-=z)*I-(t-=L)*A+z,y:e*A+t*I+L}},R=O(o,l),F=O(o,u),V=O(s,l),q=O(s,u);o=Math.min(R.x,F.x,V.x,q.x),s=Math.max(R.x,F.x,V.x,q.x),l=Math.min(R.y,F.y,V.y,q.y),u=Math.max(R.y,F.y,V.y,q.y)}Qr(e,o,l,s,u),Qr(i.labelBounds.all,o,l,s,u)}return e}},ri=function(e){var t=0,n=function(e){return(e?1:0)<(r=S[1].x)){var D=n;n=r,r=D}if(i>(a=S[1].y)){var T=i;i=a,a=T}Qr(d,n-w,i-w,r+w,a+w)}else{for(var P=m.bezierPts||m.linePts||[],M=0;M(r=N.x)){var I=n;n=r,r=I}if((i=B.y)>(a=N.y)){var A=i;i=a,a=A}Qr(d,n-=w,i-=w,r+=w,a+=w)}}if(c&&t.includeEdges&&v&&(ti(d,e,"mid-source"),ti(d,e,"mid-target"),ti(d,e,"source"),ti(d,e,"target")),c&&"yes"===e.pstyle("ghost").value){var z=e.pstyle("ghost-offset-x").pfValue,L=e.pstyle("ghost-offset-y").pfValue;Qr(d,d.x1+z,d.y1+L,d.x2+z,d.y2+L)}var O=p.bodyBounds=p.bodyBounds||{};dt(O,d),ht(O,b),ht(O,1),c&&(n=d.x1,r=d.x2,i=d.y1,a=d.y2,Qr(d,n-x,i-x,r+x,a+x));var R=p.overlayBounds=p.overlayBounds||{};dt(R,d),ht(R,b),ht(R,1);var F=p.labelBounds=p.labelBounds||{};null!=F.all?((l=F.all).x1=1/0,l.y1=1/0,l.x2=-1/0,l.y2=-1/0,l.w=0,l.h=0):F.all=ut(),c&&t.includeLabels&&(ni(d,e,null),v&&(ni(d,e,"source"),ni(d,e,"target")))}return d.x1=$r(d.x1),d.y1=$r(d.y1),d.x2=$r(d.x2),d.y2=$r(d.y2),d.w=$r(d.x2-d.x1),d.h=$r(d.y2-d.y1),d.w>0&&d.h>0&&y&&(ht(d,b),ht(d,1)),d}(e,oi),r.bbCache=n,r.bbCacheShift.x=r.bbCacheShift.y=0,r.bbCachePosKey=a):n=r.bbCache,!s&&(0!==r.bbCacheShift.x||0!==r.bbCacheShift.y)){var l=pt,u=r.bbCacheShift,c=function(e,t){null!=e&&l(e,t)};l(n,u);var h=r.bodyBounds,d=r.overlayBounds,p=r.labelBounds,f=r.arrowBounds;c(h,u),c(d,u),null!=f&&(c(f.source,u),c(f.target,u),c(f["mid-source"],u),c(f["mid-target"],u)),null!=p&&(c(p.main,u),c(p.all,u),c(p.source,u),c(p.target,u))}if(r.bbCacheShift.x=r.bbCacheShift.y=0,!i){var g=e.isNode();n=ut(),(t.includeNodes&&g||t.includeEdges&&!g)&&(t.includeOverlays?Jr(n,r.overlayBounds):Jr(n,r.bodyBounds)),t.includeLabels&&Jr(n,r.labelBounds.all),n.w=n.x2-n.x1,n.h=n.y2-n.y1}return n},oi={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeOverlays:!0,useCache:!0},si=ri(oi),li=Te(oi);Zr.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?oi:li(e),ai(this[0],e);var t=ut(),n=li(e=e||oi);if(this.cy().styleEnabled())for(var r=0;r=0;s--)o(s);return this},Ci.emit=Ci.trigger=function(e,t,n){var r=this.listeners,i=r.length;return this.emitting++,f(t)||(t=[t]),Ti(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)&&e.eventMatches(e.context,i,a)){var o=[a];null!=t&&function(e,t){for(var n=0;n1&&!r){var i=this.length-1,a=this[i],o=a._private.data.id;this[i]=void 0,this[e]=a,n.set(o,{ele:a,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,n=e._private.data.id,r=t.map.get(n);if(!r)return this;var i=r.index;return this.unmergeAt(i),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&d(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=0;r=0;t--){e(this[t])&&this.unmergeAt(t)}return this},map:function(e,t){for(var n=[],r=0;rr&&(r=o,n=a)}return{value:r,ele:n}},min:function(e,t){for(var n,r=1/0,i=0;i=0&&i1&&void 0!==arguments[1])||arguments[1],n=this[0],r=n.cy();if(r.styleEnabled()&&n){var i=n._private.style[e];return null!=i?i:t?r.style().getDefaultProperty(e):null}},numericStyle:function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var n=t.pstyle(e);return void 0!==n.pfValue?n.pfValue:n.value}},numericStyleUnits:function(e){var t=this[0];if(t.cy().styleEnabled())return t?t.pstyle(e).units:void 0},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=this[0];return n?t.style().getRenderedStyle(n,e):void 0},style:function(e,t){var n=this.cy();if(!n.styleEnabled())return this;var r=n.style();if(g(e)){var i=e;r.applyBypass(this,i,!1),this.emitAndNotify("style")}else if(d(e)){if(void 0===t){var a=this[0];return a?r.getStylePropertyValue(a,e):void 0}r.applyBypass(this,e,t,!1),this.emitAndNotify("style")}else if(void 0===e){var o=this[0];return o?r.getRawStyle(o):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=t.style();if(void 0===e)for(var r=0;r0&&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)}}),$i.neighbourhood=$i.neighborhood,$i.closedNeighbourhood=$i.closedNeighborhood,$i.openNeighbourhood=$i.openNeighborhood,I($i,{source:Ar(function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t},"source"),target:Ar(function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t},"target"),sources:ta({attr:"source"}),targets:ta({attr:"target"})}),I($i,{edgesWith:Ar(na(),"edgesWith"),edgesTo:Ar(na({thisIsSrc:!0}),"edgesTo")}),I($i,{connectedEdges:Ar(function(e){for(var t=[],n=0;n0);return a},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),$i.componentsOf=$i.components;var ia=function(e,t,n){for(var r=null!=n?n:Ce();e.hasElementWithId(r);)r=Ce();return r},aa=function(e,t,n){if(void 0!==e&&w(e)){var r=new Ne,i=!1;if(t){if(t.length>0&&g(t[0])&&!b(t[0])){i=!0;for(var a=[],o=new Ae,s=0,l=t.length;s0&&void 0!==arguments[0])||arguments[0],r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.cy(),a=i._private,o=[],s=[],l=0,u=this.length;l0){for(var L=new aa(i,e),O=0;O0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=[],r=[],i={},a=this._private.cy;function o(e){var n=i[e.id()];t&&e.removed()||n||(i[e.id()]=!0,e.isNode()?(r.push(e),function(e){for(var t=e._private.edges,n=0;n0&&(e?b.emitAndNotify("remove"):t&&b.emit("remove"));for(var x=0;x=a?function(t,r){for(var a=0;a0?i=l:r=l}while(Math.abs(a)>o&&++u1e-4&&Math.abs(s.v)>1e-4;);return a?function(e){return u[e*(u.length-1)|0]}:c}}(),ca=function(e,t,n,r){var i=la(e,t,n,r);return function(e,t,n){return e+(t-e)*i(n)}},ha={linear:function(e,t,n){return e+(t-e)*n},ease:ca(.25,.1,.25,1),"ease-in":ca(.42,0,1,1),"ease-out":ca(0,0,.58,1),"ease-in-out":ca(.42,0,.58,1),"ease-in-sine":ca(.47,0,.745,.715),"ease-out-sine":ca(.39,.575,.565,1),"ease-in-out-sine":ca(.445,.05,.55,.95),"ease-in-quad":ca(.55,.085,.68,.53),"ease-out-quad":ca(.25,.46,.45,.94),"ease-in-out-quad":ca(.455,.03,.515,.955),"ease-in-cubic":ca(.55,.055,.675,.19),"ease-out-cubic":ca(.215,.61,.355,1),"ease-in-out-cubic":ca(.645,.045,.355,1),"ease-in-quart":ca(.895,.03,.685,.22),"ease-out-quart":ca(.165,.84,.44,1),"ease-in-out-quart":ca(.77,0,.175,1),"ease-in-quint":ca(.755,.05,.855,.06),"ease-out-quint":ca(.23,1,.32,1),"ease-in-out-quint":ca(.86,0,.07,1),"ease-in-expo":ca(.95,.05,.795,.035),"ease-out-expo":ca(.19,1,.22,1),"ease-in-out-expo":ca(1,0,0,1),"ease-in-circ":ca(.6,.04,.98,.335),"ease-out-circ":ca(.075,.82,.165,1),"ease-in-out-circ":ca(.785,.135,.15,.86),spring:function(e,t,n){if(0===n)return ha.linear;var r=ua(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":ca};function da(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 pa(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function fa(e,t,n,r,i){var a=null!=i?i.type:null;n<0?n=0:n>1&&(n=1);var o=pa(e,i),s=pa(t,i);if(v(o)&&v(s))return da(a,o,s,n,r);if(f(o)&&f(s)){for(var l=[],u=0;u0?("spring"===h&&p.push(o.duration),o.easingImpl=ha[h].apply(null,p)):o.easingImpl=ha[h]}var f,g=o.easingImpl;if(f=0===o.duration?1:(n-l)/o.duration,o.applying&&(f=o.progress),f<0?f=0:f>1&&(f=1),null==o.delay){var v=o.startPosition,y=o.position;if(y&&i&&!e.locked()){var m={};va(v.x,y.x)&&(m.x=fa(v.x,y.x,f,g)),va(v.y,y.y)&&(m.y=fa(v.y,y.y,f,g)),e.position(m)}var b=o.startPan,x=o.pan,w=a.pan,E=null!=x&&r;E&&(va(b.x,x.x)&&(w.x=fa(b.x,x.x,f,g)),va(b.y,x.y)&&(w.y=fa(b.y,x.y,f,g)),e.emit("pan"));var k=o.startZoom,C=o.zoom,S=null!=C&&r;S&&(va(k,C)&&(a.zoom=fa(k,C,f,g)),e.emit("zoom")),(E||S)&&e.emit("viewport");var D=o.style;if(D&&D.length>0&&i){for(var T=0;T=0;t--){(0,e[t])()}e.splice(0,e.length)},h=a.length-1;h>=0;h--){var d=a[h],p=d._private;p.stopped?(a.splice(h,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||ya(0,d,e),ga(t,d,e,n),p.applying&&(p.applying=!1),c(p.frames),null!=p.step&&p.step(e),d.completed()&&(a.splice(h,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;o0?t.notify("draw",n):t.notify("draw")),n.unmerge(r),t.emit("step")}var ba={animate:Hn.animate(),animation:Hn.animation(),animated:Hn.animated(),clearQueue:Hn.clearQueue(),delay:Hn.delay(),delayAnimation:Hn.delayAnimation(),stop:Hn.stop(),addToAnimationPool:function(e){this.styleEnabled()&&this._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){ma(n,e)},t.beforeRenderPriorities.animations):function t(){e._private.animationsRunning&&oe(function(n){ma(n,e),t()})}()}}},xa={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&&b(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}},wa=function(e){return d(e)?new Mr(e):e},Ea={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new ki(xa,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,wa(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,wa(t),n),this},one:function(e,t,n){return this.emitter().one(e,wa(t),n),this},once:function(e,t,n){return this.emitter().one(e,wa(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}};Hn.eventAliasesOn(Ea);var ka={png:function(e){return e=e||{},this._private.renderer.png(e)},jpg:function(e){var t=this._private.renderer;return(e=e||{}).bg=e.bg||"#fff",t.jpg(e)}};ka.jpeg=ka.jpg;var Ca={layout:function(e){if(null!=e)if(null!=e.name){var t=e.name,n=this.extension("layout",t);if(null!=n){var r;r=d(e.eles)?this.$(e.eles):null!=e.eles?e.eles:this.$();var i=new n(I({},e,{cy:this,eles:r}));return i}we("No such layout `"+t+"` found. Did you forget to import it and `cytoscape.use()` it?")}else we("A `name` must be specified to make a layout");else we("Layout options must be specified to make a layout")}};Ca.createLayout=Ca.makeLayout=Ca.layout;var Sa={notify:function(e,t){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var r=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();null!=t&&r.merge(t)}else if(n.notificationsEnabled){var i=this.renderer();!this.isDestroyed()&&i&&i.notify(e,t)}},notifications:function(e){var t=this._private;return void 0===e?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return 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;r0;)e.removeChild(e.childNodes[0]);this._private.renderer=null,this.mutableElements().forEach(function(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]})},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};Ta.invalidateDimensions=Ta.resize;var Pa={collection:function(e,t){return d(e)?this.$(e):m(e)?e.collection():f(e)?new aa(this,e,t):new aa(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}};Pa.elements=Pa.filter=Pa.$;var Ma={};Ma.apply=function(e){var t=this._private,n=t.cy.collection();t.newStyle&&(t.contextStyles={},t.propDiffs={},this.cleanElements(e,!0));for(var r=0;r0;if(h||c&&d){var p=void 0;h&&d?p=l.properties:h?p=l.properties:d&&(p=l.mappedProperties);for(var f=0;f1&&(g=1),s.color){var w=i.valueMin[0],E=i.valueMax[0],k=i.valueMin[1],C=i.valueMax[1],S=i.valueMin[2],D=i.valueMax[2],T=null==i.valueMin[3]?1:i.valueMin[3],P=null==i.valueMax[3]?1:i.valueMax[3],M=[Math.round(w+(E-w)*g),Math.round(k+(C-k)*g),Math.round(S+(D-S)*g),Math.round(T+(P-T)*g)];n={bypass:i.bypass,name:i.name,value:M,strValue:"rgb("+M[0]+", "+M[1]+", "+M[2]+")"}}else{if(!s.number)return!1;var _=i.valueMin+(i.valueMax-i.valueMin)*g;n=this.parse(i.name,_,i.bypass,"mapping")}if(!n)return f(),!1;n.mapping=i,i=n;break;case o.data:for(var B=i.field.split("."),N=h.data,I=0;I0&&a>0){for(var s={},l=!1,u=0;u0?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)},Ma.checkTrigger=function(e,t,n,r,i,a){var o=i(this.properties[t]);null!=o&&o(n,r)&&a()},Ma.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)})},Ma.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBounds},function(){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()})},Ma.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r)};var _a={applyBypass:function(e,t,n,r){var i=[];if("*"===t||"**"===t){if(void 0!==n)for(var a=0;at.length?i.substr(t.length):""}function o(){n=n.length>r.length?n.substr(r.length):""}for(i=i.replace(/[\/][*](\s|.)+?[*][\/]/g,"");;){if(i.match(/^\s*$/))break;var s=i.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!s){Ee("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+i);break}t=s[0];var l=s[1];if("core"!==l)if(new Mr(l).invalid){Ee("Skipping parsing of block: Invalid selector found in string stylesheet: "+l),a();continue}var u=s[2],c=!1;n=u;for(var h=[];;){if(n.match(/^\s*$/))break;var d=n.match(/^\s*(.+?)\s*:\s*(.+?)\s*;/);if(!d){Ee("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+u),c=!0;break}r=d[0];var p=d[1],f=d[2];if(this.properties[p])this.parse(p,f)?(h.push({name:p,val:f}),o()):(Ee("Skipping property: Invalid property definition in: "+r),o());else Ee("Skipping property: Invalid property name in: "+r),o()}if(c){a();break}this.selector(l);for(var g=0;g=7&&"d"===t[0]&&(l=new RegExp(o.data.regex).exec(t))){if(n)return!1;var h=o.data;return{name:e,value:l,strValue:""+t,mapped:h,field:l[1],bypass:n}}if(t.length>=10&&"m"===t[0]&&(u=new RegExp(o.mapData.regex).exec(t))){if(n)return!1;if(c.multiple)return!1;var g=o.mapData;if(!c.color&&!c.number)return!1;var y=this.parse(e,u[4]);if(!y||y.mapped)return!1;var m=this.parse(e,u[5]);if(!m||m.mapped)return!1;if(y.pfValue===m.pfValue||y.strValue===m.strValue)return Ee("`"+e+": "+t+"` is not a valid mapper because the output range is zero; converting to `"+e+": "+y.strValue+"`"),this.parse(e,y.strValue);if(c.color){var b=y.value,x=m.value;if(!(b[0]!==x[0]||b[1]!==x[1]||b[2]!==x[2]||b[3]!==x[3]&&(null!=b[3]&&1!==b[3]||null!=x[3]&&1!==x[3])))return!1}return{name:e,value:u,strValue:""+t,mapped:g,field:u[1],fieldMin:parseFloat(u[2]),fieldMax:parseFloat(u[3]),valueMin:y.value,valueMax:m.value,bypass:n}}}if(c.multiple&&"multiple"!==r){var w;if(w=s?t.split(/\s+/):f(t)?t:[t],c.evenMultiple&&w.length%2!=0)return null;for(var E=[],k=[],C=[],S="",D=!1,P=0;P0?" ":"")+M.strValue}return c.validate&&!c.validate(E,k)?null:c.singleEnum&&D?1===E.length&&d(E[0])?{name:e,value:E[0],strValue:E[0],bypass:n}:null:{name:e,value:E,pfValue:C,strValue:S,bypass:n,units:k}}var _,N,I=function(){for(var r=0;rc.max||c.strictMax&&t===c.max))return null;var F={name:e,value:t,strValue:""+t+(z||""),units:z,bypass:n};return c.unitless||"px"!==z&&"em"!==z?F.pfValue=t:F.pfValue="px"!==z&&z?this.getEmSizeInPixels()*t:t,"ms"!==z&&"s"!==z||(F.pfValue="ms"===z?t:1e3*t),"deg"!==z&&"rad"!==z||(F.pfValue="rad"===z?t:(_=t,Math.PI*_/180)),"%"===z&&(F.pfValue=t/100),F}if(c.propList){var V=[],q=""+t;if("none"===q);else{for(var Y=q.split(/\s*,\s*|\s+/),X=0;X0&&l>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0)return{zoom:o=(o=(o=Math.min((s-2*t)/n.w,(l-2*t)/n.h))>this._private.maxZoom?this._private.maxZoom:o)=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),v(e)?n=e:g(e)&&(n=e.level,null!=e.position?t=Qe(e.position,a,i):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||r.panningEnabled||(o=!0)),n=(n=n>r.maxZoom?r.maxZoom:n)t.maxZoom||!t.zoomingEnabled?a=!0:(t.zoom=s,i.push("zoom"))}if(r&&(!a||!e.cancelOnFailedZoom)&&t.panningEnabled){var l=e.pan;v(l.x)&&(t.pan.x=l.x,o=!1),v(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(d(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();return{x:(i-(t=void 0===t?this._private.zoom:t)*(r.x1+r.x2))/2,y:(a-t*(r.y1+r.y2))/2}}}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled?(this.viewport({pan:{x:0,y:0},zoom:1}),this):this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e,t,n=this._private,r=n.container;return n.sizeCache=n.sizeCache||(r?(e=a.getComputedStyle(r),t=function(t){return parseFloat(e.getPropertyValue(t))},{width:r.clientWidth-t("padding-left")-t("padding-right"),height:r.clientHeight-t("padding-top")-t("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}}};Va.centre=Va.center,Va.autolockNodes=Va.autolock,Va.autoungrabifyNodes=Va.autoungrabify;var qa=function(e){var t=this,n=(e=I({},e)).container;n&&!y(n)&&y(n[0])&&(n=n[0]);var r=n?n._cyreg:null;(r=r||{})&&r.cy&&(r.cy.destroy(),r={});var i=r.readies=r.readies||[];n&&(n._cyreg=r),r.cy=t;var o=void 0!==a&&void 0!==n&&!e.headless,s=e;s.layout=I({name:o?"grid":"null"},s.layout),s.renderer=I({name:o?"canvas":"null"},s.renderer);var l=function(e,t,n){return void 0!==t?t:void 0!==n?n:e},u=this._private={container:n,ready:!1,options:s,elements:new aa(this),listeners:[],aniEles:new aa(this),scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:l(!0,s.zoomingEnabled),userZoomingEnabled:l(!0,s.userZoomingEnabled),panningEnabled:l(!0,s.panningEnabled),userPanningEnabled:l(!0,s.userPanningEnabled),boxSelectionEnabled:l(!0,s.boxSelectionEnabled),autolock:l(!1,s.autolock,s.autolockNodes),autoungrabify:l(!1,s.autoungrabify,s.autoungrabifyNodes),autounselectify:l(!1,s.autounselectify),styleEnabled:void 0===s.styleEnabled?o:s.styleEnabled,zoom:v(s.zoom)?s.zoom:1,pan:{x:g(s.pan)&&v(s.pan.x)?s.pan.x:0,y:g(s.pan)&&v(s.pan.y)?s.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1};this.createEmitter(),this.selectionType(s.selectionType),this.zoomRange({min:s.minZoom,max:s.maxZoom});u.styleEnabled&&t.setStyle([]);var c=I({},s,s.renderer);t.initRenderer(c);!function(e,t){if(e.some(C))return Xn.all(e).then(t);t(e)}([s.style,s.elements],function(e){var n=e[0],a=e[1];u.styleEnabled&&t.style().append(n),function(e,n,r){t.notifications(!1);var i=t.mutableElements();i.length>0&&i.remove(),null!=e&&(g(e)||f(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=I({},t._private.options.layout);a.eles=t.elements(),t.layout(a).run()}(a,function(){t.startAnimationLoop(),u.ready=!0,p(s.ready)&&t.on("ready",s.ready);for(var e=0;e0,u=ut(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()});if(m(n.roots))e=n.roots;else if(f(n.roots)){for(var c=[],h=0;h0;){var I=M.shift(),A=P(I,_);if(A)I.outgoers().filter(function(e){return e.isNode()&&i.has(e)}).forEach(B);else if(null===A){Ee("Detected double maximal shift for node `"+I.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}T();var z=0;if(n.avoidOverlap)for(var L=0;L0&&x[0].length<=3?l/2:0),h=2*Math.PI/x[r].length*i;return 0===r&&1===x[0].length&&(c=1),{x:G+c*Math.cos(h),y:Z+c*Math.sin(h)}}return{x:G+(i+1-(a+1)/2)*o,y:(r+1)*s}}),this};var Ka={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 Ga(e){this.options=I({},Ka,e)}Ga.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=ut(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),l=s.x1+s.w/2,u=s.y1+s.h/2,c=(void 0===t.sweep?2*Math.PI-2*Math.PI/a.length:t.sweep)/Math.max(1,a.length-1),h=0,d=0;d1&&t.avoidOverlap){h*=1.75;var y=Math.cos(c)-Math.cos(0),m=Math.sin(c)-Math.sin(0),b=Math.sqrt(h*h/(y*y+m*m));o=Math.max(b,o)}return a.layoutPositions(this,t,function(e,n){var r=t.startAngle+n*c*(i?1:-1),a=o*Math.cos(r),s=o*Math.sin(r);return{x:l+a,y:u+s}}),this};var Za,Ua={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 $a(e){this.options=I({},Ua,e)}$a.prototype.run=function(){for(var e=this.options,t=e,n=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,r=e.cy,i=t.eles.nodes().not(":parent"),a=ut(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),o=a.x1+a.w/2,s=a.y1+a.h/2,l=[],u=0,c=0;c0)Math.abs(y[0].value-b.value)>=g&&(y=[],v.push(y));y.push(b)}var x=u+t.minNodeSpacing;if(!t.avoidOverlap){var w=v.length>0&&v[0].length>1,E=(Math.min(a.w,a.h)/2-x)/(v.length+w?1:0);x=Math.min(x,E)}for(var k=0,C=0;C1&&t.avoidOverlap){var P=Math.cos(T)-Math.cos(0),M=Math.sin(T)-Math.sin(0),_=Math.sqrt(x*x/(P*P+M*M));k=Math.max(_,k)}S.r=k,k+=x}if(t.equidistant){for(var B=0,N=0,I=0;I0)var l=(d=r.nodeOverlap*o)*i/(m=Math.sqrt(i*i+a*a)),h=d*a/m;else{var d,p=c(e,i,a),f=c(t,-1*i,-1*a),g=f.x-p.x,v=f.y-p.y,y=g*g+v*v,m=Math.sqrt(y);l=(d=(e.nodeRepulsion+t.nodeRepulsion)/y)*g/m,h=d*v/m}e.isLocked||(e.offsetX-=l,e.offsetY-=h),t.isLocked||(t.offsetX+=l,t.offsetY+=h)}},u=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},c=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&&0n?(u.x=r,u.y=i+a/2,u):0t&&-1*l<=s&&s<=l?(u.x=r-o/2,u.y=i-o*n/2/t,u):0=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},h=function(e,t){for(var n=0;n1){var f=t.gravity*h/p,g=t.gravity*d/p;c.offsetX+=f,c.offsetY+=g}}}}},p=function(e,t){var n=[],r=0,i=-1;for(n.push.apply(n,e.graphSet[0]),i+=e.graphSet[0].length;r<=i;){var a=n[r++],o=e.idToIndex[a],s=e.layoutNodes[o],l=s.children;if(0n)var i={x:n*e/r,y:n*t/r};else i={x:e,y:t};return i},v=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.padLefti.maxY)&&(i.maxY=t.maxY+i.padBottom,a=!0),(null==i.minY||t.minY-i.padTopg&&(d+=f+t.componentSpacing,h=0,p=0,f=0)}}}(0,i),r}).then(function(e){o.layoutNodes=e.layoutNodes,r.stop(),c()});var c=function(){!0===e.animate||!1===e.animate?u({force:!0,next:function(){n.one("layoutstop",e.stop),n.emit({type:"layoutstop",layout:n})}}):e.eles.nodes().layoutPositions(n,e,function(e){var t=o.layoutNodes[o.idToIndex[e.data("id")]];return{x:t.positionX,y:t.positionY}})};return this},Ja.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},Ja.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var eo=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:ut(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()})},o=n.eles.components(),s={},l=0;l0){a.graphSet.push(w);for(l=0;lr.count?0:r.graph},no=function e(t,n,r,i){var a=i.graphSet[r];if(-1a){var p=u(),f=c();(p-1)*f>=a?u(p-1):(f-1)*p>=a&&c(f-1)}else for(;l*s=a?c(v+1):u(g+1)}var y=i.w/l,m=i.h/s;if(t.condense&&(y=0,m=0),t.avoidOverlap)for(var b=0;b=l&&(_=0,M++)},N={},I=0;I(r=wt(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(r=xt(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),k=[{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;w0&&(y(m),y(b))}function b(e,t,n){return _e(e,t,n)}function x(n,r){var i,a=n._private,o=f;i=r?r+"-":"";var s=n.pstyle(i+"label").value;if("yes"===n.pstyle("text-events").strValue&&s){var l=a.rstyle,u=n.pstyle("text-border-width").pfValue,c=n.pstyle("text-background-padding").pfValue,h=b(l,"labelWidth",r)+u+2*o+2*c,d=b(l,"labelHeight",r)+u+2*o+2*c,p=b(l,"labelX",r),g=b(l,"labelY",r),y=b(a.rscratch,"labelAngle",r),m=p-h/2,x=p+h/2,w=g-d/2,E=g+d/2;if(y){var k=Math.cos(y),C=Math.sin(y),S=function(e,t){return{x:(e-=p)*k-(t-=g)*C+p,y:e*C+t*k+g}},D=S(m,w),T=S(m,E),P=S(x,w),M=S(x,E),_=[D.x,D.y,P.x,P.y,M.x,M.y,T.x,T.y];if(Et(e,t,_))return v(n),!0}else{if(gt({w:h,h:d,x1:m,x2:x,y1:w,y2:E},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){for(var i,a,o=this.getCachedZSortedEles().interactive,s=[],l=Math.min(e,n),u=Math.max(e,n),c=Math.min(t,r),h=Math.max(t,r),d=ut({x1:e=l,y1:t=c,x2:n=u,y2:r=h}),p=0;pD?D+"$-$"+S:S+"$-$"+D,k&&(t="unbundled$-$"+E.id);var T=m[t];null==T&&(T=m[t]=[],b.push(t)),T.push(M),k&&(T.hasUnbundled=!0),C&&(T.hasBezier=!0)}else x.push(M)}for(var P=0;Pr.id()){var I=n;n=r,r=I}i=n.position(),a=r.position(),o=n.outerWidth(),s=n.outerHeight(),l=r.outerWidth(),u=r.outerHeight(),c=g.nodeShapes[this.getNodeShape(n)],h=g.nodeShapes[this.getNodeShape(r)],p=!1;var A={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0},z=i.x,L=i.y,O=o,R=s,F=a.x,V=a.y,q=l,Y=u,X=B.length;for(w=0;w0?1:f<0?-1:0;Nt&&(ne=U?U.pfValue[It]:te,re=J.value[It]);var Ot=void 0!==(At=k?ne:void 0!==ne?Lt*ne:void 0)?At:zt;Mt=1-re,_t=re;if(Z){I=Mt;Mt=_t,_t=I}var Rt;Bt={x:(Rt="node-position"===ie?ut:lt).x1*Mt+Rt.x2*_t,y:Rt.y1*Mt+Rt.y2*_t};_.ctrlpts.push(Bt.x+d.x*Ot,Bt.y+d.y*Ot)}}else _.edgeType="straight";this.findEndpoints(M);var Ft=!v(_.startX)||!v(_.startY),Vt=!v(_.arrowStartX)||!v(_.arrowStartY),qt=!v(_.endX)||!v(_.endY),Yt=!v(_.arrowEndX)||!v(_.arrowEndY),Xt=3*(this.getArrowWidth(M.pstyle("width").pfValue,M.pstyle("arrow-scale").value)*this.arrowShapeWidth);if("bezier"===_.edgeType){var jt=rt({x:_.ctrlpts[0],y:_.ctrlpts[1]},{x:_.startX,y:_.startY}),Wt=jt=c||b){h={cp:v,segment:m};break}}if(h)break}v=h.cp;var x=(c-p)/(m=h.segment).length,w=m.t1-m.t0,E=u?m.t0+w*x:m.t1-w*x;E=lt(0,E,1),t=st(v.p0,v.p1,v.p2,E),l=function(e,t,n,r){var i=lt(0,r-.001,1),a=lt(0,r+.001,1),o=st(e,t,n,i),s=st(e,t,n,a);return To(o,s)}(v.p0,v.p1,v.p2,E);break;case"straight":case"segments":case"haystack":var k,C,S,D,T=0,P=r.allpts.length;for(g=0;g+3=c));g+=2);E=lt(0,E=(c-C)/k,1),t=function(e,t,n,r){var i=t.x-e.x,a=t.y-e.y,o=rt(e,t),s=i/o,l=a/o;return n=null==n?0:n,r=null!=r?r:n*o,{x:e.x+s*r,y:e.y+l*r}}(S,D,E),l=To(S,D)}o("labelX",s,t.x),o("labelY",s,t.y),o("labelAutoAngle",s,l)}};l("source"),l("target"),this.applyLabelDimensions(e)}},So.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},So.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),i=this.calculateLabelDimensions(e,r);Be(n.rstyle,"labelWidth",t,i.width),Be(n.rscratch,"labelWidth",t,i.width),Be(n.rstyle,"labelHeight",t,i.height),Be(n.rscratch,"labelHeight",t,i.height)},So.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?(Be(n.rscratch,e,t,r),r):_e(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=i.split("\n"),c=e.pstyle("text-max-width").pfValue,h=[],d=0;dc){for(var f=p.split(/\s+/),g="",v=0;vc)break;b+=i[w],w===i.length-1&&(x=!0)}return x||(b+="…"),b}return i},So.calculateLabelDimensions=function(e,t){var n=he(t,e._private.labelDimsKey),r=this.labelDimCache||(this.labelDimCache=[]),i=r[n];if(null!=i)return i;var a=e.pstyle("font-style").strValue,o=1*e.pstyle("font-size").pfValue+"px",s=e.pstyle("font-family").strValue,l=e.pstyle("font-weight").strValue,u=this.labelCalcDiv;u||(u=this.labelCalcDiv=document.createElement("div"),document.body.appendChild(u));var c=u.style;return c.fontFamily=s,c.fontStyle=a,c.fontSize=o,c.fontWeight=l,c.position="absolute",c.left="-9999px",c.top="-9999px",c.zIndex="-1",c.visibility="hidden",c.pointerEvents="none",c.padding="0",c.lineHeight="1","wrap"===e.pstyle("text-wrap").value?c.whiteSpace="pre":c.whiteSpace="normal",u.textContent=t,r[n]={width:Math.ceil(u.clientWidth/1),height:Math.ceil(u.clientHeight/1)}},So.calculateLabelAngles=function(e){var t=e._private.rscratch,n=e.isEdge(),r=e.pstyle("text-rotation"),i=r.strValue;"none"===i?t.labelAngle=t.sourceLabelAngle=t.targetLabelAngle=0:n&&"autorotate"===i?(t.labelAngle=t.labelAutoAngle,t.sourceLabelAngle=t.sourceLabelAutoAngle,t.targetLabelAngle=t.targetLabelAutoAngle):t.labelAngle=t.sourceLabelAngle=t.targetLabelAngle="autorotate"===i?0:r.pfValue};var Po={},Mo=!1;Po.getNodeShape=function(e){var t=e.pstyle("shape").value;if("cutrectangle"===t&&(e.width()<28||e.height()<28))return Mo||(Ee("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),Mo=!0),"rectangle";if(e.isParent())return"rectangle"===t||"roundrectangle"===t||"cutrectangle"===t||"barrel"===t?t:"rectangle";if("polygon"===t){var n=e.pstyle("shape-polygon-points").value;return this.nodeShapes.makePolygon(n).name}return t};var _o={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.desktopTapThreshold2}var T=r(t);m&&(e.hoverData.tapholdCancelled=!0);a=!0,n(g,["mousemove","vmousemove","tapdrag"],t,{x:h[0],y:h[1]});var P=function(){e.data.bgActivePosistion=void 0,e.hoverData.selecting||o.emit({originalEvent:t,type:"boxstart",position:{x:h[0],y:h[1]}}),f[4]=1,e.hoverData.selecting=!0,e.redrawHint("select",!0),e.redraw()};if(3===e.hoverData.which){if(m){var M={originalEvent:t,type:"cxtdrag",position:{x:h[0],y:h[1]}};x?x.emit(M):o.emit(M),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&g===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:h[0],y:h[1]}}),e.hoverData.cxtOver=g,g&&g.emit({originalEvent:t,type:"cxtdragover",position:{x:h[0],y:h[1]}}))}}else if(e.hoverData.dragging){if(a=!0,o.panningEnabled()&&o.userPanningEnabled()){var _;if(e.hoverData.justStartedPan){var B=e.hoverData.mdownPos;_={x:(h[0]-B[0])*s,y:(h[1]-B[1])*s},e.hoverData.justStartedPan=!1}else _={x:w[0]*s,y:w[1]*s};o.panBy(_),e.hoverData.dragged=!0}h=e.projectIntoViewport(t.clientX,t.clientY)}else if(1!=f[4]||null!=x&&!x.isEdge()){if(x&&x.isEdge()&&x.active()&&x.unactivate(),x&&x.grabbed()||g==b||(b&&n(b,["mouseout","tapdragout"],t,{x:h[0],y:h[1]}),g&&n(g,["mouseover","tapdragover"],t,{x:h[0],y:h[1]}),e.hoverData.last=g),x)if(m){if(o.boxSelectionEnabled()&&T)x&&x.grabbed()&&(c(E),x.emit("freeon"),E.emit("free"),e.dragData.didDrag&&(x.emit("dragfreeon"),E.emit("dragfree"))),P();else if(x&&x.grabbed()&&e.nodeIsDraggable(x)){var N=!e.dragData.didDrag;N&&e.redrawHint("eles",!0),e.dragData.didDrag=!0;var I=o.collection();e.hoverData.draggingEles||l(E,{inDragLayer:!0});var A={x:0,y:0};if(v(w[0])&&v(w[1])&&(A.x+=w[0],A.y+=w[1],N)){var z=e.hoverData.dragDelta;z&&v(z[0])&&v(z[1])&&(A.x+=z[0],A.y+=z[1])}for(var L=0;L0&&e.redrawHint("eles",!0),e.dragData.possibleDragElements=u=a.collection()),l!=h||e.dragData.didDrag||e.hoverData.selecting||null!=l&&l._private.selectable&&(e.hoverData.dragging||("additive"===a.selectionType()||d?l.selected()?l.unselect(["tapunselect"]):l.select(["tapselect"]):d||(a.$(t).unmerge(l).unselect(["tapunselect"]),l.select(["tapselect"]))),e.redrawHint("eles",!0)),e.hoverData.selecting){var g=a.collection(e.getAllInBox(s[0],s[1],s[2],s[3]));e.redrawHint("select",!0),g.length>0&&e.redrawHint("eles",!0),a.emit({type:"boxend",originalEvent:i,position:{x:o[0],y:o[1]}});var v=function(e){return e.selectable()&&!e.selected()};"additive"===a.selectionType()?g.emit("box").stdFilter(v).select().emit("boxselect"):(d||a.$(t).unmerge(g).unselect(),g.emit("box").stdFilter(v).select().emit("boxselect")),e.redraw()}if(e.hoverData.dragging&&(e.hoverData.dragging=!1,e.redrawHint("select",!0),e.redrawHint("eles",!0),e.redraw()),!s[4]){e.redrawHint("drag",!0),e.redrawHint("eles",!0);var y=h&&h.grabbed();c(u),y&&(h.emit("freeon"),u.emit("free"),e.dragData.didDrag&&(h.emit("dragfreeon"),u.emit("dragfree")))}}s[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 m,b,x,w,E,k,C,S,D,T,P,M,_;e.registerBinding(e.container,"wheel",function(t){if(!e.scrollingPage){var n,r=e.cy,i=e.projectIntoViewport(t.clientX,t.clientY),a=[i[0]*r.zoom()+r.pan().x,i[1]*r.zoom()+r.pan().y];e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||0!==e.selection[4]?t.preventDefault():r.panningEnabled()&&r.userPanningEnabled()&&r.zoomingEnabled()&&r.userZoomingEnabled()&&(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),n=null!=t.deltaY?t.deltaY/-250:null!=t.wheelDeltaY?t.wheelDeltaY/1e3:t.wheelDelta/1e3,n*=e.wheelSensitivity,1===t.deltaMode&&(n*=33),r.zoom({level:r.zoom()*Math.pow(10,n),renderedPosition:{x:a[0],y:a[1]}}))}},!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 B,N,I,A,z=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},L=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)};if(e.registerBinding(e.container,"touchstart",B=function(t){if(y(t)){d(),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 s=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);i[0]=s[0],i[1]=s[1]}if(t.touches[1]){s=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);i[2]=s[0],i[3]=s[1]}if(t.touches[2]){s=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);i[4]=s[0],i[5]=s[1]}if(t.touches[1]){c(e.dragData.touchDragEles);var h=e.findContainerClientCoords();D=h[0],T=h[1],P=h[2],M=h[3],m=t.touches[0].clientX-D,b=t.touches[0].clientY-T,x=t.touches[1].clientX-D,w=t.touches[1].clientY-T,_=0<=m&&m<=P&&0<=x&&x<=P&&0<=b&&b<=M&&0<=w&&w<=M;var p=r.pan(),f=r.zoom();E=z(m,b,x,w),k=L(m,b,x,w),S=[((C=[(m+x)/2,(b+w)/2])[0]-p.x)/f,(C[1]-p.y)/f];if(k<4e4&&!t.touches[2]){var g=e.findNearestElement(i[0],i[1],!0,!0),v=e.findNearestElement(i[2],i[3],!0,!0);return g&&g.isNode()?(g.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:i[0],y:i[1]}}),e.touchData.start=g):v&&v.isNode()?(v.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:i[0],y:i[1]}}),e.touchData.start=v):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),N=B[0];if(null!=N&&(N.activate(),e.touchData.start=N,e.touchData.starts=B,e.nodeIsGrabbable(N))){var I=e.dragData.touchDragEles=r.collection(),A=null;e.redrawHint("eles",!0),e.redrawHint("drag",!0),N.selected()?(A=r.$(function(t){return t.selected()&&e.nodeIsGrabbable(t)}),l(A,{addToList:I})):u(N,{addToList:I}),o(N);var O=function(e){return{originalEvent:t,type:e,position:{x:i[0],y:i[1]}}};N.emit(O("grabon")),A?A.forEach(function(e){e.emit(O("grab"))}):N.emit(O("grab"))}n(N,["touchstart","tapstart","vmousedown"],t,{x:i[0],y:i[1]}),null==N&&(e.data.bgActivePosistion={x:s[0],y:s[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 R=e.touchData.startPosition=[],F=0;F=e.touchTapThreshold2}if(r&&e.touchData.cxt){t.preventDefault();var N=t.touches[0].clientX-D,I=t.touches[0].clientY-T,A=t.touches[1].clientX-D,O=t.touches[1].clientY-T,R=L(N,I,A,O);if(R/k>=2.25||R>=22500){e.touchData.cxt=!1,e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var F={originalEvent:t,type:"cxttapend",position:{x:s[0],y:s[1]}};e.touchData.start?(e.touchData.start.unactivate().emit(F),e.touchData.start=null):o.emit(F)}}if(r&&e.touchData.cxt){F={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(F):o.emit(F),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var V=e.findNearestElement(s[0],s[1],!0,!0);e.touchData.cxtOver&&V===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:s[0],y:s[1]}}),e.touchData.cxtOver=V,V&&V.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),a&&0!==a.length&&void 0!==a[0]?(a[2]=(s[0]+s[2]+s[4])/3,a[3]=(s[1]+s[3]+s[5])/3):(a[0]=(s[0]+s[2]+s[4])/3,a[1]=(s[1]+s[3]+s[5])/3,a[2]=(s[0]+s[2]+s[4])/3+1,a[3]=(s[1]+s[3]+s[5])/3+1),a[4]=1,e.touchData.selecting=!0,e.redraw();else if(r&&t.touches[1]&&o.zoomingEnabled()&&o.panningEnabled()&&o.userZoomingEnabled()&&o.userPanningEnabled()){if(t.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),ee=e.dragData.touchDragEles){e.redrawHint("drag",!0);for(var q=0;q0&&!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",I=function(t){var n=e.touchData.start;e.touchData.capture=!1,n&&n.unactivate()}),e.registerBinding(window,"touchend",A=function(r){var i=e.touchData.start;if(e.touchData.capture){0===r.touches.length&&(e.touchData.capture=!1),r.preventDefault();var a=e.selection;e.swipePanning=!1,e.hoverData.draggingEles=!1;var o,s=e.cy,l=s.zoom(),u=e.touchData.now,h=e.touchData.earlier;if(r.touches[0]){var d=e.projectIntoViewport(r.touches[0].clientX,r.touches[0].clientY);u[0]=d[0],u[1]=d[1]}if(r.touches[1]){d=e.projectIntoViewport(r.touches[1].clientX,r.touches[1].clientY);u[2]=d[0],u[3]=d[1]}if(r.touches[2]){d=e.projectIntoViewport(r.touches[2].clientX,r.touches[2].clientY);u[4]=d[0],u[5]=d[1]}if(i&&i.unactivate(),e.touchData.cxt){if(o={originalEvent:r,type:"cxttapend",position:{x:u[0],y:u[1]}},i?i.emit(o):s.emit(o),!e.touchData.cxtDragged){var p={originalEvent:r,type:"cxttap",position:{x:u[0],y:u[1]}};i?i.emit(p):s.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]&&s.boxSelectionEnabled()&&e.touchData.selecting){e.touchData.selecting=!1;var f=s.collection(e.getAllInBox(a[0],a[1],a[2],a[3]));a[0]=void 0,a[1]=void 0,a[2]=void 0,a[3]=void 0,a[4]=0,e.redrawHint("select",!0),s.emit({type:"boxend",originalEvent:r,position:{x:u[0],y:u[1]}});f.emit("box").stdFilter(function(e){return e.selectable()&&!e.selected()}).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 g=e.dragData.touchDragEles;if(null!=i){var v=i._private.grabbed;c(g),e.redrawHint("drag",!0),e.redrawHint("eles",!0),v&&(i.emit("freeon"),g.emit("free"),e.dragData.didDrag&&(i.emit("dragfreeon"),g.emit("dragfree"))),n(i,["touchend","tapend","vmouseup","tapdragout"],r,{x:u[0],y:u[1]}),i.unactivate(),e.touchData.start=null}else{var y=e.findNearestElement(u[0],u[1],!0,!0);n(y,["touchend","tapend","vmouseup","tapdragout"],r,{x:u[0],y:u[1]})}var m=e.touchData.startPosition[0]-u[0],b=m*m,x=e.touchData.startPosition[1]-u[1],w=(b+x*x)*l*l;e.touchData.singleTouchMoved||(i||s.$(":selected").unselect(["tapunselect"]),n(i,["tap","vclick"],r,{x:u[0],y:u[1]})),null!=i&&!e.dragData.didDrag&&i._private.selectable&&w0)return g[0]}return null},d=Object.keys(c),p=0;p0?l:yt(i,a,e,t,n,r,o)},checkPoint:function(e,t,n,r,i,a,o){var s=zt(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;return!!Et(e,t,[a-u,o-c,a-u,o,a+u,o,a+u,o-c])||(!!Dt(e,t,l,l,a+r/2-s,o+i/2-s,n)||!!Dt(e,t,l,l,a-r/2+s,o+i/2-s,n))}}},zo.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",Nt(3,0)),this.generatePolygon("rectangle",Nt(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",Nt(5,0)),this.generatePolygon("hexagon",Nt(6,0)),this.generatePolygon("heptagon",Nt(7,0)),this.generatePolygon("octagon",Nt(8,0));var n=new Array(20),r=At(5,0),i=At(5,Math.PI/5),a=.5*(3-Math.sqrt(5));a*=1.57;for(var o=0;o=e.deqFastCost*g)break}else if(i){if(p>=e.deqCost*l||p>=e.deqAvgCost*s)break}else if(f>=e.deqNoDrawCost*(1e3/60))break;var v=e.deq(t,h,c);if(!(v.length>0))break;for(var y=0;y0&&(e.onDeqd(t,u),!i&&e.shouldRedraw(t,u,h,c)&&r())},i(t))}}},qo=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:me;t(this,e),this.idsByKey=new Ne,this.keyForId=new Ne,this.cachesByLvl=new Ne,this.lvls=[],this.getKey=n,this.doesEleInvalidateKey=r}return r(e,[{key:"getIdsFor",value:function(e){null==e&&we("Can not get id list for null key");var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new Ae,t.set(e,n)),n}},{key:"addIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).add(t)}},{key:"deleteIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).delete(t)}},{key:"getNumberOfIdsForKey",value:function(e){return null==e?0:this.getIdsFor(e).size}},{key:"updateKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t),r=this.getKey(e);this.deleteIdForKey(n,t),this.addIdForKey(r,t),this.keyForId.set(t,r)}},{key:"deleteKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteIdForKey(n,t),this.keyForId.delete(t)}},{key:"keyHasChangedFor",value:function(e){var t=e.id();return this.keyForId.get(t)!==this.getKey(e)}},{key:"isInvalid",value:function(e){return this.keyHasChangedFor(e)||this.doesEleInvalidateKey(e)}},{key:"getCachesAt",value:function(e){var t=this.cachesByLvl,n=this.lvls,r=t.get(e);return r||(r=new Ne,t.set(e,r),n.push(e)),r}},{key:"getCache",value:function(e,t){return this.getCachesAt(t).get(e)}},{key:"get",value:function(e,t){var n=this.getKey(e),r=this.getCache(n,t);return null!=r&&this.updateKeyMappingFor(e),r}},{key:"getForCachedKey",value:function(e,t){var n=this.keyForId.get(e.id());return this.getCache(n,t)}},{key:"hasCache",value:function(e,t){return this.getCachesAt(t).has(e)}},{key:"has",value:function(e,t){var n=this.getKey(e);return this.hasCache(n,t)}},{key:"setCache",value:function(e,t,n){n.key=e,this.getCachesAt(t).set(e,n)}},{key:"set",value:function(e,t,n){var r=this.getKey(e);this.setCache(r,t,n),this.updateKeyMappingFor(e)}},{key:"deleteCache",value:function(e,t){this.getCachesAt(t).delete(e)}},{key:"delete",value:function(e,t){var n=this.getKey(e);this.deleteCache(n,t)}},{key:"invalidateKey",value:function(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}(),Yo={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},Xo=Te({getKey:null,doesEleInvalidateKey:me,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:ye,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),jo=function(e,t){this.renderer=e,this.onDequeues=[];var n=Xo(t);I(this,n),this.lookup=new qo(n.getKey,n.doesEleInvalidateKey),this.setupDequeueing()},Wo=jo.prototype;Wo.reasons=Yo,Wo.getTextureQueue=function(e){return this.eleImgCaches=this.eleImgCaches||{},this.eleImgCaches[e]=this.eleImgCaches[e]||[]},Wo.getRetiredTextureQueue=function(e){var t=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return t[e]=t[e]||[]},Wo.getElementQueue=function(){return this.eleCacheQueue=this.eleCacheQueue||new Re(function(e,t){return t.reqs-e.reqs})},Wo.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},Wo.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(nt(s*n))),r<-4)r=-4;else if(s>=7.99||r>3)return null;var u=Math.pow(2,r),c=t.h*u,h=t.w*u,d=o.eleTextBiggerThanMin(e,u);if(!this.isVisible(e,d))return null;var p,f=l.get(e,r);if(f&&f.invalidated&&(f.invalidated=!1,f.texture.invalidatedWidth-=f.width),f)return f;if(p=c<=25?25:c<=50?50:50*Math.ceil(c/50),c>1024||h>1024)return null;var g=a.getTextureQueue(p),v=g[g.length-2],y=function(){return a.recycleTexture(p,h)||a.addTexture(p,h)};v||(v=g[g.length-1]),v||(v=y()),v.width-v.usedWidthr;T--)S=a.getElement(e,t,n,T,Yo.downscale);D()}else{var P;if(!x&&!w&&!E)for(var M=r-1;M>=-4;M--){var _=l.get(e,M);if(_){P=_;break}}if(b(P))return a.queueElement(e,r),P;v.context.translate(v.usedWidth,0),v.context.scale(u,u),this.drawElement(v.context,e,t,d,!1),v.context.scale(1/u,1/u),v.context.translate(-v.usedWidth,0)}return f={x:v.usedWidth,texture:v,level:r,scale:u,width:h,height:c,scaledLabelShown:d},v.usedWidth+=Math.ceil(h+8),v.eleCaches.push(f),l.set(e,r,f),a.checkTextureFullness(v),f},Wo.invalidateElements=function(e){for(var t=0;t=.2*e.width&&this.retireTexture(e)},Wo.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>.8&&e.fullnessChecks>=10?Pe(t,e):e.fullnessChecks++},Wo.retireTexture=function(e){var t=e.height,n=this.getTextureQueue(t),r=this.lookup;Pe(n,e),e.retired=!0;for(var i=e.eleCaches,a=0;a=t)return a.retired=!1,a.usedWidth=0,a.invalidatedWidth=0,a.fullnessChecks=0,Me(a.eleCaches),a.context.setTransform(1,0,0,1,0,0),a.context.clearRect(0,0,a.width,a.height),Pe(r,a),n.push(a),a}},Wo.queueElement=function(e,t){var n=this.getElementQueue(),r=this.getElementKeyToQueue(),i=this.getKey(e),a=r[i];if(a)a.level=Math.max(a.level,t),a.eles.merge(e),a.reqs++,n.updateItem(a);else{var o={eles:e.spawn().merge(e),level:t,reqs:1,key:i};n.push(o),r[i]=o}},Wo.dequeue=function(e){for(var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=[],i=this.lookup,a=0;a<1&&t.size()>0;a++){var o=t.pop(),s=o.key,l=o.eles[0],u=i.hasCache(l,o.level);if(n[s]=null,!u){r.push(o);var c=this.getBoundingBox(l);this.getElement(l,c,e,o.level,Yo.dequeue)}}return r},Wo.removeFromQueue=function(e){var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=this.getKey(e),i=n[r];null!=i&&(1===i.eles.length?(i.reqs=ve,t.updateItem(i),t.pop(),n[r]=null):i.eles.unmerge(e))},Wo.onDequeue=function(e){this.onDequeues.push(e)},Wo.offDequeue=function(e){Pe(this.onDequeues,e)},Wo.setupDequeueing=Vo({deqRedrawThreshold:100,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n=3.99||n>2)return null;r.validateLayersElesOrdering(n,e);var o,s,l=r.layersByLevel,u=Math.pow(2,n),c=l[n]=l[n]||[];if(r.levelIsComplete(n,e))return c;!function(){var t=function(t){if(r.validateLayersElesOrdering(t,e),r.levelIsComplete(t,e))return s=l[t],!0},i=function(e){if(!s)for(var r=n+e;-4<=r&&r<=2&&!t(r);r+=e);};i(1),i(-1);for(var a=c.length-1;a>=0;a--){var o=c[a];o.invalid&&Pe(c,o)}}();var h=function(t){var i=(t=t||{}).after;if(function(){if(!o){o=ut();for(var t=0;t16e6)return null;var a=r.makeLayer(o,n);if(null!=i){var s=c.indexOf(i)+1;c.splice(s,0,a)}else(void 0===t.insert||t.insert)&&c.unshift(a);return a};if(r.skipping&&!a)return null;for(var d=null,p=e.length/1,f=!a,g=0;g=p||!vt(d.bb,v.boundingBox()))&&!(d=h({insert:!0,after:d})))return null;s||f?r.queueLayer(d,v):r.drawEleInLayer(d,v,n,t),d.eles.push(v),m[n]=d}}return s||(f?null:c)},Ko.getEleLevelForLayerLevel=function(e,t){return e},Ko.drawEleInLayer=function(e,t,n,r){var i=this.renderer,a=e.context,o=t.boundingBox();0!==o.w&&0!==o.h&&t.visible()&&(n=this.getEleLevelForLayerLevel(n,r),i.setImgSmoothing(a,!1),i.drawCachedElement(a,t,null,null,n,!0),i.setImgSmoothing(a,!0))},Ko.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||0===n.length)return!1;for(var r=0,i=0;i0)return!1;if(a.invalid)return!1;r+=a.eles.length}return r===t.length},Ko.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r0){e=!0;break}}return e},Ko.invalidateElements=function(e){var t=this;0!==e.length&&(t.lastInvalidationTime=se(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,function(e,n,r){t.invalidateLayer(e)}))},Ko.invalidateLayer=function(e){if(this.lastInvalidationTime=se(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];Pe(r,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var i=0;i3&&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,h=t.pstyle("width").pfValue,d=t.pstyle("line-cap").value,p=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;e.lineWidth=h,e.lineCap=d,o.eleStrokeStyle(e,t,n),o.drawEdgePath(t,e,s.allpts,c),e.lineCap="butt"},f=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;o.drawArrowheads(e,t,n)};if(e.lineJoin="round","yes"===t.pstyle("ghost").value){var g=t.pstyle("ghost-offset-x").pfValue,v=t.pstyle("ghost-offset-y").pfValue,y=t.pstyle("ghost-opacity").value,m=u*y;e.translate(g,v),p(m),f(m),e.translate(-g,-v)}p(),f(),i&&o.drawEdgeOverlay(e,t),o.drawElementText(e,t,null,r),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=2*t.pstyle("overlay-padding").pfValue,s=t.pstyle("overlay-color").value;e.lineWidth=o,"self"!==a.edgeType||i?e.lineCap="round":e.lineCap="butt",r.colorStrokeStyle(e,s[0],s[1],s[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 h=n.join("$");a.pathCacheKey&&a.pathCacheKey===h?(i=t=a.pathCache,s=!0):(i=t=new Path2D,a.pathCacheKey=h,a.pathCache=i)}if(o.setLineDash)switch(r){case"dotted":o.setLineDash([1,1]);break;case"dashed":o.setLineDash(u),o.lineDashOffset=c;break;case"solid":o.setLineDash([])}if(!s&&!a.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),a.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var d=2;d+35&&void 0!==arguments[5])||arguments[5],o=this;if(null==r){if(!o.eleTextBiggerThanMin(t))return}else if(!1===r)return;if(t.isNode()){if(!(s=t.pstyle("label"))||!s.value)return;switch(t.pstyle("text-halign").strValue){case"left":e.textAlign="right";break;case"right":e.textAlign="left";break;default:e.textAlign="center"}e.textBaseline="bottom"}else{var s=t.pstyle("label"),l=t.pstyle("source-label"),u=t.pstyle("target-label");if(!(s&&s.value||l&&l.value||u&&u.value))return;e.textAlign="center",e.textBaseline="bottom"}var c,h=!n;n&&(c=n,e.translate(-c.x1,-c.y1)),null==i?(o.drawText(e,t,null,h,a),t.isEdge()&&(o.drawText(e,t,"source",h,a),o.drawText(e,t,"target",h,a))):o.drawText(e,t,i,h,a),n&&e.translate(c.x1,c.y1)},us.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n2&&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)},us.getTextAngle=function(e,t){var n=e._private.rscratch,r=t?t+"-":"",i=e.pstyle(r+"text-rotation"),a=_e(n,"labelAngle",t);return"autorotate"===i.strValue?e.isEdge()?a:0:"none"===i.strValue?0:i.pfValue},us.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.rscratch,o=i?t.effectiveOpacity():1;if(0!==o&&0!==t.pstyle("text-opacity").value){"main"===n&&(n=null);var s,l,u,c,h,d,p=_e(a,"labelX",n),f=_e(a,"labelY",n),g=this.getLabelText(t,n);if(null!=g&&""!==g&&!isNaN(p)&&!isNaN(f)){this.setupTextStyle(e,t,i);var v,y=n?n+"-":"",m=_e(a,"labelWidth",n),b=_e(a,"labelHeight",n),x=t.pstyle(y+"text-margin-x").pfValue,w=t.pstyle(y+"text-margin-y").pfValue,E=t.isEdge(),k=t.pstyle("text-halign").value,C=t.pstyle("text-valign").value;if(E&&(k="center",C="center"),p+=x,f+=w,0!==(v=r?this.getTextAngle(t,n):0)){var S=p,D=f;e.translate(S,D),e.rotate(v),p=0,f=0}switch(C){case"top":break;case"center":f+=b/2;break;case"bottom":f+=b}var T=t.pstyle("text-background-opacity").value,P=t.pstyle("text-border-opacity").value,M=t.pstyle("text-border-width").pfValue,_=t.pstyle("text-background-padding").pfValue;if(T>0||M>0&&P>0){var B=p-_;switch(k){case"left":B-=m;break;case"center":B-=m/2}var N=f-b-_,I=m+2*_,A=b+2*_;if(T>0){var z=e.fillStyle,L=t.pstyle("text-background-color").value;e.fillStyle="rgba("+L[0]+","+L[1]+","+L[2]+","+T*o+")","roundrectangle"==t.pstyle("text-background-shape").strValue?(l=B,u=N,c=I,h=A,d=(d=2)||5,(s=e).beginPath(),s.moveTo(l+d,u),s.lineTo(l+c-d,u),s.quadraticCurveTo(l+c,u,l+c,u+d),s.lineTo(l+c,u+h-d),s.quadraticCurveTo(l+c,u+h,l+c-d,u+h),s.lineTo(l+d,u+h),s.quadraticCurveTo(l,u+h,l,u+h-d),s.lineTo(l,u+d),s.quadraticCurveTo(l,u,l+d,u),s.closePath(),s.fill()):e.fillRect(B,N,I,A),e.fillStyle=z}if(M>0&&P>0){var O=e.strokeStyle,R=e.lineWidth,F=t.pstyle("text-border-color").value,V=t.pstyle("text-border-style").value;if(e.strokeStyle="rgba("+F[0]+","+F[1]+","+F[2]+","+P*o+")",e.lineWidth=M,e.setLineDash)switch(V){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=M/4,e.setLineDash([]);break;case"solid":e.setLineDash([])}if(e.strokeRect(B,N,I,A),"double"===V){var q=M/2;e.strokeRect(B+q,N+q,I-2*q,A-2*q)}e.setLineDash&&e.setLineDash([]),e.lineWidth=R,e.strokeStyle=O}}var Y=2*t.pstyle("text-outline-width").pfValue;if(Y>0&&(e.lineWidth=Y),"wrap"===t.pstyle("text-wrap").value){var X=_e(a,"labelWrapCachedLines",n),j=b/X.length;switch(C){case"top":f-=(X.length-1)*j;break;case"center":case"bottom":f-=(X.length-1)*j}for(var W=0;W0&&e.strokeText(X[W],p,f),e.fillText(X[W],p,f),f+=j}else Y>0&&e.strokeText(g,p,f),e.fillText(g,p,f);0!==v&&(e.rotate(-v),e.translate(-S,-D))}}};var cs={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,h=t.position();if(v(h.x)&&v(h.y)&&t.visible()){var d,p,f=s?t.effectiveOpacity():1,g=l.usePaths(),y=!1,m=t.padding();r=t.width()+2*m,i=t.height()+2*m,n&&(p=n,e.translate(-p.x1,-p.y1));for(var b=t.pstyle("background-image").value,x=new Array(b.length),w=new Array(b.length),E=0,k=0;k0&&void 0!==arguments[0]?arguments[0]:P;l.eleFillStyle(e,t,n)},I=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:B;l.colorStrokeStyle(e,M[0],M[1],M[2],t)},A=t.pstyle("shape").strValue,z=t.pstyle("shape-polygon-points").pfValue;if(g){e.translate(h.x,h.y);var L=l.nodePathCache=l.nodePathCache||[],O=de("polygon"===A?A+","+z.join(","):A,""+i,""+r),R=L[O];null!=R?(d=R,y=!0,c.pathCache=d):(d=new Path2D,L[O]=c.pathCache=d)}var F=function(){if(!y){var n=h;g&&(n={x:0,y:0}),l.nodeShapes[l.getNodeShape(t)].draw(d||e,n.x,n.y,r,i)}g?e.fill(d):e.fill()},V=function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f,r=u.backgrounding,i=0,a=0;a0&&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,h.x,h.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(d):e.fill())},X=function(){if(T>0){if(e.lineWidth=T,e.lineCap="butt",e.setLineDash)switch(_){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([])}if(g?e.stroke(d):e.stroke(),"double"===_){e.lineWidth=T/3;var t=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",g?e.stroke(d):e.stroke(),e.globalCompositeOperation=t}e.setLineDash&&e.setLineDash([])}};if("yes"===t.pstyle("ghost").value){var j=t.pstyle("ghost-offset-x").pfValue,W=t.pstyle("ghost-offset-y").pfValue,H=t.pstyle("ghost-opacity").value,K=H*f;e.translate(j,W),N(H*P),F(),V(K),q(0!==D||0!==T),Y(K),I(H*B),X(),e.translate(-j,-W)}N(),F(),V(),q(0!==D||0!==T),Y(),I(),X(),g&&e.translate(-h.x,-h.y),l.drawElementText(e,t,null,a),o&&l.drawNodeOverlay(e,t,h,r,i),n&&e.translate(p.x1,p.y1)}},drawNodeOverlay:function(e,t,n,r,i){if(t.visible()){var a=t.pstyle("overlay-padding").pfValue,o=t.pstyle("overlay-opacity").value,s=t.pstyle("overlay-color").value;if(o>0){if(n=n||t.position(),null==r||null==i){var l=t.padding();r=t.width()+2*l,i=t.height()+2*l}this.colorFillStyle(e,s[0],s[1],s[2],o),this.nodeShapes.roundrectangle.draw(e,n.x,n.y,r+2*a,i+2*a),e.fill()}}},hasPie:function(e){return(e=e[0])._private.hasPie},drawPie:function(e,t,n,r){t=t[0],r=r||t.position();var i=t.cy().style(),a=t.pstyle("pie-size"),o=r.x,s=r.y,l=t.width(),u=t.height(),c=Math.min(l,u)/2,h=0;this.usePaths()&&(o=0,s=0),"%"===a.units?c*=a.pfValue:void 0!==a.pfValue&&(c=a.pfValue/2);for(var d=1;d<=i.pieBackgroundN;d++){var p=t.pstyle("pie-"+d+"-background-size").value,f=t.pstyle("pie-"+d+"-background-color").value,g=t.pstyle("pie-"+d+"-background-opacity").value*n,v=p/100;v+h>1&&(v=1-h);var y=1.5*Math.PI+2*Math.PI*h,m=y+2*Math.PI*v;0===p||h>=1||h+v>1||(e.beginPath(),e.moveTo(o,s),e.arc(o,s,c,y,m),e.closePath(),this.colorFillStyle(e,f[0],f[1],f[2],g),e.fill(),h+=v)}}},hs={};hs.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},hs.paintCache=function(e){for(var t,n=this.paintCaches=this.paintCaches||[],r=!0,i=0;io.minMbLowQualFrames&&(o.motionBlurPxRatio=o.mbPxRBlurry)),o.clearingMotionBlur&&(o.motionBlurPxRatio=1),o.textureDrawLastFrame&&!h&&(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},k={zoom:b,pan:{x:w.x,y:w.y}},C=o.prevViewport;void 0===C||k.zoom!==C.zoom||k.pan.x!==C.pan.x||k.pan.y!==C.pan.y||g&&!f||(o.motionBlurPxRatio=1),a&&(E=a),x*=s,E.x*=s,E.y*=s;var S=o.getCachedZSortedEles();function D(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 T(e,r){var s,l,c,h;o.clearingMotionBlur||e!==u.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]&&e!==u.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]?(s=E,l=x,c=o.canvasWidth,h=o.canvasHeight):(s={x:w.x*p,y:w.y*p},l=b*p,c=o.canvasWidth*p,h=o.canvasHeight*p),e.setTransform(1,0,0,1,0,0),"motionBlur"===r?D(e,0,0,c,h):t||void 0!==r&&!r||e.clearRect(0,0,c,h),n||(e.translate(s.x,s.y),e.scale(l,l)),a&&e.translate(a.x,a.y),i&&e.scale(i,i)}if(h||(o.textureDrawLastFrame=!1),h){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}),(k=o.textureCache.viewport={zoom:l.zoom(),pan:l.pan(),width:o.canvasWidth,height:o.canvasHeight}).mpan={x:(0-k.pan.x)/k.zoom,y:(0-k.pan.y)/k.zoom}}c[o.DRAG]=!1,c[o.NODE]=!1;var M=u.contexts[o.NODE],_=o.textureCache.texture;k=o.textureCache.viewport;M.setTransform(1,0,0,1,0,0),d?D(M,0,0,k.width,k.height):M.clearRect(0,0,k.width,k.height);var B=m.core("outside-texture-bg-color").value,N=m.core("outside-texture-bg-opacity").value;o.colorFillStyle(M,B[0],B[1],B[2],N),M.fillRect(0,0,k.width,k.height);b=l.zoom();T(M,!1),M.clearRect(k.mpan.x,k.mpan.y,k.width/k.zoom/s,k.height/k.zoom/s),M.drawImage(_,k.mpan.x,k.mpan.y,k.width/k.zoom/s,k.height/k.zoom/s)}else o.textureOnViewport&&!t&&(o.textureCache=null);var I=l.extent(),A=o.pinching||o.hoverData.dragging||o.swipePanning||o.data.wheelZooming||o.hoverData.draggingEles,z=o.hideEdgesOnViewport&&A,L=[];if(L[o.NODE]=!c[o.NODE]&&d&&!o.clearedForMotionBlur[o.NODE]||o.clearingMotionBlur,L[o.NODE]&&(o.clearedForMotionBlur[o.NODE]=!0),L[o.DRAG]=!c[o.DRAG]&&d&&!o.clearedForMotionBlur[o.DRAG]||o.clearingMotionBlur,L[o.DRAG]&&(o.clearedForMotionBlur[o.DRAG]=!0),c[o.NODE]||n||r||L[o.NODE]){var O=d&&!L[o.NODE]&&1!==p;T(M=t||(O?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]:u.contexts[o.NODE]),d&&!O?"motionBlur":void 0),z?o.drawCachedNodes(M,S.nondrag,s,I):o.drawLayeredElements(M,S.nondrag,s,I),o.debug&&o.drawDebugPoints(M,S.nondrag),n||d||(c[o.NODE]=!1)}if(!r&&(c[o.DRAG]||n||L[o.DRAG])){O=d&&!L[o.DRAG]&&1!==p;T(M=t||(O?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]:u.contexts[o.DRAG]),d&&!O?"motionBlur":void 0),z?o.drawCachedNodes(M,S.drag,s,I):o.drawCachedElements(M,S.drag,s,I),o.debug&&o.drawDebugPoints(M,S.drag),n||d||(c[o.DRAG]=!1)}if(o.showFps||!r&&c[o.SELECT_BOX]&&!n){if(T(M=t||u.contexts[o.SELECT_BOX]),1==o.selection[4]&&(o.hoverData.selecting||o.touchData.selecting)){b=o.cy.zoom();var R=m.core("selection-box-border-width").value/b;M.lineWidth=R,M.fillStyle="rgba("+m.core("selection-box-color").value[0]+","+m.core("selection-box-color").value[1]+","+m.core("selection-box-color").value[2]+","+m.core("selection-box-opacity").value+")",M.fillRect(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]),R>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 F=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(F.x,F.y,m.core("active-bg-size").pfValue/b,0,2*Math.PI),M.fill()}var V=o.lastRedrawTime;if(o.showFps&&V){V=Math.round(V);var q=Math.round(1e3/V);M.setTransform(1,0,0,1,0,0),M.fillStyle="rgba(255, 0, 0, 0.75)",M.strokeStyle="rgba(255, 0, 0, 0.75)",M.lineWidth=1,M.fillText("1 frame = "+V+" ms = "+q+" fps",0,20);M.strokeRect(0,30,250,20),M.fillRect(0,30,250*Math.min(q/60,1),20)}n||(c[o.SELECT_BOX]=!1)}if(d&&1!==p){var Y=u.contexts[o.NODE],X=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_NODE],j=u.contexts[o.DRAG],W=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_DRAG],H=function(e,t,n){e.setTransform(1,0,0,1,0,0),n||!y?e.clearRect(0,0,o.canvasWidth,o.canvasHeight):D(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]||L[o.NODE])&&(H(Y,X,L[o.NODE]),c[o.NODE]=!1),(c[o.DRAG]||L[o.DRAG])&&(H(j,W,L[o.DRAG]),c[o.DRAG]=!1)}o.prevViewport=k,o.clearingMotionBlur&&(o.clearingMotionBlur=!1,o.motionBlurCleared=!0,o.motionBlur=!0),d&&(o.motionBlurTimeout=setTimeout(function(){o.motionBlurTimeout=null,o.clearedForMotionBlur[o.NODE]=!1,o.clearedForMotionBlur[o.DRAG]=!1,o.motionBlur=!1,o.clearingMotionBlur=!h,o.mbFrames=0,c[o.NODE]=!0,c[o.DRAG]=!0,o.redraw()},100)),t||l.emit("render")};for(var ds={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;l0&&a>0){d.clearRect(0,0,i,a),d.globalCompositeOperation="source-over";var p=this.getCachedZSortedEles();if(e.full)d.translate(-n.x1*l,-n.y1*l),d.scale(l,l),this.drawElements(d,p),d.scale(1/l,1/l),d.translate(n.x1*l,n.y1*l);else{var f=t.pan(),g={x:f.x*l,y:f.y*l};l*=t.zoom(),d.translate(g.x,g.y),d.scale(l,l),this.drawElements(d,p),d.scale(1/l,1/l),d.translate(-g.x,-g.y)}e.bg&&(d.globalCompositeOperation="destination-over",d.fillStyle=e.bg,d.rect(0,0,i,a),d.fill())}return h},bs.png=function(e){return ws(e,this.bufferCanvasImage(e),"image/png")},bs.jpg=function(e){return ws(e,this.bufferCanvasImage(e),"image/jpeg")};var Es={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)}}},ks=Ss,Cs=Ss.prototype;function Ss(e){var t=this;t.data={canvases:new Array(Cs.CANVAS_LAYERS),contexts:new Array(Cs.CANVAS_LAYERS),canvasNeedsRedraw:new Array(Cs.CANVAS_LAYERS),bufferCanvases:new Array(Cs.BUFFER_COUNT),bufferContexts:new Array(Cs.CANVAS_LAYERS)};var n="-webkit-tap-highlight-color: rgba(0,0,0,0);";t.data.canvasContainer=document.createElement("div");var r=t.data.canvasContainer.style;t.data.canvasContainer.setAttribute("style",n),r.position="relative",r.zIndex="0",r.overflow="hidden";var i=e.cy.container();i.appendChild(t.data.canvasContainer),(i.getAttribute("style")||"").indexOf(n)<0&&i.setAttribute("style",(i.getAttribute("style")||"")+n);for(var a=0;a + + + + + cytoscape-compound-drag-and-drop testing demo + + + + + + + + + + + + + +

cytoscape-compound-drag-and-drop testing demo

+ +
+ +
+ + +  |  + + + + + + +  |  + + +
+ + + diff --git a/demo.html b/demo.html index 0c902c7..4cabe4f 100644 --- a/demo.html +++ b/demo.html @@ -3,14 +3,11 @@ - cytoscape-compound-drag-and-drop.js demo + cytoscape-compound-drag-and-drop demo - - - - + @@ -112,7 +109,6 @@ var cdnd = cy.compoundDragAndDrop(); var removeEmptyParents = false; - var T = 5000; var isParentOfOneChild = function(node){ return node.isParent() && node.children().length === 1; @@ -141,42 +137,14 @@ } }); - var onClick = function(id, handler){ - document.getElementById(id).addEventListener('click', handler); - }; - - onClick('remove-1ch-parents', function(){ + // toggle check handler + document.getElementById('remove-1ch-parents').addEventListener('click', function(){ removeEmptyParents = !removeEmptyParents; if( removeEmptyParents ){ removeParentsOfOneChild(); } }); - - onClick('rm-a', function(){ - setTimeout(function(){ cy.$('#a').remove(); }, T); - }); - - onClick('rm-b', function(){ - setTimeout(function(){ cy.$('#b').remove(); }, T); - }); - - onClick('rm-c', function(){ - setTimeout(function(){ cy.$('#c').remove(); }, T); - }); - - onClick('rm-d', function(){ - setTimeout(function(){ cy.$('#d').remove(); }, T); - }); - - onClick('rm-p', function(){ - setTimeout(function(){ cy.$('#p').remove(); }, T); - }); - - onClick('add-e', function(){ - setTimeout(function(){ cy.add({ data: { id: 'e' }, position: { x: 540, y: 400 } }); }, T); - }); - }); @@ -189,16 +157,6 @@

cytoscape-compound-drag-and-drop demo

-  |  - - - - - - -  |  - -
diff --git a/package.json b/package.json index 1aa087b..04215fc 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "webpack": "^2.6.1" }, "peerDependencies": { - "cytoscape": "^3.3.0" + "cytoscape": "^3.4.0" }, "dependencies": {} } diff --git a/pages/cytoscape.3.4.0-snapshot.umd.js b/pages/cytoscape.3.4.0-snapshot.umd.js deleted file mode 120000 index 4178209..0000000 --- a/pages/cytoscape.3.4.0-snapshot.umd.js +++ /dev/null @@ -1 +0,0 @@ -../cytoscape.3.4.0-snapshot.umd.js \ No newline at end of file diff --git a/pages/demo-testing.html b/pages/demo-testing.html new file mode 120000 index 0000000..f351e0f --- /dev/null +++ b/pages/demo-testing.html @@ -0,0 +1 @@ +../demo-testing.html \ No newline at end of file