diff --git "a/.output/public/assets/cytoscape-D84qPEQv.js" "b/.output/public/assets/cytoscape-D84qPEQv.js" new file mode 100644--- /dev/null +++ "b/.output/public/assets/cytoscape-D84qPEQv.js" @@ -0,0 +1,747 @@ +import{c as e,g as t}from"./@babel-D5ZMb8W9.js";var n,r={exports:{}};const a=t((n||(n=1,r.exports=function(){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function l(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function c(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,o,s=[],l=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(c){u=!0,a=c}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}function d(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){return n(e)||c(e,t)||m(e,t)||d()}function p(e){return r(e)||u(e)||m(e)||h()}function g(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function v(e){var t=g(e,"string");return"symbol"==typeof t?t:t+""}function y(e){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}var b="undefined"==typeof window?null:window,x=b?b.navigator:null;b&&b.document;var w,E,T,C,k,P,S,D,B,A,_,M,R,I,N,L,O,z,F,V,j,X,Y,q,W,U,H,G,K=y(""),Z=y({}),$=y((function(){})),Q="undefined"==typeof HTMLElement?"undefined":y(HTMLElement),J=function(e){return e&&e.instanceString&&te(e.instanceString)?e.instanceString():null},ee=function(e){return null!=e&&y(e)==K},te=function(e){return null!=e&&y(e)===$},ne=function(e){return!le(e)&&(Array.isArray?Array.isArray(e):null!=e&&e instanceof Array)},re=function(e){return null!=e&&y(e)===Z&&!ne(e)&&e.constructor===Object},ae=function(e){return null!=e&&y(e)===Z},ie=function(e){return null!=e&&y(e)===y(1)&&!isNaN(e)},oe=function(e){return ie(e)&&Math.floor(e)===e},se=function(e){return"undefined"===Q?void 0:null!=e&&e instanceof HTMLElement},le=function(e){return ue(e)||ce(e)},ue=function(e){return"collection"===J(e)&&e._private.single},ce=function(e){return"collection"===J(e)&&!e._private.single},de=function(e){return"core"===J(e)},he=function(e){return"stylesheet"===J(e)},fe=function(e){return"event"===J(e)},pe=function(e){return null==e||!(""!==e&&!e.match(/^\s+$/))},ge=function(e){return"undefined"!=typeof HTMLElement&&e instanceof HTMLElement},ve=function(e){return re(e)&&ie(e.x1)&&ie(e.x2)&&ie(e.y1)&&ie(e.y2)},ye=function(e){return ae(e)&&te(e.then)},me=function(){return x&&x.userAgent.match(/msie|trident|edge/i)},be=function(e,t){t||(t=function(){if(1===arguments.length)return arguments[0];if(0===arguments.length)return"undefined";for(var e=[],t=0;tt?1:0},Me=function(e,t){return-1*_e(e,t)},Re=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n1&&(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("^"+Se+"$").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,(a=parseFloat(c[3]))<0||a>100)return;if(a/=100,void 0!==(i=c[4])&&((i=parseFloat(i))<0||i>1))return;if(0===r)o=s=l=Math.round(255*a);else{var d=a<.5?a*(1+r):a+r-a*r,h=2*a-d;o=Math.round(255*u(h,d,n+1/3)),s=Math.round(255*u(h,d,n)),l=Math.round(255*u(h,d,n-1/3))}t=[o,s,l,i]}return t},Le=function(e){var t,n=new RegExp("^"+ke+"$").exec(e);if(n){t=[];for(var r=[],a=1;a<=3;a++){var i=n[a];if("%"===i[i.length-1]&&(r[a]=!0),i=parseFloat(i),r[a]&&(i=i/100*255),i<0||i>255)return;t.push(Math.floor(i))}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},Oe=function(e){return Fe[e.toLowerCase()]},ze=function(e){return(ne(e)?e:null)||Oe(e)||Ie(e)||Le(e)||Ne(e)},Fe={ +// special colour names +transparent:[0,0,0,0], +// NB alpha === 0 +// regular colours +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]},Ve=function(e){for(var t=e.map,n=e.keys,r=n.length,a=0;a=s||t<0||y&&e-g>=d}function T(){var e=t();if(E(e))return C(e);f=setTimeout(T,w(e))}function C(e){return f=void 0,m&&u?b(e):(u=c=void 0,h)}function k(){void 0!==f&&clearTimeout(f),g=0,u=p=c=f=void 0}function P(){return void 0===f?h:C(t())}function S(){var e=t(),n=E(e);if(u=arguments,c=this,p=e,n){if(void 0===f)return x(p);if(y)return clearTimeout(f),f=setTimeout(T,s),b(p)}return void 0===f&&(f=setTimeout(T,s)),h}return s=n(s)||0,e(l)&&(v=!!l.leading,d=(y="maxWait"in l)?a(n(l.maxWait)||0,s):d,m="trailing"in l?!!l.trailing:m),S.cancel=k,S.flush=P,S}return H=o}var at=Ye(rt()),it=b?b.performance:null,ot=it&&it.now?function(){return it.now()}:function(){return Date.now()},st=function(){if(b){if(b.requestAnimationFrame)return function(e){b.requestAnimationFrame(e)};if(b.mozRequestAnimationFrame)return function(e){b.mozRequestAnimationFrame(e)};if(b.webkitRequestAnimationFrame)return function(e){b.webkitRequestAnimationFrame(e)};if(b.msRequestAnimationFrame)return function(e){b.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout((function(){e(ot())}),1e3/60)}}(),lt=function(e){return st(e)},ut=ot,ct=9261,dt=65599,ht=5381,ft=function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ct;!(t=e.next()).done;)n=n*dt+t.value|0;return n},pt=function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:ct)*dt+e|0},gt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ht;return(t<<5)+t+e|0},vt=function(e,t){return 2097152*e+t},yt=function(e){return 2097152*e[0]+e[1]},mt=function(e,t){return[pt(e[0],t[0]),gt(e[1],t[1])]},bt=function(e,t){var n={value:0,done:!1},r=0,a=e.length;return ft({next:function(){return r=0;r--)e[r]===t&&e.splice(r,1)},Vt=function(e){e.splice(0,e.length)},jt=function(e,t){for(var n=0;n2&&void 0!==arguments[2])||arguments[2];if(void 0!==e&&void 0!==t&&de(e)){var r=t.group;if(null==r&&(r=t.data&&null!=t.data.source&&null!=t.data.target?"edges":"nodes"),"nodes"===r||"edges"===r){this.length=1,this[0]=this;var a=this._private={cy:e,single:!0, +// indicates this is an element +data:t.data||{}, +// data object +position:t.position||{x:0,y:0}, +// (x, y) position pair +autoWidth:void 0, +// width and height of nodes calculated by the renderer when set to special 'auto' value +autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1, +// whether the compound dimensions need to be recalculated the next time dimensions are read +listeners:[], +// array of bound listeners +group:r, +// string; 'nodes' or 'edges' +style:{}, +// properties as set by the style +rstyle:{}, +// properties for style sent from the renderer to the core +styleCxts:[], +// applied style contexts from the styler +styleKeys:{}, +// per-group keys of style property values +removed:!0, +// whether it's inside the vis; true if removed (set true here since we call restore) +selected:!!t.selected, +// whether it's selected +selectable:void 0===t.selectable||!!t.selectable, +// whether it's selectable +locked:!!t.locked, +// whether the element is locked (cannot be moved) +grabbed:!1, +// whether the element is grabbed by the mouse; renderer sets this privately +grabbable:void 0===t.grabbable||!!t.grabbable, +// whether the element can be grabbed +pannable:void 0===t.pannable?"edges"===r:!!t.pannable, +// whether the element has passthrough panning enabled +active:!1, +// whether the element is active from user interaction +classes:new Gt, +// map ( className => true ) +animation:{ +// object for currently-running animations +current:[],queue:[]},rscratch:{}, +// object in which the renderer can store information +scratch:t.scratch||{}, +// scratch objects +edges:[], +// array of connected edges +children:[], +// array of children +parent:t.parent&&t.parent.isNode()?t.parent:null, +// parent ref +traversalCache:{}, +// cache of output of traversal functions +backgrounding:!1, +// whether background images are loading +bbCache:null, +// cache of the current bounding box +bbCacheShift:{x:0,y:0}, +// shift applied to cached bb to be applied on next get +bodyBounds:null, +// bounds cache of element body, w/o overlay +overlayBounds:null, +// bounds cache of element body, including overlay +labelBounds:{ +// bounds cache of labels +all:null,source:null,target:null,main:null},arrowBounds:{ +// bounds cache of edge arrows +source:null,target:null,"mid-source":null,"mid-target":null}};if(null==a.position.x&&(a.position.x=0),null==a.position.y&&(a.position.y=0),t.renderedPosition){var i=t.renderedPosition,o=e.pan(),s=e.zoom();a.position={x:(i.x-o.x)/s,y:(i.y-o.y)/s}}var l=[];ne(t.classes)?l=t.classes:ee(t.classes)&&(l=t.classes.split(/\s+/));for(var u=0,c=l.length;ut?1:0},u=function(e,t,a,i,o){var s;if(null==a&&(a=0),null==o&&(o=n),a<0)throw new Error("lo must be non-negative");for(null==i&&(i=e.length);an;0<=n?t++:t--)u.push(t);return u}.apply(this).reverse()).length;ig;0<=g?++h:--h)v.push(i(e,r));return v},p=function(e,t,r,a){var i,o,s;for(null==a&&(a=n),i=e[r];r>t&&a(i,o=e[s=r-1>>1])<0;)e[r]=o,r=s;return e[r]=i},g=function(e,t,r){var a,i,o,s,l;for(null==r&&(r=n),i=e.length,l=t,o=e[t],a=2*t+1;a0;){var w=y.pop(),E=g(w),T=w.id();if(d[T]=E,E!==1/0)for(var C=w.neighborhood().intersect(f),k=0;k0)for(n.unshift(t);c[a];){var i=c[a];n.unshift(i.edge),n.unshift(i.node),a=(r=i.node).id()}return o.spawn(n)}}}},un={ +// kruskal's algorithm (finds min spanning tree, assuming undirected graph) +// implemented from pseudocode from wikipedia +kruskal:function(e){e=e||function(e){return 1};for(var t=this.byGroup(),n=t.nodes,r=t.edges,a=n.length,i=new Array(a),o=n,s=function(e){for(var t=0;t0;){if(x(),E++,u===d){for(var T=[],C=a,k=d,P=m[k];T.unshift(C),null!=P&&T.unshift(P),null!=(C=y[k]);)P=m[k=C.id()];return{found:!0,distance:h[u],path:this.spawn(T),steps:E}}p[u]=!0;for(var S=l._private.edges,D=0;DP&&(f[k]=P,y[k]=C,m[k]=x),!a){var S=C*u+T;!a&&f[S]>P&&(f[S]=P,y[S]=T,m[S]=x)}}}for(var D=0;D1&&void 0!==arguments[1]?arguments[1]:i,r=[],a=m(e);;){if(null==a)return t.spawn();var o=y(a),l=o.edge,u=o.pred;if(r.unshift(a[0]),a.same(n)&&r.length>0)break;null!=l&&r.unshift(l),a=u}return s.spawn(r)},w=0;w=0;u--){var c=l[u],d=c[1],h=c[2];(t[d]===o&&t[h]===s||t[d]===s&&t[h]===o)&&l.splice(u,1)}for(var f=0;fr;){var a=Math.floor(Math.random()*t.length);t=yn(a,e,t),n--}return t},bn={ +// Computes the minimum cut of an undirected graph +// Returns the correct answer with high probability +kargerStein:function(){var e=this,t=this.byGroup(),n=t.nodes,r=t.edges;r.unmergeBy((function(e){return e.isLoop()}));var a=n.length,i=r.length,o=Math.ceil(Math.pow(Math.log(a)/Math.LN2,2)),s=Math.floor(a/vn);if(!(a<2)){for(var l=[],u=0;u1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=1/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,a=t;a1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0,a=0,i=t;i1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];arguments.length>3&&void 0!==arguments[3]&&!arguments[3]?(n0&&e.splice(0,t)):e=e.slice(t,n);for(var i=0,o=e.length-1;o>=0;o--){var s=e[o];a?isFinite(s)||(e[o]=-1/0,i++):e.splice(o,1)}r&&e.sort((function(e,t){return e-t}));var l=e.length,u=Math.floor(l/2);return l%2!=0?e[u+1+i]:(e[u-1+i]+e[u+i])/2},Dn=function(e){return Math.PI*e/180},Bn=function(e,t){return Math.atan2(t,e)-Math.PI/2},An=Math.log2||function(e){return Math.log(e)/Math.log(2)},_n=function(e){return e>0?1:e<0?-1:0},Mn=function(e,t){return Math.sqrt(Rn(e,t))},Rn=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},In=function(e){for(var t=e.length,n=0,r=0;r=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}}},Vn=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},jn=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},Xn=function(e,t,n){return{x1:e.x1+t,x2:e.x2+t,y1:e.y1+n,y2:e.y2+n,w:e.w,h:e.h}},Yn=function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},qn=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},Wn=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},Un=function(e){var t,n,r,a,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0];if(1===i.length)t=n=r=a=i[0];else if(2===i.length)t=r=i[0],a=n=i[1];else if(4===i.length){var o=f(i,4);t=o[0],n=o[1],r=o[2],a=o[3]}return e.x1-=a,e.x2+=n,e.y1-=t,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},Hn=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},Gn=function(e,t){return!(e.x1>t.x2||t.x1>e.x2||e.x2t.y2||t.y1>e.y2)},Kn=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},Zn=function(e,t){return Kn(e,t.x,t.y)},$n=function(e,t){return Kn(e,t.x1,t.y1)&&Kn(e,t.x2,t.y2)},Qn=function(e,t,n,r,a,i,o){var s,l,u=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"auto",c="auto"===u?wr(a,i):u,d=a/2,h=i/2,f=(c=Math.min(c,d,h))!==d,p=c!==h;if(f){var g=r-h-o;if((s=pr(e,t,n,r,n-d+c-o,g,n+d-c+o,g,!1)).length>0)return s}if(p){var v=n+d+o;if((s=pr(e,t,n,r,v,r-h+c-o,v,r+h-c+o,!1)).length>0)return s}if(f){var y=r+h+o;if((s=pr(e,t,n,r,n-d+c-o,y,n+d-c+o,y,!1)).length>0)return s}if(p){var m=n-d-o;if((s=pr(e,t,n,r,m,r-h+c-o,m,r+h-c+o,!1)).length>0)return s}var b=n-d+c,x=r-h+c;if((l=hr(e,t,n,r,b,x,c+o)).length>0&&l[0]<=b&&l[1]<=x)return[l[0],l[1]];var w=n+d-c,E=r-h+c;if((l=hr(e,t,n,r,w,E,c+o)).length>0&&l[0]>=w&&l[1]<=E)return[l[0],l[1]];var T=n+d-c,C=r+h-c;if((l=hr(e,t,n,r,T,C,c+o)).length>0&&l[0]>=T&&l[1]>=C)return[l[0],l[1]];var k=n-d+c,P=r+h-c;return(l=hr(e,t,n,r,k,P,c+o)).length>0&&l[0]<=k&&l[1]>=P?[l[0],l[1]]:[]},Jn=function(e,t,n,r,a,i,o){var s=o,l=Math.min(n,a),u=Math.max(n,a),c=Math.min(r,i),d=Math.max(r,i);return l-s<=e&&e<=u+s&&c-s<=t&&t<=d+s},er=function(e,t,n,r,a,i,o,s,l){var u={x1:Math.min(n,o,a)-l,x2:Math.max(n,o,a)+l,y1:Math.min(r,s,i)-l,y2:Math.max(r,s,i)+l};return!(eu.x2||tu.y2)},tr=function(e,t,n,r){var a=t*t-4*e*(n-=r);if(a<0)return[];var i=Math.sqrt(a),o=2*e;return[(-t+i)/o,(-t-i)/o]},nr=function(e,t,n,r,a){var i,o,s,l,u,c,d,h;return 0===e&&(e=1e-5),s=-27*(r/=e)+(t/=e)*(9*(n/=e)-t*t*2),i=(o=(3*n-t*t)/9)*o*o+(s/=54)*s,a[1]=0,d=t/3,i>0?(u=(u=s+Math.sqrt(i))<0?-Math.pow(-u,1/3):Math.pow(u,1/3),c=(c=s-Math.sqrt(i))<0?-Math.pow(-c,1/3):Math.pow(c,1/3),a[0]=-d+u+c,d+=(u+c)/2,a[4]=a[2]=-d,d=Math.sqrt(3)*(-c+u)/2,a[3]=d,void(a[5]=-d)):(a[5]=a[3]=0,0===i?(h=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),a[0]=2*h-d,void(a[4]=a[2]=-(h+d))):(l=(o=-o)*o*o,l=Math.acos(s/Math.sqrt(l)),h=2*Math.sqrt(o),a[0]=-d+h*Math.cos(l/3),a[2]=-d+h*Math.cos((l+2*Math.PI)/3),void(a[4]=-d+h*Math.cos((l+4*Math.PI)/3))))},rr=function(e,t,n,r,a,i,o,s){var l=[];nr(1*n*n-4*n*a+2*n*o+4*a*a-4*a*o+o*o+r*r-4*r*i+2*r*s+4*i*i-4*i*s+s*s,9*n*a-3*n*n-3*n*o-6*a*a+3*a*o+9*r*i-3*r*r-3*r*s-6*i*i+3*i*s,3*n*n-6*n*a+n*o-n*e+2*a*a+2*a*e-o*e+3*r*r-6*r*i+r*s-r*t+2*i*i+2*i*t-s*t,1*n*a-n*n+n*e-a*e+r*i-r*r+r*t-i*t,l);for(var u=1e-7,c=[],d=0;d<6;d+=2)Math.abs(l[d+1])=0&&l[d]<=1&&c.push(l[d]);c.push(1),c.push(0);for(var h,f,p,g=-1,v=0;v=0?pl?(e-a)*(e-a)+(t-i)*(t-i):u-d},ir=function(e,t,n){for(var r,a,i,o,s=0,l=0;l=e&&e>=i||r<=e&&e<=i))continue;(e-r)/(i-r)*(o-a)+a>t&&s++}return s%2!=0},or=function(e,t,n,r,a,i,o,s,l){var u,c=new Array(n.length);null!=s[0]?(u=Math.atan(s[1]/s[0]),s[0]<0?u+=Math.PI/2:u=-u-Math.PI/2):u=s;for(var d,h=Math.cos(-u),f=Math.sin(-u),p=0;p0){var g=ur(c,-l);d=lr(g)}else d=c;return ir(e,t,d)},sr=function(e,t,n,r,a,i,o,s){for(var l=new Array(2*n.length),u=0;u=0&&p<=1&&v.push(p),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]},fr=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},pr=function(e,t,n,r,a,i,o,s,l){var u=e-a,c=n-e,d=o-a,h=t-i,f=r-t,p=s-i,g=d*h-p*u,v=c*h-f*u,y=p*c-d*f;if(0!==y){var m=g/y,b=v/y,x=.001,w=0-x,E=1+x;return w<=m&&m<=E&&w<=b&&b<=E||l?[e+m*c,t+m*f]:[]}return 0===g||0===v?fr(e,n,o)===o?[o,s]:fr(e,n,a)===a?[a,i]:fr(a,o,n)===n?[n,r]:[]:[]},gr=function(e,t,n,r,a,i,o,s){var l,u,c,d,h,f,p=[],g=new Array(n.length),v=!0;if(null==i&&(v=!1),v){for(var y=0;y0){var m=ur(g,-s);u=lr(m)}else u=g}else u=n;for(var b=0;b2){for(var f=[c[0],c[1]],p=Math.pow(f[0]-e,2)+Math.pow(f[1]-t,2),g=1;gu&&(u=t)},get:function(e){return l[e]}},d=0;d0?m.edgesTo(y)[0]:y.edgesTo(m)[0];var x=r(b);y=y.id(),u[y]>u[p]+x&&(u[y]=u[p]+x,d.nodes.indexOf(y)<0?d.push(y):d.updateItem(y),l[y]=0,n[y]=[]),u[y]==u[p]+x&&(l[y]=l[y]+l[p],n[y].push(p))}else for(var w=0;w0;){for(var k=t.pop(),P=0;P0&&o.push(n[s]);0!==o.length&&a.push(r.collection(o))}return a},qr=function(e,t){for(var n=0;n5&&void 0!==arguments[5]?arguments[5]:Gr,o=r,s=0;s=2?ea(e,t,n,0,$r,Qr):ea(e,t,n,0,Zr)},squaredEuclidean:function(e,t,n){return ea(e,t,n,0,$r)},manhattan:function(e,t,n){return ea(e,t,n,0,Zr)},max:function(e,t,n){return ea(e,t,n,-1/0,Jr)}};function na(e,t,n,r,a,i){var o;return o=te(e)?e:ta[e]||ta.euclidean,0===t&&te(e)?o(a,i):o(t,n,r,a,i)}ta["squared-euclidean"]=ta.squaredEuclidean,ta.squaredeuclidean=ta.squaredEuclidean;var ra=zt({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),aa=function(e){return ra(e)},ia=function(e,t,n,r,a){var i="kMedoids"!==a?function(e){return n[e]}:function(e){return r[e](n)},o=function(e){return r[e](t)},s=n,l=t;return na(e,r.length,i,o,s,l)},oa=function(e,t,n){for(var r=n.length,a=new Array(r),i=new Array(r),o=new Array(t),s=null,l=0;ln)return!1;return!0},da=function(e,t,n){for(var r=0;ra&&(a=t[l][u],i=u);o[i].push(e[l])}for(var c=0;c clusters must be threshold distance apart +threshold:1/0, +// the distance threshold +// mode:'dendrogram' => the nodes are organised as leaves in a tree (siblings are close), merging makes clusters +addDendrogram:!1, +// whether to add the dendrogram to the graph for viz +dendrogramDepth:0, +// depth at which dendrogram branches are merged into the returned clusters +attributes:[]}),xa={single:"min",complete:"max"},wa=function(e){var t=ba(e),n=xa[t.linkage];return null!=n&&(t.linkage=n),t},Ea=function(e,t,n,r,a){for(var i,o=0,s=1/0,l=a.attributes,u=function(e,t){return na(a.distance,l.length,(function(t){return l[t](e)}),(function(e){return l[e](t)}),e,t)},c=0;c=a.threshold||"dendrogram"===a.mode&&1===e.length)return!1;var f,p=t[o],g=t[r[o]];f="dendrogram"===a.mode?{left:p,right:g,key:p.key}:{value:p.value.concat(g.value),key:p.key},e[p.index]=f,e.splice(g.index,1),t[p.key]=f;for(var v=0;vn[g.key][y.key]&&(i=n[g.key][y.key])):"max"===a.linkage?(i=n[p.key][y.key],n[p.key][y.key]0&&r.push(a);return r},Ra=function(e,t,n){for(var r=[],a=0;ao&&(i=l,o=t[a*e+l])}i>0&&r.push(i)}for(var u=0;ul&&(s=u,l=c)}n[a]=i[s]}return r=Ra(e,t,n)},Na=function(e){for(var t,n,r,a,i,o,s=this.cy(),l=this.nodes(),u=Ba(e),c={},d=0;d=P?(S=P,P=B,D=A):B>S&&(S=B);for(var _=0;_0?1:0;T[E%u.minIterations*t+O]=z,L+=z}if(L>0&&(E>=u.minIterations-1||E==u.maxIterations-1)){for(var F=0,V=0;V1||o>1)&&(u=!0),c[t]=[],e.outgoers().forEach((function(e){e.isEdge()&&c[t].push(e.id())}))}else d[t]=[void 0,e.target().id()]})):l.forEach((function(e){var t=e.id();e.isNode()?(e.degree(!0)%2&&(n?r?u=!0:r=t:n=t),c[t]=[],e.connectedEdges().forEach((function(e){return c[t].push(e.id())}))):d[t]=[e.source().id(),e.target().id()]}));var h={found:!1,trail:void 0};if(u)return h;if(r&&n)if(s){if(a&&r!=a)return h;a=r}else{if(a&&r!=a&&n!=a)return h;a||(a=r)}else a||(a=l[0].id());var f=function(e){for(var t,n,r,a=e,i=[e];c[a].length;)t=c[a].shift(),n=d[t][0],a!=(r=d[t][1])?(c[r]=c[r].filter((function(e){return e!=t})),a=r):s||a==n||(c[n]=c[n].filter((function(e){return e!=t})),a=n),i.unshift(t),i.unshift(a);return i},p=[],g=[];for(g=f(a);1!=g.length;)0==c[g[0]].length?(p.unshift(l.getElementById(g.shift())),p.unshift(l.getElementById(g.shift()))):g=f(g.shift()).concat(g);for(var v in p.unshift(l.getElementById(g.shift())),c)if(c[v].length)return h;return h.found=!0,h.trail=this.spawn(p,!0),h}},Fa=function(){var e=this,t={},n=0,r=0,a=[],i=[],o={},s=function(n,r){for(var o=i.length-1,s=[],l=e.spawn();i[o].x!=n||i[o].y!=r;)s.push(i.pop().edge),o--;s.push(i.pop().edge),s.forEach((function(n){var r=n.connectedNodes().intersection(e);l.merge(n),r.forEach((function(n){var r=n.id(),a=n.connectedEdges().intersection(e);l.merge(n),t[r].cutVertex?l.merge(a.filter((function(e){return e.isLoop()}))):l.merge(a)}))})),a.push(l)},l=function(u,c,d){u===d&&(r+=1),t[c]={id:n,low:n++,cutVertex:!1};var h,f,p,g,v=e.getElementById(c).connectedEdges().intersection(e);0===v.size()?a.push(e.spawn(e.getElementById(c))):v.forEach((function(e){h=e.source().id(),f=e.target().id(),(p=h===c?f:h)!==d&&(g=e.id(),o[g]||(o[g]=!0,i.push({x:c,y:p,edge:e})),p in t?t[c].low=Math.min(t[c].low,t[p].id):(l(u,p,c),t[c].low=Math.min(t[c].low,t[p].low),t[c].id<=t[p].low&&(t[c].cutVertex=!0,s(c,p))))}))};e.forEach((function(e){if(e.isNode()){var n=e.id();n in t||(r=0,l(n,n),t[n].cutVertex=r>1)}}));var u=Object.keys(t).filter((function(e){return t[e].cutVertex})).map((function(t){return e.getElementById(t)}));return{cut:e.spawn(u),components:a}},Va=function(){var e=this,t={},n=0,r=[],a=[],i=e.spawn(e),o=function(s){if(a.push(s),t[s]={index:n,low:n++,explored:!1},e.getElementById(s).connectedEdges().intersection(e).forEach((function(e){var n=e.target().id();n!==s&&(n in t||o(n),t[n].explored||(t[s].low=Math.min(t[s].low,t[n].low)))})),t[s].index===t[s].low){for(var l=e.spawn();;){var u=a.pop();if(l.merge(e.getElementById(u)),t[u].low=t[s].index,t[u].explored=!0,u===s)break}var c=l.edgesWith(l),d=l.merge(c);r.push(d),i=i.difference(d)}};return e.forEach((function(e){if(e.isNode()){var n=e.id();n in t||o(n)}})),{cut:i,components:r}},ja={};[$t,ln,un,dn,fn,gn,bn,Sr,Br,_r,Rr,Hr,ma,Sa,La,za,{hopcroftTarjanBiconnected:Fa,htbc:Fa,htb:Fa,hopcroftTarjanBiconnectedComponents:Fa},{tarjanStronglyConnected:Va,tsc:Va,tscc:Va,tarjanStronglyConnectedComponents:Va}].forEach((function(e){Re(ja,e)})); +/*! + Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable + Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com) + Licensed under The MIT License (http://opensource.org/licenses/MIT) + */ +var Xa=0,Ya=1,qa=2,Wa=function(e){if(!(this instanceof Wa))return new Wa(e);this.id="Thenable/1.0.7",this.state=Xa,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof e&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};Wa.prototype={ +/* promise resolving methods */ +fulfill:function(e){return Ua(this,Ya,"fulfillValue",e)},reject:function(e){return Ua(this,qa,"rejectReason",e)}, +/* "The then Method" [Promises/A+ 1.1, 1.2, 2.2] */ +then:function(e,t){var n=this,r=new Wa;return n.onFulfilled.push(Ka(e,r,"fulfill")),n.onRejected.push(Ka(t,r,"reject")),Ha(n),r.proxy}};var Ua=function(e,t,n,r){return e.state===Xa&&(e.state=t,e[n]=r,Ha(e)),e},Ha=function(e){e.state===Ya?Ga(e,"onFulfilled",e.fulfillValue):e.state===qa&&Ga(e,"onRejected",e.rejectReason)},Ga=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var a=function(){for(var e=0;e0:void 0}}, +// animated +clearQueue:function(){return function(){var e=this,t=void 0!==e.length?e:[e];if(!(this._private.cy||this).styleEnabled())return this;for(var n=0;n-1}return Xi=t}function ns(){if(Wi)return qi;Wi=1;var e=Qo();function t(t,n){var r=this.__data__,a=e(r,t);return a<0?(++this.size,r.push([t,n])):r[a][1]=n,this}return qi=t}function rs(){if(Hi)return Ui;Hi=1;var e=Zo(),t=Jo(),n=es(),r=ts(),a=ns();function i(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&n%1==0&&n true if immutable +updateStyle:!1,beforeGet:function(e){},beforeSet:function(e,t){},onSet:function(e){},canSet:function(e){return!0}},e),function(t,n){var r=e,a=this,i=void 0!==a.length,o=i?a:[a],s=i?a[0]:a;if(ee(t)){var u,c=-1!==t.indexOf(".")&&Ks(t);if(r.allowGetting&&void 0===n)return s&&(r.beforeGet(s),u=c&&void 0===s._private[r.field][t]?Ns(s._private[r.field],c):s._private[r.field][t]),u;if(r.allowSetting&&void 0!==n&&!r.immutableKeys[t]){var d=l({},t,n);r.beforeSet(a,d);for(var h=0,f=o.length;h0&&this.spawn(r).updateStyle().emit("class"),t},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return null!=t&&t._private.classes.has(e)},toggleClass:function(e,t){ne(e)||(e=e.match(/\S+/g)||[]);for(var n=this,r=void 0===t,a=[],i=0,o=n.length;i0&&this.spawn(a).updateStyle().emit("class"),n},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var n=this;if(null==t)t=250;else if(0===t)return n;return n.addClass(e),setTimeout((function(){n.removeClass(e)}),t),n}};Js.className=Js.classNames=Js.classes;var el={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]", +// chars we need to escape in let names, etc +comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=", +// binary comparison op (used in data selectors) +boolOp:"\\?|\\!|\\^", +// boolean (unary) operators (used in data selectors) +string:"\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'", +// string literals (used in data selectors) -- doublequotes | singlequotes +number:Ce, +// number literal (used in data selectors) --- e.g. 0.1234, 1234, 12e123 +meta:"degree|indegree|outdegree", +// allowed metadata fields (i.e. allowed functions to use from Collection) +separator:"\\s*,\\s*", +// queries are separated by commas, e.g. edge[foo = 'bar'], node.someClass +descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};el.variable="(?:[\\w-.]|(?:\\\\"+el.metaChar+"))+",el.className="(?:[\\w-]|(?:\\\\"+el.metaChar+"))+",el.value=el.string+"|"+el.number,el.id=el.variable,function(){var e,t,n;for(e=el.comparatorOp.split("|"),n=0;n=0||"="!==t&&(el.comparatorOp+="|\\!"+t)}();var tl=function(){return{checks:[]}},nl={ +/** E.g. node */ +GROUP:0, +/** A collection of elements */ +COLLECTION:1, +/** A filter(ele) function */ +FILTER:2, +/** E.g. [foo > 1] */ +DATA_COMPARE:3, +/** E.g. [foo] */ +DATA_EXIST:4, +/** E.g. [?foo] */ +DATA_BOOL:5, +/** E.g. [[degree > 2]] */ +META_COMPARE:6, +/** E.g. :selected */ +STATE:7, +/** E.g. #foo */ +ID:8, +/** E.g. .foo */ +CLASS:9, +/** E.g. #foo <-> #bar */ +UNDIRECTED_EDGE:10, +/** E.g. #foo -> #bar */ +DIRECTED_EDGE:11, +/** E.g. $#foo -> #bar */ +NODE_SOURCE:12, +/** E.g. #foo -> $#bar */ +NODE_TARGET:13, +/** E.g. $#foo <-> #bar */ +NODE_NEIGHBOR:14, +/** E.g. #foo > #bar */ +CHILD:15, +/** E.g. #foo #bar */ +DESCENDANT:16, +/** E.g. $#foo > #bar */ +PARENT:17, +/** E.g. $#foo #bar */ +ANCESTOR:18, +/** E.g. #foo > $bar > #baz */ +COMPOUND_SPLIT:19, +/** Always matches, useful placeholder for subject in `COMPOUND_SPLIT` */ +TRUE:20},rl=[{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 Me(e.selector,t.selector)})),al=function(){for(var e,t={},n=0;n0&&u.edgeCount>0)return _t("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(u.edgeCount>1)return _t("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===u.edgeCount&&_t("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 ee(t)?'"'+t+'"':e(t)},n=function(e){return" "+e+" "},r=function(r,i){var o=r.type,s=r.value;switch(o){case nl.GROUP:var l=e(s);return l.substring(0,l.length-1);case nl.DATA_COMPARE:var u=r.field,c=r.operator;return"["+u+n(e(c))+t(s)+"]";case nl.DATA_BOOL:var d=r.operator,h=r.field;return"["+e(d)+h+"]";case nl.DATA_EXIST:return"["+r.field+"]";case nl.META_COMPARE:var f=r.operator;return"[["+r.field+n(e(f))+t(s)+"]]";case nl.STATE:return s;case nl.ID:return"#"+s;case nl.CLASS:return"."+s;case nl.PARENT:case nl.CHILD:return a(r.parent,i)+n(">")+a(r.child,i);case nl.ANCESTOR:case nl.DESCENDANT:return a(r.ancestor,i)+" "+a(r.descendant,i);case nl.COMPOUND_SPLIT:var p=a(r.left,i),g=a(r.subject,i),v=a(r.right,i);return p+(p.length>0?" ":"")+g+v;case nl.TRUE:return""}},a=function(e,t){return e.checks.reduce((function(n,a,i){return n+(t===e&&0===i?"$":"")+r(a,t)}),"")},i="",o=0;o1&&o=0&&(t=t.replace("!",""),c=!0),t.indexOf("@")>=0&&(t=t.replace("@",""),u=!0),(o||l||u)&&(a=o||s?""+e:"",i=""+n),u&&(e=a=a.toLowerCase(),n=i=i.toLowerCase()),t){case"*=":r=a.indexOf(i)>=0;break;case"$=":r=a.indexOf(i,a.length-i.length)>=0;break;case"^=":r=0===a.indexOf(i);break;case"=":r=e===n;break;case">":d=!0,r=e>n;break;case">=":d=!0,r=e>=n;break;case"<":d=!0,r=e0;){var u=a.shift();t(u),i.add(u.id()),o&&r(a,i,u)}return e}function Bl(e,t,n){if(n.isParent())for(var r=n._private.children,a=0;a1&&void 0!==arguments[1])||arguments[1],Bl)},Sl.forEachUp=function(e){return Dl(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],Al)},Sl.forEachUpAndDown=function(e){return Dl(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],_l)},Sl.ancestors=Sl.parents,(Cl=kl={data:$s.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:$s.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:$s.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:$s.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:$s.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:$s.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}}).attr=Cl.data,Cl.removeAttr=Cl.removeData;var Ml,Rl,Il=kl,Nl={};function Ll(e){return function(t){var n=this;if(void 0===t&&(t=!0),0!==n.length&&n.isNode()&&!n.removed()){for(var r=0,a=n[0],i=a._private.edges,o=0;ot})),minIndegree:Ol("indegree",(function(e,t){return et})),minOutdegree:Ol("outdegree",(function(e,t){return et}))}),Re(Nl,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r0,c=u;u&&(l=l[0]);var d=c?l.position():{x:0,y:0};return a={x:s.x-d.x,y:s.y-d.y},void 0===e?a:a[e]}for(var h=0;h0,v=g;g&&(p=p[0]);var y=v?p.position():{x:0,y:0};void 0!==t?f.position(e,t+y[e]):void 0!==a&&f.position({x:a.x+y.x,y:a.y+y.y})}}else if(!i)return;return this}}).modelPosition=Ml.point=Ml.position,Ml.modelPositions=Ml.points=Ml.positions,Ml.renderedPoint=Ml.renderedPosition,Ml.relativePoint=Ml.relativePosition;var Vl,jl,Xl=Rl;Vl=jl={},jl.renderedBoundingBox=function(e){var t=this.boundingBox(e),n=this.cy(),r=n.zoom(),a=n.pan(),i=t.x1*r+a.x,o=t.x2*r+a.x,s=t.y1*r+a.y,l=t.y2*r+a.y;return{x1:i,x2:o,y1:s,y2:l,w:o-i,h:l-s}},jl.dirtyCompoundBoundsCache=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();return t.styleEnabled()&&t.hasCompoundNodes()?(this.forEachUp((function(t){if(t.isParent()){var n=t._private;n.compoundBoundsClean=!1,n.bbCache=null,e||t.emitAndNotify("bounds")}})),this):this},jl.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,a={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")}},i=n.boundingBox({includeLabels:r,includeOverlays:!1, +// updating the compound bounds happens outside of the regular +// cache cycle (i.e. before fired events) +useCache:!1}),o=t.position;0!==i.w&&0!==i.h||((i={w:e.pstyle("width").pfValue,h:e.pstyle("height").pfValue}).x1=o.x-i.w/2,i.x2=o.x+i.w/2,i.y1=o.y-i.h/2,i.y2=o.y+i.h/2);var s=a.width.left.value;"px"===a.width.left.units&&a.width.val>0&&(s=100*s/a.width.val);var l=a.width.right.value;"px"===a.width.right.units&&a.width.val>0&&(l=100*l/a.width.val);var u=a.height.top.value;"px"===a.height.top.units&&a.height.val>0&&(u=100*u/a.height.val);var c=a.height.bottom.value;"px"===a.height.bottom.units&&a.height.val>0&&(c=100*c/a.height.val);var d=y(a.width.val-i.w,s,l),h=d.biasDiff,f=d.biasComplementDiff,p=y(a.height.val-i.h,u,c),g=p.biasDiff,v=p.biasComplementDiff;t.autoPadding=m(i.w,i.h,e.pstyle("padding"),e.pstyle("padding-relative-to").value),t.autoWidth=Math.max(i.w,a.width.val),o.x=(-h+i.x1+i.x2+f)/2,t.autoHeight=Math.max(i.h,a.height.val),o.y=(-g+i.y1+i.y2+v)/2}function y(e,t,n){var r=0,a=0,i=t+n;return e>0&&i>0&&(r=t/i*e,a=n/i*e),{biasDiff:r,biasComplementDiff:a}}function m(e,t,n,r){if("%"!==n.units)return"px"===n.units?n.pfValue:0;switch(r){case"width":return e>0?n.pfValue*e:0;case"height":return t>0?n.pfValue*t:0;case"average":return e>0&&t>0?n.pfValue*(e+t)/2:0;case"min":return e>0&&t>0?e>t?n.pfValue*t:n.pfValue*e:0;case"max":return e>0&&t>0?e>t?n.pfValue*e:n.pfValue*t:0;default:return 0}}}for(var r=0;re.x2?r:e.x2,e.y1=ne.y2?a:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},Wl=function(e,t){return null==t?e:ql(e,t.x1,t.y1,t.x2,t.y2)},Ul=function(e,t,n){return Xt(e,t,n)},Hl=function(e,t,n){if(!t.cy().headless()){var r,a,i=t._private,o=i.rstyle,s=o.arrowWidth/2;if("none"!==t.pstyle(n+"-arrow-shape").value){"source"===n?(r=o.srcX,a=o.srcY):"target"===n?(r=o.tgtX,a=o.tgtY):(r=o.midX,a=o.midY);var l=i.arrowBounds=i.arrowBounds||{},u=l[n]=l[n]||{};u.x1=r-s,u.y1=a-s,u.x2=r+s,u.y2=a+s,u.w=u.x2-u.x1,u.h=u.y2-u.y1,Wn(u,1),ql(e,u.x1,u.y1,u.x2,u.y2)}}},Gl=function(e,t,n){if(!t.cy().headless()){var r;r=n?n+"-":"";var a=t._private,i=a.rstyle;if(t.pstyle(r+"label").strValue){var o,s,l,u,c=t.pstyle("text-halign"),d=t.pstyle("text-valign"),h=Ul(i,"labelWidth",n),f=Ul(i,"labelHeight",n),p=Ul(i,"labelX",n),g=Ul(i,"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,T=2,C=f,k=h,P=k/2,S=C/2;if(m)o=p-P,s=p+P,l=g-S,u=g+S;else{switch(c.value){case"left":o=p-k,s=p;break;case"center":o=p-P,s=p+P;break;case"right":o=p,s=p+k}switch(d.value){case"top":l=g-C,u=g;break;case"center":l=g-S,u=g+S;break;case"bottom":l=g,u=g+C}}var D=v-Math.max(x,w)-E-T,B=v+Math.max(x,w)+E+T,A=y-Math.max(x,w)-E-T,_=y+Math.max(x,w)+E+T;o+=D,s+=B,l+=A,u+=_;var M=n||"main",R=a.labelBounds,I=R[M]=R[M]||{};I.x1=o,I.y1=l,I.x2=s,I.y2=u,I.w=s-o,I.h=u-l,I.leftPad=D,I.rightPad=B,I.topPad=A,I.botPad=_;var N=m&&"autorotate"===b.strValue,L=null!=b.pfValue&&0!==b.pfValue;if(N||L){var O=N?Ul(a.rstyle,"labelAngle",n):b.pfValue,z=Math.cos(O),F=Math.sin(O),V=(o+s)/2,j=(l+u)/2;if(!m){switch(c.value){case"left":V=s;break;case"right":V=o}switch(d.value){case"top":j=u;break;case"bottom":j=l}}var X=function(e,t){return{x:(e-=V)*z-(t-=j)*F+V,y:e*F+t*z+j}},Y=X(o,l),q=X(o,u),W=X(s,l),U=X(s,u);o=Math.min(Y.x,q.x,W.x,U.x),s=Math.max(Y.x,q.x,W.x,U.x),l=Math.min(Y.y,q.y,W.y,U.y),u=Math.max(Y.y,q.y,W.y,U.y)}var H=M+"Rot",G=R[H]=R[H]||{};G.x1=o,G.y1=l,G.x2=s,G.y2=u,G.w=s-o,G.h=u-l,ql(e,o,l,s,u),ql(a.labelBounds.all,o,l,s,u)}return e}},Kl=function(e,t){if(!t.cy().headless()){var n=t.pstyle("outline-opacity").value,r=t.pstyle("outline-width").value;if(n>0&&r>0){var a=t.pstyle("outline-offset").value,i=t.pstyle("shape").value,o=r+a,s=(e.w+2*o)/e.w,l=(e.h+2*o)/e.h,u=0,c=0;["diamond","pentagon","round-triangle"].includes(i)?(s=(e.w+2.4*o)/e.w,c=-o/3.6):["concave-hexagon","rhomboid","right-rhomboid"].includes(i)?s=(e.w+2.4*o)/e.w:"star"===i?(s=(e.w+2.8*o)/e.w,l=(e.h+2.6*o)/e.h,c=-o/3.8):"triangle"===i?(s=(e.w+2.8*o)/e.w,l=(e.h+2.4*o)/e.h,c=-o/1.4):"vee"===i&&(s=(e.w+4.4*o)/e.w,l=(e.h+3.8*o)/e.h,c=.5*-o);var d=e.h*l-e.h,h=e.w*s-e.w;if(Un(e,[Math.ceil(d/2),Math.ceil(h/2)]),0!=u||0!==c){var f=Xn(e,u,c);Yn(e,f)}}}},Zl=function(e,t){var n,r,a,i,o,s,l=e._private.cy,u=l.styleEnabled(),c=l.headless(),d=Fn(),h=e._private,f=e.isNode(),p=e.isEdge(),g=h.rstyle,v=f&&u?e.pstyle("bounds-expansion").pfValue:[0],y=function(e){return"none"!==e.pstyle("display").value},m=!u||y(e)&&(!p||y(e.source())&&y(e.target()));if(m){var b=0;u&&t.includeOverlays&&0!==e.pstyle("overlay-opacity").value&&(b=e.pstyle("overlay-padding").value);var x=0;u&&t.includeUnderlays&&0!==e.pstyle("underlay-opacity").value&&(x=e.pstyle("underlay-padding").value);var w=Math.max(b,x),E=0;if(u&&(E=e.pstyle("width").pfValue/2),f&&t.includeNodes){var T=e.position();o=T.x,s=T.y;var C=e.outerWidth()/2,k=e.outerHeight()/2;ql(d,n=o-C,a=s-k,r=o+C,i=s+k),u&&t.includeOutlines&&Kl(d,e)}else if(p&&t.includeEdges)if(u&&!c){var P=e.pstyle("curve-style").strValue;if(n=Math.min(g.srcX,g.midX,g.tgtX),r=Math.max(g.srcX,g.midX,g.tgtX),a=Math.min(g.srcY,g.midY,g.tgtY),i=Math.max(g.srcY,g.midY,g.tgtY),ql(d,n-=E,a-=E,r+=E,i+=E),"haystack"===P){var S=g.haystackPts;if(S&&2===S.length){if(n=S[0].x,a=S[0].y,n>(r=S[1].x)){var D=n;n=r,r=D}if(a>(i=S[1].y)){var B=a;a=i,i=B}ql(d,n-E,a-E,r+E,i+E)}}else if("bezier"===P||"unbundled-bezier"===P||P.endsWith("segments")||P.endsWith("taxi")){var A;switch(P){case"bezier":case"unbundled-bezier":A=g.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":A=g.linePts}if(null!=A)for(var _=0;_(r=I.x)){var N=n;n=r,r=N}if((a=R.y)>(i=I.y)){var L=a;a=i,i=L}ql(d,n-=E,a-=E,r+=E,i+=E)}if(u&&t.includeEdges&&p&&(Hl(d,e,"mid-source"),Hl(d,e,"mid-target"),Hl(d,e,"source"),Hl(d,e,"target")),u&&"yes"===e.pstyle("ghost").value){var O=e.pstyle("ghost-offset-x").pfValue,z=e.pstyle("ghost-offset-y").pfValue;ql(d,d.x1+O,d.y1+z,d.x2+O,d.y2+z)}var F=h.bodyBounds=h.bodyBounds||{};Hn(F,d),Un(F,v),Wn(F,1),u&&(n=d.x1,r=d.x2,a=d.y1,i=d.y2,ql(d,n-w,a-w,r+w,i+w));var V=h.overlayBounds=h.overlayBounds||{};Hn(V,d),Un(V,v),Wn(V,1);var j=h.labelBounds=h.labelBounds||{};null!=j.all?jn(j.all):j.all=Fn(),u&&t.includeLabels&&(t.includeMainLabels&&Gl(d,e,null),p&&(t.includeSourceLabels&&Gl(d,e,"source"),t.includeTargetLabels&&Gl(d,e,"target")))}return d.x1=Yl(d.x1),d.y1=Yl(d.y1),d.x2=Yl(d.x2),d.y2=Yl(d.y2),d.w=Yl(d.x2-d.x1),d.h=Yl(d.y2-d.y1),d.w>0&&d.h>0&&m&&(Un(d,v),Wn(d,1)),d},$l=function(e){var t=0,n=function(e){return(e?1:0)<0&&void 0!==arguments[0]?arguments[0]:Eu,t=arguments.length>1?arguments[1]:void 0,n=0;n=0;s--)o(s);return this},Cu.removeAllListeners=function(){return this.removeListener("*")},Cu.emit=Cu.trigger=function(e,t,n){var r=this.listeners,a=r.length;return this.emitting++,ne(t)||(t=[t]),Su(this,(function(e,i){null!=n&&(r=[{event:i.event,type:i.type,namespace:i.namespace,callback:n}],a=r.length);for(var o=function(){var n=r[s];if(n.type===i.type&&(!n.namespace||n.namespace===i.namespace||n.namespace===bu)&&e.eventMatches(e.context,n,i)){var a=[i];null!=t&&jt(a,t),e.beforeEmit(e.context,n,i),n.conf&&n.conf.one&&(e.listeners=e.listeners.filter((function(e){return e!==n})));var o=e.callbackContext(e.context,n,i),l=n.callback.apply(o,a);e.afterEmit(e.context,n,i),!1===l&&(i.stopPropagation(),i.preventDefault())}},s=0;s1&&!r){var a=this.length-1,i=this[a],o=i._private.data.id;this[a]=void 0,this[e]=i,n.set(o,{ele:i,index:e})}return this.length--,this}, +// remove single ele in place in calling collection +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 a=r.index;return this.unmergeAt(a),this}, +// remove eles in place on calling collection +unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&ee(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=this,a=0;ar&&(r=s,n=o)}return{value:r,ele:n}},min:function(e,t){for(var n,r=1/0,a=this,i=0;i=0&&a1&&void 0!==arguments[1])||arguments[1],n=this[0],r=n.cy();if(r.styleEnabled()&&n){n._private.styleDirty&&(n._private.styleDirty=!1,r.style().apply(n));var a=n._private.style[e];return null!=a?a: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}, +// get the specified css property as a rendered value (i.e. on-screen value) +// or get the whole rendered style if no property specified (NB doesn't allow setting) +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}, +// read the calculated css style of the element or override the style (via a bypass) +style:function(e,t){var n=this.cy();if(!n.styleEnabled())return this;var r=!1,a=n.style();if(re(e)){var i=e;a.applyBypass(this,i,r),this.emitAndNotify("style")}else if(ee(e)){if(void 0===t){var o=this[0];return o?a.getStylePropertyValue(o,e):void 0}a.applyBypass(this,e,t,r),this.emitAndNotify("style")}else if(void 0===e){var s=this[0];return s?a.getRawStyle(s):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=!1,r=t.style(),a=this;if(void 0===e)for(var i=0;i outgoing nodes +outgoers:Pl(tc({outgoing:!0}),"outgoers"), +// aka DAG descendants +successors:nc({outgoing:!0}), +// normally called parents in graph theory +// these nodes <=edges= incoming nodes +incomers:Pl(tc({incoming:!0}),"incomers"), +// aka DAG ancestors +predecessors:nc({})}),Re(Ju,{neighborhood:Pl((function(e){for(var t=[],n=this.nodes(),r=0;r0&&t.push(c[0]),t.push(s[0])}return this.spawn(t,!0).filter(e)}),"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),Ju.neighbourhood=Ju.neighborhood,Ju.closedNeighbourhood=Ju.closedNeighborhood,Ju.openNeighbourhood=Ju.openNeighborhood,Re(Ju,{source:Pl((function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t}),"source"),target:Pl((function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t}),"target"),sources:rc({attr:"source"}),targets:rc({attr:"target"})}),Re(Ju,{edgesWith:Pl(ac(),"edgesWith"),edgesTo:Pl(ac({thisIsSrc:!0}),"edgesTo")}),Re(Ju,{connectedEdges:Pl((function(e){for(var t=[],n=this,r=0;r0);return i},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),Ju.componentsOf=Ju.components;var oc=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(void 0!==e){var a=new Wt,i=!1;if(t){if(t.length>0&&re(t[0])&&!ue(t[0])){i=!0;for(var o=[],s=new Gt,l=0,u=t.length;l0&&void 0!==arguments[0])||arguments[0],r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=this,i=a.cy(),o=i._private,s=[],l=[],u=0,c=a.length;u0){for(var I=e.length===a.length?a:new oc(i,e),N=0;N0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this,r=[],a={},i=n._private.cy;function o(e){for(var t=e._private.edges,n=0;n0&&(e?k.emitAndNotify("remove"):t&&k.emit("remove"));for(var P=0;P0?a=l:r=l}while(Math.abs(i)>o&&++u=i?m(t,s):0===c?s:x(t,r,r+u)}var E=!1;function T(){E=!0,e===t&&n===r||b()}var C=function(a){return E||T(),e===t&&n===r?a:0===a?0:1===a?1:v(w(a),t,r)};C.getControlPoints=function(){return[{x:e,y:t},{x:n,y:r}]};var k="generateBezier("+[e,t,n,r]+")";return C.toString=function(){return k},C} +/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var cc=function(){function e(e){return-e.tension*e.x-e.friction*e.v}function t(t,n,r){var a={x:t.x+r.dx*n,v:t.v+r.dv*n,tension:t.tension,friction:t.friction};return{dx:a.v,dv:e(a)}}function n(n,r){var a={dx:n.v,dv:e(n)},i=t(n,.5*r,a),o=t(n,.5*r,i),s=t(n,r,o),l=1/6*(a.dx+2*(i.dx+o.dx)+s.dx),u=1/6*(a.dv+2*(i.dv+o.dv)+s.dv);return n.x=n.x+l*r,n.v=n.v+u*r,n}return function e(t,r,a){var i,o,s,l={x:-1,v:0,tension:null,friction:null},u=[0],c=0,d=1e-4,h=.016;for(t=parseFloat(t)||500,r=parseFloat(r)||20,a=a||null,l.tension=t,l.friction=r,o=(i=null!==a)?(c=e(t,r))/a*h:h;s=n(s||l,o),u.push(1+s.x),c+=16,Math.abs(s.x)>d&&Math.abs(s.v)>d;);return i?function(e){return u[e*(u.length-1)|0]}:c}}(),dc=function(e,t,n,r){var a=uc(e,t,n,r);return function(e,t,n){return e+(t-e)*a(n)}},hc={linear:function(e,t,n){return e+(t-e)*n}, +// default easings +ease:dc(.25,.1,.25,1),"ease-in":dc(.42,0,1,1),"ease-out":dc(0,0,.58,1),"ease-in-out":dc(.42,0,.58,1), +// sine +"ease-in-sine":dc(.47,0,.745,.715),"ease-out-sine":dc(.39,.575,.565,1),"ease-in-out-sine":dc(.445,.05,.55,.95), +// quad +"ease-in-quad":dc(.55,.085,.68,.53),"ease-out-quad":dc(.25,.46,.45,.94),"ease-in-out-quad":dc(.455,.03,.515,.955), +// cubic +"ease-in-cubic":dc(.55,.055,.675,.19),"ease-out-cubic":dc(.215,.61,.355,1),"ease-in-out-cubic":dc(.645,.045,.355,1), +// quart +"ease-in-quart":dc(.895,.03,.685,.22),"ease-out-quart":dc(.165,.84,.44,1),"ease-in-out-quart":dc(.77,0,.175,1), +// quint +"ease-in-quint":dc(.755,.05,.855,.06),"ease-out-quint":dc(.23,1,.32,1),"ease-in-out-quint":dc(.86,0,.07,1), +// expo +"ease-in-expo":dc(.95,.05,.795,.035),"ease-out-expo":dc(.19,1,.22,1),"ease-in-out-expo":dc(1,0,0,1), +// circ +"ease-in-circ":dc(.6,.04,.98,.335),"ease-out-circ":dc(.075,.82,.165,1),"ease-in-out-circ":dc(.785,.135,.15,.86), +// user param easings... +spring:function(e,t,n){if(0===n)return hc.linear;var r=cc(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":dc};function fc(e,t,n,r,a){if(1===r)return n;if(t===n)return n;var i=a(t,n,r);return null==e||((e.roundValue||e.color)&&(i=Math.round(i)),void 0!==e.min&&(i=Math.max(i,e.min)),void 0!==e.max&&(i=Math.min(i,e.max))),i}function pc(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function gc(e,t,n,r,a){var i=null!=a?a.type:null;n<0?n=0:n>1&&(n=1);var o=pc(e,a),s=pc(t,a);if(ie(o)&&ie(s))return fc(i,o,s,n,r);if(ne(o)&&ne(s)){for(var l=[],u=0;u0?("spring"===d&&h.push(o.duration),o.easingImpl=hc[d].apply(null,h)):o.easingImpl=hc[d]}var f,p=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 g=o.startPosition,v=o.position;if(v&&a&&!e.locked()){var y={};yc(g.x,v.x)&&(y.x=gc(g.x,v.x,f,p)),yc(g.y,v.y)&&(y.y=gc(g.y,v.y,f,p)),e.position(y)}var m=o.startPan,b=o.pan,x=i.pan,w=null!=b&&r;w&&(yc(m.x,b.x)&&(x.x=gc(m.x,b.x,f,p)),yc(m.y,b.y)&&(x.y=gc(m.y,b.y,f,p)),e.emit("pan"));var E=o.startZoom,T=o.zoom,C=null!=T&&r;C&&(yc(E,T)&&(i.zoom=zn(i.minZoom,gc(E,T,f,p),i.maxZoom)),e.emit("zoom")),(w||C)&&e.emit("viewport");var k=o.style;if(k&&k.length>0&&a){for(var P=0;P=0;t--)(0,e[t])();e.splice(0,e.length)},c=i.length-1;c>=0;c--){var d=i[c],h=d._private;h.stopped?(i.splice(c,1),h.hooked=!1,h.playing=!1,h.started=!1,u(h.frames)):(h.playing||h.applying)&&(h.playing&&h.applying&&(h.applying=!1),h.started||mc(t,d,e),vc(t,d,e,n),h.applying&&(h.applying=!1),u(h.frames),null!=h.step&&h.step(e),d.completed()&&(i.splice(c,1),h.hooked=!1,h.playing=!1,h.started=!1,u(h.completes)),s=!0)}return n||0!==i.length||0!==o.length||r.push(t),s}for(var i=!1,o=0;o0?t.notify("draw",n):t.notify("draw")),n.unmerge(r),t.emit("step")}var xc={ +// pull in animation functions +animate:$s.animate(),animation:$s.animation(),animated:$s.animated(),clearQueue:$s.clearQueue(),delay:$s.delay(),delayAnimation:$s.delayAnimation(),stop:$s.stop(),addToAnimationPool:function(e){var t=this;t.styleEnabled()&&t._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,e.styleEnabled()){var t=e.renderer();t&&t.beforeRender?t.beforeRender((function(t,n){bc(n,e)}),t.beforeRenderPriorities.animations):n()}function n(){e._private.animationsRunning&<((function(t){bc(t,e),n()}))}}},wc={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&&ue(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}},Ec=function(e){return ee(e)?new wl(e):e},Tc={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new Tu(wc,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,Ec(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,Ec(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,Ec(t),n),this},once:function(e,t,n){return this.emitter().one(e,Ec(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}};$s.eventAliasesOn(Tc);var Cc={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)}};Cc.jpeg=Cc.jpg;var kc={layout:function(e){var t=this;if(null!=e)if(null!=e.name){var n,r=e.name,a=t.extension("layout",r);if(null!=a)return n=ee(e.eles)?t.$(e.eles):null!=e.eles?e.eles:t.$(),new a(Re({},e,{cy:t,eles:n}));Bt("No such layout `"+r+"` found. Did you forget to import it and `cytoscape.use()` it?")}else Bt("A `name` must be specified to make a layout");else Bt("Layout options must be specified to make a layout")}};kc.createLayout=kc.makeLayout=kc.layout;var Pc={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 a=this.renderer();!this.destroyed()&&a&&a.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}, +// for backwards compatibility +batchData:function(e){var t=this;return this.batch((function(){for(var n=Object.keys(e),r=0;r0;)t.removeChild(t.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach((function(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]}))},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};Dc.invalidateDimensions=Dc.resize;var Bc={ +// get a collection +// - empty collection on no args +// - collection of elements in the graph on selector arg +// - guarantee a returned collection when elements or collection specified +collection:function(e,t){return ee(e)?this.$(e):le(e)?e.collection():ne(e)?(t||(t={}),new oc(this,e,t.unique,t.removed)):new oc(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}, +// search the graph like jQuery +$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};Bc.elements=Bc.filter=Bc.$;var Ac={},_c="t",Mc="f";Ac.apply=function(e){for(var t=this,n=t._private.cy.collection(),r=0;r0;if(h||d&&f){var p=void 0;h&&f||h?p=u.properties:f&&(p=u.mappedProperties);for(var g=0;g1&&(v=1),s.color){var w=a.valueMin[0],E=a.valueMax[0],T=a.valueMin[1],C=a.valueMax[1],k=a.valueMin[2],P=a.valueMax[2],S=null==a.valueMin[3]?1:a.valueMin[3],D=null==a.valueMax[3]?1:a.valueMax[3],B=[Math.round(w+(E-w)*v),Math.round(T+(C-T)*v),Math.round(k+(P-k)*v),Math.round(S+(D-S)*v)];n={ +// colours are simple, so just create the flat property instead of expensive string parsing +bypass:a.bypass, +// we're a bypass if the mapping property is a bypass +name:a.name,value:B,strValue:"rgb("+B[0]+", "+B[1]+", "+B[2]+")"}}else{if(!s.number)return!1;var A=a.valueMin+(a.valueMax-a.valueMin)*v;n=this.parse(a.name,A,a.bypass,h)}if(!n)return g(),!1;n.mapping=a,a=n;break; +// direct mapping +case o.data:for(var _=a.field.split("."),M=d.data,R=0;R<_.length&&M;R++)M=M[_[R]];if(null!=M&&(n=this.parse(a.name,M,a.bypass,h)),!n)return g(),!1;n.mapping=a,a=n;break;case o.fn:var I=a.value,N=null!=a.fnValue?a.fnValue:I(e);if(a.prevFnValue=N,null==N)return _t("Custom function mappers may not return null (i.e. `"+a.name+"` for ele `"+e.id()+"` is null)"),!1;if(!(n=this.parse(a.name,N,a.bypass,h)))return _t("Custom function mappers may not return invalid values for the property type (i.e. `"+a.name+"` for ele `"+e.id()+"` is invalid)"),!1;n.mapping=Rt(a),a=n;break;case void 0:break; +// just set the property +default:return!1}return l?(a.bypassed=c?u.bypassed:u,i[a.name]=a):c?u.bypassed=a:i[a.name]=a,p(),!0},Ac.cleanElements=function(e,t){for(var n=0;n0&&i>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:i,easing:e.pstyle("transition-timing-function").value,queue:!1}).play().promise()})).then((function(){n.removeBypasses(e,a),e.emitAndNotify("style"),r.transitioning=!1}))}else r.transitioning&&(this.removeBypasses(e,a),e.emitAndNotify("style"),r.transitioning=!1)},Ac.checkTrigger=function(e,t,n,r,a,i){var o=this.properties[t],s=a(o);e.removed()||null!=s&&s(n,r,e)&&i(o)},Ac.checkZOrderTrigger=function(e,t,n,r){var a=this;this.checkTrigger(e,t,n,r,(function(e){return e.triggersZOrder}),(function(){a._private.cy.notify("zorder",e)}))},Ac.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,(function(e){return e.triggersBounds}),(function(t){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()}))},Ac.checkConnectedEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,(function(e){return e.triggersBoundsOfConnectedEdges}),(function(t){e.connectedEdges().forEach((function(e){e.dirtyBoundingBoxCache()}))}))},Ac.checkParallelEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,(function(e){return e.triggersBoundsOfParallelEdges}),(function(t){e.parallelEdges().forEach((function(e){e.dirtyBoundingBoxCache()}))}))},Ac.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r),this.checkConnectedEdgesBoundsTrigger(e,t,n,r),this.checkParallelEdgesBoundsTrigger(e,t,n,r)};var Rc={applyBypass:function(e,t,n,r){var a=this,i=[],o=!0;if("*"===t||"**"===t){if(void 0!==n)for(var s=0;st.length?o.substr(t.length):""}function l(){n=n.length>r.length?n.substr(r.length):""}for(o=o.replace(/[/][*](\s|.)+?[*][/]/g,"");!o.match(/^\s*$/);){var u=o.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!u){_t("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+o);break}t=u[0];var c=u[1];if("core"!==c&&new wl(c).invalid)_t("Skipping parsing of block: Invalid selector found in string stylesheet: "+c),s();else{var d=u[2],h=!1;n=d;for(var f=[];!n.match(/^\s*$/);){var p=n.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!p){_t("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+d),h=!0;break}r=p[0];var g=p[1],v=p[2];a.properties[g]?i.parse(g,v)?(f.push({name:g,val:v}),l()):(_t("Skipping property: Invalid property definition in: "+r),l()):(_t("Skipping property: Invalid property name in: "+r),l())}if(h){s();break}i.selector(c);for(var y=0;y=7&&"d"===t[0]&&(u=new RegExp(s.data.regex).exec(t))){if(n)return!1;var h=s.data;return{name:e,value:u,strValue:""+t,mapped:h,field:u[1],bypass:n}}if(t.length>=10&&"m"===t[0]&&(c=new RegExp(s.mapData.regex).exec(t))){if(n)return!1;if(d.multiple)return!1;var f=s.mapData;if(!d.color&&!d.number)return!1;var p=this.parse(e,c[4]);if(!p||p.mapped)return!1;var g=this.parse(e,c[5]);if(!g||g.mapped)return!1;if(p.pfValue===g.pfValue||p.strValue===g.strValue)return _t("`"+e+": "+t+"` is not a valid mapper because the output range is zero; converting to `"+e+": "+p.strValue+"`"),this.parse(e,p.strValue);if(d.color){var v=p.value,y=g.value;if(!(v[0]!==y[0]||v[1]!==y[1]||v[2]!==y[2]||// optional alpha +v[3]!==y[3]&&(null!=v[3]&&1!==v[3]||null!=y[3]&&1!==y[3])))return!1}return{name:e,value:c,strValue:""+t,mapped:f,field:c[1],fieldMin:parseFloat(c[2]), +// min & max are numeric +fieldMax:parseFloat(c[3]),valueMin:p.value,valueMax:g.value,bypass:n}}}if(d.multiple&&"multiple"!==r){var m;if(m=l?t.split(/\s+/):ne(t)?t:[t],d.evenMultiple&&m.length%2!=0)return null;for(var b=[],x=[],w=[],E="",T=!1,C=0;C0?" ":"")+k.strValue}return d.validate&&!d.validate(b,x)?null:d.singleEnum&&T?1===b.length&&ee(b[0])?{name:e,value:b[0],strValue:b[0],bypass:n}:null:{name:e,value:b,pfValue:w,strValue:E,bypass:n,units:x}}var P=function(){for(var r=0;rd.max||d.strictMax&&t===d.max))return null;var _={name:e,value:t,strValue:""+t+(S||""),units:S,bypass:n};return d.unitless||"px"!==S&&"em"!==S?_.pfValue=t:_.pfValue="px"!==S&&S?this.getEmSizeInPixels()*t:t,"ms"!==S&&"s"!==S||(_.pfValue="ms"===S?t:1e3*t),"deg"!==S&&"rad"!==S||(_.pfValue="rad"===S?t:Dn(t)),"%"===S&&(_.pfValue=t/100),_}if(d.propList){var M=[],R=""+t;if("none"===R);else{for(var I=R.split(/\s*,\s*|\s+/),N=0;N recalc ele mappers +updateStyle:function(){this.mutableElements().updateStyle()}},Yc="single",qc={autolock:function(e){return void 0===e?this._private.autolock:(this._private.autolock=!!e,this)},autoungrabify:function(e){return void 0===e?this._private.autoungrabify:(this._private.autoungrabify=!!e,this)},autounselectify:function(e){return void 0===e?this._private.autounselectify:(this._private.autounselectify=!!e,this)},selectionType:function(e){var t=this._private;return null==t.selectionType&&(t.selectionType=Yc),void 0===e?t.selectionType:("additive"!==e&&"single"!==e||(t.selectionType=e),this)},panningEnabled:function(e){return void 0===e?this._private.panningEnabled:(this._private.panningEnabled=!!e,this)},userPanningEnabled:function(e){return void 0===e?this._private.userPanningEnabled:(this._private.userPanningEnabled=!!e,this)},zoomingEnabled:function(e){return void 0===e?this._private.zoomingEnabled:(this._private.zoomingEnabled=!!e,this)},userZoomingEnabled:function(e){return void 0===e?this._private.userZoomingEnabled:(this._private.userZoomingEnabled=!!e,this)},boxSelectionEnabled:function(e){return void 0===e?this._private.boxSelectionEnabled:(this._private.boxSelectionEnabled=!!e,this)},pan:function(){var e,t,n,r,a,i=arguments,o=this._private.pan;switch(i.length){case 0:return o;case 1:if(ee(i[0]))return o[e=i[0]];if(re(i[0])){if(!this._private.panningEnabled)return this;r=(n=i[0]).x,a=n.y,ie(r)&&(o.x=r),ie(a)&&(o.y=a),this.emit("pan viewport")}break;case 2:if(!this._private.panningEnabled)return this;e=i[0],t=i[1],"x"!==e&&"y"!==e||!ie(t)||(o[e]=t),this.emit("pan viewport")}return this.notify("viewport"),this},panBy:function(e,t){var n,r,a,i,o,s=arguments,l=this._private.pan;if(!this._private.panningEnabled)return this;switch(s.length){case 1:re(e)&&(i=(a=s[0]).x,o=a.y,ie(i)&&(l.x+=i),ie(o)&&(l.y+=o),this.emit("pan viewport"));break;case 2:r=t,"x"!==(n=e)&&"y"!==n||!ie(r)||(l[n]+=r),this.emit("pan viewport")}return this.notify("viewport"),this},gc:function(){this.notify("gc")},fit:function(e,t){var n=this.getFitViewport(e,t);if(n){var r=this._private;r.zoom=n.zoom,r.pan=n.pan,this.emit("pan zoom viewport"),this.notify("viewport")}return this},getFitViewport:function(e,t){if(ie(e)&&void 0===t&&(t=e,e=void 0),this._private.panningEnabled&&this._private.zoomingEnabled){var n;if(ee(e)){var r=e;e=this.$(r)}else if(ve(e)){var a=e;(n={x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2}).w=n.x2-n.x1,n.h=n.y2-n.y1}else le(e)||(e=this.mutableElements());if(!le(e)||!e.empty()){n=n||e.boundingBox();var i,o=this.width(),s=this.height();if(t=ie(t)?t:0,!isNaN(o)&&!isNaN(s)&&o>0&&s>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0)return{zoom:i=(i=(i=Math.min((o-2*t)/n.w,(s-2*t)/n.h))>this._private.maxZoom?this._private.maxZoom:i)=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,a=r.pan,i=r.zoom,o=!1;if(r.zoomingEnabled||(o=!0),ie(e)?n=e:re(e)&&(n=e.level,null!=e.position?t=wn(e.position,i,a):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||r.panningEnabled||(o=!0)),n=(n=n>r.maxZoom?r.maxZoom:n)t.maxZoom||!t.zoomingEnabled?i=!0:(t.zoom=s,a.push("zoom"))}if(r&&(!i||!e.cancelOnFailedZoom)&&t.panningEnabled){var l=e.pan;ie(l.x)&&(t.pan.x=l.x,o=!1),ie(l.y)&&(t.pan.y=l.y,o=!1),o||a.push("pan")}return a.length>0&&(a.push("viewport"),this.emit(a.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(ee(e)){var n=e;e=this.mutableElements().filter(n)}else le(e)||(e=this.mutableElements());if(0!==e.length){var r=e.boundingBox(),a=this.width(),i=this.height();return{ +// middle +x:(a-(t=void 0===t?this._private.zoom:t)*(r.x1+r.x2))/2,y:(i-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,a=this;return n.sizeCache=n.sizeCache||(r?(e=a.window().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")}):{ +// fallback if no container (not 0 b/c can be used for dividing etc) +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}},multiClickDebounceTime:function(e){return e?(this._private.multiClickDebounceTime=e,this):this._private.multiClickDebounceTime}};qc.centre=qc.center,qc.autolockNodes=qc.autolock,qc.autoungrabifyNodes=qc.autoungrabify;var Wc={data:$s.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:$s.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:$s.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:$s.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Wc.attr=Wc.data,Wc.removeAttr=Wc.removeData;var Uc=function(e){var t=this,n=(e=Re({},e)).container;n&&!se(n)&&se(n[0])&&(n=n[0]);var r=n?n._cyreg:null;(r=r||{})&&r.cy&&(r.cy.destroy(),r={});var a=r.readies=r.readies||[];n&&(n._cyreg=r),r.cy=t;var i=void 0!==b&&void 0!==n&&!e.headless,o=e;o.layout=Re({name:i?"grid":"null"},o.layout),o.renderer=Re({name:i?"canvas":"null"},o.renderer);var s=function(e,t,n){return void 0!==t?t:void 0!==n?n:e},l=this._private={container:n, +// html dom ele container +ready:!1, +// whether ready has been triggered +options:o, +// cached options +elements:new oc(this), +// elements in the graph +listeners:[], +// list of listeners +aniEles:new oc(this), +// elements being animated +data:o.data||{}, +// data for the core +scratch:{}, +// scratch object for core +layout:null,renderer:null,destroyed:!1, +// whether destroy was called +notificationsEnabled:!0, +// whether notifications are sent to the renderer +minZoom:1e-50,maxZoom:1e50,zoomingEnabled:s(!0,o.zoomingEnabled),userZoomingEnabled:s(!0,o.userZoomingEnabled),panningEnabled:s(!0,o.panningEnabled),userPanningEnabled:s(!0,o.userPanningEnabled),boxSelectionEnabled:s(!0,o.boxSelectionEnabled),autolock:s(!1,o.autolock,o.autolockNodes),autoungrabify:s(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:s(!1,o.autounselectify),styleEnabled:void 0===o.styleEnabled?i:o.styleEnabled,zoom:ie(o.zoom)?o.zoom:1,pan:{x:re(o.pan)&&ie(o.pan.x)?o.pan.x:0,y:re(o.pan)&&ie(o.pan.y)?o.pan.y:0},animation:{ +// object for currently-running animations +current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:s(250,o.multiClickDebounceTime)};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom});var u=function(e,t){if(e.some(ye))return $a.all(e).then(t);t(e)};l.styleEnabled&&t.setStyle([]);var c=Re({},o,o.renderer);t.initRenderer(c);var d=function(e,n,r){t.notifications(!1);var a=t.mutableElements();a.length>0&&a.remove(),null!=e&&(re(e)||ne(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 i=Re({},t._private.options.layout);i.eles=t.elements(),t.layout(i).run()};u([o.style,o.elements],(function(e){var n=e[0],i=e[1];l.styleEnabled&&t.style().append(n),d(i,(function(){t.startAnimationLoop(),l.ready=!0,te(o.ready)&&t.on("ready",o.ready);for(var e=0;e more space between nodes (N.B. n/a if causes overlap) +boundingBox:void 0, +// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } +avoidOverlap:!0, +// prevents node overlap, may overflow boundingBox if not enough space +nodeDimensionsIncludeLabels:!1, +// Excludes the label when calculating node bounding boxes for the layout algorithm +roots:void 0, +// the roots of the trees +depthSort:void 0, +// a sorting function to order nodes at equal depth. e.g. function(a, b){ return a.data('weight') - b.data('weight') } +animate:!1, +// whether to transition the node positions +animationDuration:500, +// duration of animation in ms if enabled +animationEasing:void 0, +// easing of animation if enabled, +animateFilter:function(e,t){return!0}, +// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts +ready:void 0, +// callback on layoutready +stop:void 0, +// callback on layoutstop +transform:function(e,t){return t} +// transform a given node position. Useful for changing flow direction in discrete layouts +},Kc={maximal:!1, +// whether to shift nodes down their natural BFS depths in order to avoid upwards edges (DAGS only); setting acyclic to true sets maximal to true also +acyclic:!1},Zc=function(e){return e.scratch("breadthfirst")},$c=function(e,t){return e.scratch("breadthfirst",t)};function Qc(e){this.options=Re({},Gc,Kc,e)}Qc.prototype.run=function(){var e,t=this.options,n=t.cy,r=t.eles,a=r.nodes().filter((function(e){return e.isChildless()})),i=r,o=t.directed,s=t.acyclic||t.maximal||t.maximalAdjustments>0,l=!!t.boundingBox,u=n.extent(),c=Fn(l?t.boundingBox:{x1:u.x1,y1:u.y1,w:u.w,h:u.h});if(le(t.roots))e=t.roots;else if(ne(t.roots)){for(var d=[],h=0;h0;){var _=A(),M=P(_,D);if(M)_.outgoers().filter((function(e){return e.isNode()&&r.has(e)})).forEach(B);else if(null===M){_t("Detected double maximal shift for node `"+_.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var R=0;if(t.avoidOverlap)for(var I=0;I0&&m[0].length<=3?i/2:0),s=2*Math.PI/m[r].length*a;return 0===r&&1===m[0].length&&(o=1),{x:G.x+o*Math.cos(s),y:G.y+o*Math.sin(s)}}var u=m[r].length,d=Math.max( +// only one depth +1===u?0: +// inside a bounding box, no need for left & right padding +l?(c.w-2*t.padding-K.w)/((t.grid?$:u)-1):(c.w-2*t.padding-K.w)/((t.grid?$:u)+1),R);return{x:G.x+(a+1-(u+1)/2)*d,y:G.y+(r+1-(j+1)/2)*Z}};return r.nodes().layoutPositions(this,t,Q),this};var Jc={fit:!0, +// whether to fit the viewport to the graph +padding:30, +// the padding on fit +boundingBox:void 0, +// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } +avoidOverlap:!0, +// prevents node overlap, may overflow boundingBox and radius if not enough space +nodeDimensionsIncludeLabels:!1, +// Excludes the label when calculating node bounding boxes for the layout algorithm +spacingFactor:void 0, +// Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up +radius:void 0, +// the radius of the circle +startAngle:1.5*Math.PI, +// where nodes start in radians +sweep:void 0, +// how many radians should be between the first and last node (defaults to full circle) +clockwise:!0, +// whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false) +sort:void 0, +// a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') } +animate:!1, +// whether to transition the node positions +animationDuration:500, +// duration of animation in ms if enabled +animationEasing:void 0, +// easing of animation if enabled +animateFilter:function(e,t){return!0}, +// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts +ready:void 0, +// callback on layoutready +stop:void 0, +// callback on layoutstop +transform:function(e,t){return t} +// transform a given node position. Useful for changing flow direction in discrete layouts +};function ed(e){this.options=Re({},Jc,e)}ed.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,a=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,i=r.nodes().not(":parent");t.sort&&(i=i.sort(t.sort));for(var o,s=Fn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),l={x:s.x1+s.w/2,y:s.y1+s.h/2},u=(void 0===t.sweep?2*Math.PI-2*Math.PI/i.length:t.sweep)/Math.max(1,i.length-1),c=0,d=0;d1&&t.avoidOverlap){c*=1.75;var g=Math.cos(u)-Math.cos(0),v=Math.sin(u)-Math.sin(0),y=Math.sqrt(c*c/(g*g+v*v));o=Math.max(y,o)}var m=function(e,n){var r=t.startAngle+n*u*(a?1:-1),i=o*Math.cos(r),s=o*Math.sin(r);return{x:l.x+i,y:l.y+s}};return r.nodes().layoutPositions(this,t,m),this};var td,nd={fit:!0, +// whether to fit the viewport to the graph +padding:30, +// the padding on fit +startAngle:1.5*Math.PI, +// where nodes start in radians +sweep:void 0, +// how many radians should be between the first and last node (defaults to full circle) +clockwise:!0, +// whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false) +equidistant:!1, +// whether levels have an equal radial distance betwen them, may cause bounding box overflow +minNodeSpacing:10, +// min spacing between outside of nodes (used for radius adjustment) +boundingBox:void 0, +// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } +avoidOverlap:!0, +// prevents node overlap, may overflow boundingBox if not enough space +nodeDimensionsIncludeLabels:!1, +// Excludes the label when calculating node bounding boxes for the layout algorithm +height:void 0, +// height of layout area (overrides container height) +width:void 0, +// width of layout area (overrides container width) +spacingFactor:void 0, +// Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up +concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1, +// whether to transition the node positions +animationDuration:500, +// duration of animation in ms if enabled +animationEasing:void 0, +// easing of animation if enabled +animateFilter:function(e,t){return!0}, +// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts +ready:void 0, +// callback on layoutready +stop:void 0, +// callback on layoutstop +transform:function(e,t){return t} +// transform a given node position. Useful for changing flow direction in discrete layouts +};function rd(e){this.options=Re({},nd,e)}rd.prototype.run=function(){for(var e=this.options,t=e,n=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,r=e.cy,a=t.eles,i=a.nodes().not(":parent"),o=Fn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},l=[],u=0,c=0;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(o.w,o.h)/2-x)/(v.length+w?1:0);x=Math.min(x,E)}for(var T=0,C=0;C1&&t.avoidOverlap){var D=Math.cos(S)-Math.cos(0),B=Math.sin(S)-Math.sin(0),A=Math.sqrt(x*x/(D*D+B*B));T=Math.max(A,T)}k.r=T,T+=x}if(t.equidistant){for(var _=0,M=0,R=0;R=e.numIter||(fd(r,e),r.temperature=r.temperature*e.coolingFactor,r.temperature=e.animationThreshold&&i(),lt(c)):(kd(r,e),s())};c()}else{for(;u;)u=o(l),l++;kd(r,e),s()}return this},id.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},id.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var od,sd=function(e,t,n){for(var r=n.eles.edges(),a=n.eles.nodes(),i=Fn(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),o={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:a.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:r.size(),temperature:n.initialTemp,clientWidth:i.w,clientHeight:i.h,boundingBox:i},s=n.eles.components(),l={},u=0;u0)for(o.graphSet.push(w),u=0;ur.count?0:r.graph},ud=function(e,t,n,r){var a=r.graphSet[n];if(-10)var l=(c=r.nodeOverlap*s)*a/(v=Math.sqrt(a*a+i*i)),u=c*i/v;else{var c,d=md(e,a,i),h=md(t,-1*a,-1*i),f=h.x-d.x,p=h.y-d.y,g=f*f+p*p,v=Math.sqrt(g);l=(c=(e.nodeRepulsion+t.nodeRepulsion)/g)*f/v,u=c*p/v}e.isLocked||(e.offsetX-=l,e.offsetY-=u),t.isLocked||(t.offsetX+=l,t.offsetY+=u)}},yd=function(e,t,n,r){if(n>0)var a=e.maxX-t.minX;else a=t.maxX-e.minX;if(r>0)var i=e.maxY-t.minY;else i=t.maxY-e.minY;return a>=0&&i>=0?Math.sqrt(a*a+i*i):0},md=function(e,t,n){var r=e.positionX,a=e.positionY,i=e.height||1,o=e.width||1,s=n/t,l=i/o,u={};return 0===t&&0n?(u.x=r,u.y=a+i/2,u):0t&&-1*l<=s&&s<=l?(u.x=r-o/2,u.y=a-o*n/2/t,u):0=l)?(u.x=r+i*t/2/n,u.y=a+i/2,u):0>n&&(s<=-1*l||s>=l)?(u.x=r-i*t/2/n,u.y=a-i/2,u):u},bd=function(e,t){for(var n=0;nn){var g=t.gravity*h/p,v=t.gravity*f/p;d.offsetX+=g,d.offsetY+=v}}}}},wd=function(e,t){var n=[],r=0,a=-1;for(n.push.apply(n,e.graphSet[0]),a+=e.graphSet[0].length;r<=a;){var i=n[r++],o=e.idToIndex[i],s=e.layoutNodes[o],l=s.children;if(0n)var a={x:n*e/r,y:n*t/r};else a={x:e,y:t};return a},Cd=function(e,t){var n=e.parentId;if(null!=n){var r=t.layoutNodes[t.idToIndex[n]],a=!1;return(null==r.maxX||e.maxX+r.padRight>r.maxX)&&(r.maxX=e.maxX+r.padRight,a=!0),(null==r.minX||e.minX-r.padLeftr.maxY)&&(r.maxY=e.maxY+r.padBottom,a=!0),(null==r.minY||e.minY-r.padTopp&&(d+=f+t.componentSpacing,c=0,h=0,f=0)}}},Pd={fit:!0, +// whether to fit the viewport to the graph +padding:30, +// padding used on fit +boundingBox:void 0, +// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } +avoidOverlap:!0, +// prevents node overlap, may overflow boundingBox if not enough space +avoidOverlapPadding:10, +// extra spacing around nodes when avoidOverlap: true +nodeDimensionsIncludeLabels:!1, +// Excludes the label when calculating node bounding boxes for the layout algorithm +spacingFactor:void 0, +// Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up +condense:!1, +// uses all available space on false, uses minimal space on true +rows:void 0, +// force num of rows in the grid +cols:void 0, +// force num of columns in the grid +position:function(e){}, +// returns { row, col } for element +sort:void 0, +// a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') } +animate:!1, +// whether to transition the node positions +animationDuration:500, +// duration of animation in ms if enabled +animationEasing:void 0, +// easing of animation if enabled +animateFilter:function(e,t){return!0}, +// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts +ready:void 0, +// callback on layoutready +stop:void 0, +// callback on layoutstop +transform:function(e,t){return t} +// transform a given node position. Useful for changing flow direction in discrete layouts +};function Sd(e){this.options=Re({},Pd,e)}Sd.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,a=r.nodes().not(":parent");t.sort&&(a=a.sort(t.sort));var i=Fn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(0===i.h||0===i.w)r.nodes().layoutPositions(this,t,(function(e){return{x:i.x1,y:i.y1}}));else{var o=a.size(),s=Math.sqrt(o*i.h/i.w),l=Math.round(s),u=Math.round(i.w/i.h*s),c=function(e){if(null==e)return Math.min(l,u);Math.min(l,u)==l?l=e:u=e},d=function(e){if(null==e)return Math.max(l,u);Math.max(l,u)==l?l=e:u=e},h=t.rows,f=null!=t.cols?t.cols:t.columns;if(null!=h&&null!=f)l=h,u=f;else if(null!=h&&null==f)l=h,u=Math.ceil(o/l);else if(null==h&&null!=f)u=f,l=Math.ceil(o/u);else if(u*l>o){var p=c(),g=d();(p-1)*g>=o?c(p-1):(g-1)*p>=o&&d(g-1)}else for(;u*l=o?d(y+1):c(v+1)}var m=i.w/u,b=i.h/l;if(t.condense&&(m=0,b=0),t.avoidOverlap)for(var x=0;x=u&&(_=0,A++)},R={},I=0;I (position obj); or function(node){ return somPos; } +zoom:void 0, +// the zoom level to set (prob want fit = false if set) +pan:void 0, +// the pan level to set (prob want fit = false if set) +fit:!0, +// whether to fit to viewport +padding:30, +// padding on fit +spacingFactor:void 0, +// Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up +animate:!1, +// whether to transition the node positions +animationDuration:500, +// duration of animation in ms if enabled +animationEasing:void 0, +// easing of animation if enabled +animateFilter:function(e,t){return!0}, +// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts +ready:void 0, +// callback on layoutready +stop:void 0, +// callback on layoutstop +transform:function(e,t){return t} +// transform a given node position. Useful for changing flow direction in discrete layouts +};function _d(e){this.options=Re({},Ad,e)}_d.prototype.run=function(){var e=this.options,t=e.eles.nodes(),n=te(e.positions);function r(t){if(null==e.positions)return xn(t.position());if(n)return e.positions(t);var r=e.positions[t._private.data.id];return null==r?null:r}return t.layoutPositions(this,e,(function(e,t){var n=r(e);return!e.locked()&&null!=n&&n})),this};var Md={fit:!0, +// whether to fit to viewport +padding:30, +// fit padding +boundingBox:void 0, +// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } +animate:!1, +// whether to transition the node positions +animationDuration:500, +// duration of animation in ms if enabled +animationEasing:void 0, +// easing of animation if enabled +animateFilter:function(e,t){return!0}, +// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts +ready:void 0, +// callback on layoutready +stop:void 0, +// callback on layoutstop +transform:function(e,t){return t} +// transform a given node position. Useful for changing flow direction in discrete layouts +};function Rd(e){this.options=Re({},Md,e)}Rd.prototype.run=function(){var e=this.options,t=e.cy,n=e.eles,r=Fn(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()}),a=function(e,t){return{x:r.x1+Math.round(Math.random()*r.w),y:r.y1+Math.round(Math.random()*r.h)}};return n.nodes().layoutPositions(this,e,a),this};var Id=[{name:"breadthfirst",impl:Qc},{name:"circle",impl:ed},{name:"concentric",impl:rd},{name:"cose",impl:id},{name:"grid",impl:Sd},{name:"null",impl:Bd},{name:"preset",impl:_d},{name:"random",impl:Rd}];function Nd(e){this.options=e,this.notifications=0}var Ld=function(){},Od=function(){throw new Error("A headless instance can not render images")};Nd.prototype={recalculateRenderedStyle:Ld,notify:function(){this.notifications++},init:Ld,isHeadless:function(){return!0},png:Od,jpg:Od};var zd={arrowShapeWidth:.3,registerArrowShapes:function(){var e=this.arrowShapes={},t=this,n=function(e,t,n,r,a,i,o){var s=a.x-n/2-o,l=a.x+n/2+o,u=a.y-n/2-o,c=a.y+n/2+o;return s<=e&&e<=l&&u<=t&&t<=c},r=function(e,t,n,r,a){var i=e*Math.cos(r)-t*Math.sin(r),o=(e*Math.sin(r)+t*Math.cos(r))*n;return{x:i*n+a.x,y:o+a.y}},a=function(e,t,n,a){for(var i=[],o=0;o(r=ar(e,t,x[w],x[w+1],x[w+2],x[w+3])))return v(n,r),!0}else if("bezier"===i.edgeType||"multibezier"===i.edgeType||"self"===i.edgeType||"compound"===i.edgeType)for(x=i.allpts,w=0;w+5(r=rr(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||a.source,b=b||a.target;var E=o.getArrowWidth(l,c),T=[{name:"source",x:i.arrowStartX,y:i.arrowStartY,angle:i.srcArrowAngle},{name:"target",x:i.arrowEndX,y:i.arrowEndY,angle:i.tgtArrowAngle},{name:"mid-source",x:i.midX,y:i.midY,angle:i.midsrcArrowAngle},{name:"mid-target",x:i.midX,y:i.midY,angle:i.midtgtArrowAngle}];for(w=0;w0&&(y(m),y(b))}function b(e,t,n){return Xt(e,t,n)}function x(n,r){var a,i=n._private,o=p;a=r?r+"-":"",n.boundingBox();var s=i.labelBounds[r||"main"],l=n.pstyle(a+"label").value;if("yes"===n.pstyle("text-events").strValue&&l){var u=b(i.rscratch,"labelX",r),c=b(i.rscratch,"labelY",r),d=b(i.rscratch,"labelAngle",r),h=n.pstyle(a+"text-margin-x").pfValue,f=n.pstyle(a+"text-margin-y").pfValue,g=s.x1-o-h,y=s.x2+o-h,m=s.y1-o-f,x=s.y2+o-f;if(d){var w=Math.cos(d),E=Math.sin(d),T=function(e,t){return{x:(e-=u)*w-(t-=c)*E+u,y:e*E+t*w+c}},C=T(g,m),k=T(g,x),P=T(y,m),S=T(y,x),D=[ +// with the margin added after the rotation is applied +C.x+h,C.y+f,P.x+h,P.y+f,S.x+h,S.y+f,k.x+h,k.y+f];if(ir(e,t,D))return v(n),!0}else if(Kn(s,e,t))return v(n),!0}}n&&(l=l.interactive);for(var w=l.length-1;w>=0;w--){var E=l[w];E.isNode()?y(E)||x(E):m(E)||x(E)||x(E,"source")||x(E,"target")}return u},getAllInBox:function(e,t,n,r){for(var a=this.getCachedZSortedEles().interactive,i=[],o=Math.min(e,n),s=Math.max(e,n),l=Math.min(t,r),u=Math.max(t,r),c=Fn({x1:e=o,y1:t=l,x2:n=s,y2:r=u}),d=0;d0?-(Math.PI-e.ang):Math.PI+e.ang},lh=function(e,t,n,r,a){if(e!==rh?oh(t,e,ah):sh(ih,ah),oh(t,n,ih),Yd=ah.nx*ih.ny-ah.ny*ih.nx,qd=ah.nx*ih.nx-ah.ny*-ih.ny,Hd=Math.asin(Math.max(-1,Math.min(1,Yd))),Math.abs(Hd)<1e-6)return jd=t.x,Xd=t.y,void(Kd=$d=0);Wd=1,Ud=!1,qd<0?Hd<0?Hd=Math.PI+Hd:(Hd=Math.PI-Hd,Wd=-1,Ud=!0):Hd>0&&(Wd=-1,Ud=!0),$d=void 0!==t.radius?t.radius:r,Gd=Hd/2,Qd=Math.min(ah.len/2,ih.len/2),a?(Zd=Math.abs(Math.cos(Gd)*$d/Math.sin(Gd)))>Qd?(Zd=Qd,Kd=Math.abs(Zd*Math.sin(Gd)/Math.cos(Gd))):Kd=$d:(Zd=Math.min(Qd,$d),Kd=Math.abs(Zd*Math.sin(Gd)/Math.cos(Gd))),th=t.x+ih.nx*Zd,nh=t.y+ih.ny*Zd,jd=th-ih.ny*Kd*Wd,Xd=nh+ih.nx*Kd*Wd,Jd=t.x+ah.nx*Zd,eh=t.y+ah.ny*Zd,rh=t};function uh(e,t){0===t.radius?e.lineTo(t.cx,t.cy):e.arc(t.cx,t.cy,t.radius,t.startAngle,t.endAngle,t.counterClockwise)}function ch(e,t,n,r){var a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return 0===r||0===t.radius?{cx:t.x,cy:t.y,radius:0,startX:t.x,startY:t.y,stopX:t.x,stopY:t.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(lh(e,t,n,r,a),{cx:jd,cy:Xd,radius:Kd,startX:Jd,startY:eh,stopX:th,stopY:nh,startAngle:ah.ang+Math.PI/2*Wd,endAngle:ih.ang-Math.PI/2*Wd,counterClockwise:Ud})}var dh={};function hh(e){var t=[];if(null!=e){for(var n=0;n0?Math.max(e-t,0):Math.min(e+t,0)},D=S(k,T),B=S(P,C),A=!1;y===u?v=Math.abs(D)>Math.abs(B)?a:r:y===l||y===s?(v=r,A=!0):y!==i&&y!==o||(v=a,A=!0);var _,M=v===r,R=M?B:D,I=M?P:k,N=_n(I),L=!1;A&&(b||w)||!(y===s&&I<0||y===l&&I>0||y===i&&I>0||y===o&&I<0)||(R=(N*=-1)*Math.abs(R),L=!0);var O=function(e){return Math.abs(e)=Math.abs(R)},z=O(_=b?(x<0?1+x:x)*R:(x<0?R:0)+x*N),F=O(Math.abs(R)-Math.abs(_));if(!z&&!F||L)if(M){var V=c.y1+_+(g?h/2*N:0),j=c.x1,X=c.x2;n.segpts=[j,V,X,V]}else{var Y=c.x1+_+(g?d/2*N:0),q=c.y1,W=c.y2;n.segpts=[Y,q,Y,W]}else if(M){var U=Math.abs(I)<=h/2,H=Math.abs(k)<=f/2;if(U){var G=(c.x1+c.x2)/2,K=c.y1,Z=c.y2;n.segpts=[G,K,G,Z]}else if(H){var $=(c.y1+c.y2)/2,Q=c.x1,J=c.x2;n.segpts=[Q,$,J,$]}else n.segpts=[c.x1,c.y2]}else{var ee=Math.abs(I)<=d/2,te=Math.abs(P)<=p/2;if(ee){var ne=(c.y1+c.y2)/2,re=c.x1,ae=c.x2;n.segpts=[re,ne,ae,ne]}else if(te){var ie=(c.x1+c.x2)/2,oe=c.y1,se=c.y2;n.segpts=[ie,oe,ie,se]}else n.segpts=[c.x2,c.y1]}if(n.isRound){var le=e.pstyle("taxi-radius").value,ue="arc-radius"===e.pstyle("radius-type").value[0];n.radii=new Array(n.segpts.length/2).fill(le),n.isArcRadius=new Array(n.segpts.length/2).fill(ue)}},dh.tryToCorrectInvalidPoints=function(e,t){var n=e._private.rscratch;if("bezier"===n.edgeType){var r=t.srcPos,a=t.tgtPos,i=t.srcW,o=t.srcH,s=t.tgtW,l=t.tgtH,u=t.srcShape,c=t.tgtShape,d=t.srcCornerRadius,h=t.tgtCornerRadius,f=t.srcRs,p=t.tgtRs,g=!ie(n.startX)||!ie(n.startY),v=!ie(n.arrowStartX)||!ie(n.arrowStartY),y=!ie(n.endX)||!ie(n.endY),m=!ie(n.arrowEndX)||!ie(n.arrowEndY),b=this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth*3,x=Mn({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),w=xg.poolIndex()){var v=p;p=g,g=v}var y=d.srcPos=p.position(),m=d.tgtPos=g.position(),b=d.srcW=p.outerWidth(),x=d.srcH=p.outerHeight(),E=d.tgtW=g.outerWidth(),T=d.tgtH=g.outerHeight(),C=d.srcShape=n.nodeShapes[t.getNodeShape(p)],k=d.tgtShape=n.nodeShapes[t.getNodeShape(g)],P=d.srcCornerRadius="auto"===p.pstyle("corner-radius").value?"auto":p.pstyle("corner-radius").pfValue,S=d.tgtCornerRadius="auto"===g.pstyle("corner-radius").value?"auto":g.pstyle("corner-radius").pfValue,D=d.tgtRs=g._private.rscratch,B=d.srcRs=p._private.rscratch;d.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var A=0;A0){var W=u,U=Rn(W,Tn(t)),H=Rn(W,Tn(q)),G=U;H2&&Rn(W,{x:q[2],y:q[3]})0){var le=c,ue=Rn(le,Tn(t)),ce=Rn(le,Tn(se)),de=ue;ce2&&Rn(le,{x:se[2],y:se[3]})=u||m){c={cp:g,segment:y};break}}if(c)break}var b=c.cp,x=c.segment,w=(u-h)/x.length,E=x.t1-x.t0,T=s?x.t0+E*w:x.t1-E*w;T=zn(0,T,1),t=Ln(b.p0,b.p1,b.p2,T),a=bh(b.p0,b.p1,b.p2,T);break;case"straight":case"segments":case"haystack":for(var C,k,P,S,D=0,B=r.allpts.length,A=0;A+3=u));A+=2);var _=(u-k)/C;_=zn(0,_,1),t=On(P,S,_),a=mh(P,S)}o("labelX",n,t.x),o("labelY",n,t.y),o("labelAutoAngle",n,a)}};u("source"),u("target"),this.applyLabelDimensions(e)}},vh.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},vh.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),a=this.calculateLabelDimensions(e,r),i=e.pstyle("line-height").pfValue,o=e.pstyle("text-wrap").strValue,s=Xt(n.rscratch,"labelWrapCachedLines",t)||[],l="wrap"!==o?1:Math.max(s.length,1),u=a.height/l,c=u*i,d=a.width,h=a.height+(l-1)*(i-1)*u;Yt(n.rstyle,"labelWidth",t,d),Yt(n.rscratch,"labelWidth",t,d),Yt(n.rstyle,"labelHeight",t,h),Yt(n.rscratch,"labelHeight",t,h),Yt(n.rscratch,"labelLineHeight",t,c)},vh.getLabelText=function(e,t){var n=e._private,r=t?t+"-":"",a=e.pstyle(r+"label").strValue,i=e.pstyle("text-transform").value,o=function(e,r){return r?(Yt(n.rscratch,e,t,r),r):Xt(n.rscratch,e,t)};if(!a)return"";"none"==i||("uppercase"==i?a=a.toUpperCase():"lowercase"==i&&(a=a.toLowerCase()));var l=e.pstyle("text-wrap").value;if("wrap"===l){var u=o("labelKey");if(null!=u&&o("labelWrapKey")===u)return o("labelWrapCachedText");for(var c="​",d=a.split("\n"),h=e.pstyle("text-max-width").pfValue,f="anywhere"===e.pstyle("text-overflow-wrap").value,p=[],g=/[\s\u200b]+|$/g,v=0;vh){var x,w="",E=0,T=s(y.matchAll(g));try{for(T.s();!(x=T.n()).done;){var C=x.value,k=C[0],P=y.substring(E,C.index);E=C.index+k.length;var S=0===w.length?P:w+P+k;this.calculateLabelDimensions(e,S).width<=h?w+=P+k:(w&&p.push(w),w=P+k)}}catch(R){T.e(R)}finally{T.f()}w.match(/^[\s\u200b]+$/)||p.push(w)}else p.push(y)}o("labelWrapCachedLines",p),a=o("labelWrapCachedText",p.join("\n")),o("labelWrapKey",u)}else if("ellipsis"===l){var D=e.pstyle("text-max-width").pfValue,B="",A="…",_=!1;if(this.calculateLabelDimensions(e,a).widthD);M++)B+=a[M],M===a.length-1&&(_=!0);return _||(B+=A),B}return a},vh.getLabelJustification=function(e){var t=e.pstyle("text-justification").strValue,n=e.pstyle("text-halign").strValue;if("auto"!==t)return t;if(!e.isNode())return"center";switch(n){case"left":return"right";case"right":return"left";default:return"center"}},vh.calculateLabelDimensions=function(e,t){var n=this,r=n.cy.window().document,a=xt(t,e._private.labelDimsKey),i=n.labelDimCache||(n.labelDimCache=[]),o=i[a];if(null!=o)return o;var s=0,l=e.pstyle("font-style").strValue,u=e.pstyle("font-size").pfValue,c=e.pstyle("font-family").strValue,d=e.pstyle("font-weight").strValue,h=this.labelCalcCanvas,f=this.labelCalcCanvasContext;if(!h){h=this.labelCalcCanvas=r.createElement("canvas"),f=this.labelCalcCanvasContext=h.getContext("2d");var p=h.style;p.position="absolute",p.left="-9999px",p.top="-9999px",p.zIndex="-1",p.visibility="hidden",p.pointerEvents="none"}f.font="".concat(l," ").concat(d," ").concat(u,"px ").concat(c);for(var g=0,v=0,y=t.split("\n"),m=0;m1&&void 0!==arguments[1])||arguments[1];if(t.merge(e),n)for(var r=0;r=e.desktopTapThreshold2}var P=i(t);p&&(e.hoverData.tapholdCancelled=!0);var S=function(){var t=e.hoverData.dragDelta=e.hoverData.dragDelta||[];0===t.length?(t.push(b[0]),t.push(b[1])):(t[0]+=b[0],t[1]+=b[1])};n=!0,a(f,["mousemove","vmousemove","tapdrag"],t,{x:u[0],y:u[1]});var D=function(){e.data.bgActivePosistion=void 0,e.hoverData.selecting||r.emit({originalEvent:t,type:"boxstart",position:{x:u[0],y:u[1]}}),h[4]=1,e.hoverData.selecting=!0,e.redrawHint("select",!0),e.redraw()};if(3===e.hoverData.which){if(p){var B={originalEvent:t,type:"cxtdrag",position:{x:u[0],y:u[1]}};m?m.emit(B):r.emit(B),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&f===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:u[0],y:u[1]}}),e.hoverData.cxtOver=f,f&&f.emit({originalEvent:t,type:"cxtdragover",position:{x:u[0],y:u[1]}}))}}else if(e.hoverData.dragging){if(n=!0,r.panningEnabled()&&r.userPanningEnabled()){var A;if(e.hoverData.justStartedPan){var _=e.hoverData.mdownPos;A={x:(u[0]-_[0])*s,y:(u[1]-_[1])*s},e.hoverData.justStartedPan=!1}else A={x:b[0]*s,y:b[1]*s};r.panBy(A),r.emit("dragpan"),e.hoverData.dragged=!0}u=e.projectIntoViewport(t.clientX,t.clientY)}else if(1!=h[4]||null!=m&&!m.pannable()){if(m&&m.pannable()&&m.active()&&m.unactivate(),m&&m.grabbed()||f==v||(v&&a(v,["mouseout","tapdragout"],t,{x:u[0],y:u[1]}),f&&a(f,["mouseover","tapdragover"],t,{x:u[0],y:u[1]}),e.hoverData.last=f),m)if(p){if(r.boxSelectionEnabled()&&P)m&&m.grabbed()&&(y(x),m.emit("freeon"),x.emit("free"),e.dragData.didDrag&&(m.emit("dragfreeon"),x.emit("dragfree"))),D();else if(m&&m.grabbed()&&e.nodeIsDraggable(m)){var M=!e.dragData.didDrag;M&&e.redrawHint("eles",!0),e.dragData.didDrag=!0,e.hoverData.draggingEles||g(x,{inDragLayer:!0});var R={x:0,y:0};if(ie(b[0])&&ie(b[1])&&(R.x+=b[0],R.y+=b[1],M)){var I=e.hoverData.dragDelta;I&&ie(I[0])&&ie(I[1])&&(R.x+=I[0],R.y+=I[1])}e.hoverData.draggingEles=!0,x.silentShift(R).emit("position drag"),e.redrawHint("drag",!0),e.redraw()}}else S();n=!0}else p&&(e.hoverData.dragging||!r.boxSelectionEnabled()||!P&&r.panningEnabled()&&r.userPanningEnabled()?!e.hoverData.selecting&&r.panningEnabled()&&r.userPanningEnabled()&&o(m,e.hoverData.downs)&&(e.hoverData.dragging=!0,e.hoverData.justStartedPan=!0,h[4]=0,e.data.bgActivePosistion=Tn(c),e.redrawHint("select",!0),e.redraw()):D(),m&&m.pannable()&&m.active()&&m.unactivate());return h[2]=u[0],h[3]=u[1],n?(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),!1):void 0}}),!1),e.registerBinding(t,"mouseup",(function(t){if((1!==e.hoverData.which||1===t.which||!e.hoverData.capture)&&e.hoverData.capture){e.hoverData.capture=!1;var r=e.cy,o=e.projectIntoViewport(t.clientX,t.clientY),s=e.selection,l=e.findNearestElement(o[0],o[1],!0,!1),u=e.dragData.possibleDragElements,c=e.hoverData.down,d=i(t);if(e.data.bgActivePosistion&&(e.redrawHint("select",!0),e.redraw()),e.hoverData.tapholdCancelled=!0,e.data.bgActivePosistion=void 0,c&&c.unactivate(),3===e.hoverData.which){var h={originalEvent:t,type:"cxttapend",position:{x:o[0],y:o[1]}};if(c?c.emit(h):r.emit(h),!e.hoverData.cxtDragged){var f={originalEvent:t,type:"cxttap",position:{x:o[0],y:o[1]}};c?c.emit(f):r.emit(f)}e.hoverData.cxtDragged=!1,e.hoverData.which=null}else if(1===e.hoverData.which){if(a(l,["mouseup","tapend","vmouseup"],t,{x:o[0],y:o[1]}),e.dragData.didDrag||e.hoverData.dragged||e.hoverData.selecting||e.hoverData.isOverThresholdDrag||(a(c,["click","tap","vclick"],t,{x:o[0],y:o[1]}),S=!1,t.timeStamp-D<=r.multiClickDebounceTime()?(P&&clearTimeout(P),S=!0,D=null,a(c,["dblclick","dbltap","vdblclick"],t,{x:o[0],y:o[1]})):(P=setTimeout((function(){S||a(c,["oneclick","onetap","voneclick"],t,{x:o[0],y:o[1]})}),r.multiClickDebounceTime()),D=t.timeStamp)),null!=c||e.dragData.didDrag||e.hoverData.selecting||e.hoverData.dragged||i(t)||(r.$(n).unselect(["tapunselect"]),u.length>0&&e.redrawHint("eles",!0),e.dragData.possibleDragElements=u=r.collection()),l!=c||e.dragData.didDrag||e.hoverData.selecting||null!=l&&l._private.selectable&&(e.hoverData.dragging||("additive"===r.selectionType()||d?l.selected()?l.unselect(["tapunselect"]):l.select(["tapselect"]):d||(r.$(n).unmerge(l).unselect(["tapunselect"]),l.select(["tapselect"]))),e.redrawHint("eles",!0)),e.hoverData.selecting){var p=r.collection(e.getAllInBox(s[0],s[1],s[2],s[3]));e.redrawHint("select",!0),p.length>0&&e.redrawHint("eles",!0),r.emit({type:"boxend",originalEvent:t,position:{x:o[0],y:o[1]}});var g=function(e){return e.selectable()&&!e.selected()};"additive"===r.selectionType()||d||r.$(n).unmerge(p).unselect(),p.emit("box").stdFilter(g).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 v=c&&c.grabbed();y(u),v&&(c.emit("freeon"),u.emit("free"),e.dragData.didDrag&&(c.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,e.hoverData.which=null}}),!1);var A,_,M,R,I,N,L,O,z,F,V,j,X,Y=function(t){if(!e.scrollingPage){var n=e.cy,r=n.zoom(),a=n.pan(),i=e.projectIntoViewport(t.clientX,t.clientY),o=[i[0]*r+a.x,i[1]*r+a.y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||C())t.preventDefault();else if(n.panningEnabled()&&n.userPanningEnabled()&&n.zoomingEnabled()&&n.userZoomingEnabled()){var s;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),s=null!=t.deltaY?t.deltaY/-250:null!=t.wheelDeltaY?t.wheelDeltaY/1e3:t.wheelDelta/1e3,s*=e.wheelSensitivity,1===t.deltaMode&&(s*=33);var l=n.zoom()*Math.pow(10,s);"gesturechange"===t.type&&(l=e.gestureStartZoom*t.scale),n.zoom({level:l,renderedPosition:{x:o[0],y:o[1]}}),n.emit("gesturechange"===t.type?"pinchzoom":"scrollzoom")}}};e.registerBinding(e.container,"wheel",Y,!0),e.registerBinding(t,"scroll",(function(t){e.scrollingPage=!0,clearTimeout(e.scrollingPageTimeout),e.scrollingPageTimeout=setTimeout((function(){e.scrollingPage=!1}),250)}),!0),e.registerBinding(e.container,"gesturestart",(function(t){e.gestureStartZoom=e.cy.zoom(),e.hasTouchStarted||t.preventDefault()}),!0),e.registerBinding(e.container,"gesturechange",(function(t){e.hasTouchStarted||Y(t)}),!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 q,W,U,H,G,K,Z,$=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},Q=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)};if(e.registerBinding(e.container,"touchstart",q=function(t){if(e.hasTouchStarted=!0,k(t)){b(),e.touchData.capture=!0,e.data.bgActivePosistion=void 0;var n=e.cy,r=e.touchData.now,i=e.touchData.earlier;if(t.touches[0]){var o=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);r[0]=o[0],r[1]=o[1]}if(t.touches[1]&&(o=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY),r[2]=o[0],r[3]=o[1]),t.touches[2]&&(o=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY),r[4]=o[0],r[5]=o[1]),t.touches[1]){e.touchData.singleTouchMoved=!0,y(e.dragData.touchDragEles);var s=e.findContainerClientCoords();z=s[0],F=s[1],V=s[2],j=s[3],A=t.touches[0].clientX-z,_=t.touches[0].clientY-F,M=t.touches[1].clientX-z,R=t.touches[1].clientY-F,X=0<=A&&A<=V&&0<=M&&M<=V&&0<=_&&_<=j&&0<=R&&R<=j;var l=n.pan(),u=n.zoom();I=$(A,_,M,R),N=Q(A,_,M,R),O=[((L=[(A+M)/2,(_+R)/2])[0]-l.x)/u,(L[1]-l.y)/u];var c=200;if(N=1){for(var T=e.touchData.startPosition=[null,null,null,null,null,null],C=0;C=e.touchTapThreshold2}if(n&&e.touchData.cxt){t.preventDefault();var x=t.touches[0].clientX-z,w=t.touches[0].clientY-F,E=t.touches[1].clientX-z,T=t.touches[1].clientY-F,C=Q(x,w,E,T),P=150,S=1.5;if(C/N>=S*S||C>=P*P){e.touchData.cxt=!1,e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var D={originalEvent:t,type:"cxttapend",position:{x:s[0],y:s[1]}};e.touchData.start?(e.touchData.start.unactivate().emit(D),e.touchData.start=null):i.emit(D)}}if(n&&e.touchData.cxt){D={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(D):i.emit(D),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var B=e.findNearestElement(s[0],s[1],!0,!0);e.touchData.cxtOver&&B===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:s[0],y:s[1]}}),e.touchData.cxtOver=B,B&&B.emit({originalEvent:t,type:"cxtdragover",position:{x:s[0],y:s[1]}}))}else if(n&&t.touches[2]&&i.boxSelectionEnabled())t.preventDefault(),e.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,e.touchData.selecting||i.emit({originalEvent:t,type:"boxstart",position:{x:s[0],y:s[1]}}),e.touchData.selecting=!0,e.touchData.didSelect=!0,r[4]=1,r&&0!==r.length&&void 0!==r[0]?(r[2]=(s[0]+s[2]+s[4])/3,r[3]=(s[1]+s[3]+s[5])/3):(r[0]=(s[0]+s[2]+s[4])/3,r[1]=(s[1]+s[3]+s[5])/3,r[2]=(s[0]+s[2]+s[4])/3+1,r[3]=(s[1]+s[3]+s[5])/3+1),e.redrawHint("select",!0),e.redraw();else if(n&&t.touches[1]&&!e.touchData.didSelect&&i.zoomingEnabled()&&i.panningEnabled()&&i.userZoomingEnabled()&&i.userPanningEnabled()){if(t.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),te=e.dragData.touchDragEles){e.redrawHint("drag",!0);for(var L=0;L0&&!e.hoverData.draggingEles&&!e.swipePanning&&null!=e.data.bgActivePosistion&&(e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.redraw())}},!1),e.registerBinding(t,"touchcancel",U=function(t){var n=e.touchData.start;e.touchData.capture=!1,n&&n.unactivate()}),e.registerBinding(t,"touchend",H=function(t){var r=e.touchData.start;if(e.touchData.capture){0===t.touches.length&&(e.touchData.capture=!1),t.preventDefault();var i=e.selection;e.swipePanning=!1,e.hoverData.draggingEles=!1;var o,s=e.cy,l=s.zoom(),u=e.touchData.now,c=e.touchData.earlier;if(t.touches[0]){var d=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);u[0]=d[0],u[1]=d[1]}if(t.touches[1]&&(d=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY),u[2]=d[0],u[3]=d[1]),t.touches[2]&&(d=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY),u[4]=d[0],u[5]=d[1]),r&&r.unactivate(),e.touchData.cxt){if(o={originalEvent:t,type:"cxttapend",position:{x:u[0],y:u[1]}},r?r.emit(o):s.emit(o),!e.touchData.cxtDragged){var h={originalEvent:t,type:"cxttap",position:{x:u[0],y:u[1]}};r?r.emit(h):s.emit(h)}return e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!1,e.touchData.start=null,void e.redraw()}if(!t.touches[2]&&s.boxSelectionEnabled()&&e.touchData.selecting){e.touchData.selecting=!1;var f=s.collection(e.getAllInBox(i[0],i[1],i[2],i[3]));i[0]=void 0,i[1]=void 0,i[2]=void 0,i[3]=void 0,i[4]=0,e.redrawHint("select",!0),s.emit({type:"boxend",originalEvent:t,position:{x:u[0],y:u[1]}});var p=function(e){return e.selectable()&&!e.selected()};f.emit("box").stdFilter(p).select().emit("boxselect"),f.nonempty()&&e.redrawHint("eles",!0),e.redraw()}if(null!=r&&r.unactivate(),t.touches[2])e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);else if(t.touches[1]);else if(t.touches[0]);else if(!t.touches[0]){e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var g=e.dragData.touchDragEles;if(null!=r){var v=r._private.grabbed;y(g),e.redrawHint("drag",!0),e.redrawHint("eles",!0),v&&(r.emit("freeon"),g.emit("free"),e.dragData.didDrag&&(r.emit("dragfreeon"),g.emit("dragfree"))),a(r,["touchend","tapend","vmouseup","tapdragout"],t,{x:u[0],y:u[1]}),r.unactivate(),e.touchData.start=null}else{var m=e.findNearestElement(u[0],u[1],!0,!0);a(m,["touchend","tapend","vmouseup","tapdragout"],t,{x:u[0],y:u[1]})}var b=e.touchData.startPosition[0]-u[0],x=b*b,w=e.touchData.startPosition[1]-u[1],E=(x+w*w)*l*l;e.touchData.singleTouchMoved||(r||s.$(":selected").unselect(["tapunselect"]),a(r,["tap","vclick"],t,{x:u[0],y:u[1]}),G=!1,t.timeStamp-Z<=s.multiClickDebounceTime()?(K&&clearTimeout(K),G=!0,Z=null,a(r,["dbltap","vdblclick"],t,{x:u[0],y:u[1]})):(K=setTimeout((function(){G||a(r,["onetap","voneclick"],t,{x:u[0],y:u[1]})}),s.multiClickDebounceTime()),Z=t.timeStamp)),null!=r&&!e.dragData.didDrag&&r._private.selectable&&E0)return f[0]}return null},f=Object.keys(d),p=0;p0?u:Qn(a,i,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,a,i,o,s){var l=2*(s="auto"===s?wr(r,a):s);if(or(e,t,this.points,i,o,r,a-l,[0,-1],n))return!0;if(or(e,t,this.points,i,o,r-l,a,[0,-1],n))return!0;var u=r/2+2*n,c=a/2+2*n;return!!ir(e,t,[i-u,o-c,i-u,o,i+u,o,i+u,o-c])||!!dr(e,t,l,l,i+r/2-s,o+a/2-s,n)||!!dr(e,t,l,l,i-r/2+s,o+a/2-s,n)}}},registerNodeShapes:function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",mr(3,0)),this.generateRoundPolygon("round-triangle",mr(3,0)),this.generatePolygon("rectangle",mr(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var n=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",n),this.generateRoundPolygon("round-diamond",n),this.generatePolygon("pentagon",mr(5,0)),this.generateRoundPolygon("round-pentagon",mr(5,0)),this.generatePolygon("hexagon",mr(6,0)),this.generateRoundPolygon("round-hexagon",mr(6,0)),this.generatePolygon("heptagon",mr(7,0)),this.generateRoundPolygon("round-heptagon",mr(7,0)),this.generatePolygon("octagon",mr(8,0)),this.generateRoundPolygon("round-octagon",mr(8,0));var r=new Array(20),a=xr(5,0),i=xr(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s=e.deqFastCost*g)break}else if(a){if(f>=e.deqCost*l||f>=e.deqAvgCost*s)break}else if(p>=e.deqNoDrawCost*Rh)break;var v=e.deq(t,d,c);if(!(v.length>0))break;for(var y=0;y0&&(e.onDeqd(t,u),!a&&e.shouldRedraw(t,u,d,c)&&r())},i=e.priority||Dt;n.beforeRender(a,i(t))}}}},Nh=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Pt;a(this,e),this.idsByKey=new Wt,this.keyForId=new Wt,this.cachesByLvl=new Wt,this.lvls=[],this.getKey=t,this.doesEleInvalidateKey=n}return o(e,[{key:"getIdsFor",value:function(e){null==e&&Bt("Can not get id list for null key");var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new Gt,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 Wt,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)}))} +// returns true if no other eles reference the invalidated cache (n.b. other eles may need the cache with the same key) +},{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)}}])}(),Lh=25,Oh=50,zh=-4,Fh=3,Vh=7.99,jh=8,Xh=1024,Yh=1024,qh=1024,Wh=.2,Uh=.8,Hh=10,Gh=.15,Kh=.1,Zh=.9,$h=.9,Qh=100,Jh=1,ef={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},tf=zt({getKey:null,doesEleInvalidateKey:Pt,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:kt,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),nf=function(e,t){var n=this;n.renderer=e,n.onDequeues=[];var r=tf(t);Re(n,r),n.lookup=new Nh(r.getKey,r.doesEleInvalidateKey),n.setupDequeueing()},rf=nf.prototype;rf.reasons=ef,rf.getTextureQueue=function(e){var t=this;return t.eleImgCaches=t.eleImgCaches||{},t.eleImgCaches[e]=t.eleImgCaches[e]||[]},rf.getRetiredTextureQueue=function(e){var t=this,n=t.eleImgCaches.retired=t.eleImgCaches.retired||{};return n[e]=n[e]||[]},rf.getElementQueue=function(){var e=this;return e.eleCacheQueue=e.eleCacheQueue||new on((function(e,t){return t.reqs-e.reqs}))},rf.getElementKeyToQueue=function(){var e=this;return e.eleKeyToCacheQueue=e.eleKeyToCacheQueue||{}},rf.getElement=function(e,t,n,r,a){var i=this,o=this.renderer,s=o.cy.zoom(),l=this.lookup;if(!t||0===t.w||0===t.h||isNaN(t.w)||isNaN(t.h)||!e.visible()||e.removed())return null;if(!i.allowEdgeTxrCaching&&e.isEdge()||!i.allowParentTxrCaching&&e.isParent())return null;if(null==r&&(r=Math.ceil(An(s*n))),r=Vh||r>Fh)return null;var u=Math.pow(2,r),c=t.h*u,d=t.w*u,h=o.eleTextBiggerThanMin(e,u);if(!this.isVisible(e,h))return null;var f,p=l.get(e,r);if(p&&p.invalidated&&(p.invalidated=!1,p.texture.invalidatedWidth-=p.width),p)return p;if(f=c<=Lh?Lh:c<=Oh?Oh:Math.ceil(c/Oh)*Oh,c>qh||d>Yh)return null;var g=i.getTextureQueue(f),v=g[g.length-2],y=function(){return i.recycleTexture(f,d)||i.addTexture(f,d)};v||(v=g[g.length-1]),v||(v=y()),v.width-v.usedWidthr;S--)k=i.getElement(e,t,n,S,ef.downscale);P()}else{var D;if(!x&&!w&&!E)for(var B=r-1;B>=zh;B--){var A=l.get(e,B);if(A){D=A;break}}if(b(D))return i.queueElement(e,r),D;v.context.translate(v.usedWidth,0),v.context.scale(u,u),this.drawElement(v.context,e,t,h,!1),v.context.scale(1/u,1/u),v.context.translate(-v.usedWidth,0)}return p={x:v.usedWidth,texture:v,level:r,scale:u,width:d,height:c,scaledLabelShown:h},v.usedWidth+=Math.ceil(d+jh),v.eleCaches.push(p),l.set(e,r,p),i.checkTextureFullness(v),p},rf.invalidateElements=function(e){for(var t=0;t=Wh*e.width&&this.retireTexture(e)},rf.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>Uh&&e.fullnessChecks>=Hh?Ft(t,e):e.fullnessChecks++},rf.retireTexture=function(e){var t=this,n=e.height,r=t.getTextureQueue(n),a=this.lookup;Ft(r,e),e.retired=!0;for(var i=e.eleCaches,o=0;o=t)return o.retired=!1,o.usedWidth=0,o.invalidatedWidth=0,o.fullnessChecks=0,Vt(o.eleCaches),o.context.setTransform(1,0,0,1,0,0),o.context.clearRect(0,0,o.width,o.height),Ft(a,o),r.push(o),o}},rf.queueElement=function(e,t){var n=this,r=n.getElementQueue(),a=n.getElementKeyToQueue(),i=this.getKey(e),o=a[i];if(o)o.level=Math.max(o.level,t),o.eles.merge(e),o.reqs++,r.updateItem(o);else{var s={eles:e.spawn().merge(e),level:t,reqs:1,key:i};r.push(s),a[i]=s}},rf.dequeue=function(e){for(var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),a=[],i=t.lookup,o=0;o0;o++){var s=n.pop(),l=s.key,u=s.eles[0],c=i.hasCache(u,s.level);if(r[l]=null,!c){a.push(s);var d=t.getBoundingBox(u);t.getElement(u,d,e,s.level,ef.dequeue)}}return a},rf.removeFromQueue=function(e){var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),a=this.getKey(e),i=r[a];null!=i&&(1===i.eles.length?(i.reqs=Ct,n.updateItem(i),n.pop(),r[a]=null):i.eles.unmerge(e))},rf.onDequeue=function(e){this.onDequeues.push(e)},rf.offDequeue=function(e){Ft(this.onDequeues,e)},rf.setupDequeueing=Ih.setupDequeueing({deqRedrawThreshold:Qh,deqCost:Gh,deqAvgCost:Kh,deqNoDrawCost:Zh,deqFastCost:$h,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n=lf||n>sf)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},a=function(e){if(!s)for(var r=n+e;of<=r&&r<=sf&&!t(r);r+=e);};a(1),a(-1);for(var i=c.length-1;i>=0;i--){var o=c[i];o.invalid&&Ft(c,o)}}();var d=function(){if(!o){o=Fn();for(var t=0;tmf||i>mf)return null;if(a*i>yf)return null;var s=r.makeLayer(o,n);if(null!=t){var l=c.indexOf(t)+1;c.splice(l,0,s)}else(void 0===e.insert||e.insert)&&c.unshift(s);return s};if(r.skipping&&!i)return null;for(var f=null,p=e.length/af,g=!i,v=0;v=p||!$n(f.bb,y.boundingBox()))&&!(f=h({insert:!0,after:f})))return null;s||g?r.queueLayer(f,y):r.drawEleInLayer(f,y,n,t),f.eles.push(y),b[n]=f}}return s||(g?null:c)},wf.getEleLevelForLayerLevel=function(e,t){return e},wf.drawEleInLayer=function(e,t,n,r){var a=this,i=this.renderer,o=e.context,s=t.boundingBox();0!==s.w&&0!==s.h&&t.visible()&&(n=a.getEleLevelForLayerLevel(n,r),i.setImgSmoothing(o,!1),i.drawCachedElement(o,t,null,null,n,bf),i.setImgSmoothing(o,!0))},wf.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||0===n.length)return!1;for(var r=0,a=0;a0)return!1;if(i.invalid)return!1;r+=i.eles.length}return r===t.length},wf.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r0){t=!0;break}}return t},wf.invalidateElements=function(e){var t=this;0!==e.length&&(t.lastInvalidationTime=ut(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,(function(e,n,r){t.invalidateLayer(e)})))},wf.invalidateLayer=function(e){if(this.lastInvalidationTime=ut(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];Ft(r,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var a=0;a3&&void 0!==arguments[3])||arguments[3],a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],o=this,s=t._private.rscratch;if((!i||t.visible())&&!s.badLine&&null!=s.allpts&&!isNaN(s.allpts[0])){var l;n&&(l=n,e.translate(-l.x1,-l.y1));var u=i?t.pstyle("opacity").value:1,c=i?t.pstyle("line-opacity").value:1,d=t.pstyle("curve-style").value,h=t.pstyle("line-style").value,f=t.pstyle("width").pfValue,p=t.pstyle("line-cap").value,g=t.pstyle("line-outline-width").value,v=t.pstyle("line-outline-color").value,y=u*c,m=u*c,b=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y;"straight-triangle"===d?(o.eleStrokeStyle(e,t,n),o.drawEdgeTrianglePath(t,e,s.allpts)):(e.lineWidth=f,e.lineCap=p,o.eleStrokeStyle(e,t,n),o.drawEdgePath(t,e,s.allpts,h),e.lineCap="butt")},x=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y;e.lineWidth=f+g,e.lineCap=p,g>0?(o.colorStrokeStyle(e,v[0],v[1],v[2],n),"straight-triangle"===d?o.drawEdgeTrianglePath(t,e,s.allpts):(o.drawEdgePath(t,e,s.allpts,h),e.lineCap="butt")):e.lineCap="butt"},w=function(){a&&o.drawEdgeOverlay(e,t)},E=function(){a&&o.drawEdgeUnderlay(e,t)},T=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;o.drawArrowheads(e,t,n)},C=function(){o.drawElementText(e,t,null,r)};if(e.lineJoin="round","yes"===t.pstyle("ghost").value){var k=t.pstyle("ghost-offset-x").pfValue,P=t.pstyle("ghost-offset-y").pfValue,S=t.pstyle("ghost-opacity").value,D=y*S;e.translate(k,P),b(D),T(D),e.translate(-k,-P)}else x();E(),b(),T(),w(),C(),n&&e.translate(l.x1,l.y1)}}},Ff=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,n){if(n.visible()){var r=n.pstyle("".concat(e,"-opacity")).value;if(0!==r){var a=this,i=a.usePaths(),o=n._private.rscratch,s=2*n.pstyle("".concat(e,"-padding")).pfValue,l=n.pstyle("".concat(e,"-color")).value;t.lineWidth=s,"self"!==o.edgeType||i?t.lineCap="round":t.lineCap="butt",a.colorStrokeStyle(t,l[0],l[1],l[2],r),a.drawEdgePath(n,t,o.allpts,"solid")}}}};zf.drawEdgeOverlay=Ff("overlay"),zf.drawEdgeUnderlay=Ff("underlay"),zf.drawEdgePath=function(e,t,n,r){var a,i=e._private.rscratch,o=t,l=!1,u=this.usePaths(),c=e.pstyle("line-dash-pattern").pfValue,d=e.pstyle("line-dash-offset").pfValue;if(u){var h=n.join("$");i.pathCacheKey&&i.pathCacheKey===h?(a=t=i.pathCache,l=!0):(a=t=new Path2D,i.pathCacheKey=h,i.pathCache=a)}if(o.setLineDash)switch(r){case"dotted":o.setLineDash([1,1]);break;case"dashed":o.setLineDash(c),o.lineDashOffset=d;break;case"solid":o.setLineDash([])}if(!l&&!i.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),i.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var f=2;f+35&&void 0!==arguments[5]?arguments[5]:5,o=arguments.length>6?arguments[6]:void 0;e.beginPath(),e.moveTo(t+i,n),e.lineTo(t+r-i,n),e.quadraticCurveTo(t+r,n,t+r,n+i),e.lineTo(t+r,n+a-i),e.quadraticCurveTo(t+r,n+a,t+r-i,n+a),e.lineTo(t+i,n+a),e.quadraticCurveTo(t,n+a,t,n+a-i),e.lineTo(t,n+i),e.quadraticCurveTo(t,n,t+i,n),e.closePath(),o?e.stroke():e.fill()}jf.eleTextBiggerThanMin=function(e,t){if(!t){var n=e.cy().zoom(),r=this.getPixelRatio(),a=Math.ceil(An(n*r));t=Math.pow(2,a)}return!(e.pstyle("font-size").pfValue*t5&&void 0!==arguments[5])||arguments[5],o=this;if(null==r){if(i&&!o.eleTextBiggerThanMin(t))return}else if(!1===r)return;if(t.isNode()){var s=t.pstyle("label");if(!s||!s.value)return;var l=o.getLabelJustification(t);e.textAlign=l,e.textBaseline="bottom"}else{var u=t.element()._private.rscratch.badLine,c=t.pstyle("label"),d=t.pstyle("source-label"),h=t.pstyle("target-label");if(u||(!c||!c.value)&&(!d||!d.value)&&(!h||!h.value))return;e.textAlign="center",e.textBaseline="bottom"}var f,p=!n;n&&(f=n,e.translate(-f.x1,-f.y1)),null==a?(o.drawText(e,t,null,p,i),t.isEdge()&&(o.drawText(e,t,"source",p,i),o.drawText(e,t,"target",p,i))):o.drawText(e,t,a,p,i),n&&e.translate(f.x1,f.y1)},jf.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,a=t.pstyle("font-size").pfValue+"px",i=t.pstyle("font-family").strValue,o=t.pstyle("font-weight").strValue,s=n?t.effectiveOpacity()*t.pstyle("text-opacity").value: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+" "+a+" "+i,e.lineJoin="round",this.colorFillStyle(e,u[0],u[1],u[2],s),this.colorStrokeStyle(e,c[0],c[1],c[2],l)},jf.getTextAngle=function(e,t){var n,r=e._private.rscratch,a=t?t+"-":"",i=e.pstyle(a+"text-rotation");if("autorotate"===i.strValue){var o=Xt(r,"labelAngle",t);n=e.isEdge()?o:0}else n="none"===i.strValue?0:i.pfValue;return n},jf.drawText=function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=t._private.rscratch,o=a?t.effectiveOpacity():1;if(!a||0!==o&&0!==t.pstyle("text-opacity").value){"main"===n&&(n=null);var s,l,u=Xt(i,"labelX",n),c=Xt(i,"labelY",n),d=this.getLabelText(t,n);if(null!=d&&""!==d&&!isNaN(u)&&!isNaN(c)){this.setupTextStyle(e,t,a);var h,f=n?n+"-":"",p=Xt(i,"labelWidth",n),g=Xt(i,"labelHeight",n),v=t.pstyle(f+"text-margin-x").pfValue,y=t.pstyle(f+"text-margin-y").pfValue,m=t.isEdge(),b=t.pstyle("text-halign").value,x=t.pstyle("text-valign").value;switch(m&&(b="center",x="center"),u+=v,c+=y,0!==(h=r?this.getTextAngle(t,n):0)&&(s=u,l=c,e.translate(s,l),e.rotate(h),u=0,c=0),x){case"top":break;case"center":c+=g/2;break;case"bottom":c+=g}var w=t.pstyle("text-background-opacity").value,E=t.pstyle("text-border-opacity").value,T=t.pstyle("text-border-width").pfValue,C=t.pstyle("text-background-padding").pfValue,k=0===t.pstyle("text-background-shape").strValue.indexOf("round"),P=2;if(w>0||T>0&&E>0){var S=u-C;switch(b){case"left":S-=p;break;case"center":S-=p/2}var D=c-g-C,B=p+2*C,A=g+2*C;if(w>0){var _=e.fillStyle,M=t.pstyle("text-background-color").value;e.fillStyle="rgba("+M[0]+","+M[1]+","+M[2]+","+w*o+")",k?Xf(e,S,D,B,A,P):e.fillRect(S,D,B,A),e.fillStyle=_}if(T>0&&E>0){var R=e.strokeStyle,I=e.lineWidth,N=t.pstyle("text-border-color").value,L=t.pstyle("text-border-style").value;if(e.strokeStyle="rgba("+N[0]+","+N[1]+","+N[2]+","+E*o+")",e.lineWidth=T,e.setLineDash)switch(L){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=T/4,e.setLineDash([]);break;case"solid":e.setLineDash([])}if(k?Xf(e,S,D,B,A,P,"stroke"):e.strokeRect(S,D,B,A),"double"===L){var O=T/2;k?Xf(e,S+O,D+O,B-2*O,A-2*O,P,"stroke"):e.strokeRect(S+O,D+O,B-2*O,A-2*O)}e.setLineDash&&e.setLineDash([]),e.lineWidth=I,e.strokeStyle=R}}var z=2*t.pstyle("text-outline-width").pfValue;if(z>0&&(e.lineWidth=z),"wrap"===t.pstyle("text-wrap").value){var F=Xt(i,"labelWrapCachedLines",n),V=Xt(i,"labelLineHeight",n),j=p/2,X=this.getLabelJustification(t);switch("auto"===X||("left"===b?"left"===X?u+=-p:"center"===X&&(u+=-j):"center"===b?"left"===X?u+=-j:"right"===X&&(u+=j):"right"===b&&("center"===X?u+=j:"right"===X&&(u+=p))),x){case"top":case"center":case"bottom":c-=(F.length-1)*V}for(var Y=0;Y0&&e.strokeText(F[Y],u,c),e.fillText(F[Y],u,c),c+=V}else z>0&&e.strokeText(d,u,c),e.fillText(d,u,c);0!==h&&(e.rotate(-h),e.translate(-s,-l))}}};var Yf={drawNode:function(e,t,n){var r,a,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],l=this,u=t._private,c=u.rscratch,d=t.position();if(ie(d.x)&&ie(d.y)&&(!s||t.visible())){var h,f,p=s?t.effectiveOpacity():1,g=l.usePaths(),v=!1,y=t.padding();r=t.width()+2*y,a=t.height()+2*y,n&&(f=n,e.translate(-f.x1,-f.y1));for(var m=t.pstyle("background-image").value,b=new Array(m.length),x=new Array(m.length),w=0,E=0;E0&&void 0!==arguments[0]?arguments[0]:S;l.eleFillStyle(e,t,n)},Y=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N;l.colorStrokeStyle(e,D[0],D[1],D[2],t)},q=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:F;l.colorStrokeStyle(e,O[0],O[1],O[2],t)},W=function(e,t,n,r){var a,i=l.nodePathCache=l.nodePathCache||[],o=wt("polygon"===n?n+","+r.join(","):n,""+t,""+e,""+j),s=i[o],u=!1;return null!=s?(a=s,u=!0,c.pathCache=a):(a=new Path2D,i[o]=c.pathCache=a),{path:a,cacheHit:u}},U=t.pstyle("shape").strValue,H=t.pstyle("shape-polygon-points").pfValue;if(g){e.translate(d.x,d.y);var G=W(r,a,U,H);h=G.path,v=G.cacheHit}var K=function(){if(!v){var n=d;g&&(n={x:0,y:0}),l.nodeShapes[l.getNodeShape(t)].draw(h||e,n.x,n.y,r,a,j,c)}g?e.fill(h):e.fill()},Z=function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=u.backgrounding,i=0,o=0;o0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;l.hasPie(t)&&(l.drawPie(e,t,i),n&&(g||l.nodeShapes[l.getNodeShape(t)].draw(e,d.x,d.y,r,a,j,c)))},Q=function(){var t=(k>0?k:-k)*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:p),n=k>0?0:255;0!==k&&(l.colorFillStyle(e,n,n,n,t),g?e.fill(h):e.fill())},J=function(){if(P>0){if(e.lineWidth=P,e.lineCap=_,e.lineJoin=A,e.setLineDash)switch(B){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash(R),e.lineDashOffset=I;break;case"solid":case"double":e.setLineDash([])}if("center"!==M){if(e.save(),e.lineWidth*=2,"inside"===M)g?e.clip(h):e.clip();else{var t=new Path2D;t.rect(-r/2-P,-a/2-P,r+2*P,a+2*P),t.addPath(h),e.clip(t,"evenodd")}g?e.stroke(h):e.stroke(),e.restore()}else g?e.stroke(h):e.stroke();if("double"===B){e.lineWidth=P/3;var n=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",g?e.stroke(h):e.stroke(),e.globalCompositeOperation=n}e.setLineDash&&e.setLineDash([])}},ee=function(){if(L>0){if(e.lineWidth=L,e.lineCap="butt",e.setLineDash)switch(z){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([])}var n=d;g&&(n={x:0,y:0});var i=l.getNodeShape(t),o=P;"inside"===M&&(o=0),"outside"===M&&(o*=2);var s,u=(r+o+(L+V))/r,c=(a+o+(L+V))/a,h=r*u,f=a*c,p=l.nodeShapes[i].points;if(g&&(s=W(h,f,i,p).path),"ellipse"===i)l.drawEllipsePath(s||e,n.x,n.y,h,f);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(i)){var v=0,y=0,m=0;"round-diamond"===i?v=1.4*(o+V+L):"round-heptagon"===i?(v=1.075*(o+V+L),m=-(o/2+V+L)/35):"round-hexagon"===i?v=1.12*(o+V+L):"round-pentagon"===i?(v=1.13*(o+V+L),m=-(o/2+V+L)/15):"round-tag"===i?(v=1.12*(o+V+L),y=.07*(o/2+L+V)):"round-triangle"===i&&(v=(o+V+L)*(Math.PI/2),m=-(o+V/2+L)/Math.PI),0!==v&&(h=r*(u=(r+v)/r),["round-hexagon","round-tag"].includes(i)||(f=a*(c=(a+v)/a)));for(var b=h/2,x=f/2,w=(j="auto"===j?Er(h,f):j)+(o+L+V)/2,E=new Array(p.length/2),T=new Array(p.length/2),C=0;C0){if(r=r||n.position(),null==a||null==i){var h=n.padding();a=n.width()+2*h,i=n.height()+2*h}o.colorFillStyle(t,u[0],u[1],u[2],l),o.nodeShapes[c].draw(t,r.x,r.y,a+2*s,i+2*s,d),t.fill()}}}};Yf.drawNodeOverlay=qf("overlay"),Yf.drawNodeUnderlay=qf("underlay"),Yf.hasPie=function(e){return(e=e[0])._private.hasPie},Yf.drawPie=function(e,t,n,r){t=t[0],r=r||t.position();var a=t.cy().style(),i=t.pstyle("pie-size"),o=r.x,s=r.y,l=t.width(),u=t.height(),c=Math.min(l,u)/2,d=0;this.usePaths()&&(o=0,s=0),"%"===i.units?c*=i.pfValue:void 0!==i.pfValue&&(c=i.pfValue/2);for(var h=1;h<=a.pieBackgroundN;h++){var f=t.pstyle("pie-"+h+"-background-size").value,p=t.pstyle("pie-"+h+"-background-color").value,g=t.pstyle("pie-"+h+"-background-opacity").value*n,v=f/100;v+d>1&&(v=1-d);var y=1.5*Math.PI+2*Math.PI*d,m=y+2*Math.PI*v;0===f||d>=1||d+v>1||(e.beginPath(),e.moveTo(o,s),e.arc(o,s,c,y,m),e.closePath(),this.colorFillStyle(e,p[0],p[1],p[2],g),e.fill(),d+=v)}};var Wf,Uf={},Hf=100;function Gf(e,t,n){var r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error(e.getShaderInfoLog(r));return r}function Kf(e,t,n){var r=Gf(e,e.VERTEX_SHADER,t),a=Gf(e,e.FRAGMENT_SHADER,n),i=e.createProgram();if(e.attachShader(i,r),e.attachShader(i,a),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw new Error("Could not initialize shaders");return i}function Zf(e,t,n){void 0===n&&(n=t);var r=e.makeOffscreenCanvas(t,n),a=r.context=r.getContext("2d");return r.clear=function(){return a.clearRect(0,0,r.width,r.height)},r.clear(),r}function $f(e){var t=e.pixelRatio,n=e.cy.zoom(),r=e.cy.pan();return{zoom:n*t,pan:{x:r.x*t,y:r.y*t}}}function Qf(e,t,n,r,a){var i=r*n+t.x,o=a*n+t.y;return[i,o=Math.round(e.canvasHeight-o)]}function Jf(e,t,n){var r=e[0]/255,a=e[1]/255,i=e[2]/255,o=t,s=n||new Array(4);return s[0]=r*o,s[1]=a*o,s[2]=i*o,s[3]=o,s}function ep(e,t){var n=t||new Array(4);return n[0]=(255&e)/255,n[1]=(e>>8&255)/255,n[2]=(e>>16&255)/255,n[3]=(e>>24&255)/255,n}function tp(e){return e[0]+(e[1]<<8)+(e[2]<<16)+(e[3]<<24)}function np(e,t){var n=e.createTexture();return n.buffer=function(t){e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)},n.deleteTexture=function(){e.deleteTexture(n)},n}function rp(e,t){switch(t){case"float":return[1,e.FLOAT,4];case"vec2":return[2,e.FLOAT,4];case"vec3":return[3,e.FLOAT,4];case"vec4":return[4,e.FLOAT,4];case"int":return[1,e.INT,4];case"ivec2":return[2,e.INT,4]}}function ap(e,t,n){switch(t){case e.FLOAT:return new Float32Array(n);case e.INT:return new Int32Array(n)}}function ip(e,t,n,r,a,i){switch(t){case e.FLOAT:return new Float32Array(n.buffer,i*r,a);case e.INT:return new Int32Array(n.buffer,i*r,a)}}function op(e,t,n,r){var a=f(rp(e,t),2),i=a[0],o=a[1],s=ap(e,o,r),l=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,l),e.bufferData(e.ARRAY_BUFFER,s,e.STATIC_DRAW),o===e.FLOAT?e.vertexAttribPointer(n,i,o,!1,0,0):o===e.INT&&e.vertexAttribIPointer(n,i,o,0,0),e.enableVertexAttribArray(n),e.bindBuffer(e.ARRAY_BUFFER,null),l}function sp(e,t,n,r){var a=f(rp(e,n),3),i=a[0],o=a[1],s=a[2],l=ap(e,o,t*i),u=i*s,c=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,t*u,e.DYNAMIC_DRAW),e.enableVertexAttribArray(r),o===e.FLOAT?e.vertexAttribPointer(r,i,o,!1,u,0):o===e.INT&&e.vertexAttribIPointer(r,i,o,u,0),e.vertexAttribDivisor(r,1),e.bindBuffer(e.ARRAY_BUFFER,null);for(var d=new Array(t),h=0;ht.minMbLowQualFrames&&(t.motionBlurPxRatio=t.mbPxRBlurry)),t.clearingMotionBlur&&(t.motionBlurPxRatio=1),t.textureDrawLastFrame&&!d&&(c[t.NODE]=!0,c[t.SELECT_BOX]=!0);var m=n.style(),b=n.zoom(),x=void 0!==o?o:b,w=n.pan(),E={x:w.x,y:w.y},T={zoom:b,pan:{x:w.x,y:w.y}},C=t.prevViewport;void 0===C||T.zoom!==C.zoom||T.pan.x!==C.pan.x||T.pan.y!==C.pan.y||g&&!p||(t.motionBlurPxRatio=1),s&&(E=s),x*=l,E.x*=l,E.y*=l;var k=t.getCachedZSortedEles();function P(e,n,r,a,i){var o=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",t.colorFillStyle(e,255,255,255,t.motionBlurTransparency),e.fillRect(n,r,a,i),e.globalCompositeOperation=o}function S(e,n){var i,l,c,d;t.clearingMotionBlur||e!==u.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]&&e!==u.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]?(i=E,l=x,c=t.canvasWidth,d=t.canvasHeight):(i={x:w.x*f,y:w.y*f},l=b*f,c=t.canvasWidth*f,d=t.canvasHeight*f),e.setTransform(1,0,0,1,0,0),"motionBlur"===n?P(e,0,0,c,d):r||void 0!==n&&!n||e.clearRect(0,0,c,d),a||(e.translate(i.x,i.y),e.scale(l,l)),s&&e.translate(s.x,s.y),o&&e.scale(o,o)}if(d||(t.textureDrawLastFrame=!1),d){if(t.textureDrawLastFrame=!0,!t.textureCache){t.textureCache={},t.textureCache.bb=n.mutableElements().boundingBox(),t.textureCache.texture=t.data.bufferCanvases[t.TEXTURE_BUFFER];var D=t.data.bufferContexts[t.TEXTURE_BUFFER];D.setTransform(1,0,0,1,0,0),D.clearRect(0,0,t.canvasWidth*t.textureMult,t.canvasHeight*t.textureMult),t.render({forcedContext:D,drawOnlyNodeLayer:!0,forcedPxRatio:l*t.textureMult}),(T=t.textureCache.viewport={zoom:n.zoom(),pan:n.pan(),width:t.canvasWidth,height:t.canvasHeight}).mpan={x:(0-T.pan.x)/T.zoom,y:(0-T.pan.y)/T.zoom}}c[t.DRAG]=!1,c[t.NODE]=!1;var B=u.contexts[t.NODE],A=t.textureCache.texture;T=t.textureCache.viewport,B.setTransform(1,0,0,1,0,0),h?P(B,0,0,T.width,T.height):B.clearRect(0,0,T.width,T.height);var _=m.core("outside-texture-bg-color").value,M=m.core("outside-texture-bg-opacity").value;t.colorFillStyle(B,_[0],_[1],_[2],M),B.fillRect(0,0,T.width,T.height),b=n.zoom(),S(B,!1),B.clearRect(T.mpan.x,T.mpan.y,T.width/T.zoom/l,T.height/T.zoom/l),B.drawImage(A,T.mpan.x,T.mpan.y,T.width/T.zoom/l,T.height/T.zoom/l)}else t.textureOnViewport&&!r&&(t.textureCache=null);var R=n.extent(),I=t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming||t.hoverData.draggingEles||t.cy.animated(),N=t.hideEdgesOnViewport&&I,L=[];if(L[t.NODE]=!c[t.NODE]&&h&&!t.clearedForMotionBlur[t.NODE]||t.clearingMotionBlur,L[t.NODE]&&(t.clearedForMotionBlur[t.NODE]=!0),L[t.DRAG]=!c[t.DRAG]&&h&&!t.clearedForMotionBlur[t.DRAG]||t.clearingMotionBlur,L[t.DRAG]&&(t.clearedForMotionBlur[t.DRAG]=!0),c[t.NODE]||a||i||L[t.NODE]){var O=h&&!L[t.NODE]&&1!==f;S(B=r||(O?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]:u.contexts[t.NODE]),h&&!O?"motionBlur":void 0),N?t.drawCachedNodes(B,k.nondrag,l,R):t.drawLayeredElements(B,k.nondrag,l,R),t.debug&&t.drawDebugPoints(B,k.nondrag),a||h||(c[t.NODE]=!1)}if(!i&&(c[t.DRAG]||a||L[t.DRAG])&&(O=h&&!L[t.DRAG]&&1!==f,S(B=r||(O?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]:u.contexts[t.DRAG]),h&&!O?"motionBlur":void 0),N?t.drawCachedNodes(B,k.drag,l,R):t.drawCachedElements(B,k.drag,l,R),t.debug&&t.drawDebugPoints(B,k.drag),a||h||(c[t.DRAG]=!1)),this.drawSelectionRectangle(e,S),h&&1!==f){var z=u.contexts[t.NODE],F=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE],V=u.contexts[t.DRAG],j=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG],X=function(e,n,r){e.setTransform(1,0,0,1,0,0),r||!y?e.clearRect(0,0,t.canvasWidth,t.canvasHeight):P(e,0,0,t.canvasWidth,t.canvasHeight);var a=f;e.drawImage(n, +// img +0,0, +// sx, sy +t.canvasWidth*a,t.canvasHeight*a, +// sw, sh +0,0, +// x, y +t.canvasWidth,t.canvasHeight)};(c[t.NODE]||L[t.NODE])&&(X(z,F,L[t.NODE]),c[t.NODE]=!1),(c[t.DRAG]||L[t.DRAG])&&(X(V,j,L[t.DRAG]),c[t.DRAG]=!1)}t.prevViewport=T,t.clearingMotionBlur&&(t.clearingMotionBlur=!1,t.motionBlurCleared=!0,t.motionBlur=!0),h&&(t.motionBlurTimeout=setTimeout((function(){t.motionBlurTimeout=null,t.clearedForMotionBlur[t.NODE]=!1,t.clearedForMotionBlur[t.DRAG]=!1,t.motionBlur=!1,t.clearingMotionBlur=!d,t.mbFrames=0,c[t.NODE]=!0,c[t.DRAG]=!0,t.redraw()}),Hf)),r||n.emit("render")},Uf.drawSelectionRectangle=function(e,t){var n=this,r=n.cy,a=n.data,i=r.style(),o=e.drawOnlyNodeLayer,s=e.drawAllLayers,l=a.canvasNeedsRedraw,u=e.forcedContext;if(n.showFps||!o&&l[n.SELECT_BOX]&&!s){var c=u||a.contexts[n.SELECT_BOX];if(t(c),1==n.selection[4]&&(n.hoverData.selecting||n.touchData.selecting)){var d=n.cy.zoom(),h=i.core("selection-box-border-width").value/d;c.lineWidth=h,c.fillStyle="rgba("+i.core("selection-box-color").value[0]+","+i.core("selection-box-color").value[1]+","+i.core("selection-box-color").value[2]+","+i.core("selection-box-opacity").value+")",c.fillRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]),h>0&&(c.strokeStyle="rgba("+i.core("selection-box-border-color").value[0]+","+i.core("selection-box-border-color").value[1]+","+i.core("selection-box-border-color").value[2]+","+i.core("selection-box-opacity").value+")",c.strokeRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]))}if(a.bgActivePosistion&&!n.hoverData.selecting){d=n.cy.zoom();var f=a.bgActivePosistion;c.fillStyle="rgba("+i.core("active-bg-color").value[0]+","+i.core("active-bg-color").value[1]+","+i.core("active-bg-color").value[2]+","+i.core("active-bg-opacity").value+")",c.beginPath(),c.arc(f.x,f.y,i.core("active-bg-size").pfValue/d,0,2*Math.PI),c.fill()}var p=n.lastRedrawTime;if(n.showFps&&p){p=Math.round(p);var g=Math.round(1e3/p),v="1 frame = "+p+" ms = "+g+" fps";if(c.setTransform(1,0,0,1,0,0),c.fillStyle="rgba(255, 0, 0, 0.75)",c.strokeStyle="rgba(255, 0, 0, 0.75)",c.font="30px Arial",!Wf){var y=c.measureText(v);Wf=y.actualBoundingBoxAscent}c.fillText(v,0,Wf);var m=60;c.strokeRect(0,Wf+10,250,20),c.fillRect(0,Wf+10,250*Math.min(g/m,1),20)}s||(l[n.SELECT_BOX]=!1)}};var cp="undefined"!=typeof Float32Array?Float32Array:Array;function dp(){var e=new cp(9);return cp!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function hp(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function fp(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],d=t[8],h=n[0],f=n[1],p=n[2],g=n[3],v=n[4],y=n[5],m=n[6],b=n[7],x=n[8];return e[0]=h*r+f*o+p*u,e[1]=h*a+f*s+p*c,e[2]=h*i+f*l+p*d,e[3]=g*r+v*o+y*u,e[4]=g*a+v*s+y*c,e[5]=g*i+v*l+y*d,e[6]=m*r+b*o+x*u,e[7]=m*a+b*s+x*c,e[8]=m*i+b*l+x*d,e}function pp(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],d=t[8],h=n[0],f=n[1];return e[0]=r,e[1]=a,e[2]=i,e[3]=o,e[4]=s,e[5]=l,e[6]=h*r+f*o+u,e[7]=h*a+f*s+c,e[8]=h*i+f*l+d,e}function gp(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],d=t[8],h=Math.sin(n),f=Math.cos(n);return e[0]=f*r+h*o,e[1]=f*a+h*s,e[2]=f*i+h*l,e[3]=f*o-h*r,e[4]=f*s-h*a,e[5]=f*l-h*i,e[6]=u,e[7]=c,e[8]=d,e}function vp(e,t,n){var r=n[0],a=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=a*t[3],e[4]=a*t[4],e[5]=a*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function yp(e,t,n){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/n,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var mp={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},bp=zt({texRows:24}),xp=zt({collection:"default",getKey:null, +// since render types (eg node-body, node-overlay) can share an atlas collection, its importeant their style keys don't collide +drawElement:null,getBoundingBox:null,getRotation:null,getRotationPoint:null,getRotationOffset:null,isVisible:function(){return!0}, +// this is an extra check for visibility in addition to ele.visible() +getPadding:0}),wp=function(){function e(t,n,r,i){a(this,e),this.debugID=Math.floor(1e4*Math.random()),this.r=t,this.texSize=n,this.texRows=r,this.texHeight=Math.floor(n/r),this.enableWrapping=!0,this.locked=!1,this.texture=null,this.needsBuffer=!0,this.freePointer={x:0,row:0},this.keyToLocation=new Map,this.canvas=i(t,n,n),this.scratch=i(t,n,this.texHeight,"scratch")}return o(e,[{key:"lock",value:function(){this.locked=!0}},{key:"getKeys",value:function(){return new Set(this.keyToLocation.keys())}},{key:"getScale",value:function(e){var t=e.w,n=e.h,r=this.texHeight,a=this.texSize,i=r/n,o=t*i,s=n*i;return o>a&&(o=t*(i=a/t),s=n*i),{scale:i,texW:o,texH:s}}},{key:"draw",value:function(e,t,n){var r=this;if(this.locked)throw new Error("can't draw, atlas is locked");var a=this.texSize,i=this.texRows,o=this.texHeight,s=this.getScale(t),l=s.scale,u=s.texW,c=s.texH,d=[null,null],h=function(e,r){if(n&&r){var a=r.context,i=e.x,s=e.row,u=i,c=o*s;a.save(),a.translate(u,c),a.scale(l,l),n(a,t),a.restore()}},f=function(){h(r.freePointer,r.canvas),d[0]={x:r.freePointer.x,y:r.freePointer.row*o,w:u,h:c},d[1]={ +// indlude a second location with a width of 0, for convenience +x:r.freePointer.x+u,y:r.freePointer.row*o,w:0,h:c},r.freePointer.x+=u,r.freePointer.x==a&&(r.freePointer.x=0,r.freePointer.row++)},p=function(){var e=r.scratch,t=r.canvas;e.clear(),h({x:0,row:0},e);var n=a-r.freePointer.x,i=u-n,s=o,l=r.freePointer.x,f=r.freePointer.row*o,p=n;t.context.drawImage(e,0,0,p,s,l,f,p,s),d[0]={x:l,y:f,w:p,h:c};var g=n,v=(r.freePointer.row+1)*o,y=i;t&&t.context.drawImage(e,g,0,y,s,0,v,y,s),d[1]={x:0,y:v,w:y,h:c},r.freePointer.x=i,r.freePointer.row++},g=function(){r.freePointer.x=0,r.freePointer.row++};if(this.freePointer.x+u<=a)f();else{if(this.freePointer.row>=i-1)return!1;this.freePointer.x===a?(g(),f()):this.enableWrapping?p():(g(),f())}return this.keyToLocation.set(e,d),this.needsBuffer=!0,d}},{key:"getOffsets",value:function(e){return this.keyToLocation.get(e)}},{key:"isEmpty",value:function(){return 0===this.freePointer.x&&0===this.freePointer.row}},{key:"canFit",value:function(e){if(this.locked)return!1;var t=this.texSize,n=this.texRows,r=this.getScale(e).texW;return!(this.freePointer.x+r>t)||this.freePointer.row1&&void 0!==arguments[1]?arguments[1]:{},r=n.forceRedraw,a=void 0!==r&&r,i=n.filterEle,o=void 0===i?function(){return!0}:i,l=n.filterType,u=void 0===l?function(){return!0}:l,c=!1,d=!1,h=s(e);try{for(h.s();!(t=h.n()).done;){var f=t.value;if(o(f)){var p,g=s(this.renderTypes.values());try{for(g.s();!(p=g.n()).done;){var v=p.value,y=v.type;if(u(y)){var m=v.getKey(f),b=this.collections.get(v.collection);if(a)b.markKeyForGC(m),d=!0;else{var x=v.getID?v.getID(f):f.id(),w=this._key(y,x),E=this.typeAndIdToKey.get(w);void 0!==E&&E!==m&&(this.typeAndIdToKey.delete(w),b.markKeyForGC(E),c=!0)}}}}catch(T){g.e(T)}finally{g.f()}}}}catch(T){h.e(T)}finally{h.f()}return d&&(this.gc(),c=!1),c} +/** Garbage collect */},{key:"gc",value:function(){var e,t=s(this.collections.values());try{for(t.s();!(e=t.n()).done;)e.value.gc()}catch(n){t.e(n)}finally{t.f()}}},{key:"getOrCreateAtlas",value:function(e,t,n){var r=this.renderTypes.get(t),a=r.getKey(e);n||(n=r.getBoundingBox(e));var i=this.collections.get(r.collection),o=!1,s=i.draw(a,n,(function(t){r.drawElement(t,e,n,!0,!0),o=!0}));if(o){var l=r.getID?r.getID(e):e.id(),u=this._key(t,l);this.typeAndIdToKey.set(u,a)}return s}},{key:"startBatch",value:function(){this.batchAtlases=[]}},{key:"getAtlasCount",value:function(){return this.batchAtlases.length}},{key:"getAtlases",value:function(){return this.batchAtlases}},{key:"canAddToCurrentBatch",value:function(e,t){if(this.batchAtlases.length===this.maxAtlasesPerBatch){var n=this.renderTypes.get(t),r=n.getKey(e),a=this.collections.get(n.collection).getAtlas(r);return Boolean(a)&&this.batchAtlases.includes(a)}return!0}},{key:"getAtlasIndexForBatch",value:function(e){var t=this.batchAtlases.indexOf(e);if(t<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)return;this.batchAtlases.push(e),t=this.batchAtlases.length-1}return t}},{key:"getIndexArray",value:function(){return Array.from({length:this.maxAtlasesPerBatch},(function(e,t){return t}))}},{key:"getAtlasInfo",value:function(e,t){var n=this.renderTypes.get(t),r=n.getBoundingBox(e),a=this.getOrCreateAtlas(e,t,r),i=this.getAtlasIndexForBatch(a);if(void 0!==i){var o=n.getKey(e),s=f(a.getOffsets(o),2);return{index:i,tex1:s[0],tex2:s[1],bb:r}}} +/** + * matrix is expected to be a 9 element array + * this function follows same pattern as CRp.drawCachedElementPortion(...) + */},{key:"setTransformMatrix",value:function(e,t,n,r){var a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=this.getRenderTypeOpts(n),o=i.getPadding?i.getPadding(e):0;if(r){var s=r.bb,l=r.tex1,u=r.tex2,c=l.w/(l.w+u.w);a||(c=1-c);var d=this.getAdjustedBB(s,o,a,c);this._applyTransformMatrix(t,d,i,e)}else{var h=i.getBoundingBox(e),f=this.getAdjustedBB(h,o,!0,1);this._applyTransformMatrix(t,f,i,e)}}},{key:"_applyTransformMatrix",value:function(e,t,n,r){var a,i;hp(e);var o=n.getRotation?n.getRotation(r):0;if(0!==o){var s=n.getRotationPoint(r);pp(e,e,[s.x,s.y]),gp(e,e,o);var l=n.getRotationOffset(r);a=l.x+t.xOffset,i=l.y}else a=t.x1,i=t.y1;pp(e,e,[a,i]),vp(e,e,[t.w,t.h])} +/** + * Adjusts a node or label BB to accomodate padding and split for wrapped textures. + * @param bb - the original bounding box + * @param padding - the padding to add to the bounding box + * @param first - whether this is the first part of a wrapped texture + * @param ratio - the ratio of the texture width of part of the text to the entire texture + */},{key:"getAdjustedBB",value:function(e,t,n,r){var a=e.x1,i=e.y1,o=e.w,s=e.h;t&&(a-=t,i-=t,o+=2*t,s+=2*t);var l=0,u=o*r;return n&&r<1?o=u:!n&&r<1&&(a+=l=o-u,o=u),{x1:a,y1:i,w:o,h:s,xOffset:l}}},{key:"getDebugInfo",value:function(){var e,t=[],n=s(this.collections);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1].getCounts(),o=i.keyCount,l=i.atlasCount;t.push({type:a,keyCount:o,atlasCount:l})}}catch(u){n.e(u)}finally{n.f()}return t}}])}(),kp=0,Pp=1,Sp=2,Dp=3,Bp=4,Ap=function(){function e(t,n,r){a(this,e),this.r=t,this.gl=n,this.maxInstances=r.webglBatchSize,this.atlasSize=r.webglTexSize,this.bgColor=r.bgColor,this.debug=r.webglDebug,this.batchDebugInfo=[],r.enableWrapping=!0,r.createTextureCanvas=Zf,this.atlasManager=new Cp(t,r),this.program=this.createShaderProgram(mp.SCREEN),this.pickingProgram=this.createShaderProgram(mp.PICKING),this.vao=this.createVAO()}return o(e,[{key:"addAtlasCollection",value:function(e,t){this.atlasManager.addAtlasCollection(e,t)}},{key:"addAtlasRenderType",value:function(e,t){this.atlasManager.addRenderType(e,t)}},{key:"invalidate",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).type,n=this.atlasManager;return t?n.invalidate(e,{filterType:function(e){return e===t},forceRedraw:!0}):n.invalidate(e)}},{key:"gc",value:function(){this.atlasManager.gc()}},{key:"createShaderProgram",value:function(e){var t=this.gl,n="#version 300 es\n precision highp float;\n\n uniform mat3 uPanZoomMatrix;\n uniform int uAtlasSize;\n \n // instanced\n in vec2 aPosition; \n\n in mat3 aTransform;\n\n // what are we rendering?\n in int aVertType;\n\n // for picking\n in vec4 aIndex;\n \n // For textures\n in int aAtlasId; // which shader unit/atlas to use\n in vec4 aTex; // x/y/w/h of texture in atlas\n\n // for edges\n in vec4 aPointAPointB;\n in vec4 aPointCPointD;\n in float aLineWidth;\n in vec4 aColor;\n\n out vec2 vTexCoord;\n out vec4 vColor;\n flat out int vAtlasId;\n flat out vec4 vIndex;\n flat out int vVertType;\n\n void main(void) {\n int vid = gl_VertexID;\n vec2 position = aPosition;\n\n if(aVertType == ".concat(kp,") {\n float texX = aTex.x;\n float texY = aTex.y;\n float texW = aTex.z;\n float texH = aTex.w;\n\n int vid = gl_VertexID;\n\n if(vid == 1 || vid == 2 || vid == 4) {\n texX += texW;\n }\n if(vid == 2 || vid == 4 || vid == 5) {\n texY += texH;\n }\n\n float d = float(uAtlasSize);\n vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n }\n else if(aVertType == ").concat(Bp,") {\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n vColor = aColor;\n }\n else if(aVertType == ").concat(Pp,") {\n vec2 source = aPointAPointB.xy;\n vec2 target = aPointAPointB.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n vec2 xBasis = target - source;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n vec2 point = source + xBasis * position.x + yBasis * aLineWidth * position.y;\n\n gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);\n vColor = aColor;\n } \n else if(aVertType == ").concat(Sp,") {\n vec2 pointA = aPointAPointB.xy;\n vec2 pointB = aPointAPointB.zw;\n vec2 pointC = aPointCPointD.xy;\n vec2 pointD = aPointCPointD.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n vec2 p0 = pointA;\n vec2 p1 = pointB;\n vec2 p2 = pointC;\n vec2 pos = position;\n if(position.x == 1.0) {\n p0 = pointD;\n p1 = pointC;\n p2 = pointB;\n pos = vec2(0.0, -position.y);\n }\n\n vec2 p01 = p1 - p0;\n vec2 p12 = p2 - p1;\n vec2 p21 = p1 - p2;\n\n // Find the normal vector.\n vec2 tangent = normalize(normalize(p12) + normalize(p01));\n vec2 normal = vec2(-tangent.y, tangent.x);\n\n // Find the vector perpendicular to p0 -> p1.\n vec2 p01Norm = normalize(vec2(-p01.y, p01.x));\n\n // Determine the bend direction.\n float sigma = sign(dot(p01 + p21, normal));\n float width = aLineWidth;\n\n if(sign(pos.y) == -sigma) {\n // This is an intersecting vertex. Adjust the position so that there's no overlap.\n vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n } else {\n // This is a non-intersecting vertex. Treat it like a mitre join.\n vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n }\n\n vColor = aColor;\n } \n else if(aVertType == ").concat(Dp," && vid < 3) {\n // massage the first triangle into an edge arrow\n if(vid == 0)\n position = vec2(-0.15, -0.3);\n if(vid == 1)\n position = vec2( 0.0, 0.0);\n if(vid == 2)\n position = vec2( 0.15, -0.3);\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n vColor = aColor;\n }\n else {\n gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space\n }\n\n vAtlasId = aAtlasId;\n vIndex = aIndex;\n vVertType = aVertType;\n }\n "),r=this.atlasManager.getIndexArray(),a=Kf(t,n,"#version 300 es\n precision highp float;\n\n // define texture unit for each node in the batch\n ".concat(r.map((function(e){return"uniform sampler2D uTexture".concat(e,";")})).join("\n\t"),"\n\n uniform vec4 uBGColor;\n\n in vec2 vTexCoord;\n in vec4 vColor;\n flat in int vAtlasId;\n flat in vec4 vIndex;\n flat in int vVertType;\n\n out vec4 outColor;\n\n void main(void) {\n if(vVertType == ").concat(kp,") {\n ").concat(r.map((function(e){return"if(vAtlasId == ".concat(e,") outColor = texture(uTexture").concat(e,", vTexCoord);")})).join("\n\telse "),"\n } else if(vVertType == ").concat(Dp,") {\n // blend arrow color with background (using premultiplied alpha)\n outColor.rgb = vColor.rgb + (uBGColor.rgb * (1.0 - vColor.a)); \n outColor.a = 1.0; // make opaque, masks out line under arrow\n } else {\n outColor = vColor;\n }\n\n ").concat(e.picking?"if(outColor.a == 0.0) discard;\n else outColor = vIndex;":"","\n }\n "));a.aPosition=t.getAttribLocation(a,"aPosition"),a.aIndex=t.getAttribLocation(a,"aIndex"),a.aVertType=t.getAttribLocation(a,"aVertType"),a.aTransform=t.getAttribLocation(a,"aTransform"),a.aAtlasId=t.getAttribLocation(a,"aAtlasId"),a.aTex=t.getAttribLocation(a,"aTex"),a.aPointAPointB=t.getAttribLocation(a,"aPointAPointB"),a.aPointCPointD=t.getAttribLocation(a,"aPointCPointD"),a.aLineWidth=t.getAttribLocation(a,"aLineWidth"),a.aColor=t.getAttribLocation(a,"aColor"),a.uPanZoomMatrix=t.getUniformLocation(a,"uPanZoomMatrix"),a.uAtlasSize=t.getUniformLocation(a,"uAtlasSize"),a.uBGColor=t.getUniformLocation(a,"uBGColor"),a.uTextures=[];for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:mp.SCREEN;this.panZoomMatrix=e,this.renderTarget=t,this.batchDebugInfo=[],this.wrappedCount=0,this.rectangleCount=0,this.startBatch()}},{key:"startBatch",value:function(){this.instanceCount=0,this.atlasManager.startBatch()}},{key:"endFrame",value:function(){this.endBatch()}},{key:"getTempMatrix",value:function(){return this.tempMatrix=this.tempMatrix||dp()}},{key:"drawTexture",value:function(e,t,n){var r=this.atlasManager;if(e.visible()&&r.getRenderTypeOpts(n).isVisible(e)){r.canAddToCurrentBatch(e,n)||this.endBatch(),this.instanceCount+1>=this.maxInstances&&this.endBatch();var a=this.instanceCount;this.vertTypeBuffer.getView(a)[0]=kp,ep(t,this.indexBuffer.getView(a));var i=r.getAtlasInfo(e,n),o=i.index,s=i.tex1,l=i.tex2;l.w>0&&this.wrappedCount++;for(var u=!0,c=0,d=[s,l];c=this.maxInstances&&this.endBatch()}}},{key:"drawSimpleRectangle",value:function(e,t,n){if(e.visible()){var r=this.atlasManager,a=this.instanceCount;this.vertTypeBuffer.getView(a)[0]=Bp,ep(t,this.indexBuffer.getView(a)),Jf(e.pstyle("background-color").value,e.pstyle("background-opacity").value,this.colorBuffer.getView(a));var i=this.transformBuffer.getMatrixView(a);r.setTransformMatrix(e,i,n),this.rectangleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:"drawEdgeArrow",value:function(e,t,n){if(e.visible()){var r,a,i,o=e._private.rscratch;if("source"===n?(r=o.arrowStartX,a=o.arrowStartY,i=o.srcArrowAngle):(r=o.arrowEndX,a=o.arrowEndY,i=o.tgtArrowAngle),!(isNaN(r)||null==r||isNaN(a)||null==a||isNaN(i)||null==i||"none"===e.pstyle(n+"-arrow-shape").value)){var s=e.pstyle(n+"-arrow-color").value,l=e.pstyle("opacity").value*e.pstyle("line-opacity").value,u=e.pstyle("width").pfValue,c=e.pstyle("arrow-scale").value,d=this.r.getArrowWidth(u,c),h=this.instanceCount,f=this.transformBuffer.getMatrixView(h);hp(f),pp(f,f,[r,a]),vp(f,f,[d,d]),gp(f,f,i),this.vertTypeBuffer.getView(h)[0]=Dp,ep(t,this.indexBuffer.getView(h)),Jf(s,l,this.colorBuffer.getView(h)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:"drawEdgeLine",value:function(e,t){if(e.visible()){var n=this.getEdgePoints(e);if(n){var r=e.pstyle("opacity").value,a=e.pstyle("line-opacity").value,i=e.pstyle("width").pfValue,o=e.pstyle("line-color").value,s=r*a;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),4==n.length){var l=this.instanceCount;this.vertTypeBuffer.getView(l)[0]=Pp,ep(t,this.indexBuffer.getView(l)),Jf(o,s,this.colorBuffer.getView(l)),this.lineWidthBuffer.getView(l)[0]=i;var u=this.pointAPointBBuffer.getView(l);u[0]=n[0],u[1]=n[1],u[2]=n[2],u[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var c=0;c=this.maxInstances&&this.endBatch()}}}}},{key:"getEdgePoints",value:function(e){var t=e._private.rscratch;if(!t.badLine&&null!=t.allpts&&!isNaN(t.allpts[0])){var n=t.allpts;if(4==n.length)return n;var r=this.getNumSegments(e);return this.getCurveSegmentPoints(n,r)}}},{key:"getNumSegments",value:function(e){var t=15;return Math.min(Math.max(t,5),this.maxInstances)}},{key:"getCurveSegmentPoints",value:function(e,t){if(4==e.length)return e;for(var n=Array(2*(t+1)),r=0;r<=t;r++)if(0==r)n[0]=e[0],n[1]=e[1];else if(r==t)n[2*r]=e[e.length-2],n[2*r+1]=e[e.length-1];else{var a=r/t;this.setCurvePoint(e,a,n,2*r)}return n}},{key:"setCurvePoint",value:function(e,t,n,r){if(!(e.length<=2)){for(var a=Array(e.length-2),i=0;i0}},{key:"getStyle",value:function(e,t){return{opacity:t.pstyle("".concat(e,"-opacity")).value,color:t.pstyle("".concat(e,"-color")).value,shape:t.pstyle("".concat(e,"-shape")).value}}},{key:"getPadding",value:function(e,t){return t.pstyle("".concat(e,"-padding")).pfValue}},{key:"draw",value:function(e,t,n,r){if(this.isVisible(e,n)){var a=this.r,i=r.w,o=r.h,s=i/2,l=o/2,u=this.getStyle(e,n),c=u.shape,d=u.color,h=u.opacity;t.save(),t.fillStyle=_p(d,h),"round-rectangle"===c||"roundrectangle"===c?a.drawRoundRectanglePath(t,s,l,i,o,"auto"):"ellipse"===c&&a.drawEllipsePath(t,s,l,i,o),t.fill(),t.restore()}}}])}(),Rp={};function Ip(e){var t=e.cy.container(),n=t&&t.style&&t.style.backgroundColor||"white";return ze(n)}function Np(e){var t=e.render;e.render=function(n){n=n||{};var r=e.cy;e.webgl&&(r.zoom()>Vh?(Lp(e),t.call(e,n)):(Op(e),Hp(e,n,mp.SCREEN)))};var n=e.matchCanvasSize;e.matchCanvasSize=function(t){n.call(e,t),e.pickingFrameBuffer.setFramebufferAttachmentSizes(e.canvasWidth,e.canvasHeight),e.pickingFrameBuffer.needsDraw=!0},e.findNearestElements=function(t,n,r,a){return qp(e,t,n)};var r=e.invalidateCachedZSortedEles;e.invalidateCachedZSortedEles=function(){r.call(e),e.pickingFrameBuffer.needsDraw=!0};var a=e.notify;e.notify=function(t,n){a.call(e,t,n),"viewport"===t||"bounds"===t?e.pickingFrameBuffer.needsDraw=!0:"background"===t&&e.drawing.invalidate(n,{type:"node-body"})}}function Lp(e){var t=e.data.contexts[e.WEBGL];t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)}function Op(e){var t=function(t){t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.canvasWidth,e.canvasHeight),t.restore()};t(e.data.contexts[e.NODE]),t(e.data.contexts[e.DRAG])}function zp(e){var t=e.canvasWidth,n=e.canvasHeight,r=$f(e),a=r.pan,i=r.zoom,o=dp();pp(o,o,[a.x,a.y]),vp(o,o,[i,i]);var s=dp();yp(s,t,n);var l=dp();return fp(l,s,o),l}function Fp(e,t){var n=e.canvasWidth,r=e.canvasHeight,a=$f(e),i=a.pan,o=a.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(i.x,i.y),t.scale(o,o)}function Vp(e,t){e.drawSelectionRectangle(t,(function(t){return Fp(e,t)}))}function jp(e){var t=e.data.contexts[e.NODE];t.save(),Fp(e,t),t.strokeStyle="rgba(0, 0, 0, 0.3)",t.beginPath(),t.moveTo(-1e3,0),t.lineTo(1e3,0),t.stroke(),t.beginPath(),t.moveTo(0,-1e3),t.lineTo(0,1e3),t.stroke(),t.restore()}function Xp(e){var t=function(t,n,r){for(var a=t.atlasManager.getAtlasCollection(n),i=e.data.contexts[e.NODE],o=.125,s=a.atlases,l=0;l=0&&v.add(m)}return v}function qp(e,t,n){var r,a,i,o=Yp(e,t,n),l=e.getCachedZSortedEles(),u=s(o);try{for(u.s();!(i=u.n()).done;){var c=l[i.value];if(!r&&c.isNode()&&(r=c),!a&&c.isEdge()&&(a=c),r&&a)break}}catch(d){u.e(d)}finally{u.f()}return[r,a].filter(Boolean)}function Wp(e){return"rectangle"===e.pstyle("shape").value&&"solid"===e.pstyle("background-fill").value&&0===e.pstyle("border-width").pfValue&&"none"===e.pstyle("background-image").strValue}function Up(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawTexture(n,t,"node-underlay"),Wp(n)?r.drawSimpleRectangle(n,t,"node-body"):r.drawTexture(n,t,"node-body"),r.drawTexture(n,t,"label"),r.drawTexture(n,t,"node-overlay")):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,"source"),r.drawEdgeArrow(n,t,"target"),r.drawTexture(n,t,"label"),r.drawTexture(n,t,"edge-source-label"),r.drawTexture(n,t,"edge-target-label"))}function Hp(e,t,n){var r;e.webglDebug&&(r=performance.now());var a=e.drawing,i=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&Vp(e,t),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var o=e.data.contexts[e.WEBGL];n.screen?(o.clearColor(0,0,0,0),o.enable(o.BLEND),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA)):o.disable(o.BLEND),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),o.viewport(0,0,o.canvas.width,o.canvas.height);var l=zp(e),u=e.getCachedZSortedEles();if(i=u.length,a.startFrame(l,n),n.screen){for(var c=0;c0&&(r|=n.drawing.invalidate(t)),r&&s()})),Np(n)};for(var Gp={drawPolygonPath:function(e,t,n,r,a,i){var o=r/2,s=a/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*i[0],n+s*i[1]);for(var l=1;l0&&i>0){h.clearRect(0,0,a,i),h.globalCompositeOperation="source-over";var f=this.getCachedZSortedEles();if(e.full)h.translate(-n.x1*l,-n.y1*l),h.scale(l,l),this.drawElements(h,f),h.scale(1/l,1/l),h.translate(n.x1*l,n.y1*l);else{var p=t.pan(),g={x:p.x*l,y:p.y*l};l*=t.zoom(),h.translate(g.x,g.y),h.scale(l,l),this.drawElements(h,f),h.scale(1/l,1/l),h.translate(-g.x,-g.y)}e.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=e.bg,h.rect(0,0,a,i),h.fill())}return d},tg.png=function(e){return ag(e,this.bufferCanvasImage(e),"image/png")},tg.jpg=function(e){return ag(e,this.bufferCanvasImage(e),"image/jpeg")};var ig={nodeShapeImpl:function(e,t,n,r,a,i,o,s){switch(e){case"ellipse":return this.drawEllipsePath(t,n,r,a,i);case"polygon":return this.drawPolygonPath(t,n,r,a,i,o);case"round-polygon":return this.drawRoundPolygonPath(t,n,r,a,i,o,s);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(t,n,r,a,i,s);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(t,n,r,a,i,o,s);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(t,n,r,a,i,s);case"barrel":return this.drawBarrelPath(t,n,r,a,i)}}},og=lg,sg=lg.prototype;function lg(e){var t=this,n=t.cy.window().document;e.webgl&&(sg.CANVAS_LAYERS=t.CANVAS_LAYERS=4),t.data={canvases:new Array(sg.CANVAS_LAYERS),contexts:new Array(sg.CANVAS_LAYERS),canvasNeedsRedraw:new Array(sg.CANVAS_LAYERS),bufferCanvases:new Array(sg.BUFFER_COUNT),bufferContexts:new Array(sg.CANVAS_LAYERS)};var r="-webkit-tap-highlight-color",a="rgba(0,0,0,0)";t.data.canvasContainer=n.createElement("div");var i=t.data.canvasContainer.style;t.data.canvasContainer.style[r]=a,i.position="relative",i.zIndex="0",i.overflow="hidden";var o=e.cy.container();o.appendChild(t.data.canvasContainer),o.style[r]=a;var s={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};me()&&(s["-ms-touch-action"]="none",s["touch-action"]="none");for(var l=0;l