text: !function(r,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("d3scaleCluster",[],t):"object"==typeof exports?exports.d3scaleCluster=t():r.d3scaleCluster=t()}(this,function(){return function(r){function t(e){if(n[e])return n[e].exports;var o=n[e]={exports:{},id:e,loaded:!1};return r[e].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=r,t.c=n,t.p="",t(0)}([function(r,t,n){function e(){function r(){if(!(a.length<=2)){t=o(n,Math.min(n.length,a.length)),u=[];for(var r=0;r<t.length;r++)u.push(t[r][0])}}var t=[],n=[],a=[],u=[],f=function(r){if(0!==t.length){for(var n=u.length-1;n>=0;n--)if(r>=u[n])return a[n];return a[0]}};return f.domain=function(){return arguments.length?(n=arguments[0],r(),f):n},f.range=function(){if(arguments.length){var t=arguments[0],n=t.length!==a.length;return a=t,n&&r(),f}return a},f.invertExtent=function(r){for(var t=NaN,n=NaN,e=0;e<a.length;e++)if(a[e]===r){t=u[e],n=e+1<a.length?u[e+1]:NaN;break}return[t,n]},f.clusters=function(){return u.slice(1)},f.copy=function(){return e().domain(n).range(a)},f}var o=n(1);"object"==typeof d3&&(d3.scaleCluster=e),r.exports=e},function(r,t){function n(r){return r.slice().sort(function(r,t){return r-t})}function e(r){for(var t,n=0,e=0;e<r.length;e++)0!==e&&r[e]===t||(t=r[e],n++);return n}function o(r,t){for(var n=[],e=0;e<r;e++){for(var o=[],a=0;a<t;a++)o.push(0);n.push(o)}return n}function a(r,t,n,e){var o;if(r>0){var a=(n[t]-n[r-1])/(t-r+1);o=e[t]-e[r-1]-(t-r+1)*a*a}else o=e[t]-n[t]*n[t]/(t+1);return o<0?0:o}function u(r,t,n,e,o,f,i){if(!(r>t)){var l=Math.floor((r+t)/2);e[n][l]=e[n-1][l-1],o[n][l]=l;var c=n;r>n&&(c=Math.max(c,o[n][r-1]||0)),c=Math.max(c,o[n-1][l]||0);var h=l-1;t<e.length-1&&(h=Math.min(h,o[n][t+1]||0));for(var s,v,g,p,d=h;d>=c&&(s=a(d,l,f,i),!(s+e[n-1][c-1]>=e[n][l]));--d)v=a(c,l,f,i),g=v+e[n-1][c-1],g<e[n][l]&&(e[n][l]=g,o[n][l]=c),c++,p=s+e[n-1][d-1],p<e[n][l]&&(e[n][l]=p,o[n][l]=d);u(r,l-1,n,e,o,f,i),u(l+1,t,n,e,o,f,i)}}function f(r,t,n){for(var e=t[0].length,o=new Array(e),f=new Array(e),i=r[Math.floor(e/2)],l=0;l<e;++l)0===l?(o[0]=r[0]-i,f[0]=(r[0]-i)*(r[0]-i)):(o[l]=o[l-1]+r[l]-i,f[l]=f[l-1]+(r[l]-i)*(r[l]-i)),t[0][l]=a(0,l,o,f),n[0][l]=0;for(var c,h=1;h<t.length;++h)c=h<t.length-1?h:e-1,u(c,e-1,h,t,n,o,f)}function i(r,t){if(t>r.length)throw new Error("Cannot generate more classes than there are data values");var a=r.length,u=n(r),i=e(u);if(1===i)return[u];t=Math.min(i,t);var l=o(t,a),c=o(t,a);f(u,l,c);for(var h=[],s=c[0].length-1,v=c.length-1;v>=0;v--){var g=c[v][s];h[v]=u.slice(g,s+1),v>0&&(s=g-1)}return h}r.exports=i}])});