/*
 Highcharts JS v8.0.4 (2020-03-10)

 (c) 2017-2019 Highsoft AS
 Authors: Jon Arild Nygard

 License: www.highcharts.com/license
*/
(function(a){"object"===typeof module&&module.exports?(a["default"]=a,module.exports=a):"function"===typeof define&&define.amd?define("highcharts/modules/venn",["highcharts"],function(v){a(v);a.Highcharts=v;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function v(a,g,e,f){a.hasOwnProperty(g)||(a[g]=f.apply(null,e))}a=a?a._modules:{};v(a,"mixins/draw-point.js",[],function(){var a=function(g){var e=this,f=e.graphic,a=g.animatableAttribs,u=g.onComplete,k=g.css,x=g.renderer;
if(e.shouldDraw())f||(e.graphic=f=x[g.shapeType](g.shapeArgs).add(g.group)),f.css(k).attr(g.attribs).animate(a,g.isNew?!1:void 0,u);else if(f){var w=function(){e.graphic=f=f.destroy();"function"===typeof u&&u()};Object.keys(a).length?f.animate(a,void 0,function(){w()}):w()}};return function(g){(g.attribs=g.attribs||{})["class"]=this.getClassName();a.call(this,g)}});v(a,"mixins/geometry.js",[],function(){return{getAngleBetweenPoints:function(a,g){return Math.atan2(g.x-a.x,g.y-a.y)},getCenterOfPoints:function(a){var g=
a.reduce(function(g,a){g.x+=a.x;g.y+=a.y;return g},{x:0,y:0});return{x:g.x/a.length,y:g.y/a.length}},getDistanceBetweenPoints:function(a,g){return Math.sqrt(Math.pow(g.x-a.x,2)+Math.pow(g.y-a.y,2))}}});v(a,"mixins/geometry-circles.js",[a["mixins/geometry.js"]],function(a){function g(c,b){b=Math.pow(10,b);return Math.round(c*b)/b}function e(c){if(0>=c)throw Error("radius of circle must be a positive number.");return Math.PI*c*c}function f(c,b){return c*c*Math.acos(1-b/c)-(c-b)*Math.sqrt(b*(2*c-b))}
function u(c,b){var a=t(c,b),h=c.r,e=b.r,f=[];if(a<h+e&&a>Math.abs(h-e)){h*=h;var k=(h-e*e+a*a)/(2*a);e=Math.sqrt(h-k*k);h=c.x;f=b.x;c=c.y;var n=b.y;b=h+k*(f-h)/a;k=c+k*(n-c)/a;c=e/a*-(n-c);a=e/a*-(f-h);f=[{x:g(b+c,14),y:g(k-a,14)},{x:g(b-c,14),y:g(k+a,14)}]}return f}function n(c){return c.reduce(function(c,a,g,e){e=e.slice(g+1).reduce(function(c,b,e){var h=[g,e+g+1];return c.concat(u(a,b).map(function(c){c.indexes=h;return c}))},[]);return c.concat(e)},[])}function k(c,b){return t(c,b)<=b.r+1e-10}
function x(c,b){return!b.some(function(b){return!k(c,b)})}function w(c){return n(c).filter(function(b){return x(b,c)})}var q=a.getAngleBetweenPoints,r=a.getCenterOfPoints,t=a.getDistanceBetweenPoints;return{getAreaOfCircle:e,getAreaOfIntersectionBetweenCircles:function(c){var b=w(c);if(1<b.length){var a=r(b);b=b.map(function(c){c.angle=q(a,c);return c}).sort(function(c,b){return b.angle-c.angle});var g=b[b.length-1];b=b.reduce(function(b,a){var g=b.startPoint,e=r([g,a]),f=a.indexes.filter(function(c){return-1<
g.indexes.indexOf(c)}).reduce(function(b,f){f=c[f];var h=q(f,a),k=q(f,g);h=k-(k-h+(k<h?2*Math.PI:0))/2;h=t(e,{x:f.x+f.r*Math.sin(h),y:f.y+f.r*Math.cos(h)});f=f.r;h>2*f&&(h=2*f);if(!b||b.width>h)b={r:f,largeArc:h>f?1:0,width:h,x:a.x,y:a.y};return b},null);if(f){var h=f.r;b.arcs.push(["A",h,h,0,f.largeArc,1,f.x,f.y]);b.startPoint=a}return b},{startPoint:g,arcs:[]}).arcs;if(0!==b.length&&1!==b.length){b.unshift(["M",g.x,g.y]);var e={center:a,d:b}}}return e},getCircleCircleIntersection:u,getCirclesIntersectionPoints:n,
getCirclesIntersectionPolygon:w,getCircularSegmentArea:f,getOverlapBetweenCircles:function(c,b,a){var h=0;a<c+b&&(a<=Math.abs(b-c)?h=e(c<b?c:b):(h=(c*c-b*b+a*a)/(2*a),a-=h,h=f(c,c-h)+f(b,b-a)),h=g(h,14));return h},isCircle1CompletelyOverlappingCircle2:function(c,b){return t(c,b)+b.r<c.r+1e-10},isPointInsideCircle:k,isPointInsideAllCircles:x,isPointOutsideAllCircles:function(c,b){return!b.some(function(b){return k(c,b)})},round:g}});v(a,"mixins/nelder-mead.js",[],function(){var a=function(a){a=a.slice(0,
-1);for(var g=a.length,f=[],u=function(a,g){a.sum+=g[a.i];return a},n=0;n<g;n++)f[n]=a.reduce(u,{sum:0,i:n}).sum/g;return f};return{getCentroid:a,nelderMead:function(g,e){var f=function(a,b){return a.fx-b.fx},u=function(a,b,g,f){return b.map(function(b,c){return a*b+g*f[c]})},n=function(a,b){b.fx=g(b);a[a.length-1]=b;return a},k=function(a){var b=a[0];return a.map(function(a){a=u(.5,b,.5,a);a.fx=g(a);return a})},x=function(a,b,f,e){a=u(f,a,e,b);a.fx=g(a);return a};e=function(a){var b=a.length,c=Array(b+
1);c[0]=a;c[0].fx=g(a);for(var f=0;f<b;++f){var e=a.slice();e[f]=e[f]?1.05*e[f]:.001;e.fx=g(e);c[f+1]=e}return c}(e);for(var w=0;100>w;w++){e.sort(f);var q=e[e.length-1],r=a(e),t=x(r,q,2,-1);t.fx<e[0].fx?(q=x(r,q,3,-2),e=n(e,q.fx<t.fx?q:t)):t.fx>=e[e.length-2].fx?t.fx>q.fx?(r=x(r,q,.5,.5),e=r.fx<q.fx?n(e,r):k(e)):(r=x(r,q,1.5,-.5),e=r.fx<t.fx?n(e,r):k(e)):e=n(e,t)}return e[0]}}});v(a,"modules/venn.btx.js",[a["parts/Globals.js"],a["mixins/draw-point.js"],a["mixins/geometry.js"],a["mixins/geometry-circles.js"],
a["mixins/nelder-mead.js"],a["parts/Color.js"],a["parts/Utilities.js"]],function(a,g,e,f,v,n,k){function u(a,b){var d=a.sets,l=b.reduce(function(a,b){var p=-1<d.indexOf(b.sets[0]);a[p?"internal":"external"].push(b.circle);return a},{internal:[],external:[]});l.external=l.external.filter(function(a){return l.internal.some(function(d){return!R(a,d)})});a=X(l.internal,l.external);b=J(a,l.internal,l.external);return{position:a,width:b}}function w(a){var d={},b={};if(0<a.length){var l=K(a),p=a.filter(A);
a.forEach(function(a){var m=a.sets,c=m.join();if(m=A(a)?l[c]:r(m.map(function(a){return l[a]})))d[c]=m,b[c]=u(a,p)})}return{mapOfIdToShape:d,mapOfIdToLabelValues:b}}var q=f.getAreaOfCircle,r=f.getAreaOfIntersectionBetweenCircles,t=f.getCircleCircleIntersection,c=f.getCirclesIntersectionPolygon,b=f.getOverlapBetweenCircles,R=f.isCircle1CompletelyOverlappingCircle2,h=f.isPointInsideAllCircles,S=f.isPointInsideCircle,F=f.isPointOutsideAllCircles,T=v.nelderMead,U=n.parse;n=k.addEvent;var V=k.animObject,
G=k.extend,z=k.isArray,y=k.isNumber,B=k.isObject,W=k.isString,H=k.merge;k=k.seriesType;var Y=e.getCenterOfPoints,C=e.getDistanceBetweenPoints;a=a.seriesTypes;var Z=function(a){return Object.keys(a).map(function(b){return a[b]})},aa=function(a){var d=0;2===a.length&&(d=a[0],a=a[1],d=b(d.r,a.r,C(d,a)));return d},L=function(a,b){return b.reduce(function(b,d){var p=0;1<d.sets.length&&(p=d.value,d=aa(d.sets.map(function(b){return a[b]})),d=p-d,p=Math.round(d*d*1E11)/1E11);return b+p},0)},M=function(a,
b,m,c,p){var d=a(b),f=a(m);p=p||100;c=c||1e-10;var l=m-b,g=1;if(b>=m)throw Error("a must be smaller than b.");if(0<d*f)throw Error("f(a) and f(b) must have opposite signs.");if(0===d)var e=b;else if(0===f)e=m;else for(;g++<=p&&0!==I&&l>c;){l=(m-b)/2;e=b+l;var I=a(e);0<d*I?b=e:m=e}return e},D=function(a,c,m){var d=a+c;return 0>=m?d:q(a<c?a:c)<=m?0:M(function(d){d=b(a,c,d);return m-d},0,d)},A=function(a){return z(a.sets)&&1===a.sets.length},E=function(a,b,c){b=b.reduce(function(b,d){d=d.r-C(a,d);return d<=
b?d:b},Number.MAX_VALUE);return b=c.reduce(function(b,d){d=C(a,d)-d.r;return d<=b?d:b},b)},X=function(a,b){var d=a.reduce(function(d,c){var m=c.r/2;return[{x:c.x,y:c.y},{x:c.x+m,y:c.y},{x:c.x-m,y:c.y},{x:c.x,y:c.y+m},{x:c.x,y:c.y-m}].reduce(function(d,c){var m=E(c,a,b);d.margin<m&&(d.point=c,d.margin=m);return d},d)},{point:void 0,margin:-Number.MAX_VALUE}).point;d=T(function(d){return-E({x:d[0],y:d[1]},a,b)},[d.x,d.y]);d={x:d[0],y:d[1]};h(d,a)&&F(d,b)||(d=1<a.length?Y(c(a)):{x:a[0].x,y:a[0].y});
return d},J=function(a,b,c){var d=b.reduce(function(a,b){return Math.min(b.r,a)},Infinity),m=c.filter(function(b){return!S(a,b)});c=function(d,c){return M(function(f){var e={x:a.x+c*f,y:a.y};e=h(e,b)&&F(e,m);return-(d-f)+(e?0:Number.MAX_VALUE)},0,d)};return 2*Math.min(c(d,-1),c(d,1))},N=function(a){var b=a.filter(function(a){return 2===a.sets.length}).reduce(function(a,b){b.sets.forEach(function(d,c,e){B(a[d])||(a[d]={overlapping:{},totalOverlap:0});a[d].totalOverlap+=b.value;a[d].overlapping[e[1-
c]]=b.value});return a},{});a.filter(A).forEach(function(a){G(a,b[a.sets[0]])});return a},O=function(a,b){return b.totalOverlap-a.totalOverlap},K=function(a){var b=[],d={};a.filter(function(a){return 1===a.sets.length}).forEach(function(a){d[a.sets[0]]=a.circle={x:Number.MAX_VALUE,y:Number.MAX_VALUE,r:Math.sqrt(a.value/Math.PI)}});var c=function(a,d){var c=a.circle;c.x=d.x;c.y=d.y;b.push(a)};N(a);var e=a.filter(A).sort(O);c(e.shift(),{x:0,y:0});var f=a.filter(function(a){return 2===a.sets.length});
e.forEach(function(a){var e=a.circle,g=e.r,m=a.overlapping,p=b.reduce(function(a,c,p){var l=c.circle,h=D(g,l.r,m[c.sets[0]]),k=[{x:l.x+h,y:l.y},{x:l.x-h,y:l.y},{x:l.x,y:l.y+h},{x:l.x,y:l.y-h}];b.slice(p+1).forEach(function(a){var b=a.circle;a=D(g,b.r,m[a.sets[0]]);k=k.concat(t({x:l.x,y:l.y,r:h},{x:b.x,y:b.y,r:a}))});k.forEach(function(b){e.x=b.x;e.y=b.y;var c=L(d,f);c<a.loss&&(a.loss=c,a.coordinates=b)});return a},{loss:Number.MAX_VALUE,coordinates:void 0});c(a,p.coordinates)});return d},P=function(a){var b=
{};return B(a)&&y(a.value)&&-1<a.value&&z(a.sets)&&0<a.sets.length&&!a.sets.some(function(a){var c=!1;!b[a]&&W(a)?b[a]=!0:c=!0;return c})},Q=function(a){a=z(a)?a:[];var b=a.reduce(function(a,b){P(b)&&A(b)&&0<b.value&&-1===a.indexOf(b.sets[0])&&a.push(b.sets[0]);return a},[]).sort(),c=a.reduce(function(a,c){P(c)&&!c.sets.some(function(a){return-1===b.indexOf(a)})&&(a[c.sets.sort().join()]=c);return a},{});b.reduce(function(a,b,c,d){d.slice(c+1).forEach(function(c){a.push(b+","+c)});return a},[]).forEach(function(a){if(!c[a]){var b=
{sets:a.split(","),value:0};c[a]=b}});return Z(c)},ba=function(a,b,c){var d=c.bottom-c.top,e=c.right-c.left;d=Math.min(0<e?1/e*a:1,0<d?1/d*b:1);return{scale:d,centerX:a/2-(c.right+c.left)/2*d,centerY:b/2-(c.top+c.bottom)/2*d}};k("venn","scatter",{borderColor:"#cccccc",borderDashStyle:"solid",borderWidth:1,brighten:0,clip:!1,colorByPoint:!0,dataLabels:{enabled:!0,verticalAlign:"middle",formatter:function(){return this.point.name}},inactiveOtherPoints:!0,marker:!1,opacity:.75,showInLegend:!1,states:{hover:{opacity:1,
borderColor:"#333333"},select:{color:"#cccccc",borderColor:"#000000",animation:!1},inactive:{opacity:.075}},tooltip:{pointFormat:"{point.name}: {point.value}"}},{isCartesian:!1,axisTypes:[],directTouch:!0,pointArrayMap:["value"],translate:function(){var a=this.chart;this.processedXData=this.xData;this.generatePoints();var b=Q(this.options.data);b=w(b);var c=b.mapOfIdToShape,e=b.mapOfIdToLabelValues;b=Object.keys(c).filter(function(a){return(a=c[a])&&y(a.r)}).reduce(function(a,b){var d=c[b];b=d.x-
d.r;var f=d.x+d.r,e=d.y+d.r;d=d.y-d.r;if(!y(a.left)||a.left>b)a.left=b;if(!y(a.right)||a.right<f)a.right=f;if(!y(a.top)||a.top>d)a.top=d;if(!y(a.bottom)||a.bottom<e)a.bottom=e;return a},{top:0,bottom:0,left:0,right:0});a=ba(a.plotWidth,a.plotHeight,b);var f=a.scale,g=a.centerX,h=a.centerY;this.points.forEach(function(a){var b=z(a.sets)?a.sets:[],d=b.join(),m=c[d],k,l=e[d]||{};d=l.width;l=l.position;var p=a.options&&a.options.dataLabels;m&&(m.r?k={x:g+m.x*f,y:h+m.y*f,r:m.r*f}:m.d&&(k={d:m.d.reduce(function(a,
b){"M"===b[0]?(b[1]=g+b[1]*f,b[2]=h+b[2]*f):"A"===b[0]&&(b[1]*=f,b[2]*=f,b[6]=g+b[6]*f,b[7]=h+b[7]*f);return a.concat(b)},[]).join(" ")}),l?(l.x=g+l.x*f,l.y=h+l.y*f):l={},y(d)&&(d=Math.round(d*f)));a.shapeArgs=k;l&&k&&(a.plotX=l.x,a.plotY=l.y);d&&k&&(a.dlOptions=H(!0,{style:{width:d}},B(p)&&p));a.name=a.options.name||b.join("\u2229")})},drawPoints:function(){var a=this,b=a.chart,c=a.group,f=b.renderer;(a.points||[]).forEach(function(d){var e={zIndex:z(d.sets)?d.sets.length:0},g=d.shapeArgs;b.styledMode||
G(e,a.pointAttribs(d,d.state));d.draw({isNew:!d.graphic,animatableAttribs:g,attribs:e,group:c,renderer:f,shapeType:g&&g.d?"path":"circle"})})},pointAttribs:function(a,b){var c=this.options||{};a=H(c,{color:a&&a.color},a&&a.options||{},b&&c.states[b]||{});return{fill:U(a.color).setOpacity(a.opacity).brighten(a.brightness).get(),stroke:a.borderColor,"stroke-width":a.borderWidth,dashstyle:a.borderDashStyle}},animate:function(a){if(!a){var b=V(this.options.animation);this.points.forEach(function(a){var c=
a.shapeArgs;if(a.graphic&&c){var d={},e={};c.d?d.opacity=.001:(d.r=0,e.r=c.r);a.graphic.attr(d).animate(e,b);c.d&&setTimeout(function(){a&&a.graphic&&a.graphic.animate({opacity:1})},b.duration)}},this)}},utils:{addOverlapToSets:N,geometry:e,geometryCircles:f,getLabelWidth:J,getMarginFromCircles:E,getDistanceBetweenCirclesByOverlap:D,layoutGreedyVenn:K,loss:L,nelderMead:v,processVennData:Q,sortByTotalOverlap:O}},{draw:g,shouldDraw:function(){return!!this.shapeArgs},isValid:function(){return y(this.value)}});
n(a.venn,"afterSetOptions",function(a){var b=a.options.states;this.is("venn")&&Object.keys(b).forEach(function(a){b[a].halo=!1})})});v(a,"masters/modules/venn.btx.js",[],function(){})});
//# sourceMappingURL=venn.js.map