import{b2 as hi,b3 as rl,l as Er,c as ci,aH as al,u as nl,aJ as ja,d as en,h as il,b5 as sl,b6 as ol,b7 as ul,aL as ll}from"../app.CV7ObeM5.js";import{c as fl}from"./createText-ca0c5216.CfRbav5E.js";import"./framework.DuA-ZlS8.js";import"./theme.B-IrzYt-.js";function Xe(t){"@babel/helpers - typeof";return Xe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xe(t)}function vi(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function hl(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,a=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(u){throw u},f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var u=r.next();return i=u.done,u},e:function(u){s=!0,o=u},f:function(){try{!i&&r.return!=null&&r.return()}finally{if(s)throw o}}}}var Ye=typeof window>"u"?null:window,Yi=Ye?Ye.navigator:null;Ye&&Ye.document;var gl=Xe(""),so=Xe({}),pl=Xe(function(){}),yl=typeof HTMLElement>"u"?"undefined":Xe(HTMLElement),xa=function(e){return e&&e.instanceString&&Ge(e.instanceString)?e.instanceString():null},de=function(e){return e!=null&&Xe(e)==gl},Ge=function(e){return e!=null&&Xe(e)===pl},Re=function(e){return!pt(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},Ce=function(e){return e!=null&&Xe(e)===so&&!Re(e)&&e.constructor===Object},ml=function(e){return e!=null&&Xe(e)===so},ie=function(e){return e!=null&&Xe(e)===Xe(1)&&!isNaN(e)},bl=function(e){return ie(e)&&Math.floor(e)===e},tn=function(e){if(yl!=="undefined")return e!=null&&e instanceof HTMLElement},pt=function(e){return Ta(e)||oo(e)},Ta=function(e){return xa(e)==="collection"&&e._private.single},oo=function(e){return xa(e)==="collection"&&!e._private.single},gi=function(e){return xa(e)==="core"},uo=function(e){return xa(e)==="stylesheet"},El=function(e){return xa(e)==="event"},jt=function(e){return e==null?!0:!!(e===""||e.match(/^\s+$/))},wl=function(e){return typeof HTMLElement>"u"?!1:e instanceof HTMLElement},xl=function(e){return Ce(e)&&ie(e.x1)&&ie(e.x2)&&ie(e.y1)&&ie(e.y2)},Tl=function(e){return ml(e)&&Ge(e.then)},Cl=function(){return Yi&&Yi.userAgent.match(/msie|trident|edge/i)},ha=function(e,r){r||(r=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return"undefined";for(var i=[],s=0;sr?1:0},Il=function(e,r){return-1*fo(e,r)},be=Object.assign!=null?Object.assign.bind(Object):function(t){for(var e=arguments,r=1;r1&&(g-=1),g<1/6?v+(p-v)*6*g:g<1/2?p:g<2/3?v+(p-v)*(2/3-g)*6:v}var h=new RegExp("^"+Ll+"$").exec(e);if(h){if(a=parseInt(h[1]),a<0?a=(360- -1*a%360)%360:a>360&&(a=a%360),a/=360,n=parseFloat(h[2]),n<0||n>100||(n=n/100,i=parseFloat(h[3]),i<0||i>100)||(i=i/100,s=h[4],s!==void 0&&(s=parseFloat(s),s<0||s>1)))return;if(n===0)o=u=l=Math.round(i*255);else{var d=i<.5?i*(1+n):i+n-i*n,c=2*i-d;o=Math.round(255*f(c,d,a+1/3)),u=Math.round(255*f(c,d,a)),l=Math.round(255*f(c,d,a-1/3))}r=[o,u,l,s]}return r},kl=function(e){var r,a=new RegExp("^"+Dl+"$").exec(e);if(a){r=[];for(var n=[],i=1;i<=3;i++){var s=a[i];if(s[s.length-1]==="%"&&(n[i]=!0),s=parseFloat(s),n[i]&&(s=s/100*255),s<0||s>255)return;r.push(Math.floor(s))}var o=n[1]||n[2]||n[3],u=n[1]&&n[2]&&n[3];if(o&&!u)return;var l=a[4];if(l!==void 0){if(l=parseFloat(l),l<0||l>1)return;r.push(l)}}return r},Pl=function(e){return Fl[e.toLowerCase()]},Bl=function(e){return(Re(e)?e:null)||Pl(e)||Ml(e)||kl(e)||Rl(e)},Fl={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},ho=function(e){for(var r=e.map,a=e.keys,n=a.length,i=0;i=e||E<0||h&&w>=i}function y(){var S=Rn();if(g(S))return b(S);o=setTimeout(y,p(S))}function b(S){return o=void 0,d&&a?c(S):(a=n=void 0,s)}function m(){o!==void 0&&clearTimeout(o),l=0,a=u=n=o=void 0}function T(){return o===void 0?s:b(Rn())}function C(){var S=Rn(),E=g(S);if(a=arguments,n=this,u=S,E){if(o===void 0)return v(u);if(h)return clearTimeout(o),o=setTimeout(y,e),c(u)}return o===void 0&&(o=setTimeout(y,e)),s}return C.cancel=m,C.flush=T,C}var gn=xf,kn=Ye?Ye.performance:null,po=kn&&kn.now?function(){return kn.now()}:function(){return Date.now()},Tf=function(){if(Ye){if(Ye.requestAnimationFrame)return function(t){Ye.requestAnimationFrame(t)};if(Ye.mozRequestAnimationFrame)return function(t){Ye.mozRequestAnimationFrame(t)};if(Ye.webkitRequestAnimationFrame)return function(t){Ye.webkitRequestAnimationFrame(t)};if(Ye.msRequestAnimationFrame)return function(t){Ye.msRequestAnimationFrame(t)}}return function(t){t&&setTimeout(function(){t(po())},1e3/60)}}(),rn=function(e){return Tf(e)},$t=po,Nr=9261,yo=65599,ia=5381,mo=function(e){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Nr,a=r,n;n=e.next(),!n.done;)a=a*yo+n.value|0;return a},ca=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Nr;return r*yo+e|0},va=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ia;return(r<<5)+r+e|0},Cf=function(e,r){return e*2097152+r},qt=function(e){return e[0]*2097152+e[1]},Ma=function(e,r){return[ca(e[0],r[0]),va(e[1],r[1])]},Df=function(e,r){var a={value:0,done:!1},n=0,i=e.length,s={next:function(){return n=0;n--)e[n]===r&&e.splice(n,1)},bi=function(e){e.splice(0,e.length)},Mf=function(e,r){for(var a=0;a"u"?"undefined":Xe(Set))!==kf?Set:Pf,pn=function(e,r){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(e===void 0||r===void 0||!gi(e)){ze("An element must have a core reference and parameters set");return}var n=r.group;if(n==null&&(r.data&&r.data.source!=null&&r.data.target!=null?n="edges":n="nodes"),n!=="nodes"&&n!=="edges"){ze("An element must be of type `nodes` or `edges`; you specified `"+n+"`");return}this.length=1,this[0]=this;var i=this._private={cy:e,single:!0,data:r.data||{},position:r.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:n,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!r.selected,selectable:r.selectable===void 0?!0:!!r.selectable,locked:!!r.locked,grabbed:!1,grabbable:r.grabbable===void 0?!0:!!r.grabbable,pannable:r.pannable===void 0?n==="edges":!!r.pannable,active:!1,classes:new Ur,animation:{current:[],queue:[]},rscratch:{},scratch:r.scratch||{},edges:[],children:[],parent:r.parent&&r.parent.isNode()?r.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(i.position.x==null&&(i.position.x=0),i.position.y==null&&(i.position.y=0),r.renderedPosition){var s=r.renderedPosition,o=e.pan(),u=e.zoom();i.position={x:(s.x-o.x)/u,y:(s.y-o.y)/u}}var l=[];Re(r.classes)?l=r.classes:de(r.classes)&&(l=r.classes.split(/\s+/));for(var f=0,h=l.length;fb?1:0},f=function(y,b,m,T,C){var S;if(m==null&&(m=0),C==null&&(C=a),m<0)throw new Error("lo must be non-negative");for(T==null&&(T=y.length);mD;0<=D?x++:x--)w.push(x);return w}).apply(this).reverse(),E=[],T=0,C=S.length;TL;0<=L?++w:--w)A.push(s(y,m));return A},p=function(y,b,m,T){var C,S,E;for(T==null&&(T=a),C=y[m];m>b;){if(E=m-1>>1,S=y[E],T(C,S)<0){y[m]=S,m=E;continue}break}return y[m]=C},g=function(y,b,m){var T,C,S,E,w;for(m==null&&(m=a),C=y.length,w=b,S=y[b],T=2*b+1;T0;){var S=b.pop(),E=g(S),w=S.id();if(d[w]=E,E!==1/0)for(var x=S.neighborhood().intersect(v),D=0;D0)for(P.unshift(k);h[z];){var G=h[z];P.unshift(G.edge),P.unshift(G.node),B=G.node,z=B.id()}return o.spawn(P)}}}},zf={kruskal:function(e){e=e||function(m){return 1};for(var r=this.byGroup(),a=r.nodes,n=r.edges,i=a.length,s=new Array(i),o=a,u=function(T){for(var C=0;C0;){if(C(),E++,T===f){for(var w=[],x=i,D=f,L=y[D];w.unshift(x),L!=null&&w.unshift(L),x=g[D],x!=null;)D=x.id(),L=y[D];return{found:!0,distance:h[T],path:this.spawn(w),steps:E}}c[T]=!0;for(var A=m._private.edges,N=0;NL&&(v[D]=L,b[D]=x,m[D]=C),!i){var A=x*f+w;!i&&v[A]>L&&(v[A]=L,b[A]=w,m[A]=C)}}}for(var N=0;N1&&arguments[1]!==void 0?arguments[1]:s,Ae=m(fe),xe=[],we=Ae;;){if(we==null)return r.spawn();var De=b(we),ee=De.edge,I=De.pred;if(xe.unshift(we[0]),we.same(pe)&&xe.length>0)break;ee!=null&&xe.unshift(ee),we=I}return u.spawn(xe)},S=0;S=0;f--){var h=l[f],d=h[1],c=h[2];(r[d]===o&&r[c]===u||r[d]===u&&r[c]===o)&&l.splice(f,1)}for(var v=0;vn;){var i=Math.floor(Math.random()*r.length);r=qf(i,e,r),a--}return r},Wf={kargerStein:function(){var e=this,r=this.byGroup(),a=r.nodes,n=r.edges;n.unmergeBy(function(P){return P.isLoop()});var i=a.length,s=n.length,o=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),u=Math.floor(i/Xf);if(i<2){ze("At least 2 nodes are required for Karger-Stein algorithm");return}for(var l=[],f=0;f1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=1/0,i=r;i1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=-1/0,i=r;i1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=0,i=0,s=r;s1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0;n?e=e.slice(r,a):(a0&&e.splice(0,r));for(var o=0,u=e.length-1;u>=0;u--){var l=e[u];s?isFinite(l)||(e[u]=-1/0,o++):e.splice(u,1)}i&&e.sort(function(d,c){return d-c});var f=e.length,h=Math.floor(f/2);return f%2!==0?e[h+1+o]:(e[h-1+o]+e[h+o])/2},eh=function(e){return Math.PI*e/180},Ra=function(e,r){return Math.atan2(r,e)-Math.PI/2},Ei=Math.log2||function(t){return Math.log(t)/Math.log(2)},Do=function(e){return e>0?1:e<0?-1:0},gr=function(e,r){return Math.sqrt(ur(e,r))},ur=function(e,r){var a=r.x-e.x,n=r.y-e.y;return a*a+n*n},th=function(e){for(var r=e.length,a=0,n=0;n=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(e.w!=null&&e.h!=null&&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}}},ah=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},nh=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},ih=function(e,r,a){return{x1:e.x1+r,x2:e.x2+r,y1:e.y1+a,y2:e.y2+a,w:e.w,h:e.h}},So=function(e,r){e.x1=Math.min(e.x1,r.x1),e.x2=Math.max(e.x2,r.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,r.y1),e.y2=Math.max(e.y2,r.y2),e.h=e.y2-e.y1},sh=function(e,r,a){e.x1=Math.min(e.x1,r),e.x2=Math.max(e.x2,r),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,a),e.y2=Math.max(e.y2,a),e.h=e.y2-e.y1},_a=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.x1-=r,e.x2+=r,e.y1-=r,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},Ha=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0],a,n,i,s;if(r.length===1)a=n=i=s=r[0];else if(r.length===2)a=i=r[0],s=n=r[1];else if(r.length===4){var o=St(r,4);a=o[0],n=o[1],i=o[2],s=o[3]}return e.x1-=s,e.x2+=n,e.y1-=a,e.y2+=i,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},Qi=function(e,r){e.x1=r.x1,e.y1=r.y1,e.x2=r.x2,e.y2=r.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},wi=function(e,r){return!(e.x1>r.x2||r.x1>e.x2||e.x2r.y2||r.y1>e.y2)},Gr=function(e,r,a){return e.x1<=r&&r<=e.x2&&e.y1<=a&&a<=e.y2},oh=function(e,r){return Gr(e,r.x,r.y)},Lo=function(e,r){return Gr(e,r.x1,r.y1)&&Gr(e,r.x2,r.y2)},Ao=function(e,r,a,n,i,s,o){var u=arguments.length>7&&arguments[7]!==void 0?arguments[7]:"auto",l=u==="auto"?pr(i,s):u,f=i/2,h=s/2;l=Math.min(l,f,h);var d=l!==f,c=l!==h,v;if(d){var p=a-f+l-o,g=n-h-o,y=a+f-l+o,b=g;if(v=Zt(e,r,a,n,p,g,y,b,!1),v.length>0)return v}if(c){var m=a+f+o,T=n-h+l-o,C=m,S=n+h-l+o;if(v=Zt(e,r,a,n,m,T,C,S,!1),v.length>0)return v}if(d){var E=a-f+l-o,w=n+h+o,x=a+f-l+o,D=w;if(v=Zt(e,r,a,n,E,w,x,D,!1),v.length>0)return v}if(c){var L=a-f-o,A=n-h+l-o,N=L,O=n+h-l+o;if(v=Zt(e,r,a,n,L,A,N,O,!1),v.length>0)return v}var M;{var R=a-f+l,k=n-h+l;if(M=sa(e,r,a,n,R,k,l+o),M.length>0&&M[0]<=R&&M[1]<=k)return[M[0],M[1]]}{var P=a+f-l,B=n-h+l;if(M=sa(e,r,a,n,P,B,l+o),M.length>0&&M[0]>=P&&M[1]<=B)return[M[0],M[1]]}{var z=a+f-l,G=n+h-l;if(M=sa(e,r,a,n,z,G,l+o),M.length>0&&M[0]>=z&&M[1]>=G)return[M[0],M[1]]}{var F=a-f+l,U=n+h-l;if(M=sa(e,r,a,n,F,U,l+o),M.length>0&&M[0]<=F&&M[1]>=U)return[M[0],M[1]]}return[]},uh=function(e,r,a,n,i,s,o){var u=o,l=Math.min(a,i),f=Math.max(a,i),h=Math.min(n,s),d=Math.max(n,s);return l-u<=e&&e<=f+u&&h-u<=r&&r<=d+u},lh=function(e,r,a,n,i,s,o,u,l){var f={x1:Math.min(a,o,i)-l,x2:Math.max(a,o,i)+l,y1:Math.min(n,u,s)-l,y2:Math.max(n,u,s)+l};return!(ef.x2||rf.y2)},fh=function(e,r,a,n){a-=n;var i=r*r-4*e*a;if(i<0)return[];var s=Math.sqrt(i),o=2*e,u=(-r+s)/o,l=(-r-s)/o;return[u,l]},hh=function(e,r,a,n,i){var s=1e-5;e===0&&(e=s),r/=e,a/=e,n/=e;var o,u,l,f,h,d,c,v;if(u=(3*a-r*r)/9,l=-(27*n)+r*(9*a-2*(r*r)),l/=54,o=u*u*u+l*l,i[1]=0,c=r/3,o>0){h=l+Math.sqrt(o),h=h<0?-Math.pow(-h,1/3):Math.pow(h,1/3),d=l-Math.sqrt(o),d=d<0?-Math.pow(-d,1/3):Math.pow(d,1/3),i[0]=-c+h+d,c+=(h+d)/2,i[4]=i[2]=-c,c=Math.sqrt(3)*(-d+h)/2,i[3]=c,i[5]=-c;return}if(i[5]=i[3]=0,o===0){v=l<0?-Math.pow(-l,1/3):Math.pow(l,1/3),i[0]=-c+2*v,i[4]=i[2]=-(v+c);return}u=-u,f=u*u*u,f=Math.acos(l/Math.sqrt(f)),v=2*Math.sqrt(u),i[0]=-c+v*Math.cos(f/3),i[2]=-c+v*Math.cos((f+2*Math.PI)/3),i[4]=-c+v*Math.cos((f+4*Math.PI)/3)},ch=function(e,r,a,n,i,s,o,u){var l=1*a*a-4*a*i+2*a*o+4*i*i-4*i*o+o*o+n*n-4*n*s+2*n*u+4*s*s-4*s*u+u*u,f=1*9*a*i-3*a*a-3*a*o-6*i*i+3*i*o+9*n*s-3*n*n-3*n*u-6*s*s+3*s*u,h=1*3*a*a-6*a*i+a*o-a*e+2*i*i+2*i*e-o*e+3*n*n-6*n*s+n*u-n*r+2*s*s+2*s*r-u*r,d=1*a*i-a*a+a*e-i*e+n*s-n*n+n*r-s*r,c=[];hh(l,f,h,d,c);for(var v=1e-7,p=[],g=0;g<6;g+=2)Math.abs(c[g+1])=0&&c[g]<=1&&p.push(c[g]);p.push(1),p.push(0);for(var y=-1,b,m,T,C=0;C=0?Tl?(e-i)*(e-i)+(r-s)*(r-s):f-d},dt=function(e,r,a){for(var n,i,s,o,u,l=0,f=0;f=e&&e>=s||n<=e&&e<=s)u=(e-n)/(s-n)*(o-i)+i,u>r&&l++;else continue;return l%2!==0},Yt=function(e,r,a,n,i,s,o,u,l){var f=new Array(a.length),h;u[0]!=null?(h=Math.atan(u[1]/u[0]),u[0]<0?h=h+Math.PI/2:h=-h-Math.PI/2):h=u;for(var d=Math.cos(-h),c=Math.sin(-h),v=0;v0){var g=sn(f,-l);p=nn(g)}else p=f;return dt(e,r,p)},dh=function(e,r,a,n,i,s,o,u){for(var l=new Array(a.length*2),f=0;f=0&&g<=1&&b.push(g),y>=0&&y<=1&&b.push(y),b.length===0)return[];var m=b[0]*u[0]+e,T=b[0]*u[1]+r;if(b.length>1){if(b[0]==b[1])return[m,T];var C=b[1]*u[0]+e,S=b[1]*u[1]+r;return[m,T,C,S]}else return[m,T]},Bn=function(e,r,a){return r<=e&&e<=a||a<=e&&e<=r?e:e<=r&&r<=a||a<=r&&r<=e?r:a},Zt=function(e,r,a,n,i,s,o,u,l){var f=e-i,h=a-e,d=o-i,c=r-s,v=n-r,p=u-s,g=d*c-p*f,y=h*c-v*f,b=p*h-d*v;if(b!==0){var m=g/b,T=y/b,C=.001,S=0-C,E=1+C;return S<=m&&m<=E&&S<=T&&T<=E?[e+m*h,r+m*v]:l?[e+m*h,r+m*v]:[]}else return g===0||y===0?Bn(e,a,o)===o?[o,u]:Bn(e,a,i)===i?[i,s]:Bn(i,o,a)===a?[a,n]:[]:[]},pa=function(e,r,a,n,i,s,o,u){var l=[],f,h=new Array(a.length),d=!0;s==null&&(d=!1);var c;if(d){for(var v=0;v0){var p=sn(h,-u);c=nn(p)}else c=h}else c=a;for(var g,y,b,m,T=0;T2){for(var v=[f[0],f[1]],p=Math.pow(v[0]-e,2)+Math.pow(v[1]-r,2),g=1;gf&&(f=T)},get:function(m){return l[m]}},d=0;d0?R=M.edgesTo(O)[0]:R=O.edgesTo(M)[0];var k=n(R);O=O.id(),w[O]>w[A]+k&&(w[O]=w[A]+k,x.nodes.indexOf(O)<0?x.push(O):x.updateItem(O),E[O]=0,S[O]=[]),w[O]==w[A]+k&&(E[O]=E[O]+E[A],S[O].push(A))}else for(var P=0;P0;){for(var F=C.pop(),U=0;U0&&o.push(a[u]);o.length!==0&&i.push(n.collection(o))}return i},Nh=function(e,r){for(var a=0;a5&&arguments[5]!==void 0?arguments[5]:Rh,o=n,u,l,f=0;f=2?ea(e,r,a,0,rs,kh):ea(e,r,a,0,ts)},squaredEuclidean:function(e,r,a){return ea(e,r,a,0,rs)},manhattan:function(e,r,a){return ea(e,r,a,0,ts)},max:function(e,r,a){return ea(e,r,a,-1/0,Ph)}};zr["squared-euclidean"]=zr.squaredEuclidean;zr.squaredeuclidean=zr.squaredEuclidean;function mn(t,e,r,a,n,i){var s;return Ge(t)?s=t:s=zr[t]||zr.euclidean,e===0&&Ge(t)?s(n,i):s(e,r,a,n,i)}var Bh=tt({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),Ti=function(e){return Bh(e)},on=function(e,r,a,n,i){var s=i!=="kMedoids",o=s?function(h){return a[h]}:function(h){return n[h](a)},u=function(d){return n[d](r)},l=a,f=r;return mn(e,n.length,o,u,l,f)},Fn=function(e,r,a){for(var n=a.length,i=new Array(n),s=new Array(n),o=new Array(r),u=null,l=0;la)return!1}return!0},zh=function(e,r,a){for(var n=0;no&&(o=r[l][f],u=f);i[u].push(e[l])}for(var h=0;h=i.threshold||i.mode==="dendrogram"&&e.length===1)return!1;var v=r[s],p=r[n[s]],g;i.mode==="dendrogram"?g={left:v,right:p,key:v.key}:g={value:v.value.concat(p.value),key:v.key},e[v.index]=g,e.splice(p.index,1),r[v.key]=g;for(var y=0;ya[p.key][b.key]&&(u=a[p.key][b.key])):i.linkage==="max"?(u=a[v.key][b.key],a[v.key][b.key]0&&n.push(i);return n},us=function(e,r,a){for(var n=[],i=0;io&&(s=l,o=r[i*e+l])}s>0&&n.push(s)}for(var f=0;fl&&(u=f,l=h)}a[i]=s[u]}return n=us(e,r,a),n},ls=function(e){for(var r=this.cy(),a=this.nodes(),n=jh(e),i={},s=0;s=L?(A=L,L=O,N=M):O>A&&(A=O);for(var R=0;R0?1:0;E[x%n.minIterations*o+F]=U,G+=U}if(G>0&&(x>=n.minIterations-1||x==n.maxIterations-1)){for(var Y=0,W=0;W1||S>1)&&(o=!0),h[m]=[],b.outgoers().forEach(function(w){w.isEdge()&&h[m].push(w.id())})}else d[m]=[void 0,b.target().id()]}):s.forEach(function(b){var m=b.id();if(b.isNode()){var T=b.degree(!0);T%2&&(u?l?o=!0:l=m:u=m),h[m]=[],b.connectedEdges().forEach(function(C){return h[m].push(C.id())})}else d[m]=[b.source().id(),b.target().id()]});var c={found:!1,trail:void 0};if(o)return c;if(l&&u)if(i){if(f&&l!=f)return c;f=l}else{if(f&&l!=f&&u!=f)return c;f||(f=l)}else f||(f=s[0].id());var v=function(m){for(var T=m,C=[m],S,E,w;h[T].length;)S=h[T].shift(),E=d[S][0],w=d[S][1],T!=w?(h[w]=h[w].filter(function(x){return x!=S}),T=w):!i&&T!=E&&(h[E]=h[E].filter(function(x){return x!=S}),T=E),C.unshift(S),C.unshift(T);return C},p=[],g=[];for(g=v(f);g.length!=1;)h[g[0]].length==0?(p.unshift(s.getElementById(g.shift())),p.unshift(s.getElementById(g.shift()))):g=v(g.shift()).concat(g);p.unshift(s.getElementById(g.shift()));for(var y in h)if(h[y].length)return c;return c.found=!0,c.trail=this.spawn(p,!0),c}},Ba=function(){var e=this,r={},a=0,n=0,i=[],s=[],o={},u=function(d,c){for(var v=s.length-1,p=[],g=e.spawn();s[v].x!=d||s[v].y!=c;)p.push(s.pop().edge),v--;p.push(s.pop().edge),p.forEach(function(y){var b=y.connectedNodes().intersection(e);g.merge(y),b.forEach(function(m){var T=m.id(),C=m.connectedEdges().intersection(e);g.merge(m),r[T].cutVertex?g.merge(C.filter(function(S){return S.isLoop()})):g.merge(C)})}),i.push(g)},l=function h(d,c,v){d===v&&(n+=1),r[c]={id:a,low:a++,cutVertex:!1};var p=e.getElementById(c).connectedEdges().intersection(e);if(p.size()===0)i.push(e.spawn(e.getElementById(c)));else{var g,y,b,m;p.forEach(function(T){g=T.source().id(),y=T.target().id(),b=g===c?y:g,b!==v&&(m=T.id(),o[m]||(o[m]=!0,s.push({x:c,y:b,edge:T})),b in r?r[c].low=Math.min(r[c].low,r[b].id):(h(d,b,c),r[c].low=Math.min(r[c].low,r[b].low),r[c].id<=r[b].low&&(r[c].cutVertex=!0,u(c,b))))})}};e.forEach(function(h){if(h.isNode()){var d=h.id();d in r||(n=0,l(d,d),r[d].cutVertex=n>1)}});var f=Object.keys(r).filter(function(h){return r[h].cutVertex}).map(function(h){return e.getElementById(h)});return{cut:e.spawn(f),components:i}},oc={hopcroftTarjanBiconnected:Ba,htbc:Ba,htb:Ba,hopcroftTarjanBiconnectedComponents:Ba},Fa=function(){var e=this,r={},a=0,n=[],i=[],s=e.spawn(e),o=function u(l){i.push(l),r[l]={index:a,low:a++,explored:!1};var f=e.getElementById(l).connectedEdges().intersection(e);if(f.forEach(function(p){var g=p.target().id();g!==l&&(g in r||u(g),r[g].explored||(r[l].low=Math.min(r[l].low,r[g].low)))}),r[l].index===r[l].low){for(var h=e.spawn();;){var d=i.pop();if(h.merge(e.getElementById(d)),r[d].low=r[l].index,r[d].explored=!0,d===l)break}var c=h.edgesWith(h),v=h.merge(c);n.push(v),s=s.difference(v)}};return e.forEach(function(u){if(u.isNode()){var l=u.id();l in r||o(l)}}),{cut:s,components:n}},uc={tarjanStronglyConnected:Fa,tsc:Fa,tscc:Fa,tarjanStronglyConnectedComponents:Fa},Po={};[da,Gf,zf,Uf,Yf,Hf,Wf,bh,kr,Pr,Zn,Mh,Hh,Qh,nc,sc,oc,uc].forEach(function(t){be(Po,t)});/*! 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 Bo=0,Fo=1,Go=2,_t=function t(e){if(!(this instanceof t))return new t(e);this.id="Thenable/1.0.7",this.state=Bo,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},typeof e=="function"&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};_t.prototype={fulfill:function(e){return fs(this,Fo,"fulfillValue",e)},reject:function(e){return fs(this,Go,"rejectReason",e)},then:function(e,r){var a=this,n=new _t;return a.onFulfilled.push(cs(e,n,"fulfill")),a.onRejected.push(cs(r,n,"reject")),zo(a),n.proxy}};var fs=function(e,r,a,n){return e.state===Bo&&(e.state=r,e[a]=n,zo(e)),e},zo=function(e){e.state===Fo?hs(e,"onFulfilled",e.fulfillValue):e.state===Go&&hs(e,"onRejected",e.rejectReason)},hs=function(e,r,a){if(e[r].length!==0){var n=e[r];e[r]=[];var i=function(){for(var o=0;o0}},clearQueue:function(){return function(){var r=this,a=r.length!==void 0,n=a?r:[r],i=this._private.cy||this;if(!i.styleEnabled())return this;for(var s=0;s-1}var gv=dv;function pv(t,e){var r=this.__data__,a=En(r,t);return a<0?(++this.size,r.push([t,e])):r[a][1]=e,this}var yv=pv;function _r(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t0&&this.spawn(n).updateStyle().emit("class"),r},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var r=this[0];return r!=null&&r._private.classes.has(e)},toggleClass:function(e,r){Re(e)||(e=e.match(/\S+/g)||[]);for(var a=this,n=r===void 0,i=[],s=0,o=a.length;s0&&this.spawn(i).updateStyle().emit("class"),a},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,r){var a=this;if(r==null)r=250;else if(r===0)return a;return a.addClass(e),setTimeout(function(){a.removeClass(e)},r),a}};Xa.className=Xa.classNames=Xa.classes;var Te={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:`"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,number:He,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};Te.variable="(?:[\\w-.]|(?:\\\\"+Te.metaChar+"))+";Te.className="(?:[\\w-]|(?:\\\\"+Te.metaChar+"))+";Te.value=Te.string+"|"+Te.number;Te.id=Te.variable;(function(){var t,e,r;for(t=Te.comparatorOp.split("|"),r=0;r=0)&&e!=="="&&(Te.comparatorOp+="|\\!"+e)})();var Ie=function(){return{checks:[]}},oe={GROUP:0,COLLECTION:1,FILTER:2,DATA_COMPARE:3,DATA_EXIST:4,DATA_BOOL:5,META_COMPARE:6,STATE:7,ID:8,CLASS:9,UNDIRECTED_EDGE:10,DIRECTED_EDGE:11,NODE_SOURCE:12,NODE_TARGET:13,NODE_NEIGHBOR:14,CHILD:15,DESCENDANT:16,PARENT:17,ANCESTOR:18,COMPOUND_SPLIT:19,TRUE:20},Jn=[{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(t,e){return Il(t.selector,e.selector)}),wd=function(){for(var t={},e,r=0;r0&&f.edgeCount>0)return Ne("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(f.edgeCount>1)return Ne("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;f.edgeCount===1&&Ne("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},Ld=function(){if(this.toStringCache!=null)return this.toStringCache;for(var e=function(f){return f??""},r=function(f){return de(f)?'"'+f+'"':e(f)},a=function(f){return" "+f+" "},n=function(f,h){var d=f.type,c=f.value;switch(d){case oe.GROUP:{var v=e(c);return v.substring(0,v.length-1)}case oe.DATA_COMPARE:{var p=f.field,g=f.operator;return"["+p+a(e(g))+r(c)+"]"}case oe.DATA_BOOL:{var y=f.operator,b=f.field;return"["+e(y)+b+"]"}case oe.DATA_EXIST:{var m=f.field;return"["+m+"]"}case oe.META_COMPARE:{var T=f.operator,C=f.field;return"[["+C+a(e(T))+r(c)+"]]"}case oe.STATE:return c;case oe.ID:return"#"+c;case oe.CLASS:return"."+c;case oe.PARENT:case oe.CHILD:return i(f.parent,h)+a(">")+i(f.child,h);case oe.ANCESTOR:case oe.DESCENDANT:return i(f.ancestor,h)+" "+i(f.descendant,h);case oe.COMPOUND_SPLIT:{var S=i(f.left,h),E=i(f.subject,h),w=i(f.right,h);return S+(S.length>0?" ":"")+E+w}case oe.TRUE:return""}},i=function(f,h){return f.checks.reduce(function(d,c,v){return d+(h===f&&v===0?"$":"")+n(c,h)},"")},s="",o=0;o1&&o=0&&(r=r.replace("!",""),h=!0),r.indexOf("@")>=0&&(r=r.replace("@",""),f=!0),(i||o||f)&&(u=!i&&!s?"":""+e,l=""+a),f&&(e=u=u.toLowerCase(),a=l=l.toLowerCase()),r){case"*=":n=u.indexOf(l)>=0;break;case"$=":n=u.indexOf(l,u.length-l.length)>=0;break;case"^=":n=u.indexOf(l)===0;break;case"=":n=e===a;break;case">":d=!0,n=e>a;break;case">=":d=!0,n=e>=a;break;case"<":d=!0,n=e0;){var f=n.shift();e(f),i.add(f.id()),o&&a(n,i,f)}return t}function Wo(t,e,r){if(r.isParent())for(var a=r._private.children,n=0;n1&&arguments[1]!==void 0?arguments[1]:!0;return Ai(this,t,e,Wo)};function Ko(t,e,r){if(r.isChild()){var a=r._private.parent;e.has(a.id())||t.push(a)}}Vr.forEachUp=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return Ai(this,t,e,Ko)};function Pd(t,e,r){Ko(t,e,r),Wo(t,e,r)}Vr.forEachUpAndDown=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return Ai(this,t,e,Pd)};Vr.ancestors=Vr.parents;var ma,Zo;ma=Zo={data:Oe.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:Oe.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Oe.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Oe.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Oe.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Oe.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}};ma.attr=ma.data;ma.removeAttr=ma.removeData;var Bd=Zo,xn={};function zn(t){return function(e){var r=this;if(e===void 0&&(e=!0),r.length!==0)if(r.isNode()&&!r.removed()){for(var a=0,n=r[0],i=n._private.edges,s=0;se}),minIndegree:Dr("indegree",function(t,e){return te}),minOutdegree:Dr("outdegree",function(t,e){return te})});be(xn,{totalDegree:function(e){for(var r=0,a=this.nodes(),n=0;n0,d=h;h&&(f=f[0]);var c=d?f.position():{x:0,y:0};r!==void 0?l.position(e,r+c[e]):i!==void 0&&l.position({x:i.x+c.x,y:i.y+c.y})}else{var v=a.position(),p=o?a.parent():null,g=p&&p.length>0,y=g;g&&(p=p[0]);var b=y?p.position():{x:0,y:0};return i={x:v.x-b.x,y:v.y-b.y},e===void 0?i:i[e]}else if(!s)return;return this}};Ot.modelPosition=Ot.point=Ot.position;Ot.modelPositions=Ot.points=Ot.positions;Ot.renderedPoint=Ot.renderedPosition;Ot.relativePoint=Ot.relativePosition;var Fd=Qo,Br,ir;Br=ir={};ir.renderedBoundingBox=function(t){var e=this.boundingBox(t),r=this.cy(),a=r.zoom(),n=r.pan(),i=e.x1*a+n.x,s=e.x2*a+n.x,o=e.y1*a+n.y,u=e.y2*a+n.y;return{x1:i,x2:s,y1:o,y2:u,w:s-i,h:u-o}};ir.dirtyCompoundBoundsCache=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();return!e.styleEnabled()||!e.hasCompoundNodes()?this:(this.forEachUp(function(r){if(r.isParent()){var a=r._private;a.compoundBoundsClean=!1,a.bbCache=null,t||r.emitAndNotify("bounds")}}),this)};ir.updateCompoundBounds=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();if(!e.styleEnabled()||!e.hasCompoundNodes())return this;if(!t&&e.batching())return this;function r(s){if(!s.isParent())return;var o=s._private,u=s.children(),l=s.pstyle("compound-sizing-wrt-labels").value==="include",f={width:{val:s.pstyle("min-width").pfValue,left:s.pstyle("min-width-bias-left"),right:s.pstyle("min-width-bias-right")},height:{val:s.pstyle("min-height").pfValue,top:s.pstyle("min-height-bias-top"),bottom:s.pstyle("min-height-bias-bottom")}},h=u.boundingBox({includeLabels:l,includeOverlays:!1,useCache:!1}),d=o.position;(h.w===0||h.h===0)&&(h={w:s.pstyle("width").pfValue,h:s.pstyle("height").pfValue},h.x1=d.x-h.w/2,h.x2=d.x+h.w/2,h.y1=d.y-h.h/2,h.y2=d.y+h.h/2);function c(x,D,L){var A=0,N=0,O=D+L;return x>0&&O>0&&(A=D/O*x,N=L/O*x),{biasDiff:A,biasComplementDiff:N}}function v(x,D,L,A){if(L.units==="%")switch(A){case"width":return x>0?L.pfValue*x:0;case"height":return D>0?L.pfValue*D:0;case"average":return x>0&&D>0?L.pfValue*(x+D)/2:0;case"min":return x>0&&D>0?x>D?L.pfValue*D:L.pfValue*x:0;case"max":return x>0&&D>0?x>D?L.pfValue*x:L.pfValue*D:0;default:return 0}else return L.units==="px"?L.pfValue:0}var p=f.width.left.value;f.width.left.units==="px"&&f.width.val>0&&(p=p*100/f.width.val);var g=f.width.right.value;f.width.right.units==="px"&&f.width.val>0&&(g=g*100/f.width.val);var y=f.height.top.value;f.height.top.units==="px"&&f.height.val>0&&(y=y*100/f.height.val);var b=f.height.bottom.value;f.height.bottom.units==="px"&&f.height.val>0&&(b=b*100/f.height.val);var m=c(f.width.val-h.w,p,g),T=m.biasDiff,C=m.biasComplementDiff,S=c(f.height.val-h.h,y,b),E=S.biasDiff,w=S.biasComplementDiff;o.autoPadding=v(h.w,h.h,s.pstyle("padding"),s.pstyle("padding-relative-to").value),o.autoWidth=Math.max(h.w,f.width.val),d.x=(-T+h.x1+h.x2+C)/2,o.autoHeight=Math.max(h.h,f.height.val),d.y=(-E+h.y1+h.y2+w)/2}for(var a=0;ae.x2?n:e.x2,e.y1=ae.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},lr=function(e,r){return r==null?e:Lt(e,r.x1,r.y1,r.x2,r.y2)},ta=function(e,r,a){return At(e,r,a)},Ga=function(e,r,a){if(!r.cy().headless()){var n=r._private,i=n.rstyle,s=i.arrowWidth/2,o=r.pstyle(a+"-arrow-shape").value,u,l;if(o!=="none"){a==="source"?(u=i.srcX,l=i.srcY):a==="target"?(u=i.tgtX,l=i.tgtY):(u=i.midX,l=i.midY);var f=n.arrowBounds=n.arrowBounds||{},h=f[a]=f[a]||{};h.x1=u-s,h.y1=l-s,h.x2=u+s,h.y2=l+s,h.w=h.x2-h.x1,h.h=h.y2-h.y1,_a(h,1),Lt(e,h.x1,h.y1,h.x2,h.y2)}}},Vn=function(e,r,a){if(!r.cy().headless()){var n;a?n=a+"-":n="";var i=r._private,s=i.rstyle,o=r.pstyle(n+"label").strValue;if(o){var u=r.pstyle("text-halign"),l=r.pstyle("text-valign"),f=ta(s,"labelWidth",a),h=ta(s,"labelHeight",a),d=ta(s,"labelX",a),c=ta(s,"labelY",a),v=r.pstyle(n+"text-margin-x").pfValue,p=r.pstyle(n+"text-margin-y").pfValue,g=r.isEdge(),y=r.pstyle(n+"text-rotation"),b=r.pstyle("text-outline-width").pfValue,m=r.pstyle("text-border-width").pfValue,T=m/2,C=r.pstyle("text-background-padding").pfValue,S=2,E=h,w=f,x=w/2,D=E/2,L,A,N,O;if(g)L=d-x,A=d+x,N=c-D,O=c+D;else{switch(u.value){case"left":L=d-w,A=d;break;case"center":L=d-x,A=d+x;break;case"right":L=d,A=d+w;break}switch(l.value){case"top":N=c-E,O=c;break;case"center":N=c-D,O=c+D;break;case"bottom":N=c,O=c+E;break}}L+=v-Math.max(b,T)-C-S,A+=v+Math.max(b,T)+C+S,N+=p-Math.max(b,T)-C-S,O+=p+Math.max(b,T)+C+S;var M=a||"main",R=i.labelBounds,k=R[M]=R[M]||{};k.x1=L,k.y1=N,k.x2=A,k.y2=O,k.w=A-L,k.h=O-N;var P=g&&y.strValue==="autorotate",B=y.pfValue!=null&&y.pfValue!==0;if(P||B){var z=P?ta(i.rstyle,"labelAngle",a):y.pfValue,G=Math.cos(z),F=Math.sin(z),U=(L+A)/2,Y=(N+O)/2;if(!g){switch(u.value){case"left":U=A;break;case"right":U=L;break}switch(l.value){case"top":Y=O;break;case"bottom":Y=N;break}}var W=function(ce,te){return ce=ce-U,te=te-Y,{x:ce*G-te*F+U,y:ce*F+te*G+Y}},K=W(L,N),j=W(L,O),_=W(A,N),V=W(A,O);L=Math.min(K.x,j.x,_.x,V.x),A=Math.max(K.x,j.x,_.x,V.x),N=Math.min(K.y,j.y,_.y,V.y),O=Math.max(K.y,j.y,_.y,V.y)}var H=M+"Rot",Q=R[H]=R[H]||{};Q.x1=L,Q.y1=N,Q.x2=A,Q.y2=O,Q.w=A-L,Q.h=O-N,Lt(e,L,N,A,O),Lt(i.labelBounds.all,L,N,A,O)}return e}},Gd=function(e,r){if(!r.cy().headless()){var a=r.pstyle("outline-opacity").value,n=r.pstyle("outline-width").value;if(a>0&&n>0){var i=r.pstyle("outline-offset").value,s=r.pstyle("shape").value,o=n+i,u=(e.w+o*2)/e.w,l=(e.h+o*2)/e.h,f=0,h=0;["diamond","pentagon","round-triangle"].includes(s)?(u=(e.w+o*2.4)/e.w,h=-o/3.6):["concave-hexagon","rhomboid","right-rhomboid"].includes(s)?u=(e.w+o*2.4)/e.w:s==="star"?(u=(e.w+o*2.8)/e.w,l=(e.h+o*2.6)/e.h,h=-o/3.8):s==="triangle"?(u=(e.w+o*2.8)/e.w,l=(e.h+o*2.4)/e.h,h=-o/1.4):s==="vee"&&(u=(e.w+o*4.4)/e.w,l=(e.h+o*3.8)/e.h,h=-o*.5);var d=e.h*l-e.h,c=e.w*u-e.w;if(Ha(e,[Math.ceil(d/2),Math.ceil(c/2)]),f!=0||h!==0){var v=ih(e,f,h);So(e,v)}}}},zd=function(e,r){var a=e._private.cy,n=a.styleEnabled(),i=a.headless(),s=gt(),o=e._private,u=e.isNode(),l=e.isEdge(),f,h,d,c,v,p,g=o.rstyle,y=u&&n?e.pstyle("bounds-expansion").pfValue:[0],b=function(ue){return ue.pstyle("display").value!=="none"},m=!n||b(e)&&(!l||b(e.source())&&b(e.target()));if(m){var T=0,C=0;n&&r.includeOverlays&&(T=e.pstyle("overlay-opacity").value,T!==0&&(C=e.pstyle("overlay-padding").value));var S=0,E=0;n&&r.includeUnderlays&&(S=e.pstyle("underlay-opacity").value,S!==0&&(E=e.pstyle("underlay-padding").value));var w=Math.max(C,E),x=0,D=0;if(n&&(x=e.pstyle("width").pfValue,D=x/2),u&&r.includeNodes){var L=e.position();v=L.x,p=L.y;var A=e.outerWidth(),N=A/2,O=e.outerHeight(),M=O/2;f=v-N,h=v+N,d=p-M,c=p+M,Lt(s,f,d,h,c),n&&r.includeOutlines&&Gd(s,e)}else if(l&&r.includeEdges)if(n&&!i){var R=e.pstyle("curve-style").strValue;if(f=Math.min(g.srcX,g.midX,g.tgtX),h=Math.max(g.srcX,g.midX,g.tgtX),d=Math.min(g.srcY,g.midY,g.tgtY),c=Math.max(g.srcY,g.midY,g.tgtY),f-=D,h+=D,d-=D,c+=D,Lt(s,f,d,h,c),R==="haystack"){var k=g.haystackPts;if(k&&k.length===2){if(f=k[0].x,d=k[0].y,h=k[1].x,c=k[1].y,f>h){var P=f;f=h,h=P}if(d>c){var B=d;d=c,c=B}Lt(s,f-D,d-D,h+D,c+D)}}else if(R==="bezier"||R==="unbundled-bezier"||R.endsWith("segments")||R.endsWith("taxi")){var z;switch(R){case"bezier":case"unbundled-bezier":z=g.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":z=g.linePts;break}if(z!=null)for(var G=0;Gh){var j=f;f=h,h=j}if(d>c){var _=d;d=c,c=_}f-=D,h+=D,d-=D,c+=D,Lt(s,f,d,h,c)}if(n&&r.includeEdges&&l&&(Ga(s,e,"mid-source"),Ga(s,e,"mid-target"),Ga(s,e,"source"),Ga(s,e,"target")),n){var V=e.pstyle("ghost").value==="yes";if(V){var H=e.pstyle("ghost-offset-x").pfValue,Q=e.pstyle("ghost-offset-y").pfValue;Lt(s,s.x1+H,s.y1+Q,s.x2+H,s.y2+Q)}}var ne=o.bodyBounds=o.bodyBounds||{};Qi(ne,s),Ha(ne,y),_a(ne,1),n&&(f=s.x1,h=s.x2,d=s.y1,c=s.y2,Lt(s,f-w,d-w,h+w,c+w));var ce=o.overlayBounds=o.overlayBounds||{};Qi(ce,s),Ha(ce,y),_a(ce,1);var te=o.labelBounds=o.labelBounds||{};te.all!=null?nh(te.all):te.all=gt(),n&&r.includeLabels&&(r.includeMainLabels&&Vn(s,e,null),l&&(r.includeSourceLabels&&Vn(s,e,"source"),r.includeTargetLabels&&Vn(s,e,"target")))}return s.x1=Et(s.x1),s.y1=Et(s.y1),s.x2=Et(s.x2),s.y2=Et(s.y2),s.w=Et(s.x2-s.x1),s.h=Et(s.y2-s.y1),s.w>0&&s.h>0&&m&&(Ha(s,y),_a(s,1)),s},jo=function(e){var r=0,a=function(s){return(s?1:0)<0&&arguments[0]!==void 0?arguments[0]:eg,e=arguments.length>1?arguments[1]:void 0,r=0;r=0;o--)s(o);return this};ar.removeAllListeners=function(){return this.removeListener("*")};ar.emit=ar.trigger=function(t,e,r){var a=this.listeners,n=a.length;return this.emitting++,Re(e)||(e=[e]),tg(this,function(i,s){r!=null&&(a=[{event:s.event,type:s.type,namespace:s.namespace,callback:r}],n=a.length);for(var o=function(f){var h=a[f];if(h.type===s.type&&(!h.namespace||h.namespace===s.namespace||h.namespace===jd)&&i.eventMatches(i.context,h,s)){var d=[s];e!=null&&Mf(d,e),i.beforeEmit(i.context,h,s),h.conf&&h.conf.one&&(i.listeners=i.listeners.filter(function(p){return p!==h}));var c=i.callbackContext(i.context,h,s),v=h.callback.apply(c,d);i.afterEmit(i.context,h,s),v===!1&&(s.stopPropagation(),s.preventDefault())}},u=0;u1&&!s){var o=this.length-1,u=this[o],l=u._private.data.id;this[o]=void 0,this[e]=u,i.set(l,{ele:u,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var r=this._private,a=e._private.data.id,n=r.map,i=n.get(a);if(!i)return this;var s=i.index;return this.unmergeAt(s),this},unmerge:function(e){var r=this._private.cy;if(!e)return this;if(e&&de(e)){var a=e;e=r.mutableElements().filter(a)}for(var n=0;n=0;r--){var a=this[r];e(a)&&this.unmergeAt(r)}return this},map:function(e,r){for(var a=[],n=this,i=0;ia&&(a=u,n=o)}return{value:a,ele:n}},min:function(e,r){for(var a=1/0,n,i=this,s=0;s=0&&i"u"?"undefined":Xe(Symbol))!=e&&Xe(Symbol.iterator)!=e;r&&(un[Symbol.iterator]=function(){var a=this,n={value:void 0,done:!1},i=0,s=this.length;return ao({next:function(){return i1&&arguments[1]!==void 0?arguments[1]:!0,a=this[0],n=a.cy();if(n.styleEnabled()&&a){this.cleanStyle();var i=a._private.style[e];return i??(r?n.style().getDefaultProperty(e):null)}},numericStyle:function(e){var r=this[0];if(r.cy().styleEnabled()&&r){var a=r.pstyle(e);return a.pfValue!==void 0?a.pfValue:a.value}},numericStyleUnits:function(e){var r=this[0];if(r.cy().styleEnabled()&&r)return r.pstyle(e).units},renderedStyle:function(e){var r=this.cy();if(!r.styleEnabled())return this;var a=this[0];if(a)return r.style().getRenderedStyle(a,e)},style:function(e,r){var a=this.cy();if(!a.styleEnabled())return this;var n=!1,i=a.style();if(Ce(e)){var s=e;i.applyBypass(this,s,n),this.emitAndNotify("style")}else if(de(e))if(r===void 0){var o=this[0];return o?i.getStylePropertyValue(o,e):void 0}else i.applyBypass(this,e,r,n),this.emitAndNotify("style");else if(e===void 0){var u=this[0];return u?i.getRawStyle(u):void 0}return this},removeStyle:function(e){var r=this.cy();if(!r.styleEnabled())return this;var a=!1,n=r.style(),i=this;if(e===void 0)for(var s=0;s0&&e.push(f[0]),e.push(o[0])}return this.spawn(e,!0).filter(t)},"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}});it.neighbourhood=it.neighborhood;it.closedNeighbourhood=it.closedNeighborhood;it.openNeighbourhood=it.openNeighborhood;be(it,{source:wt(function(e){var r=this[0],a;return r&&(a=r._private.source||r.cy().collection()),a&&e?a.filter(e):a},"source"),target:wt(function(e){var r=this[0],a;return r&&(a=r._private.target||r.cy().collection()),a&&e?a.filter(e):a},"target"),sources:Os({attr:"source"}),targets:Os({attr:"target"})});function Os(t){return function(r){for(var a=[],n=0;n0);return s},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}});it.componentsOf=it.components;var et=function(e,r){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(e===void 0){ze("A collection must have a reference to the core");return}var i=new Bt,s=!1;if(!r)r=[];else if(r.length>0&&Ce(r[0])&&!Ta(r[0])){s=!0;for(var o=[],u=new Ur,l=0,f=r.length;l0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=this,a=r.cy(),n=a._private,i=[],s=[],o,u=0,l=r.length;u0){for(var B=o.length===r.length?r:new et(a,o),z=0;z0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=this,a=[],n={},i=r._private.cy;function s(O){for(var M=O._private.edges,R=0;R0&&(t?L.emitAndNotify("remove"):e&&L.emit("remove"));for(var A=0;A0?A=O:L=O;while(Math.abs(N)>s&&++M=i?b(D,M):R===0?M:T(D,L,L+l)}var S=!1;function E(){S=!0,(t!==e||r!==a)&&m()}var w=function(L){return S||E(),t===e&&r===a?L:L===0?0:L===1?1:g(C(L),e,a)};w.getControlPoints=function(){return[{x:t,y:e},{x:r,y:a}]};var x="generateBezier("+[t,e,r,a]+")";return w.toString=function(){return x},w}/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var cg=function(){function t(a){return-a.tension*a.x-a.friction*a.v}function e(a,n,i){var s={x:a.x+i.dx*n,v:a.v+i.dv*n,tension:a.tension,friction:a.friction};return{dx:s.v,dv:t(s)}}function r(a,n){var i={dx:a.v,dv:t(a)},s=e(a,n*.5,i),o=e(a,n*.5,s),u=e(a,n,o),l=1/6*(i.dx+2*(s.dx+o.dx)+u.dx),f=1/6*(i.dv+2*(s.dv+o.dv)+u.dv);return a.x=a.x+l*n,a.v=a.v+f*n,a}return function a(n,i,s){var o={x:-1,v:0,tension:null,friction:null},u=[0],l=0,f=1/1e4,h=16/1e3,d,c,v;for(n=parseFloat(n)||500,i=parseFloat(i)||20,s=s||null,o.tension=n,o.friction=i,d=s!==null,d?(l=a(n,i),c=l/s*h):c=h;v=r(v||o,c),u.push(1+v.x),l+=16,Math.abs(v.x)>f&&Math.abs(v.v)>f;);return d?function(p){return u[p*(u.length-1)|0]}:l}}(),ke=function(e,r,a,n){var i=hg(e,r,a,n);return function(s,o,u){return s+(o-s)*i(u)}},Wa={linear:function(e,r,a){return e+(r-e)*a},ease:ke(.25,.1,.25,1),"ease-in":ke(.42,0,1,1),"ease-out":ke(0,0,.58,1),"ease-in-out":ke(.42,0,.58,1),"ease-in-sine":ke(.47,0,.745,.715),"ease-out-sine":ke(.39,.575,.565,1),"ease-in-out-sine":ke(.445,.05,.55,.95),"ease-in-quad":ke(.55,.085,.68,.53),"ease-out-quad":ke(.25,.46,.45,.94),"ease-in-out-quad":ke(.455,.03,.515,.955),"ease-in-cubic":ke(.55,.055,.675,.19),"ease-out-cubic":ke(.215,.61,.355,1),"ease-in-out-cubic":ke(.645,.045,.355,1),"ease-in-quart":ke(.895,.03,.685,.22),"ease-out-quart":ke(.165,.84,.44,1),"ease-in-out-quart":ke(.77,0,.175,1),"ease-in-quint":ke(.755,.05,.855,.06),"ease-out-quint":ke(.23,1,.32,1),"ease-in-out-quint":ke(.86,0,.07,1),"ease-in-expo":ke(.95,.05,.795,.035),"ease-out-expo":ke(.19,1,.22,1),"ease-in-out-expo":ke(1,0,0,1),"ease-in-circ":ke(.6,.04,.98,.335),"ease-out-circ":ke(.075,.82,.165,1),"ease-in-out-circ":ke(.785,.135,.15,.86),spring:function(e,r,a){if(a===0)return Wa.linear;var n=cg(e,r,a);return function(i,s,o){return i+(s-i)*n(o)}},"cubic-bezier":ke};function Ms(t,e,r,a,n){if(a===1||e===r)return r;var i=n(e,r,a);return t==null||((t.roundValue||t.color)&&(i=Math.round(i)),t.min!==void 0&&(i=Math.max(i,t.min)),t.max!==void 0&&(i=Math.min(i,t.max))),i}function Rs(t,e){return t.pfValue!=null||t.value!=null?t.pfValue!=null&&(e==null||e.type.units!=="%")?t.pfValue:t.value:t}function Sr(t,e,r,a,n){var i=n!=null?n.type:null;r<0?r=0:r>1&&(r=1);var s=Rs(t,n),o=Rs(e,n);if(ie(s)&&ie(o))return Ms(i,s,o,r,a);if(Re(s)&&Re(o)){for(var u=[],l=0;l0?(c==="spring"&&v.push(s.duration),s.easingImpl=Wa[c].apply(null,v)):s.easingImpl=Wa[c]}var p=s.easingImpl,g;if(s.duration===0?g=1:g=(r-u)/s.duration,s.applying&&(g=s.progress),g<0?g=0:g>1&&(g=1),s.delay==null){var y=s.startPosition,b=s.position;if(b&&n&&!t.locked()){var m={};aa(y.x,b.x)&&(m.x=Sr(y.x,b.x,g,p)),aa(y.y,b.y)&&(m.y=Sr(y.y,b.y,g,p)),t.position(m)}var T=s.startPan,C=s.pan,S=i.pan,E=C!=null&&a;E&&(aa(T.x,C.x)&&(S.x=Sr(T.x,C.x,g,p)),aa(T.y,C.y)&&(S.y=Sr(T.y,C.y,g,p)),t.emit("pan"));var w=s.startZoom,x=s.zoom,D=x!=null&&a;D&&(aa(w,x)&&(i.zoom=ga(i.minZoom,Sr(w,x,g,p),i.maxZoom)),t.emit("zoom")),(E||D)&&t.emit("viewport");var L=s.style;if(L&&L.length>0&&n){for(var A=0;A=0;E--){var w=S[E];w()}S.splice(0,S.length)},b=c.length-1;b>=0;b--){var m=c[b],T=m._private;if(T.stopped){c.splice(b,1),T.hooked=!1,T.playing=!1,T.started=!1,y(T.frames);continue}!T.playing&&!T.applying||(T.playing&&T.applying&&(T.applying=!1),T.started||dg(f,m,t),vg(f,m,t,h),T.applying&&(T.applying=!1),y(T.frames),T.step!=null&&T.step(t),m.completed()&&(c.splice(b,1),T.hooked=!1,T.playing=!1,T.started=!1,y(T.completes)),p=!0)}return!h&&c.length===0&&v.length===0&&a.push(f),p}for(var i=!1,s=0;s0?e.notify("draw",r):e.notify("draw")),r.unmerge(a),e.emit("step")}var gg={animate:Oe.animate(),animation:Oe.animation(),animated:Oe.animated(),clearQueue:Oe.clearQueue(),delay:Oe.delay(),delayAnimation:Oe.delayAnimation(),stop:Oe.stop(),addToAnimationPool:function(e){var r=this;r.styleEnabled()&&r._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,!e.styleEnabled())return;function r(){e._private.animationsRunning&&rn(function(i){ks(i,e),r()})}var a=e.renderer();a&&a.beforeRender?a.beforeRender(function(i,s){ks(s,e)},a.beforeRenderPriorities.animations):r()}},pg={qualifierCompare:function(e,r){return e==null||r==null?e==null&&r==null:e.sameText(r)},eventMatches:function(e,r,a){var n=r.qualifier;return n!=null?e!==a.target&&Ta(a.target)&&n.matches(a.target):!0},addEventFields:function(e,r){r.cy=e,r.target=e},callbackContext:function(e,r,a){return r.qualifier!=null?a.target:e}},Ua=function(e){return de(e)?new tr(e):e},fu={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new Tn(pg,this)),this},emitter:function(){return this._private.emitter},on:function(e,r,a){return this.emitter().on(e,Ua(r),a),this},removeListener:function(e,r,a){return this.emitter().removeListener(e,Ua(r),a),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,r,a){return this.emitter().one(e,Ua(r),a),this},once:function(e,r,a){return this.emitter().one(e,Ua(r),a),this},emit:function(e,r){return this.emitter().emit(e,r),this},emitAndNotify:function(e,r){return this.emit(e),this.notify(e,r),this}};Oe.eventAliasesOn(fu);var ei={png:function(e){var r=this._private.renderer;return e=e||{},r.png(e)},jpg:function(e){var r=this._private.renderer;return e=e||{},e.bg=e.bg||"#fff",r.jpg(e)}};ei.jpeg=ei.jpg;var Ka={layout:function(e){var r=this;if(e==null){ze("Layout options must be specified to make a layout");return}if(e.name==null){ze("A `name` must be specified to make a layout");return}var a=e.name,n=r.extension("layout",a);if(n==null){ze("No such layout `"+a+"` found. Did you forget to import it and `cytoscape.use()` it?");return}var i;de(e.eles)?i=r.$(e.eles):i=e.eles!=null?e.eles:r.$();var s=new n(be({},e,{cy:r,eles:i}));return s}};Ka.createLayout=Ka.makeLayout=Ka.layout;var yg={notify:function(e,r){var a=this._private;if(this.batching()){a.batchNotifications=a.batchNotifications||{};var n=a.batchNotifications[e]=a.batchNotifications[e]||this.collection();r!=null&&n.merge(r);return}if(a.notificationsEnabled){var i=this.renderer();this.destroyed()||!i||i.notify(e,r)}},notifications:function(e){var r=this._private;return e===void 0?r.notificationsEnabled:(r.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 e.batchCount==null&&(e.batchCount=0),e.batchCount===0&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(e.batchCount===0)return this;if(e.batchCount--,e.batchCount===0){e.batchStyleEles.updateStyle();var r=this.renderer();Object.keys(e.batchNotifications).forEach(function(a){var n=e.batchNotifications[a];n.empty()?r.notify(a):r.notify(a,n)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var r=this;return this.batch(function(){for(var a=Object.keys(e),n=0;n0;)r.removeChild(r.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach(function(a){var n=a._private;n.rscratch={},n.rstyle={},n.animation.current=[],n.animation.queue=[]})},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};ti.invalidateDimensions=ti.resize;var Za={collection:function(e,r){return de(e)?this.$(e):pt(e)?e.collection():Re(e)?(r||(r={}),new et(this,e,r.unique,r.removed)):new et(this)},nodes:function(e){var r=this.$(function(a){return a.isNode()});return e?r.filter(e):r},edges:function(e){var r=this.$(function(a){return a.isEdge()});return e?r.filter(e):r},$:function(e){var r=this._private.elements;return e?r.filter(e):r.spawnSelf()},mutableElements:function(){return this._private.elements}};Za.elements=Za.filter=Za.$;var ot={},la="t",bg="f";ot.apply=function(t){for(var e=this,r=e._private,a=r.cy,n=a.collection(),i=0;i0;if(d||h&&c){var v=void 0;d&&c||d?v=l.properties:c&&(v=l.mappedProperties);for(var p=0;p1&&(T=1),o.color){var S=a.valueMin[0],E=a.valueMax[0],w=a.valueMin[1],x=a.valueMax[1],D=a.valueMin[2],L=a.valueMax[2],A=a.valueMin[3]==null?1:a.valueMin[3],N=a.valueMax[3]==null?1:a.valueMax[3],O=[Math.round(S+(E-S)*T),Math.round(w+(x-w)*T),Math.round(D+(L-D)*T),Math.round(A+(N-A)*T)];i={bypass:a.bypass,name:a.name,value:O,strValue:"rgb("+O[0]+", "+O[1]+", "+O[2]+")"}}else if(o.number){var M=a.valueMin+(a.valueMax-a.valueMin)*T;i=this.parse(a.name,M,a.bypass,d)}else return!1;if(!i)return p(),!1;i.mapping=a,a=i;break}case s.data:{for(var R=a.field.split("."),k=h.data,P=0;P0&&i>0){for(var o={},u=!1,l=0;l0?t.delayAnimation(s).play().promise().then(m):m()}).then(function(){return t.animation({style:o,duration:i,easing:t.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){r.removeBypasses(t,n),t.emitAndNotify("style"),a.transitioning=!1})}else a.transitioning&&(this.removeBypasses(t,n),t.emitAndNotify("style"),a.transitioning=!1)};ot.checkTrigger=function(t,e,r,a,n,i){var s=this.properties[e],o=n(s);o!=null&&o(r,a)&&i(s)};ot.checkZOrderTrigger=function(t,e,r,a){var n=this;this.checkTrigger(t,e,r,a,function(i){return i.triggersZOrder},function(){n._private.cy.notify("zorder",t)})};ot.checkBoundsTrigger=function(t,e,r,a){this.checkTrigger(t,e,r,a,function(n){return n.triggersBounds},function(n){t.dirtyCompoundBoundsCache(),t.dirtyBoundingBoxCache(),n.triggersBoundsOfParallelBeziers&&e==="curve-style"&&(r==="bezier"||a==="bezier")&&t.parallelEdges().forEach(function(i){i.isBundledBezier()&&i.dirtyBoundingBoxCache()}),n.triggersBoundsOfConnectedEdges&&e==="display"&&(r==="none"||a==="none")&&t.connectedEdges().forEach(function(i){i.dirtyBoundingBoxCache()})})};ot.checkTriggers=function(t,e,r,a){t.dirtyStyleCache(),this.checkZOrderTrigger(t,e,r,a),this.checkBoundsTrigger(t,e,r,a)};var La={};La.applyBypass=function(t,e,r,a){var n=this,i=[],s=!0;if(e==="*"||e==="**"){if(r!==void 0)for(var o=0;on.length?a=a.substr(n.length):a=""}function u(){i.length>s.length?i=i.substr(s.length):i=""}for(;;){var l=a.match(/^\s*$/);if(l)break;var f=a.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!f){Ne("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+a);break}n=f[0];var h=f[1];if(h!=="core"){var d=new tr(h);if(d.invalid){Ne("Skipping parsing of block: Invalid selector found in string stylesheet: "+h),o();continue}}var c=f[2],v=!1;i=c;for(var p=[];;){var g=i.match(/^\s*$/);if(g)break;var y=i.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!y){Ne("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+c),v=!0;break}s=y[0];var b=y[1],m=y[2],T=e.properties[b];if(!T){Ne("Skipping property: Invalid property name in: "+s),u();continue}var C=r.parse(b,m);if(!C){Ne("Skipping property: Invalid property definition in: "+s),u();continue}p.push({name:b,val:m}),u()}if(v){o();break}r.selector(h);for(var S=0;S=7&&e[0]==="d"&&(f=new RegExp(o.data.regex).exec(e))){if(r)return!1;var d=o.data;return{name:t,value:f,strValue:""+e,mapped:d,field:f[1],bypass:r}}else if(e.length>=10&&e[0]==="m"&&(h=new RegExp(o.mapData.regex).exec(e))){if(r||l.multiple)return!1;var c=o.mapData;if(!(l.color||l.number))return!1;var v=this.parse(t,h[4]);if(!v||v.mapped)return!1;var p=this.parse(t,h[5]);if(!p||p.mapped)return!1;if(v.pfValue===p.pfValue||v.strValue===p.strValue)return Ne("`"+t+": "+e+"` is not a valid mapper because the output range is zero; converting to `"+t+": "+v.strValue+"`"),this.parse(t,v.strValue);if(l.color){var g=v.value,y=p.value,b=g[0]===y[0]&&g[1]===y[1]&&g[2]===y[2]&&(g[3]===y[3]||(g[3]==null||g[3]===1)&&(y[3]==null||y[3]===1));if(b)return!1}return{name:t,value:h,strValue:""+e,mapped:c,field:h[1],fieldMin:parseFloat(h[2]),fieldMax:parseFloat(h[3]),valueMin:v.value,valueMax:p.value,bypass:r}}}if(l.multiple&&a!=="multiple"){var m;if(u?m=e.split(/\s+/):Re(e)?m=e:m=[e],l.evenMultiple&&m.length%2!==0)return null;for(var T=[],C=[],S=[],E="",w=!1,x=0;x0?" ":"")+D.strValue}return l.validate&&!l.validate(T,C)?null:l.singleEnum&&w?T.length===1&&de(T[0])?{name:t,value:T[0],strValue:T[0],bypass:r}:null:{name:t,value:T,pfValue:S,strValue:E,bypass:r,units:C}}var L=function(){for(var V=0;Vl.max||l.strictMax&&e===l.max))return null;var R={name:t,value:e,strValue:""+e+(A||""),units:A,bypass:r};return l.unitless||A!=="px"&&A!=="em"?R.pfValue=e:R.pfValue=A==="px"||!A?e:this.getEmSizeInPixels()*e,(A==="ms"||A==="s")&&(R.pfValue=A==="ms"?e:1e3*e),(A==="deg"||A==="rad")&&(R.pfValue=A==="rad"?e:eh(e)),A==="%"&&(R.pfValue=e/100),R}else if(l.propList){var k=[],P=""+e;if(P!=="none"){for(var B=P.split(/\s*,\s*|\s+/),z=0;z0&&o>0&&!isNaN(a.w)&&!isNaN(a.h)&&a.w>0&&a.h>0){u=Math.min((s-2*r)/a.w,(o-2*r)/a.h),u=u>this._private.maxZoom?this._private.maxZoom:u,u=u=a.minZoom&&(a.maxZoom=r),this},minZoom:function(e){return e===void 0?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return e===void 0?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var r=this._private,a=r.pan,n=r.zoom,i,s,o=!1;if(r.zoomingEnabled||(o=!0),ie(e)?s=e:Ce(e)&&(s=e.level,e.position!=null?i=yn(e.position,n,a):e.renderedPosition!=null&&(i=e.renderedPosition),i!=null&&!r.panningEnabled&&(o=!0)),s=s>r.maxZoom?r.maxZoom:s,s=sr.maxZoom||!r.zoomingEnabled?s=!0:(r.zoom=u,i.push("zoom"))}if(n&&(!s||!e.cancelOnFailedZoom)&&r.panningEnabled){var l=e.pan;ie(l.x)&&(r.pan.x=l.x,o=!1),ie(l.y)&&(r.pan.y=l.y,o=!1),o||i.push("pan")}return i.length>0&&(i.push("viewport"),this.emit(i.join(" ")),this.notify("viewport")),this},center:function(e){var r=this.getCenterPan(e);return r&&(this._private.pan=r,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,r){if(this._private.panningEnabled){if(de(e)){var a=e;e=this.mutableElements().filter(a)}else pt(e)||(e=this.mutableElements());if(e.length!==0){var n=e.boundingBox(),i=this.width(),s=this.height();r=r===void 0?this._private.zoom:r;var o={x:(i-r*(n.x1+n.x2))/2,y:(s-r*(n.y1+n.y2))/2};return o}}},reset:function(){return!this._private.panningEnabled||!this._private.zoomingEnabled?this:(this.viewport({pan:{x:0,y:0},zoom:1}),this)},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e=this._private,r=e.container,a=this;return e.sizeCache=e.sizeCache||(r?function(){var n=a.window().getComputedStyle(r),i=function(o){return parseFloat(n.getPropertyValue(o))};return{width:r.clientWidth-i("padding-left")-i("padding-right"),height:r.clientHeight-i("padding-top")-i("padding-bottom")}}():{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,r=this._private.zoom,a=this.renderedExtent(),n={x1:(a.x1-e.x)/r,x2:(a.x2-e.x)/r,y1:(a.y1-e.y)/r,y2:(a.y2-e.y)/r};return n.w=n.x2-n.x1,n.h=n.y2-n.y1,n},renderedExtent:function(){var e=this.width(),r=this.height();return{x1:0,y1:0,x2:e,y2:r,w:e,h:r}},multiClickDebounceTime:function(e){if(e)this._private.multiClickDebounceTime=e;else return this._private.multiClickDebounceTime;return this}};mr.centre=mr.center;mr.autolockNodes=mr.autolock;mr.autoungrabifyNodes=mr.autoungrabify;var Ea={data:Oe.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:Oe.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:Oe.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Oe.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Ea.attr=Ea.data;Ea.removeAttr=Ea.removeData;var wa=function(e){var r=this;e=be({},e);var a=e.container;a&&!tn(a)&&tn(a[0])&&(a=a[0]);var n=a?a._cyreg:null;n=n||{},n&&n.cy&&(n.cy.destroy(),n={});var i=n.readies=n.readies||[];a&&(a._cyreg=n),n.cy=r;var s=Ye!==void 0&&a!==void 0&&!e.headless,o=e;o.layout=be({name:s?"grid":"null"},o.layout),o.renderer=be({name:s?"canvas":"null"},o.renderer);var u=function(v,p,g){return p!==void 0?p:g!==void 0?g:v},l=this._private={container:a,ready:!1,options:o,elements:new et(this),listeners:[],aniEles:new et(this),data:o.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:u(!0,o.zoomingEnabled),userZoomingEnabled:u(!0,o.userZoomingEnabled),panningEnabled:u(!0,o.panningEnabled),userPanningEnabled:u(!0,o.userPanningEnabled),boxSelectionEnabled:u(!0,o.boxSelectionEnabled),autolock:u(!1,o.autolock,o.autolockNodes),autoungrabify:u(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:u(!1,o.autounselectify),styleEnabled:o.styleEnabled===void 0?s:o.styleEnabled,zoom:ie(o.zoom)?o.zoom:1,pan:{x:Ce(o.pan)&&ie(o.pan.x)?o.pan.x:0,y:Ce(o.pan)&&ie(o.pan.y)?o.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:u(250,o.multiClickDebounceTime)};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom});var f=function(v,p){var g=v.some(Tl);if(g)return $r.all(v).then(p);p(v)};l.styleEnabled&&r.setStyle([]);var h=be({},o,o.renderer);r.initRenderer(h);var d=function(v,p,g){r.notifications(!1);var y=r.mutableElements();y.length>0&&y.remove(),v!=null&&(Ce(v)||Re(v))&&r.add(v),r.one("layoutready",function(m){r.notifications(!0),r.emit(m),r.one("load",p),r.emitAndNotify("load")}).one("layoutstop",function(){r.one("done",g),r.emit("done")});var b=be({},r._private.options.layout);b.eles=r.elements(),r.layout(b).run()};f([o.style,o.elements],function(c){var v=c[0],p=c[1];l.styleEnabled&&r.style().append(v),d(p,function(){r.startAnimationLoop(),l.ready=!0,Ge(o.ready)&&r.on("ready",o.ready);for(var g=0;g0,u=gt(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),l;if(pt(e.roots))l=e.roots;else if(Re(e.roots)){for(var f=[],h=0;h0;){var M=O(),R=D(M,A);if(R)M.outgoers().filter(function(te){return te.isNode()&&a.has(te)}).forEach(N);else if(R===null){Ne("Detected double maximal shift for node `"+M.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}x();var k=0;if(e.avoidOverlap)for(var P=0;P0&&y[0].length<=3?we/2:0),I=2*Math.PI/y[ve].length*fe;return ve===0&&y[0].length===1&&(ee=1),{x:Q.x+ee*Math.cos(I),y:Q.y+ee*Math.sin(I)}}else{var De={x:Q.x+(fe+1-(pe+1)/2)*Ae,y:(ve+1)*xe};return De}};return a.nodes().layoutPositions(this,e,ce),this};var Cg={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function cu(t){this.options=be({},Cg,t)}cu.prototype.run=function(){var t=this.options,e=t,r=t.cy,a=e.eles,n=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,i=a.nodes().not(":parent");e.sort&&(i=i.sort(e.sort));for(var s=gt(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),o={x:s.x1+s.w/2,y:s.y1+s.h/2},u=e.sweep===void 0?2*Math.PI-2*Math.PI/i.length:e.sweep,l=u/Math.max(1,i.length-1),f,h=0,d=0;d1&&e.avoidOverlap){h*=1.75;var y=Math.cos(l)-Math.cos(0),b=Math.sin(l)-Math.sin(0),m=Math.sqrt(h*h/(y*y+b*b));f=Math.max(m,f)}var T=function(S,E){var w=e.startAngle+E*l*(n?1:-1),x=f*Math.cos(w),D=f*Math.sin(w),L={x:o.x+x,y:o.y+D};return L};return a.nodes().layoutPositions(this,e,T),this};var Dg={fit:!0,padding:30,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function vu(t){this.options=be({},Dg,t)}vu.prototype.run=function(){for(var t=this.options,e=t,r=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,a=t.cy,n=e.eles,i=n.nodes().not(":parent"),s=gt(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:a.width(),h:a.height()}),o={x:s.x1+s.w/2,y:s.y1+s.h/2},u=[],l=0,f=0;f0){var C=Math.abs(b[0].value-T.value);C>=g&&(b=[],y.push(b))}b.push(T)}var S=l+e.minNodeSpacing;if(!e.avoidOverlap){var E=y.length>0&&y[0].length>1,w=Math.min(s.w,s.h)/2-S,x=w/(y.length+E?1:0);S=Math.min(S,x)}for(var D=0,L=0;L1&&e.avoidOverlap){var M=Math.cos(O)-Math.cos(0),R=Math.sin(O)-Math.sin(0),k=Math.sqrt(S*S/(M*M+R*R));D=Math.max(k,D)}A.r=D,D+=S}if(e.equidistant){for(var P=0,B=0,z=0;z=t.numIter||(Rg(a,t),a.temperature=a.temperature*t.coolingFactor,a.temperature=t.animationThreshold&&i(),rn(h)}};f()}else{for(;l;)l=s(u),u++;Fs(a,t),o()}return this};An.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this};An.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var Lg=function(e,r,a){for(var n=a.eles.edges(),i=a.eles.nodes(),s=gt(a.boundingBox?a.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),o={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:n.size(),temperature:a.initialTemp,clientWidth:s.w,clientHeight:s.h,boundingBox:s},u=a.eles.components(),l={},f=0;f0){o.graphSet.push(w);for(var f=0;fn.count?0:n.graph},Og=function t(e,r,a,n){var i=n.graphSet[a];if(-10)var h=n.nodeOverlap*f,d=Math.sqrt(o*o+u*u),c=h*o/d,v=h*u/d;else var p=fn(e,o,u),g=fn(r,-1*o,-1*u),y=g.x-p.x,b=g.y-p.y,m=y*y+b*b,d=Math.sqrt(m),h=(e.nodeRepulsion+r.nodeRepulsion)/m,c=h*y/d,v=h*b/d;e.isLocked||(e.offsetX-=c,e.offsetY-=v),r.isLocked||(r.offsetX+=c,r.offsetY+=v)}},Bg=function(e,r,a,n){if(a>0)var i=e.maxX-r.minX;else var i=r.maxX-e.minX;if(n>0)var s=e.maxY-r.minY;else var s=r.maxY-e.minY;return i>=0&&s>=0?Math.sqrt(i*i+s*s):0},fn=function(e,r,a){var n=e.positionX,i=e.positionY,s=e.height||1,o=e.width||1,u=a/r,l=s/o,f={};return r===0&&0a?(f.x=n,f.y=i+s/2,f):0r&&-1*l<=u&&u<=l?(f.x=n-o/2,f.y=i-o*a/2/r,f):0=l)?(f.x=n+s*r/2/a,f.y=i+s/2,f):(0>a&&(u<=-1*l||u>=l)&&(f.x=n-s*r/2/a,f.y=i-s/2),f)},Fg=function(e,r){for(var a=0;aa){var g=r.gravity*c/p,y=r.gravity*v/p;d.offsetX+=g,d.offsetY+=y}}}}},zg=function(e,r){var a=[],n=0,i=-1;for(a.push.apply(a,e.graphSet[0]),i+=e.graphSet[0].length;n<=i;){var s=a[n++],o=e.idToIndex[s],u=e.layoutNodes[o],l=u.children;if(0a)var i={x:a*e/n,y:a*r/n};else var i={x:e,y:r};return i},$g=function t(e,r){var a=e.parentId;if(a!=null){var n=r.layoutNodes[r.idToIndex[a]],i=!1;if((n.maxX==null||e.maxX+n.padRight>n.maxX)&&(n.maxX=e.maxX+n.padRight,i=!0),(n.minX==null||e.minX-n.padLeftn.maxY)&&(n.maxY=e.maxY+n.padBottom,i=!0),(n.minY==null||e.minY-n.padTopy&&(v+=g+r.componentSpacing,c=0,p=0,g=0)}}},Yg={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function gu(t){this.options=be({},Yg,t)}gu.prototype.run=function(){var t=this.options,e=t,r=t.cy,a=e.eles,n=a.nodes().not(":parent");e.sort&&(n=n.sort(e.sort));var i=gt(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()});if(i.h===0||i.w===0)a.nodes().layoutPositions(this,e,function(U){return{x:i.x1,y:i.y1}});else{var s=n.size(),o=Math.sqrt(s*i.h/i.w),u=Math.round(o),l=Math.round(i.w/i.h*o),f=function(Y){if(Y==null)return Math.min(u,l);var W=Math.min(u,l);W==u?u=Y:l=Y},h=function(Y){if(Y==null)return Math.max(u,l);var W=Math.max(u,l);W==u?u=Y:l=Y},d=e.rows,c=e.cols!=null?e.cols:e.columns;if(d!=null&&c!=null)u=d,l=c;else if(d!=null&&c==null)u=d,l=Math.ceil(s/u);else if(d==null&&c!=null)l=c,u=Math.ceil(s/l);else if(l*u>s){var v=f(),p=h();(v-1)*p>=s?f(v-1):(p-1)*v>=s&&h(p-1)}else for(;l*u=s?h(y+1):f(g+1)}var b=i.w/l,m=i.h/u;if(e.condense&&(b=0,m=0),e.avoidOverlap)for(var T=0;T=l&&(M=0,O++)},k={},P=0;P(M=vh(t,e,R[k],R[k+1],R[k+2],R[k+3])))return g(E,M),!0}else if(x.edgeType==="bezier"||x.edgeType==="multibezier"||x.edgeType==="self"||x.edgeType==="compound"){for(var R=x.allpts,k=0;k+5(M=ch(t,e,R[k],R[k+1],R[k+2],R[k+3],R[k+4],R[k+5])))return g(E,M),!0}for(var P=P||w.source,B=B||w.target,z=n.getArrowWidth(D,L),G=[{name:"source",x:x.arrowStartX,y:x.arrowStartY,angle:x.srcArrowAngle},{name:"target",x:x.arrowEndX,y:x.arrowEndY,angle:x.tgtArrowAngle},{name:"mid-source",x:x.midX,y:x.midY,angle:x.midsrcArrowAngle},{name:"mid-target",x:x.midX,y:x.midY,angle:x.midtgtArrowAngle}],k=0;k0&&(y(P),y(B))}function m(E,w,x){return At(E,w,x)}function T(E,w){var x=E._private,D=d,L;w?L=w+"-":L="",E.boundingBox();var A=x.labelBounds[w||"main"],N=E.pstyle(L+"label").value,O=E.pstyle("text-events").strValue==="yes";if(!(!O||!N)){var M=m(x.rscratch,"labelX",w),R=m(x.rscratch,"labelY",w),k=m(x.rscratch,"labelAngle",w),P=E.pstyle(L+"text-margin-x").pfValue,B=E.pstyle(L+"text-margin-y").pfValue,z=A.x1-D-P,G=A.x2+D-P,F=A.y1-D-B,U=A.y2+D-B;if(k){var Y=Math.cos(k),W=Math.sin(k),K=function(ce,te){return ce=ce-M,te=te-R,{x:ce*Y-te*W+M,y:ce*W+te*Y+R}},j=K(z,F),_=K(z,U),V=K(G,F),H=K(G,U),Q=[j.x+P,j.y+B,V.x+P,V.y+B,H.x+P,H.y+B,_.x+P,_.y+B];if(dt(t,e,Q))return g(E),!0}else if(Gr(A,t,e))return g(E),!0}}for(var C=s.length-1;C>=0;C--){var S=s[C];S.isNode()?y(S)||T(S):b(S)||T(S)||T(S,"source")||T(S,"target")}return o};wr.getAllInBox=function(t,e,r,a){var n=this.getCachedZSortedEles().interactive,i=[],s=Math.min(t,r),o=Math.max(t,r),u=Math.min(e,a),l=Math.max(e,a);t=s,r=o,e=u,a=l;for(var f=gt({x1:t,y1:e,x2:r,y2:a}),h=0;h0?-(Math.PI-e.ang):Math.PI+e.ang},Kg=function(e,r,a,n,i){if(e!==$s?Ys(r,e,kt):Wg(bt,kt),Ys(r,a,bt),Vs=kt.nx*bt.ny-kt.ny*bt.nx,Us=kt.nx*bt.nx-kt.ny*-bt.ny,Ut=Math.asin(Math.max(-1,Math.min(1,Vs))),Math.abs(Ut)<1e-6){ri=r.x,ai=r.y,fr=Ar=0;return}hr=1,Qa=!1,Us<0?Ut<0?Ut=Math.PI+Ut:(Ut=Math.PI-Ut,hr=-1,Qa=!0):Ut>0&&(hr=-1,Qa=!0),r.radius!==void 0?Ar=r.radius:Ar=n,or=Ut/2,$a=Math.min(kt.len/2,bt.len/2),i?(Rt=Math.abs(Math.cos(or)*Ar/Math.sin(or)),Rt>$a?(Rt=$a,fr=Math.abs(Rt*Math.sin(or)/Math.cos(or))):fr=Ar):(Rt=Math.min($a,Ar),fr=Math.abs(Rt*Math.sin(or)/Math.cos(or))),ni=r.x+bt.nx*Rt,ii=r.y+bt.ny*Rt,ri=ni-bt.ny*fr*hr,ai=ii+bt.nx*fr*hr,bu=r.x+kt.nx*Rt,Eu=r.y+kt.ny*Rt,$s=r};function wu(t,e){e.radius===0?t.lineTo(e.cx,e.cy):t.arc(e.cx,e.cy,e.radius,e.startAngle,e.endAngle,e.counterClockwise)}function ki(t,e,r,a){var n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return a===0||e.radius===0?{cx:e.x,cy:e.y,radius:0,startX:e.x,startY:e.y,stopX:e.x,stopY:e.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(Kg(t,e,r,a,n),{cx:ri,cy:ai,radius:fr,startX:bu,startY:Eu,stopX:ni,stopY:ii,startAngle:kt.ang+Math.PI/2*hr,endAngle:bt.ang-Math.PI/2*hr,counterClockwise:Qa})}var ut={};ut.findMidptPtsEtc=function(t,e){var r=e.posPts,a=e.intersectionPts,n=e.vectorNormInverse,i,s=t.pstyle("source-endpoint"),o=t.pstyle("target-endpoint"),u=s.units!=null&&o.units!=null,l=function(C,S,E,w){var x=w-S,D=E-C,L=Math.sqrt(D*D+x*x);return{x:-x/L,y:D/L}},f=t.pstyle("edge-distances").value;switch(f){case"node-position":i=r;break;case"intersection":i=a;break;case"endpoints":{if(u){var h=this.manualEndptToPx(t.source()[0],s),d=St(h,2),c=d[0],v=d[1],p=this.manualEndptToPx(t.target()[0],o),g=St(p,2),y=g[0],b=g[1],m={x1:c,y1:v,x2:y,y2:b};n=l(c,v,y,b),i=m}else Ne("Edge ".concat(t.id()," has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")),i=a;break}}return{midptPts:i,vectorNormInverse:n}};ut.findHaystackPoints=function(t){for(var e=0;e0?Math.max(ye-me,0):Math.min(ye+me,0)},N=A(D,w),O=A(L,x),M=!1;b===l?y=Math.abs(N)>Math.abs(O)?n:a:b===u||b===o?(y=a,M=!0):(b===i||b===s)&&(y=n,M=!0);var R=y===a,k=R?O:N,P=R?L:D,B=Do(P),z=!1;!(M&&(T||S))&&(b===o&&P<0||b===u&&P>0||b===i&&P>0||b===s&&P<0)&&(B*=-1,k=B*Math.abs(k),z=!0);var G;if(T){var F=C<0?1+C:C;G=F*k}else{var U=C<0?k:0;G=U+C*B}var Y=function(ye){return Math.abs(ye)=Math.abs(k)},W=Y(G),K=Y(Math.abs(k)-Math.abs(G)),j=W||K;if(j&&!z)if(R){var _=Math.abs(P)<=d/2,V=Math.abs(D)<=c/2;if(_){var H=(f.x1+f.x2)/2,Q=f.y1,ne=f.y2;r.segpts=[H,Q,H,ne]}else if(V){var ce=(f.y1+f.y2)/2,te=f.x1,se=f.x2;r.segpts=[te,ce,se,ce]}else r.segpts=[f.x1,f.y2]}else{var ue=Math.abs(P)<=h/2,ve=Math.abs(L)<=v/2;if(ue){var fe=(f.y1+f.y2)/2,pe=f.x1,Ae=f.x2;r.segpts=[pe,fe,Ae,fe]}else if(ve){var xe=(f.x1+f.x2)/2,we=f.y1,De=f.y2;r.segpts=[xe,we,xe,De]}else r.segpts=[f.x2,f.y1]}else if(R){var ee=f.y1+G+(g?d/2*B:0),I=f.x1,$=f.x2;r.segpts=[I,ee,$,ee]}else{var J=f.x1+G+(g?h/2*B:0),q=f.y1,X=f.y2;r.segpts=[J,q,J,X]}if(r.isRound){var ae=t.pstyle("taxi-radius").value,Z=t.pstyle("radius-type").value[0]==="arc-radius";r.radii=new Array(r.segpts.length/2).fill(ae),r.isArcRadius=new Array(r.segpts.length/2).fill(Z)}};ut.tryToCorrectInvalidPoints=function(t,e){var r=t._private.rscratch;if(r.edgeType==="bezier"){var a=e.srcPos,n=e.tgtPos,i=e.srcW,s=e.srcH,o=e.tgtW,u=e.tgtH,l=e.srcShape,f=e.tgtShape,h=e.srcCornerRadius,d=e.tgtCornerRadius,c=e.srcRs,v=e.tgtRs,p=!ie(r.startX)||!ie(r.startY),g=!ie(r.arrowStartX)||!ie(r.arrowStartY),y=!ie(r.endX)||!ie(r.endY),b=!ie(r.arrowEndX)||!ie(r.arrowEndY),m=3,T=this.getArrowWidth(t.pstyle("width").pfValue,t.pstyle("arrow-scale").value)*this.arrowShapeWidth,C=m*T,S=gr({x:r.ctrlpts[0],y:r.ctrlpts[1]},{x:r.startX,y:r.startY}),E=SO.poolIndex()){var M=N;N=O,O=M}var R=x.srcPos=N.position(),k=x.tgtPos=O.position(),P=x.srcW=N.outerWidth(),B=x.srcH=N.outerHeight(),z=x.tgtW=O.outerWidth(),G=x.tgtH=O.outerHeight(),F=x.srcShape=r.nodeShapes[e.getNodeShape(N)],U=x.tgtShape=r.nodeShapes[e.getNodeShape(O)],Y=x.srcCornerRadius=N.pstyle("corner-radius").value==="auto"?"auto":N.pstyle("corner-radius").pfValue,W=x.tgtCornerRadius=O.pstyle("corner-radius").value==="auto"?"auto":O.pstyle("corner-radius").pfValue,K=x.tgtRs=O._private.rscratch,j=x.srcRs=N._private.rscratch;x.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var _=0;_0){var ne=i,ce=ur(ne,Ir(r)),te=ur(ne,Ir(Q)),se=ce;if(te2){var ue=ur(ne,{x:Q[2],y:Q[3]});ue0){var X=s,ae=ur(X,Ir(r)),Z=ur(X,Ir(q)),re=ae;if(Z2){var ye=ur(X,{x:q[2],y:q[3]});ye=v||E){g={cp:T,segment:S};break}}if(g)break}var w=g.cp,x=g.segment,D=(v-y)/x.length,L=x.t1-x.t0,A=c?x.t0+L*D:x.t1-L*D;A=ga(0,A,1),e=Rr(w.p0,w.p1,w.p2,A),d=Qg(w.p0,w.p1,w.p2,A);break}case"straight":case"segments":case"haystack":{for(var N=0,O,M,R,k,P=a.allpts.length,B=0;B+3=v));B+=2);var z=v-M,G=z/O;G=ga(0,G,1),e=rh(R,k,G),d=Cu(R,k);break}}s("labelX",h,e.x),s("labelY",h,e.y),s("labelAutoAngle",h,d)}};l("source"),l("target"),this.applyLabelDimensions(t)}};Gt.applyLabelDimensions=function(t){this.applyPrefixedLabelDimensions(t),t.isEdge()&&(this.applyPrefixedLabelDimensions(t,"source"),this.applyPrefixedLabelDimensions(t,"target"))};Gt.applyPrefixedLabelDimensions=function(t,e){var r=t._private,a=this.getLabelText(t,e),n=this.calculateLabelDimensions(t,a),i=t.pstyle("line-height").pfValue,s=t.pstyle("text-wrap").strValue,o=At(r.rscratch,"labelWrapCachedLines",e)||[],u=s!=="wrap"?1:Math.max(o.length,1),l=n.height/u,f=l*i,h=n.width,d=n.height+(u-1)*(i-1)*l;Kt(r.rstyle,"labelWidth",e,h),Kt(r.rscratch,"labelWidth",e,h),Kt(r.rstyle,"labelHeight",e,d),Kt(r.rscratch,"labelHeight",e,d),Kt(r.rscratch,"labelLineHeight",e,f)};Gt.getLabelText=function(t,e){var r=t._private,a=e?e+"-":"",n=t.pstyle(a+"label").strValue,i=t.pstyle("text-transform").value,s=function(U,Y){return Y?(Kt(r.rscratch,U,e,Y),Y):At(r.rscratch,U,e)};if(!n)return"";i=="none"||(i=="uppercase"?n=n.toUpperCase():i=="lowercase"&&(n=n.toLowerCase()));var o=t.pstyle("text-wrap").value;if(o==="wrap"){var u=s("labelKey");if(u!=null&&s("labelWrapKey")===u)return s("labelWrapCachedText");for(var l="​",f=n.split(` `),h=t.pstyle("text-max-width").pfValue,d=t.pstyle("text-overflow-wrap").value,c=d==="anywhere",v=[],p=/[\s\u200b]+|$/g,g=0;gh){var C=y.matchAll(p),S="",E=0,w=io(C),x;try{for(w.s();!(x=w.n()).done;){var D=x.value,L=D[0],A=y.substring(E,D.index);E=D.index+L.length;var N=S.length===0?A:S+A+L,O=this.calculateLabelDimensions(t,N),M=O.width;M<=h?S+=A+L:(S&&v.push(S),S=A+L)}}catch(F){w.e(F)}finally{w.f()}S.match(/^[\s\u200b]+$/)||v.push(S)}else v.push(y)}s("labelWrapCachedLines",v),n=s("labelWrapCachedText",v.join(` `)),s("labelWrapKey",u)}else if(o==="ellipsis"){var R=t.pstyle("text-max-width").pfValue,k="",P="…",B=!1;if(this.calculateLabelDimensions(t,n).widthR)break;k+=n[z],z===n.length-1&&(B=!0)}return B||(k+=P),k}return n};Gt.getLabelJustification=function(t){var e=t.pstyle("text-justification").strValue,r=t.pstyle("text-halign").strValue;if(e==="auto")if(t.isNode())switch(r){case"left":return"right";case"right":return"left";default:return"center"}else return"center";else return e};Gt.calculateLabelDimensions=function(t,e){var r=this,a=r.cy.window(),n=a.document,i=dr(e,t._private.labelDimsKey),s=r.labelDimCache||(r.labelDimCache=[]),o=s[i];if(o!=null)return o;var u=0,l=t.pstyle("font-style").strValue,f=t.pstyle("font-size").pfValue,h=t.pstyle("font-family").strValue,d=t.pstyle("font-weight").strValue,c=this.labelCalcCanvas,v=this.labelCalcCanvasContext;if(!c){c=this.labelCalcCanvas=n.createElement("canvas"),v=this.labelCalcCanvasContext=c.getContext("2d");var p=c.style;p.position="absolute",p.left="-9999px",p.top="-9999px",p.zIndex="-1",p.visibility="hidden",p.pointerEvents="none"}v.font="".concat(l," ").concat(d," ").concat(f,"px ").concat(h);for(var g=0,y=0,b=e.split(` `),m=0;m1&&arguments[1]!==void 0?arguments[1]:!0;if(e.merge(s),o)for(var u=0;u=t.desktopTapThreshold2}var ft=n(I);Me&&(t.hoverData.tapholdCancelled=!0);var xt=function(){var Mt=t.hoverData.dragDelta=t.hoverData.dragDelta||[];Mt.length===0?(Mt.push(ge[0]),Mt.push(ge[1])):(Mt[0]+=ge[0],Mt[1]+=ge[1])};J=!0,a(he,["mousemove","vmousemove","tapdrag"],I,{x:Z[0],y:Z[1]});var mt=function(){t.data.bgActivePosistion=void 0,t.hoverData.selecting||q.emit({originalEvent:I,type:"boxstart",position:{x:Z[0],y:Z[1]}}),me[4]=1,t.hoverData.selecting=!0,t.redrawHint("select",!0),t.redraw()};if(t.hoverData.which===3){if(Me){var vt={originalEvent:I,type:"cxtdrag",position:{x:Z[0],y:Z[1]}};le?le.emit(vt):q.emit(vt),t.hoverData.cxtDragged=!0,(!t.hoverData.cxtOver||he!==t.hoverData.cxtOver)&&(t.hoverData.cxtOver&&t.hoverData.cxtOver.emit({originalEvent:I,type:"cxtdragout",position:{x:Z[0],y:Z[1]}}),t.hoverData.cxtOver=he,he&&he.emit({originalEvent:I,type:"cxtdragover",position:{x:Z[0],y:Z[1]}}))}}else if(t.hoverData.dragging){if(J=!0,q.panningEnabled()&&q.userPanningEnabled()){var It;if(t.hoverData.justStartedPan){var Vt=t.hoverData.mdownPos;It={x:(Z[0]-Vt[0])*X,y:(Z[1]-Vt[1])*X},t.hoverData.justStartedPan=!1}else It={x:ge[0]*X,y:ge[1]*X};q.panBy(It),q.emit("dragpan"),t.hoverData.dragged=!0}Z=t.projectIntoViewport(I.clientX,I.clientY)}else if(me[4]==1&&(le==null||le.pannable())){if(Me){if(!t.hoverData.dragging&&q.boxSelectionEnabled()&&(ft||!q.panningEnabled()||!q.userPanningEnabled()))mt();else if(!t.hoverData.selecting&&q.panningEnabled()&&q.userPanningEnabled()){var Tt=i(le,t.hoverData.downs);Tt&&(t.hoverData.dragging=!0,t.hoverData.justStartedPan=!0,me[4]=0,t.data.bgActivePosistion=Ir(re),t.redrawHint("select",!0),t.redraw())}le&&le.pannable()&&le.active()&&le.unactivate()}}else{if(le&&le.pannable()&&le.active()&&le.unactivate(),(!le||!le.grabbed())&&he!=Ee&&(Ee&&a(Ee,["mouseout","tapdragout"],I,{x:Z[0],y:Z[1]}),he&&a(he,["mouseover","tapdragover"],I,{x:Z[0],y:Z[1]}),t.hoverData.last=he),le)if(Me){if(q.boxSelectionEnabled()&&ft)le&&le.grabbed()&&(g(Fe),le.emit("freeon"),Fe.emit("free"),t.dragData.didDrag&&(le.emit("dragfreeon"),Fe.emit("dragfree"))),mt();else if(le&&le.grabbed()&&t.nodeIsDraggable(le)){var $e=!t.dragData.didDrag;$e&&t.redrawHint("eles",!0),t.dragData.didDrag=!0,t.hoverData.draggingEles||v(Fe,{inDragLayer:!0});var We={x:0,y:0};if(ie(ge[0])&&ie(ge[1])&&(We.x+=ge[0],We.y+=ge[1],$e)){var at=t.hoverData.dragDelta;at&&ie(at[0])&&ie(at[1])&&(We.x+=at[0],We.y+=at[1])}t.hoverData.draggingEles=!0,Fe.silentShift(We).emit("position drag"),t.redrawHint("drag",!0),t.redraw()}}else xt();J=!0}if(me[2]=Z[0],me[3]=Z[1],J)return I.stopPropagation&&I.stopPropagation(),I.preventDefault&&I.preventDefault(),!1}},!1);var D,L,A;t.registerBinding(e,"mouseup",function(I){if(!(t.hoverData.which===1&&I.which!==1&&t.hoverData.capture)){var $=t.hoverData.capture;if($){t.hoverData.capture=!1;var J=t.cy,q=t.projectIntoViewport(I.clientX,I.clientY),X=t.selection,ae=t.findNearestElement(q[0],q[1],!0,!1),Z=t.dragData.possibleDragElements,re=t.hoverData.down,ye=n(I);if(t.data.bgActivePosistion&&(t.redrawHint("select",!0),t.redraw()),t.hoverData.tapholdCancelled=!0,t.data.bgActivePosistion=void 0,re&&re.unactivate(),t.hoverData.which===3){var me={originalEvent:I,type:"cxttapend",position:{x:q[0],y:q[1]}};if(re?re.emit(me):J.emit(me),!t.hoverData.cxtDragged){var he={originalEvent:I,type:"cxttap",position:{x:q[0],y:q[1]}};re?re.emit(he):J.emit(he)}t.hoverData.cxtDragged=!1,t.hoverData.which=null}else if(t.hoverData.which===1){if(a(ae,["mouseup","tapend","vmouseup"],I,{x:q[0],y:q[1]}),!t.dragData.didDrag&&!t.hoverData.dragged&&!t.hoverData.selecting&&!t.hoverData.isOverThresholdDrag&&(a(re,["click","tap","vclick"],I,{x:q[0],y:q[1]}),L=!1,I.timeStamp-A<=J.multiClickDebounceTime()?(D&&clearTimeout(D),L=!0,A=null,a(re,["dblclick","dbltap","vdblclick"],I,{x:q[0],y:q[1]})):(D=setTimeout(function(){L||a(re,["oneclick","onetap","voneclick"],I,{x:q[0],y:q[1]})},J.multiClickDebounceTime()),A=I.timeStamp)),re==null&&!t.dragData.didDrag&&!t.hoverData.selecting&&!t.hoverData.dragged&&!n(I)&&(J.$(r).unselect(["tapunselect"]),Z.length>0&&t.redrawHint("eles",!0),t.dragData.possibleDragElements=Z=J.collection()),ae==re&&!t.dragData.didDrag&&!t.hoverData.selecting&&ae!=null&&ae._private.selectable&&(t.hoverData.dragging||(J.selectionType()==="additive"||ye?ae.selected()?ae.unselect(["tapunselect"]):ae.select(["tapselect"]):ye||(J.$(r).unmerge(ae).unselect(["tapunselect"]),ae.select(["tapselect"]))),t.redrawHint("eles",!0)),t.hoverData.selecting){var Ee=J.collection(t.getAllInBox(X[0],X[1],X[2],X[3]));t.redrawHint("select",!0),Ee.length>0&&t.redrawHint("eles",!0),J.emit({type:"boxend",originalEvent:I,position:{x:q[0],y:q[1]}});var le=function(Me){return Me.selectable()&&!Me.selected()};J.selectionType()==="additive"||ye||J.$(r).unmerge(Ee).unselect(),Ee.emit("box").stdFilter(le).select().emit("boxselect"),t.redraw()}if(t.hoverData.dragging&&(t.hoverData.dragging=!1,t.redrawHint("select",!0),t.redrawHint("eles",!0),t.redraw()),!X[4]){t.redrawHint("drag",!0),t.redrawHint("eles",!0);var ge=re&&re.grabbed();g(Z),ge&&(re.emit("freeon"),Z.emit("free"),t.dragData.didDrag&&(re.emit("dragfreeon"),Z.emit("dragfree")))}}X[4]=0,t.hoverData.down=null,t.hoverData.cxtStarted=!1,t.hoverData.draggingEles=!1,t.hoverData.selecting=!1,t.hoverData.isOverThresholdDrag=!1,t.dragData.didDrag=!1,t.hoverData.dragged=!1,t.hoverData.dragDelta=[],t.hoverData.mdownPos=null,t.hoverData.mdownGPos=null}}},!1);var N=function(I){if(!t.scrollingPage){var $=t.cy,J=$.zoom(),q=$.pan(),X=t.projectIntoViewport(I.clientX,I.clientY),ae=[X[0]*J+q.x,X[1]*J+q.y];if(t.hoverData.draggingEles||t.hoverData.dragging||t.hoverData.cxtStarted||w()){I.preventDefault();return}if($.panningEnabled()&&$.userPanningEnabled()&&$.zoomingEnabled()&&$.userZoomingEnabled()){I.preventDefault(),t.data.wheelZooming=!0,clearTimeout(t.data.wheelTimeout),t.data.wheelTimeout=setTimeout(function(){t.data.wheelZooming=!1,t.redrawHint("eles",!0),t.redraw()},150);var Z;I.deltaY!=null?Z=I.deltaY/-250:I.wheelDeltaY!=null?Z=I.wheelDeltaY/1e3:Z=I.wheelDelta/1e3,Z=Z*t.wheelSensitivity;var re=I.deltaMode===1;re&&(Z*=33);var ye=$.zoom()*Math.pow(10,Z);I.type==="gesturechange"&&(ye=t.gestureStartZoom*I.scale),$.zoom({level:ye,renderedPosition:{x:ae[0],y:ae[1]}}),$.emit(I.type==="gesturechange"?"pinchzoom":"scrollzoom")}}};t.registerBinding(t.container,"wheel",N,!0),t.registerBinding(e,"scroll",function(I){t.scrollingPage=!0,clearTimeout(t.scrollingPageTimeout),t.scrollingPageTimeout=setTimeout(function(){t.scrollingPage=!1},250)},!0),t.registerBinding(t.container,"gesturestart",function(I){t.gestureStartZoom=t.cy.zoom(),t.hasTouchStarted||I.preventDefault()},!0),t.registerBinding(t.container,"gesturechange",function(ee){t.hasTouchStarted||N(ee)},!0),t.registerBinding(t.container,"mouseout",function(I){var $=t.projectIntoViewport(I.clientX,I.clientY);t.cy.emit({originalEvent:I,type:"mouseout",position:{x:$[0],y:$[1]}})},!1),t.registerBinding(t.container,"mouseover",function(I){var $=t.projectIntoViewport(I.clientX,I.clientY);t.cy.emit({originalEvent:I,type:"mouseover",position:{x:$[0],y:$[1]}})},!1);var O,M,R,k,P,B,z,G,F,U,Y,W,K,j=function(I,$,J,q){return Math.sqrt((J-I)*(J-I)+(q-$)*(q-$))},_=function(I,$,J,q){return(J-I)*(J-I)+(q-$)*(q-$)},V;t.registerBinding(t.container,"touchstart",V=function(I){if(t.hasTouchStarted=!0,!!x(I)){b(),t.touchData.capture=!0,t.data.bgActivePosistion=void 0;var $=t.cy,J=t.touchData.now,q=t.touchData.earlier;if(I.touches[0]){var X=t.projectIntoViewport(I.touches[0].clientX,I.touches[0].clientY);J[0]=X[0],J[1]=X[1]}if(I.touches[1]){var X=t.projectIntoViewport(I.touches[1].clientX,I.touches[1].clientY);J[2]=X[0],J[3]=X[1]}if(I.touches[2]){var X=t.projectIntoViewport(I.touches[2].clientX,I.touches[2].clientY);J[4]=X[0],J[5]=X[1]}if(I.touches[1]){t.touchData.singleTouchMoved=!0,g(t.dragData.touchDragEles);var ae=t.findContainerClientCoords();F=ae[0],U=ae[1],Y=ae[2],W=ae[3],O=I.touches[0].clientX-F,M=I.touches[0].clientY-U,R=I.touches[1].clientX-F,k=I.touches[1].clientY-U,K=0<=O&&O<=Y&&0<=R&&R<=Y&&0<=M&&M<=W&&0<=k&&k<=W;var Z=$.pan(),re=$.zoom();P=j(O,M,R,k),B=_(O,M,R,k),z=[(O+R)/2,(M+k)/2],G=[(z[0]-Z.x)/re,(z[1]-Z.y)/re];var ye=200,me=ye*ye;if(B=1){for(var Ze=t.touchData.startPosition=[null,null,null,null,null,null],Ue=0;Ue=t.touchTapThreshold2}if($&&t.touchData.cxt){I.preventDefault();var Ze=I.touches[0].clientX-F,Ue=I.touches[0].clientY-U,ct=I.touches[1].clientX-F,Qe=I.touches[1].clientY-U,ft=_(Ze,Ue,ct,Qe),xt=ft/B,mt=150,vt=mt*mt,It=1.5,Vt=It*It;if(xt>=Vt||ft>=vt){t.touchData.cxt=!1,t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var Tt={originalEvent:I,type:"cxttapend",position:{x:X[0],y:X[1]}};t.touchData.start?(t.touchData.start.unactivate().emit(Tt),t.touchData.start=null):q.emit(Tt)}}if($&&t.touchData.cxt){var Tt={originalEvent:I,type:"cxtdrag",position:{x:X[0],y:X[1]}};t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.touchData.start?t.touchData.start.emit(Tt):q.emit(Tt),t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxtDragged=!0;var $e=t.findNearestElement(X[0],X[1],!0,!0);(!t.touchData.cxtOver||$e!==t.touchData.cxtOver)&&(t.touchData.cxtOver&&t.touchData.cxtOver.emit({originalEvent:I,type:"cxtdragout",position:{x:X[0],y:X[1]}}),t.touchData.cxtOver=$e,$e&&$e.emit({originalEvent:I,type:"cxtdragover",position:{x:X[0],y:X[1]}}))}else if($&&I.touches[2]&&q.boxSelectionEnabled())I.preventDefault(),t.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,t.touchData.selecting||q.emit({originalEvent:I,type:"boxstart",position:{x:X[0],y:X[1]}}),t.touchData.selecting=!0,t.touchData.didSelect=!0,J[4]=1,!J||J.length===0||J[0]===void 0?(J[0]=(X[0]+X[2]+X[4])/3,J[1]=(X[1]+X[3]+X[5])/3,J[2]=(X[0]+X[2]+X[4])/3+1,J[3]=(X[1]+X[3]+X[5])/3+1):(J[2]=(X[0]+X[2]+X[4])/3,J[3]=(X[1]+X[3]+X[5])/3),t.redrawHint("select",!0),t.redraw();else if($&&I.touches[1]&&!t.touchData.didSelect&&q.zoomingEnabled()&&q.panningEnabled()&&q.userZoomingEnabled()&&q.userPanningEnabled()){I.preventDefault(),t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var We=t.dragData.touchDragEles;if(We){t.redrawHint("drag",!0);for(var at=0;at0&&!t.hoverData.draggingEles&&!t.swipePanning&&t.data.bgActivePosistion!=null&&(t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.redraw())}},!1);var Q;t.registerBinding(e,"touchcancel",Q=function(I){var $=t.touchData.start;t.touchData.capture=!1,$&&$.unactivate()});var ne,ce,te,se;if(t.registerBinding(e,"touchend",ne=function(I){var $=t.touchData.start,J=t.touchData.capture;if(J)I.touches.length===0&&(t.touchData.capture=!1),I.preventDefault();else return;var q=t.selection;t.swipePanning=!1,t.hoverData.draggingEles=!1;var X=t.cy,ae=X.zoom(),Z=t.touchData.now,re=t.touchData.earlier;if(I.touches[0]){var ye=t.projectIntoViewport(I.touches[0].clientX,I.touches[0].clientY);Z[0]=ye[0],Z[1]=ye[1]}if(I.touches[1]){var ye=t.projectIntoViewport(I.touches[1].clientX,I.touches[1].clientY);Z[2]=ye[0],Z[3]=ye[1]}if(I.touches[2]){var ye=t.projectIntoViewport(I.touches[2].clientX,I.touches[2].clientY);Z[4]=ye[0],Z[5]=ye[1]}$&&$.unactivate();var me;if(t.touchData.cxt){if(me={originalEvent:I,type:"cxttapend",position:{x:Z[0],y:Z[1]}},$?$.emit(me):X.emit(me),!t.touchData.cxtDragged){var he={originalEvent:I,type:"cxttap",position:{x:Z[0],y:Z[1]}};$?$.emit(he):X.emit(he)}t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxt=!1,t.touchData.start=null,t.redraw();return}if(!I.touches[2]&&X.boxSelectionEnabled()&&t.touchData.selecting){t.touchData.selecting=!1;var Ee=X.collection(t.getAllInBox(q[0],q[1],q[2],q[3]));q[0]=void 0,q[1]=void 0,q[2]=void 0,q[3]=void 0,q[4]=0,t.redrawHint("select",!0),X.emit({type:"boxend",originalEvent:I,position:{x:Z[0],y:Z[1]}});var le=function(vt){return vt.selectable()&&!vt.selected()};Ee.emit("box").stdFilter(le).select().emit("boxselect"),Ee.nonempty()&&t.redrawHint("eles",!0),t.redraw()}if($!=null&&$.unactivate(),I.touches[2])t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);else if(!I.touches[1]){if(!I.touches[0]){if(!I.touches[0]){t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var ge=t.dragData.touchDragEles;if($!=null){var Fe=$._private.grabbed;g(ge),t.redrawHint("drag",!0),t.redrawHint("eles",!0),Fe&&($.emit("freeon"),ge.emit("free"),t.dragData.didDrag&&($.emit("dragfreeon"),ge.emit("dragfree"))),a($,["touchend","tapend","vmouseup","tapdragout"],I,{x:Z[0],y:Z[1]}),$.unactivate(),t.touchData.start=null}else{var Me=t.findNearestElement(Z[0],Z[1],!0,!0);a(Me,["touchend","tapend","vmouseup","tapdragout"],I,{x:Z[0],y:Z[1]})}var lt=t.touchData.startPosition[0]-Z[0],Ze=lt*lt,Ue=t.touchData.startPosition[1]-Z[1],ct=Ue*Ue,Qe=Ze+ct,ft=Qe*ae*ae;t.touchData.singleTouchMoved||($||X.$(":selected").unselect(["tapunselect"]),a($,["tap","vclick"],I,{x:Z[0],y:Z[1]}),ce=!1,I.timeStamp-se<=X.multiClickDebounceTime()?(te&&clearTimeout(te),ce=!0,se=null,a($,["dbltap","vdblclick"],I,{x:Z[0],y:Z[1]})):(te=setTimeout(function(){ce||a($,["onetap","voneclick"],I,{x:Z[0],y:Z[1]})},X.multiClickDebounceTime()),se=I.timeStamp)),$!=null&&!t.dragData.didDrag&&$._private.selectable&&ft"u"){var ue=[],ve=function(I){return{clientX:I.clientX,clientY:I.clientY,force:1,identifier:I.pointerId,pageX:I.pageX,pageY:I.pageY,radiusX:I.width/2,radiusY:I.height/2,screenX:I.screenX,screenY:I.screenY,target:I.target}},fe=function(I){return{event:I,touch:ve(I)}},pe=function(I){ue.push(fe(I))},Ae=function(I){for(var $=0;$0)return F[0]}return null},v=Object.keys(d),p=0;p0?c:Ao(i,s,e,r,a,n,o,u)},checkPoint:function(e,r,a,n,i,s,o,u){u=u==="auto"?pr(n,i):u;var l=2*u;if(Yt(e,r,this.points,s,o,n,i-l,[0,-1],a)||Yt(e,r,this.points,s,o,n-l,i,[0,-1],a))return!0;var f=n/2+2*a,h=i/2+2*a,d=[s-f,o-h,s-f,o,s+f,o,s+f,o-h];return!!(dt(e,r,d)||cr(e,r,l,l,s+n/2-u,o+i/2-u,a)||cr(e,r,l,l,s-n/2+u,o+i/2-u,a))}}};Ht.registerNodeShapes=function(){var t=this.nodeShapes={},e=this;this.generateEllipse(),this.generatePolygon("triangle",ht(3,0)),this.generateRoundPolygon("round-triangle",ht(3,0)),this.generatePolygon("rectangle",ht(4,0)),t.square=t.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();{var r=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",r),this.generateRoundPolygon("round-diamond",r)}this.generatePolygon("pentagon",ht(5,0)),this.generateRoundPolygon("round-pentagon",ht(5,0)),this.generatePolygon("hexagon",ht(6,0)),this.generateRoundPolygon("round-hexagon",ht(6,0)),this.generatePolygon("heptagon",ht(7,0)),this.generateRoundPolygon("round-heptagon",ht(7,0)),this.generatePolygon("octagon",ht(8,0)),this.generateRoundPolygon("round-octagon",ht(8,0));var a=new Array(20);{var n=Wn(5,0),i=Wn(5,Math.PI/5),s=.5*(3-Math.sqrt(5));s*=1.57;for(var o=0;o=e.deqFastCost*T)break}else if(l){if(b>=e.deqCost*c||b>=e.deqAvgCost*d)break}else if(m>=e.deqNoDrawCost*Yn)break;var C=e.deq(a,g,p);if(C.length>0)for(var S=0;S0&&(e.onDeqd(a,v),!l&&e.shouldRedraw(a,v,g,p)&&i())},o=e.priority||mi;n.beforeRender(s,o(a))}}}},jg=function(){function t(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:an;vi(this,t),this.idsByKey=new Bt,this.keyForId=new Bt,this.cachesByLvl=new Bt,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=r}return di(t,[{key:"getIdsFor",value:function(r){r==null&&ze("Can not get id list for null key");var a=this.idsByKey,n=this.idsByKey.get(r);return n||(n=new Ur,a.set(r,n)),n}},{key:"addIdForKey",value:function(r,a){r!=null&&this.getIdsFor(r).add(a)}},{key:"deleteIdForKey",value:function(r,a){r!=null&&this.getIdsFor(r).delete(a)}},{key:"getNumberOfIdsForKey",value:function(r){return r==null?0:this.getIdsFor(r).size}},{key:"updateKeyMappingFor",value:function(r){var a=r.id(),n=this.keyForId.get(a),i=this.getKey(r);this.deleteIdForKey(n,a),this.addIdForKey(i,a),this.keyForId.set(a,i)}},{key:"deleteKeyMappingFor",value:function(r){var a=r.id(),n=this.keyForId.get(a);this.deleteIdForKey(n,a),this.keyForId.delete(a)}},{key:"keyHasChangedFor",value:function(r){var a=r.id(),n=this.keyForId.get(a),i=this.getKey(r);return n!==i}},{key:"isInvalid",value:function(r){return this.keyHasChangedFor(r)||this.doesEleInvalidateKey(r)}},{key:"getCachesAt",value:function(r){var a=this.cachesByLvl,n=this.lvls,i=a.get(r);return i||(i=new Bt,a.set(r,i),n.push(r)),i}},{key:"getCache",value:function(r,a){return this.getCachesAt(a).get(r)}},{key:"get",value:function(r,a){var n=this.getKey(r),i=this.getCache(n,a);return i!=null&&this.updateKeyMappingFor(r),i}},{key:"getForCachedKey",value:function(r,a){var n=this.keyForId.get(r.id()),i=this.getCache(n,a);return i}},{key:"hasCache",value:function(r,a){return this.getCachesAt(a).has(r)}},{key:"has",value:function(r,a){var n=this.getKey(r);return this.hasCache(n,a)}},{key:"setCache",value:function(r,a,n){n.key=r,this.getCachesAt(a).set(r,n)}},{key:"set",value:function(r,a,n){var i=this.getKey(r);this.setCache(i,a,n),this.updateKeyMappingFor(r)}},{key:"deleteCache",value:function(r,a){this.getCachesAt(a).delete(r)}},{key:"delete",value:function(r,a){var n=this.getKey(r);this.deleteCache(n,a)}},{key:"invalidateKey",value:function(r){var a=this;this.lvls.forEach(function(n){return a.deleteCache(r,n)})}},{key:"invalidate",value:function(r){var a=r.id(),n=this.keyForId.get(a);this.deleteKeyMappingFor(r);var i=this.doesEleInvalidateKey(r);return i&&this.invalidateKey(n),i||this.getNumberOfIdsForKey(n)===0}}]),t}(),qs=25,Ya=50,Ja=-4,si=3,ep=7.99,tp=8,rp=1024,ap=1024,np=1024,ip=.2,sp=.8,op=10,up=.15,lp=.1,fp=.9,hp=.9,cp=100,vp=1,Mr={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},dp=tt({getKey:null,doesEleInvalidateKey:an,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Eo,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),ua=function(e,r){var a=this;a.renderer=e,a.onDequeues=[];var n=dp(r);be(a,n),a.lookup=new jg(n.getKey,n.doesEleInvalidateKey),a.setupDequeueing()},qe=ua.prototype;qe.reasons=Mr;qe.getTextureQueue=function(t){var e=this;return e.eleImgCaches=e.eleImgCaches||{},e.eleImgCaches[t]=e.eleImgCaches[t]||[]};qe.getRetiredTextureQueue=function(t){var e=this,r=e.eleImgCaches.retired=e.eleImgCaches.retired||{},a=r[t]=r[t]||[];return a};qe.getElementQueue=function(){var t=this,e=t.eleCacheQueue=t.eleCacheQueue||new Da(function(r,a){return a.reqs-r.reqs});return e};qe.getElementKeyToQueue=function(){var t=this,e=t.eleKeyToCacheQueue=t.eleKeyToCacheQueue||{};return e};qe.getElement=function(t,e,r,a,n){var i=this,s=this.renderer,o=s.cy.zoom(),u=this.lookup;if(!e||e.w===0||e.h===0||isNaN(e.w)||isNaN(e.h)||!t.visible()||t.removed()||!i.allowEdgeTxrCaching&&t.isEdge()||!i.allowParentTxrCaching&&t.isParent())return null;if(a==null&&(a=Math.ceil(Ei(o*r))),a=ep||a>si)return null;var l=Math.pow(2,a),f=e.h*l,h=e.w*l,d=s.eleTextBiggerThanMin(t,l);if(!this.isVisible(t,d))return null;var c=u.get(t,a);if(c&&c.invalidated&&(c.invalidated=!1,c.texture.invalidatedWidth-=c.width),c)return c;var v;if(f<=qs?v=qs:f<=Ya?v=Ya:v=Math.ceil(f/Ya)*Ya,f>np||h>ap)return null;var p=i.getTextureQueue(v),g=p[p.length-2],y=function(){return i.recycleTexture(v,h)||i.addTexture(v,h)};g||(g=p[p.length-1]),g||(g=y()),g.width-g.usedWidtha;L--)x=i.getElement(t,e,r,L,Mr.downscale);D()}else return i.queueElement(t,S.level-1),S;else{var A;if(!m&&!T&&!C)for(var N=a-1;N>=Ja;N--){var O=u.get(t,N);if(O){A=O;break}}if(b(A))return i.queueElement(t,a),A;g.context.translate(g.usedWidth,0),g.context.scale(l,l),this.drawElement(g.context,t,e,d,!1),g.context.scale(1/l,1/l),g.context.translate(-g.usedWidth,0)}return c={x:g.usedWidth,texture:g,level:a,scale:l,width:h,height:f,scaledLabelShown:d},g.usedWidth+=Math.ceil(h+tp),g.eleCaches.push(c),u.set(t,a,c),i.checkTextureFullness(g),c};qe.invalidateElements=function(t){for(var e=0;e=ip*t.width&&this.retireTexture(t)};qe.checkTextureFullness=function(t){var e=this,r=e.getTextureQueue(t.height);t.usedWidth/t.width>sp&&t.fullnessChecks>=op?er(r,t):t.fullnessChecks++};qe.retireTexture=function(t){var e=this,r=t.height,a=e.getTextureQueue(r),n=this.lookup;er(a,t),t.retired=!0;for(var i=t.eleCaches,s=0;s=e)return s.retired=!1,s.usedWidth=0,s.invalidatedWidth=0,s.fullnessChecks=0,bi(s.eleCaches),s.context.setTransform(1,0,0,1,0,0),s.context.clearRect(0,0,s.width,s.height),er(n,s),a.push(s),s}};qe.queueElement=function(t,e){var r=this,a=r.getElementQueue(),n=r.getElementKeyToQueue(),i=this.getKey(t),s=n[i];if(s)s.level=Math.max(s.level,e),s.eles.merge(t),s.reqs++,a.updateItem(s);else{var o={eles:t.spawn().merge(t),level:e,reqs:1,key:i};a.push(o),n[i]=o}};qe.dequeue=function(t){for(var e=this,r=e.getElementQueue(),a=e.getElementKeyToQueue(),n=[],i=e.lookup,s=0;s0;s++){var o=r.pop(),u=o.key,l=o.eles[0],f=i.hasCache(l,o.level);if(a[u]=null,f)continue;n.push(o);var h=e.getBoundingBox(l);e.getElement(l,h,t,o.level,Mr.dequeue)}return n};qe.removeFromQueue=function(t){var e=this,r=e.getElementQueue(),a=e.getElementKeyToQueue(),n=this.getKey(t),i=a[n];i!=null&&(i.eles.length===1?(i.reqs=yi,r.updateItem(i),r.pop(),a[n]=null):i.eles.unmerge(t))};qe.onDequeue=function(t){this.onDequeues.push(t)};qe.offDequeue=function(t){er(this.onDequeues,t)};qe.setupDequeueing=Ou.setupDequeueing({deqRedrawThreshold:cp,deqCost:up,deqAvgCost:lp,deqNoDrawCost:fp,deqFastCost:hp,deq:function(e,r,a){return e.dequeue(r,a)},onDeqd:function(e,r){for(var a=0;a=pp||r>cn)return null}a.validateLayersElesOrdering(r,t);var u=a.layersByLevel,l=Math.pow(2,r),f=u[r]=u[r]||[],h,d=a.levelIsComplete(r,t),c,v=function(){var D=function(M){if(a.validateLayersElesOrdering(M,t),a.levelIsComplete(M,t))return c=u[M],!0},L=function(M){if(!c)for(var R=r+M;fa<=R&&R<=cn&&!D(R);R+=M);};L(1),L(-1);for(var A=f.length-1;A>=0;A--){var N=f[A];N.invalid&&er(f,N)}};if(!d)v();else return f;var p=function(){if(!h){h=gt();for(var D=0;DCp)return null;var N=a.makeLayer(h,r);if(L!=null){var O=f.indexOf(L)+1;f.splice(O,0,N)}else(D.insert===void 0||D.insert)&&f.unshift(N);return N};if(a.skipping&&!o)return null;for(var y=null,b=t.length/gp,m=!o,T=0;T=b||!Lo(y.bb,C.boundingBox()))&&(y=g({insert:!0,after:y}),!y))return null;c||m?a.queueLayer(y,C):a.drawEleInLayer(y,C,r,e),y.eles.push(C),E[r]=y}return c||(m?null:f)};rt.getEleLevelForLayerLevel=function(t,e){return t};rt.drawEleInLayer=function(t,e,r,a){var n=this,i=this.renderer,s=t.context,o=e.boundingBox();o.w===0||o.h===0||!e.visible()||(r=n.getEleLevelForLayerLevel(r,a),i.setImgSmoothing(s,!1),i.drawCachedElement(s,e,null,null,r,Dp),i.setImgSmoothing(s,!0))};rt.levelIsComplete=function(t,e){var r=this,a=r.layersByLevel[t];if(!a||a.length===0)return!1;for(var n=0,i=0;i0||s.invalid)return!1;n+=s.eles.length}return n===e.length};rt.validateLayersElesOrdering=function(t,e){var r=this.layersByLevel[t];if(r)for(var a=0;a0){e=!0;break}}return e};rt.invalidateElements=function(t){var e=this;t.length!==0&&(e.lastInvalidationTime=$t(),!(t.length===0||!e.haveLayers())&&e.updateElementsInLayers(t,function(a,n,i){e.invalidateLayer(a)}))};rt.invalidateLayer=function(t){if(this.lastInvalidationTime=$t(),!t.invalid){var e=t.level,r=t.eles,a=this.layersByLevel[e];er(a,t),t.elesQueue=[],t.invalid=!0,t.replacement&&(t.replacement.invalid=!0);for(var n=0;n3&&arguments[3]!==void 0?arguments[3]:!0,n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,s=this,o=e._private.rscratch;if(!(i&&!e.visible())&&!(o.badLine||o.allpts==null||isNaN(o.allpts[0]))){var u;r&&(u=r,t.translate(-u.x1,-u.y1));var l=i?e.pstyle("opacity").value:1,f=i?e.pstyle("line-opacity").value:1,h=e.pstyle("curve-style").value,d=e.pstyle("line-style").value,c=e.pstyle("width").pfValue,v=e.pstyle("line-cap").value,p=e.pstyle("line-outline-width").value,g=e.pstyle("line-outline-color").value,y=l*f,b=l*f,m=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y;h==="straight-triangle"?(s.eleStrokeStyle(t,e,M),s.drawEdgeTrianglePath(e,t,o.allpts)):(t.lineWidth=c,t.lineCap=v,s.eleStrokeStyle(t,e,M),s.drawEdgePath(e,t,o.allpts,d),t.lineCap="butt")},T=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y;if(t.lineWidth=c+p,t.lineCap=v,p>0)s.colorStrokeStyle(t,g[0],g[1],g[2],M);else{t.lineCap="butt";return}h==="straight-triangle"?s.drawEdgeTrianglePath(e,t,o.allpts):(s.drawEdgePath(e,t,o.allpts,d),t.lineCap="butt")},C=function(){n&&s.drawEdgeOverlay(t,e)},S=function(){n&&s.drawEdgeUnderlay(t,e)},E=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:b;s.drawArrowheads(t,e,M)},w=function(){s.drawElementText(t,e,null,a)};t.lineJoin="round";var x=e.pstyle("ghost").value==="yes";if(x){var D=e.pstyle("ghost-offset-x").pfValue,L=e.pstyle("ghost-offset-y").pfValue,A=e.pstyle("ghost-opacity").value,N=y*A;t.translate(D,L),m(N),E(N),t.translate(-D,-L)}else T();S(),m(),E(),C(),w(),r&&t.translate(u.x1,u.y1)}};var Mu=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(r,a){if(a.visible()){var n=a.pstyle("".concat(e,"-opacity")).value;if(n!==0){var i=this,s=i.usePaths(),o=a._private.rscratch,u=a.pstyle("".concat(e,"-padding")).pfValue,l=2*u,f=a.pstyle("".concat(e,"-color")).value;r.lineWidth=l,o.edgeType==="self"&&!s?r.lineCap="butt":r.lineCap="round",i.colorStrokeStyle(r,f[0],f[1],f[2],n),i.drawEdgePath(a,r,o.allpts,"solid")}}}};Xt.drawEdgeOverlay=Mu("overlay");Xt.drawEdgeUnderlay=Mu("underlay");Xt.drawEdgePath=function(t,e,r,a){var n=t._private.rscratch,i=e,s,o=!1,u=this.usePaths(),l=t.pstyle("line-dash-pattern").pfValue,f=t.pstyle("line-dash-offset").pfValue;if(u){var h=r.join("$"),d=n.pathCacheKey&&n.pathCacheKey===h;d?(s=e=n.pathCache,o=!0):(s=e=new Path2D,n.pathCacheKey=h,n.pathCache=s)}if(i.setLineDash)switch(a){case"dotted":i.setLineDash([1,1]);break;case"dashed":i.setLineDash(l),i.lineDashOffset=f;break;case"solid":i.setLineDash([]);break}if(!o&&!n.badLine)switch(e.beginPath&&e.beginPath(),e.moveTo(r[0],r[1]),n.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var c=2;c+35&&arguments[5]!==void 0?arguments[5]:!0,s=this;if(a==null){if(i&&!s.eleTextBiggerThanMin(e))return}else if(a===!1)return;if(e.isNode()){var o=e.pstyle("label");if(!o||!o.value)return;var u=s.getLabelJustification(e);t.textAlign=u,t.textBaseline="bottom"}else{var l=e.element()._private.rscratch.badLine,f=e.pstyle("label"),h=e.pstyle("source-label"),d=e.pstyle("target-label");if(l||(!f||!f.value)&&(!h||!h.value)&&(!d||!d.value))return;t.textAlign="center",t.textBaseline="bottom"}var c=!r,v;r&&(v=r,t.translate(-v.x1,-v.y1)),n==null?(s.drawText(t,e,null,c,i),e.isEdge()&&(s.drawText(t,e,"source",c,i),s.drawText(t,e,"target",c,i))):s.drawText(t,e,n,c,i),r&&t.translate(v.x1,v.y1)};xr.getFontCache=function(t){var e;this.fontCaches=this.fontCaches||[];for(var r=0;r2&&arguments[2]!==void 0?arguments[2]:!0,a=e.pstyle("font-style").strValue,n=e.pstyle("font-size").pfValue+"px",i=e.pstyle("font-family").strValue,s=e.pstyle("font-weight").strValue,o=r?e.effectiveOpacity()*e.pstyle("text-opacity").value:1,u=e.pstyle("text-outline-opacity").value*o,l=e.pstyle("color").value,f=e.pstyle("text-outline-color").value;t.font=a+" "+s+" "+n+" "+i,t.lineJoin="round",this.colorFillStyle(t,l[0],l[1],l[2],o),this.colorStrokeStyle(t,f[0],f[1],f[2],u)};function Hn(t,e,r,a,n){var i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:5,s=arguments.length>6?arguments[6]:void 0;t.beginPath(),t.moveTo(e+i,r),t.lineTo(e+a-i,r),t.quadraticCurveTo(e+a,r,e+a,r+i),t.lineTo(e+a,r+n-i),t.quadraticCurveTo(e+a,r+n,e+a-i,r+n),t.lineTo(e+i,r+n),t.quadraticCurveTo(e,r+n,e,r+n-i),t.lineTo(e,r+i),t.quadraticCurveTo(e,r,e+i,r),t.closePath(),s?t.stroke():t.fill()}xr.getTextAngle=function(t,e){var r,a=t._private,n=a.rscratch,i=e?e+"-":"",s=t.pstyle(i+"text-rotation"),o=At(n,"labelAngle",e);return s.strValue==="autorotate"?r=t.isEdge()?o:0:s.strValue==="none"?r=0:r=s.pfValue,r};xr.drawText=function(t,e,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=e._private,s=i.rscratch,o=n?e.effectiveOpacity():1;if(!(n&&(o===0||e.pstyle("text-opacity").value===0))){r==="main"&&(r=null);var u=At(s,"labelX",r),l=At(s,"labelY",r),f,h,d=this.getLabelText(e,r);if(d!=null&&d!==""&&!isNaN(u)&&!isNaN(l)){this.setupTextStyle(t,e,n);var c=r?r+"-":"",v=At(s,"labelWidth",r),p=At(s,"labelHeight",r),g=e.pstyle(c+"text-margin-x").pfValue,y=e.pstyle(c+"text-margin-y").pfValue,b=e.isEdge(),m=e.pstyle("text-halign").value,T=e.pstyle("text-valign").value;b&&(m="center",T="center"),u+=g,l+=y;var C;switch(a?C=this.getTextAngle(e,r):C=0,C!==0&&(f=u,h=l,t.translate(f,h),t.rotate(C),u=0,l=0),T){case"top":break;case"center":l+=p/2;break;case"bottom":l+=p;break}var S=e.pstyle("text-background-opacity").value,E=e.pstyle("text-border-opacity").value,w=e.pstyle("text-border-width").pfValue,x=e.pstyle("text-background-padding").pfValue,D=e.pstyle("text-background-shape").strValue,L=D.indexOf("round")===0,A=2;if(S>0||w>0&&E>0){var N=u-x;switch(m){case"left":N-=v;break;case"center":N-=v/2;break}var O=l-p-x,M=v+2*x,R=p+2*x;if(S>0){var k=t.fillStyle,P=e.pstyle("text-background-color").value;t.fillStyle="rgba("+P[0]+","+P[1]+","+P[2]+","+S*o+")",L?Hn(t,N,O,M,R,A):t.fillRect(N,O,M,R),t.fillStyle=k}if(w>0&&E>0){var B=t.strokeStyle,z=t.lineWidth,G=e.pstyle("text-border-color").value,F=e.pstyle("text-border-style").value;if(t.strokeStyle="rgba("+G[0]+","+G[1]+","+G[2]+","+E*o+")",t.lineWidth=w,t.setLineDash)switch(F){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"double":t.lineWidth=w/4,t.setLineDash([]);break;case"solid":t.setLineDash([]);break}if(L?Hn(t,N,O,M,R,A,"stroke"):t.strokeRect(N,O,M,R),F==="double"){var U=w/2;L?Hn(t,N+U,O+U,M-U*2,R-U*2,A,"stroke"):t.strokeRect(N+U,O+U,M-U*2,R-U*2)}t.setLineDash&&t.setLineDash([]),t.lineWidth=z,t.strokeStyle=B}}var Y=2*e.pstyle("text-outline-width").pfValue;if(Y>0&&(t.lineWidth=Y),e.pstyle("text-wrap").value==="wrap"){var W=At(s,"labelWrapCachedLines",r),K=At(s,"labelLineHeight",r),j=v/2,_=this.getLabelJustification(e);switch(_==="auto"||(m==="left"?_==="left"?u+=-v:_==="center"&&(u+=-j):m==="center"?_==="left"?u+=-j:_==="right"&&(u+=j):m==="right"&&(_==="center"?u+=j:_==="right"&&(u+=v))),T){case"top":l-=(W.length-1)*K;break;case"center":case"bottom":l-=(W.length-1)*K;break}for(var V=0;V0&&t.strokeText(W[V],u,l),t.fillText(W[V],u,l),l+=K}else Y>0&&t.strokeText(d,u,l),t.fillText(d,u,l);C!==0&&(t.rotate(-C),t.translate(-f,-h))}}};var Zr={};Zr.drawNode=function(t,e,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,s=this,o,u,l=e._private,f=l.rscratch,h=e.position();if(!(!ie(h.x)||!ie(h.y))&&!(i&&!e.visible())){var d=i?e.effectiveOpacity():1,c=s.usePaths(),v,p=!1,g=e.padding();o=e.width()+2*g,u=e.height()+2*g;var y;r&&(y=r,t.translate(-y.x1,-y.y1));for(var b=e.pstyle("background-image"),m=b.value,T=new Array(m.length),C=new Array(m.length),S=0,E=0;E0&&arguments[0]!==void 0?arguments[0]:N;s.eleFillStyle(t,e,ae)},V=function(){var ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:G;s.colorStrokeStyle(t,O[0],O[1],O[2],ae)},H=function(){var ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:W;s.colorStrokeStyle(t,U[0],U[1],U[2],ae)},Q=function(ae,Z,re,ye){var me=s.nodePathCache=s.nodePathCache||[],he=bo(re==="polygon"?re+","+ye.join(","):re,""+Z,""+ae,""+j),Ee=me[he],le,ge=!1;return Ee!=null?(le=Ee,ge=!0,f.pathCache=le):(le=new Path2D,me[he]=f.pathCache=le),{path:le,cacheHit:ge}},ne=e.pstyle("shape").strValue,ce=e.pstyle("shape-polygon-points").pfValue;if(c){t.translate(h.x,h.y);var te=Q(o,u,ne,ce);v=te.path,p=te.cacheHit}var se=function(){if(!p){var ae=h;c&&(ae={x:0,y:0}),s.nodeShapes[s.getNodeShape(e)].draw(v||t,ae.x,ae.y,o,u,j,f)}c?t.fill(v):t.fill()},ue=function(){for(var ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:d,Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,re=l.backgrounding,ye=0,me=0;me0&&arguments[0]!==void 0?arguments[0]:!1,Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:d;s.hasPie(e)&&(s.drawPie(t,e,Z),ae&&(c||s.nodeShapes[s.getNodeShape(e)].draw(t,h.x,h.y,o,u,j,f)))},fe=function(){var ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:d,Z=(L>0?L:-L)*ae,re=L>0?0:255;L!==0&&(s.colorFillStyle(t,re,re,re,Z),c?t.fill(v):t.fill())},pe=function(){if(A>0){if(t.lineWidth=A,t.lineCap=k,t.lineJoin=R,t.setLineDash)switch(M){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash(B),t.lineDashOffset=z;break;case"solid":case"double":t.setLineDash([]);break}if(P!=="center"){if(t.save(),t.lineWidth*=2,P==="inside")c?t.clip(v):t.clip();else{var ae=new Path2D;ae.rect(-o/2-A,-u/2-A,o+2*A,u+2*A),ae.addPath(v),t.clip(ae,"evenodd")}c?t.stroke(v):t.stroke(),t.restore()}else c?t.stroke(v):t.stroke();if(M==="double"){t.lineWidth=A/3;var Z=t.globalCompositeOperation;t.globalCompositeOperation="destination-out",c?t.stroke(v):t.stroke(),t.globalCompositeOperation=Z}t.setLineDash&&t.setLineDash([])}},Ae=function(){if(F>0){if(t.lineWidth=F,t.lineCap="butt",t.setLineDash)switch(Y){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"solid":case"double":t.setLineDash([]);break}var ae=h;c&&(ae={x:0,y:0});var Z=s.getNodeShape(e),re=A;P==="inside"&&(re=0),P==="outside"&&(re*=2);var ye=(o+re+(F+K))/o,me=(u+re+(F+K))/u,he=o*ye,Ee=u*me,le=s.nodeShapes[Z].points,ge;if(c){var Fe=Q(he,Ee,Z,le);ge=Fe.path}if(Z==="ellipse")s.drawEllipsePath(ge||t,ae.x,ae.y,he,Ee);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(Z)){var Me=0,lt=0,Ze=0;Z==="round-diamond"?Me=(re+K+F)*1.4:Z==="round-heptagon"?(Me=(re+K+F)*1.075,Ze=-(re/2+K+F)/35):Z==="round-hexagon"?Me=(re+K+F)*1.12:Z==="round-pentagon"?(Me=(re+K+F)*1.13,Ze=-(re/2+K+F)/15):Z==="round-tag"?(Me=(re+K+F)*1.12,lt=(re/2+F+K)*.07):Z==="round-triangle"&&(Me=(re+K+F)*(Math.PI/2),Ze=-(re+K/2+F)/Math.PI),Me!==0&&(ye=(o+Me)/o,he=o*ye,["round-hexagon","round-tag"].includes(Z)||(me=(u+Me)/u,Ee=u*me)),j=j==="auto"?No(he,Ee):j;for(var Ue=he/2,ct=Ee/2,Qe=j+(re+F+K)/2,ft=new Array(le.length/2),xt=new Array(le.length/2),mt=0;mt0){if(n=n||a.position(),i==null||s==null){var c=a.padding();i=a.width()+2*c,s=a.height()+2*c}o.colorFillStyle(r,f[0],f[1],f[2],l),o.nodeShapes[h].draw(r,n.x,n.y,i+u*2,s+u*2,d),r.fill()}}}};Zr.drawNodeOverlay=Ru("overlay");Zr.drawNodeUnderlay=Ru("underlay");Zr.hasPie=function(t){return t=t[0],t._private.hasPie};Zr.drawPie=function(t,e,r,a){e=e[0],a=a||e.position();var n=e.cy().style(),i=e.pstyle("pie-size"),s=a.x,o=a.y,u=e.width(),l=e.height(),f=Math.min(u,l)/2,h=0,d=this.usePaths();d&&(s=0,o=0),i.units==="%"?f=f*i.pfValue:i.pfValue!==void 0&&(f=i.pfValue/2);for(var c=1;c<=n.pieBackgroundN;c++){var v=e.pstyle("pie-"+c+"-background-size").value,p=e.pstyle("pie-"+c+"-background-color").value,g=e.pstyle("pie-"+c+"-background-opacity").value*r,y=v/100;y+h>1&&(y=1-h);var b=1.5*Math.PI+2*Math.PI*h,m=2*Math.PI*y,T=b+m;v===0||h>=1||h+y>1||(t.beginPath(),t.moveTo(s,o),t.arc(s,o,f,b,T),t.closePath(),this.colorFillStyle(t,p[0],p[1],p[2],g),t.fill(),h+=y)}};var yt={},Bp=100;yt.getPixelRatio=function(){var t=this.data.contexts[0];if(this.forcedPixelRatio!=null)return this.forcedPixelRatio;var e=this.cy.window(),r=t.backingStorePixelRatio||t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return(e.devicePixelRatio||1)/r};yt.paintCache=function(t){for(var e=this.paintCaches=this.paintCaches||[],r=!0,a,n=0;ns.minMbLowQualFrames&&(s.motionBlurPxRatio=s.mbPxRBlurry)),s.clearingMotionBlur&&(s.motionBlurPxRatio=1),s.textureDrawLastFrame&&!h&&(f[s.NODE]=!0,f[s.SELECT_BOX]=!0);var b=u.style(),m=u.zoom(),T=n!==void 0?n:m,C=u.pan(),S={x:C.x,y:C.y},E={zoom:m,pan:{x:C.x,y:C.y}},w=s.prevViewport,x=w===void 0||E.zoom!==w.zoom||E.pan.x!==w.pan.x||E.pan.y!==w.pan.y;!x&&!(p&&!v)&&(s.motionBlurPxRatio=1),i&&(S=i),T*=o,S.x*=o,S.y*=o;var D=s.getCachedZSortedEles();function L(te,se,ue,ve,fe){var pe=te.globalCompositeOperation;te.globalCompositeOperation="destination-out",s.colorFillStyle(te,255,255,255,s.motionBlurTransparency),te.fillRect(se,ue,ve,fe),te.globalCompositeOperation=pe}function A(te,se){var ue,ve,fe,pe;!s.clearingMotionBlur&&(te===l.bufferContexts[s.MOTIONBLUR_BUFFER_NODE]||te===l.bufferContexts[s.MOTIONBLUR_BUFFER_DRAG])?(ue={x:C.x*c,y:C.y*c},ve=m*c,fe=s.canvasWidth*c,pe=s.canvasHeight*c):(ue=S,ve=T,fe=s.canvasWidth,pe=s.canvasHeight),te.setTransform(1,0,0,1,0,0),se==="motionBlur"?L(te,0,0,fe,pe):!e&&(se===void 0||se)&&te.clearRect(0,0,fe,pe),r||(te.translate(ue.x,ue.y),te.scale(ve,ve)),i&&te.translate(i.x,i.y),n&&te.scale(n,n)}if(h||(s.textureDrawLastFrame=!1),h){if(s.textureDrawLastFrame=!0,!s.textureCache){s.textureCache={},s.textureCache.bb=u.mutableElements().boundingBox(),s.textureCache.texture=s.data.bufferCanvases[s.TEXTURE_BUFFER];var N=s.data.bufferContexts[s.TEXTURE_BUFFER];N.setTransform(1,0,0,1,0,0),N.clearRect(0,0,s.canvasWidth*s.textureMult,s.canvasHeight*s.textureMult),s.render({forcedContext:N,drawOnlyNodeLayer:!0,forcedPxRatio:o*s.textureMult});var E=s.textureCache.viewport={zoom:u.zoom(),pan:u.pan(),width:s.canvasWidth,height:s.canvasHeight};E.mpan={x:(0-E.pan.x)/E.zoom,y:(0-E.pan.y)/E.zoom}}f[s.DRAG]=!1,f[s.NODE]=!1;var O=l.contexts[s.NODE],M=s.textureCache.texture,E=s.textureCache.viewport;O.setTransform(1,0,0,1,0,0),d?L(O,0,0,E.width,E.height):O.clearRect(0,0,E.width,E.height);var R=b.core("outside-texture-bg-color").value,k=b.core("outside-texture-bg-opacity").value;s.colorFillStyle(O,R[0],R[1],R[2],k),O.fillRect(0,0,E.width,E.height);var m=u.zoom();A(O,!1),O.clearRect(E.mpan.x,E.mpan.y,E.width/E.zoom/o,E.height/E.zoom/o),O.drawImage(M,E.mpan.x,E.mpan.y,E.width/E.zoom/o,E.height/E.zoom/o)}else s.textureOnViewport&&!e&&(s.textureCache=null);var P=u.extent(),B=s.pinching||s.hoverData.dragging||s.swipePanning||s.data.wheelZooming||s.hoverData.draggingEles||s.cy.animated(),z=s.hideEdgesOnViewport&&B,G=[];if(G[s.NODE]=!f[s.NODE]&&d&&!s.clearedForMotionBlur[s.NODE]||s.clearingMotionBlur,G[s.NODE]&&(s.clearedForMotionBlur[s.NODE]=!0),G[s.DRAG]=!f[s.DRAG]&&d&&!s.clearedForMotionBlur[s.DRAG]||s.clearingMotionBlur,G[s.DRAG]&&(s.clearedForMotionBlur[s.DRAG]=!0),f[s.NODE]||r||a||G[s.NODE]){var F=d&&!G[s.NODE]&&c!==1,O=e||(F?s.data.bufferContexts[s.MOTIONBLUR_BUFFER_NODE]:l.contexts[s.NODE]),U=d&&!F?"motionBlur":void 0;A(O,U),z?s.drawCachedNodes(O,D.nondrag,o,P):s.drawLayeredElements(O,D.nondrag,o,P),s.debug&&s.drawDebugPoints(O,D.nondrag),!r&&!d&&(f[s.NODE]=!1)}if(!a&&(f[s.DRAG]||r||G[s.DRAG])){var F=d&&!G[s.DRAG]&&c!==1,O=e||(F?s.data.bufferContexts[s.MOTIONBLUR_BUFFER_DRAG]:l.contexts[s.DRAG]);A(O,d&&!F?"motionBlur":void 0),z?s.drawCachedNodes(O,D.drag,o,P):s.drawCachedElements(O,D.drag,o,P),s.debug&&s.drawDebugPoints(O,D.drag),!r&&!d&&(f[s.DRAG]=!1)}if(s.showFps||!a&&f[s.SELECT_BOX]&&!r){var O=e||l.contexts[s.SELECT_BOX];if(A(O),s.selection[4]==1&&(s.hoverData.selecting||s.touchData.selecting)){var m=s.cy.zoom(),Y=b.core("selection-box-border-width").value/m;O.lineWidth=Y,O.fillStyle="rgba("+b.core("selection-box-color").value[0]+","+b.core("selection-box-color").value[1]+","+b.core("selection-box-color").value[2]+","+b.core("selection-box-opacity").value+")",O.fillRect(s.selection[0],s.selection[1],s.selection[2]-s.selection[0],s.selection[3]-s.selection[1]),Y>0&&(O.strokeStyle="rgba("+b.core("selection-box-border-color").value[0]+","+b.core("selection-box-border-color").value[1]+","+b.core("selection-box-border-color").value[2]+","+b.core("selection-box-opacity").value+")",O.strokeRect(s.selection[0],s.selection[1],s.selection[2]-s.selection[0],s.selection[3]-s.selection[1]))}if(l.bgActivePosistion&&!s.hoverData.selecting){var m=s.cy.zoom(),W=l.bgActivePosistion;O.fillStyle="rgba("+b.core("active-bg-color").value[0]+","+b.core("active-bg-color").value[1]+","+b.core("active-bg-color").value[2]+","+b.core("active-bg-opacity").value+")",O.beginPath(),O.arc(W.x,W.y,b.core("active-bg-size").pfValue/m,0,2*Math.PI),O.fill()}var K=s.lastRedrawTime;if(s.showFps&&K){K=Math.round(K);var j=Math.round(1e3/K);O.setTransform(1,0,0,1,0,0),O.fillStyle="rgba(255, 0, 0, 0.75)",O.strokeStyle="rgba(255, 0, 0, 0.75)",O.lineWidth=1,O.fillText("1 frame = "+K+" ms = "+j+" fps",0,20);var _=60;O.strokeRect(0,30,250,20),O.fillRect(0,30,250*Math.min(j/_,1),20)}r||(f[s.SELECT_BOX]=!1)}if(d&&c!==1){var V=l.contexts[s.NODE],H=s.data.bufferCanvases[s.MOTIONBLUR_BUFFER_NODE],Q=l.contexts[s.DRAG],ne=s.data.bufferCanvases[s.MOTIONBLUR_BUFFER_DRAG],ce=function(se,ue,ve){se.setTransform(1,0,0,1,0,0),ve||!y?se.clearRect(0,0,s.canvasWidth,s.canvasHeight):L(se,0,0,s.canvasWidth,s.canvasHeight);var fe=c;se.drawImage(ue,0,0,s.canvasWidth*fe,s.canvasHeight*fe,0,0,s.canvasWidth,s.canvasHeight)};(f[s.NODE]||G[s.NODE])&&(ce(V,H,G[s.NODE]),f[s.NODE]=!1),(f[s.DRAG]||G[s.DRAG])&&(ce(Q,ne,G[s.DRAG]),f[s.DRAG]=!1)}s.prevViewport=E,s.clearingMotionBlur&&(s.clearingMotionBlur=!1,s.motionBlurCleared=!0,s.motionBlur=!0),d&&(s.motionBlurTimeout=setTimeout(function(){s.motionBlurTimeout=null,s.clearedForMotionBlur[s.NODE]=!1,s.clearedForMotionBlur[s.DRAG]=!1,s.motionBlur=!1,s.clearingMotionBlur=!h,s.mbFrames=0,f[s.NODE]=!0,f[s.DRAG]=!0,s.redraw()},Bp)),e||u.emit("render")};var sr={};sr.drawPolygonPath=function(t,e,r,a,n,i){var s=a/2,o=n/2;t.beginPath&&t.beginPath(),t.moveTo(e+s*i[0],r+o*i[1]);for(var u=1;u0&&s>0){c.clearRect(0,0,i,s),c.globalCompositeOperation="source-over";var v=this.getCachedZSortedEles();if(t.full)c.translate(-a.x1*l,-a.y1*l),c.scale(l,l),this.drawElements(c,v),c.scale(1/l,1/l),c.translate(a.x1*l,a.y1*l);else{var p=e.pan(),g={x:p.x*l,y:p.y*l};l*=e.zoom(),c.translate(g.x,g.y),c.scale(l,l),this.drawElements(c,v),c.scale(1/l,1/l),c.translate(-g.x,-g.y)}t.bg&&(c.globalCompositeOperation="destination-over",c.fillStyle=t.bg,c.rect(0,0,i,s),c.fill())}return d};function Fp(t,e){for(var r=atob(t),a=new ArrayBuffer(r.length),n=new Uint8Array(a),i=0;i"u"?"undefined":Xe(OffscreenCanvas))!=="undefined")r=new OffscreenCanvas(t,e);else{var a=this.cy.window(),n=a.document;r=n.createElement("canvas"),r.width=t,r.height=e}return r};[Iu,zt,Xt,Bi,xr,Zr,yt,sr,Na,Bu].forEach(function(t){be(Se,t)});var Vp=[{name:"null",impl:mu},{name:"base",impl:Au},{name:"canvas",impl:Gp}],Up=[{type:"layout",extensions:qg},{type:"renderer",extensions:Vp}],Gu={},zu={};function Vu(t,e,r){var a=r,n=function(w){Ne("Can not register `"+e+"` for `"+t+"` since `"+w+"` already exists in the prototype and can not be overridden")};if(t==="core"){if(wa.prototype[e])return n(e);wa.prototype[e]=r}else if(t==="collection"){if(et.prototype[e])return n(e);et.prototype[e]=r}else if(t==="layout"){for(var i=function(w){this.options=w,r.call(this,w),Ce(this._private)||(this._private={}),this._private.cy=w.cy,this._private.listeners=[],this.createEmitter()},s=i.prototype=Object.create(r.prototype),o=[],u=0;uv&&(this.rect.x-=(this.labelWidth-v)/2,this.setWidth(this.labelWidth)),this.labelHeight>p&&(this.labelPos=="center"?this.rect.y-=(this.labelHeight-p)/2:this.labelPos=="top"&&(this.rect.y-=this.labelHeight-p),this.setHeight(this.labelHeight))}}},h.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==s.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},h.prototype.transform=function(c){var v=this.rect.x;v>u.WORLD_BOUNDARY?v=u.WORLD_BOUNDARY:v<-u.WORLD_BOUNDARY&&(v=-u.WORLD_BOUNDARY);var p=this.rect.y;p>u.WORLD_BOUNDARY?p=u.WORLD_BOUNDARY:p<-u.WORLD_BOUNDARY&&(p=-u.WORLD_BOUNDARY);var g=new f(v,p),y=c.inverseTransformPoint(g);this.setLocation(y.x,y.y)},h.prototype.getLeft=function(){return this.rect.x},h.prototype.getRight=function(){return this.rect.x+this.rect.width},h.prototype.getTop=function(){return this.rect.y},h.prototype.getBottom=function(){return this.rect.y+this.rect.height},h.prototype.getParent=function(){return this.owner==null?null:this.owner.getParent()},r.exports=h},function(r,a,n){function i(s,o){s==null&&o==null?(this.x=0,this.y=0):(this.x=s,this.y=o)}i.prototype.getX=function(){return this.x},i.prototype.getY=function(){return this.y},i.prototype.setX=function(s){this.x=s},i.prototype.setY=function(s){this.y=s},i.prototype.getDifference=function(s){return new DimensionD(this.x-s.x,this.y-s.y)},i.prototype.getCopy=function(){return new i(this.x,this.y)},i.prototype.translate=function(s){return this.x+=s.width,this.y+=s.height,this},r.exports=i},function(r,a,n){var i=n(2),s=n(10),o=n(0),u=n(6),l=n(3),f=n(1),h=n(13),d=n(12),c=n(11);function v(g,y,b){i.call(this,b),this.estimatedSize=s.MIN_VALUE,this.margin=o.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=g,y!=null&&y instanceof u?this.graphManager=y:y!=null&&y instanceof Layout&&(this.graphManager=y.graphManager)}v.prototype=Object.create(i.prototype);for(var p in i)v[p]=i[p];v.prototype.getNodes=function(){return this.nodes},v.prototype.getEdges=function(){return this.edges},v.prototype.getGraphManager=function(){return this.graphManager},v.prototype.getParent=function(){return this.parent},v.prototype.getLeft=function(){return this.left},v.prototype.getRight=function(){return this.right},v.prototype.getTop=function(){return this.top},v.prototype.getBottom=function(){return this.bottom},v.prototype.isConnected=function(){return this.isConnected},v.prototype.add=function(g,y,b){if(y==null&&b==null){var m=g;if(this.graphManager==null)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(m)>-1)throw"Node already in graph!";return m.owner=this,this.getNodes().push(m),m}else{var T=g;if(!(this.getNodes().indexOf(y)>-1&&this.getNodes().indexOf(b)>-1))throw"Source or target not in graph!";if(!(y.owner==b.owner&&y.owner==this))throw"Both owners must be this graph!";return y.owner!=b.owner?null:(T.source=y,T.target=b,T.isInterGraph=!1,this.getEdges().push(T),y.edges.push(T),b!=y&&b.edges.push(T),T)}},v.prototype.remove=function(g){var y=g;if(g instanceof l){if(y==null)throw"Node is null!";if(!(y.owner!=null&&y.owner==this))throw"Owner graph is invalid!";if(this.graphManager==null)throw"Owner graph manager is invalid!";for(var b=y.edges.slice(),m,T=b.length,C=0;C-1&&w>-1))throw"Source and/or target doesn't know this edge!";m.source.edges.splice(E,1),m.target!=m.source&&m.target.edges.splice(w,1);var S=m.source.owner.getEdges().indexOf(m);if(S==-1)throw"Not in owner's edge list!";m.source.owner.getEdges().splice(S,1)}},v.prototype.updateLeftTop=function(){for(var g=s.MAX_VALUE,y=s.MAX_VALUE,b,m,T,C=this.getNodes(),S=C.length,E=0;Eb&&(g=b),y>m&&(y=m)}return g==s.MAX_VALUE?null:(C[0].getParent().paddingLeft!=null?T=C[0].getParent().paddingLeft:T=this.margin,this.left=y-T,this.top=g-T,new d(this.left,this.top))},v.prototype.updateBounds=function(g){for(var y=s.MAX_VALUE,b=-s.MAX_VALUE,m=s.MAX_VALUE,T=-s.MAX_VALUE,C,S,E,w,x,D=this.nodes,L=D.length,A=0;AC&&(y=C),bE&&(m=E),TC&&(y=C),bE&&(m=E),T=this.nodes.length){var L=0;b.forEach(function(A){A.owner==g&&L++}),L==this.nodes.length&&(this.isConnected=!0)}},r.exports=v},function(r,a,n){var i,s=n(1);function o(u){i=n(5),this.layout=u,this.graphs=[],this.edges=[]}o.prototype.addRoot=function(){var u=this.layout.newGraph(),l=this.layout.newNode(null),f=this.add(u,l);return this.setRootGraph(f),this.rootGraph},o.prototype.add=function(u,l,f,h,d){if(f==null&&h==null&&d==null){if(u==null)throw"Graph is null!";if(l==null)throw"Parent node is null!";if(this.graphs.indexOf(u)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(u),u.parent!=null)throw"Already has a parent!";if(l.child!=null)throw"Already has a child!";return u.parent=l,l.child=u,u}else{d=f,h=l,f=u;var c=h.getOwner(),v=d.getOwner();if(!(c!=null&&c.getGraphManager()==this))throw"Source not in this graph mgr!";if(!(v!=null&&v.getGraphManager()==this))throw"Target not in this graph mgr!";if(c==v)return f.isInterGraph=!1,c.add(f,h,d);if(f.isInterGraph=!0,f.source=h,f.target=d,this.edges.indexOf(f)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(f),!(f.source!=null&&f.target!=null))throw"Edge source and/or target is null!";if(!(f.source.edges.indexOf(f)==-1&&f.target.edges.indexOf(f)==-1))throw"Edge already in source and/or target incidency list!";return f.source.edges.push(f),f.target.edges.push(f),f}},o.prototype.remove=function(u){if(u instanceof i){var l=u;if(l.getGraphManager()!=this)throw"Graph not in this graph mgr";if(!(l==this.rootGraph||l.parent!=null&&l.parent.graphManager==this))throw"Invalid parent node!";var f=[];f=f.concat(l.getEdges());for(var h,d=f.length,c=0;c=u.getRight()?l[0]+=Math.min(u.getX()-o.getX(),o.getRight()-u.getRight()):u.getX()<=o.getX()&&u.getRight()>=o.getRight()&&(l[0]+=Math.min(o.getX()-u.getX(),u.getRight()-o.getRight())),o.getY()<=u.getY()&&o.getBottom()>=u.getBottom()?l[1]+=Math.min(u.getY()-o.getY(),o.getBottom()-u.getBottom()):u.getY()<=o.getY()&&u.getBottom()>=o.getBottom()&&(l[1]+=Math.min(o.getY()-u.getY(),u.getBottom()-o.getBottom()));var d=Math.abs((u.getCenterY()-o.getCenterY())/(u.getCenterX()-o.getCenterX()));u.getCenterY()===o.getCenterY()&&u.getCenterX()===o.getCenterX()&&(d=1);var c=d*l[0],v=l[1]/d;l[0]c)return l[0]=f,l[1]=p,l[2]=d,l[3]=D,!1;if(hd)return l[0]=v,l[1]=h,l[2]=w,l[3]=c,!1;if(fd?(l[0]=y,l[1]=b,O=!0):(l[0]=g,l[1]=p,O=!0):R===P&&(f>d?(l[0]=v,l[1]=p,O=!0):(l[0]=m,l[1]=b,O=!0)),-k===P?d>f?(l[2]=x,l[3]=D,M=!0):(l[2]=w,l[3]=E,M=!0):k===P&&(d>f?(l[2]=S,l[3]=E,M=!0):(l[2]=L,l[3]=D,M=!0)),O&&M)return!1;if(f>d?h>c?(B=this.getCardinalDirection(R,P,4),z=this.getCardinalDirection(k,P,2)):(B=this.getCardinalDirection(-R,P,3),z=this.getCardinalDirection(-k,P,1)):h>c?(B=this.getCardinalDirection(-R,P,1),z=this.getCardinalDirection(-k,P,3)):(B=this.getCardinalDirection(R,P,2),z=this.getCardinalDirection(k,P,4)),!O)switch(B){case 1:F=p,G=f+-C/P,l[0]=G,l[1]=F;break;case 2:G=m,F=h+T*P,l[0]=G,l[1]=F;break;case 3:F=b,G=f+C/P,l[0]=G,l[1]=F;break;case 4:G=y,F=h+-T*P,l[0]=G,l[1]=F;break}if(!M)switch(z){case 1:Y=E,U=d+-N/P,l[2]=U,l[3]=Y;break;case 2:U=L,Y=c+A*P,l[2]=U,l[3]=Y;break;case 3:Y=D,U=d+N/P,l[2]=U,l[3]=Y;break;case 4:U=x,Y=c+-A*P,l[2]=U,l[3]=Y;break}}return!1},s.getCardinalDirection=function(o,u,l){return o>u?l:1+l%4},s.getIntersection=function(o,u,l,f){if(f==null)return this.getIntersection2(o,u,l);var h=o.x,d=o.y,c=u.x,v=u.y,p=l.x,g=l.y,y=f.x,b=f.y,m=void 0,T=void 0,C=void 0,S=void 0,E=void 0,w=void 0,x=void 0,D=void 0,L=void 0;return C=v-d,E=h-c,x=c*d-h*v,S=b-g,w=p-y,D=y*g-p*b,L=C*w-S*E,L===0?null:(m=(E*D-w*x)/L,T=(S*x-C*D)/L,new i(m,T))},s.angleOfVector=function(o,u,l,f){var h=void 0;return o!==l?(h=Math.atan((f-u)/(l-o)),l0?1:s<0?-1:0},i.floor=function(s){return s<0?Math.ceil(s):Math.floor(s)},i.ceil=function(s){return s<0?Math.floor(s):Math.ceil(s)},r.exports=i},function(r,a,n){function i(){}i.MAX_VALUE=2147483647,i.MIN_VALUE=-2147483648,r.exports=i},function(r,a,n){var i=function(){function h(d,c){for(var v=0;v"u"?"undefined":i(o);return o==null||u!="object"&&u!="function"},r.exports=s},function(r,a,n){function i(p){if(Array.isArray(p)){for(var g=0,y=Array(p.length);g0&&g;){for(C.push(E[0]);C.length>0&&g;){var w=C[0];C.splice(0,1),T.add(w);for(var x=w.getEdges(),m=0;m-1&&E.splice(N,1)}T=new Set,S=new Map}}return p},v.prototype.createDummyNodesForBendpoints=function(p){for(var g=[],y=p.source,b=this.graphManager.calcLowestCommonAncestor(p.source,p.target),m=0;m0){for(var b=this.edgeToDummyNodes.get(y),m=0;m=0&&g.splice(D,1);var L=S.getNeighborsList();L.forEach(function(O){if(y.indexOf(O)<0){var M=b.get(O),R=M-1;R==1&&w.push(O),b.set(O,R)}})}y=y.concat(w),(g.length==1||g.length==2)&&(m=!0,T=g[0])}return T},v.prototype.setGraphManager=function(p){this.graphManager=p},r.exports=v},function(r,a,n){function i(){}i.seed=1,i.x=0,i.nextDouble=function(){return i.x=Math.sin(i.seed++)*1e4,i.x-Math.floor(i.x)},r.exports=i},function(r,a,n){var i=n(4);function s(o,u){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}s.prototype.getWorldOrgX=function(){return this.lworldOrgX},s.prototype.setWorldOrgX=function(o){this.lworldOrgX=o},s.prototype.getWorldOrgY=function(){return this.lworldOrgY},s.prototype.setWorldOrgY=function(o){this.lworldOrgY=o},s.prototype.getWorldExtX=function(){return this.lworldExtX},s.prototype.setWorldExtX=function(o){this.lworldExtX=o},s.prototype.getWorldExtY=function(){return this.lworldExtY},s.prototype.setWorldExtY=function(o){this.lworldExtY=o},s.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},s.prototype.setDeviceOrgX=function(o){this.ldeviceOrgX=o},s.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},s.prototype.setDeviceOrgY=function(o){this.ldeviceOrgY=o},s.prototype.getDeviceExtX=function(){return this.ldeviceExtX},s.prototype.setDeviceExtX=function(o){this.ldeviceExtX=o},s.prototype.getDeviceExtY=function(){return this.ldeviceExtY},s.prototype.setDeviceExtY=function(o){this.ldeviceExtY=o},s.prototype.transformX=function(o){var u=0,l=this.lworldExtX;return l!=0&&(u=this.ldeviceOrgX+(o-this.lworldOrgX)*this.ldeviceExtX/l),u},s.prototype.transformY=function(o){var u=0,l=this.lworldExtY;return l!=0&&(u=this.ldeviceOrgY+(o-this.lworldOrgY)*this.ldeviceExtY/l),u},s.prototype.inverseTransformX=function(o){var u=0,l=this.ldeviceExtX;return l!=0&&(u=this.lworldOrgX+(o-this.ldeviceOrgX)*this.lworldExtX/l),u},s.prototype.inverseTransformY=function(o){var u=0,l=this.ldeviceExtY;return l!=0&&(u=this.lworldOrgY+(o-this.ldeviceOrgY)*this.lworldExtY/l),u},s.prototype.inverseTransformPoint=function(o){var u=new i(this.inverseTransformX(o.x),this.inverseTransformY(o.y));return u},r.exports=s},function(r,a,n){function i(c){if(Array.isArray(c)){for(var v=0,p=Array(c.length);vo.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*o.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(c-o.ADAPTATION_LOWER_NODE_LIMIT)/(o.ADAPTATION_UPPER_NODE_LIMIT-o.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-o.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=o.MAX_NODE_DISPLACEMENT_INCREMENTAL):(c>o.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(o.COOLING_ADAPTATION_FACTOR,1-(c-o.ADAPTATION_LOWER_NODE_LIMIT)/(o.ADAPTATION_UPPER_NODE_LIMIT-o.ADAPTATION_LOWER_NODE_LIMIT)*(1-o.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=o.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(this.getAllNodes().length*5,this.maxIterations),this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},h.prototype.calcSpringForces=function(){for(var c=this.getAllEdges(),v,p=0;p0&&arguments[0]!==void 0?arguments[0]:!0,v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,p,g,y,b,m=this.getAllNodes(),T;if(this.useFRGridVariant)for(this.totalIterations%o.GRID_CALCULATION_CHECK_PERIOD==1&&c&&this.updateGrid(),T=new Set,p=0;pC||T>C)&&(c.gravitationForceX=-this.gravityConstant*y,c.gravitationForceY=-this.gravityConstant*b)):(C=v.getEstimatedSize()*this.compoundGravityRangeFactor,(m>C||T>C)&&(c.gravitationForceX=-this.gravityConstant*y*this.compoundGravityConstant,c.gravitationForceY=-this.gravityConstant*b*this.compoundGravityConstant))},h.prototype.isConverged=function(){var c,v=!1;return this.totalIterations>this.maxIterations/3&&(v=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),c=this.totalDisplacement=m.length||C>=m[0].length)){for(var S=0;Sh}}]),l}();r.exports=u},function(r,a,n){var i=function(){function u(l,f){for(var h=0;h2&&arguments[2]!==void 0?arguments[2]:1,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:-1,c=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;s(this,u),this.sequence1=l,this.sequence2=f,this.match_score=h,this.mismatch_penalty=d,this.gap_penalty=c,this.iMax=l.length+1,this.jMax=f.length+1,this.grid=new Array(this.iMax);for(var v=0;v=0;l--){var f=this.listeners[l];f.event===o&&f.callback===u&&this.listeners.splice(l,1)}},s.emit=function(o,u){for(var l=0;lf.coolingFactor*f.maxNodeDisplacement&&(this.displacementX=f.coolingFactor*f.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>f.coolingFactor*f.maxNodeDisplacement&&(this.displacementY=f.coolingFactor*f.maxNodeDisplacement*o.sign(this.displacementY)),this.child==null?this.moveBy(this.displacementX,this.displacementY):this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),f.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},u.prototype.propogateDisplacementToChildren=function(f,h){for(var d=this.getChild().getNodes(),c,v=0;v0)this.positionNodesRadially(E);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var w=new Set(this.getAllNodes()),x=this.nodesWithGravity.filter(function(D){return w.has(D)});this.graphManager.setAllNodesToApplyGravitation(x),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},C.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var E=new Set(this.getAllNodes()),w=this.nodesWithGravity.filter(function(L){return E.has(L)});this.graphManager.setAllNodesToApplyGravitation(w),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var x=!this.isTreeGrowing&&!this.isGrowthFinished,D=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(x,D),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},C.prototype.getPositionsData=function(){for(var E=this.graphManager.getAllNodes(),w={},x=0;x1){var O;for(O=0;OD&&(D=Math.floor(N.y)),A=Math.floor(N.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(c.WORLD_CENTER_X-N.x/2,c.WORLD_CENTER_Y-N.y/2))},C.radialLayout=function(E,w,x){var D=Math.max(this.maxDiagonalInTree(E),h.DEFAULT_RADIAL_SEPARATION);C.branchRadialLayout(w,null,0,359,0,D);var L=m.calculateBounds(E),A=new T;A.setDeviceOrgX(L.getMinX()),A.setDeviceOrgY(L.getMinY()),A.setWorldOrgX(x.x),A.setWorldOrgY(x.y);for(var N=0;N1;){var Y=U[0];U.splice(0,1);var W=P.indexOf(Y);W>=0&&P.splice(W,1),G--,B--}w!=null?F=(P.indexOf(U[0])+1)%G:F=0;for(var K=Math.abs(D-x)/B,j=F;z!=B;j=++j%G){var _=P[j].getOtherEnd(E);if(_!=w){var V=(x+z*K)%360,H=(V+K)%360;C.branchRadialLayout(_,E,V,H,L+A,A),z++}}},C.maxDiagonalInTree=function(E){for(var w=y.MIN_VALUE,x=0;xw&&(w=L)}return w},C.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},C.prototype.groupZeroDegreeMembers=function(){var E=this,w={};this.memberGroups={},this.idToDummyNode={};for(var x=[],D=this.graphManager.getAllNodes(),L=0;L"u"&&(w[O]=[]),w[O]=w[O].concat(A)}Object.keys(w).forEach(function(M){if(w[M].length>1){var R="DummyCompound_"+M;E.memberGroups[R]=w[M];var k=w[M][0].getParent(),P=new l(E.graphManager);P.id=R,P.paddingLeft=k.paddingLeft||0,P.paddingRight=k.paddingRight||0,P.paddingBottom=k.paddingBottom||0,P.paddingTop=k.paddingTop||0,E.idToDummyNode[R]=P;var B=E.getGraphManager().add(E.newGraph(),P),z=k.getChild();z.add(P);for(var G=0;G=0;E--){var w=this.compoundOrder[E],x=w.id,D=w.paddingLeft,L=w.paddingTop;this.adjustLocations(this.tiledMemberPack[x],w.rect.x,w.rect.y,D,L)}},C.prototype.repopulateZeroDegreeMembers=function(){var E=this,w=this.tiledZeroDegreePack;Object.keys(w).forEach(function(x){var D=E.idToDummyNode[x],L=D.paddingLeft,A=D.paddingTop;E.adjustLocations(w[x],D.rect.x,D.rect.y,L,A)})},C.prototype.getToBeTiled=function(E){var w=E.id;if(this.toBeTiled[w]!=null)return this.toBeTiled[w];var x=E.getChild();if(x==null)return this.toBeTiled[w]=!1,!1;for(var D=x.getNodes(),L=0;L0)return this.toBeTiled[w]=!1,!1;if(A.getChild()==null){this.toBeTiled[A.id]=!1;continue}if(!this.getToBeTiled(A))return this.toBeTiled[w]=!1,!1}return this.toBeTiled[w]=!0,!0},C.prototype.getNodeDegree=function(E){E.id;for(var w=E.getEdges(),x=0,D=0;DM&&(M=k.rect.height)}x+=M+E.verticalPadding}},C.prototype.tileCompoundMembers=function(E,w){var x=this;this.tiledMemberPack=[],Object.keys(E).forEach(function(D){var L=w[D];x.tiledMemberPack[D]=x.tileNodes(E[D],L.paddingLeft+L.paddingRight),L.rect.width=x.tiledMemberPack[D].width,L.rect.height=x.tiledMemberPack[D].height})},C.prototype.tileNodes=function(E,w){var x=h.TILING_PADDING_VERTICAL,D=h.TILING_PADDING_HORIZONTAL,L={rows:[],rowWidth:[],rowHeight:[],width:0,height:w,verticalPadding:x,horizontalPadding:D};E.sort(function(O,M){return O.rect.width*O.rect.height>M.rect.width*M.rect.height?-1:O.rect.width*O.rect.height0&&(N+=E.horizontalPadding),E.rowWidth[x]=N,E.width0&&(O+=E.verticalPadding);var M=0;O>E.rowHeight[x]&&(M=E.rowHeight[x],E.rowHeight[x]=O,M=E.rowHeight[x]-M),E.height+=M,E.rows[x].push(w)},C.prototype.getShortestRowIndex=function(E){for(var w=-1,x=Number.MAX_VALUE,D=0;Dx&&(w=D,x=E.rowWidth[D]);return w},C.prototype.canAddHorizontal=function(E,w,x){var D=this.getShortestRowIndex(E);if(D<0)return!0;var L=E.rowWidth[D];if(L+E.horizontalPadding+w<=E.width)return!0;var A=0;E.rowHeight[D]0&&(A=x+E.verticalPadding-E.rowHeight[D]);var N;E.width-L>=w+E.horizontalPadding?N=(E.height+A)/(L+w+E.horizontalPadding):N=(E.height+A)/E.width,A=x+E.verticalPadding;var O;return E.widthA&&w!=x){D.splice(-1,1),E.rows[x].push(L),E.rowWidth[w]=E.rowWidth[w]-A,E.rowWidth[x]=E.rowWidth[x]+A,E.width=E.rowWidth[instance.getLongestRowIndex(E)];for(var N=Number.MIN_VALUE,O=0;ON&&(N=D[O].height);w>0&&(N+=E.verticalPadding);var M=E.rowHeight[w]+E.rowHeight[x];E.rowHeight[w]=N,E.rowHeight[x]0)for(var z=L;z<=A;z++)B[0]+=this.grid[z][N-1].length+this.grid[z][N].length-1;if(A0)for(var z=N;z<=O;z++)B[3]+=this.grid[L-1][z].length+this.grid[L][z].length-1;for(var G=y.MAX_VALUE,F,U,Y=0;Y0){var O;O=T.getGraphManager().add(T.newGraph(),x),this.processChildrenList(O,w,T)}}},p.prototype.stop=function(){return this.stopped=!0,this};var y=function(m){m("layout","cose-bilkent",p)};typeof cytoscape<"u"&&y(cytoscape),a.exports=y}])})})(Yu);var qp=Yu.exports;const Wp=rl(qp);var fi=function(){var t=function(T,C,S,E){for(S=S||{},E=T.length;E--;S[T[E]]=C);return S},e=[1,4],r=[1,13],a=[1,12],n=[1,15],i=[1,16],s=[1,20],o=[1,19],u=[6,7,8],l=[1,26],f=[1,24],h=[1,25],d=[6,7,11],c=[1,6,13,15,16,19,22],v=[1,33],p=[1,34],g=[1,6,7,11,13,15,16,19,22],y={trace:function(){},yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,MINDMAP:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,ICON:15,CLASS:16,nodeWithId:17,nodeWithoutId:18,NODE_DSTART:19,NODE_DESCR:20,NODE_DEND:21,NODE_ID:22,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"MINDMAP",11:"EOF",13:"SPACELIST",15:"ICON",16:"CLASS",19:"NODE_DSTART",20:"NODE_DESCR",21:"NODE_DEND",22:"NODE_ID"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[18,3],[17,1],[17,4]],performAction:function(C,S,E,w,x,D,L){var A=D.length-1;switch(x){case 6:case 7:return w;case 8:w.getLogger().trace("Stop NL ");break;case 9:w.getLogger().trace("Stop EOF ");break;case 11:w.getLogger().trace("Stop NL2 ");break;case 12:w.getLogger().trace("Stop EOF2 ");break;case 15:w.getLogger().info("Node: ",D[A].id),w.addNode(D[A-1].length,D[A].id,D[A].descr,D[A].type);break;case 16:w.getLogger().trace("Icon: ",D[A]),w.decorateNode({icon:D[A]});break;case 17:case 21:w.decorateNode({class:D[A]});break;case 18:w.getLogger().trace("SPACELIST");break;case 19:w.getLogger().trace("Node: ",D[A].id),w.addNode(0,D[A].id,D[A].descr,D[A].type);break;case 20:w.decorateNode({icon:D[A]});break;case 25:w.getLogger().trace("node found ..",D[A-2]),this.$={id:D[A-1],descr:D[A-1],type:w.getType(D[A-2],D[A])};break;case 26:this.$={id:D[A],descr:D[A],type:w.nodeType.DEFAULT};break;case 27:w.getLogger().trace("node found ..",D[A-3]),this.$={id:D[A-3],descr:D[A-1],type:w.getType(D[A-2],D[A])};break}},table:[{3:1,4:2,5:3,6:[1,5],8:e},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:e},{6:r,7:[1,10],9:9,12:11,13:a,14:14,15:n,16:i,17:17,18:18,19:s,22:o},t(u,[2,3]),{1:[2,2]},t(u,[2,4]),t(u,[2,5]),{1:[2,6],6:r,12:21,13:a,14:14,15:n,16:i,17:17,18:18,19:s,22:o},{6:r,9:22,12:11,13:a,14:14,15:n,16:i,17:17,18:18,19:s,22:o},{6:l,7:f,10:23,11:h},t(d,[2,22],{17:17,18:18,14:27,15:[1,28],16:[1,29],19:s,22:o}),t(d,[2,18]),t(d,[2,19]),t(d,[2,20]),t(d,[2,21]),t(d,[2,23]),t(d,[2,24]),t(d,[2,26],{19:[1,30]}),{20:[1,31]},{6:l,7:f,10:32,11:h},{1:[2,7],6:r,12:21,13:a,14:14,15:n,16:i,17:17,18:18,19:s,22:o},t(c,[2,14],{7:v,11:p}),t(g,[2,8]),t(g,[2,9]),t(g,[2,10]),t(d,[2,15]),t(d,[2,16]),t(d,[2,17]),{20:[1,35]},{21:[1,36]},t(c,[2,13],{7:v,11:p}),t(g,[2,11]),t(g,[2,12]),{21:[1,37]},t(d,[2,25]),t(d,[2,27])],defaultActions:{2:[2,1],6:[2,2]},parseError:function(C,S){if(S.recoverable)this.trace(C);else{var E=new Error(C);throw E.hash=S,E}},parse:function(C){var S=this,E=[0],w=[],x=[null],D=[],L=this.table,A="",N=0,O=0,M=2,R=1,k=D.slice.call(arguments,1),P=Object.create(this.lexer),B={yy:{}};for(var z in this.yy)Object.prototype.hasOwnProperty.call(this.yy,z)&&(B.yy[z]=this.yy[z]);P.setInput(C,B.yy),B.yy.lexer=P,B.yy.parser=this,typeof P.yylloc>"u"&&(P.yylloc={});var G=P.yylloc;D.push(G);var F=P.options&&P.options.ranges;typeof B.yy.parseError=="function"?this.parseError=B.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function U(){var te;return te=w.pop()||P.lex()||R,typeof te!="number"&&(te instanceof Array&&(w=te,te=w.pop()),te=S.symbols_[te]||te),te}for(var Y,W,K,j,_={},V,H,Q,ne;;){if(W=E[E.length-1],this.defaultActions[W]?K=this.defaultActions[W]:((Y===null||typeof Y>"u")&&(Y=U()),K=L[W]&&L[W][Y]),typeof K>"u"||!K.length||!K[0]){var ce="";ne=[];for(V in L[W])this.terminals_[V]&&V>M&&ne.push("'"+this.terminals_[V]+"'");P.showPosition?ce="Parse error on line "+(N+1)+`: `+P.showPosition()+` Expecting `+ne.join(", ")+", got '"+(this.terminals_[Y]||Y)+"'":ce="Parse error on line "+(N+1)+": Unexpected "+(Y==R?"end of input":"'"+(this.terminals_[Y]||Y)+"'"),this.parseError(ce,{text:P.match,token:this.terminals_[Y]||Y,line:P.yylineno,loc:G,expected:ne})}if(K[0]instanceof Array&&K.length>1)throw new Error("Parse Error: multiple actions possible at state: "+W+", token: "+Y);switch(K[0]){case 1:E.push(Y),x.push(P.yytext),D.push(P.yylloc),E.push(K[1]),Y=null,O=P.yyleng,A=P.yytext,N=P.yylineno,G=P.yylloc;break;case 2:if(H=this.productions_[K[1]][1],_.$=x[x.length-H],_._$={first_line:D[D.length-(H||1)].first_line,last_line:D[D.length-1].last_line,first_column:D[D.length-(H||1)].first_column,last_column:D[D.length-1].last_column},F&&(_._$.range=[D[D.length-(H||1)].range[0],D[D.length-1].range[1]]),j=this.performAction.apply(_,[A,O,N,B.yy,K[1],x,D].concat(k)),typeof j<"u")return j;H&&(E=E.slice(0,-1*H*2),x=x.slice(0,-1*H),D=D.slice(0,-1*H)),E.push(this.productions_[K[1]][0]),x.push(_.$),D.push(_._$),Q=L[E[E.length-2]][E[E.length-1]],E.push(Q);break;case 3:return!0}}return!0}},b=function(){var T={EOF:1,parseError:function(S,E){if(this.yy.parser)this.yy.parser.parseError(S,E);else throw new Error(S)},setInput:function(C,S){return this.yy=S||this.yy||{},this._input=C,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var C=this._input[0];this.yytext+=C,this.yyleng++,this.offset++,this.match+=C,this.matched+=C;var S=C.match(/(?:\r\n?|\n).*/g);return S?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),C},unput:function(C){var S=C.length,E=C.split(/(?:\r\n?|\n)/g);this._input=C+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-S),this.offset-=S;var w=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),E.length-1&&(this.yylineno-=E.length-1);var x=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:E?(E.length===w.length?this.yylloc.first_column:0)+w[w.length-E.length].length-E[0].length:this.yylloc.first_column-S},this.options.ranges&&(this.yylloc.range=[x[0],x[0]+this.yyleng-S]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true). `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(C){this.unput(this.match.slice(C))},pastInput:function(){var C=this.matched.substr(0,this.matched.length-this.match.length);return(C.length>20?"...":"")+C.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var C=this.match;return C.length<20&&(C+=this._input.substr(0,20-C.length)),(C.substr(0,20)+(C.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var C=this.pastInput(),S=new Array(C.length+1).join("-");return C+this.upcomingInput()+` `+S+"^"},test_match:function(C,S){var E,w,x;if(this.options.backtrack_lexer&&(x={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(x.yylloc.range=this.yylloc.range.slice(0))),w=C[0].match(/(?:\r\n?|\n).*/g),w&&(this.yylineno+=w.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:w?w[w.length-1].length-w[w.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+C[0].length},this.yytext+=C[0],this.match+=C[0],this.matches=C,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(C[0].length),this.matched+=C[0],E=this.performAction.call(this,this.yy,this,S,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),E)return E;if(this._backtrack){for(var D in x)this[D]=x[D];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var C,S,E,w;this._more||(this.yytext="",this.match="");for(var x=this._currentRules(),D=0;DS[0].length)){if(S=E,w=D,this.options.backtrack_lexer){if(C=this.test_match(E,x[D]),C!==!1)return C;if(this._backtrack){S=!1;continue}else return!1}else if(!this.options.flex)break}return S?(C=this.test_match(S,x[w]),C!==!1?C:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text. `+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var S=this.next();return S||this.lex()},begin:function(S){this.conditionStack.push(S)},popState:function(){var S=this.conditionStack.length-1;return S>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(S){return S=this.conditionStack.length-1-Math.abs(S||0),S>=0?this.conditionStack[S]:"INITIAL"},pushState:function(S){this.begin(S)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(S,E,w,x){switch(w){case 0:return S.getLogger().trace("Found comment",E.yytext),6;case 1:return 8;case 2:this.begin("CLASS");break;case 3:return this.popState(),16;case 4:this.popState();break;case 5:S.getLogger().trace("Begin icon"),this.begin("ICON");break;case 6:return S.getLogger().trace("SPACELINE"),6;case 7:return 7;case 8:return 15;case 9:S.getLogger().trace("end icon"),this.popState();break;case 10:return S.getLogger().trace("Exploding node"),this.begin("NODE"),19;case 11:return S.getLogger().trace("Cloud"),this.begin("NODE"),19;case 12:return S.getLogger().trace("Explosion Bang"),this.begin("NODE"),19;case 13:return S.getLogger().trace("Cloud Bang"),this.begin("NODE"),19;case 14:return this.begin("NODE"),19;case 15:return this.begin("NODE"),19;case 16:return this.begin("NODE"),19;case 17:return this.begin("NODE"),19;case 18:return 13;case 19:return 22;case 20:return 11;case 21:this.begin("NSTR2");break;case 22:return"NODE_DESCR";case 23:this.popState();break;case 24:S.getLogger().trace("Starting NSTR"),this.begin("NSTR");break;case 25:return S.getLogger().trace("description:",E.yytext),"NODE_DESCR";case 26:this.popState();break;case 27:return this.popState(),S.getLogger().trace("node end ))"),"NODE_DEND";case 28:return this.popState(),S.getLogger().trace("node end )"),"NODE_DEND";case 29:return this.popState(),S.getLogger().trace("node end ...",E.yytext),"NODE_DEND";case 30:return this.popState(),S.getLogger().trace("node end (("),"NODE_DEND";case 31:return this.popState(),S.getLogger().trace("node end (-"),"NODE_DEND";case 32:return this.popState(),S.getLogger().trace("node end (-"),"NODE_DEND";case 33:return this.popState(),S.getLogger().trace("node end (("),"NODE_DEND";case 34:return this.popState(),S.getLogger().trace("node end (("),"NODE_DEND";case 35:return S.getLogger().trace("Long description:",E.yytext),20;case 36:return S.getLogger().trace("Long description:",E.yytext),20}},rules:[/^(?:\s*%%.*)/i,/^(?:mindmap\b)/i,/^(?::::)/i,/^(?:.+)/i,/^(?:\n)/i,/^(?:::icon\()/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[^\)]+)/i,/^(?:\))/i,/^(?:-\))/i,/^(?:\(-)/i,/^(?:\)\))/i,/^(?:\))/i,/^(?:\(\()/i,/^(?:\{\{)/i,/^(?:\()/i,/^(?:\[)/i,/^(?:[\s]+)/i,/^(?:[^\(\[\n\)\{\}]+)/i,/^(?:$)/i,/^(?:["][`])/i,/^(?:[^`"]+)/i,/^(?:[`]["])/i,/^(?:["])/i,/^(?:[^"]+)/i,/^(?:["])/i,/^(?:[\)]\))/i,/^(?:[\)])/i,/^(?:[\]])/i,/^(?:\}\})/i,/^(?:\(-)/i,/^(?:-\))/i,/^(?:\(\()/i,/^(?:\()/i,/^(?:[^\)\]\(\}]+)/i,/^(?:.+(?!\(\())/i],conditions:{CLASS:{rules:[3,4],inclusive:!1},ICON:{rules:[8,9],inclusive:!1},NSTR2:{rules:[22,23],inclusive:!1},NSTR:{rules:[25,26],inclusive:!1},NODE:{rules:[21,24,27,28,29,30,31,32,33,34,35,36],inclusive:!1},INITIAL:{rules:[0,1,2,5,6,7,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};return T}();y.lexer=b;function m(){this.yy={}}return m.prototype=y,y.Parser=m,new m}();fi.parser=fi;const Kp=fi;let Nt=[],_u=0,Fi={};const Zp=()=>{Nt=[],_u=0,Fi={}},Qp=function(t){for(let e=Nt.length-1;e>=0;e--)if(Nt[e].levelNt.length>0?Nt[0]:null,jp=(t,e,r,a)=>{var n,i;Er.info("addNode",t,e,r,a);const s=ci();let o=((n=s.mindmap)==null?void 0:n.padding)??ja.mindmap.padding;switch(a){case _e.ROUNDED_RECT:case _e.RECT:case _e.HEXAGON:o*=2}const u={id:_u++,nodeId:en(e,s),level:t,descr:en(r,s),type:a,children:[],width:((i=s.mindmap)==null?void 0:i.maxNodeWidth)??ja.mindmap.maxNodeWidth,padding:o},l=Qp(t);if(l)l.children.push(u),Nt.push(u);else if(Nt.length===0)Nt.push(u);else throw new Error('There can be only one root. No parent could be found for ("'+u.descr+'")')},_e={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6},ey=(t,e)=>{switch(Er.debug("In get type",t,e),t){case"[":return _e.RECT;case"(":return e===")"?_e.ROUNDED_RECT:_e.CLOUD;case"((":return _e.CIRCLE;case")":return _e.CLOUD;case"))":return _e.BANG;case"{{":return _e.HEXAGON;default:return _e.DEFAULT}},ty=(t,e)=>{Fi[t]=e},ry=t=>{if(!t)return;const e=ci(),r=Nt[Nt.length-1];t.icon&&(r.icon=en(t.icon,e)),t.class&&(r.class=en(t.class,e))},ay=t=>{switch(t){case _e.DEFAULT:return"no-border";case _e.RECT:return"rect";case _e.ROUNDED_RECT:return"rounded-rect";case _e.CIRCLE:return"circle";case _e.CLOUD:return"cloud";case _e.BANG:return"bang";case _e.HEXAGON:return"hexgon";default:return"no-border"}},ny=()=>Er,iy=t=>Fi[t],sy={clear:Zp,addNode:jp,getMindmap:Jp,nodeType:_e,getType:ey,setElementForId:ty,decorateNode:ry,type2Str:ay,getLogger:ny,getElementById:iy},oy=sy,uy=12,ly=function(t,e,r,a){e.append("path").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("d",`M0 ${r.height-5} v${-r.height+2*5} q0,-5 5,-5 h${r.width-2*5} q5,0 5,5 v${r.height-5} H0 Z`),e.append("line").attr("class","node-line-"+a).attr("x1",0).attr("y1",r.height).attr("x2",r.width).attr("y2",r.height)},fy=function(t,e,r){e.append("rect").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("height",r.height).attr("width",r.width)},hy=function(t,e,r){const a=r.width,n=r.height,i=.15*a,s=.25*a,o=.35*a,u=.2*a;e.append("path").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("d",`M0 0 a${i},${i} 0 0,1 ${a*.25},${-1*a*.1} a${o},${o} 1 0,1 ${a*.4},${-1*a*.1} a${s},${s} 1 0,1 ${a*.35},${1*a*.2} a${i},${i} 1 0,1 ${a*.15},${1*n*.35} a${u},${u} 1 0,1 ${-1*a*.15},${1*n*.65} a${s},${i} 1 0,1 ${-1*a*.25},${a*.15} a${o},${o} 1 0,1 ${-1*a*.5},0 a${i},${i} 1 0,1 ${-1*a*.25},${-1*a*.15} a${i},${i} 1 0,1 ${-1*a*.1},${-1*n*.35} a${u},${u} 1 0,1 ${a*.1},${-1*n*.65} H0 V0 Z`)},cy=function(t,e,r){const a=r.width,n=r.height,i=.15*a;e.append("path").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("d",`M0 0 a${i},${i} 1 0,0 ${a*.25},${-1*n*.1} a${i},${i} 1 0,0 ${a*.25},0 a${i},${i} 1 0,0 ${a*.25},0 a${i},${i} 1 0,0 ${a*.25},${1*n*.1} a${i},${i} 1 0,0 ${a*.15},${1*n*.33} a${i*.8},${i*.8} 1 0,0 0,${1*n*.34} a${i},${i} 1 0,0 ${-1*a*.15},${1*n*.33} a${i},${i} 1 0,0 ${-1*a*.25},${n*.15} a${i},${i} 1 0,0 ${-1*a*.25},0 a${i},${i} 1 0,0 ${-1*a*.25},0 a${i},${i} 1 0,0 ${-1*a*.25},${-1*n*.15} a${i},${i} 1 0,0 ${-1*a*.1},${-1*n*.33} a${i*.8},${i*.8} 1 0,0 0,${-1*n*.34} a${i},${i} 1 0,0 ${a*.1},${-1*n*.33} H0 V0 Z`)},vy=function(t,e,r){e.append("circle").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("r",r.width/2)};function dy(t,e,r,a,n){return t.insert("polygon",":first-child").attr("points",a.map(function(i){return i.x+","+i.y}).join(" ")).attr("transform","translate("+(n.width-e)/2+", "+r+")")}const gy=function(t,e,r){const a=r.height,i=a/4,s=r.width-r.padding+2*i,o=[{x:i,y:0},{x:s-i,y:0},{x:s,y:-a/2},{x:s-i,y:-a},{x:i,y:-a},{x:0,y:-a/2}];dy(e,s,a,o,r)},py=function(t,e,r){e.append("rect").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("height",r.height).attr("rx",r.padding).attr("ry",r.padding).attr("width",r.width)},yy=function(t,e,r,a,n){const i=n.htmlLabels,s=a%(uy-1),o=e.append("g");r.section=s;let u="section-"+s;s<0&&(u+=" section-root"),o.attr("class",(r.class?r.class+" ":"")+"mindmap-node "+u);const l=o.append("g"),f=o.append("g"),h=r.descr.replace(/()/g,` `);fl(f,h,{useHtmlLabels:i,width:r.width,classes:"mindmap-node-label"}),i||f.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle");const d=f.node().getBBox(),[c]=ll(n.fontSize);if(r.height=d.height+c*1.1*.5+r.padding,r.width=d.width+2*r.padding,r.icon)if(r.type===t.nodeType.CIRCLE)r.height+=50,r.width+=50,o.append("foreignObject").attr("height","50px").attr("width",r.width).attr("style","text-align: center;").append("div").attr("class","icon-container").append("i").attr("class","node-icon-"+s+" "+r.icon),f.attr("transform","translate("+r.width/2+", "+(r.height/2-1.5*r.padding)+")");else{r.width+=50;const v=r.height;r.height=Math.max(v,60);const p=Math.abs(r.height-v);o.append("foreignObject").attr("width","60px").attr("height",r.height).attr("style","text-align: center;margin-top:"+p/2+"px;").append("div").attr("class","icon-container").append("i").attr("class","node-icon-"+s+" "+r.icon),f.attr("transform","translate("+(25+r.width/2)+", "+(p/2+r.padding/2)+")")}else if(i){const v=(r.width-d.width)/2,p=(r.height-d.height)/2;f.attr("transform","translate("+v+", "+p+")")}else{const v=r.width/2,p=r.padding/2;f.attr("transform","translate("+v+", "+p+")")}switch(r.type){case t.nodeType.DEFAULT:ly(t,l,r,s);break;case t.nodeType.ROUNDED_RECT:py(t,l,r);break;case t.nodeType.RECT:fy(t,l,r);break;case t.nodeType.CIRCLE:l.attr("transform","translate("+r.width/2+", "+ +r.height/2+")"),vy(t,l,r);break;case t.nodeType.CLOUD:hy(t,l,r);break;case t.nodeType.BANG:cy(t,l,r);break;case t.nodeType.HEXAGON:gy(t,l,r);break}return t.setElementForId(r.id,o),r.height},my=function(t,e){const r=t.getElementById(e.id),a=e.x||0,n=e.y||0;r.attr("transform","translate("+a+","+n+")")};nr.use(Wp);function Hu(t,e,r,a,n){yy(t,e,r,a,n),r.children&&r.children.forEach((i,s)=>{Hu(t,e,i,a<0?s:a,n)})}function by(t,e){e.edges().map((r,a)=>{const n=r.data();if(r[0]._private.bodyBounds){const i=r[0]._private.rscratch;Er.trace("Edge: ",a,n),t.insert("path").attr("d",`M ${i.startX},${i.startY} L ${i.midX},${i.midY} L${i.endX},${i.endY} `).attr("class","edge section-edge-"+n.section+" edge-depth-"+n.depth)}})}function Xu(t,e,r,a){e.add({group:"nodes",data:{id:t.id.toString(),labelText:t.descr,height:t.height,width:t.width,level:a,nodeId:t.id,padding:t.padding,type:t.type},position:{x:t.x,y:t.y}}),t.children&&t.children.forEach(n=>{Xu(n,e,r,a+1),e.add({group:"edges",data:{id:`${t.id}_${n.id}`,source:t.id,target:n.id,depth:a,section:n.section}})})}function Ey(t,e){return new Promise(r=>{const a=il("body").append("div").attr("id","cy").attr("style","display:none"),n=nr({container:document.getElementById("cy"),style:[{selector:"edge",style:{"curve-style":"bezier"}}]});a.remove(),Xu(t,n,e,0),n.nodes().forEach(function(i){i.layoutDimensions=()=>{const s=i.data();return{w:s.width,h:s.height}}}),n.layout({name:"cose-bilkent",quality:"proof",styleEnabled:!1,animate:!1}).run(),n.ready(i=>{Er.info("Ready",i),r(n)})})}function wy(t,e){e.nodes().map((r,a)=>{const n=r.data();n.x=r.position().x,n.y=r.position().y,my(t,n);const i=t.getElementById(n.nodeId);Er.info("Id:",a,"Position: (",r.position().x,", ",r.position().y,")",n),i.attr("transform",`translate(${r.position().x-n.width/2}, ${r.position().y-n.height/2})`),i.attr("attr",`apa-${a})`)})}const xy=async(t,e,r,a)=>{var n,i;Er.debug(`Rendering mindmap diagram `+t);const s=a.db,o=s.getMindmap();if(!o)return;const u=ci();u.htmlLabels=!1;const l=al(e),f=l.append("g");f.attr("class","mindmap-edges");const h=l.append("g");h.attr("class","mindmap-nodes"),Hu(s,h,o,-1,u);const d=await Ey(o,u);by(f,d),wy(s,d),nl(void 0,l,((n=u.mindmap)==null?void 0:n.padding)??ja.mindmap.padding,((i=u.mindmap)==null?void 0:i.useMaxWidth)??ja.mindmap.useMaxWidth)},Ty={draw:xy},Cy=t=>{let e="";for(let r=0;r` .edge { stroke-width: 3; } ${Cy(t)} .section-root rect, .section-root path, .section-root circle, .section-root polygon { fill: ${t.git0}; } .section-root text { fill: ${t.gitBranchLabel0}; } .icon-container { height:100%; display: flex; justify-content: center; align-items: center; } .edge { fill: none; } .mindmap-node-label { dy: 1em; alignment-baseline: middle; text-anchor: middle; dominant-baseline: middle; text-align: center; } `,Sy=Dy,Iy={db:oy,renderer:Ty,parser:Kp,styles:Sy};export{Iy as diagram};