UNPKG

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