/*
 Highcharts JS v7.1.3 (2019-08-14)

 (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(r){a(r);a.Highcharts=r;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function r(a,e,b,w){a.hasOwnProperty(e)||(a[e]=w.apply(null,b))}a=a?a._modules:{};r(a,"mixins/draw-point.js",[],function(){var a=function(e){var b=this,a=b.graphic,l=e.animatableAttribs,h=e.onComplete,B=e.css,t=e.renderer;
if(b.shouldDraw())a||(b.graphic=a=t[e.shapeType](e.shapeArgs).add(e.group)),a.css(B).attr(e.attribs).animate(l,e.isNew?!1:void 0,h);else if(a){var p=function(){b.graphic=a=a.destroy();"function"===typeof h&&h()};Object.keys(l).length?a.animate(l,void 0,function(){p()}):p()}};return function(e){(e.attribs=e.attribs||{})["class"]=this.getClassName();a.call(this,e)}});r(a,"mixins/geometry.js",[],function(){return{getAngleBetweenPoints:function(a,e){return Math.atan2(e.x-a.x,e.y-a.y)},getCenterOfPoints:function(a){var e=
a.reduce(function(b,a){b.x+=a.x;b.y+=a.y;return b},{x:0,y:0});return{x:e.x/a.length,y:e.y/a.length}},getDistanceBetweenPoints:function(a,e){return Math.sqrt(Math.pow(e.x-a.x,2)+Math.pow(e.y-a.y,2))}}});r(a,"mixins/geometry-circles.js",[a["mixins/geometry.js"]],function(a){var e=a.getAngleBetweenPoints,b=a.getCenterOfPoints,w=a.getDistanceBetweenPoints,l=function(a,c){c=Math.pow(10,c);return Math.round(a*c)/c},h=function(a){if(0>=a)throw Error("radius of circle must be a positive number.");return Math.PI*
a*a},C=function(a,c){return a*a*Math.acos(1-c/a)-(a-c)*Math.sqrt(c*(2*a-c))},t=function(a,c){var b=w(a,c),e=a.r,g=c.r,y=[];if(b<e+g&&b>Math.abs(e-g)){e*=e;var v=(e-g*g+b*b)/(2*b);g=Math.sqrt(e-v*v);e=a.x;y=c.x;a=a.y;var h=c.y;c=e+v*(y-e)/b;v=a+v*(h-a)/b;a=g/b*-(h-a);b=g/b*-(y-e);y=[{x:l(c+a,14),y:l(v-b,14)},{x:l(c-a,14),y:l(v+b,14)}]}return y},p=function(a){return a.reduce(function(a,b,e,g){g=g.slice(e+1).reduce(function(a,c,g){var n=[e,g+e+1];return a.concat(t(b,c).map(function(a){a.indexes=n;return a}))},
[]);return a.concat(g)},[])},q=function(a,c){return w(a,c)<=c.r+1e-10},u=function(a,c){return!c.some(function(c){return!q(a,c)})};return{getAreaOfCircle:h,getAreaOfIntersectionBetweenCircles:function(a){var c=p(a).filter(function(c){return u(c,a)});if(1<c.length){var g=b(c);c=c.map(function(a){a.angle=e(g,a);return a}).sort(function(a,c){return c.angle-a.angle});var x=c[c.length-1];c=c.reduce(function(c,g){var x=c.startPoint,h=b([x,g]),n=g.indexes.filter(function(a){return-1<x.indexes.indexOf(a)}).reduce(function(c,
b){b=a[b];var n=e(b,g),l=e(b,x);n=l-(l-n+(l<n?2*Math.PI:0))/2;n=w(h,{x:b.x+b.r*Math.sin(n),y:b.y+b.r*Math.cos(n)});b=b.r;n>2*b&&(n=2*b);if(!c||c.width>n)c={r:b,largeArc:n>b?1:0,width:n,x:g.x,y:g.y};return c},null);if(n){var l=n.r;c.arcs.push(["A",l,l,0,n.largeArc,1,n.x,n.y]);c.startPoint=g}return c},{startPoint:x,arcs:[]}).arcs;if(0!==c.length&&1!==c.length){c.unshift(["M",x.x,x.y]);var h={center:g,d:c}}}return h},getCircleCircleIntersection:t,getCirclesIntersectionPoints:p,getCircularSegmentArea:C,
getOverlapBetweenCircles:function(a,c,b){var e=0;b<a+c&&(b<=Math.abs(c-a)?e=h(a<c?a:c):(e=(a*a-c*c+b*b)/(2*b),b-=e,e=C(a,a-e)+C(c,c-b)),e=l(e,14));return e},isPointInsideCircle:q,isPointInsideAllCircles:u,isPointOutsideAllCircles:function(a,c){return!c.some(function(c){return q(a,c)})},round:l}});r(a,"mixins/nelder-mead.js",[],function(){var a=function(a){a=a.slice(0,-1);for(var b=a.length,e=[],l=function(a,b){a.sum+=b[a.i];return a},h=0;h<b;h++)e[h]=a.reduce(l,{sum:0,i:h}).sum/b;return e};return{getCentroid:a,
nelderMead:function(e,b){var w=function(a,b){return a.fx-b.fx},l=function(a,b,e,g){return b.map(function(b,c){return a*b+e*g[c]})},h=function(a,b){b.fx=e(b);a[a.length-1]=b;return a},r=function(a){var b=a[0];return a.map(function(a){a=l(.5,b,.5,a);a.fx=e(a);return a})},t=function(a,b,g,h){a=l(g,a,h,b);a.fx=e(a);return a};b=function(a){var b=a.length,c=Array(b+1);c[0]=a;c[0].fx=e(a);for(var g=0;g<b;++g){var h=a.slice();h[g]=h[g]?1.05*h[g]:.001;h.fx=e(h);c[g+1]=h}return c}(b);for(var p=0;100>p;p++){b.sort(w);
var q=b[b.length-1],u=a(b),g=t(u,q,2,-1);g.fx<b[0].fx?(q=t(u,q,3,-2),b=h(b,q.fx<g.fx?q:g)):g.fx>=b[b.length-2].fx?g.fx>q.fx?(u=t(u,q,.5,.5),b=u.fx<q.fx?h(b,u):r(b)):(u=t(u,q,1.5,-.5),b=u.fx<g.fx?h(b,u):r(b)):b=h(b,g)}return b[0]}}});r(a,"modules/venn.src.js",[a["mixins/draw-point.js"],a["mixins/geometry.js"],a["mixins/geometry-circles.js"],a["mixins/nelder-mead.js"],a["parts/Globals.js"],a["parts/Utilities.js"]],function(a,e,b,r,l,h){var w=r.nelderMead,t=h.isArray,p=h.isNumber,q=h.isObject,u=h.isString;
h=l.addEvent;var g=l.Color,c=l.extend,n=b.getAreaOfCircle,x=b.getAreaOfIntersectionBetweenCircles,B=b.getCircleCircleIntersection,y=e.getCenterOfPoints,v=e.getDistanceBetweenPoints,F=b.getOverlapBetweenCircles,G=b.isPointInsideAllCircles,S=b.isPointInsideCircle,J=b.isPointOutsideAllCircles,H=l.merge,T=l.seriesType,I=l.seriesTypes,U=function(a){return Object.keys(a).map(function(b){return a[b]})},V=function(a){var b=0;2===a.length&&(b=a[0],a=a[1],b=F(b.r,a.r,v(b,a)));return b},K=function(a,b){return b.reduce(function(b,
k){var d=0;1<k.sets.length&&(d=k.value,k=V(k.sets.map(function(b){return a[b]})),k=d-k,d=Math.round(k*k*1E11)/1E11);return b+d},0)},L=function(a,b,f,c,d){var k=a(b),e=a(f);d=d||100;c=c||1e-10;var m=f-b,z=1;if(b>=f)throw Error("a must be smaller than b.");if(0<k*e)throw Error("f(a) and f(b) must have opposite signs.");if(0===k)var g=b;else if(0===e)g=f;else for(;z++<=d&&0!==h&&m>c;){m=(f-b)/2;g=b+m;var h=a(g);0<k*h?b=g:f=g}return g},D=function(a,b,f){var k=a+b;return 0>=f?k:n(a<b?a:b)<=f?0:L(function(d){d=
F(a,b,d);return f-d},0,k)},A=function(a){return t(a.sets)&&1===a.sets.length},E=function(a,b,f){b=b.reduce(function(b,d){d=d.r-v(a,d);return d<=b?d:b},Number.MAX_VALUE);return b=f.reduce(function(b,d){d=v(a,d)-d.r;return d<=b?d:b},b)},W=function(a,b){var f=a.reduce(function(f,d){var k=d.r/2;return[{x:d.x,y:d.y},{x:d.x+k,y:d.y},{x:d.x-k,y:d.y},{x:d.x,y:d.y+k},{x:d.x,y:d.y-k}].reduce(function(d,f){var k=E(f,a,b);d.margin<k&&(d.point=f,d.margin=k);return d},f)},{point:void 0,margin:-Number.MAX_VALUE}).point;
f=w(function(f){return-E({x:f[0],y:f[1]},a,b)},[f.x,f.y]);f={x:f[0],y:f[1]};G(f,a)&&J(f,b)||(f=y(a));return f},M=function(a,b,f){var k=b.reduce(function(a,b){return Math.min(b.r,a)},Infinity),d=f.filter(function(b){return!S(a,b)});f=function(f,k){return L(function(c){var e={x:a.x+k*c,y:a.y};e=G(e,b)&&J(e,d);return-(f-c)+(e?0:Number.MAX_VALUE)},0,f)};return 2*Math.min(f(k,-1),f(k,1))},X=function(a){var b=a.filter(A);return a.reduce(function(a,k){if(k.value){var d=k.sets;k=d.join();var f=b.reduce(function(a,
b){var f=-1<d.indexOf(b.sets[0]);a[f?"internal":"external"].push(b.circle);return a},{internal:[],external:[]}),c=W(f.internal,f.external);f=M(c,f.internal,f.external);a[k]={position:c,width:f}}return a},{})},N=function(a){var b=a.filter(function(a){return 2===a.sets.length}).reduce(function(a,b){b.sets.forEach(function(d,f,k){q(a[d])||(a[d]={overlapping:{},totalOverlap:0});a[d].totalOverlap+=b.value;a[d].overlapping[k[1-f]]=b.value});return a},{});a.filter(A).forEach(function(a){c(a,b[a.sets[0]])});
return a},O=function(a,b){return b.totalOverlap-a.totalOverlap},P=function(a){var b=[],f={};a.filter(function(a){return 1===a.sets.length}).forEach(function(a){f[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 f=a.circle;f.x=d.x;f.y=d.y;b.push(a)};N(a);var d=a.filter(A).sort(O);c(d.shift(),{x:0,y:0});var k=a.filter(function(a){return 2===a.sets.length});d.forEach(function(a){var d=a.circle,e=d.r,g=a.overlapping,h=b.reduce(function(a,
c,h){var m=c.circle,z=D(e,m.r,g[c.sets[0]]),l=[{x:m.x+z,y:m.y},{x:m.x-z,y:m.y},{x:m.x,y:m.y+z},{x:m.x,y:m.y-z}];b.slice(h+1).forEach(function(a){var b=a.circle;a=D(e,b.r,g[a.sets[0]]);l=l.concat(B({x:m.x,y:m.y,r:z},{x:b.x,y:b.y,r:a}))});l.forEach(function(b){d.x=b.x;d.y=b.y;var c=K(f,k);c<a.loss&&(a.loss=c,a.coordinates=b)});return a},{loss:Number.MAX_VALUE,coordinates:void 0});c(a,h.coordinates)});return f},Y=function(a){var b={};0<a.length&&(b=P(a),a.filter(function(a){return!A(a)}).forEach(function(a){var c=
a.sets;a=c.join();c=c.map(function(a){return b[a]});b[a]=x(c)}));return b},Q=function(a){var b={};return q(a)&&p(a.value)&&-1<a.value&&t(a.sets)&&0<a.sets.length&&!a.sets.some(function(a){var c=!1;!b[a]&&u(a)?b[a]=!0:c=!0;return c})},R=function(a){a=t(a)?a:[];var b=a.reduce(function(a,b){Q(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){Q(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,f){f.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 U(c)},Z=function(a,b,c){var e=c.bottom-c.top,d=c.right-c.left;e=Math.min(0<d?1/d*a:1,0<e?1/e*b:1);return{scale:e,centerX:a/2-(c.right+c.left)/2*e,centerY:b/2-(c.top+c.bottom)/2*e}};T("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}},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=R(this.options.data),c=Y(b),e=X(b);b=Object.keys(c).filter(function(a){return(a=
c[a])&&p(a.r)}).reduce(function(a,b){var d=c[b];b=d.x-d.r;var e=d.x+d.r,f=d.y+d.r;d=d.y-d.r;if(!p(a.left)||a.left>b)a.left=b;if(!p(a.right)||a.right<e)a.right=e;if(!p(a.top)||a.top>d)a.top=d;if(!p(a.bottom)||a.bottom<f)a.bottom=f;return a},{top:0,bottom:0,left:0,right:0});a=Z(a.plotWidth,a.plotHeight,b);var d=a.scale,g=a.centerX,h=a.centerY;this.points.forEach(function(a){var b=t(a.sets)?a.sets:[],f=b.join(),k=c[f],l,m=e[f]||{};f=m.width;m=m.position;var n=a.options&&a.options.dataLabels;k&&(k.r?
l={x:g+k.x*d,y:h+k.y*d,r:k.r*d}:k.d&&(l={d:k.d.reduce(function(a,b){"M"===b[0]?(b[1]=g+b[1]*d,b[2]=h+b[2]*d):"A"===b[0]&&(b[1]*=d,b[2]*=d,b[6]=g+b[6]*d,b[7]=h+b[7]*d);return a.concat(b)},[]).join(" ")}),m?(m.x=g+m.x*d,m.y=h+m.y*d):m={},p(f)&&(f=Math.round(f*d)));a.shapeArgs=l;m&&l&&(a.plotX=m.x,a.plotY=m.y);f&&l&&(a.dlOptions=H(!0,{style:{width:f}},q(n)&&n));a.name=a.options.name||b.join("\u2229")})},drawPoints:function(){var a=this,b=a.chart,e=a.group,g=b.renderer;(a.points||[]).forEach(function(d){var f=
{zIndex:t(d.sets)?d.sets.length:0},k=d.shapeArgs;b.styledMode||c(f,a.pointAttribs(d,d.state));d.draw({isNew:!d.graphic,animatableAttribs:k,attribs:f,group:e,renderer:g,shapeType:k&&k.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:g(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=
l.animObject(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);this.animate=null}},utils:{addOverlapToSets:N,geometry:e,geometryCircles:b,getLabelWidth:M,getMarginFromCircles:E,getDistanceBetweenCirclesByOverlap:D,layoutGreedyVenn:P,loss:K,nelderMead:r,processVennData:R,sortByTotalOverlap:O}},
{draw:a,shouldDraw:function(){return!!this.shapeArgs},isValid:function(){return p(this.value)}});h(I.venn,"afterSetOptions",function(a){var b=a.options.states;this instanceof I.venn&&Object.keys(b).forEach(function(a){b[a].halo=!1})})});r(a,"masters/modules/venn.src.js",[],function(){})});
//# sourceMappingURL=venn.js.map