phylotree
Version:
A JavaScript library for developing applications and interactive visualizations involving [phylogenetic trees](https://en.wikipedia.org/wiki/Phylogenetic_tree), written as an extension of the [D3](http://d3js.org) [hierarchy layout](https://github.com/d3/
1 lines • 189 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("underscore"),require("lodash")):"function"==typeof define&&define.amd?define(["exports","underscore","lodash"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).phylotree=t.phylotree||{},t._,t._$1)}(this,function(t,e,n){"use strict";function i(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var r=i(e),s=i(n);function o(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function a(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function l(t){let e,n,i;function r(t,i,r=0,s=t.length){if(r<s){if(0!==e(i,i))return s;do{const e=r+s>>>1;n(t[e],i)<0?r=e+1:s=e}while(r<s)}return r}return 2!==t.length?(e=o,n=(e,n)=>o(t(e),n),i=(e,n)=>t(e)-n):(e=t===o||t===a?t:h,n=t,i=t),{left:r,center:function(t,e,n=0,s=t.length){const o=r(t,e,n,s-1);return o>n&&i(t[o-1],e)>-i(t[o],e)?o-1:o},right:function(t,i,r=0,s=t.length){if(r<s){if(0!==e(i,i))return s;do{const e=r+s>>>1;n(t[e],i)<=0?r=e+1:s=e}while(r<s)}return r}}}function h(){return 0}const u=l(o).right;l(function(t){return null===t?NaN:+t}).center;const c=Math.sqrt(50),d=Math.sqrt(10),f=Math.sqrt(2);function p(t,e,n){const i=(e-t)/Math.max(0,n),r=Math.floor(Math.log10(i)),s=i/Math.pow(10,r),o=s>=c?10:s>=d?5:s>=f?2:1;let a,l,h;return r<0?(h=Math.pow(10,-r)/o,a=Math.round(t*h),l=Math.round(e*h),a/h<t&&++a,l/h>e&&--l,h=-h):(h=Math.pow(10,r)*o,a=Math.round(t/h),l=Math.round(e/h),a*h<t&&++a,l*h>e&&--l),l<a&&.5<=n&&n<2?p(t,e,2*n):[a,l,h]}function g(t,e,n){return p(t=+t,e=+e,n=+n)[2]}function _(t){return t}var m=1e-6;function y(t){return"translate("+t+",0)"}function v(t){return e=>+t(e)}function b(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function x(){return!this.__axis}function w(t,e){var n=[],i=null,r=null,s=6,o=6,a=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,h=-1,u="y",c=y;function d(t){var d=null==i?e.ticks?e.ticks.apply(e,n):e.domain():i,f=null==r?e.tickFormat?e.tickFormat.apply(e,n):_:r,p=Math.max(s,0)+a,g=e.range(),y=+g[0]+l,w=+g[g.length-1]+l,N=(e.bandwidth?b:v)(e.copy(),l),E=t.selection?t.selection():t,S=E.selectAll(".domain").data([null]),T=E.selectAll(".tick").data(d,e).order(),M=T.exit(),k=T.enter().append("g").attr("class","tick"),A=T.select("line"),C=T.select("text");S=S.merge(S.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),T=T.merge(k),A=A.merge(k.append("line").attr("stroke","currentColor").attr("y2",h*s)),C=C.merge(k.append("text").attr("fill","currentColor").attr(u,h*p).attr("dy","0em")),t!==E&&(S=S.transition(t),T=T.transition(t),A=A.transition(t),C=C.transition(t),M=M.transition(t).attr("opacity",m).attr("transform",function(t){return isFinite(t=N(t))?c(t+l):this.getAttribute("transform")}),k.attr("opacity",m).attr("transform",function(t){var e=this.parentNode.__axis;return c((e&&isFinite(e=e(t))?e:N(t))+l)})),M.remove(),S.attr("d",o?"M"+y+","+h*o+"V"+l+"H"+w+"V"+h*o:"M"+y+","+l+"H"+w),T.attr("opacity",1).attr("transform",function(t){return c(N(t)+l)}),A.attr("y2",h*s),C.attr(u,h*p).text(f),E.filter(x).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor","middle"),E.each(function(){this.__axis=N})}return d.scale=function(t){return arguments.length?(e=t,d):e},d.ticks=function(){return n=Array.from(arguments),d},d.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),d):n.slice()},d.tickValues=function(t){return arguments.length?(i=null==t?null:Array.from(t),d):i&&i.slice()},d.tickFormat=function(t){return arguments.length?(r=t,d):r},d.tickSize=function(t){return arguments.length?(s=o=+t,d):s},d.tickSizeInner=function(t){return arguments.length?(s=+t,d):s},d.tickSizeOuter=function(t){return arguments.length?(o=+t,d):o},d.tickPadding=function(t){return arguments.length?(a=+t,d):a},d.offset=function(t){return arguments.length?(l=+t,d):l},d}var N={value:()=>{}};function E(){for(var t,e=0,n=arguments.length,i={};e<n;++e){if(!(t=arguments[e]+"")||t in i||/[\s.]/.test(t))throw new Error("illegal type: "+t);i[t]=[]}return new S(i)}function S(t){this._=t}function T(t,e){for(var n,i=0,r=t.length;i<r;++i)if((n=t[i]).name===e)return n.value}function M(t,e,n){for(var i=0,r=t.length;i<r;++i)if(t[i].name===e){t[i]=N,t=t.slice(0,i).concat(t.slice(i+1));break}return null!=n&&t.push({name:e,value:n}),t}S.prototype=E.prototype={constructor:S,on:function(t,e){var n,i,r=this._,s=(i=r,(t+"").trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!i.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),o=-1,a=s.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o<a;)if(n=(t=s[o]).type)r[n]=M(r[n],t.name,e);else if(null==e)for(n in r)r[n]=M(r[n],t.name,null);return this}for(;++o<a;)if((n=(t=s[o]).type)&&(n=T(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new S(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,i,r=new Array(n),s=0;s<n;++s)r[s]=arguments[s+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=0,n=(i=this._[t]).length;s<n;++s)i[s].value.apply(e,r)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],r=0,s=i.length;r<s;++r)i[r].value.apply(e,n)}};var k="http://www.w3.org/1999/xhtml",A={svg:"http://www.w3.org/2000/svg",xhtml:k,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function C(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),A.hasOwnProperty(e)?{space:A[e],local:t}:t}function z(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===k&&e.documentElement.namespaceURI===k?e.createElement(t):e.createElementNS(n,t)}}function $(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function P(t){var e=C(t);return(e.local?$:z)(e)}function D(){}function I(t){return null==t?D:function(){return this.querySelector(t)}}function L(){return[]}function O(t){return null==t?L:function(){return this.querySelectorAll(t)}}function U(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function j(t){return function(){return this.matches(t)}}function F(t){return function(e){return e.matches(t)}}var V=Array.prototype.find;function Y(){return this.firstElementChild}var H=Array.prototype.filter;function R(){return Array.from(this.children)}function B(t){return new Array(t.length)}function q(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function X(t,e,n,i,r,s){for(var o,a=0,l=e.length,h=s.length;a<h;++a)(o=e[a])?(o.__data__=s[a],i[a]=o):n[a]=new q(t,s[a]);for(;a<l;++a)(o=e[a])&&(r[a]=o)}function Z(t,e,n,i,r,s,o){var a,l,h,u=new Map,c=e.length,d=s.length,f=new Array(c);for(a=0;a<c;++a)(l=e[a])&&(f[a]=h=o.call(l,l.__data__,a,e)+"",u.has(h)?r[a]=l:u.set(h,l));for(a=0;a<d;++a)h=o.call(t,s[a],a,s)+"",(l=u.get(h))?(i[a]=l,l.__data__=s[a],u.delete(h)):n[a]=new q(t,s[a]);for(a=0;a<c;++a)(l=e[a])&&u.get(f[a])===l&&(r[a]=l)}function W(t){return t.__data__}function G(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function J(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function K(t){return function(){this.removeAttribute(t)}}function Q(t){return function(){this.removeAttributeNS(t.space,t.local)}}function tt(t,e){return function(){this.setAttribute(t,e)}}function et(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function nt(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function it(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function rt(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function st(t){return function(){this.style.removeProperty(t)}}function ot(t,e,n){return function(){this.style.setProperty(t,e,n)}}function at(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function lt(t,e){return t.style.getPropertyValue(e)||rt(t).getComputedStyle(t,null).getPropertyValue(e)}function ht(t){return function(){delete this[t]}}function ut(t,e){return function(){this[t]=e}}function ct(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function dt(t){return t.trim().split(/^|\s+/)}function ft(t){return t.classList||new pt(t)}function pt(t){this._node=t,this._names=dt(t.getAttribute("class")||"")}function gt(t,e){for(var n=ft(t),i=-1,r=e.length;++i<r;)n.add(e[i])}function _t(t,e){for(var n=ft(t),i=-1,r=e.length;++i<r;)n.remove(e[i])}function mt(t){return function(){gt(this,t)}}function yt(t){return function(){_t(this,t)}}function vt(t,e){return function(){(e.apply(this,arguments)?gt:_t)(this,t)}}function bt(){this.textContent=""}function xt(t){return function(){this.textContent=t}}function wt(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Nt(){this.innerHTML=""}function Et(t){return function(){this.innerHTML=t}}function St(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function Tt(){this.nextSibling&&this.parentNode.appendChild(this)}function Mt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function kt(){return null}function At(){var t=this.parentNode;t&&t.removeChild(this)}function Ct(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function zt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function $t(t){return function(){var e=this.__on;if(e){for(var n,i=0,r=-1,s=e.length;i<s;++i)n=e[i],t.type&&n.type!==t.type||n.name!==t.name?e[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?e.length=r:delete this.__on}}}function Pt(t,e,n){return function(){var i,r=this.__on,s=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(r)for(var o=0,a=r.length;o<a;++o)if((i=r[o]).type===t.type&&i.name===t.name)return this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),void(i.value=e);this.addEventListener(t.type,s,n),i={type:t.type,name:t.name,value:e,listener:s,options:n},r?r.push(i):this.__on=[i]}}function Dt(t,e,n){var i=rt(t),r=i.CustomEvent;"function"==typeof r?r=new r(e,n):(r=i.document.createEvent("Event"),n?(r.initEvent(e,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(e,!1,!1)),t.dispatchEvent(r)}function It(t,e){return function(){return Dt(this,t,e)}}function Lt(t,e){return function(){return Dt(this,t,e.apply(this,arguments))}}q.prototype={constructor:q,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},pt.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Ot=[null];function Ut(t,e){this._groups=t,this._parents=e}function jt(){return new Ut([[document.documentElement]],Ot)}function Ft(t){return"string"==typeof t?new Ut([[document.querySelector(t)]],[document.documentElement]):new Ut([[t]],Ot)}function Vt(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=t.clientX,i.y=t.clientY,[(i=i.matrixTransform(e.getScreenCTM().inverse())).x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}Ut.prototype=jt.prototype={constructor:Ut,select:function(t){"function"!=typeof t&&(t=I(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var s,o,a=e[r],l=a.length,h=i[r]=new Array(l),u=0;u<l;++u)(s=a[u])&&(o=t.call(s,s.__data__,u,a))&&("__data__"in s&&(o.__data__=s.__data__),h[u]=o);return new Ut(i,this._parents)},selectAll:function(t){t="function"==typeof t?U(t):O(t);for(var e=this._groups,n=e.length,i=[],r=[],s=0;s<n;++s)for(var o,a=e[s],l=a.length,h=0;h<l;++h)(o=a[h])&&(i.push(t.call(o,o.__data__,h,a)),r.push(o));return new Ut(i,r)},selectChild:function(t){return this.select(null==t?Y:function(t){return function(){return V.call(this.children,t)}}("function"==typeof t?t:F(t)))},selectChildren:function(t){return this.selectAll(null==t?R:function(t){return function(){return H.call(this.children,t)}}("function"==typeof t?t:F(t)))},filter:function(t){"function"!=typeof t&&(t=j(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var s,o=e[r],a=o.length,l=i[r]=[],h=0;h<a;++h)(s=o[h])&&t.call(s,s.__data__,h,o)&&l.push(s);return new Ut(i,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,W);var n=e?Z:X,i=this._parents,r=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var s=r.length,o=new Array(s),a=new Array(s),l=new Array(s),h=0;h<s;++h){var u=i[h],c=r[h],d=c.length,f=G(t.call(u,u&&u.__data__,h,i)),p=f.length,g=a[h]=new Array(p),_=o[h]=new Array(p);n(u,c,g,_,l[h]=new Array(d),f,e);for(var m,y,v=0,b=0;v<p;++v)if(m=g[v]){for(v>=b&&(b=v+1);!(y=_[b])&&++b<p;);m._next=y||null}}return(o=new Ut(o,i))._enter=a,o._exit=l,o},enter:function(){return new Ut(this._enter||this._groups.map(B),this._parents)},exit:function(){return new Ut(this._exit||this._groups.map(B),this._parents)},join:function(t,e,n){var i=this.enter(),r=this,s=this.exit();return"function"==typeof t?(i=t(i))&&(i=i.selection()):i=i.append(t+""),null!=e&&(r=e(r))&&(r=r.selection()),null==n?s.remove():n(s),i&&r?i.merge(r).order():r},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,i=e._groups,r=n.length,s=i.length,o=Math.min(r,s),a=new Array(r),l=0;l<o;++l)for(var h,u=n[l],c=i[l],d=u.length,f=a[l]=new Array(d),p=0;p<d;++p)(h=u[p]||c[p])&&(f[p]=h);for(;l<r;++l)a[l]=n[l];return new Ut(a,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var i,r=t[e],s=r.length-1,o=r[s];--s>=0;)(i=r[s])&&(o&&4^i.compareDocumentPosition(o)&&o.parentNode.insertBefore(i,o),o=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=J);for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var o,a=n[s],l=a.length,h=r[s]=new Array(l),u=0;u<l;++u)(o=a[u])&&(h[u]=o);h.sort(e)}return new Ut(r,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var i=t[e],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var r,s=e[n],o=0,a=s.length;o<a;++o)(r=s[o])&&t.call(r,r.__data__,o,s);return this},attr:function(t,e){var n=C(t);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((null==e?n.local?Q:K:"function"==typeof e?n.local?it:nt:n.local?et:tt)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?st:"function"==typeof e?at:ot)(t,e,null==n?"":n)):lt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?ht:"function"==typeof e?ct:ut)(t,e)):this.node()[t]},classed:function(t,e){var n=dt(t+"");if(arguments.length<2){for(var i=ft(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each(("function"==typeof e?vt:e?mt:yt)(n,e))},text:function(t){return arguments.length?this.each(null==t?bt:("function"==typeof t?wt:xt)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Nt:("function"==typeof t?St:Et)(t)):this.node().innerHTML},raise:function(){return this.each(Tt)},lower:function(){return this.each(Mt)},append:function(t){var e="function"==typeof t?t:P(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var n="function"==typeof t?t:P(t),i=null==e?kt:"function"==typeof e?e:I(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})},remove:function(){return this.each(At)},clone:function(t){return this.select(t?zt:Ct)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var i,r,s=function(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),o=s.length;if(!(arguments.length<2)){for(a=e?Pt:$t,i=0;i<o;++i)this.each(a(s[i],e,n));return this}var a=this.node().__on;if(a)for(var l,h=0,u=a.length;h<u;++h)for(i=0,l=a[h];i<o;++i)if((r=s[i]).type===l.type&&r.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?Lt:It)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var i,r=t[e],s=0,o=r.length;s<o;++s)(i=r[s])&&(yield i)}};const Yt={capture:!0,passive:!1};function Ht(t){t.preventDefault(),t.stopImmediatePropagation()}function Rt(t){var e=t.document.documentElement,n=Ft(t).on("dragstart.drag",Ht,Yt);"onselectstart"in e?n.on("selectstart.drag",Ht,Yt):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Bt(t,e){var n=t.document.documentElement,i=Ft(t).on("dragstart.drag",null);e&&(i.on("click.drag",Ht,Yt),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function qt(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Xt(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function Zt(){}var Wt=.7,Gt=1/Wt,Jt="\\s*([+-]?\\d+)\\s*",Kt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",te=/^#([0-9a-f]{3,8})$/,ee=new RegExp(`^rgb\\(${Jt},${Jt},${Jt}\\)$`),ne=new RegExp(`^rgb\\(${Qt},${Qt},${Qt}\\)$`),ie=new RegExp(`^rgba\\(${Jt},${Jt},${Jt},${Kt}\\)$`),re=new RegExp(`^rgba\\(${Qt},${Qt},${Qt},${Kt}\\)$`),se=new RegExp(`^hsl\\(${Kt},${Qt},${Qt}\\)$`),oe=new RegExp(`^hsla\\(${Kt},${Qt},${Qt},${Kt}\\)$`),ae={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 le(){return this.rgb().formatHex()}function he(){return this.rgb().formatRgb()}function ue(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=te.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?ce(e):3===n?new pe(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?de(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?de(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=ee.exec(t))?new pe(e[1],e[2],e[3],1):(e=ne.exec(t))?new pe(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=ie.exec(t))?de(e[1],e[2],e[3],e[4]):(e=re.exec(t))?de(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=se.exec(t))?be(e[1],e[2]/100,e[3]/100,1):(e=oe.exec(t))?be(e[1],e[2]/100,e[3]/100,e[4]):ae.hasOwnProperty(t)?ce(ae[t]):"transparent"===t?new pe(NaN,NaN,NaN,0):null}function ce(t){return new pe(t>>16&255,t>>8&255,255&t,1)}function de(t,e,n,i){return i<=0&&(t=e=n=NaN),new pe(t,e,n,i)}function fe(t,e,n,i){return 1===arguments.length?((r=t)instanceof Zt||(r=ue(r)),r?new pe((r=r.rgb()).r,r.g,r.b,r.opacity):new pe):new pe(t,e,n,null==i?1:i);var r}function pe(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function ge(){return`#${ve(this.r)}${ve(this.g)}${ve(this.b)}`}function _e(){const t=me(this.opacity);return`${1===t?"rgb(":"rgba("}${ye(this.r)}, ${ye(this.g)}, ${ye(this.b)}${1===t?")":`, ${t})`}`}function me(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ye(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ve(t){return((t=ye(t))<16?"0":"")+t.toString(16)}function be(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new we(t,e,n,i)}function xe(t){if(t instanceof we)return new we(t.h,t.s,t.l,t.opacity);if(t instanceof Zt||(t=ue(t)),!t)return new we;if(t instanceof we)return t;var e=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),s=Math.max(e,n,i),o=NaN,a=s-r,l=(s+r)/2;return a?(o=e===s?(n-i)/a+6*(n<i):n===s?(i-e)/a+2:(e-n)/a+4,a/=l<.5?s+r:2-s-r,o*=60):a=l>0&&l<1?0:o,new we(o,a,l,t.opacity)}function we(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function Ne(t){return(t=(t||0)%360)<0?t+360:t}function Ee(t){return Math.max(0,Math.min(1,t||0))}function Se(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}qt(Zt,ue,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:le,formatHex:le,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return xe(this).formatHsl()},formatRgb:he,toString:he}),qt(pe,fe,Xt(Zt,{brighter(t){return t=null==t?Gt:Math.pow(Gt,t),new pe(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Wt:Math.pow(Wt,t),new pe(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new pe(ye(this.r),ye(this.g),ye(this.b),me(this.opacity))},displayable(){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:ge,formatHex:ge,formatHex8:function(){return`#${ve(this.r)}${ve(this.g)}${ve(this.b)}${ve(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:_e,toString:_e})),qt(we,function(t,e,n,i){return 1===arguments.length?xe(t):new we(t,e,n,null==i?1:i)},Xt(Zt,{brighter(t){return t=null==t?Gt:Math.pow(Gt,t),new we(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Wt:Math.pow(Wt,t),new we(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new pe(Se(t>=240?t-240:t+120,r,i),Se(t,r,i),Se(t<120?t+240:t-120,r,i),this.opacity)},clamp(){return new we(Ne(this.h),Ee(this.s),Ee(this.l),me(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=me(this.opacity);return`${1===t?"hsl(":"hsla("}${Ne(this.h)}, ${100*Ee(this.s)}%, ${100*Ee(this.l)}%${1===t?")":`, ${t})`}`}}));var Te=t=>()=>t;function Me(t){return 1===(t=+t)?ke:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}(e,n,t):Te(isNaN(e)?n:e)}}function ke(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Te(isNaN(t)?e:t)}var Ae=function t(e){var n=Me(e);function i(t,e){var i=n((t=fe(t)).r,(e=fe(e)).r),r=n(t.g,e.g),s=n(t.b,e.b),o=ke(t.opacity,e.opacity);return function(e){return t.r=i(e),t.g=r(e),t.b=s(e),t.opacity=o(e),t+""}}return i.gamma=t,i}(1);function Ce(t,e){e||(e=[]);var n,i=t?Math.min(e.length,t.length):0,r=e.slice();return function(s){for(n=0;n<i;++n)r[n]=t[n]*(1-s)+e[n]*s;return r}}function ze(t,e){var n,i=e?e.length:0,r=t?Math.min(i,t.length):0,s=new Array(r),o=new Array(i);for(n=0;n<r;++n)s[n]=Ue(t[n],e[n]);for(;n<i;++n)o[n]=e[n];return function(t){for(n=0;n<r;++n)o[n]=s[n](t);return o}}function $e(t,e){var n=new Date;return t=+t,e=+e,function(i){return n.setTime(t*(1-i)+e*i),n}}function Pe(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function De(t,e){var n,i={},r={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?i[n]=Ue(t[n],e[n]):r[n]=e[n];return function(t){for(n in i)r[n]=i[n](t);return r}}var Ie=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Le=new RegExp(Ie.source,"g");function Oe(t,e){var n,i,r,s=Ie.lastIndex=Le.lastIndex=0,o=-1,a=[],l=[];for(t+="",e+="";(n=Ie.exec(t))&&(i=Le.exec(e));)(r=i.index)>s&&(r=e.slice(s,r),a[o]?a[o]+=r:a[++o]=r),(n=n[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,l.push({i:o,x:Pe(n,i)})),s=Le.lastIndex;return s<e.length&&(r=e.slice(s),a[o]?a[o]+=r:a[++o]=r),a.length<2?l[0]?function(t){return function(e){return t(e)+""}}(l[0].x):function(t){return function(){return t}}(e):(e=l.length,function(t){for(var n,i=0;i<e;++i)a[(n=l[i]).i]=n.x(t);return a.join("")})}function Ue(t,e){var n,i=typeof e;return null==e||"boolean"===i?Te(e):("number"===i?Pe:"string"===i?(n=ue(e))?(e=n,Ae):Oe:e instanceof ue?Ae:e instanceof Date?$e:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?Ce:Array.isArray(e)?ze:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?De:Pe)(t,e)}function je(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var Fe,Ve=180/Math.PI,Ye={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function He(t,e,n,i,r,s){var o,a,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*n+e*i)&&(n-=t*l,i-=e*l),(a=Math.sqrt(n*n+i*i))&&(n/=a,i/=a,l/=a),t*i<e*n&&(t=-t,e=-e,l=-l,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(e,t)*Ve,skewX:Math.atan(l)*Ve,scaleX:o,scaleY:a}}function Re(t,e,n,i){function r(t){return t.length?t.pop()+" ":""}return function(s,o){var a=[],l=[];return s=t(s),o=t(o),function(t,i,r,s,o,a){if(t!==r||i!==s){var l=o.push("translate(",null,e,null,n);a.push({i:l-4,x:Pe(t,r)},{i:l-2,x:Pe(i,s)})}else(r||s)&&o.push("translate("+r+e+s+n)}(s.translateX,s.translateY,o.translateX,o.translateY,a,l),function(t,e,n,s){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),s.push({i:n.push(r(n)+"rotate(",null,i)-2,x:Pe(t,e)})):e&&n.push(r(n)+"rotate("+e+i)}(s.rotate,o.rotate,a,l),function(t,e,n,s){t!==e?s.push({i:n.push(r(n)+"skewX(",null,i)-2,x:Pe(t,e)}):e&&n.push(r(n)+"skewX("+e+i)}(s.skewX,o.skewX,a,l),function(t,e,n,i,s,o){if(t!==n||e!==i){var a=s.push(r(s)+"scale(",null,",",null,")");o.push({i:a-4,x:Pe(t,n)},{i:a-2,x:Pe(e,i)})}else 1===n&&1===i||s.push(r(s)+"scale("+n+","+i+")")}(s.scaleX,s.scaleY,o.scaleX,o.scaleY,a,l),s=o=null,function(t){for(var e,n=-1,i=l.length;++n<i;)a[(e=l[n]).i]=e.x(t);return a.join("")}}}var Be=Re(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Ye:He(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),qe=Re(function(t){return null==t?Ye:(Fe||(Fe=document.createElementNS("http://www.w3.org/2000/svg","g")),Fe.setAttribute("transform",t),(t=Fe.transform.baseVal.consolidate())?He((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Ye)},", ",")",")");function Xe(t){return((t=Math.exp(t))+1/t)/2}var Ze,We,Ge=function t(e,n,i){function r(t,r){var s,o,a=t[0],l=t[1],h=t[2],u=r[0],c=r[1],d=r[2],f=u-a,p=c-l,g=f*f+p*p;if(g<1e-12)o=Math.log(d/h)/e,s=function(t){return[a+t*f,l+t*p,h*Math.exp(e*t*o)]};else{var _=Math.sqrt(g),m=(d*d-h*h+i*g)/(2*h*n*_),y=(d*d-h*h-i*g)/(2*d*n*_),v=Math.log(Math.sqrt(m*m+1)-m),b=Math.log(Math.sqrt(y*y+1)-y);o=(b-v)/e,s=function(t){var i=t*o,r=Xe(v),s=h/(n*_)*(r*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*i+v)-function(t){return((t=Math.exp(t))-1/t)/2}(v));return[a+s*f,l+s*p,h*r/Xe(e*i+v)]}}return s.duration=1e3*o*e/Math.SQRT2,s}return r.rho=function(e){var n=Math.max(.001,+e),i=n*n;return t(n,i,i*i)},r}(Math.SQRT2,2,4),Je=0,Ke=0,Qe=0,tn=0,en=0,nn=0,rn="object"==typeof performance&&performance.now?performance:Date,sn="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function on(){return en||(sn(an),en=rn.now()+nn)}function an(){en=0}function ln(){this._call=this._time=this._next=null}function hn(t,e,n){var i=new ln;return i.restart(t,e,n),i}function un(){en=(tn=rn.now())+nn,Je=Ke=0;try{!function(){on(),++Je;for(var t,e=Ze;e;)(t=en-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Je}()}finally{Je=0,function(){var t,e,n=Ze,i=1/0;for(;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Ze=e);We=t,dn(i)}(),en=0}}function cn(){var t=rn.now(),e=t-tn;e>1e3&&(nn-=e,tn=t)}function dn(t){Je||(Ke&&(Ke=clearTimeout(Ke)),t-en>24?(t<1/0&&(Ke=setTimeout(un,t-rn.now()-nn)),Qe&&(Qe=clearInterval(Qe))):(Qe||(tn=rn.now(),Qe=setInterval(cn,1e3)),Je=1,sn(un)))}function fn(t,e,n){var i=new ln;return e=null==e?0:+e,i.restart(n=>{i.stop(),t(n+e)},e,n),i}ln.prototype=hn.prototype={constructor:ln,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?on():+n)+(null==e?0:+e),this._next||We===this||(We?We._next=this:Ze=this,We=this),this._call=t,this._time=n,dn()},stop:function(){this._call&&(this._call=null,this._time=1/0,dn())}};var pn=E("start","end","cancel","interrupt"),gn=[];function _n(t,e,n,i,r,s){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var i,r=t.__transition;function s(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(s){var h,u,c,d;if(1!==n.state)return l();for(h in r)if((d=r[h]).name===n.name){if(3===d.state)return fn(o);4===d.state?(d.state=6,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete r[h]):+h<e&&(d.state=6,d.timer.stop(),d.on.call("cancel",t,t.__data__,d.index,d.group),delete r[h])}if(fn(function(){3===n.state&&(n.state=4,n.timer.restart(a,n.delay,n.time),a(s))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,i=new Array(c=n.tween.length),h=0,u=-1;h<c;++h)(d=n.tween[h].value.call(t,t.__data__,n.index,n.group))&&(i[++u]=d);i.length=u+1}}function a(e){for(var r=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(l),n.state=5,1),s=-1,o=i.length;++s<o;)i[s].call(t,r);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){for(var i in n.state=6,n.timer.stop(),delete r[e],r)return;delete t.__transition}r[e]=n,n.timer=hn(s,0,n.time)}(t,n,{name:e,index:i,group:r,on:pn,tween:gn,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:0})}function mn(t,e){var n=vn(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function yn(t,e){var n=vn(t,e);if(n.state>3)throw new Error("too late; already running");return n}function vn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function bn(t,e){var n,i,r,s=t.__transition,o=!0;if(s){for(r in e=null==e?null:e+"",s)(n=s[r]).name===e?(i=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(i?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete s[r]):o=!1;o&&delete t.__transition}}function xn(t,e){var n,i;return function(){var r=yn(this,t),s=r.tween;if(s!==n)for(var o=0,a=(i=n=s).length;o<a;++o)if(i[o].name===e){(i=i.slice()).splice(o,1);break}r.tween=i}}function wn(t,e,n){var i,r;if("function"!=typeof n)throw new Error;return function(){var s=yn(this,t),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:e,value:n},l=0,h=r.length;l<h;++l)if(r[l].name===e){r[l]=a;break}l===h&&r.push(a)}s.tween=r}}function Nn(t,e,n){var i=t._id;return t.each(function(){var t=yn(this,i);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return vn(t,i).value[e]}}function En(t,e){var n;return("number"==typeof e?Pe:e instanceof ue?Ae:(n=ue(e))?(e=n,Ae):Oe)(t,e)}function Sn(t){return function(){this.removeAttribute(t)}}function Tn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Mn(t,e,n){var i,r,s=n+"";return function(){var o=this.getAttribute(t);return o===s?null:o===i?r:r=e(i=o,n)}}function kn(t,e,n){var i,r,s=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===s?null:o===i?r:r=e(i=o,n)}}function An(t,e,n){var i,r,s;return function(){var o,a,l=n(this);if(null!=l)return(o=this.getAttribute(t))===(a=l+"")?null:o===i&&a===r?s:(r=a,s=e(i=o,l));this.removeAttribute(t)}}function Cn(t,e,n){var i,r,s;return function(){var o,a,l=n(this);if(null!=l)return(o=this.getAttributeNS(t.space,t.local))===(a=l+"")?null:o===i&&a===r?s:(r=a,s=e(i=o,l));this.removeAttributeNS(t.space,t.local)}}function zn(t,e){var n,i;function r(){var r=e.apply(this,arguments);return r!==i&&(n=(i=r)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,r)),n}return r._value=e,r}function $n(t,e){var n,i;function r(){var r=e.apply(this,arguments);return r!==i&&(n=(i=r)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,r)),n}return r._value=e,r}function Pn(t,e){return function(){mn(this,t).delay=+e.apply(this,arguments)}}function Dn(t,e){return e=+e,function(){mn(this,t).delay=e}}function In(t,e){return function(){yn(this,t).duration=+e.apply(this,arguments)}}function Ln(t,e){return e=+e,function(){yn(this,t).duration=e}}var On=jt.prototype.constructor;function Un(t){return function(){this.style.removeProperty(t)}}var jn=0;function Fn(t,e,n,i){this._groups=t,this._parents=e,this._name=n,this._id=i}function Vn(){return++jn}var Yn=jt.prototype;Fn.prototype={constructor:Fn,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=I(t));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a,l,h=i[o],u=h.length,c=s[o]=new Array(u),d=0;d<u;++d)(a=h[d])&&(l=t.call(a,a.__data__,d,h))&&("__data__"in a&&(l.__data__=a.__data__),c[d]=l,_n(c[d],e,n,d,c,vn(a,n)));return new Fn(s,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=O(t));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var l,h=i[a],u=h.length,c=0;c<u;++c)if(l=h[c]){for(var d,f=t.call(l,l.__data__,c,h),p=vn(l,n),g=0,_=f.length;g<_;++g)(d=f[g])&&_n(d,e,n,g,f,p);s.push(f),o.push(l)}return new Fn(s,o,e,n)},selectChild:Yn.selectChild,selectChildren:Yn.selectChildren,filter:function(t){"function"!=typeof t&&(t=j(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r<n;++r)for(var s,o=e[r],a=o.length,l=i[r]=[],h=0;h<a;++h)(s=o[h])&&t.call(s,s.__data__,h,o)&&l.push(s);return new Fn(i,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,i=e.length,r=n.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var l,h=e[a],u=n[a],c=h.length,d=o[a]=new Array(c),f=0;f<c;++f)(l=h[f]||u[f])&&(d[f]=l);for(;a<i;++a)o[a]=e[a];return new Fn(o,this._parents,this._name,this._id)},selection:function(){return new On(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Vn(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o,a=i[s],l=a.length,h=0;h<l;++h)if(o=a[h]){var u=vn(o,e);_n(o,t,n,h,a,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Fn(i,this._parents,t,n)},call:Yn.call,nodes:Yn.nodes,node:Yn.node,size:Yn.size,empty:Yn.empty,each:Yn.each,on:function(t,e){var n=this._id;return arguments.length<2?vn(this.node(),n).on.on(t):this.each(function(t,e,n){var i,r,s=function(t){return(t+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?mn:yn;return function(){var o=s(this,t),a=o.on;a!==i&&(r=(i=a).copy()).on(e,n),o.on=r}}(n,t,e))},attr:function(t,e){var n=C(t),i="transform"===n?qe:En;return this.attrTween(t,"function"==typeof e?(n.local?Cn:An)(n,i,Nn(this,"attr."+t,e)):null==e?(n.local?Tn:Sn)(n):(n.local?kn:Mn)(n,i,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var i=C(t);return this.tween(n,(i.local?zn:$n)(i,e))},style:function(t,e,n){var i="transform"==(t+="")?Be:En;return null==e?this.styleTween(t,function(t,e){var n,i,r;return function(){var s=lt(this,t),o=(this.style.removeProperty(t),lt(this,t));return s===o?null:s===n&&o===i?r:r=e(n=s,i=o)}}(t,i)).on("end.style."+t,Un(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var i,r,s;return function(){var o=lt(this,t),a=n(this),l=a+"";return null==a&&(this.style.removeProperty(t),l=a=lt(this,t)),o===l?null:o===i&&l===r?s:(r=l,s=e(i=o,a))}}(t,i,Nn(this,"style."+t,e))).each(function(t,e){var n,i,r,s,o="style."+e,a="end."+o;return function(){var l=yn(this,t),h=l.on,u=null==l.value[o]?s||(s=Un(e)):void 0;h===n&&r===u||(i=(n=h).copy()).on(a,r=u),l.on=i}}(this._id,t)):this.styleTween(t,function(t,e,n){var i,r,s=n+"";return function(){var o=lt(this,t);return o===s?null:o===i?r:r=e(i=o,n)}}(t,i,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var i="style."+(t+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(null==e)return this.tween(i,null);if("function"!=typeof e)throw new Error;return this.tween(i,function(t,e,n){var i,r;function s(){var s=e.apply(this,arguments);return s!==r&&(i=(r=s)&&function(t,e,n){return function(i){this.style.setProperty(t,e.call(this,i),n)}}(t,s,n)),i}return s._value=e,s}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Nn(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function i(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&function(t){return function(e){this.textContent=t.call(this,e)}}(i)),e}return i._value=t,i}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var i,r=vn(this.node(),n).tween,s=0,o=r.length;s<o;++s)if((i=r[s]).name===t)return i.value;return null}return this.each((null==e?xn:wn)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Pn:Dn)(e,t)):vn(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?In:Ln)(e,t)):vn(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw new Error;return function(){yn(this,t).ease=e}}(e,t)):vn(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;yn(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,i=n._id,r=n.size();return new Promise(function(s,o){var a={value:o},l={value:function(){0===--r&&s()}};n.each(function(){var n=yn(this,i),r=n.on;r!==t&&((e=(t=r).copy())._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),n.on=e}),0===r&&s()})},[Symbol.iterator]:Yn[Symbol.iterator]};var Hn={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Rn(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}jt.prototype.interrupt=function(t){return this.each(function(){bn(this,t)})},jt.prototype.transition=function(t){var e,n;t instanceof Fn?(e=t._id,t=t._name):(e=Vn(),(n=Hn).time=on(),t=null==t?null:t+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o,a=i[s],l=a.length,h=0;h<l;++h)(o=a[h])&&_n(o,t,e,h,a,n||Rn(o,e));return new Fn(i,this._parents,t,e)};var Bn=t=>()=>t;function qn(t,{sourceEvent:e,target:n,selection:i,mode:r,dispatch:s}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:i,enumerable:!0,configurable:!0},mode:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Xn(t){t.preventDefault(),t.stopImmediatePropagation()}var Zn={name:"drag"},Wn={name:"space"},Gn={name:"handle"},Jn={name:"center"};const{abs:Kn,max:Qn,min:ti}=Math;function ei(t){return[+t[0],+t[1]]}function ni(t){return[ei(t[0]),ei(t[1])]}var ii={},ri={},si={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(ci),input:function(t){return null==t?null:ni(t)},output:function(t){return t}},oi={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"},ai={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},li={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},hi={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},ui={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function ci(t){return{type:t}}function di(t){return!t.ctrlKey&&!t.button}function fi(){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 pi(){return navigator.maxTouchPoints||"ontouchstart"in this}function gi(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function _i(){return function(t){var e,n=fi,i=di,r=pi,s=!0,o=E("start","brush","end"),a=6;function l(e){var n=e.property("__brush",g).selectAll(".overlay").data([ci("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",oi.overlay).merge(n).each(function(){var t=gi(this).extent;Ft(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])}),e.selectAll(".selection").data([ci("selection")]).enter().append("rect").attr("class","selection").attr("cursor",oi.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var i=e.selectAll(".handle").data(t.handles,function(t){return t.type});i.exit().remove(),i.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return oi[t.type]}),e.each(h).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",d).filter(r).on("touchstart.brush",d).on("touchmove.brush",f).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(){var t=Ft(this),e=gi(this).selection;e?(t.selectAll(".selection").style("display",null).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1]),t.selectAll(".handle").style("display",null).attr("x",function(t){return"e"===t.type[t.type.length-1]?e[1][0]-a/2:e[0][0]-a/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-a/2:e[0][1]-a/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+a:a}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+a:a})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function u(t,e,n){var i=t.__brush.emitter;return!i||n&&i.clean?new c(t,e,n):i}function c(t,e,n){this.that=t,this.args=e,this.state=t.__brush,this.active=0,this.clean=n}function d(n){if((!e||n.touches)&&i.apply(this,arguments)){var r,o,a,l,c,d,f,p,g,_,m,y=this,v=n.target.__data__.type,b="selection"===(s&&n.metaKey?v="overlay":v)?Zn:s&&n.altKey?Jn:Gn,x=t===ri?null:hi[v],w=t===ii?null:ui[v],N=gi(y),E=N.extent,S=N.selection,T=E[0][0],M=E[0][1],k=E[1][0],A=E[1][1],C=0,z=0,$=x&&w&&s&&n.shiftKey,P=Array.from(n.touches||[n],t=>{const e=t.identifier;return(t=Vt(t,y)).point0=t.slice(),t.identifier=e,t});bn(y);var D=u(y,arguments,!0).beforestart();if("overlay"===v){S&&(g=!0);const e=[P[0],P[1]||P[0]];N.selection=S=[[r=t===ri?T:ti(e[0][0],e[1][0]),a=t===ii?M:ti(e[0][1],e[1][1])],[c=t===ri?k:Qn(e[0][0],e[1][0]),f=t===ii?A:Qn(e[0][1],e[1][1])]],P.length>1&&j(n)}else r=S[0][0],a=S[0][1],c=S[1][0],f=S[1][1];o=r,l=a,d=c,p=f;var I=Ft(y).attr("pointer-events","none"),L=I.selectAll(".overlay").attr("cursor",oi[v]);if(n.touches)D.moved=U,D.ended=F;else{var O=Ft(n.view).on("mousemove.brush",U,!0).on("mouseup.brush",F,!0);s&&O.on("keydown.brush",V,!0).on("keyup.brush",Y,!0),Rt(n.view)}h.call(y),D.start(n,b.name)}function U(t){for(const e of t.changedTouches||[t])for(const t of P)t.identifier===e.identifier&&(t.cur=Vt(e,y));if($&&!_&&!m&&1===P.length){const t=P[0];Kn(t.cur[0]-t[0])>Kn(t.cur[1]-t[1])?m=!0:_=!0}for(const t of P)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);g=!0,Xn(t),j(t)}function j(t){const e=P[0],n=e.point0;var i;switch(C=e[0]-n[0],z=e[1]-n[1],b){case Wn:case Zn:x&&(C=Qn(T-r,ti(k-c,C)),o=r+C,d=c+C),w&&(z=Qn(M-a,ti(A-f,z)),l=a+z,p=f+z);break;case Gn:P[1]?(x&&(o=Qn(T,ti(k,P[0][0])),d=Qn(T,ti(k,P[1][0])),x=1),w&&(l=Qn(M,ti(A,P[0][1])),p=Qn(M,ti(A,P[1][1])),w=1)):(x<0?(C=Qn(T-r,ti(k-r,C)),o=r+C,d=c):x>0&&(C=Qn(T-c,ti(k-c,C)),o=r,d=c+C),w<0?(z=Qn(M-a,ti(A-a,z)),l=a+z,p=f):w>0&&(z=Qn(M-f,ti(A-f,z)),l=a,p=f+z));break;case Jn:x&&(o=Qn(T,ti(k,r-C*x)),d=Qn(T,ti(k,c+C*x))),w&&(l=Qn(M,ti(A,a-z*w)),p=Qn(M,ti(A,f+z*w)))}d<o&&(x*=-1,i=r,r=c,c=i,i=o,o=d,d=i,v in ai&&L.attr("cursor",oi[v=ai[v]])),p<l&&(w*=-1,i=a,a=f,f=i,i=l,l=p,p=i,v in li&&L.attr("cursor",oi[v=li[v]])),N.selection&&(S=N.selection),_&&(o=S[0][0],d=S[1][0]),m&&(l=S[0][1],p=S[1][1]),S[0][0]===o&&S[0][1]===l&&S[1][0]===d&&S[1][1]===p||(N.selection=[[o,l],[d,p]],h.call(y),D.brush(t,b.name))}function F(t){if(function(t){t.stopImmediatePropagation()}(t),t.touches){if(t.touches.length)return;e&&clearTimeout(e),e=setTimeout(function(){e=null},500)}else Bt(t.view,g),O.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);I.attr("pointer-events","all"),L.attr("cursor",oi.overlay),N.selection&&(S=N.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(S)&&(N.selection=null,h.call(y)),D.end(t,b.name)}function V(t){switch(t.keyCode){case 16:$=x&&w;break;case 18:b===Gn&&(x&&(c=d-C*x,r=o+C*x),w&&(f=p-z*w,a=l+z*w),b=Jn,j(t));break;case 32:b!==Gn&&b!==Jn||(x<0?c=d-C:x>0&&(r=o-C),w<0?f=p-z:w>0&&(a=l-z),b=Wn,L.attr("cursor",oi.selection),j(t));break;default:return}Xn(t)}function Y(t){switch(t.keyCode){case 16:$&&(_=m=$=!1,j(t));break;case 18:b===Jn&&(x<0?c=d:x>0&&(r=o),w<0?f=p:w>0&&(a=l),b=Gn,j(t));break;case 32:b===Wn&&(t.altKey?(x&&(c=d-C*x,r=o+C*x),w&&(f=p-z*w,a=l+z*w),b=Jn):(x<0?c=d:x>0&&(r=o),w<0?f=p:w>0&&(a=l),b=Gn),L.attr("cursor",oi[v]),j(t));break;default:return}Xn(t)}}function f(t){u(this,arguments).moved(t)}function p(t){u(this,arguments).ended(t)}function g(){var e=this.__brush||{selection:null};return e.extent=ni(n.apply(this,arguments)),e.dim=t,e}return l.move=function(e,n,i){e.tween?e.on("start.brush",function(t){u(this,arguments).beforestart().start(t)}).on("interrupt.brush end.brush",function(t){u(this,arguments).end(t)}).tween("brush",function(){var e=this,i=e.__brush,r=u(e,arguments),s=i.selection,o=t.input("function"==typeof n?n.apply(this,arguments):n,i.extent),a=Ue(s,o);function l(t){i.selection=1===t&&null===o?null:a(t),h.call(e),r.brush()}return null!==s&&nul