if(!_.sankey){_.sankey=1;(function($){var SS=function(a,b){$.Yq.call(this);this.Aa=a;this.je=b;this.gb=null;var c={};$.T(c,[["fill",0,8192],["stroke",0,8192],["labels",0,0]]);this.ca=new $.Yx(this,c,$.Zl);$.W(this,"normal",this.ca);this.ca.pa("labelsFactoryConstructor",$.Zx);this.ca.pa("labelsAfterInitCallback",$.dy);this.xa=new $.Yx(this,c,$.po);$.W(this,"hovered",this.xa);this.xa.pa("labelsFactoryConstructor",$.$x);this.xa.pa("labelsAfterInitCallback",function(a){a.I(4294967295)})},TS=function(a,b){$.gx.call(this);this.Fa("sankey");
$.eu(this,this,this.rg,this.Gg,null,this.rg,null,null);$.T(this.ua,qfa);this.data(a||null,b);this.EQ=(0,$.pa)(this.EQ,this);this.CQ=(0,$.pa)(this.CQ,this)},US=function(a,b){for(var c=b.AD,d=0;d<c.length;d++){var e=c[d];b.level>=e.level&&(e.level=b.level+1,US(a,e));e.level>a.G&&(a.G=e.level)}},WS=function(a,b){return b?(a.tf[b]||(a.tf[b]={type:VS,name:b,level:0,nM:0,kN:0,YF:0,aH:[],AD:[],z1:[],W2:[],N_:[],Qna:[],$na:[],Zx:[],py:[],gR:!1}),a.tf[b]):null},YS=function(a,b){var c=b.type,d;if(c==VS){var e=
b.name;a.isConflict={value:b.gR,type:"string"};var f=[];for(d=0;d<b.aH.length;d++){var h=b.aH[d];var k=$.xa(h.AD,function(a){return a==b});f.push({name:h.name,value:h.W2[k]})}a.income={value:f,type:""};f=[];for(d=0;d<b.AD.length;d++)h=b.AD[d],k=$.xa(h.aH,function(a){return a==b}),f.push({name:h.name,value:h.z1[k]});a.outcome={value:f,type:""};a.dropoff={value:b.YF,type:"number"}}else e=c==XS?b.from.name+" -> "+b.Cf.name:b.from.name+" dropoff";a.type={value:rfa[c],type:"string"};a.name={value:e,type:"string"};
a.value={value:b.weight,type:"number"}},ZS=function(a,b,c){c=c?a.node().mb().labels():a.node().Sa().labels();a=a.node().Sa().labels();c=c.i("position");a=a.i("position");a=$.Ck(c||a,"center");var d=c=0,e=(b.qj+b.rj)/2,f=(b.se+b.Xe)/2;switch(a){case "left-top":c=b.qj;d=b.se;break;case "left-center":c=b.qj;d=f;break;case "left-bottom":c=b.qj;d=b.Xe;break;case "center-top":c=e;d=b.se;break;case "center":c=e;d=f;break;case "center-bottom":c=e;d=b.Xe;break;case "right-top":c=b.rj;d=b.se;break;case "right-center":c=
b.rj;d=f;break;case "right-bottom":c=b.rj,d=b.Xe}return{value:{x:c,y:d}}},aT=function(a,b,c,d,e,f){for(var h,k,l=0;l<b.length;l++)h=b[l],k=h.path,$S(a,a.b,k.tag,k,d),h.label.Vk(c),h.label.uc({value:e(h,f)}),a.ce(a.b,h,d)},$S=function(a,b,c,d,e){c=a.Ae(c);a=b.Gm(e,c);b=b.bl(e,c);d.fill(a);d.stroke(b)},bT=function(a,b,c,d,e,f){var h=b.tag;$S(a,a.f,h,b,c);b=h.element;aT(a,b.Zx,d,c,f,"leftTop");aT(a,b.py,e,c,f,"rightTop");b.label.uc(ZS(a,b,c));a.ce(a.f,b,c)},cT=function(a,b,c){b=b.tag;var d=b.element;
$S(a,a.b,b,d.path,c);d.label.Vk("center-bottom");d.label.uc({value:a.iX(d)});$S(a,a.f,d.from.path.tag,d.from.path,c);$S(a,a.f,d.Cf.path.tag,d.Cf.path,c);a.ce(a.b,d,c)},dT=function(a,b,c){var d=b.tag;$S(a,a.j,d,b,c);a.ce(a.j,d.element,c)},eT=function(a){return(a.se+a.Xe)/2},sfa=function(a,b){for(var c=0;c<a.g.length;c++)for(var d=a.g[c].tf,e=0;e<d.length;e++){var f=d[e];if(f.Zx.length){var h=(0,$.Fg)(f.Zx,function(a,b){return a+eT(b.from)*b.weight},0,a),k=(0,$.Fg)(f.Zx,function(a,b){return a+b.weight},
0,a);h=(h/k-eT(f))*b;f.se+=h;f.Xe+=h}}},tfa=function(a,b){for(var c=a.g.slice(),d=0;d<c.length;d++)for(var e=a.g[d].tf,f=0;f<e.length;f++){var h=e[f];if(h.py.length){var k=(0,$.Fg)(h.py,function(a,b){return a+eT(b.Cf)*b.weight},0,a),l=(0,$.Fg)(h.py,function(a,b){return a+b.weight},0,a);k=(k/l-eT(h))*b;h.se+=k;h.Xe+=k}}},fT=function(a,b){for(var c=0;c<a.g.length;c++){var d=a.g[c].tf.slice(),e=b.top,f=e+b.height,h=d.length,k,l=a.i("nodePadding");d.sort(a.DQ);for(k=0;k<h;++k){var m=d[k];e-=m.se;0<e&&
(m.se+=e,m.Xe+=e);e=m.Xe+l}e=e-l-f;if(0<e)for(m.se=m.se-e,m.Xe=m.Xe-e,e=m.se,k=h-2;0<=k;--k)m=d[k],e=m.Xe+l-e,0<e&&(m.se-=e,m.Xe-=e),e=m.se}},gT=function(a,b,c){var d;for(d=0;d<b.length;d++){var e=b[d];$S(a,c,e.tag,e,$.Zl)}},hT=function(a,b){return new TS(a,b)};$.H(SS,$.Yq);$.xq(SS,["fill","stroke","labels"],"normal");$.g=SS.prototype;$.g.qa=$.Yq.prototype.qa|28672;$.g.Na=function(){return this.je};$.g.sg=function(){$.W(this,"normal",this.ca);$.W(this,"hovered",this.xa)};
$.g.Xa=function(a){this.gb||(this.gb=new $.iw(0),this.gb.Ye(),$.W(this,"tooltip",this.gb),this.gb.parent(this.Aa.Xa()),this.gb.Aa(this.Aa));return $.n(a)?(this.gb.K(a),this):this.gb};$.g.hp=function(){this.ta(16384)};$.g.Zd=function(){this.ta(4096)};$.g.GH=function(){this.ca.labels().I(4294967295);this.xa.labels().I(4294967295)};$.g.Sa=function(a){return $.n(a)?(this.ca.K(a),this):this.ca};$.g.mb=function(a){return $.n(a)?(this.xa.K(a),this):this.xa};$.g.Gm=function(a,b){return this.Cy("fill",a,b)};
$.g.bl=function(a,b){return this.Cy("stroke",a,b)};$.g.Cy=function(a,b,c){a=(b?this.xa:this.ca).i(a)||this.ca.i(a);$.E(a)&&(a=a.call(c,c));return a};$.g.F=function(){var a=SS.u.F.call(this);a.tooltip=this.Xa().F();a.normal=this.ca.F();a.hovered=this.xa.F();return a};$.g.X=function(a,b){SS.u.X.call(this,a,b);"tooltip"in a&&this.Xa().ia(!!b,a.tooltip);this.ca.ia(!!b,a);this.ca.ia(!!b,a.normal);this.xa.ia(!!b,a.hovered)};$.g.R=function(){$.td(this.gb,this.ca,this.xa);SS.u.R.call(this)};var iT=SS.prototype;
iT.tooltip=iT.Xa;iT.normal=iT.Sa;iT.hovered=iT.mb;$.H(TS,$.gx);$.uz(TS,"sankey",["appearance","data","flowlabels","nodelabels"]);TS.prototype.qa=$.gx.prototype.qa;var jT={};$.hq(jT,[[0,"nodeWidth",$.Qq],[0,"nodePadding",$.qq],[0,"curveFactor",$.Tq]]);$.U(TS,jT);var qfa=[["nodeWidth",4,1],["nodePadding",4,1],["curveFactor",4,1]];$.g=TS.prototype;
$.g.data=function(a,b){if($.n(a)){if(a){var c=a.title||a.caption;c&&this.title(c);a.rows&&(a=a.rows)}this.jg!==a&&(this.jg=a,$.qd(this.oa),$.qd(this.jd),this.Nd=null,$.K(a,$.pr)?this.oa=a.tj():this.oa=$.K(a,$.zr)?a.ie():(this.jd=new $.zr($.A(a)||$.z(a)?a:null,b)).ie(),$.L(this.oa,this.Id,this),this.B(256),$.br(this,"sankey","data",1));return this}return this.oa};$.g.Id=function(){this.B(256);$.br(this,"sankey","data",1)};$.g.Qf=function(){return this.oa.aa()};$.g.vc=function(){return this.Nd=this.oa.aa()};
$.g.aa=function(){return this.Nd||(this.Nd=this.oa.aa())};$.g.Na=function(){return"sankey"};
$.g.ob=function(){if($.er(this,"sankey","data")){this.tf={};this.D={};this.G=-1;for(var a=this.aa().reset();a.advance();){var b=String(a.get("from"));var c=a.get("to");c=null===c||$.D(c)?null:String(c);var d=$.N(a.get("weight"));var e=!b.length;var f=null!==c&&!c.length;$.ea(d)&&0<d&&!e&&!f&&(b=WS(this,b),e=WS(this,c),c=b,b=e,e=this.aa().la(),this.D[e]={type:b?XS:kT,Yi:e,from:c,Cf:b,weight:d},c.kN+=d,b?(c.py.push(this.D[e]),c.W2.push(d),c.AD.push(b),b.nM+=d,b.z1.push(d),b.aH.push(c),b.Zx.push(this.D[e]),
c.level>=b.level&&(b.level=c.level+1,US(this,b)),b.level>this.G&&(this.G=b.level)):(c.YF+=d,c.N_.push(d)))}this.g=[];this.ya=!0;for(var h in this.tf)d=this.tf[h],d.weight=Math.max(d.nM,d.kN),a=d.AD.length+d.N_.length,this.ya&&!a&&(d.level=this.G),d.aH.length&&a&&(d.gR=d.nM!=d.kN),a=d.level,this.g[a]||(this.g[a]={tf:[],weight:0,top:window.NaN}),a=this.g[a],a.tf.push(d),a.weight+=d.weight;for(d=h=0;d<this.g.length;d++)for(a=this.g[d],c=0;c<a.tf.length;c++)a.tf[c].id=h++;this.B(4);$.dr(this,"sankey",
"data")}};$.g.Ej=function(){return!this.aa().Gb()};$.g.Te=function(){return[]};$.g.hp=function(){this.Xa().$()};$.g.DF=function(a,b){if(!this.U||b)this.U=new $.rw;var c={};YS(c,a);if(a.type!=VS){var d=this.aa();d.select(a.Yi);this.U.Ag(d)}else this.U.Ag(null);return $.av(this.U,c)};$.g.fC=function(a){this.wl||(this.wl=new $.rw);var b={};a=a.element;YS(b,a);if(a.type!=VS){var c=this.aa();c.select(a.Yi);this.wl.Ag(c)}else this.wl.Ag(null);return $.av(this.wl,b)};
$.g.Eea=function(a,b){return{x:a[b].x,y:a[b].y}};$.g.iX=function(a){return{x:(a.left+a.right)/2,y:a.topCenter}};$.g.rg=function(a){var b=a.domTarget,c=b.tag;if(c){var d=c.element.type;d==VS?(d=this.f.Xa(),bT(this,b,$.po,"left-bottom","right-bottom",this.Eea)):d==XS?(d=this.b.Xa(),cT(this,b,$.po)):(d=this.j.Xa(),dT(this,b,$.po));$.Aw(d,a.clientX,a.clientY,this.fC(c))}else this.Xa().Oc()};
$.g.Gg=function(a){a=a.domTarget;var b=a.tag;this.Xa().Oc();b&&(b=b.element.type,b==VS?bT(this,a,$.Zl,"center-bottom","center-bottom",this.iX):b==XS?cT(this,a,$.Zl):dT(this,a,$.Zl))};$.g.eS=function(a){var b=[];$.X(a,8192)&&b.push("appearance");$.X(a,4096)&&(a=a.target.Na()==VS,b.push(a?"nodelabels":"flowlabels"));$.cr(this,"sankey",b,1)};$.g.hL=function(a){this.j||(this.j=new SS(this,kT),$.W(this,"dropoff",this.j),this.j.sg(),$.L(this.j,this.eS,this));return $.n(a)?(this.j.K(a),this):this.j};
$.g.xL=function(a){this.b||(this.b=new SS(this,XS),$.W(this,"flow",this.b),this.b.sg(),$.L(this.b,this.eS,this));return $.n(a)?(this.b.K(a),this):this.b};$.g.node=function(a){this.f||(this.f=new SS(this,VS),$.W(this,"node",this.f),this.f.sg(),$.L(this.f,this.eS,this));return $.n(a)?(this.f.K(a),this):this.f};
$.g.cc=function(a){if($.K(a,$.ys))return this.Ic($.ys,a),this;if($.K(a,$.vs))return this.Ic($.vs,a),this;$.D(a)&&"range"==a.type?this.Ic($.ys):($.D(a)||null==this.Ea)&&this.Ic($.vs);return $.n(a)?(this.Ea.K(a),this):this.Ea};$.g.Ic=function(a,b){if($.K(this.Ea,a))b&&this.Ea.K(b);else{var c=!!this.Ea;$.qd(this.Ea);this.Ea=new a;$.W(this,"palette",this.Ea);this.Ea.oq();b&&this.Ea.K(b);$.L(this.Ea,this.If,this);c&&$.br(this,"sankey","appearance",1)}};
$.g.If=function(a){$.X(a,2)&&$.br(this,"sankey","appearance",1)};$.g.Ae=function(a){var b=a.element;a=a.element.type;var c=this.cc();return a==VS?{id:b.id,name:b.name,sourceColor:c.nc(b.id),conflict:b.gR}:a==XS?{from:b.from.name,to:b.Cf.name,sourceColor:c.nc(b.from.id)}:{from:b.from.name,sourceColor:c.nc(b.from.id)}};var VS=0,XS=1,kT=2,rfa={0:"node",1:"flow",2:"dropoff"};$.g=TS.prototype;$.g.CQ=function(a,b){return this.DQ(a.from,b.from)};$.g.EQ=function(a,b){return this.DQ(a.Cf,b.Cf)};
$.g.DQ=function(a,b){return a.se-b.se};$.g.dU=function(a,b){return function(c){return a*(1-c)+b*c}};
$.g.ei=function(a){if(!this.ef()){this.ob();this.va||(this.va=this.La.Dd(),this.va.zIndex(30),this.node(),this.xL(),this.hL());if(this.J(4)){this.va.Ki();this.f.labels().B(2);this.b.labels().B(2);this.j.labels().B(2);this.N=[];this.ba=[];this.O=[];this.ga=[];var b=this.i("nodePadding"),c=this.i("nodeWidth");if(this.g.length){var d=this.g.length;var e=a.width/d;c=$.M(c,e);e=.3*c}else c=e=d=0;var f,h=[];for(f=0;f<this.g.length;f++){var k=this.g[f];var l=k.tf;var m=l[l.length-1].YF?e:0;l=(a.height-m-
b*(l.length-1))/k.weight;h.push(l)}this.ka=Math.min.apply(null,h);b=(a.width-c)/(d-1);for(f=0;f<this.g.length;f++)for(k=this.g[f],l=k.tf,k=0;k<l.length;k++)d=l[k],d.qj=a.left+d.level*b,d.rj=d.qj+c,d.se=a.top+k,d.Xe=d.se+d.weight*this.ka;for(var p in this.D)l=this.D[p],l.height=l.weight*this.ka;fT(this,a);l=1;for(f=32;0<f;--f)l*=.99,tfa(this,l),fT(this,a),sfa(this,l),fT(this,a);for(v in this.tf)d=this.tf[v],d.py.sort(this.EQ),d.Zx.sort(this.CQ);for(v in this.tf){d=this.tf[v];var q=b=d.se;for(f=0;f<
d.py.length;f++)l=d.py[f],l.se=q+l.height/2,q+=l.height;for(f=0;f<d.Zx.length;f++)l=d.Zx[f],l.Xe=b+l.height/2,b+=l.height}for(v in this.tf)d=this.tf[v],k=this.va.path(),k.zIndex(3),this.ba.push(k),k.tag={element:d},d.path=k,d.qj=$.R($.Qm(d.qj,4),1),d.se=$.R($.Qm(d.se,4),1),d.rj=$.R($.Qm(d.rj,4),1),d.Xe=$.R($.Qm(d.Xe,4),1),k.moveTo(d.qj,d.se).lineTo(d.rj,d.se).lineTo(d.rj,d.Xe).lineTo(d.qj,d.Xe).lineTo(d.qj,d.se).close();d=this.i("curveFactor");for(p in this.D)if(l=this.D[p],l.Cf){k=this.va.path();
k.zIndex(1);this.O.push(k);k.tag={element:l};l.path=k;a=l.from.rj;f=l.Cf.qj;q=l.se;b=l.Xe;m=this.dU(a,f);h=m(d);m=m(1-d);var r=l.height/2;l.left=a;l.right=f;l.topCenter=(q+b)/2-r;l.leftTop={x:a,y:q-r};l.rightTop={x:f,y:b-r};var t=q-r,u=b-r;q+=r;b+=r;k.moveTo(a,t).yk(h,t,m,u,f,u).lineTo(f,b).yk(m,b,h,q,a,q).lineTo(a,t);3>l.height&&(k=this.va.path(),k.zIndex(2),this.ga.push(k),k.fill($.Ul).stroke($.Ul,3),k.moveTo(a,t).yk(h,t,m,u,f,u).lineTo(f,b).yk(m,b,h,q,a,q).lineTo(a,t),k.tag={element:l})}else b=
l.from.YF*this.ka,m=Math.min(b,c/4),a=l.from.rj,f=a+m,h=l.from.Xe,b=h-b,k=this.va.path(),k.zIndex(1),this.N.push(k),k.tag={element:l},l.path=k,l.Hha=f,l.Iha=h,k.moveTo(a,b).arcTo(m,m,-90,90),b+m<h&&k.lineTo(f,h),k.lineTo((a+f)/2,h+e).lineTo(a,h).close();$.cr(this,"sankey",["appearance","nodelabels","flowlabels"]);this.I(4)}$.er(this,"sankey","appearance")&&(gT(this,this.ba,this.f),gT(this,this.O,this.b),gT(this,this.N,this.j),$.dr(this,"sankey","appearance"));if($.er(this,"sankey","nodelabels")){l=
this.f.labels();l.clear().P(this.va).zIndex(3);for(var v in this.tf)d=this.tf[v],a=d.id,c=this.DF(d,!0),e=ZS(this,d,$.Zl),d.label=l.add(c,e,a),this.ce(this.f,d,$.Zl);l.$();this.f.GH();$.dr(this,"sankey","nodelabels")}if($.er(this,"sankey","flowlabels")){v=this.b.labels();f=this.j.labels();v.clear().P(this.va).zIndex(3);f.clear().P(this.va).zIndex(3);for(p in this.D)l=this.D[p],a=$.N(p),d=l.Cf,c=this.DF(l,!0),d?(e={value:this.iX(l)},l.label=v.add(c,e,a),l.label.Vk("center-bottom")):(e={value:{x:l.Hha,
y:l.Iha}},l.label=f.add(c,e,a),l.label.Vk("left-center")),this.ce(d?this.b:this.j,l,$.Zl);v.$();f.$();this.b.GH();this.j.GH();$.dr(this,"sankey","flowlabels")}}};
$.g.ce=function(a,b,c){var d=b.label;if(d){var e=this.aa();a.Na()==VS?e.reset():e.select(b.Yi);b=e.get("normal");b=$.n(b)?b.label:void 0;var f=e.get("hovered");f=$.n(f)?f.label:void 0;b=$.Ro(b,e.get("label"),null);e=$.Ro(f,e.get("hoverLabel"),null);e=c?e:null;f=c?a.mb().labels():null;var h=a.Sa().labels();c=c?a.mb().labels().ma:null;var k=a.Sa().labels().ma,l=e&&$.n(e.enabled)?e.enabled:null,m=b&&$.n(b.enabled)?b.enabled:null,p=f&&null!==f.enabled()?f.enabled():null,q=h&&null!==h.enabled()?h.enabled():
null;a=!1;null!=l?a=l:null!=m?a=m:null!=p?a=p:a=q;a?(d.enabled(!0),d.state("labelOwnSettings",d.Ma,0),d.state("pointState",e,1),d.state("pointNormal",b,2),d.state("elementState",f,3),d.state("elementNormal",h,4),d.state("elementStateTheme",c,5),d.state("auto",d.zd,6),d.state("elementNormalTheme",k,7)):d.enabled(!1);d.$()}};$.g.At=function(){return[this]};$.g.mG=function(){return["from","to","weight"]};
$.g.F=function(){var a=TS.u.F.call(this);a.data=this.data().F();a.tooltip=this.Xa().F();a.palette=this.cc().F();a.dropoff=this.hL().F();a.flow=this.xL().F();a.node=this.node().F();$.Hq(this,jT,a);return{chart:a}};$.g.X=function(a,b){TS.u.X.call(this,a,b);"data"in a&&this.data(a.data);this.cc(a.palette);"tooltip"in a&&this.Xa().ia(!!b,a.tooltip);"dropoff"in a&&this.hL().ia(!!b,a.dropoff);"flow"in a&&this.xL().ia(!!b,a.flow);"node"in a&&this.node().ia(!!b,a.node);$.zq(this,jT,a,b)};
$.g.R=function(){$.td(this.Ea,this.j,this.b,this.f,this.gb,this.N,this.ba,this.O,this.ga,this.oa,this.jd);this.gb=this.f=this.b=this.j=this.Ea=null;this.N.length=0;this.ba.length=0;this.O.length=0;this.ga.length=0;this.Nd=this.jd=this.oa=null;TS.u.R.call(this)};var lT=TS.prototype;lT.getType=lT.Na;lT.data=lT.data;lT.noData=lT.Pm;lT.tooltip=lT.Xa;lT.dropoff=lT.hL;lT.flow=lT.xL;lT.node=lT.node;lT.palette=lT.cc;$.Jp.sankey=hT;$.F("anychart.sankey",hT);}).call(this,$)}
