// https://d3js.org/d3-contour/ Version 1.1.0. Copyright 2017 Mike Bostock. !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("d3-array")):"function"==typeof define&&define.amd?define(["exports","d3-array"],r):r(t.d3=t.d3||{},t.d3)}(this,function(t,r){"use strict";function n(t,r){for(var n=r[0],i=r[1],a=-1,o=0,h=t.length,f=h-1;oi!=g>i&&n<(s-c)*(i-d)/(g-d)+c&&(a=-a)}return a}function e(t,r,n){var e;return i(t,r,n)&&a(t[e=+(t[0]===r[0])],n[e],r[e])}function i(t,r,n){return(r[0]-t[0])*(n[1]-t[1])==(n[0]-t[0])*(r[1]-t[1])}function a(t,r,n){return t<=r&&r<=n||n<=r&&r<=t}function o(t,r,n){for(var e=t.width,i=t.height,a=1+(n<<1),o=0;o=n&&(h>=a&&(f-=t.data[h-a+o*e]),r.data[h-n+o*e]=f/Math.min(h+1,e-1+a-h,a))}function h(t,r,n){for(var e=t.width,i=t.height,a=1+(n<<1),o=0;o=n&&(h>=a&&(f-=t.data[o+(h-a)*e]),r.data[o+(h-n)*e]=f/Math.min(h+1,i-1+a-h,a))}function f(t){return t[0]}function u(t){return t[1]}var c=Array.prototype,d=c.slice,l=function(t,r){return t-r},s=function(t){for(var r=0,n=t.length,e=t[n-1][1]*t[0][0]-t[n-1][0]*t[0][1];++r0?e.push([n]):i.push(n)}),i.forEach(function(t){for(var r,n=0,i=e.length;n=r,p[c<<1].forEach(i);++h=r,p[u|c<<1].forEach(i);for(p[c<<0].forEach(i);++f=r,d=t[f*a]>=r,p[c<<1|d<<2].forEach(i);++h=r,l=d,d=t[f*a+h+1]>=r,p[u|c<<1|d<<2|l<<3].forEach(i);p[c|d<<3].forEach(i)}for(h=-1,d=t[f*a]>=r,p[d<<2].forEach(i);++h=r,p[d<<2|l<<3].forEach(i);p[d<<3].forEach(i)}function e(t){return 2*t[0]+t[1]*(a+1)*4}function i(t,r,n){t.forEach(function(t){var e,i=t[0],h=t[1],f=0|i,u=0|h,c=r[u*a+f];i>0&&i0&&h0&&e>0))throw new Error("invalid size");return a=n,o=e,t},t.thresholds=function(r){return arguments.length?(h="function"==typeof r?r:g(Array.isArray(r)?d.call(r):r),t):h},t.smooth=function(r){return arguments.length?(f=r?i:w,t):f===i},t},M=function(){function t(t){var e=new Float32Array(A*m),i=new Float32Array(A*m);t.forEach(function(t,r,n){var i=l(t,r,n)+E>>M,a=s(t,r,n)+E>>M;i>=0&&i=0&&a>M),h({width:A,height:m,data:i},{width:A,height:m,data:e},p>>M),o({width:A,height:m,data:e},{width:A,height:m,data:i},p>>M),h({width:A,height:m,data:i},{width:A,height:m,data:e},p>>M),o({width:A,height:m,data:e},{width:A,height:m,data:i},p>>M),h({width:A,height:m,data:i},{width:A,height:m,data:e},p>>M);var a=z(e);if(!Array.isArray(a)){var f=r.max(e);a=r.tickStep(0,f,a),a=r.range(0,Math.floor(f/a)*a,a),a.shift()}return y().thresholds(a).size([A,m])(e).map(n)}function n(t){return t.value*=Math.pow(2,-2*M),t.coordinates.forEach(e),t}function e(t){t.forEach(i)}function i(t){t.forEach(a)}function a(t){t[0]=t[0]*Math.pow(2,M)-E,t[1]=t[1]*Math.pow(2,M)-E}function c(){return E=3*p,A=v+2*E>>M,m=w+2*E>>M,t}var l=f,s=u,v=960,w=500,p=20,M=2,E=3*p,A=v+2*E>>M,m=w+2*E>>M,z=g(20);return t.x=function(r){return arguments.length?(l="function"==typeof r?r:g(+r),t):l},t.y=function(r){return arguments.length?(s="function"==typeof r?r:g(+r),t):s},t.size=function(t){if(!arguments.length)return[v,w];var r=Math.ceil(t[0]),n=Math.ceil(t[1]);if(!(r>=0||r>=0))throw new Error("invalid size");return v=r,w=n,c()},t.cellSize=function(t){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return M=Math.floor(Math.log(t)/Math.LN2),c()},t.thresholds=function(r){return arguments.length?(z="function"==typeof r?r:g(Array.isArray(r)?d.call(r):r),t):z},t.bandwidth=function(t){if(!arguments.length)return Math.sqrt(p*(p+1));if(!((t=+t)>=0))throw new Error("invalid bandwidth");return p=Math.round((Math.sqrt(4*t*t+1)-1)/2),c()},t};t.contours=y,t.contourDensity=M,Object.defineProperty(t,"__esModule",{value:!0})});