(function(aa){typeof define=="function"&&define.amd?define(aa):aa()})(function(){"use strict";function aa(r,e,t,a){if(!(r instanceof Error))throw r;if(!(typeof window>"u"&&e||a))throw r.message+=" on line "+t,r;var n,i,s,o;try{a=a||require("fs").readFileSync(e,{encoding:"utf8"}),n=3,i=a.split(`
`),s=Math.max(t-n,0),o=Math.min(i.length,t+n)}catch(u){return r.message+=" - could not read from "+e+" ("+u.message+")",void aa(r,null,t)}n=i.slice(s,o).map(function(u,l){var v=l+s+1;return(v==t?"  > ":"    ")+v+"| "+u}).join(`
`),r.path=e;try{r.message=(e||"Pug")+":"+t+`
`+n+`

`+r.message}catch{}throw r}function Vl(r){var e="",t,a;try{a=1,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+'<div class="g-sem-container">',a=2,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+'<div class="g-item-info-header">',a=3,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+'<i class="icon-picture"></i>',a=4,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+"Image Preview</div></div>",a=5,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+'<div class="g-sem-panes clearfix">',a=6,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+'<div class="g-sem-left">',a=7,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+'<div class="g-sem-image">',a=8,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+"<div>",a=9,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+"<img/></div></div>",a=10,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+'<div class="g-sem-filename"></div></div>',a=11,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+'<div class="g-sem-right">',a=12,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semItem.pug",e=e+'<div class="g-sem-tags"></div></div></div>'}catch(n){aa(n,t,a)}return e}const Rm="";function Ar(r){var e=""+r,t=$l.exec(e);if(!t)return r;var a,n,i,s="";for(a=t.index,n=0;a<e.length;a++){switch(e.charCodeAt(a)){case 34:i="&quot;";break;case 38:i="&amp;";break;case 60:i="&lt;";break;case 62:i="&gt;";break;default:continue}n!==a&&(s+=e.substring(n,a)),n=a+1,s+=i}return n!==a?s+e.substring(n,a):s}var $l=/["&<>]/;function ns(r,e,t,a){if(!(r instanceof Error))throw r;if(!(typeof window>"u"&&e||a))throw r.message+=" on line "+t,r;var n,i,s,o;try{a=a||require("fs").readFileSync(e,{encoding:"utf8"}),n=3,i=a.split(`
`),s=Math.max(t-n,0),o=Math.min(i.length,t+n)}catch(u){return r.message+=" - could not read from "+e+" ("+u.message+")",void ns(r,null,t)}n=i.slice(s,o).map(function(u,l){var v=l+s+1;return(v==t?"  > ":"    ")+v+"| "+u}).join(`
`),r.path=e;try{r.message=(e||"Pug")+":"+t+`
`+n+`

`+r.message}catch{}throw r}function ql(r){var e="",t,a,n;try{var i=r||{};(function(s){n=1,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",(function(){var o=s;if(typeof o.length=="number")for(var u=0,l=o.length;u<l;u++){var v=o[u];n=2,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+'<table class="table table-condensed table-hover">',n=3,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<caption>",n=4,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=v.name)==null?"":t)+"</caption>",n=5,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<thead>",n=6,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<th>",n=6,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"Name</th>",n=7,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<th>",n=7,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"Value</th></thead>",n=8,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<tbody>",n=9,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",(function(){var f=v.data;if(typeof f.length=="number")for(var d=0,h=f.length;d<h;d++){var c=f[d];n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<tr>",n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+" ",n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<td>",n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=d)==null?"":t)+"</td>",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<td>",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=c)==null?"":t)+"</td></tr>"}else{var h=0;for(var d in f){h++;var c=f[d];n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<tr>",n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+" ",n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<td>",n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=d)==null?"":t)+"</td>",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<td>",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=c)==null?"":t)+"</td></tr>"}}}).call(this),e=e+"</tbody></table>"}else{var l=0;for(var u in o){l++;var v=o[u];n=2,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+'<table class="table table-condensed table-hover">',n=3,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<caption>",n=4,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=v.name)==null?"":t)+"</caption>",n=5,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<thead>",n=6,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<th>",n=6,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"Name</th>",n=7,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<th>",n=7,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"Value</th></thead>",n=8,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<tbody>",n=9,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",(function(){var c=v.data;if(typeof c.length=="number")for(var m=0,g=c.length;m<g;m++){var p=c[m];n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<tr>",n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+" ",n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<td>",n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=m)==null?"":t)+"</td>",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<td>",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=p)==null?"":t)+"</td></tr>"}else{var g=0;for(var m in c){g++;var p=c[m];n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<tr>",n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+" ",n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<td>",n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=m)==null?"":t)+"</td>",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+"<td>",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/semMetadata.pug",e=e+Ar((t=p)==null?"":t)+"</td></tr>"}}}).call(this),e=e+"</tbody></table>"}}}).call(this)}).call(this,"config"in i?i.config:typeof config<"u"?config:void 0)}catch(s){ns(s,a,n)}return e}const Lm="";var is={};(function(r){(function(e){var t=Object.assign(new Error,{name:"ConfigIniParser Error",message:"Parse config ini file error"}),a=Object.assign(new Error,{name:"ConfigIniParser Error",message:"The specify section not found"}),n=Object.assign(new Error,{name:"ConfigIniParser Error",message:"The specify option not found"}),i=Object.assign(new Error,{name:"ConfigIniParser Error",message:"Found duplicated section in the given ini file"}),s=Object.assign(new Error,{name:"ConfigIniParser Error",message:"Multiple call parse on the same parser instance"}),o=Object.assign(new TypeError,{name:"ConfigIniParser Error",message:"The argument type is not correct"}),u="__DEFAULT_SECTION__",l=/^\s*\[\s*([^\]]+?)\s*\]\s*$/,v=/\s*([^=:\s]+)\s*[=:]\s*(.*)\s*/,f=/^\s*[#;].*/,d=/^\s*$/,h=1,c=1,m=2,g=-1,p=`
`;function y(F,S){for(var D=F.sections,C=0;C<D.length;C++){var B=D[C];if(B.name==S)return B}}function w(F,S){for(var D=F.sections,C=0;C<D.length;C++){var B=D[C];if(B.name==S)return C}return g}function b(F,S){for(var D=F.options,C=0;C<D.length;C++){var B=D[C];if(B.name==S)return B}}function k(F,S){for(var D=F.options,C=0;C<D.length;C++){var B=D[C];if(B.name==S)return C}return g}function x(F){return{name:F,options:[]}}function E(F,S){return{name:F,value:S}}var T=function(F){this.delimiter=F||p,this._calledParse=!1,this._ini={sections:[]},this._ini.sections.push(x(u))};T.prototype.addSection=function(F){if(y(this._ini,F))throw i;var S=x(F);return this._ini.sections.push(S),this},T.prototype.get=function(F,S,D){var C=y(this._ini,F||u);if(C){var B=b(C,S);if(B)return B.value}if(D===void 0)throw n;return D},T.prototype.getOptionFromDefaultSection=function(F,S){return this.get(null,F,S)},T.prototype.getBoolean=function(F,S){var D=this.get(F||u,S);return isNaN(D)?String(D).toLowerCase()=="true":D!=0},T.prototype.getBooleanFromDefaultSection=function(F){return this.getBoolean(null,F)},T.prototype.getNumber=function(F,S){return+this.get(F||u,S)},T.prototype.getNumberFromDefaultSection=function(F){return this.getNumber(null,F)},T.prototype.isHaveSection=function(F){if(!F)throw o;return!!y(this._ini,F)},T.prototype.isHaveOption=function(F,S){var D=y(this._ini,F||u);if(D){var C=b(D,S);if(C)return!0}return!1},T.prototype.isHaveOptionInDefaultSection=function(F){return this.isHaveOption(null,F)},T.prototype.items=function(F){for(var S=y(this._ini,F||u),D=[],C=0;C<S.options.length;C++){var B=S.options[C];D.push([B.name,B.value])}return D},T.prototype.options=function(F){var S=y(this._ini,F||u);if(S){for(var D=[],C=S.options,B,A=0;A<C.length;A++)B=C[A],D.push(B.name);return D}else throw a},T.prototype.removeOption=function(F,S){var D=y(this._ini,F||u);if(D){var C=k(D,S);if(C!=g)return D.options.splice(C,1),!0}return!1},T.prototype.removeOptionFromDefaultSection=function(F){return this.removeOption(null,F)},T.prototype.removeSection=function(F){var S=w(this._ini,F||u);return S!=g?(this._ini.sections.splice(S,1),F===u&&this._ini.sections.push(x(u)),!0):!1},T.prototype.sections=function(){for(var F=[],S=this._ini.sections,D,C=0;C<S.length;C++)D=S[C],D.name!=u&&F.push(D.name);return F},T.prototype.set=function(F,S,D){var C=y(this._ini,F||u),B;if(C)return B=b(C,S),B?(B.value=D,this):(B=E(S,D),C.options.push(B),this);throw a},T.prototype.setOptionInDefaultSection=function(F,S){return this.set(null,F,S)},T.prototype.stringify=function(F){for(var S=[],D=this._ini.sections,C,B,A,M=0;M<D.length;M++){C=D[M],C.name!=u&&S.push("["+C.name+"]"),B=C.options;for(var I=0;I<B.length;I++)A=B[I],S.push(A.name+"="+A.value);S.length>0&&S.push("")}return S.join(F||this.delimiter)},T.prototype.parse=function(F){if(this._calledParse)throw s;this._calledParse=!0;for(var S=F.split(this.delimiter),D=y(this._ini,u),C=0;C<S.length;C++){var B=S[C];if(!(B.match(f)||B.match(d))){var A=B.match(l);if(A){var M=A[h];if(y(this._ini,M))throw i;D=x(M),this._ini.sections.push(D);continue}var I=B.match(v);if(I){var R=I[c],L=I[m],V=E(R,L);D.options.push(V);continue}throw t}}return this},T.Errors={Error:t,ErrorNoSection:a,ErrorNoOption:n,ErrorDuplicateSectionError:i,ErrorCallParseMultipleTimes:s,ErrorIncorrectArgumentType:o},e.ConfigIniParser=T})(r)})(is);const{restRequest:ss}=girder.rest,Yn=girder.views.View,Wl=girder.collections.FileCollection,Hl=Yn.extend({className:"g-sem-view",initialize:function(r){this._semImageView=null,this._semMetadataView=null,this.collection=new Wl,this.collection.altUrl="item/"+(r.itemId||r.item.get("_id"))+"/files",this.collection.append=!0;var e=this;this.collection.on("g:changed",function(){ss({url:`item/${r.item.id}/tiff_thumbnail`}).done(t=>{e.image=`data:image/png;base64,${t}`,e.trigger("g:tiffLoaded")}),ss({url:`item/${r.item.id}/tiff_metadata`}).done(t=>{const a=new is.ConfigIniParser(`\r
`);a.parse(t),e.config=a,e.trigger("g:configLoaded")})}).fetch({itemId:r.item.id}),this.listenTo(this,"g:tiffLoaded",this.render)},render:function(){return this.$el.html(Vl()),this._semImageView=new Gl({el:this.$(".g-sem-image"),parentView:this}),this._semMetadataView=new Ul({el:this.$(".g-sem-tags"),parentView:this}),this._semImageView.render(),this._semMetadataView.render(),this}}),Gl=Yn.extend({className:"g-sem-image",initialize:function(r){this.listenTo(this.parentView,"g:tiffLoaded",this.render)},render:function(){var r=this.$("div > img");return this.parentView.image&&(r[0].src=this.parentView.image,r[0].width=768),this}}),Ul=Yn.extend({className:"g-sem-tags",initialize:function(r){this.listenTo(this.parentView,"g:configLoaded",this.render)},render:function(){const r=[];return this.parentView.config&&(this.parentView.config.sections().forEach(e=>{var t={name:e,data:{}};this.parentView.config.items(e).forEach(a=>{t.data[a[0]]=a[1]}),r.push(t)}),this.$el.html(ql({config:r}))),this}});function He(r){"@babel/helpers - typeof";return He=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},He(r)}function Zr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function os(r,e){for(var t=0;t<e.length;t++){var a=e[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(r,a.key,a)}}function Qr(r,e,t){return e&&os(r.prototype,e),t&&os(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function us(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function We(r,e){return Xl(r)||Zl(r,e)||Zn(r,e)||Jl()}function ls(r){return Kl(r)||Yl(r)||Zn(r)||Ql()}function Kl(r){if(Array.isArray(r))return Qn(r)}function Xl(r){if(Array.isArray(r))return r}function Yl(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Zl(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var a=[],n=!0,i=!1,s,o;try{for(t=t.call(r);!(n=(s=t.next()).done)&&(a.push(s.value),!(e&&a.length===e));n=!0);}catch(u){i=!0,o=u}finally{try{!n&&t.return!=null&&t.return()}finally{if(i)throw o}}return a}}function Zn(r,e){if(r){if(typeof r=="string")return Qn(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Qn(r,e)}}function Qn(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,a=new Array(e);t<e;t++)a[t]=r[t];return a}function Ql(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jl(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mr(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=Zn(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var a=0,n=function(){};return{s:n,n:function(){return a>=r.length?{done:!0}:{done:!1,value:r[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(){t=t.call(r)},n:function(){var u=t.next();return i=u.done,u},e:function(u){s=!0,o=u},f:function(){try{!i&&t.return!=null&&t.return()}finally{if(s)throw o}}}}var Ge=typeof window>"u"?null:window,vs=Ge?Ge.navigator:null;Ge&&Ge.document;var jl=He(""),fs=He({}),ev=He(function(){}),rv=typeof HTMLElement>"u"?"undefined":He(HTMLElement),na=function(e){return e&&e.instanceString&&ze(e.instanceString)?e.instanceString():null},fe=function(e){return e!=null&&He(e)==jl},ze=function(e){return e!=null&&He(e)===ev},Re=function(e){return!yr(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},Se=function(e){return e!=null&&He(e)===fs&&!Re(e)&&e.constructor===Object},tv=function(e){return e!=null&&He(e)===fs},te=function(e){return e!=null&&He(e)===He(1)&&!isNaN(e)},av=function(e){return te(e)&&Math.floor(e)===e},Ga=function(e){if(rv!=="undefined")return e!=null&&e instanceof HTMLElement},yr=function(e){return ia(e)||ds(e)},ia=function(e){return na(e)==="collection"&&e._private.single},ds=function(e){return na(e)==="collection"&&!e._private.single},Jn=function(e){return na(e)==="core"},cs=function(e){return na(e)==="stylesheet"},nv=function(e){return na(e)==="event"},Jr=function(e){return e==null?!0:!!(e===""||e.match(/^\s+$/))},iv=function(e){return typeof HTMLElement>"u"?!1:e instanceof HTMLElement},sv=function(e){return Se(e)&&te(e.x1)&&te(e.x2)&&te(e.y1)&&te(e.y2)},ov=function(e){return tv(e)&&ze(e.then)},uv=function(){return vs&&vs.userAgent.match(/msie|trident|edge/i)},sa=function(e,t){t||(t=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return"undefined";for(var i=[],s=0;s<arguments.length;s++)i.push(arguments[s]);return i.join("$")});var a=function n(){var i=this,s=arguments,o,u=t.apply(i,s),l=n.cache;return(o=l[u])||(o=l[u]=e.apply(i,s)),o};return a.cache={},a},jn=sa(function(r){return r.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),Ua=sa(function(r){return r.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),hs=sa(function(r,e){return r+e[0].toUpperCase()+e.substring(1)},function(r,e){return r+"$"+e}),gs=function(e){return Jr(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},Ue="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",lv="rgb[a]?\\(("+Ue+"[%]?)\\s*,\\s*("+Ue+"[%]?)\\s*,\\s*("+Ue+"[%]?)(?:\\s*,\\s*("+Ue+"))?\\)",vv="rgb[a]?\\((?:"+Ue+"[%]?)\\s*,\\s*(?:"+Ue+"[%]?)\\s*,\\s*(?:"+Ue+"[%]?)(?:\\s*,\\s*(?:"+Ue+"))?\\)",fv="hsl[a]?\\(("+Ue+")\\s*,\\s*("+Ue+"[%])\\s*,\\s*("+Ue+"[%])(?:\\s*,\\s*("+Ue+"))?\\)",dv="hsl[a]?\\((?:"+Ue+")\\s*,\\s*(?:"+Ue+"[%])\\s*,\\s*(?:"+Ue+"[%])(?:\\s*,\\s*(?:"+Ue+"))?\\)",cv="\\#[0-9a-fA-F]{3}",hv="\\#[0-9a-fA-F]{6}",ps=function(e,t){return e<t?-1:e>t?1:0},gv=function(e,t){return-1*ps(e,t)},ce=Object.assign!=null?Object.assign.bind(Object):function(r){for(var e=arguments,t=1;t<e.length;t++){var a=e[t];if(a!=null)for(var n=Object.keys(a),i=0;i<n.length;i++){var s=n[i];r[s]=a[s]}}return r},pv=function(e){if(!(!(e.length===4||e.length===7)||e[0]!=="#")){var t=e.length===4,a,n,i,s=16;return t?(a=parseInt(e[1]+e[1],s),n=parseInt(e[2]+e[2],s),i=parseInt(e[3]+e[3],s)):(a=parseInt(e[1]+e[2],s),n=parseInt(e[3]+e[4],s),i=parseInt(e[5]+e[6],s)),[a,n,i]}},mv=function(e){var t,a,n,i,s,o,u,l;function v(c,m,g){return g<0&&(g+=1),g>1&&(g-=1),g<1/6?c+(m-c)*6*g:g<1/2?m:g<2/3?c+(m-c)*(2/3-g)*6:c}var f=new RegExp("^"+fv+"$").exec(e);if(f){if(a=parseInt(f[1]),a<0?a=(360- -1*a%360)%360:a>360&&(a=a%360),a/=360,n=parseFloat(f[2]),n<0||n>100||(n=n/100,i=parseFloat(f[3]),i<0||i>100)||(i=i/100,s=f[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,h=2*i-d;o=Math.round(255*v(h,d,a+1/3)),u=Math.round(255*v(h,d,a)),l=Math.round(255*v(h,d,a-1/3))}t=[o,u,l,s]}return t},yv=function(e){var t,a=new RegExp("^"+lv+"$").exec(e);if(a){t=[];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;t.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;t.push(l)}}return t},wv=function(e){return bv[e.toLowerCase()]},ms=function(e){return(Re(e)?e:null)||wv(e)||pv(e)||yv(e)||mv(e)},bv={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]},ys=function(e){for(var t=e.map,a=e.keys,n=a.length,i=0;i<n;i++){var s=a[i];if(Se(s))throw Error("Tried to set map with object key");i<a.length-1?(t[s]==null&&(t[s]={}),t=t[s]):t[s]=e.value}},ws=function(e){for(var t=e.map,a=e.keys,n=a.length,i=0;i<n;i++){var s=a[i];if(Se(s))throw Error("Tried to get map with object key");if(t=t[s],t==null)return t}return t};function Fv(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var ht=Fv,oa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ev(r,e){return e={exports:{}},r(e,e.exports),e.exports}var xv=typeof oa=="object"&&oa&&oa.Object===Object&&oa,Cv=xv,Tv=typeof self=="object"&&self&&self.Object===Object&&self,Sv=Cv||Tv||Function("return this")(),Ka=Sv,kv=function(){return Ka.Date.now()},ei=kv,Dv=/\s/;function Pv(r){for(var e=r.length;e--&&Dv.test(r.charAt(e)););return e}var Bv=Pv,Av=/^\s+/;function Iv(r){return r&&r.slice(0,Bv(r)+1).replace(Av,"")}var Mv=Iv,Rv=Ka.Symbol,Pt=Rv,bs=Object.prototype,Lv=bs.hasOwnProperty,Ov=bs.toString,ua=Pt?Pt.toStringTag:void 0;function _v(r){var e=Lv.call(r,ua),t=r[ua];try{r[ua]=void 0;var a=!0}catch{}var n=Ov.call(r);return a&&(e?r[ua]=t:delete r[ua]),n}var Nv=_v,zv=Object.prototype,Vv=zv.toString;function $v(r){return Vv.call(r)}var qv=$v,Wv="[object Null]",Hv="[object Undefined]",Fs=Pt?Pt.toStringTag:void 0;function Gv(r){return r==null?r===void 0?Hv:Wv:Fs&&Fs in Object(r)?Nv(r):qv(r)}var Es=Gv;function Uv(r){return r!=null&&typeof r=="object"}var Kv=Uv,Xv="[object Symbol]";function Yv(r){return typeof r=="symbol"||Kv(r)&&Es(r)==Xv}var la=Yv,xs=0/0,Zv=/^[-+]0x[0-9a-f]+$/i,Qv=/^0b[01]+$/i,Jv=/^0o[0-7]+$/i,jv=parseInt;function ef(r){if(typeof r=="number")return r;if(la(r))return xs;if(ht(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=ht(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=Mv(r);var t=Qv.test(r);return t||Jv.test(r)?jv(r.slice(2),t?2:8):Zv.test(r)?xs:+r}var Cs=ef,rf="Expected a function",tf=Math.max,af=Math.min;function nf(r,e,t){var a,n,i,s,o,u,l=0,v=!1,f=!1,d=!0;if(typeof r!="function")throw new TypeError(rf);e=Cs(e)||0,ht(t)&&(v=!!t.leading,f="maxWait"in t,i=f?tf(Cs(t.maxWait)||0,e):i,d="trailing"in t?!!t.trailing:d);function h(x){var E=a,T=n;return a=n=void 0,l=x,s=r.apply(T,E),s}function c(x){return l=x,o=setTimeout(p,e),v?h(x):s}function m(x){var E=x-u,T=x-l,F=e-E;return f?af(F,i-T):F}function g(x){var E=x-u,T=x-l;return u===void 0||E>=e||E<0||f&&T>=i}function p(){var x=ei();if(g(x))return y(x);o=setTimeout(p,m(x))}function y(x){return o=void 0,d&&a?h(x):(a=n=void 0,s)}function w(){o!==void 0&&clearTimeout(o),l=0,a=u=n=o=void 0}function b(){return o===void 0?s:y(ei())}function k(){var x=ei(),E=g(x);if(a=arguments,n=this,u=x,E){if(o===void 0)return c(u);if(f)return clearTimeout(o),o=setTimeout(p,e),h(u)}return o===void 0&&(o=setTimeout(p,e)),s}return k.cancel=w,k.flush=b,k}var va=nf,ri=Ge?Ge.performance:null,Ts=ri&&ri.now?function(){return ri.now()}:function(){return Date.now()},sf=function(){if(Ge){if(Ge.requestAnimationFrame)return function(r){Ge.requestAnimationFrame(r)};if(Ge.mozRequestAnimationFrame)return function(r){Ge.mozRequestAnimationFrame(r)};if(Ge.webkitRequestAnimationFrame)return function(r){Ge.webkitRequestAnimationFrame(r)};if(Ge.msRequestAnimationFrame)return function(r){Ge.msRequestAnimationFrame(r)}}return function(r){r&&setTimeout(function(){r(Ts())},1e3/60)}}(),Xa=function(e){return sf(e)},qr=Ts,Bt=9261,Ss=65599,fa=5381,ks=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bt,a=t,n;n=e.next(),!n.done;)a=a*Ss+n.value|0;return a},da=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bt;return t*Ss+e|0},ca=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:fa;return(t<<5)+t+e|0},of=function(e,t){return e*2097152+t},jr=function(e){return e[0]*2097152+e[1]},Ya=function(e,t){return[da(e[0],t[0]),ca(e[1],t[1])]},uf=function(e,t){var a={value:0,done:!1},n=0,i=e.length,s={next:function(){return n<i?a.value=e[n++]:a.done=!0,a}};return ks(s,t)},et=function(e,t){var a={value:0,done:!1},n=0,i=e.length,s={next:function(){return n<i?a.value=e.charCodeAt(n++):a.done=!0,a}};return ks(s,t)},Ds=function(){return lf(arguments)},lf=function(e){for(var t,a=0;a<e.length;a++){var n=e[a];a===0?t=et(n):t=et(n,t)}return t},Ps=!0,vf=console.warn!=null,ff=console.trace!=null,ti=Number.MAX_SAFE_INTEGER||9007199254740991,Bs=function(){return!0},Za=function(){return!1},As=function(){return 0},ai=function(){},Ve=function(e){throw new Error(e)},Is=function(e){if(e!==void 0)Ps=!!e;else return Ps},Pe=function(e){Is()&&(vf?console.warn(e):(console.log(e),ff&&console.trace()))},df=function(e){return ce({},e)},Ir=function(e){return e==null?e:Re(e)?e.slice():Se(e)?df(e):e},cf=function(e){return e.slice()},Ms=function(e,t){for(t=e="";e++<36;t+=e*51&52?(e^15?8^Math.random()*(e^20?16:4):4).toString(16):"-");return t},hf={},Rs=function(){return hf},Ye=function(e){var t=Object.keys(e);return function(a){for(var n={},i=0;i<t.length;i++){var s=t[i],o=a==null?void 0:a[s];n[s]=o===void 0?e[s]:o}return n}},rt=function(e,t,a){for(var n=e.length-1;n>=0&&!(e[n]===t&&(e.splice(n,1),a));n--);},ni=function(e){e.splice(0,e.length)},gf=function(e,t){for(var a=0;a<t.length;a++){var n=t[a];e.push(n)}},Sr=function(e,t,a){return a&&(t=hs(a,t)),e[t]},tt=function(e,t,a,n){a&&(t=hs(a,t)),e[t]=n},pf=function(){function r(){Zr(this,r),this._obj={}}return Qr(r,[{key:"set",value:function(t,a){return this._obj[t]=a,this}},{key:"delete",value:function(t){return this._obj[t]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(t){return this._obj[t]!==void 0}},{key:"get",value:function(t){return this._obj[t]}}]),r}(),Mr=typeof Map<"u"?Map:pf,mf="undefined",yf=function(){function r(e){if(Zr(this,r),this._obj=Object.create(null),this.size=0,e!=null){var t;e.instanceString!=null&&e.instanceString()===this.instanceString()?t=e.toArray():t=e;for(var a=0;a<t.length;a++)this.add(t[a])}}return Qr(r,[{key:"instanceString",value:function(){return"set"}},{key:"add",value:function(t){var a=this._obj;a[t]!==1&&(a[t]=1,this.size++)}},{key:"delete",value:function(t){var a=this._obj;a[t]===1&&(a[t]=0,this.size--)}},{key:"clear",value:function(){this._obj=Object.create(null)}},{key:"has",value:function(t){return this._obj[t]===1}},{key:"toArray",value:function(){var t=this;return Object.keys(this._obj).filter(function(a){return t.has(a)})}},{key:"forEach",value:function(t,a){return this.toArray().forEach(t,a)}}]),r}(),At=(typeof Set>"u"?"undefined":He(Set))!==mf?Set:yf,Qa=function(e,t){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(e===void 0||t===void 0||!Jn(e)){Ve("An element must have a core reference and parameters set");return}var n=t.group;if(n==null&&(t.data&&t.data.source!=null&&t.data.target!=null?n="edges":n="nodes"),n!=="nodes"&&n!=="edges"){Ve("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:t.data||{},position:t.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:!!t.selected,selectable:t.selectable===void 0?!0:!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:t.grabbable===void 0?!0:!!t.grabbable,pannable:t.pannable===void 0?n==="edges":!!t.pannable,active:!1,classes:new At,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:t.parent&&t.parent.isNode()?t.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),t.renderedPosition){var s=t.renderedPosition,o=e.pan(),u=e.zoom();i.position={x:(s.x-o.x)/u,y:(s.y-o.y)/u}}var l=[];Re(t.classes)?l=t.classes:fe(t.classes)&&(l=t.classes.split(/\s+/));for(var v=0,f=l.length;v<f;v++){var d=l[v];!d||d===""||i.classes.add(d)}this.createEmitter();var h=t.style||t.css;h&&(Pe("Setting a `style` bypass at element creation should be done only when absolutely necessary.  Try to use the stylesheet instead."),this.style(h)),(a===void 0||a)&&this.restore()},Ls=function(e){return e={bfs:e.bfs||!e.dfs,dfs:e.dfs||!e.bfs},function(a,n,i){var s;Se(a)&&!yr(a)&&(s=a,a=s.roots||s.root,n=s.visit,i=s.directed),i=arguments.length===2&&!ze(n)?n:i,n=ze(n)?n:function(){};for(var o=this._private.cy,u=a=fe(a)?this.filter(a):a,l=[],v=[],f={},d={},h={},c=0,m,g=this.byGroup(),p=g.nodes,y=g.edges,w=0;w<u.length;w++){var b=u[w],k=b.id();b.isNode()&&(l.unshift(b),e.bfs&&(h[k]=!0,v.push(b)),d[k]=0)}for(var x=function(){var B=e.bfs?l.shift():l.pop(),A=B.id();if(e.dfs){if(h[A])return"continue";h[A]=!0,v.push(B)}var M=d[A],I=f[A],R=I!=null?I.source():null,L=I!=null?I.target():null,V=I==null?void 0:B.same(R)?L[0]:R[0],H=void 0;if(H=n(B,I,V,c++,M),H===!0)return m=B,"break";if(H===!1)return"break";for(var z=B.connectedEdges().filter(function(Z){return(!i||Z.source().same(B))&&y.has(Z)}),$=0;$<z.length;$++){var K=z[$],Y=K.connectedNodes().filter(function(Z){return!Z.same(B)&&p.has(Z)}),Q=Y.id();Y.length!==0&&!h[Q]&&(Y=Y[0],l.push(Y),e.bfs&&(h[Q]=!0,v.push(Y)),f[Q]=K,d[Q]=d[A]+1)}};l.length!==0;){var E=x();if(E!=="continue"&&E==="break")break}for(var T=o.collection(),F=0;F<v.length;F++){var S=v[F],D=f[S.id()];D!=null&&T.push(D),T.push(S)}return{path:o.collection(T),found:o.collection(m)}}},ha={breadthFirstSearch:Ls({bfs:!0}),depthFirstSearch:Ls({dfs:!0})};ha.bfs=ha.breadthFirstSearch,ha.dfs=ha.depthFirstSearch;var wf=Ev(function(r,e){(function(){var t,a,n,i,s,o,u,l,v,f,d,h,c,m,g;n=Math.floor,f=Math.min,a=function(p,y){return p<y?-1:p>y?1:0},v=function(p,y,w,b,k){var x;if(w==null&&(w=0),k==null&&(k=a),w<0)throw new Error("lo must be non-negative");for(b==null&&(b=p.length);w<b;)x=n((w+b)/2),k(y,p[x])<0?b=x:w=x+1;return[].splice.apply(p,[w,w-w].concat(y)),y},o=function(p,y,w){return w==null&&(w=a),p.push(y),m(p,0,p.length-1,w)},s=function(p,y){var w,b;return y==null&&(y=a),w=p.pop(),p.length?(b=p[0],p[0]=w,g(p,0,y)):b=w,b},l=function(p,y,w){var b;return w==null&&(w=a),b=p[0],p[0]=y,g(p,0,w),b},u=function(p,y,w){var b;return w==null&&(w=a),p.length&&w(p[0],y)<0&&(b=[p[0],y],y=b[0],p[0]=b[1],g(p,0,w)),y},i=function(p,y){var w,b,k,x,E,T;for(y==null&&(y=a),x=(function(){T=[];for(var F=0,S=n(p.length/2);0<=S?F<S:F>S;0<=S?F++:F--)T.push(F);return T}).apply(this).reverse(),E=[],b=0,k=x.length;b<k;b++)w=x[b],E.push(g(p,w,y));return E},c=function(p,y,w){var b;if(w==null&&(w=a),b=p.indexOf(y),b!==-1)return m(p,0,b,w),g(p,b,w)},d=function(p,y,w){var b,k,x,E,T;if(w==null&&(w=a),k=p.slice(0,y),!k.length)return k;for(i(k,w),T=p.slice(y),x=0,E=T.length;x<E;x++)b=T[x],u(k,b,w);return k.sort(w).reverse()},h=function(p,y,w){var b,k,x,E,T,F,S,D,C;if(w==null&&(w=a),y*10<=p.length){if(x=p.slice(0,y).sort(w),!x.length)return x;for(k=x[x.length-1],S=p.slice(y),E=0,F=S.length;E<F;E++)b=S[E],w(b,k)<0&&(v(x,b,0,null,w),x.pop(),k=x[x.length-1]);return x}for(i(p,w),C=[],T=0,D=f(y,p.length);0<=D?T<D:T>D;0<=D?++T:--T)C.push(s(p,w));return C},m=function(p,y,w,b){var k,x,E;for(b==null&&(b=a),k=p[w];w>y;){if(E=w-1>>1,x=p[E],b(k,x)<0){p[w]=x,w=E;continue}break}return p[w]=k},g=function(p,y,w){var b,k,x,E,T;for(w==null&&(w=a),k=p.length,T=y,x=p[y],b=2*y+1;b<k;)E=b+1,E<k&&!(w(p[b],p[E])<0)&&(b=E),p[y]=p[b],y=b,b=2*y+1;return p[y]=x,m(p,T,y,w)},t=function(){p.push=o,p.pop=s,p.replace=l,p.pushpop=u,p.heapify=i,p.updateItem=c,p.nlargest=d,p.nsmallest=h;function p(y){this.cmp=y??a,this.nodes=[]}return p.prototype.push=function(y){return o(this.nodes,y,this.cmp)},p.prototype.pop=function(){return s(this.nodes,this.cmp)},p.prototype.peek=function(){return this.nodes[0]},p.prototype.contains=function(y){return this.nodes.indexOf(y)!==-1},p.prototype.replace=function(y){return l(this.nodes,y,this.cmp)},p.prototype.pushpop=function(y){return u(this.nodes,y,this.cmp)},p.prototype.heapify=function(){return i(this.nodes,this.cmp)},p.prototype.updateItem=function(y){return c(this.nodes,y,this.cmp)},p.prototype.clear=function(){return this.nodes=[]},p.prototype.empty=function(){return this.nodes.length===0},p.prototype.size=function(){return this.nodes.length},p.prototype.clone=function(){var y;return y=new p,y.nodes=this.nodes.slice(0),y},p.prototype.toArray=function(){return this.nodes.slice(0)},p.prototype.insert=p.prototype.push,p.prototype.top=p.prototype.peek,p.prototype.front=p.prototype.peek,p.prototype.has=p.prototype.contains,p.prototype.copy=p.prototype.clone,p}(),function(p,y){return r.exports=y()}(this,function(){return t})}).call(oa)}),ga=wf,bf=Ye({root:null,weight:function(e){return 1},directed:!1}),Ff={dijkstra:function(e){if(!Se(e)){var t=arguments;e={root:t[0],weight:t[1],directed:t[2]}}var a=bf(e),n=a.root,i=a.weight,s=a.directed,o=this,u=i,l=fe(n)?this.filter(n)[0]:n[0],v={},f={},d={},h=this.byGroup(),c=h.nodes,m=h.edges;m.unmergeBy(function(M){return M.isLoop()});for(var g=function(I){return v[I.id()]},p=function(I,R){v[I.id()]=R,y.updateItem(I)},y=new ga(function(M,I){return g(M)-g(I)}),w=0;w<c.length;w++){var b=c[w];v[b.id()]=b.same(l)?0:1/0,y.push(b)}for(var k=function(I,R){for(var L=(s?I.edgesTo(R):I.edgesWith(R)).intersect(m),V=1/0,H,z=0;z<L.length;z++){var $=L[z],K=u($);(K<V||!H)&&(V=K,H=$)}return{edge:H,dist:V}};y.size()>0;){var x=y.pop(),E=g(x),T=x.id();if(d[T]=E,E!==1/0)for(var F=x.neighborhood().intersect(c),S=0;S<F.length;S++){var D=F[S],C=D.id(),B=k(x,D),A=E+B.dist;A<g(D)&&(p(D,A),f[C]={node:x,edge:B.edge})}}return{distanceTo:function(I){var R=fe(I)?c.filter(I)[0]:I[0];return d[R.id()]},pathTo:function(I){var R=fe(I)?c.filter(I)[0]:I[0],L=[],V=R,H=V.id();if(R.length>0)for(L.unshift(R);f[H];){var z=f[H];L.unshift(z.edge),L.unshift(z.node),V=z.node,H=V.id()}return o.spawn(L)}}}},Ef={kruskal:function(e){e=e||function(w){return 1};for(var t=this.byGroup(),a=t.nodes,n=t.edges,i=a.length,s=new Array(i),o=a,u=function(b){for(var k=0;k<s.length;k++){var x=s[k];if(x.has(b))return k}},l=0;l<i;l++)s[l]=this.spawn(a[l]);for(var v=n.sort(function(w,b){return e(w)-e(b)}),f=0;f<v.length;f++){var d=v[f],h=d.source()[0],c=d.target()[0],m=u(h),g=u(c),p=s[m],y=s[g];m!==g&&(o.merge(d),p.merge(y),s.splice(g,1))}return o}},xf=Ye({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),Cf={aStar:function(e){var t=this.cy(),a=xf(e),n=a.root,i=a.goal,s=a.heuristic,o=a.directed,u=a.weight;n=t.collection(n)[0],i=t.collection(i)[0];var l=n.id(),v=i.id(),f={},d={},h={},c=new ga(function(H,z){return d[H.id()]-d[z.id()]}),m=new At,g={},p={},y=function(z,$){c.push(z),m.add($)},w,b,k=function(){w=c.pop(),b=w.id(),m.delete(b)},x=function(z){return m.has(z)};y(n,l),f[l]=0,d[l]=s(n);for(var E=0;c.size()>0;){if(k(),E++,b===v){for(var T=[],F=i,S=v,D=p[S];T.unshift(F),D!=null&&T.unshift(D),F=g[S],F!=null;)S=F.id(),D=p[S];return{found:!0,distance:f[b],path:this.spawn(T),steps:E}}h[b]=!0;for(var C=w._private.edges,B=0;B<C.length;B++){var A=C[B];if(this.hasElementWithId(A.id())&&!(o&&A.data("source")!==b)){var M=A.source(),I=A.target(),R=M.id()!==b?M:I,L=R.id();if(this.hasElementWithId(L)&&!h[L]){var V=f[b]+u(A);if(!x(L)){f[L]=V,d[L]=V+s(R),y(R,L),g[L]=w,p[L]=A;continue}V<f[L]&&(f[L]=V,d[L]=V+s(R),g[L]=w,p[L]=A)}}}}return{found:!1,distance:void 0,path:void 0,steps:E}}},Tf=Ye({weight:function(e){return 1},directed:!1}),Sf={floydWarshall:function(e){for(var t=this.cy(),a=Tf(e),n=a.weight,i=a.directed,s=n,o=this.byGroup(),u=o.nodes,l=o.edges,v=u.length,f=v*v,d=function(K){return u.indexOf(K)},h=function(K){return u[K]},c=new Array(f),m=0;m<f;m++){var g=m%v,p=(m-g)/v;p===g?c[m]=0:c[m]=1/0}for(var y=new Array(f),w=new Array(f),b=0;b<l.length;b++){var k=l[b],x=k.source()[0],E=k.target()[0];if(x!==E){var T=d(x),F=d(E),S=T*v+F,D=s(k);if(c[S]>D&&(c[S]=D,y[S]=F,w[S]=k),!i){var C=F*v+T;!i&&c[C]>D&&(c[C]=D,y[C]=T,w[C]=k)}}}for(var B=0;B<v;B++)for(var A=0;A<v;A++)for(var M=A*v+B,I=0;I<v;I++){var R=A*v+I,L=B*v+I;c[M]+c[L]<c[R]&&(c[R]=c[M]+c[L],y[R]=y[M])}var V=function(K){return(fe(K)?t.filter(K):K)[0]},H=function(K){return d(V(K))},z={distance:function(K,Y){var Q=H(K),Z=H(Y);return c[Q*v+Z]},path:function(K,Y){var Q=H(K),Z=H(Y),j=h(Q);if(Q===Z)return j.collection();if(y[Q*v+Z]==null)return t.collection();var re=t.collection(),W=Q,O;for(re.merge(j);Q!==Z;)W=Q,Q=y[Q*v+Z],O=w[W*v+Q],re.merge(O),re.merge(h(Q));return re}};return z}},kf=Ye({weight:function(e){return 1},directed:!1,root:null}),Df={bellmanFord:function(e){var t=this,a=kf(e),n=a.weight,i=a.directed,s=a.root,o=n,u=this,l=this.cy(),v=this.byGroup(),f=v.edges,d=v.nodes,h=d.length,c=new Mr,m=!1,g=[];s=l.collection(s)[0],f.unmergeBy(function(Ie){return Ie.isLoop()});for(var p=f.length,y=function(le){var oe=c.get(le.id());return oe||(oe={},c.set(le.id(),oe)),oe},w=function(le){return(fe(le)?l.$(le):le)[0]},b=function(le){return y(w(le)).dist},k=function(le){for(var oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:s,pe=w(le),me=[],he=pe;;){if(he==null)return t.spawn();var ye=y(he),Ee=ye.edge,Te=ye.pred;if(me.unshift(he[0]),he.same(oe)&&me.length>0)break;Ee!=null&&me.unshift(Ee),he=Te}return u.spawn(me)},x=0;x<h;x++){var E=d[x],T=y(E);E.same(s)?T.dist=0:T.dist=1/0,T.pred=null,T.edge=null}for(var F=!1,S=function(le,oe,pe,me,he,ye){var Ee=me.dist+ye;Ee<he.dist&&!pe.same(me.edge)&&(he.dist=Ee,he.pred=le,he.edge=pe,F=!0)},D=1;D<h;D++){F=!1;for(var C=0;C<p;C++){var B=f[C],A=B.source(),M=B.target(),I=o(B),R=y(A),L=y(M);S(A,M,B,R,L,I),i||S(M,A,B,L,R,I)}if(!F)break}if(F)for(var V=[],H=0;H<p;H++){var z=f[H],$=z.source(),K=z.target(),Y=o(z),Q=y($).dist,Z=y(K).dist;if(Q+Y<Z||!i&&Z+Y<Q)if(m||(Pe("Graph contains a negative weight cycle for Bellman-Ford"),m=!0),e.findNegativeWeightCycles!==!1){var j=[];Q+Y<Z&&j.push($),!i&&Z+Y<Q&&j.push(K);for(var re=j.length,W=0;W<re;W++){var O=j[W],G=[O];G.push(y(O).edge);for(var ee=y(O).pred;G.indexOf(ee)===-1;)G.push(ee),G.push(y(ee).edge),ee=y(ee).pred;G=G.slice(G.indexOf(ee));for(var ie=G[0].id(),ue=0,Ce=2;Ce<G.length;Ce+=2)G[Ce].id()<ie&&(ie=G[Ce].id(),ue=Ce);G=G.slice(ue).concat(G.slice(0,ue)),G.push(G[0]);var Ae=G.map(function(Ie){return Ie.id()}).join(",");V.indexOf(Ae)===-1&&(g.push(u.spawn(G)),V.push(Ae))}}else break}return{distanceTo:b,pathTo:k,hasNegativeWeightCycle:m,negativeWeightCycles:g}}},Pf=Math.sqrt(2),Bf=function(e,t,a){a.length===0&&Ve("Karger-Stein must be run on a connected (sub)graph");for(var n=a[e],i=n[1],s=n[2],o=t[i],u=t[s],l=a,v=l.length-1;v>=0;v--){var f=l[v],d=f[1],h=f[2];(t[d]===o&&t[h]===u||t[d]===u&&t[h]===o)&&l.splice(v,1)}for(var c=0;c<l.length;c++){var m=l[c];m[1]===u?(l[c]=m.slice(),l[c][1]=o):m[2]===u&&(l[c]=m.slice(),l[c][2]=o)}for(var g=0;g<t.length;g++)t[g]===u&&(t[g]=o);return l},ii=function(e,t,a,n){for(;a>n;){var i=Math.floor(Math.random()*t.length);t=Bf(i,e,t),a--}return t},Af={kargerStein:function(){var e=this,t=this.byGroup(),a=t.nodes,n=t.edges;n.unmergeBy(function(L){return L.isLoop()});var i=a.length,s=n.length,o=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),u=Math.floor(i/Pf);if(i<2){Ve("At least 2 nodes are required for Karger-Stein algorithm");return}for(var l=[],v=0;v<s;v++){var f=n[v];l.push([v,a.indexOf(f.source()),a.indexOf(f.target())])}for(var d=1/0,h=[],c=new Array(i),m=new Array(i),g=new Array(i),p=function(V,H){for(var z=0;z<i;z++)H[z]=V[z]},y=0;y<=o;y++){for(var w=0;w<i;w++)m[w]=w;var b=ii(m,l.slice(),i,u),k=b.slice();p(m,g);var x=ii(m,b,u,2),E=ii(g,k,u,2);x.length<=E.length&&x.length<d?(d=x.length,h=x,p(m,c)):E.length<=x.length&&E.length<d&&(d=E.length,h=E,p(g,c))}for(var T=this.spawn(h.map(function(L){return n[L[0]]})),F=this.spawn(),S=this.spawn(),D=c[0],C=0;C<c.length;C++){var B=c[C],A=a[C];B===D?F.merge(A):S.merge(A)}var M=function(V){var H=e.spawn();return V.forEach(function(z){H.merge(z),z.connectedEdges().forEach(function($){e.contains($)&&!T.contains($)&&H.merge($)})}),H},I=[M(F),M(S)],R={cut:T,components:I,partition1:F,partition2:S};return R}},If=function(e){return{x:e.x,y:e.y}},Ja=function(e,t,a){return{x:e.x*t+a.x,y:e.y*t+a.y}},Os=function(e,t,a){return{x:(e.x-a.x)/t,y:(e.y-a.y)/t}},It=function(e){return{x:e[0],y:e[1]}},Mf=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=1/0,i=t;i<a;i++){var s=e[i];isFinite(s)&&(n=Math.min(s,n))}return n},Rf=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=-1/0,i=t;i<a;i++){var s=e[i];isFinite(s)&&(n=Math.max(s,n))}return n},Lf=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=0,i=0,s=t;s<a;s++){var o=e[s];isFinite(o)&&(n+=o,i++)}return n/i},Of=function(e){var t=arguments.length>1&&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(t,a):(a<e.length&&e.splice(a,e.length-a),t>0&&e.splice(0,t));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,h){return d-h});var v=e.length,f=Math.floor(v/2);return v%2!==0?e[f+1+o]:(e[f-1+o]+e[f+o])/2},_f=function(e){return Math.PI*e/180},ja=function(e,t){return Math.atan2(t,e)-Math.PI/2},si=Math.log2||function(r){return Math.log(r)/Math.log(2)},_s=function(e){return e>0?1:e<0?-1:0},gt=function(e,t){return Math.sqrt(pt(e,t))},pt=function(e,t){var a=t.x-e.x,n=t.y-e.y;return a*a+n*n},Nf=function(e){for(var t=e.length,a=0,n=0;n<t;n++)a+=e[n];for(var i=0;i<t;i++)e[i]=e[i]/a;return e},Ze=function(e,t,a,n){return(1-n)*(1-n)*e+2*(1-n)*n*t+n*n*a},Mt=function(e,t,a,n){return{x:Ze(e.x,t.x,a.x,n),y:Ze(e.y,t.y,a.y,n)}},zf=function(e,t,a,n){var i={x:t.x-e.x,y:t.y-e.y},s=gt(e,t),o={x:i.x/s,y:i.y/s};return a=a??0,n=n??a*s,{x:e.x+o.x*n,y:e.y+o.y*n}},pa=function(e,t,a){return Math.max(e,Math.min(a,t))},hr=function(e){if(e==null)return{x1:1/0,y1:1/0,x2:-1/0,y2:-1/0,w:0,h:0};if(e.x1!=null&&e.y1!=null){if(e.x2!=null&&e.y2!=null&&e.x2>=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(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}}},Vf=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},$f=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},qf=function(e,t,a){return{x1:e.x1+t,x2:e.x2+t,y1:e.y1+a,y2:e.y2+a,w:e.w,h:e.h}},Ns=function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},Wf=function(e,t,a){e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,a),e.y2=Math.max(e.y2,a),e.h=e.y2-e.y1},en=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},rn=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0],a,n,i,s;if(t.length===1)a=n=i=s=t[0];else if(t.length===2)a=i=t[0],s=n=t[1];else if(t.length===4){var o=We(t,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},zs=function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},oi=function(e,t){return!(e.x1>t.x2||t.x1>e.x2||e.x2<t.x1||t.x2<e.x1||e.y2<t.y1||t.y2<e.y1||e.y1>t.y2||t.y1>e.y2)},Rt=function(e,t,a){return e.x1<=t&&t<=e.x2&&e.y1<=a&&a<=e.y2},Hf=function(e,t){return Rt(e,t.x,t.y)},Vs=function(e,t){return Rt(e,t.x1,t.y1)&&Rt(e,t.x2,t.y2)},$s=function(e,t,a,n,i,s,o){var u=arguments.length>7&&arguments[7]!==void 0?arguments[7]:"auto",l=u==="auto"?yt(i,s):u,v=i/2,f=s/2;l=Math.min(l,v,f);var d=l!==v,h=l!==f,c;if(d){var m=a-v+l-o,g=n-f-o,p=a+v-l+o,y=g;if(c=at(e,t,a,n,m,g,p,y,!1),c.length>0)return c}if(h){var w=a+v+o,b=n-f+l-o,k=w,x=n+f-l+o;if(c=at(e,t,a,n,w,b,k,x,!1),c.length>0)return c}if(d){var E=a-v+l-o,T=n+f+o,F=a+v-l+o,S=T;if(c=at(e,t,a,n,E,T,F,S,!1),c.length>0)return c}if(h){var D=a-v-o,C=n-f+l-o,B=D,A=n+f-l+o;if(c=at(e,t,a,n,D,C,B,A,!1),c.length>0)return c}var M;{var I=a-v+l,R=n-f+l;if(M=ma(e,t,a,n,I,R,l+o),M.length>0&&M[0]<=I&&M[1]<=R)return[M[0],M[1]]}{var L=a+v-l,V=n-f+l;if(M=ma(e,t,a,n,L,V,l+o),M.length>0&&M[0]>=L&&M[1]<=V)return[M[0],M[1]]}{var H=a+v-l,z=n+f-l;if(M=ma(e,t,a,n,H,z,l+o),M.length>0&&M[0]>=H&&M[1]>=z)return[M[0],M[1]]}{var $=a-v+l,K=n+f-l;if(M=ma(e,t,a,n,$,K,l+o),M.length>0&&M[0]<=$&&M[1]>=K)return[M[0],M[1]]}return[]},Gf=function(e,t,a,n,i,s,o){var u=o,l=Math.min(a,i),v=Math.max(a,i),f=Math.min(n,s),d=Math.max(n,s);return l-u<=e&&e<=v+u&&f-u<=t&&t<=d+u},Uf=function(e,t,a,n,i,s,o,u,l){var v={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!(e<v.x1||e>v.x2||t<v.y1||t>v.y2)},Kf=function(e,t,a,n){a-=n;var i=t*t-4*e*a;if(i<0)return[];var s=Math.sqrt(i),o=2*e,u=(-t+s)/o,l=(-t-s)/o;return[u,l]},Xf=function(e,t,a,n,i){var s=1e-5;e===0&&(e=s),t/=e,a/=e,n/=e;var o,u,l,v,f,d,h,c;if(u=(3*a-t*t)/9,l=-(27*n)+t*(9*a-2*(t*t)),l/=54,o=u*u*u+l*l,i[1]=0,h=t/3,o>0){f=l+Math.sqrt(o),f=f<0?-Math.pow(-f,1/3):Math.pow(f,1/3),d=l-Math.sqrt(o),d=d<0?-Math.pow(-d,1/3):Math.pow(d,1/3),i[0]=-h+f+d,h+=(f+d)/2,i[4]=i[2]=-h,h=Math.sqrt(3)*(-d+f)/2,i[3]=h,i[5]=-h;return}if(i[5]=i[3]=0,o===0){c=l<0?-Math.pow(-l,1/3):Math.pow(l,1/3),i[0]=-h+2*c,i[4]=i[2]=-(c+h);return}u=-u,v=u*u*u,v=Math.acos(l/Math.sqrt(v)),c=2*Math.sqrt(u),i[0]=-h+c*Math.cos(v/3),i[2]=-h+c*Math.cos((v+2*Math.PI)/3),i[4]=-h+c*Math.cos((v+4*Math.PI)/3)},Yf=function(e,t,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,v=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,f=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*t+2*s*s+2*s*t-u*t,d=1*a*i-a*a+a*e-i*e+n*s-n*n+n*t-s*t,h=[];Xf(l,v,f,d,h);for(var c=1e-7,m=[],g=0;g<6;g+=2)Math.abs(h[g+1])<c&&h[g]>=0&&h[g]<=1&&m.push(h[g]);m.push(1),m.push(0);for(var p=-1,y,w,b,k=0;k<m.length;k++)y=Math.pow(1-m[k],2)*a+2*(1-m[k])*m[k]*i+m[k]*m[k]*o,w=Math.pow(1-m[k],2)*n+2*(1-m[k])*m[k]*s+m[k]*m[k]*u,b=Math.pow(y-e,2)+Math.pow(w-t,2),p>=0?b<p&&(p=b):p=b;return p},Zf=function(e,t,a,n,i,s){var o=[e-a,t-n],u=[i-a,s-n],l=u[0]*u[0]+u[1]*u[1],v=o[0]*o[0]+o[1]*o[1],f=o[0]*u[0]+o[1]*u[1],d=f*f/l;return f<0?v:d>l?(e-i)*(e-i)+(t-s)*(t-s):v-d},gr=function(e,t,a){for(var n,i,s,o,u,l=0,v=0;v<a.length/2;v++)if(n=a[v*2],i=a[v*2+1],v+1<a.length/2?(s=a[(v+1)*2],o=a[(v+1)*2+1]):(s=a[(v+1-a.length/2)*2],o=a[(v+1-a.length/2)*2+1]),!(n==e&&s==e))if(n>=e&&e>=s||n<=e&&e<=s)u=(e-n)/(s-n)*(o-i)+i,u>t&&l++;else continue;return l%2!==0},Wr=function(e,t,a,n,i,s,o,u,l){var v=new Array(a.length),f;u[0]!=null?(f=Math.atan(u[1]/u[0]),u[0]<0?f=f+Math.PI/2:f=-f-Math.PI/2):f=u;for(var d=Math.cos(-f),h=Math.sin(-f),c=0;c<v.length/2;c++)v[c*2]=s/2*(a[c*2]*d-a[c*2+1]*h),v[c*2+1]=o/2*(a[c*2+1]*d+a[c*2]*h),v[c*2]+=n,v[c*2+1]+=i;var m;if(l>0){var g=an(v,-l);m=tn(g)}else m=v;return gr(e,t,m)},Qf=function(e,t,a,n,i,s,o,u){for(var l=new Array(a.length*2),v=0;v<u.length;v++){var f=u[v];l[v*4+0]=f.startX,l[v*4+1]=f.startY,l[v*4+2]=f.stopX,l[v*4+3]=f.stopY;var d=Math.pow(f.cx-e,2)+Math.pow(f.cy-t,2);if(d<=Math.pow(f.radius,2))return!0}return gr(e,t,l)},tn=function(e){for(var t=new Array(e.length/2),a,n,i,s,o,u,l,v,f=0;f<e.length/4;f++){a=e[f*4],n=e[f*4+1],i=e[f*4+2],s=e[f*4+3],f<e.length/4-1?(o=e[(f+1)*4],u=e[(f+1)*4+1],l=e[(f+1)*4+2],v=e[(f+1)*4+3]):(o=e[0],u=e[1],l=e[2],v=e[3]);var d=at(a,n,i,s,o,u,l,v,!0);t[f*2]=d[0],t[f*2+1]=d[1]}return t},an=function(e,t){for(var a=new Array(e.length*2),n,i,s,o,u=0;u<e.length/2;u++){n=e[u*2],i=e[u*2+1],u<e.length/2-1?(s=e[(u+1)*2],o=e[(u+1)*2+1]):(s=e[0],o=e[1]);var l=o-i,v=-(s-n),f=Math.sqrt(l*l+v*v),d=l/f,h=v/f;a[u*4]=n+d*t,a[u*4+1]=i+h*t,a[u*4+2]=s+d*t,a[u*4+3]=o+h*t}return a},Jf=function(e,t,a,n,i,s){var o=a-e,u=n-t;o/=i,u/=s;var l=Math.sqrt(o*o+u*u),v=l-1;if(v<0)return[];var f=v/l;return[(a-e)*f+e,(n-t)*f+t]},mt=function(e,t,a,n,i,s,o){return e-=i,t-=s,e/=a/2+o,t/=n/2+o,e*e+t*t<=1},ma=function(e,t,a,n,i,s,o){var u=[a-e,n-t],l=[e-i,t-s],v=u[0]*u[0]+u[1]*u[1],f=2*(l[0]*u[0]+l[1]*u[1]),d=l[0]*l[0]+l[1]*l[1]-o*o,h=f*f-4*v*d;if(h<0)return[];var c=(-f+Math.sqrt(h))/(2*v),m=(-f-Math.sqrt(h))/(2*v),g=Math.min(c,m),p=Math.max(c,m),y=[];if(g>=0&&g<=1&&y.push(g),p>=0&&p<=1&&y.push(p),y.length===0)return[];var w=y[0]*u[0]+e,b=y[0]*u[1]+t;if(y.length>1){if(y[0]==y[1])return[w,b];var k=y[1]*u[0]+e,x=y[1]*u[1]+t;return[w,b,k,x]}else return[w,b]},ui=function(e,t,a){return t<=e&&e<=a||a<=e&&e<=t?e:e<=t&&t<=a||a<=t&&t<=e?t:a},at=function(e,t,a,n,i,s,o,u,l){var v=e-i,f=a-e,d=o-i,h=t-s,c=n-t,m=u-s,g=d*h-m*v,p=f*h-c*v,y=m*f-d*c;if(y!==0){var w=g/y,b=p/y,k=.001,x=0-k,E=1+k;return x<=w&&w<=E&&x<=b&&b<=E?[e+w*f,t+w*c]:l?[e+w*f,t+w*c]:[]}else return g===0||p===0?ui(e,a,o)===o?[o,u]:ui(e,a,i)===i?[i,s]:ui(i,o,a)===a?[a,n]:[]:[]},ya=function(e,t,a,n,i,s,o,u){var l=[],v,f=new Array(a.length),d=!0;s==null&&(d=!1);var h;if(d){for(var c=0;c<f.length/2;c++)f[c*2]=a[c*2]*s+n,f[c*2+1]=a[c*2+1]*o+i;if(u>0){var m=an(f,-u);h=tn(m)}else h=f}else h=a;for(var g,p,y,w,b=0;b<h.length/2;b++)g=h[b*2],p=h[b*2+1],b<h.length/2-1?(y=h[(b+1)*2],w=h[(b+1)*2+1]):(y=h[0],w=h[1]),v=at(e,t,n,i,g,p,y,w),v.length!==0&&l.push(v[0],v[1]);return l},jf=function(e,t,a,n,i,s,o,u,l){var v=[],f,d=new Array(a.length*2);l.forEach(function(y,w){w===0?(d[d.length-2]=y.startX,d[d.length-1]=y.startY):(d[w*4-2]=y.startX,d[w*4-1]=y.startY),d[w*4]=y.stopX,d[w*4+1]=y.stopY,f=ma(e,t,n,i,y.cx,y.cy,y.radius),f.length!==0&&v.push(f[0],f[1])});for(var h=0;h<d.length/4;h++)f=at(e,t,n,i,d[h*4],d[h*4+1],d[h*4+2],d[h*4+3],!1),f.length!==0&&v.push(f[0],f[1]);if(v.length>2){for(var c=[v[0],v[1]],m=Math.pow(c[0]-e,2)+Math.pow(c[1]-t,2),g=1;g<v.length/2;g++){var p=Math.pow(v[g*2]-e,2)+Math.pow(v[g*2+1]-t,2);p<=m&&(c[0]=v[g*2],c[1]=v[g*2+1],m=p)}return c}return v},nn=function(e,t,a){var n=[e[0]-t[0],e[1]-t[1]],i=Math.sqrt(n[0]*n[0]+n[1]*n[1]),s=(i-a)/i;return s<0&&(s=1e-5),[t[0]+s*n[0],t[1]+s*n[1]]},vr=function(e,t){var a=li(e,t);return a=qs(a),a},qs=function(e){for(var t,a,n=e.length/2,i=1/0,s=1/0,o=-1/0,u=-1/0,l=0;l<n;l++)t=e[2*l],a=e[2*l+1],i=Math.min(i,t),o=Math.max(o,t),s=Math.min(s,a),u=Math.max(u,a);for(var v=2/(o-i),f=2/(u-s),d=0;d<n;d++)t=e[2*d]=e[2*d]*v,a=e[2*d+1]=e[2*d+1]*f,i=Math.min(i,t),o=Math.max(o,t),s=Math.min(s,a),u=Math.max(u,a);if(s<-1)for(var h=0;h<n;h++)a=e[2*h+1]=e[2*h+1]+(-1-s);return e},li=function(e,t){var a=1/e*2*Math.PI,n=e%2===0?Math.PI/2+a/2:Math.PI/2;n+=t;for(var i=new Array(e*2),s,o=0;o<e;o++)s=o*a+n,i[2*o]=Math.cos(s),i[2*o+1]=Math.sin(-s);return i},yt=function(e,t){return Math.min(e/4,t/4,8)},Ws=function(e,t){return Math.min(e/10,t/10,8)},vi=function(){return 8},ed=function(e,t,a){return[e-2*t+a,2*(t-e),e]},fi=function(e,t){return{heightOffset:Math.min(15,.05*t),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}},rd=Ye({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),td={pageRank:function(e){for(var t=rd(e),a=t.dampingFactor,n=t.precision,i=t.iterations,s=t.weight,o=this._private.cy,u=this.byGroup(),l=u.nodes,v=u.edges,f=l.length,d=f*f,h=v.length,c=new Array(d),m=new Array(f),g=(1-a)/f,p=0;p<f;p++){for(var y=0;y<f;y++){var w=p*f+y;c[w]=0}m[p]=0}for(var b=0;b<h;b++){var k=v[b],x=k.data("source"),E=k.data("target");if(x!==E){var T=l.indexOfId(x),F=l.indexOfId(E),S=s(k),D=F*f+T;c[D]+=S,m[T]+=S}}for(var C=1/f+g,B=0;B<f;B++)if(m[B]===0)for(var A=0;A<f;A++){var M=A*f+B;c[M]=C}else for(var I=0;I<f;I++){var R=I*f+B;c[R]=c[R]/m[B]+g}for(var L=new Array(f),V=new Array(f),H,z=0;z<f;z++)L[z]=1;for(var $=0;$<i;$++){for(var K=0;K<f;K++)V[K]=0;for(var Y=0;Y<f;Y++)for(var Q=0;Q<f;Q++){var Z=Y*f+Q;V[Y]+=c[Z]*L[Q]}Nf(V),H=L,L=V,V=H;for(var j=0,re=0;re<f;re++){var W=H[re]-L[re];j+=W*W}if(j<n)break}var O={rank:function(ee){return ee=o.collection(ee)[0],L[l.indexOf(ee)]}};return O}},Hs=Ye({root:null,weight:function(e){return 1},directed:!1,alpha:0}),Lt={degreeCentralityNormalized:function(e){e=Hs(e);var t=this.cy(),a=this.nodes(),n=a.length;if(e.directed){for(var v={},f={},d=0,h=0,c=0;c<n;c++){var m=a[c],g=m.id();e.root=m;var p=this.degreeCentrality(e);d<p.indegree&&(d=p.indegree),h<p.outdegree&&(h=p.outdegree),v[g]=p.indegree,f[g]=p.outdegree}return{indegree:function(w){return d==0?0:(fe(w)&&(w=t.filter(w)),v[w.id()]/d)},outdegree:function(w){return h===0?0:(fe(w)&&(w=t.filter(w)),f[w.id()]/h)}}}else{for(var i={},s=0,o=0;o<n;o++){var u=a[o];e.root=u;var l=this.degreeCentrality(e);s<l.degree&&(s=l.degree),i[u.id()]=l.degree}return{degree:function(w){return s===0?0:(fe(w)&&(w=t.filter(w)),i[w.id()]/s)}}}},degreeCentrality:function(e){e=Hs(e);var t=this.cy(),a=this,n=e,i=n.root,s=n.weight,o=n.directed,u=n.alpha;if(i=t.collection(i)[0],o){for(var h=i.connectedEdges(),c=h.filter(function(x){return x.target().same(i)&&a.has(x)}),m=h.filter(function(x){return x.source().same(i)&&a.has(x)}),g=c.length,p=m.length,y=0,w=0,b=0;b<c.length;b++)y+=s(c[b]);for(var k=0;k<m.length;k++)w+=s(m[k]);return{indegree:Math.pow(g,1-u)*Math.pow(y,u),outdegree:Math.pow(p,1-u)*Math.pow(w,u)}}else{for(var l=i.connectedEdges().intersection(a),v=l.length,f=0,d=0;d<l.length;d++)f+=s(l[d]);return{degree:Math.pow(v,1-u)*Math.pow(f,u)}}}};Lt.dc=Lt.degreeCentrality,Lt.dcn=Lt.degreeCentralityNormalised=Lt.degreeCentralityNormalized;var Gs=Ye({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),Ot={closenessCentralityNormalized:function(e){for(var t=Gs(e),a=t.harmonic,n=t.weight,i=t.directed,s=this.cy(),o={},u=0,l=this.nodes(),v=this.floydWarshall({weight:n,directed:i}),f=0;f<l.length;f++){for(var d=0,h=l[f],c=0;c<l.length;c++)if(f!==c){var m=v.distance(h,l[c]);a?d+=1/m:d+=m}a||(d=1/d),u<d&&(u=d),o[h.id()]=d}return{closeness:function(p){return u==0?0:(fe(p)?p=s.filter(p)[0].id():p=p.id(),o[p]/u)}}},closenessCentrality:function(e){var t=Gs(e),a=t.root,n=t.weight,i=t.directed,s=t.harmonic;a=this.filter(a)[0];for(var o=this.dijkstra({root:a,weight:n,directed:i}),u=0,l=this.nodes(),v=0;v<l.length;v++){var f=l[v];if(!f.same(a)){var d=o.distanceTo(f);s?u+=1/d:u+=d}}return s?u:1/u}};Ot.cc=Ot.closenessCentrality,Ot.ccn=Ot.closenessCentralityNormalised=Ot.closenessCentralityNormalized;var ad=Ye({weight:null,directed:!1}),di={betweennessCentrality:function(e){for(var t=ad(e),a=t.directed,n=t.weight,i=n!=null,s=this.cy(),o=this.nodes(),u={},l={},v=0,f={set:function(w,b){l[w]=b,b>v&&(v=b)},get:function(w){return l[w]}},d=0;d<o.length;d++){var h=o[d],c=h.id();a?u[c]=h.outgoers().nodes():u[c]=h.openNeighborhood().nodes(),f.set(c,0)}for(var m=function(w){for(var b=o[w].id(),k=[],x={},E={},T={},F=new ga(function(Q,Z){return T[Q]-T[Z]}),S=0;S<o.length;S++){var D=o[S].id();x[D]=[],E[D]=0,T[D]=1/0}for(E[b]=1,T[b]=0,F.push(b);!F.empty();){var C=F.pop();if(k.push(C),i)for(var B=0;B<u[C].length;B++){var A=u[C][B],M=s.getElementById(C),I=void 0;M.edgesTo(A).length>0?I=M.edgesTo(A)[0]:I=A.edgesTo(M)[0];var R=n(I);A=A.id(),T[A]>T[C]+R&&(T[A]=T[C]+R,F.nodes.indexOf(A)<0?F.push(A):F.updateItem(A),E[A]=0,x[A]=[]),T[A]==T[C]+R&&(E[A]=E[A]+E[C],x[A].push(C))}else for(var L=0;L<u[C].length;L++){var V=u[C][L].id();T[V]==1/0&&(F.push(V),T[V]=T[C]+1),T[V]==T[C]+1&&(E[V]=E[V]+E[C],x[V].push(C))}}for(var H={},z=0;z<o.length;z++)H[o[z].id()]=0;for(;k.length>0;){for(var $=k.pop(),K=0;K<x[$].length;K++){var Y=x[$][K];H[Y]=H[Y]+E[Y]/E[$]*(1+H[$])}$!=o[w].id()&&f.set($,f.get($)+H[$])}},g=0;g<o.length;g++)m(g);var p={betweenness:function(w){var b=s.collection(w).id();return f.get(b)},betweennessNormalized:function(w){if(v==0)return 0;var b=s.collection(w).id();return f.get(b)/v}};return p.betweennessNormalised=p.betweennessNormalized,p}};di.bc=di.betweennessCentrality;var nd=Ye({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(r){return 1}]}),id=function(e){return nd(e)},sd=function(e,t){for(var a=0,n=0;n<t.length;n++)a+=t[n](e);return a},od=function(e,t,a){for(var n=0;n<t;n++)e[n*t+n]=a},Us=function(e,t){for(var a,n=0;n<t;n++){a=0;for(var i=0;i<t;i++)a+=e[i*t+n];for(var s=0;s<t;s++)e[s*t+n]=e[s*t+n]/a}},ud=function(e,t,a){for(var n=new Array(a*a),i=0;i<a;i++){for(var s=0;s<a;s++)n[i*a+s]=0;for(var o=0;o<a;o++)for(var u=0;u<a;u++)n[i*a+u]+=e[i*a+o]*t[o*a+u]}return n},ld=function(e,t,a){for(var n=e.slice(0),i=1;i<a;i++)e=ud(e,n,t);return e},vd=function(e,t,a){for(var n=new Array(t*t),i=0;i<t*t;i++)n[i]=Math.pow(e[i],a);return Us(n,t),n},fd=function(e,t,a,n){for(var i=0;i<a;i++){var s=Math.round(e[i]*Math.pow(10,n))/Math.pow(10,n),o=Math.round(t[i]*Math.pow(10,n))/Math.pow(10,n);if(s!==o)return!1}return!0},dd=function(e,t,a,n){for(var i=[],s=0;s<t;s++){for(var o=[],u=0;u<t;u++)Math.round(e[s*t+u]*1e3)/1e3>0&&o.push(a[u]);o.length!==0&&i.push(n.collection(o))}return i},cd=function(e,t){for(var a=0;a<e.length;a++)if(!t[a]||e[a].id()!==t[a].id())return!1;return!0},hd=function(e){for(var t=0;t<e.length;t++)for(var a=0;a<e.length;a++)t!=a&&cd(e[t],e[a])&&e.splice(a,1);return e},Ks=function(e){for(var t=this.nodes(),a=this.edges(),n=this.cy(),i=id(e),s={},o=0;o<t.length;o++)s[t[o].id()]=o;for(var u=t.length,l=u*u,v=new Array(l),f,d=0;d<l;d++)v[d]=0;for(var h=0;h<a.length;h++){var c=a[h],m=s[c.source().id()],g=s[c.target().id()],p=sd(c,i.attributes);v[m*u+g]+=p,v[g*u+m]+=p}od(v,u,i.multFactor),Us(v,u);for(var y=!0,w=0;y&&w<i.maxIterations;)y=!1,f=ld(v,u,i.expandFactor),v=vd(f,u,i.inflateFactor),fd(v,f,l,4)||(y=!0),w++;var b=dd(v,u,t,n);return b=hd(b),b},gd={markovClustering:Ks,mcl:Ks},pd=function(e){return e},Xs=function(e,t){return Math.abs(t-e)},Ys=function(e,t,a){return e+Xs(t,a)},Zs=function(e,t,a){return e+Math.pow(a-t,2)},md=function(e){return Math.sqrt(e)},yd=function(e,t,a){return Math.max(e,Xs(t,a))},wa=function(e,t,a,n,i){for(var s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:pd,o=n,u,l,v=0;v<e;v++)u=t(v),l=a(v),o=i(o,u,l);return s(o)},_t={euclidean:function(e,t,a){return e>=2?wa(e,t,a,0,Zs,md):wa(e,t,a,0,Ys)},squaredEuclidean:function(e,t,a){return wa(e,t,a,0,Zs)},manhattan:function(e,t,a){return wa(e,t,a,0,Ys)},max:function(e,t,a){return wa(e,t,a,-1/0,yd)}};_t["squared-euclidean"]=_t.squaredEuclidean,_t.squaredeuclidean=_t.squaredEuclidean;function sn(r,e,t,a,n,i){var s;return ze(r)?s=r:s=_t[r]||_t.euclidean,e===0&&ze(r)?s(n,i):s(e,t,a,n,i)}var wd=Ye({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),ci=function(e){return wd(e)},on=function(e,t,a,n,i){var s=i!=="kMedoids",o=s?function(f){return a[f]}:function(f){return n[f](a)},u=function(d){return n[d](t)},l=a,v=t;return sn(e,n.length,o,u,l,v)},hi=function(e,t,a){for(var n=a.length,i=new Array(n),s=new Array(n),o=new Array(t),u=null,l=0;l<n;l++)i[l]=e.min(a[l]).value,s[l]=e.max(a[l]).value;for(var v=0;v<t;v++){u=[];for(var f=0;f<n;f++)u[f]=Math.random()*(s[f]-i[f])+i[f];o[v]=u}return o},Qs=function(e,t,a,n,i){for(var s=1/0,o=0,u=0;u<t.length;u++){var l=on(a,e,t[u],n,i);l<s&&(s=l,o=u)}return o},Js=function(e,t,a){for(var n=[],i=null,s=0;s<t.length;s++)i=t[s],a[i.id()]===e&&n.push(i);return n},bd=function(e,t,a){return Math.abs(t-e)<=a},Fd=function(e,t,a){for(var n=0;n<e.length;n++)for(var i=0;i<e[n].length;i++){var s=Math.abs(e[n][i]-t[n][i]);if(s>a)return!1}return!0},Ed=function(e,t,a){for(var n=0;n<a;n++)if(e===t[n])return!0;return!1},js=function(e,t){var a=new Array(t);if(e.length<50)for(var n=0;n<t;n++){for(var i=e[Math.floor(Math.random()*e.length)];Ed(i,a,n);)i=e[Math.floor(Math.random()*e.length)];a[n]=i}else for(var s=0;s<t;s++)a[s]=e[Math.floor(Math.random()*e.length)];return a},eo=function(e,t,a){for(var n=0,i=0;i<t.length;i++)n+=on("manhattan",t[i],e,a,"kMedoids");return n},xd=function(e){var t=this.cy(),a=this.nodes(),n=null,i=ci(e),s=new Array(i.k),o={},u;i.testMode?typeof i.testCentroids=="number"?(i.testCentroids,u=hi(a,i.k,i.attributes)):He(i.testCentroids)==="object"?u=i.testCentroids:u=hi(a,i.k,i.attributes):u=hi(a,i.k,i.attributes);for(var l=!0,v=0;l&&v<i.maxIterations;){for(var f=0;f<a.length;f++)n=a[f],o[n.id()]=Qs(n,u,i.distance,i.attributes,"kMeans");l=!1;for(var d=0;d<i.k;d++){var h=Js(d,a,o);if(h.length!==0){for(var c=i.attributes.length,m=u[d],g=new Array(c),p=new Array(c),y=0;y<c;y++){p[y]=0;for(var w=0;w<h.length;w++)n=h[w],p[y]+=i.attributes[y](n);g[y]=p[y]/h.length,bd(g[y],m[y],i.sensitivityThreshold)||(l=!0)}u[d]=g,s[d]=t.collection(h)}}v++}return s},Cd=function(e){var t=this.cy(),a=this.nodes(),n=null,i=ci(e),s=new Array(i.k),o,u={},l,v=new Array(i.k);i.testMode?typeof i.testCentroids=="number"||(He(i.testCentroids)==="object"?o=i.testCentroids:o=js(a,i.k)):o=js(a,i.k);for(var f=!0,d=0;f&&d<i.maxIterations;){for(var h=0;h<a.length;h++)n=a[h],u[n.id()]=Qs(n,o,i.distance,i.attributes,"kMedoids");f=!1;for(var c=0;c<o.length;c++){var m=Js(c,a,u);if(m.length!==0){v[c]=eo(o[c],m,i.attributes);for(var g=0;g<m.length;g++)l=eo(m[g],m,i.attributes),l<v[c]&&(v[c]=l,o[c]=m[g],f=!0);s[c]=t.collection(m)}}d++}return s},Td=function(e,t,a,n,i){for(var s,o,u=0;u<t.length;u++)for(var l=0;l<e.length;l++)n[u][l]=Math.pow(a[u][l],i.m);for(var v=0;v<e.length;v++)for(var f=0;f<i.attributes.length;f++){s=0,o=0;for(var d=0;d<t.length;d++)s+=n[d][v]*i.attributes[f](t[d]),o+=n[d][v];e[v][f]=s/o}},Sd=function(e,t,a,n,i){for(var s=0;s<e.length;s++)t[s]=e[s].slice();for(var o,u,l,v=2/(i.m-1),f=0;f<a.length;f++)for(var d=0;d<n.length;d++){o=0;for(var h=0;h<a.length;h++)u=on(i.distance,n[d],a[f],i.attributes,"cmeans"),l=on(i.distance,n[d],a[h],i.attributes,"cmeans"),o+=Math.pow(u/l,v);e[d][f]=1/o}},kd=function(e,t,a,n){for(var i=new Array(a.k),s=0;s<i.length;s++)i[s]=[];for(var o,u,l=0;l<t.length;l++){o=-1/0,u=-1;for(var v=0;v<t[0].length;v++)t[l][v]>o&&(o=t[l][v],u=v);i[u].push(e[l])}for(var f=0;f<i.length;f++)i[f]=n.collection(i[f]);return i},ro=function(e){var t=this.cy(),a=this.nodes(),n=ci(e),i,s,o,u,l;u=new Array(a.length);for(var v=0;v<a.length;v++)u[v]=new Array(n.k);o=new Array(a.length);for(var f=0;f<a.length;f++)o[f]=new Array(n.k);for(var d=0;d<a.length;d++){for(var h=0,c=0;c<n.k;c++)o[d][c]=Math.random(),h+=o[d][c];for(var m=0;m<n.k;m++)o[d][m]=o[d][m]/h}s=new Array(n.k);for(var g=0;g<n.k;g++)s[g]=new Array(n.attributes.length);l=new Array(a.length);for(var p=0;p<a.length;p++)l[p]=new Array(n.k);for(var y=!0,w=0;y&&w<n.maxIterations;)y=!1,Td(s,a,o,l,n),Sd(o,u,s,a,n),Fd(o,u,n.sensitivityThreshold)||(y=!0),w++;return i=kd(a,o,n,t),{clusters:i,degreeOfMembership:o}},Dd={kMeans:xd,kMedoids:Cd,fuzzyCMeans:ro,fcm:ro},Pd=Ye({distance:"euclidean",linkage:"min",mode:"threshold",threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),Bd={single:"min",complete:"max"},Ad=function(e){var t=Pd(e),a=Bd[t.linkage];return a!=null&&(t.linkage=a),t},to=function(e,t,a,n,i){for(var s=0,o=1/0,u,l=i.attributes,v=function(F,S){return sn(i.distance,l.length,function(D){return l[D](F)},function(D){return l[D](S)},F,S)},f=0;f<e.length;f++){var d=e[f].key,h=a[d][n[d]];h<o&&(s=d,o=h)}if(i.mode==="threshold"&&o>=i.threshold||i.mode==="dendrogram"&&e.length===1)return!1;var c=t[s],m=t[n[s]],g;i.mode==="dendrogram"?g={left:c,right:m,key:c.key}:g={value:c.value.concat(m.value),key:c.key},e[c.index]=g,e.splice(m.index,1),t[c.key]=g;for(var p=0;p<e.length;p++){var y=e[p];c.key===y.key?u=1/0:i.linkage==="min"?(u=a[c.key][y.key],a[c.key][y.key]>a[m.key][y.key]&&(u=a[m.key][y.key])):i.linkage==="max"?(u=a[c.key][y.key],a[c.key][y.key]<a[m.key][y.key]&&(u=a[m.key][y.key])):i.linkage==="mean"?u=(a[c.key][y.key]*c.size+a[m.key][y.key]*m.size)/(c.size+m.size):i.mode==="dendrogram"?u=v(y.value,c.value):u=v(y.value[0],c.value[0]),a[c.key][y.key]=a[y.key][c.key]=u}for(var w=0;w<e.length;w++){var b=e[w].key;if(n[b]===c.key||n[b]===m.key){for(var k=b,x=0;x<e.length;x++){var E=e[x].key;a[b][E]<a[b][k]&&(k=E)}n[b]=k}e[w].index=w}return c.key=m.key=c.index=m.index=null,!0},un=function r(e,t,a){e&&(e.value?t.push(e.value):(e.left&&r(e.left,t),e.right&&r(e.right,t)))},Id=function r(e,t){if(!e)return"";if(e.left&&e.right){var a=r(e.left,t),n=r(e.right,t),i=t.add({group:"nodes",data:{id:a+","+n}});return t.add({group:"edges",data:{source:a,target:i.id()}}),t.add({group:"edges",data:{source:n,target:i.id()}}),i.id()}else if(e.value)return e.value.id()},Md=function r(e,t,a){if(!e)return[];var n=[],i=[],s=[];return t===0?(e.left&&un(e.left,n),e.right&&un(e.right,i),s=n.concat(i),[a.collection(s)]):t===1?e.value?[a.collection(e.value)]:(e.left&&un(e.left,n),e.right&&un(e.right,i),[a.collection(n),a.collection(i)]):e.value?[a.collection(e.value)]:(e.left&&(n=r(e.left,t-1,a)),e.right&&(i=r(e.right,t-1,a)),n.concat(i))},ao=function(e){for(var t=this.cy(),a=this.nodes(),n=Ad(e),i=n.attributes,s=function(w,b){return sn(n.distance,i.length,function(k){return i[k](w)},function(k){return i[k](b)},w,b)},o=[],u=[],l=[],v=[],f=0;f<a.length;f++){var d={value:n.mode==="dendrogram"?a[f]:[a[f]],key:f,index:f};o[f]=d,v[f]=d,u[f]=[],l[f]=0}for(var h=0;h<o.length;h++)for(var c=0;c<=h;c++){var m=void 0;n.mode==="dendrogram"?m=h===c?1/0:s(o[h].value,o[c].value):m=h===c?1/0:s(o[h].value[0],o[c].value[0]),u[h][c]=m,u[c][h]=m,m<u[h][l[h]]&&(l[h]=c)}for(var g=to(o,v,u,l,n);g;)g=to(o,v,u,l,n);var p;return n.mode==="dendrogram"?(p=Md(o[0],n.dendrogramDepth,t),n.addDendrogram&&Id(o[0],t)):(p=new Array(o.length),o.forEach(function(y,w){y.key=y.index=null,p[w]=t.collection(y.value)})),p},Rd={hierarchicalClustering:ao,hca:ao},Ld=Ye({distance:"euclidean",preference:"median",damping:.8,maxIterations:1e3,minIterations:100,attributes:[]}),Od=function(e){var t=e.damping,a=e.preference;.5<=t&&t<1||Ve("Damping must range on [0.5, 1).  Got: ".concat(t));var n=["median","mean","min","max"];return n.some(function(i){return i===a})||te(a)||Ve("Preference must be one of [".concat(n.map(function(i){return"'".concat(i,"'")}).join(", "),"] or a number.  Got: ").concat(a)),Ld(e)},_d=function(e,t,a,n){var i=function(o,u){return n[u](o)};return-sn(e,n.length,function(s){return i(t,s)},function(s){return i(a,s)},t,a)},Nd=function(e,t){var a=null;return t==="median"?a=Of(e):t==="mean"?a=Lf(e):t==="min"?a=Mf(e):t==="max"?a=Rf(e):a=t,a},zd=function(e,t,a){for(var n=[],i=0;i<e;i++)t[i*e+i]+a[i*e+i]>0&&n.push(i);return n},no=function(e,t,a){for(var n=[],i=0;i<e;i++){for(var s=-1,o=-1/0,u=0;u<a.length;u++){var l=a[u];t[i*e+l]>o&&(s=l,o=t[i*e+l])}s>0&&n.push(s)}for(var v=0;v<a.length;v++)n[a[v]]=a[v];return n},Vd=function(e,t,a){for(var n=no(e,t,a),i=0;i<a.length;i++){for(var s=[],o=0;o<n.length;o++)n[o]===a[i]&&s.push(o);for(var u=-1,l=-1/0,v=0;v<s.length;v++){for(var f=0,d=0;d<s.length;d++)f+=t[s[d]*e+s[v]];f>l&&(u=v,l=f)}a[i]=s[u]}return n=no(e,t,a),n},io=function(e){for(var t=this.cy(),a=this.nodes(),n=Od(e),i={},s=0;s<a.length;s++)i[a[s].id()]=s;var o,u,l,v,f,d;o=a.length,u=o*o,l=new Array(u);for(var h=0;h<u;h++)l[h]=-1/0;for(var c=0;c<o;c++)for(var m=0;m<o;m++)c!==m&&(l[c*o+m]=_d(n.distance,a[c],a[m],n.attributes));v=Nd(l,n.preference);for(var g=0;g<o;g++)l[g*o+g]=v;f=new Array(u);for(var p=0;p<u;p++)f[p]=0;d=new Array(u);for(var y=0;y<u;y++)d[y]=0;for(var w=new Array(o),b=new Array(o),k=new Array(o),x=0;x<o;x++)w[x]=0,b[x]=0,k[x]=0;for(var E=new Array(o*n.minIterations),T=0;T<E.length;T++)E[T]=0;var F;for(F=0;F<n.maxIterations;F++){for(var S=0;S<o;S++){for(var D=-1/0,C=-1/0,B=-1,A=0,M=0;M<o;M++)w[M]=f[S*o+M],A=d[S*o+M]+l[S*o+M],A>=D?(C=D,D=A,B=M):A>C&&(C=A);for(var I=0;I<o;I++)f[S*o+I]=(1-n.damping)*(l[S*o+I]-D)+n.damping*w[I];f[S*o+B]=(1-n.damping)*(l[S*o+B]-C)+n.damping*w[B]}for(var R=0;R<o;R++){for(var L=0,V=0;V<o;V++)w[V]=d[V*o+R],b[V]=Math.max(0,f[V*o+R]),L+=b[V];L-=b[R],b[R]=f[R*o+R],L+=b[R];for(var H=0;H<o;H++)d[H*o+R]=(1-n.damping)*Math.min(0,L-b[H])+n.damping*w[H];d[R*o+R]=(1-n.damping)*(L-b[R])+n.damping*w[R]}for(var z=0,$=0;$<o;$++){var K=d[$*o+$]+f[$*o+$]>0?1:0;E[F%n.minIterations*o+$]=K,z+=K}if(z>0&&(F>=n.minIterations-1||F==n.maxIterations-1)){for(var Y=0,Q=0;Q<o;Q++){k[Q]=0;for(var Z=0;Z<n.minIterations;Z++)k[Q]+=E[Z*o+Q];(k[Q]===0||k[Q]===n.minIterations)&&Y++}if(Y===o)break}}for(var j=zd(o,f,d),re=Vd(o,l,j),W={},O=0;O<j.length;O++)W[j[O]]=[];for(var G=0;G<a.length;G++){var ee=i[a[G].id()],ie=re[ee];ie!=null&&W[ie].push(a[G])}for(var ue=new Array(j.length),Ce=0;Ce<j.length;Ce++)ue[Ce]=t.collection(W[j[Ce]]);return ue},$d={affinityPropagation:io,ap:io},qd=Ye({root:void 0,directed:!1}),Wd={hierholzer:function(e){if(!Se(e)){var t=arguments;e={root:t[0],directed:t[1]}}var a=qd(e),n=a.root,i=a.directed,s=this,o=!1,u,l,v;n&&(v=fe(n)?this.filter(n)[0].id():n[0].id());var f={},d={};i?s.forEach(function(y){var w=y.id();if(y.isNode()){var b=y.indegree(!0),k=y.outdegree(!0),x=b-k,E=k-b;x==1?u?o=!0:u=w:E==1?l?o=!0:l=w:(E>1||x>1)&&(o=!0),f[w]=[],y.outgoers().forEach(function(T){T.isEdge()&&f[w].push(T.id())})}else d[w]=[void 0,y.target().id()]}):s.forEach(function(y){var w=y.id();if(y.isNode()){var b=y.degree(!0);b%2&&(u?l?o=!0:l=w:u=w),f[w]=[],y.connectedEdges().forEach(function(k){return f[w].push(k.id())})}else d[w]=[y.source().id(),y.target().id()]});var h={found:!1,trail:void 0};if(o)return h;if(l&&u)if(i){if(v&&l!=v)return h;v=l}else{if(v&&l!=v&&u!=v)return h;v||(v=l)}else v||(v=s[0].id());var c=function(w){for(var b=w,k=[w],x,E,T;f[b].length;)x=f[b].shift(),E=d[x][0],T=d[x][1],b!=T?(f[T]=f[T].filter(function(F){return F!=x}),b=T):!i&&b!=E&&(f[E]=f[E].filter(function(F){return F!=x}),b=E),k.unshift(x),k.unshift(b);return k},m=[],g=[];for(g=c(v);g.length!=1;)f[g[0]].length==0?(m.unshift(s.getElementById(g.shift())),m.unshift(s.getElementById(g.shift()))):g=c(g.shift()).concat(g);m.unshift(s.getElementById(g.shift()));for(var p in f)if(f[p].length)return h;return h.found=!0,h.trail=this.spawn(m,!0),h}},ln=function(){var e=this,t={},a=0,n=0,i=[],s=[],o={},u=function(d,h){for(var c=s.length-1,m=[],g=e.spawn();s[c].x!=d||s[c].y!=h;)m.push(s.pop().edge),c--;m.push(s.pop().edge),m.forEach(function(p){var y=p.connectedNodes().intersection(e);g.merge(p),y.forEach(function(w){var b=w.id(),k=w.connectedEdges().intersection(e);g.merge(w),t[b].cutVertex?g.merge(k.filter(function(x){return x.isLoop()})):g.merge(k)})}),i.push(g)},l=function f(d,h,c){d===c&&(n+=1),t[h]={id:a,low:a++,cutVertex:!1};var m=e.getElementById(h).connectedEdges().intersection(e);if(m.size()===0)i.push(e.spawn(e.getElementById(h)));else{var g,p,y,w;m.forEach(function(b){g=b.source().id(),p=b.target().id(),y=g===h?p:g,y!==c&&(w=b.id(),o[w]||(o[w]=!0,s.push({x:h,y,edge:b})),y in t?t[h].low=Math.min(t[h].low,t[y].id):(f(d,y,h),t[h].low=Math.min(t[h].low,t[y].low),t[h].id<=t[y].low&&(t[h].cutVertex=!0,u(h,y))))})}};e.forEach(function(f){if(f.isNode()){var d=f.id();d in t||(n=0,l(d,d),t[d].cutVertex=n>1)}});var v=Object.keys(t).filter(function(f){return t[f].cutVertex}).map(function(f){return e.getElementById(f)});return{cut:e.spawn(v),components:i}},Hd={hopcroftTarjanBiconnected:ln,htbc:ln,htb:ln,hopcroftTarjanBiconnectedComponents:ln},vn=function(){var e=this,t={},a=0,n=[],i=[],s=e.spawn(e),o=function u(l){i.push(l),t[l]={index:a,low:a++,explored:!1};var v=e.getElementById(l).connectedEdges().intersection(e);if(v.forEach(function(m){var g=m.target().id();g!==l&&(g in t||u(g),t[g].explored||(t[l].low=Math.min(t[l].low,t[g].low)))}),t[l].index===t[l].low){for(var f=e.spawn();;){var d=i.pop();if(f.merge(e.getElementById(d)),t[d].low=t[l].index,t[d].explored=!0,d===l)break}var h=f.edgesWith(f),c=f.merge(h);n.push(c),s=s.difference(c)}};return e.forEach(function(u){if(u.isNode()){var l=u.id();l in t||o(l)}}),{cut:s,components:n}},Gd={tarjanStronglyConnected:vn,tsc:vn,tscc:vn,tarjanStronglyConnectedComponents:vn},so={};[ha,Ff,Ef,Cf,Sf,Df,Af,td,Lt,Ot,di,gd,Dd,Rd,$d,Wd,Hd,Gd].forEach(function(r){ce(so,r)});/*!
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 oo=0,uo=1,lo=2,Hr=function r(e){if(!(this instanceof r))return new r(e);this.id="Thenable/1.0.7",this.state=oo,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))};Hr.prototype={fulfill:function(e){return vo(this,uo,"fulfillValue",e)},reject:function(e){return vo(this,lo,"rejectReason",e)},then:function(e,t){var a=this,n=new Hr;return a.onFulfilled.push(ho(e,n,"fulfill")),a.onRejected.push(ho(t,n,"reject")),fo(a),n.proxy}};var vo=function(e,t,a,n){return e.state===oo&&(e.state=t,e[a]=n,fo(e)),e},fo=function(e){e.state===uo?co(e,"onFulfilled",e.fulfillValue):e.state===lo&&co(e,"onRejected",e.rejectReason)},co=function(e,t,a){if(e[t].length!==0){var n=e[t];e[t]=[];var i=function(){for(var o=0;o<n.length;o++)n[o](a)};typeof setImmediate=="function"?setImmediate(i):setTimeout(i,0)}},ho=function(e,t,a){return function(n){if(typeof e!="function")t[a].call(t,n);else{var i;try{i=e(n)}catch(s){t.reject(s);return}Ud(t,i)}}},Ud=function r(e,t){if(e===t||e.proxy===t){e.reject(new TypeError("cannot resolve promise with itself"));return}var a;if(He(t)==="object"&&t!==null||typeof t=="function")try{a=t.then}catch(i){e.reject(i);return}if(typeof a=="function"){var n=!1;try{a.call(t,function(i){n||(n=!0,i===t?e.reject(new TypeError("circular thenable chain")):r(e,i))},function(i){n||(n=!0,e.reject(i))})}catch(i){n||e.reject(i)}return}e.fulfill(t)};Hr.all=function(r){return new Hr(function(e,t){for(var a=new Array(r.length),n=0,i=function(u,l){a[u]=l,n++,n===r.length&&e(a)},s=0;s<r.length;s++)(function(o){var u=r[o],l=u!=null&&u.then!=null;if(l)u.then(function(f){i(o,f)},function(f){t(f)});else{var v=u;i(o,v)}})(s)})},Hr.resolve=function(r){return new Hr(function(e,t){e(r)})},Hr.reject=function(r){return new Hr(function(e,t){t(r)})};var Nt=typeof Promise<"u"?Promise:Hr,gi=function(e,t,a){var n=Jn(e),i=!n,s=this._private=ce({duration:1e3},t,a);if(s.target=e,s.style=s.style||s.css,s.started=!1,s.playing=!1,s.hooked=!1,s.applying=!1,s.progress=0,s.completes=[],s.frames=[],s.complete&&ze(s.complete)&&s.completes.push(s.complete),i){var o=e.position();s.startPosition=s.startPosition||{x:o.x,y:o.y},s.startStyle=s.startStyle||e.cy().style().getAnimationStartStyle(e,s.style)}if(n){var u=e.pan();s.startPan={x:u.x,y:u.y},s.startZoom=e.zoom()}this.length=1,this[0]=this},wt=gi.prototype;ce(wt,{instanceString:function(){return"animation"},hook:function(){var e=this._private;if(!e.hooked){var t,a=e.target._private.animation;e.queue?t=a.queue:t=a.current,t.push(this),yr(e.target)&&e.target.cy().addToAnimationPool(e.target),e.hooked=!0}return this},play:function(){var e=this._private;return e.progress===1&&(e.progress=0),e.playing=!0,e.started=!1,e.stopped=!1,this.hook(),this},playing:function(){return this._private.playing},apply:function(){var e=this._private;return e.applying=!0,e.started=!1,e.stopped=!1,this.hook(),this},applying:function(){return this._private.applying},pause:function(){var e=this._private;return e.playing=!1,e.started=!1,this},stop:function(){var e=this._private;return e.playing=!1,e.started=!1,e.stopped=!0,this},rewind:function(){return this.progress(0)},fastforward:function(){return this.progress(1)},time:function(e){var t=this._private;return e===void 0?t.progress*t.duration:this.progress(e/t.duration)},progress:function(e){var t=this._private,a=t.playing;return e===void 0?t.progress:(a&&this.pause(),t.progress=e,t.started=!1,a&&this.play(),this)},completed:function(){return this._private.progress===1},reverse:function(){var e=this._private,t=e.playing;t&&this.pause(),e.progress=1-e.progress,e.started=!1;var a=function(l,v){var f=e[l];f!=null&&(e[l]=e[v],e[v]=f)};if(a("zoom","startZoom"),a("pan","startPan"),a("position","startPosition"),e.style)for(var n=0;n<e.style.length;n++){var i=e.style[n],s=i.name,o=e.startStyle[s];e.startStyle[s]=i,e.style[n]=o}return t&&this.play(),this},promise:function(e){var t=this._private,a;switch(e){case"frame":a=t.frames;break;default:case"complete":case"completed":a=t.completes}return new Nt(function(n,i){a.push(function(){n()})})}}),wt.complete=wt.completed,wt.run=wt.play,wt.running=wt.playing;var Kd={animated:function(){return function(){var t=this,a=t.length!==void 0,n=a?t:[t],i=this._private.cy||this;if(!i.styleEnabled())return!1;var s=n[0];if(s)return s._private.animation.current.length>0}},clearQueue:function(){return function(){var t=this,a=t.length!==void 0,n=a?t:[t],i=this._private.cy||this;if(!i.styleEnabled())return this;for(var s=0;s<n.length;s++){var o=n[s];o._private.animation.queue=[]}return this}},delay:function(){return function(t,a){var n=this._private.cy||this;return n.styleEnabled()?this.animate({delay:t,duration:t,complete:a}):this}},delayAnimation:function(){return function(t,a){var n=this._private.cy||this;return n.styleEnabled()?this.animation({delay:t,duration:t,complete:a}):this}},animation:function(){return function(t,a){var n=this,i=n.length!==void 0,s=i?n:[n],o=this._private.cy||this,u=!i,l=!u;if(!o.styleEnabled())return this;var v=o.style();t=ce({},t,a);var f=Object.keys(t).length===0;if(f)return new gi(s[0],t);switch(t.duration===void 0&&(t.duration=400),t.duration){case"slow":t.duration=600;break;case"fast":t.duration=200;break}if(l&&(t.style=v.getPropsList(t.style||t.css),t.css=void 0),l&&t.renderedPosition!=null){var d=t.renderedPosition,h=o.pan(),c=o.zoom();t.position=Os(d,c,h)}if(u&&t.panBy!=null){var m=t.panBy,g=o.pan();t.pan={x:g.x+m.x,y:g.y+m.y}}var p=t.center||t.centre;if(u&&p!=null){var y=o.getCenterPan(p.eles,t.zoom);y!=null&&(t.pan=y)}if(u&&t.fit!=null){var w=t.fit,b=o.getFitViewport(w.eles||w.boundingBox,w.padding);b!=null&&(t.pan=b.pan,t.zoom=b.zoom)}if(u&&Se(t.zoom)){var k=o.getZoomedViewport(t.zoom);k!=null?(k.zoomed&&(t.zoom=k.zoom),k.panned&&(t.pan=k.pan)):t.zoom=null}return new gi(s[0],t)}},animate:function(){return function(t,a){var n=this,i=n.length!==void 0,s=i?n:[n],o=this._private.cy||this;if(!o.styleEnabled())return this;a&&(t=ce({},t,a));for(var u=0;u<s.length;u++){var l=s[u],v=l.animated()&&(t.queue===void 0||t.queue),f=l.animation(t,v?{queue:!0}:void 0);f.play()}return this}},stop:function(){return function(t,a){var n=this,i=n.length!==void 0,s=i?n:[n],o=this._private.cy||this;if(!o.styleEnabled())return this;for(var u=0;u<s.length;u++){for(var l=s[u],v=l._private,f=v.animation.current,d=0;d<f.length;d++){var h=f[d],c=h._private;a&&(c.duration=0)}t&&(v.animation.queue=[]),a||(v.animation.current=[])}return o.notify("draw"),this}}},Xd=Array.isArray,fn=Xd,Yd=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zd=/^\w*$/;function Qd(r,e){if(fn(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||la(r)?!0:Zd.test(r)||!Yd.test(r)||e!=null&&r in Object(e)}var Jd=Qd,jd="[object AsyncFunction]",ec="[object Function]",rc="[object GeneratorFunction]",tc="[object Proxy]";function ac(r){if(!ht(r))return!1;var e=Es(r);return e==ec||e==rc||e==jd||e==tc}var nc=ac,ic=Ka["__core-js_shared__"],pi=ic,go=function(){var r=/[^.]+$/.exec(pi&&pi.keys&&pi.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function sc(r){return!!go&&go in r}var oc=sc,uc=Function.prototype,lc=uc.toString;function vc(r){if(r!=null){try{return lc.call(r)}catch{}try{return r+""}catch{}}return""}var fc=vc,dc=/[\\^$.*+?()[\]{}|]/g,cc=/^\[object .+?Constructor\]$/,hc=Function.prototype,gc=Object.prototype,pc=hc.toString,mc=gc.hasOwnProperty,yc=RegExp("^"+pc.call(mc).replace(dc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function wc(r){if(!ht(r)||oc(r))return!1;var e=nc(r)?yc:cc;return e.test(fc(r))}var bc=wc;function Fc(r,e){return r==null?void 0:r[e]}var Ec=Fc;function xc(r,e){var t=Ec(r,e);return bc(t)?t:void 0}var mi=xc,Cc=mi(Object,"create"),ba=Cc;function Tc(){this.__data__=ba?ba(null):{},this.size=0}var Sc=Tc;function kc(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var Dc=kc,Pc="__lodash_hash_undefined__",Bc=Object.prototype,Ac=Bc.hasOwnProperty;function Ic(r){var e=this.__data__;if(ba){var t=e[r];return t===Pc?void 0:t}return Ac.call(e,r)?e[r]:void 0}var Mc=Ic,Rc=Object.prototype,Lc=Rc.hasOwnProperty;function Oc(r){var e=this.__data__;return ba?e[r]!==void 0:Lc.call(e,r)}var _c=Oc,Nc="__lodash_hash_undefined__";function zc(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=ba&&e===void 0?Nc:e,this}var Vc=zc;function zt(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var a=r[e];this.set(a[0],a[1])}}zt.prototype.clear=Sc,zt.prototype.delete=Dc,zt.prototype.get=Mc,zt.prototype.has=_c,zt.prototype.set=Vc;var po=zt;function $c(){this.__data__=[],this.size=0}var qc=$c;function Wc(r,e){return r===e||r!==r&&e!==e}var mo=Wc;function Hc(r,e){for(var t=r.length;t--;)if(mo(r[t][0],e))return t;return-1}var dn=Hc,Gc=Array.prototype,Uc=Gc.splice;function Kc(r){var e=this.__data__,t=dn(e,r);if(t<0)return!1;var a=e.length-1;return t==a?e.pop():Uc.call(e,t,1),--this.size,!0}var Xc=Kc;function Yc(r){var e=this.__data__,t=dn(e,r);return t<0?void 0:e[t][1]}var Zc=Yc;function Qc(r){return dn(this.__data__,r)>-1}var Jc=Qc;function jc(r,e){var t=this.__data__,a=dn(t,r);return a<0?(++this.size,t.push([r,e])):t[a][1]=e,this}var eh=jc;function Vt(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var a=r[e];this.set(a[0],a[1])}}Vt.prototype.clear=qc,Vt.prototype.delete=Xc,Vt.prototype.get=Zc,Vt.prototype.has=Jc,Vt.prototype.set=eh;var rh=Vt,th=mi(Ka,"Map"),ah=th;function nh(){this.size=0,this.__data__={hash:new po,map:new(ah||rh),string:new po}}var ih=nh;function sh(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var oh=sh;function uh(r,e){var t=r.__data__;return oh(e)?t[typeof e=="string"?"string":"hash"]:t.map}var cn=uh;function lh(r){var e=cn(this,r).delete(r);return this.size-=e?1:0,e}var vh=lh;function fh(r){return cn(this,r).get(r)}var dh=fh;function ch(r){return cn(this,r).has(r)}var hh=ch;function gh(r,e){var t=cn(this,r),a=t.size;return t.set(r,e),this.size+=t.size==a?0:1,this}var ph=gh;function $t(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var a=r[e];this.set(a[0],a[1])}}$t.prototype.clear=ih,$t.prototype.delete=vh,$t.prototype.get=dh,$t.prototype.has=hh,$t.prototype.set=ph;var yo=$t,mh="Expected a function";function yi(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(mh);var t=function(){var a=arguments,n=e?e.apply(this,a):a[0],i=t.cache;if(i.has(n))return i.get(n);var s=r.apply(this,a);return t.cache=i.set(n,s)||i,s};return t.cache=new(yi.Cache||yo),t}yi.Cache=yo;var yh=yi,wh=500;function bh(r){var e=yh(r,function(a){return t.size===wh&&t.clear(),a}),t=e.cache;return e}var Fh=bh,Eh=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xh=/\\(\\)?/g,Ch=Fh(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(Eh,function(t,a,n,i){e.push(n?i.replace(xh,"$1"):a||t)}),e}),wo=Ch;function Th(r,e){for(var t=-1,a=r==null?0:r.length,n=Array(a);++t<a;)n[t]=e(r[t],t,r);return n}var bo=Th,Sh=1/0,Fo=Pt?Pt.prototype:void 0,Eo=Fo?Fo.toString:void 0;function xo(r){if(typeof r=="string")return r;if(fn(r))return bo(r,xo)+"";if(la(r))return Eo?Eo.call(r):"";var e=r+"";return e=="0"&&1/r==-Sh?"-0":e}var kh=xo;function Dh(r){return r==null?"":kh(r)}var Co=Dh;function Ph(r,e){return fn(r)?r:Jd(r,e)?[r]:wo(Co(r))}var To=Ph,Bh=1/0;function Ah(r){if(typeof r=="string"||la(r))return r;var e=r+"";return e=="0"&&1/r==-Bh?"-0":e}var wi=Ah;function Ih(r,e){e=To(e,r);for(var t=0,a=e.length;r!=null&&t<a;)r=r[wi(e[t++])];return t&&t==a?r:void 0}var Mh=Ih;function Rh(r,e,t){var a=r==null?void 0:Mh(r,e);return a===void 0?t:a}var Lh=Rh,Oh=function(){try{var r=mi(Object,"defineProperty");return r({},"",{}),r}catch{}}(),So=Oh;function _h(r,e,t){e=="__proto__"&&So?So(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var Nh=_h,zh=Object.prototype,Vh=zh.hasOwnProperty;function $h(r,e,t){var a=r[e];(!(Vh.call(r,e)&&mo(a,t))||t===void 0&&!(e in r))&&Nh(r,e,t)}var qh=$h,Wh=9007199254740991,Hh=/^(?:0|[1-9]\d*)$/;function Gh(r,e){var t=typeof r;return e=e??Wh,!!e&&(t=="number"||t!="symbol"&&Hh.test(r))&&r>-1&&r%1==0&&r<e}var Uh=Gh;function Kh(r,e,t,a){if(!ht(r))return r;e=To(e,r);for(var n=-1,i=e.length,s=i-1,o=r;o!=null&&++n<i;){var u=wi(e[n]),l=t;if(u==="__proto__"||u==="constructor"||u==="prototype")return r;if(n!=s){var v=o[u];l=a?a(v,u,o):void 0,l===void 0&&(l=ht(v)?v:Uh(e[n+1])?[]:{})}qh(o,u,l),o=o[u]}return r}var Xh=Kh;function Yh(r,e,t){return r==null?r:Xh(r,e,t)}var Zh=Yh;function Qh(r,e){var t=-1,a=r.length;for(e||(e=Array(a));++t<a;)e[t]=r[t];return e}var Jh=Qh;function jh(r){return fn(r)?bo(r,wi):la(r)?[r]:Jh(wo(Co(r)))}var eg=jh,rg={data:function(e){var t={field:"data",bindingEvent:"data",allowBinding:!1,allowSetting:!1,allowGetting:!1,settingEvent:"data",settingTriggersEvent:!1,triggerFnName:"trigger",immutableKeys:{},updateStyle:!1,beforeGet:function(n){},beforeSet:function(n,i){},onSet:function(n){},canSet:function(n){return!0}};return e=ce({},t,e),function(n,i){var s=e,o=this,u=o.length!==void 0,l=u?o:[o],v=u?o[0]:o;if(fe(n)){var f=n.indexOf(".")!==-1,d=f&&eg(n);if(s.allowGetting&&i===void 0){var h;return v&&(s.beforeGet(v),d&&v._private[s.field][n]===void 0?h=Lh(v._private[s.field],d):h=v._private[s.field][n]),h}else if(s.allowSetting&&i!==void 0){var c=!s.immutableKeys[n];if(c){var m=us({},n,i);s.beforeSet(o,m);for(var g=0,p=l.length;g<p;g++){var y=l[g];s.canSet(y)&&(d&&v._private[s.field][n]===void 0?Zh(y._private[s.field],d,i):y._private[s.field][n]=i)}s.updateStyle&&o.updateStyle(),s.onSet(o),s.settingTriggersEvent&&o[s.triggerFnName](s.settingEvent)}}}else if(s.allowSetting&&Se(n)){var w=n,b,k,x=Object.keys(w);s.beforeSet(o,w);for(var E=0;E<x.length;E++){b=x[E],k=w[b];var T=!s.immutableKeys[b];if(T)for(var F=0;F<l.length;F++){var S=l[F];s.canSet(S)&&(S._private[s.field][b]=k)}}s.updateStyle&&o.updateStyle(),s.onSet(o),s.settingTriggersEvent&&o[s.triggerFnName](s.settingEvent)}else if(s.allowBinding&&ze(n)){var D=n;o.on(s.bindingEvent,D)}else if(s.allowGetting&&n===void 0){var C;return v&&(s.beforeGet(v),C=v._private[s.field]),C}return o}},removeData:function(e){var t={field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!1,immutableKeys:{}};return e=ce({},t,e),function(n){var i=e,s=this,o=s.length!==void 0,u=o?s:[s];if(fe(n)){for(var l=n.split(/\s+/),v=l.length,f=0;f<v;f++){var d=l[f];if(!Jr(d)){var h=!i.immutableKeys[d];if(h)for(var c=0,m=u.length;c<m;c++)u[c]._private[i.field][d]=void 0}}i.triggerEvent&&s[i.triggerFnName](i.event)}else if(n===void 0){for(var g=0,p=u.length;g<p;g++)for(var y=u[g]._private[i.field],w=Object.keys(y),b=0;b<w.length;b++){var k=w[b],x=!i.immutableKeys[k];x&&(y[k]=void 0)}i.triggerEvent&&s[i.triggerFnName](i.event)}return s}}},tg={eventAliasesOn:function(e){var t=e;t.addListener=t.listen=t.bind=t.on,t.unlisten=t.unbind=t.off=t.removeListener,t.trigger=t.emit,t.pon=t.promiseOn=function(a,n){var i=this,s=Array.prototype.slice.call(arguments,0);return new Nt(function(o,u){var l=function(h){i.off.apply(i,f),o(h)},v=s.concat([l]),f=v.concat([]);i.on.apply(i,v)})}}},Be={};[Kd,rg,tg].forEach(function(r){ce(Be,r)});var ag={animate:Be.animate(),animation:Be.animation(),animated:Be.animated(),clearQueue:Be.clearQueue(),delay:Be.delay(),delayAnimation:Be.delayAnimation(),stop:Be.stop()},hn={classes:function(e){var t=this;if(e===void 0){var a=[];return t[0]._private.classes.forEach(function(c){return a.push(c)}),a}else Re(e)||(e=(e||"").match(/\S+/g)||[]);for(var n=[],i=new At(e),s=0;s<t.length;s++){for(var o=t[s],u=o._private,l=u.classes,v=!1,f=0;f<e.length;f++){var d=e[f],h=l.has(d);if(!h){v=!0;break}}v||(v=l.size!==e.length),v&&(u.classes=i,n.push(o))}return n.length>0&&this.spawn(n).updateStyle().emit("class"),t},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return t!=null&&t._private.classes.has(e)},toggleClass:function(e,t){Re(e)||(e=e.match(/\S+/g)||[]);for(var a=this,n=t===void 0,i=[],s=0,o=a.length;s<o;s++)for(var u=a[s],l=u._private.classes,v=!1,f=0;f<e.length;f++){var d=e[f],h=l.has(d),c=!1;t||n&&!h?(l.add(d),c=!0):(!t||n&&h)&&(l.delete(d),c=!0),!v&&c&&(i.push(u),v=!0)}return i.length>0&&this.spawn(i).updateStyle().emit("class"),a},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var a=this;if(t==null)t=250;else if(t===0)return a;return a.addClass(e),setTimeout(function(){a.removeClass(e)},t),a}};hn.className=hn.classNames=hn.classes;var ke={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:`"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,number:Ue,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};ke.variable="(?:[\\w-.]|(?:\\\\"+ke.metaChar+"))+",ke.className="(?:[\\w-]|(?:\\\\"+ke.metaChar+"))+",ke.value=ke.string+"|"+ke.number,ke.id=ke.variable,function(){var r,e,t;for(r=ke.comparatorOp.split("|"),t=0;t<r.length;t++)e=r[t],ke.comparatorOp+="|@"+e;for(r=ke.comparatorOp.split("|"),t=0;t<r.length;t++)e=r[t],!(e.indexOf("!")>=0)&&e!=="="&&(ke.comparatorOp+="|\\!"+e)}();var Me=function(){return{checks:[]}},se={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},bi=[{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(r,e){return gv(r.selector,e.selector)}),ng=function(){for(var r={},e,t=0;t<bi.length;t++)e=bi[t],r[e.selector]=e.matches;return r}(),ig=function(e,t){return ng[e](t)},sg="("+bi.map(function(r){return r.selector}).join("|")+")",qt=function(e){return e.replace(new RegExp("\\\\("+ke.metaChar+")","g"),function(t,a){return a})},nt=function(e,t,a){e[e.length-1]=a},Fi=[{name:"group",query:!0,regex:"("+ke.group+")",populate:function(e,t,a){var n=We(a,1),i=n[0];t.checks.push({type:se.GROUP,value:i==="*"?i:i+"s"})}},{name:"state",query:!0,regex:sg,populate:function(e,t,a){var n=We(a,1),i=n[0];t.checks.push({type:se.STATE,value:i})}},{name:"id",query:!0,regex:"\\#("+ke.id+")",populate:function(e,t,a){var n=We(a,1),i=n[0];t.checks.push({type:se.ID,value:qt(i)})}},{name:"className",query:!0,regex:"\\.("+ke.className+")",populate:function(e,t,a){var n=We(a,1),i=n[0];t.checks.push({type:se.CLASS,value:qt(i)})}},{name:"dataExists",query:!0,regex:"\\[\\s*("+ke.variable+")\\s*\\]",populate:function(e,t,a){var n=We(a,1),i=n[0];t.checks.push({type:se.DATA_EXIST,field:qt(i)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+ke.variable+")\\s*("+ke.comparatorOp+")\\s*("+ke.value+")\\s*\\]",populate:function(e,t,a){var n=We(a,3),i=n[0],s=n[1],o=n[2],u=new RegExp("^"+ke.string+"$").exec(o)!=null;u?o=o.substring(1,o.length-1):o=parseFloat(o),t.checks.push({type:se.DATA_COMPARE,field:qt(i),operator:s,value:o})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+ke.boolOp+")\\s*("+ke.variable+")\\s*\\]",populate:function(e,t,a){var n=We(a,2),i=n[0],s=n[1];t.checks.push({type:se.DATA_BOOL,field:qt(s),operator:i})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+ke.meta+")\\s*("+ke.comparatorOp+")\\s*("+ke.number+")\\s*\\]\\]",populate:function(e,t,a){var n=We(a,3),i=n[0],s=n[1],o=n[2];t.checks.push({type:se.META_COMPARE,field:qt(i),operator:s,value:parseFloat(o)})}},{name:"nextQuery",separator:!0,regex:ke.separator,populate:function(e,t){var a=e.currentSubject,n=e.edgeCount,i=e.compoundCount,s=e[e.length-1];a!=null&&(s.subject=a,e.currentSubject=null),s.edgeCount=n,s.compoundCount=i,e.edgeCount=0,e.compoundCount=0;var o=e[e.length++]=Me();return o}},{name:"directedEdge",separator:!0,regex:ke.directedEdge,populate:function(e,t){if(e.currentSubject==null){var a=Me(),n=t,i=Me();return a.checks.push({type:se.DIRECTED_EDGE,source:n,target:i}),nt(e,t,a),e.edgeCount++,i}else{var s=Me(),o=t,u=Me();return s.checks.push({type:se.NODE_SOURCE,source:o,target:u}),nt(e,t,s),e.edgeCount++,u}}},{name:"undirectedEdge",separator:!0,regex:ke.undirectedEdge,populate:function(e,t){if(e.currentSubject==null){var a=Me(),n=t,i=Me();return a.checks.push({type:se.UNDIRECTED_EDGE,nodes:[n,i]}),nt(e,t,a),e.edgeCount++,i}else{var s=Me(),o=t,u=Me();return s.checks.push({type:se.NODE_NEIGHBOR,node:o,neighbor:u}),nt(e,t,s),u}}},{name:"child",separator:!0,regex:ke.child,populate:function(e,t){if(e.currentSubject==null){var a=Me(),n=Me(),i=e[e.length-1];return a.checks.push({type:se.CHILD,parent:i,child:n}),nt(e,t,a),e.compoundCount++,n}else if(e.currentSubject===t){var s=Me(),o=e[e.length-1],u=Me(),l=Me(),v=Me(),f=Me();return s.checks.push({type:se.COMPOUND_SPLIT,left:o,right:u,subject:l}),l.checks=t.checks,t.checks=[{type:se.TRUE}],f.checks.push({type:se.TRUE}),u.checks.push({type:se.PARENT,parent:f,child:v}),nt(e,o,s),e.currentSubject=l,e.compoundCount++,v}else{var d=Me(),h=Me(),c=[{type:se.PARENT,parent:d,child:h}];return d.checks=t.checks,t.checks=c,e.compoundCount++,h}}},{name:"descendant",separator:!0,regex:ke.descendant,populate:function(e,t){if(e.currentSubject==null){var a=Me(),n=Me(),i=e[e.length-1];return a.checks.push({type:se.DESCENDANT,ancestor:i,descendant:n}),nt(e,t,a),e.compoundCount++,n}else if(e.currentSubject===t){var s=Me(),o=e[e.length-1],u=Me(),l=Me(),v=Me(),f=Me();return s.checks.push({type:se.COMPOUND_SPLIT,left:o,right:u,subject:l}),l.checks=t.checks,t.checks=[{type:se.TRUE}],f.checks.push({type:se.TRUE}),u.checks.push({type:se.ANCESTOR,ancestor:f,descendant:v}),nt(e,o,s),e.currentSubject=l,e.compoundCount++,v}else{var d=Me(),h=Me(),c=[{type:se.ANCESTOR,ancestor:d,descendant:h}];return d.checks=t.checks,t.checks=c,e.compoundCount++,h}}},{name:"subject",modifier:!0,regex:ke.subject,populate:function(e,t){if(e.currentSubject!=null&&e.currentSubject!==t)return Pe("Redefinition of subject in selector `"+e.toString()+"`"),!1;e.currentSubject=t;var a=e[e.length-1],n=a.checks[0],i=n==null?null:n.type;i===se.DIRECTED_EDGE?n.type=se.NODE_TARGET:i===se.UNDIRECTED_EDGE&&(n.type=se.NODE_NEIGHBOR,n.node=n.nodes[1],n.neighbor=n.nodes[0],n.nodes=null)}}];Fi.forEach(function(r){return r.regexObj=new RegExp("^"+r.regex)});var og=function(e){for(var t,a,n,i=0;i<Fi.length;i++){var s=Fi[i],o=s.name,u=e.match(s.regexObj);if(u!=null){a=u,t=s,n=o;var l=u[0];e=e.substring(l.length);break}}return{expr:t,match:a,name:n,remaining:e}},ug=function(e){var t=e.match(/^\s+/);if(t){var a=t[0];e=e.substring(a.length)}return e},lg=function(e){var t=this,a=t.inputText=e,n=t[0]=Me();for(t.length=1,a=ug(a);;){var i=og(a);if(i.expr==null)return Pe("The selector `"+e+"`is invalid"),!1;var s=i.match.slice(1),o=i.expr.populate(t,n,s);if(o===!1)return!1;if(o!=null&&(n=o),a=i.remaining,a.match(/^\s*$/))break}var u=t[t.length-1];t.currentSubject!=null&&(u.subject=t.currentSubject),u.edgeCount=t.edgeCount,u.compoundCount=t.compoundCount;for(var l=0;l<t.length;l++){var v=t[l];if(v.compoundCount>0&&v.edgeCount>0)return Pe("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(v.edgeCount>1)return Pe("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;v.edgeCount===1&&Pe("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},vg=function(){if(this.toStringCache!=null)return this.toStringCache;for(var e=function(v){return v??""},t=function(v){return fe(v)?'"'+v+'"':e(v)},a=function(v){return" "+v+" "},n=function(v,f){var d=v.type,h=v.value;switch(d){case se.GROUP:{var c=e(h);return c.substring(0,c.length-1)}case se.DATA_COMPARE:{var m=v.field,g=v.operator;return"["+m+a(e(g))+t(h)+"]"}case se.DATA_BOOL:{var p=v.operator,y=v.field;return"["+e(p)+y+"]"}case se.DATA_EXIST:{var w=v.field;return"["+w+"]"}case se.META_COMPARE:{var b=v.operator,k=v.field;return"[["+k+a(e(b))+t(h)+"]]"}case se.STATE:return h;case se.ID:return"#"+h;case se.CLASS:return"."+h;case se.PARENT:case se.CHILD:return i(v.parent,f)+a(">")+i(v.child,f);case se.ANCESTOR:case se.DESCENDANT:return i(v.ancestor,f)+" "+i(v.descendant,f);case se.COMPOUND_SPLIT:{var x=i(v.left,f),E=i(v.subject,f),T=i(v.right,f);return x+(x.length>0?" ":"")+E+T}case se.TRUE:return""}},i=function(v,f){return v.checks.reduce(function(d,h,c){return d+(f===v&&c===0?"$":"")+n(h,f)},"")},s="",o=0;o<this.length;o++){var u=this[o];s+=i(u,u.subject),this.length>1&&o<this.length-1&&(s+=", ")}return this.toStringCache=s,s},fg={parse:lg,toString:vg},ko=function(e,t,a){var n,i=fe(e),s=te(e),o=fe(a),u,l,v=!1,f=!1,d=!1;switch(t.indexOf("!")>=0&&(t=t.replace("!",""),f=!0),t.indexOf("@")>=0&&(t=t.replace("@",""),v=!0),(i||o||v)&&(u=!i&&!s?"":""+e,l=""+a),v&&(e=u=u.toLowerCase(),a=l=l.toLowerCase()),t){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=e<a;break;case"<=":d=!0,n=e<=a;break;default:n=!1;break}return f&&(e!=null||!d)&&(n=!n),n},dg=function(e,t){switch(t){case"?":return!!e;case"!":return!e;case"^":return e===void 0}},cg=function(e){return e!==void 0},Ei=function(e,t){return e.data(t)},hg=function(e,t){return e[t]()},qe=[],Ne=function(e,t){return e.checks.every(function(a){return qe[a.type](a,t)})};qe[se.GROUP]=function(r,e){var t=r.value;return t==="*"||t===e.group()},qe[se.STATE]=function(r,e){var t=r.value;return ig(t,e)},qe[se.ID]=function(r,e){var t=r.value;return e.id()===t},qe[se.CLASS]=function(r,e){var t=r.value;return e.hasClass(t)},qe[se.META_COMPARE]=function(r,e){var t=r.field,a=r.operator,n=r.value;return ko(hg(e,t),a,n)},qe[se.DATA_COMPARE]=function(r,e){var t=r.field,a=r.operator,n=r.value;return ko(Ei(e,t),a,n)},qe[se.DATA_BOOL]=function(r,e){var t=r.field,a=r.operator;return dg(Ei(e,t),a)},qe[se.DATA_EXIST]=function(r,e){var t=r.field;return r.operator,cg(Ei(e,t))},qe[se.UNDIRECTED_EDGE]=function(r,e){var t=r.nodes[0],a=r.nodes[1],n=e.source(),i=e.target();return Ne(t,n)&&Ne(a,i)||Ne(a,n)&&Ne(t,i)},qe[se.NODE_NEIGHBOR]=function(r,e){return Ne(r.node,e)&&e.neighborhood().some(function(t){return t.isNode()&&Ne(r.neighbor,t)})},qe[se.DIRECTED_EDGE]=function(r,e){return Ne(r.source,e.source())&&Ne(r.target,e.target())},qe[se.NODE_SOURCE]=function(r,e){return Ne(r.source,e)&&e.outgoers().some(function(t){return t.isNode()&&Ne(r.target,t)})},qe[se.NODE_TARGET]=function(r,e){return Ne(r.target,e)&&e.incomers().some(function(t){return t.isNode()&&Ne(r.source,t)})},qe[se.CHILD]=function(r,e){return Ne(r.child,e)&&Ne(r.parent,e.parent())},qe[se.PARENT]=function(r,e){return Ne(r.parent,e)&&e.children().some(function(t){return Ne(r.child,t)})},qe[se.DESCENDANT]=function(r,e){return Ne(r.descendant,e)&&e.ancestors().some(function(t){return Ne(r.ancestor,t)})},qe[se.ANCESTOR]=function(r,e){return Ne(r.ancestor,e)&&e.descendants().some(function(t){return Ne(r.descendant,t)})},qe[se.COMPOUND_SPLIT]=function(r,e){return Ne(r.subject,e)&&Ne(r.left,e)&&Ne(r.right,e)},qe[se.TRUE]=function(){return!0},qe[se.COLLECTION]=function(r,e){var t=r.value;return t.has(e)},qe[se.FILTER]=function(r,e){var t=r.value;return t(e)};var gg=function(e){var t=this;if(t.length===1&&t[0].checks.length===1&&t[0].checks[0].type===se.ID)return e.getElementById(t[0].checks[0].value).collection();var a=function(i){for(var s=0;s<t.length;s++){var o=t[s];if(Ne(o,i))return!0}return!1};return t.text()==null&&(a=function(){return!0}),e.filter(a)},pg=function(e){for(var t=this,a=0;a<t.length;a++){var n=t[a];if(Ne(n,e))return!0}return!1},mg={matches:pg,filter:gg},it=function(e){this.inputText=e,this.currentSubject=null,this.compoundCount=0,this.edgeCount=0,this.length=0,e==null||fe(e)&&e.match(/^\s*$/)||(yr(e)?this.addQuery({checks:[{type:se.COLLECTION,value:e.collection()}]}):ze(e)?this.addQuery({checks:[{type:se.FILTER,value:e}]}):fe(e)?this.parse(e)||(this.invalid=!0):Ve("A selector must be created from a string; found "))},st=it.prototype;[fg,mg].forEach(function(r){return ce(st,r)}),st.text=function(){return this.inputText},st.size=function(){return this.length},st.eq=function(r){return this[r]},st.sameText=function(r){return!this.invalid&&!r.invalid&&this.text()===r.text()},st.addQuery=function(r){this[this.length++]=r},st.selector=st.toString;var ot={allAre:function(e){var t=new it(e);return this.every(function(a){return t.matches(a)})},is:function(e){var t=new it(e);return this.some(function(a){return t.matches(a)})},some:function(e,t){for(var a=0;a<this.length;a++){var n=t?e.apply(t,[this[a],a,this]):e(this[a],a,this);if(n)return!0}return!1},every:function(e,t){for(var a=0;a<this.length;a++){var n=t?e.apply(t,[this[a],a,this]):e(this[a],a,this);if(!n)return!1}return!0},same:function(e){if(this===e)return!0;e=this.cy().collection(e);var t=this.length,a=e.length;return t!==a?!1:t===1?this[0]===e[0]:this.every(function(n){return e.hasElementWithId(n.id())})},anySame:function(e){return e=this.cy().collection(e),this.some(function(t){return e.hasElementWithId(t.id())})},allAreNeighbors:function(e){e=this.cy().collection(e);var t=this.neighborhood();return e.every(function(a){return t.hasElementWithId(a.id())})},contains:function(e){e=this.cy().collection(e);var t=this;return e.every(function(a){return t.hasElementWithId(a.id())})}};ot.allAreNeighbours=ot.allAreNeighbors,ot.has=ot.contains,ot.equal=ot.equals=ot.same;var Er=function(e,t){return function(n,i,s,o){var u=n,l=this,v;if(u==null?v="":yr(u)&&u.length===1&&(v=u.id()),l.length===1&&v){var f=l[0]._private,d=f.traversalCache=f.traversalCache||{},h=d[t]=d[t]||[],c=et(v),m=h[c];return m||(h[c]=e.call(l,n,i,s,o))}else return e.call(l,n,i,s,o)}},Wt={parent:function(e){var t=[];if(this.length===1){var a=this[0]._private.parent;if(a)return a}for(var n=0;n<this.length;n++){var i=this[n],s=i._private.parent;s&&t.push(s)}return this.spawn(t,!0).filter(e)},parents:function(e){for(var t=[],a=this.parent();a.nonempty();){for(var n=0;n<a.length;n++){var i=a[n];t.push(i)}a=a.parent()}return this.spawn(t,!0).filter(e)},commonAncestors:function(e){for(var t,a=0;a<this.length;a++){var n=this[a],i=n.parents();t=t||i,t=t.intersect(i)}return t.filter(e)},orphans:function(e){return this.stdFilter(function(t){return t.isOrphan()}).filter(e)},nonorphans:function(e){return this.stdFilter(function(t){return t.isChild()}).filter(e)},children:Er(function(r){for(var e=[],t=0;t<this.length;t++)for(var a=this[t],n=a._private.children,i=0;i<n.length;i++)e.push(n[i]);return this.spawn(e,!0).filter(r)},"children"),siblings:function(e){return this.parent().children().not(this).filter(e)},isParent:function(){var e=this[0];if(e)return e.isNode()&&e._private.children.length!==0},isChildless:function(){var e=this[0];if(e)return e.isNode()&&e._private.children.length===0},isChild:function(){var e=this[0];if(e)return e.isNode()&&e._private.parent!=null},isOrphan:function(){var e=this[0];if(e)return e.isNode()&&e._private.parent==null},descendants:function(e){var t=[];function a(n){for(var i=0;i<n.length;i++){var s=n[i];t.push(s),s.children().nonempty()&&a(s.children())}}return a(this.children()),this.spawn(t,!0).filter(e)}};function xi(r,e,t,a){for(var n=[],i=new At,s=r.cy(),o=s.hasCompoundNodes(),u=0;u<r.length;u++){var l=r[u];t?n.push(l):o&&a(n,i,l)}for(;n.length>0;){var v=n.shift();e(v),i.add(v.id()),o&&a(n,i,v)}return r}function Do(r,e,t){if(t.isParent())for(var a=t._private.children,n=0;n<a.length;n++){var i=a[n];e.has(i.id())||r.push(i)}}Wt.forEachDown=function(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return xi(this,r,e,Do)};function Po(r,e,t){if(t.isChild()){var a=t._private.parent;e.has(a.id())||r.push(a)}}Wt.forEachUp=function(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return xi(this,r,e,Po)};function yg(r,e,t){Po(r,e,t),Do(r,e,t)}Wt.forEachUpAndDown=function(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return xi(this,r,e,yg)},Wt.ancestors=Wt.parents;var Fa,Bo;Fa=Bo={data:Be.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:Be.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Be.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Be.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Be.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Be.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}},Fa.attr=Fa.data,Fa.removeAttr=Fa.removeData;var wg=Bo,gn={};function Ci(r){return function(e){var t=this;if(e===void 0&&(e=!0),t.length!==0)if(t.isNode()&&!t.removed()){for(var a=0,n=t[0],i=n._private.edges,s=0;s<i.length;s++){var o=i[s];!e&&o.isLoop()||(a+=r(n,o))}return a}else return}}ce(gn,{degree:Ci(function(r,e){return e.source().same(e.target())?2:1}),indegree:Ci(function(r,e){return e.target().same(r)?1:0}),outdegree:Ci(function(r,e){return e.source().same(r)?1:0})});function Ht(r,e){return function(t){for(var a,n=this.nodes(),i=0;i<n.length;i++){var s=n[i],o=s[r](t);o!==void 0&&(a===void 0||e(o,a))&&(a=o)}return a}}ce(gn,{minDegree:Ht("degree",function(r,e){return r<e}),maxDegree:Ht("degree",function(r,e){return r>e}),minIndegree:Ht("indegree",function(r,e){return r<e}),maxIndegree:Ht("indegree",function(r,e){return r>e}),minOutdegree:Ht("outdegree",function(r,e){return r<e}),maxOutdegree:Ht("outdegree",function(r,e){return r>e})}),ce(gn,{totalDegree:function(e){for(var t=0,a=this.nodes(),n=0;n<a.length;n++)t+=a[n].degree(e);return t}});var kr,Ao,Io=function(e,t,a){for(var n=0;n<e.length;n++){var i=e[n];if(!i.locked()){var s=i._private.position,o={x:t.x!=null?t.x-s.x:0,y:t.y!=null?t.y-s.y:0};i.isParent()&&!(o.x===0&&o.y===0)&&i.children().shift(o,a),i.dirtyBoundingBoxCache()}}},Mo={field:"position",bindingEvent:"position",allowBinding:!0,allowSetting:!0,settingEvent:"position",settingTriggersEvent:!0,triggerFnName:"emitAndNotify",allowGetting:!0,validKeys:["x","y"],beforeGet:function(e){e.updateCompoundBounds()},beforeSet:function(e,t){Io(e,t,!1)},onSet:function(e){e.dirtyCompoundBoundsCache()},canSet:function(e){return!e.locked()}};kr=Ao={position:Be.data(Mo),silentPosition:Be.data(ce({},Mo,{allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!1,beforeSet:function(e,t){Io(e,t,!0)},onSet:function(e){e.dirtyCompoundBoundsCache()}})),positions:function(e,t){if(Se(e))t?this.silentPosition(e):this.position(e);else if(ze(e)){var a=e,n=this.cy();n.startBatch();for(var i=0;i<this.length;i++){var s=this[i],o=void 0;(o=a(s,i))&&(t?s.silentPosition(o):s.position(o))}n.endBatch()}return this},silentPositions:function(e){return this.positions(e,!0)},shift:function(e,t,a){var n;if(Se(e)?(n={x:te(e.x)?e.x:0,y:te(e.y)?e.y:0},a=t):fe(e)&&te(t)&&(n={x:0,y:0},n[e]=t),n!=null){var i=this.cy();i.startBatch();for(var s=0;s<this.length;s++){var o=this[s];if(!(i.hasCompoundNodes()&&o.isChild()&&o.ancestors().anySame(this))){var u=o.position(),l={x:u.x+n.x,y:u.y+n.y};a?o.silentPosition(l):o.position(l)}}i.endBatch()}return this},silentShift:function(e,t){return Se(e)?this.shift(e,!0):fe(e)&&te(t)&&this.shift(e,t,!0),this},renderedPosition:function(e,t){var a=this[0],n=this.cy(),i=n.zoom(),s=n.pan(),o=Se(e)?e:void 0,u=o!==void 0||t!==void 0&&fe(e);if(a&&a.isNode())if(u)for(var l=0;l<this.length;l++){var v=this[l];t!==void 0?v.position(e,(t-s[e])/i):o!==void 0&&v.position(Os(o,i,s))}else{var f=a.position();return o=Ja(f,i,s),e===void 0?o:o[e]}else if(!u)return;return this},relativePosition:function(e,t){var a=this[0],n=this.cy(),i=Se(e)?e:void 0,s=i!==void 0||t!==void 0&&fe(e),o=n.hasCompoundNodes();if(a&&a.isNode())if(s)for(var u=0;u<this.length;u++){var l=this[u],v=o?l.parent():null,f=v&&v.length>0,d=f;f&&(v=v[0]);var h=d?v.position():{x:0,y:0};t!==void 0?l.position(e,t+h[e]):i!==void 0&&l.position({x:i.x+h.x,y:i.y+h.y})}else{var c=a.position(),m=o?a.parent():null,g=m&&m.length>0,p=g;g&&(m=m[0]);var y=p?m.position():{x:0,y:0};return i={x:c.x-y.x,y:c.y-y.y},e===void 0?i:i[e]}else if(!s)return;return this}},kr.modelPosition=kr.point=kr.position,kr.modelPositions=kr.points=kr.positions,kr.renderedPoint=kr.renderedPosition,kr.relativePoint=kr.relativePosition;var bg=Ao,Gt,ut;Gt=ut={},ut.renderedBoundingBox=function(r){var e=this.boundingBox(r),t=this.cy(),a=t.zoom(),n=t.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}},ut.dirtyCompoundBoundsCache=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();return!e.styleEnabled()||!e.hasCompoundNodes()?this:(this.forEachUp(function(t){if(t.isParent()){var a=t._private;a.compoundBoundsClean=!1,a.bbCache=null,r||t.emitAndNotify("bounds")}}),this)},ut.updateCompoundBounds=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();if(!e.styleEnabled()||!e.hasCompoundNodes())return this;if(!r&&e.batching())return this;function t(s){if(!s.isParent())return;var o=s._private,u=s.children(),l=s.pstyle("compound-sizing-wrt-labels").value==="include",v={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")}},f=u.boundingBox({includeLabels:l,includeOverlays:!1,useCache:!1}),d=o.position;(f.w===0||f.h===0)&&(f={w:s.pstyle("width").pfValue,h:s.pstyle("height").pfValue},f.x1=d.x-f.w/2,f.x2=d.x+f.w/2,f.y1=d.y-f.h/2,f.y2=d.y+f.h/2);function h(F,S,D){var C=0,B=0,A=S+D;return F>0&&A>0&&(C=S/A*F,B=D/A*F),{biasDiff:C,biasComplementDiff:B}}function c(F,S,D,C){if(D.units==="%")switch(C){case"width":return F>0?D.pfValue*F:0;case"height":return S>0?D.pfValue*S:0;case"average":return F>0&&S>0?D.pfValue*(F+S)/2:0;case"min":return F>0&&S>0?F>S?D.pfValue*S:D.pfValue*F:0;case"max":return F>0&&S>0?F>S?D.pfValue*F:D.pfValue*S:0;default:return 0}else return D.units==="px"?D.pfValue:0}var m=v.width.left.value;v.width.left.units==="px"&&v.width.val>0&&(m=m*100/v.width.val);var g=v.width.right.value;v.width.right.units==="px"&&v.width.val>0&&(g=g*100/v.width.val);var p=v.height.top.value;v.height.top.units==="px"&&v.height.val>0&&(p=p*100/v.height.val);var y=v.height.bottom.value;v.height.bottom.units==="px"&&v.height.val>0&&(y=y*100/v.height.val);var w=h(v.width.val-f.w,m,g),b=w.biasDiff,k=w.biasComplementDiff,x=h(v.height.val-f.h,p,y),E=x.biasDiff,T=x.biasComplementDiff;o.autoPadding=c(f.w,f.h,s.pstyle("padding"),s.pstyle("padding-relative-to").value),o.autoWidth=Math.max(f.w,v.width.val),d.x=(-b+f.x1+f.x2+k)/2,o.autoHeight=Math.max(f.h,v.height.val),d.y=(-E+f.y1+f.y2+T)/2}for(var a=0;a<this.length;a++){var n=this[a],i=n._private;(!i.compoundBoundsClean||r)&&(t(n),e.batching()||(i.compoundBoundsClean=!0))}return this};var xr=function(e){return e===1/0||e===-1/0?0:e},Dr=function(e,t,a,n,i){n-t===0||i-a===0||t==null||a==null||n==null||i==null||(e.x1=t<e.x1?t:e.x1,e.x2=n>e.x2?n:e.x2,e.y1=a<e.y1?a:e.y1,e.y2=i>e.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},bt=function(e,t){return t==null?e:Dr(e,t.x1,t.y1,t.x2,t.y2)},Ea=function(e,t,a){return Sr(e,t,a)},pn=function(e,t,a){if(!t.cy().headless()){var n=t._private,i=n.rstyle,s=i.arrowWidth/2,o=t.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 v=n.arrowBounds=n.arrowBounds||{},f=v[a]=v[a]||{};f.x1=u-s,f.y1=l-s,f.x2=u+s,f.y2=l+s,f.w=f.x2-f.x1,f.h=f.y2-f.y1,en(f,1),Dr(e,f.x1,f.y1,f.x2,f.y2)}}},Ti=function(e,t,a){if(!t.cy().headless()){var n;a?n=a+"-":n="";var i=t._private,s=i.rstyle,o=t.pstyle(n+"label").strValue;if(o){var u=t.pstyle("text-halign"),l=t.pstyle("text-valign"),v=Ea(s,"labelWidth",a),f=Ea(s,"labelHeight",a),d=Ea(s,"labelX",a),h=Ea(s,"labelY",a),c=t.pstyle(n+"text-margin-x").pfValue,m=t.pstyle(n+"text-margin-y").pfValue,g=t.isEdge(),p=t.pstyle(n+"text-rotation"),y=t.pstyle("text-outline-width").pfValue,w=t.pstyle("text-border-width").pfValue,b=w/2,k=t.pstyle("text-background-padding").pfValue,x=2,E=f,T=v,F=T/2,S=E/2,D,C,B,A;if(g)D=d-F,C=d+F,B=h-S,A=h+S;else{switch(u.value){case"left":D=d-T,C=d;break;case"center":D=d-F,C=d+F;break;case"right":D=d,C=d+T;break}switch(l.value){case"top":B=h-E,A=h;break;case"center":B=h-S,A=h+S;break;case"bottom":B=h,A=h+E;break}}var M=c-Math.max(y,b)-k-x,I=c+Math.max(y,b)+k+x,R=m-Math.max(y,b)-k-x,L=m+Math.max(y,b)+k+x;D+=M,C+=I,B+=R,A+=L;var V=a||"main",H=i.labelBounds,z=H[V]=H[V]||{};z.x1=D,z.y1=B,z.x2=C,z.y2=A,z.w=C-D,z.h=A-B,z.leftPad=M,z.rightPad=I,z.topPad=R,z.botPad=L;var $=g&&p.strValue==="autorotate",K=p.pfValue!=null&&p.pfValue!==0;if($||K){var Y=$?Ea(i.rstyle,"labelAngle",a):p.pfValue,Q=Math.cos(Y),Z=Math.sin(Y),j=(D+C)/2,re=(B+A)/2;if(!g){switch(u.value){case"left":j=C;break;case"right":j=D;break}switch(l.value){case"top":re=A;break;case"bottom":re=B;break}}var W=function(Ie,le){return Ie=Ie-j,le=le-re,{x:Ie*Q-le*Z+j,y:Ie*Z+le*Q+re}},O=W(D,B),G=W(D,A),ee=W(C,B),ie=W(C,A);D=Math.min(O.x,G.x,ee.x,ie.x),C=Math.max(O.x,G.x,ee.x,ie.x),B=Math.min(O.y,G.y,ee.y,ie.y),A=Math.max(O.y,G.y,ee.y,ie.y)}var ue=V+"Rot",Ce=H[ue]=H[ue]||{};Ce.x1=D,Ce.y1=B,Ce.x2=C,Ce.y2=A,Ce.w=C-D,Ce.h=A-B,Dr(e,D,B,C,A),Dr(i.labelBounds.all,D,B,C,A)}return e}},Fg=function(e,t){if(!t.cy().headless()){var a=t.pstyle("outline-opacity").value,n=t.pstyle("outline-width").value;if(a>0&&n>0){var i=t.pstyle("outline-offset").value,s=t.pstyle("shape").value,o=n+i,u=(e.w+o*2)/e.w,l=(e.h+o*2)/e.h,v=0,f=0;["diamond","pentagon","round-triangle"].includes(s)?(u=(e.w+o*2.4)/e.w,f=-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,f=-o/3.8):s==="triangle"?(u=(e.w+o*2.8)/e.w,l=(e.h+o*2.4)/e.h,f=-o/1.4):s==="vee"&&(u=(e.w+o*4.4)/e.w,l=(e.h+o*3.8)/e.h,f=-o*.5);var d=e.h*l-e.h,h=e.w*u-e.w;if(rn(e,[Math.ceil(d/2),Math.ceil(h/2)]),v!=0||f!==0){var c=qf(e,v,f);Ns(e,c)}}}},Eg=function(e,t){var a=e._private.cy,n=a.styleEnabled(),i=a.headless(),s=hr(),o=e._private,u=e.isNode(),l=e.isEdge(),v,f,d,h,c,m,g=o.rstyle,p=u&&n?e.pstyle("bounds-expansion").pfValue:[0],y=function(Ae){return Ae.pstyle("display").value!=="none"},w=!n||y(e)&&(!l||y(e.source())&&y(e.target()));if(w){var b=0,k=0;n&&t.includeOverlays&&(b=e.pstyle("overlay-opacity").value,b!==0&&(k=e.pstyle("overlay-padding").value));var x=0,E=0;n&&t.includeUnderlays&&(x=e.pstyle("underlay-opacity").value,x!==0&&(E=e.pstyle("underlay-padding").value));var T=Math.max(k,E),F=0,S=0;if(n&&(F=e.pstyle("width").pfValue,S=F/2),u&&t.includeNodes){var D=e.position();c=D.x,m=D.y;var C=e.outerWidth(),B=C/2,A=e.outerHeight(),M=A/2;v=c-B,f=c+B,d=m-M,h=m+M,Dr(s,v,d,f,h),n&&t.includeOutlines&&Fg(s,e)}else if(l&&t.includeEdges)if(n&&!i){var I=e.pstyle("curve-style").strValue;if(v=Math.min(g.srcX,g.midX,g.tgtX),f=Math.max(g.srcX,g.midX,g.tgtX),d=Math.min(g.srcY,g.midY,g.tgtY),h=Math.max(g.srcY,g.midY,g.tgtY),v-=S,f+=S,d-=S,h+=S,Dr(s,v,d,f,h),I==="haystack"){var R=g.haystackPts;if(R&&R.length===2){if(v=R[0].x,d=R[0].y,f=R[1].x,h=R[1].y,v>f){var L=v;v=f,f=L}if(d>h){var V=d;d=h,h=V}Dr(s,v-S,d-S,f+S,h+S)}}else if(I==="bezier"||I==="unbundled-bezier"||I.endsWith("segments")||I.endsWith("taxi")){var H;switch(I){case"bezier":case"unbundled-bezier":H=g.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":H=g.linePts;break}if(H!=null)for(var z=0;z<H.length;z++){var $=H[z];v=$.x-S,f=$.x+S,d=$.y-S,h=$.y+S,Dr(s,v,d,f,h)}}}else{var K=e.source(),Y=K.position(),Q=e.target(),Z=Q.position();if(v=Y.x,f=Z.x,d=Y.y,h=Z.y,v>f){var j=v;v=f,f=j}if(d>h){var re=d;d=h,h=re}v-=S,f+=S,d-=S,h+=S,Dr(s,v,d,f,h)}if(n&&t.includeEdges&&l&&(pn(s,e,"mid-source"),pn(s,e,"mid-target"),pn(s,e,"source"),pn(s,e,"target")),n){var W=e.pstyle("ghost").value==="yes";if(W){var O=e.pstyle("ghost-offset-x").pfValue,G=e.pstyle("ghost-offset-y").pfValue;Dr(s,s.x1+O,s.y1+G,s.x2+O,s.y2+G)}}var ee=o.bodyBounds=o.bodyBounds||{};zs(ee,s),rn(ee,p),en(ee,1),n&&(v=s.x1,f=s.x2,d=s.y1,h=s.y2,Dr(s,v-T,d-T,f+T,h+T));var ie=o.overlayBounds=o.overlayBounds||{};zs(ie,s),rn(ie,p),en(ie,1);var ue=o.labelBounds=o.labelBounds||{};ue.all!=null?$f(ue.all):ue.all=hr(),n&&t.includeLabels&&(t.includeMainLabels&&Ti(s,e,null),l&&(t.includeSourceLabels&&Ti(s,e,"source"),t.includeTargetLabels&&Ti(s,e,"target")))}return s.x1=xr(s.x1),s.y1=xr(s.y1),s.x2=xr(s.x2),s.y2=xr(s.y2),s.w=xr(s.x2-s.x1),s.h=xr(s.y2-s.y1),s.w>0&&s.h>0&&w&&(rn(s,p),en(s,1)),s},Ro=function(e){var t=0,a=function(s){return(s?1:0)<<t++},n=0;return n+=a(e.incudeNodes),n+=a(e.includeEdges),n+=a(e.includeLabels),n+=a(e.includeMainLabels),n+=a(e.includeSourceLabels),n+=a(e.includeTargetLabels),n+=a(e.includeOverlays),n+=a(e.includeOutlines),n},Lo=function(e){if(e.isEdge()){var t=e.source().position(),a=e.target().position(),n=function(s){return Math.round(s)};return uf([n(t.x),n(t.y),n(a.x),n(a.y)])}else return 0},Oo=function(e,t){var a=e._private,n,i=e.isEdge(),s=t==null?_o:Ro(t),o=s===_o,u=Lo(e),l=a.bbCachePosKey===u,v=t.useCache&&l,f=function(m){return m._private.bbCache==null||m._private.styleDirty},d=!v||f(e)||i&&(f(e.source())||f(e.target()));if(d?(l||e.recalculateRenderedStyle(v),n=Eg(e,xa),a.bbCache=n,a.bbCachePosKey=u):n=a.bbCache,!o){var h=e.isNode();n=hr(),(t.includeNodes&&h||t.includeEdges&&!h)&&(t.includeOverlays?bt(n,a.overlayBounds):bt(n,a.bodyBounds)),t.includeLabels&&(t.includeMainLabels&&(!i||t.includeSourceLabels&&t.includeTargetLabels)?bt(n,a.labelBounds.all):(t.includeMainLabels&&bt(n,a.labelBounds.mainRot),t.includeSourceLabels&&bt(n,a.labelBounds.sourceRot),t.includeTargetLabels&&bt(n,a.labelBounds.targetRot))),n.w=n.x2-n.x1,n.h=n.y2-n.y1}return n},xa={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,includeUnderlays:!0,includeOutlines:!0,useCache:!0},_o=Ro(xa),No=Ye(xa);ut.boundingBox=function(r){var e;if(this.length===1&&this[0]._private.bbCache!=null&&!this[0]._private.styleDirty&&(r===void 0||r.useCache===void 0||r.useCache===!0))r===void 0?r=xa:r=No(r),e=Oo(this[0],r);else{e=hr(),r=r||xa;var t=No(r),a=this,n=a.cy(),i=n.styleEnabled();if(i)for(var s=0;s<a.length;s++){var o=a[s],u=o._private,l=Lo(o),v=u.bbCachePosKey===l,f=t.useCache&&v&&!u.styleDirty;o.recalculateRenderedStyle(f)}this.updateCompoundBounds(!r.useCache);for(var d=0;d<a.length;d++){var h=a[d];bt(e,Oo(h,t))}}return e.x1=xr(e.x1),e.y1=xr(e.y1),e.x2=xr(e.x2),e.y2=xr(e.y2),e.w=xr(e.x2-e.x1),e.h=xr(e.y2-e.y1),e},ut.dirtyBoundingBoxCache=function(){for(var r=0;r<this.length;r++){var e=this[r]._private;e.bbCache=null,e.bbCachePosKey=null,e.bodyBounds=null,e.overlayBounds=null,e.labelBounds.all=null,e.labelBounds.source=null,e.labelBounds.target=null,e.labelBounds.main=null,e.labelBounds.sourceRot=null,e.labelBounds.targetRot=null,e.labelBounds.mainRot=null,e.arrowBounds.source=null,e.arrowBounds.target=null,e.arrowBounds["mid-source"]=null,e.arrowBounds["mid-target"]=null}return this.emitAndNotify("bounds"),this},ut.boundingBoxAt=function(r){var e=this.nodes(),t=this.cy(),a=t.hasCompoundNodes(),n=t.collection();if(a&&(n=e.filter(function(l){return l.isParent()}),e=e.not(n)),Se(r)){var i=r;r=function(){return i}}var s=function(v,f){return v._private.bbAtOldPos=r(v,f)},o=function(v){return v._private.bbAtOldPos};t.startBatch(),e.forEach(s).silentPositions(r),a&&(n.dirtyCompoundBoundsCache(),n.dirtyBoundingBoxCache(),n.updateCompoundBounds(!0));var u=Vf(this.boundingBox({useCache:!1}));return e.silentPositions(o),a&&(n.dirtyCompoundBoundsCache(),n.dirtyBoundingBoxCache(),n.updateCompoundBounds(!0)),t.endBatch(),u},Gt.boundingbox=Gt.bb=Gt.boundingBox,Gt.renderedBoundingbox=Gt.renderedBoundingBox;var xg=ut,Ca,Ta;Ca=Ta={};var zo=function(e){e.uppercaseName=gs(e.name),e.autoName="auto"+e.uppercaseName,e.labelName="label"+e.uppercaseName,e.outerName="outer"+e.uppercaseName,e.uppercaseOuterName=gs(e.outerName),Ca[e.name]=function(){var a=this[0],n=a._private,i=n.cy,s=i._private.styleEnabled;if(a)if(s){if(a.isParent())return a.updateCompoundBounds(),n[e.autoName]||0;var o=a.pstyle(e.name);switch(o.strValue){case"label":return a.recalculateRenderedStyle(),n.rstyle[e.labelName]||0;default:return o.pfValue}}else return 1},Ca["outer"+e.uppercaseName]=function(){var a=this[0],n=a._private,i=n.cy,s=i._private.styleEnabled;if(a)if(s){var o=a[e.name](),u=a.pstyle("border-width").pfValue,l=2*a.padding();return o+u+l}else return 1},Ca["rendered"+e.uppercaseName]=function(){var a=this[0];if(a){var n=a[e.name]();return n*this.cy().zoom()}},Ca["rendered"+e.uppercaseOuterName]=function(){var a=this[0];if(a){var n=a[e.outerName]();return n*this.cy().zoom()}}};zo({name:"width"}),zo({name:"height"}),Ta.padding=function(){var r=this[0],e=r._private;return r.isParent()?(r.updateCompoundBounds(),e.autoPadding!==void 0?e.autoPadding:r.pstyle("padding").pfValue):r.pstyle("padding").pfValue},Ta.paddedHeight=function(){var r=this[0];return r.height()+2*r.padding()},Ta.paddedWidth=function(){var r=this[0];return r.width()+2*r.padding()};var Cg=Ta,Tg=function(e,t){if(e.isEdge())return t(e)},Sg=function(e,t){if(e.isEdge()){var a=e.cy();return Ja(t(e),a.zoom(),a.pan())}},kg=function(e,t){if(e.isEdge()){var a=e.cy(),n=a.pan(),i=a.zoom();return t(e).map(function(s){return Ja(s,i,n)})}},Dg=function(e){return e.renderer().getControlPoints(e)},Pg=function(e){return e.renderer().getSegmentPoints(e)},Bg=function(e){return e.renderer().getSourceEndpoint(e)},Ag=function(e){return e.renderer().getTargetEndpoint(e)},Ig=function(e){return e.renderer().getEdgeMidpoint(e)},Vo={controlPoints:{get:Dg,mult:!0},segmentPoints:{get:Pg,mult:!0},sourceEndpoint:{get:Bg},targetEndpoint:{get:Ag},midpoint:{get:Ig}},Mg=function(e){return"rendered"+e[0].toUpperCase()+e.substr(1)},Rg=Object.keys(Vo).reduce(function(r,e){var t=Vo[e],a=Mg(e);return r[e]=function(){return Tg(this,t.get)},t.mult?r[a]=function(){return kg(this,t.get)}:r[a]=function(){return Sg(this,t.get)},r},{}),Lg=ce({},bg,xg,Cg,Rg);/*!
  Event object based on jQuery events, MIT license

  https://jquery.org/license/
  https://tldrlegal.com/license/mit-license
  https://github.com/jquery/jquery/blob/master/src/event.js
  */var $o=function(e,t){this.recycle(e,t)};function Sa(){return!1}function mn(){return!0}$o.prototype={instanceString:function(){return"event"},recycle:function(e,t){if(this.isImmediatePropagationStopped=this.isPropagationStopped=this.isDefaultPrevented=Sa,e!=null&&e.preventDefault?(this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?mn:Sa):e!=null&&e.type?t=e:this.type=e,t!=null&&(this.originalEvent=t.originalEvent,this.type=t.type!=null?t.type:this.type,this.cy=t.cy,this.target=t.target,this.position=t.position,this.renderedPosition=t.renderedPosition,this.namespace=t.namespace,this.layout=t.layout),this.cy!=null&&this.position!=null&&this.renderedPosition==null){var a=this.position,n=this.cy.zoom(),i=this.cy.pan();this.renderedPosition={x:a.x*n+i.x,y:a.y*n+i.y}}this.timeStamp=e&&e.timeStamp||Date.now()},preventDefault:function(){this.isDefaultPrevented=mn;var e=this.originalEvent;e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){this.isPropagationStopped=mn;var e=this.originalEvent;e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=mn,this.stopPropagation()},isDefaultPrevented:Sa,isPropagationStopped:Sa,isImmediatePropagationStopped:Sa};var qo=/^([^.]+)(\.(?:[^.]+))?$/,Og=".*",Wo={qualifierCompare:function(e,t){return e===t},eventMatches:function(){return!0},addEventFields:function(){},callbackContext:function(e){return e},beforeEmit:function(){},afterEmit:function(){},bubble:function(){return!1},parent:function(){return null},context:null},Ho=Object.keys(Wo),_g={};function yn(){for(var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_g,e=arguments.length>1?arguments[1]:void 0,t=0;t<Ho.length;t++){var a=Ho[t];this[a]=r[a]||Wo[a]}this.context=e||this.context,this.listeners=[],this.emitting=0}var lt=yn.prototype,Go=function(e,t,a,n,i,s,o){ze(n)&&(i=n,n=null),o&&(s==null?s=o:s=ce({},s,o));for(var u=Re(a)?a:a.split(/\s+/),l=0;l<u.length;l++){var v=u[l];if(!Jr(v)){var f=v.match(qo);if(f){var d=f[1],h=f[2]?f[2]:null,c=t(e,v,d,h,n,i,s);if(c===!1)break}}}},Uo=function(e,t){return e.addEventFields(e.context,t),new $o(t.type,t)},Ng=function(e,t,a){if(nv(a)){t(e,a);return}else if(Se(a)){t(e,Uo(e,a));return}for(var n=Re(a)?a:a.split(/\s+/),i=0;i<n.length;i++){var s=n[i];if(!Jr(s)){var o=s.match(qo);if(o){var u=o[1],l=o[2]?o[2]:null,v=Uo(e,{type:u,namespace:l,target:e.context});t(e,v)}}}};lt.on=lt.addListener=function(r,e,t,a,n){return Go(this,function(i,s,o,u,l,v,f){ze(v)&&i.listeners.push({event:s,callback:v,type:o,namespace:u,qualifier:l,conf:f})},r,e,t,a,n),this},lt.one=function(r,e,t,a){return this.on(r,e,t,a,{one:!0})},lt.removeListener=lt.off=function(r,e,t,a){var n=this;this.emitting!==0&&(this.listeners=cf(this.listeners));for(var i=this.listeners,s=function(l){var v=i[l];Go(n,function(f,d,h,c,m,g){if((v.type===h||r==="*")&&(!c&&v.namespace!==".*"||v.namespace===c)&&(!m||f.qualifierCompare(v.qualifier,m))&&(!g||v.callback===g))return i.splice(l,1),!1},r,e,t,a)},o=i.length-1;o>=0;o--)s(o);return this},lt.removeAllListeners=function(){return this.removeListener("*")},lt.emit=lt.trigger=function(r,e,t){var a=this.listeners,n=a.length;return this.emitting++,Re(e)||(e=[e]),Ng(this,function(i,s){t!=null&&(a=[{event:s.event,type:s.type,namespace:s.namespace,callback:t}],n=a.length);for(var o=function(v){var f=a[v];if(f.type===s.type&&(!f.namespace||f.namespace===s.namespace||f.namespace===Og)&&i.eventMatches(i.context,f,s)){var d=[s];e!=null&&gf(d,e),i.beforeEmit(i.context,f,s),f.conf&&f.conf.one&&(i.listeners=i.listeners.filter(function(m){return m!==f}));var h=i.callbackContext(i.context,f,s),c=f.callback.apply(h,d);i.afterEmit(i.context,f,s),c===!1&&(s.stopPropagation(),s.preventDefault())}},u=0;u<n;u++)o(u);i.bubble(i.context)&&!s.isPropagationStopped()&&i.parent(i.context).emit(s,e)},r),this.emitting--,this};var zg={qualifierCompare:function(e,t){return e==null||t==null?e==null&&t==null:e.sameText(t)},eventMatches:function(e,t,a){var n=t.qualifier;return n!=null?e!==a.target&&ia(a.target)&&n.matches(a.target):!0},addEventFields:function(e,t){t.cy=e.cy(),t.target=e},callbackContext:function(e,t,a){return t.qualifier!=null?a.target:e},beforeEmit:function(e,t){t.conf&&t.conf.once&&t.conf.onceCollection.removeListener(t.event,t.qualifier,t.callback)},bubble:function(){return!0},parent:function(e){return e.isChild()?e.parent():e.cy()}},wn=function(e){return fe(e)?new it(e):e},Ko={createEmitter:function(){for(var e=0;e<this.length;e++){var t=this[e],a=t._private;a.emitter||(a.emitter=new yn(zg,t))}return this},emitter:function(){return this._private.emitter},on:function(e,t,a){for(var n=wn(t),i=0;i<this.length;i++){var s=this[i];s.emitter().on(e,n,a)}return this},removeListener:function(e,t,a){for(var n=wn(t),i=0;i<this.length;i++){var s=this[i];s.emitter().removeListener(e,n,a)}return this},removeAllListeners:function(){for(var e=0;e<this.length;e++){var t=this[e];t.emitter().removeAllListeners()}return this},one:function(e,t,a){for(var n=wn(t),i=0;i<this.length;i++){var s=this[i];s.emitter().one(e,n,a)}return this},once:function(e,t,a){for(var n=wn(t),i=0;i<this.length;i++){var s=this[i];s.emitter().on(e,n,a,{once:!0,onceCollection:this})}},emit:function(e,t){for(var a=0;a<this.length;a++){var n=this[a];n.emitter().emit(e,t)}return this},emitAndNotify:function(e,t){if(this.length!==0)return this.cy().notify(e,this),this.emit(e,t),this}};Be.eventAliasesOn(Ko);var Xo={nodes:function(e){return this.filter(function(t){return t.isNode()}).filter(e)},edges:function(e){return this.filter(function(t){return t.isEdge()}).filter(e)},byGroup:function(){for(var e=this.spawn(),t=this.spawn(),a=0;a<this.length;a++){var n=this[a];n.isNode()?e.push(n):t.push(n)}return{nodes:e,edges:t}},filter:function(e,t){if(e===void 0)return this;if(fe(e)||yr(e))return new it(e).filter(this);if(ze(e)){for(var a=this.spawn(),n=this,i=0;i<n.length;i++){var s=n[i],o=t?e.apply(t,[s,i,n]):e(s,i,n);o&&a.push(s)}return a}return this.spawn()},not:function(e){if(e){fe(e)&&(e=this.filter(e));for(var t=this.spawn(),a=0;a<this.length;a++){var n=this[a],i=e.has(n);i||t.push(n)}return t}else return this},absoluteComplement:function(){var e=this.cy();return e.mutableElements().not(this)},intersect:function(e){if(fe(e)){var t=e;return this.filter(t)}for(var a=this.spawn(),n=this,i=e,s=this.length<e.length,o=s?n:i,u=s?i:n,l=0;l<o.length;l++){var v=o[l];u.has(v)&&a.push(v)}return a},xor:function(e){var t=this._private.cy;fe(e)&&(e=t.$(e));var a=this.spawn(),n=this,i=e,s=function(u,l){for(var v=0;v<u.length;v++){var f=u[v],d=f._private.data.id,h=l.hasElementWithId(d);h||a.push(f)}};return s(n,i),s(i,n),a},diff:function(e){var t=this._private.cy;fe(e)&&(e=t.$(e));var a=this.spawn(),n=this.spawn(),i=this.spawn(),s=this,o=e,u=function(v,f,d){for(var h=0;h<v.length;h++){var c=v[h],m=c._private.data.id,g=f.hasElementWithId(m);g?i.merge(c):d.push(c)}};return u(s,o,a),u(o,s,n),{left:a,right:n,both:i}},add:function(e){var t=this._private.cy;if(!e)return this;if(fe(e)){var a=e;e=t.mutableElements().filter(a)}for(var n=this.spawnSelf(),i=0;i<e.length;i++){var s=e[i],o=!this.has(s);o&&n.push(s)}return n},merge:function(e){var t=this._private,a=t.cy;if(!e)return this;if(e&&fe(e)){var n=e;e=a.mutableElements().filter(n)}for(var i=t.map,s=0;s<e.length;s++){var o=e[s],u=o._private.data.id,l=!i.has(u);if(l){var v=this.length++;this[v]=o,i.set(u,{ele:o,index:v})}}return this},unmergeAt:function(e){var t=this[e],a=t.id(),n=this._private,i=n.map;this[e]=void 0,i.delete(a);var s=e===this.length-1;if(this.length>1&&!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 t=this._private,a=e._private.data.id,n=t.map,i=n.get(a);if(!i)return this;var s=i.index;return this.unmergeAt(s),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&fe(e)){var a=e;e=t.mutableElements().filter(a)}for(var n=0;n<e.length;n++)this.unmergeOne(e[n]);return this},unmergeBy:function(e){for(var t=this.length-1;t>=0;t--){var a=this[t];e(a)&&this.unmergeAt(t)}return this},map:function(e,t){for(var a=[],n=this,i=0;i<n.length;i++){var s=n[i],o=t?e.apply(t,[s,i,n]):e(s,i,n);a.push(o)}return a},reduce:function(e,t){for(var a=t,n=this,i=0;i<n.length;i++)a=e(a,n[i],i,n);return a},max:function(e,t){for(var a=-1/0,n,i=this,s=0;s<i.length;s++){var o=i[s],u=t?e.apply(t,[o,s,i]):e(o,s,i);u>a&&(a=u,n=o)}return{value:a,ele:n}},min:function(e,t){for(var a=1/0,n,i=this,s=0;s<i.length;s++){var o=i[s],u=t?e.apply(t,[o,s,i]):e(o,s,i);u<a&&(a=u,n=o)}return{value:a,ele:n}}},De=Xo;De.u=De["|"]=De["+"]=De.union=De.or=De.add,De["\\"]=De["!"]=De["-"]=De.difference=De.relativeComplement=De.subtract=De.not,De.n=De["&"]=De["."]=De.and=De.intersection=De.intersect,De["^"]=De["(+)"]=De["(-)"]=De.symmetricDifference=De.symdiff=De.xor,De.fnFilter=De.filterFn=De.stdFilter=De.filter,De.complement=De.abscomp=De.absoluteComplement;var Vg={isNode:function(){return this.group()==="nodes"},isEdge:function(){return this.group()==="edges"},isLoop:function(){return this.isEdge()&&this.source()[0]===this.target()[0]},isSimple:function(){return this.isEdge()&&this.source()[0]!==this.target()[0]},group:function(){var e=this[0];if(e)return e._private.group}},Yo=function(e,t){var a=e.cy(),n=a.hasCompoundNodes();function i(v){var f=v.pstyle("z-compound-depth");return f.value==="auto"?n?v.zDepth():0:f.value==="bottom"?-1:f.value==="top"?ti:0}var s=i(e)-i(t);if(s!==0)return s;function o(v){var f=v.pstyle("z-index-compare");return f.value==="auto"&&v.isNode()?1:0}var u=o(e)-o(t);if(u!==0)return u;var l=e.pstyle("z-index").value-t.pstyle("z-index").value;return l!==0?l:e.poolIndex()-t.poolIndex()},bn={forEach:function(e,t){if(ze(e))for(var a=this.length,n=0;n<a;n++){var i=this[n],s=t?e.apply(t,[i,n,this]):e(i,n,this);if(s===!1)break}return this},toArray:function(){for(var e=[],t=0;t<this.length;t++)e.push(this[t]);return e},slice:function(e,t){var a=[],n=this.length;t==null&&(t=n),e==null&&(e=0),e<0&&(e=n+e),t<0&&(t=n+t);for(var i=e;i>=0&&i<t&&i<n;i++)a.push(this[i]);return this.spawn(a)},size:function(){return this.length},eq:function(e){return this[e]||this.spawn()},first:function(){return this[0]||this.spawn()},last:function(){return this[this.length-1]||this.spawn()},empty:function(){return this.length===0},nonempty:function(){return!this.empty()},sort:function(e){if(!ze(e))return this;var t=this.toArray().sort(e);return this.spawn(t)},sortByZIndex:function(){return this.sort(Yo)},zDepth:function(){var e=this[0];if(e){var t=e._private,a=t.group;if(a==="nodes"){var n=t.data.parent?e.parents().size():0;return e.isParent()?n:ti-1}else{var i=t.source,s=t.target,o=i.zDepth(),u=s.zDepth();return Math.max(o,u,0)}}}};bn.each=bn.forEach;var $g=function(){var e="undefined",t=(typeof Symbol>"u"?"undefined":He(Symbol))!=e&&He(Symbol.iterator)!=e;t&&(bn[Symbol.iterator]=function(){var a=this,n={value:void 0,done:!1},i=0,s=this.length;return us({next:function(){return i<s?n.value=a[i++]:(n.value=void 0,n.done=!0),n}},Symbol.iterator,function(){return this})})};$g();var qg=Ye({nodeDimensionsIncludeLabels:!1}),Fn={layoutDimensions:function(e){e=qg(e);var t;if(!this.takesUpSpace())t={w:0,h:0};else if(e.nodeDimensionsIncludeLabels){var a=this.boundingBox();t={w:a.w,h:a.h}}else t={w:this.outerWidth(),h:this.outerHeight()};return(t.w===0||t.h===0)&&(t.w=t.h=1),t},layoutPositions:function(e,t,a){var n=this.nodes().filter(function(k){return!k.isParent()}),i=this.cy(),s=t.eles,o=function(x){return x.id()},u=sa(a,o);e.emit({type:"layoutstart",layout:e}),e.animations=[];var l=function(x,E,T){var F={x:E.x1+E.w/2,y:E.y1+E.h/2},S={x:(T.x-F.x)*x,y:(T.y-F.y)*x};return{x:F.x+S.x,y:F.y+S.y}},v=t.spacingFactor&&t.spacingFactor!==1,f=function(){if(!v)return null;for(var x=hr(),E=0;E<n.length;E++){var T=n[E],F=u(T,E);Wf(x,F.x,F.y)}return x},d=f(),h=sa(function(k,x){var E=u(k,x);if(v){var T=Math.abs(t.spacingFactor);E=l(T,d,E)}return t.transform!=null&&(E=t.transform(k,E)),E},o);if(t.animate){for(var c=0;c<n.length;c++){var m=n[c],g=h(m,c),p=t.animateFilter==null||t.animateFilter(m,c);if(p){var y=m.animation({position:g,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(y)}else m.position(g)}if(t.fit){var w=i.animation({fit:{boundingBox:s.boundingBoxAt(h),padding:t.padding},duration:t.animationDuration,easing:t.animationEasing});e.animations.push(w)}else if(t.zoom!==void 0&&t.pan!==void 0){var b=i.animation({zoom:t.zoom,pan:t.pan,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(b)}e.animations.forEach(function(k){return k.play()}),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),Nt.all(e.animations.map(function(k){return k.promise()})).then(function(){e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e})})}else n.positions(h),t.fit&&i.fit(t.eles,t.padding),t.zoom!=null&&i.zoom(t.zoom),t.pan&&i.pan(t.pan),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e});return this},layout:function(e){var t=this.cy();return t.makeLayout(ce({},e,{eles:this}))}};Fn.createLayout=Fn.makeLayout=Fn.layout;function Zo(r,e,t){var a=t._private,n=a.styleCache=a.styleCache||[],i;return(i=n[r])!=null||(i=n[r]=e(t)),i}function En(r,e){return r=et(r),function(a){return Zo(r,e,a)}}function xn(r,e){r=et(r);var t=function(n){return e.call(n)};return function(){var n=this[0];if(n)return Zo(r,t,n)}}var er={recalculateRenderedStyle:function(e){var t=this.cy(),a=t.renderer(),n=t.styleEnabled();return a&&n&&a.recalculateRenderedStyle(this,e),this},dirtyStyleCache:function(){var e=this.cy(),t=function(i){return i._private.styleCache=null};if(e.hasCompoundNodes()){var a;a=this.spawnSelf().merge(this.descendants()).merge(this.parents()),a.merge(a.connectedEdges()),a.forEach(t)}else this.forEach(function(n){t(n),n.connectedEdges().forEach(t)});return this},updateStyle:function(e){var t=this._private.cy;if(!t.styleEnabled())return this;if(t.batching()){var a=t._private.batchStyleEles;return a.merge(this),this}var n=t.hasCompoundNodes(),i=this;e=!!(e||e===void 0),n&&(i=this.spawnSelf().merge(this.descendants()).merge(this.parents()));var s=i;return e?s.emitAndNotify("style"):s.emit("style"),i.forEach(function(o){return o._private.styleDirty=!0}),this},cleanStyle:function(){var e=this.cy();if(e.styleEnabled())for(var t=0;t<this.length;t++){var a=this[t];a._private.styleDirty&&(a._private.styleDirty=!1,e.style().apply(a))}},parsedStyle:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,a=this[0],n=a.cy();if(n.styleEnabled()&&a){a._private.styleDirty&&(a._private.styleDirty=!1,n.style().apply(a));var i=a._private.style[e];return i??(t?n.style().getDefaultProperty(e):null)}},numericStyle:function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var a=t.pstyle(e);return a.pfValue!==void 0?a.pfValue:a.value}},numericStyleUnits:function(e){var t=this[0];if(t.cy().styleEnabled()&&t)return t.pstyle(e).units},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var a=this[0];if(a)return t.style().getRenderedStyle(a,e)},style:function(e,t){var a=this.cy();if(!a.styleEnabled())return this;var n=!1,i=a.style();if(Se(e)){var s=e;i.applyBypass(this,s,n),this.emitAndNotify("style")}else if(fe(e))if(t===void 0){var o=this[0];return o?i.getStylePropertyValue(o,e):void 0}else i.applyBypass(this,e,t,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 t=this.cy();if(!t.styleEnabled())return this;var a=!1,n=t.style(),i=this;if(e===void 0)for(var s=0;s<i.length;s++){var o=i[s];n.removeAllBypasses(o,a)}else{e=e.split(/\s+/);for(var u=0;u<i.length;u++){var l=i[u];n.removeBypasses(l,e,a)}}return this.emitAndNotify("style"),this},show:function(){return this.css("display","element"),this},hide:function(){return this.css("display","none"),this},effectiveOpacity:function(){var e=this.cy();if(!e.styleEnabled())return 1;var t=e.hasCompoundNodes(),a=this[0];if(a){var n=a._private,i=a.pstyle("opacity").value;if(!t)return i;var s=n.data.parent?a.parents():null;if(s)for(var o=0;o<s.length;o++){var u=s[o],l=u.pstyle("opacity").value;i=l*i}return i}},transparent:function(){var e=this.cy();if(!e.styleEnabled())return!1;var t=this[0],a=t.cy().hasCompoundNodes();if(t)return a?t.effectiveOpacity()===0:t.pstyle("opacity").value===0},backgrounding:function(){var e=this.cy();if(!e.styleEnabled())return!1;var t=this[0];return!!t._private.backgrounding}};function Si(r,e){var t=r._private,a=t.data.parent?r.parents():null;if(a)for(var n=0;n<a.length;n++){var i=a[n];if(!e(i))return!1}return!0}function ki(r){var e=r.ok,t=r.edgeOkViaNode||r.ok,a=r.parentOk||r.ok;return function(){var n=this.cy();if(!n.styleEnabled())return!0;var i=this[0],s=n.hasCompoundNodes();if(i){var o=i._private;if(!e(i))return!1;if(i.isNode())return!s||Si(i,a);var u=o.source,l=o.target;return t(u)&&(!s||Si(u,t))&&(u===l||t(l)&&(!s||Si(l,t)))}}}var Ut=En("eleTakesUpSpace",function(r){return r.pstyle("display").value==="element"&&r.width()!==0&&(r.isNode()?r.height()!==0:!0)});er.takesUpSpace=xn("takesUpSpace",ki({ok:Ut}));var Wg=En("eleInteractive",function(r){return r.pstyle("events").value==="yes"&&r.pstyle("visibility").value==="visible"&&Ut(r)}),Hg=En("parentInteractive",function(r){return r.pstyle("visibility").value==="visible"&&Ut(r)});er.interactive=xn("interactive",ki({ok:Wg,parentOk:Hg,edgeOkViaNode:Ut})),er.noninteractive=function(){var r=this[0];if(r)return!r.interactive()};var Gg=En("eleVisible",function(r){return r.pstyle("visibility").value==="visible"&&r.pstyle("opacity").pfValue!==0&&Ut(r)}),Ug=Ut;er.visible=xn("visible",ki({ok:Gg,edgeOkViaNode:Ug})),er.hidden=function(){var r=this[0];if(r)return!r.visible()},er.isBundledBezier=xn("isBundledBezier",function(){return this.cy().styleEnabled()?!this.removed()&&this.pstyle("curve-style").value==="bezier"&&this.takesUpSpace():!1}),er.bypass=er.css=er.style,er.renderedCss=er.renderedStyle,er.removeBypass=er.removeCss=er.removeStyle,er.pstyle=er.parsedStyle;var vt={};function Qo(r){return function(){var e=arguments,t=[];if(e.length===2){var a=e[0],n=e[1];this.on(r.event,a,n)}else if(e.length===1&&ze(e[0])){var i=e[0];this.on(r.event,i)}else if(e.length===0||e.length===1&&Re(e[0])){for(var s=e.length===1?e[0]:null,o=0;o<this.length;o++){var u=this[o],l=!r.ableField||u._private[r.ableField],v=u._private[r.field]!=r.value;if(r.overrideAble){var f=r.overrideAble(u);if(f!==void 0&&(l=f,!f))return this}l&&(u._private[r.field]=r.value,v&&t.push(u))}var d=this.spawn(t);d.updateStyle(),d.emit(r.event),s&&d.emit(s)}return this}}function Kt(r){vt[r.field]=function(){var e=this[0];if(e){if(r.overrideField){var t=r.overrideField(e);if(t!==void 0)return t}return e._private[r.field]}},vt[r.on]=Qo({event:r.on,field:r.field,ableField:r.ableField,overrideAble:r.overrideAble,value:!0}),vt[r.off]=Qo({event:r.off,field:r.field,ableField:r.ableField,overrideAble:r.overrideAble,value:!1})}Kt({field:"locked",overrideField:function(e){return e.cy().autolock()?!0:void 0},on:"lock",off:"unlock"}),Kt({field:"grabbable",overrideField:function(e){return e.cy().autoungrabify()||e.pannable()?!1:void 0},on:"grabify",off:"ungrabify"}),Kt({field:"selected",ableField:"selectable",overrideAble:function(e){return e.cy().autounselectify()?!1:void 0},on:"select",off:"unselect"}),Kt({field:"selectable",overrideField:function(e){return e.cy().autounselectify()?!1:void 0},on:"selectify",off:"unselectify"}),vt.deselect=vt.unselect,vt.grabbed=function(){var r=this[0];if(r)return r._private.grabbed},Kt({field:"active",on:"activate",off:"unactivate"}),Kt({field:"pannable",on:"panify",off:"unpanify"}),vt.inactive=function(){var r=this[0];if(r)return!r._private.active};var nr={},Jo=function(e){return function(a){for(var n=this,i=[],s=0;s<n.length;s++){var o=n[s];if(o.isNode()){for(var u=!1,l=o.connectedEdges(),v=0;v<l.length;v++){var f=l[v],d=f.source(),h=f.target();if(e.noIncomingEdges&&h===o&&d!==o||e.noOutgoingEdges&&d===o&&h!==o){u=!0;break}}u||i.push(o)}}return this.spawn(i,!0).filter(a)}},jo=function(e){return function(t){for(var a=this,n=[],i=0;i<a.length;i++){var s=a[i];if(s.isNode())for(var o=s.connectedEdges(),u=0;u<o.length;u++){var l=o[u],v=l.source(),f=l.target();e.outgoing&&v===s?(n.push(l),n.push(f)):e.incoming&&f===s&&(n.push(l),n.push(v))}}return this.spawn(n,!0).filter(t)}},eu=function(e){return function(t){for(var a=this,n=[],i={};;){var s=e.outgoing?a.outgoers():a.incomers();if(s.length===0)break;for(var o=!1,u=0;u<s.length;u++){var l=s[u],v=l.id();i[v]||(i[v]=!0,n.push(l),o=!0)}if(!o)break;a=s}return this.spawn(n,!0).filter(t)}};nr.clearTraversalCache=function(){for(var r=0;r<this.length;r++)this[r]._private.traversalCache=null},ce(nr,{roots:Jo({noIncomingEdges:!0}),leaves:Jo({noOutgoingEdges:!0}),outgoers:Er(jo({outgoing:!0}),"outgoers"),successors:eu({outgoing:!0}),incomers:Er(jo({incoming:!0}),"incomers"),predecessors:eu({incoming:!0})}),ce(nr,{neighborhood:Er(function(r){for(var e=[],t=this.nodes(),a=0;a<t.length;a++)for(var n=t[a],i=n.connectedEdges(),s=0;s<i.length;s++){var o=i[s],u=o.source(),l=o.target(),v=n===u?l:u;v.length>0&&e.push(v[0]),e.push(o[0])}return this.spawn(e,!0).filter(r)},"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),nr.neighbourhood=nr.neighborhood,nr.closedNeighbourhood=nr.closedNeighborhood,nr.openNeighbourhood=nr.openNeighborhood,ce(nr,{source:Er(function(e){var t=this[0],a;return t&&(a=t._private.source||t.cy().collection()),a&&e?a.filter(e):a},"source"),target:Er(function(e){var t=this[0],a;return t&&(a=t._private.target||t.cy().collection()),a&&e?a.filter(e):a},"target"),sources:ru({attr:"source"}),targets:ru({attr:"target"})});function ru(r){return function(t){for(var a=[],n=0;n<this.length;n++){var i=this[n],s=i._private[r.attr];s&&a.push(s)}return this.spawn(a,!0).filter(t)}}ce(nr,{edgesWith:Er(tu(),"edgesWith"),edgesTo:Er(tu({thisIsSrc:!0}),"edgesTo")});function tu(r){return function(t){var a=[],n=this._private.cy,i=r||{};fe(t)&&(t=n.$(t));for(var s=0;s<t.length;s++)for(var o=t[s]._private.edges,u=0;u<o.length;u++){var l=o[u],v=l._private.data,f=this.hasElementWithId(v.source)&&t.hasElementWithId(v.target),d=t.hasElementWithId(v.source)&&this.hasElementWithId(v.target),h=f||d;h&&((i.thisIsSrc||i.thisIsTgt)&&(i.thisIsSrc&&!f||i.thisIsTgt&&!d)||a.push(l))}return this.spawn(a,!0)}}ce(nr,{connectedEdges:Er(function(r){for(var e=[],t=this,a=0;a<t.length;a++){var n=t[a];if(n.isNode())for(var i=n._private.edges,s=0;s<i.length;s++){var o=i[s];e.push(o)}}return this.spawn(e,!0).filter(r)},"connectedEdges"),connectedNodes:Er(function(r){for(var e=[],t=this,a=0;a<t.length;a++){var n=t[a];n.isEdge()&&(e.push(n.source()[0]),e.push(n.target()[0]))}return this.spawn(e,!0).filter(r)},"connectedNodes"),parallelEdges:Er(au(),"parallelEdges"),codirectedEdges:Er(au({codirected:!0}),"codirectedEdges")});function au(r){var e={codirected:!1};return r=ce({},e,r),function(a){for(var n=[],i=this.edges(),s=r,o=0;o<i.length;o++)for(var u=i[o],l=u._private,v=l.source,f=v._private.data.id,d=l.data.target,h=v._private.edges,c=0;c<h.length;c++){var m=h[c],g=m._private.data,p=g.target,y=g.source,w=p===d&&y===f,b=f===p&&d===y;(s.codirected&&w||!s.codirected&&(w||b))&&n.push(m)}return this.spawn(n,!0).filter(a)}}ce(nr,{components:function(e){var t=this,a=t.cy(),n=a.collection(),i=e==null?t.nodes():e.nodes(),s=[];e!=null&&i.empty()&&(i=e.sources());var o=function(v,f){n.merge(v),i.unmerge(v),f.merge(v)};if(i.empty())return t.spawn();var u=function(){var v=a.collection();s.push(v);var f=i[0];o(f,v),t.bfs({directed:!1,roots:f,visit:function(h){return o(h,v)}}),v.forEach(function(d){d.connectedEdges().forEach(function(h){t.has(h)&&v.has(h.source())&&v.has(h.target())&&v.merge(h)})})};do u();while(i.length>0);return s},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),nr.componentsOf=nr.components;var rr=function(e,t){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){Ve("A collection must have a reference to the core");return}var i=new Mr,s=!1;if(!t)t=[];else if(t.length>0&&Se(t[0])&&!ia(t[0])){s=!0;for(var o=[],u=new At,l=0,v=t.length;l<v;l++){var f=t[l];f.data==null&&(f.data={});var d=f.data;if(d.id==null)d.id=Ms();else if(e.hasElementWithId(d.id)||u.has(d.id))continue;var h=new Qa(e,f,!1);o.push(h),u.add(d.id)}t=o}this.length=0;for(var c=0,m=t.length;c<m;c++){var g=t[c][0];if(g!=null){var p=g._private.data.id;(!a||!i.has(p))&&(a&&i.set(p,{index:this.length,ele:g}),this[this.length]=g,this.length++)}}this._private={eles:this,cy:e,get map(){return this.lazyMap==null&&this.rebuildMap(),this.lazyMap},set map(y){this.lazyMap=y},rebuildMap:function(){for(var w=this.lazyMap=new Mr,b=this.eles,k=0;k<b.length;k++){var x=b[k];w.set(x.id(),{index:k,ele:x})}}},a&&(this._private.map=i),s&&!n&&this.restore()},Le=Qa.prototype=rr.prototype=Object.create(Array.prototype);Le.instanceString=function(){return"collection"},Le.spawn=function(r,e){return new rr(this.cy(),r,e)},Le.spawnSelf=function(){return this.spawn(this)},Le.cy=function(){return this._private.cy},Le.renderer=function(){return this._private.cy.renderer()},Le.element=function(){return this[0]},Le.collection=function(){return ds(this)?this:new rr(this._private.cy,[this])},Le.unique=function(){return new rr(this._private.cy,this,!0)},Le.hasElementWithId=function(r){return r=""+r,this._private.map.has(r)},Le.getElementById=function(r){r=""+r;var e=this._private.cy,t=this._private.map.get(r);return t?t.ele:new rr(e)},Le.$id=Le.getElementById,Le.poolIndex=function(){var r=this._private.cy,e=r._private.elements,t=this[0]._private.data.id;return e._private.map.get(t).index},Le.indexOf=function(r){var e=r[0]._private.data.id;return this._private.map.get(e).index},Le.indexOfId=function(r){return r=""+r,this._private.map.get(r).index},Le.json=function(r){var e=this.element(),t=this.cy();if(e==null&&r)return this;if(e!=null){var a=e._private;if(Se(r)){if(t.startBatch(),r.data){e.data(r.data);var n=a.data;if(e.isEdge()){var i=!1,s={},o=r.data.source,u=r.data.target;o!=null&&o!=n.source&&(s.source=""+o,i=!0),u!=null&&u!=n.target&&(s.target=""+u,i=!0),i&&(e=e.move(s))}else{var l="parent"in r.data,v=r.data.parent;l&&(v!=null||n.parent!=null)&&v!=n.parent&&(v===void 0&&(v=null),v!=null&&(v=""+v),e=e.move({parent:v}))}}r.position&&e.position(r.position);var f=function(m,g,p){var y=r[m];y!=null&&y!==a[m]&&(y?e[g]():e[p]())};return f("removed","remove","restore"),f("selected","select","unselect"),f("selectable","selectify","unselectify"),f("locked","lock","unlock"),f("grabbable","grabify","ungrabify"),f("pannable","panify","unpanify"),r.classes!=null&&e.classes(r.classes),t.endBatch(),this}else if(r===void 0){var d={data:Ir(a.data),position:Ir(a.position),group:a.group,removed:a.removed,selected:a.selected,selectable:a.selectable,locked:a.locked,grabbable:a.grabbable,pannable:a.pannable,classes:null};d.classes="";var h=0;return a.classes.forEach(function(c){return d.classes+=h++===0?c:" "+c}),d}}},Le.jsons=function(){for(var r=[],e=0;e<this.length;e++){var t=this[e],a=t.json();r.push(a)}return r},Le.clone=function(){for(var r=this.cy(),e=[],t=0;t<this.length;t++){var a=this[t],n=a.json(),i=new Qa(r,n,!1);e.push(i)}return new rr(r,e)},Le.copy=Le.clone,Le.restore=function(){for(var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t=this,a=t.cy(),n=a._private,i=[],s=[],o,u=0,l=t.length;u<l;u++){var v=t[u];e&&!v.removed()||(v.isNode()?i.push(v):s.push(v))}o=i.concat(s);var f,d=function(){o.splice(f,1),f--};for(f=0;f<o.length;f++){var h=o[f],c=h._private,m=c.data;if(h.clearTraversalCache(),!(!e&&!c.removed)){if(m.id===void 0)m.id=Ms();else if(te(m.id))m.id=""+m.id;else if(Jr(m.id)||!fe(m.id)){Ve("Can not create element with invalid string ID `"+m.id+"`"),d();continue}else if(a.hasElementWithId(m.id)){Ve("Can not create second element with ID `"+m.id+"`"),d();continue}}var g=m.id;if(h.isNode()){var p=c.position;p.x==null&&(p.x=0),p.y==null&&(p.y=0)}if(h.isEdge()){for(var y=h,w=["source","target"],b=w.length,k=!1,x=0;x<b;x++){var E=w[x],T=m[E];te(T)&&(T=m[E]=""+m[E]),T==null||T===""?(Ve("Can not create edge `"+g+"` with unspecified "+E),k=!0):a.hasElementWithId(T)||(Ve("Can not create edge `"+g+"` with nonexistant "+E+" `"+T+"`"),k=!0)}if(k){d();continue}var F=a.getElementById(m.source),S=a.getElementById(m.target);F.same(S)?F._private.edges.push(y):(F._private.edges.push(y),S._private.edges.push(y)),y._private.source=F,y._private.target=S}c.map=new Mr,c.map.set(g,{ele:h,index:0}),c.removed=!1,e&&a.addToPool(h)}for(var D=0;D<i.length;D++){var C=i[D],B=C._private.data;te(B.parent)&&(B.parent=""+B.parent);var A=B.parent,M=A!=null;if(M||C._private.parent){var I=C._private.parent?a.collection().merge(C._private.parent):a.getElementById(A);if(I.empty())B.parent=void 0;else if(I[0].removed())Pe("Node added with missing parent, reference to parent removed"),B.parent=void 0,C._private.parent=null;else{for(var R=!1,L=I;!L.empty();){if(C.same(L)){R=!0,B.parent=void 0;break}L=L.parent()}R||(I[0]._private.children.push(C),C._private.parent=I[0],n.hasCompoundNodes=!0)}}}if(o.length>0){for(var V=o.length===t.length?t:new rr(a,o),H=0;H<V.length;H++){var z=V[H];z.isNode()||(z.parallelEdges().clearTraversalCache(),z.source().clearTraversalCache(),z.target().clearTraversalCache())}var $;n.hasCompoundNodes?$=a.collection().merge(V).merge(V.connectedNodes()).merge(V.parent()):$=V,$.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(r),r?V.emitAndNotify("add"):e&&V.emit("add")}return t},Le.removed=function(){var r=this[0];return r&&r._private.removed},Le.inside=function(){var r=this[0];return r&&!r._private.removed},Le.remove=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t=this,a=[],n={},i=t._private.cy;function s(A){for(var M=A._private.edges,I=0;I<M.length;I++)u(M[I])}function o(A){for(var M=A._private.children,I=0;I<M.length;I++)u(M[I])}function u(A){var M=n[A.id()];e&&A.removed()||M||(n[A.id()]=!0,A.isNode()?(a.push(A),s(A),o(A)):a.unshift(A))}for(var l=0,v=t.length;l<v;l++){var f=t[l];u(f)}function d(A,M){var I=A._private.edges;rt(I,M),A.clearTraversalCache()}function h(A){A.clearTraversalCache()}var c=[];c.ids={};function m(A,M){M=M[0],A=A[0];var I=A._private.children,R=A.id();rt(I,M),M._private.parent=null,c.ids[R]||(c.ids[R]=!0,c.push(A))}t.dirtyCompoundBoundsCache(),e&&i.removeFromPool(a);for(var g=0;g<a.length;g++){var p=a[g];if(p.isEdge()){var y=p.source()[0],w=p.target()[0];d(y,p),d(w,p);for(var b=p.parallelEdges(),k=0;k<b.length;k++){var x=b[k];h(x),x.isBundledBezier()&&x.dirtyBoundingBoxCache()}}else{var E=p.parent();E.length!==0&&m(E,p)}e&&(p._private.removed=!0)}var T=i._private.elements;i._private.hasCompoundNodes=!1;for(var F=0;F<T.length;F++){var S=T[F];if(S.isParent()){i._private.hasCompoundNodes=!0;break}}var D=new rr(this.cy(),a);D.size()>0&&(r?D.emitAndNotify("remove"):e&&D.emit("remove"));for(var C=0;C<c.length;C++){var B=c[C];(!e||!B.removed())&&B.updateStyle()}return D},Le.move=function(r){var e=this._private.cy,t=this,a=!1,n=!1,i=function(c){return c==null?c:""+c};if(r.source!==void 0||r.target!==void 0){var s=i(r.source),o=i(r.target),u=s!=null&&e.hasElementWithId(s),l=o!=null&&e.hasElementWithId(o);(u||l)&&(e.batch(function(){t.remove(a,n),t.emitAndNotify("moveout");for(var h=0;h<t.length;h++){var c=t[h],m=c._private.data;c.isEdge()&&(u&&(m.source=s),l&&(m.target=o))}t.restore(a,n)}),t.emitAndNotify("move"))}else if(r.parent!==void 0){var v=i(r.parent),f=v===null||e.hasElementWithId(v);if(f){var d=v===null?void 0:v;e.batch(function(){var h=t.remove(a,n);h.emitAndNotify("moveout");for(var c=0;c<t.length;c++){var m=t[c],g=m._private.data;m.isNode()&&(g.parent=d)}h.restore(a,n)}),t.emitAndNotify("move")}}return this},[so,ag,hn,ot,Wt,wg,gn,Lg,Ko,Xo,Vg,bn,Fn,er,vt,nr].forEach(function(r){ce(Le,r)});var Kg={add:function(e){var t,a=this;if(yr(e)){var n=e;if(n._private.cy===a)t=n.restore();else{for(var i=[],s=0;s<n.length;s++){var o=n[s];i.push(o.json())}t=new rr(a,i)}}else if(Re(e)){var u=e;t=new rr(a,u)}else if(Se(e)&&(Re(e.nodes)||Re(e.edges))){for(var l=e,v=[],f=["nodes","edges"],d=0,h=f.length;d<h;d++){var c=f[d],m=l[c];if(Re(m))for(var g=0,p=m.length;g<p;g++){var y=ce({group:c},m[g]);v.push(y)}}t=new rr(a,v)}else{var w=e;t=new Qa(a,w).collection()}return t},remove:function(e){if(!yr(e)){if(fe(e)){var t=e;e=this.$(t)}}return e.remove()}};/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */function Xg(r,e,t,a){var n=4,i=.001,s=1e-7,o=10,u=11,l=1/(u-1),v=typeof Float32Array<"u";if(arguments.length!==4)return!1;for(var f=0;f<4;++f)if(typeof arguments[f]!="number"||isNaN(arguments[f])||!isFinite(arguments[f]))return!1;r=Math.min(r,1),t=Math.min(t,1),r=Math.max(r,0),t=Math.max(t,0);var d=v?new Float32Array(u):new Array(u);function h(S,D){return 1-3*D+3*S}function c(S,D){return 3*D-6*S}function m(S){return 3*S}function g(S,D,C){return((h(D,C)*S+c(D,C))*S+m(D))*S}function p(S,D,C){return 3*h(D,C)*S*S+2*c(D,C)*S+m(D)}function y(S,D){for(var C=0;C<n;++C){var B=p(D,r,t);if(B===0)return D;var A=g(D,r,t)-S;D-=A/B}return D}function w(){for(var S=0;S<u;++S)d[S]=g(S*l,r,t)}function b(S,D,C){var B,A,M=0;do A=D+(C-D)/2,B=g(A,r,t)-S,B>0?C=A:D=A;while(Math.abs(B)>s&&++M<o);return A}function k(S){for(var D=0,C=1,B=u-1;C!==B&&d[C]<=S;++C)D+=l;--C;var A=(S-d[C])/(d[C+1]-d[C]),M=D+A*l,I=p(M,r,t);return I>=i?y(S,M):I===0?M:b(S,D,D+l)}var x=!1;function E(){x=!0,(r!==e||t!==a)&&w()}var T=function(D){return x||E(),r===e&&t===a?D:D===0?0:D===1?1:g(k(D),e,a)};T.getControlPoints=function(){return[{x:r,y:e},{x:t,y:a}]};var F="generateBezier("+[r,e,t,a]+")";return T.toString=function(){return F},T}/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var Yg=function(){function r(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:r(s)}}function t(a,n){var i={dx:a.v,dv:r(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),v=1/6*(i.dv+2*(s.dv+o.dv)+u.dv);return a.x=a.x+l*n,a.v=a.v+v*n,a}return function a(n,i,s){var o={x:-1,v:0,tension:null,friction:null},u=[0],l=0,v=1/1e4,f=16/1e3,d,h,c;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),h=l/s*f):h=f;c=t(c||o,h),u.push(1+c.x),l+=16,Math.abs(c.x)>v&&Math.abs(c.v)>v;);return d?function(m){return u[m*(u.length-1)|0]}:l}}(),Oe=function(e,t,a,n){var i=Xg(e,t,a,n);return function(s,o,u){return s+(o-s)*i(u)}},Cn={linear:function(e,t,a){return e+(t-e)*a},ease:Oe(.25,.1,.25,1),"ease-in":Oe(.42,0,1,1),"ease-out":Oe(0,0,.58,1),"ease-in-out":Oe(.42,0,.58,1),"ease-in-sine":Oe(.47,0,.745,.715),"ease-out-sine":Oe(.39,.575,.565,1),"ease-in-out-sine":Oe(.445,.05,.55,.95),"ease-in-quad":Oe(.55,.085,.68,.53),"ease-out-quad":Oe(.25,.46,.45,.94),"ease-in-out-quad":Oe(.455,.03,.515,.955),"ease-in-cubic":Oe(.55,.055,.675,.19),"ease-out-cubic":Oe(.215,.61,.355,1),"ease-in-out-cubic":Oe(.645,.045,.355,1),"ease-in-quart":Oe(.895,.03,.685,.22),"ease-out-quart":Oe(.165,.84,.44,1),"ease-in-out-quart":Oe(.77,0,.175,1),"ease-in-quint":Oe(.755,.05,.855,.06),"ease-out-quint":Oe(.23,1,.32,1),"ease-in-out-quint":Oe(.86,0,.07,1),"ease-in-expo":Oe(.95,.05,.795,.035),"ease-out-expo":Oe(.19,1,.22,1),"ease-in-out-expo":Oe(1,0,0,1),"ease-in-circ":Oe(.6,.04,.98,.335),"ease-out-circ":Oe(.075,.82,.165,1),"ease-in-out-circ":Oe(.785,.135,.15,.86),spring:function(e,t,a){if(a===0)return Cn.linear;var n=Yg(e,t,a);return function(i,s,o){return i+(s-i)*n(o)}},"cubic-bezier":Oe};function nu(r,e,t,a,n){if(a===1||e===t)return t;var i=n(e,t,a);return r==null||((r.roundValue||r.color)&&(i=Math.round(i)),r.min!==void 0&&(i=Math.max(i,r.min)),r.max!==void 0&&(i=Math.min(i,r.max))),i}function iu(r,e){return r.pfValue!=null||r.value!=null?r.pfValue!=null&&(e==null||e.type.units!=="%")?r.pfValue:r.value:r}function Xt(r,e,t,a,n){var i=n!=null?n.type:null;t<0?t=0:t>1&&(t=1);var s=iu(r,n),o=iu(e,n);if(te(s)&&te(o))return nu(i,s,o,t,a);if(Re(s)&&Re(o)){for(var u=[],l=0;l<o.length;l++){var v=s[l],f=o[l];if(v!=null&&f!=null){var d=nu(i,v,f,t,a);u.push(d)}else u.push(f)}return u}}function Zg(r,e,t,a){var n=!a,i=r._private,s=e._private,o=s.easing,u=s.startTime,l=a?r:r.cy(),v=l.style();if(!s.easingImpl)if(o==null)s.easingImpl=Cn.linear;else{var f;if(fe(o)){var d=v.parse("transition-timing-function",o);f=d.value}else f=o;var h,c;fe(f)?(h=f,c=[]):(h=f[1],c=f.slice(2).map(function(V){return+V})),c.length>0?(h==="spring"&&c.push(s.duration),s.easingImpl=Cn[h].apply(null,c)):s.easingImpl=Cn[h]}var m=s.easingImpl,g;if(s.duration===0?g=1:g=(t-u)/s.duration,s.applying&&(g=s.progress),g<0?g=0:g>1&&(g=1),s.delay==null){var p=s.startPosition,y=s.position;if(y&&n&&!r.locked()){var w={};ka(p.x,y.x)&&(w.x=Xt(p.x,y.x,g,m)),ka(p.y,y.y)&&(w.y=Xt(p.y,y.y,g,m)),r.position(w)}var b=s.startPan,k=s.pan,x=i.pan,E=k!=null&&a;E&&(ka(b.x,k.x)&&(x.x=Xt(b.x,k.x,g,m)),ka(b.y,k.y)&&(x.y=Xt(b.y,k.y,g,m)),r.emit("pan"));var T=s.startZoom,F=s.zoom,S=F!=null&&a;S&&(ka(T,F)&&(i.zoom=pa(i.minZoom,Xt(T,F,g,m),i.maxZoom)),r.emit("zoom")),(E||S)&&r.emit("viewport");var D=s.style;if(D&&D.length>0&&n){for(var C=0;C<D.length;C++){var B=D[C],A=B.name,M=B,I=s.startStyle[A],R=v.properties[I.name],L=Xt(I,M,g,m,R);v.overrideBypass(r,A,L)}r.emit("style")}}return s.progress=g,g}function ka(r,e){return r==null||e==null?!1:te(r)&&te(e)?!0:!!(r&&e)}function Qg(r,e,t,a){var n=e._private;n.started=!0,n.startTime=t-n.progress*n.duration}function su(r,e){var t=e._private.aniEles,a=[];function n(v,f){var d=v._private,h=d.animation.current,c=d.animation.queue,m=!1;if(h.length===0){var g=c.shift();g&&h.push(g)}for(var p=function(x){for(var E=x.length-1;E>=0;E--){var T=x[E];T()}x.splice(0,x.length)},y=h.length-1;y>=0;y--){var w=h[y],b=w._private;if(b.stopped){h.splice(y,1),b.hooked=!1,b.playing=!1,b.started=!1,p(b.frames);continue}!b.playing&&!b.applying||(b.playing&&b.applying&&(b.applying=!1),b.started||Qg(v,w,r),Zg(v,w,r,f),b.applying&&(b.applying=!1),p(b.frames),b.step!=null&&b.step(r),w.completed()&&(h.splice(y,1),b.hooked=!1,b.playing=!1,b.started=!1,p(b.completes)),m=!0)}return!f&&h.length===0&&c.length===0&&a.push(v),m}for(var i=!1,s=0;s<t.length;s++){var o=t[s],u=n(o);i=i||u}var l=n(e,!0);(i||l)&&(t.length>0?e.notify("draw",t):e.notify("draw")),t.unmerge(a),e.emit("step")}var Jg={animate:Be.animate(),animation:Be.animation(),animated:Be.animated(),clearQueue:Be.clearQueue(),delay:Be.delay(),delayAnimation:Be.delayAnimation(),stop:Be.stop(),addToAnimationPool:function(e){var t=this;t.styleEnabled()&&t._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,!e.styleEnabled())return;function t(){e._private.animationsRunning&&Xa(function(i){su(i,e),t()})}var a=e.renderer();a&&a.beforeRender?a.beforeRender(function(i,s){su(s,e)},a.beforeRenderPriorities.animations):t()}},jg={qualifierCompare:function(e,t){return e==null||t==null?e==null&&t==null:e.sameText(t)},eventMatches:function(e,t,a){var n=t.qualifier;return n!=null?e!==a.target&&ia(a.target)&&n.matches(a.target):!0},addEventFields:function(e,t){t.cy=e,t.target=e},callbackContext:function(e,t,a){return t.qualifier!=null?a.target:e}},Tn=function(e){return fe(e)?new it(e):e},ou={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new yn(jg,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,a){return this.emitter().on(e,Tn(t),a),this},removeListener:function(e,t,a){return this.emitter().removeListener(e,Tn(t),a),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,a){return this.emitter().one(e,Tn(t),a),this},once:function(e,t,a){return this.emitter().one(e,Tn(t),a),this},emit:function(e,t){return this.emitter().emit(e,t),this},emitAndNotify:function(e,t){return this.emit(e),this.notify(e,t),this}};Be.eventAliasesOn(ou);var Di={png:function(e){var t=this._private.renderer;return e=e||{},t.png(e)},jpg:function(e){var t=this._private.renderer;return e=e||{},e.bg=e.bg||"#fff",t.jpg(e)}};Di.jpeg=Di.jpg;var Sn={layout:function(e){var t=this;if(e==null){Ve("Layout options must be specified to make a layout");return}if(e.name==null){Ve("A `name` must be specified to make a layout");return}var a=e.name,n=t.extension("layout",a);if(n==null){Ve("No such layout `"+a+"` found.  Did you forget to import it and `cytoscape.use()` it?");return}var i;fe(e.eles)?i=t.$(e.eles):i=e.eles!=null?e.eles:t.$();var s=new n(ce({},e,{cy:t,eles:i}));return s}};Sn.createLayout=Sn.makeLayout=Sn.layout;var e0={notify:function(e,t){var a=this._private;if(this.batching()){a.batchNotifications=a.batchNotifications||{};var n=a.batchNotifications[e]=a.batchNotifications[e]||this.collection();t!=null&&n.merge(t);return}if(a.notificationsEnabled){var i=this.renderer();this.destroyed()||!i||i.notify(e,t)}},notifications:function(e){var t=this._private;return e===void 0?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var e=this._private;return 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 t=this.renderer();Object.keys(e.batchNotifications).forEach(function(a){var n=e.batchNotifications[a];n.empty()?t.notify(a):t.notify(a,n)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var t=this;return this.batch(function(){for(var a=Object.keys(e),n=0;n<a.length;n++){var i=a[n],s=e[i],o=t.getElementById(i);o.data(s)}})}},r0=Ye({hideEdgesOnViewport:!1,textureOnViewport:!1,motionBlur:!1,motionBlurOpacity:.05,pixelRatio:void 0,desktopTapThreshold:4,touchTapThreshold:8,wheelSensitivity:1,debug:!1,showFps:!1,webgl:!1,webglDebug:!1,webglDebugShowAtlases:!1,webglTexSize:2048,webglTexRows:12,webglBatchSize:2048,webglTexPerBatch:14,webglBgColor:[255,255,255]}),Pi={renderTo:function(e,t,a,n){var i=this._private.renderer;return i.renderTo(e,t,a,n),this},renderer:function(){return this._private.renderer},forceRender:function(){return this.notify("draw"),this},resize:function(){return this.invalidateSize(),this.emitAndNotify("resize"),this},initRenderer:function(e){var t=this,a=t.extension("renderer",e.name);if(a==null){Ve("Can not initialise: No such renderer `".concat(e.name,"` found. Did you forget to import it and `cytoscape.use()` it?"));return}e.wheelSensitivity!==void 0&&Pe("You have set a custom wheel sensitivity.  This will make your app zoom unnaturally when using mainstream mice.  You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.");var n=r0(e);n.cy=t,t._private.renderer=new a(n),this.notify("init")},destroyRenderer:function(){var e=this;e.notify("destroy");var t=e.container();if(t)for(t._cyreg=null;t.childNodes.length>0;)t.removeChild(t.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)}};Pi.invalidateDimensions=Pi.resize;var kn={collection:function(e,t){return fe(e)?this.$(e):yr(e)?e.collection():Re(e)?(t||(t={}),new rr(this,e,t.unique,t.removed)):new rr(this)},nodes:function(e){var t=this.$(function(a){return a.isNode()});return e?t.filter(e):t},edges:function(e){var t=this.$(function(a){return a.isEdge()});return e?t.filter(e):t},$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};kn.elements=kn.filter=kn.$;var ir={},Da="t",t0="f";ir.apply=function(r){for(var e=this,t=e._private,a=t.cy,n=a.collection(),i=0;i<r.length;i++){var s=r[i],o=e.getContextMeta(s);if(!o.empty){var u=e.getContextStyle(o),l=e.applyContextStyle(o,u,s);s._private.appliedInitStyle?e.updateTransitions(s,l.diffProps):s._private.appliedInitStyle=!0;var v=e.updateStyleHints(s);v&&n.push(s)}}return n},ir.getPropertiesDiff=function(r,e){var t=this,a=t._private.propDiffs=t._private.propDiffs||{},n=r+"-"+e,i=a[n];if(i)return i;for(var s=[],o={},u=0;u<t.length;u++){var l=t[u],v=r[u]===Da,f=e[u]===Da,d=v!==f,h=l.mappedProperties.length>0;if(d||f&&h){var c=void 0;d&&h||d?c=l.properties:h&&(c=l.mappedProperties);for(var m=0;m<c.length;m++){for(var g=c[m],p=g.name,y=!1,w=u+1;w<t.length;w++){var b=t[w],k=e[w]===Da;if(k&&(y=b.properties[g.name]!=null,y))break}!o[p]&&!y&&(o[p]=!0,s.push(p))}}}return a[n]=s,s},ir.getContextMeta=function(r){for(var e=this,t="",a,n=r._private.styleCxtKey||"",i=0;i<e.length;i++){var s=e[i],o=s.selector&&s.selector.matches(r);o?t+=Da:t+=t0}return a=e.getPropertiesDiff(n,t),r._private.styleCxtKey=t,{key:t,diffPropNames:a,empty:a.length===0}},ir.getContextStyle=function(r){var e=r.key,t=this,a=this._private.contextStyles=this._private.contextStyles||{};if(a[e])return a[e];for(var n={_private:{key:e}},i=0;i<t.length;i++){var s=t[i],o=e[i]===Da;if(o)for(var u=0;u<s.properties.length;u++){var l=s.properties[u];n[l.name]=l}}return a[e]=n,n},ir.applyContextStyle=function(r,e,t){for(var a=this,n=r.diffPropNames,i={},s=a.types,o=0;o<n.length;o++){var u=n[o],l=e[u],v=t.pstyle(u);if(!l)if(v)v.bypass?l={name:u,deleteBypassed:!0}:l={name:u,delete:!0};else continue;if(v!==l){if(l.mapped===s.fn&&v!=null&&v.mapping!=null&&v.mapping.value===l.value){var f=v.mapping,d=f.fnValue=l.value(t);if(d===f.prevFnValue)continue}var h=i[u]={prev:v};a.applyParsedProperty(t,l),h.next=t.pstyle(u),h.next&&h.next.bypass&&(h.next=h.next.bypassed)}}return{diffProps:i}},ir.updateStyleHints=function(r){var e=r._private,t=this,a=t.propertyGroupNames,n=t.propertyGroupKeys,i=function(G,ee,ie){return t.getPropertiesHash(G,ee,ie)},s=e.styleKey;if(r.removed())return!1;var o=e.group==="nodes",u=r._private.style;a=Object.keys(u);for(var l=0;l<n.length;l++){var v=n[l];e.styleKeys[v]=[Bt,fa]}for(var f=function(G,ee){return e.styleKeys[ee][0]=da(G,e.styleKeys[ee][0])},d=function(G,ee){return e.styleKeys[ee][1]=ca(G,e.styleKeys[ee][1])},h=function(G,ee){f(G,ee),d(G,ee)},c=function(G,ee){for(var ie=0;ie<G.length;ie++){var ue=G.charCodeAt(ie);f(ue,ee),d(ue,ee)}},m=2e9,g=function(G){return-128<G&&G<128&&Math.floor(G)!==G?m-(G*1024|0):G},p=0;p<a.length;p++){var y=a[p],w=u[y];if(w!=null){var b=this.properties[y],k=b.type,x=b.groupKey,E=void 0;b.hashOverride!=null?E=b.hashOverride(r,w):w.pfValue!=null&&(E=w.pfValue);var T=b.enums==null?w.value:null,F=E!=null,S=T!=null,D=F||S,C=w.units;if(k.number&&D&&!k.multiple){var B=F?E:T;h(g(B),x),!F&&C!=null&&c(C,x)}else c(w.strValue,x)}}for(var A=[Bt,fa],M=0;M<n.length;M++){var I=n[M],R=e.styleKeys[I];A[0]=da(R[0],A[0]),A[1]=ca(R[1],A[1])}e.styleKey=of(A[0],A[1]);var L=e.styleKeys;e.labelDimsKey=jr(L.labelDimensions);var V=i(r,["label"],L.labelDimensions);if(e.labelKey=jr(V),e.labelStyleKey=jr(Ya(L.commonLabel,V)),!o){var H=i(r,["source-label"],L.labelDimensions);e.sourceLabelKey=jr(H),e.sourceLabelStyleKey=jr(Ya(L.commonLabel,H));var z=i(r,["target-label"],L.labelDimensions);e.targetLabelKey=jr(z),e.targetLabelStyleKey=jr(Ya(L.commonLabel,z))}if(o){var $=e.styleKeys,K=$.nodeBody,Y=$.nodeBorder,Q=$.nodeOutline,Z=$.backgroundImage,j=$.compound,re=$.pie,W=[K,Y,Q,Z,j,re].filter(function(O){return O!=null}).reduce(Ya,[Bt,fa]);e.nodeKey=jr(W),e.hasPie=re!=null&&re[0]!==Bt&&re[1]!==fa}return s!==e.styleKey},ir.clearStyleHints=function(r){var e=r._private;e.styleCxtKey="",e.styleKeys={},e.styleKey=null,e.labelKey=null,e.labelStyleKey=null,e.sourceLabelKey=null,e.sourceLabelStyleKey=null,e.targetLabelKey=null,e.targetLabelStyleKey=null,e.nodeKey=null,e.hasPie=null},ir.applyParsedProperty=function(r,e){var t=this,a=e,n=r._private.style,i,s=t.types,o=t.properties[a.name].type,u=a.bypass,l=n[a.name],v=l&&l.bypass,f=r._private,d="mapping",h=function(K){return K==null?null:K.pfValue!=null?K.pfValue:K.value},c=function(){var K=h(l),Y=h(a);t.checkTriggers(r,a.name,K,Y)};if(e.name==="curve-style"&&r.isEdge()&&(e.value!=="bezier"&&r.isLoop()||e.value==="haystack"&&(r.source().isParent()||r.target().isParent()))&&(a=e=this.parse(e.name,"bezier",u)),a.delete)return n[a.name]=void 0,c(),!0;if(a.deleteBypassed)return l?l.bypass?(l.bypassed=void 0,c(),!0):!1:(c(),!0);if(a.deleteBypass)return l?l.bypass?(n[a.name]=l.bypassed,c(),!0):!1:(c(),!0);var m=function(){Pe("Do not assign mappings to elements without corresponding data (i.e. ele `"+r.id()+"` has no mapping for property `"+a.name+"` with data field `"+a.field+"`); try a `["+a.field+"]` selector to limit scope to elements with `"+a.field+"` defined")};switch(a.mapped){case s.mapData:{for(var g=a.field.split("."),p=f.data,y=0;y<g.length&&p;y++){var w=g[y];p=p[w]}if(p==null)return m(),!1;var b;if(te(p)){var k=a.fieldMax-a.fieldMin;k===0?b=0:b=(p-a.fieldMin)/k}else return Pe("Do not use continuous mappers without specifying numeric data (i.e. `"+a.field+": "+p+"` for `"+r.id()+"` is non-numeric)"),!1;if(b<0?b=0:b>1&&(b=1),o.color){var x=a.valueMin[0],E=a.valueMax[0],T=a.valueMin[1],F=a.valueMax[1],S=a.valueMin[2],D=a.valueMax[2],C=a.valueMin[3]==null?1:a.valueMin[3],B=a.valueMax[3]==null?1:a.valueMax[3],A=[Math.round(x+(E-x)*b),Math.round(T+(F-T)*b),Math.round(S+(D-S)*b),Math.round(C+(B-C)*b)];i={bypass:a.bypass,name:a.name,value:A,strValue:"rgb("+A[0]+", "+A[1]+", "+A[2]+")"}}else if(o.number){var M=a.valueMin+(a.valueMax-a.valueMin)*b;i=this.parse(a.name,M,a.bypass,d)}else return!1;if(!i)return m(),!1;i.mapping=a,a=i;break}case s.data:{for(var I=a.field.split("."),R=f.data,L=0;L<I.length&&R;L++){var V=I[L];R=R[V]}if(R!=null&&(i=this.parse(a.name,R,a.bypass,d)),!i)return m(),!1;i.mapping=a,a=i;break}case s.fn:{var H=a.value,z=a.fnValue!=null?a.fnValue:H(r);if(a.prevFnValue=z,z==null)return Pe("Custom function mappers may not return null (i.e. `"+a.name+"` for ele `"+r.id()+"` is null)"),!1;if(i=this.parse(a.name,z,a.bypass,d),!i)return Pe("Custom function mappers may not return invalid values for the property type (i.e. `"+a.name+"` for ele `"+r.id()+"` is invalid)"),!1;i.mapping=Ir(a),a=i;break}case void 0:break;default:return!1}return u?(v?a.bypassed=l.bypassed:a.bypassed=l,n[a.name]=a):v?l.bypassed=a:n[a.name]=a,c(),!0},ir.cleanElements=function(r,e){for(var t=0;t<r.length;t++){var a=r[t];if(this.clearStyleHints(a),a.dirtyCompoundBoundsCache(),a.dirtyBoundingBoxCache(),!e)a._private.style={};else for(var n=a._private.style,i=Object.keys(n),s=0;s<i.length;s++){var o=i[s],u=n[o];u!=null&&(u.bypass?u.bypassed=null:n[o]=null)}}},ir.update=function(){var r=this._private.cy,e=r.mutableElements();e.updateStyle()},ir.updateTransitions=function(r,e){var t=this,a=r._private,n=r.pstyle("transition-property").value,i=r.pstyle("transition-duration").pfValue,s=r.pstyle("transition-delay").pfValue;if(n.length>0&&i>0){for(var o={},u=!1,l=0;l<n.length;l++){var v=n[l],f=r.pstyle(v),d=e[v];if(d){var h=d.prev,c=h,m=d.next!=null?d.next:f,g=!1,p=void 0,y=1e-6;c&&(te(c.pfValue)&&te(m.pfValue)?(g=m.pfValue-c.pfValue,p=c.pfValue+y*g):te(c.value)&&te(m.value)?(g=m.value-c.value,p=c.value+y*g):Re(c.value)&&Re(m.value)&&(g=c.value[0]!==m.value[0]||c.value[1]!==m.value[1]||c.value[2]!==m.value[2],p=c.strValue),g&&(o[v]=m.strValue,this.applyBypass(r,v,p),u=!0))}}if(!u)return;a.transitioning=!0,new Nt(function(w){s>0?r.delayAnimation(s).play().promise().then(w):w()}).then(function(){return r.animation({style:o,duration:i,easing:r.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){t.removeBypasses(r,n),r.emitAndNotify("style"),a.transitioning=!1})}else a.transitioning&&(this.removeBypasses(r,n),r.emitAndNotify("style"),a.transitioning=!1)},ir.checkTrigger=function(r,e,t,a,n,i){var s=this.properties[e],o=n(s);o!=null&&o(t,a)&&i(s)},ir.checkZOrderTrigger=function(r,e,t,a){var n=this;this.checkTrigger(r,e,t,a,function(i){return i.triggersZOrder},function(){n._private.cy.notify("zorder",r)})},ir.checkBoundsTrigger=function(r,e,t,a){this.checkTrigger(r,e,t,a,function(n){return n.triggersBounds},function(n){r.dirtyCompoundBoundsCache(),r.dirtyBoundingBoxCache(),n.triggersBoundsOfParallelBeziers&&e==="curve-style"&&(t==="bezier"||a==="bezier")&&r.parallelEdges().forEach(function(i){i.dirtyBoundingBoxCache()}),n.triggersBoundsOfConnectedEdges&&e==="display"&&(t==="none"||a==="none")&&r.connectedEdges().forEach(function(i){i.dirtyBoundingBoxCache()})})},ir.checkTriggers=function(r,e,t,a){r.dirtyStyleCache(),this.checkZOrderTrigger(r,e,t,a),this.checkBoundsTrigger(r,e,t,a)};var Pa={};Pa.applyBypass=function(r,e,t,a){var n=this,i=[],s=!0;if(e==="*"||e==="**"){if(t!==void 0)for(var o=0;o<n.properties.length;o++){var u=n.properties[o],l=u.name,v=this.parse(l,t,!0);v&&i.push(v)}}else if(fe(e)){var f=this.parse(e,t,!0);f&&i.push(f)}else if(Se(e)){var d=e;a=t;for(var h=Object.keys(d),c=0;c<h.length;c++){var m=h[c],g=d[m];if(g===void 0&&(g=d[Ua(m)]),g!==void 0){var p=this.parse(m,g,!0);p&&i.push(p)}}}else return!1;if(i.length===0)return!1;for(var y=!1,w=0;w<r.length;w++){for(var b=r[w],k={},x=void 0,E=0;E<i.length;E++){var T=i[E];if(a){var F=b.pstyle(T.name);x=k[T.name]={prev:F}}y=this.applyParsedProperty(b,Ir(T))||y,a&&(x.next=b.pstyle(T.name))}y&&this.updateStyleHints(b),a&&this.updateTransitions(b,k,s)}return y},Pa.overrideBypass=function(r,e,t){e=jn(e);for(var a=0;a<r.length;a++){var n=r[a],i=n._private.style[e],s=this.properties[e].type,o=s.color,u=s.mutiple,l=i?i.pfValue!=null?i.pfValue:i.value:null;!i||!i.bypass?this.applyBypass(n,e,t):(i.value=t,i.pfValue!=null&&(i.pfValue=t),o?i.strValue="rgb("+t.join(",")+")":u?i.strValue=t.join(" "):i.strValue=""+t,this.updateStyleHints(n)),this.checkTriggers(n,e,l,t)}},Pa.removeAllBypasses=function(r,e){return this.removeBypasses(r,this.propertyNames,e)},Pa.removeBypasses=function(r,e,t){for(var a=!0,n=0;n<r.length;n++){for(var i=r[n],s={},o=0;o<e.length;o++){var u=e[o],l=this.properties[u],v=i.pstyle(l.name);if(!(!v||!v.bypass)){var f="",d=this.parse(u,f,!0),h=s[l.name]={prev:v};this.applyParsedProperty(i,d),h.next=i.pstyle(l.name)}}this.updateStyleHints(i),t&&this.updateTransitions(i,s,a)}};var Bi={};Bi.getEmSizeInPixels=function(){var r=this.containerCss("font-size");return r!=null?parseFloat(r):1},Bi.containerCss=function(r){var e=this._private.cy,t=e.container(),a=e.window();if(a&&t&&a.getComputedStyle)return a.getComputedStyle(t).getPropertyValue(r)};var Rr={};Rr.getRenderedStyle=function(r,e){return e?this.getStylePropertyValue(r,e,!0):this.getRawStyle(r,!0)},Rr.getRawStyle=function(r,e){var t=this;if(r=r[0],r){for(var a={},n=0;n<t.properties.length;n++){var i=t.properties[n],s=t.getStylePropertyValue(r,i.name,e);s!=null&&(a[i.name]=s,a[Ua(i.name)]=s)}return a}},Rr.getIndexedStyle=function(r,e,t,a){var n=r.pstyle(e)[t][a];return n??r.cy().style().getDefaultProperty(e)[t][0]},Rr.getStylePropertyValue=function(r,e,t){var a=this;if(r=r[0],r){var n=a.properties[e];n.alias&&(n=n.pointsTo);var i=n.type,s=r.pstyle(n.name);if(s){var o=s.value,u=s.units,l=s.strValue;if(t&&i.number&&o!=null&&te(o)){var v=r.cy().zoom(),f=function(g){return g*v},d=function(g,p){return f(g)+p},h=Re(o),c=h?u.every(function(m){return m!=null}):u!=null;return c?h?o.map(function(m,g){return d(m,u[g])}).join(" "):d(o,u):h?o.map(function(m){return fe(m)?m:""+f(m)}).join(" "):""+f(o)}else if(l!=null)return l}return null}},Rr.getAnimationStartStyle=function(r,e){for(var t={},a=0;a<e.length;a++){var n=e[a],i=n.name,s=r.pstyle(i);s!==void 0&&(Se(s)?s=this.parse(i,s.strValue):s=this.parse(i,s)),s&&(t[i]=s)}return t},Rr.getPropsList=function(r){var e=this,t=[],a=r,n=e.properties;if(a)for(var i=Object.keys(a),s=0;s<i.length;s++){var o=i[s],u=a[o],l=n[o]||n[jn(o)],v=this.parse(l.name,u);v&&t.push(v)}return t},Rr.getNonDefaultPropertiesHash=function(r,e,t){var a=t.slice(),n,i,s,o,u,l;for(u=0;u<e.length;u++)if(n=e[u],i=r.pstyle(n,!1),i!=null)if(i.pfValue!=null)a[0]=da(o,a[0]),a[1]=ca(o,a[1]);else for(s=i.strValue,l=0;l<s.length;l++)o=s.charCodeAt(l),a[0]=da(o,a[0]),a[1]=ca(o,a[1]);return a},Rr.getPropertiesHash=Rr.getNonDefaultPropertiesHash;var Dn={};Dn.appendFromJson=function(r){for(var e=this,t=0;t<r.length;t++){var a=r[t],n=a.selector,i=a.style||a.css,s=Object.keys(i);e.selector(n);for(var o=0;o<s.length;o++){var u=s[o],l=i[u];e.css(u,l)}}return e},Dn.fromJson=function(r){var e=this;return e.resetToDefault(),e.appendFromJson(r),e},Dn.json=function(){for(var r=[],e=this.defaultLength;e<this.length;e++){for(var t=this[e],a=t.selector,n=t.properties,i={},s=0;s<n.length;s++){var o=n[s];i[o.name]=o.strValue}r.push({selector:a?a.toString():"core",style:i})}return r};var Ai={};Ai.appendFromString=function(r){var e=this,t=this,a=""+r,n,i,s;a=a.replace(/[/][*](\s|.)+?[*][/]/g,"");function o(){a.length>n.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 v=a.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!v){Pe("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+a);break}n=v[0];var f=v[1];if(f!=="core"){var d=new it(f);if(d.invalid){Pe("Skipping parsing of block: Invalid selector found in string stylesheet: "+f),o();continue}}var h=v[2],c=!1;i=h;for(var m=[];;){var g=i.match(/^\s*$/);if(g)break;var p=i.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!p){Pe("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+h),c=!0;break}s=p[0];var y=p[1],w=p[2],b=e.properties[y];if(!b){Pe("Skipping property: Invalid property name in: "+s),u();continue}var k=t.parse(y,w);if(!k){Pe("Skipping property: Invalid property definition in: "+s),u();continue}m.push({name:y,val:w}),u()}if(c){o();break}t.selector(f);for(var x=0;x<m.length;x++){var E=m[x];t.css(E.name,E.val)}o()}return t},Ai.fromString=function(r){var e=this;return e.resetToDefault(),e.appendFromString(r),e};var tr={};(function(){var r=Ue,e=vv,t=dv,a=cv,n=hv,i=function(W){return"^"+W+"\\s*\\(\\s*([\\w\\.]+)\\s*\\)$"},s=function(W){var O=r+"|\\w+|"+e+"|"+t+"|"+a+"|"+n;return"^"+W+"\\s*\\(([\\w\\.]+)\\s*\\,\\s*("+r+")\\s*\\,\\s*("+r+")\\s*,\\s*("+O+")\\s*\\,\\s*("+O+")\\)$"},o=[`^url\\s*\\(\\s*['"]?(.+?)['"]?\\s*\\)$`,"^(none)$","^(.+)$"];tr.types={time:{number:!0,min:0,units:"s|ms",implicitUnits:"ms"},percent:{number:!0,min:0,max:100,units:"%",implicitUnits:"%"},percentages:{number:!0,min:0,max:100,units:"%",implicitUnits:"%",multiple:!0},zeroOneNumber:{number:!0,min:0,max:1,unitless:!0},zeroOneNumbers:{number:!0,min:0,max:1,unitless:!0,multiple:!0},nOneOneNumber:{number:!0,min:-1,max:1,unitless:!0},nonNegativeInt:{number:!0,min:0,integer:!0,unitless:!0},nonNegativeNumber:{number:!0,min:0,unitless:!0},position:{enums:["parent","origin"]},nodeSize:{number:!0,min:0,enums:["label"]},number:{number:!0,unitless:!0},numbers:{number:!0,unitless:!0,multiple:!0},positiveNumber:{number:!0,unitless:!0,min:0,strictMin:!0},size:{number:!0,min:0},bidirectionalSize:{number:!0},bidirectionalSizeMaybePercent:{number:!0,allowPercent:!0},bidirectionalSizes:{number:!0,multiple:!0},sizeMaybePercent:{number:!0,min:0,allowPercent:!0},axisDirection:{enums:["horizontal","leftward","rightward","vertical","upward","downward","auto"]},paddingRelativeTo:{enums:["width","height","average","min","max"]},bgWH:{number:!0,min:0,allowPercent:!0,enums:["auto"],multiple:!0},bgPos:{number:!0,allowPercent:!0,multiple:!0},bgRelativeTo:{enums:["inner","include-padding"],multiple:!0},bgRepeat:{enums:["repeat","repeat-x","repeat-y","no-repeat"],multiple:!0},bgFit:{enums:["none","contain","cover"],multiple:!0},bgCrossOrigin:{enums:["anonymous","use-credentials","null"],multiple:!0},bgClip:{enums:["none","node"],multiple:!0},bgContainment:{enums:["inside","over"],multiple:!0},color:{color:!0},colors:{color:!0,multiple:!0},fill:{enums:["solid","linear-gradient","radial-gradient"]},bool:{enums:["yes","no"]},bools:{enums:["yes","no"],multiple:!0},lineStyle:{enums:["solid","dotted","dashed"]},lineCap:{enums:["butt","round","square"]},linePosition:{enums:["center","inside","outside"]},lineJoin:{enums:["round","bevel","miter"]},borderStyle:{enums:["solid","dotted","dashed","double"]},curveStyle:{enums:["bezier","unbundled-bezier","haystack","segments","straight","straight-triangle","taxi","round-segments","round-taxi"]},radiusType:{enums:["arc-radius","influence-radius"],multiple:!0},fontFamily:{regex:'^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$'},fontStyle:{enums:["italic","normal","oblique"]},fontWeight:{enums:["normal","bold","bolder","lighter","100","200","300","400","500","600","800","900",100,200,300,400,500,600,700,800,900]},textDecoration:{enums:["none","underline","overline","line-through"]},textTransform:{enums:["none","uppercase","lowercase"]},textWrap:{enums:["none","wrap","ellipsis"]},textOverflowWrap:{enums:["whitespace","anywhere"]},textBackgroundShape:{enums:["rectangle","roundrectangle","round-rectangle"]},nodeShape:{enums:["rectangle","roundrectangle","round-rectangle","cutrectangle","cut-rectangle","bottomroundrectangle","bottom-round-rectangle","barrel","ellipse","triangle","round-triangle","square","pentagon","round-pentagon","hexagon","round-hexagon","concavehexagon","concave-hexagon","heptagon","round-heptagon","octagon","round-octagon","tag","round-tag","star","diamond","round-diamond","vee","rhomboid","right-rhomboid","polygon"]},overlayShape:{enums:["roundrectangle","round-rectangle","ellipse"]},cornerRadius:{number:!0,min:0,units:"px|em",implicitUnits:"px",enums:["auto"]},compoundIncludeLabels:{enums:["include","exclude"]},arrowShape:{enums:["tee","triangle","triangle-tee","circle-triangle","triangle-cross","triangle-backcurve","vee","square","circle","diamond","chevron","none"]},arrowFill:{enums:["filled","hollow"]},arrowWidth:{number:!0,units:"%|px|em",implicitUnits:"px",enums:["match-line"]},display:{enums:["element","none"]},visibility:{enums:["hidden","visible"]},zCompoundDepth:{enums:["bottom","orphan","auto","top"]},zIndexCompare:{enums:["auto","manual"]},valign:{enums:["top","center","bottom"]},halign:{enums:["left","center","right"]},justification:{enums:["left","center","right","auto"]},text:{string:!0},data:{mapping:!0,regex:i("data")},layoutData:{mapping:!0,regex:i("layoutData")},scratch:{mapping:!0,regex:i("scratch")},mapData:{mapping:!0,regex:s("mapData")},mapLayoutData:{mapping:!0,regex:s("mapLayoutData")},mapScratch:{mapping:!0,regex:s("mapScratch")},fn:{mapping:!0,fn:!0},url:{regexes:o,singleRegexMatchValue:!0},urls:{regexes:o,singleRegexMatchValue:!0,multiple:!0},propList:{propList:!0},angle:{number:!0,units:"deg|rad",implicitUnits:"rad"},textRotation:{number:!0,units:"deg|rad",implicitUnits:"rad",enums:["none","autorotate"]},polygonPointList:{number:!0,multiple:!0,evenMultiple:!0,min:-1,max:1,unitless:!0},edgeDistances:{enums:["intersection","node-position","endpoints"]},edgeEndpoint:{number:!0,multiple:!0,units:"%|px|em|deg|rad",implicitUnits:"px",enums:["inside-to-node","outside-to-node","outside-to-node-or-label","outside-to-line","outside-to-line-or-label"],singleEnum:!0,validate:function(W,O){switch(W.length){case 2:return O[0]!=="deg"&&O[0]!=="rad"&&O[1]!=="deg"&&O[1]!=="rad";case 1:return fe(W[0])||O[0]==="deg"||O[0]==="rad";default:return!1}}},easing:{regexes:["^(spring)\\s*\\(\\s*("+r+")\\s*,\\s*("+r+")\\s*\\)$","^(cubic-bezier)\\s*\\(\\s*("+r+")\\s*,\\s*("+r+")\\s*,\\s*("+r+")\\s*,\\s*("+r+")\\s*\\)$"],enums:["linear","ease","ease-in","ease-out","ease-in-out","ease-in-sine","ease-out-sine","ease-in-out-sine","ease-in-quad","ease-out-quad","ease-in-out-quad","ease-in-cubic","ease-out-cubic","ease-in-out-cubic","ease-in-quart","ease-out-quart","ease-in-out-quart","ease-in-quint","ease-out-quint","ease-in-out-quint","ease-in-expo","ease-out-expo","ease-in-out-expo","ease-in-circ","ease-out-circ","ease-in-out-circ"]},gradientDirection:{enums:["to-bottom","to-top","to-left","to-right","to-bottom-right","to-bottom-left","to-top-right","to-top-left","to-right-bottom","to-left-bottom","to-right-top","to-left-top"]},boundsExpansion:{number:!0,multiple:!0,min:0,validate:function(W){var O=W.length;return O===1||O===2||O===4}}};var u={zeroNonZero:function(W,O){return(W==null||O==null)&&W!==O||W==0&&O!=0?!0:W!=0&&O==0},any:function(W,O){return W!=O},emptyNonEmpty:function(W,O){var G=Jr(W),ee=Jr(O);return G&&!ee||!G&&ee}},l=tr.types,v=[{name:"label",type:l.text,triggersBounds:u.any,triggersZOrder:u.emptyNonEmpty},{name:"text-rotation",type:l.textRotation,triggersBounds:u.any},{name:"text-margin-x",type:l.bidirectionalSize,triggersBounds:u.any},{name:"text-margin-y",type:l.bidirectionalSize,triggersBounds:u.any}],f=[{name:"source-label",type:l.text,triggersBounds:u.any},{name:"source-text-rotation",type:l.textRotation,triggersBounds:u.any},{name:"source-text-margin-x",type:l.bidirectionalSize,triggersBounds:u.any},{name:"source-text-margin-y",type:l.bidirectionalSize,triggersBounds:u.any},{name:"source-text-offset",type:l.size,triggersBounds:u.any}],d=[{name:"target-label",type:l.text,triggersBounds:u.any},{name:"target-text-rotation",type:l.textRotation,triggersBounds:u.any},{name:"target-text-margin-x",type:l.bidirectionalSize,triggersBounds:u.any},{name:"target-text-margin-y",type:l.bidirectionalSize,triggersBounds:u.any},{name:"target-text-offset",type:l.size,triggersBounds:u.any}],h=[{name:"font-family",type:l.fontFamily,triggersBounds:u.any},{name:"font-style",type:l.fontStyle,triggersBounds:u.any},{name:"font-weight",type:l.fontWeight,triggersBounds:u.any},{name:"font-size",type:l.size,triggersBounds:u.any},{name:"text-transform",type:l.textTransform,triggersBounds:u.any},{name:"text-wrap",type:l.textWrap,triggersBounds:u.any},{name:"text-overflow-wrap",type:l.textOverflowWrap,triggersBounds:u.any},{name:"text-max-width",type:l.size,triggersBounds:u.any},{name:"text-outline-width",type:l.size,triggersBounds:u.any},{name:"line-height",type:l.positiveNumber,triggersBounds:u.any}],c=[{name:"text-valign",type:l.valign,triggersBounds:u.any},{name:"text-halign",type:l.halign,triggersBounds:u.any},{name:"color",type:l.color},{name:"text-outline-color",type:l.color},{name:"text-outline-opacity",type:l.zeroOneNumber},{name:"text-background-color",type:l.color},{name:"text-background-opacity",type:l.zeroOneNumber},{name:"text-background-padding",type:l.size,triggersBounds:u.any},{name:"text-border-opacity",type:l.zeroOneNumber},{name:"text-border-color",type:l.color},{name:"text-border-width",type:l.size,triggersBounds:u.any},{name:"text-border-style",type:l.borderStyle,triggersBounds:u.any},{name:"text-background-shape",type:l.textBackgroundShape,triggersBounds:u.any},{name:"text-justification",type:l.justification}],m=[{name:"events",type:l.bool,triggersZOrder:u.any},{name:"text-events",type:l.bool,triggersZOrder:u.any}],g=[{name:"display",type:l.display,triggersZOrder:u.any,triggersBounds:u.any,triggersBoundsOfConnectedEdges:!0},{name:"visibility",type:l.visibility,triggersZOrder:u.any},{name:"opacity",type:l.zeroOneNumber,triggersZOrder:u.zeroNonZero},{name:"text-opacity",type:l.zeroOneNumber},{name:"min-zoomed-font-size",type:l.size},{name:"z-compound-depth",type:l.zCompoundDepth,triggersZOrder:u.any},{name:"z-index-compare",type:l.zIndexCompare,triggersZOrder:u.any},{name:"z-index",type:l.number,triggersZOrder:u.any}],p=[{name:"overlay-padding",type:l.size,triggersBounds:u.any},{name:"overlay-color",type:l.color},{name:"overlay-opacity",type:l.zeroOneNumber,triggersBounds:u.zeroNonZero},{name:"overlay-shape",type:l.overlayShape,triggersBounds:u.any},{name:"overlay-corner-radius",type:l.cornerRadius}],y=[{name:"underlay-padding",type:l.size,triggersBounds:u.any},{name:"underlay-color",type:l.color},{name:"underlay-opacity",type:l.zeroOneNumber,triggersBounds:u.zeroNonZero},{name:"underlay-shape",type:l.overlayShape,triggersBounds:u.any},{name:"underlay-corner-radius",type:l.cornerRadius}],w=[{name:"transition-property",type:l.propList},{name:"transition-duration",type:l.time},{name:"transition-delay",type:l.time},{name:"transition-timing-function",type:l.easing}],b=function(W,O){return O.value==="label"?-W.poolIndex():O.pfValue},k=[{name:"height",type:l.nodeSize,triggersBounds:u.any,hashOverride:b},{name:"width",type:l.nodeSize,triggersBounds:u.any,hashOverride:b},{name:"shape",type:l.nodeShape,triggersBounds:u.any},{name:"shape-polygon-points",type:l.polygonPointList,triggersBounds:u.any},{name:"corner-radius",type:l.cornerRadius},{name:"background-color",type:l.color},{name:"background-fill",type:l.fill},{name:"background-opacity",type:l.zeroOneNumber},{name:"background-blacken",type:l.nOneOneNumber},{name:"background-gradient-stop-colors",type:l.colors},{name:"background-gradient-stop-positions",type:l.percentages},{name:"background-gradient-direction",type:l.gradientDirection},{name:"padding",type:l.sizeMaybePercent,triggersBounds:u.any},{name:"padding-relative-to",type:l.paddingRelativeTo,triggersBounds:u.any},{name:"bounds-expansion",type:l.boundsExpansion,triggersBounds:u.any}],x=[{name:"border-color",type:l.color},{name:"border-opacity",type:l.zeroOneNumber},{name:"border-width",type:l.size,triggersBounds:u.any},{name:"border-style",type:l.borderStyle},{name:"border-cap",type:l.lineCap},{name:"border-join",type:l.lineJoin},{name:"border-dash-pattern",type:l.numbers},{name:"border-dash-offset",type:l.number},{name:"border-position",type:l.linePosition}],E=[{name:"outline-color",type:l.color},{name:"outline-opacity",type:l.zeroOneNumber},{name:"outline-width",type:l.size,triggersBounds:u.any},{name:"outline-style",type:l.borderStyle},{name:"outline-offset",type:l.size,triggersBounds:u.any}],T=[{name:"background-image",type:l.urls},{name:"background-image-crossorigin",type:l.bgCrossOrigin},{name:"background-image-opacity",type:l.zeroOneNumbers},{name:"background-image-containment",type:l.bgContainment},{name:"background-image-smoothing",type:l.bools},{name:"background-position-x",type:l.bgPos},{name:"background-position-y",type:l.bgPos},{name:"background-width-relative-to",type:l.bgRelativeTo},{name:"background-height-relative-to",type:l.bgRelativeTo},{name:"background-repeat",type:l.bgRepeat},{name:"background-fit",type:l.bgFit},{name:"background-clip",type:l.bgClip},{name:"background-width",type:l.bgWH},{name:"background-height",type:l.bgWH},{name:"background-offset-x",type:l.bgPos},{name:"background-offset-y",type:l.bgPos}],F=[{name:"position",type:l.position,triggersBounds:u.any},{name:"compound-sizing-wrt-labels",type:l.compoundIncludeLabels,triggersBounds:u.any},{name:"min-width",type:l.size,triggersBounds:u.any},{name:"min-width-bias-left",type:l.sizeMaybePercent,triggersBounds:u.any},{name:"min-width-bias-right",type:l.sizeMaybePercent,triggersBounds:u.any},{name:"min-height",type:l.size,triggersBounds:u.any},{name:"min-height-bias-top",type:l.sizeMaybePercent,triggersBounds:u.any},{name:"min-height-bias-bottom",type:l.sizeMaybePercent,triggersBounds:u.any}],S=[{name:"line-style",type:l.lineStyle},{name:"line-color",type:l.color},{name:"line-fill",type:l.fill},{name:"line-cap",type:l.lineCap},{name:"line-opacity",type:l.zeroOneNumber},{name:"line-dash-pattern",type:l.numbers},{name:"line-dash-offset",type:l.number},{name:"line-outline-width",type:l.size},{name:"line-outline-color",type:l.color},{name:"line-gradient-stop-colors",type:l.colors},{name:"line-gradient-stop-positions",type:l.percentages},{name:"curve-style",type:l.curveStyle,triggersBounds:u.any,triggersBoundsOfParallelBeziers:!0},{name:"haystack-radius",type:l.zeroOneNumber,triggersBounds:u.any},{name:"source-endpoint",type:l.edgeEndpoint,triggersBounds:u.any},{name:"target-endpoint",type:l.edgeEndpoint,triggersBounds:u.any},{name:"control-point-step-size",type:l.size,triggersBounds:u.any},{name:"control-point-distances",type:l.bidirectionalSizes,triggersBounds:u.any},{name:"control-point-weights",type:l.numbers,triggersBounds:u.any},{name:"segment-distances",type:l.bidirectionalSizes,triggersBounds:u.any},{name:"segment-weights",type:l.numbers,triggersBounds:u.any},{name:"segment-radii",type:l.numbers,triggersBounds:u.any},{name:"radius-type",type:l.radiusType,triggersBounds:u.any},{name:"taxi-turn",type:l.bidirectionalSizeMaybePercent,triggersBounds:u.any},{name:"taxi-turn-min-distance",type:l.size,triggersBounds:u.any},{name:"taxi-direction",type:l.axisDirection,triggersBounds:u.any},{name:"taxi-radius",type:l.number,triggersBounds:u.any},{name:"edge-distances",type:l.edgeDistances,triggersBounds:u.any},{name:"arrow-scale",type:l.positiveNumber,triggersBounds:u.any},{name:"loop-direction",type:l.angle,triggersBounds:u.any},{name:"loop-sweep",type:l.angle,triggersBounds:u.any},{name:"source-distance-from-node",type:l.size,triggersBounds:u.any},{name:"target-distance-from-node",type:l.size,triggersBounds:u.any}],D=[{name:"ghost",type:l.bool,triggersBounds:u.any},{name:"ghost-offset-x",type:l.bidirectionalSize,triggersBounds:u.any},{name:"ghost-offset-y",type:l.bidirectionalSize,triggersBounds:u.any},{name:"ghost-opacity",type:l.zeroOneNumber}],C=[{name:"selection-box-color",type:l.color},{name:"selection-box-opacity",type:l.zeroOneNumber},{name:"selection-box-border-color",type:l.color},{name:"selection-box-border-width",type:l.size},{name:"active-bg-color",type:l.color},{name:"active-bg-opacity",type:l.zeroOneNumber},{name:"active-bg-size",type:l.size},{name:"outside-texture-bg-color",type:l.color},{name:"outside-texture-bg-opacity",type:l.zeroOneNumber}],B=[];tr.pieBackgroundN=16,B.push({name:"pie-size",type:l.sizeMaybePercent});for(var A=1;A<=tr.pieBackgroundN;A++)B.push({name:"pie-"+A+"-background-color",type:l.color}),B.push({name:"pie-"+A+"-background-size",type:l.percent}),B.push({name:"pie-"+A+"-background-opacity",type:l.zeroOneNumber});var M=[],I=tr.arrowPrefixes=["source","mid-source","target","mid-target"];[{name:"arrow-shape",type:l.arrowShape,triggersBounds:u.any},{name:"arrow-color",type:l.color},{name:"arrow-fill",type:l.arrowFill},{name:"arrow-width",type:l.arrowWidth}].forEach(function(re){I.forEach(function(W){var O=W+"-"+re.name,G=re.type,ee=re.triggersBounds;M.push({name:O,type:G,triggersBounds:ee})})},{});var R=tr.properties=[].concat(m,w,g,p,y,D,c,h,v,f,d,k,x,E,T,B,F,S,M,C),L=tr.propertyGroups={behavior:m,transition:w,visibility:g,overlay:p,underlay:y,ghost:D,commonLabel:c,labelDimensions:h,mainLabel:v,sourceLabel:f,targetLabel:d,nodeBody:k,nodeBorder:x,nodeOutline:E,backgroundImage:T,pie:B,compound:F,edgeLine:S,edgeArrow:M,core:C},V=tr.propertyGroupNames={},H=tr.propertyGroupKeys=Object.keys(L);H.forEach(function(re){V[re]=L[re].map(function(W){return W.name}),L[re].forEach(function(W){return W.groupKey=re})});var z=tr.aliases=[{name:"content",pointsTo:"label"},{name:"control-point-distance",pointsTo:"control-point-distances"},{name:"control-point-weight",pointsTo:"control-point-weights"},{name:"segment-distance",pointsTo:"segment-distances"},{name:"segment-weight",pointsTo:"segment-weights"},{name:"segment-radius",pointsTo:"segment-radii"},{name:"edge-text-rotation",pointsTo:"text-rotation"},{name:"padding-left",pointsTo:"padding"},{name:"padding-right",pointsTo:"padding"},{name:"padding-top",pointsTo:"padding"},{name:"padding-bottom",pointsTo:"padding"}];tr.propertyNames=R.map(function(re){return re.name});for(var $=0;$<R.length;$++){var K=R[$];R[K.name]=K}for(var Y=0;Y<z.length;Y++){var Q=z[Y],Z=R[Q.pointsTo],j={name:Q.name,alias:!0,pointsTo:Z};R.push(j),R[Q.name]=j}})(),tr.getDefaultProperty=function(r){return this.getDefaultProperties()[r]},tr.getDefaultProperties=function(){var r=this._private;if(r.defaultProperties!=null)return r.defaultProperties;for(var e=ce({"selection-box-color":"#ddd","selection-box-opacity":.65,"selection-box-border-color":"#aaa","selection-box-border-width":1,"active-bg-color":"black","active-bg-opacity":.15,"active-bg-size":30,"outside-texture-bg-color":"#000","outside-texture-bg-opacity":.125,events:"yes","text-events":"no","text-valign":"top","text-halign":"center","text-justification":"auto","line-height":1,color:"#000","text-outline-color":"#000","text-outline-width":0,"text-outline-opacity":1,"text-opacity":1,"text-decoration":"none","text-transform":"none","text-wrap":"none","text-overflow-wrap":"whitespace","text-max-width":9999,"text-background-color":"#000","text-background-opacity":0,"text-background-shape":"rectangle","text-background-padding":0,"text-border-opacity":0,"text-border-width":0,"text-border-style":"solid","text-border-color":"#000","font-family":"Helvetica Neue, Helvetica, sans-serif","font-style":"normal","font-weight":"normal","font-size":16,"min-zoomed-font-size":0,"text-rotation":"none","source-text-rotation":"none","target-text-rotation":"none",visibility:"visible",display:"element",opacity:1,"z-compound-depth":"auto","z-index-compare":"auto","z-index":0,label:"","text-margin-x":0,"text-margin-y":0,"source-label":"","source-text-offset":0,"source-text-margin-x":0,"source-text-margin-y":0,"target-label":"","target-text-offset":0,"target-text-margin-x":0,"target-text-margin-y":0,"overlay-opacity":0,"overlay-color":"#000","overlay-padding":10,"overlay-shape":"round-rectangle","overlay-corner-radius":"auto","underlay-opacity":0,"underlay-color":"#000","underlay-padding":10,"underlay-shape":"round-rectangle","underlay-corner-radius":"auto","transition-property":"none","transition-duration":0,"transition-delay":0,"transition-timing-function":"linear","background-blacken":0,"background-color":"#999","background-fill":"solid","background-opacity":1,"background-image":"none","background-image-crossorigin":"anonymous","background-image-opacity":1,"background-image-containment":"inside","background-image-smoothing":"yes","background-position-x":"50%","background-position-y":"50%","background-offset-x":0,"background-offset-y":0,"background-width-relative-to":"include-padding","background-height-relative-to":"include-padding","background-repeat":"no-repeat","background-fit":"none","background-clip":"node","background-width":"auto","background-height":"auto","border-color":"#000","border-opacity":1,"border-width":0,"border-style":"solid","border-dash-pattern":[4,2],"border-dash-offset":0,"border-cap":"butt","border-join":"miter","border-position":"center","outline-color":"#999","outline-opacity":1,"outline-width":0,"outline-offset":0,"outline-style":"solid",height:30,width:30,shape:"ellipse","shape-polygon-points":"-1, -1,   1, -1,   1, 1,   -1, 1","corner-radius":"auto","bounds-expansion":0,"background-gradient-direction":"to-bottom","background-gradient-stop-colors":"#999","background-gradient-stop-positions":"0%",ghost:"no","ghost-offset-y":0,"ghost-offset-x":0,"ghost-opacity":0,padding:0,"padding-relative-to":"width",position:"origin","compound-sizing-wrt-labels":"include","min-width":0,"min-width-bias-left":0,"min-width-bias-right":0,"min-height":0,"min-height-bias-top":0,"min-height-bias-bottom":0},{"pie-size":"100%"},[{name:"pie-{{i}}-background-color",value:"black"},{name:"pie-{{i}}-background-size",value:"0%"},{name:"pie-{{i}}-background-opacity",value:1}].reduce(function(u,l){for(var v=1;v<=tr.pieBackgroundN;v++){var f=l.name.replace("{{i}}",v),d=l.value;u[f]=d}return u},{}),{"line-style":"solid","line-color":"#999","line-fill":"solid","line-cap":"butt","line-opacity":1,"line-outline-width":0,"line-outline-color":"#000","line-gradient-stop-colors":"#999","line-gradient-stop-positions":"0%","control-point-step-size":40,"control-point-weights":.5,"segment-weights":.5,"segment-distances":20,"segment-radii":15,"radius-type":"arc-radius","taxi-turn":"50%","taxi-radius":15,"taxi-turn-min-distance":10,"taxi-direction":"auto","edge-distances":"intersection","curve-style":"haystack","haystack-radius":0,"arrow-scale":1,"loop-direction":"-45deg","loop-sweep":"-90deg","source-distance-from-node":0,"target-distance-from-node":0,"source-endpoint":"outside-to-node","target-endpoint":"outside-to-node","line-dash-pattern":[6,3],"line-dash-offset":0},[{name:"arrow-shape",value:"none"},{name:"arrow-color",value:"#999"},{name:"arrow-fill",value:"filled"},{name:"arrow-width",value:1}].reduce(function(u,l){return tr.arrowPrefixes.forEach(function(v){var f=v+"-"+l.name,d=l.value;u[f]=d}),u},{})),t={},a=0;a<this.properties.length;a++){var n=this.properties[a];if(!n.pointsTo){var i=n.name,s=e[i],o=this.parse(i,s);t[i]=o}}return r.defaultProperties=t,r.defaultProperties},tr.addDefaultStylesheet=function(){this.selector(":parent").css({shape:"rectangle",padding:10,"background-color":"#eee","border-color":"#ccc","border-width":1}).selector("edge").css({width:3}).selector(":loop").css({"curve-style":"bezier"}).selector("edge:compound").css({"curve-style":"bezier","source-endpoint":"outside-to-line","target-endpoint":"outside-to-line"}).selector(":selected").css({"background-color":"#0169D9","line-color":"#0169D9","source-arrow-color":"#0169D9","target-arrow-color":"#0169D9","mid-source-arrow-color":"#0169D9","mid-target-arrow-color":"#0169D9"}).selector(":parent:selected").css({"background-color":"#CCE1F9","border-color":"#aec8e5"}).selector(":active").css({"overlay-color":"black","overlay-padding":10,"overlay-opacity":.25}),this.defaultLength=this.length};var Pn={};Pn.parse=function(r,e,t,a){var n=this;if(ze(e))return n.parseImplWarn(r,e,t,a);var i=a==="mapping"||a===!0||a===!1||a==null?"dontcare":a,s=t?"t":"f",o=""+e,u=Ds(r,o,s,i),l=n.propCache=n.propCache||[],v;return(v=l[u])||(v=l[u]=n.parseImplWarn(r,e,t,a)),(t||a==="mapping")&&(v=Ir(v),v&&(v.value=Ir(v.value))),v},Pn.parseImplWarn=function(r,e,t,a){var n=this.parseImpl(r,e,t,a);return!n&&e!=null&&Pe("The style property `".concat(r,": ").concat(e,"` is invalid")),n&&(n.name==="width"||n.name==="height")&&e==="label"&&Pe("The style value of `label` is deprecated for `"+n.name+"`"),n},Pn.parseImpl=function(r,e,t,a){var n=this;r=jn(r);var i=n.properties[r],s=e,o=n.types;if(!i||e===void 0)return null;i.alias&&(i=i.pointsTo,r=i.name);var u=fe(e);u&&(e=e.trim());var l=i.type;if(!l)return null;if(t&&(e===""||e===null))return{name:r,value:e,bypass:!0,deleteBypass:!0};if(ze(e))return{name:r,value:e,strValue:"fn",mapped:o.fn,bypass:t};var v,f;if(!(!u||a||e.length<7||e[1]!=="a")){if(e.length>=7&&e[0]==="d"&&(v=new RegExp(o.data.regex).exec(e))){if(t)return!1;var d=o.data;return{name:r,value:v,strValue:""+e,mapped:d,field:v[1],bypass:t}}else if(e.length>=10&&e[0]==="m"&&(f=new RegExp(o.mapData.regex).exec(e))){if(t||l.multiple)return!1;var h=o.mapData;if(!(l.color||l.number))return!1;var c=this.parse(r,f[4]);if(!c||c.mapped)return!1;var m=this.parse(r,f[5]);if(!m||m.mapped)return!1;if(c.pfValue===m.pfValue||c.strValue===m.strValue)return Pe("`"+r+": "+e+"` is not a valid mapper because the output range is zero; converting to `"+r+": "+c.strValue+"`"),this.parse(r,c.strValue);if(l.color){var g=c.value,p=m.value,y=g[0]===p[0]&&g[1]===p[1]&&g[2]===p[2]&&(g[3]===p[3]||(g[3]==null||g[3]===1)&&(p[3]==null||p[3]===1));if(y)return!1}return{name:r,value:f,strValue:""+e,mapped:h,field:f[1],fieldMin:parseFloat(f[2]),fieldMax:parseFloat(f[3]),valueMin:c.value,valueMax:m.value,bypass:t}}}if(l.multiple&&a!=="multiple"){var w;if(u?w=e.split(/\s+/):Re(e)?w=e:w=[e],l.evenMultiple&&w.length%2!==0)return null;for(var b=[],k=[],x=[],E="",T=!1,F=0;F<w.length;F++){var S=n.parse(r,w[F],t,"multiple");T=T||fe(S.value),b.push(S.value),x.push(S.pfValue!=null?S.pfValue:S.value),k.push(S.units),E+=(F>0?" ":"")+S.strValue}return l.validate&&!l.validate(b,k)?null:l.singleEnum&&T?b.length===1&&fe(b[0])?{name:r,value:b[0],strValue:b[0],bypass:t}:null:{name:r,value:b,pfValue:x,strValue:E,bypass:t,units:k}}var D=function(){for(var W=0;W<l.enums.length;W++){var O=l.enums[W];if(O===e)return{name:r,value:e,strValue:""+e,bypass:t}}return null};if(l.number){var C,B="px";if(l.units&&(C=l.units),l.implicitUnits&&(B=l.implicitUnits),!l.unitless)if(u){var A="px|em"+(l.allowPercent?"|\\%":"");C&&(A=C);var M=e.match("^("+Ue+")("+A+")?$");M&&(e=M[1],C=M[2]||B)}else(!C||l.implicitUnits)&&(C=B);if(e=parseFloat(e),isNaN(e)&&l.enums===void 0)return null;if(isNaN(e)&&l.enums!==void 0)return e=s,D();if(l.integer&&!av(e)||l.min!==void 0&&(e<l.min||l.strictMin&&e===l.min)||l.max!==void 0&&(e>l.max||l.strictMax&&e===l.max))return null;var I={name:r,value:e,strValue:""+e+(C||""),units:C,bypass:t};return l.unitless||C!=="px"&&C!=="em"?I.pfValue=e:I.pfValue=C==="px"||!C?e:this.getEmSizeInPixels()*e,(C==="ms"||C==="s")&&(I.pfValue=C==="ms"?e:1e3*e),(C==="deg"||C==="rad")&&(I.pfValue=C==="rad"?e:_f(e)),C==="%"&&(I.pfValue=e/100),I}else if(l.propList){var R=[],L=""+e;if(L!=="none"){for(var V=L.split(/\s*,\s*|\s+/),H=0;H<V.length;H++){var z=V[H].trim();n.properties[z]?R.push(z):Pe("`"+z+"` is not a valid property name")}if(R.length===0)return null}return{name:r,value:R,strValue:R.length===0?"none":R.join(" "),bypass:t}}else if(l.color){var $=ms(e);return $?{name:r,value:$,pfValue:$,strValue:"rgb("+$[0]+","+$[1]+","+$[2]+")",bypass:t}:null}else if(l.regex||l.regexes){if(l.enums){var K=D();if(K)return K}for(var Y=l.regexes?l.regexes:[l.regex],Q=0;Q<Y.length;Q++){var Z=new RegExp(Y[Q]),j=Z.exec(e);if(j)return{name:r,value:l.singleRegexMatchValue?j[1]:j,strValue:""+e,bypass:t}}return null}else return l.string?{name:r,value:""+e,strValue:""+e,bypass:t}:l.enums?D():null};var sr=function r(e){if(!(this instanceof r))return new r(e);if(!Jn(e)){Ve("A style must have a core reference");return}this._private={cy:e,coreStyle:{}},this.length=0,this.resetToDefault()},or=sr.prototype;or.instanceString=function(){return"style"},or.clear=function(){for(var r=this._private,e=r.cy,t=e.elements(),a=0;a<this.length;a++)this[a]=void 0;return this.length=0,r.contextStyles={},r.propDiffs={},this.cleanElements(t,!0),t.forEach(function(n){var i=n[0]._private;i.styleDirty=!0,i.appliedInitStyle=!1}),this},or.resetToDefault=function(){return this.clear(),this.addDefaultStylesheet(),this},or.core=function(r){return this._private.coreStyle[r]||this.getDefaultProperty(r)},or.selector=function(r){var e=r==="core"?null:new it(r),t=this.length++;return this[t]={selector:e,properties:[],mappedProperties:[],index:t},this},or.css=function(){var r=this,e=arguments;if(e.length===1)for(var t=e[0],a=0;a<r.properties.length;a++){var n=r.properties[a],i=t[n.name];i===void 0&&(i=t[Ua(n.name)]),i!==void 0&&this.cssRule(n.name,i)}else e.length===2&&this.cssRule(e[0],e[1]);return this},or.style=or.css,or.cssRule=function(r,e){var t=this.parse(r,e);if(t){var a=this.length-1;this[a].properties.push(t),this[a].properties[t.name]=t,t.name.match(/pie-(\d+)-background-size/)&&t.value&&(this._private.hasPie=!0),t.mapped&&this[a].mappedProperties.push(t);var n=!this[a].selector;n&&(this._private.coreStyle[t.name]=t)}return this},or.append=function(r){return cs(r)?r.appendToStyle(this):Re(r)?this.appendFromJson(r):fe(r)&&this.appendFromString(r),this},sr.fromJson=function(r,e){var t=new sr(r);return t.fromJson(e),t},sr.fromString=function(r,e){return new sr(r).fromString(e)},[ir,Pa,Bi,Rr,Dn,Ai,tr,Pn].forEach(function(r){ce(or,r)}),sr.types=or.types,sr.properties=or.properties,sr.propertyGroups=or.propertyGroups,sr.propertyGroupNames=or.propertyGroupNames,sr.propertyGroupKeys=or.propertyGroupKeys;var a0={style:function(e){if(e){var t=this.setStyle(e);t.update()}return this._private.style},setStyle:function(e){var t=this._private;return cs(e)?t.style=e.generateStyle(this):Re(e)?t.style=sr.fromJson(this,e):fe(e)?t.style=sr.fromString(this,e):t.style=sr(this),t.style},updateStyle:function(){this.mutableElements().updateStyle()}},n0="single",Ft={autolock:function(e){if(e!==void 0)this._private.autolock=!!e;else return this._private.autolock;return this},autoungrabify:function(e){if(e!==void 0)this._private.autoungrabify=!!e;else return this._private.autoungrabify;return this},autounselectify:function(e){if(e!==void 0)this._private.autounselectify=!!e;else return this._private.autounselectify;return this},selectionType:function(e){var t=this._private;if(t.selectionType==null&&(t.selectionType=n0),e!==void 0)(e==="additive"||e==="single")&&(t.selectionType=e);else return t.selectionType;return this},panningEnabled:function(e){if(e!==void 0)this._private.panningEnabled=!!e;else return this._private.panningEnabled;return this},userPanningEnabled:function(e){if(e!==void 0)this._private.userPanningEnabled=!!e;else return this._private.userPanningEnabled;return this},zoomingEnabled:function(e){if(e!==void 0)this._private.zoomingEnabled=!!e;else return this._private.zoomingEnabled;return this},userZoomingEnabled:function(e){if(e!==void 0)this._private.userZoomingEnabled=!!e;else return this._private.userZoomingEnabled;return this},boxSelectionEnabled:function(e){if(e!==void 0)this._private.boxSelectionEnabled=!!e;else return this._private.boxSelectionEnabled;return this},pan:function(){var e=arguments,t=this._private.pan,a,n,i,s,o;switch(e.length){case 0:return t;case 1:if(fe(e[0]))return a=e[0],t[a];if(Se(e[0])){if(!this._private.panningEnabled)return this;i=e[0],s=i.x,o=i.y,te(s)&&(t.x=s),te(o)&&(t.y=o),this.emit("pan viewport")}break;case 2:if(!this._private.panningEnabled)return this;a=e[0],n=e[1],(a==="x"||a==="y")&&te(n)&&(t[a]=n),this.emit("pan viewport");break}return this.notify("viewport"),this},panBy:function(e,t){var a=arguments,n=this._private.pan,i,s,o,u,l;if(!this._private.panningEnabled)return this;switch(a.length){case 1:Se(e)&&(o=a[0],u=o.x,l=o.y,te(u)&&(n.x+=u),te(l)&&(n.y+=l),this.emit("pan viewport"));break;case 2:i=e,s=t,(i==="x"||i==="y")&&te(s)&&(n[i]+=s),this.emit("pan viewport");break}return this.notify("viewport"),this},gc:function(){this.notify("gc")},fit:function(e,t){var a=this.getFitViewport(e,t);if(a){var n=this._private;n.zoom=a.zoom,n.pan=a.pan,this.emit("pan zoom viewport"),this.notify("viewport")}return this},getFitViewport:function(e,t){if(te(e)&&t===void 0&&(t=e,e=void 0),!(!this._private.panningEnabled||!this._private.zoomingEnabled)){var a;if(fe(e)){var n=e;e=this.$(n)}else if(sv(e)){var i=e;a={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2},a.w=a.x2-a.x1,a.h=a.y2-a.y1}else yr(e)||(e=this.mutableElements());if(!(yr(e)&&e.empty())){a=a||e.boundingBox();var s=this.width(),o=this.height(),u;if(t=te(t)?t:0,!isNaN(s)&&!isNaN(o)&&s>0&&o>0&&!isNaN(a.w)&&!isNaN(a.h)&&a.w>0&&a.h>0){u=Math.min((s-2*t)/a.w,(o-2*t)/a.h),u=u>this._private.maxZoom?this._private.maxZoom:u,u=u<this._private.minZoom?this._private.minZoom:u;var l={x:(s-u*(a.x1+a.x2))/2,y:(o-u*(a.y1+a.y2))/2};return{zoom:u,pan:l}}}}},zoomRange:function(e,t){var a=this._private;if(t==null){var n=e;e=n.min,t=n.max}return te(e)&&te(t)&&e<=t?(a.minZoom=e,a.maxZoom=t):te(e)&&t===void 0&&e<=a.maxZoom?a.minZoom=e:te(t)&&e===void 0&&t>=a.minZoom&&(a.maxZoom=t),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 t=this._private,a=t.pan,n=t.zoom,i,s,o=!1;if(t.zoomingEnabled||(o=!0),te(e)?s=e:Se(e)&&(s=e.level,e.position!=null?i=Ja(e.position,n,a):e.renderedPosition!=null&&(i=e.renderedPosition),i!=null&&!t.panningEnabled&&(o=!0)),s=s>t.maxZoom?t.maxZoom:s,s=s<t.minZoom?t.minZoom:s,o||!te(s)||s===n||i!=null&&(!te(i.x)||!te(i.y)))return null;if(i!=null){var u=a,l=n,v=s,f={x:-v/l*(i.x-u.x)+i.x,y:-v/l*(i.y-u.y)+i.y};return{zoomed:!0,panned:!0,zoom:v,pan:f}}else return{zoomed:!0,panned:!1,zoom:s,pan:a}},zoom:function(e){if(e===void 0)return this._private.zoom;var t=this.getZoomedViewport(e),a=this._private;return t==null||!t.zoomed?this:(a.zoom=t.zoom,t.panned&&(a.pan.x=t.pan.x,a.pan.y=t.pan.y),this.emit("zoom"+(t.panned?" pan":"")+" viewport"),this.notify("viewport"),this)},viewport:function(e){var t=this._private,a=!0,n=!0,i=[],s=!1,o=!1;if(!e)return this;if(te(e.zoom)||(a=!1),Se(e.pan)||(n=!1),!a&&!n)return this;if(a){var u=e.zoom;u<t.minZoom||u>t.maxZoom||!t.zoomingEnabled?s=!0:(t.zoom=u,i.push("zoom"))}if(n&&(!s||!e.cancelOnFailedZoom)&&t.panningEnabled){var l=e.pan;te(l.x)&&(t.pan.x=l.x,o=!1),te(l.y)&&(t.pan.y=l.y,o=!1),o||i.push("pan")}return i.length>0&&(i.push("viewport"),this.emit(i.join(" ")),this.notify("viewport")),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,t){if(this._private.panningEnabled){if(fe(e)){var a=e;e=this.mutableElements().filter(a)}else yr(e)||(e=this.mutableElements());if(e.length!==0){var n=e.boundingBox(),i=this.width(),s=this.height();t=t===void 0?this._private.zoom:t;var o={x:(i-t*(n.x1+n.x2))/2,y:(s-t*(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,t=e.container,a=this;return e.sizeCache=e.sizeCache||(t?function(){var n=a.window().getComputedStyle(t),i=function(o){return parseFloat(n.getPropertyValue(o))};return{width:t.clientWidth-i("padding-left")-i("padding-right"),height:t.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,t=this._private.zoom,a=this.renderedExtent(),n={x1:(a.x1-e.x)/t,x2:(a.x2-e.x)/t,y1:(a.y1-e.y)/t,y2:(a.y2-e.y)/t};return n.w=n.x2-n.x1,n.h=n.y2-n.y1,n},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}},multiClickDebounceTime:function(e){if(e)this._private.multiClickDebounceTime=e;else return this._private.multiClickDebounceTime;return this}};Ft.centre=Ft.center,Ft.autolockNodes=Ft.autolock,Ft.autoungrabifyNodes=Ft.autoungrabify;var Ba={data:Be.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:Be.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:Be.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Be.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Ba.attr=Ba.data,Ba.removeAttr=Ba.removeData;var Aa=function(e){var t=this;e=ce({},e);var a=e.container;a&&!Ga(a)&&Ga(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=t;var s=Ge!==void 0&&a!==void 0&&!e.headless,o=e;o.layout=ce({name:s?"grid":"null"},o.layout),o.renderer=ce({name:s?"canvas":"null"},o.renderer);var u=function(c,m,g){return m!==void 0?m:g!==void 0?g:c},l=this._private={container:a,ready:!1,options:o,elements:new rr(this),listeners:[],aniEles:new rr(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:te(o.zoom)?o.zoom:1,pan:{x:Se(o.pan)&&te(o.pan.x)?o.pan.x:0,y:Se(o.pan)&&te(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 v=function(c,m){var g=c.some(ov);if(g)return Nt.all(c).then(m);m(c)};l.styleEnabled&&t.setStyle([]);var f=ce({},o,o.renderer);t.initRenderer(f);var d=function(c,m,g){t.notifications(!1);var p=t.mutableElements();p.length>0&&p.remove(),c!=null&&(Se(c)||Re(c))&&t.add(c),t.one("layoutready",function(w){t.notifications(!0),t.emit(w),t.one("load",m),t.emitAndNotify("load")}).one("layoutstop",function(){t.one("done",g),t.emit("done")});var y=ce({},t._private.options.layout);y.eles=t.elements(),t.layout(y).run()};v([o.style,o.elements],function(h){var c=h[0],m=h[1];l.styleEnabled&&t.style().append(c),d(m,function(){t.startAnimationLoop(),l.ready=!0,ze(o.ready)&&t.on("ready",o.ready);for(var g=0;g<i.length;g++){var p=i[g];t.on("ready",p)}n&&(n.readies=[]),t.emit("ready")},o.done)})},Bn=Aa.prototype;ce(Bn,{instanceString:function(){return"core"},isReady:function(){return this._private.ready},destroyed:function(){return this._private.destroyed},ready:function(e){return this.isReady()?this.emitter().emit("ready",[],e):this.on("ready",e),this},destroy:function(){var e=this;if(!e.destroyed())return e.stopAnimationLoop(),e.destroyRenderer(),this.emit("destroy"),e._private.destroyed=!0,e},hasElementWithId:function(e){return this._private.elements.hasElementWithId(e)},getElementById:function(e){return this._private.elements.getElementById(e)},hasCompoundNodes:function(){return this._private.hasCompoundNodes},headless:function(){return this._private.renderer.isHeadless()},styleEnabled:function(){return this._private.styleEnabled},addToPool:function(e){return this._private.elements.merge(e),this},removeFromPool:function(e){return this._private.elements.unmerge(e),this},container:function(){return this._private.container||null},window:function(){var e=this._private.container;if(e==null)return Ge;var t=this._private.container.ownerDocument;return t===void 0||t==null?Ge:t.defaultView||Ge},mount:function(e){if(e!=null){var t=this,a=t._private,n=a.options;return!Ga(e)&&Ga(e[0])&&(e=e[0]),t.stopAnimationLoop(),t.destroyRenderer(),a.container=e,a.styleEnabled=!0,t.invalidateSize(),t.initRenderer(ce({},n,n.renderer,{name:n.renderer.name==="null"?"canvas":n.renderer.name})),t.startAnimationLoop(),t.style(n.style),t.emit("mount"),t}},unmount:function(){var e=this;return e.stopAnimationLoop(),e.destroyRenderer(),e.initRenderer({name:"null"}),e.emit("unmount"),e},options:function(){return Ir(this._private.options)},json:function(e){var t=this,a=t._private,n=t.mutableElements(),i=function(b){return t.getElementById(b.id())};if(Se(e)){if(t.startBatch(),e.elements){var s={},o=function(b,k){for(var x=[],E=[],T=0;T<b.length;T++){var F=b[T];if(!F.data.id){Pe("cy.json() cannot handle elements without an ID attribute");continue}var S=""+F.data.id,D=t.getElementById(S);s[S]=!0,D.length!==0?E.push({ele:D,json:F}):(k&&(F.group=k),x.push(F))}t.add(x);for(var C=0;C<E.length;C++){var B=E[C],A=B.ele,M=B.json;A.json(M)}};if(Re(e.elements))o(e.elements);else for(var u=["nodes","edges"],l=0;l<u.length;l++){var v=u[l],f=e.elements[v];Re(f)&&o(f,v)}var d=t.collection();n.filter(function(w){return!s[w.id()]}).forEach(function(w){w.isParent()?d.merge(w):w.remove()}),d.forEach(function(w){return w.children().move({parent:null})}),d.forEach(function(w){return i(w).remove()})}e.style&&t.style(e.style),e.zoom!=null&&e.zoom!==a.zoom&&t.zoom(e.zoom),e.pan&&(e.pan.x!==a.pan.x||e.pan.y!==a.pan.y)&&t.pan(e.pan),e.data&&t.data(e.data);for(var h=["minZoom","maxZoom","zoomingEnabled","userZoomingEnabled","panningEnabled","userPanningEnabled","boxSelectionEnabled","autolock","autoungrabify","autounselectify","multiClickDebounceTime"],c=0;c<h.length;c++){var m=h[c];e[m]!=null&&t[m](e[m])}return t.endBatch(),this}else{var g=!!e,p={};g?p.elements=this.elements().map(function(w){return w.json()}):(p.elements={},n.forEach(function(w){var b=w.group();p.elements[b]||(p.elements[b]=[]),p.elements[b].push(w.json())})),this._private.styleEnabled&&(p.style=t.style().json()),p.data=Ir(t.data());var y=a.options;return p.zoomingEnabled=a.zoomingEnabled,p.userZoomingEnabled=a.userZoomingEnabled,p.zoom=a.zoom,p.minZoom=a.minZoom,p.maxZoom=a.maxZoom,p.panningEnabled=a.panningEnabled,p.userPanningEnabled=a.userPanningEnabled,p.pan=Ir(a.pan),p.boxSelectionEnabled=a.boxSelectionEnabled,p.renderer=Ir(y.renderer),p.hideEdgesOnViewport=y.hideEdgesOnViewport,p.textureOnViewport=y.textureOnViewport,p.wheelSensitivity=y.wheelSensitivity,p.motionBlur=y.motionBlur,p.multiClickDebounceTime=y.multiClickDebounceTime,p}}}),Bn.$id=Bn.getElementById,[Kg,Jg,ou,Di,Sn,e0,Pi,kn,a0,Ft,Ba].forEach(function(r){ce(Bn,r)});var i0={fit:!0,directed:!1,padding:30,circle:!1,grid:!1,spacingFactor:1.75,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,roots:void 0,depthSort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}},s0={maximal:!1,acyclic:!1},Yt=function(e){return e.scratch("breadthfirst")},uu=function(e,t){return e.scratch("breadthfirst",t)};function lu(r){this.options=ce({},i0,s0,r)}lu.prototype.run=function(){var r=this.options,e=r.cy,t=r.eles,a=t.nodes().filter(function(le){return le.isChildless()}),n=t,i=r.directed,s=r.acyclic||r.maximal||r.maximalAdjustments>0,o=!!r.boundingBox,u=e.extent(),l=hr(o?r.boundingBox:{x1:u.x1,y1:u.y1,w:u.w,h:u.h}),v;if(yr(r.roots))v=r.roots;else if(Re(r.roots)){for(var f=[],d=0;d<r.roots.length;d++){var h=r.roots[d],c=e.getElementById(h);f.push(c)}v=e.collection(f)}else if(fe(r.roots))v=e.$(r.roots);else if(i)v=a.roots();else{var m=t.components();v=e.collection();for(var g=function(oe){var pe=m[oe],me=pe.maxDegree(!1),he=pe.filter(function(ye){return ye.degree(!1)===me});v=v.add(he)},p=0;p<m.length;p++)g(p)}var y=[],w={},b=function(oe,pe){y[pe]==null&&(y[pe]=[]);var me=y[pe].length;y[pe].push(oe),uu(oe,{index:me,depth:pe})},k=function(oe,pe){var me=Yt(oe),he=me.depth,ye=me.index;y[he][ye]=null,oe.isChildless()&&b(oe,pe)};n.bfs({roots:v,directed:r.directed,visit:function(oe,pe,me,he,ye){var Ee=oe[0],Te=Ee.id();Ee.isChildless()&&b(Ee,ye),w[Te]=!0}});for(var x=[],E=0;E<a.length;E++){var T=a[E];w[T.id()]||x.push(T)}var F=function(oe){for(var pe=y[oe],me=0;me<pe.length;me++){var he=pe[me];if(he==null){pe.splice(me,1),me--;continue}uu(he,{depth:oe,index:me})}},S=function(oe,pe){for(var me=Yt(oe),he=oe.incomers().filter(function(U){return U.isNode()&&t.has(U)}),ye=-1,Ee=oe.id(),Te=0;Te<he.length;Te++){var J=he[Te],P=Yt(J);ye=Math.max(ye,P.depth)}if(me.depth<=ye){if(!r.acyclic&&pe[Ee])return null;var _=ye+1;return k(oe,_),pe[Ee]=_,!0}return!1};if(i&&s){var D=[],C={},B=function(oe){return D.push(oe)},A=function(){return D.shift()};for(a.forEach(function(le){return D.push(le)});D.length>0;){var M=A(),I=S(M,C);if(I)M.outgoers().filter(function(le){return le.isNode()&&t.has(le)}).forEach(B);else if(I===null){Pe("Detected double maximal shift for node `"+M.id()+"`.  Bailing maximal adjustment due to cycle.  Use `options.maximal: true` only on DAGs.");break}}}var R=0;if(r.avoidOverlap)for(var L=0;L<a.length;L++){var V=a[L],H=V.layoutDimensions(r),z=H.w,$=H.h;R=Math.max(R,z,$)}var K={},Y=function(oe){if(K[oe.id()])return K[oe.id()];for(var pe=Yt(oe).depth,me=oe.neighborhood(),he=0,ye=0,Ee=0;Ee<me.length;Ee++){var Te=me[Ee];if(!(Te.isEdge()||Te.isParent()||!a.has(Te))){var J=Yt(Te);if(J!=null){var P=J.index,_=J.depth;if(!(P==null||_==null)){var U=y[_].length;_<pe&&(he+=P/U,ye++)}}}}return ye=Math.max(1,ye),he=he/ye,ye===0&&(he=0),K[oe.id()]=he,he},Q=function(oe,pe){var me=Y(oe),he=Y(pe),ye=me-he;return ye===0?ps(oe.id(),pe.id()):ye};r.depthSort!==void 0&&(Q=r.depthSort);for(var Z=y.length,j=0;j<Z;j++)y[j].sort(Q),F(j);for(var re=[],W=0;W<x.length;W++)re.push(x[W]);var O=function(){for(var oe=0;oe<Z;oe++)F(oe)};re.length&&(y.unshift(re),Z=y.length,O());for(var G=0,ee=0;ee<Z;ee++)G=Math.max(y[ee].length,G);var ie={x:l.x1+l.w/2,y:l.y1+l.h/2},ue=a.reduce(function(le,oe){return function(pe){return{w:le.w===-1?pe.w:(le.w+pe.w)/2,h:le.h===-1?pe.h:(le.h+pe.h)/2}}(oe.boundingBox({includeLabels:r.nodeDimensionsIncludeLabels}))},{w:-1,h:-1}),Ce=Math.max(Z===1?0:o?(l.h-r.padding*2-ue.h)/(Z-1):(l.h-r.padding*2-ue.h)/(Z+1),R),Ae=y.reduce(function(le,oe){return Math.max(le,oe.length)},0),Ie=function(oe){var pe=Yt(oe),me=pe.depth,he=pe.index;if(r.circle){var ye=Math.min(l.w/2/Z,l.h/2/Z);ye=Math.max(ye,R);var Ee=ye*me+ye-(Z>0&&y[0].length<=3?ye/2:0),Te=2*Math.PI/y[me].length*he;return me===0&&y[0].length===1&&(Ee=1),{x:ie.x+Ee*Math.cos(Te),y:ie.y+Ee*Math.sin(Te)}}else{var J=y[me].length,P=Math.max(J===1?0:o?(l.w-r.padding*2-ue.w)/((r.grid?Ae:J)-1):(l.w-r.padding*2-ue.w)/((r.grid?Ae:J)+1),R),_={x:ie.x+(he+1-(J+1)/2)*P,y:ie.y+(me+1-(Z+1)/2)*Ce};return _}};return t.nodes().layoutPositions(this,r,Ie),this};var o0={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,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function vu(r){this.options=ce({},o0,r)}vu.prototype.run=function(){var r=this.options,e=r,t=r.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=hr(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.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),v,f=0,d=0;d<i.length;d++){var h=i[d],c=h.layoutDimensions(e),m=c.w,g=c.h;f=Math.max(f,m,g)}if(te(e.radius)?v=e.radius:i.length<=1?v=0:v=Math.min(s.h,s.w)/2-f,i.length>1&&e.avoidOverlap){f*=1.75;var p=Math.cos(l)-Math.cos(0),y=Math.sin(l)-Math.sin(0),w=Math.sqrt(f*f/(p*p+y*y));v=Math.max(w,v)}var b=function(x,E){var T=e.startAngle+E*l*(n?1:-1),F=v*Math.cos(T),S=v*Math.sin(T),D={x:o.x+F,y:o.y+S};return D};return a.nodes().layoutPositions(this,e,b),this};var u0={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,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function fu(r){this.options=ce({},u0,r)}fu.prototype.run=function(){for(var r=this.options,e=r,t=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,a=r.cy,n=e.eles,i=n.nodes().not(":parent"),s=hr(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,v=0;v<i.length;v++){var f=i[v],d=void 0;d=e.concentric(f),u.push({value:d,node:f}),f._private.scratch.concentric=d}i.updateStyle();for(var h=0;h<i.length;h++){var c=i[h],m=c.layoutDimensions(e);l=Math.max(l,m.w,m.h)}u.sort(function(ue,Ce){return Ce.value-ue.value});for(var g=e.levelWidth(i),p=[[]],y=p[0],w=0;w<u.length;w++){var b=u[w];if(y.length>0){var k=Math.abs(y[0].value-b.value);k>=g&&(y=[],p.push(y))}y.push(b)}var x=l+e.minNodeSpacing;if(!e.avoidOverlap){var E=p.length>0&&p[0].length>1,T=Math.min(s.w,s.h)/2-x,F=T/(p.length+E?1:0);x=Math.min(x,F)}for(var S=0,D=0;D<p.length;D++){var C=p[D],B=e.sweep===void 0?2*Math.PI-2*Math.PI/C.length:e.sweep,A=C.dTheta=B/Math.max(1,C.length-1);if(C.length>1&&e.avoidOverlap){var M=Math.cos(A)-Math.cos(0),I=Math.sin(A)-Math.sin(0),R=Math.sqrt(x*x/(M*M+I*I));S=Math.max(R,S)}C.r=S,S+=x}if(e.equidistant){for(var L=0,V=0,H=0;H<p.length;H++){var z=p[H],$=z.r-V;L=Math.max(L,$)}V=0;for(var K=0;K<p.length;K++){var Y=p[K];K===0&&(V=Y.r),Y.r=V,V+=L}}for(var Q={},Z=0;Z<p.length;Z++)for(var j=p[Z],re=j.dTheta,W=j.r,O=0;O<j.length;O++){var G=j[O],ee=e.startAngle+(t?1:-1)*re*O,ie={x:o.x+W*Math.cos(ee),y:o.y+W*Math.sin(ee)};Q[G.node.id()]=ie}return n.nodes().layoutPositions(this,e,function(ue){var Ce=ue.id();return Q[Ce]}),this};var Ii,l0={ready:function(){},stop:function(){},animate:!0,animationEasing:void 0,animationDuration:void 0,animateFilter:function(e,t){return!0},animationThreshold:250,refresh:20,fit:!0,padding:30,boundingBox:void 0,nodeDimensionsIncludeLabels:!1,randomize:!1,componentSpacing:40,nodeRepulsion:function(e){return 2048},nodeOverlap:4,idealEdgeLength:function(e){return 32},edgeElasticity:function(e){return 32},nestingFactor:1.2,gravity:1,numIter:1e3,initialTemp:1e3,coolingFactor:.99,minTemp:1};function An(r){this.options=ce({},l0,r),this.options.layout=this;var e=this.options.eles.nodes(),t=this.options.eles.edges(),a=t.filter(function(n){var i=n.source().data("id"),s=n.target().data("id"),o=e.some(function(l){return l.data("id")===i}),u=e.some(function(l){return l.data("id")===s});return!o||!u});this.options.eles=this.options.eles.not(a)}An.prototype.run=function(){var r=this.options,e=r.cy,t=this;t.stopped=!1,(r.animate===!0||r.animate===!1)&&t.emit({type:"layoutstart",layout:t}),r.debug===!0?Ii=!0:Ii=!1;var a=v0(e,t,r);Ii&&c0(a),r.randomize&&h0(a);var n=qr(),i=function(){g0(a,e,r),r.fit===!0&&e.fit(r.padding)},s=function(d){return!(t.stopped||d>=r.numIter||(p0(a,r),a.temperature=a.temperature*r.coolingFactor,a.temperature<r.minTemp))},o=function(){if(r.animate===!0||r.animate===!1)i(),t.one("layoutstop",r.stop),t.emit({type:"layoutstop",layout:t});else{var d=r.eles.nodes(),h=du(a,r,d);d.layoutPositions(t,r,h)}},u=0,l=!0;if(r.animate===!0){var v=function f(){for(var d=0;l&&d<r.refresh;)l=s(u),u++,d++;if(!l)hu(a,r),o();else{var h=qr();h-n>=r.animationThreshold&&i(),Xa(f)}};v()}else{for(;l;)l=s(u),u++;hu(a,r),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 v0=function(e,t,a){for(var n=a.eles.edges(),i=a.eles.nodes(),s=hr(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={},v=0;v<u.length;v++)for(var f=u[v],d=0;d<f.length;d++){var h=f[d];l[h.id()]=v}for(var v=0;v<o.nodeSize;v++){var c=i[v],m=c.layoutDimensions(a),g={};g.isLocked=c.locked(),g.id=c.data("id"),g.parentId=c.data("parent"),g.cmptId=l[c.id()],g.children=[],g.positionX=c.position("x"),g.positionY=c.position("y"),g.offsetX=0,g.offsetY=0,g.height=m.w,g.width=m.h,g.maxX=g.positionX+g.width/2,g.minX=g.positionX-g.width/2,g.maxY=g.positionY+g.height/2,g.minY=g.positionY-g.height/2,g.padLeft=parseFloat(c.style("padding")),g.padRight=parseFloat(c.style("padding")),g.padTop=parseFloat(c.style("padding")),g.padBottom=parseFloat(c.style("padding")),g.nodeRepulsion=ze(a.nodeRepulsion)?a.nodeRepulsion(c):a.nodeRepulsion,o.layoutNodes.push(g),o.idToIndex[g.id]=v}for(var p=[],y=0,w=-1,b=[],v=0;v<o.nodeSize;v++){var c=o.layoutNodes[v],k=c.parentId;k!=null?o.layoutNodes[o.idToIndex[k]].children.push(c.id):(p[++w]=c.id,b.push(c.id))}for(o.graphSet.push(b);y<=w;){var x=p[y++],E=o.idToIndex[x],h=o.layoutNodes[E],T=h.children;if(T.length>0){o.graphSet.push(T);for(var v=0;v<T.length;v++)p[++w]=T[v]}}for(var v=0;v<o.graphSet.length;v++)for(var F=o.graphSet[v],d=0;d<F.length;d++){var S=o.idToIndex[F[d]];o.indexToGraph[S]=v}for(var v=0;v<o.edgeSize;v++){var D=n[v],C={};C.id=D.data("id"),C.sourceId=D.data("source"),C.targetId=D.data("target");var B=ze(a.idealEdgeLength)?a.idealEdgeLength(D):a.idealEdgeLength,A=ze(a.edgeElasticity)?a.edgeElasticity(D):a.edgeElasticity,M=o.idToIndex[C.sourceId],I=o.idToIndex[C.targetId],R=o.indexToGraph[M],L=o.indexToGraph[I];if(R!=L){for(var V=f0(C.sourceId,C.targetId,o),H=o.graphSet[V],z=0,g=o.layoutNodes[M];H.indexOf(g.id)===-1;)g=o.layoutNodes[o.idToIndex[g.parentId]],z++;for(g=o.layoutNodes[I];H.indexOf(g.id)===-1;)g=o.layoutNodes[o.idToIndex[g.parentId]],z++;B*=z*a.nestingFactor}C.idealLength=B,C.elasticity=A,o.layoutEdges.push(C)}return o},f0=function(e,t,a){var n=d0(e,t,0,a);return 2>n.count?0:n.graph},d0=function r(e,t,a,n){var i=n.graphSet[a];if(-1<i.indexOf(e)&&-1<i.indexOf(t))return{count:2,graph:a};for(var s=0,o=0;o<i.length;o++){var u=i[o],l=n.idToIndex[u],v=n.layoutNodes[l].children;if(v.length!==0){var f=n.indexToGraph[n.idToIndex[v[0]]],d=r(e,t,f,n);if(d.count!==0)if(d.count===1){if(s++,s===2)break}else return d}}return{count:s,graph:a}},c0,h0=function(e,t){for(var a=e.clientWidth,n=e.clientHeight,i=0;i<e.nodeSize;i++){var s=e.layoutNodes[i];s.children.length===0&&!s.isLocked&&(s.positionX=Math.random()*a,s.positionY=Math.random()*n)}},du=function(e,t,a){var n=e.boundingBox,i={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0};return t.boundingBox&&(a.forEach(function(s){var o=e.layoutNodes[e.idToIndex[s.data("id")]];i.x1=Math.min(i.x1,o.positionX),i.x2=Math.max(i.x2,o.positionX),i.y1=Math.min(i.y1,o.positionY),i.y2=Math.max(i.y2,o.positionY)}),i.w=i.x2-i.x1,i.h=i.y2-i.y1),function(s,o){var u=e.layoutNodes[e.idToIndex[s.data("id")]];if(t.boundingBox){var l=(u.positionX-i.x1)/i.w,v=(u.positionY-i.y1)/i.h;return{x:n.x1+l*n.w,y:n.y1+v*n.h}}else return{x:u.positionX,y:u.positionY}}},g0=function(e,t,a){var n=a.layout,i=a.eles.nodes(),s=du(e,a,i);i.positions(s),e.ready!==!0&&(e.ready=!0,n.one("layoutready",a.ready),n.emit({type:"layoutready",layout:this}))},p0=function(e,t,a){m0(e,t),b0(e),F0(e,t),E0(e),x0(e)},m0=function(e,t){for(var a=0;a<e.graphSet.length;a++)for(var n=e.graphSet[a],i=n.length,s=0;s<i;s++)for(var o=e.layoutNodes[e.idToIndex[n[s]]],u=s+1;u<i;u++){var l=e.layoutNodes[e.idToIndex[n[u]]];y0(o,l,e,t)}},cu=function(e){return-e+2*e*Math.random()},y0=function(e,t,a,n){var i=e.cmptId,s=t.cmptId;if(!(i!==s&&!a.isCompound)){var o=t.positionX-e.positionX,u=t.positionY-e.positionY,l=1;o===0&&u===0&&(o=cu(l),u=cu(l));var v=w0(e,t,o,u);if(v>0)var f=n.nodeOverlap*v,d=Math.sqrt(o*o+u*u),h=f*o/d,c=f*u/d;else var m=In(e,o,u),g=In(t,-1*o,-1*u),p=g.x-m.x,y=g.y-m.y,w=p*p+y*y,d=Math.sqrt(w),f=(e.nodeRepulsion+t.nodeRepulsion)/w,h=f*p/d,c=f*y/d;e.isLocked||(e.offsetX-=h,e.offsetY-=c),t.isLocked||(t.offsetX+=h,t.offsetY+=c)}},w0=function(e,t,a,n){if(a>0)var i=e.maxX-t.minX;else var i=t.maxX-e.minX;if(n>0)var s=e.maxY-t.minY;else var s=t.maxY-e.minY;return i>=0&&s>=0?Math.sqrt(i*i+s*s):0},In=function(e,t,a){var n=e.positionX,i=e.positionY,s=e.height||1,o=e.width||1,u=a/t,l=s/o,v={};return t===0&&0<a||t===0&&0>a?(v.x=n,v.y=i+s/2,v):0<t&&-1*l<=u&&u<=l?(v.x=n+o/2,v.y=i+o*a/2/t,v):0>t&&-1*l<=u&&u<=l?(v.x=n-o/2,v.y=i-o*a/2/t,v):0<a&&(u<=-1*l||u>=l)?(v.x=n+s*t/2/a,v.y=i+s/2,v):(0>a&&(u<=-1*l||u>=l)&&(v.x=n-s*t/2/a,v.y=i-s/2),v)},b0=function(e,t){for(var a=0;a<e.edgeSize;a++){var n=e.layoutEdges[a],i=e.idToIndex[n.sourceId],s=e.layoutNodes[i],o=e.idToIndex[n.targetId],u=e.layoutNodes[o],l=u.positionX-s.positionX,v=u.positionY-s.positionY;if(!(l===0&&v===0)){var f=In(s,l,v),d=In(u,-1*l,-1*v),h=d.x-f.x,c=d.y-f.y,m=Math.sqrt(h*h+c*c),g=Math.pow(n.idealLength-m,2)/n.elasticity;if(m!==0)var p=g*h/m,y=g*c/m;else var p=0,y=0;s.isLocked||(s.offsetX+=p,s.offsetY+=y),u.isLocked||(u.offsetX-=p,u.offsetY-=y)}}},F0=function(e,t){if(t.gravity!==0)for(var a=1,n=0;n<e.graphSet.length;n++){var i=e.graphSet[n],s=i.length;if(n===0)var o=e.clientHeight/2,u=e.clientWidth/2;else var l=e.layoutNodes[e.idToIndex[i[0]]],v=e.layoutNodes[e.idToIndex[l.parentId]],o=v.positionX,u=v.positionY;for(var f=0;f<s;f++){var d=e.layoutNodes[e.idToIndex[i[f]]];if(!d.isLocked){var h=o-d.positionX,c=u-d.positionY,m=Math.sqrt(h*h+c*c);if(m>a){var g=t.gravity*h/m,p=t.gravity*c/m;d.offsetX+=g,d.offsetY+=p}}}}},E0=function(e,t){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(0<l.length&&!u.isLocked){for(var v=u.offsetX,f=u.offsetY,d=0;d<l.length;d++){var h=e.layoutNodes[e.idToIndex[l[d]]];h.offsetX+=v,h.offsetY+=f,a[++i]=l[d]}u.offsetX=0,u.offsetY=0}}},x0=function(e,t){for(var a=0;a<e.nodeSize;a++){var n=e.layoutNodes[a];0<n.children.length&&(n.maxX=void 0,n.minX=void 0,n.maxY=void 0,n.minY=void 0)}for(var a=0;a<e.nodeSize;a++){var n=e.layoutNodes[a];if(!(0<n.children.length||n.isLocked)){var i=C0(n.offsetX,n.offsetY,e.temperature);n.positionX+=i.x,n.positionY+=i.y,n.offsetX=0,n.offsetY=0,n.minX=n.positionX-n.width,n.maxX=n.positionX+n.width,n.minY=n.positionY-n.height,n.maxY=n.positionY+n.height,T0(n,e)}}for(var a=0;a<e.nodeSize;a++){var n=e.layoutNodes[a];0<n.children.length&&!n.isLocked&&(n.positionX=(n.maxX+n.minX)/2,n.positionY=(n.maxY+n.minY)/2,n.width=n.maxX-n.minX,n.height=n.maxY-n.minY)}},C0=function(e,t,a){var n=Math.sqrt(e*e+t*t);if(n>a)var i={x:a*e/n,y:a*t/n};else var i={x:e,y:t};return i},T0=function r(e,t){var a=e.parentId;if(a!=null){var n=t.layoutNodes[t.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.padLeft<n.minX)&&(n.minX=e.minX-n.padLeft,i=!0),(n.maxY==null||e.maxY+n.padBottom>n.maxY)&&(n.maxY=e.maxY+n.padBottom,i=!0),(n.minY==null||e.minY-n.padTop<n.minY)&&(n.minY=e.minY-n.padTop,i=!0),i)return r(n,t)}},hu=function(e,t){for(var a=e.layoutNodes,n=[],i=0;i<a.length;i++){var s=a[i],o=s.cmptId,u=n[o]=n[o]||[];u.push(s)}for(var l=0,i=0;i<n.length;i++){var v=n[i];if(v){v.x1=1/0,v.x2=-1/0,v.y1=1/0,v.y2=-1/0;for(var f=0;f<v.length;f++){var d=v[f];v.x1=Math.min(v.x1,d.positionX-d.width/2),v.x2=Math.max(v.x2,d.positionX+d.width/2),v.y1=Math.min(v.y1,d.positionY-d.height/2),v.y2=Math.max(v.y2,d.positionY+d.height/2)}v.w=v.x2-v.x1,v.h=v.y2-v.y1,l+=v.w*v.h}}n.sort(function(y,w){return w.w*w.h-y.w*y.h});for(var h=0,c=0,m=0,g=0,p=Math.sqrt(l)*e.clientWidth/e.clientHeight,i=0;i<n.length;i++){var v=n[i];if(v){for(var f=0;f<v.length;f++){var d=v[f];d.isLocked||(d.positionX+=h-v.x1,d.positionY+=c-v.y1)}h+=v.w+t.componentSpacing,m+=v.w+t.componentSpacing,g=Math.max(g,v.h),m>p&&(c+=g+t.componentSpacing,h=0,m=0,g=0)}}},S0={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function gu(r){this.options=ce({},S0,r)}gu.prototype.run=function(){var r=this.options,e=r,t=r.cy,a=e.eles,n=a.nodes().not(":parent");e.sort&&(n=n.sort(e.sort));var i=hr(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});if(i.h===0||i.w===0)a.nodes().layoutPositions(this,e,function(K){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),v=function(Y){if(Y==null)return Math.min(u,l);var Q=Math.min(u,l);Q==u?u=Y:l=Y},f=function(Y){if(Y==null)return Math.max(u,l);var Q=Math.max(u,l);Q==u?u=Y:l=Y},d=e.rows,h=e.cols!=null?e.cols:e.columns;if(d!=null&&h!=null)u=d,l=h;else if(d!=null&&h==null)u=d,l=Math.ceil(s/u);else if(d==null&&h!=null)l=h,u=Math.ceil(s/l);else if(l*u>s){var c=v(),m=f();(c-1)*m>=s?v(c-1):(m-1)*c>=s&&f(m-1)}else for(;l*u<s;){var g=v(),p=f();(p+1)*g>=s?f(p+1):v(g+1)}var y=i.w/l,w=i.h/u;if(e.condense&&(y=0,w=0),e.avoidOverlap)for(var b=0;b<n.length;b++){var k=n[b],x=k._private.position;(x.x==null||x.y==null)&&(x.x=0,x.y=0);var E=k.layoutDimensions(e),T=e.avoidOverlapPadding,F=E.w+T,S=E.h+T;y=Math.max(y,F),w=Math.max(w,S)}for(var D={},C=function(Y,Q){return!!D["c-"+Y+"-"+Q]},B=function(Y,Q){D["c-"+Y+"-"+Q]=!0},A=0,M=0,I=function(){M++,M>=l&&(M=0,A++)},R={},L=0;L<n.length;L++){var V=n[L],H=e.position(V);if(H&&(H.row!==void 0||H.col!==void 0)){var z={row:H.row,col:H.col};if(z.col===void 0)for(z.col=0;C(z.row,z.col);)z.col++;else if(z.row===void 0)for(z.row=0;C(z.row,z.col);)z.row++;R[V.id()]=z,B(z.row,z.col)}}var $=function(Y,Q){var Z,j;if(Y.locked()||Y.isParent())return!1;var re=R[Y.id()];if(re)Z=re.col*y+y/2+i.x1,j=re.row*w+w/2+i.y1;else{for(;C(A,M);)I();Z=M*y+y/2+i.x1,j=A*w+w/2+i.y1,B(A,M),I()}return{x:Z,y:j}};n.layoutPositions(this,e,$)}return this};var k0={ready:function(){},stop:function(){}};function Mi(r){this.options=ce({},k0,r)}Mi.prototype.run=function(){var r=this.options,e=r.eles,t=this;return r.cy,t.emit("layoutstart"),e.nodes().positions(function(){return{x:0,y:0}}),t.one("layoutready",r.ready),t.emit("layoutready"),t.one("layoutstop",r.stop),t.emit("layoutstop"),this},Mi.prototype.stop=function(){return this};var D0={positions:void 0,zoom:void 0,pan:void 0,fit:!0,padding:30,spacingFactor:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function pu(r){this.options=ce({},D0,r)}pu.prototype.run=function(){var r=this.options,e=r.eles,t=e.nodes(),a=ze(r.positions);function n(i){if(r.positions==null)return If(i.position());if(a)return r.positions(i);var s=r.positions[i._private.data.id];return s??null}return t.layoutPositions(this,r,function(i,s){var o=n(i);return i.locked()||o==null?!1:o}),this};var P0={fit:!0,padding:30,boundingBox:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function mu(r){this.options=ce({},P0,r)}mu.prototype.run=function(){var r=this.options,e=r.cy,t=r.eles,a=hr(r.boundingBox?r.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),n=function(s,o){return{x:a.x1+Math.round(Math.random()*a.w),y:a.y1+Math.round(Math.random()*a.h)}};return t.nodes().layoutPositions(this,r,n),this};var B0=[{name:"breadthfirst",impl:lu},{name:"circle",impl:vu},{name:"concentric",impl:fu},{name:"cose",impl:An},{name:"grid",impl:gu},{name:"null",impl:Mi},{name:"preset",impl:pu},{name:"random",impl:mu}];function yu(r){this.options=r,this.notifications=0}var wu=function(){},bu=function(){throw new Error("A headless instance can not render images")};yu.prototype={recalculateRenderedStyle:wu,notify:function(){this.notifications++},init:wu,isHeadless:function(){return!0},png:bu,jpg:bu};var Ri={};Ri.arrowShapeWidth=.3,Ri.registerArrowShapes=function(){var r=this.arrowShapes={},e=this,t=function(l,v,f,d,h,c,m){var g=h.x-f/2-m,p=h.x+f/2+m,y=h.y-f/2-m,w=h.y+f/2+m,b=g<=l&&l<=p&&y<=v&&v<=w;return b},a=function(l,v,f,d,h){var c=l*Math.cos(d)-v*Math.sin(d),m=l*Math.sin(d)+v*Math.cos(d),g=c*f,p=m*f,y=g+h.x,w=p+h.y;return{x:y,y:w}},n=function(l,v,f,d){for(var h=[],c=0;c<l.length;c+=2){var m=l[c],g=l[c+1];h.push(a(m,g,v,f,d))}return h},i=function(l){for(var v=[],f=0;f<l.length;f++){var d=l[f];v.push(d.x,d.y)}return v},s=function(l){return l.pstyle("width").pfValue*l.pstyle("arrow-scale").pfValue*2},o=function(l,v){fe(v)&&(v=r[v]),r[l]=ce({name:l,points:[-.15,-.3,.15,-.3,.15,.3,-.15,.3],collide:function(d,h,c,m,g,p){var y=i(n(this.points,c+2*p,m,g)),w=gr(d,h,y);return w},roughCollide:t,draw:function(d,h,c,m){var g=n(this.points,h,c,m);e.arrowShapeImpl("polygon")(d,g)},spacing:function(d){return 0},gap:s},v)};o("none",{collide:Za,roughCollide:Za,draw:ai,spacing:As,gap:As}),o("triangle",{points:[-.15,-.3,0,0,.15,-.3]}),o("arrow","triangle"),o("triangle-backcurve",{points:r.triangle.points,controlPoint:[0,-.15],roughCollide:t,draw:function(l,v,f,d,h){var c=n(this.points,v,f,d),m=this.controlPoint,g=a(m[0],m[1],v,f,d);e.arrowShapeImpl(this.name)(l,c,g)},gap:function(l){return s(l)*.8}}),o("triangle-tee",{points:[0,0,.15,-.3,-.15,-.3,0,0],pointsTee:[-.15,-.4,-.15,-.5,.15,-.5,.15,-.4],collide:function(l,v,f,d,h,c,m){var g=i(n(this.points,f+2*m,d,h)),p=i(n(this.pointsTee,f+2*m,d,h)),y=gr(l,v,g)||gr(l,v,p);return y},draw:function(l,v,f,d,h){var c=n(this.points,v,f,d),m=n(this.pointsTee,v,f,d);e.arrowShapeImpl(this.name)(l,c,m)}}),o("circle-triangle",{radius:.15,pointsTr:[0,-.15,.15,-.45,-.15,-.45,0,-.15],collide:function(l,v,f,d,h,c,m){var g=h,p=Math.pow(g.x-l,2)+Math.pow(g.y-v,2)<=Math.pow((f+2*m)*this.radius,2),y=i(n(this.points,f+2*m,d,h));return gr(l,v,y)||p},draw:function(l,v,f,d,h){var c=n(this.pointsTr,v,f,d);e.arrowShapeImpl(this.name)(l,c,d.x,d.y,this.radius*v)},spacing:function(l){return e.getArrowWidth(l.pstyle("width").pfValue,l.pstyle("arrow-scale").value)*this.radius}}),o("triangle-cross",{points:[0,0,.15,-.3,-.15,-.3,0,0],baseCrossLinePts:[-.15,-.4,-.15,-.4,.15,-.4,.15,-.4],crossLinePts:function(l,v){var f=this.baseCrossLinePts.slice(),d=v/l,h=3,c=5;return f[h]=f[h]-d,f[c]=f[c]-d,f},collide:function(l,v,f,d,h,c,m){var g=i(n(this.points,f+2*m,d,h)),p=i(n(this.crossLinePts(f,c),f+2*m,d,h)),y=gr(l,v,g)||gr(l,v,p);return y},draw:function(l,v,f,d,h){var c=n(this.points,v,f,d),m=n(this.crossLinePts(v,h),v,f,d);e.arrowShapeImpl(this.name)(l,c,m)}}),o("vee",{points:[-.15,-.3,0,0,.15,-.3,0,-.15],gap:function(l){return s(l)*.525}}),o("circle",{radius:.15,collide:function(l,v,f,d,h,c,m){var g=h,p=Math.pow(g.x-l,2)+Math.pow(g.y-v,2)<=Math.pow((f+2*m)*this.radius,2);return p},draw:function(l,v,f,d,h){e.arrowShapeImpl(this.name)(l,d.x,d.y,this.radius*v)},spacing:function(l){return e.getArrowWidth(l.pstyle("width").pfValue,l.pstyle("arrow-scale").value)*this.radius}}),o("tee",{points:[-.15,0,-.15,-.1,.15,-.1,.15,0],spacing:function(l){return 1},gap:function(l){return 1}}),o("square",{points:[-.15,0,.15,0,.15,-.3,-.15,-.3]}),o("diamond",{points:[-.15,-.15,0,-.3,.15,-.15,0,0],gap:function(l){return l.pstyle("width").pfValue*l.pstyle("arrow-scale").value}}),o("chevron",{points:[0,0,-.15,-.15,-.1,-.2,0,-.1,.1,-.2,.15,-.15],gap:function(l){return .95*l.pstyle("width").pfValue*l.pstyle("arrow-scale").value}})};var Et={};Et.projectIntoViewport=function(r,e){var t=this.cy,a=this.findContainerClientCoords(),n=a[0],i=a[1],s=a[4],o=t.pan(),u=t.zoom(),l=((r-n)/s-o.x)/u,v=((e-i)/s-o.y)/u;return[l,v]},Et.findContainerClientCoords=function(){if(this.containerBB)return this.containerBB;var r=this.container,e=r.getBoundingClientRect(),t=this.cy.window().getComputedStyle(r),a=function(p){return parseFloat(t.getPropertyValue(p))},n={left:a("padding-left"),right:a("padding-right"),top:a("padding-top"),bottom:a("padding-bottom")},i={left:a("border-left-width"),right:a("border-right-width"),top:a("border-top-width"),bottom:a("border-bottom-width")},s=r.clientWidth,o=r.clientHeight,u=n.left+n.right,l=n.top+n.bottom,v=i.left+i.right,f=e.width/(s+v),d=s-u,h=o-l,c=e.left+n.left+i.left,m=e.top+n.top+i.top;return this.containerBB=[c,m,d,h,f]},Et.invalidateContainerClientCoordsCache=function(){this.containerBB=null},Et.findNearestElement=function(r,e,t,a){return this.findNearestElements(r,e,t,a)[0]},Et.findNearestElements=function(r,e,t,a){var n=this,i=this,s=i.getCachedZSortedEles(),o=[],u=i.cy.zoom(),l=i.cy.hasCompoundNodes(),v=(a?24:8)/u,f=(a?8:2)/u,d=(a?8:2)/u,h=1/0,c,m;t&&(s=s.interactive);function g(E,T){if(E.isNode()){if(m)return;m=E,o.push(E)}if(E.isEdge()&&(T==null||T<h))if(c){if(c.pstyle("z-compound-depth").value===E.pstyle("z-compound-depth").value&&c.pstyle("z-compound-depth").value===E.pstyle("z-compound-depth").value){for(var F=0;F<o.length;F++)if(o[F].isEdge()){o[F]=E,c=E,h=T??h;break}}}else o.push(E),c=E,h=T??h}function p(E){var T=E.outerWidth()+2*f,F=E.outerHeight()+2*f,S=T/2,D=F/2,C=E.position(),B=E.pstyle("corner-radius").value==="auto"?"auto":E.pstyle("corner-radius").pfValue,A=E._private.rscratch;if(C.x-S<=r&&r<=C.x+S&&C.y-D<=e&&e<=C.y+D){var M=i.nodeShapes[n.getNodeShape(E)];if(M.checkPoint(r,e,0,T,F,C.x,C.y,B,A))return g(E,0),!0}}function y(E){var T=E._private,F=T.rscratch,S=E.pstyle("width").pfValue,D=E.pstyle("arrow-scale").value,C=S/2+v,B=C*C,A=C*2,L=T.source,V=T.target,M;if(F.edgeType==="segments"||F.edgeType==="straight"||F.edgeType==="haystack"){for(var I=F.allpts,R=0;R+3<I.length;R+=2)if(Gf(r,e,I[R],I[R+1],I[R+2],I[R+3],A)&&B>(M=Zf(r,e,I[R],I[R+1],I[R+2],I[R+3])))return g(E,M),!0}else if(F.edgeType==="bezier"||F.edgeType==="multibezier"||F.edgeType==="self"||F.edgeType==="compound"){for(var I=F.allpts,R=0;R+5<F.allpts.length;R+=4)if(Uf(r,e,I[R],I[R+1],I[R+2],I[R+3],I[R+4],I[R+5],A)&&B>(M=Yf(r,e,I[R],I[R+1],I[R+2],I[R+3],I[R+4],I[R+5])))return g(E,M),!0}for(var L=L||T.source,V=V||T.target,H=n.getArrowWidth(S,D),z=[{name:"source",x:F.arrowStartX,y:F.arrowStartY,angle:F.srcArrowAngle},{name:"target",x:F.arrowEndX,y:F.arrowEndY,angle:F.tgtArrowAngle},{name:"mid-source",x:F.midX,y:F.midY,angle:F.midsrcArrowAngle},{name:"mid-target",x:F.midX,y:F.midY,angle:F.midtgtArrowAngle}],R=0;R<z.length;R++){var $=z[R],K=i.arrowShapes[E.pstyle($.name+"-arrow-shape").value],Y=E.pstyle("width").pfValue;if(K.roughCollide(r,e,H,$.angle,{x:$.x,y:$.y},Y,v)&&K.collide(r,e,H,$.angle,{x:$.x,y:$.y},Y,v))return g(E),!0}l&&o.length>0&&(p(L),p(V))}function w(E,T,F){return Sr(E,T,F)}function b(E,T){var F=E._private,S=d,D;T?D=T+"-":D="",E.boundingBox();var C=F.labelBounds[T||"main"],B=E.pstyle(D+"label").value,A=E.pstyle("text-events").strValue==="yes";if(!(!A||!B)){var M=w(F.rscratch,"labelX",T),I=w(F.rscratch,"labelY",T),R=w(F.rscratch,"labelAngle",T),L=E.pstyle(D+"text-margin-x").pfValue,V=E.pstyle(D+"text-margin-y").pfValue,H=C.x1-S-L,z=C.x2+S-L,$=C.y1-S-V,K=C.y2+S-V;if(R){var Y=Math.cos(R),Q=Math.sin(R),Z=function(ie,ue){return ie=ie-M,ue=ue-I,{x:ie*Y-ue*Q+M,y:ie*Q+ue*Y+I}},j=Z(H,$),re=Z(H,K),W=Z(z,$),O=Z(z,K),G=[j.x+L,j.y+V,W.x+L,W.y+V,O.x+L,O.y+V,re.x+L,re.y+V];if(gr(r,e,G))return g(E),!0}else if(Rt(C,r,e))return g(E),!0}}for(var k=s.length-1;k>=0;k--){var x=s[k];x.isNode()?p(x)||b(x):y(x)||b(x)||b(x,"source")||b(x,"target")}return o},Et.getAllInBox=function(r,e,t,a){var n=this.getCachedZSortedEles().interactive,i=[],s=Math.min(r,t),o=Math.max(r,t),u=Math.min(e,a),l=Math.max(e,a);r=s,t=o,e=u,a=l;for(var v=hr({x1:r,y1:e,x2:t,y2:a}),f=0;f<n.length;f++){var d=n[f];if(d.isNode()){var h=d,c=h.boundingBox({includeNodes:!0,includeEdges:!1,includeLabels:!1});oi(v,c)&&!Vs(c,v)&&i.push(h)}else{var m=d,g=m._private,p=g.rscratch;if(p.startX!=null&&p.startY!=null&&!Rt(v,p.startX,p.startY)||p.endX!=null&&p.endY!=null&&!Rt(v,p.endX,p.endY))continue;if(p.edgeType==="bezier"||p.edgeType==="multibezier"||p.edgeType==="self"||p.edgeType==="compound"||p.edgeType==="segments"||p.edgeType==="haystack"){for(var y=g.rstyle.bezierPts||g.rstyle.linePts||g.rstyle.haystackPts,w=!0,b=0;b<y.length;b++)if(!Hf(v,y[b])){w=!1;break}w&&i.push(m)}else(p.edgeType==="haystack"||p.edgeType==="straight")&&i.push(m)}}return i};var Mn={};Mn.calculateArrowAngles=function(r){var e=r._private.rscratch,t=e.edgeType==="haystack",a=e.edgeType==="bezier",n=e.edgeType==="multibezier",i=e.edgeType==="segments",s=e.edgeType==="compound",o=e.edgeType==="self",u,l,v,f,d,h,p,y;if(t?(v=e.haystackPts[0],f=e.haystackPts[1],d=e.haystackPts[2],h=e.haystackPts[3]):(v=e.arrowStartX,f=e.arrowStartY,d=e.arrowEndX,h=e.arrowEndY),p=e.midX,y=e.midY,i)u=v-e.segpts[0],l=f-e.segpts[1];else if(n||s||o||a){var c=e.allpts,m=Ze(c[0],c[2],c[4],.1),g=Ze(c[1],c[3],c[5],.1);u=v-m,l=f-g}else u=v-p,l=f-y;e.srcArrowAngle=ja(u,l);var p=e.midX,y=e.midY;if(t&&(p=(v+d)/2,y=(f+h)/2),u=d-v,l=h-f,i){var c=e.allpts;if(c.length/2%2===0){var w=c.length/2,b=w-2;u=c[w]-c[b],l=c[w+1]-c[b+1]}else if(e.isRound)u=e.midVector[1],l=-e.midVector[0];else{var w=c.length/2-1,b=w-2;u=c[w]-c[b],l=c[w+1]-c[b+1]}}else if(n||s||o){var c=e.allpts,k=e.ctrlpts,x,E,T,F;if(k.length/2%2===0){var S=c.length/2-1,D=S+2,C=D+2;x=Ze(c[S],c[D],c[C],0),E=Ze(c[S+1],c[D+1],c[C+1],0),T=Ze(c[S],c[D],c[C],1e-4),F=Ze(c[S+1],c[D+1],c[C+1],1e-4)}else{var D=c.length/2-1,S=D-2,C=D+2;x=Ze(c[S],c[D],c[C],.4999),E=Ze(c[S+1],c[D+1],c[C+1],.4999),T=Ze(c[S],c[D],c[C],.5),F=Ze(c[S+1],c[D+1],c[C+1],.5)}u=T-x,l=F-E}if(e.midtgtArrowAngle=ja(u,l),e.midDispX=u,e.midDispY=l,u*=-1,l*=-1,i){var c=e.allpts;if(c.length/2%2!==0){if(!e.isRound){var w=c.length/2-1,B=w+2;u=-(c[B]-c[w]),l=-(c[B+1]-c[w+1])}}}if(e.midsrcArrowAngle=ja(u,l),i)u=d-e.segpts[e.segpts.length-2],l=h-e.segpts[e.segpts.length-1];else if(n||s||o||a){var c=e.allpts,A=c.length,m=Ze(c[A-6],c[A-4],c[A-2],.9),g=Ze(c[A-5],c[A-3],c[A-1],.9);u=d-m,l=h-g}else u=d-p,l=h-y;e.tgtArrowAngle=ja(u,l)},Mn.getArrowWidth=Mn.getArrowHeight=function(r,e){var t=this.arrowWidthCache=this.arrowWidthCache||{},a=t[r+", "+e];return a||(a=Math.max(Math.pow(r*13.37,.9),29)*e,t[r+", "+e]=a,a)};var Li,Oi,Lr={},Cr={},Fu,Eu,xt,Rn,Gr,Ct,Tt,Or,Zt,Ln,xu,Cu,_i,Ni,Tu,Su=function(e,t,a){a.x=t.x-e.x,a.y=t.y-e.y,a.len=Math.sqrt(a.x*a.x+a.y*a.y),a.nx=a.x/a.len,a.ny=a.y/a.len,a.ang=Math.atan2(a.ny,a.nx)},A0=function(e,t){t.x=e.x*-1,t.y=e.y*-1,t.nx=e.nx*-1,t.ny=e.ny*-1,t.ang=e.ang>0?-(Math.PI-e.ang):Math.PI+e.ang},I0=function(e,t,a,n,i){if(e!==Tu?Su(t,e,Lr):A0(Cr,Lr),Su(t,a,Cr),Fu=Lr.nx*Cr.ny-Lr.ny*Cr.nx,Eu=Lr.nx*Cr.nx-Lr.ny*-Cr.ny,Gr=Math.asin(Math.max(-1,Math.min(1,Fu))),Math.abs(Gr)<1e-6){Li=t.x,Oi=t.y,Tt=Zt=0;return}xt=1,Rn=!1,Eu<0?Gr<0?Gr=Math.PI+Gr:(Gr=Math.PI-Gr,xt=-1,Rn=!0):Gr>0&&(xt=-1,Rn=!0),t.radius!==void 0?Zt=t.radius:Zt=n,Ct=Gr/2,Ln=Math.min(Lr.len/2,Cr.len/2),i?(Or=Math.abs(Math.cos(Ct)*Zt/Math.sin(Ct)),Or>Ln?(Or=Ln,Tt=Math.abs(Or*Math.sin(Ct)/Math.cos(Ct))):Tt=Zt):(Or=Math.min(Ln,Zt),Tt=Math.abs(Or*Math.sin(Ct)/Math.cos(Ct))),_i=t.x+Cr.nx*Or,Ni=t.y+Cr.ny*Or,Li=_i-Cr.ny*Tt*xt,Oi=Ni+Cr.nx*Tt*xt,xu=t.x+Lr.nx*Or,Cu=t.y+Lr.ny*Or,Tu=t};function ku(r,e){e.radius===0?r.lineTo(e.cx,e.cy):r.arc(e.cx,e.cy,e.radius,e.startAngle,e.endAngle,e.counterClockwise)}function zi(r,e,t,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}:(I0(r,e,t,a,n),{cx:Li,cy:Oi,radius:Tt,startX:xu,startY:Cu,stopX:_i,stopY:Ni,startAngle:Lr.ang+Math.PI/2*xt,endAngle:Cr.ang-Math.PI/2*xt,counterClockwise:Rn})}var ur={};ur.findMidptPtsEtc=function(r,e){var t=e.posPts,a=e.intersectionPts,n=e.vectorNormInverse,i,s=r.pstyle("source-endpoint"),o=r.pstyle("target-endpoint"),u=s.units!=null&&o.units!=null,l=function(k,x,E,T){var F=T-x,S=E-k,D=Math.sqrt(S*S+F*F);return{x:-F/D,y:S/D}},v=r.pstyle("edge-distances").value;switch(v){case"node-position":i=t;break;case"intersection":i=a;break;case"endpoints":{if(u){var f=this.manualEndptToPx(r.source()[0],s),d=We(f,2),h=d[0],c=d[1],m=this.manualEndptToPx(r.target()[0],o),g=We(m,2),p=g[0],y=g[1],w={x1:h,y1:c,x2:p,y2:y};n=l(h,c,p,y),i=w}else Pe("Edge ".concat(r.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}},ur.findHaystackPoints=function(r){for(var e=0;e<r.length;e++){var t=r[e],a=t._private,n=a.rscratch;if(!n.haystack){var i=Math.random()*2*Math.PI;n.source={x:Math.cos(i),y:Math.sin(i)},i=Math.random()*2*Math.PI,n.target={x:Math.cos(i),y:Math.sin(i)}}var s=a.source,o=a.target,u=s.position(),l=o.position(),v=s.width(),f=o.width(),d=s.height(),h=o.height(),c=t.pstyle("haystack-radius").value,m=c/2;n.haystackPts=n.allpts=[n.source.x*v*m+u.x,n.source.y*d*m+u.y,n.target.x*f*m+l.x,n.target.y*h*m+l.y],n.midX=(n.allpts[0]+n.allpts[2])/2,n.midY=(n.allpts[1]+n.allpts[3])/2,n.edgeType="haystack",n.haystack=!0,this.storeEdgeProjections(t),this.calculateArrowAngles(t),this.recalculateEdgeLabelProjections(t),this.calculateLabelAngles(t)}},ur.findSegmentsPoints=function(r,e){var t=r._private.rscratch,a=r.pstyle("segment-weights"),n=r.pstyle("segment-distances"),i=r.pstyle("segment-radii"),s=r.pstyle("radius-type"),o=Math.min(a.pfValue.length,n.pfValue.length),u=i.pfValue[i.pfValue.length-1],l=s.pfValue[s.pfValue.length-1];t.edgeType="segments",t.segpts=[],t.radii=[],t.isArcRadius=[];for(var v=0;v<o;v++){var f=a.pfValue[v],d=n.pfValue[v],h=1-f,c=f,m=this.findMidptPtsEtc(r,e),g=m.midptPts,p=m.vectorNormInverse,y={x:g.x1*h+g.x2*c,y:g.y1*h+g.y2*c};t.segpts.push(y.x+p.x*d,y.y+p.y*d),t.radii.push(i.pfValue[v]!==void 0?i.pfValue[v]:u),t.isArcRadius.push((s.pfValue[v]!==void 0?s.pfValue[v]:l)==="arc-radius")}},ur.findLoopPoints=function(r,e,t,a){var n=r._private.rscratch,i=e.dirCounts,s=e.srcPos,o=r.pstyle("control-point-distances"),u=o?o.pfValue[0]:void 0,l=r.pstyle("loop-direction").pfValue,v=r.pstyle("loop-sweep").pfValue,f=r.pstyle("control-point-step-size").pfValue;n.edgeType="self";var d=t,h=f;a&&(d=0,h=u);var c=l-Math.PI/2,m=c-v/2,g=c+v/2,p=l+"_"+v;d=i[p]===void 0?i[p]=0:++i[p],n.ctrlpts=[s.x+Math.cos(m)*1.4*h*(d/3+1),s.y+Math.sin(m)*1.4*h*(d/3+1),s.x+Math.cos(g)*1.4*h*(d/3+1),s.y+Math.sin(g)*1.4*h*(d/3+1)]},ur.findCompoundLoopPoints=function(r,e,t,a){var n=r._private.rscratch;n.edgeType="compound";var i=e.srcPos,s=e.tgtPos,o=e.srcW,u=e.srcH,l=e.tgtW,v=e.tgtH,f=r.pstyle("control-point-step-size").pfValue,d=r.pstyle("control-point-distances"),h=d?d.pfValue[0]:void 0,c=t,m=f;a&&(c=0,m=h);var g=50,p={x:i.x-o/2,y:i.y-u/2},y={x:s.x-l/2,y:s.y-v/2},w={x:Math.min(p.x,y.x),y:Math.min(p.y,y.y)},b=.5,k=Math.max(b,Math.log(o*.01)),x=Math.max(b,Math.log(l*.01));n.ctrlpts=[w.x,w.y-(1+Math.pow(g,1.12)/100)*m*(c/3+1)*k,w.x-(1+Math.pow(g,1.12)/100)*m*(c/3+1)*x,w.y]},ur.findStraightEdgePoints=function(r){r._private.rscratch.edgeType="straight"},ur.findBezierPoints=function(r,e,t,a,n){var i=r._private.rscratch,s=r.pstyle("control-point-step-size").pfValue,o=r.pstyle("control-point-distances"),u=r.pstyle("control-point-weights"),l=o&&u?Math.min(o.value.length,u.value.length):1,v=o?o.pfValue[0]:void 0,f=u.value[0],d=a;i.edgeType=d?"multibezier":"bezier",i.ctrlpts=[];for(var h=0;h<l;h++){var c=(.5-e.eles.length/2+t)*s*(n?-1:1),m=void 0,g=_s(c);d&&(v=o?o.pfValue[h]:s,f=u.value[h]),a?m=v:m=v!==void 0?g*v:void 0;var p=m!==void 0?m:c,y=1-f,w=f,b=this.findMidptPtsEtc(r,e),k=b.midptPts,x=b.vectorNormInverse,E={x:k.x1*y+k.x2*w,y:k.y1*y+k.y2*w};i.ctrlpts.push(E.x+x.x*p,E.y+x.y*p)}},ur.findTaxiPoints=function(r,e){var t=r._private.rscratch;t.edgeType="segments";var a="vertical",n="horizontal",i="leftward",s="rightward",o="downward",u="upward",l="auto",v=e.posPts,f=e.srcW,d=e.srcH,h=e.tgtW,c=e.tgtH,m=r.pstyle("edge-distances").value,g=m!=="node-position",p=r.pstyle("taxi-direction").value,y=p,w=r.pstyle("taxi-turn"),b=w.units==="%",k=w.pfValue,x=k<0,E=r.pstyle("taxi-turn-min-distance").pfValue,T=g?(f+h)/2:0,F=g?(d+c)/2:0,S=v.x2-v.x1,D=v.y2-v.y1,C=function(X,ne){return X>0?Math.max(X-ne,0):Math.min(X+ne,0)},B=C(S,T),A=C(D,F),M=!1;y===l?p=Math.abs(B)>Math.abs(A)?n:a:y===u||y===o?(p=a,M=!0):(y===i||y===s)&&(p=n,M=!0);var I=p===a,R=I?A:B,L=I?D:S,V=_s(L),H=!1;!(M&&(b||x))&&(y===o&&L<0||y===u&&L>0||y===i&&L>0||y===s&&L<0)&&(V*=-1,R=V*Math.abs(R),H=!0);var z;if(b){var $=k<0?1+k:k;z=$*R}else{var K=k<0?R:0;z=K+k*V}var Y=function(X){return Math.abs(X)<E||Math.abs(X)>=Math.abs(R)},Q=Y(z),Z=Y(Math.abs(R)-Math.abs(z)),j=Q||Z;if(j&&!H)if(I){var re=Math.abs(L)<=d/2,W=Math.abs(S)<=h/2;if(re){var O=(v.x1+v.x2)/2,G=v.y1,ee=v.y2;t.segpts=[O,G,O,ee]}else if(W){var ie=(v.y1+v.y2)/2,ue=v.x1,Ce=v.x2;t.segpts=[ue,ie,Ce,ie]}else t.segpts=[v.x1,v.y2]}else{var Ae=Math.abs(L)<=f/2,Ie=Math.abs(D)<=c/2;if(Ae){var le=(v.y1+v.y2)/2,oe=v.x1,pe=v.x2;t.segpts=[oe,le,pe,le]}else if(Ie){var me=(v.x1+v.x2)/2,he=v.y1,ye=v.y2;t.segpts=[me,he,me,ye]}else t.segpts=[v.x2,v.y1]}else if(I){var Ee=v.y1+z+(g?d/2*V:0),Te=v.x1,J=v.x2;t.segpts=[Te,Ee,J,Ee]}else{var P=v.x1+z+(g?f/2*V:0),_=v.y1,U=v.y2;t.segpts=[P,_,P,U]}if(t.isRound){var N=r.pstyle("taxi-radius").value,q=r.pstyle("radius-type").value[0]==="arc-radius";t.radii=new Array(t.segpts.length/2).fill(N),t.isArcRadius=new Array(t.segpts.length/2).fill(q)}},ur.tryToCorrectInvalidPoints=function(r,e){var t=r._private.rscratch;if(t.edgeType==="bezier"){var a=e.srcPos,n=e.tgtPos,i=e.srcW,s=e.srcH,o=e.tgtW,u=e.tgtH,l=e.srcShape,v=e.tgtShape,f=e.srcCornerRadius,d=e.tgtCornerRadius,h=e.srcRs,c=e.tgtRs,m=!te(t.startX)||!te(t.startY),g=!te(t.arrowStartX)||!te(t.arrowStartY),p=!te(t.endX)||!te(t.endY),y=!te(t.arrowEndX)||!te(t.arrowEndY),w=3,b=this.getArrowWidth(r.pstyle("width").pfValue,r.pstyle("arrow-scale").value)*this.arrowShapeWidth,k=w*b,x=gt({x:t.ctrlpts[0],y:t.ctrlpts[1]},{x:t.startX,y:t.startY}),E=x<k,T=gt({x:t.ctrlpts[0],y:t.ctrlpts[1]},{x:t.endX,y:t.endY}),F=T<k,S=!1;if(m||g||E){S=!0;var D={x:t.ctrlpts[0]-a.x,y:t.ctrlpts[1]-a.y},C=Math.sqrt(D.x*D.x+D.y*D.y),B={x:D.x/C,y:D.y/C},A=Math.max(i,s),M={x:t.ctrlpts[0]+B.x*2*A,y:t.ctrlpts[1]+B.y*2*A},I=l.intersectLine(a.x,a.y,i,s,M.x,M.y,0,f,h);E?(t.ctrlpts[0]=t.ctrlpts[0]+B.x*(k-x),t.ctrlpts[1]=t.ctrlpts[1]+B.y*(k-x)):(t.ctrlpts[0]=I[0]+B.x*k,t.ctrlpts[1]=I[1]+B.y*k)}if(p||y||F){S=!0;var R={x:t.ctrlpts[0]-n.x,y:t.ctrlpts[1]-n.y},L=Math.sqrt(R.x*R.x+R.y*R.y),V={x:R.x/L,y:R.y/L},H=Math.max(i,s),z={x:t.ctrlpts[0]+V.x*2*H,y:t.ctrlpts[1]+V.y*2*H},$=v.intersectLine(n.x,n.y,o,u,z.x,z.y,0,d,c);F?(t.ctrlpts[0]=t.ctrlpts[0]+V.x*(k-T),t.ctrlpts[1]=t.ctrlpts[1]+V.y*(k-T)):(t.ctrlpts[0]=$[0]+V.x*k,t.ctrlpts[1]=$[1]+V.y*k)}S&&this.findEndpoints(r)}},ur.storeAllpts=function(r){var e=r._private.rscratch;if(e.edgeType==="multibezier"||e.edgeType==="bezier"||e.edgeType==="self"||e.edgeType==="compound"){e.allpts=[],e.allpts.push(e.startX,e.startY);for(var t=0;t+1<e.ctrlpts.length;t+=2)e.allpts.push(e.ctrlpts[t],e.ctrlpts[t+1]),t+3<e.ctrlpts.length&&e.allpts.push((e.ctrlpts[t]+e.ctrlpts[t+2])/2,(e.ctrlpts[t+1]+e.ctrlpts[t+3])/2);e.allpts.push(e.endX,e.endY);var a,n;e.ctrlpts.length/2%2===0?(a=e.allpts.length/2-1,e.midX=e.allpts[a],e.midY=e.allpts[a+1]):(a=e.allpts.length/2-3,n=.5,e.midX=Ze(e.allpts[a],e.allpts[a+2],e.allpts[a+4],n),e.midY=Ze(e.allpts[a+1],e.allpts[a+3],e.allpts[a+5],n))}else if(e.edgeType==="straight")e.allpts=[e.startX,e.startY,e.endX,e.endY],e.midX=(e.startX+e.endX+e.arrowStartX+e.arrowEndX)/4,e.midY=(e.startY+e.endY+e.arrowStartY+e.arrowEndY)/4;else if(e.edgeType==="segments"){if(e.allpts=[],e.allpts.push(e.startX,e.startY),e.allpts.push.apply(e.allpts,e.segpts),e.allpts.push(e.endX,e.endY),e.isRound){e.roundCorners=[];for(var i=2;i+3<e.allpts.length;i+=2){var s=e.radii[i/2-1],o=e.isArcRadius[i/2-1];e.roundCorners.push(zi({x:e.allpts[i-2],y:e.allpts[i-1]},{x:e.allpts[i],y:e.allpts[i+1],radius:s},{x:e.allpts[i+2],y:e.allpts[i+3]},s,o))}}if(e.segpts.length%4===0){var u=e.segpts.length/2,l=u-2;e.midX=(e.segpts[l]+e.segpts[u])/2,e.midY=(e.segpts[l+1]+e.segpts[u+1])/2}else{var v=e.segpts.length/2-1;if(!e.isRound)e.midX=e.segpts[v],e.midY=e.segpts[v+1];else{var f={x:e.segpts[v],y:e.segpts[v+1]},d=e.roundCorners[v/2],h=[f.x-d.cx,f.y-d.cy],c=d.radius/Math.sqrt(Math.pow(h[0],2)+Math.pow(h[1],2));h=h.map(function(m){return m*c}),e.midX=d.cx+h[0],e.midY=d.cy+h[1],e.midVector=h}}}},ur.checkForInvalidEdgeWarning=function(r){var e=r[0]._private.rscratch;e.nodesOverlap||te(e.startX)&&te(e.startY)&&te(e.endX)&&te(e.endY)?e.loggedErr=!1:e.loggedErr||(e.loggedErr=!0,Pe("Edge `"+r.id()+"` has invalid endpoints and so it is impossible to draw.  Adjust your edge style (e.g. control points) accordingly or use an alternative edge type.  This is expected behaviour when the source node and the target node overlap."))},ur.findEdgeControlPoints=function(r){var e=this;if(!(!r||r.length===0)){for(var t=this,a=t.cy,n=a.hasCompoundNodes(),i={map:new Mr,get:function(E){var T=this.map.get(E[0]);return T!=null?T.get(E[1]):null},set:function(E,T){var F=this.map.get(E[0]);F==null&&(F=new Mr,this.map.set(E[0],F)),F.set(E[1],T)}},s=[],o=[],u=0;u<r.length;u++){var l=r[u],v=l._private,f=l.pstyle("curve-style").value;if(!(l.removed()||!l.takesUpSpace())){if(f==="haystack"){o.push(l);continue}var d=f==="unbundled-bezier"||f.endsWith("segments")||f==="straight"||f==="straight-triangle"||f.endsWith("taxi"),h=f==="unbundled-bezier"||f==="bezier",c=v.source,m=v.target,g=c.poolIndex(),p=m.poolIndex(),y=[g,p].sort(),w=i.get(y);w==null&&(w={eles:[]},i.set(y,w),s.push(y)),w.eles.push(l),d&&(w.hasUnbundled=!0),h&&(w.hasBezier=!0)}}for(var b=function(E){var T=s[E],F=i.get(T),S=void 0;if(!F.hasUnbundled){var D=F.eles[0].parallelEdges().filter(function(P){return P.isBundledBezier()});ni(F.eles),D.forEach(function(P){return F.eles.push(P)}),F.eles.sort(function(P,_){return P.poolIndex()-_.poolIndex()})}var C=F.eles[0],B=C.source(),A=C.target();if(B.poolIndex()>A.poolIndex()){var M=B;B=A,A=M}var I=F.srcPos=B.position(),R=F.tgtPos=A.position(),L=F.srcW=B.outerWidth(),V=F.srcH=B.outerHeight(),H=F.tgtW=A.outerWidth(),z=F.tgtH=A.outerHeight(),$=F.srcShape=t.nodeShapes[e.getNodeShape(B)],K=F.tgtShape=t.nodeShapes[e.getNodeShape(A)],Y=F.srcCornerRadius=B.pstyle("corner-radius").value==="auto"?"auto":B.pstyle("corner-radius").pfValue,Q=F.tgtCornerRadius=A.pstyle("corner-radius").value==="auto"?"auto":A.pstyle("corner-radius").pfValue,Z=F.tgtRs=A._private.rscratch,j=F.srcRs=B._private.rscratch;F.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var re=0;re<F.eles.length;re++){var W=F.eles[re],O=W[0]._private.rscratch,G=W.pstyle("curve-style").value,ee=G==="unbundled-bezier"||G.endsWith("segments")||G.endsWith("taxi"),ie=!B.same(W.source());if(!F.calculatedIntersection&&B!==A&&(F.hasBezier||F.hasUnbundled)){F.calculatedIntersection=!0;var ue=$.intersectLine(I.x,I.y,L,V,R.x,R.y,0,Y,j),Ce=F.srcIntn=ue,Ae=K.intersectLine(R.x,R.y,H,z,I.x,I.y,0,Q,Z),Ie=F.tgtIntn=Ae,le=F.intersectionPts={x1:ue[0],x2:Ae[0],y1:ue[1],y2:Ae[1]},oe=F.posPts={x1:I.x,x2:R.x,y1:I.y,y2:R.y},pe=Ae[1]-ue[1],me=Ae[0]-ue[0],he=Math.sqrt(me*me+pe*pe),ye=F.vector={x:me,y:pe},Ee=F.vectorNorm={x:ye.x/he,y:ye.y/he},Te={x:-Ee.y,y:Ee.x};F.nodesOverlap=!te(he)||K.checkPoint(ue[0],ue[1],0,H,z,R.x,R.y,Q,Z)||$.checkPoint(Ae[0],Ae[1],0,L,V,I.x,I.y,Y,j),F.vectorNormInverse=Te,S={nodesOverlap:F.nodesOverlap,dirCounts:F.dirCounts,calculatedIntersection:!0,hasBezier:F.hasBezier,hasUnbundled:F.hasUnbundled,eles:F.eles,srcPos:R,srcRs:Z,tgtPos:I,tgtRs:j,srcW:H,srcH:z,tgtW:L,tgtH:V,srcIntn:Ie,tgtIntn:Ce,srcShape:K,tgtShape:$,posPts:{x1:oe.x2,y1:oe.y2,x2:oe.x1,y2:oe.y1},intersectionPts:{x1:le.x2,y1:le.y2,x2:le.x1,y2:le.y1},vector:{x:-ye.x,y:-ye.y},vectorNorm:{x:-Ee.x,y:-Ee.y},vectorNormInverse:{x:-Te.x,y:-Te.y}}}var J=ie?S:F;O.nodesOverlap=J.nodesOverlap,O.srcIntn=J.srcIntn,O.tgtIntn=J.tgtIntn,O.isRound=G.startsWith("round"),n&&(B.isParent()||B.isChild()||A.isParent()||A.isChild())&&(B.parents().anySame(A)||A.parents().anySame(B)||B.same(A)&&B.isParent())?e.findCompoundLoopPoints(W,J,re,ee):B===A?e.findLoopPoints(W,J,re,ee):G.endsWith("segments")?e.findSegmentsPoints(W,J):G.endsWith("taxi")?e.findTaxiPoints(W,J):G==="straight"||!ee&&F.eles.length%2===1&&re===Math.floor(F.eles.length/2)?e.findStraightEdgePoints(W):e.findBezierPoints(W,J,re,ee,ie),e.findEndpoints(W),e.tryToCorrectInvalidPoints(W,J),e.checkForInvalidEdgeWarning(W),e.storeAllpts(W),e.storeEdgeProjections(W),e.calculateArrowAngles(W),e.recalculateEdgeLabelProjections(W),e.calculateLabelAngles(W)}},k=0;k<s.length;k++)b(k);this.findHaystackPoints(o)}};function Du(r){var e=[];if(r!=null){for(var t=0;t<r.length;t+=2){var a=r[t],n=r[t+1];e.push({x:a,y:n})}return e}}ur.getSegmentPoints=function(r){var e=r[0]._private.rscratch;this.recalculateRenderedStyle(r);var t=e.edgeType;if(t==="segments")return Du(e.segpts)},ur.getControlPoints=function(r){var e=r[0]._private.rscratch;this.recalculateRenderedStyle(r);var t=e.edgeType;if(t==="bezier"||t==="multibezier"||t==="self"||t==="compound")return Du(e.ctrlpts)},ur.getEdgeMidpoint=function(r){var e=r[0]._private.rscratch;return this.recalculateRenderedStyle(r),{x:e.midX,y:e.midY}};var Ia={};Ia.manualEndptToPx=function(r,e){var t=this,a=r.position(),n=r.outerWidth(),i=r.outerHeight(),s=r._private.rscratch;if(e.value.length===2){var o=[e.pfValue[0],e.pfValue[1]];return e.units[0]==="%"&&(o[0]=o[0]*n),e.units[1]==="%"&&(o[1]=o[1]*i),o[0]+=a.x,o[1]+=a.y,o}else{var u=e.pfValue[0];u=-Math.PI/2+u;var l=2*Math.max(n,i),v=[a.x+Math.cos(u)*l,a.y+Math.sin(u)*l];return t.nodeShapes[this.getNodeShape(r)].intersectLine(a.x,a.y,n,i,v[0],v[1],0,r.pstyle("corner-radius").value==="auto"?"auto":r.pstyle("corner-radius").pfValue,s)}},Ia.findEndpoints=function(r){var e=this,t,a=r.source()[0],n=r.target()[0],i=a.position(),s=n.position(),o=r.pstyle("target-arrow-shape").value,u=r.pstyle("source-arrow-shape").value,l=r.pstyle("target-distance-from-node").pfValue,v=r.pstyle("source-distance-from-node").pfValue,f=a._private.rscratch,d=n._private.rscratch,h=r.pstyle("curve-style").value,c=r._private.rscratch,m=c.edgeType,g=h==="taxi",p=m==="self"||m==="compound",y=m==="bezier"||m==="multibezier"||p,w=m!=="bezier",b=m==="straight"||m==="segments",k=m==="segments",x=y||w||b,E=p||g,T=r.pstyle("source-endpoint"),F=E?"outside-to-node":T.value,S=a.pstyle("corner-radius").value==="auto"?"auto":a.pstyle("corner-radius").pfValue,D=r.pstyle("target-endpoint"),C=E?"outside-to-node":D.value,B=n.pstyle("corner-radius").value==="auto"?"auto":n.pstyle("corner-radius").pfValue;c.srcManEndpt=T,c.tgtManEndpt=D;var A,M,I,R;if(y){var L=[c.ctrlpts[0],c.ctrlpts[1]],V=w?[c.ctrlpts[c.ctrlpts.length-2],c.ctrlpts[c.ctrlpts.length-1]]:L;A=V,M=L}else if(b){var H=k?c.segpts.slice(0,2):[s.x,s.y],z=k?c.segpts.slice(c.segpts.length-2):[i.x,i.y];A=z,M=H}if(C==="inside-to-node")t=[s.x,s.y];else if(D.units)t=this.manualEndptToPx(n,D);else if(C==="outside-to-line")t=c.tgtIntn;else if(C==="outside-to-node"||C==="outside-to-node-or-label"?I=A:(C==="outside-to-line"||C==="outside-to-line-or-label")&&(I=[i.x,i.y]),t=e.nodeShapes[this.getNodeShape(n)].intersectLine(s.x,s.y,n.outerWidth(),n.outerHeight(),I[0],I[1],0,B,d),C==="outside-to-node-or-label"||C==="outside-to-line-or-label"){var $=n._private.rscratch,K=$.labelWidth,Y=$.labelHeight,Q=$.labelX,Z=$.labelY,j=K/2,re=Y/2,W=n.pstyle("text-valign").value;W==="top"?Z-=re:W==="bottom"&&(Z+=re);var O=n.pstyle("text-halign").value;O==="left"?Q-=j:O==="right"&&(Q+=j);var G=ya(I[0],I[1],[Q-j,Z-re,Q+j,Z-re,Q+j,Z+re,Q-j,Z+re],s.x,s.y);if(G.length>0){var ee=i,ie=pt(ee,It(t)),ue=pt(ee,It(G)),Ce=ie;if(ue<ie&&(t=G,Ce=ue),G.length>2){var Ae=pt(ee,{x:G[2],y:G[3]});Ae<Ce&&(t=[G[2],G[3]])}}}var Ie=nn(t,A,e.arrowShapes[o].spacing(r)+l),le=nn(t,A,e.arrowShapes[o].gap(r)+l);if(c.endX=le[0],c.endY=le[1],c.arrowEndX=Ie[0],c.arrowEndY=Ie[1],F==="inside-to-node")t=[i.x,i.y];else if(T.units)t=this.manualEndptToPx(a,T);else if(F==="outside-to-line")t=c.srcIntn;else if(F==="outside-to-node"||F==="outside-to-node-or-label"?R=M:(F==="outside-to-line"||F==="outside-to-line-or-label")&&(R=[s.x,s.y]),t=e.nodeShapes[this.getNodeShape(a)].intersectLine(i.x,i.y,a.outerWidth(),a.outerHeight(),R[0],R[1],0,S,f),F==="outside-to-node-or-label"||F==="outside-to-line-or-label"){var oe=a._private.rscratch,pe=oe.labelWidth,me=oe.labelHeight,he=oe.labelX,ye=oe.labelY,Ee=pe/2,Te=me/2,J=a.pstyle("text-valign").value;J==="top"?ye-=Te:J==="bottom"&&(ye+=Te);var P=a.pstyle("text-halign").value;P==="left"?he-=Ee:P==="right"&&(he+=Ee);var _=ya(R[0],R[1],[he-Ee,ye-Te,he+Ee,ye-Te,he+Ee,ye+Te,he-Ee,ye+Te],i.x,i.y);if(_.length>0){var U=s,N=pt(U,It(t)),q=pt(U,It(_)),ae=N;if(q<N&&(t=[_[0],_[1]],ae=q),_.length>2){var X=pt(U,{x:_[2],y:_[3]});X<ae&&(t=[_[2],_[3]])}}}var ne=nn(t,M,e.arrowShapes[u].spacing(r)+v),de=nn(t,M,e.arrowShapes[u].gap(r)+v);c.startX=de[0],c.startY=de[1],c.arrowStartX=ne[0],c.arrowStartY=ne[1],x&&(!te(c.startX)||!te(c.startY)||!te(c.endX)||!te(c.endY)?c.badLine=!0:c.badLine=!1)},Ia.getSourceEndpoint=function(r){var e=r[0]._private.rscratch;switch(this.recalculateRenderedStyle(r),e.edgeType){case"haystack":return{x:e.haystackPts[0],y:e.haystackPts[1]};default:return{x:e.arrowStartX,y:e.arrowStartY}}},Ia.getTargetEndpoint=function(r){var e=r[0]._private.rscratch;switch(this.recalculateRenderedStyle(r),e.edgeType){case"haystack":return{x:e.haystackPts[2],y:e.haystackPts[3]};default:return{x:e.arrowEndX,y:e.arrowEndY}}};var Vi={};function M0(r,e,t){for(var a=function(l,v,f,d){return Ze(l,v,f,d)},n=e._private,i=n.rstyle.bezierPts,s=0;s<r.bezierProjPcts.length;s++){var o=r.bezierProjPcts[s];i.push({x:a(t[0],t[2],t[4],o),y:a(t[1],t[3],t[5],o)})}}Vi.storeEdgeProjections=function(r){var e=r._private,t=e.rscratch,a=t.edgeType;if(e.rstyle.bezierPts=null,e.rstyle.linePts=null,e.rstyle.haystackPts=null,a==="multibezier"||a==="bezier"||a==="self"||a==="compound"){e.rstyle.bezierPts=[];for(var n=0;n+5<t.allpts.length;n+=4)M0(this,r,t.allpts.slice(n,n+6))}else if(a==="segments")for(var i=e.rstyle.linePts=[],n=0;n+1<t.allpts.length;n+=2)i.push({x:t.allpts[n],y:t.allpts[n+1]});else if(a==="haystack"){var s=t.haystackPts;e.rstyle.haystackPts=[{x:s[0],y:s[1]},{x:s[2],y:s[3]}]}e.rstyle.arrowWidth=this.getArrowWidth(r.pstyle("width").pfValue,r.pstyle("arrow-scale").value)*this.arrowShapeWidth},Vi.recalculateEdgeProjections=function(r){this.findEdgeControlPoints(r)};var _r={};_r.recalculateNodeLabelProjection=function(r){var e=r.pstyle("label").strValue;if(!Jr(e)){var t,a,n=r._private,i=r.width(),s=r.height(),o=r.padding(),u=r.position(),l=r.pstyle("text-halign").strValue,v=r.pstyle("text-valign").strValue,f=n.rscratch,d=n.rstyle;switch(l){case"left":t=u.x-i/2-o;break;case"right":t=u.x+i/2+o;break;default:t=u.x}switch(v){case"top":a=u.y-s/2-o;break;case"bottom":a=u.y+s/2+o;break;default:a=u.y}f.labelX=t,f.labelY=a,d.labelX=t,d.labelY=a,this.calculateLabelAngles(r),this.applyLabelDimensions(r)}};var Pu=function(e,t){var a=Math.atan(t/e);return e===0&&a<0&&(a=a*-1),a},Bu=function(e,t){var a=t.x-e.x,n=t.y-e.y;return Pu(a,n)},R0=function(e,t,a,n){var i=pa(0,n-.001,1),s=pa(0,n+.001,1),o=Mt(e,t,a,i),u=Mt(e,t,a,s);return Bu(o,u)};_r.recalculateEdgeLabelProjections=function(r){var e,t=r._private,a=t.rscratch,n=this,i={mid:r.pstyle("label").strValue,source:r.pstyle("source-label").strValue,target:r.pstyle("target-label").strValue};if(i.mid||i.source||i.target){e={x:a.midX,y:a.midY};var s=function(f,d,h){tt(t.rscratch,f,d,h),tt(t.rstyle,f,d,h)};s("labelX",null,e.x),s("labelY",null,e.y);var o=Pu(a.midDispX,a.midDispY);s("labelAutoAngle",null,o);var u=function v(){if(v.cache)return v.cache;for(var f=[],d=0;d+5<a.allpts.length;d+=4){var h={x:a.allpts[d],y:a.allpts[d+1]},c={x:a.allpts[d+2],y:a.allpts[d+3]},m={x:a.allpts[d+4],y:a.allpts[d+5]};f.push({p0:h,p1:c,p2:m,startDist:0,length:0,segments:[]})}var g=t.rstyle.bezierPts,p=n.bezierProjPcts.length;function y(E,T,F,S,D){var C=gt(T,F),B=E.segments[E.segments.length-1],A={p0:T,p1:F,t0:S,t1:D,startDist:B?B.startDist+B.length:0,length:C};E.segments.push(A),E.length+=C}for(var w=0;w<f.length;w++){var b=f[w],k=f[w-1];k&&(b.startDist=k.startDist+k.length),y(b,b.p0,g[w*p],0,n.bezierProjPcts[0]);for(var x=0;x<p-1;x++)y(b,g[w*p+x],g[w*p+x+1],n.bezierProjPcts[x],n.bezierProjPcts[x+1]);y(b,g[w*p+p-1],b.p2,n.bezierProjPcts[p-1],1)}return v.cache=f},l=function(f){var d,h=f==="source";if(i[f]){var c=r.pstyle(f+"-text-offset").pfValue;switch(a.edgeType){case"self":case"compound":case"bezier":case"multibezier":{for(var m=u(),g,p=0,y=0,w=0;w<m.length;w++){for(var b=m[h?w:m.length-1-w],k=0;k<b.segments.length;k++){var x=b.segments[h?k:b.segments.length-1-k],E=w===m.length-1&&k===b.segments.length-1;if(p=y,y+=x.length,y>=c||E){g={cp:b,segment:x};break}}if(g)break}var T=g.cp,F=g.segment,S=(c-p)/F.length,D=F.t1-F.t0,C=h?F.t0+D*S:F.t1-D*S;C=pa(0,C,1),e=Mt(T.p0,T.p1,T.p2,C),d=R0(T.p0,T.p1,T.p2,C);break}case"straight":case"segments":case"haystack":{for(var B=0,A,M,I,R,L=a.allpts.length,V=0;V+3<L&&(h?(I={x:a.allpts[V],y:a.allpts[V+1]},R={x:a.allpts[V+2],y:a.allpts[V+3]}):(I={x:a.allpts[L-2-V],y:a.allpts[L-1-V]},R={x:a.allpts[L-4-V],y:a.allpts[L-3-V]}),A=gt(I,R),M=B,B+=A,!(B>=c));V+=2);var H=c-M,z=H/A;z=pa(0,z,1),e=zf(I,R,z),d=Bu(I,R);break}}s("labelX",f,e.x),s("labelY",f,e.y),s("labelAutoAngle",f,d)}};l("source"),l("target"),this.applyLabelDimensions(r)}},_r.applyLabelDimensions=function(r){this.applyPrefixedLabelDimensions(r),r.isEdge()&&(this.applyPrefixedLabelDimensions(r,"source"),this.applyPrefixedLabelDimensions(r,"target"))},_r.applyPrefixedLabelDimensions=function(r,e){var t=r._private,a=this.getLabelText(r,e),n=this.calculateLabelDimensions(r,a),i=r.pstyle("line-height").pfValue,s=r.pstyle("text-wrap").strValue,o=Sr(t.rscratch,"labelWrapCachedLines",e)||[],u=s!=="wrap"?1:Math.max(o.length,1),l=n.height/u,v=l*i,f=n.width,d=n.height+(u-1)*(i-1)*l;tt(t.rstyle,"labelWidth",e,f),tt(t.rscratch,"labelWidth",e,f),tt(t.rstyle,"labelHeight",e,d),tt(t.rscratch,"labelHeight",e,d),tt(t.rscratch,"labelLineHeight",e,v)},_r.getLabelText=function(r,e){var t=r._private,a=e?e+"-":"",n=r.pstyle(a+"label").strValue,i=r.pstyle("text-transform").value,s=function(K,Y){return Y?(tt(t.rscratch,K,e,Y),Y):Sr(t.rscratch,K,e)};if(!n)return"";i=="none"||(i=="uppercase"?n=n.toUpperCase():i=="lowercase"&&(n=n.toLowerCase()));var o=r.pstyle("text-wrap").value;if(o==="wrap"){var u=s("labelKey");if(u!=null&&s("labelWrapKey")===u)return s("labelWrapCachedText");for(var l="​",v=n.split(`
`),f=r.pstyle("text-max-width").pfValue,d=r.pstyle("text-overflow-wrap").value,h=d==="anywhere",c=[],m=/[\s\u200b]+|$/g,g=0;g<v.length;g++){var p=v[g],y=this.calculateLabelDimensions(r,p),w=y.width;if(h){var b=p.split("").join(l);p=b}if(w>f){var k=p.matchAll(m),x="",E=0,T=mr(k),F;try{for(T.s();!(F=T.n()).done;){var S=F.value,D=S[0],C=p.substring(E,S.index);E=S.index+D.length;var B=x.length===0?C:x+C+D,A=this.calculateLabelDimensions(r,B),M=A.width;M<=f?x+=C+D:(x&&c.push(x),x=C+D)}}catch($){T.e($)}finally{T.f()}x.match(/^[\s\u200b]+$/)||c.push(x)}else c.push(p)}s("labelWrapCachedLines",c),n=s("labelWrapCachedText",c.join(`
`)),s("labelWrapKey",u)}else if(o==="ellipsis"){var I=r.pstyle("text-max-width").pfValue,R="",L="…",V=!1;if(this.calculateLabelDimensions(r,n).width<I)return n;for(var H=0;H<n.length;H++){var z=this.calculateLabelDimensions(r,R+n[H]+L).width;if(z>I)break;R+=n[H],H===n.length-1&&(V=!0)}return V||(R+=L),R}return n},_r.getLabelJustification=function(r){var e=r.pstyle("text-justification").strValue,t=r.pstyle("text-halign").strValue;if(e==="auto")if(r.isNode())switch(t){case"left":return"right";case"right":return"left";default:return"center"}else return"center";else return e},_r.calculateLabelDimensions=function(r,e){var t=this,a=t.cy.window(),n=a.document,i=et(e,r._private.labelDimsKey),s=t.labelDimCache||(t.labelDimCache=[]),o=s[i];if(o!=null)return o;var u=0,l=r.pstyle("font-style").strValue,v=r.pstyle("font-size").pfValue,f=r.pstyle("font-family").strValue,d=r.pstyle("font-weight").strValue,h=this.labelCalcCanvas,c=this.labelCalcCanvasContext;if(!h){h=this.labelCalcCanvas=n.createElement("canvas"),c=this.labelCalcCanvasContext=h.getContext("2d");var m=h.style;m.position="absolute",m.left="-9999px",m.top="-9999px",m.zIndex="-1",m.visibility="hidden",m.pointerEvents="none"}c.font="".concat(l," ").concat(d," ").concat(v,"px ").concat(f);for(var g=0,p=0,y=e.split(`
`),w=0;w<y.length;w++){var b=y[w],k=c.measureText(b),x=Math.ceil(k.width),E=v;g=Math.max(x,g),p+=E}return g+=u,p+=u,s[i]={width:g,height:p}},_r.calculateLabelAngle=function(r,e){var t=r._private,a=t.rscratch,n=r.isEdge(),i=e?e+"-":"",s=r.pstyle(i+"text-rotation"),o=s.strValue;return o==="none"?0:n&&o==="autorotate"?a.labelAutoAngle:o==="autorotate"?0:s.pfValue},_r.calculateLabelAngles=function(r){var e=this,t=r.isEdge(),a=r._private,n=a.rscratch;n.labelAngle=e.calculateLabelAngle(r),t&&(n.sourceLabelAngle=e.calculateLabelAngle(r,"source"),n.targetLabelAngle=e.calculateLabelAngle(r,"target"))};var Au={},Iu=28,Mu=!1;Au.getNodeShape=function(r){var e=this,t=r.pstyle("shape").value;if(t==="cutrectangle"&&(r.width()<Iu||r.height()<Iu))return Mu||(Pe("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),Mu=!0),"rectangle";if(r.isParent())return t==="rectangle"||t==="roundrectangle"||t==="round-rectangle"||t==="cutrectangle"||t==="cut-rectangle"||t==="barrel"?t:"rectangle";if(t==="polygon"){var a=r.pstyle("shape-polygon-points").value;return e.nodeShapes.makePolygon(a).name}return t};var On={};On.registerCalculationListeners=function(){var r=this.cy,e=r.collection(),t=this,a=function(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(e.merge(s),o)for(var u=0;u<s.length;u++){var l=s[u],v=l._private,f=v.rstyle;f.clean=!1,f.cleanConnected=!1}};t.binder(r).on("bounds.* dirty.*",function(s){var o=s.target;a(o)}).on("style.* background.*",function(s){var o=s.target;a(o,!1)});var n=function(s){if(s){var o=t.onUpdateEleCalcsFns;e.cleanStyle();for(var u=0;u<e.length;u++){var l=e[u],v=l._private.rstyle;l.isNode()&&!v.cleanConnected&&(a(l.connectedEdges()),v.cleanConnected=!0)}if(o)for(var f=0;f<o.length;f++){var d=o[f];d(s,e)}t.recalculateRenderedStyle(e),e=r.collection()}};t.flushRenderedStyleQueue=function(){n(!0)},t.beforeRender(n,t.beforeRenderPriorities.eleCalcs)},On.onUpdateEleCalcs=function(r){var e=this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[];e.push(r)},On.recalculateRenderedStyle=function(r,e){var t=function(b){return b._private.rstyle.cleanConnected},a=[],n=[];if(!this.destroyed){e===void 0&&(e=!0);for(var i=0;i<r.length;i++){var s=r[i],o=s._private,u=o.rstyle;s.isEdge()&&(!t(s.source())||!t(s.target()))&&(u.clean=!1),!(e&&u.clean||s.removed())&&s.pstyle("display").value!=="none"&&(o.group==="nodes"?n.push(s):a.push(s),u.clean=!0)}for(var l=0;l<n.length;l++){var v=n[l],f=v._private,d=f.rstyle,h=v.position();this.recalculateNodeLabelProjection(v),d.nodeX=h.x,d.nodeY=h.y,d.nodeW=v.pstyle("width").pfValue,d.nodeH=v.pstyle("height").pfValue}this.recalculateEdgeProjections(a);for(var c=0;c<a.length;c++){var m=a[c],g=m._private,p=g.rstyle,y=g.rscratch;p.srcX=y.arrowStartX,p.srcY=y.arrowStartY,p.tgtX=y.arrowEndX,p.tgtY=y.arrowEndY,p.midX=y.midX,p.midY=y.midY,p.labelAngle=y.labelAngle,p.sourceLabelAngle=y.sourceLabelAngle,p.targetLabelAngle=y.targetLabelAngle}}};var _n={};_n.updateCachedGrabbedEles=function(){var r=this.cachedZSortedEles;if(r){r.drag=[],r.nondrag=[];for(var e=[],t=0;t<r.length;t++){var a=r[t],n=a._private.rscratch;a.grabbed()&&!a.isParent()?e.push(a):n.inDragLayer?r.drag.push(a):r.nondrag.push(a)}for(var t=0;t<e.length;t++){var a=e[t];r.drag.push(a)}}},_n.invalidateCachedZSortedEles=function(){this.cachedZSortedEles=null},_n.getCachedZSortedEles=function(r){if(r||!this.cachedZSortedEles){var e=this.cy.mutableElements().toArray();e.sort(Yo),e.interactive=e.filter(function(t){return t.interactive()}),this.cachedZSortedEles=e,this.updateCachedGrabbedEles()}else e=this.cachedZSortedEles;return e};var Ru={};[Et,Mn,ur,Ia,Vi,_r,Au,On,_n].forEach(function(r){ce(Ru,r)});var Lu={};Lu.getCachedImage=function(r,e,t){var a=this,n=a.imageCache=a.imageCache||{},i=n[r];if(i)return i.image.complete||i.image.addEventListener("load",t),i.image;i=n[r]=n[r]||{};var s=i.image=new Image;s.addEventListener("load",t),s.addEventListener("error",function(){s.error=!0});var o="data:",u=r.substring(0,o.length).toLowerCase()===o;return u||(e=e==="null"?null:e,s.crossOrigin=e),s.src=r,s};var Qt={};Qt.registerBinding=function(r,e,t,a){var n=Array.prototype.slice.apply(arguments,[1]);if(Array.isArray(r)){for(var i=[],s=0;s<r.length;s++){var o=r[s];if(o!==void 0){var u=this.binder(o);i.push(u.on.apply(u,n))}}return i}var u=this.binder(r);return u.on.apply(u,n)},Qt.binder=function(r){var e=this,t=e.cy.window(),a=r===t||r===t.document||r===t.document.body||iv(r);if(e.supportsPassiveEvents==null){var n=!1;try{var i=Object.defineProperty({},"passive",{get:function(){return n=!0,!0}});t.addEventListener("test",null,i)}catch{}e.supportsPassiveEvents=n}var s=function(u,l,v){var f=Array.prototype.slice.call(arguments);return a&&e.supportsPassiveEvents&&(f[2]={capture:v??!1,passive:!1,once:!1}),e.bindings.push({target:r,args:f}),(r.addEventListener||r.on).apply(r,f),this};return{on:s,addEventListener:s,addListener:s,bind:s}},Qt.nodeIsDraggable=function(r){return r&&r.isNode()&&!r.locked()&&r.grabbable()},Qt.nodeIsGrabbable=function(r){return this.nodeIsDraggable(r)&&r.interactive()},Qt.load=function(){var r=this,e=r.cy.window(),t=function(P){return P.selected()},a=function(P){var _=P.getRootNode();if(_&&_.nodeType===11&&_.host!==void 0)return _},n=function(P,_,U,N){P==null&&(P=r.cy);for(var q=0;q<_.length;q++){var ae=_[q];P.emit({originalEvent:U,type:ae,position:N})}},i=function(P){return P.shiftKey||P.metaKey||P.ctrlKey},s=function(P,_){var U=!0;if(r.cy.hasCompoundNodes()&&P&&P.pannable())for(var N=0;_&&N<_.length;N++){var P=_[N];if(P.isNode()&&P.isParent()&&!P.pannable()){U=!1;break}}else U=!0;return U},o=function(P){P[0]._private.grabbed=!0},u=function(P){P[0]._private.grabbed=!1},l=function(P){P[0]._private.rscratch.inDragLayer=!0},v=function(P){P[0]._private.rscratch.inDragLayer=!1},f=function(P){P[0]._private.rscratch.isGrabTarget=!0},d=function(P){P[0]._private.rscratch.isGrabTarget=!1},h=function(P,_){var U=_.addToList,N=U.has(P);!N&&P.grabbable()&&!P.locked()&&(U.merge(P),o(P))},c=function(P,_){if(P.cy().hasCompoundNodes()&&!(_.inDragLayer==null&&_.addToList==null)){var U=P.descendants();_.inDragLayer&&(U.forEach(l),U.connectedEdges().forEach(l)),_.addToList&&h(U,_)}},m=function(P,_){_=_||{};var U=P.cy().hasCompoundNodes();_.inDragLayer&&(P.forEach(l),P.neighborhood().stdFilter(function(N){return!U||N.isEdge()}).forEach(l)),_.addToList&&P.forEach(function(N){h(N,_)}),c(P,_),y(P,{inDragLayer:_.inDragLayer}),r.updateCachedGrabbedEles()},g=m,p=function(P){P&&(r.getCachedZSortedEles().forEach(function(_){u(_),v(_),d(_)}),r.updateCachedGrabbedEles())},y=function(P,_){if(!(_.inDragLayer==null&&_.addToList==null)&&P.cy().hasCompoundNodes()){var U=P.ancestors().orphans();if(!U.same(P)){var N=U.descendants().spawnSelf().merge(U).unmerge(P).unmerge(P.descendants()),q=N.connectedEdges();_.inDragLayer&&(q.forEach(l),N.forEach(l)),_.addToList&&N.forEach(function(ae){h(ae,_)})}}},w=function(){document.activeElement!=null&&document.activeElement.blur!=null&&document.activeElement.blur()},b=typeof MutationObserver<"u",k=typeof ResizeObserver<"u";b?(r.removeObserver=new MutationObserver(function(J){for(var P=0;P<J.length;P++){var _=J[P],U=_.removedNodes;if(U)for(var N=0;N<U.length;N++){var q=U[N];if(q===r.container){r.destroy();break}}}}),r.container.parentNode&&r.removeObserver.observe(r.container.parentNode,{childList:!0})):r.registerBinding(r.container,"DOMNodeRemoved",function(J){r.destroy()});var x=va(function(){r.cy.resize()},100);b&&(r.styleObserver=new MutationObserver(x),r.styleObserver.observe(r.container,{attributes:!0})),r.registerBinding(e,"resize",x),k&&(r.resizeObserver=new ResizeObserver(x),r.resizeObserver.observe(r.container));var E=function(P,_){for(;P!=null;)_(P),P=P.parentNode},T=function(){r.invalidateContainerClientCoordsCache()};E(r.container,function(J){r.registerBinding(J,"transitionend",T),r.registerBinding(J,"animationend",T),r.registerBinding(J,"scroll",T)}),r.registerBinding(r.container,"contextmenu",function(J){J.preventDefault()});var F=function(){return r.selection[4]!==0},S=function(P){for(var _=r.findContainerClientCoords(),U=_[0],N=_[1],q=_[2],ae=_[3],X=P.touches?P.touches:[P],ne=!1,de=0;de<X.length;de++){var Fe=X[de];if(U<=Fe.clientX&&Fe.clientX<=U+q&&N<=Fe.clientY&&Fe.clientY<=N+ae){ne=!0;break}}if(!ne)return!1;for(var ve=r.container,we=P.target,be=we.parentNode,ge=!1;be;){if(be===ve){ge=!0;break}be=be.parentNode}return!!ge};r.registerBinding(r.container,"mousedown",function(P){if(S(P)&&!(r.hoverData.which===1&&P.which!==1)){P.preventDefault(),w(),r.hoverData.capture=!0,r.hoverData.which=P.which;var _=r.cy,U=[P.clientX,P.clientY],N=r.projectIntoViewport(U[0],U[1]),q=r.selection,ae=r.findNearestElements(N[0],N[1],!0,!1),X=ae[0],ne=r.dragData.possibleDragElements;r.hoverData.mdownPos=N,r.hoverData.mdownGPos=U;var de=function(){r.hoverData.tapholdCancelled=!1,clearTimeout(r.hoverData.tapholdTimeout),r.hoverData.tapholdTimeout=setTimeout(function(){if(!r.hoverData.tapholdCancelled){var _e=r.hoverData.down;_e?_e.emit({originalEvent:P,type:"taphold",position:{x:N[0],y:N[1]}}):_.emit({originalEvent:P,type:"taphold",position:{x:N[0],y:N[1]}})}},r.tapholdDuration)};if(P.which==3){r.hoverData.cxtStarted=!0;var Fe={originalEvent:P,type:"cxttapstart",position:{x:N[0],y:N[1]}};X?(X.activate(),X.emit(Fe),r.hoverData.down=X):_.emit(Fe),r.hoverData.downTime=new Date().getTime(),r.hoverData.cxtDragged=!1}else if(P.which==1){X&&X.activate();{if(X!=null&&r.nodeIsGrabbable(X)){var ve=function(_e){return{originalEvent:P,type:_e,position:{x:N[0],y:N[1]}}},we=function(_e){_e.emit(ve("grab"))};if(f(X),!X.selected())ne=r.dragData.possibleDragElements=_.collection(),g(X,{addToList:ne}),X.emit(ve("grabon")).emit(ve("grab"));else{ne=r.dragData.possibleDragElements=_.collection();var be=_.$(function(ge){return ge.isNode()&&ge.selected()&&r.nodeIsGrabbable(ge)});m(be,{addToList:ne}),X.emit(ve("grabon")),be.forEach(we)}r.redrawHint("eles",!0),r.redrawHint("drag",!0)}r.hoverData.down=X,r.hoverData.downs=ae,r.hoverData.downTime=new Date().getTime()}n(X,["mousedown","tapstart","vmousedown"],P,{x:N[0],y:N[1]}),X==null?(q[4]=1,r.data.bgActivePosistion={x:N[0],y:N[1]},r.redrawHint("select",!0),r.redraw()):X.pannable()&&(q[4]=1),de()}q[0]=q[2]=N[0],q[1]=q[3]=N[1]}},!1);var D=a(r.container);r.registerBinding([e,D],"mousemove",function(P){var _=r.hoverData.capture;if(!(!_&&!S(P))){var U=!1,N=r.cy,q=N.zoom(),ae=[P.clientX,P.clientY],X=r.projectIntoViewport(ae[0],ae[1]),ne=r.hoverData.mdownPos,de=r.hoverData.mdownGPos,Fe=r.selection,ve=null;!r.hoverData.draggingEles&&!r.hoverData.dragging&&!r.hoverData.selecting&&(ve=r.findNearestElement(X[0],X[1],!0,!1));var we=r.hoverData.last,be=r.hoverData.down,ge=[X[0]-Fe[2],X[1]-Fe[3]],_e=r.dragData.possibleDragElements,$e;if(de){var br=ae[0]-de[0],Fr=br*br,Xe=ae[1]-de[1],Qe=Xe*Xe,Je=Fr+Qe;r.hoverData.isOverThresholdDrag=$e=Je>=r.desktopTapThreshold2}var dr=i(P);$e&&(r.hoverData.tapholdCancelled=!0);var cr=function(){var $r=r.hoverData.dragDelta=r.hoverData.dragDelta||[];$r.length===0?($r.push(ge[0]),$r.push(ge[1])):($r[0]+=ge[0],$r[1]+=ge[1])};U=!0,n(ve,["mousemove","vmousemove","tapdrag"],P,{x:X[0],y:X[1]});var zr=function(){r.data.bgActivePosistion=void 0,r.hoverData.selecting||N.emit({originalEvent:P,type:"boxstart",position:{x:X[0],y:X[1]}}),Fe[4]=1,r.hoverData.selecting=!0,r.redrawHint("select",!0),r.redraw()};if(r.hoverData.which===3){if($e){var Tr={originalEvent:P,type:"cxtdrag",position:{x:X[0],y:X[1]}};be?be.emit(Tr):N.emit(Tr),r.hoverData.cxtDragged=!0,(!r.hoverData.cxtOver||ve!==r.hoverData.cxtOver)&&(r.hoverData.cxtOver&&r.hoverData.cxtOver.emit({originalEvent:P,type:"cxtdragout",position:{x:X[0],y:X[1]}}),r.hoverData.cxtOver=ve,ve&&ve.emit({originalEvent:P,type:"cxtdragover",position:{x:X[0],y:X[1]}}))}}else if(r.hoverData.dragging){if(U=!0,N.panningEnabled()&&N.userPanningEnabled()){var Vr;if(r.hoverData.justStartedPan){var Xr=r.hoverData.mdownPos;Vr={x:(X[0]-Xr[0])*q,y:(X[1]-Xr[1])*q},r.hoverData.justStartedPan=!1}else Vr={x:ge[0]*q,y:ge[1]*q};N.panBy(Vr),N.emit("dragpan"),r.hoverData.dragged=!0}X=r.projectIntoViewport(P.clientX,P.clientY)}else if(Fe[4]==1&&(be==null||be.pannable())){if($e){if(!r.hoverData.dragging&&N.boxSelectionEnabled()&&(dr||!N.panningEnabled()||!N.userPanningEnabled()))zr();else if(!r.hoverData.selecting&&N.panningEnabled()&&N.userPanningEnabled()){var Yr=s(be,r.hoverData.downs);Yr&&(r.hoverData.dragging=!0,r.hoverData.justStartedPan=!0,Fe[4]=0,r.data.bgActivePosistion=It(ne),r.redrawHint("select",!0),r.redraw())}be&&be.pannable()&&be.active()&&be.unactivate()}}else{if(be&&be.pannable()&&be.active()&&be.unactivate(),(!be||!be.grabbed())&&ve!=we&&(we&&n(we,["mouseout","tapdragout"],P,{x:X[0],y:X[1]}),ve&&n(ve,["mouseover","tapdragover"],P,{x:X[0],y:X[1]}),r.hoverData.last=ve),be)if($e){if(N.boxSelectionEnabled()&&dr)be&&be.grabbed()&&(p(_e),be.emit("freeon"),_e.emit("free"),r.dragData.didDrag&&(be.emit("dragfreeon"),_e.emit("dragfree"))),zr();else if(be&&be.grabbed()&&r.nodeIsDraggable(be)){var lr=!r.dragData.didDrag;lr&&r.redrawHint("eles",!0),r.dragData.didDrag=!0,r.hoverData.draggingEles||m(_e,{inDragLayer:!0});var je={x:0,y:0};if(te(ge[0])&&te(ge[1])&&(je.x+=ge[0],je.y+=ge[1],lr)){var pr=r.hoverData.dragDelta;pr&&te(pr[0])&&te(pr[1])&&(je.x+=pr[0],je.y+=pr[1])}r.hoverData.draggingEles=!0,_e.silentShift(je).emit("position drag"),r.redrawHint("drag",!0),r.redraw()}}else cr();U=!0}if(Fe[2]=X[0],Fe[3]=X[1],U)return P.stopPropagation&&P.stopPropagation(),P.preventDefault&&P.preventDefault(),!1}},!1);var C,B,A;r.registerBinding(e,"mouseup",function(P){if(!(r.hoverData.which===1&&P.which!==1&&r.hoverData.capture)){var _=r.hoverData.capture;if(_){r.hoverData.capture=!1;var U=r.cy,N=r.projectIntoViewport(P.clientX,P.clientY),q=r.selection,ae=r.findNearestElement(N[0],N[1],!0,!1),X=r.dragData.possibleDragElements,ne=r.hoverData.down,de=i(P);if(r.data.bgActivePosistion&&(r.redrawHint("select",!0),r.redraw()),r.hoverData.tapholdCancelled=!0,r.data.bgActivePosistion=void 0,ne&&ne.unactivate(),r.hoverData.which===3){var Fe={originalEvent:P,type:"cxttapend",position:{x:N[0],y:N[1]}};if(ne?ne.emit(Fe):U.emit(Fe),!r.hoverData.cxtDragged){var ve={originalEvent:P,type:"cxttap",position:{x:N[0],y:N[1]}};ne?ne.emit(ve):U.emit(ve)}r.hoverData.cxtDragged=!1,r.hoverData.which=null}else if(r.hoverData.which===1){if(n(ae,["mouseup","tapend","vmouseup"],P,{x:N[0],y:N[1]}),!r.dragData.didDrag&&!r.hoverData.dragged&&!r.hoverData.selecting&&!r.hoverData.isOverThresholdDrag&&(n(ne,["click","tap","vclick"],P,{x:N[0],y:N[1]}),B=!1,P.timeStamp-A<=U.multiClickDebounceTime()?(C&&clearTimeout(C),B=!0,A=null,n(ne,["dblclick","dbltap","vdblclick"],P,{x:N[0],y:N[1]})):(C=setTimeout(function(){B||n(ne,["oneclick","onetap","voneclick"],P,{x:N[0],y:N[1]})},U.multiClickDebounceTime()),A=P.timeStamp)),ne==null&&!r.dragData.didDrag&&!r.hoverData.selecting&&!r.hoverData.dragged&&!i(P)&&(U.$(t).unselect(["tapunselect"]),X.length>0&&r.redrawHint("eles",!0),r.dragData.possibleDragElements=X=U.collection()),ae==ne&&!r.dragData.didDrag&&!r.hoverData.selecting&&ae!=null&&ae._private.selectable&&(r.hoverData.dragging||(U.selectionType()==="additive"||de?ae.selected()?ae.unselect(["tapunselect"]):ae.select(["tapselect"]):de||(U.$(t).unmerge(ae).unselect(["tapunselect"]),ae.select(["tapselect"]))),r.redrawHint("eles",!0)),r.hoverData.selecting){var we=U.collection(r.getAllInBox(q[0],q[1],q[2],q[3]));r.redrawHint("select",!0),we.length>0&&r.redrawHint("eles",!0),U.emit({type:"boxend",originalEvent:P,position:{x:N[0],y:N[1]}});var be=function($e){return $e.selectable()&&!$e.selected()};U.selectionType()==="additive"||de||U.$(t).unmerge(we).unselect(),we.emit("box").stdFilter(be).select().emit("boxselect"),r.redraw()}if(r.hoverData.dragging&&(r.hoverData.dragging=!1,r.redrawHint("select",!0),r.redrawHint("eles",!0),r.redraw()),!q[4]){r.redrawHint("drag",!0),r.redrawHint("eles",!0);var ge=ne&&ne.grabbed();p(X),ge&&(ne.emit("freeon"),X.emit("free"),r.dragData.didDrag&&(ne.emit("dragfreeon"),X.emit("dragfree")))}}q[4]=0,r.hoverData.down=null,r.hoverData.cxtStarted=!1,r.hoverData.draggingEles=!1,r.hoverData.selecting=!1,r.hoverData.isOverThresholdDrag=!1,r.dragData.didDrag=!1,r.hoverData.dragged=!1,r.hoverData.dragDelta=[],r.hoverData.mdownPos=null,r.hoverData.mdownGPos=null,r.hoverData.which=null}}},!1);var M=function(P){if(!r.scrollingPage){var _=r.cy,U=_.zoom(),N=_.pan(),q=r.projectIntoViewport(P.clientX,P.clientY),ae=[q[0]*U+N.x,q[1]*U+N.y];if(r.hoverData.draggingEles||r.hoverData.dragging||r.hoverData.cxtStarted||F()){P.preventDefault();return}if(_.panningEnabled()&&_.userPanningEnabled()&&_.zoomingEnabled()&&_.userZoomingEnabled()){P.preventDefault(),r.data.wheelZooming=!0,clearTimeout(r.data.wheelTimeout),r.data.wheelTimeout=setTimeout(function(){r.data.wheelZooming=!1,r.redrawHint("eles",!0),r.redraw()},150);var X;P.deltaY!=null?X=P.deltaY/-250:P.wheelDeltaY!=null?X=P.wheelDeltaY/1e3:X=P.wheelDelta/1e3,X=X*r.wheelSensitivity;var ne=P.deltaMode===1;ne&&(X*=33);var de=_.zoom()*Math.pow(10,X);P.type==="gesturechange"&&(de=r.gestureStartZoom*P.scale),_.zoom({level:de,renderedPosition:{x:ae[0],y:ae[1]}}),_.emit(P.type==="gesturechange"?"pinchzoom":"scrollzoom")}}};r.registerBinding(r.container,"wheel",M,!0),r.registerBinding(e,"scroll",function(P){r.scrollingPage=!0,clearTimeout(r.scrollingPageTimeout),r.scrollingPageTimeout=setTimeout(function(){r.scrollingPage=!1},250)},!0),r.registerBinding(r.container,"gesturestart",function(P){r.gestureStartZoom=r.cy.zoom(),r.hasTouchStarted||P.preventDefault()},!0),r.registerBinding(r.container,"gesturechange",function(J){r.hasTouchStarted||M(J)},!0),r.registerBinding(r.container,"mouseout",function(P){var _=r.projectIntoViewport(P.clientX,P.clientY);r.cy.emit({originalEvent:P,type:"mouseout",position:{x:_[0],y:_[1]}})},!1),r.registerBinding(r.container,"mouseover",function(P){var _=r.projectIntoViewport(P.clientX,P.clientY);r.cy.emit({originalEvent:P,type:"mouseover",position:{x:_[0],y:_[1]}})},!1);var I,R,L,V,H,z,$,K,Y,Q,Z,j,re,W=function(P,_,U,N){return Math.sqrt((U-P)*(U-P)+(N-_)*(N-_))},O=function(P,_,U,N){return(U-P)*(U-P)+(N-_)*(N-_)},G;r.registerBinding(r.container,"touchstart",G=function(P){if(r.hasTouchStarted=!0,!!S(P)){w(),r.touchData.capture=!0,r.data.bgActivePosistion=void 0;var _=r.cy,U=r.touchData.now,N=r.touchData.earlier;if(P.touches[0]){var q=r.projectIntoViewport(P.touches[0].clientX,P.touches[0].clientY);U[0]=q[0],U[1]=q[1]}if(P.touches[1]){var q=r.projectIntoViewport(P.touches[1].clientX,P.touches[1].clientY);U[2]=q[0],U[3]=q[1]}if(P.touches[2]){var q=r.projectIntoViewport(P.touches[2].clientX,P.touches[2].clientY);U[4]=q[0],U[5]=q[1]}if(P.touches[1]){r.touchData.singleTouchMoved=!0,p(r.dragData.touchDragEles);var ae=r.findContainerClientCoords();Y=ae[0],Q=ae[1],Z=ae[2],j=ae[3],I=P.touches[0].clientX-Y,R=P.touches[0].clientY-Q,L=P.touches[1].clientX-Y,V=P.touches[1].clientY-Q,re=0<=I&&I<=Z&&0<=L&&L<=Z&&0<=R&&R<=j&&0<=V&&V<=j;var X=_.pan(),ne=_.zoom();H=W(I,R,L,V),z=O(I,R,L,V),$=[(I+L)/2,(R+V)/2],K=[($[0]-X.x)/ne,($[1]-X.y)/ne];var de=200,Fe=de*de;if(z<Fe&&!P.touches[2]){var ve=r.findNearestElement(U[0],U[1],!0,!0),we=r.findNearestElement(U[2],U[3],!0,!0);ve&&ve.isNode()?(ve.activate().emit({originalEvent:P,type:"cxttapstart",position:{x:U[0],y:U[1]}}),r.touchData.start=ve):we&&we.isNode()?(we.activate().emit({originalEvent:P,type:"cxttapstart",position:{x:U[0],y:U[1]}}),r.touchData.start=we):_.emit({originalEvent:P,type:"cxttapstart",position:{x:U[0],y:U[1]}}),r.touchData.start&&(r.touchData.start._private.grabbed=!1),r.touchData.cxt=!0,r.touchData.cxtDragged=!1,r.data.bgActivePosistion=void 0,r.redraw();return}}if(P.touches[2])_.boxSelectionEnabled()&&P.preventDefault();else if(!P.touches[1]){if(P.touches[0]){var be=r.findNearestElements(U[0],U[1],!0,!0),ge=be[0];if(ge!=null&&(ge.activate(),r.touchData.start=ge,r.touchData.starts=be,r.nodeIsGrabbable(ge))){var _e=r.dragData.touchDragEles=_.collection(),$e=null;r.redrawHint("eles",!0),r.redrawHint("drag",!0),ge.selected()?($e=_.$(function(Je){return Je.selected()&&r.nodeIsGrabbable(Je)}),m($e,{addToList:_e})):g(ge,{addToList:_e}),f(ge);var br=function(dr){return{originalEvent:P,type:dr,position:{x:U[0],y:U[1]}}};ge.emit(br("grabon")),$e?$e.forEach(function(Je){Je.emit(br("grab"))}):ge.emit(br("grab"))}n(ge,["touchstart","tapstart","vmousedown"],P,{x:U[0],y:U[1]}),ge==null&&(r.data.bgActivePosistion={x:q[0],y:q[1]},r.redrawHint("select",!0),r.redraw()),r.touchData.singleTouchMoved=!1,r.touchData.singleTouchStartTime=+new Date,clearTimeout(r.touchData.tapholdTimeout),r.touchData.tapholdTimeout=setTimeout(function(){r.touchData.singleTouchMoved===!1&&!r.pinching&&!r.touchData.selecting&&n(r.touchData.start,["taphold"],P,{x:U[0],y:U[1]})},r.tapholdDuration)}}if(P.touches.length>=1){for(var Fr=r.touchData.startPosition=[null,null,null,null,null,null],Xe=0;Xe<U.length;Xe++)Fr[Xe]=N[Xe]=U[Xe];var Qe=P.touches[0];r.touchData.startGPosition=[Qe.clientX,Qe.clientY]}}},!1);var ee;r.registerBinding(e,"touchmove",ee=function(P){var _=r.touchData.capture;if(!(!_&&!S(P))){var U=r.selection,N=r.cy,q=r.touchData.now,ae=r.touchData.earlier,X=N.zoom();if(P.touches[0]){var ne=r.projectIntoViewport(P.touches[0].clientX,P.touches[0].clientY);q[0]=ne[0],q[1]=ne[1]}if(P.touches[1]){var ne=r.projectIntoViewport(P.touches[1].clientX,P.touches[1].clientY);q[2]=ne[0],q[3]=ne[1]}if(P.touches[2]){var ne=r.projectIntoViewport(P.touches[2].clientX,P.touches[2].clientY);q[4]=ne[0],q[5]=ne[1]}var de=r.touchData.startGPosition,Fe;if(_&&P.touches[0]&&de){for(var ve=[],we=0;we<q.length;we++)ve[we]=q[we]-ae[we];var be=P.touches[0].clientX-de[0],ge=be*be,_e=P.touches[0].clientY-de[1],$e=_e*_e,br=ge+$e;Fe=br>=r.touchTapThreshold2}if(_&&r.touchData.cxt){P.preventDefault();var Fr=P.touches[0].clientX-Y,Xe=P.touches[0].clientY-Q,Qe=P.touches[1].clientX-Y,Je=P.touches[1].clientY-Q,dr=O(Fr,Xe,Qe,Je),cr=dr/z,zr=150,Tr=zr*zr,Vr=1.5,Xr=Vr*Vr;if(cr>=Xr||dr>=Tr){r.touchData.cxt=!1,r.data.bgActivePosistion=void 0,r.redrawHint("select",!0);var Yr={originalEvent:P,type:"cxttapend",position:{x:q[0],y:q[1]}};r.touchData.start?(r.touchData.start.unactivate().emit(Yr),r.touchData.start=null):N.emit(Yr)}}if(_&&r.touchData.cxt){var Yr={originalEvent:P,type:"cxtdrag",position:{x:q[0],y:q[1]}};r.data.bgActivePosistion=void 0,r.redrawHint("select",!0),r.touchData.start?r.touchData.start.emit(Yr):N.emit(Yr),r.touchData.start&&(r.touchData.start._private.grabbed=!1),r.touchData.cxtDragged=!0;var lr=r.findNearestElement(q[0],q[1],!0,!0);(!r.touchData.cxtOver||lr!==r.touchData.cxtOver)&&(r.touchData.cxtOver&&r.touchData.cxtOver.emit({originalEvent:P,type:"cxtdragout",position:{x:q[0],y:q[1]}}),r.touchData.cxtOver=lr,lr&&lr.emit({originalEvent:P,type:"cxtdragover",position:{x:q[0],y:q[1]}}))}else if(_&&P.touches[2]&&N.boxSelectionEnabled())P.preventDefault(),r.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,r.touchData.selecting||N.emit({originalEvent:P,type:"boxstart",position:{x:q[0],y:q[1]}}),r.touchData.selecting=!0,r.touchData.didSelect=!0,U[4]=1,!U||U.length===0||U[0]===void 0?(U[0]=(q[0]+q[2]+q[4])/3,U[1]=(q[1]+q[3]+q[5])/3,U[2]=(q[0]+q[2]+q[4])/3+1,U[3]=(q[1]+q[3]+q[5])/3+1):(U[2]=(q[0]+q[2]+q[4])/3,U[3]=(q[1]+q[3]+q[5])/3),r.redrawHint("select",!0),r.redraw();else if(_&&P.touches[1]&&!r.touchData.didSelect&&N.zoomingEnabled()&&N.panningEnabled()&&N.userZoomingEnabled()&&N.userPanningEnabled()){P.preventDefault(),r.data.bgActivePosistion=void 0,r.redrawHint("select",!0);var je=r.dragData.touchDragEles;if(je){r.redrawHint("drag",!0);for(var pr=0;pr<je.length;pr++){var Kn=je[pr]._private;Kn.grabbed=!1,Kn.rscratch.inDragLayer=!1}}var $r=r.touchData.start,Fr=P.touches[0].clientX-Y,Xe=P.touches[0].clientY-Q,Qe=P.touches[1].clientX-Y,Je=P.touches[1].clientY-Q,Ol=W(Fr,Xe,Qe,Je),Tm=Ol/H;if(re){var Sm=Fr-I,km=Xe-R,Dm=Qe-L,Pm=Je-V,Bm=(Sm+Dm)/2,Am=(km+Pm)/2,Wa=N.zoom(),ts=Wa*Tm,Xn=N.pan(),_l=K[0]*Wa+Xn.x,Nl=K[1]*Wa+Xn.y,Im={x:-ts/Wa*(_l-Xn.x-Bm)+_l,y:-ts/Wa*(Nl-Xn.y-Am)+Nl};if($r&&$r.active()){var je=r.dragData.touchDragEles;p(je),r.redrawHint("drag",!0),r.redrawHint("eles",!0),$r.unactivate().emit("freeon"),je.emit("free"),r.dragData.didDrag&&($r.emit("dragfreeon"),je.emit("dragfree"))}N.viewport({zoom:ts,pan:Im,cancelOnFailedZoom:!0}),N.emit("pinchzoom"),H=Ol,I=Fr,R=Xe,L=Qe,V=Je,r.pinching=!0}if(P.touches[0]){var ne=r.projectIntoViewport(P.touches[0].clientX,P.touches[0].clientY);q[0]=ne[0],q[1]=ne[1]}if(P.touches[1]){var ne=r.projectIntoViewport(P.touches[1].clientX,P.touches[1].clientY);q[2]=ne[0],q[3]=ne[1]}if(P.touches[2]){var ne=r.projectIntoViewport(P.touches[2].clientX,P.touches[2].clientY);q[4]=ne[0],q[5]=ne[1]}}else if(P.touches[0]&&!r.touchData.didSelect){var Pr=r.touchData.start,as=r.touchData.last,lr;if(!r.hoverData.draggingEles&&!r.swipePanning&&(lr=r.findNearestElement(q[0],q[1],!0,!0)),_&&Pr!=null&&P.preventDefault(),_&&Pr!=null&&r.nodeIsDraggable(Pr))if(Fe){var je=r.dragData.touchDragEles,zl=!r.dragData.didDrag;zl&&m(je,{inDragLayer:!0}),r.dragData.didDrag=!0;var Ha={x:0,y:0};if(te(ve[0])&&te(ve[1])&&(Ha.x+=ve[0],Ha.y+=ve[1],zl)){r.redrawHint("eles",!0);var Br=r.touchData.dragDelta;Br&&te(Br[0])&&te(Br[1])&&(Ha.x+=Br[0],Ha.y+=Br[1])}r.hoverData.draggingEles=!0,je.silentShift(Ha).emit("position drag"),r.redrawHint("drag",!0),r.touchData.startPosition[0]==ae[0]&&r.touchData.startPosition[1]==ae[1]&&r.redrawHint("eles",!0),r.redraw()}else{var Br=r.touchData.dragDelta=r.touchData.dragDelta||[];Br.length===0?(Br.push(ve[0]),Br.push(ve[1])):(Br[0]+=ve[0],Br[1]+=ve[1])}if(n(Pr||lr,["touchmove","tapdrag","vmousemove"],P,{x:q[0],y:q[1]}),(!Pr||!Pr.grabbed())&&lr!=as&&(as&&as.emit({originalEvent:P,type:"tapdragout",position:{x:q[0],y:q[1]}}),lr&&lr.emit({originalEvent:P,type:"tapdragover",position:{x:q[0],y:q[1]}})),r.touchData.last=lr,_)for(var pr=0;pr<q.length;pr++)q[pr]&&r.touchData.startPosition[pr]&&Fe&&(r.touchData.singleTouchMoved=!0);if(_&&(Pr==null||Pr.pannable())&&N.panningEnabled()&&N.userPanningEnabled()){var Mm=s(Pr,r.touchData.starts);Mm&&(P.preventDefault(),r.data.bgActivePosistion||(r.data.bgActivePosistion=It(r.touchData.startPosition)),r.swipePanning?(N.panBy({x:ve[0]*X,y:ve[1]*X}),N.emit("dragpan")):Fe&&(r.swipePanning=!0,N.panBy({x:be*X,y:_e*X}),N.emit("dragpan"),Pr&&(Pr.unactivate(),r.redrawHint("select",!0),r.touchData.start=null)));var ne=r.projectIntoViewport(P.touches[0].clientX,P.touches[0].clientY);q[0]=ne[0],q[1]=ne[1]}}for(var we=0;we<q.length;we++)ae[we]=q[we];_&&P.touches.length>0&&!r.hoverData.draggingEles&&!r.swipePanning&&r.data.bgActivePosistion!=null&&(r.data.bgActivePosistion=void 0,r.redrawHint("select",!0),r.redraw())}},!1);var ie;r.registerBinding(e,"touchcancel",ie=function(P){var _=r.touchData.start;r.touchData.capture=!1,_&&_.unactivate()});var ue,Ce,Ae,Ie;if(r.registerBinding(e,"touchend",ue=function(P){var _=r.touchData.start,U=r.touchData.capture;if(U)P.touches.length===0&&(r.touchData.capture=!1),P.preventDefault();else return;var N=r.selection;r.swipePanning=!1,r.hoverData.draggingEles=!1;var q=r.cy,ae=q.zoom(),X=r.touchData.now,ne=r.touchData.earlier;if(P.touches[0]){var de=r.projectIntoViewport(P.touches[0].clientX,P.touches[0].clientY);X[0]=de[0],X[1]=de[1]}if(P.touches[1]){var de=r.projectIntoViewport(P.touches[1].clientX,P.touches[1].clientY);X[2]=de[0],X[3]=de[1]}if(P.touches[2]){var de=r.projectIntoViewport(P.touches[2].clientX,P.touches[2].clientY);X[4]=de[0],X[5]=de[1]}_&&_.unactivate();var Fe;if(r.touchData.cxt){if(Fe={originalEvent:P,type:"cxttapend",position:{x:X[0],y:X[1]}},_?_.emit(Fe):q.emit(Fe),!r.touchData.cxtDragged){var ve={originalEvent:P,type:"cxttap",position:{x:X[0],y:X[1]}};_?_.emit(ve):q.emit(ve)}r.touchData.start&&(r.touchData.start._private.grabbed=!1),r.touchData.cxt=!1,r.touchData.start=null,r.redraw();return}if(!P.touches[2]&&q.boxSelectionEnabled()&&r.touchData.selecting){r.touchData.selecting=!1;var we=q.collection(r.getAllInBox(N[0],N[1],N[2],N[3]));N[0]=void 0,N[1]=void 0,N[2]=void 0,N[3]=void 0,N[4]=0,r.redrawHint("select",!0),q.emit({type:"boxend",originalEvent:P,position:{x:X[0],y:X[1]}});var be=function(Tr){return Tr.selectable()&&!Tr.selected()};we.emit("box").stdFilter(be).select().emit("boxselect"),we.nonempty()&&r.redrawHint("eles",!0),r.redraw()}if(_!=null&&_.unactivate(),P.touches[2])r.data.bgActivePosistion=void 0,r.redrawHint("select",!0);else if(!P.touches[1]){if(!P.touches[0]){if(!P.touches[0]){r.data.bgActivePosistion=void 0,r.redrawHint("select",!0);var ge=r.dragData.touchDragEles;if(_!=null){var _e=_._private.grabbed;p(ge),r.redrawHint("drag",!0),r.redrawHint("eles",!0),_e&&(_.emit("freeon"),ge.emit("free"),r.dragData.didDrag&&(_.emit("dragfreeon"),ge.emit("dragfree"))),n(_,["touchend","tapend","vmouseup","tapdragout"],P,{x:X[0],y:X[1]}),_.unactivate(),r.touchData.start=null}else{var $e=r.findNearestElement(X[0],X[1],!0,!0);n($e,["touchend","tapend","vmouseup","tapdragout"],P,{x:X[0],y:X[1]})}var br=r.touchData.startPosition[0]-X[0],Fr=br*br,Xe=r.touchData.startPosition[1]-X[1],Qe=Xe*Xe,Je=Fr+Qe,dr=Je*ae*ae;r.touchData.singleTouchMoved||(_||q.$(":selected").unselect(["tapunselect"]),n(_,["tap","vclick"],P,{x:X[0],y:X[1]}),Ce=!1,P.timeStamp-Ie<=q.multiClickDebounceTime()?(Ae&&clearTimeout(Ae),Ce=!0,Ie=null,n(_,["dbltap","vdblclick"],P,{x:X[0],y:X[1]})):(Ae=setTimeout(function(){Ce||n(_,["onetap","voneclick"],P,{x:X[0],y:X[1]})},q.multiClickDebounceTime()),Ie=P.timeStamp)),_!=null&&!r.dragData.didDrag&&_._private.selectable&&dr<r.touchTapThreshold2&&!r.pinching&&(q.selectionType()==="single"?(q.$(t).unmerge(_).unselect(["tapunselect"]),_.select(["tapselect"])):_.selected()?_.unselect(["tapunselect"]):_.select(["tapselect"]),r.redrawHint("eles",!0)),r.touchData.singleTouchMoved=!0}}}for(var cr=0;cr<X.length;cr++)ne[cr]=X[cr];r.dragData.didDrag=!1,P.touches.length===0&&(r.touchData.dragDelta=[],r.touchData.startPosition=[null,null,null,null,null,null],r.touchData.startGPosition=null,r.touchData.didSelect=!1),P.touches.length<2&&(P.touches.length===1&&(r.touchData.startGPosition=[P.touches[0].clientX,P.touches[0].clientY]),r.pinching=!1,r.redrawHint("eles",!0),r.redraw())},!1),typeof TouchEvent>"u"){var le=[],oe=function(P){return{clientX:P.clientX,clientY:P.clientY,force:1,identifier:P.pointerId,pageX:P.pageX,pageY:P.pageY,radiusX:P.width/2,radiusY:P.height/2,screenX:P.screenX,screenY:P.screenY,target:P.target}},pe=function(P){return{event:P,touch:oe(P)}},me=function(P){le.push(pe(P))},he=function(P){for(var _=0;_<le.length;_++){var U=le[_];if(U.event.pointerId===P.pointerId){le.splice(_,1);return}}},ye=function(P){var _=le.filter(function(U){return U.event.pointerId===P.pointerId})[0];_.event=P,_.touch=oe(P)},Ee=function(P){P.touches=le.map(function(_){return _.touch})},Te=function(P){return P.pointerType==="mouse"||P.pointerType===4};r.registerBinding(r.container,"pointerdown",function(J){Te(J)||(J.preventDefault(),me(J),Ee(J),G(J))}),r.registerBinding(r.container,"pointerup",function(J){Te(J)||(he(J),Ee(J),ue(J))}),r.registerBinding(r.container,"pointercancel",function(J){Te(J)||(he(J),Ee(J),ie(J))}),r.registerBinding(r.container,"pointermove",function(J){Te(J)||(J.preventDefault(),ye(J),Ee(J),ee(J))})}};var Ur={};Ur.generatePolygon=function(r,e){return this.nodeShapes[r]={renderer:this,name:r,points:e,draw:function(a,n,i,s,o,u){this.renderer.nodeShapeImpl("polygon",a,n,i,s,o,this.points)},intersectLine:function(a,n,i,s,o,u,l,v){return ya(o,u,this.points,a,n,i/2,s/2,l)},checkPoint:function(a,n,i,s,o,u,l,v){return Wr(a,n,this.points,u,l,s,o,[0,-1],i)}}},Ur.generateEllipse=function(){return this.nodeShapes.ellipse={renderer:this,name:"ellipse",draw:function(e,t,a,n,i,s){this.renderer.nodeShapeImpl(this.name,e,t,a,n,i)},intersectLine:function(e,t,a,n,i,s,o,u){return Jf(i,s,e,t,a/2+o,n/2+o)},checkPoint:function(e,t,a,n,i,s,o,u){return mt(e,t,n,i,s,o,a)}}},Ur.generateRoundPolygon=function(r,e){return this.nodeShapes[r]={renderer:this,name:r,points:e,getOrCreateCorners:function(a,n,i,s,o,u,l){if(u[l]!==void 0&&u[l+"-cx"]===a&&u[l+"-cy"]===n)return u[l];u[l]=new Array(e.length/2),u[l+"-cx"]=a,u[l+"-cy"]=n;var v=i/2,f=s/2;o=o==="auto"?Ws(i,s):o;for(var d=new Array(e.length/2),h=0;h<e.length/2;h++)d[h]={x:a+v*e[h*2],y:n+f*e[h*2+1]};var c,m,g,p,y=d.length;for(m=d[y-1],c=0;c<y;c++)g=d[c%y],p=d[(c+1)%y],u[l][c]=zi(m,g,p,o),m=g,g=p;return u[l]},draw:function(a,n,i,s,o,u,l){this.renderer.nodeShapeImpl("round-polygon",a,n,i,s,o,this.points,this.getOrCreateCorners(n,i,s,o,u,l,"drawCorners"))},intersectLine:function(a,n,i,s,o,u,l,v,f){return jf(o,u,this.points,a,n,i,s,l,this.getOrCreateCorners(a,n,i,s,v,f,"corners"))},checkPoint:function(a,n,i,s,o,u,l,v,f){return Qf(a,n,this.points,u,l,s,o,this.getOrCreateCorners(u,l,s,o,v,f,"corners"))}}},Ur.generateRoundRectangle=function(){return this.nodeShapes["round-rectangle"]=this.nodeShapes.roundrectangle={renderer:this,name:"round-rectangle",points:vr(4,0),draw:function(e,t,a,n,i,s){this.renderer.nodeShapeImpl(this.name,e,t,a,n,i,this.points,s)},intersectLine:function(e,t,a,n,i,s,o,u){return $s(i,s,e,t,a,n,o,u)},checkPoint:function(e,t,a,n,i,s,o,u){var l=n/2,v=i/2;u=u==="auto"?yt(n,i):u,u=Math.min(l,v,u);var f=u*2;return!!(Wr(e,t,this.points,s,o,n,i-f,[0,-1],a)||Wr(e,t,this.points,s,o,n-f,i,[0,-1],a)||mt(e,t,f,f,s-l+u,o-v+u,a)||mt(e,t,f,f,s+l-u,o-v+u,a)||mt(e,t,f,f,s+l-u,o+v-u,a)||mt(e,t,f,f,s-l+u,o+v-u,a))}}},Ur.generateCutRectangle=function(){return this.nodeShapes["cut-rectangle"]=this.nodeShapes.cutrectangle={renderer:this,name:"cut-rectangle",cornerLength:vi(),points:vr(4,0),draw:function(e,t,a,n,i,s){this.renderer.nodeShapeImpl(this.name,e,t,a,n,i,null,s)},generateCutTrianglePts:function(e,t,a,n,i){var s=i==="auto"?this.cornerLength:i,o=t/2,u=e/2,l=a-u,v=a+u,f=n-o,d=n+o;return{topLeft:[l,f+s,l+s,f,l+s,f+s],topRight:[v-s,f,v,f+s,v-s,f+s],bottomRight:[v,d-s,v-s,d,v-s,d-s],bottomLeft:[l+s,d,l,d-s,l+s,d-s]}},intersectLine:function(e,t,a,n,i,s,o,u){var l=this.generateCutTrianglePts(a+2*o,n+2*o,e,t,u),v=[].concat.apply([],[l.topLeft.splice(0,4),l.topRight.splice(0,4),l.bottomRight.splice(0,4),l.bottomLeft.splice(0,4)]);return ya(i,s,v,e,t)},checkPoint:function(e,t,a,n,i,s,o,u){var l=u==="auto"?this.cornerLength:u;if(Wr(e,t,this.points,s,o,n,i-2*l,[0,-1],a)||Wr(e,t,this.points,s,o,n-2*l,i,[0,-1],a))return!0;var v=this.generateCutTrianglePts(n,i,s,o);return gr(e,t,v.topLeft)||gr(e,t,v.topRight)||gr(e,t,v.bottomRight)||gr(e,t,v.bottomLeft)}}},Ur.generateBarrel=function(){return this.nodeShapes.barrel={renderer:this,name:"barrel",points:vr(4,0),draw:function(e,t,a,n,i,s){this.renderer.nodeShapeImpl(this.name,e,t,a,n,i)},intersectLine:function(e,t,a,n,i,s,o,u){var l=.15,v=.5,f=.85,d=this.generateBarrelBezierPts(a+2*o,n+2*o,e,t),h=function(g){var p=Mt({x:g[0],y:g[1]},{x:g[2],y:g[3]},{x:g[4],y:g[5]},l),y=Mt({x:g[0],y:g[1]},{x:g[2],y:g[3]},{x:g[4],y:g[5]},v),w=Mt({x:g[0],y:g[1]},{x:g[2],y:g[3]},{x:g[4],y:g[5]},f);return[g[0],g[1],p.x,p.y,y.x,y.y,w.x,w.y,g[4],g[5]]},c=[].concat(h(d.topLeft),h(d.topRight),h(d.bottomRight),h(d.bottomLeft));return ya(i,s,c,e,t)},generateBarrelBezierPts:function(e,t,a,n){var i=t/2,s=e/2,o=a-s,u=a+s,l=n-i,v=n+i,f=fi(e,t),d=f.heightOffset,h=f.widthOffset,c=f.ctrlPtOffsetPct*e,m={topLeft:[o,l+d,o+c,l,o+h,l],topRight:[u-h,l,u-c,l,u,l+d],bottomRight:[u,v-d,u-c,v,u-h,v],bottomLeft:[o+h,v,o+c,v,o,v-d]};return m.topLeft.isTop=!0,m.topRight.isTop=!0,m.bottomLeft.isBottom=!0,m.bottomRight.isBottom=!0,m},checkPoint:function(e,t,a,n,i,s,o,u){var l=fi(n,i),v=l.heightOffset,f=l.widthOffset;if(Wr(e,t,this.points,s,o,n,i-2*v,[0,-1],a)||Wr(e,t,this.points,s,o,n-2*f,i,[0,-1],a))return!0;for(var d=this.generateBarrelBezierPts(n,i,s,o),h=function(T,F,S){var D=S[4],C=S[2],B=S[0],A=S[5],M=S[1],I=Math.min(D,B),R=Math.max(D,B),L=Math.min(A,M),V=Math.max(A,M);if(I<=T&&T<=R&&L<=F&&F<=V){var H=ed(D,C,B),z=Kf(H[0],H[1],H[2],T),$=z.filter(function(K){return 0<=K&&K<=1});if($.length>0)return $[0]}return null},c=Object.keys(d),m=0;m<c.length;m++){var g=c[m],p=d[g],y=h(e,t,p);if(y!=null){var w=p[5],b=p[3],k=p[1],x=Ze(w,b,k,y);if(p.isTop&&x<=t||p.isBottom&&t<=x)return!0}}return!1}}},Ur.generateBottomRoundrectangle=function(){return this.nodeShapes["bottom-round-rectangle"]=this.nodeShapes.bottomroundrectangle={renderer:this,name:"bottom-round-rectangle",points:vr(4,0),draw:function(e,t,a,n,i,s){this.renderer.nodeShapeImpl(this.name,e,t,a,n,i,this.points,s)},intersectLine:function(e,t,a,n,i,s,o,u){var l=e-(a/2+o),v=t-(n/2+o),f=v,d=e+(a/2+o),h=at(i,s,e,t,l,v,d,f,!1);return h.length>0?h:$s(i,s,e,t,a,n,o,u)},checkPoint:function(e,t,a,n,i,s,o,u){u=u==="auto"?yt(n,i):u;var l=2*u;if(Wr(e,t,this.points,s,o,n,i-l,[0,-1],a)||Wr(e,t,this.points,s,o,n-l,i,[0,-1],a))return!0;var v=n/2+2*a,f=i/2+2*a,d=[s-v,o-f,s-v,o,s+v,o,s+v,o-f];return!!(gr(e,t,d)||mt(e,t,l,l,s+n/2-u,o+i/2-u,a)||mt(e,t,l,l,s-n/2+u,o+i/2-u,a))}}},Ur.registerNodeShapes=function(){var r=this.nodeShapes={},e=this;this.generateEllipse(),this.generatePolygon("triangle",vr(3,0)),this.generateRoundPolygon("round-triangle",vr(3,0)),this.generatePolygon("rectangle",vr(4,0)),r.square=r.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();{var t=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",t),this.generateRoundPolygon("round-diamond",t)}this.generatePolygon("pentagon",vr(5,0)),this.generateRoundPolygon("round-pentagon",vr(5,0)),this.generatePolygon("hexagon",vr(6,0)),this.generateRoundPolygon("round-hexagon",vr(6,0)),this.generatePolygon("heptagon",vr(7,0)),this.generateRoundPolygon("round-heptagon",vr(7,0)),this.generatePolygon("octagon",vr(8,0)),this.generateRoundPolygon("round-octagon",vr(8,0));var a=new Array(20);{var n=li(5,0),i=li(5,Math.PI/5),s=.5*(3-Math.sqrt(5));s*=1.57;for(var o=0;o<i.length/2;o++)i[o*2]*=s,i[o*2+1]*=s;for(var o=0;o<20/4;o++)a[o*4]=n[o*2],a[o*4+1]=n[o*2+1],a[o*4+2]=i[o*2],a[o*4+3]=i[o*2+1]}a=qs(a),this.generatePolygon("star",a),this.generatePolygon("vee",[-1,-1,0,-.333,1,-1,0,1]),this.generatePolygon("rhomboid",[-1,-1,.333,-1,1,1,-.333,1]),this.generatePolygon("right-rhomboid",[-.333,-1,1,-1,.333,1,-1,1]),this.nodeShapes.concavehexagon=this.generatePolygon("concave-hexagon",[-1,-.95,-.75,0,-1,.95,1,.95,.75,0,1,-.95]);{var u=[-1,-1,.25,-1,1,0,.25,1,-1,1];this.generatePolygon("tag",u),this.generateRoundPolygon("round-tag",u)}r.makePolygon=function(l){var v=l.join("$"),f="polygon-"+v,d;return(d=this[f])?d:e.generatePolygon(f,l)}};var Ma={};Ma.timeToRender=function(){return this.redrawTotalTime/this.redrawCount},Ma.redraw=function(r){r=r||Rs();var e=this;e.averageRedrawTime===void 0&&(e.averageRedrawTime=0),e.lastRedrawTime===void 0&&(e.lastRedrawTime=0),e.lastDrawTime===void 0&&(e.lastDrawTime=0),e.requestedFrame=!0,e.renderOptions=r},Ma.beforeRender=function(r,e){if(!this.destroyed){e==null&&Ve("Priority is not optional for beforeRender");var t=this.beforeRenderCallbacks;t.push({fn:r,priority:e}),t.sort(function(a,n){return n.priority-a.priority})}};var Ou=function(e,t,a){for(var n=e.beforeRenderCallbacks,i=0;i<n.length;i++)n[i].fn(t,a)};Ma.startRenderLoop=function(){var r=this,e=r.cy;if(!r.renderLoopStarted){r.renderLoopStarted=!0;var t=function a(n){if(!r.destroyed){if(!e.batching())if(r.requestedFrame&&!r.skipFrame){Ou(r,!0,n);var i=qr();r.render(r.renderOptions);var s=r.lastDrawTime=qr();r.averageRedrawTime===void 0&&(r.averageRedrawTime=s-i),r.redrawCount===void 0&&(r.redrawCount=0),r.redrawCount++,r.redrawTotalTime===void 0&&(r.redrawTotalTime=0);var o=s-i;r.redrawTotalTime+=o,r.lastRedrawTime=o,r.averageRedrawTime=r.averageRedrawTime/2+o/2,r.requestedFrame=!1}else Ou(r,!1,n);r.skipFrame=!1,Xa(a)}};Xa(t)}};var L0=function(e){this.init(e)},_u=L0,Jt=_u.prototype;Jt.clientFunctions=["redrawHint","render","renderTo","matchCanvasSize","nodeShapeImpl","arrowShapeImpl"],Jt.init=function(r){var e=this;e.options=r,e.cy=r.cy;var t=e.container=r.cy.container(),a=e.cy.window();if(a){var n=a.document,i=n.head,s="__________cytoscape_stylesheet",o="__________cytoscape_container",u=n.getElementById(s)!=null;if(t.className.indexOf(o)<0&&(t.className=(t.className||"")+" "+o),!u){var l=n.createElement("style");l.id=s,l.textContent="."+o+" { position: relative; }",i.insertBefore(l,i.children[0])}var v=a.getComputedStyle(t),f=v.getPropertyValue("position");f==="static"&&Pe("A Cytoscape container has style position:static and so can not use UI extensions properly")}e.selection=[void 0,void 0,void 0,void 0,0],e.bezierProjPcts=[.05,.225,.4,.5,.6,.775,.95],e.hoverData={down:null,last:null,downTime:null,triggerMode:null,dragging:!1,initialPan:[null,null],capture:!1},e.dragData={possibleDragElements:[]},e.touchData={start:null,capture:!1,startPosition:[null,null,null,null,null,null],singleTouchStartTime:null,singleTouchMoved:!0,now:[null,null,null,null,null,null],earlier:[null,null,null,null,null,null]},e.redraws=0,e.showFps=r.showFps,e.debug=r.debug,e.webgl=r.webgl,e.hideEdgesOnViewport=r.hideEdgesOnViewport,e.textureOnViewport=r.textureOnViewport,e.wheelSensitivity=r.wheelSensitivity,e.motionBlurEnabled=r.motionBlur,e.forcedPixelRatio=te(r.pixelRatio)?r.pixelRatio:null,e.motionBlur=r.motionBlur,e.motionBlurOpacity=r.motionBlurOpacity,e.motionBlurTransparency=1-e.motionBlurOpacity,e.motionBlurPxRatio=1,e.mbPxRBlurry=1,e.minMbLowQualFrames=4,e.fullQualityMb=!1,e.clearedForMotionBlur=[],e.desktopTapThreshold=r.desktopTapThreshold,e.desktopTapThreshold2=r.desktopTapThreshold*r.desktopTapThreshold,e.touchTapThreshold=r.touchTapThreshold,e.touchTapThreshold2=r.touchTapThreshold*r.touchTapThreshold,e.tapholdDuration=500,e.bindings=[],e.beforeRenderCallbacks=[],e.beforeRenderPriorities={animations:400,eleCalcs:300,eleTxrDeq:200,lyrTxrDeq:150,lyrTxrSkip:100},e.registerNodeShapes(),e.registerArrowShapes(),e.registerCalculationListeners()},Jt.notify=function(r,e){var t=this,a=t.cy;if(!this.destroyed){if(r==="init"){t.load();return}if(r==="destroy"){t.destroy();return}(r==="add"||r==="remove"||r==="move"&&a.hasCompoundNodes()||r==="load"||r==="zorder"||r==="mount")&&t.invalidateCachedZSortedEles(),r==="viewport"&&t.redrawHint("select",!0),r==="gc"&&t.redrawHint("gc",!0),(r==="load"||r==="resize"||r==="mount")&&(t.invalidateContainerClientCoordsCache(),t.matchCanvasSize(t.container)),t.redrawHint("eles",!0),t.redrawHint("drag",!0),this.startRenderLoop(),this.redraw()}},Jt.destroy=function(){var r=this;r.destroyed=!0,r.cy.stopAnimationLoop();for(var e=0;e<r.bindings.length;e++){var t=r.bindings[e],a=t,n=a.target;(n.off||n.removeEventListener).apply(n,a.args)}if(r.bindings=[],r.beforeRenderCallbacks=[],r.onUpdateEleCalcsFns=[],r.removeObserver&&r.removeObserver.disconnect(),r.styleObserver&&r.styleObserver.disconnect(),r.resizeObserver&&r.resizeObserver.disconnect(),r.labelCalcDiv)try{document.body.removeChild(r.labelCalcDiv)}catch{}},Jt.isHeadless=function(){return!1},[Ri,Ru,Lu,Qt,Ur,Ma].forEach(function(r){ce(Jt,r)});var $i=1e3/60,Nu={setupDequeueing:function(e){return function(){var a=this,n=this.renderer;if(!a.dequeueingSetup){a.dequeueingSetup=!0;var i=va(function(){n.redrawHint("eles",!0),n.redrawHint("drag",!0),n.redraw()},e.deqRedrawThreshold),s=function(l,v){var f=qr(),d=n.averageRedrawTime,h=n.lastRedrawTime,c=[],m=n.cy.extent(),g=n.getPixelRatio();for(l||n.flushRenderedStyleQueue();;){var p=qr(),y=p-f,w=p-v;if(h<$i){var b=$i-(l?d:0);if(w>=e.deqFastCost*b)break}else if(l){if(y>=e.deqCost*h||y>=e.deqAvgCost*d)break}else if(w>=e.deqNoDrawCost*$i)break;var k=e.deq(a,g,m);if(k.length>0)for(var x=0;x<k.length;x++)c.push(k[x]);else break}c.length>0&&(e.onDeqd(a,c),!l&&e.shouldRedraw(a,c,g,m)&&i())},o=e.priority||ai;n.beforeRender(s,o(a))}}}},O0=function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Za;Zr(this,r),this.idsByKey=new Mr,this.keyForId=new Mr,this.cachesByLvl=new Mr,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=t}return Qr(r,[{key:"getIdsFor",value:function(t){t==null&&Ve("Can not get id list for null key");var a=this.idsByKey,n=this.idsByKey.get(t);return n||(n=new At,a.set(t,n)),n}},{key:"addIdForKey",value:function(t,a){t!=null&&this.getIdsFor(t).add(a)}},{key:"deleteIdForKey",value:function(t,a){t!=null&&this.getIdsFor(t).delete(a)}},{key:"getNumberOfIdsForKey",value:function(t){return t==null?0:this.getIdsFor(t).size}},{key:"updateKeyMappingFor",value:function(t){var a=t.id(),n=this.keyForId.get(a),i=this.getKey(t);this.deleteIdForKey(n,a),this.addIdForKey(i,a),this.keyForId.set(a,i)}},{key:"deleteKeyMappingFor",value:function(t){var a=t.id(),n=this.keyForId.get(a);this.deleteIdForKey(n,a),this.keyForId.delete(a)}},{key:"keyHasChangedFor",value:function(t){var a=t.id(),n=this.keyForId.get(a),i=this.getKey(t);return n!==i}},{key:"isInvalid",value:function(t){return this.keyHasChangedFor(t)||this.doesEleInvalidateKey(t)}},{key:"getCachesAt",value:function(t){var a=this.cachesByLvl,n=this.lvls,i=a.get(t);return i||(i=new Mr,a.set(t,i),n.push(t)),i}},{key:"getCache",value:function(t,a){return this.getCachesAt(a).get(t)}},{key:"get",value:function(t,a){var n=this.getKey(t),i=this.getCache(n,a);return i!=null&&this.updateKeyMappingFor(t),i}},{key:"getForCachedKey",value:function(t,a){var n=this.keyForId.get(t.id()),i=this.getCache(n,a);return i}},{key:"hasCache",value:function(t,a){return this.getCachesAt(a).has(t)}},{key:"has",value:function(t,a){var n=this.getKey(t);return this.hasCache(n,a)}},{key:"setCache",value:function(t,a,n){n.key=t,this.getCachesAt(a).set(t,n)}},{key:"set",value:function(t,a,n){var i=this.getKey(t);this.setCache(i,a,n),this.updateKeyMappingFor(t)}},{key:"deleteCache",value:function(t,a){this.getCachesAt(a).delete(t)}},{key:"delete",value:function(t,a){var n=this.getKey(t);this.deleteCache(n,a)}},{key:"invalidateKey",value:function(t){var a=this;this.lvls.forEach(function(n){return a.deleteCache(t,n)})}},{key:"invalidate",value:function(t){var a=t.id(),n=this.keyForId.get(a);this.deleteKeyMappingFor(t);var i=this.doesEleInvalidateKey(t);return i&&this.invalidateKey(n),i||this.getNumberOfIdsForKey(n)===0}}]),r}(),zu=25,Nn=50,zn=-4,qi=3,Vu=7.99,_0=8,N0=1024,z0=1024,V0=1024,$0=.2,q0=.8,W0=10,H0=.15,G0=.1,U0=.9,K0=.9,X0=100,Y0=1,jt={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},Z0=Ye({getKey:null,doesEleInvalidateKey:Za,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Bs,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),Ra=function(e,t){var a=this;a.renderer=e,a.onDequeues=[];var n=Z0(t);ce(a,n),a.lookup=new O0(n.getKey,n.doesEleInvalidateKey),a.setupDequeueing()},Ke=Ra.prototype;Ke.reasons=jt,Ke.getTextureQueue=function(r){var e=this;return e.eleImgCaches=e.eleImgCaches||{},e.eleImgCaches[r]=e.eleImgCaches[r]||[]},Ke.getRetiredTextureQueue=function(r){var e=this,t=e.eleImgCaches.retired=e.eleImgCaches.retired||{},a=t[r]=t[r]||[];return a},Ke.getElementQueue=function(){var r=this,e=r.eleCacheQueue=r.eleCacheQueue||new ga(function(t,a){return a.reqs-t.reqs});return e},Ke.getElementKeyToQueue=function(){var r=this,e=r.eleKeyToCacheQueue=r.eleKeyToCacheQueue||{};return e},Ke.getElement=function(r,e,t,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)||!r.visible()||r.removed()||!i.allowEdgeTxrCaching&&r.isEdge()||!i.allowParentTxrCaching&&r.isParent())return null;if(a==null&&(a=Math.ceil(si(o*t))),a<zn)a=zn;else if(o>=Vu||a>qi)return null;var l=Math.pow(2,a),v=e.h*l,f=e.w*l,d=s.eleTextBiggerThanMin(r,l);if(!this.isVisible(r,d))return null;var h=u.get(r,a);if(h&&h.invalidated&&(h.invalidated=!1,h.texture.invalidatedWidth-=h.width),h)return h;var c;if(v<=zu?c=zu:v<=Nn?c=Nn:c=Math.ceil(v/Nn)*Nn,v>V0||f>z0)return null;var m=i.getTextureQueue(c),g=m[m.length-2],p=function(){return i.recycleTexture(c,f)||i.addTexture(c,f)};g||(g=m[m.length-1]),g||(g=p()),g.width-g.usedWidth<f&&(g=p());for(var y=function(I){return I&&I.scaledLabelShown===d},w=n&&n===jt.dequeue,b=n&&n===jt.highQuality,k=n&&n===jt.downscale,x,E=a+1;E<=qi;E++){var T=u.get(r,E);if(T){x=T;break}}var F=x&&x.level===a+1?x:null,S=function(){g.context.drawImage(F.texture.canvas,F.x,0,F.width,F.height,g.usedWidth,0,f,v)};if(g.context.setTransform(1,0,0,1,0,0),g.context.clearRect(g.usedWidth,0,f,c),y(F))S();else if(y(x))if(b){for(var D=x.level;D>a;D--)F=i.getElement(r,e,t,D,jt.downscale);S()}else return i.queueElement(r,x.level-1),x;else{var C;if(!w&&!b&&!k)for(var B=a-1;B>=zn;B--){var A=u.get(r,B);if(A){C=A;break}}if(y(C))return i.queueElement(r,a),C;g.context.translate(g.usedWidth,0),g.context.scale(l,l),this.drawElement(g.context,r,e,d,!1),g.context.scale(1/l,1/l),g.context.translate(-g.usedWidth,0)}return h={x:g.usedWidth,texture:g,level:a,scale:l,width:f,height:v,scaledLabelShown:d},g.usedWidth+=Math.ceil(f+_0),g.eleCaches.push(h),u.set(r,a,h),i.checkTextureFullness(g),h},Ke.invalidateElements=function(r){for(var e=0;e<r.length;e++)this.invalidateElement(r[e])},Ke.invalidateElement=function(r){var e=this,t=e.lookup,a=[],n=t.isInvalid(r);if(n){for(var i=zn;i<=qi;i++){var s=t.getForCachedKey(r,i);s&&a.push(s)}var o=t.invalidate(r);if(o)for(var u=0;u<a.length;u++){var l=a[u],v=l.texture;v.invalidatedWidth+=l.width,l.invalidated=!0,e.checkTextureUtility(v)}e.removeFromQueue(r)}},Ke.checkTextureUtility=function(r){r.invalidatedWidth>=$0*r.width&&this.retireTexture(r)},Ke.checkTextureFullness=function(r){var e=this,t=e.getTextureQueue(r.height);r.usedWidth/r.width>q0&&r.fullnessChecks>=W0?rt(t,r):r.fullnessChecks++},Ke.retireTexture=function(r){var e=this,t=r.height,a=e.getTextureQueue(t),n=this.lookup;rt(a,r),r.retired=!0;for(var i=r.eleCaches,s=0;s<i.length;s++){var o=i[s];n.deleteCache(o.key,o.level)}ni(i);var u=e.getRetiredTextureQueue(t);u.push(r)},Ke.addTexture=function(r,e){var t=this,a=t.getTextureQueue(r),n={};return a.push(n),n.eleCaches=[],n.height=r,n.width=Math.max(N0,e),n.usedWidth=0,n.invalidatedWidth=0,n.fullnessChecks=0,n.canvas=t.renderer.makeOffscreenCanvas(n.width,n.height),n.context=n.canvas.getContext("2d"),n},Ke.recycleTexture=function(r,e){for(var t=this,a=t.getTextureQueue(r),n=t.getRetiredTextureQueue(r),i=0;i<n.length;i++){var s=n[i];if(s.width>=e)return s.retired=!1,s.usedWidth=0,s.invalidatedWidth=0,s.fullnessChecks=0,ni(s.eleCaches),s.context.setTransform(1,0,0,1,0,0),s.context.clearRect(0,0,s.width,s.height),rt(n,s),a.push(s),s}},Ke.queueElement=function(r,e){var t=this,a=t.getElementQueue(),n=t.getElementKeyToQueue(),i=this.getKey(r),s=n[i];if(s)s.level=Math.max(s.level,e),s.eles.merge(r),s.reqs++,a.updateItem(s);else{var o={eles:r.spawn().merge(r),level:e,reqs:1,key:i};a.push(o),n[i]=o}},Ke.dequeue=function(r){for(var e=this,t=e.getElementQueue(),a=e.getElementKeyToQueue(),n=[],i=e.lookup,s=0;s<Y0&&t.size()>0;s++){var o=t.pop(),u=o.key,l=o.eles[0],v=i.hasCache(l,o.level);if(a[u]=null,v)continue;n.push(o);var f=e.getBoundingBox(l);e.getElement(l,f,r,o.level,jt.dequeue)}return n},Ke.removeFromQueue=function(r){var e=this,t=e.getElementQueue(),a=e.getElementKeyToQueue(),n=this.getKey(r),i=a[n];i!=null&&(i.eles.length===1?(i.reqs=ti,t.updateItem(i),t.pop(),a[n]=null):i.eles.unmerge(r))},Ke.onDequeue=function(r){this.onDequeues.push(r)},Ke.offDequeue=function(r){rt(this.onDequeues,r)},Ke.setupDequeueing=Nu.setupDequeueing({deqRedrawThreshold:X0,deqCost:H0,deqAvgCost:G0,deqNoDrawCost:U0,deqFastCost:K0,deq:function(e,t,a){return e.dequeue(t,a)},onDeqd:function(e,t){for(var a=0;a<e.onDequeues.length;a++){var n=e.onDequeues[a];n(t)}},shouldRedraw:function(e,t,a,n){for(var i=0;i<t.length;i++)for(var s=t[i].eles,o=0;o<s.length;o++){var u=s[o].boundingBox();if(oi(u,n))return!0}return!1},priority:function(e){return e.renderer.beforeRenderPriorities.eleTxrDeq}});var Q0=1,La=-4,Vn=2,J0=3.99,j0=50,ep=50,rp=.15,tp=.1,ap=.9,np=.9,ip=1,$u=250,sp=4e3*4e3,qu=32767,op=!0,Wu=function(e){var t=this,a=t.renderer=e,n=a.cy;t.layersByLevel={},t.firstGet=!0,t.lastInvalidationTime=qr()-2*$u,t.skipping=!1,t.eleTxrDeqs=n.collection(),t.scheduleElementRefinement=va(function(){t.refineElementTextures(t.eleTxrDeqs),t.eleTxrDeqs.unmerge(t.eleTxrDeqs)},ep),a.beforeRender(function(s,o){o-t.lastInvalidationTime<=$u?t.skipping=!0:t.skipping=!1},a.beforeRenderPriorities.lyrTxrSkip);var i=function(o,u){return u.reqs-o.reqs};t.layersQueue=new ga(i),t.setupDequeueing()},ar=Wu.prototype,Hu=0,up=Math.pow(2,53)-1;ar.makeLayer=function(r,e){var t=Math.pow(2,e),a=Math.ceil(r.w*t),n=Math.ceil(r.h*t),i=this.renderer.makeOffscreenCanvas(a,n),s={id:Hu=++Hu%up,bb:r,level:e,width:a,height:n,canvas:i,context:i.getContext("2d"),eles:[],elesQueue:[],reqs:0},o=s.context,u=-s.bb.x1,l=-s.bb.y1;return o.scale(t,t),o.translate(u,l),s},ar.getLayers=function(r,e,t){var a=this,n=a.renderer,i=n.cy,s=i.zoom(),o=a.firstGet;if(a.firstGet=!1,t==null){if(t=Math.ceil(si(s*e)),t<La)t=La;else if(s>=J0||t>Vn)return null}a.validateLayersElesOrdering(t,r);var u=a.layersByLevel,l=Math.pow(2,t),v=u[t]=u[t]||[],f,d=a.levelIsComplete(t,r),h,c=function(){var S=function(M){if(a.validateLayersElesOrdering(M,r),a.levelIsComplete(M,r))return h=u[M],!0},D=function(M){if(!h)for(var I=t+M;La<=I&&I<=Vn&&!S(I);I+=M);};D(1),D(-1);for(var C=v.length-1;C>=0;C--){var B=v[C];B.invalid&&rt(v,B)}};if(!d)c();else return v;var m=function(){if(!f){f=hr();for(var S=0;S<r.length;S++)Ns(f,r[S].boundingBox())}return f},g=function(S){S=S||{};var D=S.after;m();var C=Math.ceil(f.w*l),B=Math.ceil(f.h*l);if(C>qu||B>qu)return null;var A=C*B;if(A>sp)return null;var M=a.makeLayer(f,t);if(D!=null){var I=v.indexOf(D)+1;v.splice(I,0,M)}else(S.insert===void 0||S.insert)&&v.unshift(M);return M};if(a.skipping&&!o)return null;for(var p=null,y=r.length/Q0,w=!o,b=0;b<r.length;b++){var k=r[b],x=k._private.rscratch,E=x.imgLayerCaches=x.imgLayerCaches||{},T=E[t];if(T){p=T;continue}if((!p||p.eles.length>=y||!Vs(p.bb,k.boundingBox()))&&(p=g({insert:!0,after:p}),!p))return null;h||w?a.queueLayer(p,k):a.drawEleInLayer(p,k,t,e),p.eles.push(k),E[t]=p}return h||(w?null:v)},ar.getEleLevelForLayerLevel=function(r,e){return r},ar.drawEleInLayer=function(r,e,t,a){var n=this,i=this.renderer,s=r.context,o=e.boundingBox();o.w===0||o.h===0||!e.visible()||(t=n.getEleLevelForLayerLevel(t,a),i.setImgSmoothing(s,!1),i.drawCachedElement(s,e,null,null,t,op),i.setImgSmoothing(s,!0))},ar.levelIsComplete=function(r,e){var t=this,a=t.layersByLevel[r];if(!a||a.length===0)return!1;for(var n=0,i=0;i<a.length;i++){var s=a[i];if(s.reqs>0||s.invalid)return!1;n+=s.eles.length}return n===e.length},ar.validateLayersElesOrdering=function(r,e){var t=this.layersByLevel[r];if(t)for(var a=0;a<t.length;a++){for(var n=t[a],i=-1,s=0;s<e.length;s++)if(n.eles[0]===e[s]){i=s;break}if(i<0){this.invalidateLayer(n);continue}for(var o=i,s=0;s<n.eles.length;s++)if(n.eles[s]!==e[o+s]){this.invalidateLayer(n);break}}},ar.updateElementsInLayers=function(r,e){for(var t=this,a=ia(r[0]),n=0;n<r.length;n++)for(var i=a?null:r[n],s=a?r[n]:r[n].ele,o=s._private.rscratch,u=o.imgLayerCaches=o.imgLayerCaches||{},l=La;l<=Vn;l++){var v=u[l];v&&(i&&t.getEleLevelForLayerLevel(v.level)!==i.level||e(v,s,i))}},ar.haveLayers=function(){for(var r=this,e=!1,t=La;t<=Vn;t++){var a=r.layersByLevel[t];if(a&&a.length>0){e=!0;break}}return e},ar.invalidateElements=function(r){var e=this;r.length!==0&&(e.lastInvalidationTime=qr(),!(r.length===0||!e.haveLayers())&&e.updateElementsInLayers(r,function(a,n,i){e.invalidateLayer(a)}))},ar.invalidateLayer=function(r){if(this.lastInvalidationTime=qr(),!r.invalid){var e=r.level,t=r.eles,a=this.layersByLevel[e];rt(a,r),r.elesQueue=[],r.invalid=!0,r.replacement&&(r.replacement.invalid=!0);for(var n=0;n<t.length;n++){var i=t[n]._private.rscratch.imgLayerCaches;i&&(i[e]=null)}}},ar.refineElementTextures=function(r){var e=this;e.updateElementsInLayers(r,function(a,n,i){var s=a.replacement;if(s||(s=a.replacement=e.makeLayer(a.bb,a.level),s.replaces=a,s.eles=a.eles),!s.reqs)for(var o=0;o<s.eles.length;o++)e.queueLayer(s,s.eles[o])})},ar.enqueueElementRefinement=function(r){this.eleTxrDeqs.merge(r),this.scheduleElementRefinement()},ar.queueLayer=function(r,e){var t=this,a=t.layersQueue,n=r.elesQueue,i=n.hasId=n.hasId||{};if(!r.replacement){if(e){if(i[e.id()])return;n.push(e),i[e.id()]=!0}r.reqs?(r.reqs++,a.updateItem(r)):(r.reqs=1,a.push(r))}},ar.dequeue=function(r){for(var e=this,t=e.layersQueue,a=[],n=0;n<ip&&t.size()!==0;){var i=t.peek();if(i.replacement){t.pop();continue}if(i.replaces&&i!==i.replaces.replacement){t.pop();continue}if(i.invalid){t.pop();continue}var s=i.elesQueue.shift();s&&(e.drawEleInLayer(i,s,i.level,r),n++),a.length===0&&a.push(!0),i.elesQueue.length===0&&(t.pop(),i.reqs=0,i.replaces&&e.applyLayerReplacement(i),e.requestRedraw())}return a},ar.applyLayerReplacement=function(r){var e=this,t=e.layersByLevel[r.level],a=r.replaces,n=t.indexOf(a);if(!(n<0||a.invalid)){t[n]=r;for(var i=0;i<r.eles.length;i++){var s=r.eles[i]._private,o=s.imgLayerCaches=s.imgLayerCaches||{};o&&(o[r.level]=r)}e.requestRedraw()}},ar.requestRedraw=va(function(){var r=this.renderer;r.redrawHint("eles",!0),r.redrawHint("drag",!0),r.redraw()},100),ar.setupDequeueing=Nu.setupDequeueing({deqRedrawThreshold:j0,deqCost:rp,deqAvgCost:tp,deqNoDrawCost:ap,deqFastCost:np,deq:function(e,t){return e.dequeue(t)},onDeqd:ai,shouldRedraw:Bs,priority:function(e){return e.renderer.beforeRenderPriorities.lyrTxrDeq}});var Gu={},Uu;function lp(r,e){for(var t=0;t<e.length;t++){var a=e[t];r.lineTo(a.x,a.y)}}function vp(r,e,t){for(var a,n=0;n<e.length;n++){var i=e[n];n===0&&(a=i),r.lineTo(i.x,i.y)}r.quadraticCurveTo(t.x,t.y,a.x,a.y)}function Ku(r,e,t){r.beginPath&&r.beginPath();for(var a=e,n=0;n<a.length;n++){var i=a[n];r.lineTo(i.x,i.y)}var s=t,o=t[0];r.moveTo(o.x,o.y);for(var n=1;n<s.length;n++){var i=s[n];r.lineTo(i.x,i.y)}r.closePath&&r.closePath()}function fp(r,e,t,a,n){r.beginPath&&r.beginPath(),r.arc(t,a,n,0,Math.PI*2,!1);var i=e,s=i[0];r.moveTo(s.x,s.y);for(var o=0;o<i.length;o++){var u=i[o];r.lineTo(u.x,u.y)}r.closePath&&r.closePath()}function dp(r,e,t,a){r.arc(e,t,a,0,Math.PI*2,!1)}Gu.arrowShapeImpl=function(r){return(Uu||(Uu={polygon:lp,"triangle-backcurve":vp,"triangle-tee":Ku,"circle-triangle":fp,"triangle-cross":Ku,circle:dp}))[r]};var Nr={};Nr.drawElement=function(r,e,t,a,n,i){var s=this;e.isNode()?s.drawNode(r,e,t,a,n,i):s.drawEdge(r,e,t,a,n,i)},Nr.drawElementOverlay=function(r,e){var t=this;e.isNode()?t.drawNodeOverlay(r,e):t.drawEdgeOverlay(r,e)},Nr.drawElementUnderlay=function(r,e){var t=this;e.isNode()?t.drawNodeUnderlay(r,e):t.drawEdgeUnderlay(r,e)},Nr.drawCachedElementPortion=function(r,e,t,a,n,i,s,o){var u=this,l=t.getBoundingBox(e);if(!(l.w===0||l.h===0)){var v=t.getElement(e,l,a,n,i);if(v!=null){var f=o(u,e);if(f===0)return;var d=s(u,e),h=l.x1,c=l.y1,m=l.w,g=l.h,p,y,w,b,k;if(d!==0){var x=t.getRotationPoint(e);w=x.x,b=x.y,r.translate(w,b),r.rotate(d),k=u.getImgSmoothing(r),k||u.setImgSmoothing(r,!0);var E=t.getRotationOffset(e);p=E.x,y=E.y}else p=h,y=c;var T;f!==1&&(T=r.globalAlpha,r.globalAlpha=T*f),r.drawImage(v.texture.canvas,v.x,0,v.width,v.height,p,y,m,g),f!==1&&(r.globalAlpha=T),d!==0&&(r.rotate(-d),r.translate(-w,-b),k||u.setImgSmoothing(r,!1))}else t.drawElement(r,e)}};var cp=function(){return 0},hp=function(e,t){return e.getTextAngle(t,null)},gp=function(e,t){return e.getTextAngle(t,"source")},pp=function(e,t){return e.getTextAngle(t,"target")},mp=function(e,t){return t.effectiveOpacity()},Wi=function(e,t){return t.pstyle("text-opacity").pfValue*t.effectiveOpacity()};Nr.drawCachedElement=function(r,e,t,a,n,i){var s=this,o=s.data,u=o.eleTxrCache,l=o.lblTxrCache,v=o.slbTxrCache,f=o.tlbTxrCache,d=e.boundingBox(),h=i===!0?u.reasons.highQuality:null;if(!(d.w===0||d.h===0||!e.visible())&&(!a||oi(d,a))){var c=e.isEdge(),m=e.element()._private.rscratch.badLine;s.drawElementUnderlay(r,e),s.drawCachedElementPortion(r,e,u,t,n,h,cp,mp),(!c||!m)&&s.drawCachedElementPortion(r,e,l,t,n,h,hp,Wi),c&&!m&&(s.drawCachedElementPortion(r,e,v,t,n,h,gp,Wi),s.drawCachedElementPortion(r,e,f,t,n,h,pp,Wi)),s.drawElementOverlay(r,e)}},Nr.drawElements=function(r,e){for(var t=this,a=0;a<e.length;a++){var n=e[a];t.drawElement(r,n)}},Nr.drawCachedElements=function(r,e,t,a){for(var n=this,i=0;i<e.length;i++){var s=e[i];n.drawCachedElement(r,s,t,a)}},Nr.drawCachedNodes=function(r,e,t,a){for(var n=this,i=0;i<e.length;i++){var s=e[i];s.isNode()&&n.drawCachedElement(r,s,t,a)}},Nr.drawLayeredElements=function(r,e,t,a){var n=this,i=n.data.lyrTxrCache.getLayers(e,t);if(i)for(var s=0;s<i.length;s++){var o=i[s],u=o.bb;u.w===0||u.h===0||r.drawImage(o.canvas,u.x1,u.y1,u.w,u.h)}else n.drawCachedElements(r,e,t,a)};var Kr={};Kr.drawEdge=function(r,e,t){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=e._private.rscratch;if(!(i&&!e.visible())&&!(o.badLine||o.allpts==null||isNaN(o.allpts[0]))){var u;t&&(u=t,r.translate(-u.x1,-u.y1));var l=i?e.pstyle("opacity").value:1,v=i?e.pstyle("line-opacity").value:1,f=e.pstyle("curve-style").value,d=e.pstyle("line-style").value,h=e.pstyle("width").pfValue,c=e.pstyle("line-cap").value,m=e.pstyle("line-outline-width").value,g=e.pstyle("line-outline-color").value,p=l*v,y=l*v,w=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p;f==="straight-triangle"?(s.eleStrokeStyle(r,e,M),s.drawEdgeTrianglePath(e,r,o.allpts)):(r.lineWidth=h,r.lineCap=c,s.eleStrokeStyle(r,e,M),s.drawEdgePath(e,r,o.allpts,d),r.lineCap="butt")},b=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p;if(r.lineWidth=h+m,r.lineCap=c,m>0)s.colorStrokeStyle(r,g[0],g[1],g[2],M);else{r.lineCap="butt";return}f==="straight-triangle"?s.drawEdgeTrianglePath(e,r,o.allpts):(s.drawEdgePath(e,r,o.allpts,d),r.lineCap="butt")},k=function(){n&&s.drawEdgeOverlay(r,e)},x=function(){n&&s.drawEdgeUnderlay(r,e)},E=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y;s.drawArrowheads(r,e,M)},T=function(){s.drawElementText(r,e,null,a)};r.lineJoin="round";var F=e.pstyle("ghost").value==="yes";if(F){var S=e.pstyle("ghost-offset-x").pfValue,D=e.pstyle("ghost-offset-y").pfValue,C=e.pstyle("ghost-opacity").value,B=p*C;r.translate(S,D),w(B),E(B),r.translate(-S,-D)}else b();x(),w(),E(),k(),T(),t&&r.translate(u.x1,u.y1)}};var Xu=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,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,v=a.pstyle("".concat(e,"-color")).value;t.lineWidth=l,o.edgeType==="self"&&!s?t.lineCap="butt":t.lineCap="round",i.colorStrokeStyle(t,v[0],v[1],v[2],n),i.drawEdgePath(a,t,o.allpts,"solid")}}}};Kr.drawEdgeOverlay=Xu("overlay"),Kr.drawEdgeUnderlay=Xu("underlay"),Kr.drawEdgePath=function(r,e,t,a){var n=r._private.rscratch,i=e,s,o=!1,u=this.usePaths(),l=r.pstyle("line-dash-pattern").pfValue,v=r.pstyle("line-dash-offset").pfValue;if(u){var f=t.join("$"),d=n.pathCacheKey&&n.pathCacheKey===f;d?(s=e=n.pathCache,o=!0):(s=e=new Path2D,n.pathCacheKey=f,n.pathCache=s)}if(i.setLineDash)switch(a){case"dotted":i.setLineDash([1,1]);break;case"dashed":i.setLineDash(l),i.lineDashOffset=v;break;case"solid":i.setLineDash([]);break}if(!o&&!n.badLine)switch(e.beginPath&&e.beginPath(),e.moveTo(t[0],t[1]),n.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var h=2;h+3<t.length;h+=4)e.quadraticCurveTo(t[h],t[h+1],t[h+2],t[h+3]);break;case"straight":case"haystack":for(var c=2;c+1<t.length;c+=2)e.lineTo(t[c],t[c+1]);break;case"segments":if(n.isRound){var m=mr(n.roundCorners),g;try{for(m.s();!(g=m.n()).done;){var p=g.value;ku(e,p)}}catch(w){m.e(w)}finally{m.f()}e.lineTo(t[t.length-2],t[t.length-1])}else for(var y=2;y+1<t.length;y+=2)e.lineTo(t[y],t[y+1]);break}e=i,u?e.stroke(s):e.stroke(),e.setLineDash&&e.setLineDash([])},Kr.drawEdgeTrianglePath=function(r,e,t){e.fillStyle=e.strokeStyle;for(var a=r.pstyle("width").pfValue,n=0;n+1<t.length;n+=2){var i=[t[n+2]-t[n],t[n+3]-t[n+1]],s=Math.sqrt(i[0]*i[0]+i[1]*i[1]),o=[i[1]/s,-i[0]/s],u=[o[0]*a/2,o[1]*a/2];e.beginPath(),e.moveTo(t[n]-u[0],t[n+1]-u[1]),e.lineTo(t[n]+u[0],t[n+1]+u[1]),e.lineTo(t[n+2],t[n+3]),e.closePath(),e.fill()}},Kr.drawArrowheads=function(r,e,t){var a=e._private.rscratch,n=a.edgeType==="haystack";n||this.drawArrowhead(r,e,"source",a.arrowStartX,a.arrowStartY,a.srcArrowAngle,t),this.drawArrowhead(r,e,"mid-target",a.midX,a.midY,a.midtgtArrowAngle,t),this.drawArrowhead(r,e,"mid-source",a.midX,a.midY,a.midsrcArrowAngle,t),n||this.drawArrowhead(r,e,"target",a.arrowEndX,a.arrowEndY,a.tgtArrowAngle,t)},Kr.drawArrowhead=function(r,e,t,a,n,i,s){if(!(isNaN(a)||a==null||isNaN(n)||n==null||isNaN(i)||i==null)){var o=this,u=e.pstyle(t+"-arrow-shape").value;if(u!=="none"){var l=e.pstyle(t+"-arrow-fill").value==="hollow"?"both":"filled",v=e.pstyle(t+"-arrow-fill").value,f=e.pstyle("width").pfValue,d=e.pstyle(t+"-arrow-width"),h=d.value==="match-line"?f:d.pfValue;d.units==="%"&&(h*=f);var c=e.pstyle("opacity").value;s===void 0&&(s=c);var m=r.globalCompositeOperation;(s!==1||v==="hollow")&&(r.globalCompositeOperation="destination-out",o.colorFillStyle(r,255,255,255,1),o.colorStrokeStyle(r,255,255,255,1),o.drawArrowShape(e,r,l,f,u,h,a,n,i),r.globalCompositeOperation=m);var g=e.pstyle(t+"-arrow-color").value;o.colorFillStyle(r,g[0],g[1],g[2],s),o.colorStrokeStyle(r,g[0],g[1],g[2],s),o.drawArrowShape(e,r,v,f,u,h,a,n,i)}}},Kr.drawArrowShape=function(r,e,t,a,n,i,s,o,u){var l=this,v=this.usePaths()&&n!=="triangle-cross",f=!1,d,h=e,c={x:s,y:o},m=r.pstyle("arrow-scale").value,g=this.getArrowWidth(a,m),p=l.arrowShapes[n];if(v){var y=l.arrowPathCache=l.arrowPathCache||[],w=et(n),b=y[w];b!=null?(d=e=b,f=!0):(d=e=new Path2D,y[w]=d)}f||(e.beginPath&&e.beginPath(),v?p.draw(e,1,0,{x:0,y:0},1):p.draw(e,g,u,c,a),e.closePath&&e.closePath()),e=h,v&&(e.translate(s,o),e.rotate(u),e.scale(g,g)),(t==="filled"||t==="both")&&(v?e.fill(d):e.fill()),(t==="hollow"||t==="both")&&(e.lineWidth=i/(v?g:1),e.lineJoin="miter",v?e.stroke(d):e.stroke()),v&&(e.scale(1/g,1/g),e.rotate(-u),e.translate(-s,-o))};var Hi={};Hi.safeDrawImage=function(r,e,t,a,n,i,s,o,u,l){if(!(n<=0||i<=0||u<=0||l<=0))try{r.drawImage(e,t,a,n,i,s,o,u,l)}catch(v){Pe(v)}},Hi.drawInscribedImage=function(r,e,t,a,n){var i=this,s=t.position(),o=s.x,u=s.y,l=t.cy().style(),v=l.getIndexedStyle.bind(l),f=v(t,"background-fit","value",a),d=v(t,"background-repeat","value",a),h=t.width(),c=t.height(),m=t.padding()*2,g=h+(v(t,"background-width-relative-to","value",a)==="inner"?0:m),p=c+(v(t,"background-height-relative-to","value",a)==="inner"?0:m),y=t._private.rscratch,w=v(t,"background-clip","value",a),b=w==="node",k=v(t,"background-image-opacity","value",a)*n,x=v(t,"background-image-smoothing","value",a),E=t.pstyle("corner-radius").value;E!=="auto"&&(E=t.pstyle("corner-radius").pfValue);var T=e.width||e.cachedW,F=e.height||e.cachedH;(T==null||F==null)&&(document.body.appendChild(e),T=e.cachedW=e.width||e.offsetWidth,F=e.cachedH=e.height||e.offsetHeight,document.body.removeChild(e));var S=T,D=F;if(v(t,"background-width","value",a)!=="auto"&&(v(t,"background-width","units",a)==="%"?S=v(t,"background-width","pfValue",a)*g:S=v(t,"background-width","pfValue",a)),v(t,"background-height","value",a)!=="auto"&&(v(t,"background-height","units",a)==="%"?D=v(t,"background-height","pfValue",a)*p:D=v(t,"background-height","pfValue",a)),!(S===0||D===0)){if(f==="contain"){var C=Math.min(g/S,p/D);S*=C,D*=C}else if(f==="cover"){var C=Math.max(g/S,p/D);S*=C,D*=C}var B=o-g/2,A=v(t,"background-position-x","units",a),M=v(t,"background-position-x","pfValue",a);A==="%"?B+=(g-S)*M:B+=M;var I=v(t,"background-offset-x","units",a),R=v(t,"background-offset-x","pfValue",a);I==="%"?B+=(g-S)*R:B+=R;var L=u-p/2,V=v(t,"background-position-y","units",a),H=v(t,"background-position-y","pfValue",a);V==="%"?L+=(p-D)*H:L+=H;var z=v(t,"background-offset-y","units",a),$=v(t,"background-offset-y","pfValue",a);z==="%"?L+=(p-D)*$:L+=$,y.pathCache&&(B-=o,L-=u,o=0,u=0);var K=r.globalAlpha;r.globalAlpha=k;var Y=i.getImgSmoothing(r),Q=!1;if(x==="no"&&Y?(i.setImgSmoothing(r,!1),Q=!0):x==="yes"&&!Y&&(i.setImgSmoothing(r,!0),Q=!0),d==="no-repeat")b&&(r.save(),y.pathCache?r.clip(y.pathCache):(i.nodeShapes[i.getNodeShape(t)].draw(r,o,u,g,p,E,y),r.clip())),i.safeDrawImage(r,e,0,0,T,F,B,L,S,D),b&&r.restore();else{var Z=r.createPattern(e,d);r.fillStyle=Z,i.nodeShapes[i.getNodeShape(t)].draw(r,o,u,g,p,E,y),r.translate(B,L),r.fill(),r.translate(-B,-L)}r.globalAlpha=K,Q&&i.setImgSmoothing(r,Y)}};var St={};St.eleTextBiggerThanMin=function(r,e){if(!e){var t=r.cy().zoom(),a=this.getPixelRatio(),n=Math.ceil(si(t*a));e=Math.pow(2,n)}var i=r.pstyle("font-size").pfValue*e,s=r.pstyle("min-zoomed-font-size").pfValue;return!(i<s)},St.drawElementText=function(r,e,t,a,n){var i=arguments.length>5&&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);r.textAlign=u,r.textBaseline="bottom"}else{var l=e.element()._private.rscratch.badLine,v=e.pstyle("label"),f=e.pstyle("source-label"),d=e.pstyle("target-label");if(l||(!v||!v.value)&&(!f||!f.value)&&(!d||!d.value))return;r.textAlign="center",r.textBaseline="bottom"}var h=!t,c;t&&(c=t,r.translate(-c.x1,-c.y1)),n==null?(s.drawText(r,e,null,h,i),e.isEdge()&&(s.drawText(r,e,"source",h,i),s.drawText(r,e,"target",h,i))):s.drawText(r,e,n,h,i),t&&r.translate(c.x1,c.y1)},St.getFontCache=function(r){var e;this.fontCaches=this.fontCaches||[];for(var t=0;t<this.fontCaches.length;t++)if(e=this.fontCaches[t],e.context===r)return e;return e={context:r},this.fontCaches.push(e),e},St.setupTextStyle=function(r,e){var t=arguments.length>2&&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=t?e.effectiveOpacity()*e.pstyle("text-opacity").value:1,u=e.pstyle("text-outline-opacity").value*o,l=e.pstyle("color").value,v=e.pstyle("text-outline-color").value;r.font=a+" "+s+" "+n+" "+i,r.lineJoin="round",this.colorFillStyle(r,l[0],l[1],l[2],o),this.colorStrokeStyle(r,v[0],v[1],v[2],u)};function Gi(r,e,t,a,n){var i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:5,s=arguments.length>6?arguments[6]:void 0;r.beginPath(),r.moveTo(e+i,t),r.lineTo(e+a-i,t),r.quadraticCurveTo(e+a,t,e+a,t+i),r.lineTo(e+a,t+n-i),r.quadraticCurveTo(e+a,t+n,e+a-i,t+n),r.lineTo(e+i,t+n),r.quadraticCurveTo(e,t+n,e,t+n-i),r.lineTo(e,t+i),r.quadraticCurveTo(e,t,e+i,t),r.closePath(),s?r.stroke():r.fill()}St.getTextAngle=function(r,e){var t,a=r._private,n=a.rscratch,i=e?e+"-":"",s=r.pstyle(i+"text-rotation");if(s.strValue==="autorotate"){var o=Sr(n,"labelAngle",e);t=r.isEdge()?o:0}else s.strValue==="none"?t=0:t=s.pfValue;return t},St.drawText=function(r,e,t){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))){t==="main"&&(t=null);var u=Sr(s,"labelX",t),l=Sr(s,"labelY",t),v,f,d=this.getLabelText(e,t);if(d!=null&&d!==""&&!isNaN(u)&&!isNaN(l)){this.setupTextStyle(r,e,n);var h=t?t+"-":"",c=Sr(s,"labelWidth",t),m=Sr(s,"labelHeight",t),g=e.pstyle(h+"text-margin-x").pfValue,p=e.pstyle(h+"text-margin-y").pfValue,y=e.isEdge(),w=e.pstyle("text-halign").value,b=e.pstyle("text-valign").value;y&&(w="center",b="center"),u+=g,l+=p;var k;switch(a?k=this.getTextAngle(e,t):k=0,k!==0&&(v=u,f=l,r.translate(v,f),r.rotate(k),u=0,l=0),b){case"top":break;case"center":l+=m/2;break;case"bottom":l+=m;break}var x=e.pstyle("text-background-opacity").value,E=e.pstyle("text-border-opacity").value,T=e.pstyle("text-border-width").pfValue,F=e.pstyle("text-background-padding").pfValue,S=e.pstyle("text-background-shape").strValue,D=S.indexOf("round")===0,C=2;if(x>0||T>0&&E>0){var B=u-F;switch(w){case"left":B-=c;break;case"center":B-=c/2;break}var A=l-m-F,M=c+2*F,I=m+2*F;if(x>0){var R=r.fillStyle,L=e.pstyle("text-background-color").value;r.fillStyle="rgba("+L[0]+","+L[1]+","+L[2]+","+x*o+")",D?Gi(r,B,A,M,I,C):r.fillRect(B,A,M,I),r.fillStyle=R}if(T>0&&E>0){var V=r.strokeStyle,H=r.lineWidth,z=e.pstyle("text-border-color").value,$=e.pstyle("text-border-style").value;if(r.strokeStyle="rgba("+z[0]+","+z[1]+","+z[2]+","+E*o+")",r.lineWidth=T,r.setLineDash)switch($){case"dotted":r.setLineDash([1,1]);break;case"dashed":r.setLineDash([4,2]);break;case"double":r.lineWidth=T/4,r.setLineDash([]);break;case"solid":r.setLineDash([]);break}if(D?Gi(r,B,A,M,I,C,"stroke"):r.strokeRect(B,A,M,I),$==="double"){var K=T/2;D?Gi(r,B+K,A+K,M-K*2,I-K*2,C,"stroke"):r.strokeRect(B+K,A+K,M-K*2,I-K*2)}r.setLineDash&&r.setLineDash([]),r.lineWidth=H,r.strokeStyle=V}}var Y=2*e.pstyle("text-outline-width").pfValue;if(Y>0&&(r.lineWidth=Y),e.pstyle("text-wrap").value==="wrap"){var Q=Sr(s,"labelWrapCachedLines",t),Z=Sr(s,"labelLineHeight",t),j=c/2,re=this.getLabelJustification(e);switch(re==="auto"||(w==="left"?re==="left"?u+=-c:re==="center"&&(u+=-j):w==="center"?re==="left"?u+=-j:re==="right"&&(u+=j):w==="right"&&(re==="center"?u+=j:re==="right"&&(u+=c))),b){case"top":l-=(Q.length-1)*Z;break;case"center":case"bottom":l-=(Q.length-1)*Z;break}for(var W=0;W<Q.length;W++)Y>0&&r.strokeText(Q[W],u,l),r.fillText(Q[W],u,l),l+=Z}else Y>0&&r.strokeText(d,u,l),r.fillText(d,u,l);k!==0&&(r.rotate(-k),r.translate(-v,-f))}}};var ea={};ea.drawNode=function(r,e,t){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,v=l.rscratch,f=e.position();if(!(!te(f.x)||!te(f.y))&&!(i&&!e.visible())){var d=i?e.effectiveOpacity():1,h=s.usePaths(),c,m=!1,g=e.padding();o=e.width()+2*g,u=e.height()+2*g;var p;t&&(p=t,r.translate(-p.x1,-p.y1));for(var y=e.pstyle("background-image"),w=y.value,b=new Array(w.length),k=new Array(w.length),x=0,E=0;E<w.length;E++){var T=w[E],F=b[E]=T!=null&&T!=="none";if(F){var S=e.cy().style().getIndexedStyle(e,"background-image-crossorigin","value",E);x++,k[E]=s.getCachedImage(T,S,function(){l.backgroundTimestamp=Date.now(),e.emitAndNotify("background")})}}var D=e.pstyle("background-blacken").value,C=e.pstyle("border-width").pfValue,B=e.pstyle("background-opacity").value*d,A=e.pstyle("border-color").value,M=e.pstyle("border-style").value,I=e.pstyle("border-join").value,R=e.pstyle("border-cap").value,L=e.pstyle("border-position").value,V=e.pstyle("border-dash-pattern").pfValue,H=e.pstyle("border-dash-offset").pfValue,z=e.pstyle("border-opacity").value*d,$=e.pstyle("outline-width").pfValue,K=e.pstyle("outline-color").value,Y=e.pstyle("outline-style").value,Q=e.pstyle("outline-opacity").value*d,Z=e.pstyle("outline-offset").value,j=e.pstyle("corner-radius").value;j!=="auto"&&(j=e.pstyle("corner-radius").pfValue);var re=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:B;s.eleFillStyle(r,e,N)},W=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z;s.colorStrokeStyle(r,A[0],A[1],A[2],N)},O=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Q;s.colorStrokeStyle(r,K[0],K[1],K[2],N)},G=function(N,q,ae,X){var ne=s.nodePathCache=s.nodePathCache||[],de=Ds(ae==="polygon"?ae+","+X.join(","):ae,""+q,""+N,""+j),Fe=ne[de],ve,we=!1;return Fe!=null?(ve=Fe,we=!0,v.pathCache=ve):(ve=new Path2D,ne[de]=v.pathCache=ve),{path:ve,cacheHit:we}},ee=e.pstyle("shape").strValue,ie=e.pstyle("shape-polygon-points").pfValue;if(h){r.translate(f.x,f.y);var ue=G(o,u,ee,ie);c=ue.path,m=ue.cacheHit}var Ce=function(){if(!m){var N=f;h&&(N={x:0,y:0}),s.nodeShapes[s.getNodeShape(e)].draw(c||r,N.x,N.y,o,u,j,v)}h?r.fill(c):r.fill()},Ae=function(){for(var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:d,q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,ae=l.backgrounding,X=0,ne=0;ne<k.length;ne++){var de=e.cy().style().getIndexedStyle(e,"background-image-containment","value",ne);if(q&&de==="over"||!q&&de==="inside"){X++;continue}b[ne]&&k[ne].complete&&!k[ne].error&&(X++,s.drawInscribedImage(r,k[ne],e,ne,N))}l.backgrounding=X!==x,ae!==l.backgrounding&&e.updateStyle(!1)},Ie=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:d;s.hasPie(e)&&(s.drawPie(r,e,q),N&&(h||s.nodeShapes[s.getNodeShape(e)].draw(r,f.x,f.y,o,u,j,v)))},le=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:d,q=(D>0?D:-D)*N,ae=D>0?0:255;D!==0&&(s.colorFillStyle(r,ae,ae,ae,q),h?r.fill(c):r.fill())},oe=function(){if(C>0){if(r.lineWidth=C,r.lineCap=R,r.lineJoin=I,r.setLineDash)switch(M){case"dotted":r.setLineDash([1,1]);break;case"dashed":r.setLineDash(V),r.lineDashOffset=H;break;case"solid":case"double":r.setLineDash([]);break}if(L!=="center"){if(r.save(),r.lineWidth*=2,L==="inside")h?r.clip(c):r.clip();else{var N=new Path2D;N.rect(-o/2-C,-u/2-C,o+2*C,u+2*C),N.addPath(c),r.clip(N,"evenodd")}h?r.stroke(c):r.stroke(),r.restore()}else h?r.stroke(c):r.stroke();if(M==="double"){r.lineWidth=C/3;var q=r.globalCompositeOperation;r.globalCompositeOperation="destination-out",h?r.stroke(c):r.stroke(),r.globalCompositeOperation=q}r.setLineDash&&r.setLineDash([])}},pe=function(){if($>0){if(r.lineWidth=$,r.lineCap="butt",r.setLineDash)switch(Y){case"dotted":r.setLineDash([1,1]);break;case"dashed":r.setLineDash([4,2]);break;case"solid":case"double":r.setLineDash([]);break}var N=f;h&&(N={x:0,y:0});var q=s.getNodeShape(e),ae=C;L==="inside"&&(ae=0),L==="outside"&&(ae*=2);var X=(o+ae+($+Z))/o,ne=(u+ae+($+Z))/u,de=o*X,Fe=u*ne,ve=s.nodeShapes[q].points,we;if(h){var be=G(de,Fe,q,ve);we=be.path}if(q==="ellipse")s.drawEllipsePath(we||r,N.x,N.y,de,Fe);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(q)){var ge=0,_e=0,$e=0;q==="round-diamond"?ge=(ae+Z+$)*1.4:q==="round-heptagon"?(ge=(ae+Z+$)*1.075,$e=-(ae/2+Z+$)/35):q==="round-hexagon"?ge=(ae+Z+$)*1.12:q==="round-pentagon"?(ge=(ae+Z+$)*1.13,$e=-(ae/2+Z+$)/15):q==="round-tag"?(ge=(ae+Z+$)*1.12,_e=(ae/2+$+Z)*.07):q==="round-triangle"&&(ge=(ae+Z+$)*(Math.PI/2),$e=-(ae+Z/2+$)/Math.PI),ge!==0&&(X=(o+ge)/o,de=o*X,["round-hexagon","round-tag"].includes(q)||(ne=(u+ge)/u,Fe=u*ne)),j=j==="auto"?Ws(de,Fe):j;for(var br=de/2,Fr=Fe/2,Xe=j+(ae+$+Z)/2,Qe=new Array(ve.length/2),Je=new Array(ve.length/2),dr=0;dr<ve.length/2;dr++)Qe[dr]={x:N.x+_e+br*ve[dr*2],y:N.y+$e+Fr*ve[dr*2+1]};var cr,zr,Tr,Vr,Xr=Qe.length;for(zr=Qe[Xr-1],cr=0;cr<Xr;cr++)Tr=Qe[cr%Xr],Vr=Qe[(cr+1)%Xr],Je[cr]=zi(zr,Tr,Vr,Xe),zr=Tr,Tr=Vr;s.drawRoundPolygonPath(we||r,N.x+_e,N.y+$e,o*X,u*ne,ve,Je)}else if(["roundrectangle","round-rectangle"].includes(q))j=j==="auto"?yt(de,Fe):j,s.drawRoundRectanglePath(we||r,N.x,N.y,de,Fe,j+(ae+$+Z)/2);else if(["cutrectangle","cut-rectangle"].includes(q))j=j==="auto"?vi():j,s.drawCutRectanglePath(we||r,N.x,N.y,de,Fe,null,j+(ae+$+Z)/4);else if(["bottomroundrectangle","bottom-round-rectangle"].includes(q))j=j==="auto"?yt(de,Fe):j,s.drawBottomRoundRectanglePath(we||r,N.x,N.y,de,Fe,j+(ae+$+Z)/2);else if(q==="barrel")s.drawBarrelPath(we||r,N.x,N.y,de,Fe);else if(q.startsWith("polygon")||["rhomboid","right-rhomboid","round-tag","tag","vee"].includes(q)){var Yr=(ae+$+Z)/o;ve=tn(an(ve,Yr)),s.drawPolygonPath(we||r,N.x,N.y,o,u,ve)}else{var lr=(ae+$+Z)/o;ve=tn(an(ve,-lr)),s.drawPolygonPath(we||r,N.x,N.y,o,u,ve)}if(h?r.stroke(we):r.stroke(),Y==="double"){r.lineWidth=ae/3;var je=r.globalCompositeOperation;r.globalCompositeOperation="destination-out",h?r.stroke(we):r.stroke(),r.globalCompositeOperation=je}r.setLineDash&&r.setLineDash([])}},me=function(){n&&s.drawNodeOverlay(r,e,f,o,u)},he=function(){n&&s.drawNodeUnderlay(r,e,f,o,u)},ye=function(){s.drawElementText(r,e,null,a)},Ee=e.pstyle("ghost").value==="yes";if(Ee){var Te=e.pstyle("ghost-offset-x").pfValue,J=e.pstyle("ghost-offset-y").pfValue,P=e.pstyle("ghost-opacity").value,_=P*d;r.translate(Te,J),O(),pe(),re(P*B),Ce(),Ae(_,!0),W(P*z),oe(),Ie(D!==0||C!==0),Ae(_,!1),le(_),r.translate(-Te,-J)}h&&r.translate(-f.x,-f.y),he(),h&&r.translate(f.x,f.y),O(),pe(),re(),Ce(),Ae(d,!0),W(),oe(),Ie(D!==0||C!==0),Ae(d,!1),le(),h&&r.translate(-f.x,-f.y),ye(),me(),t&&r.translate(p.x1,p.y1)}};var Yu=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,a,n,i,s){var o=this;if(a.visible()){var u=a.pstyle("".concat(e,"-padding")).pfValue,l=a.pstyle("".concat(e,"-opacity")).value,v=a.pstyle("".concat(e,"-color")).value,f=a.pstyle("".concat(e,"-shape")).value,d=a.pstyle("".concat(e,"-corner-radius")).value;if(l>0){if(n=n||a.position(),i==null||s==null){var h=a.padding();i=a.width()+2*h,s=a.height()+2*h}o.colorFillStyle(t,v[0],v[1],v[2],l),o.nodeShapes[f].draw(t,n.x,n.y,i+u*2,s+u*2,d),t.fill()}}}};ea.drawNodeOverlay=Yu("overlay"),ea.drawNodeUnderlay=Yu("underlay"),ea.hasPie=function(r){return r=r[0],r._private.hasPie},ea.drawPie=function(r,e,t,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(),v=Math.min(u,l)/2,f=0,d=this.usePaths();d&&(s=0,o=0),i.units==="%"?v=v*i.pfValue:i.pfValue!==void 0&&(v=i.pfValue/2);for(var h=1;h<=n.pieBackgroundN;h++){var c=e.pstyle("pie-"+h+"-background-size").value,m=e.pstyle("pie-"+h+"-background-color").value,g=e.pstyle("pie-"+h+"-background-opacity").value*t,p=c/100;p+f>1&&(p=1-f);var y=1.5*Math.PI+2*Math.PI*f,w=2*Math.PI*p,b=y+w;c===0||f>=1||f+p>1||(r.beginPath(),r.moveTo(s,o),r.arc(s,o,v,y,b),r.closePath(),this.colorFillStyle(r,m[0],m[1],m[2],g),r.fill(),f+=p)}};var fr={},yp=100;fr.getPixelRatio=function(){var r=this.data.contexts[0];if(this.forcedPixelRatio!=null)return this.forcedPixelRatio;var e=this.cy.window(),t=r.backingStorePixelRatio||r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1;return(e.devicePixelRatio||1)/t},fr.paintCache=function(r){for(var e=this.paintCaches=this.paintCaches||[],t=!0,a,n=0;n<e.length;n++)if(a=e[n],a.context===r){t=!1;break}return t&&(a={context:r},e.push(a)),a},fr.createGradientStyleFor=function(r,e,t,a,n){var i,s=this.usePaths(),o=t.pstyle(e+"-gradient-stop-colors").value,u=t.pstyle(e+"-gradient-stop-positions").pfValue;if(a==="radial-gradient")if(t.isEdge()){var l=t.sourceEndpoint(),v=t.targetEndpoint(),f=t.midpoint(),d=gt(l,f),h=gt(v,f);i=r.createRadialGradient(f.x,f.y,0,f.x,f.y,Math.max(d,h))}else{var c=s?{x:0,y:0}:t.position(),m=t.paddedWidth(),g=t.paddedHeight();i=r.createRadialGradient(c.x,c.y,0,c.x,c.y,Math.max(m,g))}else if(t.isEdge()){var p=t.sourceEndpoint(),y=t.targetEndpoint();i=r.createLinearGradient(p.x,p.y,y.x,y.y)}else{var w=s?{x:0,y:0}:t.position(),b=t.paddedWidth(),k=t.paddedHeight(),x=b/2,E=k/2,T=t.pstyle("background-gradient-direction").value;switch(T){case"to-bottom":i=r.createLinearGradient(w.x,w.y-E,w.x,w.y+E);break;case"to-top":i=r.createLinearGradient(w.x,w.y+E,w.x,w.y-E);break;case"to-left":i=r.createLinearGradient(w.x+x,w.y,w.x-x,w.y);break;case"to-right":i=r.createLinearGradient(w.x-x,w.y,w.x+x,w.y);break;case"to-bottom-right":case"to-right-bottom":i=r.createLinearGradient(w.x-x,w.y-E,w.x+x,w.y+E);break;case"to-top-right":case"to-right-top":i=r.createLinearGradient(w.x-x,w.y+E,w.x+x,w.y-E);break;case"to-bottom-left":case"to-left-bottom":i=r.createLinearGradient(w.x+x,w.y-E,w.x-x,w.y+E);break;case"to-top-left":case"to-left-top":i=r.createLinearGradient(w.x+x,w.y+E,w.x-x,w.y-E);break}}if(!i)return null;for(var F=u.length===o.length,S=o.length,D=0;D<S;D++)i.addColorStop(F?u[D]:D/(S-1),"rgba("+o[D][0]+","+o[D][1]+","+o[D][2]+","+n+")");return i},fr.gradientFillStyle=function(r,e,t,a){var n=this.createGradientStyleFor(r,"background",e,t,a);if(!n)return null;r.fillStyle=n},fr.colorFillStyle=function(r,e,t,a,n){r.fillStyle="rgba("+e+","+t+","+a+","+n+")"},fr.eleFillStyle=function(r,e,t){var a=e.pstyle("background-fill").value;if(a==="linear-gradient"||a==="radial-gradient")this.gradientFillStyle(r,e,a,t);else{var n=e.pstyle("background-color").value;this.colorFillStyle(r,n[0],n[1],n[2],t)}},fr.gradientStrokeStyle=function(r,e,t,a){var n=this.createGradientStyleFor(r,"line",e,t,a);if(!n)return null;r.strokeStyle=n},fr.colorStrokeStyle=function(r,e,t,a,n){r.strokeStyle="rgba("+e+","+t+","+a+","+n+")"},fr.eleStrokeStyle=function(r,e,t){var a=e.pstyle("line-fill").value;if(a==="linear-gradient"||a==="radial-gradient")this.gradientStrokeStyle(r,e,a,t);else{var n=e.pstyle("line-color").value;this.colorStrokeStyle(r,n[0],n[1],n[2],t)}},fr.matchCanvasSize=function(r){var e=this,t=e.data,a=e.findContainerClientCoords(),n=a[2],i=a[3],s=e.getPixelRatio(),o=e.motionBlurPxRatio;(r===e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE]||r===e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG])&&(s=o);var u=n*s,l=i*s,v;if(!(u===e.canvasWidth&&l===e.canvasHeight)){e.fontCaches=null;var f=t.canvasContainer;f.style.width=n+"px",f.style.height=i+"px";for(var d=0;d<e.CANVAS_LAYERS;d++)v=t.canvases[d],v.width=u,v.height=l,v.style.width=n+"px",v.style.height=i+"px";for(var d=0;d<e.BUFFER_COUNT;d++)v=t.bufferCanvases[d],v.width=u,v.height=l,v.style.width=n+"px",v.style.height=i+"px";e.textureMult=1,s<=1&&(v=t.bufferCanvases[e.TEXTURE_BUFFER],e.textureMult=2,v.width=u*e.textureMult,v.height=l*e.textureMult),e.canvasWidth=u,e.canvasHeight=l,e.pixelRatio=s}},fr.renderTo=function(r,e,t,a){this.render({forcedContext:r,forcedZoom:e,forcedPan:t,drawAllLayers:!0,forcedPxRatio:a})},fr.clearCanvas=function(){var r=this,e=r.data;function t(a){a.clearRect(0,0,r.canvasWidth,r.canvasHeight)}t(e.contexts[r.NODE]),t(e.contexts[r.DRAG])},fr.render=function(r){var e=this;r=r||Rs();var t=e.cy,a=r.forcedContext,n=r.drawAllLayers,i=r.drawOnlyNodeLayer,s=r.forcedZoom,o=r.forcedPan,u=r.forcedPxRatio===void 0?this.getPixelRatio():r.forcedPxRatio,l=e.data,v=l.canvasNeedsRedraw,f=e.textureOnViewport&&!a&&(e.pinching||e.hoverData.dragging||e.swipePanning||e.data.wheelZooming),d=r.motionBlur!==void 0?r.motionBlur:e.motionBlur,h=e.motionBlurPxRatio,c=t.hasCompoundNodes(),m=e.hoverData.draggingEles,g=!!(e.hoverData.selecting||e.touchData.selecting);d=d&&!a&&e.motionBlurEnabled&&!g;var p=d;a||(e.prevPxRatio!==u&&(e.invalidateContainerClientCoordsCache(),e.matchCanvasSize(e.container),e.redrawHint("eles",!0),e.redrawHint("drag",!0)),e.prevPxRatio=u),!a&&e.motionBlurTimeout&&clearTimeout(e.motionBlurTimeout),d&&(e.mbFrames==null&&(e.mbFrames=0),e.mbFrames++,e.mbFrames<3&&(p=!1),e.mbFrames>e.minMbLowQualFrames&&(e.motionBlurPxRatio=e.mbPxRBlurry)),e.clearingMotionBlur&&(e.motionBlurPxRatio=1),e.textureDrawLastFrame&&!f&&(v[e.NODE]=!0,v[e.SELECT_BOX]=!0);var y=t.style(),w=t.zoom(),b=s!==void 0?s:w,k=t.pan(),x={x:k.x,y:k.y},E={zoom:w,pan:{x:k.x,y:k.y}},T=e.prevViewport,F=T===void 0||E.zoom!==T.zoom||E.pan.x!==T.pan.x||E.pan.y!==T.pan.y;!F&&!(m&&!c)&&(e.motionBlurPxRatio=1),o&&(x=o),b*=u,x.x*=u,x.y*=u;var S=e.getCachedZSortedEles();function D(W,O,G,ee,ie){var ue=W.globalCompositeOperation;W.globalCompositeOperation="destination-out",e.colorFillStyle(W,255,255,255,e.motionBlurTransparency),W.fillRect(O,G,ee,ie),W.globalCompositeOperation=ue}function C(W,O){var G,ee,ie,ue;!e.clearingMotionBlur&&(W===l.bufferContexts[e.MOTIONBLUR_BUFFER_NODE]||W===l.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG])?(G={x:k.x*h,y:k.y*h},ee=w*h,ie=e.canvasWidth*h,ue=e.canvasHeight*h):(G=x,ee=b,ie=e.canvasWidth,ue=e.canvasHeight),W.setTransform(1,0,0,1,0,0),O==="motionBlur"?D(W,0,0,ie,ue):!a&&(O===void 0||O)&&W.clearRect(0,0,ie,ue),n||(W.translate(G.x,G.y),W.scale(ee,ee)),o&&W.translate(o.x,o.y),s&&W.scale(s,s)}if(f||(e.textureDrawLastFrame=!1),f){if(e.textureDrawLastFrame=!0,!e.textureCache){e.textureCache={},e.textureCache.bb=t.mutableElements().boundingBox(),e.textureCache.texture=e.data.bufferCanvases[e.TEXTURE_BUFFER];var B=e.data.bufferContexts[e.TEXTURE_BUFFER];B.setTransform(1,0,0,1,0,0),B.clearRect(0,0,e.canvasWidth*e.textureMult,e.canvasHeight*e.textureMult),e.render({forcedContext:B,drawOnlyNodeLayer:!0,forcedPxRatio:u*e.textureMult});var E=e.textureCache.viewport={zoom:t.zoom(),pan:t.pan(),width:e.canvasWidth,height:e.canvasHeight};E.mpan={x:(0-E.pan.x)/E.zoom,y:(0-E.pan.y)/E.zoom}}v[e.DRAG]=!1,v[e.NODE]=!1;var A=l.contexts[e.NODE],M=e.textureCache.texture,E=e.textureCache.viewport;A.setTransform(1,0,0,1,0,0),d?D(A,0,0,E.width,E.height):A.clearRect(0,0,E.width,E.height);var I=y.core("outside-texture-bg-color").value,R=y.core("outside-texture-bg-opacity").value;e.colorFillStyle(A,I[0],I[1],I[2],R),A.fillRect(0,0,E.width,E.height);var w=t.zoom();C(A,!1),A.clearRect(E.mpan.x,E.mpan.y,E.width/E.zoom/u,E.height/E.zoom/u),A.drawImage(M,E.mpan.x,E.mpan.y,E.width/E.zoom/u,E.height/E.zoom/u)}else e.textureOnViewport&&!a&&(e.textureCache=null);var L=t.extent(),V=e.pinching||e.hoverData.dragging||e.swipePanning||e.data.wheelZooming||e.hoverData.draggingEles||e.cy.animated(),H=e.hideEdgesOnViewport&&V,z=[];if(z[e.NODE]=!v[e.NODE]&&d&&!e.clearedForMotionBlur[e.NODE]||e.clearingMotionBlur,z[e.NODE]&&(e.clearedForMotionBlur[e.NODE]=!0),z[e.DRAG]=!v[e.DRAG]&&d&&!e.clearedForMotionBlur[e.DRAG]||e.clearingMotionBlur,z[e.DRAG]&&(e.clearedForMotionBlur[e.DRAG]=!0),v[e.NODE]||n||i||z[e.NODE]){var $=d&&!z[e.NODE]&&h!==1,A=a||($?e.data.bufferContexts[e.MOTIONBLUR_BUFFER_NODE]:l.contexts[e.NODE]),K=d&&!$?"motionBlur":void 0;C(A,K),H?e.drawCachedNodes(A,S.nondrag,u,L):e.drawLayeredElements(A,S.nondrag,u,L),e.debug&&e.drawDebugPoints(A,S.nondrag),!n&&!d&&(v[e.NODE]=!1)}if(!i&&(v[e.DRAG]||n||z[e.DRAG])){var $=d&&!z[e.DRAG]&&h!==1,A=a||($?e.data.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG]:l.contexts[e.DRAG]);C(A,d&&!$?"motionBlur":void 0),H?e.drawCachedNodes(A,S.drag,u,L):e.drawCachedElements(A,S.drag,u,L),e.debug&&e.drawDebugPoints(A,S.drag),!n&&!d&&(v[e.DRAG]=!1)}if(this.drawSelectionRectangle(r,C),d&&h!==1){var Y=l.contexts[e.NODE],Q=e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE],Z=l.contexts[e.DRAG],j=e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG],re=function(O,G,ee){O.setTransform(1,0,0,1,0,0),ee||!p?O.clearRect(0,0,e.canvasWidth,e.canvasHeight):D(O,0,0,e.canvasWidth,e.canvasHeight);var ie=h;O.drawImage(G,0,0,e.canvasWidth*ie,e.canvasHeight*ie,0,0,e.canvasWidth,e.canvasHeight)};(v[e.NODE]||z[e.NODE])&&(re(Y,Q,z[e.NODE]),v[e.NODE]=!1),(v[e.DRAG]||z[e.DRAG])&&(re(Z,j,z[e.DRAG]),v[e.DRAG]=!1)}e.prevViewport=E,e.clearingMotionBlur&&(e.clearingMotionBlur=!1,e.motionBlurCleared=!0,e.motionBlur=!0),d&&(e.motionBlurTimeout=setTimeout(function(){e.motionBlurTimeout=null,e.clearedForMotionBlur[e.NODE]=!1,e.clearedForMotionBlur[e.DRAG]=!1,e.motionBlur=!1,e.clearingMotionBlur=!f,e.mbFrames=0,v[e.NODE]=!0,v[e.DRAG]=!0,e.redraw()},yp)),a||t.emit("render")};var Oa;fr.drawSelectionRectangle=function(r,e){var t=this,a=t.cy,n=t.data,i=a.style(),s=r.drawOnlyNodeLayer,o=r.drawAllLayers,u=n.canvasNeedsRedraw,l=r.forcedContext;if(t.showFps||!s&&u[t.SELECT_BOX]&&!o){var v=l||n.contexts[t.SELECT_BOX];if(e(v),t.selection[4]==1&&(t.hoverData.selecting||t.touchData.selecting)){var f=t.cy.zoom(),d=i.core("selection-box-border-width").value/f;v.lineWidth=d,v.fillStyle="rgba("+i.core("selection-box-color").value[0]+","+i.core("selection-box-color").value[1]+","+i.core("selection-box-color").value[2]+","+i.core("selection-box-opacity").value+")",v.fillRect(t.selection[0],t.selection[1],t.selection[2]-t.selection[0],t.selection[3]-t.selection[1]),d>0&&(v.strokeStyle="rgba("+i.core("selection-box-border-color").value[0]+","+i.core("selection-box-border-color").value[1]+","+i.core("selection-box-border-color").value[2]+","+i.core("selection-box-opacity").value+")",v.strokeRect(t.selection[0],t.selection[1],t.selection[2]-t.selection[0],t.selection[3]-t.selection[1]))}if(n.bgActivePosistion&&!t.hoverData.selecting){var f=t.cy.zoom(),h=n.bgActivePosistion;v.fillStyle="rgba("+i.core("active-bg-color").value[0]+","+i.core("active-bg-color").value[1]+","+i.core("active-bg-color").value[2]+","+i.core("active-bg-opacity").value+")",v.beginPath(),v.arc(h.x,h.y,i.core("active-bg-size").pfValue/f,0,2*Math.PI),v.fill()}var c=t.lastRedrawTime;if(t.showFps&&c){c=Math.round(c);var m=Math.round(1e3/c),g="1 frame = "+c+" ms = "+m+" fps";if(v.setTransform(1,0,0,1,0,0),v.fillStyle="rgba(255, 0, 0, 0.75)",v.strokeStyle="rgba(255, 0, 0, 0.75)",v.font="30px Arial",!Oa){var p=v.measureText(g);Oa=p.actualBoundingBoxAscent}v.fillText(g,0,Oa);var y=60;v.strokeRect(0,Oa+10,250,20),v.fillRect(0,Oa+10,250*Math.min(m/y,1),20)}o||(u[t.SELECT_BOX]=!1)}};function Zu(r,e,t){var a=r.createShader(e);if(r.shaderSource(a,t),r.compileShader(a),!r.getShaderParameter(a,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(a));return a}function wp(r,e,t){var a=Zu(r,r.VERTEX_SHADER,e),n=Zu(r,r.FRAGMENT_SHADER,t),i=r.createProgram();if(r.attachShader(i,a),r.attachShader(i,n),r.linkProgram(i),!r.getProgramParameter(i,r.LINK_STATUS))throw new Error("Could not initialize shaders");return i}function bp(r,e,t){t===void 0&&(t=e);var a=r.makeOffscreenCanvas(e,t),n=a.context=a.getContext("2d");return a.clear=function(){return n.clearRect(0,0,a.width,a.height)},a.clear(),a}function Ui(r){var e=r.pixelRatio,t=r.cy.zoom(),a=r.cy.pan();return{zoom:t*e,pan:{x:a.x*e,y:a.y*e}}}function Ki(r,e,t,a,n){var i=a*t+e.x,s=n*t+e.y;return s=Math.round(r.canvasHeight-s),[i,s]}function $n(r,e,t){var a=r[0]/255,n=r[1]/255,i=r[2]/255,s=e,o=t||new Array(4);return o[0]=a*s,o[1]=n*s,o[2]=i*s,o[3]=s,o}function qn(r,e){var t=e||new Array(4);return t[0]=(r>>0&255)/255,t[1]=(r>>8&255)/255,t[2]=(r>>16&255)/255,t[3]=(r>>24&255)/255,t}function Fp(r){return r[0]+(r[1]<<8)+(r[2]<<16)+(r[3]<<24)}function Ep(r,e){var t=r.createTexture();return t.buffer=function(a){r.bindTexture(r.TEXTURE_2D,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_NEAREST),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,a),r.generateMipmap(r.TEXTURE_2D),r.bindTexture(r.TEXTURE_2D,null)},t.deleteTexture=function(){r.deleteTexture(t)},t}function Qu(r,e){switch(e){case"float":return[1,r.FLOAT,4];case"vec2":return[2,r.FLOAT,4];case"vec3":return[3,r.FLOAT,4];case"vec4":return[4,r.FLOAT,4];case"int":return[1,r.INT,4];case"ivec2":return[2,r.INT,4]}}function Ju(r,e,t){switch(e){case r.FLOAT:return new Float32Array(t);case r.INT:return new Int32Array(t)}}function xp(r,e,t,a,n,i){switch(e){case r.FLOAT:return new Float32Array(t.buffer,i*a,n);case r.INT:return new Int32Array(t.buffer,i*a,n)}}function Cp(r,e,t,a){var n=Qu(r,e),i=We(n,2),s=i[0],o=i[1],u=Ju(r,o,a),l=r.createBuffer();return r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,u,r.STATIC_DRAW),o===r.FLOAT?r.vertexAttribPointer(t,s,o,!1,0,0):o===r.INT&&r.vertexAttribIPointer(t,s,o,0,0),r.enableVertexAttribArray(t),r.bindBuffer(r.ARRAY_BUFFER,null),l}function wr(r,e,t,a){var n=Qu(r,t),i=We(n,3),s=i[0],o=i[1],u=i[2],l=Ju(r,o,e*s),v=s*u,f=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,f),r.bufferData(r.ARRAY_BUFFER,e*v,r.DYNAMIC_DRAW),r.enableVertexAttribArray(a),o===r.FLOAT?r.vertexAttribPointer(a,s,o,!1,v,0):o===r.INT&&r.vertexAttribIPointer(a,s,o,v,0),r.vertexAttribDivisor(a,1),r.bindBuffer(r.ARRAY_BUFFER,null);for(var d=new Array(e),h=0;h<e;h++)d[h]=xp(r,o,l,v,s,h);return f.dataArray=l,f.stride=v,f.size=s,f.getView=function(c){return d[c]},f.setPoint=function(c,m,g){var p=d[c];p[0]=m,p[1]=g},f.bufferSubData=function(c){r.bindBuffer(r.ARRAY_BUFFER,f),c?r.bufferSubData(r.ARRAY_BUFFER,0,l,0,c*s):r.bufferSubData(r.ARRAY_BUFFER,0,l)},f}function Tp(r){var e=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,e);var t=r.createTexture();return r.bindTexture(r.TEXTURE_2D,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t,0),r.bindFramebuffer(r.FRAMEBUFFER,null),e.setFramebufferAttachmentSizes=function(a,n){r.bindTexture(r.TEXTURE_2D,t),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,a,n,0,r.RGBA,r.UNSIGNED_BYTE,null)},e}var ju=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var r=0,e=arguments.length;e--;)r+=arguments[e]*arguments[e];return Math.sqrt(r)});function _a(){var r=new ju(9);return ju!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function el(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=1,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r}function Sp(r,e,t){var a=e[0],n=e[1],i=e[2],s=e[3],o=e[4],u=e[5],l=e[6],v=e[7],f=e[8],d=t[0],h=t[1],c=t[2],m=t[3],g=t[4],p=t[5],y=t[6],w=t[7],b=t[8];return r[0]=d*a+h*s+c*l,r[1]=d*n+h*o+c*v,r[2]=d*i+h*u+c*f,r[3]=m*a+g*s+p*l,r[4]=m*n+g*o+p*v,r[5]=m*i+g*u+p*f,r[6]=y*a+w*s+b*l,r[7]=y*n+w*o+b*v,r[8]=y*i+w*u+b*f,r}function Wn(r,e,t){var a=e[0],n=e[1],i=e[2],s=e[3],o=e[4],u=e[5],l=e[6],v=e[7],f=e[8],d=t[0],h=t[1];return r[0]=a,r[1]=n,r[2]=i,r[3]=s,r[4]=o,r[5]=u,r[6]=d*a+h*s+l,r[7]=d*n+h*o+v,r[8]=d*i+h*u+f,r}function rl(r,e,t){var a=e[0],n=e[1],i=e[2],s=e[3],o=e[4],u=e[5],l=e[6],v=e[7],f=e[8],d=Math.sin(t),h=Math.cos(t);return r[0]=h*a+d*s,r[1]=h*n+d*o,r[2]=h*i+d*u,r[3]=h*s-d*a,r[4]=h*o-d*n,r[5]=h*u-d*i,r[6]=l,r[7]=v,r[8]=f,r}function Xi(r,e,t){var a=t[0],n=t[1];return r[0]=a*e[0],r[1]=a*e[1],r[2]=a*e[2],r[3]=n*e[3],r[4]=n*e[4],r[5]=n*e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r}function kp(r,e,t){return r[0]=2/e,r[1]=0,r[2]=0,r[3]=0,r[4]=-2/t,r[5]=0,r[6]=-1,r[7]=1,r[8]=1,r}var Na={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},za=Ye({getKey:null,drawElement:null,getBoundingBox:null,getRotation:null,getRotationPoint:null,getRotationOffset:null,isVisible:null,getPadding:null}),Dp=function(){function r(e,t){Zr(this,r),this.debugID=Math.floor(Math.random()*1e4),this.r=e,this.atlasSize=t.webglTexSize,this.rows=t.webglTexRows,this.enableWrapping=t.enableWrapping,this.texHeight=Math.floor(this.atlasSize/this.rows),this.maxTexWidth=this.atlasSize,this.texture=null,this.canvas=null,this.needsBuffer=!0,this.freePointer={x:0,row:0},this.keyToLocation=new Map,this.canvas=t.createTextureCanvas(e,this.atlasSize,this.atlasSize),this.scratch=t.createTextureCanvas(e,this.atlasSize,this.texHeight,"scratch")}return Qr(r,[{key:"getKeys",value:function(){return new Set(this.keyToLocation.keys())}},{key:"getScale",value:function(t){var a=t.w,n=t.h,i=this.texHeight,s=this.maxTexWidth,o=i/n,u=a*o,l=n*o;return u>s&&(o=s/a,u=a*o,l=n*o),{scale:o,texW:u,texH:l}}},{key:"draw",value:function(t,a,n){var i=this,s=this.atlasSize,o=this.rows,u=this.texHeight,l=this.getScale(a),v=l.scale,f=l.texW,d=l.texH,h=[null,null],c=function(w,b){if(n&&b){var k=b.context,x=w.x,E=w.row,T=x,F=u*E;k.save(),k.translate(T,F),k.scale(v,v),n(k,a),k.restore()}},m=function(){c(i.freePointer,i.canvas),h[0]={x:i.freePointer.x,y:i.freePointer.row*u,w:f,h:d},h[1]={x:i.freePointer.x+f,y:i.freePointer.row*u,w:0,h:d},i.freePointer.x+=f,i.freePointer.x==s&&(i.freePointer.x=0,i.freePointer.row++)},g=function(){var w=i.scratch,b=i.canvas;w.clear(),c({x:0,row:0},w);var k=s-i.freePointer.x,x=f-k,E=u;{var T=i.freePointer.x,F=i.freePointer.row*u,S=k;b.context.drawImage(w,0,0,S,E,T,F,S,E),h[0]={x:T,y:F,w:S,h:d}}{var D=k,C=(i.freePointer.row+1)*u,B=x;b&&b.context.drawImage(w,D,0,B,E,0,C,B,E),h[1]={x:0,y:C,w:B,h:d}}i.freePointer.x=x,i.freePointer.row++},p=function(){i.freePointer.x=0,i.freePointer.row++};if(this.freePointer.x+f<=s)m();else{if(this.freePointer.row>=o-1)return!1;this.freePointer.x===s?(p(),m()):this.enableWrapping?g():(p(),m())}return this.keyToLocation.set(t,h),this.needsBuffer=!0,h}},{key:"getOffsets",value:function(t){return this.keyToLocation.get(t)}},{key:"isEmpty",value:function(){return this.freePointer.x===0&&this.freePointer.row===0}},{key:"canFit",value:function(t){var a=this.atlasSize,n=this.rows,i=this.getScale(t),s=i.texW;return this.freePointer.x+s>a?this.freePointer.row<n-1:!0}},{key:"bufferIfNeeded",value:function(t){this.texture||(this.texture=Ep(t,this.debugID)),this.needsBuffer&&(this.texture.buffer(this.canvas),this.needsBuffer=!1)}},{key:"dispose",value:function(){this.texture&&(this.texture.deleteTexture(),this.texture=null,this.needsBuffer=!0)}}]),r}(),Pp=function(){function r(e,t){Zr(this,r),this.r=e,this.opts=t,this.keyToIds=new Map,this.idToKey=new Map,this.atlases=[],this.styleKeyToAtlas=new Map,this.styleKeyNeedsRedraw=new Set,this.forceGC=!1}return Qr(r,[{key:"getKeys",value:function(){return new Set(this.styleKeyToAtlas.keys())}},{key:"getIdsFor",value:function(t){var a=this.keyToIds.get(t);return a||(a=new Set,this.keyToIds.set(t,a)),a}},{key:"_createAtlas",value:function(){var t=this.r,a=this.opts;return new Dp(t,a)}},{key:"_getScratchCanvas",value:function(){if(!this.scratch){var t=this.r,a=this.opts,n=a.webglTexSize,i=Math.floor(n/a.webglTexRows);this.scratch=a.createTextureCanvas(t,n,i,"scratch")}return this.scratch}},{key:"draw",value:function(t,a,n,i){if(this.styleKeyNeedsRedraw.has(a)){this.styleKeyNeedsRedraw.delete(a),this.deleteKey(t,a);var s=this.styleKeyToAtlas.get(a);s&&(s.forceGC=!0),this.styleKeyToAtlas.delete(a)}var o=this.styleKeyToAtlas.get(a);return o||(o=this.atlases[this.atlases.length-1],(!o||!o.canFit(n))&&(o=this._createAtlas(),this.atlases.push(o)),o.draw(a,n,i),this.styleKeyToAtlas.set(a,o),this.getIdsFor(a).add(t),this.idToKey.set(t,a)),o}},{key:"getAtlas",value:function(t){return this.styleKeyToAtlas.get(t)}},{key:"hasAtlas",value:function(t){return this.styleKeyToAtlas.has(t)}},{key:"deleteKey",value:function(t,a){this.idToKey.delete(t),this.getIdsFor(a).delete(t)}},{key:"checkKeyIsInvalid",value:function(t,a){if(!this.idToKey.has(t))return!1;var n=this.idToKey.get(t);return n!=a?(this.deleteKey(t,n),!0):!1}},{key:"_getKeysToCollect",value:function(){var t=new Set,a=mr(this.styleKeyToAtlas.keys()),n;try{for(a.s();!(n=a.n()).done;){var i=n.value;this.getIdsFor(i).size==0&&t.add(i)}}catch(s){a.e(s)}finally{a.f()}return t}},{key:"gc",value:function(){var t=this,a=this.atlases.some(function(d){return d.forceGC}),n=this._getKeysToCollect();if(n.size===0&&!a){console.log("nothing to garbage collect");return}var i=[],s=new Map,o=null,u=mr(this.atlases),l;try{var v=function(){var h=l.value,c=h.getKeys(),m=Bp(n,c);if(m.size===0&&!h.forceGC)return i.push(h),c.forEach(function(E){return s.set(E,h)}),"continue";o||(o=t._createAtlas(),i.push(o));var g=mr(c),p;try{for(g.s();!(p=g.n()).done;){var y=p.value;if(!m.has(y)){var w=h.getOffsets(y),b=We(w,2),k=b[0],x=b[1];o.canFit({w:k.w+x.w,h:k.h})||(o=t._createAtlas(),i.push(o)),t._copyTextureToNewAtlas(y,h,o),s.set(y,o)}}}catch(E){g.e(E)}finally{g.f()}};for(u.s();!(l=u.n()).done;)var f=v()}catch(d){u.e(d)}finally{u.f()}this.atlases=i,this.styleKeyToAtlas=s}},{key:"_copyTextureToNewAtlas",value:function(t,a,n){var i=a.getOffsets(t),s=We(i,2),o=s[0],u=s[1];if(u.w===0)n.draw(t,o,function(d){d.drawImage(a.canvas,o.x,o.y,o.w,o.h,0,0,o.w,o.h)});else{var l=this._getScratchCanvas();l.clear(),l.context.drawImage(a.canvas,o.x,o.y,o.w,o.h,0,0,o.w,o.h),l.context.drawImage(a.canvas,u.x,u.y,u.w,u.h,o.w,0,u.w,u.h);var v=o.w+u.w,f=o.h;n.draw(t,{w:v,h:f},function(d){d.drawImage(l,0,0,v,f,0,0,v,f)})}}},{key:"getCounts",value:function(){return{keyCount:this.styleKeyToAtlas.size,atlasCount:new Set(this.styleKeyToAtlas.values()).size}}}]),r}();function Bp(r,e){return r.intersection?r.intersection(e):new Set(ls(r).filter(function(t){return e.has(t)}))}var Ap=function(){function r(e,t){Zr(this,r),this.r=e;var a=t;this.globalOptions=a,this.maxAtlases=a.webglTexPerBatch,this.atlasSize=a.webglTexSize,this.renderTypes=new Map,this.maxAtlasesPerBatch=t.webglTexPerBatch,this.batchAtlases=[],this._cacheScratchCanvas(a)}return Qr(r,[{key:"_cacheScratchCanvas",value:function(t){var a=-1,n=-1,i=null,s=t.createTextureCanvas;t.createTextureCanvas=function(o,u,l,v){return v?((!i||u!=a||l!=n)&&(a=u,n=l,i=s(o,u,l)),i):s(o,u,l)}}},{key:"addRenderType",value:function(t,a){var n=new Pp(this.r,this.globalOptions),i=a;this.renderTypes.set(t,ce({type:t,atlasCollection:n},i))}},{key:"getRenderTypes",value:function(){return ls(this.renderTypes.values())}},{key:"getRenderTypeOpts",value:function(t){return this.renderTypes.get(t)}},{key:"invalidate",value:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=a.forceRedraw,i=n===void 0?!1:n,s=a.filterEle,o=s===void 0?function(){return!0}:s,u=a.filterType,l=u===void 0?function(){return!0}:u,v=!1,f=mr(t),d;try{for(f.s();!(d=f.n()).done;){var h=d.value;if(o(h)){var c=h.id(),m=mr(this.getRenderTypes()),g;try{for(m.s();!(g=m.n()).done;){var p=g.value;if(l(p.type)){var y=p.getKey(h);i?(p.atlasCollection.deleteKey(c,y),p.atlasCollection.styleKeyNeedsRedraw.add(y),v=!0):v|=p.atlasCollection.checkKeyIsInvalid(c,y)}}}catch(w){m.e(w)}finally{m.f()}}}}catch(w){f.e(w)}finally{f.f()}return v}},{key:"gc",value:function(){var t=mr(this.getRenderTypes()),a;try{for(t.s();!(a=t.n()).done;){var n=a.value;n.atlasCollection.gc()}}catch(i){t.e(i)}finally{t.f()}}},{key:"isRenderable",value:function(t,a){var n=this.getRenderTypeOpts(a);return n&&n.isVisible(t)}},{key:"startBatch",value:function(){this.batchAtlases=[]}},{key:"getAtlasCount",value:function(){return this.batchAtlases.length}},{key:"getAtlases",value:function(){return this.batchAtlases}},{key:"getOrCreateAtlas",value:function(t,a,n){var i=this.renderTypes.get(n),s=i.getKey(t),o=t.id();return i.atlasCollection.draw(o,s,a,function(u){i.drawElement(u,t,a,!0,!0)})}},{key:"getAtlasIndexForBatch",value:function(t){var a=this.batchAtlases.indexOf(t);if(a<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)return;this.batchAtlases.push(t),a=this.batchAtlases.length-1}return a}},{key:"getIndexArray",value:function(){return Array.from({length:this.maxAtlases},function(t,a){return a})}},{key:"getAtlasInfo",value:function(t,a){var n=this.renderTypes.get(a),i=n.getBoundingBox(t),s=this.getOrCreateAtlas(t,i,a),o=this.getAtlasIndexForBatch(s);if(o!==void 0){var u=n.getKey(t),l=s.getOffsets(u),v=We(l,2),f=v[0],d=v[1];return{atlasID:o,tex:f,tex1:f,tex2:d,bb:i,type:a,styleKey:u}}}},{key:"canAddToCurrentBatch",value:function(t,a){if(this.batchAtlases.length===this.maxAtlasesPerBatch){var n=this.renderTypes.get(a),i=n.getKey(t),s=n.atlasCollection.getAtlas(i);return s&&this.batchAtlases.includes(s)}return!0}},{key:"setTransformMatrix",value:function(t,a,n){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,s=a.bb,o=a.type,u=a.tex1,l=a.tex2,v=this.getRenderTypeOpts(o),f=v.getPadding?v.getPadding(n):0,d=u.w/(u.w+l.w);i||(d=1-d);var h=this.getAdjustedBB(s,f,i,d),c,m;el(t);var g=v.getRotation?v.getRotation(n):0;if(g!==0){var p=v.getRotationPoint(n),y=p.x,w=p.y;Wn(t,t,[y,w]),rl(t,t,g);var b=v.getRotationOffset(n);c=b.x+h.xOffset,m=b.y}else c=h.x1,m=h.y1;Wn(t,t,[c,m]),Xi(t,t,[h.w,h.h])}},{key:"getTransformMatrix",value:function(t,a){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=_a();return this.setTransformMatrix(i,t,a,n),i}},{key:"getAdjustedBB",value:function(t,a,n,i){var s=t.x1,o=t.y1,u=t.w,l=t.h;a&&(s-=a,o-=a,u+=2*a,l+=2*a);var v=0,f=u*i;return n&&i<1?u=f:!n&&i<1&&(v=u-f,s+=v,u=f),{x1:s,y1:o,w:u,h:l,xOffset:v}}},{key:"getDebugInfo",value:function(){var t=[],a=mr(this.renderTypes),n;try{for(a.s();!(n=a.n()).done;){var i=We(n.value,2),s=i[0],o=i[1],u=o.atlasCollection.getCounts(),l=u.keyCount,v=u.atlasCount;t.push({type:s,keyCount:l,atlasCount:v})}}catch(f){a.e(f)}finally{a.f()}return t}}]),r}(),Yi=0,tl=1,al=2,Zi=3,Ip=function(){function r(e,t,a){Zr(this,r),this.r=e,this.gl=t,this.maxInstances=a.webglBatchSize,this.maxAtlases=a.webglTexPerBatch,this.atlasSize=a.webglTexSize,this.bgColor=a.bgColor,a.enableWrapping=!0,a.createTextureCanvas=bp,this.atlasManager=new Ap(e,a),this.program=this.createShaderProgram(Na.SCREEN),this.pickingProgram=this.createShaderProgram(Na.PICKING),this.vao=this.createVAO(),this.debugInfo=[]}return Qr(r,[{key:"addTextureRenderType",value:function(t,a){this.atlasManager.addRenderType(t,a)}},{key:"invalidate",value:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=a.type,i=this.atlasManager;return n?i.invalidate(t,{filterType:function(o){return o===n},forceRedraw:!0}):i.invalidate(t)}},{key:"gc",value:function(){this.atlasManager.gc()}},{key:"createShaderProgram",value:function(t){var a=this.gl,n=`#version 300 es
      precision highp float;

      uniform mat3 uPanZoomMatrix;
      uniform int  uAtlasSize;
      
      // instanced
      in vec2 aPosition; 

      // what are we rendering?
      in int aVertType;

      // for picking
      in vec4 aIndex;
      
      // For textures
      in int aAtlasId; // which shader unit/atlas to use
      in vec4 aTex1; // x/y/w/h of texture in atlas
      in vec4 aTex2; 

      // for any transforms that are needed
      in vec4 aScaleRotate1;  // vectors use fewer attributes than matrices
      in vec2 aTranslate1;
      in vec4 aScaleRotate2;
      in vec2 aTranslate2;

      // for edges
      in vec4 aPointAPointB;
      in vec4 aPointCPointD;
      in float aLineWidth;
      in vec4 aEdgeColor;

      out vec2 vTexCoord;
      out vec4 vEdgeColor;
      flat out int vAtlasId;
      flat out vec4 vIndex;
      flat out int vVertType;

      void main(void) {
        int vid = gl_VertexID;
        vec2 position = aPosition;

        if(aVertType == `.concat(Yi,`) {
          float texX;
          float texY;
          float texW;
          float texH;
          mat3  texMatrix;

          int vid = gl_VertexID;
          if(vid <= 5) {
            texX = aTex1.x;
            texY = aTex1.y;
            texW = aTex1.z;
            texH = aTex1.w;
            texMatrix = mat3(
              vec3(aScaleRotate1.xy, 0.0),
              vec3(aScaleRotate2.zw, 0.0),
              vec3(aTranslate1,      1.0)
            );
          } else {
            texX = aTex2.x;
            texY = aTex2.y;
            texW = aTex2.z;
            texH = aTex2.w;
            texMatrix = mat3(
              vec3(aScaleRotate2.xy, 0.0),
              vec3(aScaleRotate2.zw, 0.0),
              vec3(aTranslate2,      1.0)
            );
          }

          if(vid == 1 || vid == 2 || vid == 4 || vid == 7 || vid == 8 || vid == 10) {
            texX += texW;
          }
          if(vid == 2 || vid == 4 || vid == 5 || vid == 8 || vid == 10 || vid == 11) {
            texY += texH;
          }

          float d = float(uAtlasSize);
          vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1

          gl_Position = vec4(uPanZoomMatrix * texMatrix * vec3(position, 1.0), 1.0);
        } 
        else if(aVertType == `).concat(tl,` && vid < 6) {
          vec2 source = aPointAPointB.xy;
          vec2 target = aPointAPointB.zw;

          // adjust the geometry so that the line is centered on the edge
          position.y = position.y - 0.5;

          vec2 xBasis = target - source;
          vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
          vec2 point = source + xBasis * position.x + yBasis * aLineWidth * position.y;

          gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);
          vEdgeColor = aEdgeColor;
        } 
        else if(aVertType == `).concat(al,` && vid < 6) {
          vec2 pointA = aPointAPointB.xy;
          vec2 pointB = aPointAPointB.zw;
          vec2 pointC = aPointCPointD.xy;
          vec2 pointD = aPointCPointD.zw;

          // adjust the geometry so that the line is centered on the edge
          position.y = position.y - 0.5;

          vec2 p0 = pointA;
          vec2 p1 = pointB;
          vec2 p2 = pointC;
          vec2 pos = position;
          if(position.x == 1.0) {
            p0 = pointD;
            p1 = pointC;
            p2 = pointB;
            pos = vec2(0.0, -position.y);
          }

          vec2 p01 = p1 - p0;
          vec2 p12 = p2 - p1;
          vec2 p21 = p1 - p2;

          // Find the normal vector.
          vec2 tangent = normalize(normalize(p12) + normalize(p01));
          vec2 normal = vec2(-tangent.y, tangent.x);

          // Find the vector perpendicular to p0 -> p1.
          vec2 p01Norm = normalize(vec2(-p01.y, p01.x));

          // Determine the bend direction.
          float sigma = sign(dot(p01 + p21, normal));
          float width = aLineWidth;

          if(sign(pos.y) == -sigma) {
            // This is an intersecting vertex. Adjust the position so that there's no overlap.
            vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);
            gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
          } else {
            // This is a non-intersecting vertex. Treat it like a mitre join.
            vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);
            gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
          }

          vEdgeColor = aEdgeColor;
        } 
        else if(aVertType == `).concat(Zi,` && vid < 3) {
          // massage the first triangle into an edge arrow
          if(vid == 0)
            position = vec2(-0.15, -0.3);
          if(vid == 1)
            position = vec2( 0.0,   0.0);
          if(vid == 2)
            position = vec2( 0.15, -0.3);

          mat3 transform = mat3(
            vec3(aScaleRotate1.xy, 0.0),
            vec3(aScaleRotate1.zw, 0.0),
            vec3(aTranslate1,      1.0)
          );
          gl_Position = vec4(uPanZoomMatrix * transform * vec3(position, 1.0), 1.0);
          vEdgeColor = aEdgeColor;
        } else {
          gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space
        }

        vAtlasId = aAtlasId;
        vIndex = aIndex;
        vVertType = aVertType;
      }
    `),i=this.atlasManager.getIndexArray(),s=`#version 300 es
      precision highp float;

      // define texture unit for each node in the batch
      `.concat(i.map(function(l){return"uniform sampler2D uTexture".concat(l,";")}).join(`
	`),`

      uniform vec4 uBGColor;

      in vec2 vTexCoord;
      in vec4 vEdgeColor;
      flat in int vAtlasId;
      flat in vec4 vIndex;
      flat in int vVertType;

      out vec4 outColor;

      void main(void) {
        if(vVertType == `).concat(Yi,`) {
          `).concat(i.map(function(l){return"if(vAtlasId == ".concat(l,") outColor = texture(uTexture").concat(l,", vTexCoord);")}).join(`
	else `),`
        } else if(vVertType == `).concat(Zi,`) {
          // blend arrow color with background (using premultiplied alpha)
          outColor.rgb = vEdgeColor.rgb + (uBGColor.rgb * (1.0 - vEdgeColor.a)); 
          outColor.a = 1.0; // make opaque, masks out line under arrow
        } else {
          outColor = vEdgeColor;
        }

        `).concat(t.picking?`if(outColor.a == 0.0) discard;
             else outColor = vIndex;`:"",`
      }
    `),o=wp(a,n,s);o.aPosition=a.getAttribLocation(o,"aPosition"),o.aIndex=a.getAttribLocation(o,"aIndex"),o.aVertType=a.getAttribLocation(o,"aVertType"),o.aAtlasId=a.getAttribLocation(o,"aAtlasId"),o.aTex1=a.getAttribLocation(o,"aTex1"),o.aTex2=a.getAttribLocation(o,"aTex2"),o.aScaleRotate1=a.getAttribLocation(o,"aScaleRotate1"),o.aTranslate1=a.getAttribLocation(o,"aTranslate1"),o.aScaleRotate2=a.getAttribLocation(o,"aScaleRotate2"),o.aTranslate2=a.getAttribLocation(o,"aTranslate2"),o.aPointAPointB=a.getAttribLocation(o,"aPointAPointB"),o.aPointCPointD=a.getAttribLocation(o,"aPointCPointD"),o.aLineWidth=a.getAttribLocation(o,"aLineWidth"),o.aEdgeColor=a.getAttribLocation(o,"aEdgeColor"),o.uPanZoomMatrix=a.getUniformLocation(o,"uPanZoomMatrix"),o.uAtlasSize=a.getUniformLocation(o,"uAtlasSize"),o.uBGColor=a.getUniformLocation(o,"uBGColor"),o.uTextures=[];for(var u=0;u<this.atlasManager.maxAtlases;u++)o.uTextures.push(a.getUniformLocation(o,"uTexture".concat(u)));return o}},{key:"createVAO",value:function(){var t=[0,0,1,0,1,1,0,0,1,1,0,1],a=[].concat(t,t);this.vertexCount=a.length/2;var n=this.maxInstances,i=this.gl,s=this.program,o=i.createVertexArray();return i.bindVertexArray(o),Cp(i,"vec2",s.aPosition,a),this.indexBuffer=wr(i,n,"vec4",s.aIndex),this.vertTypeBuffer=wr(i,n,"int",s.aVertType),this.atlasIdBuffer=wr(i,n,"int",s.aAtlasId),this.tex1Buffer=wr(i,n,"vec4",s.aTex1),this.tex2Buffer=wr(i,n,"vec4",s.aTex2),this.scaleRotate1Buffer=wr(i,n,"vec4",s.aScaleRotate1),this.translate1Buffer=wr(i,n,"vec2",s.aTranslate1),this.scaleRotate2Buffer=wr(i,n,"vec4",s.aScaleRotate2),this.translate2Buffer=wr(i,n,"vec2",s.aTranslate2),this.pointAPointBBuffer=wr(i,n,"vec4",s.aPointAPointB),this.pointCPointDBuffer=wr(i,n,"vec4",s.aPointCPointD),this.lineWidthBuffer=wr(i,n,"float",s.aLineWidth),this.edgeColorBuffer=wr(i,n,"vec4",s.aEdgeColor),i.bindVertexArray(null),o}},{key:"buffers",get:function(){var t=this;return this._buffers||(this._buffers=Object.keys(this).filter(function(a){return a.endsWith("Buffer")}).map(function(a){return t[a]})),this._buffers}},{key:"startFrame",value:function(t,a){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Na.SCREEN;this.panZoomMatrix=t,this.debugInfo=a,this.renderTarget=n,this.startBatch()}},{key:"startBatch",value:function(){this.instanceCount=0,this.atlasManager.startBatch()}},{key:"endFrame",value:function(){this.endBatch()}},{key:"getTempMatrix",value:function(){return this.tempMatrix=this.tempMatrix||_a()}},{key:"drawTexture",value:function(t,a,n){var i=this.atlasManager;if(i.isRenderable(t,n)){i.canAddToCurrentBatch(t,n)||this.endBatch();var s=this.instanceCount;this.vertTypeBuffer.getView(s)[0]=Yi;var o=this.indexBuffer.getView(s);qn(a,o);var u=i.getAtlasInfo(t,n,u),l=u.atlasID,v=u.tex1,f=u.tex2,d=this.atlasIdBuffer.getView(s);d[0]=l;var h=this.tex1Buffer.getView(s);h[0]=v.x,h[1]=v.y,h[2]=v.w,h[3]=v.h;var c=this.tex2Buffer.getView(s);c[0]=f.x,c[1]=f.y,c[2]=f.w,c[3]=f.h;for(var m=this.getTempMatrix(),g=0,p=[1,2];g<p.length;g++){var y=p[g];i.setTransformMatrix(m,u,t,y===1);var w=this["scaleRotate".concat(y,"Buffer")].getView(s);w[0]=m[0],w[1]=m[1],w[2]=m[3],w[3]=m[4];var b=this["translate".concat(y,"Buffer")].getView(s);b[0]=m[6],b[1]=m[7]}this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:"drawEdgeArrow",value:function(t,a,n){var i=t._private.rscratch,s,o,u;if(n==="source"?(s=i.arrowStartX,o=i.arrowStartY,u=i.srcArrowAngle):(s=i.arrowEndX,o=i.arrowEndY,u=i.tgtArrowAngle),!(isNaN(s)||s==null||isNaN(o)||o==null||isNaN(u)||u==null)){var l=t.pstyle(n+"-arrow-shape").value;if(l!=="none"){var v=t.pstyle(n+"-arrow-color").value,f=t.pstyle("opacity").value,d=t.pstyle("line-opacity").value,h=f*d,c=t.pstyle("width").pfValue,m=t.pstyle("arrow-scale").value,g=this.r.getArrowWidth(c,m),p=this.getTempMatrix();el(p),Wn(p,p,[s,o]),Xi(p,p,[g,g]),rl(p,p,u);var y=this.instanceCount;this.vertTypeBuffer.getView(y)[0]=Zi;var w=this.indexBuffer.getView(y);qn(a,w);var b=this.edgeColorBuffer.getView(y);$n(v,h,b);var k=this.scaleRotate1Buffer.getView(y);k[0]=p[0],k[1]=p[1],k[2]=p[3],k[3]=p[4];var x=this.translate1Buffer.getView(y);x[0]=p[6],x[1]=p[7],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:"drawEdgeLine",value:function(t,a){var n=t.pstyle("opacity").value,i=t.pstyle("line-opacity").value,s=t.pstyle("width").pfValue,o=t.pstyle("line-color").value,u=n*i,l=this.getEdgePoints(t);if(l.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),l.length==4){var v=this.instanceCount;this.vertTypeBuffer.getView(v)[0]=tl;var f=this.indexBuffer.getView(v);qn(a,f);var d=this.edgeColorBuffer.getView(v);$n(o,u,d);var h=this.lineWidthBuffer.getView(v);h[0]=s;var c=this.pointAPointBBuffer.getView(v);c[0]=l[0],c[1]=l[1],c[2]=l[2],c[3]=l[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var m=0;m<l.length-2;m+=2){var g=this.instanceCount;this.vertTypeBuffer.getView(g)[0]=al;var p=this.indexBuffer.getView(g);qn(a,p);var y=this.edgeColorBuffer.getView(g);$n(o,u,y);var w=this.lineWidthBuffer.getView(g);w[0]=s;var b=l[m-2],k=l[m-1],x=l[m],E=l[m+1],T=l[m+2],F=l[m+3],S=l[m+4],D=l[m+5];m==0&&(b=2*x-T+.001,k=2*E-F+.001),m==l.length-4&&(S=2*T-x+.001,D=2*F-E+.001);var C=this.pointAPointBBuffer.getView(g);C[0]=b,C[1]=k,C[2]=x,C[3]=E;var B=this.pointCPointDBuffer.getView(g);B[0]=T,B[1]=F,B[2]=S,B[3]=D,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:"getEdgePoints",value:function(t){var a=t._private.rscratch,n=a.allpts;if(n.length==4)return n;var i=this.getNumSegments(t);return this.getCurveSegmentPoints(n,i)}},{key:"getNumSegments",value:function(t){var a=15;return Math.min(Math.max(a,5),this.maxInstances)}},{key:"getCurveSegmentPoints",value:function(t,a){if(t.length==4)return t;for(var n=Array((a+1)*2),i=0;i<=a;i++)if(i==0)n[0]=t[0],n[1]=t[1];else if(i==a)n[i*2]=t[t.length-2],n[i*2+1]=t[t.length-1];else{var s=i/a;this.setCurvePoint(t,s,n,i*2)}return n}},{key:"setCurvePoint",value:function(t,a,n,i){if(t.length<=2)n[i]=t[0],n[i+1]=t[1];else{for(var s=Array(t.length-2),o=0;o<s.length;o+=2){var u=(1-a)*t[o]+a*t[o+2],l=(1-a)*t[o+1]+a*t[o+3];s[o]=u,s[o+1]=l}return this.setCurvePoint(s,a,n,i)}}},{key:"endBatch",value:function(){var t=this.gl,a=this.vao,n=this.vertexCount,i=this.instanceCount;if(i!==0){var s=this.renderTarget.picking?this.pickingProgram:this.program;t.useProgram(s),t.bindVertexArray(a);var o=mr(this.buffers),u;try{for(o.s();!(u=o.n()).done;){var l=u.value;l.bufferSubData(i)}}catch(c){o.e(c)}finally{o.f()}for(var v=this.atlasManager.getAtlases(),f=0;f<v.length;f++)v[f].bufferIfNeeded(t);for(var d=0;d<v.length;d++)t.activeTexture(t.TEXTURE0+d),t.bindTexture(t.TEXTURE_2D,v[d].texture),t.uniform1i(s.uTextures[d],d);t.uniformMatrix3fv(s.uPanZoomMatrix,!1,this.panZoomMatrix),t.uniform1i(s.uAtlasSize,this.atlasManager.atlasSize);var h=$n(this.bgColor,1);t.uniform4fv(s.uBGColor,h),t.drawArraysInstanced(t.TRIANGLES,0,n,i),t.bindVertexArray(null),t.bindTexture(t.TEXTURE_2D,null),this.debugInfo&&this.debugInfo.push({count:i,atlasCount:v.length}),this.startBatch()}}},{key:"getDebugInfo",value:function(){return this.debugInfo}},{key:"getAtlasDebugInfo",value:function(){return this.atlasManager.getDebugInfo()}}]),r}();function nl(r,e){return"rgba(".concat(r[0],", ").concat(r[1],", ").concat(r[2],", ").concat(e,")")}var Mp=function(){function r(e){Zr(this,r),this.r=e}return Qr(r,[{key:"getStyleKey",value:function(t,a){var n=this.getStyle(t,a),i=n.shape,s=n.opacity,o=n.color;if(!i)return null;var u=a.width(),l=a.height(),v=nl(o,s);return et("".concat(i,"-").concat(u,"-").concat(l,"-").concat(v))}},{key:"isVisible",value:function(t,a){var n=a.pstyle("".concat(t,"-opacity")).value;return n>0}},{key:"getStyle",value:function(t,a){var n=a.pstyle("".concat(t,"-opacity")).value,i=a.pstyle("".concat(t,"-color")).value,s=a.pstyle("".concat(t,"-shape")).value;return{opacity:n,color:i,shape:s}}},{key:"getPadding",value:function(t,a){return a.pstyle("".concat(t,"-padding")).pfValue}},{key:"draw",value:function(t,a,n,i){if(this.isVisible(t,n)){var s=this.r,o=i.w,u=i.h,l=o/2,v=u/2,f=this.getStyle(t,n),d=f.shape,h=f.color,c=f.opacity;a.save(),a.fillStyle=nl(h,c),d==="round-rectangle"||d==="roundrectangle"?s.drawRoundRectanglePath(a,l,v,o,u,"auto"):d==="ellipse"&&s.drawEllipsePath(a,l,v,o,u),a.fill(),a.restore()}}}]),r}();function Rp(r){var e=r&&r.style&&r.style.backgroundColor||"white";return ms(e)}var il={};il.initWebgl=function(r,e){var t=this,a=t.data.contexts[t.WEBGL],n=r.cy.container();r.bgColor=Rp(n),r.webglTexSize=Math.min(r.webglTexSize,a.getParameter(a.MAX_TEXTURE_SIZE)),r.webglTexRows=Math.min(r.webglTexRows,54),r.webglBatchSize=Math.min(r.webglBatchSize,16384),r.webglTexPerBatch=Math.min(r.webglTexPerBatch,a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS)),t.webglDebug=r.webglDebug,t.webglDebugShowAtlases=r.webglDebugShowAtlases,console.log("max texture units",a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS)),console.log("max texture size",a.getParameter(a.MAX_TEXTURE_SIZE)),console.log("webgl options",r),t.pickingFrameBuffer=Tp(a),t.pickingFrameBuffer.needsDraw=!0;var i=function(v){return t.getTextAngle(v,null)},s=function(v){var f=v.pstyle("label");return f&&f.value};t.eleDrawing=new Ip(t,a,r);var o=new Mp(t);t.eleDrawing.addTextureRenderType("node-body",za({getKey:e.getStyleKey,getBoundingBox:e.getElementBox,drawElement:e.drawElement,isVisible:function(v){return v.visible()}})),t.eleDrawing.addTextureRenderType("node-label",za({getKey:e.getLabelKey,getBoundingBox:e.getLabelBox,drawElement:e.drawLabel,getRotation:i,getRotationPoint:e.getLabelRotationPoint,getRotationOffset:e.getLabelRotationOffset,isVisible:s})),t.eleDrawing.addTextureRenderType("node-overlay",za({getBoundingBox:e.getElementBox,getKey:function(v){return o.getStyleKey("overlay",v)},drawElement:function(v,f,d){return o.draw("overlay",v,f,d)},isVisible:function(v){return o.isVisible("overlay",v)},getPadding:function(v){return o.getPadding("overlay",v)}})),t.eleDrawing.addTextureRenderType("node-underlay",za({getBoundingBox:e.getElementBox,getKey:function(v){return o.getStyleKey("underlay",v)},drawElement:function(v,f,d){return o.draw("underlay",v,f,d)},isVisible:function(v){return o.isVisible("underlay",v)},getPadding:function(v){return o.getPadding("underlay",v)}})),t.eleDrawing.addTextureRenderType("edge-label",za({getKey:e.getLabelKey,getBoundingBox:e.getLabelBox,drawElement:e.drawLabel,getRotation:i,getRotationPoint:e.getLabelRotationPoint,getRotationOffset:e.getLabelRotationOffset,isVisible:s}));var u=va(function(){console.log("garbage collect flag set"),t.data.gc=!0},1e4);t.onUpdateEleCalcs(function(l,v){var f=!1;v&&v.length>0&&(f|=t.eleDrawing.invalidate(v)),f&&u()}),Lp(t)};function Lp(r){{var e=r.render;r.render=function(i){i=i||{};var s=r.cy;r.webgl&&(s.zoom()>Vu?(Op(r),e.call(r,i)):(_p(r),ol(r,i,Na.SCREEN)))}}{var t=r.matchCanvasSize;r.matchCanvasSize=function(i){t.call(r,i),r.pickingFrameBuffer.setFramebufferAttachmentSizes(r.canvasWidth,r.canvasHeight),r.pickingFrameBuffer.needsDraw=!0}}r.findNearestElements=function(i,s,o,u){return Wp(r,i,s)};{var a=r.invalidateCachedZSortedEles;r.invalidateCachedZSortedEles=function(){a.call(r),r.pickingFrameBuffer.needsDraw=!0}}{var n=r.notify;r.notify=function(i,s){n.call(r,i,s),i==="viewport"||i==="bounds"?r.pickingFrameBuffer.needsDraw=!0:i==="background"&&r.eleDrawing.invalidate(s,{type:"node-body"})}}}function Op(r){var e=r.data.contexts[r.WEBGL];e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)}function _p(r){var e=function(a){a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,r.canvasWidth,r.canvasHeight),a.restore()};e(r.data.contexts[r.NODE]),e(r.data.contexts[r.DRAG])}function Np(r){var e=r.canvasWidth,t=r.canvasHeight,a=Ui(r),n=a.pan,i=a.zoom,s=_a();Wn(s,s,[n.x,n.y]),Xi(s,s,[i,i]);var o=_a();kp(o,e,t);var u=_a();return Sp(u,o,s),u}function sl(r,e){var t=r.canvasWidth,a=r.canvasHeight,n=Ui(r),i=n.pan,s=n.zoom;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t,a),e.translate(i.x,i.y),e.scale(s,s)}function zp(r,e){r.drawSelectionRectangle(e,function(t){return sl(r,t)})}function Vp(r){var e=r.data.contexts[r.NODE];e.save(),sl(r,e),e.strokeStyle="rgba(0, 0, 0, 0.3)",e.beginPath(),e.moveTo(-1e3,0),e.lineTo(1e3,0),e.stroke(),e.beginPath(),e.moveTo(0,-1e3),e.lineTo(0,1e3),e.stroke(),e.restore()}function $p(r){var e=function(n,i,s){for(var o=n.atlasManager.getRenderTypeOpts(i),u=r.data.contexts[r.NODE],l=.125,v=o.atlasCollection.atlases,f=0;f<v.length;f++){var d=v[f],h=d.canvas,c=h.width,m=h.height,g=c*f,p=h.height*s;u.save(),u.scale(l,l),u.drawImage(h,g,p),u.strokeStyle="black",u.rect(g,p,c,m),u.stroke(),u.restore()}},t=0;e(r.eleDrawing,"node-body",t++),e(r.eleDrawing,"node-label",t++)}function qp(r,e,t,a,n){var i,s,o,u,l=Ui(r),v=l.pan,f=l.zoom;if(a===void 0||n===void 0){var d=Ki(r,v,f,e,t),h=We(d,2),c=h[0],m=h[1],g=6;i=c-g/2,s=m-g/2,o=g,u=g}else{var p=Ki(r,v,f,e,t),y=We(p,2),w=y[0],b=y[1],k=Ki(r,v,f,a,n),x=We(k,2),E=x[0],T=x[1];i=w,s=T,o=Math.abs(E-w),u=Math.abs(T-b)}if(o===0||u===0)return[];var F=r.data.contexts[r.WEBGL];F.bindFramebuffer(F.FRAMEBUFFER,r.pickingFrameBuffer),r.pickingFrameBuffer.needsDraw&&(F.viewport(0,0,F.canvas.width,F.canvas.height),ol(r,null,Na.PICKING),r.pickingFrameBuffer.needsDraw=!1);var S=o*u,D=new Uint8Array(S*4);F.readPixels(i,s,o,u,F.RGBA,F.UNSIGNED_BYTE,D),F.bindFramebuffer(F.FRAMEBUFFER,null);for(var C=new Set,B=0;B<S;B++){var A=D.slice(B*4,B*4+4),M=Fp(A)-1;M>=0&&C.add(M)}return C}function Wp(r,e,t){var a=qp(r,e,t),n=r.getCachedZSortedEles(),i,s,o=mr(a),u;try{for(o.s();!(u=o.n()).done;){var l=u.value,v=n[l];if(!i&&v.isNode()&&(i=v),!s&&v.isEdge()&&(s=v),i&&s)break}}catch(f){o.e(f)}finally{o.f()}return[i,s].filter(Boolean)}function ol(r,e,t){var a,n;r.webglDebug&&(n=[],a=performance.now());var i=r.eleDrawing,s=0;if(t.screen&&r.data.canvasNeedsRedraw[r.SELECT_BOX]&&zp(r,e),r.data.canvasNeedsRedraw[r.NODE]||t.picking){var o=function(C,B){B+=1,C.isNode()?(i.drawTexture(C,B,"node-underlay"),i.drawTexture(C,B,"node-body"),i.drawTexture(C,B,"node-label"),i.drawTexture(C,B,"node-overlay")):(i.drawEdgeLine(C,B),i.drawEdgeArrow(C,B,"source"),i.drawEdgeArrow(C,B,"target"),i.drawTexture(C,B,"edge-label"))},u=r.data.contexts[r.WEBGL];t.screen?(u.clearColor(0,0,0,0),u.enable(u.BLEND),u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA)):u.disable(u.BLEND),u.clear(u.COLOR_BUFFER_BIT|u.DEPTH_BUFFER_BIT),u.viewport(0,0,u.canvas.width,u.canvas.height);var l=Np(r),v=r.getCachedZSortedEles();if(s=v.length,i.startFrame(l,n,t),t.screen){for(var f=0;f<v.nondrag.length;f++)o(v.nondrag[f],f);for(var d=0;d<v.drag.length;d++)o(v.drag[d],-1)}else if(t.picking)for(var h=0;h<v.length;h++)o(v[h],h);i.endFrame(),r.data.gc&&(console.log("Garbage Collect!"),r.data.gc=!1,i.gc()),t.screen&&r.webglDebugShowAtlases&&(Vp(r),$p(r)),r.data.canvasNeedsRedraw[r.NODE]=!1,r.data.canvasNeedsRedraw[r.DRAG]=!1}if(r.webglDebug){var c=performance.now(),m=!0,g=0,p=0,y=mr(n),w;try{for(y.s();!(w=y.n()).done;){var b=w.value;g++,p+=b.count}}catch(D){y.e(D)}finally{y.f()}var k=Math.ceil(c-a),x="".concat(s," elements, ").concat(p," rectangles, ").concat(g," batches");if(m)console.log("WebGL (".concat(t.name,") - ").concat(x));else{console.log("WebGL render (".concat(t.name,") - frame time ").concat(k,"ms")),console.log("  ".concat(x)),console.log("Texture Atlases Used:");var E=i.getAtlasDebugInfo(),T=mr(E),F;try{for(T.s();!(F=T.n()).done;){var S=F.value;console.log("  ".concat(S.type,": ").concat(S.keyCount," keys, ").concat(S.atlasCount," atlases"))}}catch(D){T.e(D)}finally{T.f()}console.log("")}}}var ft={};ft.drawPolygonPath=function(r,e,t,a,n,i){var s=a/2,o=n/2;r.beginPath&&r.beginPath(),r.moveTo(e+s*i[0],t+o*i[1]);for(var u=1;u<i.length/2;u++)r.lineTo(e+s*i[u*2],t+o*i[u*2+1]);r.closePath()},ft.drawRoundPolygonPath=function(r,e,t,a,n,i,s){s.forEach(function(o){return ku(r,o)}),r.closePath()},ft.drawRoundRectanglePath=function(r,e,t,a,n,i){var s=a/2,o=n/2,u=i==="auto"?yt(a,n):Math.min(i,o,s);r.beginPath&&r.beginPath(),r.moveTo(e,t-o),r.arcTo(e+s,t-o,e+s,t,u),r.arcTo(e+s,t+o,e,t+o,u),r.arcTo(e-s,t+o,e-s,t,u),r.arcTo(e-s,t-o,e,t-o,u),r.lineTo(e,t-o),r.closePath()},ft.drawBottomRoundRectanglePath=function(r,e,t,a,n,i){var s=a/2,o=n/2,u=i==="auto"?yt(a,n):i;r.beginPath&&r.beginPath(),r.moveTo(e,t-o),r.lineTo(e+s,t-o),r.lineTo(e+s,t),r.arcTo(e+s,t+o,e,t+o,u),r.arcTo(e-s,t+o,e-s,t,u),r.lineTo(e-s,t-o),r.lineTo(e,t-o),r.closePath()},ft.drawCutRectanglePath=function(r,e,t,a,n,i,s){var o=a/2,u=n/2,l=s==="auto"?vi():s;r.beginPath&&r.beginPath(),r.moveTo(e-o+l,t-u),r.lineTo(e+o-l,t-u),r.lineTo(e+o,t-u+l),r.lineTo(e+o,t+u-l),r.lineTo(e+o-l,t+u),r.lineTo(e-o+l,t+u),r.lineTo(e-o,t+u-l),r.lineTo(e-o,t-u+l),r.closePath()},ft.drawBarrelPath=function(r,e,t,a,n){var i=a/2,s=n/2,o=e-i,u=e+i,l=t-s,v=t+s,f=fi(a,n),d=f.widthOffset,h=f.heightOffset,c=f.ctrlPtOffsetPct*d;r.beginPath&&r.beginPath(),r.moveTo(o,l+h),r.lineTo(o,v-h),r.quadraticCurveTo(o+c,v,o+d,v),r.lineTo(u-d,v),r.quadraticCurveTo(u-c,v,u,v-h),r.lineTo(u,l+h),r.quadraticCurveTo(u-c,l,u-d,l),r.lineTo(o+d,l),r.quadraticCurveTo(o+c,l,o,l+h),r.closePath()};for(var ul=Math.sin(0),ll=Math.cos(0),Qi={},Ji={},vl=Math.PI/40,ra=0*Math.PI;ra<2*Math.PI;ra+=vl)Qi[ra]=Math.sin(ra),Ji[ra]=Math.cos(ra);ft.drawEllipsePath=function(r,e,t,a,n){if(r.beginPath&&r.beginPath(),r.ellipse)r.ellipse(e,t,a/2,n/2,0,0,2*Math.PI);else for(var i,s,o=a/2,u=n/2,l=0*Math.PI;l<2*Math.PI;l+=vl)i=e-o*Qi[l]*ul+o*Ji[l]*ll,s=t+u*Ji[l]*ul+u*Qi[l]*ll,l===0?r.moveTo(i,s):r.lineTo(i,s);r.closePath()};var Va={};Va.createBuffer=function(r,e){var t=document.createElement("canvas");return t.width=r,t.height=e,[t,t.getContext("2d")]},Va.bufferCanvasImage=function(r){var e=this.cy,t=e.mutableElements(),a=t.boundingBox(),n=this.findContainerClientCoords(),i=r.full?Math.ceil(a.w):n[2],s=r.full?Math.ceil(a.h):n[3],o=te(r.maxWidth)||te(r.maxHeight),u=this.getPixelRatio(),l=1;if(r.scale!==void 0)i*=r.scale,s*=r.scale,l=r.scale;else if(o){var v=1/0,f=1/0;te(r.maxWidth)&&(v=l*r.maxWidth/i),te(r.maxHeight)&&(f=l*r.maxHeight/s),l=Math.min(v,f),i*=l,s*=l}o||(i*=u,s*=u,l*=u);var d=document.createElement("canvas");d.width=i,d.height=s,d.style.width=i+"px",d.style.height=s+"px";var h=d.getContext("2d");if(i>0&&s>0){h.clearRect(0,0,i,s),h.globalCompositeOperation="source-over";var c=this.getCachedZSortedEles();if(r.full)h.translate(-a.x1*l,-a.y1*l),h.scale(l,l),this.drawElements(h,c),h.scale(1/l,1/l),h.translate(a.x1*l,a.y1*l);else{var m=e.pan(),g={x:m.x*l,y:m.y*l};l*=e.zoom(),h.translate(g.x,g.y),h.scale(l,l),this.drawElements(h,c),h.scale(1/l,1/l),h.translate(-g.x,-g.y)}r.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=r.bg,h.rect(0,0,i,s),h.fill())}return d};function Hp(r,e){for(var t=atob(r),a=new ArrayBuffer(t.length),n=new Uint8Array(a),i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return new Blob([a],{type:e})}function fl(r){var e=r.indexOf(",");return r.substr(e+1)}function dl(r,e,t){var a=function(){return e.toDataURL(t,r.quality)};switch(r.output){case"blob-promise":return new Nt(function(n,i){try{e.toBlob(function(s){s!=null?n(s):i(new Error("`canvas.toBlob()` sent a null value in its callback"))},t,r.quality)}catch(s){i(s)}});case"blob":return Hp(fl(a()),t);case"base64":return fl(a());case"base64uri":default:return a()}}Va.png=function(r){return dl(r,this.bufferCanvasImage(r),"image/png")},Va.jpg=function(r){return dl(r,this.bufferCanvasImage(r),"image/jpeg")};var cl={};cl.nodeShapeImpl=function(r,e,t,a,n,i,s,o){switch(r){case"ellipse":return this.drawEllipsePath(e,t,a,n,i);case"polygon":return this.drawPolygonPath(e,t,a,n,i,s);case"round-polygon":return this.drawRoundPolygonPath(e,t,a,n,i,s,o);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(e,t,a,n,i,o);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(e,t,a,n,i,s,o);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(e,t,a,n,i,o);case"barrel":return this.drawBarrelPath(e,t,a,n,i)}};var Gp=hl,xe=hl.prototype;xe.CANVAS_LAYERS=3,xe.SELECT_BOX=0,xe.DRAG=1,xe.NODE=2,xe.WEBGL=3,xe.CANVAS_TYPES=["2d","2d","2d","webgl2"],xe.BUFFER_COUNT=3,xe.TEXTURE_BUFFER=0,xe.MOTIONBLUR_BUFFER_NODE=1,xe.MOTIONBLUR_BUFFER_DRAG=2;function hl(r){var e=this,t=e.cy.window(),a=t.document;r.webgl&&(xe.CANVAS_LAYERS=e.CANVAS_LAYERS=4,console.log("webgl rendering enabled")),e.data={canvases:new Array(xe.CANVAS_LAYERS),contexts:new Array(xe.CANVAS_LAYERS),canvasNeedsRedraw:new Array(xe.CANVAS_LAYERS),bufferCanvases:new Array(xe.BUFFER_COUNT),bufferContexts:new Array(xe.CANVAS_LAYERS)};var n="-webkit-tap-highlight-color",i="rgba(0,0,0,0)";e.data.canvasContainer=a.createElement("div");var s=e.data.canvasContainer.style;e.data.canvasContainer.style[n]=i,s.position="relative",s.zIndex="0",s.overflow="hidden";var o=r.cy.container();o.appendChild(e.data.canvasContainer),o.style[n]=i;var u={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};uv()&&(u["-ms-touch-action"]="none",u["touch-action"]="none");for(var l=0;l<xe.CANVAS_LAYERS;l++){var v=e.data.canvases[l]=a.createElement("canvas"),f=xe.CANVAS_TYPES[l];e.data.contexts[l]=v.getContext(f),e.data.contexts[l]||Ve("Could not create canvas of type "+f),Object.keys(u).forEach(function(W){v.style[W]=u[W]}),v.style.position="absolute",v.setAttribute("data-id","layer"+l),v.style.zIndex=String(xe.CANVAS_LAYERS-l),e.data.canvasContainer.appendChild(v),e.data.canvasNeedsRedraw[l]=!1}e.data.topCanvas=e.data.canvases[0],e.data.canvases[xe.NODE].setAttribute("data-id","layer"+xe.NODE+"-node"),e.data.canvases[xe.SELECT_BOX].setAttribute("data-id","layer"+xe.SELECT_BOX+"-selectbox"),e.data.canvases[xe.DRAG].setAttribute("data-id","layer"+xe.DRAG+"-drag"),e.data.canvases[xe.WEBGL]&&e.data.canvases[xe.WEBGL].setAttribute("data-id","layer"+xe.WEBGL+"-webgl");for(var l=0;l<xe.BUFFER_COUNT;l++)e.data.bufferCanvases[l]=a.createElement("canvas"),e.data.bufferContexts[l]=e.data.bufferCanvases[l].getContext("2d"),e.data.bufferCanvases[l].style.position="absolute",e.data.bufferCanvases[l].setAttribute("data-id","buffer"+l),e.data.bufferCanvases[l].style.zIndex=String(-l-1),e.data.bufferCanvases[l].style.visibility="hidden";e.pathsEnabled=!0;var d=hr(),h=function(O){return{x:(O.x1+O.x2)/2,y:(O.y1+O.y2)/2}},c=function(O){return{x:-O.w/2,y:-O.h/2}},m=function(O){var G=O[0]._private,ee=G.oldBackgroundTimestamp===G.backgroundTimestamp;return!ee},g=function(O){return O[0]._private.nodeKey},p=function(O){return O[0]._private.labelStyleKey},y=function(O){return O[0]._private.sourceLabelStyleKey},w=function(O){return O[0]._private.targetLabelStyleKey},b=function(O,G,ee,ie,ue){return e.drawElement(O,G,ee,!1,!1,ue)},k=function(O,G,ee,ie,ue){return e.drawElementText(O,G,ee,ie,"main",ue)},x=function(O,G,ee,ie,ue){return e.drawElementText(O,G,ee,ie,"source",ue)},E=function(O,G,ee,ie,ue){return e.drawElementText(O,G,ee,ie,"target",ue)},T=function(O){return O.boundingBox(),O[0]._private.bodyBounds},F=function(O){return O.boundingBox(),O[0]._private.labelBounds.main||d},S=function(O){return O.boundingBox(),O[0]._private.labelBounds.source||d},D=function(O){return O.boundingBox(),O[0]._private.labelBounds.target||d},C=function(O,G){return G},B=function(O){return h(T(O))},A=function(O,G,ee){var ie=O?O+"-":"";return{x:G.x+ee.pstyle(ie+"text-margin-x").pfValue,y:G.y+ee.pstyle(ie+"text-margin-y").pfValue}},M=function(O,G,ee){var ie=O[0]._private.rscratch;return{x:ie[G],y:ie[ee]}},I=function(O){return A("",M(O,"labelX","labelY"),O)},R=function(O){return A("source",M(O,"sourceLabelX","sourceLabelY"),O)},L=function(O){return A("target",M(O,"targetLabelX","targetLabelY"),O)},V=function(O){return c(T(O))},H=function(O){return c(S(O))},z=function(O){return c(D(O))},$=function(O){var G=F(O),ee=c(F(O));if(O.isNode()){switch(O.pstyle("text-halign").value){case"left":ee.x=-G.w-(G.leftPad||0);break;case"right":ee.x=-(G.rightPad||0);break}switch(O.pstyle("text-valign").value){case"top":ee.y=-G.h-(G.topPad||0);break;case"bottom":ee.y=-(G.botPad||0);break}}return ee},K=e.data.eleTxrCache=new Ra(e,{getKey:g,doesEleInvalidateKey:m,drawElement:b,getBoundingBox:T,getRotationPoint:B,getRotationOffset:V,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),Y=e.data.lblTxrCache=new Ra(e,{getKey:p,drawElement:k,getBoundingBox:F,getRotationPoint:I,getRotationOffset:$,isVisible:C}),Q=e.data.slbTxrCache=new Ra(e,{getKey:y,drawElement:x,getBoundingBox:S,getRotationPoint:R,getRotationOffset:H,isVisible:C}),Z=e.data.tlbTxrCache=new Ra(e,{getKey:w,drawElement:E,getBoundingBox:D,getRotationPoint:L,getRotationOffset:z,isVisible:C}),j=e.data.lyrTxrCache=new Wu(e);e.onUpdateEleCalcs(function(O,G){K.invalidateElements(G),Y.invalidateElements(G),Q.invalidateElements(G),Z.invalidateElements(G),j.invalidateElements(G);for(var ee=0;ee<G.length;ee++){var ie=G[ee]._private;ie.oldBackgroundTimestamp=ie.backgroundTimestamp}});var re=function(O){for(var G=0;G<O.length;G++)j.enqueueElementRefinement(O[G].ele)};K.onDequeue(re),Y.onDequeue(re),Q.onDequeue(re),Z.onDequeue(re),r.webgl&&e.initWebgl(r,{getStyleKey:g,getLabelKey:p,drawElement:b,drawLabel:k,getElementBox:T,getLabelBox:F,getElementRotationPoint:B,getElementRotationOffset:V,getLabelRotationPoint:I,getLabelRotationOffset:$})}xe.redrawHint=function(r,e){var t=this;switch(r){case"eles":t.data.canvasNeedsRedraw[xe.NODE]=e;break;case"drag":t.data.canvasNeedsRedraw[xe.DRAG]=e;break;case"select":t.data.canvasNeedsRedraw[xe.SELECT_BOX]=e;break;case"gc":t.data.gc=!0;break}};var Up=typeof Path2D<"u";xe.path2dEnabled=function(r){if(r===void 0)return this.pathsEnabled;this.pathsEnabled=!!r},xe.usePaths=function(){return Up&&this.pathsEnabled},xe.setImgSmoothing=function(r,e){r.imageSmoothingEnabled!=null?r.imageSmoothingEnabled=e:(r.webkitImageSmoothingEnabled=e,r.mozImageSmoothingEnabled=e,r.msImageSmoothingEnabled=e)},xe.getImgSmoothing=function(r){return r.imageSmoothingEnabled!=null?r.imageSmoothingEnabled:r.webkitImageSmoothingEnabled||r.mozImageSmoothingEnabled||r.msImageSmoothingEnabled},xe.makeOffscreenCanvas=function(r,e){var t;if((typeof OffscreenCanvas>"u"?"undefined":He(OffscreenCanvas))!=="undefined")t=new OffscreenCanvas(r,e);else{var a=this.cy.window(),n=a.document;t=n.createElement("canvas"),t.width=r,t.height=e}return t},[Gu,Nr,Kr,Hi,St,ea,fr,il,ft,Va,cl].forEach(function(r){ce(xe,r)});var Kp=[{name:"null",impl:yu},{name:"base",impl:_u},{name:"canvas",impl:Gp}],Xp=[{type:"layout",extensions:B0},{type:"renderer",extensions:Kp}],gl={},pl={};function ml(r,e,t){var a=t,n=function(T){Pe("Can not register `"+e+"` for `"+r+"` since `"+T+"` already exists in the prototype and can not be overridden")};if(r==="core"){if(Aa.prototype[e])return n(e);Aa.prototype[e]=t}else if(r==="collection"){if(rr.prototype[e])return n(e);rr.prototype[e]=t}else if(r==="layout"){for(var i=function(T){this.options=T,t.call(this,T),Se(this._private)||(this._private={}),this._private.cy=T.cy,this._private.listeners=[],this.createEmitter()},s=i.prototype=Object.create(t.prototype),o=[],u=0;u<o.length;u++){var l=o[u];s[l]=s[l]||function(){return this}}s.start&&!s.run?s.run=function(){return this.start(),this}:!s.start&&s.run&&(s.start=function(){return this.run(),this});var v=t.prototype.stop;s.stop=function(){var E=this.options;if(E&&E.animate){var T=this.animations;if(T)for(var F=0;F<T.length;F++)T[F].stop()}return v?v.call(this):this.emit("layoutstop"),this},s.destroy||(s.destroy=function(){return this}),s.cy=function(){return this._private.cy};var f=function(T){return T._private.cy},d={addEventFields:function(T,F){F.layout=T,F.cy=f(T),F.target=T},bubble:function(){return!0},parent:function(T){return f(T)}};ce(s,{createEmitter:function(){return this._private.emitter=new yn(d,this),this},emitter:function(){return this._private.emitter},on:function(T,F){return this.emitter().on(T,F),this},one:function(T,F){return this.emitter().one(T,F),this},once:function(T,F){return this.emitter().one(T,F),this},removeListener:function(T,F){return this.emitter().removeListener(T,F),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(T,F){return this.emitter().emit(T,F),this}}),Be.eventAliasesOn(s),a=i}else if(r==="renderer"&&e!=="null"&&e!=="base"){var h=yl("renderer","base"),c=h.prototype,m=t,g=t.prototype,p=function(){h.apply(this,arguments),m.apply(this,arguments)},y=p.prototype;for(var w in c){var b=c[w],k=g[w]!=null;if(k)return n(w);y[w]=b}for(var x in g)y[x]=g[x];c.clientFunctions.forEach(function(E){y[E]=y[E]||function(){Ve("Renderer does not implement `renderer."+E+"()` on its prototype")}}),a=p}else if(r==="__proto__"||r==="constructor"||r==="prototype")return Ve(r+" is an illegal type to be registered, possibly lead to prototype pollutions");return ys({map:gl,keys:[r,e],value:a})}function yl(r,e){return ws({map:gl,keys:[r,e]})}function Yp(r,e,t,a,n){return ys({map:pl,keys:[r,e,t,a],value:n})}function Zp(r,e,t,a){return ws({map:pl,keys:[r,e,t,a]})}var ji=function(){if(arguments.length===2)return yl.apply(null,arguments);if(arguments.length===3)return ml.apply(null,arguments);if(arguments.length===4)return Zp.apply(null,arguments);if(arguments.length===5)return Yp.apply(null,arguments);Ve("Invalid extension access syntax")};Aa.prototype.extension=ji,Xp.forEach(function(r){r.extensions.forEach(function(e){ml(r.type,e.name,e.impl)})});var wl=function r(){if(!(this instanceof r))return new r;this.length=0},kt=wl.prototype;kt.instanceString=function(){return"stylesheet"},kt.selector=function(r){var e=this.length++;return this[e]={selector:r,properties:[]},this},kt.css=function(r,e){var t=this.length-1;if(fe(r))this[t].properties.push({name:r,value:e});else if(Se(r))for(var a=r,n=Object.keys(a),i=0;i<n.length;i++){var s=n[i],o=a[s];if(o!=null){var u=sr.properties[s]||sr.properties[Ua(s)];if(u!=null){var l=u.name,v=o;this[t].properties.push({name:l,value:v})}}}return this},kt.style=kt.css,kt.generateStyle=function(r){var e=new sr(r);return this.appendToStyle(e)},kt.appendToStyle=function(r){for(var e=0;e<this.length;e++){var t=this[e],a=t.selector,n=t.properties;r.selector(a);for(var i=0;i<n.length;i++){var s=n[i];r.css(s.name,s.value)}}return r};var Qp="3.31.0",dt=function(e){if(e===void 0&&(e={}),Se(e))return new Aa(e);if(fe(e))return ji.apply(ji,arguments)};dt.use=function(r){var e=Array.prototype.slice.call(arguments,1);return e.unshift(dt),r.apply(null,e),this},dt.warnings=function(r){return Is(r)},dt.version=Qp,dt.stylesheet=dt.Stylesheet=wl;function bl(r,e,t,a){if(!(r instanceof Error))throw r;if(!(typeof window>"u"&&e||a))throw r.message+=" on line "+t,r;var n,i,s,o;try{a=a||require("fs").readFileSync(e,{encoding:"utf8"}),n=3,i=a.split(`
`),s=Math.max(t-n,0),o=Math.min(i.length,t+n)}catch(u){return r.message+=" - could not read from "+e+" ("+u.message+")",void bl(r,null,t)}n=i.slice(s,o).map(function(u,l){var v=l+s+1;return(v==t?"  > ":"    ")+v+"| "+u}).join(`
`),r.path=e;try{r.message=(e||"Pug")+":"+t+`
`+n+`

`+r.message}catch{}throw r}function Jp(r){var e="",t,a;try{a=1,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/graphItem.pug",e=e+'<div class="g-graph-container">',a=2,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/graphItem.pug",e=e+'<div class="g-item-info-header">',a=3,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/graphItem.pug",e=e+'<i class="icon-picture"></i>',a=4,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/graphItem.pug",e=e+"GEMD Graph</div></div>",a=5,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/graphItem.pug",e=e+'<div class="g-graph-panes clearfix">',a=6,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/graphItem.pug",e=e+'<div class="g-graph-left">',a=7,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/graphItem.pug",e=e+'<div id="cy"></div></div>',a=8,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/graphItem.pug",e=e+'<div class="g-graph-right">',a=9,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/graphItem.pug",e=e+'<div id="cy-json"></div></div></div>'}catch(n){bl(n,t,a)}return e}const Om="",{restRequest:jp}=girder.rest,em=girder.views.View,Fl=girder.$;var El={node:{css:!1,data:!0,position:!0,discludeds:[]},edge:{css:!1,data:!0,discludeds:[]},layoutBy:"cose"};dt("core","graphml",function(r){var e=this,t,a=function(n,i,s,o){function u(l,v){l.children("node").each(function(){var f=i(this),d=f.attr("id");d.includes("[")&&(d=d.split(" [")[0]);var h={data:{id:f.attr("id"),label:d},css:{},position:{}};v!==null&&(h.data.parent=v.attr("id")),f.children("data").each(function(){var c=i(this);h.data[c.attr("key")]=c.text()}),n.add({group:"nodes",data:h.data,css:h.css,position:h.position,style:{"background-color":h.data.color}}),f.children("graph").each(function(){var c=i(this);u(c,f)})})}n.batch(function(){i(i.parseXML(r)).find("graph").first().each(function(){var d=i(this);u(d,null),d.find("edge").each(function(){var h=i(this),c={data:{id:h.attr("id"),source:h.attr("source"),target:h.attr("target")},css:{},position:{}};h.find("data").each(function(){var m=i(this);c.data[m.attr("key")]=m.text()}),n.add({group:"edges",data:c.data,css:c.css})})});var f=typeof s.layoutBy;f==="string"?n.layout({name:s.layoutBy}).run():f==="function"&&s.layoutBy()})};switch(typeof r){case"string":console.log("Importing GraphML..."),t=a(e,Fl,El);break;case"object":Fl.extend(!0,El,r),t=e;break;case"undefined":console.log("Exporter doesn't work yet.");break;default:console.log("Functionality(argument) of .graphml() is not recognized.")}return t});const rm=em.extend({className:"g-graph-view",initialize:function(r){this.graphId=r.graphId;var e=this;jp({url:`file/${r.graphId}/download`}).done(t=>{e.graphFile=t,e.render()})},render:function(){if(this.$el.html(Jp()),document.getElementById("cy")){var r=this,e=dt({container:document.getElementById("cy"),style:[{selector:"node",style:{"background-color":"#666",label:"data(label)"}},{selector:"edge",style:{width:3,"line-color":"#ccc","target-arrow-color":"#ccc","target-arrow-shape":"triangle","curve-style":"bezier"}}],layout:{name:"grid",rows:1},ready:function(){console.log(r.graphFile),this.graphml({layoutBy:"cose"}),this.graphml(r.graphFile)}});e.on("tap","node",function(){const t=JSON.stringify(JSON.parse(this.data("object")),null,2),a=/(https?:\/\/[^\s]+)/g,n=t.replace(a,function(i){return'<a href="'+i+'" target="_blank">'+i+"</a>"});document.getElementById("cy-json").innerHTML="<pre>"+n+"</pre>",console.log("tapped "+this.id())})}return this}});function xl(r,e,t,a){if(!(r instanceof Error))throw r;if(!(typeof window>"u"&&e||a))throw r.message+=" on line "+t,r;var n,i,s,o;try{a=a||require("fs").readFileSync(e,{encoding:"utf8"}),n=3,i=a.split(`
`),s=Math.max(t-n,0),o=Math.min(i.length,t+n)}catch(u){return r.message+=" - could not read from "+e+" ("+u.message+")",void xl(r,null,t)}n=i.slice(s,o).map(function(u,l){var v=l+s+1;return(v==t?"  > ":"    ")+v+"| "+u}).join(`
`),r.path=e;try{r.message=(e||"Pug")+":"+t+`
`+n+`

`+r.message}catch{}throw r}function tm(r){var e="",t,a;try{a=1,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewWidget.pug",e=e+'<div class="g-widget-item-previews-header">',a=2,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewWidget.pug",e=e+'<i class="icon-eye"></i>',a=3,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewWidget.pug",e=e+" Item Previews</div>",a=5,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewWidget.pug",e=e+'<div class="g-widget-item-previews-container">',a=6,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewWidget.pug",e=e+'<div class="g-widget-item-previews-wrapper"></div></div>'}catch(n){xl(n,t,a)}return e}function $a(r,e,t,a){if(e===!1||e==null||!e&&(r==="class"||r==="style"))return"";if(e===!0)return" "+(a?r:r+'="'+r+'"');var n=typeof e;return n!=="object"&&n!=="function"||typeof e.toJSON!="function"||(e=e.toJSON()),typeof e=="string"||(e=JSON.stringify(e),t||e.indexOf('"')===-1)?(t&&(e=Hn(e))," "+r+'="'+e+'"'):" "+r+"='"+e.replace(/'/g,"&#39;")+"'"}function Hn(r){var e=""+r,t=am.exec(e);if(!t)return r;var a,n,i,s="";for(a=t.index,n=0;a<e.length;a++){switch(e.charCodeAt(a)){case 34:i="&quot;";break;case 38:i="&amp;";break;case 60:i="&lt;";break;case 62:i="&gt;";break;default:continue}n!==a&&(s+=e.substring(n,a)),n=a+1,s+=i}return n!==a?s+e.substring(n,a):s}var am=/["&<>]/;function Cl(r,e,t,a){if(!(r instanceof Error))throw r;if(!(typeof window>"u"&&e||a))throw r.message+=" on line "+t,r;var n,i,s,o;try{a=a||require("fs").readFileSync(e,{encoding:"utf8"}),n=3,i=a.split(`
`),s=Math.max(t-n,0),o=Math.min(i.length,t+n)}catch(u){return r.message+=" - could not read from "+e+" ("+u.message+")",void Cl(r,null,t)}n=i.slice(s,o).map(function(u,l){var v=l+s+1;return(v==t?"  > ":"    ")+v+"| "+u}).join(`
`),r.path=e;try{r.message=(e||"Pug")+":"+t+`
`+n+`

`+r.message}catch{}throw r}function nm(r){var e="",t,a,n;try{var i=r||{};(function(s,o,u){n=1,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+'<div class="g-widget-item-preview">',n=3,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+"<h4>",n=4,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+"<a"+(' class="g-item-preview-link"'+$a("data-id",u.id,!0,!1))+">",n=4,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+Hn((t=u.name())==null?"":t)+"</a></h4>",n=6,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",(function(){var l=o;if(typeof l.length=="number")for(var v=0,f=l.length;v<f;v++){var d=l[v];n=7,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",d.type==="image"?(n=8,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+"<div>",n=9,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+"<img"+$a("src",d.value,!0,!1)+"/></div>"):d.type==="json"&&(n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+"<textarea"+(' class="json"'+$a("data-id",u.id,!0,!1))+">",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+Hn((t=s.stringify(d.value,null,"	"))==null?"":t)+"</textarea>")}else{var f=0;for(var v in l){f++;var d=l[v];n=7,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",d.type==="image"?(n=8,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+"<div>",n=9,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+"<img"+$a("src",d.value,!0,!1)+"/></div>"):d.type==="json"&&(n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+"<textarea"+(' class="json"'+$a("data-id",u.id,!0,!1))+">",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/itemPreviewItem.pug",e=e+Hn((t=s.stringify(d.value,null,"	"))==null?"":t)+"</textarea>")}}}).call(this),e=e+"</div>"}).call(this,"JSON"in i?i.JSON:typeof JSON<"u"?JSON:void 0,"contents"in i?i.contents:typeof contents<"u"?contents:void 0,"item"in i?i.item:typeof item<"u"?item:void 0)}catch(s){Cl(s,a,n)}return e}const _m="",Tl=girder.views.View,{getApiRoot:im,restRequest:Sl}=girder.rest,{_whenAll:kl}=girder.misc,es=girder.$,Dl=girder._;var sm=Tl.extend({events:{"click a.g-item-preview-link":function(r){var e=this.$(r.currentTarget).data("id");this.parentView.itemListView.trigger("g:itemClicked",this.collection.get(e))}},initialize:function(r){this.debouncedaddMoreItems=Dl.debounce(this.addMoreItems,100),this.onScroll=Dl.debounce(this.onScroll,100),this.initialized=!1,this.addingMoreItems=!1,this.supportedItems=[]},setCollection:function(r){this.collection=r,this.listenTo(this.collection,"g:changed",()=>{this.supportedItems=this.collection.filter(this._isSupportedItem.bind(this)),this.supportedItems.length!==0&&(this.isNotFull()||this.isNearBottom())&&this.debouncedaddMoreItems()})},_MAX_JSON_SIZE:2e6,_MAX_IMAGE_SIZE:2e7,_LOAD_BATCH_SIZE:2,_isSupportedItem:function(r){return this._isImageItem(r.name())||this._isJSONItem(r.name())},_isJSONItem:function(r){return/(json)$/i.test(r)},_isImageItem:function(r){return/(jpg|jpeg|png|gif)$/i.test(r)},setElement:function(r){return this.initialized=!1,Tl.prototype.setElement.apply(this,arguments)},render:function(){return this.initialized||(this.initialized=!0,this.renderedIndex=0,this.$el.html(tm()),this.$(".g-widget-item-previews-container").on("scroll",r=>this.onScroll(r)),this.debouncedaddMoreItems()),this},isNotFull:function(){return this.$(".g-widget-item-previews-wrapper").height()<=this.$(".g-widget-item-previews-container").height()},allItemAdded:function(){return this.renderedIndex>=this.supportedItems.length},addMoreItems:function(){this.addingMoreItems=!0;var r=this.supportedItems.slice(this.renderedIndex,this.renderedIndex+this._LOAD_BATCH_SIZE);if(this.renderedIndex=Math.min(this.renderedIndex+this._LOAD_BATCH_SIZE,this.supportedItems.length),!!r.length){var e=this.$(".g-widget-item-previews-wrapper");kl(r.map(t=>Sl({url:`item/${t.id}/files`,data:{limit:5}}).then(a=>kl(a.map(n=>this.tryGetFileContent(n,n.mimeType)))))).done(t=>{r.forEach((a,n)=>{var i=t[n].filter(s=>s);i.length&&e.append(nm({item:a,contents:i}))}),!this.allItemAdded()&&this.isNotFull()&&this.addMoreItems()}).always(()=>{this.addingMoreItems=!1})}},isNearBottom:function(){var r=this.$(".g-widget-item-previews-container");return r.scrollTop()+r.innerHeight()>=r[0].scrollHeight-200},onScroll:function(r){this.isNearBottom()&&!this.addingMoreItems&&!this.allItemAdded()&&this.addMoreItems()},tryGetFileContent:function(r,e){if(this._isJSONItem(r.name))return r.size>this._MAX_JSON_SIZE?es.Deferred().resolve(null).promise():this.getJsonContent(`file/${r._id}/download`);if(this._isImageItem(e))return r.size>this._MAX_IMAGE_SIZE?es.Deferred().resolve(null).promise():this.getImageContent(`file/${r._id}/download`)},getJsonContent:function(r){return Sl({url:r,method:"GET",error:null}).then(e=>({type:"json",value:e}))},getImageContent:function(r){var e=es.Deferred(),a=im()+"/"+r,n=new Image;return n.onload=function(){e.resolve({type:"image",value:a})},n.src=a,e.promise()}});const{wrap:om}=girder.utilities.PluginUtils,um=girder.views.widgets.HierarchyWidget;om(um,"render",function(r){return r.call(this),this.parentModel.resourceName==="folder"&&this._showItems&&(this.itemPreviewView=new sm({class:"g-item-previews-container",collection:this.itemListView.collection,parentView:this}),this.$el.append(this.itemPreviewView.$el),this.itemPreviewView.setCollection(this.itemListView.collection),this.itemPreviewView.render()),this});function Pl(r,e,t,a){if(!(r instanceof Error))throw r;if(!(typeof window>"u"&&e||a))throw r.message+=" on line "+t,r;var n,i,s,o;try{a=a||require("fs").readFileSync(e,{encoding:"utf8"}),n=3,i=a.split(`
`),s=Math.max(t-n,0),o=Math.min(i.length,t+n)}catch(u){return r.message+=" - could not read from "+e+" ("+u.message+")",void Pl(r,null,t)}n=i.slice(s,o).map(function(u,l){var v=l+s+1;return(v==t?"  > ":"    ")+v+"| "+u}).join(`
`),r.path=e;try{r.message=(e||"Pug")+":"+t+`
`+n+`

`+r.message}catch{}throw r}function lm(r){var e="",t,a;try{a=1,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+'<div class="form-group">',a=2,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+'<label for="g-htmdec-data">',a=2,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+"HTMDEC Data",a=3,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+'<select class="form-control input-sm" id="g-htmdec-data">',a=4,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+'<option value="default" selected="selected">',a=4,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+"Not HTMDEC</option>",a=5,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+'<option value="sem">',a=5,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+"SEM Data</option>",a=6,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+'<option value="pdv">',a=6,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+"PDV Data</option>",a=7,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+'<option value="syncFolder">',a=7,t="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/filesystemImport.pug",e=e+"Sync Folder</option></select></label></div>"}catch(n){Pl(n,t,a)}return e}const vm=girder.router,Bl=girder.views.body.FilesystemImportView,{wrap:fm}=girder.utilities.PluginUtils,dm=girder.$;Bl.prototype.events["submit .g-filesystem-import-form"]=function(r){r.preventDefault();var e=this.$("#g-filesystem-import-dest-id").val().trim().split(/\s/)[0],t=this.$("#g-filesystem-import-dest-type").val(),a=this.$("#g-filesystem-import-leaf-items").val();this.$(".g-validation-failed-message").empty(),this.assetstore.off("g:imported").on("g:imported",function(){vm.navigate(t+"/"+e,{trigger:!0})},this).on("g:error",function(n){this.$(".g-validation-failed-message").text(n.responseJSON.message)},this).import({importPath:this.$("#g-filesystem-import-path").val().trim(),leafFoldersAsItems:a,destinationId:e,destinationType:t,dataType:this.$("#g-htmdec-data").val(),progress:!0})},fm(Bl,"render",function(r){return r.call(this),dm(".g-filesystem-import-form > .form-group").last().after(lm()),this});function ct(r,e,t,a){if(e===!1||e==null||!e&&(r==="class"||r==="style"))return"";if(e===!0)return" "+(a?r:r+'="'+r+'"');var n=typeof e;return n!=="object"&&n!=="function"||typeof e.toJSON!="function"||(e=e.toJSON()),typeof e=="string"||(e=JSON.stringify(e),t||e.indexOf('"')===-1)?(t&&(e=qa(e))," "+r+'="'+e+'"'):" "+r+"='"+e.replace(/'/g,"&#39;")+"'"}function qa(r){var e=""+r,t=cm.exec(e);if(!t)return r;var a,n,i,s="";for(a=t.index,n=0;a<e.length;a++){switch(e.charCodeAt(a)){case 34:i="&quot;";break;case 38:i="&amp;";break;case 60:i="&lt;";break;case 62:i="&gt;";break;default:continue}n!==a&&(s+=e.substring(n,a)),n=a+1,s+=i}return n!==a?s+e.substring(n,a):s}var cm=/["&<>]/;function Al(r,e,t,a){if(!(r instanceof Error))throw r;if(!(typeof window>"u"&&e||a))throw r.message+=" on line "+t,r;var n,i,s,o;try{a=a||require("fs").readFileSync(e,{encoding:"utf8"}),n=3,i=a.split(`
`),s=Math.max(t-n,0),o=Math.min(i.length,t+n)}catch(u){return r.message+=" - could not read from "+e+" ("+u.message+")",void Al(r,null,t)}n=i.slice(s,o).map(function(u,l){var v=l+s+1;return(v==t?"  > ":"    ")+v+"| "+u}).join(`
`),r.path=e;try{r.message=(e||"Pug")+":"+t+`
`+n+`

`+r.message}catch{}throw r}function hm(r){var e="",t,a,n;try{var i=r||{};(function(s,o,u){n=1,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+'<div class="g-item-rel-sims g-info list-entry">',n=2,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+'<i class="icon-link-ext"></i>',n=3,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+"Related Data",n=4,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",(function(){var l=s;if(typeof l.length=="number")for(var v=0,f=l.length;v<f;v++){var d=l[v];n=5,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+'<li class="g-sim-list-entry">',n=6,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+"<a"+(' class="g-item-list-link g-right-border"'+ct("g-item-cid",d.cid,!0,!1)+ct("href",`#folder/${d._id}`,!0,!1))+">",n=7,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+qa((t=d.name)==null?"":t)+"</a></li>"}else{var f=0;for(var v in l){f++;var d=l[v];n=5,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+'<li class="g-sim-list-entry">',n=6,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+"<a"+(' class="g-item-list-link g-right-border"'+ct("g-item-cid",d.cid,!0,!1)+ct("href",`#folder/${d._id}`,!0,!1))+">",n=7,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+qa((t=d.name)==null?"":t)+"</a></li>"}}}).call(this),n=8,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",(function(){var l=o;if(typeof l.length=="number")for(var v=0,f=l.length;v<f;v++){var d=l[v];n=9,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",d._id!=u.model.id&&(n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+'<li class="g-sim-list-entry">',n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+"<a"+(' class="g-item-list-link g-right-border"'+ct("g-item-cid",d.cid,!0,!1)+ct("href",`#item/${d._id}`,!0,!1))+">",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+qa((t=d.name)==null?"":t)+"</a></li>")}else{var f=0;for(var v in l){f++;var d=l[v];n=9,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",d._id!=u.model.id&&(n=10,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+'<li class="g-sim-list-entry">',n=11,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+"<a"+(' class="g-item-list-link g-right-border"'+ct("g-item-cid",d.cid,!0,!1)+ct("href",`#item/${d._id}`,!0,!1))+">",n=12,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+qa((t=d.name)==null?"":t)+"</a></li>")}}}).call(this),e=e+"</div>",n=13,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+'<div class="g-item-analyze-in-wt g-info list-entry">',n=14,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+'<i class="icon-eye">',n=15,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+'<a class="g-item-list-link" id="ainwt" href="#" style="font-style: normal;">',n=16,a="/home/runner/work/girder-sem-viewer/girder-sem-viewer/girder_sem_viewer/web_client/templates/relatedDataWidget.pug",e=e+"Analyze in WholeTale</a></i></div>"}).call(this,"folders"in i?i.folders:typeof folders<"u"?folders:void 0,"items"in i?i.items:typeof items<"u"?items:void 0,"parentView"in i?i.parentView:typeof parentView<"u"?parentView:void 0)}catch(s){Al(s,a,n)}return e}const Nm="",{restRequest:gm}=girder.rest,Il=girder.views.body.ItemView,{wrap:Ml}=girder.utilities.PluginUtils;Ml(Il,"initialize",function(r,...e){if(r.apply(this,e),this._dataRequest=null,this.model.attributes.meta&&this.model.attributes.meta.jhu_id){const t=this.model.attributes.meta.jhu_id,a={baseParentId:this.model.attributes.baseParentId,baseParentType:this.model.attributes.baseParentType};this._dataRequest=gm({url:"resource/search",data:{q:t,mode:"jhuId",types:JSON.stringify(["item","folder"]),filters:JSON.stringify(a),limit:10}})}}),Ml(Il,"render",function(r){return this.once("g:rendered",function(){this._dataRequest!==null&&this._dataRequest.done(e=>{girder.$(".g-item-info").append(hm({items:e.item,folders:e.folder,parentView:this}));const t=e.item.map(u=>({itemId:u._id,mountPath:`/${u.name}`,_modelType:"item"})),a=e.folder.map(u=>({itemId:u._id,mountPath:`/${u.name}`,_modelType:"folder"})),n=t.concat(a),i=window.location.hostname.split(".")[0],s=window.location.origin.replace(i,"dashboard")+"/mine",o=new URLSearchParams;o.set("name","My Tale"),o.set("asTale",!1),o.set("dataSet",JSON.stringify(n)),document.querySelector("#ainwt").href=`${s}?${o.toString()}`})},this),r.call(this),this});const zm="",pm=girder.models.FileModel,mm=girder.models.FolderModel,ym=girder.views.widgets.HierarchyWidget,ta=girder.views.widgets.UploadWidget,{getCurrentUser:wm}=girder.auth,{AccessType:Rl}=girder.constants,{formatSize:Gn}=girder.misc,{wrap:Dt}=girder.utilities.PluginUtils,{restRequest:bm}=girder.rest,Ll=girder.$,rs=girder._;function Un(r){const e=r.webkitRelativePath.split("/");return e.length>1?e.slice(0,-1).join("/")+"/":""}function Fm(r){const e=Array.from(r),t=new Map;return e.sort((a,n)=>{const i=Un(a),s=Un(n);return i.localeCompare(s)}),e.forEach(a=>{const n=Un(a);t.has(n)||t.set(n,[]),t.get(n).push(a)}),Array.from(t.values())}Dt(ta,"initialize",function(r,e){return r.call(this,e),this.onlyFiles=rs.has(e,"onlyFiles")?e.onlyFiles:!1,this.onlyFolders=rs.has(e,"onlyFolders")?e.onlyFolders:!1,this}),Dt(ta,"render",function(r){if(this.parentType=this.parent.attributes._modelType,r.call(this),this.parentType!=="item"&&!this.onlyFiles){var e='<div class="g-upload-folder"><i class="icon-folder-open"></i>Select a folder to upload</div>';e+='<div class="form-group hide"><input type="file" id="folderInput" webkitdirectory multiple></div>',this.$(".g-drop-zone").after(e)}return(this.parentType==="user"||this.parentType==="collection"||this.onlyFolders)&&this.$(".g-drop-zone").addClass("hide"),this}),Dt(ta,"events",function(r){return this.events["submit #g-upload-form"]=function(e){e.preventDefault(),this.$(".g-upload-folder").addClass("hide"),this.startUpload()},this.events["click .g-resume-upload"]=function(){this.$(".g-upload-error-message").html(""),this.currentFile.resumeUpload()},this.events["click .g-restart-upload"]=function(){this.$(".g-upload-error-message").html(""),this.uploadNextFile()},this.events["change #g-files"]=function(){var e=this.$("#g-files")[0].files;e.length&&(this.files=e,this.filesChanged())},this.events["click .g-drop-zone"]=function(){this.$("#g-files").click()},this.events["dragenter .g-drop-zone"]=function(e){e.stopPropagation(),e.preventDefault(),e.originalEvent.dataTransfer.dropEffect="copy",this.$(".g-drop-zone").addClass("g-dropzone-show").html('<i class="icon-bullseye"/> Drop files here')},this.events["dragleave .g-drop-zone"]=function(e){e.stopPropagation(),e.preventDefault(),this.$(".g-drop-zone").removeClass("g-dropzone-show").html('<i class="icon-docs"/> Browse or drop files')},this.events["dragover .g-drop-zone"]=function(e){var t=e.originalEvent.dataTransfer;if(t){var a=t.effectAllowed;t.dropEffect=a==="move"||a==="linkMove"?"move":"copy",e.preventDefault()}},this.events["drop .g-drop-zone"]="filesDropped",this.events["click .g-upload-folder"]=function(){this.$("#folderInput").click()},this.events["change #folderInput"]=function(){var e=this.$("#folderInput")[0].files;e.length>0&&(this.files=e,this.filesChanged())},this.events}),Dt(ta,"uploadNextFile",function(r){const e=Fm(this.files);e.length===1&&e[0][0].webkitRelativePath===""?r.call(this):(this.totalFiles=this.files.length,this.groupedFiles=e,this.currentDirIndex=0,this.uploadNextFileRecursive())}),Dt(ta,"uploadNextFileRecursive",function(r){this.files=this.groupedFiles[this.currentDirIndex],this._currentDirFileIndex=0,this._currentDirTotalFiles=this.files.length;const e=Un(this.files[0]).slice(0,-1);if(this.currentDirIndex>=this.groupedFiles.length){this.modal&&this.$el.modal("hide"),this.trigger("g:uploadFinished",{files:[].concat(...this.groupedFiles),totalFiles:this.totalFiles,folder:e});return}var t=this;bm({url:"folder/recursive",method:"POST",data:{parentId:this.parent.id,parentType:this.parentType,path:e}}).done(function(a){var n=new mm;n.set(a),t._uploadNext(n)})}),Dt(ta,"_uploadNext",function(r,e){if(!(this._currentDirFileIndex>=this._currentDirTotalFiles)){this.currentFile=new pm,this.currentFile.on("g:upload.complete",function(){this.files[this._currentDirFileIndex].id=this.currentFile.id,this._currentDirFileIndex+=1,this._currentDirFileIndex<this._currentDirTotalFiles?this._uploadNext(e):(this.currentDirIndex+=1,this.currentDirIndex<this.groupedFiles.length?this.uploadNextFileRecursive():(this.modal&&this.$el.modal("hide"),this.trigger("g:uploadFinished",{files:[].concat(...this.groupedFiles),totalFiles:this.totalFiles})))},this).on("g:upload.chunkSent",function(a){this.overallProgress+=a.bytes},this).on("g:upload.progress",function(a){var n=a.startByte+a.loaded;this.$(".g-progress-current>.progress-bar").css("width",Math.ceil(100*n/a.total)+"%"),this.$(".g-progress-overall>.progress-bar").css("width",Math.ceil(100*(this.overallProgress+a.loaded)/this.totalSize)+"%"),this.$(".g-current-progress-message").html('<i class="icon-doc-text"/>'+(this.currentIndex+1)+" of "+this.files.length+" - <b>"+a.file.name+"</b>: "+Gn(n)+" / "+Gn(a.total)),this.$(".g-overall-progress-message").html("Overall progress: "+Gn(this.overallProgress+a.loaded)+" / "+Gn(this.totalSize))},this).on("g:upload.error",function(a){var n=a.message+' <a class="g-resume-upload">Click here to resume the upload</a>';Ll(".g-upload-error-message").html(n)},this).on("g:upload.errorStarting",function(a){var n=a.message+' <a class="g-restart-upload">Click here to restart the upload</a>';Ll(".g-upload-error-message").html(n)},this);var t=this.otherParams;rs.isFunction(this.otherParams)&&(t=this.otherParams(this)),this.currentFile.upload(e,this.files[this._currentDirFileIndex],null,t)}}),Dt(ym,"render",function(r){const e=this.parentModel.getAccessLevel(),t=wm(),a=this.parentModel.resourceName,n=`<button
                      class="g-upload-here-button btn btn-sm btn-success"
                      title="Upload here">
                      <i class="icon-upload"></i>
                    </button>`;r.call(this);const i=this.$(".g-folder-header-buttons");t&&a==="collection"&&e>=Rl.WRITE&&i.length>0&&this.$(".g-collection-info-button").after(n),t&&a==="user"&&e>=Rl.WRITE&&i.prepend(n)});const{wrap:Em}=girder.utilities.PluginUtils,xm=girder.views.body.ItemView,Cm=girder.views.widgets.SearchFieldWidget;Em(xm,"render",function(r){return this.once("g:rendered",()=>{(this.model.attributes.name.endsWith(".tif")||this.model.attributes.name.endsWith(".tiff"))&&new Hl({parentView:this,item:this.model}).render().$el.insertAfter(this.$(".g-item-info")),this.model.attributes.meta&&this.model.attributes.meta.graphml&&new rm({parentView:this,graphId:this.model.attributes.meta.graphml}).render().$el.insertAfter(this.$(".g-item-info"))}),r.call(this)}),Cm.addMode("jhuId",["item","folder"],"Search by JHU ID","You are searching for all data collected for a specific JHU ID. (e.g. F138-R2C7)")});
//# sourceMappingURL=girder-plugin-sem-viewer.umd.cjs.map
