!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-polygon"),require("d3-timer"),require("d3-dispatch"),require("d3-weighted-voronoi")):"function"==typeof define&&define.amd?define(["exports","d3-polygon","d3-timer","d3-dispatch","d3-weighted-voronoi"],n):n(t.d3=t.d3||{},t.d3,t.d3,t.d3,t.d3)}(this,function(t,n,e,r,i){"use strict";function o(){this.growthChangesLength=p,this.totalAvailableArea=NaN,this.lastAreaError=NaN,this.lastGrowth=NaN,this.growthChanges=[],this.growthChangeWeights=h(this.growthChangesLength),this.growthChangeWeightsSum=s(this.growthChangeWeights)}function a(t,n){return t>=n?1:-1}function h(t){for(var n=3,e=1,r=1,i=n,o=[],a=0;a1?(d=h,v=s):(d=o+w*l,v=a+w*c);var C=r-d,y=i-v;return Math.sqrt(C*C+y*y)}var o,a,h,s,g,u,l=0;return t.startAngle=function(n){return arguments.length?(l=n,t):l},t}function l(){function t(t,n,o,a){var s=!1;return r!==a.clip()&&(r=a.clip(),s|=!0),i!==o&&(i=o,s|=!0),s&&e(),h}function e(){o=i.length,a=n.polygonArea(r),h=a/o/2}var r,i,o,a,h;return t}function c(t){this.message=t,this.stack=(new Error).stack}function f(t){function a(t){return Math.pow(t,2)}function h(t,n){return a(n.x-t.x)+a(n.y-t.y)}function s(){u(),U.call("tick",P),k&&(T.stop(),U.call("end",P))}function u(){k||(Q&&f(),W=d(W,K.ratio()),b++,E=A(W),K.add(E),L=E=V)}function f(){m(),M=t.length,x=Math.abs(n.polygonArea(J.clip())),N=z*x,K.clear().totalArea(x),b=0,L=!1,W=p(t,P),k=!1,Q=!1}function p(t,n){var e,r,i=t.reduce(function(t,n){return Math.max(t,R(n))},-(1/0)),o=i*_;return e=t.map(function(t,e,r){return{index:e,weight:Math.max(R(t),o),initialPosition:B(t,e,r,n),initialWeight:H(t,e,r,n),originalData:t}}),r=w(e,n),Y(r),J(r)}function w(t,e){var r,i=t.reduce(function(t,n){return t+=n.weight},0);return t.map(function(t,o,a){return r=t.initialPosition,n.polygonContains(J.clip(),r)||(r=q(t,o,a,e)),{index:t.index,targetedArea:x*t.weight/i,data:t,x:r[0],y:r[1],weight:t.initialWeight}})}function d(t,n){var e;if(v(t,n),e=t.map(function(t){return t.site.originalObject}),t=J(e),t.lengthX)throw new c("handleOverweighted1 is looping too much");n=!1;for(var u=0;ur.weight?(i=e,o=r):(i=r,o=e),a=h(e,r),a0?(this.growthChangesLength=Math.floor(parseInt(t)),this.growthChangeWeights=h(this.growthChangesLength),this.growthChangeWeightsSum=s(this.growthChangeWeights)):console.warn("FlickeringMitigation.length() accepts only positive integers; unable to handle "+t),this):this.growthChangesLength},o.prototype.totalArea=function(t){return arguments.length?(parseFloat(t)>0?this.totalAvailableArea=parseFloat(t):console.warn("FlickeringMitigation.totalArea() accepts only positive numbers; unable to handle "+t),this):this.totalAvailableArea},o.prototype.add=function(t){var n,e;return n=this.lastAreaError,this.lastAreaError=t,isNaN(n)||(e=this.lastGrowth,this.lastGrowth=a(this.lastAreaError,n)),isNaN(e)||this.growthChanges.unshift(this.lastGrowth!=e),this.growthChanges.length>this.growthChangesLength&&this.growthChanges.pop(),this},o.prototype.ratio=function(){var t,n=0;if(this.growthChanges.lengththis.totalAvailableArea/10)return 0;for(var e=0;e