@visuallyjs/browser-ui 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  var lb=Object.defineProperty,AL=Object.defineProperties,SL=Object.getOwnPropertyDescriptor,TL=Object.getOwnPropertyDescriptors;var ab=Object.getOwnPropertySymbols;var vL=Object.prototype.hasOwnProperty,CL=Object.prototype.propertyIsEnumerable;var Hg=(i,r,e)=>r in i?lb(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e,Wn=(i,r)=>{for(var e in r||(r={}))vL.call(r,e)&&Hg(i,e,r[e]);if(ab)for(var e of ab(r))CL.call(r,e)&&Hg(i,e,r[e]);return i},hb=(i,r)=>AL(i,TL(r));var Rt=(i,r,e,t)=>{for(var n=t>1?void 0:t?SL(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&lb(r,e,n),n};var c=(i,r,e)=>(Hg(i,typeof r!="symbol"?r+"":r,e),e);function wc(i){let r=i.graph,e=i.source,t=i.target,n=i.nodeFilter,o=i.edgeFilter,s={},a={},l={},h={dist:s,previous:a,edges:l,path:[]},d=i.processAll,u={},p={},m=i.strict!==!1,g=C=>C.getFullId?C.getFullId():C.id,E=[],y=C=>{let _=p[C.getFullId()];return u[_.v.id]},x=(C,_)=>{let w,B;if(C.objectType===me.objectType){for(s[C.getFullId()]=_,w=y(C),B=0;B<w.length;B++)w[B].p!=C&&(s[w[B].p.getFullId()]=_+C.getParent().getInternalEdge(C,w[B].p).cost);m||(s[C.getParent().id]=_)}else for(s[C.id]=_,w=u[C.id],B=0;B<w.length;B++)s[w[B].p.getFullId()]=_},f=C=>n&&!n(C)?1/0:s[g(C)],b=(C,_,w)=>{if(C.objectType===me.objectType){let B=y(C);for(let D=0;D<B.length;D++)a[B[D].p.getFullId()]=w.node;m||(a[C.getParent().id]=w.node)}a[_]=w.node},A=(C,_,w)=>{if(C.objectType===me.objectType){let B=y(C);for(let D=0;D<B.length;D++)l[B[D].p.getFullId()]=w;m||(l[C.getParent().id]=w)}l[_]=w},T=(C,_,w,B,D)=>{let M=-1,N=null,G=1/0;for(let J=0;J<C.length;J++)if(!_[J]){let Ee=D(C[J]);Ee<G?(G=Ee,M=J,N=C[J]):Ee===G&&C[J].objectType===me.objectType&&C[J].getParent()===N&&(M=J,N=C[J])}return{node:N,index:M}},S=(C,_)=>{let w=_.getFullId(),B=C[w];return B==null&&(w=_.getParent?_.getParent().id:_.id,B=C[w]),B==null?null:{p:B,id:w}},R=(C,_,w,B,D,M)=>{let N=[],G=B,J=S(_,G);for(;J!=null;)N.splice(0,0,{vertex:G,cost:C[J.id],edge:w[J.id]}),G=J.p,J=S(_,G);return N.splice(0,0,{vertex:G,cost:0,edge:null}),N},v=C=>{for(let _=0;_<C.length;_++){let w=C[_],B=w.getPorts();E.push(w);let D={v:w,i:E.length-1};u[w.id]=[],x(w,1/0);for(let M=0;M<B.length;M++)E.push(B[M]),p[B[M].getFullId()]=D,u[w.id].push({p:B[M],i:E.length-1}),x(B[M],1/0)}};if(v(r.nodes),v(r.groups),e==null&&(e=r.getVertex(i.sourceId)),t==null&&(t=r.getVertex(i.targetId)),e==null||t==null)return h;x(e,0);let O=new Array(r.nodes.length),P=0,I=(C,_,w,B)=>{for(let D=0;D<_.length;D++){let M=_[D];if(w(M)){let N=B(M),G=N.tp||N.tn,J=g(G),Ee=f(C.node)+M.getCost(),j=f(G);Ee<j&&(x(G,Ee),b(G,J,C),A(G,J,M))}}};for(;P<E.length;){let C=T(E,O,s,g,f),_=C.node?g(C.node):null;if(!C.node||f(C.node)==1/0||t&&(_==g(t)||!m&&C.node.objectType===me.objectType&&C.node.isChildOf(t))&&(h.path=R(s,a,l,t,g),h.pathDistance=h.path[h.path.length-1].cost,!d))break;O[C.index]=!0,P=P+1,I(C,C.node.getAllEdges(),w=>o&&!o(w)?!1:!w.isDirected()||C.node==w.source||!m&&w.source.objectType===me.objectType&&w.source.isChildOf(C.node),w=>{var B=w.source.objectType===me.objectType?w.source.getParent():w.source,D=w.source.objectType===me.objectType?w.source:null,M=w.target.objectType===me.objectType?w.target.getParent():w.target,N=w.target.objectType===me.objectType?w.target:null;return w.source==C.node||!m&&w.source.objectType===me.objectType&&w.source.isChildOf(C.node)?{tn:M,tp:N}:{tn:B,tp:D}})}return h}function cb(i){let r=i.graph,e=r.getVertexCount(),t={},n={},o,s,a;for(o=0;o<e;o++){let l=r.getVertexAt(o);for(t[l.id]||(t[l.id]={}),n[l.id]||(n[l.id]={}),t[l.id][l.id]=0,s=0;s<e;s++)if(o!=s){let d=r.getVertexAt(s);t[l.id][d.id]||(t[l.id][d.id]=1/0),n[l.id][d.id]||(n[l.id][d.id]=[])}let h=l.getEdges();for(a=0;a<h.length;a++)h[a].source==l?t[l.id][h[a].target.id]=h[a].getCost():(t[h[a].source.id]||(t[h[a].source.id]={},n[h[a].source.id]={}),t[l.id][h[a].source.id]=h[a].getCost())}for(a=0;a<e;a++)for(o=0;o<e;o++)for(s=0;s<e;s++)if(o!=s&&s!=a&&o!=a){let l=r.getVertexAt(o).id,h=r.getVertexAt(s).id,d=r.getVertexAt(a).id;t[l][d]+t[d][h]<=t[l][h]&&t[l][d]+t[d][h]!=1/0&&(t[l][h]=t[l][d]+t[d][h],n[l][h]||(n[l][h]=[]),n[l][h].unshift([r.getVertexAt(a),t[l][h]]))}return{paths:t,parents:n}}var Dc=class{constructor(r){c(this,"vertices");c(this,"q");this.vertices=[r],this.q=new Set}addVertex(r){this.vertices.push(r),r.getAllEdges().forEach(e=>this.q.add(e))}get edges(){return Array.from(this.q)}};var PL=[null,[1,-1],[1,1],[-1,1],[-1,-1]],OL=[null,[-1,-1],[-1,1],[1,1],[1,-1]],vi=2*Math.PI;function Ci(i,r){return{x:i.x+r.x,y:i.y+r.y}}function pb(i,r){return{x:i.x-r.x,y:i.y-r.y}}function Nr(i,r){return r.x===i.x?r.y>i.y?1/0:-1/0:r.y===i.y?r.x>i.x?0:-0:(r.y-i.y)/(r.x-i.x)}function mb(i,r){return-1/Nr(i,r)}function Be(i,r){return Math.sqrt(Math.pow(r.y-i.y,2)+Math.pow(r.x-i.x,2))}function WV(i,r){return Math.abs(r.y-i.y)+Math.abs(r.x-i.x)}function Os(i,r){return r.x>i.x||r.x==i.x?r.y>i.y?2:1:r.y>i.y?3:4}function gb(i,r){let e=Nr(i,r),t=Math.atan(e),n=Os(i,r);return(n==4||n==3)&&(t+=Math.PI),t<0&&(t+=2*Math.PI),t}function ke(i,r){let e=i.x,t=i.x+i.width,n=i.y,o=i.y+i.height,s=r.x,a=r.x+r.width,l=r.y,h=r.y+r.height;return e<=s&&s<=t&&n<=l&&l<=o||e<=a&&a<=t&&n<=l&&l<=o||e<=s&&s<=t&&n<=h&&h<=o||e<=a&&s<=t&&n<=h&&h<=o||s<=e&&e<=a&&l<=n&&n<=h||s<=t&&t<=a&&l<=n&&n<=h||s<=e&&e<=a&&l<=o&&o<=h||s<=t&&e<=a&&l<=o&&o<=h}function kg(i,r){let e=Math.max(0,Math.min(i.x+i.width,r.x+r.width)-Math.max(i.x,r.x)),t=Math.max(0,Math.min(i.y+i.height,r.y+r.height)-Math.max(i.y,r.y));return e*t}function db(i){let r=i[1].y-i[0].y,e=i[0].x-i[1].x;return{A:r,B:e,C:Nc(r*i[0].x+e*i[0].y)}}function Nc(i,r){return r=r==null?3:r,Math.floor(i*Math.pow(10,r))/Math.pow(10,r)}function Wg(i,r){let e=db(i),t=db(r),n=e.A*t.B-t.A*e.B;if(n==0)return null;{let o={x:Math.round((t.B*e.C-e.B*t.C)/n),y:Math.round((e.A*t.C-t.A*e.C)/n)},s=Math.floor(Math.min(i[0].x,i[1].x)),a=Math.round(Math.max(i[0].x,i[1].x)),l=Math.floor(Math.min(i[0].y,i[1].y)),h=Math.round(Math.max(i[0].y,i[1].y)),d=Math.floor(Math.min(r[0].x,r[1].x)),u=Math.round(Math.max(r[0].x,r[1].x)),p=Math.floor(Math.min(r[0].y,r[1].y)),m=Math.round(Math.max(r[0].y,r[1].y));return o.x>=s&&o.x<=a&&o.y>=l&&o.y<=h&&o.x>=d&&o.x<=u&&o.y>=p&&o.y<=m?o:null}}function cr(i,r){let e=[];return[[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y}],[{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height}],[{x:r.x,y:r.y},{x:r.x,y:r.y+r.height}],[{x:r.x,y:r.y+r.height},{x:r.x+r.width,y:r.y+r.height}]].forEach(n=>{let o=Wg(i,n);o!=null&&e.push(o)}),e}function Eb(i,r){return _s(r,i[0],!0)||_s(r,i[1],!0)||cr(i,r).length>0}function ZV(i,r,e){let t=i.x,n=i.x+i.width,o=i.y,s=i.y+i.height,a=r.x,l=r.x+r.width,h=r.y,d=r.y+r.height,u=(p,m,g,E)=>e?p<=m&&g>=E:p<m&&g>E;return u(t,a,n,l)&&u(o,h,s,d)}function _s(i,r,e){return e?i.x<=r.x&&i.x+i.width>=r.x&&i.y<=r.y&&i.y+i.height>=r.y:i.x<r.x&&i.x+i.width>r.x&&i.y<r.y&&i.y+i.height>r.y}function zt(i,r,e){let t=Nr(i,r),n=Os(i,r),o=e>0?PL[n]:OL[n],s=Math.atan(t),a=Math.abs(e*Math.sin(s))*o[1],l=Math.abs(e*Math.cos(s))*o[0];return{x:i.x+l,y:i.y+a}}function rr(i,r,e){let t=Nr(i,r),n=Math.atan(-1/t),o=e/2*Math.sin(n),s=e/2*Math.cos(n);return[{x:r.x+s,y:r.y+o},{x:r.x-s,y:r.y-o}]}function JV(i,r,e){let t={x:(i.x+r.x)/2,y:(i.y+r.y)/2},n=Nr(i,r),o=Math.atan(-1/n),s=e/2*Math.sin(o),a=e/2*Math.cos(o);return[{x:t.x,y:t.y},{x:t.x-a,y:t.y-s}]}function se(i,r,e,t){e=e==null?r.thresholdX==null?r.width/2:r.thresholdX:e,t=t==null?r.thresholdY==null?r.height/2:r.thresholdY:t;let n=Math.floor(i.x/r.width),o=r.width*n,s=o+r.width,a=Math.abs(i.x-o)<=e?o:Math.abs(s-i.x)<=e?s:i.x,l=Math.floor(i.y/r.height),h=r.height*l,d=h+r.height,u=Math.abs(i.y-h)<=t?h:Math.abs(d-i.y)<=t?d:i.y;return{x:a,y:u}}function KV(i,r){let e=Math.floor(i.x/r.width),t=r.width*e,n=t+r.width,o=Math.floor(i.y/r.height),s=r.height*o,a=s+r.height;return{x:n,y:a}}function _L(i,r,e,t){let n=Math.max(i,r);i=Math.min(i,r),r=n;let o=Math.max(e,t);return e=Math.min(e,t),t=o,i<=e&&e<=r&&i<=t&&t<=r?{point1:e,point2:t}:i<=e&&e<=r&&t>=r?{point1:e,point2:r}:e<=i&&i<=t&&t<=r?{point1:i,point2:t}:i===e&&r===t||r===e&&i===t?{point1:i,point2:r}:e<=i&&i<=t&&e<=r&&r<=t?{point1:i,point2:r}:null}function Zg(i,r,e,t,n=0){let o=_L(i,r,e,t);return o==null?!1:Math.abs(o.point2-o.point1)>n}function fb(i,r,e){let t=i.x-r,n=i.y-e,o=i.width+2*r,s=i.height+2*e,a=Object.assign({},i);return Object.assign(a,{x:t,y:n,width:o,height:s})}function yb(i,r){let e=i[0].x,t=i[1].x,n=i[0].y,o=i[1].y,s=r[0].x,a=r[1].x,l=r[0].y,h=r[1].y;if(e===t&&n===o||s===a&&l===h)return null;let d=(h-l)*(t-e)-(a-s)*(o-n);if(d===0)return null;let u=((a-s)*(n-l)-(h-l)*(e-s))/d,p=e+u*(t-e),m=n+u*(o-n);return{x:p,y:m}}function ub(i,r){if(i[0].x===i[1].x){let e=i[0].y<i[1].y?1:-1;return[{x:i[0].x+e*r,y:i[0].y},{x:i[0].x+e*r,y:i[1].y}]}else if(i[0].y===i[1].y){let e=i[0].x<i[1].x?1:-1;return[{y:i[0].y+e*r,x:i[0].x},{y:i[0].y+e*r,x:i[1].x}]}else{let e=Nr(i[0],i[1]),t=Math.atan(-1/e),n=length/2*Math.sin(t),o=length/2*Math.cos(t);return[{x:i[0].x+o,y:i[0].y+n},{x:i[1].x+o,y:i[1].y+n}]}}function xb(i,r){return[ub(i,r),ub(i,-r)]}function qV(i,r,e){if(i[0].x===i[1].x){let t=i[0].y<i[1].y?1:-1;return[r,{x:r.x,y:r.y+t*e}]}else if(i[0].y===i[1].y){let t=i[0].x<i[1].x?1:-1;return[r,{x:r.x+t*e,y:r.y}]}else{let t=Nr(i[0],i[1]),n=Math.atan(-1/t),o=e*Math.sin(n),s=e*Math.cos(n);return[r,{x:r.x+s,y:r.y+o}]}}var Ic=(i,r,e,t)=>Math.abs(e-i)+Math.abs(t-r),QV=(i,r,e,t)=>Math.pow(Math.pow(e-i,2)+Math.pow(t-r,2),.5),eG=(i,r,e,t)=>Math.max(Math.abs(e-i),Math.abs(t-r)),tG=(i,r,e,t)=>{let n=Math.abs(e-i),o=Math.abs(t-r),s=Math.SQRT2-1;return n<o?s*n+o:s*o+n};var RL=!0;function U(...i){if(RL&&typeof console!="undefined")try{let r=arguments[arguments.length-1];console.log(r)}catch(r){}}function Ab(i,r){let e=i.prototype;for(;e!=null;){if(e instanceof r)return!0;e=e.prototype}return!1}function Jg(i,r){let e=i.indexOf(r);return e>-1&&i.splice(e,1),e!==-1}function dG(i,r,e){i.findIndex(e)===-1&&i.push(r)}function Sb(i,r,e,t){let n=i[r];return n==null&&(n=[],i[r]=n),n[t?"unshift":"push"](e),n}function uG(i,r,e,t){let n=i.get(r);return n==null&&(n=[],i.set(r,n)),n[t?"unshift":"push"](e),n}function Kg(i,r,e){return i.indexOf(r)===-1?(e?i.unshift(r):i.push(r),!0):!1}function qg(i,r){let e=null;return i.forEach(t=>{r(t)&&(e=t)}),e}function Lt(i,r){let e=i.findIndex(r);return e>-1&&i.splice(e,1),e!==-1}function xt(i,r,e){let t={x:i.x-r.x,y:i.y-r.y},n=Math.cos(e/360*Math.PI*2),o=Math.sin(e/360*Math.PI*2);return{x:t.x*n-t.y*o+r.x,y:t.y*n+t.x*o+r.y,cr:n,sr:o}}function bt(i){if(i==null)return null;let r=i.replace(/^\s\s*/,""),e=/\s/,t=r.length;for(;e.test(r.charAt(--t)););return r.slice(0,t+1)}function Qg(i,r,e,t){if(r.length===0)r.push(i);else{let n=t?-1:1,o=0,s=r.length,a=Math.floor((o+s)/2);for(;s>o;)e(i,r[a])*n<0?s=a:o=a+1,a=Math.floor((o+s)/2);r.splice(a,0,i)}}function Pi(){return{xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0}}function nr(i){return{x:i.x,y:i.y}}function Ls(i){return{width:i.width,height:i.height}}function pG(i){return{x:i.x,y:i.y,width:i.width,height:i.height}}function eE(i,r,e){return{x:i.x+e*r.x,y:i.y+e*r.y,width:i.width,height:i.height}}var Gt=[];for(let i=0;i<256;i++)Gt[i]=(i<16?"0":"")+i.toString(16);function V(){let i=Math.random()*4294967295|0,r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0;return Gt[i&255]+Gt[i>>8&255]+Gt[i>>16&255]+Gt[i>>24&255]+"-"+Gt[r&255]+Gt[r>>8&255]+"-"+Gt[r>>16&15|64]+Gt[r>>24&255]+"-"+Gt[e&63|128]+Gt[e>>8&255]+"-"+Gt[e>>16&255]+Gt[e>>24&255]+Gt[t&255]+Gt[t>>8&255]+Gt[t>>16&255]+Gt[t>>24&255]}function tE(i=6){return V().substring(0,i-1)}function LL(i){return[{x:i.x+i.width/2,y:i.y},{x:i.x+i.width,y:i.y+i.height/2},{x:i.x+i.width/2,y:i.y+i.height},{x:i.x,y:i.y+i.height/2}]}function Tb(i,r){let e=LL(r).map(t=>({p:t,d:Be(t,i)}));return e.sort((t,n)=>Math.sign(t.d-n.d)),e[0].p}function Oe(i,r,e){if(i==null)return null;if(r==="$data"||r==null)return i;let t=r.match(/^\{(.*)\}$/);if(t){let a={},l=t[1].split(",");for(let h=0;h<l.length;h++){let d=l[h].split(":"),u=Oe(i,d[1]);a[bt(d[0])]=u||d[1].replace(/'/g,"")}return a}r=r.replace(/\['([^']*)'\]/g,".$1");let n=i,o=n,s=null;return r.replace(/([^\.])+/g,(a,l,h,d)=>{if(s!=null)return;let u=a.match(/([^\[0-9]+){1}(\[)([0-9+])/),p=h+a.length>=d.length,m=function(){return o[u[1]]||function(){return o[u[1]]=[],o[u[1]]}()};if(p)if(u){let g=m(),E=u[3];e==null?s=g[E]:g[E]=e}else e==null?s=o[a]:o[a]=e;else if(u){let g=m();o=g[u[3]]||function(){return g[u[3]]={},g[u[3]]}()}else o=o[a]||function(){return o[a]={},o[a]}()}),s}function ml(i,r){let e={left:[],right:[]};for(let t=0;t<i.length;t++){let n=i[t];r(n)?e.left.push(n):e.right.push(n)}return e}function vb(i){return i.filter(r=>r!=null&&bt(r).length>0)}function Cb(i,r){for(let e=0;e<i.length;e++){let t=i[e];t==null||t.length===0||r(e,t)}}function Vc(i,r,e){let t=e.map((n,o)=>{let[s,a]=[r.x+r.width*n.x,r.y+r.height*n.y],l=Math.sqrt(Math.pow(i.x-s,2)+Math.pow(i.y-a,2));return{p:n,idx:o,distance:l}});return t.sort((n,o)=>n.distance<o.distance?-1:1),t[0]}function ws(i,r,e){return i.has(r)||i.set(r,e()),i.get(r)}function Ds(i,r,e){return i[r]==null&&(i[r]=e()),i[r]}function Mc(i){return Object.prototype.toString.call(i)==="[object Number]"}function z(i){return typeof i=="string"}function xo(i){return typeof i=="boolean"}function dr(i){return i==null?!1:Object.prototype.toString.call(i)==="[object Object]"}function wL(i){return Object.prototype.toString.call(i)==="[object Date]"}function vr(i){return Object.prototype.toString.call(i)==="[object Function]"}function mG(i){return vr(i)&&i.name!=null&&i.name.length>0}function gl(i){for(let r in i)if(i.hasOwnProperty(r))return!1;return!0}function El(i,r){if(i==null&&r==null)return!0;if(i==null&&r!=null)return!1;if(i!=null&&r==null)return!1;for(let e in i){let t=i[e],n=r[e];if(!bb(t,n))return!1}return!0}function gG(i){let r={};for(let e in i)i[e]!=null&&(r[e]=i[e]);return r}function ot(i){if(z(i))return""+i;if(xo(i))return!!i;if(wL(i))return new Date(i.getTime());if(vr(i))return i;if(Array.isArray(i))return i.map(r=>ot(r));if(dr(i)){let r={};for(let e in i)r[e]=ot(i[e]);return r}else return i}function fn(i,r,e,t){let n={},o,s,a={};for(e=e||[],t=t||[],s=0;s<e.length;s++)n[e[s]]=!0;for(s=0;s<t.length;s++)a[t[s]]=!0;let l=ot(i);for(s in r)if(l[s]==null||a[s])l[s]=r[s];else if(n[s])o=[],o.push.apply(o,Array.isArray(l[s])?l[s]:[l[s]]),o.push(r[s]),l[s]=o;else if(z(r[s])||xo(r[s])||vr(r[s])||Mc(r[s]))l[s]=r[s];else if(Array.isArray(r[s]))o=[],Array.isArray(l[s])&&o.push.apply(o,l[s]),o.push.apply(o,r[s]),l[s]=o;else if(dr(r[s])){dr(l[s])||(l[s]={});for(let h in r[s])l[s][h]=r[s][h]}return l}function bb(i,r){if(i!=null&&r==null)return!1;if((i==null||z(i)||xo(i)||Mc(i))&&i!==r)return!1;if(Array.isArray(i))if(Array.isArray(r)){if(!DL(i,r))return!1}else return!1;else if(dr(i))if(dr(i)){if(!El(i,r))return!1}else return!1;return!0}function DL(i,r){if(i==null&&r==null)return!0;if(i==null&&r!=null)return!1;if(i!=null&&r==null||i.length!==r.length)return!1;for(let e=0;e<i.length;e++)if(!bb(i[e],r[e]))return!1;return!0}function Pb(i,r){return i.x===r.x&&i.y===r.y}function Ob(i,r){let e=i.slice(),t={x:e[0],y:e[1],cr:0,sr:0};return r.forEach(n=>{t=xt(t,n.c,n.r)}),t}function _b(i,r){return r.forEach(e=>{i=xt(i,e.c,e.r)}),i}function rE(i,r,e){if(i==null)return;let t=i,n=t;return r.replace(/([^\.])+/g,(o,s,a,l)=>{let h=o.match(/([^\[0-9]+){1}(\[)([0-9+])/),d=a+o.length>=l.length,u=function(){return n[h[1]]||function(){return n[h[1]]=[],n[h[1]]}()};if(d)h?u()[h[3]]=e:n[o]=e;else if(h){let p=u();n=p[h[3]]||function(){return p[h[3]]={},p[h[3]]}()}else n=n[o]||function(){return n[o]={},n[o]}();return""}),i}function bo(i,r,e,t){let n=s=>{let a=s.match(/(\${.*?})/g);if(a!=null)for(let l=0;l<a.length;l++){let h=r[a[l].substring(2,a[l].length-1)]||"";h!=null&&(s=s.replace(a[l],h))}if(a=s.match(/({{.*?}})/g),a!=null)for(let l=0;l<a.length;l++){let h=r[a[l].substring(2,a[l].length-2)]||"";h!=null&&(s=s.replace(a[l],h))}return s},o=s=>{if(s!=null){if(z(s))return n(s);if(vr(s)&&!t&&(e==null||(s.name||"").indexOf(e)===0))return s(r);if(Array.isArray(s)){let a=[];for(let l=0;l<s.length;l++)a.push(o(s[l]));return a}else if(dr(s)){let a={};for(let l in s)a[l]=o(s[l]);return a}else return s}};return o(i)}var Rs=class{constructor(r,...e){this.sorter=r;c(this,"stack");this.stack=e.slice(),this.stack.sort(this.sorter)}get length(){return this.stack.length}add(r){Qg(r,this.stack,this.sorter,!0)}update(r){this.delete(r),this.add(r)}pop(){return this.stack.pop()}delete(r){let e=this.stack.indexOf(r);e>-1&&this.stack.splice(e,1)}head(){return this.stack.length===0?null:this.stack[0]}peek(){return this.stack.length===0?null:this.stack[this.stack.length-1]}isEmpty(){return this.stack.length===0}clear(){this.stack.length=0}};function nE(i){return H(i)?i.getParent().id:i.getFullId()}function Zn(i){return H(i)?i.getParent():i}function CG(i){return H(i)?i.id:null}function K(i){return i!=null&&i.objectType===de.objectType}function iE(i){return K(i)&&i.group!=null}function Y(i){return i!=null&&i.objectType===le.objectType}function oE(i){return Y(i)&&i.group!=null}function Ke(i){return i!=null&&i.objectType===Fe.objectType}function H(i){return i!=null&&i.objectType===me.objectType}function wb(i){return i.objectType===de.objectType||i.objectType===le.objectType}function Oi(i){return K(i)||Y(i)||H(i)}function sE(i){return i.id}var NL=".";function fl(i,r){if(r==null)return i.edges;{let e=[];for(let t=0;t<i.edges.length;t++)r(i.edges[t])&&e.push(i.edges[t]);return e}}function IL(i,r){let e=fl(i,r).slice(0);if(K(i)||Y(i))for(let t=0;t<i.ports.length;t++)e.push.apply(e,fl(i.ports[t],r));return e}function Rb(i){return fl(i,r=>r.source==i)}function Lb(i){return fl(i,r=>r.target==i)}function PG(i){let r=Rb(i).slice(0);if(K(i)||Y(i))for(let e=0;e<i.ports.length;e++)r.push.apply(r,Rb(i.ports[e]));return r}function OG(i){let r=Lb(i).slice(0);if(K(i)||Y(i))for(let e=0;e<i.ports.length;e++)r.push.apply(r,Lb(i.ports[e]));return r}function aE(i,r,e,t){let n=new Set,o=(a,l)=>{let h=l.source===a||l.target===a;return h?t?t(l):h:!1},s=a=>{a.members.forEach(l=>{let h=o.bind(null,l);(e?IL(l,h):fl(l,h)).forEach(u=>n.add(u)),!r&&Y(l)&&s(l)})};return s(i),Array.from(n)}function zc(i){let r=0,e=i.group;for(;e!=null;)r++,e=e.group;return r}function yn(i){let r=Zn(i),e=[],t=r.group;for(;t!=null;)e.push(t),t=t.group;return e}function We(i,r){return i==null||r==null?!1:yn(i).indexOf(r)!==-1}function Db(i,r){let e=!1,t=n=>{for(let o=0;o<n.members.length;o++)if(Y(n.members[o]))if(n.members[o].id===i.id){e=!0;break}else t(n.members[o])};return t(r),e}function Ns(i){let r=[],e=t=>{t.members.forEach(n=>{r.push(n),Y(n)&&e(n)})};return e(i),r}function _G(i,r){let t=!(K(i)||Y(i))||r?i.getSourceEdges():i.getAllSourceEdges();return Array.from(new Set(t.map(n=>n.target)))}function RG(i,r){let t=!(K(i)||Y(i))||r?i.getTargetEdges():i.getAllTargetEdges();return Array.from(new Set(t.map(n=>n.source)))}function LG(i,r){let e=new Set,t=K(i)||Y(i),n=!t||r?i.getSourceEdges():i.getAllSourceEdges(),o=!t||r?i.getTargetEdges():i.getAllTargetEdges();return n.forEach(s=>e.add(s.target)),o.forEach(s=>e.add(s.source)),Array.from(e)}function Nb(i,r){return i.getSourceEdges().find(e=>e.target===r)!=null||i.getTargetEdges().find(e=>e.source==r)!=null}var xl=class{constructor(r){c(this,"nodes",[]);c(this,"id");c(this,"edges",[]);c(this,"groups",[]);c(this,"Le",new Map);c(this,"_r",new Map);c(this,"Fe",new Map);c(this,"defaultDirected");c(this,"defaultCost");c(this,"zt");c(this,"typeFunction");c(this,"enableSubgraphs");c(this,"portSeparator");c(this,"Ro",{});r=r||{},this.nodes=[],this.edges=[],this.groups=[],this.id=r.id,this.defaultDirected=r.defaultDirected!==!1,this.defaultCost=r.defaultCost||1,this.zt=r.defaultIdFunction||sE,this.typeFunction=r.typeFunction||function(e){return e.type||"default"},this.enableSubgraphs=r.enableSubgraphs===!0,this.portSeparator=r.portSeparator||NL}Qs(r){delete this.Ro[r.id]}ea(r){this.Ro[r.id]=r}mg(){this.Ro={}}getIdFunction(){return this.zt}setIdFunction(r){this.zt=r}setTypeFunction(r){this.typeFunction=r}getType(r){return this.typeFunction(r)}getId(r,e){return r==null?V():typeof r=="string"?r:(e||this.getIdFunction())(r)||V()}getTopLevelElements(){return this.Ro}setEnableSubgraphs(r){this.enableSubgraphs=r}setPortSeparator(r){this.portSeparator=r}getPortSeparator(){return this.portSeparator}splitPortId(r){return r!=null?r.split(this.portSeparator):[]}getVertexByPortId(r){let e=this.splitPortId(r);if(e.length===2)return this.Le.get(e[0])||this.Fe.get(e[0])}getVertex(r,e){if(r==null)return null;let t;if(typeof r!="string"){if(r.constructor===me||r.constructor===de||r.constructor===le)return r;let s=r;if(t=this.zt(r),typeof t!="string")return s}t=r;let n=this.enableSubgraphs?t.split("/"):[t],o=s=>{if(this.Le.has(s))return this.Le.get(s);if(this.Fe.has(s))return this.Fe.get(s);let a=s.split(this.portSeparator),l=a[0],h=this.Le.get(l)||this.Fe.get(l);if(a.length===2&&h!=null){let d=h.getPort(a[1]);return d==null&&e&&(d=h.$addPort(a[1])),d}else return h};if(n.length==1)return o(n[0]);if(n.length>1&&n.length%2==0)throw"Subgraph path format error.";{let s=null,a=null;for(let l=0;l<n.length-1;l+=2)s=o(n[l]),a=s.getGraph(n[l+1]);return a.getVertex(n[n.length-1])}}clear(){this.nodes.length=0,this.groups.length=0,this.Le.clear(),this._r.clear(),this.Fe.clear(),this.mg()}getVertices(){return this.nodes}getVertexCount(){return this.nodes.length}getVertexAt(r){return this.nodes[r]}getEdgeCount(){return this._r.size}addEdge(r,e,t){let n=r.directed==null?this.defaultDirected===!0:r.directed!==!1,o=r.cost||this.defaultCost,s=this.getVertex(r.source,!0),a=this.getVertex(r.target,!0);if(e=e||this.getId(r.data,t),s==null||s.objectType==null)throw new TypeError("Unknown source node ["+r.source+"]");if(a==null||a.objectType==null)throw new TypeError("Unknown target node ["+r.target+"]");let l=new Fe({source:s,target:a,cost:o,directed:n,data:r.data||{},id:e,graph:this,transient:r.transient,anchors:r.anchors});return l.source.$addEdge(l),l.source!==l.target&&l.target.$addEdge(l),this._r.set(e,l),r.geometry!=null&&(l.geometry=r.geometry),l}addNode(r,e){let t=new de(this,r||{},e||this.zt);return this.Le.has(t.id)?null:(this.nodes.push(t),this.Le.set(t.id,t),this.ea(t),t)}addNodes(r,e){for(let t=0;t<r.length;t++)this.addNode(r[t],e||this.zt)}addGroup(r,e){let t=new le(this,r,e||this.zt);return this.Fe.has(t.id)?this.Fe.get(t.id):(this.groups.push(t),this.Fe.set(t.id,t),this.ea(t),t)}getGroupCount(){return this.groups.length}getGroupAt(r){return this.groups[r]}getGroups(){return this.groups}$addMemberToGroup(r,e){let t=typeof e=="string"?this.Fe.get(e):e,n=this.getVertex(r);n&&t&&(t.$addMember(n),this.Qs(n))}$addMembersToGroup(r,e){for(let t=0;t<r.length;t++)this.$addMemberToGroup(r[t],e)}$removeMemberFromGroup(r){let e=this.getVertex(r);e&&e.group&&(e.group.$removeMember(e),this.ea(e))}$removeMembersFromGroup(r){for(let e=0;e<r.length;e++)this.$removeMemberFromGroup(r[e])}getGroup(r){return typeof r=="string"?this.Fe.get(r):r}deleteGroup(r,e){let t={group:typeof r=="string"?this.Fe.get(r):r,edges:[],nodes:[],nestedGroups:[],children:[]};if(t.group){t.parentGroup=t.group.group,t.children=t.group.members.slice();let n;if(e){let{left:l,right:h}=ml(t.group.getMembers(),d=>Y(d));l.forEach(d=>{t.nestedGroups.push(this.deleteGroup(d,!0))}),h.forEach(d=>{t.nodes.push(this.deleteNode(d))})}else t.group.getMembers().forEach(l=>delete l.group);t.group.members.length=0,t.edges=t.group.getAllDirectEdges().slice();let o=t.edges.length;for(n=0;n<o;n++)this.deleteEdge(t.edges[n]);let s=t.group.getPorts();for(let l=0;l<s.length;l++)this.deletePort(s[l]);this.Fe.delete(t.group.id);let a=-1;for(let l=0;l<this.groups.length;l++)if(this.groups[l].id===t.group.id){a=l;break}a>-1&&this.groups.splice(a,1),t.group.group!=null&&t.group.group.$removeMember(r),this.Qs(t.group)}return t}deletePort(r){let e=r.getEdges();for(let t=0;t<e.length;t++)this.deleteEdge(e[t]);return e}$_removeNodeFromCache(r){let e=-1;for(let t=0;t<this.nodes.length;t++)if(this.nodes[t].id===r.id){e=t;break}e>-1&&(this.nodes.splice(e,1),r.group!=null&&r.group.$removeMember(r)),this.Le.delete(r.id)}deleteNode(r){let e=this.getVertex(r),t={node:null,edges:[],parentGroup:null};if(e){t.node=e,t.parentGroup=e.group;let n=e.getPorts();for(let s=0;s<n.length;s++)this.deletePort(n[s]);let o=e;this.$_removeNodeFromCache(o),t.edges=e.getEdges().slice();for(let s=0;s<t.edges.length;s++)this.deleteEdge(t.edges[s]);this.Qs(e)}return t}deleteEdge(r){if(r=this.getEdge(r),r==null)return;let e=this.getVertex(r.source,!1);e&&e.$deleteEdge(r);let t=this.getVertex(r.target,!1);t&&t.$deleteEdge(r),this._r.delete(r.getId())}getEdge(r){if(r!=null){if(typeof r!="string"){if(r.constructor===Fe)return r;let e=r;if(r=this.zt(r),typeof r!="string")return e}return this._r.get(r)}}getEdges(r){r=r||{};let e=r.source!=null,t=r.target!=null,n=r.node?this.getVertex(r.node):null,o=r.filter||function(){return!0},s=d=>(!e||(r.source===!0?d.source===n:d.source!==n))&&(!t||(r.target===!0?d.target===n:d.target!==n)),a=[],l=d=>{o(d)&&s(d)&&a.push(d)},h;if(r.node){let u=this.getVertex(r.node).getAllEdges();for(h=0;h<u.length;h++)l(u[h])}else this._r.forEach((d,u)=>l(d));return a}getAllEdges(){let r=[];return this._r.forEach((e,t)=>r.push(e)),r}renamePort(r,e){return r.getParent().$renamePort(r,e)?(r.id=e,!0):!1}findPath(r,e,t,n,o){let s=this.getVertex(r),a=this.getVertex(e);return wc({graph:this,source:s,target:a,strict:t!==!1,nodeFilter:n,edgeFilter:o})}getDistance(r,e,t){return this.findPath(r,e,t).pathDistance}setTarget(r,e){let t=this.getVertex(e);if(t==null)return{success:!1};let n=r.target;return r.target.$deleteEdge(r),r.target=t,t.$addEdge(r),{old:n,edge:r,new:t,success:!0}}setSource(r,e){let t=this.getVertex(e);if(t==null)return{success:!1};let n=r.source;return r.source.$deleteEdge(r),r.source=t,t.$addEdge(r),{old:n,edge:r,new:t,success:!0}}printPath(r,e){let t=this.getVertex(r),n=this.getVertex(e),o=this.findPath(t,n).path,s="["+t.id+" - "+n.id+"] : ";for(let a=0;a<o.length;a++)s=s+"{ vertex:"+o[a].vertex.id+", cost:"+o[a].cost+", edge: "+(o[a].edge&&o[a].edge.getId())+" } ";return s}getDiameter(r){let e=0;for(let t=0;t<this.nodes.length;t++)for(let n=0;n<this.nodes.length;n++)if(n!=t){let o=wc({graph:this,source:this.nodes[t],target:this.nodes[n]});if(o.path==null||o.path.length==0){if(!r)return 1/0}else e=Math.max(e,o.pathDistance)}return e}getCentrality(r){let e=this.getVertex(r);return(e.getIndegreeCentrality()+e.getOutdegreeCentrality())/(this.getVertexCount()-1)}getIndegreeCentrality(r){return this.getVertex(r).getIndegreeCentrality()/(this.getVertexCount()-1)}getOutdegreeCentrality(r){return this.getVertex(r).getOutdegreeCentrality()/(this.getVertexCount()-1)}getCloseness(r){return 1/this.getFarness(r)}getFarness(r){let e=this.getVertex(r),t=wc({graph:this,source:e,target:e,processAll:!0}),n=0;for(let o in t.dist)n+=t.dist[o];return n/(this.getVertexCount()-1)}getBetweenness(r){let e=this.getVertexCount(),t=(e-1)*(e-2)/2,n=0,o=0,s=(h,d,u,p,m)=>{let g=u.parents[h][d];if(g.length==0){let E=p.slice();E.unshift(h),m.push(E)}else for(let E=0;E<g.length;E++)if(p.indexOf(g[E][0].id)==-1){let y=p.slice();y.unshift(g[E][0].id),s(h,g[E][0].id,u,y,m)}},a=this.getVertex(r),l=cb({graph:this,focus:a});for(let h in l.paths)for(let d in l.paths[h])if(h!=d){let u=[],p=0;s(h,d,l,[d],u);for(let m=0;m<u.length;m++){let g=u[m].indexOf(a.id);g>0&&g<u[m].length-1&&p++}n+=p/u.length,o+=p}return n/t}inspect(){let r="";for(let e=0;e<this.nodes.length;e++)r+=this.nodes[e].inspect()+`
2
2
  `;return r}serialize(){let r={nodes:[],edges:[],groups:[]},e,t,n;for(let o=0;o<this.nodes.length;o++)if(e=this.nodes[o],!e.transient){r.nodes.push(Object.assign({},e.data)),t=e.getAllEdges();for(let s=0;s<t.length;s++)if(t[s].source==e||t[s].source.objectType===me.objectType&&t[s].source.getParent()==e){let a={source:t[s].source.getFullId(),target:t[s].target.getFullId()};t[s].data&&(a.data=Object.assign({},t[s].data)),t[s].geometry&&(a.geometry=Object.assign({},t[s].geometry)),r.edges.push(a)}}for(let o=0;o<this.groups.length;o++){n=this.groups[o],r.groups.push(Object.assign({},n.data)),t=n.getEdges();for(let s=0;s<t.length;s++)if(t[s].source===n){let a={source:n.getFullId(),target:t[s].target.getFullId()};t[s].data&&(a.data=Object.assign({},t[s].data)),t[s].geometry&&(a.geometry=Object.assign({},t[s].geometry)),r.edges.push(a)}}return r}getClusters(){return this.ph(this.nodes,this.groups)}getCluster(r){let e=K(r)?[r]:[],t=Y(r)?[r]:[];return this.ph(e,t)[0]}ph(r,e){let t=[],n={},o,s=(a,l)=>{if(a==null||n[a.id])return;l==null?(l=new Dc(a),t.push(l)):l.addVertex(a),n[a.id]=!0;let h=a.getAllEdges();for(let d=0;d<h.length;d++){let u=h[d].source===a?h[d].target:h[d].source;s(u,l)}};for(o=0;o<r.length;o++)s(this.nodes[o]);for(o=0;o<e.length;o++)s(this.groups[o]);return t}},Gc=class{constructor(r,e={}){this.graph=r;this.data=e;c(this,"atts",new Map);c(this,"type");this.data=this.data||{},this.type=r.getType(this.data)}setAttribute(r,e){this.atts.set(r,e)}getAttribute(r){return this.atts.get(r)}getType(){return this.type}setType(r){this.type=r}};function yl(i){return i instanceof me?i.id:i}var $c=class extends Gc{constructor(e,t,n){super(e,t);this.graph=e;c(this,"id");c(this,"transient");c(this,"transientRenderer");c(this,"dummy");c(this,"edges",[]);c(this,"indegreeCentrality",0);c(this,"outdegreeCentrality",0);c(this,"nestedGraphs",[]);c(this,"graphs",[]);this.id=e.getId(t,n),this.data=typeof t=="string"?{id:t}:t}getIndegreeCentrality(){return this.indegreeCentrality}getOutdegreeCentrality(){return this.outdegreeCentrality}addGraph(e){return e=typeof e=="string"?new xl({id:e}):e,this.graphs.push(e),e.id||(e.id=""+this.graphs.length),e}getGraph(e){for(let t=0;t<this.graphs.length;t++)if(this.graphs[t].id===e)return this.graphs[t]}getFullId(){return this.id}getEdges(e){if(e==null||e.filter==null)return this.edges;{let t=[];for(let n=0;n<this.edges.length;n++)e.filter(this.edges[n])&&t.push(this.edges[n]);return t}}getSourceEdges(){return this.getEdges({filter:e=>e.source==this})}getTargetEdges(){return this.getEdges({filter:e=>e.target==this})}$addEdge(e){this.edges.push(e),(e.source===this||!e.isDirected())&&this.outdegreeCentrality++,(e.target===this||!e.isDirected())&&this.indegreeCentrality++}$deleteEdge(e){let t=-1;for(let n=0;n<this.edges.length;n++)if(this.edges[n].getId()===e.getId()){t=n;break}return t>-1?(this.edges.splice(t,1),(e.source===this||!e.isDirected())&&this.outdegreeCentrality--,(e.target===this||!e.isDirected())&&this.indegreeCentrality--,!0):!1}inspect(){let e="{ id:"+this.id+`, edges:[
3
3
  `;for(let t=0;t<this.edges.length;t++)e+=this.edges[t].inspect()+`
4
- `;return e+="]}",e}isChildOf(e){return!1}},Bc=class Bc extends $c{constructor(e,t,n){super(e,t,n);c(this,"objectType",Bc.objectType);c(this,"ports",[]);c(this,"group");c(this,"portMap",{});c(this,"defaultInternalCost",0);c(this,"internalEdges",{})}getAllEdges(e){let t=e==null?null:{filter:e},n=this.getEdges(t).slice(0);for(let o=0;o<this.ports.length;o++)n.push.apply(n,this.ports[o].getEdges(t));return n}getAllSourceEdges(){let e=this.getSourceEdges().slice(0);for(let t=0;t<this.ports.length;t++)e.push.apply(e,this.ports[t].getSourceEdges());return e}getAllTargetEdges(){let e=this.getTargetEdges().slice(0);for(let t=0;t<this.ports.length;t++)e.push.apply(e,this.ports[t].getTargetEdges());return e}getDirectEdges(e){return this.getEdges(e==null?null:{filter:e})}getDirectSourceEdges(){return this.getSourceEdges()}getDirectTargetEdges(){return this.getTargetEdges()}getPortEdges(e){let t=[];for(let n=0;n<this.ports.length;n++)t.push.apply(t,this.ports[n].getEdges(e==null?null:{filter:e}));return t}getPortSourceEdges(){let e=[];for(let t=0;t<this.ports.length;t++)e.push.apply(e,this.ports[t].getSourceEdges());return e}getPortTargetEdges(){let e=[];for(let t=0;t<this.ports.length;t++)e.push.apply(e,this.ports[t].getTargetEdges());return e}getIndegreeCentrality(){let e=0;for(let t=0;t<this.ports.length;t++)e+=this.ports[t].getIndegreeCentrality();return this.indegreeCentrality+e}getOutdegreeCentrality(){let e=0;for(let t=0;t<this.ports.length;t++)e+=this.ports[t].getOutdegreeCentrality();return this.outdegreeCentrality+e}getPorts(){return this.ports}$addPort(e,t){let n=this.graph.getId(e,t),o=this.getPort(n);return o==null&&(o=new me(this,e,t),this.ports.push(o),this.portMap[o.id]=o),o}$setPort(e,t){let n=this.getPort(e);return n||(n=this.$addPort({id:e})),n.data=t,n.setType(this.graph.getType(t)),n}getPort(e){return this.portMap[e]}$renamePort(e,t){return this.portMap[e.id]?(this.portMap[t]=this.portMap[e.id],delete this.portMap[e.id],!0):!1}$removePort(e){let t=!1;if(e){let n=yl(e),o=-1;for(let s=0;s<this.ports.length;s++)if(this.ports[s].id===n){o=s;break}if(o!=-1){let s=this.ports[o];this.graph.deletePort(s),this.ports.splice(o,1),t=!0}delete this.portMap[n]}return t}$setDefaultInternalCost(e){this.defaultInternalCost=e}getInternalEdge(e,t){let n=yl(e),o=yl(t),s={source:this.portMap[n],target:this.portMap[o],cost:1/0};if(s.source&&s.target){let a=this.internalEdges[n+"-"+o]||{cost:this.defaultInternalCost,directed:!1};Object.assign(s,a)}return s}$setInternalEdge(e,t,n,o){let s=yl(e),a=yl(t);return this.internalEdges[s+"-"+a]={cost:n||this.defaultInternalCost,directed:o},this.getInternalEdge(e,t)}};c(Bc,"objectType","Node");var de=Bc,Fc=class Fc extends $c{constructor(e,t,n){super(e.graph,t,n);this.parent=e;c(this,"objectType",Fc.objectType)}getParent(){return this.parent}getFullId(){return this.parent.id+this.graph.getPortSeparator()+this.id}isChildOf(e){return this.parent===e}getAllEdges(e){return this.getEdges(e==null?null:{filter:e})}};c(Fc,"objectType","Port");var me=Fc,Uc=class Uc extends de{constructor(e,t,n){super(e,t,n);c(this,"objectType",Uc.objectType);c(this,"members",[]);c(this,"Lo",{})}$addMember(e){return this.Lo[e.id]!=null?!1:(this.members.push(e),this.Lo[e.id]=e,e.group=this,!0)}getMemberCount(){return this.members.length}getMembers(){return this.members}$removeMember(e){let t=typeof e=="string"?this.Lo[e]:e;if(t){let n=this.members.indexOf(t);return n!=-1&&(this.members.splice(n,1),delete this.Lo[t.id]),t.group&&t.group.id===this.id&&delete t.group,!0}else return!1}getAllDirectEdges(e){let t=[],n,o=e==null?null:{filter:e};t.push.apply(t,this.getEdges(o).slice(0));let s=this.getPorts();for(n=0;n<s.length;n++)t.push.apply(t,s[n].getEdges(o));return t}getInternalEdges(e){let t=[],n={};for(let o=0;o<this.members.length;o++)Array.prototype.push.apply(t,this.members[o].getAllEdges(e).filter(function(s){let a=s.getId(),l=n[a]==null;return n[a]=!0,l}));return t}};c(Uc,"objectType","Group");var le=Uc,Yc=class Yc extends Gc{constructor(e){super(e.graph,e.data);c(this,"objectType",Yc.objectType);c(this,"source");c(this,"target");c(this,"cost");c(this,"directed");c(this,"id");c(this,"geometry");c(this,"transient");c(this,"anchors");this.transient=e.transient===!0,this.source=e.source,this.target=e.target,this.cost=e.cost||1,this.directed=e.directed!==!1,this.id=e.id,e.anchors&&(this.anchors=e.anchors)}getCost(){return this.cost}setCost(e){this.cost=e}getId(){return this.id==null?this.source.id+"_"+this.target.id:this.id}getFullId(){return this.getId()}setId(e){this.id=e}isDirected(){return this.directed}setDirected(e){this.directed=e}inspect(){if(this.id!=null)return"{ id:"+this.id+", cost:"+this.cost+", directed:"+this.directed+", source:"+this.source.id+", target:"+this.target.id+"}"}};c(Yc,"objectType","Edge");var Fe=Yc;var Ib="undoRedo",Ao="userActivity",bl="api",Al="dataLoad",Mb="transient",Vb="copyPaste";var ML=(i,r,e)=>{let t=i.nodes||[],n=i.edges||[],o=i.groups||[],s=new Map,a=new Map,l=new Map,h=r.getGroups().map(p=>p.id),d=p=>{let m=l.get(p);m!=null&&m.forEach(g=>{h.push(r.addGroup(g).id)}),l.delete(p),m!=null&&m.forEach(g=>{d(g.id)})};for(let p=0;p<o.length;p++){let m=o[p];if(e.groupDecorator&&e.groupDecorator(m),m.group!=null&&h.indexOf(m.group)===-1)ws(l,m.group,()=>[]).push(m);else{let g=r.addGroup(m);a.set(g.id,m),h.push(g.id),d(g.id)}}l.forEach((p,m)=>{if(h.indexOf(m)===-1)throw new Error("Parent group ["+m+"] not found");p.forEach(g=>h.push(r.addGroup(g).id))});for(let p=0;p<t.length;p++){e.nodeDecorator&&e.nodeDecorator(t[p]);let m=r.addNode(t[p]);s.set(m.id,t[p])}function u(p){return z(p)?s.get(p)||a.get(p)||{}:{}}for(let p=0;p<n.length;p++){let m=n[p].data||{},g={source:n[p].source,target:n[p].target,cost:n[p].cost||1,directed:n[p].directed,data:m};if(e.edgeDecorator){let E=u(n[p].source),y=u(n[p].target);e.edgeDecorator(m,E,y)}n[p].anchors&&(g.anchors=n[p].anchors),n[p].geometry&&(g.geometry=n[p].geometry),r.$_addEdge(g,Al,null)}},VL=(i,r)=>{let e=i.getGraph(),t={nodes:[],edges:[],groups:[]},n,o,s;for(let a=0;a<e.nodes.length;a++){n=e.nodes[a];let l=n.transient;if(!l){let h=Object.assign({},n.data);n.group==null&&delete h.group,t.nodes.push(h)}o=n.getAllEdges();for(let h=0;h<o.length;h++){let d=o[h],u={},p=!1;(d.source===n||d.source.objectType===me.objectType&&d.source.getParent()==n)&&(d.source.dummy?(p=!0,u.source={x:d.source.data[i.modelLeftAttribute],y:d.source.data[i.modelTopAttribute]}):u.source=d.source.getFullId(),d.target.dummy?(p=!0,u.target={x:d.target.data[i.modelLeftAttribute],y:d.target.data[i.modelTopAttribute]}):u.target=d.target.getFullId(),(!l||p)&&(d.data&&(u.data=Object.assign({},d.data)),d.geometry&&(u.geometry=Object.assign({},d.geometry)),t.edges.push(u)))}}for(let a=0;a<e.groups.length;a++){s=e.groups[a];let l=Object.assign({},s.data);s.group==null&&delete l.group,t.groups.push(l),o=s.getEdges();for(let h=0;h<o.length;h++)if(o[h].source===s||o[h].source.objectType===me.objectType&&o[h].source.getParent()==s){let d={source:s.getFullId()};o[h].target.dummy?d.target={x:o[h].target.data[i.modelLeftAttribute],y:o[h].target.data[i.modelTopAttribute]}:d.target=o[h].target.getFullId(),o[h].data&&(d.data=Object.assign({},o[h].data)),o[h].geometry&&(d.geometry=Object.assign({},o[h].geometry)),t.edges.push(d)}}return t},GL=(i,r,e)=>{let t=n=>{let o=r.addNode(n);if(n.children)for(let s=0;s<n.children.length;s++){let a=r.addNode(n.children[s]);r.$_addEdge({source:o,target:a},Al,null),t(n.children[s])}};t(i)},Xt="json",lE="hierarchical-json",Gb={[Xt]:VL},$b={[Xt]:ML,[lE]:GL};function Bb(i,r){$b[i]=r}function h$(i,r){Gb[i]=r}function Fb(i,r,e,t){let n=$b[i];if(n==null)throw new Error("VisuallyJs - parse - ["+i+"] is an unsupported type");return n(r,e,t)}function hE(i,r,e){let t=Gb[i];if(t===null)throw new Error("VisuallyJs - exportData - ["+i+"] is an unsupported type");return t(r,e)}var cE=class{constructor(){c(this,"Ue",{});c(this,"ta",!1);c(this,"ra",!1);c(this,"gg",{ready:!0});c(this,"mh",[])}fire(r,e,t){return this.fireUnchecked(r,e,t)}fireUnchecked(r,e,t){let n=null;if(this.ra)this.mh.unshift(arguments);else{if(this.ra=!0,!this.ta&&this.Ue[r]){let o=this.Ue[r].length,s=0,a=!1;if(!this.shouldFireEvent||this.shouldFireEvent(r,e,t))for(;!a&&s<o&&n!==!1;){if(this.gg[r])this.Ue[r][s](e,t);else try{n=this.Ue[r][s](e,t)}catch(l){U("VisuallyJs: fire failed for event "+r+" : "+(l.message||l))}s++,(this.Ue==null||this.Ue[r]==null)&&(a=!0)}}this.ra=!1,this.Eg()}return n}Eg(){let r=this.mh.pop();r&&this.fire.apply(this,r)}unbind(r,e){if(arguments.length===0)this.Ue={};else if(arguments.length===1){if(typeof r=="string")delete this.Ue[r];else if(r.Wn){let t;for(let n in r.Wn)t=r.Wn[n],Jg(this.Ue[t]||[],r)}}else arguments.length===2&&Jg(this.Ue[r]||[],e);return this}getListener(r){return this.Ue[r]||[]}isSuspendEvents(){return this.ta}setSuspendEvents(r){this.ta=r}bind(r,e,t){return this.bindUnchecked(r,e,t)}bindAll(r,e,t){return r.forEach(n=>this.bind(n,e,t)),this}bindUnchecked(r,e,t){return(o=>{Sb(this.Ue,o,e,t),e.Wn=e.Wn||{},e.Wn[V()]=o})(r),this}silently(r){this.setSuspendEvents(!0);try{r()}catch(e){U("Cannot execute silent function "+e)}this.setSuspendEvents(!1)}},$t=class extends cE{shouldFireEvent(r,e,t){return!0}};var Sl=class{constructor(r,e){this.instance=r;c(this,"result");c(this,"gh",[]);c(this,"qr",{});this.result=r.getGraph().findPath(e.source,e.target,e.strict,e.nodeFilter,e.edgeFilter);for(let t=0;t<this.result.path.length;t++)this.gh.push(this.result.path[t].vertex),this.qr[this.result.path[t].vertex.getFullId()]=[this.result.path[t].vertex,t]}deleteEdges(){for(let r=0;r<this.result.path.length;r++)this.result.path[r].edge&&this.instance.removeEdge(this.result.path[r].edge);return this}deleteVertices(){for(let r=0;r<this.result.path.length;r++)this.instance.removeNode(this.result.path[r].vertex);return this}contains(r,e){let t=this.instance.findGraphObject(r),n=!1;if(t){for(let o=0;o<this.result.path.length;o++)if(this.result.path[o].vertex==t||this.result.path[o].edge==t||!e&&this.result.path[o].vertex.objectType==me.objectType&&this.result.path[o].vertex.isChildOf(t)){n=!0;break}}return n}getVertices(){return this.gh}getVertex(r){return this.qr[typeof r=="string"?r:r.id][0]}getAllEdgesFor(r){let e=this.qr[r.id][1];return e<this.result.path.length-1?[this.result.path[e+1].edge]:[]}filter(r,e){U("not implemented.")}ze(r,e){for(let t=e||0;t<this.result.path.length;t++)try{r(t,this.result.path[t])}catch(n){U("Path iterator function failed",n)}}each(r){this.ze((e,t)=>{r(e,t)})}eachVertex(r){this.ze((e,t)=>{r(e,t.vertex)})}eachEdge(r){this.ze((e,t)=>{r(e,t.edge)},1)}eachNode(r){this.ze((e,t)=>{K(t.vertex)&&r(e,t.vertex)})}eachGroup(r){this.ze((e,t)=>{Y(t.vertex)&&r(e,t.vertex)})}getVertexCount(){return this.result.path.length}getNodeAt(r){return this.result.path[r].vertex}getEdgeCount(){return this.result.path.length==0?0:this.result.path.length-1}getEdgeAt(r){return r<0&&(r=this.result.path.length-1+r),this.result.path.length>r+1?this.result.path[r+1].edge:null}deleteAll(){this.deleteVertices()}isEmpty(){return this.result.path.length==0}getCost(){return this.result.pathDistance}exists(){return this.result.pathDistance!=null}};var Xc=class{constructor(r,e){c(this,"Eh",new Map);c(this,"fh",new Map);c(this,"yh",new Map);if(e!=null){let t=e.nodes||{};for(let s in t)this.Eh.set(s,t[s]);let n=e.groups||{};for(let s in n)this.fh.set(s,n[s]);let o=e.ports||{};for(let s in o)this.yh.set(s,o[s])}}getNodeDefinition(r){return this.Eh.get(r)||{}}getGroupDefinition(r){return this.fh.get(r)||{}}getPortDefinition(r){return this.yh.get(r)||{}}};var xn=class i{constructor(r){c(this,"instance");c(this,"adapter");c(this,"$vertices",[]);c(this,"parameters");c(this,"done");c(this,"width");c(this,"height");c(this,"container");c(this,"containerSize");c(this,"padding");c(this,"xShift");c(this,"yShift");c(this,"Zn");this.Zn=r.options.locationFunction,this.adapter=r.adapter,this.instance=r.instance,this.container=r.container,this.containerSize=this.adapter.getSize(this.container),this.width=r.options.width||this.containerSize.width,this.height=r.options.height||this.containerSize.height,this.padding=r.options.padding,this.done=!1,this.parameters=r.options||{}}Jn(){this.done=!1,this.$vertices.length=0,this.reset()}static fg(){return{padding:{x:0,y:0}}}yg(){let r=Object.assign(i.fg(),this.getDefaultParameters()||{});return Object.assign(r,this.parameters||{}),this.parameters=r,this.parameters}getSize(r,e){return Ds(e,r,()=>{let t=this.adapter.getViewportPositionById(r);return t!=null?{width:t.width,height:t.height}:{width:0,height:0}})}xg(r,e,t,n,o){t=t||10,n=n||10;let s=Math.floor(Math.random()*t),a=Math.floor(Math.random()*n);return{x:s,y:a}}xh(r){if(this.instance==null)return;this.containerSize=this.adapter.getSize(this.container),this.width=this.containerSize.width,this.height=this.containerSize.height;let e=this.yg();this.$vertices=this.adapter.getElements().slice();let t={},n={},o=1/0,s=1/0,a=-1/0,l=-1/0,h=(p,m,g)=>{let E=n[p]||{width:0,height:0};o=Math.min(o,m),s=Math.min(s,g),a=Math.max(a,m+E.width),l=Math.max(l,g+E.height),t[p]={x:m,y:g}},d=p=>t[p];this.$vertices.forEach(p=>this.getSize(p.id,n)),this.begin(this.instance,d,h,n,e);let u=()=>{let p={};this.$vertices.forEach(m=>p[m.id]=t[m.id]),this.end(this.instance,d,h,n,e),r&&r({positions:p,bounds:{xmin:o,ymin:s,xmax:a,ymax:l},sizes:n,layout:this})};for(;!this.done;)this.step(this.instance,d,h,n,e);u()}relayout(r,e){this.Jn(),r!=null&&(this.parameters=r),this.xh(e)}layout(r){this.done=!1,this.xh(r)}};var jc=class{};var Ub={},qe={get:(i,r)=>{let e=Ub[i];if(e)return r.options=r.options||{},new e(r);throw{message:"VisuallyJs: unknown layout type '"+i+"'"}},register:(i,r)=>{Ub[i]=r}};var Hc=class Hc extends xn{constructor(e){super(e);c(this,"type",Hc.type)}getDefaultParameters(){return{}}reset(){}begin(e,t,n,o,s){this.$vertices.forEach(a=>n(a.id,0,0))}end(e,t,n,o,s){}step(e,t,n,o,s){this.done=!0}};c(Hc,"type","Empty");var Is=Hc;qe.register(Is.type,Is);function $L(i){return{x:i.data.left,y:i.data.top}}var Jn=class extends xn{constructor(e){super(e);c(this,"bh");c(this,"absoluteBacked");this.absoluteBacked=e.options.absoluteBacked===!0,this.bh=e.options.locationFunction}$_findLocation(e,t){return(t!=null&&t.locationFunction?t.locationFunction:this.bh||$L)(e)}begin(e,t,n,o,s){let a=this.adapter.getElements(),l=a.length;for(let h=0;h<l;h++){let d=a[h],u=d.getFullId(),p=t(u);p==null&&(p=this.$_findLocation(d,s),isNaN(p.x)&&(p.x=0),isNaN(p.y)&&(p.y=0)),n(u,p.x,p.y)}}step(e,t,n,o,s){this.done=!0}end(e,t,n,o,s){}reset(){}getAbsolutePosition(e,t){return e==null?{x:null,y:null}:this.$_findLocation(e,t)}},BL="Absolute",kc=class kc extends Jn{constructor(e){super(e);c(this,"type",kc.type)}getDefaultParameters(){return{}}};c(kc,"type",BL);var So=kc;qe.register(So.type,So);function FL(i,r,e,t){return i[r]<=t&&t<=i[r]+i[e]}var Wc=[(i,r)=>i.x+i.width-r.x,(i,r)=>i.x-(r.x+r.width)],Zc=[(i,r)=>i.y+i.height-r.y,(i,r)=>i.y-(r.y+r.height)],Yb=[null,[Wc[0],Zc[1]],[Wc[0],Zc[0]],[Wc[1],Zc[0]],[Wc[1],Zc[1]]],UL=(i,r,e,t,n)=>{isNaN(e)&&(e=0);let o=r.y+r.height,s=e==1/0||e==-1/0?r.x+r.width/2:(o-t)/e,a=Math.atan(e),l,h,d;return FL(r,"x","width",s)?(l=Yb[n][1](i,r),h=l/Math.sin(a),d=h*Math.cos(a),{x:d,y:l}):(d=Yb[n][0](i,r),h=d/Math.cos(a),l=h*Math.sin(a),{x:d,y:l})};function _i(i,r){let e=i.center||{x:i.x+i.width/2,y:i.y+i.height/2},t=r.center||{x:r.x+r.width/2,y:r.y+r.height/2},n=Nr(e,t),o=Os(e,t),s=n==1/0||n==-1/0||isNaN(n)?0:e.y-n*e.x;return UL(i,r,n,s,o)}function Kn(i,r,e){let t=r.width+2*e.x,n=r.height+2*e.y;return{x:i.x-t/2,y:i.y-n/2,width:t,height:n}}function zb(i){let r=[];if(i==null)return null;if(Array.isArray(i)){let e=[];return e.push.apply(e,i),e}else for(let e in i)r.push(i[e]);return r}var YL={x:20,y:20},zL=1/0;function Xb(i,r){let e={x:i.x,y:i.y};if(r!=null){let t=se(i,r);i.x=t.x,i.y=t.y,i.center!=null&&(i.center.x=i.x+i.width/2,i.center.y=i.y+i.height/2)}return{moved:e.x!==i.x||e.y!==i.y,pos:i}}var Ri=class{constructor(r){c(this,"we");c(this,"$");c(this,"na");c(this,"ht");c(this,"Ah");c(this,"Rr",null);c(this,"Qr");c(this,"F");c(this,"en");c(this,"Sh");c(this,"U",[]);c(this,"ne",new Map);c(this,"wo",new Map);c(this,"rn",new Map);c(this,"nn",new Set);c(this,"Do",!1);c(this,"Th");c(this,"At",new Map);this.en=r.positionGetter,this.Sh=r.positionSetter,this.F=r.getId,this.Qr=r.getSize,this.$=zb(r.elements||[]),this.ht=r.filter||(e=>!0),this.Ah=r.exclude||(e=>!1),this.na=r.constrain||((e,t,n)=>n)}executeAtPoint(r,e){return this.$.length>0?(this.Kn((e==null?void 0:e.getSize)||this.Qr,(e==null?void 0:e.getPosition)||this.en,e==null?void 0:e.knownLocations),this.ia(r),this.Rr=null,this.oa(e)):{original:{},current:{}}}executeAtCenter(r){if(this.$.length>0){let e=this.Kn((r==null?void 0:r.getSize)||this.Qr,(r==null?void 0:r.getPosition)||this.en,r==null?void 0:r.knownLocations);return this.ia({x:(e.minx+e.maxx)/2,y:(e.miny+e.maxy)/2}),this.Rr=null,this.oa(r)}else return{original:{},current:{}}}executeWithFocus(r,e){return this.$.length>0?(this.Kn((e==null?void 0:e.getSize)||this.Qr,(e==null?void 0:e.getPosition)||this.en,e==null?void 0:e.knownLocations,e==null?void 0:e.knownSizes),this.Rr={id:r,bounds:this.ne.get(r),element:this.$.find(t=>t.id===r)},this.ia(this.Rr.bounds.center),this.oa(e)):{original:{},current:{}}}snapToGrid(r){let e={original:{},current:{}};this.Kn(this.Qr,this.en);for(let t=0;t<this.U.length;t++){let n=this.ne.get(this.U[t].id),{moved:o,pos:s}=Xb(this.U[t].bounds,r);o&&(e.original[this.U[t].id]=n,e.current[this.U[t].id]=s)}return this.Ch(e),e}setElements(r){return this.$=zb(r),this}startTracking(r,e,t){return this.setElements(r),this.Kn(this.Qr,this.en),this.Th=t||zL,this.rn.clear(),this.nn.clear(),this.wo.entries().forEach(n=>{this.rn.set(n[0],Object.assign({},n[1]))}),this.Do=e,this}stopTracking(){this.rn.clear(),this.nn.clear(),this.Do=!1}addElement(r,e){return r!=null&&(e||this.$.indexOf(r)===-1)&&this.$.push(r),this}addElements(r,e){if(e)Array.prototype.push.apply(this.$,r);else for(let t=0;t<r.length;t++)this.addElement(r[t]);return this}removeElement(r){let e=-1;for(let t=0;t<this.$.length;t++)if(this.$[t]===r){e=t;break}return e!==-1&&this.$.splice(e,1),this}reset(){this.$.length=0}ia(r){r!=null&&(this.we=r)}Kn(r,e,t,n){return this.U.length=0,this.ne.clear(),this.wo.clear(),this.At.clear(),this.Ag(this.$,r,e,t,n)}Ag(r,e,t,n,o){let s,a,l,h;s=a=1/0,l=h=-1/0,n=n||{},o=o||{};for(let d=0;d<r.length;d++){let u=n[r[d].id]||t(r[d]),p=o[r[d].id]||e(r[d]),m=this.F(r[d]),g={x:u.x,y:u.y,width:p.width,height:p.height,center:{x:u.x+p.width/2,y:u.y+p.height/2}};this.ne.set(m,g),this.wo.set(m,Object.assign({},g)),this.U.push({bounds:g,id:m,element:r[d]}),this.At.set(m,p),s=Math.min(s,u.x),a=Math.min(a,u.y),l=Math.max(l,u.x+p.width),h=Math.max(h,u.y+p.height)}return{minx:s,maxx:l,miny:a,maxy:h}}Sg(r,e,t,n){if(this.rn.has(r)){let o=this.rn.get(r),s=this.ne.get(r),a={x:s.x+o.width/2,y:s.y+o.height/2},l=Be(o.center,a),h=l/Math.ceil(l/10),d=Math.round(l/h)+1,u=Math.atan2(o.center.y-a.y,o.center.x-a.x);if(l>this.Th)return null;let p=null,m=0;for(let g=1;g<d;g++){let E={x:a.x+g*h*Math.cos(u),y:a.y+g*h*Math.sin(u)},y=Kn(E,o,{x:0,y:0});Xb(y,n);let x=!0;for(let f=0;f<this.U.length;f++){let b=this.U[f];if(b.id!==r&&!t(b.id,b.element)){let A=b.bounds,T=Kn(A.center,A,e);if(ke(y,T)){x=!1;break}}}if(x)m=g,p={x:E.x-o.width/2,y:E.y-o.height/2};else break}return p!=null?{moved:!0,reverted:m===d-1,positionReached:p}:null}else return null}Tg(r={},e,t,n,o){if((this.Do&&!o||!this.Do&&o)&&this.nn.size>0){let a=!1;for(;!a;){let l=!0;this.nn.forEach(h=>{let d=this.Sg(h,e,t,n);if(d!=null&&d.moved){let u=this.rn.get(h),p=d.reverted?{x:u.x,y:u.y}:d.positionReached;r[h]=p;let m=this.ne.get(h);m.x=p.x,m.y=p.y,m.center.x=p.x+u.width/2,m.center.y=p.y+u.height/2,d.reverted&&this.nn.delete(h),l=!1}}),a=l}}}oa(r){let e={};if(this.$.length>1){r=r||{};let n=r.filter||this.ht,o=r.padding||YL,s=r.iterations,a=r.exclude||this.Ah;r.gather&&Object.assign(e,this.vg(o,this.na,n,a)),Object.assign(e,this.Cg(o,this.na,n,s,a,r.grid)),this.Tg(e,o,a,r.grid,r.invertTrackbackPreference)}let t={original:{},current:{}};for(let n in e)t.original[n]=this.wo.get(n),t.current[n]=e[n],this.nn.add(n);return this.Ch(t),t}vg(r,e,t,n){let o={},s=Kn(this.we,{width:0,height:0},r);this.Oh();let a={},l=h=>{let d=[this.we,h],u=[];Array.prototype.push.apply(u,cr(d,s).map(p=>[s,p,null]));for(let p in a){let m=this.ne.get(p);Array.prototype.push.apply(u,cr(d,m).map(g=>[m,g,p]))}return u.filter(p=>p!=null)};for(let h=0;h<this.U.length;h++){if(n(this.U[h].id,this.U[h].element))continue;let d=this.U[h].bounds,u=this.U[h].bounds,p=Kn(d.center,u,r);if(t(this.U[h].id,this.U[h].element)){let m=l(d.center);if(m.length>0){m.sort((y,x)=>{let f=Be(y[1],d),b=Be(x[1],d);return f<b?-1:1});let g=m[0][0],E=_i(g,p);d.x+=E.x,d.y+=E.y,d.center.x+=E.x,d.center.y+=E.y,o[this.U[h].id]=d,a[this.U[h].id]=!0}}}return o}Cg(r,e,t,n,o,s){n=n||2;let a,l;this.Rr!=null?(a=Kn(this.we,this.Rr.bounds,{x:0,y:0}),l=this.Rr.id):a=Kn(this.we,{width:0,height:0},r),this.Oh();let h=1,d=!0,u,p,m={},g=(x,f,b,A)=>{f.x+=b,f.y+=A,f.center.x+=b,f.center.y+=A,m[x]=f},E=(x,f)=>{if(s==null)return f;{let b=Ci(x,f),A=b.x/s.width,T=b.y/s.height,S=f.x>=0?Math.ceil(A):Math.floor(A),R=f.y>=0?Math.ceil(T):Math.floor(T),v={x:s.width*S,y:s.height*R};return pb(v,x)}},y=()=>{let x,f;for(let b=0;b<this.U.length;b++){if(x=this.U[b],o(x.id,x.element))continue;let A=x.bounds,T=Kn(A.center,A,r);x.id!==l&&t(x.id,x.element)&&ke(a,T)&&(u=_i(a,T),u=E(A,u),p=e(x.id,A,u),g(x.id,A,p.x,p.y),T=Kn(A.center,A,r));for(let S=0;S<this.U.length;S++)if(b!==S){if(f=this.U[S],f.id===l||o(f.id,f.element))continue;if(t(f.id,f.element)){let R=f.bounds,v=Kn(R.center,R,r);ke(T,v)&&(d=!0,u=_i(T,v),u=E(R,u),p=e(f.id,R,u),g(f.id,R,p.x,p.y))}}}d&&h<n&&(d=!1,h++,y())};return y(),m}Ch(r){for(let e=0;e<this.$.length;e++){let t=this.F(this.$[e]);r.current[t]&&this.Sh(this.$[e],r.current[t])}}Oh(){let r={};this.U.sort((e,t)=>{let n=r[e.id]||Math.min(Be(e.bounds,this.we),Be(Ci(e.bounds,{x:e.bounds.width,y:0}),this.we),Be(Ci(e.bounds,{x:e.bounds.width,y:e.bounds.height}),this.we),Be(Ci(e.bounds,{x:0,y:e.bounds.height}),this.we)),o=r[t.id]||Math.min(Be(t.bounds,this.we),Be(Ci(t.bounds,{x:t.bounds.width,y:0}),this.we),Be(Ci(t.bounds,{x:t.bounds.width,y:t.bounds.height}),this.we),Be(Ci(t.bounds,{x:0,y:t.bounds.height}),this.we));return r[e.id]=n,r[t.id]=o,n===o?0:n<o?-1:1})}};var jb={x:30,y:30},Kc=class Kc extends xn{constructor(e){super(e);c(this,"Ph");c(this,"type",Kc.type);c(this,"padding",jb);this.Ph=e.options.centerRoot===!0,this.padding=e.options.padding||jb}getDefaultParameters(){return{padding:this.padding,locationFunction:this.Zn}}begin(e,t,n,o,s){}end(e,t,n,o,s){}reset(){}step(e,t,n,o,s){let a=this.$vertices.slice(),l=0,h=0,d,u,p=10;if(this.Ph&&a.length>0){let E=this.getSize(a[0].id,o);p=Math.max(E.width,E.height)+80,n(a[0].id,0,0),a=a.slice(1)}if(a.length===0){this.done=!0;return}let m=2*Math.PI/a.length,g=-Math.PI/2;for(d=0;d<a.length;d++)if(u=a[d],n(u.id,l+Math.sin(g)*p,h+Math.cos(g)*p),g+=m,d>0){let E=a[d-1],y=this.getSize(E.id,o),x=t(E.id),f={x:x.x-s.padding.x,y:x.y-s.padding.y,width:y.width+2*s.padding.x,height:y.height+2*s.padding.y},b=a[d],A=this.getSize(b.id,o),T=t(b.id),S={x:T.x-s.padding.x,y:T.y-s.padding.y,width:A.width+2*s.padding.x,height:A.height+2*s.padding.y},R=_i(f,S),v=[x.x+y.width/2,x.y+y.height/2],O=[T.x+R.x+A.width/2,T.y+R.y+ +(A.height/2)],P=Math.sqrt(Math.pow(v[0]-O[0],2)+Math.pow(v[1]-O[1],2));p=Math.max(p,P/2/Math.sin(m/2))}for(d=0;d<a.length;d++)u=a[d],n(u.id,l+Math.sin(g)*p,h+Math.cos(g)*p),g+=m;this.done=!0}};c(Kc,"type","Circular");var Jc=Kc;qe.register(Jc.type,Jc);var dE="Grid",uE="Column",pE="Row";var Te="width",De="height",xF="rotation",qc="v",Hb="h",Se="top",ze="left",ut="right",st="bottom",wt="center",Q="x",fe="y",bn="dlr",qn="drl",rn="none",nn="orthogonal",kb="manhattan",Qc="diagonal",Wb="metro",Zb=-1,he="v",ne="h",Jb="undefined",xe="default",At="true",at="false",Kb="left",qb="top",Qb="rotation",eA="width",tA="height",Qe="source",An="target";var XL={x:30,y:30},Li="row",mE="column",To=class extends xn{constructor(e){super(e);c(this,"sn",[]);c(this,"sa");c(this,"aa");c(this,"de");c(this,"an");c(this,"ln");c(this,"Lr");c(this,"wr");c(this,"type");this.type=dE,this.de=e.options.orientation||Li,this.padding=e.options.padding||XL,this.sa=e.options.verticalAlignment||wt,this.aa=e.options.horizontalAlignment||wt,this.an=e.options.rows||-1,this.ln=e.options.columns||-1}getDefaultParameters(){return{orientation:Li,rows:-1,columns:-1}}begin(e,t,n,o,s){this.sn.length=0;let a,l;if(this.an===-1&&this.ln===-1){let p=Math.round(Math.sqrt(this.$vertices.length));a=p+(this.de===Li?1:0),l=p+(this.de===mE?1:0)}else this.an!==-1?(a=this.an,l=Math.ceil(this.$vertices.length/a)):this.ln!==-1&&(l=this.ln,a=Math.ceil(this.$vertices.length/l));this.Lr=-1/0,this.wr=-1/0;let h=0,[d,u]=this.de===Li?[a,l]:[l,a];for(let p=0;p<d;p++){this.sn[p]=[];for(let m=0;m<u;m++)if(h=p*u+m,h<this.$vertices.length){let g=this.$vertices[h],E=this.getSize(g.id,o);this.Lr=Math.max(this.Lr,E.width),this.wr=Math.max(this.wr,E.height),this.sn[p][m]={vertex:g,size:E}}}}end(e,t,n,o,s){}reset(){}Og(e){let t=this.de===Li&&this.an===1||this.aa===ze?0:this.aa===wt?(this.Lr-e.width)/2:this.Lr-e.width,n=this.de===mE&&this.ln===1||this.sa===Se?0:this.sa===wt?(this.wr-e.height)/2:this.wr-e.height;return{padX:t,padY:n}}step(e,t,n,o,s){let a=0,l=0;for(let h=0;h<this.sn.length;h++){for(let d=0;d<this.sn[h].length;d++){let u=this.sn[h][d],{padX:p,padY:m}=this.Og(u.size);n(u.vertex.id,a+p,l+m),this.de===Li?a+=this.padding.x*2+(this.an===1?u.size.width:this.Lr):l+=this.padding.y*2+(this.ln===1?u.size.height:this.wr)}this.de===Li?(l+=this.padding.y*2+this.wr,a=0):(a+=this.padding.x*2+this.Lr,l=0)}this.done=!0}};c(To,"type",dE),qe.register(To.type,To);var Tl=class extends To{constructor(r){super(Object.assign(r,{options:Object.assign(r.options||{},{orientation:mE,columns:1})})),this.type=uE}};c(Tl,"type",uE),qe.register(Tl.type,Tl);var vl=class extends To{constructor(r){super(Object.assign(r,{options:Object.assign(r.options||{},{orientation:Li,rows:1})})),this.type=pE}};c(vl,"type",pE),qe.register(vl.type,vl);var td=class td extends Jn{constructor(e){super(e);c(this,"No");c(this,"type",td.type);c(this,"$",new Map);c(this,"qn",new Map);c(this,"Qn");c(this,"St");c(this,"Io",1/0);c(this,"Mo",-1/0);c(this,"Vo",1/0);c(this,"Go",-1/0);c(this,"Tt",[]);c(this,"la",new Map);c(this,"vt");c(this,"ca");this.vt=fn(this.getDefaultParameters(),e.options),this.St=e.options.absoluteBacked!==!1}getDefaultParameters(){return{iterations:15,spacing:250,r:.25,locationFunction:this.Zn}}cn(e,t,n){return t=Nc(t),n=Nc(n),e.x=t,e.y=n,e.center.x=t+e.width/2,e.center.y=n+e.height/2,{Pg:t,_g:n}}hn(e){return this.qn.get(e.id)===!0}Rg(e){this.qn.set(e.id,!0)}reset(){super.reset(),this.$.clear(),this.qn.clear(),this.No=0,this.Io=this.Vo=1/0,this.Mo=this.Go=-1/0,this.la.clear()}begin(e,t,n,o,s){this.Tt.length=0,this.$.clear(),this.No=0,this.Io=1/0,this.Mo=-1/0,this.Vo=1/0,this.Go=-1/0,this.ca=this.vt.r,this.St&&this.$vertices.forEach(a=>{let l=this.$_findLocation(a,s);l!=null&&l.x!=null&&l.y!=null&&n(a.id,l.x,l.y)})}dt(e,t,n){let o=H(e)?e.getParent():e,s=this.$.get(o.id);if(!s){let a=t(o.id)||this.xg(o.id,n,this.width,this.height,!0),l=this.getSize(o.id,n);l.width===0&&(l.width=1),l.height===0&&(l.height=1),s={id:o.id,n:o,x:a.x,y:a.y,f:[0,0],width:l.width,height:l.height,center:{x:a.x+l.width/2,y:a.y+l.height/2}},this.$.set(o.id,s),this.la.set(o.id,this.instance.getAllEdgesFor(o).filter(h=>this.adapter.filter(h.target)))}return s}ha(e,t,n){return this.Tt[e]?this.Tt[e]:(this.Tt[e]=this.dt(this.$vertices[e],t,n),this.Tt[e])}step(e,t,n,o,s){let a;for(this.Qn=0,a=0;a<this.$vertices.length;a++){let l=this.ha(a,t,o);if(this.St&&!this.hn(l)){let d=this.getAbsolutePosition(l.n,s);if(d!=null&&d.x!=null&&d.y!=null&&!isNaN(d.x)&&!isNaN(d.y)){this._h(l,d.x,d.y),n(l.id,d.x,d.y),this.Rg(l),l.x=d.x,l.y=d.y,l.f[0]=0,l.f[1]=0;continue}}for(let d=a+1;d<this.$vertices.length;d++){let u=this.ha(d,t,o);this.Lg(l,u)}let h=this.la.get(l.id);for(let d=0;d<h.length;d++)this.wg(l,h[d],t,o)}if(this.Qn!==0)for(a=0;a<this.$vertices.length;a++){let l=this.ha(a,t,o);if(!this.hn(l)){let h=l.f[0],d=l.f[1];this._h(l,l.x+h,l.y+d)}l.f[0]=0,l.f[1]=0}this.No++,(this.Qn===0||this.No>=this.vt.iterations)&&(this.Dg(n,o),this.done=!0)}end(e,t,n,o,s){this.qn.clear(),this.$.forEach((a,l)=>{this.qn.set(l,!0)})}_h(e,t,n){let{Pg:o,_g:s}=this.cn(e,t,n);this.Io=Math.min(this.Io,o),this.Vo=Math.min(this.Vo,s),this.Mo=Math.max(this.Mo,o),this.Go=Math.max(this.Go,s)}Dg(e,t){this.$.forEach((n,o)=>{let s=this.$.get(o);e(o,Math.floor(s.x),Math.floor(s.y))})}Lg(e,t){let n=this.hn(e),o=this.hn(t);if(n&&o||e.width===0||e.height===0||t.width===0||t.height===0)return;let s,a,l,h;if(ke(e,t))h=1,s=1,a=1;else{let d=[e.center,t.center],u=cr(d,e)[0],p=cr(d,t)[0];s=p.x-u.x,a=p.y-u.y,l=s*s+a*a,h=Math.sqrt(l),h==0&&(h=1,s=1,a=1)}if(h<this.vt.spacing){this.Qn++;let d=this.ca*(this.vt.spacing-h),u=1,p=1,m=u*d*s/h,g=p*d*a/h,E=o?0:(n?2:1)*m,y=o?0:(n?2:1)*g,x=n?0:(o?2:1)*m,f=n?0:(o?2:1)*g;t.f[0]+=E,t.f[1]+=y,e.f[0]-=x,e.f[1]-=f}}wg(e,t,n,o){let s=this.dt(t.target,n,o),a=this.hn(e),l=this.hn(s);if(a&&l)return;this.Qn++;let h,d,u,p,m;if(ke(e,s))p=-2*this.vt.spacing,h=-2*this.vt.spacing,d=-2*this.vt.spacing;else{let y=[e.center,s.center],x=cr(y,e)[0],f=cr(y,s)[0];h=f.x-x.x,d=f.y-x.y,u=h*h+d*d,p=Math.sqrt(u),p===0&&(p=1,h=1,d=1)}m=this.ca*(p-this.vt.spacing),(t.cost==null||t.cost<1)&&(t.cost=1),m*=Math.log(t.cost)*.5+1;let g=m*h/p,E=m*d/p;s.f[0]-=l?0:(a?2:1)*g,s.f[1]-=l?0:(a?2:1)*E,e.f[0]+=a?0:(l?2:1)*g,e.f[1]+=a?0:(l?2:1)*E}};c(td,"type","ForceDirected");var ed=td;qe.register(ed.type,ed);function jL(i,r){for(let e=0;e<i.length;e++)if(i[e].target!==r||i[e].source!==r)return!1;return!0}var Ms=class extends Jn{constructor(e){super(e);c(this,"Rh");c(this,"dn");c(this,"Lh");this.Rh=!!e.options.ignoreLoops,this.Lh=e.options.ignorePorts===!0,this.dn=e.options.getRootNode||(t=>e.options.multipleRoots!==!1?t.filter(n=>{if(wb(n)){let o=n.getTargetEdges();return(o.length===0||jL(o,n))&&this.adapter.filter(n)}else return!1}).getAll():this.$vertices.length>0?[this.$vertices[0]]:null)}begin(e,t,n,o,s){super.begin(e,t,n,o,s),s.ignoreLoops=this.Rh,s.getRootNode=this.dn,s.getChildVertices=s.getChildVertices||((a,l,h)=>{let d=[];return h.getAllEdgesFor(a).forEach(u=>{let p=H(u.target)?u.target.getParent():u.target;(u.source===a||this.Lh!==!0&&H(u.source)&&u.source.getParent()===a)&&this.adapter.filter(p)&&d.push(p)}),d}),s.rootNode=s.getRootNode(e),s.rootNode||(this.done=!0)}};var rA=wt,nA={x:60,y:60},iA="auto",oA=wt;function Cl(i){return i.parents.length>0?i.parents[0].loc:null}function rd(i,r){if(i.parents.length===0)return null;{let e=i.parents[0].size;for(let t=1;t<i.parents.length;t++)e+=r+i.parents[t].size;return e}}function HL(i){return i.parents.length>0?i.parents[0].root===!0:!1}function sA(i){return i.parents.length>0?i.parents[0].childGroup:null}function kL(i){return i.parents.length>0?i.parents[i.parents.length-1].childGroupIndex:null}var nd=class{constructor(r,e){this.dataSource=r;c(this,"Dr");c(this,"Yt");c(this,"ve");c(this,"P",[]);c(this,"Nr",[]);c(this,"ei",{});c(this,"Q");c(this,"J");c(this,"Ct");c(this,"ue");c(this,"ti");c(this,"xe");c(this,"St");c(this,"D");c(this,"un",-1/0);c(this,"pn",1/0);c(this,"ri");c(this,"Ot");c(this,"ni");c(this,"De",[]);c(this,"positions",new Map);c(this,"da",{[wt]:r=>Cl(r)+rd(r,this.J)/2-(r.size-this.J)/2,start:r=>Cl(r),end:r=>Cl(r)+rd(r,0)-(r.size-this.J)});c(this,"F");c(this,"Pt");c(this,"Xt");c(this,"ii");c(this,"fa",{center:(r,e,t)=>(e+t)/2-rd(r)/2,start:(r,e,t)=>e,end:(r,e,t)=>e});this.Dr=Array.isArray(e.rootNode)?e.rootNode:[e.rootNode],this.Yt=e.compress===!0,this.St=e.absoluteBacked===!0,this.F=e.idFunction,this.Pt=e.sizeFunction,this.Xt=e.childVerticesFunction,this.ii=e.absolutePositionFunction,this.ue=e.axisIndex,this.xe=this.ue!==1,this.ti=this.ue===0?1:0,this.ri=this.xe?"y":"x",this.Ot=this.xe?Te:De,this.ni=this.xe?De:Te,this.ve=e.invert===!0,this.D=e.alignment||oA,this.Q=e.padding,this.J=this.xe?this.Q.x:this.Q.y,this.Ct=this.xe?this.Q.y:this.Q.x}execute(){let r,e,t;for(let n=0;n<this.Dr.length;n++){r=this.Dr[n];let o=this.Pt(r.id),s=this.Qe(r,o,0,null,null),a=0;s.root=!0,a=this.oi(s,0);let l=0,h,d,u=(m,g)=>this.Yt&&m.parents&&m.parents.length>0?this.positions.get(this.F(m.parents[0].node)).position[this.ri]+this.ua(m,this.ti)+this.Ct:g,p=!1;if(a===0&&this.St===!0){let m=this.ii(r);!isNaN(m.x)&&!isNaN(m.y)&&(this.si(r.id,m,0),p=!0)}if(!p)for(e=0;e<this.P.length;e++){for(this.P[e].otherAxis=l,t=0;t<this.P[e].entries.length;t++)h=this.ue===0?this.P[e].entries[t].loc:u(this.P[e].entries[t],l),d=this.ue===1?this.P[e].entries[t].loc:u(this.P[e].entries[t],l),this.si(this.F(this.P[e].entries[t].node),{x:h,y:d},e);this.ve?e<this.P.length-1&&(this.P[e].otherAxisSize=this.De[e+1]+this.Ct,l-=this.P[e].otherAxisSize):(this.P[e].otherAxisSize=this.De[e]+this.Ct,l+=this.P[e].otherAxisSize)}}return this.positions}si(r,e,t){this.positions.set(r,{position:e,layer:t});let n=this.Pt(r),o=this.ue===0?e.x+n.width:e.y+n.height;this.un=Math.max(this.un,o),this.pn=Math.min(this.pn,o)}dt(r){let e=this.P[r];return e||(e={entries:[],pointer:0},this.P[r]=e),e}Qe(r,e,t,n,o){let s=this.dt(t),a={node:r,parents:n==null?[]:[n],childGroup:o,loc:s.pointer,index:s.entries.length,dimensions:e,size:e[this.Ot],children:[]},l=e[this.ni];return this.De[t]==null?this.De[t]=l:this.De[t]=Math.max(this.De[t],l),s.pointer+=e[this.Ot]+this.J,s.entries.push(a),n&&n.children.push(a),a}pa(r,e){let t=this.Nr[e];t||(t=[],this.Nr[e]=t),r.index=t.length,t.push(r)}ma(r,e){if(r.parents.length>0){let t=e-r.parents[0].loc;for(let s=0;s<r.parents.length;s++)r.parents[s].loc+=t;let n=r.parents[r.parents.length-1],o=this.dt(r.depth-1);o.pointer=Math.max(o.pointer,n.loc+n.size+this.J)}}ua(r,e){let t=r.parents.map(n=>n.dimensions[e===0?Te:De]);return Math.max.apply(null,t)}ga(r){if(r.size>0){let e=this.da[this.D](r),t=this.Nr[r.depth],n=this.D==="end"?1/0:-1/0,o=0;if(t!=null&&t.length>0){let d=t[t.length-1],u=d.nodes[d.nodes.length-1];n=this.D==="end"?u.loc-r.size:u.loc+u.size+this.J}this.D!=="end"&&e>=n||this.D==="end"&&e<=n?r.loc=e:(o=n-e,r.loc=n);let s=r.loc,a=this.D==="end"?r.nodes.length-1:0,l=this.D==="end"?-1:r.nodes.length,h=this.D==="end"?-1:1;for(let d=a;d!==l;d+=h)r.nodes[d].loc=s,s+=r.nodes[d].size,s+=this.J;o!==0&&this.Ea(r),this.pa(r,r.depth)}}ya(r){let e=r.nodes[0].loc,t=r.nodes[r.nodes.length-1].loc+r.nodes[r.nodes.length-1].size,n=this.fa[this.D](r,e,t),o=n-Cl(r);if(this.ma(r,n),!HL(r)){let s=sA(r),a=kL(r);for(let l=a+1;l<s.nodes.length;l++)s.nodes[l].loc+=o}}Ea(r){let e=r;for(;e!=null;)this.ya(e),e=sA(e)}oi(r,e){if(this.ei[r.node.id])return;this.ei[r.node.id]=!0;let t={nodes:[],loc:0,size:0,parents:[r],depth:e+1,children:[]},n=[],o,s={},a=this.dt(e+1),l=this.Xt(r.node,e,this.dataSource);for(o=0;o<l.length;o++){let h=l[o];if(h!=null&&h!==r.node&&!s[h.id]){let d=this.Pt(this.F(h)),u=a.entries.find(p=>this.F(p.node)===this.F(h));if(u!=null){u.parents.push(r);let p=Cl(u),m=rd(u,this.J),g=p+m/2-u.size/2,E=g-u.loc,y=x=>{for(let f=x.childGroupIndex;f<x.childGroup.nodes.length;f++)x.childGroup.nodes[f].loc+=E,x.children.forEach(y),x.childGroup.size+=E};y(u)}else{let p=this.Qe(h,d,e+1,r,t);p.childGroupIndex=t.nodes.length,t.nodes.push(p);let m=d[this.Ot];t.size+=m+this.J,n.push(p)}s[h.id]=!0}}for(this.ga(t),o=0;o<n.length;o++)this.oi(n[o],e+1);return l.length}};var WL="Hierarchical",od=class od extends Ms{constructor(e){super(e);c(this,"type",od.type);c(this,"de");c(this,"xe");c(this,"ue");c(this,"Yt");c(this,"ve");c(this,"D");c(this,"Dh");c(this,"P",[]);c(this,"Xt");this.ve=e.options.invert,this.Dh=e.options.spacing||iA,this.Yt=this.Dh==="compress",this.D=e.options.align||rA,this.de=e.options.orientation!=null?e.options.orientation:"horizontal"}getDefaultParameters(){return{padding:nA,orientation:this.de,locationFunction:this.Zn,align:this.D}}begin(e,t,n,o,s){super.begin(e,t,n,o,s),this.de=s.orientation,this.xe=this.de==="horizontal",this.ue=this.xe?0:1,this.padding=s.padding,this.P.length=0,this.Xt=s.getChildVertices}step(e,t,n,o,s){new nd(e,{rootNode:s.rootNode,compress:this.Yt,padding:this.padding,axisIndex:this.ue,invert:this.ve,alignment:this.D,idFunction:h=>e.getNodeId(h),sizeFunction:h=>this.getSize(h,o),childVerticesFunction:(h,d,u)=>this.Xt(h,d,u),absoluteBacked:this.absoluteBacked,absolutePositionFunction:h=>this.getAbsolutePosition(h,s)}).execute().forEach((h,d)=>{n(d,h.position.x,h.position.y)}),this.done=!0}getHierarchy(){return this.P}getOrientation(){return this.de}};c(od,"type",WL);var id=od;qe.register(id.type,id);var gE=class{constructor(r){this.focus=r;c(this,"id");c(this,"children",new Set);c(this,"ne",new Map);c(this,"Nh",new Map);c(this,"group");c(this,"extents");c(this,"offsets");this.id=V(),this.group=[r]}setPosition(r,e,t){this.ne.set(r,{x:e,y:t})}getPosition(r){return this.ne.get(r)}getIncidentAngle(r){return this.Nh.get(r)}setIncidentAngle(r,e){this.Nh.set(r,e)}getPositions(){return this.ne}},ZL=100,JL={x:50,y:50},ad=class ad extends Ms{constructor(e){super(e);c(this,"type",ad.type);c(this,"Ih");c(this,"et",[]);c(this,"clusterMagnetizer");c(this,"groupPadding");this.groupPadding=e.options.groupPadding||ZL,this.padding=e.options.padding||JL,this.clusterMagnetizer=new Ri({positionGetter:t=>({x:t.extents[0],y:t.extents[2]}),positionSetter:(t,n)=>{for(let o=0;o<t.group.length;o++){let s=t.offsets[t.group[o].id];t.setPosition(t.group[o].id,n.x+s.x,n.y+s.y)}},getSize:t=>({width:t.extents[1]-t.extents[0],height:t.extents[3]-t.extents[2]}),getId:t=>t.focus.id,filter:t=>this.et[0].focus.id!==t})}getDefaultParameters(){return{padding:this.padding,locationFunction:this.Zn,groupPadding:this.groupPadding,getChildEdges:(e,t,n)=>n.getAllEdgesFor(e,o=>{let s=H(o.source)?o.source.getParent():o.source,a=H(o.target)?o.target.getParent():o.target;return s===e&&s!==a&&this.adapter.filter(a)})}}begin(e,t,n,o,s){super.begin(e,t,n,o,s),this.et.length=0,this.Ih=s.getChildEdges}Mh(e,t,n,o,s,a,l){let h=(T,S,R,v)=>({x:T-a.padding.x,y:S-a.padding.y,width:R+2*a.padding.x,height:v+2*a.padding.y}),d,u=new gE(e),p=s?s.position:{x:0,y:0},m=p.x,g=p.y,E={},y=T=>E[T]||(E[T]=this.getSize(T,o),E[T]),x,f,b;u.setPosition(e.id,p.x,p.y);let A=this.Ih(e,l,this.instance);for(let T=0;T<A.length;T++){let S=A[T].target,R=H(S)?S.getParent():S;u.children.add(R)}if(x=y(u.focus.id),d=Math.max(x.width,x.height),b=h(m-x.width/2,g-x.height/2,x.width,x.height),n(u.focus.id,-(x.width/2),-(x.height/2)),u.children.size>0){this.et.push(u);let T=2*Math.PI/(u.children.size+(s?1:0)),S=s?s.incidentAngle+Math.PI+T:Math.PI,R=S,v=null;u.children.forEach(D=>{f=y(D.id);let M=h(m+Math.sin(S)*f.width,g+Math.cos(S)*f.height,f.width,f.height),N=_i(b,M),G=Math.sqrt(Math.pow(M.x+N.x-m,2)+Math.pow(M.y+N.y-g,2));if(d=Math.max(d,G),u.setPosition(D.id,M.x+N.x,M.y+N.y),S+=T,v!=null){let J=y(v.id),Ee=u.getPosition(v.id),j=h(Ee.x,Ee.y,J.width,J.height),pe=y(D.id),Me=u.getPosition(D.id),Ye=h(Me.x,Me.y,pe.width,pe.height),Mt=_i(j,Ye),tr={x:Ee.x+J.width/2,y:Ee.y+J.height/2},Yt={x:Me.x+Mt.x+pe.width/2,y:Me.y+Mt.y+ +(pe.height/2)},Tr=Math.sqrt(Math.pow(tr.x-Yt.x,2)+Math.pow(tr.y-Yt.y,2));d=Math.max(d,Tr/2/Math.sin(T/2))}v=D}),S=R,u.children.forEach(D=>{u.setIncidentAngle(D.id,S),u.setPosition(D.id,m+Math.sin(S)*d,g+Math.cos(S)*d),S+=T});let O=u.getPosition(e.id),P=O.x,I=y(e.id),C=P+I.width,_=O.y,w=_+I.height,B;u.children.forEach(D=>{if(!this.Mh(D,t,n,o,{parent:e,incidentAngle:u.getIncidentAngle(D.id),position:u.getPosition(D.id)},a,l+1)){B=y(D.id),u.group.push(D);let N=u.getPosition(D.id);P=Math.min(P,N.x),C=Math.max(C,N.x+B.width),_=Math.min(_,N.y),w=Math.max(w,N.y+B.height)}}),u.extents=[P,C,_,w],u.offsets={};for(let D=0;D<u.group.length;D++){let M=u.group[D],N=u.getPosition(M.id);u.offsets[M.id]={x:N.x-u.extents[0],y:N.y-u.extents[2]}}}return u.children.size}step(e,t,n,o,s){if(s.rootNode&&s.rootNode.length>0){if(this.Mh(s.rootNode[0],t,n,o,null,s,0),this.et.length>0){let a=(this.et[0].extents[0]+this.et[0].extents[1])/2,l=(this.et[0].extents[2]+this.et[0].extents[3])/2;this.clusterMagnetizer.setElements(this.et),this.clusterMagnetizer.executeAtPoint({x:a,y:l},{padding:{x:100,y:100}})}for(let a=0;a<this.et.length;a++)this.et[a].getPositions().forEach((h,d)=>{n(d,h.x,h.y)})}this.done=!0}};c(ad,"type","Balloon");var sd=ad;qe.register(sd.type,sd);var Vs=class{constructor(r){this.model=r}};var Cr="edge",vo="vertex",ld="center",EE=30;function lt(i){return i.type===Cr}function eY(i){return i.type===vo}var hd=class extends Vs{constructor(e,t){super(e);this.vertexSet=t;c(this,"jt",new Map);c(this,"$o",!1);c(this,"kt");c(this,"Ir",[]);c(this,"Vh",new Set);c(this,"ai");this.ai=e.layout.ai}Ng(e){let t=this.model.getAdjacentVertices(e);return t.vertices.filter(n=>this.jt.has(n.id)==!1).filter(n=>t.target.findIndex(o=>o.id===n.id)!==-1?t.source.findIndex(o=>o.id===n.id)===-1:!1).length}Gh(e,t){let n=this.model.getAdjacentVertices(e.id),o=n.vertices;Array.from(n.filteredEdges).forEach(h=>this.Vh.add(h));let s=[],a,l;for(a=0;a<o.length;a++)if(!this.jt.has(o[a].id))if(l=this.model.getVertex(o[a].id),l!=null)if(this.Ng(o[a].id)===0){let d=t+1,u=this.model.getAdjacentVertices(o[a].id).target.filter(p=>this.jt.has(p.id));if(u.length>0){let p=Math.max(...u.map(m=>this.vertexSet.findLayerIndex(m.id)));d=Math.max(d,p+1)}this.vertexSet.addToLayer(d,l),s.push(l),o[a].edges.forEach(p=>{let m={edge:p,id:p.id,sourceNode:e,targetNode:l,rootLayer:-1,targetLayer:-1,span:-1,type:Cr,entries:[]};this.vertexSet.edgeNodes.push(m),this.vertexSet.edgeNodeMap.set(p.id,m)})}else o[a].edges.forEach(d=>{let u={edge:d,id:d.id,sourceNode:e,targetNode:l,rootLayer:-1,targetLayer:-1,span:-1/0,type:Cr,entries:[]};this.vertexSet.edgeNodes.push(u),this.vertexSet.edgeNodeMap.set(d.id,u),this.Ir.push([l,t+1,u])});else this.model.excludedNodes[o[a].id]=!0;for(a=0;a<s.length;a++)this.jt.set(s[a].id,!0),this.Gh(s[a],t+1)}Ig(){let e,t=(o,s)=>o.span>s.span?-1:o.span<s.span?1:o.rootLayer<s.rootLayer?-1:o.rootLayer>s.rootLayer?1:0,n=[];this.vertexSet.edgeNodes.forEach(o=>{o.rootLayer=this.model.getLayer(o.sourceNode),o.targetLayer=this.model.getLayer(o.targetNode),o.rootLayer!=null&&o.targetLayer!=null&&(o.span=o.targetLayer-o.rootLayer,o.span>1&&(n.length===0?n.push(o):t(o,n[0])<=0?n.unshift(o):n.push(o)))});for(let o=0;o<n.length;o++){let s=n[o];if(s.span>1){let l=this.vertexSet.layers[s.rootLayer].entries.filter(u=>!lt(u)),h=l.findIndex(u=>u.obj.id===s.sourceNode.id),d=l.length===1?!1:h<l.length/2;e=this.vertexSet.insertEdgeNodeInLayer(s.rootLayer+1,s,d),this.vertexSet.edgeEntryMap.set(e.id,e);for(let u=s.rootLayer+2;u<s.targetLayer;u++){let p=this.vertexSet.addToLayer(u,s,d);this.vertexSet.edgeEntryMap.set(p.id,p),p.previous=e,e.next=p,e=p}}}}execute(e){for(this.jt.clear(),this.$o=!1,this.kt=0,this.Ir.length=0,this.jt.set(e.id,!0);!this.$o;)if(this.Gh(e,this.kt),this.Ir.length>0)if(this.Ir=this.Ir.filter(t=>!this.jt.has(t[0].id)),this.Ir.length>0){let t=this.Ir.splice(0,1)[0];e=t[0],this.kt=t[1],this.jt.set(e.id,!0),this.vertexSet.addToLayer(this.kt,e)}else this.$o=!0;else this.$o=!0;this.ai&&this.Mg(),this.Ig()}Mg(){let e=this.vertexSet.layers.length-1;if(!(e<=0))for(let t=0;t<e;t++)this.vertexSet.layers[t].entries.filter(s=>!lt(s)&&s.leaf).forEach(s=>{this.vertexSet.removeFromLayer(t,s),this.vertexSet.addToLayer(e,s)})}getFilteredEdges(){return Array.from(this.Vh)}};var fE=i=>{let r=0;for(let e=0;e<i.length;e++){let t=i[e];t.length>0&&t[0].leaf&&r++,t.length>1&&t[t.length-1].leaf&&r++}return r};function KL(i){let r=0;return i.forEach(e=>r+=e[1]),r/i.length}var Gs=class{constructor(r,e,t){this.vertexSet=r;this.getAdjacentEntries=e;c(this,"li");c(this,"ci");t=t||{},this.li=t.maxIterations||24,this.ci=t.maxIterationsWithoutImprovement||5}Vg(){let r=[];for(let e=0;e<this.vertexSet.layers.length;e++)r.push(this.vertexSet.layers[e].entries.slice());return r}execute(){let r=this.Vg(),e=r,t=0,n=this.$h(r),o=fE(e);for(let s=0;s<this.li;s++){let a=this.Gg(s,e),l=this.$h(a);if(l.total<n.total)n=l,t=0,o=fE(a);else if(l.total===n.total){let h=fE(a);h>o&&(n=l,t=0,o=h)}else t++;if(e=a,n.total===0||t>=this.ci)break}this.vertexSet.layers.forEach((s,a)=>{s.entries=n.ordering[a]})}$h(r){let e=0,t=[],n;for(let o=r.length-2;o>-1;o--)n=this.$g(o,r,o+1),t[o]=n,e+=n.length;return{total:e,layers:t,ordering:r}}$g(r,e,t){let n=[],o=e[r],s=e[t],a=new Array(s.length);for(let u=0;u<a.length;u++)a[u]=[];let l=[],h,d=[];for(h=0;h<o.length;h++){let u=o[h],p=h,m=this.getAdjacentEntries(e,t,u),g=[];for(let E=0;E<m.length;E++){let y=m[E][1];g.push(y)}g.sort(function(E,y){return E-y}),l[p]=g}for(h=0;h<l.length;h++)d=d.concat(l[h].map(u=>[h,u]));for(h=0;h<d.length;h++){let u=d[h],p={sourceLayer:r,targetLayer:t,sourceVertex:u[0],targetVertex:u[1]};a[u[1]].push(p);for(let m=u[1]+1;m<a.length;m++)n.push(...a[m])}return n}Gg(r,e){let t=[],n;if(r%2===0){for(n=e.length-1;n>0;n--)t[n]=this.Bh(n,e,!1);t[0]=e[0].slice()}else{for(n=0;n<e.length-1;n++)t[n]=this.Bh(n,e,!0);t[e.length-1]=e[e.length-1].slice()}return t}Bh(r,e,t){let n=e[r],o=n.length,s=[],a=t?r+1:r-1,l={},h;if(o===1)return n;for(h=0;h<o;h++){let d=n[h],u=this.getAdjacentEntries(e,a,d),p=u.filter(g=>!lt(g[0])),m=u.filter(g=>lt(g[0]));m.length>0&&(m.sort((g,E)=>g[0].obj.span>E[0].obj.span?-1:E[0].obj.span>g[0].obj.span?1:0),p.push(m[0])),u.length>0?s.push([d,KL(p)]):(l[d.obj.id]=!0,s.push([d,-1]))}return s.sort((d,u)=>l[d[0].id]||l[u[0].id]?0:d[1]<u[1]?-1:u[1]<d[1]?1:d[0].type===vo&&u[0].type===vo?0:d[0].type===Cr&&u[0].leaf?-1:u[0].type===Cr&&d[0].leaf?1:0),s.map(d=>d[0])}};var aA="xmax",lA="ymax",hA="xmin",cA="ymin",cd="_min",dd="_max",ud=class{constructor(r,e,t,n,o){this.R=r;this.oe=e;this.axis=t;this.ve=n;this.Bg=o;c(this,"hi",{})}execute(){this.hi={};let r=this.Bg(),e={},t=this.axis===0?{[cd]:hA,[dd]:aA}:{[cd]:cA,[dd]:lA},n=this.axis===1?{[cd]:hA,[dd]:aA}:{[cd]:cA,[dd]:lA},o=null;for(let a=0;a<this.oe.layers.length-1;a++){let l=this.oe.layers[a],h=this.oe.layers[a+1],d=Math.min(l[t.be],h[t.be]),p=Math.max(l[t._t],h[t._t])-d,m=this.ve?n.be:n._t,g=this.ve?n._t:n.be,E=l[m],x=h[g]-E,f={id:`r${a}`,type:"channel",axis:this.axis,left:this.axis===0?d:E,top:this.axis===1?d:E,width:this.axis===0?p:x,height:this.axis===1?p:x,lines:[]};this.oe.regions.push(f);for(let b=0;b<l.entries.length;b++){let A=l.entries[b],T=r.getVertexPosition(A.id)||A.loc,S={left:T.x,top:T.y,width:A.size.width,height:A.size.height,type:A.type,id:A.id,lines:[],paddingRegion:null,paddingRegionGate:null,gateDown:null,gateUp:null};this.oe.regions.push(S),this.hi[A.id]=S;let R=S;if(this.axis===0){let v=this.axis===0?S.top+S.height:S.left+S.width,O=this.axis===0?f.top:f.left;if(v<O){let P={left:this.axis===0?T.x:T.x+A.size.width,top:this.axis===0?T.y+A.size.height:T.y,width:this.axis===0?A.size.width:O-v,height:this.axis===0?O-v:A.size.height,type:A.type,id:`${A.id}_pad`,lines:[]};this.oe.regions.push(P),S.paddingRegion=P,S.paddingRegionGate=this.Bo(A,T,S,P,!0),R=P}}S.gateDown=this.Bo(A,T,R,f,!0),o!=null&&(S.gateUp=this.Bo(A,T,o,S,!1))}o=f}let s=this.oe.layers[this.oe.layers.length-1];for(let a=0;a<s.entries.length;a++){let l=s.entries[a],h=r.getVertexPosition(l.id),d={left:h.x,top:h.y,width:l.size.width,height:l.size.height,type:l.type,id:l.id,lines:[],gateUp:null};this.oe.regions.push(d),this.hi[l.id]=d,o!=null&&(d.gateUp=this.Bo(l,h,o,d,!1))}return this.oe.edgeNodes.forEach(a=>{let l=a.edge,h=H(l.source)?l.source.getParent():l.source,d=H(l.target)?l.target.getParent():l.target,u=this.R.entryMap[h.id],p=this.R.entryMap[d.id],m=this.hi[u.id],g=this.hi[p.id],E=[],y=u.layer<p.layer?1:-1;if(u.layer<p.layer){m.paddingRegionGate!=null&&E.push(m.paddingRegionGate),E.push(m.gateDown);for(let f=0;f<a.entries.length;f++){let b=a.entries[f],A=`r${b.layer-1}:${b.id}`;E.push(this.oe.gateMap[A]);let T=`${b.id}:r${b.layer}`;E.push(this.oe.gateMap[T])}E.push(g.gateUp)}else{E.push(m.gateUp);for(let f=a.entries.length-1;f>-1;f--){let b=a.entries[f],A=`${b.id}:r${b.layer}`;E.push(this.oe.gateMap[A]);let T=`r${b.layer-1}:${b.id}`;E.push(this.oe.gateMap[T])}g.paddingRegionGate!=null&&E.push(g.paddingRegionGate),E.push(g.gateDown)}let x={id:l.id,sourceId:l.source.id,targetId:l.target.id,path:E.map(f=>f.id),pathDirection:y};this.oe.edgeRoutingMap[l.id]=x,this.oe.edgeRouting.push(x),e[l.id]=E}),e}Bo(r,e,t,n,o){let s=this.axis===0?e.x:e.y,a=this.axis===0?r.size.width:r.size.height,l=this.axis===0?e.y:e.x,h=this.axis===0?r.size.height:r.size.width,d=this.ve?l+(o?0:h):l+(o?h:0);return this.Fg(t,n,this.axis,{point1:s,point2:s+a},a,d,{x:this.axis===0?s+a/2:d,y:this.axis===0?d:s+a/2})}Fg(r,e,t,n,o,s,a){let l={id:`${r.id}:${e.id}`,a:{type:r.type,id:r.id},b:{type:e.type,id:e.id},axis:t,otherAxisLocation:s,segment:n,length:o,midpoint:a,edges:[]};return this.oe.gates.push(l),this.oe.gateMap[l.id]=l,l}};function qL(i,r){let e=[],t=[],n=[],o={},s={},a={},l=i.getAllEdges(),h=[],d=new Set,u=(p,m)=>{let g=Zn(p.source),y={edge:p,isSource:g===m,sourceVertex:g,targetVertex:Zn(p.target)};return h.push(y),y};Y(i)&&i.getMembers().forEach(p=>{p.getAllEdges().forEach(m=>{(We(m.source,i)&&!We(m.target,i)||We(m.target,i)&&!We(m.source,i))&&u(m,p)})}),r!=null?l.forEach(p=>{r(p)?u(p,i):d.add(p)}):l.forEach(p=>u(p,i));for(let p=0;p<h.length;p++){let m=h[p].isSource?h[p].targetVertex.id:h[p].sourceVertex.id;o[m]||(o[m]={id:m,edges:new Set},e.push(o[m])),o[m].edges.add(h[p].edge),h[p].isSource?(s[m]||(s[m]={id:m,edges:new Set},t.push(s[m])),s[m].edges.add(h[p].edge)):(a[m]||(a[m]={id:m,edges:new Set},n.push(a[m])),a[m].edges.add(h[p].edge))}return{vertices:e,source:t,target:n,filteredEdges:d}}function QL(i){return i.target.length===1&&(i.source.length===0||i.source[0].id===i.target[0].id)}var pd=class{constructor(r,e,t){this.instance=r;this.layout=t;c(this,"Q");c(this,"qr",{});c(this,"At",{});c(this,"Fo",null);c(this,"Fh",[]);c(this,"Uh",new Map);c(this,"xa");c(this,"Ne");c(this,"di");c(this,"pi",[]);c(this,"unattachedRootPadding");c(this,"vertexEntryMap",new Map);c(this,"entryMap",{});c(this,"assignedVertices",new Map);c(this,"axis");c(this,"invert");c(this,"sets",[]);c(this,"excludedNodes",{});c(this,"zh");c(this,"adjacentVertices",{});this.Q=e.padding||{x:50,y:50},this.unattachedRootPadding=e.unattachedRootPadding,this.axis=e.axis,this.invert=e.invert===!0,this.zh=e.setPosition,this.xa=e.getSize,this.Fo=e.rootNode,this.Ne=e.edgeNodeSize,this.di=e.edgeFilter}nextRoot(){let r=this.pi.find(t=>!this.assignedVertices.has(t.id));return r?r.obj:null}getVertex(r){return this.qr[r]}setRootNode(r){this.Fo=r}getLayer(r){return this.getLayerForId(r.id)}getLayerForId(r){return this.assignedVertices.get(r)}getSize(r){return this.At[r.id]}getNodeSizeInMainAxis(r){return this.getSizeInMainAxis(this.getSize(r))}getNodeSizeInOtherAxis(r){return this.getSizeInOtherAxis(this.getSize(r))}Yh(){let r={width:50,height:50};return this.axis===0?r.width=this.Ne:r.height=this.Ne,r}getSizeInMainAxis(r){return this.axis===0?r.width:r.height}getSizeInOtherAxis(r){return this.axis===0?r.height:r.width}getPaddingInMainAxis(){return this.axis===0?this.Q.x:this.Q.y}getPaddingInOtherAxis(){return this.axis===0?this.Q.x:this.Q.y}initialize(){this.pi.length=0,this.Fh.length=0,this.Uh.clear(),this.assignedVertices.clear();let r=this.layout.$vertices.length;if(r>0){let e;for(let t=0;t<r;t++){e=this.layout.$vertices[t],this.At[e.id]=this.xa(e.id),this.qr[e.id]=e;let n=qL(e,this.di);this.adjacentVertices[e.id]=n;let o={obj:e,id:e.id,adjacent:n.vertices,sourceEdges:n.source,targetEdges:n.target,leaf:QL(n),size:this.xa(e.id),type:vo,layer:-1,vertexSet:null};this.pi.push(o),this.vertexEntryMap.set(e.id,o),n.target.length===0&&(this.Fh.push(o),this.Uh.set(e.id,o))}this.pi.sort((t,n)=>{let o=this.Fo?this.Fo.id:"";return t.obj.id===o?-1:n.obj.id===o||t.adjacent.length===0?1:n.adjacent.length===0||t.targetEdges.length<n.targetEdges.length?-1:n.targetEdges.length<t.targetEdges.length?1:t.sourceEdges.length>n.sourceEdges.length?-1:n.sourceEdges.length>t.sourceEdges.length?1:0})}}isEmpty(){return this.pi.length===0}getAdjacentEntries(r,e,t){let n=[];for(let o=0;o<r[e].length;o++)this.areConnected(r[e][o],t)&&n.push([r[e][o],o]);return n}getAdjacentEntriesInLayer(r,e){let t=[];for(let n=0;n<r.length;n++)this.areConnected(r[n],e)&&t.push({entry:r[n],index:n});return t}areConnected(r,e){return lt(r)&&r.obj.edge.source===e.obj||lt(e)&&e.obj.edge.source===r.obj||lt(r)&&r.obj.edge.target===e.obj||lt(e)&&e.obj.edge.target===r.obj||lt(r)&&lt(e)&&(r.next===e||r.previous===e||e.next===r||e.previous===r)?!0:this.areAdjacent(r.obj.id,e.obj.id)}areAdjacent(r,e){let t=this.getAdjacentVertices(r),n=this.getAdjacentVertices(e);return t!=null&&t.vertices.findIndex(o=>o.id===e)!==-1||n!=null&&n.vertices.findIndex(o=>o.id===r)!==-1}getAdjacentVertices(r){return this.adjacentVertices[r]||{vertices:[],source:[],target:[],filteredEdges:new Set}}isLeaf(r){let e=this.vertexEntryMap.get(r);return e!=null?e.leaf:!1}};function Pl(i){return i.parents.length>0?i.parents[0].loc:null}function md(i,r){if(i.parents.length===0)return null;{let e=i.parents[0].size;for(let t=1;t<i.parents.length;t++)e+=r+i.parents[t].size;return e}}function e0(i){return i.parents.length>0?i.parents[0].root===!0:!1}function dA(i){return i.parents.length>0?i.parents[0].childGroup:null}function t0(i){return i.parents.length>0?i.parents[i.parents.length-1].childGroupIndex:null}var gd=class{constructor(r,e){this.model=r;c(this,"un",-1/0);c(this,"pn",1/0);c(this,"Dr");c(this,"Yt");c(this,"ve");c(this,"P",[]);c(this,"Nr",[]);c(this,"ei",{});c(this,"Q");c(this,"J");c(this,"Ct");c(this,"ue");c(this,"ti");c(this,"xe");c(this,"St");c(this,"D");c(this,"ri");c(this,"Ot");c(this,"ni");c(this,"De",[]);c(this,"ne",new Map);c(this,"da",{center:r=>Pl(r)+md(r,this.J)/2-(r.size-this.J)/2,start:r=>Pl(r),end:r=>Pl(r)+md(r,0)-(r.size-this.J)});c(this,"F");c(this,"Pt");c(this,"Xt");c(this,"ii");c(this,"fa",{center:(r,e,t)=>(e+t)/2-md(r,0)/2,start:(r,e,t)=>e,end:(r,e,t)=>e});this.Dr=Array.isArray(e.rootNode)?e.rootNode:[e.rootNode],this.Yt=e.compress===!0,this.St=e.absoluteBacked===!0,this.F=e.idFunction,this.Pt=e.sizeFunction,this.Xt=e.childVerticesFunction,this.ii=e.absolutePositionFunction,this.ue=e.axisIndex,this.xe=this.ue!==1,this.ti=this.ue===0?1:0,this.ri=this.xe?fe:Q,this.Ot=this.xe?Te:De,this.ni=this.xe?De:Te,this.ve=e.invert===!0,this.D=e.alignment||ld,this.Q=e.padding,this.J=this.xe?this.Q.x:this.Q.y,this.Ct=this.xe?this.Q.y:this.Q.x}execute(){let r,e,t;for(let n=0;n<this.Dr.length;n++){r=this.Dr[n];let o=this.Pt(r.id),s=this.Qe(r,o,0,null,null),a=0;s.root=!0,a=this.oi(s,0);let l=0,h,d,u=(m,g)=>this.Yt&&m.parents&&m.parents.length>0?this.ne.get(this.F(m.parents[0].node)).position[this.ri]+this.ua(m,this.ti)+this.Ct:g,p=!1;if(a===0&&this.St===!0){let m=this.ii(r);!isNaN(m.x)&&!isNaN(m.y)&&(this.si(r.id,m,0),p=!0)}if(!p)for(e=0;e<this.P.length;e++){for(this.P[e].otherAxis=l,t=0;t<this.P[e].entries.length;t++)h=this.ue===0?this.P[e].entries[t].loc:u(this.P[e].entries[t],l),d=this.ue===1?this.P[e].entries[t].loc:u(this.P[e].entries[t],l),this.si(this.F(this.P[e].entries[t].node),{x:h,y:d},e);this.ve?e<this.P.length-1&&(this.P[e].otherAxisSize=this.De[e+1]+this.Ct,l-=this.P[e].otherAxisSize):(this.P[e].otherAxisSize=this.De[e]+this.Ct,l+=this.P[e].otherAxisSize)}}return this.ne}si(r,e,t){this.ne.set(r,{position:e,layer:t});let n=this.Pt(r),o=this.ue===0?e.x+n.width:e.y+n.height,s=this.ue===0?e.x:e.y;this.un=Math.max(this.un,o),this.pn=Math.min(this.pn,s)}dt(r){let e=this.P[r];return e||(e={entries:[],pointer:0,otherAxis:null,otherAxisSize:null},this.P[r]=e),e}Qe(r,e,t,n,o){let s=this.dt(t),a={node:r,parents:n==null?[]:[n],childGroup:o,childGroupIndex:o==null?void 0:o.nodes.length,loc:s.pointer,index:s.entries.length,dimensions:e,size:e[this.Ot],children:[]},l=e[this.ni];return this.De[t]==null?this.De[t]=l:this.De[t]=Math.max(this.De[t],l),s.pointer+=e[this.Ot]+(r.type===Cr?0:this.J),s.entries.push(a),n&&n.children.push(a),a}pa(r,e){let t=this.Nr[e];t||(t=[],this.Nr[e]=t),r.index=t.length,t.push(r)}ma(r,e){if(r.parents.length>0){let t=e-r.parents[0].loc;for(let s=0;s<r.parents.length;s++)r.parents[s].loc+=t;let n=r.parents[r.parents.length-1],o=this.dt(r.depth-1);o.pointer=Math.max(o.pointer,n.loc+n.size+this.J)}}ua(r,e){let t=r.parents.map(n=>n.dimensions[e===0?Te:De]);return Math.max.apply(null,t)}ga(r){if(r.size>0){let e=this.da[this.D](r),t=this.Nr[r.depth],n=this.D==="end"?1/0:-1/0,o=0;if(t!=null&&t.length>0){let d=t[t.length-1],u=d.nodes[d.nodes.length-1];n=this.D==="end"?u.loc-r.size:u.loc+u.size+this.J}this.D!=="end"&&e>=n||this.D==="end"&&e<=n?r.loc=e:(o=n-e,r.loc=n);let s=r.loc,a=this.D==="end"?r.nodes.length-1:0,l=this.D==="end"?-1:r.nodes.length,h=this.D==="end"?-1:1;for(let d=a;d!==l;d+=h)r.nodes[d].loc=s,s+=r.nodes[d].size,s+=this.J;o!==0&&this.Ea(r),this.pa(r,r.depth)}}ya(r){let e=r.nodes[0].loc,t=r.nodes[r.nodes.length-1].loc+r.nodes[r.nodes.length-1].size,n=this.fa[this.D](r,e,t),o=n-Pl(r);if(this.ma(r,n),!e0(r)){let s=dA(r),a=t0(r);for(let l=a+1;l<s.nodes.length;l++)s.nodes[l].loc+=o}}Ea(r){let e=r;for(;e!=null;)this.ya(e),e=dA(e)}oi(r,e){if(this.ei[r.node.id])return;this.ei[r.node.id]=!0;let t={nodes:[],loc:0,size:0,parents:[r],depth:e+1,children:[],index:-1,id:V()},n=[],o,s={},a=this.dt(e+1),l=this.Xt(r.node,e,this.model);for(o=0;o<l.length;o++){let h=l[o];if(h!=null&&h!==r.node&&!s[h.id]){let d=this.Pt(this.F(h)),u=a.entries.find(p=>this.F(p.node)===this.F(h));if(u!=null){u.parents.push(r);let p=u.loc+u.size/2,m=Pl(u),g=md(u,this.J),E=m+g/2,y=E-p;y>0&&this.Ug(u,y,r)}else{let p=this.Qe(h,d,e+1,r,t);t.nodes.push(p);let m=d[this.Ot];t.size+=m+this.J,n.push(p)}s[h.id]=!0}}for(this.ga(t),o=0;o<n.length;o++)this.oi(n[o],e+1);return l.length}Ug(r,e,t){let n={},o=s=>{let a=s.childGroup;if(n[a.id]!==!0){n[a.id]=!0;let l=s.childGroupIndex;for(let h=l;h<a.nodes.length;h++)a.nodes[h].loc+=e;l===0?a.loc+=e:a.size+=e}s.children.forEach(o)};o(r)}};var Ed=class extends Vs{constructor(e,t,n){super(e);this.model=e;this.vertexSet=t;c(this,"Ht");c(this,"kt");c(this,"Q");c(this,"mn");c(this,"gn");c(this,"D");c(this,"Ne");c(this,"mi");n=n||{},this.Q=n.padding||{x:50,y:50},this.mn=n.unattachedRootPadding||150,this.Ht=n.lastPlacements,this.gn=n.strategy||"parent",this.Ne=n.edgeNodeSize,this.mi=n.gatherUnattachedRoots,this.D=n.alignment||"center"}zg(e,t){return{mainAxis:(e.length-1)*t+e.reduce((n,o)=>lt(o)?n+this.Ne:n+this.model.getSizeInMainAxis(o.size),0),otherAxis:e.reduce((n,o)=>Math.max(n,this.model.getSizeInOtherAxis(o.size)),0)}}execute(e){let t=0,n,o=this.model.getPaddingInMainAxis(),s=this.model.getPaddingInOtherAxis(),a=this.model.axis,l=this.Ht?this.Ht.maximumPointer+o:0,h=this.vertexSet.layers,d=l,u=h.map(g=>this.zg(g.entries,o)),p={rootId:e.id,rootSize:this.model.getNodeSizeInMainAxis(e),maximumPointer:d,rootPosition:d,biggestLayer:Math.max(...u.map(g=>g.mainAxis))},m=this.model.getNodeSizeInMainAxis(e);return n=this.gn==="center"?(p.biggestLayer-m)/2:this.gn==="start"?0:p.biggestLayer-m,h.length>0&&(this.model.invert?t-=u[0].otherAxis+2*s:t+=this.model.getNodeSizeInOtherAxis(e)+2*s,this.gn==="parent"?this.Yg(p,l):this.Xg(h,n,a,p,l,t,u,o,s)),p.maximumPointer=Math.max(p.maximumPointer,p.rootPosition+p.rootSize+o),p}Xg(e,t,n,o,s,a,l,h,d){let u=s,p;for(let m=0;m<e.length;m++){this.kt=e[m],t=this.gn==="center"?(o.biggestLayer-l[m].mainAxis)/2:this.gn==="start"?0:o.biggestLayer-l[m].mainAxis,u=s;for(let g=0;g<this.kt.entries.length;g++){p=this.kt.entries[g];let E=t+u,y=a,x=n===0?E:y,f=n===0?y:E;if(lt(p)){let b=n===0?this.Ne:y,A=n===0?y:this.Ne;p.loc={x,y:f,w:b,h:A},u+=this.Ne+h}else this.vertexSet.setPosition(p.obj,x,f,m),u+=this.model.getSizeInMainAxis(p.size)+h}o.maximumPointer=Math.max(o.maximumPointer,u),m<e.length-1&&(this.model.invert?a-=l[m+1].otherAxis+2*d:a+=l[m].otherAxis+2*d)}}Yg(e,t){let n=new gd(this.model.layout.instance,{rootNode:this.vertexSet.layers[0].entries,padding:this.Q,axisIndex:this.model.axis,invert:this.model.invert,alignment:this.D,idFunction:d=>this.model.layout.instance.getNodeId(d),sizeFunction:d=>this.model.entryMap[d].size,childVerticesFunction:(d,u,p)=>{let m=[];if(u<this.vertexSet.layers.length-1){let g=this.model.getAdjacentEntriesInLayer(this.vertexSet.layers[u+1].entries,d).map(E=>E.entry);m.push(...g)}return m},absoluteBacked:this.model.layout.absoluteBacked,absolutePositionFunction:d=>this.model.layout.getAbsolutePosition(d,this.model.layout.parameters)}),o=n.execute(),s=n.un,a=n.pn,l=0,h=0;if(this.mi&&o.size===1&&this.Ht!=null){let d=this.Ht.rootPosition+this.Ht.rootSize+this.mn;o.get(e.rootId).position[this.model.axis===0?"x":"y"]=d,e.maximumPointer=d+e.rootSize}else if(this.Ht){let d=this.Ht.maximumPointer-a;this.model.axis===0?l=d:h=d}o.forEach((d,u)=>{this.vertexSet.setPositionById(u,d.position.x+l,d.position.y+h,d.layer),u===e.rootId&&(e.rootPosition=this.model.axis===0?d.position.x+l:d.position.y+h)}),e.maximumPointer=t+(s-a)}};var fd=class{constructor(r,e){this.R=r;this.index=e;c(this,"layers",[]);c(this,"regions",[]);c(this,"gateMap",{});c(this,"edgeNodes",[]);c(this,"edgeNodeMap",new Map);c(this,"gates",[]);c(this,"edgeRoutingMap",{});c(this,"edgeRouting",[]);c(this,"Xh",[]);c(this,"edgeEntryMap",new Map)}addToLayer(r,e,t){let n=this.jh(r),o=lt(e),s;return o?(s={id:V(),obj:e,previous:null,size:this.R.Yh(),next:null,leaf:!1,type:Cr,layer:r,vertexSet:this},e.entries.push(s)):(s=this.R.vertexEntryMap.get(e.id),s.layer=r,s.vertexSet=this),this.R.entryMap[s.id]=s,t?n.entries.unshift(s):n.entries.push(s),this.R.assignedVertices.set(e.id,r),this.Xh.push(s),s}findLayerIndex(r){var e;return(e=this.Xh.find(t=>t.id===r))==null?void 0:e.layer}insertEdgeNodeInLayer(r,e,t){let n=this.jh(r),o=this.R.Yh();this.R.assignedVertices.set(e.id,r);let s={id:V(),obj:e,size:o,leaf:!1,type:Cr,layer:r,vertexSet:this};e.entries.push(s),this.R.entryMap[s.id]=s;let a=t?1:-1,l=t?0:n.entries.length-1,h=null;for(;h==null&&l>=0&&l<n.entries.length;)lt(n.entries[l])?n.entries[l].obj.span<e.span&&(h=l):h=l,l+=a;let d=h!=null?t?h:h+1:t?0:n.entries.length;return n.entries.splice(d,0,s),s}removeFromLayer(r,e){let t=this.layers[r];t.entries.splice(t.entries.indexOf(e),1),this.R.assignedVertices.delete(e.id)}setPositionById(r,e,t,n){if(!this.R.layout.absoluteBacked)this.En(r,e,t,n);else{let o=this.R.layout.model.getVertex(r),s=this.R.layout.getAbsolutePosition(o);s.x!=null&&s.y!=null&&!isNaN(s.x)&&!isNaN(s.y)?this.En(r,s.x,s.y,n):this.En(r,e,t,n)}}setPosition(r,e,t,n){if(!this.R.layout.absoluteBacked)this.En(r.id,e,t,n);else{let o=this.R.layout.getAbsolutePosition(r);o.x!=null&&o.y!=null&&!isNaN(o.x)&&!isNaN(o.y)?this.En(r.id,o.x,o.y,n):this.En(r.id,e,t,n)}}jh(r){return this.layers[r]==null&&(this.layers[r]={layer:r,entries:[],xmin:1/0,ymin:1/0,xmax:-1/0,ymax:-1/0}),this.layers[r]}En(r,e,t,n){this.R.zh(r,e,t,n);let o=this.layers[n],s=this.R.vertexEntryMap.get(r)||this.edgeEntryMap.get(r);if(s){let a=e+s.size.width,l=t+s.size.height;o.xmin=Math.min(o.xmin,e),o.ymin=Math.min(o.ymin,t),o.xmax=Math.max(o.xmax,a),o.ymax=Math.max(o.ymax,l)}}};var uA="Hierarchy",Co=class extends Jn{constructor(e){super(e);c(this,"type",uA);c(this,"axis");c(this,"model");c(this,"mn");c(this,"ci");c(this,"li");c(this,"ve");c(this,"mi");c(this,"kh");c(this,"dn");c(this,"Hh");c(this,"D");c(this,"Wh");c(this,"ai");c(this,"Ne");c(this,"di");c(this,"ba");c(this,"routingInformation");c(this,"resultSets",[]);this.mn=e.options.unattachedRootPadding==null?150:e.options.unattachedRootPadding,this.axis=e.options.axis?e.options.axis==="horizontal"?0:1:0,this.ci=e.options.maxIterationsWithoutImprovement||5,this.li=e.options.maxIterations||24,this.Hh=e.options.rootNode,this.dn=e.options.getRootNode,this.Wh=e.options.placementStrategy,this.Ne=e.options.edgeNodeSize||EE,this.ve=e.options.invert===!0,this.mi=e.options.gatherUnattachedRoots===!0,this.D=e.options.alignment||ld,this.kh=e.options.generateRouting===!0,this.di=e.options.edgeFilter,this.ba=e.options.filteredEdgeProcessor,this.ai=e.options.leavesAtBottom}begin(e,t,n,o,s){this.resultSets.length=0;let a=this.dn?this.dn():this.Hh;this.model=new pd(e,{getSize:l=>this.getSize(l,o),axis:this.axis,padding:this.padding,setPosition:n,rootNode:a,invert:s.invert===!0,unattachedRootPadding:this.mn,edgeNodeSize:this.Ne,edgeFilter:this.di},this),this.model.initialize()}end(e,t,n,o,s){}reset(){}getDefaultParameters(){return{padding:{x:50,y:50},unattachedRootPadding:150,axis:"horizontal",maxIterations:24,maxIterationsWithoutImprovement:2,placementStrategy:"parent",alignment:"center",edgeNodeSize:EE}}step(e,t,n,o,s){let a=0;if(!this.model.isEmpty()){let l=this.model.nextRoot(),h=null;for(;l!=null;){let d=new fd(this.model,a++);d.addToLayer(0,l),this.model.sets.push(d);let u=new hd(this.model,d);u.execute(l),new Gs(d,(g,E,y)=>this.model.getAdjacentEntries(g,E,y),{maxIterations:this.li,maxIterationsWithoutImprovement:this.ci}).execute(),h=new Ed(this.model,d,{padding:this.padding,strategy:this.Wh,edgeNodeSize:this.Ne,lastPlacements:h,gatherUnattachedRoots:this.mi,unattachedRootPadding:this.mn,alignment:this.D}).execute(l);let p=[];if(d.layers.flatMap(g=>g.entries.map(E=>{if(lt(E)){p.push(E);let y=this.axis===0?g.ymax-g.ymin:g.xmax-g.xmin;this.axis===0?E.size.height=y:E.size.width=y}})),this.ba){let g=u.getFilteredEdges().map(E=>{let y=this.model.entryMap[E.source.id],x=this.model.entryMap[E.target.id],f=d.layers[y.layer].entries.findIndex(A=>A.id===y.id),b=d.layers[x.layer].entries.findIndex(A=>A.id===x.id);return{sourceEntry:y,sourceEntryIndex:f,targetEntry:x,targetEntryIndex:b,edge:E}});this.ba(g,this)}let m={};this.kh&&(this.routingInformation=this.model.sets.map(g=>{let E={gates:g.gates,edges:g.edgeRouting,edgeMap:g.edgeRoutingMap,regions:g.regions,getVertexPosition:y=>t(y),getVertexSize:y=>o[y]};return new ud(this.model,d,this.axis,this.ve,()=>E).execute(),E})),this.resultSets.push({node:l,edgeNodes:p,paths:m}),l=this.model.nextRoot()}}this.done=!0}getRoutingInformation(){return this.routingInformation}};c(Co,"type",uA),qe.register(Co.type,Co);var yd=class{constructor(r){this.color=r}generate(r){return this.color}},Qn=class i{constructor(r,e,t){this.r=r;this.g=e;this.b=t}toString(){return`rgb(${this.r}, ${this.g}, ${this.b})`}static fromString(r){if(r.startsWith("#")){let e=r.substring(1);e.length===3&&(e=[e[0],e[0],e[1],e[1],e[2],e[2]].join(""));let t=parseInt(e.substring(0,2),16),n=parseInt(e.substring(2,4),16),o=parseInt(e.substring(4,6),16);return new i(t,n,o)}else if(r.startsWith("rgb")){let e=r.match(/\d+/g);if(e&&e.length>=3)return new i(parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10))}else{let e=r0(r);return i.fromString(e)}}};function r0(i){let r=document.createElement("div");r.style.color=i,document.body.appendChild(r);let e=getComputedStyle(r).color;return document.body.removeChild(r),e}function pA(){return new Qn(Math.floor(Math.random()*225+20),Math.floor(Math.random()*225+20),Math.floor(Math.random()*225+20))}var $s=class{constructor(){c(this,"assignedColors",[])}generate(r){let n=0,o=pA(),s=this.assignedColors.find(a=>gA(a,o)<20);for(;s!=null&&n<10;)o=pA(),s=this.assignedColors.find(a=>gA(a,o)<20),n++;return this.assignedColors.push(o),o.toString()}reset(){this.assignedColors.length=0}},mA=class{constructor(...r){c(this,"colors");c(this,"counter",0);this.colors=r}generate(r){let e=this.colors[this.counter];return this.counter++,this.counter>=this.colors.length&&(this.counter=0),e}};function gA(i,r){let e=(i.r+r.r)/2,t=i.r-r.r,n=i.g-r.g,o=i.b-r.b;return Math.sqrt(((512+e)*t*t>>8)+4*n*n+((767-e)*o*o>>8))}function xd(i){let r=z(i)?Qn.fromString(i):i;return(.2126*r.r+.7152*r.g+.0722*r.b)/255>.5?new Qn(Math.floor(r.r*.3),Math.floor(r.g*.3),Math.floor(r.b*.3)):new Qn(Math.min(255,Math.floor(r.r+(255-r.r)*.7)),Math.min(255,Math.floor(r.g+(255-r.g)*.7)),Math.min(255,Math.floor(r.b+(255-r.b)*.7)))}function tj(i){let r=z(i)?Qn.fromString(i):i;return(.2126*r.r+.7152*r.g+.0722*r.b)/255>.5?new Qn(0,0,0):new Qn(255,255,255)}var yE="empty",n0=[{dx:0,dy:-1,axis:he,directionFromParent:-1},{dx:1,dy:0,axis:ne,directionFromParent:1},{dx:0,dy:1,axis:he,directionFromParent:1},{dx:-1,dy:0,axis:ne,directionFromParent:-1},{dx:-1,dy:-1,axis:bn,directionFromParent:-1},{dx:1,dy:-1,axis:qn,directionFromParent:-1},{dx:1,dy:1,axis:bn,directionFromParent:1},{dx:-1,dy:1,axis:qn,directionFromParent:1}],i0=[{dx:0,dy:-1,axis:he,directionFromParent:-1},{dx:1,dy:0,axis:ne,directionFromParent:1},{dx:0,dy:1,axis:he,directionFromParent:1},{dx:-1,dy:0,axis:ne,directionFromParent:-1}],EA=(i,r,e,t)=>i0.filter(n=>n.axis!==e||n.directionFromParent===t),xE=(i,r,e,t)=>{let n=[];switch(e){case qn:n.push({x:-t,y:0}),n.push({x:-t,y:t}),n.push({x:0,y:t});break;case bn:n.push({x:t,y:0}),n.push({x:t,y:t}),n.push({x:0,y:t});break;case ne:n.push({x:t,y:-1}),n.push({x:t,y:0}),n.push({x:t,y:1});break;case he:n.push({x:-1,y:t}),n.push({x:0,y:t}),n.push({x:1,y:t});break}return n0.filter(o=>n.find(s=>s.x===o.dx&&s.y===o.dy))};var Fs=class{constructor(r,e,t,n,o,s){this.gridCellSize=t;this.vertexBorder=n;this.vertexBuffer=o;this.getCoincidentObstacles=s;c(this,"ut",{});c(this,"gi");c(this,"Zh");c(this,"sourceId");c(this,"targetId");c(this,"sourceObstacles",[]);c(this,"targetObstacles",[]);c(this,"sourceBuffers",[]);c(this,"targetBuffers",[]);c(this,"sourceAxis");c(this,"sourceDirection");c(this,"targetAxis");c(this,"targetDirection");this.gi={x:Math.min(r.x,e.x),y:Math.min(r.y,e.y)},this.Zh=t*(n+o)}Uo(r,e){return{x:Math.floor((r-this.gi.x)/this.gridCellSize),y:Math.floor((e-this.gi.y)/this.gridCellSize)}}jg(r){let e=this.Uo(r.x,r.y),t=this.Uo(r.x+r.width,r.y+r.height);return{x:e.x,y:e.y,width:t.x-e.x,height:t.y-e.y}}kg(r,e){let t=r*this.gridCellSize,n=e*this.gridCellSize,o=this.gi.x+t,s=this.gi.y+n;return{x:o,y:s,width:this.gridCellSize,height:this.gridCellSize}}makeKey(r,e){return`${r}_${e}`}Hg(r){return this.sourceObstacles.indexOf(r)!==-1||this.sourceBuffers.indexOf(r)!==-1||this.targetObstacles.indexOf(r)!==-1||this.targetBuffers.indexOf(r)!==-1}Wg(r,e,t,n){let o=this.makeKey(r,e);if(this.ut[o]==null){let s=this.kg(r,e),a=s.x,l=s.y,h=this.getCoincidentObstacles(a,l,this.Zh),d=[],u=[],p=!1,m=!1;h.forEach(g=>{if(!p&&(this.sourceId===g.id||this.sourceObstacles.indexOf(g.id)!==-1)&&(p=!0),!m&&(this.targetId===g.id||this.targetObstacles.indexOf(g.id)!==-1)&&(m=!0),!this.Hg(g.id)){let E=fb(this.jg(g),this.vertexBorder,this.vertexBorder);u.push(g.id),E.x<=r&&E.x+E.width>=r&&E.y<=e&&E.y+E.height>=e&&d.push(g.id)}}),this.ut[o]={key:o,f:0,g:1/0,h:null,opened:!1,closed:!1,x:r,y:e,cx:a,cy:l,ax:t,ay:n,parent:null,fixedAxis:null,directionFromParent:null,obstacles:d,buffers:u,hasSourceObstacles:p,hasTargetObstacles:m}}else t&&(this.ut[o].ax=t),n&&(this.ut[o].ay=n);return this.ut[o]}setSourceCell(r,e,t,n,o,s,a){this.sourceId=r;let l=this.getCell(e,t,n,o);return this.sourceObstacles=l.obstacles.slice(),this.sourceBuffers=l.buffers.slice(),this.sourceAxis=s,this.sourceDirection=a,l.opened=!0,l.g=0,l.f=0,l.fixedAxis=s,l.directionFromParent=a,l}setTargetCell(r,e,t,n,o,s,a){this.targetId=r;let l=this.getCell(e,t,n,o);return this.targetObstacles=l.obstacles.slice(),this.targetBuffers=l.buffers.slice(),this.targetAxis=s,this.targetDirection=a,l.fixedAxis=s,l.directionFromParent=this.targetDirection,l}get sourceAndTargetObstacles(){let r=this.sourceObstacles.slice(),e=this.targetObstacles.slice();return r.push(...e),r}getCell(r,e,t,n){return this.Wg(r,e,t,n)}reinitialize(){Object.entries(this.ut).forEach(r=>{r[1].f=0,r[1].g=1/0,r[1].h=null,r[1].closed=!1,r[1].opened=!1,r[1].parent=null,r[1].directionFromParent=null,r[1].ax=null,r[1].ay=null,r[1].fixedAxis=null}),this.sourceObstacles.length=0,this.sourceBuffers.length=0,this.targetObstacles.length=0,this.targetBuffers.length=0}};function Bs(i,r){return i===0&&r===0?void 0:i===0&&r!==0?he:i!==0&&r===0?ne:Math.sign(r)===Math.sign(i)?bn:qn}function fA(i,r,e){return e==null?0:e===ne?i>0?1:-1:e===he?r>0?1:-1:e===bn?i>0&&r>0?1:-1:i<0&&r>0?1:-1}function bE(i){let r=Bs(i.ox,i.oy);return{axis:r,direction:fA(i.ox,i.oy,r)}}function yA(i,r){let e=Math.abs(r.x-i.x),t=Math.abs(r.y-i.y);return e>t?ne:he}function Ir(i){if(i.parent==null)return i.fixedAxis;{let r=Math.sign(i.parent.x-i.x),e=Math.sign(i.parent.y-i.y);return Bs(r,e)}}function xA(i){if(i.parent==null)return i.directionFromParent;{let r=Math.sign(i.x-i.parent.x),e=Math.sign(i.y-i.parent.y),t=Bs(r,e);return fA(r,e,t)}}function o0(i,r,e){if(r.f<e.f)return-1;if(e.f<r.f)return 1;if(r.h<e.h)return-1;if(e.h<r.h)return 1;{let t=Ir(i);return Ir(r)===t?-1:Ir(e)===t?1:0}}var bd=class{constructor(){c(this,"node")}sort(r,e){return o0(this.node,r,e)}};var jt="group:added",wi="group:member:added",Us="group:member:removed",Ge="group:removed",Po="dataLoadStart",AE="dataAppendStart",Mr="dataLoadEnd",SE="dataAppendEnd",TE="dataUpdated",Sn="graphClearStart",Ht="graphCleared",bA="graphChanged",Re="group:updated",$e="node:updated",ur="port:updated",pt="edge:updated",pr="edge:added",kt="node:added",mt="edge:removed",Le="node:removed",ei="port:added",Vr="port:removed",on="edge:target",sn="edge:source",mr="select",gr="deselect",Pr="selection:cleared",ti="edge:geometry",ri="edge:pathEdited",Ad="edge:typeChanged",Sd="node:typeChanged",Td="port:typeChanged",vd="group:typeChanged",AA="group:move:start",Cd="group:move",Gr="group:move:end",Pd="internal:group:sizeChanged",Od="internal:group:sizeChangedRedo",_d="internal:group:sizeChangedUndo",SA="renderer:added",Ys="node:move:start",ir="node:move",Dt="node:move:end",zs="undoredo:update",TA="undo",vA="redo",Di="destroy";var s0=[kt,ei,pr,jt,Le,Vr,mt,Ge,$e,ur,pt,Re,Dt,Gr,sn,on,wi,Us],Oo=(i,r,e)=>{i.instance.bind(r,e),i.bindings.push([r,e])},Ol=class{constructor(r,e){this.instance=r;c(this,"bindings",[]);c(this,"zo",null);if(e.saveUrl==null&&e.autoSaveHandler==null)throw new Error("VisuallyJs autosave: neither saveUrl nor autoSaveHandler was specified");function t(a){return function(){a&&a.apply(a,arguments),e.onAfterAutoSave&&e.onAfterAutoSave()}}let n=!1,o=function(){if(!n){try{e.onBeforeAutoSave&&e.onBeforeAutoSave()}catch(a){}e.autoSaveHandler!=null?e.autoSaveHandler(r):r.save({type:e.type||Xt,url:e.saveUrl,success:t(e.onAutoSaveSuccess),error:t(e.onAutoSaveError),headers:e.saveHeaders})}},s=()=>{e.debounceTimeout==null?o():this.zo==null?this.zo=setTimeout(o,e.debounceTimeout):(clearTimeout(this.zo),this.zo=setTimeout(o,e.debounceTimeout))};Oo(this,Po,()=>{n=!0}),Oo(this,Mr,()=>{n=!1}),Oo(this,Sn,()=>{n=!0}),Oo(this,Ht,()=>{n=!1}),Oo(this,TE,s),Oo(this,ri,s)}discard(){this.bindings.forEach(r=>this.instance.unbind(r[0],r[1])),this.bindings.length=0}},Rd=class{constructor(r){this.instance=r;c(this,"bindings",[]);let e=()=>{r.fire(TE)};s0.forEach(t=>Oo(this,t,e))}};var CA="mixed",Ld="isolated",PA="nodesOnly",OA="groupsOnly",_A="edgesOnly",_o=class _o extends $t{constructor(e,t){super();this.instance=e;c(this,"Wt",1/0);c(this,"Jh",1/0);c(this,"Kh",1/0);c(this,"se",[]);c(this,"K",[]);c(this,"q",[]);c(this,"capacityPolicy");c(this,"generator");c(this,"onReload");c(this,"onBeforeReload");c(this,"onClear");c(this,"autoFill");c(this,"Ie",{});c(this,"Mr");c(this,"Yo",!1);c(this,"edgeFactory");t=t||{},this.edgeFactory=e.edgeFactory,this.generator=t.generator,this.onReload=t.onReload,this.onBeforeReload=t.onBeforeReload,this.autoFill=t.autoFill===!0,this.onClear=t.onClear||function(){},this.Mr=t.mode||CA,this.instance.bind(Le,n=>{this.Rt(n.node)}),this.instance.bind(Ge,n=>{this.Rt(n.group)}),this.instance.bind(Vr,n=>{this.Rt(n.port)}),this.instance.bind(mt,n=>{this.Rt(n.edge)}),this.instance.bind(on,n=>{this.Ie[n.edge.getFullId()]&&this.fire(on,n)}),this.instance.bind(sn,n=>{this.Ie[n.edge.getFullId()]&&this.fire(sn,n)}),this.instance.bind(kt,n=>{this.generator&&this.autoFill&&!this.Yo&&this.reload()}),this.instance.bind(jt,n=>{this.generator&&this.autoFill&&!this.Yo&&this.reload()}),this.instance.bind($e,n=>{this.Ie[n.vertex.getFullId()]&&this.fire($e,n)}),this.instance.bind(Re,n=>{this.Ie[n.vertex.getFullId()]&&this.fire(Re,n)}),this.instance.bind(pt,n=>{this.Ie[n.edge.getFullId()]&&this.fire(pt,n)}),this.instance.bind(ur,n=>{n.port!=null&&this.Ie[n.port.getFullId()]&&this.fire(ur,n)}),this.instance.bind(Ht,()=>{this.clear()}),this.instance.bind(Mr,()=>{this.reload()}),this.setCapacityPolicy(_o.DISCARD_EXISTING),t.lazy!==!0&&this.reload()}isEmpty(){return this.se.length===0&&this.K.length===0&&this.q.length===0}qh(e){return e.objectType===Fe.objectType?this.q:e.objectType===de.objectType?this.se:this.K}setMode(e){this.Mr=e,e===Ld?this.Zg():e===_A?this.Qh():e===PA?(this.Aa(),this.ed()):e===OA&&(this.Aa(),this.td())}Jg(e){let t=[],n=this.qh(e),o=e.objectType===Fe.objectType?this.Jh:e.objectType===de.objectType?this.Wt:this.Kh;if(n.length>=o){if(this.capacityPolicy===_o.DISCARD_NEW)return!1;t=n.splice(0,1),this.Sa(t[0],":removed"),delete this.Ie[t[0].getFullId()]}return n.push(e),this.Sa(e,":added"),t}Sa(e,t){let n=e.objectType.toLowerCase()+t,o={Group:s=>({data:s.data,group:s}),Node:s=>({data:s.data,node:s}),Port:s=>({data:s.data,node:s.getParent(),port:s}),Edge:s=>({data:s.data,edge:s})};this.fire(n,o[e.objectType](e))}rd(e,t){if(this.Kg(e)&&!this.Ie[e.getFullId()]){let n=this.Jg(e);return n===!1?[[],[]]:(this.Ie[e.getFullId()]=e,t&&t(e,!0),[[e],n])}return[[],[]]}Kg(e){return this.Mr===CA||this.Mr===PA&&e.objectType===de.objectType||this.Mr===OA&&e.objectType===le.objectType||this.Mr===_A&&e.objectType===Fe.objectType?!0:this.Mr===Ld?e.objectType===Fe.objectType?this.se.length===0&&this.K.length===0:this.q.length===0:!1}Rt(e,t){let n=e.getFullId();return Lt(this.qh(e),s=>s.getFullId()==n)?(delete this.Ie[e.getFullId()],t&&t(e,!1),this.Sa(e,":removed"),[[],[e]]):[[],[]]}qg(e,t){return this.Ie[e.getFullId()]?this.Rt(e,t):this.rd(e,t)}Ta(e,t,n){let o=[],s=[],a;if(e==null)return o;let l=h=>{let d;if(z(h))d=this.instance.getNode(h)||this.instance.getEdge(h)||this.instance.getGroup(h),d!=null&&(a=t(d,n),o.push.apply(o,a[0]),s.push.apply(s,a[1]));else if(h.eachVertex&&h.eachEdge)h.eachVertex((u,p)=>{l(p)}),h.eachEdge((u,p)=>{l(p)});else if(h.ze)h.each((u,p)=>{l(p.vertex||p)});else if(h.length!=null)for(let u=0;u<h.length;u++)l(h[u]);else a=t(h,n),o.push.apply(o,a[0]),s.push.apply(s,a[1])};return l(e),[o,s]}remove(e,t){return this.Ta(e,this.Rt.bind(this),t)}append(e,t){return this.Ta(e,this.rd.bind(this),t)}toggle(e,t){return this.Ta(e,this.qg.bind(this),t)}setMaxNodes(e){this.Wt=e}setMaxGroups(e){this.Kh=e}setMaxEdges(e){this.Jh=e}setCapacityPolicy(e){this.capacityPolicy=e}Aa(){for(let e=this.q.length,t=0;t<e;t++)this.Rt(this.q[0])}td(){for(let e=this.se.length,t=0;t<e;t++)this.Rt(this.se[0])}ed(){for(let e=this.K.length,t=0;t<e;t++)this.Rt(this.K[0])}Qh(){this.td(),this.ed()}Zg(){this.Qh(),this.Aa()}clear(e){this.se.length=0,this.q.length=0,this.K.length=0,this.Ie={},this.fire(Sn),e||this.onClear(this)}nd(e){let t=[];for(let n=0;n<e.length;n++)this.Ie[e[n].getId()]!=null&&t.push(e[n]);return t}reload(){this.generator!=null&&(this.onBeforeReload&&this.onBeforeReload(),this.clear(),this.Yo=!0,this.fire(Po,{}),this.generator(this,this.instance),this.fire(Mr,{}),this.onReload&&this.onReload(),this.Yo=!1)}ze(e,t){let n=t===Fe.objectType?this.q:t===le.objectType?this.K:this.se;for(let o=0;o<n.length;o++)try{e(o,n[o])}catch(s){}}eachNode(e){this.ze(e,de.objectType)}eachGroup(e){this.ze(e,le.objectType)}eachVertex(e){this.ze(e,de.objectType),this.ze(e,le.objectType)}eachEdge(e){this.ze(e,Fe.objectType)}getNodeCount(){return this.se.length}getNodeAt(e){return this.se[e]}getNodes(){return this.se}getNode(e){return this.se.find(t=>t.id===e)}getGroupAt(e){return this.K[e]}getGroups(){return this.K}getGroup(e){return this.K.find(t=>t.id===e)}getGroupCount(){return this.K.length}getAll(){let e=[];return Array.prototype.push.apply(e,this.se),Array.prototype.push.apply(e,this.q),Array.prototype.push.apply(e,this.K),e}getAllEdgesFor(e,t){return this.nd(e.getAllEdges(t))}getSourceEdgesFor(e){return this.nd(e.getSourceEdges())}getEdgeCount(){return this.q.length}getAllEdges(){return this.getEdges()}getEdgeAt(e){return this.q[e]}getEdges(){return this.q}getGroupType(e){return this.instance.getGroupType(e)}getNodeType(e){return this.instance.getNodeType(e)}getModel(){return this.instance.getModel()}getGraph(){return this.instance.getGraph()}getNodeId(e){return this.instance.getNodeId(e)}getGroupId(e){return this.instance.getGroupId(e)}getPortType(e){return this.instance.getPortType(e)}addPort(e,t){return this.instance.addPort(e,t)}getPortId(e){return this.instance.getPortId(e)}getEdge(e){return this.instance.getEdge(e)}getEdgeType(e){return this.instance.getEdgeType(e)}getVertex(e){return this.getNode(e)||this.getGroup(e)}containsVertex(e){return this.getVertex(e)!=null}getObjectInfo(e){return this.instance.getObjectInfo(e)}beforeConnect(e,t,n,o){return this.instance.beforeConnect(e,t,n,o)}beforeMoveConnection(e,t,n){return this.instance.beforeMoveConnection(e,t,n)}beforeStartConnect(e,t){return this.instance.beforeStartConnect(e,t)}beforeDetach(e,t,n){return this.instance.beforeDetach(e,t,n)}beforeStartDetach(e,t){return this.instance.beforeStartDetach(e,t)}get debugEnabled(){return this.instance.debugEnabled}Qg(e){return new _o(this.instance,{onClear:e||function(){}})}filter(e,t){let n=typeof e=="function"?e:function(s){let a=s.data,l=!1;for(let h in e){let d=e[h]===a[h];if(!d&&!t)return!1;l=l||d}return l},o=this.Qg();return this.eachNode(function(s,a){n(a)&&o.append(a);let l=a.getPorts();for(let h=0;h<l.length;h++)n(l[h])&&o.append(l[h])}),this.eachEdge(function(s,a){n(a)&&o.append(a)}),this.eachGroup(function(s,a){n(a)&&o.append(a)}),o}getAncestors(e){return this.instance.getAncestors(e).filter(t=>this.containsVertex(t.id))}getDescendants(e){return this.instance.getDescendants(e)}getType(e){return this.instance.getType(e)}isAncestor(e,t){return this.instance.isAncestor(e,t)}isDescendantGroup(e,t){return this.instance.isDescendantGroup(e,t)}resolveFullId(e){return this.instance.resolveFullId(e)}};c(_o,"DISCARD_EXISTING","discardExisting"),c(_o,"DISCARD_NEW","discardNew");var Er=_o;var ni=class{constructor(r,e,t){this.obj=r;this.instance=e;this.manager=t;c(this,"edgeId");c(this,"source");c(this,"target");c(this,"va");c(this,"Ca");c(this,"Ei");c(this,"od");c(this,"sd");c(this,"ad");c(this,"ld");this.source=r.source.getFullId(),this.target=r.target.getFullId(),H(r.source)&&(this.va=r.source.id,this.source=r.source.getParent().getFullId()),H(r.target)&&(this.Ca=r.target.id,this.target=r.target.getParent().getFullId()),this.edgeId=r.getId(),this.Ei=r.geometry,r.source.dummy&&(this.od=!0,this.ad={x:r.source.data[e.modelLeftAttribute],y:r.source.data[e.modelTopAttribute]}),r.target.dummy&&(this.sd=!0,this.ld={x:r.target.data[e.modelLeftAttribute],y:r.target.data[e.modelTopAttribute]})}generateSourceIdentifier(){return this.od?this.ad:this.va==null?this.source:this.source+this.instance.getGraph().getPortSeparator()+this.va}generateTargetIdentifier(){return this.sd?this.ld:this.Ca==null?this.target:this.target+this.instance.getGraph().getPortSeparator()+this.Ca}Qe(){let r={source:this.generateSourceIdentifier(),target:this.generateTargetIdentifier(),data:this.obj.data,geometry:this.Ei},e=this.instance.$_addEdge(r,Ib,null);this.manager.edgeChange(this.edgeId,e)}tt(){this.instance.removeEdge(this.obj)}edgeChange(r){this.obj=r,this.edgeId=this.obj.getId()}},Dd=class extends ni{constructor(){super(...arguments);c(this,"type","addEdge")}undo(){this.tt()}redo(){this.Qe()}hasDeltas(){return this.obj!=null}},Nd=class extends ni{constructor(){super(...arguments);c(this,"type","removeEdge")}undo(){this.Qe()}redo(){this.tt()}hasDeltas(){return this.obj!=null}},wd=class extends ni{constructor(e,t,n,o,s){super(n,e,t);this.oldVertex=o;this.newVertex=s}verticesAreTheSame(){return Oi(this.newVertex)&&Oi(this.oldVertex)&&this.newVertex.id===this.oldVertex.id}pointsAreTheSame(){return!Oi(this.newVertex)&&!Oi(this.oldVertex)&&Pb(this.newVertex,this.oldVertex)}hasDeltas(){return this.obj!=null&&!this.verticesAreTheSame()&&!this.pointsAreTheSame()}},Id=class extends wd{constructor(){super(...arguments);c(this,"type","edgeSourceChanged")}undo(){this.instance.setSource(this.obj,this.oldVertex)}redo(){this.instance.setSource(this.obj,this.newVertex)}},Md=class extends wd{constructor(){super(...arguments);c(this,"type","edgeTargetChanged")}undo(){this.instance.setTarget(this.obj,this.oldVertex)}redo(){this.instance.setTarget(this.obj,this.newVertex)}};var Tn=class i{constructor(r){this.actions=r;c(this,"id");c(this,"type","compound");this.actions==null&&(this.actions=[]),this.id=V()}$mergeInto(r){this.actions.reverse().forEach(e=>r.addAction(e,!0))}addAction(r,e){e?this.actions.unshift(r):this.actions.push(r)}undo(){this.actions.slice().reverse().forEach(r=>r.undo())}redo(){this.actions.forEach(r=>r.redo())}edgeChange(r,e){this.actions.forEach(t=>{t instanceof ni&&t.edgeId===r&&t.edgeChange(e)})}hasDeltas(){for(let r=0;r<this.actions.length;r++)if(this.actions[r].hasDeltas())return!0;return!1}compress(){let r=new i,e={},t={},n={};for(let o=0;o<this.actions.length;o++){let s=this.actions[o];RA(s)?e[s.obj.id]!=null?Object.assign(e[s.obj.id].$nd,s.$nd):(e[s.obj.id]=s,r.addAction(s)):LA(s)?t[s.obj.id]!=null?Object.assign(t[s.obj.id].pos,s.pos):(t[s.obj.id]=s,r.addAction(s)):wA(s)?n[s.group.id]!=null?Object.assign(n[s.group.id].newGroupSize,s.newGroupSize):(n[s.group.id]=s,r.addAction(s)):r.addAction(s)}return r}};var Xs=class{constructor(r,e,t,n){this.obj=r;this.originalPosition=e;this.pos=t;this.renderer=n;c(this,"type","moveAction")}redo(){this.renderer.setPosition(this.obj,this.pos.x,this.pos.y)}undo(){this.renderer.setPosition(this.obj,this.originalPosition.x,this.originalPosition.y)}hasDeltas(){return this.pos.x!==this.originalPosition.x||this.pos.y!==this.originalPosition.y}};var Vd=class{constructor(r,e){this.obj=r;this.instance=e}$add(){this.obj.objectType===de.objectType?this.obj=this.instance.addNode(this.obj.data):this.obj.objectType===le.objectType&&(this.obj=this.instance.addGroup(this.obj.data))}cd(){this.instance.remove(this.obj)}getTerminusId(){return this.obj.getFullId()}hasDeltas(){return this.obj!=null}},Rl=class extends Vd{constructor(){super(...arguments);c(this,"type","terminusAdd")}undo(){this.cd()}redo(){this.$add()}},_l=class extends Vd{constructor(){super(...arguments);c(this,"type","terminusRemove")}undo(){this.$add()}redo(){this.cd()}isConnectedTo(e){let t=this.getTerminusId();return e.source===t||e.target===t}},Gd=class extends _l{constructor(e,t){super(e.group,t);c(this,"type","groupRemove");c(this,"childrenRemoved");c(this,"orphanedChildren");this.childrenRemoved=e.removeChildren,this.orphanedChildren=e.children.slice()}$add(){super.$add(),this.childrenRemoved||this.orphanedChildren.forEach(e=>this.instance.$addToGroup(e,this.obj,null,null,null,null))}},Ll=class{constructor(r,e,t,n,o){this.group=r;this.originalGroupSize=e;this.newGroupSize=t;this.instance=n;this.source=o;c(this,"type","groupSizeChanged")}hasDeltas(){return Math.round(this.originalGroupSize.width)!==Math.round(this.newGroupSize.width)||Math.round(this.originalGroupSize.height)!==Math.round(this.newGroupSize.height)}redo(){this.Vr(Od,this.newGroupSize,this.originalGroupSize)}undo(){this.Vr(_d,this.originalGroupSize,this.newGroupSize)}Vr(r,e,t){this.instance.fire(r,{group:this.group,source:this.source,sizeAfterUndo:e,sizeBeforeUndo:t})}};function Ok(i,r,e){return i==="*"?!0:i.length>0?i.indexOf(r)!==-1:!e}function js(i,r,e){let t;i=i||{},r=r||{};let n=i,o=r;if(e)for(t=0;t<e.length;t++)n[e[t]]=o[e[t]];else for(t in o)n[t]=o[t];return i}function _k(i,r){let e=xt({x:i[0],y:i[1]},{x:0,y:0},r);return[Math.round(e.x),Math.round(e.y)]}function Rk(i,r){i=i.length==null||typeof i=="string"?[i]:i;for(let e=0;e<i.length;e++)r(i[e])}function $d(i,r,e){return function(){let t=null;try{r!=null&&(t=r.apply(this,arguments))}catch(n){U("VisuallyJs: function failed : "+n)}if(i!=null&&(e==null||t!==e))try{t=i.apply(this,arguments)}catch(n){U("VisuallyJs: wrapped function failed : "+n)}return t}}var Ni=class{constructor(r,e,t,n){this.obj=r;this.instance=t;c(this,"type","update");c(this,"$nd");c(this,"$od");c(this,"reason");this.$nd=js({},r.data),this.$od=js({},e),this.reason=n}hd(r){this.obj.objectType===de.objectType?this.instance.$_updateNode(this.obj,r,this.reason,!0):this.obj.objectType===le.objectType?this.instance.$_updateGroup(this.obj,r,this.reason,!0):this.obj.objectType===me.objectType?this.instance.$_updatePort(this.obj,r,this.reason,!0):this.obj.objectType===Fe.objectType&&this.instance.$_updateEdge(this.obj,r,this.reason,!0)}undo(){this.hd(this.$od)}redo(){this.hd(this.$nd)}hasDeltas(){return!El(this.$nd,this.$od)}};var Bd=class{constructor(r,e,t){this.obj=r;this.yn=e;this.instance=t}Qe(){this.instance.addPort(this.yn,this.obj.data)}tt(){this.instance.removePort(this.yn,this.obj.id)}getTerminusId(){return this.obj.getFullId()}},Fd=class extends Bd{constructor(){super(...arguments);c(this,"type","portAdd")}undo(){this.tt()}redo(){this.Qe()}hasDeltas(){return this.obj!=null}},Ud=class extends Bd{constructor(){super(...arguments);c(this,"type","portRemove")}undo(){this.Qe()}redo(){this.tt()}isConnectedTo(e){let t=this.getTerminusId();return e.generateSourceIdentifier()===t||e.generateTargetIdentifier()===t}hasDeltas(){return this.obj!=null}};var Yd=class{constructor(r,e,t){this.node=r;this.group=e;this.instance=t}hasDeltas(){return this.node!=null}},zd=class extends Yd{constructor(e,t,n,o,s,a,l){super(e,t,a);this.node=e;this.group=t;this.sourceGroup=n;this.Pa=o;this.Oa=s;this.instance=a;this.renderer=l;c(this,"type","addGroupMember")}redo(){this.instance.addToGroup(this.node,this.group),this.renderer!=null&&this.Oa!=null&&this.renderer.setPosition(this.node.id,this.Oa.x,this.Oa.y)}undo(){this.sourceGroup?this.instance.addToGroup(this.node,this.sourceGroup):this.instance.removeFromGroup(this.node),this.renderer!=null&&this.Pa!=null&&this.renderer.setPosition(this.node.id,this.Pa.x,this.Pa.y)}},Xd=class extends Yd{constructor(e,t,n,o,s,a,l){super(e,t,a);this.node=e;this.group=t;this.targetGroup=n;this.Ra=o;this._a=s;this.instance=a;this.renderer=l;c(this,"type","removeGroupMember")}redo(){this.instance.removeFromGroup(this.node),this.renderer!=null&&this._a!=null&&this.renderer.setPosition(this.node.id,this._a.x,this._a.y)}undo(){this.instance.addToGroup(this.node,this.group),this.renderer!=null&&this.Ra!=null&&this.renderer.setPosition(this.node.id,this.Ra.x,this.Ra.y)}},jd=class{constructor(r,e){this.group=r;this.renderer=e;c(this,"type","groupCollapse")}redo(){this.renderer.collapseGroup(this.group)}undo(){this.renderer.expandGroup(this.group)}hasDeltas(){return this.group!=null}},Hd=class{constructor(r,e){this.group=r;this.renderer=e;c(this,"type","groupExpand")}redo(){this.renderer.expandGroup(this.group)}undo(){this.renderer.collapseGroup(this.group)}hasDeltas(){return this.group!=null}};var wl=class{constructor(r,e,t){this.La=r;this.vertex=e;this.pos=t;c(this,"type","rendererVertexRemovedAction")}redo(){}undo(){this.La.setPosition(this.vertex,this.pos.x,this.pos.y)}hasDeltas(){return this.vertex!=null}};var DA="internal.connection",Dl="context:update",kd="group:collapse",Wd="group:expand",Ro="zoom",Zd="render:start",vn="render:end",NA="adhocLayout",Hs="afterLayoutRefresh",Nl="group:relayout",$r="group:render",ks="internal.vertex:updated",Br="node:render",Jd="node:visibility",Kd="plugin:added",IA="plugin:removed",Cn="relayout",MA="objectRepainted",Ue="click",gt="contextmenu",Lo="dblclick",Fr="dbltap",VA="focus",ue="mousedown",vE="mouseenter",CE="mouseexit",ie="mousemove",GA="mouseleave",oe="mouseup",et="mouseout",tt="mouseover",W="tap",$A="touchstart",BA="touchend",FA="touchmove",UA="vertex:click",YA="vertex:dblclick",zA="vertex:dbltap",XA="vertex:mouseout",jA="vertex:mouseover",HA="vertex:mousemove",P5="vertex:mouseup",O5="vertex:mousedown",kA="vertex:contextmenu",WA="vertex:tap",ZA="edge:click",JA="edge:dblclick",KA="edge:dbltap",qd="edge:mouseout",Qd="edge:mouseover",qA="edge:mouseup",Il="edge:mousedown",QA="edge:contextmenu",eS="edge:tap",wo="canvasClick",tS="canvasDblClick",eu="edge:redraw",rS="lasso:end",Ml="pan",Pn="modeChanged",_5="allGroupsRelayout",nS="groupRelayoutAdhoc",R5="groupMemberRemoved",iS="newVertexAddedToGroup",oS="existingVertexAddedToGroup";var Ws=class extends Ni{constructor(e,t,n,o){super(e,t,n,o);this.obj=e;this.instance=n;c(this,"type","vertexUpdate");o===Zs&&t[this.instance.modelRotationAttribute]==null&&(this.$od[this.instance.modelRotationAttribute]=0)}};var Do=class{constructor(r,e,t,n){this.obj=r;this.previousType=e;this.newType=t;this.instance=n;c(this,"type","setTypeAction")}hasDeltas(){return this.previousType!==this.newType}redo(){this.instance.setType(this.obj,this.newType)}undo(){this.instance.setType(this.obj,this.previousType)}};var PE=class{constructor(r,e,t,n,o){this.T=r;this.eE=e;this.ud=t;this.Ei=n;this.La=o;c(this,"type","edgePath")}dd(r){this.T.setEdgeGeometry(this.eE,r,null,this.La)}undo(){this.dd(this.ud)}redo(){this.dd(this.Ei)}hasDeltas(){return!El(this.ud,this.Ei)}},a0=50,OE="Cannot start a new transaction while one is active. Either commit/rollback the current transaction before creating a new one, or pass a cleanup flag in to this method",l0="Cannot rollback transaction from here; it has been appended to. Close all transaction appenders before attempting to rollback the transaction.",tu=class{constructor(r){c(this,"T");c(this,"Xo");c(this,"Lt");c(this,"wa");c(this,"undoStack");c(this,"redoStack");c(this,"jo",[]);c(this,"ae");c(this,"Zt",0);this.T=r.instance,this.Lt=!1,this.undoStack=[],this.redoStack=[],this.Xo=r.maximumSize||a0,this.wa=r.onChange,this.tE()}pd(r){this.Lt=r}dataLoadStart(){this.clear(),this.pd(!0)}dataAppendStart(){this.dataLoadStart()}dataLoadEnd(){this.pd(!1)}dataAppendEnd(){this.dataLoadEnd()}tE(){this.T.bind(Ht,()=>{this.clear()}),this.T.bind(kt,r=>{this.command(new Rl(r.node,this.T))}),this.T.bind(Le,r=>{this.command(new _l(r.node,this.T))}),this.T.bind($e,r=>{gl(r.updates)||this.command(new Ws(r.vertex,r.originalData,this.T,r.reason))}),this.T.bind(jt,r=>{this.command(new Rl(r.group,this.T))}),this.T.bind(Ge,r=>{this.command(new Gd(r,this.T))}),this.T.bind(Re,r=>{gl(r.updates)||this.command(new Ws(r.vertex,r.originalData,this.T,r.reason))}),this.T.bind(Pd,r=>{let e=new Ll(r.group,r.originalGroupSize,r.newGroupSize,this.T,r.source);e.hasDeltas()&&this.command(e)}),this.T.bind(pr,r=>{this.command(new Dd(r.edge,this.T,this))}),this.T.bind(mt,r=>{this.command(new Nd(r.edge,this.T,this))}),this.T.bind(pt,r=>{gl(r.updates)||this.command(new Ni(r.edge,r.originalData,this.T,r.reason))}),this.T.bind(sn,r=>{this.command(new Id(this.T,this,r.edge,r.old,r.new))}),this.T.bind(on,r=>{this.command(new Md(this.T,this,r.edge,r.old,r.new))}),this.T.bind(ri,r=>{this.command(new PE(this.T,r.edge,r.originalGeometry,r.geometry,r.ui))}),this.T.bind(ei,r=>{this.command(new Fd(r.port,r.vertex,this.T))}),this.T.bind(Vr,r=>{this.command(new Ud(r.port,r.vertex,this.T))}),this.T.bind(ur,r=>{gl(r.updates)||this.command(new Ni(r.port,r.originalData,this.T,null))}),this.T.bind(wi,r=>{r.vertexIsNew!==!0&&this.command(new zd(r.vertex,r.group,r.sourceGroup,r.originalPosition,r.pos,this.T,r.source))}),this.T.bind(Us,r=>{this.command(new Xd(r.vertex,r.group,r.targetGroup,r.originalPosition,r.newPosition,this.T,r.source))}),this.T.bind(Sd,r=>{this.command(new Do(r.obj,r.previousType,r.newType,this.T))}),this.T.bind(Td,r=>{this.command(new Do(r.obj,r.previousType,r.newType,this.T))}),this.T.bind(vd,r=>{this.command(new Do(r.obj,r.previousType,r.newType,this.T))}),this.T.bind(Ad,r=>{this.command(new Do(r.obj,r.previousType,r.newType,this.T))}),this.T.bind("renderer:added",r=>{r.renderer.bind(Dt,e=>{e.dragGroup.forEach(t=>{t.originalPosition!=null&&this.command(new Xs(t.vertex,t.originalPosition,t.pos,e.ui))})}),r.renderer.bind(Gr,e=>{e.dragGroup.forEach(t=>{t.originalPosition!=null&&this.command(new Xs(t.vertex,t.originalPosition,t.pos,e.ui))})}),r.renderer.bind(kd,e=>{this.command(new jd(e.group,r.renderer))}),r.renderer.bind(Wd,e=>{this.command(new Hd(e.group,r.renderer))}),r.renderer.bind(Le,e=>{this.command(new wl(r.renderer,e.vertex,e.pos))}),r.renderer.bind(Ge,e=>{this.command(new wl(r.renderer,e.vertex,e.pos))})})}fi(){this.wa&&this.wa(this,this.undoStack.length,this.redoStack.length)}command(r,e){if(!this.Lt){if(!r.hasDeltas())return;d0(r)&&(r=r.compress()),this.ae!=null?this.ae.addAction(r,e):(this.undoStack.push(r),this.undoStack.length>this.Xo&&this.undoStack.splice(this.undoStack.length-this.Xo-1,this.undoStack.length-this.Xo),this.redoStack.length=0,this.fi())}}edgeChange(r,e){let t=n=>{n.forEach(o=>{o instanceof ni&&o.edgeId===r?o.edgeChange(e):o instanceof Tn&&o.edgeChange(r,e)})};t(this.undoStack),t(this.redoStack)}undo(){let r=this.undoStack.pop();r&&(this.Lt=!0,this.redoStack.push(r),r.undo(),this.Lt=!1,this.fi())}redo(){let r=this.redoStack.pop();r&&(this.Lt=!0,this.undoStack.push(r),r.redo(),this.Lt=!1,this.fi())}clear(){this.undoStack.length=0,this.redoStack.length=0,this.ae=null,this.Zt=0,this.Lt=!1,this.fi()}transaction(r,e,t){if(this.ae!=null&&e==null)return U(OE),!1;if(this.openTransaction(e)==null){if(t)return r()}else try{if(r()!==!1){let a=this.ae;return this.ae=null,this.command(a),a.id}else return this.rollbackTransaction(),!1}catch(s){return U("Exception thrown in transaction "+s.message+"; rolling transaction back"),this.rollbackTransaction(),!1}}mergeTransaction(r){if(this.ae!=null)return this.transaction(r,St);try{let e=this.transaction(r);if(e!==!1){if(this.undoStack.length>1){let t=this.undoStack.pop(),n=this.undoStack.pop();this.rE(t,n),this.undoStack.push(t)}return e}else return this.rollbackTransaction(),!1}catch(e){return U("Exception thrown in transaction "+e.message+"; rolling transaction back"),this.rollbackTransaction(),!1}}rE(r,e){e instanceof Tn?e.$mergeInto(r):r.addAction(e,!0)}nE(){return this.ae=new Tn,this.Zt=0,this.ae.id}openTransaction(r){if(!this.Lt){let e=!0;if(this.ae!=null)if(r!=null)if(r===h0)this.commitTransaction();else if(r===c0)this.rollbackTransaction();else if(r===St)e=!1,this.Zt++;else throw new Error(OE);else throw new Error(OE);return e&&this.nE(),this.ae.id}return null}rollbackTransaction(){this.ae!=null&&(this.Zt>0?(this.Zt--,U(l0)):(this.ae.undo(),this.ae=null,this.fi(),this.jo.length=0))}commitTransaction(r){if(this.ae!=null)if(r!==!0&&this.Zt>0)this.Zt--;else{let e=this.ae;this.ae=null,this.command(e),this.Zt=0,this.md()}}Ib(r){if(this.undoStack.length===0){let e=new Tn;e.addAction(r),this.command(e)}else{let e=this.undoStack[this.undoStack.length-1];if(e instanceof Tn)e.addAction(r);else{this.undoStack.pop();let t=new Tn;t.addAction(e),t.addAction(r),this.undoStack.push(t)}}}Mb(r){this.iE(r),this.md()}iE(r){this.jo.push(r)}md(){this.ae==null&&(this.jo.forEach(r=>{try{r()}catch(e){}}),this.jo.length=0)}},h0="commitCurrent",c0="rollbackCurrent",St="appendToCurrent";function d0(i){return i instanceof Tn}function RA(i){return i instanceof Ni||i instanceof Ws}function LA(i){return i instanceof Xs}function wA(i){return i instanceof Ll}var ru="1.0.0";var _E="type",RE="default",hS="groupResized",u0="addPort",p0="addNewPort",m0="removePort",nu="updatePort",Js="moved",s6="layout",LE="updateVertex",sS="updateNode",aS="updateGroup",cS="magnetizer",ou="setPosition",dS="snapToGrid",a6="sizeGroupToFit",Vl="drawingToolsResize",Zs="rotation",uS="resized",lS="updated",iu=class extends $t{constructor(e){super();c(this,"graph");c(this,"autoSaver");c(this,"idFunction");c(this,"typeProperty");c(this,"edgeTypeProperty");c(this,"portTypeProperty");c(this,"typeFunction");c(this,"edgeIdFunction");c(this,"edgeTypeFunction");c(this,"portIdFunction");c(this,"portTypeFunction");c(this,"portExtractor");c(this,"portUpdater");c(this,"portDataProperty");c(this,"portOrderProperty");c(this,"modelTopAttribute");c(this,"modelLeftAttribute");c(this,"modelWidthAttribute");c(this,"modelHeightAttribute");c(this,"modelRotationAttribute");c(this,"model");c(this,"Da");c(this,"gd");c(this,"debugEnabled");c(this,"defaultObjectFactory");c(this,"nodeFactory");c(this,"edgeFactory");c(this,"portFactory");c(this,"groupFactory");c(this,"portSeparator",".");c(this,"undoRedo");c(this,"Ed");c(this,"beforeConnect");c(this,"beforeMoveConnection");c(this,"beforeStartConnect");c(this,"beforeDetach");c(this,"beforeStartDetach");c(this,"pe");c(this,"Jt",new Map);c(this,"$transientVerticesByRenderer",{});e=e||{};let t=e.undoRedo||{};t.enabled!==!1&&(this.undoRedo=new tu({instance:this,maximumSize:t.maximumSize,onChange:(o,s,a)=>{this.fire(zs,{undoCount:s,redoCount:a})}})),this.idFunction=e.idFunction||sE,this.typeProperty=e.typeProperty||_E,this.edgeTypeProperty=e.edgeTypeProperty||_E,this.portTypeProperty=e.portTypeProperty||_E,this.typeFunction=e.typeFunction||(o=>o[this.typeProperty]||RE),this.edgeIdFunction=e.edgeIdFunction||this.idFunction,this.edgeTypeFunction=e.edgeTypeFunction||(o=>o[this.edgeTypeProperty]||RE),this.portIdFunction=e.portIdFunction||this.idFunction,this.portTypeFunction=e.portTypeFunction||(o=>o[this.portTypeProperty]||RE),this.portExtractor=e.portExtractor,this.portUpdater=e.portUpdater,this.portDataProperty=e.portDataProperty,this.portOrderProperty=e.portOrderProperty,this.debugEnabled=!1,this.model=new Xc(this,e.model),this.defaultObjectFactory=(o,s,a,l)=>(a=a==null||!dr(a)?{}:a,a=ot(a),a.id=a.id||V(),a.type=a.type||(s==null?null:s.type||s),l(a),!0),this.modelLeftAttribute=e.modelLeftAttribute||Kb,this.modelTopAttribute=e.modelTopAttribute||qb,this.modelWidthAttribute=e.modelWidthAttribute||eA,this.modelHeightAttribute=e.modelHeightAttribute||tA,this.modelRotationAttribute=e.modelRotationAttribute||Qb,this.nodeFactory=e.nodeFactory||this.defaultObjectFactory,this.edgeFactory=e.edgeFactory||this.defaultObjectFactory,this.portFactory=e.portFactory||this.defaultObjectFactory,this.groupFactory=e.groupFactory||this.defaultObjectFactory,this.gd=e.autoSave&&e.autoSave.enabled!==!1,this.Ed={portSeparator:e.portSeparator,defaultCost:e.defaultCost,defaultDirected:e.defaultDirected,enableSubgraphs:e.enableSubgraphs},this.portDataProperty!=null&&this.portExtractor==null&&(this.portExtractor=o=>{let s=o[this.portDataProperty]||[];return this.portOrderProperty!=null&&s.sort((a,l)=>{let h=a[this.portOrderProperty],d=l[this.portOrderProperty],u=h==null?1/0:h,p=d==null?1/0:d;return u-p}),s}),this.portDataProperty!=null&&this.portUpdater==null&&(this.portUpdater=(o,s,a)=>{let l={};return this.portOrderProperty!=null&&a.sort((h,d)=>{let u=h.data[this.portOrderProperty],p=d.data[this.portOrderProperty],m=u==null?1/0:u,g=p==null?1/0:p;return m-g}),l[this.portDataProperty]=a.map(h=>h.data),Object.assign(o,l)}),this.graph=new xl(this.Ed),this.gd&&(this.autoSaver=new Ol(this,e.autoSave)),new Rd(this);let n=(o,s)=>{if(this.model==null)return!0;let a=this.getType(o),l=this.getType(s),h=H(o)?o.getParent():o,d=H(s)?s.getParent():s,u=H(o)?this.model.getPortDefinition(a):K(o)?this.model.getNodeDefinition(a):this.model.getGroupDefinition(a),p=H(s)?this.model.getPortDefinition(l):K(s)?this.model.getNodeDefinition(l):this.model.getGroupDefinition(l),m=K(h)?this.model.getNodeDefinition(a):this.model.getGroupDefinition(a),g=K(d)?this.model.getNodeDefinition(l):this.model.getGroupDefinition(l);return u.maxConnections!=null&&o.getEdges().length>=u.maxConnections||p.maxConnections!=null&&s.getEdges().length>=p.maxConnections?!1:o===s?!(m.allowLoopback===!1||u.allowLoopback===!1||p.allowLoopback===!1||g.allowLoopback===!1):h===d?!(m.allowVertexLoopback===!1||u.allowVertexLoopback===!1||p.allowVertexLoopback===!1||g.allowVertexLoopback===!1):!0};if(this.beforeConnect=e.beforeConnect||n,this.beforeMoveConnection=e.beforeMoveConnection||n,this.beforeStartConnect=e.beforeStartConnect||((o,s)=>({})),this.beforeDetach=e.beforeDetach||((o,s,a)=>!0),this.beforeStartDetach=e.beforeStartDetach||((o,s)=>!0),this.pe=this.ko(o=>{this.L(s=>s.$selectionCleared(o)),this.fire(Pr,{selection:o})}),e.selectionMode&&this.pe.setMode(e.selectionMode),e.maxSelectedNodes&&this.pe.setMaxNodes(e.maxSelectedNodes),e.maxSelectedGroups&&this.pe.setMaxGroups(e.maxSelectedGroups),e.maxSelectedEdges&&this.pe.setMaxEdges(e.maxSelectedEdges),e.selectionCapacityPolicy&&this.pe.setCapacityPolicy(e.selectionCapacityPolicy),e.events)for(let o in e.events)this.bind(o,e.events[o]);e.data!=null&&this.load({data:e.data})}oE(e,t,n){return{id:`${e}_${n}`,[this.modelLeftAttribute]:t.x,[this.modelTopAttribute]:t.y}}Ho(e,t,n,o){if(z(e))return[this.graph.getVertex(e,!0),!1];if(K(e)||Y(e)||H(e))return[e,!1];{let s=e,a=s.x==null?0:s.x,l=s.y==null?0:s.y;return[this.fd(this.oE(t,{x:a,y:l},n),o),!0]}}ko(e){return new Er(this,{onClear:e||function(){}})}filter(e,t){let n=typeof e=="function"?e:function(s){let a=s.data,l=!1,h=e;for(let d in h){let u=h[d]===a[d];if(!u&&!t)return!1;l=l||u}return l},o=this.ko();return this.eachNode(function(s,a){n(a)&&o.append(a);let l=a.getPorts();for(let h=0;h<l.length;h++)n(l[h])&&o.append(l[h])}),this.eachEdge(function(s,a){n(a)&&o.append(a)}),this.eachGroup(function(s,a){n(a)&&o.append(a)}),o}getModel(){return this.model}setAutoSave(e){this.autoSaver!=null&&this.autoSaver.discard(),this.autoSaver=new Ol(this,e)}connect(e){let t,n=this.graph.getVertex(e.source),o=this.graph.getVertex(e.target),s=e.cost,a=e.directed;if(!n)if(!e.doNotCreateMissingNodes)n=this.graph.addNode(e.source),this.Na(n);else return;if(!o)if(!e.doNotCreateMissingNodes)o=this.graph.addNode(e.target),this.Na(o);else return;let l=e.data||{},h=this.beforeStartConnect(n,this.edgeTypeFunction(l));return h&&(typeof h=="object"&&(l=Object.assign(h,l)),this.beforeConnect(n,o,l,!1)!==!1&&(t=this.$_addEdge({source:n,target:o,cost:s,directed:a,data:l,geometry:e.geometry},bl,null))),t}clear(){return this.L(e=>e.$graphClearStart()),this.fire(Sn),this.graph.clear(),this.$transientVerticesByRenderer={},this.L(e=>e.$graphClearEnd()),this.fire(Ht),this}destroy(){this.clear(),delete this.Jt,delete this.$transientVerticesByRenderer}getGraph(){return this.graph}getNodeCount(){return this.graph.getVertexCount()}getNodeAt(e){return this.graph.getVertexAt(e)}getNodes(){return this.graph.getVertices()}eachNode(e){let t;for(let n=0,o=this.graph.getVertexCount();n<o;n++)t=this.graph.getVertexAt(n),e(n,t)}eachGroup(e){let t;for(let n=0,o=this.graph.getGroupCount();n<o;n++)t=this.graph.getGroupAt(n),e(n,t)}eachVertex(e){this.eachNode(e),this.eachGroup(e)}eachEdge(e){let t=this.graph.getEdges();for(let n=0,o=t.length;n<o;n++)e(n,t[n])}getEdgeCount(){return this.graph.getEdgeCount()}getGroupCount(){return this.graph.getGroupCount()}getGroupAt(e){return this.graph.getGroupAt(e)}getGroups(){return this.graph.getGroups()}getDescendants(e){return Ns(e)}getAncestors(e){return yn(e)}isAncestor(e,t){return We(e,t)}isDescendantGroup(e,t){return Db(e,t)}getClusters(){return this.graph.getClusters()}getCluster(e){let t=z(e)?this.getVertex(e):e;return this.graph.getCluster(t)}getNodeId(e){return typeof e=="string"?e:this.idFunction(e)}getNodeType(e){return this.typeFunction(e)||"default"}getGroupId(e){return typeof e=="string"?e:this.idFunction(e)}getGroupType(e){return this.typeFunction(e)||"default"}getEdgeType(e){return this.edgeTypeFunction(e)||"default"}getPortId(e){return this.portIdFunction(e)}getPortType(e){return this.portTypeFunction(e)||"default"}getType(e){return(K(e)?this.typeFunction:H(e)?this.portTypeFunction:this.edgeTypeFunction)(e.data)||"default"}setType(e,t){let n=this.getType(e);if(n===t)return;let o=e.objectType===de.objectType?this.typeProperty:e.objectType===me.objectType?this.portTypeProperty:this.edgeTypeProperty;e.data[o]=t,e.type=t,this.$dispatchTypeChange(e,n,t)}$dispatchTypeChange(e,t,n){let o,s;K(e)?(o=Sd,s=()=>this.L(a=>a.$nodeTypeChanged(e,t,n))):H(e)?(o=Td,s=()=>this.L(a=>a.$portTypeChanged(e,t,n))):Ke(e)?(o=Ad,s=()=>this.L(a=>a.$edgeTypeChanged(e,t,n))):Y(e)&&(o=vd,s=()=>this.L(a=>a.$groupTypeChanged(e,t,n))),o!=null&&(this.fire(o,{obj:e,previousType:t,newType:n}),s())}resolveFullId(e){if(Ke(e))return e.id;if(K(e))return e.id;if(Y(e))return e.id;if(H(e))return e.parent.id+this.graph.portSeparator+e.id}resolveNode(e){return H(e)?e.parent:e}addNode(e,t){let n=this.idFunction(e),o=null;n==null&&typeof e!="string"&&(e.id=V());let s=this.graph.addNode(e,this.idFunction);if(s!=null){if(this.portExtractor!=null){let a=this.portExtractor(s.data,s);if(a!=null)for(let l=0;l<a.length;l++)s.$addPort(a[l],this.portIdFunction)}if(typeof e!="string"&&e.group!=null)if(o=this.getGroup(e.group),o!=null)o.$addMember(s);else throw new Error("parent group ["+e.group+"] not found");return this.Na(s,o),o!=null&&this.fire(wi,{group:o,vertex:s,vertexIsNew:!0}),s}else return this.graph.getVertex(n)}Na(e,t){let n={node:e,parentGroup:t};this.L(o=>o.$nodeAdded(n)),this.fire(kt,n)}sE(e,t){let n={group:e,parentGroup:t};this.L(o=>o.$groupAdded(n)),this.fire(jt,n)}addFactoryNode(e,t,n,o,s){n==null&&(t!=null?(t=typeof t=="object"?t:{},n=typeof t=="function"?t:null):t={}),t.type=t.type||e;try{this.nodeFactory(this,e,t,a=>{s!==!1&&this.openTransaction(St);let l=this.addNode(a);try{n&&n(l)}catch(h){U("WARN: Factory node callback threw an error",h)}s!==!1&&this.commitTransaction()},()=>{o&&o(),s!==!1&&this.rollbackTransaction()})}catch(a){U("WARN: Factory node threw an error",a),s!==!1&&this.rollbackTransaction()}}addNodes(e){for(let t=0;t<e.length;t++)this.addNode(e[t]);return this}yd(e){return Ds(this.$transientVerticesByRenderer,e.id,()=>({}))}$addTransientVertex(e,t){let n=this.graph.addNode(e);if(n.transient=!0,t!=null){let o=this.yd(t);o[n.id]=n,n.transientRenderer=t.id}return n}fd(e,t){let n=this.$addTransientVertex(e,t);return n.dummy=!0,this.L(o=>{o.$renderDummyVertex(n)}),n}Wo(e){this.graph.deleteNode(e),this.L(t=>{t.$nodeRemoved({node:e,edges:[],parentGroupIsBeingRemoved:!1})})}$setEdgeDetached(e,t,n){let o=this.fd({id:`${e.id}_${n===Qe?"0":"1"}`,[this.modelLeftAttribute]:t.x,[this.modelTopAttribute]:t.y});n===Qe?this.setSource(e,o):this.setTarget(e,o)}$cleanupTransientVertex(e,t){let n=e.getAllEdges()||[];this.graph.deleteNode(e);for(let o=0;o<n.length;o++)this.graph.deleteEdge(n[o]),t.$edgeRemoved({edge:n[o],source:t});if(t.$nodeRemoved({node:e,edges:n,parentGroupIsBeingRemoved:!1}),t!=null){let o=this.yd(t);o&&delete o[e.id]}}$addTransientEdge(e,t,n,o,s,a){let l={source:t,target:n,data:o||{},geometry:s,transient:!0},h=this.graph.addEdge(l);return e.$edgeAdded({edge:h,source:e,geometry:h.geometry,transient:!0,reason:Mb},a),h}addFactoryGroup(e,t,n,o,s){n==null&&(t!=null?(t=typeof t=="object"?t:{},n=typeof t=="function"?t:null):t==null&&n==null&&(t={})),t.type=t.type||e;try{this.groupFactory(this,e,t,a=>{s!==!1&&this.openTransaction(St);let l=this.addGroup(a);try{n&&n(l)}catch(h){U("WARN: Factory group callback threw an error",h)}s!==!1&&this.commitTransaction()},()=>{o&&o(),s!==!1&&this.rollbackTransaction()})}catch(a){U("WARN: group factory threw an error",a),s!==!1&&this.rollbackTransaction()}}addGroup(e,t){let n,o;if(this.idFunction(e)==null&&typeof e!="string"&&(e.id=V()),o=this.graph.addGroup(e,this.idFunction),o!=null){if(typeof e!="string"&&e.group!=null){if(n=this.getGroup(e.group),n==null)throw new Error("Cannot find parent group ["+e.group+"]");n.$addMember(o)}this.sE(o,n),n!=null&&this.fire(wi,{group:n,vertex:o,vertexIsNew:!0})}return o}addToGroup(e,t,n){return this.$addToGroup(e,t,null,null,n,null)}$addToGroup(e,t,n,o,s,a){let l=!1,h=this.getObjectInfo(t),d=this.getObjectInfo(e);if(n=n||d.obj.group,d.obj&&h.obj&&(l=h.obj.$addMember(d.obj),l)){n&&n.$removeMember(d.obj),d.obj.data.group=h.obj.id;let u={vertex:d.obj,group:h.obj,pos:s,originalPosition:o,source:a,positionInGroup:s};n&&(u.sourceGroup=n),this.L(p=>{p.$groupMemberAdded(u)}),this.fire(wi,u)}return l}removeFromGroup(e){return this.$removeFromGroup(e,null,null,null,null)}$removeFromGroup(e,t,n,o,s){let a=this.getObjectInfo(e),l;if(a.obj&&a.obj.group&&(l=a.obj.group,l.$removeMember(a.obj))){let h={vertex:a.obj,group:l,newPosition:o,originalPosition:n,source:s};t&&(h.targetGroup=t),this.L(d=>{d.$groupMemberRemoved(h)}),delete a.obj.data.group,this.fire(Us,h)}return l}xd(e,t,n,o){e.nestedGroups.forEach(a=>this.xd(a,t,!0,o)),e.nodes.forEach(a=>this.bd(a,!0,o));for(let a=0;a<e.edges.length;a++)this.Ia(e.edges[a]);let s={group:e.group,removeChildren:t,children:e.children,parentGroup:e.parentGroup,parentGroupIsBeingRemoved:n};this.L(a=>a.$groupRemoved(s)),o||this.fire(Ge,s)}bd(e,t,n){for(let s=0;s<e.edges.length;s++)this.Ia(e.edges[s]);let o={node:e.node,edges:e.edges,parentGroup:e.parentGroup,parentGroupIsBeingRemoved:t};this.L(s=>s.$nodeRemoved(o)),n||this.fire(Le,o)}removeGroup(e,t,n){let o=this.graph.getVertex(z(e)?e:e.id);if(o){this.openTransaction(St);let s=this.graph.deleteGroup(o,t);return s.group&&(t||s.children.forEach(a=>delete a.data.group),this.xd(s,t===!0,!1,n)),this.commitTransaction(),!0}return!1}getNode(e){return this.graph.getVertex(e)}getEdge(e){return this.graph.getEdge(e)}getGroup(e){return this.graph.getGroup(e)}getVertex(e){return this.getNode(e)||this.getGroup(e)}getPort(e){let t=this.graph.getVertexByPortId(e);if(t)return t.getPort(this.graph.splitPortId(e)[1])}exists(...e){for(let t=0;t<e.length;t++)if(this.graph.getVertex(e[t])==null)return!1;return!0}removeNode(e){if(!z(e)&&e.transient===!0)return!1;let t=this.graph.getVertex(z(e)?e:e.id);if(t!=null){this.openTransaction(St);let n=t.getAllEdges()||[];for(let s=0;s<n.length;s++)this.removeEdge(n[s]);let o=this.graph.deleteNode(t);return this.bd(o,!1),this.commitTransaction(),!0}return!1}addEdge(e){return this.$_addEdge(e,bl,null)}$_addEdge(e,t,n,o){let s=this.$_deriveEdgeId(e.data),[a,l]=this.Ho(e.source,s,0,n),[h,d]=this.Ho(e.target,s,1,n);if(a==null||a.objectType==null)throw new TypeError("Unknown source node ["+e.source+"]");if(h==null||h.objectType==null)throw new TypeError("Unknown target node ["+e.target+"]");if(!l&&a.dummy)return U(`Cannot add edge to dummy vertex ${a.id}`),null;if(!d&&h.dummy)return U(`Cannot add edge to dummy vertex ${h.id}`),null;let u=Object.assign(e,{source:a,target:h});if(this.beforeConnect(a,h,e.data,e.addedByMouse===!0)!==!1){let p=this.graph.addEdge(u,s,this.edgeIdFunction),m={edge:p,source:n,geometry:e.geometry,addedByMouse:e.addedByMouse,reason:t};return this.L(g=>g.$edgeAdded(m,e.context)),o||this.fire(pr,m,null),p}else return this.debugEnabled&&U("Could not add edge"),null}Ia(e,t){let n={edge:e,source:t};this.L((o,s)=>o.$edgeRemoved(n)),this.fire(mt,n,null)}removeEdge(e,t){let n=this.graph.getEdge(e);return n!=null&&(this.graph.deleteEdge(n),n.source.dummy&&K(n.source)&&this.Wo(n.source),n.target.dummy&&K(n.target)&&this.Wo(n.target),this.Ia(n,t)),this}setTarget(e,t){if(t==null)return{success:!1};let[n]=this.Ho(t,e.id,1);if(n==null||this.beforeConnect(e.source,n,e.data)===!1)return{success:!1};let o=this.graph.setTarget(e,n);if(o.success!==!1){let s=o.old;o.old.dummy===!0&&(s={x:o.old.data[this.modelLeftAttribute],y:o.old.data[this.modelTopAttribute]},this.Wo(o.old));let a=o.new;o.new.dummy===!0&&(a={x:o.new.data[this.modelLeftAttribute],y:o.new.data[this.modelTopAttribute]});let l={edge:e,old:s,new:a,success:!0};this.L(h=>{h.$edgeTargetChanged(l)}),this.fire(on,l)}return o}setSource(e,t){if(t==null)return{success:!1};let[n]=this.Ho(t,e.id,0);if(n==null||this.beforeConnect(n,e.target,e.data)===!1)return{success:!1};let o=this.graph.setSource(e,n);if(o.success!==!1){let s=o.old;o.old.dummy===!0&&(s={x:o.old.data[this.modelLeftAttribute],y:o.old.data[this.modelTopAttribute]},this.Wo(o.old));let a=o.new;o.new.dummy===!0&&(a={x:o.new.data[this.modelLeftAttribute],y:o.new.data[this.modelTopAttribute]});let l={edge:e,old:s,new:a,success:!0};this.L(h=>{h.$edgeSourceChanged(l)}),this.fire(sn,l)}return o}addNewPort(e,t,n){let o=this.graph.getVertex(e);this.portFactory(this,t,n,s=>{let a=this.portIdFunction(s),l=o.$addPort(a);l.data=s,this.Zo(o,p0);let h={vertex:o,data:s,port:l};this.L(d=>d.$portAdded(h)),this.fire(ei,h,null)},()=>{})}addPort(e,t){let n=this.graph.getVertex(e),o=n.$addPort(t,this.portIdFunction);this.Zo(n,u0);let s={vertex:n,data:t,port:o};return this.L(a=>a.$portAdded(s)),this.fire(ei,s,null),o}removePort(e,t){let n;if(typeof e=="string"){let o=this.graph.splitPortId(e);o.length===2?(n=this.graph.getVertex(o[0]),t=o[1]):n=this.graph.getVertex(e)}else H(e)?(t=e.id,n=e.getParent()):n=this.graph.getVertex(e);if(n!=null&&t!=null){let o=n.getPort(t);if(o){this.openTransaction(St);let s=o.getAllEdges();for(let l=s.length,h=0;h<l;h++)this.removeEdge(s[0]);n.$removePort(o),this.Zo(n,m0);let a={vertex:n,port:o,edges:s};return this.L(l=>l.$portRemoved(a)),this.fire(Vr,a,null),this.commitTransaction(),!0}}return!1}remove(e,t){if(e==null)return;let n=this.getObjectInfo(e);this.setSuspendRendering(!0);try{if(n.obj&&K(n.obj))this.removeNode(n.obj);else if(n.obj&&Y(n.obj))this.removeGroup(n.obj);else if(n.obj&&Ke(n.obj))this.removeEdge(n.obj);else{for(;e.getNodeCount()>0;)this.removeNode(e.getNodeAt(0));for(;e.getEdgeCount()>0;)this.removeEdge(e.getEdgeAt(0));for(;e.getGroupCount()>0;)this.removeGroup(e.getGroupAt(0),t!==!1)}}finally{this.setSuspendRendering(!1,!0)}}setSuspendRendering(e,t){for(let n in this.Jt)this.Jt.get(n).setSuspendRendering(e,t)}batch(e){this.setSuspendRendering(!0);try{e()}catch(t){U("Error in transaction "+t)}finally{this.setSuspendRendering(!1,!0)}}updateGroup(e,t){this.$_updateVertex(e,t,aS,!1)}$_updateGroup(e,t,n,o){this.$_updateVertex(e,t,n,o)}updateNode(e,t){this.$_updateVertex(e,t,sS,!1)}$_updateNode(e,t,n,o){this.$_updateVertex(e,t,n,o)}updateVertex(e,t){this.$_updateVertex(e,t,LE,!1)}$_updateVertex(e,t,n,o,s){let a=this.getObjectInfo(e);if(a.obj){let h=(H(a.obj)?a.obj.getParent():a.obj).objectType===de.objectType?$e:Re;this.Ad(a.obj,t,o,h,(d,u)=>({vertex:d,updates:t||{},originalData:u,reason:n||LE,source:s}))}}updateVertices(e,t){this.aE(e,LE,!1,t)}aE(e,t,n,o){this.transaction(()=>{e.forEach(s=>{this.$_updateVertex(s.id,s.updates,t,n)})},o||St)}updatePort(e,t){this.$_updatePort(e,t,nu,!1)}$_updatePort(e,t,n,o){let s=this.getObjectInfo(e);s.obj&&this.Ad(s.obj,t,o,ur,(a,l)=>({port:a,vertex:a.getParent(),updates:t||{},originalData:l,reason:n||nu}))}updateEdge(e,t){this.$_updateEdge(e,t,lS,!1)}$_updateEdge(e,t,n,o){let s=typeof e=="string"?this.graph.getEdge(e):e;if(s!=null){let a=Object.assign({},s.data);if(t)if(o)s.data=Object.assign({},t);else for(let l in t)s.data[l]==null?s.data[l]=t[l]:rE(s.data,l,t[l]);this.Sd(a,s),this.fire(pt,{edge:s,updates:t||{},originalData:a,reason:n},null)}}update(e,t){this.cn(e,t,null,!1)}cn(e,t,n,o){if(K(e)){let s=n==null?sS:n;this.$_updateVertex(e,t,s,o)}else if(Y(e)){let s=n==null?aS:n;this.$_updateVertex(e,t,s,o)}else if(Ke(e)){let s=n==null?lS:n;this.$_updateEdge(e,t,s,o)}else if(H(e)){let s=n==null?nu:n;this.$_updatePort(e,t,s,o)}}setEdgeGeometry(e,t,n,o){n=ot(n||e.geometry),e.geometry=ot(t),this.fire(ri,{edge:e,geometry:t,originalGeometry:n,ui:o}),this.L(s=>{s.$edgeGeometryUpdated(e,t,n)})}clearEdgeGeometry(e){this.setEdgeGeometry(e,null,null,null)}getPath(e){return new Sl(this,e)}findGraphObject(e){return e==null?null:e==="*"?this.graph:e.constructor===de||e.constructor===me||e.constructor===le||e.constructor===Fe?e:z(e)||dr(e)?this.graph.getVertex(e):null}Jo(e,t,n,o){return t||n.clear(),n.append(e,s=>{let a={obj:s,selection:n};o&&(this.L(l=>{l.$select(a)}),this.fire(mr,a))})}lE(e,t,n){e=e||{};let o=[],s={},a=h=>{s[h.getId()]||(o.push(h),s[h.getId()]=!0)},l=(h,d,u,p)=>{if(h!=null){let m;Ke(h)?m=[h]:m=t(h),e.filter&&(m=m.filter(e.filter));for(let g=0;g<m.length;g++){let E=d&&h===this.graph||m[g].source===h||n&&H(m[g].source)&&m[g].source.getParent()===h,y=u&&h===this.graph||m[g].target===h||n&&H(m[g].target)&&m[g].target.getParent()===h;(d&&E||u&&y||p&&(E||y))&&a(m[g])}}};return l(this.findGraphObject(e.source),!0,!1,!1),l(this.findGraphObject(e.target),!1,!0,!1),l(this.findGraphObject(e.element),!1,!1,!0),o}Sd(e,t){let n=t.objectType===Fe.objectType?this.edgeTypeProperty:t.objectType===me.objectType?this.portTypeProperty:this.typeProperty;if(t.data[n]!=null&&t.data[n]!==e[n]){let o=t.data[n],s=e[n];t.type=o,this.$dispatchTypeChange(t,s,o)}}Ad(e,t,n,o,s){if(e&&e.objectType){let a=Object.assign({},e.data),l=e.objectType===me.objectType?e.getFullId():e.id,h=e.objectType===me.objectType?this.portIdFunction(a):null,d;if(t){if(n)e.data=Object.assign({},t);else for(let p in t)rE(e.data,p,t[p]);e.objectType===me.objectType&&(d=this.portIdFunction(e.data),d!==e.id&&this.graph.renamePort(e,d),this.Zo(e.getParent(),nu))}let u=s(e,a);u.originalId=l,h!=null&&(u.originalPortId=h),this.L(p=>p.$vertexUpdated(u)),this.Sd(a,e),this.fire(o,u,null)}}Zo(e,t){if(this.portUpdater!=null){let n=this.portUpdater(e.data,e,e.getPorts());if(n!=null&&(e.data=n,!this.Da)){let o=Y(e)?Re:$e,s={vertex:e,updates:{},originalData:e.data,reason:t};this.L(a=>a.$vertexUpdated(s)),this.fire(o,s)}}}getEdges(e){return this.lE(e,t=>t.getEdges(),!1)}getAllEdges(){return this.graph.getAllEdges()}getAllEdgesFor(e,t){return e.getAllEdges(t)}selectAllEdges(){return this.filter(Ke)}addAllEdgesToSelection(){this.addToSelection(this.getAllEdges())}setSelection(e){let t=this.yi(e);this.Jo(t,!1,this.pe,!0)}select(e,t){let n=this.ko(),o=this.yi(e),s=this.Jo(o,!0,n);if(t)for(let a=0;a<s[0].length;a++){let l=s[0][a];if(K(l||Y(l)||H(l))){let h=l.getAllEdges();for(let d=0;d<h.length;d++)n.append(h[d])}}return n}Td(e,t,n,o){let s=e.getAllEdges();for(let a=0,l=s.length;a<l;a++)if(s[a].source===e){let h=s[a].target,d=h.getFullId();o[d]||(t.append(h),n&&t.append(s[a]),o[d]=!0,this.Td(h,t,n,o))}}selectDescendants(e,t,n){let o=this.getObjectInfo(e),s=this.ko();if(o.obj&&o.obj.objectType===de.objectType){t&&this.Jo(o.obj,!0,s);let a={};a[o.obj.getFullId()]=!0,this.Td(o.obj,s,n,a)}return s}yi(e){return e instanceof Sl||e instanceof Er?e:z(e)?this.getVertex(e)||this.getEdge(e):Array.isArray(e)?e.map(t=>z(t)?this.getVertex(e)||this.getEdge(e):t):e}addToSelection(e){let t=this.yi(e);if(t){let n=this.Jo(t,!0,this.pe,!1);n[1]!=null&&n[1].length>0&&this.xi(!1,n[1]),n[0]!=null&&n[0].length>0&&this.xi(!0,n[0])}}xi(e,t){let n=e?mr:gr;for(let o=0;o<t.length;o++){let s={obj:t[o],selection:this.pe};this.L(a=>{e?a.$select(s):a.$deselect(s)}),this.fire(n,s)}}toggleSelection(e){let t=this.yi(e);if(t){let n=[],o=this.pe.toggle(t,(s,a)=>{a||n.push(s)});this.xi(!1,o[1]),this.xi(!1,n),this.xi(!0,o[0])}}removeFromSelection(e){let t=this.yi(e);t&&this.pe.remove(t,n=>{let o={obj:n,selection:this.pe};this.L(s=>{s.$deselect(o)}),this.fire(gr,o)})}addPathToSelection(e){this.addToSelection(this.getPath(e))}clearSelection(){this.pe.clear()}getSelection(){return this.pe}setMaxSelectedNodes(e){this.pe.setMaxNodes(e)}setMaxSelectedEdges(e){this.pe.setMaxEdges(e)}setSelectionCapacityPolicy(e){this.pe.setCapacityPolicy(e)}cE(e){this.fire(e),this.Da=!1}vd(e,t,n){e=e||{};let o=e.type||"json",s=e.data,a=e.url,l=e.jsonp,h=e.onload,d=e.parameters||{},u=e.error||function(m){};if(s==null&&a==null)throw new TypeError("You must supply either data or url to load.");let p=m=>{e.incremental===!1&&this.clear(),this.Da=!0,t===Po?(this.undoRedo&&this.undoRedo.dataLoadStart(),this.L(g=>g.$dataLoadStart())):t===AE&&(this.undoRedo&&this.undoRedo.dataAppendStart(),this.L(g=>g.$dataAppendStart())),this.fire(t),Fb(o,m,this,d),this.cE(n),h&&h(this,m),this.fire(bA),n===Mr?(this.L(g=>g.$dataLoadEnd()),this.undoRedo&&this.undoRedo.dataLoadEnd()):n===SE&&(this.L(g=>g.$dataAppendEnd()),this.undoRedo&&this.undoRedo.dataAppendEnd())};if(s)p(s);else if(a){if(l){let E=a.indexOf("?")===-1?"?":"&";a=a+E+"callback=?"}let m=o===Xt||o===lE?Xt:e.dataType,g=e.headers||{Accept:"application/json"};this.fetchUrl({url:a,success:p,dataType:m,error:u,headers:g})}return this}load(e){return this.vd(e,Po,Mr)}append(e){return this.vd(e,AE,SE)}save(e){if(e==null){U("VisuallyJs: save method requires at least URL parameter - no params given.");return}if(e.url==null){U("VisuallyJs: save method requires at least URL parameter");return}let t=e.data||this.exportData(e),n={"Content-Type":"application/json"};Object.assign(n,e.headers||{}),this.fetchUrl({url:e.url,type:"POST",data:t,success:e.success||function(o){},error:e.error||function(o){},headers:n})}exportData(e){return e=e||{},hE(e.type||Xt,this,e.parameters)}toJSON(){return hE(Xt,this,{})}getRenderer(e){return this.Jt.get(e)}getRenderers(){return this.Jt}L(e,t){this.Jt.forEach((n,o)=>{if(t==null||t!==n)try{e(n,o)}catch(s){U("WARN: could not invoke renderer "+o+" ["+s+"]")}})}$addRenderer(e,t){t=t||V(),this.Jt.set(t,e),e.id=t,e.onDestroy(n=>{this.Jt.delete(n.id)}),this.fire(SA,{renderer:e,id:t})}getObjectInfo(e){let t={obj:null,type:null,id:null};if(e!=null){if(typeof e=="string")e=this.getNode(e)||this.getGroup(e)||this.getPort(e)||this.getEdge(e);else if(typeof e=="object"&&typeof e.objectType=="undefined"){let n=this.idFunction(e),o=this.edgeIdFunction(e);e=this.getNode(n)||this.getGroup(n)||this.getEdge(o)}if(e!=null)t.obj=e;else return t;t.obj!=null&&(t.id=t.obj.id,t.type=t.obj.objectType)}return t}undo(){this.undoRedo&&(this.undoRedo.undo(),this.fire(TA,{undoCount:this.undoRedo.undoStack.length,redoCount:this.undoRedo.redoStack.length}))}redo(){this.undoRedo&&(this.undoRedo.redo(),this.fire(vA,{undoCount:this.undoRedo.undoStack.length,redoCount:this.undoRedo.redoStack.length}))}transaction(e,t){return this.undoRedo?this.undoRedo.transaction(e,t):null}$transaction(e,t,n){return this.undoRedo?this.undoRedo.transaction(e,t,n):null}mergeTransaction(e){return this.undoRedo?this.undoRedo.mergeTransaction(e):null}openTransaction(e){return this.undoRedo?this.undoRedo.openTransaction(e):null}rollbackTransaction(){this.undoRedo&&this.undoRedo.rollbackTransaction()}commitTransaction(e){this.undoRedo&&this.undoRedo.commitTransaction(e)}flushUndoRedo(){this.undoRedo&&this.undoRedo.clear()}get version(){return ru}$_deriveEdgeId(e){return e==null?V():typeof e=="string"?e:this.edgeIdFunction(e)||V()}};var f6="csv";function pS(i){let r=[],e="",t=!1;for(let n=0;n<i.length;n++){let o=i[n],s=i[n+1];t?o==='"'&&s==='"'?(e+='"',n++):o==='"'?t=!1:e+=o:o==='"'?t=!0:o===","?(r.push(e),e=""):e+=o}return r.push(e),r}var wE=class{constructor(r,e){c(this,"csv");c(this,"lines");c(this,"startLine");c(this,"headers");this.csv=r,this.lines=r.split(/\r?\n/).map(t=>t.trim()),e=e||{},this.startLine=e.skipLines!=null?e.skipLines:e.readHeaders?1:0,e.readHeaders?this.lines[0]&&this.lines[0].length>0&&(this.headers=pS(this.lines[0])):this.headers=e.headers}Cd(r){for(let e=this.startLine;e<this.lines.length;e++){let t=this.lines[e].trim();if(t.length===0)continue;let n=pS(t);r(n)}}readLines(r){this.Cd(e=>r(e))}readRecords(r){this.Cd(e=>{let t={};for(let n=0;n<e.length;n++){let o=this.headers?this.headers[n]||`Field ${n+1}`:`Field ${n+1}`;t[o]=e[n]}r(t)})}},mS=(i,r,e)=>{e=e||{};let t=e.nodeDecorator||(l=>l),n=e.edgeDecorator||(l=>l),o=new Map,s=[];new wE(i,{readHeaders:e.readHeaders!==!1,headers:e.readHeaders===!1?["source","target","value"]:null}).readRecords(l=>{o.has(l.source)||o.set(l.source,t({id:l.source},!0)),o.has(l.target)||o.set(l.target,t({id:l.target},!1)),s.push({source:l.source,target:l.target,data:n({value:parseFloat(l.value)},o.get(l.source),o.get(l.target))})}),s.sort((l,h)=>h.data.value-l.data.value),Array.from(o.values()).forEach(l=>r.addNode(l)),s.forEach(l=>r.addEdge(l))};function gS(i){return i.eachNode!=null&&i.eachEdge!=null&&i.eachGroup!=null&&i.filter!=null}function ES(i,r){return r?i:i.toLowerCase()}function g0(i){i=""+i;let r=i.split(/\s/),e=[],t=[],n=4;for(let o=0;o<r.length;o++){let s=bt(r[o].replace(/[^\w]*/,""));s.length>0&&(e.push({token:s,context:""}),t.unshift(s),t.splice(n-1),t.length>1&&(t.reverse(),e.push({token:t.join(" "),context:""}),t.reverse()))}for(t.pop();t.length>1;)t.reverse(),e.push({token:t.join(" "),context:""}),t.reverse(),t.pop();return e}var E0=g0;function z6(i){return i=bt(i),[{token:i.replace(/\s/g,"_"),context:i}]}function f0(i){return[{token:bt(i),context:i}]}function y0(i,r){return i.score>r.score?-1:1}var x0=i=>i.id;function b0(i,r,e){if(i.length===0){i.push(r);return}let t=(n,o)=>{let s=n+Math.floor((o-n)/2),a=i[s],l=e(a,r),h;if(l===0){i.splice(s,0,r);return}else if(l===-1){if(s===i.length-1){i.push(r);return}else if(h=e(i[s+1],r),h!==l){i.splice(s+1,0,r);return}t(s+1,o)}else{if(s===0){i.unshift(r);return}else if(h=e(i[s-1],r),h!==l){i.splice(s,0,r);return}t(n,n+Math.floor((o-n)/2))}};t(0,i.length-1)}var A0=10,Ks=class{constructor(r){c(this,"fields");c(this,"root");c(this,"tokenizer");c(this,"searchTokenizer");c(this,"limit");c(this,"exclusions");c(this,"caseSensitive");c(this,"idFunction");c(this,"sorter");c(this,"Od",0);c(this,"bi",new Map);c(this,"Gr",[]);c(this,"Ko",0);c(this,"Le",{});r=r||{},this.fields=r.fields,this.root=this.Ma(),this.tokenizer=r.tokenizer||E0,this.searchTokenizer=r.searchTokenizer||f0,this.limit=r.limit||A0,this.exclusions=r.exclusions||[],this.caseSensitive=r.caseSensitive===!0,this.idFunction=r.idFunction||x0,this.sorter=r.sorter||y0}Ma(r){return{index:this.Od++,children:{},documentIds:{},key:r}}hE(r,e,t){let n=this.Le[r];n||(n={},this.Le[r]=n),n[e.index]=e}dE(r,e,t){let n=(o,s,a,l)=>{if(s!==a.length){var h=a[s],d=o.children[h];d||(d=this.Ma(h),o.children[h]=d),d.documentIds[l]=d.documentIds[l]||[],d.documentIds[l].push(a),this.hE(l,d,t),n(d,s+1,a,l)}};n(this.root,0,r,e)}removeExclusions(r){let e={};for(let t in r)this.exclusions.indexOf(t)===-1&&(e[t]=r[t]);return e}add(r){let e=t=>{let n=this.removeExclusions(t);b0(this.Gr,{document:n,score:1},this.sorter);var o=this.idFunction(t),s={fields:a=>{for(let l=0;l<this.fields.length;l++){let h=t[this.fields[l]];typeof h=="string"&&a(h)}},document:a=>{for(let l in t)if(l!=="id"){let h=t[l];typeof h=="string"&&a(h)}}};this.bi.set(o,n),s[this.fields?"fields":"document"](a=>{if(a){let l=this.tokenizer(a);for(let h=0;h<l.length;h++)this.dE(ES(l[h].token,this.caseSensitive),o,l[h].context)}}),this.Ko++};if(r.constructor===Array)for(let t=0;t<r.length;t++)e(r[t]);else e(r)}addAll(...r){for(let e=0;e<r.length;e++)this.add(r[e])}reindex(r){this.remove(r),this.add(r)}remove(r){let e=this.idFunction(r),t=this.Le[e],n;if(t)for(n in t)delete t[n].documentIds[e];let o=-1;for(n=0;n<this.Gr.length;n++)if(this.idFunction(this.Gr[n].document)===e){o=n;break}o!==-1&&(this.Gr.splice(o,1),this.Ko=this.Gr.length),this.bi.delete(e)}clear(){this.bi.clear(),this.Le={},this.Od=0,this.Gr.length=0,this.Ko=0,this.root=this.Ma()}getDocumentCount(){return this.Ko}getDocumentList(){return this.Gr}getDocument(r){return this.bi.get(r)}search(r,e){let t=this.searchTokenizer(r),n={},o=[],s={},a={},l=(d,u,p)=>{let m=n[d];m||(m={},n[d]=m,s[d]=0,a[d]=[]),a[d].push(p),m[u]||(m[u]=!0,s[d]++)},h=(d,u,p)=>{if(u===p.length){for(let g in d.documentIds)if(d.documentIds.hasOwnProperty(g)){let E=d.documentIds[g];for(let y=0;y<E.length;y++)l(g,p,E[y])}return}let m=p[u];d.children[m]&&h(d.children[m],u+1,p)};for(let d=0;d<t.length;d++)h(this.root,0,ES(t[d].token,this.caseSensitive));for(let d in n)o.unshift({document:this.bi.get(d),score:s[d],contexts:a[d]});return o.sort(this.sorter),o.slice(0,e==null?this.limit:e)}},fS=class{constructor(r,e){this.instance=r;c(this,"nodeIndex");c(this,"groupIndex");c(this,"edgeIndex");c(this,"portIndex");this.nodeIndex=new Ks(e),this.groupIndex=new Ks(e),this.edgeIndex=new Ks(e),this.portIndex=new Ks(e),r.bind(kt,t=>{this.Pd(t.node)}),r.bind(Le,t=>{this.nodeIndex.remove(t.node.data),t.node.getPorts().forEach(n=>this.portIndex.remove(n.data))}),r.bind($e,t=>{this.nodeIndex.remove(t.vertex.data),this.nodeIndex.add(t.vertex.data)}),r.bind(jt,t=>{this._d(t.group)}),r.bind(Ge,t=>{this.groupIndex.remove(t.group.data)}),r.bind(Re,t=>{this.groupIndex.remove(t.vertex.data),this.groupIndex.add(t.vertex.data)}),r.bind(pr,t=>{this.Rd(t.edge)}),r.bind(mt,t=>{this.edgeIndex.remove({id:t.edge.getId()})}),r.bind(pt,t=>{let n=Object.assign(t.originalData||{},{id:t.edge.getId()});this.edgeIndex.remove(n);let o=Object.assign(t.edge.data||{},{id:t.edge.getId()});this.edgeIndex.add(o)}),r.bind(ei,t=>{this.portIndex.add(t.port.data)}),r.bind(Vr,t=>{this.portIndex.remove(t.port.data)}),r.bind(ur,t=>{this.portIndex.remove(t.port.data),this.portIndex.add(t.port.data)}),r.bind(Ht,()=>{this.nodeIndex.clear(),this.groupIndex.clear(),this.edgeIndex.clear(),this.portIndex.clear()}),this.instance.eachNode((t,n)=>{this.Pd(n)}),this.instance.eachGroup((t,n)=>{this._d(n)}),this.instance.eachEdge((t,n)=>{this.Rd(n)})}Pd(r){this.nodeIndex.add(r.data),r.getPorts().forEach(e=>this.portIndex.add(e.data))}_d(r){this.groupIndex.add(r.data)}Rd(r){let e=Object.assign(r.data||{},{id:r.getId()});this.edgeIndex.add(e)}search(r){let e=this.nodeIndex.search(r).map(s=>this.instance.getNode(s.document.id)),t=this.portIndex.search(r).map(s=>this.instance.getPort(s.document.id)),n=this.groupIndex.search(r).map(s=>this.instance.getGroup(s.document.id)),o=this.edgeIndex.search(r).map(s=>this.instance.getEdge(s.document.id));return{nodes:e,groups:n,edges:o,ports:t}}};var yS="context",DE="lookup",xS="default",ii="element",Ii="text",No="tmpl",oi="each",Gl="if",bS="root",AS="class",SS="style",Io="$value",$l="$key",TS="attribute";function NE(i,r){if(i==null)return i;{let e=i.replace(/\n/g,"").replace(/^[\s]+</,"<").replace("/>",">").replace(/>[\s]+$/,">").split(/^<|>$/)[1].split(r);return vb(e)}}function CS(i){return i.length>0?i[i.length-1]:null}function PS(i){if(i==null||i.length===0)return!1;for(let r=i.length-1;r>-1;r--)if(i[r].type==="each")return!0;return!1}function IE(i,r,e,t,n){let o=V(),s={w:r,expressions:[],id:o};return e.bindings[i]=s,r.replace(/\{\{([^\}]*)\}\}/g,(a,l,h,d)=>{let u=!1;return l.startsWith(":")&&(u=!0,l=l.substring(1)),s.expressions.push([a,l,u]),""}),o}function vS(i,r,e,t,n){e.atts[i]=r,IE(i,r,e,t,n)}function OS(i,r){let e=NE(i,r.attributesRe),t={el:bt(e[0]),atts:{},bindings:{}},n=(o,s)=>{let a=o.match(/([^=]+)=['"](.*)['"]/);return a==null&&s==null?t.atts[o]="":a==null?vS(o,"",t,s,r):vS(a[1],a[2],t,s,r),a};for(let o=1;o<e.length;o++){let s=bt(e[o]);s!=null&&s.length>0&&n(s)}return t}var S0=["*","-","+","/","%"],_S=["==",">","<",">=","<=","===","!=","!==","||"],T0=/([(])|([)])|(===)|(==)|(!==)|(!=)|(!{1,2})|(\|\|)|(<=)|(>=)|(<)|(>)|(\+)|(-)|(\*)|(\/)|(\s+)|([0-9\.]+)|(\$data\[[0-9]+\])|(\$value\[[0-9]+\])|(\$key)|(\$value)|('[^']+')|([#a-zA-Z\$]+[0-9a-zA-Z_\$\.]*)/g,Bl="bool",RS="num",LS="group",wS="var",v0="op",ME="comp",DS="exp",NS="string",IS="array",MS="key",VS="value";function C0(i){return i[i.length-1]}function GS(i){return i.t===LS}function P0(i){return i.t===wS}function O0(i){return i.t===DS}function _0(i){return i.t===RS}function R0(i){return i.t===Bl}function L0(i){return i.t===NS}function w0(i){return i.t===IS}function D0(i){return i.t===MS}function N0(i){return i.t===VS}function I0(i){let r=i.match(T0),e,t=[{t:"root",c:[],e:i,v:null}];for(let n=0;n<r.length;n++){e=r[n];let o=C0(t);if(e==="("){let s={t:LS,c:[],v:null};o.c.push(s),t.push(s)}else if(e===")")t.pop();else if(e.match(/\$value\[[0-9]+\]/)){let s=parseInt(e.substring(7,e.length-1),10);o.c.push({t:IS,v:e,index:s})}else if(e.match(/\$key/))o.c.push({t:MS,v:null});else if(e.match(/\$value/))o.c.push({t:VS,v:null});else if(e.match(/^#/))o.c.push({t:DS,v:e.substring(1)});else if(e.match(/'[a-zA-Z0-9#_\$\.]+'/))o.c.push({t:NS,v:e.replace(/'/g,"")});else if(e.match(/true/))o.c.push({t:Bl,v:!0});else if(e.match(/false/))o.c.push({t:Bl,v:!1});else if(e.match(/^[0-9\.]+$/)){let s=e.indexOf(".")!==-1?parseFloat(e):parseInt(e,10);o.c.push({t:RS,v:s})}else e.match(/[a-zA-Z_\$\.]+/)?o.c.push({t:wS,v:e}):S0.indexOf(e)!==-1?o.c.push({t:v0,v:e}):_S.indexOf(e)!==-1?o.c.push({t:ME,v:e}):e.match(/!{1,2}/)&&(e.length===1?(o.c.push({t:Bl,v:!1}),o.c.push({t:ME,v:"=="})):(o.c.push({t:Bl,v:!1}),o.c.push({t:ME,v:"!=="})))}return t[0]}function M0(i){let r=null,e={t:"root",c:[],v:""},t={t:"root",c:[],v:""},n=e.c;for(let a=0;a<i.c.length;a++)if(_S.indexOf(i.c[a].v)!==-1){if(r!=null)throw new Error("Cannot parse expression; more than one comparator.");r=i.c[a].v,n=t.c}else n.push(i.c[a]);let o=a=>(GS(a)&&(a.c=s(a)),a),s=a=>{let l=a.c;if(l.length===0)return[];let h=[],d=o(l[0]);if(l.length===1)return[d];if(l.length===3)return[d,l[1],o(l[2])];{let u=d,p=null,m;for(let g=1;g<l.length;g+=2)m=l[g],(m.v==="+"||m.v==="-"?1:2)===2?p==null?(p={t:"group",c:[u,m],v:null},h.push(p)):p.c.push(u,m):(p!=null?p.c.push(u):h.push(u),p=null,h.push(m)),u=o(l[g+1]);return p!=null?p.c.push(u):h.push(u),h}};return e.c=s(e),t.c=s(t),{left:e,right:t,comparator:r}}function Fl(i){let r=I0(i);return M0(r)}function Mi(i,r,e,t,n){let o=VE(i.left.c,r,e,t,n);if(i.comparator==null)return o;{let s=VE(i.right.c,r,e,t,n);if(i.comparator==="==")return o==s;if(i.comparator==="===")return o===s;if(i.comparator===">")return o>s;if(i.comparator===">=")return o>=s;if(i.comparator==="<")return o<s;if(i.comparator==="<=")return o<=s;if(i.comparator==="!=")return o!=s;if(i.comparator==="!==")return o!==s;if(i.comparator==="||")return o||s}}function VE(i,r,e,t,n){let o=i.map(l=>GS(l)?VE(l.c,r,e,t,n):P0(l)?r(l.v):O0(l)?e(l.v):w0(l)?r(Io)[l.index]:D0(l)?r($l):N0(l)?r(Io):_0(l)||L0(l)||R0(l)?l.v:l),s=o[0],a;for(let l=1;l<o.length;l+=2){a=o[l].v;let h=o[l+1];a==="+"?s+=h:a==="-"?s-=h:a==="*"?s*=h:a==="/"&&(s/=h)}return typeof s=="undefined"?"":n!=null?n(s,t):s}var Vi=class{constructor(r){this.instance=r;c(this,"tag");c(this,"remove");c(this,"uuid");c(this,"children",[]);c(this,"elements",[]);c(this,"bindings");c(this,"context");c(this,"compiledBindings");this.uuid=V(),r.entries[this.uuid]=this,this.compiledBindings={}}Ld(r){for(let e in r){let t=r[e];t.expressions.length>0&&(this.compiledBindings[e]={id:V(),name:e,expressions:t.expressions.map(([n,o,s])=>{let[a,l]=o==null?[null,null]:o.split(":");return{source:n,expression:Fl(a),once:s,format:l}})})}}};var su=class su extends Vi{constructor(e,t){super(t);c(this,"type","text");c(this,"value");this.value=e.value,this.bindings={};let n={id:V(),w:e.value,expressions:[]};e.value.replace(/\{\{([^\}]*)\}\}/g,function(o,s,a,l){let h=!1;return s.startsWith(":")&&(h=!0,s=s.substring(1)),n.expressions.push([o,s,h]),""}),this.Ld({[su.TEXT_BINDING_NAME]:n})}};c(su,"TEXT_BINDING_NAME","__element");var Gi=su;var au=class au extends Vi{constructor(e,t){super(t);c(this,"type",au.type);c(this,"comment");this.comment=e}};c(au,"type","comment");var qs=au;var lu=class lu extends Vi{constructor(e,t,n,o,s){super(t);this.templateResolver=n;this.stack=o;this.parseIdStack=s;c(this,"type",lu.type);c(this,"namespace");c(this,"atts");c(this,"custom");let a=e.el.split(":");this.tag=e.el,a.length===2&&(this.namespace=a[0]),this.atts=e.atts,this.Ld(e.bindings),this.remove=!1}};c(lu,"type",ii);var Ur=lu;var GE={},si={construct:(i,r,e,t,n,o)=>{let s=GE[i];if(s)return new s(r,e,t,n,o);throw{message:"Recado: unknown element '"+i+"'"}},register:(i,r)=>{GE[i]=r},exists:i=>GE[i]!=null};var cu=class cu extends Ur{constructor(e,t,n,o,s){super(e,t,n,o,s);c(this,"key");c(this,"type",oi);this.context=e.atts.in,this.key=e.atts.key,this.tag=cu.tag}};c(cu,"tag","r-each");var hu=cu;si.register(hu.tag,hu);function $E(i,r,e){i.entryMap[r]=i.entryMap[r]||[],i.entryMap[r].push(e)}function $S(i,r,e,t){for(let n=0;n<r.children.length;n++){let o=r.children[n];$E(i,e,o)}Array.from(r.fragment.childNodes).forEach(n=>t.added.push({el:n})),i.placeholder.before(r.fragment)}var du=class{constructor(r,e,t){this.instance=r;this.tagName=e;this.options=t;c(this,"id");c(this,"template");c(this,"rendered");c(this,"updated");c(this,"fragments",{});c(this,"mounted");c(this,"defaultableFragmentKeys");c(this,"fragmentKeys");c(this,"parsedTemplates",{});c(this,"defaultNamespace");c(this,"decorator");this.id=`custom-${e}`;let n=t.fragments||{};this.defaultableFragmentKeys=t.defaultableFragmentKeys||[],this.template=t.template,this.defaultNamespace=t.defaultNamespace,this.decorator=t.decorator||((s,a)=>null);let o=new Set;for(let s in n){this.fragments[s]=this.fragments[s]||{},o.add(s);for(let a in n[s]){let l=`custom-${e}-${s}-${a}`,h=n[s][a];r.addTemplate(l,h),this.fragments[s][a]=r.parseAndCache(l,d=>{if(d===l)return h})}}this.fragmentKeys=Array.from(o),this.fragmentKeys.sort(),this.parsedTemplates[xe]=this.wd(this.id),this.rendered=t.rendered||function(s,a,l){},this.updated=t.updated||function(s,a,l){},this.mounted=t.mounted}wd(r){return this.instance.parseAndCache(r,e=>{if(e===r)return this.template})}extractTemplateData(r,e){let t=r.split(":"),n=[];for(let o=0;o<t.length;o++){let s=e[t[o]];if(s==null)if(this.defaultableFragmentKeys.indexOf(t[o])!==-1)n.push(xe);else return null;else n.push(s)}return n.join(":")}getAST(r){if(r==null)return this.parsedTemplates[xe];{let e=[],t={};if(this.fragmentKeys.forEach(n=>{let o=this.extractTemplateData(n,r);o!=null&&(t[n]=this.fragments[n][o]||[],e.push(`${n}:${o}`))}),e.length>0){let n=e.join(" ");if(this.parsedTemplates[n]!=null)return this.parsedTemplates[n];{let o=this.wd(n);return this.Dd(o[0],t),this.parsedTemplates[n]=o,o}}return this.parsedTemplates[xe]}}Dd(r,e){let t=[];for(let n=0;n<r.children.length;n++)if(r.children[n].tag==="r-fragment"){let o=e[r.children[n].atts.key]||[];t.push(...o)}else t.push(r.children[n]),this.Dd(r.children[n],e);r.children=t}};function BS(i,r,e,t){t?i.el.style[r]=e:i.el.setAttribute(r,e)}function V0(i,r){i.el.nodeValue=r}function G0(i,r){let e=[];for(let t=0;t<r.children.length;t++)e.push(...Ul(i,r.children[t]));return e}function Ul(i,r){let e=G0(i,r);return r.type===ii?(i.removeElement(r.el),e.unshift(r.el)):r.type===Ii?(i.removeTextNode(r.el),e.unshift(r.el)):r.type===oi&&(r.entryMap={}),e}function FS(i,r,e,t){for(let n in i.bindings)if(n!==AS){let o=i.bindings[n],s=o.binding,a=o.originalValue,l=!1;for(let h=0;h<s.expressions.length;h++)if(!s.expressions[h].once){let d=Mi(s.expressions[h].expression,r,u=>e(u),s.expressions[h].format,t);a=a.replace(s.expressions[h].source,d),d!==o.results[h].result&&(l=!0,o.results[h].result=d)}l&&(i.type===ii?n!==SS?BS(i,n,a,!1):a.split(";").forEach(h=>{let d=h.indexOf(":"),u=h.substring(0,d);BS(i,u,h.substring(d+1),!0)}):i.type===Ii&&V0(i,a))}}function US(){return{added:[],removed:[],elements:[]}}var pu=class pu extends Ur{constructor(e,t,n,o,s){super(e,t,n,o,s);c(this,"type","if");c(this,"tag",pu.tag);c(this,"test");c(this,"expression");this.test=e.atts.test,this.expression=Fl(this.test)}};c(pu,"tag","r-if");var uu=pu;si.register(uu.tag,uu);function BE(i,r,e,t,n){return i.resolution=Mi(i.entry.expression,o=>Oe(r,o),o=>e(o),t,n),i.resolution}var Mo=class extends Ur{constructor(e,t,n,o,s){super(e,t,n,o,s);c(this,"templateId");c(this,"lookup");c(this,"default");if(this.context=e.atts[yS],this.type=No,this.remove=!0,e.atts[DE])this.lookup=e.atts[DE],this.default=e.atts[xS]||"";else{this.templateId=e.atts.id;let a=PS(o);if(s.indexOf(this.templateId)!==-1){if(!a)throw new TypeError("recursive template call ["+this.templateId+"]")}else{let l=n(this.templateId);s.push(this.templateId);let h=this.instance.parse(l,n,null,s);for(let d=0;d<h.length;d++)h[d].context=this.context;this.children=h,s.pop()}}}};c(Mo,"tag","r-tmpl"),si.register(Mo.tag,Mo);function YS(i,r){if(Array.isArray(i))for(let e=0;e<i.length;e++)r(i[e],e);else if(dr(i)){let e=i;for(let t in e)r(e[t],t)}}var Vo=class{constructor(r){c(this,"templateResolver");c(this,"defaultTemplate");c(this,"defaultNamespace");c(this,"macros");c(this,"entries");c(this,"customTags",{});c(this,"formatter");c(this,"Tt",new Map);c(this,"Ai",new Map);c(this,"openRe",new RegExp("<([^/>]*?)>$|<([^/].*[^/])>$"));c(this,"closeRe",new RegExp("^</([^>]+)>"));c(this,"openCloseRe",new RegExp("<(.*)(/>$)"));c(this,"tokenizerRe",/(<[^\^>]+\/>)|(<!--[\s\S]*?-->)|(<[\/a-zA-Z0-9\-:]+(?:\s*[\(a-zA-Z\-\):]+=\"[^\"]*\"|\s*[a-zA-Z\-:]+='[^']+'|\s*[\(a-zA-Z\-\):]|\s*\{\{.*\}\}|\s*\{#.*\})*>)/);c(this,"commentRe",/<!--[\s\S]*?-->/);c(this,"attributesRe",/([\(a-zA-Z0-9\-_:\)]+="[^"]*")|\s+([\(a-zA-Z0-9\-_:\)]+(?=\s.|$))/);c(this,"qo");c(this,"namespaceHandlers",{});c(this,"namespaces",{});r=r||{},this.qo=r.templates||{},this.entries={},this.defaultTemplate=r.defaultTemplate,this.templateResolver=r.templateResolver||this.Nd(),this.macros=r.templateMacros||{},this.formatter=r.formatter,this.defaultNamespace=r.defaultNamespace}resolveTemplate(r){return this.qo[r]!=null?this.qo[r]:this.templateResolver(r)}setAttribute(r,e,t){let n=e.split(":");n.length===1?r.setAttribute(n[0],t):this.namespaces[n[0]]==null?r.setAttribute(e,t):r.setAttributeNS(this.namespaces[n[0]],n[1],t)}clearCache(){this.Tt.clear(),this.Ai.clear()}parseAttributes(r){return NE(r,this.attributesRe)}Id(r,e){return t=>{let n=e?null:this.Tt.get(t);return n==null&&(n=r(t)),n==null&&(n=this.defaultTemplate),n!=null&&this.Tt.set(t,n),n}}getTemplate(r){return this.Ai.get(r)}addTemplate(r,e){this.qo[r]=e}template(r,e,t,n,o){e=e||{};let s=n?null:this.Ai.get(r);if(s!=null)return this.render(s,e,t,o).fragment;{let a=this.parseAndCache(r,t,n);return a!=null?this.render(a,e,t,o).fragment:this.cf()}}mounted(r){r.$recado.mountings.forEach(e=>{e.mount(e.el,e.data,this,e.parent,e.context)})}parseAndCache(r,e,t){let n=this.Ai.get(r);if(n==null||t===!0){e=this.Id(e||(s=>this.resolveTemplate(s)),t);let o=e(r);if(o!=null){let s=zS(this,o,e,null,[r]);return this.Ai.set(r,s),s}}else return n}data(r,e,t){return Oe(r,e,t)}each(r,e,t,n,o){let s;if(Array.isArray(r))for(s=0;s<r.length;s++)e(r[s],t,s,n,o);else for(s in r)r.hasOwnProperty(s)&&e({$key:s,$value:r[s]},t,s,n,o)}lookupValueInDataOrContext(r,e,t){return t.indexOf("$context.")===0?Oe(e,t.substring(9)):Oe(r,t)}update(r,e,t){let n=r.$recado,o=US();return t=t||{},n!=null&&this.xn(n,e,o,t),o}onUpdate(r,e){r.$recado!=null&&(r.$recado.updaters=r.$recado.updaters||[],r.$recado.updaters.push(e))}xn(r,e,t,n,o){if(r.type===bS)for(let s=0;s<r.children.length;s++)this.xn(r.children[s],e,t,n,o);else if(r.type===ii||r.type===Ii){let s=e,a=this.customTags[r.entry.tag];a!=null&&(s=Object.assign({},e),Object.assign(s,a.decorator(e,n)||{})),FS(r,l=>this.lookupValueInDataOrContext(s,n,l),l=>this.Si(l,s,n),this.formatter),a!=null&&a.updated&&a.updated(r.el,s,this);for(let l=0;l<r.children.length;l++)this.xn(r.children[l],s,t,n,o)}else if(r.type===Gl){let s=r,a=s.resolution,l=BE(s,e,h=>this.Si(h,e,n),null,this.formatter);if(!l){for(let h=0;h<r.children.length;h++)Ul(this,r.children[h]).map(d=>t.removed.push({el:d}));r.children.length=0}if(l)if(a)for(let h=0;h<r.children.length;h++)this.xn(r.children[h],e,t,n,s.defaultNamespace||o);else{let h=this.render(r.entry.children,e,this.templateResolver,n,s.defaultNamespace||o);r.children=h.children;for(let d=0;d<r.children.length;d++){let u=r.children[d];s.placeholder.before(u.el),t.added.push({el:u.el})}}}else if(r.type===No){let s=r.entry.context==null||r.entry.context.length===0?e:this.lookupValueInDataOrContext(e,n,r.entry.context);for(let a=0;a<r.children.length;a++)this.xn(r.children[a],s,t,n)}else if(r.type===oi){let s=r,a=this.lookupValueInDataOrContext(e,n,r.entry.context);if(a==null)Ul(this,r).map(l=>t.removed.push({el:l}));else if(s.entry.key==null||s.entry.key.length===0)U("WARN: Cannot update r-each entry when no `key` parameter was set.");else{let l={},h=[],d=[];YS(a,(u,p)=>{let m=Oe(u,s.entry.key);if(l[m]=u,s.entryMap[m]!=null){let g=s.entryMap[m];for(let E=0;E<g.length;E++)h.push({data:u,key:m,execution:g[E]})}else h.push({data:u,key:m})});for(let u in s.entryMap)if(l[u]==null)for(let p=0;p<s.entryMap[u].length;p++)d.push({e:s.entryMap[u][p],key:u});for(let u=0;u<d.length;u++)delete s.entryMap[d[u].key],Ul(this,d[u].e).map(p=>t.removed.push({el:p}));for(let u=0;u<h.length;u++){let p=h[u];if(p.execution)this.xn(p.execution,p.data,t,n),p.execution.el!=null?s.placeholder.before(p.execution.el):p.execution.children.forEach(m=>{m.el!=null&&s.placeholder.before(m.el)});else{let m=this.render(r.entry.children,p.data,null,n);$S(s,m,p.key,t)}}}}if(r.updaters)for(let s=0;s<r.updaters.length;s++)r.updaters[s](r.el);return t}remove(r,e){e&&r.parentNode&&r.parentNode.removeChild(r)}registerTag(r,e){this.customTags[r]=new du(this,r,e)}parse(r,e,t,n){return zS(this,r,e,t,n)}Si(r,e,t){return this.macros[r]&&this.macros[r](e,t)||""}render(r,e,t,n,o){let s={id:V(),fragment:this.cf(),children:[],type:"root",bindings:{},entry:null,mountings:[]},a=s.fragment,l=null,h=s;a.$recado=s,n=n||{};let d=(f,b,A)=>{let T={id:b,entry:f,placeholder:this.cc(`${oi}:${b}`),entryMap:{},type:oi,children:[]};return E(T.placeholder,A),h.children.push(T),T},u=(f,b,A)=>{let T={placeholder:this.cc(`${No}:${b}`),entry:f,id:b,children:[],type:No};return E(T.placeholder,A),h.children.push(T),T},p=(f,b,A,T)=>{y(f,T);let S={id:V(),entry:b,bindings:A,children:[],el:f,type:ii};return h.children.push(S),f.$recado=S,S},m=(f,b,A,T)=>{y(f,T);let S={id:V(),el:f,entry:b,bindings:A,children:[],type:Ii};return h.children.push(S),f.$recado=S,S},g=(f,b,A)=>{let T=V(),S={id:T,entry:f,resolution:!1,placeholder:this.cc(`${Gl}:${T}`),type:Gl,children:[],defaultNamespace:A};return E(S.placeholder,b),h.children.push(S),S},E=(f,b)=>{b!=null?b.before(f):l!=null?l.appendChild(f):a.appendChild(f)},y=(f,b)=>{b!=null?b.before(f):l!=null?l.appendChild(f):a.appendChild(f)},x=(f,b,A,T)=>{b=b||{};let S=!1,R=null;if(f.type===Gl){let v=h,O=g(f,A,o);if(h=O,S=BE(O,b,P=>this.Si(P,b,n),null,this.formatter),S)for(let P=0;P<f.children.length;P++)x(f.children[P],b,O.placeholder,T);h=v,R=O}else if(f.type===oi){let v=f,O=l,P=f.context===Io?b:this.lookupValueInDataOrContext(b,n,f.context),I=h,C=V(),_=d(v,C,A);h=_,P!=null&&YS(P,(w,B)=>{let D=v.key&&dr(w)?Oe(w,v.key):B||null;for(let M=0;M<f.children.length;M++){let N=x(f.children[M],w,_.placeholder,B);D!=null&&$E(_,D,N)}}),l=O,h=I,R=_}else if(f.type===No){let v=f,O=l,P=h,I=V(),C=u(v,I,A);h=C;let _=f.context==null||f.context.length===0?b:Oe(b,f.context),w=v.lookup!=null?Oe(b,v.lookup.replace(/[\{\{\}\}]/g,"")):v.templateId,B=this.parseAndCache(w,t);B==null&&v.default!=null&&(B=this.parseAndCache(v.default,t));for(let D=0;D<B.length;D++)x(B[D],_,C.placeholder,T);l=O,h=P,R=C}else if(f.type===ii){let v,O=f,P,I={},C=[];if(this.customTags[f.tag]!=null){P=this.customTags[f.tag];let D=Object.assign({},b);Object.assign(D,P.decorator(b,n)||{});let M=this.render(P.getAST(D),D,t,n,P.defaultNamespace);v=M.fragment.childNodes[0];let N=M.children[0].bindings;for(let G in N)I[G]=N[G];C.push(...M.children[0].children)}else if(O.namespace!=null&&this.namespaceHandlers[O.namespace])v=this.namespaceHandlers[O.namespace](f.tag);else{let D=o||this.defaultNamespace;D!=null&&this.namespaceHandlers[D]?v=this.namespaceHandlers[D](`${D}:${f.tag}`):v=this.ce(f.tag)}for(let D in O.atts)if(O.atts.hasOwnProperty(D)){let M=O.atts[D];if(f.compiledBindings[D]!=null){let N=f.compiledBindings[D];I[D]={id:N.id,binding:N,results:[],originalValue:M,type:TS};for(let G=0;G<N.expressions.length;G++){let J=N.expressions[G],Ee=Mi(J.expression,j=>j===$l?T:j===Io?b:this.lookupValueInDataOrContext(b,n,j),j=>this.Si(j,b,n),J.format,this.formatter);M=M.replace(J.source,Ee),I[D].results.push({source:J.source,result:Ee})}}this.setAttribute(v,D,M)}P&&(P.rendered&&P.rendered(v,b,this,l,n),P.mounted&&s.mountings.push({mount:P.mounted,el:v,data:b,parent:l,context:n}));let _=l,w=h,B=p(v,O,I,A);B.children.push(...C),h=B,l=v;for(let D=0;D<f.children.length;D++)x(f.children[D],b,null,T);h=w,l=_,R=B}else if(f.type===Ii){let v=f.value||"",O={},P=f.compiledBindings[Gi.TEXT_BINDING_NAME];if(P!=null){O[Gi.TEXT_BINDING_NAME]={id:P.id,binding:P,results:[],originalValue:v,type:Ii};for(let _=0;_<P.expressions.length;_++){let w=P.expressions[_],B=Mi(w.expression,D=>D===$l?T:D===Io?b:this.lookupValueInDataOrContext(b,n,D),D=>this.Si(D,b,n),w.format,this.formatter);v=v.replace(w.source,B),O[Gi.TEXT_BINDING_NAME].results.push({source:w.source,result:B})}}let I=this.ctn(v);R=m(I,f,O,A)}return R};for(let f=0;f<r.length;f++)x(r[f],e||{},null,null),l=null,h=s;return s}};function $0(i){return si.exists(i)}function B0(i,r,e,t,n,o){return si.construct(r,e,i,t,n,o)}function zS(i,r,e,t,n){n=n||[],e=i.Id(e||(E=>i.resolveTemplate(E)),null);let o=[],s=[],a=(E,y)=>{let x=E.match(y);return x==null?null:x},l=()=>o.length>0?o[o.length-1]:null,h=E=>{let y=l();return y!=null&&y.tag===E},d=(E,y)=>{o.length>0&&l().children.push(E),y?o.length===0&&s.push(E):o.push(E)},u=E=>{d(E,!0)},p=()=>{let E=o.pop();if(o.length===0&&!E.remove)s.push(E);else if(E.remove){let y=l();y&&y.children.pop()}return E},m=(E,y,x,f)=>{let b=OS(E,i);return $0(b.el)?B0(i,b.el,b,x,o,n):new Ur(b,i,x,o,n)},g=[{re:i.commentRe,handler:(E,y,x,f,b)=>{d(new qs(E,f),!0)}},{re:i.openRe,handler:(E,y,x,f,b)=>{let A=m(E,y,x,b);d(A,A.remove)}},{re:i.closeRe,handler:(E,y,x,f,b)=>{if(y[1]!==Mo.tag)if(h(y[1]))p();else throw new TypeError("Unbalanced closing tag '"+y[1]+"'; opening tag was '"+p().tag+"'")}},{re:i.openCloseRe,handler:(E,y,x,f,b)=>{let A=m(E,y,x,b);d(A,!0)}},{re:/.*/,handler:(E,y,x,f,b)=>{let A=new Gi({value:E},f);u(A),E.match(/^[\s]*$/)!=null||IE(Gi.TEXT_BINDING_NAME,E,A,null,f)}}];if(Cb(bt(r).split(i.tokenizerRe),(E,y)=>{let x=bt(y);for(let f=0;f<g.length;f++){let b=a(x,g[f].re);if(b){g[f].handler(y,b,e,i,n);break}}}),s.length>0&&t)for(let E in t)s[0][E]=t[E];return s}function XS(i,r){let e=typeof i=="string"?parseFloat(i):i;if(isNaN(e))return i;let t=/^(['|,])?(\.(\d+))?([df])$/,n=r.match(t);if(!n)return e.toString();let o=n[1],s=n[3]?parseInt(n[3],10):null,a=n[4],l;a==="d"?l=Math.floor(e).toString():l=s!==null?e.toFixed(s):e.toString();let h=l.split("."),d="";return o===","?d=",":o==="'"?d=" ":d=1e3.toLocaleString().substring(1,2),h[0]=h[0].replace(/\B(?=(\d{3})+(?!\d))/g,d),h.join(".")}var Yl=class{constructor(){c(this,"childNodes");this.childNodes=[]}removeChild(r){this.childNodes=this.childNodes.filter(e=>e!==r)}appendChild(r){this.childNodes.push(r)}insertAfter(r,e){let t=this.childNodes.indexOf(r);t!=null&&this.childNodes.splice(t,0,e)}insertBefore(r,e){let t=this.childNodes.indexOf(r);t!=null&&this.childNodes.splice(t-1,0,e)}toString(){let r="";for(let e=0;e<this.childNodes.length;e++)r+=this.childNodes[e].toString();return r}},mu=class extends Yl{constructor(e){super();c(this,"nodeType",1);c(this,"parentElement");c(this,"tag");c(this,"atts");c(this,"style",{});this.tag=e,this.atts={}}getAttribute(e){return this.atts[e]}setAttributeNS(e,t,n){this.atts[e+":"+t]=n}setAttribute(e,t){this.atts[e]=t}toString(){let e="<"+this.tag,t="";for(let n in this.atts)t+=" "+n+'="'+this.atts[n]+'"';e=e+t+">";for(let n=0;n<this.childNodes.length;n++)e+=this.childNodes[n].toString();return e+"</"+this.tag+">"}after(e){this.parentElement.insertAfter(this,e)}before(e){this.parentElement.insertBefore(this,e)}},gu=class{constructor(r){this.nodeValue=r;c(this,"parentElement");c(this,"nodeType",3)}toString(){return this.nodeValue}after(r){this.parentElement.insertAfter(this,r)}},Eu=class{constructor(r){this.nodeValue=r;c(this,"parentElement");c(this,"nodeType",8)}before(r){this.parentElement.insertBefore(this,r)}};var FE=class extends Vo{Nd(){return null}ce(r){return new mu(r)}cf(){return new Yl}ctn(r){return new gu(r)}cc(r){return new Eu(r)}removeElement(r){}removeTextNode(r){}};function fu(i){let r={};for(let e=0;e<i.length;e++)r[i[e].id]=i[e];return r}function UE(i,r){let e=r===0?"x":"y";return i.target[e]<i.source[e]?-1:1}function jS(i,r,e){let t=e===0?"x":"y";return i.source[t]>r.source[t]&&i.source[t]<r.target[t]||r.source[t]>i.source[t]&&r.source[t]<i.target[t]||i.target[t]>r.target[t]&&i.target[t]<r.source[t]||r.target[t]>i.target[t]&&r.target[t]<i.source[t]}function yu(i,r,e,t,n){let o=i,s=r;for(let a=0;a<o.length;a++){let l=o[a];l.sourcePosition=t(l.sourceId),l.sourceSize=n(l.sourceId),l.targetPosition=t(l.targetId),l.targetSize=n(l.targetId),l.sourceCenter={x:l.sourcePosition.x+l.sourceSize.width/2,y:l.sourcePosition.y+l.sourceSize.height/2},l.targetCenter={x:l.targetPosition.x+l.targetSize.width/2,y:l.targetPosition.y+l.targetSize.height/2};for(let h=0;h<l.path.length;h++){let d=e[l.path[h]],u=h<l.path.length-1?e[l.path[h+1]]:null;d.edges=d.edges||[],d.edges.push({edge:l,next:u})}}for(let a=0;a<s.length;a++)if(s[a].edges){let l=s[a];l.edges.sort((u,p)=>{let m=u.edge.pathDirection,g=p.edge.pathDirection,E=u.edge.path.indexOf(l.id),y=p.edge.path.indexOf(l.id),x=m===1?E+1:E-1,f=g===1?y+1:y-1,b=x>=0&&x<u.edge.path.length?e[u.edge.path[x]]:null,A=f>=0&&f<p.edge.path.length?e[p.edge.path[f]]:null,T=m===1?E-1:E+1,S=g===1?y-1:y+1,R=T>=0&&T<u.edge.path.length?e[u.edge.path[T]]:null,v=S>=0&&S<p.edge.path.length?e[p.edge.path[S]]:null,O=l.axis===0?Q:fe,P=b?b.midpoint[O]:R?R.midpoint[O]:p.edge.sourceCenter[O]!==u.edge.sourceCenter[O]?u.edge.sourceCenter[O]:u.edge.targetCenter[O],I=b?A.midpoint[O]:v?v.midpoint[O]:u.edge.sourceCenter[O]!==p.edge.sourceCenter[O]?p.edge.sourceCenter[O]:p.edge.targetCenter[O];return P-I});let h=s[a].length/(s[a].edges.length+1),d=h;for(let u=0;u<s[a].edges.length;u++)s[a].edges[u].location=d,d+=h}}function xu(i,r,e){for(let t=0;t<i.length;t++){let n=i[t];n.regionPath=n.regionPath||[];for(let o=0;o<n.path.length;o++){let s=e[n.path[o]],a=s.edges.find(d=>d.edge.id===n.id),l=a.edge.pathDirection;if(!(a.edge.pathDirection===1&&s.b.type==="vertex"||a.edge.pathDirection===-1&&s.a.type==="vertex")){let d=a.next.edges.find(A=>A.edge.id===n.id),u=r.find(A=>A.id===(l===1?s.b.id:s.a.id)),p=s.axis===0?l===1?0:u.height:l===1?0:u.width,m=s.axis===0?l===1?u.height:0:l===1?u.width:0,g=s.segment.point1-(s.axis===0?u.left:u.top),E=a.next.segment.point1-(s.axis===0?u.left:u.top),y=s.axis===0?"x":"y",x=s.axis===0?"y":"x",f={[y]:a.location+g,[x]:p},b={[y]:d.location+E,[x]:m};u.lines.push({source:f,target:b,id:n.id}),n.regionPath.push(u)}}}}var bu="separate",D7="bus";function HS(i){let r=i.axis,e=i.gates,t=i.gateMap||fu(e),n=i.mode||bu,o=i.regions,s=i.edges,a=i.pad||10,l={};yu(s,e,t,i.getVertexPosition,i.getVertexSize),xu(s,o,t);for(let h=0;h<o.length;h++){o[h].edgeMap={};let d=[],u=o[h].lines;for(let x=0;x<u.length;x++){let f=[];for(let b=0;b<d.length;b++)e:for(let A=0;A<d[b].length;A++)if(jS(u[x],d[b][A],r)){f.push(b);break e}if(f.length===0)d.push([u[x]]);else{let b=[u[x]],A=[];for(let T=0;T<d.length;T++)f.indexOf(T)!==-1?b=b.concat(d[T]):A.push(d[T]);A.push(b),d=A}}for(let x=0;x<d.length;x++)d[x].sort((f,b)=>{let A=UE(f,r),T=UE(b,r),S=r==0?"x":"y";return A===T?A<0?f.source[S]-b.source[S]:b.source[S]-f.source[S]:f.source[S]-b.source[S]});o[h].lineSets=d;let p=r===0?o[h].height:o[h].width,m=r===0?o[h].left:o[h].top,g=r===0?o[h].top:o[h].left,E=r===0?"x":"y",y=r===1?"x":"y";if(n===bu)for(let x=0;x<d.length;x++){let f=(p-a)/(d[x].length+1),b=a+f;for(let A=0;A<d[x].length;A++){let T=d[x][A];l[T.id]=l[T.id]||[],o[h].edgeMap[T.id]=[{[E]:T.source[E]+m,[y]:T.source[y]+g},{[E]:T.source[E]+m,[y]:b+g},{[E]:T.target[E]+m,[y]:b+g},{[E]:T.target[E]+m,[y]:T.target[y]+g}],b+=f}}else for(let x=0;x<d.length;x++){let f=(p-a)/2,b=a+f;for(let A=0;A<d[x].length;A++){let T=d[x][A];o[h].edgeMap[T.id]=[{[E]:T.source[E]+m,[y]:T.source[y]+g},{[E]:T.source[E]+m,[y]:b+g},{[E]:T.target[E]+m,[y]:b+g},{[E]:T.target[E]+m,[y]:T.target[y]+g}]}}}for(let h=0;h<s.length;h++){let d=s[h];l[d.id]=[],d.regionPath.forEach(p=>{let m=p.edgeMap[d.id];l[d.id].push(...m)})}return l}function kS(i){let r=i.gates,e=fu(r),t=i.regions,n=i.edges,o={};yu(n,r,e,i.getVertexPosition,i.getVertexSize),xu(n,t,e);for(let s=0;s<t.length;s++){t[s].edgeMap={};let a=t[s].lines;for(let l=0;l<a.length;l++){let h=a[l];t[s].edgeMap[h.id]=[{x:h.source.x+t[s].left,y:h.source.y+t[s].top},{x:h.target.x+t[s].left,y:h.target.y+t[s].top}]}}for(let s=0;s<n.length;s++){let a=n[s];o[a.id]=[],a.regionPath.forEach(h=>{let d=h.edgeMap[a.id];o[a.id].push(...d)})}return o}var WS=4;function ZS(i){return{x:Math.ceil(i.x+i.width/2),y:Math.ceil(i.y+i.height/2)}}var Qs={sortRect:i=>{let r,e=1/0,t=-1/0;i.forEach(s=>{r=ZS(s),t=Math.max(t,r.x,r.y),e=Math.min(e,r.x,r.y)});let n=t-e;return i.sort(s=>(r=ZS(s),Qs.toHilbertCoordinates(n,r.x-e,r.y-e)))},toHilbertCoordinates:(i,r,e)=>{let t=i,n=(1<<t)-1,o=0,s=r^e,a=~r&n,l=~e&n,h=a^e,d=0,u=0;for(let p=1;p<t;p++)u=(u&s|(d^l)&h)>>1,d=(d&(u^a)|~d&(u^l))>>1;return o=~d&(u^r)|d&(u^l),Qs.hilbertInterleaveBits(o,s)},hilbertInterleaveBits:(i,r)=>{let e=0,t=Math.max(i,r),n=0;for(;t>0;)n++,t>>=1;for(let o=0;o<n;o++){let s=1<<o,a=(r&s)>0?1<<2*o:0,l=(i&s)>0?1<<2*o+1:0;e+=a+l}return e}};function JS(i){return i.height*i.width}function YE(i,r){i.x===1/0?(i.height=r.height,i.width=r.width,i.x=r.x,i.y=r.y):(i.height=Math.max(i.y+i.height,r.y+r.height)-Math.min(i.y,r.y),i.width=Math.max(i.x+i.width,r.x+r.width)-Math.min(i.x,r.x),i.x=Math.min(i.x,r.x),i.y=Math.min(i.y,r.y))}function zE(i){i.x=Math.min(...i.children.map(r=>r.x)),i.y=Math.min(...i.children.map(r=>r.y)),i.width=Math.max(...i.children.map(r=>r.x+r.width))-i.x,i.height=Math.max(...i.children.map(r=>r.y+r.height))-i.y,i.parent!=null&&zE(i.parent)}function KS(i,r){return i.x===1/0?JS(r):(Math.max(i.y+i.height,r.y+r.height)-Math.min(i.y,r.y))*(Math.max(i.x+i.width,r.x+r.width)-Math.min(i.x,r.x))-JS(i)}function XE(i){let r=Math.floor(i.children.length/2),e=Go(),t=Go();return Qs.sortRect(i.children).forEach((n,o)=>{o<=r?$o(e,n):$o(t,n)}),i.children.length=0,[e,t]}function Go(i){return{x:1/0,y:1/0,width:0,height:0,children:[],parent:null,id:i,data:null}}function Au(i){return i.children==null||i.children.length===0}function qS(i){return Au(i)||Au(i.children[0])}function $o(i,r){r.parent=i,i.children.push(r),YE(i,r)}function jE(i,r){let e=i.children.indexOf(r);return e>=0?(i.children.splice(e,1),!0):!1}function F0(i){return i.reduce(function(r,e){return Array.isArray(e)?r.concat(F0(e)):r.concat(e)},[])}function QS(i,r){let e=i.map(r);return i[e.indexOf(Math.min.apply(null,e))]}function eT(i){i.parent&&(jE(i.parent,i),zE(i.parent))}var ea=class{constructor(r){c(this,"Wt");c(this,"ee");c(this,"bn",{});this.Wt=r||WS,this.ee=Go()}search(r,e){let t=[];return this.Md(r,(n,o)=>t.push(n),e),t}searchAndRank(r,e){let t=[];return this.Md(r,(n,o)=>t.push({node:n,overlap:kg(n,r)}),e),t.sort((n,o)=>n.overlap<o.overlap?-1:1),t}Md(r,e,t){if(this.ee.children.length===0)return;t=t||{};let n=Object.assign({},r);t.margin&&(n.x-=t.margin,n.y-=t.margin,n.width+=2*t.margin,n.height+=2*t.margin);let o=s=>{if(ke(s,n))for(let a=0;a<s.children.length;a++){let l=s.children[a];if(ke(l,n))if(l.id!=null){if(t.minimumOverlap!=null&&kg(l,n)<t.minimumOverlap)continue;if(e(l,n),t.greedy)return}else o(l)}};o(this.ee)}findIntersectionsWithLine(r,e){let t=[];e=e||[];let n=o=>{Eb(r,o)&&(Au(o)?e.indexOf(o.id)===-1&&t.push(o):o.children.forEach(n))};return n(this.ee),t}insert(r){let e=n=>{let o=this.ee;if(o){let s={x:n.x,y:n.y,width:n.width,height:n.height,data:n.data,children:[],id:n.id};for(n.id&&(this.bn[n.id]=s);!qS(o);)YE(o,s),o=QS(o.children,a=>KS(a,s));$o(o,s),this.uE(s)}},t=Array.isArray(r)?r:[r];for(let n=0;n<t.length;n++)e(t[n])}uE(r){let e=r;for(;e.parent&&e.parent.children.length>this.Wt;)e=e.parent,e!=this.ee?(jE(e.parent,e),XE(e).forEach(t=>{$o(e.parent,t)})):e==this.ee&&XE(e).forEach(t=>{$o(e,t)})}Vd(r,e){e===void 0&&(e=1);let t=Math.ceil(r.length/this.Wt),n=[],o=0,s;for(let a=0;a<t;a++){s=Go(),o=Math.min(this.Wt,r.length);for(let l=0;l<o;l++){let h=r.pop();h.id&&(this.bn[h.id]=h),$o(s,h)}n.push(s)}return t>1?this.Vd(n,e+1):n}load(r){if(r!=null&&r.length>0){let e=Qs.sortRect(r);this.ee=this.Vd(e)[0]||Go()}}getBounds(){return{x:this.ee.x,y:this.ee.y,width:this.ee.width,height:this.ee.height}}getExtents(){return{xmin:this.ee.x,ymin:this.ee.y,xmax:this.ee.x+this.ee.width,ymax:this.ee.y+this.ee.height}}removeById(r){let e=this.searchById(r);return e&&e.parent&&this.Gd(e),e}Gd(r,e){let t=[],n=r.parent;for(eT(r),r.id!=null&&delete this.bn[r.id];n!=null&&n!==this.ee;)n.children.length<=this.Wt/2&&(eT(n),t.push(...this.pE(n))),n=n.parent;e&&t.push(...e),this.insert(t)}searchById(r){return r==null?null:this.bn[r]}update(r,e,t,n,o,s){let a=this.searchById(r);a?this.Gd(a,[{x:e,y:t,width:n,height:o,data:s||a.data,children:[],id:r}]):this.insert({id:r,x:e,y:t,width:n,height:o,data:s,children:[]})}clear(){this.ee=Go(),this.bn={}}getLeafNodes(){return Object.values(this.bn)}pE(r){let e=[],t=n=>{n.id!=null?e.push(n):n.children.forEach(t)};return t(r),e}};var Su=class i{constructor(r){this.instance=r;c(this,"se",[]);c(this,"K",[]);c(this,"q",[])}static from(r){let e=new i(r.instance);return e.se=r.se.slice(),e.K=r.K.slice(),e.q=r.q.slice(),e}paste(r,e){let t=e&&e.origin,n=e&&e.hermetic===!0,o=e&&e.shallow===!0,s=this.mE(r,t,n,o);return this.instance.transaction(()=>{s.groups.forEach(a=>this.instance.addGroup(a)),s.nodes.forEach(a=>this.instance.addNode(a)),s.edges.forEach(a=>this.instance.$_addEdge(a,Vb,null))}),s}mE(r,e,t,n){let o={nodes:[],groups:[],edges:[],vertexMap:new Map,edgeMap:new Map,origin:{x:0,y:0},transform:{x:0,y:0}},s=[],a=this.instance.modelLeftAttribute,l=this.instance.modelTopAttribute,h=1/0,d=1/0,u=new Map;function p(g){let E=r.getCoordinates(g,!0);u.set(g.id,E),g.group==null&&(h=Math.min(h,E.x),d=Math.min(d,E.y))}this.K.forEach(p),this.se.forEach(p),o.origin.x=h,o.origin.y=d,o.transform.x=e!=null?e.x-o.origin.x:0,o.transform.y=e!=null?e.y-o.origin.y:0;let m=(g,E,y)=>{y=y||0;let x=Object.assign({},g.data),f=V();if(o.vertexMap.set(g.getFullId(),f),x.id=f,E==null){let b=u.get(g.getFullId());x[a]=b.x+o.transform.x,x[l]=b.y+o.transform.y,x.group!=null&&delete x.group}else x.group=E.id;return!n&&Y(g)&&g.getMembers().forEach(b=>{let A=m(b,x,y+1);Y(b)?s.push(A):o.nodes.push(A[0])}),[x,y]};return this.se.forEach(g=>o.nodes.push(m(g,null,0)[0])),this.K.forEach(g=>s.push(m(g,null,0))),s.sort((g,E)=>g[1]<E[1]?-1:1),o.groups=s.map(g=>g[0]),this.q.forEach(g=>{let E,y,x=g.source,f=H(x)?x.getParent():x,b=o.vertexMap.get(f.id),A=g.target,T=H(A)?A.getParent():A,S=o.vertexMap.get(T.id);if(b==null){if(t)return;E=f.id}else E=b;if(S==null){if(t)return;y=T.id}else y=S;let R={source:E,target:y,data:Object.assign({},g.data||{})};if(R.data.id!=null){let v=V();o.edgeMap.set(R.data.id,v),R.data.id=v}g.geometry!=null&&S!=null&&b!=null&&(R.geometry=r.transformGeometry(g,o.transform.x,o.transform.y)),o.edges.push(R)}),o}};var Tu=class{constructor(r){this.instance=r;c(this,"stack",[])}copy(r){let e=this.instance.select(r);this.stack.push(Su.from(e))}paste(r){let t=r&&r.clear===!0?this.stack.pop():this.stack[this.stack.length-1];return t!=null?t.paste(this.$getCopyDataTransformer(),r):null}clear(){this.stack.length=0}copyCurrentSelection(){this.copy(this.instance.getSelection())}pasteCurrentSelection(r){return this.copyCurrentSelection(),this.paste(r)}};var HE="Anchor",Et="top",Tt="left",vt="right",Ct="bottom",$i={[Et]:{x:0,y:-1},[Ct]:{x:0,y:1},[vt]:{x:1,y:0},[Tt]:{x:-1,y:0}},JJ=[Tt,vt],KJ=[Et,Ct],qJ={[Et]:[Tt,vt],[Ct]:[Tt,vt],[Tt]:[Ct,Et],[vt]:[Ct,Et]},QJ={[Et]:Ct,[Ct]:Et,[Tt]:vt,[vt]:Tt},U0=(s=>(s.Circle="Circle",s.Ellipse="Ellipse",s.Triangle="Triangle",s.Diamond="Diamond",s.Rectangle="Rectangle",s.Square="Square",s))(U0||{}),vu=(f=>(f.Assign="Assign",f.AutoDefault="AutoDefault",f.Bottom="Bottom",f.BottomLeft="BottomLeft",f.BottomRight="BottomRight",f.Center="Center",f.Continuous="Continuous",f.ContinuousBottom="ContinuousBottom",f.ContinuousLeft="ContinuousLeft",f.ContinuousRight="ContinuousRight",f.ContinuousTop="ContinuousTop",f.ContinuousLeftRight="ContinuousLeftRight",f.ContinuousTopBottom="ContinuousTopBottom",f.Left="Left",f.Right="Right",f.Top="Top",f.TopLeft="TopLeft",f.TopRight="TopRight",f))(vu||{});var an={};function ta(i,r){an[i]=r}var fr={lineIntersection(i,r,e,t,n){return an[i.type].lineIntersection(i,r,e,t,n)},boxIntersection(i,r,e,t,n){return an[i.type].boxIntersection(i,r,e,t,n)},boundingBoxIntersection(i,r){return an[i.type].boundingBoxIntersection(i,r)},pointOnPath(i,r,e){return an[i.type].pointOnPath(i,r,e)},gradientAtPoint(i,r,e){return an[i.type].gradientAtPoint(i,r,e)},pointAlongPathFrom(i,r,e,t){return an[i.type].pointAlongPathFrom(i,r,e,t)},findClosestPointOnPath(i,r,e){return an[i.type].findClosestPointOnPath(i,r,e)},getPath(i,r){return an[i.type].getPath(i,r)}};function kE(i){return an[i.type].getLength(i)}function tT(i,r){return an[i].create(r)}function Y0(){return{d:1/0,x:null,y:null,l:null,x1:null,y1:null,x2:null,y2:null}}function rT(i,r,e){return Y0()}function nT(i,r,e,t,n){return[]}function zl(i,r,e,t,n){let o=[];return o.push.apply(o,fr.lineIntersection(i,r,e,r+t,e)),o.push.apply(o,fr.lineIntersection(i,r+t,e,r+t,e+n)),o.push.apply(o,fr.lineIntersection(i,r+t,e+n,r,e+n)),o.push.apply(o,fr.lineIntersection(i,r,e+n,r,e)),o}function iT(i,r){return zl(i,r.x,r.y,r.width,r.height)}function ra(i){return Object.assign({extents:Pi()},i)}function z0(){return{sx:0,sy:0,tx:0,ty:0,so:{x:0,y:0},to:{x:0,y:0},x:0,y:0,w:0,h:0,quadrant:1,startStubX:0,startStubY:0,endStubX:0,endStubY:0,isXGreaterThanStubTimes2:!1,isYGreaterThanStubTimes2:!1,opposite:!1,perpendicular:!1,orthogonal:!1,sourceAxis:Q,stubs:[0,0]}}function na(i,r,e){return{x:i.x,y:i.y,ox:i.ox,oy:i.oy,curX:i.curX+r,curY:i.curY+e}}function Cu(i,r,e,t){let n=e.gap||0,o=e.stub||t,s=Array.isArray(o)?o[0]:o,a=Array.isArray(o)?o[1]:o;return{type:i,internalSegments:[],segmentProportionalLengths:[],segmentProportions:[],totalLength:0,cssClass:e.cssClass||"",hoverClass:e.hoverClass||"",gap:n,stub:o,sourceStub:s,targetStub:a,sourceGap:Array.isArray(n)?n[0]:n,targetGap:Array.isArray(n)?n[1]:n,typeDescriptor:"connector",geometry:null,idPrefix:"_vjs_connector",bounds:Pi(),x:0,y:0,width:0,height:0,edited:!1,strokeWidth:1,typeId:null,quadrant:0,paintInfo:z0()}}function WE(i,r,e){let t=e===0?r.anchors.source:r.anchors.target;t.isFixed=!0,t.fixedLocation=Object.assign({},i,{offsetX:i.offsetX==null?0:i.offsetX,offsetY:i.offsetY==null?0:i.offsetY})}var oT=.45,X0=62;function Pu(i,r,e){let t=Cu(i,r,e,[0,0]);return Object.assign(t,{curviness:e.curviness||10,gap:e.gap||5,proximityLimit:e.proximityLimit||80,clockwise:e.orientation&&e.orientation==="clockwise",loopbackDistance:e.loopbackDistance||X0,isLoopbackCurrently:!1,constrain:rn,smooth:!0})}var On={subtract:(i,r)=>({x:i.x-r.x,y:i.y-r.y}),dotProduct:(i,r)=>i.x*r.x+i.y*r.y,square:i=>Math.sqrt(i.x*i.x+i.y*i.y),scale:(i,r)=>({x:i.x*r,y:i.y*r})},sT=64,j0=Math.pow(2,-sT-1);function H0(i,r){let e=[],t=k0(i,r),n=r.length-1,o=2*n-1,s=ZE(t,o,e,0),a=On.subtract(i,r[0]),l=On.square(a),h=0,d;for(let u=0;u<s;u++)a=On.subtract(i,JE(r,n,e[u],null,null)),d=On.square(a),d<l&&(l=d,h=e[u]);return a=On.subtract(i,r[n]),d=On.square(a),d<l&&(l=d,h=1),{location:h,distance:l}}function dT(i,r){let e=H0(i,r);return{point:JE(r,r.length-1,e.location,null,null),location:e.location}}function k0(i,r){let e=r.length-1,t=2*e-1,n=[],o=[],s=[],a=[],l=[[1,.6,.3,.1],[.4,.6,.6,.4],[.1,.3,.6,1]];for(let u=0;u<=e;u++)n[u]=On.subtract(r[u],i);for(let u=0;u<=e-1;u++)o[u]=On.subtract(r[u+1],r[u]),o[u]=On.scale(o[u],3);for(let u=0;u<=e-1;u++)for(let p=0;p<=e;p++)s[u]||(s[u]=[]),s[u][p]=On.dotProduct(o[u],n[p]);for(let u=0;u<=t;u++)a[u]||(a[u]=[]),a[u].y=0,a[u].x=parseFloat(""+u)/t;let h=e,d=e-1;for(let u=0;u<=h+d;u++){let p=Math.max(0,u-d),m=Math.min(u,h);for(let g=p;g<=m;g++){let E=u-g;a[g+E].y+=s[E][g]*l[E][g]}}return a}function ZE(i,r,e,t){let n=[],o=[],s,a,l=[],h=[];switch(W0(i,r)){case 0:return 0;case 1:{if(t>=sT)return e[0]=(i[0].x+i[r].x)/2,1;if(Z0(i,r))return e[0]=J0(i,r),1;break}}JE(i,r,.5,n,o),s=ZE(n,r,l,t+1),a=ZE(o,r,h,t+1);for(let d=0;d<s;d++)e[d]=l[d];for(let d=0;d<a;d++)e[d+s]=h[d];return s+a}function W0(i,r){let e=0,t,n;t=n=Math.sign(i[0].y);for(let o=1;o<=r;o++)t=Math.sign(i[o].y),t!=n&&e++,n=t;return e}function Z0(i,r){let e,t,n,o,s,a,l,h,d,u,p,m,g,E,y,x;a=i[0].y-i[r].y,l=i[r].x-i[0].x,h=i[0].x*i[r].y-i[r].x*i[0].y;let f,b;f=b=0;for(let A=1;A<r;A++){let T=a*i[A].x+l*i[A].y+h;T>f?f=T:T<b&&(b=T)}return p=0,m=1,g=0,E=a,y=l,x=h-f,d=p*y-E*m,u=1/d,t=(m*x-y*g)*u,E=a,y=l,x=h-b,d=p*y-E*m,u=1/d,n=(m*x-y*g)*u,o=Math.min(t,n),s=Math.max(t,n),e=s-o,e<j0?1:0}function J0(i,r){let e=1,t=0,n=i[r].x-i[0].x,o=i[r].y-i[0].y,s=i[0].x-0,a=i[0].y-0,l=n*t-o*e,h=1/l,d=(n*a-o*s)*h;return 0+e*d}function JE(i,r,e,t,n){let o=[[]];for(let s=0;s<=r;s++)o[0][s]=i[s];for(let s=1;s<=r;s++)for(let a=0;a<=r-s;a++)o[s]||(o[s]=[]),o[s][a]||(o[s][a]={}),o[s][a].x=(1-e)*o[s-1][a].x+e*o[s-1][a+1].x,o[s][a].y=(1-e)*o[s-1][a].y+e*o[s-1][a+1].y;if(t!=null)for(let s=0;s<=r;s++)t[s]=o[s][0];if(n!=null)for(let s=0;s<=r;s++)n[s]=o[r-s][s];return o[r][0]}function K0(i,r){let e=[];i--;for(let t=0;t<=i;t++)e.push(q0(t/i,r));return e}function q0(i,r){let e={x:0,y:0};if(i===0)return r[0];let t=r.length-1;if(i===1)return r[t];let n=r,o=1-i;if(t===0)return r[0];if(t===1)return{x:o*n[0].x+i*n[1].x,y:o*n[0].y+i*n[1].y};if(4>t){let s=o*o,a=i*i,l=0,h,d,u;return t===2?(n=[n[0],n[1],n[2],e],h=s,d=2*(o*i),u=a):t===3&&(h=s*o,d=3*(s*i),u=3*(o*a),l=i*a),{x:h*n[0].x+d*n[1].x+u*n[2].x+l*n[3].x,y:h*n[0].y+d*n[1].y+u*n[2].y+l*n[3].y}}else return e}function uT(i){let r=0;if(!hT(i)){let t=K0(16,i);for(let n=0;n<15;n++){let o=t[n],s=t[n+1];r+=lT(o,s)}}return r}var aT=new Map;function Q0(i){let r=aT.get(i);if(!r){r=[];let e=()=>l=>Math.pow(l,i),t=()=>l=>Math.pow(1-l,i),n=l=>h=>l,o=()=>l=>l,s=()=>l=>1-l,a=l=>h=>{let d=1;for(let u=0;u<l.length;u++)d=d*l[u](h);return d};r.push(e());for(let l=1;l<i;l++){let h=[n(i)];for(let d=0;d<i-l;d++)h.push(o());for(let d=0;d<l;d++)h.push(s());r.push(a(h))}r.push(t()),aT.set(i,r)}return r}function ia(i,r){let e=Q0(i.length-1),t=0,n=0;for(let o=0;o<i.length;o++)t=t+i[o].x*e[o](1-r),n=n+i[o].y*e[o](1-r);return{x:t,y:n}}function lT(i,r){return Math.sqrt(Math.pow(i.x-r.x,2)+Math.pow(i.y-r.y,2))}function hT(i){return i[0].x===i[1].x&&i[0].y===i[1].y}function Ou(i,r,e){if(hT(i))return{point:i[0],location:r};let t=ia(i,r),n=0,o=r,s=e>0?1:-1,a=null;for(;n<Math.abs(e);)o+=.005*s,a=ia(i,o),n+=lT(a,t),t=a;return{point:a,location:o}}function pT(i,r,e){return Ou(i,r,e).point}function mT(i,r,e){return Ou(i,r,e).location}function _u(i,r){let e=ia(i,r),t=ia(i.slice(0,i.length-1),r),n=t.y-e.y,o=t.x-e.x;return n===0?1/0:Math.atan(n/o)}function H9(i,r,e){let t=Ou(i,r,e);return t.location>1&&(t.location=1),t.location<0&&(t.location=0),_u(i,t.location)}function k9(i,r,e,t){t=t==null?0:t;let n=Ou(i,r,t),o=_u(i,n.location),s=Math.atan(-1/o),a=e/2*Math.sin(s),l=e/2*Math.cos(s);return[{x:n.point.x+l,y:n.point.y+a},{x:n.point.x-l,y:n.point.y-a}]}function _n(i,r,e,t,n){let o=t-r,s=i-e,a=i*(r-t)+r*(e-i),l=ew(n),h=[o*l[0][0]+s*l[1][0],o*l[0][1]+s*l[1][1],o*l[0][2]+s*l[1][2],o*l[0][3]+s*l[1][3]+a],d=tw.apply(null,h),u=[];if(d!=null)for(let p=0;p<3;p++){let m=d[p],g=Math.pow(m,2),E=Math.pow(m,3),y={x:l[0][0]*E+l[0][1]*g+l[0][2]*m+l[0][3],y:l[1][0]*E+l[1][1]*g+l[1][2]*m+l[1][3]},x;e-i!==0?x=(y.x-i)/(e-i):x=(y.y-r)/(t-r),m>=0&&m<=1&&x>=0&&x<=1&&u.push(y)}return u}function W9(i,r,e,t,n){let o=[];return o.push.apply(o,_n(i,r,i+e,r,n)),o.push.apply(o,_n(i+e,r,i+e,r+t,n)),o.push.apply(o,_n(i+e,r+t,i,r+t,n)),o.push.apply(o,_n(i,r+t,i,r,n)),o}function Z9(i,r){let e=[];return e.push.apply(e,_n(i.x,i.y,i.x+i.width,i.y,r)),e.push.apply(e,_n(i.x+i.width,i.y,i.x+i.width,i.y+i.height,r)),e.push.apply(e,_n(i.x+i.width,i.y+i.height,i.x,i.y+i.height,r)),e.push.apply(e,_n(i.x,i.y+i.height,i.x,i.y,r)),e}function cT(i,r){return[-i[0][r]+3*i[1][r]+-3*i[2][r]+i[3][r],3*i[0][r]-6*i[1][r]+3*i[2][r],-3*i[0][r]+3*i[1][r],i[0][r]]}function ew(i){return[cT(i,"x"),cT(i,"y")]}function tw(i,r,e,t){let n=r/i,o=e/i,s=t/i,a=(3*o-Math.pow(n,2))/9,l=(9*n*o-27*s-2*Math.pow(n,3))/54,h=Math.pow(a,3)+Math.pow(l,2),d,u,p=[0,0,0];if(h>=0)d=Math.sign(l+Math.sqrt(h))*Math.pow(Math.abs(l+Math.sqrt(h)),1/3),u=Math.sign(l-Math.sqrt(h))*Math.pow(Math.abs(l-Math.sqrt(h)),1/3),p[0]=-n/3+(d+u),p[1]=-n/3-(d+u)/2,p[2]=-n/3-(d+u)/2,Math.abs(Math.sqrt(3)*(d-u)/2)!==0&&(p[1]=-1,p[2]=-1);else{let m=Math.acos(l/Math.sqrt(-Math.pow(a,3)));p[0]=2*Math.sqrt(-a)*Math.cos(m/3)-n/3,p[1]=2*Math.sqrt(-a)*Math.cos((m+2*Math.PI)/3)-n/3,p[2]=2*Math.sqrt(-a)*Math.cos((m+4*Math.PI)/3)-n/3}for(let m=0;m<3;m++)(p[m]<0||p[m]>1)&&(p[m]=-1);return p}var Bo="Bezier";function KE(i,r,e){return e&&(r=mT(i,r>0?0:1,r)),r}var rw={create(i){let r=ra(i),e=i.cp1,t=i.cp2,n=[{x:r.x1,y:r.y1},{x:e.x,y:e.y},{x:t.x,y:t.y},{x:r.x2,y:r.y2}],o={xmin:Math.min(r.x1,r.x2,e.x,t.x),ymin:Math.min(r.y1,r.y2,e.y,t.y),xmax:Math.max(r.x1,r.x2,e.x,t.x),ymax:Math.max(r.y1,r.y2,e.y,t.y)};return Object.assign(r,{cp1:e,cp2:t,curve:n,extents:o,length:0,type:Bo})},boundingBoxIntersection(i,r){return iT(i,r)},boxIntersection(i,r,e,t,n){return zl(i,r,e,t,n)},findClosestPointOnPath(i,r,e){let t=dT({x:r,y:e},i.curve);return{d:Math.sqrt(Math.pow(t.point.x-r,2)+Math.pow(t.point.y-e,2)),x:t.point.x,y:t.point.y,l:1-t.location,s:i,x1:null,y1:null,x2:null,y2:null}},getLength(i){return(i.length==null||i.length===0)&&(i.length=uT(i.curve)),i.length},getPath(i,r){return(r?"M "+i.x1+" "+i.y1+" ":"")+"C "+i.cp1.x+" "+i.cp1.y+" "+i.cp2.x+" "+i.cp2.y+" "+i.x2+" "+i.y2},gradientAtPoint(i,r,e){return r=KE(i.curve,r,e),_u(i.curve,r)},lineIntersection(i,r,e,t,n){return _n(r,e,t,n,i.curve)},pointAlongPathFrom(i,r,e,t){return r=KE(i.curve,r,t),pT(i.curve,r,e)},pointOnPath(i,r,e){return r=KE(i.curve,r,e),ia(i.curve,r)}};ta(Bo,rw);var Xl={};function nw(i){return i.x1!=null&&!isNaN(i.x1)&&i.y1!=null&&!isNaN(i.y1)&&i.x2!=null&&!isNaN(i.x2)&&i.y2!=null&&!isNaN(i.y2)}function gT(i){return i.curX!=null&&!isNaN(i.curX)&&i.curY!=null&&!isNaN(i.curY)&&i.x!=null&&!isNaN(i.x)&&i.y!=null&&!isNaN(i.y)&&i.ox!=null&&!isNaN(i.ox)&&i.oy!=null&&!isNaN(i.oy)}function iw(i){return!i.source||!i.target||!gT(i.source)||!gT(i.target)||i.segments==null||i.segments.length===0?!1:i.segments.find(r=>!nw(r))==null}var Yr=i=>ot(i.geometry),Ne={get:(i,r,e)=>{let t=Xl[r];if(t)return t.create(i,e);throw"VisuallyJs: unknown connector type '"+r+"'"},register:(i,r)=>{Xl[i]=r},compute:(i,r,e)=>{let t=Xl[i.connector.type];if(t)return t.compute(i,r,e);throw"VisuallyJs: unknown connector type '"+i.connector.type+"'"},update:(i,r,e,t,n)=>{let o=Xl[i.connector.type];if(o)return o.update(i,r,e,t,n);throw"VisuallyJs: unknown connector type '"+i.connector.type+"'"},markEdited(i,r){r=r||Yr(i.connector),i.connector.edited=!0,i.edge.geometry=r,Ne.$_setAnchorsFromGeometry(i,r)},importGeometry(i,r){if(iw(r)){let e=i.connector;e.geometry=ot(r),e.edited=!0,Ne.$_setAnchorsFromGeometry(i,r)}else U("VisuallyJS WARN: edge geometry invalid")},$_setAnchorsFromGeometry(i,r){WE(r.source,i,0),WE(r.target,i,1)},transformGeometry(i,r,e,t){let n=Xl[i.type];if(n)return n.transformGeometry(r,e,t);throw"VisuallyJs: unknown connector type '"+i.type+"'"},setGeometry(i,r,e){if(r!=null){let t=i.connector;t.geometry=ot(r),e||(t.edited=!0,i.edge.geometry=Yr(t))}}};function OK(i){return i.geometry}function _K(i,r){return i.geometry=r,!0}function ow(i,r){let e=r.extents;i.bounds.xmin=Math.min(i.bounds.xmin,e.xmin),i.bounds.xmax=Math.max(i.bounds.xmax,e.xmax),i.bounds.ymin=Math.min(i.bounds.ymin,e.ymin),i.bounds.ymax=Math.max(i.bounds.ymax,e.ymax)}function QE(i){i.totalLength=0,i.internalSegments.length=0,i.segmentProportions.length=0,i.segmentProportionalLengths.length=0}function zr(i,r,e){if(e.x1===e.x2&&e.y1===e.y2)return;let t=tT(r,e);i.internalSegments.push(t),i.totalLength+=kE(t),ow(i,t)}function qE(i,r,e){let t,n,o;if(e&&(r=r>0?r/i.totalLength:(i.totalLength+r)/i.totalLength),r===1)t=i.internalSegments.length-1,o=1;else if(r===0)o=0,t=0;else if(r>=.5){for(t=0,o=0,n=i.segmentProportions.length-1;n>-1;n--)if(i.segmentProportions[n][1]>=r&&i.segmentProportions[n][0]<=r){t=n,o=(r-i.segmentProportions[n][0])/i.segmentProportionalLengths[n];break}}else for(t=i.segmentProportions.length-1,o=1,n=0;n<i.segmentProportions.length;n++)if(i.segmentProportions[n][1]>=r){t=n,o=(r-i.segmentProportions[n][0])/i.segmentProportionalLengths[n];break}return{segment:i.internalSegments[t],proportion:o,index:t}}function Xr(i,r,e){let t=qE(i,r,e);return t.segment&&fr.pointOnPath(t.segment,t.proportion,!1)||{x:0,y:0}}function RK(i,r,e){let t=qE(i,r,e);return t.segment&&fr.gradientAtPoint(t.segment,t.proportion,!1)||0}function rt(i,r,e,t){let n=qE(i,r,t);return n.segment&&fr.pointAlongPathFrom(n.segment,n.proportion,e,!1)||{x:0,y:0}}function ef(i){let r=0;for(let e=0;e<i.internalSegments.length;e++){let t=kE(i.internalSegments[e]);i.segmentProportionalLengths[e]=t/i.totalLength,i.segmentProportions[e]=[r,r+=t/i.totalLength]}}function ET(i){return!((i.ox===0||i.ox==null)&&(i.oy===0||i.oy==null))}function tf(i,r){i.strokeWidth=r.strokeWidth;let e=r.sourcePos.curX,t=r.targetPos.curX,n=r.sourcePos.curY,o=r.targetPos.curY,s=t<e,a=o<n,l={x:r.sourcePos.ox,y:r.sourcePos.oy},h={x:r.targetPos.ox,y:r.targetPos.oy},d=s?t:e,u=a?o:n,p=Math.abs(t-e),m=Math.abs(o-n),g=!ET(r.sourcePos),E=!ET(r.targetPos);if(g||E){let S=p>m,R=S?e:n,v=S?t:o,O=R>v?-1:1,P=R>v?1:-1;g&&(l.x=S?O:0,l.y=S?0:O),E&&(h.x=S?P:0,h.y=S?0:P)}let y=e+i.sourceGap*l.x,x=n+i.sourceGap*l.y,f=t+i.targetGap*h.x,b=o+i.targetGap*h.y,A=l.x*h.x+l.y*h.y,T={sx:y,sy:x,tx:f,ty:b,so:l,to:h,x:d,y:u,w:p,h:m,quadrant:Os({x:e,y:n},{x:t,y:o}),startStubX:y+l.x*i.sourceStub,startStubY:x+l.y*i.sourceStub,endStubX:f+h.x*i.targetStub,endStubY:b+h.y*i.targetStub,isXGreaterThanStubTimes2:Math.abs(y-f)>i.sourceStub+i.targetStub,isYGreaterThanStubTimes2:Math.abs(x-b)>i.sourceStub+i.targetStub,opposite:A===-1,perpendicular:A===0,orthogonal:A===1,sourceAxis:l.x===0?fe:Q,stubs:[i.sourceStub,i.targetStub]};return T.anchorOrientation=T.opposite?"opposite":T.orthogonal?"orthogonal":"perpendicular",T}function LK(i,r){let e=i.connector;e.paintInfo=tf(e,r),QE(e),Ne.compute(i,e.paintInfo,r),e.x=e.paintInfo.x,e.y=e.paintInfo.y,e.width=e.paintInfo.w,e.height=e.paintInfo.h,e.quadrant=e.paintInfo.quadrant,ef(e)}function Bi(i){i.connector.geometry=null,i.connector.edited=!1,[i.anchors.source,i.anchors.target].forEach(r=>{r.locations.length>0&&(delete r.fixedLocation,r.isFixed=!1)})}function fT(i){i.bounds=Pi()}function yT(i,r,e){let t={d:1/0,s:null,x:null,y:null,l:null,x1:null,y1:null,x2:null,y2:null,index:null,connectorLocation:null};for(let n=0;n<i.internalSegments.length;n++){let o=fr.findClosestPointOnPath(i.internalSegments[n],r,e);o.d<t.d&&(t.d=o.d,t.l=o.l,t.x=o.x,t.y=o.y,t.s=i.internalSegments[n],t.x1=o.x1,t.x2=o.x2,t.y1=o.y1,t.y2=o.y2,t.index=n,t.connectorLocation=i.segmentProportions[n][0]+o.l*(i.segmentProportions[n][1]-i.segmentProportions[n][0]))}return t}function wK(i,r,e,t,n){let o=[];for(let s=0;s<i.internalSegments.length;s++)o.push.apply(o,fr.lineIntersection(i.internalSegments[s],r,e,t,n));return o}function DK(i,r,e,t,n){let o=[];for(let s=0;s<i.internalSegments.length;s++)o.push.apply(o,fr.boxIntersection(i.internalSegments[s],r,e,t,n));return o}function xT(i,r){let e=[];for(let t=0;t<i.internalSegments.length;t++)e.push.apply(e,fr.boundingBoxIntersection(i.internalSegments[t],r));return e}function NK(i){return i.typeDescriptor==="connector"}function bT(i){let r="";for(let e=0;e<i.internalSegments.length;e++)r+=fr.getPath(i.internalSegments[e],e===0),r+=" ";return r}function sw(i,r,e,t,n,o,s){let a=t,l=n,h=r.sx,d=r.sy,u=r.tx,p=r.ty,m,g;if(r.perpendicular){let E=h+a.ox*i.loopbackDistance,y=d+a.oy*i.loopbackDistance,x=u+l.ox*i.loopbackDistance,f=p+l.oy*i.loopbackDistance;m={x:E,y},g={x,y:f}}else{let E=Math.sign(r.tx-r.sx),y=Math.sign(r.ty-r.sy),x=a.ox===0?.25*i.loopbackDistance*-E:a.ox*i.loopbackDistance,f=a.oy===0?.25*i.loopbackDistance*-y:a.oy*i.loopbackDistance,b=l.ox===0?.25*i.loopbackDistance*E:l.ox*i.loopbackDistance,A=l.oy===0?.25*i.loopbackDistance*y:l.oy*i.loopbackDistance;m={x:r.sx+x,y:r.sy+f},g={x:r.tx+b,y:r.ty+A}}return[m,g]}function aw(i,r,e,t,n,o,s){let a=t,l=n,h,d,[u,p]=[i.scale*r.w,i.scale*r.h];return e.sourceInfo.id===e.targetInfo.id?[h,d]=sw(i,r,e,t,n,o,s):(h={x:r.sx+a.ox*u,y:r.sy+a.oy*p},d={x:r.tx+l.ox*u,y:r.ty+l.oy*p}),[h,d]}function AT(i){return[i.geometry.segments[0].cp1,i.geometry.segments[0].cp1]}function lw(i,r,e,t,n,o,s){let a=r.sx,l=r.sy,h=r.tx,d=r.ty,u,p=(a+h)/2,m=(l+d)/2,g=Math.sqrt(Math.pow(h-a,2)+Math.pow(d-l,2));return u=hw(p,m,r.quadrant,e.sourcePos,e.targetPos,i.curviness,i.curviness,g,i.proximityLimit),[u,u]}function hw(i,r,e,t,n,o,s,a,l){if(a<=l)return{x:i,y:r};if(e===1)return t.curY<=0&&n.curY>=1?{x:i+(t.x<.5?-1*o:o),y:r}:t.curX>=1&&n.curX<=0?{x:i,y:r+(t.y<.5?-1*s:s)}:{x:i+-1*o,y:r+-1*s};if(e===2)return t.curY>=1&&n.curY<=0?{x:i+(t.x<.5?-1*o:o),y:r}:t.curX>=1&&n.curX<=0?{x:i,y:r+(t.y<.5?-1*s:s)}:{x:i+o,y:r+-1*s};if(e===3)return t.curY>=1&&n.curY<=0?{x:i+(t.x<.5?-1*o:o),y:r}:t.curX<=0&&n.curX>=1?{x:i,y:r+(t.y<.5?-1*s:s)}:{x:i+-1*o,y:r+-1*s};if(e===4)return t.curY<=0&&n.curY>=1?{x:i+(t.x<.5?-1*o:o),y:r}:t.curX<=0&&n.curX>=1?{x:i,y:r+(t.y<.5?-1*s:s)}:{x:i+o,y:r+-1*s}}function ST(i){return[i.geometry.segments[0].cp1,i.geometry.segments[0].cp2]}function Ru(i,r,e,t,n){let o=i.connector,s,a;o.type===Fo?[s,a]=ST(o):[s,a]=AT(o);let l={segments:[{x1:r.sx,y1:r.sy,x2:r.tx,y2:r.ty,cp1:s,cp2:a}],source:e.sourcePos,target:e.targetPos};return zr(o,Bo,{x1:r.sx,y1:r.sy,x2:r.tx,y2:r.ty,cp1:s,cp2:a}),l}function Lu(i,r,e){let t=i.connector,n=e.sourcePos,o=e.targetPos,s=Math.abs(n.curX-o.curX),a=Math.abs(n.curY-o.curY),l,h;t.type===Fo?t.edited?[l,h]=ST(t):[l,h]=aw(t,r,e,n,o,s,a):t.edited?[l,h]=AT(t):[l,h]=lw(t,r,e,n,o,s,a);let d={segments:[{x1:r.sx,y1:r.sy,x2:r.tx,y2:r.ty,cp1:l,cp2:h}],source:e.sourcePos,target:e.targetPos};return zr(t,Bo,{x1:r.sx,y1:r.sy,x2:r.tx,y2:r.ty,cp1:l,cp2:h}),d}function wu(i,r,e){return{source:na(i.source,r,e),target:na(i.target,r,e),segments:i.segments.map(t=>({x1:t.x1+r,y1:t.y1+e,x2:t.x2+r,y2:t.y2+e,cp1:{x:t.cp1.x+r,y:t.cp1.y+e},cp2:{x:t.cp2.x+r,y:t.cp2.y+e}}))}}var Fo="Bezier";function cw(i,r){let e=Pu(Fo,i,r);return Object.assign(e,{scale:r.scale||oT})}Ne.register(Fo,{compute:Lu,update:Ru,create:cw,transformGeometry:wu});var Du="QuadraticBezier";function dw(i,r){let e=Pu(Du,i,r);return Object.assign(e,{curviness:r.curviness||10,gap:r.gap||5,proximityLimit:r.proximityLimit||80,clockwise:r.orientation&&r.orientation==="clockwise",Vb:{x:0,y:0}})}Ne.register(Du,{compute:Lu,update:Ru,create:dw,transformGeometry:wu});var rf="perpendicular",nf="orthogonal",of="opposite",oa="Orthogonal",TT="Smooth",vT=30;function jl(i,r,e,t){let n=Math.max(r,e),o=Math.min(r,e);return t?o<=i&&n>=i:o<i&&n>i}function CT(i,r,e){return Nu(r,"h",e,1)}function PT(i,r,e){return Nu(r,"h",e,-1)}function OT(i,r,e){return Nu(r,"v",e,1)}function _T(i,r,e){return Nu(r,"v",e,-1)}function Nu(i,r,e,t){let n=r==="h"?"v":"h",o=[],s=i,a=t===-1?-1:e.length;for(;s!==a;){let l=e[s];if(l.o===n)o.push(l),s+=t;else return{segment:l,others:o,index:s}}return null}function Iu(i,r,e,t){let n=null,o;if(t!=null){if(o=i.indexOf(t),o===-1)return null;o+=r}else o=r===-1?i.length-2:1;for(let s=o;s>0&&s<i.length-1;s+=r)if(i[s].o===e){n=[i[s],s];break}return n}function Mu(i,r,e,t){let n=i.indexOf(t),o=Iu(i,r,e,t);return o&&o[1]==n+r?o:null}function Uo(i){return{[ne]:Math.sign(i.x2-i.x1),[he]:Math.sign(i.y2-i.y1)}}function Mq(i){return[Math.sign(i.x2-i.x1),Math.sign(i.y2-i.y1)]}function sf(i,r){return i.curX===r.curX&&i.curY===r.curY}function Hl(i,r,e,t,n,o){if(i.lastx===r&&i.lasty===e)return;let s=i.lastx==null?t.sx:i.lastx,a=i.lasty==null?t.sy:i.lasty,l=s===r?he:ne;i.lastx=r,i.lasty=e;let h={x1:s,y1:a,x2:r,y2:e,o:l};i.orthogonalSegments.push(h)}function RT(i,r,e){let t=i[1],n=!1,o=[{x:t.x1,y:t.y1},{x:t.x2,y:t.y2}];if(t.o===ne){if(jl(t.x2,i[0].x1,i[0].x2)||cr(o,r).length>0){let a=OT(t,1,i);if(a!=null){let l=(a.segment.y1+a.segment.y2)/2;if(n=!0,l<t.y1){let h=Math.round((r.y-e)*100)/100,d=t.y1;a.others.forEach(u=>{u.y1=h,u.y2=h}),i.splice(1,0,{x1:t.x1,x2:t.x1,y1:d,y2:h,o:he}),a.segment.y1=h}else{let h=Math.round((r.y2+e)*100)/100,d=t.y1;a.others.forEach(u=>{u.y1=h,u.y2=h}),i.splice(1,0,{x1:t.x1,x2:t.x1,y1:d,y2:h,o:he}),a.segment.y1=h}}}}else if(t.o===he&&(jl(t.y2,i[0].y1,i[0].y2)||cr(o,r).length>0)){let a=CT(t,1,i);if(a!=null){let l=(a.segment.x1+a.segment.x2)/2;if(n=!0,l<t.x1){let h=Math.round((r.x-e)*100)/100,d=t.x1;a.others.forEach(u=>{u.x1=h,u.x2=h}),i.splice(1,0,{y1:t.y1,y2:t.y1,x1:d,x2:h,o:ne}),a.segment.x1=h}else{let h=Math.round((r.x2+e)*100)/100,d=t.x1;a.others.forEach(u=>{u.x1=h,u.x2=h}),i.splice(1,0,{y1:t.y1,y2:t.y1,x1:d,x2:h,o:ne}),a.segment.x1=h}}}return n}function LT(i,r,e){let t=i.length-2,n=i[t],o=!1,s=[{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}],a=i[i.length-1];if(n.o===ne){if(jl(n.x1,a.x1,a.x2)||cr(s,r).length>0){let h=_T(n,t,i);if(h!=null){let d=(h.segment.y1+h.segment.y2)/2;if(o=!0,d<n.y1){let u=Math.round((r.y-e)*100)/100,p=n.y1;h.others.forEach(m=>{m.y1=u,m.y2=u}),i.splice(t+1,0,{x1:n.x2,x2:n.x2,y1:u,y2:p,o:he}),h.segment.y2=u}else{let u=Math.round((r.y2+e)*100)/100,p=n.y1;h.others.forEach(m=>{m.y1=u,m.y2=u}),i.splice(t+1,0,{x1:n.x2,x2:n.x2,y1:u,y2:p,o:he}),h.segment.y2=u}}}}else if(n.o===he&&(jl(n.y1,a.y1,a.y2)||cr(s,r).length>0)){let h=PT(n,t,i);if(h!=null){let d=(h.segment.x1+h.segment.x2)/2;if(o=!0,d<n.x1){let u=Math.round((r.x-e)*100)/100,p=n.x1;h.others.forEach(m=>{m.x1=u,m.x2=u}),i.splice(t+1,0,{y1:n.y2,y2:n.y2,x1:u,x2:p,o:ne}),h.segment.x2=u}else{let u=Math.round((r.x2+e)*100)/100,p=n.x1;h.others.forEach(m=>{m.x1=u,m.x2=u}),i.splice(t+1,0,{y1:n.y2,y2:n.y2,x1:u,x2:p,o:ne}),h.segment.x2=u}}}return o}function wT(i,r,e,t,n){if(i.vertexAvoidance===!1)return{segments:r,sourceAdjusted:!1,targetAdjusted:!1};{let o,s;return n?(o=LT(r,t,i.targetStub),s=RT(r,e,i.sourceStub)):(s=RT(r,e,i.sourceStub),o=LT(r,t,i.targetStub)),{segments:r,sourceAdjusted:s,targetAdjusted:o}}}var Ln="Straight";function Rn(i,r,e){return e>r?r<=i&&i<=e:r>=i&&i>=e}function Vu(i,r,e){return e>=Math.min(i,r)&&e<=Math.max(i,r)}function Gu(i,r,e){return Math.abs(e-i)<Math.abs(e-r)?i:r}var Yo={create(i){let r=ra(i),e=Math.sqrt(Math.pow(r.x2-r.x1,2)+Math.pow(r.y2-r.y1,2)),t=Nr({x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),n=-1/t,o={xmin:Math.min(r.x1,r.x2),ymin:Math.min(r.y1,r.y2),xmax:Math.max(r.x1,r.x2),ymax:Math.max(r.y1,r.y2)};return Object.assign(r,{length:e,m:t,m2:n,extents:o,type:Ln})},boundingBoxIntersection(i,r){return Yo.boxIntersection(i,r.x,r.y,r.width,r.height)},boxIntersection(i,r,e,t,n){let o=[];return o.push.apply(o,Yo.lineIntersection(i,r,e,r+t,e)),o.push.apply(o,Yo.lineIntersection(i,r+t,e,r+t,e+n)),o.push.apply(o,Yo.lineIntersection(i,r+t,e+n,r,e+n)),o.push.apply(o,Yo.lineIntersection(i,r,e+n,r,e)),o},findClosestPointOnPath(i,r,e){let t={d:1/0,x:null,y:null,l:null,x1:i.x1,x2:i.x2,y1:i.y1,y2:i.y2};if(i.m===0)t.y=i.y1,t.x=Vu(i.x1,i.x2,r)?r:Gu(i.x1,i.x2,r);else if(i.m===1/0||i.m===-1/0)t.x=i.x1,t.y=Vu(i.y1,i.y2,e)?e:Gu(i.y1,i.y2,e);else{let o=i.y1-i.m*i.x1,s=e-i.m2*r,a=(s-o)/(i.m-i.m2),l=i.m*a+o;t.x=Vu(i.x1,i.x2,a)?a:Gu(i.x1,i.x2,a),t.y=Vu(i.y1,i.y2,l)?l:Gu(i.y1,i.y2,l)}let n=Be({x:t.x,y:t.y},{x:i.x1,y:i.y1});return t.d=Be({x:r,y:e},t),t.l=n/i.length,t},getLength(i){return i.length},getPath(i,r){return(r?"M "+i.x1+" "+i.y1+" ":"")+"L "+i.x2+" "+i.y2},gradientAtPoint(i,r,e){return i.m},lineIntersection(i,r,e,t,n){let o=Math.abs(Nr({x:r,y:e},{x:t,y:n})),s=Math.abs(i.m),a=s===1/0?i.x1:i.y1-s*i.x1,l=[],h=o===1/0?r:e-o*r;if(o!==s)if(o===1/0&&s===0)Rn(r,i.x1,i.x2)&&Rn(i.y1,e,n)&&l.push({x:r,y:i.y1});else if(o===0&&s===1/0)Rn(e,i.y1,i.y2)&&Rn(i.x1,r,t)&&l.push({x:i.x1,y:e});else{let d,u;o===1/0?(d=r,Rn(d,i.x1,i.x2)&&(u=s*r+a,Rn(u,e,n)&&l.push({x:d,y:u}))):o===0?(u=e,Rn(u,i.y1,i.y2)&&(d=(e-a)/s,Rn(d,r,t)&&l.push({x:d,y:u}))):(d=(h-a)/(s-o),u=s*d+a,Rn(d,i.x1,i.x2)&&Rn(u,i.y1,i.y2)&&l.push({x:d,y:u}))}return l},pointAlongPathFrom(i,r,e,t){let n=Yo.pointOnPath(i,r,t),o=e<=0?{x:i.x1,y:i.y1}:{x:i.x2,y:i.y2};return e<=0&&Math.abs(e)>1&&(e*=-1),zt(n,o,e)},pointOnPath(i,r,e){if(r===0&&!e)return{x:i.x1,y:i.y1};if(r===1&&!e)return{x:i.x2,y:i.y2};{let t=e?r>0?r:i.length+r:r*i.length;return zt({x:i.x1,y:i.y1},{x:i.x2,y:i.y2},t)}}};ta(Ln,Yo);var DT=1e-10;function NT(i){let r=Math.floor(i),e=Math.ceil(i);return i-r<DT?r:e-i<DT?e:i}var kl="Arc";function IT(i,r,e,t){return gb({x:i,y:r},{x:e,y:t})}function uw(i,r){if(i.anticlockwise){let e=i.startAngle<i.endAngle?i.startAngle+vi:i.startAngle,t=Math.abs(e-i.endAngle);return e-t*r}else{let e=i.endAngle<i.startAngle?i.endAngle+vi:i.endAngle,t=Math.abs(e-i.startAngle);return i.startAngle+t*r}}var $u={create(i){let r=ra(i),e=i.cx,t=i.cy,n=i.r,o=i.ac,s,a;i.startAngle&&i.endAngle?(s=i.startAngle,a=i.endAngle,r.x1=e+n*Math.cos(s),r.y1=t+n*Math.sin(s),r.x2=e+n*Math.cos(a),r.y2=t+n*Math.sin(a)):(s=IT(e,t,r.x1,r.y1),a=IT(e,t,r.x2,r.y2)),a<0&&(a+=vi),s<0&&(s+=vi);let l=a<s?a+vi:a,h=Math.abs(l-s);o&&(h=vi-h);let d=2*Math.PI*n,u=h/vi,p=d*u,m={xmin:e-n,xmax:e+n,ymin:t-n,ymax:t+n};return Object.assign(r,{extents:m,length:p,frac:u,circumference:d,sweep:h,startAngle:s,endAngle:a,anticlockwise:o,cx:e,cy:t,radius:n,type:kl})},boundingBoxIntersection(i,r){return $u.boxIntersection(i,r.x,r.y,r.width,r.height)},boxIntersection(i,r,e,t,n){return zl(i,r,e,t,n)},findClosestPointOnPath(i,r,e){return rT(i,r,e)},getLength(i){return i.length},getPath(i,r){let e=i.sweep>Math.PI?1:0,t=i.anticlockwise?0:1;return(r?"M"+i.x1+" "+i.y1+" ":"")+"A "+i.radius+" "+i.radius+" 0 "+e+","+t+" "+i.x2+" "+i.y2},gradientAtPoint(i,r,e){let t=$u.pointOnPath(i,r,e),n=mb({x:i.cx,y:i.cy},t);return!i.anticlockwise&&(n===1/0||n===-1/0)&&(n*=-1),n},lineIntersection(i,r,e,t,n){return nT(i,r,e,t,n)},pointAlongPathFrom(i,r,e,t){let n=$u.pointOnPath(i,r,t),o=e/i.circumference*2*Math.PI,s=i.anticlockwise?-1:1,a=n.theta+s*o,l=i.cx+i.radius*Math.cos(a),h=i.cy+i.radius*Math.sin(a);return{x:l,y:h}},pointOnPath(i,r,e){if(r===0)return{x:i.x1,y:i.y1,theta:i.startAngle};if(r===1)return{x:i.x2,y:i.y2,theta:i.endAngle};e&&(r=r/length);let t=uw(i,r),n=i.cx+i.radius*Math.cos(t),o=i.cy+i.radius*Math.sin(t);return{x:NT(n),y:NT(o),theta:t}}};ta(kl,$u);var MT={x:[Q,fe],y:[fe,Q]};function VT(i,r){return[i.startStubX,i.startStubY,i.endStubX,i.endStubY]}var Wl=new Map;Wl.set(rf,VT),Wl.set(nf,VT),Wl.set(of,(i,r)=>{let e=i,t=e.sourceAxis,n={[Q]:function(){return e.so[t]===1&&(e.startStubX>e.endStubX&&e.tx>e.startStubX||e.sx>e.endStubX&&e.tx>e.sx)||e.so[t]===-1&&(e.startStubX<e.endStubX&&e.tx<e.startStubX||e.sx<e.endStubX&&e.tx<e.sx)},[fe]:function(){return e.so[t]===1&&(e.startStubY>e.endStubY&&e.ty>e.startStubY||e.sy>e.endStubY&&e.ty>e.sy)||e.so[t]===-1&&(e.startStubY<e.endStubY&&e.ty<e.startStubY||e.sy<e.endStubY&&e.ty<e.sy)}};return!r&&n[e.sourceAxis]()?{[Q]:[(i.sx+i.tx)/2,i.startStubY,(i.sx+i.tx)/2,i.endStubY],[fe]:[i.startStubX,(i.sy+i.ty)/2,i.endStubX,(i.sy+i.ty)/2]}[e.sourceAxis]:[i.startStubX,i.startStubY,i.endStubX,i.endStubY]});var Zl=new Map;Zl.set(rf,(i,r,e,t,n,o,s,a,l,h)=>{let d={x:[[[1,2,3,4],null,[2,1,4,3]],null,[[4,3,2,1],null,[3,4,1,2]]],y:[[[3,2,1,4],null,[2,3,4,1]],null,[[4,1,2,3],null,[1,4,3,2]]]},u={x:[[i.startStubX,i.endStubX],null,[i.endStubX,i.startStubX]],y:[[i.startStubY,i.endStubY],null,[i.endStubY,i.startStubY]]},p={x:[{x:a,y:i.startStubY},{x:a,y:i.endStubY}],y:[{x:i.startStubX,y:l},{x:i.endStubX,y:l}]},m={x:[{x:i.endStubX,y:i.startStubY}],y:[{x:i.startStubX,y:i.endStubY}]},g={x:[{x:i.startStubX,y:i.endStubY},{x:i.endStubX,y:i.endStubY}],y:[{x:i.endStubX,y:i.startStubY},{x:i.endStubX,y:i.endStubY}]},E={x:[{x:i.startStubX,y:l},{x:i.endStubX,y:l},{x:i.endStubX,y:i.endStubY}],y:[{x:a,y:i.startStubY},{x:a,y:i.endStubY},{x:i.endStubX,y:i.endStubY}]},y={x:[i.startStubY,i.endStubY],y:[i.startStubX,i.endStubX]},x=MT[e][0],f=MT[e][1],b=i.so[x]+1,A=i.to[f]+1,T=i.to[f]===-1&&y[e][1]<y[e][0]||i.to[f]===1&&y[e][1]>y[e][0],S=u[e][b][0],R=u[e][b][1],v=d[e][b][A];if(i.quadrant===v[3]||i.quadrant===v[2]&&T)return p[e];if(i.quadrant===v[2]&&R<S)return m[e];if(i.quadrant===v[2]&&R>=S||i.quadrant===v[1]&&!T)return E[e];if(i.quadrant===v[0]||i.quadrant===v[1]&&T)return g[e]}),Zl.set(nf,(i,r,e,t,n,o,s,a,l,h)=>{let d={[Q]:i.so.x===-1?Math.min(t,o):Math.max(t,o),[fe]:i.so.y===-1?Math.min(t,o):Math.max(t,o)}[e];return{[Q]:[{x:d,y:n},{x:d,y:s},{x:o,y:s}],[fe]:[{x:n,y:d},{x:s,y:d},{x:s,y:o}]}[e]}),Zl.set(of,(i,r,e,t,n,o,s,a,l,h)=>{let d={[Q]:fe,[fe]:Q}[e],u=e===Q?i.isXGreaterThanStubTimes2:i.isYGreaterThanStubTimes2;if(r.sourceInfo.id===r.targetInfo.id){let p={[Q]:De,[fe]:Te}[e],m=n+(1-r.sourcePos[d])*r.sourceInfo[p]+h;return{[Q]:[{x:t,y:m},{x:o,y:m}],[fe]:[{x:m,y:t},{x:m,y:o}]}[e]}else{if(!u||i.so[e]===1&&t>o||i.so[e]===-1&&t<o)return{[Q]:[{x:t,y:l},{x:o,y:l}],[fe]:[{x:a,y:t},{x:a,y:o}]}[e];if(i.so[e]===1&&t<o||i.so[e]===-1&&t>o)return{[Q]:i.sy===i.ty?[{y:i.ty,x:o}]:[{x:a,y:i.sy},{x:a,y:i.ty}],[fe]:i.sx===i.tx?[{x:i.tx,y:o}]:[{x:i.sx,y:l},{x:i.tx,y:l}]}[e]}});function GT(i,r,e){let t={lastx:null,lasty:null,orthogonalSegments:[]},n=e.targetPos.curX>=e.sourcePos.curX?e.sourcePos.curX:e.targetPos.curX,o=e.targetPos.curY>=e.sourcePos.curY?e.sourcePos.curY:e.targetPos.curY,s=Wl.get(r.anchorOrientation)(r,i.alwaysRespectStubs),a=r.sourceAxis===Q?0:1,l=r.sourceAxis===Q?1:0,h=s[a],d=s[l],u=s[a+2],p=s[l+2];Hl(t,s[0],s[1],r,n,o);let m=r.startStubX+(r.endStubX-r.startStubX)*i.midpoint,g=r.startStubY+(r.endStubY-r.startStubY)*i.midpoint,y=Zl.get(r.anchorOrientation)(r,e,r.sourceAxis,h,d,u,p,m,g,Math.max(i.sourceStub,i.targetStub));if(y)for(let x=0;x<y.length;x++)Hl(t,y[x].x,y[x].y,r,n,o);return Hl(t,s[2],s[3],r,n,o),Hl(t,r.tx,r.ty,r,n,o),t.orthogonalSegments}function Bu(i,r){let e=r;return i.smooth===!0&&e.length>=2?gw(i,e).map(n=>zr(i,n.type,n.segment)):i.cornerRadius!=null&&e.length>1?pw(i,e):e.map(t=>zr(i,Ln,t)),i.$pathSegments=e,e}function $T(i){return Math.atan2(i.y1-i.y2,i.x1-i.x2)}function BT(i){return Math.sqrt(Math.pow(i.x2-i.x1,2)+Math.pow(i.y2-i.y1,2))}function pw(i,r){let e=null,t,n,o;for(let s=0;s<r.length-1;s++){if(e=e||Object.assign({},r[s]),t=Object.assign({},r[s+1]),n=$T(e),o=$T(t),i.cornerRadius>0&&n!==o){let a=Math.min(BT(e),BT(t)),l=Math.min(i.cornerRadius,.99*a/2),h={x:e.x2+l*Math.cos(n),y:e.y2+l*Math.sin(n)},d={x:t.x1-l*Math.cos(o),y:t.y1-l*Math.sin(o)},u=Math.atan((n-o)/(1+n*o)),p=rr({x:e.x1,y:e.y1},h,1e4),m=rr({x:t.x1,y:t.y1},d,1e4),g=Wg(p,m),E=g!=null?Be(g,h):0;E>0?(e.x2=h.x,e.y2=h.y,t.x1=d.x,t.y1=d.y,zr(i,Ln,Object.assign({},e)),i.slightlyWonky?zr(i,kl,Object.assign({r:l,cx:g.x,cy:g.y,ac:u>0},e)):zr(i,kl,{r:E,x1:h.x,y1:h.y,x2:d.x,y2:d.y,cx:g.x,cy:g.y,ac:u>0})):zr(i,Ln,Object.assign({},e))}else zr(i,Ln,Object.assign({},e));e=t}t!=null&&zr(i,Ln,Object.assign({},e))}var mw=(i,r)=>{let e=r.x-i.x,t=r.y-i.y;return{length:Math.sqrt(Math.pow(e,2)+Math.pow(t,2)),angle:Math.atan2(t,e)}},FT=(i,r,e,t,n)=>{let a=mw(r||i,e||i),l=a.angle+(n?Math.PI:0),h=a.length*t,d=i.x+Math.cos(l)*h,u=i.y+Math.sin(l)*h;return{x:d,y:u}};function af(i,r){let e=[];for(let t=1;t<i.length;t++){let n=FT(i[t-1],i[t-2],i[t],r),o=FT(i[t],i[t-1],i[t+1],r,!0);e.push({type:Bo,segment:{x1:i[t-1].x,y1:i[t-1].y,cp1:n,cp2:o,x2:i[t].x,y2:i[t].y}})}return e}function gw(i,r){let e=[{x:r[0].x1,y:r[0].y1}];for(let t=1;t<r.length;t++)e.push({x:r[t].x1,y:r[t].y1});return e.push({x:r[r.length-1].x2,y:r[r.length-1].y2}),af(e,i.smoothing)}function Ew(i,r,e){return lf([{x1:r.sx,y1:r.sy,x2:r.startStubX,y2:r.startStubY},{x1:r.startStubX,y1:r.startStubY,x2:r.endStubX,y2:r.endStubY},{x1:r.endStubX,y1:r.endStubY,x2:r.tx,y2:r.ty}])}function Fu(i,r,e,t,n){let o=i.connector;o.lastx=null,o.lasty=null,o.lastOrientation=null;let s=e.sourcePos,a=e.targetPos;return o.$pathSegments=o.geometry.segments,o.constrain===nn?UT(s,a,o,r,e,t,n):fw(s,a,o,r.quadrant,t,n),Bu(o,o.$pathSegments),{segments:o.$pathSegments,source:e.sourcePos,target:e.targetPos,quadrant:r.quadrant}}function Uu(i,r,e){let t=i.connector;return t.lastx=null,t.lasty=null,t.lastOrientation=null,t.constrain===nn?t.$pathSegments=GT(t,r,e):t.$pathSegments=Ew(t,r,e),Bu(t,t.$pathSegments),{segments:t.$pathSegments,source:e.sourcePos,target:e.targetPos,quadrant:r.quadrant}}function fw(i,r,e,t,n,o){if(o){let s=e.geometry.segments[e.geometry.segments.length-1];s.x2=r.curX,s.y2=r.curY,e.geometry.target.curX=r.curX,e.geometry.target.curY=r.curY}else if(n){let s=e.geometry.segments[0];s.x1=i.curX,s.y1=i.curY,e.geometry.source.curX=i.curX,e.geometry.source.curY=i.curY}e.geometry.quadrant=t,e.$pathSegments=e.geometry.segments}function Yu(i,r,e){return{source:na(i.source,r,e),target:na(i.target,r,e),segments:i.segments.map(t=>({x1:t.x1+r,y1:t.y1+e,x2:t.x2+r,y2:t.y2+e}))}}function lf(i){return i.length===0?[]:i.filter(r=>!(r.x1===r.x2&&r.y1===r.y2))}var yw=.15,wn="Straight";function sa(i){return Math.sqrt(Math.pow(i.x2-i.x1,2)+Math.pow(i.y2-i.y1,2))}Ne.register(wn,{compute:Uu,update:Fu,create:hf,transformGeometry:Yu});function xw(i,r){let e=Object.assign(r,{constrain:nn});return hf(i,e)}Ne.register(oa,{compute:Uu,update:Fu,create:xw,transformGeometry:Yu});function bw(i,r){let e=Object.assign(r,{constrain:rn,smooth:!0});return hf(i,e)}Ne.register(TT,{compute:Uu,update:Fu,create:bw,transformGeometry:Yu});function Aw(i){return i==null?null:i===kb?nn:i===Wb?Qc:i}function hf(i,r){let e=Aw(r.constrain);r.stub=r.stub==null?e===nn?vT:null:r.stub;let t=Cu(wn,i,r,[0,0]),n=r.midpoint==null||isNaN(r.midpoint)?.5:r.midpoint,o=r.alwaysRespectStubs!==!1,s=r.loopbackRadius||25;return Object.assign(t,{cornerRadius:r.cornerRadius!=null?r.cornerRadius:null,smooth:r.smooth===!0,smoothing:r.smoothing==null?yw:r.smoothing,geometry:{segments:[]},constrain:e==null?rn:e,$pathSegments:[],loopbackRadius:s,isLoopbackCurrently:!1,alwaysRespectStubs:o,midpoint:n,lastOrientation:null,lastx:null,lasty:null,slightlyWonky:r.slightlyWonky===!0})}function zT(i,r,e){YT(1,i,r,e),YT(0,i,r,e)}var Fi="x2",Ui="x1",Yi="y1",zi="y2";function Sw(i,r,e){let t=e===i.x1?{value:i.x2,coord:Fi,prev:!0}:{value:i.x1,coord:Ui,prev:!0},n=e===r.x1?{value:r.x2,coord:Fi,prev:!1}:{value:r.x1,coord:Ui,prev:!1},o=Math.abs(e-t.value),s=Math.abs(e-n.value),a=o>s?t:n,l=o>s?n:t;return Object.assign(a,{ref:l.value})}function Tw(i,r,e){let t=e===i.y1?{value:i.y2,coord:zi,prev:!0}:{value:i.y1,coord:Yi,prev:!0},n=e===r.y1?{value:r.y2,coord:zi,prev:!1}:{value:r.y1,coord:Yi,prev:!1},o=Math.abs(e-t.value),s=Math.abs(e-n.value),a=o>s?t:n,l=o>s?n:t;return Object.assign(a,{ref:l.value})}function vw(i,r){if(r.length<5)return r;function e(d,u,p){let m=p===d.x1?d.x2:d.x1,g=p===u.x1?u.x2:u.x1;if(m>u.x1&&u.x2>m||m>u.x2&&u.x1>m)return m;if(g>d.x1&&d.x2>g||g>d.x2&&d.x1>g)return g}function t(d,u,p){let m=p===d.y1?d.y2:d.y1,g=p===u.y1?u.y2:u.y1;if(m>u.y1&&u.y2>m||m>u.y2&&u.y1>m)return m;if(g>d.y1&&d.y2>g||g>d.y2&&d.y1>g)return g}let n=r[1],o,s,a=Math.max(i.sourceStub,i.targetStub),l=[];for(let d=2;d<r.length-2;d++)if(o=r[d],s=Uo(n)[n.o],o.o!==n.o)if(sa(o)<a){let p=r[d+1];if(Uo(p)[p.o]!==s){let g=Object.assign({},o);if(o.o===he){let E=Sw(n,p,o.x1),y=e(n,p,o.x1);if(y!=null){if(g.x1=y,g.x2=y,E.prev){let x=Object.assign({},n);n.x2===o.x1?x.x2=y:x.x1=y,l.push({start:d-1,segments:[x,g]})}else{let x=Object.assign({},p);p.x1===o.x1?x.x1=y:x.x2=y,l.push({start:d-1,segments:[g,x]})}n=p,d+=1}else n=o}else if(o.o===ne){let E=Tw(n,p,o.y1),y=t(n,p,o.y1);if(y!=null){if(g.y1=y,g.y2=y,E.prev){let x=Object.assign({},n);n.y2===o.y1?x.y2=y:x.y1=y,l.push({start:d-1,segments:[x,g]})}else{let x=Object.assign({},p);p.y1===o.y1?x.y1=y:x.y2=y,l.push({start:d-1,segments:[g,x]})}n=p,d+=1}else n=o}}else n=o}else n=o;else n=o;let h=r.slice();for(let d=0;d<l.length;d++)h.splice(l[d].start-d,3,...l[d].segments);return l.length>0?cf(h):h}function YT(i,r,e,t){let n=r.$pathSegments.slice();i===1&&n.reverse();let o=n[0],s=n[n.length-1],a=i===1?r.targetStub:r.sourceStub,l=i===1?t.targetPos.curX:t.sourcePos.curX,h=i===1?t.targetPos.curY:t.sourcePos.curY,d=i===1?e.to:e.so,u=i===1?Fi:Ui,p=i===1?zi:Yi,m=i===1?Ui:Fi,g=i===1?Yi:zi,E=1,y=n.length-2,x=1,f=n[1];o[m]=l+a*d.x,o[g]=h+a*d.y,o[u]=l,o[p]=h,o.o=o.x1===o.x2?"v":"h";let b=Uo(o),A=o.o,T=o.o===ne?he:ne,S=o.o===ne?[Fi,Ui]:[zi,Yi],R=o.o===ne?[Ui,Fi]:[Yi,zi],v=o.o===ne?[zi,Yi]:[Fi,Ui],O=o.o===ne?[Yi,zi]:[Ui,Fi],P=S[i],I=R[i],C=v[i],_=O[i];if(f!=null)if(f.o===o.o){f[I]=o[P],f[C]=f[_]=o[C];let B=Uo(f)[A],D=Mu(n,x,T,f);if(B!==b[A]){if(D!=null){let M=Mu(n,x,A,D[0]);if(M!=null)n.splice(E,1),M[0][I]=o[P],D[0][P]=o[P],D[0][I]=o[P],D[0][_]=o[C];else{let N=(D[0][C]+D[0][_])/2;D[0][_]=N,f[C]=f[_]=N;let G={x1:0,y1:0,x2:0,y2:0,o:T,[P]:o[P],[C]:N,[_]:o[C],[I]:o[P]};n.splice(E,0,G)}}}else f[C]=f[_]=o[C],D!=null&&(D[0][_]=o[C])}else{f[_]=o[C],f[P]=f[I]=o[P];let B=Mu(n,x,A,f);if(B!=null){let D=Uo(B[0])[A];B[0][I]=o[P];let M=Uo(B[0])[A];if(D!==M&&B[1]===y){n.splice(B[1],1);let N=(f[C]+f[_])/2;f[_]=N,f[P]=f[I]=s[I];let G={x1:0,y1:0,x2:0,y2:0,o:A,[P]:s[I],[C]:N,[_]:N,[I]:o[P]};n.splice(E,0,G);let J={x1:0,y1:0,x2:0,y2:0,o:T,[P]:o[P],[C]:N,[_]:o[C],[I]:o[P]};n.splice(E,0,J)}}else{let D=(f[C]+f[_])/2;f[_]=D,f[P]=f[I]=s[I];let M={x1:0,y1:0,x2:0,y2:0,o:A,[P]:s[I],[C]:D,[_]:D,[I]:o[P]};n.splice(E,0,M);let N={x1:0,y1:0,x2:0,y2:0,o:T,[P]:o[P],[C]:D,[_]:o[C],[I]:o[P]};n.splice(E,0,N)}}let w=vw(r,n);i===1&&w.reverse(),r.$pathSegments=w}function UT(i,r,e,t,n,o,s){let a=e.geometry;if(o||s){let l=i.curX-a.source.curX,h=i.curY-a.source.curY,d=r.curX-a.target.curX,u=r.curY-a.target.curY;if(l===d&&h===u){let p=[];e.$pathSegments.forEach(m=>{let g=Object.assign({},m);g.x1+=l,g.x2+=l,g.y1+=h,g.y2+=h,p.push(g)}),e.$pathSegments=p;return}zT(e,t,n)}}function Cw(i,r,e){let t=i.findIndex(n=>n.x1===r.x1&&n.y1===r.y1&&n.x2===r.x2&&n.y2===r.y2);if(t>-1){let n=i[t].o,o=i[t];return{segment:o,index:t,axis:n,prev:t>1?i[t-1]:null,next:t<i.length-2?i[t+1]:null,left:e?Iu(i,-1,n,o):null,right:e?Iu(i,1,n,o):null}}else return null}function XT(i,r,e,t,n){let o=Cw(r.$pathSegments,e);if(o!=null){o.axis===he?o.segment.x1=o.segment.x2=t.x:o.segment.y1=o.segment.y2=t.y;let s=o.axis===he,a=o.index,l=o.index,h=a>1?r.$pathSegments[a-1]:null,d=o.segment;for(;h!=null;)h.o===d.o?s?(h.x1=d.x1,h.x2=d.x2):(h.y1=d.y1,h.y2=d.y2):(h.x2=d.x1,h.y2=d.y1),d=h,a--,h=a>1?r.$pathSegments[a-1]:null;if(d.x1!==r.$pathSegments[0].x2){let m={o:ne,x1:r.$pathSegments[0].x2,y1:r.$pathSegments[0].y2,x2:d.x1,y2:d.y1};r.$pathSegments.splice(1,0,m),l++}else if(d.y1!==r.$pathSegments[0].y2){let m={o:he,x1:r.$pathSegments[0].x2,y1:r.$pathSegments[0].y2,x2:d.x1,y2:d.y1};r.$pathSegments.splice(1,0,m),l++}d=o.segment,a=l;let u=a<r.$pathSegments.length-2?r.$pathSegments[a+1]:null;for(;u!=null;)u.o===d.o?s?(u.x1=d.x1,u.x2=d.x2):(u.y1=d.y1,u.y2=d.y2):(u.x1=d.x2,u.y1=d.y2),d=u,a++,u=a<r.$pathSegments.length-2?r.$pathSegments[a+1]:null;let p=r.$pathSegments[r.$pathSegments.length-1];if(d.x2!==p.x1){let m={o:ne,x1:d.x2,y1:d.y2,x2:p.x1,y2:p.y1};r.$pathSegments.splice(r.$pathSegments.length-1,0,m)}else if(d.y2!==p.y1){let m={o:he,x1:d.x2,y1:d.y2,x2:p.x1,y2:p.y1};r.$pathSegments.splice(r.$pathSegments.length-1,0,m)}if(n!==!0){let m=i.instance.getElement(i.sourceId),g=i.instance.getElement(i.targetId);wT(r,r.$pathSegments,m,g,!1).sourceAdjusted&&(l+=1)}return r.edited=!0,{ctx:o,segments:r.$pathSegments,index:l}}else return null}function cf(i){let r=[ot(i[0])],e=ot(i[i.length-1]),t=i.slice(1,i.length-1).filter(s=>sa(s)>0).map(ot);if(t.length===0)return i;let n=null,o=null;for(let s=0;s<t.length;s++)n==null||o==null?(n=t[s],o=t[s].o):t[s].o===o?(n.y2=t[s].y2,n.x2=t[s].x2):(r.push(n),n=t[s],o=t[s].o);if(r.push(n),r.push(e),r.length===3){let s=r[1],a=s.o,l=Object.assign({},s),h=Object.assign({},s),d=Object.assign({},s);h.o=a===ne?he:ne,h.x1=l.x1,h.y1=l.y1,h.x2=l.x1,h.y2=l.y1,d.o=a===ne?he:ne,d.x1=l.x2,d.y1=l.y2,d.x2=l.x2,d.y2=l.y2,r=[r[0],h,l,d,r[2]]}return r}function jT(i){let r=cf(i.$pathSegments);i.$pathSegments=r,i.geometry!=null&&(i.geometry.segments=r)}function Qee(i,r,e){if(i.$pathSegments.length>=2){let t=r===0?i.$pathSegments[0]:i.$pathSegments[i.$pathSegments.length-1],n=e[0]===0?he:ne;t.o=n,i.edited=!0}}var zu=class extends $t{constructor(e){super();c(this,"$context");this.$context=e||{}}getFromContext(e){return this.$context[e]}ensureContext(e,t){let n=this.$context[e];return n==null&&(n=t(),this.$context[e]=n,this.fire(Dl,{key:e,value:n})),n}updateContext(e,t){this.$context[e]=t,this.fire(Dl,{key:e,value:t})}};var Xi=(e=>(e.SVG="SVG",e.HTML="HTML",e))(Xi||{});var jr="px",Dn="50px",Or="block",ht="none",Vte=0,Gte=1,je="absolute",df="fixed",HT="static",kT="relative",WT="data-vjs-group",Pt="data-vjs-managed",Jl="data-vjs-not-draggable",ZT="data-vjs-elements-draggable",uf="tabindex",$te="overlays",ee="data-vjs-vertex",ln="data-vjs-port",Kl="data-vjs-port-id",Hr="data-vjs-port-type",Xu="data-vjs-edge-type",ju="data-vjs-source",zo="data-vjs-target",pf="data-vjs-allow-loopback",Hu="data-vjs-source-port-id",ku="data-vjs-target-port-id",Xo="data-vjs-source-port",jo="data-vjs-target-port",ai="data-vjs-source-port-type",ji="data-vjs-target-port-type",Wu="data-vjs-magnet",Ze="data-vjs-edge",Zu="data-vjs-overlay-id",yr="*";var aa="vjs-connector",JT="vjs-connector-path",KT="vjs-connector-outline",qT="vjs-connector-transient",ql="vjs-connected",mf="vjs-group-collapsed",gf="vjs-group-expanded",Ju="vjs-toggle-group-collapse",la="vjs-overlay",Ql="vjs-overlay-hide",QT="vjs-label-overlay",Hi="vjs-node",ev="vjs-port",Ho="vjs-group",tv="vjs-dummy-vertex",eh="vjs-selected-connection",ki="vjs-selected-element",ha="vjs-edge-delete",Ku="vjs-edge-delete-i";var Ef="allowNestedGroups",th="anchor",rh="anchors",lre="astarGridCellSize",rv="astarVertexBorder",nv="astarVertexBuffer",hre="overlays",cre="edgesDetachable",qu="connector",iv="cssClass",ov="edgeRelocateHandleSize",dre="ensureAnchorsInWhitespace",ure="groupSize",sv="hoverClass",Qu="hoverPaintStyle",av="maxConnections",pre="nodeSize",ko="paintStyle",mre="reattachEdges",ff="scope",lv=[.05,3];function hv(i){return i.type!=null&&i.options!=null}function hi(i){let r=null;return z(i)?r={type:i,options:{}}:r=i,r.options.id=r.options.id||V(),r}var ep="always",Wi="hover";function yf(i,r){let e=i.location==null?.5:i.location;if(r!=null)try{let t=typeof r=="string"?parseFloat(r):r;isNaN(t)||(e=t)}catch(t){}i.location=e}var li=class{constructor(r,e){this.component=r;c(this,"id");c(this,"cssClass");c(this,"Qo");c(this,"visible",!0);c(this,"location",.5);c(this,"events");c(this,"attributes");c(this,"ignoreTypes",!1);e=e||{},this.id=e.id||V(),this.cssClass=e.cssClass||"",yf(this,e.location),this.events=e.events||{},this.attributes=e.attributes||{},this.Qo=r.instance.$isTouchDevice()?ep:e.visibility||ep,this.Qo===Wi&&(this.visible=!1)}},Nn=class extends li{constructor(e,t,n){super(t,n);this.component=t;c(this,"paintStyle");c(this,"$hollow");c(this,"isSimpleShape",!0);n=n||{},this.paintStyle=n.paintStyle||{strokeWidth:1},this.$hollow=n.hollow===!0}$getStyle(e){let t=this.paintStyle.stroke||e.stroke,n=this.$hollow?"none":this.paintStyle.fill||e.stroke,o=this.paintStyle.strokeWidth||e.strokeWidth;return{stroke:t,fill:n,lineWidth:o}}updateFrom(e,t){}};var cv={},nt={get:(i,r,e,t)=>{let n=cv[r];if(n)return new n(i,e,t);throw{message:"VisuallyJs: unknown overlay type '"+r+"'"}},register:(i,r)=>{cv[i]=r}};var tp=class tp extends li{constructor(e,t,n){super(t,n);this.instance=e;this.component=t;c(this,"label");c(this,"type",tp.type);c(this,"useHTMLElement");c(this,"font");c(this,"isSimpleShape",!1);n=n||{label:""},this.useHTMLElement=e.containerType!=="SVG"&&n.useHTMLElement===!0,this.font=n.font,this.setLabel(n.label)}getLabel(){return vr(this.label)?this.label(this):this.label}setLabel(e){this.label=e,this.instance.updateLabel(this)}updateFrom(e,t){e.font!=null&&(this.font=e.font),e.label!=null&&this.setLabel(e.label),e.location!=null&&yf(this,e.location),xf(this,t)}};c(tp,"type","Label");var or=tp;function kr(i){return i.type===or.type}nt.register(or.type,or);function xf(i,r){if(r){let e=r.fontSize;e!=null&&(i.font=i.font||{},i.font.size=e);let t=r.fontStyle;t!=null&&(i.font=i.font||{},i.font.style=t);let n=r.fontFamily;n!=null&&(i.font=i.font||{},i.font.family=n)}}var Af="labelLocation",Pw=[th,rh,"cssClass",qu,ko,Qu],Ow="parent";function rp(i,r){let e=h=>h?r[h]:null,t=(h,d)=>{if(h==null)return null;{let u=h[Ow],p;if(Array.isArray(u)?p=u:p=[u],p.find(g=>d.indexOf(g)!==-1))throw new Error("circular view reference");return d.push(...p),p.map(g=>e(g)).filter(g=>g!=null)}},n=(h,d,u)=>{let p=Pw.slice();d.mergeStrategy==="override"&&Array.prototype.push.apply(p,["events","overlays"]);let m=fn(h,d,[],p);return o(t(h,u),m,u)},o=(h,d,u)=>{if(h==null)return d;{let p=d;for(let m=0;m<h.length;m++)p=n(h[m],p,u);return p}},s=h=>{if(h==null)return{};if(typeof h=="string")return e(h);if(h.length){let d=!1,u=0,p;for(;!d&&u<h.length;)p=s(h[u]),p?d=!0:u++;return p}},a=s(i),l=[];return a?o(t(a,l),a,l):{}}function ca(i){return(r,e,t)=>{let n=Vc(e,{x:0,y:0,width:1,height:1},i);return Object.assign(n.p,{portId:i[n.idx].portId})}}function bf(i){i.anchorPositions!=null&&(i.anchorPositionFinder=ca(i.anchorPositions))}var np=class{constructor(r,e,t,n){this.model=r;this.viewOptions=t;c(this,"defMap",{nodes:new Map,edges:new Map,groups:new Map,ports:new Map});c(this,"nodes");c(this,"edges");c(this,"groups");c(this,"ports");this.viewOptions=this.viewOptions||{},this.nodes=this.viewOptions.nodes||{},this.edges=this.viewOptions.edges||{},this.ports=this.viewOptions.ports||{},this.groups=this.viewOptions.groups||{};let o,s;function a(l,h){return d=>{l.call(h,{overlay:d.overlay,e:d.e,connection:d.overlay.component,edge:d.overlay.component.edge,model:d.overlay.component.instance.model})}}for(let l in this.viewOptions.edges){if(o=this.getEdgeDefinition(l),o.overlays)for(s=0;s<o.overlays.length;s++){let h=o.overlays[s];if(hv(h)){let d=h.options;if(d.events!=null)for(let u in d.events){let p=d.events[u];d.events[u]=a(p,h)}}}n.$registerConnectionType(l,o)}}getEdgeDefinition(r){if(r==null)return null;if(this.defMap.edges.has(r))return this.defMap.edges.get(r);{let e=rp([r,xe],this.edges);if(e.label!=null){e.overlays=e.overlays||[];let t={type:or.type,options:{useHTMLElement:e.useHTMLLabel===!0,id:"label",label:e.label}};e.labelClass&&(t.options.cssClass=e.labelClass);let n=e.labelLocationAttribute||Af;e.labelLocation?t.options.location=e.labelLocation:t.options.location=`{{${n}}}`,e.labelLocationAttribute&&(t.options.labelLocationAttribute=e.labelLocationAttribute),e.labelFont&&(t.options.font=Object.assign({},e.labelFont)),e.overlays.push(t),delete e.label}if(e.deleteButton!=null){e.overlays=e.overlays||[];let t=(e.deleteButtonClass||ha)+" "+Ku,n=e.deleteButtonLocation||.1;(Array.isArray(n)?n:[n]).forEach(s=>{e.overlays.push({type:or.type,options:{location:s,label:"\u2716",cssClass:t,visibility:e.deleteButton===Wi?Wi:ep}})})}return delete e.parent,this.defMap.edges.set(r,e),e}}getNodeDefinition(r){if(r==null)return null;if(this.defMap.nodes.has(r))return this.defMap.nodes.get(r);{let e=rp([r,xe],this.nodes);return delete e.parent,bf(e),this.defMap.nodes.set(r,e),e}}getPortDefinition(r){if(r==null)return null;if(this.defMap.ports.has(r))return this.defMap.ports.get(r);{let e=rp([r,xe],this.ports);return delete e.parent,bf(e),this.defMap.ports.set(r,e),e}}getGroupDefinition(r){if(r==null)return null;if(this.defMap.groups.has(r))return this.defMap.groups.get(r);{let e=rp([r,xe],this.groups);return delete e.parent,bf(e),this.defMap.groups.set(r,e),e}}getTypeDefinition(r){let e=this.model.getType(r);if(K(r))return this.getNodeDefinition(e);if(Y(r))return this.getGroupDefinition(e);if(H(r))return this.getPortDefinition(e)}};function ip(){return{c:new Set,e:new Set}}var dv=class{constructor(){c(this,"affectedElements",new Set)}};function _w(i){return{id:i,el:null,dirty:!0,x:NaN,y:NaN,width:NaN,height:NaN,modelObject:null,r:0,c:{x:0,y:0},ro:{x:0,y:0},x2:0,y2:0,t:{id:i,c:{x:0,y:0},x:NaN,y:NaN,width:NaN,height:NaN,r:0,x2:0,y2:0,cr:0,sr:0,ro:{x:0,y:0}}}}function Rw(i,r,e,t,n,o){let s=o/360*Math.PI*2,a={x:r+t/2,y:e+n/2},l=Math.cos(s),h=Math.sin(s),d=(A,T)=>xt({x:A,y:T},a,o),u=d(r,e),p=d(r+t,e),m=d(r+t,e+n),g=d(r,e+n),E=d(r+t/2,e+n/2),y=Math.min(u.x,p.x,m.x,g.x),x=Math.max(u.x,p.x,m.x,g.x),f=Math.min(u.y,p.y,m.y,g.y),b=Math.max(u.y,p.y,m.y,g.y);return{x:y,y:f,width:x-y,height:b-f,c:E,r:o,x2:x,y2:b,cr:l,sr:h,id:i,ro:{x:y,y:f}}}var op=(i,r)=>{let e=0;return r.value>i.value?e=-1:r.value<i.value&&(e=1),e},uv=(i,r)=>op(i,r)*-1;function sp(i,r,e,t,n){Qg({id:i,value:r,otherBound:e},t,op,n)}function Zi(i,r){let e=r.findIndex(t=>t.id===i);e>-1&&r.splice(e,1)}var ap=class{constructor(r,e){this.instance=r;this.getRenderedElement=e;c(this,"$d",null);c(this,"rtree");c(this,"Ye",!1);c(this,"Va",!0);c(this,"O",{xmin:[],xmax:[],ymin:[],ymax:[]});c(this,"N",{});c(this,"Ga",{});c(this,"Xe",{xmin:0,xmax:0,ymin:0,ymax:0});this.rtree=new ea(4)}setSuspended(r){this.Ye=r,this.Ye||(this.recomputeBounds(),this.gE())}getExtents(){return Object.assign({},this.Xe)}EE(r,e,t){e!=null&&(Zi(r,this.O.xmin),Zi(r,this.O.xmax),Zi(r,this.O.ymin),Zi(r,this.O.ymax),sp(r,e.t.x,e.t.x2,this.O.xmin,!1),sp(r,e.t.x2,e.t.x,this.O.xmax,!0),sp(r,e.t.y,e.t.y2,this.O.ymin,!1),sp(r,e.t.y2,e.t.y,this.O.ymax,!0),t!==!0&&this.es())}es(){this.Xe.xmin=this.O.xmin.length>0?this.O.xmin[0].value:0,this.Xe.xmax=this.O.xmax.length>0?this.O.xmax[0].value:0,this.Xe.ymin=this.O.ymin.length>0?this.O.ymin[0].value:0,this.Xe.ymax=this.O.ymax.length>0?this.O.ymax[0].value:0}recomputeBounds(){if(this.Va){this.Va=!1,this.O.xmin.length=0,this.O.xmax.length=0,this.O.ymin.length=0,this.O.ymax.length=0;for(let r in this.N){let e=this.N[r];this.O.xmin.push({id:r,value:e.t.x,otherBound:e.t.x2}),this.O.xmax.push({id:r,value:e.t.x2,otherBound:e.t.x}),this.O.ymin.push({id:r,value:e.t.y,otherBound:e.t.y2}),this.O.ymax.push({id:r,value:e.t.y2,otherBound:e.t.y})}this.O.xmin.sort(op),this.O.ymin.sort(op),this.O.xmax.sort(uv),this.O.ymax.sort(uv),this.es()}}findVerticesAtPoint(r,e,t,n,o){t=t==null?0:t;let s=[];if(o=o||[],this.rtree==null)for(let a=0;a<this.O.xmin.length;a++){let l=this.O.xmin[a];if(o.indexOf(l.id)===-1&&l.value-t<r&&l.otherBound+t>r){let h=this.N[l.id];if(h.y-t<e&&h.y2+t>e&&(s.push(h),n))return s}}else{let a=this.rtree.search({x:r-t,y:e-t,width:t===0?1:t*2,height:t===0?1:t*2});for(let l=0;l<a.length;l++){let h=a[l].id;if(o.indexOf(h)===-1&&(s.push(this.N[h]),n))return s}}return s}findVerticesIntersectingWithRect(r,e,t,n,o){e=e==null?0:e;let s=[];if(n=n||[],this.rtree==null)for(let a=0;a<this.O.xmin.length;a++){let l=this.O.xmin[a];if(n.indexOf(l.id)===-1&&Zg(l.value-e,l.otherBound+e,r.x,r.x+r.width,1)){let d=this.N[l.id];if(Zg(d.y-e,d.y2+e,r.y,r.y+r.height,1)&&(s.push(d),t))return s}}else{let a=o?1:0,l=this.rtree.search({x:r.x-e+a,y:r.y-e+a,width:r.width+2*e-2*a,height:r.height+2*e-2*a});for(let h=0;h<l.length;h++){let d=l[h].id;if(n.indexOf(d)===-1&&(s.push(this.N[d]),t))return s}}return s}findVerticesEnclosedByRect(r,e,t,n,o){let s=r.x+r.width,a=r.y+r.height;return this.findVerticesIntersectingWithRect(r,e,t,n,o).filter(l=>o?r.x<l.x&&r.y<l.y&&s>l.x2&&a>l.y2:r.x<=l.x&&r.y<=l.y&&s>=l.x2&&a>=l.y2)}hasVerticesIntersectingWithRect(r,e,t,n){return this.findVerticesIntersectingWithRect(r,e,!0,t,n).length>0}hasLineOfSight(r,e,t){let n=xb(r,e/2);return this.rtree.findIntersectionsWithLine(n[0],t).length===0&&this.rtree.findIntersectionsWithLine(n[1],t).length===0}fE(r,e,t){e.t=Rw(r,e.x,e.y,e.width,e.height,e.r),this.Ga[r]=e.t,this.Va=!0,t!==!0&&(this.Ye||this.EE(r,e,t)),this.rtree!=null&&e.modelObject!=null&&(this.Ye||this.rtree.update(r,e.t.x,e.t.y,e.t.width,e.t.height,{id:r}))}updateElement(r,e,t,n,o,s,a,l){let h=Ds(this.N,r,()=>this.addElement(r,this.getRenderedElement(r),a,{x:e,y:t},{width:n,height:o},s));return h!=null&&(h.dirty=e==null&&h.x==null||t==null&&h.y==null||n==null&&h.width==null||o==null&&h.height==null,a!=null&&(h.modelObject=a),e!=null&&(h.x=e),t!=null&&(h.y=t),n!=null&&(h.width=n),o!=null&&(h.height=o),h.c.x=h.x+h.width/2,h.c.y=h.y+h.height/2,h.x2=h.x+h.width,h.y2=h.y+h.height,s!=null&&(h.r=s||0),h.r==null||h.r===0?h.ro={x:h.x,y:h.y}:h.ro=xt({x:h.x,y:h.y},h.c,h.r),this.$d==null?this.fE(r,h,l):this.$d.affectedElements.add(r)),h}$forEachElement(r){for(let e in this.N)r(this.N[e])}$refreshEveryElement(){for(let r in this.N)this.$refreshElement(r,!0)}$refreshElement(r,e,t,n,o){let s=this.N[r];if(s!=null){let a=n||(this.instance.$_useModelForSizes?{width:s.width,height:s.height}:this.instance.$getSize(s.el)),l=t||this.instance.$getElementPositionInUIRelativeToCanvasOrigin(s.el,a);return(isNaN(l.x)||isNaN(l.y))&&(l=this.instance.$getElementPositionInUIRelativeToCanvasOrigin(s.el)),this.updateElement(r,l.x,l.y,a.width,a.height,o,null,e)}else return null}yE(r,e){return this.updateElement(r,null,null,null,null,e,null,!1)}getBoundsWidth(){return this.Xe.xmax-this.Xe.xmin}getBoundsHeight(){return this.Xe.ymax-this.Xe.ymin}getX(){return this.Xe.xmin}getY(){return this.Xe.ymin}setSize(r,e,t){if(this.N[r]!=null)return this.updateElement(r,null,null,e,t,null,null,!1)}$_updatePosition(r,e,t){if(this.N[r]!=null)return this.updateElement(r,e,t,null,null,null,null,!1)}$_updateSize(r,e,t){if(this.N[r]!=null)return this.updateElement(r,null,null,e,t,null,null,!1)}reset(){this.O.xmin.length=0,this.O.xmax.length=0,this.O.ymin.length=0,this.O.ymax.length=0,this.N={},this.Ga={},this.rtree.clear(),this.es()}remove(r){Zi(r,this.O.xmin),Zi(r,this.O.xmax),Zi(r,this.O.ymin),Zi(r,this.O.ymax),delete this.N[r],delete this.Ga[r],this.rtree!=null&&this.rtree.removeById(r),this.es()}$computeGroupContentExtents(r,e,t,n,o){let s=r.members.map(l=>l.id),a=t!=null?t[r.id]:null;if(a==null){let l=this.instance.viewport.getGroupElement(r.id);o=o||this.instance.$_getGroupContentAreaInfo(r.id),a={x:l.x+o.internalOffset.x,y:l.y+o.internalOffset.y}}return this.$computeExtentsForElementIds(s,e?null:a.x,e?null:a.y,t,n)}$computeExtentsForElementIds(r,e=0,t=0,n,o){let s=1/0,a=-1/0,l=1/0,h=-1/0;return n=n||{},o=o||{},r.forEach(d=>{var p,m,g,E;let u=this.getElement(d);if(u!=null){let y=((p=n[u.id])==null?void 0:p.x)||u.x,x=((m=n[u.id])==null?void 0:m.y)||u.y,f=((g=o[u.id])==null?void 0:g.width)||u.width,b=((E=o[u.id])==null?void 0:E.height)||u.height;s=Math.min(s,y-e),l=Math.min(l,x-t),a=Math.max(a,y-e+f),h=Math.max(h,x-t+b)}}),{xmin:s,xmax:a,ymin:l,ymax:h}}gE(){this.rtree.clear();let r=Object.values(this.N).map(e=>({id:e.id,x:e.t.x,y:e.t.y,width:e.t.width,height:e.t.height,children:[]}));this.rtree.load(r)}getPosition(r){return this.N[r]}getElements(){return this.N}isEmpty(){return Object.keys(this.N).length===0}getElement(r){let e=this.N[r];if(e)return e.dirty?this.$refreshElement(r,!1):e}getElementPosition(r){return this.N[r]!=null?nr(this.N[r]):null}getElementSize(r){return this.N[r]!=null?Ls(this.N[r]):null}getElementBounds(r){return this.N[r]!=null?Object.assign(nr(this.N[r]),Ls(this.N[r])):null}getGroupElement(r){return this.getElement(r)}getNodeElement(r){return this.getElement(r)}addElement(r,e,t,n,o,s){let a=_w(r);a.el=e;let l=Object.assign(a,{connections:[],modelObject:t,visible:!0});if(this.N[r]=l,Y(t)){let m=a;m.collapsed=!1,m.enabled=!0,m.contentArea=this.instance.$getGroupContentAreaElement(e),m.contentAreaOffset=this.instance.$getElementPositionInUIRelativeToParent(m.contentArea)}let h=n==null?{x:0,y:0}:n,d=o==null?{width:0,height:0}:o,u=s==null?0:s,p=this.updateElement(r,h.x,h.y,d.width,d.height,u,t,!0);return p.el=e,l}};var Lw="currentFace",pv={[Et]:Ct,[vt]:Tt,[Tt]:vt,[Ct]:Et},mv={[Et]:vt,[vt]:Ct,[Tt]:Et,[Ct]:Tt},gv={[Et]:Tt,[vt]:Et,[Tt]:Ct,[Ct]:vt};function Sie(i){return i.faces.length===0?Et:i.faces[0]}function nh(i,r){return i.faces.indexOf(r)!==-1}function ww(i,r){return(i.clockwise?mv:gv)[r]}function Dw(i,r){return(i.clockwise?gv:mv)[r]}function Sf(i,r,e){let t=()=>nh(i,r)===!0&&!e(r);return i.lockedAxis==null?i.lockedFace==null?t():i.lockedFace===r:i.lockedAxis.indexOf(r)!==-1}function Nw(i,r){if(nh(i,r))return r;if(nh(i,pv[r]))return pv[r];{let e=ww(i,r);if(nh(i,e))return e;{let t=Dw(i,r);if(nh(i,t))return t}}return r}function Ev(i,r,e){let t={type:i,locations:[{x:0,y:0,offx:0,offy:0,ox:0,oy:0}],currentLocation:0,locked:!1,id:V(),cssClass:e.cssClass||"",isContinuous:!0,timestamp:null,faces:e.faces||r,lockedFace:null,lockedAxis:null,clockwise:e.clockwise!==!1,Bd:null};return Object.defineProperty(t,Lw,{get(){return this.Bd},set(n){this.Bd=Nw(this,n)}}),t}var fv={Continuous:{faces:[Et,Tt,Ct,vt]},ContinuousTop:{faces:[Et]},ContinuousRight:{faces:[vt]},ContinuousBottom:{faces:[Ct]},ContinuousLeft:{faces:[Tt]},ContinuousLeftRight:{faces:[Tt,vt]},ContinuousTopBottom:{faces:[Et,Ct]}};function Iw(i,r){let e=1/0,t=-1;for(let n=0;n<i.locations.length;n++){let o=Math.sqrt(Math.pow(r.x-i.locations[n].x,2)+Math.pow(r.y-i.locations[n].y,2));o<e&&(e=o,t=n,i.currentLocation=n)}return t}var yv={x:.5,y:0,ox:0,oy:-1,offx:0,offy:0},xv={x:.5,y:1,ox:0,oy:1,offx:0,offy:0},bv={x:0,y:.5,ox:-1,oy:0,offx:0,offy:0},Av={x:1,y:.5,ox:1,oy:0,offx:0,offy:0},Mw={x:0,y:0,ox:0,oy:-1,offx:0,offy:0},Vw={x:1,y:0,ox:1,oy:-1,offx:0,offy:0},Gw={x:0,y:1,ox:0,oy:1,offx:0,offy:0},$w={x:1,y:1,ox:0,oy:1,offx:0,offy:0},Bw={x:.5,y:.5,ox:0,oy:0,offx:0,offy:0},Sv={Top:[yv],Bottom:[xv],Left:[bv],Right:[Av],TopLeft:[Mw],TopRight:[Vw],BottomLeft:[Gw],BottomRight:[$w],Center:[Bw],AutoDefault:[yv,bv,xv,Av]};function Tv(i,r){r=r||{};let e=Sv[i];if(e!=null)return Tf(i,e.map(n=>Object.assign({iox:n.ox,ioy:n.oy},n)),r,null);let t=fv[i];if(t!=null)return Ev(i,t.faces,r);throw{message:"VisuallyJs: unknown anchor type '"+i+"'"}}function Tf(i,r,e,t){return{objectType:HE,type:i,locations:r,currentLocation:0,id:V(),isContinuous:!1,isDynamic:r.length>1,isFixed:t!=null,fixedLocation:t,timestamp:null,cssClass:e.cssClass||""}}function vv(i){return i.type==null&&i.x!=null&&i.y!=null&&i.ox!=null&&i.oy!=null}function lp(i,r,e){let t=ft(i);return r!=null&&r<i.length?t.currentLocation=r:e!=null&&Iw(t,e),t}function Fw(i){return i.objectType===HE}function ft(i,r){if(Fw(i))return i;if(r!=null&&(isNaN(r.offsetX)&&(r.offsetX=0),isNaN(r.offsetY)&&(r.offsetY=0),isNaN(r.ox)&&(r.ox=0),isNaN(r.oy)&&(r.oy=0)),z(i)){let e=Tv(i,null);return r!=null&&(e.fixedLocation=r,e.isFixed=!0),e}else{if(vv(i))return Tf(null,[{x:i.x,y:i.y,ox:i.ox,oy:i.oy,offsetX:i.offsetX==null?0:i.offsetX,offsetY:i.offsetY==null?0:i.offsetY}],{},r);if(Array.isArray(i)){let e=i.map(t=>{if(z(t)){let n=Sv[t];return n!=null?Object.assign({iox:n[0].ox,ioy:n[0].oy,cls:""},n[0]):null}else if(vv(t))return Object.assign({iox:t.ox,ioy:t.oy,offx:t.offsetX==null?0:t.offsetX,offy:t.offsetY==null?0:t.offsetY,cls:null},t)}).filter(t=>t!=null);return Tf("Dynamic",e,{},null)}else if(i.type!=null){let e=i;return Tv(e.type,e.options)}else throw`Cannot parse anchor specification ${i}`}}var ioe="___sourceMarker",ooe="___targetMarker",da="__label",Rv="vjs-default-label",Cv="overlay",Uw="labelLocation";function Yw(i,r){let e={cssClass:r.cssClass,id:da,component:i},t=Object.assign(e,r);return new or(i.instance,i,t)}function zw(i,r){let e=null;if(z(r))e=nt.get(i.instance,r,i,{});else if(r.type!=null&&r.options!=null){let t=r,n=Object.assign({},t.options);e=nt.get(i.instance,t.type,i,n)}else e=r;return e.id=e.id||V(),we.cacheTypeItem(i,Cv,e,e.id),i.overlays[e.id]=e,e}function oh(i,r){let e=zw(i,r);if(e.type===or.type&&!z(r)){let t=e,o=r.options.labelLocationAttribute||Uw,s=i.edge.data[o];s&&(t.location=s),xf(t,i.edge.data)}return e}function ih(i,r){return i.overlays[r]}function Xw(i){return i.overlays}function soe(i,r){let e=ih(i,r);e&&i.instance.setOverlayVisible(e,!1)}function jw(i,...r){r=r||[];for(let e in i.overlays)(r.length===0||r.indexOf(e)!==-1)&&i.instance.setOverlayVisible(i.overlays[e],!1)}function aoe(i,r){let e=ih(i,r);e&&i.instance.setOverlayVisible(e,!0)}function Hw(i,...r){r=r||[];for(let e in i.overlays)(r.length===0||r.indexOf(e)!==-1)&&i.instance.setOverlayVisible(i.overlays[e],!0)}function loe(i){for(let r in i.overlays)i.instance.destroyOverlay(i.overlays[r]);i.overlays={},i.overlayPositions=null,i.overlayPlacements={}}function Ji(i,r,e){let t=i.overlays[r];t&&(i.instance.setOverlayVisible(t,!1),e||i.instance.destroyOverlay(t),delete i.overlays[r],i.overlayPositions&&delete i.overlayPositions[r],i.overlayPlacements&&delete i.overlayPlacements[r])}function hoe(i,...r){for(let e=0,t=r.length;e<t;e++)Ji(i,r[e])}function kw(i){return ih(i,da)}function coe(i,r){let e=kw(i);if(e)if(z(r)||vr(r))e.setLabel(r);else{let t=r;t.label&&e.setLabel(t.label),t.location&&(e.location=t.location)}else{let t=z(r)||vr(r)?{label:r}:r;e=Yw(i,t),i.overlays[da]=e}}var Pv="add",Ov="remove",hp="anchors",vf="connector";function _v(i,r,e){for(let t in i.overlays)r===Pv?i.instance.$addOverlayClass(i.overlays[t],e):r===Ov&&i.instance.$removeOverlayClass(i.overlays[t],e)}function Lv(i,r,e){let t=null;r.connector!=null&&(t=we.getCachedTypeItem(i,vf,e.connector),t==null&&(t=Wt.Fd(i,r.connector,e.connector),we.cacheTypeItem(i,vf,t,e.connector)),Wt.setPreparedConnector(i,t)),we.applyType(i,r,e);let n={};function o(h,d){let u=h.options;if(d)return d.updateFrom(u,i.edge.data),n[u.id]=!0,i.instance.$reattachOverlay(d,i),d;{let p=we.getCachedTypeItem(i,Cv,u.id);return p!=null?(i.instance.$reattachOverlay(p,i),p.Qo!==Wi&&i.instance.setOverlayVisible(p,!0),p.updateFrom(u,i.edge.data),i.overlays[p.id]=p):p=oh(i,h),n[p.id]=!0,p}}if(r.overlays)for(let h in r.overlays)o(r.overlays[h],i.overlays[r.overlays[h].options.id]);if(r.sourceMarker){let h=i.sourceMarker==null?null:i.sourceMarker.id===r.sourceMarker.options.id?i.sourceMarker:null;i.sourceMarker=o(r.sourceMarker,h)}else i.sourceMarker=null;if(r.targetMarker){let h=i.targetMarker==null?null:i.targetMarker.id===r.targetMarker.options.id?i.targetMarker:null;i.targetMarker=o(r.targetMarker,h)}else i.targetMarker=null;for(let h in i.overlays)i.overlays[h].ignoreTypes!==!0&&n[i.overlays[h].id]==null&&Ji(i,i.overlays[h].id,!0);r.detachable!=null&&(i.detachable=r.detachable===!0),r.reattach!=null&&(i.reattach=r.reattach===!0),r.scope&&(i.scope=r.scope);let s=null;r.anchor?(s=we.getCachedTypeItem(i,hp,e.anchor),s==null&&(s=[ft(r.anchor),ft(r.anchor)],we.cacheTypeItem(i,hp,s,e.anchor))):r.anchors&&(s=we.getCachedTypeItem(i,hp,e.anchors),s==null&&(s=[ft(r.anchors[0]),ft(r.anchors[1])],we.cacheTypeItem(i,hp,s,e.anchors))),s!=null&&i.instance.router.setConnectionAnchors(i,s);let a={};i.instance.$_extractSimpleEdgeStyles(r,a)&&i.instance.$_setLineStyle(i,a,!1),i.instance.$applyConnectorType(i.connector,r)}function Wr(i,r){we.addClass(i,r),_v(i,Pv,r),i.connector&&i.instance.$addConnectorClass(i.connector,r)}function _r(i,r){we.removeClass(i,r),_v(i,Ov,r),i.connector&&i.instance.$removeConnectorClass(i.connector,r)}var Wt={getAbsoluteOverlayPosition(i,r){return i.overlayPositions?i.overlayPositions[r.id]:null},setPreparedConnector(i,r,e,t,n){if(i.connector!==r){let o,s="";if(i.connector!=null&&(o=i.connector,s=i.instance.$getConnectorClass(i.connector),i.instance.$destroyConnector(i)),i.connector=r,n&&we.cacheTypeItem(i,vf,r,n),Wr(i,s),o!=null){let a=Xw(i);for(let l in a)i.instance.$reattachOverlay(a[l],i)}e||i.instance.$paintConnection(i)}},destroy(i){for(let r in i.overlays)i.instance.destroyOverlay(i.overlays[r]);i.overlays={},i.overlayPositions={},i.sourceElement=null,i.targetElement=null,i.instance.$destroyConnector(i),i.connector=null,we.destroy(i)},setVisible(i,r){we.setVisible(i,r),r?Hw(i):jw(i),i.connector&&i.instance.$setConnectorVisible(i.connector,r),i.instance.$paintConnection(i)},Fd(i,r,e){let t={},n;if(z(r))n=Ne.get(i,r,t);else{let o=r;n=Ne.get(i,o.type,fn(o.options||{},t))}return e!=null&&(n.typeId=e),n},Ud(i,r,e,t,n){let o=Wt.Fd(i,r,n);Wt.setPreparedConnector(i,o,e,t,n)}};function Cf(i){return i==null?null:i.split(" ").filter(r=>r!=null&&r.length>0)}function wv(i,r,e){for(let t in r)i[t]=e}var Ww="connector",Zw="override",Jw="cssClass",Dv="__default",Kw="anchor",qw="anchors";function cp(i,r){let e={},t=i.$defaultType,n=Object.assign({},t);return wv(e,t,Dv),i.$types.forEach(o=>{if(o!==Dv){let s=i.instance.$getConnectionType(o);if(s!=null){let a=new Set([Ww,Kw,qw]);if(s.mergeStrategy===Zw)for(let l in s)a.add(l);n=fn(n,s,[Jw],Array.from(a)),wv(e,s,o)}}}),r&&(n=bo(n,r,"_")),Wo(i)&&Lv(i,n,e),e}function Wo(i){return i.objectType===Pf}var Pf="connection";function Nv(i,r){let e=i.instance.$getConnectionType(r);e!=null&&e.cssClass&&Wo(i)&&_r(i,e.cssClass)}function dp(i){if(i.paintStyle&&i.hoverPaintStyle){let r={};Object.assign(r,i.paintStyle),Object.assign(r,i.hoverPaintStyle),i.hoverPaintStyle=r}}var Toe="add",voe="remove";function Coe(i){if(Wo(i))return{x:i.connector.x,y:i.connector.y}}function Iv(i,r,e){return e=e||{},{cssClass:e.cssClass||"",hoverClass:e.hoverClass||i.defaults.hoverClass,$types:new Set,$typeCache:{},id:e.id||V(),$defaultType:{scope:e.scope||i.defaultScope,overlays:{}},instance:i,deleted:!1,objectType:r,visible:!0,$hover:!1,paintStyle:{},paintStyleInUse:{},hoverPaintStyle:{}}}var we={create(i,r,e){e=e||{};let t=e.cssClass||"",n=e.hoverClass||i.defaults.hoverClass,o=new Set,s={},a=e.id||r+new Date().getTime(),l={scope:e.scope||i.defaultScope,overlays:{}};return{cssClass:t,instance:i,hoverClass:n,$types:o,$typeCache:s,$defaultType:l,id:a}},addClass(i,r){let e=(i.cssClass||"").split(" ");e.push(r),i.cssClass=e.join(" ")},removeClass(i,r,e){let t=(i.cssClass||"").split(" ");i.cssClass=t.filter(n=>n!==r).join(" ")},cacheTypeItem(i,r,e,t){i.$typeCache[t]=i.$typeCache[t]||{},i.$typeCache[t][r]=e},hasType(i,r){return i.$types.has(r)},removeType(i,r,e){let t=Cf(r),n=!1,o=s=>i.$types.has(s)?(Nv(i,s),i.$types.delete(s),!0):!1;if(t!=null){for(let s=0,a=t.length;s<a;s++)n=o(t[s])||n;n&&cp(i,e)}},addType(i,r,e){let t=Cf(r),n=!1;if(t!=null){for(let o=0,s=t.length;o<s;o++)i.$types.has(t[o])||(i.$types.add(t[o]),n=!0);n&&cp(i,e)}},getCachedTypeItem(i,r,e){return i.$typeCache[e]?i.$typeCache[e][r]:null},setPaintStyle(i,r){i.paintStyle=r,i.paintStyleInUse=i.paintStyle,dp(i)},setHoverPaintStyle(i,r){i.hoverPaintStyle=r,dp(i)},getType(i){return Array.from(i.$types.keys())},clearTypes(i,r){i.$types.forEach(e=>{Nv(i,e)}),i.$types.clear(),cp(i,r)},setType(i,r,e){return we.clearTypes(i),(Cf(r)||[]).forEach(i.$types.add,i.$types),cp(i,e)},applyType(i,r,e){we.setPaintStyle(i,r.paintStyle),we.setHoverPaintStyle(i,r.hoverPaintStyle),i.paintStyleInUse=i.paintStyle},appendToDefaultType(i,r){Object.assign(i.$defaultType,r)},destroy(i){i.deleted=!0,delete i.instance},setVisible(i,r){i.visible=r}};function Mv(i,r){return r.theta-i.theta}function Vv(i,r){let e=i.theta<0?-Math.PI-i.theta:Math.PI-i.theta,t=r.theta<0?-Math.PI-r.theta:Math.PI-r.theta;return e-t}var $v={[Et]:Vv,[vt]:Mv,[Ct]:Mv,[Tt]:Vv};function Bv(i,r,e,t,n){let o=e?i.width:i.height,s=e?i.height:i.width,a=[],l=o/(r.length+1);for(let h=0;h<r.length;h++){let d=(h+1)*l,u=t*s;n&&(d=o-d);let p=e?d:u,m=i.x+p,g=i.width===0?0:p/i.width,E=e?u:d,y=i.y+E,x=i.height===0?0:E/i.height;if(i.r!==0&&i.r!=null){let f=xt({x:m,y},i.c,i.r);m=f.x,y=f.y}a.push({x:m,y,xLoc:g,yLoc:x,c:r[h].c,a:r[h].anchor})}return a}function Zo(i){return!i.isFixed&&i.isContinuous===!0}function Fv(i){return[i.currentLocation,i.locations[i.currentLocation]]}function Hoe(i,r,e){let t=$i[r].x,n=$i[r].y;return Gv(i,t,n,e,e/3)}function koe(i,r,e){let t=$i[r].x,n=$i[r].y,o=t===0?i.x-e:i.x+t*e*2,s=t===0?i.x+e:i.x,a=n===0?i.y-e:i.y+n*e*2,l=n===0?i.y+e:i.y,h=Math.min(o,s),d=Math.min(a,l),u=Math.max(o,s),p=Math.max(a,l);return{x:h,y:d,width:u-h,height:p-d}}function Gv(i,r,e,t,n){let o={x:i.x+t*r,y:i.y+t*e},s=rr(i,o,n),a=rr(o,i,n),l=Math.min(s[0].x,s[1].x,a[0].x,a[1].x),h=Math.max(s[0].x,s[1].x,a[0].x,a[1].x),d=Math.min(s[0].y,s[1].y,a[0].y,a[1].y),u=Math.max(s[0].y,s[1].y,a[0].y,a[1].y);return{x:l,y:d,width:h-l,height:u-d}}function Woe(i,r,e,t){if(t.connector!=null){let n=2*Math.max(t.connector.sourceStub,t.connector.targetStub);return Gv(i,r,e,n,n/3)}else return{x:i.x,y:i.y,width:1,height:1}}function up(i,r,e,t){let n,o=t.rotation,s={curX:r.x+i.x*e.width+(isNaN(i.offsetX)?0:i.offsetX),curY:r.y+i.y*e.height+(isNaN(i.offsetY)?0:i.offsetY),x:i.x,y:i.y,ox:0,oy:0};if(o!=null&&o.length>0&&!(o.length===0&&o[0].r===0)){let a=[i.ox,i.oy],l={x:s.curX,y:s.curY,cr:0,sr:0};o.forEach(h=>{l=xt(l,h.c,h.r),a=[Math.round(a[0]*l.cr-a[1]*l.sr),Math.round(a[1]*l.cr+a[0]*l.sr)].slice()}),n={curX:l.x,curY:l.y,x:i.x,y:i.y,ox:a[0],oy:a[1]}}else n=Object.assign({},s);return n}var Qw=10;function eD(i,r,e,t,n,o,s){let a=t.x+i.x*n.width,l=t.y+i.y*n.height;if(o!=null&&o.length>0){let h=Ob([a,l,0,0],o);a=h.x,l=h.y}return Math.sqrt(Math.pow(r-a,2)+Math.pow(e-l,2))}var pp=class{constructor(r,e){this.instance=r;c(this,"anchorLists",new Map);c(this,"zd");c(this,"Ti");c(this,"vi");c(this,"Ci");c(this,"ut");c(this,"rs",new Map);c(this,"Yd",null);e=e||{},this.Ti=e.gridCellSize||Qw,this.zd=e.avoidVertices===!0,this.vi=e.vertexBuffer||2,this.Ci=e.vertexBorder||2}$connectionRemoved(r){Zo(r.connection.anchors.source)&&this.$_removeAnchorFromAnchorLists(r.connection.sourceId,r.connection.anchors.source),Zo(r.connection.anchors.target)&&this.$_removeAnchorFromAnchorLists(r.connection.targetId,r.connection.anchors.target)}elementRemoved(r){r!=null&&this.anchorLists.delete(r.id)}xE(r,e){let t=this.anchorLists.get(e.id),n=0;t!=null&&function(o){if(o){let s=a=>a.c.id===r.id;Lt(o.top,s),Lt(o.left,s),Lt(o.bottom,s),Lt(o.right,s),n+=o.top.length,n+=o.left.length,n+=o.bottom.length,n+=o.right.length}}(t),n===0&&this.anchorLists.delete(e.id)}$connectionDetachedFromElement(r,e){this.xE(r,e)}$setCurrentLocation(r,e,t){r.currentLocation=e}bE(r,e){let t;if(r.isFixed&&r.fixedLocation!=null)t=up(r.fixedLocation,e.xy,e.wh,e);else{let n=e.xy,o=e.wh,s=e.txy,a=e.twh,[l,h]=Fv(r);if(r.locations.length===1||s==null||a==null)t=up(h,n,o,e);else{let[d,u]=this.AE(n,o,s,a,e.rotation,e.tRotation,r.locations,e.otherAnchor);d!==l&&this.$setCurrentLocation(r,d,e.connection),t=up(u,n,o,e)}}return r.computedPosition=t,t}SE(r,e){let t=this.instance.viewport.getPosition(r),n=(o,s,a,l,h,d)=>{if(a.length>0){let u=a.sort($v[o]),p=o===ut||o===Se,m=Bv(t,u,l,h,p);for(let g=0;g<m.length;g++)m[g].a.locations[0]={x:m[g].xLoc,y:m[g].yLoc,ox:d.x,oy:d.y,offsetX:0,offsetY:0},m[g].a.currentLocation=0}};n(st,t,e.bottom,!0,1,{x:0,y:1}),n(Se,t,e.top,!0,0,{x:0,y:-1}),n(ze,t,e.left,!1,0,{x:-1,y:0}),n(ut,t,e.right,!1,1,{x:1,y:0})}ts(r,e,t,n,o,s,a,l,h,d){this.anchorLists.has(r)||this.anchorLists.set(r,{top:[],right:[],bottom:[],left:[]});let u=this.anchorLists.get(r),p=-1,m=-1,g={theta:t,order:n,c:o,elId:s,anchor:e},E=u[h],y=e.currentFace?u[e.currentFace]:null,x;if(y){let f=y.findIndex(b=>b.anchor.id===e.id);if(f!==-1){y.splice(f,1);for(let b=0;b<y.length;b++)x=y[b].c,x.placeholder!==!0&&d.add(x)}}for(let f=0;f<E.length;f++)x=E[f].c,x.placeholder!==!0&&d.add(x);if(p!==-1)E[p]=g;else{let f=l?m!==-1?m:0:E.length;E.splice(f,0,g)}e.currentFace=h}$_removeAnchorFromAnchorLists(r,e){let t=this.anchorLists.get(r),n=0;t!=null&&function(o,s){if(o){let a=l=>l.anchor.id===s;Lt(o.top,a),Lt(o.left,a),Lt(o.bottom,a),Lt(o.right,a),n+=o.top.length,n+=o.left.length,n+=o.bottom.length,n+=o.right.length}}(t,e.id),n===0&&this.anchorLists.delete(r)}computeAnchorLocation(r,e){let t=this.bE(r,e);return r.computedPosition=t,r.timestamp=e.timestamp,t}computePath(r,e){let t=this.instance.viewport.getPosition(r.sourceId),n=this.instance.viewport.getPosition(r.targetId),o=r.connector,s=this.computeAnchorLocation(r.anchors.source,{xy:t,wh:t,elementId:t.id,timestamp:e,rotation:this.instance.$getRotations(r.sourceId),txy:n,twh:n}),a=this.computeAnchorLocation(r.anchors.target,{xy:n,wh:n,elementId:n.id,timestamp:e,rotation:this.instance.$getRotations(r.targetId),txy:t,twh:t});fT(r.connector);let l={sourcePos:s,targetPos:a,strokeWidth:r.paintStyleInUse.strokeWidth,sourceInfo:t,targetInfo:n};o.paintInfo=tf(o,l),QE(o),o.x=o.paintInfo.x,o.y=o.paintInfo.y,o.quadrant=o.paintInfo.quadrant;let h=o.geometry==null||o.geometry.source==null?!1:!sf(s,o.geometry.source),d=o.geometry==null||o.geometry.target==null?!1:!sf(a,o.geometry.target);if(this.instance.$_discardEdgeEditsOnDrag&&(h||d)&&Bi(r),o.edited){let u=this.TE(r,o,l,e,h,d);Ne.setGeometry(r,u,!1)}else{let u=this.vE(r,o,l,e);Ne.setGeometry(r,u,!0)}ef(o),o.width=Math.max(10,o.bounds.xmax-o.x),o.height=Math.max(10,o.bounds.ymax-o.y)}prepareAnchor(r){return ft(r)}Gb(r){let e=Math.max(r.sourceStub,r.targetStub);return Math.max(this.instance.$_vertexBuffer,e)}CE(r,e,t,n,o,s,a,l,h,d,u,p){if(u===this.Yd){let v=this.rs.get(p);if(v!=null)return v}else this.rs.clear();this.Yd=u;let m={HORIZONTAL:"horizontal",VERTICAL:"vertical",DIAGONAL:"diagonal",IDENTITY:"identity"};if(r===e)return{orientation:m.IDENTITY,a:[Se,Se]};let g=Math.atan2(n.c.y-t.c.y,n.c.x-t.c.x),E=Math.atan2(t.c.y-n.c.y,t.c.x-n.c.x),y=[],x={};((v,O)=>{for(let P=0;P<v.length;P++)if(x[v[P]]={[ze]:{x:O[P][0].x,y:O[P][0].c.y},[ut]:{x:O[P][0].x+O[P][0].width,y:O[P][0].c.y},[Se]:{x:O[P][0].c.x,y:O[P][0].y},[st]:{x:O[P][0].c.x,y:O[P][0].y+O[P][0].height}},O[P][1]!=null&&O[P][1].length>0)for(let I in x[v[P]])x[v[P]][I]=_b(x[v[P]][I],O[P][1])})([Qe,An],[[t,a],[n,l]]);let f=[Se,ze,ut,st];for(let v=0;v<f.length;v++)for(let O=0;O<f.length;O++)y.push({source:f[v],target:f[O],dist:Math.round(Be(x.source[f[v]],x.target[f[O]]))});y.sort(function(v,O){if(v.dist<O.dist)return-1;if(O.dist<v.dist)return 1;{let P={[ze]:0,[Se]:1,[ut]:2,[st]:3},I=P[v.source],C=P[O.source],_=P[v.target],w=P[O.target];return I<C?-1:C<I?1:_<w?-1:w<_?1:0}});let b=y[0].source,A=y[0].target,T={},S={};for(let v=0;v<y.length;v++){let O=y[v];if(!Zo(o)||Sf(o,O.source,P=>{if(!h.avoidVertices||h.connector==null)return!1;if(T[P]==null){let I=h.connector.sourceGap+h.connector.sourceStub,C=$i[P],_=this.Ti*(this.Ci+this.vi),w={x:x.source[P].x+I*C.x,y:x.source[P].y+I*C.y,width:Math.max(1,Math.abs(_*C.x)),height:Math.max(1,Math.abs(_*C.y))};T[P]=this.instance.viewport.hasVerticesIntersectingWithRect(w,0,[r],!1)}return T[P]})?b=y[v].source:b=null,!Zo(s)||Sf(s,O.target,P=>{if(!h.avoidVertices||h.connector==null)return!1;if(S[P]==null){let I=h.connector.targetGap+h.connector.targetStub,C=$i[P],_=this.Ti*(this.Ci+this.vi),w={x:x.target[P].x+I*C.x,y:x.target[P].y+I*C.y,width:Math.max(1,Math.abs(_*C.x)),height:Math.max(1,Math.abs(_*C.y))};S[P]=this.instance.viewport.hasVerticesIntersectingWithRect(w,0,[e],!1)}return S[P]})?A=y[v].target:A=null,b!=null&&A!=null)break}b==null&&(b=y[0].source),A==null&&(A=y[0].target);let R={a:[b,A],theta:g,theta2:E};return this.rs.set(p,R),R}$redrawEveryConnection(){let r=V();return this.$a(Object.values(this.instance.$_connMap),r)}$redrawConnection(r,e){return this.$a([this.instance.$_connMap[r.id]],e)}$redraw(r,e){return this.$a(r.connections||[],e)}$a(r,e){let t=new Set,n=new Set;if(!this.instance.pt){e=e||V();let o={};for(let s=0;s<r.length;s++){let a=r[s];if(a.visible===!1)continue;t.add(a);let l=a.sourceId,h=a.targetId,d=Zo(a.anchors.source),u=Zo(a.anchors.target);if(d||u){let p=(a.anchors.source.faces||[]).join("-"),m=(a.anchors.target.faces||[]).join("-"),g=[l,p,h,m].join("-"),E=o[g];d&&!this.anchorLists.has(l)&&this.anchorLists.set(l,{top:[],right:[],bottom:[],left:[]}),u&&!this.anchorLists.has(h)&&this.anchorLists.set(h,{top:[],right:[],bottom:[],left:[]});let y=this.instance.viewport.getPosition(h),x=this.instance.viewport.getPosition(l);if(h===l&&(d||u))this.ts(l,a.anchors.source,-Math.PI/2,0,a,h,0,!1,Se,t),this.ts(h,a.anchors.target,-Math.PI/2,0,a,l,1,!1,Se,t);else{let f=this.instance.$getRotations(l),b=this.instance.$getRotations(h);E||(E=this.CE(l,h,x,y,a.anchors.source,a.anchors.target,f,b,a,a.connector.sourceStub+a.connector.targetStub,e,g),o[g]=E),d&&this.ts(l,a.anchors.source,E.theta,0,a,h,0,!1,E.a[0],t),u&&this.ts(h,a.anchors.target,E.theta2,-1,a,l,1,!0,E.a[1],t)}d&&n.add(l),u&&n.add(h)}}n.forEach(s=>{this.SE(s,this.anchorLists.get(s))}),t.forEach(s=>{this.instance.$paintConnection(s,{timestamp:e})})}return{c:t}}reset(){this.anchorLists.clear(),this.rs.clear()}setConnectionAnchors(r,e){r.anchors.source=e[0],r.anchors.target=e[1]}AE(r,e,t,n,o,s,a,l){if(l!=null){let h=a.map((p,m)=>{let g=r.x+p.x*e.width,E=r.y+p.y*e.height;return{x:g,y:E,idx:m}}),d=l.locations.map((p,m)=>{let g=t.x+p.x*n.width,E=t.y+p.y*n.height;return{idx:m,x:g,y:E}}),u=[];for(let p=0;p<h.length;p++)for(let m=0;m<d.length;m++){let g=Math.round(Be(h[p],d[m]));u.push({d:g,idx:p,idx2:m})}return u.sort((p,m)=>p.d-m.d),[u[0].idx,a[u[0].idx]]}else{let h=t.x+n.width/2,d=t.y+n.height/2,u=a.map((p,m)=>({d:eD(p,h,d,r,e,o,s),idx:m}));return u.sort((p,m)=>p.d-m.d),[u[0].idx,a[u[0].idx]]}}};function Uv(i,r,e,t,n,o,s,a){let l=Ir(r),h=xA(r),d=s(e,t,l,h);d.sort((p,m)=>{let g=p.axis===l&&p.directionFromParent===r.directionFromParent,E=p.axis===l&&p.directionFromParent!==r.directionFromParent,y=m.axis===l&&m.directionFromParent===r.directionFromParent,x=m.axis===l&&m.directionFromParent!==r.directionFromParent;return g||x?-1:y||E?1:0});let u=[];for(let p=0;p<d.length;p++){let m=d[p],g=e+m.dx,E=t+m.dy,y=m.axis,x=m.directionFromParent,f=r.ax+m.dx*n,b=r.ay+m.dy*n,A=i.getCell(g,E,null,null),T=A===a,S={cx:g,cy:E,obj:A,axis:y,directionFromParent:x,ax:f,ay:b,g:r.g+(g-r.x===0||E-r.y===0?1:Math.SQRT2),obstacles:A.obstacles,buffers:A.buffers,isTarget:T};if(A===a)return[S];u.push(S)}return u}function Of(i){let r=[],e=Ir(i),t=i,n=!1,o=0;for(;!n&&t!=null;)r.push(t),o++,Ir(t)!==e&&(n=!0),t=t.parent;return r.length===0?null:{source:i,target:r[r.length-1],isFirstSegment:r[r.length-1].parent==null,axis:Ir(i),length:o}}function tD(i){return i.axis===bn||i.axis===qn}function rD(i){return i.axis===he&&i.source.ax===i.target.ax||i.axis===ne&&i.source.ay===i.target.ay}function Yv(i,r,e){r.push({ax2:i.source.ax,ay2:i.source.ay,ax1:i.target.ax,ay1:i.target.ay,axis:i.axis,pathId:e})}function nD(i,r,e){if(tD(i)||rD(i))Yv(i,r,e);else{let t=i.axis===ne?(i.source.ax+i.target.ax)/2:i.source.ax,n=i.axis===he?(i.source.ay+i.target.ay)/2:i.source.ay,o=i.axis===ne?(i.source.ax+i.target.ax)/2:i.target.ax,s=i.axis===he?(i.source.ay+i.target.ay)/2:i.target.ay,a=i.axis===he?ne:he,l={ax2:i.source.ax,ay2:i.source.ay,ax1:t,ay1:n,axis:i.axis,pathId:e};r.push(l);let h={ax2:t,ay2:n,ax1:o,ay1:s,axis:a,pathId:e};r.push(h);let d={ax2:o,ay2:s,ax1:i.target.ax,ay1:i.target.ay,axis:a,pathId:e};r.push(d)}}function zv(i,r,e){if(e===ne)return[{x:i-50,y:r},{x:i+50,y:r}];if(e===he)return[{x:i,y:r-50},{x:i,y:r+50}];if(e===bn)return[{x:i+50,y:r+50},{x:i-50,y:r-50}];if(e===qn)return[{x:i-50,y:r+50},{x:i+50,y:r-50}]}function _f(i,r,e,t,n,o){let s=i,a=[];n=n||V();let l=Of(s);if(l.isFirstSegment)t===rn?Yv(l,a,n):nD(l,a,n);else{let d=l.source.ax,u=l.source.ay,p=!1,m=Of(l.target);for(;!p&&m!=null;){let g=zv(d,u,l.axis),E;E=zv(m.isFirstSegment?m.target.ax:m.target.cx,m.isFirstSegment?m.target.ay:m.target.cy,m.axis);let y=yb(g,E);y!=null&&(a.push({ax1:y.x,ay1:y.y,ax2:d,ay2:u,axis:l.axis,pathId:n}),d=y.x,u=y.y,l=m),m.isFirstSegment?p=!0:m=Of(m.target)}m!=null&&a.push({ax1:m.target.ax,ay1:m.target.ay,ax2:d,ay2:u,pathId:n,axis:m.axis})}return a.reverse(),{id:n,segments:a,targetCell:i,sourceCell:r,isEmpty:a.length===0}}function Xv(i,r,e,t,n,o){let s=_f(i,r,e,t,o,!1);if(s.segments.length<2)return s;let a=[],l=0,h=!1;function d(u){let p={x:s.segments[u].ax1,y:s.segments[u].ay1},m=u+1,g=!1;for(;!g;){let E=s.segments[m];if(E==null||!n(e,[p,{x:E.ax2,y:E.ay2}]))return{startIdx:u,endIdx:m-1,segment:{ax1:p.x,ay1:p.y,ax2:s.segments[m-1].ax2,ay2:s.segments[m-1].ay2},finished:E==null};m++}}for(;!h;){let u=d(l);a.push(u.segment),u.finished?h=!0:l=u.endIdx+1}return{targetCell:s.targetCell,sourceCell:s.sourceCell,isEmpty:s.isEmpty,segments:a,id:s.id}}function jv(i,r,e,t,n,o,s,a,l,h,d,u,p,m,g,E,y){E==null?E=new Fs(i,r,s,h,d,u):E.reinitialize();let x=E.Uo(i.x,i.y),f=E.Uo(r.x,r.y),b=bE(n);b.axis==null&&(b.axis=yA(i,r));let A=bE(o),T=E.setSourceCell(e,x.x,x.y,i.x,i.y,b.axis,b.direction),S=E.setTargetCell(t,f.x,f.y,r.x,r.y,A.axis,A.direction);if(S.x===T.x&&S.y===T.y)return{targetCell:S,sourceCell:T,segments:[],id:yE,isEmpty:!0};S.fixedAxis=S.fixedAxis||b.axis;let R=T,v=S,O=()=>a===rn?Xv(v,R,E,a,g,y):_f(v,R,E,a,y,!0),P=new bd,I=new Rs(P.sort.bind(P),T),C,_,w=Ic(T.x,T.y,S.x,S.y)*100,B=0;for(;I.length>0;){if(C=I.pop(),C.closed=!0,_=Ir(C),B++,B>w)throw`too many iterations ${B} `;if(C===S)return O();P.node=C;let D=Uv(E,C,C.x,C.y,s,u,m,S);for(let M=0,N=D.length;M<N;M++){let G=D[M];if(G.isTarget)return G.obj.parent=C,O();if(G.obj.closed||G.obj===T||G.obj===S||G.obstacles.length>0||G.buffers.length>0)continue;let J=0;G.axis!==_&&(J=.5),(!G.obj.opened||G.g<G.obj.g)&&(G.obj.g=G.g,G.obj.h=l(G.cx,G.cy,S.x,S.y)+J,G.obj.f=G.obj.g+G.obj.h,G.obj.parent=C,G.obj.ax=G.ax,G.obj.ay=G.ay,G.obj.opened?I.update(G.obj):(I.add(G.obj),G.obj.opened=!0))}}return{targetCell:S,sourceCell:T,segments:[],id:yE,isEmpty:!0}}function Hv(i,r,e,t,n,o,s,a,l,h,d,u,p,m){return jv(i,r,e,t,n,o,a,l,h,d,u,s.findVerticesAtPoint.bind(s),s.findVerticesIntersectingWithRect.bind(s),(g,E,y,x)=>{if(l===rn||l==null)return xE(g,E,y,x);if(l===Qc)return xE(g,E,y,x);if(l===nn)return EA(g,E,y,x)},(g,E)=>{let y=a*d;return s.hasLineOfSight(E,y,g.sourceAndTargetObstacles)},p,m)}function kv(i,r){return{curX:i.curX+i.ox*r,curY:i.curY+i.oy*r,ox:i.ox,oy:i.oy,x:i.x,y:i.y}}var sh=class extends pp{constructor(e,t){super(e,t);this.instance=e;c(this,"Xd")}vE(e,t,n,o){return this.zd||e.avoidVertices?this.OE(e,t,n,o):this.is(e,t,n)}TE(e,t,n,o,s,a){return Ne.update(e,t.paintInfo,n,s,a)}is(e,t,n){return Ne.compute(e,t.paintInfo,n)}OE(e,t,n,o){if(t.edited)this.is(e,t,n);else{let s=t,a=kv(n.sourcePos,t.sourceGap),l=kv(n.targetPos,t.targetGap),h={x:a.curX+t.sourceStub*a.ox,y:a.curY+t.sourceStub*a.oy},d={x:l.curX+t.targetStub*l.ox,y:l.curY+t.targetStub*l.oy},u=Math.min(h.x,d.x),p=Math.max(h.x,d.x),m=Math.min(h.y,d.y),g=Math.max(h.y,d.y),E={x:u,y:m,width:Math.max(p-u,10),height:Math.max(g-m,10)};if(!this.instance.viewport.hasVerticesIntersectingWithRect(E,0,[],!1))return this.is(e,t,n);(this.ut==null||o!==this.Xd)&&(this.ut=new Fs(h,d,this.Ti,this.Ci,this.vi,(y,x,f)=>this.instance.viewport.findVerticesAtPoint(y,x,f))),this.Xd=o;try{let y=e.edge?e.edge.id:e.id,x=Hv(h,d,e.sourceId,e.targetId,a,l,this.instance.viewport,this.Ti,s.constrain,Ic,this.Ci,this.vi,this.ut,y);if(x.isEmpty)Ne.compute(e,t.paintInfo,n);else{x.segments.unshift({ax1:a.curX,ay1:a.curY,ax2:h.x,ay2:h.y,axis:Bs(a.ox,a.oy),pathId:y}),x.segments.push({ax1:d.x,ay1:d.y,ax2:l.curX,ay2:l.curY,axis:Bs(l.ox,l.oy),pathId:y});let f=lf(x.segments.map(A=>Object.assign({x1:A.ax1,y1:A.ay1,x2:A.ax2,y2:A.ay2,o:A.axis||iD(A)},A)));return Bu(e.connector,f),{segments:s.$pathSegments,source:n.sourcePos,target:n.targetPos,quadrant:t.paintInfo.quadrant}}}catch(y){return this.is(e,t,n)}}}};c(sh,"type",xe);function iD(i){return i.axis!=null?i.axis:i.ax1===i.ax2?he:i.ay1===i.ay2?ne:null}var Wv="fill",Rf="stroke",Zv="stroke-width",dle="strokeWidth",ve="svg",Jv="defs",te="path",Xe="circle",Kv="ellipse",Je="text",Lf="tspan",Z="rect",q="g",ule="version",ple="xmlns",mle="fill",wf="stroke-dasharray",gle="stroke-linejoin",Ele="stroke-linecap",fle="stroke-miterlimit",yle="stroke-dashoffset",xle="stroke-opacity",ble="stroke",Ale="stroke-width",mp="vector-effect",gp="non-scaling-stroke",Sle="text-anchor",Zt="http://www.w3.org/2000/svg",Tle="http://www.w3.org/1999/xlink",vle="http://www.w3.org/1999/xhtml";var Ep=class{constructor(r,e){c(this,"$properties");c(this,"$values");this.$values=e||{},this.$properties=Object.keys(e),r.bindAll([$e,Re],t=>{this.$properties.forEach(n=>{t.updates[n]!=null&&(this.$values[n]=t.updates[n])})})}getValue(r,e){return this.$values[r]||e}getValues(){return Object.assign({},this.$values)}};var oD=.5;function qv(i,r){var b,A;let e=Iv(i,Pf,r),t=r.overlays||[],n={},o=i.$defaultOverlays;o&&t.push(...o);for(let T=0;T<t.length;T++){let S=hi(t[T]);n[S.options.id]=S}if(e.$defaultType.overlays=n,r.label&&(e.$defaultType.overlays[da]={type:or.type,options:{label:r.label,useHTMLElement:r.useHTMLLabel===!0,location:r.labelLocation||oD,id:da,cssClass:Rv}}),r.sourceMarker){let T=hi(r.sourceMarker);T.options.location=0,T.options.direction=-1,T.sourceMarker=!0,e.$defaultType.sourceMarker=T}if(r.targetMarker){let T=hi(r.targetMarker);T.options.location=1,T.options.direction=1,T.targetMarker=!0,e.$defaultType.targetMarker=T}let s=r.source,a=r.target,l=(r.anchors?r.anchors[0]:r.anchor)||i.$defaultAnchors[0]||i.$defaultAnchor,h=(r.anchors?r.anchors[1]:r.anchor)||i.$defaultAnchors[1]||i.$defaultAnchor,d=(b=r.edge.anchors)==null?void 0:b.source,u=(A=r.edge.anchors)==null?void 0:A.target,p=ft(l,d),m=ft(h,u),g=i.$_edgesDetachable;r.detachable===!1&&(g=!1);let E=i.$_reattachEdges===!0,y=js({},r.paintStyle||i.defaults.paintStyle);we.appendToDefaultType(e,{detachable:g,reattach:E,paintStyle:y,hoverPaintStyle:js({},r.hoverPaintStyle||i.defaults.hoverPaintStyle)}),r.outlineWidth&&(y.outlineWidth=r.outlineWidth),r.outlineColor&&(y.outlineStroke=r.outlineColor),r.lineWidth&&(y.strokeWidth=r.lineWidth),r.color&&(y.stroke=r.color),r.gradient&&(y.gradient=r.gradient),r.dashArray&&(y.dashArray=r.dashArray);let x=Object.assign(e,{anchorDefs:{source:l,target:h},anchors:{source:p,target:m},sourceId:r.edge.source.getFullId(),sourceElement:s,targetId:r.edge.target.getFullId(),targetElement:a,scope:r.scope,lastPaintedAt:null,visible:!0,paintStyle:r.paintStyle,hoverPaintStyle:r.hoverPaintStyle,detachable:g,reattach:E,edge:r.edge,suspendedElement:null,suspendedElementId:null,suspendedElementType:null,suspendedEndpoint:null,suspendedIndex:null,overlays:{},overlayPlacements:{},overlayPositions:{},connector:null,proxies:{[Qe]:[],[An]:[]},avoidVertices:r.avoidVertices===!0,sourceMarker:null,targetMarker:null});Wt.Ud(x,r.connector||i.$defaultConnector,!0);let f=[xe,r.type].join(" ");return/[^\s]/.test(f)&&we.addType(x,f,r.data),x}var ah=class{constructor(r){c(this,"grid");c(this,"snap",!1);c(this,"fitGroupsToGrid",!1);r!=null&&(this.snap=r.snap===!0,this.grid=r.size,this.fitGroupsToGrid=r.fitGroupsToGrid!==!1)}};var fp=class{constructor(r,e){this.gridProfile=e;c(this,"afterGroupCollapse");c(this,"afterGroupExpand");c(this,"afterGroupResize");c(this,"afterGroupShrink");c(this,"afterGroupGrow");c(this,"afterLayout");c(this,"afterDrag");c(this,"constant");c(this,"trackback");c(this,"trackbackThreshold");c(this,"constrainToViewport");c(this,"repositionDraggedElement");c(this,"grid");r=r||{},this.afterDrag=r.afterDrag===!0,this.constant=r.constant===!0,this.trackback=r.trackback!==!1,this.trackbackThreshold=r.trackbackThreshold,this.constrainToViewport=r.constrainToViewport===!0,this.repositionDraggedElement=r.repositionDraggedElement===!0,this.afterLayout=r.afterLayout===!0,this.afterGroupResize=r.afterGroupResize===!0,this.afterGroupShrink=r.afterGroupShrink===!0||this.afterGroupResize&&r.afterGroupShrink!==!1,this.afterGroupGrow=r.afterGroupGrow===!0||this.afterGroupResize&&r.afterGroupGrow!==!1,this.afterGroupCollapse=r.afterGroupCollapse===!0,this.afterGroupExpand=r.afterGroupExpand===!0,this.constant&&this.afterDrag&&(this.constant=!1),this.constant&&(this.repositionDraggedElement=!1)}};var Qv={},sr={get:i=>{let r=Qv[i];if(!r)U("WARN: VisuallyJs: unknown UI plugin '"+i+"'");else return new r},register:(i,r)=>{Qv[i]=r}};function Nt(i){return function(r){sr.register(i,r)}}function yp(i,r,e,t,n,o,s){s=s||r.minSize;let a=r.maxSize,l=r.padding||0,h=(s==null?void 0:s.width)||0,d=(s==null?void 0:s.height)||0,u=0,p=0;isFinite(i.xmin)&&i.xmin<l&&n&&(u=l-i.xmin),isFinite(i.ymin)&&i.ymin<l&&n&&(p=l-i.ymin);let m=(isFinite(i.xmax)?i.xmax:0)+u+l,g=(isFinite(i.ymax)?i.ymax:0)+p+l,E=Math.min((a==null?void 0:a.width)||m,m),y=Math.min((a==null?void 0:a.height)||g,g);if(E=Math.max(h,E),y=Math.max(d,y),e){if(isFinite(i.xmin)&&i.xmin>l&&t){let x=i.xmin-l,f=E-x;E=Math.max((s==null?void 0:s.width)||f,f),E>f&&(x-=E-f),u=-x}if(isFinite(i.ymin)&&i.ymin>l&&t){let x=i.ymin-l,f=y-x;y=Math.max((s==null?void 0:s.height)||f,f),y>f&&(x-=y-f),p=-x}}if(o.grid&&o.fitGroupsToGrid!==!1){let x=E/o.grid.width;E=o.grid.width*Math.ceil(x);let f=y/o.grid.height;y=o.grid.height*Math.ceil(f);let b=u/o.grid.width;u=o.grid.width*Math.ceil(b);let A=p/o.grid.height;p=o.grid.height*Math.ceil(A)}return{width:E,height:y,layoutShiftX:u,layoutShiftY:p}}function eC(i,r,e,t){let n=i.$_connMap[r.id];if(n){if(n.proxies==null||n.proxies[e]==null||n.proxies[e].length===0)return;let o=n.proxies[e].pop(),s=o.originalElement,a=o.element,l=o.originalAnchor;return t!=null&&(l=ft(t)),i.$sourceOrTargetChanged(a.id,s.id,n,s.el,e),e===Qe?n.anchors.source=l:n.anchors.target=l,Wt.setVisible(n,o.originallyVisible),s}return null}function tC(i,r,e,t,n){let o=i.$_connMap[r.id];if(o){let s=e==="source"?0:1;if(n==null)if(Y(t.modelObject)){let d=i.view.getGroupDefinition(i.model.getNodeType(t.modelObject.data));n=ft(d.anchor||i.$defaultAnchors[s]||i.$defaultAnchor||"Continuous")}else n=ft(i.$defaultAnchors[s]||i.$defaultAnchor||"Continuous");let a=CS(o.proxies[e]),l=a!=null?a.originalElement.id:e===Qe?o.sourceId:o.targetId,h=a!=null?a.originalAnchor:e===Qe?o.anchors.source:o.anchors.target;e===Qe?o.anchors.source=n:o.anchors.target=n,i.$sourceOrTargetChanged(l,t.id,o,t.el,e),o.proxies[e].push({originalAnchor:h,element:t,originalElement:i.$getManagedElement(l),originallyVisible:o.visible}),Wt.setVisible(o,!0),i.$revalidateElementById(t.id)}}var sD=["color","lineWidth","outlineWidth","outlineColor","dashArray","gradient"];function xp(i,r,e){r!=null&&(Kg(r.connections,i),r.connections.length===1&&i.instance.$addClassToElement(r.el,ql)),e!=null&&(r==null||i.sourceId!==i.targetId)&&(Kg(e.connections,i),e.connections.length===1&&i.instance.$addClassToElement(e.el,ql))}function bp(i,r,e){if(r!=null){let t=r.connections.length;Lt(r.connections,n=>i.id===n.id),i.instance.router.$connectionDetachedFromElement(i,r),t>0&&r.connections.length===0&&i.instance.$removeClassFromElement(r.el,ql)}if(e!=null){let t=e.connections.length;(r==null||i.sourceId!==i.targetId)&&Lt(e.connections,n=>i.id===n.id),i.instance.router.$connectionDetachedFromElement(i,e),t>0&&e.connections.length===0&&i.instance.$removeClassFromElement(e.el,ql)}}var aD=2,lD=2,Ap=class extends $t{constructor(e,t,n,o,s){var l,h,d,u,p,m,g,E,y,x,f,b,A,T;super();c(this,"Ba",[]);c(this,"Fa",[]);c(this,"containerType",null);c(this,"id");c(this,"defaults");c(this,"Oi",{});c(this,"hoverSuspended",!1);c(this,"pt",!1);c(this,"jd",null);c(this,"$_dataLoading",!1);c(this,"zoomToFitOnLoad");c(this,"plugins",[]);c(this,"pluginMap",new Map);c(this,"connectorClass",aa);c(this,"connectorOutlineClass",KT);c(this,"connectorPathClass",JT);c(this,"overlayClass",la);c(this,"labelOverlayClass",QT);c(this,"$_connMap",{});c(this,"allowNestedGroups");c(this,"$_discardEdgeEditsOnDrag");c(this,"$_vertexBuffer");c(this,"$_vertexBorder");c(this,"os");c(this,"viewport",new ap(this,e=>this.getRenderedElement(e)));c(this,"router");c(this,"Ua",new Map);c(this,"me");c(this,"za",new Set);c(this,"kd");c(this,"$defaultConnector");c(this,"$defaultOverlays");c(this,"$defaultAnchor");c(this,"$defaultAnchors");c(this,"Hd");c(this,"Wd");c(this,"$isInMotion");c(this,"magnetizerProfile");c(this,"magnetizer");c(this,"$unrenderedVertices",new Map);c(this,"$unprocessedGroupMemberships",new Map);c(this,"$_useModelForSizes");c(this,"$_writeSizeToElements");c(this,"$_useModelForPositions");c(this,"$_allowUnattachedEdges");c(this,"$_edgesDetachable");c(this,"$_reattachEdges");c(this,"$paintConnectorOutline");c(this,"$connectorOutlineColor");c(this,"$connectorOutlineWidth");c(this,"j",1);c(this,"$collapsedGroupSizeCalculator");c(this,"Zd");c(this,"Ya");c(this,"Xa");c(this,"view");c(this,"gridProfile");c(this,"$connectionEstablished");c(this,"vertexList",[]);c(this,"logicalPorts");c(this,"objectFilter");c(this,"layoutMap",new Map);c(this,"$_layout");c(this,"model");c(this,"dataSource");c(this,"PE");c(this,"ss");c(this,"rootElement");c(this,"wt",[]);c(this,"$_dataHooks",[]);this.model=e,this.dataSource=t,this.rootElement=n,this.id=o.id||V(),this.gridProfile=new ah(o.grid),this.$connectionEstablished=o.connectionEstablished||(S=>{}),this.logicalPorts=o.logicalPorts===!0,this.objectFilter=o.objectFilter||function(S){return!0},this.$defaultConnector=((l=o.edges)==null?void 0:l.connector)||wn,this.Hd=(h=o.edges)==null?void 0:h.sourceMarker,this.Wd=(d=o.edges)==null?void 0:d.targetMarker,this.$defaultOverlays=(((u=o.edges)==null?void 0:u.overlays)||[]).map(S=>hi(S)),this.$defaultAnchor=((p=o.edges)==null?void 0:p.anchor)||"Continuous",this.$defaultAnchors=((m=o.edges)==null?void 0:m.anchors)||[null,null],this.defaults={[Qu]:null,[av]:1,[ko]:{strokeWidth:2,stroke:"#000000"},[ff]:"vjs_defaultscope",[Ef]:!0,[ov]:20},s&&Object.assign(this.defaults,s),Object.assign(this.Oi,this.defaults),this.Oi[ko]!=null&&(this.Oi[ko].strokeWidth=this.Oi[ko].strokeWidth||2),this.kd=this.defaults[ff],this.allowNestedGroups=this.Oi[Ef]!==!1,this.$_discardEdgeEditsOnDrag=o.edges&&o.edges.discardEditsOnDrag===!0,this.$_vertexBuffer=o.edges?o.edges[nv]:aD,this.$_vertexBorder=o.edges?o.edges[rv]:lD,this.os=((g=o.edges)==null?void 0:g.avoidVertices)===!0,this.$_allowUnattachedEdges=((E=o.edges)==null?void 0:E.allowUnattached)===!0,this.$_edgesDetachable=((y=o.edges)==null?void 0:y.detachable)!==!1,this.$_reattachEdges=((x=o.edges)==null?void 0:x.reattach)===!0,this.$paintConnectorOutline=((f=o.edges)==null?void 0:f.paintOutline)!==!1,this.$connectorOutlineWidth=((b=o.edges)==null?void 0:b.outlineWidth)||20,this.$connectorOutlineColor=((A=o.edges)==null?void 0:A.outlineColor)||"transparent",this.zoomToFitOnLoad=o.zoomToFit===!0,this.router=new sh(this,{gridCellSize:((T=o.edges)==null?void 0:T.astarGridCellSize)||10,avoidVertices:this.os}),this.$_useModelForSizes=o.useModelForSizes===!0,this.$_writeSizeToElements=o.writeSizeToElements!==!1,this.$_useModelForPositions=o.useModelForPositions!==!1,this.magnetizerProfile=new fp(o.magnetizer||{},this.gridProfile),this.magnetizer=new Ri({positionGetter:S=>this.getElementPosition(S.id),getSize:S=>this.getElementSize(S.id),getId:S=>S.id,positionSetter:(S,R)=>{}}),this.ss=!0,o.edges!=null&&o.edges.simpleEdgeStyles===!1&&(this.ss=!1),this.setContainer(n),this.$setView(o.view),this.ja(pt,S=>{let R=this.$_connMap[S.edge.getId()];if(R){let v=this.dataSource.getEdgeType(S.edge.data),O=[...new Set([xe,v])];if(this.$_setConnectionType(R,O.join(" "),S.edge.data),this.ss===!0){let P={};this.$_extractSimpleEdgeStyles(S.edge.data,P)&&this.$_setLineStyle(R,P,!0)}this.le(P=>{P.$edgeUpdated(S.edge,R)})}}),this.ja(_d,S=>{if(S.source===this){S.group.data[this.$modelWidthAttribute]=S.sizeAfterUndo.width,S.group.data[this.$modelHeightAttribute]=S.sizeAfterUndo.height;var R=this.viewport.updateElement(S.group.id,null,null,S.sizeAfterUndo.width,S.sizeAfterUndo.height,null,null,!1);this.$setGroupElementSize(S.group,S.sizeAfterUndo),this.$doVertexUpdated(R),this.le(v=>{v.$groupResized({element:R,newGroupSize:S.sizeAfterUndo,originalGroupSize:S.sizeBeforeUndo})})}}),this.ja(Od,S=>{if(S.source===this){S.group.data[this.$modelWidthAttribute]=S.sizeAfterUndo.width,S.group.data[this.$modelHeightAttribute]=S.sizeAfterUndo.height;var R=this.viewport.updateElement(S.group.id,null,null,S.sizeAfterUndo.width,S.sizeAfterUndo.height,null,null,!1);this.$setGroupElementSize(S.group,S.sizeAfterUndo),this.$doVertexUpdated(R),this.le(v=>{v.$groupResized({element:R,newGroupSize:S.sizeAfterUndo,originalGroupSize:S.sizeBeforeUndo})})}}),this.$_layout=qe.get(Is.type,{adapter:this.$createDefaultLayoutAdapter(),instance:this.model,dataSource:this.dataSource,container:this.rootElement,options:{}});let a=o.layout||{type:So.type};this.setLayout(a,!0),this.$collapsedGroupSizeCalculator=o.getCollapsedGroupSize,this.Zd=o.defaultCollapsedGroupSize||{width:200,height:150},this.Ya=o.canCollapseGroup,this.Xa=o.canExpandGroup}get defaultScope(){return this.kd}get $modelTopAttribute(){return this.model.modelTopAttribute}get $modelLeftAttribute(){return this.model.modelLeftAttribute}get $modelWidthAttribute(){return this.model.modelWidthAttribute}get $modelHeightAttribute(){return this.model.modelHeightAttribute}get $modelRotationAttribute(){return this.model.modelRotationAttribute}get currentZoom(){return this.j}getLayout(){return this.$_layout}$edgeTargetChanged(e){if(e.source==null||e.source!==this){let t=e.edge,n=this.$_connMap[t.getId()],o=t.target.getFullId(),s=this.$getManagedElement(o);s==null&&H(t.target)&&(s=this.Jd(t.target),s==null&&(s=this.$getManagedElement(t.target.parent.id))),n?s!=null?(this.dataSource.debugEnabled&&console.log("DEBUG: target change",n),this._E(n,s,!Oi(e.old))):(delete this.$_connMap[t.getId()],this.ka(n,{force:!0,fireEvent:!1})):s!=null&&this.dataSource.debugEnabled&&U("DEBUG: Target for Edge "+t.getId()+" changed to Node "+s.id+"; we have no valid connection.")}}$select(e){if(K(e.obj)||Y(e.obj)){let t=this.getRenderedElement(e.obj.id);t&&this.$addClassToElement(t,ki)}else if(Ke(e.obj)){let t=this.$_connMap[e.obj.id];t&&this.$addConnectorClass(t.connector,eh)}else if(H(e.obj)){let t=this.getRenderedElement(e.obj.getFullId());t&&this.$addClassToElement(t,ki)}}setSuspendRendering(e,t){}$deselect(e){if(K(e.obj)||Y(e.obj)){let t=this.getRenderedElement(e.obj.id);t&&this.$removeClassFromElement(t,ki)}else if(Ke(e.obj)){let t=this.$_connMap[e.obj.id];t&&this.$removeConnectorClass(t.connector,eh)}else if(H(e.obj)){let t=this.getRenderedElement(e.obj.getFullId());t&&this.$removeClassFromElement(t,ki)}}$selectionCleared(e){this.$getSelector(this.me,"."+eh).forEach(t=>this.$removeClassFromElement(t,eh)),this.$getSelector(this.me,"."+ki).forEach(t=>this.$removeClassFromElement(t,ki))}Jd(e){let t=this.getRenderedPort(e);if(t!=null)return this.$manage(t,e,null,null,null,!1)}$edgeSourceChanged(e){if(e.source==null||e.source!==this){let t=e.edge,n=this.$_connMap[t.getId()],o=t.source.getFullId(),s=this.$getManagedElement(o);s==null&&H(t.source)&&(s=this.Jd(t.source),s==null&&(s=this.$getManagedElement(t.source.parent.id))),n&&s?s!=null?this.RE(n,s,!Oi(e.old)):(delete this.$_connMap[t.getId()],this.ka(n,{force:!0,fireEvent:!1})):s!=null&&this.dataSource.debugEnabled&&U("DEBUG: Source for Edge "+t.getId()+" changed to Node "+t.source.getFullId()+"; we have no valid connection.")}}onDestroy(e){this.bind(Di,e)}ja(e,t){this.Ba.push({event:e,fn:t}),this.dataSource.bind(e,t,!0)}$dataLoadStart(){this.$_dataLoading=!0,this.$_setSuspendDrawing(!0),this.viewport.setSuspended(!0),this.fire(Zd)}$dataAppendStart(){this.$_setSuspendDrawing(!0)}$dataAppendEnd(e){}$dataLoadEnd(e){if(this.$unrenderedVertices.size===0){let t=V();this.$_setSuspendDrawing(!1,!1),e?this.viewport.setSuspended(!1):(this.relayout(null,!0),this.viewport.setSuspended(!1),this.$flushUnrenderedEdges(t),this.router.$redrawEveryConnection()),this.zoomToFitOnLoad&&!e&&this.zoomToFit(),this.$_dataLoading=!1,this.fire(vn)}}zoomToFit(e){this.$zoomToFit(e)}zoomToFitIfNecessary(e){this.$zoomToFitIfNecessary(e)}zoomToElements(e){this.$zoomToElements(e)}cloneVertex(e,t){var o,s;let n=this.getObjectInfo(e,!1);if(n.obj){let a=t==null?void 0:t.newPosition,l=ot(n.obj.data);if(delete l.id,a!=null)l[this.$modelLeftAttribute]=a.x,l[this.$modelTopAttribute]=a.y;else{let d=((o=t==null?void 0:t.offsetPosition)==null?void 0:o.x)||50,u=((s=t==null?void 0:t.offsetPosition)==null?void 0:s.y)||50;l[this.$modelLeftAttribute]+=d,l[this.$modelTopAttribute]+=u}let h;return this.model.transaction(()=>{h=Y(n.obj)?this.model.addGroup(l):this.model.addNode(l),a==null&&(this.magnetizerProfile.constant&&(t==null?void 0:t.magnetize)!==!1||!this.magnetizerProfile.constant&&(t==null?void 0:t.magnetize)===!0)&&this.as(h,null,!1,{},{},null,!0,!1,!1),(t==null?void 0:t.selectAfterCreate)===!0&&setTimeout(()=>this.model.setSelection(h))},St),h}}Kd(){let e,t,n,o,s,a=!1,l=V();for(e=0,n=this.dataSource.getGroupCount();e<n;e++)o=this.dataSource.getGroupAt(e),this.objectFilter(o)&&(this.$doRenderGroup(o),a=!0);for(e=0,n=this.dataSource.getNodeCount();e<n;e++)t=this.dataSource.getNodeAt(e),this.objectFilter(t)&&(this.$doRenderNode(t),a=!0);let h=this.dataSource.getAllEdges();for(e=0,n=h.length;e<n;e++)s=h[e],this.objectFilter(s)&&(this.qd(h[e],Al,null,null,l),a=!0);return this.$flushUnrenderedEdges(l),a}$_hasUnrenderedEdges(){return this.wt.length!==0}LE(e,t,n,o){let s=H(o.source)?o.source.getParent():o.source,a=H(o.target)?o.target.getParent():o.target,l=n.sourcePortType||(H(o.source)?null:this.$getAttribute(e,ai)||this.$getAttribute(e,Hr)),h=n.targetPortType||(H(o.target)?null:this.$getAttribute(e,ji)||this.$getAttribute(t,Hr));return{sourceDef:l!=null?this.view.getPortDefinition(l):this.view.getTypeDefinition(o.source),targetDef:h!=null?this.view.getPortDefinition(h):this.view.getTypeDefinition(o.target),sourceParentDef:this.view.getTypeDefinition(s),targetParentDef:this.view.getTypeDefinition(a)}}$_extractSimpleEdgeStyles(e,t){let n=!1;return sD.forEach(o=>{e.hasOwnProperty(o)&&(n=!0,t[o]=e[o])}),n}wE(e,t,n,o){var R,v;let s=e.edge,a=e.context||{},l=a.edgeType||this.dataSource.getEdgeType(s.data),h=e.def||this.view.getEdgeDefinition(l),d=H(s.source)?s.source.getParent():s.source,u=this.getElement(d.id),p=H(s.target)?s.target.getParent():s.target,m=this.getElement(p.id),{sourceDef:g,targetDef:E,sourceParentDef:y,targetParentDef:x}=this.LE(u.el,m.el,a,s),f={type:l,data:s.data,cost:s.getCost(),directed:s.isDirected(),geometry:s.geometry,id:s.id,edge:s,anchor:null,anchors:[null,null],source:t,target:n,sourceMarker:h.sourceMarker||this.Hd,targetMarker:h.targetMarker||this.Wd};[qu,iv,sv].forEach(O=>{h.hasOwnProperty(O)&&(f[O]=h[O])}),f.anchor&&!f.anchors&&(f.anchors=[f.anchor,f.anchor],delete f.anchor);let A=(O,P,I,C,_)=>{if(C&&C[I]){let w=O[P]||[C[I],C[I]];w[_]=C[I],O[P]=w}};g!=null&&A(f,rh,th,g,0),E!=null&&A(f,rh,th,E,1);let T=f;if(T.avoidVertices=this.os||h.avoidVertices,this.dataSource.debugEnabled&&console.log("Renderer","adding connection with params",T),h!=null&&Object.assign(f,bo(h,s.data,null,!0)),this.$manage(T.source,s.source,null,null,null,!1),(R=s.anchors)!=null&&R.source)f.anchors[0]=ft(s.anchors.source);else{let O=a.positionOnSource||{x:0,y:0},P=g.anchorPositions||y.anchorPositions,I=g.anchorPositionFinder||y.anchorPositionFinder;if(P!=null)f.anchors[0]=lp(P.slice(),null,O);else if(I!=null){let C=I(u.el,O,s.source,E);f.anchors[0]=C}}if(this.$manage(T.target,s.target,null,null,null,!1),(v=s.anchors)!=null&&v.target)f.anchors[1]=ft(s.anchors.target);else{let O=a.positionOnTarget||{x:0,y:0},P=E.anchorPositions||x.anchorPositions,I=E.anchorPositionFinder||x.anchorPositionFinder;if(a.targetAnchor!=null)f.anchors[1]=lp([a.targetAnchor]);else if(P!=null)f.anchors[1]=lp(P.slice(),null,O);else if(I!=null){let C=I(m.el,O,s.target,E);f.anchors[1]=C}}this.ss===!0&&this.$_extractSimpleEdgeStyles(s.data,f);let S=qv(this,f);if(S!=null){xp(S,this.getElement(S.sourceId),this.getElement(S.targetId)),T.geometry&&(Ne.importGeometry(S,T.geometry),this.$revalidateElementById(S.sourceId,o),this.$revalidateElementById(S.targetId,o)),S.edge=s,this.$_connMap[s.getId()]=S,s.source.dummy&&(S.anchors.source.isFixed=!0,S.anchors.source.fixedLocation={x:.5,y:.5,ox:0,oy:0,offsetX:0,offsetY:0}),s.target.dummy&&(S.anchors.target.isFixed=!0,S.anchors.target.fixedLocation={x:.5,y:.5,ox:0,oy:0,offsetX:0,offsetY:0}),this.PE&&this.refresh(),(m.visible===!1||u.visible===!1)&&this.ls(s,!1),T.geometry||this.$revalidateElementById(S.sourceId,o);let O={connection:S,edge:s,reason:e.reason};this.fire(DA,O)}else U("VisuallyJs - WARN : An edge could not be rendered "+s+" and is being removed from the dataset."),this.model.removeEdge(s,this);return S}$graphClearStart(){this.$_layout&&this.$_layout.Jn(),this.layoutMap.clear(),this.reset()}$graphClearEnd(){}$groupRemoved(e){let t=this.viewport.getGroupElement(e.group.id);return t&&(this.vertexList=this.vertexList.filter(o=>o.id!==e.group.id),e.removeChildren===!1&&e.children.forEach(o=>{let s=this.$getManagedElement(o.id);o.data[this.$modelLeftAttribute]=s.x,o.data[this.$modelTopAttribute]=s.y,this.$appendElementToVertexLayer(s.el),this.$setViewportElementPosition(s,s)}),e.group.getPorts().map(o=>this.$getManagedElement(o.getFullId())).forEach(o=>this.$__unmanage(o.el,!1,!0)),this.$__unmanage(t.el,e.removeChildren===!0,!0),this.le(o=>{o.$groupRemoved(t)})),t}qd(e,t,n,o,s,a){this.wt.push({edge:e,reason:t,context:n,def:o}),a&&this.$flushUnrenderedEdges(s)}$flushUnrenderedEdges(e){let t=this.wt.length,n=[];if(t>0){let o=[];for(let s=0;s<this.wt.length;s++)this.DE(this.wt[s],e)==null?o.push(this.wt[s]):n.push(this.wt[s].edge);this.wt=o}return n}DE(e,t){let n=this.getRenderedElement(e.edge.target),o=this.getRenderedElement(e.edge.source);return n==null||o==null?null:this.wE(e,o,n,t)}$edgeAdded(e,t){if(e.source!==this||e.transient===!0&&e.source===this){let n=e.edge;if(this.objectFilter(n.source)&&this.objectFilter(n.target)){let o=this.view.getEdgeDefinition(this.dataSource.getEdgeType(n.data||{}));if(o&&o.ignore===!0)return;this.qd(n,e.reason,t,o,null,!this.$_dataLoading)}}}$edgeRemoved(e){if(e.edge.transient||e.source!==this){let t=e.edge,n=this.$_connMap[t.getId()];n&&(this.dataSource.debugEnabled&&console.log("Renderer","removing edge",t),delete this.$_connMap[t.getId()],this.ka(n,{fireEvent:!1,force:!0}),this.le(o=>{o.$edgeRemoved(t,n)}))}}$edgeGeometryUpdated(e,t,n){let o=this.getRenderedConnection(e.id);o!=null&&(t!=null?Ne.importGeometry(o,t):Bi(o),this.$revalidateElementById(e.source.getFullId()),this.fire(ti,{edge:e,geometry:t,originalGeometry:n}))}$exportEdgeGeometry(e){let t=this.$_connMap[e.id];return t==null?null:Yr(t.connector)}$nodeAdded(e){let t=e.node;this.objectFilter(t)&&this.$doRenderNode(t,e.eventInfo)}$groupAdded(e){let t=e.group;this.objectFilter(t)&&this.$doRenderGroup(t,e.eventInfo)}$portAdded(e){this.objectFilter(e.port.getParent())&&setTimeout(()=>this.$flushUnrenderedEdges(V()))}$vertexUpdated(e){if(e.vertex!=null){let t=this.getElement(e.vertex.getFullId());if(t){let n=null,o=e.vertex.data[this.$modelLeftAttribute],s=null,a=e.vertex.data[this.$modelTopAttribute];if(e.updates!=null){if((e.updates[this.$modelWidthAttribute]!=null||e.updates[this.$modelHeightAttribute]!=null)&&(n=e.vertex.data[this.$modelWidthAttribute],s=e.vertex.data[this.$modelHeightAttribute],this.$_useModelForSizes)){let d=this.$resolveVertexSizeFromModel(e.vertex,this.view.getTypeDefinition(e.vertex));this.$setElementSizeInUI(t.el,d.width,d.height),n=d.width,s=d.height,this.le(u=>{u.$vertexResized(this.getElement(e.vertex.getFullId()),n,s)})}e.updates[this.$modelRotationAttribute]!=null&&this.Qd(e.vertex,e.updates[this.$modelRotationAttribute],!1,!0)}let l=o,h=a;if(e.vertex.group!=null){let d=this.$_getGroupContentAreaInfo(e.vertex.group.id).pageOrigin;l+=d.x,h+=d.y}if(this.viewport.updateElement(t.id,l,h,n,s,null,e.vertex,!1),(e.updates[this.$modelLeftAttribute]!=null||e.updates[this.$modelTopAttribute]!=null)&&this.$setViewportElementPosition(t,{x:o,y:a}),this.$doVertexUpdated(t),this.$repaintUIElement(this.getElement(t.id)),e.reason===Js&&this.os){let d=this.model.getAllEdges().filter(u=>Zn(u.source).id!==e.vertex.id&&Zn(u.target).id!==e.vertex.id);this.repaintEdges(d)}e.reason===ou?this.NE(this.getElement(t.id),e.originalData):this.fire(ks,this.getElement(t.id)),this.le(d=>d.$vertexUpdated(this.getElement(t.id),e.reason))}}}NE(e,t){let n={x:t[this.$modelLeftAttribute],y:t[this.$modelTopAttribute]},o={dragGroup:[{element:e,vertex:e.modelObject,pos:{x:e.x,y:e.y},originalPos:n}],positions:{[e.id]:{x:e.x,y:e.y}},ui:this},s=Y(e.modelObject)?Gr:Dt;this.fire(s,o)}IE(e){this.fire(Le,e)}getLayoutFor(e){return iE(e)||oE(e)?this.layoutMap.get(e.group.id):this.$_layout}$groupMemberAdded(e){this.$_processGroupAddition(e,!1)||(this.$unprocessedGroupMemberships.has(e.group.id)||this.$unprocessedGroupMemberships.set(e.group.id,[]),this.$unprocessedGroupMemberships.get(e.group.id).push(e))}$_processGroupAddition(e,t){let n=this.$getManagedElement(e.vertex.id),o=this.viewport.getGroupElement(e.group.id);if(o!=null&&n!=null){this.$appendElement(n.el,o.contentArea);let s=this.$_getGroupContentAreaInfo(e.group.id),a=e.positionInGroup?e.positionInGroup.x:n.x-o.x,l=e.positionInGroup?e.positionInGroup.y:n.y-o.y;return this.$_updateVertexPositions({positions:{[n.id]:{x:a,y:l}},sizes:null,offset:{x:o.x+s.internalOffset.x,y:o.y+s.internalOffset.y},storePositionsInModel:!0,repaintConnections:!0,resizedGroups:null,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1}),e.source!=this&&this.relayoutGroup(e.group.id,oS),this.le(h=>{h.$groupMemberAdded(n)}),t||setTimeout(()=>this.$revalidateElement(n.el)),!0}else return!1}$groupMemberRemoved(e){let t=this.$getManagedElement(e.vertex.id),n=this.viewport.getGroupElement(e.group.id),o=this.$_getGroupContentAreaInfo(e.group.id);this.$appendElementToVertexLayer(t.el),this.$_updateVertexPositions({positions:{[t.id]:{x:t.x-n.x-o.internalOffset.x,y:t.y-n.y-o.internalOffset.y}},sizes:null,offset:null,storePositionsInModel:!0,repaintConnections:!0,resizedGroups:null,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1}),this.le(s=>{s.$groupMemberRemoved(t)})}$nodeRemoved(e){let t=this.$getManagedElement(e.node.id);return t&&(e.node.getPorts().map(o=>this.$getManagedElement(o.getFullId())).filter(o=>o!=null).forEach(o=>this.$__unmanage(o.el,!1,!0)),this.vertexList=this.vertexList.filter(o=>o.id!==e.node.id),this.$__unmanage(t.el,!1,!0),this.le(o=>{o.$nodeRemoved(t)}),this.IE(t)),t}$portRemoved(e){let t=this.$getManagedElement(e.port.getFullId());if(t){let n=this.$getManagedElement(e.port.getParent().id);n.el!==t.el?this.$__unmanage(t.el,!1,!1):(this.$removeAttribute(n.el,Kl),this.$removeAttribute(n.el,Hr))}}$edgeTypeChanged(e,t,n){let o=this.$_connMap[e.getId()];if(o){let s=this.view.getEdgeDefinition(n);if(s&&s.ignore===!0)return;s.connector&&Wt.Ud(o,s.connector),we.setType(o,n,e.data)}}$groupTypeChanged(e,t,n){}$nodeTypeChanged(e,t,n){this.$reRenderNode(e)}$portTypeChanged(e,t,n){}$vertexRendered(e,t,n,o){if(!t)throw new Error("Cannot render vertex");let s=K(e),a=Y(e);this.$setAttribute(t,ee,e.getFullId());let l=s?Hi:a?Ho:H(e)?ev:"";this.$addClassToElement(t,l),t.jtk=t.jtk||{},t.jtk[e.objectType.toLowerCase()]=e,t.jtk.vertex=e;let h=this.getElement(e.id),d=h!=null;if(d&&(this.$setAttribute(t,Pt,this.$getAttribute(h.el,Pt)),h.el=t,this.model.getSelection().containsVertex(e.id)&&this.$addClassToElement(t,ki)),K(e)||Y(e))if(this.vertexList.push(e),e.group==null)this.$appendVertexElement(t);else{let g=this.eu(e.group);this.$appendElement(t,g)}let u=null,p=e.data[this.$modelRotationAttribute];this.$_useModelForSizes?(u=this.$resolveVertexSizeFromModel(e,n),this.$_writeSizeToElements!==!1&&this.$setElementSizeInUI(t,u.width,u.height),e.data[this.$modelWidthAttribute]=u.width,e.data[this.$modelHeightAttribute]=u.height):u=this.$getSize(t);let m=this.$manage(t,e,null,u,null,!1);if(p!=null&&this.Qd(e,p,!this.$_dataLoading,!1),K(e)){if(!d){let g={el:t,id:e.id,vertex:e,size:u};this.fire(Br,g)}}else if(Y(e)){let g={el:t,vertex:e,id:e.id,size:u},E=m,y=n;E.contentArea=this.$getGroupContentAreaElement(t),E.elastic=y.elastic===!0;let x=y.layout||{type:So.type};this.layoutMap.set(e.id,this.tu(x,e)),this.fire($r,g),this.$unprocessedGroupMemberships.has(e.id)&&(this.$unprocessedGroupMemberships.get(e.id).forEach(b=>this.$_processGroupAddition(b,!0)),this.$unprocessedGroupMemberships.delete(e.id))}if(this.$unrenderedVertices.delete(e.id),this.$_dataLoading&&this.$isAsynchronousRender())this.$dataLoadEnd(!1);else if(!this.$_dataLoading){d&&this.le(y=>{y.$vertexRerendered({el:t,id:e.id,vertex:e,size:u})});let g=V(),E=this.$flushUnrenderedEdges(null);this.$unrenderedVertices.size===0&&this.refresh(),E.forEach(y=>{this.viewport.$refreshElement(y.source.getFullId()),this.viewport.$refreshElement(y.target.getFullId()),this.router.$redrawConnection(y,g)})}}ls(e,t,n){let o=this.$_connMap[e.id];o&&Wt.setVisible(o,t)}isVisible(e){return this.ru(e,t=>{switch(t.type){case Fe.objectType:let n=this.$_connMap[t.obj.id];return n?n.visible:!1;case de.objectType:case le.objectType:return t.managedElement.visible!==!1}})}setVisible(e,t,n){if(e==null)return;let o=s=>{switch(s.type){case Fe.objectType:this.ls(s.obj,t,n);break;case de.objectType:case le.objectType:this.ME(s,t,n);break;case me.objectType:U("WARN togglePort method not implemented in 7.x");break}};this.ru(e,o)}ME(e,t,n){if(e.el&&(this.$setElementVisible(e.el,t),e.el.$b=t,e.managedElement.visible=t,this.fire(Jd,{node:e.obj,el:e.el,state:t}),!n)){let o=this.dataSource.getAllEdgesFor(e.obj);for(let s=0;s<o.length;s++)if(!t)this.ls(o[s],t,n);else{let a=Zn(o[s].source),l=Zn(o[s].target),h=a===e.obj?l:a;this.isVisible(h)&&this.ls(o[s],t,n)}}}ru(e,t){let n;if(gS(e))n={nodes:[],edges:[]},e.eachVertex((o,s)=>{n.nodes.push(t(this.getObjectInfo(s,!1)))}),e.eachEdge((o,s)=>{n.edges.push(t(this.getObjectInfo(s,!1)))});else if(this.$isArrayLike(e)){n=[];for(let o=0;o<e.length;o++)n.push(t(this.getObjectInfo(e[o],!1)))}else n=t(this.getObjectInfo(e,!1));return n}$resolveVertexSizeFromModel(e,t){let n=this.$_getModelSizeForVertex(e);return n!=null?n:this.$_getDefaultSizeForVertex(e,t)}$_getDefaultSizeForVertex(e,t){let n=K(e)?this.defaults.nodeSize||{width:100,height:80}:this.defaults.groupSize||{width:300,height:300};return t.defaultSize&&(n.width=t.defaultSize.width,n.height=t.defaultSize.height),n}$_getModelSizeForVertex(e){let t=e.data[this.$modelWidthAttribute],n=e.data[this.$modelHeightAttribute];if(t!=null&&n!=null)return{width:e.data[this.$modelWidthAttribute],height:e.data[this.$modelHeightAttribute]}}getContainer(){return this.me}setZoom(e,t){return this.j=e,e}F(e){if(e==null)return null;let t=this.$getAttribute(e,Pt);return(!t||t==="undefined")&&(t=`vjs-${V()}`,this.$setAttribute(e,Pt,t)),t}setContainer(e){this.me=e}nu(e,t,n,o){let s=n===0?e.sourceId:e.targetId;if(o){let l=n===0?e.anchors.source:e.anchors.target;l.isFixed=!1,delete l.fixedLocation}let a={index:n,originalSourceId:n===0?s:e.sourceId,newSourceId:e.sourceId,originalTargetId:n===1?s:e.targetId,newTargetId:e.targetId,connection:e};return n===0?(a.newSourceId=t.id,e.sourceId=t.id,e.sourceElement=t.el):(a.newTargetId=t.id,e.targetId=t.id,e.targetElement=t.el),a}RE(e,t,n){bp(e,this.getElement(e.sourceId)),this.$revalidateManagedElement(this.getElement(e.sourceId));let o=this.nu(e,t,0,n);xp(e,this.getElement(o.newSourceId),this.getElement(e.targetId)),this.$revalidateManagedElement(this.getElement(o.newSourceId))}_E(e,t,n){bp(e,this.getElement(e.targetId)),this.$revalidateManagedElement(this.getElement(e.targetId));let o=this.nu(e,t,1,n);xp(e,this.getElement(e.sourceId),this.getElement(o.newTargetId)),this.$revalidateManagedElement(this.getElement(o.newTargetId))}$_setConnectionType(e,t,n){let o=we.setType(e,t,n);return this.$paintConnection(e),o}$_setSuspendDrawing(e,t){let n=this.pt;return this.pt=e,e?this.jd=""+new Date().getTime():this.jd=null,this.pt||(this.autoSizeGroups(Array.from(this.za.keys()).map(o=>o.modelObject)),this.za.clear(),t&&this.repaintEverything()),n}$batch(e,t){let n=this.pt===!0;n||this.$_setSuspendDrawing(!0),e(),n||this.$_setSuspendDrawing(!1,!t)}An(e){let t=e.elId;return e.recalc?this.viewport.$refreshElement(t,!1,e.pos,e.size):this.viewport.getPosition(t)}VE(e,t){return this.dataSource.beforeDetach(e.edge.source,e.edge.target,e.edge)}ka(e,t){return e!=null&&e.deleted!==!0&&(t=t||{},t.force||this.VE(e)===!0)?(bp(e,this.getElement(e.sourceId),this.getElement(e.targetId)),this.router.$connectionRemoved({connection:e,reason:bl,edge:e.edge}),delete this.$_connMap[e.id],Wt.destroy(e),!0):!1}$manage(e,t,n,o,s,a){let l=t.getFullId();this.$getAttribute(e,Pt)==null&&this.$setAttribute(e,Pt,l);let h=this.getElement(l);return h==null?(h=this.viewport.addElement(l,e,t,n,o,s),this.pt||this.An({elId:l,recalc:!0,pos:n,size:o,rotation:s})):a&&this.An({elId:l,timestamp:null,recalc:!0}),h}$getManagedElement(e){return this.viewport.getElement(e)}$__unmanage(e,t,n){let o=s=>{let a=this.F(s),l=this.getElement(a);this.router.elementRemoved(l),this.viewport.remove(a),this.$removeAttribute(s,Pt),s&&n&&this.$removeElement(s)};t&&this.$getAssociatedElements(e).map(o),o(e)}rotate(e,t){this.getObjectInfo(e,!1).obj&&this.model.$_updateVertex(e,{[this.$modelRotationAttribute]:t},Zs,!1)}setSize(e,t,n){this.getObjectInfo(e,!1).obj&&this.model.transaction(()=>{this.model.$_updateVertex(e,{[this.$modelWidthAttribute]:t,[this.$modelHeightAttribute]:n},uS,!1)},St)}Qd(e,t,n,o){let s=z(e)?e:e.id;if(this.getElement(s)){this.viewport.yE(s,t);let a=this.getElement(s);if(this.$syncManagedElementWithView(a,!1),this.le(l=>{l.$vertexRotated(a,t)}),n!==!0)return this.$revalidateElementById(s)}}$getRotation(e){let t=this.getElement(e);return t!=null&&t.r||0}$getRotations(e){let t=[],n=this.getElement(e),o=s=>{if((K(s.modelObject)||Y(s.modelObject))&&s.modelObject.group){let a=this.getElement(s.modelObject.group.id);a!=null&&(t.push({r:a.r,c:a.c}),o(a))}};return n!=null&&(t.push({r:n.r||0,c:n.c}),o(n)),t}$revalidateElement(e,t){let n=this.F(e);return this.$revalidateElementById(n)}$revalidateElementById(e,t){return this.$revalidateManagedElement(this.getElement(e),t)}$revalidateManagedElement(e,t){return e!=null?(this.An({elId:e.id,recalc:!0,timestamp:t}),this.$repaintUIElement(e)):ip()}repaintEverything(e){let t=V();e!==!0&&this.viewport.$refreshEveryElement(),this.viewport.recomputeBounds(),this.viewport.$forEachElement(n=>this.$repaintUIElement(n,t,!0))}repaint(e,t){let n=this.getObjectInfo(e,!1);n!=null&&(t&&this.$setViewportElementPosition(n.managedElement,n.managedElement),this.$repaintUIElement(n.managedElement))}$repaintUIElement(e,t,n){let o=ip(),s=a=>{a.c.forEach(l=>o.c.add(l))};if(!this.pt&&e!=null){let a=this.$getAssociatedElements(e.el).map(l=>this.getElement(this.F(l))).filter(l=>l!=null);if(t==null&&(t=V()),!n)for(let l=0;l<a.length;l++)this.An({elId:a[l].id,recalc:!0,timestamp:t});if(s(this.router.$redraw(e,t,null)),a.length>0)for(let l=0;l<a.length;l++)s(this.router.$redraw(a[l],t,null))}return o}reset(){this.$_connMap={},this.vertexList.length=0,this.viewport.reset(),this.router.reset(),this.wt.length=0,this.$unrenderedVertices.clear(),this.za.clear()}getRenderedConnection(e){return this.$_connMap[e]}getNodes(){return this.vertexList.filter(K)}getGroups(){return this.vertexList.filter(Y)}getUIGroups(){return this.getGroups().map(e=>this.viewport.getGroupElement(e.id))}destroy(){for(let e=0;e<this.Fa.length;e++)this.off(this.me,this.Fa[e][0],this.Fa[e][1]);this.reset(),this.unbind(),this.Ua.clear()}$registerConnectionType(e,t){let n=Object.assign({},t);if(this.Ua.set(e,n),t.overlays){let o={};for(let s=0;s<t.overlays.length;s++){let a=hi(t.overlays[s]);o[a.options.id]=a}n.overlays=o}if(t.sourceMarker){let o=hi(t.sourceMarker);o.options.direction=-1,o.options.location=0,o.sourceMarker=!0,n.sourceMarker=o}if(t.targetMarker){let o=hi(t.targetMarker);o.options.direction=1,o.options.location=1,o.targetMarker=!0,n.targetMarker=o}}$getConnectionType(e){return this.Ua.get(e)}$sourceOrTargetChanged(e,t,n,o,s){let a,l,h,d;e!==t&&(s===Qe?(n.sourceId=t,n.sourceElement=o,h=this.getElement(e),a=this.getElement(t),l=this.getElement(n.targetId),d=l):s===An&&(n.targetId=t,n.targetElement=o,l=this.getElement(t),d=this.getElement(e),a=this.getElement(n.sourceId),h=a),bp(n,h,d),xp(n,a,l))}Ha(e,t,n,o){n=n||{},o=o||{},t=t||{};let s={},a=yn(e);a.unshift(e),a.forEach(l=>{let h=this.viewport.getGroupElement(l.id),d=o[l.id]||this.viewport.$computeGroupContentExtents(l,!1,t,n,null),u=this.Wa(l,t,n,d,!1);if(u!=null&&(s[l.id]=u,n[l.id]=u.size,t[l.id]=u.position,(u.originalSize.width!==u.size.width||u.originalSize.height!==u.size.height)&&(this.$trackGroupSizeChanges({[l.id]:{element:h,originalGroupSize:u.originalSize,newGroupSize:u.size}}),l.group==null))){let p=u.size.width-u.originalSize.width,m=u.size.height-u.originalSize.height;if(this.magnetizerProfile.afterGroupShrink&&(p<0||m<0)){let g=this.$provisionallyGather(l,t,n,!1,!1);this.$_updateVertexPositions({positions:g.current,storePositionsInModel:!0,sizes:null,resizedGroups:null,offset:null,repaintConnections:!0,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1})}else if(this.magnetizerProfile.afterGroupGrow){let g=this.$provisionallyMagnetize(l,!1,t,n,!1,!1);this.$_updateVertexPositions({positions:g.current,storePositionsInModel:!0,sizes:null,resizedGroups:null,offset:null,repaintConnections:!0,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1})}}})}expandGroup(e){this.model.$transaction(()=>{let t=z(e)?this.dataSource.getGroup(e):e,n=this.viewport.getGroupElement(t.id);if(n!=null){let o=this.Xa?this.Xa(t,n.lastExpandedSize):null;if(o===!1)return;let s=n.el;if(this.iu(n)==null){n.collapsed=!1,this.$updateElementClasses(s,[gf],[mf]);let l=new Set,h=new Set,d=new Set;this.ou(n,l,h,d,!0),d.forEach(p=>this.$setConnectionVisible(this.$_connMap[p.id],!0)),l.forEach(p=>this.$_unproxyEdge(p.edge,p.index));let u={};if(this.$_useModelForSizes&&n.lastExpandedSize!=null&&(u[t.id]=n.lastExpandedSize,this.model.updateGroup(t,n.lastExpandedSize)),o!=null){let p=o;for(let m in p)this.model.updateVertex(m,p[m])}this.Ha(t,null,u,null),this.magnetizerProfile.afterGroupExpand===!0&&this.magnetize(n.modelObject),this.$revalidateManagedElement(n),this.le(p=>{p.$groupExpanded(n)}),this.fire(Wd,{group:t})}}},St,!0)}$_proxyEdge(e,t,n,o){tC(this,e,t,n,o)}$_unproxyEdge(e,t,n){return eC(this,e,t,n)}ou(e,t,n,o,s){let a=e.modelObject.members.map(d=>d.id),l=aE(e.modelObject,!0,!0);this.An({elId:e.id,recalc:!0}),a.forEach(d=>{this.An({elId:d,recalc:!0})});let h=ml(l,d=>!(a.indexOf(d.source.id)!==-1&&a.indexOf(d.target.id)!==-1));h.left.forEach(d=>{t.add({edge:d,index:a.indexOf(d.source.id)===-1?An:Qe})}),h.right.forEach(d=>{o.add(d)}),this.su(e).forEach(d=>{this.ou(d,t,n,o,!1)})}toggleGroup(e){let t=this.viewport.getGroupElement(z(e)?e:e.id);t!=null&&(t.collapsed?this.expandGroup(e):this.collapseGroup(e))}iu(e){let t=null;if(e.modelObject.group==null)return null;{let n=e.modelObject.group;for(;n!=null;){let o=this.$getManagedElement(n.id);o.collapsed&&(t=o),n=o.modelObject.group}return t}}collapseGroup(e){this.model.$transaction(()=>{let t=z(e)?this.dataSource.getGroup(e):e,n=this.viewport.getGroupElement(t.id);if(n!=null){let o={width:n.width,height:n.height},s=this.Ya==null?null:this.Ya(t,o);if(s===!1)return;let a=n.el;if(n.lastExpandedSize=o,this.iu(n)==null){n.collapsed=!0,this.$updateElementClasses(a,[mf],[gf]);let h=new Set,d=new Set;this.au(n,h,d),d.forEach(p=>this.$setConnectionVisible(this.$_connMap[p.id],!1)),h.forEach(p=>this.$_proxyEdge(p.edge,p.index,n));let u={};if(this.$_useModelForSizes){let p=this.$getCollapsedGroupSize(t,{width:n.width,height:n.height});u[t.id]=p,this.model.updateGroup(t,p)}if(s!=null){let p=s;for(let m in p)this.model.updateVertex(m,p[m])}this.Ha(t,null,u,null),this.$revalidateManagedElement(n),this.magnetizerProfile.afterGroupCollapse===!0&&this.gather(n.modelObject),this.le(p=>{p.$groupCollapsed(n)}),this.fire(kd,{group:t})}}},St,!0)}$computeCollapsedGroupSize(e,t){return this.$collapsedGroupSizeCalculator!=null?this.$collapsedGroupSizeCalculator(e,t):null}$getCollapsedGroupSize(e,t){try{let o=this.$computeCollapsedGroupSize(e,t);if(o!=null)return o}catch(o){U("ERROR: user function getGroupCollapsedSize threw error",o)}let n=this.getGroupDefinition(e);return n&&n.collapsedSize?n.collapsedSize:this.Zd}su(e){return e.modelObject.members.filter(t=>t.objectType===le.objectType).map(t=>this.viewport.getGroupElement(t.id))}au(e,t,n){let o=e.modelObject.members.map(a=>a.id),s=aE(e.modelObject,!0,!0);if(e.proxied!==!1){let a=ml(s,l=>!(o.indexOf(l.source.id)!==-1&&o.indexOf(l.target.id)!==-1));a.left.forEach(l=>{t.add({edge:l,index:o.indexOf(l.source.id)===-1?An:Qe})}),a.right.forEach(l=>{n.add(l)})}else s.forEach(a=>n.add(a));this.su(e).forEach(a=>{this.au(a,t,n)})}GE(){return this.lu(this.dataSource.getGroups().filter(this.objectFilter))}lu(e){let t=[];return e.forEach(n=>{let o=yn(n);t.push({group:n,depth:o.length})}),t.sort((n,o)=>n.depth===o.depth?0:n.depth>o.depth?-1:1),t}relayoutGroup(e,t){let n=Y(e)?e:this.dataSource.getGroup(e),o=this.layoutMap.get(n.id);if(o==null)return;let s=this.getElement(n.id),a=s;o.relayout(null,h=>{this.$_updateVertexPositions({positions:h.positions,sizes:h.sizes,resizedGroups:null,offset:{x:a.x,y:a.y},storePositionsInModel:!0,repaintConnections:!1,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1}),this.fire(Nl,{element:s,positions:h.positions,sizes:h.sizes,extents:h.bounds})});let l=!0;this.$_dataLoading&&this.$_useModelForSizes&&(l=!1),t===iS&&(l=!1),l&&this.autoSizeGroup(n),this.$revalidateManagedElement(s)}$_updateVertexPositions(e){let t=e.offset||{x:0,y:0},n=new Set,o=ip();for(let s in e.positions){let a=e.positions[s],l=e.sizes!=null?e.sizes[s].width:null,h=e.sizes!=null?e.sizes[s].height:null,d=this.viewport.updateElement(s,a.x+t.x,a.y+t.y,l,h,null,null,!1);e.writeSizesToElements&&l!=null&&h!=null&&this.$setElementSizeInUI(this.getElement(s).el,l,h),n.add(this.getElement(s)),this.$setViewportElementPosition(d,a),e.storePositionsInModel&&this.$storePositionInModel({id:s,pos:a})}if(e.resizedGroups!=null)for(let s in e.resizedGroups){let a=e.resizedGroups[s].newGroupSize;this.viewport.updateElement(s,null,null,a.width,a.height,null,e.resizedGroups[s].group,!1),n.add(this.getElement(s)),this.$_useModelForSizes&&this.$E(s,a)}if(e.rotations!=null)for(let s in e.rotations){let a=this.getElement(s);this.viewport.updateElement(s,null,null,null,null,e.rotations[s],null,!1),n.add(a),e.writeRotationsToElements&&this.$setElementRotation(a.el,e.rotations[s])}return e.repaintConnections&&n.forEach(s=>{this.$repaintUIElement(s).c.forEach(l=>o.c.add(l))}),o}relayout(e,t){this.cu(n=>{this.$_layout.relayout(e,n)},n=>{this.$afterRelayout(n)},Cn,t)}refresh(e){this.cu(t=>{this.$_layout.layout(t)},t=>{this.$afterRefresh(t)},Hs,e)}cu(e,t,n,o){if(!this.pt){let s={};e(a=>{let l=a.positions;if(this.magnetizerProfile.afterLayout){let p=[];for(let g in l)p.push(this.dataSource.getVertex(g));this.magnetizer.setElements(p);let m=this.magnetizer.executeAtCenter({getPosition:g=>l[g.id],getSize:g=>a.sizes[g.id]});for(let g in m.current)l[g]=m.current[g]}let h=this.BE(),d=h.orderedGroups.length>0&&!(this.$_dataLoading&&this.$_useModelForSizes),u={};if(d){let p=(g,E)=>h.info[g].positions[E]||this.getElementPosition(E),m=(g,E)=>a.sizes[E]||h.info[g].sizes[E]||this.getElementSize(E);h.orderedGroups.forEach(g=>{let E=Pi();g.group.members.forEach(x=>{let f=p(g.group.id,x.id),b=m(g.group.id,x.id);E.xmin=Math.min(E.xmin,f.x),E.ymin=Math.min(E.ymin,f.y),E.xmax=Math.max(E.xmax,f.x+b.width),E.ymax=Math.max(E.ymax,f.y+b.height)});let y=this.Wa(g.group,l,a.sizes,E,!1);if(y!=null&&(s[g.group.id]={group:g.group,newGroupSize:y.size,originalGroupSize:y.originalSize},l[g.group.id]!=null&&(l[g.group.id]=y.position),u[g.group.id]=this.$_getGroupContentAreaInfo(g.group.id),a.sizes[g.group.id]=y.size,y.layoutShiftX!==0||y.layoutShiftY!==0)){let x=h.info[g.group.id].positions;for(let f in x)x[f].x+=y.layoutShiftX,x[f].y+=y.layoutShiftY}})}this.$_updateVertexPositions({positions:l,sizes:a.sizes,resizedGroups:s,offset:null,repaintConnections:!1,storePositionsInModel:!0,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1}),h.orderedGroups.reverse().forEach(p=>{let m=p.group.id,g=h.info[m],E=l[m]||nr(g.element),y=u[m]||this.$_getGroupContentAreaInfo(m);y&&(E.x+=y.internalOffset.x,E.y+=y.internalOffset.y),this.$_updateVertexPositions({positions:g.positions,sizes:g.sizes,resizedGroups:s,offset:E,repaintConnections:!1,storePositionsInModel:!0,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1})}),o!==!0&&this.repaintEverything(!0),t({bounds:a.bounds,positions:a.positions,sizes:a.sizes,layout:a.layout}),this.fire(n,{positions:a.positions,sizes:a.sizes,layout:a.layout});for(let p in h.info)this.fire(Nl,h.info[p])})}}repaintEdge(e){let t=this.getRenderedConnection(e.id);this.$paintConnection(t)}repaintEdges(e){let t=V();e.forEach(n=>{let o=this.getRenderedConnection(n.id);this.$paintConnection(o,{timestamp:t})})}$paintConnection(e,t){if(!this.pt&&e.visible!==!1){t=t||{};let n=t.timestamp;if(n!=null&&n===e.lastPaintedAt)return;if(n==null||n!==e.lastPaintedAt){this.router.computePath(e,n);let o=e.sourceMarker;if(o!=null&&o.visible){let a=this.$drawOverlay(o,e.connector,e.paintStyleInUse);e.overlayPlacements[o.id]=a,e.connector.internalSegments.length>0&&(e.connector.internalSegments[0].x1=a.tail.x,e.connector.internalSegments[0].y1=a.tail.y)}let s=e.targetMarker;if(s!=null&&s.visible){let a=this.$drawOverlay(s,e.connector,e.paintStyleInUse);e.overlayPlacements[s.id]=a;let l=e.connector.internalSegments.length-1;e.connector.internalSegments.length>0&&(e.connector.internalSegments[l].x2=a.tail.x,e.connector.internalSegments[l].y2=a.tail.y)}for(let a in e.overlays)if(e.overlays.hasOwnProperty(a)){let l=e.overlays[a];l!==o&&l!==s&&l.visible&&(e.overlayPlacements[a]=this.$drawOverlay(l,e.connector,e.paintStyleInUse,Wt.getAbsoluteOverlayPosition(e,l)))}this.$paintConnector(e,e.paintStyleInUse);for(let a in e.overlays)if(e.overlays.hasOwnProperty(a)){let l=e.overlays[a];l.visible&&this.$paintOverlay(l,e.overlayPlacements[a],e.connector)}}e.lastPaintedAt=n}}$addOverlay(e,t,n){let o=oh(e,t);return o!=null&&(o.ignoreTypes=!0,n||this.$revalidateElementById(e.sourceId)),o}$removeOverlay(e,t){Ji(e,t),this.$revalidateElementById(e.sourceId)}$_setLineStyle(e,t,n){t.hasOwnProperty("lineWidth")&&(e.paintStyle.strokeWidth=t.lineWidth,e.hoverPaintStyle.strokeWidth=t.lineWidth),t.hasOwnProperty("outlineWidth")&&(e.paintStyle.outlineWidth=t.outlineWidth,e.hoverPaintStyle.outlineWidth=t.outlineWidth),t.hasOwnProperty("color")&&(e.paintStyle.stroke=t.color),t.hasOwnProperty("outlineColor")&&(e.paintStyle.outlineStroke=t.outlineColor),t.hasOwnProperty("dashArray")&&(e.paintStyle.dashArray=t.dashArray),dp(e),n&&this.$paintConnection(e)}$setView(e){this.view=new np(this.dataSource,this.dataSource.getModel(),e,this)}findIntersectingVertices(e){if(e.dontIncludeNodes===!0&&e.dontIncludeGroups===!0&&e.dontIncludeNodesInsideGroups===!0)return[];let t={x:e.origin.x,y:e.origin.y,width:e.dimensions.width,height:e.dimensions.height};return(e.enclosed?this.viewport.findVerticesEnclosedByRect(t,0,!1,[],!1):this.viewport.findVerticesIntersectingWithRect(t,0,!1,[],!1)).filter(s=>{let a=K(s.modelObject),l=a&&iE(s.modelObject),h=Y(s.modelObject),d=h&&oE(s.modelObject),u=e.dontIncludeNodes===!0&&a,p=e.dontIncludeGroups===!0&&h,m=e.dontIncludeNodesInsideGroups&&l,g=e.dontIncludeNestedGroups&&d;return!(u||p||m||g)}).map(s=>({enclosed:e.enclosed,id:s.id,r:s,v:s.modelObject,el:s.el}))}findEnclosedVertices(e){return this.findIntersectingVertices(Object.assign(e,{enclosed:!0}))}eu(e){let t=this.viewport.getGroupElement(e.id);return t==null?null:this.$getGroupContentAreaElement(t.el)}$_getGroupContentAreaInfo(e){let t=this.viewport.getGroupElement(e);if(t==null)return{pageOrigin:{x:0,y:0},internalOffset:{x:0,y:0},contentArea:null,isGroupElement:!0};{let n=this.$getGroupContentAreaElement(t.el);if(n!==t.el){let o=this.$getElementPositionInUIRelativeToParent(n);return{pageOrigin:{x:t.x+o.x,y:t.y+o.y},internalOffset:{x:o.x,y:o.y},contentArea:n,isGroupElement:!1}}else return{pageOrigin:{x:t.x,y:t.y},internalOffset:{x:0,y:0},contentArea:t.el,isGroupElement:!0}}}getElementPosition(e){return this.viewport.getElementPosition(e)}getElementSize(e){return this.viewport.getElementSize(e)}getElement(e){return this.viewport.getElement(e)}getGroupElement(e){return this.viewport.getGroupElement(e)}getObjectInfo(e,t){if(e==null)return{id:null,obj:null,el:null,type:null,managedElement:null};if(Wo(e)){let n=e.edge;return{obj:n,id:n.id,type:Fe.objectType,el:e.connector.canvas,managedElement:null}}else if(this.$isElement(e)){let n=this.getModelObjectFromElement(e,!0,t);if(n!=null){let o=this.dataSource.resolveFullId(n.obj);return{el:n.el,obj:n.obj,type:n.obj.objectType,id:o,managedElement:this.getElement(o)}}else{let o=this.F(e);return{id:o,obj:null,el:e,type:null,uiOnly:!0,managedElement:this.getElement(o)}}}else{let n=this.dataSource.getObjectInfo(e);return n.obj!=null?n.type===Fe.objectType?Object.assign({el:this.getRenderedConnection(n.id).connector.canvas,managedElement:null},n):Object.assign({el:this.getRenderedElement(n.obj),managedElement:this.getElement(n.obj.getFullId())},n):Object.assign({el:null,managedElement:null},n)}}Za(){let e=this.dataSource.getNodes().filter(t=>t.group==null);return e.push(...this.dataSource.getGroups().filter(t=>t.group==null)),e}FE(e,t,n,o,s,a,l,h,d,u){let p={invertTrackbackPreference:u};if(t&&(p.origin=t),n&&(p.gather=n),!h&&!d&&this.magnetizer.setElements(a),e){let g=this.getObjectInfo(e,!1);if(g.obj)if(!l)p.focus=g.obj.id;else{let E=this.getElement(g.obj.id);p.origin={x:E.x+E.width/2,y:E.y+E.height/2},p.filter=y=>y===g.obj.id}}o&&(p.knownLocations=o),s&&(p.knownSizes=s);let m=this.getGrid();return m&&(p.grid=m),p}cs(e,t,n,o,s,a,l,h,d,u){a==null&&(a=h?[]:this.Za());let p=this.FE(e,t,n,o,s,a,l,h,d,u);return p.focus!=null?this.magnetizer.executeWithFocus(p.focus,p):t!=null?this.magnetizer.executeAtPoint(t,p):this.magnetizer.executeAtCenter(p)}as(e,t,n,o,s,a,l,h,d){let u=this.cs(e,t,n,o,s,null,a,l,h,d);this.hs(u,cS)}magnetize(e,t){this.as(e,null,!1,null,null,t,!1,!1,!1)}$provisionallyMagnetize(e,t,n,o,s,a){return this.cs(e,null,!1,n,o,null,t,!1,s,a)}$provisionallyGather(e,t,n,o,s){return this.cs(e,null,!0,t,n,null,!1,!1,o,s)}magnetizeAtPoint(e){this.as(null,e,!1,null,null,null,!1,!1,!1)}gather(e){this.as(e,null,!0,null,null,null,!1,!1,!1)}$startMagnetizer(){this.magnetizer.startTracking(this.Za(),this.magnetizerProfile.trackback,this.magnetizerProfile.trackbackThreshold)}$stopMagnetizer(){this.magnetizer.stopTracking()}$startMotion(){this.$isInMotion=!0}$stopMotion(){this.$isInMotion=!1}hu(e){return{[this.$modelLeftAttribute]:e.x,[this.$modelTopAttribute]:e.y}}UE(e,t){let n=this.hu(t);this.model.updateVertex(e,n)}hs(e,t,n){this.model.openTransaction(St);try{for(let o in e.current){let s=this.hu(e.current[o]);this.model.$_updateVertex(o,s,t,!1)}n&&n()}catch(o){U("Exception thrown when setting position",o)}finally{this.model.commitTransaction()}}$storePositionInModel(e){let t=typeof e=="string"?e:e.id,n=typeof e=="string"?null:e.pos,o=this.getModelPositionAttributes(),s=typeof e=="string"?o.x:e.leftAttribute||o.x,a=typeof e=="string"?o.y:e.topAttribute||o.y,l=e.obj||this.dataSource.getVertex(t);return l&&(n==null&&(n=this.getElementPosition(l.id)),Oe(l.data,s,n.x),Oe(l.data,a,n.y)),n}$E(e,t){let n=z(e)?this.dataSource.getVertex(e):e;n&&(t==null&&(t=this.getElementSize(n.id)),Oe(n.data,this.$modelWidthAttribute,t.width),Oe(n.data,this.$modelHeightAttribute,t.height))}setMagnetizedPosition(e,t,n){this.setPosition(e,t,n,!0)}setPosition(e,t,n,o,s){let a=this.getObjectInfo(e,!1);if(a.obj)if(a.obj.group==null){let l=this.zE(a.obj,t,n,o,s===!1,!1,!1,!1);this.hs(l,ou)}else{let l=a.obj.group,h=this.viewport.getGroupElement(l.id);if(h!=null){let d={[a.id]:{x:t+h.x,y:n+h.y}},u={[a.id]:{x:t,y:n}},p=this.viewport.$computeGroupContentExtents(l,!1,d,null,null);this.hs({original:{},current:u},ou,()=>{this.Ha(l,u,null,{[l.id]:p})})}}}adHocGroupLayout(e,t){if(t){let n=this.dataSource.getObjectInfo(e);if(n.obj){let o=this.layoutMap.get(n.id);this.layoutMap.set(n.id,this.tu(t,n.obj)),this.relayoutGroup(n.obj,nS),this.layoutMap.set(n.id,o)}}}getGroupDefinition(e){return this.view.getGroupDefinition(this.model.getNodeType(e.data))}getPortDefinition(e){return this.view.getPortDefinition(this.model.getPortType(e.data))}getNodeDefinition(e){return this.view.getNodeDefinition(this.model.getNodeType(e.data))}zE(e,t,n,o,s,a,l,h){let d={x:t,y:n};if(o){let u=this.cs(e,{x:t,y:n},!1,{[e.id]:{x:t,y:n}},null,null,s,a,l,h);return u.original[e.id]={x:t,y:n},u.current[e.id]={x:t,y:n},u}else return this.YE()&&(d=se(d,this.getGrid())),{original:{[e.id]:d},current:{[e.id]:d}}}getModelPositionAttributes(){return{x:this.$modelLeftAttribute,y:this.$modelTopAttribute}}storePositionsInModel(e){e=e||{};let t=this.getModelPositionAttributes(),n=e.leftAttribute||t.x,o=e.topAttribute||t.y,s=(a,l)=>{let h=this.getElement(l.id);Oe(l.data,n,h.x),Oe(l.data,o,h.y)};this.dataSource.eachNode((a,l)=>s(a,l)),this.dataSource.eachGroup((a,l)=>s(a,l))}setGrid(e){this.gridProfile==null?this.gridProfile=new ah({size:e}):this.gridProfile.grid=e}getGrid(){return this.gridProfile==null?null:this.gridProfile.grid}YE(){return this.gridProfile!=null&&this.gridProfile.snap}Bb(e){if(this.gridProfile!=null){let t=this.$getSize(e),n=se({x:t.width,y:t.height},this.gridProfile.grid);return this.$setElementSizeInUI(e,n.x,n.y),{width:n.x,height:n.y}}return null}snapToGrid(e,t){t=t||this.getGrid();let n;if(t){e!=null&&(n=this.getObjectInfo(e,!1).obj),n!=null?this.magnetizer.setElements([n]):this.magnetizer.setElements(this.Za());let o=this.magnetizer.snapToGrid(t);return this.hs(o,dS),o}}autoSizeGroup(e,t){let n=new Set;return n.add(e),this.$_sizeGroupsToFit(n,null,null,t)[e.id]}$_sizeGroupsToFit(e,t,n,o){let s=this.lu(Array.from(e));t=t||{},n=n||{};let a={};return s.forEach(l=>{if(a[l.group.id]==null){let h=this.XE(l.group,o,t,n);Object.assign(a,h)}}),this.$trackGroupSizeChanges(a),a}XE(e,t,n,o){let s={};n=n||{},o=o||{};let a=l=>{let h=this.viewport.getGroupElement(l.id),d=this.viewport.$computeGroupContentExtents(l,!1,null,o,null),u=this.Wa(l,n,o,d,t);u!=null&&(o[l.id]=u.size,s[l.id]={element:h,newGroupSize:u.size,originalGroupSize:u.originalSize},l.group&&a(l.group))};return e&&a(e),s}BE(){let e={orderedGroups:this.GE(),info:{}};return e.orderedGroups.forEach(t=>{let n=this.layoutMap.get(t.group.id);if(n!=null){let o=this.viewport.getGroupElement(t.group.id);n.relayout(null,s=>{e.info[t.group.id]={positions:s.positions,sizes:s.sizes,extents:s.bounds,element:o}})}}),e}getGroupContentExtents(e,t){return this.viewport.$computeGroupContentExtents(e,t,null,null,null)}$trackGroupSizeChanges(e){for(let t in e){let n=e[t];if(n.originalGroupSize.width!==n.newGroupSize.width||n.originalGroupSize.height!==n.newGroupSize.height){let o=n.element.modelObject,s={[this.$modelWidthAttribute]:n.newGroupSize.width,[this.$modelHeightAttribute]:n.newGroupSize.height};o.data[this.$modelWidthAttribute]=n.newGroupSize.width,o.data[this.$modelHeightAttribute]=n.newGroupSize.height;let a=this.viewport.updateElement(o.id,null,null,n.newGroupSize.width,n.newGroupSize.height,null,null,!1);this.$doVertexUpdated(a),this.$repaintUIElement(a,null,!0),this.model.fire(Pd,{group:o,originalGroupSize:n.originalGroupSize,newGroupSize:n.newGroupSize,source:this}),this.le(l=>{l.$groupResized(n)}),this.model.fire(Re,{vertex:o,updates:s,originalData:o.data,reason:hS},null)}}}Wa(e,t,n,o,s){t=t||{},n=n||{};let a=this.getGroupDefinition(e),l=s||a.autoShrink||a.autoGrow||a.autoSize||a.elastic,h=a.autoShrink===!0||a.elastic===!0||a.autoSize===!0&&a.autoShrink!==!1,d=a.autoGrow===!0||a.elastic===!0||a.autoSize===!0&&a.autoGrow!==!1;if(!l)return null;let u=P=>t[P]||this.getElementPosition(P),p=P=>n[P]||this.getElementSize(P),m=this.$_getGroupContentAreaInfo(e.id),g=m.contentArea,E=0,y=0,x,f,b=p(e.id),A=m.isGroupElement?p(e.id):this.$getSize(g),T=Math.max(A.width,b.width),S=Math.max(A.height,b.height),R=Object.assign({},u(e.id)),v,O=null;if(O!=null)E=O.layoutShiftX,y=O.layoutShiftY,x=O.width,f=O.height,v={x:R.x-E,y:R.y-y};else{let P=yp(o,a,!1,h,d,this.gridProfile);x=P.width,f=P.height,E=P.layoutShiftX,y=P.layoutShiftY,v={x:R.x-E,y:R.y-y}}if(x=parseInt(x,10),f=parseInt(f,10),this.$setElementSizeInUI(g,x,f),!m.isGroupElement){let P=this.viewport.getGroupElement(e.id),I=this.$getSize(P.el),C=I.width-T,_=I.height-S;if(!s&&h===!1){let w=!1;C<0&&(this.$setElementWidth(g,T-m.internalOffset.x),C=0,w=!0),_<0&&(this.$setElementHeight(g,S-m.internalOffset.y),_=0,w=!0),w&&(I=this.$getSize(P.el))}if(!s&&d===!1){let w=!1;C>0&&(this.$setElementWidth(g,T-m.internalOffset.x),C=0,w=!0),_>0&&(this.$setElementHeight(g,S-m.internalOffset.y),_=0,w=!0),w&&(I=this.$getSize(P.el))}x=I.width,f=I.height}return{position:v,size:{width:x,height:f},originalSize:{width:T,height:S},layoutShiftX:E,layoutShiftY:y}}autoSizeGroups(e,t){return e=e||this.getGroups(),this.$_sizeGroupsToFit(new Set(e),null,null,t)}du(e){let t={container:this.me,options:e.options||{},instance:this.model,dataSource:this.dataSource,adapter:this.$createDefaultLayoutAdapter()};return t.options.locationFunction||(t.options.locationFunction=n=>({x:Oe(n.data,this.$modelLeftAttribute),y:Oe(n.data,this.$modelTopAttribute)})),qe.get(e.type,t)}tu(e,t){let n=this.eu(t);n==null&&(n=this.$getManagedElement(t.id).el);let o={container:n,options:e.options||{},instance:this.model,dataSource:this.dataSource,adapter:this.$createGroupLayoutAdapter(t)};return o.options.locationFunction||(o.options.locationFunction=s=>{let a={x:Oe(s.data,this.$modelLeftAttribute),y:Oe(s.data,this.$modelTopAttribute)};return z(a.x)&&(a.x=parseInt(a.x,10)),z(a.y)&&(a.y=parseInt(a.y,10)),a}),qe.get(e.type,o)}setLayout(e,t){e&&(this.$_layout=this.du(e),t||this.refresh())}adHocLayout(e){e&&this.model.transaction(()=>{for(let n in this.$_connMap){let o=this.$_connMap[n].edge;this.model.clearEdgeGeometry(o)}this.du(e).layout(n=>{for(let o in n.positions)this.UE(o,n.positions[o])})})}$_doRenderTransientVertex(e,t,n,o,s,a,l){let h=this.$renderTransientVertex(t,n,o,s,a,l);return this.$appendVertexElement(h),this.$manage(h,e,t,n,null,!1)}$addTransientVertex(e,t,n,o,s,a){let l=this.model.$addTransientVertex(n,this),h=this.$_doRenderTransientVertex(l,e,t,n,o,s,a);return{vertex:l,el:h}}$renderDummyVertex(e){let t={x:e.data[this.$modelLeftAttribute]||0,y:e.data[this.$modelTopAttribute]||0};this.$_doRenderTransientVertex(e,t,{width:1,height:1},e.data,{},[Hi,tv].join(" "),{[ee]:e.id})}$removeTransientVertex(e){this.model.$cleanupTransientVertex(e.modelObject,this)}$addTransientEdge(e,t,n,o){return this.model.$addTransientEdge(this,e,t,n,null,o)}$isUnattachedEdgeAllowed(e){let t=this.model.getEdgeType(e.data),n=this.view.getEdgeDefinition(t);return n.allowUnattached!=null?n.allowUnattached:this.$_allowUnattachedEdges===!0}uu(e){(e.plugins||[]).forEach(n=>{this.pu(n,!0)})}addPlugin(e){return this.pu(e,!0)}pu(e,t){let n=z(e)?e:e.type,o=z(e)?{}:e.options||{},s=sr.get(n);if(s!=null)return s.initialise(this,o),this.plugins.push(s),this.pluginMap.set(n,s),t&&this.fire(Kd,s),s}getPlugin(e){return this.pluginMap.get(e)}le(e){this.plugins.forEach(t=>{try{e(t)}catch(n){U(`WARN: could not dispatch event to plugin ${t.id} [${n}]`)}})}registerDataHook(e){this.$_dataHooks.push(e)}save(e){let t={data:this.model.exportData(e),zoom:this.j};return this.$_dataHooks.forEach(n=>{n.save(t)}),t}saveToUrl(e){this.model.save(Object.assign(e,{data:this.save(e)}))}load(e,t){this.model.load({data:e.data,onload:()=>{e.zoom&&this.setZoom(e.zoom),this.$_dataHooks.forEach(n=>{n.load(e)}),t&&t()}})}$isArrayLike(e){return!z(e)&&Array.isArray(e)}};var hD=20,cD=20,Sp=class Sp extends Nn{constructor(e,t,n){super(e,t,n);this.component=t;c(this,"width");c(this,"length");c(this,"foldback");c(this,"direction");c(this,"type",Sp.type);c(this,"contentTags",[te]);n=n||{},this.width=n.width||hD,this.length=n.length||cD,this.direction=(n.direction||1)<0?-1:1,this.foldback=n.foldback||.623}draw(e,t,n){let o,s,a,l,h;if(this.location>1||this.location<0){let g=this.location<0?1:0;o=rt(e,g,this.location,!1),s=rt(e,g,this.location-this.direction*this.length/2,!1),a=zt(o,s,this.length)}else if(this.location===1){if(o={x:e.paintInfo.tx,y:e.paintInfo.ty},s=rt(e,this.location,-this.length),a=zt(o,s,this.length),this.direction===-1){let g=a;a=o,o=g}}else if(this.location===0){if(a={x:e.paintInfo.sx,y:e.paintInfo.sy},s=rt(e,this.location,this.length),o=zt(a,s,this.length),this.direction===-1){let g=a;a=o,o=g}}else o=rt(e,this.location,this.direction*this.length/2),s=Xr(e,this.location),a=zt(o,s,this.length);l=rr(o,a,this.width),h=zt(o,a,this.foldback*this.length);let{stroke:d,fill:u,lineWidth:p}=this.$getStyle(t);return{atts:[{d:isNaN(h.x)||isNaN(h.y)?"M 0 0":"M"+o.x+","+o.y+" L"+l[0].x+","+l[0].y+" L"+h.x+","+h.y+" L"+l[1].x+","+l[1].y+" Z","stroke-width":p,stroke:d,fill:u}],xmin:Math.min(o.x,l[0].x,l[1].x),xmax:Math.max(o.x,l[0].x,l[1].x),ymin:Math.min(o.y,l[0].y,l[1].y),ymax:Math.max(o.y,l[0].y,l[1].y),tail:h}}};c(Sp,"type","Arrow");var Rr=Sp;nt.register(Rr.type,Rr);var vp=class vp extends Rr{constructor(e,t,n){super(e,t,n);c(this,"type",vp.type);this.foldback=1}};c(vp,"type","PlainArrow");var Tp=vp;nt.register(Tp.type,Tp);var Pp=class Pp extends Rr{constructor(e,t,n){super(e,t,n);c(this,"type",Pp.type);this.length=this.length/2,this.foldback=2}};c(Pp,"type","Diamond");var Cp=Pp;nt.register(Cp.type,Cp);var Op=class Op extends li{constructor(e,t,n){super(t,n);this.connection=t;c(this,"create");c(this,"isSimpleShape",!1);c(this,"type",Op.type);this.create=n.create}updateFrom(e,t){}};c(Op,"type","Custom");var lh=Op;function hn(i){return i.type===lh.type}nt.register(lh.type,lh);var dD=5,Rp=class Rp extends Nn{constructor(e,t,n){super(e,t,n);this.component=t;c(this,"Ce");c(this,"$r");c(this,"type",Rp.type);c(this,"contentTags",[Xe]);n=n||{},this.Ce=n.radius||dD,this.$r=n.align||"flush"}draw(e,t,n){let{stroke:o,fill:s,lineWidth:a}=this.$getStyle(t),l,h;if(this.location===0)if(this.$r==="center")l={x:e.paintInfo.sx,y:e.paintInfo.sy},h=rt(e,this.location,this.Ce);else{let d={x:e.paintInfo.sx,y:e.paintInfo.sy},u=rt(e,this.location,this.Ce);l=zt(d,u,this.Ce),h=rt(e,this.location,2*this.Ce)}else if(this.location===1)if(this.$r==="center")l={x:e.paintInfo.tx,y:e.paintInfo.ty},h=rt(e,this.location,-this.Ce);else{let d={x:e.paintInfo.tx,y:e.paintInfo.ty},u=rt(e,this.location,-this.Ce);l=zt(d,u,this.Ce),h=rt(e,this.location,-2*this.Ce)}else l=Xr(e,this.location),h=rt(e,this.location,this.Ce);return{atts:[{cx:l.x,cy:l.y,r:this.Ce,"stroke-width":a,stroke:o,fill:s}],xmin:l.x-this.Ce,xmax:l.x+this.Ce,ymin:l.y-this.Ce,ymax:l.y+this.Ce,tail:h}}};c(Rp,"type","Dot");var _p=Rp;nt.register(_p.type,_p);var uD=10,pD=10,wp=class wp extends Nn{constructor(e,t,n){super(e,t,n);this.component=t;c(this,"width");c(this,"height");c(this,"mu");c(this,"$r");c(this,"type",wp.type);c(this,"contentTags",[te]);n=n||{},this.width=n.width||uD,this.height=n.height||pD,this.mu=n.rotate===!0,this.$r=n.align||"flush"}draw(e,t,n){let{stroke:o,fill:s,lineWidth:a}=this.$getStyle(t),l,h,d,u,p,m,g,E,y,x,f,b,A,T,S,R;if(this.mu){if(this.location===0){let v={x:e.paintInfo.sx,y:e.paintInfo.sy},O,P;this.$r==="center"?(P=rt(e,this.location,this.width/2),O=zt(P,v,this.width)):(O=v,P=rt(e,this.location,this.width)),S=rr(P,O,this.height),R=rr(O,P,this.height),m=P}else if(this.location===1){let v={x:e.paintInfo.tx,y:e.paintInfo.ty},O,P;this.$r==="center"?(P=rt(e,this.location,-this.width/2),O=zt(P,v,this.width)):(O=v,P=rt(e,this.location,-this.width)),S=rr(O,P,this.height),R=rr(P,O,this.height),m=P}else{let v=rt(e,this.location,this.width/2),O=Xr(e,this.location),P=zt(v,O,this.width);S=rr(v,P,this.height),R=rr(P,v,this.height),m=P}g=S[0].x,E=S[0].y,y=S[1].x,x=S[1].y,f=R[1].x,b=R[1].y,A=R[0].x,T=R[0].y}else{let v;this.location===0?v={x:e.paintInfo.sx,y:e.paintInfo.sy}:this.location===1?v={x:e.paintInfo.tx,y:e.paintInfo.ty}:v=Xr(e,this.location),m=v,g=v.x-this.width/2,E=v.y-this.height/2,y=g+this.width,x=E,f=y,b=E+this.height,A=g,T=E+this.height}return h=Math.min(g,y,f,A),d=Math.max(g,y,f,A),u=Math.min(E,x,b,T),p=Math.max(E,x,b,T),l=`M ${g} ${E} L ${y} ${x} L ${f} ${b} L ${A} ${T} Z`,{atts:[{"stroke-width":a,stroke:o,fill:s,d:l}],xmin:h,xmax:d,ymin:u,ymax:p,tail:m}}};c(wp,"type","Rectangle");var Lp=wp;nt.register(Lp.type,Lp);var mD=8,gD=5,Np=class Np extends Nn{constructor(e,t,n){super(e,t,n);this.component=t;c(this,"rx");c(this,"ry");c(this,"type",Np.type);c(this,"contentTags",[Kv]);n=n||{},this.rx=n.rx||mD,this.ry=n.ry||gD}draw(e,t,n){let{stroke:o,fill:s,lineWidth:a}=this.$getStyle(t),l;return this.location===0?l={x:e.paintInfo.sx,y:e.paintInfo.sy}:this.location===1?l={x:e.paintInfo.tx,y:e.paintInfo.ty}:l=Xr(e,this.location),{atts:[{cx:l.x,cy:l.y,rx:this.rx,ry:this.ry,"stroke-width":a,stroke:o,fill:s}],xmin:l.x-this.rx,xmax:l.x+this.rx,ymin:l.y-this.ry,ymax:l.y+this.ry,tail:rt(e,this.location,(this.ry+this.rx)/2)}}};c(Np,"type","Ellipse");var Dp=Np;nt.register(Dp.type,Dp);var Ip=class{constructor(r,e){this.surface=r;c(this,"Kt");c(this,"gu");e=e||{edgeMappings:[]},this.Kt=e.edgeMappings||[],this.gu=this.surface.model.edgeTypeFunction,this.jE()}computeTypes(r){let e=[this.gu(r)];for(let t=0;t<this.Kt.length;t++){let n=this.Kt[t].property,o=this.Kt[t].mappings;if(z(n)){if(r[n]!=null){let s=z(r[n])?r[n].split(" "):[r[n]];e.push(...s.filter(a=>o[a]!=null).map(a=>`${n}_${a}`))}o[yr]!=null&&r[n]!=null&&e.push(`${n}_${yr}`)}else{let s=n.map(a=>r[a]);if(s.every(a=>a!=null)){let a=s.join(" ");o[a]!=null&&e.push(`${n.join("_")}_${a.replace(/ /g,"_")}`)}}}return e.join(" ")}jE(){for(let r=0;r<this.Kt.length;r++){let e=this.Kt[r].property,t=this.Kt[r].mappings;for(let n in t)if(t.hasOwnProperty(n)){let o=z(e)?`${e}_${n}`:`${e.join("_")}_${n.replace(/ /g,"_")}`;this.surface.$registerConnectionType(o,t[n])}}this.surface.model.edgeTypeFunction=r=>this.computeTypes(r)}getPropertyMappings(){return this.Kt}};function ED(i,r,e,t,n,o,s){return new Touch({target:i,identifier:V(),pageX:r,pageY:e,screenX:t,screenY:n,clientX:o||t,clientY:s||n})}function fD(...i){let r=[];return r.push(...i),r.item=function(e){return this[e]},r}function yD(i,r,e,t,n,o,s){return fD(ED(i,r,e,t,n,o,s))}function ua(i,r,e){e=e||i.parentNode;let t=e.querySelectorAll(r);for(let n=0;n<t.length;n++)if(t[n]===i)return!0;return!1}function hh(i){return i.srcElement||i.target}function Df(i,r,e,t){if(t){let n=i.composedPath?i.composedPath():i.path;if(typeof n!="undefined"&&n.indexOf)return{path:n,end:n.indexOf(e)};{let o={path:[],end:-1},s=a=>{o.path.push(a),a===e?o.end=o.path.length-1:a.parentNode!=null&&s(a.parentNode)};return s(r),o}}else return{path:[r],end:1}}function xD(i,r){let e=0,t;for(e=0,t=i.length;e<t&&i[e][0]!==r;e++);e<i.length&&i.splice(e,1)}var bD=1,rC=!1,nC=!1;function In(){return rC||"ontouchstart"in document.documentElement||navigator.maxTouchPoints!=null&&navigator.maxTouchPoints>0}function di(){return nC||"onmousedown"in document.documentElement}function AD(i){rC=i}function SD(i){nC=i}var ci={[ue]:$A,[oe]:BA,[ie]:FA};function Nf(i,r){if(i==null)return{x:0,y:0};let e=Jo(i),t=Gf(e,0);return r(t)}function ge(i){return Nf(i,r=>({x:r.pageX,y:r.pageY}))}function TD(i){return Nf(i,r=>({x:r.screenX,y:r.screenY}))}function vD(i){return Nf(i,r=>({x:r.clientX,y:r.clientY}))}function Gf(i,r){return i.item?i.item(r):i[r]}function Jo(i){return i.touches!=null&&i.touches.length>0?i.touches:i.changedTouches&&i.changedTouches.length>0?i.changedTouches:i.targetTouches&&i.targetTouches.length>0?i.targetTouches:[i]}function aC(i){return Jo(i).length}function CD(i){if(i==null)return{x:0,y:0};if(i.pageX!==null)return{x:i.pageX,y:i.pageY};{let r=Jo(i),e=Gf(r,0);return e!=null&&e.pageX!=null?{x:e.pageX,y:e.pageY}:{x:0,y:0}}}function Mp(i,r,e,t,n){oC(i,r,e),t.qt=e.qt,i.addEventListener&&i.addEventListener(r,e,!1,n)}function ch(i,r,e){e!=null&&iC(i,t=>{PD(t,r,e),e.qt!=null&&t.removeEventListener&&(t.removeEventListener(r,e,!1),In()&&ci[r]&&t.removeEventListener(ci[r],e,!1)),e.Eu&&ch(i,e.Eu[1],e.Eu[0])})}function iC(i,r){if(i==null)return;let e=typeof i=="string"?document.querySelectorAll(i):Array.isArray(i)?i:[i];for(let t=0;t<e.length;t++)r(e[t])}function oC(i,r,e){let t=bD++;return i.Br=i.Br||{},i.Br[r]=i.Br[r]||{},i.Br[r][t]=e,e.qt=t,t}function PD(i,r,e){if(i.Br&&i.Br[r]&&delete i.Br[r][e.qt],e.Fr){for(let t=0;t<e.Fr.length;t++)ch(i,e.Fr[t][0],e.Fr[t][1]);e.Fr.length=0}e.Ja&&e.Ja()}var OD=/:not\(([^)]+)\)/;function Vp(i,r,e,t){if(i==null)return e;{let n=i.split(","),o=[],s=[];n.forEach(l=>{let h=l.match(OD);h!=null?s.push(h[1]):o.push(l)}),s.length>0&&o.length===0&&o.push(yr);let a=l=>{a.qt=e.qt;let h=hh(l),d=!1,u=h,p=Df(l,h,r,i!=null);if(p.end!=-1)for(let m=0;!d&&m<p.end;m++){u=p.path[m];for(let g=0;g<s.length;g++)if(ua(u,s[g],r))return;for(let g=0;!d&&g<o.length;g++)if(ua(u,o[g],r)){e.apply(u,[l,u]),d=!0;break}}};return _D(e,t,a),a}}function _D(i,r,e){i.Fr=i.Fr||[],i.Fr.push([r,e])}var Gp=(i,r,e,t,n)=>{if(In()&&ci[r]){let o=Vp(t,i,e,ci[r]);Mp(i,ci[r],o,e,n)}r===VA&&i.getAttribute(uf)==null&&i.setAttribute(uf,"1"),Mp(i,r,Vp(t,i,e,r),e,n)},If={[W]:{touches:1,taps:1},[Fr]:{touches:1,taps:2},[gt]:{touches:2,taps:1}};function sC(i,r,e,t){for(let n in e.Me[i])e.Me[i].hasOwnProperty(n)&&e.Me[i][n].apply(t,[r])}var Mf=class{static generate(r,e){return(t,n,o,s)=>{if(n==gt&&di())Gp(t,n,o,s);else{if(t.je==null){let a=t.je={tap:[],dbltap:[],down:!1,taps:0,downSelectors:[]},l=function(){a.down=!1},h=function(){a.taps=0},d=p=>{let m=hh(p),g=Df(p,m,t,s!=null),E=!1;for(let y=0;y<g.end;y++){if(E)return;m=g.path[y];for(let x=0;x<a.downSelectors.length;x++)if(a.downSelectors[x]==null||ua(m,a.downSelectors[x],t)){a.down=!0,setTimeout(l,r),setTimeout(h,e),E=!0;break}}},u=p=>{if(a.down){let m=hh(p),g,E;a.taps++;let y=aC(p);for(let x in If)if(If.hasOwnProperty(x)){let f=If[x];if(f.touches===y&&(f.taps===1||f.taps===a.taps))for(let b=0;b<a[x].length;b++){E=Df(p,m,t,a[x][b][1]!=null);for(let A=0;A<E.end;A++)if(g=E.path[A],a[x][b][1]==null||ua(g,a[x][b][1],t)){a[x][b][0].apply(g,[p,g]);break}}}}};t.je.downHandler=d,t.je.upHandler=u,Gp(t,ue,d),Gp(t,oe,u)}t.je.downSelectors.push(s),t.je[n].push([o,s]),o.Ja=function(){t.je!=null&&(Lt(t.je.downSelectors,a=>a===s),xD(t.je[n],o),t.je.downSelectors.length===0&&(ch(t,ue,t.je.downHandler),ch(t,oe,t.je.upHandler),delete t.je))}}}}},Vf=class{static generate(){let r=[];return(e,t,n,o)=>{if(!e.Me){e.Me={over:!1,mouseenter:[],mouseexit:[]};let s=l=>{let h=hh(l);(o==null&&h==e&&!e.Me.over||ua(h,o,e)&&(h.Me==null||!h.Me.over))&&(sC(vE,l,e,h),h.Me=h.Me||{},h.Me.over=!0,r.push(h))},a=l=>{let h=hh(l);for(let d=0;d<r.length;d++)h==r[d]&&!ua(l.relatedTarget||l.toElement,"*",h)&&(h.Me.over=!1,r.splice(d,1),sC(CE,l,e,h))};Mp(e,tt,Vp(o,e,s,tt),s),Mp(e,et,Vp(o,e,a,et),a)}n.Ja=function(){delete e.Me[t][n.qt]},oC(e,t,n),e.Me[t][n.qt]=n}}},ye=class{constructor(r){c(this,"clickThreshold");c(this,"dblClickThreshold");c(this,"tapHandler");c(this,"mouseEnterExitHandler");r=r||{},this.clickThreshold=r.clickThreshold||250,this.dblClickThreshold=r.dblClickThreshold||450,this.mouseEnterExitHandler=Vf.generate(),this.tapHandler=Mf.generate(this.clickThreshold,this.dblClickThreshold)}kE(r,e,t,n,o){if(t==null)return;let s=r;e===W||e===Fr||e===gt?this.tapHandler(s,e,t,n,o):e===vE||e==CE?this.mouseEnterExitHandler(s,e,t,n,o):Gp(s,e,t,n,o)}on(r,e,t,n,o){let s=n==null?null:t,a=n==null?t:n;return this.kE(r,e,a,s,o),this}off(r,e,t){return ch(r,e,t),this}trigger(r,e,t,n,o){let s=di()&&(typeof MouseEvent=="undefined"||t==null||t.constructor===MouseEvent),a=In()&&!di()&&ci[e]?ci[e]:e,l=!(In()&&!di()&&ci[e]),h=ge(t),d=TD(t),u=vD(t);return iC(r,p=>{let m;t=t||{screenX:d.x,screenY:d.y,clientX:u.x,clientY:u.y};let g=f=>{n&&(f.payload=n)},E={TouchEvent:f=>{let b=yD(p,h.x,h.y,d.x,d.y,u.x,u.y);(f.initTouchEvent||f.initEvent)(a,!0,!0,window,null,d.x,d.y,u.x,u.y,!1,!1,!1,!1,b,b,b,1,0)},MouseEvents:f=>{f.initMouseEvent(a,!0,!0,window,o==null?1:o,d.x,d.y,u.x,u.y,t.ctrlKey===!0,t.altKey===!0,t.shiftKey===!0,t.metaKey===!0,1,p)}},y=!l&&!s&&In()&&ci[e],x=y?"TouchEvent":"MouseEvents";m=document.createEvent(x),E[x](m),g(m),p.dispatchEvent(m)}),this}};var RD=["stroke-linejoin","stroke-dashoffset","stroke-linecap"];function ce(i,r){for(let e in r){let t=r[e];if(e==="style"&&typeof t=="object"){let n=Object.entries(t);for(let o=0;o<n.length;o++){let s=n[o];i.style[s[0]]=s[1]}}else i.setAttribute(e,""+r[e])}}function $(i,r,e,t){return r=r||{},ma(Zt,i,e,t,r)}function lC(i,r){let e=r.map(t=>$("stop",{offset:`${t[0]}%`,"stop-color":t[1]}));i.replaceChildren(...e)}function LD(i,r){i.gradient==null&&(i.gradient=$("linearGradient",{id:tE(),gradientUnits:"userSpaceOnUse"}),i.canvas.insertBefore(i.gradient,i.canvas.childNodes[0])),i.gradient.setAttribute("x1",`${i.x}`),i.gradient.setAttribute("x2",`${i.x+i.width}`),lC(i.gradient,r)}function hC(i,r,e){let t=tE(),n=$("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:i,x2:r});return lC(n,e),{id:t,g:n}}function $f(i,r,e,t){r.setAttribute(Wv,e.fill?e.fill:ht),!t&&e.gradient?(LD(i,e.gradient),r.setAttribute(Rf,`url(#${i.gradient.id})`)):r.setAttribute(Rf,e.stroke?e.stroke:ht),e.strokeWidth&&r.setAttribute(Zv,e.strokeWidth),e.dashArray?r.setAttribute(wf,e.dashArray):r.removeAttribute(wf),RD.forEach(n=>{e[n]&&r.setAttribute(n,e[n])})}function pa(i,r,e){e>=0?i.insertBefore(r,i.childNodes[e]):i.appendChild(r)}function wD(i,r,e){let t=[];return i!=null&&i.split(/\n/).forEach(o=>{t.push(...DD(o,r,e))}),t}function DD(i,r,e){let t=(i||"").split(/\s/),n=[];if(t.length===0)return[];if(t.length===1)return[i];let o=[t[0]],s=1,a=0,l=!1,h=$(Lf);for(e.appendChild(h);!l;){let d=t.slice(a,s+1),u=d.join(" ");h.innerHTML=u,h.getBBox().width<r||o.length===0?(o=d.slice(),s+=1,s>=t.length&&(l=!0)):(n.push(o),a=s,o=[t[a]],s=a+1,s>=t.length&&(l=!0))}return e.removeChild(h),n.push(o),n.map(d=>d.join(" "))}function ND(i,r,e){return wD(i,r,e).map(t=>{let n=$(Lf);return n.innerHTML=t,n})}function $p(i,r,e){let n=i.getAttribute(Q)||"50%",o=ND(r,e,i);i.innerHTML="";let s=0;return o.forEach((a,l)=>{i.appendChild(a),a.setAttribute("dominant-baseline","hanging"),a.setAttribute(Q,n),a.setAttribute("dy",s==0?"0":`${s+3}`),s=a.getBBox().height}),o.length>0&&o[0].setAttribute("dy",`${-i.getBBox().height/2}`),i}var Bf="data-vjs-container",Ff="data-vjs-group-content",Bp="data-vjs-expanded-content",Fp="data-vjs-collapsed-content",xr="data-vjs-enabled",dh="data-vjs-scope",uh="data-vjs-is-group",jme="endpoint",Hme="element",kme="connection",He="div",Uf="position",Zr=X(aa),Wme=be(WT),cC=be(Ff),Mn=X(la),dC=X(Ju);function Bt(i,r,e){e=e||i.parentNode;let t=e.querySelectorAll(r);for(let n=0;n<t.length;n++)if(t[n]===i)return!0;return!1}function ae(i,r){i.stopPropagation?i.stopPropagation():i.returnValue=!1,!r&&i.preventDefault&&i.preventDefault()}function Jt(i,r,e,t){if(t&&Bt(i,r,e))return i;for(i=i.parentNode;i!=null&&i!==e;){if(Bt(i,r))return i;i=i.parentNode}}function cge(i,r,e){e=e||document.body;let t=[],n=Jt(i,r,e,!1);for(;n!=null;)t.push(n),n=Jt(n,r,e,!1);return t}function Ko(i){return i.srcElement||i.target}function uC(i,r){r=bt(r),typeof i.className.baseVal!="undefined"?i.className.baseVal=r:i.className=r}function Up(i){return i.className!=null?typeof i.className.baseVal=="undefined"?i.className:i.className.baseVal:""}function pC(i,r,e){let t=r==null?[]:Array.isArray(r)?r:r.split(/\s+/),n=e==null?[]:Array.isArray(e)?e:e.split(/\s+/),o=Up(i),s=o.split(/\s+/),a=(l,h)=>{for(let d=0;d<h.length;d++)if(l)s.indexOf(h[d])===-1&&s.push(h[d]);else{let u=s.indexOf(h[d]);u!==-1&&s.splice(u,1)}};a(!0,t),a(!1,n),uC(i,s.join(" "))}function Vn(i){return!z(i)&&!Array.isArray(i)&&i.length!=null&&i.documentElement==null&&i.nodeType==null}function dge(i){return!z(i)&&(Array.isArray(i)||Vn(i))}function gC(i){return!z(i)&&(Array.isArray(i)||Vn(i))}function EC(i){return Up(i)}function L(i,r){let e=(t,n)=>{t!=null&&n!=null&&n.length>0&&(t.classList?bt(n).split(/\s+/).forEach(s=>{t.classList.add(s)}):pC(t,n))};Vn(i)?i.forEach(t=>e(t,r)):e(i,r)}function cn(i,r){return i.classList?i.classList.contains(r):Up(i).indexOf(r)!==-1}function F(i,r){let e=(t,n)=>{t!=null&&n!=null&&n.length>0&&(t.classList?bt(n).split(/\s+/).forEach(s=>{t.classList.remove(s)}):pC(t,null,n))};Vn(i)?i.forEach(t=>e(t,r)):e(i,r)}function Yf(i,r){let e=(t,n)=>{t!=null&&n!=null&&n.length>0&&(t.classList?t.classList.toggle(n):cn(t,n)?F(t,n):L(t,n))};Vn(i)?i.forEach(t=>e(t,r)):e(i,r)}function Ft(i,r=[],e=[]){let n=Up(i).split(" ").filter(o=>e.indexOf(o)===-1&&r.indexOf(o)===-1);n.push(...r),uC(i,n.join(" "))}function fC(i,r){let e=null;if(arguments.length===1){if(!z(i)){let t=document.createDocumentFragment();return t.appendChild(i),Array.from(t.childNodes)}e=Array.from(document.querySelectorAll(i))}else e=Array.from(i.querySelectorAll(r));return e}function Jr(i,r,e,t){return ma(null,i,r,e,t)}function ma(i,r,e,t,n){let o=i==null?document.createElement(r):document.createElementNS(i,r);return e=e||{},Object.assign(o.style,e),t&&L(o,t),ce(o,n||{}),o}function Kr(i,r,e,t,n,o,s){let a=ma(i,r||He,e,t,n);return o!=null&&(s?o.insertBefore(a,o.lastChild):o.appendChild(a)),a}function Ki(i,r){let e=i.getBoundingClientRect(),t=document.body,n=document.documentElement,o=window.pageYOffset||n.scrollTop||t.scrollTop,s=window.pageXOffset||n.scrollLeft||t.scrollLeft,a=n.clientTop||t.clientTop||0,l=n.clientLeft||t.clientLeft||0,h=e.top+o-a,d=e.left+s-l;return{x:r?d:Math.round(d),y:r?h:Math.round(h)}}function Yp(i){return i==null?"HTML":i instanceof SVGElement?"SVG":"HTML"}function Ot(i){return Yp(i)==="SVG"}function qi(i){return i.nodeType!=null&&i.nodeType!==3&&i.nodeType!==8}var mC=class i{static setNodeText(r,e){r.text=e;try{r.textContent=e}catch(t){}}static getNodeText(r){return r!=null?r.text||r.textContent:""}static getChild(r,e){let t=null;for(let n=0;n<r.childNodes.length;n++)if(r.childNodes[n].nodeType===1&&r.childNodes[n].nodeName===e){t=r.childNodes[n];break}return t}static getChildren(r,e){let t=[];for(let n=0;n<r.childNodes.length;n++)r.childNodes[n].nodeType===1&&r.childNodes[n].nodeName===e&&t.push(r.childNodes[n]);return t}static xmlToString(r){try{return new XMLSerializer().serializeToString(r).replace(/\s*xmlns=\"http\:\/\/www.w3.org\/1999\/xhtml\"/g,"")}catch(e){try{return r.xml}catch(t){throw new Error("Cannot serialize XML "+t)}}}static createElement(r,e,t){let n;if(n=document.createElement(r),t&&i.setNodeText(n,t),e)for(let o in e)n.setAttribute(o,e[o]);return n}};function ga(i,r){r=r||150;let e=null;return()=>{window.clearTimeout(e),e=window.setTimeout(i,r)}}function Ea(i){let r=new XMLHttpRequest,e=i.type||"GET";if(r){let t=i.dataType===Xt?o=>JSON.parse(o):o=>o;r.open(e,i.url,!0);let n=i.headers||{};for(let o in n)r.setRequestHeader(o,n[o]);r.onreadystatechange=()=>{r.readyState===4&&((""+r.status)[0]==="2"?i.success(t(r.responseText)):i.error&&i.error(r.responseText,r.status))},r.send(i.data?JSON.stringify(i.data):null)}else i.error&&i.error("ajax not supported")}function zp(i,r,e){let t=r.getBoundingClientRect(),n=ge(i);return{x:t.width===0?0:(n.x-t.x)/t.width,y:t.height===0?0:(n.y-t.y)/t.height}}function yC(i){return i==null?!1:Object.prototype.toString.call(i).match(/\[object .*Element]/)!=null}function uge(i){return i==null?!1:Object.prototype.toString.call(i)==="[object Text]"}function qr(i,r){return"["+i+"='"+r+"']"}function pge(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}function mge(i){window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",r=>{i(r.matches)})}function X(...i){return i.map(r=>"."+r).join(",")}function gge(...i){return i.join(" ")}function be(...i){return i.map(r=>"["+r+"]").join(",")}var ph=be(Pt);function fa(i,r,e){return function(t){return t[i]/r*(e?-1:1)}}var xC="deltaY",bC="deltaX",ID="wheelDeltaY",MD="wheelDeltaX",Xp="webkit",ya="mac",mh="win",zf="ie",Xf="safari",jf="firefox",Hf="default";function AC(i){return i.deltaY*(i.deltaMode===1?25:1)/120}function SC(i){return i.deltaX*(i.deltaMode===1?25:1)/120}var kf={[Xp]:{[ya]:fa(xC,120),[mh]:fa(xC,100)},[Xf]:fa(ID,120,!0),[jf]:{[ya]:AC,[mh]:AC},[zf]:function(i){return i.wheelDelta/120},[Hf]:function(i){return i.deltaY||i.wheelDelta}},Wf={[Xp]:{[ya]:fa(bC,120),[mh]:fa(bC,100)},[Xf]:fa(MD,120,!0),[jf]:{[ya]:SC,[mh]:SC},[zf]:function(i){return i.wheelDelta/120},[Hf]:function(i){return i.deltaX||i.wheelDelta}},TC=typeof navigator!="undefined",vC=TC?/Mac/.test(navigator.userAgent)?ya:mh:ya,xa=TC?navigator.userAgent.indexOf("Firefox")!==-1?jf:/Chrome/.test(navigator.userAgent)?Xp:/Safari/.test(navigator.userAgent)?Xf:/WebKit/.test(navigator.userAgent)?Xp:/Trident/.test(navigator.userAgent)?zf:"default":Hf,VD=typeof kf[xa]=="function"?kf[xa]:kf[xa][vC],GD=typeof Wf[xa]=="function"?Wf[xa]:Wf[xa][vC],$D=function(i){return VD(i||event)},BD=function(i){return GD(i||event)},FD=function(i,r,e){let t=n=>{let o=$D(n),s=BD(n);n.normalizedWheelDelta=o,(!e||n.metaKey||n.ctrlKey)&&i(n,s,o,n.metaKey||n.ctrlKey)};return i.HE=t,t},UD=typeof document!="undefined",CC=UD?"onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll":"wheel";function gh(i,r,e,t){let n=FD(r,e,t);return i.addEventListener?i.addEventListener(CC,n,!1):i.attachEvent&&i.attachEvent("onmousewheel",n),n}function Eh(i,r){let e=r.HE;e!=null&&(i.removeEventListener?i.removeEventListener(CC,e,!1):i.detachEvent&&i.detachEvent("onmousewheel",e))}function PC(i){return i.startEditingPath!=null&&i.stopEditingPath!=null}var OC="vjs-paper",_C="vjs-paper-canvas",RC=20,oEe="vjs-paper-node",fh="start",qo="center",yh="end";function LC(i){return kr(i)&&i.useHTMLElement===!0}var xh=class{constructor(r,e){this.instance=r;this.overlay=e;c(this,"htmlElementOverlay");this.htmlElementOverlay=e}static getElement(r,e,t,n){if(e.contentElement==null){if(n&&t){e.contentElement=n(t);let s=r.overlayClass+" "+(e.cssClass?e.cssClass:"");L(e.contentElement,s)}else e.contentElement=Jr(He,{},r.overlayClass+" "+(e.cssClass?e.cssClass:""));t&&t.edge&&e.contentElement.setAttribute(Ze,t.edge.id),e.contentElement.setAttribute(Zu,e.id);for(let s in e.attributes)e.contentElement.setAttribute(s,e.attributes[s]);e.contentElement.style.position=je,r.$appendOverlayElement(e.contentElement);let o="translate(-50%, -50%)";e.contentElement.style.webkitTransform=o,e.contentElement.style.mozTransform=o,e.contentElement.style.msTransform=o,e.contentElement.style.oTransform=o,e.contentElement.style.transform=o,e.visible||L(e.contentElement,Ql),e.contentElement.jtk={overlay:e}}return e.contentElement}static destroy(r){r.contentElement&&r.contentElement.parentNode&&r.contentElement.parentNode.removeChild(r.contentElement),delete r.contentElement}};function Zf(i,r,e){if(r.contentElements==null){r.contentElements=[];let t=Object.assign({[Zu]:r.id},r.attributes);e.forEach(n=>{let o=$(n,t),s=i.overlayClass+" "+(r.cssClass?r.cssClass:"");L(o,s),o.jtk={overlay:r},r.contentElements.push(o)})}return r.contentElements.forEach(t=>{var o;let n=t.parentNode;if(n==null){let s=(o=r.component)==null?void 0:o.connector;n=s!=null?s.canvas:null,n!=null&&pa(n,t,-1)}}),r.contentElements}function wC(i,r,e,t){let n=r;Zf(i,n,r.contentTags);let o=[-t.x,-t.y],s=Object.assign({transform:"translate("+o[0]+","+o[1]+")","pointer-events":"visibleStroke"},e.paintStyle);n.contentElements.forEach((a,l)=>{let h=e.atts[l],d=Object.assign(s,h);ce(a,d)})}function bh(i,r){return Zf(i,r,r.contentTags)}function Qo(i,r){return Zf(i,r,[q]),r.bgElement==null&&(r.bgElement=$(Z),r.contentElements[0].appendChild(r.bgElement)),r.textElement==null&&(r.textElement=$(Je),r.contentElements[0].appendChild(r.textElement)),r.contentElements}function DC(i,r,e,t){Qo(i,r);let n=vr(r.label)?r.label(r):r.label,o=[-t.x,-t.y],s={x:e.d.loc.x,y:e.d.loc.y,"text-anchor":"middle","dominant-baseline":"middle","pointer-events":"visibleStroke",transform:"translate("+o[0]+","+o[1]+")"};r.font&&r.font.size&&(s["font-size"]=r.font.size),r.font&&r.font.style&&(s["font-style"]=r.font.style),r.font&&r.font.family&&(s["font-family"]=r.font.family),ce(r.textElement,s),r.textElement.textContent=n;let a=r.textElement.getBBox(),l=i.currentZoom,h=a.width/l,d=a.height/l,u=5,p={transform:"translate("+o[0]+","+o[1]+")",x:s.x-u-h/2,y:s.y-u-d/2,width:h+2*u,height:d+2*u,fill:n==null||n.length===0?"none":"white"};ce(r.bgElement,p)}function Jf(i,r){i.contentElements!=null&&i.contentElements.forEach(e=>{e!=null&&e.parentNode!=null&&e.parentNode.removeChild(e)}),i.backgroundContentElements!=null&&i.backgroundContentElements.forEach(e=>{e!=null&&e.parentNode!=null&&e.parentNode.removeChild(e)}),delete i.contentElements,delete i.backgroundContentElements}var jp=class extends li{constructor(){super(...arguments);c(this,"contentElements");c(this,"backgroundContentElements")}};var ui="transform",Kf=/translate\(([-0-9\.]+),\s*([-0-9\.]+)\)/,NC=/rotate\(([-0-9\.]+)\)/;function it(i){let r=i;return r.width&&r.width.baseVal?HD(r):r.getBBox?kD(r):YD(i)}function un(i,r){let e=i;return Ot(i.parentElement)?Ah(e,r):e.x&&e.x.baseVal?XD(e):zD(e)}function Ce(i,r){let e=i;Ot(i.parentElement)?dn(e,r):(e.x&&e.x.baseVal&&jD(e,r),Kt(e,r))}function IC(i,r,e,t,n){let o=i;if(o instanceof HTMLElement)o.style[e]=`${r}px`;else if(o[t]&&o[t].baseVal)o.setAttribute(t,r);else if(o.localName===q){let s=Ah(o);s[n]=r,dn(o,s)}}function $C(i,r){IC(i,r,ze,Q,Q)}function BC(i,r){IC(i,r,Se,fe,fe)}function Lr(i,r,e){let t=i;t instanceof HTMLElement?MC(i,r,e):t.width&&t.width.baseVal&&(MC(i,r,e),i.setAttribute(Te,`${r}`),i.setAttribute(De,`${e}`))}function FC(i,r){let e=i;e instanceof HTMLElement?VC(i,r):e.width&&e.width.baseVal&&(VC(i,r),i.setAttribute(Te,`${r}`))}function UC(i,r){let e=i;e instanceof HTMLElement?GC(i,r):e.height&&e.height.baseVal&&(GC(i,r),i.setAttribute(De,`${r}`))}function YD(i){return{width:i.offsetWidth,height:i.offsetHeight}}function zD(i){return{x:parseFloat(i.offsetLeft),y:parseFloat(i.offsetTop)}}function jEe(i){return{x:parseInt(i.style.left,10),y:parseInt(i.style.top,10)}}function Kt(i,r){i.style.left=r.x+"px",i.style.top=r.y+"px"}function MC(i,r,e){i.style.width=`${r}px`,i.style.height=`${e}px`}function VC(i,r){i.style.width=`${r}px`}function GC(i,r){i.style.height=`${r}px`}function XD(i){try{return{x:parseFloat(i.x.baseVal.value),y:parseFloat(i.y.baseVal.value)}}catch(r){return{x:0,y:0}}}function jD(i,r){i.setAttribute("x",`${r.x}`),i.setAttribute("y",`${r.y}`)}function HD(i){try{return{width:parseFloat(i.width.baseVal.value),height:parseFloat(i.height.baseVal.value)}}catch(r){return{width:0,height:0}}}function kD(i){try{let r=i.getBBox();return{width:r.width,height:r.height}}catch(r){return{width:0,height:0}}}function Ah(i,r){let e,t,n,o,s;if(e=i.getAttribute(ui),e!=null){if(t=e.match(Kf),o=parseFloat(t[1]),s=parseFloat(t[2]),n=e.match(NC),n!=null){let a=parseFloat(n[1]),l=r||i.getBBox(),h={x:o+l.width/2,y:s+l.height/2},d=xt(h,{x:o,y:s},a),u=xt({x:o,y:s},d,-a);o=u.x,s=u.y}return{x:o,y:s}}else if(e=i.style.transform,e!=null){t=e.match(Kf);try{return{x:parseFloat(t[1]),y:parseFloat(t[2])}}catch(a){return{x:0,y:0}}}return{x:0,y:0}}function es(i,r){if(Ot(i.parentElement)){let t=(i.getAttribute(ui)||"").match(Kf);i.setAttribute(ui,(t==null?"":`${t[0]} `)+`rotate(${r})`)}else i.style.transform=r==0?"":"rotate("+r+"deg)",i.style.transformOrigin="center center"}function dn(i,r){let t=(i.getAttribute(ui)||"").match(NC);i.setAttribute(ui,`translate(${r.x.toFixed(2)}, ${r.y.toFixed(2)})`+(t==null?"":` ${t[0]}`))}var Hp=class{static paint(r,e,t){if(t!=null){let n=[r.width,r.height];if(isFinite(n[0])&&isFinite(n[1])){let o={[Te]:""+(n[0]||0),[De]:""+(n[1]||0)};ce(r.canvas,o),Ce(r.canvas,r)}}}};var qf="vjs-surface",YC="vjs-surface-direct-render",zC="vjs-surface-touch-device",XC="vjs-surface-pointer-device",Qf="vjs-surface-nopan",ey="vjs-surface-canvas",ty="vjs-surface-pan",nfe="vjs-surface-pan-left",ife="vjs-surface-pan-top",ofe="vjs-surface-pan-right",sfe="vjs-surface-pan-bottom",ry="vjs-surface-pan-active",ny="vjs-surface-flash",jC="vjs-flash-vertex",iy="vjs-surface-panning",oy="vjs-surface-element-dragging",Sh="vjs-element-dragging",sy="vjs-group-child-element-dragging",Th="vjs-most-recently-dragged",Gn="vjs-surface-edge-dragging",ay="vjs-edge-relocating",kp="vjs-edge-will-relocate",HC="vjs-lasso",vh="vjs-lasso-mask",kC="vjs-lasso-mask-left",WC="vjs-lasso-mask-top",ZC="vjs-lasso-mask-right",JC="vjs-lasso-mask-bottom",Wp="vjs-miniview",KC="vjs-miniview-canvas",qC="vjs-miniview-panner",QC="vjs-miniview-element",eP="vjs-miniview-group-element",ly="vjs-miniview-panning",tP="vjs-miniview-collapse",Zp="vjs-miniview-collapsed",rP="vjs-miniview-click-to-center",ct="vjs-drag-select-defeat",hy="vjs-default-node",cy="vjs-default-group",Qi="vjs-connector-source-drag",eo="vjs-connector-target-drag",nP="vjs-connector-transient-drag",ts="vjs-palette-selected-element",Ch="vjs-palette-tap-mode-active",iP="vjs-palette-current",Jp="vjs-palette-current-shape-type",rs="vjs-drag-hover-cannot-drop",dy="vjs-drag-original-group",qt="vjs-drag-active",Qt="vjs-drag-hover",uy="vjs-source-hover",py="vjs-target-hover",Ph="vjs-hover";function WD(i,r){if(r.outlineStroke!=null){let e=r.outlineWidth||1,t=r.strokeWidth+2*e,n=Object.assign({},r);return n.stroke=r.outlineStroke,n.strokeWidth=t,n}else if(i.$paintConnectorOutline){let e=i.$connectorOutlineWidth,t=Object.assign({},r);return t.stroke=i.$connectorOutlineColor||"transparent",t.strokeWidth=e,t}}function oP(i,r,e){JD(i,r);let t=r.connector;Hp.paint(t,i,e);let n="",o={x:-t.x,y:-t.y};if(t.internalSegments.length>0){n=bT(t);let s={d:n,transform:"translate("+o.x+","+o.y+")","pointer-events":"visibleStroke",[Ze]:r.edge.id},a=WD(i,e);a!=null&&(t.bgPath==null?(t.bgPath=$(te,s),L(t.bgPath,i.connectorOutlineClass),pa(t.canvas,t.bgPath,0)):ce(t.bgPath,s),$f(t,t.bgPath,a,!0)),t.path==null?(t.path=$(te,s),pa(t.canvas,t.path,a!=null?1:0),L(t.path,i.connectorPathClass),r.edge.transient&&L(t.canvas,qT)):(t.path.parentNode!==t.canvas&&pa(t.canvas,t.path,a!=null?1:0),ce(t.path,s)),$f(t,t.path,e,!1),r.detachable&&ZD(r,o,i.defaults.edgeRelocateHandleSize)}}function ZD(i,r,e){if(i.detachable){let t=i.connector,n=t.internalSegments[0].x1,o=t.internalSegments[0].y1,s={width:e,height:e,transform:`translate(${r.x-e/2},${r.y-e/2})`,"pointer-events":"fill",cursor:"move"},a=Object.assign(s,{x:n,y:o});t.sourceZone==null?(t.sourceZone=$(Z,a),L(t.sourceZone,Qi),t.canvas.appendChild(t.sourceZone)):ce(t.sourceZone,a);let l=t.internalSegments[t.internalSegments.length-1].x2,h=t.internalSegments[t.internalSegments.length-1].y2,d=Object.assign(s,{x:l,y:h});t.targetZone==null?(t.targetZone=$(Z,d),L(t.targetZone,eo),t.canvas.appendChild(t.targetZone)):ce(t.targetZone,d)}}function JD(i,r){let e=r.connector;if(e.canvas!=null)return e.canvas;{let t=i.containerType==="HTML"?$(ve,{[Te]:"0",[De]:"0",style:{"pointer-events":ht,position:je},[Ze]:r.edge.id}):$(q,{[Ze]:r.edge.id});return e.canvas=t,i.$appendEdgeElement(e.canvas),e.cssClass!=null&&L(t,e.cssClass),L(t,i.connectorClass),e.classesToAddWhenRendered!=null&&(L(t,e.classesToAddWhenRendered.join(" ")),delete e.classesToAddWhenRendered),t.jtk=t.jtk||{},t.jtk.connection=r,t}}var Kp=class{constructor(r,e){this.container=r;c(this,"Qt",!0);c(this,"ge");c(this,"Ka");c(this,"Pi");c(this,"qa");c(this,"ke");c(this,"fu");c(this,"rt");c(this,"er");c(this,"rr",{});c(this,"Sn",[]);c(this,"H");c(this,"Ur");c(this,"_i");c(this,"Ri");c(this,"Li");c(this,"Qa");e=e||{init:null},this.ge=new ye,this.Ka=this.WE.bind(this),this.ge.on(r,ue,"*",this.Ka),this.Pi=this.ZE.bind(this),this.qa=this.JE.bind(this),this.Li=e.translate||(t=>Object.assign({},t)),this.Qa=e.init}$enable(){this.Qt=!0}$disable(){this.Qt=!1}addHandler(r){let e=this.rr[r.selector];e==null&&(this.rr[r.selector]=[],e=this.rr[r.selector],this.Sn.push(r.selector)),e.push(r),e.sort((t,n)=>{let o=t.priority==null?0:t.priority,s=n.priority==null?0:n.priority;return o>s?-1:s>o?1:0})}removeHandler(r){let e=this.rr[r.selector];e!=null&&(this.rr[r.selector]=e.filter(t=>t!==r),this.rr[r.selector].length===0&&(delete this.rr[r.selector],this.Sn=this.Sn.filter(t=>t!==r.selector)))}WE(r){if(!this.Qt||r.KE===!0)return;let e=!1;this.rt=r.target;let t=()=>{e||(e=!0,this.Qa&&this.Qa(r),this.er=it(this.rt),this.ke=null,this.H=ge(r),this._i=this.Li(this.H),this.Ur=Object.assign({},this.H),this.Ri=Object.assign({},this._i))};for(let n=0;n<this.Sn.length;n++)if(Bt(this.rt,this.Sn[n],this.container)){let o=this.rr[this.Sn[n]];if(o!=null){t();for(let s=0;s<o.length;s++){let a=this.rt,l=this.er;if(o[s].target){if(a=this.rt.closest(o[s].target),a==null)continue;l=it(a)}if(this.fu=o[s].start({pagePosition:this.H,e:r,el:a,size:l,translatedPosition:this._i}),this.fu!==!1){this.rt=a,this.er=l,this.ke=o[s],ae(r),r.KE=!0;break}}}}this.ke!=null&&(this.ge.on(document,ie,this.Pi),this.ge.on(document,oe,this.qa))}ZE(r){if(!this.Qt)return;let e=ge(r),t=this.Li(e);this.ke!=null&&(this.ke.constrainFunction&&(this.ke.usesPageCoordinates?(e=this.ke.constrainFunction(e,this.rt,{width:0,height:0},this.er,this.Ur,r),t=this.Li(e)):t=this.ke.constrainFunction(t,this.rt,{width:0,height:0},this.er,this.Ri,r)),this.ke.drag({e:r,el:this.rt,pagePosition:e,size:this.er,originalPagePosition:this.H,translatedPosition:t,originalTranslatedPosition:this._i}),this.Ur=e,this.Ri={x:t.x,y:t.y})}JE(r){this.Ur=ge(r),this.Ri=this.Li(this.Ur),this.ke!=null&&this.ke.stop({e:r,el:this.rt,pagePosition:this.Ur,size:this.er,originalPagePosition:this.H,translatedPosition:this.Ri,originalTranslatedPosition:this._i}),this.ie()}ie(){this.ge.off(document,ie,this.Pi),this.ge.off(document,oe,this.qa),this.ke=null,this.rt=null,this.er=null,this.H=null,this.Ur=null}destroy(){this.ge.off(this.container,ue,this.Ka),this.ie()}};var qp={FILL:"#FFFFFF",STROKE:"#000000",TEXT_COLOR:"#000000",STROKE_WIDTH:1.25},Oh="start",_h="center",Rh="end",kfe="Default",Wfe="Default shapes",sP="vjs-shape",Qp="vjs-shape-label",Lh="vjs-shape";var KD="http://www.w3.org/2000/svg",qD="http://www.w3.org/1999/xlink",QD="svg",eN="xlink",tN="html";function my(i){let r=document.getElementById(i);return r!=null?r.innerHTML:null}var ns=class extends Vo{constructor(r){super(r),this.namespaceHandlers[QD]=e=>document.createElementNS(KD,e.split(":")[1]),this.namespaceHandlers[tN]=e=>document.createElement(e.split(":")[1]),this.namespaces[eN]=qD}ce(r){return document.createElement(r)}cf(){return document.createDocumentFragment()}ctn(r){return document.createTextNode(r)}cc(r){return document.createComment(r)}Nd(){return my}removeElement(r){r.parentElement.removeChild(r)}removeTextNode(r){r.parentNode.removeChild(r)}};function br(i){return new ns(i||{})}var em="link",tm="clone",rm="trash",aP="cross",lP="plus",hP="circle",cP="gear",dP={x:0,y:0,width:32,height:32},wh={[tm]:{id:tm,viewBox:dP,shapes:[{tag:te,atts:{d:"M 6 24 L 2 24 L 2 2 L 24 2 L 24 6 M 8 8 L 30 8 L 30 30 L 8 30 Z",stroke:"currentColor","stroke-width":3,fill:"none","stroke-linejoin":"round"}}]},[em]:{id:em,viewBox:dP,shapes:[{tag:Z,atts:{x:0,y:0,width:32,height:32,fill:"transparent",stroke:"none"}},{tag:Xe,atts:{cx:5,cy:16,r:5,fill:"currentColor"}},{tag:te,atts:{d:"M 5 16 L 22 16",stroke:"currentColor","stroke-width":3,fill:"none"}},{tag:te,atts:{d:"M 22 16 L 20 8 L 30 16 L 20 24",fill:"currentColor"}}]},[rm]:{id:rm,viewBox:{x:0,y:0,width:32,height:32},atts:{fill:"none",stroke:"currentColor","stroke-linejoin":"round","stroke-width":"2"},shapes:[{tag:te,atts:{d:"M 7 30 L 4 2 L 28 2 L 25 30 Z","stroke-width":"3"}},{tag:te,atts:{d:"M 12 26 L 10 8"}},{tag:te,atts:{d:"M 20 26 L 22 8"}},{tag:te,atts:{d:"M 16 26 L 16 8.5"}}]},[aP]:{id:aP,viewBox:{x:0,y:0,width:32,height:32},atts:{fill:"none",stroke:"currentColor","stroke-width":3,"stroke-linecap":"round"},shapes:[{tag:te,atts:{d:"M 2 2 L 30 30"}},{tag:te,atts:{d:"M 30 2 L 2 30"}}]},[lP]:{id:lP,viewBox:{x:0,y:0,width:32,height:32},atts:{fill:"none",stroke:"currentColor","stroke-width":3,"stroke-linecap":"round"},shapes:[{tag:te,atts:{d:"M 16 2 L 16 30"}},{tag:te,atts:{d:"M 2 16 L 30 16"}}]},[hP]:{id:hP,viewBox:{x:0,y:0,width:32,height:32},atts:{fill:"none",stroke:"currentColor","stroke-width":3,"stroke-linecap":"round"},shapes:[{tag:Xe,atts:{cx:16,cy:16,r:15}}]},[cP]:{id:cP,viewBox:{x:0,y:0,width:32,height:32},atts:{},shapes:[{tag:te,atts:{"fill-rule":"evenodd",d:"M 16.0000,4.5000 L 18.1126,3.3755 L 18.6424,1.7428 L 20.8402,2.3317 L 20.4827,4.0106 L 21.7500,6.0407 L 24.1418,6.1232 L 25.4170,4.9741 L 27.0259,6.5830 L 25.8768,7.8582 L 25.9593,10.2500 L 27.9894,11.5173 L 29.6683,11.1598 L 30.2572,13.3576 L 28.6245,13.8874 L 27.5000,16.0000 L 28.6245,18.1126 L 30.2572,18.6424 L 29.6683,20.8402 L 27.9894,20.4827 L 25.9593,21.7500 L 25.8768,24.1418 L 27.0259,25.4170 L 25.4170,27.0259 L 24.1418,25.8768 L 21.7500,25.9593 L 20.4827,27.9894 L 20.8402,29.6683 L 18.6424,30.2572 L 18.1126,28.6245 L 16.0000,27.5000 L 13.8874,28.6245 L 13.3576,30.2572 L 11.1598,29.6683 L 11.5173,27.9894 L 10.2500,25.9593 L 7.8582,25.8768 L 6.5830,27.0259 L 4.9741,25.4170 L 6.1232,24.1418 L 6.0407,21.7500 L 4.0106,20.4827 L 2.3317,20.8402 L 1.7428,18.6424 L 3.3755,18.1126 L 4.5000,16.0000 L 3.3755,13.8874 L 1.7428,13.3576 L 2.3317,11.1598 L 4.0106,11.5173 L 6.0407,10.2500 L 6.1232,7.8582 L 4.9741,6.5830 L 6.5830,4.9741 L 7.8582,6.1232 L 10.2500,6.0407 L 11.5173,4.0106 L 11.1598,2.3317 L 13.3576,1.7428 L 13.8874,3.3755 Z M 23.2500,16.0000 A 7.25,7.25 0 1 0 8.7500,16.0000 A 7.25,7.25 0 1 0 23.2500,16.0000 Z"}}]}};function aye(i,r){let e=typeof i=="string"?wh[i]:i;if(e==null)return null;{let t=Object.assign({},e);return t.id=r,t}}function nm(i,r,e,t,n,o,s){t=t||[],n=n||{};let a=Object.assign({viewBox:`0 0 ${i.viewBox.width} ${i.viewBox.height}`,"pointer-events":"all",width:r,height:e},i.atts||{}),l=$(ve,Object.assign(n||{},a),null,t.join(" "));return i.shapes.forEach(h=>{let d=$(h.tag,Object.assign(h.atts,s||{}));l.appendChild(d)}),o&&o.appendChild(l),l}function im(i,r,e,t,n,o,s){return nm(wh[i],r,e,t,n,o,s)}var rN={x:0,y:0,width:32,height:32},nN={stroke:"currentColor",fill:"none"},gy=class extends HTMLElement{static get observedAttributes(){return["icon-id","width","height"]}findIcon(r){return wh[r]}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}render(){let r=this.getAttribute("icon-id"),e=this.getAttribute("width")||"32",t=this.getAttribute("height")||"32",n=this.findIcon(r)||wh[r];if(!n){this.innerHTML="";return}let o=n.viewBox||rN,s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",e),s.setAttribute("height",t),s.setAttribute("viewBox",`${o.x} ${o.y} ${o.width} ${o.height}`);let a=Wn(Wn({},nN),n.atts);for(let[l,h]of Object.entries(a))s.setAttribute(l,h);n.shapes.forEach(l=>{let h=document.createElementNS("http://www.w3.org/2000/svg",l.tag);for(let[d,u]of Object.entries(l.atts))h.setAttribute(d,u);s.appendChild(h)}),this.innerHTML="",this.appendChild(s)}};customElements.define("vjs-icon",gy);var iN="label",uP="transform",pP="x",mP="y",om="origin",gP="originX",EP="originY",oN="orientation",fP="size",yP="key",sN="iconId",ba="middle",Ey="type",sm="category",xP="horizontal",Yye="vertical",am="vjs-shape-icon",aN="vjs-include-icon",lN="vjs-include-icons",hN="category",cN="type",ro="__vjsRootSet",to=iN,fy="fill",Dh="outline",Nh="outlineWidth",yy="color",Ih="#FFFFFF",is="#000000",Mh=2,bP="#000000",dN=.8,Aa=class{constructor(r,e){c(this,"compiledShapes",new Map);c(this,"templateRenderer",br({defaultNamespace:"svg"}));c(this,"shapeSets",new Map);c(this,"defaultCategoryId");c(this,"labelPosition");c(this,"rootSet");c(this,"iconContainerTemplate",`<svg:svg class="${am}" x="{{x}}" y="{{y}}" viewBox="{{viewBox}}" width="{{width}}" height="{{height}}" style="overflow:visible"/>`);c(this,"iconContainerAst");c(this,"iconSpecs",new Map);c(this,"iconList",[]);c(this,"typeParameter");c(this,"categoryParameter");c(this,"multilineLabels");c(this,"labelFillRatio");e=e||{},r==null?(U("WARN: no shapes were provided to shape library."),r=[]):Array.isArray(r)||(r=[r]),this.typeParameter=e.typeParameter||cN,this.categoryParameter=e.categoryParameter||hN,this.multilineLabels=e.multilineLabels!==!1,this.labelFillRatio=e.labelFillRatio||dN,this.labelPosition=e.labelPosition||"center",this.qE(r),this.defaultCategoryId=this.rootSet.children.length>0?this.rootSet.children[0].id:xe,this.iconContainerAst=this.templateRenderer.parse(this.iconContainerTemplate)}useMultilineLabels(){return this.multilineLabels}refresh(r,e,t){this.QE(r,e);let n=r.closest(".vjs-shape")||r;this.$applyMultilineLabel(n.querySelector(":scope > .vjs-shape-label"),e,t||to)}qE(r){let e=(t,n)=>{let o=[];return t!=null&&t.forEach(s=>{let a=Object.assign(s,{parent:n,children:e(s.children,s.id)});if(this.shapeSets.set(a.id,a),a.icons){let l=ws(this.iconSpecs,a.id,()=>new Map);a.icons.forEach(h=>{l.set(h.id,h)}),this.iconList.push(...a.icons)}o.push(a)}),o};this.rootSet={children:e(r,ro),parent:null,id:ro,name:ro,shapes:[]}}getShapeSet(r){return this.shapeSets.get(r)}getShapeDefinition(r,e){return e=e||this.defaultCategoryId,this.shapeSets.get(e).shapes.find(t=>t.type===r)}$getShapeDefinitionForObject(r,e,t){let n=e||this.typeParameter,o=t||this.categoryParameter;return this.getShapeDefinition(r[n],r[o])}getShapeTemplate(r,e){let t=this.getShapeDefinition(r,e);return t==null?(U(`Cannot find shape [${r}] in set [${e}]. Returning default shape.`),this.ef()):t.template}getCompiledShape(r,e){let t=this.tf(r,e);if(!this.compiledShapes.has(t)){let n=this.templateRenderer.parse(this.getShapeTemplate(r,e)),o=s=>this.templateRenderer.render(n,s).fragment;this.compiledShapes.set(t,o)}return this.compiledShapes.get(t)}rf(r){r.setAttribute&&r.setAttribute(mp,gp),r.hasChildNodes&&r.childNodes.forEach(e=>this.rf(e))}renderCompiledShape(r,e,t,n){e=r.outlineWidth||e||1;let o=t||this.typeParameter,s=n||this.categoryParameter,a=this.getShapeDefinition(r[o],r[s]),l=a.square?Math.min(r.width,r.height):r.width,h=a.square?Math.min(r.width,r.height):r.height;return this.getCompiledShape(r[o],r[s])(Object.assign({outlineWidth:e},r,{width:l,height:h})).childNodes[0]}renderShapeLabel(r,e,t,n,o,s,a){e=e||to;let l=$(Je,{x:"50%",y:"50%",fill:o,stroke:s,"text-anchor":ba,"dominant-baseline":ba,class:Qp,"stroke-width":t||"0.25px"});l.textContent=n||r[e]||"";let h=r.fontSize||(a==null?void 0:a.size),d=r.fontStyle||(a==null?void 0:a.style),u=r.fontWeight||(a==null?void 0:a.weight),p=r.fontFamily||(a==null?void 0:a.family);return h&&l.setAttribute("font-size",h.toString()),d&&l.setAttribute("font-style",d),u&&l.setAttribute("font-weight",u),p&&l.setAttribute("font-family",p),l}tf(r,e){return e=e||this.defaultCategoryId,[r,e].join(":")}nf(r,e,t){return{center:{x:"{{width/2}}",y:"{{height/2}}",transform:"",textAnchor:ba,dominantBaseline:ba},top:{x:"{{width/2}}",y:"0",transform:`translate(0, -${e+t})`,textAnchor:ba,dominantBaseline:"hanging"},bottom:{x:"{{width/2}}",y:"{{height}}",transform:`translate(0, ${t})`,textAnchor:ba,dominantBaseline:"auto"}}[r]}of(r,e,t=to){let n={};return this.shapeSets.forEach(o=>{o.shapes.forEach(s=>{let a=s.font||e,l=a==null?14:a.size||14,h=a==null?"normal":a.style||"normal",d=a==null?"normal":a.weight||"normal",u=(a==null?void 0:a.family)||"",p=s.labelPosition||this.labelPosition,{x:m,y:g,transform:E,textAnchor:y,dominantBaseline:x}=this.nf(p,l,20),b=(s.collapsedTemplate==null?s.template:`<svg:g ${Bp}>${s.template}</svg:g><svg:g ${Fp}>${s.collapsedTemplate}</svg:g>`)+(r?`<svg:text x="${m}" y="${g}" transform="${E}" fill="{{color}}" stroke="{{color}}" stroke-width="0.25px" text-anchor="${y}" dominant-baseline="${x}" class="${Qp}" font-size="{{fontSize || ${l}}}" font-style="{{fontStyle || '${h}'}}" font-weight="{{fontWeight || '${d}'}}" font-family="{{fontFamily || '${u}'}}">{{${t}}}</svg:text>`:"");n[`${o.id}:${s.type}`]=b,n[`${xe}:${s.type}`]=b})}),n}getShapeTagDefinition(r,e,t,n={size:14,style:"normal"},o=to,s=Ih,a=is,l=is,h=Mh){return e=e||h,{template:r?`<svg:g class="${Lh}" fill="{{fill}}" stroke="{{outline}}" stroke-width="{{outlineWidth}}">
4
+ `;return e+="]}",e}isChildOf(e){return!1}},Bc=class Bc extends $c{constructor(e,t,n){super(e,t,n);c(this,"objectType",Bc.objectType);c(this,"ports",[]);c(this,"group");c(this,"portMap",{});c(this,"defaultInternalCost",0);c(this,"internalEdges",{})}getAllEdges(e){let t=e==null?null:{filter:e},n=this.getEdges(t).slice(0);for(let o=0;o<this.ports.length;o++)n.push.apply(n,this.ports[o].getEdges(t));return n}getAllSourceEdges(){let e=this.getSourceEdges().slice(0);for(let t=0;t<this.ports.length;t++)e.push.apply(e,this.ports[t].getSourceEdges());return e}getAllTargetEdges(){let e=this.getTargetEdges().slice(0);for(let t=0;t<this.ports.length;t++)e.push.apply(e,this.ports[t].getTargetEdges());return e}getDirectEdges(e){return this.getEdges(e==null?null:{filter:e})}getDirectSourceEdges(){return this.getSourceEdges()}getDirectTargetEdges(){return this.getTargetEdges()}getPortEdges(e){let t=[];for(let n=0;n<this.ports.length;n++)t.push.apply(t,this.ports[n].getEdges(e==null?null:{filter:e}));return t}getPortSourceEdges(){let e=[];for(let t=0;t<this.ports.length;t++)e.push.apply(e,this.ports[t].getSourceEdges());return e}getPortTargetEdges(){let e=[];for(let t=0;t<this.ports.length;t++)e.push.apply(e,this.ports[t].getTargetEdges());return e}getIndegreeCentrality(){let e=0;for(let t=0;t<this.ports.length;t++)e+=this.ports[t].getIndegreeCentrality();return this.indegreeCentrality+e}getOutdegreeCentrality(){let e=0;for(let t=0;t<this.ports.length;t++)e+=this.ports[t].getOutdegreeCentrality();return this.outdegreeCentrality+e}getPorts(){return this.ports}$addPort(e,t){let n=this.graph.getId(e,t),o=this.getPort(n);return o==null&&(o=new me(this,e,t),this.ports.push(o),this.portMap[o.id]=o),o}$setPort(e,t){let n=this.getPort(e);return n||(n=this.$addPort({id:e})),n.data=t,n.setType(this.graph.getType(t)),n}getPort(e){return this.portMap[e]}$renamePort(e,t){return this.portMap[e.id]?(this.portMap[t]=this.portMap[e.id],delete this.portMap[e.id],!0):!1}$removePort(e){let t=!1;if(e){let n=yl(e),o=-1;for(let s=0;s<this.ports.length;s++)if(this.ports[s].id===n){o=s;break}if(o!=-1){let s=this.ports[o];this.graph.deletePort(s),this.ports.splice(o,1),t=!0}delete this.portMap[n]}return t}$setDefaultInternalCost(e){this.defaultInternalCost=e}getInternalEdge(e,t){let n=yl(e),o=yl(t),s={source:this.portMap[n],target:this.portMap[o],cost:1/0};if(s.source&&s.target){let a=this.internalEdges[n+"-"+o]||{cost:this.defaultInternalCost,directed:!1};Object.assign(s,a)}return s}$setInternalEdge(e,t,n,o){let s=yl(e),a=yl(t);return this.internalEdges[s+"-"+a]={cost:n||this.defaultInternalCost,directed:o},this.getInternalEdge(e,t)}};c(Bc,"objectType","Node");var de=Bc,Fc=class Fc extends $c{constructor(e,t,n){super(e.graph,t,n);this.parent=e;c(this,"objectType",Fc.objectType)}getParent(){return this.parent}getFullId(){return this.parent.id+this.graph.getPortSeparator()+this.id}isChildOf(e){return this.parent===e}getAllEdges(e){return this.getEdges(e==null?null:{filter:e})}};c(Fc,"objectType","Port");var me=Fc,Uc=class Uc extends de{constructor(e,t,n){super(e,t,n);c(this,"objectType",Uc.objectType);c(this,"members",[]);c(this,"Lo",{})}$addMember(e){return this.Lo[e.id]!=null?!1:(this.members.push(e),this.Lo[e.id]=e,e.group=this,!0)}getMemberCount(){return this.members.length}getMembers(){return this.members}$removeMember(e){let t=typeof e=="string"?this.Lo[e]:e;if(t){let n=this.members.indexOf(t);return n!=-1&&(this.members.splice(n,1),delete this.Lo[t.id]),t.group&&t.group.id===this.id&&delete t.group,!0}else return!1}getAllDirectEdges(e){let t=[],n,o=e==null?null:{filter:e};t.push.apply(t,this.getEdges(o).slice(0));let s=this.getPorts();for(n=0;n<s.length;n++)t.push.apply(t,s[n].getEdges(o));return t}getInternalEdges(e){let t=[],n={};for(let o=0;o<this.members.length;o++)Array.prototype.push.apply(t,this.members[o].getAllEdges(e).filter(function(s){let a=s.getId(),l=n[a]==null;return n[a]=!0,l}));return t}};c(Uc,"objectType","Group");var le=Uc,Yc=class Yc extends Gc{constructor(e){super(e.graph,e.data);c(this,"objectType",Yc.objectType);c(this,"source");c(this,"target");c(this,"cost");c(this,"directed");c(this,"id");c(this,"geometry");c(this,"transient");c(this,"anchors");this.transient=e.transient===!0,this.source=e.source,this.target=e.target,this.cost=e.cost||1,this.directed=e.directed!==!1,this.id=e.id,e.anchors&&(this.anchors=e.anchors)}getCost(){return this.cost}setCost(e){this.cost=e}getId(){return this.id==null?this.source.id+"_"+this.target.id:this.id}getFullId(){return this.getId()}setId(e){this.id=e}isDirected(){return this.directed}setDirected(e){this.directed=e}inspect(){if(this.id!=null)return"{ id:"+this.id+", cost:"+this.cost+", directed:"+this.directed+", source:"+this.source.id+", target:"+this.target.id+"}"}};c(Yc,"objectType","Edge");var Fe=Yc;var Ib="undoRedo",Ao="userActivity",bl="api",Al="dataLoad",Mb="transient",Vb="copyPaste";var ML=(i,r,e)=>{let t=i.nodes||[],n=i.edges||[],o=i.groups||[],s=new Map,a=new Map,l=new Map,h=r.getGroups().map(p=>p.id),d=p=>{let m=l.get(p);m!=null&&m.forEach(g=>{h.push(r.addGroup(g).id)}),l.delete(p),m!=null&&m.forEach(g=>{d(g.id)})};for(let p=0;p<o.length;p++){let m=o[p];if(e.groupDecorator&&e.groupDecorator(m),m.group!=null&&h.indexOf(m.group)===-1)ws(l,m.group,()=>[]).push(m);else{let g=r.addGroup(m);a.set(g.id,m),h.push(g.id),d(g.id)}}l.forEach((p,m)=>{if(h.indexOf(m)===-1)throw new Error("Parent group ["+m+"] not found");p.forEach(g=>h.push(r.addGroup(g).id))});for(let p=0;p<t.length;p++){e.nodeDecorator&&e.nodeDecorator(t[p]);let m=r.addNode(t[p]);s.set(m.id,t[p])}function u(p){return z(p)?s.get(p)||a.get(p)||{}:{}}for(let p=0;p<n.length;p++){let m=n[p].data||{},g={source:n[p].source,target:n[p].target,cost:n[p].cost||1,directed:n[p].directed,data:m};if(e.edgeDecorator){let E=u(n[p].source),y=u(n[p].target);e.edgeDecorator(m,E,y)}n[p].anchors&&(g.anchors=n[p].anchors),n[p].geometry&&(g.geometry=n[p].geometry),r.$_addEdge(g,Al,null)}},VL=(i,r)=>{let e=i.getGraph(),t={nodes:[],edges:[],groups:[]},n,o,s;for(let a=0;a<e.nodes.length;a++){n=e.nodes[a];let l=n.transient;if(!l){let h=Object.assign({},n.data);n.group==null&&delete h.group,t.nodes.push(h)}o=n.getAllEdges();for(let h=0;h<o.length;h++){let d=o[h],u={},p=!1;(d.source===n||d.source.objectType===me.objectType&&d.source.getParent()==n)&&(d.source.dummy?(p=!0,u.source={x:d.source.data[i.modelLeftAttribute],y:d.source.data[i.modelTopAttribute]}):u.source=d.source.getFullId(),d.target.dummy?(p=!0,u.target={x:d.target.data[i.modelLeftAttribute],y:d.target.data[i.modelTopAttribute]}):u.target=d.target.getFullId(),(!l||p)&&(d.data&&(u.data=Object.assign({},d.data)),d.geometry&&(u.geometry=Object.assign({},d.geometry)),t.edges.push(u)))}}for(let a=0;a<e.groups.length;a++){s=e.groups[a];let l=Object.assign({},s.data);s.group==null&&delete l.group,t.groups.push(l),o=s.getEdges();for(let h=0;h<o.length;h++)if(o[h].source===s||o[h].source.objectType===me.objectType&&o[h].source.getParent()==s){let d={source:s.getFullId()};o[h].target.dummy?d.target={x:o[h].target.data[i.modelLeftAttribute],y:o[h].target.data[i.modelTopAttribute]}:d.target=o[h].target.getFullId(),o[h].data&&(d.data=Object.assign({},o[h].data)),o[h].geometry&&(d.geometry=Object.assign({},o[h].geometry)),t.edges.push(d)}}return t},GL=(i,r,e)=>{let t=n=>{let o=r.addNode(n);if(n.children)for(let s=0;s<n.children.length;s++){let a=r.addNode(n.children[s]);r.$_addEdge({source:o,target:a},Al,null),t(n.children[s])}};t(i)},Xt="json",lE="hierarchical-json",Gb={[Xt]:VL},$b={[Xt]:ML,[lE]:GL};function Bb(i,r){$b[i]=r}function h$(i,r){Gb[i]=r}function Fb(i,r,e,t){let n=$b[i];if(n==null)throw new Error("VisuallyJs - parse - ["+i+"] is an unsupported type");return n(r,e,t)}function hE(i,r,e){let t=Gb[i];if(t===null)throw new Error("VisuallyJs - exportData - ["+i+"] is an unsupported type");return t(r,e)}var cE=class{constructor(){c(this,"Ue",{});c(this,"ta",!1);c(this,"ra",!1);c(this,"gg",{ready:!0});c(this,"mh",[])}fire(r,e,t){return this.fireUnchecked(r,e,t)}fireUnchecked(r,e,t){let n=null;if(this.ra)this.mh.unshift(arguments);else{if(this.ra=!0,!this.ta&&this.Ue[r]){let o=this.Ue[r].length,s=0,a=!1;if(!this.shouldFireEvent||this.shouldFireEvent(r,e,t))for(;!a&&s<o&&n!==!1;){if(this.gg[r])this.Ue[r][s](e,t);else try{n=this.Ue[r][s](e,t)}catch(l){U("VisuallyJs: fire failed for event "+r+" : "+(l.message||l))}s++,(this.Ue==null||this.Ue[r]==null)&&(a=!0)}}this.ra=!1,this.Eg()}return n}Eg(){let r=this.mh.pop();r&&this.fire.apply(this,r)}unbind(r,e){if(arguments.length===0)this.Ue={};else if(arguments.length===1){if(typeof r=="string")delete this.Ue[r];else if(r.Wn){let t;for(let n in r.Wn)t=r.Wn[n],Jg(this.Ue[t]||[],r)}}else arguments.length===2&&Jg(this.Ue[r]||[],e);return this}getListener(r){return this.Ue[r]||[]}isSuspendEvents(){return this.ta}setSuspendEvents(r){this.ta=r}bind(r,e,t){return this.bindUnchecked(r,e,t)}bindAll(r,e,t){return r.forEach(n=>this.bind(n,e,t)),this}bindUnchecked(r,e,t){return(o=>{Sb(this.Ue,o,e,t),e.Wn=e.Wn||{},e.Wn[V()]=o})(r),this}silently(r){this.setSuspendEvents(!0);try{r()}catch(e){U("Cannot execute silent function "+e)}this.setSuspendEvents(!1)}},$t=class extends cE{shouldFireEvent(r,e,t){return!0}};var Sl=class{constructor(r,e){this.instance=r;c(this,"result");c(this,"gh",[]);c(this,"qr",{});this.result=r.getGraph().findPath(e.source,e.target,e.strict,e.nodeFilter,e.edgeFilter);for(let t=0;t<this.result.path.length;t++)this.gh.push(this.result.path[t].vertex),this.qr[this.result.path[t].vertex.getFullId()]=[this.result.path[t].vertex,t]}deleteEdges(){for(let r=0;r<this.result.path.length;r++)this.result.path[r].edge&&this.instance.removeEdge(this.result.path[r].edge);return this}deleteVertices(){for(let r=0;r<this.result.path.length;r++)this.instance.removeNode(this.result.path[r].vertex);return this}contains(r,e){let t=this.instance.findGraphObject(r),n=!1;if(t){for(let o=0;o<this.result.path.length;o++)if(this.result.path[o].vertex==t||this.result.path[o].edge==t||!e&&this.result.path[o].vertex.objectType==me.objectType&&this.result.path[o].vertex.isChildOf(t)){n=!0;break}}return n}getVertices(){return this.gh}getVertex(r){return this.qr[typeof r=="string"?r:r.id][0]}getAllEdgesFor(r){let e=this.qr[r.id][1];return e<this.result.path.length-1?[this.result.path[e+1].edge]:[]}filter(r,e){U("not implemented.")}ze(r,e){for(let t=e||0;t<this.result.path.length;t++)try{r(t,this.result.path[t])}catch(n){U("Path iterator function failed",n)}}each(r){this.ze((e,t)=>{r(e,t)})}eachVertex(r){this.ze((e,t)=>{r(e,t.vertex)})}eachEdge(r){this.ze((e,t)=>{r(e,t.edge)},1)}eachNode(r){this.ze((e,t)=>{K(t.vertex)&&r(e,t.vertex)})}eachGroup(r){this.ze((e,t)=>{Y(t.vertex)&&r(e,t.vertex)})}getVertexCount(){return this.result.path.length}getNodeAt(r){return this.result.path[r].vertex}getEdgeCount(){return this.result.path.length==0?0:this.result.path.length-1}getEdgeAt(r){return r<0&&(r=this.result.path.length-1+r),this.result.path.length>r+1?this.result.path[r+1].edge:null}deleteAll(){this.deleteVertices()}isEmpty(){return this.result.path.length==0}getCost(){return this.result.pathDistance}exists(){return this.result.pathDistance!=null}};var Xc=class{constructor(r,e){c(this,"Eh",new Map);c(this,"fh",new Map);c(this,"yh",new Map);if(e!=null){let t=e.nodes||{};for(let s in t)this.Eh.set(s,t[s]);let n=e.groups||{};for(let s in n)this.fh.set(s,n[s]);let o=e.ports||{};for(let s in o)this.yh.set(s,o[s])}}getNodeDefinition(r){return this.Eh.get(r)||{}}getGroupDefinition(r){return this.fh.get(r)||{}}getPortDefinition(r){return this.yh.get(r)||{}}};var xn=class i{constructor(r){c(this,"instance");c(this,"adapter");c(this,"$vertices",[]);c(this,"parameters");c(this,"done");c(this,"width");c(this,"height");c(this,"container");c(this,"containerSize");c(this,"padding");c(this,"xShift");c(this,"yShift");c(this,"Zn");this.Zn=r.options.locationFunction,this.adapter=r.adapter,this.instance=r.instance,this.container=r.container,this.containerSize=this.adapter.getSize(this.container),this.width=r.options.width||this.containerSize.width,this.height=r.options.height||this.containerSize.height,this.padding=r.options.padding,this.done=!1,this.parameters=r.options||{}}Jn(){this.done=!1,this.$vertices.length=0,this.reset()}static fg(){return{padding:{x:0,y:0}}}yg(){let r=Object.assign(i.fg(),this.getDefaultParameters()||{});return Object.assign(r,this.parameters||{}),this.parameters=r,this.parameters}getSize(r,e){return Ds(e,r,()=>{let t=this.adapter.getViewportPositionById(r);return t!=null?{width:t.width,height:t.height}:{width:0,height:0}})}xg(r,e,t,n,o){t=t||10,n=n||10;let s=Math.floor(Math.random()*t),a=Math.floor(Math.random()*n);return{x:s,y:a}}xh(r){if(this.instance==null)return;this.containerSize=this.adapter.getSize(this.container),this.width=this.containerSize.width,this.height=this.containerSize.height;let e=this.yg();this.$vertices=this.adapter.getElements().slice();let t={},n={},o=1/0,s=1/0,a=-1/0,l=-1/0,h=(p,m,g)=>{let E=n[p]||{width:0,height:0};o=Math.min(o,m),s=Math.min(s,g),a=Math.max(a,m+E.width),l=Math.max(l,g+E.height),t[p]={x:m,y:g}},d=p=>t[p];this.$vertices.forEach(p=>this.getSize(p.id,n)),this.begin(this.instance,d,h,n,e);let u=()=>{let p={};this.$vertices.forEach(m=>p[m.id]=t[m.id]),this.end(this.instance,d,h,n,e),r&&r({positions:p,bounds:{xmin:o,ymin:s,xmax:a,ymax:l},sizes:n,layout:this})};for(;!this.done;)this.step(this.instance,d,h,n,e);u()}relayout(r,e){this.Jn(),r!=null&&(this.parameters=r),this.xh(e)}layout(r){this.done=!1,this.xh(r)}};var jc=class{};var Ub={},qe={get:(i,r)=>{let e=Ub[i];if(e)return r.options=r.options||{},new e(r);throw{message:"VisuallyJs: unknown layout type '"+i+"'"}},register:(i,r)=>{Ub[i]=r}};var Hc=class Hc extends xn{constructor(e){super(e);c(this,"type",Hc.type)}getDefaultParameters(){return{}}reset(){}begin(e,t,n,o,s){this.$vertices.forEach(a=>n(a.id,0,0))}end(e,t,n,o,s){}step(e,t,n,o,s){this.done=!0}};c(Hc,"type","Empty");var Is=Hc;qe.register(Is.type,Is);function $L(i){return{x:i.data.left,y:i.data.top}}var Jn=class extends xn{constructor(e){super(e);c(this,"bh");c(this,"absoluteBacked");this.absoluteBacked=e.options.absoluteBacked===!0,this.bh=e.options.locationFunction}$_findLocation(e,t){return(t!=null&&t.locationFunction?t.locationFunction:this.bh||$L)(e)}begin(e,t,n,o,s){let a=this.adapter.getElements(),l=a.length;for(let h=0;h<l;h++){let d=a[h],u=d.getFullId(),p=t(u);p==null&&(p=this.$_findLocation(d,s),isNaN(p.x)&&(p.x=0),isNaN(p.y)&&(p.y=0)),n(u,p.x,p.y)}}step(e,t,n,o,s){this.done=!0}end(e,t,n,o,s){}reset(){}getAbsolutePosition(e,t){return e==null?{x:null,y:null}:this.$_findLocation(e,t)}},BL="Absolute",kc=class kc extends Jn{constructor(e){super(e);c(this,"type",kc.type)}getDefaultParameters(){return{}}};c(kc,"type",BL);var So=kc;qe.register(So.type,So);function FL(i,r,e,t){return i[r]<=t&&t<=i[r]+i[e]}var Wc=[(i,r)=>i.x+i.width-r.x,(i,r)=>i.x-(r.x+r.width)],Zc=[(i,r)=>i.y+i.height-r.y,(i,r)=>i.y-(r.y+r.height)],Yb=[null,[Wc[0],Zc[1]],[Wc[0],Zc[0]],[Wc[1],Zc[0]],[Wc[1],Zc[1]]],UL=(i,r,e,t,n)=>{isNaN(e)&&(e=0);let o=r.y+r.height,s=e==1/0||e==-1/0?r.x+r.width/2:(o-t)/e,a=Math.atan(e),l,h,d;return FL(r,"x","width",s)?(l=Yb[n][1](i,r),h=l/Math.sin(a),d=h*Math.cos(a),{x:d,y:l}):(d=Yb[n][0](i,r),h=d/Math.cos(a),l=h*Math.sin(a),{x:d,y:l})};function _i(i,r){let e=i.center||{x:i.x+i.width/2,y:i.y+i.height/2},t=r.center||{x:r.x+r.width/2,y:r.y+r.height/2},n=Nr(e,t),o=Os(e,t),s=n==1/0||n==-1/0||isNaN(n)?0:e.y-n*e.x;return UL(i,r,n,s,o)}function Kn(i,r,e){let t=r.width+2*e.x,n=r.height+2*e.y;return{x:i.x-t/2,y:i.y-n/2,width:t,height:n}}function zb(i){let r=[];if(i==null)return null;if(Array.isArray(i)){let e=[];return e.push.apply(e,i),e}else for(let e in i)r.push(i[e]);return r}var YL={x:20,y:20},zL=1/0;function Xb(i,r){let e={x:i.x,y:i.y};if(r!=null){let t=se(i,r);i.x=t.x,i.y=t.y,i.center!=null&&(i.center.x=i.x+i.width/2,i.center.y=i.y+i.height/2)}return{moved:e.x!==i.x||e.y!==i.y,pos:i}}var Ri=class{constructor(r){c(this,"we");c(this,"$");c(this,"na");c(this,"ht");c(this,"Ah");c(this,"Rr",null);c(this,"Qr");c(this,"F");c(this,"en");c(this,"Sh");c(this,"U",[]);c(this,"ne",new Map);c(this,"wo",new Map);c(this,"rn",new Map);c(this,"nn",new Set);c(this,"Do",!1);c(this,"Th");c(this,"At",new Map);this.en=r.positionGetter,this.Sh=r.positionSetter,this.F=r.getId,this.Qr=r.getSize,this.$=zb(r.elements||[]),this.ht=r.filter||(e=>!0),this.Ah=r.exclude||(e=>!1),this.na=r.constrain||((e,t,n)=>n)}executeAtPoint(r,e){return this.$.length>0?(this.Kn((e==null?void 0:e.getSize)||this.Qr,(e==null?void 0:e.getPosition)||this.en,e==null?void 0:e.knownLocations),this.ia(r),this.Rr=null,this.oa(e)):{original:{},current:{}}}executeAtCenter(r){if(this.$.length>0){let e=this.Kn((r==null?void 0:r.getSize)||this.Qr,(r==null?void 0:r.getPosition)||this.en,r==null?void 0:r.knownLocations);return this.ia({x:(e.minx+e.maxx)/2,y:(e.miny+e.maxy)/2}),this.Rr=null,this.oa(r)}else return{original:{},current:{}}}executeWithFocus(r,e){return this.$.length>0?(this.Kn((e==null?void 0:e.getSize)||this.Qr,(e==null?void 0:e.getPosition)||this.en,e==null?void 0:e.knownLocations,e==null?void 0:e.knownSizes),this.Rr={id:r,bounds:this.ne.get(r),element:this.$.find(t=>t.id===r)},this.ia(this.Rr.bounds.center),this.oa(e)):{original:{},current:{}}}snapToGrid(r){let e={original:{},current:{}};this.Kn(this.Qr,this.en);for(let t=0;t<this.U.length;t++){let n=this.ne.get(this.U[t].id),{moved:o,pos:s}=Xb(this.U[t].bounds,r);o&&(e.original[this.U[t].id]=n,e.current[this.U[t].id]=s)}return this.Ch(e),e}setElements(r){return this.$=zb(r),this}startTracking(r,e,t){return this.setElements(r),this.Kn(this.Qr,this.en),this.Th=t||zL,this.rn.clear(),this.nn.clear(),this.wo.entries().forEach(n=>{this.rn.set(n[0],Object.assign({},n[1]))}),this.Do=e,this}stopTracking(){this.rn.clear(),this.nn.clear(),this.Do=!1}addElement(r,e){return r!=null&&(e||this.$.indexOf(r)===-1)&&this.$.push(r),this}addElements(r,e){if(e)Array.prototype.push.apply(this.$,r);else for(let t=0;t<r.length;t++)this.addElement(r[t]);return this}removeElement(r){let e=-1;for(let t=0;t<this.$.length;t++)if(this.$[t]===r){e=t;break}return e!==-1&&this.$.splice(e,1),this}reset(){this.$.length=0}ia(r){r!=null&&(this.we=r)}Kn(r,e,t,n){return this.U.length=0,this.ne.clear(),this.wo.clear(),this.At.clear(),this.Ag(this.$,r,e,t,n)}Ag(r,e,t,n,o){let s,a,l,h;s=a=1/0,l=h=-1/0,n=n||{},o=o||{};for(let d=0;d<r.length;d++){let u=n[r[d].id]||t(r[d]),p=o[r[d].id]||e(r[d]),m=this.F(r[d]),g={x:u.x,y:u.y,width:p.width,height:p.height,center:{x:u.x+p.width/2,y:u.y+p.height/2}};this.ne.set(m,g),this.wo.set(m,Object.assign({},g)),this.U.push({bounds:g,id:m,element:r[d]}),this.At.set(m,p),s=Math.min(s,u.x),a=Math.min(a,u.y),l=Math.max(l,u.x+p.width),h=Math.max(h,u.y+p.height)}return{minx:s,maxx:l,miny:a,maxy:h}}Sg(r,e,t,n){if(this.rn.has(r)){let o=this.rn.get(r),s=this.ne.get(r),a={x:s.x+o.width/2,y:s.y+o.height/2},l=Be(o.center,a),h=l/Math.ceil(l/10),d=Math.round(l/h)+1,u=Math.atan2(o.center.y-a.y,o.center.x-a.x);if(l>this.Th)return null;let p=null,m=0;for(let g=1;g<d;g++){let E={x:a.x+g*h*Math.cos(u),y:a.y+g*h*Math.sin(u)},y=Kn(E,o,{x:0,y:0});Xb(y,n);let x=!0;for(let f=0;f<this.U.length;f++){let b=this.U[f];if(b.id!==r&&!t(b.id,b.element)){let A=b.bounds,T=Kn(A.center,A,e);if(ke(y,T)){x=!1;break}}}if(x)m=g,p={x:E.x-o.width/2,y:E.y-o.height/2};else break}return p!=null?{moved:!0,reverted:m===d-1,positionReached:p}:null}else return null}Tg(r={},e,t,n,o){if((this.Do&&!o||!this.Do&&o)&&this.nn.size>0){let a=!1;for(;!a;){let l=!0;this.nn.forEach(h=>{let d=this.Sg(h,e,t,n);if(d!=null&&d.moved){let u=this.rn.get(h),p=d.reverted?{x:u.x,y:u.y}:d.positionReached;r[h]=p;let m=this.ne.get(h);m.x=p.x,m.y=p.y,m.center.x=p.x+u.width/2,m.center.y=p.y+u.height/2,d.reverted&&this.nn.delete(h),l=!1}}),a=l}}}oa(r){let e={};if(this.$.length>1){r=r||{};let n=r.filter||this.ht,o=r.padding||YL,s=r.iterations,a=r.exclude||this.Ah;r.gather&&Object.assign(e,this.vg(o,this.na,n,a)),Object.assign(e,this.Cg(o,this.na,n,s,a,r.grid)),this.Tg(e,o,a,r.grid,r.invertTrackbackPreference)}let t={original:{},current:{}};for(let n in e)t.original[n]=this.wo.get(n),t.current[n]=e[n],this.nn.add(n);return this.Ch(t),t}vg(r,e,t,n){let o={},s=Kn(this.we,{width:0,height:0},r);this.Oh();let a={},l=h=>{let d=[this.we,h],u=[];Array.prototype.push.apply(u,cr(d,s).map(p=>[s,p,null]));for(let p in a){let m=this.ne.get(p);Array.prototype.push.apply(u,cr(d,m).map(g=>[m,g,p]))}return u.filter(p=>p!=null)};for(let h=0;h<this.U.length;h++){if(n(this.U[h].id,this.U[h].element))continue;let d=this.U[h].bounds,u=this.U[h].bounds,p=Kn(d.center,u,r);if(t(this.U[h].id,this.U[h].element)){let m=l(d.center);if(m.length>0){m.sort((y,x)=>{let f=Be(y[1],d),b=Be(x[1],d);return f<b?-1:1});let g=m[0][0],E=_i(g,p);d.x+=E.x,d.y+=E.y,d.center.x+=E.x,d.center.y+=E.y,o[this.U[h].id]=d,a[this.U[h].id]=!0}}}return o}Cg(r,e,t,n,o,s){n=n||2;let a,l;this.Rr!=null?(a=Kn(this.we,this.Rr.bounds,{x:0,y:0}),l=this.Rr.id):a=Kn(this.we,{width:0,height:0},r),this.Oh();let h=1,d=!0,u,p,m={},g=(x,f,b,A)=>{f.x+=b,f.y+=A,f.center.x+=b,f.center.y+=A,m[x]=f},E=(x,f)=>{if(s==null)return f;{let b=Ci(x,f),A=b.x/s.width,T=b.y/s.height,S=f.x>=0?Math.ceil(A):Math.floor(A),R=f.y>=0?Math.ceil(T):Math.floor(T),v={x:s.width*S,y:s.height*R};return pb(v,x)}},y=()=>{let x,f;for(let b=0;b<this.U.length;b++){if(x=this.U[b],o(x.id,x.element))continue;let A=x.bounds,T=Kn(A.center,A,r);x.id!==l&&t(x.id,x.element)&&ke(a,T)&&(u=_i(a,T),u=E(A,u),p=e(x.id,A,u),g(x.id,A,p.x,p.y),T=Kn(A.center,A,r));for(let S=0;S<this.U.length;S++)if(b!==S){if(f=this.U[S],f.id===l||o(f.id,f.element))continue;if(t(f.id,f.element)){let R=f.bounds,v=Kn(R.center,R,r);ke(T,v)&&(d=!0,u=_i(T,v),u=E(R,u),p=e(f.id,R,u),g(f.id,R,p.x,p.y))}}}d&&h<n&&(d=!1,h++,y())};return y(),m}Ch(r){for(let e=0;e<this.$.length;e++){let t=this.F(this.$[e]);r.current[t]&&this.Sh(this.$[e],r.current[t])}}Oh(){let r={};this.U.sort((e,t)=>{let n=r[e.id]||Math.min(Be(e.bounds,this.we),Be(Ci(e.bounds,{x:e.bounds.width,y:0}),this.we),Be(Ci(e.bounds,{x:e.bounds.width,y:e.bounds.height}),this.we),Be(Ci(e.bounds,{x:0,y:e.bounds.height}),this.we)),o=r[t.id]||Math.min(Be(t.bounds,this.we),Be(Ci(t.bounds,{x:t.bounds.width,y:0}),this.we),Be(Ci(t.bounds,{x:t.bounds.width,y:t.bounds.height}),this.we),Be(Ci(t.bounds,{x:0,y:t.bounds.height}),this.we));return r[e.id]=n,r[t.id]=o,n===o?0:n<o?-1:1})}};var jb={x:30,y:30},Kc=class Kc extends xn{constructor(e){super(e);c(this,"Ph");c(this,"type",Kc.type);c(this,"padding",jb);this.Ph=e.options.centerRoot===!0,this.padding=e.options.padding||jb}getDefaultParameters(){return{padding:this.padding,locationFunction:this.Zn}}begin(e,t,n,o,s){}end(e,t,n,o,s){}reset(){}step(e,t,n,o,s){let a=this.$vertices.slice(),l=0,h=0,d,u,p=10;if(this.Ph&&a.length>0){let E=this.getSize(a[0].id,o);p=Math.max(E.width,E.height)+80,n(a[0].id,0,0),a=a.slice(1)}if(a.length===0){this.done=!0;return}let m=2*Math.PI/a.length,g=-Math.PI/2;for(d=0;d<a.length;d++)if(u=a[d],n(u.id,l+Math.sin(g)*p,h+Math.cos(g)*p),g+=m,d>0){let E=a[d-1],y=this.getSize(E.id,o),x=t(E.id),f={x:x.x-s.padding.x,y:x.y-s.padding.y,width:y.width+2*s.padding.x,height:y.height+2*s.padding.y},b=a[d],A=this.getSize(b.id,o),T=t(b.id),S={x:T.x-s.padding.x,y:T.y-s.padding.y,width:A.width+2*s.padding.x,height:A.height+2*s.padding.y},R=_i(f,S),v=[x.x+y.width/2,x.y+y.height/2],O=[T.x+R.x+A.width/2,T.y+R.y+ +(A.height/2)],P=Math.sqrt(Math.pow(v[0]-O[0],2)+Math.pow(v[1]-O[1],2));p=Math.max(p,P/2/Math.sin(m/2))}for(d=0;d<a.length;d++)u=a[d],n(u.id,l+Math.sin(g)*p,h+Math.cos(g)*p),g+=m;this.done=!0}};c(Kc,"type","Circular");var Jc=Kc;qe.register(Jc.type,Jc);var dE="Grid",uE="Column",pE="Row";var Te="width",De="height",xF="rotation",qc="v",Hb="h",Se="top",ze="left",ut="right",st="bottom",wt="center",Q="x",fe="y",bn="dlr",qn="drl",rn="none",nn="orthogonal",kb="manhattan",Qc="diagonal",Wb="metro",Zb=-1,he="v",ne="h",Jb="undefined",xe="default",At="true",at="false",Kb="left",qb="top",Qb="rotation",eA="width",tA="height",Qe="source",An="target";var XL={x:30,y:30},Li="row",mE="column",To=class extends xn{constructor(e){super(e);c(this,"sn",[]);c(this,"sa");c(this,"aa");c(this,"de");c(this,"an");c(this,"ln");c(this,"Lr");c(this,"wr");c(this,"type");this.type=dE,this.de=e.options.orientation||Li,this.padding=e.options.padding||XL,this.sa=e.options.verticalAlignment||wt,this.aa=e.options.horizontalAlignment||wt,this.an=e.options.rows||-1,this.ln=e.options.columns||-1}getDefaultParameters(){return{orientation:Li,rows:-1,columns:-1}}begin(e,t,n,o,s){this.sn.length=0;let a,l;if(this.an===-1&&this.ln===-1){let p=Math.round(Math.sqrt(this.$vertices.length));a=p+(this.de===Li?1:0),l=p+(this.de===mE?1:0)}else this.an!==-1?(a=this.an,l=Math.ceil(this.$vertices.length/a)):this.ln!==-1&&(l=this.ln,a=Math.ceil(this.$vertices.length/l));this.Lr=-1/0,this.wr=-1/0;let h=0,[d,u]=this.de===Li?[a,l]:[l,a];for(let p=0;p<d;p++){this.sn[p]=[];for(let m=0;m<u;m++)if(h=p*u+m,h<this.$vertices.length){let g=this.$vertices[h],E=this.getSize(g.id,o);this.Lr=Math.max(this.Lr,E.width),this.wr=Math.max(this.wr,E.height),this.sn[p][m]={vertex:g,size:E}}}}end(e,t,n,o,s){}reset(){}Og(e){let t=this.de===Li&&this.an===1||this.aa===ze?0:this.aa===wt?(this.Lr-e.width)/2:this.Lr-e.width,n=this.de===mE&&this.ln===1||this.sa===Se?0:this.sa===wt?(this.wr-e.height)/2:this.wr-e.height;return{padX:t,padY:n}}step(e,t,n,o,s){let a=0,l=0;for(let h=0;h<this.sn.length;h++){for(let d=0;d<this.sn[h].length;d++){let u=this.sn[h][d],{padX:p,padY:m}=this.Og(u.size);n(u.vertex.id,a+p,l+m),this.de===Li?a+=this.padding.x*2+(this.an===1?u.size.width:this.Lr):l+=this.padding.y*2+(this.ln===1?u.size.height:this.wr)}this.de===Li?(l+=this.padding.y*2+this.wr,a=0):(a+=this.padding.x*2+this.Lr,l=0)}this.done=!0}};c(To,"type",dE),qe.register(To.type,To);var Tl=class extends To{constructor(r){super(Object.assign(r,{options:Object.assign(r.options||{},{orientation:mE,columns:1})})),this.type=uE}};c(Tl,"type",uE),qe.register(Tl.type,Tl);var vl=class extends To{constructor(r){super(Object.assign(r,{options:Object.assign(r.options||{},{orientation:Li,rows:1})})),this.type=pE}};c(vl,"type",pE),qe.register(vl.type,vl);var td=class td extends Jn{constructor(e){super(e);c(this,"No");c(this,"type",td.type);c(this,"$",new Map);c(this,"qn",new Map);c(this,"Qn");c(this,"St");c(this,"Io",1/0);c(this,"Mo",-1/0);c(this,"Vo",1/0);c(this,"Go",-1/0);c(this,"Tt",[]);c(this,"la",new Map);c(this,"vt");c(this,"ca");this.vt=fn(this.getDefaultParameters(),e.options),this.St=e.options.absoluteBacked!==!1}getDefaultParameters(){return{iterations:15,spacing:250,r:.25,locationFunction:this.Zn}}cn(e,t,n){return t=Nc(t),n=Nc(n),e.x=t,e.y=n,e.center.x=t+e.width/2,e.center.y=n+e.height/2,{Pg:t,_g:n}}hn(e){return this.qn.get(e.id)===!0}Rg(e){this.qn.set(e.id,!0)}reset(){super.reset(),this.$.clear(),this.qn.clear(),this.No=0,this.Io=this.Vo=1/0,this.Mo=this.Go=-1/0,this.la.clear()}begin(e,t,n,o,s){this.Tt.length=0,this.$.clear(),this.No=0,this.Io=1/0,this.Mo=-1/0,this.Vo=1/0,this.Go=-1/0,this.ca=this.vt.r,this.St&&this.$vertices.forEach(a=>{let l=this.$_findLocation(a,s);l!=null&&l.x!=null&&l.y!=null&&n(a.id,l.x,l.y)})}dt(e,t,n){let o=H(e)?e.getParent():e,s=this.$.get(o.id);if(!s){let a=t(o.id)||this.xg(o.id,n,this.width,this.height,!0),l=this.getSize(o.id,n);l.width===0&&(l.width=1),l.height===0&&(l.height=1),s={id:o.id,n:o,x:a.x,y:a.y,f:[0,0],width:l.width,height:l.height,center:{x:a.x+l.width/2,y:a.y+l.height/2}},this.$.set(o.id,s),this.la.set(o.id,this.instance.getAllEdgesFor(o).filter(h=>this.adapter.filter(h.target)))}return s}ha(e,t,n){return this.Tt[e]?this.Tt[e]:(this.Tt[e]=this.dt(this.$vertices[e],t,n),this.Tt[e])}step(e,t,n,o,s){let a;for(this.Qn=0,a=0;a<this.$vertices.length;a++){let l=this.ha(a,t,o);if(this.St&&!this.hn(l)){let d=this.getAbsolutePosition(l.n,s);if(d!=null&&d.x!=null&&d.y!=null&&!isNaN(d.x)&&!isNaN(d.y)){this._h(l,d.x,d.y),n(l.id,d.x,d.y),this.Rg(l),l.x=d.x,l.y=d.y,l.f[0]=0,l.f[1]=0;continue}}for(let d=a+1;d<this.$vertices.length;d++){let u=this.ha(d,t,o);this.Lg(l,u)}let h=this.la.get(l.id);for(let d=0;d<h.length;d++)this.wg(l,h[d],t,o)}if(this.Qn!==0)for(a=0;a<this.$vertices.length;a++){let l=this.ha(a,t,o);if(!this.hn(l)){let h=l.f[0],d=l.f[1];this._h(l,l.x+h,l.y+d)}l.f[0]=0,l.f[1]=0}this.No++,(this.Qn===0||this.No>=this.vt.iterations)&&(this.Dg(n,o),this.done=!0)}end(e,t,n,o,s){this.qn.clear(),this.$.forEach((a,l)=>{this.qn.set(l,!0)})}_h(e,t,n){let{Pg:o,_g:s}=this.cn(e,t,n);this.Io=Math.min(this.Io,o),this.Vo=Math.min(this.Vo,s),this.Mo=Math.max(this.Mo,o),this.Go=Math.max(this.Go,s)}Dg(e,t){this.$.forEach((n,o)=>{let s=this.$.get(o);e(o,Math.floor(s.x),Math.floor(s.y))})}Lg(e,t){let n=this.hn(e),o=this.hn(t);if(n&&o||e.width===0||e.height===0||t.width===0||t.height===0)return;let s,a,l,h;if(ke(e,t))h=1,s=1,a=1;else{let d=[e.center,t.center],u=cr(d,e)[0],p=cr(d,t)[0];s=p.x-u.x,a=p.y-u.y,l=s*s+a*a,h=Math.sqrt(l),h==0&&(h=1,s=1,a=1)}if(h<this.vt.spacing){this.Qn++;let d=this.ca*(this.vt.spacing-h),u=1,p=1,m=u*d*s/h,g=p*d*a/h,E=o?0:(n?2:1)*m,y=o?0:(n?2:1)*g,x=n?0:(o?2:1)*m,f=n?0:(o?2:1)*g;t.f[0]+=E,t.f[1]+=y,e.f[0]-=x,e.f[1]-=f}}wg(e,t,n,o){let s=this.dt(t.target,n,o),a=this.hn(e),l=this.hn(s);if(a&&l)return;this.Qn++;let h,d,u,p,m;if(ke(e,s))p=-2*this.vt.spacing,h=-2*this.vt.spacing,d=-2*this.vt.spacing;else{let y=[e.center,s.center],x=cr(y,e)[0],f=cr(y,s)[0];h=f.x-x.x,d=f.y-x.y,u=h*h+d*d,p=Math.sqrt(u),p===0&&(p=1,h=1,d=1)}m=this.ca*(p-this.vt.spacing),(t.cost==null||t.cost<1)&&(t.cost=1),m*=Math.log(t.cost)*.5+1;let g=m*h/p,E=m*d/p;s.f[0]-=l?0:(a?2:1)*g,s.f[1]-=l?0:(a?2:1)*E,e.f[0]+=a?0:(l?2:1)*g,e.f[1]+=a?0:(l?2:1)*E}};c(td,"type","ForceDirected");var ed=td;qe.register(ed.type,ed);function jL(i,r){for(let e=0;e<i.length;e++)if(i[e].target!==r||i[e].source!==r)return!1;return!0}var Ms=class extends Jn{constructor(e){super(e);c(this,"Rh");c(this,"dn");c(this,"Lh");this.Rh=!!e.options.ignoreLoops,this.Lh=e.options.ignorePorts===!0,this.dn=e.options.getRootNode||(t=>e.options.multipleRoots!==!1?t.filter(n=>{if(wb(n)){let o=n.getTargetEdges();return(o.length===0||jL(o,n))&&this.adapter.filter(n)}else return!1}).getAll():this.$vertices.length>0?[this.$vertices[0]]:null)}begin(e,t,n,o,s){super.begin(e,t,n,o,s),s.ignoreLoops=this.Rh,s.getRootNode=this.dn,s.getChildVertices=s.getChildVertices||((a,l,h)=>{let d=[];return h.getAllEdgesFor(a).forEach(u=>{let p=H(u.target)?u.target.getParent():u.target;(u.source===a||this.Lh!==!0&&H(u.source)&&u.source.getParent()===a)&&this.adapter.filter(p)&&d.push(p)}),d}),s.rootNode=s.getRootNode(e),s.rootNode||(this.done=!0)}};var rA=wt,nA={x:60,y:60},iA="auto",oA=wt;function Cl(i){return i.parents.length>0?i.parents[0].loc:null}function rd(i,r){if(i.parents.length===0)return null;{let e=i.parents[0].size;for(let t=1;t<i.parents.length;t++)e+=r+i.parents[t].size;return e}}function HL(i){return i.parents.length>0?i.parents[0].root===!0:!1}function sA(i){return i.parents.length>0?i.parents[0].childGroup:null}function kL(i){return i.parents.length>0?i.parents[i.parents.length-1].childGroupIndex:null}var nd=class{constructor(r,e){this.dataSource=r;c(this,"Dr");c(this,"Yt");c(this,"ve");c(this,"P",[]);c(this,"Nr",[]);c(this,"ei",{});c(this,"Q");c(this,"J");c(this,"Ct");c(this,"ue");c(this,"ti");c(this,"xe");c(this,"St");c(this,"D");c(this,"un",-1/0);c(this,"pn",1/0);c(this,"ri");c(this,"Ot");c(this,"ni");c(this,"De",[]);c(this,"positions",new Map);c(this,"da",{[wt]:r=>Cl(r)+rd(r,this.J)/2-(r.size-this.J)/2,start:r=>Cl(r),end:r=>Cl(r)+rd(r,0)-(r.size-this.J)});c(this,"F");c(this,"Pt");c(this,"Xt");c(this,"ii");c(this,"fa",{center:(r,e,t)=>(e+t)/2-rd(r)/2,start:(r,e,t)=>e,end:(r,e,t)=>e});this.Dr=Array.isArray(e.rootNode)?e.rootNode:[e.rootNode],this.Yt=e.compress===!0,this.St=e.absoluteBacked===!0,this.F=e.idFunction,this.Pt=e.sizeFunction,this.Xt=e.childVerticesFunction,this.ii=e.absolutePositionFunction,this.ue=e.axisIndex,this.xe=this.ue!==1,this.ti=this.ue===0?1:0,this.ri=this.xe?"y":"x",this.Ot=this.xe?Te:De,this.ni=this.xe?De:Te,this.ve=e.invert===!0,this.D=e.alignment||oA,this.Q=e.padding,this.J=this.xe?this.Q.x:this.Q.y,this.Ct=this.xe?this.Q.y:this.Q.x}execute(){let r,e,t;for(let n=0;n<this.Dr.length;n++){r=this.Dr[n];let o=this.Pt(r.id),s=this.Qe(r,o,0,null,null),a=0;s.root=!0,a=this.oi(s,0);let l=0,h,d,u=(m,g)=>this.Yt&&m.parents&&m.parents.length>0?this.positions.get(this.F(m.parents[0].node)).position[this.ri]+this.ua(m,this.ti)+this.Ct:g,p=!1;if(a===0&&this.St===!0){let m=this.ii(r);!isNaN(m.x)&&!isNaN(m.y)&&(this.si(r.id,m,0),p=!0)}if(!p)for(e=0;e<this.P.length;e++){for(this.P[e].otherAxis=l,t=0;t<this.P[e].entries.length;t++)h=this.ue===0?this.P[e].entries[t].loc:u(this.P[e].entries[t],l),d=this.ue===1?this.P[e].entries[t].loc:u(this.P[e].entries[t],l),this.si(this.F(this.P[e].entries[t].node),{x:h,y:d},e);this.ve?e<this.P.length-1&&(this.P[e].otherAxisSize=this.De[e+1]+this.Ct,l-=this.P[e].otherAxisSize):(this.P[e].otherAxisSize=this.De[e]+this.Ct,l+=this.P[e].otherAxisSize)}}return this.positions}si(r,e,t){this.positions.set(r,{position:e,layer:t});let n=this.Pt(r),o=this.ue===0?e.x+n.width:e.y+n.height;this.un=Math.max(this.un,o),this.pn=Math.min(this.pn,o)}dt(r){let e=this.P[r];return e||(e={entries:[],pointer:0},this.P[r]=e),e}Qe(r,e,t,n,o){let s=this.dt(t),a={node:r,parents:n==null?[]:[n],childGroup:o,loc:s.pointer,index:s.entries.length,dimensions:e,size:e[this.Ot],children:[]},l=e[this.ni];return this.De[t]==null?this.De[t]=l:this.De[t]=Math.max(this.De[t],l),s.pointer+=e[this.Ot]+this.J,s.entries.push(a),n&&n.children.push(a),a}pa(r,e){let t=this.Nr[e];t||(t=[],this.Nr[e]=t),r.index=t.length,t.push(r)}ma(r,e){if(r.parents.length>0){let t=e-r.parents[0].loc;for(let s=0;s<r.parents.length;s++)r.parents[s].loc+=t;let n=r.parents[r.parents.length-1],o=this.dt(r.depth-1);o.pointer=Math.max(o.pointer,n.loc+n.size+this.J)}}ua(r,e){let t=r.parents.map(n=>n.dimensions[e===0?Te:De]);return Math.max.apply(null,t)}ga(r){if(r.size>0){let e=this.da[this.D](r),t=this.Nr[r.depth],n=this.D==="end"?1/0:-1/0,o=0;if(t!=null&&t.length>0){let d=t[t.length-1],u=d.nodes[d.nodes.length-1];n=this.D==="end"?u.loc-r.size:u.loc+u.size+this.J}this.D!=="end"&&e>=n||this.D==="end"&&e<=n?r.loc=e:(o=n-e,r.loc=n);let s=r.loc,a=this.D==="end"?r.nodes.length-1:0,l=this.D==="end"?-1:r.nodes.length,h=this.D==="end"?-1:1;for(let d=a;d!==l;d+=h)r.nodes[d].loc=s,s+=r.nodes[d].size,s+=this.J;o!==0&&this.Ea(r),this.pa(r,r.depth)}}ya(r){let e=r.nodes[0].loc,t=r.nodes[r.nodes.length-1].loc+r.nodes[r.nodes.length-1].size,n=this.fa[this.D](r,e,t),o=n-Cl(r);if(this.ma(r,n),!HL(r)){let s=sA(r),a=kL(r);for(let l=a+1;l<s.nodes.length;l++)s.nodes[l].loc+=o}}Ea(r){let e=r;for(;e!=null;)this.ya(e),e=sA(e)}oi(r,e){if(this.ei[r.node.id])return;this.ei[r.node.id]=!0;let t={nodes:[],loc:0,size:0,parents:[r],depth:e+1,children:[]},n=[],o,s={},a=this.dt(e+1),l=this.Xt(r.node,e,this.dataSource);for(o=0;o<l.length;o++){let h=l[o];if(h!=null&&h!==r.node&&!s[h.id]){let d=this.Pt(this.F(h)),u=a.entries.find(p=>this.F(p.node)===this.F(h));if(u!=null){u.parents.push(r);let p=Cl(u),m=rd(u,this.J),g=p+m/2-u.size/2,E=g-u.loc,y=x=>{for(let f=x.childGroupIndex;f<x.childGroup.nodes.length;f++)x.childGroup.nodes[f].loc+=E,x.children.forEach(y),x.childGroup.size+=E};y(u)}else{let p=this.Qe(h,d,e+1,r,t);p.childGroupIndex=t.nodes.length,t.nodes.push(p);let m=d[this.Ot];t.size+=m+this.J,n.push(p)}s[h.id]=!0}}for(this.ga(t),o=0;o<n.length;o++)this.oi(n[o],e+1);return l.length}};var WL="Hierarchical",od=class od extends Ms{constructor(e){super(e);c(this,"type",od.type);c(this,"de");c(this,"xe");c(this,"ue");c(this,"Yt");c(this,"ve");c(this,"D");c(this,"Dh");c(this,"P",[]);c(this,"Xt");this.ve=e.options.invert,this.Dh=e.options.spacing||iA,this.Yt=this.Dh==="compress",this.D=e.options.align||rA,this.de=e.options.orientation!=null?e.options.orientation:"horizontal"}getDefaultParameters(){return{padding:nA,orientation:this.de,locationFunction:this.Zn,align:this.D}}begin(e,t,n,o,s){super.begin(e,t,n,o,s),this.de=s.orientation,this.xe=this.de==="horizontal",this.ue=this.xe?0:1,this.padding=s.padding,this.P.length=0,this.Xt=s.getChildVertices}step(e,t,n,o,s){new nd(e,{rootNode:s.rootNode,compress:this.Yt,padding:this.padding,axisIndex:this.ue,invert:this.ve,alignment:this.D,idFunction:h=>e.getNodeId(h),sizeFunction:h=>this.getSize(h,o),childVerticesFunction:(h,d,u)=>this.Xt(h,d,u),absoluteBacked:this.absoluteBacked,absolutePositionFunction:h=>this.getAbsolutePosition(h,s)}).execute().forEach((h,d)=>{n(d,h.position.x,h.position.y)}),this.done=!0}getHierarchy(){return this.P}getOrientation(){return this.de}};c(od,"type",WL);var id=od;qe.register(id.type,id);var gE=class{constructor(r){this.focus=r;c(this,"id");c(this,"children",new Set);c(this,"ne",new Map);c(this,"Nh",new Map);c(this,"group");c(this,"extents");c(this,"offsets");this.id=V(),this.group=[r]}setPosition(r,e,t){this.ne.set(r,{x:e,y:t})}getPosition(r){return this.ne.get(r)}getIncidentAngle(r){return this.Nh.get(r)}setIncidentAngle(r,e){this.Nh.set(r,e)}getPositions(){return this.ne}},ZL=100,JL={x:50,y:50},ad=class ad extends Ms{constructor(e){super(e);c(this,"type",ad.type);c(this,"Ih");c(this,"et",[]);c(this,"clusterMagnetizer");c(this,"groupPadding");this.groupPadding=e.options.groupPadding||ZL,this.padding=e.options.padding||JL,this.clusterMagnetizer=new Ri({positionGetter:t=>({x:t.extents[0],y:t.extents[2]}),positionSetter:(t,n)=>{for(let o=0;o<t.group.length;o++){let s=t.offsets[t.group[o].id];t.setPosition(t.group[o].id,n.x+s.x,n.y+s.y)}},getSize:t=>({width:t.extents[1]-t.extents[0],height:t.extents[3]-t.extents[2]}),getId:t=>t.focus.id,filter:t=>this.et[0].focus.id!==t})}getDefaultParameters(){return{padding:this.padding,locationFunction:this.Zn,groupPadding:this.groupPadding,getChildEdges:(e,t,n)=>n.getAllEdgesFor(e,o=>{let s=H(o.source)?o.source.getParent():o.source,a=H(o.target)?o.target.getParent():o.target;return s===e&&s!==a&&this.adapter.filter(a)})}}begin(e,t,n,o,s){super.begin(e,t,n,o,s),this.et.length=0,this.Ih=s.getChildEdges}Mh(e,t,n,o,s,a,l){let h=(T,S,R,v)=>({x:T-a.padding.x,y:S-a.padding.y,width:R+2*a.padding.x,height:v+2*a.padding.y}),d,u=new gE(e),p=s?s.position:{x:0,y:0},m=p.x,g=p.y,E={},y=T=>E[T]||(E[T]=this.getSize(T,o),E[T]),x,f,b;u.setPosition(e.id,p.x,p.y);let A=this.Ih(e,l,this.instance);for(let T=0;T<A.length;T++){let S=A[T].target,R=H(S)?S.getParent():S;u.children.add(R)}if(x=y(u.focus.id),d=Math.max(x.width,x.height),b=h(m-x.width/2,g-x.height/2,x.width,x.height),n(u.focus.id,-(x.width/2),-(x.height/2)),u.children.size>0){this.et.push(u);let T=2*Math.PI/(u.children.size+(s?1:0)),S=s?s.incidentAngle+Math.PI+T:Math.PI,R=S,v=null;u.children.forEach(D=>{f=y(D.id);let M=h(m+Math.sin(S)*f.width,g+Math.cos(S)*f.height,f.width,f.height),N=_i(b,M),G=Math.sqrt(Math.pow(M.x+N.x-m,2)+Math.pow(M.y+N.y-g,2));if(d=Math.max(d,G),u.setPosition(D.id,M.x+N.x,M.y+N.y),S+=T,v!=null){let J=y(v.id),Ee=u.getPosition(v.id),j=h(Ee.x,Ee.y,J.width,J.height),pe=y(D.id),Me=u.getPosition(D.id),Ye=h(Me.x,Me.y,pe.width,pe.height),Mt=_i(j,Ye),tr={x:Ee.x+J.width/2,y:Ee.y+J.height/2},Yt={x:Me.x+Mt.x+pe.width/2,y:Me.y+Mt.y+ +(pe.height/2)},Tr=Math.sqrt(Math.pow(tr.x-Yt.x,2)+Math.pow(tr.y-Yt.y,2));d=Math.max(d,Tr/2/Math.sin(T/2))}v=D}),S=R,u.children.forEach(D=>{u.setIncidentAngle(D.id,S),u.setPosition(D.id,m+Math.sin(S)*d,g+Math.cos(S)*d),S+=T});let O=u.getPosition(e.id),P=O.x,I=y(e.id),C=P+I.width,_=O.y,w=_+I.height,B;u.children.forEach(D=>{if(!this.Mh(D,t,n,o,{parent:e,incidentAngle:u.getIncidentAngle(D.id),position:u.getPosition(D.id)},a,l+1)){B=y(D.id),u.group.push(D);let N=u.getPosition(D.id);P=Math.min(P,N.x),C=Math.max(C,N.x+B.width),_=Math.min(_,N.y),w=Math.max(w,N.y+B.height)}}),u.extents=[P,C,_,w],u.offsets={};for(let D=0;D<u.group.length;D++){let M=u.group[D],N=u.getPosition(M.id);u.offsets[M.id]={x:N.x-u.extents[0],y:N.y-u.extents[2]}}}return u.children.size}step(e,t,n,o,s){if(s.rootNode&&s.rootNode.length>0){if(this.Mh(s.rootNode[0],t,n,o,null,s,0),this.et.length>0){let a=(this.et[0].extents[0]+this.et[0].extents[1])/2,l=(this.et[0].extents[2]+this.et[0].extents[3])/2;this.clusterMagnetizer.setElements(this.et),this.clusterMagnetizer.executeAtPoint({x:a,y:l},{padding:{x:100,y:100}})}for(let a=0;a<this.et.length;a++)this.et[a].getPositions().forEach((h,d)=>{n(d,h.x,h.y)})}this.done=!0}};c(ad,"type","Balloon");var sd=ad;qe.register(sd.type,sd);var Vs=class{constructor(r){this.model=r}};var Cr="edge",vo="vertex",ld="center",EE=30;function lt(i){return i.type===Cr}function eY(i){return i.type===vo}var hd=class extends Vs{constructor(e,t){super(e);this.vertexSet=t;c(this,"jt",new Map);c(this,"$o",!1);c(this,"kt");c(this,"Ir",[]);c(this,"Vh",new Set);c(this,"ai");this.ai=e.layout.ai}Ng(e){let t=this.model.getAdjacentVertices(e);return t.vertices.filter(n=>this.jt.has(n.id)==!1).filter(n=>t.target.findIndex(o=>o.id===n.id)!==-1?t.source.findIndex(o=>o.id===n.id)===-1:!1).length}Gh(e,t){let n=this.model.getAdjacentVertices(e.id),o=n.vertices;Array.from(n.filteredEdges).forEach(h=>this.Vh.add(h));let s=[],a,l;for(a=0;a<o.length;a++)if(!this.jt.has(o[a].id))if(l=this.model.getVertex(o[a].id),l!=null)if(this.Ng(o[a].id)===0){let d=t+1,u=this.model.getAdjacentVertices(o[a].id).target.filter(p=>this.jt.has(p.id));if(u.length>0){let p=Math.max(...u.map(m=>this.vertexSet.findLayerIndex(m.id)));d=Math.max(d,p+1)}this.vertexSet.addToLayer(d,l),s.push(l),o[a].edges.forEach(p=>{let m={edge:p,id:p.id,sourceNode:e,targetNode:l,rootLayer:-1,targetLayer:-1,span:-1,type:Cr,entries:[]};this.vertexSet.edgeNodes.push(m),this.vertexSet.edgeNodeMap.set(p.id,m)})}else o[a].edges.forEach(d=>{let u={edge:d,id:d.id,sourceNode:e,targetNode:l,rootLayer:-1,targetLayer:-1,span:-1/0,type:Cr,entries:[]};this.vertexSet.edgeNodes.push(u),this.vertexSet.edgeNodeMap.set(d.id,u),this.Ir.push([l,t+1,u])});else this.model.excludedNodes[o[a].id]=!0;for(a=0;a<s.length;a++)this.jt.set(s[a].id,!0),this.Gh(s[a],t+1)}Ig(){let e,t=(o,s)=>o.span>s.span?-1:o.span<s.span?1:o.rootLayer<s.rootLayer?-1:o.rootLayer>s.rootLayer?1:0,n=[];this.vertexSet.edgeNodes.forEach(o=>{o.rootLayer=this.model.getLayer(o.sourceNode),o.targetLayer=this.model.getLayer(o.targetNode),o.rootLayer!=null&&o.targetLayer!=null&&(o.span=o.targetLayer-o.rootLayer,o.span>1&&(n.length===0?n.push(o):t(o,n[0])<=0?n.unshift(o):n.push(o)))});for(let o=0;o<n.length;o++){let s=n[o];if(s.span>1){let l=this.vertexSet.layers[s.rootLayer].entries.filter(u=>!lt(u)),h=l.findIndex(u=>u.obj.id===s.sourceNode.id),d=l.length===1?!1:h<l.length/2;e=this.vertexSet.insertEdgeNodeInLayer(s.rootLayer+1,s,d),this.vertexSet.edgeEntryMap.set(e.id,e);for(let u=s.rootLayer+2;u<s.targetLayer;u++){let p=this.vertexSet.addToLayer(u,s,d);this.vertexSet.edgeEntryMap.set(p.id,p),p.previous=e,e.next=p,e=p}}}}execute(e){for(this.jt.clear(),this.$o=!1,this.kt=0,this.Ir.length=0,this.jt.set(e.id,!0);!this.$o;)if(this.Gh(e,this.kt),this.Ir.length>0)if(this.Ir=this.Ir.filter(t=>!this.jt.has(t[0].id)),this.Ir.length>0){let t=this.Ir.splice(0,1)[0];e=t[0],this.kt=t[1],this.jt.set(e.id,!0),this.vertexSet.addToLayer(this.kt,e)}else this.$o=!0;else this.$o=!0;this.ai&&this.Mg(),this.Ig()}Mg(){let e=this.vertexSet.layers.length-1;if(!(e<=0))for(let t=0;t<e;t++)this.vertexSet.layers[t].entries.filter(s=>!lt(s)&&s.leaf).forEach(s=>{this.vertexSet.removeFromLayer(t,s),this.vertexSet.addToLayer(e,s)})}getFilteredEdges(){return Array.from(this.Vh)}};var fE=i=>{let r=0;for(let e=0;e<i.length;e++){let t=i[e];t.length>0&&t[0].leaf&&r++,t.length>1&&t[t.length-1].leaf&&r++}return r};function KL(i){let r=0;return i.forEach(e=>r+=e[1]),r/i.length}var Gs=class{constructor(r,e,t){this.vertexSet=r;this.getAdjacentEntries=e;c(this,"li");c(this,"ci");t=t||{},this.li=t.maxIterations||24,this.ci=t.maxIterationsWithoutImprovement||5}Vg(){let r=[];for(let e=0;e<this.vertexSet.layers.length;e++)r.push(this.vertexSet.layers[e].entries.slice());return r}execute(){let r=this.Vg(),e=r,t=0,n=this.$h(r),o=fE(e);for(let s=0;s<this.li;s++){let a=this.Gg(s,e),l=this.$h(a);if(l.total<n.total)n=l,t=0,o=fE(a);else if(l.total===n.total){let h=fE(a);h>o&&(n=l,t=0,o=h)}else t++;if(e=a,n.total===0||t>=this.ci)break}this.vertexSet.layers.forEach((s,a)=>{s.entries=n.ordering[a]})}$h(r){let e=0,t=[],n;for(let o=r.length-2;o>-1;o--)n=this.$g(o,r,o+1),t[o]=n,e+=n.length;return{total:e,layers:t,ordering:r}}$g(r,e,t){let n=[],o=e[r],s=e[t],a=new Array(s.length);for(let u=0;u<a.length;u++)a[u]=[];let l=[],h,d=[];for(h=0;h<o.length;h++){let u=o[h],p=h,m=this.getAdjacentEntries(e,t,u),g=[];for(let E=0;E<m.length;E++){let y=m[E][1];g.push(y)}g.sort(function(E,y){return E-y}),l[p]=g}for(h=0;h<l.length;h++)d=d.concat(l[h].map(u=>[h,u]));for(h=0;h<d.length;h++){let u=d[h],p={sourceLayer:r,targetLayer:t,sourceVertex:u[0],targetVertex:u[1]};a[u[1]].push(p);for(let m=u[1]+1;m<a.length;m++)n.push(...a[m])}return n}Gg(r,e){let t=[],n;if(r%2===0){for(n=e.length-1;n>0;n--)t[n]=this.Bh(n,e,!1);t[0]=e[0].slice()}else{for(n=0;n<e.length-1;n++)t[n]=this.Bh(n,e,!0);t[e.length-1]=e[e.length-1].slice()}return t}Bh(r,e,t){let n=e[r],o=n.length,s=[],a=t?r+1:r-1,l={},h;if(o===1)return n;for(h=0;h<o;h++){let d=n[h],u=this.getAdjacentEntries(e,a,d),p=u.filter(g=>!lt(g[0])),m=u.filter(g=>lt(g[0]));m.length>0&&(m.sort((g,E)=>g[0].obj.span>E[0].obj.span?-1:E[0].obj.span>g[0].obj.span?1:0),p.push(m[0])),u.length>0?s.push([d,KL(p)]):(l[d.obj.id]=!0,s.push([d,-1]))}return s.sort((d,u)=>l[d[0].id]||l[u[0].id]?0:d[1]<u[1]?-1:u[1]<d[1]?1:d[0].type===vo&&u[0].type===vo?0:d[0].type===Cr&&u[0].leaf?-1:u[0].type===Cr&&d[0].leaf?1:0),s.map(d=>d[0])}};var aA="xmax",lA="ymax",hA="xmin",cA="ymin",cd="_min",dd="_max",ud=class{constructor(r,e,t,n,o){this.R=r;this.oe=e;this.axis=t;this.ve=n;this.Bg=o;c(this,"hi",{})}execute(){this.hi={};let r=this.Bg(),e={},t=this.axis===0?{[cd]:hA,[dd]:aA}:{[cd]:cA,[dd]:lA},n=this.axis===1?{[cd]:hA,[dd]:aA}:{[cd]:cA,[dd]:lA},o=null;for(let a=0;a<this.oe.layers.length-1;a++){let l=this.oe.layers[a],h=this.oe.layers[a+1],d=Math.min(l[t.be],h[t.be]),p=Math.max(l[t._t],h[t._t])-d,m=this.ve?n.be:n._t,g=this.ve?n._t:n.be,E=l[m],x=h[g]-E,f={id:`r${a}`,type:"channel",axis:this.axis,left:this.axis===0?d:E,top:this.axis===1?d:E,width:this.axis===0?p:x,height:this.axis===1?p:x,lines:[]};this.oe.regions.push(f);for(let b=0;b<l.entries.length;b++){let A=l.entries[b],T=r.getVertexPosition(A.id)||A.loc,S={left:T.x,top:T.y,width:A.size.width,height:A.size.height,type:A.type,id:A.id,lines:[],paddingRegion:null,paddingRegionGate:null,gateDown:null,gateUp:null};this.oe.regions.push(S),this.hi[A.id]=S;let R=S;if(this.axis===0){let v=this.axis===0?S.top+S.height:S.left+S.width,O=this.axis===0?f.top:f.left;if(v<O){let P={left:this.axis===0?T.x:T.x+A.size.width,top:this.axis===0?T.y+A.size.height:T.y,width:this.axis===0?A.size.width:O-v,height:this.axis===0?O-v:A.size.height,type:A.type,id:`${A.id}_pad`,lines:[]};this.oe.regions.push(P),S.paddingRegion=P,S.paddingRegionGate=this.Bo(A,T,S,P,!0),R=P}}S.gateDown=this.Bo(A,T,R,f,!0),o!=null&&(S.gateUp=this.Bo(A,T,o,S,!1))}o=f}let s=this.oe.layers[this.oe.layers.length-1];for(let a=0;a<s.entries.length;a++){let l=s.entries[a],h=r.getVertexPosition(l.id),d={left:h.x,top:h.y,width:l.size.width,height:l.size.height,type:l.type,id:l.id,lines:[],gateUp:null};this.oe.regions.push(d),this.hi[l.id]=d,o!=null&&(d.gateUp=this.Bo(l,h,o,d,!1))}return this.oe.edgeNodes.forEach(a=>{let l=a.edge,h=H(l.source)?l.source.getParent():l.source,d=H(l.target)?l.target.getParent():l.target,u=this.R.entryMap[h.id],p=this.R.entryMap[d.id],m=this.hi[u.id],g=this.hi[p.id],E=[],y=u.layer<p.layer?1:-1;if(u.layer<p.layer){m.paddingRegionGate!=null&&E.push(m.paddingRegionGate),E.push(m.gateDown);for(let f=0;f<a.entries.length;f++){let b=a.entries[f],A=`r${b.layer-1}:${b.id}`;E.push(this.oe.gateMap[A]);let T=`${b.id}:r${b.layer}`;E.push(this.oe.gateMap[T])}E.push(g.gateUp)}else{E.push(m.gateUp);for(let f=a.entries.length-1;f>-1;f--){let b=a.entries[f],A=`${b.id}:r${b.layer}`;E.push(this.oe.gateMap[A]);let T=`r${b.layer-1}:${b.id}`;E.push(this.oe.gateMap[T])}g.paddingRegionGate!=null&&E.push(g.paddingRegionGate),E.push(g.gateDown)}let x={id:l.id,sourceId:l.source.id,targetId:l.target.id,path:E.map(f=>f.id),pathDirection:y};this.oe.edgeRoutingMap[l.id]=x,this.oe.edgeRouting.push(x),e[l.id]=E}),e}Bo(r,e,t,n,o){let s=this.axis===0?e.x:e.y,a=this.axis===0?r.size.width:r.size.height,l=this.axis===0?e.y:e.x,h=this.axis===0?r.size.height:r.size.width,d=this.ve?l+(o?0:h):l+(o?h:0);return this.Fg(t,n,this.axis,{point1:s,point2:s+a},a,d,{x:this.axis===0?s+a/2:d,y:this.axis===0?d:s+a/2})}Fg(r,e,t,n,o,s,a){let l={id:`${r.id}:${e.id}`,a:{type:r.type,id:r.id},b:{type:e.type,id:e.id},axis:t,otherAxisLocation:s,segment:n,length:o,midpoint:a,edges:[]};return this.oe.gates.push(l),this.oe.gateMap[l.id]=l,l}};function qL(i,r){let e=[],t=[],n=[],o={},s={},a={},l=i.getAllEdges(),h=[],d=new Set,u=(p,m)=>{let g=Zn(p.source),y={edge:p,isSource:g===m,sourceVertex:g,targetVertex:Zn(p.target)};return h.push(y),y};Y(i)&&i.getMembers().forEach(p=>{p.getAllEdges().forEach(m=>{(We(m.source,i)&&!We(m.target,i)||We(m.target,i)&&!We(m.source,i))&&u(m,p)})}),r!=null?l.forEach(p=>{r(p)?u(p,i):d.add(p)}):l.forEach(p=>u(p,i));for(let p=0;p<h.length;p++){let m=h[p].isSource?h[p].targetVertex.id:h[p].sourceVertex.id;o[m]||(o[m]={id:m,edges:new Set},e.push(o[m])),o[m].edges.add(h[p].edge),h[p].isSource?(s[m]||(s[m]={id:m,edges:new Set},t.push(s[m])),s[m].edges.add(h[p].edge)):(a[m]||(a[m]={id:m,edges:new Set},n.push(a[m])),a[m].edges.add(h[p].edge))}return{vertices:e,source:t,target:n,filteredEdges:d}}function QL(i){return i.target.length===1&&(i.source.length===0||i.source[0].id===i.target[0].id)}var pd=class{constructor(r,e,t){this.instance=r;this.layout=t;c(this,"Q");c(this,"qr",{});c(this,"At",{});c(this,"Fo",null);c(this,"Fh",[]);c(this,"Uh",new Map);c(this,"xa");c(this,"Ne");c(this,"di");c(this,"pi",[]);c(this,"unattachedRootPadding");c(this,"vertexEntryMap",new Map);c(this,"entryMap",{});c(this,"assignedVertices",new Map);c(this,"axis");c(this,"invert");c(this,"sets",[]);c(this,"excludedNodes",{});c(this,"zh");c(this,"adjacentVertices",{});this.Q=e.padding||{x:50,y:50},this.unattachedRootPadding=e.unattachedRootPadding,this.axis=e.axis,this.invert=e.invert===!0,this.zh=e.setPosition,this.xa=e.getSize,this.Fo=e.rootNode,this.Ne=e.edgeNodeSize,this.di=e.edgeFilter}nextRoot(){let r=this.pi.find(t=>!this.assignedVertices.has(t.id));return r?r.obj:null}getVertex(r){return this.qr[r]}setRootNode(r){this.Fo=r}getLayer(r){return this.getLayerForId(r.id)}getLayerForId(r){return this.assignedVertices.get(r)}getSize(r){return this.At[r.id]}getNodeSizeInMainAxis(r){return this.getSizeInMainAxis(this.getSize(r))}getNodeSizeInOtherAxis(r){return this.getSizeInOtherAxis(this.getSize(r))}Yh(){let r={width:50,height:50};return this.axis===0?r.width=this.Ne:r.height=this.Ne,r}getSizeInMainAxis(r){return this.axis===0?r.width:r.height}getSizeInOtherAxis(r){return this.axis===0?r.height:r.width}getPaddingInMainAxis(){return this.axis===0?this.Q.x:this.Q.y}getPaddingInOtherAxis(){return this.axis===0?this.Q.x:this.Q.y}initialize(){this.pi.length=0,this.Fh.length=0,this.Uh.clear(),this.assignedVertices.clear();let r=this.layout.$vertices.length;if(r>0){let e;for(let t=0;t<r;t++){e=this.layout.$vertices[t],this.At[e.id]=this.xa(e.id),this.qr[e.id]=e;let n=qL(e,this.di);this.adjacentVertices[e.id]=n;let o={obj:e,id:e.id,adjacent:n.vertices,sourceEdges:n.source,targetEdges:n.target,leaf:QL(n),size:this.xa(e.id),type:vo,layer:-1,vertexSet:null};this.pi.push(o),this.vertexEntryMap.set(e.id,o),n.target.length===0&&(this.Fh.push(o),this.Uh.set(e.id,o))}this.pi.sort((t,n)=>{let o=this.Fo?this.Fo.id:"";return t.obj.id===o?-1:n.obj.id===o||t.adjacent.length===0?1:n.adjacent.length===0||t.targetEdges.length<n.targetEdges.length?-1:n.targetEdges.length<t.targetEdges.length?1:t.sourceEdges.length>n.sourceEdges.length?-1:n.sourceEdges.length>t.sourceEdges.length?1:0})}}isEmpty(){return this.pi.length===0}getAdjacentEntries(r,e,t){let n=[];for(let o=0;o<r[e].length;o++)this.areConnected(r[e][o],t)&&n.push([r[e][o],o]);return n}getAdjacentEntriesInLayer(r,e){let t=[];for(let n=0;n<r.length;n++)this.areConnected(r[n],e)&&t.push({entry:r[n],index:n});return t}areConnected(r,e){return lt(r)&&r.obj.edge.source===e.obj||lt(e)&&e.obj.edge.source===r.obj||lt(r)&&r.obj.edge.target===e.obj||lt(e)&&e.obj.edge.target===r.obj||lt(r)&&lt(e)&&(r.next===e||r.previous===e||e.next===r||e.previous===r)?!0:this.areAdjacent(r.obj.id,e.obj.id)}areAdjacent(r,e){let t=this.getAdjacentVertices(r),n=this.getAdjacentVertices(e);return t!=null&&t.vertices.findIndex(o=>o.id===e)!==-1||n!=null&&n.vertices.findIndex(o=>o.id===r)!==-1}getAdjacentVertices(r){return this.adjacentVertices[r]||{vertices:[],source:[],target:[],filteredEdges:new Set}}isLeaf(r){let e=this.vertexEntryMap.get(r);return e!=null?e.leaf:!1}};function Pl(i){return i.parents.length>0?i.parents[0].loc:null}function md(i,r){if(i.parents.length===0)return null;{let e=i.parents[0].size;for(let t=1;t<i.parents.length;t++)e+=r+i.parents[t].size;return e}}function e0(i){return i.parents.length>0?i.parents[0].root===!0:!1}function dA(i){return i.parents.length>0?i.parents[0].childGroup:null}function t0(i){return i.parents.length>0?i.parents[i.parents.length-1].childGroupIndex:null}var gd=class{constructor(r,e){this.model=r;c(this,"un",-1/0);c(this,"pn",1/0);c(this,"Dr");c(this,"Yt");c(this,"ve");c(this,"P",[]);c(this,"Nr",[]);c(this,"ei",{});c(this,"Q");c(this,"J");c(this,"Ct");c(this,"ue");c(this,"ti");c(this,"xe");c(this,"St");c(this,"D");c(this,"ri");c(this,"Ot");c(this,"ni");c(this,"De",[]);c(this,"ne",new Map);c(this,"da",{center:r=>Pl(r)+md(r,this.J)/2-(r.size-this.J)/2,start:r=>Pl(r),end:r=>Pl(r)+md(r,0)-(r.size-this.J)});c(this,"F");c(this,"Pt");c(this,"Xt");c(this,"ii");c(this,"fa",{center:(r,e,t)=>(e+t)/2-md(r,0)/2,start:(r,e,t)=>e,end:(r,e,t)=>e});this.Dr=Array.isArray(e.rootNode)?e.rootNode:[e.rootNode],this.Yt=e.compress===!0,this.St=e.absoluteBacked===!0,this.F=e.idFunction,this.Pt=e.sizeFunction,this.Xt=e.childVerticesFunction,this.ii=e.absolutePositionFunction,this.ue=e.axisIndex,this.xe=this.ue!==1,this.ti=this.ue===0?1:0,this.ri=this.xe?fe:Q,this.Ot=this.xe?Te:De,this.ni=this.xe?De:Te,this.ve=e.invert===!0,this.D=e.alignment||ld,this.Q=e.padding,this.J=this.xe?this.Q.x:this.Q.y,this.Ct=this.xe?this.Q.y:this.Q.x}execute(){let r,e,t;for(let n=0;n<this.Dr.length;n++){r=this.Dr[n];let o=this.Pt(r.id),s=this.Qe(r,o,0,null,null),a=0;s.root=!0,a=this.oi(s,0);let l=0,h,d,u=(m,g)=>this.Yt&&m.parents&&m.parents.length>0?this.ne.get(this.F(m.parents[0].node)).position[this.ri]+this.ua(m,this.ti)+this.Ct:g,p=!1;if(a===0&&this.St===!0){let m=this.ii(r);!isNaN(m.x)&&!isNaN(m.y)&&(this.si(r.id,m,0),p=!0)}if(!p)for(e=0;e<this.P.length;e++){for(this.P[e].otherAxis=l,t=0;t<this.P[e].entries.length;t++)h=this.ue===0?this.P[e].entries[t].loc:u(this.P[e].entries[t],l),d=this.ue===1?this.P[e].entries[t].loc:u(this.P[e].entries[t],l),this.si(this.F(this.P[e].entries[t].node),{x:h,y:d},e);this.ve?e<this.P.length-1&&(this.P[e].otherAxisSize=this.De[e+1]+this.Ct,l-=this.P[e].otherAxisSize):(this.P[e].otherAxisSize=this.De[e]+this.Ct,l+=this.P[e].otherAxisSize)}}return this.ne}si(r,e,t){this.ne.set(r,{position:e,layer:t});let n=this.Pt(r),o=this.ue===0?e.x+n.width:e.y+n.height,s=this.ue===0?e.x:e.y;this.un=Math.max(this.un,o),this.pn=Math.min(this.pn,s)}dt(r){let e=this.P[r];return e||(e={entries:[],pointer:0,otherAxis:null,otherAxisSize:null},this.P[r]=e),e}Qe(r,e,t,n,o){let s=this.dt(t),a={node:r,parents:n==null?[]:[n],childGroup:o,childGroupIndex:o==null?void 0:o.nodes.length,loc:s.pointer,index:s.entries.length,dimensions:e,size:e[this.Ot],children:[]},l=e[this.ni];return this.De[t]==null?this.De[t]=l:this.De[t]=Math.max(this.De[t],l),s.pointer+=e[this.Ot]+(r.type===Cr?0:this.J),s.entries.push(a),n&&n.children.push(a),a}pa(r,e){let t=this.Nr[e];t||(t=[],this.Nr[e]=t),r.index=t.length,t.push(r)}ma(r,e){if(r.parents.length>0){let t=e-r.parents[0].loc;for(let s=0;s<r.parents.length;s++)r.parents[s].loc+=t;let n=r.parents[r.parents.length-1],o=this.dt(r.depth-1);o.pointer=Math.max(o.pointer,n.loc+n.size+this.J)}}ua(r,e){let t=r.parents.map(n=>n.dimensions[e===0?Te:De]);return Math.max.apply(null,t)}ga(r){if(r.size>0){let e=this.da[this.D](r),t=this.Nr[r.depth],n=this.D==="end"?1/0:-1/0,o=0;if(t!=null&&t.length>0){let d=t[t.length-1],u=d.nodes[d.nodes.length-1];n=this.D==="end"?u.loc-r.size:u.loc+u.size+this.J}this.D!=="end"&&e>=n||this.D==="end"&&e<=n?r.loc=e:(o=n-e,r.loc=n);let s=r.loc,a=this.D==="end"?r.nodes.length-1:0,l=this.D==="end"?-1:r.nodes.length,h=this.D==="end"?-1:1;for(let d=a;d!==l;d+=h)r.nodes[d].loc=s,s+=r.nodes[d].size,s+=this.J;o!==0&&this.Ea(r),this.pa(r,r.depth)}}ya(r){let e=r.nodes[0].loc,t=r.nodes[r.nodes.length-1].loc+r.nodes[r.nodes.length-1].size,n=this.fa[this.D](r,e,t),o=n-Pl(r);if(this.ma(r,n),!e0(r)){let s=dA(r),a=t0(r);for(let l=a+1;l<s.nodes.length;l++)s.nodes[l].loc+=o}}Ea(r){let e=r;for(;e!=null;)this.ya(e),e=dA(e)}oi(r,e){if(this.ei[r.node.id])return;this.ei[r.node.id]=!0;let t={nodes:[],loc:0,size:0,parents:[r],depth:e+1,children:[],index:-1,id:V()},n=[],o,s={},a=this.dt(e+1),l=this.Xt(r.node,e,this.model);for(o=0;o<l.length;o++){let h=l[o];if(h!=null&&h!==r.node&&!s[h.id]){let d=this.Pt(this.F(h)),u=a.entries.find(p=>this.F(p.node)===this.F(h));if(u!=null){u.parents.push(r);let p=u.loc+u.size/2,m=Pl(u),g=md(u,this.J),E=m+g/2,y=E-p;y>0&&this.Ug(u,y,r)}else{let p=this.Qe(h,d,e+1,r,t);t.nodes.push(p);let m=d[this.Ot];t.size+=m+this.J,n.push(p)}s[h.id]=!0}}for(this.ga(t),o=0;o<n.length;o++)this.oi(n[o],e+1);return l.length}Ug(r,e,t){let n={},o=s=>{let a=s.childGroup;if(n[a.id]!==!0){n[a.id]=!0;let l=s.childGroupIndex;for(let h=l;h<a.nodes.length;h++)a.nodes[h].loc+=e;l===0?a.loc+=e:a.size+=e}s.children.forEach(o)};o(r)}};var Ed=class extends Vs{constructor(e,t,n){super(e);this.model=e;this.vertexSet=t;c(this,"Ht");c(this,"kt");c(this,"Q");c(this,"mn");c(this,"gn");c(this,"D");c(this,"Ne");c(this,"mi");n=n||{},this.Q=n.padding||{x:50,y:50},this.mn=n.unattachedRootPadding||150,this.Ht=n.lastPlacements,this.gn=n.strategy||"parent",this.Ne=n.edgeNodeSize,this.mi=n.gatherUnattachedRoots,this.D=n.alignment||"center"}zg(e,t){return{mainAxis:(e.length-1)*t+e.reduce((n,o)=>lt(o)?n+this.Ne:n+this.model.getSizeInMainAxis(o.size),0),otherAxis:e.reduce((n,o)=>Math.max(n,this.model.getSizeInOtherAxis(o.size)),0)}}execute(e){let t=0,n,o=this.model.getPaddingInMainAxis(),s=this.model.getPaddingInOtherAxis(),a=this.model.axis,l=this.Ht?this.Ht.maximumPointer+o:0,h=this.vertexSet.layers,d=l,u=h.map(g=>this.zg(g.entries,o)),p={rootId:e.id,rootSize:this.model.getNodeSizeInMainAxis(e),maximumPointer:d,rootPosition:d,biggestLayer:Math.max(...u.map(g=>g.mainAxis))},m=this.model.getNodeSizeInMainAxis(e);return n=this.gn==="center"?(p.biggestLayer-m)/2:this.gn==="start"?0:p.biggestLayer-m,h.length>0&&(this.model.invert?t-=u[0].otherAxis+2*s:t+=this.model.getNodeSizeInOtherAxis(e)+2*s,this.gn==="parent"?this.Yg(p,l):this.Xg(h,n,a,p,l,t,u,o,s)),p.maximumPointer=Math.max(p.maximumPointer,p.rootPosition+p.rootSize+o),p}Xg(e,t,n,o,s,a,l,h,d){let u=s,p;for(let m=0;m<e.length;m++){this.kt=e[m],t=this.gn==="center"?(o.biggestLayer-l[m].mainAxis)/2:this.gn==="start"?0:o.biggestLayer-l[m].mainAxis,u=s;for(let g=0;g<this.kt.entries.length;g++){p=this.kt.entries[g];let E=t+u,y=a,x=n===0?E:y,f=n===0?y:E;if(lt(p)){let b=n===0?this.Ne:y,A=n===0?y:this.Ne;p.loc={x,y:f,w:b,h:A},u+=this.Ne+h}else this.vertexSet.setPosition(p.obj,x,f,m),u+=this.model.getSizeInMainAxis(p.size)+h}o.maximumPointer=Math.max(o.maximumPointer,u),m<e.length-1&&(this.model.invert?a-=l[m+1].otherAxis+2*d:a+=l[m].otherAxis+2*d)}}Yg(e,t){let n=new gd(this.model.layout.instance,{rootNode:this.vertexSet.layers[0].entries,padding:this.Q,axisIndex:this.model.axis,invert:this.model.invert,alignment:this.D,idFunction:d=>this.model.layout.instance.getNodeId(d),sizeFunction:d=>this.model.entryMap[d].size,childVerticesFunction:(d,u,p)=>{let m=[];if(u<this.vertexSet.layers.length-1){let g=this.model.getAdjacentEntriesInLayer(this.vertexSet.layers[u+1].entries,d).map(E=>E.entry);m.push(...g)}return m},absoluteBacked:this.model.layout.absoluteBacked,absolutePositionFunction:d=>this.model.layout.getAbsolutePosition(d,this.model.layout.parameters)}),o=n.execute(),s=n.un,a=n.pn,l=0,h=0;if(this.mi&&o.size===1&&this.Ht!=null){let d=this.Ht.rootPosition+this.Ht.rootSize+this.mn;o.get(e.rootId).position[this.model.axis===0?"x":"y"]=d,e.maximumPointer=d+e.rootSize}else if(this.Ht){let d=this.Ht.maximumPointer-a;this.model.axis===0?l=d:h=d}o.forEach((d,u)=>{this.vertexSet.setPositionById(u,d.position.x+l,d.position.y+h,d.layer),u===e.rootId&&(e.rootPosition=this.model.axis===0?d.position.x+l:d.position.y+h)}),e.maximumPointer=t+(s-a)}};var fd=class{constructor(r,e){this.R=r;this.index=e;c(this,"layers",[]);c(this,"regions",[]);c(this,"gateMap",{});c(this,"edgeNodes",[]);c(this,"edgeNodeMap",new Map);c(this,"gates",[]);c(this,"edgeRoutingMap",{});c(this,"edgeRouting",[]);c(this,"Xh",[]);c(this,"edgeEntryMap",new Map)}addToLayer(r,e,t){let n=this.jh(r),o=lt(e),s;return o?(s={id:V(),obj:e,previous:null,size:this.R.Yh(),next:null,leaf:!1,type:Cr,layer:r,vertexSet:this},e.entries.push(s)):(s=this.R.vertexEntryMap.get(e.id),s.layer=r,s.vertexSet=this),this.R.entryMap[s.id]=s,t?n.entries.unshift(s):n.entries.push(s),this.R.assignedVertices.set(e.id,r),this.Xh.push(s),s}findLayerIndex(r){var e;return(e=this.Xh.find(t=>t.id===r))==null?void 0:e.layer}insertEdgeNodeInLayer(r,e,t){let n=this.jh(r),o=this.R.Yh();this.R.assignedVertices.set(e.id,r);let s={id:V(),obj:e,size:o,leaf:!1,type:Cr,layer:r,vertexSet:this};e.entries.push(s),this.R.entryMap[s.id]=s;let a=t?1:-1,l=t?0:n.entries.length-1,h=null;for(;h==null&&l>=0&&l<n.entries.length;)lt(n.entries[l])?n.entries[l].obj.span<e.span&&(h=l):h=l,l+=a;let d=h!=null?t?h:h+1:t?0:n.entries.length;return n.entries.splice(d,0,s),s}removeFromLayer(r,e){let t=this.layers[r];t.entries.splice(t.entries.indexOf(e),1),this.R.assignedVertices.delete(e.id)}setPositionById(r,e,t,n){if(!this.R.layout.absoluteBacked)this.En(r,e,t,n);else{let o=this.R.layout.model.getVertex(r),s=this.R.layout.getAbsolutePosition(o);s.x!=null&&s.y!=null&&!isNaN(s.x)&&!isNaN(s.y)?this.En(r,s.x,s.y,n):this.En(r,e,t,n)}}setPosition(r,e,t,n){if(!this.R.layout.absoluteBacked)this.En(r.id,e,t,n);else{let o=this.R.layout.getAbsolutePosition(r);o.x!=null&&o.y!=null&&!isNaN(o.x)&&!isNaN(o.y)?this.En(r.id,o.x,o.y,n):this.En(r.id,e,t,n)}}jh(r){return this.layers[r]==null&&(this.layers[r]={layer:r,entries:[],xmin:1/0,ymin:1/0,xmax:-1/0,ymax:-1/0}),this.layers[r]}En(r,e,t,n){this.R.zh(r,e,t,n);let o=this.layers[n],s=this.R.vertexEntryMap.get(r)||this.edgeEntryMap.get(r);if(s){let a=e+s.size.width,l=t+s.size.height;o.xmin=Math.min(o.xmin,e),o.ymin=Math.min(o.ymin,t),o.xmax=Math.max(o.xmax,a),o.ymax=Math.max(o.ymax,l)}}};var uA="Hierarchy",Co=class extends Jn{constructor(e){super(e);c(this,"type",uA);c(this,"axis");c(this,"model");c(this,"mn");c(this,"ci");c(this,"li");c(this,"ve");c(this,"mi");c(this,"kh");c(this,"dn");c(this,"Hh");c(this,"D");c(this,"Wh");c(this,"ai");c(this,"Ne");c(this,"di");c(this,"ba");c(this,"routingInformation");c(this,"resultSets",[]);this.mn=e.options.unattachedRootPadding==null?150:e.options.unattachedRootPadding,this.axis=e.options.axis?e.options.axis==="horizontal"?0:1:0,this.ci=e.options.maxIterationsWithoutImprovement||5,this.li=e.options.maxIterations||24,this.Hh=e.options.rootNode,this.dn=e.options.getRootNode,this.Wh=e.options.placementStrategy,this.Ne=e.options.edgeNodeSize||EE,this.ve=e.options.invert===!0,this.mi=e.options.gatherUnattachedRoots===!0,this.D=e.options.alignment||ld,this.kh=e.options.generateRouting===!0,this.di=e.options.edgeFilter,this.ba=e.options.filteredEdgeProcessor,this.ai=e.options.leavesAtBottom}begin(e,t,n,o,s){this.resultSets.length=0;let a=this.dn?this.dn():this.Hh;this.model=new pd(e,{getSize:l=>this.getSize(l,o),axis:this.axis,padding:this.padding,setPosition:n,rootNode:a,invert:s.invert===!0,unattachedRootPadding:this.mn,edgeNodeSize:this.Ne,edgeFilter:this.di},this),this.model.initialize()}end(e,t,n,o,s){}reset(){}getDefaultParameters(){return{padding:{x:50,y:50},unattachedRootPadding:150,axis:"horizontal",maxIterations:24,maxIterationsWithoutImprovement:2,placementStrategy:"parent",alignment:"center",edgeNodeSize:EE}}step(e,t,n,o,s){let a=0;if(!this.model.isEmpty()){let l=this.model.nextRoot(),h=null;for(;l!=null;){let d=new fd(this.model,a++);d.addToLayer(0,l),this.model.sets.push(d);let u=new hd(this.model,d);u.execute(l),new Gs(d,(g,E,y)=>this.model.getAdjacentEntries(g,E,y),{maxIterations:this.li,maxIterationsWithoutImprovement:this.ci}).execute(),h=new Ed(this.model,d,{padding:this.padding,strategy:this.Wh,edgeNodeSize:this.Ne,lastPlacements:h,gatherUnattachedRoots:this.mi,unattachedRootPadding:this.mn,alignment:this.D}).execute(l);let p=[];if(d.layers.flatMap(g=>g.entries.map(E=>{if(lt(E)){p.push(E);let y=this.axis===0?g.ymax-g.ymin:g.xmax-g.xmin;this.axis===0?E.size.height=y:E.size.width=y}})),this.ba){let g=u.getFilteredEdges().map(E=>{let y=this.model.entryMap[E.source.id],x=this.model.entryMap[E.target.id],f=d.layers[y.layer].entries.findIndex(A=>A.id===y.id),b=d.layers[x.layer].entries.findIndex(A=>A.id===x.id);return{sourceEntry:y,sourceEntryIndex:f,targetEntry:x,targetEntryIndex:b,edge:E}});this.ba(g,this)}let m={};this.kh&&(this.routingInformation=this.model.sets.map(g=>{let E={gates:g.gates,edges:g.edgeRouting,edgeMap:g.edgeRoutingMap,regions:g.regions,getVertexPosition:y=>t(y),getVertexSize:y=>o[y]};return new ud(this.model,d,this.axis,this.ve,()=>E).execute(),E})),this.resultSets.push({node:l,edgeNodes:p,paths:m}),l=this.model.nextRoot()}}this.done=!0}getRoutingInformation(){return this.routingInformation}};c(Co,"type",uA),qe.register(Co.type,Co);var yd=class{constructor(r){this.color=r}generate(r){return this.color}},Qn=class i{constructor(r,e,t){this.r=r;this.g=e;this.b=t}toString(){return`rgb(${this.r}, ${this.g}, ${this.b})`}static fromString(r){if(r.startsWith("#")){let e=r.substring(1);e.length===3&&(e=[e[0],e[0],e[1],e[1],e[2],e[2]].join(""));let t=parseInt(e.substring(0,2),16),n=parseInt(e.substring(2,4),16),o=parseInt(e.substring(4,6),16);return new i(t,n,o)}else if(r.startsWith("rgb")){let e=r.match(/\d+/g);if(e&&e.length>=3)return new i(parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10))}else{let e=r0(r);return i.fromString(e)}}};function r0(i){let r=document.createElement("div");r.style.color=i,document.body.appendChild(r);let e=getComputedStyle(r).color;return document.body.removeChild(r),e}function pA(){return new Qn(Math.floor(Math.random()*225+20),Math.floor(Math.random()*225+20),Math.floor(Math.random()*225+20))}var $s=class{constructor(){c(this,"assignedColors",[])}generate(r){let n=0,o=pA(),s=this.assignedColors.find(a=>gA(a,o)<20);for(;s!=null&&n<10;)o=pA(),s=this.assignedColors.find(a=>gA(a,o)<20),n++;return this.assignedColors.push(o),o.toString()}reset(){this.assignedColors.length=0}},mA=class{constructor(...r){c(this,"colors");c(this,"counter",0);this.colors=r}generate(r){let e=this.colors[this.counter];return this.counter++,this.counter>=this.colors.length&&(this.counter=0),e}};function gA(i,r){let e=(i.r+r.r)/2,t=i.r-r.r,n=i.g-r.g,o=i.b-r.b;return Math.sqrt(((512+e)*t*t>>8)+4*n*n+((767-e)*o*o>>8))}function xd(i){let r=z(i)?Qn.fromString(i):i;return(.2126*r.r+.7152*r.g+.0722*r.b)/255>.5?new Qn(Math.floor(r.r*.3),Math.floor(r.g*.3),Math.floor(r.b*.3)):new Qn(Math.min(255,Math.floor(r.r+(255-r.r)*.7)),Math.min(255,Math.floor(r.g+(255-r.g)*.7)),Math.min(255,Math.floor(r.b+(255-r.b)*.7)))}function tj(i){let r=z(i)?Qn.fromString(i):i;return(.2126*r.r+.7152*r.g+.0722*r.b)/255>.5?new Qn(0,0,0):new Qn(255,255,255)}var yE="empty",n0=[{dx:0,dy:-1,axis:he,directionFromParent:-1},{dx:1,dy:0,axis:ne,directionFromParent:1},{dx:0,dy:1,axis:he,directionFromParent:1},{dx:-1,dy:0,axis:ne,directionFromParent:-1},{dx:-1,dy:-1,axis:bn,directionFromParent:-1},{dx:1,dy:-1,axis:qn,directionFromParent:-1},{dx:1,dy:1,axis:bn,directionFromParent:1},{dx:-1,dy:1,axis:qn,directionFromParent:1}],i0=[{dx:0,dy:-1,axis:he,directionFromParent:-1},{dx:1,dy:0,axis:ne,directionFromParent:1},{dx:0,dy:1,axis:he,directionFromParent:1},{dx:-1,dy:0,axis:ne,directionFromParent:-1}],EA=(i,r,e,t)=>i0.filter(n=>n.axis!==e||n.directionFromParent===t),xE=(i,r,e,t)=>{let n=[];switch(e){case qn:n.push({x:-t,y:0}),n.push({x:-t,y:t}),n.push({x:0,y:t});break;case bn:n.push({x:t,y:0}),n.push({x:t,y:t}),n.push({x:0,y:t});break;case ne:n.push({x:t,y:-1}),n.push({x:t,y:0}),n.push({x:t,y:1});break;case he:n.push({x:-1,y:t}),n.push({x:0,y:t}),n.push({x:1,y:t});break}return n0.filter(o=>n.find(s=>s.x===o.dx&&s.y===o.dy))};var Fs=class{constructor(r,e,t,n,o,s){this.gridCellSize=t;this.vertexBorder=n;this.vertexBuffer=o;this.getCoincidentObstacles=s;c(this,"ut",{});c(this,"gi");c(this,"Zh");c(this,"sourceId");c(this,"targetId");c(this,"sourceObstacles",[]);c(this,"targetObstacles",[]);c(this,"sourceBuffers",[]);c(this,"targetBuffers",[]);c(this,"sourceAxis");c(this,"sourceDirection");c(this,"targetAxis");c(this,"targetDirection");this.gi={x:Math.min(r.x,e.x),y:Math.min(r.y,e.y)},this.Zh=t*(n+o)}Uo(r,e){return{x:Math.floor((r-this.gi.x)/this.gridCellSize),y:Math.floor((e-this.gi.y)/this.gridCellSize)}}jg(r){let e=this.Uo(r.x,r.y),t=this.Uo(r.x+r.width,r.y+r.height);return{x:e.x,y:e.y,width:t.x-e.x,height:t.y-e.y}}kg(r,e){let t=r*this.gridCellSize,n=e*this.gridCellSize,o=this.gi.x+t,s=this.gi.y+n;return{x:o,y:s,width:this.gridCellSize,height:this.gridCellSize}}makeKey(r,e){return`${r}_${e}`}Hg(r){return this.sourceObstacles.indexOf(r)!==-1||this.sourceBuffers.indexOf(r)!==-1||this.targetObstacles.indexOf(r)!==-1||this.targetBuffers.indexOf(r)!==-1}Wg(r,e,t,n){let o=this.makeKey(r,e);if(this.ut[o]==null){let s=this.kg(r,e),a=s.x,l=s.y,h=this.getCoincidentObstacles(a,l,this.Zh),d=[],u=[],p=!1,m=!1;h.forEach(g=>{if(!p&&(this.sourceId===g.id||this.sourceObstacles.indexOf(g.id)!==-1)&&(p=!0),!m&&(this.targetId===g.id||this.targetObstacles.indexOf(g.id)!==-1)&&(m=!0),!this.Hg(g.id)){let E=fb(this.jg(g),this.vertexBorder,this.vertexBorder);u.push(g.id),E.x<=r&&E.x+E.width>=r&&E.y<=e&&E.y+E.height>=e&&d.push(g.id)}}),this.ut[o]={key:o,f:0,g:1/0,h:null,opened:!1,closed:!1,x:r,y:e,cx:a,cy:l,ax:t,ay:n,parent:null,fixedAxis:null,directionFromParent:null,obstacles:d,buffers:u,hasSourceObstacles:p,hasTargetObstacles:m}}else t&&(this.ut[o].ax=t),n&&(this.ut[o].ay=n);return this.ut[o]}setSourceCell(r,e,t,n,o,s,a){this.sourceId=r;let l=this.getCell(e,t,n,o);return this.sourceObstacles=l.obstacles.slice(),this.sourceBuffers=l.buffers.slice(),this.sourceAxis=s,this.sourceDirection=a,l.opened=!0,l.g=0,l.f=0,l.fixedAxis=s,l.directionFromParent=a,l}setTargetCell(r,e,t,n,o,s,a){this.targetId=r;let l=this.getCell(e,t,n,o);return this.targetObstacles=l.obstacles.slice(),this.targetBuffers=l.buffers.slice(),this.targetAxis=s,this.targetDirection=a,l.fixedAxis=s,l.directionFromParent=this.targetDirection,l}get sourceAndTargetObstacles(){let r=this.sourceObstacles.slice(),e=this.targetObstacles.slice();return r.push(...e),r}getCell(r,e,t,n){return this.Wg(r,e,t,n)}reinitialize(){Object.entries(this.ut).forEach(r=>{r[1].f=0,r[1].g=1/0,r[1].h=null,r[1].closed=!1,r[1].opened=!1,r[1].parent=null,r[1].directionFromParent=null,r[1].ax=null,r[1].ay=null,r[1].fixedAxis=null}),this.sourceObstacles.length=0,this.sourceBuffers.length=0,this.targetObstacles.length=0,this.targetBuffers.length=0}};function Bs(i,r){return i===0&&r===0?void 0:i===0&&r!==0?he:i!==0&&r===0?ne:Math.sign(r)===Math.sign(i)?bn:qn}function fA(i,r,e){return e==null?0:e===ne?i>0?1:-1:e===he?r>0?1:-1:e===bn?i>0&&r>0?1:-1:i<0&&r>0?1:-1}function bE(i){let r=Bs(i.ox,i.oy);return{axis:r,direction:fA(i.ox,i.oy,r)}}function yA(i,r){let e=Math.abs(r.x-i.x),t=Math.abs(r.y-i.y);return e>t?ne:he}function Ir(i){if(i.parent==null)return i.fixedAxis;{let r=Math.sign(i.parent.x-i.x),e=Math.sign(i.parent.y-i.y);return Bs(r,e)}}function xA(i){if(i.parent==null)return i.directionFromParent;{let r=Math.sign(i.x-i.parent.x),e=Math.sign(i.y-i.parent.y),t=Bs(r,e);return fA(r,e,t)}}function o0(i,r,e){if(r.f<e.f)return-1;if(e.f<r.f)return 1;if(r.h<e.h)return-1;if(e.h<r.h)return 1;{let t=Ir(i);return Ir(r)===t?-1:Ir(e)===t?1:0}}var bd=class{constructor(){c(this,"node")}sort(r,e){return o0(this.node,r,e)}};var jt="group:added",wi="group:member:added",Us="group:member:removed",Ge="group:removed",Po="dataLoadStart",AE="dataAppendStart",Mr="dataLoadEnd",SE="dataAppendEnd",TE="dataUpdated",Sn="graphClearStart",Ht="graphCleared",bA="graphChanged",Re="group:updated",$e="node:updated",ur="port:updated",pt="edge:updated",pr="edge:added",kt="node:added",mt="edge:removed",Le="node:removed",ei="port:added",Vr="port:removed",on="edge:target",sn="edge:source",mr="select",gr="deselect",Pr="selection:cleared",ti="edge:geometry",ri="edge:pathEdited",Ad="edge:typeChanged",Sd="node:typeChanged",Td="port:typeChanged",vd="group:typeChanged",AA="group:move:start",Cd="group:move",Gr="group:move:end",Pd="internal:group:sizeChanged",Od="internal:group:sizeChangedRedo",_d="internal:group:sizeChangedUndo",SA="renderer:added",Ys="node:move:start",ir="node:move",Dt="node:move:end",zs="undoredo:update",TA="undo",vA="redo",Di="destroy";var s0=[kt,ei,pr,jt,Le,Vr,mt,Ge,$e,ur,pt,Re,Dt,Gr,sn,on,wi,Us],Oo=(i,r,e)=>{i.instance.bind(r,e),i.bindings.push([r,e])},Ol=class{constructor(r,e){this.instance=r;c(this,"bindings",[]);c(this,"zo",null);if(e.saveUrl==null&&e.autoSaveHandler==null)throw new Error("VisuallyJs autosave: neither saveUrl nor autoSaveHandler was specified");function t(a){return function(){a&&a.apply(a,arguments),e.onAfterAutoSave&&e.onAfterAutoSave()}}let n=!1,o=function(){if(!n){try{e.onBeforeAutoSave&&e.onBeforeAutoSave()}catch(a){}e.autoSaveHandler!=null?e.autoSaveHandler(r):r.save({type:e.type||Xt,url:e.saveUrl,success:t(e.onAutoSaveSuccess),error:t(e.onAutoSaveError),headers:e.saveHeaders})}},s=()=>{e.debounceTimeout==null?o():this.zo==null?this.zo=setTimeout(o,e.debounceTimeout):(clearTimeout(this.zo),this.zo=setTimeout(o,e.debounceTimeout))};Oo(this,Po,()=>{n=!0}),Oo(this,Mr,()=>{n=!1}),Oo(this,Sn,()=>{n=!0}),Oo(this,Ht,()=>{n=!1}),Oo(this,TE,s),Oo(this,ri,s)}discard(){this.bindings.forEach(r=>this.instance.unbind(r[0],r[1])),this.bindings.length=0}},Rd=class{constructor(r){this.instance=r;c(this,"bindings",[]);let e=()=>{r.fire(TE)};s0.forEach(t=>Oo(this,t,e))}};var CA="mixed",Ld="isolated",PA="nodesOnly",OA="groupsOnly",_A="edgesOnly",_o=class _o extends $t{constructor(e,t){super();this.instance=e;c(this,"Wt",1/0);c(this,"Jh",1/0);c(this,"Kh",1/0);c(this,"se",[]);c(this,"K",[]);c(this,"q",[]);c(this,"capacityPolicy");c(this,"generator");c(this,"onReload");c(this,"onBeforeReload");c(this,"onClear");c(this,"autoFill");c(this,"Ie",{});c(this,"Mr");c(this,"Yo",!1);c(this,"edgeFactory");t=t||{},this.edgeFactory=e.edgeFactory,this.generator=t.generator,this.onReload=t.onReload,this.onBeforeReload=t.onBeforeReload,this.autoFill=t.autoFill===!0,this.onClear=t.onClear||function(){},this.Mr=t.mode||CA,this.instance.bind(Le,n=>{this.Rt(n.node)}),this.instance.bind(Ge,n=>{this.Rt(n.group)}),this.instance.bind(Vr,n=>{this.Rt(n.port)}),this.instance.bind(mt,n=>{this.Rt(n.edge)}),this.instance.bind(on,n=>{this.Ie[n.edge.getFullId()]&&this.fire(on,n)}),this.instance.bind(sn,n=>{this.Ie[n.edge.getFullId()]&&this.fire(sn,n)}),this.instance.bind(kt,n=>{this.generator&&this.autoFill&&!this.Yo&&this.reload()}),this.instance.bind(jt,n=>{this.generator&&this.autoFill&&!this.Yo&&this.reload()}),this.instance.bind($e,n=>{this.Ie[n.vertex.getFullId()]&&this.fire($e,n)}),this.instance.bind(Re,n=>{this.Ie[n.vertex.getFullId()]&&this.fire(Re,n)}),this.instance.bind(pt,n=>{this.Ie[n.edge.getFullId()]&&this.fire(pt,n)}),this.instance.bind(ur,n=>{n.port!=null&&this.Ie[n.port.getFullId()]&&this.fire(ur,n)}),this.instance.bind(Ht,()=>{this.clear()}),this.instance.bind(Mr,()=>{this.reload()}),this.setCapacityPolicy(_o.DISCARD_EXISTING),t.lazy!==!0&&this.reload()}isEmpty(){return this.se.length===0&&this.K.length===0&&this.q.length===0}qh(e){return e.objectType===Fe.objectType?this.q:e.objectType===de.objectType?this.se:this.K}setMode(e){this.Mr=e,e===Ld?this.Zg():e===_A?this.Qh():e===PA?(this.Aa(),this.ed()):e===OA&&(this.Aa(),this.td())}Jg(e){let t=[],n=this.qh(e),o=e.objectType===Fe.objectType?this.Jh:e.objectType===de.objectType?this.Wt:this.Kh;if(n.length>=o){if(this.capacityPolicy===_o.DISCARD_NEW)return!1;t=n.splice(0,1),this.Sa(t[0],":removed"),delete this.Ie[t[0].getFullId()]}return n.push(e),this.Sa(e,":added"),t}Sa(e,t){let n=e.objectType.toLowerCase()+t,o={Group:s=>({data:s.data,group:s}),Node:s=>({data:s.data,node:s}),Port:s=>({data:s.data,node:s.getParent(),port:s}),Edge:s=>({data:s.data,edge:s})};this.fire(n,o[e.objectType](e))}rd(e,t){if(this.Kg(e)&&!this.Ie[e.getFullId()]){let n=this.Jg(e);return n===!1?[[],[]]:(this.Ie[e.getFullId()]=e,t&&t(e,!0),[[e],n])}return[[],[]]}Kg(e){return this.Mr===CA||this.Mr===PA&&e.objectType===de.objectType||this.Mr===OA&&e.objectType===le.objectType||this.Mr===_A&&e.objectType===Fe.objectType?!0:this.Mr===Ld?e.objectType===Fe.objectType?this.se.length===0&&this.K.length===0:this.q.length===0:!1}Rt(e,t){let n=e.getFullId();return Lt(this.qh(e),s=>s.getFullId()==n)?(delete this.Ie[e.getFullId()],t&&t(e,!1),this.Sa(e,":removed"),[[],[e]]):[[],[]]}qg(e,t){return this.Ie[e.getFullId()]?this.Rt(e,t):this.rd(e,t)}Ta(e,t,n){let o=[],s=[],a;if(e==null)return o;let l=h=>{let d;if(z(h))d=this.instance.getNode(h)||this.instance.getEdge(h)||this.instance.getGroup(h),d!=null&&(a=t(d,n),o.push.apply(o,a[0]),s.push.apply(s,a[1]));else if(h.eachVertex&&h.eachEdge)h.eachVertex((u,p)=>{l(p)}),h.eachEdge((u,p)=>{l(p)});else if(h.ze)h.each((u,p)=>{l(p.vertex||p)});else if(h.length!=null)for(let u=0;u<h.length;u++)l(h[u]);else a=t(h,n),o.push.apply(o,a[0]),s.push.apply(s,a[1])};return l(e),[o,s]}remove(e,t){return this.Ta(e,this.Rt.bind(this),t)}append(e,t){return this.Ta(e,this.rd.bind(this),t)}toggle(e,t){return this.Ta(e,this.qg.bind(this),t)}setMaxNodes(e){this.Wt=e}setMaxGroups(e){this.Kh=e}setMaxEdges(e){this.Jh=e}setCapacityPolicy(e){this.capacityPolicy=e}Aa(){for(let e=this.q.length,t=0;t<e;t++)this.Rt(this.q[0])}td(){for(let e=this.se.length,t=0;t<e;t++)this.Rt(this.se[0])}ed(){for(let e=this.K.length,t=0;t<e;t++)this.Rt(this.K[0])}Qh(){this.td(),this.ed()}Zg(){this.Qh(),this.Aa()}clear(e){this.se.length=0,this.q.length=0,this.K.length=0,this.Ie={},this.fire(Sn),e||this.onClear(this)}nd(e){let t=[];for(let n=0;n<e.length;n++)this.Ie[e[n].getId()]!=null&&t.push(e[n]);return t}reload(){this.generator!=null&&(this.onBeforeReload&&this.onBeforeReload(),this.clear(),this.Yo=!0,this.fire(Po,{}),this.generator(this,this.instance),this.fire(Mr,{}),this.onReload&&this.onReload(),this.Yo=!1)}ze(e,t){let n=t===Fe.objectType?this.q:t===le.objectType?this.K:this.se;for(let o=0;o<n.length;o++)try{e(o,n[o])}catch(s){}}eachNode(e){this.ze(e,de.objectType)}eachGroup(e){this.ze(e,le.objectType)}eachVertex(e){this.ze(e,de.objectType),this.ze(e,le.objectType)}eachEdge(e){this.ze(e,Fe.objectType)}getNodeCount(){return this.se.length}getNodeAt(e){return this.se[e]}getNodes(){return this.se}getNode(e){return this.se.find(t=>t.id===e)}getGroupAt(e){return this.K[e]}getGroups(){return this.K}getGroup(e){return this.K.find(t=>t.id===e)}getGroupCount(){return this.K.length}getAll(){let e=[];return Array.prototype.push.apply(e,this.se),Array.prototype.push.apply(e,this.q),Array.prototype.push.apply(e,this.K),e}getAllEdgesFor(e,t){return this.nd(e.getAllEdges(t))}getSourceEdgesFor(e){return this.nd(e.getSourceEdges())}getEdgeCount(){return this.q.length}getAllEdges(){return this.getEdges()}getEdgeAt(e){return this.q[e]}getEdges(){return this.q}getGroupType(e){return this.instance.getGroupType(e)}getNodeType(e){return this.instance.getNodeType(e)}getModel(){return this.instance.getModel()}getGraph(){return this.instance.getGraph()}getNodeId(e){return this.instance.getNodeId(e)}getGroupId(e){return this.instance.getGroupId(e)}getPortType(e){return this.instance.getPortType(e)}addPort(e,t){return this.instance.addPort(e,t)}getPortId(e){return this.instance.getPortId(e)}getEdge(e){return this.instance.getEdge(e)}getEdgeType(e){return this.instance.getEdgeType(e)}getVertex(e){return this.getNode(e)||this.getGroup(e)}containsVertex(e){return this.getVertex(e)!=null}getObjectInfo(e){return this.instance.getObjectInfo(e)}beforeConnect(e,t,n,o){return this.instance.beforeConnect(e,t,n,o)}beforeMoveConnection(e,t,n){return this.instance.beforeMoveConnection(e,t,n)}beforeStartConnect(e,t){return this.instance.beforeStartConnect(e,t)}beforeDetach(e,t,n){return this.instance.beforeDetach(e,t,n)}beforeStartDetach(e,t){return this.instance.beforeStartDetach(e,t)}get debugEnabled(){return this.instance.debugEnabled}Qg(e){return new _o(this.instance,{onClear:e||function(){}})}filter(e,t){let n=typeof e=="function"?e:function(s){let a=s.data,l=!1;for(let h in e){let d=e[h]===a[h];if(!d&&!t)return!1;l=l||d}return l},o=this.Qg();return this.eachNode(function(s,a){n(a)&&o.append(a);let l=a.getPorts();for(let h=0;h<l.length;h++)n(l[h])&&o.append(l[h])}),this.eachEdge(function(s,a){n(a)&&o.append(a)}),this.eachGroup(function(s,a){n(a)&&o.append(a)}),o}getAncestors(e){return this.instance.getAncestors(e).filter(t=>this.containsVertex(t.id))}getDescendants(e){return this.instance.getDescendants(e)}getType(e){return this.instance.getType(e)}isAncestor(e,t){return this.instance.isAncestor(e,t)}isDescendantGroup(e,t){return this.instance.isDescendantGroup(e,t)}resolveFullId(e){return this.instance.resolveFullId(e)}};c(_o,"DISCARD_EXISTING","discardExisting"),c(_o,"DISCARD_NEW","discardNew");var Er=_o;var ni=class{constructor(r,e,t){this.obj=r;this.instance=e;this.manager=t;c(this,"edgeId");c(this,"source");c(this,"target");c(this,"va");c(this,"Ca");c(this,"Ei");c(this,"od");c(this,"sd");c(this,"ad");c(this,"ld");this.source=r.source.getFullId(),this.target=r.target.getFullId(),H(r.source)&&(this.va=r.source.id,this.source=r.source.getParent().getFullId()),H(r.target)&&(this.Ca=r.target.id,this.target=r.target.getParent().getFullId()),this.edgeId=r.getId(),this.Ei=r.geometry,r.source.dummy&&(this.od=!0,this.ad={x:r.source.data[e.modelLeftAttribute],y:r.source.data[e.modelTopAttribute]}),r.target.dummy&&(this.sd=!0,this.ld={x:r.target.data[e.modelLeftAttribute],y:r.target.data[e.modelTopAttribute]})}generateSourceIdentifier(){return this.od?this.ad:this.va==null?this.source:this.source+this.instance.getGraph().getPortSeparator()+this.va}generateTargetIdentifier(){return this.sd?this.ld:this.Ca==null?this.target:this.target+this.instance.getGraph().getPortSeparator()+this.Ca}Qe(){let r={source:this.generateSourceIdentifier(),target:this.generateTargetIdentifier(),data:this.obj.data,geometry:this.Ei},e=this.instance.$_addEdge(r,Ib,null);this.manager.edgeChange(this.edgeId,e)}tt(){this.instance.removeEdge(this.obj)}edgeChange(r){this.obj=r,this.edgeId=this.obj.getId()}},Dd=class extends ni{constructor(){super(...arguments);c(this,"type","addEdge")}undo(){this.tt()}redo(){this.Qe()}hasDeltas(){return this.obj!=null}},Nd=class extends ni{constructor(){super(...arguments);c(this,"type","removeEdge")}undo(){this.Qe()}redo(){this.tt()}hasDeltas(){return this.obj!=null}},wd=class extends ni{constructor(e,t,n,o,s){super(n,e,t);this.oldVertex=o;this.newVertex=s}verticesAreTheSame(){return Oi(this.newVertex)&&Oi(this.oldVertex)&&this.newVertex.id===this.oldVertex.id}pointsAreTheSame(){return!Oi(this.newVertex)&&!Oi(this.oldVertex)&&Pb(this.newVertex,this.oldVertex)}hasDeltas(){return this.obj!=null&&!this.verticesAreTheSame()&&!this.pointsAreTheSame()}},Id=class extends wd{constructor(){super(...arguments);c(this,"type","edgeSourceChanged")}undo(){this.instance.setSource(this.obj,this.oldVertex)}redo(){this.instance.setSource(this.obj,this.newVertex)}},Md=class extends wd{constructor(){super(...arguments);c(this,"type","edgeTargetChanged")}undo(){this.instance.setTarget(this.obj,this.oldVertex)}redo(){this.instance.setTarget(this.obj,this.newVertex)}};var Tn=class i{constructor(r){this.actions=r;c(this,"id");c(this,"type","compound");this.actions==null&&(this.actions=[]),this.id=V()}$mergeInto(r){this.actions.reverse().forEach(e=>r.addAction(e,!0))}addAction(r,e){e?this.actions.unshift(r):this.actions.push(r)}undo(){this.actions.slice().reverse().forEach(r=>r.undo())}redo(){this.actions.forEach(r=>r.redo())}edgeChange(r,e){this.actions.forEach(t=>{t instanceof ni&&t.edgeId===r&&t.edgeChange(e)})}hasDeltas(){for(let r=0;r<this.actions.length;r++)if(this.actions[r].hasDeltas())return!0;return!1}compress(){let r=new i,e={},t={},n={};for(let o=0;o<this.actions.length;o++){let s=this.actions[o];RA(s)?e[s.obj.id]!=null?Object.assign(e[s.obj.id].$nd,s.$nd):(e[s.obj.id]=s,r.addAction(s)):LA(s)?t[s.obj.id]!=null?Object.assign(t[s.obj.id].pos,s.pos):(t[s.obj.id]=s,r.addAction(s)):wA(s)?n[s.group.id]!=null?Object.assign(n[s.group.id].newGroupSize,s.newGroupSize):(n[s.group.id]=s,r.addAction(s)):r.addAction(s)}return r}};var Xs=class{constructor(r,e,t,n){this.obj=r;this.originalPosition=e;this.pos=t;this.renderer=n;c(this,"type","moveAction")}redo(){this.renderer.setPosition(this.obj,this.pos.x,this.pos.y)}undo(){this.renderer.setPosition(this.obj,this.originalPosition.x,this.originalPosition.y)}hasDeltas(){return this.pos.x!==this.originalPosition.x||this.pos.y!==this.originalPosition.y}};var Vd=class{constructor(r,e){this.obj=r;this.instance=e}$add(){this.obj.objectType===de.objectType?this.obj=this.instance.addNode(this.obj.data):this.obj.objectType===le.objectType&&(this.obj=this.instance.addGroup(this.obj.data))}cd(){this.instance.remove(this.obj)}getTerminusId(){return this.obj.getFullId()}hasDeltas(){return this.obj!=null}},Rl=class extends Vd{constructor(){super(...arguments);c(this,"type","terminusAdd")}undo(){this.cd()}redo(){this.$add()}},_l=class extends Vd{constructor(){super(...arguments);c(this,"type","terminusRemove")}undo(){this.$add()}redo(){this.cd()}isConnectedTo(e){let t=this.getTerminusId();return e.source===t||e.target===t}},Gd=class extends _l{constructor(e,t){super(e.group,t);c(this,"type","groupRemove");c(this,"childrenRemoved");c(this,"orphanedChildren");this.childrenRemoved=e.removeChildren,this.orphanedChildren=e.children.slice()}$add(){super.$add(),this.childrenRemoved||this.orphanedChildren.forEach(e=>this.instance.$addToGroup(e,this.obj,null,null,null,null))}},Ll=class{constructor(r,e,t,n,o){this.group=r;this.originalGroupSize=e;this.newGroupSize=t;this.instance=n;this.source=o;c(this,"type","groupSizeChanged")}hasDeltas(){return Math.round(this.originalGroupSize.width)!==Math.round(this.newGroupSize.width)||Math.round(this.originalGroupSize.height)!==Math.round(this.newGroupSize.height)}redo(){this.Vr(Od,this.newGroupSize,this.originalGroupSize)}undo(){this.Vr(_d,this.originalGroupSize,this.newGroupSize)}Vr(r,e,t){this.instance.fire(r,{group:this.group,source:this.source,sizeAfterUndo:e,sizeBeforeUndo:t})}};function Ok(i,r,e){return i==="*"?!0:i.length>0?i.indexOf(r)!==-1:!e}function js(i,r,e){let t;i=i||{},r=r||{};let n=i,o=r;if(e)for(t=0;t<e.length;t++)n[e[t]]=o[e[t]];else for(t in o)n[t]=o[t];return i}function _k(i,r){let e=xt({x:i[0],y:i[1]},{x:0,y:0},r);return[Math.round(e.x),Math.round(e.y)]}function Rk(i,r){i=i.length==null||typeof i=="string"?[i]:i;for(let e=0;e<i.length;e++)r(i[e])}function $d(i,r,e){return function(){let t=null;try{r!=null&&(t=r.apply(this,arguments))}catch(n){U("VisuallyJs: function failed : "+n)}if(i!=null&&(e==null||t!==e))try{t=i.apply(this,arguments)}catch(n){U("VisuallyJs: wrapped function failed : "+n)}return t}}var Ni=class{constructor(r,e,t,n){this.obj=r;this.instance=t;c(this,"type","update");c(this,"$nd");c(this,"$od");c(this,"reason");this.$nd=js({},r.data),this.$od=js({},e),this.reason=n}hd(r){this.obj.objectType===de.objectType?this.instance.$_updateNode(this.obj,r,this.reason,!0):this.obj.objectType===le.objectType?this.instance.$_updateGroup(this.obj,r,this.reason,!0):this.obj.objectType===me.objectType?this.instance.$_updatePort(this.obj,r,this.reason,!0):this.obj.objectType===Fe.objectType&&this.instance.$_updateEdge(this.obj,r,this.reason,!0)}undo(){this.hd(this.$od)}redo(){this.hd(this.$nd)}hasDeltas(){return!El(this.$nd,this.$od)}};var Bd=class{constructor(r,e,t){this.obj=r;this.yn=e;this.instance=t}Qe(){this.instance.addPort(this.yn,this.obj.data)}tt(){this.instance.removePort(this.yn,this.obj.id)}getTerminusId(){return this.obj.getFullId()}},Fd=class extends Bd{constructor(){super(...arguments);c(this,"type","portAdd")}undo(){this.tt()}redo(){this.Qe()}hasDeltas(){return this.obj!=null}},Ud=class extends Bd{constructor(){super(...arguments);c(this,"type","portRemove")}undo(){this.Qe()}redo(){this.tt()}isConnectedTo(e){let t=this.getTerminusId();return e.generateSourceIdentifier()===t||e.generateTargetIdentifier()===t}hasDeltas(){return this.obj!=null}};var Yd=class{constructor(r,e,t){this.node=r;this.group=e;this.instance=t}hasDeltas(){return this.node!=null}},zd=class extends Yd{constructor(e,t,n,o,s,a,l){super(e,t,a);this.node=e;this.group=t;this.sourceGroup=n;this.Pa=o;this.Oa=s;this.instance=a;this.renderer=l;c(this,"type","addGroupMember")}redo(){this.instance.addToGroup(this.node,this.group),this.renderer!=null&&this.Oa!=null&&this.renderer.setPosition(this.node.id,this.Oa.x,this.Oa.y)}undo(){this.sourceGroup?this.instance.addToGroup(this.node,this.sourceGroup):this.instance.removeFromGroup(this.node),this.renderer!=null&&this.Pa!=null&&this.renderer.setPosition(this.node.id,this.Pa.x,this.Pa.y)}},Xd=class extends Yd{constructor(e,t,n,o,s,a,l){super(e,t,a);this.node=e;this.group=t;this.targetGroup=n;this.Ra=o;this._a=s;this.instance=a;this.renderer=l;c(this,"type","removeGroupMember")}redo(){this.instance.removeFromGroup(this.node),this.renderer!=null&&this._a!=null&&this.renderer.setPosition(this.node.id,this._a.x,this._a.y)}undo(){this.instance.addToGroup(this.node,this.group),this.renderer!=null&&this.Ra!=null&&this.renderer.setPosition(this.node.id,this.Ra.x,this.Ra.y)}},jd=class{constructor(r,e){this.group=r;this.renderer=e;c(this,"type","groupCollapse")}redo(){this.renderer.collapseGroup(this.group)}undo(){this.renderer.expandGroup(this.group)}hasDeltas(){return this.group!=null}},Hd=class{constructor(r,e){this.group=r;this.renderer=e;c(this,"type","groupExpand")}redo(){this.renderer.expandGroup(this.group)}undo(){this.renderer.collapseGroup(this.group)}hasDeltas(){return this.group!=null}};var wl=class{constructor(r,e,t){this.La=r;this.vertex=e;this.pos=t;c(this,"type","rendererVertexRemovedAction")}redo(){}undo(){this.La.setPosition(this.vertex,this.pos.x,this.pos.y)}hasDeltas(){return this.vertex!=null}};var DA="internal.connection",Dl="context:update",kd="group:collapse",Wd="group:expand",Ro="zoom",Zd="render:start",vn="render:end",NA="adhocLayout",Hs="afterLayoutRefresh",Nl="group:relayout",$r="group:render",ks="internal.vertex:updated",Br="node:render",Jd="node:visibility",Kd="plugin:added",IA="plugin:removed",Cn="relayout",MA="objectRepainted",Ue="click",gt="contextmenu",Lo="dblclick",Fr="dbltap",VA="focus",ue="mousedown",vE="mouseenter",CE="mouseexit",ie="mousemove",GA="mouseleave",oe="mouseup",et="mouseout",tt="mouseover",W="tap",$A="touchstart",BA="touchend",FA="touchmove",UA="vertex:click",YA="vertex:dblclick",zA="vertex:dbltap",XA="vertex:mouseout",jA="vertex:mouseover",HA="vertex:mousemove",P5="vertex:mouseup",O5="vertex:mousedown",kA="vertex:contextmenu",WA="vertex:tap",ZA="edge:click",JA="edge:dblclick",KA="edge:dbltap",qd="edge:mouseout",Qd="edge:mouseover",qA="edge:mouseup",Il="edge:mousedown",QA="edge:contextmenu",eS="edge:tap",wo="canvasClick",tS="canvasDblClick",eu="edge:redraw",rS="lasso:end",Ml="pan",Pn="modeChanged",_5="allGroupsRelayout",nS="groupRelayoutAdhoc",R5="groupMemberRemoved",iS="newVertexAddedToGroup",oS="existingVertexAddedToGroup";var Ws=class extends Ni{constructor(e,t,n,o){super(e,t,n,o);this.obj=e;this.instance=n;c(this,"type","vertexUpdate");o===Zs&&t[this.instance.modelRotationAttribute]==null&&(this.$od[this.instance.modelRotationAttribute]=0)}};var Do=class{constructor(r,e,t,n){this.obj=r;this.previousType=e;this.newType=t;this.instance=n;c(this,"type","setTypeAction")}hasDeltas(){return this.previousType!==this.newType}redo(){this.instance.setType(this.obj,this.newType)}undo(){this.instance.setType(this.obj,this.previousType)}};var PE=class{constructor(r,e,t,n,o){this.T=r;this.eE=e;this.ud=t;this.Ei=n;this.La=o;c(this,"type","edgePath")}dd(r){this.T.setEdgeGeometry(this.eE,r,null,this.La)}undo(){this.dd(this.ud)}redo(){this.dd(this.Ei)}hasDeltas(){return!El(this.ud,this.Ei)}},a0=50,OE="Cannot start a new transaction while one is active. Either commit/rollback the current transaction before creating a new one, or pass a cleanup flag in to this method",l0="Cannot rollback transaction from here; it has been appended to. Close all transaction appenders before attempting to rollback the transaction.",tu=class{constructor(r){c(this,"T");c(this,"Xo");c(this,"Lt");c(this,"wa");c(this,"undoStack");c(this,"redoStack");c(this,"jo",[]);c(this,"ae");c(this,"Zt",0);this.T=r.instance,this.Lt=!1,this.undoStack=[],this.redoStack=[],this.Xo=r.maximumSize||a0,this.wa=r.onChange,this.tE()}pd(r){this.Lt=r}dataLoadStart(){this.clear(),this.pd(!0)}dataAppendStart(){this.dataLoadStart()}dataLoadEnd(){this.pd(!1)}dataAppendEnd(){this.dataLoadEnd()}tE(){this.T.bind(Ht,()=>{this.clear()}),this.T.bind(kt,r=>{this.command(new Rl(r.node,this.T))}),this.T.bind(Le,r=>{this.command(new _l(r.node,this.T))}),this.T.bind($e,r=>{gl(r.updates)||this.command(new Ws(r.vertex,r.originalData,this.T,r.reason))}),this.T.bind(jt,r=>{this.command(new Rl(r.group,this.T))}),this.T.bind(Ge,r=>{this.command(new Gd(r,this.T))}),this.T.bind(Re,r=>{gl(r.updates)||this.command(new Ws(r.vertex,r.originalData,this.T,r.reason))}),this.T.bind(Pd,r=>{let e=new Ll(r.group,r.originalGroupSize,r.newGroupSize,this.T,r.source);e.hasDeltas()&&this.command(e)}),this.T.bind(pr,r=>{this.command(new Dd(r.edge,this.T,this))}),this.T.bind(mt,r=>{this.command(new Nd(r.edge,this.T,this))}),this.T.bind(pt,r=>{gl(r.updates)||this.command(new Ni(r.edge,r.originalData,this.T,r.reason))}),this.T.bind(sn,r=>{this.command(new Id(this.T,this,r.edge,r.old,r.new))}),this.T.bind(on,r=>{this.command(new Md(this.T,this,r.edge,r.old,r.new))}),this.T.bind(ri,r=>{this.command(new PE(this.T,r.edge,r.originalGeometry,r.geometry,r.ui))}),this.T.bind(ei,r=>{this.command(new Fd(r.port,r.vertex,this.T))}),this.T.bind(Vr,r=>{this.command(new Ud(r.port,r.vertex,this.T))}),this.T.bind(ur,r=>{gl(r.updates)||this.command(new Ni(r.port,r.originalData,this.T,null))}),this.T.bind(wi,r=>{r.vertexIsNew!==!0&&this.command(new zd(r.vertex,r.group,r.sourceGroup,r.originalPosition,r.pos,this.T,r.source))}),this.T.bind(Us,r=>{this.command(new Xd(r.vertex,r.group,r.targetGroup,r.originalPosition,r.newPosition,this.T,r.source))}),this.T.bind(Sd,r=>{this.command(new Do(r.obj,r.previousType,r.newType,this.T))}),this.T.bind(Td,r=>{this.command(new Do(r.obj,r.previousType,r.newType,this.T))}),this.T.bind(vd,r=>{this.command(new Do(r.obj,r.previousType,r.newType,this.T))}),this.T.bind(Ad,r=>{this.command(new Do(r.obj,r.previousType,r.newType,this.T))}),this.T.bind("renderer:added",r=>{r.renderer.bind(Dt,e=>{e.dragGroup.forEach(t=>{t.originalPosition!=null&&this.command(new Xs(t.vertex,t.originalPosition,t.pos,e.ui))})}),r.renderer.bind(Gr,e=>{e.dragGroup.forEach(t=>{t.originalPosition!=null&&this.command(new Xs(t.vertex,t.originalPosition,t.pos,e.ui))})}),r.renderer.bind(kd,e=>{this.command(new jd(e.group,r.renderer))}),r.renderer.bind(Wd,e=>{this.command(new Hd(e.group,r.renderer))}),r.renderer.bind(Le,e=>{this.command(new wl(r.renderer,e.vertex,e.pos))}),r.renderer.bind(Ge,e=>{this.command(new wl(r.renderer,e.vertex,e.pos))})})}fi(){this.wa&&this.wa(this,this.undoStack.length,this.redoStack.length)}command(r,e){if(!this.Lt){if(!r.hasDeltas())return;d0(r)&&(r=r.compress()),this.ae!=null?this.ae.addAction(r,e):(this.undoStack.push(r),this.undoStack.length>this.Xo&&this.undoStack.splice(this.undoStack.length-this.Xo-1,this.undoStack.length-this.Xo),this.redoStack.length=0,this.fi())}}edgeChange(r,e){let t=n=>{n.forEach(o=>{o instanceof ni&&o.edgeId===r?o.edgeChange(e):o instanceof Tn&&o.edgeChange(r,e)})};t(this.undoStack),t(this.redoStack)}undo(){let r=this.undoStack.pop();r&&(this.Lt=!0,this.redoStack.push(r),r.undo(),this.Lt=!1,this.fi())}redo(){let r=this.redoStack.pop();r&&(this.Lt=!0,this.undoStack.push(r),r.redo(),this.Lt=!1,this.fi())}clear(){this.undoStack.length=0,this.redoStack.length=0,this.ae=null,this.Zt=0,this.Lt=!1,this.fi()}transaction(r,e,t){if(this.ae!=null&&e==null)return U(OE),!1;if(this.openTransaction(e)==null){if(t)return r()}else try{if(r()!==!1){let a=this.ae;return this.ae=null,this.command(a),a.id}else return this.rollbackTransaction(),!1}catch(s){return U("Exception thrown in transaction "+s.message+"; rolling transaction back"),this.rollbackTransaction(),!1}}mergeTransaction(r){if(this.ae!=null)return this.transaction(r,St);try{let e=this.transaction(r);if(e!==!1){if(this.undoStack.length>1){let t=this.undoStack.pop(),n=this.undoStack.pop();this.rE(t,n),this.undoStack.push(t)}return e}else return this.rollbackTransaction(),!1}catch(e){return U("Exception thrown in transaction "+e.message+"; rolling transaction back"),this.rollbackTransaction(),!1}}rE(r,e){e instanceof Tn?e.$mergeInto(r):r.addAction(e,!0)}nE(){return this.ae=new Tn,this.Zt=0,this.ae.id}openTransaction(r){if(!this.Lt){let e=!0;if(this.ae!=null)if(r!=null)if(r===h0)this.commitTransaction();else if(r===c0)this.rollbackTransaction();else if(r===St)e=!1,this.Zt++;else throw new Error(OE);else throw new Error(OE);return e&&this.nE(),this.ae.id}return null}rollbackTransaction(){this.ae!=null&&(this.Zt>0?(this.Zt--,U(l0)):(this.ae.undo(),this.ae=null,this.fi(),this.jo.length=0))}commitTransaction(r){if(this.ae!=null)if(r!==!0&&this.Zt>0)this.Zt--;else{let e=this.ae;this.ae=null,this.command(e),this.Zt=0,this.md()}}Ib(r){if(this.undoStack.length===0){let e=new Tn;e.addAction(r),this.command(e)}else{let e=this.undoStack[this.undoStack.length-1];if(e instanceof Tn)e.addAction(r);else{this.undoStack.pop();let t=new Tn;t.addAction(e),t.addAction(r),this.undoStack.push(t)}}}Mb(r){this.iE(r),this.md()}iE(r){this.jo.push(r)}md(){this.ae==null&&(this.jo.forEach(r=>{try{r()}catch(e){}}),this.jo.length=0)}},h0="commitCurrent",c0="rollbackCurrent",St="appendToCurrent";function d0(i){return i instanceof Tn}function RA(i){return i instanceof Ni||i instanceof Ws}function LA(i){return i instanceof Xs}function wA(i){return i instanceof Ll}var ru="1.0.1";var _E="type",RE="default",hS="groupResized",u0="addPort",p0="addNewPort",m0="removePort",nu="updatePort",Js="moved",s6="layout",LE="updateVertex",sS="updateNode",aS="updateGroup",cS="magnetizer",ou="setPosition",dS="snapToGrid",a6="sizeGroupToFit",Vl="drawingToolsResize",Zs="rotation",uS="resized",lS="updated",iu=class extends $t{constructor(e){super();c(this,"graph");c(this,"autoSaver");c(this,"idFunction");c(this,"typeProperty");c(this,"edgeTypeProperty");c(this,"portTypeProperty");c(this,"typeFunction");c(this,"edgeIdFunction");c(this,"edgeTypeFunction");c(this,"portIdFunction");c(this,"portTypeFunction");c(this,"portExtractor");c(this,"portUpdater");c(this,"portDataProperty");c(this,"portOrderProperty");c(this,"modelTopAttribute");c(this,"modelLeftAttribute");c(this,"modelWidthAttribute");c(this,"modelHeightAttribute");c(this,"modelRotationAttribute");c(this,"model");c(this,"Da");c(this,"gd");c(this,"debugEnabled");c(this,"defaultObjectFactory");c(this,"nodeFactory");c(this,"edgeFactory");c(this,"portFactory");c(this,"groupFactory");c(this,"portSeparator",".");c(this,"undoRedo");c(this,"Ed");c(this,"beforeConnect");c(this,"beforeMoveConnection");c(this,"beforeStartConnect");c(this,"beforeDetach");c(this,"beforeStartDetach");c(this,"pe");c(this,"Jt",new Map);c(this,"$transientVerticesByRenderer",{});e=e||{};let t=e.undoRedo||{};t.enabled!==!1&&(this.undoRedo=new tu({instance:this,maximumSize:t.maximumSize,onChange:(o,s,a)=>{this.fire(zs,{undoCount:s,redoCount:a})}})),this.idFunction=e.idFunction||sE,this.typeProperty=e.typeProperty||_E,this.edgeTypeProperty=e.edgeTypeProperty||_E,this.portTypeProperty=e.portTypeProperty||_E,this.typeFunction=e.typeFunction||(o=>o[this.typeProperty]||RE),this.edgeIdFunction=e.edgeIdFunction||this.idFunction,this.edgeTypeFunction=e.edgeTypeFunction||(o=>o[this.edgeTypeProperty]||RE),this.portIdFunction=e.portIdFunction||this.idFunction,this.portTypeFunction=e.portTypeFunction||(o=>o[this.portTypeProperty]||RE),this.portExtractor=e.portExtractor,this.portUpdater=e.portUpdater,this.portDataProperty=e.portDataProperty,this.portOrderProperty=e.portOrderProperty,this.debugEnabled=!1,this.model=new Xc(this,e.model),this.defaultObjectFactory=(o,s,a,l)=>(a=a==null||!dr(a)?{}:a,a=ot(a),a.id=a.id||V(),a.type=a.type||(s==null?null:s.type||s),l(a),!0),this.modelLeftAttribute=e.modelLeftAttribute||Kb,this.modelTopAttribute=e.modelTopAttribute||qb,this.modelWidthAttribute=e.modelWidthAttribute||eA,this.modelHeightAttribute=e.modelHeightAttribute||tA,this.modelRotationAttribute=e.modelRotationAttribute||Qb,this.nodeFactory=e.nodeFactory||this.defaultObjectFactory,this.edgeFactory=e.edgeFactory||this.defaultObjectFactory,this.portFactory=e.portFactory||this.defaultObjectFactory,this.groupFactory=e.groupFactory||this.defaultObjectFactory,this.gd=e.autoSave&&e.autoSave.enabled!==!1,this.Ed={portSeparator:e.portSeparator,defaultCost:e.defaultCost,defaultDirected:e.defaultDirected,enableSubgraphs:e.enableSubgraphs},this.portDataProperty!=null&&this.portExtractor==null&&(this.portExtractor=o=>{let s=o[this.portDataProperty]||[];return this.portOrderProperty!=null&&s.sort((a,l)=>{let h=a[this.portOrderProperty],d=l[this.portOrderProperty],u=h==null?1/0:h,p=d==null?1/0:d;return u-p}),s}),this.portDataProperty!=null&&this.portUpdater==null&&(this.portUpdater=(o,s,a)=>{let l={};return this.portOrderProperty!=null&&a.sort((h,d)=>{let u=h.data[this.portOrderProperty],p=d.data[this.portOrderProperty],m=u==null?1/0:u,g=p==null?1/0:p;return m-g}),l[this.portDataProperty]=a.map(h=>h.data),Object.assign(o,l)}),this.graph=new xl(this.Ed),this.gd&&(this.autoSaver=new Ol(this,e.autoSave)),new Rd(this);let n=(o,s)=>{if(this.model==null)return!0;let a=this.getType(o),l=this.getType(s),h=H(o)?o.getParent():o,d=H(s)?s.getParent():s,u=H(o)?this.model.getPortDefinition(a):K(o)?this.model.getNodeDefinition(a):this.model.getGroupDefinition(a),p=H(s)?this.model.getPortDefinition(l):K(s)?this.model.getNodeDefinition(l):this.model.getGroupDefinition(l),m=K(h)?this.model.getNodeDefinition(a):this.model.getGroupDefinition(a),g=K(d)?this.model.getNodeDefinition(l):this.model.getGroupDefinition(l);return u.maxConnections!=null&&o.getEdges().length>=u.maxConnections||p.maxConnections!=null&&s.getEdges().length>=p.maxConnections?!1:o===s?!(m.allowLoopback===!1||u.allowLoopback===!1||p.allowLoopback===!1||g.allowLoopback===!1):h===d?!(m.allowVertexLoopback===!1||u.allowVertexLoopback===!1||p.allowVertexLoopback===!1||g.allowVertexLoopback===!1):!0};if(this.beforeConnect=e.beforeConnect||n,this.beforeMoveConnection=e.beforeMoveConnection||n,this.beforeStartConnect=e.beforeStartConnect||((o,s)=>({})),this.beforeDetach=e.beforeDetach||((o,s,a)=>!0),this.beforeStartDetach=e.beforeStartDetach||((o,s)=>!0),this.pe=this.ko(o=>{this.L(s=>s.$selectionCleared(o)),this.fire(Pr,{selection:o})}),e.selectionMode&&this.pe.setMode(e.selectionMode),e.maxSelectedNodes&&this.pe.setMaxNodes(e.maxSelectedNodes),e.maxSelectedGroups&&this.pe.setMaxGroups(e.maxSelectedGroups),e.maxSelectedEdges&&this.pe.setMaxEdges(e.maxSelectedEdges),e.selectionCapacityPolicy&&this.pe.setCapacityPolicy(e.selectionCapacityPolicy),e.events)for(let o in e.events)this.bind(o,e.events[o]);e.data!=null&&this.load({data:e.data})}oE(e,t,n){return{id:`${e}_${n}`,[this.modelLeftAttribute]:t.x,[this.modelTopAttribute]:t.y}}Ho(e,t,n,o){if(z(e))return[this.graph.getVertex(e,!0),!1];if(K(e)||Y(e)||H(e))return[e,!1];{let s=e,a=s.x==null?0:s.x,l=s.y==null?0:s.y;return[this.fd(this.oE(t,{x:a,y:l},n),o),!0]}}ko(e){return new Er(this,{onClear:e||function(){}})}filter(e,t){let n=typeof e=="function"?e:function(s){let a=s.data,l=!1,h=e;for(let d in h){let u=h[d]===a[d];if(!u&&!t)return!1;l=l||u}return l},o=this.ko();return this.eachNode(function(s,a){n(a)&&o.append(a);let l=a.getPorts();for(let h=0;h<l.length;h++)n(l[h])&&o.append(l[h])}),this.eachEdge(function(s,a){n(a)&&o.append(a)}),this.eachGroup(function(s,a){n(a)&&o.append(a)}),o}getModel(){return this.model}setAutoSave(e){this.autoSaver!=null&&this.autoSaver.discard(),this.autoSaver=new Ol(this,e)}connect(e){let t,n=this.graph.getVertex(e.source),o=this.graph.getVertex(e.target),s=e.cost,a=e.directed;if(!n)if(!e.doNotCreateMissingNodes)n=this.graph.addNode(e.source),this.Na(n);else return;if(!o)if(!e.doNotCreateMissingNodes)o=this.graph.addNode(e.target),this.Na(o);else return;let l=e.data||{},h=this.beforeStartConnect(n,this.edgeTypeFunction(l));return h&&(typeof h=="object"&&(l=Object.assign(h,l)),this.beforeConnect(n,o,l,!1)!==!1&&(t=this.$_addEdge({source:n,target:o,cost:s,directed:a,data:l,geometry:e.geometry},bl,null))),t}clear(){return this.L(e=>e.$graphClearStart()),this.fire(Sn),this.graph.clear(),this.$transientVerticesByRenderer={},this.L(e=>e.$graphClearEnd()),this.fire(Ht),this}destroy(){this.clear(),delete this.Jt,delete this.$transientVerticesByRenderer}getGraph(){return this.graph}getNodeCount(){return this.graph.getVertexCount()}getNodeAt(e){return this.graph.getVertexAt(e)}getNodes(){return this.graph.getVertices()}eachNode(e){let t;for(let n=0,o=this.graph.getVertexCount();n<o;n++)t=this.graph.getVertexAt(n),e(n,t)}eachGroup(e){let t;for(let n=0,o=this.graph.getGroupCount();n<o;n++)t=this.graph.getGroupAt(n),e(n,t)}eachVertex(e){this.eachNode(e),this.eachGroup(e)}eachEdge(e){let t=this.graph.getEdges();for(let n=0,o=t.length;n<o;n++)e(n,t[n])}getEdgeCount(){return this.graph.getEdgeCount()}getGroupCount(){return this.graph.getGroupCount()}getGroupAt(e){return this.graph.getGroupAt(e)}getGroups(){return this.graph.getGroups()}getDescendants(e){return Ns(e)}getAncestors(e){return yn(e)}isAncestor(e,t){return We(e,t)}isDescendantGroup(e,t){return Db(e,t)}getClusters(){return this.graph.getClusters()}getCluster(e){let t=z(e)?this.getVertex(e):e;return this.graph.getCluster(t)}getNodeId(e){return typeof e=="string"?e:this.idFunction(e)}getNodeType(e){return this.typeFunction(e)||"default"}getGroupId(e){return typeof e=="string"?e:this.idFunction(e)}getGroupType(e){return this.typeFunction(e)||"default"}getEdgeType(e){return this.edgeTypeFunction(e)||"default"}getPortId(e){return this.portIdFunction(e)}getPortType(e){return this.portTypeFunction(e)||"default"}getType(e){return(K(e)?this.typeFunction:H(e)?this.portTypeFunction:this.edgeTypeFunction)(e.data)||"default"}setType(e,t){let n=this.getType(e);if(n===t)return;let o=e.objectType===de.objectType?this.typeProperty:e.objectType===me.objectType?this.portTypeProperty:this.edgeTypeProperty;e.data[o]=t,e.type=t,this.$dispatchTypeChange(e,n,t)}$dispatchTypeChange(e,t,n){let o,s;K(e)?(o=Sd,s=()=>this.L(a=>a.$nodeTypeChanged(e,t,n))):H(e)?(o=Td,s=()=>this.L(a=>a.$portTypeChanged(e,t,n))):Ke(e)?(o=Ad,s=()=>this.L(a=>a.$edgeTypeChanged(e,t,n))):Y(e)&&(o=vd,s=()=>this.L(a=>a.$groupTypeChanged(e,t,n))),o!=null&&(this.fire(o,{obj:e,previousType:t,newType:n}),s())}resolveFullId(e){if(Ke(e))return e.id;if(K(e))return e.id;if(Y(e))return e.id;if(H(e))return e.parent.id+this.graph.portSeparator+e.id}resolveNode(e){return H(e)?e.parent:e}addNode(e,t){let n=this.idFunction(e),o=null;n==null&&typeof e!="string"&&(e.id=V());let s=this.graph.addNode(e,this.idFunction);if(s!=null){if(this.portExtractor!=null){let a=this.portExtractor(s.data,s);if(a!=null)for(let l=0;l<a.length;l++)s.$addPort(a[l],this.portIdFunction)}if(typeof e!="string"&&e.group!=null)if(o=this.getGroup(e.group),o!=null)o.$addMember(s);else throw new Error("parent group ["+e.group+"] not found");return this.Na(s,o),o!=null&&this.fire(wi,{group:o,vertex:s,vertexIsNew:!0}),s}else return this.graph.getVertex(n)}Na(e,t){let n={node:e,parentGroup:t};this.L(o=>o.$nodeAdded(n)),this.fire(kt,n)}sE(e,t){let n={group:e,parentGroup:t};this.L(o=>o.$groupAdded(n)),this.fire(jt,n)}addFactoryNode(e,t,n,o,s){n==null&&(t!=null?(t=typeof t=="object"?t:{},n=typeof t=="function"?t:null):t={}),t.type=t.type||e;try{this.nodeFactory(this,e,t,a=>{s!==!1&&this.openTransaction(St);let l=this.addNode(a);try{n&&n(l)}catch(h){U("WARN: Factory node callback threw an error",h)}s!==!1&&this.commitTransaction()},()=>{o&&o(),s!==!1&&this.rollbackTransaction()})}catch(a){U("WARN: Factory node threw an error",a),s!==!1&&this.rollbackTransaction()}}addNodes(e){for(let t=0;t<e.length;t++)this.addNode(e[t]);return this}yd(e){return Ds(this.$transientVerticesByRenderer,e.id,()=>({}))}$addTransientVertex(e,t){let n=this.graph.addNode(e);if(n.transient=!0,t!=null){let o=this.yd(t);o[n.id]=n,n.transientRenderer=t.id}return n}fd(e,t){let n=this.$addTransientVertex(e,t);return n.dummy=!0,this.L(o=>{o.$renderDummyVertex(n)}),n}Wo(e){this.graph.deleteNode(e),this.L(t=>{t.$nodeRemoved({node:e,edges:[],parentGroupIsBeingRemoved:!1})})}$setEdgeDetached(e,t,n){let o=this.fd({id:`${e.id}_${n===Qe?"0":"1"}`,[this.modelLeftAttribute]:t.x,[this.modelTopAttribute]:t.y});n===Qe?this.setSource(e,o):this.setTarget(e,o)}$cleanupTransientVertex(e,t){let n=e.getAllEdges()||[];this.graph.deleteNode(e);for(let o=0;o<n.length;o++)this.graph.deleteEdge(n[o]),t.$edgeRemoved({edge:n[o],source:t});if(t.$nodeRemoved({node:e,edges:n,parentGroupIsBeingRemoved:!1}),t!=null){let o=this.yd(t);o&&delete o[e.id]}}$addTransientEdge(e,t,n,o,s,a){let l={source:t,target:n,data:o||{},geometry:s,transient:!0},h=this.graph.addEdge(l);return e.$edgeAdded({edge:h,source:e,geometry:h.geometry,transient:!0,reason:Mb},a),h}addFactoryGroup(e,t,n,o,s){n==null&&(t!=null?(t=typeof t=="object"?t:{},n=typeof t=="function"?t:null):t==null&&n==null&&(t={})),t.type=t.type||e;try{this.groupFactory(this,e,t,a=>{s!==!1&&this.openTransaction(St);let l=this.addGroup(a);try{n&&n(l)}catch(h){U("WARN: Factory group callback threw an error",h)}s!==!1&&this.commitTransaction()},()=>{o&&o(),s!==!1&&this.rollbackTransaction()})}catch(a){U("WARN: group factory threw an error",a),s!==!1&&this.rollbackTransaction()}}addGroup(e,t){let n,o;if(this.idFunction(e)==null&&typeof e!="string"&&(e.id=V()),o=this.graph.addGroup(e,this.idFunction),o!=null){if(typeof e!="string"&&e.group!=null){if(n=this.getGroup(e.group),n==null)throw new Error("Cannot find parent group ["+e.group+"]");n.$addMember(o)}this.sE(o,n),n!=null&&this.fire(wi,{group:n,vertex:o,vertexIsNew:!0})}return o}addToGroup(e,t,n){return this.$addToGroup(e,t,null,null,n,null)}$addToGroup(e,t,n,o,s,a){let l=!1,h=this.getObjectInfo(t),d=this.getObjectInfo(e);if(n=n||d.obj.group,d.obj&&h.obj&&(l=h.obj.$addMember(d.obj),l)){n&&n.$removeMember(d.obj),d.obj.data.group=h.obj.id;let u={vertex:d.obj,group:h.obj,pos:s,originalPosition:o,source:a,positionInGroup:s};n&&(u.sourceGroup=n),this.L(p=>{p.$groupMemberAdded(u)}),this.fire(wi,u)}return l}removeFromGroup(e){return this.$removeFromGroup(e,null,null,null,null)}$removeFromGroup(e,t,n,o,s){let a=this.getObjectInfo(e),l;if(a.obj&&a.obj.group&&(l=a.obj.group,l.$removeMember(a.obj))){let h={vertex:a.obj,group:l,newPosition:o,originalPosition:n,source:s};t&&(h.targetGroup=t),this.L(d=>{d.$groupMemberRemoved(h)}),delete a.obj.data.group,this.fire(Us,h)}return l}xd(e,t,n,o){e.nestedGroups.forEach(a=>this.xd(a,t,!0,o)),e.nodes.forEach(a=>this.bd(a,!0,o));for(let a=0;a<e.edges.length;a++)this.Ia(e.edges[a]);let s={group:e.group,removeChildren:t,children:e.children,parentGroup:e.parentGroup,parentGroupIsBeingRemoved:n};this.L(a=>a.$groupRemoved(s)),o||this.fire(Ge,s)}bd(e,t,n){for(let s=0;s<e.edges.length;s++)this.Ia(e.edges[s]);let o={node:e.node,edges:e.edges,parentGroup:e.parentGroup,parentGroupIsBeingRemoved:t};this.L(s=>s.$nodeRemoved(o)),n||this.fire(Le,o)}removeGroup(e,t,n){let o=this.graph.getVertex(z(e)?e:e.id);if(o){this.openTransaction(St);let s=this.graph.deleteGroup(o,t);return s.group&&(t||s.children.forEach(a=>delete a.data.group),this.xd(s,t===!0,!1,n)),this.commitTransaction(),!0}return!1}getNode(e){return this.graph.getVertex(e)}getEdge(e){return this.graph.getEdge(e)}getGroup(e){return this.graph.getGroup(e)}getVertex(e){return this.getNode(e)||this.getGroup(e)}getPort(e){let t=this.graph.getVertexByPortId(e);if(t)return t.getPort(this.graph.splitPortId(e)[1])}exists(...e){for(let t=0;t<e.length;t++)if(this.graph.getVertex(e[t])==null)return!1;return!0}removeNode(e){if(!z(e)&&e.transient===!0)return!1;let t=this.graph.getVertex(z(e)?e:e.id);if(t!=null){this.openTransaction(St);let n=t.getAllEdges()||[];for(let s=0;s<n.length;s++)this.removeEdge(n[s]);let o=this.graph.deleteNode(t);return this.bd(o,!1),this.commitTransaction(),!0}return!1}addEdge(e){return this.$_addEdge(e,bl,null)}$_addEdge(e,t,n,o){let s=this.$_deriveEdgeId(e.data),[a,l]=this.Ho(e.source,s,0,n),[h,d]=this.Ho(e.target,s,1,n);if(a==null||a.objectType==null)throw new TypeError("Unknown source node ["+e.source+"]");if(h==null||h.objectType==null)throw new TypeError("Unknown target node ["+e.target+"]");if(!l&&a.dummy)return U(`Cannot add edge to dummy vertex ${a.id}`),null;if(!d&&h.dummy)return U(`Cannot add edge to dummy vertex ${h.id}`),null;let u=Object.assign(e,{source:a,target:h});if(this.beforeConnect(a,h,e.data,e.addedByMouse===!0)!==!1){let p=this.graph.addEdge(u,s,this.edgeIdFunction),m={edge:p,source:n,geometry:e.geometry,addedByMouse:e.addedByMouse,reason:t};return this.L(g=>g.$edgeAdded(m,e.context)),o||this.fire(pr,m,null),p}else return this.debugEnabled&&U("Could not add edge"),null}Ia(e,t){let n={edge:e,source:t};this.L((o,s)=>o.$edgeRemoved(n)),this.fire(mt,n,null)}removeEdge(e,t){let n=this.graph.getEdge(e);return n!=null&&(this.graph.deleteEdge(n),n.source.dummy&&K(n.source)&&this.Wo(n.source),n.target.dummy&&K(n.target)&&this.Wo(n.target),this.Ia(n,t)),this}setTarget(e,t){if(t==null)return{success:!1};let[n]=this.Ho(t,e.id,1);if(n==null||this.beforeConnect(e.source,n,e.data)===!1)return{success:!1};let o=this.graph.setTarget(e,n);if(o.success!==!1){let s=o.old;o.old.dummy===!0&&(s={x:o.old.data[this.modelLeftAttribute],y:o.old.data[this.modelTopAttribute]},this.Wo(o.old));let a=o.new;o.new.dummy===!0&&(a={x:o.new.data[this.modelLeftAttribute],y:o.new.data[this.modelTopAttribute]});let l={edge:e,old:s,new:a,success:!0};this.L(h=>{h.$edgeTargetChanged(l)}),this.fire(on,l)}return o}setSource(e,t){if(t==null)return{success:!1};let[n]=this.Ho(t,e.id,0);if(n==null||this.beforeConnect(n,e.target,e.data)===!1)return{success:!1};let o=this.graph.setSource(e,n);if(o.success!==!1){let s=o.old;o.old.dummy===!0&&(s={x:o.old.data[this.modelLeftAttribute],y:o.old.data[this.modelTopAttribute]},this.Wo(o.old));let a=o.new;o.new.dummy===!0&&(a={x:o.new.data[this.modelLeftAttribute],y:o.new.data[this.modelTopAttribute]});let l={edge:e,old:s,new:a,success:!0};this.L(h=>{h.$edgeSourceChanged(l)}),this.fire(sn,l)}return o}addNewPort(e,t,n){let o=this.graph.getVertex(e);this.portFactory(this,t,n,s=>{let a=this.portIdFunction(s),l=o.$addPort(a);l.data=s,this.Zo(o,p0);let h={vertex:o,data:s,port:l};this.L(d=>d.$portAdded(h)),this.fire(ei,h,null)},()=>{})}addPort(e,t){let n=this.graph.getVertex(e),o=n.$addPort(t,this.portIdFunction);this.Zo(n,u0);let s={vertex:n,data:t,port:o};return this.L(a=>a.$portAdded(s)),this.fire(ei,s,null),o}removePort(e,t){let n;if(typeof e=="string"){let o=this.graph.splitPortId(e);o.length===2?(n=this.graph.getVertex(o[0]),t=o[1]):n=this.graph.getVertex(e)}else H(e)?(t=e.id,n=e.getParent()):n=this.graph.getVertex(e);if(n!=null&&t!=null){let o=n.getPort(t);if(o){this.openTransaction(St);let s=o.getAllEdges();for(let l=s.length,h=0;h<l;h++)this.removeEdge(s[0]);n.$removePort(o),this.Zo(n,m0);let a={vertex:n,port:o,edges:s};return this.L(l=>l.$portRemoved(a)),this.fire(Vr,a,null),this.commitTransaction(),!0}}return!1}remove(e,t){if(e==null)return;let n=this.getObjectInfo(e);this.setSuspendRendering(!0);try{if(n.obj&&K(n.obj))this.removeNode(n.obj);else if(n.obj&&Y(n.obj))this.removeGroup(n.obj);else if(n.obj&&Ke(n.obj))this.removeEdge(n.obj);else{for(;e.getNodeCount()>0;)this.removeNode(e.getNodeAt(0));for(;e.getEdgeCount()>0;)this.removeEdge(e.getEdgeAt(0));for(;e.getGroupCount()>0;)this.removeGroup(e.getGroupAt(0),t!==!1)}}finally{this.setSuspendRendering(!1,!0)}}setSuspendRendering(e,t){for(let n in this.Jt)this.Jt.get(n).setSuspendRendering(e,t)}batch(e){this.setSuspendRendering(!0);try{e()}catch(t){U("Error in transaction "+t)}finally{this.setSuspendRendering(!1,!0)}}updateGroup(e,t){this.$_updateVertex(e,t,aS,!1)}$_updateGroup(e,t,n,o){this.$_updateVertex(e,t,n,o)}updateNode(e,t){this.$_updateVertex(e,t,sS,!1)}$_updateNode(e,t,n,o){this.$_updateVertex(e,t,n,o)}updateVertex(e,t){this.$_updateVertex(e,t,LE,!1)}$_updateVertex(e,t,n,o,s){let a=this.getObjectInfo(e);if(a.obj){let h=(H(a.obj)?a.obj.getParent():a.obj).objectType===de.objectType?$e:Re;this.Ad(a.obj,t,o,h,(d,u)=>({vertex:d,updates:t||{},originalData:u,reason:n||LE,source:s}))}}updateVertices(e,t){this.aE(e,LE,!1,t)}aE(e,t,n,o){this.transaction(()=>{e.forEach(s=>{this.$_updateVertex(s.id,s.updates,t,n)})},o||St)}updatePort(e,t){this.$_updatePort(e,t,nu,!1)}$_updatePort(e,t,n,o){let s=this.getObjectInfo(e);s.obj&&this.Ad(s.obj,t,o,ur,(a,l)=>({port:a,vertex:a.getParent(),updates:t||{},originalData:l,reason:n||nu}))}updateEdge(e,t){this.$_updateEdge(e,t,lS,!1)}$_updateEdge(e,t,n,o){let s=typeof e=="string"?this.graph.getEdge(e):e;if(s!=null){let a=Object.assign({},s.data);if(t)if(o)s.data=Object.assign({},t);else for(let l in t)s.data[l]==null?s.data[l]=t[l]:rE(s.data,l,t[l]);this.Sd(a,s),this.fire(pt,{edge:s,updates:t||{},originalData:a,reason:n},null)}}update(e,t){this.cn(e,t,null,!1)}cn(e,t,n,o){if(K(e)){let s=n==null?sS:n;this.$_updateVertex(e,t,s,o)}else if(Y(e)){let s=n==null?aS:n;this.$_updateVertex(e,t,s,o)}else if(Ke(e)){let s=n==null?lS:n;this.$_updateEdge(e,t,s,o)}else if(H(e)){let s=n==null?nu:n;this.$_updatePort(e,t,s,o)}}setEdgeGeometry(e,t,n,o){n=ot(n||e.geometry),e.geometry=ot(t),this.fire(ri,{edge:e,geometry:t,originalGeometry:n,ui:o}),this.L(s=>{s.$edgeGeometryUpdated(e,t,n)})}clearEdgeGeometry(e){this.setEdgeGeometry(e,null,null,null)}getPath(e){return new Sl(this,e)}findGraphObject(e){return e==null?null:e==="*"?this.graph:e.constructor===de||e.constructor===me||e.constructor===le||e.constructor===Fe?e:z(e)||dr(e)?this.graph.getVertex(e):null}Jo(e,t,n,o){return t||n.clear(),n.append(e,s=>{let a={obj:s,selection:n};o&&(this.L(l=>{l.$select(a)}),this.fire(mr,a))})}lE(e,t,n){e=e||{};let o=[],s={},a=h=>{s[h.getId()]||(o.push(h),s[h.getId()]=!0)},l=(h,d,u,p)=>{if(h!=null){let m;Ke(h)?m=[h]:m=t(h),e.filter&&(m=m.filter(e.filter));for(let g=0;g<m.length;g++){let E=d&&h===this.graph||m[g].source===h||n&&H(m[g].source)&&m[g].source.getParent()===h,y=u&&h===this.graph||m[g].target===h||n&&H(m[g].target)&&m[g].target.getParent()===h;(d&&E||u&&y||p&&(E||y))&&a(m[g])}}};return l(this.findGraphObject(e.source),!0,!1,!1),l(this.findGraphObject(e.target),!1,!0,!1),l(this.findGraphObject(e.element),!1,!1,!0),o}Sd(e,t){let n=t.objectType===Fe.objectType?this.edgeTypeProperty:t.objectType===me.objectType?this.portTypeProperty:this.typeProperty;if(t.data[n]!=null&&t.data[n]!==e[n]){let o=t.data[n],s=e[n];t.type=o,this.$dispatchTypeChange(t,s,o)}}Ad(e,t,n,o,s){if(e&&e.objectType){let a=Object.assign({},e.data),l=e.objectType===me.objectType?e.getFullId():e.id,h=e.objectType===me.objectType?this.portIdFunction(a):null,d;if(t){if(n)e.data=Object.assign({},t);else for(let p in t)rE(e.data,p,t[p]);e.objectType===me.objectType&&(d=this.portIdFunction(e.data),d!==e.id&&this.graph.renamePort(e,d),this.Zo(e.getParent(),nu))}let u=s(e,a);u.originalId=l,h!=null&&(u.originalPortId=h),this.L(p=>p.$vertexUpdated(u)),this.Sd(a,e),this.fire(o,u,null)}}Zo(e,t){if(this.portUpdater!=null){let n=this.portUpdater(e.data,e,e.getPorts());if(n!=null&&(e.data=n,!this.Da)){let o=Y(e)?Re:$e,s={vertex:e,updates:{},originalData:e.data,reason:t};this.L(a=>a.$vertexUpdated(s)),this.fire(o,s)}}}getEdges(e){return this.lE(e,t=>t.getEdges(),!1)}getAllEdges(){return this.graph.getAllEdges()}getAllEdgesFor(e,t){return e.getAllEdges(t)}selectAllEdges(){return this.filter(Ke)}addAllEdgesToSelection(){this.addToSelection(this.getAllEdges())}setSelection(e){let t=this.yi(e);this.Jo(t,!1,this.pe,!0)}select(e,t){let n=this.ko(),o=this.yi(e),s=this.Jo(o,!0,n);if(t)for(let a=0;a<s[0].length;a++){let l=s[0][a];if(K(l||Y(l)||H(l))){let h=l.getAllEdges();for(let d=0;d<h.length;d++)n.append(h[d])}}return n}Td(e,t,n,o){let s=e.getAllEdges();for(let a=0,l=s.length;a<l;a++)if(s[a].source===e){let h=s[a].target,d=h.getFullId();o[d]||(t.append(h),n&&t.append(s[a]),o[d]=!0,this.Td(h,t,n,o))}}selectDescendants(e,t,n){let o=this.getObjectInfo(e),s=this.ko();if(o.obj&&o.obj.objectType===de.objectType){t&&this.Jo(o.obj,!0,s);let a={};a[o.obj.getFullId()]=!0,this.Td(o.obj,s,n,a)}return s}yi(e){return e instanceof Sl||e instanceof Er?e:z(e)?this.getVertex(e)||this.getEdge(e):Array.isArray(e)?e.map(t=>z(t)?this.getVertex(e)||this.getEdge(e):t):e}addToSelection(e){let t=this.yi(e);if(t){let n=this.Jo(t,!0,this.pe,!1);n[1]!=null&&n[1].length>0&&this.xi(!1,n[1]),n[0]!=null&&n[0].length>0&&this.xi(!0,n[0])}}xi(e,t){let n=e?mr:gr;for(let o=0;o<t.length;o++){let s={obj:t[o],selection:this.pe};this.L(a=>{e?a.$select(s):a.$deselect(s)}),this.fire(n,s)}}toggleSelection(e){let t=this.yi(e);if(t){let n=[],o=this.pe.toggle(t,(s,a)=>{a||n.push(s)});this.xi(!1,o[1]),this.xi(!1,n),this.xi(!0,o[0])}}removeFromSelection(e){let t=this.yi(e);t&&this.pe.remove(t,n=>{let o={obj:n,selection:this.pe};this.L(s=>{s.$deselect(o)}),this.fire(gr,o)})}addPathToSelection(e){this.addToSelection(this.getPath(e))}clearSelection(){this.pe.clear()}getSelection(){return this.pe}setMaxSelectedNodes(e){this.pe.setMaxNodes(e)}setMaxSelectedEdges(e){this.pe.setMaxEdges(e)}setSelectionCapacityPolicy(e){this.pe.setCapacityPolicy(e)}cE(e){this.fire(e),this.Da=!1}vd(e,t,n){e=e||{};let o=e.type||"json",s=e.data,a=e.url,l=e.jsonp,h=e.onload,d=e.parameters||{},u=e.error||function(m){};if(s==null&&a==null)throw new TypeError("You must supply either data or url to load.");let p=m=>{e.incremental===!1&&this.clear(),this.Da=!0,t===Po?(this.undoRedo&&this.undoRedo.dataLoadStart(),this.L(g=>g.$dataLoadStart())):t===AE&&(this.undoRedo&&this.undoRedo.dataAppendStart(),this.L(g=>g.$dataAppendStart())),this.fire(t),Fb(o,m,this,d),this.cE(n),h&&h(this,m),this.fire(bA),n===Mr?(this.L(g=>g.$dataLoadEnd()),this.undoRedo&&this.undoRedo.dataLoadEnd()):n===SE&&(this.L(g=>g.$dataAppendEnd()),this.undoRedo&&this.undoRedo.dataAppendEnd())};if(s)p(s);else if(a){if(l){let E=a.indexOf("?")===-1?"?":"&";a=a+E+"callback=?"}let m=o===Xt||o===lE?Xt:e.dataType,g=e.headers||{Accept:"application/json"};this.fetchUrl({url:a,success:p,dataType:m,error:u,headers:g})}return this}load(e){return this.vd(e,Po,Mr)}append(e){return this.vd(e,AE,SE)}save(e){if(e==null){U("VisuallyJs: save method requires at least URL parameter - no params given.");return}if(e.url==null){U("VisuallyJs: save method requires at least URL parameter");return}let t=e.data||this.exportData(e),n={"Content-Type":"application/json"};Object.assign(n,e.headers||{}),this.fetchUrl({url:e.url,type:"POST",data:t,success:e.success||function(o){},error:e.error||function(o){},headers:n})}exportData(e){return e=e||{},hE(e.type||Xt,this,e.parameters)}toJSON(){return hE(Xt,this,{})}getRenderer(e){return this.Jt.get(e)}getRenderers(){return this.Jt}L(e,t){this.Jt.forEach((n,o)=>{if(t==null||t!==n)try{e(n,o)}catch(s){U("WARN: could not invoke renderer "+o+" ["+s+"]")}})}$addRenderer(e,t){t=t||V(),this.Jt.set(t,e),e.id=t,e.onDestroy(n=>{this.Jt.delete(n.id)}),this.fire(SA,{renderer:e,id:t})}getObjectInfo(e){let t={obj:null,type:null,id:null};if(e!=null){if(typeof e=="string")e=this.getNode(e)||this.getGroup(e)||this.getPort(e)||this.getEdge(e);else if(typeof e=="object"&&typeof e.objectType=="undefined"){let n=this.idFunction(e),o=this.edgeIdFunction(e);e=this.getNode(n)||this.getGroup(n)||this.getEdge(o)}if(e!=null)t.obj=e;else return t;t.obj!=null&&(t.id=t.obj.id,t.type=t.obj.objectType)}return t}undo(){this.undoRedo&&(this.undoRedo.undo(),this.fire(TA,{undoCount:this.undoRedo.undoStack.length,redoCount:this.undoRedo.redoStack.length}))}redo(){this.undoRedo&&(this.undoRedo.redo(),this.fire(vA,{undoCount:this.undoRedo.undoStack.length,redoCount:this.undoRedo.redoStack.length}))}transaction(e,t){return this.undoRedo?this.undoRedo.transaction(e,t):null}$transaction(e,t,n){return this.undoRedo?this.undoRedo.transaction(e,t,n):null}mergeTransaction(e){return this.undoRedo?this.undoRedo.mergeTransaction(e):null}openTransaction(e){return this.undoRedo?this.undoRedo.openTransaction(e):null}rollbackTransaction(){this.undoRedo&&this.undoRedo.rollbackTransaction()}commitTransaction(e){this.undoRedo&&this.undoRedo.commitTransaction(e)}flushUndoRedo(){this.undoRedo&&this.undoRedo.clear()}get version(){return ru}$_deriveEdgeId(e){return e==null?V():typeof e=="string"?e:this.edgeIdFunction(e)||V()}};var f6="csv";function pS(i){let r=[],e="",t=!1;for(let n=0;n<i.length;n++){let o=i[n],s=i[n+1];t?o==='"'&&s==='"'?(e+='"',n++):o==='"'?t=!1:e+=o:o==='"'?t=!0:o===","?(r.push(e),e=""):e+=o}return r.push(e),r}var wE=class{constructor(r,e){c(this,"csv");c(this,"lines");c(this,"startLine");c(this,"headers");this.csv=r,this.lines=r.split(/\r?\n/).map(t=>t.trim()),e=e||{},this.startLine=e.skipLines!=null?e.skipLines:e.readHeaders?1:0,e.readHeaders?this.lines[0]&&this.lines[0].length>0&&(this.headers=pS(this.lines[0])):this.headers=e.headers}Cd(r){for(let e=this.startLine;e<this.lines.length;e++){let t=this.lines[e].trim();if(t.length===0)continue;let n=pS(t);r(n)}}readLines(r){this.Cd(e=>r(e))}readRecords(r){this.Cd(e=>{let t={};for(let n=0;n<e.length;n++){let o=this.headers?this.headers[n]||`Field ${n+1}`:`Field ${n+1}`;t[o]=e[n]}r(t)})}},mS=(i,r,e)=>{e=e||{};let t=e.nodeDecorator||(l=>l),n=e.edgeDecorator||(l=>l),o=new Map,s=[];new wE(i,{readHeaders:e.readHeaders!==!1,headers:e.readHeaders===!1?["source","target","value"]:null}).readRecords(l=>{o.has(l.source)||o.set(l.source,t({id:l.source},!0)),o.has(l.target)||o.set(l.target,t({id:l.target},!1)),s.push({source:l.source,target:l.target,data:n({value:parseFloat(l.value)},o.get(l.source),o.get(l.target))})}),s.sort((l,h)=>h.data.value-l.data.value),Array.from(o.values()).forEach(l=>r.addNode(l)),s.forEach(l=>r.addEdge(l))};function gS(i){return i.eachNode!=null&&i.eachEdge!=null&&i.eachGroup!=null&&i.filter!=null}function ES(i,r){return r?i:i.toLowerCase()}function g0(i){i=""+i;let r=i.split(/\s/),e=[],t=[],n=4;for(let o=0;o<r.length;o++){let s=bt(r[o].replace(/[^\w]*/,""));s.length>0&&(e.push({token:s,context:""}),t.unshift(s),t.splice(n-1),t.length>1&&(t.reverse(),e.push({token:t.join(" "),context:""}),t.reverse()))}for(t.pop();t.length>1;)t.reverse(),e.push({token:t.join(" "),context:""}),t.reverse(),t.pop();return e}var E0=g0;function z6(i){return i=bt(i),[{token:i.replace(/\s/g,"_"),context:i}]}function f0(i){return[{token:bt(i),context:i}]}function y0(i,r){return i.score>r.score?-1:1}var x0=i=>i.id;function b0(i,r,e){if(i.length===0){i.push(r);return}let t=(n,o)=>{let s=n+Math.floor((o-n)/2),a=i[s],l=e(a,r),h;if(l===0){i.splice(s,0,r);return}else if(l===-1){if(s===i.length-1){i.push(r);return}else if(h=e(i[s+1],r),h!==l){i.splice(s+1,0,r);return}t(s+1,o)}else{if(s===0){i.unshift(r);return}else if(h=e(i[s-1],r),h!==l){i.splice(s,0,r);return}t(n,n+Math.floor((o-n)/2))}};t(0,i.length-1)}var A0=10,Ks=class{constructor(r){c(this,"fields");c(this,"root");c(this,"tokenizer");c(this,"searchTokenizer");c(this,"limit");c(this,"exclusions");c(this,"caseSensitive");c(this,"idFunction");c(this,"sorter");c(this,"Od",0);c(this,"bi",new Map);c(this,"Gr",[]);c(this,"Ko",0);c(this,"Le",{});r=r||{},this.fields=r.fields,this.root=this.Ma(),this.tokenizer=r.tokenizer||E0,this.searchTokenizer=r.searchTokenizer||f0,this.limit=r.limit||A0,this.exclusions=r.exclusions||[],this.caseSensitive=r.caseSensitive===!0,this.idFunction=r.idFunction||x0,this.sorter=r.sorter||y0}Ma(r){return{index:this.Od++,children:{},documentIds:{},key:r}}hE(r,e,t){let n=this.Le[r];n||(n={},this.Le[r]=n),n[e.index]=e}dE(r,e,t){let n=(o,s,a,l)=>{if(s!==a.length){var h=a[s],d=o.children[h];d||(d=this.Ma(h),o.children[h]=d),d.documentIds[l]=d.documentIds[l]||[],d.documentIds[l].push(a),this.hE(l,d,t),n(d,s+1,a,l)}};n(this.root,0,r,e)}removeExclusions(r){let e={};for(let t in r)this.exclusions.indexOf(t)===-1&&(e[t]=r[t]);return e}add(r){let e=t=>{let n=this.removeExclusions(t);b0(this.Gr,{document:n,score:1},this.sorter);var o=this.idFunction(t),s={fields:a=>{for(let l=0;l<this.fields.length;l++){let h=t[this.fields[l]];typeof h=="string"&&a(h)}},document:a=>{for(let l in t)if(l!=="id"){let h=t[l];typeof h=="string"&&a(h)}}};this.bi.set(o,n),s[this.fields?"fields":"document"](a=>{if(a){let l=this.tokenizer(a);for(let h=0;h<l.length;h++)this.dE(ES(l[h].token,this.caseSensitive),o,l[h].context)}}),this.Ko++};if(r.constructor===Array)for(let t=0;t<r.length;t++)e(r[t]);else e(r)}addAll(...r){for(let e=0;e<r.length;e++)this.add(r[e])}reindex(r){this.remove(r),this.add(r)}remove(r){let e=this.idFunction(r),t=this.Le[e],n;if(t)for(n in t)delete t[n].documentIds[e];let o=-1;for(n=0;n<this.Gr.length;n++)if(this.idFunction(this.Gr[n].document)===e){o=n;break}o!==-1&&(this.Gr.splice(o,1),this.Ko=this.Gr.length),this.bi.delete(e)}clear(){this.bi.clear(),this.Le={},this.Od=0,this.Gr.length=0,this.Ko=0,this.root=this.Ma()}getDocumentCount(){return this.Ko}getDocumentList(){return this.Gr}getDocument(r){return this.bi.get(r)}search(r,e){let t=this.searchTokenizer(r),n={},o=[],s={},a={},l=(d,u,p)=>{let m=n[d];m||(m={},n[d]=m,s[d]=0,a[d]=[]),a[d].push(p),m[u]||(m[u]=!0,s[d]++)},h=(d,u,p)=>{if(u===p.length){for(let g in d.documentIds)if(d.documentIds.hasOwnProperty(g)){let E=d.documentIds[g];for(let y=0;y<E.length;y++)l(g,p,E[y])}return}let m=p[u];d.children[m]&&h(d.children[m],u+1,p)};for(let d=0;d<t.length;d++)h(this.root,0,ES(t[d].token,this.caseSensitive));for(let d in n)o.unshift({document:this.bi.get(d),score:s[d],contexts:a[d]});return o.sort(this.sorter),o.slice(0,e==null?this.limit:e)}},fS=class{constructor(r,e){this.instance=r;c(this,"nodeIndex");c(this,"groupIndex");c(this,"edgeIndex");c(this,"portIndex");this.nodeIndex=new Ks(e),this.groupIndex=new Ks(e),this.edgeIndex=new Ks(e),this.portIndex=new Ks(e),r.bind(kt,t=>{this.Pd(t.node)}),r.bind(Le,t=>{this.nodeIndex.remove(t.node.data),t.node.getPorts().forEach(n=>this.portIndex.remove(n.data))}),r.bind($e,t=>{this.nodeIndex.remove(t.vertex.data),this.nodeIndex.add(t.vertex.data)}),r.bind(jt,t=>{this._d(t.group)}),r.bind(Ge,t=>{this.groupIndex.remove(t.group.data)}),r.bind(Re,t=>{this.groupIndex.remove(t.vertex.data),this.groupIndex.add(t.vertex.data)}),r.bind(pr,t=>{this.Rd(t.edge)}),r.bind(mt,t=>{this.edgeIndex.remove({id:t.edge.getId()})}),r.bind(pt,t=>{let n=Object.assign(t.originalData||{},{id:t.edge.getId()});this.edgeIndex.remove(n);let o=Object.assign(t.edge.data||{},{id:t.edge.getId()});this.edgeIndex.add(o)}),r.bind(ei,t=>{this.portIndex.add(t.port.data)}),r.bind(Vr,t=>{this.portIndex.remove(t.port.data)}),r.bind(ur,t=>{this.portIndex.remove(t.port.data),this.portIndex.add(t.port.data)}),r.bind(Ht,()=>{this.nodeIndex.clear(),this.groupIndex.clear(),this.edgeIndex.clear(),this.portIndex.clear()}),this.instance.eachNode((t,n)=>{this.Pd(n)}),this.instance.eachGroup((t,n)=>{this._d(n)}),this.instance.eachEdge((t,n)=>{this.Rd(n)})}Pd(r){this.nodeIndex.add(r.data),r.getPorts().forEach(e=>this.portIndex.add(e.data))}_d(r){this.groupIndex.add(r.data)}Rd(r){let e=Object.assign(r.data||{},{id:r.getId()});this.edgeIndex.add(e)}search(r){let e=this.nodeIndex.search(r).map(s=>this.instance.getNode(s.document.id)),t=this.portIndex.search(r).map(s=>this.instance.getPort(s.document.id)),n=this.groupIndex.search(r).map(s=>this.instance.getGroup(s.document.id)),o=this.edgeIndex.search(r).map(s=>this.instance.getEdge(s.document.id));return{nodes:e,groups:n,edges:o,ports:t}}};var yS="context",DE="lookup",xS="default",ii="element",Ii="text",No="tmpl",oi="each",Gl="if",bS="root",AS="class",SS="style",Io="$value",$l="$key",TS="attribute";function NE(i,r){if(i==null)return i;{let e=i.replace(/\n/g,"").replace(/^[\s]+</,"<").replace("/>",">").replace(/>[\s]+$/,">").split(/^<|>$/)[1].split(r);return vb(e)}}function CS(i){return i.length>0?i[i.length-1]:null}function PS(i){if(i==null||i.length===0)return!1;for(let r=i.length-1;r>-1;r--)if(i[r].type==="each")return!0;return!1}function IE(i,r,e,t,n){let o=V(),s={w:r,expressions:[],id:o};return e.bindings[i]=s,r.replace(/\{\{([^\}]*)\}\}/g,(a,l,h,d)=>{let u=!1;return l.startsWith(":")&&(u=!0,l=l.substring(1)),s.expressions.push([a,l,u]),""}),o}function vS(i,r,e,t,n){e.atts[i]=r,IE(i,r,e,t,n)}function OS(i,r){let e=NE(i,r.attributesRe),t={el:bt(e[0]),atts:{},bindings:{}},n=(o,s)=>{let a=o.match(/([^=]+)=['"](.*)['"]/);return a==null&&s==null?t.atts[o]="":a==null?vS(o,"",t,s,r):vS(a[1],a[2],t,s,r),a};for(let o=1;o<e.length;o++){let s=bt(e[o]);s!=null&&s.length>0&&n(s)}return t}var S0=["*","-","+","/","%"],_S=["==",">","<",">=","<=","===","!=","!==","||"],T0=/([(])|([)])|(===)|(==)|(!==)|(!=)|(!{1,2})|(\|\|)|(<=)|(>=)|(<)|(>)|(\+)|(-)|(\*)|(\/)|(\s+)|([0-9\.]+)|(\$data\[[0-9]+\])|(\$value\[[0-9]+\])|(\$key)|(\$value)|('[^']+')|([#a-zA-Z\$]+[0-9a-zA-Z_\$\.]*)/g,Bl="bool",RS="num",LS="group",wS="var",v0="op",ME="comp",DS="exp",NS="string",IS="array",MS="key",VS="value";function C0(i){return i[i.length-1]}function GS(i){return i.t===LS}function P0(i){return i.t===wS}function O0(i){return i.t===DS}function _0(i){return i.t===RS}function R0(i){return i.t===Bl}function L0(i){return i.t===NS}function w0(i){return i.t===IS}function D0(i){return i.t===MS}function N0(i){return i.t===VS}function I0(i){let r=i.match(T0),e,t=[{t:"root",c:[],e:i,v:null}];for(let n=0;n<r.length;n++){e=r[n];let o=C0(t);if(e==="("){let s={t:LS,c:[],v:null};o.c.push(s),t.push(s)}else if(e===")")t.pop();else if(e.match(/\$value\[[0-9]+\]/)){let s=parseInt(e.substring(7,e.length-1),10);o.c.push({t:IS,v:e,index:s})}else if(e.match(/\$key/))o.c.push({t:MS,v:null});else if(e.match(/\$value/))o.c.push({t:VS,v:null});else if(e.match(/^#/))o.c.push({t:DS,v:e.substring(1)});else if(e.match(/'[a-zA-Z0-9#_\$\.]+'/))o.c.push({t:NS,v:e.replace(/'/g,"")});else if(e.match(/true/))o.c.push({t:Bl,v:!0});else if(e.match(/false/))o.c.push({t:Bl,v:!1});else if(e.match(/^[0-9\.]+$/)){let s=e.indexOf(".")!==-1?parseFloat(e):parseInt(e,10);o.c.push({t:RS,v:s})}else e.match(/[a-zA-Z_\$\.]+/)?o.c.push({t:wS,v:e}):S0.indexOf(e)!==-1?o.c.push({t:v0,v:e}):_S.indexOf(e)!==-1?o.c.push({t:ME,v:e}):e.match(/!{1,2}/)&&(e.length===1?(o.c.push({t:Bl,v:!1}),o.c.push({t:ME,v:"=="})):(o.c.push({t:Bl,v:!1}),o.c.push({t:ME,v:"!=="})))}return t[0]}function M0(i){let r=null,e={t:"root",c:[],v:""},t={t:"root",c:[],v:""},n=e.c;for(let a=0;a<i.c.length;a++)if(_S.indexOf(i.c[a].v)!==-1){if(r!=null)throw new Error("Cannot parse expression; more than one comparator.");r=i.c[a].v,n=t.c}else n.push(i.c[a]);let o=a=>(GS(a)&&(a.c=s(a)),a),s=a=>{let l=a.c;if(l.length===0)return[];let h=[],d=o(l[0]);if(l.length===1)return[d];if(l.length===3)return[d,l[1],o(l[2])];{let u=d,p=null,m;for(let g=1;g<l.length;g+=2)m=l[g],(m.v==="+"||m.v==="-"?1:2)===2?p==null?(p={t:"group",c:[u,m],v:null},h.push(p)):p.c.push(u,m):(p!=null?p.c.push(u):h.push(u),p=null,h.push(m)),u=o(l[g+1]);return p!=null?p.c.push(u):h.push(u),h}};return e.c=s(e),t.c=s(t),{left:e,right:t,comparator:r}}function Fl(i){let r=I0(i);return M0(r)}function Mi(i,r,e,t,n){let o=VE(i.left.c,r,e,t,n);if(i.comparator==null)return o;{let s=VE(i.right.c,r,e,t,n);if(i.comparator==="==")return o==s;if(i.comparator==="===")return o===s;if(i.comparator===">")return o>s;if(i.comparator===">=")return o>=s;if(i.comparator==="<")return o<s;if(i.comparator==="<=")return o<=s;if(i.comparator==="!=")return o!=s;if(i.comparator==="!==")return o!==s;if(i.comparator==="||")return o||s}}function VE(i,r,e,t,n){let o=i.map(l=>GS(l)?VE(l.c,r,e,t,n):P0(l)?r(l.v):O0(l)?e(l.v):w0(l)?r(Io)[l.index]:D0(l)?r($l):N0(l)?r(Io):_0(l)||L0(l)||R0(l)?l.v:l),s=o[0],a;for(let l=1;l<o.length;l+=2){a=o[l].v;let h=o[l+1];a==="+"?s+=h:a==="-"?s-=h:a==="*"?s*=h:a==="/"&&(s/=h)}return typeof s=="undefined"?"":n!=null?n(s,t):s}var Vi=class{constructor(r){this.instance=r;c(this,"tag");c(this,"remove");c(this,"uuid");c(this,"children",[]);c(this,"elements",[]);c(this,"bindings");c(this,"context");c(this,"compiledBindings");this.uuid=V(),r.entries[this.uuid]=this,this.compiledBindings={}}Ld(r){for(let e in r){let t=r[e];t.expressions.length>0&&(this.compiledBindings[e]={id:V(),name:e,expressions:t.expressions.map(([n,o,s])=>{let[a,l]=o==null?[null,null]:o.split(":");return{source:n,expression:Fl(a),once:s,format:l}})})}}};var su=class su extends Vi{constructor(e,t){super(t);c(this,"type","text");c(this,"value");this.value=e.value,this.bindings={};let n={id:V(),w:e.value,expressions:[]};e.value.replace(/\{\{([^\}]*)\}\}/g,function(o,s,a,l){let h=!1;return s.startsWith(":")&&(h=!0,s=s.substring(1)),n.expressions.push([o,s,h]),""}),this.Ld({[su.TEXT_BINDING_NAME]:n})}};c(su,"TEXT_BINDING_NAME","__element");var Gi=su;var au=class au extends Vi{constructor(e,t){super(t);c(this,"type",au.type);c(this,"comment");this.comment=e}};c(au,"type","comment");var qs=au;var lu=class lu extends Vi{constructor(e,t,n,o,s){super(t);this.templateResolver=n;this.stack=o;this.parseIdStack=s;c(this,"type",lu.type);c(this,"namespace");c(this,"atts");c(this,"custom");let a=e.el.split(":");this.tag=e.el,a.length===2&&(this.namespace=a[0]),this.atts=e.atts,this.Ld(e.bindings),this.remove=!1}};c(lu,"type",ii);var Ur=lu;var GE={},si={construct:(i,r,e,t,n,o)=>{let s=GE[i];if(s)return new s(r,e,t,n,o);throw{message:"Recado: unknown element '"+i+"'"}},register:(i,r)=>{GE[i]=r},exists:i=>GE[i]!=null};var cu=class cu extends Ur{constructor(e,t,n,o,s){super(e,t,n,o,s);c(this,"key");c(this,"type",oi);this.context=e.atts.in,this.key=e.atts.key,this.tag=cu.tag}};c(cu,"tag","r-each");var hu=cu;si.register(hu.tag,hu);function $E(i,r,e){i.entryMap[r]=i.entryMap[r]||[],i.entryMap[r].push(e)}function $S(i,r,e,t){for(let n=0;n<r.children.length;n++){let o=r.children[n];$E(i,e,o)}Array.from(r.fragment.childNodes).forEach(n=>t.added.push({el:n})),i.placeholder.before(r.fragment)}var du=class{constructor(r,e,t){this.instance=r;this.tagName=e;this.options=t;c(this,"id");c(this,"template");c(this,"rendered");c(this,"updated");c(this,"fragments",{});c(this,"mounted");c(this,"defaultableFragmentKeys");c(this,"fragmentKeys");c(this,"parsedTemplates",{});c(this,"defaultNamespace");c(this,"decorator");this.id=`custom-${e}`;let n=t.fragments||{};this.defaultableFragmentKeys=t.defaultableFragmentKeys||[],this.template=t.template,this.defaultNamespace=t.defaultNamespace,this.decorator=t.decorator||((s,a)=>null);let o=new Set;for(let s in n){this.fragments[s]=this.fragments[s]||{},o.add(s);for(let a in n[s]){let l=`custom-${e}-${s}-${a}`,h=n[s][a];r.addTemplate(l,h),this.fragments[s][a]=r.parseAndCache(l,d=>{if(d===l)return h})}}this.fragmentKeys=Array.from(o),this.fragmentKeys.sort(),this.parsedTemplates[xe]=this.wd(this.id),this.rendered=t.rendered||function(s,a,l){},this.updated=t.updated||function(s,a,l){},this.mounted=t.mounted}wd(r){return this.instance.parseAndCache(r,e=>{if(e===r)return this.template})}extractTemplateData(r,e){let t=r.split(":"),n=[];for(let o=0;o<t.length;o++){let s=e[t[o]];if(s==null)if(this.defaultableFragmentKeys.indexOf(t[o])!==-1)n.push(xe);else return null;else n.push(s)}return n.join(":")}getAST(r){if(r==null)return this.parsedTemplates[xe];{let e=[],t={};if(this.fragmentKeys.forEach(n=>{let o=this.extractTemplateData(n,r);o!=null&&(t[n]=this.fragments[n][o]||[],e.push(`${n}:${o}`))}),e.length>0){let n=e.join(" ");if(this.parsedTemplates[n]!=null)return this.parsedTemplates[n];{let o=this.wd(n);return this.Dd(o[0],t),this.parsedTemplates[n]=o,o}}return this.parsedTemplates[xe]}}Dd(r,e){let t=[];for(let n=0;n<r.children.length;n++)if(r.children[n].tag==="r-fragment"){let o=e[r.children[n].atts.key]||[];t.push(...o)}else t.push(r.children[n]),this.Dd(r.children[n],e);r.children=t}};function BS(i,r,e,t){t?i.el.style[r]=e:i.el.setAttribute(r,e)}function V0(i,r){i.el.nodeValue=r}function G0(i,r){let e=[];for(let t=0;t<r.children.length;t++)e.push(...Ul(i,r.children[t]));return e}function Ul(i,r){let e=G0(i,r);return r.type===ii?(i.removeElement(r.el),e.unshift(r.el)):r.type===Ii?(i.removeTextNode(r.el),e.unshift(r.el)):r.type===oi&&(r.entryMap={}),e}function FS(i,r,e,t){for(let n in i.bindings)if(n!==AS){let o=i.bindings[n],s=o.binding,a=o.originalValue,l=!1;for(let h=0;h<s.expressions.length;h++)if(!s.expressions[h].once){let d=Mi(s.expressions[h].expression,r,u=>e(u),s.expressions[h].format,t);a=a.replace(s.expressions[h].source,d),d!==o.results[h].result&&(l=!0,o.results[h].result=d)}l&&(i.type===ii?n!==SS?BS(i,n,a,!1):a.split(";").forEach(h=>{let d=h.indexOf(":"),u=h.substring(0,d);BS(i,u,h.substring(d+1),!0)}):i.type===Ii&&V0(i,a))}}function US(){return{added:[],removed:[],elements:[]}}var pu=class pu extends Ur{constructor(e,t,n,o,s){super(e,t,n,o,s);c(this,"type","if");c(this,"tag",pu.tag);c(this,"test");c(this,"expression");this.test=e.atts.test,this.expression=Fl(this.test)}};c(pu,"tag","r-if");var uu=pu;si.register(uu.tag,uu);function BE(i,r,e,t,n){return i.resolution=Mi(i.entry.expression,o=>Oe(r,o),o=>e(o),t,n),i.resolution}var Mo=class extends Ur{constructor(e,t,n,o,s){super(e,t,n,o,s);c(this,"templateId");c(this,"lookup");c(this,"default");if(this.context=e.atts[yS],this.type=No,this.remove=!0,e.atts[DE])this.lookup=e.atts[DE],this.default=e.atts[xS]||"";else{this.templateId=e.atts.id;let a=PS(o);if(s.indexOf(this.templateId)!==-1){if(!a)throw new TypeError("recursive template call ["+this.templateId+"]")}else{let l=n(this.templateId);s.push(this.templateId);let h=this.instance.parse(l,n,null,s);for(let d=0;d<h.length;d++)h[d].context=this.context;this.children=h,s.pop()}}}};c(Mo,"tag","r-tmpl"),si.register(Mo.tag,Mo);function YS(i,r){if(Array.isArray(i))for(let e=0;e<i.length;e++)r(i[e],e);else if(dr(i)){let e=i;for(let t in e)r(e[t],t)}}var Vo=class{constructor(r){c(this,"templateResolver");c(this,"defaultTemplate");c(this,"defaultNamespace");c(this,"macros");c(this,"entries");c(this,"customTags",{});c(this,"formatter");c(this,"Tt",new Map);c(this,"Ai",new Map);c(this,"openRe",new RegExp("<([^/>]*?)>$|<([^/].*[^/])>$"));c(this,"closeRe",new RegExp("^</([^>]+)>"));c(this,"openCloseRe",new RegExp("<(.*)(/>$)"));c(this,"tokenizerRe",/(<[^\^>]+\/>)|(<!--[\s\S]*?-->)|(<[\/a-zA-Z0-9\-:]+(?:\s*[\(a-zA-Z\-\):]+=\"[^\"]*\"|\s*[a-zA-Z\-:]+='[^']+'|\s*[\(a-zA-Z\-\):]|\s*\{\{.*\}\}|\s*\{#.*\})*>)/);c(this,"commentRe",/<!--[\s\S]*?-->/);c(this,"attributesRe",/([\(a-zA-Z0-9\-_:\)]+="[^"]*")|\s+([\(a-zA-Z0-9\-_:\)]+(?=\s.|$))/);c(this,"qo");c(this,"namespaceHandlers",{});c(this,"namespaces",{});r=r||{},this.qo=r.templates||{},this.entries={},this.defaultTemplate=r.defaultTemplate,this.templateResolver=r.templateResolver||this.Nd(),this.macros=r.templateMacros||{},this.formatter=r.formatter,this.defaultNamespace=r.defaultNamespace}resolveTemplate(r){return this.qo[r]!=null?this.qo[r]:this.templateResolver(r)}setAttribute(r,e,t){let n=e.split(":");n.length===1?r.setAttribute(n[0],t):this.namespaces[n[0]]==null?r.setAttribute(e,t):r.setAttributeNS(this.namespaces[n[0]],n[1],t)}clearCache(){this.Tt.clear(),this.Ai.clear()}parseAttributes(r){return NE(r,this.attributesRe)}Id(r,e){return t=>{let n=e?null:this.Tt.get(t);return n==null&&(n=r(t)),n==null&&(n=this.defaultTemplate),n!=null&&this.Tt.set(t,n),n}}getTemplate(r){return this.Ai.get(r)}addTemplate(r,e){this.qo[r]=e}template(r,e,t,n,o){e=e||{};let s=n?null:this.Ai.get(r);if(s!=null)return this.render(s,e,t,o).fragment;{let a=this.parseAndCache(r,t,n);return a!=null?this.render(a,e,t,o).fragment:this.cf()}}mounted(r){r.$recado.mountings.forEach(e=>{e.mount(e.el,e.data,this,e.parent,e.context)})}parseAndCache(r,e,t){let n=this.Ai.get(r);if(n==null||t===!0){e=this.Id(e||(s=>this.resolveTemplate(s)),t);let o=e(r);if(o!=null){let s=zS(this,o,e,null,[r]);return this.Ai.set(r,s),s}}else return n}data(r,e,t){return Oe(r,e,t)}each(r,e,t,n,o){let s;if(Array.isArray(r))for(s=0;s<r.length;s++)e(r[s],t,s,n,o);else for(s in r)r.hasOwnProperty(s)&&e({$key:s,$value:r[s]},t,s,n,o)}lookupValueInDataOrContext(r,e,t){return t.indexOf("$context.")===0?Oe(e,t.substring(9)):Oe(r,t)}update(r,e,t){let n=r.$recado,o=US();return t=t||{},n!=null&&this.xn(n,e,o,t),o}onUpdate(r,e){r.$recado!=null&&(r.$recado.updaters=r.$recado.updaters||[],r.$recado.updaters.push(e))}xn(r,e,t,n,o){if(r.type===bS)for(let s=0;s<r.children.length;s++)this.xn(r.children[s],e,t,n,o);else if(r.type===ii||r.type===Ii){let s=e,a=this.customTags[r.entry.tag];a!=null&&(s=Object.assign({},e),Object.assign(s,a.decorator(e,n)||{})),FS(r,l=>this.lookupValueInDataOrContext(s,n,l),l=>this.Si(l,s,n),this.formatter),a!=null&&a.updated&&a.updated(r.el,s,this);for(let l=0;l<r.children.length;l++)this.xn(r.children[l],s,t,n,o)}else if(r.type===Gl){let s=r,a=s.resolution,l=BE(s,e,h=>this.Si(h,e,n),null,this.formatter);if(!l){for(let h=0;h<r.children.length;h++)Ul(this,r.children[h]).map(d=>t.removed.push({el:d}));r.children.length=0}if(l)if(a)for(let h=0;h<r.children.length;h++)this.xn(r.children[h],e,t,n,s.defaultNamespace||o);else{let h=this.render(r.entry.children,e,this.templateResolver,n,s.defaultNamespace||o);r.children=h.children;for(let d=0;d<r.children.length;d++){let u=r.children[d];s.placeholder.before(u.el),t.added.push({el:u.el})}}}else if(r.type===No){let s=r.entry.context==null||r.entry.context.length===0?e:this.lookupValueInDataOrContext(e,n,r.entry.context);for(let a=0;a<r.children.length;a++)this.xn(r.children[a],s,t,n)}else if(r.type===oi){let s=r,a=this.lookupValueInDataOrContext(e,n,r.entry.context);if(a==null)Ul(this,r).map(l=>t.removed.push({el:l}));else if(s.entry.key==null||s.entry.key.length===0)U("WARN: Cannot update r-each entry when no `key` parameter was set.");else{let l={},h=[],d=[];YS(a,(u,p)=>{let m=Oe(u,s.entry.key);if(l[m]=u,s.entryMap[m]!=null){let g=s.entryMap[m];for(let E=0;E<g.length;E++)h.push({data:u,key:m,execution:g[E]})}else h.push({data:u,key:m})});for(let u in s.entryMap)if(l[u]==null)for(let p=0;p<s.entryMap[u].length;p++)d.push({e:s.entryMap[u][p],key:u});for(let u=0;u<d.length;u++)delete s.entryMap[d[u].key],Ul(this,d[u].e).map(p=>t.removed.push({el:p}));for(let u=0;u<h.length;u++){let p=h[u];if(p.execution)this.xn(p.execution,p.data,t,n),p.execution.el!=null?s.placeholder.before(p.execution.el):p.execution.children.forEach(m=>{m.el!=null&&s.placeholder.before(m.el)});else{let m=this.render(r.entry.children,p.data,null,n);$S(s,m,p.key,t)}}}}if(r.updaters)for(let s=0;s<r.updaters.length;s++)r.updaters[s](r.el);return t}remove(r,e){e&&r.parentNode&&r.parentNode.removeChild(r)}registerTag(r,e){this.customTags[r]=new du(this,r,e)}parse(r,e,t,n){return zS(this,r,e,t,n)}Si(r,e,t){return this.macros[r]&&this.macros[r](e,t)||""}render(r,e,t,n,o){let s={id:V(),fragment:this.cf(),children:[],type:"root",bindings:{},entry:null,mountings:[]},a=s.fragment,l=null,h=s;a.$recado=s,n=n||{};let d=(f,b,A)=>{let T={id:b,entry:f,placeholder:this.cc(`${oi}:${b}`),entryMap:{},type:oi,children:[]};return E(T.placeholder,A),h.children.push(T),T},u=(f,b,A)=>{let T={placeholder:this.cc(`${No}:${b}`),entry:f,id:b,children:[],type:No};return E(T.placeholder,A),h.children.push(T),T},p=(f,b,A,T)=>{y(f,T);let S={id:V(),entry:b,bindings:A,children:[],el:f,type:ii};return h.children.push(S),f.$recado=S,S},m=(f,b,A,T)=>{y(f,T);let S={id:V(),el:f,entry:b,bindings:A,children:[],type:Ii};return h.children.push(S),f.$recado=S,S},g=(f,b,A)=>{let T=V(),S={id:T,entry:f,resolution:!1,placeholder:this.cc(`${Gl}:${T}`),type:Gl,children:[],defaultNamespace:A};return E(S.placeholder,b),h.children.push(S),S},E=(f,b)=>{b!=null?b.before(f):l!=null?l.appendChild(f):a.appendChild(f)},y=(f,b)=>{b!=null?b.before(f):l!=null?l.appendChild(f):a.appendChild(f)},x=(f,b,A,T)=>{b=b||{};let S=!1,R=null;if(f.type===Gl){let v=h,O=g(f,A,o);if(h=O,S=BE(O,b,P=>this.Si(P,b,n),null,this.formatter),S)for(let P=0;P<f.children.length;P++)x(f.children[P],b,O.placeholder,T);h=v,R=O}else if(f.type===oi){let v=f,O=l,P=f.context===Io?b:this.lookupValueInDataOrContext(b,n,f.context),I=h,C=V(),_=d(v,C,A);h=_,P!=null&&YS(P,(w,B)=>{let D=v.key&&dr(w)?Oe(w,v.key):B||null;for(let M=0;M<f.children.length;M++){let N=x(f.children[M],w,_.placeholder,B);D!=null&&$E(_,D,N)}}),l=O,h=I,R=_}else if(f.type===No){let v=f,O=l,P=h,I=V(),C=u(v,I,A);h=C;let _=f.context==null||f.context.length===0?b:Oe(b,f.context),w=v.lookup!=null?Oe(b,v.lookup.replace(/[\{\{\}\}]/g,"")):v.templateId,B=this.parseAndCache(w,t);B==null&&v.default!=null&&(B=this.parseAndCache(v.default,t));for(let D=0;D<B.length;D++)x(B[D],_,C.placeholder,T);l=O,h=P,R=C}else if(f.type===ii){let v,O=f,P,I={},C=[];if(this.customTags[f.tag]!=null){P=this.customTags[f.tag];let D=Object.assign({},b);Object.assign(D,P.decorator(b,n)||{});let M=this.render(P.getAST(D),D,t,n,P.defaultNamespace);v=M.fragment.childNodes[0];let N=M.children[0].bindings;for(let G in N)I[G]=N[G];C.push(...M.children[0].children)}else if(O.namespace!=null&&this.namespaceHandlers[O.namespace])v=this.namespaceHandlers[O.namespace](f.tag);else{let D=o||this.defaultNamespace;D!=null&&this.namespaceHandlers[D]?v=this.namespaceHandlers[D](`${D}:${f.tag}`):v=this.ce(f.tag)}for(let D in O.atts)if(O.atts.hasOwnProperty(D)){let M=O.atts[D];if(f.compiledBindings[D]!=null){let N=f.compiledBindings[D];I[D]={id:N.id,binding:N,results:[],originalValue:M,type:TS};for(let G=0;G<N.expressions.length;G++){let J=N.expressions[G],Ee=Mi(J.expression,j=>j===$l?T:j===Io?b:this.lookupValueInDataOrContext(b,n,j),j=>this.Si(j,b,n),J.format,this.formatter);M=M.replace(J.source,Ee),I[D].results.push({source:J.source,result:Ee})}}this.setAttribute(v,D,M)}P&&(P.rendered&&P.rendered(v,b,this,l,n),P.mounted&&s.mountings.push({mount:P.mounted,el:v,data:b,parent:l,context:n}));let _=l,w=h,B=p(v,O,I,A);B.children.push(...C),h=B,l=v;for(let D=0;D<f.children.length;D++)x(f.children[D],b,null,T);h=w,l=_,R=B}else if(f.type===Ii){let v=f.value||"",O={},P=f.compiledBindings[Gi.TEXT_BINDING_NAME];if(P!=null){O[Gi.TEXT_BINDING_NAME]={id:P.id,binding:P,results:[],originalValue:v,type:Ii};for(let _=0;_<P.expressions.length;_++){let w=P.expressions[_],B=Mi(w.expression,D=>D===$l?T:D===Io?b:this.lookupValueInDataOrContext(b,n,D),D=>this.Si(D,b,n),w.format,this.formatter);v=v.replace(w.source,B),O[Gi.TEXT_BINDING_NAME].results.push({source:w.source,result:B})}}let I=this.ctn(v);R=m(I,f,O,A)}return R};for(let f=0;f<r.length;f++)x(r[f],e||{},null,null),l=null,h=s;return s}};function $0(i){return si.exists(i)}function B0(i,r,e,t,n,o){return si.construct(r,e,i,t,n,o)}function zS(i,r,e,t,n){n=n||[],e=i.Id(e||(E=>i.resolveTemplate(E)),null);let o=[],s=[],a=(E,y)=>{let x=E.match(y);return x==null?null:x},l=()=>o.length>0?o[o.length-1]:null,h=E=>{let y=l();return y!=null&&y.tag===E},d=(E,y)=>{o.length>0&&l().children.push(E),y?o.length===0&&s.push(E):o.push(E)},u=E=>{d(E,!0)},p=()=>{let E=o.pop();if(o.length===0&&!E.remove)s.push(E);else if(E.remove){let y=l();y&&y.children.pop()}return E},m=(E,y,x,f)=>{let b=OS(E,i);return $0(b.el)?B0(i,b.el,b,x,o,n):new Ur(b,i,x,o,n)},g=[{re:i.commentRe,handler:(E,y,x,f,b)=>{d(new qs(E,f),!0)}},{re:i.openRe,handler:(E,y,x,f,b)=>{let A=m(E,y,x,b);d(A,A.remove)}},{re:i.closeRe,handler:(E,y,x,f,b)=>{if(y[1]!==Mo.tag)if(h(y[1]))p();else throw new TypeError("Unbalanced closing tag '"+y[1]+"'; opening tag was '"+p().tag+"'")}},{re:i.openCloseRe,handler:(E,y,x,f,b)=>{let A=m(E,y,x,b);d(A,!0)}},{re:/.*/,handler:(E,y,x,f,b)=>{let A=new Gi({value:E},f);u(A),E.match(/^[\s]*$/)!=null||IE(Gi.TEXT_BINDING_NAME,E,A,null,f)}}];if(Cb(bt(r).split(i.tokenizerRe),(E,y)=>{let x=bt(y);for(let f=0;f<g.length;f++){let b=a(x,g[f].re);if(b){g[f].handler(y,b,e,i,n);break}}}),s.length>0&&t)for(let E in t)s[0][E]=t[E];return s}function XS(i,r){let e=typeof i=="string"?parseFloat(i):i;if(isNaN(e))return i;let t=/^(['|,])?(\.(\d+))?([df])$/,n=r.match(t);if(!n)return e.toString();let o=n[1],s=n[3]?parseInt(n[3],10):null,a=n[4],l;a==="d"?l=Math.floor(e).toString():l=s!==null?e.toFixed(s):e.toString();let h=l.split("."),d="";return o===","?d=",":o==="'"?d=" ":d=1e3.toLocaleString().substring(1,2),h[0]=h[0].replace(/\B(?=(\d{3})+(?!\d))/g,d),h.join(".")}var Yl=class{constructor(){c(this,"childNodes");this.childNodes=[]}removeChild(r){this.childNodes=this.childNodes.filter(e=>e!==r)}appendChild(r){this.childNodes.push(r)}insertAfter(r,e){let t=this.childNodes.indexOf(r);t!=null&&this.childNodes.splice(t,0,e)}insertBefore(r,e){let t=this.childNodes.indexOf(r);t!=null&&this.childNodes.splice(t-1,0,e)}toString(){let r="";for(let e=0;e<this.childNodes.length;e++)r+=this.childNodes[e].toString();return r}},mu=class extends Yl{constructor(e){super();c(this,"nodeType",1);c(this,"parentElement");c(this,"tag");c(this,"atts");c(this,"style",{});this.tag=e,this.atts={}}getAttribute(e){return this.atts[e]}setAttributeNS(e,t,n){this.atts[e+":"+t]=n}setAttribute(e,t){this.atts[e]=t}toString(){let e="<"+this.tag,t="";for(let n in this.atts)t+=" "+n+'="'+this.atts[n]+'"';e=e+t+">";for(let n=0;n<this.childNodes.length;n++)e+=this.childNodes[n].toString();return e+"</"+this.tag+">"}after(e){this.parentElement.insertAfter(this,e)}before(e){this.parentElement.insertBefore(this,e)}},gu=class{constructor(r){this.nodeValue=r;c(this,"parentElement");c(this,"nodeType",3)}toString(){return this.nodeValue}after(r){this.parentElement.insertAfter(this,r)}},Eu=class{constructor(r){this.nodeValue=r;c(this,"parentElement");c(this,"nodeType",8)}before(r){this.parentElement.insertBefore(this,r)}};var FE=class extends Vo{Nd(){return null}ce(r){return new mu(r)}cf(){return new Yl}ctn(r){return new gu(r)}cc(r){return new Eu(r)}removeElement(r){}removeTextNode(r){}};function fu(i){let r={};for(let e=0;e<i.length;e++)r[i[e].id]=i[e];return r}function UE(i,r){let e=r===0?"x":"y";return i.target[e]<i.source[e]?-1:1}function jS(i,r,e){let t=e===0?"x":"y";return i.source[t]>r.source[t]&&i.source[t]<r.target[t]||r.source[t]>i.source[t]&&r.source[t]<i.target[t]||i.target[t]>r.target[t]&&i.target[t]<r.source[t]||r.target[t]>i.target[t]&&r.target[t]<i.source[t]}function yu(i,r,e,t,n){let o=i,s=r;for(let a=0;a<o.length;a++){let l=o[a];l.sourcePosition=t(l.sourceId),l.sourceSize=n(l.sourceId),l.targetPosition=t(l.targetId),l.targetSize=n(l.targetId),l.sourceCenter={x:l.sourcePosition.x+l.sourceSize.width/2,y:l.sourcePosition.y+l.sourceSize.height/2},l.targetCenter={x:l.targetPosition.x+l.targetSize.width/2,y:l.targetPosition.y+l.targetSize.height/2};for(let h=0;h<l.path.length;h++){let d=e[l.path[h]],u=h<l.path.length-1?e[l.path[h+1]]:null;d.edges=d.edges||[],d.edges.push({edge:l,next:u})}}for(let a=0;a<s.length;a++)if(s[a].edges){let l=s[a];l.edges.sort((u,p)=>{let m=u.edge.pathDirection,g=p.edge.pathDirection,E=u.edge.path.indexOf(l.id),y=p.edge.path.indexOf(l.id),x=m===1?E+1:E-1,f=g===1?y+1:y-1,b=x>=0&&x<u.edge.path.length?e[u.edge.path[x]]:null,A=f>=0&&f<p.edge.path.length?e[p.edge.path[f]]:null,T=m===1?E-1:E+1,S=g===1?y-1:y+1,R=T>=0&&T<u.edge.path.length?e[u.edge.path[T]]:null,v=S>=0&&S<p.edge.path.length?e[p.edge.path[S]]:null,O=l.axis===0?Q:fe,P=b?b.midpoint[O]:R?R.midpoint[O]:p.edge.sourceCenter[O]!==u.edge.sourceCenter[O]?u.edge.sourceCenter[O]:u.edge.targetCenter[O],I=b?A.midpoint[O]:v?v.midpoint[O]:u.edge.sourceCenter[O]!==p.edge.sourceCenter[O]?p.edge.sourceCenter[O]:p.edge.targetCenter[O];return P-I});let h=s[a].length/(s[a].edges.length+1),d=h;for(let u=0;u<s[a].edges.length;u++)s[a].edges[u].location=d,d+=h}}function xu(i,r,e){for(let t=0;t<i.length;t++){let n=i[t];n.regionPath=n.regionPath||[];for(let o=0;o<n.path.length;o++){let s=e[n.path[o]],a=s.edges.find(d=>d.edge.id===n.id),l=a.edge.pathDirection;if(!(a.edge.pathDirection===1&&s.b.type==="vertex"||a.edge.pathDirection===-1&&s.a.type==="vertex")){let d=a.next.edges.find(A=>A.edge.id===n.id),u=r.find(A=>A.id===(l===1?s.b.id:s.a.id)),p=s.axis===0?l===1?0:u.height:l===1?0:u.width,m=s.axis===0?l===1?u.height:0:l===1?u.width:0,g=s.segment.point1-(s.axis===0?u.left:u.top),E=a.next.segment.point1-(s.axis===0?u.left:u.top),y=s.axis===0?"x":"y",x=s.axis===0?"y":"x",f={[y]:a.location+g,[x]:p},b={[y]:d.location+E,[x]:m};u.lines.push({source:f,target:b,id:n.id}),n.regionPath.push(u)}}}}var bu="separate",D7="bus";function HS(i){let r=i.axis,e=i.gates,t=i.gateMap||fu(e),n=i.mode||bu,o=i.regions,s=i.edges,a=i.pad||10,l={};yu(s,e,t,i.getVertexPosition,i.getVertexSize),xu(s,o,t);for(let h=0;h<o.length;h++){o[h].edgeMap={};let d=[],u=o[h].lines;for(let x=0;x<u.length;x++){let f=[];for(let b=0;b<d.length;b++)e:for(let A=0;A<d[b].length;A++)if(jS(u[x],d[b][A],r)){f.push(b);break e}if(f.length===0)d.push([u[x]]);else{let b=[u[x]],A=[];for(let T=0;T<d.length;T++)f.indexOf(T)!==-1?b=b.concat(d[T]):A.push(d[T]);A.push(b),d=A}}for(let x=0;x<d.length;x++)d[x].sort((f,b)=>{let A=UE(f,r),T=UE(b,r),S=r==0?"x":"y";return A===T?A<0?f.source[S]-b.source[S]:b.source[S]-f.source[S]:f.source[S]-b.source[S]});o[h].lineSets=d;let p=r===0?o[h].height:o[h].width,m=r===0?o[h].left:o[h].top,g=r===0?o[h].top:o[h].left,E=r===0?"x":"y",y=r===1?"x":"y";if(n===bu)for(let x=0;x<d.length;x++){let f=(p-a)/(d[x].length+1),b=a+f;for(let A=0;A<d[x].length;A++){let T=d[x][A];l[T.id]=l[T.id]||[],o[h].edgeMap[T.id]=[{[E]:T.source[E]+m,[y]:T.source[y]+g},{[E]:T.source[E]+m,[y]:b+g},{[E]:T.target[E]+m,[y]:b+g},{[E]:T.target[E]+m,[y]:T.target[y]+g}],b+=f}}else for(let x=0;x<d.length;x++){let f=(p-a)/2,b=a+f;for(let A=0;A<d[x].length;A++){let T=d[x][A];o[h].edgeMap[T.id]=[{[E]:T.source[E]+m,[y]:T.source[y]+g},{[E]:T.source[E]+m,[y]:b+g},{[E]:T.target[E]+m,[y]:b+g},{[E]:T.target[E]+m,[y]:T.target[y]+g}]}}}for(let h=0;h<s.length;h++){let d=s[h];l[d.id]=[],d.regionPath.forEach(p=>{let m=p.edgeMap[d.id];l[d.id].push(...m)})}return l}function kS(i){let r=i.gates,e=fu(r),t=i.regions,n=i.edges,o={};yu(n,r,e,i.getVertexPosition,i.getVertexSize),xu(n,t,e);for(let s=0;s<t.length;s++){t[s].edgeMap={};let a=t[s].lines;for(let l=0;l<a.length;l++){let h=a[l];t[s].edgeMap[h.id]=[{x:h.source.x+t[s].left,y:h.source.y+t[s].top},{x:h.target.x+t[s].left,y:h.target.y+t[s].top}]}}for(let s=0;s<n.length;s++){let a=n[s];o[a.id]=[],a.regionPath.forEach(h=>{let d=h.edgeMap[a.id];o[a.id].push(...d)})}return o}var WS=4;function ZS(i){return{x:Math.ceil(i.x+i.width/2),y:Math.ceil(i.y+i.height/2)}}var Qs={sortRect:i=>{let r,e=1/0,t=-1/0;i.forEach(s=>{r=ZS(s),t=Math.max(t,r.x,r.y),e=Math.min(e,r.x,r.y)});let n=t-e;return i.sort(s=>(r=ZS(s),Qs.toHilbertCoordinates(n,r.x-e,r.y-e)))},toHilbertCoordinates:(i,r,e)=>{let t=i,n=(1<<t)-1,o=0,s=r^e,a=~r&n,l=~e&n,h=a^e,d=0,u=0;for(let p=1;p<t;p++)u=(u&s|(d^l)&h)>>1,d=(d&(u^a)|~d&(u^l))>>1;return o=~d&(u^r)|d&(u^l),Qs.hilbertInterleaveBits(o,s)},hilbertInterleaveBits:(i,r)=>{let e=0,t=Math.max(i,r),n=0;for(;t>0;)n++,t>>=1;for(let o=0;o<n;o++){let s=1<<o,a=(r&s)>0?1<<2*o:0,l=(i&s)>0?1<<2*o+1:0;e+=a+l}return e}};function JS(i){return i.height*i.width}function YE(i,r){i.x===1/0?(i.height=r.height,i.width=r.width,i.x=r.x,i.y=r.y):(i.height=Math.max(i.y+i.height,r.y+r.height)-Math.min(i.y,r.y),i.width=Math.max(i.x+i.width,r.x+r.width)-Math.min(i.x,r.x),i.x=Math.min(i.x,r.x),i.y=Math.min(i.y,r.y))}function zE(i){i.x=Math.min(...i.children.map(r=>r.x)),i.y=Math.min(...i.children.map(r=>r.y)),i.width=Math.max(...i.children.map(r=>r.x+r.width))-i.x,i.height=Math.max(...i.children.map(r=>r.y+r.height))-i.y,i.parent!=null&&zE(i.parent)}function KS(i,r){return i.x===1/0?JS(r):(Math.max(i.y+i.height,r.y+r.height)-Math.min(i.y,r.y))*(Math.max(i.x+i.width,r.x+r.width)-Math.min(i.x,r.x))-JS(i)}function XE(i){let r=Math.floor(i.children.length/2),e=Go(),t=Go();return Qs.sortRect(i.children).forEach((n,o)=>{o<=r?$o(e,n):$o(t,n)}),i.children.length=0,[e,t]}function Go(i){return{x:1/0,y:1/0,width:0,height:0,children:[],parent:null,id:i,data:null}}function Au(i){return i.children==null||i.children.length===0}function qS(i){return Au(i)||Au(i.children[0])}function $o(i,r){r.parent=i,i.children.push(r),YE(i,r)}function jE(i,r){let e=i.children.indexOf(r);return e>=0?(i.children.splice(e,1),!0):!1}function F0(i){return i.reduce(function(r,e){return Array.isArray(e)?r.concat(F0(e)):r.concat(e)},[])}function QS(i,r){let e=i.map(r);return i[e.indexOf(Math.min.apply(null,e))]}function eT(i){i.parent&&(jE(i.parent,i),zE(i.parent))}var ea=class{constructor(r){c(this,"Wt");c(this,"ee");c(this,"bn",{});this.Wt=r||WS,this.ee=Go()}search(r,e){let t=[];return this.Md(r,(n,o)=>t.push(n),e),t}searchAndRank(r,e){let t=[];return this.Md(r,(n,o)=>t.push({node:n,overlap:kg(n,r)}),e),t.sort((n,o)=>n.overlap<o.overlap?-1:1),t}Md(r,e,t){if(this.ee.children.length===0)return;t=t||{};let n=Object.assign({},r);t.margin&&(n.x-=t.margin,n.y-=t.margin,n.width+=2*t.margin,n.height+=2*t.margin);let o=s=>{if(ke(s,n))for(let a=0;a<s.children.length;a++){let l=s.children[a];if(ke(l,n))if(l.id!=null){if(t.minimumOverlap!=null&&kg(l,n)<t.minimumOverlap)continue;if(e(l,n),t.greedy)return}else o(l)}};o(this.ee)}findIntersectionsWithLine(r,e){let t=[];e=e||[];let n=o=>{Eb(r,o)&&(Au(o)?e.indexOf(o.id)===-1&&t.push(o):o.children.forEach(n))};return n(this.ee),t}insert(r){let e=n=>{let o=this.ee;if(o){let s={x:n.x,y:n.y,width:n.width,height:n.height,data:n.data,children:[],id:n.id};for(n.id&&(this.bn[n.id]=s);!qS(o);)YE(o,s),o=QS(o.children,a=>KS(a,s));$o(o,s),this.uE(s)}},t=Array.isArray(r)?r:[r];for(let n=0;n<t.length;n++)e(t[n])}uE(r){let e=r;for(;e.parent&&e.parent.children.length>this.Wt;)e=e.parent,e!=this.ee?(jE(e.parent,e),XE(e).forEach(t=>{$o(e.parent,t)})):e==this.ee&&XE(e).forEach(t=>{$o(e,t)})}Vd(r,e){e===void 0&&(e=1);let t=Math.ceil(r.length/this.Wt),n=[],o=0,s;for(let a=0;a<t;a++){s=Go(),o=Math.min(this.Wt,r.length);for(let l=0;l<o;l++){let h=r.pop();h.id&&(this.bn[h.id]=h),$o(s,h)}n.push(s)}return t>1?this.Vd(n,e+1):n}load(r){if(r!=null&&r.length>0){let e=Qs.sortRect(r);this.ee=this.Vd(e)[0]||Go()}}getBounds(){return{x:this.ee.x,y:this.ee.y,width:this.ee.width,height:this.ee.height}}getExtents(){return{xmin:this.ee.x,ymin:this.ee.y,xmax:this.ee.x+this.ee.width,ymax:this.ee.y+this.ee.height}}removeById(r){let e=this.searchById(r);return e&&e.parent&&this.Gd(e),e}Gd(r,e){let t=[],n=r.parent;for(eT(r),r.id!=null&&delete this.bn[r.id];n!=null&&n!==this.ee;)n.children.length<=this.Wt/2&&(eT(n),t.push(...this.pE(n))),n=n.parent;e&&t.push(...e),this.insert(t)}searchById(r){return r==null?null:this.bn[r]}update(r,e,t,n,o,s){let a=this.searchById(r);a?this.Gd(a,[{x:e,y:t,width:n,height:o,data:s||a.data,children:[],id:r}]):this.insert({id:r,x:e,y:t,width:n,height:o,data:s,children:[]})}clear(){this.ee=Go(),this.bn={}}getLeafNodes(){return Object.values(this.bn)}pE(r){let e=[],t=n=>{n.id!=null?e.push(n):n.children.forEach(t)};return t(r),e}};var Su=class i{constructor(r){this.instance=r;c(this,"se",[]);c(this,"K",[]);c(this,"q",[])}static from(r){let e=new i(r.instance);return e.se=r.se.slice(),e.K=r.K.slice(),e.q=r.q.slice(),e}paste(r,e){let t=e&&e.origin,n=e&&e.hermetic===!0,o=e&&e.shallow===!0,s=this.mE(r,t,n,o);return this.instance.transaction(()=>{s.groups.forEach(a=>this.instance.addGroup(a)),s.nodes.forEach(a=>this.instance.addNode(a)),s.edges.forEach(a=>this.instance.$_addEdge(a,Vb,null))}),s}mE(r,e,t,n){let o={nodes:[],groups:[],edges:[],vertexMap:new Map,edgeMap:new Map,origin:{x:0,y:0},transform:{x:0,y:0}},s=[],a=this.instance.modelLeftAttribute,l=this.instance.modelTopAttribute,h=1/0,d=1/0,u=new Map;function p(g){let E=r.getCoordinates(g,!0);u.set(g.id,E),g.group==null&&(h=Math.min(h,E.x),d=Math.min(d,E.y))}this.K.forEach(p),this.se.forEach(p),o.origin.x=h,o.origin.y=d,o.transform.x=e!=null?e.x-o.origin.x:0,o.transform.y=e!=null?e.y-o.origin.y:0;let m=(g,E,y)=>{y=y||0;let x=Object.assign({},g.data),f=V();if(o.vertexMap.set(g.getFullId(),f),x.id=f,E==null){let b=u.get(g.getFullId());x[a]=b.x+o.transform.x,x[l]=b.y+o.transform.y,x.group!=null&&delete x.group}else x.group=E.id;return!n&&Y(g)&&g.getMembers().forEach(b=>{let A=m(b,x,y+1);Y(b)?s.push(A):o.nodes.push(A[0])}),[x,y]};return this.se.forEach(g=>o.nodes.push(m(g,null,0)[0])),this.K.forEach(g=>s.push(m(g,null,0))),s.sort((g,E)=>g[1]<E[1]?-1:1),o.groups=s.map(g=>g[0]),this.q.forEach(g=>{let E,y,x=g.source,f=H(x)?x.getParent():x,b=o.vertexMap.get(f.id),A=g.target,T=H(A)?A.getParent():A,S=o.vertexMap.get(T.id);if(b==null){if(t)return;E=f.id}else E=b;if(S==null){if(t)return;y=T.id}else y=S;let R={source:E,target:y,data:Object.assign({},g.data||{})};if(R.data.id!=null){let v=V();o.edgeMap.set(R.data.id,v),R.data.id=v}g.geometry!=null&&S!=null&&b!=null&&(R.geometry=r.transformGeometry(g,o.transform.x,o.transform.y)),o.edges.push(R)}),o}};var Tu=class{constructor(r){this.instance=r;c(this,"stack",[])}copy(r){let e=this.instance.select(r);this.stack.push(Su.from(e))}paste(r){let t=r&&r.clear===!0?this.stack.pop():this.stack[this.stack.length-1];return t!=null?t.paste(this.$getCopyDataTransformer(),r):null}clear(){this.stack.length=0}copyCurrentSelection(){this.copy(this.instance.getSelection())}pasteCurrentSelection(r){return this.copyCurrentSelection(),this.paste(r)}};var HE="Anchor",Et="top",Tt="left",vt="right",Ct="bottom",$i={[Et]:{x:0,y:-1},[Ct]:{x:0,y:1},[vt]:{x:1,y:0},[Tt]:{x:-1,y:0}},JJ=[Tt,vt],KJ=[Et,Ct],qJ={[Et]:[Tt,vt],[Ct]:[Tt,vt],[Tt]:[Ct,Et],[vt]:[Ct,Et]},QJ={[Et]:Ct,[Ct]:Et,[Tt]:vt,[vt]:Tt},U0=(s=>(s.Circle="Circle",s.Ellipse="Ellipse",s.Triangle="Triangle",s.Diamond="Diamond",s.Rectangle="Rectangle",s.Square="Square",s))(U0||{}),vu=(f=>(f.Assign="Assign",f.AutoDefault="AutoDefault",f.Bottom="Bottom",f.BottomLeft="BottomLeft",f.BottomRight="BottomRight",f.Center="Center",f.Continuous="Continuous",f.ContinuousBottom="ContinuousBottom",f.ContinuousLeft="ContinuousLeft",f.ContinuousRight="ContinuousRight",f.ContinuousTop="ContinuousTop",f.ContinuousLeftRight="ContinuousLeftRight",f.ContinuousTopBottom="ContinuousTopBottom",f.Left="Left",f.Right="Right",f.Top="Top",f.TopLeft="TopLeft",f.TopRight="TopRight",f))(vu||{});var an={};function ta(i,r){an[i]=r}var fr={lineIntersection(i,r,e,t,n){return an[i.type].lineIntersection(i,r,e,t,n)},boxIntersection(i,r,e,t,n){return an[i.type].boxIntersection(i,r,e,t,n)},boundingBoxIntersection(i,r){return an[i.type].boundingBoxIntersection(i,r)},pointOnPath(i,r,e){return an[i.type].pointOnPath(i,r,e)},gradientAtPoint(i,r,e){return an[i.type].gradientAtPoint(i,r,e)},pointAlongPathFrom(i,r,e,t){return an[i.type].pointAlongPathFrom(i,r,e,t)},findClosestPointOnPath(i,r,e){return an[i.type].findClosestPointOnPath(i,r,e)},getPath(i,r){return an[i.type].getPath(i,r)}};function kE(i){return an[i.type].getLength(i)}function tT(i,r){return an[i].create(r)}function Y0(){return{d:1/0,x:null,y:null,l:null,x1:null,y1:null,x2:null,y2:null}}function rT(i,r,e){return Y0()}function nT(i,r,e,t,n){return[]}function zl(i,r,e,t,n){let o=[];return o.push.apply(o,fr.lineIntersection(i,r,e,r+t,e)),o.push.apply(o,fr.lineIntersection(i,r+t,e,r+t,e+n)),o.push.apply(o,fr.lineIntersection(i,r+t,e+n,r,e+n)),o.push.apply(o,fr.lineIntersection(i,r,e+n,r,e)),o}function iT(i,r){return zl(i,r.x,r.y,r.width,r.height)}function ra(i){return Object.assign({extents:Pi()},i)}function z0(){return{sx:0,sy:0,tx:0,ty:0,so:{x:0,y:0},to:{x:0,y:0},x:0,y:0,w:0,h:0,quadrant:1,startStubX:0,startStubY:0,endStubX:0,endStubY:0,isXGreaterThanStubTimes2:!1,isYGreaterThanStubTimes2:!1,opposite:!1,perpendicular:!1,orthogonal:!1,sourceAxis:Q,stubs:[0,0]}}function na(i,r,e){return{x:i.x,y:i.y,ox:i.ox,oy:i.oy,curX:i.curX+r,curY:i.curY+e}}function Cu(i,r,e,t){let n=e.gap||0,o=e.stub||t,s=Array.isArray(o)?o[0]:o,a=Array.isArray(o)?o[1]:o;return{type:i,internalSegments:[],segmentProportionalLengths:[],segmentProportions:[],totalLength:0,cssClass:e.cssClass||"",hoverClass:e.hoverClass||"",gap:n,stub:o,sourceStub:s,targetStub:a,sourceGap:Array.isArray(n)?n[0]:n,targetGap:Array.isArray(n)?n[1]:n,typeDescriptor:"connector",geometry:null,idPrefix:"_vjs_connector",bounds:Pi(),x:0,y:0,width:0,height:0,edited:!1,strokeWidth:1,typeId:null,quadrant:0,paintInfo:z0()}}function WE(i,r,e){let t=e===0?r.anchors.source:r.anchors.target;t.isFixed=!0,t.fixedLocation=Object.assign({},i,{offsetX:i.offsetX==null?0:i.offsetX,offsetY:i.offsetY==null?0:i.offsetY})}var oT=.45,X0=62;function Pu(i,r,e){let t=Cu(i,r,e,[0,0]);return Object.assign(t,{curviness:e.curviness||10,gap:e.gap||5,proximityLimit:e.proximityLimit||80,clockwise:e.orientation&&e.orientation==="clockwise",loopbackDistance:e.loopbackDistance||X0,isLoopbackCurrently:!1,constrain:rn,smooth:!0})}var On={subtract:(i,r)=>({x:i.x-r.x,y:i.y-r.y}),dotProduct:(i,r)=>i.x*r.x+i.y*r.y,square:i=>Math.sqrt(i.x*i.x+i.y*i.y),scale:(i,r)=>({x:i.x*r,y:i.y*r})},sT=64,j0=Math.pow(2,-sT-1);function H0(i,r){let e=[],t=k0(i,r),n=r.length-1,o=2*n-1,s=ZE(t,o,e,0),a=On.subtract(i,r[0]),l=On.square(a),h=0,d;for(let u=0;u<s;u++)a=On.subtract(i,JE(r,n,e[u],null,null)),d=On.square(a),d<l&&(l=d,h=e[u]);return a=On.subtract(i,r[n]),d=On.square(a),d<l&&(l=d,h=1),{location:h,distance:l}}function dT(i,r){let e=H0(i,r);return{point:JE(r,r.length-1,e.location,null,null),location:e.location}}function k0(i,r){let e=r.length-1,t=2*e-1,n=[],o=[],s=[],a=[],l=[[1,.6,.3,.1],[.4,.6,.6,.4],[.1,.3,.6,1]];for(let u=0;u<=e;u++)n[u]=On.subtract(r[u],i);for(let u=0;u<=e-1;u++)o[u]=On.subtract(r[u+1],r[u]),o[u]=On.scale(o[u],3);for(let u=0;u<=e-1;u++)for(let p=0;p<=e;p++)s[u]||(s[u]=[]),s[u][p]=On.dotProduct(o[u],n[p]);for(let u=0;u<=t;u++)a[u]||(a[u]=[]),a[u].y=0,a[u].x=parseFloat(""+u)/t;let h=e,d=e-1;for(let u=0;u<=h+d;u++){let p=Math.max(0,u-d),m=Math.min(u,h);for(let g=p;g<=m;g++){let E=u-g;a[g+E].y+=s[E][g]*l[E][g]}}return a}function ZE(i,r,e,t){let n=[],o=[],s,a,l=[],h=[];switch(W0(i,r)){case 0:return 0;case 1:{if(t>=sT)return e[0]=(i[0].x+i[r].x)/2,1;if(Z0(i,r))return e[0]=J0(i,r),1;break}}JE(i,r,.5,n,o),s=ZE(n,r,l,t+1),a=ZE(o,r,h,t+1);for(let d=0;d<s;d++)e[d]=l[d];for(let d=0;d<a;d++)e[d+s]=h[d];return s+a}function W0(i,r){let e=0,t,n;t=n=Math.sign(i[0].y);for(let o=1;o<=r;o++)t=Math.sign(i[o].y),t!=n&&e++,n=t;return e}function Z0(i,r){let e,t,n,o,s,a,l,h,d,u,p,m,g,E,y,x;a=i[0].y-i[r].y,l=i[r].x-i[0].x,h=i[0].x*i[r].y-i[r].x*i[0].y;let f,b;f=b=0;for(let A=1;A<r;A++){let T=a*i[A].x+l*i[A].y+h;T>f?f=T:T<b&&(b=T)}return p=0,m=1,g=0,E=a,y=l,x=h-f,d=p*y-E*m,u=1/d,t=(m*x-y*g)*u,E=a,y=l,x=h-b,d=p*y-E*m,u=1/d,n=(m*x-y*g)*u,o=Math.min(t,n),s=Math.max(t,n),e=s-o,e<j0?1:0}function J0(i,r){let e=1,t=0,n=i[r].x-i[0].x,o=i[r].y-i[0].y,s=i[0].x-0,a=i[0].y-0,l=n*t-o*e,h=1/l,d=(n*a-o*s)*h;return 0+e*d}function JE(i,r,e,t,n){let o=[[]];for(let s=0;s<=r;s++)o[0][s]=i[s];for(let s=1;s<=r;s++)for(let a=0;a<=r-s;a++)o[s]||(o[s]=[]),o[s][a]||(o[s][a]={}),o[s][a].x=(1-e)*o[s-1][a].x+e*o[s-1][a+1].x,o[s][a].y=(1-e)*o[s-1][a].y+e*o[s-1][a+1].y;if(t!=null)for(let s=0;s<=r;s++)t[s]=o[s][0];if(n!=null)for(let s=0;s<=r;s++)n[s]=o[r-s][s];return o[r][0]}function K0(i,r){let e=[];i--;for(let t=0;t<=i;t++)e.push(q0(t/i,r));return e}function q0(i,r){let e={x:0,y:0};if(i===0)return r[0];let t=r.length-1;if(i===1)return r[t];let n=r,o=1-i;if(t===0)return r[0];if(t===1)return{x:o*n[0].x+i*n[1].x,y:o*n[0].y+i*n[1].y};if(4>t){let s=o*o,a=i*i,l=0,h,d,u;return t===2?(n=[n[0],n[1],n[2],e],h=s,d=2*(o*i),u=a):t===3&&(h=s*o,d=3*(s*i),u=3*(o*a),l=i*a),{x:h*n[0].x+d*n[1].x+u*n[2].x+l*n[3].x,y:h*n[0].y+d*n[1].y+u*n[2].y+l*n[3].y}}else return e}function uT(i){let r=0;if(!hT(i)){let t=K0(16,i);for(let n=0;n<15;n++){let o=t[n],s=t[n+1];r+=lT(o,s)}}return r}var aT=new Map;function Q0(i){let r=aT.get(i);if(!r){r=[];let e=()=>l=>Math.pow(l,i),t=()=>l=>Math.pow(1-l,i),n=l=>h=>l,o=()=>l=>l,s=()=>l=>1-l,a=l=>h=>{let d=1;for(let u=0;u<l.length;u++)d=d*l[u](h);return d};r.push(e());for(let l=1;l<i;l++){let h=[n(i)];for(let d=0;d<i-l;d++)h.push(o());for(let d=0;d<l;d++)h.push(s());r.push(a(h))}r.push(t()),aT.set(i,r)}return r}function ia(i,r){let e=Q0(i.length-1),t=0,n=0;for(let o=0;o<i.length;o++)t=t+i[o].x*e[o](1-r),n=n+i[o].y*e[o](1-r);return{x:t,y:n}}function lT(i,r){return Math.sqrt(Math.pow(i.x-r.x,2)+Math.pow(i.y-r.y,2))}function hT(i){return i[0].x===i[1].x&&i[0].y===i[1].y}function Ou(i,r,e){if(hT(i))return{point:i[0],location:r};let t=ia(i,r),n=0,o=r,s=e>0?1:-1,a=null;for(;n<Math.abs(e);)o+=.005*s,a=ia(i,o),n+=lT(a,t),t=a;return{point:a,location:o}}function pT(i,r,e){return Ou(i,r,e).point}function mT(i,r,e){return Ou(i,r,e).location}function _u(i,r){let e=ia(i,r),t=ia(i.slice(0,i.length-1),r),n=t.y-e.y,o=t.x-e.x;return n===0?1/0:Math.atan(n/o)}function H9(i,r,e){let t=Ou(i,r,e);return t.location>1&&(t.location=1),t.location<0&&(t.location=0),_u(i,t.location)}function k9(i,r,e,t){t=t==null?0:t;let n=Ou(i,r,t),o=_u(i,n.location),s=Math.atan(-1/o),a=e/2*Math.sin(s),l=e/2*Math.cos(s);return[{x:n.point.x+l,y:n.point.y+a},{x:n.point.x-l,y:n.point.y-a}]}function _n(i,r,e,t,n){let o=t-r,s=i-e,a=i*(r-t)+r*(e-i),l=ew(n),h=[o*l[0][0]+s*l[1][0],o*l[0][1]+s*l[1][1],o*l[0][2]+s*l[1][2],o*l[0][3]+s*l[1][3]+a],d=tw.apply(null,h),u=[];if(d!=null)for(let p=0;p<3;p++){let m=d[p],g=Math.pow(m,2),E=Math.pow(m,3),y={x:l[0][0]*E+l[0][1]*g+l[0][2]*m+l[0][3],y:l[1][0]*E+l[1][1]*g+l[1][2]*m+l[1][3]},x;e-i!==0?x=(y.x-i)/(e-i):x=(y.y-r)/(t-r),m>=0&&m<=1&&x>=0&&x<=1&&u.push(y)}return u}function W9(i,r,e,t,n){let o=[];return o.push.apply(o,_n(i,r,i+e,r,n)),o.push.apply(o,_n(i+e,r,i+e,r+t,n)),o.push.apply(o,_n(i+e,r+t,i,r+t,n)),o.push.apply(o,_n(i,r+t,i,r,n)),o}function Z9(i,r){let e=[];return e.push.apply(e,_n(i.x,i.y,i.x+i.width,i.y,r)),e.push.apply(e,_n(i.x+i.width,i.y,i.x+i.width,i.y+i.height,r)),e.push.apply(e,_n(i.x+i.width,i.y+i.height,i.x,i.y+i.height,r)),e.push.apply(e,_n(i.x,i.y+i.height,i.x,i.y,r)),e}function cT(i,r){return[-i[0][r]+3*i[1][r]+-3*i[2][r]+i[3][r],3*i[0][r]-6*i[1][r]+3*i[2][r],-3*i[0][r]+3*i[1][r],i[0][r]]}function ew(i){return[cT(i,"x"),cT(i,"y")]}function tw(i,r,e,t){let n=r/i,o=e/i,s=t/i,a=(3*o-Math.pow(n,2))/9,l=(9*n*o-27*s-2*Math.pow(n,3))/54,h=Math.pow(a,3)+Math.pow(l,2),d,u,p=[0,0,0];if(h>=0)d=Math.sign(l+Math.sqrt(h))*Math.pow(Math.abs(l+Math.sqrt(h)),1/3),u=Math.sign(l-Math.sqrt(h))*Math.pow(Math.abs(l-Math.sqrt(h)),1/3),p[0]=-n/3+(d+u),p[1]=-n/3-(d+u)/2,p[2]=-n/3-(d+u)/2,Math.abs(Math.sqrt(3)*(d-u)/2)!==0&&(p[1]=-1,p[2]=-1);else{let m=Math.acos(l/Math.sqrt(-Math.pow(a,3)));p[0]=2*Math.sqrt(-a)*Math.cos(m/3)-n/3,p[1]=2*Math.sqrt(-a)*Math.cos((m+2*Math.PI)/3)-n/3,p[2]=2*Math.sqrt(-a)*Math.cos((m+4*Math.PI)/3)-n/3}for(let m=0;m<3;m++)(p[m]<0||p[m]>1)&&(p[m]=-1);return p}var Bo="Bezier";function KE(i,r,e){return e&&(r=mT(i,r>0?0:1,r)),r}var rw={create(i){let r=ra(i),e=i.cp1,t=i.cp2,n=[{x:r.x1,y:r.y1},{x:e.x,y:e.y},{x:t.x,y:t.y},{x:r.x2,y:r.y2}],o={xmin:Math.min(r.x1,r.x2,e.x,t.x),ymin:Math.min(r.y1,r.y2,e.y,t.y),xmax:Math.max(r.x1,r.x2,e.x,t.x),ymax:Math.max(r.y1,r.y2,e.y,t.y)};return Object.assign(r,{cp1:e,cp2:t,curve:n,extents:o,length:0,type:Bo})},boundingBoxIntersection(i,r){return iT(i,r)},boxIntersection(i,r,e,t,n){return zl(i,r,e,t,n)},findClosestPointOnPath(i,r,e){let t=dT({x:r,y:e},i.curve);return{d:Math.sqrt(Math.pow(t.point.x-r,2)+Math.pow(t.point.y-e,2)),x:t.point.x,y:t.point.y,l:1-t.location,s:i,x1:null,y1:null,x2:null,y2:null}},getLength(i){return(i.length==null||i.length===0)&&(i.length=uT(i.curve)),i.length},getPath(i,r){return(r?"M "+i.x1+" "+i.y1+" ":"")+"C "+i.cp1.x+" "+i.cp1.y+" "+i.cp2.x+" "+i.cp2.y+" "+i.x2+" "+i.y2},gradientAtPoint(i,r,e){return r=KE(i.curve,r,e),_u(i.curve,r)},lineIntersection(i,r,e,t,n){return _n(r,e,t,n,i.curve)},pointAlongPathFrom(i,r,e,t){return r=KE(i.curve,r,t),pT(i.curve,r,e)},pointOnPath(i,r,e){return r=KE(i.curve,r,e),ia(i.curve,r)}};ta(Bo,rw);var Xl={};function nw(i){return i.x1!=null&&!isNaN(i.x1)&&i.y1!=null&&!isNaN(i.y1)&&i.x2!=null&&!isNaN(i.x2)&&i.y2!=null&&!isNaN(i.y2)}function gT(i){return i.curX!=null&&!isNaN(i.curX)&&i.curY!=null&&!isNaN(i.curY)&&i.x!=null&&!isNaN(i.x)&&i.y!=null&&!isNaN(i.y)&&i.ox!=null&&!isNaN(i.ox)&&i.oy!=null&&!isNaN(i.oy)}function iw(i){return!i.source||!i.target||!gT(i.source)||!gT(i.target)||i.segments==null||i.segments.length===0?!1:i.segments.find(r=>!nw(r))==null}var Yr=i=>ot(i.geometry),Ne={get:(i,r,e)=>{let t=Xl[r];if(t)return t.create(i,e);throw"VisuallyJs: unknown connector type '"+r+"'"},register:(i,r)=>{Xl[i]=r},compute:(i,r,e)=>{let t=Xl[i.connector.type];if(t)return t.compute(i,r,e);throw"VisuallyJs: unknown connector type '"+i.connector.type+"'"},update:(i,r,e,t,n)=>{let o=Xl[i.connector.type];if(o)return o.update(i,r,e,t,n);throw"VisuallyJs: unknown connector type '"+i.connector.type+"'"},markEdited(i,r){r=r||Yr(i.connector),i.connector.edited=!0,i.edge.geometry=r,Ne.$_setAnchorsFromGeometry(i,r)},importGeometry(i,r){if(iw(r)){let e=i.connector;e.geometry=ot(r),e.edited=!0,Ne.$_setAnchorsFromGeometry(i,r)}else U("VisuallyJS WARN: edge geometry invalid")},$_setAnchorsFromGeometry(i,r){WE(r.source,i,0),WE(r.target,i,1)},transformGeometry(i,r,e,t){let n=Xl[i.type];if(n)return n.transformGeometry(r,e,t);throw"VisuallyJs: unknown connector type '"+i.type+"'"},setGeometry(i,r,e){if(r!=null){let t=i.connector;t.geometry=ot(r),e||(t.edited=!0,i.edge.geometry=Yr(t))}}};function OK(i){return i.geometry}function _K(i,r){return i.geometry=r,!0}function ow(i,r){let e=r.extents;i.bounds.xmin=Math.min(i.bounds.xmin,e.xmin),i.bounds.xmax=Math.max(i.bounds.xmax,e.xmax),i.bounds.ymin=Math.min(i.bounds.ymin,e.ymin),i.bounds.ymax=Math.max(i.bounds.ymax,e.ymax)}function QE(i){i.totalLength=0,i.internalSegments.length=0,i.segmentProportions.length=0,i.segmentProportionalLengths.length=0}function zr(i,r,e){if(e.x1===e.x2&&e.y1===e.y2)return;let t=tT(r,e);i.internalSegments.push(t),i.totalLength+=kE(t),ow(i,t)}function qE(i,r,e){let t,n,o;if(e&&(r=r>0?r/i.totalLength:(i.totalLength+r)/i.totalLength),r===1)t=i.internalSegments.length-1,o=1;else if(r===0)o=0,t=0;else if(r>=.5){for(t=0,o=0,n=i.segmentProportions.length-1;n>-1;n--)if(i.segmentProportions[n][1]>=r&&i.segmentProportions[n][0]<=r){t=n,o=(r-i.segmentProportions[n][0])/i.segmentProportionalLengths[n];break}}else for(t=i.segmentProportions.length-1,o=1,n=0;n<i.segmentProportions.length;n++)if(i.segmentProportions[n][1]>=r){t=n,o=(r-i.segmentProportions[n][0])/i.segmentProportionalLengths[n];break}return{segment:i.internalSegments[t],proportion:o,index:t}}function Xr(i,r,e){let t=qE(i,r,e);return t.segment&&fr.pointOnPath(t.segment,t.proportion,!1)||{x:0,y:0}}function RK(i,r,e){let t=qE(i,r,e);return t.segment&&fr.gradientAtPoint(t.segment,t.proportion,!1)||0}function rt(i,r,e,t){let n=qE(i,r,t);return n.segment&&fr.pointAlongPathFrom(n.segment,n.proportion,e,!1)||{x:0,y:0}}function ef(i){let r=0;for(let e=0;e<i.internalSegments.length;e++){let t=kE(i.internalSegments[e]);i.segmentProportionalLengths[e]=t/i.totalLength,i.segmentProportions[e]=[r,r+=t/i.totalLength]}}function ET(i){return!((i.ox===0||i.ox==null)&&(i.oy===0||i.oy==null))}function tf(i,r){i.strokeWidth=r.strokeWidth;let e=r.sourcePos.curX,t=r.targetPos.curX,n=r.sourcePos.curY,o=r.targetPos.curY,s=t<e,a=o<n,l={x:r.sourcePos.ox,y:r.sourcePos.oy},h={x:r.targetPos.ox,y:r.targetPos.oy},d=s?t:e,u=a?o:n,p=Math.abs(t-e),m=Math.abs(o-n),g=!ET(r.sourcePos),E=!ET(r.targetPos);if(g||E){let S=p>m,R=S?e:n,v=S?t:o,O=R>v?-1:1,P=R>v?1:-1;g&&(l.x=S?O:0,l.y=S?0:O),E&&(h.x=S?P:0,h.y=S?0:P)}let y=e+i.sourceGap*l.x,x=n+i.sourceGap*l.y,f=t+i.targetGap*h.x,b=o+i.targetGap*h.y,A=l.x*h.x+l.y*h.y,T={sx:y,sy:x,tx:f,ty:b,so:l,to:h,x:d,y:u,w:p,h:m,quadrant:Os({x:e,y:n},{x:t,y:o}),startStubX:y+l.x*i.sourceStub,startStubY:x+l.y*i.sourceStub,endStubX:f+h.x*i.targetStub,endStubY:b+h.y*i.targetStub,isXGreaterThanStubTimes2:Math.abs(y-f)>i.sourceStub+i.targetStub,isYGreaterThanStubTimes2:Math.abs(x-b)>i.sourceStub+i.targetStub,opposite:A===-1,perpendicular:A===0,orthogonal:A===1,sourceAxis:l.x===0?fe:Q,stubs:[i.sourceStub,i.targetStub]};return T.anchorOrientation=T.opposite?"opposite":T.orthogonal?"orthogonal":"perpendicular",T}function LK(i,r){let e=i.connector;e.paintInfo=tf(e,r),QE(e),Ne.compute(i,e.paintInfo,r),e.x=e.paintInfo.x,e.y=e.paintInfo.y,e.width=e.paintInfo.w,e.height=e.paintInfo.h,e.quadrant=e.paintInfo.quadrant,ef(e)}function Bi(i){i.connector.geometry=null,i.connector.edited=!1,[i.anchors.source,i.anchors.target].forEach(r=>{r.locations.length>0&&(delete r.fixedLocation,r.isFixed=!1)})}function fT(i){i.bounds=Pi()}function yT(i,r,e){let t={d:1/0,s:null,x:null,y:null,l:null,x1:null,y1:null,x2:null,y2:null,index:null,connectorLocation:null};for(let n=0;n<i.internalSegments.length;n++){let o=fr.findClosestPointOnPath(i.internalSegments[n],r,e);o.d<t.d&&(t.d=o.d,t.l=o.l,t.x=o.x,t.y=o.y,t.s=i.internalSegments[n],t.x1=o.x1,t.x2=o.x2,t.y1=o.y1,t.y2=o.y2,t.index=n,t.connectorLocation=i.segmentProportions[n][0]+o.l*(i.segmentProportions[n][1]-i.segmentProportions[n][0]))}return t}function wK(i,r,e,t,n){let o=[];for(let s=0;s<i.internalSegments.length;s++)o.push.apply(o,fr.lineIntersection(i.internalSegments[s],r,e,t,n));return o}function DK(i,r,e,t,n){let o=[];for(let s=0;s<i.internalSegments.length;s++)o.push.apply(o,fr.boxIntersection(i.internalSegments[s],r,e,t,n));return o}function xT(i,r){let e=[];for(let t=0;t<i.internalSegments.length;t++)e.push.apply(e,fr.boundingBoxIntersection(i.internalSegments[t],r));return e}function NK(i){return i.typeDescriptor==="connector"}function bT(i){let r="";for(let e=0;e<i.internalSegments.length;e++)r+=fr.getPath(i.internalSegments[e],e===0),r+=" ";return r}function sw(i,r,e,t,n,o,s){let a=t,l=n,h=r.sx,d=r.sy,u=r.tx,p=r.ty,m,g;if(r.perpendicular){let E=h+a.ox*i.loopbackDistance,y=d+a.oy*i.loopbackDistance,x=u+l.ox*i.loopbackDistance,f=p+l.oy*i.loopbackDistance;m={x:E,y},g={x,y:f}}else{let E=Math.sign(r.tx-r.sx),y=Math.sign(r.ty-r.sy),x=a.ox===0?.25*i.loopbackDistance*-E:a.ox*i.loopbackDistance,f=a.oy===0?.25*i.loopbackDistance*-y:a.oy*i.loopbackDistance,b=l.ox===0?.25*i.loopbackDistance*E:l.ox*i.loopbackDistance,A=l.oy===0?.25*i.loopbackDistance*y:l.oy*i.loopbackDistance;m={x:r.sx+x,y:r.sy+f},g={x:r.tx+b,y:r.ty+A}}return[m,g]}function aw(i,r,e,t,n,o,s){let a=t,l=n,h,d,[u,p]=[i.scale*r.w,i.scale*r.h];return e.sourceInfo.id===e.targetInfo.id?[h,d]=sw(i,r,e,t,n,o,s):(h={x:r.sx+a.ox*u,y:r.sy+a.oy*p},d={x:r.tx+l.ox*u,y:r.ty+l.oy*p}),[h,d]}function AT(i){return[i.geometry.segments[0].cp1,i.geometry.segments[0].cp1]}function lw(i,r,e,t,n,o,s){let a=r.sx,l=r.sy,h=r.tx,d=r.ty,u,p=(a+h)/2,m=(l+d)/2,g=Math.sqrt(Math.pow(h-a,2)+Math.pow(d-l,2));return u=hw(p,m,r.quadrant,e.sourcePos,e.targetPos,i.curviness,i.curviness,g,i.proximityLimit),[u,u]}function hw(i,r,e,t,n,o,s,a,l){if(a<=l)return{x:i,y:r};if(e===1)return t.curY<=0&&n.curY>=1?{x:i+(t.x<.5?-1*o:o),y:r}:t.curX>=1&&n.curX<=0?{x:i,y:r+(t.y<.5?-1*s:s)}:{x:i+-1*o,y:r+-1*s};if(e===2)return t.curY>=1&&n.curY<=0?{x:i+(t.x<.5?-1*o:o),y:r}:t.curX>=1&&n.curX<=0?{x:i,y:r+(t.y<.5?-1*s:s)}:{x:i+o,y:r+-1*s};if(e===3)return t.curY>=1&&n.curY<=0?{x:i+(t.x<.5?-1*o:o),y:r}:t.curX<=0&&n.curX>=1?{x:i,y:r+(t.y<.5?-1*s:s)}:{x:i+-1*o,y:r+-1*s};if(e===4)return t.curY<=0&&n.curY>=1?{x:i+(t.x<.5?-1*o:o),y:r}:t.curX<=0&&n.curX>=1?{x:i,y:r+(t.y<.5?-1*s:s)}:{x:i+o,y:r+-1*s}}function ST(i){return[i.geometry.segments[0].cp1,i.geometry.segments[0].cp2]}function Ru(i,r,e,t,n){let o=i.connector,s,a;o.type===Fo?[s,a]=ST(o):[s,a]=AT(o);let l={segments:[{x1:r.sx,y1:r.sy,x2:r.tx,y2:r.ty,cp1:s,cp2:a}],source:e.sourcePos,target:e.targetPos};return zr(o,Bo,{x1:r.sx,y1:r.sy,x2:r.tx,y2:r.ty,cp1:s,cp2:a}),l}function Lu(i,r,e){let t=i.connector,n=e.sourcePos,o=e.targetPos,s=Math.abs(n.curX-o.curX),a=Math.abs(n.curY-o.curY),l,h;t.type===Fo?t.edited?[l,h]=ST(t):[l,h]=aw(t,r,e,n,o,s,a):t.edited?[l,h]=AT(t):[l,h]=lw(t,r,e,n,o,s,a);let d={segments:[{x1:r.sx,y1:r.sy,x2:r.tx,y2:r.ty,cp1:l,cp2:h}],source:e.sourcePos,target:e.targetPos};return zr(t,Bo,{x1:r.sx,y1:r.sy,x2:r.tx,y2:r.ty,cp1:l,cp2:h}),d}function wu(i,r,e){return{source:na(i.source,r,e),target:na(i.target,r,e),segments:i.segments.map(t=>({x1:t.x1+r,y1:t.y1+e,x2:t.x2+r,y2:t.y2+e,cp1:{x:t.cp1.x+r,y:t.cp1.y+e},cp2:{x:t.cp2.x+r,y:t.cp2.y+e}}))}}var Fo="Bezier";function cw(i,r){let e=Pu(Fo,i,r);return Object.assign(e,{scale:r.scale||oT})}Ne.register(Fo,{compute:Lu,update:Ru,create:cw,transformGeometry:wu});var Du="QuadraticBezier";function dw(i,r){let e=Pu(Du,i,r);return Object.assign(e,{curviness:r.curviness||10,gap:r.gap||5,proximityLimit:r.proximityLimit||80,clockwise:r.orientation&&r.orientation==="clockwise",Vb:{x:0,y:0}})}Ne.register(Du,{compute:Lu,update:Ru,create:dw,transformGeometry:wu});var rf="perpendicular",nf="orthogonal",of="opposite",oa="Orthogonal",TT="Smooth",vT=30;function jl(i,r,e,t){let n=Math.max(r,e),o=Math.min(r,e);return t?o<=i&&n>=i:o<i&&n>i}function CT(i,r,e){return Nu(r,"h",e,1)}function PT(i,r,e){return Nu(r,"h",e,-1)}function OT(i,r,e){return Nu(r,"v",e,1)}function _T(i,r,e){return Nu(r,"v",e,-1)}function Nu(i,r,e,t){let n=r==="h"?"v":"h",o=[],s=i,a=t===-1?-1:e.length;for(;s!==a;){let l=e[s];if(l.o===n)o.push(l),s+=t;else return{segment:l,others:o,index:s}}return null}function Iu(i,r,e,t){let n=null,o;if(t!=null){if(o=i.indexOf(t),o===-1)return null;o+=r}else o=r===-1?i.length-2:1;for(let s=o;s>0&&s<i.length-1;s+=r)if(i[s].o===e){n=[i[s],s];break}return n}function Mu(i,r,e,t){let n=i.indexOf(t),o=Iu(i,r,e,t);return o&&o[1]==n+r?o:null}function Uo(i){return{[ne]:Math.sign(i.x2-i.x1),[he]:Math.sign(i.y2-i.y1)}}function Mq(i){return[Math.sign(i.x2-i.x1),Math.sign(i.y2-i.y1)]}function sf(i,r){return i.curX===r.curX&&i.curY===r.curY}function Hl(i,r,e,t,n,o){if(i.lastx===r&&i.lasty===e)return;let s=i.lastx==null?t.sx:i.lastx,a=i.lasty==null?t.sy:i.lasty,l=s===r?he:ne;i.lastx=r,i.lasty=e;let h={x1:s,y1:a,x2:r,y2:e,o:l};i.orthogonalSegments.push(h)}function RT(i,r,e){let t=i[1],n=!1,o=[{x:t.x1,y:t.y1},{x:t.x2,y:t.y2}];if(t.o===ne){if(jl(t.x2,i[0].x1,i[0].x2)||cr(o,r).length>0){let a=OT(t,1,i);if(a!=null){let l=(a.segment.y1+a.segment.y2)/2;if(n=!0,l<t.y1){let h=Math.round((r.y-e)*100)/100,d=t.y1;a.others.forEach(u=>{u.y1=h,u.y2=h}),i.splice(1,0,{x1:t.x1,x2:t.x1,y1:d,y2:h,o:he}),a.segment.y1=h}else{let h=Math.round((r.y2+e)*100)/100,d=t.y1;a.others.forEach(u=>{u.y1=h,u.y2=h}),i.splice(1,0,{x1:t.x1,x2:t.x1,y1:d,y2:h,o:he}),a.segment.y1=h}}}}else if(t.o===he&&(jl(t.y2,i[0].y1,i[0].y2)||cr(o,r).length>0)){let a=CT(t,1,i);if(a!=null){let l=(a.segment.x1+a.segment.x2)/2;if(n=!0,l<t.x1){let h=Math.round((r.x-e)*100)/100,d=t.x1;a.others.forEach(u=>{u.x1=h,u.x2=h}),i.splice(1,0,{y1:t.y1,y2:t.y1,x1:d,x2:h,o:ne}),a.segment.x1=h}else{let h=Math.round((r.x2+e)*100)/100,d=t.x1;a.others.forEach(u=>{u.x1=h,u.x2=h}),i.splice(1,0,{y1:t.y1,y2:t.y1,x1:d,x2:h,o:ne}),a.segment.x1=h}}}return n}function LT(i,r,e){let t=i.length-2,n=i[t],o=!1,s=[{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}],a=i[i.length-1];if(n.o===ne){if(jl(n.x1,a.x1,a.x2)||cr(s,r).length>0){let h=_T(n,t,i);if(h!=null){let d=(h.segment.y1+h.segment.y2)/2;if(o=!0,d<n.y1){let u=Math.round((r.y-e)*100)/100,p=n.y1;h.others.forEach(m=>{m.y1=u,m.y2=u}),i.splice(t+1,0,{x1:n.x2,x2:n.x2,y1:u,y2:p,o:he}),h.segment.y2=u}else{let u=Math.round((r.y2+e)*100)/100,p=n.y1;h.others.forEach(m=>{m.y1=u,m.y2=u}),i.splice(t+1,0,{x1:n.x2,x2:n.x2,y1:u,y2:p,o:he}),h.segment.y2=u}}}}else if(n.o===he&&(jl(n.y1,a.y1,a.y2)||cr(s,r).length>0)){let h=PT(n,t,i);if(h!=null){let d=(h.segment.x1+h.segment.x2)/2;if(o=!0,d<n.x1){let u=Math.round((r.x-e)*100)/100,p=n.x1;h.others.forEach(m=>{m.x1=u,m.x2=u}),i.splice(t+1,0,{y1:n.y2,y2:n.y2,x1:u,x2:p,o:ne}),h.segment.x2=u}else{let u=Math.round((r.x2+e)*100)/100,p=n.x1;h.others.forEach(m=>{m.x1=u,m.x2=u}),i.splice(t+1,0,{y1:n.y2,y2:n.y2,x1:u,x2:p,o:ne}),h.segment.x2=u}}}return o}function wT(i,r,e,t,n){if(i.vertexAvoidance===!1)return{segments:r,sourceAdjusted:!1,targetAdjusted:!1};{let o,s;return n?(o=LT(r,t,i.targetStub),s=RT(r,e,i.sourceStub)):(s=RT(r,e,i.sourceStub),o=LT(r,t,i.targetStub)),{segments:r,sourceAdjusted:s,targetAdjusted:o}}}var Ln="Straight";function Rn(i,r,e){return e>r?r<=i&&i<=e:r>=i&&i>=e}function Vu(i,r,e){return e>=Math.min(i,r)&&e<=Math.max(i,r)}function Gu(i,r,e){return Math.abs(e-i)<Math.abs(e-r)?i:r}var Yo={create(i){let r=ra(i),e=Math.sqrt(Math.pow(r.x2-r.x1,2)+Math.pow(r.y2-r.y1,2)),t=Nr({x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),n=-1/t,o={xmin:Math.min(r.x1,r.x2),ymin:Math.min(r.y1,r.y2),xmax:Math.max(r.x1,r.x2),ymax:Math.max(r.y1,r.y2)};return Object.assign(r,{length:e,m:t,m2:n,extents:o,type:Ln})},boundingBoxIntersection(i,r){return Yo.boxIntersection(i,r.x,r.y,r.width,r.height)},boxIntersection(i,r,e,t,n){let o=[];return o.push.apply(o,Yo.lineIntersection(i,r,e,r+t,e)),o.push.apply(o,Yo.lineIntersection(i,r+t,e,r+t,e+n)),o.push.apply(o,Yo.lineIntersection(i,r+t,e+n,r,e+n)),o.push.apply(o,Yo.lineIntersection(i,r,e+n,r,e)),o},findClosestPointOnPath(i,r,e){let t={d:1/0,x:null,y:null,l:null,x1:i.x1,x2:i.x2,y1:i.y1,y2:i.y2};if(i.m===0)t.y=i.y1,t.x=Vu(i.x1,i.x2,r)?r:Gu(i.x1,i.x2,r);else if(i.m===1/0||i.m===-1/0)t.x=i.x1,t.y=Vu(i.y1,i.y2,e)?e:Gu(i.y1,i.y2,e);else{let o=i.y1-i.m*i.x1,s=e-i.m2*r,a=(s-o)/(i.m-i.m2),l=i.m*a+o;t.x=Vu(i.x1,i.x2,a)?a:Gu(i.x1,i.x2,a),t.y=Vu(i.y1,i.y2,l)?l:Gu(i.y1,i.y2,l)}let n=Be({x:t.x,y:t.y},{x:i.x1,y:i.y1});return t.d=Be({x:r,y:e},t),t.l=n/i.length,t},getLength(i){return i.length},getPath(i,r){return(r?"M "+i.x1+" "+i.y1+" ":"")+"L "+i.x2+" "+i.y2},gradientAtPoint(i,r,e){return i.m},lineIntersection(i,r,e,t,n){let o=Math.abs(Nr({x:r,y:e},{x:t,y:n})),s=Math.abs(i.m),a=s===1/0?i.x1:i.y1-s*i.x1,l=[],h=o===1/0?r:e-o*r;if(o!==s)if(o===1/0&&s===0)Rn(r,i.x1,i.x2)&&Rn(i.y1,e,n)&&l.push({x:r,y:i.y1});else if(o===0&&s===1/0)Rn(e,i.y1,i.y2)&&Rn(i.x1,r,t)&&l.push({x:i.x1,y:e});else{let d,u;o===1/0?(d=r,Rn(d,i.x1,i.x2)&&(u=s*r+a,Rn(u,e,n)&&l.push({x:d,y:u}))):o===0?(u=e,Rn(u,i.y1,i.y2)&&(d=(e-a)/s,Rn(d,r,t)&&l.push({x:d,y:u}))):(d=(h-a)/(s-o),u=s*d+a,Rn(d,i.x1,i.x2)&&Rn(u,i.y1,i.y2)&&l.push({x:d,y:u}))}return l},pointAlongPathFrom(i,r,e,t){let n=Yo.pointOnPath(i,r,t),o=e<=0?{x:i.x1,y:i.y1}:{x:i.x2,y:i.y2};return e<=0&&Math.abs(e)>1&&(e*=-1),zt(n,o,e)},pointOnPath(i,r,e){if(r===0&&!e)return{x:i.x1,y:i.y1};if(r===1&&!e)return{x:i.x2,y:i.y2};{let t=e?r>0?r:i.length+r:r*i.length;return zt({x:i.x1,y:i.y1},{x:i.x2,y:i.y2},t)}}};ta(Ln,Yo);var DT=1e-10;function NT(i){let r=Math.floor(i),e=Math.ceil(i);return i-r<DT?r:e-i<DT?e:i}var kl="Arc";function IT(i,r,e,t){return gb({x:i,y:r},{x:e,y:t})}function uw(i,r){if(i.anticlockwise){let e=i.startAngle<i.endAngle?i.startAngle+vi:i.startAngle,t=Math.abs(e-i.endAngle);return e-t*r}else{let e=i.endAngle<i.startAngle?i.endAngle+vi:i.endAngle,t=Math.abs(e-i.startAngle);return i.startAngle+t*r}}var $u={create(i){let r=ra(i),e=i.cx,t=i.cy,n=i.r,o=i.ac,s,a;i.startAngle&&i.endAngle?(s=i.startAngle,a=i.endAngle,r.x1=e+n*Math.cos(s),r.y1=t+n*Math.sin(s),r.x2=e+n*Math.cos(a),r.y2=t+n*Math.sin(a)):(s=IT(e,t,r.x1,r.y1),a=IT(e,t,r.x2,r.y2)),a<0&&(a+=vi),s<0&&(s+=vi);let l=a<s?a+vi:a,h=Math.abs(l-s);o&&(h=vi-h);let d=2*Math.PI*n,u=h/vi,p=d*u,m={xmin:e-n,xmax:e+n,ymin:t-n,ymax:t+n};return Object.assign(r,{extents:m,length:p,frac:u,circumference:d,sweep:h,startAngle:s,endAngle:a,anticlockwise:o,cx:e,cy:t,radius:n,type:kl})},boundingBoxIntersection(i,r){return $u.boxIntersection(i,r.x,r.y,r.width,r.height)},boxIntersection(i,r,e,t,n){return zl(i,r,e,t,n)},findClosestPointOnPath(i,r,e){return rT(i,r,e)},getLength(i){return i.length},getPath(i,r){let e=i.sweep>Math.PI?1:0,t=i.anticlockwise?0:1;return(r?"M"+i.x1+" "+i.y1+" ":"")+"A "+i.radius+" "+i.radius+" 0 "+e+","+t+" "+i.x2+" "+i.y2},gradientAtPoint(i,r,e){let t=$u.pointOnPath(i,r,e),n=mb({x:i.cx,y:i.cy},t);return!i.anticlockwise&&(n===1/0||n===-1/0)&&(n*=-1),n},lineIntersection(i,r,e,t,n){return nT(i,r,e,t,n)},pointAlongPathFrom(i,r,e,t){let n=$u.pointOnPath(i,r,t),o=e/i.circumference*2*Math.PI,s=i.anticlockwise?-1:1,a=n.theta+s*o,l=i.cx+i.radius*Math.cos(a),h=i.cy+i.radius*Math.sin(a);return{x:l,y:h}},pointOnPath(i,r,e){if(r===0)return{x:i.x1,y:i.y1,theta:i.startAngle};if(r===1)return{x:i.x2,y:i.y2,theta:i.endAngle};e&&(r=r/length);let t=uw(i,r),n=i.cx+i.radius*Math.cos(t),o=i.cy+i.radius*Math.sin(t);return{x:NT(n),y:NT(o),theta:t}}};ta(kl,$u);var MT={x:[Q,fe],y:[fe,Q]};function VT(i,r){return[i.startStubX,i.startStubY,i.endStubX,i.endStubY]}var Wl=new Map;Wl.set(rf,VT),Wl.set(nf,VT),Wl.set(of,(i,r)=>{let e=i,t=e.sourceAxis,n={[Q]:function(){return e.so[t]===1&&(e.startStubX>e.endStubX&&e.tx>e.startStubX||e.sx>e.endStubX&&e.tx>e.sx)||e.so[t]===-1&&(e.startStubX<e.endStubX&&e.tx<e.startStubX||e.sx<e.endStubX&&e.tx<e.sx)},[fe]:function(){return e.so[t]===1&&(e.startStubY>e.endStubY&&e.ty>e.startStubY||e.sy>e.endStubY&&e.ty>e.sy)||e.so[t]===-1&&(e.startStubY<e.endStubY&&e.ty<e.startStubY||e.sy<e.endStubY&&e.ty<e.sy)}};return!r&&n[e.sourceAxis]()?{[Q]:[(i.sx+i.tx)/2,i.startStubY,(i.sx+i.tx)/2,i.endStubY],[fe]:[i.startStubX,(i.sy+i.ty)/2,i.endStubX,(i.sy+i.ty)/2]}[e.sourceAxis]:[i.startStubX,i.startStubY,i.endStubX,i.endStubY]});var Zl=new Map;Zl.set(rf,(i,r,e,t,n,o,s,a,l,h)=>{let d={x:[[[1,2,3,4],null,[2,1,4,3]],null,[[4,3,2,1],null,[3,4,1,2]]],y:[[[3,2,1,4],null,[2,3,4,1]],null,[[4,1,2,3],null,[1,4,3,2]]]},u={x:[[i.startStubX,i.endStubX],null,[i.endStubX,i.startStubX]],y:[[i.startStubY,i.endStubY],null,[i.endStubY,i.startStubY]]},p={x:[{x:a,y:i.startStubY},{x:a,y:i.endStubY}],y:[{x:i.startStubX,y:l},{x:i.endStubX,y:l}]},m={x:[{x:i.endStubX,y:i.startStubY}],y:[{x:i.startStubX,y:i.endStubY}]},g={x:[{x:i.startStubX,y:i.endStubY},{x:i.endStubX,y:i.endStubY}],y:[{x:i.endStubX,y:i.startStubY},{x:i.endStubX,y:i.endStubY}]},E={x:[{x:i.startStubX,y:l},{x:i.endStubX,y:l},{x:i.endStubX,y:i.endStubY}],y:[{x:a,y:i.startStubY},{x:a,y:i.endStubY},{x:i.endStubX,y:i.endStubY}]},y={x:[i.startStubY,i.endStubY],y:[i.startStubX,i.endStubX]},x=MT[e][0],f=MT[e][1],b=i.so[x]+1,A=i.to[f]+1,T=i.to[f]===-1&&y[e][1]<y[e][0]||i.to[f]===1&&y[e][1]>y[e][0],S=u[e][b][0],R=u[e][b][1],v=d[e][b][A];if(i.quadrant===v[3]||i.quadrant===v[2]&&T)return p[e];if(i.quadrant===v[2]&&R<S)return m[e];if(i.quadrant===v[2]&&R>=S||i.quadrant===v[1]&&!T)return E[e];if(i.quadrant===v[0]||i.quadrant===v[1]&&T)return g[e]}),Zl.set(nf,(i,r,e,t,n,o,s,a,l,h)=>{let d={[Q]:i.so.x===-1?Math.min(t,o):Math.max(t,o),[fe]:i.so.y===-1?Math.min(t,o):Math.max(t,o)}[e];return{[Q]:[{x:d,y:n},{x:d,y:s},{x:o,y:s}],[fe]:[{x:n,y:d},{x:s,y:d},{x:s,y:o}]}[e]}),Zl.set(of,(i,r,e,t,n,o,s,a,l,h)=>{let d={[Q]:fe,[fe]:Q}[e],u=e===Q?i.isXGreaterThanStubTimes2:i.isYGreaterThanStubTimes2;if(r.sourceInfo.id===r.targetInfo.id){let p={[Q]:De,[fe]:Te}[e],m=n+(1-r.sourcePos[d])*r.sourceInfo[p]+h;return{[Q]:[{x:t,y:m},{x:o,y:m}],[fe]:[{x:m,y:t},{x:m,y:o}]}[e]}else{if(!u||i.so[e]===1&&t>o||i.so[e]===-1&&t<o)return{[Q]:[{x:t,y:l},{x:o,y:l}],[fe]:[{x:a,y:t},{x:a,y:o}]}[e];if(i.so[e]===1&&t<o||i.so[e]===-1&&t>o)return{[Q]:i.sy===i.ty?[{y:i.ty,x:o}]:[{x:a,y:i.sy},{x:a,y:i.ty}],[fe]:i.sx===i.tx?[{x:i.tx,y:o}]:[{x:i.sx,y:l},{x:i.tx,y:l}]}[e]}});function GT(i,r,e){let t={lastx:null,lasty:null,orthogonalSegments:[]},n=e.targetPos.curX>=e.sourcePos.curX?e.sourcePos.curX:e.targetPos.curX,o=e.targetPos.curY>=e.sourcePos.curY?e.sourcePos.curY:e.targetPos.curY,s=Wl.get(r.anchorOrientation)(r,i.alwaysRespectStubs),a=r.sourceAxis===Q?0:1,l=r.sourceAxis===Q?1:0,h=s[a],d=s[l],u=s[a+2],p=s[l+2];Hl(t,s[0],s[1],r,n,o);let m=r.startStubX+(r.endStubX-r.startStubX)*i.midpoint,g=r.startStubY+(r.endStubY-r.startStubY)*i.midpoint,y=Zl.get(r.anchorOrientation)(r,e,r.sourceAxis,h,d,u,p,m,g,Math.max(i.sourceStub,i.targetStub));if(y)for(let x=0;x<y.length;x++)Hl(t,y[x].x,y[x].y,r,n,o);return Hl(t,s[2],s[3],r,n,o),Hl(t,r.tx,r.ty,r,n,o),t.orthogonalSegments}function Bu(i,r){let e=r;return i.smooth===!0&&e.length>=2?gw(i,e).map(n=>zr(i,n.type,n.segment)):i.cornerRadius!=null&&e.length>1?pw(i,e):e.map(t=>zr(i,Ln,t)),i.$pathSegments=e,e}function $T(i){return Math.atan2(i.y1-i.y2,i.x1-i.x2)}function BT(i){return Math.sqrt(Math.pow(i.x2-i.x1,2)+Math.pow(i.y2-i.y1,2))}function pw(i,r){let e=null,t,n,o;for(let s=0;s<r.length-1;s++){if(e=e||Object.assign({},r[s]),t=Object.assign({},r[s+1]),n=$T(e),o=$T(t),i.cornerRadius>0&&n!==o){let a=Math.min(BT(e),BT(t)),l=Math.min(i.cornerRadius,.99*a/2),h={x:e.x2+l*Math.cos(n),y:e.y2+l*Math.sin(n)},d={x:t.x1-l*Math.cos(o),y:t.y1-l*Math.sin(o)},u=Math.atan((n-o)/(1+n*o)),p=rr({x:e.x1,y:e.y1},h,1e4),m=rr({x:t.x1,y:t.y1},d,1e4),g=Wg(p,m),E=g!=null?Be(g,h):0;E>0?(e.x2=h.x,e.y2=h.y,t.x1=d.x,t.y1=d.y,zr(i,Ln,Object.assign({},e)),i.slightlyWonky?zr(i,kl,Object.assign({r:l,cx:g.x,cy:g.y,ac:u>0},e)):zr(i,kl,{r:E,x1:h.x,y1:h.y,x2:d.x,y2:d.y,cx:g.x,cy:g.y,ac:u>0})):zr(i,Ln,Object.assign({},e))}else zr(i,Ln,Object.assign({},e));e=t}t!=null&&zr(i,Ln,Object.assign({},e))}var mw=(i,r)=>{let e=r.x-i.x,t=r.y-i.y;return{length:Math.sqrt(Math.pow(e,2)+Math.pow(t,2)),angle:Math.atan2(t,e)}},FT=(i,r,e,t,n)=>{let a=mw(r||i,e||i),l=a.angle+(n?Math.PI:0),h=a.length*t,d=i.x+Math.cos(l)*h,u=i.y+Math.sin(l)*h;return{x:d,y:u}};function af(i,r){let e=[];for(let t=1;t<i.length;t++){let n=FT(i[t-1],i[t-2],i[t],r),o=FT(i[t],i[t-1],i[t+1],r,!0);e.push({type:Bo,segment:{x1:i[t-1].x,y1:i[t-1].y,cp1:n,cp2:o,x2:i[t].x,y2:i[t].y}})}return e}function gw(i,r){let e=[{x:r[0].x1,y:r[0].y1}];for(let t=1;t<r.length;t++)e.push({x:r[t].x1,y:r[t].y1});return e.push({x:r[r.length-1].x2,y:r[r.length-1].y2}),af(e,i.smoothing)}function Ew(i,r,e){return lf([{x1:r.sx,y1:r.sy,x2:r.startStubX,y2:r.startStubY},{x1:r.startStubX,y1:r.startStubY,x2:r.endStubX,y2:r.endStubY},{x1:r.endStubX,y1:r.endStubY,x2:r.tx,y2:r.ty}])}function Fu(i,r,e,t,n){let o=i.connector;o.lastx=null,o.lasty=null,o.lastOrientation=null;let s=e.sourcePos,a=e.targetPos;return o.$pathSegments=o.geometry.segments,o.constrain===nn?UT(s,a,o,r,e,t,n):fw(s,a,o,r.quadrant,t,n),Bu(o,o.$pathSegments),{segments:o.$pathSegments,source:e.sourcePos,target:e.targetPos,quadrant:r.quadrant}}function Uu(i,r,e){let t=i.connector;return t.lastx=null,t.lasty=null,t.lastOrientation=null,t.constrain===nn?t.$pathSegments=GT(t,r,e):t.$pathSegments=Ew(t,r,e),Bu(t,t.$pathSegments),{segments:t.$pathSegments,source:e.sourcePos,target:e.targetPos,quadrant:r.quadrant}}function fw(i,r,e,t,n,o){if(o){let s=e.geometry.segments[e.geometry.segments.length-1];s.x2=r.curX,s.y2=r.curY,e.geometry.target.curX=r.curX,e.geometry.target.curY=r.curY}else if(n){let s=e.geometry.segments[0];s.x1=i.curX,s.y1=i.curY,e.geometry.source.curX=i.curX,e.geometry.source.curY=i.curY}e.geometry.quadrant=t,e.$pathSegments=e.geometry.segments}function Yu(i,r,e){return{source:na(i.source,r,e),target:na(i.target,r,e),segments:i.segments.map(t=>({x1:t.x1+r,y1:t.y1+e,x2:t.x2+r,y2:t.y2+e}))}}function lf(i){return i.length===0?[]:i.filter(r=>!(r.x1===r.x2&&r.y1===r.y2))}var yw=.15,wn="Straight";function sa(i){return Math.sqrt(Math.pow(i.x2-i.x1,2)+Math.pow(i.y2-i.y1,2))}Ne.register(wn,{compute:Uu,update:Fu,create:hf,transformGeometry:Yu});function xw(i,r){let e=Object.assign(r,{constrain:nn});return hf(i,e)}Ne.register(oa,{compute:Uu,update:Fu,create:xw,transformGeometry:Yu});function bw(i,r){let e=Object.assign(r,{constrain:rn,smooth:!0});return hf(i,e)}Ne.register(TT,{compute:Uu,update:Fu,create:bw,transformGeometry:Yu});function Aw(i){return i==null?null:i===kb?nn:i===Wb?Qc:i}function hf(i,r){let e=Aw(r.constrain);r.stub=r.stub==null?e===nn?vT:null:r.stub;let t=Cu(wn,i,r,[0,0]),n=r.midpoint==null||isNaN(r.midpoint)?.5:r.midpoint,o=r.alwaysRespectStubs!==!1,s=r.loopbackRadius||25;return Object.assign(t,{cornerRadius:r.cornerRadius!=null?r.cornerRadius:null,smooth:r.smooth===!0,smoothing:r.smoothing==null?yw:r.smoothing,geometry:{segments:[]},constrain:e==null?rn:e,$pathSegments:[],loopbackRadius:s,isLoopbackCurrently:!1,alwaysRespectStubs:o,midpoint:n,lastOrientation:null,lastx:null,lasty:null,slightlyWonky:r.slightlyWonky===!0})}function zT(i,r,e){YT(1,i,r,e),YT(0,i,r,e)}var Fi="x2",Ui="x1",Yi="y1",zi="y2";function Sw(i,r,e){let t=e===i.x1?{value:i.x2,coord:Fi,prev:!0}:{value:i.x1,coord:Ui,prev:!0},n=e===r.x1?{value:r.x2,coord:Fi,prev:!1}:{value:r.x1,coord:Ui,prev:!1},o=Math.abs(e-t.value),s=Math.abs(e-n.value),a=o>s?t:n,l=o>s?n:t;return Object.assign(a,{ref:l.value})}function Tw(i,r,e){let t=e===i.y1?{value:i.y2,coord:zi,prev:!0}:{value:i.y1,coord:Yi,prev:!0},n=e===r.y1?{value:r.y2,coord:zi,prev:!1}:{value:r.y1,coord:Yi,prev:!1},o=Math.abs(e-t.value),s=Math.abs(e-n.value),a=o>s?t:n,l=o>s?n:t;return Object.assign(a,{ref:l.value})}function vw(i,r){if(r.length<5)return r;function e(d,u,p){let m=p===d.x1?d.x2:d.x1,g=p===u.x1?u.x2:u.x1;if(m>u.x1&&u.x2>m||m>u.x2&&u.x1>m)return m;if(g>d.x1&&d.x2>g||g>d.x2&&d.x1>g)return g}function t(d,u,p){let m=p===d.y1?d.y2:d.y1,g=p===u.y1?u.y2:u.y1;if(m>u.y1&&u.y2>m||m>u.y2&&u.y1>m)return m;if(g>d.y1&&d.y2>g||g>d.y2&&d.y1>g)return g}let n=r[1],o,s,a=Math.max(i.sourceStub,i.targetStub),l=[];for(let d=2;d<r.length-2;d++)if(o=r[d],s=Uo(n)[n.o],o.o!==n.o)if(sa(o)<a){let p=r[d+1];if(Uo(p)[p.o]!==s){let g=Object.assign({},o);if(o.o===he){let E=Sw(n,p,o.x1),y=e(n,p,o.x1);if(y!=null){if(g.x1=y,g.x2=y,E.prev){let x=Object.assign({},n);n.x2===o.x1?x.x2=y:x.x1=y,l.push({start:d-1,segments:[x,g]})}else{let x=Object.assign({},p);p.x1===o.x1?x.x1=y:x.x2=y,l.push({start:d-1,segments:[g,x]})}n=p,d+=1}else n=o}else if(o.o===ne){let E=Tw(n,p,o.y1),y=t(n,p,o.y1);if(y!=null){if(g.y1=y,g.y2=y,E.prev){let x=Object.assign({},n);n.y2===o.y1?x.y2=y:x.y1=y,l.push({start:d-1,segments:[x,g]})}else{let x=Object.assign({},p);p.y1===o.y1?x.y1=y:x.y2=y,l.push({start:d-1,segments:[g,x]})}n=p,d+=1}else n=o}}else n=o}else n=o;else n=o;let h=r.slice();for(let d=0;d<l.length;d++)h.splice(l[d].start-d,3,...l[d].segments);return l.length>0?cf(h):h}function YT(i,r,e,t){let n=r.$pathSegments.slice();i===1&&n.reverse();let o=n[0],s=n[n.length-1],a=i===1?r.targetStub:r.sourceStub,l=i===1?t.targetPos.curX:t.sourcePos.curX,h=i===1?t.targetPos.curY:t.sourcePos.curY,d=i===1?e.to:e.so,u=i===1?Fi:Ui,p=i===1?zi:Yi,m=i===1?Ui:Fi,g=i===1?Yi:zi,E=1,y=n.length-2,x=1,f=n[1];o[m]=l+a*d.x,o[g]=h+a*d.y,o[u]=l,o[p]=h,o.o=o.x1===o.x2?"v":"h";let b=Uo(o),A=o.o,T=o.o===ne?he:ne,S=o.o===ne?[Fi,Ui]:[zi,Yi],R=o.o===ne?[Ui,Fi]:[Yi,zi],v=o.o===ne?[zi,Yi]:[Fi,Ui],O=o.o===ne?[Yi,zi]:[Ui,Fi],P=S[i],I=R[i],C=v[i],_=O[i];if(f!=null)if(f.o===o.o){f[I]=o[P],f[C]=f[_]=o[C];let B=Uo(f)[A],D=Mu(n,x,T,f);if(B!==b[A]){if(D!=null){let M=Mu(n,x,A,D[0]);if(M!=null)n.splice(E,1),M[0][I]=o[P],D[0][P]=o[P],D[0][I]=o[P],D[0][_]=o[C];else{let N=(D[0][C]+D[0][_])/2;D[0][_]=N,f[C]=f[_]=N;let G={x1:0,y1:0,x2:0,y2:0,o:T,[P]:o[P],[C]:N,[_]:o[C],[I]:o[P]};n.splice(E,0,G)}}}else f[C]=f[_]=o[C],D!=null&&(D[0][_]=o[C])}else{f[_]=o[C],f[P]=f[I]=o[P];let B=Mu(n,x,A,f);if(B!=null){let D=Uo(B[0])[A];B[0][I]=o[P];let M=Uo(B[0])[A];if(D!==M&&B[1]===y){n.splice(B[1],1);let N=(f[C]+f[_])/2;f[_]=N,f[P]=f[I]=s[I];let G={x1:0,y1:0,x2:0,y2:0,o:A,[P]:s[I],[C]:N,[_]:N,[I]:o[P]};n.splice(E,0,G);let J={x1:0,y1:0,x2:0,y2:0,o:T,[P]:o[P],[C]:N,[_]:o[C],[I]:o[P]};n.splice(E,0,J)}}else{let D=(f[C]+f[_])/2;f[_]=D,f[P]=f[I]=s[I];let M={x1:0,y1:0,x2:0,y2:0,o:A,[P]:s[I],[C]:D,[_]:D,[I]:o[P]};n.splice(E,0,M);let N={x1:0,y1:0,x2:0,y2:0,o:T,[P]:o[P],[C]:D,[_]:o[C],[I]:o[P]};n.splice(E,0,N)}}let w=vw(r,n);i===1&&w.reverse(),r.$pathSegments=w}function UT(i,r,e,t,n,o,s){let a=e.geometry;if(o||s){let l=i.curX-a.source.curX,h=i.curY-a.source.curY,d=r.curX-a.target.curX,u=r.curY-a.target.curY;if(l===d&&h===u){let p=[];e.$pathSegments.forEach(m=>{let g=Object.assign({},m);g.x1+=l,g.x2+=l,g.y1+=h,g.y2+=h,p.push(g)}),e.$pathSegments=p;return}zT(e,t,n)}}function Cw(i,r,e){let t=i.findIndex(n=>n.x1===r.x1&&n.y1===r.y1&&n.x2===r.x2&&n.y2===r.y2);if(t>-1){let n=i[t].o,o=i[t];return{segment:o,index:t,axis:n,prev:t>1?i[t-1]:null,next:t<i.length-2?i[t+1]:null,left:e?Iu(i,-1,n,o):null,right:e?Iu(i,1,n,o):null}}else return null}function XT(i,r,e,t,n){let o=Cw(r.$pathSegments,e);if(o!=null){o.axis===he?o.segment.x1=o.segment.x2=t.x:o.segment.y1=o.segment.y2=t.y;let s=o.axis===he,a=o.index,l=o.index,h=a>1?r.$pathSegments[a-1]:null,d=o.segment;for(;h!=null;)h.o===d.o?s?(h.x1=d.x1,h.x2=d.x2):(h.y1=d.y1,h.y2=d.y2):(h.x2=d.x1,h.y2=d.y1),d=h,a--,h=a>1?r.$pathSegments[a-1]:null;if(d.x1!==r.$pathSegments[0].x2){let m={o:ne,x1:r.$pathSegments[0].x2,y1:r.$pathSegments[0].y2,x2:d.x1,y2:d.y1};r.$pathSegments.splice(1,0,m),l++}else if(d.y1!==r.$pathSegments[0].y2){let m={o:he,x1:r.$pathSegments[0].x2,y1:r.$pathSegments[0].y2,x2:d.x1,y2:d.y1};r.$pathSegments.splice(1,0,m),l++}d=o.segment,a=l;let u=a<r.$pathSegments.length-2?r.$pathSegments[a+1]:null;for(;u!=null;)u.o===d.o?s?(u.x1=d.x1,u.x2=d.x2):(u.y1=d.y1,u.y2=d.y2):(u.x1=d.x2,u.y1=d.y2),d=u,a++,u=a<r.$pathSegments.length-2?r.$pathSegments[a+1]:null;let p=r.$pathSegments[r.$pathSegments.length-1];if(d.x2!==p.x1){let m={o:ne,x1:d.x2,y1:d.y2,x2:p.x1,y2:p.y1};r.$pathSegments.splice(r.$pathSegments.length-1,0,m)}else if(d.y2!==p.y1){let m={o:he,x1:d.x2,y1:d.y2,x2:p.x1,y2:p.y1};r.$pathSegments.splice(r.$pathSegments.length-1,0,m)}if(n!==!0){let m=i.instance.getElement(i.sourceId),g=i.instance.getElement(i.targetId);wT(r,r.$pathSegments,m,g,!1).sourceAdjusted&&(l+=1)}return r.edited=!0,{ctx:o,segments:r.$pathSegments,index:l}}else return null}function cf(i){let r=[ot(i[0])],e=ot(i[i.length-1]),t=i.slice(1,i.length-1).filter(s=>sa(s)>0).map(ot);if(t.length===0)return i;let n=null,o=null;for(let s=0;s<t.length;s++)n==null||o==null?(n=t[s],o=t[s].o):t[s].o===o?(n.y2=t[s].y2,n.x2=t[s].x2):(r.push(n),n=t[s],o=t[s].o);if(r.push(n),r.push(e),r.length===3){let s=r[1],a=s.o,l=Object.assign({},s),h=Object.assign({},s),d=Object.assign({},s);h.o=a===ne?he:ne,h.x1=l.x1,h.y1=l.y1,h.x2=l.x1,h.y2=l.y1,d.o=a===ne?he:ne,d.x1=l.x2,d.y1=l.y2,d.x2=l.x2,d.y2=l.y2,r=[r[0],h,l,d,r[2]]}return r}function jT(i){let r=cf(i.$pathSegments);i.$pathSegments=r,i.geometry!=null&&(i.geometry.segments=r)}function Qee(i,r,e){if(i.$pathSegments.length>=2){let t=r===0?i.$pathSegments[0]:i.$pathSegments[i.$pathSegments.length-1],n=e[0]===0?he:ne;t.o=n,i.edited=!0}}var zu=class extends $t{constructor(e){super();c(this,"$context");this.$context=e||{}}getFromContext(e){return this.$context[e]}ensureContext(e,t){let n=this.$context[e];return n==null&&(n=t(),this.$context[e]=n,this.fire(Dl,{key:e,value:n})),n}updateContext(e,t){this.$context[e]=t,this.fire(Dl,{key:e,value:t})}};var Xi=(e=>(e.SVG="SVG",e.HTML="HTML",e))(Xi||{});var jr="px",Dn="50px",Or="block",ht="none",Vte=0,Gte=1,je="absolute",df="fixed",HT="static",kT="relative",WT="data-vjs-group",Pt="data-vjs-managed",Jl="data-vjs-not-draggable",ZT="data-vjs-elements-draggable",uf="tabindex",$te="overlays",ee="data-vjs-vertex",ln="data-vjs-port",Kl="data-vjs-port-id",Hr="data-vjs-port-type",Xu="data-vjs-edge-type",ju="data-vjs-source",zo="data-vjs-target",pf="data-vjs-allow-loopback",Hu="data-vjs-source-port-id",ku="data-vjs-target-port-id",Xo="data-vjs-source-port",jo="data-vjs-target-port",ai="data-vjs-source-port-type",ji="data-vjs-target-port-type",Wu="data-vjs-magnet",Ze="data-vjs-edge",Zu="data-vjs-overlay-id",yr="*";var aa="vjs-connector",JT="vjs-connector-path",KT="vjs-connector-outline",qT="vjs-connector-transient",ql="vjs-connected",mf="vjs-group-collapsed",gf="vjs-group-expanded",Ju="vjs-toggle-group-collapse",la="vjs-overlay",Ql="vjs-overlay-hide",QT="vjs-label-overlay",Hi="vjs-node",ev="vjs-port",Ho="vjs-group",tv="vjs-dummy-vertex",eh="vjs-selected-connection",ki="vjs-selected-element",ha="vjs-edge-delete",Ku="vjs-edge-delete-i";var Ef="allowNestedGroups",th="anchor",rh="anchors",lre="astarGridCellSize",rv="astarVertexBorder",nv="astarVertexBuffer",hre="overlays",cre="edgesDetachable",qu="connector",iv="cssClass",ov="edgeRelocateHandleSize",dre="ensureAnchorsInWhitespace",ure="groupSize",sv="hoverClass",Qu="hoverPaintStyle",av="maxConnections",pre="nodeSize",ko="paintStyle",mre="reattachEdges",ff="scope",lv=[.05,3];function hv(i){return i.type!=null&&i.options!=null}function hi(i){let r=null;return z(i)?r={type:i,options:{}}:r=i,r.options.id=r.options.id||V(),r}var ep="always",Wi="hover";function yf(i,r){let e=i.location==null?.5:i.location;if(r!=null)try{let t=typeof r=="string"?parseFloat(r):r;isNaN(t)||(e=t)}catch(t){}i.location=e}var li=class{constructor(r,e){this.component=r;c(this,"id");c(this,"cssClass");c(this,"Qo");c(this,"visible",!0);c(this,"location",.5);c(this,"events");c(this,"attributes");c(this,"ignoreTypes",!1);e=e||{},this.id=e.id||V(),this.cssClass=e.cssClass||"",yf(this,e.location),this.events=e.events||{},this.attributes=e.attributes||{},this.Qo=r.instance.$isTouchDevice()?ep:e.visibility||ep,this.Qo===Wi&&(this.visible=!1)}},Nn=class extends li{constructor(e,t,n){super(t,n);this.component=t;c(this,"paintStyle");c(this,"$hollow");c(this,"isSimpleShape",!0);n=n||{},this.paintStyle=n.paintStyle||{strokeWidth:1},this.$hollow=n.hollow===!0}$getStyle(e){let t=this.paintStyle.stroke||e.stroke,n=this.$hollow?"none":this.paintStyle.fill||e.stroke,o=this.paintStyle.strokeWidth||e.strokeWidth;return{stroke:t,fill:n,lineWidth:o}}updateFrom(e,t){}};var cv={},nt={get:(i,r,e,t)=>{let n=cv[r];if(n)return new n(i,e,t);throw{message:"VisuallyJs: unknown overlay type '"+r+"'"}},register:(i,r)=>{cv[i]=r}};var tp=class tp extends li{constructor(e,t,n){super(t,n);this.instance=e;this.component=t;c(this,"label");c(this,"type",tp.type);c(this,"useHTMLElement");c(this,"font");c(this,"isSimpleShape",!1);n=n||{label:""},this.useHTMLElement=e.containerType!=="SVG"&&n.useHTMLElement===!0,this.font=n.font,this.setLabel(n.label)}getLabel(){return vr(this.label)?this.label(this):this.label}setLabel(e){this.label=e,this.instance.updateLabel(this)}updateFrom(e,t){e.font!=null&&(this.font=e.font),e.label!=null&&this.setLabel(e.label),e.location!=null&&yf(this,e.location),xf(this,t)}};c(tp,"type","Label");var or=tp;function kr(i){return i.type===or.type}nt.register(or.type,or);function xf(i,r){if(r){let e=r.fontSize;e!=null&&(i.font=i.font||{},i.font.size=e);let t=r.fontStyle;t!=null&&(i.font=i.font||{},i.font.style=t);let n=r.fontFamily;n!=null&&(i.font=i.font||{},i.font.family=n)}}var Af="labelLocation",Pw=[th,rh,"cssClass",qu,ko,Qu],Ow="parent";function rp(i,r){let e=h=>h?r[h]:null,t=(h,d)=>{if(h==null)return null;{let u=h[Ow],p;if(Array.isArray(u)?p=u:p=[u],p.find(g=>d.indexOf(g)!==-1))throw new Error("circular view reference");return d.push(...p),p.map(g=>e(g)).filter(g=>g!=null)}},n=(h,d,u)=>{let p=Pw.slice();d.mergeStrategy==="override"&&Array.prototype.push.apply(p,["events","overlays"]);let m=fn(h,d,[],p);return o(t(h,u),m,u)},o=(h,d,u)=>{if(h==null)return d;{let p=d;for(let m=0;m<h.length;m++)p=n(h[m],p,u);return p}},s=h=>{if(h==null)return{};if(typeof h=="string")return e(h);if(h.length){let d=!1,u=0,p;for(;!d&&u<h.length;)p=s(h[u]),p?d=!0:u++;return p}},a=s(i),l=[];return a?o(t(a,l),a,l):{}}function ca(i){return(r,e,t)=>{let n=Vc(e,{x:0,y:0,width:1,height:1},i);return Object.assign(n.p,{portId:i[n.idx].portId})}}function bf(i){i.anchorPositions!=null&&(i.anchorPositionFinder=ca(i.anchorPositions))}var np=class{constructor(r,e,t,n){this.model=r;this.viewOptions=t;c(this,"defMap",{nodes:new Map,edges:new Map,groups:new Map,ports:new Map});c(this,"nodes");c(this,"edges");c(this,"groups");c(this,"ports");this.viewOptions=this.viewOptions||{},this.nodes=this.viewOptions.nodes||{},this.edges=this.viewOptions.edges||{},this.ports=this.viewOptions.ports||{},this.groups=this.viewOptions.groups||{};let o,s;function a(l,h){return d=>{l.call(h,{overlay:d.overlay,e:d.e,connection:d.overlay.component,edge:d.overlay.component.edge,model:d.overlay.component.instance.model})}}for(let l in this.viewOptions.edges){if(o=this.getEdgeDefinition(l),o.overlays)for(s=0;s<o.overlays.length;s++){let h=o.overlays[s];if(hv(h)){let d=h.options;if(d.events!=null)for(let u in d.events){let p=d.events[u];d.events[u]=a(p,h)}}}n.$registerConnectionType(l,o)}}getEdgeDefinition(r){if(r==null)return null;if(this.defMap.edges.has(r))return this.defMap.edges.get(r);{let e=rp([r,xe],this.edges);if(e.label!=null){e.overlays=e.overlays||[];let t={type:or.type,options:{useHTMLElement:e.useHTMLLabel===!0,id:"label",label:e.label}};e.labelClass&&(t.options.cssClass=e.labelClass);let n=e.labelLocationAttribute||Af;e.labelLocation?t.options.location=e.labelLocation:t.options.location=`{{${n}}}`,e.labelLocationAttribute&&(t.options.labelLocationAttribute=e.labelLocationAttribute),e.labelFont&&(t.options.font=Object.assign({},e.labelFont)),e.overlays.push(t),delete e.label}if(e.deleteButton!=null){e.overlays=e.overlays||[];let t=(e.deleteButtonClass||ha)+" "+Ku,n=e.deleteButtonLocation||.1;(Array.isArray(n)?n:[n]).forEach(s=>{e.overlays.push({type:or.type,options:{location:s,label:"\u2716",cssClass:t,visibility:e.deleteButton===Wi?Wi:ep}})})}return delete e.parent,this.defMap.edges.set(r,e),e}}getNodeDefinition(r){if(r==null)return null;if(this.defMap.nodes.has(r))return this.defMap.nodes.get(r);{let e=rp([r,xe],this.nodes);return delete e.parent,bf(e),this.defMap.nodes.set(r,e),e}}getPortDefinition(r){if(r==null)return null;if(this.defMap.ports.has(r))return this.defMap.ports.get(r);{let e=rp([r,xe],this.ports);return delete e.parent,bf(e),this.defMap.ports.set(r,e),e}}getGroupDefinition(r){if(r==null)return null;if(this.defMap.groups.has(r))return this.defMap.groups.get(r);{let e=rp([r,xe],this.groups);return delete e.parent,bf(e),this.defMap.groups.set(r,e),e}}getTypeDefinition(r){let e=this.model.getType(r);if(K(r))return this.getNodeDefinition(e);if(Y(r))return this.getGroupDefinition(e);if(H(r))return this.getPortDefinition(e)}};function ip(){return{c:new Set,e:new Set}}var dv=class{constructor(){c(this,"affectedElements",new Set)}};function _w(i){return{id:i,el:null,dirty:!0,x:NaN,y:NaN,width:NaN,height:NaN,modelObject:null,r:0,c:{x:0,y:0},ro:{x:0,y:0},x2:0,y2:0,t:{id:i,c:{x:0,y:0},x:NaN,y:NaN,width:NaN,height:NaN,r:0,x2:0,y2:0,cr:0,sr:0,ro:{x:0,y:0}}}}function Rw(i,r,e,t,n,o){let s=o/360*Math.PI*2,a={x:r+t/2,y:e+n/2},l=Math.cos(s),h=Math.sin(s),d=(A,T)=>xt({x:A,y:T},a,o),u=d(r,e),p=d(r+t,e),m=d(r+t,e+n),g=d(r,e+n),E=d(r+t/2,e+n/2),y=Math.min(u.x,p.x,m.x,g.x),x=Math.max(u.x,p.x,m.x,g.x),f=Math.min(u.y,p.y,m.y,g.y),b=Math.max(u.y,p.y,m.y,g.y);return{x:y,y:f,width:x-y,height:b-f,c:E,r:o,x2:x,y2:b,cr:l,sr:h,id:i,ro:{x:y,y:f}}}var op=(i,r)=>{let e=0;return r.value>i.value?e=-1:r.value<i.value&&(e=1),e},uv=(i,r)=>op(i,r)*-1;function sp(i,r,e,t,n){Qg({id:i,value:r,otherBound:e},t,op,n)}function Zi(i,r){let e=r.findIndex(t=>t.id===i);e>-1&&r.splice(e,1)}var ap=class{constructor(r,e){this.instance=r;this.getRenderedElement=e;c(this,"$d",null);c(this,"rtree");c(this,"Ye",!1);c(this,"Va",!0);c(this,"O",{xmin:[],xmax:[],ymin:[],ymax:[]});c(this,"N",{});c(this,"Ga",{});c(this,"Xe",{xmin:0,xmax:0,ymin:0,ymax:0});this.rtree=new ea(4)}setSuspended(r){this.Ye=r,this.Ye||(this.recomputeBounds(),this.gE())}getExtents(){return Object.assign({},this.Xe)}EE(r,e,t){e!=null&&(Zi(r,this.O.xmin),Zi(r,this.O.xmax),Zi(r,this.O.ymin),Zi(r,this.O.ymax),sp(r,e.t.x,e.t.x2,this.O.xmin,!1),sp(r,e.t.x2,e.t.x,this.O.xmax,!0),sp(r,e.t.y,e.t.y2,this.O.ymin,!1),sp(r,e.t.y2,e.t.y,this.O.ymax,!0),t!==!0&&this.es())}es(){this.Xe.xmin=this.O.xmin.length>0?this.O.xmin[0].value:0,this.Xe.xmax=this.O.xmax.length>0?this.O.xmax[0].value:0,this.Xe.ymin=this.O.ymin.length>0?this.O.ymin[0].value:0,this.Xe.ymax=this.O.ymax.length>0?this.O.ymax[0].value:0}recomputeBounds(){if(this.Va){this.Va=!1,this.O.xmin.length=0,this.O.xmax.length=0,this.O.ymin.length=0,this.O.ymax.length=0;for(let r in this.N){let e=this.N[r];this.O.xmin.push({id:r,value:e.t.x,otherBound:e.t.x2}),this.O.xmax.push({id:r,value:e.t.x2,otherBound:e.t.x}),this.O.ymin.push({id:r,value:e.t.y,otherBound:e.t.y2}),this.O.ymax.push({id:r,value:e.t.y2,otherBound:e.t.y})}this.O.xmin.sort(op),this.O.ymin.sort(op),this.O.xmax.sort(uv),this.O.ymax.sort(uv),this.es()}}findVerticesAtPoint(r,e,t,n,o){t=t==null?0:t;let s=[];if(o=o||[],this.rtree==null)for(let a=0;a<this.O.xmin.length;a++){let l=this.O.xmin[a];if(o.indexOf(l.id)===-1&&l.value-t<r&&l.otherBound+t>r){let h=this.N[l.id];if(h.y-t<e&&h.y2+t>e&&(s.push(h),n))return s}}else{let a=this.rtree.search({x:r-t,y:e-t,width:t===0?1:t*2,height:t===0?1:t*2});for(let l=0;l<a.length;l++){let h=a[l].id;if(o.indexOf(h)===-1&&(s.push(this.N[h]),n))return s}}return s}findVerticesIntersectingWithRect(r,e,t,n,o){e=e==null?0:e;let s=[];if(n=n||[],this.rtree==null)for(let a=0;a<this.O.xmin.length;a++){let l=this.O.xmin[a];if(n.indexOf(l.id)===-1&&Zg(l.value-e,l.otherBound+e,r.x,r.x+r.width,1)){let d=this.N[l.id];if(Zg(d.y-e,d.y2+e,r.y,r.y+r.height,1)&&(s.push(d),t))return s}}else{let a=o?1:0,l=this.rtree.search({x:r.x-e+a,y:r.y-e+a,width:r.width+2*e-2*a,height:r.height+2*e-2*a});for(let h=0;h<l.length;h++){let d=l[h].id;if(n.indexOf(d)===-1&&(s.push(this.N[d]),t))return s}}return s}findVerticesEnclosedByRect(r,e,t,n,o){let s=r.x+r.width,a=r.y+r.height;return this.findVerticesIntersectingWithRect(r,e,t,n,o).filter(l=>o?r.x<l.x&&r.y<l.y&&s>l.x2&&a>l.y2:r.x<=l.x&&r.y<=l.y&&s>=l.x2&&a>=l.y2)}hasVerticesIntersectingWithRect(r,e,t,n){return this.findVerticesIntersectingWithRect(r,e,!0,t,n).length>0}hasLineOfSight(r,e,t){let n=xb(r,e/2);return this.rtree.findIntersectionsWithLine(n[0],t).length===0&&this.rtree.findIntersectionsWithLine(n[1],t).length===0}fE(r,e,t){e.t=Rw(r,e.x,e.y,e.width,e.height,e.r),this.Ga[r]=e.t,this.Va=!0,t!==!0&&(this.Ye||this.EE(r,e,t)),this.rtree!=null&&e.modelObject!=null&&(this.Ye||this.rtree.update(r,e.t.x,e.t.y,e.t.width,e.t.height,{id:r}))}updateElement(r,e,t,n,o,s,a,l){let h=Ds(this.N,r,()=>this.addElement(r,this.getRenderedElement(r),a,{x:e,y:t},{width:n,height:o},s));return h!=null&&(h.dirty=e==null&&h.x==null||t==null&&h.y==null||n==null&&h.width==null||o==null&&h.height==null,a!=null&&(h.modelObject=a),e!=null&&(h.x=e),t!=null&&(h.y=t),n!=null&&(h.width=n),o!=null&&(h.height=o),h.c.x=h.x+h.width/2,h.c.y=h.y+h.height/2,h.x2=h.x+h.width,h.y2=h.y+h.height,s!=null&&(h.r=s||0),h.r==null||h.r===0?h.ro={x:h.x,y:h.y}:h.ro=xt({x:h.x,y:h.y},h.c,h.r),this.$d==null?this.fE(r,h,l):this.$d.affectedElements.add(r)),h}$forEachElement(r){for(let e in this.N)r(this.N[e])}$refreshEveryElement(){for(let r in this.N)this.$refreshElement(r,!0)}$refreshElement(r,e,t,n,o){let s=this.N[r];if(s!=null){let a=n||(this.instance.$_useModelForSizes?{width:s.width,height:s.height}:this.instance.$getSize(s.el)),l=t||this.instance.$getElementPositionInUIRelativeToCanvasOrigin(s.el,a);return(isNaN(l.x)||isNaN(l.y))&&(l=this.instance.$getElementPositionInUIRelativeToCanvasOrigin(s.el)),this.updateElement(r,l.x,l.y,a.width,a.height,o,null,e)}else return null}yE(r,e){return this.updateElement(r,null,null,null,null,e,null,!1)}getBoundsWidth(){return this.Xe.xmax-this.Xe.xmin}getBoundsHeight(){return this.Xe.ymax-this.Xe.ymin}getX(){return this.Xe.xmin}getY(){return this.Xe.ymin}setSize(r,e,t){if(this.N[r]!=null)return this.updateElement(r,null,null,e,t,null,null,!1)}$_updatePosition(r,e,t){if(this.N[r]!=null)return this.updateElement(r,e,t,null,null,null,null,!1)}$_updateSize(r,e,t){if(this.N[r]!=null)return this.updateElement(r,null,null,e,t,null,null,!1)}reset(){this.O.xmin.length=0,this.O.xmax.length=0,this.O.ymin.length=0,this.O.ymax.length=0,this.N={},this.Ga={},this.rtree.clear(),this.es()}remove(r){Zi(r,this.O.xmin),Zi(r,this.O.xmax),Zi(r,this.O.ymin),Zi(r,this.O.ymax),delete this.N[r],delete this.Ga[r],this.rtree!=null&&this.rtree.removeById(r),this.es()}$computeGroupContentExtents(r,e,t,n,o){let s=r.members.map(l=>l.id),a=t!=null?t[r.id]:null;if(a==null){let l=this.instance.viewport.getGroupElement(r.id);o=o||this.instance.$_getGroupContentAreaInfo(r.id),a={x:l.x+o.internalOffset.x,y:l.y+o.internalOffset.y}}return this.$computeExtentsForElementIds(s,e?null:a.x,e?null:a.y,t,n)}$computeExtentsForElementIds(r,e=0,t=0,n,o){let s=1/0,a=-1/0,l=1/0,h=-1/0;return n=n||{},o=o||{},r.forEach(d=>{var p,m,g,E;let u=this.getElement(d);if(u!=null){let y=((p=n[u.id])==null?void 0:p.x)||u.x,x=((m=n[u.id])==null?void 0:m.y)||u.y,f=((g=o[u.id])==null?void 0:g.width)||u.width,b=((E=o[u.id])==null?void 0:E.height)||u.height;s=Math.min(s,y-e),l=Math.min(l,x-t),a=Math.max(a,y-e+f),h=Math.max(h,x-t+b)}}),{xmin:s,xmax:a,ymin:l,ymax:h}}gE(){this.rtree.clear();let r=Object.values(this.N).map(e=>({id:e.id,x:e.t.x,y:e.t.y,width:e.t.width,height:e.t.height,children:[]}));this.rtree.load(r)}getPosition(r){return this.N[r]}getElements(){return this.N}isEmpty(){return Object.keys(this.N).length===0}getElement(r){let e=this.N[r];if(e)return e.dirty?this.$refreshElement(r,!1):e}getElementPosition(r){return this.N[r]!=null?nr(this.N[r]):null}getElementSize(r){return this.N[r]!=null?Ls(this.N[r]):null}getElementBounds(r){return this.N[r]!=null?Object.assign(nr(this.N[r]),Ls(this.N[r])):null}getGroupElement(r){return this.getElement(r)}getNodeElement(r){return this.getElement(r)}addElement(r,e,t,n,o,s){let a=_w(r);a.el=e;let l=Object.assign(a,{connections:[],modelObject:t,visible:!0});if(this.N[r]=l,Y(t)){let m=a;m.collapsed=!1,m.enabled=!0,m.contentArea=this.instance.$getGroupContentAreaElement(e),m.contentAreaOffset=this.instance.$getElementPositionInUIRelativeToParent(m.contentArea)}let h=n==null?{x:0,y:0}:n,d=o==null?{width:0,height:0}:o,u=s==null?0:s,p=this.updateElement(r,h.x,h.y,d.width,d.height,u,t,!0);return p.el=e,l}};var Lw="currentFace",pv={[Et]:Ct,[vt]:Tt,[Tt]:vt,[Ct]:Et},mv={[Et]:vt,[vt]:Ct,[Tt]:Et,[Ct]:Tt},gv={[Et]:Tt,[vt]:Et,[Tt]:Ct,[Ct]:vt};function Sie(i){return i.faces.length===0?Et:i.faces[0]}function nh(i,r){return i.faces.indexOf(r)!==-1}function ww(i,r){return(i.clockwise?mv:gv)[r]}function Dw(i,r){return(i.clockwise?gv:mv)[r]}function Sf(i,r,e){let t=()=>nh(i,r)===!0&&!e(r);return i.lockedAxis==null?i.lockedFace==null?t():i.lockedFace===r:i.lockedAxis.indexOf(r)!==-1}function Nw(i,r){if(nh(i,r))return r;if(nh(i,pv[r]))return pv[r];{let e=ww(i,r);if(nh(i,e))return e;{let t=Dw(i,r);if(nh(i,t))return t}}return r}function Ev(i,r,e){let t={type:i,locations:[{x:0,y:0,offx:0,offy:0,ox:0,oy:0}],currentLocation:0,locked:!1,id:V(),cssClass:e.cssClass||"",isContinuous:!0,timestamp:null,faces:e.faces||r,lockedFace:null,lockedAxis:null,clockwise:e.clockwise!==!1,Bd:null};return Object.defineProperty(t,Lw,{get(){return this.Bd},set(n){this.Bd=Nw(this,n)}}),t}var fv={Continuous:{faces:[Et,Tt,Ct,vt]},ContinuousTop:{faces:[Et]},ContinuousRight:{faces:[vt]},ContinuousBottom:{faces:[Ct]},ContinuousLeft:{faces:[Tt]},ContinuousLeftRight:{faces:[Tt,vt]},ContinuousTopBottom:{faces:[Et,Ct]}};function Iw(i,r){let e=1/0,t=-1;for(let n=0;n<i.locations.length;n++){let o=Math.sqrt(Math.pow(r.x-i.locations[n].x,2)+Math.pow(r.y-i.locations[n].y,2));o<e&&(e=o,t=n,i.currentLocation=n)}return t}var yv={x:.5,y:0,ox:0,oy:-1,offx:0,offy:0},xv={x:.5,y:1,ox:0,oy:1,offx:0,offy:0},bv={x:0,y:.5,ox:-1,oy:0,offx:0,offy:0},Av={x:1,y:.5,ox:1,oy:0,offx:0,offy:0},Mw={x:0,y:0,ox:0,oy:-1,offx:0,offy:0},Vw={x:1,y:0,ox:1,oy:-1,offx:0,offy:0},Gw={x:0,y:1,ox:0,oy:1,offx:0,offy:0},$w={x:1,y:1,ox:0,oy:1,offx:0,offy:0},Bw={x:.5,y:.5,ox:0,oy:0,offx:0,offy:0},Sv={Top:[yv],Bottom:[xv],Left:[bv],Right:[Av],TopLeft:[Mw],TopRight:[Vw],BottomLeft:[Gw],BottomRight:[$w],Center:[Bw],AutoDefault:[yv,bv,xv,Av]};function Tv(i,r){r=r||{};let e=Sv[i];if(e!=null)return Tf(i,e.map(n=>Object.assign({iox:n.ox,ioy:n.oy},n)),r,null);let t=fv[i];if(t!=null)return Ev(i,t.faces,r);throw{message:"VisuallyJs: unknown anchor type '"+i+"'"}}function Tf(i,r,e,t){return{objectType:HE,type:i,locations:r,currentLocation:0,id:V(),isContinuous:!1,isDynamic:r.length>1,isFixed:t!=null,fixedLocation:t,timestamp:null,cssClass:e.cssClass||""}}function vv(i){return i.type==null&&i.x!=null&&i.y!=null&&i.ox!=null&&i.oy!=null}function lp(i,r,e){let t=ft(i);return r!=null&&r<i.length?t.currentLocation=r:e!=null&&Iw(t,e),t}function Fw(i){return i.objectType===HE}function ft(i,r){if(Fw(i))return i;if(r!=null&&(isNaN(r.offsetX)&&(r.offsetX=0),isNaN(r.offsetY)&&(r.offsetY=0),isNaN(r.ox)&&(r.ox=0),isNaN(r.oy)&&(r.oy=0)),z(i)){let e=Tv(i,null);return r!=null&&(e.fixedLocation=r,e.isFixed=!0),e}else{if(vv(i))return Tf(null,[{x:i.x,y:i.y,ox:i.ox,oy:i.oy,offsetX:i.offsetX==null?0:i.offsetX,offsetY:i.offsetY==null?0:i.offsetY}],{},r);if(Array.isArray(i)){let e=i.map(t=>{if(z(t)){let n=Sv[t];return n!=null?Object.assign({iox:n[0].ox,ioy:n[0].oy,cls:""},n[0]):null}else if(vv(t))return Object.assign({iox:t.ox,ioy:t.oy,offx:t.offsetX==null?0:t.offsetX,offy:t.offsetY==null?0:t.offsetY,cls:null},t)}).filter(t=>t!=null);return Tf("Dynamic",e,{},null)}else if(i.type!=null){let e=i;return Tv(e.type,e.options)}else throw`Cannot parse anchor specification ${i}`}}var ioe="___sourceMarker",ooe="___targetMarker",da="__label",Rv="vjs-default-label",Cv="overlay",Uw="labelLocation";function Yw(i,r){let e={cssClass:r.cssClass,id:da,component:i},t=Object.assign(e,r);return new or(i.instance,i,t)}function zw(i,r){let e=null;if(z(r))e=nt.get(i.instance,r,i,{});else if(r.type!=null&&r.options!=null){let t=r,n=Object.assign({},t.options);e=nt.get(i.instance,t.type,i,n)}else e=r;return e.id=e.id||V(),we.cacheTypeItem(i,Cv,e,e.id),i.overlays[e.id]=e,e}function oh(i,r){let e=zw(i,r);if(e.type===or.type&&!z(r)){let t=e,o=r.options.labelLocationAttribute||Uw,s=i.edge.data[o];s&&(t.location=s),xf(t,i.edge.data)}return e}function ih(i,r){return i.overlays[r]}function Xw(i){return i.overlays}function soe(i,r){let e=ih(i,r);e&&i.instance.setOverlayVisible(e,!1)}function jw(i,...r){r=r||[];for(let e in i.overlays)(r.length===0||r.indexOf(e)!==-1)&&i.instance.setOverlayVisible(i.overlays[e],!1)}function aoe(i,r){let e=ih(i,r);e&&i.instance.setOverlayVisible(e,!0)}function Hw(i,...r){r=r||[];for(let e in i.overlays)(r.length===0||r.indexOf(e)!==-1)&&i.instance.setOverlayVisible(i.overlays[e],!0)}function loe(i){for(let r in i.overlays)i.instance.destroyOverlay(i.overlays[r]);i.overlays={},i.overlayPositions=null,i.overlayPlacements={}}function Ji(i,r,e){let t=i.overlays[r];t&&(i.instance.setOverlayVisible(t,!1),e||i.instance.destroyOverlay(t),delete i.overlays[r],i.overlayPositions&&delete i.overlayPositions[r],i.overlayPlacements&&delete i.overlayPlacements[r])}function hoe(i,...r){for(let e=0,t=r.length;e<t;e++)Ji(i,r[e])}function kw(i){return ih(i,da)}function coe(i,r){let e=kw(i);if(e)if(z(r)||vr(r))e.setLabel(r);else{let t=r;t.label&&e.setLabel(t.label),t.location&&(e.location=t.location)}else{let t=z(r)||vr(r)?{label:r}:r;e=Yw(i,t),i.overlays[da]=e}}var Pv="add",Ov="remove",hp="anchors",vf="connector";function _v(i,r,e){for(let t in i.overlays)r===Pv?i.instance.$addOverlayClass(i.overlays[t],e):r===Ov&&i.instance.$removeOverlayClass(i.overlays[t],e)}function Lv(i,r,e){let t=null;r.connector!=null&&(t=we.getCachedTypeItem(i,vf,e.connector),t==null&&(t=Wt.Fd(i,r.connector,e.connector),we.cacheTypeItem(i,vf,t,e.connector)),Wt.setPreparedConnector(i,t)),we.applyType(i,r,e);let n={};function o(h,d){let u=h.options;if(d)return d.updateFrom(u,i.edge.data),n[u.id]=!0,i.instance.$reattachOverlay(d,i),d;{let p=we.getCachedTypeItem(i,Cv,u.id);return p!=null?(i.instance.$reattachOverlay(p,i),p.Qo!==Wi&&i.instance.setOverlayVisible(p,!0),p.updateFrom(u,i.edge.data),i.overlays[p.id]=p):p=oh(i,h),n[p.id]=!0,p}}if(r.overlays)for(let h in r.overlays)o(r.overlays[h],i.overlays[r.overlays[h].options.id]);if(r.sourceMarker){let h=i.sourceMarker==null?null:i.sourceMarker.id===r.sourceMarker.options.id?i.sourceMarker:null;i.sourceMarker=o(r.sourceMarker,h)}else i.sourceMarker=null;if(r.targetMarker){let h=i.targetMarker==null?null:i.targetMarker.id===r.targetMarker.options.id?i.targetMarker:null;i.targetMarker=o(r.targetMarker,h)}else i.targetMarker=null;for(let h in i.overlays)i.overlays[h].ignoreTypes!==!0&&n[i.overlays[h].id]==null&&Ji(i,i.overlays[h].id,!0);r.detachable!=null&&(i.detachable=r.detachable===!0),r.reattach!=null&&(i.reattach=r.reattach===!0),r.scope&&(i.scope=r.scope);let s=null;r.anchor?(s=we.getCachedTypeItem(i,hp,e.anchor),s==null&&(s=[ft(r.anchor),ft(r.anchor)],we.cacheTypeItem(i,hp,s,e.anchor))):r.anchors&&(s=we.getCachedTypeItem(i,hp,e.anchors),s==null&&(s=[ft(r.anchors[0]),ft(r.anchors[1])],we.cacheTypeItem(i,hp,s,e.anchors))),s!=null&&i.instance.router.setConnectionAnchors(i,s);let a={};i.instance.$_extractSimpleEdgeStyles(r,a)&&i.instance.$_setLineStyle(i,a,!1),i.instance.$applyConnectorType(i.connector,r)}function Wr(i,r){we.addClass(i,r),_v(i,Pv,r),i.connector&&i.instance.$addConnectorClass(i.connector,r)}function _r(i,r){we.removeClass(i,r),_v(i,Ov,r),i.connector&&i.instance.$removeConnectorClass(i.connector,r)}var Wt={getAbsoluteOverlayPosition(i,r){return i.overlayPositions?i.overlayPositions[r.id]:null},setPreparedConnector(i,r,e,t,n){if(i.connector!==r){let o,s="";if(i.connector!=null&&(o=i.connector,s=i.instance.$getConnectorClass(i.connector),i.instance.$destroyConnector(i)),i.connector=r,n&&we.cacheTypeItem(i,vf,r,n),Wr(i,s),o!=null){let a=Xw(i);for(let l in a)i.instance.$reattachOverlay(a[l],i)}e||i.instance.$paintConnection(i)}},destroy(i){for(let r in i.overlays)i.instance.destroyOverlay(i.overlays[r]);i.overlays={},i.overlayPositions={},i.sourceElement=null,i.targetElement=null,i.instance.$destroyConnector(i),i.connector=null,we.destroy(i)},setVisible(i,r){we.setVisible(i,r),r?Hw(i):jw(i),i.connector&&i.instance.$setConnectorVisible(i.connector,r),i.instance.$paintConnection(i)},Fd(i,r,e){let t={},n;if(z(r))n=Ne.get(i,r,t);else{let o=r;n=Ne.get(i,o.type,fn(o.options||{},t))}return e!=null&&(n.typeId=e),n},Ud(i,r,e,t,n){let o=Wt.Fd(i,r,n);Wt.setPreparedConnector(i,o,e,t,n)}};function Cf(i){return i==null?null:i.split(" ").filter(r=>r!=null&&r.length>0)}function wv(i,r,e){for(let t in r)i[t]=e}var Ww="connector",Zw="override",Jw="cssClass",Dv="__default",Kw="anchor",qw="anchors";function cp(i,r){let e={},t=i.$defaultType,n=Object.assign({},t);return wv(e,t,Dv),i.$types.forEach(o=>{if(o!==Dv){let s=i.instance.$getConnectionType(o);if(s!=null){let a=new Set([Ww,Kw,qw]);if(s.mergeStrategy===Zw)for(let l in s)a.add(l);n=fn(n,s,[Jw],Array.from(a)),wv(e,s,o)}}}),r&&(n=bo(n,r,"_")),Wo(i)&&Lv(i,n,e),e}function Wo(i){return i.objectType===Pf}var Pf="connection";function Nv(i,r){let e=i.instance.$getConnectionType(r);e!=null&&e.cssClass&&Wo(i)&&_r(i,e.cssClass)}function dp(i){if(i.paintStyle&&i.hoverPaintStyle){let r={};Object.assign(r,i.paintStyle),Object.assign(r,i.hoverPaintStyle),i.hoverPaintStyle=r}}var Toe="add",voe="remove";function Coe(i){if(Wo(i))return{x:i.connector.x,y:i.connector.y}}function Iv(i,r,e){return e=e||{},{cssClass:e.cssClass||"",hoverClass:e.hoverClass||i.defaults.hoverClass,$types:new Set,$typeCache:{},id:e.id||V(),$defaultType:{scope:e.scope||i.defaultScope,overlays:{}},instance:i,deleted:!1,objectType:r,visible:!0,$hover:!1,paintStyle:{},paintStyleInUse:{},hoverPaintStyle:{}}}var we={create(i,r,e){e=e||{};let t=e.cssClass||"",n=e.hoverClass||i.defaults.hoverClass,o=new Set,s={},a=e.id||r+new Date().getTime(),l={scope:e.scope||i.defaultScope,overlays:{}};return{cssClass:t,instance:i,hoverClass:n,$types:o,$typeCache:s,$defaultType:l,id:a}},addClass(i,r){let e=(i.cssClass||"").split(" ");e.push(r),i.cssClass=e.join(" ")},removeClass(i,r,e){let t=(i.cssClass||"").split(" ");i.cssClass=t.filter(n=>n!==r).join(" ")},cacheTypeItem(i,r,e,t){i.$typeCache[t]=i.$typeCache[t]||{},i.$typeCache[t][r]=e},hasType(i,r){return i.$types.has(r)},removeType(i,r,e){let t=Cf(r),n=!1,o=s=>i.$types.has(s)?(Nv(i,s),i.$types.delete(s),!0):!1;if(t!=null){for(let s=0,a=t.length;s<a;s++)n=o(t[s])||n;n&&cp(i,e)}},addType(i,r,e){let t=Cf(r),n=!1;if(t!=null){for(let o=0,s=t.length;o<s;o++)i.$types.has(t[o])||(i.$types.add(t[o]),n=!0);n&&cp(i,e)}},getCachedTypeItem(i,r,e){return i.$typeCache[e]?i.$typeCache[e][r]:null},setPaintStyle(i,r){i.paintStyle=r,i.paintStyleInUse=i.paintStyle,dp(i)},setHoverPaintStyle(i,r){i.hoverPaintStyle=r,dp(i)},getType(i){return Array.from(i.$types.keys())},clearTypes(i,r){i.$types.forEach(e=>{Nv(i,e)}),i.$types.clear(),cp(i,r)},setType(i,r,e){return we.clearTypes(i),(Cf(r)||[]).forEach(i.$types.add,i.$types),cp(i,e)},applyType(i,r,e){we.setPaintStyle(i,r.paintStyle),we.setHoverPaintStyle(i,r.hoverPaintStyle),i.paintStyleInUse=i.paintStyle},appendToDefaultType(i,r){Object.assign(i.$defaultType,r)},destroy(i){i.deleted=!0,delete i.instance},setVisible(i,r){i.visible=r}};function Mv(i,r){return r.theta-i.theta}function Vv(i,r){let e=i.theta<0?-Math.PI-i.theta:Math.PI-i.theta,t=r.theta<0?-Math.PI-r.theta:Math.PI-r.theta;return e-t}var $v={[Et]:Vv,[vt]:Mv,[Ct]:Mv,[Tt]:Vv};function Bv(i,r,e,t,n){let o=e?i.width:i.height,s=e?i.height:i.width,a=[],l=o/(r.length+1);for(let h=0;h<r.length;h++){let d=(h+1)*l,u=t*s;n&&(d=o-d);let p=e?d:u,m=i.x+p,g=i.width===0?0:p/i.width,E=e?u:d,y=i.y+E,x=i.height===0?0:E/i.height;if(i.r!==0&&i.r!=null){let f=xt({x:m,y},i.c,i.r);m=f.x,y=f.y}a.push({x:m,y,xLoc:g,yLoc:x,c:r[h].c,a:r[h].anchor})}return a}function Zo(i){return!i.isFixed&&i.isContinuous===!0}function Fv(i){return[i.currentLocation,i.locations[i.currentLocation]]}function Hoe(i,r,e){let t=$i[r].x,n=$i[r].y;return Gv(i,t,n,e,e/3)}function koe(i,r,e){let t=$i[r].x,n=$i[r].y,o=t===0?i.x-e:i.x+t*e*2,s=t===0?i.x+e:i.x,a=n===0?i.y-e:i.y+n*e*2,l=n===0?i.y+e:i.y,h=Math.min(o,s),d=Math.min(a,l),u=Math.max(o,s),p=Math.max(a,l);return{x:h,y:d,width:u-h,height:p-d}}function Gv(i,r,e,t,n){let o={x:i.x+t*r,y:i.y+t*e},s=rr(i,o,n),a=rr(o,i,n),l=Math.min(s[0].x,s[1].x,a[0].x,a[1].x),h=Math.max(s[0].x,s[1].x,a[0].x,a[1].x),d=Math.min(s[0].y,s[1].y,a[0].y,a[1].y),u=Math.max(s[0].y,s[1].y,a[0].y,a[1].y);return{x:l,y:d,width:h-l,height:u-d}}function Woe(i,r,e,t){if(t.connector!=null){let n=2*Math.max(t.connector.sourceStub,t.connector.targetStub);return Gv(i,r,e,n,n/3)}else return{x:i.x,y:i.y,width:1,height:1}}function up(i,r,e,t){let n,o=t.rotation,s={curX:r.x+i.x*e.width+(isNaN(i.offsetX)?0:i.offsetX),curY:r.y+i.y*e.height+(isNaN(i.offsetY)?0:i.offsetY),x:i.x,y:i.y,ox:0,oy:0};if(o!=null&&o.length>0&&!(o.length===0&&o[0].r===0)){let a=[i.ox,i.oy],l={x:s.curX,y:s.curY,cr:0,sr:0};o.forEach(h=>{l=xt(l,h.c,h.r),a=[Math.round(a[0]*l.cr-a[1]*l.sr),Math.round(a[1]*l.cr+a[0]*l.sr)].slice()}),n={curX:l.x,curY:l.y,x:i.x,y:i.y,ox:a[0],oy:a[1]}}else n=Object.assign({},s);return n}var Qw=10;function eD(i,r,e,t,n,o,s){let a=t.x+i.x*n.width,l=t.y+i.y*n.height;if(o!=null&&o.length>0){let h=Ob([a,l,0,0],o);a=h.x,l=h.y}return Math.sqrt(Math.pow(r-a,2)+Math.pow(e-l,2))}var pp=class{constructor(r,e){this.instance=r;c(this,"anchorLists",new Map);c(this,"zd");c(this,"Ti");c(this,"vi");c(this,"Ci");c(this,"ut");c(this,"rs",new Map);c(this,"Yd",null);e=e||{},this.Ti=e.gridCellSize||Qw,this.zd=e.avoidVertices===!0,this.vi=e.vertexBuffer||2,this.Ci=e.vertexBorder||2}$connectionRemoved(r){Zo(r.connection.anchors.source)&&this.$_removeAnchorFromAnchorLists(r.connection.sourceId,r.connection.anchors.source),Zo(r.connection.anchors.target)&&this.$_removeAnchorFromAnchorLists(r.connection.targetId,r.connection.anchors.target)}elementRemoved(r){r!=null&&this.anchorLists.delete(r.id)}xE(r,e){let t=this.anchorLists.get(e.id),n=0;t!=null&&function(o){if(o){let s=a=>a.c.id===r.id;Lt(o.top,s),Lt(o.left,s),Lt(o.bottom,s),Lt(o.right,s),n+=o.top.length,n+=o.left.length,n+=o.bottom.length,n+=o.right.length}}(t),n===0&&this.anchorLists.delete(e.id)}$connectionDetachedFromElement(r,e){this.xE(r,e)}$setCurrentLocation(r,e,t){r.currentLocation=e}bE(r,e){let t;if(r.isFixed&&r.fixedLocation!=null)t=up(r.fixedLocation,e.xy,e.wh,e);else{let n=e.xy,o=e.wh,s=e.txy,a=e.twh,[l,h]=Fv(r);if(r.locations.length===1||s==null||a==null)t=up(h,n,o,e);else{let[d,u]=this.AE(n,o,s,a,e.rotation,e.tRotation,r.locations,e.otherAnchor);d!==l&&this.$setCurrentLocation(r,d,e.connection),t=up(u,n,o,e)}}return r.computedPosition=t,t}SE(r,e){let t=this.instance.viewport.getPosition(r),n=(o,s,a,l,h,d)=>{if(a.length>0){let u=a.sort($v[o]),p=o===ut||o===Se,m=Bv(t,u,l,h,p);for(let g=0;g<m.length;g++)m[g].a.locations[0]={x:m[g].xLoc,y:m[g].yLoc,ox:d.x,oy:d.y,offsetX:0,offsetY:0},m[g].a.currentLocation=0}};n(st,t,e.bottom,!0,1,{x:0,y:1}),n(Se,t,e.top,!0,0,{x:0,y:-1}),n(ze,t,e.left,!1,0,{x:-1,y:0}),n(ut,t,e.right,!1,1,{x:1,y:0})}ts(r,e,t,n,o,s,a,l,h,d){this.anchorLists.has(r)||this.anchorLists.set(r,{top:[],right:[],bottom:[],left:[]});let u=this.anchorLists.get(r),p=-1,m=-1,g={theta:t,order:n,c:o,elId:s,anchor:e},E=u[h],y=e.currentFace?u[e.currentFace]:null,x;if(y){let f=y.findIndex(b=>b.anchor.id===e.id);if(f!==-1){y.splice(f,1);for(let b=0;b<y.length;b++)x=y[b].c,x.placeholder!==!0&&d.add(x)}}for(let f=0;f<E.length;f++)x=E[f].c,x.placeholder!==!0&&d.add(x);if(p!==-1)E[p]=g;else{let f=l?m!==-1?m:0:E.length;E.splice(f,0,g)}e.currentFace=h}$_removeAnchorFromAnchorLists(r,e){let t=this.anchorLists.get(r),n=0;t!=null&&function(o,s){if(o){let a=l=>l.anchor.id===s;Lt(o.top,a),Lt(o.left,a),Lt(o.bottom,a),Lt(o.right,a),n+=o.top.length,n+=o.left.length,n+=o.bottom.length,n+=o.right.length}}(t,e.id),n===0&&this.anchorLists.delete(r)}computeAnchorLocation(r,e){let t=this.bE(r,e);return r.computedPosition=t,r.timestamp=e.timestamp,t}computePath(r,e){let t=this.instance.viewport.getPosition(r.sourceId),n=this.instance.viewport.getPosition(r.targetId),o=r.connector,s=this.computeAnchorLocation(r.anchors.source,{xy:t,wh:t,elementId:t.id,timestamp:e,rotation:this.instance.$getRotations(r.sourceId),txy:n,twh:n}),a=this.computeAnchorLocation(r.anchors.target,{xy:n,wh:n,elementId:n.id,timestamp:e,rotation:this.instance.$getRotations(r.targetId),txy:t,twh:t});fT(r.connector);let l={sourcePos:s,targetPos:a,strokeWidth:r.paintStyleInUse.strokeWidth,sourceInfo:t,targetInfo:n};o.paintInfo=tf(o,l),QE(o),o.x=o.paintInfo.x,o.y=o.paintInfo.y,o.quadrant=o.paintInfo.quadrant;let h=o.geometry==null||o.geometry.source==null?!1:!sf(s,o.geometry.source),d=o.geometry==null||o.geometry.target==null?!1:!sf(a,o.geometry.target);if(this.instance.$_discardEdgeEditsOnDrag&&(h||d)&&Bi(r),o.edited){let u=this.TE(r,o,l,e,h,d);Ne.setGeometry(r,u,!1)}else{let u=this.vE(r,o,l,e);Ne.setGeometry(r,u,!0)}ef(o),o.width=Math.max(10,o.bounds.xmax-o.x),o.height=Math.max(10,o.bounds.ymax-o.y)}prepareAnchor(r){return ft(r)}Gb(r){let e=Math.max(r.sourceStub,r.targetStub);return Math.max(this.instance.$_vertexBuffer,e)}CE(r,e,t,n,o,s,a,l,h,d,u,p){if(u===this.Yd){let v=this.rs.get(p);if(v!=null)return v}else this.rs.clear();this.Yd=u;let m={HORIZONTAL:"horizontal",VERTICAL:"vertical",DIAGONAL:"diagonal",IDENTITY:"identity"};if(r===e)return{orientation:m.IDENTITY,a:[Se,Se]};let g=Math.atan2(n.c.y-t.c.y,n.c.x-t.c.x),E=Math.atan2(t.c.y-n.c.y,t.c.x-n.c.x),y=[],x={};((v,O)=>{for(let P=0;P<v.length;P++)if(x[v[P]]={[ze]:{x:O[P][0].x,y:O[P][0].c.y},[ut]:{x:O[P][0].x+O[P][0].width,y:O[P][0].c.y},[Se]:{x:O[P][0].c.x,y:O[P][0].y},[st]:{x:O[P][0].c.x,y:O[P][0].y+O[P][0].height}},O[P][1]!=null&&O[P][1].length>0)for(let I in x[v[P]])x[v[P]][I]=_b(x[v[P]][I],O[P][1])})([Qe,An],[[t,a],[n,l]]);let f=[Se,ze,ut,st];for(let v=0;v<f.length;v++)for(let O=0;O<f.length;O++)y.push({source:f[v],target:f[O],dist:Math.round(Be(x.source[f[v]],x.target[f[O]]))});y.sort(function(v,O){if(v.dist<O.dist)return-1;if(O.dist<v.dist)return 1;{let P={[ze]:0,[Se]:1,[ut]:2,[st]:3},I=P[v.source],C=P[O.source],_=P[v.target],w=P[O.target];return I<C?-1:C<I?1:_<w?-1:w<_?1:0}});let b=y[0].source,A=y[0].target,T={},S={};for(let v=0;v<y.length;v++){let O=y[v];if(!Zo(o)||Sf(o,O.source,P=>{if(!h.avoidVertices||h.connector==null)return!1;if(T[P]==null){let I=h.connector.sourceGap+h.connector.sourceStub,C=$i[P],_=this.Ti*(this.Ci+this.vi),w={x:x.source[P].x+I*C.x,y:x.source[P].y+I*C.y,width:Math.max(1,Math.abs(_*C.x)),height:Math.max(1,Math.abs(_*C.y))};T[P]=this.instance.viewport.hasVerticesIntersectingWithRect(w,0,[r],!1)}return T[P]})?b=y[v].source:b=null,!Zo(s)||Sf(s,O.target,P=>{if(!h.avoidVertices||h.connector==null)return!1;if(S[P]==null){let I=h.connector.targetGap+h.connector.targetStub,C=$i[P],_=this.Ti*(this.Ci+this.vi),w={x:x.target[P].x+I*C.x,y:x.target[P].y+I*C.y,width:Math.max(1,Math.abs(_*C.x)),height:Math.max(1,Math.abs(_*C.y))};S[P]=this.instance.viewport.hasVerticesIntersectingWithRect(w,0,[e],!1)}return S[P]})?A=y[v].target:A=null,b!=null&&A!=null)break}b==null&&(b=y[0].source),A==null&&(A=y[0].target);let R={a:[b,A],theta:g,theta2:E};return this.rs.set(p,R),R}$redrawEveryConnection(){let r=V();return this.$a(Object.values(this.instance.$_connMap),r)}$redrawConnection(r,e){return this.$a([this.instance.$_connMap[r.id]],e)}$redraw(r,e){return this.$a(r.connections||[],e)}$a(r,e){let t=new Set,n=new Set;if(!this.instance.pt){e=e||V();let o={};for(let s=0;s<r.length;s++){let a=r[s];if(a.visible===!1)continue;t.add(a);let l=a.sourceId,h=a.targetId,d=Zo(a.anchors.source),u=Zo(a.anchors.target);if(d||u){let p=(a.anchors.source.faces||[]).join("-"),m=(a.anchors.target.faces||[]).join("-"),g=[l,p,h,m].join("-"),E=o[g];d&&!this.anchorLists.has(l)&&this.anchorLists.set(l,{top:[],right:[],bottom:[],left:[]}),u&&!this.anchorLists.has(h)&&this.anchorLists.set(h,{top:[],right:[],bottom:[],left:[]});let y=this.instance.viewport.getPosition(h),x=this.instance.viewport.getPosition(l);if(h===l&&(d||u))this.ts(l,a.anchors.source,-Math.PI/2,0,a,h,0,!1,Se,t),this.ts(h,a.anchors.target,-Math.PI/2,0,a,l,1,!1,Se,t);else{let f=this.instance.$getRotations(l),b=this.instance.$getRotations(h);E||(E=this.CE(l,h,x,y,a.anchors.source,a.anchors.target,f,b,a,a.connector.sourceStub+a.connector.targetStub,e,g),o[g]=E),d&&this.ts(l,a.anchors.source,E.theta,0,a,h,0,!1,E.a[0],t),u&&this.ts(h,a.anchors.target,E.theta2,-1,a,l,1,!0,E.a[1],t)}d&&n.add(l),u&&n.add(h)}}n.forEach(s=>{this.SE(s,this.anchorLists.get(s))}),t.forEach(s=>{this.instance.$paintConnection(s,{timestamp:e})})}return{c:t}}reset(){this.anchorLists.clear(),this.rs.clear()}setConnectionAnchors(r,e){r.anchors.source=e[0],r.anchors.target=e[1]}AE(r,e,t,n,o,s,a,l){if(l!=null){let h=a.map((p,m)=>{let g=r.x+p.x*e.width,E=r.y+p.y*e.height;return{x:g,y:E,idx:m}}),d=l.locations.map((p,m)=>{let g=t.x+p.x*n.width,E=t.y+p.y*n.height;return{idx:m,x:g,y:E}}),u=[];for(let p=0;p<h.length;p++)for(let m=0;m<d.length;m++){let g=Math.round(Be(h[p],d[m]));u.push({d:g,idx:p,idx2:m})}return u.sort((p,m)=>p.d-m.d),[u[0].idx,a[u[0].idx]]}else{let h=t.x+n.width/2,d=t.y+n.height/2,u=a.map((p,m)=>({d:eD(p,h,d,r,e,o,s),idx:m}));return u.sort((p,m)=>p.d-m.d),[u[0].idx,a[u[0].idx]]}}};function Uv(i,r,e,t,n,o,s,a){let l=Ir(r),h=xA(r),d=s(e,t,l,h);d.sort((p,m)=>{let g=p.axis===l&&p.directionFromParent===r.directionFromParent,E=p.axis===l&&p.directionFromParent!==r.directionFromParent,y=m.axis===l&&m.directionFromParent===r.directionFromParent,x=m.axis===l&&m.directionFromParent!==r.directionFromParent;return g||x?-1:y||E?1:0});let u=[];for(let p=0;p<d.length;p++){let m=d[p],g=e+m.dx,E=t+m.dy,y=m.axis,x=m.directionFromParent,f=r.ax+m.dx*n,b=r.ay+m.dy*n,A=i.getCell(g,E,null,null),T=A===a,S={cx:g,cy:E,obj:A,axis:y,directionFromParent:x,ax:f,ay:b,g:r.g+(g-r.x===0||E-r.y===0?1:Math.SQRT2),obstacles:A.obstacles,buffers:A.buffers,isTarget:T};if(A===a)return[S];u.push(S)}return u}function Of(i){let r=[],e=Ir(i),t=i,n=!1,o=0;for(;!n&&t!=null;)r.push(t),o++,Ir(t)!==e&&(n=!0),t=t.parent;return r.length===0?null:{source:i,target:r[r.length-1],isFirstSegment:r[r.length-1].parent==null,axis:Ir(i),length:o}}function tD(i){return i.axis===bn||i.axis===qn}function rD(i){return i.axis===he&&i.source.ax===i.target.ax||i.axis===ne&&i.source.ay===i.target.ay}function Yv(i,r,e){r.push({ax2:i.source.ax,ay2:i.source.ay,ax1:i.target.ax,ay1:i.target.ay,axis:i.axis,pathId:e})}function nD(i,r,e){if(tD(i)||rD(i))Yv(i,r,e);else{let t=i.axis===ne?(i.source.ax+i.target.ax)/2:i.source.ax,n=i.axis===he?(i.source.ay+i.target.ay)/2:i.source.ay,o=i.axis===ne?(i.source.ax+i.target.ax)/2:i.target.ax,s=i.axis===he?(i.source.ay+i.target.ay)/2:i.target.ay,a=i.axis===he?ne:he,l={ax2:i.source.ax,ay2:i.source.ay,ax1:t,ay1:n,axis:i.axis,pathId:e};r.push(l);let h={ax2:t,ay2:n,ax1:o,ay1:s,axis:a,pathId:e};r.push(h);let d={ax2:o,ay2:s,ax1:i.target.ax,ay1:i.target.ay,axis:a,pathId:e};r.push(d)}}function zv(i,r,e){if(e===ne)return[{x:i-50,y:r},{x:i+50,y:r}];if(e===he)return[{x:i,y:r-50},{x:i,y:r+50}];if(e===bn)return[{x:i+50,y:r+50},{x:i-50,y:r-50}];if(e===qn)return[{x:i-50,y:r+50},{x:i+50,y:r-50}]}function _f(i,r,e,t,n,o){let s=i,a=[];n=n||V();let l=Of(s);if(l.isFirstSegment)t===rn?Yv(l,a,n):nD(l,a,n);else{let d=l.source.ax,u=l.source.ay,p=!1,m=Of(l.target);for(;!p&&m!=null;){let g=zv(d,u,l.axis),E;E=zv(m.isFirstSegment?m.target.ax:m.target.cx,m.isFirstSegment?m.target.ay:m.target.cy,m.axis);let y=yb(g,E);y!=null&&(a.push({ax1:y.x,ay1:y.y,ax2:d,ay2:u,axis:l.axis,pathId:n}),d=y.x,u=y.y,l=m),m.isFirstSegment?p=!0:m=Of(m.target)}m!=null&&a.push({ax1:m.target.ax,ay1:m.target.ay,ax2:d,ay2:u,pathId:n,axis:m.axis})}return a.reverse(),{id:n,segments:a,targetCell:i,sourceCell:r,isEmpty:a.length===0}}function Xv(i,r,e,t,n,o){let s=_f(i,r,e,t,o,!1);if(s.segments.length<2)return s;let a=[],l=0,h=!1;function d(u){let p={x:s.segments[u].ax1,y:s.segments[u].ay1},m=u+1,g=!1;for(;!g;){let E=s.segments[m];if(E==null||!n(e,[p,{x:E.ax2,y:E.ay2}]))return{startIdx:u,endIdx:m-1,segment:{ax1:p.x,ay1:p.y,ax2:s.segments[m-1].ax2,ay2:s.segments[m-1].ay2},finished:E==null};m++}}for(;!h;){let u=d(l);a.push(u.segment),u.finished?h=!0:l=u.endIdx+1}return{targetCell:s.targetCell,sourceCell:s.sourceCell,isEmpty:s.isEmpty,segments:a,id:s.id}}function jv(i,r,e,t,n,o,s,a,l,h,d,u,p,m,g,E,y){E==null?E=new Fs(i,r,s,h,d,u):E.reinitialize();let x=E.Uo(i.x,i.y),f=E.Uo(r.x,r.y),b=bE(n);b.axis==null&&(b.axis=yA(i,r));let A=bE(o),T=E.setSourceCell(e,x.x,x.y,i.x,i.y,b.axis,b.direction),S=E.setTargetCell(t,f.x,f.y,r.x,r.y,A.axis,A.direction);if(S.x===T.x&&S.y===T.y)return{targetCell:S,sourceCell:T,segments:[],id:yE,isEmpty:!0};S.fixedAxis=S.fixedAxis||b.axis;let R=T,v=S,O=()=>a===rn?Xv(v,R,E,a,g,y):_f(v,R,E,a,y,!0),P=new bd,I=new Rs(P.sort.bind(P),T),C,_,w=Ic(T.x,T.y,S.x,S.y)*100,B=0;for(;I.length>0;){if(C=I.pop(),C.closed=!0,_=Ir(C),B++,B>w)throw`too many iterations ${B} `;if(C===S)return O();P.node=C;let D=Uv(E,C,C.x,C.y,s,u,m,S);for(let M=0,N=D.length;M<N;M++){let G=D[M];if(G.isTarget)return G.obj.parent=C,O();if(G.obj.closed||G.obj===T||G.obj===S||G.obstacles.length>0||G.buffers.length>0)continue;let J=0;G.axis!==_&&(J=.5),(!G.obj.opened||G.g<G.obj.g)&&(G.obj.g=G.g,G.obj.h=l(G.cx,G.cy,S.x,S.y)+J,G.obj.f=G.obj.g+G.obj.h,G.obj.parent=C,G.obj.ax=G.ax,G.obj.ay=G.ay,G.obj.opened?I.update(G.obj):(I.add(G.obj),G.obj.opened=!0))}}return{targetCell:S,sourceCell:T,segments:[],id:yE,isEmpty:!0}}function Hv(i,r,e,t,n,o,s,a,l,h,d,u,p,m){return jv(i,r,e,t,n,o,a,l,h,d,u,s.findVerticesAtPoint.bind(s),s.findVerticesIntersectingWithRect.bind(s),(g,E,y,x)=>{if(l===rn||l==null)return xE(g,E,y,x);if(l===Qc)return xE(g,E,y,x);if(l===nn)return EA(g,E,y,x)},(g,E)=>{let y=a*d;return s.hasLineOfSight(E,y,g.sourceAndTargetObstacles)},p,m)}function kv(i,r){return{curX:i.curX+i.ox*r,curY:i.curY+i.oy*r,ox:i.ox,oy:i.oy,x:i.x,y:i.y}}var sh=class extends pp{constructor(e,t){super(e,t);this.instance=e;c(this,"Xd")}vE(e,t,n,o){return this.zd||e.avoidVertices?this.OE(e,t,n,o):this.is(e,t,n)}TE(e,t,n,o,s,a){return Ne.update(e,t.paintInfo,n,s,a)}is(e,t,n){return Ne.compute(e,t.paintInfo,n)}OE(e,t,n,o){if(t.edited)this.is(e,t,n);else{let s=t,a=kv(n.sourcePos,t.sourceGap),l=kv(n.targetPos,t.targetGap),h={x:a.curX+t.sourceStub*a.ox,y:a.curY+t.sourceStub*a.oy},d={x:l.curX+t.targetStub*l.ox,y:l.curY+t.targetStub*l.oy},u=Math.min(h.x,d.x),p=Math.max(h.x,d.x),m=Math.min(h.y,d.y),g=Math.max(h.y,d.y),E={x:u,y:m,width:Math.max(p-u,10),height:Math.max(g-m,10)};if(!this.instance.viewport.hasVerticesIntersectingWithRect(E,0,[],!1))return this.is(e,t,n);(this.ut==null||o!==this.Xd)&&(this.ut=new Fs(h,d,this.Ti,this.Ci,this.vi,(y,x,f)=>this.instance.viewport.findVerticesAtPoint(y,x,f))),this.Xd=o;try{let y=e.edge?e.edge.id:e.id,x=Hv(h,d,e.sourceId,e.targetId,a,l,this.instance.viewport,this.Ti,s.constrain,Ic,this.Ci,this.vi,this.ut,y);if(x.isEmpty)Ne.compute(e,t.paintInfo,n);else{x.segments.unshift({ax1:a.curX,ay1:a.curY,ax2:h.x,ay2:h.y,axis:Bs(a.ox,a.oy),pathId:y}),x.segments.push({ax1:d.x,ay1:d.y,ax2:l.curX,ay2:l.curY,axis:Bs(l.ox,l.oy),pathId:y});let f=lf(x.segments.map(A=>Object.assign({x1:A.ax1,y1:A.ay1,x2:A.ax2,y2:A.ay2,o:A.axis||iD(A)},A)));return Bu(e.connector,f),{segments:s.$pathSegments,source:n.sourcePos,target:n.targetPos,quadrant:t.paintInfo.quadrant}}}catch(y){return this.is(e,t,n)}}}};c(sh,"type",xe);function iD(i){return i.axis!=null?i.axis:i.ax1===i.ax2?he:i.ay1===i.ay2?ne:null}var Wv="fill",Rf="stroke",Zv="stroke-width",dle="strokeWidth",ve="svg",Jv="defs",te="path",Xe="circle",Kv="ellipse",Je="text",Lf="tspan",Z="rect",q="g",ule="version",ple="xmlns",mle="fill",wf="stroke-dasharray",gle="stroke-linejoin",Ele="stroke-linecap",fle="stroke-miterlimit",yle="stroke-dashoffset",xle="stroke-opacity",ble="stroke",Ale="stroke-width",mp="vector-effect",gp="non-scaling-stroke",Sle="text-anchor",Zt="http://www.w3.org/2000/svg",Tle="http://www.w3.org/1999/xlink",vle="http://www.w3.org/1999/xhtml";var Ep=class{constructor(r,e){c(this,"$properties");c(this,"$values");this.$values=e||{},this.$properties=Object.keys(e),r.bindAll([$e,Re],t=>{this.$properties.forEach(n=>{t.updates[n]!=null&&(this.$values[n]=t.updates[n])})})}getValue(r,e){return this.$values[r]||e}getValues(){return Object.assign({},this.$values)}};var oD=.5;function qv(i,r){var b,A;let e=Iv(i,Pf,r),t=r.overlays||[],n={},o=i.$defaultOverlays;o&&t.push(...o);for(let T=0;T<t.length;T++){let S=hi(t[T]);n[S.options.id]=S}if(e.$defaultType.overlays=n,r.label&&(e.$defaultType.overlays[da]={type:or.type,options:{label:r.label,useHTMLElement:r.useHTMLLabel===!0,location:r.labelLocation||oD,id:da,cssClass:Rv}}),r.sourceMarker){let T=hi(r.sourceMarker);T.options.location=0,T.options.direction=-1,T.sourceMarker=!0,e.$defaultType.sourceMarker=T}if(r.targetMarker){let T=hi(r.targetMarker);T.options.location=1,T.options.direction=1,T.targetMarker=!0,e.$defaultType.targetMarker=T}let s=r.source,a=r.target,l=(r.anchors?r.anchors[0]:r.anchor)||i.$defaultAnchors[0]||i.$defaultAnchor,h=(r.anchors?r.anchors[1]:r.anchor)||i.$defaultAnchors[1]||i.$defaultAnchor,d=(b=r.edge.anchors)==null?void 0:b.source,u=(A=r.edge.anchors)==null?void 0:A.target,p=ft(l,d),m=ft(h,u),g=i.$_edgesDetachable;r.detachable===!1&&(g=!1);let E=i.$_reattachEdges===!0,y=js({},r.paintStyle||i.defaults.paintStyle);we.appendToDefaultType(e,{detachable:g,reattach:E,paintStyle:y,hoverPaintStyle:js({},r.hoverPaintStyle||i.defaults.hoverPaintStyle)}),r.outlineWidth&&(y.outlineWidth=r.outlineWidth),r.outlineColor&&(y.outlineStroke=r.outlineColor),r.lineWidth&&(y.strokeWidth=r.lineWidth),r.color&&(y.stroke=r.color),r.gradient&&(y.gradient=r.gradient),r.dashArray&&(y.dashArray=r.dashArray);let x=Object.assign(e,{anchorDefs:{source:l,target:h},anchors:{source:p,target:m},sourceId:r.edge.source.getFullId(),sourceElement:s,targetId:r.edge.target.getFullId(),targetElement:a,scope:r.scope,lastPaintedAt:null,visible:!0,paintStyle:r.paintStyle,hoverPaintStyle:r.hoverPaintStyle,detachable:g,reattach:E,edge:r.edge,suspendedElement:null,suspendedElementId:null,suspendedElementType:null,suspendedEndpoint:null,suspendedIndex:null,overlays:{},overlayPlacements:{},overlayPositions:{},connector:null,proxies:{[Qe]:[],[An]:[]},avoidVertices:r.avoidVertices===!0,sourceMarker:null,targetMarker:null});Wt.Ud(x,r.connector||i.$defaultConnector,!0);let f=[xe,r.type].join(" ");return/[^\s]/.test(f)&&we.addType(x,f,r.data),x}var ah=class{constructor(r){c(this,"grid");c(this,"snap",!1);c(this,"fitGroupsToGrid",!1);r!=null&&(this.snap=r.snap===!0,this.grid=r.size,this.fitGroupsToGrid=r.fitGroupsToGrid!==!1)}};var fp=class{constructor(r,e){this.gridProfile=e;c(this,"afterGroupCollapse");c(this,"afterGroupExpand");c(this,"afterGroupResize");c(this,"afterGroupShrink");c(this,"afterGroupGrow");c(this,"afterLayout");c(this,"afterDrag");c(this,"constant");c(this,"trackback");c(this,"trackbackThreshold");c(this,"constrainToViewport");c(this,"repositionDraggedElement");c(this,"grid");r=r||{},this.afterDrag=r.afterDrag===!0,this.constant=r.constant===!0,this.trackback=r.trackback!==!1,this.trackbackThreshold=r.trackbackThreshold,this.constrainToViewport=r.constrainToViewport===!0,this.repositionDraggedElement=r.repositionDraggedElement===!0,this.afterLayout=r.afterLayout===!0,this.afterGroupResize=r.afterGroupResize===!0,this.afterGroupShrink=r.afterGroupShrink===!0||this.afterGroupResize&&r.afterGroupShrink!==!1,this.afterGroupGrow=r.afterGroupGrow===!0||this.afterGroupResize&&r.afterGroupGrow!==!1,this.afterGroupCollapse=r.afterGroupCollapse===!0,this.afterGroupExpand=r.afterGroupExpand===!0,this.constant&&this.afterDrag&&(this.constant=!1),this.constant&&(this.repositionDraggedElement=!1)}};var Qv={},sr={get:i=>{let r=Qv[i];if(!r)U("WARN: VisuallyJs: unknown UI plugin '"+i+"'");else return new r},register:(i,r)=>{Qv[i]=r}};function Nt(i){return function(r){sr.register(i,r)}}function yp(i,r,e,t,n,o,s){s=s||r.minSize;let a=r.maxSize,l=r.padding||0,h=(s==null?void 0:s.width)||0,d=(s==null?void 0:s.height)||0,u=0,p=0;isFinite(i.xmin)&&i.xmin<l&&n&&(u=l-i.xmin),isFinite(i.ymin)&&i.ymin<l&&n&&(p=l-i.ymin);let m=(isFinite(i.xmax)?i.xmax:0)+u+l,g=(isFinite(i.ymax)?i.ymax:0)+p+l,E=Math.min((a==null?void 0:a.width)||m,m),y=Math.min((a==null?void 0:a.height)||g,g);if(E=Math.max(h,E),y=Math.max(d,y),e){if(isFinite(i.xmin)&&i.xmin>l&&t){let x=i.xmin-l,f=E-x;E=Math.max((s==null?void 0:s.width)||f,f),E>f&&(x-=E-f),u=-x}if(isFinite(i.ymin)&&i.ymin>l&&t){let x=i.ymin-l,f=y-x;y=Math.max((s==null?void 0:s.height)||f,f),y>f&&(x-=y-f),p=-x}}if(o.grid&&o.fitGroupsToGrid!==!1){let x=E/o.grid.width;E=o.grid.width*Math.ceil(x);let f=y/o.grid.height;y=o.grid.height*Math.ceil(f);let b=u/o.grid.width;u=o.grid.width*Math.ceil(b);let A=p/o.grid.height;p=o.grid.height*Math.ceil(A)}return{width:E,height:y,layoutShiftX:u,layoutShiftY:p}}function eC(i,r,e,t){let n=i.$_connMap[r.id];if(n){if(n.proxies==null||n.proxies[e]==null||n.proxies[e].length===0)return;let o=n.proxies[e].pop(),s=o.originalElement,a=o.element,l=o.originalAnchor;return t!=null&&(l=ft(t)),i.$sourceOrTargetChanged(a.id,s.id,n,s.el,e),e===Qe?n.anchors.source=l:n.anchors.target=l,Wt.setVisible(n,o.originallyVisible),s}return null}function tC(i,r,e,t,n){let o=i.$_connMap[r.id];if(o){let s=e==="source"?0:1;if(n==null)if(Y(t.modelObject)){let d=i.view.getGroupDefinition(i.model.getNodeType(t.modelObject.data));n=ft(d.anchor||i.$defaultAnchors[s]||i.$defaultAnchor||"Continuous")}else n=ft(i.$defaultAnchors[s]||i.$defaultAnchor||"Continuous");let a=CS(o.proxies[e]),l=a!=null?a.originalElement.id:e===Qe?o.sourceId:o.targetId,h=a!=null?a.originalAnchor:e===Qe?o.anchors.source:o.anchors.target;e===Qe?o.anchors.source=n:o.anchors.target=n,i.$sourceOrTargetChanged(l,t.id,o,t.el,e),o.proxies[e].push({originalAnchor:h,element:t,originalElement:i.$getManagedElement(l),originallyVisible:o.visible}),Wt.setVisible(o,!0),i.$revalidateElementById(t.id)}}var sD=["color","lineWidth","outlineWidth","outlineColor","dashArray","gradient"];function xp(i,r,e){r!=null&&(Kg(r.connections,i),r.connections.length===1&&i.instance.$addClassToElement(r.el,ql)),e!=null&&(r==null||i.sourceId!==i.targetId)&&(Kg(e.connections,i),e.connections.length===1&&i.instance.$addClassToElement(e.el,ql))}function bp(i,r,e){if(r!=null){let t=r.connections.length;Lt(r.connections,n=>i.id===n.id),i.instance.router.$connectionDetachedFromElement(i,r),t>0&&r.connections.length===0&&i.instance.$removeClassFromElement(r.el,ql)}if(e!=null){let t=e.connections.length;(r==null||i.sourceId!==i.targetId)&&Lt(e.connections,n=>i.id===n.id),i.instance.router.$connectionDetachedFromElement(i,e),t>0&&e.connections.length===0&&i.instance.$removeClassFromElement(e.el,ql)}}var aD=2,lD=2,Ap=class extends $t{constructor(e,t,n,o,s){var l,h,d,u,p,m,g,E,y,x,f,b,A,T;super();c(this,"Ba",[]);c(this,"Fa",[]);c(this,"containerType",null);c(this,"id");c(this,"defaults");c(this,"Oi",{});c(this,"hoverSuspended",!1);c(this,"pt",!1);c(this,"jd",null);c(this,"$_dataLoading",!1);c(this,"zoomToFitOnLoad");c(this,"plugins",[]);c(this,"pluginMap",new Map);c(this,"connectorClass",aa);c(this,"connectorOutlineClass",KT);c(this,"connectorPathClass",JT);c(this,"overlayClass",la);c(this,"labelOverlayClass",QT);c(this,"$_connMap",{});c(this,"allowNestedGroups");c(this,"$_discardEdgeEditsOnDrag");c(this,"$_vertexBuffer");c(this,"$_vertexBorder");c(this,"os");c(this,"viewport",new ap(this,e=>this.getRenderedElement(e)));c(this,"router");c(this,"Ua",new Map);c(this,"me");c(this,"za",new Set);c(this,"kd");c(this,"$defaultConnector");c(this,"$defaultOverlays");c(this,"$defaultAnchor");c(this,"$defaultAnchors");c(this,"Hd");c(this,"Wd");c(this,"$isInMotion");c(this,"magnetizerProfile");c(this,"magnetizer");c(this,"$unrenderedVertices",new Map);c(this,"$unprocessedGroupMemberships",new Map);c(this,"$_useModelForSizes");c(this,"$_writeSizeToElements");c(this,"$_useModelForPositions");c(this,"$_allowUnattachedEdges");c(this,"$_edgesDetachable");c(this,"$_reattachEdges");c(this,"$paintConnectorOutline");c(this,"$connectorOutlineColor");c(this,"$connectorOutlineWidth");c(this,"j",1);c(this,"$collapsedGroupSizeCalculator");c(this,"Zd");c(this,"Ya");c(this,"Xa");c(this,"view");c(this,"gridProfile");c(this,"$connectionEstablished");c(this,"vertexList",[]);c(this,"logicalPorts");c(this,"objectFilter");c(this,"layoutMap",new Map);c(this,"$_layout");c(this,"model");c(this,"dataSource");c(this,"PE");c(this,"ss");c(this,"rootElement");c(this,"wt",[]);c(this,"$_dataHooks",[]);this.model=e,this.dataSource=t,this.rootElement=n,this.id=o.id||V(),this.gridProfile=new ah(o.grid),this.$connectionEstablished=o.connectionEstablished||(S=>{}),this.logicalPorts=o.logicalPorts===!0,this.objectFilter=o.objectFilter||function(S){return!0},this.$defaultConnector=((l=o.edges)==null?void 0:l.connector)||wn,this.Hd=(h=o.edges)==null?void 0:h.sourceMarker,this.Wd=(d=o.edges)==null?void 0:d.targetMarker,this.$defaultOverlays=(((u=o.edges)==null?void 0:u.overlays)||[]).map(S=>hi(S)),this.$defaultAnchor=((p=o.edges)==null?void 0:p.anchor)||"Continuous",this.$defaultAnchors=((m=o.edges)==null?void 0:m.anchors)||[null,null],this.defaults={[Qu]:null,[av]:1,[ko]:{strokeWidth:2,stroke:"#000000"},[ff]:"vjs_defaultscope",[Ef]:!0,[ov]:20},s&&Object.assign(this.defaults,s),Object.assign(this.Oi,this.defaults),this.Oi[ko]!=null&&(this.Oi[ko].strokeWidth=this.Oi[ko].strokeWidth||2),this.kd=this.defaults[ff],this.allowNestedGroups=this.Oi[Ef]!==!1,this.$_discardEdgeEditsOnDrag=o.edges&&o.edges.discardEditsOnDrag===!0,this.$_vertexBuffer=o.edges?o.edges[nv]:aD,this.$_vertexBorder=o.edges?o.edges[rv]:lD,this.os=((g=o.edges)==null?void 0:g.avoidVertices)===!0,this.$_allowUnattachedEdges=((E=o.edges)==null?void 0:E.allowUnattached)===!0,this.$_edgesDetachable=((y=o.edges)==null?void 0:y.detachable)!==!1,this.$_reattachEdges=((x=o.edges)==null?void 0:x.reattach)===!0,this.$paintConnectorOutline=((f=o.edges)==null?void 0:f.paintOutline)!==!1,this.$connectorOutlineWidth=((b=o.edges)==null?void 0:b.outlineWidth)||20,this.$connectorOutlineColor=((A=o.edges)==null?void 0:A.outlineColor)||"transparent",this.zoomToFitOnLoad=o.zoomToFit===!0,this.router=new sh(this,{gridCellSize:((T=o.edges)==null?void 0:T.astarGridCellSize)||10,avoidVertices:this.os}),this.$_useModelForSizes=o.useModelForSizes===!0,this.$_writeSizeToElements=o.writeSizeToElements!==!1,this.$_useModelForPositions=o.useModelForPositions!==!1,this.magnetizerProfile=new fp(o.magnetizer||{},this.gridProfile),this.magnetizer=new Ri({positionGetter:S=>this.getElementPosition(S.id),getSize:S=>this.getElementSize(S.id),getId:S=>S.id,positionSetter:(S,R)=>{}}),this.ss=!0,o.edges!=null&&o.edges.simpleEdgeStyles===!1&&(this.ss=!1),this.setContainer(n),this.$setView(o.view),this.ja(pt,S=>{let R=this.$_connMap[S.edge.getId()];if(R){let v=this.dataSource.getEdgeType(S.edge.data),O=[...new Set([xe,v])];if(this.$_setConnectionType(R,O.join(" "),S.edge.data),this.ss===!0){let P={};this.$_extractSimpleEdgeStyles(S.edge.data,P)&&this.$_setLineStyle(R,P,!0)}this.le(P=>{P.$edgeUpdated(S.edge,R)})}}),this.ja(_d,S=>{if(S.source===this){S.group.data[this.$modelWidthAttribute]=S.sizeAfterUndo.width,S.group.data[this.$modelHeightAttribute]=S.sizeAfterUndo.height;var R=this.viewport.updateElement(S.group.id,null,null,S.sizeAfterUndo.width,S.sizeAfterUndo.height,null,null,!1);this.$setGroupElementSize(S.group,S.sizeAfterUndo),this.$doVertexUpdated(R),this.le(v=>{v.$groupResized({element:R,newGroupSize:S.sizeAfterUndo,originalGroupSize:S.sizeBeforeUndo})})}}),this.ja(Od,S=>{if(S.source===this){S.group.data[this.$modelWidthAttribute]=S.sizeAfterUndo.width,S.group.data[this.$modelHeightAttribute]=S.sizeAfterUndo.height;var R=this.viewport.updateElement(S.group.id,null,null,S.sizeAfterUndo.width,S.sizeAfterUndo.height,null,null,!1);this.$setGroupElementSize(S.group,S.sizeAfterUndo),this.$doVertexUpdated(R),this.le(v=>{v.$groupResized({element:R,newGroupSize:S.sizeAfterUndo,originalGroupSize:S.sizeBeforeUndo})})}}),this.$_layout=qe.get(Is.type,{adapter:this.$createDefaultLayoutAdapter(),instance:this.model,dataSource:this.dataSource,container:this.rootElement,options:{}});let a=o.layout||{type:So.type};this.setLayout(a,!0),this.$collapsedGroupSizeCalculator=o.getCollapsedGroupSize,this.Zd=o.defaultCollapsedGroupSize||{width:200,height:150},this.Ya=o.canCollapseGroup,this.Xa=o.canExpandGroup}get defaultScope(){return this.kd}get $modelTopAttribute(){return this.model.modelTopAttribute}get $modelLeftAttribute(){return this.model.modelLeftAttribute}get $modelWidthAttribute(){return this.model.modelWidthAttribute}get $modelHeightAttribute(){return this.model.modelHeightAttribute}get $modelRotationAttribute(){return this.model.modelRotationAttribute}get currentZoom(){return this.j}getLayout(){return this.$_layout}$edgeTargetChanged(e){if(e.source==null||e.source!==this){let t=e.edge,n=this.$_connMap[t.getId()],o=t.target.getFullId(),s=this.$getManagedElement(o);s==null&&H(t.target)&&(s=this.Jd(t.target),s==null&&(s=this.$getManagedElement(t.target.parent.id))),n?s!=null?(this.dataSource.debugEnabled&&console.log("DEBUG: target change",n),this._E(n,s,!Oi(e.old))):(delete this.$_connMap[t.getId()],this.ka(n,{force:!0,fireEvent:!1})):s!=null&&this.dataSource.debugEnabled&&U("DEBUG: Target for Edge "+t.getId()+" changed to Node "+s.id+"; we have no valid connection.")}}$select(e){if(K(e.obj)||Y(e.obj)){let t=this.getRenderedElement(e.obj.id);t&&this.$addClassToElement(t,ki)}else if(Ke(e.obj)){let t=this.$_connMap[e.obj.id];t&&this.$addConnectorClass(t.connector,eh)}else if(H(e.obj)){let t=this.getRenderedElement(e.obj.getFullId());t&&this.$addClassToElement(t,ki)}}setSuspendRendering(e,t){}$deselect(e){if(K(e.obj)||Y(e.obj)){let t=this.getRenderedElement(e.obj.id);t&&this.$removeClassFromElement(t,ki)}else if(Ke(e.obj)){let t=this.$_connMap[e.obj.id];t&&this.$removeConnectorClass(t.connector,eh)}else if(H(e.obj)){let t=this.getRenderedElement(e.obj.getFullId());t&&this.$removeClassFromElement(t,ki)}}$selectionCleared(e){this.$getSelector(this.me,"."+eh).forEach(t=>this.$removeClassFromElement(t,eh)),this.$getSelector(this.me,"."+ki).forEach(t=>this.$removeClassFromElement(t,ki))}Jd(e){let t=this.getRenderedPort(e);if(t!=null)return this.$manage(t,e,null,null,null,!1)}$edgeSourceChanged(e){if(e.source==null||e.source!==this){let t=e.edge,n=this.$_connMap[t.getId()],o=t.source.getFullId(),s=this.$getManagedElement(o);s==null&&H(t.source)&&(s=this.Jd(t.source),s==null&&(s=this.$getManagedElement(t.source.parent.id))),n&&s?s!=null?this.RE(n,s,!Oi(e.old)):(delete this.$_connMap[t.getId()],this.ka(n,{force:!0,fireEvent:!1})):s!=null&&this.dataSource.debugEnabled&&U("DEBUG: Source for Edge "+t.getId()+" changed to Node "+t.source.getFullId()+"; we have no valid connection.")}}onDestroy(e){this.bind(Di,e)}ja(e,t){this.Ba.push({event:e,fn:t}),this.dataSource.bind(e,t,!0)}$dataLoadStart(){this.$_dataLoading=!0,this.$_setSuspendDrawing(!0),this.viewport.setSuspended(!0),this.fire(Zd)}$dataAppendStart(){this.$_setSuspendDrawing(!0)}$dataAppendEnd(e){}$dataLoadEnd(e){if(this.$unrenderedVertices.size===0){let t=V();this.$_setSuspendDrawing(!1,!1),e?this.viewport.setSuspended(!1):(this.relayout(null,!0),this.viewport.setSuspended(!1),this.$flushUnrenderedEdges(t),this.router.$redrawEveryConnection()),this.zoomToFitOnLoad&&!e&&this.zoomToFit(),this.$_dataLoading=!1,this.fire(vn)}}zoomToFit(e){this.$zoomToFit(e)}zoomToFitIfNecessary(e){this.$zoomToFitIfNecessary(e)}zoomToElements(e){this.$zoomToElements(e)}cloneVertex(e,t){var o,s;let n=this.getObjectInfo(e,!1);if(n.obj){let a=t==null?void 0:t.newPosition,l=ot(n.obj.data);if(delete l.id,a!=null)l[this.$modelLeftAttribute]=a.x,l[this.$modelTopAttribute]=a.y;else{let d=((o=t==null?void 0:t.offsetPosition)==null?void 0:o.x)||50,u=((s=t==null?void 0:t.offsetPosition)==null?void 0:s.y)||50;l[this.$modelLeftAttribute]+=d,l[this.$modelTopAttribute]+=u}let h;return this.model.transaction(()=>{h=Y(n.obj)?this.model.addGroup(l):this.model.addNode(l),a==null&&(this.magnetizerProfile.constant&&(t==null?void 0:t.magnetize)!==!1||!this.magnetizerProfile.constant&&(t==null?void 0:t.magnetize)===!0)&&this.as(h,null,!1,{},{},null,!0,!1,!1),(t==null?void 0:t.selectAfterCreate)===!0&&setTimeout(()=>this.model.setSelection(h))},St),h}}Kd(){let e,t,n,o,s,a=!1,l=V();for(e=0,n=this.dataSource.getGroupCount();e<n;e++)o=this.dataSource.getGroupAt(e),this.objectFilter(o)&&(this.$doRenderGroup(o),a=!0);for(e=0,n=this.dataSource.getNodeCount();e<n;e++)t=this.dataSource.getNodeAt(e),this.objectFilter(t)&&(this.$doRenderNode(t),a=!0);let h=this.dataSource.getAllEdges();for(e=0,n=h.length;e<n;e++)s=h[e],this.objectFilter(s)&&(this.qd(h[e],Al,null,null,l),a=!0);return this.$flushUnrenderedEdges(l),a}$_hasUnrenderedEdges(){return this.wt.length!==0}LE(e,t,n,o){let s=H(o.source)?o.source.getParent():o.source,a=H(o.target)?o.target.getParent():o.target,l=n.sourcePortType||(H(o.source)?null:this.$getAttribute(e,ai)||this.$getAttribute(e,Hr)),h=n.targetPortType||(H(o.target)?null:this.$getAttribute(e,ji)||this.$getAttribute(t,Hr));return{sourceDef:l!=null?this.view.getPortDefinition(l):this.view.getTypeDefinition(o.source),targetDef:h!=null?this.view.getPortDefinition(h):this.view.getTypeDefinition(o.target),sourceParentDef:this.view.getTypeDefinition(s),targetParentDef:this.view.getTypeDefinition(a)}}$_extractSimpleEdgeStyles(e,t){let n=!1;return sD.forEach(o=>{e.hasOwnProperty(o)&&(n=!0,t[o]=e[o])}),n}wE(e,t,n,o){var R,v;let s=e.edge,a=e.context||{},l=a.edgeType||this.dataSource.getEdgeType(s.data),h=e.def||this.view.getEdgeDefinition(l),d=H(s.source)?s.source.getParent():s.source,u=this.getElement(d.id),p=H(s.target)?s.target.getParent():s.target,m=this.getElement(p.id),{sourceDef:g,targetDef:E,sourceParentDef:y,targetParentDef:x}=this.LE(u.el,m.el,a,s),f={type:l,data:s.data,cost:s.getCost(),directed:s.isDirected(),geometry:s.geometry,id:s.id,edge:s,anchor:null,anchors:[null,null],source:t,target:n,sourceMarker:h.sourceMarker||this.Hd,targetMarker:h.targetMarker||this.Wd};[qu,iv,sv].forEach(O=>{h.hasOwnProperty(O)&&(f[O]=h[O])}),f.anchor&&!f.anchors&&(f.anchors=[f.anchor,f.anchor],delete f.anchor);let A=(O,P,I,C,_)=>{if(C&&C[I]){let w=O[P]||[C[I],C[I]];w[_]=C[I],O[P]=w}};g!=null&&A(f,rh,th,g,0),E!=null&&A(f,rh,th,E,1);let T=f;if(T.avoidVertices=this.os||h.avoidVertices,this.dataSource.debugEnabled&&console.log("Renderer","adding connection with params",T),h!=null&&Object.assign(f,bo(h,s.data,null,!0)),this.$manage(T.source,s.source,null,null,null,!1),(R=s.anchors)!=null&&R.source)f.anchors[0]=ft(s.anchors.source);else{let O=a.positionOnSource||{x:0,y:0},P=g.anchorPositions||y.anchorPositions,I=g.anchorPositionFinder||y.anchorPositionFinder;if(P!=null)f.anchors[0]=lp(P.slice(),null,O);else if(I!=null){let C=I(u.el,O,s.source,E);f.anchors[0]=C}}if(this.$manage(T.target,s.target,null,null,null,!1),(v=s.anchors)!=null&&v.target)f.anchors[1]=ft(s.anchors.target);else{let O=a.positionOnTarget||{x:0,y:0},P=E.anchorPositions||x.anchorPositions,I=E.anchorPositionFinder||x.anchorPositionFinder;if(a.targetAnchor!=null)f.anchors[1]=lp([a.targetAnchor]);else if(P!=null)f.anchors[1]=lp(P.slice(),null,O);else if(I!=null){let C=I(m.el,O,s.target,E);f.anchors[1]=C}}this.ss===!0&&this.$_extractSimpleEdgeStyles(s.data,f);let S=qv(this,f);if(S!=null){xp(S,this.getElement(S.sourceId),this.getElement(S.targetId)),T.geometry&&(Ne.importGeometry(S,T.geometry),this.$revalidateElementById(S.sourceId,o),this.$revalidateElementById(S.targetId,o)),S.edge=s,this.$_connMap[s.getId()]=S,s.source.dummy&&(S.anchors.source.isFixed=!0,S.anchors.source.fixedLocation={x:.5,y:.5,ox:0,oy:0,offsetX:0,offsetY:0}),s.target.dummy&&(S.anchors.target.isFixed=!0,S.anchors.target.fixedLocation={x:.5,y:.5,ox:0,oy:0,offsetX:0,offsetY:0}),this.PE&&this.refresh(),(m.visible===!1||u.visible===!1)&&this.ls(s,!1),T.geometry||this.$revalidateElementById(S.sourceId,o);let O={connection:S,edge:s,reason:e.reason};this.fire(DA,O)}else U("VisuallyJs - WARN : An edge could not be rendered "+s+" and is being removed from the dataset."),this.model.removeEdge(s,this);return S}$graphClearStart(){this.$_layout&&this.$_layout.Jn(),this.layoutMap.clear(),this.reset()}$graphClearEnd(){}$groupRemoved(e){let t=this.viewport.getGroupElement(e.group.id);return t&&(this.vertexList=this.vertexList.filter(o=>o.id!==e.group.id),e.removeChildren===!1&&e.children.forEach(o=>{let s=this.$getManagedElement(o.id);o.data[this.$modelLeftAttribute]=s.x,o.data[this.$modelTopAttribute]=s.y,this.$appendElementToVertexLayer(s.el),this.$setViewportElementPosition(s,s)}),e.group.getPorts().map(o=>this.$getManagedElement(o.getFullId())).forEach(o=>this.$__unmanage(o.el,!1,!0)),this.$__unmanage(t.el,e.removeChildren===!0,!0),this.le(o=>{o.$groupRemoved(t)})),t}qd(e,t,n,o,s,a){this.wt.push({edge:e,reason:t,context:n,def:o}),a&&this.$flushUnrenderedEdges(s)}$flushUnrenderedEdges(e){let t=this.wt.length,n=[];if(t>0){let o=[];for(let s=0;s<this.wt.length;s++)this.DE(this.wt[s],e)==null?o.push(this.wt[s]):n.push(this.wt[s].edge);this.wt=o}return n}DE(e,t){let n=this.getRenderedElement(e.edge.target),o=this.getRenderedElement(e.edge.source);return n==null||o==null?null:this.wE(e,o,n,t)}$edgeAdded(e,t){if(e.source!==this||e.transient===!0&&e.source===this){let n=e.edge;if(this.objectFilter(n.source)&&this.objectFilter(n.target)){let o=this.view.getEdgeDefinition(this.dataSource.getEdgeType(n.data||{}));if(o&&o.ignore===!0)return;this.qd(n,e.reason,t,o,null,!this.$_dataLoading)}}}$edgeRemoved(e){if(e.edge.transient||e.source!==this){let t=e.edge,n=this.$_connMap[t.getId()];n&&(this.dataSource.debugEnabled&&console.log("Renderer","removing edge",t),delete this.$_connMap[t.getId()],this.ka(n,{fireEvent:!1,force:!0}),this.le(o=>{o.$edgeRemoved(t,n)}))}}$edgeGeometryUpdated(e,t,n){let o=this.getRenderedConnection(e.id);o!=null&&(t!=null?Ne.importGeometry(o,t):Bi(o),this.$revalidateElementById(e.source.getFullId()),this.fire(ti,{edge:e,geometry:t,originalGeometry:n}))}$exportEdgeGeometry(e){let t=this.$_connMap[e.id];return t==null?null:Yr(t.connector)}$nodeAdded(e){let t=e.node;this.objectFilter(t)&&this.$doRenderNode(t,e.eventInfo)}$groupAdded(e){let t=e.group;this.objectFilter(t)&&this.$doRenderGroup(t,e.eventInfo)}$portAdded(e){this.objectFilter(e.port.getParent())&&setTimeout(()=>this.$flushUnrenderedEdges(V()))}$vertexUpdated(e){if(e.vertex!=null){let t=this.getElement(e.vertex.getFullId());if(t){let n=null,o=e.vertex.data[this.$modelLeftAttribute],s=null,a=e.vertex.data[this.$modelTopAttribute];if(e.updates!=null){if((e.updates[this.$modelWidthAttribute]!=null||e.updates[this.$modelHeightAttribute]!=null)&&(n=e.vertex.data[this.$modelWidthAttribute],s=e.vertex.data[this.$modelHeightAttribute],this.$_useModelForSizes)){let d=this.$resolveVertexSizeFromModel(e.vertex,this.view.getTypeDefinition(e.vertex));this.$setElementSizeInUI(t.el,d.width,d.height),n=d.width,s=d.height,this.le(u=>{u.$vertexResized(this.getElement(e.vertex.getFullId()),n,s)})}e.updates[this.$modelRotationAttribute]!=null&&this.Qd(e.vertex,e.updates[this.$modelRotationAttribute],!1,!0)}let l=o,h=a;if(e.vertex.group!=null){let d=this.$_getGroupContentAreaInfo(e.vertex.group.id).pageOrigin;l+=d.x,h+=d.y}if(this.viewport.updateElement(t.id,l,h,n,s,null,e.vertex,!1),(e.updates[this.$modelLeftAttribute]!=null||e.updates[this.$modelTopAttribute]!=null)&&this.$setViewportElementPosition(t,{x:o,y:a}),this.$doVertexUpdated(t),this.$repaintUIElement(this.getElement(t.id)),e.reason===Js&&this.os){let d=this.model.getAllEdges().filter(u=>Zn(u.source).id!==e.vertex.id&&Zn(u.target).id!==e.vertex.id);this.repaintEdges(d)}e.reason===ou?this.NE(this.getElement(t.id),e.originalData):this.fire(ks,this.getElement(t.id)),this.le(d=>d.$vertexUpdated(this.getElement(t.id),e.reason))}}}NE(e,t){let n={x:t[this.$modelLeftAttribute],y:t[this.$modelTopAttribute]},o={dragGroup:[{element:e,vertex:e.modelObject,pos:{x:e.x,y:e.y},originalPos:n}],positions:{[e.id]:{x:e.x,y:e.y}},ui:this},s=Y(e.modelObject)?Gr:Dt;this.fire(s,o)}IE(e){this.fire(Le,e)}getLayoutFor(e){return iE(e)||oE(e)?this.layoutMap.get(e.group.id):this.$_layout}$groupMemberAdded(e){this.$_processGroupAddition(e,!1)||(this.$unprocessedGroupMemberships.has(e.group.id)||this.$unprocessedGroupMemberships.set(e.group.id,[]),this.$unprocessedGroupMemberships.get(e.group.id).push(e))}$_processGroupAddition(e,t){let n=this.$getManagedElement(e.vertex.id),o=this.viewport.getGroupElement(e.group.id);if(o!=null&&n!=null){this.$appendElement(n.el,o.contentArea);let s=this.$_getGroupContentAreaInfo(e.group.id),a=e.positionInGroup?e.positionInGroup.x:n.x-o.x,l=e.positionInGroup?e.positionInGroup.y:n.y-o.y;return this.$_updateVertexPositions({positions:{[n.id]:{x:a,y:l}},sizes:null,offset:{x:o.x+s.internalOffset.x,y:o.y+s.internalOffset.y},storePositionsInModel:!0,repaintConnections:!0,resizedGroups:null,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1}),e.source!=this&&this.relayoutGroup(e.group.id,oS),this.le(h=>{h.$groupMemberAdded(n)}),t||setTimeout(()=>this.$revalidateElement(n.el)),!0}else return!1}$groupMemberRemoved(e){let t=this.$getManagedElement(e.vertex.id),n=this.viewport.getGroupElement(e.group.id),o=this.$_getGroupContentAreaInfo(e.group.id);this.$appendElementToVertexLayer(t.el),this.$_updateVertexPositions({positions:{[t.id]:{x:t.x-n.x-o.internalOffset.x,y:t.y-n.y-o.internalOffset.y}},sizes:null,offset:null,storePositionsInModel:!0,repaintConnections:!0,resizedGroups:null,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1}),this.le(s=>{s.$groupMemberRemoved(t)})}$nodeRemoved(e){let t=this.$getManagedElement(e.node.id);return t&&(e.node.getPorts().map(o=>this.$getManagedElement(o.getFullId())).filter(o=>o!=null).forEach(o=>this.$__unmanage(o.el,!1,!0)),this.vertexList=this.vertexList.filter(o=>o.id!==e.node.id),this.$__unmanage(t.el,!1,!0),this.le(o=>{o.$nodeRemoved(t)}),this.IE(t)),t}$portRemoved(e){let t=this.$getManagedElement(e.port.getFullId());if(t){let n=this.$getManagedElement(e.port.getParent().id);n.el!==t.el?this.$__unmanage(t.el,!1,!1):(this.$removeAttribute(n.el,Kl),this.$removeAttribute(n.el,Hr))}}$edgeTypeChanged(e,t,n){let o=this.$_connMap[e.getId()];if(o){let s=this.view.getEdgeDefinition(n);if(s&&s.ignore===!0)return;s.connector&&Wt.Ud(o,s.connector),we.setType(o,n,e.data)}}$groupTypeChanged(e,t,n){}$nodeTypeChanged(e,t,n){this.$reRenderNode(e)}$portTypeChanged(e,t,n){}$vertexRendered(e,t,n,o){if(!t)throw new Error("Cannot render vertex");let s=K(e),a=Y(e);this.$setAttribute(t,ee,e.getFullId());let l=s?Hi:a?Ho:H(e)?ev:"";this.$addClassToElement(t,l),t.jtk=t.jtk||{},t.jtk[e.objectType.toLowerCase()]=e,t.jtk.vertex=e;let h=this.getElement(e.id),d=h!=null;if(d&&(this.$setAttribute(t,Pt,this.$getAttribute(h.el,Pt)),h.el=t,this.model.getSelection().containsVertex(e.id)&&this.$addClassToElement(t,ki)),K(e)||Y(e))if(this.vertexList.push(e),e.group==null)this.$appendVertexElement(t);else{let g=this.eu(e.group);this.$appendElement(t,g)}let u=null,p=e.data[this.$modelRotationAttribute];this.$_useModelForSizes?(u=this.$resolveVertexSizeFromModel(e,n),this.$_writeSizeToElements!==!1&&this.$setElementSizeInUI(t,u.width,u.height),e.data[this.$modelWidthAttribute]=u.width,e.data[this.$modelHeightAttribute]=u.height):u=this.$getSize(t);let m=this.$manage(t,e,null,u,null,!1);if(p!=null&&this.Qd(e,p,!this.$_dataLoading,!1),K(e)){if(!d){let g={el:t,id:e.id,vertex:e,size:u};this.fire(Br,g)}}else if(Y(e)){let g={el:t,vertex:e,id:e.id,size:u},E=m,y=n;E.contentArea=this.$getGroupContentAreaElement(t),E.elastic=y.elastic===!0;let x=y.layout||{type:So.type};this.layoutMap.set(e.id,this.tu(x,e)),this.fire($r,g),this.$unprocessedGroupMemberships.has(e.id)&&(this.$unprocessedGroupMemberships.get(e.id).forEach(b=>this.$_processGroupAddition(b,!0)),this.$unprocessedGroupMemberships.delete(e.id))}if(this.$unrenderedVertices.delete(e.id),this.$_dataLoading&&this.$isAsynchronousRender())this.$dataLoadEnd(!1);else if(!this.$_dataLoading){d&&this.le(y=>{y.$vertexRerendered({el:t,id:e.id,vertex:e,size:u})});let g=V(),E=this.$flushUnrenderedEdges(null);this.$unrenderedVertices.size===0&&this.refresh(),E.forEach(y=>{this.viewport.$refreshElement(y.source.getFullId()),this.viewport.$refreshElement(y.target.getFullId()),this.router.$redrawConnection(y,g)})}}ls(e,t,n){let o=this.$_connMap[e.id];o&&Wt.setVisible(o,t)}isVisible(e){return this.ru(e,t=>{switch(t.type){case Fe.objectType:let n=this.$_connMap[t.obj.id];return n?n.visible:!1;case de.objectType:case le.objectType:return t.managedElement.visible!==!1}})}setVisible(e,t,n){if(e==null)return;let o=s=>{switch(s.type){case Fe.objectType:this.ls(s.obj,t,n);break;case de.objectType:case le.objectType:this.ME(s,t,n);break;case me.objectType:U("WARN togglePort method not implemented in 7.x");break}};this.ru(e,o)}ME(e,t,n){if(e.el&&(this.$setElementVisible(e.el,t),e.el.$b=t,e.managedElement.visible=t,this.fire(Jd,{node:e.obj,el:e.el,state:t}),!n)){let o=this.dataSource.getAllEdgesFor(e.obj);for(let s=0;s<o.length;s++)if(!t)this.ls(o[s],t,n);else{let a=Zn(o[s].source),l=Zn(o[s].target),h=a===e.obj?l:a;this.isVisible(h)&&this.ls(o[s],t,n)}}}ru(e,t){let n;if(gS(e))n={nodes:[],edges:[]},e.eachVertex((o,s)=>{n.nodes.push(t(this.getObjectInfo(s,!1)))}),e.eachEdge((o,s)=>{n.edges.push(t(this.getObjectInfo(s,!1)))});else if(this.$isArrayLike(e)){n=[];for(let o=0;o<e.length;o++)n.push(t(this.getObjectInfo(e[o],!1)))}else n=t(this.getObjectInfo(e,!1));return n}$resolveVertexSizeFromModel(e,t){let n=this.$_getModelSizeForVertex(e);return n!=null?n:this.$_getDefaultSizeForVertex(e,t)}$_getDefaultSizeForVertex(e,t){let n=K(e)?this.defaults.nodeSize||{width:100,height:80}:this.defaults.groupSize||{width:300,height:300};return t.defaultSize&&(n.width=t.defaultSize.width,n.height=t.defaultSize.height),n}$_getModelSizeForVertex(e){let t=e.data[this.$modelWidthAttribute],n=e.data[this.$modelHeightAttribute];if(t!=null&&n!=null)return{width:e.data[this.$modelWidthAttribute],height:e.data[this.$modelHeightAttribute]}}getContainer(){return this.me}setZoom(e,t){return this.j=e,e}F(e){if(e==null)return null;let t=this.$getAttribute(e,Pt);return(!t||t==="undefined")&&(t=`vjs-${V()}`,this.$setAttribute(e,Pt,t)),t}setContainer(e){this.me=e}nu(e,t,n,o){let s=n===0?e.sourceId:e.targetId;if(o){let l=n===0?e.anchors.source:e.anchors.target;l.isFixed=!1,delete l.fixedLocation}let a={index:n,originalSourceId:n===0?s:e.sourceId,newSourceId:e.sourceId,originalTargetId:n===1?s:e.targetId,newTargetId:e.targetId,connection:e};return n===0?(a.newSourceId=t.id,e.sourceId=t.id,e.sourceElement=t.el):(a.newTargetId=t.id,e.targetId=t.id,e.targetElement=t.el),a}RE(e,t,n){bp(e,this.getElement(e.sourceId)),this.$revalidateManagedElement(this.getElement(e.sourceId));let o=this.nu(e,t,0,n);xp(e,this.getElement(o.newSourceId),this.getElement(e.targetId)),this.$revalidateManagedElement(this.getElement(o.newSourceId))}_E(e,t,n){bp(e,this.getElement(e.targetId)),this.$revalidateManagedElement(this.getElement(e.targetId));let o=this.nu(e,t,1,n);xp(e,this.getElement(e.sourceId),this.getElement(o.newTargetId)),this.$revalidateManagedElement(this.getElement(o.newTargetId))}$_setConnectionType(e,t,n){let o=we.setType(e,t,n);return this.$paintConnection(e),o}$_setSuspendDrawing(e,t){let n=this.pt;return this.pt=e,e?this.jd=""+new Date().getTime():this.jd=null,this.pt||(this.autoSizeGroups(Array.from(this.za.keys()).map(o=>o.modelObject)),this.za.clear(),t&&this.repaintEverything()),n}$batch(e,t){let n=this.pt===!0;n||this.$_setSuspendDrawing(!0),e(),n||this.$_setSuspendDrawing(!1,!t)}An(e){let t=e.elId;return e.recalc?this.viewport.$refreshElement(t,!1,e.pos,e.size):this.viewport.getPosition(t)}VE(e,t){return this.dataSource.beforeDetach(e.edge.source,e.edge.target,e.edge)}ka(e,t){return e!=null&&e.deleted!==!0&&(t=t||{},t.force||this.VE(e)===!0)?(bp(e,this.getElement(e.sourceId),this.getElement(e.targetId)),this.router.$connectionRemoved({connection:e,reason:bl,edge:e.edge}),delete this.$_connMap[e.id],Wt.destroy(e),!0):!1}$manage(e,t,n,o,s,a){let l=t.getFullId();this.$getAttribute(e,Pt)==null&&this.$setAttribute(e,Pt,l);let h=this.getElement(l);return h==null?(h=this.viewport.addElement(l,e,t,n,o,s),this.pt||this.An({elId:l,recalc:!0,pos:n,size:o,rotation:s})):a&&this.An({elId:l,timestamp:null,recalc:!0}),h}$getManagedElement(e){return this.viewport.getElement(e)}$__unmanage(e,t,n){let o=s=>{let a=this.F(s),l=this.getElement(a);this.router.elementRemoved(l),this.viewport.remove(a),this.$removeAttribute(s,Pt),s&&n&&this.$removeElement(s)};t&&this.$getAssociatedElements(e).map(o),o(e)}rotate(e,t){this.getObjectInfo(e,!1).obj&&this.model.$_updateVertex(e,{[this.$modelRotationAttribute]:t},Zs,!1)}setSize(e,t,n){this.getObjectInfo(e,!1).obj&&this.model.transaction(()=>{this.model.$_updateVertex(e,{[this.$modelWidthAttribute]:t,[this.$modelHeightAttribute]:n},uS,!1)},St)}Qd(e,t,n,o){let s=z(e)?e:e.id;if(this.getElement(s)){this.viewport.yE(s,t);let a=this.getElement(s);if(this.$syncManagedElementWithView(a,!1),this.le(l=>{l.$vertexRotated(a,t)}),n!==!0)return this.$revalidateElementById(s)}}$getRotation(e){let t=this.getElement(e);return t!=null&&t.r||0}$getRotations(e){let t=[],n=this.getElement(e),o=s=>{if((K(s.modelObject)||Y(s.modelObject))&&s.modelObject.group){let a=this.getElement(s.modelObject.group.id);a!=null&&(t.push({r:a.r,c:a.c}),o(a))}};return n!=null&&(t.push({r:n.r||0,c:n.c}),o(n)),t}$revalidateElement(e,t){let n=this.F(e);return this.$revalidateElementById(n)}$revalidateElementById(e,t){return this.$revalidateManagedElement(this.getElement(e),t)}$revalidateManagedElement(e,t){return e!=null?(this.An({elId:e.id,recalc:!0,timestamp:t}),this.$repaintUIElement(e)):ip()}repaintEverything(e){let t=V();e!==!0&&this.viewport.$refreshEveryElement(),this.viewport.recomputeBounds(),this.viewport.$forEachElement(n=>this.$repaintUIElement(n,t,!0))}repaint(e,t){let n=this.getObjectInfo(e,!1);n!=null&&(t&&this.$setViewportElementPosition(n.managedElement,n.managedElement),this.$repaintUIElement(n.managedElement))}$repaintUIElement(e,t,n){let o=ip(),s=a=>{a.c.forEach(l=>o.c.add(l))};if(!this.pt&&e!=null){let a=this.$getAssociatedElements(e.el).map(l=>this.getElement(this.F(l))).filter(l=>l!=null);if(t==null&&(t=V()),!n)for(let l=0;l<a.length;l++)this.An({elId:a[l].id,recalc:!0,timestamp:t});if(s(this.router.$redraw(e,t,null)),a.length>0)for(let l=0;l<a.length;l++)s(this.router.$redraw(a[l],t,null))}return o}reset(){this.$_connMap={},this.vertexList.length=0,this.viewport.reset(),this.router.reset(),this.wt.length=0,this.$unrenderedVertices.clear(),this.za.clear()}getRenderedConnection(e){return this.$_connMap[e]}getNodes(){return this.vertexList.filter(K)}getGroups(){return this.vertexList.filter(Y)}getUIGroups(){return this.getGroups().map(e=>this.viewport.getGroupElement(e.id))}destroy(){for(let e=0;e<this.Fa.length;e++)this.off(this.me,this.Fa[e][0],this.Fa[e][1]);this.reset(),this.unbind(),this.Ua.clear()}$registerConnectionType(e,t){let n=Object.assign({},t);if(this.Ua.set(e,n),t.overlays){let o={};for(let s=0;s<t.overlays.length;s++){let a=hi(t.overlays[s]);o[a.options.id]=a}n.overlays=o}if(t.sourceMarker){let o=hi(t.sourceMarker);o.options.direction=-1,o.options.location=0,o.sourceMarker=!0,n.sourceMarker=o}if(t.targetMarker){let o=hi(t.targetMarker);o.options.direction=1,o.options.location=1,o.targetMarker=!0,n.targetMarker=o}}$getConnectionType(e){return this.Ua.get(e)}$sourceOrTargetChanged(e,t,n,o,s){let a,l,h,d;e!==t&&(s===Qe?(n.sourceId=t,n.sourceElement=o,h=this.getElement(e),a=this.getElement(t),l=this.getElement(n.targetId),d=l):s===An&&(n.targetId=t,n.targetElement=o,l=this.getElement(t),d=this.getElement(e),a=this.getElement(n.sourceId),h=a),bp(n,h,d),xp(n,a,l))}Ha(e,t,n,o){n=n||{},o=o||{},t=t||{};let s={},a=yn(e);a.unshift(e),a.forEach(l=>{let h=this.viewport.getGroupElement(l.id),d=o[l.id]||this.viewport.$computeGroupContentExtents(l,!1,t,n,null),u=this.Wa(l,t,n,d,!1);if(u!=null&&(s[l.id]=u,n[l.id]=u.size,t[l.id]=u.position,(u.originalSize.width!==u.size.width||u.originalSize.height!==u.size.height)&&(this.$trackGroupSizeChanges({[l.id]:{element:h,originalGroupSize:u.originalSize,newGroupSize:u.size}}),l.group==null))){let p=u.size.width-u.originalSize.width,m=u.size.height-u.originalSize.height;if(this.magnetizerProfile.afterGroupShrink&&(p<0||m<0)){let g=this.$provisionallyGather(l,t,n,!1,!1);this.$_updateVertexPositions({positions:g.current,storePositionsInModel:!0,sizes:null,resizedGroups:null,offset:null,repaintConnections:!0,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1})}else if(this.magnetizerProfile.afterGroupGrow){let g=this.$provisionallyMagnetize(l,!1,t,n,!1,!1);this.$_updateVertexPositions({positions:g.current,storePositionsInModel:!0,sizes:null,resizedGroups:null,offset:null,repaintConnections:!0,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1})}}})}expandGroup(e){this.model.$transaction(()=>{let t=z(e)?this.dataSource.getGroup(e):e,n=this.viewport.getGroupElement(t.id);if(n!=null){let o=this.Xa?this.Xa(t,n.lastExpandedSize):null;if(o===!1)return;let s=n.el;if(this.iu(n)==null){n.collapsed=!1,this.$updateElementClasses(s,[gf],[mf]);let l=new Set,h=new Set,d=new Set;this.ou(n,l,h,d,!0),d.forEach(p=>this.$setConnectionVisible(this.$_connMap[p.id],!0)),l.forEach(p=>this.$_unproxyEdge(p.edge,p.index));let u={};if(this.$_useModelForSizes&&n.lastExpandedSize!=null&&(u[t.id]=n.lastExpandedSize,this.model.updateGroup(t,n.lastExpandedSize)),o!=null){let p=o;for(let m in p)this.model.updateVertex(m,p[m])}this.Ha(t,null,u,null),this.magnetizerProfile.afterGroupExpand===!0&&this.magnetize(n.modelObject),this.$revalidateManagedElement(n),this.le(p=>{p.$groupExpanded(n)}),this.fire(Wd,{group:t})}}},St,!0)}$_proxyEdge(e,t,n,o){tC(this,e,t,n,o)}$_unproxyEdge(e,t,n){return eC(this,e,t,n)}ou(e,t,n,o,s){let a=e.modelObject.members.map(d=>d.id),l=aE(e.modelObject,!0,!0);this.An({elId:e.id,recalc:!0}),a.forEach(d=>{this.An({elId:d,recalc:!0})});let h=ml(l,d=>!(a.indexOf(d.source.id)!==-1&&a.indexOf(d.target.id)!==-1));h.left.forEach(d=>{t.add({edge:d,index:a.indexOf(d.source.id)===-1?An:Qe})}),h.right.forEach(d=>{o.add(d)}),this.su(e).forEach(d=>{this.ou(d,t,n,o,!1)})}toggleGroup(e){let t=this.viewport.getGroupElement(z(e)?e:e.id);t!=null&&(t.collapsed?this.expandGroup(e):this.collapseGroup(e))}iu(e){let t=null;if(e.modelObject.group==null)return null;{let n=e.modelObject.group;for(;n!=null;){let o=this.$getManagedElement(n.id);o.collapsed&&(t=o),n=o.modelObject.group}return t}}collapseGroup(e){this.model.$transaction(()=>{let t=z(e)?this.dataSource.getGroup(e):e,n=this.viewport.getGroupElement(t.id);if(n!=null){let o={width:n.width,height:n.height},s=this.Ya==null?null:this.Ya(t,o);if(s===!1)return;let a=n.el;if(n.lastExpandedSize=o,this.iu(n)==null){n.collapsed=!0,this.$updateElementClasses(a,[mf],[gf]);let h=new Set,d=new Set;this.au(n,h,d),d.forEach(p=>this.$setConnectionVisible(this.$_connMap[p.id],!1)),h.forEach(p=>this.$_proxyEdge(p.edge,p.index,n));let u={};if(this.$_useModelForSizes){let p=this.$getCollapsedGroupSize(t,{width:n.width,height:n.height});u[t.id]=p,this.model.updateGroup(t,p)}if(s!=null){let p=s;for(let m in p)this.model.updateVertex(m,p[m])}this.Ha(t,null,u,null),this.$revalidateManagedElement(n),this.magnetizerProfile.afterGroupCollapse===!0&&this.gather(n.modelObject),this.le(p=>{p.$groupCollapsed(n)}),this.fire(kd,{group:t})}}},St,!0)}$computeCollapsedGroupSize(e,t){return this.$collapsedGroupSizeCalculator!=null?this.$collapsedGroupSizeCalculator(e,t):null}$getCollapsedGroupSize(e,t){try{let o=this.$computeCollapsedGroupSize(e,t);if(o!=null)return o}catch(o){U("ERROR: user function getGroupCollapsedSize threw error",o)}let n=this.getGroupDefinition(e);return n&&n.collapsedSize?n.collapsedSize:this.Zd}su(e){return e.modelObject.members.filter(t=>t.objectType===le.objectType).map(t=>this.viewport.getGroupElement(t.id))}au(e,t,n){let o=e.modelObject.members.map(a=>a.id),s=aE(e.modelObject,!0,!0);if(e.proxied!==!1){let a=ml(s,l=>!(o.indexOf(l.source.id)!==-1&&o.indexOf(l.target.id)!==-1));a.left.forEach(l=>{t.add({edge:l,index:o.indexOf(l.source.id)===-1?An:Qe})}),a.right.forEach(l=>{n.add(l)})}else s.forEach(a=>n.add(a));this.su(e).forEach(a=>{this.au(a,t,n)})}GE(){return this.lu(this.dataSource.getGroups().filter(this.objectFilter))}lu(e){let t=[];return e.forEach(n=>{let o=yn(n);t.push({group:n,depth:o.length})}),t.sort((n,o)=>n.depth===o.depth?0:n.depth>o.depth?-1:1),t}relayoutGroup(e,t){let n=Y(e)?e:this.dataSource.getGroup(e),o=this.layoutMap.get(n.id);if(o==null)return;let s=this.getElement(n.id),a=s;o.relayout(null,h=>{this.$_updateVertexPositions({positions:h.positions,sizes:h.sizes,resizedGroups:null,offset:{x:a.x,y:a.y},storePositionsInModel:!0,repaintConnections:!1,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1}),this.fire(Nl,{element:s,positions:h.positions,sizes:h.sizes,extents:h.bounds})});let l=!0;this.$_dataLoading&&this.$_useModelForSizes&&(l=!1),t===iS&&(l=!1),l&&this.autoSizeGroup(n),this.$revalidateManagedElement(s)}$_updateVertexPositions(e){let t=e.offset||{x:0,y:0},n=new Set,o=ip();for(let s in e.positions){let a=e.positions[s],l=e.sizes!=null?e.sizes[s].width:null,h=e.sizes!=null?e.sizes[s].height:null,d=this.viewport.updateElement(s,a.x+t.x,a.y+t.y,l,h,null,null,!1);e.writeSizesToElements&&l!=null&&h!=null&&this.$setElementSizeInUI(this.getElement(s).el,l,h),n.add(this.getElement(s)),this.$setViewportElementPosition(d,a),e.storePositionsInModel&&this.$storePositionInModel({id:s,pos:a})}if(e.resizedGroups!=null)for(let s in e.resizedGroups){let a=e.resizedGroups[s].newGroupSize;this.viewport.updateElement(s,null,null,a.width,a.height,null,e.resizedGroups[s].group,!1),n.add(this.getElement(s)),this.$_useModelForSizes&&this.$E(s,a)}if(e.rotations!=null)for(let s in e.rotations){let a=this.getElement(s);this.viewport.updateElement(s,null,null,null,null,e.rotations[s],null,!1),n.add(a),e.writeRotationsToElements&&this.$setElementRotation(a.el,e.rotations[s])}return e.repaintConnections&&n.forEach(s=>{this.$repaintUIElement(s).c.forEach(l=>o.c.add(l))}),o}relayout(e,t){this.cu(n=>{this.$_layout.relayout(e,n)},n=>{this.$afterRelayout(n)},Cn,t)}refresh(e){this.cu(t=>{this.$_layout.layout(t)},t=>{this.$afterRefresh(t)},Hs,e)}cu(e,t,n,o){if(!this.pt){let s={};e(a=>{let l=a.positions;if(this.magnetizerProfile.afterLayout){let p=[];for(let g in l)p.push(this.dataSource.getVertex(g));this.magnetizer.setElements(p);let m=this.magnetizer.executeAtCenter({getPosition:g=>l[g.id],getSize:g=>a.sizes[g.id]});for(let g in m.current)l[g]=m.current[g]}let h=this.BE(),d=h.orderedGroups.length>0&&!(this.$_dataLoading&&this.$_useModelForSizes),u={};if(d){let p=(g,E)=>h.info[g].positions[E]||this.getElementPosition(E),m=(g,E)=>a.sizes[E]||h.info[g].sizes[E]||this.getElementSize(E);h.orderedGroups.forEach(g=>{let E=Pi();g.group.members.forEach(x=>{let f=p(g.group.id,x.id),b=m(g.group.id,x.id);E.xmin=Math.min(E.xmin,f.x),E.ymin=Math.min(E.ymin,f.y),E.xmax=Math.max(E.xmax,f.x+b.width),E.ymax=Math.max(E.ymax,f.y+b.height)});let y=this.Wa(g.group,l,a.sizes,E,!1);if(y!=null&&(s[g.group.id]={group:g.group,newGroupSize:y.size,originalGroupSize:y.originalSize},l[g.group.id]!=null&&(l[g.group.id]=y.position),u[g.group.id]=this.$_getGroupContentAreaInfo(g.group.id),a.sizes[g.group.id]=y.size,y.layoutShiftX!==0||y.layoutShiftY!==0)){let x=h.info[g.group.id].positions;for(let f in x)x[f].x+=y.layoutShiftX,x[f].y+=y.layoutShiftY}})}this.$_updateVertexPositions({positions:l,sizes:a.sizes,resizedGroups:s,offset:null,repaintConnections:!1,storePositionsInModel:!0,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1}),h.orderedGroups.reverse().forEach(p=>{let m=p.group.id,g=h.info[m],E=l[m]||nr(g.element),y=u[m]||this.$_getGroupContentAreaInfo(m);y&&(E.x+=y.internalOffset.x,E.y+=y.internalOffset.y),this.$_updateVertexPositions({positions:g.positions,sizes:g.sizes,resizedGroups:s,offset:E,repaintConnections:!1,storePositionsInModel:!0,writeSizesToElements:!1,rotations:null,writeRotationsToElements:!1})}),o!==!0&&this.repaintEverything(!0),t({bounds:a.bounds,positions:a.positions,sizes:a.sizes,layout:a.layout}),this.fire(n,{positions:a.positions,sizes:a.sizes,layout:a.layout});for(let p in h.info)this.fire(Nl,h.info[p])})}}repaintEdge(e){let t=this.getRenderedConnection(e.id);this.$paintConnection(t)}repaintEdges(e){let t=V();e.forEach(n=>{let o=this.getRenderedConnection(n.id);this.$paintConnection(o,{timestamp:t})})}$paintConnection(e,t){if(!this.pt&&e.visible!==!1){t=t||{};let n=t.timestamp;if(n!=null&&n===e.lastPaintedAt)return;if(n==null||n!==e.lastPaintedAt){this.router.computePath(e,n);let o=e.sourceMarker;if(o!=null&&o.visible){let a=this.$drawOverlay(o,e.connector,e.paintStyleInUse);e.overlayPlacements[o.id]=a,e.connector.internalSegments.length>0&&(e.connector.internalSegments[0].x1=a.tail.x,e.connector.internalSegments[0].y1=a.tail.y)}let s=e.targetMarker;if(s!=null&&s.visible){let a=this.$drawOverlay(s,e.connector,e.paintStyleInUse);e.overlayPlacements[s.id]=a;let l=e.connector.internalSegments.length-1;e.connector.internalSegments.length>0&&(e.connector.internalSegments[l].x2=a.tail.x,e.connector.internalSegments[l].y2=a.tail.y)}for(let a in e.overlays)if(e.overlays.hasOwnProperty(a)){let l=e.overlays[a];l!==o&&l!==s&&l.visible&&(e.overlayPlacements[a]=this.$drawOverlay(l,e.connector,e.paintStyleInUse,Wt.getAbsoluteOverlayPosition(e,l)))}this.$paintConnector(e,e.paintStyleInUse);for(let a in e.overlays)if(e.overlays.hasOwnProperty(a)){let l=e.overlays[a];l.visible&&this.$paintOverlay(l,e.overlayPlacements[a],e.connector)}}e.lastPaintedAt=n}}$addOverlay(e,t,n){let o=oh(e,t);return o!=null&&(o.ignoreTypes=!0,n||this.$revalidateElementById(e.sourceId)),o}$removeOverlay(e,t){Ji(e,t),this.$revalidateElementById(e.sourceId)}$_setLineStyle(e,t,n){t.hasOwnProperty("lineWidth")&&(e.paintStyle.strokeWidth=t.lineWidth,e.hoverPaintStyle.strokeWidth=t.lineWidth),t.hasOwnProperty("outlineWidth")&&(e.paintStyle.outlineWidth=t.outlineWidth,e.hoverPaintStyle.outlineWidth=t.outlineWidth),t.hasOwnProperty("color")&&(e.paintStyle.stroke=t.color),t.hasOwnProperty("outlineColor")&&(e.paintStyle.outlineStroke=t.outlineColor),t.hasOwnProperty("dashArray")&&(e.paintStyle.dashArray=t.dashArray),dp(e),n&&this.$paintConnection(e)}$setView(e){this.view=new np(this.dataSource,this.dataSource.getModel(),e,this)}findIntersectingVertices(e){if(e.dontIncludeNodes===!0&&e.dontIncludeGroups===!0&&e.dontIncludeNodesInsideGroups===!0)return[];let t={x:e.origin.x,y:e.origin.y,width:e.dimensions.width,height:e.dimensions.height};return(e.enclosed?this.viewport.findVerticesEnclosedByRect(t,0,!1,[],!1):this.viewport.findVerticesIntersectingWithRect(t,0,!1,[],!1)).filter(s=>{let a=K(s.modelObject),l=a&&iE(s.modelObject),h=Y(s.modelObject),d=h&&oE(s.modelObject),u=e.dontIncludeNodes===!0&&a,p=e.dontIncludeGroups===!0&&h,m=e.dontIncludeNodesInsideGroups&&l,g=e.dontIncludeNestedGroups&&d;return!(u||p||m||g)}).map(s=>({enclosed:e.enclosed,id:s.id,r:s,v:s.modelObject,el:s.el}))}findEnclosedVertices(e){return this.findIntersectingVertices(Object.assign(e,{enclosed:!0}))}eu(e){let t=this.viewport.getGroupElement(e.id);return t==null?null:this.$getGroupContentAreaElement(t.el)}$_getGroupContentAreaInfo(e){let t=this.viewport.getGroupElement(e);if(t==null)return{pageOrigin:{x:0,y:0},internalOffset:{x:0,y:0},contentArea:null,isGroupElement:!0};{let n=this.$getGroupContentAreaElement(t.el);if(n!==t.el){let o=this.$getElementPositionInUIRelativeToParent(n);return{pageOrigin:{x:t.x+o.x,y:t.y+o.y},internalOffset:{x:o.x,y:o.y},contentArea:n,isGroupElement:!1}}else return{pageOrigin:{x:t.x,y:t.y},internalOffset:{x:0,y:0},contentArea:t.el,isGroupElement:!0}}}getElementPosition(e){return this.viewport.getElementPosition(e)}getElementSize(e){return this.viewport.getElementSize(e)}getElement(e){return this.viewport.getElement(e)}getGroupElement(e){return this.viewport.getGroupElement(e)}getObjectInfo(e,t){if(e==null)return{id:null,obj:null,el:null,type:null,managedElement:null};if(Wo(e)){let n=e.edge;return{obj:n,id:n.id,type:Fe.objectType,el:e.connector.canvas,managedElement:null}}else if(this.$isElement(e)){let n=this.getModelObjectFromElement(e,!0,t);if(n!=null){let o=this.dataSource.resolveFullId(n.obj);return{el:n.el,obj:n.obj,type:n.obj.objectType,id:o,managedElement:this.getElement(o)}}else{let o=this.F(e);return{id:o,obj:null,el:e,type:null,uiOnly:!0,managedElement:this.getElement(o)}}}else{let n=this.dataSource.getObjectInfo(e);return n.obj!=null?n.type===Fe.objectType?Object.assign({el:this.getRenderedConnection(n.id).connector.canvas,managedElement:null},n):Object.assign({el:this.getRenderedElement(n.obj),managedElement:this.getElement(n.obj.getFullId())},n):Object.assign({el:null,managedElement:null},n)}}Za(){let e=this.dataSource.getNodes().filter(t=>t.group==null);return e.push(...this.dataSource.getGroups().filter(t=>t.group==null)),e}FE(e,t,n,o,s,a,l,h,d,u){let p={invertTrackbackPreference:u};if(t&&(p.origin=t),n&&(p.gather=n),!h&&!d&&this.magnetizer.setElements(a),e){let g=this.getObjectInfo(e,!1);if(g.obj)if(!l)p.focus=g.obj.id;else{let E=this.getElement(g.obj.id);p.origin={x:E.x+E.width/2,y:E.y+E.height/2},p.filter=y=>y===g.obj.id}}o&&(p.knownLocations=o),s&&(p.knownSizes=s);let m=this.getGrid();return m&&(p.grid=m),p}cs(e,t,n,o,s,a,l,h,d,u){a==null&&(a=h?[]:this.Za());let p=this.FE(e,t,n,o,s,a,l,h,d,u);return p.focus!=null?this.magnetizer.executeWithFocus(p.focus,p):t!=null?this.magnetizer.executeAtPoint(t,p):this.magnetizer.executeAtCenter(p)}as(e,t,n,o,s,a,l,h,d){let u=this.cs(e,t,n,o,s,null,a,l,h,d);this.hs(u,cS)}magnetize(e,t){this.as(e,null,!1,null,null,t,!1,!1,!1)}$provisionallyMagnetize(e,t,n,o,s,a){return this.cs(e,null,!1,n,o,null,t,!1,s,a)}$provisionallyGather(e,t,n,o,s){return this.cs(e,null,!0,t,n,null,!1,!1,o,s)}magnetizeAtPoint(e){this.as(null,e,!1,null,null,null,!1,!1,!1)}gather(e){this.as(e,null,!0,null,null,null,!1,!1,!1)}$startMagnetizer(){this.magnetizer.startTracking(this.Za(),this.magnetizerProfile.trackback,this.magnetizerProfile.trackbackThreshold)}$stopMagnetizer(){this.magnetizer.stopTracking()}$startMotion(){this.$isInMotion=!0}$stopMotion(){this.$isInMotion=!1}hu(e){return{[this.$modelLeftAttribute]:e.x,[this.$modelTopAttribute]:e.y}}UE(e,t){let n=this.hu(t);this.model.updateVertex(e,n)}hs(e,t,n){this.model.openTransaction(St);try{for(let o in e.current){let s=this.hu(e.current[o]);this.model.$_updateVertex(o,s,t,!1)}n&&n()}catch(o){U("Exception thrown when setting position",o)}finally{this.model.commitTransaction()}}$storePositionInModel(e){let t=typeof e=="string"?e:e.id,n=typeof e=="string"?null:e.pos,o=this.getModelPositionAttributes(),s=typeof e=="string"?o.x:e.leftAttribute||o.x,a=typeof e=="string"?o.y:e.topAttribute||o.y,l=e.obj||this.dataSource.getVertex(t);return l&&(n==null&&(n=this.getElementPosition(l.id)),Oe(l.data,s,n.x),Oe(l.data,a,n.y)),n}$E(e,t){let n=z(e)?this.dataSource.getVertex(e):e;n&&(t==null&&(t=this.getElementSize(n.id)),Oe(n.data,this.$modelWidthAttribute,t.width),Oe(n.data,this.$modelHeightAttribute,t.height))}setMagnetizedPosition(e,t,n){this.setPosition(e,t,n,!0)}setPosition(e,t,n,o,s){let a=this.getObjectInfo(e,!1);if(a.obj)if(a.obj.group==null){let l=this.zE(a.obj,t,n,o,s===!1,!1,!1,!1);this.hs(l,ou)}else{let l=a.obj.group,h=this.viewport.getGroupElement(l.id);if(h!=null){let d={[a.id]:{x:t+h.x,y:n+h.y}},u={[a.id]:{x:t,y:n}},p=this.viewport.$computeGroupContentExtents(l,!1,d,null,null);this.hs({original:{},current:u},ou,()=>{this.Ha(l,u,null,{[l.id]:p})})}}}adHocGroupLayout(e,t){if(t){let n=this.dataSource.getObjectInfo(e);if(n.obj){let o=this.layoutMap.get(n.id);this.layoutMap.set(n.id,this.tu(t,n.obj)),this.relayoutGroup(n.obj,nS),this.layoutMap.set(n.id,o)}}}getGroupDefinition(e){return this.view.getGroupDefinition(this.model.getNodeType(e.data))}getPortDefinition(e){return this.view.getPortDefinition(this.model.getPortType(e.data))}getNodeDefinition(e){return this.view.getNodeDefinition(this.model.getNodeType(e.data))}zE(e,t,n,o,s,a,l,h){let d={x:t,y:n};if(o){let u=this.cs(e,{x:t,y:n},!1,{[e.id]:{x:t,y:n}},null,null,s,a,l,h);return u.original[e.id]={x:t,y:n},u.current[e.id]={x:t,y:n},u}else return this.YE()&&(d=se(d,this.getGrid())),{original:{[e.id]:d},current:{[e.id]:d}}}getModelPositionAttributes(){return{x:this.$modelLeftAttribute,y:this.$modelTopAttribute}}storePositionsInModel(e){e=e||{};let t=this.getModelPositionAttributes(),n=e.leftAttribute||t.x,o=e.topAttribute||t.y,s=(a,l)=>{let h=this.getElement(l.id);Oe(l.data,n,h.x),Oe(l.data,o,h.y)};this.dataSource.eachNode((a,l)=>s(a,l)),this.dataSource.eachGroup((a,l)=>s(a,l))}setGrid(e){this.gridProfile==null?this.gridProfile=new ah({size:e}):this.gridProfile.grid=e}getGrid(){return this.gridProfile==null?null:this.gridProfile.grid}YE(){return this.gridProfile!=null&&this.gridProfile.snap}Bb(e){if(this.gridProfile!=null){let t=this.$getSize(e),n=se({x:t.width,y:t.height},this.gridProfile.grid);return this.$setElementSizeInUI(e,n.x,n.y),{width:n.x,height:n.y}}return null}snapToGrid(e,t){t=t||this.getGrid();let n;if(t){e!=null&&(n=this.getObjectInfo(e,!1).obj),n!=null?this.magnetizer.setElements([n]):this.magnetizer.setElements(this.Za());let o=this.magnetizer.snapToGrid(t);return this.hs(o,dS),o}}autoSizeGroup(e,t){let n=new Set;return n.add(e),this.$_sizeGroupsToFit(n,null,null,t)[e.id]}$_sizeGroupsToFit(e,t,n,o){let s=this.lu(Array.from(e));t=t||{},n=n||{};let a={};return s.forEach(l=>{if(a[l.group.id]==null){let h=this.XE(l.group,o,t,n);Object.assign(a,h)}}),this.$trackGroupSizeChanges(a),a}XE(e,t,n,o){let s={};n=n||{},o=o||{};let a=l=>{let h=this.viewport.getGroupElement(l.id),d=this.viewport.$computeGroupContentExtents(l,!1,null,o,null),u=this.Wa(l,n,o,d,t);u!=null&&(o[l.id]=u.size,s[l.id]={element:h,newGroupSize:u.size,originalGroupSize:u.originalSize},l.group&&a(l.group))};return e&&a(e),s}BE(){let e={orderedGroups:this.GE(),info:{}};return e.orderedGroups.forEach(t=>{let n=this.layoutMap.get(t.group.id);if(n!=null){let o=this.viewport.getGroupElement(t.group.id);n.relayout(null,s=>{e.info[t.group.id]={positions:s.positions,sizes:s.sizes,extents:s.bounds,element:o}})}}),e}getGroupContentExtents(e,t){return this.viewport.$computeGroupContentExtents(e,t,null,null,null)}$trackGroupSizeChanges(e){for(let t in e){let n=e[t];if(n.originalGroupSize.width!==n.newGroupSize.width||n.originalGroupSize.height!==n.newGroupSize.height){let o=n.element.modelObject,s={[this.$modelWidthAttribute]:n.newGroupSize.width,[this.$modelHeightAttribute]:n.newGroupSize.height};o.data[this.$modelWidthAttribute]=n.newGroupSize.width,o.data[this.$modelHeightAttribute]=n.newGroupSize.height;let a=this.viewport.updateElement(o.id,null,null,n.newGroupSize.width,n.newGroupSize.height,null,null,!1);this.$doVertexUpdated(a),this.$repaintUIElement(a,null,!0),this.model.fire(Pd,{group:o,originalGroupSize:n.originalGroupSize,newGroupSize:n.newGroupSize,source:this}),this.le(l=>{l.$groupResized(n)}),this.model.fire(Re,{vertex:o,updates:s,originalData:o.data,reason:hS},null)}}}Wa(e,t,n,o,s){t=t||{},n=n||{};let a=this.getGroupDefinition(e),l=s||a.autoShrink||a.autoGrow||a.autoSize||a.elastic,h=a.autoShrink===!0||a.elastic===!0||a.autoSize===!0&&a.autoShrink!==!1,d=a.autoGrow===!0||a.elastic===!0||a.autoSize===!0&&a.autoGrow!==!1;if(!l)return null;let u=P=>t[P]||this.getElementPosition(P),p=P=>n[P]||this.getElementSize(P),m=this.$_getGroupContentAreaInfo(e.id),g=m.contentArea,E=0,y=0,x,f,b=p(e.id),A=m.isGroupElement?p(e.id):this.$getSize(g),T=Math.max(A.width,b.width),S=Math.max(A.height,b.height),R=Object.assign({},u(e.id)),v,O=null;if(O!=null)E=O.layoutShiftX,y=O.layoutShiftY,x=O.width,f=O.height,v={x:R.x-E,y:R.y-y};else{let P=yp(o,a,!1,h,d,this.gridProfile);x=P.width,f=P.height,E=P.layoutShiftX,y=P.layoutShiftY,v={x:R.x-E,y:R.y-y}}if(x=parseInt(x,10),f=parseInt(f,10),this.$setElementSizeInUI(g,x,f),!m.isGroupElement){let P=this.viewport.getGroupElement(e.id),I=this.$getSize(P.el),C=I.width-T,_=I.height-S;if(!s&&h===!1){let w=!1;C<0&&(this.$setElementWidth(g,T-m.internalOffset.x),C=0,w=!0),_<0&&(this.$setElementHeight(g,S-m.internalOffset.y),_=0,w=!0),w&&(I=this.$getSize(P.el))}if(!s&&d===!1){let w=!1;C>0&&(this.$setElementWidth(g,T-m.internalOffset.x),C=0,w=!0),_>0&&(this.$setElementHeight(g,S-m.internalOffset.y),_=0,w=!0),w&&(I=this.$getSize(P.el))}x=I.width,f=I.height}return{position:v,size:{width:x,height:f},originalSize:{width:T,height:S},layoutShiftX:E,layoutShiftY:y}}autoSizeGroups(e,t){return e=e||this.getGroups(),this.$_sizeGroupsToFit(new Set(e),null,null,t)}du(e){let t={container:this.me,options:e.options||{},instance:this.model,dataSource:this.dataSource,adapter:this.$createDefaultLayoutAdapter()};return t.options.locationFunction||(t.options.locationFunction=n=>({x:Oe(n.data,this.$modelLeftAttribute),y:Oe(n.data,this.$modelTopAttribute)})),qe.get(e.type,t)}tu(e,t){let n=this.eu(t);n==null&&(n=this.$getManagedElement(t.id).el);let o={container:n,options:e.options||{},instance:this.model,dataSource:this.dataSource,adapter:this.$createGroupLayoutAdapter(t)};return o.options.locationFunction||(o.options.locationFunction=s=>{let a={x:Oe(s.data,this.$modelLeftAttribute),y:Oe(s.data,this.$modelTopAttribute)};return z(a.x)&&(a.x=parseInt(a.x,10)),z(a.y)&&(a.y=parseInt(a.y,10)),a}),qe.get(e.type,o)}setLayout(e,t){e&&(this.$_layout=this.du(e),t||this.refresh())}adHocLayout(e){e&&this.model.transaction(()=>{for(let n in this.$_connMap){let o=this.$_connMap[n].edge;this.model.clearEdgeGeometry(o)}this.du(e).layout(n=>{for(let o in n.positions)this.UE(o,n.positions[o])})})}$_doRenderTransientVertex(e,t,n,o,s,a,l){let h=this.$renderTransientVertex(t,n,o,s,a,l);return this.$appendVertexElement(h),this.$manage(h,e,t,n,null,!1)}$addTransientVertex(e,t,n,o,s,a){let l=this.model.$addTransientVertex(n,this),h=this.$_doRenderTransientVertex(l,e,t,n,o,s,a);return{vertex:l,el:h}}$renderDummyVertex(e){let t={x:e.data[this.$modelLeftAttribute]||0,y:e.data[this.$modelTopAttribute]||0};this.$_doRenderTransientVertex(e,t,{width:1,height:1},e.data,{},[Hi,tv].join(" "),{[ee]:e.id})}$removeTransientVertex(e){this.model.$cleanupTransientVertex(e.modelObject,this)}$addTransientEdge(e,t,n,o){return this.model.$addTransientEdge(this,e,t,n,null,o)}$isUnattachedEdgeAllowed(e){let t=this.model.getEdgeType(e.data),n=this.view.getEdgeDefinition(t);return n.allowUnattached!=null?n.allowUnattached:this.$_allowUnattachedEdges===!0}uu(e){(e.plugins||[]).forEach(n=>{this.pu(n,!0)})}addPlugin(e){return this.pu(e,!0)}pu(e,t){let n=z(e)?e:e.type,o=z(e)?{}:e.options||{},s=sr.get(n);if(s!=null)return s.initialise(this,o),this.plugins.push(s),this.pluginMap.set(n,s),t&&this.fire(Kd,s),s}getPlugin(e){return this.pluginMap.get(e)}le(e){this.plugins.forEach(t=>{try{e(t)}catch(n){U(`WARN: could not dispatch event to plugin ${t.id} [${n}]`)}})}registerDataHook(e){this.$_dataHooks.push(e)}save(e){let t={data:this.model.exportData(e),zoom:this.j};return this.$_dataHooks.forEach(n=>{n.save(t)}),t}saveToUrl(e){this.model.save(Object.assign(e,{data:this.save(e)}))}load(e,t){this.model.load({data:e.data,onload:()=>{e.zoom&&this.setZoom(e.zoom),this.$_dataHooks.forEach(n=>{n.load(e)}),t&&t()}})}$isArrayLike(e){return!z(e)&&Array.isArray(e)}};var hD=20,cD=20,Sp=class Sp extends Nn{constructor(e,t,n){super(e,t,n);this.component=t;c(this,"width");c(this,"length");c(this,"foldback");c(this,"direction");c(this,"type",Sp.type);c(this,"contentTags",[te]);n=n||{},this.width=n.width||hD,this.length=n.length||cD,this.direction=(n.direction||1)<0?-1:1,this.foldback=n.foldback||.623}draw(e,t,n){let o,s,a,l,h;if(this.location>1||this.location<0){let g=this.location<0?1:0;o=rt(e,g,this.location,!1),s=rt(e,g,this.location-this.direction*this.length/2,!1),a=zt(o,s,this.length)}else if(this.location===1){if(o={x:e.paintInfo.tx,y:e.paintInfo.ty},s=rt(e,this.location,-this.length),a=zt(o,s,this.length),this.direction===-1){let g=a;a=o,o=g}}else if(this.location===0){if(a={x:e.paintInfo.sx,y:e.paintInfo.sy},s=rt(e,this.location,this.length),o=zt(a,s,this.length),this.direction===-1){let g=a;a=o,o=g}}else o=rt(e,this.location,this.direction*this.length/2),s=Xr(e,this.location),a=zt(o,s,this.length);l=rr(o,a,this.width),h=zt(o,a,this.foldback*this.length);let{stroke:d,fill:u,lineWidth:p}=this.$getStyle(t);return{atts:[{d:isNaN(h.x)||isNaN(h.y)?"M 0 0":"M"+o.x+","+o.y+" L"+l[0].x+","+l[0].y+" L"+h.x+","+h.y+" L"+l[1].x+","+l[1].y+" Z","stroke-width":p,stroke:d,fill:u}],xmin:Math.min(o.x,l[0].x,l[1].x),xmax:Math.max(o.x,l[0].x,l[1].x),ymin:Math.min(o.y,l[0].y,l[1].y),ymax:Math.max(o.y,l[0].y,l[1].y),tail:h}}};c(Sp,"type","Arrow");var Rr=Sp;nt.register(Rr.type,Rr);var vp=class vp extends Rr{constructor(e,t,n){super(e,t,n);c(this,"type",vp.type);this.foldback=1}};c(vp,"type","PlainArrow");var Tp=vp;nt.register(Tp.type,Tp);var Pp=class Pp extends Rr{constructor(e,t,n){super(e,t,n);c(this,"type",Pp.type);this.length=this.length/2,this.foldback=2}};c(Pp,"type","Diamond");var Cp=Pp;nt.register(Cp.type,Cp);var Op=class Op extends li{constructor(e,t,n){super(t,n);this.connection=t;c(this,"create");c(this,"isSimpleShape",!1);c(this,"type",Op.type);this.create=n.create}updateFrom(e,t){}};c(Op,"type","Custom");var lh=Op;function hn(i){return i.type===lh.type}nt.register(lh.type,lh);var dD=5,Rp=class Rp extends Nn{constructor(e,t,n){super(e,t,n);this.component=t;c(this,"Ce");c(this,"$r");c(this,"type",Rp.type);c(this,"contentTags",[Xe]);n=n||{},this.Ce=n.radius||dD,this.$r=n.align||"flush"}draw(e,t,n){let{stroke:o,fill:s,lineWidth:a}=this.$getStyle(t),l,h;if(this.location===0)if(this.$r==="center")l={x:e.paintInfo.sx,y:e.paintInfo.sy},h=rt(e,this.location,this.Ce);else{let d={x:e.paintInfo.sx,y:e.paintInfo.sy},u=rt(e,this.location,this.Ce);l=zt(d,u,this.Ce),h=rt(e,this.location,2*this.Ce)}else if(this.location===1)if(this.$r==="center")l={x:e.paintInfo.tx,y:e.paintInfo.ty},h=rt(e,this.location,-this.Ce);else{let d={x:e.paintInfo.tx,y:e.paintInfo.ty},u=rt(e,this.location,-this.Ce);l=zt(d,u,this.Ce),h=rt(e,this.location,-2*this.Ce)}else l=Xr(e,this.location),h=rt(e,this.location,this.Ce);return{atts:[{cx:l.x,cy:l.y,r:this.Ce,"stroke-width":a,stroke:o,fill:s}],xmin:l.x-this.Ce,xmax:l.x+this.Ce,ymin:l.y-this.Ce,ymax:l.y+this.Ce,tail:h}}};c(Rp,"type","Dot");var _p=Rp;nt.register(_p.type,_p);var uD=10,pD=10,wp=class wp extends Nn{constructor(e,t,n){super(e,t,n);this.component=t;c(this,"width");c(this,"height");c(this,"mu");c(this,"$r");c(this,"type",wp.type);c(this,"contentTags",[te]);n=n||{},this.width=n.width||uD,this.height=n.height||pD,this.mu=n.rotate===!0,this.$r=n.align||"flush"}draw(e,t,n){let{stroke:o,fill:s,lineWidth:a}=this.$getStyle(t),l,h,d,u,p,m,g,E,y,x,f,b,A,T,S,R;if(this.mu){if(this.location===0){let v={x:e.paintInfo.sx,y:e.paintInfo.sy},O,P;this.$r==="center"?(P=rt(e,this.location,this.width/2),O=zt(P,v,this.width)):(O=v,P=rt(e,this.location,this.width)),S=rr(P,O,this.height),R=rr(O,P,this.height),m=P}else if(this.location===1){let v={x:e.paintInfo.tx,y:e.paintInfo.ty},O,P;this.$r==="center"?(P=rt(e,this.location,-this.width/2),O=zt(P,v,this.width)):(O=v,P=rt(e,this.location,-this.width)),S=rr(O,P,this.height),R=rr(P,O,this.height),m=P}else{let v=rt(e,this.location,this.width/2),O=Xr(e,this.location),P=zt(v,O,this.width);S=rr(v,P,this.height),R=rr(P,v,this.height),m=P}g=S[0].x,E=S[0].y,y=S[1].x,x=S[1].y,f=R[1].x,b=R[1].y,A=R[0].x,T=R[0].y}else{let v;this.location===0?v={x:e.paintInfo.sx,y:e.paintInfo.sy}:this.location===1?v={x:e.paintInfo.tx,y:e.paintInfo.ty}:v=Xr(e,this.location),m=v,g=v.x-this.width/2,E=v.y-this.height/2,y=g+this.width,x=E,f=y,b=E+this.height,A=g,T=E+this.height}return h=Math.min(g,y,f,A),d=Math.max(g,y,f,A),u=Math.min(E,x,b,T),p=Math.max(E,x,b,T),l=`M ${g} ${E} L ${y} ${x} L ${f} ${b} L ${A} ${T} Z`,{atts:[{"stroke-width":a,stroke:o,fill:s,d:l}],xmin:h,xmax:d,ymin:u,ymax:p,tail:m}}};c(wp,"type","Rectangle");var Lp=wp;nt.register(Lp.type,Lp);var mD=8,gD=5,Np=class Np extends Nn{constructor(e,t,n){super(e,t,n);this.component=t;c(this,"rx");c(this,"ry");c(this,"type",Np.type);c(this,"contentTags",[Kv]);n=n||{},this.rx=n.rx||mD,this.ry=n.ry||gD}draw(e,t,n){let{stroke:o,fill:s,lineWidth:a}=this.$getStyle(t),l;return this.location===0?l={x:e.paintInfo.sx,y:e.paintInfo.sy}:this.location===1?l={x:e.paintInfo.tx,y:e.paintInfo.ty}:l=Xr(e,this.location),{atts:[{cx:l.x,cy:l.y,rx:this.rx,ry:this.ry,"stroke-width":a,stroke:o,fill:s}],xmin:l.x-this.rx,xmax:l.x+this.rx,ymin:l.y-this.ry,ymax:l.y+this.ry,tail:rt(e,this.location,(this.ry+this.rx)/2)}}};c(Np,"type","Ellipse");var Dp=Np;nt.register(Dp.type,Dp);var Ip=class{constructor(r,e){this.surface=r;c(this,"Kt");c(this,"gu");e=e||{edgeMappings:[]},this.Kt=e.edgeMappings||[],this.gu=this.surface.model.edgeTypeFunction,this.jE()}computeTypes(r){let e=[this.gu(r)];for(let t=0;t<this.Kt.length;t++){let n=this.Kt[t].property,o=this.Kt[t].mappings;if(z(n)){if(r[n]!=null){let s=z(r[n])?r[n].split(" "):[r[n]];e.push(...s.filter(a=>o[a]!=null).map(a=>`${n}_${a}`))}o[yr]!=null&&r[n]!=null&&e.push(`${n}_${yr}`)}else{let s=n.map(a=>r[a]);if(s.every(a=>a!=null)){let a=s.join(" ");o[a]!=null&&e.push(`${n.join("_")}_${a.replace(/ /g,"_")}`)}}}return e.join(" ")}jE(){for(let r=0;r<this.Kt.length;r++){let e=this.Kt[r].property,t=this.Kt[r].mappings;for(let n in t)if(t.hasOwnProperty(n)){let o=z(e)?`${e}_${n}`:`${e.join("_")}_${n.replace(/ /g,"_")}`;this.surface.$registerConnectionType(o,t[n])}}this.surface.model.edgeTypeFunction=r=>this.computeTypes(r)}getPropertyMappings(){return this.Kt}};function ED(i,r,e,t,n,o,s){return new Touch({target:i,identifier:V(),pageX:r,pageY:e,screenX:t,screenY:n,clientX:o||t,clientY:s||n})}function fD(...i){let r=[];return r.push(...i),r.item=function(e){return this[e]},r}function yD(i,r,e,t,n,o,s){return fD(ED(i,r,e,t,n,o,s))}function ua(i,r,e){e=e||i.parentNode;let t=e.querySelectorAll(r);for(let n=0;n<t.length;n++)if(t[n]===i)return!0;return!1}function hh(i){return i.srcElement||i.target}function Df(i,r,e,t){if(t){let n=i.composedPath?i.composedPath():i.path;if(typeof n!="undefined"&&n.indexOf)return{path:n,end:n.indexOf(e)};{let o={path:[],end:-1},s=a=>{o.path.push(a),a===e?o.end=o.path.length-1:a.parentNode!=null&&s(a.parentNode)};return s(r),o}}else return{path:[r],end:1}}function xD(i,r){let e=0,t;for(e=0,t=i.length;e<t&&i[e][0]!==r;e++);e<i.length&&i.splice(e,1)}var bD=1,rC=!1,nC=!1;function In(){return rC||"ontouchstart"in document.documentElement||navigator.maxTouchPoints!=null&&navigator.maxTouchPoints>0}function di(){return nC||"onmousedown"in document.documentElement}function AD(i){rC=i}function SD(i){nC=i}var ci={[ue]:$A,[oe]:BA,[ie]:FA};function Nf(i,r){if(i==null)return{x:0,y:0};let e=Jo(i),t=Gf(e,0);return r(t)}function ge(i){return Nf(i,r=>({x:r.pageX,y:r.pageY}))}function TD(i){return Nf(i,r=>({x:r.screenX,y:r.screenY}))}function vD(i){return Nf(i,r=>({x:r.clientX,y:r.clientY}))}function Gf(i,r){return i.item?i.item(r):i[r]}function Jo(i){return i.touches!=null&&i.touches.length>0?i.touches:i.changedTouches&&i.changedTouches.length>0?i.changedTouches:i.targetTouches&&i.targetTouches.length>0?i.targetTouches:[i]}function aC(i){return Jo(i).length}function CD(i){if(i==null)return{x:0,y:0};if(i.pageX!==null)return{x:i.pageX,y:i.pageY};{let r=Jo(i),e=Gf(r,0);return e!=null&&e.pageX!=null?{x:e.pageX,y:e.pageY}:{x:0,y:0}}}function Mp(i,r,e,t,n){oC(i,r,e),t.qt=e.qt,i.addEventListener&&i.addEventListener(r,e,!1,n)}function ch(i,r,e){e!=null&&iC(i,t=>{PD(t,r,e),e.qt!=null&&t.removeEventListener&&(t.removeEventListener(r,e,!1),In()&&ci[r]&&t.removeEventListener(ci[r],e,!1)),e.Eu&&ch(i,e.Eu[1],e.Eu[0])})}function iC(i,r){if(i==null)return;let e=typeof i=="string"?document.querySelectorAll(i):Array.isArray(i)?i:[i];for(let t=0;t<e.length;t++)r(e[t])}function oC(i,r,e){let t=bD++;return i.Br=i.Br||{},i.Br[r]=i.Br[r]||{},i.Br[r][t]=e,e.qt=t,t}function PD(i,r,e){if(i.Br&&i.Br[r]&&delete i.Br[r][e.qt],e.Fr){for(let t=0;t<e.Fr.length;t++)ch(i,e.Fr[t][0],e.Fr[t][1]);e.Fr.length=0}e.Ja&&e.Ja()}var OD=/:not\(([^)]+)\)/;function Vp(i,r,e,t){if(i==null)return e;{let n=i.split(","),o=[],s=[];n.forEach(l=>{let h=l.match(OD);h!=null?s.push(h[1]):o.push(l)}),s.length>0&&o.length===0&&o.push(yr);let a=l=>{a.qt=e.qt;let h=hh(l),d=!1,u=h,p=Df(l,h,r,i!=null);if(p.end!=-1)for(let m=0;!d&&m<p.end;m++){u=p.path[m];for(let g=0;g<s.length;g++)if(ua(u,s[g],r))return;for(let g=0;!d&&g<o.length;g++)if(ua(u,o[g],r)){e.apply(u,[l,u]),d=!0;break}}};return _D(e,t,a),a}}function _D(i,r,e){i.Fr=i.Fr||[],i.Fr.push([r,e])}var Gp=(i,r,e,t,n)=>{if(In()&&ci[r]){let o=Vp(t,i,e,ci[r]);Mp(i,ci[r],o,e,n)}r===VA&&i.getAttribute(uf)==null&&i.setAttribute(uf,"1"),Mp(i,r,Vp(t,i,e,r),e,n)},If={[W]:{touches:1,taps:1},[Fr]:{touches:1,taps:2},[gt]:{touches:2,taps:1}};function sC(i,r,e,t){for(let n in e.Me[i])e.Me[i].hasOwnProperty(n)&&e.Me[i][n].apply(t,[r])}var Mf=class{static generate(r,e){return(t,n,o,s)=>{if(n==gt&&di())Gp(t,n,o,s);else{if(t.je==null){let a=t.je={tap:[],dbltap:[],down:!1,taps:0,downSelectors:[]},l=function(){a.down=!1},h=function(){a.taps=0},d=p=>{let m=hh(p),g=Df(p,m,t,s!=null),E=!1;for(let y=0;y<g.end;y++){if(E)return;m=g.path[y];for(let x=0;x<a.downSelectors.length;x++)if(a.downSelectors[x]==null||ua(m,a.downSelectors[x],t)){a.down=!0,setTimeout(l,r),setTimeout(h,e),E=!0;break}}},u=p=>{if(a.down){let m=hh(p),g,E;a.taps++;let y=aC(p);for(let x in If)if(If.hasOwnProperty(x)){let f=If[x];if(f.touches===y&&(f.taps===1||f.taps===a.taps))for(let b=0;b<a[x].length;b++){E=Df(p,m,t,a[x][b][1]!=null);for(let A=0;A<E.end;A++)if(g=E.path[A],a[x][b][1]==null||ua(g,a[x][b][1],t)){a[x][b][0].apply(g,[p,g]);break}}}}};t.je.downHandler=d,t.je.upHandler=u,Gp(t,ue,d),Gp(t,oe,u)}t.je.downSelectors.push(s),t.je[n].push([o,s]),o.Ja=function(){t.je!=null&&(Lt(t.je.downSelectors,a=>a===s),xD(t.je[n],o),t.je.downSelectors.length===0&&(ch(t,ue,t.je.downHandler),ch(t,oe,t.je.upHandler),delete t.je))}}}}},Vf=class{static generate(){let r=[];return(e,t,n,o)=>{if(!e.Me){e.Me={over:!1,mouseenter:[],mouseexit:[]};let s=l=>{let h=hh(l);(o==null&&h==e&&!e.Me.over||ua(h,o,e)&&(h.Me==null||!h.Me.over))&&(sC(vE,l,e,h),h.Me=h.Me||{},h.Me.over=!0,r.push(h))},a=l=>{let h=hh(l);for(let d=0;d<r.length;d++)h==r[d]&&!ua(l.relatedTarget||l.toElement,"*",h)&&(h.Me.over=!1,r.splice(d,1),sC(CE,l,e,h))};Mp(e,tt,Vp(o,e,s,tt),s),Mp(e,et,Vp(o,e,a,et),a)}n.Ja=function(){delete e.Me[t][n.qt]},oC(e,t,n),e.Me[t][n.qt]=n}}},ye=class{constructor(r){c(this,"clickThreshold");c(this,"dblClickThreshold");c(this,"tapHandler");c(this,"mouseEnterExitHandler");r=r||{},this.clickThreshold=r.clickThreshold||250,this.dblClickThreshold=r.dblClickThreshold||450,this.mouseEnterExitHandler=Vf.generate(),this.tapHandler=Mf.generate(this.clickThreshold,this.dblClickThreshold)}kE(r,e,t,n,o){if(t==null)return;let s=r;e===W||e===Fr||e===gt?this.tapHandler(s,e,t,n,o):e===vE||e==CE?this.mouseEnterExitHandler(s,e,t,n,o):Gp(s,e,t,n,o)}on(r,e,t,n,o){let s=n==null?null:t,a=n==null?t:n;return this.kE(r,e,a,s,o),this}off(r,e,t){return ch(r,e,t),this}trigger(r,e,t,n,o){let s=di()&&(typeof MouseEvent=="undefined"||t==null||t.constructor===MouseEvent),a=In()&&!di()&&ci[e]?ci[e]:e,l=!(In()&&!di()&&ci[e]),h=ge(t),d=TD(t),u=vD(t);return iC(r,p=>{let m;t=t||{screenX:d.x,screenY:d.y,clientX:u.x,clientY:u.y};let g=f=>{n&&(f.payload=n)},E={TouchEvent:f=>{let b=yD(p,h.x,h.y,d.x,d.y,u.x,u.y);(f.initTouchEvent||f.initEvent)(a,!0,!0,window,null,d.x,d.y,u.x,u.y,!1,!1,!1,!1,b,b,b,1,0)},MouseEvents:f=>{f.initMouseEvent(a,!0,!0,window,o==null?1:o,d.x,d.y,u.x,u.y,t.ctrlKey===!0,t.altKey===!0,t.shiftKey===!0,t.metaKey===!0,1,p)}},y=!l&&!s&&In()&&ci[e],x=y?"TouchEvent":"MouseEvents";m=document.createEvent(x),E[x](m),g(m),p.dispatchEvent(m)}),this}};var RD=["stroke-linejoin","stroke-dashoffset","stroke-linecap"];function ce(i,r){for(let e in r){let t=r[e];if(e==="style"&&typeof t=="object"){let n=Object.entries(t);for(let o=0;o<n.length;o++){let s=n[o];i.style[s[0]]=s[1]}}else i.setAttribute(e,""+r[e])}}function $(i,r,e,t){return r=r||{},ma(Zt,i,e,t,r)}function lC(i,r){let e=r.map(t=>$("stop",{offset:`${t[0]}%`,"stop-color":t[1]}));i.replaceChildren(...e)}function LD(i,r){i.gradient==null&&(i.gradient=$("linearGradient",{id:tE(),gradientUnits:"userSpaceOnUse"}),i.canvas.insertBefore(i.gradient,i.canvas.childNodes[0])),i.gradient.setAttribute("x1",`${i.x}`),i.gradient.setAttribute("x2",`${i.x+i.width}`),lC(i.gradient,r)}function hC(i,r,e){let t=tE(),n=$("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:i,x2:r});return lC(n,e),{id:t,g:n}}function $f(i,r,e,t){r.setAttribute(Wv,e.fill?e.fill:ht),!t&&e.gradient?(LD(i,e.gradient),r.setAttribute(Rf,`url(#${i.gradient.id})`)):r.setAttribute(Rf,e.stroke?e.stroke:ht),e.strokeWidth&&r.setAttribute(Zv,e.strokeWidth),e.dashArray?r.setAttribute(wf,e.dashArray):r.removeAttribute(wf),RD.forEach(n=>{e[n]&&r.setAttribute(n,e[n])})}function pa(i,r,e){e>=0?i.insertBefore(r,i.childNodes[e]):i.appendChild(r)}function wD(i,r,e){let t=[];return i!=null&&i.split(/\n/).forEach(o=>{t.push(...DD(o,r,e))}),t}function DD(i,r,e){let t=(i||"").split(/\s/),n=[];if(t.length===0)return[];if(t.length===1)return[i];let o=[t[0]],s=1,a=0,l=!1,h=$(Lf);for(e.appendChild(h);!l;){let d=t.slice(a,s+1),u=d.join(" ");h.innerHTML=u,h.getBBox().width<r||o.length===0?(o=d.slice(),s+=1,s>=t.length&&(l=!0)):(n.push(o),a=s,o=[t[a]],s=a+1,s>=t.length&&(l=!0))}return e.removeChild(h),n.push(o),n.map(d=>d.join(" "))}function ND(i,r,e){return wD(i,r,e).map(t=>{let n=$(Lf);return n.innerHTML=t,n})}function $p(i,r,e){let n=i.getAttribute(Q)||"50%",o=ND(r,e,i);i.innerHTML="";let s=0;return o.forEach((a,l)=>{i.appendChild(a),a.setAttribute("dominant-baseline","hanging"),a.setAttribute(Q,n),a.setAttribute("dy",s==0?"0":`${s+3}`),s=a.getBBox().height}),o.length>0&&o[0].setAttribute("dy",`${-i.getBBox().height/2}`),i}var Bf="data-vjs-container",Ff="data-vjs-group-content",Bp="data-vjs-expanded-content",Fp="data-vjs-collapsed-content",xr="data-vjs-enabled",dh="data-vjs-scope",uh="data-vjs-is-group",jme="endpoint",Hme="element",kme="connection",He="div",Uf="position",Zr=X(aa),Wme=be(WT),cC=be(Ff),Mn=X(la),dC=X(Ju);function Bt(i,r,e){e=e||i.parentNode;let t=e.querySelectorAll(r);for(let n=0;n<t.length;n++)if(t[n]===i)return!0;return!1}function ae(i,r){i.stopPropagation?i.stopPropagation():i.returnValue=!1,!r&&i.preventDefault&&i.preventDefault()}function Jt(i,r,e,t){if(t&&Bt(i,r,e))return i;for(i=i.parentNode;i!=null&&i!==e;){if(Bt(i,r))return i;i=i.parentNode}}function cge(i,r,e){e=e||document.body;let t=[],n=Jt(i,r,e,!1);for(;n!=null;)t.push(n),n=Jt(n,r,e,!1);return t}function Ko(i){return i.srcElement||i.target}function uC(i,r){r=bt(r),typeof i.className.baseVal!="undefined"?i.className.baseVal=r:i.className=r}function Up(i){return i.className!=null?typeof i.className.baseVal=="undefined"?i.className:i.className.baseVal:""}function pC(i,r,e){let t=r==null?[]:Array.isArray(r)?r:r.split(/\s+/),n=e==null?[]:Array.isArray(e)?e:e.split(/\s+/),o=Up(i),s=o.split(/\s+/),a=(l,h)=>{for(let d=0;d<h.length;d++)if(l)s.indexOf(h[d])===-1&&s.push(h[d]);else{let u=s.indexOf(h[d]);u!==-1&&s.splice(u,1)}};a(!0,t),a(!1,n),uC(i,s.join(" "))}function Vn(i){return!z(i)&&!Array.isArray(i)&&i.length!=null&&i.documentElement==null&&i.nodeType==null}function dge(i){return!z(i)&&(Array.isArray(i)||Vn(i))}function gC(i){return!z(i)&&(Array.isArray(i)||Vn(i))}function EC(i){return Up(i)}function L(i,r){let e=(t,n)=>{t!=null&&n!=null&&n.length>0&&(t.classList?bt(n).split(/\s+/).forEach(s=>{t.classList.add(s)}):pC(t,n))};Vn(i)?i.forEach(t=>e(t,r)):e(i,r)}function cn(i,r){return i.classList?i.classList.contains(r):Up(i).indexOf(r)!==-1}function F(i,r){let e=(t,n)=>{t!=null&&n!=null&&n.length>0&&(t.classList?bt(n).split(/\s+/).forEach(s=>{t.classList.remove(s)}):pC(t,null,n))};Vn(i)?i.forEach(t=>e(t,r)):e(i,r)}function Yf(i,r){let e=(t,n)=>{t!=null&&n!=null&&n.length>0&&(t.classList?t.classList.toggle(n):cn(t,n)?F(t,n):L(t,n))};Vn(i)?i.forEach(t=>e(t,r)):e(i,r)}function Ft(i,r=[],e=[]){let n=Up(i).split(" ").filter(o=>e.indexOf(o)===-1&&r.indexOf(o)===-1);n.push(...r),uC(i,n.join(" "))}function fC(i,r){let e=null;if(arguments.length===1){if(!z(i)){let t=document.createDocumentFragment();return t.appendChild(i),Array.from(t.childNodes)}e=Array.from(document.querySelectorAll(i))}else e=Array.from(i.querySelectorAll(r));return e}function Jr(i,r,e,t){return ma(null,i,r,e,t)}function ma(i,r,e,t,n){let o=i==null?document.createElement(r):document.createElementNS(i,r);return e=e||{},Object.assign(o.style,e),t&&L(o,t),ce(o,n||{}),o}function Kr(i,r,e,t,n,o,s){let a=ma(i,r||He,e,t,n);return o!=null&&(s?o.insertBefore(a,o.lastChild):o.appendChild(a)),a}function Ki(i,r){let e=i.getBoundingClientRect(),t=document.body,n=document.documentElement,o=window.pageYOffset||n.scrollTop||t.scrollTop,s=window.pageXOffset||n.scrollLeft||t.scrollLeft,a=n.clientTop||t.clientTop||0,l=n.clientLeft||t.clientLeft||0,h=e.top+o-a,d=e.left+s-l;return{x:r?d:Math.round(d),y:r?h:Math.round(h)}}function Yp(i){return i==null?"HTML":i instanceof SVGElement?"SVG":"HTML"}function Ot(i){return Yp(i)==="SVG"}function qi(i){return i.nodeType!=null&&i.nodeType!==3&&i.nodeType!==8}var mC=class i{static setNodeText(r,e){r.text=e;try{r.textContent=e}catch(t){}}static getNodeText(r){return r!=null?r.text||r.textContent:""}static getChild(r,e){let t=null;for(let n=0;n<r.childNodes.length;n++)if(r.childNodes[n].nodeType===1&&r.childNodes[n].nodeName===e){t=r.childNodes[n];break}return t}static getChildren(r,e){let t=[];for(let n=0;n<r.childNodes.length;n++)r.childNodes[n].nodeType===1&&r.childNodes[n].nodeName===e&&t.push(r.childNodes[n]);return t}static xmlToString(r){try{return new XMLSerializer().serializeToString(r).replace(/\s*xmlns=\"http\:\/\/www.w3.org\/1999\/xhtml\"/g,"")}catch(e){try{return r.xml}catch(t){throw new Error("Cannot serialize XML "+t)}}}static createElement(r,e,t){let n;if(n=document.createElement(r),t&&i.setNodeText(n,t),e)for(let o in e)n.setAttribute(o,e[o]);return n}};function ga(i,r){r=r||150;let e=null;return()=>{window.clearTimeout(e),e=window.setTimeout(i,r)}}function Ea(i){let r=new XMLHttpRequest,e=i.type||"GET";if(r){let t=i.dataType===Xt?o=>JSON.parse(o):o=>o;r.open(e,i.url,!0);let n=i.headers||{};for(let o in n)r.setRequestHeader(o,n[o]);r.onreadystatechange=()=>{r.readyState===4&&((""+r.status)[0]==="2"?i.success(t(r.responseText)):i.error&&i.error(r.responseText,r.status))},r.send(i.data?JSON.stringify(i.data):null)}else i.error&&i.error("ajax not supported")}function zp(i,r,e){let t=r.getBoundingClientRect(),n=ge(i);return{x:t.width===0?0:(n.x-t.x)/t.width,y:t.height===0?0:(n.y-t.y)/t.height}}function yC(i){return i==null?!1:Object.prototype.toString.call(i).match(/\[object .*Element]/)!=null}function uge(i){return i==null?!1:Object.prototype.toString.call(i)==="[object Text]"}function qr(i,r){return"["+i+"='"+r+"']"}function pge(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}function mge(i){window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",r=>{i(r.matches)})}function X(...i){return i.map(r=>"."+r).join(",")}function gge(...i){return i.join(" ")}function be(...i){return i.map(r=>"["+r+"]").join(",")}var ph=be(Pt);function fa(i,r,e){return function(t){return t[i]/r*(e?-1:1)}}var xC="deltaY",bC="deltaX",ID="wheelDeltaY",MD="wheelDeltaX",Xp="webkit",ya="mac",mh="win",zf="ie",Xf="safari",jf="firefox",Hf="default";function AC(i){return i.deltaY*(i.deltaMode===1?25:1)/120}function SC(i){return i.deltaX*(i.deltaMode===1?25:1)/120}var kf={[Xp]:{[ya]:fa(xC,120),[mh]:fa(xC,100)},[Xf]:fa(ID,120,!0),[jf]:{[ya]:AC,[mh]:AC},[zf]:function(i){return i.wheelDelta/120},[Hf]:function(i){return i.deltaY||i.wheelDelta}},Wf={[Xp]:{[ya]:fa(bC,120),[mh]:fa(bC,100)},[Xf]:fa(MD,120,!0),[jf]:{[ya]:SC,[mh]:SC},[zf]:function(i){return i.wheelDelta/120},[Hf]:function(i){return i.deltaX||i.wheelDelta}},TC=typeof navigator!="undefined",vC=TC?/Mac/.test(navigator.userAgent)?ya:mh:ya,xa=TC?navigator.userAgent.indexOf("Firefox")!==-1?jf:/Chrome/.test(navigator.userAgent)?Xp:/Safari/.test(navigator.userAgent)?Xf:/WebKit/.test(navigator.userAgent)?Xp:/Trident/.test(navigator.userAgent)?zf:"default":Hf,VD=typeof kf[xa]=="function"?kf[xa]:kf[xa][vC],GD=typeof Wf[xa]=="function"?Wf[xa]:Wf[xa][vC],$D=function(i){return VD(i||event)},BD=function(i){return GD(i||event)},FD=function(i,r,e){let t=n=>{let o=$D(n),s=BD(n);n.normalizedWheelDelta=o,(!e||n.metaKey||n.ctrlKey)&&i(n,s,o,n.metaKey||n.ctrlKey)};return i.HE=t,t},UD=typeof document!="undefined",CC=UD?"onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll":"wheel";function gh(i,r,e,t){let n=FD(r,e,t);return i.addEventListener?i.addEventListener(CC,n,!1):i.attachEvent&&i.attachEvent("onmousewheel",n),n}function Eh(i,r){let e=r.HE;e!=null&&(i.removeEventListener?i.removeEventListener(CC,e,!1):i.detachEvent&&i.detachEvent("onmousewheel",e))}function PC(i){return i.startEditingPath!=null&&i.stopEditingPath!=null}var OC="vjs-paper",_C="vjs-paper-canvas",RC=20,oEe="vjs-paper-node",fh="start",qo="center",yh="end";function LC(i){return kr(i)&&i.useHTMLElement===!0}var xh=class{constructor(r,e){this.instance=r;this.overlay=e;c(this,"htmlElementOverlay");this.htmlElementOverlay=e}static getElement(r,e,t,n){if(e.contentElement==null){if(n&&t){e.contentElement=n(t);let s=r.overlayClass+" "+(e.cssClass?e.cssClass:"");L(e.contentElement,s)}else e.contentElement=Jr(He,{},r.overlayClass+" "+(e.cssClass?e.cssClass:""));t&&t.edge&&e.contentElement.setAttribute(Ze,t.edge.id),e.contentElement.setAttribute(Zu,e.id);for(let s in e.attributes)e.contentElement.setAttribute(s,e.attributes[s]);e.contentElement.style.position=je,r.$appendOverlayElement(e.contentElement);let o="translate(-50%, -50%)";e.contentElement.style.webkitTransform=o,e.contentElement.style.mozTransform=o,e.contentElement.style.msTransform=o,e.contentElement.style.oTransform=o,e.contentElement.style.transform=o,e.visible||L(e.contentElement,Ql),e.contentElement.jtk={overlay:e}}return e.contentElement}static destroy(r){r.contentElement&&r.contentElement.parentNode&&r.contentElement.parentNode.removeChild(r.contentElement),delete r.contentElement}};function Zf(i,r,e){if(r.contentElements==null){r.contentElements=[];let t=Object.assign({[Zu]:r.id},r.attributes);e.forEach(n=>{let o=$(n,t),s=i.overlayClass+" "+(r.cssClass?r.cssClass:"");L(o,s),o.jtk={overlay:r},r.contentElements.push(o)})}return r.contentElements.forEach(t=>{var o;let n=t.parentNode;if(n==null){let s=(o=r.component)==null?void 0:o.connector;n=s!=null?s.canvas:null,n!=null&&pa(n,t,-1)}}),r.contentElements}function wC(i,r,e,t){let n=r;Zf(i,n,r.contentTags);let o=[-t.x,-t.y],s=Object.assign({transform:"translate("+o[0]+","+o[1]+")","pointer-events":"visibleStroke"},e.paintStyle);n.contentElements.forEach((a,l)=>{let h=e.atts[l],d=Object.assign(s,h);ce(a,d)})}function bh(i,r){return Zf(i,r,r.contentTags)}function Qo(i,r){return Zf(i,r,[q]),r.bgElement==null&&(r.bgElement=$(Z),r.contentElements[0].appendChild(r.bgElement)),r.textElement==null&&(r.textElement=$(Je),r.contentElements[0].appendChild(r.textElement)),r.contentElements}function DC(i,r,e,t){Qo(i,r);let n=vr(r.label)?r.label(r):r.label,o=[-t.x,-t.y],s={x:e.d.loc.x,y:e.d.loc.y,"text-anchor":"middle","dominant-baseline":"middle","pointer-events":"visibleStroke",transform:"translate("+o[0]+","+o[1]+")"};r.font&&r.font.size&&(s["font-size"]=r.font.size),r.font&&r.font.style&&(s["font-style"]=r.font.style),r.font&&r.font.family&&(s["font-family"]=r.font.family),ce(r.textElement,s),r.textElement.textContent=n;let a=r.textElement.getBBox(),l=i.currentZoom,h=a.width/l,d=a.height/l,u=5,p={transform:"translate("+o[0]+","+o[1]+")",x:s.x-u-h/2,y:s.y-u-d/2,width:h+2*u,height:d+2*u,fill:n==null||n.length===0?"none":"white"};ce(r.bgElement,p)}function Jf(i,r){i.contentElements!=null&&i.contentElements.forEach(e=>{e!=null&&e.parentNode!=null&&e.parentNode.removeChild(e)}),i.backgroundContentElements!=null&&i.backgroundContentElements.forEach(e=>{e!=null&&e.parentNode!=null&&e.parentNode.removeChild(e)}),delete i.contentElements,delete i.backgroundContentElements}var jp=class extends li{constructor(){super(...arguments);c(this,"contentElements");c(this,"backgroundContentElements")}};var ui="transform",Kf=/translate\(([-0-9\.]+),\s*([-0-9\.]+)\)/,NC=/rotate\(([-0-9\.]+)\)/;function it(i){let r=i;return r.width&&r.width.baseVal?HD(r):r.getBBox?kD(r):YD(i)}function un(i,r){let e=i;return Ot(i.parentElement)?Ah(e,r):e.x&&e.x.baseVal?XD(e):zD(e)}function Ce(i,r){let e=i;Ot(i.parentElement)?dn(e,r):(e.x&&e.x.baseVal&&jD(e,r),Kt(e,r))}function IC(i,r,e,t,n){let o=i;if(o instanceof HTMLElement)o.style[e]=`${r}px`;else if(o[t]&&o[t].baseVal)o.setAttribute(t,r);else if(o.localName===q){let s=Ah(o);s[n]=r,dn(o,s)}}function $C(i,r){IC(i,r,ze,Q,Q)}function BC(i,r){IC(i,r,Se,fe,fe)}function Lr(i,r,e){let t=i;t instanceof HTMLElement?MC(i,r,e):t.width&&t.width.baseVal&&(MC(i,r,e),i.setAttribute(Te,`${r}`),i.setAttribute(De,`${e}`))}function FC(i,r){let e=i;e instanceof HTMLElement?VC(i,r):e.width&&e.width.baseVal&&(VC(i,r),i.setAttribute(Te,`${r}`))}function UC(i,r){let e=i;e instanceof HTMLElement?GC(i,r):e.height&&e.height.baseVal&&(GC(i,r),i.setAttribute(De,`${r}`))}function YD(i){return{width:i.offsetWidth,height:i.offsetHeight}}function zD(i){return{x:parseFloat(i.offsetLeft),y:parseFloat(i.offsetTop)}}function jEe(i){return{x:parseInt(i.style.left,10),y:parseInt(i.style.top,10)}}function Kt(i,r){i.style.left=r.x+"px",i.style.top=r.y+"px"}function MC(i,r,e){i.style.width=`${r}px`,i.style.height=`${e}px`}function VC(i,r){i.style.width=`${r}px`}function GC(i,r){i.style.height=`${r}px`}function XD(i){try{return{x:parseFloat(i.x.baseVal.value),y:parseFloat(i.y.baseVal.value)}}catch(r){return{x:0,y:0}}}function jD(i,r){i.setAttribute("x",`${r.x}`),i.setAttribute("y",`${r.y}`)}function HD(i){try{return{width:parseFloat(i.width.baseVal.value),height:parseFloat(i.height.baseVal.value)}}catch(r){return{width:0,height:0}}}function kD(i){try{let r=i.getBBox();return{width:r.width,height:r.height}}catch(r){return{width:0,height:0}}}function Ah(i,r){let e,t,n,o,s;if(e=i.getAttribute(ui),e!=null){if(t=e.match(Kf),o=parseFloat(t[1]),s=parseFloat(t[2]),n=e.match(NC),n!=null){let a=parseFloat(n[1]),l=r||i.getBBox(),h={x:o+l.width/2,y:s+l.height/2},d=xt(h,{x:o,y:s},a),u=xt({x:o,y:s},d,-a);o=u.x,s=u.y}return{x:o,y:s}}else if(e=i.style.transform,e!=null){t=e.match(Kf);try{return{x:parseFloat(t[1]),y:parseFloat(t[2])}}catch(a){return{x:0,y:0}}}return{x:0,y:0}}function es(i,r){if(Ot(i.parentElement)){let t=(i.getAttribute(ui)||"").match(Kf);i.setAttribute(ui,(t==null?"":`${t[0]} `)+`rotate(${r})`)}else i.style.transform=r==0?"":"rotate("+r+"deg)",i.style.transformOrigin="center center"}function dn(i,r){let t=(i.getAttribute(ui)||"").match(NC);i.setAttribute(ui,`translate(${r.x.toFixed(2)}, ${r.y.toFixed(2)})`+(t==null?"":` ${t[0]}`))}var Hp=class{static paint(r,e,t){if(t!=null){let n=[r.width,r.height];if(isFinite(n[0])&&isFinite(n[1])){let o={[Te]:""+(n[0]||0),[De]:""+(n[1]||0)};ce(r.canvas,o),Ce(r.canvas,r)}}}};var qf="vjs-surface",YC="vjs-surface-direct-render",zC="vjs-surface-touch-device",XC="vjs-surface-pointer-device",Qf="vjs-surface-nopan",ey="vjs-surface-canvas",ty="vjs-surface-pan",nfe="vjs-surface-pan-left",ife="vjs-surface-pan-top",ofe="vjs-surface-pan-right",sfe="vjs-surface-pan-bottom",ry="vjs-surface-pan-active",ny="vjs-surface-flash",jC="vjs-flash-vertex",iy="vjs-surface-panning",oy="vjs-surface-element-dragging",Sh="vjs-element-dragging",sy="vjs-group-child-element-dragging",Th="vjs-most-recently-dragged",Gn="vjs-surface-edge-dragging",ay="vjs-edge-relocating",kp="vjs-edge-will-relocate",HC="vjs-lasso",vh="vjs-lasso-mask",kC="vjs-lasso-mask-left",WC="vjs-lasso-mask-top",ZC="vjs-lasso-mask-right",JC="vjs-lasso-mask-bottom",Wp="vjs-miniview",KC="vjs-miniview-canvas",qC="vjs-miniview-panner",QC="vjs-miniview-element",eP="vjs-miniview-group-element",ly="vjs-miniview-panning",tP="vjs-miniview-collapse",Zp="vjs-miniview-collapsed",rP="vjs-miniview-click-to-center",ct="vjs-drag-select-defeat",hy="vjs-default-node",cy="vjs-default-group",Qi="vjs-connector-source-drag",eo="vjs-connector-target-drag",nP="vjs-connector-transient-drag",ts="vjs-palette-selected-element",Ch="vjs-palette-tap-mode-active",iP="vjs-palette-current",Jp="vjs-palette-current-shape-type",rs="vjs-drag-hover-cannot-drop",dy="vjs-drag-original-group",qt="vjs-drag-active",Qt="vjs-drag-hover",uy="vjs-source-hover",py="vjs-target-hover",Ph="vjs-hover";function WD(i,r){if(r.outlineStroke!=null){let e=r.outlineWidth||1,t=r.strokeWidth+2*e,n=Object.assign({},r);return n.stroke=r.outlineStroke,n.strokeWidth=t,n}else if(i.$paintConnectorOutline){let e=i.$connectorOutlineWidth,t=Object.assign({},r);return t.stroke=i.$connectorOutlineColor||"transparent",t.strokeWidth=e,t}}function oP(i,r,e){JD(i,r);let t=r.connector;Hp.paint(t,i,e);let n="",o={x:-t.x,y:-t.y};if(t.internalSegments.length>0){n=bT(t);let s={d:n,transform:"translate("+o.x+","+o.y+")","pointer-events":"visibleStroke",[Ze]:r.edge.id},a=WD(i,e);a!=null&&(t.bgPath==null?(t.bgPath=$(te,s),L(t.bgPath,i.connectorOutlineClass),pa(t.canvas,t.bgPath,0)):ce(t.bgPath,s),$f(t,t.bgPath,a,!0)),t.path==null?(t.path=$(te,s),pa(t.canvas,t.path,a!=null?1:0),L(t.path,i.connectorPathClass),r.edge.transient&&L(t.canvas,qT)):(t.path.parentNode!==t.canvas&&pa(t.canvas,t.path,a!=null?1:0),ce(t.path,s)),$f(t,t.path,e,!1),r.detachable&&ZD(r,o,i.defaults.edgeRelocateHandleSize)}}function ZD(i,r,e){if(i.detachable){let t=i.connector,n=t.internalSegments[0].x1,o=t.internalSegments[0].y1,s={width:e,height:e,transform:`translate(${r.x-e/2},${r.y-e/2})`,"pointer-events":"fill",cursor:"move"},a=Object.assign(s,{x:n,y:o});t.sourceZone==null?(t.sourceZone=$(Z,a),L(t.sourceZone,Qi),t.canvas.appendChild(t.sourceZone)):ce(t.sourceZone,a);let l=t.internalSegments[t.internalSegments.length-1].x2,h=t.internalSegments[t.internalSegments.length-1].y2,d=Object.assign(s,{x:l,y:h});t.targetZone==null?(t.targetZone=$(Z,d),L(t.targetZone,eo),t.canvas.appendChild(t.targetZone)):ce(t.targetZone,d)}}function JD(i,r){let e=r.connector;if(e.canvas!=null)return e.canvas;{let t=i.containerType==="HTML"?$(ve,{[Te]:"0",[De]:"0",style:{"pointer-events":ht,position:je},[Ze]:r.edge.id}):$(q,{[Ze]:r.edge.id});return e.canvas=t,i.$appendEdgeElement(e.canvas),e.cssClass!=null&&L(t,e.cssClass),L(t,i.connectorClass),e.classesToAddWhenRendered!=null&&(L(t,e.classesToAddWhenRendered.join(" ")),delete e.classesToAddWhenRendered),t.jtk=t.jtk||{},t.jtk.connection=r,t}}var Kp=class{constructor(r,e){this.container=r;c(this,"Qt",!0);c(this,"ge");c(this,"Ka");c(this,"Pi");c(this,"qa");c(this,"ke");c(this,"fu");c(this,"rt");c(this,"er");c(this,"rr",{});c(this,"Sn",[]);c(this,"H");c(this,"Ur");c(this,"_i");c(this,"Ri");c(this,"Li");c(this,"Qa");e=e||{init:null},this.ge=new ye,this.Ka=this.WE.bind(this),this.ge.on(r,ue,"*",this.Ka),this.Pi=this.ZE.bind(this),this.qa=this.JE.bind(this),this.Li=e.translate||(t=>Object.assign({},t)),this.Qa=e.init}$enable(){this.Qt=!0}$disable(){this.Qt=!1}addHandler(r){let e=this.rr[r.selector];e==null&&(this.rr[r.selector]=[],e=this.rr[r.selector],this.Sn.push(r.selector)),e.push(r),e.sort((t,n)=>{let o=t.priority==null?0:t.priority,s=n.priority==null?0:n.priority;return o>s?-1:s>o?1:0})}removeHandler(r){let e=this.rr[r.selector];e!=null&&(this.rr[r.selector]=e.filter(t=>t!==r),this.rr[r.selector].length===0&&(delete this.rr[r.selector],this.Sn=this.Sn.filter(t=>t!==r.selector)))}WE(r){if(!this.Qt||r.KE===!0)return;let e=!1;this.rt=r.target;let t=()=>{e||(e=!0,this.Qa&&this.Qa(r),this.er=it(this.rt),this.ke=null,this.H=ge(r),this._i=this.Li(this.H),this.Ur=Object.assign({},this.H),this.Ri=Object.assign({},this._i))};for(let n=0;n<this.Sn.length;n++)if(Bt(this.rt,this.Sn[n],this.container)){let o=this.rr[this.Sn[n]];if(o!=null){t();for(let s=0;s<o.length;s++){let a=this.rt,l=this.er;if(o[s].target){if(a=this.rt.closest(o[s].target),a==null)continue;l=it(a)}if(this.fu=o[s].start({pagePosition:this.H,e:r,el:a,size:l,translatedPosition:this._i}),this.fu!==!1){this.rt=a,this.er=l,this.ke=o[s],ae(r),r.KE=!0;break}}}}this.ke!=null&&(this.ge.on(document,ie,this.Pi),this.ge.on(document,oe,this.qa))}ZE(r){if(!this.Qt)return;let e=ge(r),t=this.Li(e);this.ke!=null&&(this.ke.constrainFunction&&(this.ke.usesPageCoordinates?(e=this.ke.constrainFunction(e,this.rt,{width:0,height:0},this.er,this.Ur,r),t=this.Li(e)):t=this.ke.constrainFunction(t,this.rt,{width:0,height:0},this.er,this.Ri,r)),this.ke.drag({e:r,el:this.rt,pagePosition:e,size:this.er,originalPagePosition:this.H,translatedPosition:t,originalTranslatedPosition:this._i}),this.Ur=e,this.Ri={x:t.x,y:t.y})}JE(r){this.Ur=ge(r),this.Ri=this.Li(this.Ur),this.ke!=null&&this.ke.stop({e:r,el:this.rt,pagePosition:this.Ur,size:this.er,originalPagePosition:this.H,translatedPosition:this.Ri,originalTranslatedPosition:this._i}),this.ie()}ie(){this.ge.off(document,ie,this.Pi),this.ge.off(document,oe,this.qa),this.ke=null,this.rt=null,this.er=null,this.H=null,this.Ur=null}destroy(){this.ge.off(this.container,ue,this.Ka),this.ie()}};var qp={FILL:"#FFFFFF",STROKE:"#000000",TEXT_COLOR:"#000000",STROKE_WIDTH:1.25},Oh="start",_h="center",Rh="end",kfe="Default",Wfe="Default shapes",sP="vjs-shape",Qp="vjs-shape-label",Lh="vjs-shape";var KD="http://www.w3.org/2000/svg",qD="http://www.w3.org/1999/xlink",QD="svg",eN="xlink",tN="html";function my(i){let r=document.getElementById(i);return r!=null?r.innerHTML:null}var ns=class extends Vo{constructor(r){super(r),this.namespaceHandlers[QD]=e=>document.createElementNS(KD,e.split(":")[1]),this.namespaceHandlers[tN]=e=>document.createElement(e.split(":")[1]),this.namespaces[eN]=qD}ce(r){return document.createElement(r)}cf(){return document.createDocumentFragment()}ctn(r){return document.createTextNode(r)}cc(r){return document.createComment(r)}Nd(){return my}removeElement(r){r.parentElement.removeChild(r)}removeTextNode(r){r.parentNode.removeChild(r)}};function br(i){return new ns(i||{})}var em="link",tm="clone",rm="trash",aP="cross",lP="plus",hP="circle",cP="gear",dP={x:0,y:0,width:32,height:32},wh={[tm]:{id:tm,viewBox:dP,shapes:[{tag:te,atts:{d:"M 6 24 L 2 24 L 2 2 L 24 2 L 24 6 M 8 8 L 30 8 L 30 30 L 8 30 Z",stroke:"currentColor","stroke-width":3,fill:"none","stroke-linejoin":"round"}}]},[em]:{id:em,viewBox:dP,shapes:[{tag:Z,atts:{x:0,y:0,width:32,height:32,fill:"transparent",stroke:"none"}},{tag:Xe,atts:{cx:5,cy:16,r:5,fill:"currentColor"}},{tag:te,atts:{d:"M 5 16 L 22 16",stroke:"currentColor","stroke-width":3,fill:"none"}},{tag:te,atts:{d:"M 22 16 L 20 8 L 30 16 L 20 24",fill:"currentColor"}}]},[rm]:{id:rm,viewBox:{x:0,y:0,width:32,height:32},atts:{fill:"none",stroke:"currentColor","stroke-linejoin":"round","stroke-width":"2"},shapes:[{tag:te,atts:{d:"M 7 30 L 4 2 L 28 2 L 25 30 Z","stroke-width":"3"}},{tag:te,atts:{d:"M 12 26 L 10 8"}},{tag:te,atts:{d:"M 20 26 L 22 8"}},{tag:te,atts:{d:"M 16 26 L 16 8.5"}}]},[aP]:{id:aP,viewBox:{x:0,y:0,width:32,height:32},atts:{fill:"none",stroke:"currentColor","stroke-width":3,"stroke-linecap":"round"},shapes:[{tag:te,atts:{d:"M 2 2 L 30 30"}},{tag:te,atts:{d:"M 30 2 L 2 30"}}]},[lP]:{id:lP,viewBox:{x:0,y:0,width:32,height:32},atts:{fill:"none",stroke:"currentColor","stroke-width":3,"stroke-linecap":"round"},shapes:[{tag:te,atts:{d:"M 16 2 L 16 30"}},{tag:te,atts:{d:"M 2 16 L 30 16"}}]},[hP]:{id:hP,viewBox:{x:0,y:0,width:32,height:32},atts:{fill:"none",stroke:"currentColor","stroke-width":3,"stroke-linecap":"round"},shapes:[{tag:Xe,atts:{cx:16,cy:16,r:15}}]},[cP]:{id:cP,viewBox:{x:0,y:0,width:32,height:32},atts:{},shapes:[{tag:te,atts:{"fill-rule":"evenodd",d:"M 16.0000,4.5000 L 18.1126,3.3755 L 18.6424,1.7428 L 20.8402,2.3317 L 20.4827,4.0106 L 21.7500,6.0407 L 24.1418,6.1232 L 25.4170,4.9741 L 27.0259,6.5830 L 25.8768,7.8582 L 25.9593,10.2500 L 27.9894,11.5173 L 29.6683,11.1598 L 30.2572,13.3576 L 28.6245,13.8874 L 27.5000,16.0000 L 28.6245,18.1126 L 30.2572,18.6424 L 29.6683,20.8402 L 27.9894,20.4827 L 25.9593,21.7500 L 25.8768,24.1418 L 27.0259,25.4170 L 25.4170,27.0259 L 24.1418,25.8768 L 21.7500,25.9593 L 20.4827,27.9894 L 20.8402,29.6683 L 18.6424,30.2572 L 18.1126,28.6245 L 16.0000,27.5000 L 13.8874,28.6245 L 13.3576,30.2572 L 11.1598,29.6683 L 11.5173,27.9894 L 10.2500,25.9593 L 7.8582,25.8768 L 6.5830,27.0259 L 4.9741,25.4170 L 6.1232,24.1418 L 6.0407,21.7500 L 4.0106,20.4827 L 2.3317,20.8402 L 1.7428,18.6424 L 3.3755,18.1126 L 4.5000,16.0000 L 3.3755,13.8874 L 1.7428,13.3576 L 2.3317,11.1598 L 4.0106,11.5173 L 6.0407,10.2500 L 6.1232,7.8582 L 4.9741,6.5830 L 6.5830,4.9741 L 7.8582,6.1232 L 10.2500,6.0407 L 11.5173,4.0106 L 11.1598,2.3317 L 13.3576,1.7428 L 13.8874,3.3755 Z M 23.2500,16.0000 A 7.25,7.25 0 1 0 8.7500,16.0000 A 7.25,7.25 0 1 0 23.2500,16.0000 Z"}}]}};function aye(i,r){let e=typeof i=="string"?wh[i]:i;if(e==null)return null;{let t=Object.assign({},e);return t.id=r,t}}function nm(i,r,e,t,n,o,s){t=t||[],n=n||{};let a=Object.assign({viewBox:`0 0 ${i.viewBox.width} ${i.viewBox.height}`,"pointer-events":"all",width:r,height:e},i.atts||{}),l=$(ve,Object.assign(n||{},a),null,t.join(" "));return i.shapes.forEach(h=>{let d=$(h.tag,Object.assign(h.atts,s||{}));l.appendChild(d)}),o&&o.appendChild(l),l}function im(i,r,e,t,n,o,s){return nm(wh[i],r,e,t,n,o,s)}var rN={x:0,y:0,width:32,height:32},nN={stroke:"currentColor",fill:"none"},gy=class extends HTMLElement{static get observedAttributes(){return["icon-id","width","height"]}findIcon(r){return wh[r]}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}render(){let r=this.getAttribute("icon-id"),e=this.getAttribute("width")||"32",t=this.getAttribute("height")||"32",n=this.findIcon(r)||wh[r];if(!n){this.innerHTML="";return}let o=n.viewBox||rN,s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",e),s.setAttribute("height",t),s.setAttribute("viewBox",`${o.x} ${o.y} ${o.width} ${o.height}`);let a=Wn(Wn({},nN),n.atts);for(let[l,h]of Object.entries(a))s.setAttribute(l,h);n.shapes.forEach(l=>{let h=document.createElementNS("http://www.w3.org/2000/svg",l.tag);for(let[d,u]of Object.entries(l.atts))h.setAttribute(d,u);s.appendChild(h)}),this.innerHTML="",this.appendChild(s)}};customElements.define("vjs-icon",gy);var iN="label",uP="transform",pP="x",mP="y",om="origin",gP="originX",EP="originY",oN="orientation",fP="size",yP="key",sN="iconId",ba="middle",Ey="type",sm="category",xP="horizontal",Yye="vertical",am="vjs-shape-icon",aN="vjs-include-icon",lN="vjs-include-icons",hN="category",cN="type",ro="__vjsRootSet",to=iN,fy="fill",Dh="outline",Nh="outlineWidth",yy="color",Ih="#FFFFFF",is="#000000",Mh=2,bP="#000000",dN=.8,Aa=class{constructor(r,e){c(this,"compiledShapes",new Map);c(this,"templateRenderer",br({defaultNamespace:"svg"}));c(this,"shapeSets",new Map);c(this,"defaultCategoryId");c(this,"labelPosition");c(this,"rootSet");c(this,"iconContainerTemplate",`<svg:svg class="${am}" x="{{x}}" y="{{y}}" viewBox="{{viewBox}}" width="{{width}}" height="{{height}}" style="overflow:visible"/>`);c(this,"iconContainerAst");c(this,"iconSpecs",new Map);c(this,"iconList",[]);c(this,"typeParameter");c(this,"categoryParameter");c(this,"multilineLabels");c(this,"labelFillRatio");e=e||{},r==null?(U("WARN: no shapes were provided to shape library."),r=[]):Array.isArray(r)||(r=[r]),this.typeParameter=e.typeParameter||cN,this.categoryParameter=e.categoryParameter||hN,this.multilineLabels=e.multilineLabels!==!1,this.labelFillRatio=e.labelFillRatio||dN,this.labelPosition=e.labelPosition||"center",this.qE(r),this.defaultCategoryId=this.rootSet.children.length>0?this.rootSet.children[0].id:xe,this.iconContainerAst=this.templateRenderer.parse(this.iconContainerTemplate)}useMultilineLabels(){return this.multilineLabels}refresh(r,e,t){this.QE(r,e);let n=r.closest(".vjs-shape")||r;this.$applyMultilineLabel(n.querySelector(":scope > .vjs-shape-label"),e,t||to)}qE(r){let e=(t,n)=>{let o=[];return t!=null&&t.forEach(s=>{let a=Object.assign(s,{parent:n,children:e(s.children,s.id)});if(this.shapeSets.set(a.id,a),a.icons){let l=ws(this.iconSpecs,a.id,()=>new Map);a.icons.forEach(h=>{l.set(h.id,h)}),this.iconList.push(...a.icons)}o.push(a)}),o};this.rootSet={children:e(r,ro),parent:null,id:ro,name:ro,shapes:[]}}getShapeSet(r){return this.shapeSets.get(r)}getShapeDefinition(r,e){return e=e||this.defaultCategoryId,this.shapeSets.get(e).shapes.find(t=>t.type===r)}$getShapeDefinitionForObject(r,e,t){let n=e||this.typeParameter,o=t||this.categoryParameter;return this.getShapeDefinition(r[n],r[o])}getShapeTemplate(r,e){let t=this.getShapeDefinition(r,e);return t==null?(U(`Cannot find shape [${r}] in set [${e}]. Returning default shape.`),this.ef()):t.template}getCompiledShape(r,e){let t=this.tf(r,e);if(!this.compiledShapes.has(t)){let n=this.templateRenderer.parse(this.getShapeTemplate(r,e)),o=s=>this.templateRenderer.render(n,s).fragment;this.compiledShapes.set(t,o)}return this.compiledShapes.get(t)}rf(r){r.setAttribute&&r.setAttribute(mp,gp),r.hasChildNodes&&r.childNodes.forEach(e=>this.rf(e))}renderCompiledShape(r,e,t,n){e=r.outlineWidth||e||1;let o=t||this.typeParameter,s=n||this.categoryParameter,a=this.getShapeDefinition(r[o],r[s]),l=a.square?Math.min(r.width,r.height):r.width,h=a.square?Math.min(r.width,r.height):r.height;return this.getCompiledShape(r[o],r[s])(Object.assign({outlineWidth:e},r,{width:l,height:h})).childNodes[0]}renderShapeLabel(r,e,t,n,o,s,a){e=e||to;let l=$(Je,{x:"50%",y:"50%",fill:o,stroke:s,"text-anchor":ba,"dominant-baseline":ba,class:Qp,"stroke-width":t||"0.25px"});l.textContent=n||r[e]||"";let h=r.fontSize||(a==null?void 0:a.size),d=r.fontStyle||(a==null?void 0:a.style),u=r.fontWeight||(a==null?void 0:a.weight),p=r.fontFamily||(a==null?void 0:a.family);return h&&l.setAttribute("font-size",h.toString()),d&&l.setAttribute("font-style",d),u&&l.setAttribute("font-weight",u),p&&l.setAttribute("font-family",p),l}tf(r,e){return e=e||this.defaultCategoryId,[r,e].join(":")}nf(r,e,t){return{center:{x:"{{width/2}}",y:"{{height/2}}",transform:"",textAnchor:ba,dominantBaseline:ba},top:{x:"{{width/2}}",y:"0",transform:`translate(0, -${e+t})`,textAnchor:ba,dominantBaseline:"hanging"},bottom:{x:"{{width/2}}",y:"{{height}}",transform:`translate(0, ${t})`,textAnchor:ba,dominantBaseline:"auto"}}[r]}of(r,e,t=to){let n={};return this.shapeSets.forEach(o=>{o.shapes.forEach(s=>{let a=s.font||e,l=a==null?14:a.size||14,h=a==null?"normal":a.style||"normal",d=a==null?"normal":a.weight||"normal",u=(a==null?void 0:a.family)||"",p=s.labelPosition||this.labelPosition,{x:m,y:g,transform:E,textAnchor:y,dominantBaseline:x}=this.nf(p,l,20),b=(s.collapsedTemplate==null?s.template:`<svg:g ${Bp}>${s.template}</svg:g><svg:g ${Fp}>${s.collapsedTemplate}</svg:g>`)+(r?`<svg:text x="${m}" y="${g}" transform="${E}" fill="{{color}}" stroke="{{color}}" stroke-width="0.25px" text-anchor="${y}" dominant-baseline="${x}" class="${Qp}" font-size="{{fontSize || ${l}}}" font-style="{{fontStyle || '${h}'}}" font-weight="{{fontWeight || '${d}'}}" font-family="{{fontFamily || '${u}'}}">{{${t}}}</svg:text>`:"");n[`${o.id}:${s.type}`]=b,n[`${xe}:${s.type}`]=b})}),n}getShapeTagDefinition(r,e,t,n={size:14,style:"normal"},o=to,s=Ih,a=is,l=is,h=Mh){return e=e||h,{template:r?`<svg:g class="${Lh}" fill="{{fill}}" stroke="{{outline}}" stroke-width="{{outlineWidth}}">
5
5
  <r-fragment key="${sm}:${Ey}"/>
6
6
  </svg:g>`:`<svg:svg class="${Lh}" fill="{{fill}}" stroke="{{outline}}" viewBox="0 0 {{width}} {{height}}" preserveAspectRatio="none" stroke-width="{{outlineWidth}}">
7
7
  <r-fragment key="${sm}:${Ey}"/>