@hpcc-js/tree 3.2.12 → 3.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var t=Object.defineProperty,e=(e,n)=>t(e,"name",{value:n,configurable:!0});import{ITree as n}from"@hpcc-js/api";import{SVGWidget as r,rgb as i,d3Event as o,interpolateZoom as a,Utility as l,PropertyExt as s,SVGZoomWidget as c,select as u,Palette as h,HTMLWidget as p,Platform as d,max as f,scaleLinear as y,scaleSqrt as m,interpolate as g}from"@hpcc-js/common";const x="@hpcc-js/tree",_="3.2.12",b="3.21.2";function v(t,e){return t.parent===e.parent?1:2}function w(t){return t.reduce(S,0)/t.length}function S(t,e){return t+e.x}function z(t){return 1+t.reduce(C,0)}function C(t,e){return Math.max(t,e.y)}function k(t){for(var e;e=t.children;)t=e[0];return t}function M(t){for(var e;e=t.children;)t=e[e.length-1];return t}function T(){var t=v,n=1,r=1,i=!1;function o(e){var o,a=0;e.eachAfter(function(e){var n=e.children;n?(e.x=w(n),e.y=z(n)):(e.x=o?a+=t(e,o):0,e.y=0,o=e)});var l=k(e),s=M(e),c=l.x-t(l,s)/2,u=s.x+t(s,l)/2;return e.eachAfter(i?function(t){t.x=(t.x-e.x)*n,t.y=(e.y-t.y)*r}:function(t){t.x=(t.x-c)/(u-c)*n,t.y=(1-(e.y?t.y/e.y:1))*r})}return e(o,"cluster"),o.separation=function(e){return arguments.length?(t=e,o):t},o.size=function(t){return arguments.length?(i=!1,n=+t[0],r=+t[1],o):i?null:[n,r]},o.nodeSize=function(t){return arguments.length?(i=!0,n=+t[0],r=+t[1],o):i?[n,r]:null},o}function D(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function A(){return this.eachAfter(D)}function I(t){var e,n,r,i,o=this,a=[o];do{for(e=a.reverse(),a=[];o=e.pop();)if(t(o),n=o.children)for(r=0,i=n.length;r<i;++r)a.push(n[r])}while(a.length);return this}function R(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this}function P(t){for(var e,n,r,i=this,o=[i],a=[];i=o.pop();)if(a.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)o.push(e[n]);for(;i=a.pop();)t(i);return this}function L(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 B(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function E(t){for(var e=this,n=N(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 N(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 q(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function F(){var t=[];return this.each(function(e){t.push(e)}),t}function O(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function V(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function W(t,e){var n,r,i,o,a,l=new Z(t),s=+t.value&&(l.value=t.value),c=[l];for(null==e&&(e=j);n=c.pop();)if(s&&(n.value=+n.data.value),(i=e(n.data))&&(a=i.length))for(n.children=new Array(a),o=a-1;o>=0;--o)c.push(r=n.children[o]=new Z(i[o])),r.parent=n,r.depth=n.depth+1;return l.eachBefore(J)}function $(){return W(this).eachBefore(H)}function j(t){return t.children}function H(t){t.data=t.data.data}function J(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Z(t){this.data=t,this.depth=this.height=0,this.parent=null}e(v,"defaultSeparation$1"),e(w,"meanX"),e(S,"meanXReduce"),e(z,"maxY"),e(C,"maxYReduce"),e(k,"leafLeft"),e(M,"leafRight"),e(T,"d3Cluster"),e(D,"count"),e(A,"node_count"),e(I,"node_each"),e(R,"node_eachBefore"),e(P,"node_eachAfter"),e(L,"node_sum"),e(B,"node_sort"),e(E,"node_path"),e(N,"leastCommonAncestor"),e(q,"node_ancestors"),e(F,"node_descendants"),e(O,"node_leaves"),e(V,"node_links"),e(W,"hierarchy"),e($,"node_copy"),e(j,"defaultChildren"),e(H,"copyData"),e(J,"computeHeight"),e(Z,"Node$1"),Z.prototype=W.prototype={constructor:Z,count:A,each:I,eachAfter:P,eachBefore:R,sum:L,sort:B,path:E,ancestors:q,descendants:F,leaves:O,links:V,copy:$};var X=Array.prototype.slice;function Y(t){for(var e,n,r=t.length;r;)n=Math.random()*r--|0,e=t[r],t[r]=t[n],t[n]=e;return t}function K(t){for(var e,n,r=0,i=(t=Y(X.call(t))).length,o=[];r<i;)e=t[r],n&&U(n,e)?++r:(n=et(o=Q(o,e)),r=0);return n}function Q(t,e){var n,r;if(tt(e,t))return[e];for(n=0;n<t.length;++n)if(G(e,t[n])&&tt(rt(t[n],e),t))return[t[n],e];for(n=0;n<t.length-1;++n)for(r=n+1;r<t.length;++r)if(G(rt(t[n],t[r]),e)&&G(rt(t[n],e),t[r])&&G(rt(t[r],e),t[n])&&tt(it(t[n],t[r],e),t))return[t[n],t[r],e];throw new Error}function G(t,e){var n=t.r-e.r,r=e.x-t.x,i=e.y-t.y;return n<0||n*n<r*r+i*i}function U(t,e){var n=t.r-e.r+1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function tt(t,e){for(var n=0;n<e.length;++n)if(!U(t,e[n]))return!1;return!0}function et(t){switch(t.length){case 1:return nt(t[0]);case 2:return rt(t[0],t[1]);case 3:return it(t[0],t[1],t[2])}}function nt(t){return{x:t.x,y:t.y,r:t.r}}function rt(t,e){var n=t.x,r=t.y,i=t.r,o=e.x,a=e.y,l=e.r,s=o-n,c=a-r,u=l-i,h=Math.sqrt(s*s+c*c);return{x:(n+o+s/h*u)/2,y:(r+a+c/h*u)/2,r:(h+i+l)/2}}function it(t,e,n){var r=t.x,i=t.y,o=t.r,a=e.x,l=e.y,s=e.r,c=n.x,u=n.y,h=n.r,p=r-a,d=r-c,f=i-l,y=i-u,m=s-o,g=h-o,x=r*r+i*i-o*o,_=x-a*a-l*l+s*s,b=x-c*c-u*u+h*h,v=d*f-p*y,w=(f*b-y*_)/(2*v)-r,S=(y*m-f*g)/v,z=(d*_-p*b)/(2*v)-i,C=(p*g-d*m)/v,k=S*S+C*C-1,M=2*(o+w*S+z*C),T=w*w+z*z-o*o,D=-(k?(M+Math.sqrt(M*M-4*k*T))/(2*k):T/M);return{x:r+w+S*D,y:i+z+C*D,r:D}}function ot(t,e,n){var r,i,o,a,l=t.x-e.x,s=t.y-e.y,c=l*l+s*s;c?(i=e.r+n.r,i*=i,a=t.r+n.r,i>(a*=a)?(r=(c+a-i)/(2*c),o=Math.sqrt(Math.max(0,a/c-r*r)),n.x=t.x-r*l-o*s,n.y=t.y-r*s+o*l):(r=(c+i-a)/(2*c),o=Math.sqrt(Math.max(0,i/c-r*r)),n.x=e.x+r*l-o*s,n.y=e.y+r*s+o*l)):(n.x=e.x+n.r,n.y=e.y)}function at(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function lt(t){var e=t._,n=t.next._,r=e.r+n.r,i=(e.x*n.r+n.x*e.r)/r,o=(e.y*n.r+n.y*e.r)/r;return i*i+o*o}function st(t){this._=t,this.next=null,this.previous=null}function ct(t){if(!(i=t.length))return 0;var e,n,r,i,o,a,l,s,c,u,h;if((e=t[0]).x=0,e.y=0,!(i>1))return e.r;if(n=t[1],e.x=-n.r,n.x=e.r,n.y=0,!(i>2))return e.r+n.r;ot(n,e,r=t[2]),e=new st(e),n=new st(n),r=new st(r),e.next=r.previous=n,n.next=e.previous=r,r.next=n.previous=e;t:for(l=3;l<i;++l){ot(e._,n._,r=t[l]),r=new st(r),s=n.next,c=e.previous,u=n._.r,h=e._.r;do{if(u<=h){if(at(s._,r._)){n=s,e.next=n,n.previous=e,--l;continue t}u+=s._.r,s=s.next}else{if(at(c._,r._)){(e=c).next=n,n.previous=e,--l;continue t}h+=c._.r,c=c.previous}}while(s!==c.next);for(r.previous=e,r.next=n,e.next=n.previous=n=r,o=lt(e);(r=r.next)!==n;)(a=lt(r))<o&&(e=r,o=a);n=e.next}for(e=[n._],r=n;(r=r.next)!==n;)e.push(r._);for(r=K(e),l=0;l<i;++l)(e=t[l]).x-=r.x,e.y-=r.y;return r.r}function ut(t){return null==t?null:ht(t)}function ht(t){if("function"!=typeof t)throw new Error;return t}function pt(){return 0}function dt(t){return function(){return t}}function ft(t){return Math.sqrt(t.value)}function yt(){var t=null,n=1,r=1,i=pt;function o(e){return e.x=n/2,e.y=r/2,t?e.eachBefore(mt(t)).eachAfter(gt(i,.5)).eachBefore(xt(1)):e.eachBefore(mt(ft)).eachAfter(gt(pt,1)).eachAfter(gt(i,e.r/Math.min(n,r))).eachBefore(xt(Math.min(n,r)/(2*e.r))),e}return e(o,"pack"),o.radius=function(e){return arguments.length?(t=ut(e),o):t},o.size=function(t){return arguments.length?(n=+t[0],r=+t[1],o):[n,r]},o.padding=function(t){return arguments.length?(i="function"==typeof t?t:dt(+t),o):i},o}function mt(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0))}}function gt(t,e){return function(n){if(r=n.children){var r,i,o,a=r.length,l=t(n)*e||0;if(l)for(i=0;i<a;++i)r[i].r+=l;if(o=ct(r),l)for(i=0;i<a;++i)r[i].r-=l;n.r=o+l}}}function xt(t){return function(e){var n=e.parent;e.r*=t,n&&(e.x=n.x+t*e.x,e.y=n.y+t*e.y)}}function _t(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function bt(t,e,n,r,i){for(var o,a=t.children,l=-1,s=a.length,c=t.value&&(r-e)/t.value;++l<s;)(o=a[l]).y0=n,o.y1=i,o.x0=e,o.x1=e+=o.value*c}function vt(){var t=1,n=1,r=0,i=!1;function o(e){var o=e.height+1;return e.x0=e.y0=r,e.x1=t,e.y1=n/o,e.eachBefore(a(n,o)),i&&e.eachBefore(_t),e}function a(t,e){return function(n){n.children&&bt(n,n.x0,t*(n.depth+1)/e,n.x1,t*(n.depth+2)/e);var i=n.x0,o=n.y0,a=n.x1-r,l=n.y1-r;a<i&&(i=a=(i+a)/2),l<o&&(o=l=(o+l)/2),n.x0=i,n.y0=o,n.x1=a,n.y1=l}}return e(o,"partition"),e(a,"positionNode"),o.round=function(t){return arguments.length?(i=!!t,o):i},o.size=function(e){return arguments.length?(t=+e[0],n=+e[1],o):[t,n]},o.padding=function(t){return arguments.length?(r=+t,o):r},o}function wt(t,e){return t.parent===e.parent?1:2}function St(t){var e=t.children;return e?e[0]:t.t}function zt(t){var e=t.children;return e?e[e.length-1]:t.t}function Ct(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 kt(t){for(var e,n=0,r=0,i=t.children,o=i.length;--o>=0;)(e=i[o]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}function Mt(t,e,n){return t.a.parent===e.parent?t.a:n}function Tt(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}function Dt(t){for(var e,n,r,i,o,a=new Tt(t,0),l=[a];e=l.pop();)if(r=e._.children)for(e.children=new Array(o=r.length),i=o-1;i>=0;--i)l.push(n=e.children[i]=new Tt(r[i],i)),n.parent=e;return(a.parent=new Tt(null,0)).children=[a],a}function At(){var t=wt,n=1,r=1,i=null;function o(e){var o=Dt(e);if(o.eachAfter(a),o.parent.m=-o.z,o.eachBefore(l),i)e.eachBefore(c);else{var s=e,u=e,h=e;e.eachBefore(function(t){t.x<s.x&&(s=t),t.x>u.x&&(u=t),t.depth>h.depth&&(h=t)});var p=s===u?1:t(s,u)/2,d=p-s.x,f=n/(u.x+p+d),y=r/(h.depth||1);e.eachBefore(function(t){t.x=(t.x+d)*f,t.y=t.depth*y})}return e}function a(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){kt(e);var o=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-o):e.z=o}else i&&(e.z=i.z+t(e._,i._));e.parent.A=s(e,i,e.parent.A||r[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(e,n,r){if(n){for(var i,o=e,a=e,l=n,s=o.parent.children[0],c=o.m,u=a.m,h=l.m,p=s.m;l=zt(l),o=St(o),l&&o;)s=St(s),(a=zt(a)).a=e,(i=l.z+h-o.z-c+t(l._,o._))>0&&(Ct(Mt(l,e,r),e,i),c+=i,u+=i),h+=l.m,c+=o.m,p+=s.m,u+=a.m;l&&!zt(a)&&(a.t=l,a.m+=h-u),o&&!St(s)&&(s.t=o,s.m+=c-p,r=e)}return r}function c(t){t.x*=n,t.y=t.depth*r}return e(o,"tree"),e(a,"firstWalk"),e(l,"secondWalk"),e(s,"apportion"),e(c,"sizeNode"),o.separation=function(e){return arguments.length?(t=e,o):t},o.size=function(t){return arguments.length?(i=!1,n=+t[0],r=+t[1],o):i?null:[n,r]},o.nodeSize=function(t){return arguments.length?(i=!0,n=+t[0],r=+t[1],o):i?[n,r]:null},o}function It(t,e,n,r,i){for(var o,a=t.children,l=-1,s=a.length,c=t.value&&(i-n)/t.value;++l<s;)(o=a[l]).x0=e,o.x1=r,o.y0=n,o.y1=n+=o.value*c}e(Y,"shuffle"),e(K,"enclose"),e(Q,"extendBasis"),e(G,"enclosesNot"),e(U,"enclosesWeak"),e(tt,"enclosesWeakAll"),e(et,"encloseBasis"),e(nt,"encloseBasis1"),e(rt,"encloseBasis2"),e(it,"encloseBasis3"),e(ot,"place"),e(at,"intersects"),e(lt,"score"),e(st,"Node"),e(ct,"packEnclose"),e(ut,"optional"),e(ht,"required"),e(pt,"constantZero"),e(dt,"constant$1"),e(ft,"defaultRadius"),e(yt,"d3Pack"),e(mt,"radiusLeaf"),e(gt,"packChildren"),e(xt,"translateChild"),e(_t,"roundNode"),e(bt,"d3treemapDice"),e(vt,"d3Parition"),e(wt,"defaultSeparation"),e(St,"nextLeft"),e(zt,"nextRight"),e(Ct,"moveSubtree"),e(kt,"executeShifts"),e(Mt,"nextAncestor"),e(Tt,"TreeNode"),Tt.prototype=Object.create(Z.prototype),e(Dt,"treeRoot"),e(At,"d3Tree"),e(It,"d3treemapSlice");var Rt=(1+Math.sqrt(5))/2;function Pt(t,e,n,r,i,o){for(var a,l,s,c,u,h,p,d,f,y,m,g=[],x=e.children,_=0,b=0,v=x.length,w=e.value;_<v;){s=i-n,c=o-r;do{u=x[b++].value}while(!u&&b<v);for(h=p=u,m=u*u*(y=Math.max(c/s,s/c)/(w*t)),f=Math.max(p/m,m/h);b<v;++b){if(u+=l=x[b].value,l<h&&(h=l),l>p&&(p=l),m=u*u*y,(d=Math.max(p/m,m/h))>f){u-=l;break}f=d}g.push(a={value:u,dice:s<c,children:x.slice(_,b)}),a.dice?bt(a,n,r,i,w?r+=c*u/w:o):It(a,n,r,w?n+=s*u/w:i,o),w-=u,_=b}return g}e(Pt,"squarifyRatio");const Lt=/* @__PURE__ */e(function t(n){function r(t,e,r,i,o){Pt(n,t,e,r,i,o)}return e(r,"squarify"),r.ratio=function(e){return t((e=+e)>1?e:1)},r},"custom")(Rt);function Bt(){var t=Lt,n=!1,r=1,i=1,o=[0],a=pt,l=pt,s=pt,c=pt,u=pt;function h(t){return t.x0=t.y0=0,t.x1=r,t.y1=i,t.eachBefore(p),o=[0],n&&t.eachBefore(_t),t}function p(e){var n=o[e.depth],r=e.x0+n,i=e.y0+n,h=e.x1-n,p=e.y1-n;h<r&&(r=h=(r+h)/2),p<i&&(i=p=(i+p)/2),e.x0=r,e.y0=i,e.x1=h,e.y1=p,e.children&&(n=o[e.depth+1]=a(e)/2,r+=u(e)-n,i+=l(e)-n,(h-=s(e)-n)<r&&(r=h=(r+h)/2),(p-=c(e)-n)<i&&(i=p=(i+p)/2),t(e,r,i,h,p))}return e(h,"treemap"),e(p,"positionNode"),h.round=function(t){return arguments.length?(n=!!t,h):n},h.size=function(t){return arguments.length?(r=+t[0],i=+t[1],h):[r,i]},h.tile=function(e){return arguments.length?(t=ht(e),h):t},h.padding=function(t){return arguments.length?h.paddingInner(t).paddingOuter(t):h.paddingInner()},h.paddingInner=function(t){return arguments.length?(a="function"==typeof t?t:dt(+t),h):a},h.paddingOuter=function(t){return arguments.length?h.paddingTop(t).paddingRight(t).paddingBottom(t).paddingLeft(t):h.paddingTop()},h.paddingTop=function(t){return arguments.length?(l="function"==typeof t?t:dt(+t),h):l},h.paddingRight=function(t){return arguments.length?(s="function"==typeof t?t:dt(+t),h):s},h.paddingBottom=function(t){return arguments.length?(c="function"==typeof t?t:dt(+t),h):c},h.paddingLeft=function(t){return arguments.length?(u="function"==typeof t?t:dt(+t),h):u},h}function Et(t,n,r,i,o){var a,l,s=t.children,c=s.length,u=new Array(c+1);for(u[0]=l=a=0;a<c;++a)u[a+1]=l+=s[a].value;function h(t,e,n,r,i,o,a){if(t>=e-1){var l=s[t];return l.x0=r,l.y0=i,l.x1=o,void(l.y1=a)}for(var c=u[t],p=n/2+c,d=t+1,f=e-1;d<f;){var y=d+f>>>1;u[y]<p?d=y+1:f=y}p-u[d-1]<u[d]-p&&t+1<d&&--d;var m=u[d]-c,g=n-m;if(o-r>a-i){var x=(r*g+o*m)/n;h(t,d,m,r,i,x,a),h(d,e,g,x,i,o,a)}else{var _=(i*g+a*m)/n;h(t,d,m,r,i,o,_),h(d,e,g,r,_,o,a)}}h(0,c,t.value,n,r,i,o),e(h,"partition")}function Nt(t,e,n,r,i){(1&t.depth?It:bt)(t,e,n,r,i)}e(Bt,"d3Treemap"),e(Et,"d3treemapBinary"),e(Nt,"d3treemapSliceDice");const qt=/* @__PURE__ */e(function t(n){function r(t,e,r,i,o){if((a=t._squarify)&&a.ratio===n)for(var a,l,s,c,u,h=-1,p=a.length,d=t.value;++h<p;){for(s=(l=a[h]).children,c=l.value=0,u=s.length;c<u;++c)l.value+=s[c].value;l.dice?bt(l,e,r,i,r+=(o-r)*l.value/d):It(l,e,r,e+=(i-e)*l.value/d,o),d-=l.value}else t._squarify=a=Pt(n,t,e,r,i,o),a.ratio=n}return e(r,"resquarify"),r.ratio=function(e){return t((e=+e)>1?e:1)},r},"custom")(Rt),Ft=class _CirclePacking extends r{diameter;pack;svg;_focus;circle;view;_node;constructor(){super(),n.call(this)}enter(t,e){this.diameter=Math.min(this.width(),this.height()),this.pack=yt().size([this.diameter-4,this.diameter-4]).padding(1.5),this.svg=e.append("g")}update(t,e){const n=this;this.diameter=Math.min(this.width(),this.height()),this.pack.size([this.diameter-4,this.diameter-4]).padding(1.5),this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this.svg.selectAll("circle").remove(),this.svg.selectAll("text").remove();const r=W(this.data()).sum(function(t){return t&&t.size?t.size:1}).sort(function(t,e){return t.value<e.value?-1:t.value>e.value?1:0});this._focus=r,this.pack(r),this.circle=this.svg.selectAll("circle").data(r.descendants()).enter().append("circle").attr("class",function(t){return t.parent?t.children?"node":"node leaf":"node root"}).style("fill",function(t){return t.color=n.paletteDepthLevel_exists()&&t.depth>n.paletteDepthLevel()?i(t.parent.color)[n.paletteDepthVariant()](1):n._palette(t.data.label),t.color}).on("click",function(t){n.click(t.data,null,null)}).on("dblclick",function(t){this._focus!==t&&n.zoom(t),o().stopPropagation()}),this.circle.append("title").text(function(t){return t.data.label}),this.svg.selectAll("text").data(r.descendants()).enter().append("text").attr("class","label").style("fill-opacity",function(t){return t.parent===r?1:0}).style("display",function(t){return t.parent===r?null:"none"}).text(function(t){return t.data.label+(n.showSize()&&void 0!==t.data.size?" "+t.data.size:"")}),this._node=this.svg.selectAll("circle,text"),this.zoomTo([r.x,r.y,2*r.r])}zoom(t){this._focus=t;const n=this,r=this.svg.transition().duration(o().altKey?7500:750).tween("zoom",function(){const t=a(n.view,[n._focus.x,n._focus.y,2*n._focus.r]);return function(e){n.zoomTo(t(e))}});function i(t){return t===n._focus&&!t.children||t.parent===n._focus}e(i,"showText"),r.selectAll("text").filter(function(t){return i(t)||"inline"===this.style.display}).style("fill-opacity",function(t){return i(t)?1:0}).on("start",function(t){i(t)&&(this.style.display="inline")}).on("end",function(t){i(t)||(this.style.display="none")})}zoomTo(t){const e=this.diameter/t[2];this.view=t,this._node.attr("transform",function(n){return"translate("+(n.x-t[0])*e+","+(n.y-t[1])*e+")"}),this.circle.attr("r",function(t){return t.r*e})}};e(Ft,"CirclePacking");let Ot=Ft;Ot.prototype._class+=" tree_CirclePacking",Ot.prototype.implements(n.prototype),Ot.prototype.publish("showSize",!0,"boolean","Show size along with label"),Ot.prototype.publish("paletteDepthLevel",null,"number","If not null then beyond this depth number the child node colors are based on parent",null,{optional:!0}),Ot.prototype.publish("paletteDepthVariant","brighter","set","Determines paletteDepthLevel decendant color shade variant",["brighter","darker"],{disable:/* @__PURE__ */e(t=>t.paletteDepthLevel_exists(),"disable")}),Ot.prototype.publish("paletteID","default","set","Color palette for this widget",Ot.prototype._palette.switch(),{tags:["Basic","Shared"]}),Ot.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]});const Vt=class _DendrogramColumn extends s{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};e(Vt,"DendrogramColumn");let Wt=Vt;Wt.prototype._class+=" tree_Dendrogram.DendrogramColumn",Wt.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const $t=class _Dendrogram extends c{Column;_d3LayoutCluster;_d3LayoutTree;_d3Layout;constructor(){super(),n.call(this),l.SimpleSelectionMixin.call(this),this._drawStartPos="origin",this._d3LayoutCluster=T(),this._d3LayoutTree=At()}dendrogramData(){if(0===this.data().length)return[];if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.rollupView(this.mappings().map(function(t){return t.column()})).entries()});function t(e){return{label:e.key,children:e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),origRows:e.values}}}enter(t,e){super.enter(t,e),this._renderElement.attr("opacity",0).transition().duration(500).attr("opacity",1),this._selection.widgetElement(this._renderElement)}update(t,n){super.update(t,n);const r=this,i="vertical"===this.orientation();this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this._d3Layout=this.dendrogram()?this._d3LayoutCluster:this._d3LayoutTree,this.radial()?(this._d3Layout.size([360,2*this.separation()]),this._d3Layout.separation(/* @__PURE__ */e(function(t,e){return(t.parent===e.parent?1:2)/t.depth},"separation"))):(this._d3Layout.nodeSize([14,this.separation()]),this._d3Layout.separation(/* @__PURE__ */e(function(t,e){return t.parent===e.parent?1:2},"separation")));const o=W(this.dendrogramData());this._d3Layout(o);const a=o.descendants(),l=o.descendants().slice(1);function s(t){return"M"+t.parent.x+","+t.parent.y+"C"+t.parent.x+","+(t.parent.y+t.y)/2+" "+t.x+","+(t.parent.y+t.y)/2+" "+t.x+","+t.y}function c(t){return"M"+t.y+","+t.x+"C"+(t.y+t.parent.y)/2+","+t.x+" "+(t.y+t.parent.y)/2+","+t.parent.x+" "+t.parent.y+","+t.parent.x}function h(t){return i?s(t):c(t)}function p(t,e){const n=(t-90)/180*Math.PI,r=e;return[r*Math.cos(n),r*Math.sin(n)]}function d(t){return"M"+p(t.x,t.y)+"C"+p(t.x,(t.y+t.parent.y)/2)+" "+p(t.parent.x,(t.y+t.parent.y)/2)+" "+p(t.parent.x,t.parent.y)}e(s,"linkVertical"),e(c,"linkHorizontal"),e(h,"diagonal"),e(p,"project"),e(d,"radialDiagonal");const f=this._renderCount?500:0,y=this._renderElement.selectAll(".link").data(l);y.enter().append("path").attr("class","link").attr("d",this.radial()?d:h),y.transition().duration(f).attr("d",this.radial()?d:h),y.exit().remove();const m=this.circleRadius()+2;function g(t){return r.radial()?"rotate("+(t.x-90)+")translate("+t.y+")":"horizontal"===r.orientation()?"translate("+t.y+","+t.x+")":"translate("+t.x+","+t.y+")"}e(g,"nodeTransform");const x=this._renderElement.selectAll(".node").data(a);x.transition().duration(f).attr("transform",g);const _=x.enter().append("g").attr("class","node").attr("transform",g).call(this._selection.enter.bind(this._selection)).on("click",function(t){let e=t;for(;e.children;)e=e.children[0];t.depth>0&&(e.origRows?r.click(r.rowToObj(e.origRows[0]),r.mappings()[t.depth-1].column(),!0):r.click(e.data,r.mappings()[t.depth-1].column(),!0))}).on("dblclick",function(t){let e=t;for(;e.children;)e=e.children[0];t.depth>0&&(e.origRows?r.dblclick(r.rowToObj(e.origRows[0]),r.mappings()[t.depth-1].column(),!0):r.dblclick(e.data,r.mappings()[t.depth-1].column(),!0))}).each(function(){const t=u(this);t.append("circle"),t.append("text")});_.merge(x).select("circle").attr("r",this.circleRadius()).style("fill",function(t){return r._palette(t.data.label)}).append("title").text(function(t){return t.data.label}),_.merge(x).select("text").attr("dx",function(t){return r.radial()?t.children?t.x<180?-m:m:t.x<180?m:-m:i?t.children?m:-m:t.children?-m:m}).attr("dy","0.25em").style("text-anchor",function(t){return r.radial()?t.children?t.x<180?"end":"start":t.x<180?"start":"end":i?t.children?"start":"end":t.children?"end":"start"}).attr("transform",function(t){return r.radial()?t.x<180?null:"rotate(180)":i?"rotate(-66)":null}).text(function(t){return t.data.label}),x.exit().remove(),this._renderCount||r.zoomToFit()}};e($t,"Dendrogram");let jt=$t;jt.prototype._class+=" tree_Dendrogram",jt.prototype.implements(n.prototype),jt.prototype.mixin(l.SimpleSelectionMixin),jt.prototype.Column=Wt,jt.prototype.publish("paletteID","default","set","Color palette for this widget",jt.prototype._palette.switch(),{tags:["Basic","Shared"]}),jt.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]}),jt.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:Wt}),jt.prototype.publish("circleRadius",4.5,"number","Text offset from circle"),jt.prototype.publish("separation",240,"number","Leaf Separation"),jt.prototype.publish("dendrogram",!0,"boolean","Dendrogram"),jt.prototype.publish("radial",!1,"boolean","Radial"),jt.prototype.publish("orientation","horizontal","set","Orientation",["horizontal","vertical"],{tags:["Private"],disable:/* @__PURE__ */e(t=>t.radial(),"disable")});const Ht=class _DirectoryTree extends p{constructor(){super()}flattenData(t){const e=this,n=W(t),r=[];return this.omitRoot()?n.children&&n.children.forEach(i):i(n),r;function i(t){const n=t.data.markers&&t.data.markers.length?t.data.markers.length:"";r.push({label:t.data.label,depth:t.depth-(e.omitRoot()?1:0),content:t.data.content,isFolder:!!t.data.children,iconClass:t.data.iconClass,color:t.data.color,bold:t.data.bold,weightValue:n,markers:t.data.markers,selected:t.data.selected}),t.children&&t.children.forEach(i)}}iconClass(t){return"error"===t.label?"fa fa-exclamation":t.isFolder?this.folderIconOpen():this.textFileIcon()}calcRequiredWidth(){const t=this.flattenData(this.data());let e=0;const n=this.rowItemPadding(),r=this.iconSize()+2*n,i=d.getScrollbarWidth();return t.forEach(t=>{const o=t.depth*r+2*n,a=l.textSize(t.label,this.fontFamily(),this.fontSize(),!!t.bold).width+2*n+r+o+i;e<a&&(e=a)}),e}rowClick(t,e){}enter(t,e){super.enter(t,e),e.style("width","100%").style("height","100%")}update(t,e){super.update(t,e),this._palette=this._palette.switch(this.paletteID()),e.style("overflow-y",this.verticalScroll()?"scroll":null);const n=this.flattenData(this.data()),r=f(n,t=>Number(t.weightValue));n.forEach(t=>{t.weightValue?t.weightColor=this._palette(t.weightValue,1,r):t.weightColor="transparent"});const i=this,o=this.rowItemPadding(),a=this.iconSize()+o,l=Math.max(i.iconSize(),i.fontSize()),s=e.selectAll(".directory-row").data(n),c=this.fontFamily(),p=this.fontSize(),d=f(n,t=>this.textSize(t.weightValue,c,p).width),y=`${o}px ${o}px ${o/2}px ${o}px`;s.enter().append("div").attr("class",t=>`directory-row directory-row-depth-${t.depth}`).style("display","flex").style("cursor","pointer").each(function(t){const n=u(this),r=t.color?t.color:i.fontColor(),s=t.weightColor?t.weightColor:"transparent",f=h.textColor(s),m=n.append("div").attr("class","row-weight").style("padding",y).style("color",f).style("box-shadow",`inset 0 0 100px ${s}`).style("font-weight",t.bold?"bold":"normal").style("font-family",c).style("font-size",p+"px").text(t.weightValue).attr("title",t.weightValue).style("overflow","hidden").style("width",d+2*o+"px").style("text-overflow","ellipsis").style("text-align","right").style("line-height",l+"px");n.append("div").attr("class","row-depth").style("width",i.depthSize()*t.depth+"px").style("opacity",1).style("line-height",l+"px");const g=n.append("div").attr("class","row-icon "+(t.iconClass?t.iconClass:i.iconClass(t))).style("width",a+"px").style("height",l+"px").style("color",r).style("background-color",t.selected?i.selectionBackgroundColor():"transparent").style("font-size",i.iconSize()+"px").style("padding",y).style("line-height",l+"px"),x=n.append("div").attr("class","row-label").style("padding",y).style("color",r).style("background-color",t.selected?i.selectionBackgroundColor():"transparent").style("font-weight",t.bold?"bold":"normal").style("font-family",i.fontFamily()).style("font-size",i.fontSize()+"px").text(t.label).attr("title",t.label).style("flex",1).style("overflow","hidden").style("text-overflow","ellipsis").style("line-height",l+"px");n.on("mouseenter",()=>{x.style("font-weight","bold")}).on("mouseleave",()=>{x.style("font-weight",t.bold?"bold":"normal")}),m.on("mouseenter",()=>{i.weight_mouseenter(t)}).on("mouseleave",()=>{i.weight_mouseleave(t)}),t.isFolder?n.on("click",function(t){let e=this.nextSibling;const r=n.classed("folder-closed");for(r?(n.classed("folder-closed",!1),n.classed("folder-open",!0),g.attr("class","row-icon "+i.folderIconOpen())):(n.classed("folder-closed",!0),n.classed("folder-open",!1),g.attr("class","row-icon "+i.folderIconClosed()));null!==e;){u(e).datum().depth>t.depth?(e.style.display=r?"flex":"none",e=e.nextSibling):e=null}}):n.on("click",()=>{e.selectAll(".row-label").style("background-color","transparent"),e.selectAll(".row-icon").style("background-color","transparent"),g.style("background-color",i.selectionBackgroundColor()),x.style("background-color",i.selectionBackgroundColor());const n=t.label.split(".").pop().toLowerCase();i.rowClick("json"===n?JSON.stringify(JSON.parse(t.content),null,4):t.content,t.markers)})}).merge(s).style("background-color",i.backgroundColor()),s.exit().remove()}weight_mouseenter(t){}weight_mouseleave(t){}};e(Ht,"DirectoryTree");let Jt=Ht;Jt.prototype._class+=" tree_DirectoryTree",Jt.prototype._palette=h.rainbow("Blues"),Jt.prototype.publish("depthSize",14,"number","Width of indentation per file or folder depth (pixels)"),Jt.prototype.publish("paletteID","Blues","set","Color palette for the weight backgrounds",Jt.prototype._palette.switch(),{tags:["Basic"]}),Jt.prototype.publish("omitRoot",!1,"boolean","If true, root node will not display"),Jt.prototype.publish("rowItemPadding",2,"number","Top, bottom, left and right row item padding"),Jt.prototype.publish("selectionBackgroundColor","#CCC","html-color","Background color of selected directory rows"),Jt.prototype.publish("backgroundColor","#FFF","html-color","Directory item background color"),Jt.prototype.publish("fontColor","#000","html-color","Directory item font color"),Jt.prototype.publish("fontFamily","Arial","string","Directory item font family"),Jt.prototype.publish("fontSize",12,"number","Directory item font size (pixels)"),Jt.prototype.publish("iconSize",12,"number","Directory folder and file icon size (pixels)"),Jt.prototype.publish("folderIconOpen","fa fa-folder-open","string","Open folder icon class"),Jt.prototype.publish("folderIconClosed","fa fa-folder","string","Closed folder icon class"),Jt.prototype.publish("textFileIcon","fa fa-file-text-o","string","Text file icon class"),Jt.prototype.publish("verticalScroll",!0,"boolean","If true, vertical scroll bar will be shown");const Zt=class _IndentedColumn extends s{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};e(Zt,"IndentedColumn");let Xt=Zt;Xt.prototype._class+=" tree_Dendrogram.IndentedColumn",Xt.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const Yt=class _Indented extends c{Column;_d3Tree;_xml;_svgLinks;_svgNodes;_treeData;_collapsed={};constructor(){super(),n.call(this),l.SimpleSelectionMixin.call(this),this._drawStartPos="origin",this._d3Tree=At()}xmlToData(t,e=""){if(DOMParser){return Qt((new DOMParser).parseFromString(t,"text/xml"),e).children[0]}return[]}xml(t){return arguments.length?(this._xml=t,this.data(this.xmlToData(this._xml)),this):this._xml}IndentedData(){if(0===this.data().length)return[];if(this.xmlColumn_exists()){const t=this.columns().indexOf(this.xmlColumn()),e={label:this.xmlColumn(),children:this.data().map(function(e,n){return this.xmlToData(e[t],"["+n+"]")},this)};return 1===e.children.length?e.children[0]:e}if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.rollupView(this.mappings().map(function(t){return t.column()})).entries()});function t(e){if(e.values instanceof Array){const n=e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),r={label:e.key};return n.length?r.children=n:r.size=22,r}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(t,e){super.enter(t,e),this._svgLinks=this._renderElement.append("g"),this._svgNodes=this._renderElement.append("g"),this._selection.widgetElement(this._svgNodes)}_prevDataChecksum;update(t,n){super.update(t,n);const r=this;this._d3Tree.nodeSize([0,this.barHeight()]);const i=this._db.dataChecksum();function o(t){return(t.parent?o(t.parent)+".":"")+t.data.label}this._prevDataChecksum!==i&&(this._treeData=this.IndentedData(),this._prevDataChecksum=i),e(o,"getID");const a=W(this.data()).sum(function(t){return t.size||50}).each(t=>{this._collapsed[o(t)]&&delete t.children}),l=this._d3Tree(a).descendants(),s=this._d3Tree(a).descendants().slice(1);let c=0;a.eachBefore(t=>{t.x=c*r.barHeight(),++c});const h=this.barHeight()-4,p=this._renderCount?500:0,d=this._svgLinks.selectAll(".link").data(s,function(t){return o(t)});function f(t){return"M"+t.parent.y+","+t.parent.x+"V"+t.x+", H"+t.y}d.enter().append("path").attr("class","link").attr("d",f),d.transition().duration(p).attr("d",f),d.exit().remove(),e(f,"elbow");const y=this._svgNodes.selectAll(".node").data(l,function(t){return o(t)});y.transition().duration(p).attr("transform",function(t){return"translate("+t.y+","+t.x+")"});const m=y.enter().append("g").attr("class","node").attr("transform",function(t){return"translate("+t.y+","+t.x+")"}).call(this._selection.enter.bind(this._selection)).each(function(){const t=u(this);t.append("rect").attr("height",h).attr("width",h).on("click",function(t){r._collapsed[o(t)]?delete r._collapsed[o(t)]:t.children&&(r._collapsed[o(t)]=!0),r.lazyRender()}),t.append("text")}).style("opacity",0);function g(t){return r._collapsed[o(t)]?"#3182bd":t.children?"#c6dbef":"#fd8d3c"}m.transition().style("opacity",1),m.merge(y).select("rect").attr("x",-h/2).attr("y",-h/2).style("fill",g),m.merge(y).select("text").attr("dx",h/2+4+"px").attr("dy","0.33em").text(function(t){return t.data.label}),y.exit().transition().style("opacity",0).remove(),this._renderCount||r.zoomToFit(),e(g,"color")}};e(Yt,"Indented");let Kt=Yt;function Qt(t,e=""){const n={id:e,label:"",attributes:{},children:[]};if(n.label=t.nodeName,1===t.nodeType){if(t.attributes.length>0)for(let r=0;r<t.attributes.length;r++){const e=t.attributes.item(r);n.attributes[e.nodeName]=e.nodeValue}}else 3===t.nodeType&&(n.label=t.nodeValue);if(t.hasChildNodes())for(let r=0;r<t.childNodes.length;r++){const i=Qt(t.childNodes.item(r),e+"["+n.children.length+"]");n.children.push(i)}return n}Kt.prototype._class+=" tree_Indented",Kt.prototype.implements(n.prototype),Kt.prototype.mixin(l.SimpleSelectionMixin),Kt.prototype.Column=Xt,Kt.prototype.publish("xmlColumn",null,"set","Field",function(){return this.columns()},{optional:!0}),Kt.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:Xt,disable:/* @__PURE__ */e(t=>t.xmlColumn_exists(),"disable")}),Kt.prototype.publish("barHeight",16,"number","Bar height"),e(Qt,"xmlToJson");var Gt=Math.PI,Ut=2*Gt,te=1e-6,ee=Ut-te;function ne(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function re(){return new ne}function ie(t){/* @__PURE__ */
1
+ var t=Object.defineProperty,e=(e,n)=>t(e,"name",{value:n,configurable:!0});import{ITree as n}from"@hpcc-js/api";import{SVGWidget as r,rgb as i,d3Event as o,interpolateZoom as a,Utility as l,PropertyExt as s,SVGZoomWidget as c,select as u,Palette as h,HTMLWidget as p,Platform as d,max as f,scaleLinear as y,scaleSqrt as m,interpolate as g}from"@hpcc-js/common";const x="@hpcc-js/tree",_="3.2.13",b="3.21.3";function v(t,e){return t.parent===e.parent?1:2}function w(t){return t.reduce(S,0)/t.length}function S(t,e){return t+e.x}function z(t){return 1+t.reduce(C,0)}function C(t,e){return Math.max(t,e.y)}function k(t){for(var e;e=t.children;)t=e[0];return t}function M(t){for(var e;e=t.children;)t=e[e.length-1];return t}function T(){var t=v,n=1,r=1,i=!1;function o(e){var o,a=0;e.eachAfter(function(e){var n=e.children;n?(e.x=w(n),e.y=z(n)):(e.x=o?a+=t(e,o):0,e.y=0,o=e)});var l=k(e),s=M(e),c=l.x-t(l,s)/2,u=s.x+t(s,l)/2;return e.eachAfter(i?function(t){t.x=(t.x-e.x)*n,t.y=(e.y-t.y)*r}:function(t){t.x=(t.x-c)/(u-c)*n,t.y=(1-(e.y?t.y/e.y:1))*r})}return e(o,"cluster"),o.separation=function(e){return arguments.length?(t=e,o):t},o.size=function(t){return arguments.length?(i=!1,n=+t[0],r=+t[1],o):i?null:[n,r]},o.nodeSize=function(t){return arguments.length?(i=!0,n=+t[0],r=+t[1],o):i?[n,r]:null},o}function D(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function A(){return this.eachAfter(D)}function I(t){var e,n,r,i,o=this,a=[o];do{for(e=a.reverse(),a=[];o=e.pop();)if(t(o),n=o.children)for(r=0,i=n.length;r<i;++r)a.push(n[r])}while(a.length);return this}function R(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this}function P(t){for(var e,n,r,i=this,o=[i],a=[];i=o.pop();)if(a.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)o.push(e[n]);for(;i=a.pop();)t(i);return this}function L(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 B(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function E(t){for(var e=this,n=N(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 N(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 q(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function F(){var t=[];return this.each(function(e){t.push(e)}),t}function O(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function V(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function W(t,e){var n,r,i,o,a,l=new Z(t),s=+t.value&&(l.value=t.value),c=[l];for(null==e&&(e=j);n=c.pop();)if(s&&(n.value=+n.data.value),(i=e(n.data))&&(a=i.length))for(n.children=new Array(a),o=a-1;o>=0;--o)c.push(r=n.children[o]=new Z(i[o])),r.parent=n,r.depth=n.depth+1;return l.eachBefore(J)}function $(){return W(this).eachBefore(H)}function j(t){return t.children}function H(t){t.data=t.data.data}function J(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Z(t){this.data=t,this.depth=this.height=0,this.parent=null}e(v,"defaultSeparation$1"),e(w,"meanX"),e(S,"meanXReduce"),e(z,"maxY"),e(C,"maxYReduce"),e(k,"leafLeft"),e(M,"leafRight"),e(T,"d3Cluster"),e(D,"count"),e(A,"node_count"),e(I,"node_each"),e(R,"node_eachBefore"),e(P,"node_eachAfter"),e(L,"node_sum"),e(B,"node_sort"),e(E,"node_path"),e(N,"leastCommonAncestor"),e(q,"node_ancestors"),e(F,"node_descendants"),e(O,"node_leaves"),e(V,"node_links"),e(W,"hierarchy"),e($,"node_copy"),e(j,"defaultChildren"),e(H,"copyData"),e(J,"computeHeight"),e(Z,"Node$1"),Z.prototype=W.prototype={constructor:Z,count:A,each:I,eachAfter:P,eachBefore:R,sum:L,sort:B,path:E,ancestors:q,descendants:F,leaves:O,links:V,copy:$};var X=Array.prototype.slice;function Y(t){for(var e,n,r=t.length;r;)n=Math.random()*r--|0,e=t[r],t[r]=t[n],t[n]=e;return t}function K(t){for(var e,n,r=0,i=(t=Y(X.call(t))).length,o=[];r<i;)e=t[r],n&&U(n,e)?++r:(n=et(o=Q(o,e)),r=0);return n}function Q(t,e){var n,r;if(tt(e,t))return[e];for(n=0;n<t.length;++n)if(G(e,t[n])&&tt(rt(t[n],e),t))return[t[n],e];for(n=0;n<t.length-1;++n)for(r=n+1;r<t.length;++r)if(G(rt(t[n],t[r]),e)&&G(rt(t[n],e),t[r])&&G(rt(t[r],e),t[n])&&tt(it(t[n],t[r],e),t))return[t[n],t[r],e];throw new Error}function G(t,e){var n=t.r-e.r,r=e.x-t.x,i=e.y-t.y;return n<0||n*n<r*r+i*i}function U(t,e){var n=t.r-e.r+1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function tt(t,e){for(var n=0;n<e.length;++n)if(!U(t,e[n]))return!1;return!0}function et(t){switch(t.length){case 1:return nt(t[0]);case 2:return rt(t[0],t[1]);case 3:return it(t[0],t[1],t[2])}}function nt(t){return{x:t.x,y:t.y,r:t.r}}function rt(t,e){var n=t.x,r=t.y,i=t.r,o=e.x,a=e.y,l=e.r,s=o-n,c=a-r,u=l-i,h=Math.sqrt(s*s+c*c);return{x:(n+o+s/h*u)/2,y:(r+a+c/h*u)/2,r:(h+i+l)/2}}function it(t,e,n){var r=t.x,i=t.y,o=t.r,a=e.x,l=e.y,s=e.r,c=n.x,u=n.y,h=n.r,p=r-a,d=r-c,f=i-l,y=i-u,m=s-o,g=h-o,x=r*r+i*i-o*o,_=x-a*a-l*l+s*s,b=x-c*c-u*u+h*h,v=d*f-p*y,w=(f*b-y*_)/(2*v)-r,S=(y*m-f*g)/v,z=(d*_-p*b)/(2*v)-i,C=(p*g-d*m)/v,k=S*S+C*C-1,M=2*(o+w*S+z*C),T=w*w+z*z-o*o,D=-(k?(M+Math.sqrt(M*M-4*k*T))/(2*k):T/M);return{x:r+w+S*D,y:i+z+C*D,r:D}}function ot(t,e,n){var r,i,o,a,l=t.x-e.x,s=t.y-e.y,c=l*l+s*s;c?(i=e.r+n.r,i*=i,a=t.r+n.r,i>(a*=a)?(r=(c+a-i)/(2*c),o=Math.sqrt(Math.max(0,a/c-r*r)),n.x=t.x-r*l-o*s,n.y=t.y-r*s+o*l):(r=(c+i-a)/(2*c),o=Math.sqrt(Math.max(0,i/c-r*r)),n.x=e.x+r*l-o*s,n.y=e.y+r*s+o*l)):(n.x=e.x+n.r,n.y=e.y)}function at(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function lt(t){var e=t._,n=t.next._,r=e.r+n.r,i=(e.x*n.r+n.x*e.r)/r,o=(e.y*n.r+n.y*e.r)/r;return i*i+o*o}function st(t){this._=t,this.next=null,this.previous=null}function ct(t){if(!(i=t.length))return 0;var e,n,r,i,o,a,l,s,c,u,h;if((e=t[0]).x=0,e.y=0,!(i>1))return e.r;if(n=t[1],e.x=-n.r,n.x=e.r,n.y=0,!(i>2))return e.r+n.r;ot(n,e,r=t[2]),e=new st(e),n=new st(n),r=new st(r),e.next=r.previous=n,n.next=e.previous=r,r.next=n.previous=e;t:for(l=3;l<i;++l){ot(e._,n._,r=t[l]),r=new st(r),s=n.next,c=e.previous,u=n._.r,h=e._.r;do{if(u<=h){if(at(s._,r._)){n=s,e.next=n,n.previous=e,--l;continue t}u+=s._.r,s=s.next}else{if(at(c._,r._)){(e=c).next=n,n.previous=e,--l;continue t}h+=c._.r,c=c.previous}}while(s!==c.next);for(r.previous=e,r.next=n,e.next=n.previous=n=r,o=lt(e);(r=r.next)!==n;)(a=lt(r))<o&&(e=r,o=a);n=e.next}for(e=[n._],r=n;(r=r.next)!==n;)e.push(r._);for(r=K(e),l=0;l<i;++l)(e=t[l]).x-=r.x,e.y-=r.y;return r.r}function ut(t){return null==t?null:ht(t)}function ht(t){if("function"!=typeof t)throw new Error;return t}function pt(){return 0}function dt(t){return function(){return t}}function ft(t){return Math.sqrt(t.value)}function yt(){var t=null,n=1,r=1,i=pt;function o(e){return e.x=n/2,e.y=r/2,t?e.eachBefore(mt(t)).eachAfter(gt(i,.5)).eachBefore(xt(1)):e.eachBefore(mt(ft)).eachAfter(gt(pt,1)).eachAfter(gt(i,e.r/Math.min(n,r))).eachBefore(xt(Math.min(n,r)/(2*e.r))),e}return e(o,"pack"),o.radius=function(e){return arguments.length?(t=ut(e),o):t},o.size=function(t){return arguments.length?(n=+t[0],r=+t[1],o):[n,r]},o.padding=function(t){return arguments.length?(i="function"==typeof t?t:dt(+t),o):i},o}function mt(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0))}}function gt(t,e){return function(n){if(r=n.children){var r,i,o,a=r.length,l=t(n)*e||0;if(l)for(i=0;i<a;++i)r[i].r+=l;if(o=ct(r),l)for(i=0;i<a;++i)r[i].r-=l;n.r=o+l}}}function xt(t){return function(e){var n=e.parent;e.r*=t,n&&(e.x=n.x+t*e.x,e.y=n.y+t*e.y)}}function _t(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function bt(t,e,n,r,i){for(var o,a=t.children,l=-1,s=a.length,c=t.value&&(r-e)/t.value;++l<s;)(o=a[l]).y0=n,o.y1=i,o.x0=e,o.x1=e+=o.value*c}function vt(){var t=1,n=1,r=0,i=!1;function o(e){var o=e.height+1;return e.x0=e.y0=r,e.x1=t,e.y1=n/o,e.eachBefore(a(n,o)),i&&e.eachBefore(_t),e}function a(t,e){return function(n){n.children&&bt(n,n.x0,t*(n.depth+1)/e,n.x1,t*(n.depth+2)/e);var i=n.x0,o=n.y0,a=n.x1-r,l=n.y1-r;a<i&&(i=a=(i+a)/2),l<o&&(o=l=(o+l)/2),n.x0=i,n.y0=o,n.x1=a,n.y1=l}}return e(o,"partition"),e(a,"positionNode"),o.round=function(t){return arguments.length?(i=!!t,o):i},o.size=function(e){return arguments.length?(t=+e[0],n=+e[1],o):[t,n]},o.padding=function(t){return arguments.length?(r=+t,o):r},o}function wt(t,e){return t.parent===e.parent?1:2}function St(t){var e=t.children;return e?e[0]:t.t}function zt(t){var e=t.children;return e?e[e.length-1]:t.t}function Ct(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 kt(t){for(var e,n=0,r=0,i=t.children,o=i.length;--o>=0;)(e=i[o]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}function Mt(t,e,n){return t.a.parent===e.parent?t.a:n}function Tt(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}function Dt(t){for(var e,n,r,i,o,a=new Tt(t,0),l=[a];e=l.pop();)if(r=e._.children)for(e.children=new Array(o=r.length),i=o-1;i>=0;--i)l.push(n=e.children[i]=new Tt(r[i],i)),n.parent=e;return(a.parent=new Tt(null,0)).children=[a],a}function At(){var t=wt,n=1,r=1,i=null;function o(e){var o=Dt(e);if(o.eachAfter(a),o.parent.m=-o.z,o.eachBefore(l),i)e.eachBefore(c);else{var s=e,u=e,h=e;e.eachBefore(function(t){t.x<s.x&&(s=t),t.x>u.x&&(u=t),t.depth>h.depth&&(h=t)});var p=s===u?1:t(s,u)/2,d=p-s.x,f=n/(u.x+p+d),y=r/(h.depth||1);e.eachBefore(function(t){t.x=(t.x+d)*f,t.y=t.depth*y})}return e}function a(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){kt(e);var o=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-o):e.z=o}else i&&(e.z=i.z+t(e._,i._));e.parent.A=s(e,i,e.parent.A||r[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(e,n,r){if(n){for(var i,o=e,a=e,l=n,s=o.parent.children[0],c=o.m,u=a.m,h=l.m,p=s.m;l=zt(l),o=St(o),l&&o;)s=St(s),(a=zt(a)).a=e,(i=l.z+h-o.z-c+t(l._,o._))>0&&(Ct(Mt(l,e,r),e,i),c+=i,u+=i),h+=l.m,c+=o.m,p+=s.m,u+=a.m;l&&!zt(a)&&(a.t=l,a.m+=h-u),o&&!St(s)&&(s.t=o,s.m+=c-p,r=e)}return r}function c(t){t.x*=n,t.y=t.depth*r}return e(o,"tree"),e(a,"firstWalk"),e(l,"secondWalk"),e(s,"apportion"),e(c,"sizeNode"),o.separation=function(e){return arguments.length?(t=e,o):t},o.size=function(t){return arguments.length?(i=!1,n=+t[0],r=+t[1],o):i?null:[n,r]},o.nodeSize=function(t){return arguments.length?(i=!0,n=+t[0],r=+t[1],o):i?[n,r]:null},o}function It(t,e,n,r,i){for(var o,a=t.children,l=-1,s=a.length,c=t.value&&(i-n)/t.value;++l<s;)(o=a[l]).x0=e,o.x1=r,o.y0=n,o.y1=n+=o.value*c}e(Y,"shuffle"),e(K,"enclose"),e(Q,"extendBasis"),e(G,"enclosesNot"),e(U,"enclosesWeak"),e(tt,"enclosesWeakAll"),e(et,"encloseBasis"),e(nt,"encloseBasis1"),e(rt,"encloseBasis2"),e(it,"encloseBasis3"),e(ot,"place"),e(at,"intersects"),e(lt,"score"),e(st,"Node"),e(ct,"packEnclose"),e(ut,"optional"),e(ht,"required"),e(pt,"constantZero"),e(dt,"constant$1"),e(ft,"defaultRadius"),e(yt,"d3Pack"),e(mt,"radiusLeaf"),e(gt,"packChildren"),e(xt,"translateChild"),e(_t,"roundNode"),e(bt,"d3treemapDice"),e(vt,"d3Parition"),e(wt,"defaultSeparation"),e(St,"nextLeft"),e(zt,"nextRight"),e(Ct,"moveSubtree"),e(kt,"executeShifts"),e(Mt,"nextAncestor"),e(Tt,"TreeNode"),Tt.prototype=Object.create(Z.prototype),e(Dt,"treeRoot"),e(At,"d3Tree"),e(It,"d3treemapSlice");var Rt=(1+Math.sqrt(5))/2;function Pt(t,e,n,r,i,o){for(var a,l,s,c,u,h,p,d,f,y,m,g=[],x=e.children,_=0,b=0,v=x.length,w=e.value;_<v;){s=i-n,c=o-r;do{u=x[b++].value}while(!u&&b<v);for(h=p=u,m=u*u*(y=Math.max(c/s,s/c)/(w*t)),f=Math.max(p/m,m/h);b<v;++b){if(u+=l=x[b].value,l<h&&(h=l),l>p&&(p=l),m=u*u*y,(d=Math.max(p/m,m/h))>f){u-=l;break}f=d}g.push(a={value:u,dice:s<c,children:x.slice(_,b)}),a.dice?bt(a,n,r,i,w?r+=c*u/w:o):It(a,n,r,w?n+=s*u/w:i,o),w-=u,_=b}return g}e(Pt,"squarifyRatio");const Lt=/* @__PURE__ */e(function t(n){function r(t,e,r,i,o){Pt(n,t,e,r,i,o)}return e(r,"squarify"),r.ratio=function(e){return t((e=+e)>1?e:1)},r},"custom")(Rt);function Bt(){var t=Lt,n=!1,r=1,i=1,o=[0],a=pt,l=pt,s=pt,c=pt,u=pt;function h(t){return t.x0=t.y0=0,t.x1=r,t.y1=i,t.eachBefore(p),o=[0],n&&t.eachBefore(_t),t}function p(e){var n=o[e.depth],r=e.x0+n,i=e.y0+n,h=e.x1-n,p=e.y1-n;h<r&&(r=h=(r+h)/2),p<i&&(i=p=(i+p)/2),e.x0=r,e.y0=i,e.x1=h,e.y1=p,e.children&&(n=o[e.depth+1]=a(e)/2,r+=u(e)-n,i+=l(e)-n,(h-=s(e)-n)<r&&(r=h=(r+h)/2),(p-=c(e)-n)<i&&(i=p=(i+p)/2),t(e,r,i,h,p))}return e(h,"treemap"),e(p,"positionNode"),h.round=function(t){return arguments.length?(n=!!t,h):n},h.size=function(t){return arguments.length?(r=+t[0],i=+t[1],h):[r,i]},h.tile=function(e){return arguments.length?(t=ht(e),h):t},h.padding=function(t){return arguments.length?h.paddingInner(t).paddingOuter(t):h.paddingInner()},h.paddingInner=function(t){return arguments.length?(a="function"==typeof t?t:dt(+t),h):a},h.paddingOuter=function(t){return arguments.length?h.paddingTop(t).paddingRight(t).paddingBottom(t).paddingLeft(t):h.paddingTop()},h.paddingTop=function(t){return arguments.length?(l="function"==typeof t?t:dt(+t),h):l},h.paddingRight=function(t){return arguments.length?(s="function"==typeof t?t:dt(+t),h):s},h.paddingBottom=function(t){return arguments.length?(c="function"==typeof t?t:dt(+t),h):c},h.paddingLeft=function(t){return arguments.length?(u="function"==typeof t?t:dt(+t),h):u},h}function Et(t,n,r,i,o){var a,l,s=t.children,c=s.length,u=new Array(c+1);for(u[0]=l=a=0;a<c;++a)u[a+1]=l+=s[a].value;function h(t,e,n,r,i,o,a){if(t>=e-1){var l=s[t];return l.x0=r,l.y0=i,l.x1=o,void(l.y1=a)}for(var c=u[t],p=n/2+c,d=t+1,f=e-1;d<f;){var y=d+f>>>1;u[y]<p?d=y+1:f=y}p-u[d-1]<u[d]-p&&t+1<d&&--d;var m=u[d]-c,g=n-m;if(o-r>a-i){var x=(r*g+o*m)/n;h(t,d,m,r,i,x,a),h(d,e,g,x,i,o,a)}else{var _=(i*g+a*m)/n;h(t,d,m,r,i,o,_),h(d,e,g,r,_,o,a)}}h(0,c,t.value,n,r,i,o),e(h,"partition")}function Nt(t,e,n,r,i){(1&t.depth?It:bt)(t,e,n,r,i)}e(Bt,"d3Treemap"),e(Et,"d3treemapBinary"),e(Nt,"d3treemapSliceDice");const qt=/* @__PURE__ */e(function t(n){function r(t,e,r,i,o){if((a=t._squarify)&&a.ratio===n)for(var a,l,s,c,u,h=-1,p=a.length,d=t.value;++h<p;){for(s=(l=a[h]).children,c=l.value=0,u=s.length;c<u;++c)l.value+=s[c].value;l.dice?bt(l,e,r,i,r+=(o-r)*l.value/d):It(l,e,r,e+=(i-e)*l.value/d,o),d-=l.value}else t._squarify=a=Pt(n,t,e,r,i,o),a.ratio=n}return e(r,"resquarify"),r.ratio=function(e){return t((e=+e)>1?e:1)},r},"custom")(Rt),Ft=class _CirclePacking extends r{diameter;pack;svg;_focus;circle;view;_node;constructor(){super(),n.call(this)}enter(t,e){this.diameter=Math.min(this.width(),this.height()),this.pack=yt().size([this.diameter-4,this.diameter-4]).padding(1.5),this.svg=e.append("g")}update(t,e){const n=this;this.diameter=Math.min(this.width(),this.height()),this.pack.size([this.diameter-4,this.diameter-4]).padding(1.5),this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this.svg.selectAll("circle").remove(),this.svg.selectAll("text").remove();const r=W(this.data()).sum(function(t){return t&&t.size?t.size:1}).sort(function(t,e){return t.value<e.value?-1:t.value>e.value?1:0});this._focus=r,this.pack(r),this.circle=this.svg.selectAll("circle").data(r.descendants()).enter().append("circle").attr("class",function(t){return t.parent?t.children?"node":"node leaf":"node root"}).style("fill",function(t){return t.color=n.paletteDepthLevel_exists()&&t.depth>n.paletteDepthLevel()?i(t.parent.color)[n.paletteDepthVariant()](1):n._palette(t.data.label),t.color}).on("click",function(t){n.click(t.data,null,null)}).on("dblclick",function(t){this._focus!==t&&n.zoom(t),o().stopPropagation()}),this.circle.append("title").text(function(t){return t.data.label}),this.svg.selectAll("text").data(r.descendants()).enter().append("text").attr("class","label").style("fill-opacity",function(t){return t.parent===r?1:0}).style("display",function(t){return t.parent===r?null:"none"}).text(function(t){return t.data.label+(n.showSize()&&void 0!==t.data.size?" "+t.data.size:"")}),this._node=this.svg.selectAll("circle,text"),this.zoomTo([r.x,r.y,2*r.r])}zoom(t){this._focus=t;const n=this,r=this.svg.transition().duration(o().altKey?7500:750).tween("zoom",function(){const t=a(n.view,[n._focus.x,n._focus.y,2*n._focus.r]);return function(e){n.zoomTo(t(e))}});function i(t){return t===n._focus&&!t.children||t.parent===n._focus}e(i,"showText"),r.selectAll("text").filter(function(t){return i(t)||"inline"===this.style.display}).style("fill-opacity",function(t){return i(t)?1:0}).on("start",function(t){i(t)&&(this.style.display="inline")}).on("end",function(t){i(t)||(this.style.display="none")})}zoomTo(t){const e=this.diameter/t[2];this.view=t,this._node.attr("transform",function(n){return"translate("+(n.x-t[0])*e+","+(n.y-t[1])*e+")"}),this.circle.attr("r",function(t){return t.r*e})}};e(Ft,"CirclePacking");let Ot=Ft;Ot.prototype._class+=" tree_CirclePacking",Ot.prototype.implements(n.prototype),Ot.prototype.publish("showSize",!0,"boolean","Show size along with label"),Ot.prototype.publish("paletteDepthLevel",null,"number","If not null then beyond this depth number the child node colors are based on parent",null,{optional:!0}),Ot.prototype.publish("paletteDepthVariant","brighter","set","Determines paletteDepthLevel decendant color shade variant",["brighter","darker"],{disable:/* @__PURE__ */e(t=>t.paletteDepthLevel_exists(),"disable")}),Ot.prototype.publish("paletteID","default","set","Color palette for this widget",Ot.prototype._palette.switch(),{tags:["Basic","Shared"]}),Ot.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]});const Vt=class _DendrogramColumn extends s{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};e(Vt,"DendrogramColumn");let Wt=Vt;Wt.prototype._class+=" tree_Dendrogram.DendrogramColumn",Wt.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const $t=class _Dendrogram extends c{Column;_d3LayoutCluster;_d3LayoutTree;_d3Layout;constructor(){super(),n.call(this),l.SimpleSelectionMixin.call(this),this._drawStartPos="origin",this._d3LayoutCluster=T(),this._d3LayoutTree=At()}dendrogramData(){if(0===this.data().length)return[];if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.rollupView(this.mappings().map(function(t){return t.column()})).entries()});function t(e){return{label:e.key,children:e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),origRows:e.values}}}enter(t,e){super.enter(t,e),this._renderElement.attr("opacity",0).transition().duration(500).attr("opacity",1),this._selection.widgetElement(this._renderElement)}update(t,n){super.update(t,n);const r=this,i="vertical"===this.orientation();this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this._d3Layout=this.dendrogram()?this._d3LayoutCluster:this._d3LayoutTree,this.radial()?(this._d3Layout.size([360,2*this.separation()]),this._d3Layout.separation(/* @__PURE__ */e(function(t,e){return(t.parent===e.parent?1:2)/t.depth},"separation"))):(this._d3Layout.nodeSize([14,this.separation()]),this._d3Layout.separation(/* @__PURE__ */e(function(t,e){return t.parent===e.parent?1:2},"separation")));const o=W(this.dendrogramData());this._d3Layout(o);const a=o.descendants(),l=o.descendants().slice(1);function s(t){return"M"+t.parent.x+","+t.parent.y+"C"+t.parent.x+","+(t.parent.y+t.y)/2+" "+t.x+","+(t.parent.y+t.y)/2+" "+t.x+","+t.y}function c(t){return"M"+t.y+","+t.x+"C"+(t.y+t.parent.y)/2+","+t.x+" "+(t.y+t.parent.y)/2+","+t.parent.x+" "+t.parent.y+","+t.parent.x}function h(t){return i?s(t):c(t)}function p(t,e){const n=(t-90)/180*Math.PI,r=e;return[r*Math.cos(n),r*Math.sin(n)]}function d(t){return"M"+p(t.x,t.y)+"C"+p(t.x,(t.y+t.parent.y)/2)+" "+p(t.parent.x,(t.y+t.parent.y)/2)+" "+p(t.parent.x,t.parent.y)}e(s,"linkVertical"),e(c,"linkHorizontal"),e(h,"diagonal"),e(p,"project"),e(d,"radialDiagonal");const f=this._renderCount?500:0,y=this._renderElement.selectAll(".link").data(l);y.enter().append("path").attr("class","link").attr("d",this.radial()?d:h),y.transition().duration(f).attr("d",this.radial()?d:h),y.exit().remove();const m=this.circleRadius()+2;function g(t){return r.radial()?"rotate("+(t.x-90)+")translate("+t.y+")":"horizontal"===r.orientation()?"translate("+t.y+","+t.x+")":"translate("+t.x+","+t.y+")"}e(g,"nodeTransform");const x=this._renderElement.selectAll(".node").data(a);x.transition().duration(f).attr("transform",g);const _=x.enter().append("g").attr("class","node").attr("transform",g).call(this._selection.enter.bind(this._selection)).on("click",function(t){let e=t;for(;e.children;)e=e.children[0];t.depth>0&&(e.origRows?r.click(r.rowToObj(e.origRows[0]),r.mappings()[t.depth-1].column(),!0):r.click(e.data,r.mappings()[t.depth-1].column(),!0))}).on("dblclick",function(t){let e=t;for(;e.children;)e=e.children[0];t.depth>0&&(e.origRows?r.dblclick(r.rowToObj(e.origRows[0]),r.mappings()[t.depth-1].column(),!0):r.dblclick(e.data,r.mappings()[t.depth-1].column(),!0))}).each(function(){const t=u(this);t.append("circle"),t.append("text")});_.merge(x).select("circle").attr("r",this.circleRadius()).style("fill",function(t){return r._palette(t.data.label)}).append("title").text(function(t){return t.data.label}),_.merge(x).select("text").attr("dx",function(t){return r.radial()?t.children?t.x<180?-m:m:t.x<180?m:-m:i?t.children?m:-m:t.children?-m:m}).attr("dy","0.25em").style("text-anchor",function(t){return r.radial()?t.children?t.x<180?"end":"start":t.x<180?"start":"end":i?t.children?"start":"end":t.children?"end":"start"}).attr("transform",function(t){return r.radial()?t.x<180?null:"rotate(180)":i?"rotate(-66)":null}).text(function(t){return t.data.label}),x.exit().remove(),this._renderCount||r.zoomToFit()}};e($t,"Dendrogram");let jt=$t;jt.prototype._class+=" tree_Dendrogram",jt.prototype.implements(n.prototype),jt.prototype.mixin(l.SimpleSelectionMixin),jt.prototype.Column=Wt,jt.prototype.publish("paletteID","default","set","Color palette for this widget",jt.prototype._palette.switch(),{tags:["Basic","Shared"]}),jt.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]}),jt.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:Wt}),jt.prototype.publish("circleRadius",4.5,"number","Text offset from circle"),jt.prototype.publish("separation",240,"number","Leaf Separation"),jt.prototype.publish("dendrogram",!0,"boolean","Dendrogram"),jt.prototype.publish("radial",!1,"boolean","Radial"),jt.prototype.publish("orientation","horizontal","set","Orientation",["horizontal","vertical"],{tags:["Private"],disable:/* @__PURE__ */e(t=>t.radial(),"disable")});const Ht=class _DirectoryTree extends p{constructor(){super()}flattenData(t){const e=this,n=W(t),r=[];return this.omitRoot()?n.children&&n.children.forEach(i):i(n),r;function i(t){const n=t.data.markers&&t.data.markers.length?t.data.markers.length:"";r.push({label:t.data.label,depth:t.depth-(e.omitRoot()?1:0),content:t.data.content,isFolder:!!t.data.children,iconClass:t.data.iconClass,color:t.data.color,bold:t.data.bold,weightValue:n,markers:t.data.markers,selected:t.data.selected}),t.children&&t.children.forEach(i)}}iconClass(t){return"error"===t.label?"fa fa-exclamation":t.isFolder?this.folderIconOpen():this.textFileIcon()}calcRequiredWidth(){const t=this.flattenData(this.data());let e=0;const n=this.rowItemPadding(),r=this.iconSize()+2*n,i=d.getScrollbarWidth();return t.forEach(t=>{const o=t.depth*r+2*n,a=l.textSize(t.label,this.fontFamily(),this.fontSize(),!!t.bold).width+2*n+r+o+i;e<a&&(e=a)}),e}rowClick(t,e){}enter(t,e){super.enter(t,e),e.style("width","100%").style("height","100%")}update(t,e){super.update(t,e),this._palette=this._palette.switch(this.paletteID()),e.style("overflow-y",this.verticalScroll()?"scroll":null);const n=this.flattenData(this.data()),r=f(n,t=>Number(t.weightValue));n.forEach(t=>{t.weightValue?t.weightColor=this._palette(t.weightValue,1,r):t.weightColor="transparent"});const i=this,o=this.rowItemPadding(),a=this.iconSize()+o,l=Math.max(i.iconSize(),i.fontSize()),s=e.selectAll(".directory-row").data(n),c=this.fontFamily(),p=this.fontSize(),d=f(n,t=>this.textSize(t.weightValue,c,p).width),y=`${o}px ${o}px ${o/2}px ${o}px`;s.enter().append("div").attr("class",t=>`directory-row directory-row-depth-${t.depth}`).style("display","flex").style("cursor","pointer").each(function(t){const n=u(this),r=t.color?t.color:i.fontColor(),s=t.weightColor?t.weightColor:"transparent",f=h.textColor(s),m=n.append("div").attr("class","row-weight").style("padding",y).style("color",f).style("box-shadow",`inset 0 0 100px ${s}`).style("font-weight",t.bold?"bold":"normal").style("font-family",c).style("font-size",p+"px").text(t.weightValue).attr("title",t.weightValue).style("overflow","hidden").style("width",d+2*o+"px").style("text-overflow","ellipsis").style("text-align","right").style("line-height",l+"px");n.append("div").attr("class","row-depth").style("width",i.depthSize()*t.depth+"px").style("opacity",1).style("line-height",l+"px");const g=n.append("div").attr("class","row-icon "+(t.iconClass?t.iconClass:i.iconClass(t))).style("width",a+"px").style("height",l+"px").style("color",r).style("background-color",t.selected?i.selectionBackgroundColor():"transparent").style("font-size",i.iconSize()+"px").style("padding",y).style("line-height",l+"px"),x=n.append("div").attr("class","row-label").style("padding",y).style("color",r).style("background-color",t.selected?i.selectionBackgroundColor():"transparent").style("font-weight",t.bold?"bold":"normal").style("font-family",i.fontFamily()).style("font-size",i.fontSize()+"px").text(t.label).attr("title",t.label).style("flex",1).style("overflow","hidden").style("text-overflow","ellipsis").style("line-height",l+"px");n.on("mouseenter",()=>{x.style("font-weight","bold")}).on("mouseleave",()=>{x.style("font-weight",t.bold?"bold":"normal")}),m.on("mouseenter",()=>{i.weight_mouseenter(t)}).on("mouseleave",()=>{i.weight_mouseleave(t)}),t.isFolder?n.on("click",function(t){let e=this.nextSibling;const r=n.classed("folder-closed");for(r?(n.classed("folder-closed",!1),n.classed("folder-open",!0),g.attr("class","row-icon "+i.folderIconOpen())):(n.classed("folder-closed",!0),n.classed("folder-open",!1),g.attr("class","row-icon "+i.folderIconClosed()));null!==e;){u(e).datum().depth>t.depth?(e.style.display=r?"flex":"none",e=e.nextSibling):e=null}}):n.on("click",()=>{e.selectAll(".row-label").style("background-color","transparent"),e.selectAll(".row-icon").style("background-color","transparent"),g.style("background-color",i.selectionBackgroundColor()),x.style("background-color",i.selectionBackgroundColor());const n=t.label.split(".").pop().toLowerCase();i.rowClick("json"===n?JSON.stringify(JSON.parse(t.content),null,4):t.content,t.markers)})}).merge(s).style("background-color",i.backgroundColor()),s.exit().remove()}weight_mouseenter(t){}weight_mouseleave(t){}};e(Ht,"DirectoryTree");let Jt=Ht;Jt.prototype._class+=" tree_DirectoryTree",Jt.prototype._palette=h.rainbow("Blues"),Jt.prototype.publish("depthSize",14,"number","Width of indentation per file or folder depth (pixels)"),Jt.prototype.publish("paletteID","Blues","set","Color palette for the weight backgrounds",Jt.prototype._palette.switch(),{tags:["Basic"]}),Jt.prototype.publish("omitRoot",!1,"boolean","If true, root node will not display"),Jt.prototype.publish("rowItemPadding",2,"number","Top, bottom, left and right row item padding"),Jt.prototype.publish("selectionBackgroundColor","#CCC","html-color","Background color of selected directory rows"),Jt.prototype.publish("backgroundColor","#FFF","html-color","Directory item background color"),Jt.prototype.publish("fontColor","#000","html-color","Directory item font color"),Jt.prototype.publish("fontFamily","Arial","string","Directory item font family"),Jt.prototype.publish("fontSize",12,"number","Directory item font size (pixels)"),Jt.prototype.publish("iconSize",12,"number","Directory folder and file icon size (pixels)"),Jt.prototype.publish("folderIconOpen","fa fa-folder-open","string","Open folder icon class"),Jt.prototype.publish("folderIconClosed","fa fa-folder","string","Closed folder icon class"),Jt.prototype.publish("textFileIcon","fa fa-file-text-o","string","Text file icon class"),Jt.prototype.publish("verticalScroll",!0,"boolean","If true, vertical scroll bar will be shown");const Zt=class _IndentedColumn extends s{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};e(Zt,"IndentedColumn");let Xt=Zt;Xt.prototype._class+=" tree_Dendrogram.IndentedColumn",Xt.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const Yt=class _Indented extends c{Column;_d3Tree;_xml;_svgLinks;_svgNodes;_treeData;_collapsed={};constructor(){super(),n.call(this),l.SimpleSelectionMixin.call(this),this._drawStartPos="origin",this._d3Tree=At()}xmlToData(t,e=""){if(DOMParser){return Qt((new DOMParser).parseFromString(t,"text/xml"),e).children[0]}return[]}xml(t){return arguments.length?(this._xml=t,this.data(this.xmlToData(this._xml)),this):this._xml}IndentedData(){if(0===this.data().length)return[];if(this.xmlColumn_exists()){const t=this.columns().indexOf(this.xmlColumn()),e={label:this.xmlColumn(),children:this.data().map(function(e,n){return this.xmlToData(e[t],"["+n+"]")},this)};return 1===e.children.length?e.children[0]:e}if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.rollupView(this.mappings().map(function(t){return t.column()})).entries()});function t(e){if(e.values instanceof Array){const n=e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),r={label:e.key};return n.length?r.children=n:r.size=22,r}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(t,e){super.enter(t,e),this._svgLinks=this._renderElement.append("g"),this._svgNodes=this._renderElement.append("g"),this._selection.widgetElement(this._svgNodes)}_prevDataChecksum;update(t,n){super.update(t,n);const r=this;this._d3Tree.nodeSize([0,this.barHeight()]);const i=this._db.dataChecksum();function o(t){return(t.parent?o(t.parent)+".":"")+t.data.label}this._prevDataChecksum!==i&&(this._treeData=this.IndentedData(),this._prevDataChecksum=i),e(o,"getID");const a=W(this.data()).sum(function(t){return t.size||50}).each(t=>{this._collapsed[o(t)]&&delete t.children}),l=this._d3Tree(a).descendants(),s=this._d3Tree(a).descendants().slice(1);let c=0;a.eachBefore(t=>{t.x=c*r.barHeight(),++c});const h=this.barHeight()-4,p=this._renderCount?500:0,d=this._svgLinks.selectAll(".link").data(s,function(t){return o(t)});function f(t){return"M"+t.parent.y+","+t.parent.x+"V"+t.x+", H"+t.y}d.enter().append("path").attr("class","link").attr("d",f),d.transition().duration(p).attr("d",f),d.exit().remove(),e(f,"elbow");const y=this._svgNodes.selectAll(".node").data(l,function(t){return o(t)});y.transition().duration(p).attr("transform",function(t){return"translate("+t.y+","+t.x+")"});const m=y.enter().append("g").attr("class","node").attr("transform",function(t){return"translate("+t.y+","+t.x+")"}).call(this._selection.enter.bind(this._selection)).each(function(){const t=u(this);t.append("rect").attr("height",h).attr("width",h).on("click",function(t){r._collapsed[o(t)]?delete r._collapsed[o(t)]:t.children&&(r._collapsed[o(t)]=!0),r.lazyRender()}),t.append("text")}).style("opacity",0);function g(t){return r._collapsed[o(t)]?"#3182bd":t.children?"#c6dbef":"#fd8d3c"}m.transition().style("opacity",1),m.merge(y).select("rect").attr("x",-h/2).attr("y",-h/2).style("fill",g),m.merge(y).select("text").attr("dx",h/2+4+"px").attr("dy","0.33em").text(function(t){return t.data.label}),y.exit().transition().style("opacity",0).remove(),this._renderCount||r.zoomToFit(),e(g,"color")}};e(Yt,"Indented");let Kt=Yt;function Qt(t,e=""){const n={id:e,label:"",attributes:{},children:[]};if(n.label=t.nodeName,1===t.nodeType){if(t.attributes.length>0)for(let r=0;r<t.attributes.length;r++){const e=t.attributes.item(r);n.attributes[e.nodeName]=e.nodeValue}}else 3===t.nodeType&&(n.label=t.nodeValue);if(t.hasChildNodes())for(let r=0;r<t.childNodes.length;r++){const i=Qt(t.childNodes.item(r),e+"["+n.children.length+"]");n.children.push(i)}return n}Kt.prototype._class+=" tree_Indented",Kt.prototype.implements(n.prototype),Kt.prototype.mixin(l.SimpleSelectionMixin),Kt.prototype.Column=Xt,Kt.prototype.publish("xmlColumn",null,"set","Field",function(){return this.columns()},{optional:!0}),Kt.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:Xt,disable:/* @__PURE__ */e(t=>t.xmlColumn_exists(),"disable")}),Kt.prototype.publish("barHeight",16,"number","Bar height"),e(Qt,"xmlToJson");var Gt=Math.PI,Ut=2*Gt,te=1e-6,ee=Ut-te;function ne(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function re(){return new ne}function ie(t){/* @__PURE__ */
2
2
  return e(function(){return t},"constant")}e(ne,"Path"),e(re,"path"),ne.prototype=re.prototype={constructor:ne,moveTo:/* @__PURE__ */e(function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)},"moveTo"),closePath:/* @__PURE__ */e(function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},"closePath"),lineTo:/* @__PURE__ */e(function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e)},"lineTo"),quadraticCurveTo:/* @__PURE__ */e(function(t,e,n,r){this._+="Q"+ +t+","+ +e+","+(this._x1=+n)+","+(this._y1=+r)},"quadraticCurveTo"),bezierCurveTo:/* @__PURE__ */e(function(t,e,n,r,i,o){this._+="C"+ +t+","+ +e+","+ +n+","+ +r+","+(this._x1=+i)+","+(this._y1=+o)},"bezierCurveTo"),arcTo:/* @__PURE__ */e(function(t,e,n,r,i){t=+t,e=+e,n=+n,r=+r,i=+i;var o=this._x1,a=this._y1,l=n-t,s=r-e,c=o-t,u=a-e,h=c*c+u*u;if(i<0)throw new Error("negative radius: "+i);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(h>te)if(Math.abs(u*l-s*c)>te&&i){var p=n-o,d=r-a,f=l*l+s*s,y=p*p+d*d,m=Math.sqrt(f),g=Math.sqrt(h),x=i*Math.tan((Gt-Math.acos((f+h-y)/(2*m*g)))/2),_=x/g,b=x/m;Math.abs(_-1)>te&&(this._+="L"+(t+_*c)+","+(e+_*u)),this._+="A"+i+","+i+",0,0,"+ +(u*p>c*d)+","+(this._x1=t+b*l)+","+(this._y1=e+b*s)}else this._+="L"+(this._x1=t)+","+(this._y1=e);else;},"arcTo"),arc:/* @__PURE__ */e(function(t,e,n,r,i,o){t=+t,e=+e,o=!!o;var a=(n=+n)*Math.cos(r),l=n*Math.sin(r),s=t+a,c=e+l,u=1^o,h=o?r-i:i-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+s+","+c:(Math.abs(this._x1-s)>te||Math.abs(this._y1-c)>te)&&(this._+="L"+s+","+c),n&&(h<0&&(h=h%Ut+Ut),h>ee?this._+="A"+n+","+n+",0,1,"+u+","+(t-a)+","+(e-l)+"A"+n+","+n+",0,1,"+u+","+(this._x1=s)+","+(this._y1=c):h>te&&(this._+="A"+n+","+n+",0,"+ +(h>=Gt)+","+u+","+(this._x1=t+n*Math.cos(i))+","+(this._y1=e+n*Math.sin(i))))},"arc"),rect:/* @__PURE__ */e(function(t,e,n,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},"rect"),toString:/* @__PURE__ */e(function(){return this._},"toString")},e(ie,"constant");var oe=Math.abs,ae=Math.atan2,le=Math.cos,se=Math.max,ce=Math.min,ue=Math.sin,he=Math.sqrt,pe=1e-12,de=Math.PI,fe=de/2,ye=2*de;function me(t){return t>1?0:t<-1?de:Math.acos(t)}function ge(t){return t>=1?fe:t<=-1?-fe:Math.asin(t)}function xe(t){return t.innerRadius}function _e(t){return t.outerRadius}function be(t){return t.startAngle}function ve(t){return t.endAngle}function we(t){return t&&t.padAngle}function Se(t,e,n,r,i,o,a,l){var s=n-t,c=r-e,u=a-i,h=l-o,p=h*s-u*c;if(!(p*p<pe))return[t+(p=(u*(e-o)-h*(t-i))/p)*s,e+p*c]}function ze(t,e,n,r,i,o,a){var l=t-n,s=e-r,c=(a?o:-o)/he(l*l+s*s),u=c*s,h=-c*l,p=t+u,d=e+h,f=n+u,y=r+h,m=(p+f)/2,g=(d+y)/2,x=f-p,_=y-d,b=x*x+_*_,v=i-o,w=p*y-f*d,S=(_<0?-1:1)*he(se(0,v*v*b-w*w)),z=(w*_-x*S)/b,C=(-w*x-_*S)/b,k=(w*_+x*S)/b,M=(-w*x+_*S)/b,T=z-m,D=C-g,A=k-m,I=M-g;return T*T+D*D>A*A+I*I&&(z=k,C=M),{cx:z,cy:C,x01:-u,y01:-h,x11:z*(i/v-1),y11:C*(i/v-1)}}function Ce(){var t=xe,n=_e,r=ie(0),i=null,o=be,a=ve,l=we,s=null;function c(){var e,c,u=+t.apply(this,arguments),h=+n.apply(this,arguments),p=o.apply(this,arguments)-fe,d=a.apply(this,arguments)-fe,f=oe(d-p),y=d>p;if(s||(s=e=re()),h<u&&(c=h,h=u,u=c),h>pe)if(f>ye-pe)s.moveTo(h*le(p),h*ue(p)),s.arc(0,0,h,p,d,!y),u>pe&&(s.moveTo(u*le(d),u*ue(d)),s.arc(0,0,u,d,p,y));else{var m,g,x=p,_=d,b=p,v=d,w=f,S=f,z=l.apply(this,arguments)/2,C=z>pe&&(i?+i.apply(this,arguments):he(u*u+h*h)),k=ce(oe(h-u)/2,+r.apply(this,arguments)),M=k,T=k;if(C>pe){var D=ge(C/u*ue(z)),A=ge(C/h*ue(z));(w-=2*D)>pe?(b+=D*=y?1:-1,v-=D):(w=0,b=v=(p+d)/2),(S-=2*A)>pe?(x+=A*=y?1:-1,_-=A):(S=0,x=_=(p+d)/2)}var I=h*le(x),R=h*ue(x),P=u*le(v),L=u*ue(v);if(k>pe){var B,E=h*le(_),N=h*ue(_),q=u*le(b),F=u*ue(b);if(f<de&&(B=Se(I,R,q,F,E,N,P,L))){var O=I-B[0],V=R-B[1],W=E-B[0],$=N-B[1],j=1/ue(me((O*W+V*$)/(he(O*O+V*V)*he(W*W+$*$)))/2),H=he(B[0]*B[0]+B[1]*B[1]);M=ce(k,(u-H)/(j-1)),T=ce(k,(h-H)/(j+1))}}S>pe?T>pe?(m=ze(q,F,I,R,h,T,y),g=ze(E,N,P,L,h,T,y),s.moveTo(m.cx+m.x01,m.cy+m.y01),T<k?s.arc(m.cx,m.cy,T,ae(m.y01,m.x01),ae(g.y01,g.x01),!y):(s.arc(m.cx,m.cy,T,ae(m.y01,m.x01),ae(m.y11,m.x11),!y),s.arc(0,0,h,ae(m.cy+m.y11,m.cx+m.x11),ae(g.cy+g.y11,g.cx+g.x11),!y),s.arc(g.cx,g.cy,T,ae(g.y11,g.x11),ae(g.y01,g.x01),!y))):(s.moveTo(I,R),s.arc(0,0,h,x,_,!y)):s.moveTo(I,R),u>pe&&w>pe?M>pe?(m=ze(P,L,E,N,u,-M,y),g=ze(I,R,q,F,u,-M,y),s.lineTo(m.cx+m.x01,m.cy+m.y01),M<k?s.arc(m.cx,m.cy,M,ae(m.y01,m.x01),ae(g.y01,g.x01),!y):(s.arc(m.cx,m.cy,M,ae(m.y01,m.x01),ae(m.y11,m.x11),!y),s.arc(0,0,u,ae(m.cy+m.y11,m.cx+m.x11),ae(g.cy+g.y11,g.cx+g.x11),y),s.arc(g.cx,g.cy,M,ae(g.y11,g.x11),ae(g.y01,g.x01),!y))):s.arc(0,0,u,v,b,y):s.lineTo(P,L)}else s.moveTo(0,0);if(s.closePath(),e)return s=null,e+""||null}return e(c,"arc"),c.centroid=function(){var e=(+t.apply(this,arguments)+ +n.apply(this,arguments))/2,r=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-de/2;return[le(r)*e,ue(r)*e]},c.innerRadius=function(e){return arguments.length?(t="function"==typeof e?e:ie(+e),c):t},c.outerRadius=function(t){return arguments.length?(n="function"==typeof t?t:ie(+t),c):n},c.cornerRadius=function(t){return arguments.length?(r="function"==typeof t?t:ie(+t),c):r},c.padRadius=function(t){return arguments.length?(i=null==t?null:"function"==typeof t?t:ie(+t),c):i},c.startAngle=function(t){return arguments.length?(o="function"==typeof t?t:ie(+t),c):o},c.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:ie(+t),c):a},c.padAngle=function(t){return arguments.length?(l="function"==typeof t?t:ie(+t),c):l},c.context=function(t){return arguments.length?(s=null==t?null:t,c):s},c}e(me,"acos"),e(ge,"asin"),e(xe,"arcInnerRadius"),e(_e,"arcOuterRadius"),e(be,"arcStartAngle"),e(ve,"arcEndAngle"),e(we,"arcPadAngle"),e(Se,"intersect"),e(ze,"cornerTangents"),e(Ce,"d3Arc");const ke=class _SunburstPartition extends r{svg;radius;_xScale;_yScale;partition;arc;_resetRoot;constructor(){super(),n.call(this)}data(t){const e=r.prototype.data.apply(this,arguments);return arguments.length&&(this._resetRoot=!0),e}enter(t,e){const n=this;this.radius=Math.min(this.width(),this.height())/2,this._xScale=y().range([0,2*Math.PI]),this._yScale=m().range([0,this.radius]),this.partition=vt(),this.arc=Ce().startAngle(function(t){return Math.max(0,Math.min(2*Math.PI,n._xScale(t.x0)))}).endAngle(function(t){return Math.max(0,Math.min(2*Math.PI,n._xScale(t.x1)))}).innerRadius(function(t){return Math.max(0,n._yScale(t.y0))}).outerRadius(function(t){return Math.max(0,n._yScale(t.y1))}),this.svg=e.append("g")}update(t,e){const n=this;this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this.radius=Math.min(this.width(),this.height())/2,this._yScale.range([0,this.radius]);const r=W(this.data()).sum(function(t){return void 0!==t.size?t.size:1}),i=this.svg.selectAll("path").data(this.partition(r).descendants(),function(t,e){return void 0!==t.data.label?t.data.label:e});i.enter().append("path").on("click",function(t){n.click(t.data,null,null)}).on("dblclick",function(t){const e=o();e&&e.stopPropagation(),n.zoomTo(t)}).each(function(){u(this).append("title")}).merge(i).attr("d",this.arc).style("fill",function(t){return t.data.__viz_fill?t.data.__viz_fill:n._palette(t.data.label)}).style("stroke",function(t){return t.value>16?"white":"none"}).select("title").text(function(t){return t.data.label}),i.exit().remove(),this._resetRoot&&(this._resetRoot=!1,this.zoomTo(r))}zoomTo(t){const e=this;this.svg.transition().duration(750).tween("scale",function(){const n=g(e._xScale.domain(),[t.x0,t.x1]),r=g(e._yScale.domain(),[t.y0,1]),i=g(e._yScale.range(),[t.y0?20:0,e.radius]);return function(t){e._xScale.domain(n(t)),e._yScale.domain(r(t)).range(i(t))}}).selectAll("path").attrTween("d",function(t){return function(){return e.arc(t)}})}};e(ke,"SunburstPartition");let Me=ke;Me.prototype._class+=" tree_SunburstPartition",Me.prototype.implements(n.prototype),Me.prototype.publish("paletteID","default","set","Color palette for this widget",Me.prototype._palette.switch(),{tags:["Basic","Shared"]}),Me.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]});const Te=class _TreemapColumn extends s{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};e(Te,"TreemapColumn");let De=Te;De.prototype._class+=" tree_Dendrogram.TreemapColumn",De.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const Ae=class _Treemap extends p{Column;_d3Treemap;_elementDIV;_selection;constructor(){super(),n.call(this),l.SimpleSelectionMixin.call(this,!0)}getTilingMethod(){switch(this.tilingMethod()){case"treemapBinary":return Et;case"treemapDice":return bt;case"treemapSlice":return It;case"treemapSliceDice":return Nt;case"treemapResquarify":return qt;default:return Lt}}treemapData(){if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.aggregateView(this.mappings().map(function(t){return t.column()}),this.aggrType(),this.aggrColumn()).entries()});function t(e){if(e.values instanceof Array){const n=e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),r={label:e.key};return n.length?r.children=n:r.size=22,r}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(t,e){super.enter(t,e),this._d3Treemap=Bt(),this._elementDIV=e.append("div"),this._selection.widgetElement(this._elementDIV)}update(t,n){super.update(t,n);const r=this;this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id()));const o=W(this.treemapData()).sum(this.nodeWeight);this._d3Treemap.size([this.width(),this.height()]).paddingInner(this.paddingInner()).paddingOuter(this.paddingOuter()).paddingTop(this.paddingTop()),-1!==["treemapSquarify","treemapResquarify"].indexOf(this.tilingMethod())?this._d3Treemap.tile(this.getTilingMethod().ratio(this.squarifyRatio())):this._d3Treemap.tile(this.getTilingMethod()),this._d3Treemap(o),this._elementDIV.style("font-size",this.fontSize_exists()?this.fontSize()+"px":null).style("line-height",this.fontSize_exists()?this.fontSize()+2+"px":null);const a=this._elementDIV.selectAll(".node").data(o.descendants());function l(t){if(t.children&&!r.enableParentTooltips())return null;let e=t.data.label+" ("+t.value+")";for(;t.parent&&t.parent.parent;)e=t.parent.data.label+" -> "+e,t=t.parent;return e}a.enter().append("div").attr("class","node").call(this._selection.enter.bind(this._selection)).on("click",function(t){if(t){let e="";r.mappings().forEach(function(t){t.column()&&(e=t.column())}),t.origRows?r.click(r.rowToObj(t.origRows[0]),e,r._selection.selected(this)):r.click(t.data,e,r._selection.selected(this))}}).on("dblclick",function(t){if(t){let e="";r.mappings().forEach(function(t){t.column()&&(e=t.column())}),t.origRows?r.dblclick(r.rowToObj(t.origRows[0]),e,r._selection.selected(this)):r.dblclick(t.data,e,r._selection.selected(this))}}).merge(a).style("left",function(t){return t.x0+Math.max(0,t.x1-t.x0)/2+"px"}).style("top",function(t){return t.y0+Math.max(0,t.y1-t.y0)/2+"px"}).style("width",function(){return"0px"}).style("height",function(){return"0px"}).style("font-size",function(t){return(t.children?r.parentFontSize():r.leafFontSize())+"px"}).style("line-height",function(t){return(t.children?r.parentFontSize():r.leafFontSize())+"px"}).attr("title",l).html(function(t){return r.showRoot()||0!==t.depth?t.children?r.enableParentLabels()?r.parentWeightHTML(t):null:r.leafWeightHTML(t):null}).style("background",function(t){if(!r.showRoot()&&0===t.depth)return this.style.color="transparent","transparent";const e=r.brighterLeafNodes()?"brighter":"darker";let n;return r.usePaletteOnParentNodes()?n=t.children?r._palette(t.data.label):i(r._palette(t.parent.data.label))[e](1):(n=t.depth>r.depthColorLimit()?i(t.parent.color)[e](1):r._palette(t.data.label),t.color=n),this.style.color=h.textColor(n),n}).transition().duration(this.transitionDuration()).style("pointer-events",function(t){return r.showRoot()||0!==t.depth?"all":"none"}).style("opacity",function(t){return t.children?1:null}).style("left",function(t){return t.x0+"px"}).style("top",function(t){return t.y0+"px"}).style("width",function(t){return Math.max(0,t.x1-t.x0)+"px"}).style("height",function(t){return Math.max(0,t.y1-t.y0)+"px"}).each(function(t){0===t.depth&&(this.style.color=r.showRoot()?"":"transparent",this.style.borderColor=r.showRoot()?"":"transparent")}),a.exit().transition().duration(this.transitionDuration()).style("opacity",0).remove(),e(l,"tooltip")}exit(t,e){super.exit(t,e)}nodeWeight(t){return t.size||1}parentWeightHTML(t){return this.showParentWeight()?`<span class="treemap-parent-label">${t.data.label}</span><span class="treemap-parent-value">${t.value}${this.weightSuffix()}</span>`:`<span class="treemap-parent-label">${t.data.label}</span>`}leafWeightHTML(t){return this.showLeafWeight()?`<span class="treemap-leaf-label">${t.data.label}</span><span class="treemap-leaf-value">${t.value}${this.weightSuffix()}</span>`:`<span class="treemap-leaf-label">${t.data.label}</span>`}};e(Ae,"Treemap");let Ie=Ae;Ie.prototype._class+=" tree_Treemap",Ie.prototype.implements(n.prototype),Ie.prototype.mixin(l.SimpleSelectionMixin),Ie.prototype.Column=De,Ie.prototype.publish("paletteID","default","set","Color palette for this widget",Ie.prototype._palette.switch(),{tags:["Basic","Shared"]}),Ie.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]}),Ie.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:De}),Ie.prototype.publish("aggrType",null,"set","Aggregation Type",[null,"mean","median","sum","min","max"],{optional:!0}),Ie.prototype.publish("aggrColumn",null,"set","Aggregation Field",function(){return this.columns()},{optional:!0,disable:/* @__PURE__ */e(t=>!t.aggrType(),"disable")}),Ie.prototype.publish("fontSize",null,"number","Font Size",null,{optional:!0}),Ie.prototype.publish("paddingInner",18.6,"number","Pixel spacing between each sibling node"),Ie.prototype.publish("paddingOuter",30,"number","Pixel padding of parent nodes"),Ie.prototype.publish("paddingTop",41.4,"number","Additional top pixel padding of parent nodes"),Ie.prototype.publish("showRoot",!1,"boolean","Show root element"),Ie.prototype.publish("parentFontSize",18,"number","Parent font-size"),Ie.prototype.publish("leafFontSize",16,"number","Leaf font-size"),Ie.prototype.publish("usePaletteOnParentNodes",!1,"boolean","Assign a color from the palette to every parent node"),Ie.prototype.publish("depthColorLimit",1,"number","Assign a color from the palette to node with depth lower than this value",null,{optional:!0,disable:/* @__PURE__ */e(t=>t.usePaletteOnParentNodes(),"disable")}),Ie.prototype.publish("squarifyRatio",1,"number","Specifies the desired aspect ratio of the generated rectangles (must be >= 1)",null,{optional:!0,disable:/* @__PURE__ */e(t=>-1===["treemapSquarify","treemapResquarify"].indexOf(t.tilingMethod()),"disable")}),Ie.prototype.publish("showParentWeight",!0,"boolean","Show weight of parent nodes"),Ie.prototype.publish("showLeafWeight",!0,"boolean","Show weight of leaf nodes"),Ie.prototype.publish("weightSuffix","","string","Weight suffix (ex: 'ms')"),Ie.prototype.publish("brighterLeafNodes",!1,"boolean","Brighter/darker leaf node color (false = darker)"),Ie.prototype.publish("enableParentLabels",!0,"boolean","Enable parent labels"),Ie.prototype.publish("enableParentTooltips",!0,"boolean","Enable parent tooltips"),Ie.prototype.publish("transitionDuration",250,"number","Transition Duration"),Ie.prototype.publish("tilingMethod","treemapSquarify","set","Transition Duration",["treemapBinary","treemapDice","treemapResquarify","treemapSlice","treemapSliceDice","treemapSquarify"]);export{b as BUILD_VERSION,Ot as CirclePacking,jt as Dendrogram,Wt as DendrogramColumn,Jt as DirectoryTree,Kt as Indented,Xt as IndentedColumn,x as PKG_NAME,_ as PKG_VERSION,Me as SunburstPartition,Ie as Treemap,De as TreemapColumn};
3
3
  //# sourceMappingURL=index.js.map
4
4
  !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".tree_CirclePacking circle{fill:#1f77b4;fill-opacity:.25;stroke:#1f77b4;stroke-width:1px}.tree_CirclePacking .leaf circle{fill:#ff7f0e;fill-opacity:1}.tree_CirclePacking .label{fill:#fff;text-anchor:middle}.tree_Dendrogram .node circle{fill:#dcf1ff;stroke:#1f77b4;stroke-width:1px}.tree_Dendrogram .node.selected circle{stroke:red}.tree_Dendrogram .node.over circle{stroke:orange}.tree_Dendrogram .node.selected.over circle{stroke:red}.tree_Dendrogram .node.selected text{fill:red}.tree_Dendrogram .node.over text{fill:orange}.tree_Dendrogram .node.selected.over text{fill:red}.tree_Dendrogram .node text{font-size:14px}.tree_Dendrogram .link{fill:none;stroke:#656565;stroke-width:1px}.tree_Indented .node rect{cursor:pointer;fill:#fff;stroke:#3182bd;stroke-width:1px}.tree_Indented .node text{font:10px sans-serif;pointer-events:none}.tree_Indented path.link{fill:none;stroke:#9ecae1;stroke-width:1.5px}.tree_Sunburst path{stroke:#fff;stroke-width:.5px;fill-rule:evenodd}.tree_Treemap *{box-sizing:border-box}.tree_Treemap .node{border:solid 1px #333;overflow:hidden;text-overflow:ellipsis;position:absolute}.tree_Treemap .node.selected{border-color:red}.tree_Treemap .node.over{border-color:orange}.tree_Treemap .node.selected.over{border-color:red}.tree_Treemap .node>span.treemap-parent-label{font-weight:700;display:inline-block;margin:4px 4px 0}.tree_Treemap .node>span.treemap-parent-value{font-weight:400;font-style:italic;margin:4px 0 0}.tree_Treemap .node>span.treemap-singleton-label{font-weight:400;display:block;margin:4px 0 0 4px}.tree_Treemap .node>span.treemap-singleton-value{font-style:italic;display:block;margin:0 0 0 4px}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}}();
@@ -1,3 +1,3 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@hpcc-js/api"),require("@hpcc-js/common")):"function"==typeof define&&define.amd?define(["exports","@hpcc-js/api","@hpcc-js/common"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@hpcc-js/tree"]={},t["@hpcc-js/api"],t["@hpcc-js/common"])}(this,function(t,e,n){"use strict";var r=Object.defineProperty,i=(t,e)=>r(t,"name",{value:e,configurable:!0});function o(t,e){return t.parent===e.parent?1:2}function a(t){return t.reduce(l,0)/t.length}function l(t,e){return t+e.x}function s(t){return 1+t.reduce(c,0)}function c(t,e){return Math.max(t,e.y)}function u(t){for(var e;e=t.children;)t=e[0];return t}function h(t){for(var e;e=t.children;)t=e[e.length-1];return t}function p(){var t=o,e=1,n=1,r=!1;function l(i){var o,l=0;i.eachAfter(function(e){var n=e.children;n?(e.x=a(n),e.y=s(n)):(e.x=o?l+=t(e,o):0,e.y=0,o=e)});var c=u(i),p=h(i),d=c.x-t(c,p)/2,f=p.x+t(p,c)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*e,t.y=(i.y-t.y)*n}:function(t){t.x=(t.x-d)/(f-d)*e,t.y=(1-(i.y?t.y/i.y:1))*n})}return i(l,"cluster"),l.separation=function(e){return arguments.length?(t=e,l):t},l.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],l):r?null:[e,n]},l.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],l):r?[e,n]:null},l}function d(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function f(){return this.eachAfter(d)}function y(t){var e,n,r,i,o=this,a=[o];do{for(e=a.reverse(),a=[];o=e.pop();)if(t(o),n=o.children)for(r=0,i=n.length;r<i;++r)a.push(n[r])}while(a.length);return this}function m(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this}function g(t){for(var e,n,r,i=this,o=[i],a=[];i=o.pop();)if(a.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)o.push(e[n]);for(;i=a.pop();)t(i);return this}function x(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 _(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function b(t){for(var e=this,n=v(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 v(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 w(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function S(){var t=[];return this.each(function(e){t.push(e)}),t}function T(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function C(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function z(t,e){var n,r,i,o,a,l=new A(t),s=+t.value&&(l.value=t.value),c=[l];for(null==e&&(e=k);n=c.pop();)if(s&&(n.value=+n.data.value),(i=e(n.data))&&(a=i.length))for(n.children=new Array(a),o=a-1;o>=0;--o)c.push(r=n.children[o]=new A(i[o])),r.parent=n,r.depth=n.depth+1;return l.eachBefore(I)}function M(){return z(this).eachBefore(D)}function k(t){return t.children}function D(t){t.data=t.data.data}function I(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function A(t){this.data=t,this.depth=this.height=0,this.parent=null}i(o,"defaultSeparation$1"),i(a,"meanX"),i(l,"meanXReduce"),i(s,"maxY"),i(c,"maxYReduce"),i(u,"leafLeft"),i(h,"leafRight"),i(p,"d3Cluster"),i(d,"count"),i(f,"node_count"),i(y,"node_each"),i(m,"node_eachBefore"),i(g,"node_eachAfter"),i(x,"node_sum"),i(_,"node_sort"),i(b,"node_path"),i(v,"leastCommonAncestor"),i(w,"node_ancestors"),i(S,"node_descendants"),i(T,"node_leaves"),i(C,"node_links"),i(z,"hierarchy"),i(M,"node_copy"),i(k,"defaultChildren"),i(D,"copyData"),i(I,"computeHeight"),i(A,"Node$1"),A.prototype=z.prototype={constructor:A,count:f,each:y,eachAfter:g,eachBefore:m,sum:x,sort:_,path:b,ancestors:w,descendants:S,leaves:T,links:C,copy:M};var P=Array.prototype.slice;function R(t){for(var e,n,r=t.length;r;)n=Math.random()*r--|0,e=t[r],t[r]=t[n],t[n]=e;return t}function L(t){for(var e,n,r=0,i=(t=R(P.call(t))).length,o=[];r<i;)e=t[r],n&&N(n,e)?++r:(n=O(o=B(o,e)),r=0);return n}function B(t,e){var n,r;if(q(e,t))return[e];for(n=0;n<t.length;++n)if(E(e,t[n])&&q(F(t[n],e),t))return[t[n],e];for(n=0;n<t.length-1;++n)for(r=n+1;r<t.length;++r)if(E(F(t[n],t[r]),e)&&E(F(t[n],e),t[r])&&E(F(t[r],e),t[n])&&q(W(t[n],t[r],e),t))return[t[n],t[r],e];throw new Error}function E(t,e){var n=t.r-e.r,r=e.x-t.x,i=e.y-t.y;return n<0||n*n<r*r+i*i}function N(t,e){var n=t.r-e.r+1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function q(t,e){for(var n=0;n<e.length;++n)if(!N(t,e[n]))return!1;return!0}function O(t){switch(t.length){case 1:return V(t[0]);case 2:return F(t[0],t[1]);case 3:return W(t[0],t[1],t[2])}}function V(t){return{x:t.x,y:t.y,r:t.r}}function F(t,e){var n=t.x,r=t.y,i=t.r,o=e.x,a=e.y,l=e.r,s=o-n,c=a-r,u=l-i,h=Math.sqrt(s*s+c*c);return{x:(n+o+s/h*u)/2,y:(r+a+c/h*u)/2,r:(h+i+l)/2}}function W(t,e,n){var r=t.x,i=t.y,o=t.r,a=e.x,l=e.y,s=e.r,c=n.x,u=n.y,h=n.r,p=r-a,d=r-c,f=i-l,y=i-u,m=s-o,g=h-o,x=r*r+i*i-o*o,_=x-a*a-l*l+s*s,b=x-c*c-u*u+h*h,v=d*f-p*y,w=(f*b-y*_)/(2*v)-r,S=(y*m-f*g)/v,T=(d*_-p*b)/(2*v)-i,C=(p*g-d*m)/v,z=S*S+C*C-1,M=2*(o+w*S+T*C),k=w*w+T*T-o*o,D=-(z?(M+Math.sqrt(M*M-4*z*k))/(2*z):k/M);return{x:r+w+S*D,y:i+T+C*D,r:D}}function j(t,e,n){var r,i,o,a,l=t.x-e.x,s=t.y-e.y,c=l*l+s*s;c?(i=e.r+n.r,i*=i,a=t.r+n.r,i>(a*=a)?(r=(c+a-i)/(2*c),o=Math.sqrt(Math.max(0,a/c-r*r)),n.x=t.x-r*l-o*s,n.y=t.y-r*s+o*l):(r=(c+i-a)/(2*c),o=Math.sqrt(Math.max(0,i/c-r*r)),n.x=e.x+r*l-o*s,n.y=e.y+r*s+o*l)):(n.x=e.x+n.r,n.y=e.y)}function $(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function H(t){var e=t._,n=t.next._,r=e.r+n.r,i=(e.x*n.r+n.x*e.r)/r,o=(e.y*n.r+n.y*e.r)/r;return i*i+o*o}function U(t){this._=t,this.next=null,this.previous=null}function G(t){if(!(i=t.length))return 0;var e,n,r,i,o,a,l,s,c,u,h;if((e=t[0]).x=0,e.y=0,!(i>1))return e.r;if(n=t[1],e.x=-n.r,n.x=e.r,n.y=0,!(i>2))return e.r+n.r;j(n,e,r=t[2]),e=new U(e),n=new U(n),r=new U(r),e.next=r.previous=n,n.next=e.previous=r,r.next=n.previous=e;t:for(l=3;l<i;++l){j(e._,n._,r=t[l]),r=new U(r),s=n.next,c=e.previous,u=n._.r,h=e._.r;do{if(u<=h){if($(s._,r._)){n=s,e.next=n,n.previous=e,--l;continue t}u+=s._.r,s=s.next}else{if($(c._,r._)){(e=c).next=n,n.previous=e,--l;continue t}h+=c._.r,c=c.previous}}while(s!==c.next);for(r.previous=e,r.next=n,e.next=n.previous=n=r,o=H(e);(r=r.next)!==n;)(a=H(r))<o&&(e=r,o=a);n=e.next}for(e=[n._],r=n;(r=r.next)!==n;)e.push(r._);for(r=L(e),l=0;l<i;++l)(e=t[l]).x-=r.x,e.y-=r.y;return r.r}function Z(t){return null==t?null:J(t)}function J(t){if("function"!=typeof t)throw new Error;return t}function K(){return 0}function X(t){return function(){return t}}function Y(t){return Math.sqrt(t.value)}function Q(){var t=null,e=1,n=1,r=K;function o(i){return i.x=e/2,i.y=n/2,t?i.eachBefore(tt(t)).eachAfter(et(r,.5)).eachBefore(nt(1)):i.eachBefore(tt(Y)).eachAfter(et(K,1)).eachAfter(et(r,i.r/Math.min(e,n))).eachBefore(nt(Math.min(e,n)/(2*i.r))),i}return i(o,"pack"),o.radius=function(e){return arguments.length?(t=Z(e),o):t},o.size=function(t){return arguments.length?(e=+t[0],n=+t[1],o):[e,n]},o.padding=function(t){return arguments.length?(r="function"==typeof t?t:X(+t),o):r},o}function tt(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0))}}function et(t,e){return function(n){if(r=n.children){var r,i,o,a=r.length,l=t(n)*e||0;if(l)for(i=0;i<a;++i)r[i].r+=l;if(o=G(r),l)for(i=0;i<a;++i)r[i].r-=l;n.r=o+l}}}function nt(t){return function(e){var n=e.parent;e.r*=t,n&&(e.x=n.x+t*e.x,e.y=n.y+t*e.y)}}function rt(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function it(t,e,n,r,i){for(var o,a=t.children,l=-1,s=a.length,c=t.value&&(r-e)/t.value;++l<s;)(o=a[l]).y0=n,o.y1=i,o.x0=e,o.x1=e+=o.value*c}function ot(){var t=1,e=1,n=0,r=!1;function o(i){var o=i.height+1;return i.x0=i.y0=n,i.x1=t,i.y1=e/o,i.eachBefore(a(e,o)),r&&i.eachBefore(rt),i}function a(t,e){return function(r){r.children&&it(r,r.x0,t*(r.depth+1)/e,r.x1,t*(r.depth+2)/e);var i=r.x0,o=r.y0,a=r.x1-n,l=r.y1-n;a<i&&(i=a=(i+a)/2),l<o&&(o=l=(o+l)/2),r.x0=i,r.y0=o,r.x1=a,r.y1=l}}return i(o,"partition"),i(a,"positionNode"),o.round=function(t){return arguments.length?(r=!!t,o):r},o.size=function(n){return arguments.length?(t=+n[0],e=+n[1],o):[t,e]},o.padding=function(t){return arguments.length?(n=+t,o):n},o}function at(t,e){return t.parent===e.parent?1:2}function lt(t){var e=t.children;return e?e[0]:t.t}function st(t){var e=t.children;return e?e[e.length-1]:t.t}function ct(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 ut(t){for(var e,n=0,r=0,i=t.children,o=i.length;--o>=0;)(e=i[o]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}function ht(t,e,n){return t.a.parent===e.parent?t.a:n}function pt(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}function dt(t){for(var e,n,r,i,o,a=new pt(t,0),l=[a];e=l.pop();)if(r=e._.children)for(e.children=new Array(o=r.length),i=o-1;i>=0;--i)l.push(n=e.children[i]=new pt(r[i],i)),n.parent=e;return(a.parent=new pt(null,0)).children=[a],a}function ft(){var t=at,e=1,n=1,r=null;function o(i){var o=dt(i);if(o.eachAfter(a),o.parent.m=-o.z,o.eachBefore(l),r)i.eachBefore(c);else{var s=i,u=i,h=i;i.eachBefore(function(t){t.x<s.x&&(s=t),t.x>u.x&&(u=t),t.depth>h.depth&&(h=t)});var p=s===u?1:t(s,u)/2,d=p-s.x,f=e/(u.x+p+d),y=n/(h.depth||1);i.eachBefore(function(t){t.x=(t.x+d)*f,t.y=t.depth*y})}return i}function a(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){ut(e);var o=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-o):e.z=o}else i&&(e.z=i.z+t(e._,i._));e.parent.A=s(e,i,e.parent.A||r[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(e,n,r){if(n){for(var i,o=e,a=e,l=n,s=o.parent.children[0],c=o.m,u=a.m,h=l.m,p=s.m;l=st(l),o=lt(o),l&&o;)s=lt(s),(a=st(a)).a=e,(i=l.z+h-o.z-c+t(l._,o._))>0&&(ct(ht(l,e,r),e,i),c+=i,u+=i),h+=l.m,c+=o.m,p+=s.m,u+=a.m;l&&!st(a)&&(a.t=l,a.m+=h-u),o&&!lt(s)&&(s.t=o,s.m+=c-p,r=e)}return r}function c(t){t.x*=e,t.y=t.depth*n}return i(o,"tree"),i(a,"firstWalk"),i(l,"secondWalk"),i(s,"apportion"),i(c,"sizeNode"),o.separation=function(e){return arguments.length?(t=e,o):t},o.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],o):r?null:[e,n]},o.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],o):r?[e,n]:null},o}function yt(t,e,n,r,i){for(var o,a=t.children,l=-1,s=a.length,c=t.value&&(i-n)/t.value;++l<s;)(o=a[l]).x0=e,o.x1=r,o.y0=n,o.y1=n+=o.value*c}i(R,"shuffle"),i(L,"enclose"),i(B,"extendBasis"),i(E,"enclosesNot"),i(N,"enclosesWeak"),i(q,"enclosesWeakAll"),i(O,"encloseBasis"),i(V,"encloseBasis1"),i(F,"encloseBasis2"),i(W,"encloseBasis3"),i(j,"place"),i($,"intersects"),i(H,"score"),i(U,"Node"),i(G,"packEnclose"),i(Z,"optional"),i(J,"required"),i(K,"constantZero"),i(X,"constant$1"),i(Y,"defaultRadius"),i(Q,"d3Pack"),i(tt,"radiusLeaf"),i(et,"packChildren"),i(nt,"translateChild"),i(rt,"roundNode"),i(it,"d3treemapDice"),i(ot,"d3Parition"),i(at,"defaultSeparation"),i(lt,"nextLeft"),i(st,"nextRight"),i(ct,"moveSubtree"),i(ut,"executeShifts"),i(ht,"nextAncestor"),i(pt,"TreeNode"),pt.prototype=Object.create(A.prototype),i(dt,"treeRoot"),i(ft,"d3Tree"),i(yt,"d3treemapSlice");var mt=(1+Math.sqrt(5))/2;function gt(t,e,n,r,i,o){for(var a,l,s,c,u,h,p,d,f,y,m,g=[],x=e.children,_=0,b=0,v=x.length,w=e.value;_<v;){s=i-n,c=o-r;do{u=x[b++].value}while(!u&&b<v);for(h=p=u,m=u*u*(y=Math.max(c/s,s/c)/(w*t)),f=Math.max(p/m,m/h);b<v;++b){if(u+=l=x[b].value,l<h&&(h=l),l>p&&(p=l),m=u*u*y,(d=Math.max(p/m,m/h))>f){u-=l;break}f=d}g.push(a={value:u,dice:s<c,children:x.slice(_,b)}),a.dice?it(a,n,r,i,w?r+=c*u/w:o):yt(a,n,r,w?n+=s*u/w:i,o),w-=u,_=b}return g}i(gt,"squarifyRatio");const xt=i(function t(e){function n(t,n,r,i,o){gt(e,t,n,r,i,o)}return i(n,"squarify"),n.ratio=function(e){return t((e=+e)>1?e:1)},n},"custom")(mt);function _t(){var t=xt,e=!1,n=1,r=1,o=[0],a=K,l=K,s=K,c=K,u=K;function h(t){return t.x0=t.y0=0,t.x1=n,t.y1=r,t.eachBefore(p),o=[0],e&&t.eachBefore(rt),t}function p(e){var n=o[e.depth],r=e.x0+n,i=e.y0+n,h=e.x1-n,p=e.y1-n;h<r&&(r=h=(r+h)/2),p<i&&(i=p=(i+p)/2),e.x0=r,e.y0=i,e.x1=h,e.y1=p,e.children&&(n=o[e.depth+1]=a(e)/2,r+=u(e)-n,i+=l(e)-n,(h-=s(e)-n)<r&&(r=h=(r+h)/2),(p-=c(e)-n)<i&&(i=p=(i+p)/2),t(e,r,i,h,p))}return i(h,"treemap"),i(p,"positionNode"),h.round=function(t){return arguments.length?(e=!!t,h):e},h.size=function(t){return arguments.length?(n=+t[0],r=+t[1],h):[n,r]},h.tile=function(e){return arguments.length?(t=J(e),h):t},h.padding=function(t){return arguments.length?h.paddingInner(t).paddingOuter(t):h.paddingInner()},h.paddingInner=function(t){return arguments.length?(a="function"==typeof t?t:X(+t),h):a},h.paddingOuter=function(t){return arguments.length?h.paddingTop(t).paddingRight(t).paddingBottom(t).paddingLeft(t):h.paddingTop()},h.paddingTop=function(t){return arguments.length?(l="function"==typeof t?t:X(+t),h):l},h.paddingRight=function(t){return arguments.length?(s="function"==typeof t?t:X(+t),h):s},h.paddingBottom=function(t){return arguments.length?(c="function"==typeof t?t:X(+t),h):c},h.paddingLeft=function(t){return arguments.length?(u="function"==typeof t?t:X(+t),h):u},h}function bt(t,e,n,r,o){var a,l,s=t.children,c=s.length,u=new Array(c+1);for(u[0]=l=a=0;a<c;++a)u[a+1]=l+=s[a].value;function h(t,e,n,r,i,o,a){if(t>=e-1){var l=s[t];return l.x0=r,l.y0=i,l.x1=o,void(l.y1=a)}for(var c=u[t],p=n/2+c,d=t+1,f=e-1;d<f;){var y=d+f>>>1;u[y]<p?d=y+1:f=y}p-u[d-1]<u[d]-p&&t+1<d&&--d;var m=u[d]-c,g=n-m;if(o-r>a-i){var x=(r*g+o*m)/n;h(t,d,m,r,i,x,a),h(d,e,g,x,i,o,a)}else{var _=(i*g+a*m)/n;h(t,d,m,r,i,o,_),h(d,e,g,r,_,o,a)}}h(0,c,t.value,e,n,r,o),i(h,"partition")}function vt(t,e,n,r,i){(1&t.depth?yt:it)(t,e,n,r,i)}i(_t,"d3Treemap"),i(bt,"d3treemapBinary"),i(vt,"d3treemapSliceDice");const wt=i(function t(e){function n(t,n,r,i,o){if((a=t._squarify)&&a.ratio===e)for(var a,l,s,c,u,h=-1,p=a.length,d=t.value;++h<p;){for(s=(l=a[h]).children,c=l.value=0,u=s.length;c<u;++c)l.value+=s[c].value;l.dice?it(l,n,r,i,r+=(o-r)*l.value/d):yt(l,n,r,n+=(i-n)*l.value/d,o),d-=l.value}else t._squarify=a=gt(e,t,n,r,i,o),a.ratio=e}return i(n,"resquarify"),n.ratio=function(e){return t((e=+e)>1?e:1)},n},"custom")(mt),St=class _CirclePacking extends n.SVGWidget{diameter;pack;svg;_focus;circle;view;_node;constructor(){super(),e.ITree.call(this)}enter(t,e){this.diameter=Math.min(this.width(),this.height()),this.pack=Q().size([this.diameter-4,this.diameter-4]).padding(1.5),this.svg=e.append("g")}update(t,e){const r=this;this.diameter=Math.min(this.width(),this.height()),this.pack.size([this.diameter-4,this.diameter-4]).padding(1.5),this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this.svg.selectAll("circle").remove(),this.svg.selectAll("text").remove();const i=z(this.data()).sum(function(t){return t&&t.size?t.size:1}).sort(function(t,e){return t.value<e.value?-1:t.value>e.value?1:0});this._focus=i,this.pack(i),this.circle=this.svg.selectAll("circle").data(i.descendants()).enter().append("circle").attr("class",function(t){return t.parent?t.children?"node":"node leaf":"node root"}).style("fill",function(t){return t.color=r.paletteDepthLevel_exists()&&t.depth>r.paletteDepthLevel()?n.rgb(t.parent.color)[r.paletteDepthVariant()](1):r._palette(t.data.label),t.color}).on("click",function(t){r.click(t.data,null,null)}).on("dblclick",function(t){this._focus!==t&&r.zoom(t),n.d3Event().stopPropagation()}),this.circle.append("title").text(function(t){return t.data.label}),this.svg.selectAll("text").data(i.descendants()).enter().append("text").attr("class","label").style("fill-opacity",function(t){return t.parent===i?1:0}).style("display",function(t){return t.parent===i?null:"none"}).text(function(t){return t.data.label+(r.showSize()&&void 0!==t.data.size?" "+t.data.size:"")}),this._node=this.svg.selectAll("circle,text"),this.zoomTo([i.x,i.y,2*i.r])}zoom(t){this._focus=t;const e=this,r=this.svg.transition().duration(n.d3Event().altKey?7500:750).tween("zoom",function(){const t=n.interpolateZoom(e.view,[e._focus.x,e._focus.y,2*e._focus.r]);return function(n){e.zoomTo(t(n))}});function o(t){return t===e._focus&&!t.children||t.parent===e._focus}i(o,"showText"),r.selectAll("text").filter(function(t){return o(t)||"inline"===this.style.display}).style("fill-opacity",function(t){return o(t)?1:0}).on("start",function(t){o(t)&&(this.style.display="inline")}).on("end",function(t){o(t)||(this.style.display="none")})}zoomTo(t){const e=this.diameter/t[2];this.view=t,this._node.attr("transform",function(n){return"translate("+(n.x-t[0])*e+","+(n.y-t[1])*e+")"}),this.circle.attr("r",function(t){return t.r*e})}};i(St,"CirclePacking");let Tt=St;Tt.prototype._class+=" tree_CirclePacking",Tt.prototype.implements(e.ITree.prototype),Tt.prototype.publish("showSize",!0,"boolean","Show size along with label"),Tt.prototype.publish("paletteDepthLevel",null,"number","If not null then beyond this depth number the child node colors are based on parent",null,{optional:!0}),Tt.prototype.publish("paletteDepthVariant","brighter","set","Determines paletteDepthLevel decendant color shade variant",["brighter","darker"],{disable:i(t=>t.paletteDepthLevel_exists(),"disable")}),Tt.prototype.publish("paletteID","default","set","Color palette for this widget",Tt.prototype._palette.switch(),{tags:["Basic","Shared"]}),Tt.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]});const Ct=class _DendrogramColumn extends n.PropertyExt{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};i(Ct,"DendrogramColumn");let zt=Ct;zt.prototype._class+=" tree_Dendrogram.DendrogramColumn",zt.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const Mt=class _Dendrogram extends n.SVGZoomWidget{Column;_d3LayoutCluster;_d3LayoutTree;_d3Layout;constructor(){super(),e.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this),this._drawStartPos="origin",this._d3LayoutCluster=p(),this._d3LayoutTree=ft()}dendrogramData(){if(0===this.data().length)return[];if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.rollupView(this.mappings().map(function(t){return t.column()})).entries()});function t(e){return{label:e.key,children:e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),origRows:e.values}}}enter(t,e){super.enter(t,e),this._renderElement.attr("opacity",0).transition().duration(500).attr("opacity",1),this._selection.widgetElement(this._renderElement)}update(t,e){super.update(t,e);const r=this,o="vertical"===this.orientation();this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this._d3Layout=this.dendrogram()?this._d3LayoutCluster:this._d3LayoutTree,this.radial()?(this._d3Layout.size([360,2*this.separation()]),this._d3Layout.separation(i(function(t,e){return(t.parent===e.parent?1:2)/t.depth},"separation"))):(this._d3Layout.nodeSize([14,this.separation()]),this._d3Layout.separation(i(function(t,e){return t.parent===e.parent?1:2},"separation")));const a=z(this.dendrogramData());this._d3Layout(a);const l=a.descendants(),s=a.descendants().slice(1);function c(t){return"M"+t.parent.x+","+t.parent.y+"C"+t.parent.x+","+(t.parent.y+t.y)/2+" "+t.x+","+(t.parent.y+t.y)/2+" "+t.x+","+t.y}function u(t){return"M"+t.y+","+t.x+"C"+(t.y+t.parent.y)/2+","+t.x+" "+(t.y+t.parent.y)/2+","+t.parent.x+" "+t.parent.y+","+t.parent.x}function h(t){return o?c(t):u(t)}function p(t,e){const n=(t-90)/180*Math.PI,r=e;return[r*Math.cos(n),r*Math.sin(n)]}function d(t){return"M"+p(t.x,t.y)+"C"+p(t.x,(t.y+t.parent.y)/2)+" "+p(t.parent.x,(t.y+t.parent.y)/2)+" "+p(t.parent.x,t.parent.y)}i(c,"linkVertical"),i(u,"linkHorizontal"),i(h,"diagonal"),i(p,"project"),i(d,"radialDiagonal");const f=this._renderCount?500:0,y=this._renderElement.selectAll(".link").data(s);y.enter().append("path").attr("class","link").attr("d",this.radial()?d:h),y.transition().duration(f).attr("d",this.radial()?d:h),y.exit().remove();const m=this.circleRadius()+2;function g(t){return r.radial()?"rotate("+(t.x-90)+")translate("+t.y+")":"horizontal"===r.orientation()?"translate("+t.y+","+t.x+")":"translate("+t.x+","+t.y+")"}i(g,"nodeTransform");const x=this._renderElement.selectAll(".node").data(l);x.transition().duration(f).attr("transform",g);const _=x.enter().append("g").attr("class","node").attr("transform",g).call(this._selection.enter.bind(this._selection)).on("click",function(t){let e=t;for(;e.children;)e=e.children[0];t.depth>0&&(e.origRows?r.click(r.rowToObj(e.origRows[0]),r.mappings()[t.depth-1].column(),!0):r.click(e.data,r.mappings()[t.depth-1].column(),!0))}).on("dblclick",function(t){let e=t;for(;e.children;)e=e.children[0];t.depth>0&&(e.origRows?r.dblclick(r.rowToObj(e.origRows[0]),r.mappings()[t.depth-1].column(),!0):r.dblclick(e.data,r.mappings()[t.depth-1].column(),!0))}).each(function(){const t=n.select(this);t.append("circle"),t.append("text")});_.merge(x).select("circle").attr("r",this.circleRadius()).style("fill",function(t){return r._palette(t.data.label)}).append("title").text(function(t){return t.data.label}),_.merge(x).select("text").attr("dx",function(t){return r.radial()?t.children?t.x<180?-m:m:t.x<180?m:-m:o?t.children?m:-m:t.children?-m:m}).attr("dy","0.25em").style("text-anchor",function(t){return r.radial()?t.children?t.x<180?"end":"start":t.x<180?"start":"end":o?t.children?"start":"end":t.children?"end":"start"}).attr("transform",function(t){return r.radial()?t.x<180?null:"rotate(180)":o?"rotate(-66)":null}).text(function(t){return t.data.label}),x.exit().remove(),this._renderCount||r.zoomToFit()}};i(Mt,"Dendrogram");let kt=Mt;kt.prototype._class+=" tree_Dendrogram",kt.prototype.implements(e.ITree.prototype),kt.prototype.mixin(n.Utility.SimpleSelectionMixin),kt.prototype.Column=zt,kt.prototype.publish("paletteID","default","set","Color palette for this widget",kt.prototype._palette.switch(),{tags:["Basic","Shared"]}),kt.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]}),kt.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:zt}),kt.prototype.publish("circleRadius",4.5,"number","Text offset from circle"),kt.prototype.publish("separation",240,"number","Leaf Separation"),kt.prototype.publish("dendrogram",!0,"boolean","Dendrogram"),kt.prototype.publish("radial",!1,"boolean","Radial"),kt.prototype.publish("orientation","horizontal","set","Orientation",["horizontal","vertical"],{tags:["Private"],disable:i(t=>t.radial(),"disable")});const Dt=class _DirectoryTree extends n.HTMLWidget{constructor(){super()}flattenData(t){const e=this,n=z(t),r=[];return this.omitRoot()?n.children&&n.children.forEach(i):i(n),r;function i(t){const n=t.data.markers&&t.data.markers.length?t.data.markers.length:"";r.push({label:t.data.label,depth:t.depth-(e.omitRoot()?1:0),content:t.data.content,isFolder:!!t.data.children,iconClass:t.data.iconClass,color:t.data.color,bold:t.data.bold,weightValue:n,markers:t.data.markers,selected:t.data.selected}),t.children&&t.children.forEach(i)}}iconClass(t){return"error"===t.label?"fa fa-exclamation":t.isFolder?this.folderIconOpen():this.textFileIcon()}calcRequiredWidth(){const t=this.flattenData(this.data());let e=0;const r=this.rowItemPadding(),i=this.iconSize()+2*r,o=n.Platform.getScrollbarWidth();return t.forEach(t=>{const a=t.depth*i+2*r,l=n.Utility.textSize(t.label,this.fontFamily(),this.fontSize(),!!t.bold).width+2*r+i+a+o;e<l&&(e=l)}),e}rowClick(t,e){}enter(t,e){super.enter(t,e),e.style("width","100%").style("height","100%")}update(t,e){super.update(t,e),this._palette=this._palette.switch(this.paletteID()),e.style("overflow-y",this.verticalScroll()?"scroll":null);const r=this.flattenData(this.data()),i=n.max(r,t=>Number(t.weightValue));r.forEach(t=>{t.weightValue?t.weightColor=this._palette(t.weightValue,1,i):t.weightColor="transparent"});const o=this,a=this.rowItemPadding(),l=this.iconSize()+a,s=Math.max(o.iconSize(),o.fontSize()),c=e.selectAll(".directory-row").data(r),u=this.fontFamily(),h=this.fontSize(),p=n.max(r,t=>this.textSize(t.weightValue,u,h).width),d=`${a}px ${a}px ${a/2}px ${a}px`;c.enter().append("div").attr("class",t=>`directory-row directory-row-depth-${t.depth}`).style("display","flex").style("cursor","pointer").each(function(t){const r=n.select(this),i=t.color?t.color:o.fontColor(),c=t.weightColor?t.weightColor:"transparent",f=n.Palette.textColor(c),y=r.append("div").attr("class","row-weight").style("padding",d).style("color",f).style("box-shadow",`inset 0 0 100px ${c}`).style("font-weight",t.bold?"bold":"normal").style("font-family",u).style("font-size",h+"px").text(t.weightValue).attr("title",t.weightValue).style("overflow","hidden").style("width",p+2*a+"px").style("text-overflow","ellipsis").style("text-align","right").style("line-height",s+"px");r.append("div").attr("class","row-depth").style("width",o.depthSize()*t.depth+"px").style("opacity",1).style("line-height",s+"px");const m=r.append("div").attr("class","row-icon "+(t.iconClass?t.iconClass:o.iconClass(t))).style("width",l+"px").style("height",s+"px").style("color",i).style("background-color",t.selected?o.selectionBackgroundColor():"transparent").style("font-size",o.iconSize()+"px").style("padding",d).style("line-height",s+"px"),g=r.append("div").attr("class","row-label").style("padding",d).style("color",i).style("background-color",t.selected?o.selectionBackgroundColor():"transparent").style("font-weight",t.bold?"bold":"normal").style("font-family",o.fontFamily()).style("font-size",o.fontSize()+"px").text(t.label).attr("title",t.label).style("flex",1).style("overflow","hidden").style("text-overflow","ellipsis").style("line-height",s+"px");r.on("mouseenter",()=>{g.style("font-weight","bold")}).on("mouseleave",()=>{g.style("font-weight",t.bold?"bold":"normal")}),y.on("mouseenter",()=>{o.weight_mouseenter(t)}).on("mouseleave",()=>{o.weight_mouseleave(t)}),t.isFolder?r.on("click",function(t){let e=this.nextSibling;const i=r.classed("folder-closed");for(i?(r.classed("folder-closed",!1),r.classed("folder-open",!0),m.attr("class","row-icon "+o.folderIconOpen())):(r.classed("folder-closed",!0),r.classed("folder-open",!1),m.attr("class","row-icon "+o.folderIconClosed()));null!==e;){n.select(e).datum().depth>t.depth?(e.style.display=i?"flex":"none",e=e.nextSibling):e=null}}):r.on("click",()=>{e.selectAll(".row-label").style("background-color","transparent"),e.selectAll(".row-icon").style("background-color","transparent"),m.style("background-color",o.selectionBackgroundColor()),g.style("background-color",o.selectionBackgroundColor());const n=t.label.split(".").pop().toLowerCase();o.rowClick("json"===n?JSON.stringify(JSON.parse(t.content),null,4):t.content,t.markers)})}).merge(c).style("background-color",o.backgroundColor()),c.exit().remove()}weight_mouseenter(t){}weight_mouseleave(t){}};i(Dt,"DirectoryTree");let It=Dt;It.prototype._class+=" tree_DirectoryTree",It.prototype._palette=n.Palette.rainbow("Blues"),It.prototype.publish("depthSize",14,"number","Width of indentation per file or folder depth (pixels)"),It.prototype.publish("paletteID","Blues","set","Color palette for the weight backgrounds",It.prototype._palette.switch(),{tags:["Basic"]}),It.prototype.publish("omitRoot",!1,"boolean","If true, root node will not display"),It.prototype.publish("rowItemPadding",2,"number","Top, bottom, left and right row item padding"),It.prototype.publish("selectionBackgroundColor","#CCC","html-color","Background color of selected directory rows"),It.prototype.publish("backgroundColor","#FFF","html-color","Directory item background color"),It.prototype.publish("fontColor","#000","html-color","Directory item font color"),It.prototype.publish("fontFamily","Arial","string","Directory item font family"),It.prototype.publish("fontSize",12,"number","Directory item font size (pixels)"),It.prototype.publish("iconSize",12,"number","Directory folder and file icon size (pixels)"),It.prototype.publish("folderIconOpen","fa fa-folder-open","string","Open folder icon class"),It.prototype.publish("folderIconClosed","fa fa-folder","string","Closed folder icon class"),It.prototype.publish("textFileIcon","fa fa-file-text-o","string","Text file icon class"),It.prototype.publish("verticalScroll",!0,"boolean","If true, vertical scroll bar will be shown");const At=class _IndentedColumn extends n.PropertyExt{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};i(At,"IndentedColumn");let Pt=At;Pt.prototype._class+=" tree_Dendrogram.IndentedColumn",Pt.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const Rt=class _Indented extends n.SVGZoomWidget{Column;_d3Tree;_xml;_svgLinks;_svgNodes;_treeData;_collapsed={};constructor(){super(),e.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this),this._drawStartPos="origin",this._d3Tree=ft()}xmlToData(t,e=""){if(DOMParser){return Bt((new DOMParser).parseFromString(t,"text/xml"),e).children[0]}return[]}xml(t){return arguments.length?(this._xml=t,this.data(this.xmlToData(this._xml)),this):this._xml}IndentedData(){if(0===this.data().length)return[];if(this.xmlColumn_exists()){const t=this.columns().indexOf(this.xmlColumn()),e={label:this.xmlColumn(),children:this.data().map(function(e,n){return this.xmlToData(e[t],"["+n+"]")},this)};return 1===e.children.length?e.children[0]:e}if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.rollupView(this.mappings().map(function(t){return t.column()})).entries()});function t(e){if(e.values instanceof Array){const n=e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),r={label:e.key};return n.length?r.children=n:r.size=22,r}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(t,e){super.enter(t,e),this._svgLinks=this._renderElement.append("g"),this._svgNodes=this._renderElement.append("g"),this._selection.widgetElement(this._svgNodes)}_prevDataChecksum;update(t,e){super.update(t,e);const r=this;this._d3Tree.nodeSize([0,this.barHeight()]);const o=this._db.dataChecksum();function a(t){return(t.parent?a(t.parent)+".":"")+t.data.label}this._prevDataChecksum!==o&&(this._treeData=this.IndentedData(),this._prevDataChecksum=o),i(a,"getID");const l=z(this.data()).sum(function(t){return t.size||50}).each(t=>{this._collapsed[a(t)]&&delete t.children}),s=this._d3Tree(l).descendants(),c=this._d3Tree(l).descendants().slice(1);let u=0;l.eachBefore(t=>{t.x=u*r.barHeight(),++u});const h=this.barHeight()-4,p=this._renderCount?500:0,d=this._svgLinks.selectAll(".link").data(c,function(t){return a(t)});function f(t){return"M"+t.parent.y+","+t.parent.x+"V"+t.x+", H"+t.y}d.enter().append("path").attr("class","link").attr("d",f),d.transition().duration(p).attr("d",f),d.exit().remove(),i(f,"elbow");const y=this._svgNodes.selectAll(".node").data(s,function(t){return a(t)});y.transition().duration(p).attr("transform",function(t){return"translate("+t.y+","+t.x+")"});const m=y.enter().append("g").attr("class","node").attr("transform",function(t){return"translate("+t.y+","+t.x+")"}).call(this._selection.enter.bind(this._selection)).each(function(){const t=n.select(this);t.append("rect").attr("height",h).attr("width",h).on("click",function(t){r._collapsed[a(t)]?delete r._collapsed[a(t)]:t.children&&(r._collapsed[a(t)]=!0),r.lazyRender()}),t.append("text")}).style("opacity",0);function g(t){return r._collapsed[a(t)]?"#3182bd":t.children?"#c6dbef":"#fd8d3c"}m.transition().style("opacity",1),m.merge(y).select("rect").attr("x",-h/2).attr("y",-h/2).style("fill",g),m.merge(y).select("text").attr("dx",h/2+4+"px").attr("dy","0.33em").text(function(t){return t.data.label}),y.exit().transition().style("opacity",0).remove(),this._renderCount||r.zoomToFit(),i(g,"color")}};i(Rt,"Indented");let Lt=Rt;function Bt(t,e=""){const n={id:e,label:"",attributes:{},children:[]};if(n.label=t.nodeName,1===t.nodeType){if(t.attributes.length>0)for(let r=0;r<t.attributes.length;r++){const e=t.attributes.item(r);n.attributes[e.nodeName]=e.nodeValue}}else 3===t.nodeType&&(n.label=t.nodeValue);if(t.hasChildNodes())for(let r=0;r<t.childNodes.length;r++){const i=Bt(t.childNodes.item(r),e+"["+n.children.length+"]");n.children.push(i)}return n}Lt.prototype._class+=" tree_Indented",Lt.prototype.implements(e.ITree.prototype),Lt.prototype.mixin(n.Utility.SimpleSelectionMixin),Lt.prototype.Column=Pt,Lt.prototype.publish("xmlColumn",null,"set","Field",function(){return this.columns()},{optional:!0}),Lt.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:Pt,disable:i(t=>t.xmlColumn_exists(),"disable")}),Lt.prototype.publish("barHeight",16,"number","Bar height"),i(Bt,"xmlToJson");var Et=Math.PI,Nt=2*Et,qt=1e-6,Ot=Nt-qt;function Vt(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function Ft(){return new Vt}function Wt(t){return i(function(){return t},"constant")}i(Vt,"Path"),i(Ft,"path"),Vt.prototype=Ft.prototype={constructor:Vt,moveTo:i(function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)},"moveTo"),closePath:i(function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},"closePath"),lineTo:i(function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e)},"lineTo"),quadraticCurveTo:i(function(t,e,n,r){this._+="Q"+ +t+","+ +e+","+(this._x1=+n)+","+(this._y1=+r)},"quadraticCurveTo"),bezierCurveTo:i(function(t,e,n,r,i,o){this._+="C"+ +t+","+ +e+","+ +n+","+ +r+","+(this._x1=+i)+","+(this._y1=+o)},"bezierCurveTo"),arcTo:i(function(t,e,n,r,i){t=+t,e=+e,n=+n,r=+r,i=+i;var o=this._x1,a=this._y1,l=n-t,s=r-e,c=o-t,u=a-e,h=c*c+u*u;if(i<0)throw new Error("negative radius: "+i);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(h>qt)if(Math.abs(u*l-s*c)>qt&&i){var p=n-o,d=r-a,f=l*l+s*s,y=p*p+d*d,m=Math.sqrt(f),g=Math.sqrt(h),x=i*Math.tan((Et-Math.acos((f+h-y)/(2*m*g)))/2),_=x/g,b=x/m;Math.abs(_-1)>qt&&(this._+="L"+(t+_*c)+","+(e+_*u)),this._+="A"+i+","+i+",0,0,"+ +(u*p>c*d)+","+(this._x1=t+b*l)+","+(this._y1=e+b*s)}else this._+="L"+(this._x1=t)+","+(this._y1=e);else;},"arcTo"),arc:i(function(t,e,n,r,i,o){t=+t,e=+e,o=!!o;var a=(n=+n)*Math.cos(r),l=n*Math.sin(r),s=t+a,c=e+l,u=1^o,h=o?r-i:i-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+s+","+c:(Math.abs(this._x1-s)>qt||Math.abs(this._y1-c)>qt)&&(this._+="L"+s+","+c),n&&(h<0&&(h=h%Nt+Nt),h>Ot?this._+="A"+n+","+n+",0,1,"+u+","+(t-a)+","+(e-l)+"A"+n+","+n+",0,1,"+u+","+(this._x1=s)+","+(this._y1=c):h>qt&&(this._+="A"+n+","+n+",0,"+ +(h>=Et)+","+u+","+(this._x1=t+n*Math.cos(i))+","+(this._y1=e+n*Math.sin(i))))},"arc"),rect:i(function(t,e,n,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},"rect"),toString:i(function(){return this._},"toString")},i(Wt,"constant");var jt=Math.abs,$t=Math.atan2,Ht=Math.cos,Ut=Math.max,Gt=Math.min,Zt=Math.sin,Jt=Math.sqrt,Kt=1e-12,Xt=Math.PI,Yt=Xt/2,Qt=2*Xt;function te(t){return t>1?0:t<-1?Xt:Math.acos(t)}function ee(t){return t>=1?Yt:t<=-1?-Yt:Math.asin(t)}function ne(t){return t.innerRadius}function re(t){return t.outerRadius}function ie(t){return t.startAngle}function oe(t){return t.endAngle}function ae(t){return t&&t.padAngle}function le(t,e,n,r,i,o,a,l){var s=n-t,c=r-e,u=a-i,h=l-o,p=h*s-u*c;if(!(p*p<Kt))return[t+(p=(u*(e-o)-h*(t-i))/p)*s,e+p*c]}function se(t,e,n,r,i,o,a){var l=t-n,s=e-r,c=(a?o:-o)/Jt(l*l+s*s),u=c*s,h=-c*l,p=t+u,d=e+h,f=n+u,y=r+h,m=(p+f)/2,g=(d+y)/2,x=f-p,_=y-d,b=x*x+_*_,v=i-o,w=p*y-f*d,S=(_<0?-1:1)*Jt(Ut(0,v*v*b-w*w)),T=(w*_-x*S)/b,C=(-w*x-_*S)/b,z=(w*_+x*S)/b,M=(-w*x+_*S)/b,k=T-m,D=C-g,I=z-m,A=M-g;return k*k+D*D>I*I+A*A&&(T=z,C=M),{cx:T,cy:C,x01:-u,y01:-h,x11:T*(i/v-1),y11:C*(i/v-1)}}function ce(){var t=ne,e=re,n=Wt(0),r=null,o=ie,a=oe,l=ae,s=null;function c(){var i,c,u=+t.apply(this,arguments),h=+e.apply(this,arguments),p=o.apply(this,arguments)-Yt,d=a.apply(this,arguments)-Yt,f=jt(d-p),y=d>p;if(s||(s=i=Ft()),h<u&&(c=h,h=u,u=c),h>Kt)if(f>Qt-Kt)s.moveTo(h*Ht(p),h*Zt(p)),s.arc(0,0,h,p,d,!y),u>Kt&&(s.moveTo(u*Ht(d),u*Zt(d)),s.arc(0,0,u,d,p,y));else{var m,g,x=p,_=d,b=p,v=d,w=f,S=f,T=l.apply(this,arguments)/2,C=T>Kt&&(r?+r.apply(this,arguments):Jt(u*u+h*h)),z=Gt(jt(h-u)/2,+n.apply(this,arguments)),M=z,k=z;if(C>Kt){var D=ee(C/u*Zt(T)),I=ee(C/h*Zt(T));(w-=2*D)>Kt?(b+=D*=y?1:-1,v-=D):(w=0,b=v=(p+d)/2),(S-=2*I)>Kt?(x+=I*=y?1:-1,_-=I):(S=0,x=_=(p+d)/2)}var A=h*Ht(x),P=h*Zt(x),R=u*Ht(v),L=u*Zt(v);if(z>Kt){var B,E=h*Ht(_),N=h*Zt(_),q=u*Ht(b),O=u*Zt(b);if(f<Xt&&(B=le(A,P,q,O,E,N,R,L))){var V=A-B[0],F=P-B[1],W=E-B[0],j=N-B[1],$=1/Zt(te((V*W+F*j)/(Jt(V*V+F*F)*Jt(W*W+j*j)))/2),H=Jt(B[0]*B[0]+B[1]*B[1]);M=Gt(z,(u-H)/($-1)),k=Gt(z,(h-H)/($+1))}}S>Kt?k>Kt?(m=se(q,O,A,P,h,k,y),g=se(E,N,R,L,h,k,y),s.moveTo(m.cx+m.x01,m.cy+m.y01),k<z?s.arc(m.cx,m.cy,k,$t(m.y01,m.x01),$t(g.y01,g.x01),!y):(s.arc(m.cx,m.cy,k,$t(m.y01,m.x01),$t(m.y11,m.x11),!y),s.arc(0,0,h,$t(m.cy+m.y11,m.cx+m.x11),$t(g.cy+g.y11,g.cx+g.x11),!y),s.arc(g.cx,g.cy,k,$t(g.y11,g.x11),$t(g.y01,g.x01),!y))):(s.moveTo(A,P),s.arc(0,0,h,x,_,!y)):s.moveTo(A,P),u>Kt&&w>Kt?M>Kt?(m=se(R,L,E,N,u,-M,y),g=se(A,P,q,O,u,-M,y),s.lineTo(m.cx+m.x01,m.cy+m.y01),M<z?s.arc(m.cx,m.cy,M,$t(m.y01,m.x01),$t(g.y01,g.x01),!y):(s.arc(m.cx,m.cy,M,$t(m.y01,m.x01),$t(m.y11,m.x11),!y),s.arc(0,0,u,$t(m.cy+m.y11,m.cx+m.x11),$t(g.cy+g.y11,g.cx+g.x11),y),s.arc(g.cx,g.cy,M,$t(g.y11,g.x11),$t(g.y01,g.x01),!y))):s.arc(0,0,u,v,b,y):s.lineTo(R,L)}else s.moveTo(0,0);if(s.closePath(),i)return s=null,i+""||null}return i(c,"arc"),c.centroid=function(){var n=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,r=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-Xt/2;return[Ht(r)*n,Zt(r)*n]},c.innerRadius=function(e){return arguments.length?(t="function"==typeof e?e:Wt(+e),c):t},c.outerRadius=function(t){return arguments.length?(e="function"==typeof t?t:Wt(+t),c):e},c.cornerRadius=function(t){return arguments.length?(n="function"==typeof t?t:Wt(+t),c):n},c.padRadius=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:Wt(+t),c):r},c.startAngle=function(t){return arguments.length?(o="function"==typeof t?t:Wt(+t),c):o},c.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:Wt(+t),c):a},c.padAngle=function(t){return arguments.length?(l="function"==typeof t?t:Wt(+t),c):l},c.context=function(t){return arguments.length?(s=null==t?null:t,c):s},c}i(te,"acos"),i(ee,"asin"),i(ne,"arcInnerRadius"),i(re,"arcOuterRadius"),i(ie,"arcStartAngle"),i(oe,"arcEndAngle"),i(ae,"arcPadAngle"),i(le,"intersect"),i(se,"cornerTangents"),i(ce,"d3Arc");const ue=class _SunburstPartition extends n.SVGWidget{svg;radius;_xScale;_yScale;partition;arc;_resetRoot;constructor(){super(),e.ITree.call(this)}data(t){const e=n.SVGWidget.prototype.data.apply(this,arguments);return arguments.length&&(this._resetRoot=!0),e}enter(t,e){const r=this;this.radius=Math.min(this.width(),this.height())/2,this._xScale=n.scaleLinear().range([0,2*Math.PI]),this._yScale=n.scaleSqrt().range([0,this.radius]),this.partition=ot(),this.arc=ce().startAngle(function(t){return Math.max(0,Math.min(2*Math.PI,r._xScale(t.x0)))}).endAngle(function(t){return Math.max(0,Math.min(2*Math.PI,r._xScale(t.x1)))}).innerRadius(function(t){return Math.max(0,r._yScale(t.y0))}).outerRadius(function(t){return Math.max(0,r._yScale(t.y1))}),this.svg=e.append("g")}update(t,e){const r=this;this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this.radius=Math.min(this.width(),this.height())/2,this._yScale.range([0,this.radius]);const i=z(this.data()).sum(function(t){return void 0!==t.size?t.size:1}),o=this.svg.selectAll("path").data(this.partition(i).descendants(),function(t,e){return void 0!==t.data.label?t.data.label:e});o.enter().append("path").on("click",function(t){r.click(t.data,null,null)}).on("dblclick",function(t){const e=n.d3Event();e&&e.stopPropagation(),r.zoomTo(t)}).each(function(){n.select(this).append("title")}).merge(o).attr("d",this.arc).style("fill",function(t){return t.data.__viz_fill?t.data.__viz_fill:r._palette(t.data.label)}).style("stroke",function(t){return t.value>16?"white":"none"}).select("title").text(function(t){return t.data.label}),o.exit().remove(),this._resetRoot&&(this._resetRoot=!1,this.zoomTo(i))}zoomTo(t){const e=this;this.svg.transition().duration(750).tween("scale",function(){const r=n.interpolate(e._xScale.domain(),[t.x0,t.x1]),i=n.interpolate(e._yScale.domain(),[t.y0,1]),o=n.interpolate(e._yScale.range(),[t.y0?20:0,e.radius]);return function(t){e._xScale.domain(r(t)),e._yScale.domain(i(t)).range(o(t))}}).selectAll("path").attrTween("d",function(t){return function(){return e.arc(t)}})}};i(ue,"SunburstPartition");let he=ue;he.prototype._class+=" tree_SunburstPartition",he.prototype.implements(e.ITree.prototype),he.prototype.publish("paletteID","default","set","Color palette for this widget",he.prototype._palette.switch(),{tags:["Basic","Shared"]}),he.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]});const pe=class _TreemapColumn extends n.PropertyExt{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};i(pe,"TreemapColumn");let de=pe;de.prototype._class+=" tree_Dendrogram.TreemapColumn",de.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const fe=class _Treemap extends n.HTMLWidget{Column;_d3Treemap;_elementDIV;_selection;constructor(){super(),e.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this,!0)}getTilingMethod(){switch(this.tilingMethod()){case"treemapBinary":return bt;case"treemapDice":return it;case"treemapSlice":return yt;case"treemapSliceDice":return vt;case"treemapResquarify":return wt;default:return xt}}treemapData(){if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.aggregateView(this.mappings().map(function(t){return t.column()}),this.aggrType(),this.aggrColumn()).entries()});function t(e){if(e.values instanceof Array){const n=e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),r={label:e.key};return n.length?r.children=n:r.size=22,r}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(t,e){super.enter(t,e),this._d3Treemap=_t(),this._elementDIV=e.append("div"),this._selection.widgetElement(this._elementDIV)}update(t,e){super.update(t,e);const r=this;this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id()));const o=z(this.treemapData()).sum(this.nodeWeight);this._d3Treemap.size([this.width(),this.height()]).paddingInner(this.paddingInner()).paddingOuter(this.paddingOuter()).paddingTop(this.paddingTop()),-1!==["treemapSquarify","treemapResquarify"].indexOf(this.tilingMethod())?this._d3Treemap.tile(this.getTilingMethod().ratio(this.squarifyRatio())):this._d3Treemap.tile(this.getTilingMethod()),this._d3Treemap(o),this._elementDIV.style("font-size",this.fontSize_exists()?this.fontSize()+"px":null).style("line-height",this.fontSize_exists()?this.fontSize()+2+"px":null);const a=this._elementDIV.selectAll(".node").data(o.descendants());function l(t){if(t.children&&!r.enableParentTooltips())return null;let e=t.data.label+" ("+t.value+")";for(;t.parent&&t.parent.parent;)e=t.parent.data.label+" -> "+e,t=t.parent;return e}a.enter().append("div").attr("class","node").call(this._selection.enter.bind(this._selection)).on("click",function(t){if(t){let e="";r.mappings().forEach(function(t){t.column()&&(e=t.column())}),t.origRows?r.click(r.rowToObj(t.origRows[0]),e,r._selection.selected(this)):r.click(t.data,e,r._selection.selected(this))}}).on("dblclick",function(t){if(t){let e="";r.mappings().forEach(function(t){t.column()&&(e=t.column())}),t.origRows?r.dblclick(r.rowToObj(t.origRows[0]),e,r._selection.selected(this)):r.dblclick(t.data,e,r._selection.selected(this))}}).merge(a).style("left",function(t){return t.x0+Math.max(0,t.x1-t.x0)/2+"px"}).style("top",function(t){return t.y0+Math.max(0,t.y1-t.y0)/2+"px"}).style("width",function(){return"0px"}).style("height",function(){return"0px"}).style("font-size",function(t){return(t.children?r.parentFontSize():r.leafFontSize())+"px"}).style("line-height",function(t){return(t.children?r.parentFontSize():r.leafFontSize())+"px"}).attr("title",l).html(function(t){return r.showRoot()||0!==t.depth?t.children?r.enableParentLabels()?r.parentWeightHTML(t):null:r.leafWeightHTML(t):null}).style("background",function(t){if(!r.showRoot()&&0===t.depth)return this.style.color="transparent","transparent";const e=r.brighterLeafNodes()?"brighter":"darker";let i;return r.usePaletteOnParentNodes()?i=t.children?r._palette(t.data.label):n.rgb(r._palette(t.parent.data.label))[e](1):(i=t.depth>r.depthColorLimit()?n.rgb(t.parent.color)[e](1):r._palette(t.data.label),t.color=i),this.style.color=n.Palette.textColor(i),i}).transition().duration(this.transitionDuration()).style("pointer-events",function(t){return r.showRoot()||0!==t.depth?"all":"none"}).style("opacity",function(t){return t.children?1:null}).style("left",function(t){return t.x0+"px"}).style("top",function(t){return t.y0+"px"}).style("width",function(t){return Math.max(0,t.x1-t.x0)+"px"}).style("height",function(t){return Math.max(0,t.y1-t.y0)+"px"}).each(function(t){0===t.depth&&(this.style.color=r.showRoot()?"":"transparent",this.style.borderColor=r.showRoot()?"":"transparent")}),a.exit().transition().duration(this.transitionDuration()).style("opacity",0).remove(),i(l,"tooltip")}exit(t,e){super.exit(t,e)}nodeWeight(t){return t.size||1}parentWeightHTML(t){return this.showParentWeight()?`<span class="treemap-parent-label">${t.data.label}</span><span class="treemap-parent-value">${t.value}${this.weightSuffix()}</span>`:`<span class="treemap-parent-label">${t.data.label}</span>`}leafWeightHTML(t){return this.showLeafWeight()?`<span class="treemap-leaf-label">${t.data.label}</span><span class="treemap-leaf-value">${t.value}${this.weightSuffix()}</span>`:`<span class="treemap-leaf-label">${t.data.label}</span>`}};i(fe,"Treemap");let ye=fe;ye.prototype._class+=" tree_Treemap",ye.prototype.implements(e.ITree.prototype),ye.prototype.mixin(n.Utility.SimpleSelectionMixin),ye.prototype.Column=de,ye.prototype.publish("paletteID","default","set","Color palette for this widget",ye.prototype._palette.switch(),{tags:["Basic","Shared"]}),ye.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]}),ye.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:de}),ye.prototype.publish("aggrType",null,"set","Aggregation Type",[null,"mean","median","sum","min","max"],{optional:!0}),ye.prototype.publish("aggrColumn",null,"set","Aggregation Field",function(){return this.columns()},{optional:!0,disable:i(t=>!t.aggrType(),"disable")}),ye.prototype.publish("fontSize",null,"number","Font Size",null,{optional:!0}),ye.prototype.publish("paddingInner",18.6,"number","Pixel spacing between each sibling node"),ye.prototype.publish("paddingOuter",30,"number","Pixel padding of parent nodes"),ye.prototype.publish("paddingTop",41.4,"number","Additional top pixel padding of parent nodes"),ye.prototype.publish("showRoot",!1,"boolean","Show root element"),ye.prototype.publish("parentFontSize",18,"number","Parent font-size"),ye.prototype.publish("leafFontSize",16,"number","Leaf font-size"),ye.prototype.publish("usePaletteOnParentNodes",!1,"boolean","Assign a color from the palette to every parent node"),ye.prototype.publish("depthColorLimit",1,"number","Assign a color from the palette to node with depth lower than this value",null,{optional:!0,disable:i(t=>t.usePaletteOnParentNodes(),"disable")}),ye.prototype.publish("squarifyRatio",1,"number","Specifies the desired aspect ratio of the generated rectangles (must be >= 1)",null,{optional:!0,disable:i(t=>-1===["treemapSquarify","treemapResquarify"].indexOf(t.tilingMethod()),"disable")}),ye.prototype.publish("showParentWeight",!0,"boolean","Show weight of parent nodes"),ye.prototype.publish("showLeafWeight",!0,"boolean","Show weight of leaf nodes"),ye.prototype.publish("weightSuffix","","string","Weight suffix (ex: 'ms')"),ye.prototype.publish("brighterLeafNodes",!1,"boolean","Brighter/darker leaf node color (false = darker)"),ye.prototype.publish("enableParentLabels",!0,"boolean","Enable parent labels"),ye.prototype.publish("enableParentTooltips",!0,"boolean","Enable parent tooltips"),ye.prototype.publish("transitionDuration",250,"number","Transition Duration"),ye.prototype.publish("tilingMethod","treemapSquarify","set","Transition Duration",["treemapBinary","treemapDice","treemapResquarify","treemapSlice","treemapSliceDice","treemapSquarify"]),t.BUILD_VERSION="3.21.2",t.CirclePacking=Tt,t.Dendrogram=kt,t.DendrogramColumn=zt,t.DirectoryTree=It,t.Indented=Lt,t.IndentedColumn=Pt,t.PKG_NAME="@hpcc-js/tree",t.PKG_VERSION="3.2.12",t.SunburstPartition=he,t.Treemap=ye,t.TreemapColumn=de,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@hpcc-js/api"),require("@hpcc-js/common")):"function"==typeof define&&define.amd?define(["exports","@hpcc-js/api","@hpcc-js/common"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@hpcc-js/tree"]={},t["@hpcc-js/api"],t["@hpcc-js/common"])}(this,function(t,e,n){"use strict";var r=Object.defineProperty,i=(t,e)=>r(t,"name",{value:e,configurable:!0});function o(t,e){return t.parent===e.parent?1:2}function a(t){return t.reduce(l,0)/t.length}function l(t,e){return t+e.x}function s(t){return 1+t.reduce(c,0)}function c(t,e){return Math.max(t,e.y)}function u(t){for(var e;e=t.children;)t=e[0];return t}function h(t){for(var e;e=t.children;)t=e[e.length-1];return t}function p(){var t=o,e=1,n=1,r=!1;function l(i){var o,l=0;i.eachAfter(function(e){var n=e.children;n?(e.x=a(n),e.y=s(n)):(e.x=o?l+=t(e,o):0,e.y=0,o=e)});var c=u(i),p=h(i),d=c.x-t(c,p)/2,f=p.x+t(p,c)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*e,t.y=(i.y-t.y)*n}:function(t){t.x=(t.x-d)/(f-d)*e,t.y=(1-(i.y?t.y/i.y:1))*n})}return i(l,"cluster"),l.separation=function(e){return arguments.length?(t=e,l):t},l.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],l):r?null:[e,n]},l.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],l):r?[e,n]:null},l}function d(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function f(){return this.eachAfter(d)}function y(t){var e,n,r,i,o=this,a=[o];do{for(e=a.reverse(),a=[];o=e.pop();)if(t(o),n=o.children)for(r=0,i=n.length;r<i;++r)a.push(n[r])}while(a.length);return this}function m(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this}function g(t){for(var e,n,r,i=this,o=[i],a=[];i=o.pop();)if(a.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)o.push(e[n]);for(;i=a.pop();)t(i);return this}function x(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 _(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function b(t){for(var e=this,n=v(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 v(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 w(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function S(){var t=[];return this.each(function(e){t.push(e)}),t}function T(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function C(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function z(t,e){var n,r,i,o,a,l=new A(t),s=+t.value&&(l.value=t.value),c=[l];for(null==e&&(e=k);n=c.pop();)if(s&&(n.value=+n.data.value),(i=e(n.data))&&(a=i.length))for(n.children=new Array(a),o=a-1;o>=0;--o)c.push(r=n.children[o]=new A(i[o])),r.parent=n,r.depth=n.depth+1;return l.eachBefore(I)}function M(){return z(this).eachBefore(D)}function k(t){return t.children}function D(t){t.data=t.data.data}function I(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function A(t){this.data=t,this.depth=this.height=0,this.parent=null}i(o,"defaultSeparation$1"),i(a,"meanX"),i(l,"meanXReduce"),i(s,"maxY"),i(c,"maxYReduce"),i(u,"leafLeft"),i(h,"leafRight"),i(p,"d3Cluster"),i(d,"count"),i(f,"node_count"),i(y,"node_each"),i(m,"node_eachBefore"),i(g,"node_eachAfter"),i(x,"node_sum"),i(_,"node_sort"),i(b,"node_path"),i(v,"leastCommonAncestor"),i(w,"node_ancestors"),i(S,"node_descendants"),i(T,"node_leaves"),i(C,"node_links"),i(z,"hierarchy"),i(M,"node_copy"),i(k,"defaultChildren"),i(D,"copyData"),i(I,"computeHeight"),i(A,"Node$1"),A.prototype=z.prototype={constructor:A,count:f,each:y,eachAfter:g,eachBefore:m,sum:x,sort:_,path:b,ancestors:w,descendants:S,leaves:T,links:C,copy:M};var P=Array.prototype.slice;function R(t){for(var e,n,r=t.length;r;)n=Math.random()*r--|0,e=t[r],t[r]=t[n],t[n]=e;return t}function L(t){for(var e,n,r=0,i=(t=R(P.call(t))).length,o=[];r<i;)e=t[r],n&&N(n,e)?++r:(n=O(o=B(o,e)),r=0);return n}function B(t,e){var n,r;if(q(e,t))return[e];for(n=0;n<t.length;++n)if(E(e,t[n])&&q(F(t[n],e),t))return[t[n],e];for(n=0;n<t.length-1;++n)for(r=n+1;r<t.length;++r)if(E(F(t[n],t[r]),e)&&E(F(t[n],e),t[r])&&E(F(t[r],e),t[n])&&q(W(t[n],t[r],e),t))return[t[n],t[r],e];throw new Error}function E(t,e){var n=t.r-e.r,r=e.x-t.x,i=e.y-t.y;return n<0||n*n<r*r+i*i}function N(t,e){var n=t.r-e.r+1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function q(t,e){for(var n=0;n<e.length;++n)if(!N(t,e[n]))return!1;return!0}function O(t){switch(t.length){case 1:return V(t[0]);case 2:return F(t[0],t[1]);case 3:return W(t[0],t[1],t[2])}}function V(t){return{x:t.x,y:t.y,r:t.r}}function F(t,e){var n=t.x,r=t.y,i=t.r,o=e.x,a=e.y,l=e.r,s=o-n,c=a-r,u=l-i,h=Math.sqrt(s*s+c*c);return{x:(n+o+s/h*u)/2,y:(r+a+c/h*u)/2,r:(h+i+l)/2}}function W(t,e,n){var r=t.x,i=t.y,o=t.r,a=e.x,l=e.y,s=e.r,c=n.x,u=n.y,h=n.r,p=r-a,d=r-c,f=i-l,y=i-u,m=s-o,g=h-o,x=r*r+i*i-o*o,_=x-a*a-l*l+s*s,b=x-c*c-u*u+h*h,v=d*f-p*y,w=(f*b-y*_)/(2*v)-r,S=(y*m-f*g)/v,T=(d*_-p*b)/(2*v)-i,C=(p*g-d*m)/v,z=S*S+C*C-1,M=2*(o+w*S+T*C),k=w*w+T*T-o*o,D=-(z?(M+Math.sqrt(M*M-4*z*k))/(2*z):k/M);return{x:r+w+S*D,y:i+T+C*D,r:D}}function j(t,e,n){var r,i,o,a,l=t.x-e.x,s=t.y-e.y,c=l*l+s*s;c?(i=e.r+n.r,i*=i,a=t.r+n.r,i>(a*=a)?(r=(c+a-i)/(2*c),o=Math.sqrt(Math.max(0,a/c-r*r)),n.x=t.x-r*l-o*s,n.y=t.y-r*s+o*l):(r=(c+i-a)/(2*c),o=Math.sqrt(Math.max(0,i/c-r*r)),n.x=e.x+r*l-o*s,n.y=e.y+r*s+o*l)):(n.x=e.x+n.r,n.y=e.y)}function $(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function H(t){var e=t._,n=t.next._,r=e.r+n.r,i=(e.x*n.r+n.x*e.r)/r,o=(e.y*n.r+n.y*e.r)/r;return i*i+o*o}function U(t){this._=t,this.next=null,this.previous=null}function G(t){if(!(i=t.length))return 0;var e,n,r,i,o,a,l,s,c,u,h;if((e=t[0]).x=0,e.y=0,!(i>1))return e.r;if(n=t[1],e.x=-n.r,n.x=e.r,n.y=0,!(i>2))return e.r+n.r;j(n,e,r=t[2]),e=new U(e),n=new U(n),r=new U(r),e.next=r.previous=n,n.next=e.previous=r,r.next=n.previous=e;t:for(l=3;l<i;++l){j(e._,n._,r=t[l]),r=new U(r),s=n.next,c=e.previous,u=n._.r,h=e._.r;do{if(u<=h){if($(s._,r._)){n=s,e.next=n,n.previous=e,--l;continue t}u+=s._.r,s=s.next}else{if($(c._,r._)){(e=c).next=n,n.previous=e,--l;continue t}h+=c._.r,c=c.previous}}while(s!==c.next);for(r.previous=e,r.next=n,e.next=n.previous=n=r,o=H(e);(r=r.next)!==n;)(a=H(r))<o&&(e=r,o=a);n=e.next}for(e=[n._],r=n;(r=r.next)!==n;)e.push(r._);for(r=L(e),l=0;l<i;++l)(e=t[l]).x-=r.x,e.y-=r.y;return r.r}function Z(t){return null==t?null:J(t)}function J(t){if("function"!=typeof t)throw new Error;return t}function K(){return 0}function X(t){return function(){return t}}function Y(t){return Math.sqrt(t.value)}function Q(){var t=null,e=1,n=1,r=K;function o(i){return i.x=e/2,i.y=n/2,t?i.eachBefore(tt(t)).eachAfter(et(r,.5)).eachBefore(nt(1)):i.eachBefore(tt(Y)).eachAfter(et(K,1)).eachAfter(et(r,i.r/Math.min(e,n))).eachBefore(nt(Math.min(e,n)/(2*i.r))),i}return i(o,"pack"),o.radius=function(e){return arguments.length?(t=Z(e),o):t},o.size=function(t){return arguments.length?(e=+t[0],n=+t[1],o):[e,n]},o.padding=function(t){return arguments.length?(r="function"==typeof t?t:X(+t),o):r},o}function tt(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0))}}function et(t,e){return function(n){if(r=n.children){var r,i,o,a=r.length,l=t(n)*e||0;if(l)for(i=0;i<a;++i)r[i].r+=l;if(o=G(r),l)for(i=0;i<a;++i)r[i].r-=l;n.r=o+l}}}function nt(t){return function(e){var n=e.parent;e.r*=t,n&&(e.x=n.x+t*e.x,e.y=n.y+t*e.y)}}function rt(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function it(t,e,n,r,i){for(var o,a=t.children,l=-1,s=a.length,c=t.value&&(r-e)/t.value;++l<s;)(o=a[l]).y0=n,o.y1=i,o.x0=e,o.x1=e+=o.value*c}function ot(){var t=1,e=1,n=0,r=!1;function o(i){var o=i.height+1;return i.x0=i.y0=n,i.x1=t,i.y1=e/o,i.eachBefore(a(e,o)),r&&i.eachBefore(rt),i}function a(t,e){return function(r){r.children&&it(r,r.x0,t*(r.depth+1)/e,r.x1,t*(r.depth+2)/e);var i=r.x0,o=r.y0,a=r.x1-n,l=r.y1-n;a<i&&(i=a=(i+a)/2),l<o&&(o=l=(o+l)/2),r.x0=i,r.y0=o,r.x1=a,r.y1=l}}return i(o,"partition"),i(a,"positionNode"),o.round=function(t){return arguments.length?(r=!!t,o):r},o.size=function(n){return arguments.length?(t=+n[0],e=+n[1],o):[t,e]},o.padding=function(t){return arguments.length?(n=+t,o):n},o}function at(t,e){return t.parent===e.parent?1:2}function lt(t){var e=t.children;return e?e[0]:t.t}function st(t){var e=t.children;return e?e[e.length-1]:t.t}function ct(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 ut(t){for(var e,n=0,r=0,i=t.children,o=i.length;--o>=0;)(e=i[o]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}function ht(t,e,n){return t.a.parent===e.parent?t.a:n}function pt(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}function dt(t){for(var e,n,r,i,o,a=new pt(t,0),l=[a];e=l.pop();)if(r=e._.children)for(e.children=new Array(o=r.length),i=o-1;i>=0;--i)l.push(n=e.children[i]=new pt(r[i],i)),n.parent=e;return(a.parent=new pt(null,0)).children=[a],a}function ft(){var t=at,e=1,n=1,r=null;function o(i){var o=dt(i);if(o.eachAfter(a),o.parent.m=-o.z,o.eachBefore(l),r)i.eachBefore(c);else{var s=i,u=i,h=i;i.eachBefore(function(t){t.x<s.x&&(s=t),t.x>u.x&&(u=t),t.depth>h.depth&&(h=t)});var p=s===u?1:t(s,u)/2,d=p-s.x,f=e/(u.x+p+d),y=n/(h.depth||1);i.eachBefore(function(t){t.x=(t.x+d)*f,t.y=t.depth*y})}return i}function a(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){ut(e);var o=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-o):e.z=o}else i&&(e.z=i.z+t(e._,i._));e.parent.A=s(e,i,e.parent.A||r[0])}function l(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(e,n,r){if(n){for(var i,o=e,a=e,l=n,s=o.parent.children[0],c=o.m,u=a.m,h=l.m,p=s.m;l=st(l),o=lt(o),l&&o;)s=lt(s),(a=st(a)).a=e,(i=l.z+h-o.z-c+t(l._,o._))>0&&(ct(ht(l,e,r),e,i),c+=i,u+=i),h+=l.m,c+=o.m,p+=s.m,u+=a.m;l&&!st(a)&&(a.t=l,a.m+=h-u),o&&!lt(s)&&(s.t=o,s.m+=c-p,r=e)}return r}function c(t){t.x*=e,t.y=t.depth*n}return i(o,"tree"),i(a,"firstWalk"),i(l,"secondWalk"),i(s,"apportion"),i(c,"sizeNode"),o.separation=function(e){return arguments.length?(t=e,o):t},o.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],o):r?null:[e,n]},o.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],o):r?[e,n]:null},o}function yt(t,e,n,r,i){for(var o,a=t.children,l=-1,s=a.length,c=t.value&&(i-n)/t.value;++l<s;)(o=a[l]).x0=e,o.x1=r,o.y0=n,o.y1=n+=o.value*c}i(R,"shuffle"),i(L,"enclose"),i(B,"extendBasis"),i(E,"enclosesNot"),i(N,"enclosesWeak"),i(q,"enclosesWeakAll"),i(O,"encloseBasis"),i(V,"encloseBasis1"),i(F,"encloseBasis2"),i(W,"encloseBasis3"),i(j,"place"),i($,"intersects"),i(H,"score"),i(U,"Node"),i(G,"packEnclose"),i(Z,"optional"),i(J,"required"),i(K,"constantZero"),i(X,"constant$1"),i(Y,"defaultRadius"),i(Q,"d3Pack"),i(tt,"radiusLeaf"),i(et,"packChildren"),i(nt,"translateChild"),i(rt,"roundNode"),i(it,"d3treemapDice"),i(ot,"d3Parition"),i(at,"defaultSeparation"),i(lt,"nextLeft"),i(st,"nextRight"),i(ct,"moveSubtree"),i(ut,"executeShifts"),i(ht,"nextAncestor"),i(pt,"TreeNode"),pt.prototype=Object.create(A.prototype),i(dt,"treeRoot"),i(ft,"d3Tree"),i(yt,"d3treemapSlice");var mt=(1+Math.sqrt(5))/2;function gt(t,e,n,r,i,o){for(var a,l,s,c,u,h,p,d,f,y,m,g=[],x=e.children,_=0,b=0,v=x.length,w=e.value;_<v;){s=i-n,c=o-r;do{u=x[b++].value}while(!u&&b<v);for(h=p=u,m=u*u*(y=Math.max(c/s,s/c)/(w*t)),f=Math.max(p/m,m/h);b<v;++b){if(u+=l=x[b].value,l<h&&(h=l),l>p&&(p=l),m=u*u*y,(d=Math.max(p/m,m/h))>f){u-=l;break}f=d}g.push(a={value:u,dice:s<c,children:x.slice(_,b)}),a.dice?it(a,n,r,i,w?r+=c*u/w:o):yt(a,n,r,w?n+=s*u/w:i,o),w-=u,_=b}return g}i(gt,"squarifyRatio");const xt=i(function t(e){function n(t,n,r,i,o){gt(e,t,n,r,i,o)}return i(n,"squarify"),n.ratio=function(e){return t((e=+e)>1?e:1)},n},"custom")(mt);function _t(){var t=xt,e=!1,n=1,r=1,o=[0],a=K,l=K,s=K,c=K,u=K;function h(t){return t.x0=t.y0=0,t.x1=n,t.y1=r,t.eachBefore(p),o=[0],e&&t.eachBefore(rt),t}function p(e){var n=o[e.depth],r=e.x0+n,i=e.y0+n,h=e.x1-n,p=e.y1-n;h<r&&(r=h=(r+h)/2),p<i&&(i=p=(i+p)/2),e.x0=r,e.y0=i,e.x1=h,e.y1=p,e.children&&(n=o[e.depth+1]=a(e)/2,r+=u(e)-n,i+=l(e)-n,(h-=s(e)-n)<r&&(r=h=(r+h)/2),(p-=c(e)-n)<i&&(i=p=(i+p)/2),t(e,r,i,h,p))}return i(h,"treemap"),i(p,"positionNode"),h.round=function(t){return arguments.length?(e=!!t,h):e},h.size=function(t){return arguments.length?(n=+t[0],r=+t[1],h):[n,r]},h.tile=function(e){return arguments.length?(t=J(e),h):t},h.padding=function(t){return arguments.length?h.paddingInner(t).paddingOuter(t):h.paddingInner()},h.paddingInner=function(t){return arguments.length?(a="function"==typeof t?t:X(+t),h):a},h.paddingOuter=function(t){return arguments.length?h.paddingTop(t).paddingRight(t).paddingBottom(t).paddingLeft(t):h.paddingTop()},h.paddingTop=function(t){return arguments.length?(l="function"==typeof t?t:X(+t),h):l},h.paddingRight=function(t){return arguments.length?(s="function"==typeof t?t:X(+t),h):s},h.paddingBottom=function(t){return arguments.length?(c="function"==typeof t?t:X(+t),h):c},h.paddingLeft=function(t){return arguments.length?(u="function"==typeof t?t:X(+t),h):u},h}function bt(t,e,n,r,o){var a,l,s=t.children,c=s.length,u=new Array(c+1);for(u[0]=l=a=0;a<c;++a)u[a+1]=l+=s[a].value;function h(t,e,n,r,i,o,a){if(t>=e-1){var l=s[t];return l.x0=r,l.y0=i,l.x1=o,void(l.y1=a)}for(var c=u[t],p=n/2+c,d=t+1,f=e-1;d<f;){var y=d+f>>>1;u[y]<p?d=y+1:f=y}p-u[d-1]<u[d]-p&&t+1<d&&--d;var m=u[d]-c,g=n-m;if(o-r>a-i){var x=(r*g+o*m)/n;h(t,d,m,r,i,x,a),h(d,e,g,x,i,o,a)}else{var _=(i*g+a*m)/n;h(t,d,m,r,i,o,_),h(d,e,g,r,_,o,a)}}h(0,c,t.value,e,n,r,o),i(h,"partition")}function vt(t,e,n,r,i){(1&t.depth?yt:it)(t,e,n,r,i)}i(_t,"d3Treemap"),i(bt,"d3treemapBinary"),i(vt,"d3treemapSliceDice");const wt=i(function t(e){function n(t,n,r,i,o){if((a=t._squarify)&&a.ratio===e)for(var a,l,s,c,u,h=-1,p=a.length,d=t.value;++h<p;){for(s=(l=a[h]).children,c=l.value=0,u=s.length;c<u;++c)l.value+=s[c].value;l.dice?it(l,n,r,i,r+=(o-r)*l.value/d):yt(l,n,r,n+=(i-n)*l.value/d,o),d-=l.value}else t._squarify=a=gt(e,t,n,r,i,o),a.ratio=e}return i(n,"resquarify"),n.ratio=function(e){return t((e=+e)>1?e:1)},n},"custom")(mt),St=class _CirclePacking extends n.SVGWidget{diameter;pack;svg;_focus;circle;view;_node;constructor(){super(),e.ITree.call(this)}enter(t,e){this.diameter=Math.min(this.width(),this.height()),this.pack=Q().size([this.diameter-4,this.diameter-4]).padding(1.5),this.svg=e.append("g")}update(t,e){const r=this;this.diameter=Math.min(this.width(),this.height()),this.pack.size([this.diameter-4,this.diameter-4]).padding(1.5),this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this.svg.selectAll("circle").remove(),this.svg.selectAll("text").remove();const i=z(this.data()).sum(function(t){return t&&t.size?t.size:1}).sort(function(t,e){return t.value<e.value?-1:t.value>e.value?1:0});this._focus=i,this.pack(i),this.circle=this.svg.selectAll("circle").data(i.descendants()).enter().append("circle").attr("class",function(t){return t.parent?t.children?"node":"node leaf":"node root"}).style("fill",function(t){return t.color=r.paletteDepthLevel_exists()&&t.depth>r.paletteDepthLevel()?n.rgb(t.parent.color)[r.paletteDepthVariant()](1):r._palette(t.data.label),t.color}).on("click",function(t){r.click(t.data,null,null)}).on("dblclick",function(t){this._focus!==t&&r.zoom(t),n.d3Event().stopPropagation()}),this.circle.append("title").text(function(t){return t.data.label}),this.svg.selectAll("text").data(i.descendants()).enter().append("text").attr("class","label").style("fill-opacity",function(t){return t.parent===i?1:0}).style("display",function(t){return t.parent===i?null:"none"}).text(function(t){return t.data.label+(r.showSize()&&void 0!==t.data.size?" "+t.data.size:"")}),this._node=this.svg.selectAll("circle,text"),this.zoomTo([i.x,i.y,2*i.r])}zoom(t){this._focus=t;const e=this,r=this.svg.transition().duration(n.d3Event().altKey?7500:750).tween("zoom",function(){const t=n.interpolateZoom(e.view,[e._focus.x,e._focus.y,2*e._focus.r]);return function(n){e.zoomTo(t(n))}});function o(t){return t===e._focus&&!t.children||t.parent===e._focus}i(o,"showText"),r.selectAll("text").filter(function(t){return o(t)||"inline"===this.style.display}).style("fill-opacity",function(t){return o(t)?1:0}).on("start",function(t){o(t)&&(this.style.display="inline")}).on("end",function(t){o(t)||(this.style.display="none")})}zoomTo(t){const e=this.diameter/t[2];this.view=t,this._node.attr("transform",function(n){return"translate("+(n.x-t[0])*e+","+(n.y-t[1])*e+")"}),this.circle.attr("r",function(t){return t.r*e})}};i(St,"CirclePacking");let Tt=St;Tt.prototype._class+=" tree_CirclePacking",Tt.prototype.implements(e.ITree.prototype),Tt.prototype.publish("showSize",!0,"boolean","Show size along with label"),Tt.prototype.publish("paletteDepthLevel",null,"number","If not null then beyond this depth number the child node colors are based on parent",null,{optional:!0}),Tt.prototype.publish("paletteDepthVariant","brighter","set","Determines paletteDepthLevel decendant color shade variant",["brighter","darker"],{disable:i(t=>t.paletteDepthLevel_exists(),"disable")}),Tt.prototype.publish("paletteID","default","set","Color palette for this widget",Tt.prototype._palette.switch(),{tags:["Basic","Shared"]}),Tt.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]});const Ct=class _DendrogramColumn extends n.PropertyExt{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};i(Ct,"DendrogramColumn");let zt=Ct;zt.prototype._class+=" tree_Dendrogram.DendrogramColumn",zt.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const Mt=class _Dendrogram extends n.SVGZoomWidget{Column;_d3LayoutCluster;_d3LayoutTree;_d3Layout;constructor(){super(),e.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this),this._drawStartPos="origin",this._d3LayoutCluster=p(),this._d3LayoutTree=ft()}dendrogramData(){if(0===this.data().length)return[];if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.rollupView(this.mappings().map(function(t){return t.column()})).entries()});function t(e){return{label:e.key,children:e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),origRows:e.values}}}enter(t,e){super.enter(t,e),this._renderElement.attr("opacity",0).transition().duration(500).attr("opacity",1),this._selection.widgetElement(this._renderElement)}update(t,e){super.update(t,e);const r=this,o="vertical"===this.orientation();this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this._d3Layout=this.dendrogram()?this._d3LayoutCluster:this._d3LayoutTree,this.radial()?(this._d3Layout.size([360,2*this.separation()]),this._d3Layout.separation(i(function(t,e){return(t.parent===e.parent?1:2)/t.depth},"separation"))):(this._d3Layout.nodeSize([14,this.separation()]),this._d3Layout.separation(i(function(t,e){return t.parent===e.parent?1:2},"separation")));const a=z(this.dendrogramData());this._d3Layout(a);const l=a.descendants(),s=a.descendants().slice(1);function c(t){return"M"+t.parent.x+","+t.parent.y+"C"+t.parent.x+","+(t.parent.y+t.y)/2+" "+t.x+","+(t.parent.y+t.y)/2+" "+t.x+","+t.y}function u(t){return"M"+t.y+","+t.x+"C"+(t.y+t.parent.y)/2+","+t.x+" "+(t.y+t.parent.y)/2+","+t.parent.x+" "+t.parent.y+","+t.parent.x}function h(t){return o?c(t):u(t)}function p(t,e){const n=(t-90)/180*Math.PI,r=e;return[r*Math.cos(n),r*Math.sin(n)]}function d(t){return"M"+p(t.x,t.y)+"C"+p(t.x,(t.y+t.parent.y)/2)+" "+p(t.parent.x,(t.y+t.parent.y)/2)+" "+p(t.parent.x,t.parent.y)}i(c,"linkVertical"),i(u,"linkHorizontal"),i(h,"diagonal"),i(p,"project"),i(d,"radialDiagonal");const f=this._renderCount?500:0,y=this._renderElement.selectAll(".link").data(s);y.enter().append("path").attr("class","link").attr("d",this.radial()?d:h),y.transition().duration(f).attr("d",this.radial()?d:h),y.exit().remove();const m=this.circleRadius()+2;function g(t){return r.radial()?"rotate("+(t.x-90)+")translate("+t.y+")":"horizontal"===r.orientation()?"translate("+t.y+","+t.x+")":"translate("+t.x+","+t.y+")"}i(g,"nodeTransform");const x=this._renderElement.selectAll(".node").data(l);x.transition().duration(f).attr("transform",g);const _=x.enter().append("g").attr("class","node").attr("transform",g).call(this._selection.enter.bind(this._selection)).on("click",function(t){let e=t;for(;e.children;)e=e.children[0];t.depth>0&&(e.origRows?r.click(r.rowToObj(e.origRows[0]),r.mappings()[t.depth-1].column(),!0):r.click(e.data,r.mappings()[t.depth-1].column(),!0))}).on("dblclick",function(t){let e=t;for(;e.children;)e=e.children[0];t.depth>0&&(e.origRows?r.dblclick(r.rowToObj(e.origRows[0]),r.mappings()[t.depth-1].column(),!0):r.dblclick(e.data,r.mappings()[t.depth-1].column(),!0))}).each(function(){const t=n.select(this);t.append("circle"),t.append("text")});_.merge(x).select("circle").attr("r",this.circleRadius()).style("fill",function(t){return r._palette(t.data.label)}).append("title").text(function(t){return t.data.label}),_.merge(x).select("text").attr("dx",function(t){return r.radial()?t.children?t.x<180?-m:m:t.x<180?m:-m:o?t.children?m:-m:t.children?-m:m}).attr("dy","0.25em").style("text-anchor",function(t){return r.radial()?t.children?t.x<180?"end":"start":t.x<180?"start":"end":o?t.children?"start":"end":t.children?"end":"start"}).attr("transform",function(t){return r.radial()?t.x<180?null:"rotate(180)":o?"rotate(-66)":null}).text(function(t){return t.data.label}),x.exit().remove(),this._renderCount||r.zoomToFit()}};i(Mt,"Dendrogram");let kt=Mt;kt.prototype._class+=" tree_Dendrogram",kt.prototype.implements(e.ITree.prototype),kt.prototype.mixin(n.Utility.SimpleSelectionMixin),kt.prototype.Column=zt,kt.prototype.publish("paletteID","default","set","Color palette for this widget",kt.prototype._palette.switch(),{tags:["Basic","Shared"]}),kt.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]}),kt.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:zt}),kt.prototype.publish("circleRadius",4.5,"number","Text offset from circle"),kt.prototype.publish("separation",240,"number","Leaf Separation"),kt.prototype.publish("dendrogram",!0,"boolean","Dendrogram"),kt.prototype.publish("radial",!1,"boolean","Radial"),kt.prototype.publish("orientation","horizontal","set","Orientation",["horizontal","vertical"],{tags:["Private"],disable:i(t=>t.radial(),"disable")});const Dt=class _DirectoryTree extends n.HTMLWidget{constructor(){super()}flattenData(t){const e=this,n=z(t),r=[];return this.omitRoot()?n.children&&n.children.forEach(i):i(n),r;function i(t){const n=t.data.markers&&t.data.markers.length?t.data.markers.length:"";r.push({label:t.data.label,depth:t.depth-(e.omitRoot()?1:0),content:t.data.content,isFolder:!!t.data.children,iconClass:t.data.iconClass,color:t.data.color,bold:t.data.bold,weightValue:n,markers:t.data.markers,selected:t.data.selected}),t.children&&t.children.forEach(i)}}iconClass(t){return"error"===t.label?"fa fa-exclamation":t.isFolder?this.folderIconOpen():this.textFileIcon()}calcRequiredWidth(){const t=this.flattenData(this.data());let e=0;const r=this.rowItemPadding(),i=this.iconSize()+2*r,o=n.Platform.getScrollbarWidth();return t.forEach(t=>{const a=t.depth*i+2*r,l=n.Utility.textSize(t.label,this.fontFamily(),this.fontSize(),!!t.bold).width+2*r+i+a+o;e<l&&(e=l)}),e}rowClick(t,e){}enter(t,e){super.enter(t,e),e.style("width","100%").style("height","100%")}update(t,e){super.update(t,e),this._palette=this._palette.switch(this.paletteID()),e.style("overflow-y",this.verticalScroll()?"scroll":null);const r=this.flattenData(this.data()),i=n.max(r,t=>Number(t.weightValue));r.forEach(t=>{t.weightValue?t.weightColor=this._palette(t.weightValue,1,i):t.weightColor="transparent"});const o=this,a=this.rowItemPadding(),l=this.iconSize()+a,s=Math.max(o.iconSize(),o.fontSize()),c=e.selectAll(".directory-row").data(r),u=this.fontFamily(),h=this.fontSize(),p=n.max(r,t=>this.textSize(t.weightValue,u,h).width),d=`${a}px ${a}px ${a/2}px ${a}px`;c.enter().append("div").attr("class",t=>`directory-row directory-row-depth-${t.depth}`).style("display","flex").style("cursor","pointer").each(function(t){const r=n.select(this),i=t.color?t.color:o.fontColor(),c=t.weightColor?t.weightColor:"transparent",f=n.Palette.textColor(c),y=r.append("div").attr("class","row-weight").style("padding",d).style("color",f).style("box-shadow",`inset 0 0 100px ${c}`).style("font-weight",t.bold?"bold":"normal").style("font-family",u).style("font-size",h+"px").text(t.weightValue).attr("title",t.weightValue).style("overflow","hidden").style("width",p+2*a+"px").style("text-overflow","ellipsis").style("text-align","right").style("line-height",s+"px");r.append("div").attr("class","row-depth").style("width",o.depthSize()*t.depth+"px").style("opacity",1).style("line-height",s+"px");const m=r.append("div").attr("class","row-icon "+(t.iconClass?t.iconClass:o.iconClass(t))).style("width",l+"px").style("height",s+"px").style("color",i).style("background-color",t.selected?o.selectionBackgroundColor():"transparent").style("font-size",o.iconSize()+"px").style("padding",d).style("line-height",s+"px"),g=r.append("div").attr("class","row-label").style("padding",d).style("color",i).style("background-color",t.selected?o.selectionBackgroundColor():"transparent").style("font-weight",t.bold?"bold":"normal").style("font-family",o.fontFamily()).style("font-size",o.fontSize()+"px").text(t.label).attr("title",t.label).style("flex",1).style("overflow","hidden").style("text-overflow","ellipsis").style("line-height",s+"px");r.on("mouseenter",()=>{g.style("font-weight","bold")}).on("mouseleave",()=>{g.style("font-weight",t.bold?"bold":"normal")}),y.on("mouseenter",()=>{o.weight_mouseenter(t)}).on("mouseleave",()=>{o.weight_mouseleave(t)}),t.isFolder?r.on("click",function(t){let e=this.nextSibling;const i=r.classed("folder-closed");for(i?(r.classed("folder-closed",!1),r.classed("folder-open",!0),m.attr("class","row-icon "+o.folderIconOpen())):(r.classed("folder-closed",!0),r.classed("folder-open",!1),m.attr("class","row-icon "+o.folderIconClosed()));null!==e;){n.select(e).datum().depth>t.depth?(e.style.display=i?"flex":"none",e=e.nextSibling):e=null}}):r.on("click",()=>{e.selectAll(".row-label").style("background-color","transparent"),e.selectAll(".row-icon").style("background-color","transparent"),m.style("background-color",o.selectionBackgroundColor()),g.style("background-color",o.selectionBackgroundColor());const n=t.label.split(".").pop().toLowerCase();o.rowClick("json"===n?JSON.stringify(JSON.parse(t.content),null,4):t.content,t.markers)})}).merge(c).style("background-color",o.backgroundColor()),c.exit().remove()}weight_mouseenter(t){}weight_mouseleave(t){}};i(Dt,"DirectoryTree");let It=Dt;It.prototype._class+=" tree_DirectoryTree",It.prototype._palette=n.Palette.rainbow("Blues"),It.prototype.publish("depthSize",14,"number","Width of indentation per file or folder depth (pixels)"),It.prototype.publish("paletteID","Blues","set","Color palette for the weight backgrounds",It.prototype._palette.switch(),{tags:["Basic"]}),It.prototype.publish("omitRoot",!1,"boolean","If true, root node will not display"),It.prototype.publish("rowItemPadding",2,"number","Top, bottom, left and right row item padding"),It.prototype.publish("selectionBackgroundColor","#CCC","html-color","Background color of selected directory rows"),It.prototype.publish("backgroundColor","#FFF","html-color","Directory item background color"),It.prototype.publish("fontColor","#000","html-color","Directory item font color"),It.prototype.publish("fontFamily","Arial","string","Directory item font family"),It.prototype.publish("fontSize",12,"number","Directory item font size (pixels)"),It.prototype.publish("iconSize",12,"number","Directory folder and file icon size (pixels)"),It.prototype.publish("folderIconOpen","fa fa-folder-open","string","Open folder icon class"),It.prototype.publish("folderIconClosed","fa fa-folder","string","Closed folder icon class"),It.prototype.publish("textFileIcon","fa fa-file-text-o","string","Text file icon class"),It.prototype.publish("verticalScroll",!0,"boolean","If true, vertical scroll bar will be shown");const At=class _IndentedColumn extends n.PropertyExt{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};i(At,"IndentedColumn");let Pt=At;Pt.prototype._class+=" tree_Dendrogram.IndentedColumn",Pt.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const Rt=class _Indented extends n.SVGZoomWidget{Column;_d3Tree;_xml;_svgLinks;_svgNodes;_treeData;_collapsed={};constructor(){super(),e.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this),this._drawStartPos="origin",this._d3Tree=ft()}xmlToData(t,e=""){if(DOMParser){return Bt((new DOMParser).parseFromString(t,"text/xml"),e).children[0]}return[]}xml(t){return arguments.length?(this._xml=t,this.data(this.xmlToData(this._xml)),this):this._xml}IndentedData(){if(0===this.data().length)return[];if(this.xmlColumn_exists()){const t=this.columns().indexOf(this.xmlColumn()),e={label:this.xmlColumn(),children:this.data().map(function(e,n){return this.xmlToData(e[t],"["+n+"]")},this)};return 1===e.children.length?e.children[0]:e}if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.rollupView(this.mappings().map(function(t){return t.column()})).entries()});function t(e){if(e.values instanceof Array){const n=e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),r={label:e.key};return n.length?r.children=n:r.size=22,r}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(t,e){super.enter(t,e),this._svgLinks=this._renderElement.append("g"),this._svgNodes=this._renderElement.append("g"),this._selection.widgetElement(this._svgNodes)}_prevDataChecksum;update(t,e){super.update(t,e);const r=this;this._d3Tree.nodeSize([0,this.barHeight()]);const o=this._db.dataChecksum();function a(t){return(t.parent?a(t.parent)+".":"")+t.data.label}this._prevDataChecksum!==o&&(this._treeData=this.IndentedData(),this._prevDataChecksum=o),i(a,"getID");const l=z(this.data()).sum(function(t){return t.size||50}).each(t=>{this._collapsed[a(t)]&&delete t.children}),s=this._d3Tree(l).descendants(),c=this._d3Tree(l).descendants().slice(1);let u=0;l.eachBefore(t=>{t.x=u*r.barHeight(),++u});const h=this.barHeight()-4,p=this._renderCount?500:0,d=this._svgLinks.selectAll(".link").data(c,function(t){return a(t)});function f(t){return"M"+t.parent.y+","+t.parent.x+"V"+t.x+", H"+t.y}d.enter().append("path").attr("class","link").attr("d",f),d.transition().duration(p).attr("d",f),d.exit().remove(),i(f,"elbow");const y=this._svgNodes.selectAll(".node").data(s,function(t){return a(t)});y.transition().duration(p).attr("transform",function(t){return"translate("+t.y+","+t.x+")"});const m=y.enter().append("g").attr("class","node").attr("transform",function(t){return"translate("+t.y+","+t.x+")"}).call(this._selection.enter.bind(this._selection)).each(function(){const t=n.select(this);t.append("rect").attr("height",h).attr("width",h).on("click",function(t){r._collapsed[a(t)]?delete r._collapsed[a(t)]:t.children&&(r._collapsed[a(t)]=!0),r.lazyRender()}),t.append("text")}).style("opacity",0);function g(t){return r._collapsed[a(t)]?"#3182bd":t.children?"#c6dbef":"#fd8d3c"}m.transition().style("opacity",1),m.merge(y).select("rect").attr("x",-h/2).attr("y",-h/2).style("fill",g),m.merge(y).select("text").attr("dx",h/2+4+"px").attr("dy","0.33em").text(function(t){return t.data.label}),y.exit().transition().style("opacity",0).remove(),this._renderCount||r.zoomToFit(),i(g,"color")}};i(Rt,"Indented");let Lt=Rt;function Bt(t,e=""){const n={id:e,label:"",attributes:{},children:[]};if(n.label=t.nodeName,1===t.nodeType){if(t.attributes.length>0)for(let r=0;r<t.attributes.length;r++){const e=t.attributes.item(r);n.attributes[e.nodeName]=e.nodeValue}}else 3===t.nodeType&&(n.label=t.nodeValue);if(t.hasChildNodes())for(let r=0;r<t.childNodes.length;r++){const i=Bt(t.childNodes.item(r),e+"["+n.children.length+"]");n.children.push(i)}return n}Lt.prototype._class+=" tree_Indented",Lt.prototype.implements(e.ITree.prototype),Lt.prototype.mixin(n.Utility.SimpleSelectionMixin),Lt.prototype.Column=Pt,Lt.prototype.publish("xmlColumn",null,"set","Field",function(){return this.columns()},{optional:!0}),Lt.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:Pt,disable:i(t=>t.xmlColumn_exists(),"disable")}),Lt.prototype.publish("barHeight",16,"number","Bar height"),i(Bt,"xmlToJson");var Et=Math.PI,Nt=2*Et,qt=1e-6,Ot=Nt-qt;function Vt(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function Ft(){return new Vt}function Wt(t){return i(function(){return t},"constant")}i(Vt,"Path"),i(Ft,"path"),Vt.prototype=Ft.prototype={constructor:Vt,moveTo:i(function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)},"moveTo"),closePath:i(function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},"closePath"),lineTo:i(function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e)},"lineTo"),quadraticCurveTo:i(function(t,e,n,r){this._+="Q"+ +t+","+ +e+","+(this._x1=+n)+","+(this._y1=+r)},"quadraticCurveTo"),bezierCurveTo:i(function(t,e,n,r,i,o){this._+="C"+ +t+","+ +e+","+ +n+","+ +r+","+(this._x1=+i)+","+(this._y1=+o)},"bezierCurveTo"),arcTo:i(function(t,e,n,r,i){t=+t,e=+e,n=+n,r=+r,i=+i;var o=this._x1,a=this._y1,l=n-t,s=r-e,c=o-t,u=a-e,h=c*c+u*u;if(i<0)throw new Error("negative radius: "+i);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(h>qt)if(Math.abs(u*l-s*c)>qt&&i){var p=n-o,d=r-a,f=l*l+s*s,y=p*p+d*d,m=Math.sqrt(f),g=Math.sqrt(h),x=i*Math.tan((Et-Math.acos((f+h-y)/(2*m*g)))/2),_=x/g,b=x/m;Math.abs(_-1)>qt&&(this._+="L"+(t+_*c)+","+(e+_*u)),this._+="A"+i+","+i+",0,0,"+ +(u*p>c*d)+","+(this._x1=t+b*l)+","+(this._y1=e+b*s)}else this._+="L"+(this._x1=t)+","+(this._y1=e);else;},"arcTo"),arc:i(function(t,e,n,r,i,o){t=+t,e=+e,o=!!o;var a=(n=+n)*Math.cos(r),l=n*Math.sin(r),s=t+a,c=e+l,u=1^o,h=o?r-i:i-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+s+","+c:(Math.abs(this._x1-s)>qt||Math.abs(this._y1-c)>qt)&&(this._+="L"+s+","+c),n&&(h<0&&(h=h%Nt+Nt),h>Ot?this._+="A"+n+","+n+",0,1,"+u+","+(t-a)+","+(e-l)+"A"+n+","+n+",0,1,"+u+","+(this._x1=s)+","+(this._y1=c):h>qt&&(this._+="A"+n+","+n+",0,"+ +(h>=Et)+","+u+","+(this._x1=t+n*Math.cos(i))+","+(this._y1=e+n*Math.sin(i))))},"arc"),rect:i(function(t,e,n,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},"rect"),toString:i(function(){return this._},"toString")},i(Wt,"constant");var jt=Math.abs,$t=Math.atan2,Ht=Math.cos,Ut=Math.max,Gt=Math.min,Zt=Math.sin,Jt=Math.sqrt,Kt=1e-12,Xt=Math.PI,Yt=Xt/2,Qt=2*Xt;function te(t){return t>1?0:t<-1?Xt:Math.acos(t)}function ee(t){return t>=1?Yt:t<=-1?-Yt:Math.asin(t)}function ne(t){return t.innerRadius}function re(t){return t.outerRadius}function ie(t){return t.startAngle}function oe(t){return t.endAngle}function ae(t){return t&&t.padAngle}function le(t,e,n,r,i,o,a,l){var s=n-t,c=r-e,u=a-i,h=l-o,p=h*s-u*c;if(!(p*p<Kt))return[t+(p=(u*(e-o)-h*(t-i))/p)*s,e+p*c]}function se(t,e,n,r,i,o,a){var l=t-n,s=e-r,c=(a?o:-o)/Jt(l*l+s*s),u=c*s,h=-c*l,p=t+u,d=e+h,f=n+u,y=r+h,m=(p+f)/2,g=(d+y)/2,x=f-p,_=y-d,b=x*x+_*_,v=i-o,w=p*y-f*d,S=(_<0?-1:1)*Jt(Ut(0,v*v*b-w*w)),T=(w*_-x*S)/b,C=(-w*x-_*S)/b,z=(w*_+x*S)/b,M=(-w*x+_*S)/b,k=T-m,D=C-g,I=z-m,A=M-g;return k*k+D*D>I*I+A*A&&(T=z,C=M),{cx:T,cy:C,x01:-u,y01:-h,x11:T*(i/v-1),y11:C*(i/v-1)}}function ce(){var t=ne,e=re,n=Wt(0),r=null,o=ie,a=oe,l=ae,s=null;function c(){var i,c,u=+t.apply(this,arguments),h=+e.apply(this,arguments),p=o.apply(this,arguments)-Yt,d=a.apply(this,arguments)-Yt,f=jt(d-p),y=d>p;if(s||(s=i=Ft()),h<u&&(c=h,h=u,u=c),h>Kt)if(f>Qt-Kt)s.moveTo(h*Ht(p),h*Zt(p)),s.arc(0,0,h,p,d,!y),u>Kt&&(s.moveTo(u*Ht(d),u*Zt(d)),s.arc(0,0,u,d,p,y));else{var m,g,x=p,_=d,b=p,v=d,w=f,S=f,T=l.apply(this,arguments)/2,C=T>Kt&&(r?+r.apply(this,arguments):Jt(u*u+h*h)),z=Gt(jt(h-u)/2,+n.apply(this,arguments)),M=z,k=z;if(C>Kt){var D=ee(C/u*Zt(T)),I=ee(C/h*Zt(T));(w-=2*D)>Kt?(b+=D*=y?1:-1,v-=D):(w=0,b=v=(p+d)/2),(S-=2*I)>Kt?(x+=I*=y?1:-1,_-=I):(S=0,x=_=(p+d)/2)}var A=h*Ht(x),P=h*Zt(x),R=u*Ht(v),L=u*Zt(v);if(z>Kt){var B,E=h*Ht(_),N=h*Zt(_),q=u*Ht(b),O=u*Zt(b);if(f<Xt&&(B=le(A,P,q,O,E,N,R,L))){var V=A-B[0],F=P-B[1],W=E-B[0],j=N-B[1],$=1/Zt(te((V*W+F*j)/(Jt(V*V+F*F)*Jt(W*W+j*j)))/2),H=Jt(B[0]*B[0]+B[1]*B[1]);M=Gt(z,(u-H)/($-1)),k=Gt(z,(h-H)/($+1))}}S>Kt?k>Kt?(m=se(q,O,A,P,h,k,y),g=se(E,N,R,L,h,k,y),s.moveTo(m.cx+m.x01,m.cy+m.y01),k<z?s.arc(m.cx,m.cy,k,$t(m.y01,m.x01),$t(g.y01,g.x01),!y):(s.arc(m.cx,m.cy,k,$t(m.y01,m.x01),$t(m.y11,m.x11),!y),s.arc(0,0,h,$t(m.cy+m.y11,m.cx+m.x11),$t(g.cy+g.y11,g.cx+g.x11),!y),s.arc(g.cx,g.cy,k,$t(g.y11,g.x11),$t(g.y01,g.x01),!y))):(s.moveTo(A,P),s.arc(0,0,h,x,_,!y)):s.moveTo(A,P),u>Kt&&w>Kt?M>Kt?(m=se(R,L,E,N,u,-M,y),g=se(A,P,q,O,u,-M,y),s.lineTo(m.cx+m.x01,m.cy+m.y01),M<z?s.arc(m.cx,m.cy,M,$t(m.y01,m.x01),$t(g.y01,g.x01),!y):(s.arc(m.cx,m.cy,M,$t(m.y01,m.x01),$t(m.y11,m.x11),!y),s.arc(0,0,u,$t(m.cy+m.y11,m.cx+m.x11),$t(g.cy+g.y11,g.cx+g.x11),y),s.arc(g.cx,g.cy,M,$t(g.y11,g.x11),$t(g.y01,g.x01),!y))):s.arc(0,0,u,v,b,y):s.lineTo(R,L)}else s.moveTo(0,0);if(s.closePath(),i)return s=null,i+""||null}return i(c,"arc"),c.centroid=function(){var n=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,r=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-Xt/2;return[Ht(r)*n,Zt(r)*n]},c.innerRadius=function(e){return arguments.length?(t="function"==typeof e?e:Wt(+e),c):t},c.outerRadius=function(t){return arguments.length?(e="function"==typeof t?t:Wt(+t),c):e},c.cornerRadius=function(t){return arguments.length?(n="function"==typeof t?t:Wt(+t),c):n},c.padRadius=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:Wt(+t),c):r},c.startAngle=function(t){return arguments.length?(o="function"==typeof t?t:Wt(+t),c):o},c.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:Wt(+t),c):a},c.padAngle=function(t){return arguments.length?(l="function"==typeof t?t:Wt(+t),c):l},c.context=function(t){return arguments.length?(s=null==t?null:t,c):s},c}i(te,"acos"),i(ee,"asin"),i(ne,"arcInnerRadius"),i(re,"arcOuterRadius"),i(ie,"arcStartAngle"),i(oe,"arcEndAngle"),i(ae,"arcPadAngle"),i(le,"intersect"),i(se,"cornerTangents"),i(ce,"d3Arc");const ue=class _SunburstPartition extends n.SVGWidget{svg;radius;_xScale;_yScale;partition;arc;_resetRoot;constructor(){super(),e.ITree.call(this)}data(t){const e=n.SVGWidget.prototype.data.apply(this,arguments);return arguments.length&&(this._resetRoot=!0),e}enter(t,e){const r=this;this.radius=Math.min(this.width(),this.height())/2,this._xScale=n.scaleLinear().range([0,2*Math.PI]),this._yScale=n.scaleSqrt().range([0,this.radius]),this.partition=ot(),this.arc=ce().startAngle(function(t){return Math.max(0,Math.min(2*Math.PI,r._xScale(t.x0)))}).endAngle(function(t){return Math.max(0,Math.min(2*Math.PI,r._xScale(t.x1)))}).innerRadius(function(t){return Math.max(0,r._yScale(t.y0))}).outerRadius(function(t){return Math.max(0,r._yScale(t.y1))}),this.svg=e.append("g")}update(t,e){const r=this;this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id())),this.radius=Math.min(this.width(),this.height())/2,this._yScale.range([0,this.radius]);const i=z(this.data()).sum(function(t){return void 0!==t.size?t.size:1}),o=this.svg.selectAll("path").data(this.partition(i).descendants(),function(t,e){return void 0!==t.data.label?t.data.label:e});o.enter().append("path").on("click",function(t){r.click(t.data,null,null)}).on("dblclick",function(t){const e=n.d3Event();e&&e.stopPropagation(),r.zoomTo(t)}).each(function(){n.select(this).append("title")}).merge(o).attr("d",this.arc).style("fill",function(t){return t.data.__viz_fill?t.data.__viz_fill:r._palette(t.data.label)}).style("stroke",function(t){return t.value>16?"white":"none"}).select("title").text(function(t){return t.data.label}),o.exit().remove(),this._resetRoot&&(this._resetRoot=!1,this.zoomTo(i))}zoomTo(t){const e=this;this.svg.transition().duration(750).tween("scale",function(){const r=n.interpolate(e._xScale.domain(),[t.x0,t.x1]),i=n.interpolate(e._yScale.domain(),[t.y0,1]),o=n.interpolate(e._yScale.range(),[t.y0?20:0,e.radius]);return function(t){e._xScale.domain(r(t)),e._yScale.domain(i(t)).range(o(t))}}).selectAll("path").attrTween("d",function(t){return function(){return e.arc(t)}})}};i(ue,"SunburstPartition");let he=ue;he.prototype._class+=" tree_SunburstPartition",he.prototype.implements(e.ITree.prototype),he.prototype.publish("paletteID","default","set","Color palette for this widget",he.prototype._palette.switch(),{tags:["Basic","Shared"]}),he.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]});const pe=class _TreemapColumn extends n.PropertyExt{_owner;constructor(){super()}owner(t){return arguments.length?(this._owner=t,this):this._owner}valid(){return!!this.column()}column};i(pe,"TreemapColumn");let de=pe;de.prototype._class+=" tree_Dendrogram.TreemapColumn",de.prototype.publish("column",null,"set","Field",function(){return this._owner?this._owner.columns():[]},{optional:!0});const fe=class _Treemap extends n.HTMLWidget{Column;_d3Treemap;_elementDIV;_selection;constructor(){super(),e.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this,!0)}getTilingMethod(){switch(this.tilingMethod()){case"treemapBinary":return bt;case"treemapDice":return it;case"treemapSlice":return yt;case"treemapSliceDice":return vt;case"treemapResquarify":return wt;default:return xt}}treemapData(){if(!this.mappings().filter(t=>t.valid()).length)return this.data();return t({key:"root",values:this._db.aggregateView(this.mappings().map(function(t){return t.column()}),this.aggrType(),this.aggrColumn()).entries()});function t(e){if(e.values instanceof Array){const n=e.values.filter(function(t){return!(t instanceof Array)}).map(function(e){return t(e)}),r={label:e.key};return n.length?r.children=n:r.size=22,r}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(t,e){super.enter(t,e),this._d3Treemap=_t(),this._elementDIV=e.append("div"),this._selection.widgetElement(this._elementDIV)}update(t,e){super.update(t,e);const r=this;this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+"_"+this.id()));const o=z(this.treemapData()).sum(this.nodeWeight);this._d3Treemap.size([this.width(),this.height()]).paddingInner(this.paddingInner()).paddingOuter(this.paddingOuter()).paddingTop(this.paddingTop()),-1!==["treemapSquarify","treemapResquarify"].indexOf(this.tilingMethod())?this._d3Treemap.tile(this.getTilingMethod().ratio(this.squarifyRatio())):this._d3Treemap.tile(this.getTilingMethod()),this._d3Treemap(o),this._elementDIV.style("font-size",this.fontSize_exists()?this.fontSize()+"px":null).style("line-height",this.fontSize_exists()?this.fontSize()+2+"px":null);const a=this._elementDIV.selectAll(".node").data(o.descendants());function l(t){if(t.children&&!r.enableParentTooltips())return null;let e=t.data.label+" ("+t.value+")";for(;t.parent&&t.parent.parent;)e=t.parent.data.label+" -> "+e,t=t.parent;return e}a.enter().append("div").attr("class","node").call(this._selection.enter.bind(this._selection)).on("click",function(t){if(t){let e="";r.mappings().forEach(function(t){t.column()&&(e=t.column())}),t.origRows?r.click(r.rowToObj(t.origRows[0]),e,r._selection.selected(this)):r.click(t.data,e,r._selection.selected(this))}}).on("dblclick",function(t){if(t){let e="";r.mappings().forEach(function(t){t.column()&&(e=t.column())}),t.origRows?r.dblclick(r.rowToObj(t.origRows[0]),e,r._selection.selected(this)):r.dblclick(t.data,e,r._selection.selected(this))}}).merge(a).style("left",function(t){return t.x0+Math.max(0,t.x1-t.x0)/2+"px"}).style("top",function(t){return t.y0+Math.max(0,t.y1-t.y0)/2+"px"}).style("width",function(){return"0px"}).style("height",function(){return"0px"}).style("font-size",function(t){return(t.children?r.parentFontSize():r.leafFontSize())+"px"}).style("line-height",function(t){return(t.children?r.parentFontSize():r.leafFontSize())+"px"}).attr("title",l).html(function(t){return r.showRoot()||0!==t.depth?t.children?r.enableParentLabels()?r.parentWeightHTML(t):null:r.leafWeightHTML(t):null}).style("background",function(t){if(!r.showRoot()&&0===t.depth)return this.style.color="transparent","transparent";const e=r.brighterLeafNodes()?"brighter":"darker";let i;return r.usePaletteOnParentNodes()?i=t.children?r._palette(t.data.label):n.rgb(r._palette(t.parent.data.label))[e](1):(i=t.depth>r.depthColorLimit()?n.rgb(t.parent.color)[e](1):r._palette(t.data.label),t.color=i),this.style.color=n.Palette.textColor(i),i}).transition().duration(this.transitionDuration()).style("pointer-events",function(t){return r.showRoot()||0!==t.depth?"all":"none"}).style("opacity",function(t){return t.children?1:null}).style("left",function(t){return t.x0+"px"}).style("top",function(t){return t.y0+"px"}).style("width",function(t){return Math.max(0,t.x1-t.x0)+"px"}).style("height",function(t){return Math.max(0,t.y1-t.y0)+"px"}).each(function(t){0===t.depth&&(this.style.color=r.showRoot()?"":"transparent",this.style.borderColor=r.showRoot()?"":"transparent")}),a.exit().transition().duration(this.transitionDuration()).style("opacity",0).remove(),i(l,"tooltip")}exit(t,e){super.exit(t,e)}nodeWeight(t){return t.size||1}parentWeightHTML(t){return this.showParentWeight()?`<span class="treemap-parent-label">${t.data.label}</span><span class="treemap-parent-value">${t.value}${this.weightSuffix()}</span>`:`<span class="treemap-parent-label">${t.data.label}</span>`}leafWeightHTML(t){return this.showLeafWeight()?`<span class="treemap-leaf-label">${t.data.label}</span><span class="treemap-leaf-value">${t.value}${this.weightSuffix()}</span>`:`<span class="treemap-leaf-label">${t.data.label}</span>`}};i(fe,"Treemap");let ye=fe;ye.prototype._class+=" tree_Treemap",ye.prototype.implements(e.ITree.prototype),ye.prototype.mixin(n.Utility.SimpleSelectionMixin),ye.prototype.Column=de,ye.prototype.publish("paletteID","default","set","Color palette for this widget",ye.prototype._palette.switch(),{tags:["Basic","Shared"]}),ye.prototype.publish("useClonedPalette",!1,"boolean","Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]}),ye.prototype.publish("mappings",[],"propertyArray","Source Columns",null,{autoExpand:de}),ye.prototype.publish("aggrType",null,"set","Aggregation Type",[null,"mean","median","sum","min","max"],{optional:!0}),ye.prototype.publish("aggrColumn",null,"set","Aggregation Field",function(){return this.columns()},{optional:!0,disable:i(t=>!t.aggrType(),"disable")}),ye.prototype.publish("fontSize",null,"number","Font Size",null,{optional:!0}),ye.prototype.publish("paddingInner",18.6,"number","Pixel spacing between each sibling node"),ye.prototype.publish("paddingOuter",30,"number","Pixel padding of parent nodes"),ye.prototype.publish("paddingTop",41.4,"number","Additional top pixel padding of parent nodes"),ye.prototype.publish("showRoot",!1,"boolean","Show root element"),ye.prototype.publish("parentFontSize",18,"number","Parent font-size"),ye.prototype.publish("leafFontSize",16,"number","Leaf font-size"),ye.prototype.publish("usePaletteOnParentNodes",!1,"boolean","Assign a color from the palette to every parent node"),ye.prototype.publish("depthColorLimit",1,"number","Assign a color from the palette to node with depth lower than this value",null,{optional:!0,disable:i(t=>t.usePaletteOnParentNodes(),"disable")}),ye.prototype.publish("squarifyRatio",1,"number","Specifies the desired aspect ratio of the generated rectangles (must be >= 1)",null,{optional:!0,disable:i(t=>-1===["treemapSquarify","treemapResquarify"].indexOf(t.tilingMethod()),"disable")}),ye.prototype.publish("showParentWeight",!0,"boolean","Show weight of parent nodes"),ye.prototype.publish("showLeafWeight",!0,"boolean","Show weight of leaf nodes"),ye.prototype.publish("weightSuffix","","string","Weight suffix (ex: 'ms')"),ye.prototype.publish("brighterLeafNodes",!1,"boolean","Brighter/darker leaf node color (false = darker)"),ye.prototype.publish("enableParentLabels",!0,"boolean","Enable parent labels"),ye.prototype.publish("enableParentTooltips",!0,"boolean","Enable parent tooltips"),ye.prototype.publish("transitionDuration",250,"number","Transition Duration"),ye.prototype.publish("tilingMethod","treemapSquarify","set","Transition Duration",["treemapBinary","treemapDice","treemapResquarify","treemapSlice","treemapSliceDice","treemapSquarify"]),t.BUILD_VERSION="3.21.3",t.CirclePacking=Tt,t.Dendrogram=kt,t.DendrogramColumn=zt,t.DirectoryTree=It,t.Indented=Lt,t.IndentedColumn=Pt,t.PKG_NAME="@hpcc-js/tree",t.PKG_VERSION="3.2.13",t.SunburstPartition=he,t.Treemap=ye,t.TreemapColumn=de,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=index.umd.cjs.map
3
3
  !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".tree_CirclePacking circle{fill:#1f77b4;fill-opacity:.25;stroke:#1f77b4;stroke-width:1px}.tree_CirclePacking .leaf circle{fill:#ff7f0e;fill-opacity:1}.tree_CirclePacking .label{fill:#fff;text-anchor:middle}.tree_Dendrogram .node circle{fill:#dcf1ff;stroke:#1f77b4;stroke-width:1px}.tree_Dendrogram .node.selected circle{stroke:red}.tree_Dendrogram .node.over circle{stroke:orange}.tree_Dendrogram .node.selected.over circle{stroke:red}.tree_Dendrogram .node.selected text{fill:red}.tree_Dendrogram .node.over text{fill:orange}.tree_Dendrogram .node.selected.over text{fill:red}.tree_Dendrogram .node text{font-size:14px}.tree_Dendrogram .link{fill:none;stroke:#656565;stroke-width:1px}.tree_Indented .node rect{cursor:pointer;fill:#fff;stroke:#3182bd;stroke-width:1px}.tree_Indented .node text{font:10px sans-serif;pointer-events:none}.tree_Indented path.link{fill:none;stroke:#9ecae1;stroke-width:1.5px}.tree_Sunburst path{stroke:#fff;stroke-width:.5px;fill-rule:evenodd}.tree_Treemap *{box-sizing:border-box}.tree_Treemap .node{border:solid 1px #333;overflow:hidden;text-overflow:ellipsis;position:absolute}.tree_Treemap .node.selected{border-color:red}.tree_Treemap .node.over{border-color:orange}.tree_Treemap .node.selected.over{border-color:red}.tree_Treemap .node>span.treemap-parent-label{font-weight:700;display:inline-block;margin:4px 4px 0}.tree_Treemap .node>span.treemap-parent-value{font-weight:400;font-style:italic;margin:4px 0 0}.tree_Treemap .node>span.treemap-singleton-label{font-weight:400;display:block;margin:4px 0 0 4px}.tree_Treemap .node>span.treemap-singleton-value{font-style:italic;display:block;margin:0 0 0 4px}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/tree",
3
- "version": "3.2.12",
3
+ "version": "3.2.13",
4
4
  "description": "hpcc-js - Viz Tree",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.cjs",
@@ -37,11 +37,11 @@
37
37
  "update-major": "npx --yes npm-check-updates -u"
38
38
  },
39
39
  "dependencies": {
40
- "@hpcc-js/api": "^3.4.12",
41
- "@hpcc-js/common": "^3.7.2"
40
+ "@hpcc-js/api": "^3.4.13",
41
+ "@hpcc-js/common": "^3.7.3"
42
42
  },
43
43
  "devDependencies": {
44
- "@hpcc-js/esbuild-plugins": "^1.8.4",
44
+ "@hpcc-js/esbuild-plugins": "^1.8.5",
45
45
  "@types/d3-transition": "1.3.6",
46
46
  "d3-hierarchy": "^1",
47
47
  "d3-interpolate": "^1",
@@ -61,5 +61,5 @@
61
61
  "url": "https://github.com/hpcc-systems/Visualization/issues"
62
62
  },
63
63
  "homepage": "https://github.com/hpcc-systems/Visualization",
64
- "gitHead": "04460c76008934053c9957c361693aac862ca7dc"
64
+ "gitHead": "eab3a48367063ed368bdd82c05de6a822ee308aa"
65
65
  }