=x&&(x=m+1);!(b=y[x])&&++x=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=$t);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?en:"function"==typeof n?on:rn)(t,n,null==e?"":e)):an(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?un:"function"==typeof n?fn:cn)(t,n)):this.node()[t]},classed:function(t,n){var e=sn(t+"");if(arguments.length<2){for(var r=ln(this.node()),i=-1,o=e.length;++i()=>t;function Qn(t,{sourceEvent:n,subject:e,target:r,identifier:i,active:o,x:a,y:u,dx:c,dy:f,dispatch:s}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:s}})}function Jn(t){return!t.ctrlKey&&!t.button}function te(){return this.parentNode}function ne(t,n){return null==n?{x:t.x,y:t.y}:n}function ee(){return navigator.maxTouchPoints||"ontouchstart"in this}function re(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function ie(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function oe(){}Qn.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var ae=.7,ue=1/ae,ce="\\s*([+-]?\\d+)\\s*",fe="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",se="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",le=/^#([0-9a-f]{3,8})$/,he=new RegExp("^rgb\\("+[ce,ce,ce]+"\\)$"),de=new RegExp("^rgb\\("+[se,se,se]+"\\)$"),pe=new RegExp("^rgba\\("+[ce,ce,ce,fe]+"\\)$"),ge=new RegExp("^rgba\\("+[se,se,se,fe]+"\\)$"),ye=new RegExp("^hsl\\("+[fe,se,se]+"\\)$"),ve=new RegExp("^hsla\\("+[fe,se,se,fe]+"\\)$"),_e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function be(){return this.rgb().formatHex()}function me(){return this.rgb().formatRgb()}function xe(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=le.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?we(n):3===e?new Se(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?Me(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?Me(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=he.exec(t))?new Se(n[1],n[2],n[3],1):(n=de.exec(t))?new Se(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=pe.exec(t))?Me(n[1],n[2],n[3],n[4]):(n=ge.exec(t))?Me(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=ye.exec(t))?Ce(n[1],n[2]/100,n[3]/100,1):(n=ve.exec(t))?Ce(n[1],n[2]/100,n[3]/100,n[4]):_e.hasOwnProperty(t)?we(_e[t]):"transparent"===t?new Se(NaN,NaN,NaN,0):null}function we(t){return new Se(t>>16&255,t>>8&255,255&t,1)}function Me(t,n,e,r){return r<=0&&(t=n=e=NaN),new Se(t,n,e,r)}function Ae(t){return t instanceof oe||(t=xe(t)),t?new Se((t=t.rgb()).r,t.g,t.b,t.opacity):new Se}function Te(t,n,e,r){return 1===arguments.length?Ae(t):new Se(t,n,e,null==r?1:r)}function Se(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function Ee(){return"#"+Ne(this.r)+Ne(this.g)+Ne(this.b)}function ke(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function Ne(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Ce(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new De(t,n,e,r)}function Pe(t){if(t instanceof De)return new De(t.h,t.s,t.l,t.opacity);if(t instanceof oe||(t=xe(t)),!t)return new De;if(t instanceof De)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,u=o-i,c=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e0&&c<1?0:a,new De(a,u,c,t.opacity)}function ze(t,n,e,r){return 1===arguments.length?Pe(t):new De(t,n,e,null==r?1:r)}function De(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function qe(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}re(oe,xe,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:be,formatHex:be,formatHsl:function(){return Pe(this).formatHsl()},formatRgb:me,toString:me}),re(Se,Te,ie(oe,{brighter:function(t){return t=null==t?ue:Math.pow(ue,t),new Se(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?ae:Math.pow(ae,t),new Se(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ee,formatHex:Ee,formatRgb:ke,toString:ke})),re(De,ze,ie(oe,{brighter:function(t){return t=null==t?ue:Math.pow(ue,t),new De(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?ae:Math.pow(ae,t),new De(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new Se(qe(t>=240?t-240:t+120,i,r),qe(t,i,r),qe(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));const Re=Math.PI/180,Fe=180/Math.PI,Oe=.96422,Ie=.82521,Ue=4/29,Be=6/29,Ye=3*Be*Be;function Le(t){if(t instanceof He)return new He(t.l,t.a,t.b,t.opacity);if(t instanceof Ke)return Qe(t);t instanceof Se||(t=Ae(t));var n,e,r=$e(t.r),i=$e(t.g),o=$e(t.b),a=Xe((.2225045*r+.7168786*i+.0606169*o)/1);return r===i&&i===o?n=e=a:(n=Xe((.4360747*r+.3850649*i+.1430804*o)/Oe),e=Xe((.0139322*r+.0971045*i+.7141733*o)/Ie)),new He(116*a-16,500*(n-a),200*(a-e),t.opacity)}function je(t,n,e,r){return 1===arguments.length?Le(t):new He(t,n,e,null==r?1:r)}function He(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function Xe(t){return t>.008856451679035631?Math.pow(t,1/3):t/Ye+Ue}function Ge(t){return t>Be?t*t*t:Ye*(t-Ue)}function Ve(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function $e(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function We(t){if(t instanceof Ke)return new Ke(t.h,t.c,t.l,t.opacity);if(t instanceof He||(t=Le(t)),0===t.a&&0===t.b)return new Ke(NaN,0=1?(e=1,n-1):Math.floor(e*n),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,u=r()=>t;function pr(t,n){return function(e){return t+e*n}}function gr(t,n){var e=n-t;return e?pr(t,e>180||e<-180?e-360*Math.round(e/360):e):dr(isNaN(t)?n:t)}function yr(t){return 1==(t=+t)?vr:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):dr(isNaN(n)?e:n)}}function vr(t,n){var e=n-t;return e?pr(t,e):dr(isNaN(t)?n:t)}var _r=function t(n){var e=yr(n);function r(t,n){var r=e((t=Te(t)).r,(n=Te(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=vr(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function br(t){return function(n){var e,r,i=n.length,o=new Array(i),a=new Array(i),u=new Array(i);for(e=0;eo&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,c.push({i:a,x:Sr(e,r)})),o=Nr.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:Sr(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,c),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:Sr(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,c),function(t,n,e,r,o,a){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:Sr(t,e)},{i:u-2,x:Sr(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,c),o=a=null,function(t){for(var n,e=-1,r=c.length;++e=0&&n._call.call(void 0,t),n=n._next;--ti}function di(){ii=(ri=ai.now())+oi,ti=ni=0;try{hi()}finally{ti=0,function(){var t,n,e=Qr,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Qr=n);Jr=t,gi(r)}(),ii=0}}function pi(){var t=ai.now(),n=t-ri;n>1e3&&(oi-=n,ri=t)}function gi(t){ti||(ni&&(ni=clearTimeout(ni)),t-ii>24?(t<1/0&&(ni=setTimeout(di,t-ai.now()-oi)),ei&&(ei=clearInterval(ei))):(ei||(ri=ai.now(),ei=setInterval(pi,1e3)),ti=1,ui(di)))}function yi(t,n,e){var r=new si;return n=null==n?0:+n,r.restart((e=>{r.stop(),t(e+n)}),n,e),r}si.prototype=li.prototype={constructor:si,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?ci():+e)+(null==n?0:+n),this._next||Jr===this||(Jr?Jr._next=this:Qr=this,Jr=this),this._call=t,this._time=e,gi()},stop:function(){this._call&&(this._call=null,this._time=1/0,gi())}};var vi=bt("start","end","cancel","interrupt"),_i=[];function bi(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(t){e.state=1,e.timer.restart(a,e.delay,e.time),e.delay<=t&&a(t-e.delay)}function a(o){var f,s,l,h;if(1!==e.state)return c();for(f in i)if((h=i[f]).name===e.name){if(3===h.state)return yi(a);4===h.state?(h.state=6,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[f]):+f0)throw new Error("too late; already scheduled");return e}function xi(t,n){var e=wi(t,n);if(e.state>3)throw new Error("too late; already running");return e}function wi(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Mi(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>2&&e.state<5,e.state=6,e.timer.stop(),e.on.call(r?"interrupt":"cancel",t,t.__data__,e.index,e.group),delete o[i]):a=!1;a&&delete t.__transition}}function Ai(t,n){var e,r;return function(){var i=xi(this,t),o=i.tween;if(o!==e)for(var a=0,u=(r=e=o).length;a=0&&(t=t.slice(0,n)),!t||"start"===t}))}(n)?mi:xi;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}var Hi=In.prototype.constructor;function Xi(t){return function(){this.style.removeProperty(t)}}function Gi(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}function Vi(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&Gi(t,o,e)),r}return o._value=n,o}function $i(t){return function(n){this.textContent=t.call(this,n)}}function Wi(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&$i(r)),n}return r._value=t,r}var Zi=0;function Ki(t,n,e,r){this._groups=t,this._parents=n,this._name=e,this._id=r}function Qi(t){return In().transition(t)}function Ji(){return++Zi}var to=In.prototype;Ki.prototype=Qi.prototype={constructor:Ki,select:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=Pt(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a()=>t;function ko(t,{sourceEvent:n,target:e,selection:r,mode:i,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function No(t){t.stopImmediatePropagation()}function Co(t){t.preventDefault(),t.stopImmediatePropagation()}var Po={name:"drag"},zo={name:"space"},Do={name:"handle"},qo={name:"center"};const{abs:Ro,max:Fo,min:Oo}=Math;function Io(t){return[+t[0],+t[1]]}function Uo(t){return[Io(t[0]),Io(t[1])]}var Bo={name:"x",handles:["w","e"].map($o),input:function(t,n){return null==t?null:[[+t[0],n[0][1]],[+t[1],n[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},Yo={name:"y",handles:["n","s"].map($o),input:function(t,n){return null==t?null:[[n[0][0],+t[0]],[n[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},Lo={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map($o),input:function(t){return null==t?null:Uo(t)},output:function(t){return t}},jo={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Ho={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},Xo={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},Go={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},Vo={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function $o(t){return{type:t}}function Wo(t){return!t.ctrlKey&&!t.button}function Zo(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function Ko(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qo(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function Jo(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}function ta(t){var n,e=Zo,r=Wo,i=Ko,o=!0,a=bt("start","brush","end"),u=6;function c(n){var e=n.property("__brush",g).selectAll(".overlay").data([$o("overlay")]);e.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",jo.overlay).merge(e).each((function(){var t=Qo(this).extent;Un(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])})),n.selectAll(".selection").data([$o("selection")]).enter().append("rect").attr("class","selection").attr("cursor",jo.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=n.selectAll(".handle").data(t.handles,(function(t){return t.type}));r.exit().remove(),r.enter().append("rect").attr("class",(function(t){return"handle handle--"+t.type})).attr("cursor",(function(t){return jo[t.type]})),n.each(f).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",h).filter(i).on("touchstart.brush",h).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(){var t=Un(this),n=Qo(this).selection;n?(t.selectAll(".selection").style("display",null).attr("x",n[0][0]).attr("y",n[0][1]).attr("width",n[1][0]-n[0][0]).attr("height",n[1][1]-n[0][1]),t.selectAll(".handle").style("display",null).attr("x",(function(t){return"e"===t.type[t.type.length-1]?n[1][0]-u/2:n[0][0]-u/2})).attr("y",(function(t){return"s"===t.type[0]?n[1][1]-u/2:n[0][1]-u/2})).attr("width",(function(t){return"n"===t.type||"s"===t.type?n[1][0]-n[0][0]+u:u})).attr("height",(function(t){return"e"===t.type||"w"===t.type?n[1][1]-n[0][1]+u:u}))):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function s(t,n,e){var r=t.__brush.emitter;return!r||e&&r.clean?new l(t,n,e):r}function l(t,n,e){this.that=t,this.args=n,this.state=t.__brush,this.active=0,this.clean=e}function h(e){if((!n||e.touches)&&r.apply(this,arguments)){var i,a,u,c,l,h,d,p,g,y,v,_=this,b=e.target.__data__.type,m="selection"===(o&&e.metaKey?b="overlay":b)?Po:o&&e.altKey?qo:Do,x=t===Yo?null:Go[b],w=t===Bo?null:Vo[b],M=Qo(_),A=M.extent,T=M.selection,S=A[0][0],E=A[0][1],k=A[1][0],N=A[1][1],C=0,P=0,z=x&&w&&o&&e.shiftKey,D=Array.from(e.touches||[e],(t=>{const n=t.identifier;return(t=Hn(t,_)).point0=t.slice(),t.identifier=n,t}));Mi(_);var q=s(_,arguments,!0).beforestart();if("overlay"===b){T&&(g=!0);const n=[D[0],D[1]||D[0]];M.selection=T=[[i=t===Yo?S:Oo(n[0][0],n[1][0]),u=t===Bo?E:Oo(n[0][1],n[1][1])],[l=t===Yo?k:Fo(n[0][0],n[1][0]),d=t===Bo?N:Fo(n[0][1],n[1][1])]],D.length>1&&U(e)}else i=T[0][0],u=T[0][1],l=T[1][0],d=T[1][1];a=i,c=u,h=l,p=d;var R=Un(_).attr("pointer-events","none"),F=R.selectAll(".overlay").attr("cursor",jo[b]);if(e.touches)q.moved=I,q.ended=B;else{var O=Un(e.view).on("mousemove.brush",I,!0).on("mouseup.brush",B,!0);o&&O.on("keydown.brush",Y,!0).on("keyup.brush",L,!0),Wn(e.view)}f.call(_),q.start(e,m.name)}function I(t){for(const n of t.changedTouches||[t])for(const t of D)t.identifier===n.identifier&&(t.cur=Hn(n,_));if(z&&!y&&!v&&1===D.length){const t=D[0];Ro(t.cur[0]-t[0])>Ro(t.cur[1]-t[1])?v=!0:y=!0}for(const t of D)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);g=!0,Co(t),U(t)}function U(t){const n=D[0],e=n.point0;var r;switch(C=n[0]-e[0],P=n[1]-e[1],m){case zo:case Po:x&&(C=Fo(S-i,Oo(k-l,C)),a=i+C,h=l+C),w&&(P=Fo(E-u,Oo(N-d,P)),c=u+P,p=d+P);break;case Do:D[1]?(x&&(a=Fo(S,Oo(k,D[0][0])),h=Fo(S,Oo(k,D[1][0])),x=1),w&&(c=Fo(E,Oo(N,D[0][1])),p=Fo(E,Oo(N,D[1][1])),w=1)):(x<0?(C=Fo(S-i,Oo(k-i,C)),a=i+C,h=l):x>0&&(C=Fo(S-l,Oo(k-l,C)),a=i,h=l+C),w<0?(P=Fo(E-u,Oo(N-u,P)),c=u+P,p=d):w>0&&(P=Fo(E-d,Oo(N-d,P)),c=u,p=d+P));break;case qo:x&&(a=Fo(S,Oo(k,i-C*x)),h=Fo(S,Oo(k,l+C*x))),w&&(c=Fo(E,Oo(N,u-P*w)),p=Fo(E,Oo(N,d+P*w)))}h0&&(i=a-C),w<0?d=p-P:w>0&&(u=c-P),m=zo,F.attr("cursor",jo.selection),U(t));break;default:return}Co(t)}function L(t){switch(t.keyCode){case 16:z&&(y=v=z=!1,U(t));break;case 18:m===qo&&(x<0?l=h:x>0&&(i=a),w<0?d=p:w>0&&(u=c),m=Do,U(t));break;case 32:m===zo&&(t.altKey?(x&&(l=h-C*x,i=a+C*x),w&&(d=p-P*w,u=c+P*w),m=qo):(x<0?l=h:x>0&&(i=a),w<0?d=p:w>0&&(u=c),m=Do),F.attr("cursor",jo[b]),U(t));break;default:return}Co(t)}}function d(t){s(this,arguments).moved(t)}function p(t){s(this,arguments).ended(t)}function g(){var n=this.__brush||{selection:null};return n.extent=Uo(e.apply(this,arguments)),n.dim=t,n}return c.move=function(n,e,r){n.tween?n.on("start.brush",(function(t){s(this,arguments).beforestart().start(t)})).on("interrupt.brush end.brush",(function(t){s(this,arguments).end(t)})).tween("brush",(function(){var n=this,r=n.__brush,i=s(n,arguments),o=r.selection,a=t.input("function"==typeof e?e.apply(this,arguments):e,r.extent),u=Pr(o,a);function c(t){r.selection=1===t&&null===a?null:u(t),f.call(n),i.brush()}return null!==o&&null!==a?c:c(1)})):n.each((function(){var n=this,i=arguments,o=n.__brush,a=t.input("function"==typeof e?e.apply(n,i):e,o.extent),u=s(n,i).beforestart();Mi(n),o.selection=null===a?null:a,f.call(n),u.start(r).brush(r).end(r)}))},c.clear=function(t,n){c.move(t,null,n)},l.prototype={beforestart:function(){return 1==++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(t,n){return this.starting?(this.starting=!1,this.emit("start",t,n)):this.emit("brush",t),this},brush:function(t,n){return this.emit("brush",t,n),this},end:function(t,n){return 0==--this.active&&(delete this.state.emitter,this.emit("end",t,n)),this},emit:function(n,e,r){var i=Un(this.that).datum();a.call(n,this.that,new ko(n,{sourceEvent:e,target:c,selection:t.output(this.state.selection),mode:r,dispatch:a}),i)}},c.extent=function(t){return arguments.length?(e="function"==typeof t?t:Eo(Uo(t)),c):e},c.filter=function(t){return arguments.length?(r="function"==typeof t?t:Eo(!!t),c):r},c.touchable=function(t){return arguments.length?(i="function"==typeof t?t:Eo(!!t),c):i},c.handleSize=function(t){return arguments.length?(u=+t,c):u},c.keyModifiers=function(t){return arguments.length?(o=!!t,c):o},c.on=function(){var t=a.on.apply(a,arguments);return t===a?c:t},c}var na=Math.abs,ea=Math.cos,ra=Math.sin,ia=Math.PI,oa=ia/2,aa=2*ia,ua=Math.max,ca=1e-12;function fa(t,n){return Array.from({length:n-t},((n,e)=>t+e))}function sa(t){return function(n,e){return t(n.source.value+n.target.value,e.source.value+e.target.value)}}function la(t,n){var e=0,r=null,i=null,o=null;function a(a){var u,c=a.length,f=new Array(c),s=fa(0,c),l=new Array(c*c),h=new Array(c),d=0;a=Float64Array.from({length:c*c},n?(t,n)=>a[n%c][n/c|0]:(t,n)=>a[n/c|0][n%c]);for(let n=0;nr(f[t],f[n])));for(const e of s){const r=n;if(t){const t=fa(1+~c,c).filter((t=>t<0?a[~t*c+e]:a[e*c+t]));i&&t.sort(((t,n)=>i(t<0?-a[~t*c+e]:a[e*c+t],n<0?-a[~n*c+e]:a[e*c+n])));for(const r of t)if(r<0){(l[~r*c+e]||(l[~r*c+e]={source:null,target:null})).target={index:e,startAngle:n,endAngle:n+=a[~r*c+e]*d,value:a[~r*c+e]}}else{(l[e*c+r]||(l[e*c+r]={source:null,target:null})).source={index:e,startAngle:n,endAngle:n+=a[e*c+r]*d,value:a[e*c+r]}}h[e]={index:e,startAngle:r,endAngle:n,value:f[e]}}else{const t=fa(0,c).filter((t=>a[e*c+t]||a[t*c+e]));i&&t.sort(((t,n)=>i(a[e*c+t],a[e*c+n])));for(const r of t){let t;if(epa)if(Math.abs(s*u-c*f)>pa&&i){var h=e-o,d=r-a,p=u*u+c*c,g=h*h+d*d,y=Math.sqrt(p),v=Math.sqrt(l),_=i*Math.tan((ha-Math.acos((p+l-g)/(2*y*v)))/2),b=_/v,m=_/y;Math.abs(b-1)>pa&&(this._+="L"+(t+b*f)+","+(n+b*s)),this._+="A"+i+","+i+",0,0,"+ +(s*h>f*d)+","+(this._x1=t+m*u)+","+(this._y1=n+m*c)}else this._+="L"+(this._x1=t)+","+(this._y1=n);else;},arc:function(t,n,e,r,i,o){t=+t,n=+n,o=!!o;var a=(e=+e)*Math.cos(r),u=e*Math.sin(r),c=t+a,f=n+u,s=1^o,l=o?r-i:i-r;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+c+","+f:(Math.abs(this._x1-c)>pa||Math.abs(this._y1-f)>pa)&&(this._+="L"+c+","+f),e&&(l<0&&(l=l%da+da),l>ga?this._+="A"+e+","+e+",0,1,"+s+","+(t-a)+","+(n-u)+"A"+e+","+e+",0,1,"+s+","+(this._x1=c)+","+(this._y1=f):l>pa&&(this._+="A"+e+","+e+",0,"+ +(l>=ha)+","+s+","+(this._x1=t+e*Math.cos(i))+","+(this._y1=n+e*Math.sin(i))))},rect:function(t,n,e,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +r+"h"+-e+"Z"},toString:function(){return this._}};var _a=Array.prototype.slice;function ba(t){return function(){return t}}function ma(t){return t.source}function xa(t){return t.target}function wa(t){return t.radius}function Ma(t){return t.startAngle}function Aa(t){return t.endAngle}function Ta(){return 0}function Sa(){return 10}function Ea(t){var n=ma,e=xa,r=wa,i=wa,o=Ma,a=Aa,u=Ta,c=null;function f(){var f,s=n.apply(this,arguments),l=e.apply(this,arguments),h=u.apply(this,arguments)/2,d=_a.call(arguments),p=+r.apply(this,(d[0]=s,d)),g=o.apply(this,d)-oa,y=a.apply(this,d)-oa,v=+i.apply(this,(d[0]=l,d)),_=o.apply(this,d)-oa,b=a.apply(this,d)-oa;if(c||(c=f=va()),h>ca&&(na(y-g)>2*h+ca?y>g?(g+=h,y-=h):(g-=h,y+=h):g=y=(g+y)/2,na(b-_)>2*h+ca?b>_?(_+=h,b-=h):(_-=h,b+=h):_=b=(_+b)/2),c.moveTo(p*ea(g),p*ra(g)),c.arc(0,0,p,g,y),g!==_||y!==b)if(t){var m=+t.apply(this,arguments),x=v-m,w=(_+b)/2;c.quadraticCurveTo(0,0,x*ea(_),x*ra(_)),c.lineTo(v*ea(w),v*ra(w)),c.lineTo(x*ea(b),x*ra(b))}else c.quadraticCurveTo(0,0,v*ea(_),v*ra(_)),c.arc(0,0,v,_,b);if(c.quadraticCurveTo(0,0,p*ea(g),p*ra(g)),c.closePath(),f)return c=null,f+""||null}return t&&(f.headRadius=function(n){return arguments.length?(t="function"==typeof n?n:ba(+n),f):t}),f.radius=function(t){return arguments.length?(r=i="function"==typeof t?t:ba(+t),f):r},f.sourceRadius=function(t){return arguments.length?(r="function"==typeof t?t:ba(+t),f):r},f.targetRadius=function(t){return arguments.length?(i="function"==typeof t?t:ba(+t),f):i},f.startAngle=function(t){return arguments.length?(o="function"==typeof t?t:ba(+t),f):o},f.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:ba(+t),f):a},f.padAngle=function(t){return arguments.length?(u="function"==typeof t?t:ba(+t),f):u},f.source=function(t){return arguments.length?(n=t,f):n},f.target=function(t){return arguments.length?(e=t,f):e},f.context=function(t){return arguments.length?(c=null==t?null:t,f):c},f}var ka=Array.prototype.slice;function Na(t,n){return t-n}var Ca=t=>()=>t;function Pa(t,n){for(var e,r=-1,i=n.length;++rr!=d>r&&e<(h-f)*(r-s)/(d-s)+f&&(i=-i)}return i}function Da(t,n,e){var r,i,o,a;return function(t,n,e){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])}(t,n,e)&&(i=t[r=+(t[0]===n[0])],o=e[r],a=n[r],i<=o&&o<=a||a<=o&&o<=i)}function qa(){}var Ra=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Fa(){var t=1,n=1,e=H,r=u;function i(t){var n=e(t);if(Array.isArray(n))n=n.slice().sort(Na);else{const e=g(t),r=L(e[0],e[1],n);n=B(Math.floor(e[0]/r)*r,Math.floor(e[1]/r-1)*r,n)}return n.map((n=>o(t,n)))}function o(e,i){var o=[],u=[];return function(e,r,i){var o,u,c,f,s,l,h=new Array,d=new Array;o=u=-1,f=e[0]>=r,Ra[f<<1].forEach(p);for(;++o=r,Ra[c|f<<1].forEach(p);Ra[f<<0].forEach(p);for(;++u=r,s=e[u*t]>=r,Ra[f<<1|s<<2].forEach(p);++o=r,l=s,s=e[u*t+o+1]>=r,Ra[c|f<<1|s<<2|l<<3].forEach(p);Ra[f|s<<3].forEach(p)}o=-1,s=e[u*t]>=r,Ra[s<<2].forEach(p);for(;++o=r,Ra[s<<2|l<<3].forEach(p);function p(t){var n,e,r=[t[0][0]+o,t[0][1]+u],c=[t[1][0]+o,t[1][1]+u],f=a(r),s=a(c);(n=d[f])?(e=h[s])?(delete d[n.end],delete h[e.start],n===e?(n.ring.push(c),i(n.ring)):h[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete d[n.end],n.ring.push(c),d[n.end=s]=n):(n=h[s])?(e=d[f])?(delete h[n.start],delete d[e.end],n===e?(n.ring.push(c),i(n.ring)):h[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete h[n.start],n.ring.unshift(r),h[n.start=f]=n):h[f]=d[s]={start:f,end:s,ring:[r,c]}}Ra[s<<3].forEach(p)}(e,i,(function(t){r(t,e,i),function(t){for(var n=0,e=t.length,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++n0?o.push([t]):u.push(t)})),u.forEach((function(t){for(var n,e=0,r=o.length;e0&&a0&&u=0&&o>=0))throw new Error("invalid size");return t=r,n=o,i},i.thresholds=function(t){return arguments.length?(e="function"==typeof t?t:Array.isArray(t)?Ca(ka.call(t)):Ca(t),i):e},i.smooth=function(t){return arguments.length?(r=t?u:qa,i):r===u},i}function Oa(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(c-=t.data[u-o+a*r]),n.data[u-e+a*r]=c/Math.min(u+1,r-1+o-u,o))}function Ia(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(c-=t.data[a+(u-o)*r]),n.data[a+(u-e)*r]=c/Math.min(u+1,i-1+o-u,o))}function Ua(t){return t[0]}function Ba(t){return t[1]}function Ya(){return 1}const La=134217729;function ja(t,n,e,r,i){let o,a,u,c,f=n[0],s=r[0],l=0,h=0;s>f==s>-f?(o=f,f=n[++l]):(o=s,s=r[++h]);let d=0;if(lf==s>-f?(a=f+o,u=o-(a-f),f=n[++l]):(a=s+o,u=o-(a-s),s=r[++h]),o=a,0!==u&&(i[d++]=u);lf==s>-f?(a=o+f,c=a-o,u=o-(a-c)+(f-c),f=n[++l]):(a=o+s,c=a-o,u=o-(a-c)+(s-c),s=r[++h]),o=a,0!==u&&(i[d++]=u);for(;l0!=u>0)return c;const f=Math.abs(a+u);return Math.abs(c)>=33306690738754716e-32*f?c:-function(t,n,e,r,i,o,a){let u,c,f,s,l,h,d,p,g,y,v,_,b,m,x,w,M,A;const T=t-i,S=e-i,E=n-o,k=r-o;m=T*k,h=La*T,d=h-(h-T),p=T-d,h=La*k,g=h-(h-k),y=k-g,x=p*y-(m-d*g-p*g-d*y),w=E*S,h=La*E,d=h-(h-E),p=E-d,h=La*S,g=h-(h-S),y=S-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,Xa[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,Xa[1]=b-(v+l)+(l-w),A=_+v,l=A-_,Xa[2]=_-(A-l)+(v-l),Xa[3]=A;let N=function(t,n){let e=n[0];for(let r=1;r=C||-N>=C)return N;if(l=t-T,u=t-(T+l)+(l-i),l=e-S,f=e-(S+l)+(l-i),l=n-E,c=n-(E+l)+(l-o),l=r-k,s=r-(k+l)+(l-o),0===u&&0===c&&0===f&&0===s)return N;if(C=11093356479670487e-47*a+33306690738754706e-32*Math.abs(N),N+=T*s+k*u-(E*f+S*c),N>=C||-N>=C)return N;m=u*k,h=La*u,d=h-(h-u),p=u-d,h=La*k,g=h-(h-k),y=k-g,x=p*y-(m-d*g-p*g-d*y),w=c*S,h=La*c,d=h-(h-c),p=c-d,h=La*S,g=h-(h-S),y=S-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,Wa[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,Wa[1]=b-(v+l)+(l-w),A=_+v,l=A-_,Wa[2]=_-(A-l)+(v-l),Wa[3]=A;const P=ja(4,Xa,4,Wa,Ga);m=T*s,h=La*T,d=h-(h-T),p=T-d,h=La*s,g=h-(h-s),y=s-g,x=p*y-(m-d*g-p*g-d*y),w=E*f,h=La*E,d=h-(h-E),p=E-d,h=La*f,g=h-(h-f),y=f-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,Wa[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,Wa[1]=b-(v+l)+(l-w),A=_+v,l=A-_,Wa[2]=_-(A-l)+(v-l),Wa[3]=A;const z=ja(P,Ga,4,Wa,Va);m=u*s,h=La*u,d=h-(h-u),p=u-d,h=La*s,g=h-(h-s),y=s-g,x=p*y-(m-d*g-p*g-d*y),w=c*f,h=La*c,d=h-(h-c),p=c-d,h=La*f,g=h-(h-f),y=f-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,Wa[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,Wa[1]=b-(v+l)+(l-w),A=_+v,l=A-_,Wa[2]=_-(A-l)+(v-l),Wa[3]=A;const D=ja(z,Va,4,Wa,$a);return $a[D-1]}(t,n,e,r,i,o,f)}const Ka=Math.pow(2,-52),Qa=new Uint32Array(512);class Ja{static from(t,n=ou,e=au){const r=t.length,i=new Float64Array(2*r);for(let o=0;o>1;if(n>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;const e=Math.max(2*n-5,0);this._triangles=new Uint32Array(3*e),this._halfedges=new Int32Array(3*e),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:e,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let a=1/0,u=1/0,c=-1/0,f=-1/0;for(let n=0;nc&&(c=e),r>f&&(f=r),this._ids[n]=n}const s=(a+c)/2,l=(u+f)/2;let h,d,p,g=1/0;for(let n=0;n0&&(d=n,g=e)}let _=t[2*d],b=t[2*d+1],m=1/0;for(let n=0;nr&&(n[e++]=i,r=this._dists[i])}return this.hull=n.subarray(0,e),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(Za(y,v,_,b,x,w)<0){const t=d,n=_,e=b;d=p,_=x,b=w,p=t,x=n,w=e}const M=function(t,n,e,r,i,o){const a=e-t,u=r-n,c=i-t,f=o-n,s=a*a+u*u,l=c*c+f*f,h=.5/(a*f-u*c);return{x:t+(f*s-u*l)*h,y:n+(a*l-c*s)*h}}(y,v,_,b,x,w);this._cx=M.x,this._cy=M.y;for(let n=0;n0&&Math.abs(f-o)<=Ka&&Math.abs(s-a)<=Ka)continue;if(o=f,a=s,c===h||c===d||c===p)continue;let l=0;for(let t=0,n=this._hashKey(f,s);t=0;)if(y=g,y===l){y=-1;break}if(-1===y)continue;let v=this._addTriangle(y,c,e[y],-1,-1,r[y]);r[c]=this._legalize(v+2),r[y]=v,A++;let _=e[y];for(;g=e[_],Za(f,s,t[2*_],t[2*_+1],t[2*g],t[2*g+1])<0;)v=this._addTriangle(_,c,g,r[c],-1,r[_]),r[c]=this._legalize(v+2),e[_]=_,A--,_=g;if(y===l)for(;g=n[y],Za(f,s,t[2*g],t[2*g+1],t[2*y],t[2*y+1])<0;)v=this._addTriangle(g,c,y,-1,r[y],r[g]),this._legalize(v+2),r[g]=v,e[y]=y,A--,y=g;this._hullStart=n[c]=y,e[y]=n[_]=c,e[c]=_,i[this._hashKey(f,s)]=c,i[this._hashKey(t[2*y],t[2*y+1])]=y}this.hull=new Uint32Array(A);for(let t=0,n=this._hullStart;t0?3-e:1+e)/4}(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:e,coords:r}=this;let i=0,o=0;for(;;){const a=e[t],u=t-t%3;if(o=u+(t+2)%3,-1===a){if(0===i)break;t=Qa[--i];continue}const c=a-a%3,f=u+(t+1)%3,s=c+(a+2)%3,l=n[o],h=n[t],d=n[f],p=n[s];if(nu(r[2*l],r[2*l+1],r[2*h],r[2*h+1],r[2*d],r[2*d+1],r[2*p],r[2*p+1])){n[t]=p,n[a]=l;const r=e[s];if(-1===r){let n=this._hullStart;do{if(this._hullTri[n]===s){this._hullTri[n]=t;break}n=this._hullPrev[n]}while(n!==this._hullStart)}this._link(t,r),this._link(a,e[o]),this._link(o,s);const u=c+(a+1)%3;i=e&&n[t[a]]>o;)t[a+1]=t[a--];t[a+1]=r}else{let i=e+1,o=r;iu(t,e+r>>1,i),n[t[e]]>n[t[r]]&&iu(t,e,r),n[t[i]]>n[t[r]]&&iu(t,i,r),n[t[e]]>n[t[i]]&&iu(t,e,i);const a=t[i],u=n[a];for(;;){do{i++}while(n[t[i]]u);if(o=o-e?(ru(t,n,i,r),ru(t,n,e,o-1)):(ru(t,n,e,o-1),ru(t,n,i,r))}}function iu(t,n,e){const r=t[n];t[n]=t[e],t[e]=r}function ou(t){return t[0]}function au(t){return t[1]}const uu=1e-6;class cu{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(t,n){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(t,n){this._+=`L${this._x1=+t},${this._y1=+n}`}arc(t,n,e){const r=(t=+t)+(e=+e),i=n=+n;if(e<0)throw new Error("negative radius");null===this._x1?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>uu||Math.abs(this._y1-i)>uu)&&(this._+="L"+r+","+i),e&&(this._+=`A${e},${e},0,1,1,${t-e},${n}A${e},${e},0,1,1,${this._x1=r},${this._y1=i}`)}rect(t,n,e,r){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${+e}v${+r}h${-e}Z`}value(){return this._||null}}class fu{constructor(){this._=[]}moveTo(t,n){this._.push([t,n])}closePath(){this._.push(this._[0].slice())}lineTo(t,n){this._.push([t,n])}value(){return this._.length?this._:null}}class su{constructor(t,[n,e,r,i]=[0,0,960,500]){if(!((r=+r)>=(n=+n)&&(i=+i)>=(e=+e)))throw new Error("invalid bounds");this.delaunay=t,this._circumcenters=new Float64Array(2*t.points.length),this.vectors=new Float64Array(2*t.points.length),this.xmax=r,this.xmin=n,this.ymax=i,this.ymin=e,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:t,hull:n,triangles:e},vectors:r}=this,i=this.circumcenters=this._circumcenters.subarray(0,e.length/3*2);for(let n,r,o=0,a=0,u=e.length;o