var zn=Object.defineProperty;var ke=t=>{throw TypeError(t)};var Sn=(t,e,n)=>e in t?zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var q=(t,e,n)=>Sn(t,typeof e!="symbol"?e+"":e,n),ze=(t,e,n)=>e.has(t)||ke("Cannot "+n);var Se=(t,e,n)=>(ze(t,e,"read from private field"),n?n.call(t):e.get(t)),St=(t,e,n)=>e.has(t)?ke("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n);var Q=(t,e,n)=>(ze(t,e,"access private method"),n);import{a as gt,c as Tt}from"./triplestore-DD4Ytlqh.js";import{S as Ue,h as Un,r as Pn,s as B,j as pe,k as En,l as In,c as Pe,i as jn,d as An,f as On,n as Vt,T as Jt,o as Kt,p as Fn,m as Yn,e as Bn,q as Ee}from"./transform-CA9Jdjju.js";import{b6 as Lt}from"./index-pVvkWKzi.js";function Ln(t){let e;for(;e=t.sourceEvent;)t=e;return t}function lt(t,e){if(t=Ln(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}function Rt(t){return typeof t=="string"?new Ue([document.querySelectorAll(t)],[document.documentElement]):new Ue([Un(t)],Pn)}const Rn={passive:!1},jt={capture:!0,passive:!1};function te(t){t.stopImmediatePropagation()}function Ct(t){t.preventDefault(),t.stopImmediatePropagation()}function tn(t){var e=t.document.documentElement,n=B(t).on("dragstart.drag",Ct,jt);"onselectstart"in e?n.on("selectstart.drag",Ct,jt):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function en(t,e){var n=t.document.documentElement,r=B(t).on("dragstart.drag",null);e&&(r.on("click.drag",Ct,jt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ft=t=>()=>t;function le(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:o,x:s,y:a,dx:l,dy:u,dispatch:_}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:_}})}le.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function qn(t){return!t.ctrlKey&&!t.button}function Hn(){return this.parentNode}function Wn(t,e){return e??{x:t.x,y:t.y}}function Xn(){return navigator.maxTouchPoints||"ontouchstart"in this}function me(){var t=qn,e=Hn,n=Wn,r=Xn,i={},o=pe("start","drag","end"),s=0,a,l,u,_,p=0;function f(h){h.on("mousedown.drag",g).filter(r).on("touchstart.drag",m).on("touchmove.drag",c,Rn).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(h,N){if(!(_||!t.call(this,h,N))){var x=D(this,e.call(this,h,N),h,N,"mouse");x&&(B(h.view).on("mousemove.drag",T,jt).on("mouseup.drag",y,jt),tn(h.view),te(h),u=!1,a=h.clientX,l=h.clientY,x("start",h))}}function T(h){if(Ct(h),!u){var N=h.clientX-a,x=h.clientY-l;u=N*N+x*x>p}i.mouse("drag",h)}function y(h){B(h.view).on("mousemove.drag mouseup.drag",null),en(h.view,u),Ct(h),i.mouse("end",h)}function m(h,N){if(t.call(this,h,N)){var x=h.changedTouches,k=e.call(this,h,N),E=x.length,Y,L;for(Y=0;Y<E;++Y)(L=D(this,k,h,N,x[Y].identifier,x[Y]))&&(te(h),L("start",h,x[Y]))}}function c(h){var N=h.changedTouches,x=N.length,k,E;for(k=0;k<x;++k)(E=i[N[k].identifier])&&(Ct(h),E("drag",h,N[k]))}function v(h){var N=h.changedTouches,x=N.length,k,E;for(_&&clearTimeout(_),_=setTimeout(function(){_=null},500),k=0;k<x;++k)(E=i[N[k].identifier])&&(te(h),E("end",h,N[k]))}function D(h,N,x,k,E,Y){var L=o.copy(),Z=lt(Y||x,N),vt,bt,d;if((d=n.call(h,new le("beforestart",{sourceEvent:x,target:f,identifier:E,active:s,x:Z[0],y:Z[1],dx:0,dy:0,dispatch:L}),k))!=null)return vt=d.x-Z[0]||0,bt=d.y-Z[1]||0,function $(w,C,z){var S=Z,U;switch(w){case"start":i[E]=$,U=s++;break;case"end":delete i[E],--s;case"drag":Z=lt(z||C,N),U=s;break}L.call(w,h,new le(w,{sourceEvent:C,subject:d,target:f,identifier:E,active:U,x:Z[0]+vt,y:Z[1]+bt,dx:Z[0]-S[0],dy:Z[1]-S[1],dispatch:L}),k)}}return f.filter=function(h){return arguments.length?(t=typeof h=="function"?h:Ft(!!h),f):t},f.container=function(h){return arguments.length?(e=typeof h=="function"?h:Ft(h),f):e},f.subject=function(h){return arguments.length?(n=typeof h=="function"?h:Ft(h),f):n},f.touchable=function(h){return arguments.length?(r=typeof h=="function"?h:Ft(!!h),f):r},f.on=function(){var h=o.on.apply(o,arguments);return h===o?f:h},f.clickDistance=function(h){return arguments.length?(p=(h=+h)*h,f):Math.sqrt(p)},f}var Gn=1e-12;function Ie(t){return((t=Math.exp(t))+1/t)/2}function Zn(t){return((t=Math.exp(t))-1/t)/2}function Vn(t){return((t=Math.exp(2*t))-1)/(t+1)}const Qn=function t(e,n,r){function i(o,s){var a=o[0],l=o[1],u=o[2],_=s[0],p=s[1],f=s[2],g=_-a,T=p-l,y=g*g+T*T,m,c;if(y<Gn)c=Math.log(f/u)/e,m=function(k){return[a+k*g,l+k*T,u*Math.exp(e*k*c)]};else{var v=Math.sqrt(y),D=(f*f-u*u+r*y)/(2*u*n*v),h=(f*f-u*u-r*y)/(2*f*n*v),N=Math.log(Math.sqrt(D*D+1)-D),x=Math.log(Math.sqrt(h*h+1)-h);c=(x-N)/e,m=function(k){var E=k*c,Y=Ie(N),L=u/(n*v)*(Y*Vn(e*E+N)-Zn(N));return[a+L*g,l+L*T,u*Y/Ie(e*E+N)]}}return m.duration=c*1e3*e/Math.SQRT2,m}return i.rho=function(o){var s=Math.max(.001,+o),a=s*s,l=a*a;return t(s,a,l)},i}(Math.SQRT2,2,4),ce=Math.PI,he=2*ce,mt=1e-6,Jn=he-mt;function nn(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function Kn(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return nn;const n=10**e;return function(r){this._+=r[0];for(let i=1,o=r.length;i<o;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class tr{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?nn:Kn(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,o,s){this._append`C${+e},${+n},${+r},${+i},${this._x1=+o},${this._y1=+s}`}arcTo(e,n,r,i,o){if(e=+e,n=+n,r=+r,i=+i,o=+o,o<0)throw new Error(`negative radius: ${o}`);let s=this._x1,a=this._y1,l=r-e,u=i-n,_=s-e,p=a-n,f=_*_+p*p;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(f>mt)if(!(Math.abs(p*l-u*_)>mt)||!o)this._append`L${this._x1=e},${this._y1=n}`;else{let g=r-s,T=i-a,y=l*l+u*u,m=g*g+T*T,c=Math.sqrt(y),v=Math.sqrt(f),D=o*Math.tan((ce-Math.acos((y+f-m)/(2*c*v)))/2),h=D/v,N=D/c;Math.abs(h-1)>mt&&this._append`L${e+h*_},${n+h*p}`,this._append`A${o},${o},0,0,${+(p*g>_*T)},${this._x1=e+N*l},${this._y1=n+N*u}`}}arc(e,n,r,i,o,s){if(e=+e,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let a=r*Math.cos(i),l=r*Math.sin(i),u=e+a,_=n+l,p=1^s,f=s?i-o:o-i;this._x1===null?this._append`M${u},${_}`:(Math.abs(this._x1-u)>mt||Math.abs(this._y1-_)>mt)&&this._append`L${u},${_}`,r&&(f<0&&(f=f%he+he),f>Jn?this._append`A${r},${r},0,1,${p},${e-a},${n-l}A${r},${r},0,1,${p},${this._x1=u},${this._y1=_}`:f>mt&&this._append`A${r},${r},0,${+(f>=ce)},${p},${this._x1=e+r*Math.cos(o)},${this._y1=n+r*Math.sin(o)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function rn(t,e){var n,r=1;t==null&&(t=0),e==null&&(e=0);function i(){var o,s=n.length,a,l=0,u=0;for(o=0;o<s;++o)a=n[o],l+=a.x,u+=a.y;for(l=(l/s-t)*r,u=(u/s-e)*r,o=0;o<s;++o)a=n[o],a.x-=l,a.y-=u}return i.initialize=function(o){n=o},i.x=function(o){return arguments.length?(t=+o,i):t},i.y=function(o){return arguments.length?(e=+o,i):e},i.strength=function(o){return arguments.length?(r=+o,i):r},i}function er(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return on(this.cover(e,n),e,n,t)}function on(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o=t._root,s={data:r},a=t._x0,l=t._y0,u=t._x1,_=t._y1,p,f,g,T,y,m,c,v;if(!o)return t._root=s,t;for(;o.length;)if((y=e>=(p=(a+u)/2))?a=p:u=p,(m=n>=(f=(l+_)/2))?l=f:_=f,i=o,!(o=o[c=m<<1|y]))return i[c]=s,t;if(g=+t._x.call(null,o.data),T=+t._y.call(null,o.data),e===g&&n===T)return s.next=o,i?i[c]=s:t._root=s,t;do i=i?i[c]=new Array(4):t._root=new Array(4),(y=e>=(p=(a+u)/2))?a=p:u=p,(m=n>=(f=(l+_)/2))?l=f:_=f;while((c=m<<1|y)===(v=(T>=f)<<1|g>=p));return i[v]=o,i[c]=s,t}function nr(t){var e,n,r=t.length,i,o,s=new Array(r),a=new Array(r),l=1/0,u=1/0,_=-1/0,p=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(o=+this._y.call(null,e))||(s[n]=i,a[n]=o,i<l&&(l=i),i>_&&(_=i),o<u&&(u=o),o>p&&(p=o));if(l>_||u>p)return this;for(this.cover(l,u).cover(_,p),n=0;n<r;++n)on(this,s[n],a[n],t[n]);return this}function rr(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var s=i-n||1,a=this._root,l,u;n>t||t>=i||r>e||e>=o;)switch(u=(e<r)<<1|t<n,l=new Array(4),l[u]=a,a=l,s*=2,u){case 0:i=n+s,o=r+s;break;case 1:n=i-s,o=r+s;break;case 2:i=n+s,r=o-s;break;case 3:n=i-s,r=o-s;break}this._root&&this._root.length&&(this._root=a)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function ir(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function or(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 X(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function sr(t,e,n){var r,i=this._x0,o=this._y0,s,a,l,u,_=this._x1,p=this._y1,f=[],g=this._root,T,y;for(g&&f.push(new X(g,i,o,_,p)),n==null?n=1/0:(i=t-n,o=e-n,_=t+n,p=e+n,n*=n);T=f.pop();)if(!(!(g=T.node)||(s=T.x0)>_||(a=T.y0)>p||(l=T.x1)<i||(u=T.y1)<o))if(g.length){var m=(s+l)/2,c=(a+u)/2;f.push(new X(g[3],m,c,l,u),new X(g[2],s,c,m,u),new X(g[1],m,a,l,c),new X(g[0],s,a,m,c)),(y=(e>=c)<<1|t>=m)&&(T=f[f.length-1],f[f.length-1]=f[f.length-1-y],f[f.length-1-y]=T)}else{var v=t-+this._x.call(null,g.data),D=e-+this._y.call(null,g.data),h=v*v+D*D;if(h<n){var N=Math.sqrt(n=h);i=t-N,o=e-N,_=t+N,p=e+N,r=g.data}}return r}function ar(t){if(isNaN(_=+this._x.call(null,t))||isNaN(p=+this._y.call(null,t)))return this;var e,n=this._root,r,i,o,s=this._x0,a=this._y0,l=this._x1,u=this._y1,_,p,f,g,T,y,m,c;if(!n)return this;if(n.length)for(;;){if((T=_>=(f=(s+l)/2))?s=f:l=f,(y=p>=(g=(a+u)/2))?a=g:u=g,e=n,!(n=n[m=y<<1|T]))return this;if(!n.length)break;(e[m+1&3]||e[m+2&3]||e[m+3&3])&&(r=e,c=m)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):e?(o?e[m]=o:delete e[m],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[c]=n:this._root=n),this):(this._root=o,this)}function ur(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function lr(){return this._root}function cr(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function hr(t){var e=[],n,r=this._root,i,o,s,a,l;for(r&&e.push(new X(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,o=n.x0,s=n.y0,a=n.x1,l=n.y1)&&r.length){var u=(o+a)/2,_=(s+l)/2;(i=r[3])&&e.push(new X(i,u,_,a,l)),(i=r[2])&&e.push(new X(i,o,_,u,l)),(i=r[1])&&e.push(new X(i,u,s,a,_)),(i=r[0])&&e.push(new X(i,o,s,u,_))}return this}function _r(t){var e=[],n=[],r;for(this._root&&e.push(new X(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var i=r.node;if(i.length){var o,s=r.x0,a=r.y0,l=r.x1,u=r.y1,_=(s+l)/2,p=(a+u)/2;(o=i[0])&&e.push(new X(o,s,a,_,p)),(o=i[1])&&e.push(new X(o,_,a,l,p)),(o=i[2])&&e.push(new X(o,s,p,_,u)),(o=i[3])&&e.push(new X(o,_,p,l,u))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function fr(t){return t[0]}function dr(t){return arguments.length?(this._x=t,this):this._x}function gr(t){return t[1]}function pr(t){return arguments.length?(this._y=t,this):this._y}function sn(t,e,n){var r=new ye(e??fr,n??gr,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function ye(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function je(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var G=sn.prototype=ye.prototype;G.copy=function(){var t=new ye(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=je(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var i=0;i<4;++i)(r=e.source[i])&&(r.length?n.push({source:r,target:e.target[i]=new Array(4)}):e.target[i]=je(r));return t};G.add=er;G.addAll=nr;G.cover=rr;G.data=ir;G.extent=or;G.find=sr;G.remove=ar;G.removeAll=ur;G.root=lr;G.size=cr;G.visit=hr;G.visitAfter=_r;G.x=dr;G.y=pr;function nt(t){return function(){return t}}function Nt(t){return(t()-.5)*1e-6}function mr(t){return t.index}function Ae(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function xe(t){var e=mr,n=p,r,i=nt(30),o,s,a,l,u,_=1;t==null&&(t=[]);function p(m){return 1/Math.min(a[m.source.index],a[m.target.index])}function f(m){for(var c=0,v=t.length;c<_;++c)for(var D=0,h,N,x,k,E,Y,L;D<v;++D)h=t[D],N=h.source,x=h.target,k=x.x+x.vx-N.x-N.vx||Nt(u),E=x.y+x.vy-N.y-N.vy||Nt(u),Y=Math.sqrt(k*k+E*E),Y=(Y-o[D])/Y*m*r[D],k*=Y,E*=Y,x.vx-=k*(L=l[D]),x.vy-=E*L,N.vx+=k*(L=1-L),N.vy+=E*L}function g(){if(s){var m,c=s.length,v=t.length,D=new Map(s.map((N,x)=>[e(N,x,s),N])),h;for(m=0,a=new Array(c);m<v;++m)h=t[m],h.index=m,typeof h.source!="object"&&(h.source=Ae(D,h.source)),typeof h.target!="object"&&(h.target=Ae(D,h.target)),a[h.source.index]=(a[h.source.index]||0)+1,a[h.target.index]=(a[h.target.index]||0)+1;for(m=0,l=new Array(v);m<v;++m)h=t[m],l[m]=a[h.source.index]/(a[h.source.index]+a[h.target.index]);r=new Array(v),T(),o=new Array(v),y()}}function T(){if(s)for(var m=0,c=t.length;m<c;++m)r[m]=+n(t[m],m,t)}function y(){if(s)for(var m=0,c=t.length;m<c;++m)o[m]=+i(t[m],m,t)}return f.initialize=function(m,c){s=m,u=c,g()},f.links=function(m){return arguments.length?(t=m,g(),f):t},f.id=function(m){return arguments.length?(e=m,f):e},f.iterations=function(m){return arguments.length?(_=+m,f):_},f.strength=function(m){return arguments.length?(n=typeof m=="function"?m:nt(+m),T(),f):n},f.distance=function(m){return arguments.length?(i=typeof m=="function"?m:nt(+m),y(),f):i},f}const yr=1664525,xr=1013904223,Oe=4294967296;function wr(){let t=1;return()=>(t=(yr*t+xr)%Oe)/Oe}function vr(t){return t.x}function br(t){return t.y}var Tr=10,Mr=Math.PI*(3-Math.sqrt(5));function we(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,s=.6,a=new Map,l=En(p),u=pe("tick","end"),_=wr();t==null&&(t=[]);function p(){f(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function f(y){var m,c=t.length,v;y===void 0&&(y=1);for(var D=0;D<y;++D)for(n+=(o-n)*i,a.forEach(function(h){h(n)}),m=0;m<c;++m)v=t[m],v.fx==null?v.x+=v.vx*=s:(v.x=v.fx,v.vx=0),v.fy==null?v.y+=v.vy*=s:(v.y=v.fy,v.vy=0);return e}function g(){for(var y=0,m=t.length,c;y<m;++y){if(c=t[y],c.index=y,c.fx!=null&&(c.x=c.fx),c.fy!=null&&(c.y=c.fy),isNaN(c.x)||isNaN(c.y)){var v=Tr*Math.sqrt(.5+y),D=y*Mr;c.x=v*Math.cos(D),c.y=v*Math.sin(D)}(isNaN(c.vx)||isNaN(c.vy))&&(c.vx=c.vy=0)}}function T(y){return y.initialize&&y.initialize(t,_),y}return g(),e={tick:f,restart:function(){return l.restart(p),e},stop:function(){return l.stop(),e},nodes:function(y){return arguments.length?(t=y,g(),a.forEach(T),e):t},alpha:function(y){return arguments.length?(n=+y,e):n},alphaMin:function(y){return arguments.length?(r=+y,e):r},alphaDecay:function(y){return arguments.length?(i=+y,e):+i},alphaTarget:function(y){return arguments.length?(o=+y,e):o},velocityDecay:function(y){return arguments.length?(s=1-y,e):1-s},randomSource:function(y){return arguments.length?(_=y,a.forEach(T),e):_},force:function(y,m){return arguments.length>1?(m==null?a.delete(y):a.set(y,T(m)),e):a.get(y)},find:function(y,m,c){var v=0,D=t.length,h,N,x,k,E;for(c==null?c=1/0:c*=c,v=0;v<D;++v)k=t[v],h=y-k.x,N=m-k.y,x=h*h+N*N,x<c&&(E=k,c=x);return E},on:function(y,m){return arguments.length>1?(u.on(y,m),e):u.on(y)}}}function ve(){var t,e,n,r,i=nt(-30),o,s=1,a=1/0,l=.81;function u(g){var T,y=t.length,m=sn(t,vr,br).visitAfter(p);for(r=g,T=0;T<y;++T)e=t[T],m.visit(f)}function _(){if(t){var g,T=t.length,y;for(o=new Array(T),g=0;g<T;++g)y=t[g],o[y.index]=+i(y,g,t)}}function p(g){var T=0,y,m,c=0,v,D,h;if(g.length){for(v=D=h=0;h<4;++h)(y=g[h])&&(m=Math.abs(y.value))&&(T+=y.value,c+=m,v+=m*y.x,D+=m*y.y);g.x=v/c,g.y=D/c}else{y=g,y.x=y.data.x,y.y=y.data.y;do T+=o[y.data.index];while(y=y.next)}g.value=T}function f(g,T,y,m){if(!g.value)return!0;var c=g.x-e.x,v=g.y-e.y,D=m-T,h=c*c+v*v;if(D*D/l<h)return h<a&&(c===0&&(c=Nt(n),h+=c*c),v===0&&(v=Nt(n),h+=v*v),h<s&&(h=Math.sqrt(s*h)),e.vx+=c*g.value*r/h,e.vy+=v*g.value*r/h),!0;if(g.length||h>=a)return;(g.data!==e||g.next)&&(c===0&&(c=Nt(n),h+=c*c),v===0&&(v=Nt(n),h+=v*v),h<s&&(h=Math.sqrt(s*h)));do g.data!==e&&(D=o[g.data.index]*r/h,e.vx+=c*D,e.vy+=v*D);while(g=g.next)}return u.initialize=function(g,T){t=g,n=T,_()},u.strength=function(g){return arguments.length?(i=typeof g=="function"?g:nt(+g),_(),u):i},u.distanceMin=function(g){return arguments.length?(s=g*g,u):Math.sqrt(s)},u.distanceMax=function(g){return arguments.length?(a=g*g,u):Math.sqrt(a)},u.theta=function(g){return arguments.length?(l=g*g,u):Math.sqrt(l)},u}function Nr(t){var e=nt(.1),n,r,i;typeof t!="function"&&(t=nt(t==null?0:+t));function o(a){for(var l=0,u=n.length,_;l<u;++l)_=n[l],_.vx+=(i[l]-_.x)*r[l]*a}function s(){if(n){var a,l=n.length;for(r=new Array(l),i=new Array(l),a=0;a<l;++a)r[a]=isNaN(i[a]=+t(n[a],a,n))?0:+e(n[a],a,n)}}return o.initialize=function(a){n=a,s()},o.strength=function(a){return arguments.length?(e=typeof a=="function"?a:nt(+a),s(),o):e},o.x=function(a){return arguments.length?(t=typeof a=="function"?a:nt(+a),s(),o):t},o}function Dr(t){var e=nt(.1),n,r,i;typeof t!="function"&&(t=nt(t==null?0:+t));function o(a){for(var l=0,u=n.length,_;l<u;++l)_=n[l],_.vy+=(i[l]-_.y)*r[l]*a}function s(){if(n){var a,l=n.length;for(r=new Array(l),i=new Array(l),a=0;a<l;++a)r[a]=isNaN(i[a]=+t(n[a],a,n))?0:+e(n[a],a,n)}}return o.initialize=function(a){n=a,s()},o.strength=function(a){return arguments.length?(e=typeof a=="function"?a:nt(+a),s(),o):e},o.y=function(a){return arguments.length?(t=typeof a=="function"?a:nt(+a),s(),o):t},o}function $r(t){var e=0,n=t.children,r=n&&n.length;if(!r)e=1;else for(;--r>=0;)e+=n[r].value;t.value=e}function Cr(){return this.eachAfter($r)}function kr(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this}function zr(t,e){for(var n=this,r=[n],i,o,s=-1;n=r.pop();)if(t.call(e,n,++s,this),i=n.children)for(o=i.length-1;o>=0;--o)r.push(i[o]);return this}function Sr(t,e){for(var n=this,r=[n],i=[],o,s,a,l=-1;n=r.pop();)if(i.push(n),o=n.children)for(s=0,a=o.length;s<a;++s)r.push(o[s]);for(;n=i.pop();)t.call(e,n,++l,this);return this}function Ur(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r}function Pr(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n})}function Er(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function Ir(t){for(var e=this,n=jr(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r}function jr(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;for(t=n.pop(),e=r.pop();t===e;)i=t,t=n.pop(),e=r.pop();return i}function Ar(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function Or(){return Array.from(this)}function Fr(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function Yr(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function*Br(){var t=this,e,n=[t],r,i,o;do for(e=n.reverse(),n=[];t=e.pop();)if(yield t,r=t.children)for(i=0,o=r.length;i<o;++i)n.push(r[i]);while(n.length)}function be(t,e){t instanceof Map?(t=[void 0,t],e===void 0&&(e=qr)):e===void 0&&(e=Rr);for(var n=new At(t),r,i=[n],o,s,a,l;r=i.pop();)if((s=e(r.data))&&(l=(s=Array.from(s)).length))for(r.children=s,a=l-1;a>=0;--a)i.push(o=s[a]=new At(s[a])),o.parent=r,o.depth=r.depth+1;return n.eachBefore(Wr)}function Lr(){return be(this).eachBefore(Hr)}function Rr(t){return t.children}function qr(t){return Array.isArray(t)?t[1]:null}function Hr(t){t.data.value!==void 0&&(t.value=t.data.value),t.data=t.data.data}function Wr(t){var e=0;do t.height=e;while((t=t.parent)&&t.height<++e)}function At(t){this.data=t,this.depth=this.height=0,this.parent=null}At.prototype=be.prototype={constructor:At,count:Cr,each:kr,eachAfter:Sr,eachBefore:zr,find:Ur,sum:Pr,sort:Er,path:Ir,ancestors:Ar,descendants:Or,leaves:Fr,links:Yr,copy:Lr,[Symbol.iterator]:Br};function Xr(t,e){return t.parent===e.parent?1:2}function ee(t){var e=t.children;return e?e[0]:t.t}function ne(t){var e=t.children;return e?e[e.length-1]:t.t}function Gr(t,e,n){var r=n/(e.i-t.i);e.c-=r,e.s+=n,t.c+=r,e.z+=n,e.m+=n}function Zr(t){for(var e=0,n=0,r=t.children,i=r.length,o;--i>=0;)o=r[i],o.z+=e,o.m+=e,e+=o.s+(n+=o.c)}function Vr(t,e,n){return t.a.parent===e.parent?t.a:n}function Bt(t,e){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e}Bt.prototype=Object.create(At.prototype);function Qr(t){for(var e=new Bt(t,0),n,r=[e],i,o,s,a;n=r.pop();)if(o=n._.children)for(n.children=new Array(a=o.length),s=a-1;s>=0;--s)r.push(i=n.children[s]=new Bt(o[s],s)),i.parent=n;return(e.parent=new Bt(null,0)).children=[e],e}function Jr(){var t=Xr,e=1,n=1,r=null;function i(u){var _=Qr(u);if(_.eachAfter(o),_.parent.m=-_.z,_.eachBefore(s),r)u.eachBefore(l);else{var p=u,f=u,g=u;u.eachBefore(function(v){v.x<p.x&&(p=v),v.x>f.x&&(f=v),v.depth>g.depth&&(g=v)});var T=p===f?1:t(p,f)/2,y=T-p.x,m=e/(f.x+T+y),c=n/(g.depth||1);u.eachBefore(function(v){v.x=(v.x+y)*m,v.y=v.depth*c})}return u}function o(u){var _=u.children,p=u.parent.children,f=u.i?p[u.i-1]:null;if(_){Zr(u);var g=(_[0].z+_[_.length-1].z)/2;f?(u.z=f.z+t(u._,f._),u.m=u.z-g):u.z=g}else f&&(u.z=f.z+t(u._,f._));u.parent.A=a(u,f,u.parent.A||p[0])}function s(u){u._.x=u.z+u.parent.m,u.m+=u.parent.m}function a(u,_,p){if(_){for(var f=u,g=u,T=_,y=f.parent.children[0],m=f.m,c=g.m,v=T.m,D=y.m,h;T=ne(T),f=ee(f),T&&f;)y=ee(y),g=ne(g),g.a=u,h=T.z+v-f.z-m+t(T._,f._),h>0&&(Gr(Vr(T,u,p),u,h),m+=h,c+=h),v+=T.m,m+=f.m,D+=y.m,c+=g.m;T&&!ne(g)&&(g.t=T,g.m+=v-c),f&&!ee(y)&&(y.t=f,y.m+=m-D,p=u)}return p}function l(u){u.x*=e,u.y=u.depth*n}return i.separation=function(u){return arguments.length?(t=u,i):t},i.size=function(u){return arguments.length?(r=!1,e=+u[0],n=+u[1],i):r?null:[e,n]},i.nodeSize=function(u){return arguments.length?(r=!0,e=+u[0],n=+u[1],i):r?[e,n]:null},i}function Kr(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],o=t[r],s;return o<i&&(s=n,n=r,r=s,s=i,i=o,o=s),t[n]=e.floor(i),t[r]=e.ceil(o),t}const re=new Date,ie=new Date;function H(t,e,n,r){function i(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return i.floor=o=>(t(o=new Date(+o)),o),i.ceil=o=>(t(o=new Date(o-1)),e(o,1),t(o),o),i.round=o=>{const s=i(o),a=i.ceil(o);return o-s<a-o?s:a},i.offset=(o,s)=>(e(o=new Date(+o),s==null?1:Math.floor(s)),o),i.range=(o,s,a)=>{const l=[];if(o=i.ceil(o),a=a==null?1:Math.floor(a),!(o<s)||!(a>0))return l;let u;do l.push(u=new Date(+o)),e(o,a),t(o);while(u<o&&o<s);return l},i.filter=o=>H(s=>{if(s>=s)for(;t(s),!o(s);)s.setTime(s-1)},(s,a)=>{if(s>=s)if(a<0)for(;++a<=0;)for(;e(s,-1),!o(s););else for(;--a>=0;)for(;e(s,1),!o(s););}),n&&(i.count=(o,s)=>(re.setTime(+o),ie.setTime(+s),t(re),t(ie),Math.floor(n(re,ie))),i.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?i.filter(r?s=>r(s)%o===0:s=>i.count(0,s)%o===0):i)),i}const qt=H(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);qt.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?H(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):qt);qt.range;const ct=1e3,ot=ct*60,ht=ot*60,_t=ht*24,Te=_t*7,Fe=_t*30,oe=_t*365,Dt=H(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*ct)},(t,e)=>(e-t)/ct,t=>t.getUTCSeconds());Dt.range;const Me=H(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*ct)},(t,e)=>{t.setTime(+t+e*ot)},(t,e)=>(e-t)/ot,t=>t.getMinutes());Me.range;const ti=H(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*ot)},(t,e)=>(e-t)/ot,t=>t.getUTCMinutes());ti.range;const Ne=H(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*ct-t.getMinutes()*ot)},(t,e)=>{t.setTime(+t+e*ht)},(t,e)=>(e-t)/ht,t=>t.getHours());Ne.range;const ei=H(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*ht)},(t,e)=>(e-t)/ht,t=>t.getUTCHours());ei.range;const Ot=H(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ot)/_t,t=>t.getDate()-1);Ot.range;const De=H(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/_t,t=>t.getUTCDate()-1);De.range;const ni=H(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/_t,t=>Math.floor(t/_t));ni.range;function xt(t){return H(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*ot)/Te)}const Qt=xt(0),Ht=xt(1),ri=xt(2),ii=xt(3),kt=xt(4),oi=xt(5),si=xt(6);Qt.range;Ht.range;ri.range;ii.range;kt.range;oi.range;si.range;function wt(t){return H(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/Te)}const an=wt(0),Wt=wt(1),ai=wt(2),ui=wt(3),zt=wt(4),li=wt(5),ci=wt(6);an.range;Wt.range;ai.range;ui.range;zt.range;li.range;ci.range;const $e=H(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());$e.range;const hi=H(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());hi.range;const ft=H(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());ft.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:H(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});ft.range;const yt=H(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());yt.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:H(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});yt.range;function _i(t,e,n,r,i,o){const s=[[Dt,1,ct],[Dt,5,5*ct],[Dt,15,15*ct],[Dt,30,30*ct],[o,1,ot],[o,5,5*ot],[o,15,15*ot],[o,30,30*ot],[i,1,ht],[i,3,3*ht],[i,6,6*ht],[i,12,12*ht],[r,1,_t],[r,2,2*_t],[n,1,Te],[e,1,Fe],[e,3,3*Fe],[t,1,oe]];function a(u,_,p){const f=_<u;f&&([u,_]=[_,u]);const g=p&&typeof p.range=="function"?p:l(u,_,p),T=g?g.range(u,+_+1):[];return f?T.reverse():T}function l(u,_,p){const f=Math.abs(_-u)/p,g=In(([,,m])=>m).right(s,f);if(g===s.length)return t.every(Pe(u/oe,_/oe,p));if(g===0)return qt.every(Math.max(Pe(u,_,p),1));const[T,y]=s[f/s[g-1][2]<s[g][2]/f?g-1:g];return T.every(y)}return[a,l]}const[fi,di]=_i(ft,$e,Qt,Ot,Ne,Me);function se(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function ae(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Ut(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function gi(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,o=t.days,s=t.shortDays,a=t.months,l=t.shortMonths,u=Pt(i),_=Et(i),p=Pt(o),f=Et(o),g=Pt(s),T=Et(s),y=Pt(a),m=Et(a),c=Pt(l),v=Et(l),D={a:C,A:z,b:S,B:U,c:null,d:He,e:He,f:Oi,g:Gi,G:Vi,H:Ii,I:ji,j:Ai,L:un,m:Fi,M:Yi,p:A,q:F,Q:Ge,s:Ze,S:Bi,u:Li,U:Ri,V:qi,w:Hi,W:Wi,x:null,X:null,y:Xi,Y:Zi,Z:Qi,"%":Xe},h={a:it,A:R,b:J,B:at,c:null,d:We,e:We,f:eo,g:ho,G:fo,H:Ji,I:Ki,j:to,L:cn,m:no,M:ro,p:K,q:ut,Q:Ge,s:Ze,S:io,u:oo,U:so,V:ao,w:uo,W:lo,x:null,X:null,y:co,Y:_o,Z:go,"%":Xe},N={a:L,A:Z,b:vt,B:bt,c:d,d:Re,e:Re,f:Si,g:Le,G:Be,H:qe,I:qe,j:$i,L:zi,m:Di,M:Ci,p:Y,q:Ni,Q:Pi,s:Ei,S:ki,u:wi,U:vi,V:bi,w:xi,W:Ti,x:$,X:w,y:Le,Y:Be,Z:Mi,"%":Ui};D.x=x(n,D),D.X=x(r,D),D.c=x(e,D),h.x=x(n,h),h.X=x(r,h),h.c=x(e,h);function x(M,P){return function(I){var b=[],V=-1,O=0,tt=M.length,et,dt,Ce;for(I instanceof Date||(I=new Date(+I));++V<tt;)M.charCodeAt(V)===37&&(b.push(M.slice(O,V)),(dt=Ye[et=M.charAt(++V)])!=null?et=M.charAt(++V):dt=et==="e"?" ":"0",(Ce=P[et])&&(et=Ce(I,dt)),b.push(et),O=V+1);return b.push(M.slice(O,V)),b.join("")}}function k(M,P){return function(I){var b=Ut(1900,void 0,1),V=E(b,M,I+="",0),O,tt;if(V!=I.length)return null;if("Q"in b)return new Date(b.Q);if("s"in b)return new Date(b.s*1e3+("L"in b?b.L:0));if(P&&!("Z"in b)&&(b.Z=0),"p"in b&&(b.H=b.H%12+b.p*12),b.m===void 0&&(b.m="q"in b?b.q:0),"V"in b){if(b.V<1||b.V>53)return null;"w"in b||(b.w=1),"Z"in b?(O=ae(Ut(b.y,0,1)),tt=O.getUTCDay(),O=tt>4||tt===0?Wt.ceil(O):Wt(O),O=De.offset(O,(b.V-1)*7),b.y=O.getUTCFullYear(),b.m=O.getUTCMonth(),b.d=O.getUTCDate()+(b.w+6)%7):(O=se(Ut(b.y,0,1)),tt=O.getDay(),O=tt>4||tt===0?Ht.ceil(O):Ht(O),O=Ot.offset(O,(b.V-1)*7),b.y=O.getFullYear(),b.m=O.getMonth(),b.d=O.getDate()+(b.w+6)%7)}else("W"in b||"U"in b)&&("w"in b||(b.w="u"in b?b.u%7:"W"in b?1:0),tt="Z"in b?ae(Ut(b.y,0,1)).getUTCDay():se(Ut(b.y,0,1)).getDay(),b.m=0,b.d="W"in b?(b.w+6)%7+b.W*7-(tt+5)%7:b.w+b.U*7-(tt+6)%7);return"Z"in b?(b.H+=b.Z/100|0,b.M+=b.Z%100,ae(b)):se(b)}}function E(M,P,I,b){for(var V=0,O=P.length,tt=I.length,et,dt;V<O;){if(b>=tt)return-1;if(et=P.charCodeAt(V++),et===37){if(et=P.charAt(V++),dt=N[et in Ye?P.charAt(V++):et],!dt||(b=dt(M,I,b))<0)return-1}else if(et!=I.charCodeAt(b++))return-1}return b}function Y(M,P,I){var b=u.exec(P.slice(I));return b?(M.p=_.get(b[0].toLowerCase()),I+b[0].length):-1}function L(M,P,I){var b=g.exec(P.slice(I));return b?(M.w=T.get(b[0].toLowerCase()),I+b[0].length):-1}function Z(M,P,I){var b=p.exec(P.slice(I));return b?(M.w=f.get(b[0].toLowerCase()),I+b[0].length):-1}function vt(M,P,I){var b=c.exec(P.slice(I));return b?(M.m=v.get(b[0].toLowerCase()),I+b[0].length):-1}function bt(M,P,I){var b=y.exec(P.slice(I));return b?(M.m=m.get(b[0].toLowerCase()),I+b[0].length):-1}function d(M,P,I){return E(M,e,P,I)}function $(M,P,I){return E(M,n,P,I)}function w(M,P,I){return E(M,r,P,I)}function C(M){return s[M.getDay()]}function z(M){return o[M.getDay()]}function S(M){return l[M.getMonth()]}function U(M){return a[M.getMonth()]}function A(M){return i[+(M.getHours()>=12)]}function F(M){return 1+~~(M.getMonth()/3)}function it(M){return s[M.getUTCDay()]}function R(M){return o[M.getUTCDay()]}function J(M){return l[M.getUTCMonth()]}function at(M){return a[M.getUTCMonth()]}function K(M){return i[+(M.getUTCHours()>=12)]}function ut(M){return 1+~~(M.getUTCMonth()/3)}return{format:function(M){var P=x(M+="",D);return P.toString=function(){return M},P},parse:function(M){var P=k(M+="",!1);return P.toString=function(){return M},P},utcFormat:function(M){var P=x(M+="",h);return P.toString=function(){return M},P},utcParse:function(M){var P=k(M+="",!0);return P.toString=function(){return M},P}}}var Ye={"-":"",_:" ",0:"0"},W=/^\s*\d+/,pi=/^%/,mi=/[\\^$*+?|[\]().{}]/g;function j(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o<n?new Array(n-o+1).join(e)+i:i)}function yi(t){return t.replace(mi,"\\$&")}function Pt(t){return new RegExp("^(?:"+t.map(yi).join("|")+")","i")}function Et(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function xi(t,e,n){var r=W.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function wi(t,e,n){var r=W.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function vi(t,e,n){var r=W.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function bi(t,e,n){var r=W.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Ti(t,e,n){var r=W.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Be(t,e,n){var r=W.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Le(t,e,n){var r=W.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Mi(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Ni(t,e,n){var r=W.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Di(t,e,n){var r=W.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Re(t,e,n){var r=W.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function $i(t,e,n){var r=W.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function qe(t,e,n){var r=W.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Ci(t,e,n){var r=W.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ki(t,e,n){var r=W.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function zi(t,e,n){var r=W.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Si(t,e,n){var r=W.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Ui(t,e,n){var r=pi.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Pi(t,e,n){var r=W.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Ei(t,e,n){var r=W.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function He(t,e){return j(t.getDate(),e,2)}function Ii(t,e){return j(t.getHours(),e,2)}function ji(t,e){return j(t.getHours()%12||12,e,2)}function Ai(t,e){return j(1+Ot.count(ft(t),t),e,3)}function un(t,e){return j(t.getMilliseconds(),e,3)}function Oi(t,e){return un(t,e)+"000"}function Fi(t,e){return j(t.getMonth()+1,e,2)}function Yi(t,e){return j(t.getMinutes(),e,2)}function Bi(t,e){return j(t.getSeconds(),e,2)}function Li(t){var e=t.getDay();return e===0?7:e}function Ri(t,e){return j(Qt.count(ft(t)-1,t),e,2)}function ln(t){var e=t.getDay();return e>=4||e===0?kt(t):kt.ceil(t)}function qi(t,e){return t=ln(t),j(kt.count(ft(t),t)+(ft(t).getDay()===4),e,2)}function Hi(t){return t.getDay()}function Wi(t,e){return j(Ht.count(ft(t)-1,t),e,2)}function Xi(t,e){return j(t.getFullYear()%100,e,2)}function Gi(t,e){return t=ln(t),j(t.getFullYear()%100,e,2)}function Zi(t,e){return j(t.getFullYear()%1e4,e,4)}function Vi(t,e){var n=t.getDay();return t=n>=4||n===0?kt(t):kt.ceil(t),j(t.getFullYear()%1e4,e,4)}function Qi(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+j(e/60|0,"0",2)+j(e%60,"0",2)}function We(t,e){return j(t.getUTCDate(),e,2)}function Ji(t,e){return j(t.getUTCHours(),e,2)}function Ki(t,e){return j(t.getUTCHours()%12||12,e,2)}function to(t,e){return j(1+De.count(yt(t),t),e,3)}function cn(t,e){return j(t.getUTCMilliseconds(),e,3)}function eo(t,e){return cn(t,e)+"000"}function no(t,e){return j(t.getUTCMonth()+1,e,2)}function ro(t,e){return j(t.getUTCMinutes(),e,2)}function io(t,e){return j(t.getUTCSeconds(),e,2)}function oo(t){var e=t.getUTCDay();return e===0?7:e}function so(t,e){return j(an.count(yt(t)-1,t),e,2)}function hn(t){var e=t.getUTCDay();return e>=4||e===0?zt(t):zt.ceil(t)}function ao(t,e){return t=hn(t),j(zt.count(yt(t),t)+(yt(t).getUTCDay()===4),e,2)}function uo(t){return t.getUTCDay()}function lo(t,e){return j(Wt.count(yt(t)-1,t),e,2)}function co(t,e){return j(t.getUTCFullYear()%100,e,2)}function ho(t,e){return t=hn(t),j(t.getUTCFullYear()%100,e,2)}function _o(t,e){return j(t.getUTCFullYear()%1e4,e,4)}function fo(t,e){var n=t.getUTCDay();return t=n>=4||n===0?zt(t):zt.ceil(t),j(t.getUTCFullYear()%1e4,e,4)}function go(){return"+0000"}function Xe(){return"%"}function Ge(t){return+t}function Ze(t){return Math.floor(+t/1e3)}var Mt,_n;po({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function po(t){return Mt=gi(t),_n=Mt.format,Mt.parse,Mt.utcFormat,Mt.utcParse,Mt}function mo(t){return new Date(t)}function yo(t){return t instanceof Date?+t:+new Date(+t)}function fn(t,e,n,r,i,o,s,a,l,u){var _=An(),p=_.invert,f=_.domain,g=u(".%L"),T=u(":%S"),y=u("%I:%M"),m=u("%I %p"),c=u("%a %d"),v=u("%b %d"),D=u("%B"),h=u("%Y");function N(x){return(l(x)<x?g:a(x)<x?T:s(x)<x?y:o(x)<x?m:r(x)<x?i(x)<x?c:v:n(x)<x?D:h)(x)}return _.invert=function(x){return new Date(p(x))},_.domain=function(x){return arguments.length?f(Array.from(x,yo)):f().map(mo)},_.ticks=function(x){var k=f();return t(k[0],k[k.length-1],x??10)},_.tickFormat=function(x,k){return k==null?N:u(k)},_.nice=function(x){var k=f();return(!x||typeof x.range!="function")&&(x=e(k[0],k[k.length-1],x??10)),x?f(Kr(k,x)):_},_.copy=function(){return On(_,fn(t,e,n,r,i,o,s,a,l,u))},_}function xo(){return jn.apply(fn(fi,di,ft,$e,Qt,Ot,Ne,Me,Dt,_n).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Ve(t){return function(){return t}}function wo(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new tr(e)}var vo=Array.prototype.slice;function bo(t){return t[0]}function To(t){return t[1]}class dn{constructor(e,n){this._context=e,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,n){switch(e=+e,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(e,n):this._context.moveTo(e,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,n,e,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,e,this._y0,e,n);break}}this._x0=e,this._y0=n}}function Mo(t){return new dn(t,!0)}function No(t){return new dn(t,!1)}function Do(t){return t.source}function $o(t){return t.target}function Co(t){let e=Do,n=$o,r=bo,i=To,o=null,s=null,a=wo(l);function l(){let u;const _=vo.call(arguments),p=e.apply(this,_),f=n.apply(this,_);if(o==null&&(s=t(u=a())),s.lineStart(),_[0]=p,s.point(+r.apply(this,_),+i.apply(this,_)),_[0]=f,s.point(+r.apply(this,_),+i.apply(this,_)),s.lineEnd(),u)return s=null,u+""||null}return l.source=function(u){return arguments.length?(e=u,l):e},l.target=function(u){return arguments.length?(n=u,l):n},l.x=function(u){return arguments.length?(r=typeof u=="function"?u:Ve(+u),l):r},l.y=function(u){return arguments.length?(i=typeof u=="function"?u:Ve(+u),l):i},l.context=function(u){return arguments.length?(u==null?o=s=null:s=t(o=u),l):o},l}const Yt=t=>()=>t;function ko(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function ue(t){t.stopImmediatePropagation()}function It(t){t.preventDefault(),t.stopImmediatePropagation()}function zo(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function So(){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 Qe(){return this.__zoom||Vt}function Uo(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Po(){return navigator.maxTouchPoints||"ontouchstart"in this}function Eo(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],s=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function $t(){var t=zo,e=So,n=Eo,r=Uo,i=Po,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Qn,u=pe("start","zoom","end"),_,p,f,g=500,T=150,y=0,m=10;function c(d){d.property("__zoom",Qe).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",Y).on("dblclick.zoom",L).filter(i).on("touchstart.zoom",Z).on("touchmove.zoom",vt).on("touchend.zoom touchcancel.zoom",bt).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}c.transform=function(d,$,w,C){var z=d.selection?d.selection():d;z.property("__zoom",Qe),d!==z?N(d,$,w,C):z.interrupt().each(function(){x(this,arguments).event(C).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},c.scaleBy=function(d,$,w,C){c.scaleTo(d,function(){var z=this.__zoom.k,S=typeof $=="function"?$.apply(this,arguments):$;return z*S},w,C)},c.scaleTo=function(d,$,w,C){c.transform(d,function(){var z=e.apply(this,arguments),S=this.__zoom,U=w==null?h(z):typeof w=="function"?w.apply(this,arguments):w,A=S.invert(U),F=typeof $=="function"?$.apply(this,arguments):$;return n(D(v(S,F),U,A),z,s)},w,C)},c.translateBy=function(d,$,w,C){c.transform(d,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof w=="function"?w.apply(this,arguments):w),e.apply(this,arguments),s)},null,C)},c.translateTo=function(d,$,w,C,z){c.transform(d,function(){var S=e.apply(this,arguments),U=this.__zoom,A=C==null?h(S):typeof C=="function"?C.apply(this,arguments):C;return n(Vt.translate(A[0],A[1]).scale(U.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof w=="function"?-w.apply(this,arguments):-w),S,s)},C,z)};function v(d,$){return $=Math.max(o[0],Math.min(o[1],$)),$===d.k?d:new Jt($,d.x,d.y)}function D(d,$,w){var C=$[0]-w[0]*d.k,z=$[1]-w[1]*d.k;return C===d.x&&z===d.y?d:new Jt(d.k,C,z)}function h(d){return[(+d[0][0]+ +d[1][0])/2,(+d[0][1]+ +d[1][1])/2]}function N(d,$,w,C){d.on("start.zoom",function(){x(this,arguments).event(C).start()}).on("interrupt.zoom end.zoom",function(){x(this,arguments).event(C).end()}).tween("zoom",function(){var z=this,S=arguments,U=x(z,S).event(C),A=e.apply(z,S),F=w==null?h(A):typeof w=="function"?w.apply(z,S):w,it=Math.max(A[1][0]-A[0][0],A[1][1]-A[0][1]),R=z.__zoom,J=typeof $=="function"?$.apply(z,S):$,at=l(R.invert(F).concat(it/R.k),J.invert(F).concat(it/J.k));return function(K){if(K===1)K=J;else{var ut=at(K),M=it/ut[2];K=new Jt(M,F[0]-ut[0]*M,F[1]-ut[1]*M)}U.zoom(null,K)}})}function x(d,$,w){return!w&&d.__zooming||new k(d,$)}function k(d,$){this.that=d,this.args=$,this.active=0,this.sourceEvent=null,this.extent=e.apply(d,$),this.taps=0}k.prototype={event:function(d){return d&&(this.sourceEvent=d),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(d,$){return this.mouse&&d!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&d!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&d!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(d){var $=B(this.that).datum();u.call(d,this.that,new ko(d,{sourceEvent:this.sourceEvent,target:c,type:d,transform:this.that.__zoom,dispatch:u}),$)}};function E(d,...$){if(!t.apply(this,arguments))return;var w=x(this,$).event(d),C=this.__zoom,z=Math.max(o[0],Math.min(o[1],C.k*Math.pow(2,r.apply(this,arguments)))),S=lt(d);if(w.wheel)(w.mouse[0][0]!==S[0]||w.mouse[0][1]!==S[1])&&(w.mouse[1]=C.invert(w.mouse[0]=S)),clearTimeout(w.wheel);else{if(C.k===z)return;w.mouse=[S,C.invert(S)],Kt(this),w.start()}It(d),w.wheel=setTimeout(U,T),w.zoom("mouse",n(D(v(C,z),w.mouse[0],w.mouse[1]),w.extent,s));function U(){w.wheel=null,w.end()}}function Y(d,...$){if(f||!t.apply(this,arguments))return;var w=d.currentTarget,C=x(this,$,!0).event(d),z=B(d.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",it,!0),S=lt(d,w),U=d.clientX,A=d.clientY;tn(d.view),ue(d),C.mouse=[S,this.__zoom.invert(S)],Kt(this),C.start();function F(R){if(It(R),!C.moved){var J=R.clientX-U,at=R.clientY-A;C.moved=J*J+at*at>y}C.event(R).zoom("mouse",n(D(C.that.__zoom,C.mouse[0]=lt(R,w),C.mouse[1]),C.extent,s))}function it(R){z.on("mousemove.zoom mouseup.zoom",null),en(R.view,C.moved),It(R),C.event(R).end()}}function L(d,...$){if(t.apply(this,arguments)){var w=this.__zoom,C=lt(d.changedTouches?d.changedTouches[0]:d,this),z=w.invert(C),S=w.k*(d.shiftKey?.5:2),U=n(D(v(w,S),C,z),e.apply(this,$),s);It(d),a>0?B(this).transition().duration(a).call(N,U,C,d):B(this).call(c.transform,U,C,d)}}function Z(d,...$){if(t.apply(this,arguments)){var w=d.touches,C=w.length,z=x(this,$,d.changedTouches.length===C).event(d),S,U,A,F;for(ue(d),U=0;U<C;++U)A=w[U],F=lt(A,this),F=[F,this.__zoom.invert(F),A.identifier],z.touch0?!z.touch1&&z.touch0[2]!==F[2]&&(z.touch1=F,z.taps=0):(z.touch0=F,S=!0,z.taps=1+!!_);_&&(_=clearTimeout(_)),S&&(z.taps<2&&(p=F[0],_=setTimeout(function(){_=null},g)),Kt(this),z.start())}}function vt(d,...$){if(this.__zooming){var w=x(this,$).event(d),C=d.changedTouches,z=C.length,S,U,A,F;for(It(d),S=0;S<z;++S)U=C[S],A=lt(U,this),w.touch0&&w.touch0[2]===U.identifier?w.touch0[0]=A:w.touch1&&w.touch1[2]===U.identifier&&(w.touch1[0]=A);if(U=w.that.__zoom,w.touch1){var it=w.touch0[0],R=w.touch0[1],J=w.touch1[0],at=w.touch1[1],K=(K=J[0]-it[0])*K+(K=J[1]-it[1])*K,ut=(ut=at[0]-R[0])*ut+(ut=at[1]-R[1])*ut;U=v(U,Math.sqrt(K/ut)),A=[(it[0]+J[0])/2,(it[1]+J[1])/2],F=[(R[0]+at[0])/2,(R[1]+at[1])/2]}else if(w.touch0)A=w.touch0[0],F=w.touch0[1];else return;w.zoom("touch",n(D(U,A,F),w.extent,s))}}function bt(d,...$){if(this.__zooming){var w=x(this,$).event(d),C=d.changedTouches,z=C.length,S,U;for(ue(d),f&&clearTimeout(f),f=setTimeout(function(){f=null},g),S=0;S<z;++S)U=C[S],w.touch0&&w.touch0[2]===U.identifier?delete w.touch0:w.touch1&&w.touch1[2]===U.identifier&&delete w.touch1;if(w.touch1&&!w.touch0&&(w.touch0=w.touch1,delete w.touch1),w.touch0)w.touch0[1]=this.__zoom.invert(w.touch0[0]);else if(w.end(),w.taps===2&&(U=lt(U,this),Math.hypot(p[0]-U[0],p[1]-U[1])<m)){var A=B(this).on("dblclick.zoom");A&&A.apply(this,arguments)}}}return c.wheelDelta=function(d){return arguments.length?(r=typeof d=="function"?d:Yt(+d),c):r},c.filter=function(d){return arguments.length?(t=typeof d=="function"?d:Yt(!!d),c):t},c.touchable=function(d){return arguments.length?(i=typeof d=="function"?d:Yt(!!d),c):i},c.extent=function(d){return arguments.length?(e=typeof d=="function"?d:Yt([[+d[0][0],+d[0][1]],[+d[1][0],+d[1][1]]]),c):e},c.scaleExtent=function(d){return arguments.length?(o[0]=+d[0],o[1]=+d[1],c):[o[0],o[1]]},c.translateExtent=function(d){return arguments.length?(s[0][0]=+d[0][0],s[1][0]=+d[1][0],s[0][1]=+d[0][1],s[1][1]=+d[1][1],c):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},c.constrain=function(d){return arguments.length?(n=d,c):n},c.duration=function(d){return arguments.length?(a=+d,c):a},c.interpolate=function(d){return arguments.length?(l=d,c):l},c.on=function(){var d=u.on.apply(u,arguments);return d===u?c:d},c.clickDistance=function(d){return arguments.length?(y=(d=+d)*d,c):Math.sqrt(y)},c.tapDistance=function(d){return arguments.length?(m=+d,c):m},c}class gn{constructor(e,n){this.items=e,this.id=JSON.stringify(e),this.support=n}}function Io(t,e){const n=[[]];for(const r of t){const i=n.map(o=>[...o,r]);n.push(...i)}return n.filter(r=>r.length==e)}function Xt(t,e){return e?e.every(n=>t.find(r=>JSON.stringify(r)==JSON.stringify(n))):!1}function jo(t,e){const n=[],r=t.size,i=[...t.values()];i.sort((o,s)=>o.id.localeCompare(s.id));for(let o=0;o<r;o++)for(let s=o+1;s<r;s++){const a=i[o].items,l=i[s].items;let u=a,_=l;if(e>2&&(u=a.slice(0,e-2),_=l.slice(0,e-2)),e<=2||Xt(u,_)){const p=[...new Set([...a,...l])],f=Io(p,e-1);Xt(i.map(g=>g.items),f)&&n.push(new gn(p,0))}}return n}function Ao(t,e,n){const r=t.reduce((o,s)=>o+s.count,0),i=new Map;return e.forEach(o=>{i.set(o.id,o)}),t.forEach(o=>{e.forEach(s=>{Xt(o.found_values,s.items)&&(s.support+=o.count)})}),i.forEach(o=>{o.support/=r,o.support<n&&i.delete(o.id)}),i}function Oo(t,e=1){let r=Fo(t).map(o=>new gn([o],0)),i=new Map([]);for(let o=1;r.length>0;o++){let s=Ao(t,r,e);i=new Map([...i,...s]),r=jo(s,o+1)}return i}function Fo(t){return[...new Set(t.flatMap(e=>e.found_values))].sort((e,n)=>e.localeCompare(n))}function Yo(t,e){let n=[];return t.forEach((r,i,o)=>{if(r.items.length>1){const s=pn(r.items,[],e,o);n=[...n,...s]}}),n=Ro(n),n=Lo(n),n}function Bo(t){return[...new Set(t.map(n=>JSON.stringify(n)))].map(n=>JSON.parse(n))}function Lo(t){const e=[];for(let n of t)for(let r of t)n!=r&&n.length!=r.length&&Xt(n,r)&&(n.length>r.length?e.push(t.indexOf(r)):e.push(t.indexOf(n)));return t.filter((n,r)=>!e.includes(r))}function Ro(t){let e=t.map(n=>[...n.left.items,...n.right.items]).map(n=>n.sort((r,i)=>r.localeCompare(i)));return Bo(e)}function pn(t,e,n,r){const i=[],o=r.get(JSON.stringify(t));for(let s of t)if(!e.some(a=>a.localeCompare(s))){const a=t.filter(f=>f!=s),l=[...e,s],u=r.get(JSON.stringify(a)),_=r.get(JSON.stringify(l)),p=qo(o,u);p>=n&&(i.push({left:u,right:_,confidence:p}),pn(a,l,n,r))}return i}function qo(t,e){return t.support/e.support}class Ho{classify(e){console.log(`implement me cant classify your list else. ${e}`)}}class Wo extends Ho{classify(e){if(e.length<=1)return[];const n=.1,r=.7,i=Oo(e,n);return Yo(i,r)}}const Je=t=>new Promise(e=>setTimeout(e,t)),pt=`
    BASE <https://db.antiquitatum-thesaurus.eu>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
    PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> 
    PREFIX owl: <http://www.w3.org/2002/07/owl#>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX at: <https://db.antiquitatum-thesaurus.eu/ontology/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX dcterms: <http://purl.org/dc/terms/> `;function mn(t,e,n=""){var i,o;let r="";return n&&((i=t.constituent_props)!=null&&i.includes(n))||((o=t.constituent_props)!=null&&o.length&&!t.negate_constituent_props?r=t.constituent_props.reduce((s,a,l)=>s+`?${e} ${a} ?${e}_${l}_xprop .
`,""):t.negate_constituent_props&&t.constituent_props.forEach((s,a)=>{r+=`FILTER NOT EXISTS { ?${e} ${s} ?${e}_${a}_xprop . }
`})),r}function _e(t,e,n="root"){let r="",i=`parent_${e}`;if(t.parent_params&&t.property_name){t.parent_params.parent_params&&(r=_e(t.parent_params,++e,i));const o=mn(t.parent_params,i,t.property_name);return`${r} 

            ?${i} a ${t.parent_params.class_name} .
            ?${i} ${t.property_name} ?${n}  .
            ${o}
        `}return""}const ns={async find_constituent_properties(t,e=null,n=0){var s;let r="";t.type_iri&&(r=`?root crm:P2_has_type ${t.type_iri} .`);const i=_e(t,0,"root"),o=`
      ${pt}
      SELECT ?properties (COUNT(*) as ?cnt) {
        SELECT (GROUP_CONCAT(DISTINCT ?property; separator=",") as ?properties)
          WHERE {
            ${i}
            ?root a ${t.class_name} . 
            ${r}
          
            ?root ?property ?o .
            FILTER(?property NOT IN (crm:P2_has_type, crm:P3_has_note, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>))
          } GROUP BY ?root
      } GROUP BY ?properties
        ORDER BY ?cnt`;try{const a=await gt(o,{signal:e});let l=Tt(a,{props:[{properties:"properties",count:"cnt"}]});if((s=l.props)!=null&&s.length){let u=[];for(let f of l.props)u.push({found_values:f.properties.split(","),count:Number(f.count)});const p=new Wo().classify(u);return p.length>1?p:[]}return[]}catch(a){if(n==0)return console.warn("Retrying find_constituent_properties"),await Je(6e3),await this.find_constituent_properties(t,e,1);throw console.log(o),a}},async get_properties_and_types_for(t={class_name:"crm:E24_Physical_Human-Made_Thing"},e=null,n=0){const r=_e(t,0,"root"),i=mn(t,"root");let o=`
            ${pt}
            
            SELECT ?property ?class ?dt WHERE {
                VALUES ?none {  UNDEF  }
                ?root a ${t.class_name} .

                ${r}
                

                ${i} 
                ?root ?property ?o . 
                OPTIONAL { 
                    ?o a ?class .
                }
                
                BIND(
                  IF(!BOUND(?class) && isLiteral(?o), datatype(?o), 
                  IF(!BOUND(?class) && isIRI(?o), 
                    IF(STRSTARTS(STR(?o), "https://d-nb.info/gnd/"), "<https://d-nb.info/gnd/[gnd_id]>", 
                    IF(STRSTARTS(STR(?o), "http://d-nb.info/gnd/"), "<http://d-nb.info/gnd/[gnd_id]>", 
                    IF(STRSTARTS(STR(?o), "http://vocab.getty.edu/aat/"), ?o, 
                    "<IRI>")))
                  , ?none)
                ) as ?dt) .
             
            } GROUP BY ?property ?class ?class_type ?dt 
            ORDER BY ?class ?dt 
        `;try{const s=await gt(o,{signal:e});return Tt(s,{graph:[{node:"class",edge:"property",leaf:"dt"}]})}catch(s){if(n==0)return console.warn("Retrying get_properties_and_types_for"),await Je(6e3),await this.get_properties_and_types_for(t,e,1);throw console.log(o),s}},async get_node(t,e=null){let n=`
      ${pt}

     SELECT ?object_id ?object_title ?thumbnail_urls (MIN(?begin_dating )as ?min_b_date) (MIN(?end_dating) as ?min_e_date)
     WHERE {
        VALUES ?object_id {<${t.object_iris.join("> <")}>}
        ?object_id crm:P1_is_identified_by ?object_title_iri .
        ?object_title_iri crm:P2_has_type <type/preferred_title> ;
                          crm:P190_has_symbolic_content ?object_title .
        OPTIONAL {  
          ?object_id crm:P138i_has_representation?vi . 

          ?vi at:has_sorting_index "1"^^xsd:int ;
              crm:P165i_is_incorporated_in ?image .

          ?image crm:P2_has_type <type/thumbnail> ;
                 crm:P1_is_identified_by / crm:P190_has_symbolic_content ?thumbnail_urls .
        }
        
     } GROUP BY ?object_id ?object_title ?thumbnail_urls 
    `;const r=await gt(n,{signal:e});return Tt(r,{node:{node_iri:"object_id",node_label:"object_title",node_img:"thumbnail_urls"}})},relationship_queries:{depicts:`
      ?root_ids crm:P01i_is_domain_of ?depicts .
      ?depicts a crm:PC62_depicts .
      ?depicts crm:P02_has_range ?object_id .
    `,is_depicted_by:`
      ?object_id crm:P01i_is_domain_of ?depicts .
      ?depicts a crm:PC62_depicts .
      ?depicts crm:P02_has_range ?root_ids . 
    `,is_copy_after:`?object_id crm:P02i_is_range_of ?use_object . 
                    ?use_object crm:P01_has_domain/crm:P108_has_produced ?root_ids .
                    ?use_object crm:P16.1_mode_of_use <type/original> .`,has_copy:`?root_ids crm:P02i_is_range_of ?use_object . 
               ?use_object crm:P01_has_domain/crm:P108_has_produced ?object_id .
               ?use_object crm:P16.1_mode_of_use <type/original> .`,based_on:`?object_id crm:P02i_is_range_of ?use_object . 
               ?use_object crm:P01_has_domain/crm:P108_has_produced ?root_ids .
               ?use_object crm:P16.1_mode_of_use <type/precursor> .`,precursor_of:`?root_ids  crm:P02i_is_range_of ?use_object . 
                   ?use_object crm:P01_has_domain/crm:P108_has_produced ?object_id .
                   ?use_object crm:P16.1_mode_of_use <type/precursor> .`,is_duplicate_of:`?root_ids crm:P01i_is_domain_of ?rel.
                      ?rel crm:P130.1_kind_of_similarity <type/1641767> .
                      ?rel crm:P02_has_range ?object_id .`,is_version_of:`?rel crm:P130.1_kind_of_similarity <type/object_version> .
                      ?rel crm:P01_has_domain ?root_ids .
                      ?rel crm:P02_has_range ?object_id .`,has_version:`?rel crm:P130.1_kind_of_similarity <type/object_version> .
                      ?rel crm:P01_has_domain ?object_id .
                      ?rel crm:P02_has_range ?root_ids .`},async has_relationships(t,e=null){let n=`
    ${pt}
    
    ASK {
      VALUES ?root_ids {<object/${t}>}
      {
        ${Object.values(this.relationship_queries).join("} UNION {")}
      }
    }`;return{exists:(await gt(n,{signal:e})).boolean||!1}},hierarchy_relation:`UNION  {
    # treated differently because its hirachy and not relationship per se
    BIND("ist Teil von" as ?relation_type )
    ?root_ids at:is_part_of_source_work ?object_id .
  }`,async get_all_relations(t=null,e=!1){let n="";e&&(n=this.hierarchy_relation);let r=`
      ${pt}

      SELECT (?root_ids as ?source) (?object_id as ?target) (?relation_type as ?label)
      WHERE {
        { 
          BIND("bildet ab" as ?relation_type )
          ${this.relationship_queries.depicts} 

        } UNION { 
          BIND("ist abgebildet in" as ?relation_type )
          ${this.relationship_queries.is_depicted_by} 

        } UNION {
          BIND("ist Kopie nach" as ?relation_type )
          ${this.relationship_queries.is_copy_after}

        } UNION {
          BIND("hat Kopie" as ?relation_type )
          ${this.relationship_queries.has_copy}

        } UNION {
          BIND("basiert auf" as ?relation_type )
          ${this.relationship_queries.based_on}

        } UNION {
          BIND("ist Vorbereitend für" as ?relation_type )
          ${this.relationship_queries.precursor_of}
          
        } UNION {
          BIND("ist Duplikat von" as ?relation_type )
          ${this.relationship_queries.is_duplicate_of}

        } UNION {
          BIND("ist Zustand von" as ?relation_type )
          ${this.relationship_queries.is_version_of}

        }UNION {
          BIND("hat Zustand" as ?relation_type )
          ${this.relationship_queries.has_version}

        } ${n}

      } 
      ORDER BY ?source ?target
    `;const i=await gt(r,{signal:t});return Tt(i,{links:[{source:"source",target:"target",label:"label"}]})},async get_all_nodes(t=null){let e=`
    ${pt}

    SELECT DISTINCT ?object_id ?object_title ?img ?date_from ?date_to 
      WHERE {
        ?object_id a crm:E24_Physical_Human-Made_Thing .
        ?object_id crm:P1_is_identified_by ?object_title_iri .
        ?object_title_iri crm:P2_has_type <type/preferred_title> ;
                    crm:P190_has_symbolic_content ?object_title .
          
        OPTIONAL {  
            ?object_id crm:P138i_has_representation ?vi . 
            ?vi at:has_sorting_index "1"^^xsd:int ;
                crm:P165i_is_incorporated_in ?image .
            ?image crm:P2_has_type <type/thumbnail> ;
                  crm:P1_is_identified_by ?image_id . 
            ?image_id crm:P190_has_symbolic_content ?img .
        }
    
        OPTIONAL {
            ?object_id crm:P108i_was_produced_by / crm:P4_has_time-span ?time . 
            ?time crm:P82a_begin_of_the_beginning ?date_from ;
                    crm:P82b_end_of_the_end ?date_to .
        } 
      }`;const n=await gt(e,{signal:t});return Tt(n,{nodes:[{node_iri:"object_id",node_label:"object_title",dating:{from:"date_from",to:"date_to"},node_img:"img"}]})},async get_relations_for(t,e=null,n=!0){let r="";n&&(r=this.hierarchy_relation);let i=`
      ${pt}

      SELECT ?root_ids ?object_id ?object_title ?relation_type ?thumbnail_urls 
      WHERE {
        VALUES ?root_ids {<${t.object_iris.join("> <")}>}
        { 
          BIND("bildet ab" as ?relation_type )
          ${this.relationship_queries.depicts} 

        } UNION { 
          BIND("ist abgebildet in" as ?relation_type )
          ${this.relationship_queries.is_depicted_by} 

        } UNION {
          BIND("ist Kopie nach" as ?relation_type )
          ${this.relationship_queries.is_copy_after}

        } UNION {
          BIND("hat Kopie" as ?relation_type )
          ${this.relationship_queries.has_copy}

        } UNION {
          BIND("basiert auf" as ?relation_type )
          ${this.relationship_queries.based_on}

        } UNION {
          BIND("ist Vorbereitend für" as ?relation_type )
          ${this.relationship_queries.precursor_of}
          
        } UNION {
          BIND("ist Duplikat von" as ?relation_type )
          ${this.relationship_queries.is_duplicate_of}

        }  ${r}

        ?object_id crm:P1_is_identified_by ?object_title_iri .
        ?object_title_iri crm:P2_has_type <type/preferred_title> ;
                          crm:P190_has_symbolic_content ?object_title .
        OPTIONAL {  
          ?object_id crm:P138i_has_representation ?vi . 

          ?vi at:has_sorting_index "1"^^xsd:int ;
              crm:P165i_is_incorporated_in ?image .

          ?image crm:P2_has_type <type/thumbnail> ;
                 crm:P1_is_identified_by ?image_id . 

          ?image_id crm:P190_has_symbolic_content ?thumbnail_urls .
        }


      } 
      GROUP BY ?root_ids ?object_id ?object_title ?relation_type ?thumbnail_urls
      ORDER BY ?object_title
    `;const o=await gt(i,{signal:e});return Tt(o,{graph:[{root_node:"root_ids",node_iri:"object_id",node_label:"object_title",edge_label:"relation_type",node_img:"thumbnail_urls"}]})}};class rs{constructor(e){this.parent_params=e}}class Xo{constructor(e,n,r,i){q(this,"children",[]);q(this,"depth",0);this.node_label=e,this.type=n,this.id=r,this.search_params=i}}class is{constructor(){this._init()}set_deepest_depth(e){e>this.deepest_depth&&(this.deepest_depth=e)}_init(){this.nodes_visited=0,this.nodes_allready_finished=0,this.circles_detected=0,this.nodes_newly_finished=0,this.deepest_depth=0,this.detected_nodes=1}reset(){this._init()}}class os{constructor(e,n,r){this.tree_search=e,this.observer=n,this.ac=r}build_tree(e){return this.tree_search.create_tree(e,this.observer,this.ac.signal)}async build_network(e){return this.tree_search.create_network(e,this.observer,this.ac.signal)}}class ss{create_node(e,n){return new Xo(e.node_label,e.type,e.id,n)}attach_children(e,n){return e.children=n,e}}class as{async get_children(e,n){return console.error("abstract function get_children cannot be used without proper implementation",e),[]}async get_node(e,n){return console.error("abstract function get_node cannot be used without proper implementation",e),[]}}class us{constructor(){q(this,"visited_nodes",[])}get_id(e){return e.id}check_visited_nodes(e){return this.visited_nodes.includes(e.id)?!0:(this.visited_nodes.push(e.id),!1)}is_loop(e){return this.check_visited_nodes(e)}}class yn{constructor(e,n){this.node_factory=e,this.querie_interface=n}async fetch_node(e,n){const r=await this.querie_interface.get_node(e,n);return r&&r.node?this.node_factory.create_node(r.node,e):null}async fetch_children(e,n){let r=[];const i=await this.querie_interface.get_children(e,n);if(i&&i.graph)for(let o of i.graph){let s=this.node_factory.create_node(o,e);s&&r.push(s)}return r}}class ls extends yn{add_to_network(e,n,r){n.id in e?e[n].push(r):e[n.id]=[r]}build_inverted_index(e){const n={};for(let r=0;r<e.length;r++){let i=e[r];this.add_to_inverted_index(n,i.source,r),this.add_to_inverted_index(n,i.target,r)}return n}add_to_inverted_index(e,n,r){const i=n.split("/").slice(-1)[0];i in e?e[i].add(r):e[i]=new Set([r])}async create_networks(e){console.info("fetch fresh network data");const{links:n}=await this.querie_interface.get_all_relations(e);let{nodes:r}=await this.querie_interface.get_all_nodes(e);console.info("create networks"),r=Object.fromEntries(r.map(s=>[s.node_iri,this.node_factory.create_node(s)]));const i=this.build_inverted_index(n),o={nodes:r,links:n,inverted_idx:i};return console.info("finished creating networks"),o}async create_network(e,n,r){return await this.fetch_all_relations(r)}}var Gt;class cs extends yn{constructor(n,r,i){super(n,r);St(this,Gt,200);q(this,"visited_nodes",[]);q(this,"finished_nodes",[]);this.loop_detection=i}async create_tree(n,r,i){if(this.finished_nodes.includes(n.id)&&(r.nodes_allready_finished+=1),this.loop_detection.is_loop(n)){r.circles_detected+=1,n.type="circle";return}if(r.nodes_visited=this.loop_detection.visited_nodes.length,n.search_params!=null){console.info(`expanding: ${n.id}`);const o=await this.fetch_children(n.search_params,i);r.detected_nodes+=o.length,n=await this.node_factory.attach_children(n,o);for(let s of n.children)s.depth=n.depth+1,r.set_deepest_depth(s.depth),Se(this,Gt)>=s.depth&&await this.create_tree(s,r,i)}return this.finished_nodes.push(n.id),r.nodes_newly_finished=this.finished_nodes.length,console.info("return node"),n}}Gt=new WeakMap;function Go(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function Ke(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function Zo(t,e){const n=Go(t);if(isNaN(e))return Ke(t,NaN);if(!e)return n;const r=n.getDate(),i=Ke(t,n.getTime());i.setMonth(n.getMonth()+e+1,0);const o=i.getDate();return r>=o?i:(n.setFullYear(i.getFullYear(),i.getMonth(),r),n)}function xn(t,e){return Zo(t,e*12)}function Vo(t,e){return xn(t,-e)}class wn{constructor(e=""){this.id_attr_base=e}get_id_attribute(e){return`${this.id_attr_base}-${e}`}}var st,fe,vn,de,bn;class hs extends wn{constructor(n,{height:r,width:i},o="rect",s="rect_group"){super(s);St(this,st);this.color_schema=n,this.height=r,this.width=i,this.shape=o}setup_nodes(n){return n.append("g").attr("cursor","pointer")}draw_nodes(n,r,i,o,s){return n.selectAll("g").data(r,l=>l.id).join(l=>(l=l.append("g").on("click",(u,_)=>s(u,_)),l=Q(this,st,fe).call(this,l,{x:o.x0,y:o.y0}),Q(this,st,vn).call(this,l),Q(this,st,bn).call(this,l),l),l=>l,l=>(l=l.transition(i),l=Q(this,st,fe).call(this,l,{x:o.x,y:o.y}),l.remove())).transition(i).attr("transform",l=>Q(this,st,de).call(this,l.x,l.y,l.data.depth)).end()}determine_color(n){return this.color_schema[n.type]}get_fill_color(){return this.color_schema.fill?this.color_schema.fill:"white"}calculate_x_coordinate(n,r){return n+r*this.width}calculate_y_coordinate(n){return n-this.height/2}get_label_translate(n,r,i){return n=i==0?n:n+i*this.width,`translate(${n},${r})`}}st=new WeakSet,fe=function(n,r=null){return n.attr("transform",i=>{const{x:o,y:s}=r||i;return Q(this,st,de).call(this,o,s,i.data.depth)})},vn=function(n){return n.append(this.shape).attr("stroke",r=>this.determine_color(r.data)).attr("id",(r,i)=>this.get_id_attribute(i)).attr("stroke-linejoin","round").attr("stroke-width",3).attr("fill",()=>this.get_fill_color()).attr("width",this.width).attr("height",this.height)},de=function(n,r,i){const o=this.calculate_x_coordinate(r,i),s=this.calculate_y_coordinate(n);return`translate(${o}, ${s})`},bn=function(n){return n.append("text","rect").attr("stroke","white").attr("paint-order","stroke").attr("dy","1.2em").attr("x","6").text(r=>r.data.node_label)};var Zt,Tn;class _s extends wn{constructor({opacity:n,width:r,color:i},o=200,s="path"){super(s);St(this,Zt);this.stroke_opacity=n,this.stroke_width=r,this.stroke_color=i,this.label_space=o}calculate_path_dimension(n,r,i){let{x:o,y:s,depth:a}=n,{x:l,y:u}=r,_=i*(a+1),p=s+_,f=u+_-this.label_space;return`
        M${p},${o}
        L${f},${l}
        h${this.label_space}`}calculate_label_offset(n){let r=this.get_id_attribute(n);const i=B(`path#${r}`).node();return i?i.getTotalLength()-this.label_space:null}setup_edges(n){return n.append("g").attr("cursor","pointer")}async draw_edges(n,r,i,o,s,a){const l={x:s.x0,y:s.y0,depth:s.depth},u=n.selectAll("g").data(r,p=>p.target.id).join(p=>(p=p.append("g").on("click",(f,g)=>a(f,g)),p.append("path").attr("d",()=>this.calculate_path_dimension(l,l,i)).attr("fill","none").attr("stroke",this.stroke_color).attr("stroke-opacity",this.stroke_opacity).attr("stroke-width",this.stroke_width).attr("id",f=>this.get_id_attribute(f.target.id)),Q(this,Zt,Tn).call(this,p),p),p=>p,p=>p.transition(o).remove().selectAll("path").attr("d",()=>this.calculate_path_dimension(s,s,i)));return await u.transition(o).selectAll("path").attr("d",p=>this.calculate_path_dimension(p.source,p.target,i)).end(),u.selectAll("text textPath").attr("startOffset",p=>this.calculate_label_offset(p.target.id)),u}}Zt=new WeakSet,Tn=function(n){return n.append("text").append("textPath").attr("startOffset",i=>this.calculate_label_offset(i.target.id)).attr("xlink:href",i=>`#${this.get_id_attribute(i.target.id)}`).text(i=>i.target.data.edge_label)};class fs{constructor(e={width:"100%",height:"80vh"}){this.viewport=e,this.init_viewbox_values()}get_viewport_width(){return this.viewport.width}get_viewport_height(){return this.viewport.height}set_viewport(e){this.viewport=e}init_viewbox_values(){this.smallest_y=1/0,this.smallest_x=1/0,this.largest_y=-this.smallest_y,this.largest_x=-this.smallest_y,this.min_x=0,this.min_y=0,this.view_box_width=this.largest_x,this.view_box_heigth=this.largest_y}override_computed_viewbox_values({x:e,y:n,width:r,height:i}){this.view_box_width=r,this.view_box_heigth=i,this.min_x=e,this.min_y=n}adjust_viewbox(e=0,n=0,r=0){this.min_y=this.smallest_y-r,this.min_x=this.smallest_x-e,this.view_box_width=this.largest_x+n,this.view_box_heigth=this.largest_y-this.smallest_y+2*r}get_viewbox_settings(){return[this.min_x,this.min_y,this.view_box_width,this.view_box_heigth]}get_viewbox_width(){return this.view_box_width}get_viewbox_height(){return this.view_box_heigth}_calculate_viewbox_size(e,n=!0){this.init_viewbox_values();const r=i=>{let o,s;n?(o=i.y,s=i.x):(o=i.x,s=i.y),s>this.largest_y&&(this.largest_y=s),s<this.smallest_y&&(this.smallest_y=s),o>this.largest_x&&(this.largest_x=o),o<this.smallest_x&&(this.smallest_x=o)};return typeof e.eachBefore=="function"?e.eachBefore(r):e.forEach(r),this.min_x=this.smallest_x,this.min_y=this.smallest_y,this.view_box_width=this.largest_x,this.view_box_heigth=this.largest_y,this.get_viewbox_settings()}}class ds{constructor(e=null){q(this,"zoom",null);q(this,"scale",null);this.scale=e,e?this.zoom=$t().scaleExtent(e).on("zoom",this.handle_zoom):this.zoom=$t().on("zoom",this.handle_zoom)}handle_zoom(e){Rt("svg > g").attr("transform",e.transform)}center_view(e="svg"){return B(e).transition().call(this.zoom.transform,Vt).end()}create_zoom(e=null){let n=this.handle_zoom;e&&(n=e),this.scale?this.zoom=$t().scaleExtent(this.scale).on("zoom",n):this.zoom=$t().on("zoom",n)}activateZoom(e="svg"){B(e).call(this.zoom)}get_zoom_max_extent(){return this.zoom.scaleExtent()[1]}get_zoom_min_extent(){return this.zoom.scaleExtent()[0]}async zoom_in(e=1.5,n="svg"){return B(n).transition().call(this.zoom.scaleBy,e).end()}async zoom_out(e=.75,n="svg"){return B(n).transition().call(this.zoom.scaleBy,e).end()}zoom_to(e,n="svg"){B(n).transition().call(this.zoom.scaleTo,e)}get_current_zoom_scale(e="svg"){return Number(Fn(B(e).node()).k).toFixed(2)}attach_zoom_handler(e){this.zoom.on("end",e)}}class Mn{constructor(e){q(this,"svg",null);q(this,"label_map",{"ist abgebildet in":"depiction","bildet ab":"depiction","ist Kopie nach":"copy","hat Kopie":"copy","basiert auf":"precursor","ist Vorbereitend für":"precursor","ist Duplikat von":"duplicate","ist Zustand von":"version","hat Zustand":"version"});this.layout=e,this.max_depth=0}_create_root_svg(e){return B(e).append("svg").attr("width",this.layout.get_viewport_width()).attr("height",this.layout.get_viewport_height()).attr("viewBox",this.layout.get_viewbox_settings()).attr("style","max-width: 100%; height: auto; height: intrinsic;").attr("overflow","scroll").attr("font-family","sans-serif").attr("font-size",10)}clear_canvas(){Rt("svg").remove()}get_zoom_handler(){return e=>Rt("svg > g").attr("transform",e.transform)}_add_click_event(e){return e.on("click",(n,r)=>{n.stopPropagation();const i=new CustomEvent("nodeClicked",{bubbles:!0,detail:{node:r}});n.target.dispatchEvent(i)})}}var rt,Nn,Dn,$n,Cn,ge;class gs extends Mn{constructor(n,r,i){super(n);St(this,rt);q(this,"node_space",1.75);q(this,"root",null);q(this,"gNodes",null);q(this,"gEdges",null);q(this,"fully_expand",!0);q(this,"zoom_scale",0);this.node_handler=r,this.edge_handler=i}async draw_tree(n,r){return console.info("drawing"),this.clear_canvas(),this.root=be(n),Q(this,rt,Nn).call(this),Q(this,rt,Dn).call(this),Q(this,rt,ge).call(this),console.info("prepared adding nodes"),this.svg=this._create_root_svg(r),this.gNodes=this.node_handler.setup_nodes(this.svg),this.gEdges=this.edge_handler.setup_edges(this.svg),this.update_tree(this.root)}update_tree(n){console.info("update graph");const r=1e3;Q(this,rt,ge).call(this);const i=this.svg.transition().duration(r).attr("viewBox",this.layout.get_viewbox_settings()).tween("resize",window.ResizeObserver?null:()=>()=>this.svg.dispatch("toggle")),o=this.node_handler.draw_nodes(this.gNodes,this.root.descendants(),i,n,(s,a)=>{if(s!=null&&s.altKey||s.button!=0){s.stopPropagation();const l=new CustomEvent("nodeClicked",{bubbles:!0,detail:{node:a}});s.target.dispatchEvent(l)}else a&&(s.stopPropagation(),this.toggle_collapse_node(a),this.update_tree(a))});return this.edge_handler.draw_edges(this.gEdges,this.root.links(),this.node_handler.width,i,n,(s,a)=>{if(a){s.stopPropagation();const l=new CustomEvent("edgeClicked",{bubbles:!0,detail:{node:a.target}});s.target.dispatchEvent(l)}}),Q(this,rt,$n).call(this),o}toggle_collapse_node(n){n._children||(n._children=n.children),n.children=n.children?null:n._children}collapse_all(){return this.root?(this.root.eachAfter(n=>n.children=null),this.fully_expand=!1,this.update_tree(this.root)):null}is_fully_expand(){let n=!0;return this.root&&this.root.eachAfter(r=>{r.children==null&&(n=!1)}),n}expand_next_level(){return this.root.leaves().forEach(r=>{r._children&&r.children==null&&(r.children=r._children)}),this.fully_expand=this.is_fully_expand(),this.update_tree(this.root)}collapse_last_lvl(){let n=this.root.leaves();const r=Math.max(...n.map(i=>i.depth));r>0&&(this.root.eachAfter(i=>{i.depth==r-1&&(i.children=null)}),this.update_tree(this.root)),console.info("Nothing more to collapse")}collapse_all_but(n){this.expand_all_without_update();let r=[];if(this.root){for(let i of n){let o=this.root.find(s=>s.data.id==i);this.root==o.parent?r.push(o):r.push(...o.parent.ancestors())}this.root.eachAfter(i=>{i.parent==null?i.children=i.children.filter(o=>r.includes(o)):r.includes(i)||(i.children=null)}),this.fully_expand=!1,this.update_tree(this.root)}}expand_all_without_update(){this.root.children=this.root._children,this.root.each(n=>n.children=n._children)}expand_all(){this.expand_all_without_update(),this.update_tree(this.root)}}rt=new WeakSet,Nn=function(){this.root.x0=0,this.root.y0=0},Dn=function(){this.root.descendants().forEach((n,r)=>{n.id=r,n._children=n.children})},$n=function(){this.root.eachBefore(n=>{n.x0=n.x,n.y0=n.y})},Cn=function(){const n=Jr().nodeSize([this.node_handler.height,this.node_handler.width*this.node_space]);n.separation((r,i)=>r.parent==i.parent?2:8),n(this.root)},ge=function(n=10){Q(this,rt,Cn).call(this),this.layout._calculate_viewbox_size(this.root),this.max_depth=Yn(this.root,i=>i.depth);let r=this.node_handler.width+(this.max_depth+1)*this.edge_handler.label_space;this.layout.adjust_viewbox(n,r,this.node_handler.height)};class kn extends Mn{constructor(n,r,i={width:100,height:100}){super(n);q(this,"zoom",null);this.color_schema=r,this.node_dimensions=i}zoom_to_full_extent(){if(this.zoom){const n=this.svg.select("g.nodes").node().getBBox(),r=this.svg.node().getBoundingClientRect(),i=r.width,o=r.height,s=Math.max(n.width/i,n.height/o),a=Math.min(3,.8/s),l=n.x-n.x*a,u=n.y-n.y*a,_=(n.width/a-n.width)/2,p=(n.height/a-n.height)/2;this.svg.transition().duration(750).call(this.zoom.transform,Vt.translate(l,u).scale(a).translate(_+50/a,p))}else console.log("no zoom")}_calculate_node_weight(n,r){const i={};for(let o of r)i[o.target.id]||(i[o.target.id]=0),i[o.target.id]++;n.map(o=>(o.weight=i[o.id],o))}_create_simulation(n,r){return we(n).velocityDecay(.6).force("link",xe(r).id(i=>i.id).distance(()=>(this.node_dimensions.width+this.node_dimensions.height)*3)).force("charge",ve().strength(-4e3)).force("center",rn(this.layout.view_box_width/2,this.layout.view_box_heigth/2)).tick(100)}_create_nodes(n,r="node"){return this.svg.append("g").attr("class","nodes").selectAll(`.${r}`).data(n).join("g").attr("class",r).attr("cursor","pointer")}_create_node_labels(n){n.append("title").text(r=>r.node_label)}_add_click_event(n){return n.on("click",(r,i)=>{r.stopPropagation();const o=new CustomEvent("nodeClicked",{bubbles:!0,detail:{node:i}});r.target.dispatchEvent(o)})}_add_simulation(n,r){return n.call(this.drag(r))}_style_nodes(n){return n.append("rect").attr("fill",r=>r.node_img?"#f5f5f5":"#000").attr("stroke",r=>r.type?this.color_schema[r.type]:"#00f").attr("stroke-width","2").attr("x",-(this.node_dimensions.width/2)-1).attr("y",-(this.node_dimensions.height/2)-1).attr("width",this.node_dimensions.width+2).attr("height",this.node_dimensions.height+2)}_add_image(n){const r=o=>o.node_img.width*this.node_dimensions.width/o.node_img.width,i=o=>o.node_img.height*this.node_dimensions.height/o.node_img.height;return n.append("image").attr("href",o=>o.node_img.url).attr("x",o=>r(o)/2*-1).attr("y",o=>i(o)/2*-1).attr("width",o=>r(o)).attr("height",o=>i(o)).attr("alt",o=>o.id).attr("opacity",o=>o.node_img.is_placeholder?.3:1)}_create_title(n){return n.append("title").text(r=>r.node_label)}_add_tick_listener(n,r,i,o=Mo){n.on("tick",()=>{i.attr("d",Co(o).x(s=>s.x).y(s=>s.y)),r.attr("transform",s=>`translate(${s.x},${s.y})`)})}_get_links(n){return n.links}_get_nodes(n){return n.nodes}async draw_network(n,r){console.info("drawing forced tree"),this.clear_canvas();const i=this._get_links(n),o=this._get_nodes(n);this._calculate_node_weight(o,i);const s=this._create_simulation(o,i);this._compute_layout(o),this.svg=this._create_root_svg(r),this.svg.attr("cursor","grab");const a=this._create_edges(i);let l=this._create_nodes(o);return this._add_click_event(l),this._add_simulation(l,s),this._style_nodes(l),this._add_image(l),this._create_title(l),this._add_tick_listener(s,l,a),this.svg.node()}_compute_layout(n,r=10){this.layout._calculate_viewbox_size(n,!1),this.layout.adjust_viewbox(r,30,30)}_calculate_path_coordinates(n,r){let i=n.x,o=r.x,s=n.y,a=r.y;return`M ${i} ${s} L ${o} ${a}`}_create_edges(n){return this.svg.append("g").attr("class","links").selectAll("path").data(n).join("path").attr("id",(r,i)=>`linkPath${i}`).attr("stroke",r=>{if(r.label in this.label_map){const i=this.label_map[r.label];return Object.keys(this.color_schema.links).includes(i)?this.color_schema.links[i]:"#999"}else return"#999"}).attr("stroke-width",1).attr("fill","none")}_create_link_labels(n){return this.svg.append("g").attr("class","linkLabels").selectAll("text").data(n).join("text").attr("dy",-2).append("textPath").attr("xlink:href",(r,i)=>`#linkPath${i}`).attr("startOffset","50%").text(r=>r.label).style("font-size",".2em")}drag(n){function r(s,a){s.active||n.alphaTarget(.3).restart(),a.fx=a.x,a.fy=a.y}function i(s,a){a.fx=s.x,a.fy=s.y}function o(s,a){s.active||n.alphaTarget(0),a.fx=null,a.fy=null}return me().on("start",r).on("drag",i).on("end",o)}}class Qo extends kn{constructor(){super(...arguments);q(this,"root",null);q(this,"scale",null)}_calculate_path_coordinates(n,r,i){let o=n.x,s=n.y,a=r.x,l=r.y;return o>a?(o+=i.width/2,a+=i.width*1.5):(o+=i.width*1.5,a+=i.width/2),l+=i.height/2,s+=i.height/2,`M ${o} ${s} L ${a} ${l}`}_create_children(n,r,i){const o=[],s=[];for(let a of r){let l=!1;a.source==n.id?l=i.find(u=>u.id==a.target):a.target==n.id&&(l=i.find(u=>u.id==a.source)),l&&(o.push(a),s.push({child:l,label:a.label}))}return n.children=s.filter((a,l,u)=>u.indexOf(a)==l),r.filter(a=>!o.includes(a))}_add_year_from_dating(n){var i;const r=/(-?\d{4})/;for(let o of n)if(!((i=o.dating)!=null&&i.to))o.dating.year=null;else{let s=o.dating.to.match(r)[0];o.dating.year=Number(s)}return n}_sort_nodes(n){return n.toSorted((r,i)=>r.dating.year==null?1:i.dating.year==null?-1:r.dating.year-i.dating.year)}_create_scale(n,r=[0,500]){let i=n.filter(a=>a.dating.year>0).map(a=>new Date(a.dating.to));const o={};for(let a of i)o[a.getFullYear()]=a;if(i=Object.values(o),i.length==0)return null;i.length==1&&(i.push(Vo(i[0],10)),i.push(xn(i[0],10)));let s=Bn(i);return xo().domain(s).range(r)}_create_tree(n,r,i){n[0].x=1,n[0].y=-3*this.node_dimensions.height;for(let o of r){const s=o.cluster_id?1+o.cluster_id:1;!o.x&&o.dating.year?(o.y=i(new Date(o.dating.to))-this.node_dimensions.height/2,o.x=s):o.dating.year==null&&(o.x=s,o.y=500-this.node_dimensions.height/2)}}_compute_layout(n,r=10){this.layout._calculate_viewbox_size(n);let i=this.node_dimensions.width;this.layout.adjust_viewbox(r,i,this.node_dimensions.height)}_extract_node(n,r){const i={a:null,rest:null};return i.a=[n.find(o=>o.id==r)],i.rest=n.filter(o=>o.id!=r),i}_replace_node_ids_with_obj(n,r){return n.map(i=>{const o=r.find(a=>a.id==i.source),s=r.find(a=>a.id==i.target);return i.source=o,i.target=s,i})}_remove_depicted_links(n){return n.filter(r=>!["ist abgebildet in","bildet ab"].includes(r.label))}_create_title(n){return n.append("title").text(r=>`${r.dating.year} - ${r.id} - ${r.index} `)}create_time_grid(n,r){this.scale=n,r.append("g").attr("class","time_axis fixed").attr("transform","translate(50,5)").call(Ee(n)).node()}get_zoom_handler(){return n=>{Rt("svg > g:not(.fixed)").attr("transform",n.transform),B(".time_axis").call(Ee(n.transform.rescaleY(this.scale)))}}prepare_nodes(n){let r=this._add_year_from_dating(n);return r=r.map(i=>(i.cluster_id=0,i)),this._sort_nodes(r)}drag(n){function r(s,a){s.active||n.alphaTarget(.3).restart(),a.fx=a.x}function i(s,a){a.fx=s.x}function o(s,a){s.active||n.alphaTarget(0),a.fx=null}return me().on("start",r).on("drag",i).on("end",o)}pythagoras(n,r){return Math.sqrt(n*n+r*r)}}class ps extends kn{_compute_layout(e){const n=this.svg.node().getBoundingClientRect();console.log(n);let r=0,i=0,o=n.width,s=n.height;this.layout.override_computed_viewbox_values({x:r,y:i,width:o,height:s})}async draw_network(e,n){const r=e.nodes.map(p=>Lt(p)),i=e.links.map(p=>Lt(p)),o=structuredClone({nodes:r,links:i});this.svg=B(n).append("svg").attr("width",this.layout.get_viewport_width()).attr("height",this.layout.get_viewport_height()),this.svg.attr("cursor","grab"),this._compute_layout(o.nodes);const s=this._create_simulation(o);this.svg.attr("viewBox",this.layout.get_viewbox_settings());const a=this._create_edges(o.links),l=this._create_nodes(o.nodes);this._add_simulation(l,s),this._add_click_event(l),this._style_nodes(l),this._add_image(l),this._create_node_labels(l),this._create_link_labels(o.links),this._add_tick_listener(s,l,a);const u=this.get_zoom_handler(),_=$t().on("zoom",u);this.svg.call(_)}_create_simulation(e){const n=Number(this.layout.get_viewbox_width()),r=Number(this.layout.get_viewbox_height());return we(e.nodes).force("link",xe(e.links).id(i=>i.id).distance(150)).force("charge",ve().strength(-500)).force("center",rn(n/2,r/2))}}class ms extends Qo{_compute_layout(e){const n=this.svg.node().getBoundingClientRect();let r=0,i=0,o=n.width,s=n.height;this.layout.override_computed_viewbox_values({x:r,y:i,width:o,height:s})}async draw_network(e,n){const r=e.nodes.map(c=>Lt(c)),i=e.links.map(c=>Lt(c)),o=structuredClone({nodes:r,links:i});if(this.node_dimensions.width=this.node_dimensions.width/2,this.node_dimensions.height=this.node_dimensions.height/2,o.links.some(c=>c.label=="ist abgebildet in")){const{rest:c}=this._extract_node(o.nodes,o.links.find(v=>v.label=="ist abgebildet in").source.id);o.nodes=c}o.nodes=this._add_year_from_dating(o.nodes),o.nodes=this._sort_nodes(o.nodes),o.links=this._remove_depicted_links(o.links),this.svg=B(n).append("svg").attr("width",this.layout.get_viewport_width()).attr("height",this.layout.get_viewport_height()).attr("transform","translate(0, 0)"),this.svg.attr("cursor","grab");const s=this.svg.node().getBoundingClientRect().height;let a=this._create_scale(o.nodes,[0,s-10]);a&&this.create_time_grid(a,this.svg);const l=o.nodes.findLast(c=>c.dating.year!=null),u=new Date(l.dating.to);u.setFullYear(u.getFullYear()+1);const _=c=>c.dating.to?a(new Date(c.dating.to)):a(u);o.nodes.forEach(c=>{c.y=_(c)}),this._compute_layout(o.nodes);const p=Number(this.layout.get_viewbox_width()),f=this._create_simulation(o,_,p);this.svg.attr("viewBox",this.layout.get_viewbox_settings());const g=this._create_edges(o.links),T=this._create_nodes(o.nodes);T.call(m(f)),this._add_click_event(T),this._style_nodes(T),this._add_image(T),this._create_node_labels(T),this._create_link_labels(o.links),this._add_tick_listener(f,T,g,No);const y=this.get_zoom_handler();this.zoom=$t().on("zoom",y),this.svg.call(this.zoom);function m(c){function v(N,x){N.active||c.alphaTarget(.3).restart(),x.fx=x.x,x.fy=x.y}function D(N,x){x.fx=N.x,x.fy=N.y}function h(N,x){N.active||c.alphaTarget(0),x.fx=null,x.fy=null}return me().on("start",v).on("drag",D).on("end",h)}}_create_simulation(e,n,r){return we(e.nodes).force("link",xe(e.links).id(i=>i.id).distance(i=>{const s=this.pythagoras(0,n(i.target)-n(i.source));return s>200?s:200})).force("charge",ve().strength(-500)).force("y",Dr(n).strength(1)).force("x",Nr(r/2))}}export{ss as B,ps as D,ls as F,fs as G,us as L,Xo as N,as as Q,rs as S,os as T,ms as a,is as b,ds as c,hs as d,_s as e,gs as f,ns as g,cs as h};