bionym 0.1.0__py3-none-any.whl

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.
bionym/__init__.py ADDED
@@ -0,0 +1,9 @@
1
+ """bionym: bioinformatics ID -> confidence-scored knowledge graph via JEV."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("bionym")
7
+ except PackageNotFoundError:
8
+ # source tree without an install (tests set their own expectations)
9
+ __version__ = "0.0.0.dev0"
@@ -0,0 +1,63 @@
1
+ /* @bionym/components — scoped component styles.
2
+ * All selectors are .bn-* namespaced; override freely or pass {colors}
3
+ * to components instead. CSS vars: --bn-ink, --bn-muted, --bn-line, --bn-bg. */
4
+
5
+ .bn-net-wrap, .bn-ov-wrap, .bn-detail {
6
+ --bn-ink: #1a202c; --bn-muted: #4a5568; --bn-line: #cbd5e0; --bn-bg: #f7fafc;
7
+ }
8
+
9
+ /* ---- network ---------------------------------------------------------- */
10
+ .bn-net-wrap { position: relative; }
11
+ .bn-net { display: block; width: 100%; height: auto; cursor: grab; }
12
+ .bn-net:active { cursor: grabbing; }
13
+
14
+ .bn-net .node { stroke: #fff; stroke-width: 1px; cursor: default; }
15
+ .bn-net .nodelabel { font-size: 9px; pointer-events: none; opacity: 0; transition: opacity .1s; }
16
+ .bn-net .nodelabel.on { opacity: 1; }
17
+ .bn-net .link { fill: none; }
18
+ .bn-net .link.link-dim { stroke-opacity: .04; }
19
+ .bn-net .link.link-hi { stroke-opacity: .95; stroke: #2b6cb0; }
20
+ .bn-net .colhead { font-size: 11px; font-weight: 600; fill: var(--bn-muted); }
21
+ .bn-net .nodeg.dim { opacity: .12; }
22
+ .bn-net .nodeg:focus { outline: none; }
23
+ .bn-net .nodeg:focus .node { stroke: #2b6cb0; stroke-width: 2px; }
24
+ .bn-net .cluster { cursor: pointer; }
25
+
26
+ /* tooltip — absolutely positioned element inside the container */
27
+ .bn-tip {
28
+ position: fixed; z-index: 10; pointer-events: none;
29
+ background: #fff; border: 1px solid var(--bn-line); border-radius: 6px;
30
+ padding: .4rem .6rem; font-size: .78rem; max-width: 22rem;
31
+ box-shadow: 0 2px 8px rgba(0,0,0,.12); color: var(--bn-ink);
32
+ }
33
+ .bn-tip .bn-t-title { font-weight: 600; margin-bottom: .15rem; }
34
+ .bn-tip .bn-t-sub { color: var(--bn-muted); }
35
+
36
+ /* legend */
37
+ .bn-legend {
38
+ display: flex; flex-wrap: wrap; gap: .4rem 1rem;
39
+ padding: .4rem .2rem; font-size: .75rem; color: var(--bn-muted);
40
+ }
41
+ .bn-legend .leg { display: inline-flex; align-items: center; gap: .3rem; }
42
+ .bn-legend .leg i { width: .7rem; height: .7rem; border-radius: 50%; display: inline-block; }
43
+
44
+ /* ---- overview bar chart ------------------------------------------------ */
45
+ .bn-ov { display: block; width: 100%; height: auto; }
46
+ .bn-ov text { font-size: 9px; fill: var(--bn-muted); }
47
+ .bn-ov .seg { stroke: #fff; stroke-width: .5px; }
48
+ .bn-ov .bar:hover { opacity: .85; }
49
+
50
+ /* ---- detail panel -------------------------------------------------------
51
+ * Positioning is the consumer's — component only styles the box. Put it in
52
+ * an <aside> or wherever fits your layout. */
53
+ .bn-detail {
54
+ background: #fff; border: 1px solid var(--bn-line); border-radius: 8px;
55
+ padding: .7rem .9rem; font-size: .8rem; color: var(--bn-ink);
56
+ box-shadow: 0 4px 14px rgba(0,0,0,.15);
57
+ }
58
+ .bn-detail h3 { margin: 0 0 .3rem; font-size: .9rem; }
59
+ .bn-detail .bn-d-sub { color: var(--bn-muted); font-size: .72rem; word-break: break-all; }
60
+ .bn-detail ul { margin: .4rem 0 0; padding-left: 1.1rem; }
61
+ .bn-detail .bn-d-close { float: right; background: none; border: 0; color: var(--bn-muted); font-size: 1rem; padding: 0; cursor: pointer; }
62
+ .bn-detail .bn-d-actions a { margin-right: .8rem; font-size: .78rem; }
63
+ .bn-conf { color: var(--bn-muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
@@ -0,0 +1 @@
1
+ var BionymComponents=(()=>{var Cr=Object.defineProperty;var Ra=Object.getOwnPropertyDescriptor;var Oa=Object.getOwnPropertyNames;var Pa=Object.prototype.hasOwnProperty;var za=(t,e)=>{for(var r in e)Cr(t,r,{get:e[r],enumerable:!0})},Da=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Oa(e))!Pa.call(t,o)&&o!==r&&Cr(t,o,{get:()=>e[o],enumerable:!(n=Ra(e,o))||n.enumerable});return t};var Ba=t=>Da(Cr({},"__esModule",{value:!0}),t);var Df={};za(Df,{BAR_COLOR:()=>Er,BionymDetail:()=>Ia,BionymNetwork:()=>$a,BionymOverview:()=>Ca,FALLBACK_COLOR:()=>Ar,PREDICATE_OTHER:()=>fe,PREDICATE_PALETTE:()=>ue,TYPE_ORDER:()=>bt,TYPE_PALETTE:()=>Mr,edgesToRows:()=>Aa,ellipsize:()=>De,esc:()=>tt,filterByConfidence:()=>Sr,mergePalette:()=>Tr,nodesToRows:()=>Ma,parseGraph:()=>yt,predicateColors:()=>Nr,resolveId:()=>Ta,typeCounts:()=>Ea});function Bt(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Ir(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Be(t){let e,r,n;t.length!==2?(e=Bt,r=(u,f)=>Bt(t(u),f),n=(u,f)=>t(u)-f):(e=t===Bt||t===Ir?t:La,r=t,n=t);function o(u,f,s=0,l=u.length){if(s<l){if(e(f,f)!==0)return l;do{let h=s+l>>>1;r(u[h],f)<0?s=h+1:l=h}while(s<l)}return s}function i(u,f,s=0,l=u.length){if(s<l){if(e(f,f)!==0)return l;do{let h=s+l>>>1;r(u[h],f)<=0?s=h+1:l=h}while(s<l)}return s}function a(u,f,s=0,l=u.length){let h=o(u,f,s,l-1);return h>s&&n(u[h-1],f)>-n(u[h],f)?h-1:h}return{left:o,center:a,right:i}}function La(){return 0}function Rr(t){return t===null?NaN:+t}var On=Be(Bt),Pn=On.right,qa=On.left,Fa=Be(Rr).center,Or=Pn;var $t=class extends Map{constructor(e,r=Xa){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),e!=null)for(let[n,o]of e)this.set(n,o)}get(e){return super.get(zn(this,e))}has(e){return super.has(zn(this,e))}set(e,r){return super.set(Ha(this,e),r)}delete(e){return super.delete(ja(this,e))}};function zn({_intern:t,_key:e},r){let n=e(r);return t.has(n)?t.get(n):r}function Ha({_intern:t,_key:e},r){let n=e(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function ja({_intern:t,_key:e},r){let n=e(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function Xa(t){return t!==null&&typeof t=="object"?t.valueOf():t}function ce(t){return t}function Lt(t,...e){return Dn(t,ce,ce,e)}function pe(t,e,...r){return Dn(t,ce,e,r)}function Dn(t,e,r,n){return(function o(i,a){if(a>=n.length)return r(i);let u=new $t,f=n[a++],s=-1;for(let l of i){let h=f(l,++s,i),c=u.get(h);c?c.push(l):u.set(h,[l])}for(let[l,h]of u)u.set(l,o(h,a));return e(u)})(t,0)}var Ya=Math.sqrt(50),Va=Math.sqrt(10),Ga=Math.sqrt(2);function Le(t,e,r){let n=(e-t)/Math.max(0,r),o=Math.floor(Math.log10(n)),i=n/Math.pow(10,o),a=i>=Ya?10:i>=Va?5:i>=Ga?2:1,u,f,s;return o<0?(s=Math.pow(10,-o)/a,u=Math.round(t*s),f=Math.round(e*s),u/s<t&&++u,f/s>e&&--f,s=-s):(s=Math.pow(10,o)*a,u=Math.round(t/s),f=Math.round(e/s),u*s<t&&++u,f*s>e&&--f),f<u&&.5<=r&&r<2?Le(t,e,r*2):[u,f,s]}function qe(t,e,r){if(e=+e,t=+t,r=+r,!(r>0))return[];if(t===e)return[t];let n=e<t,[o,i,a]=n?Le(e,t,r):Le(t,e,r);if(!(i>=o))return[];let u=i-o+1,f=new Array(u);if(n)if(a<0)for(let s=0;s<u;++s)f[s]=(i-s)/-a;else for(let s=0;s<u;++s)f[s]=(i-s)*a;else if(a<0)for(let s=0;s<u;++s)f[s]=(o+s)/-a;else for(let s=0;s<u;++s)f[s]=(o+s)*a;return f}function he(t,e,r){return e=+e,t=+t,r=+r,Le(t,e,r)[2]}function Pr(t,e,r){e=+e,t=+t,r=+r;let n=e<t,o=n?he(e,t,r):he(t,e,r);return(n?-1:1)*(o<0?1/-o:o)}function ct(t,e){let r;if(e===void 0)for(let n of t)n!=null&&(r<n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let o of t)(o=e(o,++n,t))!=null&&(r<o||r===void 0&&o>=o)&&(r=o)}return r}function kt(t,e){let r;if(e===void 0)for(let n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let o of t)(o=e(o,++n,t))!=null&&(r>o||r===void 0&&o>=o)&&(r=o)}return r}function me(t,e){let r=0,n=0;if(e===void 0)for(let o of t)o!=null&&(o=+o)>=o&&(++r,n+=o);else{let o=-1;for(let i of t)(i=e(i,++o,t))!=null&&(i=+i)>=i&&(++r,n+=i)}if(r)return n/r}function Wt(t,e,r){t=+t,e=+e,r=(o=arguments.length)<2?(e=t,t=0,1):o<3?1:+r;for(var n=-1,o=Math.max(0,Math.ceil((e-t)/r))|0,i=new Array(o);++n<o;)i[n]=t+n*r;return i}function Fe(t,e){let r=0;if(e===void 0)for(let n of t)(n=+n)&&(r+=n);else{let n=-1;for(let o of t)(o=+e(o,++n,t))&&(r+=o)}return r}function Bn(t){return t}var zr=1,Dr=2,Ln=3,de=4,qn=1e-6;function Ka(t){return"translate("+t+",0)"}function Qa(t){return"translate(0,"+t+")"}function Ua(t){return e=>+t(e)}function Za(t,e){return e=Math.max(0,t.bandwidth()-e*2)/2,t.round()&&(e=Math.round(e)),r=>+t(r)+e}function Wa(){return!this.__axis}function Ja(t,e){var r=[],n=null,o=null,i=6,a=6,u=3,f=typeof window<"u"&&window.devicePixelRatio>1?0:.5,s=t===zr||t===de?-1:1,l=t===de||t===Dr?"x":"y",h=t===zr||t===Ln?Ka:Qa;function c(p){var y=n??(e.ticks?e.ticks.apply(e,r):e.domain()),x=o??(e.tickFormat?e.tickFormat.apply(e,r):Bn),g=Math.max(i,0)+u,d=e.range(),_=+d[0]+f,A=+d[d.length-1]+f,w=(e.bandwidth?Za:Ua)(e.copy(),f),I=p.selection?p.selection():p,b=I.selectAll(".domain").data([null]),z=I.selectAll(".tick").data(y,e).order(),L=z.exit(),C=z.enter().append("g").attr("class","tick"),B=z.select("line"),S=z.select("text");b=b.merge(b.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),z=z.merge(C),B=B.merge(C.append("line").attr("stroke","currentColor").attr(l+"2",s*i)),S=S.merge(C.append("text").attr("fill","currentColor").attr(l,s*g).attr("dy",t===zr?"0em":t===Ln?"0.71em":"0.32em")),p!==I&&(b=b.transition(p),z=z.transition(p),B=B.transition(p),S=S.transition(p),L=L.transition(p).attr("opacity",qn).attr("transform",function(M){return isFinite(M=w(M))?h(M+f):this.getAttribute("transform")}),C.attr("opacity",qn).attr("transform",function(M){var k=this.parentNode.__axis;return h((k&&isFinite(k=k(M))?k:w(M))+f)})),L.remove(),b.attr("d",t===de||t===Dr?a?"M"+s*a+","+_+"H"+f+"V"+A+"H"+s*a:"M"+f+","+_+"V"+A:a?"M"+_+","+s*a+"V"+f+"H"+A+"V"+s*a:"M"+_+","+f+"H"+A),z.attr("opacity",1).attr("transform",function(M){return h(w(M)+f)}),B.attr(l+"2",s*i),S.attr(l,s*g).text(x),I.filter(Wa).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===Dr?"start":t===de?"end":"middle"),I.each(function(){this.__axis=w})}return c.scale=function(p){return arguments.length?(e=p,c):e},c.ticks=function(){return r=Array.from(arguments),c},c.tickArguments=function(p){return arguments.length?(r=p==null?[]:Array.from(p),c):r.slice()},c.tickValues=function(p){return arguments.length?(n=p==null?null:Array.from(p),c):n&&n.slice()},c.tickFormat=function(p){return arguments.length?(o=p,c):o},c.tickSize=function(p){return arguments.length?(i=a=+p,c):i},c.tickSizeInner=function(p){return arguments.length?(i=+p,c):i},c.tickSizeOuter=function(p){return arguments.length?(a=+p,c):a},c.tickPadding=function(p){return arguments.length?(u=+p,c):u},c.offset=function(p){return arguments.length?(f=+p,c):f},c}function Br(t){return Ja(de,t)}var ts={value:()=>{}};function Hn(){for(var t=0,e=arguments.length,r={},n;t<e;++t){if(!(n=arguments[t]+"")||n in r||/[\s.]/.test(n))throw new Error("illegal type: "+n);r[n]=[]}return new He(r)}function He(t){this._=t}function es(t,e){return t.trim().split(/^|\s+/).map(function(r){var n="",o=r.indexOf(".");if(o>=0&&(n=r.slice(o+1),r=r.slice(0,o)),r&&!e.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:n}})}He.prototype=Hn.prototype={constructor:He,on:function(t,e){var r=this._,n=es(t+"",r),o,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((o=(t=n[i]).type)&&(o=rs(r[o],t.name)))return o;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<a;)if(o=(t=n[i]).type)r[o]=Fn(r[o],t.name,e);else if(e==null)for(o in r)r[o]=Fn(r[o],t.name,null);return this},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new He(t)},call:function(t,e){if((o=arguments.length-2)>0)for(var r=new Array(o),n=0,o,i;n<o;++n)r[n]=arguments[n+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=this._[t],n=0,o=i.length;n<o;++n)i[n].value.apply(e,r)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};function rs(t,e){for(var r=0,n=t.length,o;r<n;++r)if((o=t[r]).name===e)return o.value}function Fn(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=ts,t=t.slice(0,n).concat(t.slice(n+1));break}return r!=null&&t.push({name:e,value:r}),t}var qt=Hn;var je="http://www.w3.org/1999/xhtml",Lr={svg:"http://www.w3.org/2000/svg",xhtml:je,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Mt(t){var e=t+="",r=e.indexOf(":");return r>=0&&(e=t.slice(0,r))!=="xmlns"&&(t=t.slice(r+1)),Lr.hasOwnProperty(e)?{space:Lr[e],local:t}:t}function ns(t){return function(){var e=this.ownerDocument,r=this.namespaceURI;return r===je&&e.documentElement.namespaceURI===je?e.createElement(t):e.createElementNS(r,t)}}function os(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Xe(t){var e=Mt(t);return(e.local?os:ns)(e)}function is(){}function Ft(t){return t==null?is:function(){return this.querySelector(t)}}function jn(t){typeof t!="function"&&(t=Ft(t));for(var e=this._groups,r=e.length,n=new Array(r),o=0;o<r;++o)for(var i=e[o],a=i.length,u=n[o]=new Array(a),f,s,l=0;l<a;++l)(f=i[l])&&(s=t.call(f,f.__data__,l,i))&&("__data__"in f&&(s.__data__=f.__data__),u[l]=s);return new K(n,this._parents)}function qr(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function as(){return[]}function xe(t){return t==null?as:function(){return this.querySelectorAll(t)}}function ss(t){return function(){return qr(t.apply(this,arguments))}}function Xn(t){typeof t=="function"?t=ss(t):t=xe(t);for(var e=this._groups,r=e.length,n=[],o=[],i=0;i<r;++i)for(var a=e[i],u=a.length,f,s=0;s<u;++s)(f=a[s])&&(n.push(t.call(f,f.__data__,s,a)),o.push(f));return new K(n,o)}function ge(t){return function(){return this.matches(t)}}function Ye(t){return function(e){return e.matches(t)}}var us=Array.prototype.find;function fs(t){return function(){return us.call(this.children,t)}}function ls(){return this.firstElementChild}function Yn(t){return this.select(t==null?ls:fs(typeof t=="function"?t:Ye(t)))}var cs=Array.prototype.filter;function ps(){return Array.from(this.children)}function hs(t){return function(){return cs.call(this.children,t)}}function Vn(t){return this.selectAll(t==null?ps:hs(typeof t=="function"?t:Ye(t)))}function Gn(t){typeof t!="function"&&(t=ge(t));for(var e=this._groups,r=e.length,n=new Array(r),o=0;o<r;++o)for(var i=e[o],a=i.length,u=n[o]=[],f,s=0;s<a;++s)(f=i[s])&&t.call(f,f.__data__,s,i)&&u.push(f);return new K(n,this._parents)}function Ve(t){return new Array(t.length)}function Kn(){return new K(this._enter||this._groups.map(Ve),this._parents)}function ye(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}ye.prototype={constructor:ye,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)}};function Qn(t){return function(){return t}}function ms(t,e,r,n,o,i){for(var a=0,u,f=e.length,s=i.length;a<s;++a)(u=e[a])?(u.__data__=i[a],n[a]=u):r[a]=new ye(t,i[a]);for(;a<f;++a)(u=e[a])&&(o[a]=u)}function ds(t,e,r,n,o,i,a){var u,f,s=new Map,l=e.length,h=i.length,c=new Array(l),p;for(u=0;u<l;++u)(f=e[u])&&(c[u]=p=a.call(f,f.__data__,u,e)+"",s.has(p)?o[u]=f:s.set(p,f));for(u=0;u<h;++u)p=a.call(t,i[u],u,i)+"",(f=s.get(p))?(n[u]=f,f.__data__=i[u],s.delete(p)):r[u]=new ye(t,i[u]);for(u=0;u<l;++u)(f=e[u])&&s.get(c[u])===f&&(o[u]=f)}function xs(t){return t.__data__}function Un(t,e){if(!arguments.length)return Array.from(this,xs);var r=e?ds:ms,n=this._parents,o=this._groups;typeof t!="function"&&(t=Qn(t));for(var i=o.length,a=new Array(i),u=new Array(i),f=new Array(i),s=0;s<i;++s){var l=n[s],h=o[s],c=h.length,p=gs(t.call(l,l&&l.__data__,s,n)),y=p.length,x=u[s]=new Array(y),g=a[s]=new Array(y),d=f[s]=new Array(c);r(l,h,x,g,d,p,e);for(var _=0,A=0,w,I;_<y;++_)if(w=x[_]){for(_>=A&&(A=_+1);!(I=g[A])&&++A<y;);w._next=I||null}}return a=new K(a,n),a._enter=u,a._exit=f,a}function gs(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Zn(){return new K(this._exit||this._groups.map(Ve),this._parents)}function Wn(t,e,r){var n=this.enter(),o=this,i=this.exit();return typeof t=="function"?(n=t(n),n&&(n=n.selection())):n=n.append(t+""),e!=null&&(o=e(o),o&&(o=o.selection())),r==null?i.remove():r(i),n&&o?n.merge(o).order():o}function Jn(t){for(var e=t.selection?t.selection():t,r=this._groups,n=e._groups,o=r.length,i=n.length,a=Math.min(o,i),u=new Array(o),f=0;f<a;++f)for(var s=r[f],l=n[f],h=s.length,c=u[f]=new Array(h),p,y=0;y<h;++y)(p=s[y]||l[y])&&(c[y]=p);for(;f<o;++f)u[f]=r[f];return new K(u,this._parents)}function to(){for(var t=this._groups,e=-1,r=t.length;++e<r;)for(var n=t[e],o=n.length-1,i=n[o],a;--o>=0;)(a=n[o])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function eo(t){t||(t=ys);function e(h,c){return h&&c?t(h.__data__,c.__data__):!h-!c}for(var r=this._groups,n=r.length,o=new Array(n),i=0;i<n;++i){for(var a=r[i],u=a.length,f=o[i]=new Array(u),s,l=0;l<u;++l)(s=a[l])&&(f[l]=s);f.sort(e)}return new K(o,this._parents).order()}function ys(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function ro(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function no(){return Array.from(this)}function oo(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],o=0,i=n.length;o<i;++o){var a=n[o];if(a)return a}return null}function io(){let t=0;for(let e of this)++t;return t}function ao(){return!this.node()}function so(t){for(var e=this._groups,r=0,n=e.length;r<n;++r)for(var o=e[r],i=0,a=o.length,u;i<a;++i)(u=o[i])&&t.call(u,u.__data__,i,o);return this}function vs(t){return function(){this.removeAttribute(t)}}function ws(t){return function(){this.removeAttributeNS(t.space,t.local)}}function _s(t,e){return function(){this.setAttribute(t,e)}}function bs(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ks(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttribute(t):this.setAttribute(t,r)}}function Ms(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,r)}}function uo(t,e){var r=Mt(t);if(arguments.length<2){var n=this.node();return r.local?n.getAttributeNS(r.space,r.local):n.getAttribute(r)}return this.each((e==null?r.local?ws:vs:typeof e=="function"?r.local?Ms:ks:r.local?bs:_s)(r,e))}function Ge(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function As(t){return function(){this.style.removeProperty(t)}}function Es(t,e,r){return function(){this.style.setProperty(t,e,r)}}function Ts(t,e,r){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(t):this.style.setProperty(t,n,r)}}function fo(t,e,r){return arguments.length>1?this.each((e==null?As:typeof e=="function"?Ts:Es)(t,e,r??"")):Ct(this.node(),t)}function Ct(t,e){return t.style.getPropertyValue(e)||Ge(t).getComputedStyle(t,null).getPropertyValue(e)}function Ss(t){return function(){delete this[t]}}function Ns(t,e){return function(){this[t]=e}}function $s(t,e){return function(){var r=e.apply(this,arguments);r==null?delete this[t]:this[t]=r}}function lo(t,e){return arguments.length>1?this.each((e==null?Ss:typeof e=="function"?$s:Ns)(t,e)):this.node()[t]}function co(t){return t.trim().split(/^|\s+/)}function Fr(t){return t.classList||new po(t)}function po(t){this._node=t,this._names=co(t.getAttribute("class")||"")}po.prototype={add:function(t){var e=this._names.indexOf(t);e<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}};function ho(t,e){for(var r=Fr(t),n=-1,o=e.length;++n<o;)r.add(e[n])}function mo(t,e){for(var r=Fr(t),n=-1,o=e.length;++n<o;)r.remove(e[n])}function Cs(t){return function(){ho(this,t)}}function Is(t){return function(){mo(this,t)}}function Rs(t,e){return function(){(e.apply(this,arguments)?ho:mo)(this,t)}}function xo(t,e){var r=co(t+"");if(arguments.length<2){for(var n=Fr(this.node()),o=-1,i=r.length;++o<i;)if(!n.contains(r[o]))return!1;return!0}return this.each((typeof e=="function"?Rs:e?Cs:Is)(r,e))}function Os(){this.textContent=""}function Ps(t){return function(){this.textContent=t}}function zs(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function go(t){return arguments.length?this.each(t==null?Os:(typeof t=="function"?zs:Ps)(t)):this.node().textContent}function Ds(){this.innerHTML=""}function Bs(t){return function(){this.innerHTML=t}}function Ls(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function yo(t){return arguments.length?this.each(t==null?Ds:(typeof t=="function"?Ls:Bs)(t)):this.node().innerHTML}function qs(){this.nextSibling&&this.parentNode.appendChild(this)}function vo(){return this.each(qs)}function Fs(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function wo(){return this.each(Fs)}function _o(t){var e=typeof t=="function"?t:Xe(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Hs(){return null}function bo(t,e){var r=typeof t=="function"?t:Xe(t),n=e==null?Hs:typeof e=="function"?e:Ft(e);return this.select(function(){return this.insertBefore(r.apply(this,arguments),n.apply(this,arguments)||null)})}function js(){var t=this.parentNode;t&&t.removeChild(this)}function ko(){return this.each(js)}function Xs(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ys(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Mo(t){return this.select(t?Ys:Xs)}function Ao(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Vs(t){return function(e){t.call(this,e,this.__data__)}}function Gs(t){return t.trim().split(/^|\s+/).map(function(e){var r="",n=e.indexOf(".");return n>=0&&(r=e.slice(n+1),e=e.slice(0,n)),{type:e,name:r}})}function Ks(t){return function(){var e=this.__on;if(e){for(var r=0,n=-1,o=e.length,i;r<o;++r)i=e[r],(!t.type||i.type===t.type)&&i.name===t.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function Qs(t,e,r){return function(){var n=this.__on,o,i=Vs(e);if(n){for(var a=0,u=n.length;a<u;++a)if((o=n[a]).type===t.type&&o.name===t.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=r),o.value=e;return}}this.addEventListener(t.type,i,r),o={type:t.type,name:t.name,value:e,listener:i,options:r},n?n.push(o):this.__on=[o]}}function Eo(t,e,r){var n=Gs(t+""),o,i=n.length,a;if(arguments.length<2){var u=this.node().__on;if(u){for(var f=0,s=u.length,l;f<s;++f)for(o=0,l=u[f];o<i;++o)if((a=n[o]).type===l.type&&a.name===l.name)return l.value}return}for(u=e?Qs:Ks,o=0;o<i;++o)this.each(u(n[o],e,r));return this}function To(t,e,r){var n=Ge(t),o=n.CustomEvent;typeof o=="function"?o=new o(e,r):(o=n.document.createEvent("Event"),r?(o.initEvent(e,r.bubbles,r.cancelable),o.detail=r.detail):o.initEvent(e,!1,!1)),t.dispatchEvent(o)}function Us(t,e){return function(){return To(this,t,e)}}function Zs(t,e){return function(){return To(this,t,e.apply(this,arguments))}}function So(t,e){return this.each((typeof e=="function"?Zs:Us)(t,e))}function*No(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],o=0,i=n.length,a;o<i;++o)(a=n[o])&&(yield a)}var Hr=[null];function K(t,e){this._groups=t,this._parents=e}function $o(){return new K([[document.documentElement]],Hr)}function Ws(){return this}K.prototype=$o.prototype={constructor:K,select:jn,selectAll:Xn,selectChild:Yn,selectChildren:Vn,filter:Gn,data:Un,enter:Kn,exit:Zn,join:Wn,merge:Jn,selection:Ws,order:to,sort:eo,call:ro,nodes:no,node:oo,size:io,empty:ao,each:so,attr:uo,style:fo,property:lo,classed:xo,text:go,html:yo,raise:vo,lower:wo,append:_o,insert:bo,remove:ko,clone:Mo,datum:Ao,on:Eo,dispatch:So,[Symbol.iterator]:No};var At=$o;function at(t){return typeof t=="string"?new K([[document.querySelector(t)]],[document.documentElement]):new K([[t]],Hr)}function Co(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Et(t,e){if(t=Co(t),e===void 0&&(e=t.currentTarget),e){var r=e.ownerSVGElement||e;if(r.createSVGPoint){var n=r.createSVGPoint();return n.x=t.clientX,n.y=t.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var o=e.getBoundingClientRect();return[t.clientX-o.left-e.clientLeft,t.clientY-o.top-e.clientTop]}}return[t.pageX,t.pageY]}var Ke={capture:!0,passive:!1};function Qe(t){t.preventDefault(),t.stopImmediatePropagation()}function jr(t){var e=t.document.documentElement,r=at(t).on("dragstart.drag",Qe,Ke);"onselectstart"in e?r.on("selectstart.drag",Qe,Ke):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Xr(t,e){var r=t.document.documentElement,n=at(t).on("dragstart.drag",null);e&&(n.on("click.drag",Qe,Ke),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in r?n.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}function Ue(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function Yr(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function _e(){}var ve=.7,Je=1/ve,Jt="\\s*([+-]?\\d+)\\s*",we="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Js=/^#([0-9a-f]{3,8})$/,tu=new RegExp(`^rgb\\(${Jt},${Jt},${Jt}\\)$`),eu=new RegExp(`^rgb\\(${vt},${vt},${vt}\\)$`),ru=new RegExp(`^rgba\\(${Jt},${Jt},${Jt},${we}\\)$`),nu=new RegExp(`^rgba\\(${vt},${vt},${vt},${we}\\)$`),ou=new RegExp(`^hsl\\(${we},${vt},${vt}\\)$`),iu=new RegExp(`^hsla\\(${we},${vt},${vt},${we}\\)$`),Io={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};Ue(_e,ht,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Ro,formatHex:Ro,formatHex8:au,formatHsl:su,formatRgb:Oo,toString:Oo});function Ro(){return this.rgb().formatHex()}function au(){return this.rgb().formatHex8()}function su(){return qo(this).formatHsl()}function Oo(){return this.rgb().formatRgb()}function ht(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=Js.exec(t))?(r=e[1].length,e=parseInt(e[1],16),r===6?Po(e):r===3?new lt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):r===8?Ze(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):r===4?Ze(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=tu.exec(t))?new lt(e[1],e[2],e[3],1):(e=eu.exec(t))?new lt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=ru.exec(t))?Ze(e[1],e[2],e[3],e[4]):(e=nu.exec(t))?Ze(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=ou.exec(t))?Bo(e[1],e[2]/100,e[3]/100,1):(e=iu.exec(t))?Bo(e[1],e[2]/100,e[3]/100,e[4]):Io.hasOwnProperty(t)?Po(Io[t]):t==="transparent"?new lt(NaN,NaN,NaN,0):null}function Po(t){return new lt(t>>16&255,t>>8&255,t&255,1)}function Ze(t,e,r,n){return n<=0&&(t=e=r=NaN),new lt(t,e,r,n)}function uu(t){return t instanceof _e||(t=ht(t)),t?(t=t.rgb(),new lt(t.r,t.g,t.b,t.opacity)):new lt}function te(t,e,r,n){return arguments.length===1?uu(t):new lt(t,e,r,n??1)}function lt(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}Ue(lt,te,Yr(_e,{brighter(t){return t=t==null?Je:Math.pow(Je,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ve:Math.pow(ve,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new lt(jt(this.r),jt(this.g),jt(this.b),tr(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:zo,formatHex:zo,formatHex8:fu,formatRgb:Do,toString:Do}));function zo(){return`#${Ht(this.r)}${Ht(this.g)}${Ht(this.b)}`}function fu(){return`#${Ht(this.r)}${Ht(this.g)}${Ht(this.b)}${Ht((isNaN(this.opacity)?1:this.opacity)*255)}`}function Do(){let t=tr(this.opacity);return`${t===1?"rgb(":"rgba("}${jt(this.r)}, ${jt(this.g)}, ${jt(this.b)}${t===1?")":`, ${t})`}`}function tr(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function jt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Ht(t){return t=jt(t),(t<16?"0":"")+t.toString(16)}function Bo(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new pt(t,e,r,n)}function qo(t){if(t instanceof pt)return new pt(t.h,t.s,t.l,t.opacity);if(t instanceof _e||(t=ht(t)),!t)return new pt;if(t instanceof pt)return t;t=t.rgb();var e=t.r/255,r=t.g/255,n=t.b/255,o=Math.min(e,r,n),i=Math.max(e,r,n),a=NaN,u=i-o,f=(i+o)/2;return u?(e===i?a=(r-n)/u+(r<n)*6:r===i?a=(n-e)/u+2:a=(e-r)/u+4,u/=f<.5?i+o:2-i-o,a*=60):u=f>0&&f<1?0:a,new pt(a,u,f,t.opacity)}function Fo(t,e,r,n){return arguments.length===1?qo(t):new pt(t,e,r,n??1)}function pt(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}Ue(pt,Fo,Yr(_e,{brighter(t){return t=t==null?Je:Math.pow(Je,t),new pt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ve:Math.pow(ve,t),new pt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,o=2*r-n;return new lt(Vr(t>=240?t-240:t+120,o,n),Vr(t,o,n),Vr(t<120?t+240:t-120,o,n),this.opacity)},clamp(){return new pt(Lo(this.h),We(this.s),We(this.l),tr(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(){let t=tr(this.opacity);return`${t===1?"hsl(":"hsla("}${Lo(this.h)}, ${We(this.s)*100}%, ${We(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Lo(t){return t=(t||0)%360,t<0?t+360:t}function We(t){return Math.max(0,Math.min(1,t||0))}function Vr(t,e,r){return(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)*255}function Gr(t,e,r,n,o){var i=t*t,a=i*t;return((1-3*t+3*i-a)*e+(4-6*i+3*a)*r+(1+3*t+3*i-3*a)*n+a*o)/6}function Ho(t){var e=t.length-1;return function(r){var n=r<=0?r=0:r>=1?(r=1,e-1):Math.floor(r*e),o=t[n],i=t[n+1],a=n>0?t[n-1]:2*o-i,u=n<e-1?t[n+2]:2*i-o;return Gr((r-n/e)*e,a,o,i,u)}}function jo(t){var e=t.length;return function(r){var n=Math.floor(((r%=1)<0?++r:r)*e),o=t[(n+e-1)%e],i=t[n%e],a=t[(n+1)%e],u=t[(n+2)%e];return Gr((r-n/e)*e,o,i,a,u)}}var be=t=>()=>t;function lu(t,e){return function(r){return t+r*e}}function cu(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}function Xo(t){return(t=+t)==1?er:function(e,r){return r-e?cu(e,r,t):be(isNaN(e)?r:e)}}function er(t,e){var r=e-t;return r?lu(t,r):be(isNaN(t)?e:t)}var Xt=(function t(e){var r=Xo(e);function n(o,i){var a=r((o=te(o)).r,(i=te(i)).r),u=r(o.g,i.g),f=r(o.b,i.b),s=er(o.opacity,i.opacity);return function(l){return o.r=a(l),o.g=u(l),o.b=f(l),o.opacity=s(l),o+""}}return n.gamma=t,n})(1);function Yo(t){return function(e){var r=e.length,n=new Array(r),o=new Array(r),i=new Array(r),a,u;for(a=0;a<r;++a)u=te(e[a]),n[a]=u.r||0,o[a]=u.g||0,i[a]=u.b||0;return n=t(n),o=t(o),i=t(i),u.opacity=1,function(f){return u.r=n(f),u.g=o(f),u.b=i(f),u+""}}}var pu=Yo(Ho),hu=Yo(jo);function Vo(t,e){e||(e=[]);var r=t?Math.min(e.length,t.length):0,n=e.slice(),o;return function(i){for(o=0;o<r;++o)n[o]=t[o]*(1-i)+e[o]*i;return n}}function Go(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ko(t,e){var r=e?e.length:0,n=t?Math.min(r,t.length):0,o=new Array(n),i=new Array(r),a;for(a=0;a<n;++a)o[a]=Yt(t[a],e[a]);for(;a<r;++a)i[a]=e[a];return function(u){for(a=0;a<n;++a)i[a]=o[a](u);return i}}function Qo(t,e){var r=new Date;return t=+t,e=+e,function(n){return r.setTime(t*(1-n)+e*n),r}}function rt(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function Uo(t,e){var r={},n={},o;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(o in e)o in t?r[o]=Yt(t[o],e[o]):n[o]=e[o];return function(i){for(o in r)n[o]=r[o](i);return n}}var Qr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Kr=new RegExp(Qr.source,"g");function mu(t){return function(){return t}}function du(t){return function(e){return t(e)+""}}function ke(t,e){var r=Qr.lastIndex=Kr.lastIndex=0,n,o,i,a=-1,u=[],f=[];for(t=t+"",e=e+"";(n=Qr.exec(t))&&(o=Kr.exec(e));)(i=o.index)>r&&(i=e.slice(r,i),u[a]?u[a]+=i:u[++a]=i),(n=n[0])===(o=o[0])?u[a]?u[a]+=o:u[++a]=o:(u[++a]=null,f.push({i:a,x:rt(n,o)})),r=Kr.lastIndex;return r<e.length&&(i=e.slice(r),u[a]?u[a]+=i:u[++a]=i),u.length<2?f[0]?du(f[0].x):mu(e):(e=f.length,function(s){for(var l=0,h;l<e;++l)u[(h=f[l]).i]=h.x(s);return u.join("")})}function Yt(t,e){var r=typeof e,n;return e==null||r==="boolean"?be(e):(r==="number"?rt:r==="string"?(n=ht(e))?(e=n,Xt):ke:e instanceof ht?Xt:e instanceof Date?Qo:Go(e)?Vo:Array.isArray(e)?Ko:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Uo:rt)(t,e)}function Ur(t,e){return t=+t,e=+e,function(r){return Math.round(t*(1-r)+e*r)}}var Zo=180/Math.PI,rr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Zr(t,e,r,n,o,i){var a,u,f;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(f=t*r+e*n)&&(r-=t*f,n-=e*f),(u=Math.sqrt(r*r+n*n))&&(r/=u,n/=u,f/=u),t*n<e*r&&(t=-t,e=-e,f=-f,a=-a),{translateX:o,translateY:i,rotate:Math.atan2(e,t)*Zo,skewX:Math.atan(f)*Zo,scaleX:a,scaleY:u}}var nr;function Wo(t){let e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?rr:Zr(e.a,e.b,e.c,e.d,e.e,e.f)}function Jo(t){return t==null?rr:(nr||(nr=document.createElementNS("http://www.w3.org/2000/svg","g")),nr.setAttribute("transform",t),(t=nr.transform.baseVal.consolidate())?(t=t.matrix,Zr(t.a,t.b,t.c,t.d,t.e,t.f)):rr)}function ti(t,e,r,n){function o(s){return s.length?s.pop()+" ":""}function i(s,l,h,c,p,y){if(s!==h||l!==c){var x=p.push("translate(",null,e,null,r);y.push({i:x-4,x:rt(s,h)},{i:x-2,x:rt(l,c)})}else(h||c)&&p.push("translate("+h+e+c+r)}function a(s,l,h,c){s!==l?(s-l>180?l+=360:l-s>180&&(s+=360),c.push({i:h.push(o(h)+"rotate(",null,n)-2,x:rt(s,l)})):l&&h.push(o(h)+"rotate("+l+n)}function u(s,l,h,c){s!==l?c.push({i:h.push(o(h)+"skewX(",null,n)-2,x:rt(s,l)}):l&&h.push(o(h)+"skewX("+l+n)}function f(s,l,h,c,p,y){if(s!==h||l!==c){var x=p.push(o(p)+"scale(",null,",",null,")");y.push({i:x-4,x:rt(s,h)},{i:x-2,x:rt(l,c)})}else(h!==1||c!==1)&&p.push(o(p)+"scale("+h+","+c+")")}return function(s,l){var h=[],c=[];return s=t(s),l=t(l),i(s.translateX,s.translateY,l.translateX,l.translateY,h,c),a(s.rotate,l.rotate,h,c),u(s.skewX,l.skewX,h,c),f(s.scaleX,s.scaleY,l.scaleX,l.scaleY,h,c),s=l=null,function(p){for(var y=-1,x=c.length,g;++y<x;)h[(g=c[y]).i]=g.x(p);return h.join("")}}}var Wr=ti(Wo,"px, ","px)","deg)"),Jr=ti(Jo,", ",")",")");var xu=1e-12;function ei(t){return((t=Math.exp(t))+1/t)/2}function gu(t){return((t=Math.exp(t))-1/t)/2}function yu(t){return((t=Math.exp(2*t))-1)/(t+1)}var tn=(function t(e,r,n){function o(i,a){var u=i[0],f=i[1],s=i[2],l=a[0],h=a[1],c=a[2],p=l-u,y=h-f,x=p*p+y*y,g,d;if(x<xu)d=Math.log(c/s)/e,g=function(z){return[u+z*p,f+z*y,s*Math.exp(e*z*d)]};else{var _=Math.sqrt(x),A=(c*c-s*s+n*x)/(2*s*r*_),w=(c*c-s*s-n*x)/(2*c*r*_),I=Math.log(Math.sqrt(A*A+1)-A),b=Math.log(Math.sqrt(w*w+1)-w);d=(b-I)/e,g=function(z){var L=z*d,C=ei(I),B=s/(r*_)*(C*yu(e*L+I)-gu(I));return[u+B*p,f+B*y,s*C/ei(e*L+I)]}}return g.duration=d*1e3*e/Math.SQRT2,g}return o.rho=function(i){var a=Math.max(.001,+i),u=a*a,f=u*u;return t(a,u,f)},o})(Math.SQRT2,2,4);var ee=0,Ae=0,Me=0,ni=1e3,or,Ee,ir=0,Vt=0,ar=0,Te=typeof performance=="object"&&performance.now?performance:Date,oi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Ne(){return Vt||(oi(vu),Vt=Te.now()+ar)}function vu(){Vt=0}function Se(){this._call=this._time=this._next=null}Se.prototype=re.prototype={constructor:Se,restart:function(t,e,r){if(typeof t!="function")throw new TypeError("callback is not a function");r=(r==null?Ne():+r)+(e==null?0:+e),!this._next&&Ee!==this&&(Ee?Ee._next=this:or=this,Ee=this),this._call=t,this._time=r,en()},stop:function(){this._call&&(this._call=null,this._time=1/0,en())}};function re(t,e,r){var n=new Se;return n.restart(t,e,r),n}function ii(){Ne(),++ee;for(var t=or,e;t;)(e=Vt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--ee}function ri(){Vt=(ir=Te.now())+ar,ee=Ae=0;try{ii()}finally{ee=0,_u(),Vt=0}}function wu(){var t=Te.now(),e=t-ir;e>ni&&(ar-=e,ir=t)}function _u(){for(var t,e=or,r,n=1/0;e;)e._call?(n>e._time&&(n=e._time),t=e,e=e._next):(r=e._next,e._next=null,e=t?t._next=r:or=r);Ee=t,en(n)}function en(t){if(!ee){Ae&&(Ae=clearTimeout(Ae));var e=t-Vt;e>24?(t<1/0&&(Ae=setTimeout(ri,t-Te.now()-ar)),Me&&(Me=clearInterval(Me))):(Me||(ir=Te.now(),Me=setInterval(wu,ni)),ee=1,oi(ri))}}function sr(t,e,r){var n=new Se;return e=e==null?0:+e,n.restart(o=>{n.stop(),t(o+e)},e,r),n}var bu=qt("start","end","cancel","interrupt"),ku=[],ui=0,ai=1,fr=2,ur=3,si=4,lr=5,$e=6;function It(t,e,r,n,o,i){var a=t.__transition;if(!a)t.__transition={};else if(r in a)return;Mu(t,r,{name:e,index:n,group:o,on:bu,tween:ku,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ui})}function Ce(t,e){var r=Z(t,e);if(r.state>ui)throw new Error("too late; already scheduled");return r}function nt(t,e){var r=Z(t,e);if(r.state>ur)throw new Error("too late; already running");return r}function Z(t,e){var r=t.__transition;if(!r||!(r=r[e]))throw new Error("transition not found");return r}function Mu(t,e,r){var n=t.__transition,o;n[e]=r,r.timer=re(i,0,r.time);function i(s){r.state=ai,r.timer.restart(a,r.delay,r.time),r.delay<=s&&a(s-r.delay)}function a(s){var l,h,c,p;if(r.state!==ai)return f();for(l in n)if(p=n[l],p.name===r.name){if(p.state===ur)return sr(a);p.state===si?(p.state=$e,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete n[l]):+l<e&&(p.state=$e,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete n[l])}if(sr(function(){r.state===ur&&(r.state=si,r.timer.restart(u,r.delay,r.time),u(s))}),r.state=fr,r.on.call("start",t,t.__data__,r.index,r.group),r.state===fr){for(r.state=ur,o=new Array(c=r.tween.length),l=0,h=-1;l<c;++l)(p=r.tween[l].value.call(t,t.__data__,r.index,r.group))&&(o[++h]=p);o.length=h+1}}function u(s){for(var l=s<r.duration?r.ease.call(null,s/r.duration):(r.timer.restart(f),r.state=lr,1),h=-1,c=o.length;++h<c;)o[h].call(t,l);r.state===lr&&(r.on.call("end",t,t.__data__,r.index,r.group),f())}function f(){r.state=$e,r.timer.stop(),delete n[e];for(var s in n)return;delete t.__transition}}function Rt(t,e){var r=t.__transition,n,o,i=!0,a;if(r){e=e==null?null:e+"";for(a in r){if((n=r[a]).name!==e){i=!1;continue}o=n.state>fr&&n.state<lr,n.state=$e,n.timer.stop(),n.on.call(o?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete r[a]}i&&delete t.__transition}}function fi(t){return this.each(function(){Rt(this,t)})}function Au(t,e){var r,n;return function(){var o=nt(this,t),i=o.tween;if(i!==r){n=r=i;for(var a=0,u=n.length;a<u;++a)if(n[a].name===e){n=n.slice(),n.splice(a,1);break}}o.tween=n}}function Eu(t,e,r){var n,o;if(typeof r!="function")throw new Error;return function(){var i=nt(this,t),a=i.tween;if(a!==n){o=(n=a).slice();for(var u={name:e,value:r},f=0,s=o.length;f<s;++f)if(o[f].name===e){o[f]=u;break}f===s&&o.push(u)}i.tween=o}}function li(t,e){var r=this._id;if(t+="",arguments.length<2){for(var n=Z(this.node(),r).tween,o=0,i=n.length,a;o<i;++o)if((a=n[o]).name===t)return a.value;return null}return this.each((e==null?Au:Eu)(r,t,e))}function ne(t,e,r){var n=t._id;return t.each(function(){var o=nt(this,n);(o.value||(o.value={}))[e]=r.apply(this,arguments)}),function(o){return Z(o,n).value[e]}}function cr(t,e){var r;return(typeof e=="number"?rt:e instanceof ht?Xt:(r=ht(e))?(e=r,Xt):ke)(t,e)}function Tu(t){return function(){this.removeAttribute(t)}}function Su(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Nu(t,e,r){var n,o=r+"",i;return function(){var a=this.getAttribute(t);return a===o?null:a===n?i:i=e(n=a,r)}}function $u(t,e,r){var n,o=r+"",i;return function(){var a=this.getAttributeNS(t.space,t.local);return a===o?null:a===n?i:i=e(n=a,r)}}function Cu(t,e,r){var n,o,i;return function(){var a,u=r(this),f;return u==null?void this.removeAttribute(t):(a=this.getAttribute(t),f=u+"",a===f?null:a===n&&f===o?i:(o=f,i=e(n=a,u)))}}function Iu(t,e,r){var n,o,i;return function(){var a,u=r(this),f;return u==null?void this.removeAttributeNS(t.space,t.local):(a=this.getAttributeNS(t.space,t.local),f=u+"",a===f?null:a===n&&f===o?i:(o=f,i=e(n=a,u)))}}function ci(t,e){var r=Mt(t),n=r==="transform"?Jr:cr;return this.attrTween(t,typeof e=="function"?(r.local?Iu:Cu)(r,n,ne(this,"attr."+t,e)):e==null?(r.local?Su:Tu)(r):(r.local?$u:Nu)(r,n,e))}function Ru(t,e){return function(r){this.setAttribute(t,e.call(this,r))}}function Ou(t,e){return function(r){this.setAttributeNS(t.space,t.local,e.call(this,r))}}function Pu(t,e){var r,n;function o(){var i=e.apply(this,arguments);return i!==n&&(r=(n=i)&&Ou(t,i)),r}return o._value=e,o}function zu(t,e){var r,n;function o(){var i=e.apply(this,arguments);return i!==n&&(r=(n=i)&&Ru(t,i)),r}return o._value=e,o}function pi(t,e){var r="attr."+t;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;var n=Mt(t);return this.tween(r,(n.local?Pu:zu)(n,e))}function Du(t,e){return function(){Ce(this,t).delay=+e.apply(this,arguments)}}function Bu(t,e){return e=+e,function(){Ce(this,t).delay=e}}function hi(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Du:Bu)(e,t)):Z(this.node(),e).delay}function Lu(t,e){return function(){nt(this,t).duration=+e.apply(this,arguments)}}function qu(t,e){return e=+e,function(){nt(this,t).duration=e}}function mi(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Lu:qu)(e,t)):Z(this.node(),e).duration}function Fu(t,e){if(typeof e!="function")throw new Error;return function(){nt(this,t).ease=e}}function di(t){var e=this._id;return arguments.length?this.each(Fu(e,t)):Z(this.node(),e).ease}function Hu(t,e){return function(){var r=e.apply(this,arguments);if(typeof r!="function")throw new Error;nt(this,t).ease=r}}function xi(t){if(typeof t!="function")throw new Error;return this.each(Hu(this._id,t))}function gi(t){typeof t!="function"&&(t=ge(t));for(var e=this._groups,r=e.length,n=new Array(r),o=0;o<r;++o)for(var i=e[o],a=i.length,u=n[o]=[],f,s=0;s<a;++s)(f=i[s])&&t.call(f,f.__data__,s,i)&&u.push(f);return new st(n,this._parents,this._name,this._id)}function yi(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,r=t._groups,n=e.length,o=r.length,i=Math.min(n,o),a=new Array(n),u=0;u<i;++u)for(var f=e[u],s=r[u],l=f.length,h=a[u]=new Array(l),c,p=0;p<l;++p)(c=f[p]||s[p])&&(h[p]=c);for(;u<n;++u)a[u]=e[u];return new st(a,this._parents,this._name,this._id)}function ju(t){return(t+"").trim().split(/^|\s+/).every(function(e){var r=e.indexOf(".");return r>=0&&(e=e.slice(0,r)),!e||e==="start"})}function Xu(t,e,r){var n,o,i=ju(e)?Ce:nt;return function(){var a=i(this,t),u=a.on;u!==n&&(o=(n=u).copy()).on(e,r),a.on=o}}function vi(t,e){var r=this._id;return arguments.length<2?Z(this.node(),r).on.on(t):this.each(Xu(r,t,e))}function Yu(t){return function(){var e=this.parentNode;for(var r in this.__transition)if(+r!==t)return;e&&e.removeChild(this)}}function wi(){return this.on("end.remove",Yu(this._id))}function _i(t){var e=this._name,r=this._id;typeof t!="function"&&(t=Ft(t));for(var n=this._groups,o=n.length,i=new Array(o),a=0;a<o;++a)for(var u=n[a],f=u.length,s=i[a]=new Array(f),l,h,c=0;c<f;++c)(l=u[c])&&(h=t.call(l,l.__data__,c,u))&&("__data__"in l&&(h.__data__=l.__data__),s[c]=h,It(s[c],e,r,c,s,Z(l,r)));return new st(i,this._parents,e,r)}function bi(t){var e=this._name,r=this._id;typeof t!="function"&&(t=xe(t));for(var n=this._groups,o=n.length,i=[],a=[],u=0;u<o;++u)for(var f=n[u],s=f.length,l,h=0;h<s;++h)if(l=f[h]){for(var c=t.call(l,l.__data__,h,f),p,y=Z(l,r),x=0,g=c.length;x<g;++x)(p=c[x])&&It(p,e,r,x,c,y);i.push(c),a.push(l)}return new st(i,a,e,r)}var Vu=At.prototype.constructor;function ki(){return new Vu(this._groups,this._parents)}function Gu(t,e){var r,n,o;return function(){var i=Ct(this,t),a=(this.style.removeProperty(t),Ct(this,t));return i===a?null:i===r&&a===n?o:o=e(r=i,n=a)}}function Mi(t){return function(){this.style.removeProperty(t)}}function Ku(t,e,r){var n,o=r+"",i;return function(){var a=Ct(this,t);return a===o?null:a===n?i:i=e(n=a,r)}}function Qu(t,e,r){var n,o,i;return function(){var a=Ct(this,t),u=r(this),f=u+"";return u==null&&(f=u=(this.style.removeProperty(t),Ct(this,t))),a===f?null:a===n&&f===o?i:(o=f,i=e(n=a,u))}}function Uu(t,e){var r,n,o,i="style."+e,a="end."+i,u;return function(){var f=nt(this,t),s=f.on,l=f.value[i]==null?u||(u=Mi(e)):void 0;(s!==r||o!==l)&&(n=(r=s).copy()).on(a,o=l),f.on=n}}function Ai(t,e,r){var n=(t+="")=="transform"?Wr:cr;return e==null?this.styleTween(t,Gu(t,n)).on("end.style."+t,Mi(t)):typeof e=="function"?this.styleTween(t,Qu(t,n,ne(this,"style."+t,e))).each(Uu(this._id,t)):this.styleTween(t,Ku(t,n,e),r).on("end.style."+t,null)}function Zu(t,e,r){return function(n){this.style.setProperty(t,e.call(this,n),r)}}function Wu(t,e,r){var n,o;function i(){var a=e.apply(this,arguments);return a!==o&&(n=(o=a)&&Zu(t,a,r)),n}return i._value=e,i}function Ei(t,e,r){var n="style."+(t+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,Wu(t,e,r??""))}function Ju(t){return function(){this.textContent=t}}function tf(t){return function(){var e=t(this);this.textContent=e??""}}function Ti(t){return this.tween("text",typeof t=="function"?tf(ne(this,"text",t)):Ju(t==null?"":t+""))}function ef(t){return function(e){this.textContent=t.call(this,e)}}function rf(t){var e,r;function n(){var o=t.apply(this,arguments);return o!==r&&(e=(r=o)&&ef(o)),e}return n._value=t,n}function Si(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,rf(t))}function Ni(){for(var t=this._name,e=this._id,r=pr(),n=this._groups,o=n.length,i=0;i<o;++i)for(var a=n[i],u=a.length,f,s=0;s<u;++s)if(f=a[s]){var l=Z(f,e);It(f,t,r,s,a,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new st(n,this._parents,t,r)}function $i(){var t,e,r=this,n=r._id,o=r.size();return new Promise(function(i,a){var u={value:a},f={value:function(){--o===0&&i()}};r.each(function(){var s=nt(this,n),l=s.on;l!==t&&(e=(t=l).copy(),e._.cancel.push(u),e._.interrupt.push(u),e._.end.push(f)),s.on=e}),o===0&&i()})}var nf=0;function st(t,e,r,n){this._groups=t,this._parents=e,this._name=r,this._id=n}function Ci(t){return At().transition(t)}function pr(){return++nf}var Tt=At.prototype;st.prototype=Ci.prototype={constructor:st,select:_i,selectAll:bi,selectChild:Tt.selectChild,selectChildren:Tt.selectChildren,filter:gi,merge:yi,selection:ki,transition:Ni,call:Tt.call,nodes:Tt.nodes,node:Tt.node,size:Tt.size,empty:Tt.empty,each:Tt.each,on:vi,attr:ci,attrTween:pi,style:Ai,styleTween:Ei,text:Ti,textTween:Si,remove:wi,tween:li,delay:hi,duration:mi,ease:di,easeVarying:xi,end:$i,[Symbol.iterator]:Tt[Symbol.iterator]};function hr(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var of={time:null,delay:0,duration:250,ease:hr};function af(t,e){for(var r;!(r=t.__transition)||!(r=r[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return r}function Ii(t){var e,r;t instanceof st?(e=t._id,t=t._name):(e=pr(),(r=of).time=Ne(),t=t==null?null:t+"");for(var n=this._groups,o=n.length,i=0;i<o;++i)for(var a=n[i],u=a.length,f,s=0;s<u;++s)(f=a[s])&&It(f,t,e,s,a,r||af(f,e));return new st(n,this._parents,t,e)}At.prototype.interrupt=fi;At.prototype.transition=Ii;var{abs:rx,max:nx,min:ox}=Math;function Ri(t){return[+t[0],+t[1]]}function sf(t){return[Ri(t[0]),Ri(t[1])]}var ix={name:"x",handles:["w","e"].map(rn),input:function(t,e){return t==null?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},ax={name:"y",handles:["n","s"].map(rn),input:function(t,e){return t==null?null:[[e[0][0],+t[0]],[e[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},sx={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(rn),input:function(t){return t==null?null:sf(t)},output:function(t){return t}};function rn(t){return{type:t}}var nn=Math.PI,on=2*nn,Gt=1e-6,uf=on-Gt;function Oi(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=arguments[e]+t[e]}function ff(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Oi;let r=10**e;return function(n){this._+=n[0];for(let o=1,i=n.length;o<i;++o)this._+=Math.round(arguments[o]*r)/r+n[o]}}var Kt=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?Oi:ff(e)}moveTo(e,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+r}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,r){this._append`L${this._x1=+e},${this._y1=+r}`}quadraticCurveTo(e,r,n,o){this._append`Q${+e},${+r},${this._x1=+n},${this._y1=+o}`}bezierCurveTo(e,r,n,o,i,a){this._append`C${+e},${+r},${+n},${+o},${this._x1=+i},${this._y1=+a}`}arcTo(e,r,n,o,i){if(e=+e,r=+r,n=+n,o=+o,i=+i,i<0)throw new Error(`negative radius: ${i}`);let a=this._x1,u=this._y1,f=n-e,s=o-r,l=a-e,h=u-r,c=l*l+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=r}`;else if(c>Gt)if(!(Math.abs(h*f-s*l)>Gt)||!i)this._append`L${this._x1=e},${this._y1=r}`;else{let p=n-a,y=o-u,x=f*f+s*s,g=p*p+y*y,d=Math.sqrt(x),_=Math.sqrt(c),A=i*Math.tan((nn-Math.acos((x+c-g)/(2*d*_)))/2),w=A/_,I=A/d;Math.abs(w-1)>Gt&&this._append`L${e+w*l},${r+w*h}`,this._append`A${i},${i},0,0,${+(h*p>l*y)},${this._x1=e+I*f},${this._y1=r+I*s}`}}arc(e,r,n,o,i,a){if(e=+e,r=+r,n=+n,a=!!a,n<0)throw new Error(`negative radius: ${n}`);let u=n*Math.cos(o),f=n*Math.sin(o),s=e+u,l=r+f,h=1^a,c=a?o-i:i-o;this._x1===null?this._append`M${s},${l}`:(Math.abs(this._x1-s)>Gt||Math.abs(this._y1-l)>Gt)&&this._append`L${s},${l}`,n&&(c<0&&(c=c%on+on),c>uf?this._append`A${n},${n},0,1,${h},${e-u},${r-f}A${n},${n},0,1,${h},${this._x1=s},${this._y1=l}`:c>Gt&&this._append`A${n},${n},0,${+(c>=nn)},${h},${this._x1=e+n*Math.cos(i)},${this._y1=r+n*Math.sin(i)}`)}rect(e,r,n,o){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+r}h${n=+n}v${+o}h${-n}Z`}toString(){return this._}};function Pi(){return new Kt}Pi.prototype=Kt.prototype;function an(t,e){var r,n=1;t==null&&(t=0),e==null&&(e=0);function o(){var i,a=r.length,u,f=0,s=0;for(i=0;i<a;++i)u=r[i],f+=u.x,s+=u.y;for(f=(f/a-t)*n,s=(s/a-e)*n,i=0;i<a;++i)u=r[i],u.x-=f,u.y-=s}return o.initialize=function(i){r=i},o.x=function(i){return arguments.length?(t=+i,o):t},o.y=function(i){return arguments.length?(e=+i,o):e},o.strength=function(i){return arguments.length?(n=+i,o):n},o}function zi(t){let e=+this._x.call(null,t),r=+this._y.call(null,t);return Di(this.cover(e,r),e,r,t)}function Di(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i=t._root,a={data:n},u=t._x0,f=t._y0,s=t._x1,l=t._y1,h,c,p,y,x,g,d,_;if(!i)return t._root=a,t;for(;i.length;)if((x=e>=(h=(u+s)/2))?u=h:s=h,(g=r>=(c=(f+l)/2))?f=c:l=c,o=i,!(i=i[d=g<<1|x]))return o[d]=a,t;if(p=+t._x.call(null,i.data),y=+t._y.call(null,i.data),e===p&&r===y)return a.next=i,o?o[d]=a:t._root=a,t;do o=o?o[d]=new Array(4):t._root=new Array(4),(x=e>=(h=(u+s)/2))?u=h:s=h,(g=r>=(c=(f+l)/2))?f=c:l=c;while((d=g<<1|x)===(_=(y>=c)<<1|p>=h));return o[_]=i,o[d]=a,t}function Bi(t){var e,r,n=t.length,o,i,a=new Array(n),u=new Array(n),f=1/0,s=1/0,l=-1/0,h=-1/0;for(r=0;r<n;++r)isNaN(o=+this._x.call(null,e=t[r]))||isNaN(i=+this._y.call(null,e))||(a[r]=o,u[r]=i,o<f&&(f=o),o>l&&(l=o),i<s&&(s=i),i>h&&(h=i));if(f>l||s>h)return this;for(this.cover(f,s).cover(l,h),r=0;r<n;++r)Di(this,a[r],u[r],t[r]);return this}function Li(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var a=o-r||1,u=this._root,f,s;r>t||t>=o||n>e||e>=i;)switch(s=(e<n)<<1|t<r,f=new Array(4),f[s]=u,u=f,a*=2,s){case 0:o=r+a,i=n+a;break;case 1:r=o-a,i=n+a;break;case 2:o=r+a,n=i-a;break;case 3:r=o-a,n=i-a;break}this._root&&this._root.length&&(this._root=u)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this}function qi(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Fi(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function J(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function Hi(t,e,r){var n,o=this._x0,i=this._y0,a,u,f,s,l=this._x1,h=this._y1,c=[],p=this._root,y,x;for(p&&c.push(new J(p,o,i,l,h)),r==null?r=1/0:(o=t-r,i=e-r,l=t+r,h=e+r,r*=r);y=c.pop();)if(!(!(p=y.node)||(a=y.x0)>l||(u=y.y0)>h||(f=y.x1)<o||(s=y.y1)<i))if(p.length){var g=(a+f)/2,d=(u+s)/2;c.push(new J(p[3],g,d,f,s),new J(p[2],a,d,g,s),new J(p[1],g,u,f,d),new J(p[0],a,u,g,d)),(x=(e>=d)<<1|t>=g)&&(y=c[c.length-1],c[c.length-1]=c[c.length-1-x],c[c.length-1-x]=y)}else{var _=t-+this._x.call(null,p.data),A=e-+this._y.call(null,p.data),w=_*_+A*A;if(w<r){var I=Math.sqrt(r=w);o=t-I,i=e-I,l=t+I,h=e+I,n=p.data}}return n}function ji(t){if(isNaN(l=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var e,r=this._root,n,o,i,a=this._x0,u=this._y0,f=this._x1,s=this._y1,l,h,c,p,y,x,g,d;if(!r)return this;if(r.length)for(;;){if((y=l>=(c=(a+f)/2))?a=c:f=c,(x=h>=(p=(u+s)/2))?u=p:s=p,e=r,!(r=r[g=x<<1|y]))return this;if(!r.length)break;(e[g+1&3]||e[g+2&3]||e[g+3&3])&&(n=e,d=g)}for(;r.data!==t;)if(o=r,!(r=r.next))return this;return(i=r.next)&&delete r.next,o?(i?o.next=i:delete o.next,this):e?(i?e[g]=i:delete e[g],(r=e[0]||e[1]||e[2]||e[3])&&r===(e[3]||e[2]||e[1]||e[0])&&!r.length&&(n?n[d]=r:this._root=r),this):(this._root=i,this)}function Xi(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this}function Yi(){return this._root}function Vi(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Gi(t){var e=[],r,n=this._root,o,i,a,u,f;for(n&&e.push(new J(n,this._x0,this._y0,this._x1,this._y1));r=e.pop();)if(!t(n=r.node,i=r.x0,a=r.y0,u=r.x1,f=r.y1)&&n.length){var s=(i+u)/2,l=(a+f)/2;(o=n[3])&&e.push(new J(o,s,l,u,f)),(o=n[2])&&e.push(new J(o,i,l,s,f)),(o=n[1])&&e.push(new J(o,s,a,u,l)),(o=n[0])&&e.push(new J(o,i,a,s,l))}return this}function Ki(t){var e=[],r=[],n;for(this._root&&e.push(new J(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var o=n.node;if(o.length){var i,a=n.x0,u=n.y0,f=n.x1,s=n.y1,l=(a+f)/2,h=(u+s)/2;(i=o[0])&&e.push(new J(i,a,u,l,h)),(i=o[1])&&e.push(new J(i,l,u,f,h)),(i=o[2])&&e.push(new J(i,a,h,l,s)),(i=o[3])&&e.push(new J(i,l,h,f,s))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.y0,n.x1,n.y1);return this}function Qi(t){return t[0]}function Ui(t){return arguments.length?(this._x=t,this):this._x}function Zi(t){return t[1]}function Wi(t){return arguments.length?(this._y=t,this):this._y}function Qt(t,e,r){var n=new sn(e??Qi,r??Zi,NaN,NaN,NaN,NaN);return t==null?n:n.addAll(t)}function sn(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function Ji(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var ut=Qt.prototype=sn.prototype;ut.copy=function(){var t=new sn(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,r,n;if(!e)return t;if(!e.length)return t._root=Ji(e),t;for(r=[{source:e,target:t._root=new Array(4)}];e=r.pop();)for(var o=0;o<4;++o)(n=e.source[o])&&(n.length?r.push({source:n,target:e.target[o]=new Array(4)}):e.target[o]=Ji(n));return t};ut.add=zi;ut.addAll=Bi;ut.cover=Li;ut.data=qi;ut.extent=Fi;ut.find=Hi;ut.remove=ji;ut.removeAll=Xi;ut.root=Yi;ut.size=Vi;ut.visit=Gi;ut.visitAfter=Ki;ut.x=Ui;ut.y=Wi;function wt(t){return function(){return t}}function mt(t){return(t()-.5)*1e-6}function lf(t){return t.x+t.vx}function cf(t){return t.y+t.vy}function un(t){var e,r,n,o=1,i=1;typeof t!="function"&&(t=wt(t==null?1:+t));function a(){for(var s,l=e.length,h,c,p,y,x,g,d=0;d<i;++d)for(h=Qt(e,lf,cf).visitAfter(u),s=0;s<l;++s)c=e[s],x=r[c.index],g=x*x,p=c.x+c.vx,y=c.y+c.vy,h.visit(_);function _(A,w,I,b,z){var L=A.data,C=A.r,B=x+C;if(L){if(L.index>c.index){var S=p-L.x-L.vx,M=y-L.y-L.vy,k=S*S+M*M;k<B*B&&(S===0&&(S=mt(n),k+=S*S),M===0&&(M=mt(n),k+=M*M),k=(B-(k=Math.sqrt(k)))/k*o,c.vx+=(S*=k)*(B=(C*=C)/(g+C)),c.vy+=(M*=k)*B,L.vx-=S*(B=1-B),L.vy-=M*B)}return}return w>p+B||b<p-B||I>y+B||z<y-B}}function u(s){if(s.data)return s.r=r[s.data.index];for(var l=s.r=0;l<4;++l)s[l]&&s[l].r>s.r&&(s.r=s[l].r)}function f(){if(e){var s,l=e.length,h;for(r=new Array(l),s=0;s<l;++s)h=e[s],r[h.index]=+t(h,s,e)}}return a.initialize=function(s,l){e=s,n=l,f()},a.iterations=function(s){return arguments.length?(i=+s,a):i},a.strength=function(s){return arguments.length?(o=+s,a):o},a.radius=function(s){return arguments.length?(t=typeof s=="function"?s:wt(+s),f(),a):t},a}function pf(t){return t.index}function ta(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function fn(t){var e=pf,r=h,n,o=wt(30),i,a,u,f,s,l=1;t==null&&(t=[]);function h(g){return 1/Math.min(u[g.source.index],u[g.target.index])}function c(g){for(var d=0,_=t.length;d<l;++d)for(var A=0,w,I,b,z,L,C,B;A<_;++A)w=t[A],I=w.source,b=w.target,z=b.x+b.vx-I.x-I.vx||mt(s),L=b.y+b.vy-I.y-I.vy||mt(s),C=Math.sqrt(z*z+L*L),C=(C-i[A])/C*g*n[A],z*=C,L*=C,b.vx-=z*(B=f[A]),b.vy-=L*B,I.vx+=z*(B=1-B),I.vy+=L*B}function p(){if(a){var g,d=a.length,_=t.length,A=new Map(a.map((I,b)=>[e(I,b,a),I])),w;for(g=0,u=new Array(d);g<_;++g)w=t[g],w.index=g,typeof w.source!="object"&&(w.source=ta(A,w.source)),typeof w.target!="object"&&(w.target=ta(A,w.target)),u[w.source.index]=(u[w.source.index]||0)+1,u[w.target.index]=(u[w.target.index]||0)+1;for(g=0,f=new Array(_);g<_;++g)w=t[g],f[g]=u[w.source.index]/(u[w.source.index]+u[w.target.index]);n=new Array(_),y(),i=new Array(_),x()}}function y(){if(a)for(var g=0,d=t.length;g<d;++g)n[g]=+r(t[g],g,t)}function x(){if(a)for(var g=0,d=t.length;g<d;++g)i[g]=+o(t[g],g,t)}return c.initialize=function(g,d){a=g,s=d,p()},c.links=function(g){return arguments.length?(t=g,p(),c):t},c.id=function(g){return arguments.length?(e=g,c):e},c.iterations=function(g){return arguments.length?(l=+g,c):l},c.strength=function(g){return arguments.length?(r=typeof g=="function"?g:wt(+g),y(),c):r},c.distance=function(g){return arguments.length?(o=typeof g=="function"?g:wt(+g),x(),c):o},c}function ea(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function ra(t){return t.x}function na(t){return t.y}var hf=10,mf=Math.PI*(3-Math.sqrt(5));function ln(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,u=new Map,f=re(h),s=qt("tick","end"),l=ea();t==null&&(t=[]);function h(){c(),s.call("tick",e),r<n&&(f.stop(),s.call("end",e))}function c(x){var g,d=t.length,_;x===void 0&&(x=1);for(var A=0;A<x;++A)for(r+=(i-r)*o,u.forEach(function(w){w(r)}),g=0;g<d;++g)_=t[g],_.fx==null?_.x+=_.vx*=a:(_.x=_.fx,_.vx=0),_.fy==null?_.y+=_.vy*=a:(_.y=_.fy,_.vy=0);return e}function p(){for(var x=0,g=t.length,d;x<g;++x){if(d=t[x],d.index=x,d.fx!=null&&(d.x=d.fx),d.fy!=null&&(d.y=d.fy),isNaN(d.x)||isNaN(d.y)){var _=hf*Math.sqrt(.5+x),A=x*mf;d.x=_*Math.cos(A),d.y=_*Math.sin(A)}(isNaN(d.vx)||isNaN(d.vy))&&(d.vx=d.vy=0)}}function y(x){return x.initialize&&x.initialize(t,l),x}return p(),e={tick:c,restart:function(){return f.restart(h),e},stop:function(){return f.stop(),e},nodes:function(x){return arguments.length?(t=x,p(),u.forEach(y),e):t},alpha:function(x){return arguments.length?(r=+x,e):r},alphaMin:function(x){return arguments.length?(n=+x,e):n},alphaDecay:function(x){return arguments.length?(o=+x,e):+o},alphaTarget:function(x){return arguments.length?(i=+x,e):i},velocityDecay:function(x){return arguments.length?(a=1-x,e):1-a},randomSource:function(x){return arguments.length?(l=x,u.forEach(y),e):l},force:function(x,g){return arguments.length>1?(g==null?u.delete(x):u.set(x,y(g)),e):u.get(x)},find:function(x,g,d){var _=0,A=t.length,w,I,b,z,L;for(d==null?d=1/0:d*=d,_=0;_<A;++_)z=t[_],w=x-z.x,I=g-z.y,b=w*w+I*I,b<d&&(L=z,d=b);return L},on:function(x,g){return arguments.length>1?(s.on(x,g),e):s.on(x)}}}function cn(){var t,e,r,n,o=wt(-30),i,a=1,u=1/0,f=.81;function s(p){var y,x=t.length,g=Qt(t,ra,na).visitAfter(h);for(n=p,y=0;y<x;++y)e=t[y],g.visit(c)}function l(){if(t){var p,y=t.length,x;for(i=new Array(y),p=0;p<y;++p)x=t[p],i[x.index]=+o(x,p,t)}}function h(p){var y=0,x,g,d=0,_,A,w;if(p.length){for(_=A=w=0;w<4;++w)(x=p[w])&&(g=Math.abs(x.value))&&(y+=x.value,d+=g,_+=g*x.x,A+=g*x.y);p.x=_/d,p.y=A/d}else{x=p,x.x=x.data.x,x.y=x.data.y;do y+=i[x.data.index];while(x=x.next)}p.value=y}function c(p,y,x,g){if(!p.value)return!0;var d=p.x-e.x,_=p.y-e.y,A=g-y,w=d*d+_*_;if(A*A/f<w)return w<u&&(d===0&&(d=mt(r),w+=d*d),_===0&&(_=mt(r),w+=_*_),w<a&&(w=Math.sqrt(a*w)),e.vx+=d*p.value*n/w,e.vy+=_*p.value*n/w),!0;if(p.length||w>=u)return;(p.data!==e||p.next)&&(d===0&&(d=mt(r),w+=d*d),_===0&&(_=mt(r),w+=_*_),w<a&&(w=Math.sqrt(a*w)));do p.data!==e&&(A=i[p.data.index]*n/w,e.vx+=d*A,e.vy+=_*A);while(p=p.next)}return s.initialize=function(p,y){t=p,r=y,l()},s.strength=function(p){return arguments.length?(o=typeof p=="function"?p:wt(+p),l(),s):o},s.distanceMin=function(p){return arguments.length?(a=p*p,s):Math.sqrt(a)},s.distanceMax=function(p){return arguments.length?(u=p*p,s):Math.sqrt(u)},s.theta=function(p){return arguments.length?(f=p*p,s):Math.sqrt(f)},s}function oa(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Ut(t,e){if(!isFinite(t)||t===0)return null;var r=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function _t(t){return t=Ut(Math.abs(t)),t?t[1]:NaN}function ia(t,e){return function(r,n){for(var o=r.length,i=[],a=0,u=t[0],f=0;o>0&&u>0&&(f+u+1>n&&(u=Math.max(1,n-f)),i.push(r.substring(o-=u,o+u)),!((f+=u+1)>n));)u=t[a=(a+1)%t.length];return i.reverse().join(e)}}function aa(t){return function(e){return e.replace(/[0-9]/g,function(r){return t[+r]})}}var df=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Ot(t){if(!(e=df.exec(t)))throw new Error("invalid format: "+t);var e;return new mr({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]})}Ot.prototype=mr.prototype;function mr(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}mr.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function sa(t){t:for(var e=t.length,r=1,n=-1,o;r<e;++r)switch(t[r]){case".":n=o=r;break;case"0":n===0&&(n=r),o=r;break;default:if(!+t[r])break t;n>0&&(n=0);break}return n>0?t.slice(0,n)+t.slice(o+1):t}var Ie;function ua(t,e){var r=Ut(t,e);if(!r)return Ie=void 0,t.toPrecision(e);var n=r[0],o=r[1],i=o-(Ie=Math.max(-8,Math.min(8,Math.floor(o/3)))*3)+1,a=n.length;return i===a?n:i>a?n+new Array(i-a+1).join("0"):i>0?n.slice(0,i)+"."+n.slice(i):"0."+new Array(1-i).join("0")+Ut(t,Math.max(0,e+i-1))[0]}function pn(t,e){var r=Ut(t,e);if(!r)return t+"";var n=r[0],o=r[1];return o<0?"0."+new Array(-o).join("0")+n:n.length>o+1?n.slice(0,o+1)+"."+n.slice(o+1):n+new Array(o-n.length+2).join("0")}var hn={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:oa,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)=>pn(t*100,e),r:pn,s:ua,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function mn(t){return t}var fa=Array.prototype.map,la=["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"];function ca(t){var e=t.grouping===void 0||t.thousands===void 0?mn:ia(fa.call(t.grouping,Number),t.thousands+""),r=t.currency===void 0?"":t.currency[0]+"",n=t.currency===void 0?"":t.currency[1]+"",o=t.decimal===void 0?".":t.decimal+"",i=t.numerals===void 0?mn:aa(fa.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",u=t.minus===void 0?"\u2212":t.minus+"",f=t.nan===void 0?"NaN":t.nan+"";function s(h,c){h=Ot(h);var p=h.fill,y=h.align,x=h.sign,g=h.symbol,d=h.zero,_=h.width,A=h.comma,w=h.precision,I=h.trim,b=h.type;b==="n"?(A=!0,b="g"):hn[b]||(w===void 0&&(w=12),I=!0,b="g"),(d||p==="0"&&y==="=")&&(d=!0,p="0",y="=");var z=(c&&c.prefix!==void 0?c.prefix:"")+(g==="$"?r:g==="#"&&/[boxX]/.test(b)?"0"+b.toLowerCase():""),L=(g==="$"?n:/[%p]/.test(b)?a:"")+(c&&c.suffix!==void 0?c.suffix:""),C=hn[b],B=/[defgprs%]/.test(b);w=w===void 0?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function S(M){var k=z,m=L,E,v,T;if(b==="c")m=C(M)+m,M="";else{M=+M;var O=M<0||1/M<0;if(M=isNaN(M)?f:C(Math.abs(M),w),I&&(M=sa(M)),O&&+M==0&&x!=="+"&&(O=!1),k=(O?x==="("?x:u:x==="-"||x==="("?"":x)+k,m=(b==="s"&&!isNaN(M)&&Ie!==void 0?la[8+Ie/3]:"")+m+(O&&x==="("?")":""),B){for(E=-1,v=M.length;++E<v;)if(T=M.charCodeAt(E),48>T||T>57){m=(T===46?o+M.slice(E+1):M.slice(E))+m,M=M.slice(0,E);break}}}A&&!d&&(M=e(M,1/0));var P=k.length+M.length+m.length,$=P<_?new Array(_-P+1).join(p):"";switch(A&&d&&(M=e($+M,$.length?_-m.length:1/0),$=""),y){case"<":M=k+M+m+$;break;case"=":M=k+$+M+m;break;case"^":M=$.slice(0,P=$.length>>1)+k+M+m+$.slice(P);break;default:M=$+k+M+m;break}return i(M)}return S.toString=function(){return h+""},S}function l(h,c){var p=Math.max(-8,Math.min(8,Math.floor(_t(c)/3)))*3,y=Math.pow(10,-p),x=s((h=Ot(h),h.type="f",h),{suffix:la[8+p/3]});return function(g){return x(y*g)}}return{format:s,formatPrefix:l}}var dr,xr,gr;dn({thousands:",",grouping:[3],currency:["$",""]});function dn(t){return dr=ca(t),xr=dr.format,gr=dr.formatPrefix,dr}function xn(t){return Math.max(0,-_t(Math.abs(t)))}function gn(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(_t(e)/3)))*3-_t(Math.abs(t)))}function yn(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,_t(e)-_t(t))+1}function Pt(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}var pa=Symbol("implicit");function yr(){var t=new $t,e=[],r=[],n=pa;function o(i){let a=t.get(i);if(a===void 0){if(n!==pa)return n;t.set(i,a=e.push(i)-1)}return r[a%r.length]}return o.domain=function(i){if(!arguments.length)return e.slice();e=[],t=new $t;for(let a of i)t.has(a)||t.set(a,e.push(a)-1);return o},o.range=function(i){return arguments.length?(r=Array.from(i),o):r.slice()},o.unknown=function(i){return arguments.length?(n=i,o):n},o.copy=function(){return yr(e,r).unknown(n)},Pt.apply(o,arguments),o}function oe(){var t=yr().unknown(void 0),e=t.domain,r=t.range,n=0,o=1,i,a,u=!1,f=0,s=0,l=.5;delete t.unknown;function h(){var c=e().length,p=o<n,y=p?o:n,x=p?n:o;i=(x-y)/Math.max(1,c-f+s*2),u&&(i=Math.floor(i)),y+=(x-y-i*(c-f))*l,a=i*(1-f),u&&(y=Math.round(y),a=Math.round(a));var g=Wt(c).map(function(d){return y+i*d});return r(p?g.reverse():g)}return t.domain=function(c){return arguments.length?(e(c),h()):e()},t.range=function(c){return arguments.length?([n,o]=c,n=+n,o=+o,h()):[n,o]},t.rangeRound=function(c){return[n,o]=c,n=+n,o=+o,u=!0,h()},t.bandwidth=function(){return a},t.step=function(){return i},t.round=function(c){return arguments.length?(u=!!c,h()):u},t.padding=function(c){return arguments.length?(f=Math.min(1,s=+c),h()):f},t.paddingInner=function(c){return arguments.length?(f=Math.min(1,c),h()):f},t.paddingOuter=function(c){return arguments.length?(s=+c,h()):s},t.align=function(c){return arguments.length?(l=Math.max(0,Math.min(1,c)),h()):l},t.copy=function(){return oe(e(),[n,o]).round(u).paddingInner(f).paddingOuter(s).align(l)},Pt.apply(h(),arguments)}function ha(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return ha(e())},t}function Re(){return ha(oe.apply(null,arguments).paddingInner(1))}function vn(t){return function(){return t}}function wn(t){return+t}var ma=[0,1];function dt(t){return t}function _n(t,e){return(e-=t=+t)?function(r){return(r-t)/e}:vn(isNaN(e)?NaN:.5)}function xf(t,e){var r;return t>e&&(r=t,t=e,e=r),function(n){return Math.max(t,Math.min(e,n))}}function gf(t,e,r){var n=t[0],o=t[1],i=e[0],a=e[1];return o<n?(n=_n(o,n),i=r(a,i)):(n=_n(n,o),i=r(i,a)),function(u){return i(n(u))}}function yf(t,e,r){var n=Math.min(t.length,e.length)-1,o=new Array(n),i=new Array(n),a=-1;for(t[n]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++a<n;)o[a]=_n(t[a],t[a+1]),i[a]=r(e[a],e[a+1]);return function(u){var f=Or(t,u,1,n)-1;return i[f](o[f](u))}}function vr(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function bn(){var t=ma,e=ma,r=Yt,n,o,i,a=dt,u,f,s;function l(){var c=Math.min(t.length,e.length);return a!==dt&&(a=xf(t[0],t[c-1])),u=c>2?yf:gf,f=s=null,h}function h(c){return c==null||isNaN(c=+c)?i:(f||(f=u(t.map(n),e,r)))(n(a(c)))}return h.invert=function(c){return a(o((s||(s=u(e,t.map(n),rt)))(c)))},h.domain=function(c){return arguments.length?(t=Array.from(c,wn),l()):t.slice()},h.range=function(c){return arguments.length?(e=Array.from(c),l()):e.slice()},h.rangeRound=function(c){return e=Array.from(c),r=Ur,l()},h.clamp=function(c){return arguments.length?(a=c?!0:dt,l()):a!==dt},h.interpolate=function(c){return arguments.length?(r=c,l()):r},h.unknown=function(c){return arguments.length?(i=c,h):i},function(c,p){return n=c,o=p,l()}}function kn(){return bn()(dt,dt)}function Mn(t,e,r,n){var o=Pr(t,e,r),i;switch(n=Ot(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return n.precision==null&&!isNaN(i=gn(o,a))&&(n.precision=i),gr(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(i=yn(o,Math.max(Math.abs(t),Math.abs(e))))&&(n.precision=i-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(i=xn(o))&&(n.precision=i-(n.type==="%")*2);break}}return xr(n)}function An(t){var e=t.domain;return t.ticks=function(r){var n=e();return qe(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var o=e();return Mn(o[0],o[o.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=e(),o=0,i=n.length-1,a=n[o],u=n[i],f,s,l=10;for(u<a&&(s=a,a=u,u=s,s=o,o=i,i=s);l-- >0;){if(s=he(a,u,r),s===f)return n[o]=a,n[i]=u,e(n);if(s>0)a=Math.floor(a/s)*s,u=Math.ceil(u/s)*s;else if(s<0)a=Math.ceil(a*s)/s,u=Math.floor(u*s)/s;else break;f=s}return t},t}function Oe(){var t=kn();return t.copy=function(){return vr(t,Oe())},Pt.apply(t,arguments),An(t)}function da(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function vf(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function wf(t){return t<0?-t*t:t*t}function _f(t){var e=t(dt,dt),r=1;function n(){return r===1?t(dt,dt):r===.5?t(vf,wf):t(da(r),da(1/r))}return e.exponent=function(o){return arguments.length?(r=+o,n()):r},An(e)}function wr(){var t=_f(bn());return t.copy=function(){return vr(t,wr()).exponent(t.exponent())},Pt.apply(t,arguments),t}function En(){return wr.apply(null,arguments).exponent(.5)}function ot(t){return function(){return t}}var Tn=Math.abs,it=Math.atan2,zt=Math.cos,xa=Math.max,_r=Math.min,xt=Math.sin,Zt=Math.sqrt,ft=1e-12,ie=Math.PI,Pe=ie/2,ae=2*ie;function ga(t){return t>1?0:t<-1?ie:Math.acos(t)}function Sn(t){return t>=1?Pe:t<=-1?-Pe:Math.asin(t)}function ya(t){let e=3;return t.digits=function(r){if(!arguments.length)return e;if(r==null)e=null;else{let n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);e=n}return t},()=>new Kt(e)}function bf(t){return t.innerRadius}function kf(t){return t.outerRadius}function Mf(t){return t.startAngle}function Af(t){return t.endAngle}function Ef(t){return t&&t.padAngle}function Tf(t,e,r,n,o,i,a,u){var f=r-t,s=n-e,l=a-o,h=u-i,c=h*f-l*s;if(!(c*c<ft))return c=(l*(e-i)-h*(t-o))/c,[t+c*f,e+c*s]}function br(t,e,r,n,o,i,a){var u=t-r,f=e-n,s=(a?i:-i)/Zt(u*u+f*f),l=s*f,h=-s*u,c=t+l,p=e+h,y=r+l,x=n+h,g=(c+y)/2,d=(p+x)/2,_=y-c,A=x-p,w=_*_+A*A,I=o-i,b=c*x-y*p,z=(A<0?-1:1)*Zt(xa(0,I*I*w-b*b)),L=(b*A-_*z)/w,C=(-b*_-A*z)/w,B=(b*A+_*z)/w,S=(-b*_+A*z)/w,M=L-g,k=C-d,m=B-g,E=S-d;return M*M+k*k>m*m+E*E&&(L=B,C=S),{cx:L,cy:C,x01:-l,y01:-h,x11:L*(o/I-1),y11:C*(o/I-1)}}function Nn(){var t=bf,e=kf,r=ot(0),n=null,o=Mf,i=Af,a=Ef,u=null,f=ya(s);function s(){var l,h,c=+t.apply(this,arguments),p=+e.apply(this,arguments),y=o.apply(this,arguments)-Pe,x=i.apply(this,arguments)-Pe,g=Tn(x-y),d=x>y;if(u||(u=l=f()),p<c&&(h=p,p=c,c=h),!(p>ft))u.moveTo(0,0);else if(g>ae-ft)u.moveTo(p*zt(y),p*xt(y)),u.arc(0,0,p,y,x,!d),c>ft&&(u.moveTo(c*zt(x),c*xt(x)),u.arc(0,0,c,x,y,d));else{var _=y,A=x,w=y,I=x,b=g,z=g,L=a.apply(this,arguments)/2,C=L>ft&&(n?+n.apply(this,arguments):Zt(c*c+p*p)),B=_r(Tn(p-c)/2,+r.apply(this,arguments)),S=B,M=B,k,m;if(C>ft){var E=Sn(C/c*xt(L)),v=Sn(C/p*xt(L));(b-=E*2)>ft?(E*=d?1:-1,w+=E,I-=E):(b=0,w=I=(y+x)/2),(z-=v*2)>ft?(v*=d?1:-1,_+=v,A-=v):(z=0,_=A=(y+x)/2)}var T=p*zt(_),O=p*xt(_),P=c*zt(I),$=c*xt(I);if(B>ft){var D=p*zt(A),j=p*xt(A),Q=c*zt(w),X=c*xt(w),V;if(g<ie)if(V=Tf(T,O,Q,X,D,j,P,$)){var U=T-V[0],G=O-V[1],et=D-V[0],W=j-V[1],R=1/xt(ga((U*et+G*W)/(Zt(U*U+G*G)*Zt(et*et+W*W)))/2),Y=Zt(V[0]*V[0]+V[1]*V[1]);S=_r(B,(c-Y)/(R-1)),M=_r(B,(p-Y)/(R+1))}else S=M=0}z>ft?M>ft?(k=br(Q,X,T,O,p,M,d),m=br(D,j,P,$,p,M,d),u.moveTo(k.cx+k.x01,k.cy+k.y01),M<B?u.arc(k.cx,k.cy,M,it(k.y01,k.x01),it(m.y01,m.x01),!d):(u.arc(k.cx,k.cy,M,it(k.y01,k.x01),it(k.y11,k.x11),!d),u.arc(0,0,p,it(k.cy+k.y11,k.cx+k.x11),it(m.cy+m.y11,m.cx+m.x11),!d),u.arc(m.cx,m.cy,M,it(m.y11,m.x11),it(m.y01,m.x01),!d))):(u.moveTo(T,O),u.arc(0,0,p,_,A,!d)):u.moveTo(T,O),!(c>ft)||!(b>ft)?u.lineTo(P,$):S>ft?(k=br(P,$,D,j,c,-S,d),m=br(T,O,Q,X,c,-S,d),u.lineTo(k.cx+k.x01,k.cy+k.y01),S<B?u.arc(k.cx,k.cy,S,it(k.y01,k.x01),it(m.y01,m.x01),!d):(u.arc(k.cx,k.cy,S,it(k.y01,k.x01),it(k.y11,k.x11),!d),u.arc(0,0,c,it(k.cy+k.y11,k.cx+k.x11),it(m.cy+m.y11,m.cx+m.x11),d),u.arc(m.cx,m.cy,S,it(m.y11,m.x11),it(m.y01,m.x01),!d))):u.arc(0,0,c,I,w,d)}if(u.closePath(),l)return u=null,l+""||null}return s.centroid=function(){var l=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,h=(+o.apply(this,arguments)+ +i.apply(this,arguments))/2-ie/2;return[zt(h)*l,xt(h)*l]},s.innerRadius=function(l){return arguments.length?(t=typeof l=="function"?l:ot(+l),s):t},s.outerRadius=function(l){return arguments.length?(e=typeof l=="function"?l:ot(+l),s):e},s.cornerRadius=function(l){return arguments.length?(r=typeof l=="function"?l:ot(+l),s):r},s.padRadius=function(l){return arguments.length?(n=l==null?null:typeof l=="function"?l:ot(+l),s):n},s.startAngle=function(l){return arguments.length?(o=typeof l=="function"?l:ot(+l),s):o},s.endAngle=function(l){return arguments.length?(i=typeof l=="function"?l:ot(+l),s):i},s.padAngle=function(l){return arguments.length?(a=typeof l=="function"?l:ot(+l),s):a},s.context=function(l){return arguments.length?(u=l??null,s):u},s}var Vg=Array.prototype.slice;function va(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function wa(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function _a(t){return t}function $n(){var t=_a,e=wa,r=null,n=ot(0),o=ot(ae),i=ot(0);function a(u){var f,s=(u=va(u)).length,l,h,c=0,p=new Array(s),y=new Array(s),x=+n.apply(this,arguments),g=Math.min(ae,Math.max(-ae,o.apply(this,arguments)-x)),d,_=Math.min(Math.abs(g)/s,i.apply(this,arguments)),A=_*(g<0?-1:1),w;for(f=0;f<s;++f)(w=y[p[f]=f]=+t(u[f],f,u))>0&&(c+=w);for(e!=null?p.sort(function(I,b){return e(y[I],y[b])}):r!=null&&p.sort(function(I,b){return r(u[I],u[b])}),f=0,h=c?(g-s*A)/c:0;f<s;++f,x=d)l=p[f],w=y[l],d=x+(w>0?w*h:0)+A,y[l]={data:u[l],index:f,value:w,startAngle:x,endAngle:d,padAngle:_};return y}return a.value=function(u){return arguments.length?(t=typeof u=="function"?u:ot(+u),a):t},a.sortValues=function(u){return arguments.length?(e=u,r=null,a):e},a.sort=function(u){return arguments.length?(r=u,e=null,a):r},a.startAngle=function(u){return arguments.length?(n=typeof u=="function"?u:ot(+u),a):n},a.endAngle=function(u){return arguments.length?(o=typeof u=="function"?u:ot(+u),a):o},a.padAngle=function(u){return arguments.length?(i=typeof u=="function"?u:ot(+u),a):i},a}var ze=t=>()=>t;function Cn(t,{sourceEvent:e,target:r,transform:n,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:o}})}function gt(t,e,r){this.k=t,this.x=e,this.y=r}gt.prototype={constructor:gt,scale:function(t){return t===1?this:new gt(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new gt(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 St=new gt(1,0,0);Dt.prototype=gt.prototype;function Dt(t){for(;!t.__zoom;)if(!(t=t.parentNode))return St;return t.__zoom}function kr(t){t.stopImmediatePropagation()}function se(t){t.preventDefault(),t.stopImmediatePropagation()}function Sf(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Nf(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.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 ba(){return this.__zoom||St}function $f(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Cf(){return navigator.maxTouchPoints||"ontouchstart"in this}function If(t,e,r){var n=t.invertX(e[0][0])-r[0][0],o=t.invertX(e[1][0])-r[1][0],i=t.invertY(e[0][1])-r[0][1],a=t.invertY(e[1][1])-r[1][1];return t.translate(o>n?(n+o)/2:Math.min(0,n)||Math.max(0,o),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function In(){var t=Sf,e=Nf,r=If,n=$f,o=Cf,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],u=250,f=tn,s=qt("start","zoom","end"),l,h,c,p=500,y=150,x=0,g=10;function d(m){m.property("__zoom",ba).on("wheel.zoom",L,{passive:!1}).on("mousedown.zoom",C).on("dblclick.zoom",B).filter(o).on("touchstart.zoom",S).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",k).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}d.transform=function(m,E,v,T){var O=m.selection?m.selection():m;O.property("__zoom",ba),m!==O?I(m,E,v,T):O.interrupt().each(function(){b(this,arguments).event(T).start().zoom(null,typeof E=="function"?E.apply(this,arguments):E).end()})},d.scaleBy=function(m,E,v,T){d.scaleTo(m,function(){var O=this.__zoom.k,P=typeof E=="function"?E.apply(this,arguments):E;return O*P},v,T)},d.scaleTo=function(m,E,v,T){d.transform(m,function(){var O=e.apply(this,arguments),P=this.__zoom,$=v==null?w(O):typeof v=="function"?v.apply(this,arguments):v,D=P.invert($),j=typeof E=="function"?E.apply(this,arguments):E;return r(A(_(P,j),$,D),O,a)},v,T)},d.translateBy=function(m,E,v,T){d.transform(m,function(){return r(this.__zoom.translate(typeof E=="function"?E.apply(this,arguments):E,typeof v=="function"?v.apply(this,arguments):v),e.apply(this,arguments),a)},null,T)},d.translateTo=function(m,E,v,T,O){d.transform(m,function(){var P=e.apply(this,arguments),$=this.__zoom,D=T==null?w(P):typeof T=="function"?T.apply(this,arguments):T;return r(St.translate(D[0],D[1]).scale($.k).translate(typeof E=="function"?-E.apply(this,arguments):-E,typeof v=="function"?-v.apply(this,arguments):-v),P,a)},T,O)};function _(m,E){return E=Math.max(i[0],Math.min(i[1],E)),E===m.k?m:new gt(E,m.x,m.y)}function A(m,E,v){var T=E[0]-v[0]*m.k,O=E[1]-v[1]*m.k;return T===m.x&&O===m.y?m:new gt(m.k,T,O)}function w(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function I(m,E,v,T){m.on("start.zoom",function(){b(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event(T).end()}).tween("zoom",function(){var O=this,P=arguments,$=b(O,P).event(T),D=e.apply(O,P),j=v==null?w(D):typeof v=="function"?v.apply(O,P):v,Q=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),X=O.__zoom,V=typeof E=="function"?E.apply(O,P):E,U=f(X.invert(j).concat(Q/X.k),V.invert(j).concat(Q/V.k));return function(G){if(G===1)G=V;else{var et=U(G),W=Q/et[2];G=new gt(W,j[0]-et[0]*W,j[1]-et[1]*W)}$.zoom(null,G)}})}function b(m,E,v){return!v&&m.__zooming||new z(m,E)}function z(m,E){this.that=m,this.args=E,this.active=0,this.sourceEvent=null,this.extent=e.apply(m,E),this.taps=0}z.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,E){return this.mouse&&m!=="mouse"&&(this.mouse[1]=E.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=E.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=E.invert(this.touch1[0])),this.that.__zoom=E,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var E=at(this.that).datum();s.call(m,this.that,new Cn(m,{sourceEvent:this.sourceEvent,target:d,type:m,transform:this.that.__zoom,dispatch:s}),E)}};function L(m,...E){if(!t.apply(this,arguments))return;var v=b(this,E).event(m),T=this.__zoom,O=Math.max(i[0],Math.min(i[1],T.k*Math.pow(2,n.apply(this,arguments)))),P=Et(m);if(v.wheel)(v.mouse[0][0]!==P[0]||v.mouse[0][1]!==P[1])&&(v.mouse[1]=T.invert(v.mouse[0]=P)),clearTimeout(v.wheel);else{if(T.k===O)return;v.mouse=[P,T.invert(P)],Rt(this),v.start()}se(m),v.wheel=setTimeout($,y),v.zoom("mouse",r(A(_(T,O),v.mouse[0],v.mouse[1]),v.extent,a));function $(){v.wheel=null,v.end()}}function C(m,...E){if(c||!t.apply(this,arguments))return;var v=m.currentTarget,T=b(this,E,!0).event(m),O=at(m.view).on("mousemove.zoom",j,!0).on("mouseup.zoom",Q,!0),P=Et(m,v),$=m.clientX,D=m.clientY;jr(m.view),kr(m),T.mouse=[P,this.__zoom.invert(P)],Rt(this),T.start();function j(X){if(se(X),!T.moved){var V=X.clientX-$,U=X.clientY-D;T.moved=V*V+U*U>x}T.event(X).zoom("mouse",r(A(T.that.__zoom,T.mouse[0]=Et(X,v),T.mouse[1]),T.extent,a))}function Q(X){O.on("mousemove.zoom mouseup.zoom",null),Xr(X.view,T.moved),se(X),T.event(X).end()}}function B(m,...E){if(t.apply(this,arguments)){var v=this.__zoom,T=Et(m.changedTouches?m.changedTouches[0]:m,this),O=v.invert(T),P=v.k*(m.shiftKey?.5:2),$=r(A(_(v,P),T,O),e.apply(this,E),a);se(m),u>0?at(this).transition().duration(u).call(I,$,T,m):at(this).call(d.transform,$,T,m)}}function S(m,...E){if(t.apply(this,arguments)){var v=m.touches,T=v.length,O=b(this,E,m.changedTouches.length===T).event(m),P,$,D,j;for(kr(m),$=0;$<T;++$)D=v[$],j=Et(D,this),j=[j,this.__zoom.invert(j),D.identifier],O.touch0?!O.touch1&&O.touch0[2]!==j[2]&&(O.touch1=j,O.taps=0):(O.touch0=j,P=!0,O.taps=1+!!l);l&&(l=clearTimeout(l)),P&&(O.taps<2&&(h=j[0],l=setTimeout(function(){l=null},p)),Rt(this),O.start())}}function M(m,...E){if(this.__zooming){var v=b(this,E).event(m),T=m.changedTouches,O=T.length,P,$,D,j;for(se(m),P=0;P<O;++P)$=T[P],D=Et($,this),v.touch0&&v.touch0[2]===$.identifier?v.touch0[0]=D:v.touch1&&v.touch1[2]===$.identifier&&(v.touch1[0]=D);if($=v.that.__zoom,v.touch1){var Q=v.touch0[0],X=v.touch0[1],V=v.touch1[0],U=v.touch1[1],G=(G=V[0]-Q[0])*G+(G=V[1]-Q[1])*G,et=(et=U[0]-X[0])*et+(et=U[1]-X[1])*et;$=_($,Math.sqrt(G/et)),D=[(Q[0]+V[0])/2,(Q[1]+V[1])/2],j=[(X[0]+U[0])/2,(X[1]+U[1])/2]}else if(v.touch0)D=v.touch0[0],j=v.touch0[1];else return;v.zoom("touch",r(A($,D,j),v.extent,a))}}function k(m,...E){if(this.__zooming){var v=b(this,E).event(m),T=m.changedTouches,O=T.length,P,$;for(kr(m),c&&clearTimeout(c),c=setTimeout(function(){c=null},p),P=0;P<O;++P)$=T[P],v.touch0&&v.touch0[2]===$.identifier?delete v.touch0:v.touch1&&v.touch1[2]===$.identifier&&delete v.touch1;if(v.touch1&&!v.touch0&&(v.touch0=v.touch1,delete v.touch1),v.touch0)v.touch0[1]=this.__zoom.invert(v.touch0[0]);else if(v.end(),v.taps===2&&($=Et($,this),Math.hypot(h[0]-$[0],h[1]-$[1])<g)){var D=at(this).on("dblclick.zoom");D&&D.apply(this,arguments)}}}return d.wheelDelta=function(m){return arguments.length?(n=typeof m=="function"?m:ze(+m),d):n},d.filter=function(m){return arguments.length?(t=typeof m=="function"?m:ze(!!m),d):t},d.touchable=function(m){return arguments.length?(o=typeof m=="function"?m:ze(!!m),d):o},d.extent=function(m){return arguments.length?(e=typeof m=="function"?m:ze([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),d):e},d.scaleExtent=function(m){return arguments.length?(i[0]=+m[0],i[1]=+m[1],d):[i[0],i[1]]},d.translateExtent=function(m){return arguments.length?(a[0][0]=+m[0][0],a[1][0]=+m[1][0],a[0][1]=+m[0][1],a[1][1]=+m[1][1],d):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},d.constrain=function(m){return arguments.length?(r=m,d):r},d.duration=function(m){return arguments.length?(u=+m,d):u},d.interpolate=function(m){return arguments.length?(f=m,d):f},d.on=function(){var m=s.on.apply(s,arguments);return m===s?d:m},d.clickDistance=function(m){return arguments.length?(x=(m=+m)*m,d):Math.sqrt(x)},d.tapDistance=function(m){return arguments.length?(g=+m,d):g},d}var Mr={IdType:"#BBBBBB",Gene:"#332288",Organism:"#117733",Assembly:"#999933",OrthologGroup:"#882255",Transcript:"#44AA99",Protein:"#88CCEE",Domain:"#CC6677",GOTerm:"#AA4499",Pathway:"#DDCC77",Dataset:"#011959",Condition:"#FCA993",Publication:"#4D734D"},Ar="#999",ue=["#E69F00","#56B4E9","#009E73","#F0E442","#0072B2","#D55E00","#CC79A7","#999999"],fe="#BBBBBB",Er="#0072B2",Tr=(t,e)=>({...t,...e});var bt=["IdType","Gene","Organism","Assembly","OrthologGroup","Transcript","Protein","Domain","GOTerm","Pathway","Dataset","Condition","Publication"],tt=t=>String(t??"").replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[e]),De=(t,e=26)=>t.length>e?t.slice(0,e-1)+"\u2026":t;function yt(t){let e=Array.isArray(t.nodes)?t.nodes:Object.values(t.nodes||{}),r=t.edges||[],n=Object.fromEntries(e.map(o=>[o.id,o]));return{nodes:e,edges:r,metadata:t.metadata||{},byId:n}}function Sr(t,e,r){let{nodes:n,edges:o,metadata:i}=yt(t),a=o.filter(l=>l.confidence>=e),u=new Set(a.flatMap(l=>[l.subject,l.object])),f=r||i.query;f&&u.add(f);let s=n.filter(l=>u.has(l.id));return{nodes:s,edges:a,metadata:i,byId:Object.fromEntries(s.map(l=>[l.id,l]))}}function Ma(t){return yt(t).nodes.map(e=>({id:e.id,type:e.type,label:e.label||e.id,namespace:e.id_namespace,url:e.url,degree:e.degree}))}function Aa(t){let{edges:e,byId:r}=yt(t);return e.map(n=>({subject:n.subject,subjectLabel:r[n.subject]?.label||n.subject,predicate:n.predicate,object:n.object,objectLabel:r[n.object]?.label||n.object,confidence:n.confidence}))}function Ea(t){let{nodes:e}=yt(t),r=new Map;return e.forEach(o=>r.set(o.type,(r.get(o.type)||0)+1)),bt.filter(o=>r.has(o)).concat([...r.keys()].filter(o=>!bt.includes(o))).map(o=>({type:o,count:r.get(o)}))}function Nr(t,e=ue,r=fe){let n=new Map;t.forEach(a=>n.set(a.predicate,(n.get(a.predicate)||0)+1));let o=[...n.entries()].sort((a,u)=>u[1]-a[1]),i=new Map(o.slice(0,e.length).map((a,u)=>[a[0],e[u]]));return{color:a=>i.get(a)||r,ranked:o}}function Ta(t){return t.attrs&&t.attrs.resolve_id?String(t.attrs.resolve_id):t.attrs&&t.attrs.gene_id?String(t.attrs.gene_id):(t.id.includes(":")?t.id.split(":").slice(1).join(":"):t.id)||t.id}var Sa=.05,Na=6,Rf=44,Of=110;function Pf(t,e,r,n,o){if(r==="force"){let s=t.map(y=>({...y})),l=e.map(y=>({source:y.subject,target:y.object})),h=ln(s).force("link",fn(l).id(y=>y.id).distance(70)).force("charge",cn().strength(-180)).force("center",an(n/2,o/2)).force("collide",un(16)).stop(),c=300,p=30;return new Promise(y=>{let x=0,g=()=>{for(let d=0;d<p&&x<c;d++,x++)h.tick();x<c?setTimeout(g,0):y([Object.fromEntries(s.map(d=>[d.id,{x:d.x,y:d.y}])),[]])};g()})}let i=Lt(t,s=>s.type),a=bt.filter(s=>i.has(s)).concat([...i.keys()].filter(s=>!bt.includes(s))),u=Re(a,[90,n-90]),f={};return a.forEach(s=>{let l=i.get(s),h=Re(Wt(l.length),[45,o-30]);l.forEach((c,p)=>f[c.id]={x:u(s),y:h(p)})}),[f,a]}function zf(t,e,r,n){let o=new Map(t.map(s=>[s.id,{...s,x:e[s.id].x,y:e[s.id].y}])),i=new Map,a=new Map;t.forEach(s=>{i.set(s.id,s.id);let[l,h]=n.apply([e[s.id].x,e[s.id].y]);a.set(s.id,[l,h,l,h])});let u=s=>{for(;i.get(s)!==s;)i.set(s,i.get(i.get(s))),s=i.get(s);return s};r.map(s=>{let l=e[s.subject],h=e[s.object];if(!l||!h)return null;let[c,p]=n.apply([l.x,l.y]),[y,x]=n.apply([h.x,h.y]);return{d:Math.hypot(c-y,p-x),s:s.subject,o:s.object}}).filter(s=>s&&s.d<Rf).sort((s,l)=>s.d-l.d).forEach(({s,o:l})=>{let h=u(s),c=u(l);if(h===c)return;let p=a.get(h),y=a.get(c),x=[Math.min(p[0],y[0]),Math.min(p[1],y[1]),Math.max(p[2],y[2]),Math.max(p[3],y[3])];Math.max(x[2]-x[0],x[3]-x[1])>Of||(i.set(h,c),a.set(c,x))});let f=new Map;return t.forEach(s=>{let l=u(s.id);(f.get(l)||f.set(l,[]).get(l)).push(o.get(s.id))}),[...f.entries()].map(([s,l])=>({key:l.length>1?`c:${s}`:`s:${l[0].id}`,members:l}))}function $r(t,e){let r=[...pe(e,n=>n.length,n=>n.predicate).entries()].sort((n,o)=>o[1]-n[1]);return`<div class="bn-t-title">${tt(t.label||t.id)}</div><div class="bn-t-sub">${tt(t.id)} \xB7 ${tt(t.type)} \xB7 click for details</div>`+(e.length?`<div class="bn-t-sub">${e.length} edges \xB7 ${r.map(([n,o])=>`${tt(n)}\xD7${o}`).join(" ")}</div>`:"")}function Rn(t,e){if(t.count===1)return $r(t.members[0],e(t.members[0].id));let r=[...pe(t.members,o=>o.length,o=>o.type).entries()].sort((o,i)=>i[1]-o[1]),n=t.members.slice(0,5).map(o=>tt(o.label||o.id));return`<div class="bn-t-title">${t.count} nodes \u2014 click to zoom in</div><div class="bn-t-sub">${r.map(([o,i])=>`${tt(o)}\xD7${i}`).join(" ")}</div><div class="bn-t-sub">${n.join(", ")}${t.count>5?", \u2026":""}</div>`}function $a(t,e,r={}){let n={layout:"columns",width:1400,height:700,minConfidence:0,cluster:!0,legend:!0,interactive:!0,palette:{},onSelect:null,onHover:null,...r},o=Tr(Mr,n.palette),i=S=>o[S]||Ar;t.classList.add("bn-net-wrap");let a=at(t).append("svg").attr("class","bn-net").attr("viewBox",`0 0 ${n.width} ${n.height}`).attr("preserveAspectRatio","xMidYMid meet"),u=document.createElement("div");u.className="bn-tip",u.style.display="none",t.appendChild(u);let f=document.createElement("div");f.className="bn-legend",n.legend&&t.appendChild(f);let s=null,l=null,h=null,c=!1,p=0,y=n.width,x=n.height,g=In().scaleExtent([Sa,Na]).on("zoom",S=>{a.select(".viewport").attr("transform",S.transform),l&&l.mode==="force"&&n.cluster&&I()});n.interactive&&a.call(g);let d=(S,M,k,m,E=.85,v=Na)=>{let T=Math.max(Sa,Math.min(v,E*Math.min(y/Math.max(20,k-S),x/Math.max(20,m-M))));return St.translate(y/2-T*(S+k)/2,x/2-T*(M+m)/2).scale(T)},_=(S,M)=>{u.innerHTML=M,u.style.display="block";let k=u.getBoundingClientRect();u.style.left=Math.min(S.clientX+14,innerWidth-k.width-10)+"px",u.style.top=Math.min(S.clientY+12,innerHeight-k.height-10)+"px"},A=()=>u.style.display="none",w=(S,M)=>{let k=Dt(a.node()),[m,E]=k.apply([S,M]),v=a.node().getBoundingClientRect();return{clientX:v.left+m*v.width/y,clientY:v.top+E*v.height/x}};function I(){c||(c=!0,requestAnimationFrame(()=>{c=!1,l&&b()}))}function b(){let{nodes:S,edges:M,pos:k,mode:m,byId:E,labelAlways:v}=l,T=a.select(".viewport"),O=Dt(a.node());T.select(".links").selectAll("*").remove(),T.select(".nodes").selectAll("*").remove();let P=new Map,$=new Map;M.forEach(R=>{(P.get(R.subject)||P.set(R.subject,new Set).get(R.subject)).add(R.object),(P.get(R.object)||P.set(R.object,new Set).get(R.object)).add(R.subject),($.get(R.subject)||$.set(R.subject,[]).get(R.subject)).push(R),($.get(R.object)||$.set(R.object,[]).get(R.object)).push(R)});let D=R=>P.get(R)||new Set,j=R=>$.get(R)||[];if(n.interactive&&a.on("click.bg",R=>{R.target.closest&&R.target.closest(".nodeg")||h!==null&&(h=null,n.onSelect?.(null,l),b())}),m==="force"&&n.cluster){L(T,S,M,k,E,O,D);return}let Q=T.select(".links").selectAll(".link").data(M).join("path").attr("class","link").attr("d",R=>{let Y=k[R.subject],H=k[R.object];if(!Y||!H)return"";let N=(Y.x+H.x)/2;return`M${Y.x},${Y.y} C${N},${Y.y} ${N},${H.y} ${H.x},${H.y}`}).attr("stroke","#718096").attr("stroke-opacity",R=>.12+.88*R.confidence).attr("stroke-width",R=>.5+2.5*R.confidence);function X(R){let Y=D(R);W.classed("dim",H=>H.id!==R&&!Y.has(H.id)),Q.classed("link-dim",H=>H.subject!==R&&H.object!==R).classed("link-hi",H=>H.subject===R||H.object===R),W.select(".nodelabel").classed("on",H=>H.id===R||Y.has(H.id)||v.has(H.id))}function V(){W.classed("dim",!1),Q.classed("link-dim",!1).classed("link-hi",!1),W.select(".nodelabel").classed("on",R=>v.has(R.id))}let U=()=>{h&&E[h]?X(h):V()},G=R=>{h=h===R.id?null:R.id,n.onSelect?.(h?R:null,l)},et=n.interactive?R=>R.attr("tabindex",0).attr("role","button").attr("aria-label",Y=>`${Y.label||Y.id} (${Y.type})`).style("cursor","pointer").on("click",(Y,H)=>G(H)).on("keydown",(Y,H)=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),G(H))}).on("mouseenter",(Y,H)=>{X(H.id),n.onHover?.(H),_(Y,$r(H,j(H.id)))}).on("mousemove",(Y,H)=>_(Y,$r(H,j(H.id)))).on("mouseleave",()=>{U(),A(),n.onHover?.(null)}).on("focus",(Y,H)=>{let N=k[H.id];_(w(N.x,N.y),$r(H,j(H.id))),X(H.id)}).on("blur",()=>{A(),U()}):R=>R,W=T.select(".nodes").selectAll(".nodeg").data(S,R=>R.id).join("g").attr("class","nodeg").attr("transform",R=>`translate(${k[R.id].x},${k[R.id].y})`).call(et);W.append("circle").attr("class","node").attr("r",5).attr("fill",R=>i(R.type)),W.append("text").attr("class","nodelabel").attr("x",7).attr("y",3).classed("on",R=>v.has(R.id)).text(R=>De(R.label||R.id)),U()}function z(S){let M=kt(S,v=>v.x),k=ct(S,v=>v.x),m=kt(S,v=>v.y),E=ct(S,v=>v.y);a.transition().duration(450).call(g.transform,d(M,m,k,E))}function L(S,M,k,m,E,v,T){let O=zf(M,m,k,v);O.forEach((N,F)=>{N.i=F,N.count=N.members.length,N.x=me(N.members,q=>q.x),N.y=me(N.members,q=>q.y)});let P=new Map;O.forEach(N=>N.members.forEach(F=>P.set(F.id,N)));let $=new Map,D=new Map;k.forEach(N=>{let F=P.get(N.subject),q=P.get(N.object);if(!F||!q||F===q)return;($.get(F)||$.set(F,new Set).get(F)).add(q),($.get(q)||$.set(q,new Set).get(q)).add(F);let Nt=F.i<q.i?F.i+"|"+q.i:q.i+"|"+F.i,le=D.get(Nt)||{a:F,b:q,n:0,conf:0,preds:{}};le.n++,le.conf+=N.confidence,le.preds[N.predicate]=(le.preds[N.predicate]||0)+1,D.set(Nt,le)});let j=[...D.values()],Q=S.select(".links").selectAll(".link").data(j).join("path").attr("class","link").attr("d",N=>`M${N.a.x},${N.a.y} C${(N.a.x+N.b.x)/2},${N.a.y} ${(N.a.x+N.b.x)/2},${N.b.y} ${N.b.x},${N.b.y}`).attr("stroke","#718096").attr("stroke-opacity",N=>.12+.88*(N.conf/N.n)).attr("stroke-width",N=>.8+1.6*Math.sqrt(N.n));Q.append("title").text(N=>`${N.n} edge${N.n>1?"s":""} \xB7 `+Object.entries(N.preds).sort((F,q)=>q[1]-F[1]).map(([F,q])=>`${F}\xD7${q}`).join(" "));let X=En().domain([1,Math.max(2,ct(O,N=>N.count))]).range([5,26]),V=$n().value(N=>N[1]),U=Nn().innerRadius(0);function G(N){let F=$.get(N)||new Set;H.classed("dim",q=>q!==N&&!F.has(q)),Q.classed("link-dim",q=>q.a!==N&&q.b!==N).classed("link-hi",q=>q.a===N||q.b===N),H.select(".nodelabel").classed("on",q=>q.count>1||q===N||F.has(q))}function et(){H.classed("dim",!1),Q.classed("link-dim",!1).classed("link-hi",!1),H.select(".nodelabel").classed("on",N=>N.count>1)}let W=()=>{let N=h?P.get(h):null;N?G(N):et()},R=N=>{if(A(),N.count===1){let F=N.members[0];h=h===F.id?null:F.id,n.onSelect?.(h?F:null,l)}else z(N.members)},Y=n.interactive?N=>N.attr("tabindex",0).attr("role","button").attr("aria-label",F=>F.count>1?`cluster of ${F.count} nodes`:`${F.members[0].label||F.members[0].id} (${F.members[0].type})`).style("cursor","pointer").on("click",(F,q)=>R(q)).on("keydown",(F,q)=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),R(q))}).on("mouseenter",(F,q)=>{G(q),_(F,Rn(q,incOf))}).on("mousemove",(F,q)=>_(F,Rn(q,incOf))).on("mouseleave",()=>{W(),A()}).on("focus",(F,q)=>{G(q),_(w(q.x,q.y),Rn(q,incOf))}).on("blur",()=>{W(),A()}):N=>N,H=S.select(".nodes").selectAll(".nodeg").data(O,N=>N.key).join("g").attr("class",N=>"nodeg"+(N.count>1?" cluster":"")).attr("transform",N=>`translate(${N.x},${N.y})`).call(Y);H.each(function(N){let F=at(this);if(N.count>1){let q=V([...pe(N.members,Nt=>Nt.length,Nt=>Nt.type).entries()]);F.selectAll("path.slice").data(q).join("path").attr("class","slice").attr("d",U.outerRadius(X(N.count))).attr("fill",Nt=>i(Nt.data[0])).attr("stroke","#fff").attr("stroke-width",1),F.append("text").attr("class","nodelabel on").attr("text-anchor","middle").attr("dy","0.35em").attr("font-weight","600").text(N.count)}else{let q=N.members[0];F.append("circle").attr("class","node").attr("r",5).attr("fill",i(q.type)),F.append("text").attr("class","nodelabel").attr("x",7).attr("y",3).text(De(q.label||q.id))}}),W()}function C(S){let M=yt(S);s=M;let k=n.minConfidence>0?Sr(M,n.minConfidence,M.metadata.query):M,{nodes:m,edges:E,byId:v}=k,T=n.layout;a.selectAll("*").remove();let O=++p,P=Pf(m,E,T,y,x),$=([D,j])=>O===p&&B(k,T,D,j);P instanceof Promise?P.then($):$(P)}function B({nodes:S,edges:M,byId:k},m,E,v){let T=a.append("g").attr("class","viewport"),O=Dt(a.node());if(m==="force"&&S.length&&O.k===1&&!O.x&&!O.y){let $=S.map(j=>E[j.id].x),D=S.map(j=>E[j.id].y);a.call(g.transform,d(kt($),kt(D),ct($),ct(D),.9,1.5))}if(T.attr("transform",Dt(a.node())),m==="columns"){let $=Re(v,[90,y-90]);T.append("g").selectAll(".colhead").data(v).join("text").attr("class","colhead").attr("x",D=>$(D)).attr("y",20).attr("text-anchor","middle").text(D=>D)}T.append("g").attr("class","links"),T.append("g").attr("class","nodes");let P=new Set;if(m==="columns"&&Lt(S,D=>D.type).forEach(D=>{D.length&&(x-75)/D.length>=12&&D.forEach(j=>P.add(j.id))}),h=null,l={nodes:S,edges:M,pos:E,mode:m,byId:k,labelAlways:P},b(),n.legend){let $=[...new Set(S.map(D=>D.type))];f.innerHTML=$.map(D=>`<span class="leg"><i style="background:${i(D)}"></i>${tt(D)}</span>`).join(""),f.hidden=!S.length}}return e&&C(e),{update(S){a.call(g.transform,St),C(S)},refresh(){s&&C(s)},setLayout(S){n.layout=S,this.refresh()},setCluster(S){n.cluster=S,l&&b()},setMinConfidence(S){n.minConfidence=S,this.refresh()},zoomBy(S){a.transition().duration(200).call(g.scaleBy,S)},fit(){if(l&&l.nodes.length){let S=l.nodes.map(k=>l.pos[k.id].x),M=l.nodes.map(k=>l.pos[k.id].y);a.transition().duration(300).call(g.transform,d(kt(S),kt(M),ct(S),ct(M),.9,1.5))}else this.resetView()},resetView(){a.transition().duration(300).call(g.transform,St)},selected(){return h&&l?l.byId[h]:null},destroy(){a.on(".zoom",null),t.innerHTML="",t.classList.remove("bn-net-wrap")}}}function Ca(t,e,r={}){let n={width:null,height:130,stackBy:"off",barColor:Er,predicatePalette:ue,predicateOther:fe,onBarClick:null,onSegmentClick:null,...r};t.classList.add("bn-ov-wrap");let o=at(t).append("svg").attr("class","bn-ov"),i=null;function a(){if(!i)return;let{nodes:f,edges:s,byId:l}=i;if(o.selectAll("*").remove(),t.hidden=!f.length,!f.length)return;let h=n.width||Math.max(600,t.clientWidth||900),c=n.height,p={t:28,r:10,b:30,l:36};o.attr("viewBox",`0 0 ${h} ${c}`);let y=Lt(f,b=>b.type),x=bt.filter(b=>y.has(b)).concat([...y.keys()].filter(b=>!bt.includes(b))),g=oe(x,[p.l,h-p.r]).padding(.25),d=Nr(s,n.predicatePalette,n.predicateOther),_=null,A;if(n.stackBy==="off")A=ct(x,b=>y.get(b).length)||1;else{let b=new Map(x.map(z=>[z,new Map]));s.forEach(z=>{let L=l[n.stackBy==="subject"?z.subject:z.object];!L||!b.has(L.type)||b.get(L.type).set(z.predicate,(b.get(L.type).get(z.predicate)||0)+1)}),_=new Map(x.map(z=>{let L=0;return[z,[...b.get(z).entries()].sort((C,B)=>B[1]-C[1]).map(([C,B])=>({pred:C,v0:L,v1:L+=B}))]})),A=ct(x,z=>Fe([...b.get(z).values()]))||1}let w=Oe([0,A],[c-p.b,p.t]);o.append("g").attr("transform",`translate(${p.l},0)`).call(Br(w).ticks(4).tickSize(0)).call(b=>b.select(".domain").remove());let I=o.selectAll(".bar").data(x).join("g").attr("class","bar").attr("transform",b=>`translate(${g(b)},0)`);if((n.onBarClick||n.onSegmentClick)&&I.style("cursor","pointer").on("click",(b,z)=>n.onBarClick&&n.onBarClick(z,b)),n.stackBy==="off")I.append("rect").attr("y",b=>w(y.get(b).length)).attr("height",b=>c-p.b-w(y.get(b).length)).attr("width",g.bandwidth()).attr("fill",n.barColor).append("title").text(b=>`${b}: ${y.get(b).length} nodes`),I.append("text").attr("x",g.bandwidth()/2).attr("text-anchor","middle").attr("y",b=>w(y.get(b).length)-3).text(b=>y.get(b).length);else{I.selectAll("rect.seg").data(C=>_.get(C)).join("rect").attr("class","seg").attr("y",C=>w(C.v1)).attr("height",C=>w(C.v0)-w(C.v1)).attr("width",g.bandwidth()).attr("fill",C=>d.color(C.pred)).on("click",n.onSegmentClick?(C,B)=>{C.stopPropagation(),n.onSegmentClick(at(C.target.parentNode).datum(),B.pred,C)}:null).append("title").text(C=>`${C.pred} \xD7${C.v1-C.v0}`);let b=new Set;_.forEach(C=>C.forEach(B=>b.add(B.pred)));let z=d.ranked.filter(([C])=>b.has(C)).slice(0,8).map(([C])=>C);[...b].some(C=>d.color(C)===n.predicateOther)&&z.push("other");let L=o.append("g").attr("transform",`translate(${p.l+6},6)`);z.forEach((C,B)=>{let S=B%5*115,M=Math.floor(B/5)*12;L.append("rect").attr("x",S).attr("y",M).attr("width",8).attr("height",8).attr("fill",C==="other"?n.predicateOther:d.color(C)),L.append("text").attr("x",S+11).attr("y",M+7).text(C)})}I.append("text").attr("x",g.bandwidth()/2).attr("y",c-p.b+12).attr("text-anchor","middle").text(b=>b)}let u=null;return!n.width&&typeof ResizeObserver<"u"&&(u=new ResizeObserver(()=>a()),u.observe(t)),e&&(i=yt(e),a()),{update(f){i=yt(f),a()},setStackBy(f){n.stackBy=f,a()},destroy(){u?.disconnect(),o.remove(),t.classList.remove("bn-ov-wrap")}}}function Ia(t,e={}){let r={onResolve:null,...e};return t.classList.add("bn-detail"),t.hidden=!0,{show(n,{edges:o=[],byId:i={}}={}){let a=o.filter(f=>f.subject===n.id||f.object===n.id);t.innerHTML=`<button class="bn-d-close" title="close">\u2715</button><h3>${tt(n.label||n.id)}</h3><div class="bn-d-sub">${tt(n.id)} \xB7 ${tt(n.type)}${n.id_namespace?" \xB7 "+tt(n.id_namespace):""}</div><ul>`+a.map(f=>{let s=f.subject===n.id?f.object:f.subject,l=i[s];return`<li>${f.subject===n.id?"\u2192":"\u2190"} ${tt(f.predicate)} ${tt(l&&l.label||s)} <span class="bn-conf">${f.confidence.toFixed(2)}</span></li>`}).join("")+'</ul><div class="bn-d-actions">'+(n.url?`<a href="${tt(n.url)}" target="_blank" rel="noopener">source \u2197</a>`:"")+(r.onResolve&&n.type==="Gene"?'<a href="#" class="bn-d-resolve">resolve \u2192</a>':"")+"</div>",t.hidden=!1,t.querySelector(".bn-d-close").onclick=()=>{t.hidden=!0};let u=t.querySelector(".bn-d-resolve");u&&(u.onclick=f=>{f.preventDefault(),r.onResolve(n)})},hide(){t.hidden=!0},visible(){return!t.hidden},destroy(){t.innerHTML="",t.hidden=!0,t.classList.remove("bn-detail")}}}return Ba(Df);})();
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Driver script for `bionym resolve --report` HTML output.
3
+ * Inlined into the generated page after the IIFE bundle and graph JSON.
4
+ * Expects: window.BionymComponents (bundle), window.__GRAPH__ (JSON).
5
+ */
6
+ (function () {
7
+ const { BionymNetwork, BionymOverview, BionymDetail, parseGraph, esc } =
8
+ window.BionymComponents;
9
+ const graph = window.__GRAPH__;
10
+ const $ = s => document.querySelector(s);
11
+
12
+ const g = parseGraph(graph);
13
+ const byId = g.byId;
14
+
15
+ // collapsible summary block (only when the resolver ran summarize)
16
+ const sum = g.metadata.summary;
17
+ const det = $("#summary");
18
+ det.hidden = !sum || !sum.length;
19
+ if (!det.hidden) {
20
+ $("#summarylist").innerHTML = sum
21
+ .map(s => `<li>${esc(s.claim)} <span class="sumconf">${(+s.confidence).toFixed(2)}</span></li>`)
22
+ .join("");
23
+ }
24
+
25
+ const detail = BionymDetail($("#detail"));
26
+ const net = BionymNetwork($("#net"), graph, {
27
+ onSelect: (n, ctx) => (n ? detail.show(n, ctx) : detail.hide()),
28
+ });
29
+ const ov = BionymOverview($("#ov"), graph);
30
+
31
+ // ---- control chrome → component methods ----------------------------------
32
+ $("#resetzoom").addEventListener("click", () => net.fit());
33
+ $("#zin").addEventListener("click", () => net.zoomBy(1.4));
34
+ $("#zout").addEventListener("click", () => net.zoomBy(1 / 1.4));
35
+ $("#layout").addEventListener("change", () => {
36
+ $("#clustwrap").hidden = $("#layout").value !== "force";
37
+ net.setLayout($("#layout").value);
38
+ });
39
+ $("#clustergroup").addEventListener("change", () => net.setCluster($("#clustergroup").checked));
40
+ $("#stacksel").addEventListener("change", () => ov.setStackBy($("#stacksel").value));
41
+
42
+ // ---- sortable + filterable tables ----------------------------------------
43
+ const link = n => n.url
44
+ ? `<a href="${esc(n.url)}" target="_blank" rel="noopener">${esc(n.label || n.id)}</a>`
45
+ : esc(n.label || n.id);
46
+ const cell = id => byId[id] ? link(byId[id]) : esc(id);
47
+
48
+ function sortable(tableId, rows, cols, initKey = null, initDir = 1) {
49
+ const tbl = document.getElementById(tableId);
50
+ const tbody = tbl.querySelector("tbody");
51
+ const ths = [...tbl.querySelectorAll("th")];
52
+ const state = { key: initKey, dir: initDir, filter: "" };
53
+ const fi = document.querySelector(`.tfilter[data-for="${tableId}"]`);
54
+ if (fi) fi.oninput = e => { state.filter = e.target.value.toLowerCase(); draw(); };
55
+ ths.forEach((th, i) => th.onclick = () => {
56
+ if (state.key === i) state.dir *= -1; else { state.key = i; state.dir = 1; }
57
+ draw();
58
+ });
59
+ function draw() {
60
+ let rs = rows.filter(r => !state.filter || cols.some(c => String(c.val(r) ?? "").toLowerCase().includes(state.filter)));
61
+ if (state.key !== null) {
62
+ const c = cols[state.key];
63
+ rs = rs.slice().sort((a, b) => {
64
+ const x = c.val(a), y = c.val(b);
65
+ return (typeof x === "number" && typeof y === "number" ? x - y
66
+ : String(x ?? "").localeCompare(String(y ?? ""))) * state.dir;
67
+ });
68
+ }
69
+ tbody.innerHTML = rs.map(r => "<tr>" +
70
+ cols.map(c => `<td class="${c.cls || ""}">${c.render(r)}</td>`).join("") +
71
+ "</tr>").join("");
72
+ ths.forEach((th, i) => th.textContent =
73
+ cols[i].label + (state.key === i ? (state.dir > 0 ? " ▲" : " ▼") : ""));
74
+ }
75
+ draw();
76
+ }
77
+
78
+ sortable("edges", g.edges, [
79
+ { label: "subject", val: e => e.subject, render: e => cell(e.subject) },
80
+ { label: "predicate", val: e => e.predicate, render: e => esc(e.predicate) },
81
+ { label: "object", val: e => e.object, render: e => cell(e.object) },
82
+ { label: "conf", val: e => e.confidence, render: e => e.confidence.toFixed(2), cls: "conf" },
83
+ { label: "ev", val: e => (e.evidence || []).length, render: e => (e.evidence || []).length },
84
+ ], 3, -1);
85
+ sortable("nodes", g.nodes, [
86
+ { label: "id", val: n => n.id, render: n => esc(n.id) },
87
+ { label: "type", val: n => n.type, render: n => esc(n.type) },
88
+ { label: "label", val: n => n.label || n.id, render: n => link(n) },
89
+ { label: "namespace", val: n => n.id_namespace, render: n => esc(n.id_namespace) },
90
+ ], 1, 1);
91
+ })();
bionym/ask.py ADDED
@@ -0,0 +1,157 @@
1
+ """Ask-the-graph orchestration: classify -> slice -> LLM answers -> JEV scores.
2
+
3
+ The question is first bucketed into graph categories (JEV noul flags —
4
+ see questions/ask.CATEGORIES); the LLM and the judging JEV ask then see
5
+ only that slice, because whole-graph states overflow JEV's context.
6
+ When no category matches (`other`), the LLM still answers over a compact
7
+ projection but nothing is scored — a warning says so.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import logging
14
+ from typing import Any
15
+
16
+ from .graph import KnowledgeGraph
17
+ from .jev import JevClient, JevError
18
+ from .llm import LlmClient, LlmError
19
+ from .questions import ask as ask_q
20
+
21
+ log = logging.getLogger(__name__)
22
+
23
+ # Category noul >= this counts the question as "about" that category.
24
+ CAT_THRESHOLD = 0.5
25
+
26
+
27
+ def _categories(
28
+ answers: dict[str, Any],
29
+ ) -> tuple[list[str], dict[str, float]]:
30
+ flags = {
31
+ qid.removeprefix("cat_"): (v.get("noul") if isinstance(v, dict) else v)
32
+ for qid, v in answers.items()
33
+ }
34
+ picked = [k for k, v in flags.items() if (v or 0) >= CAT_THRESHOLD]
35
+ # stable order = CATEGORIES declaration order
36
+ picked.sort(key=list(ask_q.CATEGORIES).index)
37
+ return picked, flags
38
+
39
+
40
+ def _parse_payload(text: str) -> dict | None:
41
+ """Strict JSON, else the outermost {...} span — models often wrap
42
+ the payload in a ```json fence or add prose around it."""
43
+ try:
44
+ v = json.loads(text)
45
+ except json.JSONDecodeError:
46
+ try:
47
+ v = json.loads(text[text.index("{"):text.rindex("}") + 1])
48
+ except (json.JSONDecodeError, ValueError):
49
+ return None
50
+ return v if isinstance(v, dict) else None
51
+
52
+
53
+ def _llm_answer(
54
+ llm: LlmClient, projection: dict, question: str, excerpt: bool
55
+ ) -> tuple[str, list]:
56
+ system, user = ask_q.build_answer_messages(
57
+ json.dumps(projection), question, excerpt=excerpt
58
+ )
59
+ raw = llm.complete(system, user)
60
+ payload = _parse_payload(raw)
61
+ if payload is None:
62
+ # model ignored the JSON contract — keep the prose, flag no cites
63
+ return raw, []
64
+ answer = payload.get("answer") or ""
65
+ if isinstance(answer, str):
66
+ # tolerate double-encoding: answer is itself a JSON string
67
+ inner = _parse_payload(answer)
68
+ if inner and isinstance(inner.get("answer"), str) and inner["answer"]:
69
+ answer = inner["answer"]
70
+ else:
71
+ answer = json.dumps(answer)
72
+ cited = payload.get("cited_nodes")
73
+ return answer, cited if isinstance(cited, list) else []
74
+
75
+
76
+ def ask_graph(
77
+ jev: JevClient,
78
+ llm: LlmClient,
79
+ question: str,
80
+ graph: KnowledgeGraph,
81
+ ) -> dict[str, Any]:
82
+ """Answer `question` over `graph`; return answer + JEV scores."""
83
+ if not llm.enabled:
84
+ raise LlmError("LLM not configured (LLM_API_KEY/LLM_MODEL)")
85
+
86
+ cls = jev.ask(
87
+ ask_q.build_classify_state(question),
88
+ ask_q.build_classify_questions(),
89
+ stage="ask_classify",
90
+ )
91
+ categories, flags = _categories(cls)
92
+
93
+ if not categories:
94
+ # 'other': no bounded slice exists to judge against, so we answer
95
+ # over the capped full projection and return the answer unscored.
96
+ answer, cited = _llm_answer(
97
+ llm, ask_q.compact_graph(graph), question, excerpt=False
98
+ )
99
+ return {
100
+ "question": question,
101
+ "answer": answer,
102
+ "cited_nodes": cited,
103
+ "invalid_cited_nodes": [c for c in cited if str(c) not in graph.nodes],
104
+ "categories": [],
105
+ "category_scores": flags,
106
+ "scored": False,
107
+ "warning": (
108
+ "Question didn't map to any graph category — answer "
109
+ "returned without JEV scoring. It may be outside what the "
110
+ "graph can answer."
111
+ ),
112
+ "scores": {},
113
+ }
114
+
115
+ proj = ask_q.slice_graph(graph, categories)
116
+ answer, cited = _llm_answer(llm, proj, question, excerpt=True)
117
+ # Citation fidelity is checked deterministically against the FULL
118
+ # graph — a cite to a real node outside the slice is still a real id.
119
+ invalid = [c for c in cited if str(c) not in graph.nodes]
120
+ fidelity = (len(cited) - len(invalid)) / len(cited) if cited else None
121
+ try:
122
+ answers = jev.ask(
123
+ ask_q.build_state(question, answer, proj, categories),
124
+ ask_q.build_questions(),
125
+ stage="ask",
126
+ )
127
+ except JevError as e:
128
+ # Judge failed after the answer was generated — same contract as
129
+ # 'other': keep the answer, flag it unscored.
130
+ return {
131
+ "question": question,
132
+ "answer": answer,
133
+ "cited_nodes": cited,
134
+ "invalid_cited_nodes": invalid,
135
+ "categories": categories,
136
+ "category_scores": flags,
137
+ "scored": False,
138
+ "warning": f"JEV scoring failed ({e}) — answer returned unscored.",
139
+ "scores": {"citation_fidelity": fidelity},
140
+ }
141
+ return {
142
+ "question": question,
143
+ "answer": answer,
144
+ "cited_nodes": cited,
145
+ "invalid_cited_nodes": invalid,
146
+ "categories": categories,
147
+ "category_scores": flags,
148
+ "scored": True,
149
+ "warning": None,
150
+ "scores": {
151
+ "citation_fidelity": fidelity,
152
+ **{
153
+ k: (v.get("noul") if isinstance(v, dict) else v)
154
+ for k, v in answers.items()
155
+ },
156
+ },
157
+ }