phylotree 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/phylotree.js +8548 -58
- package/dist/phylotree.min.js +2 -1
- package/package.json +6 -3
- package/src/formats/nexml.js +2 -2
- package/src/formats/phyloxml.js +24 -4
package/dist/phylotree.min.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("underscore"),require("xml2js"),require("lodash")):"function"==typeof define&&define.amd?define(["exports","underscore","xml2js","lodash"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).phylotree=t.phylotree||{},t._,t.xml2js,t._$1)}(this,function(t,e,n,r){"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 r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var a=i(e),o=i(r);function s(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function l(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function u(t){let e,n,r;function i(t,r,i=0,a=t.length){if(i<a){if(0!==e(r,r))return a;do{const e=i+a>>>1;n(t[e],r)<0?i=e+1:a=e}while(i<a)}return i}return 2!==t.length?(e=s,n=(e,n)=>s(t(e),n),r=(e,n)=>t(e)-n):(e=t===s||t===l?t:c,n=t,r=t),{left:i,center:function(t,e,n=0,a=t.length){const o=i(t,e,n,a-1);return o>n&&r(t[o-1],e)>-r(t[o],e)?o-1:o},right:function(t,r,i=0,a=t.length){if(i<a){if(0!==e(r,r))return a;do{const e=i+a>>>1;n(t[e],r)<=0?i=e+1:a=e}while(i<a)}return i}}}function c(){return 0}const h=u(s).right;u(function(t){return null===t?NaN:+t}).center;var f=h;const d=Math.sqrt(50),p=Math.sqrt(10),_=Math.sqrt(2);function g(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=d?10:a>=p?5:a>=_?2:1;let s,l,u;return i<0?(u=Math.pow(10,-i)/o,s=Math.round(t*u),l=Math.round(e*u),s/u<t&&++s,l/u>e&&--l,u=-u):(u=Math.pow(10,i)*o,s=Math.round(t/u),l=Math.round(e/u),s*u<t&&++s,l*u>e&&--l),l<s&&.5<=n&&n<2?g(t,e,2*n):[s,l,u]}function m(t,e,n){return g(t=+t,e=+e,n=+n)[2]}function v(t){return t}var y=1e-6;function b(t){return"translate("+t+",0)"}function w(t){return"translate(0,"+t+")"}function x(t){return e=>+t(e)}function M(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function k(){return!this.__axis}function N(t,e){var n=[],r=null,i=null,a=6,o=6,s=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,u=1===t||4===t?-1:1,c=4===t||2===t?"x":"y",h=1===t||3===t?b:w;function f(f){var d=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,p=null==i?e.tickFormat?e.tickFormat.apply(e,n):v:i,_=Math.max(a,0)+s,g=e.range(),m=+g[0]+l,b=+g[g.length-1]+l,w=(e.bandwidth?M:x)(e.copy(),l),N=f.selection?f.selection():f,T=N.selectAll(".domain").data([null]),A=N.selectAll(".tick").data(d,e).order(),z=A.exit(),S=A.enter().append("g").attr("class","tick"),E=A.select("line"),C=A.select("text");T=T.merge(T.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),A=A.merge(S),E=E.merge(S.append("line").attr("stroke","currentColor").attr(c+"2",u*a)),C=C.merge(S.append("text").attr("fill","currentColor").attr(c,u*_).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),f!==N&&(T=T.transition(f),A=A.transition(f),E=E.transition(f),C=C.transition(f),z=z.transition(f).attr("opacity",y).attr("transform",function(t){return isFinite(t=w(t))?h(t+l):this.getAttribute("transform")}),S.attr("opacity",y).attr("transform",function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:w(t))+l)})),z.remove(),T.attr("d",4===t||2===t?o?"M"+u*o+","+m+"H"+l+"V"+b+"H"+u*o:"M"+l+","+m+"V"+b:o?"M"+m+","+u*o+"V"+l+"H"+b+"V"+u*o:"M"+m+","+l+"H"+b),A.attr("opacity",1).attr("transform",function(t){return h(w(t)+l)}),E.attr(c+"2",u*a),C.attr(c,u*_).text(p),N.filter(k).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),N.each(function(){this.__axis=w})}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?(r=null==t?null:Array.from(t),f):r&&r.slice()},f.tickFormat=function(t){return arguments.length?(i=t,f):i},f.tickSize=function(t){return arguments.length?(a=o=+t,f):a},f.tickSizeInner=function(t){return arguments.length?(a=+t,f):a},f.tickSizeOuter=function(t){return arguments.length?(o=+t,f):o},f.tickPadding=function(t){return arguments.length?(s=+t,f):s},f.offset=function(t){return arguments.length?(l=+t,f):l},f}var T={value:()=>{}};function A(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new z(r)}function z(t){this._=t}function S(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function E(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=T,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}z.prototype=A.prototype={constructor:z,on:function(t,e){var n,r,i=this._,a=(r=i,(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&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),o=-1,s=a.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o<s;)if(n=(t=a[o]).type)i[n]=E(i[n],t.name,e);else if(null==e)for(n in i)i[n]=E(i[n],t.name,null);return this}for(;++o<s;)if((n=(t=a[o]).type)&&(n=S(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new z(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};var C="http://www.w3.org/1999/xhtml",$={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 D(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),$.hasOwnProperty(e)?{space:$[e],local:t}:t}function L(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 U(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function P(t){var e=D(t);return(e.local?U:L)(e)}function H(){}function O(t){return null==t?H:function(){return this.querySelector(t)}}function j(){return[]}function F(t){return null==t?j:function(){return this.querySelectorAll(t)}}function Y(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function R(t){return function(){return this.matches(t)}}function I(t){return function(e){return e.matches(t)}}var q=Array.prototype.find;function B(){return this.firstElementChild}var V=Array.prototype.filter;function X(){return Array.from(this.children)}function W(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 G(t,e,n,r,i,a){for(var o,s=0,l=e.length,u=a.length;s<u;++s)(o=e[s])?(o.__data__=a[s],r[s]=o):n[s]=new Z(t,a[s]);for(;s<l;++s)(o=e[s])&&(i[s]=o)}function K(t,e,n,r,i,a,o){var s,l,u,c=new Map,h=e.length,f=a.length,d=new Array(h);for(s=0;s<h;++s)(l=e[s])&&(d[s]=u=o.call(l,l.__data__,s,e)+"",c.has(u)?i[s]=l:c.set(u,l));for(s=0;s<f;++s)u=o.call(t,a[s],s,a)+"",(l=c.get(u))?(r[s]=l,l.__data__=a[s],c.delete(u)):n[s]=new Z(t,a[s]);for(s=0;s<h;++s)(l=e[s])&&c.get(d[s])===l&&(i[s]=l)}function Q(t){return t.__data__}function J(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function tt(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function et(t){return function(){this.removeAttribute(t)}}function nt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function rt(t,e){return function(){this.setAttribute(t,e)}}function it(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function at(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function ot(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 st(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function lt(t){return function(){this.style.removeProperty(t)}}function ut(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ct(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ht(t,e){return t.style.getPropertyValue(e)||st(t).getComputedStyle(t,null).getPropertyValue(e)}function ft(t){return function(){delete this[t]}}function dt(t,e){return function(){this[t]=e}}function pt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function _t(t){return t.trim().split(/^|\s+/)}function gt(t){return t.classList||new mt(t)}function mt(t){this._node=t,this._names=_t(t.getAttribute("class")||"")}function vt(t,e){for(var n=gt(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function yt(t,e){for(var n=gt(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function bt(t){return function(){vt(this,t)}}function wt(t){return function(){yt(this,t)}}function xt(t,e){return function(){(e.apply(this,arguments)?vt:yt)(this,t)}}function Mt(){this.textContent=""}function kt(t){return function(){this.textContent=t}}function Nt(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Tt(){this.innerHTML=""}function At(t){return function(){this.innerHTML=t}}function zt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function St(){this.nextSibling&&this.parentNode.appendChild(this)}function Et(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ct(){return null}function $t(){var t=this.parentNode;t&&t.removeChild(this)}function Dt(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Lt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ut(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,a=e.length;r<a;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function Pt(t,e,n){return function(){var r,i=this.__on,a=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var o=0,s=i.length;o<s;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),void(r.value=e);this.addEventListener(t.type,a,n),r={type:t.type,name:t.name,value:e,listener:a,options:n},i?i.push(r):this.__on=[r]}}function Ht(t,e,n){var r=st(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Ot(t,e){return function(){return Ht(this,t,e)}}function jt(t,e){return function(){return Ht(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)}},mt.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 Yt(t,e){this._groups=t,this._parents=e}function Rt(){return new Yt([[document.documentElement]],Ft)}function It(t){return"string"==typeof t?new Yt([[document.querySelector(t)]],[document.documentElement]):new Yt([[t]],Ft)}function qt(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 r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}Yt.prototype=Rt.prototype={constructor:Yt,select:function(t){"function"!=typeof t&&(t=O(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o,s=e[i],l=s.length,u=r[i]=new Array(l),c=0;c<l;++c)(a=s[c])&&(o=t.call(a,a.__data__,c,s))&&("__data__"in a&&(o.__data__=a.__data__),u[c]=o);return new Yt(r,this._parents)},selectAll:function(t){t="function"==typeof t?Y(t):F(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o,s=e[a],l=s.length,u=0;u<l;++u)(o=s[u])&&(r.push(t.call(o,o.__data__,u,s)),i.push(o));return new Yt(r,i)},selectChild:function(t){return this.select(null==t?B:function(t){return function(){return q.call(this.children,t)}}("function"==typeof t?t:I(t)))},selectChildren:function(t){return this.selectAll(null==t?X:function(t){return function(){return V.call(this.children,t)}}("function"==typeof t?t:I(t)))},filter:function(t){"function"!=typeof t&&(t=R(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,l=r[i]=[],u=0;u<s;++u)(a=o[u])&&t.call(a,a.__data__,u,o)&&l.push(a);return new Yt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,Q);var n=e?K:G,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var a=i.length,o=new Array(a),s=new Array(a),l=new Array(a),u=0;u<a;++u){var c=r[u],h=i[u],f=h.length,d=J(t.call(c,c&&c.__data__,u,r)),p=d.length,_=s[u]=new Array(p),g=o[u]=new Array(p);n(c,h,_,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 Yt(o,r))._enter=s,o._exit=l,o},enter:function(){return new Yt(this._enter||this._groups.map(W),this._parents)},exit:function(){return new Yt(this._exit||this._groups.map(W),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,a=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?a.remove():n(a),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,a=r.length,o=Math.min(i,a),s=new Array(i),l=0;l<o;++l)for(var u,c=n[l],h=r[l],f=c.length,d=s[l]=new Array(f),p=0;p<f;++p)(u=c[p]||h[p])&&(d[p]=u);for(;l<i;++l)s[l]=n[l];return new Yt(s,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],a=i.length-1,o=i[a];--a>=0;)(r=i[a])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=tt);for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o,s=n[a],l=s.length,u=i[a]=new Array(l),c=0;c<l;++c)(o=s[c])&&(u[c]=o);u.sort(e)}return new Yt(i,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 r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];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,r=e.length;n<r;++n)for(var i,a=e[n],o=0,s=a.length;o<s;++o)(i=a[o])&&t.call(i,i.__data__,o,a);return this},attr:function(t,e){var n=D(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?nt:et:"function"==typeof e?n.local?ot:at:n.local?it:rt)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?lt:"function"==typeof e?ct:ut)(t,e,null==n?"":n)):ht(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?ft:"function"==typeof e?pt:dt)(t,e)):this.node()[t]},classed:function(t,e){var n=_t(t+"");if(arguments.length<2){for(var r=gt(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?xt:e?bt:wt)(n,e))},text:function(t){return arguments.length?this.each(null==t?Mt:("function"==typeof t?Nt:kt)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Tt:("function"==typeof t?zt:At)(t)):this.node().innerHTML},raise:function(){return this.each(St)},lower:function(){return this.each(Et)},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),r=null==e?Ct:"function"==typeof e?e:O(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each($t)},clone:function(t){return this.select(t?Lt:Dt)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,a=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=a.length;if(!(arguments.length<2)){for(s=e?Pt:Ut,r=0;r<o;++r)this.each(s(a[r],e,n));return this}var s=this.node().__on;if(s)for(var l,u=0,c=s.length;u<c;++u)for(r=0,l=s[u];r<o;++r)if((i=a[r]).type===l.type&&i.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?jt:Ot)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],a=0,o=i.length;a<o;++a)(r=i[a])&&(yield r)}};const Bt={capture:!0,passive:!1};function Vt(t){t.preventDefault(),t.stopImmediatePropagation()}function Xt(t){var e=t.document.documentElement,n=It(t).on("dragstart.drag",Vt,Bt);"onselectstart"in e?n.on("selectstart.drag",Vt,Bt):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Wt(t,e){var n=t.document.documentElement,r=It(t).on("dragstart.drag",null);e&&(r.on("click.drag",Vt,Bt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.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 Gt(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Kt(){}var Qt=.7,Jt=1/Qt,te="\\s*([+-]?\\d+)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",re=/^#([0-9a-f]{3,8})$/,ie=new RegExp(`^rgb\\(${te},${te},${te}\\)$`),ae=new RegExp(`^rgb\\(${ne},${ne},${ne}\\)$`),oe=new RegExp(`^rgba\\(${te},${te},${te},${ee}\\)$`),se=new RegExp(`^rgba\\(${ne},${ne},${ne},${ee}\\)$`),le=new RegExp(`^hsl\\(${ee},${ne},${ne}\\)$`),ue=new RegExp(`^hsla\\(${ee},${ne},${ne},${ee}\\)$`),ce={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 fe(){return this.rgb().formatRgb()}function de(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=re.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?pe(e):3===n?new me(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?_e(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?_e(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 me(e[1],e[2],e[3],1):(e=ae.exec(t))?new me(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=oe.exec(t))?_e(e[1],e[2],e[3],e[4]):(e=se.exec(t))?_e(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=le.exec(t))?Me(e[1],e[2]/100,e[3]/100,1):(e=ue.exec(t))?Me(e[1],e[2]/100,e[3]/100,e[4]):ce.hasOwnProperty(t)?pe(ce[t]):"transparent"===t?new me(NaN,NaN,NaN,0):null}function pe(t){return new me(t>>16&255,t>>8&255,255&t,1)}function _e(t,e,n,r){return r<=0&&(t=e=n=NaN),new me(t,e,n,r)}function ge(t,e,n,r){return 1===arguments.length?((i=t)instanceof Kt||(i=de(i)),i?new me((i=i.rgb()).r,i.g,i.b,i.opacity):new me):new me(t,e,n,null==r?1:r);var i}function me(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ve(){return`#${xe(this.r)}${xe(this.g)}${xe(this.b)}`}function ye(){const t=be(this.opacity);return`${1===t?"rgb(":"rgba("}${we(this.r)}, ${we(this.g)}, ${we(this.b)}${1===t?")":`, ${t})`}`}function be(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function we(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function xe(t){return((t=we(t))<16?"0":"")+t.toString(16)}function Me(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Ne(t,e,n,r)}function ke(t){if(t instanceof Ne)return new Ne(t.h,t.s,t.l,t.opacity);if(t instanceof Kt||(t=de(t)),!t)return new Ne;if(t instanceof Ne)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,s=a-i,l=(a+i)/2;return s?(o=e===a?(n-r)/s+6*(n<r):n===a?(r-e)/s+2:(e-n)/s+4,s/=l<.5?a+i:2-a-i,o*=60):s=l>0&&l<1?0:o,new Ne(o,s,l,t.opacity)}function Ne(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Te(t){return(t=(t||0)%360)<0?t+360:t}function Ae(t){return Math.max(0,Math.min(1,t||0))}function ze(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(Kt,de,{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 ke(this).formatHsl()},formatRgb:fe,toString:fe}),Zt(me,ge,Gt(Kt,{brighter(t){return t=null==t?Jt:Math.pow(Jt,t),new me(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Qt:Math.pow(Qt,t),new me(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new me(we(this.r),we(this.g),we(this.b),be(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:ve,formatHex:ve,formatHex8:function(){return`#${xe(this.r)}${xe(this.g)}${xe(this.b)}${xe(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:ye,toString:ye})),Zt(Ne,function(t,e,n,r){return 1===arguments.length?ke(t):new Ne(t,e,n,null==r?1:r)},Gt(Kt,{brighter(t){return t=null==t?Jt:Math.pow(Jt,t),new Ne(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Qt:Math.pow(Qt,t),new Ne(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,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new me(ze(t>=240?t-240:t+120,i,r),ze(t,i,r),ze(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Ne(Te(this.h),Ae(this.s),Ae(this.l),be(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=be(this.opacity);return`${1===t?"hsl(":"hsla("}${Te(this.h)}, ${100*Ae(this.s)}%, ${100*Ae(this.l)}%${1===t?")":`, ${t})`}`}}));var Se=t=>()=>t;function Ee(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(r){return Math.pow(t+r*e,n)}}(e,n,t):Se(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):Se(isNaN(t)?e:t)}var $e=function t(e){var n=Ee(e);function r(t,e){var r=n((t=ge(t)).r,(e=ge(e)).r),i=n(t.g,e.g),a=n(t.b,e.b),o=Ce(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);function De(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(a){for(n=0;n<r;++n)i[n]=t[n]*(1-a)+e[n]*a;return i}}function Le(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,a=new Array(i),o=new Array(r);for(n=0;n<i;++n)a[n]=Ye(t[n],e[n]);for(;n<r;++n)o[n]=e[n];return function(t){for(n=0;n<i;++n)o[n]=a[n](t);return o}}function Ue(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Pe(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function He(t,e){var n,r={},i={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?r[n]=Ye(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var Oe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,je=new RegExp(Oe.source,"g");function Fe(t,e){var n,r,i,a=Oe.lastIndex=je.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(n=Oe.exec(t))&&(r=je.exec(e));)(i=r.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,l.push({i:o,x:Pe(n,r)})),a=je.lastIndex;return a<e.length&&(i=e.slice(a),s[o]?s[o]+=i:s[++o]=i),s.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,r=0;r<e;++r)s[(n=l[r]).i]=n.x(t);return s.join("")})}function Ye(t,e){var n,r=typeof e;return null==e||"boolean"===r?Se(e):("number"===r?Pe:"string"===r?(n=de(e))?(e=n,$e):Fe:e instanceof de?$e:e instanceof Date?Ue:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?De:Array.isArray(e)?Le:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?He:Pe)(t,e)}function Re(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var Ie,qe=180/Math.PI,Be={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ve(t,e,n,r,i,a){var o,s,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,l/=s),t*r<e*n&&(t=-t,e=-e,l=-l,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(e,t)*qe,skewX:Math.atan(l)*qe,scaleX:o,scaleY:s}}function Xe(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(a,o){var s=[],l=[];return a=t(a),o=t(o),function(t,r,i,a,o,s){if(t!==i||r!==a){var l=o.push("translate(",null,e,null,n);s.push({i:l-4,x:Pe(t,i)},{i:l-2,x:Pe(r,a)})}else(i||a)&&o.push("translate("+i+e+a+n)}(a.translateX,a.translateY,o.translateX,o.translateY,s,l),function(t,e,n,a){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Pe(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(a.rotate,o.rotate,s,l),function(t,e,n,a){t!==e?a.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Pe(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(a.skewX,o.skewX,s,l),function(t,e,n,r,a,o){if(t!==n||e!==r){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:Pe(t,n)},{i:s-2,x:Pe(e,r)})}else 1===n&&1===r||a.push(i(a)+"scale("+n+","+r+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,l),a=o=null,function(t){for(var e,n=-1,r=l.length;++n<r;)s[(e=l[n]).i]=e.x(t);return s.join("")}}}var We=Xe(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Be:Ve(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),Ze=Xe(function(t){return null==t?Be:(Ie||(Ie=document.createElementNS("http://www.w3.org/2000/svg","g")),Ie.setAttribute("transform",t),(t=Ie.transform.baseVal.consolidate())?Ve((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Be)},", ",")",")");function Ge(t){return((t=Math.exp(t))+1/t)/2}var Ke,Qe,Je=function t(e,n,r){function i(t,i){var a,o,s=t[0],l=t[1],u=t[2],c=i[0],h=i[1],f=i[2],d=c-s,p=h-l,_=d*d+p*p;if(_<1e-12)o=Math.log(f/u)/e,a=function(t){return[s+t*d,l+t*p,u*Math.exp(e*t*o)]};else{var g=Math.sqrt(_),m=(f*f-u*u+r*_)/(2*u*n*g),v=(f*f-u*u-r*_)/(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,a=function(t){var r=t*o,i=Ge(y),a=u/(n*g)*(i*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*r+y)-function(t){return((t=Math.exp(t))-1/t)/2}(y));return[s+a*d,l+a*p,u*i/Ge(e*r+y)]}}return a.duration=1e3*o*e/Math.SQRT2,a}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r)},i}(Math.SQRT2,2,4),tn=0,en=0,nn=0,rn=0,an=0,on=0,sn="object"==typeof performance&&performance.now?performance:Date,ln="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function un(){return an||(ln(cn),an=sn.now()+on)}function cn(){an=0}function hn(){this._call=this._time=this._next=null}function fn(t,e,n){var r=new hn;return r.restart(t,e,n),r}function dn(){an=(rn=sn.now())+on,tn=en=0;try{!function(){un(),++tn;for(var t,e=Ke;e;)(t=an-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tn}()}finally{tn=0,function(){var t,e,n=Ke,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Ke=e);Qe=t,_n(r)}(),an=0}}function pn(){var t=sn.now(),e=t-rn;e>1e3&&(on-=e,rn=t)}function _n(t){tn||(en&&(en=clearTimeout(en)),t-an>24?(t<1/0&&(en=setTimeout(dn,t-sn.now()-on)),nn&&(nn=clearInterval(nn))):(nn||(rn=sn.now(),nn=setInterval(pn,1e3)),tn=1,ln(dn)))}function gn(t,e,n){var r=new hn;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}hn.prototype=fn.prototype={constructor:hn,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?un():+n)+(null==e?0:+e),this._next||Qe===this||(Qe?Qe._next=this:Ke=this,Qe=this),this._call=t,this._time=n,_n()},stop:function(){this._call&&(this._call=null,this._time=1/0,_n())}};var mn=A("start","end","cancel","interrupt"),vn=[];function yn(t,e,n,r,i,a){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function a(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(a){var u,c,h,f;if(1!==n.state)return l();for(u in i)if((f=i[u]).name===n.name){if(3===f.state)return gn(o);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[u]):+u<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[u])}if(gn(function(){3===n.state&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(h=n.tween.length),u=0,c=-1;u<h;++u)(f=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=f);r.length=c+1}}function s(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(l),n.state=5,1),a=-1,o=r.length;++a<o;)r[a].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=fn(a,0,n.time)}(t,n,{name:e,index:r,group:i,on:mn,tween:vn,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function bn(t,e){var n=xn(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function wn(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 Mn(t,e){var n,r,i,a=t.__transition,o=!0;if(a){for(i in e=null==e?null:e+"",a)(n=a[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete a[i]):o=!1;o&&delete t.__transition}}function kn(t,e){var n,r;return function(){var i=wn(this,t),a=i.tween;if(a!==n)for(var o=0,s=(r=n=a).length;o<s;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r}}function Nn(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var a=wn(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:e,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===e){i[l]=s;break}l===u&&i.push(s)}a.tween=i}}function Tn(t,e,n){var r=t._id;return t.each(function(){var t=wn(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return xn(t,r).value[e]}}function An(t,e){var n;return("number"==typeof e?Pe:e instanceof de?$e:(n=de(e))?(e=n,$e):Fe)(t,e)}function zn(t){return function(){this.removeAttribute(t)}}function Sn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function En(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=e(r=o,n)}}function Cn(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=e(r=o,n)}}function $n(t,e,n){var r,i,a;return function(){var o,s,l=n(this);if(null!=l)return(o=this.getAttribute(t))===(s=l+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,l));this.removeAttribute(t)}}function Dn(t,e,n){var r,i,a;return function(){var o,s,l=n(this);if(null!=l)return(o=this.getAttributeNS(t.space,t.local))===(s=l+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,l));this.removeAttributeNS(t.space,t.local)}}function Ln(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Un(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Pn(t,e){return function(){bn(this,t).delay=+e.apply(this,arguments)}}function Hn(t,e){return e=+e,function(){bn(this,t).delay=e}}function On(t,e){return function(){wn(this,t).duration=+e.apply(this,arguments)}}function jn(t,e){return e=+e,function(){wn(this,t).duration=e}}var Fn=Rt.prototype.constructor;function Yn(t){return function(){this.style.removeProperty(t)}}var Rn=0;function In(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function qn(){return++Rn}var Bn=Rt.prototype;In.prototype={constructor:In,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=O(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s,l,u=r[o],c=u.length,h=a[o]=new Array(c),f=0;f<c;++f)(s=u[f])&&(l=t.call(s,s.__data__,f,u))&&("__data__"in s&&(l.__data__=s.__data__),h[f]=l,yn(h[f],e,n,f,h,xn(s,n)));return new In(a,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=F(t));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var l,u=r[s],c=u.length,h=0;h<c;++h)if(l=u[h]){for(var f,d=t.call(l,l.__data__,h,u),p=xn(l,n),_=0,g=d.length;_<g;++_)(f=d[_])&&yn(f,e,n,_,d,p);a.push(d),o.push(l)}return new In(a,o,e,n)},selectChild:Bn.selectChild,selectChildren:Bn.selectChildren,filter:function(t){"function"!=typeof t&&(t=R(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,l=r[i]=[],u=0;u<s;++u)(a=o[u])&&t.call(a,a.__data__,u,o)&&l.push(a);return new In(r,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,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var l,u=e[s],c=n[s],h=u.length,f=o[s]=new Array(h),d=0;d<h;++d)(l=u[d]||c[d])&&(f[d]=l);for(;s<r;++s)o[s]=e[s];return new In(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=qn(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],l=s.length,u=0;u<l;++u)if(o=s[u]){var c=xn(o,e);yn(o,t,n,u,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new In(r,this._parents,t,n)},call:Bn.call,nodes:Bn.nodes,node:Bn.node,size:Bn.size,empty:Bn.empty,each:Bn.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 r,i,a=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)?bn:wn;return function(){var o=a(this,t),s=o.on;s!==r&&(i=(r=s).copy()).on(e,n),o.on=i}}(n,t,e))},attr:function(t,e){var n=D(t),r="transform"===n?Ze:An;return this.attrTween(t,"function"==typeof e?(n.local?Dn:$n)(n,r,Tn(this,"attr."+t,e)):null==e?(n.local?Sn:zn)(n):(n.local?Cn:En)(n,r,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 r=D(t);return this.tween(n,(r.local?Ln:Un)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?We:An;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var a=ht(this,t),o=(this.style.removeProperty(t),ht(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}(t,r)).on("end.style."+t,Yn(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,a;return function(){var o=ht(this,t),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(t),l=s=ht(this,t)),o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s))}}(t,r,Tn(this,"style."+t,e))).each(function(t,e){var n,r,i,a,o="style."+e,s="end."+o;return function(){var l=wn(this,t),u=l.on,c=null==l.value[o]?a||(a=Yn(e)):void 0;u===n&&i===c||(r=(n=u).copy()).on(s,i=c),l.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,a=n+"";return function(){var o=ht(this,t);return o===a?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function a(){var a=e.apply(this,arguments);return a!==i&&(r=(i=a)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,a,n)),r}return a._value=e,a}(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}}(Tn(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 r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(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 r,i=xn(this.node(),n).tween,a=0,o=i.length;a<o;++a)if((r=i[a]).name===t)return r.value;return null}return this.each((null==e?kn:Nn)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Pn:Hn)(e,t)):xn(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?On:jn)(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(){wn(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;wn(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},l={value:function(){0===--i&&a()}};n.each(function(){var n=wn(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(s),e._.interrupt.push(s),e._.end.push(l)),n.on=e}),0===i&&a()})},[Symbol.iterator]:Bn[Symbol.iterator]};var Vn={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Xn(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}Rt.prototype.interrupt=function(t){return this.each(function(){Mn(this,t)})},Rt.prototype.transition=function(t){var e,n;t instanceof In?(e=t._id,t=t._name):(e=qn(),(n=Vn).time=un(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],l=s.length,u=0;u<l;++u)(o=s[u])&&yn(o,t,e,u,s,n||Xn(o,e));return new In(r,this._parents,t,e)};var Wn=t=>()=>t;function Zn(t,{sourceEvent:e,target:n,selection:r,mode:i,dispatch:a}){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:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function Gn(t){t.preventDefault(),t.stopImmediatePropagation()}var Kn={name:"drag"},Qn={name:"space"},Jn={name:"handle"},tr={name:"center"};const{abs:er,max:nr,min:rr}=Math;function ir(t){return[+t[0],+t[1]]}function ar(t){return[ir(t[0]),ir(t[1])]}var or={name:"x",handles:["w","e"].map(pr),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]]}},sr={name:"y",handles:["n","s"].map(pr),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]]}},lr={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(pr),input:function(t){return null==t?null:ar(t)},output:function(t){return t}},ur={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"},cr={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},hr={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},fr={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},dr={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function pr(t){return{type:t}}function _r(t){return!t.ctrlKey&&!t.button}function gr(){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 mr(){return navigator.maxTouchPoints||"ontouchstart"in this}function vr(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function yr(){return function(t){var e,n=gr,r=_r,i=mr,a=!0,o=A("start","brush","end"),s=6;function l(e){var n=e.property("__brush",_).selectAll(".overlay").data([pr("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",ur.overlay).merge(n).each(function(){var t=vr(this).extent;It(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([pr("selection")]).enter().append("rect").attr("class","selection").attr("cursor",ur.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=e.selectAll(".handle").data(t.handles,function(t){return t.type});r.exit().remove(),r.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return ur[t.type]}),e.each(u).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",f).filter(i).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=It(this),e=vr(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]-s/2:e[0][0]-s/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-s/2:e[0][1]-s/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+s:s}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+s:s})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function c(t,e,n){var r=t.__brush.emitter;return!r||n&&r.clean?new h(t,e,n):r}function h(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)&&r.apply(this,arguments)){var i,o,s,l,h,f,d,p,_,g,m,v=this,y=n.target.__data__.type,b="selection"===(a&&n.metaKey?y="overlay":y)?Kn:a&&n.altKey?tr:Jn,w=t===sr?null:fr[y],x=t===or?null:dr[y],M=vr(v),k=M.extent,N=M.selection,T=k[0][0],A=k[0][1],z=k[1][0],S=k[1][1],E=0,C=0,$=w&&x&&a&&n.shiftKey,D=Array.from(n.touches||[n],t=>{const e=t.identifier;return(t=qt(t,v)).point0=t.slice(),t.identifier=e,t});Mn(v);var L=c(v,arguments,!0).beforestart();if("overlay"===y){N&&(_=!0);const e=[D[0],D[1]||D[0]];M.selection=N=[[i=t===sr?T:rr(e[0][0],e[1][0]),s=t===or?A:rr(e[0][1],e[1][1])],[h=t===sr?z:nr(e[0][0],e[1][0]),d=t===or?S:nr(e[0][1],e[1][1])]],D.length>1&&j(n)}else i=N[0][0],s=N[0][1],h=N[1][0],d=N[1][1];o=i,l=s,f=h,p=d;var U=It(v).attr("pointer-events","none"),P=U.selectAll(".overlay").attr("cursor",ur[y]);if(n.touches)L.moved=O,L.ended=F;else{var H=It(n.view).on("mousemove.brush",O,!0).on("mouseup.brush",F,!0);a&&H.on("keydown.brush",Y,!0).on("keyup.brush",R,!0),Xt(n.view)}u.call(v),L.start(n,b.name)}function O(t){for(const e of t.changedTouches||[t])for(const t of D)t.identifier===e.identifier&&(t.cur=qt(e,v));if($&&!g&&!m&&1===D.length){const t=D[0];er(t.cur[0]-t[0])>er(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,Gn(t),j(t)}function j(t){const e=D[0],n=e.point0;var r;switch(E=e[0]-n[0],C=e[1]-n[1],b){case Qn:case Kn:w&&(E=nr(T-i,rr(z-h,E)),o=i+E,f=h+E),x&&(C=nr(A-s,rr(S-d,C)),l=s+C,p=d+C);break;case Jn:D[1]?(w&&(o=nr(T,rr(z,D[0][0])),f=nr(T,rr(z,D[1][0])),w=1),x&&(l=nr(A,rr(S,D[0][1])),p=nr(A,rr(S,D[1][1])),x=1)):(w<0?(E=nr(T-i,rr(z-i,E)),o=i+E,f=h):w>0&&(E=nr(T-h,rr(z-h,E)),o=i,f=h+E),x<0?(C=nr(A-s,rr(S-s,C)),l=s+C,p=d):x>0&&(C=nr(A-d,rr(S-d,C)),l=s,p=d+C));break;case tr:w&&(o=nr(T,rr(z,i-E*w)),f=nr(T,rr(z,h+E*w))),x&&(l=nr(A,rr(S,s-C*x)),p=nr(A,rr(S,d+C*x)))}f<o&&(w*=-1,r=i,i=h,h=r,r=o,o=f,f=r,y in cr&&P.attr("cursor",ur[y=cr[y]])),p<l&&(x*=-1,r=s,s=d,d=r,r=l,l=p,p=r,y in hr&&P.attr("cursor",ur[y=hr[y]])),M.selection&&(N=M.selection),g&&(o=N[0][0],f=N[1][0]),m&&(l=N[0][1],p=N[1][1]),N[0][0]===o&&N[0][1]===l&&N[1][0]===f&&N[1][1]===p||(M.selection=[[o,l],[f,p]],u.call(v),L.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 Wt(t.view,_),H.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);U.attr("pointer-events","all"),P.attr("cursor",ur.overlay),M.selection&&(N=M.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(N)&&(M.selection=null,u.call(v)),L.end(t,b.name)}function Y(t){switch(t.keyCode){case 16:$=w&&x;break;case 18:b===Jn&&(w&&(h=f-E*w,i=o+E*w),x&&(d=p-C*x,s=l+C*x),b=tr,j(t));break;case 32:b!==Jn&&b!==tr||(w<0?h=f-E:w>0&&(i=o-E),x<0?d=p-C:x>0&&(s=l-C),b=Qn,P.attr("cursor",ur.selection),j(t));break;default:return}Gn(t)}function R(t){switch(t.keyCode){case 16:$&&(g=m=$=!1,j(t));break;case 18:b===tr&&(w<0?h=f:w>0&&(i=o),x<0?d=p:x>0&&(s=l),b=Jn,j(t));break;case 32:b===Qn&&(t.altKey?(w&&(h=f-E*w,i=o+E*w),x&&(d=p-C*x,s=l+C*x),b=tr):(w<0?h=f:w>0&&(i=o),x<0?d=p:x>0&&(s=l),b=Jn),P.attr("cursor",ur[y]),j(t));break;default:return}Gn(t)}}function d(t){c(this,arguments).moved(t)}function p(t){c(this,arguments).ended(t)}function _(){var e=this.__brush||{selection:null};return e.extent=ar(n.apply(this,arguments)),e.dim=t,e}return l.move=function(e,n,r){e.tween?e.on("start.brush",function(t){c(this,arguments).beforestart().start(t)}).on("interrupt.brush end.brush",function(t){c(this,arguments).end(t)}).tween("brush",function(){var e=this,r=e.__brush,i=c(e,arguments),a=r.selection,o=t.input("function"==typeof n?n.apply(this,arguments):n,r.extent),s=Ye(a,o);function l(t){r.selection=1===t&&null===o?null:s(t),u.call(e),i.brush()}return null!==a&&null!==o?l:l(1)}):e.each(function(){var e=this,i=arguments,a=e.__brush,o=t.input("function"==typeof n?n.apply(e,i):n,a.extent),s=c(e,i).beforestart();Mn(e),a.selection=null===o?null:o,u.call(e),s.start(r).brush(r).end(r)})},l.clear=function(t,e){l.move(t,null,e)},h.prototype={beforestart:function(){return 1===++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(t,e){return this.starting?(this.starting=!1,this.emit("start",t,e)):this.emit("brush",t),this},brush:function(t,e){return this.emit("brush",t,e),this},end:function(t,e){return 0===--this.active&&(delete this.state.emitter,this.emit("end",t,e)),this},emit:function(e,n,r){var i=It(this.that).datum();o.call(e,this.that,new Zn(e,{sourceEvent:n,target:l,selection:t.output(this.state.selection),mode:r,dispatch:o}),i)}},l.extent=function(t){return arguments.length?(n="function"==typeof t?t:Wn(ar(t)),l):n},l.filter=function(t){return arguments.length?(r="function"==typeof t?t:Wn(!!t),l):r},l.touchable=function(t){return arguments.length?(i="function"==typeof t?t:Wn(!!t),l):i},l.handleSize=function(t){return arguments.length?(s=+t,l):s},l.keyModifiers=function(t){return arguments.length?(a=!!t,l):a},l.on=function(){var t=o.on.apply(o,arguments);return t===o?l:t},l}(lr)}const br=Math.PI,wr=2*br,xr=1e-6,Mr=wr-xr;function kr(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}class Nr{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?kr:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return kr;const n=10**e;return function(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=Math.round(arguments[e]*n)/n+t[e]}}(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,n,r){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(t,e,n,r,i,a){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(t,e,n,r,i){if(t=+t,e=+e,n=+n,r=+r,(i=+i)<0)throw new Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-t,l=r-e,u=a-t,c=o-e,h=u*u+c*c;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(h>xr)if(Math.abs(c*s-l*u)>xr&&i){let f=n-a,d=r-o,p=s*s+l*l,_=f*f+d*d,g=Math.sqrt(p),m=Math.sqrt(h),v=i*Math.tan((br-Math.acos((p+h-_)/(2*g*m)))/2),y=v/m,b=v/g;Math.abs(y-1)>xr&&this._append`L${t+y*u},${e+y*c}`,this._append`A${i},${i},0,0,${+(c*f>u*d)},${this._x1=t+b*s},${this._y1=e+b*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,a){if(t=+t,e=+e,a=!!a,(n=+n)<0)throw new Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),l=t+o,u=e+s,c=1^a,h=a?r-i:i-r;null===this._x1?this._append`M${l},${u}`:(Math.abs(this._x1-l)>xr||Math.abs(this._y1-u)>xr)&&this._append`L${l},${u}`,n&&(h<0&&(h=h%wr+wr),h>Mr?this._append`A${n},${n},0,1,${c},${t-o},${e-s}A${n},${n},0,1,${c},${this._x1=l},${this._y1=u}`:h>xr&&this._append`A${n},${n},0,${+(h>=br)},${c},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}}function Tr(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Ar(t){return(t=Tr(Math.abs(t)))?t[1]:NaN}var zr,Sr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Er(t){if(!(e=Sr.exec(t)))throw new Error("invalid format: "+t);var e;return new Cr({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function Cr(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function $r(t,e){var n=Tr(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}Er.prototype=Cr.prototype,Cr.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Dr={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>$r(100*t,e),r:$r,s:function(t,e){var n=Tr(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(zr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Tr(t,Math.max(0,e+a-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Lr(t){return t}var Ur,Pr,Hr,Or=Array.prototype.map,jr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Fr(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Lr:(e=Or.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,a=[],o=0,s=e[0],l=0;i>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?Lr:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(Or.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",u=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=Er(t)).fill,n=t.align,h=t.sign,f=t.symbol,d=t.zero,p=t.width,_=t.comma,g=t.precision,m=t.trim,v=t.type;"n"===v?(_=!0,v="g"):Dr[v]||(void 0===g&&(g=12),m=!0,v="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var y="$"===f?i:"#"===f&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",b="$"===f?a:/[%p]/.test(v)?l:"",w=Dr[v],x=/[defgprs%]/.test(v);function M(t){var i,a,l,f=y,M=b;if("c"===v)M=w(t)+M,t="";else{var k=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:w(Math.abs(t),g),m&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),k&&0===+t&&"+"!==h&&(k=!1),f=(k?"("===h?h:u:"-"===h||"("===h?"":h)+f,M=("s"===v?jr[8+zr/3]:"")+M+(k&&"("===h?")":""),x)for(i=-1,a=t.length;++i<a;)if(48>(l=t.charCodeAt(i))||l>57){M=(46===l?o+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}_&&!d&&(t=r(t,1/0));var N=f.length+t.length+M.length,T=N<p?new Array(p-N+1).join(e):"";switch(_&&d&&(t=r(T+t,T.length?p-M.length:1/0),T=""),n){case"<":t=f+t+M+T;break;case"=":t=f+T+t+M;break;case"^":t=T.slice(0,N=T.length>>1)+f+t+M+T.slice(N);break;default:t=T+f+t+M}return s(t)}return g=void 0===g?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),M.toString=function(){return t+""},M}return{format:h,formatPrefix:function(t,e){var n=h(((t=Er(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Ar(e)/3))),i=Math.pow(10,-r),a=jr[8+r/3];return function(t){return n(i*t)+a}}}}function Yr(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function Rr(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=qr)):void 0===e&&(e=Ir);for(var n,r,i,a,o,s=new Xr(t),l=[s];n=l.pop();)if((i=e(n.data))&&(o=(i=Array.from(i)).length))for(n.children=i,a=o-1;a>=0;--a)l.push(r=i[a]=new Xr(i[a])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(Vr)}function Ir(t){return t.children}function qr(t){return Array.isArray(t)?t[1]:null}function Br(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Vr(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Xr(t){this.data=t,this.depth=this.height=0,this.parent=null}function Wr(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Zr(t){return+t}Ur=Fr({thousands:",",grouping:[3],currency:["$",""]}),Pr=Ur.format,Hr=Ur.formatPrefix,Xr.prototype=Rr.prototype={constructor:Xr,count:function(){return this.eachAfter(Yr)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,a=this,o=[a],s=[],l=-1;a=o.pop();)if(s.push(a),n=a.children)for(r=0,i=n.length;r<i;++r)o.push(n[r]);for(;a=s.pop();)t.call(e,a,++l,this);return this},eachBefore:function(t,e){for(var n,r,i=this,a=[i],o=-1;i=a.pop();)if(t.call(e,i,++o,this),n=i.children)for(r=n.length-1;r>=0;--r)a.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n})},sort:function(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t},links:function(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e},copy:function(){return Rr(this).eachBefore(Br)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,a=[i];do{for(t=a.reverse(),a=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)a.push(e[n])}while(a.length)}};var Gr=[0,1];function Kr(t){return t}function Qr(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function Jr(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=Qr(i,r),a=n(o,a)):(r=Qr(r,i),a=n(a,o)),function(t){return a(r(t))}}function ti(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=Qr(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(e){var n=f(t,e,1,r)-1;return a[n](i[n](e))}}function ei(){var t,e,n,r,i,a,o=Gr,s=Gr,l=Ye,u=Kr;function c(){var t,e,n,l=Math.min(o.length,s.length);return u!==Kr&&(t=o[0],e=o[l-1],t>e&&(n=t,t=e,e=n),u=function(n){return Math.max(t,Math.min(e,n))}),r=l>2?ti:Jr,i=a=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(o.map(t),s,l)))(t(u(e)))}return h.invert=function(n){return u(e((a||(a=r(s,o.map(t),Pe)))(n)))},h.domain=function(t){return arguments.length?(o=Array.from(t,Zr),c()):o.slice()},h.range=function(t){return arguments.length?(s=Array.from(t),c()):s.slice()},h.rangeRound=function(t){return s=Array.from(t),l=Re,c()},h.clamp=function(t){return arguments.length?(u=!!t||Kr,c()):u!==Kr},h.interpolate=function(t){return arguments.length?(l=t,c()):l},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,c()}}function ni(t,e,n,r){var i,a=function(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?m(e,t,n):m(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}(t,e,n);switch((r=Er(null==r?",f":r)).type){case"s":var o=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Ar(e)/3)))-Ar(Math.abs(t)))}(a,o))||(r.precision=i),Hr(r,o);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Ar(e)-Ar(t))+1}(a,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-Ar(Math.abs(t)))}(a))||(r.precision=i-2*("%"===r.type))}return Pr(r)}function ri(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)===(e=+e))return[t];const r=e<t,[i,a,o]=r?g(e,t,n):g(t,e,n);if(!(a>=i))return[];const s=a-i+1,l=new Array(s);if(r)if(o<0)for(let t=0;t<s;++t)l[t]=(a-t)/-o;else for(let t=0;t<s;++t)l[t]=(a-t)*o;else if(o<0)for(let t=0;t<s;++t)l[t]=(i+t)/-o;else for(let t=0;t<s;++t)l[t]=(i+t)*o;return l}(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return ni(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,a=e(),o=0,s=a.length-1,l=a[o],u=a[s],c=10;for(u<l&&(i=l,l=u,u=i,i=o,o=s,s=i);c-- >0;){if((i=m(l,u,n))===r)return a[o]=l,a[s]=u,e(a);if(i>0)l=Math.floor(l/i)*i,u=Math.ceil(u/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,u=Math.floor(u*i)/i}r=i}return t},t}function ii(){var t=ei()(Kr,Kr);return t.copy=function(){return e=t,ii().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},Wr.apply(t,arguments),ri(t)}const ai=new Date,oi=new Date;function si(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=e=>(t(e=new Date(+e)),e),i.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),i.round=t=>{const e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=(t,n)=>(e(t=new Date(+t),null==n?1:Math.floor(n)),t),i.range=(n,r,a)=>{const o=[];if(n=i.ceil(n),a=null==a?1:Math.floor(a),!(n<r&&a>0))return o;let s;do{o.push(s=new Date(+n)),e(n,a),t(n)}while(s<n&&n<r);return o},i.filter=n=>si(e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)},(t,r)=>{if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}),n&&(i.count=(e,r)=>(ai.setTime(+e),oi.setTime(+r),t(ai),t(oi),Math.floor(n(ai,oi))),i.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?e=>r(e)%t===0:e=>i.count(0,e)%t===0):i:null)),i}const li=6e4,ui=864e5,ci=6048e5,hi=si(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*li)/ui,t=>t.getDate()-1);hi.range;const fi=si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ui,t=>t.getUTCDate()-1);fi.range;const di=si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ui,t=>Math.floor(t/ui));function pi(t){return si(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+7*e)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*li)/ci)}di.range;const _i=pi(0),gi=pi(1),mi=pi(2),vi=pi(3),yi=pi(4),bi=pi(5),wi=pi(6);function xi(t){return si(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)},(t,e)=>(e-t)/ci)}_i.range,gi.range,mi.range,vi.range,yi.range,bi.range,wi.range;const Mi=xi(0),ki=xi(1),Ni=xi(2),Ti=xi(3),Ai=xi(4),zi=xi(5),Si=xi(6);Mi.range,ki.range,Ni.range,Ti.range,Ai.range,zi.range,Si.range;const Ei=si(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Ei.every=t=>isFinite(t=Math.floor(t))&&t>0?si(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)}):null,Ei.range;const Ci=si(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());function $i(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Di(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Li(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}Ci.every=t=>isFinite(t=Math.floor(t))&&t>0?si(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)}):null,Ci.range;var Ui,Pi,Hi={"-":"",_:" ",0:"0"},Oi=/^\s*\d+/,ji=/^%/,Fi=/[\\^$*+?|[\]().{}]/g;function Yi(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function Ri(t){return t.replace(Fi,"\\$&")}function Ii(t){return new RegExp("^(?:"+t.map(Ri).join("|")+")","i")}function qi(t){return new Map(t.map((t,e)=>[t.toLowerCase(),e]))}function Bi(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Vi(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Xi(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Wi(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Zi(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Gi(t,e,n){var r=Oi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Ki(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Qi(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Ji(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function ta(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ea(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function na(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function ra(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function ia(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function aa(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function oa(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function sa(t,e,n){var r=Oi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function la(t,e,n){var r=ji.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ua(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function ca(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function ha(t,e){return Yi(t.getDate(),e,2)}function fa(t,e){return Yi(t.getHours(),e,2)}function da(t,e){return Yi(t.getHours()%12||12,e,2)}function pa(t,e){return Yi(1+hi.count(Ei(t),t),e,3)}function _a(t,e){return Yi(t.getMilliseconds(),e,3)}function ga(t,e){return _a(t,e)+"000"}function ma(t,e){return Yi(t.getMonth()+1,e,2)}function va(t,e){return Yi(t.getMinutes(),e,2)}function ya(t,e){return Yi(t.getSeconds(),e,2)}function ba(t){var e=t.getDay();return 0===e?7:e}function wa(t,e){return Yi(_i.count(Ei(t)-1,t),e,2)}function xa(t){var e=t.getDay();return e>=4||0===e?yi(t):yi.ceil(t)}function Ma(t,e){return t=xa(t),Yi(yi.count(Ei(t),t)+(4===Ei(t).getDay()),e,2)}function ka(t){return t.getDay()}function Na(t,e){return Yi(gi.count(Ei(t)-1,t),e,2)}function Ta(t,e){return Yi(t.getFullYear()%100,e,2)}function Aa(t,e){return Yi((t=xa(t)).getFullYear()%100,e,2)}function za(t,e){return Yi(t.getFullYear()%1e4,e,4)}function Sa(t,e){var n=t.getDay();return Yi((t=n>=4||0===n?yi(t):yi.ceil(t)).getFullYear()%1e4,e,4)}function Ea(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Yi(e/60|0,"0",2)+Yi(e%60,"0",2)}function Ca(t,e){return Yi(t.getUTCDate(),e,2)}function $a(t,e){return Yi(t.getUTCHours(),e,2)}function Da(t,e){return Yi(t.getUTCHours()%12||12,e,2)}function La(t,e){return Yi(1+fi.count(Ci(t),t),e,3)}function Ua(t,e){return Yi(t.getUTCMilliseconds(),e,3)}function Pa(t,e){return Ua(t,e)+"000"}function Ha(t,e){return Yi(t.getUTCMonth()+1,e,2)}function Oa(t,e){return Yi(t.getUTCMinutes(),e,2)}function ja(t,e){return Yi(t.getUTCSeconds(),e,2)}function Fa(t){var e=t.getUTCDay();return 0===e?7:e}function Ya(t,e){return Yi(Mi.count(Ci(t)-1,t),e,2)}function Ra(t){var e=t.getUTCDay();return e>=4||0===e?Ai(t):Ai.ceil(t)}function Ia(t,e){return t=Ra(t),Yi(Ai.count(Ci(t),t)+(4===Ci(t).getUTCDay()),e,2)}function qa(t){return t.getUTCDay()}function Ba(t,e){return Yi(ki.count(Ci(t)-1,t),e,2)}function Va(t,e){return Yi(t.getUTCFullYear()%100,e,2)}function Xa(t,e){return Yi((t=Ra(t)).getUTCFullYear()%100,e,2)}function Wa(t,e){return Yi(t.getUTCFullYear()%1e4,e,4)}function Za(t,e){var n=t.getUTCDay();return Yi((t=n>=4||0===n?Ai(t):Ai.ceil(t)).getUTCFullYear()%1e4,e,4)}function Ga(){return"+0000"}function Ka(){return"%"}function Qa(t){return+t}function Ja(t){return Math.floor(+t/1e3)}function to(t){return function(){return t}}function eo(t){this._context=t}function no(t){return new eo(t)}function ro(t){return t[0]}function io(t){return t[1]}function ao(t,e){var n=to(!0),r=null,i=no,a=null,o=function(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(null==n)e=null;else{const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new Nr(e)}(s);function s(s){var l,u,c,h=(s=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(s)).length,f=!1;for(null==r&&(a=i(c=o())),l=0;l<=h;++l)!(l<h&&n(u=s[l],l,s))===f&&((f=!f)?a.lineStart():a.lineEnd()),f&&a.point(+t(u,l,s),+e(u,l,s));if(c)return a=null,c+""||null}return t="function"==typeof t?t:void 0===t?ro:to(t),e="function"==typeof e?e:void 0===e?io:to(e),s.x=function(e){return arguments.length?(t="function"==typeof e?e:to(+e),s):t},s.y=function(t){return arguments.length?(e="function"==typeof t?t:to(+t),s):e},s.defined=function(t){return arguments.length?(n="function"==typeof t?t:to(!!t),s):n},s.curve=function(t){return arguments.length?(i=t,null!=r&&(a=i(r)),s):i},s.context=function(t){return arguments.length?(null==t?r=a=null:a=i(r=t),s):r},s}function oo(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function so(t){this._context=t}function lo(t){return new so(t)}function uo(t,e){this._context=t,this._t=e}!function(t){Ui=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,s=t.months,l=t.shortMonths,u=Ii(i),c=qi(i),h=Ii(a),f=qi(a),d=Ii(o),p=qi(o),_=Ii(s),g=qi(s),m=Ii(l),v=qi(l),y={a:function(t){return o[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:null,d:ha,e:ha,f:ga,g:Aa,G:Sa,H:fa,I:da,j:pa,L:_a,m:ma,M:va,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Qa,s:Ja,S:ya,u:ba,U:wa,V:Ma,w:ka,W:Na,x:null,X:null,y:Ta,Y:za,Z:Ea,"%":Ka},b={a:function(t){return o[t.getUTCDay()]},A:function(t){return a[t.getUTCDay()]},b:function(t){return l[t.getUTCMonth()]},B:function(t){return s[t.getUTCMonth()]},c:null,d:Ca,e:Ca,f:Pa,g:Xa,G:Za,H:$a,I:Da,j:La,L:Ua,m:Ha,M:Oa,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Qa,s:Ja,S:ja,u:Fa,U:Ya,V:Ia,w:qa,W:Ba,x:null,X:null,y:Va,Y:Wa,Z:Ga,"%":Ka},w={a:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.w=f.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=v.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=_.exec(e.slice(n));return r?(t.m=g.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return k(t,e,n,r)},d:ea,e:ea,f:sa,g:Ki,G:Gi,H:ra,I:ra,j:na,L:oa,m:ta,M:ia,p:function(t,e,n){var r=u.exec(e.slice(n));return r?(t.p=c.get(r[0].toLowerCase()),n+r[0].length):-1},q:Ji,Q:ua,s:ca,S:aa,u:Vi,U:Xi,V:Wi,w:Bi,W:Zi,x:function(t,e,r){return k(t,n,e,r)},X:function(t,e,n){return k(t,r,e,n)},y:Ki,Y:Gi,Z:Qi,"%":la};function x(t,e){return function(n){var r,i,a,o=[],s=-1,l=0,u=t.length;for(n instanceof Date||(n=new Date(+n));++s<u;)37===t.charCodeAt(s)&&(o.push(t.slice(l,s)),null!=(i=Hi[r=t.charAt(++s)])?r=t.charAt(++s):i="e"===r?" ":"0",(a=e[r])&&(r=a(n,i)),o.push(r),l=s+1);return o.push(t.slice(l,s)),o.join("")}}function M(t,e){return function(n){var r,i,a=Li(1900,void 0,1);if(k(a,t,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("s"in a)return new Date(1e3*a.s+("L"in a?a.L:0));if(e&&!("Z"in a)&&(a.Z=0),"p"in a&&(a.H=a.H%12+12*a.p),void 0===a.m&&(a.m="q"in a?a.q:0),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(i=(r=Di(Li(a.y,0,1))).getUTCDay(),r=i>4||0===i?ki.ceil(r):ki(r),r=fi.offset(r,7*(a.V-1)),a.y=r.getUTCFullYear(),a.m=r.getUTCMonth(),a.d=r.getUTCDate()+(a.w+6)%7):(i=(r=$i(Li(a.y,0,1))).getDay(),r=i>4||0===i?gi.ceil(r):gi(r),r=hi.offset(r,7*(a.V-1)),a.y=r.getFullYear(),a.m=r.getMonth(),a.d=r.getDate()+(a.w+6)%7)}else("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),i="Z"in a?Di(Li(a.y,0,1)).getUTCDay():$i(Li(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(i+5)%7:a.w+7*a.U-(i+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,Di(a)):$i(a)}}function k(t,e,n,r){for(var i,a,o=0,s=e.length,l=n.length;o<s;){if(r>=l)return-1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(a=w[i in Hi?e.charAt(o++):i])||(r=a(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return y.x=x(n,y),y.X=x(r,y),y.c=x(e,y),b.x=x(n,b),b.X=x(r,b),b.c=x(e,b),{format:function(t){var e=x(t+="",y);return e.toString=function(){return t},e},parse:function(t){var e=M(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=x(t+="",b);return e.toString=function(){return t},e},utcParse:function(t){var e=M(t+="",!0);return e.toString=function(){return t},e}}}(t),Ui.format,Pi=Ui.parse,Ui.utcFormat,Ui.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),eo.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}},so.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:oo(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:oo(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},uo.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}}this._x=t,this._y=e}};var co=t=>()=>t;function ho(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function fo(t,e,n){this.k=t,this.x=e,this.y=n}fo.prototype={constructor:fo,scale:function(t){return 1===t?this:new fo(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new fo(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var po=new fo(1,0,0);function _o(t){t.stopImmediatePropagation()}function go(t){t.preventDefault(),t.stopImmediatePropagation()}function mo(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function vo(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||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]]:[[0,0],[t.clientWidth,t.clientHeight]]}function yo(){return this.__zoom||po}function bo(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function wo(){return navigator.maxTouchPoints||"ontouchstart"in this}function xo(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],a=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}fo.prototype;function Mo(t){return!a.has(t,"children")}function ko(t,e,n){let r=[];return function i(a){Mo(a)?e&&a!=t&&r.push(a):(n&&a!=t&&r.push(a),a.children.forEach(i))}(t),r}var No=Object.freeze({__proto__:null,graftANode:function(t,e,n,r){let i=this.nodes.descendants();if(t.parent){if(i.indexOf(t)>=0){let i=t.parent.children.indexOf(t),a={name:n,parent:t.parent,attribute:r?r[2]:null,original_child_order:t.original_child_order},o={name:e,parent:a,attribute:r?r[1]:null,original_child_order:2};a.children=[t,o],t.parent.children[i]=a,t.parent=a,t.attribute=r?r[0]:null,t.original_child_order=1}}return this},addChild:function(t,e){return t.children?t.children.push(e):t.children=[e],t},createNode:function(t,e){return{data:{name:t,attribute:e?e[1]:null},parent:""}},deleteANode:function(t){let e=this.nodes.descendants();if("number"!=typeof t)return this.deleteANode(e.indexOf(t));if(t>0&&t<e.length){let n=e[t];if(n.parent){let r=n.parent.children.indexOf(n);r>=0&&(e.splice(t,1),n.children&&n.children.forEach(function(t){t.original_child_order=n.parent.children.length,n.parent.children.push(t),t.parent=n.parent}),n.parent.children.length>2?n.parent.children.splice(r,1):n.parent.parent?(n.parent.parent.children[n.parent.parent.children.indexOf(n.parent)]=n.parent.children[1-r],n.parent.children[1-r].parent=n.parent.parent,e.splice(e.indexOf(n.parent),1)):(e.splice(0,1),e.parent=null,delete e.data.attribute,delete e.data.annotation,delete e.data.original_child_order,e.name="root",e.data.name="root"))}}return this},getTips:function(){return a.filter(this.nodes.descendants(),t=>!a.has(t,"children"))},getInternals:function(){return a.filter(this.nodes.descendants(),t=>a.has(t,"children"))},getRootNode:function(){return this.nodes},getNodes:function(){return this.nodes},getNodeByName:function(t){return a.filter(this.nodes.descendants(),e=>e.data.name==t)[0]},assignAttributes:function(t){a.each(this.nodes.descendants(),function(e){e.data&&e.data.name in t&&(e.annotations=t[e.data.name])})},isLeafNode:Mo,updateKeyName:function(t,e){return this.nodes.each(function(n){t in n&&(e&&(n[e]=n[t]),delete n[t])}),this},clearInternalNodes:function(t){t||this.nodes.each(t=>{Mo(t)||(t[this.selection_attribute_name]=!1,t.data.traits||(t.data.traits={}),t.data.traits[this.selection_attribute_name]=t[this.selection_attribute_name])})},selectAllDescendants:ko});function To(t,e={}){const n=/^-?\d+(\.\d+)?$/;let r=e.left_delimiter||"{",i=e.right_delimiter||"}",a=[];function o(){let t=a[a.length-1];"children"in t||(t.children=[]),a.push({name:null}),t.children.push(a[a.length-1]),a[a.length-1].original_child_order=t.children.length}function s(){let t=a.pop();t.name=c,"children"in t?t.bootstrap_values=c:t.name=c,t.attribute=h,"["==r&&f.includes("&&NHX")?f.split(":").slice(1).forEach(e=>{const[r,i]=e.split("=");t[r]=n.test(i)?+i:i}):t.annotation=f,c="",h="",f=""}function l(e){return{json:null,error:"Unexpected '"+t[e]+"' in '"+t.substring(e-20,e+1)+"[ERROR HERE]"+t.substring(e+1,e+20)+"'"}}let u=0,c="",h="",f="",d=null,p={"'":1,'"':1},_={name:"root"};a.push(_);for(var g=/\s/,m=0;m<t.length;m++)try{var v=t[m];switch(u){case 0:"("==v&&(o(),u=1);break;case 1:case 3:if(":"==v)u=3;else if(","==v||")"==v)try{s(),u=1,","==v&&o()}catch(t){return l(m)}else if("("==v){if(c.length>0)return l(m);o()}else{if(v in p){if(1==u&&0===c.length&&0===h.length&&0===f.length){u=2,d=v;continue}return l(m)}if(v==r){if(f.length)return l(m);u=4}else if(3==u)h+=v;else{if(g.test(v))continue;if(";"==v){m=t.length;break}c+=v}}break;case 2:if(v==d){if(m<t.length-1&&t[m+1]==d){m++,c+=d;continue}d=0,u=1;continue}c+=v;break;case 4:if(v==i)u=3;else{if(v==r)return l(m);f+=v}}}catch(t){return l(m)}return 1!=a.length?l(t.length-1):{json:_,error:null}}function Ao(t,e){let n=this;t||(t=t=>"");let r=[];return t=t||"",function e(i){if(i.notshown)return;if(Mo(i)||(r.push("("),i.children.forEach(function(t,n){n&&r.push(","),e(t)}),r.push(")")),"root"!==i.data.name){const t=i.data.name.replaceAll("'","''");/\W/.test(t)?r.push("'"+t+"'"):r.push(t)}r.push(t(i));let a=n.branch_length_accessor(i);void 0!==a&&r.push(":"+a)}(e||this.nodes),r.join("")+";"}function zo(t){let e=t,n=e.toUpperCase().indexOf("BEGIN DATA;"),r=e.slice(n);if(r.length<2)return"";n=r.toUpperCase().indexOf("END;");let i=r.slice(0,n);r=a.map(i.split(";"),t=>t.trim());let o=a.filter(r,t=>t.toUpperCase().startsWith("DIMENSION"));o=o[0].split(" "),o=a.object(a.map(a.rest(o),t=>t.split("=")));let s=a.filter(r,t=>t.toUpperCase().startsWith("FORMAT"));s=s[0].split(" "),s=a.object(a.map(a.rest(s),t=>t.split("="))),s.symbols=a.reject(s.symbols.split(""),t=>'"'==t);let l=a.filter(r,t=>t.toUpperCase().startsWith("MATRIX"));return l=l[0].split("\n"),l=a.object(a.map(a.rest(l),t=>a.compact(t.split(" ")))),l=a.mapObject(l,(t,e)=>"?"==t?s.symbols:Array(t)),{dimensions:o,format:s,matrix:l}}function So(t,e,n){a.each(t.getTips(),t=>{t.data.test=n.matrix[t.data.name]})}function Eo(t){let e=t,n=e.toUpperCase().indexOf("BEGIN TREES;"),r=e.slice(n);if(r.length<2)return"";n=r.toUpperCase().indexOf("END;");let i=r.slice(0,n).split("\n");return i=a.filter(i,t=>t.trim().toUpperCase().startsWith("TREE")),To(i[0])}var Co=Object.freeze({__proto__:null,parseAnnotations:zo,loadAnnotations:So,default:Eo});function $o(t){var e={};if(1==t.nodeType){if(t.attributes.length>0){e["@attributes"]={};for(var n=0;n<t.attributes.length;n++){var r=t.attributes.item(n);e["@attributes"][r.nodeName]=r.nodeValue}}}else 3==t.nodeType&&(e=t.nodeValue);if(t.hasChildNodes()&&1===t.childNodes.length&&3===t.childNodes[0].nodeType)e=t.childNodes[0].nodeValue;else if(t.hasChildNodes())for(var i=0;i<t.childNodes.length;i++){var a=t.childNodes.item(i),o=a.nodeName;if(void 0===e[o])e[o]=$o(a);else{if(void 0===e[o].push){var s=e[o];e[o]=[],e[o].push(s)}e[o].push($o(a))}}return e}var Do=function(t,e){var n;return(n=(t=$o(t)).phyloxml.phylogeny.clade).name="root",function t(e,n){e.clade&&(e.clade.forEach(t),e.children=e.clade,delete e.clade),e.annotation=1,e.attribute="0.01",e.branch_length&&(e.attribute=e.branch_length),e.taxonomy&&(e.name=e.taxonomy.scientific_name),e.annotation=""}(n),{json:n,error:null}};var Lo={nexml:function(t,e){var r;return n.parseString(t,function(t,e){r=e["nex:nexml"].trees[0].tree.map(function(t){var e=t.node.map(t=>t.$),n=e.reduce(function(t,e){return e.edges=[],e.name=e.id,t[e.id]=e,t},{}),r=e.filter(t=>t.root),i=r>0?r[0].id:e[0].id;return n[i].name="root",t.edge.map(t=>t.$).forEach(function(t){n[t.source].edges.push(t)}),function t(e,r){if(e.edges){var i=a.pluck(e.edges,"target");e.children=a.values(a.pick(n,i)),e.children.forEach(function(t,n){t.attribute=e.edges[n].length||""}),e.children.forEach(t),e.annotation=""}}(n[i]),n[i]})}),r},phyloxml:Do,nexus:Eo,nwk:To,nhx:To,beast:function(t,e){e.left_delimiter="[",e.right_delimiter="]";const n=To(t,e);return function t(e){if(e.annotation){e.beast={};const t=e.annotation.split(/=|,|{|}/).filter(t=>t);for(var n=0;n<t.length;n+=2){let r=t[n].replace(/&|%/g,"");/[a-df-zA-DF-Z]+/.test(t[n+2])?e.beast[r]=+t[n+1]:(e.beast[r]=[+t[n+1],+t[n+2]],n++)}}e.annotation=void 0,e.children&&e.children.forEach(t)}(n.json),n}};function Uo(t,e,n){let r,i,a,o=[t],s=[];for(;t=o.pop();)if((!n||!n(t))&&(s.push(t),r=t.children,r))for(i=0,a=r.length;i<a;++i)o.push(r[i]);for(;t=s.pop();)e(t);return t}function Po(t,e,n){let r,i,a=[t];for(;t=a.pop();)if((!n||!n(t))&&(e(t),r=t.children,r))for(i=r.length-1;i>=0;--i)a.push(r[i]);return t}function Ho(t,e,n){let r,i,a,o,s=[t];do{for(r=s.reverse(),s=[];t=r.pop();)if((!n||!n(t))&&(e(t),i=t.children,i))for(a=0,o=i.length;a<o;++a)s.push(i[a])}while(s.length);return t}function Oo(t){return Uo(t,function(t){t.children&&(t.children[0].data.multiway_parent=t,t.children[1].data.multiway_parent=t.parent)}),o.map(t.descendants(),t=>{let e=t.data.multiway_parent,n="unknown";return e&&(n=e.data.name),{source:t.data.multiway_parent,target:t,name:n}})}function jo(t,e){let n=t.data;if("attribute"in n&&n.attribute&&n.attribute.length){e>0&&(n.attribute=String(e));let t=parseFloat(n.attribute);if(!isNaN(t))return Math.max(0,t)}if("root"==n.name)return 0;console.warn("Undefined branch length at "+n.name+"!")}var Fo=Object.freeze({__proto__:null,reroot:function(t,e){if(!(t instanceof Rr))throw new Error("node needs to be an instance of a d3.hierarchy node!");let n=this.nodes.copy();if(e=void 0!==e?e:.5,t.parent){var r=Rr({name:"new_root"});r.children=[t.copy()],r.data.__mapped_bl=void 0,n.each(t=>{t.data.__mapped_bl=this.branch_length_accessor(t)}),this.setBranchLength(t=>t.data.__mapped_bl);let o=t,s=t.parent,l=a.noop(),u=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl*e;var i;if(l=s.data.__mapped_bl,s.data.__mapped_bl=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl-u,t.data.__mapped_bl=u,s.parent){for(r.children.push(s);s.parent;){i=s.children.indexOf(o),s.parent.parent?s.children.splice(i,1,s.parent):s.children.splice(i,1);let t=s.parent.data.__mapped_bl;void 0!==t&&(s.parent.data.__mapped_bl=l,l=t),o=s,s=s.parent}i=s.children.indexOf(o),s.children.splice(i,1)}else i=s.children.indexOf(o),s.children.splice(i,1),l=s.data.__mapped_bl,o=r;if(1==s.children.length)l&&(s.children[0].data.__mapped_bl+=l),o.children=o.children.concat(s.children);else{let e=new Rr({name:"__reroot_top_clade",__mapped_bl:l});a.extendOwn(r.children[0],t),e.data.__mapped_bl=l,e.children=s.children.map(function(t){return t.parent=e,t}),e.parent=o,o.children.push(e)}}if(this.update(r),this.traverse_and_compute(t=>{a.each(t.children,e=>{e.parent=t})},"pre-order"),!a.isUndefined(this.display)){let t=this.display.options;It(this.display.container).select("svg").remove();let e=this.display.selection_attribute_name;delete this.display;let n=this.render(t);n.selectionLabel(e),n.update(),It(n.container).node().appendChild(n.show()),It(this.display.container).dispatch("reroot")}return this},rootpath:function(t,e){if(t=t||"attribute",e=e||"y_scaled","parent"in this){let n=parseFloat(this[t]);this[e]=this.parent[e]+(isNaN(n)?.1:n)}else this[e]=0;return this[e]},pathToRoot:function(t){let e=[];for(;t;)e.push(t),t=t.parent;return e}});function Yo(t){return t.y}function Ro(t){return t.x}function Io(t,e,n){return{x:n+t*Math.sin(e),y:n+t*Math.cos(e)}}function qo(t,e,n,r,i,a){t.radius=e*(t.radius+n),t.angle=2*Math.PI*t.x*i[0]/a[0];let o=Io(t.radius,t.angle,r);return t.x=o.x,t.y=o.y,t}function Bo(t,e){var n=Io(e[0].radius,e[0].angle,t),r=Io(e[0].radius,e[1].angle,t);return"M "+Yo(n)+","+Ro(n)+" A "+e[0].radius+","+e[0].radius+" 0,0, "+(e[1].angle>e[0].angle?1:0)+" "+Yo(r)+","+Ro(r)+" L "+Yo(e[1])+","+Ro(e[1])}function Vo(t,e,n){var r=Io(t.target.radius+(t.source.radius-t.target.radius)*e,t.target.angle,n);return{x:Yo(r),y:Ro(r)}}var Xo=ao().x(function(t){return Yo(t)}).y(function(t){return Ro(t)}).curve(function(t){return new uo(t,0)});function Wo(t,e){return{x:Yo(t.target)+(Yo(t.source)-Yo(t.target))*e,y:Ro(t.target)}}function Zo(t){return t.tag||!1}function Go(t,e){return t[e]||!1}const Ko={"tree-container":"phylotree-container","tree-scale-bar":"tree-scale-bar",node:"node","internal-node":"internal-node","tagged-node":"node-tagged","selected-node":"node-selected","collapsed-node":"node-collapsed","root-node":"root-node",branch:"branch","selected-branch":"branch-selected","tagged-branch":"branch-tagged","tree-selection-brush":"tree-selection-brush","branch-tracer":"branch-tracer",clade:"clade",node_text:"phylotree-node-text"};function Qo(t={}){Object.keys(t).forEach(e=>{Ko[e]=t[e]})}function Jo(t){return arguments.length?(Jo="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):Jo}var ts={all:t=>!0,none:t=>!1,"all-leaf-nodes":t=>Mo(t.target),"all-internal-nodes":t=>!Mo(t.target)};var es=Object.freeze({__proto__:null,css_classes:Ko,initializeCssClasses:Qo,internalNames:function(t){return arguments.length?(this.options["internal-names"]=t,this):this.options["internal-names"]},radial:function(t){return arguments.length?(this.options["is-radial"]=t,this):this.options["is-radial"]},alignTips:function(t){return arguments.length?(this.options["align-tips"]=t,this):this.options["align-tips"]},nodeBubbleSize:function(t){return this.options["draw-size-bubbles"]&&this.options["bubble-styler"]?this.options["bubble-styler"](t):this.options["draw-size-bubbles"]?this.relative_nodeSpan(t)*this.scales[0]*.25:0},shiftTip:function(t){return this.options["is-radial"]?[("end"==t.text_align?-1:1)*(this.radius_pad_for_bubbles-t.radius),0]:(this.options["right-to-left"],[this.right_most_leaf-t.screen_x,0])},layoutHandler:function(t){return arguments.length?(this.layout_listener_handler=t,this):this.layout_listener_handler},selectionLabel:function(t){return arguments.length?(this.selection_attribute_name=t,this.syncEdgeLabels(),this):this.selection_attribute_name},get nodeSpan(){return Jo},predefined_selecters:ts,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function ns(t){return!(t.hidden||t.notshown)}function rs(t){return t.notshown}function is(t){return t.hasHiddenNodes||!1}function as(t){return t.collapsed||!1}function os(t){return[t.node,t["internal-node"],t["collapsed-node"],t["tagged-node"],t["root-node"]].reduce(function(t,e,n,r){return t+"g."+e+(n<r.length-1?",":"")},"")}function ss(t){return Mo(t=t.data)?t.name||"":this.showInternalName(t)?t.name:""}var ls=Object.freeze({__proto__:null,shiftTip:function(t){return this.radial()?[("end"==t.text_align?-1:1)*(this.radius_pad_for_bubbles-t.radius),0]:(this.options["right-to-left"],[this.right_most_leaf-t.screen_x,0])},drawNode:function(t,e,n){t=It(t);var r=Mo(e);r&&(t=t.attr("data-node-name",e.data.name));var i=t.selectAll("text").data([e]),a=t.selectAll("line");if(r||this.showInternalName(e)&&!as(e))if(i=i.enter().append("text").classed(this.css_classes.node_text,!0).merge(i).on("click",t=>{this.handle_node_click(e,t)}).attr("dy",t=>.33*this.shown_font_size).text(t=>this.options["show-labels"]?this._nodeLabel(t):"").style("font-size",t=>this.ensure_size_is_in_px(this.shown_font_size)),i=this.radial()?i.attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)+this.d3PhylotreeSvgTranslate(this.alignTips()?this.shiftTip(t):null)).attr("text-anchor",t=>t.text_align):i.attr("text-anchor","start").attr("transform",t=>"right-to-left"==this.options.layout?this.d3PhylotreeSvgTranslate([-20,0]):this.d3PhylotreeSvgTranslate(this.alignTips()?this.shiftTip(t):null)),this.alignTips()?(a=a.data([e]),n?a=a.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(a).attr("x1",t=>("end"==t.text_align?-1:1)*this.nodeBubbleSize(e)).attr("x2",0).attr("y1",0).attr("y2",0).attr("x2",t=>"right-to-left"==this.options.layout?t.screen_x:this.shiftTip(t)[0]).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)).attr("x2",t=>"right-to-left"==this.options.layout?t.screen_x:this.shiftTip(t)[0]).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)):(a=a.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(a).attr("x1",t=>("end"==t.text_align?-1:1)*this.nodeBubbleSize(e)).attr("y2",0).attr("y1",0).attr("x2",t=>this.shiftTip(t)[0])).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle))):a.remove(),this.options["draw-size-bubbles"]){var o=this.nodeBubbleSize(e);t.selectAll("circle").data([o]).enter().append("circle").attr("r",function(t){return t}),this.shown_font_size>=5&&(i=i.attr("dx",t=>("end"==t.text_align?-1:1)*((this.alignTips()?0:o)+.33*this.shown_font_size)))}else this.shown_font_size>=5&&(i=i.attr("dx",t=>("end"==t.text_align?-1:1)*this.shown_font_size*.33));if(!r){let n=t.selectAll("circle").data([e]).enter().append("circle"),r=this.node_circle_size()(e);r>0?n.merge(n).attr("r",t=>Math.min(.75*this.shown_font_size,r)).on("click",t=>{this.handle_node_click(e,t)}):n.remove()}return this.node_styler&&this.node_styler(t,e),e},updateHasHiddenNodes:function(){let t=this.phylotree.nodes.descendants();for(let e=t.length-1;e>=0;e-=1)Mo(t[e])?t[e].hasHiddenNodes=t[e].notshown:t[e].hasHiddenNodes=t[e].children.reduce(function(t,e){return e.notshown||t},!1);return this},showInternalName:function(t){const e=this.internalNames();return!!e&&("function"==typeof e?e(t):e)},nodeSpan:function(t){return arguments.length?(this.nodeSpan="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):this.nodeSpan},reclassNode:function(t){let e=Ko[Mo(t)?"node":"internal-node"];return Zo(t)&&(e+=" "+Ko["tagged-node"]),Go(t,this.selection_attribute_name)&&(e+=" "+Ko["selected-node"]),t.parent||(e+=" "+Ko["root-node"]),(as(t)||is(t))&&(e+=" "+Ko["collapsed-node"]),e},nodeVisible:ns,nodeNotshown:rs,hasHiddenNodes:is,isNodeCollapsed:as,nodeCssSelectors:os,internalLabel:function(t,e){this.phylotree.clearInternalNodes(e);for(var n=this.phylotree.nodes.descendants().length-1;n>=0;n--){var r=this.phylotree.nodes.descendants()[n];Mo(r)||Go(r,this.selection_attribute_name)||(r[this.selection_attribute_name]=t(r.children))}this.modifySelection((t,e)=>(Mo(t.target),t.target[this.selection_attribute_name]))},defNodeLabel:ss,nodeLabel:function(t){return arguments.length?(this._nodeLabel=t||ss,this.update(),this):this._nodeLabel}});function us(t){return[t.clade].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var cs=Object.freeze({__proto__:null,cladeCssSelectors:us,updateCollapsedClades:function(t){let e=this.svg.selectAll("."+this.css_classes["tree-container"]);var n=0;let r=e.selectAll(us(this.css_classes)).data(this.phylotree.nodes.descendants().filter(as),function(t){return t.id||(t.id=++n)}),i=function(){},o=a.noop();this.radial()?(i=ao().curve(lo).y(function(t){return t[0]}).x(function(t){return t[1]}),o=function(t,e,n,r,i){return e?[n.screen_y+(t[0]-r)/50,n.screen_x+(t[1]-i)/50]:[n.screen_y,n.screen_x]}):(i=ao().y(function(t){return t[0]}).x(function(t){return t[1]}).curve(lo),o=function(t,e,n,r,i){return e?[n.screen_y+(t[0]-r)/50,n.screen_x+(t[1]-i)/50]:[n.screen_y,n.screen_x]}),r.exit().each(function(t){t.collapsed_clade=null}).remove(),t?r.enter().insert("path",":first-child").attr("class",this.css_classes.clade).merge(r).attr("d",function(t){if(t.collapsed_clade)return t.collapsed_clade;let e=t.collapsed[0][0],n=t.collapsed[0][1];return i(t.collapsed.map(function(r,i){return o(r,i,t,e,n)}))}).attr("d",function(t){return t.collapsed_clade=i(t.collapsed)}):r.enter().insert("path",":first-child").attr("class",this.css_classes.clade).merge(r).attr("d",function(t){return t.collapsed_clade?t.collapsed_clade:t.collapsed_clade=i(t.collapsed)})}});function hs(t){return!(t.target.hidden||t.target.notshown)}function fs(t){return[t.branch,t["selected-branch"],t["tagged-branch"]].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var ds=Object.freeze({__proto__:null,drawEdge:function(t,e,n){t=(t=It(t)).attr("class",t=>this.reclassEdge(t)).on("click",t=>{this.modifySelection([e.target],this.selection_attribute_name),this.update()});let r=this.draw_branch([e.source,e.target]);n?(t.datum().existing_path&&(t=t.attr("d",function(t){return t.existing_path})),t=t.attr("d",r)):t=t.attr("d",r),e.existing_path=r;var i=this.phylotree.branch_length_accessor(e.target);if(void 0!==i){var a=t.selectAll("title");a.empty()&&(a=t.append("title")),a.text("Length = "+i)}else t.selectAll("title").remove();return this.edge_styler&&this.edge_styler(t,e,n),this.phylotree},reclassEdge:function(t){let e=Ko.branch;return Zo(t)&&(e+=" "+Ko["tagged-branch"]),Go(t,this.selection_attribute_name)&&(e+=" "+Ko["selected-branch"]),e},initializeEdgeLabels:function(){this.links.forEach(t=>{t.target.data.annotation&&(t.target[t.target.data.annotation]=t.target.data.annotation)})},syncEdgeLabels:function(){if(this.links.forEach(t=>{t[this.selection_attribute_name]=t.target[this.selection_attribute_name]||!1,t.tag=t.target.tag||!1}),this.countHandler()){let t={};t[this.selection_attribute_name]=this.links.reduce((t,e)=>t+(e[this.selection_attribute_name]?1:0),0),t.tagged=this.links.reduce(function(t,e){return t+(Zo(e)?1:0)},0),this.countUpdate(this,t,this.countHandler())}},edgeVisible:hs,edgeCssSelectors:fs,placeAlongAnEdge:function(t,e){return this.edge_placer(t,e)}});let ps="phylotree.event";function _s(t){var e=new CustomEvent(ps,{detail:["refresh",t]});document.dispatchEvent(e)}function gs(t,e){var n=new CustomEvent(ps,{detail:["countUpdate",e,t.countHandler()]});document.dispatchEvent(n)}function ms(t){switch(t.detail[0]){case"refresh":t.detail[1].refresh();break;case"countUpdate":case"layout":t.detail[2](t.detail[1])}return!0}function vs(){document.addEventListener(ps,ms,!1)}var ys=Object.freeze({__proto__:null,toggleCollapse:function(t){if(t.collapsed){t.collapsed=!1;let e=function(t){Mo(t)||t.collapsed||t.children.forEach(e),t.hidden=!1};e(t)}else t.collapsed=!0;return this.placenodes(),this},resizeSvg:function(t,e,n){let r=this.size;if(this.radial()){let t=this.pad_width(),n="fit-to-size"!=this.options["top-bottom-spacing"]?this.pad_height():0;r=[r[1]+2*t,r[0]+2*t+n],e&&e.selectAll("."+Ko["tree-container"]).attr("transform","translate ("+t+","+(t+n)+")")}else r=[r[0]+("fit-to-size"!=this.options["top-bottom-spacing"]?this.pad_height():0),r[1]+("fit-to-size"!=this.options["left-right-spacing"]?this.pad_width():0)];return e&&(n&&(e=e.transition(100)),e.attr("height",r[0]).attr("width",r[1])),this.size=r,r},rescale:function(t,e){(e=e||"y_scaled")in this&&(this[e]*=t)},triggerRefresh:_s,countUpdate:gs,d3PhylotreeTriggerLayout:function(t){var e=new CustomEvent(ps,{detail:["layout",t,t.layoutHandler()]});document.dispatchEvent(e)},d3PhylotreeEventListener:ms,d3PhylotreeAddEventListener:vs,d3PhylotreeSvgTranslate:function(t){return!t||null===t[0]&&null===t[1]?"":"translate ("+(null!==t[0]?t[0]:0)+","+(null!==t[1]?t[1]:0)+") "},d3PhylotreeSvgRotate:function(t){return null!==t?"rotate ("+t+") ":""}});let bs="d3_layout_phylotree_context_menu";function ws(t,e,n){let r=[];return function i(a){Mo(a)?e&&a!=t&&r.push(a):(n&&a!=t&&r.push(a),a.children.forEach(i))}(t),r}var xs=Object.freeze({__proto__:null,nodeDropdownMenu:function(t,e,n,r,i){let o=It(e).select("#"+bs);if(o.empty()&&(o=It(e).append("div").attr("id",bs).attr("class","dropdown-menu").attr("role","menu")),o.selectAll("a").remove(),o.selectAll("h6").remove(),o.selectAll("div").remove(),t){if(!a.some([Boolean(t.menu_items),r.hide,r.selectable,r.collapsible])||!r["show-menu"])return;Mo(t)||(r.collapsible&&(o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(as(t)?"Expand Subtree":"Collapse Subtree").on("click",e=>{o.style("display","none"),this.toggleCollapse(t).update()}),r.selectable&&(o.append("div").attr("class","dropdown-divider"),o.append("h6").attr("class","dropdown-header").text("Toggle selection"))),r.selectable&&(o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All descendant branches").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0))}),o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All terminal branches").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!1))}),o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All internal branches").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!1,!0))}))),t.parent&&(r.selectable&&(o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Incident branch").on("click",function(e){o.style("display","none"),n.modifySelection([t])}),o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Path to root").on("click",e=>{o.style("display","none"),this.modifySelection(this.phylotree.pathToRoot(t))}),(r.reroot||r.hide)&&o.append("div").attr("class","dropdown-divider")),r.reroot&&o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Reroot on this node").on("click",e=>{o.style("display","none"),this.phylotree.reroot(t),this.update()}),r.hide&&o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Hide this "+(Mo(t)?"node":"subtree")).on("click",e=>{o.style("display","none"),this.modifySelection([t],"notshown",!0,!0).updateHasHiddenNodes().update()})),is(t)&&o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Show all descendant nodes").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0),"notshown",!0,!0,"false").updateHasHiddenNodes().update()});var s=[];if("menu_items"in t&&"object"==typeof t.menu_items&&t.menu_items.forEach(function(e){3==e.length&&(e[2]&&!e[2](t)||s.push([e[0],e[1]]))}),s.length){const e=[r.hide,r.selectable,r.collapsible];a.some(e)&&o.append("div").attr("class","dropdown-divider"),s.forEach(function(e){o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(e[0](t)).on("click",a.partial(e[1],t))})}let l=document.querySelector(e).getBoundingClientRect();o.style("position","absolute").style("left",i.clientX-l.x+12+"px").style("top",i.clientY-l.y+"px").style("display","block")}else o.style("display","none")},addCustomMenu:function(t,e,n,r){"menu_items"in t||(t.menu_items=[]),t.menu_items.some(function(t){return t[0]==e&&t[1]==n&&t[2]==r})||t.menu_items.push([e,n,r])},modifySelection:function(t,e,n,r,i){if(e=e||this.selection_attribute_name,i=i||"toggle",this.options["restricted-selectable"].length){if(!a.contains(a.keys(ts),t))return;t=ts[t]}if(!this.options["restricted-selectable"]&&!this.options.selectable||this.options["binary-selectable"])this.options["binary-selectable"]&&("function"==typeof t?this.links.forEach(function(n){var r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,s=!0,n.target[e]=r),this.options["attribute-list"].forEach(function(t){t!=e&&!0===n[e]&&(n[t]=!1,n.target[t]=!1)})}):(t.forEach(function(t){var n;n=!t[e],t[e]!=n&&(t[e]=n,s=!0)}),this.links.forEach(function(t){t[e]=t.target[e],this.options["attribute-list"].forEach(function(n){n!=e&&!0!==t[e]&&(t[n]=!1,t.target[n]=!1)})})),s&&(r||_s(this),this.countHandler()&&((o={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),this.countUpdate(this,o,this.countHandler())),n&&this.placenodes()));else{var o,s=!1;"function"==typeof t?this.links.forEach(function(n){let r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,s=!0,n.target[e]=r)}):(t.forEach(function(t){var n;switch(i){case"true":n=!0;break;case"false":n=!1;break;default:n=!t[e]}t[e]!=n&&(t[e]=n,s=!0)}),this.links.forEach(function(t){t[e]=t.target[e]})),s&&(r||_s(this),this.countHandler&&((o={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),gs(this,o,this.countHandler)),n&&this.placenodes())}return this._selectionCallback&&"tag"!=e&&this._selectionCallback(this.getSelection()),this.refresh(),this.update(),this},getSelection:function(){return ws(this.phylotree.getRootNode(),!0,!0).filter(t=>t[this.selection_attribute_name])},selectAllDescendants:ws,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function Ms(t){return function(){return t}}class ks{constructor(t,e={}){Qo(e["css-classes"]),this.css_classes=Ko,this.phylotree=t,this.container=e.container,this.separation=function(t,e){return 0},this._nodeLabel=this.defNodeLabel,this.svg=null,this._selectionCallback=null,this.scales=[1,1],this.size=[1,1],this.fixed_width=[14,30],this.scale_bar_font_size=12,this.draw_branch=Xo,this.draw_scale_bar=null,this.edge_placer=Wo,this.count_listener_handler=function(){},this.layout_listener_handler=function(){},this.node_styler=void 0,this.edge_styler=void 0,this.selection_attribute_name="selected",this.right_most_leaf=0,this.label_width=0,this.radial_center=0,this.radius=1,this.radius_pad_for_bubbles=0,this.rescale_nodeSpan=1,this.relative_nodeSpan=function(t){return this.nodeSpan(t)/this.rescale_nodeSpan};let n={layout:"left-to-right",logger:console,branches:"step",scaling:!0,bootstrap:!1,"color-fill":!0,"font-size":14,"internal-names":!1,selectable:!0,"restricted-selectable":!1,collapsible:!0,"left-right-spacing":"fixed-step","top-bottom-spacing":"fixed-step","left-offset":0,"show-scale":"top","draw-size-bubbles":!1,"bubble-styler":this.radius_pad_for_bubbles,"binary-selectable":!1,"is-radial":!1,"attribute-list":[],"max-radius":768,"annular-limit":.38196601125010515,compression:.2,"align-tips":!1,"maximum-per-node-spacing":100,"minimum-per-node-spacing":2,"maximum-per-level-spacing":100,"minimum-per-level-spacing":10,node_circle_size:Ms(3),transitions:null,brush:!0,reroot:!0,hide:!0,"label-nodes-with-name":!1,zoom:!1,"show-menu":!0,"show-labels":!0,"node-styler":null,"edge-styler":null,"node-span":null};this.ensure_size_is_in_px=function(t){return"number"==typeof t?t+"px":t},this.options=a.defaults(e,n),this.font_size=this.options["font-size"],this.offsets=[0,this.font_size/2],this.shown_font_size=this.font_size,this.width=this.options.width||800,this.height=this.options.height||600,this.node_styler=this.options["node-styler"],this.edge_styler=this.options["edge-styler"],this.nodeSpan=this.options["node-span"],this.nodeSpan||(this.nodeSpan=function(t){return 1}),this.rescale_nodeSpan=this.phylotree.nodes.children.map(t=>{if(Mo(t)||this.showInternalName(t))return this.nodeSpan(t)}).reduce(function(t,e){return Math.min(e,t||1e200)},null)||1,this.initialize_svg(this.container),this.links=this.phylotree.nodes.links(),this.initializeEdgeLabels(),this.update(),vs()}pad_height(){return this.draw_scale_bar?this.scale_bar_font_size+25:0}pad_width(){this.label_width=this._label_width(this.shown_font_size);const t=this.options["show-labels"]?this.label_width:0;return this.offsets[1]+this.options["left-offset"]+t}collapse_node(t){as(t)||(t.collapsed=!0)}set_size(t){if(!arguments.length)return this.size;let e=t;return"fixed-step"!=this.options["top-bottom-spacing"]&&(this.size[0]=e[0]),"fixed-step"!=this.options["left-right-spacing"]&&(this.size[1]=e[1]),this}initialize_svg(t){var e;return this.svg!==t&&(It(t).select("svg").remove(),this.svg=(e="svg",It(P(e).call(document.documentElement))).attr("width",this.width).attr("height",this.height),this.set_size([this.height,this.width]),"phylotree-container"==this.css_classes["tree-container"]&&(this.svg.selectAll("*").remove(),this.svg.append("defs")),It(this.container).on("click",t=>{this.handle_node_click(null)},!0)),this}update_layout(t,e){e&&(this.nodes=Rr(t),this.nodes.each(function(t){t.id=null})),this.update(),this.syncEdgeLabels()}update(t){var e=this;this.placenodes(),t=this.transitions(t);let n=0,r=this.svg.selectAll("."+Ko["tree-container"]).data([0]);if(r=r.enter().append("g").attr("class",Ko["tree-container"]).merge(r).attr("transform",t=>this.d3PhylotreeSvgTranslate([this.offsets[1]+this.options["left-offset"],this.pad_height()])),this.draw_scale_bar){let t=this.svg.selectAll("."+Ko["tree-scale-bar"]).data([0]);t.enter().append("g").attr("class",Ko["tree-scale-bar"]).style("font-size",this.ensure_size_is_in_px(this.scale_bar_font_size)).merge(t).attr("transform",t=>this.d3PhylotreeSvgTranslate([this.offsets[1]+this.options["left-offset"],this.pad_height()-10])).call(this.draw_scale_bar),t.selectAll("text").style("text-anchor","end")}else this.svg.selectAll("."+Ko["tree-scale-bar"]).remove();r=this.svg.selectAll("."+Ko["tree-container"]).data([0]),this.updateCollapsedClades(t);let i=r.selectAll(fs(Ko)).data(this.links.filter(hs),t=>t.target.id||(t.target.id=++n));i.exit().remove(),i=i.enter().insert("path",":first-child").merge(i).each(function(n){e.drawEdge(this,n,t)});let o=r.selectAll(os(Ko)).data(this.phylotree.nodes.descendants().filter(ns),t=>t.id||(t.id=++n));if(o.exit().remove(),o=o.enter().append("g").attr("class",this.reclassNode).merge(o).attr("transform",t=>{const e="right-to-left"==this.options.layout&&Mo(t);return t.screen_x=Yo(t),t.screen_y=Ro(t),this.d3PhylotreeSvgTranslate([e?0:t.screen_x,t.screen_y])}).each(function(n){e.drawNode(this,n,t)}).attr("transform",t=>{if(!a.isUndefined(t.screen_x)&&!a.isUndefined(t.screen_y))return"translate("+t.screen_x+","+t.screen_y+")"}),this.options["label-nodes-with-name"]&&(o=o.attr("id",t=>"node-"+t.name)),this.resizeSvg(this.phylotree,this.svg,t),this.options.brush){var s=r.selectAll("."+Ko["tree-selection-brush"]).data([0]).enter().insert("g",":first-child").attr("class",Ko["tree-selection-brush"]),l=yr().on("brush",(t,e)=>{var n=t.selection,r=this.links.filter(hs).filter((t,e)=>t.source.screen_x>=n[0][0]&&t.source.screen_x<=n[1][0]&&t.source.screen_y>=n[0][1]&&t.source.screen_y<=n[1][1]&&t.target.screen_x>=n[0][0]&&t.target.screen_x<=n[1][0]&&t.target.screen_y>=n[0][1]&&t.target.screen_y<=n[1][1]).map(t=>t.target);this.modifySelection(this.phylotree.links.map(t=>t.target),"tag",!1,r.length>0,"false"),this.modifySelection(r,"tag",!1,!1,"true")}).on("end",()=>{});s.call(l)}if(this.syncEdgeLabels(),this.options.zoom){let t=function(){var t,e,n,r=mo,i=vo,a=xo,o=bo,s=wo,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,h=Je,f=A("start","zoom","end"),d=0,p=10;function _(t){t.property("__zoom",yo).on("wheel.zoom",x,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",k).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(t,e){return(e=Math.max(l[0],Math.min(l[1],e)))===t.k?t:new fo(e,t.x,t.y)}function m(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new fo(t.k,r,i)}function v(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function y(t,e,n,r){t.on("start.zoom",function(){b(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event(r).end()}).tween("zoom",function(){var t=this,a=arguments,o=b(t,a).event(r),s=i.apply(t,a),l=null==n?v(s):"function"==typeof n?n.apply(t,a):n,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),c=t.__zoom,f="function"==typeof e?e.apply(t,a):e,d=h(c.invert(l).concat(u/c.k),f.invert(l).concat(u/f.k));return function(t){if(1===t)t=f;else{var e=d(t),n=u/e[2];t=new fo(n,l[0]-e[0]*n,l[1]-e[1]*n)}o.zoom(null,t)}})}function b(t,e,n){return!n&&t.__zooming||new w(t,e)}function w(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function x(t,...e){if(r.apply(this,arguments)){var n=b(this,e).event(t),i=this.__zoom,s=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,o.apply(this,arguments)))),c=qt(t);if(n.wheel)n.mouse[0][0]===c[0]&&n.mouse[0][1]===c[1]||(n.mouse[1]=i.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(i.k===s)return;n.mouse=[c,i.invert(c)],Mn(this),n.start()}go(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",a(m(g(i,s),n.mouse[0],n.mouse[1]),n.extent,u))}}function M(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,o=b(this,e,!0).event(t),s=It(t.view).on("mousemove.zoom",function(t){if(go(t),!o.moved){var e=t.clientX-c,n=t.clientY-h;o.moved=e*e+n*n>d}o.event(t).zoom("mouse",a(m(o.that.__zoom,o.mouse[0]=qt(t,i),o.mouse[1]),o.extent,u))},!0).on("mouseup.zoom",function(t){s.on("mousemove.zoom mouseup.zoom",null),Wt(t.view,o.moved),go(t),o.event(t).end()},!0),l=qt(t,i),c=t.clientX,h=t.clientY;Xt(t.view),_o(t),o.mouse=[l,this.__zoom.invert(l)],Mn(this),o.start()}}function k(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,o=qt(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(o),l=n.k*(t.shiftKey?.5:2),h=a(m(g(n,l),o,s),i.apply(this,e),u);go(t),c>0?It(this).transition().duration(c).call(y,h,o,t):It(this).call(_.transform,h,o,t)}}function N(n,...i){if(r.apply(this,arguments)){var a,o,s,l,u=n.touches,c=u.length,h=b(this,i,n.changedTouches.length===c).event(n);for(_o(n),o=0;o<c;++o)l=[l=qt(s=u[o],this),this.__zoom.invert(l),s.identifier],h.touch0?h.touch1||h.touch0[2]===l[2]||(h.touch1=l,h.taps=0):(h.touch0=l,a=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),a&&(h.taps<2&&(e=l[0],t=setTimeout(function(){t=null},500)),Mn(this),h.start())}}function T(t,...e){if(this.__zooming){var n,r,i,o,s=b(this,e).event(t),l=t.changedTouches,c=l.length;for(go(t),n=0;n<c;++n)i=qt(r=l[n],this),s.touch0&&s.touch0[2]===r.identifier?s.touch0[0]=i:s.touch1&&s.touch1[2]===r.identifier&&(s.touch1[0]=i);if(r=s.that.__zoom,s.touch1){var h=s.touch0[0],f=s.touch0[1],d=s.touch1[0],p=s.touch1[1],_=(_=d[0]-h[0])*_+(_=d[1]-h[1])*_,v=(v=p[0]-f[0])*v+(v=p[1]-f[1])*v;r=g(r,Math.sqrt(_/v)),i=[(h[0]+d[0])/2,(h[1]+d[1])/2],o=[(f[0]+p[0])/2,(f[1]+p[1])/2]}else{if(!s.touch0)return;i=s.touch0[0],o=s.touch0[1]}s.zoom("touch",a(m(r,i,o),s.extent,u))}}function z(t,...r){if(this.__zooming){var i,a,o=b(this,r).event(t),s=t.changedTouches,l=s.length;for(_o(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<l;++i)a=s[i],o.touch0&&o.touch0[2]===a.identifier?delete o.touch0:o.touch1&&o.touch1[2]===a.identifier&&delete o.touch1;if(o.touch1&&!o.touch0&&(o.touch0=o.touch1,delete o.touch1),o.touch0)o.touch0[1]=this.__zoom.invert(o.touch0[0]);else if(o.end(),2===o.taps&&(a=qt(a,this),Math.hypot(e[0]-a[0],e[1]-a[1])<p)){var u=It(this).on("dblclick.zoom");u&&u.apply(this,arguments)}}}return _.transform=function(t,e,n,r){var i=t.selection?t.selection():t;i.property("__zoom",yo),t!==i?y(t,e,n,r):i.interrupt().each(function(){b(this,arguments).event(r).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},_.scaleBy=function(t,e,n,r){_.scaleTo(t,function(){return this.__zoom.k*("function"==typeof e?e.apply(this,arguments):e)},n,r)},_.scaleTo=function(t,e,n,r){_.transform(t,function(){var t=i.apply(this,arguments),r=this.__zoom,o=null==n?v(t):"function"==typeof n?n.apply(this,arguments):n,s=r.invert(o),l="function"==typeof e?e.apply(this,arguments):e;return a(m(g(r,l),o,s),t,u)},n,r)},_.translateBy=function(t,e,n,r){_.transform(t,function(){return a(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),u)},null,r)},_.translateTo=function(t,e,n,r,o){_.transform(t,function(){var t=i.apply(this,arguments),o=this.__zoom,s=null==r?v(t):"function"==typeof r?r.apply(this,arguments):r;return a(po.translate(s[0],s[1]).scale(o.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,u)},r,o)},w.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1===++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0===--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var e=It(this.that).datum();f.call(t,this.that,new ho(t,{sourceEvent:this.sourceEvent,target:_,type:t,transform:this.that.__zoom,dispatch:f}),e)}},_.wheelDelta=function(t){return arguments.length?(o="function"==typeof t?t:co(+t),_):o},_.filter=function(t){return arguments.length?(r="function"==typeof t?t:co(!!t),_):r},_.touchable=function(t){return arguments.length?(s="function"==typeof t?t:co(!!t),_):s},_.extent=function(t){return arguments.length?(i="function"==typeof t?t:co([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),_):i},_.scaleExtent=function(t){return arguments.length?(l[0]=+t[0],l[1]=+t[1],_):[l[0],l[1]]},_.translateExtent=function(t){return arguments.length?(u[0][0]=+t[0][0],u[1][0]=+t[1][0],u[0][1]=+t[0][1],u[1][1]=+t[1][1],_):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},_.constrain=function(t){return arguments.length?(a=t,_):a},_.duration=function(t){return arguments.length?(c=+t,_):c},_.interpolate=function(t){return arguments.length?(h=t,_):h},_.on=function(){var t=f.on.apply(f,arguments);return t===f?_:t},_.clickDistance=function(t){return arguments.length?(d=(t=+t)*t,_):Math.sqrt(d)},_.tapDistance=function(t){return arguments.length?(p=+t,_):p},_}().scaleExtent([.1,10]).on("zoom",t=>{It("."+Ko["tree-container"]).attr("transform",e=>t.transform),It("."+Ko["tree-scale-bar"]).attr("transform",e=>{let n=t.transform;return n.y-=10,n})});this.svg.call(t)}return this}_handle_single_node_layout(t){let e=this.nodeSpan(t)/this.rescale_nodeSpan;this.x=t.x=this.x+this.separation(this.last_node,t)+.5*(this.last_span+e),this._extents[1][1]=Math.max(this._extents[1][1],t.y),this._extents[1][0]=Math.min(this._extents[1][0],t.y-.5*e),this.is_under_collapsed_parent?this._extents[0][1]=Math.max(this._extents[0][1],this.save_x+(t.x-this.save_x)*this.options.compression+this.save_span+(.5*e+this.separation(this.last_node,t))*this.options.compression):this._extents[0][1]=Math.max(this._extents[0][1],this.x+.5*e+this.separation(this.last_node,t)),this.last_node=t,this.last_span=e}tree_layout(t){if(rs(t))return;let e=Mo(t);t.text_angle=null,t.text_align=null,t.radius=null,t.angle=null;let n=!1;if(t.parent)if(this.do_scaling){if(n)return 0;if(t.y=this.phylotree.branch_length_accessor(t),void 0===t.y)return n=!0,0;t.y+=t.parent.y}else t.y=e?this.max_depth:t.depth;else this.x=0,t.y=0,this.last_node=null,this.last_span=0,this._extents=[[0,0],[0,0]];if(e&&this._handle_single_node_layout(t),!e)if(as(t)&&!this.is_under_collapsed_parent){if(this.save_x=this.x,this.save_span=.5*this.last_span,this.is_under_collapsed_parent=!0,this.process_internal_node(t),this.is_under_collapsed_parent=!1,"number"==typeof t.x){t.x=this.save_x+(t.x-this.save_x)*this.options.compression+this.save_span,t.collapsed=[[t.x,t.y]];var r=e=>{e.hidden=!0,Mo(e)?(this.x=e.x=this.save_x+(e.x-this.save_x)*this.options.compression+this.save_span,t.collapsed.push([e.x,e.y])):e.children.map(r)};this.x=this.save_x,r(t),t.collapsed.splice(1,0,[this.save_x,t.y]),t.collapsed.push([this.x,t.y]),t.collapsed.push([t.x,t.y]),t.hidden=!1}}else this.process_internal_node(t);return t.x}process_internal_node(t){let e=0;if(this.showInternalName(t)){let e=t.children.length/2|0,n=0,r=!1;for(let i=0;i<t.children.length;i++){"number"==typeof this.tree_layout(t.children[i])&&n++,n>=e&&!r&&(this._handle_single_node_layout(t),r=!0)}0==n?(t.notshown=!0,t.x=void 0):r||this._handle_single_node_layout(t)}else t.x=t.children.map(this.tree_layout.bind(this)).reduce((t,n)=>"number"==typeof n?t+n:(e+=1,t),0),e==t.children.length?(t.notshown=!0,t.x=void 0):t.x/=t.children.length-e}do_lr(t){if(this.radial()&&t&&(this.offsets[1]=0),"fixed-step"==this.options["left-right-spacing"])this.size[1]=this.max_depth*this.fixed_width[1],this.scales[1]=(this.size[1]-this.offsets[1]-this.options["left-offset"])/this._extents[1][1],this.label_width=this._label_width(this.shown_font_size),this.radial()&&(this.label_width*=2);else{this.label_width=this._label_width(this.shown_font_size),t=!0;let e=this.size[1]-this.offsets[1]-this.options["left-offset"];.5*e<this.label_width&&(this.shown_font_size*=.5*e/this.label_width,this.label_width=.5*e),this.scales[1]=(this.size[1]-this.offsets[1]-this.options["left-offset"]-this.label_width)/this._extents[1][1]}}placenodes(){this._extents=[[0,0],[0,0]],this.x=0,this.last_span=0,this.last_node=null,this.last_span=0,this.save_x=this.x,this.save_span=.5*this.last_span,this.do_scaling=this.options.scaling;this.is_under_collapsed_parent=!1,this.max_depth=1,this.phylotree.nodes.x=this.tree_layout(this.phylotree.nodes,this.do_scaling),this.max_depth=function(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n<e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n<i||void 0===n&&i>=i)&&(n=i)}return n}(this.phylotree.nodes.descendants(),t=>t.depth),this.do_scaling;let t=!1;if(this.draw_scale_bar=this.options["show-scale"]&&this.do_scaling,this.offsets[1]=Math.max(this.font_size,-this._extents[1][0]*this.fixed_width[0]),"fixed-step"==this.options["top-bottom-spacing"]?(this.size[0]=this._extents[0][1]*this.fixed_width[0],this.scales[0]=this.fixed_width[0]):(this.scales[0]=(this.size[0]-this.pad_height())/this._extents[0][1],t=!0),this.shown_font_size=Math.min(this.font_size,this.scales[0]),this.radial()){this.draw_branch=a.partial(Bo,this.radial_center),this.edge_placer=Vo;let e=null,n=null,r=null,i=0,o=this._extents[0][1]*this.scales[0],s=function(t,e,n,r,i){return i=i||0,Math.sqrt((e-t)*(e-t)+2*(t+i)*(e+i)*(1-Math.cos(n-r)))},l=0;this.phylotree.nodes.each(t=>{let e=t.x*this.scales[0];t.angle=2*Math.PI*e/o,t.text_angle=t.angle-Math.PI/2,t.text_angle=t.text_angle>0&&t.text_angle<Math.PI,t.text_align=t.text_angle?"end":"start",t.text_angle=(t.text_angle?180:0)+180*t.angle/Math.PI}),this.do_lr(t),this.phylotree.nodes.each(t=>{t.radius=t.y*this.scales[1]/this.size[1],l=Math.max(t.radius,l)});let u=0;this.phylotree.nodes.each(t=>{if(!t.children){let a=t.x*this.scales[0];if(null!==e){let o=a-n,c=s(t.radius,r,t.angle,e,u),h=c>0?o/c:10*this.options["max-radius"];if(h>this.options["max-radius"]){let n=o/this.options["max-radius"],a=t.radius+r,s=t.radius*r-(n*n-(r-t.radius)*(r-t.radius))/2/(1-Math.cos(e-t.angle)),c=Math.sqrt(a*a-4*s);u=Math.min(this.options["annular-limit"]*l,(-a+c)/2),i=this.options["max-radius"]}else i=Math.max(i,h)}e=t.angle,n=a,r=t.radius}}),this.radius=Math.min(this.options["max-radius"],Math.max(o/2/Math.PI,i)),t&&(this.radius=Math.min(this.radius,.5*(Math.min(o,this._extents[1][1]*this.scales[1])-this.label_width)-this.radius*u)),this.radial_center=this.radius_pad_for_bubbles=this.radius,this.draw_branch=a.partial(Bo,this.radial_center);let c=1;u&&(c=l/(l+u),this.radius*=c),this.phylotree.nodes.each(t=>{if(qo(t,this.radius,u,this.radial_center,this.scales,this.size),l=Math.max(l,t.radius),this.options["draw-size-bubbles"]?this.radius_pad_for_bubbles=Math.max(this.radius_pad_for_bubbles,t.radius+this.nodeBubbleSize(t)):this.radius_pad_for_bubbles=Math.max(this.radius_pad_for_bubbles,t.radius),t.collapsed){t.collapsed=t.collapsed.map(t=>{let e={};return e.x=t[0],e.y=t[1],e=qo(e,this.radius,u,this.radial_center,this.scales,this.size),[e.x,e.y]});let e=t.collapsed[1];t.collapsed=t.collapsed.filter(function(n,r){return r<3||r>t.collapsed.length-4||Math.sqrt(Math.pow(n[0]-e[0],2)+Math.pow(n[1]-e[1],2))>3&&(e=n,!0)})}}),this.size[0]=this.radial_center+this.radius/c,this.size[1]=this.radial_center+this.radius/c}else this.do_lr(),this.draw_branch=Xo,this.edge_placer=Wo,this.right_most_leaf=0,this.phylotree.nodes.each(t=>{if(t.x*=this.scales[0],t.y*=.8*this.scales[1],"right-to-left"==this.options.layout&&(t.y=this._extents[1][1]*this.scales[1]-t.y),Mo(t)&&(this.right_most_leaf=Math.max(this.right_most_leaf,t.y+this.nodeBubbleSize(t))),t.collapsed){t.collapsed.forEach(t=>{t[0]*=this.scales[0],t[1]*=.8*this.scales[1]});let e=t.collapsed[1][0];t.collapsed=t.collapsed.filter(function(n,r){return r<3||r>t.collapsed.length-4||n[0]-e>3&&(e=n[0],!0)})}});if(this.draw_scale_bar){let t,e;if(this.radial()){if(e=Math.min(this.radius/5,50),t=Math.pow(10,Math.ceil(Math.log(this._extents[1][1]*e/this.radius)/Math.log(10))),e=t*(this.radius/this._extents[1][1]),e<30){let n=Math.ceil(30/e);e*=n,t*=n}}else t=this._extents[1][1],e=this.size[1]-this.offsets[1]-this.options["left-offset"]-this.shown_font_size;let n=ii().domain([0,t]).range([0,e]),r=Pr(".2f");if(this.draw_scale_bar=function(t){return N(1,t)}().scale(n).tickFormat(function(t){return 0===t?"":r(t)}),this.radial())this.draw_scale_bar.tickValues([t]);else{let t=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)},i=n.ticks();i=i.length>1?i[1]:i[0],this.draw_scale_bar.ticks(Math.min(10,t(e/(this.shown_font_size*r(i).length*2),0)))}}else this.draw_scale_bar=null;return this}spacing_x(t,e){return arguments.length?(this.fixed_width[0]!=t&&t>=this.options["minimum-per-node-spacing"]&&t<=this.options["maximum-per-node-spacing"]&&(this.fixed_width[0]=t,e||this.placenodes()),this):this.fixed_width[0]}spacing_y(t,e){return arguments.length?(this.fixed_width[1]!=t&&t>=this.options["minimum-per-level-spacing"]&&t<=this.options["maximum-per-level-spacing"]&&(this.fixed_width[1]=t,e||this.placenodes()),this):this.fixed_width[1]}_label_width(t){t=t||this.shown_font_size;let e=0;return this.phylotree.nodes.descendants().filter(ns).forEach(n=>{let r=12+this._nodeLabel(n).length*t*.8;null!==n.angle&&(r*=Math.max(Math.abs(Math.cos(n.angle)),Math.abs(Math.sin(n.angle)))),e=Math.max(r,e)}),e}font_size(t){return arguments.length?(this.font_size=void 0===t?12:t,this):this.font_size}scale_bar_font_size(t){return arguments.length?(this.scale_bar_font_size=void 0===t?12:t,this):this.scale_bar_font_size}node_circle_size(t,e){return arguments.length?(this.options.node_circle_size=Ms(void 0===t?3:t),this):this.options.node_circle_size}css(t){if(0===arguments.length)return this.css_classes;if(arguments.length>2){var e={};return e[t[0]]=t[1],this.css(e)}for(var n in Ko)n in t&&t[n]!=Ko[n]&&(Ko[n]=t[n]);return this}transitions(t){return void 0!==t?t:null!==this.options.transitions?this.options.transitions:this.phylotree.nodes.descendants().length<=300}css_classes(t,e){if(!arguments.length)return this.css_classes;let n=!1;for(var r in Ko)r in t&&t[r]!=this.css_classes[r]&&(n=!0,this.css_classes[r]=t[r]);return e&&n&&this.layout(),this}layout(t){return this.svg?(this.svg.selectAll("."+this.css_classes["tree-container"]+",."+this.css_classes["tree-scale-bar"]+",."+this.css_classes["tree-selection-brush"]),this.d3PhylotreeTriggerLayout(this),this.update()):(this.d3PhylotreeTriggerLayout(this),this)}handle_node_click(t,e){this.nodeDropdownMenu(t,this.container,this,this.options,e)}refresh(){if(this.svg){let t=this.svg.selectAll("."+this.css_classes["tree-container"]).selectAll(fs(this.css_classes)).attr("class",this.reclassEdge.bind(this));this.edge_styler&&t.each(t=>{this.edge_styler(It(this),t)})}return this}countHandler(t){return arguments.length?(this.count_listener_handler=t,this):this.count_listener_handler}style_nodes(t){return arguments.length?(this.node_styler=t,this):this.node_styler}style_edges(t){return arguments.length?(this.edge_styler=t.bind(this),this):this.edge_styler}itemSelected(t,e){return t[e]||!1}show(){return this.svg.node()}}a.extend(ks.prototype,cs),a.extend(ks.prototype,ls),a.extend(ks.prototype,ds),a.extend(ks.prototype,ys),a.extend(ks.prototype,xs),a.extend(ks.prototype,es);let Ns=class{constructor(t,e={}){this.newick_string="",this.nodes=[],this.links=[],this.parsed_tags=[],this.partitions=[],this.branch_length_accessor=jo,this.branch_length=jo,this.logger=e.logger||console,this.selection_attribute_name="selected";var n=e.type||void 0,r=[],i=this;if(a.isString(n))n in Lo?r=Lo[n](t,e):i.logger.error("type "+n+" not in registry! Available types are "+a.keys(Lo));else if(a.isFunction(n))try{r=n(t,e)}catch(t){i.logger.error("Could not parse custom format!")}else"root"==t.name?r={json:t,error:null}:"string"!=typeof t?r=t:"application/xml"==t.contentType?r=Do(t):(this.newick_string=t,r=To(t,e));if(r.json){i.nodes=Rr(r.json);let t={};i.nodes.each(e=>{e.data.annotation&&(t[e.data.annotation]=!0)}),i.parsed_tags=Object.keys(t)}else i.nodes=[];return i.links=i.nodes.links(),this.hasBranchLengths()||(console.warn("Phylotree User Warning : NO BRANCH LENGTHS DETECTED, SETTING ALL LENGTHS TO 1"),this.setBranchLength(t=>1)),i}json(t){var e=0;this.traverse_and_compute(function(t){t.json_export_index=e++},t);var n=new Array(e);return e=0,this.traverse_and_compute(function(t){let r=a.clone(t);delete r.json_export_index,t.parent&&(r.parent=t.parent.json_export_index),t.children&&(r.children=a.map(t.children,function(t){return t.json_export_index})),n[e++]=r},t),this.traverse_and_compute(function(t){delete t.json_export_index},t),JSON.stringify(n)}traverse_and_compute(t,e,n,r){return(e="pre-order"==(e=e||"post-order")?function(e){Po(e,t,r)}:"in-order"==e?function(e){Ho(e,t,r)}:function(e){a.isUndefined(e)||Uo(e,t,r)})(n||this.nodes),this}get_parsed_tags(){return this.parsed_tags}update(t){this.nodes=t}render(t){return this.display=new ks(this,t),this.display}};function Ts(t){var e=t.branch_length_accessor;if(!e)throw"A non-null branch lengths accessor function is required for this operation";var n=0;function r(t){for(var e=0;e<t.children.length;e++)for(var n=0;n<t.children.length;n++)e!=n&&a.each(t.children[n].cot_path_to_leaves_below,function(r,i){t.children[e].cot_path_to_leaves_above&&(t.children[e].cot_path_to_leaves_above[i]=r+t.children[n].cot_computed_length)})}return t.traverse_and_compute(function(r){if(r.cot_computed_length=e(r),r.parent&&a.isUndefined(r.cot_computed_length))throw"Non-null branch lengths are required for this operation: missing branch length at node "+r.data.name;t.isLeafNode(r)?(r.cot_leaf_index=n++,r.cot_path_to_leaves_below={},r.cot_path_to_leaves_below[r.cot_leaf_index]=0,r.cot_path_to_leaves_above={}):(r.cot_path_to_leaves_below={},r.cot_path_to_leaves_above={})}),t.traverse_and_compute(function(t){t.parent&&a.each(t.cot_path_to_leaves_below,function(e,n){t.parent.cot_path_to_leaves_below[n]=e+t.cot_computed_length})}),r(t.getRootNode()),t.traverse_and_compute(function(e){e.parent&&(a.each(e.parent.cot_path_to_leaves_above,function(t,n){e.cot_path_to_leaves_above[n]=t+e.parent.cot_computed_length}),t.isLeafNode(e)||r(e))},"pre-order"),n}function As(t,e,n,r,i){var a=t.branch_length(e),o=!1;if(n||(r=e.data.rootToTip,i=0,o=!0),e.children)for(var s=0;s<e.children.length;s++)e.children[s]!=n?As(t,e.children[s],e,r,i):o=!0;e.data.rtta=e.data.rootToTip-r+i,o&&(r-=a,i+=a),e.parent&&o&&As(t,e.parent,e,r,i)}function zs(t){var e=t.reduce(function(t,e){return e[2]+t},0),n=t.reduce(function(t,e){return e[2]*e[0]+t},0),r=t.reduce(function(t,e){return e[2]*e[1]+t},0),i=n/e,a=r/e,o=0,s=0,l=0;t.forEach(function(t){var e=t[0]-i;s+=t[2]*e*e,o+=t[2]*e*t[1],l+=t[2]*(t[1]-a)*(t[1]-a)});var u=(r-n*(o/=s))/e,c=0;return t.forEach(function(t){var e=t[1]-u-o*t[0];c+=t[2]*e*e}),{intercept:u,slope:o,r2:1-c/l,"var (intercept)":Math.sqrt((1+n*n/(e*s))/e),"var (slope)":Math.sqrt(1/s)}}function Ss(t){var e=t.branch_length_accessor,n=0;t.traverse_and_compute(r=>{if(r.parent&&(r.data._computed_length=e(r),!a.isNumber(r.data._computed_length)))throw"rootToTip cannot be run on trees with missing branch lengths";t.isLeafNode(r)&&(r.data.leaf_index=n++),"r2t"in r.data&&delete r.data.r2t}),t.traverse_and_compute(e=>{e.parent&&("r2t"in e.parent.data||(e.parent.data.r2t={}),t.isLeafNode(e)?e.parent.data.r2t[e.data.leaf_index]=e.data._computed_length:(a.each(e.data.r2t,function(t,n){e.parent.data.r2t[n]=t+e.data._computed_length}),delete e.data.r2t),delete e.data._computed_length)});var r=t.getRootNode().data.r2t;return t.traverse_and_compute(e=>{t.isLeafNode(e)&&(e.data.rootToTip=r[e.data.leaf_index]||0,delete e.data.leaf_index)}),delete t.getRootNode().data.r2t,t}Ns.prototype.isLeafNode=Mo,Ns.prototype.selectAllDescendants=ko,Ns.prototype.mrca=function(t){var e;return t=t.map(function(t){return"string"==typeof t?t:t.data.name}),this.traverse_and_compute(function(n){n.children?n.parent?(n.data.mrca=a.union(...n.descendants().map(t=>t.data.mrca)),e||n.data.mrca.length!=t.length||(e=n)):e||(e=n):n.data.mrca=a.intersection([n.data.name],t)}),e},Ns.prototype.hasBranchLengths=function(){let t=this.branch_length;return!!t&&a.every(this.nodes.descendants(),function(e){return!e.parent||!a.isUndefined(t(e))})},Ns.prototype.getBranchLengths=function(){let t=this.branch_length;return a.map(this.nodes.descendants(),e=>t(e))},Ns.prototype.branchName=function(t){return arguments.length?(this.nodeLabel=t,this):this.nodeLabel},Ns.prototype.normalizeBranchLengths=function(t){let e=this.branch_length,n=a.map(this.nodes.descendants(),function(t){return e(t)?e(t):null});const r=a.max(n),i=a.min(n);return a.each(this.nodes.descendants(),t=>{let n=e(t);n&&e(t,function(t){return(t-i)/(r-i)}(n))}),this},Ns.prototype.scaleBranchLengths=function(t){let e=this.branch_length;return a.each(this.nodes.descendants(),n=>{let r=e(n);r&&e(n,t(r))}),this},Ns.prototype.getNewick=Ao,Ns.prototype.resortChildren=function(t,e,n){return this.nodes.sum(function(t){return t.value}).sort(t),this.display&&(this.display.update_layout(this.nodes),this.display.update()),this},Ns.prototype.setBranchLength=function(t){return arguments.length?(this.branch_length_accessor=t||jo,this):this.branch_length_accessor},Ns.prototype.maxParsimony=function(t,e){const n=a.partial(function(t,e){if(e.mp=[[0,0],[!1,!1]],Mo(e))e.mp[1][0]=e.mp[1][1]=e[t]||!1,e.mp[0][0]=e.mp[1][0]?1:0,e.mp[0][1]=1-e.mp[0][0];else{e.children.forEach(n);var r=e.children.reduce(function(t,e){return e.mp[0][0]+t},0),i=e.children.reduce(function(t,e){return e.mp[0][1]+t},0);e[t]?(e.mp[0][0]=i+1,e.mp[1][0]=!0,e.mp[0][1]=i,e.mp[1][1]=!0):(r<i+1?(e.mp[0][0]=r,e.mp[1][0]=!1):(e.mp[0][0]=i+1,e.mp[1][0]=!0),i<r+1?(e.mp[0][1]=i,e.mp[1][1]=!0):(e.mp[0][1]=r+1,e.mp[1][1]=!1))}},e);n(this.nodes),this.nodes.each(t=>{t.parent?t.mp=t.mp[1][t.parent.mp?1:0]:t.mp=t.mp[1][t.mp[0][0]<t.mp[0][1]?0:1]}),this.display.modifySelection((t,n)=>Mo(t.target)?t.target[e]:t.target.mp)},Ns.prototype.getTipLengths=function(){let t=this.getTips(),e=a.map(t,t=>({name:t.data.name,length:parseFloat(t.data.attribute)}));return e=a.sortBy(e,t=>-t.length),e},Ns.prototype.leftChildRightSibling=Oo,a.extend(Ns.prototype,No),a.extend(Ns.prototype,Fo),a.extend(Ns.prototype,Co);const Es=Pi("%Y%m%d"),Cs=/([0-9]{4}).?([0-9]{2}).?([0-9]{2})$/g,$s=function(t){if(Mo(t)&&"name"in t){let e=Cs.exec(t.name);if(e)return e[1]+e[2]+e[3]}return null};function Ds(t,e){let n=[];for(let r of o.range(e.length))if(r!=t){let i=[];for(let n of o.range(e[r].length))n!=t&&i.push(e[r][n]);n.push(i)}return n}t.centerOfTree=function(t,e){e=e||2;var n=Ts(t),r=Number.MAX_VALUE,i=0,o=null;return 2==e?t.traverse_and_compute(function(t){if(t.parent){var e=0,s=0,l=0,u=0,c=0;a.each(t.cot_path_to_leaves_below,function(t){e+=t,s+=t*t,c++}),a.each(t.cot_path_to_leaves_above,function(t){l+=t,u+=t*t});var h=n-c,f=(l-e+t.cot_computed_length*h)/n;f<0?f=0:f>t.cot_computed_length&&(f=t.cot_computed_length);var d=u+s+2*(l*(t.cot_computed_length-f)+e*f)+c*f*f+(t.cot_computed_length-f)*(t.cot_computed_length-f)*h;d<r&&(o=t,i=f/t.cot_computed_length,r=d),delete t.cot_computed_length,delete t.cot_path_to_leaves_below,delete t.cot_path_to_leaves_above,delete t.cot_leaf_index}}):t.traverse_and_compute(function(t){if(t.parent)for(var n=t.cot_computed_length>0?.05*t.cot_computed_length:.1,s=0;s<t.cot_computed_length;){var l=0;a.each(t.cot_path_to_leaves_below,function(t){l+=Math.pow(t+s,e)}),a.each(t.cot_path_to_leaves_above,function(n){l+=Math.pow(n+(t.cot_computed_length-s),e)}),l<r&&(o=t,i=s/t.cot_computed_length,r=l),s+=n}}),{location:o,breakpoint:i,distance:r}},t.clusterPicker=function(t,e,n,r,i){r=r||t.getRootNode(),i=a.isNumber(i)?i:1;let o=t.branch_length;t.traverse_and_compute(function(t){if(t.parent){if(t._computed_length=o(t),!a.isNumber(t._computed_length))throw"clusterPicker cannot be run on trees with missing branch lengths";t.max_path_length=0}}),t.traverse_and_compute(function(t){t.parent&&(t.parent.max_path_length=Math.max(t.parent.max_path_length,t.max_path_length+t._computed_length))});var s=[];return t.traverse_and_compute(a.noop,"pre-order",r,function(r){if(!t.isLeafNode(r)){var o=a.isString(r.data.bootstrap_values)?+r.data.bootstrap_values:i;if(o>=e){var l=a.reduce(r.children,function(t,e){return e.max_path_length+e._computed_length+t},0);if(l<=n)return s.push({root:r,diameter:l,bootstrap:o}),!0}}return!1}),t.traverse_and_compute(function(t){t.parent&&(delete t._computed_length,delete t.max_path_length)},"post-order",r),a.each(s,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),s},t.computeMidpoint=function(t){if(!t.hasBranchLengths())throw"Center of tree calculation cannot be performed on trees that do not have fully specified branch lengths";var e=t.branch_length;t.traverse_and_compute(function(n){if(n.parent){var r,i=e(n);t.isLeafNode(n)?(r=n,n.max_path=0,n.max_path_terminus=n):(i+=n.max_path,r=n.max_path_terminus),(!n.parent.max_path||n.parent.max_path<i)&&(n.parent.max_path=i,n.parent.max_path_terminus=r)}});var n=t.getRootNode(),r=0;if(n.children.forEach(function(t){if(t.max_path_terminus!==n.max_path_terminus){var i=t.max_path+e(t);i>=r&&(r=i)}}),n.max_path>r){r=.5*(r+n.max_path);for(var i=n.max_path_terminus;;){var a=e(i);if(!(a<=r))return{location:i,breakpoint:r/a};r-=a,i=i.parent}}return{location:n,breakpoint:0}},t.extract_dates=function(t,e,n=Es){return e=e||$s,t.traverse_and_compute(function(t){var r=e(t);if(r)try{t.data.date_value=n(r);var i=t.data.date_value.getFullYear(),a=new Date(i,0,1),o=new Date(i+1,0,1);return void(t.data.decimal_date_value=i+(t.data.date_value-a)/(o-a))}catch(t){}t.data.date_value=null,t.data.decimal_date_value=null}),t},t.fitRootToTip=function(t){var e=[],n=0,r=0;!function(t){t.traverse_and_compute(function(e){t.isLeafNode(e)&&(e.data.copy_number=1)})}(t),Ss(t),t.traverse_and_compute(function(n){t.isLeafNode(n)&&!a.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});let i=zs(e);return t.traverse_and_compute(function(o){if(t.isLeafNode(o)&&!a.isNull(o.data.decimal_date_value)){As(t,o,null,0,0),e=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&!a.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});var s=zs(e),l=s.r2;l>n&&(n=l,r=o,i=s)}}),{root:r,fit:i}},t.getDistanceMatrix=function(t){let e=o.keys(t)[0],n=t[e].length;return o.mapValues(t,e=>o.map(t,t=>o.sum(o.map(o.range(n),n=>e[n]!=t[n]&&"-"!=e[n]&&"-"!=t[n]))))},t.getNewick=Ao,t.inOrder=Ho,t.leftChildRightSibling=Oo,t.loadAnnotations=So,t.neighborJoining=function t(e,n,r){if(n<=2){let t=new Ns(""),n=t.getNodes(),i=e[0][1]/2,a=t.createNode(r[0],[null,[i]]),o=t.createNode(r[1],[null,[i]]);return t.addChild(n,a),t.addChild(n,o),t}{let a=n,s=(i=e,o.map(i,o.sum)),l=function(t,e,n){let r=o.chunk(o.fill(Array(n*n),0),n);for(let i of o.range(n))for(let a of o.range(o.parseInt(i)+1,n))r[i][a]=(n-2)*t[i][a]-e[i]-e[a],r[a][i]=r[i][a];return r}(e,s,a),[u,c,h]=function(t,e){let n=-1,r=-1,i=1/0;for(let a of o.range(e))for(let s of o.range(n,e))t[a][s]<i&&(n=a,r=s,i=t[n][r]);return[n,r,i]}(l,a),f=function(t,e){let n=o.chunk(Array(e*e),e);for(let r of o.range(e))for(let i of o.range(parseInt(r)+1,e))n[r][i]=(t[r]-t[i])/(e-2),n[i][r]=n[r][i];return n}(s,a),d=(e[u][c]+f[u][c])/2,p=(e[u][c]-f[u][c])/2,_=o.concat(0,o.filter(o.map(o.range(n),t=>{if(t!=u&&t!=c)return.5*(e[t][u]+e[t][c]-e[u][c])}),o.isNumber)),g=r[u],m=r[c],v="InternalNode0",y=o.filter(r,t=>o.includes(t,"InternalNode"));if(y.length){let t=o.max(o.map(y,t=>o.split(t,"InternalNode")[1]));v="InternalNode"+ ++t}r.unshift(v),e=Ds(o.max([u,c]),e),(e=Ds(o.min([u,c]),e)).unshift(_),o.each(o.range(1,n-1),t=>e[t].unshift(_[t])),o.remove(r,t=>t==g||t==m);let b=t(e,a-1,r),w=b.createNode(g,[null,[d]]),x=b.createNode(m,[null,[p]]);if(b.getNodeByName(v)){let t=b.getNodeByName(v);b.addChild(t,w),b.addChild(t,x)}else{let t=b.createNode(v,[null,[0]]);b.addChild(b.getNodes(),t),b.addChild(t,w),b.addChild(t,x)}return b}var i},t.newickParser=To,t.pairwise_distances=Ts,t.parseAnnotations=zo,t.parseFasta=function(t){let e=o.split(t,"\n");return o.chain(e).map((t,e)=>t.startsWith(">")?e:-1).filter(t=>-1!=t).map((t,n,r)=>o.slice(e,r[n],r[n+1])).keyBy(t=>o.trim(t[0],">")).mapValues(t=>o.tail(t).join("")).value()},t.phylopart=function(t,e,n,r,i){r=a.isNumber(r)?r:1;var o=Ts(t),s=t.getRootNode().children[0],l=Number.MAX_VALUE,u=Number.MAX_VALUE;if(!(n>0&&n<1))throw"Invalid percentile threshold in perform_phylopart";t.traverse_and_compute(function(e){t.isLeafNode(e)&&(e.cot_computed_length<l?(l<u&&(u=l),l=e.cot_computed_length):e.cot_computed_length<u&&(u=e.cot_computed_length))}),l+=u;var c=a.reduce(s.cot_path_to_leaves_below,function(t,e){return e>t?e:t},0)+a.reduce(s.cot_path_to_leaves_above,function(t,e){return e>t?e:t},0)+s.cot_computed_length-l;a.isUndefined(i)&&(i=Math.min(.001,c/100));var h=1+(c/i|0);h>500&&(i=c/(h=500));var f=t.getRootNode();f.paths_to_leaves=new Array(o),a.each(f.children,function(t){a.each(f.cot_path_to_leaves_below,function(e,n){f.paths_to_leaves[n]=e+t.cot_computed_length})}),t.traverse_and_compute(function(e){if(!t.isLeafNode(e)){e.histogram=new Array(h);for(var n=0;n<h;n++)e.histogram[n]=0;if(e.parent){var r=0;e.paths_to_leaves=[],a.each(e.cot_path_to_leaves_below,function(t,n){e.paths_to_leaves[r++]=t})}}delete e.cot_path_to_leaves_above,delete e.cot_path_to_leaves_below}),t.traverse_and_compute(function(e){if(!t.isLeafNode(e)){for(var n=0;n<e.paths_to_leaves.length;n++)for(var r=n+1;r<e.paths_to_leaves.length;r++){var a=e.paths_to_leaves[n]+e.paths_to_leaves[r];e.histogram[(a-l)/i|0]++}e.leaf_count=e.paths_to_leaves.length,delete e.paths_to_leaves}});for(var d=(o-1)*o/2*n,p=0;p<h-1&&d>f.histogram[p];p++)d-=f.histogram[p];var _=l+(p+(f.histogram[p]-d)/f.histogram[p])*i,g=[];return t.traverse_and_compute(a.noop,"pre-order",null,function(n){if(!t.isLeafNode(n)){var o=a.isString(n.data.bootstrap_values)?+n.data.bootstrap_values:r;if(o>=e){for(var s=n.leaf_count*(n.leaf_count-1)*.25,u=0;u<h-1&&s>n.histogram[u];u++)s-=n.histogram[u];var c=l+(u+(n.histogram[u]-s)/n.histogram[u])*i;if(c<=_)return g.push({root:n,median:c,bootstrap:o}),!0}}return!1}),t.traverse_and_compute(function(e){t.isLeafNode(e)||"histogram"in e&&(delete e.histogram,delete e.leaf_count)}),a.each(g,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),g},t.phylotree=Ns,t.postOrder=Uo,t.preOrder=Po,t.rootToTip=Ss,t.sackin=function(t){let e=t.getTips(),n=a.map(e,t=>t.depth);return a.reduce(n,function(t,e){return t+e},0)},Object.defineProperty(t,"__esModule",{value:!0})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("underscore"),require("string_decoder"),require("events"),require("timers"),require("lodash")):"function"==typeof define&&define.amd?define(["exports","underscore","string_decoder","events","timers","lodash"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).phylotree=t.phylotree||{},t._,t.require$$1,t.require$$1$1,t.require$$4,t._$1)}(this,function(t,e,n,r,i,o){"use strict";function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function a(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var u=a(e),l=s(n),c=s(r),h=s(i),p=a(o);function f(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function d(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function m(t){let e,n,r;function i(t,r,i=0,o=t.length){if(i<o){if(0!==e(r,r))return o;do{const e=i+o>>>1;n(t[e],r)<0?i=e+1:o=e}while(i<o)}return i}return 2!==t.length?(e=f,n=(e,n)=>f(t(e),n),r=(e,n)=>t(e)-n):(e=t===f||t===d?t:g,n=t,r=t),{left:i,center:function(t,e,n=0,o=t.length){const s=i(t,e,n,o-1);return s>n&&r(t[s-1],e)>-r(t[s],e)?s-1:s},right:function(t,r,i=0,o=t.length){if(i<o){if(0!==e(r,r))return o;do{const e=i+o>>>1;n(t[e],r)<=0?i=e+1:o=e}while(i<o)}return i}}}function g(){return 0}const y=m(f).right;m(function(t){return null===t?NaN:+t}).center;var _=y;const v=Math.sqrt(50),b=Math.sqrt(10),w=Math.sqrt(2);function x(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),s=o>=v?10:o>=b?5:o>=w?2:1;let a,u,l;return i<0?(l=Math.pow(10,-i)/s,a=Math.round(t*l),u=Math.round(e*l),a/l<t&&++a,u/l>e&&--u,l=-l):(l=Math.pow(10,i)*s,a=Math.round(t/l),u=Math.round(e/l),a*l<t&&++a,u*l>e&&--u),u<a&&.5<=n&&n<2?x(t,e,2*n):[a,u,l]}function T(t,e,n){return x(t=+t,e=+e,n=+n)[2]}function E(t){return t}var N=1e-6;function D(t){return"translate("+t+",0)"}function O(t){return"translate(0,"+t+")"}function A(t){return e=>+t(e)}function I(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function C(){return!this.__axis}function M(t,e){var n=[],r=null,i=null,o=6,s=6,a=3,u="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,l=1===t||4===t?-1:1,c=4===t||2===t?"x":"y",h=1===t||3===t?D:O;function p(p){var f=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,d=null==i?e.tickFormat?e.tickFormat.apply(e,n):E:i,m=Math.max(o,0)+a,g=e.range(),y=+g[0]+u,_=+g[g.length-1]+u,v=(e.bandwidth?I:A)(e.copy(),u),b=p.selection?p.selection():p,w=b.selectAll(".domain").data([null]),x=b.selectAll(".tick").data(f,e).order(),T=x.exit(),D=x.enter().append("g").attr("class","tick"),O=x.select("line"),M=x.select("text");w=w.merge(w.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),x=x.merge(D),O=O.merge(D.append("line").attr("stroke","currentColor").attr(c+"2",l*o)),M=M.merge(D.append("text").attr("fill","currentColor").attr(c,l*m).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),p!==b&&(w=w.transition(p),x=x.transition(p),O=O.transition(p),M=M.transition(p),T=T.transition(p).attr("opacity",N).attr("transform",function(t){return isFinite(t=v(t))?h(t+u):this.getAttribute("transform")}),D.attr("opacity",N).attr("transform",function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:v(t))+u)})),T.remove(),w.attr("d",4===t||2===t?s?"M"+l*s+","+y+"H"+u+"V"+_+"H"+l*s:"M"+u+","+y+"V"+_:s?"M"+y+","+l*s+"V"+u+"H"+_+"V"+l*s:"M"+y+","+u+"H"+_),x.attr("opacity",1).attr("transform",function(t){return h(v(t)+u)}),O.attr(c+"2",l*o),M.attr(c,l*m).text(d),b.filter(C).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),b.each(function(){this.__axis=v})}return p.scale=function(t){return arguments.length?(e=t,p):e},p.ticks=function(){return n=Array.from(arguments),p},p.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),p):n.slice()},p.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),p):r&&r.slice()},p.tickFormat=function(t){return arguments.length?(i=t,p):i},p.tickSize=function(t){return arguments.length?(o=s=+t,p):o},p.tickSizeInner=function(t){return arguments.length?(o=+t,p):o},p.tickSizeOuter=function(t){return arguments.length?(s=+t,p):s},p.tickPadding=function(t){return arguments.length?(a=+t,p):a},p.offset=function(t){return arguments.length?(u=+t,p):u},p}var P={value:()=>{}};function S(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new k(r)}function k(t){this._=t}function F(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function L(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=P,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}k.prototype=S.prototype={constructor:k,on:function(t,e){var n,r,i=this._,o=(r=i,(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&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),s=-1,a=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<a;)if(n=(t=o[s]).type)i[n]=L(i[n],t.name,e);else if(null==e)for(n in i)i[n]=L(i[n],t.name,null);return this}for(;++s<a;)if((n=(t=o[s]).type)&&(n=F(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new k(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var j="http://www.w3.org/1999/xhtml",z={svg:"http://www.w3.org/2000/svg",xhtml:j,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function U(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 R(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===j&&e.documentElement.namespaceURI===j?e.createElement(t):e.createElementNS(n,t)}}function B(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function V(t){var e=U(t);return(e.local?B:R)(e)}function $(){}function Y(t){return null==t?$:function(){return this.querySelector(t)}}function q(){return[]}function H(t){return null==t?q:function(){return this.querySelectorAll(t)}}function X(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function G(t){return function(){return this.matches(t)}}function W(t){return function(e){return e.matches(t)}}var K=Array.prototype.find;function Q(){return this.firstElementChild}var Z=Array.prototype.filter;function J(){return Array.from(this.children)}function tt(t){return new Array(t.length)}function et(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function nt(t,e,n,r,i,o){for(var s,a=0,u=e.length,l=o.length;a<l;++a)(s=e[a])?(s.__data__=o[a],r[a]=s):n[a]=new et(t,o[a]);for(;a<u;++a)(s=e[a])&&(i[a]=s)}function rt(t,e,n,r,i,o,s){var a,u,l,c=new Map,h=e.length,p=o.length,f=new Array(h);for(a=0;a<h;++a)(u=e[a])&&(f[a]=l=s.call(u,u.__data__,a,e)+"",c.has(l)?i[a]=u:c.set(l,u));for(a=0;a<p;++a)l=s.call(t,o[a],a,o)+"",(u=c.get(l))?(r[a]=u,u.__data__=o[a],c.delete(l)):n[a]=new et(t,o[a]);for(a=0;a<h;++a)(u=e[a])&&c.get(f[a])===u&&(i[a]=u)}function it(t){return t.__data__}function ot(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function st(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function at(t){return function(){this.removeAttribute(t)}}function ut(t){return function(){this.removeAttributeNS(t.space,t.local)}}function lt(t,e){return function(){this.setAttribute(t,e)}}function ct(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ht(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function pt(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 ft(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function dt(t){return function(){this.style.removeProperty(t)}}function mt(t,e,n){return function(){this.style.setProperty(t,e,n)}}function gt(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function yt(t,e){return t.style.getPropertyValue(e)||ft(t).getComputedStyle(t,null).getPropertyValue(e)}function _t(t){return function(){delete this[t]}}function vt(t,e){return function(){this[t]=e}}function bt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function wt(t){return t.trim().split(/^|\s+/)}function xt(t){return t.classList||new Tt(t)}function Tt(t){this._node=t,this._names=wt(t.getAttribute("class")||"")}function Et(t,e){for(var n=xt(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function Nt(t,e){for(var n=xt(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function Dt(t){return function(){Et(this,t)}}function Ot(t){return function(){Nt(this,t)}}function At(t,e){return function(){(e.apply(this,arguments)?Et:Nt)(this,t)}}function It(){this.textContent=""}function Ct(t){return function(){this.textContent=t}}function Mt(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Pt(){this.innerHTML=""}function St(t){return function(){this.innerHTML=t}}function kt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function Ft(){this.nextSibling&&this.parentNode.appendChild(this)}function Lt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function jt(){return null}function zt(){var t=this.parentNode;t&&t.removeChild(this)}function Ut(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Rt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Bt(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r<o;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function Vt(t,e,n){return function(){var r,i=this.__on,o=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var s=0,a=i.length;s<a;++s)if((r=i[s]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),void(r.value=e);this.addEventListener(t.type,o,n),r={type:t.type,name:t.name,value:e,listener:o,options:n},i?i.push(r):this.__on=[r]}}function $t(t,e,n){var r=ft(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Yt(t,e){return function(){return $t(this,t,e)}}function qt(t,e){return function(){return $t(this,t,e.apply(this,arguments))}}et.prototype={constructor:et,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)}},Tt.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 Ht=[null];function Xt(t,e){this._groups=t,this._parents=e}function Gt(){return new Xt([[document.documentElement]],Ht)}function Wt(t){return"string"==typeof t?new Xt([[document.querySelector(t)]],[document.documentElement]):new Xt([[t]],Ht)}function Kt(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 r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}Xt.prototype=Gt.prototype={constructor:Xt,select:function(t){"function"!=typeof t&&(t=Y(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s,a=e[i],u=a.length,l=r[i]=new Array(u),c=0;c<u;++c)(o=a[c])&&(s=t.call(o,o.__data__,c,a))&&("__data__"in o&&(s.__data__=o.__data__),l[c]=s);return new Xt(r,this._parents)},selectAll:function(t){t="function"==typeof t?X(t):H(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var s,a=e[o],u=a.length,l=0;l<u;++l)(s=a[l])&&(r.push(t.call(s,s.__data__,l,a)),i.push(s));return new Xt(r,i)},selectChild:function(t){return this.select(null==t?Q:function(t){return function(){return K.call(this.children,t)}}("function"==typeof t?t:W(t)))},selectChildren:function(t){return this.selectAll(null==t?J:function(t){return function(){return Z.call(this.children,t)}}("function"==typeof t?t:W(t)))},filter:function(t){"function"!=typeof t&&(t=G(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s=e[i],a=s.length,u=r[i]=[],l=0;l<a;++l)(o=s[l])&&t.call(o,o.__data__,l,s)&&u.push(o);return new Xt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,it);var n=e?rt:nt,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var o=i.length,s=new Array(o),a=new Array(o),u=new Array(o),l=0;l<o;++l){var c=r[l],h=i[l],p=h.length,f=ot(t.call(c,c&&c.__data__,l,r)),d=f.length,m=a[l]=new Array(d),g=s[l]=new Array(d);n(c,h,m,g,u[l]=new Array(p),f,e);for(var y,_,v=0,b=0;v<d;++v)if(y=m[v]){for(v>=b&&(b=v+1);!(_=g[b])&&++b<d;);y._next=_||null}}return(s=new Xt(s,r))._enter=a,s._exit=u,s},enter:function(){return new Xt(this._enter||this._groups.map(tt),this._parents)},exit:function(){return new Xt(this._exit||this._groups.map(tt),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,o=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?o.remove():n(o),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,o=r.length,s=Math.min(i,o),a=new Array(i),u=0;u<s;++u)for(var l,c=n[u],h=r[u],p=c.length,f=a[u]=new Array(p),d=0;d<p;++d)(l=c[d]||h[d])&&(f[d]=l);for(;u<i;++u)a[u]=n[u];return new Xt(a,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],o=i.length-1,s=i[o];--o>=0;)(r=i[o])&&(s&&4^r.compareDocumentPosition(s)&&s.parentNode.insertBefore(r,s),s=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=st);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var s,a=n[o],u=a.length,l=i[o]=new Array(u),c=0;c<u;++c)(s=a[c])&&(l[c]=s);l.sort(e)}return new Xt(i,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 r=t[e],i=0,o=r.length;i<o;++i){var s=r[i];if(s)return s}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,r=e.length;n<r;++n)for(var i,o=e[n],s=0,a=o.length;s<a;++s)(i=o[s])&&t.call(i,i.__data__,s,o);return this},attr:function(t,e){var n=U(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?ut:at:"function"==typeof e?n.local?pt:ht:n.local?ct:lt)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?dt:"function"==typeof e?gt:mt)(t,e,null==n?"":n)):yt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?_t:"function"==typeof e?bt:vt)(t,e)):this.node()[t]},classed:function(t,e){var n=wt(t+"");if(arguments.length<2){for(var r=xt(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?At:e?Dt:Ot)(n,e))},text:function(t){return arguments.length?this.each(null==t?It:("function"==typeof t?Mt:Ct)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Pt:("function"==typeof t?kt:St)(t)):this.node().innerHTML},raise:function(){return this.each(Ft)},lower:function(){return this.each(Lt)},append:function(t){var e="function"==typeof t?t:V(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var n="function"==typeof t?t:V(t),r=null==e?jt:"function"==typeof e?e:Y(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(zt)},clone:function(t){return this.select(t?Rt:Ut)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,o=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+""),s=o.length;if(!(arguments.length<2)){for(a=e?Vt:Bt,r=0;r<s;++r)this.each(a(o[r],e,n));return this}var a=this.node().__on;if(a)for(var u,l=0,c=a.length;l<c;++l)for(r=0,u=a[l];r<s;++r)if((i=o[r]).type===u.type&&i.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?qt:Yt)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],o=0,s=i.length;o<s;++o)(r=i[o])&&(yield r)}};const Qt={capture:!0,passive:!1};function Zt(t){t.preventDefault(),t.stopImmediatePropagation()}function Jt(t){var e=t.document.documentElement,n=Wt(t).on("dragstart.drag",Zt,Qt);"onselectstart"in e?n.on("selectstart.drag",Zt,Qt):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function te(t,e){var n=t.document.documentElement,r=Wt(t).on("dragstart.drag",null);e&&(r.on("click.drag",Zt,Qt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function ee(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function ne(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function re(){}var ie=.7,oe=1/ie,se="\\s*([+-]?\\d+)\\s*",ae="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ue="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",le=/^#([0-9a-f]{3,8})$/,ce=new RegExp(`^rgb\\(${se},${se},${se}\\)$`),he=new RegExp(`^rgb\\(${ue},${ue},${ue}\\)$`),pe=new RegExp(`^rgba\\(${se},${se},${se},${ae}\\)$`),fe=new RegExp(`^rgba\\(${ue},${ue},${ue},${ae}\\)$`),de=new RegExp(`^hsl\\(${ae},${ue},${ue}\\)$`),me=new RegExp(`^hsla\\(${ae},${ue},${ue},${ae}\\)$`),ge={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 ye(){return this.rgb().formatHex()}function _e(){return this.rgb().formatRgb()}function ve(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=le.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?be(e):3===n?new Te(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?we(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?we(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=ce.exec(t))?new Te(e[1],e[2],e[3],1):(e=he.exec(t))?new Te(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=pe.exec(t))?we(e[1],e[2],e[3],e[4]):(e=fe.exec(t))?we(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=de.exec(t))?Ie(e[1],e[2]/100,e[3]/100,1):(e=me.exec(t))?Ie(e[1],e[2]/100,e[3]/100,e[4]):ge.hasOwnProperty(t)?be(ge[t]):"transparent"===t?new Te(NaN,NaN,NaN,0):null}function be(t){return new Te(t>>16&255,t>>8&255,255&t,1)}function we(t,e,n,r){return r<=0&&(t=e=n=NaN),new Te(t,e,n,r)}function xe(t,e,n,r){return 1===arguments.length?((i=t)instanceof re||(i=ve(i)),i?new Te((i=i.rgb()).r,i.g,i.b,i.opacity):new Te):new Te(t,e,n,null==r?1:r);var i}function Te(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Ee(){return`#${Ae(this.r)}${Ae(this.g)}${Ae(this.b)}`}function Ne(){const t=De(this.opacity);return`${1===t?"rgb(":"rgba("}${Oe(this.r)}, ${Oe(this.g)}, ${Oe(this.b)}${1===t?")":`, ${t})`}`}function De(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Oe(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Ae(t){return((t=Oe(t))<16?"0":"")+t.toString(16)}function Ie(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Me(t,e,n,r)}function Ce(t){if(t instanceof Me)return new Me(t.h,t.s,t.l,t.opacity);if(t instanceof re||(t=ve(t)),!t)return new Me;if(t instanceof Me)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),s=NaN,a=o-i,u=(o+i)/2;return a?(s=e===o?(n-r)/a+6*(n<r):n===o?(r-e)/a+2:(e-n)/a+4,a/=u<.5?o+i:2-o-i,s*=60):a=u>0&&u<1?0:s,new Me(s,a,u,t.opacity)}function Me(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Pe(t){return(t=(t||0)%360)<0?t+360:t}function Se(t){return Math.max(0,Math.min(1,t||0))}function ke(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}ee(re,ve,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:ye,formatHex:ye,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Ce(this).formatHsl()},formatRgb:_e,toString:_e}),ee(Te,xe,ne(re,{brighter(t){return t=null==t?oe:Math.pow(oe,t),new Te(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?ie:Math.pow(ie,t),new Te(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Te(Oe(this.r),Oe(this.g),Oe(this.b),De(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:Ee,formatHex:Ee,formatHex8:function(){return`#${Ae(this.r)}${Ae(this.g)}${Ae(this.b)}${Ae(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Ne,toString:Ne})),ee(Me,function(t,e,n,r){return 1===arguments.length?Ce(t):new Me(t,e,n,null==r?1:r)},ne(re,{brighter(t){return t=null==t?oe:Math.pow(oe,t),new Me(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?ie:Math.pow(ie,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,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Te(ke(t>=240?t-240:t+120,i,r),ke(t,i,r),ke(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Me(Pe(this.h),Se(this.s),Se(this.l),De(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=De(this.opacity);return`${1===t?"hsl(":"hsla("}${Pe(this.h)}, ${100*Se(this.s)}%, ${100*Se(this.l)}%${1===t?")":`, ${t})`}`}}));var Fe=t=>()=>t;function Le(t){return 1===(t=+t)?je: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(r){return Math.pow(t+r*e,n)}}(e,n,t):Fe(isNaN(e)?n:e)}}function je(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Fe(isNaN(t)?e:t)}var ze=function t(e){var n=Le(e);function r(t,e){var r=n((t=xe(t)).r,(e=xe(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),s=je(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=s(e),t+""}}return r.gamma=t,r}(1);function Ue(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(o){for(n=0;n<r;++n)i[n]=t[n]*(1-o)+e[n]*o;return i}}function Re(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,o=new Array(i),s=new Array(r);for(n=0;n<i;++n)o[n]=Xe(t[n],e[n]);for(;n<r;++n)s[n]=e[n];return function(t){for(n=0;n<i;++n)s[n]=o[n](t);return s}}function Be(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Ve(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function $e(t,e){var n,r={},i={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?r[n]=Xe(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var Ye=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,qe=new RegExp(Ye.source,"g");function He(t,e){var n,r,i,o=Ye.lastIndex=qe.lastIndex=0,s=-1,a=[],u=[];for(t+="",e+="";(n=Ye.exec(t))&&(r=qe.exec(e));)(i=r.index)>o&&(i=e.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,u.push({i:s,x:Ve(n,r)})),o=qe.lastIndex;return o<e.length&&(i=e.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,r=0;r<e;++r)a[(n=u[r]).i]=n.x(t);return a.join("")})}function Xe(t,e){var n,r=typeof e;return null==e||"boolean"===r?Fe(e):("number"===r?Ve:"string"===r?(n=ve(e))?(e=n,ze):He:e instanceof ve?ze:e instanceof Date?Be:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?Ue:Array.isArray(e)?Re:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?$e:Ve)(t,e)}function Ge(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var We,Ke=180/Math.PI,Qe={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ze(t,e,n,r,i,o){var s,a,u;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,u/=a),t*r<e*n&&(t=-t,e=-e,u=-u,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*Ke,skewX:Math.atan(u)*Ke,scaleX:s,scaleY:a}}function Je(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(o,s){var a=[],u=[];return o=t(o),s=t(s),function(t,r,i,o,s,a){if(t!==i||r!==o){var u=s.push("translate(",null,e,null,n);a.push({i:u-4,x:Ve(t,i)},{i:u-2,x:Ve(r,o)})}else(i||o)&&s.push("translate("+i+e+o+n)}(o.translateX,o.translateY,s.translateX,s.translateY,a,u),function(t,e,n,o){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Ve(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,s.rotate,a,u),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Ve(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,s.skewX,a,u),function(t,e,n,r,o,s){if(t!==n||e!==r){var a=o.push(i(o)+"scale(",null,",",null,")");s.push({i:a-4,x:Ve(t,n)},{i:a-2,x:Ve(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,s.scaleX,s.scaleY,a,u),o=s=null,function(t){for(var e,n=-1,r=u.length;++n<r;)a[(e=u[n]).i]=e.x(t);return a.join("")}}}var tn=Je(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Qe:Ze(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),en=Je(function(t){return null==t?Qe:(We||(We=document.createElementNS("http://www.w3.org/2000/svg","g")),We.setAttribute("transform",t),(t=We.transform.baseVal.consolidate())?Ze((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Qe)},", ",")",")");function nn(t){return((t=Math.exp(t))+1/t)/2}var rn,on,sn=function t(e,n,r){function i(t,i){var o,s,a=t[0],u=t[1],l=t[2],c=i[0],h=i[1],p=i[2],f=c-a,d=h-u,m=f*f+d*d;if(m<1e-12)s=Math.log(p/l)/e,o=function(t){return[a+t*f,u+t*d,l*Math.exp(e*t*s)]};else{var g=Math.sqrt(m),y=(p*p-l*l+r*m)/(2*l*n*g),_=(p*p-l*l-r*m)/(2*p*n*g),v=Math.log(Math.sqrt(y*y+1)-y),b=Math.log(Math.sqrt(_*_+1)-_);s=(b-v)/e,o=function(t){var r=t*s,i=nn(v),o=l/(n*g)*(i*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*r+v)-function(t){return((t=Math.exp(t))-1/t)/2}(v));return[a+o*f,u+o*d,l*i/nn(e*r+v)]}}return o.duration=1e3*s*e/Math.SQRT2,o}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r)},i}(Math.SQRT2,2,4),an=0,un=0,ln=0,cn=0,hn=0,pn=0,fn="object"==typeof performance&&performance.now?performance:Date,dn="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function mn(){return hn||(dn(gn),hn=fn.now()+pn)}function gn(){hn=0}function yn(){this._call=this._time=this._next=null}function _n(t,e,n){var r=new yn;return r.restart(t,e,n),r}function vn(){hn=(cn=fn.now())+pn,an=un=0;try{!function(){mn(),++an;for(var t,e=rn;e;)(t=hn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--an}()}finally{an=0,function(){var t,e,n=rn,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:rn=e);on=t,wn(r)}(),hn=0}}function bn(){var t=fn.now(),e=t-cn;e>1e3&&(pn-=e,cn=t)}function wn(t){an||(un&&(un=clearTimeout(un)),t-hn>24?(t<1/0&&(un=setTimeout(vn,t-fn.now()-pn)),ln&&(ln=clearInterval(ln))):(ln||(cn=fn.now(),ln=setInterval(bn,1e3)),an=1,dn(vn)))}function xn(t,e,n){var r=new yn;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}yn.prototype=_n.prototype={constructor:yn,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?mn():+n)+(null==e?0:+e),this._next||on===this||(on?on._next=this:rn=this,on=this),this._call=t,this._time=n,wn()},stop:function(){this._call&&(this._call=null,this._time=1/0,wn())}};var Tn=S("start","end","cancel","interrupt"),En=[];function Nn(t,e,n,r,i,o){var s=t.__transition;if(s){if(n in s)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(t){n.state=1,n.timer.restart(s,n.delay,n.time),n.delay<=t&&s(t-n.delay)}function s(o){var l,c,h,p;if(1!==n.state)return u();for(l in i)if((p=i[l]).name===n.name){if(3===p.state)return xn(s);4===p.state?(p.state=6,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete i[l]):+l<e&&(p.state=6,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete i[l])}if(xn(function(){3===n.state&&(n.state=4,n.timer.restart(a,n.delay,n.time),a(o))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(h=n.tween.length),l=0,c=-1;l<h;++l)(p=n.tween[l].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=p);r.length=c+1}}function a(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=5,1),o=-1,s=r.length;++o<s;)r[o].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=_n(o,0,n.time)}(t,n,{name:e,index:r,group:i,on:Tn,tween:En,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function Dn(t,e){var n=An(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function On(t,e){var n=An(t,e);if(n.state>3)throw new Error("too late; already running");return n}function An(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function In(t,e){var n,r,i,o=t.__transition,s=!0;if(o){for(i in e=null==e?null:e+"",o)(n=o[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[i]):s=!1;s&&delete t.__transition}}function Cn(t,e){var n,r;return function(){var i=On(this,t),o=i.tween;if(o!==n)for(var s=0,a=(r=n=o).length;s<a;++s)if(r[s].name===e){(r=r.slice()).splice(s,1);break}i.tween=r}}function Mn(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var o=On(this,t),s=o.tween;if(s!==r){i=(r=s).slice();for(var a={name:e,value:n},u=0,l=i.length;u<l;++u)if(i[u].name===e){i[u]=a;break}u===l&&i.push(a)}o.tween=i}}function Pn(t,e,n){var r=t._id;return t.each(function(){var t=On(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return An(t,r).value[e]}}function Sn(t,e){var n;return("number"==typeof e?Ve:e instanceof ve?ze:(n=ve(e))?(e=n,ze):He)(t,e)}function kn(t){return function(){this.removeAttribute(t)}}function Fn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Ln(t,e,n){var r,i,o=n+"";return function(){var s=this.getAttribute(t);return s===o?null:s===r?i:i=e(r=s,n)}}function jn(t,e,n){var r,i,o=n+"";return function(){var s=this.getAttributeNS(t.space,t.local);return s===o?null:s===r?i:i=e(r=s,n)}}function zn(t,e,n){var r,i,o;return function(){var s,a,u=n(this);if(null!=u)return(s=this.getAttribute(t))===(a=u+"")?null:s===r&&a===i?o:(i=a,o=e(r=s,u));this.removeAttribute(t)}}function Un(t,e,n){var r,i,o;return function(){var s,a,u=n(this);if(null!=u)return(s=this.getAttributeNS(t.space,t.local))===(a=u+"")?null:s===r&&a===i?o:(i=a,o=e(r=s,u));this.removeAttributeNS(t.space,t.local)}}function Rn(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Bn(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Vn(t,e){return function(){Dn(this,t).delay=+e.apply(this,arguments)}}function $n(t,e){return e=+e,function(){Dn(this,t).delay=e}}function Yn(t,e){return function(){On(this,t).duration=+e.apply(this,arguments)}}function qn(t,e){return e=+e,function(){On(this,t).duration=e}}var Hn=Gt.prototype.constructor;function Xn(t){return function(){this.style.removeProperty(t)}}var Gn=0;function Wn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Kn(){return++Gn}var Qn=Gt.prototype;Wn.prototype={constructor:Wn,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Y(t));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var a,u,l=r[s],c=l.length,h=o[s]=new Array(c),p=0;p<c;++p)(a=l[p])&&(u=t.call(a,a.__data__,p,l))&&("__data__"in a&&(u.__data__=a.__data__),h[p]=u,Nn(h[p],e,n,p,h,An(a,n)));return new Wn(o,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=H(t));for(var r=this._groups,i=r.length,o=[],s=[],a=0;a<i;++a)for(var u,l=r[a],c=l.length,h=0;h<c;++h)if(u=l[h]){for(var p,f=t.call(u,u.__data__,h,l),d=An(u,n),m=0,g=f.length;m<g;++m)(p=f[m])&&Nn(p,e,n,m,f,d);o.push(f),s.push(u)}return new Wn(o,s,e,n)},selectChild:Qn.selectChild,selectChildren:Qn.selectChildren,filter:function(t){"function"!=typeof t&&(t=G(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s=e[i],a=s.length,u=r[i]=[],l=0;l<a;++l)(o=s[l])&&t.call(o,o.__data__,l,s)&&u.push(o);return new Wn(r,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,r=e.length,i=n.length,o=Math.min(r,i),s=new Array(r),a=0;a<o;++a)for(var u,l=e[a],c=n[a],h=l.length,p=s[a]=new Array(h),f=0;f<h;++f)(u=l[f]||c[f])&&(p[f]=u);for(;a<r;++a)s[a]=e[a];return new Wn(s,this._parents,this._name,this._id)},selection:function(){return new Hn(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Kn(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s,a=r[o],u=a.length,l=0;l<u;++l)if(s=a[l]){var c=An(s,e);Nn(s,t,n,l,a,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Wn(r,this._parents,t,n)},call:Qn.call,nodes:Qn.nodes,node:Qn.node,size:Qn.size,empty:Qn.empty,each:Qn.each,on:function(t,e){var n=this._id;return arguments.length<2?An(this.node(),n).on.on(t):this.each(function(t,e,n){var r,i,o=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)?Dn:On;return function(){var s=o(this,t),a=s.on;a!==r&&(i=(r=a).copy()).on(e,n),s.on=i}}(n,t,e))},attr:function(t,e){var n=U(t),r="transform"===n?en:Sn;return this.attrTween(t,"function"==typeof e?(n.local?Un:zn)(n,r,Pn(this,"attr."+t,e)):null==e?(n.local?Fn:kn)(n):(n.local?jn:Ln)(n,r,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 r=U(t);return this.tween(n,(r.local?Rn:Bn)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?tn:Sn;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var o=yt(this,t),s=(this.style.removeProperty(t),yt(this,t));return o===s?null:o===n&&s===r?i:i=e(n=o,r=s)}}(t,r)).on("end.style."+t,Xn(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,o;return function(){var s=yt(this,t),a=n(this),u=a+"";return null==a&&(this.style.removeProperty(t),u=a=yt(this,t)),s===u?null:s===r&&u===i?o:(i=u,o=e(r=s,a))}}(t,r,Pn(this,"style."+t,e))).each(function(t,e){var n,r,i,o,s="style."+e,a="end."+s;return function(){var u=On(this,t),l=u.on,c=null==u.value[s]?o||(o=Xn(e)):void 0;l===n&&i===c||(r=(n=l).copy()).on(a,i=c),u.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,o=n+"";return function(){var s=yt(this,t);return s===o?null:s===r?i:i=e(r=s,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,o,n)),r}return o._value=e,o}(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}}(Pn(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 r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(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 r,i=An(this.node(),n).tween,o=0,s=i.length;o<s;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==e?Cn:Mn)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Vn:$n)(e,t)):An(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Yn:qn)(e,t)):An(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(){On(this,t).ease=e}}(e,t)):An(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;On(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(o,s){var a={value:s},u={value:function(){0===--i&&o()}};n.each(function(){var n=On(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(a),e._.interrupt.push(a),e._.end.push(u)),n.on=e}),0===i&&o()})},[Symbol.iterator]:Qn[Symbol.iterator]};var Zn={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Jn(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}Gt.prototype.interrupt=function(t){return this.each(function(){In(this,t)})},Gt.prototype.transition=function(t){var e,n;t instanceof Wn?(e=t._id,t=t._name):(e=Kn(),(n=Zn).time=mn(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s,a=r[o],u=a.length,l=0;l<u;++l)(s=a[l])&&Nn(s,t,e,l,a,n||Jn(s,e));return new Wn(r,this._parents,t,e)};var tr=t=>()=>t;function er(t,{sourceEvent:e,target:n,selection:r,mode:i,dispatch:o}){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:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function nr(t){t.preventDefault(),t.stopImmediatePropagation()}var rr={name:"drag"},ir={name:"space"},or={name:"handle"},sr={name:"center"};const{abs:ar,max:ur,min:lr}=Math;function cr(t){return[+t[0],+t[1]]}function hr(t){return[cr(t[0]),cr(t[1])]}var pr={name:"x",handles:["w","e"].map(br),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]]}},fr={name:"y",handles:["n","s"].map(br),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]]}},dr={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(br),input:function(t){return null==t?null:hr(t)},output:function(t){return t}},mr={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"},gr={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},yr={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},_r={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},vr={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function br(t){return{type:t}}function wr(t){return!t.ctrlKey&&!t.button}function xr(){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 Tr(){return navigator.maxTouchPoints||"ontouchstart"in this}function Er(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function Nr(){return function(t){var e,n=xr,r=wr,i=Tr,o=!0,s=S("start","brush","end"),a=6;function u(e){var n=e.property("__brush",m).selectAll(".overlay").data([br("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",mr.overlay).merge(n).each(function(){var t=Er(this).extent;Wt(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([br("selection")]).enter().append("rect").attr("class","selection").attr("cursor",mr.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=e.selectAll(".handle").data(t.handles,function(t){return t.type});r.exit().remove(),r.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return mr[t.type]}),e.each(l).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",p).filter(i).on("touchstart.brush",p).on("touchmove.brush",f).on("touchend.brush touchcancel.brush",d).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function l(){var t=Wt(this),e=Er(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 c(t,e,n){var r=t.__brush.emitter;return!r||n&&r.clean?new h(t,e,n):r}function h(t,e,n){this.that=t,this.args=e,this.state=t.__brush,this.active=0,this.clean=n}function p(n){if((!e||n.touches)&&r.apply(this,arguments)){var i,s,a,u,h,p,f,d,m,g,y,_=this,v=n.target.__data__.type,b="selection"===(o&&n.metaKey?v="overlay":v)?rr:o&&n.altKey?sr:or,w=t===fr?null:_r[v],x=t===pr?null:vr[v],T=Er(_),E=T.extent,N=T.selection,D=E[0][0],O=E[0][1],A=E[1][0],I=E[1][1],C=0,M=0,P=w&&x&&o&&n.shiftKey,S=Array.from(n.touches||[n],t=>{const e=t.identifier;return(t=Kt(t,_)).point0=t.slice(),t.identifier=e,t});In(_);var k=c(_,arguments,!0).beforestart();if("overlay"===v){N&&(m=!0);const e=[S[0],S[1]||S[0]];T.selection=N=[[i=t===fr?D:lr(e[0][0],e[1][0]),a=t===pr?O:lr(e[0][1],e[1][1])],[h=t===fr?A:ur(e[0][0],e[1][0]),f=t===pr?I:ur(e[0][1],e[1][1])]],S.length>1&&U(n)}else i=N[0][0],a=N[0][1],h=N[1][0],f=N[1][1];s=i,u=a,p=h,d=f;var F=Wt(_).attr("pointer-events","none"),L=F.selectAll(".overlay").attr("cursor",mr[v]);if(n.touches)k.moved=z,k.ended=R;else{var j=Wt(n.view).on("mousemove.brush",z,!0).on("mouseup.brush",R,!0);o&&j.on("keydown.brush",B,!0).on("keyup.brush",V,!0),Jt(n.view)}l.call(_),k.start(n,b.name)}function z(t){for(const e of t.changedTouches||[t])for(const t of S)t.identifier===e.identifier&&(t.cur=Kt(e,_));if(P&&!g&&!y&&1===S.length){const t=S[0];ar(t.cur[0]-t[0])>ar(t.cur[1]-t[1])?y=!0:g=!0}for(const t of S)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);m=!0,nr(t),U(t)}function U(t){const e=S[0],n=e.point0;var r;switch(C=e[0]-n[0],M=e[1]-n[1],b){case ir:case rr:w&&(C=ur(D-i,lr(A-h,C)),s=i+C,p=h+C),x&&(M=ur(O-a,lr(I-f,M)),u=a+M,d=f+M);break;case or:S[1]?(w&&(s=ur(D,lr(A,S[0][0])),p=ur(D,lr(A,S[1][0])),w=1),x&&(u=ur(O,lr(I,S[0][1])),d=ur(O,lr(I,S[1][1])),x=1)):(w<0?(C=ur(D-i,lr(A-i,C)),s=i+C,p=h):w>0&&(C=ur(D-h,lr(A-h,C)),s=i,p=h+C),x<0?(M=ur(O-a,lr(I-a,M)),u=a+M,d=f):x>0&&(M=ur(O-f,lr(I-f,M)),u=a,d=f+M));break;case sr:w&&(s=ur(D,lr(A,i-C*w)),p=ur(D,lr(A,h+C*w))),x&&(u=ur(O,lr(I,a-M*x)),d=ur(O,lr(I,f+M*x)))}p<s&&(w*=-1,r=i,i=h,h=r,r=s,s=p,p=r,v in gr&&L.attr("cursor",mr[v=gr[v]])),d<u&&(x*=-1,r=a,a=f,f=r,r=u,u=d,d=r,v in yr&&L.attr("cursor",mr[v=yr[v]])),T.selection&&(N=T.selection),g&&(s=N[0][0],p=N[1][0]),y&&(u=N[0][1],d=N[1][1]),N[0][0]===s&&N[0][1]===u&&N[1][0]===p&&N[1][1]===d||(T.selection=[[s,u],[p,d]],l.call(_),k.brush(t,b.name))}function R(t){if(function(t){t.stopImmediatePropagation()}(t),t.touches){if(t.touches.length)return;e&&clearTimeout(e),e=setTimeout(function(){e=null},500)}else te(t.view,m),j.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);F.attr("pointer-events","all"),L.attr("cursor",mr.overlay),T.selection&&(N=T.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(N)&&(T.selection=null,l.call(_)),k.end(t,b.name)}function B(t){switch(t.keyCode){case 16:P=w&&x;break;case 18:b===or&&(w&&(h=p-C*w,i=s+C*w),x&&(f=d-M*x,a=u+M*x),b=sr,U(t));break;case 32:b!==or&&b!==sr||(w<0?h=p-C:w>0&&(i=s-C),x<0?f=d-M:x>0&&(a=u-M),b=ir,L.attr("cursor",mr.selection),U(t));break;default:return}nr(t)}function V(t){switch(t.keyCode){case 16:P&&(g=y=P=!1,U(t));break;case 18:b===sr&&(w<0?h=p:w>0&&(i=s),x<0?f=d:x>0&&(a=u),b=or,U(t));break;case 32:b===ir&&(t.altKey?(w&&(h=p-C*w,i=s+C*w),x&&(f=d-M*x,a=u+M*x),b=sr):(w<0?h=p:w>0&&(i=s),x<0?f=d:x>0&&(a=u),b=or),L.attr("cursor",mr[v]),U(t));break;default:return}nr(t)}}function f(t){c(this,arguments).moved(t)}function d(t){c(this,arguments).ended(t)}function m(){var e=this.__brush||{selection:null};return e.extent=hr(n.apply(this,arguments)),e.dim=t,e}return u.move=function(e,n,r){e.tween?e.on("start.brush",function(t){c(this,arguments).beforestart().start(t)}).on("interrupt.brush end.brush",function(t){c(this,arguments).end(t)}).tween("brush",function(){var e=this,r=e.__brush,i=c(e,arguments),o=r.selection,s=t.input("function"==typeof n?n.apply(this,arguments):n,r.extent),a=Xe(o,s);function u(t){r.selection=1===t&&null===s?null:a(t),l.call(e),i.brush()}return null!==o&&null!==s?u:u(1)}):e.each(function(){var e=this,i=arguments,o=e.__brush,s=t.input("function"==typeof n?n.apply(e,i):n,o.extent),a=c(e,i).beforestart();In(e),o.selection=null===s?null:s,l.call(e),a.start(r).brush(r).end(r)})},u.clear=function(t,e){u.move(t,null,e)},h.prototype={beforestart:function(){return 1===++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(t,e){return this.starting?(this.starting=!1,this.emit("start",t,e)):this.emit("brush",t),this},brush:function(t,e){return this.emit("brush",t,e),this},end:function(t,e){return 0===--this.active&&(delete this.state.emitter,this.emit("end",t,e)),this},emit:function(e,n,r){var i=Wt(this.that).datum();s.call(e,this.that,new er(e,{sourceEvent:n,target:u,selection:t.output(this.state.selection),mode:r,dispatch:s}),i)}},u.extent=function(t){return arguments.length?(n="function"==typeof t?t:tr(hr(t)),u):n},u.filter=function(t){return arguments.length?(r="function"==typeof t?t:tr(!!t),u):r},u.touchable=function(t){return arguments.length?(i="function"==typeof t?t:tr(!!t),u):i},u.handleSize=function(t){return arguments.length?(a=+t,u):a},u.keyModifiers=function(t){return arguments.length?(o=!!t,u):o},u.on=function(){var t=s.on.apply(s,arguments);return t===s?u:t},u}(dr)}const Dr=Math.PI,Or=2*Dr,Ar=1e-6,Ir=Or-Ar;function Cr(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}class Mr{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?Cr:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Cr;const n=10**e;return function(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=Math.round(arguments[e]*n)/n+t[e]}}(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,n,r){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(t,e,n,r,i,o){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+o}`}arcTo(t,e,n,r,i){if(t=+t,e=+e,n=+n,r=+r,(i=+i)<0)throw new Error(`negative radius: ${i}`);let o=this._x1,s=this._y1,a=n-t,u=r-e,l=o-t,c=s-e,h=l*l+c*c;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(h>Ar)if(Math.abs(c*a-u*l)>Ar&&i){let p=n-o,f=r-s,d=a*a+u*u,m=p*p+f*f,g=Math.sqrt(d),y=Math.sqrt(h),_=i*Math.tan((Dr-Math.acos((d+h-m)/(2*g*y)))/2),v=_/y,b=_/g;Math.abs(v-1)>Ar&&this._append`L${t+v*l},${e+v*c}`,this._append`A${i},${i},0,0,${+(c*p>l*f)},${this._x1=t+b*a},${this._y1=e+b*u}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,o){if(t=+t,e=+e,o=!!o,(n=+n)<0)throw new Error(`negative radius: ${n}`);let s=n*Math.cos(r),a=n*Math.sin(r),u=t+s,l=e+a,c=1^o,h=o?r-i:i-r;null===this._x1?this._append`M${u},${l}`:(Math.abs(this._x1-u)>Ar||Math.abs(this._y1-l)>Ar)&&this._append`L${u},${l}`,n&&(h<0&&(h=h%Or+Or),h>Ir?this._append`A${n},${n},0,1,${c},${t-s},${e-a}A${n},${n},0,1,${c},${this._x1=u},${this._y1=l}`:h>Ar&&this._append`A${n},${n},0,${+(h>=Dr)},${c},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}}function Pr(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Sr(t){return(t=Pr(Math.abs(t)))?t[1]:NaN}var kr,Fr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Lr(t){if(!(e=Fr.exec(t)))throw new Error("invalid format: "+t);var e;return new jr({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function jr(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function zr(t,e){var n=Pr(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}Lr.prototype=jr.prototype,jr.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Ur={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>zr(100*t,e),r:zr,s:function(t,e){var n=Pr(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(kr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,s=r.length;return o===s?r:o>s?r+new Array(o-s+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Pr(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Rr(t){return t}var Br,Vr,$r,Yr=Array.prototype.map,qr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Hr(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Rr:(e=Yr.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,o=[],s=0,a=e[0],u=0;i>0&&a>0&&(u+a+1>r&&(a=Math.max(1,r-u)),o.push(t.substring(i-=a,i+a)),!((u+=a+1)>r));)a=e[s=(s+1)%e.length];return o.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",s=void 0===t.decimal?".":t.decimal+"",a=void 0===t.numerals?Rr:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(Yr.call(t.numerals,String)),u=void 0===t.percent?"%":t.percent+"",l=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=Lr(t)).fill,n=t.align,h=t.sign,p=t.symbol,f=t.zero,d=t.width,m=t.comma,g=t.precision,y=t.trim,_=t.type;"n"===_?(m=!0,_="g"):Ur[_]||(void 0===g&&(g=12),y=!0,_="g"),(f||"0"===e&&"="===n)&&(f=!0,e="0",n="=");var v="$"===p?i:"#"===p&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",b="$"===p?o:/[%p]/.test(_)?u:"",w=Ur[_],x=/[defgprs%]/.test(_);function T(t){var i,o,u,p=v,T=b;if("c"===_)T=w(t)+T,t="";else{var E=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:w(Math.abs(t),g),y&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),E&&0===+t&&"+"!==h&&(E=!1),p=(E?"("===h?h:l:"-"===h||"("===h?"":h)+p,T=("s"===_?qr[8+kr/3]:"")+T+(E&&"("===h?")":""),x)for(i=-1,o=t.length;++i<o;)if(48>(u=t.charCodeAt(i))||u>57){T=(46===u?s+t.slice(i+1):t.slice(i))+T,t=t.slice(0,i);break}}m&&!f&&(t=r(t,1/0));var N=p.length+t.length+T.length,D=N<d?new Array(d-N+1).join(e):"";switch(m&&f&&(t=r(D+t,D.length?d-T.length:1/0),D=""),n){case"<":t=p+t+T+D;break;case"=":t=p+D+t+T;break;case"^":t=D.slice(0,N=D.length>>1)+p+t+T+D.slice(N);break;default:t=D+p+t+T}return a(t)}return g=void 0===g?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),T.toString=function(){return t+""},T}return{format:h,formatPrefix:function(t,e){var n=h(((t=Lr(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Sr(e)/3))),i=Math.pow(10,-r),o=qr[8+r/3];return function(t){return n(i*t)+o}}}}function Xr(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function Gr(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=Kr)):void 0===e&&(e=Wr);for(var n,r,i,o,s,a=new Jr(t),u=[a];n=u.pop();)if((i=e(n.data))&&(s=(i=Array.from(i)).length))for(n.children=i,o=s-1;o>=0;--o)u.push(r=i[o]=new Jr(i[o])),r.parent=n,r.depth=n.depth+1;return a.eachBefore(Zr)}function Wr(t){return t.children}function Kr(t){return Array.isArray(t)?t[1]:null}function Qr(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Zr(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Jr(t){this.data=t,this.depth=this.height=0,this.parent=null}function ti(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function ei(t){return+t}Br=Hr({thousands:",",grouping:[3],currency:["$",""]}),Vr=Br.format,$r=Br.formatPrefix,Jr.prototype=Gr.prototype={constructor:Jr,count:function(){return this.eachAfter(Xr)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,o=this,s=[o],a=[],u=-1;o=s.pop();)if(a.push(o),n=o.children)for(r=0,i=n.length;r<i;++r)s.push(n[r]);for(;o=a.pop();)t.call(e,o,++u,this);return this},eachBefore:function(t,e){for(var n,r,i=this,o=[i],s=-1;i=o.pop();)if(t.call(e,i,++s,this),n=i.children)for(r=n.length-1;r>=0;--r)o.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n})},sort:function(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t},links:function(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e},copy:function(){return Gr(this).eachBefore(Qr)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,o=[i];do{for(t=o.reverse(),o=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)o.push(e[n])}while(o.length)}};var ni=[0,1];function ri(t){return t}function ii(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function oi(t,e,n){var r=t[0],i=t[1],o=e[0],s=e[1];return i<r?(r=ii(i,r),o=n(s,o)):(r=ii(r,i),o=n(o,s)),function(t){return o(r(t))}}function si(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)i[s]=ii(t[s],t[s+1]),o[s]=n(e[s],e[s+1]);return function(e){var n=_(t,e,1,r)-1;return o[n](i[n](e))}}function ai(){var t,e,n,r,i,o,s=ni,a=ni,u=Xe,l=ri;function c(){var t,e,n,u=Math.min(s.length,a.length);return l!==ri&&(t=s[0],e=s[u-1],t>e&&(n=t,t=e,e=n),l=function(n){return Math.max(t,Math.min(e,n))}),r=u>2?si:oi,i=o=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(s.map(t),a,u)))(t(l(e)))}return h.invert=function(n){return l(e((o||(o=r(a,s.map(t),Ve)))(n)))},h.domain=function(t){return arguments.length?(s=Array.from(t,ei),c()):s.slice()},h.range=function(t){return arguments.length?(a=Array.from(t),c()):a.slice()},h.rangeRound=function(t){return a=Array.from(t),u=Ge,c()},h.clamp=function(t){return arguments.length?(l=!!t||ri,c()):l!==ri},h.interpolate=function(t){return arguments.length?(u=t,c()):u},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,c()}}function ui(t,e,n,r){var i,o=function(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?T(e,t,n):T(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}(t,e,n);switch((r=Lr(null==r?",f":r)).type){case"s":var s=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Sr(e)/3)))-Sr(Math.abs(t)))}(o,s))||(r.precision=i),$r(r,s);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Sr(e)-Sr(t))+1}(o,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-Sr(Math.abs(t)))}(o))||(r.precision=i-2*("%"===r.type))}return Vr(r)}function li(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)===(e=+e))return[t];const r=e<t,[i,o,s]=r?x(e,t,n):x(t,e,n);if(!(o>=i))return[];const a=o-i+1,u=new Array(a);if(r)if(s<0)for(let t=0;t<a;++t)u[t]=(o-t)/-s;else for(let t=0;t<a;++t)u[t]=(o-t)*s;else if(s<0)for(let t=0;t<a;++t)u[t]=(i+t)/-s;else for(let t=0;t<a;++t)u[t]=(i+t)*s;return u}(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return ui(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,o=e(),s=0,a=o.length-1,u=o[s],l=o[a],c=10;for(l<u&&(i=u,u=l,l=i,i=s,s=a,a=i);c-- >0;){if((i=T(u,l,n))===r)return o[s]=u,o[a]=l,e(o);if(i>0)u=Math.floor(u/i)*i,l=Math.ceil(l/i)*i;else{if(!(i<0))break;u=Math.ceil(u*i)/i,l=Math.floor(l*i)/i}r=i}return t},t}function ci(){var t=ai()(ri,ri);return t.copy=function(){return e=t,ci().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},ti.apply(t,arguments),li(t)}const hi=new Date,pi=new Date;function fi(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=e=>(t(e=new Date(+e)),e),i.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),i.round=t=>{const e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=(t,n)=>(e(t=new Date(+t),null==n?1:Math.floor(n)),t),i.range=(n,r,o)=>{const s=[];if(n=i.ceil(n),o=null==o?1:Math.floor(o),!(n<r&&o>0))return s;let a;do{s.push(a=new Date(+n)),e(n,o),t(n)}while(a<n&&n<r);return s},i.filter=n=>fi(e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)},(t,r)=>{if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}),n&&(i.count=(e,r)=>(hi.setTime(+e),pi.setTime(+r),t(hi),t(pi),Math.floor(n(hi,pi))),i.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?e=>r(e)%t===0:e=>i.count(0,e)%t===0):i:null)),i}const di=6e4,mi=864e5,gi=6048e5,yi=fi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*di)/mi,t=>t.getDate()-1);yi.range;const _i=fi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/mi,t=>t.getUTCDate()-1);_i.range;const vi=fi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/mi,t=>Math.floor(t/mi));function bi(t){return fi(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+7*e)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*di)/gi)}vi.range;const wi=bi(0),xi=bi(1),Ti=bi(2),Ei=bi(3),Ni=bi(4),Di=bi(5),Oi=bi(6);function Ai(t){return fi(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)},(t,e)=>(e-t)/gi)}wi.range,xi.range,Ti.range,Ei.range,Ni.range,Di.range,Oi.range;const Ii=Ai(0),Ci=Ai(1),Mi=Ai(2),Pi=Ai(3),Si=Ai(4),ki=Ai(5),Fi=Ai(6);Ii.range,Ci.range,Mi.range,Pi.range,Si.range,ki.range,Fi.range;const Li=fi(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Li.every=t=>isFinite(t=Math.floor(t))&&t>0?fi(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)}):null,Li.range;const ji=fi(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());function zi(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Ui(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Ri(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}ji.every=t=>isFinite(t=Math.floor(t))&&t>0?fi(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)}):null,ji.range;var Bi,Vi,$i={"-":"",_:" ",0:"0"},Yi=/^\s*\d+/,qi=/^%/,Hi=/[\\^$*+?|[\]().{}]/g;function Xi(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o<n?new Array(n-o+1).join(e)+i:i)}function Gi(t){return t.replace(Hi,"\\$&")}function Wi(t){return new RegExp("^(?:"+t.map(Gi).join("|")+")","i")}function Ki(t){return new Map(t.map((t,e)=>[t.toLowerCase(),e]))}function Qi(t,e,n){var r=Yi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Zi(t,e,n){var r=Yi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Ji(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function to(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function eo(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function no(t,e,n){var r=Yi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function ro(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function io(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function oo(t,e,n){var r=Yi.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function so(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ao(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function uo(t,e,n){var r=Yi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function lo(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function co(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ho(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function po(t,e,n){var r=Yi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function fo(t,e,n){var r=Yi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function mo(t,e,n){var r=qi.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function go(t,e,n){var r=Yi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function yo(t,e,n){var r=Yi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function _o(t,e){return Xi(t.getDate(),e,2)}function vo(t,e){return Xi(t.getHours(),e,2)}function bo(t,e){return Xi(t.getHours()%12||12,e,2)}function wo(t,e){return Xi(1+yi.count(Li(t),t),e,3)}function xo(t,e){return Xi(t.getMilliseconds(),e,3)}function To(t,e){return xo(t,e)+"000"}function Eo(t,e){return Xi(t.getMonth()+1,e,2)}function No(t,e){return Xi(t.getMinutes(),e,2)}function Do(t,e){return Xi(t.getSeconds(),e,2)}function Oo(t){var e=t.getDay();return 0===e?7:e}function Ao(t,e){return Xi(wi.count(Li(t)-1,t),e,2)}function Io(t){var e=t.getDay();return e>=4||0===e?Ni(t):Ni.ceil(t)}function Co(t,e){return t=Io(t),Xi(Ni.count(Li(t),t)+(4===Li(t).getDay()),e,2)}function Mo(t){return t.getDay()}function Po(t,e){return Xi(xi.count(Li(t)-1,t),e,2)}function So(t,e){return Xi(t.getFullYear()%100,e,2)}function ko(t,e){return Xi((t=Io(t)).getFullYear()%100,e,2)}function Fo(t,e){return Xi(t.getFullYear()%1e4,e,4)}function Lo(t,e){var n=t.getDay();return Xi((t=n>=4||0===n?Ni(t):Ni.ceil(t)).getFullYear()%1e4,e,4)}function jo(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Xi(e/60|0,"0",2)+Xi(e%60,"0",2)}function zo(t,e){return Xi(t.getUTCDate(),e,2)}function Uo(t,e){return Xi(t.getUTCHours(),e,2)}function Ro(t,e){return Xi(t.getUTCHours()%12||12,e,2)}function Bo(t,e){return Xi(1+_i.count(ji(t),t),e,3)}function Vo(t,e){return Xi(t.getUTCMilliseconds(),e,3)}function $o(t,e){return Vo(t,e)+"000"}function Yo(t,e){return Xi(t.getUTCMonth()+1,e,2)}function qo(t,e){return Xi(t.getUTCMinutes(),e,2)}function Ho(t,e){return Xi(t.getUTCSeconds(),e,2)}function Xo(t){var e=t.getUTCDay();return 0===e?7:e}function Go(t,e){return Xi(Ii.count(ji(t)-1,t),e,2)}function Wo(t){var e=t.getUTCDay();return e>=4||0===e?Si(t):Si.ceil(t)}function Ko(t,e){return t=Wo(t),Xi(Si.count(ji(t),t)+(4===ji(t).getUTCDay()),e,2)}function Qo(t){return t.getUTCDay()}function Zo(t,e){return Xi(Ci.count(ji(t)-1,t),e,2)}function Jo(t,e){return Xi(t.getUTCFullYear()%100,e,2)}function ts(t,e){return Xi((t=Wo(t)).getUTCFullYear()%100,e,2)}function es(t,e){return Xi(t.getUTCFullYear()%1e4,e,4)}function ns(t,e){var n=t.getUTCDay();return Xi((t=n>=4||0===n?Si(t):Si.ceil(t)).getUTCFullYear()%1e4,e,4)}function rs(){return"+0000"}function is(){return"%"}function os(t){return+t}function ss(t){return Math.floor(+t/1e3)}function as(t){return function(){return t}}function us(t){this._context=t}function ls(t){return new us(t)}function cs(t){return t[0]}function hs(t){return t[1]}function ps(t,e){var n=as(!0),r=null,i=ls,o=null,s=function(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(null==n)e=null;else{const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new Mr(e)}(a);function a(a){var u,l,c,h=(a=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(a)).length,p=!1;for(null==r&&(o=i(c=s())),u=0;u<=h;++u)!(u<h&&n(l=a[u],u,a))===p&&((p=!p)?o.lineStart():o.lineEnd()),p&&o.point(+t(l,u,a),+e(l,u,a));if(c)return o=null,c+""||null}return t="function"==typeof t?t:void 0===t?cs:as(t),e="function"==typeof e?e:void 0===e?hs:as(e),a.x=function(e){return arguments.length?(t="function"==typeof e?e:as(+e),a):t},a.y=function(t){return arguments.length?(e="function"==typeof t?t:as(+t),a):e},a.defined=function(t){return arguments.length?(n="function"==typeof t?t:as(!!t),a):n},a.curve=function(t){return arguments.length?(i=t,null!=r&&(o=i(r)),a):i},a.context=function(t){return arguments.length?(null==t?r=o=null:o=i(r=t),a):r},a}function fs(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function ds(t){this._context=t}function ms(t){return new ds(t)}function gs(t,e){this._context=t,this._t=e}!function(t){Bi=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,o=t.days,s=t.shortDays,a=t.months,u=t.shortMonths,l=Wi(i),c=Ki(i),h=Wi(o),p=Ki(o),f=Wi(s),d=Ki(s),m=Wi(a),g=Ki(a),y=Wi(u),_=Ki(u),v={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return a[t.getMonth()]},c:null,d:_o,e:_o,f:To,g:ko,G:Lo,H:vo,I:bo,j:wo,L:xo,m:Eo,M:No,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:os,s:ss,S:Do,u:Oo,U:Ao,V:Co,w:Mo,W:Po,x:null,X:null,y:So,Y:Fo,Z:jo,"%":is},b={a:function(t){return s[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return u[t.getUTCMonth()]},B:function(t){return a[t.getUTCMonth()]},c:null,d:zo,e:zo,f:$o,g:ts,G:ns,H:Uo,I:Ro,j:Bo,L:Vo,m:Yo,M:qo,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:os,s:ss,S:Ho,u:Xo,U:Go,V:Ko,w:Qo,W:Zo,x:null,X:null,y:Jo,Y:es,Z:rs,"%":is},w={a:function(t,e,n){var r=f.exec(e.slice(n));return r?(t.w=d.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=y.exec(e.slice(n));return r?(t.m=_.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=g.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return E(t,e,n,r)},d:ao,e:ao,f:fo,g:ro,G:no,H:lo,I:lo,j:uo,L:po,m:so,M:co,p:function(t,e,n){var r=l.exec(e.slice(n));return r?(t.p=c.get(r[0].toLowerCase()),n+r[0].length):-1},q:oo,Q:go,s:yo,S:ho,u:Zi,U:Ji,V:to,w:Qi,W:eo,x:function(t,e,r){return E(t,n,e,r)},X:function(t,e,n){return E(t,r,e,n)},y:ro,Y:no,Z:io,"%":mo};function x(t,e){return function(n){var r,i,o,s=[],a=-1,u=0,l=t.length;for(n instanceof Date||(n=new Date(+n));++a<l;)37===t.charCodeAt(a)&&(s.push(t.slice(u,a)),null!=(i=$i[r=t.charAt(++a)])?r=t.charAt(++a):i="e"===r?" ":"0",(o=e[r])&&(r=o(n,i)),s.push(r),u=a+1);return s.push(t.slice(u,a)),s.join("")}}function T(t,e){return function(n){var r,i,o=Ri(1900,void 0,1);if(E(o,t,n+="",0)!=n.length)return null;if("Q"in o)return new Date(o.Q);if("s"in o)return new Date(1e3*o.s+("L"in o?o.L:0));if(e&&!("Z"in o)&&(o.Z=0),"p"in o&&(o.H=o.H%12+12*o.p),void 0===o.m&&(o.m="q"in o?o.q:0),"V"in o){if(o.V<1||o.V>53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=Ui(Ri(o.y,0,1))).getUTCDay(),r=i>4||0===i?Ci.ceil(r):Ci(r),r=_i.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=zi(Ri(o.y,0,1))).getDay(),r=i>4||0===i?xi.ceil(r):xi(r),r=yi.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?Ui(Ri(o.y,0,1)).getUTCDay():zi(Ri(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,Ui(o)):zi(o)}}function E(t,e,n,r){for(var i,o,s=0,a=e.length,u=n.length;s<a;){if(r>=u)return-1;if(37===(i=e.charCodeAt(s++))){if(i=e.charAt(s++),!(o=w[i in $i?e.charAt(s++):i])||(r=o(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return v.x=x(n,v),v.X=x(r,v),v.c=x(e,v),b.x=x(n,b),b.X=x(r,b),b.c=x(e,b),{format:function(t){var e=x(t+="",v);return e.toString=function(){return t},e},parse:function(t){var e=T(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=x(t+="",b);return e.toString=function(){return t},e},utcParse:function(t){var e=T(t+="",!0);return e.toString=function(){return t},e}}}(t),Bi.format,Vi=Bi.parse,Bi.utcFormat,Bi.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),us.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}},ds.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:fs(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:fs(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},gs.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}}this._x=t,this._y=e}};var ys=t=>()=>t;function _s(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function vs(t,e,n){this.k=t,this.x=e,this.y=n}vs.prototype={constructor:vs,scale:function(t){return 1===t?this:new vs(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new vs(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var bs=new vs(1,0,0);function ws(t){t.stopImmediatePropagation()}function xs(t){t.preventDefault(),t.stopImmediatePropagation()}function Ts(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Es(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||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]]:[[0,0],[t.clientWidth,t.clientHeight]]}function Ns(){return this.__zoom||bs}function Ds(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Os(){return navigator.maxTouchPoints||"ontouchstart"in this}function As(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],s=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}vs.prototype;var Is,Cs={},Ms={};function Ps(){return Is||(Is=1,function(){Ms.defaults={.1:{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},.2:{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:"\n"},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}}}.call(Ms)),Ms}var Ss,ks={},Fs={},Ls={};function js(){return Ss||(Ss=1,function(){var t,e,n,r,i,o,s,a=[].slice,u={}.hasOwnProperty;t=function(){var t,e,n,r,o,s;if(s=arguments[0],o=2<=arguments.length?a.call(arguments,1):[],i(Object.assign))Object.assign.apply(null,arguments);else for(t=0,n=o.length;t<n;t++)if(null!=(r=o[t]))for(e in r)u.call(r,e)&&(s[e]=r[e]);return s},i=function(t){return!!t&&"[object Function]"===Object.prototype.toString.call(t)},o=function(t){var e;return!!t&&("function"==(e=typeof t)||"object"===e)},n=function(t){return i(Array.isArray)?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},r=function(t){var e;if(n(t))return!t.length;for(e in t)if(u.call(t,e))return!1;return!0},s=function(t){var e,n;return o(t)&&(n=Object.getPrototypeOf(t))&&(e=n.constructor)&&"function"==typeof e&&e instanceof e&&Function.prototype.toString.call(e)===Function.prototype.toString.call(Object)},e=function(t){return i(t.valueOf)?t.valueOf():t},Ls.assign=t,Ls.isFunction=i,Ls.isObject=o,Ls.isArray=n,Ls.isEmpty=r,Ls.isPlainObject=s,Ls.getValue=e}.call(Ls)),Ls}var zs,Us={exports:{}},Rs=Us.exports;function Bs(){return zs||(zs=1,function(){Us.exports=function(){function t(){}return t.prototype.hasFeature=function(t,e){return!0},t.prototype.createDocumentType=function(t,e,n){throw new Error("This DOM method is not implemented.")},t.prototype.createDocument=function(t,e,n){throw new Error("This DOM method is not implemented.")},t.prototype.createHTMLDocument=function(t){throw new Error("This DOM method is not implemented.")},t.prototype.getFeature=function(t,e){throw new Error("This DOM method is not implemented.")},t}()}.call(Rs)),Us.exports}var Vs,$s={exports:{}},Ys={exports:{}},qs={exports:{}},Hs=qs.exports;function Xs(){return Vs||(Vs=1,function(){qs.exports=function(){function t(){}return t.prototype.handleError=function(t){throw new Error(t)},t}()}.call(Hs)),qs.exports}var Gs,Ws={exports:{}},Ks=Ws.exports;function Qs(){return Gs||(Gs=1,function(){Ws.exports=function(){function t(t){this.arr=t||[]}return Object.defineProperty(t.prototype,"length",{get:function(){return this.arr.length}}),t.prototype.item=function(t){return this.arr[t]||null},t.prototype.contains=function(t){return-1!==this.arr.indexOf(t)},t}()}.call(Ks)),Ws.exports}var Zs,Js=Ys.exports;function ta(){return Zs||(Zs=1,function(){var t,e;t=Xs(),e=Qs(),Ys.exports=function(){function n(){this.defaultParams={"canonical-form":!1,"cdata-sections":!1,comments:!1,"datatype-normalization":!1,"element-content-whitespace":!0,entities:!0,"error-handler":new t,infoset:!0,"validate-if-schema":!1,namespaces:!0,"namespace-declarations":!0,"normalize-characters":!1,"schema-location":"","schema-type":"","split-cdata-sections":!0,validate:!1,"well-formed":!0},this.params=Object.create(this.defaultParams)}return Object.defineProperty(n.prototype,"parameterNames",{get:function(){return new e(Object.keys(this.defaultParams))}}),n.prototype.getParameter=function(t){return this.params.hasOwnProperty(t)?this.params[t]:null},n.prototype.canSetParameter=function(t,e){return!0},n.prototype.setParameter=function(t,e){return null!=e?this.params[t]=e:delete this.params[t]},n}()}.call(Js)),Ys.exports}var ea,na={exports:{}},ra={exports:{}},ia={exports:{}},oa=ia.exports;function sa(){return ea||(ea=1,function(){ia.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}.call(oa)),ia.exports}var aa,ua={exports:{}},la=ua.exports;function ca(){return aa||(aa=1,function(){var t;t=sa(),Du(),ua.exports=function(){function e(e,n,r){if(this.parent=e,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),null==n)throw new Error("Missing attribute name. "+this.debugInfo(n));this.name=this.stringify.name(n),this.value=this.stringify.attValue(r),this.type=t.Attribute,this.isId=!1,this.schemaTypeInfo=null}return Object.defineProperty(e.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(e.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(e.prototype,"textContent",{get:function(){return this.value},set:function(t){return this.value=t||""}}),Object.defineProperty(e.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(e.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(e.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(e.prototype,"specified",{get:function(){return!0}}),e.prototype.clone=function(){return Object.create(this)},e.prototype.toString=function(t){return this.options.writer.attribute(this,this.options.writer.filterOptions(t))},e.prototype.debugInfo=function(t){return null==(t=t||this.name)?"parent: <"+this.parent.name+">":"attribute: {"+t+"}, parent: <"+this.parent.name+">"},e.prototype.isEqualNode=function(t){return t.namespaceURI===this.namespaceURI&&(t.prefix===this.prefix&&(t.localName===this.localName&&t.value===this.value))},e}()}.call(la)),ua.exports}var ha,pa={exports:{}},fa=pa.exports;function da(){return ha||(ha=1,function(){pa.exports=function(){function t(t){this.nodes=t}return Object.defineProperty(t.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),t.prototype.clone=function(){return this.nodes=null},t.prototype.getNamedItem=function(t){return this.nodes[t]},t.prototype.setNamedItem=function(t){var e;return e=this.nodes[t.nodeName],this.nodes[t.nodeName]=t,e||null},t.prototype.removeNamedItem=function(t){var e;return e=this.nodes[t],delete this.nodes[t],e||null},t.prototype.item=function(t){return this.nodes[Object.keys(this.nodes)[t]]||null},t.prototype.getNamedItemNS=function(t,e){throw new Error("This DOM method is not implemented.")},t.prototype.setNamedItemNS=function(t){throw new Error("This DOM method is not implemented.")},t.prototype.removeNamedItemNS=function(t,e){throw new Error("This DOM method is not implemented.")},t}()}.call(fa)),pa.exports}var ma,ga=ra.exports;function ya(){return ma||(ma=1,function(){var t,e,n,r,i,o,s,a,u={}.hasOwnProperty;a=js(),s=a.isObject,o=a.isFunction,i=a.getValue,r=Du(),t=sa(),e=ca(),n=da(),ra.exports=function(r){function a(e,n,r){var i,o,s,u;if(a.__super__.constructor.call(this,e),null==n)throw new Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(n),this.type=t.Element,this.attribs={},this.schemaTypeInfo=null,null!=r&&this.attribute(r),e.type===t.Document&&(this.isRoot=!0,this.documentObject=e,e.rootObject=this,e.children))for(o=0,s=(u=e.children).length;o<s;o++)if((i=u[o]).type===t.DocType){i.name=this.name;break}}return function(t,e){for(var n in e)u.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(a,r),Object.defineProperty(a.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(a.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(a.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(a.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(a.prototype,"id",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(a.prototype,"className",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(a.prototype,"classList",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(a.prototype,"attributes",{get:function(){return this.attributeMap&&this.attributeMap.nodes||(this.attributeMap=new n(this.attribs)),this.attributeMap}}),a.prototype.clone=function(){var t,e,n,r;for(e in(n=Object.create(this)).isRoot&&(n.documentObject=null),n.attribs={},r=this.attribs)u.call(r,e)&&(t=r[e],n.attribs[e]=t.clone());return n.children=[],this.children.forEach(function(t){var e;return(e=t.clone()).parent=n,n.children.push(e)}),n},a.prototype.attribute=function(t,n){var r,a;if(null!=t&&(t=i(t)),s(t))for(r in t)u.call(t,r)&&(a=t[r],this.attribute(r,a));else o(n)&&(n=n.apply()),this.options.keepNullAttributes&&null==n?this.attribs[t]=new e(this,t,""):null!=n&&(this.attribs[t]=new e(this,t,n));return this},a.prototype.removeAttribute=function(t){var e,n,r;if(null==t)throw new Error("Missing attribute name. "+this.debugInfo());if(t=i(t),Array.isArray(t))for(n=0,r=t.length;n<r;n++)e=t[n],delete this.attribs[e];else delete this.attribs[t];return this},a.prototype.toString=function(t){return this.options.writer.element(this,this.options.writer.filterOptions(t))},a.prototype.att=function(t,e){return this.attribute(t,e)},a.prototype.a=function(t,e){return this.attribute(t,e)},a.prototype.getAttribute=function(t){return this.attribs.hasOwnProperty(t)?this.attribs[t].value:null},a.prototype.setAttribute=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getAttributeNode=function(t){return this.attribs.hasOwnProperty(t)?this.attribs[t]:null},a.prototype.setAttributeNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.removeAttributeNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByTagName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getAttributeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.setAttributeNS=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.removeAttributeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getAttributeNodeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.setAttributeNodeNS=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByTagNameNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.hasAttribute=function(t){return this.attribs.hasOwnProperty(t)},a.prototype.hasAttributeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.setIdAttribute=function(t,e){return this.attribs.hasOwnProperty(t)?this.attribs[t].isId:e},a.prototype.setIdAttributeNS=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.setIdAttributeNode=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByTagName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByTagNameNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByClassName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.isEqualNode=function(t){var e,n,r;if(!a.__super__.isEqualNode.apply(this,arguments).isEqualNode(t))return!1;if(t.namespaceURI!==this.namespaceURI)return!1;if(t.prefix!==this.prefix)return!1;if(t.localName!==this.localName)return!1;if(t.attribs.length!==this.attribs.length)return!1;for(e=n=0,r=this.attribs.length-1;0<=r?n<=r:n>=r;e=0<=r?++n:--n)if(!this.attribs[e].isEqualNode(t.attribs[e]))return!1;return!0},a}(r)}.call(ga)),ra.exports}var _a,va={exports:{}},ba={exports:{}},wa=ba.exports;function xa(){return _a||(_a=1,function(){var t,e={}.hasOwnProperty;t=Du(),ba.exports=function(t){function n(t){n.__super__.constructor.call(this,t),this.value=""}return function(t,n){for(var r in n)e.call(n,r)&&(t[r]=n[r]);function i(){this.constructor=t}i.prototype=n.prototype,t.prototype=new i,t.__super__=n.prototype}(n,t),Object.defineProperty(n.prototype,"data",{get:function(){return this.value},set:function(t){return this.value=t||""}}),Object.defineProperty(n.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(n.prototype,"textContent",{get:function(){return this.value},set:function(t){return this.value=t||""}}),n.prototype.clone=function(){return Object.create(this)},n.prototype.substringData=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.appendData=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.insertData=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.deleteData=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.replaceData=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.isEqualNode=function(t){return!!n.__super__.isEqualNode.apply(this,arguments).isEqualNode(t)&&t.data===this.data},n}(t)}.call(wa)),ba.exports}var Ta,Ea=va.exports;function Na(){return Ta||(Ta=1,function(){var t,e,n={}.hasOwnProperty;t=sa(),e=xa(),va.exports=function(e){function r(e,n){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=t.CData,this.value=this.stringify.cdata(n)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.cdata(this,this.options.writer.filterOptions(t))},r}(e)}.call(Ea)),va.exports}var Da,Oa={exports:{}},Aa=Oa.exports;function Ia(){return Da||(Da=1,function(){var t,e,n={}.hasOwnProperty;t=sa(),e=xa(),Oa.exports=function(e){function r(e,n){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=t.Comment,this.value=this.stringify.comment(n)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.comment(this,this.options.writer.filterOptions(t))},r}(e)}.call(Aa)),Oa.exports}var Ca,Ma={exports:{}},Pa=Ma.exports;function Sa(){return Ca||(Ca=1,function(){var t,e,n,r={}.hasOwnProperty;n=js().isObject,e=Du(),t=sa(),Ma.exports=function(e){function i(e,r,o,s){var a;i.__super__.constructor.call(this,e),n(r)&&(r=(a=r).version,o=a.encoding,s=a.standalone),r||(r="1.0"),this.type=t.Declaration,this.version=this.stringify.xmlVersion(r),null!=o&&(this.encoding=this.stringify.xmlEncoding(o)),null!=s&&(this.standalone=this.stringify.xmlStandalone(s))}return function(t,e){for(var n in e)r.call(e,n)&&(t[n]=e[n]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(i,e),i.prototype.toString=function(t){return this.options.writer.declaration(this,this.options.writer.filterOptions(t))},i}(e)}.call(Pa)),Ma.exports}var ka,Fa={exports:{}},La={exports:{}},ja=La.exports;function za(){return ka||(ka=1,function(){var t,e,n={}.hasOwnProperty;e=Du(),t=sa(),La.exports=function(e){function r(e,n,i,o,s,a){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing DTD element name. "+this.debugInfo());if(null==i)throw new Error("Missing DTD attribute name. "+this.debugInfo(n));if(!o)throw new Error("Missing DTD attribute type. "+this.debugInfo(n));if(!s)throw new Error("Missing DTD attribute default. "+this.debugInfo(n));if(0!==s.indexOf("#")&&(s="#"+s),!s.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(n));if(a&&!s.match(/^(#FIXED|#DEFAULT)$/))throw new Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(n));this.elementName=this.stringify.name(n),this.type=t.AttributeDeclaration,this.attributeName=this.stringify.name(i),this.attributeType=this.stringify.dtdAttType(o),a&&(this.defaultValue=this.stringify.dtdAttDefault(a)),this.defaultValueType=s}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.toString=function(t){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(t))},r}(e)}.call(ja)),La.exports}var Ua,Ra={exports:{}},Ba=Ra.exports;function Va(){return Ua||(Ua=1,function(){var t,e,n,r={}.hasOwnProperty;n=js().isObject,e=Du(),t=sa(),Ra.exports=function(e){function i(e,r,o,s){if(i.__super__.constructor.call(this,e),null==o)throw new Error("Missing DTD entity name. "+this.debugInfo(o));if(null==s)throw new Error("Missing DTD entity value. "+this.debugInfo(o));if(this.pe=!!r,this.name=this.stringify.name(o),this.type=t.EntityDeclaration,n(s)){if(!s.pubID&&!s.sysID)throw new Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(o));if(s.pubID&&!s.sysID)throw new Error("System identifier is required for a public external entity. "+this.debugInfo(o));if(this.internal=!1,null!=s.pubID&&(this.pubID=this.stringify.dtdPubID(s.pubID)),null!=s.sysID&&(this.sysID=this.stringify.dtdSysID(s.sysID)),null!=s.nData&&(this.nData=this.stringify.dtdNData(s.nData)),this.pe&&this.nData)throw new Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(o))}else this.value=this.stringify.dtdEntityValue(s),this.internal=!0}return function(t,e){for(var n in e)r.call(e,n)&&(t[n]=e[n]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(i,e),Object.defineProperty(i.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(i.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(i.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(i.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(i.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(i.prototype,"xmlVersion",{get:function(){return null}}),i.prototype.toString=function(t){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(t))},i}(e)}.call(Ba)),Ra.exports}var $a,Ya={exports:{}},qa=Ya.exports;function Ha(){return $a||($a=1,function(){var t,e,n={}.hasOwnProperty;e=Du(),t=sa(),Ya.exports=function(e){function r(e,n,i){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing DTD element name. "+this.debugInfo());i||(i="(#PCDATA)"),Array.isArray(i)&&(i="("+i.join(",")+")"),this.name=this.stringify.name(n),this.type=t.ElementDeclaration,this.value=this.stringify.dtdElementValue(i)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.toString=function(t){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(t))},r}(e)}.call(qa)),Ya.exports}var Xa,Ga={exports:{}},Wa=Ga.exports;function Ka(){return Xa||(Xa=1,function(){var t,e,n={}.hasOwnProperty;e=Du(),t=sa(),Ga.exports=function(e){function r(e,n,i){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing DTD notation name. "+this.debugInfo(n));if(!i.pubID&&!i.sysID)throw new Error("Public or system identifiers are required for an external entity. "+this.debugInfo(n));this.name=this.stringify.name(n),this.type=t.NotationDeclaration,null!=i.pubID&&(this.pubID=this.stringify.dtdPubID(i.pubID)),null!=i.sysID&&(this.sysID=this.stringify.dtdSysID(i.sysID))}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),Object.defineProperty(r.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(r.prototype,"systemId",{get:function(){return this.sysID}}),r.prototype.toString=function(t){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(t))},r}(e)}.call(Wa)),Ga.exports}var Qa,Za=Fa.exports;function Ja(){return Qa||(Qa=1,function(){var t,e,n,r,i,o,s,a,u={}.hasOwnProperty;a=js().isObject,s=Du(),t=sa(),e=za(),r=Va(),n=Ha(),i=Ka(),o=da(),Fa.exports=function(s){function l(e,n,r){var i,o,s,u,c,h;if(l.__super__.constructor.call(this,e),this.type=t.DocType,e.children)for(o=0,s=(u=e.children).length;o<s;o++)if((i=u[o]).type===t.Element){this.name=i.name;break}this.documentObject=e,a(n)&&(n=(c=n).pubID,r=c.sysID),null==r&&(r=(h=[n,r])[0],n=h[1]),null!=n&&(this.pubID=this.stringify.dtdPubID(n)),null!=r&&(this.sysID=this.stringify.dtdSysID(r))}return function(t,e){for(var n in e)u.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(l,s),Object.defineProperty(l.prototype,"entities",{get:function(){var e,n,r,i,s;for(i={},n=0,r=(s=this.children).length;n<r;n++)(e=s[n]).type!==t.EntityDeclaration||e.pe||(i[e.name]=e);return new o(i)}}),Object.defineProperty(l.prototype,"notations",{get:function(){var e,n,r,i,s;for(i={},n=0,r=(s=this.children).length;n<r;n++)(e=s[n]).type===t.NotationDeclaration&&(i[e.name]=e);return new o(i)}}),Object.defineProperty(l.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(l.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(l.prototype,"internalSubset",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),l.prototype.element=function(t,e){var r;return r=new n(this,t,e),this.children.push(r),this},l.prototype.attList=function(t,n,r,i,o){var s;return s=new e(this,t,n,r,i,o),this.children.push(s),this},l.prototype.entity=function(t,e){var n;return n=new r(this,!1,t,e),this.children.push(n),this},l.prototype.pEntity=function(t,e){var n;return n=new r(this,!0,t,e),this.children.push(n),this},l.prototype.notation=function(t,e){var n;return n=new i(this,t,e),this.children.push(n),this},l.prototype.toString=function(t){return this.options.writer.docType(this,this.options.writer.filterOptions(t))},l.prototype.ele=function(t,e){return this.element(t,e)},l.prototype.att=function(t,e,n,r,i){return this.attList(t,e,n,r,i)},l.prototype.ent=function(t,e){return this.entity(t,e)},l.prototype.pent=function(t,e){return this.pEntity(t,e)},l.prototype.not=function(t,e){return this.notation(t,e)},l.prototype.up=function(){return this.root()||this.documentObject},l.prototype.isEqualNode=function(t){return!!l.__super__.isEqualNode.apply(this,arguments).isEqualNode(t)&&(t.name===this.name&&(t.publicId===this.publicId&&t.systemId===this.systemId))},l}(s)}.call(Za)),Fa.exports}var tu,eu={exports:{}},nu=eu.exports;function ru(){return tu||(tu=1,function(){var t,e,n={}.hasOwnProperty;t=sa(),e=Du(),eu.exports=function(e){function r(e,n){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing raw text. "+this.debugInfo());this.type=t.Raw,this.value=this.stringify.raw(n)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.raw(this,this.options.writer.filterOptions(t))},r}(e)}.call(nu)),eu.exports}var iu,ou={exports:{}},su=ou.exports;function au(){return iu||(iu=1,function(){var t,e,n={}.hasOwnProperty;t=sa(),e=xa(),ou.exports=function(e){function r(e,n){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing element text. "+this.debugInfo());this.name="#text",this.type=t.Text,this.value=this.stringify.text(n)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),Object.defineProperty(r.prototype,"isElementContentWhitespace",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(r.prototype,"wholeText",{get:function(){var t,e,n;for(n="",e=this.previousSibling;e;)n=e.data+n,e=e.previousSibling;for(n+=this.data,t=this.nextSibling;t;)n+=t.data,t=t.nextSibling;return n}}),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.text(this,this.options.writer.filterOptions(t))},r.prototype.splitText=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},r.prototype.replaceWholeText=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},r}(e)}.call(su)),ou.exports}var uu,lu={exports:{}},cu=lu.exports;function hu(){return uu||(uu=1,function(){var t,e,n={}.hasOwnProperty;t=sa(),e=xa(),lu.exports=function(e){function r(e,n,i){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing instruction target. "+this.debugInfo());this.type=t.ProcessingInstruction,this.target=this.stringify.insTarget(n),this.name=this.target,i&&(this.value=this.stringify.insValue(i))}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.processingInstruction(this,this.options.writer.filterOptions(t))},r.prototype.isEqualNode=function(t){return!!r.__super__.isEqualNode.apply(this,arguments).isEqualNode(t)&&t.target===this.target},r}(e)}.call(cu)),lu.exports}var pu,fu={exports:{}},du=fu.exports;function mu(){return pu||(pu=1,function(){var t,e,n={}.hasOwnProperty;e=Du(),t=sa(),fu.exports=function(e){function r(e){r.__super__.constructor.call(this,e),this.type=t.Dummy}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return""},r}(e)}.call(du)),fu.exports}var gu,yu={exports:{}},_u=yu.exports;function vu(){return gu||(gu=1,function(){yu.exports=function(){function t(t){this.nodes=t}return Object.defineProperty(t.prototype,"length",{get:function(){return this.nodes.length||0}}),t.prototype.clone=function(){return this.nodes=null},t.prototype.item=function(t){return this.nodes[t]||null},t}()}.call(_u)),yu.exports}var bu,wu={exports:{}},xu=wu.exports;function Tu(){return bu||(bu=1,function(){wu.exports={Disconnected:1,Preceding:2,Following:4,Contains:8,ContainedBy:16,ImplementationSpecific:32}}.call(xu)),wu.exports}var Eu,Nu=na.exports;function Du(){return Eu||(Eu=1,function(){var t,e,n,r,i,o,s,a,u,l,c,h,p,f,d,m,g,y={}.hasOwnProperty;g=js(),m=g.isObject,d=g.isFunction,f=g.isEmpty,p=g.getValue,a=null,n=null,r=null,i=null,o=null,c=null,h=null,l=null,s=null,e=null,u=null,t=null,na.exports=function(){function g(p){this.parent=p,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),this.value=null,this.children=[],this.baseURI=null,a||(a=ya(),n=Na(),r=Ia(),i=Sa(),o=Ja(),c=ru(),h=au(),l=hu(),s=mu(),e=sa(),u=vu(),da(),t=Tu())}return Object.defineProperty(g.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(g.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(g.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(g.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(g.prototype,"childNodes",{get:function(){return this.childNodeList&&this.childNodeList.nodes||(this.childNodeList=new u(this.children)),this.childNodeList}}),Object.defineProperty(g.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(g.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(g.prototype,"previousSibling",{get:function(){var t;return t=this.parent.children.indexOf(this),this.parent.children[t-1]||null}}),Object.defineProperty(g.prototype,"nextSibling",{get:function(){var t;return t=this.parent.children.indexOf(this),this.parent.children[t+1]||null}}),Object.defineProperty(g.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(g.prototype,"textContent",{get:function(){var t,n,r,i,o;if(this.nodeType===e.Element||this.nodeType===e.DocumentFragment){for(o="",n=0,r=(i=this.children).length;n<r;n++)(t=i[n]).textContent&&(o+=t.textContent);return o}return null},set:function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),g.prototype.setParent=function(t){var e,n,r,i,o;for(this.parent=t,t&&(this.options=t.options,this.stringify=t.stringify),o=[],n=0,r=(i=this.children).length;n<r;n++)e=i[n],o.push(e.setParent(this));return o},g.prototype.element=function(t,e,n){var r,i,o,s,a,u,l,c,h,g,_;if(u=null,null===e&&null==n&&(e=(h=[{},null])[0],n=h[1]),null==e&&(e={}),e=p(e),m(e)||(n=(g=[e,n])[0],e=g[1]),null!=t&&(t=p(t)),Array.isArray(t))for(o=0,l=t.length;o<l;o++)i=t[o],u=this.element(i);else if(d(t))u=this.element(t.apply());else if(m(t)){for(a in t)if(y.call(t,a))if(_=t[a],d(_)&&(_=_.apply()),!this.options.ignoreDecorators&&this.stringify.convertAttKey&&0===a.indexOf(this.stringify.convertAttKey))u=this.attribute(a.substr(this.stringify.convertAttKey.length),_);else if(!this.options.separateArrayItems&&Array.isArray(_)&&f(_))u=this.dummy();else if(m(_)&&f(_))u=this.element(a);else if(this.options.keepNullNodes||null!=_)if(!this.options.separateArrayItems&&Array.isArray(_))for(s=0,c=_.length;s<c;s++)i=_[s],(r={})[a]=i,u=this.element(r);else m(_)?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===a.indexOf(this.stringify.convertTextKey)?u=this.element(_):(u=this.element(a)).element(_):u=this.element(a,_);else u=this.dummy()}else u=this.options.keepNullNodes||null!==n?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===t.indexOf(this.stringify.convertTextKey)?this.text(n):!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&0===t.indexOf(this.stringify.convertCDataKey)?this.cdata(n):!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&0===t.indexOf(this.stringify.convertCommentKey)?this.comment(n):!this.options.ignoreDecorators&&this.stringify.convertRawKey&&0===t.indexOf(this.stringify.convertRawKey)?this.raw(n):!this.options.ignoreDecorators&&this.stringify.convertPIKey&&0===t.indexOf(this.stringify.convertPIKey)?this.instruction(t.substr(this.stringify.convertPIKey.length),n):this.node(t,e,n):this.dummy();if(null==u)throw new Error("Could not create any elements with: "+t+". "+this.debugInfo());return u},g.prototype.insertBefore=function(t,e,n){var r,i,o,s,a;if(null!=t?t.type:void 0)return s=e,(o=t).setParent(this),s?(i=children.indexOf(s),a=children.splice(i),children.push(o),Array.prototype.push.apply(children,a)):children.push(o),o;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(t));return i=this.parent.children.indexOf(this),a=this.parent.children.splice(i),r=this.parent.element(t,e,n),Array.prototype.push.apply(this.parent.children,a),r},g.prototype.insertAfter=function(t,e,n){var r,i,o;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(t));return i=this.parent.children.indexOf(this),o=this.parent.children.splice(i+1),r=this.parent.element(t,e,n),Array.prototype.push.apply(this.parent.children,o),r},g.prototype.remove=function(){var t;if(this.isRoot)throw new Error("Cannot remove the root element. "+this.debugInfo());return t=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[t,t-t+1].concat([])),this.parent},g.prototype.node=function(t,e,n){var r,i;return null!=t&&(t=p(t)),e||(e={}),e=p(e),m(e)||(n=(i=[e,n])[0],e=i[1]),r=new a(this,t,e),null!=n&&r.text(n),this.children.push(r),r},g.prototype.text=function(t){var e;return m(t)&&this.element(t),e=new h(this,t),this.children.push(e),this},g.prototype.cdata=function(t){var e;return e=new n(this,t),this.children.push(e),this},g.prototype.comment=function(t){var e;return e=new r(this,t),this.children.push(e),this},g.prototype.commentBefore=function(t){var e,n;return e=this.parent.children.indexOf(this),n=this.parent.children.splice(e),this.parent.comment(t),Array.prototype.push.apply(this.parent.children,n),this},g.prototype.commentAfter=function(t){var e,n;return e=this.parent.children.indexOf(this),n=this.parent.children.splice(e+1),this.parent.comment(t),Array.prototype.push.apply(this.parent.children,n),this},g.prototype.raw=function(t){var e;return e=new c(this,t),this.children.push(e),this},g.prototype.dummy=function(){return new s(this)},g.prototype.instruction=function(t,e){var n,r,i,o,s;if(null!=t&&(t=p(t)),null!=e&&(e=p(e)),Array.isArray(t))for(o=0,s=t.length;o<s;o++)n=t[o],this.instruction(n);else if(m(t))for(n in t)y.call(t,n)&&(r=t[n],this.instruction(n,r));else d(e)&&(e=e.apply()),i=new l(this,t,e),this.children.push(i);return this},g.prototype.instructionBefore=function(t,e){var n,r;return n=this.parent.children.indexOf(this),r=this.parent.children.splice(n),this.parent.instruction(t,e),Array.prototype.push.apply(this.parent.children,r),this},g.prototype.instructionAfter=function(t,e){var n,r;return n=this.parent.children.indexOf(this),r=this.parent.children.splice(n+1),this.parent.instruction(t,e),Array.prototype.push.apply(this.parent.children,r),this},g.prototype.declaration=function(t,n,r){var o,s;return o=this.document(),s=new i(o,t,n,r),0===o.children.length?o.children.unshift(s):o.children[0].type===e.Declaration?o.children[0]=s:o.children.unshift(s),o.root()||o},g.prototype.dtd=function(t,n){var r,i,s,a,u,l,c,h,p;for(r=this.document(),i=new o(r,t,n),s=a=0,l=(h=r.children).length;a<l;s=++a)if(h[s].type===e.DocType)return r.children[s]=i,i;for(s=u=0,c=(p=r.children).length;u<c;s=++u)if(p[s].isRoot)return r.children.splice(s,0,i),i;return r.children.push(i),i},g.prototype.up=function(){if(this.isRoot)throw new Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},g.prototype.root=function(){var t;for(t=this;t;){if(t.type===e.Document)return t.rootObject;if(t.isRoot)return t;t=t.parent}},g.prototype.document=function(){var t;for(t=this;t;){if(t.type===e.Document)return t;t=t.parent}},g.prototype.end=function(t){return this.document().end(t)},g.prototype.prev=function(){var t;if((t=this.parent.children.indexOf(this))<1)throw new Error("Already at the first node. "+this.debugInfo());return this.parent.children[t-1]},g.prototype.next=function(){var t;if(-1===(t=this.parent.children.indexOf(this))||t===this.parent.children.length-1)throw new Error("Already at the last node. "+this.debugInfo());return this.parent.children[t+1]},g.prototype.importDocument=function(t){var e;return(e=t.root().clone()).parent=this,e.isRoot=!1,this.children.push(e),this},g.prototype.debugInfo=function(t){var e,n;return null!=(t=t||this.name)||(null!=(e=this.parent)?e.name:void 0)?null==t?"parent: <"+this.parent.name+">":(null!=(n=this.parent)?n.name:void 0)?"node: <"+t+">, parent: <"+this.parent.name+">":"node: <"+t+">":""},g.prototype.ele=function(t,e,n){return this.element(t,e,n)},g.prototype.nod=function(t,e,n){return this.node(t,e,n)},g.prototype.txt=function(t){return this.text(t)},g.prototype.dat=function(t){return this.cdata(t)},g.prototype.com=function(t){return this.comment(t)},g.prototype.ins=function(t,e){return this.instruction(t,e)},g.prototype.doc=function(){return this.document()},g.prototype.dec=function(t,e,n){return this.declaration(t,e,n)},g.prototype.e=function(t,e,n){return this.element(t,e,n)},g.prototype.n=function(t,e,n){return this.node(t,e,n)},g.prototype.t=function(t){return this.text(t)},g.prototype.d=function(t){return this.cdata(t)},g.prototype.c=function(t){return this.comment(t)},g.prototype.r=function(t){return this.raw(t)},g.prototype.i=function(t,e){return this.instruction(t,e)},g.prototype.u=function(){return this.up()},g.prototype.importXMLBuilder=function(t){return this.importDocument(t)},g.prototype.replaceChild=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.removeChild=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.appendChild=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.hasChildNodes=function(){return 0!==this.children.length},g.prototype.cloneNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.normalize=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.isSupported=function(t,e){return!0},g.prototype.hasAttributes=function(){return 0!==this.attribs.length},g.prototype.compareDocumentPosition=function(e){var n,r;return(n=this)===e?0:this.document()!==e.document()?(r=t.Disconnected|t.ImplementationSpecific,Math.random()<.5?r|=t.Preceding:r|=t.Following,r):n.isAncestor(e)?t.Contains|t.Preceding:n.isDescendant(e)?t.Contains|t.Following:n.isPreceding(e)?t.Preceding:t.Following},g.prototype.isSameNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.lookupPrefix=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.isDefaultNamespace=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.lookupNamespaceURI=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.isEqualNode=function(t){var e,n,r;if(t.nodeType!==this.nodeType)return!1;if(t.children.length!==this.children.length)return!1;for(e=n=0,r=this.children.length-1;0<=r?n<=r:n>=r;e=0<=r?++n:--n)if(!this.children[e].isEqualNode(t.children[e]))return!1;return!0},g.prototype.getFeature=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.setUserData=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.getUserData=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.contains=function(t){return!!t&&(t===this||this.isDescendant(t))},g.prototype.isDescendant=function(t){var e,n,r,i;for(n=0,r=(i=this.children).length;n<r;n++){if(t===(e=i[n]))return!0;if(e.isDescendant(t))return!0}return!1},g.prototype.isAncestor=function(t){return t.isDescendant(this)},g.prototype.isPreceding=function(t){var e,n;return e=this.treePosition(t),n=this.treePosition(this),-1!==e&&-1!==n&&e<n},g.prototype.isFollowing=function(t){var e,n;return e=this.treePosition(t),n=this.treePosition(this),-1!==e&&-1!==n&&e>n},g.prototype.treePosition=function(t){var e,n;return n=0,e=!1,this.foreachTreeNode(this.document(),function(r){if(n++,!e&&r===t)return e=!0}),e?n:-1},g.prototype.foreachTreeNode=function(t,e){var n,r,i,o,s;for(t||(t=this.document()),r=0,i=(o=t.children).length;r<i;r++){if(s=e(n=o[r]))return s;if(s=this.foreachTreeNode(n,e))return s}},g}()}.call(Nu)),na.exports}var Ou,Au={exports:{}},Iu=Au.exports;function Cu(){return Ou||(Ou=1,function(){var t=function(t,e){return function(){return t.apply(e,arguments)}},e={}.hasOwnProperty;Au.exports=function(){function n(n){var r,i,o;for(r in this.assertLegalName=t(this.assertLegalName,this),this.assertLegalChar=t(this.assertLegalChar,this),n||(n={}),this.options=n,this.options.version||(this.options.version="1.0"),i=n.stringify||{})e.call(i,r)&&(o=i[r],this[r]=o)}return n.prototype.name=function(t){return this.options.noValidation?t:this.assertLegalName(""+t||"")},n.prototype.text=function(t){return this.options.noValidation?t:this.assertLegalChar(this.textEscape(""+t||""))},n.prototype.cdata=function(t){return this.options.noValidation?t:(t=(t=""+t||"").replace("]]>","]]]]><![CDATA[>"),this.assertLegalChar(t))},n.prototype.comment=function(t){if(this.options.noValidation)return t;if((t=""+t||"").match(/--/))throw new Error("Comment text cannot contain double-hypen: "+t);return this.assertLegalChar(t)},n.prototype.raw=function(t){return this.options.noValidation?t:""+t||""},n.prototype.attValue=function(t){return this.options.noValidation?t:this.assertLegalChar(this.attEscape(t=""+t||""))},n.prototype.insTarget=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.insValue=function(t){if(this.options.noValidation)return t;if((t=""+t||"").match(/\?>/))throw new Error("Invalid processing instruction value: "+t);return this.assertLegalChar(t)},n.prototype.xmlVersion=function(t){if(this.options.noValidation)return t;if(!(t=""+t||"").match(/1\.[0-9]+/))throw new Error("Invalid version number: "+t);return t},n.prototype.xmlEncoding=function(t){if(this.options.noValidation)return t;if(!(t=""+t||"").match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw new Error("Invalid encoding: "+t);return this.assertLegalChar(t)},n.prototype.xmlStandalone=function(t){return this.options.noValidation?t:t?"yes":"no"},n.prototype.dtdPubID=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdSysID=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdElementValue=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdAttType=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdAttDefault=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdEntityValue=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdNData=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.convertAttKey="@",n.prototype.convertPIKey="?",n.prototype.convertTextKey="#text",n.prototype.convertCDataKey="#cdata",n.prototype.convertCommentKey="#comment",n.prototype.convertRawKey="#raw",n.prototype.assertLegalChar=function(t){var e,n;if(this.options.noValidation)return t;if(e="","1.0"===this.options.version){if(e=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,n=t.match(e))throw new Error("Invalid character in string: "+t+" at index "+n.index)}else if("1.1"===this.options.version&&(e=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,n=t.match(e)))throw new Error("Invalid character in string: "+t+" at index "+n.index);return t},n.prototype.assertLegalName=function(t){var e;if(this.options.noValidation)return t;if(this.assertLegalChar(t),e=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!t.match(e))throw new Error("Invalid character in name");return t},n.prototype.textEscape=function(t){var e;return this.options.noValidation?t:(e=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,t.replace(e,"&").replace(/</g,"<").replace(/>/g,">").replace(/\r/g,"
"))},n.prototype.attEscape=function(t){var e;return this.options.noValidation?t:(e=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,t.replace(e,"&").replace(/</g,"<").replace(/"/g,""").replace(/\t/g,"	").replace(/\n/g,"
").replace(/\r/g,"
"))},n}()}.call(Iu)),Au.exports}var Mu,Pu={exports:{}},Su={exports:{}},ku={exports:{}},Fu=ku.exports;function Lu(){return Mu||(Mu=1,function(){ku.exports={None:0,OpenTag:1,InsideTag:2,CloseTag:3}}.call(Fu)),ku.exports}var ju,zu=Su.exports;function Uu(){return ju||(ju=1,function(){var t,e,n,r={}.hasOwnProperty;n=js().assign,t=sa(),Sa(),Ja(),Na(),Ia(),ya(),ru(),au(),hu(),mu(),za(),Ha(),Va(),Ka(),e=Lu(),Su.exports=function(){function i(t){var e,n,i;for(e in t||(t={}),this.options=t,n=t.writer||{})r.call(n,e)&&(i=n[e],this["_"+e]=this[e],this[e]=i)}return i.prototype.filterOptions=function(t){var r,i,o,s,a,u,l,c;return t||(t={}),t=n({},this.options,t),(r={writer:this}).pretty=t.pretty||!1,r.allowEmpty=t.allowEmpty||!1,r.indent=null!=(i=t.indent)?i:" ",r.newline=null!=(o=t.newline)?o:"\n",r.offset=null!=(s=t.offset)?s:0,r.dontPrettyTextNodes=null!=(a=null!=(u=t.dontPrettyTextNodes)?u:t.dontprettytextnodes)?a:0,r.spaceBeforeSlash=null!=(l=null!=(c=t.spaceBeforeSlash)?c:t.spacebeforeslash)?l:"",!0===r.spaceBeforeSlash&&(r.spaceBeforeSlash=" "),r.suppressPrettyCount=0,r.user={},r.state=e.None,r},i.prototype.indent=function(t,e,n){var r;return!e.pretty||e.suppressPrettyCount?"":e.pretty&&(r=(n||0)+e.offset+1)>0?new Array(r).join(e.indent):""},i.prototype.endline=function(t,e,n){return!e.pretty||e.suppressPrettyCount?"":e.newline},i.prototype.attribute=function(t,e,n){var r;return this.openAttribute(t,e,n),r=" "+t.name+'="'+t.value+'"',this.closeAttribute(t,e,n),r},i.prototype.cdata=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<![CDATA[",n.state=e.InsideTag,i+=t.value,n.state=e.CloseTag,i+="]]>"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.comment=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"\x3c!-- ",n.state=e.InsideTag,i+=t.value,n.state=e.CloseTag,i+=" --\x3e"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.declaration=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<?xml",n.state=e.InsideTag,i+=' version="'+t.version+'"',null!=t.encoding&&(i+=' encoding="'+t.encoding+'"'),null!=t.standalone&&(i+=' standalone="'+t.standalone+'"'),n.state=e.CloseTag,i+=n.spaceBeforeSlash+"?>",i+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.docType=function(t,n,r){var i,o,s,a,u;if(r||(r=0),this.openNode(t,n,r),n.state=e.OpenTag,a=this.indent(t,n,r),a+="<!DOCTYPE "+t.root().name,t.pubID&&t.sysID?a+=' PUBLIC "'+t.pubID+'" "'+t.sysID+'"':t.sysID&&(a+=' SYSTEM "'+t.sysID+'"'),t.children.length>0){for(a+=" [",a+=this.endline(t,n,r),n.state=e.InsideTag,o=0,s=(u=t.children).length;o<s;o++)i=u[o],a+=this.writeChildNode(i,n,r+1);n.state=e.CloseTag,a+="]"}return n.state=e.CloseTag,a+=n.spaceBeforeSlash+">",a+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),a},i.prototype.element=function(n,i,o){var s,a,u,l,c,h,p,f,d,m,g,y,_,v;for(d in o||(o=0),m=!1,g="",this.openNode(n,i,o),i.state=e.OpenTag,g+=this.indent(n,i,o)+"<"+n.name,y=n.attribs)r.call(y,d)&&(s=y[d],g+=this.attribute(s,i,o));if(l=0===(u=n.children.length)?null:n.children[0],0===u||n.children.every(function(e){return(e.type===t.Text||e.type===t.Raw)&&""===e.value}))i.allowEmpty?(g+=">",i.state=e.CloseTag,g+="</"+n.name+">"+this.endline(n,i,o)):(i.state=e.CloseTag,g+=i.spaceBeforeSlash+"/>"+this.endline(n,i,o));else if(!i.pretty||1!==u||l.type!==t.Text&&l.type!==t.Raw||null==l.value){if(i.dontPrettyTextNodes)for(c=0,p=(_=n.children).length;c<p;c++)if(((a=_[c]).type===t.Text||a.type===t.Raw)&&null!=a.value){i.suppressPrettyCount++,m=!0;break}for(g+=">"+this.endline(n,i,o),i.state=e.InsideTag,h=0,f=(v=n.children).length;h<f;h++)a=v[h],g+=this.writeChildNode(a,i,o+1);i.state=e.CloseTag,g+=this.indent(n,i,o)+"</"+n.name+">",m&&i.suppressPrettyCount--,g+=this.endline(n,i,o),i.state=e.None}else g+=">",i.state=e.InsideTag,i.suppressPrettyCount++,m=!0,g+=this.writeChildNode(l,i,o+1),i.suppressPrettyCount--,m=!1,i.state=e.CloseTag,g+="</"+n.name+">"+this.endline(n,i,o);return this.closeNode(n,i,o),g},i.prototype.writeChildNode=function(e,n,r){switch(e.type){case t.CData:return this.cdata(e,n,r);case t.Comment:return this.comment(e,n,r);case t.Element:return this.element(e,n,r);case t.Raw:return this.raw(e,n,r);case t.Text:return this.text(e,n,r);case t.ProcessingInstruction:return this.processingInstruction(e,n,r);case t.Dummy:return"";case t.Declaration:return this.declaration(e,n,r);case t.DocType:return this.docType(e,n,r);case t.AttributeDeclaration:return this.dtdAttList(e,n,r);case t.ElementDeclaration:return this.dtdElement(e,n,r);case t.EntityDeclaration:return this.dtdEntity(e,n,r);case t.NotationDeclaration:return this.dtdNotation(e,n,r);default:throw new Error("Unknown XML node type: "+e.constructor.name)}},i.prototype.processingInstruction=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<?",n.state=e.InsideTag,i+=t.target,t.value&&(i+=" "+t.value),n.state=e.CloseTag,i+=n.spaceBeforeSlash+"?>",i+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.raw=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r),n.state=e.InsideTag,i+=t.value,n.state=e.CloseTag,i+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.text=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r),n.state=e.InsideTag,i+=t.value,n.state=e.CloseTag,i+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.dtdAttList=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<!ATTLIST",n.state=e.InsideTag,i+=" "+t.elementName+" "+t.attributeName+" "+t.attributeType,"#DEFAULT"!==t.defaultValueType&&(i+=" "+t.defaultValueType),t.defaultValue&&(i+=' "'+t.defaultValue+'"'),n.state=e.CloseTag,i+=n.spaceBeforeSlash+">"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.dtdElement=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<!ELEMENT",n.state=e.InsideTag,i+=" "+t.name+" "+t.value,n.state=e.CloseTag,i+=n.spaceBeforeSlash+">"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.dtdEntity=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<!ENTITY",n.state=e.InsideTag,t.pe&&(i+=" %"),i+=" "+t.name,t.value?i+=' "'+t.value+'"':(t.pubID&&t.sysID?i+=' PUBLIC "'+t.pubID+'" "'+t.sysID+'"':t.sysID&&(i+=' SYSTEM "'+t.sysID+'"'),t.nData&&(i+=" NDATA "+t.nData)),n.state=e.CloseTag,i+=n.spaceBeforeSlash+">"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.dtdNotation=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<!NOTATION",n.state=e.InsideTag,i+=" "+t.name,t.pubID&&t.sysID?i+=' PUBLIC "'+t.pubID+'" "'+t.sysID+'"':t.pubID?i+=' PUBLIC "'+t.pubID+'"':t.sysID&&(i+=' SYSTEM "'+t.sysID+'"'),n.state=e.CloseTag,i+=n.spaceBeforeSlash+">"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.openNode=function(t,e,n){},i.prototype.closeNode=function(t,e,n){},i.prototype.openAttribute=function(t,e,n){},i.prototype.closeAttribute=function(t,e,n){},i}()}.call(zu)),Su.exports}var Ru,Bu=Pu.exports;function Vu(){return Ru||(Ru=1,function(){var t,e={}.hasOwnProperty;t=Uu(),Pu.exports=function(t){function n(t){n.__super__.constructor.call(this,t)}return function(t,n){for(var r in n)e.call(n,r)&&(t[r]=n[r]);function i(){this.constructor=t}i.prototype=n.prototype,t.prototype=new i,t.__super__=n.prototype}(n,t),n.prototype.document=function(t,e){var n,r,i,o,s;for(e=this.filterOptions(e),o="",r=0,i=(s=t.children).length;r<i;r++)n=s[r],o+=this.writeChildNode(n,e,0);return e.pretty&&o.slice(-e.newline.length)===e.newline&&(o=o.slice(0,-e.newline.length)),o},n}(t)}.call(Bu)),Pu.exports}var $u,Yu=$s.exports;function qu(){return $u||($u=1,function(){var t,e,n,r,i,o,s,a={}.hasOwnProperty;s=js().isPlainObject,n=Bs(),e=ta(),r=Du(),t=sa(),o=Cu(),i=Vu(),$s.exports=function(r){function u(n){u.__super__.constructor.call(this,null),this.name="#document",this.type=t.Document,this.documentURI=null,this.domConfig=new e,n||(n={}),n.writer||(n.writer=new i),this.options=n,this.stringify=new o(n)}return function(t,e){for(var n in e)a.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(u,r),Object.defineProperty(u.prototype,"implementation",{value:new n}),Object.defineProperty(u.prototype,"doctype",{get:function(){var e,n,r,i;for(n=0,r=(i=this.children).length;n<r;n++)if((e=i[n]).type===t.DocType)return e;return null}}),Object.defineProperty(u.prototype,"documentElement",{get:function(){return this.rootObject||null}}),Object.defineProperty(u.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(u.prototype,"strictErrorChecking",{get:function(){return!1}}),Object.defineProperty(u.prototype,"xmlEncoding",{get:function(){return 0!==this.children.length&&this.children[0].type===t.Declaration?this.children[0].encoding:null}}),Object.defineProperty(u.prototype,"xmlStandalone",{get:function(){return 0!==this.children.length&&this.children[0].type===t.Declaration&&"yes"===this.children[0].standalone}}),Object.defineProperty(u.prototype,"xmlVersion",{get:function(){return 0!==this.children.length&&this.children[0].type===t.Declaration?this.children[0].version:"1.0"}}),Object.defineProperty(u.prototype,"URL",{get:function(){return this.documentURI}}),Object.defineProperty(u.prototype,"origin",{get:function(){return null}}),Object.defineProperty(u.prototype,"compatMode",{get:function(){return null}}),Object.defineProperty(u.prototype,"characterSet",{get:function(){return null}}),Object.defineProperty(u.prototype,"contentType",{get:function(){return null}}),u.prototype.end=function(t){var e;return e={},t?s(t)&&(e=t,t=this.options.writer):t=this.options.writer,t.document(this,t.filterOptions(e))},u.prototype.toString=function(t){return this.options.writer.document(this,this.options.writer.filterOptions(t))},u.prototype.createElement=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createDocumentFragment=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createTextNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createComment=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createCDATASection=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createProcessingInstruction=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createAttribute=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createEntityReference=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.getElementsByTagName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.importNode=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createElementNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createAttributeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.getElementsByTagNameNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.getElementById=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.adoptNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.normalizeDocument=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.renameNode=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.getElementsByClassName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createEvent=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createRange=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createNodeIterator=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createTreeWalker=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},u}(r)}.call(Yu)),$s.exports}var Hu,Xu={exports:{}},Gu=Xu.exports;function Wu(){return Hu||(Hu=1,function(){var t,e,n,r,i,o,s,a,u,l,c,h,p,f,d,m,g,y,_,v,b,w,x,T={}.hasOwnProperty;x=js(),b=x.isObject,v=x.isFunction,w=x.isPlainObject,_=x.getValue,t=sa(),h=qu(),p=ya(),r=Na(),i=Ia(),d=ru(),y=au(),f=hu(),l=Sa(),c=Ja(),o=za(),a=Va(),s=Ha(),u=Ka(),n=ca(),g=Cu(),m=Vu(),e=Lu(),Xu.exports=function(){function x(e,n,r){var i;this.name="?xml",this.type=t.Document,e||(e={}),i={},e.writer?w(e.writer)&&(i=e.writer,e.writer=new m):e.writer=new m,this.options=e,this.writer=e.writer,this.writerOptions=this.writer.filterOptions(i),this.stringify=new g(e),this.onDataCallback=n||function(){},this.onEndCallback=r||function(){},this.currentNode=null,this.currentLevel=-1,this.openTags={},this.documentStarted=!1,this.documentCompleted=!1,this.root=null}return x.prototype.createChildNode=function(e){var n,r,i,o,s,a,u,l;switch(e.type){case t.CData:this.cdata(e.value);break;case t.Comment:this.comment(e.value);break;case t.Element:for(r in i={},u=e.attribs)T.call(u,r)&&(n=u[r],i[r]=n.value);this.node(e.name,i);break;case t.Dummy:this.dummy();break;case t.Raw:this.raw(e.value);break;case t.Text:this.text(e.value);break;case t.ProcessingInstruction:this.instruction(e.target,e.value);break;default:throw new Error("This XML node type is not supported in a JS object: "+e.constructor.name)}for(s=0,a=(l=e.children).length;s<a;s++)o=l[s],this.createChildNode(o),o.type===t.Element&&this.up();return this},x.prototype.dummy=function(){return this},x.prototype.node=function(t,e,n){var r;if(null==t)throw new Error("Missing node name.");if(this.root&&-1===this.currentLevel)throw new Error("Document can only have one root node. "+this.debugInfo(t));return this.openCurrent(),t=_(t),null==e&&(e={}),e=_(e),b(e)||(n=(r=[e,n])[0],e=r[1]),this.currentNode=new p(this,t,e),this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,null!=n&&this.text(n),this},x.prototype.element=function(e,n,r){var i,o,s,a,u,l;if(this.currentNode&&this.currentNode.type===t.DocType)this.dtdElement.apply(this,arguments);else if(Array.isArray(e)||b(e)||v(e))for(a=this.options.noValidation,this.options.noValidation=!0,(l=new h(this.options).element("TEMP_ROOT")).element(e),this.options.noValidation=a,o=0,s=(u=l.children).length;o<s;o++)i=u[o],this.createChildNode(i),i.type===t.Element&&this.up();else this.node(e,n,r);return this},x.prototype.attribute=function(t,e){var r,i;if(!this.currentNode||this.currentNode.children)throw new Error("att() can only be used immediately after an ele() call in callback mode. "+this.debugInfo(t));if(null!=t&&(t=_(t)),b(t))for(r in t)T.call(t,r)&&(i=t[r],this.attribute(r,i));else v(e)&&(e=e.apply()),this.options.keepNullAttributes&&null==e?this.currentNode.attribs[t]=new n(this,t,""):null!=e&&(this.currentNode.attribs[t]=new n(this,t,e));return this},x.prototype.text=function(t){var e;return this.openCurrent(),e=new y(this,t),this.onData(this.writer.text(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.cdata=function(t){var e;return this.openCurrent(),e=new r(this,t),this.onData(this.writer.cdata(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.comment=function(t){var e;return this.openCurrent(),e=new i(this,t),this.onData(this.writer.comment(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.raw=function(t){var e;return this.openCurrent(),e=new d(this,t),this.onData(this.writer.raw(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.instruction=function(t,e){var n,r,i,o,s;if(this.openCurrent(),null!=t&&(t=_(t)),null!=e&&(e=_(e)),Array.isArray(t))for(n=0,o=t.length;n<o;n++)r=t[n],this.instruction(r);else if(b(t))for(r in t)T.call(t,r)&&(i=t[r],this.instruction(r,i));else v(e)&&(e=e.apply()),s=new f(this,t,e),this.onData(this.writer.processingInstruction(s,this.writerOptions,this.currentLevel+1),this.currentLevel+1);return this},x.prototype.declaration=function(t,e,n){var r;if(this.openCurrent(),this.documentStarted)throw new Error("declaration() must be the first node.");return r=new l(this,t,e,n),this.onData(this.writer.declaration(r,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.doctype=function(t,e,n){if(this.openCurrent(),null==t)throw new Error("Missing root node name.");if(this.root)throw new Error("dtd() must come before the root node.");return this.currentNode=new c(this,e,n),this.currentNode.rootNodeName=t,this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,this},x.prototype.dtdElement=function(t,e){var n;return this.openCurrent(),n=new s(this,t,e),this.onData(this.writer.dtdElement(n,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.attList=function(t,e,n,r,i){var s;return this.openCurrent(),s=new o(this,t,e,n,r,i),this.onData(this.writer.dtdAttList(s,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.entity=function(t,e){var n;return this.openCurrent(),n=new a(this,!1,t,e),this.onData(this.writer.dtdEntity(n,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.pEntity=function(t,e){var n;return this.openCurrent(),n=new a(this,!0,t,e),this.onData(this.writer.dtdEntity(n,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.notation=function(t,e){var n;return this.openCurrent(),n=new u(this,t,e),this.onData(this.writer.dtdNotation(n,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.up=function(){if(this.currentLevel<0)throw new Error("The document node has no parent.");return this.currentNode?(this.currentNode.children?this.closeNode(this.currentNode):this.openNode(this.currentNode),this.currentNode=null):this.closeNode(this.openTags[this.currentLevel]),delete this.openTags[this.currentLevel],this.currentLevel--,this},x.prototype.end=function(){for(;this.currentLevel>=0;)this.up();return this.onEnd()},x.prototype.openCurrent=function(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)},x.prototype.openNode=function(n){var r,i,o,s;if(!n.isOpen){if(this.root||0!==this.currentLevel||n.type!==t.Element||(this.root=n),i="",n.type===t.Element){for(o in this.writerOptions.state=e.OpenTag,i=this.writer.indent(n,this.writerOptions,this.currentLevel)+"<"+n.name,s=n.attribs)T.call(s,o)&&(r=s[o],i+=this.writer.attribute(r,this.writerOptions,this.currentLevel));i+=(n.children?">":"/>")+this.writer.endline(n,this.writerOptions,this.currentLevel),this.writerOptions.state=e.InsideTag}else this.writerOptions.state=e.OpenTag,i=this.writer.indent(n,this.writerOptions,this.currentLevel)+"<!DOCTYPE "+n.rootNodeName,n.pubID&&n.sysID?i+=' PUBLIC "'+n.pubID+'" "'+n.sysID+'"':n.sysID&&(i+=' SYSTEM "'+n.sysID+'"'),n.children?(i+=" [",this.writerOptions.state=e.InsideTag):(this.writerOptions.state=e.CloseTag,i+=">"),i+=this.writer.endline(n,this.writerOptions,this.currentLevel);return this.onData(i,this.currentLevel),n.isOpen=!0}},x.prototype.closeNode=function(n){var r;if(!n.isClosed)return r="",this.writerOptions.state=e.CloseTag,r=n.type===t.Element?this.writer.indent(n,this.writerOptions,this.currentLevel)+"</"+n.name+">"+this.writer.endline(n,this.writerOptions,this.currentLevel):this.writer.indent(n,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(n,this.writerOptions,this.currentLevel),this.writerOptions.state=e.None,this.onData(r,this.currentLevel),n.isClosed=!0},x.prototype.onData=function(t,e){return this.documentStarted=!0,this.onDataCallback(t,e+1)},x.prototype.onEnd=function(){return this.documentCompleted=!0,this.onEndCallback()},x.prototype.debugInfo=function(t){return null==t?"":"node: <"+t+">"},x.prototype.ele=function(){return this.element.apply(this,arguments)},x.prototype.nod=function(t,e,n){return this.node(t,e,n)},x.prototype.txt=function(t){return this.text(t)},x.prototype.dat=function(t){return this.cdata(t)},x.prototype.com=function(t){return this.comment(t)},x.prototype.ins=function(t,e){return this.instruction(t,e)},x.prototype.dec=function(t,e,n){return this.declaration(t,e,n)},x.prototype.dtd=function(t,e,n){return this.doctype(t,e,n)},x.prototype.e=function(t,e,n){return this.element(t,e,n)},x.prototype.n=function(t,e,n){return this.node(t,e,n)},x.prototype.t=function(t){return this.text(t)},x.prototype.d=function(t){return this.cdata(t)},x.prototype.c=function(t){return this.comment(t)},x.prototype.r=function(t){return this.raw(t)},x.prototype.i=function(t,e){return this.instruction(t,e)},x.prototype.att=function(){return this.currentNode&&this.currentNode.type===t.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},x.prototype.a=function(){return this.currentNode&&this.currentNode.type===t.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},x.prototype.ent=function(t,e){return this.entity(t,e)},x.prototype.pent=function(t,e){return this.pEntity(t,e)},x.prototype.not=function(t,e){return this.notation(t,e)},x}()}.call(Gu)),Xu.exports}var Ku,Qu,Zu,Ju={exports:{}},tl=Ju.exports;function el(){return Ku||(Ku=1,function(){var t,e,n,r={}.hasOwnProperty;t=sa(),n=Uu(),e=Lu(),Ju.exports=function(n){function i(t,e){this.stream=t,i.__super__.constructor.call(this,e)}return function(t,e){for(var n in e)r.call(e,n)&&(t[n]=e[n]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(i,n),i.prototype.endline=function(t,n,r){return t.isLastRootNode&&n.state===e.CloseTag?"":i.__super__.endline.call(this,t,n,r)},i.prototype.document=function(t,e){var n,r,i,o,s,a,u,l,c;for(r=i=0,s=(u=t.children).length;i<s;r=++i)(n=u[r]).isLastRootNode=r===t.children.length-1;for(e=this.filterOptions(e),c=[],o=0,a=(l=t.children).length;o<a;o++)n=l[o],c.push(this.writeChildNode(n,e,0));return c},i.prototype.attribute=function(t,e,n){return this.stream.write(i.__super__.attribute.call(this,t,e,n))},i.prototype.cdata=function(t,e,n){return this.stream.write(i.__super__.cdata.call(this,t,e,n))},i.prototype.comment=function(t,e,n){return this.stream.write(i.__super__.comment.call(this,t,e,n))},i.prototype.declaration=function(t,e,n){return this.stream.write(i.__super__.declaration.call(this,t,e,n))},i.prototype.docType=function(t,n,r){var i,o,s,a;if(r||(r=0),this.openNode(t,n,r),n.state=e.OpenTag,this.stream.write(this.indent(t,n,r)),this.stream.write("<!DOCTYPE "+t.root().name),t.pubID&&t.sysID?this.stream.write(' PUBLIC "'+t.pubID+'" "'+t.sysID+'"'):t.sysID&&this.stream.write(' SYSTEM "'+t.sysID+'"'),t.children.length>0){for(this.stream.write(" ["),this.stream.write(this.endline(t,n,r)),n.state=e.InsideTag,o=0,s=(a=t.children).length;o<s;o++)i=a[o],this.writeChildNode(i,n,r+1);n.state=e.CloseTag,this.stream.write("]")}return n.state=e.CloseTag,this.stream.write(n.spaceBeforeSlash+">"),this.stream.write(this.endline(t,n,r)),n.state=e.None,this.closeNode(t,n,r)},i.prototype.element=function(n,i,o){var s,a,u,l,c,h,p,f,d;for(p in o||(o=0),this.openNode(n,i,o),i.state=e.OpenTag,this.stream.write(this.indent(n,i,o)+"<"+n.name),f=n.attribs)r.call(f,p)&&(s=f[p],this.attribute(s,i,o));if(l=0===(u=n.children.length)?null:n.children[0],0===u||n.children.every(function(e){return(e.type===t.Text||e.type===t.Raw)&&""===e.value}))i.allowEmpty?(this.stream.write(">"),i.state=e.CloseTag,this.stream.write("</"+n.name+">")):(i.state=e.CloseTag,this.stream.write(i.spaceBeforeSlash+"/>"));else if(!i.pretty||1!==u||l.type!==t.Text&&l.type!==t.Raw||null==l.value){for(this.stream.write(">"+this.endline(n,i,o)),i.state=e.InsideTag,c=0,h=(d=n.children).length;c<h;c++)a=d[c],this.writeChildNode(a,i,o+1);i.state=e.CloseTag,this.stream.write(this.indent(n,i,o)+"</"+n.name+">")}else this.stream.write(">"),i.state=e.InsideTag,i.suppressPrettyCount++,this.writeChildNode(l,i,o+1),i.suppressPrettyCount--,i.state=e.CloseTag,this.stream.write("</"+n.name+">");return this.stream.write(this.endline(n,i,o)),i.state=e.None,this.closeNode(n,i,o)},i.prototype.processingInstruction=function(t,e,n){return this.stream.write(i.__super__.processingInstruction.call(this,t,e,n))},i.prototype.raw=function(t,e,n){return this.stream.write(i.__super__.raw.call(this,t,e,n))},i.prototype.text=function(t,e,n){return this.stream.write(i.__super__.text.call(this,t,e,n))},i.prototype.dtdAttList=function(t,e,n){return this.stream.write(i.__super__.dtdAttList.call(this,t,e,n))},i.prototype.dtdElement=function(t,e,n){return this.stream.write(i.__super__.dtdElement.call(this,t,e,n))},i.prototype.dtdEntity=function(t,e,n){return this.stream.write(i.__super__.dtdEntity.call(this,t,e,n))},i.prototype.dtdNotation=function(t,e,n){return this.stream.write(i.__super__.dtdNotation.call(this,t,e,n))},i}(n)}.call(tl)),Ju.exports}function nl(){return Zu||(Zu=1,function(){var t,e,n,r,i,o={}.hasOwnProperty;Qu||(Qu=1,function(){var t,e,n,r,i,o,s,a,u,l;l=js(),a=l.assign,u=l.isFunction,n=Bs(),r=qu(),i=Wu(),s=Vu(),o=el(),t=sa(),e=Lu(),Fs.create=function(t,e,n,i){var o,s;if(null==t)throw new Error("Root element needs a name.");return i=a({},e,n,i),s=(o=new r(i)).element(t),i.headless||(o.declaration(i),null==i.pubID&&null==i.sysID||o.dtd(i)),s},Fs.begin=function(t,e,n){var o;return u(t)&&(e=(o=[t,e])[0],n=o[1],t={}),e?new i(t,e,n):new r(t)},Fs.stringWriter=function(t){return new s(t)},Fs.streamWriter=function(t,e){return new o(t,e)},Fs.implementation=new n,Fs.nodeType=t,Fs.writerState=e}.call(Fs)),t=Fs,e=Ps().defaults,r=function(t){return"string"==typeof t&&(t.indexOf("&")>=0||t.indexOf(">")>=0||t.indexOf("<")>=0)},i=function(t){return"<![CDATA["+n(t)+"]]>"},n=function(t){return t.replace("]]>","]]]]><![CDATA[>")},ks.Builder=function(){function n(t){var n,r,i;for(n in this.options={},r=e[.2])o.call(r,n)&&(i=r[n],this.options[n]=i);for(n in t)o.call(t,n)&&(i=t[n],this.options[n]=i)}return n.prototype.buildObject=function(n){var s,a,u,l,c,h;return s=this.options.attrkey,a=this.options.charkey,1===Object.keys(n).length&&this.options.rootName===e[.2].rootName?n=n[c=Object.keys(n)[0]]:c=this.options.rootName,h=this,u=function(t,e){var n,l,c,p,f,d;if("object"!=typeof e)h.options.cdata&&r(e)?t.raw(i(e)):t.txt(e);else if(Array.isArray(e)){for(p in e)if(o.call(e,p))for(f in l=e[p])c=l[f],t=u(t.ele(f),c).up()}else for(f in e)if(o.call(e,f))if(l=e[f],f===s){if("object"==typeof l)for(n in l)d=l[n],t=t.att(n,d)}else if(f===a)t=h.options.cdata&&r(l)?t.raw(i(l)):t.txt(l);else if(Array.isArray(l))for(p in l)o.call(l,p)&&(t="string"==typeof(c=l[p])?h.options.cdata&&r(c)?t.ele(f).raw(i(c)).up():t.ele(f,c).up():u(t.ele(f),c).up());else"object"==typeof l?t=u(t.ele(f),l).up():"string"==typeof l&&h.options.cdata&&r(l)?t=t.ele(f).raw(i(l)).up():(null==l&&(l=""),t=t.ele(f,l.toString()).up());return t},l=t.create(c,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),u(l,n).end(this.options.renderOpts)},n}()}.call(ks)),ks}var rl,il={},ol={};function sl(){return rl||(rl=1,function(t){!function(t){t.parser=function(t,e){return new r(t,e)},t.SAXParser=r,t.SAXStream=o,t.createStream=function(t,e){return new o(t,e)},t.MAX_BUFFER_LENGTH=65536;var e,n=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function r(e,i){if(!(this instanceof r))return new r(e,i);var o=this;!function(t){for(var e=0,r=n.length;e<r;e++)t[n[e]]=""}(o),o.q=o.c="",o.bufferCheckPosition=t.MAX_BUFFER_LENGTH,o.opt=i||{},o.opt.lowercase=o.opt.lowercase||o.opt.lowercasetags,o.looseCase=o.opt.lowercase?"toLowerCase":"toUpperCase",o.tags=[],o.closed=o.closedRoot=o.sawRoot=!1,o.tag=o.error=null,o.strict=!!e,o.noscript=!(!e&&!o.opt.noscript),o.state=E.BEGIN,o.strictEntities=o.opt.strictEntities,o.ENTITIES=o.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),o.attribList=[],o.opt.xmlns&&(o.ns=Object.create(h)),o.trackPosition=!1!==o.opt.position,o.trackPosition&&(o.position=o.line=o.column=0),D(o,"onready")}t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(t){function e(){}return e.prototype=t,new e}),Object.keys||(Object.keys=function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e}),r.prototype={end:function(){M(this)},write:function(e){var r=this;if(this.error)throw this.error;if(r.closed)return C(r,"Cannot write after close. Assign an onready handler.");if(null===e)return M(r);"object"==typeof e&&(e=e.toString());var i=0,o="";for(;o=R(e,i++),r.c=o,o;)switch(r.trackPosition&&(r.position++,"\n"===o?(r.line++,r.column=0):r.column++),r.state){case E.BEGIN:if(r.state=E.BEGIN_WHITESPACE,"\ufeff"===o)continue;U(r,o);continue;case E.BEGIN_WHITESPACE:U(r,o);continue;case E.TEXT:if(r.sawRoot&&!r.closedRoot){for(var u=i-1;o&&"<"!==o&&"&"!==o;)(o=R(e,i++))&&r.trackPosition&&(r.position++,"\n"===o?(r.line++,r.column=0):r.column++);r.textNode+=e.substring(u,i-1)}"<"!==o||r.sawRoot&&r.closedRoot&&!r.strict?(g(o)||r.sawRoot&&!r.closedRoot||P(r,"Text data outside of root node."),"&"===o?r.state=E.TEXT_ENTITY:r.textNode+=o):(r.state=E.OPEN_WAKA,r.startTagPosition=r.position);continue;case E.SCRIPT:"<"===o?r.state=E.SCRIPT_ENDING:r.script+=o;continue;case E.SCRIPT_ENDING:"/"===o?r.state=E.CLOSE_TAG:(r.script+="<"+o,r.state=E.SCRIPT);continue;case E.OPEN_WAKA:if("!"===o)r.state=E.SGML_DECL,r.sgmlDecl="";else if(g(o));else if(v(p,o))r.state=E.OPEN_TAG,r.tagName=o;else if("/"===o)r.state=E.CLOSE_TAG,r.tagName="";else if("?"===o)r.state=E.PROC_INST,r.procInstName=r.procInstBody="";else{if(P(r,"Unencoded <"),r.startTagPosition+1<r.position){var l=r.position-r.startTagPosition;o=new Array(l).join(" ")+o}r.textNode+="<"+o,r.state=E.TEXT}continue;case E.SGML_DECL:(r.sgmlDecl+o).toUpperCase()===s?(O(r,"onopencdata"),r.state=E.CDATA,r.sgmlDecl="",r.cdata=""):r.sgmlDecl+o==="--"?(r.state=E.COMMENT,r.comment="",r.sgmlDecl=""):(r.sgmlDecl+o).toUpperCase()===a?(r.state=E.DOCTYPE,(r.doctype||r.sawRoot)&&P(r,"Inappropriately located doctype declaration"),r.doctype="",r.sgmlDecl=""):">"===o?(O(r,"onsgmldeclaration",r.sgmlDecl),r.sgmlDecl="",r.state=E.TEXT):y(o)?(r.state=E.SGML_DECL_QUOTED,r.sgmlDecl+=o):r.sgmlDecl+=o;continue;case E.SGML_DECL_QUOTED:o===r.q&&(r.state=E.SGML_DECL,r.q=""),r.sgmlDecl+=o;continue;case E.DOCTYPE:">"===o?(r.state=E.TEXT,O(r,"ondoctype",r.doctype),r.doctype=!0):(r.doctype+=o,"["===o?r.state=E.DOCTYPE_DTD:y(o)&&(r.state=E.DOCTYPE_QUOTED,r.q=o));continue;case E.DOCTYPE_QUOTED:r.doctype+=o,o===r.q&&(r.q="",r.state=E.DOCTYPE);continue;case E.DOCTYPE_DTD:r.doctype+=o,"]"===o?r.state=E.DOCTYPE:y(o)&&(r.state=E.DOCTYPE_DTD_QUOTED,r.q=o);continue;case E.DOCTYPE_DTD_QUOTED:r.doctype+=o,o===r.q&&(r.state=E.DOCTYPE_DTD,r.q="");continue;case E.COMMENT:"-"===o?r.state=E.COMMENT_ENDING:r.comment+=o;continue;case E.COMMENT_ENDING:"-"===o?(r.state=E.COMMENT_ENDED,r.comment=I(r.opt,r.comment),r.comment&&O(r,"oncomment",r.comment),r.comment=""):(r.comment+="-"+o,r.state=E.COMMENT);continue;case E.COMMENT_ENDED:">"!==o?(P(r,"Malformed comment"),r.comment+="--"+o,r.state=E.COMMENT):r.state=E.TEXT;continue;case E.CDATA:"]"===o?r.state=E.CDATA_ENDING:r.cdata+=o;continue;case E.CDATA_ENDING:"]"===o?r.state=E.CDATA_ENDING_2:(r.cdata+="]"+o,r.state=E.CDATA);continue;case E.CDATA_ENDING_2:">"===o?(r.cdata&&O(r,"oncdata",r.cdata),O(r,"onclosecdata"),r.cdata="",r.state=E.TEXT):"]"===o?r.cdata+="]":(r.cdata+="]]"+o,r.state=E.CDATA);continue;case E.PROC_INST:"?"===o?r.state=E.PROC_INST_ENDING:g(o)?r.state=E.PROC_INST_BODY:r.procInstName+=o;continue;case E.PROC_INST_BODY:if(!r.procInstBody&&g(o))continue;"?"===o?r.state=E.PROC_INST_ENDING:r.procInstBody+=o;continue;case E.PROC_INST_ENDING:">"===o?(O(r,"onprocessinginstruction",{name:r.procInstName,body:r.procInstBody}),r.procInstName=r.procInstBody="",r.state=E.TEXT):(r.procInstBody+="?"+o,r.state=E.PROC_INST_BODY);continue;case E.OPEN_TAG:v(f,o)?r.tagName+=o:(S(r),">"===o?L(r):"/"===o?r.state=E.OPEN_TAG_SLASH:(g(o)||P(r,"Invalid character in tag name"),r.state=E.ATTRIB));continue;case E.OPEN_TAG_SLASH:">"===o?(L(r,!0),j(r)):(P(r,"Forward-slash in opening tag not followed by >"),r.state=E.ATTRIB);continue;case E.ATTRIB:if(g(o))continue;">"===o?L(r):"/"===o?r.state=E.OPEN_TAG_SLASH:v(p,o)?(r.attribName=o,r.attribValue="",r.state=E.ATTRIB_NAME):P(r,"Invalid attribute name");continue;case E.ATTRIB_NAME:"="===o?r.state=E.ATTRIB_VALUE:">"===o?(P(r,"Attribute without value"),r.attribValue=r.attribName,F(r),L(r)):g(o)?r.state=E.ATTRIB_NAME_SAW_WHITE:v(f,o)?r.attribName+=o:P(r,"Invalid attribute name");continue;case E.ATTRIB_NAME_SAW_WHITE:if("="===o)r.state=E.ATTRIB_VALUE;else{if(g(o))continue;P(r,"Attribute without value"),r.tag.attributes[r.attribName]="",r.attribValue="",O(r,"onattribute",{name:r.attribName,value:""}),r.attribName="",">"===o?L(r):v(p,o)?(r.attribName=o,r.state=E.ATTRIB_NAME):(P(r,"Invalid attribute name"),r.state=E.ATTRIB)}continue;case E.ATTRIB_VALUE:if(g(o))continue;y(o)?(r.q=o,r.state=E.ATTRIB_VALUE_QUOTED):(P(r,"Unquoted attribute value"),r.state=E.ATTRIB_VALUE_UNQUOTED,r.attribValue=o);continue;case E.ATTRIB_VALUE_QUOTED:if(o!==r.q){"&"===o?r.state=E.ATTRIB_VALUE_ENTITY_Q:r.attribValue+=o;continue}F(r),r.q="",r.state=E.ATTRIB_VALUE_CLOSED;continue;case E.ATTRIB_VALUE_CLOSED:g(o)?r.state=E.ATTRIB:">"===o?L(r):"/"===o?r.state=E.OPEN_TAG_SLASH:v(p,o)?(P(r,"No whitespace between attributes"),r.attribName=o,r.attribValue="",r.state=E.ATTRIB_NAME):P(r,"Invalid attribute name");continue;case E.ATTRIB_VALUE_UNQUOTED:if(!_(o)){"&"===o?r.state=E.ATTRIB_VALUE_ENTITY_U:r.attribValue+=o;continue}F(r),">"===o?L(r):r.state=E.ATTRIB;continue;case E.CLOSE_TAG:if(r.tagName)">"===o?j(r):v(f,o)?r.tagName+=o:r.script?(r.script+="</"+r.tagName,r.tagName="",r.state=E.SCRIPT):(g(o)||P(r,"Invalid tagname in closing tag"),r.state=E.CLOSE_TAG_SAW_WHITE);else{if(g(o))continue;b(p,o)?r.script?(r.script+="</"+o,r.state=E.SCRIPT):P(r,"Invalid tagname in closing tag."):r.tagName=o}continue;case E.CLOSE_TAG_SAW_WHITE:if(g(o))continue;">"===o?j(r):P(r,"Invalid characters in closing tag");continue;case E.TEXT_ENTITY:case E.ATTRIB_VALUE_ENTITY_Q:case E.ATTRIB_VALUE_ENTITY_U:var c,h;switch(r.state){case E.TEXT_ENTITY:c=E.TEXT,h="textNode";break;case E.ATTRIB_VALUE_ENTITY_Q:c=E.ATTRIB_VALUE_QUOTED,h="attribValue";break;case E.ATTRIB_VALUE_ENTITY_U:c=E.ATTRIB_VALUE_UNQUOTED,h="attribValue"}";"===o?(r[h]+=z(r),r.entity="",r.state=c):v(r.entity.length?m:d,o)?r.entity+=o:(P(r,"Invalid character in entity name"),r[h]+="&"+r.entity+o,r.entity="",r.state=c);continue;default:throw new Error(r,"Unknown state: "+r.state)}r.position>=r.bufferCheckPosition&&function(e){for(var r=Math.max(t.MAX_BUFFER_LENGTH,10),i=0,o=0,s=n.length;o<s;o++){var a=e[n[o]].length;if(a>r)switch(n[o]){case"textNode":A(e);break;case"cdata":O(e,"oncdata",e.cdata),e.cdata="";break;case"script":O(e,"onscript",e.script),e.script="";break;default:C(e,"Max buffer length exceeded: "+n[o])}i=Math.max(i,a)}var u=t.MAX_BUFFER_LENGTH-i;e.bufferCheckPosition=u+e.position}(r);return r}
|
|
2
|
+
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){!function(t){A(t),""!==t.cdata&&(O(t,"oncdata",t.cdata),t.cdata=""),""!==t.script&&(O(t,"onscript",t.script),t.script="")}(this)}};try{e=require("stream").Stream}catch(t){e=function(){}}var i=t.EVENTS.filter(function(t){return"error"!==t&&"end"!==t});function o(t,n){if(!(this instanceof o))return new o(t,n);e.apply(this),this._parser=new r(t,n),this.writable=!0,this.readable=!0;var s=this;this._parser.onend=function(){s.emit("end")},this._parser.onerror=function(t){s.emit("error",t),s._parser.error=null},this._decoder=null,i.forEach(function(t){Object.defineProperty(s,"on"+t,{get:function(){return s._parser["on"+t]},set:function(e){if(!e)return s.removeAllListeners(t),s._parser["on"+t]=e,e;s.on(t,e)},enumerable:!0,configurable:!1})})}o.prototype=Object.create(e.prototype,{constructor:{value:o}}),o.prototype.write=function(t){if("function"==typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(t)){if(!this._decoder){var e=l.default.StringDecoder;this._decoder=new e("utf8")}t=this._decoder.write(t)}return this._parser.write(t.toString()),this.emit("data",t),!0},o.prototype.end=function(t){return t&&t.length&&this.write(t),this._parser.end(),!0},o.prototype.on=function(t,n){var r=this;return r._parser["on"+t]||-1===i.indexOf(t)||(r._parser["on"+t]=function(){var e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);e.splice(0,0,t),r.emit.apply(r,e)}),e.prototype.on.call(r,t,n)};var s="[CDATA[",a="DOCTYPE",u="http://www.w3.org/XML/1998/namespace",c="http://www.w3.org/2000/xmlns/",h={xml:u,xmlns:c},p=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,f=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,d=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function g(t){return" "===t||"\n"===t||"\r"===t||"\t"===t}function y(t){return'"'===t||"'"===t}function _(t){return">"===t||g(t)}function v(t,e){return t.test(e)}function b(t,e){return!v(t,e)}var w,x,T,E=0;for(var N in t.STATE={BEGIN:E++,BEGIN_WHITESPACE:E++,TEXT:E++,TEXT_ENTITY:E++,OPEN_WAKA:E++,SGML_DECL:E++,SGML_DECL_QUOTED:E++,DOCTYPE:E++,DOCTYPE_QUOTED:E++,DOCTYPE_DTD:E++,DOCTYPE_DTD_QUOTED:E++,COMMENT_STARTING:E++,COMMENT:E++,COMMENT_ENDING:E++,COMMENT_ENDED:E++,CDATA:E++,CDATA_ENDING:E++,CDATA_ENDING_2:E++,PROC_INST:E++,PROC_INST_BODY:E++,PROC_INST_ENDING:E++,OPEN_TAG:E++,OPEN_TAG_SLASH:E++,ATTRIB:E++,ATTRIB_NAME:E++,ATTRIB_NAME_SAW_WHITE:E++,ATTRIB_VALUE:E++,ATTRIB_VALUE_QUOTED:E++,ATTRIB_VALUE_CLOSED:E++,ATTRIB_VALUE_UNQUOTED:E++,ATTRIB_VALUE_ENTITY_Q:E++,ATTRIB_VALUE_ENTITY_U:E++,CLOSE_TAG:E++,CLOSE_TAG_SAW_WHITE:E++,SCRIPT:E++,SCRIPT_ENDING:E++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(e){var n=t.ENTITIES[e],r="number"==typeof n?String.fromCharCode(n):n;t.ENTITIES[e]=r}),t.STATE)t.STATE[t.STATE[N]]=N;function D(t,e,n){t[e]&&t[e](n)}function O(t,e,n){t.textNode&&A(t),D(t,e,n)}function A(t){t.textNode=I(t.opt,t.textNode),t.textNode&&D(t,"ontext",t.textNode),t.textNode=""}function I(t,e){return t.trim&&(e=e.trim()),t.normalize&&(e=e.replace(/\s+/g," ")),e}function C(t,e){return A(t),t.trackPosition&&(e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c),e=new Error(e),t.error=e,D(t,"onerror",e),t}function M(t){return t.sawRoot&&!t.closedRoot&&P(t,"Unclosed root tag"),t.state!==E.BEGIN&&t.state!==E.BEGIN_WHITESPACE&&t.state!==E.TEXT&&C(t,"Unexpected end"),A(t),t.c="",t.closed=!0,D(t,"onend"),r.call(t,t.strict,t.opt),t}function P(t,e){if("object"!=typeof t||!(t instanceof r))throw new Error("bad call to strictFail");t.strict&&C(t,e)}function S(t){t.strict||(t.tagName=t.tagName[t.looseCase]());var e=t.tags[t.tags.length-1]||t,n=t.tag={name:t.tagName,attributes:{}};t.opt.xmlns&&(n.ns=e.ns),t.attribList.length=0,O(t,"onopentagstart",n)}function k(t,e){var n=t.indexOf(":")<0?["",t]:t.split(":"),r=n[0],i=n[1];return e&&"xmlns"===t&&(r="xmlns",i=""),{prefix:r,local:i}}function F(t){if(t.strict||(t.attribName=t.attribName[t.looseCase]()),-1!==t.attribList.indexOf(t.attribName)||t.tag.attributes.hasOwnProperty(t.attribName))t.attribName=t.attribValue="";else{if(t.opt.xmlns){var e=k(t.attribName,!0),n=e.prefix,r=e.local;if("xmlns"===n)if("xml"===r&&t.attribValue!==u)P(t,"xml: prefix must be bound to "+u+"\nActual: "+t.attribValue);else if("xmlns"===r&&t.attribValue!==c)P(t,"xmlns: prefix must be bound to "+c+"\nActual: "+t.attribValue);else{var i=t.tag,o=t.tags[t.tags.length-1]||t;i.ns===o.ns&&(i.ns=Object.create(o.ns)),i.ns[r]=t.attribValue}t.attribList.push([t.attribName,t.attribValue])}else t.tag.attributes[t.attribName]=t.attribValue,O(t,"onattribute",{name:t.attribName,value:t.attribValue});t.attribName=t.attribValue=""}}function L(t,e){if(t.opt.xmlns){var n=t.tag,r=k(t.tagName);n.prefix=r.prefix,n.local=r.local,n.uri=n.ns[r.prefix]||"",n.prefix&&!n.uri&&(P(t,"Unbound namespace prefix: "+JSON.stringify(t.tagName)),n.uri=r.prefix);var i=t.tags[t.tags.length-1]||t;n.ns&&i.ns!==n.ns&&Object.keys(n.ns).forEach(function(e){O(t,"onopennamespace",{prefix:e,uri:n.ns[e]})});for(var o=0,s=t.attribList.length;o<s;o++){var a=t.attribList[o],u=a[0],l=a[1],c=k(u,!0),h=c.prefix,p=c.local,f=""===h?"":n.ns[h]||"",d={name:u,value:l,prefix:h,local:p,uri:f};h&&"xmlns"!==h&&!f&&(P(t,"Unbound namespace prefix: "+JSON.stringify(h)),d.uri=h),t.tag.attributes[u]=d,O(t,"onattribute",d)}t.attribList.length=0}t.tag.isSelfClosing=!!e,t.sawRoot=!0,t.tags.push(t.tag),O(t,"onopentag",t.tag),e||(t.noscript||"script"!==t.tagName.toLowerCase()?t.state=E.TEXT:t.state=E.SCRIPT,t.tag=null,t.tagName=""),t.attribName=t.attribValue="",t.attribList.length=0}function j(t){if(!t.tagName)return P(t,"Weird empty close tag."),t.textNode+="</>",void(t.state=E.TEXT);if(t.script){if("script"!==t.tagName)return t.script+="</"+t.tagName+">",t.tagName="",void(t.state=E.SCRIPT);O(t,"onscript",t.script),t.script=""}var e=t.tags.length,n=t.tagName;t.strict||(n=n[t.looseCase]());for(var r=n;e--;){if(t.tags[e].name===r)break;P(t,"Unexpected close tag")}if(e<0)return P(t,"Unmatched closing tag: "+t.tagName),t.textNode+="</"+t.tagName+">",void(t.state=E.TEXT);t.tagName=n;for(var i=t.tags.length;i-- >e;){var o=t.tag=t.tags.pop();t.tagName=t.tag.name,O(t,"onclosetag",t.tagName);var s={};for(var a in o.ns)s[a]=o.ns[a];var u=t.tags[t.tags.length-1]||t;t.opt.xmlns&&o.ns!==u.ns&&Object.keys(o.ns).forEach(function(e){var n=o.ns[e];O(t,"onclosenamespace",{prefix:e,uri:n})})}0===e&&(t.closedRoot=!0),t.tagName=t.attribValue=t.attribName="",t.attribList.length=0,t.state=E.TEXT}function z(t){var e,n=t.entity,r=n.toLowerCase(),i="";return t.ENTITIES[n]?t.ENTITIES[n]:t.ENTITIES[r]?t.ENTITIES[r]:("#"===(n=r).charAt(0)&&("x"===n.charAt(1)?(n=n.slice(2),i=(e=parseInt(n,16)).toString(16)):(n=n.slice(1),i=(e=parseInt(n,10)).toString(10))),n=n.replace(/^0+/,""),isNaN(e)||i.toLowerCase()!==n?(P(t,"Invalid character entity"),"&"+t.entity+";"):String.fromCodePoint(e))}function U(t,e){"<"===e?(t.state=E.OPEN_WAKA,t.startTagPosition=t.position):g(e)||(P(t,"Non-whitespace before first tag."),t.textNode=e,t.state=E.TEXT)}function R(t,e){var n="";return e<t.length&&(n=t.charAt(e)),n}E=t.STATE,String.fromCodePoint||(w=String.fromCharCode,x=Math.floor,T=function(){var t,e,n=[],r=-1,i=arguments.length;if(!i)return"";for(var o="";++r<i;){var s=Number(arguments[r]);if(!isFinite(s)||s<0||s>1114111||x(s)!==s)throw RangeError("Invalid code point: "+s);s<=65535?n.push(s):(t=55296+((s-=65536)>>10),e=s%1024+56320,n.push(t,e)),(r+1===i||n.length>16384)&&(o+=w.apply(null,n),n.length=0)}return o},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:T,configurable:!0,writable:!0}):String.fromCodePoint=T)}(t)}(ol)),ol}var al,ul={};function ll(){return al||(al=1,function(){ul.stripBOM=function(t){return"\ufeff"===t[0]?t.substring(1):t}}.call(ul)),ul}var cl,hl,pl,fl={};function dl(){return cl||(cl=1,function(){var t;t=new RegExp(/(?!xmlns)^.*:/),fl.normalize=function(t){return t.toLowerCase()},fl.firstCharLowerCase=function(t){return t.charAt(0).toLowerCase()+t.slice(1)},fl.stripPrefix=function(e){return e.replace(t,"")},fl.parseNumbers=function(t){return isNaN(t)||(t=t%1==0?parseInt(t,10):parseFloat(t)),t},fl.parseBooleans=function(t){return/^(?:true|false)$/i.test(t)&&(t="true"===t.toLowerCase()),t}}.call(fl)),fl}function ml(){return hl||(hl=1,function(t){(function(){var e,n,r,i,o,s,a,u,l,p=function(t,e){return function(){return t.apply(e,arguments)}},f={}.hasOwnProperty;u=sl(),i=c.default,e=ll(),a=dl(),l=h.default.setImmediate,n=Ps().defaults,o=function(t){return"object"==typeof t&&null!=t&&0===Object.keys(t).length},s=function(t,e,n){var r,i;for(r=0,i=t.length;r<i;r++)e=(0,t[r])(e,n);return e},r=function(t,e,n){var r;return(r=Object.create(null)).value=n,r.writable=!0,r.enumerable=!0,r.configurable=!0,Object.defineProperty(t,e,r)},t.Parser=function(i){function c(e){var r,i,o;if(this.parseStringPromise=p(this.parseStringPromise,this),this.parseString=p(this.parseString,this),this.reset=p(this.reset,this),this.assignOrPush=p(this.assignOrPush,this),this.processAsync=p(this.processAsync,this),!(this instanceof t.Parser))return new t.Parser(e);for(r in this.options={},i=n[.2])f.call(i,r)&&(o=i[r],this.options[r]=o);for(r in e)f.call(e,r)&&(o=e[r],this.options[r]=o);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(a.normalize)),this.reset()}return function(t,e){for(var n in e)f.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(c,i),c.prototype.processAsync=function(){var t,e;try{return this.remaining.length<=this.options.chunkSize?(t=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(t),this.saxParser.close()):(t=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(t),l(this.processAsync))}catch(t){if(e=t,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(e)}},c.prototype.assignOrPush=function(t,e,n){return e in t?(t[e]instanceof Array||r(t,e,[t[e]]),t[e].push(n)):this.options.explicitArray?r(t,e,[n]):r(t,e,n)},c.prototype.reset=function(){var t,e,n,i,a;return this.removeAllListeners(),this.saxParser=u.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=(a=this,function(t){if(a.saxParser.resume(),!a.saxParser.errThrown)return a.saxParser.errThrown=!0,a.emit("error",t)}),this.saxParser.onend=function(t){return function(){if(!t.saxParser.ended)return t.saxParser.ended=!0,t.emit("end",t.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,i=[],t=this.options.attrkey,e=this.options.charkey,this.saxParser.onopentag=function(n){return function(o){var a,u,l,c,h;if((l={})[e]="",!n.options.ignoreAttrs)for(a in h=o.attributes)f.call(h,a)&&(t in l||n.options.mergeAttrs||(l[t]={}),u=n.options.attrValueProcessors?s(n.options.attrValueProcessors,o.attributes[a],a):o.attributes[a],c=n.options.attrNameProcessors?s(n.options.attrNameProcessors,a):a,n.options.mergeAttrs?n.assignOrPush(l,c,u):r(l[t],c,u));return l["#name"]=n.options.tagNameProcessors?s(n.options.tagNameProcessors,o.name):o.name,n.options.xmlns&&(l[n.options.xmlnskey]={uri:o.uri,local:o.local}),i.push(l)}}(this),this.saxParser.onclosetag=function(t){return function(){var n,a,u,l,c,h,p,d,m,g;if(h=i.pop(),c=h["#name"],t.options.explicitChildren&&t.options.preserveChildrenOrder||delete h["#name"],!0===h.cdata&&(n=h.cdata,delete h.cdata),m=i[i.length-1],h[e].match(/^\s*$/)&&!n?(a=h[e],delete h[e]):(t.options.trim&&(h[e]=h[e].trim()),t.options.normalize&&(h[e]=h[e].replace(/\s{2,}/g," ").trim()),h[e]=t.options.valueProcessors?s(t.options.valueProcessors,h[e],c):h[e],1===Object.keys(h).length&&e in h&&!t.EXPLICIT_CHARKEY&&(h=h[e])),o(h)&&(h="function"==typeof t.options.emptyTag?t.options.emptyTag():""!==t.options.emptyTag?t.options.emptyTag:a),null!=t.options.validator&&(g="/"+function(){var t,e,n;for(n=[],t=0,e=i.length;t<e;t++)l=i[t],n.push(l["#name"]);return n}().concat(c).join("/"),function(){var e;try{return h=t.options.validator(g,m&&m[c],h)}catch(n){return e=n,t.emit("error",e)}}()),t.options.explicitChildren&&!t.options.mergeAttrs&&"object"==typeof h)if(t.options.preserveChildrenOrder){if(m){for(u in m[t.options.childkey]=m[t.options.childkey]||[],p={},h)f.call(h,u)&&r(p,u,h[u]);m[t.options.childkey].push(p),delete h["#name"],1===Object.keys(h).length&&e in h&&!t.EXPLICIT_CHARKEY&&(h=h[e])}}else l={},t.options.attrkey in h&&(l[t.options.attrkey]=h[t.options.attrkey],delete h[t.options.attrkey]),!t.options.charsAsChildren&&t.options.charkey in h&&(l[t.options.charkey]=h[t.options.charkey],delete h[t.options.charkey]),Object.getOwnPropertyNames(h).length>0&&(l[t.options.childkey]=h),h=l;return i.length>0?t.assignOrPush(m,c,h):(t.options.explicitRoot&&(d=h,r(h={},c,d)),t.resultObject=h,t.saxParser.ended=!0,t.emit("end",t.resultObject))}}(this),n=function(t){return function(n){var r,o;if(o=i[i.length-1])return o[e]+=n,t.options.explicitChildren&&t.options.preserveChildrenOrder&&t.options.charsAsChildren&&(t.options.includeWhiteChars||""!==n.replace(/\\n/g,"").trim())&&(o[t.options.childkey]=o[t.options.childkey]||[],(r={"#name":"__text__"})[e]=n,t.options.normalize&&(r[e]=r[e].replace(/\s{2,}/g," ").trim()),o[t.options.childkey].push(r)),o}}(this),this.saxParser.ontext=n,this.saxParser.oncdata=function(t){var e;if(e=n(t))return e.cdata=!0}},c.prototype.parseString=function(t,n){var r;null!=n&&"function"==typeof n&&(this.on("end",function(t){return this.reset(),n(null,t)}),this.on("error",function(t){return this.reset(),n(t)}));try{return""===(t=t.toString()).trim()?(this.emit("end",null),!0):(t=e.stripBOM(t),this.options.async?(this.remaining=t,l(this.processAsync),this.saxParser):this.saxParser.write(t).close())}catch(t){if(r=t,!this.saxParser.errThrown&&!this.saxParser.ended)return this.emit("error",r),this.saxParser.errThrown=!0;if(this.saxParser.ended)throw r}},c.prototype.parseStringPromise=function(t){return new Promise((e=this,function(n,r){return e.parseString(t,function(t,e){return t?r(t):n(e)})}));var e},c}(i),t.parseString=function(e,n,r){var i,o;return null!=r?("function"==typeof r&&(i=r),"object"==typeof n&&(o=n)):("function"==typeof n&&(i=n),o={}),new t.Parser(o).parseString(e,i)},t.parseStringPromise=function(e,n){var r;return"object"==typeof n&&(r=n),new t.Parser(r).parseStringPromise(e)}}).call(il)}(il)),il}var gl=(pl||(pl=1,function(){var t,e,n,r,i={}.hasOwnProperty;e=Ps(),t=nl(),n=ml(),r=dl(),Cs.defaults=e.defaults,Cs.processors=r,Cs.ValidationError=function(){function t(t){this.message=t}return function(t,e){for(var n in e)i.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(t,Error),t}(),Cs.Builder=t.Builder,Cs.Parser=n.Parser,Cs.parseString=n.parseString,Cs.parseStringPromise=n.parseStringPromise}.call(Cs)),Cs);function yl(t){return!u.has(t,"children")}function _l(t,e,n){let r=[];return function i(o){yl(o)?e&&o!=t&&r.push(o):(n&&o!=t&&r.push(o),o.children.forEach(i))}(t),r}var vl=Object.freeze({__proto__:null,graftANode:function(t,e,n,r){let i=this.nodes.descendants();if(t.parent){if(i.indexOf(t)>=0){let i=t.parent.children.indexOf(t),o={name:n,parent:t.parent,attribute:r?r[2]:null,original_child_order:t.original_child_order},s={name:e,parent:o,attribute:r?r[1]:null,original_child_order:2};o.children=[t,s],t.parent.children[i]=o,t.parent=o,t.attribute=r?r[0]:null,t.original_child_order=1}}return this},addChild:function(t,e){return t.children?t.children.push(e):t.children=[e],t},createNode:function(t,e){return{data:{name:t,attribute:e?e[1]:null},parent:""}},deleteANode:function(t){let e=this.nodes.descendants();if("number"!=typeof t)return this.deleteANode(e.indexOf(t));if(t>0&&t<e.length){let n=e[t];if(n.parent){let r=n.parent.children.indexOf(n);r>=0&&(e.splice(t,1),n.children&&n.children.forEach(function(t){t.original_child_order=n.parent.children.length,n.parent.children.push(t),t.parent=n.parent}),n.parent.children.length>2?n.parent.children.splice(r,1):n.parent.parent?(n.parent.parent.children[n.parent.parent.children.indexOf(n.parent)]=n.parent.children[1-r],n.parent.children[1-r].parent=n.parent.parent,e.splice(e.indexOf(n.parent),1)):(e.splice(0,1),e.parent=null,delete e.data.attribute,delete e.data.annotation,delete e.data.original_child_order,e.name="root",e.data.name="root"))}}return this},getTips:function(){return u.filter(this.nodes.descendants(),t=>!u.has(t,"children"))},getInternals:function(){return u.filter(this.nodes.descendants(),t=>u.has(t,"children"))},getRootNode:function(){return this.nodes},getNodes:function(){return this.nodes},getNodeByName:function(t){return u.filter(this.nodes.descendants(),e=>e.data.name==t)[0]},assignAttributes:function(t){u.each(this.nodes.descendants(),function(e){e.data&&e.data.name in t&&(e.annotations=t[e.data.name])})},isLeafNode:yl,updateKeyName:function(t,e){return this.nodes.each(function(n){t in n&&(e&&(n[e]=n[t]),delete n[t])}),this},clearInternalNodes:function(t){t||this.nodes.each(t=>{yl(t)||(t[this.selection_attribute_name]=!1,t.data.traits||(t.data.traits={}),t.data.traits[this.selection_attribute_name]=t[this.selection_attribute_name])})},selectAllDescendants:_l});function bl(t,e={}){const n=/^-?\d+(\.\d+)?$/;let r=e.left_delimiter||"{",i=e.right_delimiter||"}",o=[];function s(){let t=o[o.length-1];"children"in t||(t.children=[]),o.push({name:null}),t.children.push(o[o.length-1]),o[o.length-1].original_child_order=t.children.length}function a(){let t=o.pop();t.name=c,"children"in t?t.bootstrap_values=c:t.name=c,t.attribute=h,"["==r&&p.includes("&&NHX")?p.split(":").slice(1).forEach(e=>{const[r,i]=e.split("=");t[r]=n.test(i)?+i:i}):t.annotation=p,c="",h="",p=""}function u(e){return{json:null,error:"Unexpected '"+t[e]+"' in '"+t.substring(e-20,e+1)+"[ERROR HERE]"+t.substring(e+1,e+20)+"'"}}let l=0,c="",h="",p="",f=null,d={"'":1,'"':1},m={name:"root"};o.push(m);for(var g=/\s/,y=0;y<t.length;y++)try{var _=t[y];switch(l){case 0:"("==_&&(s(),l=1);break;case 1:case 3:if(":"==_)l=3;else if(","==_||")"==_)try{a(),l=1,","==_&&s()}catch(t){return u(y)}else if("("==_){if(c.length>0)return u(y);s()}else{if(_ in d){if(1==l&&0===c.length&&0===h.length&&0===p.length){l=2,f=_;continue}return u(y)}if(_==r){if(p.length)return u(y);l=4}else if(3==l)h+=_;else{if(g.test(_))continue;if(";"==_){y=t.length;break}c+=_}}break;case 2:if(_==f){if(y<t.length-1&&t[y+1]==f){y++,c+=f;continue}f=0,l=1;continue}c+=_;break;case 4:if(_==i)l=3;else{if(_==r)return u(y);p+=_}}}catch(t){return u(y)}return 1!=o.length?u(t.length-1):{json:m,error:null}}function wl(t,e){let n=this;t||(t=t=>"");let r=[];return t=t||"",function e(i){if(i.notshown)return;if(yl(i)||(r.push("("),i.children.forEach(function(t,n){n&&r.push(","),e(t)}),r.push(")")),"root"!==i.data.name){const t=i.data.name.replaceAll("'","''");/\W/.test(t)?r.push("'"+t+"'"):r.push(t)}r.push(t(i));let o=n.branch_length_accessor(i);void 0!==o&&r.push(":"+o)}(e||this.nodes),r.join("")+";"}function xl(t){let e=t,n=e.toUpperCase().indexOf("BEGIN DATA;"),r=e.slice(n);if(r.length<2)return"";n=r.toUpperCase().indexOf("END;");let i=r.slice(0,n);r=u.map(i.split(";"),t=>t.trim());let o=u.filter(r,t=>t.toUpperCase().startsWith("DIMENSION"));o=o[0].split(" "),o=u.object(u.map(u.rest(o),t=>t.split("=")));let s=u.filter(r,t=>t.toUpperCase().startsWith("FORMAT"));s=s[0].split(" "),s=u.object(u.map(u.rest(s),t=>t.split("="))),s.symbols=u.reject(s.symbols.split(""),t=>'"'==t);let a=u.filter(r,t=>t.toUpperCase().startsWith("MATRIX"));return a=a[0].split("\n"),a=u.object(u.map(u.rest(a),t=>u.compact(t.split(" ")))),a=u.mapObject(a,(t,e)=>"?"==t?s.symbols:Array(t)),{dimensions:o,format:s,matrix:a}}function Tl(t,e,n){u.each(t.getTips(),t=>{t.data.test=n.matrix[t.data.name]})}function El(t){let e=t,n=e.toUpperCase().indexOf("BEGIN TREES;"),r=e.slice(n);if(r.length<2)return"";n=r.toUpperCase().indexOf("END;");let i=r.slice(0,n).split("\n");return i=u.filter(i,t=>t.trim().toUpperCase().startsWith("TREE")),bl(i[0])}var Nl=Object.freeze({__proto__:null,parseAnnotations:xl,loadAnnotations:Tl,default:El});const Dl=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Ol=new RegExp("^"+("["+Dl+"]["+(Dl+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040")+"]*")+"$");function Al(t,e){const n=[];let r=e.exec(t);for(;r;){const i=[];i.startIndex=e.lastIndex-r[0].length;const o=r.length;for(let t=0;t<o;t++)i.push(r[t]);n.push(i),r=e.exec(t)}return n}const Il=function(t){const e=Ol.exec(t);return!(null==e)};const Cl={allowBooleanAttributes:!1,unpairedTags:[]};function Ml(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function Pl(t,e){const n=e;for(;e<t.length;e++)if("?"==t[e]||" "==t[e]){const r=t.substr(n,e-n);if(e>5&&"xml"===r)return Rl("InvalidXml","XML declaration allowed only at the start of the document.",$l(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}continue}return e}function Sl(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){let n=1;for(e+=8;e<t.length;e++)if("<"===t[e])n++;else if(">"===t[e]&&(n--,0===n))break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}const kl='"',Fl="'";function Ll(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===kl||t[e]===Fl)""===r?r=t[e]:r!==t[e]||(r="");else if(">"===t[e]&&""===r){i=!0;break}n+=t[e]}return""===r&&{value:n,index:e,tagClosed:i}}const jl=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function zl(t,e){const n=Al(t,jl),r={};for(let t=0;t<n.length;t++){if(0===n[t][1].length)return Rl("InvalidAttr","Attribute '"+n[t][2]+"' has no space in starting.",Yl(n[t]));if(void 0!==n[t][3]&&void 0===n[t][4])return Rl("InvalidAttr","Attribute '"+n[t][2]+"' is without value.",Yl(n[t]));if(void 0===n[t][3]&&!e.allowBooleanAttributes)return Rl("InvalidAttr","boolean attribute '"+n[t][2]+"' is not allowed.",Yl(n[t]));const i=n[t][2];if(!Bl(i))return Rl("InvalidAttr","Attribute '"+i+"' is an invalid name.",Yl(n[t]));if(r.hasOwnProperty(i))return Rl("InvalidAttr","Attribute '"+i+"' is repeated.",Yl(n[t]));r[i]=1}return!0}function Ul(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){let n=/\d/;for("x"===t[e]&&(e++,n=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(n))break}return-1}(t,++e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(";"===t[e])break;return-1}return e}function Rl(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function Bl(t){return Il(t)}function Vl(t){return Il(t)}function $l(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function Yl(t){return t.startIndex+t[1].length}const ql={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,n){return t},captureMetaData:!1};let Hl;Hl="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class Xl{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t,e){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),void 0!==e&&(this.child[this.child.length-1][Hl]={startIndex:e})}static getMetaDataSymbol(){return Hl}}function Gl(t,e){const n={};if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let r=1,i=!1,o=!1,s="";for(;e<t.length;e++)if("<"!==t[e]||o)if(">"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=!1,r--):r--,0===r)break}else"["===t[e]?i=!0:s+=t[e];else{if(i&&tc(t,"!ENTITY",e)){let r,i;e+=7,[r,i,e]=Kl(t,e+1),-1===i.indexOf("&")&&(n[r]={regx:RegExp(`&${r};`,"g"),val:i})}else if(i&&tc(t,"!ELEMENT",e)){e+=8;const{index:n}=Jl(t,e+1);e=n}else if(i&&tc(t,"!ATTLIST",e))e+=8;else if(i&&tc(t,"!NOTATION",e)){e+=9;const{index:n}=Ql(t,e+1);e=n}else{if(!tc(t,"!--",e))throw new Error("Invalid DOCTYPE");o=!0}r++,s=""}if(0!==r)throw new Error("Unclosed DOCTYPE")}return{entities:n,i:e}}const Wl=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function Kl(t,e){e=Wl(t,e);let n="";for(;e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)n+=t[e],e++;if(ec(n),e=Wl(t,e),"SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported");let r="";return[e,r]=Zl(t,e,"entity"),[n,r,--e]}function Ql(t,e){e=Wl(t,e);let n="";for(;e<t.length&&!/\s/.test(t[e]);)n+=t[e],e++;ec(n),e=Wl(t,e);const r=t.substring(e,e+6).toUpperCase();if("SYSTEM"!==r&&"PUBLIC"!==r)throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);e+=r.length,e=Wl(t,e);let i=null,o=null;if("PUBLIC"===r)[e,i]=Zl(t,e,"publicIdentifier"),'"'!==t[e=Wl(t,e)]&&"'"!==t[e]||([e,o]=Zl(t,e,"systemIdentifier"));else if("SYSTEM"===r&&([e,o]=Zl(t,e,"systemIdentifier"),!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:i,systemIdentifier:o,index:--e}}function Zl(t,e,n){let r="";const i=t[e];if('"'!==i&&"'"!==i)throw new Error(`Expected quoted string, found "${i}"`);for(e++;e<t.length&&t[e]!==i;)r+=t[e],e++;if(t[e]!==i)throw new Error(`Unterminated ${n} value`);return[++e,r]}function Jl(t,e){e=Wl(t,e);let n="";for(;e<t.length&&!/\s/.test(t[e]);)n+=t[e],e++;if(!ec(n))throw new Error(`Invalid element name: "${n}"`);let r="";if("E"===t[e=Wl(t,e)]&&tc(t,"MPTY",e))e+=4;else if("A"===t[e]&&tc(t,"NY",e))e+=2;else{if("("!==t[e])throw new Error(`Invalid Element Expression, found "${t[e]}"`);for(e++;e<t.length&&")"!==t[e];)r+=t[e],e++;if(")"!==t[e])throw new Error("Unterminated content model")}return{elementName:n,contentModel:r.trim(),index:e}}function tc(t,e,n){for(let r=0;r<e.length;r++)if(e[r]!==t[n+r+1])return!1;return!0}function ec(t){if(Il(t))return t;throw new Error(`Invalid entity name ${t}`)}const nc=/^[-+]?0x[a-fA-F0-9]+$/,rc=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,ic={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function oc(t,e={}){if(e=Object.assign({},ic,e),!t||"string"!=typeof t)return t;let n=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(n))return t;if("0"===t)return 0;if(e.hex&&nc.test(n))return function(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(n,16);if(-1!==n.search(/.+[eE].+/))return function(t,e,n){if(!n.eNotation)return t;const r=e.match(sc);if(r){let i=r[1]||"";const o=-1===r[3].indexOf("e")?"E":"e",s=r[2],a=i?t[s.length+1]===o:t[s.length]===o;return s.length>1&&a?t:1!==s.length||!r[3].startsWith(`.${o}`)&&r[3][0]!==o?n.leadingZeros&&!a?(e=(r[1]||"")+r[3],Number(e)):t:Number(e)}return t}(t,n,e);{const r=rc.exec(n);if(r){const i=r[1]||"",o=r[2];let s=function(t){if(t&&-1!==t.indexOf("."))return"."===(t=t.replace(/0+$/,""))?t="0":"."===t[0]?t="0"+t:"."===t[t.length-1]&&(t=t.substring(0,t.length-1)),t;return t}(r[3]);const a=i?"."===t[o.length+1]:"."===t[o.length];if(!e.leadingZeros&&(o.length>1||1===o.length&&!a))return t;{const r=Number(n),a=String(r);if(0===r)return r;if(-1!==a.search(/[eE]/))return e.eNotation?r:t;if(-1!==n.indexOf("."))return"0"===a||a===s||a===`${i}${s}`?r:t;let u=o?s:n;return o?u===a||i+u===a?r:t:u===a||u===i+a?r:t}}return t}}const sc=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;class ac{constructor(t){var e;this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,e)=>String.fromCodePoint(Number.parseInt(e,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,e)=>String.fromCodePoint(Number.parseInt(e,16))}},this.addExternalEntities=uc,this.parseXml=fc,this.parseTextData=lc,this.resolveNameSpace=cc,this.buildAttributesMap=pc,this.isItStopNode=yc,this.replaceEntitiesValue=mc,this.readStopNodeData=bc,this.saveTextToParentTag=gc,this.addChild=dc,this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const n of e){if("string"==typeof n&&t===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}}:()=>!1}}function uc(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:t[r]}}}function lc(t,e,n,r,i,o,s){if(void 0!==t&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t));const r=this.options.tagValueProcessor(e,t,n,i,o);if(null==r)return t;if(typeof r!=typeof t||r!==t)return r;if(this.options.trimValues)return wc(t,this.options.parseTagValue,this.options.numberParseOptions);return t.trim()===t?wc(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function cc(t){if(this.options.removeNSPrefix){const e=t.split(":"),n="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=n+e[1])}return t}const hc=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function pc(t,e,n){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){const n=Al(t,hc),r=n.length,i={};for(let t=0;t<r;t++){const r=this.resolveNameSpace(n[t][1]);if(this.ignoreAttributesFn(r,e))continue;let o=n[t][4],s=this.options.attributeNamePrefix+r;if(r.length)if(this.options.transformAttributeName&&(s=this.options.transformAttributeName(s)),"__proto__"===s&&(s="#__proto__"),void 0!==o){this.options.trimValues&&(o=o.trim()),o=this.replaceEntitiesValue(o);const t=this.options.attributeValueProcessor(r,o,e);i[s]=null==t?o:typeof t!=typeof o||t!==o?t:wc(o,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(i[s]=!0)}if(!Object.keys(i).length)return;if(this.options.attributesGroupName){const t={};return t[this.options.attributesGroupName]=i,t}return i}}const fc=function(t){t=t.replace(/\r\n?/g,"\n");const e=new Xl("!xml");let n=e,r="",i="";for(let o=0;o<t.length;o++){if("<"===t[o])if("/"===t[o+1]){const e=_c(t,">",o,"Closing Tag is not closed.");let s=t.substring(o+2,e).trim();if(this.options.removeNSPrefix){const t=s.indexOf(":");-1!==t&&(s=s.substr(t+1))}this.options.transformTagName&&(s=this.options.transformTagName(s)),n&&(r=this.saveTextToParentTag(r,n,i));const a=i.substring(i.lastIndexOf(".")+1);if(s&&-1!==this.options.unpairedTags.indexOf(s))throw new Error(`Unpaired tag can not be used as closing tag: </${s}>`);let u=0;a&&-1!==this.options.unpairedTags.indexOf(a)?(u=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=i.lastIndexOf("."),i=i.substring(0,u),n=this.tagsNodeStack.pop(),r="",o=e}else if("?"===t[o+1]){let e=vc(t,o,!1,"?>");if(!e)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),this.options.ignoreDeclaration&&"?xml"===e.tagName||this.options.ignorePiTags);else{const t=new Xl(e.tagName);t.add(this.options.textNodeName,""),e.tagName!==e.tagExp&&e.attrExpPresent&&(t[":@"]=this.buildAttributesMap(e.tagExp,i,e.tagName)),this.addChild(n,t,i,o)}o=e.closeIndex+1}else if("!--"===t.substr(o+1,3)){const e=_c(t,"--\x3e",o+4,"Comment is not closed.");if(this.options.commentPropName){const s=t.substring(o+4,e-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:s}])}o=e}else if("!D"===t.substr(o+1,2)){const e=Gl(t,o);this.docTypeEntities=e.entities,o=e.i}else if("!["===t.substr(o+1,2)){const e=_c(t,"]]>",o,"CDATA is not closed.")-2,s=t.substring(o+9,e);r=this.saveTextToParentTag(r,n,i);let a=this.parseTextData(s,n.tagname,i,!0,!1,!0,!0);null==a&&(a=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:s}]):n.add(this.options.textNodeName,a),o=e+2}else{let s=vc(t,o,this.options.removeNSPrefix),a=s.tagName;const u=s.rawTagName;let l=s.tagExp,c=s.attrExpPresent,h=s.closeIndex;this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&r&&"!xml"!==n.tagname&&(r=this.saveTextToParentTag(r,n,i,!1));const p=n;p&&-1!==this.options.unpairedTags.indexOf(p.tagname)&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),a!==e.tagname&&(i+=i?"."+a:a);const f=o;if(this.isItStopNode(this.options.stopNodes,i,a)){let e="";if(l.length>0&&l.lastIndexOf("/")===l.length-1)"/"===a[a.length-1]?(a=a.substr(0,a.length-1),i=i.substr(0,i.length-1),l=a):l=l.substr(0,l.length-1),o=s.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(a))o=s.closeIndex;else{const n=this.readStopNodeData(t,u,h+1);if(!n)throw new Error(`Unexpected end of ${u}`);o=n.i,e=n.tagContent}const r=new Xl(a);a!==l&&c&&(r[":@"]=this.buildAttributesMap(l,i,a)),e&&(e=this.parseTextData(e,a,i,!0,c,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),r.add(this.options.textNodeName,e),this.addChild(n,r,i,f)}else{if(l.length>0&&l.lastIndexOf("/")===l.length-1){"/"===a[a.length-1]?(a=a.substr(0,a.length-1),i=i.substr(0,i.length-1),l=a):l=l.substr(0,l.length-1),this.options.transformTagName&&(a=this.options.transformTagName(a));const t=new Xl(a);a!==l&&c&&(t[":@"]=this.buildAttributesMap(l,i,a)),this.addChild(n,t,i,f),i=i.substr(0,i.lastIndexOf("."))}else{const t=new Xl(a);this.tagsNodeStack.push(n),a!==l&&c&&(t[":@"]=this.buildAttributesMap(l,i,a)),this.addChild(n,t,i,f),n=t}r="",o=h}}else r+=t[o]}return e.child};function dc(t,e,n,r){this.options.captureMetaData||(r=void 0);const i=this.options.updateTag(e.tagname,n,e[":@"]);!1===i||("string"==typeof i?(e.tagname=i,t.addChild(e,r)):t.addChild(e,r))}const mc=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const n=this.docTypeEntities[e];t=t.replace(n.regx,n.val)}for(let e in this.lastEntities){const n=this.lastEntities[e];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const n=this.htmlEntities[e];t=t.replace(n.regex,n.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function gc(t,e,n,r){return t&&(void 0===r&&(r=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,n,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,r))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function yc(t,e,n){const r="*."+n;for(const n in t){const i=t[n];if(r===i||e===i)return!0}return!1}function _c(t,e,n,r){const i=t.indexOf(e,n);if(-1===i)throw new Error(r);return i+e.length-1}function vc(t,e,n,r=">"){const i=function(t,e,n=">"){let r,i="";for(let o=e;o<t.length;o++){let e=t[o];if(r)e===r&&(r="");else if('"'===e||"'"===e)r=e;else if(e===n[0]){if(!n[1])return{data:i,index:o};if(t[o+1]===n[1])return{data:i,index:o}}else"\t"===e&&(e=" ");i+=e}}(t,e+1,r);if(!i)return;let o=i.data;const s=i.index,a=o.search(/\s/);let u=o,l=!0;-1!==a&&(u=o.substring(0,a),o=o.substring(a+1).trimStart());const c=u;if(n){const t=u.indexOf(":");-1!==t&&(u=u.substr(t+1),l=u!==i.data.substr(t+1))}return{tagName:u,tagExp:o,closeIndex:s,attrExpPresent:l,rawTagName:c}}function bc(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if("<"===t[n])if("/"===t[n+1]){const o=_c(t,">",n,`${e} is not closed`);if(t.substring(n+2,o).trim()===e&&(i--,0===i))return{tagContent:t.substring(r,n),i:o};n=o}else if("?"===t[n+1]){n=_c(t,"?>",n+1,"StopNode is not closed.")}else if("!--"===t.substr(n+1,3)){n=_c(t,"--\x3e",n+3,"StopNode is not closed.")}else if("!["===t.substr(n+1,2)){n=_c(t,"]]>",n,"StopNode is not closed.")-2}else{const r=vc(t,n,">");if(r){(r&&r.tagName)===e&&"/"!==r.tagExp[r.tagExp.length-1]&&i++,n=r.closeIndex}}}function wc(t,e,n){if(e&&"string"==typeof t){const e=t.trim();return"true"===e||"false"!==e&&oc(t,n)}return void 0!==t?t:""}const xc=Xl.getMetaDataSymbol();function Tc(t,e){return Ec(t,e)}function Ec(t,e,n){let r;const i={};for(let o=0;o<t.length;o++){const s=t[o],a=Nc(s);let u="";if(u=void 0===n?a:n+"."+a,a===e.textNodeName)void 0===r?r=s[a]:r+=""+s[a];else{if(void 0===a)continue;if(s[a]){let t=Ec(s[a],e,u);const n=Oc(t,e);void 0!==s[xc]&&(t[xc]=s[xc]),s[":@"]?Dc(t,s[":@"],u,e):1!==Object.keys(t).length||void 0===t[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(t).length&&(e.alwaysCreateTextNode?t[e.textNodeName]="":t=""):t=t[e.textNodeName],void 0!==i[a]&&i.hasOwnProperty(a)?(Array.isArray(i[a])||(i[a]=[i[a]]),i[a].push(t)):e.isArray(a,u,n)?i[a]=[t]:i[a]=t}}}return"string"==typeof r?r.length>0&&(i[e.textNodeName]=r):void 0!==r&&(i[e.textNodeName]=r),i}function Nc(t){const e=Object.keys(t);for(let t=0;t<e.length;t++){const n=e[t];if(":@"!==n)return n}}function Dc(t,e,n,r){if(e){const i=Object.keys(e),o=i.length;for(let s=0;s<o;s++){const o=i[s];r.isArray(o,n+"."+o,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}}function Oc(t,e){const{textNodeName:n}=e,r=Object.keys(t).length;return 0===r||!(1!==r||!t[n]&&"boolean"!=typeof t[n]&&0!==t[n])}class Ac{constructor(t){this.externalEntities={},this.options=function(t){return Object.assign({},ql,t)}(t)}parse(t,e){if("string"==typeof t);else{if(!t.toString)throw new Error("XML data is accepted in String or Bytes[] form.");t=t.toString()}if(e){!0===e&&(e={});const n=function(t,e){e=Object.assign({},Cl,e);const n=[];let r=!1,i=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(let o=0;o<t.length;o++)if("<"===t[o]&&"?"===t[o+1]){if(o+=2,o=Pl(t,o),o.err)return o}else{if("<"!==t[o]){if(Ml(t[o]))continue;return Rl("InvalidChar","char '"+t[o]+"' is not expected.",$l(t,o))}{let s=o;if(o++,"!"===t[o]){o=Sl(t,o);continue}{let a=!1;"/"===t[o]&&(a=!0,o++);let u="";for(;o<t.length&&">"!==t[o]&&" "!==t[o]&&"\t"!==t[o]&&"\n"!==t[o]&&"\r"!==t[o];o++)u+=t[o];if(u=u.trim(),"/"===u[u.length-1]&&(u=u.substring(0,u.length-1),o--),!Vl(u)){let e;return e=0===u.trim().length?"Invalid space after '<'.":"Tag '"+u+"' is an invalid name.",Rl("InvalidTag",e,$l(t,o))}const l=Ll(t,o);if(!1===l)return Rl("InvalidAttr","Attributes for '"+u+"' have open quote.",$l(t,o));let c=l.value;if(o=l.index,"/"===c[c.length-1]){const n=o-c.length;c=c.substring(0,c.length-1);const i=zl(c,e);if(!0!==i)return Rl(i.err.code,i.err.msg,$l(t,n+i.err.line));r=!0}else if(a){if(!l.tagClosed)return Rl("InvalidTag","Closing tag '"+u+"' doesn't have proper closing.",$l(t,o));if(c.trim().length>0)return Rl("InvalidTag","Closing tag '"+u+"' can't have attributes or invalid starting.",$l(t,s));if(0===n.length)return Rl("InvalidTag","Closing tag '"+u+"' has not been opened.",$l(t,s));{const e=n.pop();if(u!==e.tagName){let n=$l(t,e.tagStartPos);return Rl("InvalidTag","Expected closing tag '"+e.tagName+"' (opened in line "+n.line+", col "+n.col+") instead of closing tag '"+u+"'.",$l(t,s))}0==n.length&&(i=!0)}}else{const a=zl(c,e);if(!0!==a)return Rl(a.err.code,a.err.msg,$l(t,o-c.length+a.err.line));if(!0===i)return Rl("InvalidXml","Multiple possible root nodes found.",$l(t,o));-1!==e.unpairedTags.indexOf(u)||n.push({tagName:u,tagStartPos:s}),r=!0}for(o++;o<t.length;o++)if("<"===t[o]){if("!"===t[o+1]){o++,o=Sl(t,o);continue}if("?"!==t[o+1])break;if(o=Pl(t,++o),o.err)return o}else if("&"===t[o]){const e=Ul(t,o);if(-1==e)return Rl("InvalidChar","char '&' is not expected.",$l(t,o));o=e}else if(!0===i&&!Ml(t[o]))return Rl("InvalidXml","Extra text at the end",$l(t,o));"<"===t[o]&&o--}}}return r?1==n.length?Rl("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",$l(t,n[0].tagStartPos)):!(n.length>0)||Rl("InvalidXml","Invalid '"+JSON.stringify(n.map(t=>t.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):Rl("InvalidXml","Start tag expected.",1)}(t,e);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const n=new ac(this.options);n.addExternalEntities(this.externalEntities);const r=n.parseXml(t);return this.options.preserveOrder||void 0===r?r:Tc(r,this.options)}addEntity(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}static getMetaDataSymbol(){return Xl.getMetaDataSymbol()}}function Ic(t){var e={};if(1==t.nodeType){if(t.attributes.length>0){e["@attributes"]={};for(var n=0;n<t.attributes.length;n++){var r=t.attributes.item(n);e["@attributes"][r.nodeName]=r.nodeValue}}}else 3==t.nodeType&&(e=t.nodeValue);if(t.hasChildNodes()&&1===t.childNodes.length&&3===t.childNodes[0].nodeType)e=t.childNodes[0].nodeValue;else if(t.hasChildNodes())for(var i=0;i<t.childNodes.length;i++){var o=t.childNodes.item(i),s=o.nodeName;if(void 0===e[s])e[s]=Ic(o);else{if(void 0===e[s].push){var a=e[s];e[s]=[],e[s].push(a)}e[s].push(Ic(o))}}return e}var Cc=function(t,e){var n;if("string"==typeof t)if(DOMParser){t=(new DOMParser).parseFromString(t,"text/xml")}else{t=(new Ac).parse(t)}var r=(t=Ic(t)).phyloxml.phylogeny;return Array.isArray(r)&&(r=r[0],console.warn("PhyloXML files with multiple phylogenies are not currently supported. Only the first phylogeny will be loaded.")),(n=r.clade).name="root",function t(e,n){e.clade&&(Array.isArray(e.clade)||(e.clade=[e.clade]),e.clade.forEach(t),e.children=e.clade,delete e.clade),e.annotation=1,e.attribute="0.01",e.branch_length&&(e.attribute=e.branch_length),e.taxonomy&&(e.name=e.taxonomy.scientific_name),e.annotation=""}(n),{json:n,error:null}};var Mc={nexml:function(t,e){var n;return gl.parseString(t,function(t,e){n=e["nex:nexml"].trees[0].tree.map(function(t){var e=t.node.map(t=>t.$),n=e.reduce(function(t,e){return e.edges=[],e.name=e.id,t[e.id]=e,t},{}),r=e.filter(t=>t.root),i=r>0?r[0].id:e[0].id;return n[i].name="root",t.edge.map(t=>t.$).forEach(function(t){n[t.source].edges.push(t)}),function t(e,r){if(e.edges){var i=u.pluck(e.edges,"target");e.children=u.values(u.pick(n,i)),e.children.forEach(function(t,n){t.attribute=e.edges[n].length||""}),e.children.forEach(t),e.annotation=""}}(n[i]),n[i]})}),n},phyloxml:Cc,nexus:El,nwk:bl,nhx:bl,beast:function(t,e){e.left_delimiter="[",e.right_delimiter="]";const n=bl(t,e);return function t(e){if(e.annotation){e.beast={};const t=e.annotation.split(/=|,|{|}/).filter(t=>t);for(var n=0;n<t.length;n+=2){let r=t[n].replace(/&|%/g,"");/[a-df-zA-DF-Z]+/.test(t[n+2])?e.beast[r]=+t[n+1]:(e.beast[r]=[+t[n+1],+t[n+2]],n++)}}e.annotation=void 0,e.children&&e.children.forEach(t)}(n.json),n}};function Pc(t,e,n){let r,i,o,s=[t],a=[];for(;t=s.pop();)if((!n||!n(t))&&(a.push(t),r=t.children,r))for(i=0,o=r.length;i<o;++i)s.push(r[i]);for(;t=a.pop();)e(t);return t}function Sc(t,e,n){let r,i,o=[t];for(;t=o.pop();)if((!n||!n(t))&&(e(t),r=t.children,r))for(i=r.length-1;i>=0;--i)o.push(r[i]);return t}function kc(t,e,n){let r,i,o,s,a=[t];do{for(r=a.reverse(),a=[];t=r.pop();)if((!n||!n(t))&&(e(t),i=t.children,i))for(o=0,s=i.length;o<s;++o)a.push(i[o])}while(a.length);return t}function Fc(t){return Pc(t,function(t){t.children&&(t.children[0].data.multiway_parent=t,t.children[1].data.multiway_parent=t.parent)}),p.map(t.descendants(),t=>{let e=t.data.multiway_parent,n="unknown";return e&&(n=e.data.name),{source:t.data.multiway_parent,target:t,name:n}})}function Lc(t,e){let n=t.data;if("attribute"in n&&n.attribute&&n.attribute.length){e>0&&(n.attribute=String(e));let t=parseFloat(n.attribute);if(!isNaN(t))return Math.max(0,t)}if("root"==n.name)return 0;console.warn("Undefined branch length at "+n.name+"!")}var jc=Object.freeze({__proto__:null,reroot:function(t,e){if(!(t instanceof Gr))throw new Error("node needs to be an instance of a d3.hierarchy node!");let n=this.nodes.copy();if(e=void 0!==e?e:.5,t.parent){var r=Gr({name:"new_root"});r.children=[t.copy()],r.data.__mapped_bl=void 0,n.each(t=>{t.data.__mapped_bl=this.branch_length_accessor(t)}),this.setBranchLength(t=>t.data.__mapped_bl);let o=t,s=t.parent,a=u.noop(),l=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl*e;var i;if(a=s.data.__mapped_bl,s.data.__mapped_bl=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl-l,t.data.__mapped_bl=l,s.parent){for(r.children.push(s);s.parent;){i=s.children.indexOf(o),s.parent.parent?s.children.splice(i,1,s.parent):s.children.splice(i,1);let t=s.parent.data.__mapped_bl;void 0!==t&&(s.parent.data.__mapped_bl=a,a=t),o=s,s=s.parent}i=s.children.indexOf(o),s.children.splice(i,1)}else i=s.children.indexOf(o),s.children.splice(i,1),a=s.data.__mapped_bl,o=r;if(1==s.children.length)a&&(s.children[0].data.__mapped_bl+=a),o.children=o.children.concat(s.children);else{let e=new Gr({name:"__reroot_top_clade",__mapped_bl:a});u.extendOwn(r.children[0],t),e.data.__mapped_bl=a,e.children=s.children.map(function(t){return t.parent=e,t}),e.parent=o,o.children.push(e)}}if(this.update(r),this.traverse_and_compute(t=>{u.each(t.children,e=>{e.parent=t})},"pre-order"),!u.isUndefined(this.display)){let t=this.display.options;Wt(this.display.container).select("svg").remove();let e=this.display.selection_attribute_name;delete this.display;let n=this.render(t);n.selectionLabel(e),n.update(),Wt(n.container).node().appendChild(n.show()),Wt(this.display.container).dispatch("reroot")}return this},rootpath:function(t,e){if(t=t||"attribute",e=e||"y_scaled","parent"in this){let n=parseFloat(this[t]);this[e]=this.parent[e]+(isNaN(n)?.1:n)}else this[e]=0;return this[e]},pathToRoot:function(t){let e=[];for(;t;)e.push(t),t=t.parent;return e}});function zc(t){return t.y}function Uc(t){return t.x}function Rc(t,e,n){return{x:n+t*Math.sin(e),y:n+t*Math.cos(e)}}function Bc(t,e,n,r,i,o){t.radius=e*(t.radius+n),t.angle=2*Math.PI*t.x*i[0]/o[0];let s=Rc(t.radius,t.angle,r);return t.x=s.x,t.y=s.y,t}function Vc(t,e){var n=Rc(e[0].radius,e[0].angle,t),r=Rc(e[0].radius,e[1].angle,t);return"M "+zc(n)+","+Uc(n)+" A "+e[0].radius+","+e[0].radius+" 0,0, "+(e[1].angle>e[0].angle?1:0)+" "+zc(r)+","+Uc(r)+" L "+zc(e[1])+","+Uc(e[1])}function $c(t,e,n){var r=Rc(t.target.radius+(t.source.radius-t.target.radius)*e,t.target.angle,n);return{x:zc(r),y:Uc(r)}}var Yc=ps().x(function(t){return zc(t)}).y(function(t){return Uc(t)}).curve(function(t){return new gs(t,0)});function qc(t,e){return{x:zc(t.target)+(zc(t.source)-zc(t.target))*e,y:Uc(t.target)}}function Hc(t){return t.tag||!1}function Xc(t,e){return t[e]||!1}const Gc={"tree-container":"phylotree-container","tree-scale-bar":"tree-scale-bar",node:"node","internal-node":"internal-node","tagged-node":"node-tagged","selected-node":"node-selected","collapsed-node":"node-collapsed","root-node":"root-node",branch:"branch","selected-branch":"branch-selected","tagged-branch":"branch-tagged","tree-selection-brush":"tree-selection-brush","branch-tracer":"branch-tracer",clade:"clade",node_text:"phylotree-node-text"};function Wc(t={}){Object.keys(t).forEach(e=>{Gc[e]=t[e]})}function Kc(t){return arguments.length?(Kc="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):Kc}var Qc={all:t=>!0,none:t=>!1,"all-leaf-nodes":t=>yl(t.target),"all-internal-nodes":t=>!yl(t.target)};var Zc=Object.freeze({__proto__:null,css_classes:Gc,initializeCssClasses:Wc,internalNames:function(t){return arguments.length?(this.options["internal-names"]=t,this):this.options["internal-names"]},radial:function(t){return arguments.length?(this.options["is-radial"]=t,this):this.options["is-radial"]},alignTips:function(t){return arguments.length?(this.options["align-tips"]=t,this):this.options["align-tips"]},nodeBubbleSize:function(t){return this.options["draw-size-bubbles"]&&this.options["bubble-styler"]?this.options["bubble-styler"](t):this.options["draw-size-bubbles"]?this.relative_nodeSpan(t)*this.scales[0]*.25:0},shiftTip:function(t){return this.options["is-radial"]?[("end"==t.text_align?-1:1)*(this.radius_pad_for_bubbles-t.radius),0]:(this.options["right-to-left"],[this.right_most_leaf-t.screen_x,0])},layoutHandler:function(t){return arguments.length?(this.layout_listener_handler=t,this):this.layout_listener_handler},selectionLabel:function(t){return arguments.length?(this.selection_attribute_name=t,this.syncEdgeLabels(),this):this.selection_attribute_name},get nodeSpan(){return Kc},predefined_selecters:Qc,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function Jc(t){return!(t.hidden||t.notshown)}function th(t){return t.notshown}function eh(t){return t.hasHiddenNodes||!1}function nh(t){return t.collapsed||!1}function rh(t){return[t.node,t["internal-node"],t["collapsed-node"],t["tagged-node"],t["root-node"]].reduce(function(t,e,n,r){return t+"g."+e+(n<r.length-1?",":"")},"")}function ih(t){return yl(t=t.data)?t.name||"":this.showInternalName(t)?t.name:""}var oh=Object.freeze({__proto__:null,shiftTip:function(t){return this.radial()?[("end"==t.text_align?-1:1)*(this.radius_pad_for_bubbles-t.radius),0]:(this.options["right-to-left"],[this.right_most_leaf-t.screen_x,0])},drawNode:function(t,e,n){t=Wt(t);var r=yl(e);r&&(t=t.attr("data-node-name",e.data.name));var i=t.selectAll("text").data([e]),o=t.selectAll("line");if(r||this.showInternalName(e)&&!nh(e))if(i=i.enter().append("text").classed(this.css_classes.node_text,!0).merge(i).on("click",t=>{this.handle_node_click(e,t)}).attr("dy",t=>.33*this.shown_font_size).text(t=>this.options["show-labels"]?this._nodeLabel(t):"").style("font-size",t=>this.ensure_size_is_in_px(this.shown_font_size)),i=this.radial()?i.attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)+this.d3PhylotreeSvgTranslate(this.alignTips()?this.shiftTip(t):null)).attr("text-anchor",t=>t.text_align):i.attr("text-anchor","start").attr("transform",t=>"right-to-left"==this.options.layout?this.d3PhylotreeSvgTranslate([-20,0]):this.d3PhylotreeSvgTranslate(this.alignTips()?this.shiftTip(t):null)),this.alignTips()?(o=o.data([e]),n?o=o.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(o).attr("x1",t=>("end"==t.text_align?-1:1)*this.nodeBubbleSize(e)).attr("x2",0).attr("y1",0).attr("y2",0).attr("x2",t=>"right-to-left"==this.options.layout?t.screen_x:this.shiftTip(t)[0]).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)).attr("x2",t=>"right-to-left"==this.options.layout?t.screen_x:this.shiftTip(t)[0]).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)):(o=o.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(o).attr("x1",t=>("end"==t.text_align?-1:1)*this.nodeBubbleSize(e)).attr("y2",0).attr("y1",0).attr("x2",t=>this.shiftTip(t)[0])).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle))):o.remove(),this.options["draw-size-bubbles"]){var s=this.nodeBubbleSize(e);t.selectAll("circle").data([s]).enter().append("circle").attr("r",function(t){return t}),this.shown_font_size>=5&&(i=i.attr("dx",t=>("end"==t.text_align?-1:1)*((this.alignTips()?0:s)+.33*this.shown_font_size)))}else this.shown_font_size>=5&&(i=i.attr("dx",t=>("end"==t.text_align?-1:1)*this.shown_font_size*.33));if(!r){let n=t.selectAll("circle").data([e]).enter().append("circle"),r=this.node_circle_size()(e);r>0?n.merge(n).attr("r",t=>Math.min(.75*this.shown_font_size,r)).on("click",t=>{this.handle_node_click(e,t)}):n.remove()}return this.node_styler&&this.node_styler(t,e),e},updateHasHiddenNodes:function(){let t=this.phylotree.nodes.descendants();for(let e=t.length-1;e>=0;e-=1)yl(t[e])?t[e].hasHiddenNodes=t[e].notshown:t[e].hasHiddenNodes=t[e].children.reduce(function(t,e){return e.notshown||t},!1);return this},showInternalName:function(t){const e=this.internalNames();return!!e&&("function"==typeof e?e(t):e)},nodeSpan:function(t){return arguments.length?(this.nodeSpan="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):this.nodeSpan},reclassNode:function(t){let e=Gc[yl(t)?"node":"internal-node"];return Hc(t)&&(e+=" "+Gc["tagged-node"]),Xc(t,this.selection_attribute_name)&&(e+=" "+Gc["selected-node"]),t.parent||(e+=" "+Gc["root-node"]),(nh(t)||eh(t))&&(e+=" "+Gc["collapsed-node"]),e},nodeVisible:Jc,nodeNotshown:th,hasHiddenNodes:eh,isNodeCollapsed:nh,nodeCssSelectors:rh,internalLabel:function(t,e){this.phylotree.clearInternalNodes(e);for(var n=this.phylotree.nodes.descendants().length-1;n>=0;n--){var r=this.phylotree.nodes.descendants()[n];yl(r)||Xc(r,this.selection_attribute_name)||(r[this.selection_attribute_name]=t(r.children))}this.modifySelection((t,e)=>(yl(t.target),t.target[this.selection_attribute_name]))},defNodeLabel:ih,nodeLabel:function(t){return arguments.length?(this._nodeLabel=t||ih,this.update(),this):this._nodeLabel}});function sh(t){return[t.clade].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var ah=Object.freeze({__proto__:null,cladeCssSelectors:sh,updateCollapsedClades:function(t){let e=this.svg.selectAll("."+this.css_classes["tree-container"]);var n=0;let r=e.selectAll(sh(this.css_classes)).data(this.phylotree.nodes.descendants().filter(nh),function(t){return t.id||(t.id=++n)}),i=function(){},o=u.noop();this.radial()?(i=ps().curve(ms).y(function(t){return t[0]}).x(function(t){return t[1]}),o=function(t,e,n,r,i){return e?[n.screen_y+(t[0]-r)/50,n.screen_x+(t[1]-i)/50]:[n.screen_y,n.screen_x]}):(i=ps().y(function(t){return t[0]}).x(function(t){return t[1]}).curve(ms),o=function(t,e,n,r,i){return e?[n.screen_y+(t[0]-r)/50,n.screen_x+(t[1]-i)/50]:[n.screen_y,n.screen_x]}),r.exit().each(function(t){t.collapsed_clade=null}).remove(),t?r.enter().insert("path",":first-child").attr("class",this.css_classes.clade).merge(r).attr("d",function(t){if(t.collapsed_clade)return t.collapsed_clade;let e=t.collapsed[0][0],n=t.collapsed[0][1];return i(t.collapsed.map(function(r,i){return o(r,i,t,e,n)}))}).attr("d",function(t){return t.collapsed_clade=i(t.collapsed)}):r.enter().insert("path",":first-child").attr("class",this.css_classes.clade).merge(r).attr("d",function(t){return t.collapsed_clade?t.collapsed_clade:t.collapsed_clade=i(t.collapsed)})}});function uh(t){return!(t.target.hidden||t.target.notshown)}function lh(t){return[t.branch,t["selected-branch"],t["tagged-branch"]].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var ch=Object.freeze({__proto__:null,drawEdge:function(t,e,n){t=(t=Wt(t)).attr("class",t=>this.reclassEdge(t)).on("click",t=>{this.modifySelection([e.target],this.selection_attribute_name),this.update()});let r=this.draw_branch([e.source,e.target]);n?(t.datum().existing_path&&(t=t.attr("d",function(t){return t.existing_path})),t=t.attr("d",r)):t=t.attr("d",r),e.existing_path=r;var i=this.phylotree.branch_length_accessor(e.target);if(void 0!==i){var o=t.selectAll("title");o.empty()&&(o=t.append("title")),o.text("Length = "+i)}else t.selectAll("title").remove();return this.edge_styler&&this.edge_styler(t,e,n),this.phylotree},reclassEdge:function(t){let e=Gc.branch;return Hc(t)&&(e+=" "+Gc["tagged-branch"]),Xc(t,this.selection_attribute_name)&&(e+=" "+Gc["selected-branch"]),e},initializeEdgeLabels:function(){this.links.forEach(t=>{t.target.data.annotation&&(t.target[t.target.data.annotation]=t.target.data.annotation)})},syncEdgeLabels:function(){if(this.links.forEach(t=>{t[this.selection_attribute_name]=t.target[this.selection_attribute_name]||!1,t.tag=t.target.tag||!1}),this.countHandler()){let t={};t[this.selection_attribute_name]=this.links.reduce((t,e)=>t+(e[this.selection_attribute_name]?1:0),0),t.tagged=this.links.reduce(function(t,e){return t+(Hc(e)?1:0)},0),this.countUpdate(this,t,this.countHandler())}},edgeVisible:uh,edgeCssSelectors:lh,placeAlongAnEdge:function(t,e){return this.edge_placer(t,e)}});let hh="phylotree.event";function ph(t){var e=new CustomEvent(hh,{detail:["refresh",t]});document.dispatchEvent(e)}function fh(t,e){var n=new CustomEvent(hh,{detail:["countUpdate",e,t.countHandler()]});document.dispatchEvent(n)}function dh(t){switch(t.detail[0]){case"refresh":t.detail[1].refresh();break;case"countUpdate":case"layout":t.detail[2](t.detail[1])}return!0}function mh(){document.addEventListener(hh,dh,!1)}var gh=Object.freeze({__proto__:null,toggleCollapse:function(t){if(t.collapsed){t.collapsed=!1;let e=function(t){yl(t)||t.collapsed||t.children.forEach(e),t.hidden=!1};e(t)}else t.collapsed=!0;return this.placenodes(),this},resizeSvg:function(t,e,n){let r=this.size;if(this.radial()){let t=this.pad_width(),n="fit-to-size"!=this.options["top-bottom-spacing"]?this.pad_height():0;r=[r[1]+2*t,r[0]+2*t+n],e&&e.selectAll("."+Gc["tree-container"]).attr("transform","translate ("+t+","+(t+n)+")")}else r=[r[0]+("fit-to-size"!=this.options["top-bottom-spacing"]?this.pad_height():0),r[1]+("fit-to-size"!=this.options["left-right-spacing"]?this.pad_width():0)];return e&&(n&&(e=e.transition(100)),e.attr("height",r[0]).attr("width",r[1])),this.size=r,r},rescale:function(t,e){(e=e||"y_scaled")in this&&(this[e]*=t)},triggerRefresh:ph,countUpdate:fh,d3PhylotreeTriggerLayout:function(t){var e=new CustomEvent(hh,{detail:["layout",t,t.layoutHandler()]});document.dispatchEvent(e)},d3PhylotreeEventListener:dh,d3PhylotreeAddEventListener:mh,d3PhylotreeSvgTranslate:function(t){return!t||null===t[0]&&null===t[1]?"":"translate ("+(null!==t[0]?t[0]:0)+","+(null!==t[1]?t[1]:0)+") "},d3PhylotreeSvgRotate:function(t){return null!==t?"rotate ("+t+") ":""}});let yh="d3_layout_phylotree_context_menu";function _h(t,e,n){let r=[];return function i(o){yl(o)?e&&o!=t&&r.push(o):(n&&o!=t&&r.push(o),o.children.forEach(i))}(t),r}var vh=Object.freeze({__proto__:null,nodeDropdownMenu:function(t,e,n,r,i){let o=Wt(e).select("#"+yh);if(o.empty()&&(o=Wt(e).append("div").attr("id",yh).attr("class","dropdown-menu").attr("role","menu")),o.selectAll("a").remove(),o.selectAll("h6").remove(),o.selectAll("div").remove(),t){if(!u.some([Boolean(t.menu_items),r.hide,r.selectable,r.collapsible])||!r["show-menu"])return;yl(t)||(r.collapsible&&(o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(nh(t)?"Expand Subtree":"Collapse Subtree").on("click",e=>{o.style("display","none"),this.toggleCollapse(t).update()}),r.selectable&&(o.append("div").attr("class","dropdown-divider"),o.append("h6").attr("class","dropdown-header").text("Toggle selection"))),r.selectable&&(o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All descendant branches").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0))}),o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All terminal branches").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!1))}),o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All internal branches").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!1,!0))}))),t.parent&&(r.selectable&&(o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Incident branch").on("click",function(e){o.style("display","none"),n.modifySelection([t])}),o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Path to root").on("click",e=>{o.style("display","none"),this.modifySelection(this.phylotree.pathToRoot(t))}),(r.reroot||r.hide)&&o.append("div").attr("class","dropdown-divider")),r.reroot&&o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Reroot on this node").on("click",e=>{o.style("display","none"),this.phylotree.reroot(t),this.update()}),r.hide&&o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Hide this "+(yl(t)?"node":"subtree")).on("click",e=>{o.style("display","none"),this.modifySelection([t],"notshown",!0,!0).updateHasHiddenNodes().update()})),eh(t)&&o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Show all descendant nodes").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0),"notshown",!0,!0,"false").updateHasHiddenNodes().update()});var s=[];if("menu_items"in t&&"object"==typeof t.menu_items&&t.menu_items.forEach(function(e){3==e.length&&(e[2]&&!e[2](t)||s.push([e[0],e[1]]))}),s.length){const e=[r.hide,r.selectable,r.collapsible];u.some(e)&&o.append("div").attr("class","dropdown-divider"),s.forEach(function(e){o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(e[0](t)).on("click",u.partial(e[1],t))})}let a=document.querySelector(e).getBoundingClientRect();o.style("position","absolute").style("left",i.clientX-a.x+12+"px").style("top",i.clientY-a.y+"px").style("display","block")}else o.style("display","none")},addCustomMenu:function(t,e,n,r){"menu_items"in t||(t.menu_items=[]),t.menu_items.some(function(t){return t[0]==e&&t[1]==n&&t[2]==r})||t.menu_items.push([e,n,r])},modifySelection:function(t,e,n,r,i){if(e=e||this.selection_attribute_name,i=i||"toggle",this.options["restricted-selectable"].length){if(!u.contains(u.keys(Qc),t))return;t=Qc[t]}if(!this.options["restricted-selectable"]&&!this.options.selectable||this.options["binary-selectable"])this.options["binary-selectable"]&&("function"==typeof t?this.links.forEach(function(n){var r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,s=!0,n.target[e]=r),this.options["attribute-list"].forEach(function(t){t!=e&&!0===n[e]&&(n[t]=!1,n.target[t]=!1)})}):(t.forEach(function(t){var n;n=!t[e],t[e]!=n&&(t[e]=n,s=!0)}),this.links.forEach(function(t){t[e]=t.target[e],this.options["attribute-list"].forEach(function(n){n!=e&&!0!==t[e]&&(t[n]=!1,t.target[n]=!1)})})),s&&(r||ph(this),this.countHandler()&&((o={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),this.countUpdate(this,o,this.countHandler())),n&&this.placenodes()));else{var o,s=!1;"function"==typeof t?this.links.forEach(function(n){let r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,s=!0,n.target[e]=r)}):(t.forEach(function(t){var n;switch(i){case"true":n=!0;break;case"false":n=!1;break;default:n=!t[e]}t[e]!=n&&(t[e]=n,s=!0)}),this.links.forEach(function(t){t[e]=t.target[e]})),s&&(r||ph(this),this.countHandler&&((o={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),fh(this,o,this.countHandler)),n&&this.placenodes())}return this._selectionCallback&&"tag"!=e&&this._selectionCallback(this.getSelection()),this.refresh(),this.update(),this},getSelection:function(){return _h(this.phylotree.getRootNode(),!0,!0).filter(t=>t[this.selection_attribute_name])},selectAllDescendants:_h,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function bh(t){return function(){return t}}class wh{constructor(t,e={}){Wc(e["css-classes"]),this.css_classes=Gc,this.phylotree=t,this.container=e.container,this.separation=function(t,e){return 0},this._nodeLabel=this.defNodeLabel,this.svg=null,this._selectionCallback=null,this.scales=[1,1],this.size=[1,1],this.fixed_width=[14,30],this.scale_bar_font_size=12,this.draw_branch=Yc,this.draw_scale_bar=null,this.edge_placer=qc,this.count_listener_handler=function(){},this.layout_listener_handler=function(){},this.node_styler=void 0,this.edge_styler=void 0,this.selection_attribute_name="selected",this.right_most_leaf=0,this.label_width=0,this.radial_center=0,this.radius=1,this.radius_pad_for_bubbles=0,this.rescale_nodeSpan=1,this.relative_nodeSpan=function(t){return this.nodeSpan(t)/this.rescale_nodeSpan};let n={layout:"left-to-right",logger:console,branches:"step",scaling:!0,bootstrap:!1,"color-fill":!0,"font-size":14,"internal-names":!1,selectable:!0,"restricted-selectable":!1,collapsible:!0,"left-right-spacing":"fixed-step","top-bottom-spacing":"fixed-step","left-offset":0,"show-scale":"top","draw-size-bubbles":!1,"bubble-styler":this.radius_pad_for_bubbles,"binary-selectable":!1,"is-radial":!1,"attribute-list":[],"max-radius":768,"annular-limit":.38196601125010515,compression:.2,"align-tips":!1,"maximum-per-node-spacing":100,"minimum-per-node-spacing":2,"maximum-per-level-spacing":100,"minimum-per-level-spacing":10,node_circle_size:bh(3),transitions:null,brush:!0,reroot:!0,hide:!0,"label-nodes-with-name":!1,zoom:!1,"show-menu":!0,"show-labels":!0,"node-styler":null,"edge-styler":null,"node-span":null};this.ensure_size_is_in_px=function(t){return"number"==typeof t?t+"px":t},this.options=u.defaults(e,n),this.font_size=this.options["font-size"],this.offsets=[0,this.font_size/2],this.shown_font_size=this.font_size,this.width=this.options.width||800,this.height=this.options.height||600,this.node_styler=this.options["node-styler"],this.edge_styler=this.options["edge-styler"],this.nodeSpan=this.options["node-span"],this.nodeSpan||(this.nodeSpan=function(t){return 1}),this.rescale_nodeSpan=this.phylotree.nodes.children.map(t=>{if(yl(t)||this.showInternalName(t))return this.nodeSpan(t)}).reduce(function(t,e){return Math.min(e,t||1e200)},null)||1,this.initialize_svg(this.container),this.links=this.phylotree.nodes.links(),this.initializeEdgeLabels(),this.update(),mh()}pad_height(){return this.draw_scale_bar?this.scale_bar_font_size+25:0}pad_width(){this.label_width=this._label_width(this.shown_font_size);const t=this.options["show-labels"]?this.label_width:0;return this.offsets[1]+this.options["left-offset"]+t}collapse_node(t){nh(t)||(t.collapsed=!0)}set_size(t){if(!arguments.length)return this.size;let e=t;return"fixed-step"!=this.options["top-bottom-spacing"]&&(this.size[0]=e[0]),"fixed-step"!=this.options["left-right-spacing"]&&(this.size[1]=e[1]),this}initialize_svg(t){var e;return this.svg!==t&&(Wt(t).select("svg").remove(),this.svg=(e="svg",Wt(V(e).call(document.documentElement))).attr("width",this.width).attr("height",this.height),this.set_size([this.height,this.width]),"phylotree-container"==this.css_classes["tree-container"]&&(this.svg.selectAll("*").remove(),this.svg.append("defs")),Wt(this.container).on("click",t=>{this.handle_node_click(null)},!0)),this}update_layout(t,e){e&&(this.nodes=Gr(t),this.nodes.each(function(t){t.id=null})),this.update(),this.syncEdgeLabels()}update(t){var e=this;this.placenodes(),t=this.transitions(t);let n=0,r=this.svg.selectAll("."+Gc["tree-container"]).data([0]);if(r=r.enter().append("g").attr("class",Gc["tree-container"]).merge(r).attr("transform",t=>this.d3PhylotreeSvgTranslate([this.offsets[1]+this.options["left-offset"],this.pad_height()])),this.draw_scale_bar){let t=this.svg.selectAll("."+Gc["tree-scale-bar"]).data([0]);t.enter().append("g").attr("class",Gc["tree-scale-bar"]).style("font-size",this.ensure_size_is_in_px(this.scale_bar_font_size)).merge(t).attr("transform",t=>this.d3PhylotreeSvgTranslate([this.offsets[1]+this.options["left-offset"],this.pad_height()-10])).call(this.draw_scale_bar),t.selectAll("text").style("text-anchor","end")}else this.svg.selectAll("."+Gc["tree-scale-bar"]).remove();r=this.svg.selectAll("."+Gc["tree-container"]).data([0]),this.updateCollapsedClades(t);let i=r.selectAll(lh(Gc)).data(this.links.filter(uh),t=>t.target.id||(t.target.id=++n));i.exit().remove(),i=i.enter().insert("path",":first-child").merge(i).each(function(n){e.drawEdge(this,n,t)});let o=r.selectAll(rh(Gc)).data(this.phylotree.nodes.descendants().filter(Jc),t=>t.id||(t.id=++n));if(o.exit().remove(),o=o.enter().append("g").attr("class",this.reclassNode).merge(o).attr("transform",t=>{const e="right-to-left"==this.options.layout&&yl(t);return t.screen_x=zc(t),t.screen_y=Uc(t),this.d3PhylotreeSvgTranslate([e?0:t.screen_x,t.screen_y])}).each(function(n){e.drawNode(this,n,t)}).attr("transform",t=>{if(!u.isUndefined(t.screen_x)&&!u.isUndefined(t.screen_y))return"translate("+t.screen_x+","+t.screen_y+")"}),this.options["label-nodes-with-name"]&&(o=o.attr("id",t=>"node-"+t.name)),this.resizeSvg(this.phylotree,this.svg,t),this.options.brush){var s=r.selectAll("."+Gc["tree-selection-brush"]).data([0]).enter().insert("g",":first-child").attr("class",Gc["tree-selection-brush"]),a=Nr().on("brush",(t,e)=>{var n=t.selection,r=this.links.filter(uh).filter((t,e)=>t.source.screen_x>=n[0][0]&&t.source.screen_x<=n[1][0]&&t.source.screen_y>=n[0][1]&&t.source.screen_y<=n[1][1]&&t.target.screen_x>=n[0][0]&&t.target.screen_x<=n[1][0]&&t.target.screen_y>=n[0][1]&&t.target.screen_y<=n[1][1]).map(t=>t.target);this.modifySelection(this.phylotree.links.map(t=>t.target),"tag",!1,r.length>0,"false"),this.modifySelection(r,"tag",!1,!1,"true")}).on("end",()=>{});s.call(a)}if(this.syncEdgeLabels(),this.options.zoom){let t=function(){var t,e,n,r=Ts,i=Es,o=As,s=Ds,a=Os,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,h=sn,p=S("start","zoom","end"),f=0,d=10;function m(t){t.property("__zoom",Ns).on("wheel.zoom",x,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",E).filter(a).on("touchstart.zoom",N).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(t,e){return(e=Math.max(u[0],Math.min(u[1],e)))===t.k?t:new vs(e,t.x,t.y)}function y(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new vs(t.k,r,i)}function _(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function v(t,e,n,r){t.on("start.zoom",function(){b(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event(r).end()}).tween("zoom",function(){var t=this,o=arguments,s=b(t,o).event(r),a=i.apply(t,o),u=null==n?_(a):"function"==typeof n?n.apply(t,o):n,l=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),c=t.__zoom,p="function"==typeof e?e.apply(t,o):e,f=h(c.invert(u).concat(l/c.k),p.invert(u).concat(l/p.k));return function(t){if(1===t)t=p;else{var e=f(t),n=l/e[2];t=new vs(n,u[0]-e[0]*n,u[1]-e[1]*n)}s.zoom(null,t)}})}function b(t,e,n){return!n&&t.__zooming||new w(t,e)}function w(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function x(t,...e){if(r.apply(this,arguments)){var n=b(this,e).event(t),i=this.__zoom,a=Math.max(u[0],Math.min(u[1],i.k*Math.pow(2,s.apply(this,arguments)))),c=Kt(t);if(n.wheel)n.mouse[0][0]===c[0]&&n.mouse[0][1]===c[1]||(n.mouse[1]=i.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(i.k===a)return;n.mouse=[c,i.invert(c)],In(this),n.start()}xs(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",o(y(g(i,a),n.mouse[0],n.mouse[1]),n.extent,l))}}function T(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,s=b(this,e,!0).event(t),a=Wt(t.view).on("mousemove.zoom",function(t){if(xs(t),!s.moved){var e=t.clientX-c,n=t.clientY-h;s.moved=e*e+n*n>f}s.event(t).zoom("mouse",o(y(s.that.__zoom,s.mouse[0]=Kt(t,i),s.mouse[1]),s.extent,l))},!0).on("mouseup.zoom",function(t){a.on("mousemove.zoom mouseup.zoom",null),te(t.view,s.moved),xs(t),s.event(t).end()},!0),u=Kt(t,i),c=t.clientX,h=t.clientY;Jt(t.view),ws(t),s.mouse=[u,this.__zoom.invert(u)],In(this),s.start()}}function E(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,s=Kt(t.changedTouches?t.changedTouches[0]:t,this),a=n.invert(s),u=n.k*(t.shiftKey?.5:2),h=o(y(g(n,u),s,a),i.apply(this,e),l);xs(t),c>0?Wt(this).transition().duration(c).call(v,h,s,t):Wt(this).call(m.transform,h,s,t)}}function N(n,...i){if(r.apply(this,arguments)){var o,s,a,u,l=n.touches,c=l.length,h=b(this,i,n.changedTouches.length===c).event(n);for(ws(n),s=0;s<c;++s)u=[u=Kt(a=l[s],this),this.__zoom.invert(u),a.identifier],h.touch0?h.touch1||h.touch0[2]===u[2]||(h.touch1=u,h.taps=0):(h.touch0=u,o=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),o&&(h.taps<2&&(e=u[0],t=setTimeout(function(){t=null},500)),In(this),h.start())}}function D(t,...e){if(this.__zooming){var n,r,i,s,a=b(this,e).event(t),u=t.changedTouches,c=u.length;for(xs(t),n=0;n<c;++n)i=Kt(r=u[n],this),a.touch0&&a.touch0[2]===r.identifier?a.touch0[0]=i:a.touch1&&a.touch1[2]===r.identifier&&(a.touch1[0]=i);if(r=a.that.__zoom,a.touch1){var h=a.touch0[0],p=a.touch0[1],f=a.touch1[0],d=a.touch1[1],m=(m=f[0]-h[0])*m+(m=f[1]-h[1])*m,_=(_=d[0]-p[0])*_+(_=d[1]-p[1])*_;r=g(r,Math.sqrt(m/_)),i=[(h[0]+f[0])/2,(h[1]+f[1])/2],s=[(p[0]+d[0])/2,(p[1]+d[1])/2]}else{if(!a.touch0)return;i=a.touch0[0],s=a.touch0[1]}a.zoom("touch",o(y(r,i,s),a.extent,l))}}function O(t,...r){if(this.__zooming){var i,o,s=b(this,r).event(t),a=t.changedTouches,u=a.length;for(ws(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<u;++i)o=a[i],s.touch0&&s.touch0[2]===o.identifier?delete s.touch0:s.touch1&&s.touch1[2]===o.identifier&&delete s.touch1;if(s.touch1&&!s.touch0&&(s.touch0=s.touch1,delete s.touch1),s.touch0)s.touch0[1]=this.__zoom.invert(s.touch0[0]);else if(s.end(),2===s.taps&&(o=Kt(o,this),Math.hypot(e[0]-o[0],e[1]-o[1])<d)){var l=Wt(this).on("dblclick.zoom");l&&l.apply(this,arguments)}}}return m.transform=function(t,e,n,r){var i=t.selection?t.selection():t;i.property("__zoom",Ns),t!==i?v(t,e,n,r):i.interrupt().each(function(){b(this,arguments).event(r).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},m.scaleBy=function(t,e,n,r){m.scaleTo(t,function(){return this.__zoom.k*("function"==typeof e?e.apply(this,arguments):e)},n,r)},m.scaleTo=function(t,e,n,r){m.transform(t,function(){var t=i.apply(this,arguments),r=this.__zoom,s=null==n?_(t):"function"==typeof n?n.apply(this,arguments):n,a=r.invert(s),u="function"==typeof e?e.apply(this,arguments):e;return o(y(g(r,u),s,a),t,l)},n,r)},m.translateBy=function(t,e,n,r){m.transform(t,function(){return o(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),l)},null,r)},m.translateTo=function(t,e,n,r,s){m.transform(t,function(){var t=i.apply(this,arguments),s=this.__zoom,a=null==r?_(t):"function"==typeof r?r.apply(this,arguments):r;return o(bs.translate(a[0],a[1]).scale(s.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,l)},r,s)},w.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1===++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0===--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var e=Wt(this.that).datum();p.call(t,this.that,new _s(t,{sourceEvent:this.sourceEvent,target:m,type:t,transform:this.that.__zoom,dispatch:p}),e)}},m.wheelDelta=function(t){return arguments.length?(s="function"==typeof t?t:ys(+t),m):s},m.filter=function(t){return arguments.length?(r="function"==typeof t?t:ys(!!t),m):r},m.touchable=function(t){return arguments.length?(a="function"==typeof t?t:ys(!!t),m):a},m.extent=function(t){return arguments.length?(i="function"==typeof t?t:ys([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),m):i},m.scaleExtent=function(t){return arguments.length?(u[0]=+t[0],u[1]=+t[1],m):[u[0],u[1]]},m.translateExtent=function(t){return arguments.length?(l[0][0]=+t[0][0],l[1][0]=+t[1][0],l[0][1]=+t[0][1],l[1][1]=+t[1][1],m):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},m.constrain=function(t){return arguments.length?(o=t,m):o},m.duration=function(t){return arguments.length?(c=+t,m):c},m.interpolate=function(t){return arguments.length?(h=t,m):h},m.on=function(){var t=p.on.apply(p,arguments);return t===p?m:t},m.clickDistance=function(t){return arguments.length?(f=(t=+t)*t,m):Math.sqrt(f)},m.tapDistance=function(t){return arguments.length?(d=+t,m):d},m}().scaleExtent([.1,10]).on("zoom",t=>{Wt("."+Gc["tree-container"]).attr("transform",e=>t.transform),Wt("."+Gc["tree-scale-bar"]).attr("transform",e=>{let n=t.transform;return n.y-=10,n})});this.svg.call(t)}return this}_handle_single_node_layout(t){let e=this.nodeSpan(t)/this.rescale_nodeSpan;this.x=t.x=this.x+this.separation(this.last_node,t)+.5*(this.last_span+e),this._extents[1][1]=Math.max(this._extents[1][1],t.y),this._extents[1][0]=Math.min(this._extents[1][0],t.y-.5*e),this.is_under_collapsed_parent?this._extents[0][1]=Math.max(this._extents[0][1],this.save_x+(t.x-this.save_x)*this.options.compression+this.save_span+(.5*e+this.separation(this.last_node,t))*this.options.compression):this._extents[0][1]=Math.max(this._extents[0][1],this.x+.5*e+this.separation(this.last_node,t)),this.last_node=t,this.last_span=e}tree_layout(t){if(th(t))return;let e=yl(t);t.text_angle=null,t.text_align=null,t.radius=null,t.angle=null;let n=!1;if(t.parent)if(this.do_scaling){if(n)return 0;if(t.y=this.phylotree.branch_length_accessor(t),void 0===t.y)return n=!0,0;t.y+=t.parent.y}else t.y=e?this.max_depth:t.depth;else this.x=0,t.y=0,this.last_node=null,this.last_span=0,this._extents=[[0,0],[0,0]];if(e&&this._handle_single_node_layout(t),!e)if(nh(t)&&!this.is_under_collapsed_parent){if(this.save_x=this.x,this.save_span=.5*this.last_span,this.is_under_collapsed_parent=!0,this.process_internal_node(t),this.is_under_collapsed_parent=!1,"number"==typeof t.x){t.x=this.save_x+(t.x-this.save_x)*this.options.compression+this.save_span,t.collapsed=[[t.x,t.y]];var r=e=>{e.hidden=!0,yl(e)?(this.x=e.x=this.save_x+(e.x-this.save_x)*this.options.compression+this.save_span,t.collapsed.push([e.x,e.y])):e.children.map(r)};this.x=this.save_x,r(t),t.collapsed.splice(1,0,[this.save_x,t.y]),t.collapsed.push([this.x,t.y]),t.collapsed.push([t.x,t.y]),t.hidden=!1}}else this.process_internal_node(t);return t.x}process_internal_node(t){let e=0;if(this.showInternalName(t)){let e=t.children.length/2|0,n=0,r=!1;for(let i=0;i<t.children.length;i++){"number"==typeof this.tree_layout(t.children[i])&&n++,n>=e&&!r&&(this._handle_single_node_layout(t),r=!0)}0==n?(t.notshown=!0,t.x=void 0):r||this._handle_single_node_layout(t)}else t.x=t.children.map(this.tree_layout.bind(this)).reduce((t,n)=>"number"==typeof n?t+n:(e+=1,t),0),e==t.children.length?(t.notshown=!0,t.x=void 0):t.x/=t.children.length-e}do_lr(t){if(this.radial()&&t&&(this.offsets[1]=0),"fixed-step"==this.options["left-right-spacing"])this.size[1]=this.max_depth*this.fixed_width[1],this.scales[1]=(this.size[1]-this.offsets[1]-this.options["left-offset"])/this._extents[1][1],this.label_width=this._label_width(this.shown_font_size),this.radial()&&(this.label_width*=2);else{this.label_width=this._label_width(this.shown_font_size),t=!0;let e=this.size[1]-this.offsets[1]-this.options["left-offset"];.5*e<this.label_width&&(this.shown_font_size*=.5*e/this.label_width,this.label_width=.5*e),this.scales[1]=(this.size[1]-this.offsets[1]-this.options["left-offset"]-this.label_width)/this._extents[1][1]}}placenodes(){this._extents=[[0,0],[0,0]],this.x=0,this.last_span=0,this.last_node=null,this.last_span=0,this.save_x=this.x,this.save_span=.5*this.last_span,this.do_scaling=this.options.scaling;this.is_under_collapsed_parent=!1,this.max_depth=1,this.phylotree.nodes.x=this.tree_layout(this.phylotree.nodes,this.do_scaling),this.max_depth=function(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n<e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n<i||void 0===n&&i>=i)&&(n=i)}return n}(this.phylotree.nodes.descendants(),t=>t.depth),this.do_scaling;let t=!1;if(this.draw_scale_bar=this.options["show-scale"]&&this.do_scaling,this.offsets[1]=Math.max(this.font_size,-this._extents[1][0]*this.fixed_width[0]),"fixed-step"==this.options["top-bottom-spacing"]?(this.size[0]=this._extents[0][1]*this.fixed_width[0],this.scales[0]=this.fixed_width[0]):(this.scales[0]=(this.size[0]-this.pad_height())/this._extents[0][1],t=!0),this.shown_font_size=Math.min(this.font_size,this.scales[0]),this.radial()){this.draw_branch=u.partial(Vc,this.radial_center),this.edge_placer=$c;let e=null,n=null,r=null,i=0,o=this._extents[0][1]*this.scales[0],s=function(t,e,n,r,i){return i=i||0,Math.sqrt((e-t)*(e-t)+2*(t+i)*(e+i)*(1-Math.cos(n-r)))},a=0;this.phylotree.nodes.each(t=>{let e=t.x*this.scales[0];t.angle=2*Math.PI*e/o,t.text_angle=t.angle-Math.PI/2,t.text_angle=t.text_angle>0&&t.text_angle<Math.PI,t.text_align=t.text_angle?"end":"start",t.text_angle=(t.text_angle?180:0)+180*t.angle/Math.PI}),this.do_lr(t),this.phylotree.nodes.each(t=>{t.radius=t.y*this.scales[1]/this.size[1],a=Math.max(t.radius,a)});let l=0;this.phylotree.nodes.each(t=>{if(!t.children){let o=t.x*this.scales[0];if(null!==e){let u=o-n,c=s(t.radius,r,t.angle,e,l),h=c>0?u/c:10*this.options["max-radius"];if(h>this.options["max-radius"]){let n=u/this.options["max-radius"],o=t.radius+r,s=t.radius*r-(n*n-(r-t.radius)*(r-t.radius))/2/(1-Math.cos(e-t.angle)),c=Math.sqrt(o*o-4*s);l=Math.min(this.options["annular-limit"]*a,(-o+c)/2),i=this.options["max-radius"]}else i=Math.max(i,h)}e=t.angle,n=o,r=t.radius}}),this.radius=Math.min(this.options["max-radius"],Math.max(o/2/Math.PI,i)),t&&(this.radius=Math.min(this.radius,.5*(Math.min(o,this._extents[1][1]*this.scales[1])-this.label_width)-this.radius*l)),this.radial_center=this.radius_pad_for_bubbles=this.radius,this.draw_branch=u.partial(Vc,this.radial_center);let c=1;l&&(c=a/(a+l),this.radius*=c),this.phylotree.nodes.each(t=>{if(Bc(t,this.radius,l,this.radial_center,this.scales,this.size),a=Math.max(a,t.radius),this.options["draw-size-bubbles"]?this.radius_pad_for_bubbles=Math.max(this.radius_pad_for_bubbles,t.radius+this.nodeBubbleSize(t)):this.radius_pad_for_bubbles=Math.max(this.radius_pad_for_bubbles,t.radius),t.collapsed){t.collapsed=t.collapsed.map(t=>{let e={};return e.x=t[0],e.y=t[1],e=Bc(e,this.radius,l,this.radial_center,this.scales,this.size),[e.x,e.y]});let e=t.collapsed[1];t.collapsed=t.collapsed.filter(function(n,r){return r<3||r>t.collapsed.length-4||Math.sqrt(Math.pow(n[0]-e[0],2)+Math.pow(n[1]-e[1],2))>3&&(e=n,!0)})}}),this.size[0]=this.radial_center+this.radius/c,this.size[1]=this.radial_center+this.radius/c}else this.do_lr(),this.draw_branch=Yc,this.edge_placer=qc,this.right_most_leaf=0,this.phylotree.nodes.each(t=>{if(t.x*=this.scales[0],t.y*=.8*this.scales[1],"right-to-left"==this.options.layout&&(t.y=this._extents[1][1]*this.scales[1]-t.y),yl(t)&&(this.right_most_leaf=Math.max(this.right_most_leaf,t.y+this.nodeBubbleSize(t))),t.collapsed){t.collapsed.forEach(t=>{t[0]*=this.scales[0],t[1]*=.8*this.scales[1]});let e=t.collapsed[1][0];t.collapsed=t.collapsed.filter(function(n,r){return r<3||r>t.collapsed.length-4||n[0]-e>3&&(e=n[0],!0)})}});if(this.draw_scale_bar){let t,e;if(this.radial()){if(e=Math.min(this.radius/5,50),t=Math.pow(10,Math.ceil(Math.log(this._extents[1][1]*e/this.radius)/Math.log(10))),e=t*(this.radius/this._extents[1][1]),e<30){let n=Math.ceil(30/e);e*=n,t*=n}}else t=this._extents[1][1],e=this.size[1]-this.offsets[1]-this.options["left-offset"]-this.shown_font_size;let n=ci().domain([0,t]).range([0,e]),r=Vr(".2f");if(this.draw_scale_bar=function(t){return M(1,t)}().scale(n).tickFormat(function(t){return 0===t?"":r(t)}),this.radial())this.draw_scale_bar.tickValues([t]);else{let t=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)},i=n.ticks();i=i.length>1?i[1]:i[0],this.draw_scale_bar.ticks(Math.min(10,t(e/(this.shown_font_size*r(i).length*2),0)))}}else this.draw_scale_bar=null;return this}spacing_x(t,e){return arguments.length?(this.fixed_width[0]!=t&&t>=this.options["minimum-per-node-spacing"]&&t<=this.options["maximum-per-node-spacing"]&&(this.fixed_width[0]=t,e||this.placenodes()),this):this.fixed_width[0]}spacing_y(t,e){return arguments.length?(this.fixed_width[1]!=t&&t>=this.options["minimum-per-level-spacing"]&&t<=this.options["maximum-per-level-spacing"]&&(this.fixed_width[1]=t,e||this.placenodes()),this):this.fixed_width[1]}_label_width(t){t=t||this.shown_font_size;let e=0;return this.phylotree.nodes.descendants().filter(Jc).forEach(n=>{let r=12+this._nodeLabel(n).length*t*.8;null!==n.angle&&(r*=Math.max(Math.abs(Math.cos(n.angle)),Math.abs(Math.sin(n.angle)))),e=Math.max(r,e)}),e}font_size(t){return arguments.length?(this.font_size=void 0===t?12:t,this):this.font_size}scale_bar_font_size(t){return arguments.length?(this.scale_bar_font_size=void 0===t?12:t,this):this.scale_bar_font_size}node_circle_size(t,e){return arguments.length?(this.options.node_circle_size=bh(void 0===t?3:t),this):this.options.node_circle_size}css(t){if(0===arguments.length)return this.css_classes;if(arguments.length>2){var e={};return e[t[0]]=t[1],this.css(e)}for(var n in Gc)n in t&&t[n]!=Gc[n]&&(Gc[n]=t[n]);return this}transitions(t){return void 0!==t?t:null!==this.options.transitions?this.options.transitions:this.phylotree.nodes.descendants().length<=300}css_classes(t,e){if(!arguments.length)return this.css_classes;let n=!1;for(var r in Gc)r in t&&t[r]!=this.css_classes[r]&&(n=!0,this.css_classes[r]=t[r]);return e&&n&&this.layout(),this}layout(t){return this.svg?(this.svg.selectAll("."+this.css_classes["tree-container"]+",."+this.css_classes["tree-scale-bar"]+",."+this.css_classes["tree-selection-brush"]),this.d3PhylotreeTriggerLayout(this),this.update()):(this.d3PhylotreeTriggerLayout(this),this)}handle_node_click(t,e){this.nodeDropdownMenu(t,this.container,this,this.options,e)}refresh(){if(this.svg){let t=this.svg.selectAll("."+this.css_classes["tree-container"]).selectAll(lh(this.css_classes)).attr("class",this.reclassEdge.bind(this));this.edge_styler&&t.each(t=>{this.edge_styler(Wt(this),t)})}return this}countHandler(t){return arguments.length?(this.count_listener_handler=t,this):this.count_listener_handler}style_nodes(t){return arguments.length?(this.node_styler=t,this):this.node_styler}style_edges(t){return arguments.length?(this.edge_styler=t.bind(this),this):this.edge_styler}itemSelected(t,e){return t[e]||!1}show(){return this.svg.node()}}u.extend(wh.prototype,ah),u.extend(wh.prototype,oh),u.extend(wh.prototype,ch),u.extend(wh.prototype,gh),u.extend(wh.prototype,vh),u.extend(wh.prototype,Zc);let xh=class{constructor(t,e={}){this.newick_string="",this.nodes=[],this.links=[],this.parsed_tags=[],this.partitions=[],this.branch_length_accessor=Lc,this.branch_length=Lc,this.logger=e.logger||console,this.selection_attribute_name="selected";var n=e.type||void 0,r=[],i=this;if(u.isString(n))n in Mc?r=Mc[n](t,e):i.logger.error("type "+n+" not in registry! Available types are "+u.keys(Mc));else if(u.isFunction(n))try{r=n(t,e)}catch(t){i.logger.error("Could not parse custom format!")}else"root"==t.name?r={json:t,error:null}:"string"!=typeof t?r=t:"application/xml"==t.contentType?r=Cc(t):(this.newick_string=t,r=bl(t,e));if(r.json){i.nodes=Gr(r.json);let t={};i.nodes.each(e=>{e.data.annotation&&(t[e.data.annotation]=!0)}),i.parsed_tags=Object.keys(t)}else i.nodes=[];return i.links=i.nodes.links(),this.hasBranchLengths()||(console.warn("Phylotree User Warning : NO BRANCH LENGTHS DETECTED, SETTING ALL LENGTHS TO 1"),this.setBranchLength(t=>1)),i}json(t){var e=0;this.traverse_and_compute(function(t){t.json_export_index=e++},t);var n=new Array(e);return e=0,this.traverse_and_compute(function(t){let r=u.clone(t);delete r.json_export_index,t.parent&&(r.parent=t.parent.json_export_index),t.children&&(r.children=u.map(t.children,function(t){return t.json_export_index})),n[e++]=r},t),this.traverse_and_compute(function(t){delete t.json_export_index},t),JSON.stringify(n)}traverse_and_compute(t,e,n,r){return(e="pre-order"==(e=e||"post-order")?function(e){Sc(e,t,r)}:"in-order"==e?function(e){kc(e,t,r)}:function(e){u.isUndefined(e)||Pc(e,t,r)})(n||this.nodes),this}get_parsed_tags(){return this.parsed_tags}update(t){this.nodes=t}render(t){return this.display=new wh(this,t),this.display}};function Th(t){var e=t.branch_length_accessor;if(!e)throw"A non-null branch lengths accessor function is required for this operation";var n=0;function r(t){for(var e=0;e<t.children.length;e++)for(var n=0;n<t.children.length;n++)e!=n&&u.each(t.children[n].cot_path_to_leaves_below,function(r,i){t.children[e].cot_path_to_leaves_above&&(t.children[e].cot_path_to_leaves_above[i]=r+t.children[n].cot_computed_length)})}return t.traverse_and_compute(function(r){if(r.cot_computed_length=e(r),r.parent&&u.isUndefined(r.cot_computed_length))throw"Non-null branch lengths are required for this operation: missing branch length at node "+r.data.name;t.isLeafNode(r)?(r.cot_leaf_index=n++,r.cot_path_to_leaves_below={},r.cot_path_to_leaves_below[r.cot_leaf_index]=0,r.cot_path_to_leaves_above={}):(r.cot_path_to_leaves_below={},r.cot_path_to_leaves_above={})}),t.traverse_and_compute(function(t){t.parent&&u.each(t.cot_path_to_leaves_below,function(e,n){t.parent.cot_path_to_leaves_below[n]=e+t.cot_computed_length})}),r(t.getRootNode()),t.traverse_and_compute(function(e){e.parent&&(u.each(e.parent.cot_path_to_leaves_above,function(t,n){e.cot_path_to_leaves_above[n]=t+e.parent.cot_computed_length}),t.isLeafNode(e)||r(e))},"pre-order"),n}function Eh(t,e,n,r,i){var o=t.branch_length(e),s=!1;if(n||(r=e.data.rootToTip,i=0,s=!0),e.children)for(var a=0;a<e.children.length;a++)e.children[a]!=n?Eh(t,e.children[a],e,r,i):s=!0;e.data.rtta=e.data.rootToTip-r+i,s&&(r-=o,i+=o),e.parent&&s&&Eh(t,e.parent,e,r,i)}function Nh(t){var e=t.reduce(function(t,e){return e[2]+t},0),n=t.reduce(function(t,e){return e[2]*e[0]+t},0),r=t.reduce(function(t,e){return e[2]*e[1]+t},0),i=n/e,o=r/e,s=0,a=0,u=0;t.forEach(function(t){var e=t[0]-i;a+=t[2]*e*e,s+=t[2]*e*t[1],u+=t[2]*(t[1]-o)*(t[1]-o)});var l=(r-n*(s/=a))/e,c=0;return t.forEach(function(t){var e=t[1]-l-s*t[0];c+=t[2]*e*e}),{intercept:l,slope:s,r2:1-c/u,"var (intercept)":Math.sqrt((1+n*n/(e*a))/e),"var (slope)":Math.sqrt(1/a)}}function Dh(t){var e=t.branch_length_accessor,n=0;t.traverse_and_compute(r=>{if(r.parent&&(r.data._computed_length=e(r),!u.isNumber(r.data._computed_length)))throw"rootToTip cannot be run on trees with missing branch lengths";t.isLeafNode(r)&&(r.data.leaf_index=n++),"r2t"in r.data&&delete r.data.r2t}),t.traverse_and_compute(e=>{e.parent&&("r2t"in e.parent.data||(e.parent.data.r2t={}),t.isLeafNode(e)?e.parent.data.r2t[e.data.leaf_index]=e.data._computed_length:(u.each(e.data.r2t,function(t,n){e.parent.data.r2t[n]=t+e.data._computed_length}),delete e.data.r2t),delete e.data._computed_length)});var r=t.getRootNode().data.r2t;return t.traverse_and_compute(e=>{t.isLeafNode(e)&&(e.data.rootToTip=r[e.data.leaf_index]||0,delete e.data.leaf_index)}),delete t.getRootNode().data.r2t,t}xh.prototype.isLeafNode=yl,xh.prototype.selectAllDescendants=_l,xh.prototype.mrca=function(t){var e;return t=t.map(function(t){return"string"==typeof t?t:t.data.name}),this.traverse_and_compute(function(n){n.children?n.parent?(n.data.mrca=u.union(...n.descendants().map(t=>t.data.mrca)),e||n.data.mrca.length!=t.length||(e=n)):e||(e=n):n.data.mrca=u.intersection([n.data.name],t)}),e},xh.prototype.hasBranchLengths=function(){let t=this.branch_length;return!!t&&u.every(this.nodes.descendants(),function(e){return!e.parent||!u.isUndefined(t(e))})},xh.prototype.getBranchLengths=function(){let t=this.branch_length;return u.map(this.nodes.descendants(),e=>t(e))},xh.prototype.branchName=function(t){return arguments.length?(this.nodeLabel=t,this):this.nodeLabel},xh.prototype.normalizeBranchLengths=function(t){let e=this.branch_length,n=u.map(this.nodes.descendants(),function(t){return e(t)?e(t):null});const r=u.max(n),i=u.min(n);return u.each(this.nodes.descendants(),t=>{let n=e(t);n&&e(t,function(t){return(t-i)/(r-i)}(n))}),this},xh.prototype.scaleBranchLengths=function(t){let e=this.branch_length;return u.each(this.nodes.descendants(),n=>{let r=e(n);r&&e(n,t(r))}),this},xh.prototype.getNewick=wl,xh.prototype.resortChildren=function(t,e,n){return this.nodes.sum(function(t){return t.value}).sort(t),this.display&&(this.display.update_layout(this.nodes),this.display.update()),this},xh.prototype.setBranchLength=function(t){return arguments.length?(this.branch_length_accessor=t||Lc,this):this.branch_length_accessor},xh.prototype.maxParsimony=function(t,e){const n=u.partial(function(t,e){if(e.mp=[[0,0],[!1,!1]],yl(e))e.mp[1][0]=e.mp[1][1]=e[t]||!1,e.mp[0][0]=e.mp[1][0]?1:0,e.mp[0][1]=1-e.mp[0][0];else{e.children.forEach(n);var r=e.children.reduce(function(t,e){return e.mp[0][0]+t},0),i=e.children.reduce(function(t,e){return e.mp[0][1]+t},0);e[t]?(e.mp[0][0]=i+1,e.mp[1][0]=!0,e.mp[0][1]=i,e.mp[1][1]=!0):(r<i+1?(e.mp[0][0]=r,e.mp[1][0]=!1):(e.mp[0][0]=i+1,e.mp[1][0]=!0),i<r+1?(e.mp[0][1]=i,e.mp[1][1]=!0):(e.mp[0][1]=r+1,e.mp[1][1]=!1))}},e);n(this.nodes),this.nodes.each(t=>{t.parent?t.mp=t.mp[1][t.parent.mp?1:0]:t.mp=t.mp[1][t.mp[0][0]<t.mp[0][1]?0:1]}),this.display.modifySelection((t,n)=>yl(t.target)?t.target[e]:t.target.mp)},xh.prototype.getTipLengths=function(){let t=this.getTips(),e=u.map(t,t=>({name:t.data.name,length:parseFloat(t.data.attribute)}));return e=u.sortBy(e,t=>-t.length),e},xh.prototype.leftChildRightSibling=Fc,u.extend(xh.prototype,vl),u.extend(xh.prototype,jc),u.extend(xh.prototype,Nl);const Oh=Vi("%Y%m%d"),Ah=/([0-9]{4}).?([0-9]{2}).?([0-9]{2})$/g,Ih=function(t){if(yl(t)&&"name"in t){let e=Ah.exec(t.name);if(e)return e[1]+e[2]+e[3]}return null};function Ch(t,e){let n=[];for(let r of p.range(e.length))if(r!=t){let i=[];for(let n of p.range(e[r].length))n!=t&&i.push(e[r][n]);n.push(i)}return n}t.centerOfTree=function(t,e){e=e||2;var n=Th(t),r=Number.MAX_VALUE,i=0,o=null;return 2==e?t.traverse_and_compute(function(t){if(t.parent){var e=0,s=0,a=0,l=0,c=0;u.each(t.cot_path_to_leaves_below,function(t){e+=t,s+=t*t,c++}),u.each(t.cot_path_to_leaves_above,function(t){a+=t,l+=t*t});var h=n-c,p=(a-e+t.cot_computed_length*h)/n;p<0?p=0:p>t.cot_computed_length&&(p=t.cot_computed_length);var f=l+s+2*(a*(t.cot_computed_length-p)+e*p)+c*p*p+(t.cot_computed_length-p)*(t.cot_computed_length-p)*h;f<r&&(o=t,i=p/t.cot_computed_length,r=f),delete t.cot_computed_length,delete t.cot_path_to_leaves_below,delete t.cot_path_to_leaves_above,delete t.cot_leaf_index}}):t.traverse_and_compute(function(t){if(t.parent)for(var n=t.cot_computed_length>0?.05*t.cot_computed_length:.1,s=0;s<t.cot_computed_length;){var a=0;u.each(t.cot_path_to_leaves_below,function(t){a+=Math.pow(t+s,e)}),u.each(t.cot_path_to_leaves_above,function(n){a+=Math.pow(n+(t.cot_computed_length-s),e)}),a<r&&(o=t,i=s/t.cot_computed_length,r=a),s+=n}}),{location:o,breakpoint:i,distance:r}},t.clusterPicker=function(t,e,n,r,i){r=r||t.getRootNode(),i=u.isNumber(i)?i:1;let o=t.branch_length;t.traverse_and_compute(function(t){if(t.parent){if(t._computed_length=o(t),!u.isNumber(t._computed_length))throw"clusterPicker cannot be run on trees with missing branch lengths";t.max_path_length=0}}),t.traverse_and_compute(function(t){t.parent&&(t.parent.max_path_length=Math.max(t.parent.max_path_length,t.max_path_length+t._computed_length))});var s=[];return t.traverse_and_compute(u.noop,"pre-order",r,function(r){if(!t.isLeafNode(r)){var o=u.isString(r.data.bootstrap_values)?+r.data.bootstrap_values:i;if(o>=e){var a=u.reduce(r.children,function(t,e){return e.max_path_length+e._computed_length+t},0);if(a<=n)return s.push({root:r,diameter:a,bootstrap:o}),!0}}return!1}),t.traverse_and_compute(function(t){t.parent&&(delete t._computed_length,delete t.max_path_length)},"post-order",r),u.each(s,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),s},t.computeMidpoint=function(t){if(!t.hasBranchLengths())throw"Center of tree calculation cannot be performed on trees that do not have fully specified branch lengths";var e=t.branch_length;t.traverse_and_compute(function(n){if(n.parent){var r,i=e(n);t.isLeafNode(n)?(r=n,n.max_path=0,n.max_path_terminus=n):(i+=n.max_path,r=n.max_path_terminus),(!n.parent.max_path||n.parent.max_path<i)&&(n.parent.max_path=i,n.parent.max_path_terminus=r)}});var n=t.getRootNode(),r=0;if(n.children.forEach(function(t){if(t.max_path_terminus!==n.max_path_terminus){var i=t.max_path+e(t);i>=r&&(r=i)}}),n.max_path>r){r=.5*(r+n.max_path);for(var i=n.max_path_terminus;;){var o=e(i);if(!(o<=r))return{location:i,breakpoint:r/o};r-=o,i=i.parent}}return{location:n,breakpoint:0}},t.extract_dates=function(t,e,n=Oh){return e=e||Ih,t.traverse_and_compute(function(t){var r=e(t);if(r)try{t.data.date_value=n(r);var i=t.data.date_value.getFullYear(),o=new Date(i,0,1),s=new Date(i+1,0,1);return void(t.data.decimal_date_value=i+(t.data.date_value-o)/(s-o))}catch(t){}t.data.date_value=null,t.data.decimal_date_value=null}),t},t.fitRootToTip=function(t){var e=[],n=0,r=0;!function(t){t.traverse_and_compute(function(e){t.isLeafNode(e)&&(e.data.copy_number=1)})}(t),Dh(t),t.traverse_and_compute(function(n){t.isLeafNode(n)&&!u.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});let i=Nh(e);return t.traverse_and_compute(function(o){if(t.isLeafNode(o)&&!u.isNull(o.data.decimal_date_value)){Eh(t,o,null,0,0),e=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&!u.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});var s=Nh(e),a=s.r2;a>n&&(n=a,r=o,i=s)}}),{root:r,fit:i}},t.getDistanceMatrix=function(t){let e=p.keys(t)[0],n=t[e].length;return p.mapValues(t,e=>p.map(t,t=>p.sum(p.map(p.range(n),n=>e[n]!=t[n]&&"-"!=e[n]&&"-"!=t[n]))))},t.getNewick=wl,t.inOrder=kc,t.leftChildRightSibling=Fc,t.loadAnnotations=Tl,t.neighborJoining=function t(e,n,r){if(n<=2){let t=new xh(""),n=t.getNodes(),i=e[0][1]/2,o=t.createNode(r[0],[null,[i]]),s=t.createNode(r[1],[null,[i]]);return t.addChild(n,o),t.addChild(n,s),t}{let o=n,s=(i=e,p.map(i,p.sum)),a=function(t,e,n){let r=p.chunk(p.fill(Array(n*n),0),n);for(let i of p.range(n))for(let o of p.range(p.parseInt(i)+1,n))r[i][o]=(n-2)*t[i][o]-e[i]-e[o],r[o][i]=r[i][o];return r}(e,s,o),[u,l,c]=function(t,e){let n=-1,r=-1,i=1/0;for(let o of p.range(e))for(let s of p.range(n,e))t[o][s]<i&&(n=o,r=s,i=t[n][r]);return[n,r,i]}(a,o),h=function(t,e){let n=p.chunk(Array(e*e),e);for(let r of p.range(e))for(let i of p.range(parseInt(r)+1,e))n[r][i]=(t[r]-t[i])/(e-2),n[i][r]=n[r][i];return n}(s,o),f=(e[u][l]+h[u][l])/2,d=(e[u][l]-h[u][l])/2,m=p.concat(0,p.filter(p.map(p.range(n),t=>{if(t!=u&&t!=l)return.5*(e[t][u]+e[t][l]-e[u][l])}),p.isNumber)),g=r[u],y=r[l],_="InternalNode0",v=p.filter(r,t=>p.includes(t,"InternalNode"));if(v.length){let t=p.max(p.map(v,t=>p.split(t,"InternalNode")[1]));_="InternalNode"+ ++t}r.unshift(_),e=Ch(p.max([u,l]),e),(e=Ch(p.min([u,l]),e)).unshift(m),p.each(p.range(1,n-1),t=>e[t].unshift(m[t])),p.remove(r,t=>t==g||t==y);let b=t(e,o-1,r),w=b.createNode(g,[null,[f]]),x=b.createNode(y,[null,[d]]);if(b.getNodeByName(_)){let t=b.getNodeByName(_);b.addChild(t,w),b.addChild(t,x)}else{let t=b.createNode(_,[null,[0]]);b.addChild(b.getNodes(),t),b.addChild(t,w),b.addChild(t,x)}return b}var i},t.newickParser=bl,t.pairwise_distances=Th,t.parseAnnotations=xl,t.parseFasta=function(t){let e=p.split(t,"\n");return p.chain(e).map((t,e)=>t.startsWith(">")?e:-1).filter(t=>-1!=t).map((t,n,r)=>p.slice(e,r[n],r[n+1])).keyBy(t=>p.trim(t[0],">")).mapValues(t=>p.tail(t).join("")).value()},t.phylopart=function(t,e,n,r,i){r=u.isNumber(r)?r:1;var o=Th(t),s=t.getRootNode().children[0],a=Number.MAX_VALUE,l=Number.MAX_VALUE;if(!(n>0&&n<1))throw"Invalid percentile threshold in perform_phylopart";t.traverse_and_compute(function(e){t.isLeafNode(e)&&(e.cot_computed_length<a?(a<l&&(l=a),a=e.cot_computed_length):e.cot_computed_length<l&&(l=e.cot_computed_length))}),a+=l;var c=u.reduce(s.cot_path_to_leaves_below,function(t,e){return e>t?e:t},0)+u.reduce(s.cot_path_to_leaves_above,function(t,e){return e>t?e:t},0)+s.cot_computed_length-a;u.isUndefined(i)&&(i=Math.min(.001,c/100));var h=1+(c/i|0);h>500&&(i=c/(h=500));var p=t.getRootNode();p.paths_to_leaves=new Array(o),u.each(p.children,function(t){u.each(p.cot_path_to_leaves_below,function(e,n){p.paths_to_leaves[n]=e+t.cot_computed_length})}),t.traverse_and_compute(function(e){if(!t.isLeafNode(e)){e.histogram=new Array(h);for(var n=0;n<h;n++)e.histogram[n]=0;if(e.parent){var r=0;e.paths_to_leaves=[],u.each(e.cot_path_to_leaves_below,function(t,n){e.paths_to_leaves[r++]=t})}}delete e.cot_path_to_leaves_above,delete e.cot_path_to_leaves_below}),t.traverse_and_compute(function(e){if(!t.isLeafNode(e)){for(var n=0;n<e.paths_to_leaves.length;n++)for(var r=n+1;r<e.paths_to_leaves.length;r++){var o=e.paths_to_leaves[n]+e.paths_to_leaves[r];e.histogram[(o-a)/i|0]++}e.leaf_count=e.paths_to_leaves.length,delete e.paths_to_leaves}});for(var f=(o-1)*o/2*n,d=0;d<h-1&&f>p.histogram[d];d++)f-=p.histogram[d];var m=a+(d+(p.histogram[d]-f)/p.histogram[d])*i,g=[];return t.traverse_and_compute(u.noop,"pre-order",null,function(n){if(!t.isLeafNode(n)){var o=u.isString(n.data.bootstrap_values)?+n.data.bootstrap_values:r;if(o>=e){for(var s=n.leaf_count*(n.leaf_count-1)*.25,l=0;l<h-1&&s>n.histogram[l];l++)s-=n.histogram[l];var c=a+(l+(n.histogram[l]-s)/n.histogram[l])*i;if(c<=m)return g.push({root:n,median:c,bootstrap:o}),!0}}return!1}),t.traverse_and_compute(function(e){t.isLeafNode(e)||"histogram"in e&&(delete e.histogram,delete e.leaf_count)}),u.each(g,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),g},t.phylotree=xh,t.postOrder=Pc,t.preOrder=Sc,t.rootToTip=Dh,t.sackin=function(t){let e=t.getTips(),n=u.map(e,t=>t.depth);return u.reduce(n,function(t,e){return t+e},0)},Object.defineProperty(t,"__esModule",{value:!0})});
|
|
2
3
|
//# sourceMappingURL=phylotree.min.js.map
|