@hpcc-js/tree 3.2.20 → 3.3.0

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.
@@ -1,3 +1,3 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@hpcc-js/api"),require("@hpcc-js/common")):typeof define==`function`&&define.amd?define([`exports`,`@hpcc-js/api`,`@hpcc-js/common`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@hpcc-js/tree`]={},e[`@hpcc-js/api`],e[`@hpcc-js/common`]))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=Object.defineProperty,__name=(e,t)=>r(e,`name`,{value:t,configurable:!0}),i=`@hpcc-js/tree`,a=`3.2.20`,o=`3.25.1`;function defaultSeparation$1(e,t){return e.parent===t.parent?1:2}__name(defaultSeparation$1,`defaultSeparation`);function meanX(e){return e.reduce(meanXReduce,0)/e.length}function meanXReduce(e,t){return e+t.x}function maxY(e){return 1+e.reduce(maxYReduce,0)}function maxYReduce(e,t){return Math.max(e,t.y)}function leafLeft(e){for(var t;t=e.children;)e=t[0];return e}function leafRight(e){for(var t;t=e.children;)e=t[t.length-1];return e}__name(cluster_default,`default`);function cluster_default(){var e=defaultSeparation$1,t=1,n=1,r=!1;function cluster(i){var a,o=0;i.eachAfter(function(t){var n=t.children;n?(t.x=meanX(n),t.y=maxY(n)):(t.x=a?o+=e(t,a):0,t.y=0,a=t)});var s=leafLeft(i),c=leafRight(i),l=s.x-e(s,c)/2,u=c.x+e(c,s)/2;return i.eachAfter(r?function(e){e.x=(e.x-i.x)*t,e.y=(i.y-e.y)*n}:function(e){e.x=(e.x-l)/(u-l)*t,e.y=(1-(i.y?e.y/i.y:1))*n})}return cluster.separation=function(t){return arguments.length?(e=t,cluster):e},cluster.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],cluster):r?null:[t,n]},cluster.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],cluster):r?[t,n]:null},cluster}function count(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function count_default(){return this.eachAfter(count)}__name(count_default,`default`);function each_default(e){var t=this,n,r=[t],i,a,o;do for(n=r.reverse(),r=[];t=n.pop();)if(e(t),i=t.children,i)for(a=0,o=i.length;a<o;++a)r.push(i[a]);while(r.length);return this}__name(each_default,`default`);function eachBefore_default(e){for(var t=this,n=[t],r,i;t=n.pop();)if(e(t),r=t.children,r)for(i=r.length-1;i>=0;--i)n.push(r[i]);return this}__name(eachBefore_default,`default`);function eachAfter_default(e){for(var t=this,n=[t],r=[],i,a,o;t=n.pop();)if(r.push(t),i=t.children,i)for(a=0,o=i.length;a<o;++a)n.push(i[a]);for(;t=r.pop();)e(t);return this}__name(eachAfter_default,`default`);function sum_default(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}__name(sum_default,`default`);function sort_default(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}__name(sort_default,`default`);function path_default(e){for(var t=this,n=leastCommonAncestor(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}__name(path_default,`default`);function leastCommonAncestor(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}function ancestors_default(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}__name(ancestors_default,`default`);function descendants_default(){var e=[];return this.each(function(t){e.push(t)}),e}__name(descendants_default,`default`);function leaves_default(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}__name(leaves_default,`default`);function links_default(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}__name(links_default,`default`);function hierarchy(e,t){var n=new Node$1(e),r=+e.value&&(n.value=e.value),i,a=[n],o,s,c,l;for(t??=defaultChildren;i=a.pop();)if(r&&(i.value=+i.data.value),(s=t(i.data))&&(l=s.length))for(i.children=Array(l),c=l-1;c>=0;--c)a.push(o=i.children[c]=new Node$1(s[c])),o.parent=i,o.depth=i.depth+1;return n.eachBefore(computeHeight)}function node_copy(){return hierarchy(this).eachBefore(copyData)}function defaultChildren(e){return e.children}function copyData(e){e.data=e.data.data}function computeHeight(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function Node$1(e){this.data=e,this.depth=this.height=0,this.parent=null}__name(Node$1,`Node`),Node$1.prototype=hierarchy.prototype={constructor:Node$1,count:count_default,each:each_default,eachAfter:eachAfter_default,eachBefore:eachBefore_default,sum:sum_default,sort:sort_default,path:path_default,ancestors:ancestors_default,descendants:descendants_default,leaves:leaves_default,links:links_default,copy:node_copy};var s=Array.prototype.slice;function shuffle(e){for(var t=e.length,n,r;t;)r=Math.random()*t--|0,n=e[t],e[t]=e[r],e[r]=n;return e}function enclose_default(e){for(var t=0,n=(e=shuffle(s.call(e))).length,r=[],i,a;t<n;)i=e[t],a&&enclosesWeak(a,i)?++t:(a=encloseBasis(r=extendBasis(r,i)),t=0);return a}__name(enclose_default,`default`);function extendBasis(e,t){var n,r;if(enclosesWeakAll(t,e))return[t];for(n=0;n<e.length;++n)if(enclosesNot(t,e[n])&&enclosesWeakAll(encloseBasis2(e[n],t),e))return[e[n],t];for(n=0;n<e.length-1;++n)for(r=n+1;r<e.length;++r)if(enclosesNot(encloseBasis2(e[n],e[r]),t)&&enclosesNot(encloseBasis2(e[n],t),e[r])&&enclosesNot(encloseBasis2(e[r],t),e[n])&&enclosesWeakAll(encloseBasis3(e[n],e[r],t),e))return[e[n],e[r],t];throw Error()}function enclosesNot(e,t){var n=e.r-t.r,r=t.x-e.x,i=t.y-e.y;return n<0||n*n<r*r+i*i}function enclosesWeak(e,t){var n=e.r-t.r+1e-6,r=t.x-e.x,i=t.y-e.y;return n>0&&n*n>r*r+i*i}function enclosesWeakAll(e,t){for(var n=0;n<t.length;++n)if(!enclosesWeak(e,t[n]))return!1;return!0}function encloseBasis(e){switch(e.length){case 1:return encloseBasis1(e[0]);case 2:return encloseBasis2(e[0],e[1]);case 3:return encloseBasis3(e[0],e[1],e[2])}}function encloseBasis1(e){return{x:e.x,y:e.y,r:e.r}}function encloseBasis2(e,t){var n=e.x,r=e.y,i=e.r,a=t.x,o=t.y,s=t.r,c=a-n,l=o-r,u=s-i,d=Math.sqrt(c*c+l*l);return{x:(n+a+c/d*u)/2,y:(r+o+l/d*u)/2,r:(d+i+s)/2}}function encloseBasis3(e,t,n){var r=e.x,i=e.y,a=e.r,o=t.x,s=t.y,c=t.r,l=n.x,u=n.y,d=n.r,f=r-o,p=r-l,m=i-s,h=i-u,g=c-a,_=d-a,v=r*r+i*i-a*a,y=v-o*o-s*s+c*c,b=v-l*l-u*u+d*d,x=p*m-f*h,S=(m*b-h*y)/(x*2)-r,C=(h*g-m*_)/x,w=(p*y-f*b)/(x*2)-i,T=(f*_-p*g)/x,E=C*C+T*T-1,D=2*(a+S*C+w*T),O=S*S+w*w-a*a,k=-(E?(D+Math.sqrt(D*D-4*E*O))/(2*E):O/D);return{x:r+S+C*k,y:i+w+T*k,r:k}}function place(e,t,n){var r=e.x-t.x,i,a,o=e.y-t.y,s,c,l=r*r+o*o;l?(a=t.r+n.r,a*=a,c=e.r+n.r,c*=c,a>c?(i=(l+c-a)/(2*l),s=Math.sqrt(Math.max(0,c/l-i*i)),n.x=e.x-i*r-s*o,n.y=e.y-i*o+s*r):(i=(l+a-c)/(2*l),s=Math.sqrt(Math.max(0,a/l-i*i)),n.x=t.x+i*r-s*o,n.y=t.y+i*o+s*r)):(n.x=t.x+n.r,n.y=t.y)}function intersects(e,t){var n=e.r+t.r-1e-6,r=t.x-e.x,i=t.y-e.y;return n>0&&n*n>r*r+i*i}function score(e){var t=e._,n=e.next._,r=t.r+n.r,i=(t.x*n.r+n.x*t.r)/r,a=(t.y*n.r+n.y*t.r)/r;return i*i+a*a}function Node(e){this._=e,this.next=null,this.previous=null}function packEnclose(e){if(!(i=e.length))return 0;var t=e[0],n,r,i,a,o,s,c,l,u,d;if(t.x=0,t.y=0,!(i>1))return t.r;if(n=e[1],t.x=-n.r,n.x=t.r,n.y=0,!(i>2))return t.r+n.r;place(n,t,r=e[2]),t=new Node(t),n=new Node(n),r=new Node(r),t.next=r.previous=n,n.next=t.previous=r,r.next=n.previous=t;pack:for(s=3;s<i;++s){place(t._,n._,r=e[s]),r=new Node(r),c=n.next,l=t.previous,u=n._.r,d=t._.r;do if(u<=d){if(intersects(c._,r._)){n=c,t.next=n,n.previous=t,--s;continue pack}u+=c._.r,c=c.next}else{if(intersects(l._,r._)){t=l,t.next=n,n.previous=t,--s;continue pack}d+=l._.r,l=l.previous}while(c!==l.next);for(r.previous=t,r.next=n,t.next=n.previous=n=r,a=score(t);(r=r.next)!==n;)(o=score(r))<a&&(t=r,a=o);n=t.next}for(t=[n._],r=n;(r=r.next)!==n;)t.push(r._);for(r=enclose_default(t),s=0;s<i;++s)t=e[s],t.x-=r.x,t.y-=r.y;return r.r}function optional(e){return e==null?null:required(e)}function required(e){if(typeof e!=`function`)throw Error();return e}function constantZero(){return 0}function constant_default$1(e){return function(){return e}}__name(constant_default$1,`default`);function defaultRadius(e){return Math.sqrt(e.value)}function pack_default(){var e=null,t=1,n=1,r=constantZero;function pack(i){return i.x=t/2,i.y=n/2,e?i.eachBefore(radiusLeaf(e)).eachAfter(packChildren(r,.5)).eachBefore(translateChild(1)):i.eachBefore(radiusLeaf(defaultRadius)).eachAfter(packChildren(constantZero,1)).eachAfter(packChildren(r,i.r/Math.min(t,n))).eachBefore(translateChild(Math.min(t,n)/(2*i.r))),i}return pack.radius=function(t){return arguments.length?(e=optional(t),pack):e},pack.size=function(e){return arguments.length?(t=+e[0],n=+e[1],pack):[t,n]},pack.padding=function(e){return arguments.length?(r=typeof e==`function`?e:constant_default$1(+e),pack):r},pack}__name(pack_default,`default`);function radiusLeaf(e){return function(t){t.children||(t.r=Math.max(0,+e(t)||0))}}function packChildren(e,t){return function(n){if(r=n.children){var r,i,a=r.length,o=e(n)*t||0,s;if(o)for(i=0;i<a;++i)r[i].r+=o;if(s=packEnclose(r),o)for(i=0;i<a;++i)r[i].r-=o;n.r=s+o}}}function translateChild(e){return function(t){var n=t.parent;t.r*=e,n&&(t.x=n.x+e*t.x,t.y=n.y+e*t.y)}}function round_default(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}__name(round_default,`default`);function dice_default(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s<c;)o=a[s],o.y0=n,o.y1=i,o.x0=t,o.x1=t+=o.value*l}__name(dice_default,`default`);function partition_default(){var e=1,t=1,n=0,r=!1;function partition(i){var a=i.height+1;return i.x0=i.y0=n,i.x1=e,i.y1=t/a,i.eachBefore(positionNode(t,a)),r&&i.eachBefore(round_default),i}function positionNode(e,t){return function(r){r.children&&dice_default(r,r.x0,e*(r.depth+1)/t,r.x1,e*(r.depth+2)/t);var i=r.x0,a=r.y0,o=r.x1-n,s=r.y1-n;o<i&&(i=o=(i+o)/2),s<a&&(a=s=(a+s)/2),r.x0=i,r.y0=a,r.x1=o,r.y1=s}}return partition.round=function(e){return arguments.length?(r=!!e,partition):r},partition.size=function(n){return arguments.length?(e=+n[0],t=+n[1],partition):[e,t]},partition.padding=function(e){return arguments.length?(n=+e,partition):n},partition}__name(partition_default,`default`);function defaultSeparation(e,t){return e.parent===t.parent?1:2}function nextLeft(e){var t=e.children;return t?t[0]:e.t}function nextRight(e){var t=e.children;return t?t[t.length-1]:e.t}function moveSubtree(e,t,n){var r=n/(t.i-e.i);t.c-=r,t.s+=n,e.c+=r,t.z+=n,t.m+=n}function executeShifts(e){for(var t=0,n=0,r=e.children,i=r.length,a;--i>=0;)a=r[i],a.z+=t,a.m+=t,t+=a.s+(n+=a.c)}function nextAncestor(e,t,n){return e.a.parent===t.parent?e.a:n}function TreeNode(e,t){this._=e,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=t}TreeNode.prototype=Object.create(Node$1.prototype);function treeRoot(e){for(var t=new TreeNode(e,0),n,r=[t],i,a,o,s;n=r.pop();)if(a=n._.children)for(n.children=Array(s=a.length),o=s-1;o>=0;--o)r.push(i=n.children[o]=new TreeNode(a[o],o)),i.parent=n;return(t.parent=new TreeNode(null,0)).children=[t],t}function tree_default(){var e=defaultSeparation,t=1,n=1,r=null;function tree(i){var a=treeRoot(i);if(a.eachAfter(firstWalk),a.parent.m=-a.z,a.eachBefore(secondWalk),r)i.eachBefore(sizeNode);else{var o=i,s=i,c=i;i.eachBefore(function(e){e.x<o.x&&(o=e),e.x>s.x&&(s=e),e.depth>c.depth&&(c=e)});var l=o===s?1:e(o,s)/2,u=l-o.x,d=t/(s.x+l+u),f=n/(c.depth||1);i.eachBefore(function(e){e.x=(e.x+u)*d,e.y=e.depth*f})}return i}function firstWalk(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n){executeShifts(t);var a=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+e(t._,i._));t.parent.A=apportion(t,i,t.parent.A||r[0])}function secondWalk(e){e._.x=e.z+e.parent.m,e.m+=e.parent.m}function apportion(t,n,r){if(n){for(var i=t,a=t,o=n,s=i.parent.children[0],c=i.m,l=a.m,u=o.m,d=s.m,f;o=nextRight(o),i=nextLeft(i),o&&i;)s=nextLeft(s),a=nextRight(a),a.a=t,f=o.z+u-i.z-c+e(o._,i._),f>0&&(moveSubtree(nextAncestor(o,t,r),t,f),c+=f,l+=f),u+=o.m,c+=i.m,d+=s.m,l+=a.m;o&&!nextRight(a)&&(a.t=o,a.m+=u-l),i&&!nextLeft(s)&&(s.t=i,s.m+=c-d,r=t)}return r}function sizeNode(e){e.x*=t,e.y=e.depth*n}return tree.separation=function(t){return arguments.length?(e=t,tree):e},tree.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],tree):r?null:[t,n]},tree.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],tree):r?[t,n]:null},tree}__name(tree_default,`default`);function slice_default(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(i-n)/e.value;++s<c;)o=a[s],o.x0=t,o.x1=r,o.y0=n,o.y1=n+=o.value*l}__name(slice_default,`default`);var c=(1+Math.sqrt(5))/2;function squarifyRatio(e,t,n,r,i,a){for(var o=[],s=t.children,c,l,u=0,d=0,f=s.length,p,m,h=t.value,g,_,v,y,b,x,S;u<f;){p=i-n,m=a-r;do g=s[d++].value;while(!g&&d<f);for(_=v=g,x=Math.max(m/p,p/m)/(h*e),S=g*g*x,b=Math.max(v/S,S/_);d<f;++d){if(g+=l=s[d].value,l<_&&(_=l),l>v&&(v=l),S=g*g*x,y=Math.max(v/S,S/_),y>b){g-=l;break}b=y}o.push(c={value:g,dice:p<m,children:s.slice(u,d)}),c.dice?dice_default(c,n,r,i,h?r+=m*g/h:a):slice_default(c,n,r,h?n+=p*g/h:i,a),h-=g,u=d}return o}var l=(function custom(e){function squarify(t,n,r,i,a){squarifyRatio(e,t,n,r,i,a)}return squarify.ratio=function(e){return custom((e=+e)>1?e:1)},squarify})(c);function treemap_default(){var e=l,t=!1,n=1,r=1,i=[0],a=constantZero,o=constantZero,s=constantZero,c=constantZero,u=constantZero;function treemap(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(positionNode),i=[0],t&&e.eachBefore(round_default),e}function positionNode(t){var n=i[t.depth],r=t.x0+n,l=t.y0+n,d=t.x1-n,f=t.y1-n;d<r&&(r=d=(r+d)/2),f<l&&(l=f=(l+f)/2),t.x0=r,t.y0=l,t.x1=d,t.y1=f,t.children&&(n=i[t.depth+1]=a(t)/2,r+=u(t)-n,l+=o(t)-n,d-=s(t)-n,f-=c(t)-n,d<r&&(r=d=(r+d)/2),f<l&&(l=f=(l+f)/2),e(t,r,l,d,f))}return treemap.round=function(e){return arguments.length?(t=!!e,treemap):t},treemap.size=function(e){return arguments.length?(n=+e[0],r=+e[1],treemap):[n,r]},treemap.tile=function(t){return arguments.length?(e=required(t),treemap):e},treemap.padding=function(e){return arguments.length?treemap.paddingInner(e).paddingOuter(e):treemap.paddingInner()},treemap.paddingInner=function(e){return arguments.length?(a=typeof e==`function`?e:constant_default$1(+e),treemap):a},treemap.paddingOuter=function(e){return arguments.length?treemap.paddingTop(e).paddingRight(e).paddingBottom(e).paddingLeft(e):treemap.paddingTop()},treemap.paddingTop=function(e){return arguments.length?(o=typeof e==`function`?e:constant_default$1(+e),treemap):o},treemap.paddingRight=function(e){return arguments.length?(s=typeof e==`function`?e:constant_default$1(+e),treemap):s},treemap.paddingBottom=function(e){return arguments.length?(c=typeof e==`function`?e:constant_default$1(+e),treemap):c},treemap.paddingLeft=function(e){return arguments.length?(u=typeof e==`function`?e:constant_default$1(+e),treemap):u},treemap}__name(treemap_default,`default`);function binary_default(e,t,n,r,i){var a=e.children,o,s=a.length,c,l=Array(s+1);for(l[0]=c=o=0;o<s;++o)l[o+1]=c+=a[o].value;partition(0,s,e.value,t,n,r,i);function partition(e,t,n,r,i,o,s){if(e>=t-1){var c=a[e];c.x0=r,c.y0=i,c.x1=o,c.y1=s;return}for(var u=l[e],d=n/2+u,f=e+1,p=t-1;f<p;){var m=f+p>>>1;l[m]<d?f=m+1:p=m}d-l[f-1]<l[f]-d&&e+1<f&&--f;var h=l[f]-u,g=n-h;if(o-r>s-i){var _=(r*g+o*h)/n;partition(e,f,h,r,i,_,s),partition(f,t,g,_,i,o,s)}else{var v=(i*g+s*h)/n;partition(e,f,h,r,i,o,v),partition(f,t,g,r,v,o,s)}}}__name(binary_default,`default`);function sliceDice_default(e,t,n,r,i){(e.depth&1?slice_default:dice_default)(e,t,n,r,i)}__name(sliceDice_default,`default`);var u=(function custom(e){function resquarify(t,n,r,i,a){if((o=t._squarify)&&o.ratio===e)for(var o,s,c,l,u=-1,d,f=o.length,p=t.value;++u<f;){for(s=o[u],c=s.children,l=s.value=0,d=c.length;l<d;++l)s.value+=c[l].value;s.dice?dice_default(s,n,r,i,r+=(a-r)*s.value/p):slice_default(s,n,r,n+=(i-n)*s.value/p,a),p-=s.value}else t._squarify=o=squarifyRatio(e,t,n,r,i,a),o.ratio=e}return resquarify.ratio=function(e){return custom((e=+e)>1?e:1)},resquarify})(c),CirclePacking=class extends n.SVGWidget{diameter;pack;svg;_focus;circle;view;_node;constructor(){super(),t.ITree.call(this)}enter(e,t){this.diameter=Math.min(this.width(),this.height()),this.pack=pack_default().size([this.diameter-4,this.diameter-4]).padding(1.5),this.svg=t.append(`g`)}update(e,t){let 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();let i=hierarchy(this.data()).sum(function(e){return e&&e.size?e.size:1}).sort(function(e,t){return e.value<t.value?-1:+(e.value>t.value)});this._focus=i,this.pack(i),this.circle=this.svg.selectAll(`circle`).data(i.descendants()).enter().append(`circle`).attr(`class`,function(e){return e.parent?e.children?`node`:`node leaf`:`node root`}).style(`fill`,function(e){return e.color=r.paletteDepthLevel_exists()&&e.depth>r.paletteDepthLevel()?(0,n.rgb)(e.parent.color)[r.paletteDepthVariant()](1):r._palette(e.data.label),e.color}).on(`click`,function(e){r.click(e.data,null,null)}).on(`dblclick`,function(e){this._focus!==e&&r.zoom(e),(0,n.d3Event)().stopPropagation()}),this.circle.append(`title`).text(function(e){return e.data.label}),this.svg.selectAll(`text`).data(i.descendants()).enter().append(`text`).attr(`class`,`label`).style(`fill-opacity`,function(e){return+(e.parent===i)}).style(`display`,function(e){return e.parent===i?null:`none`}).text(function(e){return e.data.label+(r.showSize()&&e.data.size!==void 0?` `+e.data.size:``)}),this._node=this.svg.selectAll(`circle,text`),this.zoomTo([i.x,i.y,i.r*2])}zoom(e){this._focus=e;let t=this,r=this.svg.transition().duration((0,n.d3Event)().altKey?7500:750).tween(`zoom`,function(){let e=(0,n.interpolateZoom)(t.view,[t._focus.x,t._focus.y,t._focus.r*2]);return function(n){t.zoomTo(e(n))}});function showText(e){return e===t._focus&&!e.children||e.parent===t._focus}r.selectAll(`text`).filter(function(e){return showText(e)||this.style.display===`inline`}).style(`fill-opacity`,function(e){return+!!showText(e)}).on(`start`,function(e){showText(e)&&(this.style.display=`inline`)}).on(`end`,function(e){showText(e)||(this.style.display=`none`)})}zoomTo(e){let t=this.diameter/e[2];this.view=e,this._node.attr(`transform`,function(n){return`translate(`+(n.x-e[0])*t+`,`+(n.y-e[1])*t+`)`}),this.circle.attr(`r`,function(e){return e.r*t})}};CirclePacking.prototype._class+=` tree_CirclePacking`,CirclePacking.prototype.implements(t.ITree.prototype),CirclePacking.prototype.publish(`showSize`,!0,`boolean`,`Show size along with label`),CirclePacking.prototype.publish(`paletteDepthLevel`,null,`number`,`If not null then beyond this depth number the child node colors are based on parent`,null,{optional:!0}),CirclePacking.prototype.publish(`paletteDepthVariant`,`brighter`,`set`,`Determines paletteDepthLevel decendant color shade variant`,[`brighter`,`darker`],{disable:e=>e.paletteDepthLevel_exists()}),CirclePacking.prototype.publish(`paletteID`,`default`,`set`,`Color palette for this widget`,CirclePacking.prototype._palette.switch(),{tags:[`Basic`,`Shared`]}),CirclePacking.prototype.publish(`useClonedPalette`,!1,`boolean`,`Enable or disable using a cloned palette`,null,{tags:[`Intermediate`,`Shared`]});var DendrogramColumn=class extends n.PropertyExt{_owner;constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.column()}column};DendrogramColumn.prototype._class+=` tree_Dendrogram.DendrogramColumn`,DendrogramColumn.prototype.publish(`column`,null,`set`,`Field`,function(){return this._owner?this._owner.columns():[]},{optional:!0});var Dendrogram=class extends n.SVGZoomWidget{Column;_d3LayoutCluster;_d3LayoutTree;_d3Layout;constructor(){super(),t.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this),this._drawStartPos=`origin`,this._d3LayoutCluster=cluster_default(),this._d3LayoutTree=tree_default()}dendrogramData(){if(this.data().length===0)return[];if(!this.mappings().filter(e=>e.valid()).length)return this.data();return formatData({key:`root`,values:this._db.rollupView(this.mappings().map(function(e){return e.column()})).entries()});function formatData(e){return{label:e.key,children:e.values.filter(function(e){return!(e instanceof Array)}).map(function(e){return formatData(e)}),origRows:e.values}}}enter(e,t){super.enter(e,t),this._renderElement.attr(`opacity`,0).transition().duration(500).attr(`opacity`,1),this._selection.widgetElement(this._renderElement)}update(e,t){super.update(e,t);let r=this,i=this.orientation()===`vertical`;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,this.separation()*2]),this._d3Layout.separation(function separation(e,t){return(e.parent===t.parent?1:2)/e.depth})):(this._d3Layout.nodeSize([14,this.separation()]),this._d3Layout.separation(function separation(e,t){return e.parent===t.parent?1:2}));let a=hierarchy(this.dendrogramData());this._d3Layout(a);let o=a.descendants(),s=a.descendants().slice(1);function linkVertical(e){return`M`+e.parent.x+`,`+e.parent.y+`C`+e.parent.x+`,`+(e.parent.y+e.y)/2+` `+e.x+`,`+(e.parent.y+e.y)/2+` `+e.x+`,`+e.y}function linkHorizontal(e){return`M`+e.y+`,`+e.x+`C`+(e.y+e.parent.y)/2+`,`+e.x+` `+(e.y+e.parent.y)/2+`,`+e.parent.x+` `+e.parent.y+`,`+e.parent.x}function diagonal(e){return i?linkVertical(e):linkHorizontal(e)}function project(e,t){let n=(e-90)/180*Math.PI,r=t;return[r*Math.cos(n),r*Math.sin(n)]}function radialDiagonal(e){return`M`+project(e.x,e.y)+`C`+project(e.x,(e.y+e.parent.y)/2)+` `+project(e.parent.x,(e.y+e.parent.y)/2)+` `+project(e.parent.x,e.parent.y)}let c=this._renderCount?500:0,l=this._renderElement.selectAll(`.link`).data(s);l.enter().append(`path`).attr(`class`,`link`).attr(`d`,this.radial()?radialDiagonal:diagonal),l.transition().duration(c).attr(`d`,this.radial()?radialDiagonal:diagonal),l.exit().remove();let u=this.circleRadius()+2;function nodeTransform(e){return r.radial()?`rotate(`+(e.x-90)+`)translate(`+e.y+`)`:r.orientation()===`horizontal`?`translate(`+e.y+`,`+e.x+`)`:`translate(`+e.x+`,`+e.y+`)`}let d=this._renderElement.selectAll(`.node`).data(o);d.transition().duration(c).attr(`transform`,nodeTransform);let f=d.enter().append(`g`).attr(`class`,`node`).attr(`transform`,nodeTransform).call(this._selection.enter.bind(this._selection)).on(`click`,function(e){let t=e;for(;t.children;)t=t.children[0];e.depth>0&&(t.origRows?r.click(r.rowToObj(t.origRows[0]),r.mappings()[e.depth-1].column(),!0):r.click(t.data,r.mappings()[e.depth-1].column(),!0))}).on(`dblclick`,function(e){let t=e;for(;t.children;)t=t.children[0];e.depth>0&&(t.origRows?r.dblclick(r.rowToObj(t.origRows[0]),r.mappings()[e.depth-1].column(),!0):r.dblclick(t.data,r.mappings()[e.depth-1].column(),!0))}).each(function(){let e=(0,n.select)(this);e.append(`circle`),e.append(`text`)});f.merge(d).select(`circle`).attr(`r`,this.circleRadius()).style(`fill`,function(e){return r._palette(e.data.label)}).append(`title`).text(function(e){return e.data.label}),f.merge(d).select(`text`).attr(`dx`,function(e){return r.radial()?e.children?e.x<180?-u:u:e.x<180?u:-u:i?e.children?u:-u:e.children?-u:u}).attr(`dy`,`0.25em`).style(`text-anchor`,function(e){return r.radial()?e.children?e.x<180?`end`:`start`:e.x<180?`start`:`end`:i?e.children?`start`:`end`:e.children?`end`:`start`}).attr(`transform`,function(e){return r.radial()?e.x<180?null:`rotate(180)`:i?`rotate(-66)`:null}).text(function(e){return e.data.label}),d.exit().remove(),this._renderCount||r.zoomToFit()}};Dendrogram.prototype._class+=` tree_Dendrogram`,Dendrogram.prototype.implements(t.ITree.prototype),Dendrogram.prototype.mixin(n.Utility.SimpleSelectionMixin),Dendrogram.prototype.Column=DendrogramColumn,Dendrogram.prototype.publish(`paletteID`,`default`,`set`,`Color palette for this widget`,Dendrogram.prototype._palette.switch(),{tags:[`Basic`,`Shared`]}),Dendrogram.prototype.publish(`useClonedPalette`,!1,`boolean`,`Enable or disable using a cloned palette`,null,{tags:[`Intermediate`,`Shared`]}),Dendrogram.prototype.publish(`mappings`,[],`propertyArray`,`Source Columns`,null,{autoExpand:DendrogramColumn}),Dendrogram.prototype.publish(`circleRadius`,4.5,`number`,`Text offset from circle`),Dendrogram.prototype.publish(`separation`,240,`number`,`Leaf Separation`),Dendrogram.prototype.publish(`dendrogram`,!0,`boolean`,`Dendrogram`),Dendrogram.prototype.publish(`radial`,!1,`boolean`,`Radial`),Dendrogram.prototype.publish(`orientation`,`horizontal`,`set`,`Orientation`,[`horizontal`,`vertical`],{tags:[`Private`],disable:e=>e.radial()});var DirectoryTree=class extends n.HTMLWidget{constructor(){super()}flattenData(e){let t=this,n=hierarchy(e),r=[];return this.omitRoot()?n.children&&n.children.forEach(visitNode):visitNode(n),r;function visitNode(e){let n=e.data.markers&&e.data.markers.length?e.data.markers.length:``;r.push({label:e.data.label,depth:e.depth-+!!t.omitRoot(),content:e.data.content,isFolder:!!e.data.children,iconClass:e.data.iconClass,color:e.data.color,bold:e.data.bold,weightValue:n,markers:e.data.markers,selected:e.data.selected}),e.children&&e.children.forEach(visitNode)}}iconClass(e){return e.label===`error`?`fa fa-exclamation`:e.isFolder?this.folderIconOpen():this.textFileIcon()}calcRequiredWidth(){let e=this.flattenData(this.data()),t=0,r=this.rowItemPadding(),i=this.iconSize()+r*2,a=n.Platform.getScrollbarWidth();return e.forEach(e=>{let o=e.depth*i+r*2,s=n.Utility.textSize(e.label,this.fontFamily(),this.fontSize(),!!e.bold).width+r*2+i+o+a;t<s&&(t=s)}),t}rowClick(e,t){}enter(e,t){super.enter(e,t),t.style(`width`,`100%`).style(`height`,`100%`)}update(e,t){super.update(e,t),this._palette=this._palette.switch(this.paletteID()),t.style(`overflow-y`,this.verticalScroll()?`scroll`:null);let r=this.flattenData(this.data()),i=(0,n.max)(r,e=>Number(e.weightValue));r.forEach(e=>{e.weightValue?e.weightColor=this._palette(e.weightValue,1,i):e.weightColor=`transparent`});let a=this,o=this.rowItemPadding(),s=this.iconSize()+o,c=Math.max(a.iconSize(),a.fontSize()),l=t.selectAll(`.directory-row`).data(r),u=this.fontFamily(),d=this.fontSize(),f=(0,n.max)(r,e=>this.textSize(e.weightValue,u,d).width),p=`${o}px ${o}px ${o/2}px ${o}px`;l.enter().append(`div`).attr(`class`,e=>`directory-row directory-row-depth-${e.depth}`).style(`display`,`flex`).style(`cursor`,`pointer`).each(function(e){let r=(0,n.select)(this),i=e.color?e.color:a.fontColor(),l=e.weightColor?e.weightColor:`transparent`,m=n.Palette.textColor(l),h=r.append(`div`).attr(`class`,`row-weight`).style(`padding`,p).style(`color`,m).style(`box-shadow`,`inset 0 0 100px ${l}`).style(`font-weight`,e.bold?`bold`:`normal`).style(`font-family`,u).style(`font-size`,d+`px`).text(e.weightValue).attr(`title`,e.weightValue).style(`overflow`,`hidden`).style(`width`,f+o*2+`px`).style(`text-overflow`,`ellipsis`).style(`text-align`,`right`).style(`line-height`,c+`px`);r.append(`div`).attr(`class`,`row-depth`).style(`width`,a.depthSize()*e.depth+`px`).style(`opacity`,1).style(`line-height`,c+`px`);let g=r.append(`div`).attr(`class`,`row-icon `+(e.iconClass?e.iconClass:a.iconClass(e))).style(`width`,s+`px`).style(`height`,c+`px`).style(`color`,i).style(`background-color`,e.selected?a.selectionBackgroundColor():`transparent`).style(`font-size`,a.iconSize()+`px`).style(`padding`,p).style(`line-height`,c+`px`),_=r.append(`div`).attr(`class`,`row-label`).style(`padding`,p).style(`color`,i).style(`background-color`,e.selected?a.selectionBackgroundColor():`transparent`).style(`font-weight`,e.bold?`bold`:`normal`).style(`font-family`,a.fontFamily()).style(`font-size`,a.fontSize()+`px`).text(e.label).attr(`title`,e.label).style(`flex`,1).style(`overflow`,`hidden`).style(`text-overflow`,`ellipsis`).style(`line-height`,c+`px`);r.on(`mouseenter`,()=>{_.style(`font-weight`,`bold`)}).on(`mouseleave`,()=>{_.style(`font-weight`,e.bold?`bold`:`normal`)}),h.on(`mouseenter`,()=>{a.weight_mouseenter(e)}).on(`mouseleave`,()=>{a.weight_mouseleave(e)}),e.isFolder?r.on(`click`,function(e){let t=this.nextSibling,i=r.classed(`folder-closed`);for(i?(r.classed(`folder-closed`,!1),r.classed(`folder-open`,!0),g.attr(`class`,`row-icon `+a.folderIconOpen())):(r.classed(`folder-closed`,!0),r.classed(`folder-open`,!1),g.attr(`class`,`row-icon `+a.folderIconClosed()));t!==null;)(0,n.select)(t).datum().depth>e.depth?(t.style.display=i?`flex`:`none`,t=t.nextSibling):t=null}):r.on(`click`,()=>{t.selectAll(`.row-label`).style(`background-color`,`transparent`),t.selectAll(`.row-icon`).style(`background-color`,`transparent`),g.style(`background-color`,a.selectionBackgroundColor()),_.style(`background-color`,a.selectionBackgroundColor());let n=e.label.split(`.`).pop().toLowerCase();a.rowClick(n===`json`?JSON.stringify(JSON.parse(e.content),null,4):e.content,e.markers)})}).merge(l).style(`background-color`,a.backgroundColor()),l.exit().remove()}weight_mouseenter(e){}weight_mouseleave(e){}};DirectoryTree.prototype._class+=` tree_DirectoryTree`,DirectoryTree.prototype._palette=n.Palette.rainbow(`Blues`),DirectoryTree.prototype.publish(`depthSize`,14,`number`,`Width of indentation per file or folder depth (pixels)`),DirectoryTree.prototype.publish(`paletteID`,`Blues`,`set`,`Color palette for the weight backgrounds`,DirectoryTree.prototype._palette.switch(),{tags:[`Basic`]}),DirectoryTree.prototype.publish(`omitRoot`,!1,`boolean`,`If true, root node will not display`),DirectoryTree.prototype.publish(`rowItemPadding`,2,`number`,`Top, bottom, left and right row item padding`),DirectoryTree.prototype.publish(`selectionBackgroundColor`,`#CCC`,`html-color`,`Background color of selected directory rows`),DirectoryTree.prototype.publish(`backgroundColor`,`#FFF`,`html-color`,`Directory item background color`),DirectoryTree.prototype.publish(`fontColor`,`#000`,`html-color`,`Directory item font color`),DirectoryTree.prototype.publish(`fontFamily`,`Arial`,`string`,`Directory item font family`),DirectoryTree.prototype.publish(`fontSize`,12,`number`,`Directory item font size (pixels)`),DirectoryTree.prototype.publish(`iconSize`,12,`number`,`Directory folder and file icon size (pixels)`),DirectoryTree.prototype.publish(`folderIconOpen`,`fa fa-folder-open`,`string`,`Open folder icon class`),DirectoryTree.prototype.publish(`folderIconClosed`,`fa fa-folder`,`string`,`Closed folder icon class`),DirectoryTree.prototype.publish(`textFileIcon`,`fa fa-file-text-o`,`string`,`Text file icon class`),DirectoryTree.prototype.publish(`verticalScroll`,!0,`boolean`,`If true, vertical scroll bar will be shown`);var IndentedColumn=class extends n.PropertyExt{_owner;constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.column()}column};IndentedColumn.prototype._class+=` tree_Dendrogram.IndentedColumn`,IndentedColumn.prototype.publish(`column`,null,`set`,`Field`,function(){return this._owner?this._owner.columns():[]},{optional:!0});var Indented=class extends n.SVGZoomWidget{Column;_d3Tree;_xml;_svgLinks;_svgNodes;_treeData;_collapsed={};constructor(){super(),t.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this),this._drawStartPos=`origin`,this._d3Tree=tree_default()}xmlToData(e,t=``){return DOMParser?xmlToJson(new DOMParser().parseFromString(e,`text/xml`),t).children[0]:[]}xml(e){return arguments.length?(this._xml=e,this.data(this.xmlToData(this._xml)),this):this._xml}IndentedData(){if(this.data().length===0)return[];if(this.xmlColumn_exists()){let e=this.columns().indexOf(this.xmlColumn()),t={label:this.xmlColumn(),children:this.data().map(function(t,n){return this.xmlToData(t[e],`[`+n+`]`)},this)};return t.children.length===1?t.children[0]:t}else return this.mappings().filter(e=>e.valid()).length?formatData({key:`root`,values:this._db.rollupView(this.mappings().map(function(e){return e.column()})).entries()}):this.data();function formatData(e){if(e.values instanceof Array){let t=e.values.filter(function(e){return!(e instanceof Array)}).map(function(e){return formatData(e)}),n={label:e.key};return t.length?n.children=t:n.size=22,n}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(e,t){super.enter(e,t),this._svgLinks=this._renderElement.append(`g`),this._svgNodes=this._renderElement.append(`g`),this._selection.widgetElement(this._svgNodes)}_prevDataChecksum;update(e,t){super.update(e,t);let r=this;this._d3Tree.nodeSize([0,this.barHeight()]);let i=this._db.dataChecksum();this._prevDataChecksum!==i&&(this._treeData=this.IndentedData(),this._prevDataChecksum=i);function getID(e){return(e.parent?getID(e.parent)+`.`:``)+e.data.label}let a=hierarchy(this.data()).sum(function(e){return e.size||50}).each(e=>{this._collapsed[getID(e)]&&delete e.children}),o=this._d3Tree(a).descendants(),s=this._d3Tree(a).descendants().slice(1),c=0;a.eachBefore(e=>{e.x=c*r.barHeight(),++c});let l=this.barHeight()-4,u=this._renderCount?500:0,d=this._svgLinks.selectAll(`.link`).data(s,function(e){return getID(e)});d.enter().append(`path`).attr(`class`,`link`).attr(`d`,elbow),d.transition().duration(u).attr(`d`,elbow),d.exit().remove();function elbow(e){return`M`+e.parent.y+`,`+e.parent.x+`V`+e.x+`, H`+e.y}let f=this._svgNodes.selectAll(`.node`).data(o,function(e){return getID(e)});f.transition().duration(u).attr(`transform`,function(e){return`translate(`+e.y+`,`+e.x+`)`});let p=f.enter().append(`g`).attr(`class`,`node`).attr(`transform`,function(e){return`translate(`+e.y+`,`+e.x+`)`}).call(this._selection.enter.bind(this._selection)).each(function(){let e=(0,n.select)(this);e.append(`rect`).attr(`height`,l).attr(`width`,l).on(`click`,function(e){r._collapsed[getID(e)]?delete r._collapsed[getID(e)]:e.children&&(r._collapsed[getID(e)]=!0),r.lazyRender()}),e.append(`text`)}).style(`opacity`,0);p.transition().style(`opacity`,1),p.merge(f).select(`rect`).attr(`x`,-l/2).attr(`y`,-l/2).style(`fill`,color),p.merge(f).select(`text`).attr(`dx`,l/2+4+`px`).attr(`dy`,`0.33em`).text(function(e){return e.data.label}),f.exit().transition().style(`opacity`,0).remove(),this._renderCount||r.zoomToFit();function color(e){return r._collapsed[getID(e)]?`#3182bd`:e.children?`#c6dbef`:`#fd8d3c`}}};Indented.prototype._class+=` tree_Indented`,Indented.prototype.implements(t.ITree.prototype),Indented.prototype.mixin(n.Utility.SimpleSelectionMixin),Indented.prototype.Column=IndentedColumn,Indented.prototype.publish(`xmlColumn`,null,`set`,`Field`,function(){return this.columns()},{optional:!0}),Indented.prototype.publish(`mappings`,[],`propertyArray`,`Source Columns`,null,{autoExpand:IndentedColumn,disable:e=>e.xmlColumn_exists()}),Indented.prototype.publish(`barHeight`,16,`number`,`Bar height`);function xmlToJson(e,t=``){let n={id:t,label:``,attributes:{},children:[]};if(n.label=e.nodeName,e.nodeType===1){if(e.attributes.length>0)for(let t=0;t<e.attributes.length;t++){let r=e.attributes.item(t);n.attributes[r.nodeName]=r.nodeValue}}else e.nodeType===3&&(n.label=e.nodeValue);if(e.hasChildNodes())for(let r=0;r<e.childNodes.length;r++){let i=xmlToJson(e.childNodes.item(r),t+`[`+n.children.length+`]`);n.children.push(i)}return n}var d=Math.PI,f=2*d,p=1e-6,m=f-p;function Path(){this._x0=this._y0=this._x1=this._y1=null,this._=``}function path(){return new Path}Path.prototype=path.prototype={constructor:Path,moveTo:function(e,t){this._+=`M`+(this._x0=this._x1=+e)+`,`+(this._y0=this._y1=+t)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)},lineTo:function(e,t){this._+=`L`+(this._x1=+e)+`,`+(this._y1=+t)},quadraticCurveTo:function(e,t,n,r){this._+=`Q`+ +e+`,`+ +t+`,`+(this._x1=+n)+`,`+(this._y1=+r)},bezierCurveTo:function(e,t,n,r,i,a){this._+=`C`+ +e+`,`+ +t+`,`+ +n+`,`+ +r+`,`+(this._x1=+i)+`,`+(this._y1=+a)},arcTo:function(e,t,n,r,i){e=+e,t=+t,n=+n,r=+r,i=+i;var a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,f=l*l+u*u;if(i<0)throw Error(`negative radius: `+i);if(this._x1===null)this._+=`M`+(this._x1=e)+`,`+(this._y1=t);else if(f>p)if(!(Math.abs(u*s-c*l)>p)||!i)this._+=`L`+(this._x1=e)+`,`+(this._y1=t);else{var m=n-a,h=r-o,g=s*s+c*c,_=m*m+h*h,v=Math.sqrt(g),y=Math.sqrt(f),b=i*Math.tan((d-Math.acos((g+f-_)/(2*v*y)))/2),x=b/y,S=b/v;Math.abs(x-1)>p&&(this._+=`L`+(e+x*l)+`,`+(t+x*u)),this._+=`A`+i+`,`+i+`,0,0,`+ +(u*m>l*h)+`,`+(this._x1=e+S*s)+`,`+(this._y1=t+S*c)}},arc:function(e,t,n,r,i,a){e=+e,t=+t,n=+n,a=!!a;var o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,h=a?r-i:i-r;if(n<0)throw Error(`negative radius: `+n);this._x1===null?this._+=`M`+c+`,`+l:(Math.abs(this._x1-c)>p||Math.abs(this._y1-l)>p)&&(this._+=`L`+c+`,`+l),n&&(h<0&&(h=h%f+f),h>m?this._+=`A`+n+`,`+n+`,0,1,`+u+`,`+(e-o)+`,`+(t-s)+`A`+n+`,`+n+`,0,1,`+u+`,`+(this._x1=c)+`,`+(this._y1=l):h>p&&(this._+=`A`+n+`,`+n+`,0,`+ +(h>=d)+`,`+u+`,`+(this._x1=e+n*Math.cos(i))+`,`+(this._y1=t+n*Math.sin(i))))},rect:function(e,t,n,r){this._+=`M`+(this._x0=this._x1=+e)+`,`+(this._y0=this._y1=+t)+`h`+ +n+`v`+ +r+`h`+-n+`Z`},toString:function(){return this._}};function constant_default(e){return function constant(){return e}}__name(constant_default,`default`);var h=Math.abs,g=Math.atan2,_=Math.cos,v=Math.max,y=Math.min,b=Math.sin,x=Math.sqrt,S=Math.PI,C=S/2,w=2*S;function acos(e){return e>1?0:e<-1?S:Math.acos(e)}function asin(e){return e>=1?C:e<=-1?-C:Math.asin(e)}function arcInnerRadius(e){return e.innerRadius}function arcOuterRadius(e){return e.outerRadius}function arcStartAngle(e){return e.startAngle}function arcEndAngle(e){return e.endAngle}function arcPadAngle(e){return e&&e.padAngle}function intersect(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function cornerTangents(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/x(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,y=m-f,b=h-p,S=y*y+b*b,C=i-a,w=f*h-m*p,T=(b<0?-1:1)*x(v(0,C*C*S-w*w)),E=(w*b-y*T)/S,D=(-w*y-b*T)/S,O=(w*b+y*T)/S,k=(-w*y+b*T)/S,A=E-g,j=D-_,M=O-g,N=k-_;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-u,y01:-d,x11:E*(i/C-1),y11:D*(i/C-1)}}function arc_default(){var e=arcInnerRadius,t=arcOuterRadius,n=constant_default(0),r=null,i=arcStartAngle,a=arcEndAngle,o=arcPadAngle,s=null;function arc(){var c,l,u=+e.apply(this,arguments),d=+t.apply(this,arguments),f=i.apply(this,arguments)-C,p=a.apply(this,arguments)-C,m=h(p-f),v=p>f;if(s||=c=path(),d<u&&(l=d,d=u,u=l),!(d>1e-12))s.moveTo(0,0);else if(m>w-1e-12)s.moveTo(d*_(f),d*b(f)),s.arc(0,0,d,f,p,!v),u>1e-12&&(s.moveTo(u*_(p),u*b(p)),s.arc(0,0,u,p,f,v));else{var T=f,E=p,D=f,O=p,k=m,A=m,j=o.apply(this,arguments)/2,M=j>1e-12&&(r?+r.apply(this,arguments):x(u*u+d*d)),N=y(h(d-u)/2,+n.apply(this,arguments)),P=N,F=N,I,L;if(M>1e-12){var R=asin(M/u*b(j)),z=asin(M/d*b(j));(k-=R*2)>1e-12?(R*=v?1:-1,D+=R,O-=R):(k=0,D=O=(f+p)/2),(A-=z*2)>1e-12?(z*=v?1:-1,T+=z,E-=z):(A=0,T=E=(f+p)/2)}var B=d*_(T),V=d*b(T),H=u*_(O),U=u*b(O);if(N>1e-12){var W=d*_(E),G=d*b(E),K=u*_(D),q=u*b(D),J;if(m<S&&(J=intersect(B,V,K,q,W,G,H,U))){var Y=B-J[0],X=V-J[1],Z=W-J[0],Q=G-J[1],$=1/b(acos((Y*Z+X*Q)/(x(Y*Y+X*X)*x(Z*Z+Q*Q)))/2),ee=x(J[0]*J[0]+J[1]*J[1]);P=y(N,(u-ee)/($-1)),F=y(N,(d-ee)/($+1))}}A>1e-12?F>1e-12?(I=cornerTangents(K,q,B,V,d,F,v),L=cornerTangents(W,G,H,U,d,F,v),s.moveTo(I.cx+I.x01,I.cy+I.y01),F<N?s.arc(I.cx,I.cy,F,g(I.y01,I.x01),g(L.y01,L.x01),!v):(s.arc(I.cx,I.cy,F,g(I.y01,I.x01),g(I.y11,I.x11),!v),s.arc(0,0,d,g(I.cy+I.y11,I.cx+I.x11),g(L.cy+L.y11,L.cx+L.x11),!v),s.arc(L.cx,L.cy,F,g(L.y11,L.x11),g(L.y01,L.x01),!v))):(s.moveTo(B,V),s.arc(0,0,d,T,E,!v)):s.moveTo(B,V),!(u>1e-12)||!(k>1e-12)?s.lineTo(H,U):P>1e-12?(I=cornerTangents(H,U,W,G,u,-P,v),L=cornerTangents(B,V,K,q,u,-P,v),s.lineTo(I.cx+I.x01,I.cy+I.y01),P<N?s.arc(I.cx,I.cy,P,g(I.y01,I.x01),g(L.y01,L.x01),!v):(s.arc(I.cx,I.cy,P,g(I.y01,I.x01),g(I.y11,I.x11),!v),s.arc(0,0,u,g(I.cy+I.y11,I.cx+I.x11),g(L.cy+L.y11,L.cx+L.x11),v),s.arc(L.cx,L.cy,P,g(L.y11,L.x11),g(L.y01,L.x01),!v))):s.arc(0,0,u,O,D,v)}if(s.closePath(),c)return s=null,c+``||null}return arc.centroid=function(){var n=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-S/2;return[_(r)*n,b(r)*n]},arc.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:constant_default(+t),arc):e},arc.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:constant_default(+e),arc):t},arc.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:constant_default(+e),arc):n},arc.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:constant_default(+e),arc):r},arc.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:constant_default(+e),arc):i},arc.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:constant_default(+e),arc):a},arc.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:constant_default(+e),arc):o},arc.context=function(e){return arguments.length?(s=e??null,arc):s},arc}__name(arc_default,`default`);var SunburstPartition=class extends n.SVGWidget{svg;radius;_xScale;_yScale;partition;arc;_resetRoot;constructor(){super(),t.ITree.call(this)}data(e){let t=n.SVGWidget.prototype.data.apply(this,arguments);return arguments.length&&(this._resetRoot=!0),t}enter(e,t){let r=this;this.radius=Math.min(this.width(),this.height())/2,this._xScale=(0,n.scaleLinear)().range([0,2*Math.PI]),this._yScale=(0,n.scaleSqrt)().range([0,this.radius]),this.partition=partition_default(),this.arc=arc_default().startAngle(function(e){return Math.max(0,Math.min(2*Math.PI,r._xScale(e.x0)))}).endAngle(function(e){return Math.max(0,Math.min(2*Math.PI,r._xScale(e.x1)))}).innerRadius(function(e){return Math.max(0,r._yScale(e.y0))}).outerRadius(function(e){return Math.max(0,r._yScale(e.y1))}),this.svg=t.append(`g`)}update(e,t){let 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]);let i=hierarchy(this.data()).sum(function(e){return e.size===void 0?1:e.size}),a=this.svg.selectAll(`path`).data(this.partition(i).descendants(),function(e,t){return e.data.label===void 0?t:e.data.label});a.enter().append(`path`).on(`click`,function(e){r.click(e.data,null,null)}).on(`dblclick`,function(e){let t=(0,n.d3Event)();t&&t.stopPropagation(),r.zoomTo(e)}).each(function(){(0,n.select)(this).append(`title`)}).merge(a).attr(`d`,this.arc).style(`fill`,function(e){return e.data.__viz_fill?e.data.__viz_fill:r._palette(e.data.label)}).style(`stroke`,function(e){return e.value>16?`white`:`none`}).select(`title`).text(function(e){return e.data.label}),a.exit().remove(),this._resetRoot&&(this._resetRoot=!1,this.zoomTo(i))}zoomTo(e){let t=this;this.svg.transition().duration(750).tween(`scale`,function(){let r=(0,n.interpolate)(t._xScale.domain(),[e.x0,e.x1]),i=(0,n.interpolate)(t._yScale.domain(),[e.y0,1]),a=(0,n.interpolate)(t._yScale.range(),[e.y0?20:0,t.radius]);return function(e){t._xScale.domain(r(e)),t._yScale.domain(i(e)).range(a(e))}}).selectAll(`path`).attrTween(`d`,function(e){return function(){return t.arc(e)}})}};SunburstPartition.prototype._class+=` tree_SunburstPartition`,SunburstPartition.prototype.implements(t.ITree.prototype),SunburstPartition.prototype.publish(`paletteID`,`default`,`set`,`Color palette for this widget`,SunburstPartition.prototype._palette.switch(),{tags:[`Basic`,`Shared`]}),SunburstPartition.prototype.publish(`useClonedPalette`,!1,`boolean`,`Enable or disable using a cloned palette`,null,{tags:[`Intermediate`,`Shared`]});var TreemapColumn=class extends n.PropertyExt{_owner;constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.column()}column};TreemapColumn.prototype._class+=` tree_Dendrogram.TreemapColumn`,TreemapColumn.prototype.publish(`column`,null,`set`,`Field`,function(){return this._owner?this._owner.columns():[]},{optional:!0});var Treemap=class extends n.HTMLWidget{Column;_d3Treemap;_elementDIV;_selection;constructor(){super(),t.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this,!0)}getTilingMethod(){switch(this.tilingMethod()){case`treemapBinary`:return binary_default;case`treemapDice`:return dice_default;case`treemapSlice`:return slice_default;case`treemapSliceDice`:return sliceDice_default;case`treemapResquarify`:return u;default:return l}}treemapData(){if(!this.mappings().filter(e=>e.valid()).length)return this.data();return formatData({key:`root`,values:this._db.aggregateView(this.mappings().map(function(e){return e.column()}),this.aggrType(),this.aggrColumn()).entries()});function formatData(e){if(e.values instanceof Array){let t=e.values.filter(function(e){return!(e instanceof Array)}).map(function(e){return formatData(e)}),n={label:e.key};return t.length?n.children=t:n.size=22,n}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(e,t){super.enter(e,t),this._d3Treemap=treemap_default(),this._elementDIV=t.append(`div`),this._selection.widgetElement(this._elementDIV)}update(e,t){super.update(e,t);let r=this;this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+`_`+this.id()));let i=hierarchy(this.treemapData()).sum(this.nodeWeight);this._d3Treemap.size([this.width(),this.height()]).paddingInner(this.paddingInner()).paddingOuter(this.paddingOuter()).paddingTop(this.paddingTop()),[`treemapSquarify`,`treemapResquarify`].indexOf(this.tilingMethod())===-1?this._d3Treemap.tile(this.getTilingMethod()):this._d3Treemap.tile(this.getTilingMethod().ratio(this.squarifyRatio())),this._d3Treemap(i),this._elementDIV.style(`font-size`,this.fontSize_exists()?this.fontSize()+`px`:null).style(`line-height`,this.fontSize_exists()?this.fontSize()+2+`px`:null);let a=this._elementDIV.selectAll(`.node`).data(i.descendants());a.enter().append(`div`).attr(`class`,`node`).call(this._selection.enter.bind(this._selection)).on(`click`,function(e){if(e){let t=``;r.mappings().forEach(function(e){e.column()&&(t=e.column())}),e.origRows?r.click(r.rowToObj(e.origRows[0]),t,r._selection.selected(this)):r.click(e.data,t,r._selection.selected(this))}}).on(`dblclick`,function(e){if(e){let t=``;r.mappings().forEach(function(e){e.column()&&(t=e.column())}),e.origRows?r.dblclick(r.rowToObj(e.origRows[0]),t,r._selection.selected(this)):r.dblclick(e.data,t,r._selection.selected(this))}}).merge(a).style(`left`,function(e){return e.x0+Math.max(0,e.x1-e.x0)/2+`px`}).style(`top`,function(e){return e.y0+Math.max(0,e.y1-e.y0)/2+`px`}).style(`width`,function(){return`0px`}).style(`height`,function(){return`0px`}).style(`font-size`,function(e){return(e.children?r.parentFontSize():r.leafFontSize())+`px`}).style(`line-height`,function(e){return(e.children?r.parentFontSize():r.leafFontSize())+`px`}).attr(`title`,tooltip).html(function(e){return!r.showRoot()&&e.depth===0?null:e.children?r.enableParentLabels()?r.parentWeightHTML(e):null:r.leafWeightHTML(e)}).style(`background`,function(e){if(!r.showRoot()&&e.depth===0)return this.style.color=`transparent`,`transparent`;let t=r.brighterLeafNodes()?`brighter`:`darker`,i;return r.usePaletteOnParentNodes()?i=e.children?r._palette(e.data.label):(0,n.rgb)(r._palette(e.parent.data.label))[t](1):(i=e.depth>r.depthColorLimit()?(0,n.rgb)(e.parent.color)[t](1):r._palette(e.data.label),e.color=i),this.style.color=n.Palette.textColor(i),i}).transition().duration(this.transitionDuration()).style(`pointer-events`,function(e){return!r.showRoot()&&e.depth===0?`none`:`all`}).style(`opacity`,function(e){return e.children?1:null}).style(`left`,function(e){return e.x0+`px`}).style(`top`,function(e){return e.y0+`px`}).style(`width`,function(e){return Math.max(0,e.x1-e.x0)+`px`}).style(`height`,function(e){return Math.max(0,e.y1-e.y0)+`px`}).each(function(e){e.depth===0&&(this.style.color=r.showRoot()?``:`transparent`,this.style.borderColor=r.showRoot()?``:`transparent`)}),a.exit().transition().duration(this.transitionDuration()).style(`opacity`,0).remove();function tooltip(e){if(e.children&&!r.enableParentTooltips())return null;let t=e.data.label+` (`+e.value+`)`;for(;e.parent&&e.parent.parent;)t=e.parent.data.label+` -> `+t,e=e.parent;return t}}exit(e,t){super.exit(e,t)}nodeWeight(e){return e.size||1}parentWeightHTML(e){return this.showParentWeight()?`<span class="treemap-parent-label">${e.data.label}</span><span class="treemap-parent-value">${e.value}${this.weightSuffix()}</span>`:`<span class="treemap-parent-label">${e.data.label}</span>`}leafWeightHTML(e){return this.showLeafWeight()?`<span class="treemap-leaf-label">${e.data.label}</span><span class="treemap-leaf-value">${e.value}${this.weightSuffix()}</span>`:`<span class="treemap-leaf-label">${e.data.label}</span>`}};Treemap.prototype._class+=` tree_Treemap`,Treemap.prototype.implements(t.ITree.prototype),Treemap.prototype.mixin(n.Utility.SimpleSelectionMixin),Treemap.prototype.Column=TreemapColumn,Treemap.prototype.publish(`paletteID`,`default`,`set`,`Color palette for this widget`,Treemap.prototype._palette.switch(),{tags:[`Basic`,`Shared`]}),Treemap.prototype.publish(`useClonedPalette`,!1,`boolean`,`Enable or disable using a cloned palette`,null,{tags:[`Intermediate`,`Shared`]}),Treemap.prototype.publish(`mappings`,[],`propertyArray`,`Source Columns`,null,{autoExpand:TreemapColumn}),Treemap.prototype.publish(`aggrType`,null,`set`,`Aggregation Type`,[null,`mean`,`median`,`sum`,`min`,`max`],{optional:!0}),Treemap.prototype.publish(`aggrColumn`,null,`set`,`Aggregation Field`,function(){return this.columns()},{optional:!0,disable:e=>!e.aggrType()}),Treemap.prototype.publish(`fontSize`,null,`number`,`Font Size`,null,{optional:!0}),Treemap.prototype.publish(`paddingInner`,18.6,`number`,`Pixel spacing between each sibling node`),Treemap.prototype.publish(`paddingOuter`,30,`number`,`Pixel padding of parent nodes`),Treemap.prototype.publish(`paddingTop`,41.4,`number`,`Additional top pixel padding of parent nodes`),Treemap.prototype.publish(`showRoot`,!1,`boolean`,`Show root element`),Treemap.prototype.publish(`parentFontSize`,18,`number`,`Parent font-size`),Treemap.prototype.publish(`leafFontSize`,16,`number`,`Leaf font-size`),Treemap.prototype.publish(`usePaletteOnParentNodes`,!1,`boolean`,`Assign a color from the palette to every parent node`),Treemap.prototype.publish(`depthColorLimit`,1,`number`,`Assign a color from the palette to node with depth lower than this value`,null,{optional:!0,disable:e=>e.usePaletteOnParentNodes()}),Treemap.prototype.publish(`squarifyRatio`,1,`number`,`Specifies the desired aspect ratio of the generated rectangles (must be >= 1)`,null,{optional:!0,disable:e=>[`treemapSquarify`,`treemapResquarify`].indexOf(e.tilingMethod())===-1}),Treemap.prototype.publish(`showParentWeight`,!0,`boolean`,`Show weight of parent nodes`),Treemap.prototype.publish(`showLeafWeight`,!0,`boolean`,`Show weight of leaf nodes`),Treemap.prototype.publish(`weightSuffix`,``,`string`,`Weight suffix (ex: 'ms')`),Treemap.prototype.publish(`brighterLeafNodes`,!1,`boolean`,`Brighter/darker leaf node color (false = darker)`),Treemap.prototype.publish(`enableParentLabels`,!0,`boolean`,`Enable parent labels`),Treemap.prototype.publish(`enableParentTooltips`,!0,`boolean`,`Enable parent tooltips`),Treemap.prototype.publish(`transitionDuration`,250,`number`,`Transition Duration`),Treemap.prototype.publish(`tilingMethod`,`treemapSquarify`,`set`,`Transition Duration`,[`treemapBinary`,`treemapDice`,`treemapResquarify`,`treemapSlice`,`treemapSliceDice`,`treemapSquarify`]),e.BUILD_VERSION=o,e.CirclePacking=CirclePacking,e.Dendrogram=Dendrogram,e.DendrogramColumn=DendrogramColumn,e.DirectoryTree=DirectoryTree,e.Indented=Indented,e.IndentedColumn=IndentedColumn,e.PKG_NAME=i,e.PKG_VERSION=a,e.SunburstPartition=SunburstPartition,e.Treemap=Treemap,e.TreemapColumn=TreemapColumn});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@hpcc-js/api"),require("@hpcc-js/common")):typeof define==`function`&&define.amd?define([`exports`,`@hpcc-js/api`,`@hpcc-js/common`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@hpcc-js/tree`]={},e[`@hpcc-js/api`],e[`@hpcc-js/common`]))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=Object.defineProperty,__name=(e,t)=>r(e,`name`,{value:t,configurable:!0}),i=`@hpcc-js/tree`,a=`3.3.0`,o=`3.26.0`;function defaultSeparation$1(e,t){return e.parent===t.parent?1:2}__name(defaultSeparation$1,`defaultSeparation`);function meanX(e){return e.reduce(meanXReduce,0)/e.length}function meanXReduce(e,t){return e+t.x}function maxY(e){return 1+e.reduce(maxYReduce,0)}function maxYReduce(e,t){return Math.max(e,t.y)}function leafLeft(e){for(var t;t=e.children;)e=t[0];return e}function leafRight(e){for(var t;t=e.children;)e=t[t.length-1];return e}__name(cluster_default,`default`);function cluster_default(){var e=defaultSeparation$1,t=1,n=1,r=!1;function cluster(i){var a,o=0;i.eachAfter(function(t){var n=t.children;n?(t.x=meanX(n),t.y=maxY(n)):(t.x=a?o+=e(t,a):0,t.y=0,a=t)});var s=leafLeft(i),c=leafRight(i),l=s.x-e(s,c)/2,u=c.x+e(c,s)/2;return i.eachAfter(r?function(e){e.x=(e.x-i.x)*t,e.y=(i.y-e.y)*n}:function(e){e.x=(e.x-l)/(u-l)*t,e.y=(1-(i.y?e.y/i.y:1))*n})}return cluster.separation=function(t){return arguments.length?(e=t,cluster):e},cluster.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],cluster):r?null:[t,n]},cluster.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],cluster):r?[t,n]:null},cluster}function count(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function count_default(){return this.eachAfter(count)}__name(count_default,`default`);function each_default(e){var t=this,n,r=[t],i,a,o;do for(n=r.reverse(),r=[];t=n.pop();)if(e(t),i=t.children,i)for(a=0,o=i.length;a<o;++a)r.push(i[a]);while(r.length);return this}__name(each_default,`default`);function eachBefore_default(e){for(var t=this,n=[t],r,i;t=n.pop();)if(e(t),r=t.children,r)for(i=r.length-1;i>=0;--i)n.push(r[i]);return this}__name(eachBefore_default,`default`);function eachAfter_default(e){for(var t=this,n=[t],r=[],i,a,o;t=n.pop();)if(r.push(t),i=t.children,i)for(a=0,o=i.length;a<o;++a)n.push(i[a]);for(;t=r.pop();)e(t);return this}__name(eachAfter_default,`default`);function sum_default(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}__name(sum_default,`default`);function sort_default(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}__name(sort_default,`default`);function path_default(e){for(var t=this,n=leastCommonAncestor(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}__name(path_default,`default`);function leastCommonAncestor(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}function ancestors_default(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}__name(ancestors_default,`default`);function descendants_default(){var e=[];return this.each(function(t){e.push(t)}),e}__name(descendants_default,`default`);function leaves_default(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}__name(leaves_default,`default`);function links_default(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}__name(links_default,`default`);function hierarchy(e,t){var n=new Node$1(e),r=+e.value&&(n.value=e.value),i,a=[n],o,s,c,l;for(t??=defaultChildren;i=a.pop();)if(r&&(i.value=+i.data.value),(s=t(i.data))&&(l=s.length))for(i.children=Array(l),c=l-1;c>=0;--c)a.push(o=i.children[c]=new Node$1(s[c])),o.parent=i,o.depth=i.depth+1;return n.eachBefore(computeHeight)}function node_copy(){return hierarchy(this).eachBefore(copyData)}function defaultChildren(e){return e.children}function copyData(e){e.data=e.data.data}function computeHeight(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function Node$1(e){this.data=e,this.depth=this.height=0,this.parent=null}__name(Node$1,`Node`),Node$1.prototype=hierarchy.prototype={constructor:Node$1,count:count_default,each:each_default,eachAfter:eachAfter_default,eachBefore:eachBefore_default,sum:sum_default,sort:sort_default,path:path_default,ancestors:ancestors_default,descendants:descendants_default,leaves:leaves_default,links:links_default,copy:node_copy};var s=Array.prototype.slice;function shuffle(e){for(var t=e.length,n,r;t;)r=Math.random()*t--|0,n=e[t],e[t]=e[r],e[r]=n;return e}function enclose_default(e){for(var t=0,n=(e=shuffle(s.call(e))).length,r=[],i,a;t<n;)i=e[t],a&&enclosesWeak(a,i)?++t:(a=encloseBasis(r=extendBasis(r,i)),t=0);return a}__name(enclose_default,`default`);function extendBasis(e,t){var n,r;if(enclosesWeakAll(t,e))return[t];for(n=0;n<e.length;++n)if(enclosesNot(t,e[n])&&enclosesWeakAll(encloseBasis2(e[n],t),e))return[e[n],t];for(n=0;n<e.length-1;++n)for(r=n+1;r<e.length;++r)if(enclosesNot(encloseBasis2(e[n],e[r]),t)&&enclosesNot(encloseBasis2(e[n],t),e[r])&&enclosesNot(encloseBasis2(e[r],t),e[n])&&enclosesWeakAll(encloseBasis3(e[n],e[r],t),e))return[e[n],e[r],t];throw Error()}function enclosesNot(e,t){var n=e.r-t.r,r=t.x-e.x,i=t.y-e.y;return n<0||n*n<r*r+i*i}function enclosesWeak(e,t){var n=e.r-t.r+1e-6,r=t.x-e.x,i=t.y-e.y;return n>0&&n*n>r*r+i*i}function enclosesWeakAll(e,t){for(var n=0;n<t.length;++n)if(!enclosesWeak(e,t[n]))return!1;return!0}function encloseBasis(e){switch(e.length){case 1:return encloseBasis1(e[0]);case 2:return encloseBasis2(e[0],e[1]);case 3:return encloseBasis3(e[0],e[1],e[2])}}function encloseBasis1(e){return{x:e.x,y:e.y,r:e.r}}function encloseBasis2(e,t){var n=e.x,r=e.y,i=e.r,a=t.x,o=t.y,s=t.r,c=a-n,l=o-r,u=s-i,d=Math.sqrt(c*c+l*l);return{x:(n+a+c/d*u)/2,y:(r+o+l/d*u)/2,r:(d+i+s)/2}}function encloseBasis3(e,t,n){var r=e.x,i=e.y,a=e.r,o=t.x,s=t.y,c=t.r,l=n.x,u=n.y,d=n.r,f=r-o,p=r-l,m=i-s,h=i-u,g=c-a,_=d-a,v=r*r+i*i-a*a,y=v-o*o-s*s+c*c,b=v-l*l-u*u+d*d,x=p*m-f*h,S=(m*b-h*y)/(x*2)-r,C=(h*g-m*_)/x,w=(p*y-f*b)/(x*2)-i,T=(f*_-p*g)/x,E=C*C+T*T-1,D=2*(a+S*C+w*T),O=S*S+w*w-a*a,k=-(E?(D+Math.sqrt(D*D-4*E*O))/(2*E):O/D);return{x:r+S+C*k,y:i+w+T*k,r:k}}function place(e,t,n){var r=e.x-t.x,i,a,o=e.y-t.y,s,c,l=r*r+o*o;l?(a=t.r+n.r,a*=a,c=e.r+n.r,c*=c,a>c?(i=(l+c-a)/(2*l),s=Math.sqrt(Math.max(0,c/l-i*i)),n.x=e.x-i*r-s*o,n.y=e.y-i*o+s*r):(i=(l+a-c)/(2*l),s=Math.sqrt(Math.max(0,a/l-i*i)),n.x=t.x+i*r-s*o,n.y=t.y+i*o+s*r)):(n.x=t.x+n.r,n.y=t.y)}function intersects(e,t){var n=e.r+t.r-1e-6,r=t.x-e.x,i=t.y-e.y;return n>0&&n*n>r*r+i*i}function score(e){var t=e._,n=e.next._,r=t.r+n.r,i=(t.x*n.r+n.x*t.r)/r,a=(t.y*n.r+n.y*t.r)/r;return i*i+a*a}function Node(e){this._=e,this.next=null,this.previous=null}function packEnclose(e){if(!(i=e.length))return 0;var t=e[0],n,r,i,a,o,s,c,l,u,d;if(t.x=0,t.y=0,!(i>1))return t.r;if(n=e[1],t.x=-n.r,n.x=t.r,n.y=0,!(i>2))return t.r+n.r;place(n,t,r=e[2]),t=new Node(t),n=new Node(n),r=new Node(r),t.next=r.previous=n,n.next=t.previous=r,r.next=n.previous=t;pack:for(s=3;s<i;++s){place(t._,n._,r=e[s]),r=new Node(r),c=n.next,l=t.previous,u=n._.r,d=t._.r;do if(u<=d){if(intersects(c._,r._)){n=c,t.next=n,n.previous=t,--s;continue pack}u+=c._.r,c=c.next}else{if(intersects(l._,r._)){t=l,t.next=n,n.previous=t,--s;continue pack}d+=l._.r,l=l.previous}while(c!==l.next);for(r.previous=t,r.next=n,t.next=n.previous=n=r,a=score(t);(r=r.next)!==n;)(o=score(r))<a&&(t=r,a=o);n=t.next}for(t=[n._],r=n;(r=r.next)!==n;)t.push(r._);for(r=enclose_default(t),s=0;s<i;++s)t=e[s],t.x-=r.x,t.y-=r.y;return r.r}function optional(e){return e==null?null:required(e)}function required(e){if(typeof e!=`function`)throw Error();return e}function constantZero(){return 0}function constant_default$1(e){return function(){return e}}__name(constant_default$1,`default`);function defaultRadius(e){return Math.sqrt(e.value)}function pack_default(){var e=null,t=1,n=1,r=constantZero;function pack(i){return i.x=t/2,i.y=n/2,e?i.eachBefore(radiusLeaf(e)).eachAfter(packChildren(r,.5)).eachBefore(translateChild(1)):i.eachBefore(radiusLeaf(defaultRadius)).eachAfter(packChildren(constantZero,1)).eachAfter(packChildren(r,i.r/Math.min(t,n))).eachBefore(translateChild(Math.min(t,n)/(2*i.r))),i}return pack.radius=function(t){return arguments.length?(e=optional(t),pack):e},pack.size=function(e){return arguments.length?(t=+e[0],n=+e[1],pack):[t,n]},pack.padding=function(e){return arguments.length?(r=typeof e==`function`?e:constant_default$1(+e),pack):r},pack}__name(pack_default,`default`);function radiusLeaf(e){return function(t){t.children||(t.r=Math.max(0,+e(t)||0))}}function packChildren(e,t){return function(n){if(r=n.children){var r,i,a=r.length,o=e(n)*t||0,s;if(o)for(i=0;i<a;++i)r[i].r+=o;if(s=packEnclose(r),o)for(i=0;i<a;++i)r[i].r-=o;n.r=s+o}}}function translateChild(e){return function(t){var n=t.parent;t.r*=e,n&&(t.x=n.x+e*t.x,t.y=n.y+e*t.y)}}function round_default(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}__name(round_default,`default`);function dice_default(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s<c;)o=a[s],o.y0=n,o.y1=i,o.x0=t,o.x1=t+=o.value*l}__name(dice_default,`default`);function partition_default(){var e=1,t=1,n=0,r=!1;function partition(i){var a=i.height+1;return i.x0=i.y0=n,i.x1=e,i.y1=t/a,i.eachBefore(positionNode(t,a)),r&&i.eachBefore(round_default),i}function positionNode(e,t){return function(r){r.children&&dice_default(r,r.x0,e*(r.depth+1)/t,r.x1,e*(r.depth+2)/t);var i=r.x0,a=r.y0,o=r.x1-n,s=r.y1-n;o<i&&(i=o=(i+o)/2),s<a&&(a=s=(a+s)/2),r.x0=i,r.y0=a,r.x1=o,r.y1=s}}return partition.round=function(e){return arguments.length?(r=!!e,partition):r},partition.size=function(n){return arguments.length?(e=+n[0],t=+n[1],partition):[e,t]},partition.padding=function(e){return arguments.length?(n=+e,partition):n},partition}__name(partition_default,`default`);function defaultSeparation(e,t){return e.parent===t.parent?1:2}function nextLeft(e){var t=e.children;return t?t[0]:e.t}function nextRight(e){var t=e.children;return t?t[t.length-1]:e.t}function moveSubtree(e,t,n){var r=n/(t.i-e.i);t.c-=r,t.s+=n,e.c+=r,t.z+=n,t.m+=n}function executeShifts(e){for(var t=0,n=0,r=e.children,i=r.length,a;--i>=0;)a=r[i],a.z+=t,a.m+=t,t+=a.s+(n+=a.c)}function nextAncestor(e,t,n){return e.a.parent===t.parent?e.a:n}function TreeNode(e,t){this._=e,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=t}TreeNode.prototype=Object.create(Node$1.prototype);function treeRoot(e){for(var t=new TreeNode(e,0),n,r=[t],i,a,o,s;n=r.pop();)if(a=n._.children)for(n.children=Array(s=a.length),o=s-1;o>=0;--o)r.push(i=n.children[o]=new TreeNode(a[o],o)),i.parent=n;return(t.parent=new TreeNode(null,0)).children=[t],t}function tree_default(){var e=defaultSeparation,t=1,n=1,r=null;function tree(i){var a=treeRoot(i);if(a.eachAfter(firstWalk),a.parent.m=-a.z,a.eachBefore(secondWalk),r)i.eachBefore(sizeNode);else{var o=i,s=i,c=i;i.eachBefore(function(e){e.x<o.x&&(o=e),e.x>s.x&&(s=e),e.depth>c.depth&&(c=e)});var l=o===s?1:e(o,s)/2,u=l-o.x,d=t/(s.x+l+u),f=n/(c.depth||1);i.eachBefore(function(e){e.x=(e.x+u)*d,e.y=e.depth*f})}return i}function firstWalk(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n){executeShifts(t);var a=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+e(t._,i._));t.parent.A=apportion(t,i,t.parent.A||r[0])}function secondWalk(e){e._.x=e.z+e.parent.m,e.m+=e.parent.m}function apportion(t,n,r){if(n){for(var i=t,a=t,o=n,s=i.parent.children[0],c=i.m,l=a.m,u=o.m,d=s.m,f;o=nextRight(o),i=nextLeft(i),o&&i;)s=nextLeft(s),a=nextRight(a),a.a=t,f=o.z+u-i.z-c+e(o._,i._),f>0&&(moveSubtree(nextAncestor(o,t,r),t,f),c+=f,l+=f),u+=o.m,c+=i.m,d+=s.m,l+=a.m;o&&!nextRight(a)&&(a.t=o,a.m+=u-l),i&&!nextLeft(s)&&(s.t=i,s.m+=c-d,r=t)}return r}function sizeNode(e){e.x*=t,e.y=e.depth*n}return tree.separation=function(t){return arguments.length?(e=t,tree):e},tree.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],tree):r?null:[t,n]},tree.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],tree):r?[t,n]:null},tree}__name(tree_default,`default`);function slice_default(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(i-n)/e.value;++s<c;)o=a[s],o.x0=t,o.x1=r,o.y0=n,o.y1=n+=o.value*l}__name(slice_default,`default`);var c=(1+Math.sqrt(5))/2;function squarifyRatio(e,t,n,r,i,a){for(var o=[],s=t.children,c,l,u=0,d=0,f=s.length,p,m,h=t.value,g,_,v,y,b,x,S;u<f;){p=i-n,m=a-r;do g=s[d++].value;while(!g&&d<f);for(_=v=g,x=Math.max(m/p,p/m)/(h*e),S=g*g*x,b=Math.max(v/S,S/_);d<f;++d){if(g+=l=s[d].value,l<_&&(_=l),l>v&&(v=l),S=g*g*x,y=Math.max(v/S,S/_),y>b){g-=l;break}b=y}o.push(c={value:g,dice:p<m,children:s.slice(u,d)}),c.dice?dice_default(c,n,r,i,h?r+=m*g/h:a):slice_default(c,n,r,h?n+=p*g/h:i,a),h-=g,u=d}return o}var l=(function custom(e){function squarify(t,n,r,i,a){squarifyRatio(e,t,n,r,i,a)}return squarify.ratio=function(e){return custom((e=+e)>1?e:1)},squarify})(c);function treemap_default(){var e=l,t=!1,n=1,r=1,i=[0],a=constantZero,o=constantZero,s=constantZero,c=constantZero,u=constantZero;function treemap(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(positionNode),i=[0],t&&e.eachBefore(round_default),e}function positionNode(t){var n=i[t.depth],r=t.x0+n,l=t.y0+n,d=t.x1-n,f=t.y1-n;d<r&&(r=d=(r+d)/2),f<l&&(l=f=(l+f)/2),t.x0=r,t.y0=l,t.x1=d,t.y1=f,t.children&&(n=i[t.depth+1]=a(t)/2,r+=u(t)-n,l+=o(t)-n,d-=s(t)-n,f-=c(t)-n,d<r&&(r=d=(r+d)/2),f<l&&(l=f=(l+f)/2),e(t,r,l,d,f))}return treemap.round=function(e){return arguments.length?(t=!!e,treemap):t},treemap.size=function(e){return arguments.length?(n=+e[0],r=+e[1],treemap):[n,r]},treemap.tile=function(t){return arguments.length?(e=required(t),treemap):e},treemap.padding=function(e){return arguments.length?treemap.paddingInner(e).paddingOuter(e):treemap.paddingInner()},treemap.paddingInner=function(e){return arguments.length?(a=typeof e==`function`?e:constant_default$1(+e),treemap):a},treemap.paddingOuter=function(e){return arguments.length?treemap.paddingTop(e).paddingRight(e).paddingBottom(e).paddingLeft(e):treemap.paddingTop()},treemap.paddingTop=function(e){return arguments.length?(o=typeof e==`function`?e:constant_default$1(+e),treemap):o},treemap.paddingRight=function(e){return arguments.length?(s=typeof e==`function`?e:constant_default$1(+e),treemap):s},treemap.paddingBottom=function(e){return arguments.length?(c=typeof e==`function`?e:constant_default$1(+e),treemap):c},treemap.paddingLeft=function(e){return arguments.length?(u=typeof e==`function`?e:constant_default$1(+e),treemap):u},treemap}__name(treemap_default,`default`);function binary_default(e,t,n,r,i){var a=e.children,o,s=a.length,c,l=Array(s+1);for(l[0]=c=o=0;o<s;++o)l[o+1]=c+=a[o].value;partition(0,s,e.value,t,n,r,i);function partition(e,t,n,r,i,o,s){if(e>=t-1){var c=a[e];c.x0=r,c.y0=i,c.x1=o,c.y1=s;return}for(var u=l[e],d=n/2+u,f=e+1,p=t-1;f<p;){var m=f+p>>>1;l[m]<d?f=m+1:p=m}d-l[f-1]<l[f]-d&&e+1<f&&--f;var h=l[f]-u,g=n-h;if(o-r>s-i){var _=(r*g+o*h)/n;partition(e,f,h,r,i,_,s),partition(f,t,g,_,i,o,s)}else{var v=(i*g+s*h)/n;partition(e,f,h,r,i,o,v),partition(f,t,g,r,v,o,s)}}}__name(binary_default,`default`);function sliceDice_default(e,t,n,r,i){(e.depth&1?slice_default:dice_default)(e,t,n,r,i)}__name(sliceDice_default,`default`);var u=(function custom(e){function resquarify(t,n,r,i,a){if((o=t._squarify)&&o.ratio===e)for(var o,s,c,l,u=-1,d,f=o.length,p=t.value;++u<f;){for(s=o[u],c=s.children,l=s.value=0,d=c.length;l<d;++l)s.value+=c[l].value;s.dice?dice_default(s,n,r,i,r+=(a-r)*s.value/p):slice_default(s,n,r,n+=(i-n)*s.value/p,a),p-=s.value}else t._squarify=o=squarifyRatio(e,t,n,r,i,a),o.ratio=e}return resquarify.ratio=function(e){return custom((e=+e)>1?e:1)},resquarify})(c),CirclePacking=class extends n.SVGWidget{diameter;pack;svg;_focus;circle;view;_node;constructor(){super(),t.ITree.call(this)}enter(e,t){this.diameter=Math.min(this.width(),this.height()),this.pack=pack_default().size([this.diameter-4,this.diameter-4]).padding(1.5),this.svg=t.append(`g`)}update(e,t){let 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();let i=hierarchy(this.data()).sum(function(e){return e&&e.size?e.size:1}).sort(function(e,t){return e.value<t.value?-1:+(e.value>t.value)});this._focus=i,this.pack(i),this.circle=this.svg.selectAll(`circle`).data(i.descendants()).enter().append(`circle`).attr(`class`,function(e){return e.parent?e.children?`node`:`node leaf`:`node root`}).style(`fill`,function(e){return e.color=r.paletteDepthLevel_exists()&&e.depth>r.paletteDepthLevel()?(0,n.rgb)(e.parent.color)[r.paletteDepthVariant()](1):r._palette(e.data.label),e.color}).on(`click`,function(e){r.click(e.data,null,null)}).on(`dblclick`,function(e){this._focus!==e&&r.zoom(e),(0,n.d3Event)().stopPropagation()}),this.circle.append(`title`).text(function(e){return e.data.label}),this.svg.selectAll(`text`).data(i.descendants()).enter().append(`text`).attr(`class`,`label`).style(`fill-opacity`,function(e){return+(e.parent===i)}).style(`display`,function(e){return e.parent===i?null:`none`}).text(function(e){return e.data.label+(r.showSize()&&e.data.size!==void 0?` `+e.data.size:``)}),this._node=this.svg.selectAll(`circle,text`),this.zoomTo([i.x,i.y,i.r*2])}zoom(e){this._focus=e;let t=this,r=this.svg.transition().duration((0,n.d3Event)().altKey?7500:750).tween(`zoom`,function(){let e=(0,n.interpolateZoom)(t.view,[t._focus.x,t._focus.y,t._focus.r*2]);return function(n){t.zoomTo(e(n))}});function showText(e){return e===t._focus&&!e.children||e.parent===t._focus}r.selectAll(`text`).filter(function(e){return showText(e)||this.style.display===`inline`}).style(`fill-opacity`,function(e){return+!!showText(e)}).on(`start`,function(e){showText(e)&&(this.style.display=`inline`)}).on(`end`,function(e){showText(e)||(this.style.display=`none`)})}zoomTo(e){let t=this.diameter/e[2];this.view=e,this._node.attr(`transform`,function(n){return`translate(`+(n.x-e[0])*t+`,`+(n.y-e[1])*t+`)`}),this.circle.attr(`r`,function(e){return e.r*t})}};CirclePacking.prototype._class+=` tree_CirclePacking`,CirclePacking.prototype.implements(t.ITree.prototype),CirclePacking.prototype.publish(`showSize`,!0,`boolean`,`Show size along with label`),CirclePacking.prototype.publish(`paletteDepthLevel`,null,`number`,`If not null then beyond this depth number the child node colors are based on parent`,null,{optional:!0}),CirclePacking.prototype.publish(`paletteDepthVariant`,`brighter`,`set`,`Determines paletteDepthLevel decendant color shade variant`,[`brighter`,`darker`],{disable:e=>e.paletteDepthLevel_exists()}),CirclePacking.prototype.publish(`paletteID`,`default`,`set`,`Color palette for this widget`,CirclePacking.prototype._palette.switch(),{tags:[`Basic`,`Shared`]}),CirclePacking.prototype.publish(`useClonedPalette`,!1,`boolean`,`Enable or disable using a cloned palette`,null,{tags:[`Intermediate`,`Shared`]});var DendrogramColumn=class extends n.PropertyExt{_owner;constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.column()}column};DendrogramColumn.prototype._class+=` tree_Dendrogram.DendrogramColumn`,DendrogramColumn.prototype.publish(`column`,null,`set`,`Field`,function(){return this._owner?this._owner.columns():[]},{optional:!0});var Dendrogram=class extends n.SVGZoomWidget{Column;_d3LayoutCluster;_d3LayoutTree;_d3Layout;constructor(){super(),t.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this),this._drawStartPos=`origin`,this._d3LayoutCluster=cluster_default(),this._d3LayoutTree=tree_default()}dendrogramData(){if(this.data().length===0)return[];if(!this.mappings().filter(e=>e.valid()).length)return this.data();return formatData({key:`root`,values:this._db.rollupView(this.mappings().map(function(e){return e.column()})).entries()});function formatData(e){return{label:e.key,children:e.values.filter(function(e){return!(e instanceof Array)}).map(function(e){return formatData(e)}),origRows:e.values}}}enter(e,t){super.enter(e,t),this._renderElement.attr(`opacity`,0).transition().duration(500).attr(`opacity`,1),this._selection.widgetElement(this._renderElement)}update(e,t){super.update(e,t);let r=this,i=this.orientation()===`vertical`;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,this.separation()*2]),this._d3Layout.separation(function separation(e,t){return(e.parent===t.parent?1:2)/e.depth})):(this._d3Layout.nodeSize([14,this.separation()]),this._d3Layout.separation(function separation(e,t){return e.parent===t.parent?1:2}));let a=hierarchy(this.dendrogramData());this._d3Layout(a);let o=a.descendants(),s=a.descendants().slice(1);function linkVertical(e){return`M`+e.parent.x+`,`+e.parent.y+`C`+e.parent.x+`,`+(e.parent.y+e.y)/2+` `+e.x+`,`+(e.parent.y+e.y)/2+` `+e.x+`,`+e.y}function linkHorizontal(e){return`M`+e.y+`,`+e.x+`C`+(e.y+e.parent.y)/2+`,`+e.x+` `+(e.y+e.parent.y)/2+`,`+e.parent.x+` `+e.parent.y+`,`+e.parent.x}function diagonal(e){return i?linkVertical(e):linkHorizontal(e)}function project(e,t){let n=(e-90)/180*Math.PI,r=t;return[r*Math.cos(n),r*Math.sin(n)]}function radialDiagonal(e){return`M`+project(e.x,e.y)+`C`+project(e.x,(e.y+e.parent.y)/2)+` `+project(e.parent.x,(e.y+e.parent.y)/2)+` `+project(e.parent.x,e.parent.y)}let c=this._renderCount?500:0,l=this._renderElement.selectAll(`.link`).data(s);l.enter().append(`path`).attr(`class`,`link`).attr(`d`,this.radial()?radialDiagonal:diagonal),l.transition().duration(c).attr(`d`,this.radial()?radialDiagonal:diagonal),l.exit().remove();let u=this.circleRadius()+2;function nodeTransform(e){return r.radial()?`rotate(`+(e.x-90)+`)translate(`+e.y+`)`:r.orientation()===`horizontal`?`translate(`+e.y+`,`+e.x+`)`:`translate(`+e.x+`,`+e.y+`)`}let d=this._renderElement.selectAll(`.node`).data(o);d.transition().duration(c).attr(`transform`,nodeTransform);let f=d.enter().append(`g`).attr(`class`,`node`).attr(`transform`,nodeTransform).call(this._selection.enter.bind(this._selection)).on(`click`,function(e){let t=e;for(;t.children;)t=t.children[0];e.depth>0&&(t.origRows?r.click(r.rowToObj(t.origRows[0]),r.mappings()[e.depth-1].column(),!0):r.click(t.data,r.mappings()[e.depth-1].column(),!0))}).on(`dblclick`,function(e){let t=e;for(;t.children;)t=t.children[0];e.depth>0&&(t.origRows?r.dblclick(r.rowToObj(t.origRows[0]),r.mappings()[e.depth-1].column(),!0):r.dblclick(t.data,r.mappings()[e.depth-1].column(),!0))}).each(function(){let e=(0,n.select)(this);e.append(`circle`),e.append(`text`)});f.merge(d).select(`circle`).attr(`r`,this.circleRadius()).style(`fill`,function(e){return r._palette(e.data.label)}).append(`title`).text(function(e){return e.data.label}),f.merge(d).select(`text`).attr(`dx`,function(e){return r.radial()?e.children?e.x<180?-u:u:e.x<180?u:-u:i?e.children?u:-u:e.children?-u:u}).attr(`dy`,`0.25em`).style(`text-anchor`,function(e){return r.radial()?e.children?e.x<180?`end`:`start`:e.x<180?`start`:`end`:i?e.children?`start`:`end`:e.children?`end`:`start`}).attr(`transform`,function(e){return r.radial()?e.x<180?null:`rotate(180)`:i?`rotate(-66)`:null}).text(function(e){return e.data.label}),d.exit().remove(),this._renderCount||r.zoomToFit()}};Dendrogram.prototype._class+=` tree_Dendrogram`,Dendrogram.prototype.implements(t.ITree.prototype),Dendrogram.prototype.mixin(n.Utility.SimpleSelectionMixin),Dendrogram.prototype.Column=DendrogramColumn,Dendrogram.prototype.publish(`paletteID`,`default`,`set`,`Color palette for this widget`,Dendrogram.prototype._palette.switch(),{tags:[`Basic`,`Shared`]}),Dendrogram.prototype.publish(`useClonedPalette`,!1,`boolean`,`Enable or disable using a cloned palette`,null,{tags:[`Intermediate`,`Shared`]}),Dendrogram.prototype.publish(`mappings`,[],`propertyArray`,`Source Columns`,null,{autoExpand:DendrogramColumn}),Dendrogram.prototype.publish(`circleRadius`,4.5,`number`,`Text offset from circle`),Dendrogram.prototype.publish(`separation`,240,`number`,`Leaf Separation`),Dendrogram.prototype.publish(`dendrogram`,!0,`boolean`,`Dendrogram`),Dendrogram.prototype.publish(`radial`,!1,`boolean`,`Radial`),Dendrogram.prototype.publish(`orientation`,`horizontal`,`set`,`Orientation`,[`horizontal`,`vertical`],{tags:[`Private`],disable:e=>e.radial()});var DirectoryTree=class extends n.HTMLWidget{constructor(){super()}flattenData(e){let t=this,n=hierarchy(e),r=[];return this.omitRoot()?n.children&&n.children.forEach(visitNode):visitNode(n),r;function visitNode(e){let n=e.data.markers&&e.data.markers.length?e.data.markers.length:``;r.push({label:e.data.label,depth:e.depth-+!!t.omitRoot(),content:e.data.content,isFolder:!!e.data.children,iconClass:e.data.iconClass,color:e.data.color,bold:e.data.bold,weightValue:n,markers:e.data.markers,selected:e.data.selected}),e.children&&e.children.forEach(visitNode)}}iconClass(e){return e.label===`error`?`fa fa-exclamation`:e.isFolder?this.folderIconOpen():this.textFileIcon()}calcRequiredWidth(){let e=this.flattenData(this.data()),t=0,r=this.rowItemPadding(),i=this.iconSize()+r*2,a=n.Platform.getScrollbarWidth();return e.forEach(e=>{let o=e.depth*i+r*2,s=n.Utility.textSize(e.label,this.fontFamily(),this.fontSize(),!!e.bold).width+r*2+i+o+a;t<s&&(t=s)}),t}rowClick(e,t){}enter(e,t){super.enter(e,t),t.style(`width`,`100%`).style(`height`,`100%`)}update(e,t){super.update(e,t),this._palette=this._palette.switch(this.paletteID()),t.style(`overflow-y`,this.verticalScroll()?`scroll`:null);let r=this.flattenData(this.data()),i=(0,n.max)(r,e=>Number(e.weightValue));r.forEach(e=>{e.weightValue?e.weightColor=this._palette(e.weightValue,1,i):e.weightColor=`transparent`});let a=this,o=this.rowItemPadding(),s=this.iconSize()+o,c=Math.max(a.iconSize(),a.fontSize()),l=t.selectAll(`.directory-row`).data(r),u=this.fontFamily(),d=this.fontSize(),f=(0,n.max)(r,e=>this.textSize(e.weightValue,u,d).width),p=`${o}px ${o}px ${o/2}px ${o}px`;l.enter().append(`div`).attr(`class`,e=>`directory-row directory-row-depth-${e.depth}`).style(`display`,`flex`).style(`cursor`,`pointer`).each(function(e){let r=(0,n.select)(this),i=e.color?e.color:a.fontColor(),l=e.weightColor?e.weightColor:`transparent`,m=n.Palette.textColor(l),h=r.append(`div`).attr(`class`,`row-weight`).style(`padding`,p).style(`color`,m).style(`box-shadow`,`inset 0 0 100px ${l}`).style(`font-weight`,e.bold?`bold`:`normal`).style(`font-family`,u).style(`font-size`,d+`px`).text(e.weightValue).attr(`title`,e.weightValue).style(`overflow`,`hidden`).style(`width`,f+o*2+`px`).style(`text-overflow`,`ellipsis`).style(`text-align`,`right`).style(`line-height`,c+`px`);r.append(`div`).attr(`class`,`row-depth`).style(`width`,a.depthSize()*e.depth+`px`).style(`opacity`,1).style(`line-height`,c+`px`);let g=r.append(`div`).attr(`class`,`row-icon `+(e.iconClass?e.iconClass:a.iconClass(e))).style(`width`,s+`px`).style(`height`,c+`px`).style(`color`,i).style(`background-color`,e.selected?a.selectionBackgroundColor():`transparent`).style(`font-size`,a.iconSize()+`px`).style(`padding`,p).style(`line-height`,c+`px`),_=r.append(`div`).attr(`class`,`row-label`).style(`padding`,p).style(`color`,i).style(`background-color`,e.selected?a.selectionBackgroundColor():`transparent`).style(`font-weight`,e.bold?`bold`:`normal`).style(`font-family`,a.fontFamily()).style(`font-size`,a.fontSize()+`px`).text(e.label).attr(`title`,e.label).style(`flex`,1).style(`overflow`,`hidden`).style(`text-overflow`,`ellipsis`).style(`line-height`,c+`px`);r.on(`mouseenter`,()=>{_.style(`font-weight`,`bold`)}).on(`mouseleave`,()=>{_.style(`font-weight`,e.bold?`bold`:`normal`)}),h.on(`mouseenter`,()=>{a.weight_mouseenter(e)}).on(`mouseleave`,()=>{a.weight_mouseleave(e)}),e.isFolder?r.on(`click`,function(e){let t=this.nextSibling,i=r.classed(`folder-closed`);for(i?(r.classed(`folder-closed`,!1),r.classed(`folder-open`,!0),g.attr(`class`,`row-icon `+a.folderIconOpen())):(r.classed(`folder-closed`,!0),r.classed(`folder-open`,!1),g.attr(`class`,`row-icon `+a.folderIconClosed()));t!==null;)(0,n.select)(t).datum().depth>e.depth?(t.style.display=i?`flex`:`none`,t=t.nextSibling):t=null}):r.on(`click`,()=>{t.selectAll(`.row-label`).style(`background-color`,`transparent`),t.selectAll(`.row-icon`).style(`background-color`,`transparent`),g.style(`background-color`,a.selectionBackgroundColor()),_.style(`background-color`,a.selectionBackgroundColor());let n=e.label.split(`.`).pop().toLowerCase();a.rowClick(n===`json`?JSON.stringify(JSON.parse(e.content),null,4):e.content,e.markers)})}).merge(l).style(`background-color`,a.backgroundColor()),l.exit().remove()}weight_mouseenter(e){}weight_mouseleave(e){}};DirectoryTree.prototype._class+=` tree_DirectoryTree`,DirectoryTree.prototype._palette=n.Palette.rainbow(`Blues`),DirectoryTree.prototype.publish(`depthSize`,14,`number`,`Width of indentation per file or folder depth (pixels)`),DirectoryTree.prototype.publish(`paletteID`,`Blues`,`set`,`Color palette for the weight backgrounds`,DirectoryTree.prototype._palette.switch(),{tags:[`Basic`]}),DirectoryTree.prototype.publish(`omitRoot`,!1,`boolean`,`If true, root node will not display`),DirectoryTree.prototype.publish(`rowItemPadding`,2,`number`,`Top, bottom, left and right row item padding`),DirectoryTree.prototype.publish(`selectionBackgroundColor`,`#CCC`,`html-color`,`Background color of selected directory rows`),DirectoryTree.prototype.publish(`backgroundColor`,`#FFF`,`html-color`,`Directory item background color`),DirectoryTree.prototype.publish(`fontColor`,`#000`,`html-color`,`Directory item font color`),DirectoryTree.prototype.publish(`fontFamily`,`Arial`,`string`,`Directory item font family`),DirectoryTree.prototype.publish(`fontSize`,12,`number`,`Directory item font size (pixels)`),DirectoryTree.prototype.publish(`iconSize`,12,`number`,`Directory folder and file icon size (pixels)`),DirectoryTree.prototype.publish(`folderIconOpen`,`fa fa-folder-open`,`string`,`Open folder icon class`),DirectoryTree.prototype.publish(`folderIconClosed`,`fa fa-folder`,`string`,`Closed folder icon class`),DirectoryTree.prototype.publish(`textFileIcon`,`fa fa-file-text-o`,`string`,`Text file icon class`),DirectoryTree.prototype.publish(`verticalScroll`,!0,`boolean`,`If true, vertical scroll bar will be shown`);var IndentedColumn=class extends n.PropertyExt{_owner;constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.column()}column};IndentedColumn.prototype._class+=` tree_Dendrogram.IndentedColumn`,IndentedColumn.prototype.publish(`column`,null,`set`,`Field`,function(){return this._owner?this._owner.columns():[]},{optional:!0});var Indented=class extends n.SVGZoomWidget{Column;_d3Tree;_xml;_svgLinks;_svgNodes;_treeData;_collapsed={};constructor(){super(),t.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this),this._drawStartPos=`origin`,this._d3Tree=tree_default()}xmlToData(e,t=``){return DOMParser?xmlToJson(new DOMParser().parseFromString(e,`text/xml`),t).children[0]:[]}xml(e){return arguments.length?(this._xml=e,this.data(this.xmlToData(this._xml)),this):this._xml}IndentedData(){if(this.data().length===0)return[];if(this.xmlColumn_exists()){let e=this.columns().indexOf(this.xmlColumn()),t={label:this.xmlColumn(),children:this.data().map(function(t,n){return this.xmlToData(t[e],`[`+n+`]`)},this)};return t.children.length===1?t.children[0]:t}else return this.mappings().filter(e=>e.valid()).length?formatData({key:`root`,values:this._db.rollupView(this.mappings().map(function(e){return e.column()})).entries()}):this.data();function formatData(e){if(e.values instanceof Array){let t=e.values.filter(function(e){return!(e instanceof Array)}).map(function(e){return formatData(e)}),n={label:e.key};return t.length?n.children=t:n.size=22,n}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(e,t){super.enter(e,t),this._svgLinks=this._renderElement.append(`g`),this._svgNodes=this._renderElement.append(`g`),this._selection.widgetElement(this._svgNodes)}_prevDataChecksum;update(e,t){super.update(e,t);let r=this;this._d3Tree.nodeSize([0,this.barHeight()]);let i=this._db.dataChecksum();this._prevDataChecksum!==i&&(this._treeData=this.IndentedData(),this._prevDataChecksum=i);function getID(e){return(e.parent?getID(e.parent)+`.`:``)+e.data.label}let a=hierarchy(this.data()).sum(function(e){return e.size||50}).each(e=>{this._collapsed[getID(e)]&&delete e.children}),o=this._d3Tree(a).descendants(),s=this._d3Tree(a).descendants().slice(1),c=0;a.eachBefore(e=>{e.x=c*r.barHeight(),++c});let l=this.barHeight()-4,u=this._renderCount?500:0,d=this._svgLinks.selectAll(`.link`).data(s,function(e){return getID(e)});d.enter().append(`path`).attr(`class`,`link`).attr(`d`,elbow),d.transition().duration(u).attr(`d`,elbow),d.exit().remove();function elbow(e){return`M`+e.parent.y+`,`+e.parent.x+`V`+e.x+`, H`+e.y}let f=this._svgNodes.selectAll(`.node`).data(o,function(e){return getID(e)});f.transition().duration(u).attr(`transform`,function(e){return`translate(`+e.y+`,`+e.x+`)`});let p=f.enter().append(`g`).attr(`class`,`node`).attr(`transform`,function(e){return`translate(`+e.y+`,`+e.x+`)`}).call(this._selection.enter.bind(this._selection)).each(function(){let e=(0,n.select)(this);e.append(`rect`).attr(`height`,l).attr(`width`,l).on(`click`,function(e){r._collapsed[getID(e)]?delete r._collapsed[getID(e)]:e.children&&(r._collapsed[getID(e)]=!0),r.lazyRender()}),e.append(`text`)}).style(`opacity`,0);p.transition().style(`opacity`,1),p.merge(f).select(`rect`).attr(`x`,-l/2).attr(`y`,-l/2).style(`fill`,color),p.merge(f).select(`text`).attr(`dx`,l/2+4+`px`).attr(`dy`,`0.33em`).text(function(e){return e.data.label}),f.exit().transition().style(`opacity`,0).remove(),this._renderCount||r.zoomToFit();function color(e){return r._collapsed[getID(e)]?`#3182bd`:e.children?`#c6dbef`:`#fd8d3c`}}};Indented.prototype._class+=` tree_Indented`,Indented.prototype.implements(t.ITree.prototype),Indented.prototype.mixin(n.Utility.SimpleSelectionMixin),Indented.prototype.Column=IndentedColumn,Indented.prototype.publish(`xmlColumn`,null,`set`,`Field`,function(){return this.columns()},{optional:!0}),Indented.prototype.publish(`mappings`,[],`propertyArray`,`Source Columns`,null,{autoExpand:IndentedColumn,disable:e=>e.xmlColumn_exists()}),Indented.prototype.publish(`barHeight`,16,`number`,`Bar height`);function xmlToJson(e,t=``){let n={id:t,label:``,attributes:{},children:[]};if(n.label=e.nodeName,e.nodeType===1){if(e.attributes.length>0)for(let t=0;t<e.attributes.length;t++){let r=e.attributes.item(t);n.attributes[r.nodeName]=r.nodeValue}}else e.nodeType===3&&(n.label=e.nodeValue);if(e.hasChildNodes())for(let r=0;r<e.childNodes.length;r++){let i=xmlToJson(e.childNodes.item(r),t+`[`+n.children.length+`]`);n.children.push(i)}return n}var d=Math.PI,f=2*d,p=1e-6,m=f-p;function Path(){this._x0=this._y0=this._x1=this._y1=null,this._=``}function path(){return new Path}Path.prototype=path.prototype={constructor:Path,moveTo:function(e,t){this._+=`M`+(this._x0=this._x1=+e)+`,`+(this._y0=this._y1=+t)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)},lineTo:function(e,t){this._+=`L`+(this._x1=+e)+`,`+(this._y1=+t)},quadraticCurveTo:function(e,t,n,r){this._+=`Q`+ +e+`,`+ +t+`,`+(this._x1=+n)+`,`+(this._y1=+r)},bezierCurveTo:function(e,t,n,r,i,a){this._+=`C`+ +e+`,`+ +t+`,`+ +n+`,`+ +r+`,`+(this._x1=+i)+`,`+(this._y1=+a)},arcTo:function(e,t,n,r,i){e=+e,t=+t,n=+n,r=+r,i=+i;var a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,f=l*l+u*u;if(i<0)throw Error(`negative radius: `+i);if(this._x1===null)this._+=`M`+(this._x1=e)+`,`+(this._y1=t);else if(f>p)if(!(Math.abs(u*s-c*l)>p)||!i)this._+=`L`+(this._x1=e)+`,`+(this._y1=t);else{var m=n-a,h=r-o,g=s*s+c*c,_=m*m+h*h,v=Math.sqrt(g),y=Math.sqrt(f),b=i*Math.tan((d-Math.acos((g+f-_)/(2*v*y)))/2),x=b/y,S=b/v;Math.abs(x-1)>p&&(this._+=`L`+(e+x*l)+`,`+(t+x*u)),this._+=`A`+i+`,`+i+`,0,0,`+ +(u*m>l*h)+`,`+(this._x1=e+S*s)+`,`+(this._y1=t+S*c)}},arc:function(e,t,n,r,i,a){e=+e,t=+t,n=+n,a=!!a;var o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,h=a?r-i:i-r;if(n<0)throw Error(`negative radius: `+n);this._x1===null?this._+=`M`+c+`,`+l:(Math.abs(this._x1-c)>p||Math.abs(this._y1-l)>p)&&(this._+=`L`+c+`,`+l),n&&(h<0&&(h=h%f+f),h>m?this._+=`A`+n+`,`+n+`,0,1,`+u+`,`+(e-o)+`,`+(t-s)+`A`+n+`,`+n+`,0,1,`+u+`,`+(this._x1=c)+`,`+(this._y1=l):h>p&&(this._+=`A`+n+`,`+n+`,0,`+ +(h>=d)+`,`+u+`,`+(this._x1=e+n*Math.cos(i))+`,`+(this._y1=t+n*Math.sin(i))))},rect:function(e,t,n,r){this._+=`M`+(this._x0=this._x1=+e)+`,`+(this._y0=this._y1=+t)+`h`+ +n+`v`+ +r+`h`+-n+`Z`},toString:function(){return this._}};function constant_default(e){return function constant(){return e}}__name(constant_default,`default`);var h=Math.abs,g=Math.atan2,_=Math.cos,v=Math.max,y=Math.min,b=Math.sin,x=Math.sqrt,S=Math.PI,C=S/2,w=2*S;function acos(e){return e>1?0:e<-1?S:Math.acos(e)}function asin(e){return e>=1?C:e<=-1?-C:Math.asin(e)}function arcInnerRadius(e){return e.innerRadius}function arcOuterRadius(e){return e.outerRadius}function arcStartAngle(e){return e.startAngle}function arcEndAngle(e){return e.endAngle}function arcPadAngle(e){return e&&e.padAngle}function intersect(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function cornerTangents(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/x(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,y=m-f,b=h-p,S=y*y+b*b,C=i-a,w=f*h-m*p,T=(b<0?-1:1)*x(v(0,C*C*S-w*w)),E=(w*b-y*T)/S,D=(-w*y-b*T)/S,O=(w*b+y*T)/S,k=(-w*y+b*T)/S,A=E-g,j=D-_,M=O-g,N=k-_;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-u,y01:-d,x11:E*(i/C-1),y11:D*(i/C-1)}}function arc_default(){var e=arcInnerRadius,t=arcOuterRadius,n=constant_default(0),r=null,i=arcStartAngle,a=arcEndAngle,o=arcPadAngle,s=null;function arc(){var c,l,u=+e.apply(this,arguments),d=+t.apply(this,arguments),f=i.apply(this,arguments)-C,p=a.apply(this,arguments)-C,m=h(p-f),v=p>f;if(s||=c=path(),d<u&&(l=d,d=u,u=l),!(d>1e-12))s.moveTo(0,0);else if(m>w-1e-12)s.moveTo(d*_(f),d*b(f)),s.arc(0,0,d,f,p,!v),u>1e-12&&(s.moveTo(u*_(p),u*b(p)),s.arc(0,0,u,p,f,v));else{var T=f,E=p,D=f,O=p,k=m,A=m,j=o.apply(this,arguments)/2,M=j>1e-12&&(r?+r.apply(this,arguments):x(u*u+d*d)),N=y(h(d-u)/2,+n.apply(this,arguments)),P=N,F=N,I,L;if(M>1e-12){var R=asin(M/u*b(j)),z=asin(M/d*b(j));(k-=R*2)>1e-12?(R*=v?1:-1,D+=R,O-=R):(k=0,D=O=(f+p)/2),(A-=z*2)>1e-12?(z*=v?1:-1,T+=z,E-=z):(A=0,T=E=(f+p)/2)}var B=d*_(T),V=d*b(T),H=u*_(O),U=u*b(O);if(N>1e-12){var W=d*_(E),G=d*b(E),K=u*_(D),q=u*b(D),J;if(m<S&&(J=intersect(B,V,K,q,W,G,H,U))){var Y=B-J[0],X=V-J[1],Z=W-J[0],Q=G-J[1],$=1/b(acos((Y*Z+X*Q)/(x(Y*Y+X*X)*x(Z*Z+Q*Q)))/2),ee=x(J[0]*J[0]+J[1]*J[1]);P=y(N,(u-ee)/($-1)),F=y(N,(d-ee)/($+1))}}A>1e-12?F>1e-12?(I=cornerTangents(K,q,B,V,d,F,v),L=cornerTangents(W,G,H,U,d,F,v),s.moveTo(I.cx+I.x01,I.cy+I.y01),F<N?s.arc(I.cx,I.cy,F,g(I.y01,I.x01),g(L.y01,L.x01),!v):(s.arc(I.cx,I.cy,F,g(I.y01,I.x01),g(I.y11,I.x11),!v),s.arc(0,0,d,g(I.cy+I.y11,I.cx+I.x11),g(L.cy+L.y11,L.cx+L.x11),!v),s.arc(L.cx,L.cy,F,g(L.y11,L.x11),g(L.y01,L.x01),!v))):(s.moveTo(B,V),s.arc(0,0,d,T,E,!v)):s.moveTo(B,V),!(u>1e-12)||!(k>1e-12)?s.lineTo(H,U):P>1e-12?(I=cornerTangents(H,U,W,G,u,-P,v),L=cornerTangents(B,V,K,q,u,-P,v),s.lineTo(I.cx+I.x01,I.cy+I.y01),P<N?s.arc(I.cx,I.cy,P,g(I.y01,I.x01),g(L.y01,L.x01),!v):(s.arc(I.cx,I.cy,P,g(I.y01,I.x01),g(I.y11,I.x11),!v),s.arc(0,0,u,g(I.cy+I.y11,I.cx+I.x11),g(L.cy+L.y11,L.cx+L.x11),v),s.arc(L.cx,L.cy,P,g(L.y11,L.x11),g(L.y01,L.x01),!v))):s.arc(0,0,u,O,D,v)}if(s.closePath(),c)return s=null,c+``||null}return arc.centroid=function(){var n=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-S/2;return[_(r)*n,b(r)*n]},arc.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:constant_default(+t),arc):e},arc.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:constant_default(+e),arc):t},arc.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:constant_default(+e),arc):n},arc.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:constant_default(+e),arc):r},arc.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:constant_default(+e),arc):i},arc.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:constant_default(+e),arc):a},arc.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:constant_default(+e),arc):o},arc.context=function(e){return arguments.length?(s=e??null,arc):s},arc}__name(arc_default,`default`);var SunburstPartition=class extends n.SVGWidget{svg;radius;_xScale;_yScale;partition;arc;_resetRoot;constructor(){super(),t.ITree.call(this)}data(e){let t=n.SVGWidget.prototype.data.apply(this,arguments);return arguments.length&&(this._resetRoot=!0),t}enter(e,t){let r=this;this.radius=Math.min(this.width(),this.height())/2,this._xScale=(0,n.scaleLinear)().range([0,2*Math.PI]),this._yScale=(0,n.scaleSqrt)().range([0,this.radius]),this.partition=partition_default(),this.arc=arc_default().startAngle(function(e){return Math.max(0,Math.min(2*Math.PI,r._xScale(e.x0)))}).endAngle(function(e){return Math.max(0,Math.min(2*Math.PI,r._xScale(e.x1)))}).innerRadius(function(e){return Math.max(0,r._yScale(e.y0))}).outerRadius(function(e){return Math.max(0,r._yScale(e.y1))}),this.svg=t.append(`g`)}update(e,t){let 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]);let i=hierarchy(this.data()).sum(function(e){return e.size===void 0?1:e.size}),a=this.svg.selectAll(`path`).data(this.partition(i).descendants(),function(e,t){return e.data.label===void 0?t:e.data.label});a.enter().append(`path`).on(`click`,function(e){r.click(e.data,null,null)}).on(`dblclick`,function(e){let t=(0,n.d3Event)();t&&t.stopPropagation(),r.zoomTo(e)}).each(function(){(0,n.select)(this).append(`title`)}).merge(a).attr(`d`,this.arc).style(`fill`,function(e){return e.data.__viz_fill?e.data.__viz_fill:r._palette(e.data.label)}).style(`stroke`,function(e){return e.value>16?`white`:`none`}).select(`title`).text(function(e){return e.data.label}),a.exit().remove(),this._resetRoot&&(this._resetRoot=!1,this.zoomTo(i))}zoomTo(e){let t=this;this.svg.transition().duration(750).tween(`scale`,function(){let r=(0,n.interpolate)(t._xScale.domain(),[e.x0,e.x1]),i=(0,n.interpolate)(t._yScale.domain(),[e.y0,1]),a=(0,n.interpolate)(t._yScale.range(),[e.y0?20:0,t.radius]);return function(e){t._xScale.domain(r(e)),t._yScale.domain(i(e)).range(a(e))}}).selectAll(`path`).attrTween(`d`,function(e){return function(){return t.arc(e)}})}};SunburstPartition.prototype._class+=` tree_SunburstPartition`,SunburstPartition.prototype.implements(t.ITree.prototype),SunburstPartition.prototype.publish(`paletteID`,`default`,`set`,`Color palette for this widget`,SunburstPartition.prototype._palette.switch(),{tags:[`Basic`,`Shared`]}),SunburstPartition.prototype.publish(`useClonedPalette`,!1,`boolean`,`Enable or disable using a cloned palette`,null,{tags:[`Intermediate`,`Shared`]});var TreemapColumn=class extends n.PropertyExt{_owner;constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.column()}column};TreemapColumn.prototype._class+=` tree_Dendrogram.TreemapColumn`,TreemapColumn.prototype.publish(`column`,null,`set`,`Field`,function(){return this._owner?this._owner.columns():[]},{optional:!0});var Treemap=class extends n.HTMLWidget{Column;_d3Treemap;_elementDIV;_selection;constructor(){super(),t.ITree.call(this),n.Utility.SimpleSelectionMixin.call(this,!0)}getTilingMethod(){switch(this.tilingMethod()){case`treemapBinary`:return binary_default;case`treemapDice`:return dice_default;case`treemapSlice`:return slice_default;case`treemapSliceDice`:return sliceDice_default;case`treemapResquarify`:return u;default:return l}}treemapData(){if(!this.mappings().filter(e=>e.valid()).length)return this.data();return formatData({key:`root`,values:this._db.aggregateView(this.mappings().map(function(e){return e.column()}),this.aggrType(),this.aggrColumn()).entries()});function formatData(e){if(e.values instanceof Array){let t=e.values.filter(function(e){return!(e instanceof Array)}).map(function(e){return formatData(e)}),n={label:e.key};return t.length?n.children=t:n.size=22,n}return{label:e.key,size:e.values.aggregate,origRows:e.values}}}enter(e,t){super.enter(e,t),this._d3Treemap=treemap_default(),this._elementDIV=t.append(`div`),this._selection.widgetElement(this._elementDIV)}update(e,t){super.update(e,t);let r=this;this._palette=this._palette.switch(this.paletteID()),this.useClonedPalette()&&(this._palette=this._palette.cloneNotExists(this.paletteID()+`_`+this.id()));let i=hierarchy(this.treemapData()).sum(this.nodeWeight);this._d3Treemap.size([this.width(),this.height()]).paddingInner(this.paddingInner()).paddingOuter(this.paddingOuter()).paddingTop(this.paddingTop()),[`treemapSquarify`,`treemapResquarify`].indexOf(this.tilingMethod())===-1?this._d3Treemap.tile(this.getTilingMethod()):this._d3Treemap.tile(this.getTilingMethod().ratio(this.squarifyRatio())),this._d3Treemap(i),this._elementDIV.style(`font-size`,this.fontSize_exists()?this.fontSize()+`px`:null).style(`line-height`,this.fontSize_exists()?this.fontSize()+2+`px`:null);let a=this._elementDIV.selectAll(`.node`).data(i.descendants());a.enter().append(`div`).attr(`class`,`node`).call(this._selection.enter.bind(this._selection)).on(`click`,function(e){if(e){let t=``;r.mappings().forEach(function(e){e.column()&&(t=e.column())}),e.origRows?r.click(r.rowToObj(e.origRows[0]),t,r._selection.selected(this)):r.click(e.data,t,r._selection.selected(this))}}).on(`dblclick`,function(e){if(e){let t=``;r.mappings().forEach(function(e){e.column()&&(t=e.column())}),e.origRows?r.dblclick(r.rowToObj(e.origRows[0]),t,r._selection.selected(this)):r.dblclick(e.data,t,r._selection.selected(this))}}).merge(a).style(`left`,function(e){return e.x0+Math.max(0,e.x1-e.x0)/2+`px`}).style(`top`,function(e){return e.y0+Math.max(0,e.y1-e.y0)/2+`px`}).style(`width`,function(){return`0px`}).style(`height`,function(){return`0px`}).style(`font-size`,function(e){return(e.children?r.parentFontSize():r.leafFontSize())+`px`}).style(`line-height`,function(e){return(e.children?r.parentFontSize():r.leafFontSize())+`px`}).attr(`title`,tooltip).html(function(e){return!r.showRoot()&&e.depth===0?null:e.children?r.enableParentLabels()?r.parentWeightHTML(e):null:r.leafWeightHTML(e)}).style(`background`,function(e){if(!r.showRoot()&&e.depth===0)return this.style.color=`transparent`,`transparent`;let t=r.brighterLeafNodes()?`brighter`:`darker`,i;return r.usePaletteOnParentNodes()?i=e.children?r._palette(e.data.label):(0,n.rgb)(r._palette(e.parent.data.label))[t](1):(i=e.depth>r.depthColorLimit()?(0,n.rgb)(e.parent.color)[t](1):r._palette(e.data.label),e.color=i),this.style.color=n.Palette.textColor(i),i}).transition().duration(this.transitionDuration()).style(`pointer-events`,function(e){return!r.showRoot()&&e.depth===0?`none`:`all`}).style(`opacity`,function(e){return e.children?1:null}).style(`left`,function(e){return e.x0+`px`}).style(`top`,function(e){return e.y0+`px`}).style(`width`,function(e){return Math.max(0,e.x1-e.x0)+`px`}).style(`height`,function(e){return Math.max(0,e.y1-e.y0)+`px`}).each(function(e){e.depth===0&&(this.style.color=r.showRoot()?``:`transparent`,this.style.borderColor=r.showRoot()?``:`transparent`)}),a.exit().transition().duration(this.transitionDuration()).style(`opacity`,0).remove();function tooltip(e){if(e.children&&!r.enableParentTooltips())return null;let t=e.data.label+` (`+e.value+`)`;for(;e.parent&&e.parent.parent;)t=e.parent.data.label+` -> `+t,e=e.parent;return t}}exit(e,t){super.exit(e,t)}nodeWeight(e){return e.size||1}parentWeightHTML(e){return this.showParentWeight()?`<span class="treemap-parent-label">${e.data.label}</span><span class="treemap-parent-value">${e.value}${this.weightSuffix()}</span>`:`<span class="treemap-parent-label">${e.data.label}</span>`}leafWeightHTML(e){return this.showLeafWeight()?`<span class="treemap-leaf-label">${e.data.label}</span><span class="treemap-leaf-value">${e.value}${this.weightSuffix()}</span>`:`<span class="treemap-leaf-label">${e.data.label}</span>`}};Treemap.prototype._class+=` tree_Treemap`,Treemap.prototype.implements(t.ITree.prototype),Treemap.prototype.mixin(n.Utility.SimpleSelectionMixin),Treemap.prototype.Column=TreemapColumn,Treemap.prototype.publish(`paletteID`,`default`,`set`,`Color palette for this widget`,Treemap.prototype._palette.switch(),{tags:[`Basic`,`Shared`]}),Treemap.prototype.publish(`useClonedPalette`,!1,`boolean`,`Enable or disable using a cloned palette`,null,{tags:[`Intermediate`,`Shared`]}),Treemap.prototype.publish(`mappings`,[],`propertyArray`,`Source Columns`,null,{autoExpand:TreemapColumn}),Treemap.prototype.publish(`aggrType`,null,`set`,`Aggregation Type`,[null,`mean`,`median`,`sum`,`min`,`max`],{optional:!0}),Treemap.prototype.publish(`aggrColumn`,null,`set`,`Aggregation Field`,function(){return this.columns()},{optional:!0,disable:e=>!e.aggrType()}),Treemap.prototype.publish(`fontSize`,null,`number`,`Font Size`,null,{optional:!0}),Treemap.prototype.publish(`paddingInner`,18.6,`number`,`Pixel spacing between each sibling node`),Treemap.prototype.publish(`paddingOuter`,30,`number`,`Pixel padding of parent nodes`),Treemap.prototype.publish(`paddingTop`,41.4,`number`,`Additional top pixel padding of parent nodes`),Treemap.prototype.publish(`showRoot`,!1,`boolean`,`Show root element`),Treemap.prototype.publish(`parentFontSize`,18,`number`,`Parent font-size`),Treemap.prototype.publish(`leafFontSize`,16,`number`,`Leaf font-size`),Treemap.prototype.publish(`usePaletteOnParentNodes`,!1,`boolean`,`Assign a color from the palette to every parent node`),Treemap.prototype.publish(`depthColorLimit`,1,`number`,`Assign a color from the palette to node with depth lower than this value`,null,{optional:!0,disable:e=>e.usePaletteOnParentNodes()}),Treemap.prototype.publish(`squarifyRatio`,1,`number`,`Specifies the desired aspect ratio of the generated rectangles (must be >= 1)`,null,{optional:!0,disable:e=>[`treemapSquarify`,`treemapResquarify`].indexOf(e.tilingMethod())===-1}),Treemap.prototype.publish(`showParentWeight`,!0,`boolean`,`Show weight of parent nodes`),Treemap.prototype.publish(`showLeafWeight`,!0,`boolean`,`Show weight of leaf nodes`),Treemap.prototype.publish(`weightSuffix`,``,`string`,`Weight suffix (ex: 'ms')`),Treemap.prototype.publish(`brighterLeafNodes`,!1,`boolean`,`Brighter/darker leaf node color (false = darker)`),Treemap.prototype.publish(`enableParentLabels`,!0,`boolean`,`Enable parent labels`),Treemap.prototype.publish(`enableParentTooltips`,!0,`boolean`,`Enable parent tooltips`),Treemap.prototype.publish(`transitionDuration`,250,`number`,`Transition Duration`),Treemap.prototype.publish(`tilingMethod`,`treemapSquarify`,`set`,`Transition Duration`,[`treemapBinary`,`treemapDice`,`treemapResquarify`,`treemapSlice`,`treemapSliceDice`,`treemapSquarify`]),e.BUILD_VERSION=o,e.CirclePacking=CirclePacking,e.Dendrogram=Dendrogram,e.DendrogramColumn=DendrogramColumn,e.DirectoryTree=DirectoryTree,e.Indented=Indented,e.IndentedColumn=IndentedColumn,e.PKG_NAME=i,e.PKG_VERSION=a,e.SunburstPartition=SunburstPartition,e.Treemap=Treemap,e.TreemapColumn=TreemapColumn});
2
2
  //# sourceMappingURL=index.umd.cjs.map
3
3
  (function(){try{if(typeof document<`u`){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{pointer-events:none;font:10px sans-serif}.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{text-overflow:ellipsis;border:1px solid #333;position:absolute;overflow:hidden}.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{margin:4px 4px 0;font-weight:700;display:inline-block}.tree_Treemap .node>span.treemap-parent-value{margin:4px 0 0;font-style:italic;font-weight:400}.tree_Treemap .node>span.treemap-singleton-label{margin:4px 0 0 4px;font-weight:400;display:block}.tree_Treemap .node>span.treemap-singleton-value{margin:0 0 0 4px;font-style:italic;display:block}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();