/*
    *
    * Wijmo Library 5.20181.462
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
"use strict";var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function i(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wjcChart=require("wijmo/wijmo.chart"),wjcCore=require("wijmo/wijmo"),wjcSelfRef=require("wijmo/wijmo.chart.hierarchical"),wjcSelf=wjcSelfRef||exports;window.wijmo=window.wijmo||{},window.wijmo.chart=window.wijmo.chart||{},window.wijmo.chart.hierarchical=wjcSelf;var Sunburst=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i._selectionIndex=0,i.applyTemplate("wj-sunburst",null,null),i.initialize(r),i.refresh(),i}return __extends(e,t),Object.defineProperty(e.prototype,"bindingName",{get:function(){return this._bindName},set:function(t){t!=this._bindName&&(wjcCore.assert(null==t||wjcCore.isArray(t)||wjcCore.isString(t),"bindingName should be an array or a string."),this._bindName=t,this._bindChart())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(t){t!=this._childItemsPath&&(wjcCore.assert(null==t||wjcCore.isArray(t)||wjcCore.isString(t),"childItemsPath should be an array or a string."),this._childItemsPath=t,this._bindChart())},enumerable:!0,configurable:!0}),e.prototype._initData=function(){t.prototype._initData.call(this),this._processedData=[],this._level=1,this._legendLabels=[],this._processedItem=[]},e.prototype._performBind=function(){var t,e=this;this._initData(),this._cv&&(t=this._cv.items,this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):t&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(t,this.binding,this.bindingName,this.childItemsPath)),this._processedData&&this._processedData.length&&(this._sum=this._calculateValueAndLevel(this._processedData,1),this._processedData.forEach(function(t){e._legendLabels.push(t.name)})))},e.prototype._calculateValueAndLevel=function(t,e){var r=this,i=0,o=this._values,a=this._labels;return this._level<e&&(this._level=e),t.forEach(function(t){var n;t.items?(n=r._calculateValueAndLevel(t.items,e+1),t.value=n,o.push(n),a.push(t.name)):(n=r._getBindData(t,o,a,"value","name"),t.value=n),i+=n}),i},e.prototype._renderPie=function(t,e,r,i,o){var a=this._getCenter();this._sliceIndex=0,this._renderHierarchicalSlices(t,a.x,a.y,this._processedData,this._sum,e,r,i,2*Math.PI,o,1)},e.prototype._renderHierarchicalSlices=function(t,e,r,i,o,a,n,l,s,h,c){var u,p,_,d,m,f,w,C,g,v,b=i.length,y=l,j=1==this.reversed;_=(a-n)/this._level,u=a-(this._level-c)*_,p=n+(c-1)*_;for(var I=0;I<b;I++)C=e,g=r,w=t.startGroup("wj-slice slice-level"+c),1===c&&(t.fill=this._getColorLight(I),t.stroke=this._getColor(I)),m=i[I],f=Math.abs(m.value),d=Math.abs(f-o)<1e-10?s:s*f/o,v=j?y-.5*d:y+.5*d,h>0&&d<s&&(C+=h*Math.cos(v),g+=h*Math.sin(v)),m.items&&this._renderHierarchicalSlices(t,C,g,m.items,f,a,n,y,d,0,c+1),this._renderSlice(t,C,g,v,this._sliceIndex,u,p,y,d,s),this._processedItem.push(m.item),this._sliceIndex++,j?y-=d:y+=d,t.endGroup(),this._pels.push(w)},e.prototype._getLabelsForLegend=function(){return this._legendLabels||[]},e.prototype._highlightCurrent=function(){this.selectionMode!=wjcChart.SelectionMode.None&&this._highlight(!0,this._selectionIndex)},e.prototype.hitTest=function(e,r){var i=t.prototype.hitTest.call(this,e,r),o=this._toControl(e,r);if(wjcChart.FlexChart._contains(this._rectChart,o)){var a=i.pointIndex,n=this._processedItem[a],l=new wjcChart._DataPoint(null,a,null,null);l.item=n,i._setDataPoint(l)}return i},e}(wjcChart.FlexPie);exports.Sunburst=Sunburst;var TreeMapType;!function(t){t[t.Squarified=0]="Squarified",t[t.Horizontal=1]="Horizontal",t[t.Vertical=2]="Vertical"}(TreeMapType=exports.TreeMapType||(exports.TreeMapType={}));var TreeMap=function(t){function e(e,r){var i=t.call(this,e,null,!0)||this;return i._values=[],i._labels=[],i._areas=[],i._sum=0,i._keywords=new wjcChart._KeyWords,i._processedData=[],i._depth=1,i._itemIndex=0,i._processedItem=[],i._maxDepth=-1,i._tmItems=[],i._colRowLens=[],i._defPalette=[{titleColor:"#033884",maxColor:"#1450a7",minColor:"#83b3f9"},{titleColor:"#a83100",maxColor:"#dc4a0d",minColor:"#ffb190"},{titleColor:"#006658",maxColor:"#008d7a",minColor:"#7deddf"},{titleColor:"#a10046",maxColor:"#df0061",minColor:"#ff8cbe"},{titleColor:"#784d08",maxColor:"#99681a",minColor:"#efc989"},{titleColor:"#54156f",maxColor:"#722a90",minColor:"#cf95e7"},{titleColor:"#998605",maxColor:"#c2ac19",minColor:"#ffef8b"},{titleColor:"#9a0005",maxColor:"#c80c14",minColor:"#ff888d"}],i.applyTemplate("wj-control wj-flexchart wj-treemap",null,null),i._currentRenderEngine=new wjcChart._SvgRenderEngine(i.hostElement),i._legend=new wjcChart.Legend(i),i._legend.position=wjcChart.Position.None,i._tooltip=new wjcChart.ChartTooltip,i._tooltip.content="<b>{name}</b><br/>{value}",i._tooltip.showDelay=0,i._lbl=new wjcChart.DataLabel,i._lbl.position=wjcChart.LabelPosition.Center,i._lbl._chart=i,i.hostElement.addEventListener("mousemove",function(t){i.isTouching||i._toogleTooltip(t)}),i.hostElement.addEventListener("click",function(t){var e=!0;if(i.maxDepth>0){var r=i.hitTest(t),o=wjcChart.FlexChart._SELECTION_THRESHOLD;if(i.tooltip&&i.tooltip.threshold&&(o=i.tooltip.threshold),r.distance<=o&&r.pointIndex>=-1&&r.pointIndex<i._areas.length){var a=i._areas[r.pointIndex];i._currentItem!=a.item&&(i._currentItem=a.item,i._refreshChart(),e=!1)}}e&&i.isTouching&&i._toogleTooltip(t)}),i.hostElement.addEventListener("contextmenu",function(t){if(i.maxDepth>0){var e=i.hitTest(t),r=wjcChart.FlexChart._SELECTION_THRESHOLD;i.tooltip&&i.tooltip.threshold&&(r=i.tooltip.threshold),e.distance<=r&&i._rollUp()}return t.preventDefault(),!1}),i.hostElement.addEventListener("mouseleave",function(){i._hideToolTip()}),i.initialize(r),i.refresh(),i}return __extends(e,t),e.prototype._rollUp=function(){this._currentItem=this._currentItem&&this._currentItem.parent?this._currentItem.parent:null,this._refreshChart()},e.prototype._toogleTooltip=function(t){var e=this._tooltip;if(e.content){var r=this.hitTest(t);if(r.distance<=e.threshold){var i=this._getLabelContent(r,this.tooltip.content);this._showToolTip(i,new wjcCore.Rect(t.clientX,t.clientY,5,5))}else this._hideToolTip()}},Object.defineProperty(e.prototype,"selectionMode",{get:function(){return wjcChart.SelectionMode.None},set:function(t){},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_treeMapItems",{get:function(){return this._tmItems},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tooltip",{get:function(){return this._tooltip},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binding",{get:function(){return this._binding},set:function(t){t!=this._binding&&(this._binding=wjcCore.asString(t,!0),this._bindChart())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return null==this._type?TreeMapType.Squarified:this._type},set:function(t){(t=wjcCore.asEnum(t,TreeMapType))!=this._type&&(this._type=t,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bindingName",{get:function(){return this._bindingName},set:function(t){t!=this._bindingName&&(wjcCore.assert(null==t||wjcCore.isArray(t)||wjcCore.isString(t),"bindingName should be an array or a string."),this._bindingName=t,this._bindChart())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataLabel",{get:function(){return this._lbl},set:function(t){t!=this._lbl&&(this._lbl=t,this._lbl&&(this._lbl._chart=this))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(t){t!=this._childItemsPath&&(wjcCore.assert(null==t||wjcCore.isArray(t)||wjcCore.isString(t),"childItemsPath should be an array or a string."),this._childItemsPath=t,this._bindChart())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxDepth",{get:function(){return this._maxDepth},set:function(t){t!=this._maxDepth&&(this._maxDepth=wjcCore.asNumber(t,!0),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"palette",{get:function(){return this._palette},set:function(t){t!=this._palette&&(this._palette=wjcCore.asArray(t),this._tmItems&&this._tmItems.length>0&&this._calculateColorForItems(this._tmItems),this.invalidate())},enumerable:!0,configurable:!0}),e.prototype._initData=function(){this._sum=0,this._tmItems=[],this._currentItem=null,this._values=[],this._labels=[],this._processedData=[],this._depth=1,this._processedItem=[]},e.prototype._performBind=function(){var t;this._initData(),this._cv&&(t=this._cv.items,this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):t&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(t,this.binding,this.bindingName,this.childItemsPath)),this._processedData&&this._processedData.length&&(this._sum=this._calculateValueAndDepth(this._processedData,1),this._sortData(this._processedData),this._values=[],this._getTMItemsAndLabelsAndValues(this._processedData,this._tmItems,1,null),this._calculateColorForItems(this._tmItems)))},e.prototype._sortData=function(t){var e=this;t.forEach(function(t){t.items&&e._sortData(t.items)}),t.sort(function(t,e){return e.value-t.value})},e.prototype._getTMItemsAndLabelsAndValues=function(t,e,r,i,o){var a=this;t&&t.length>0&&t.forEach(function(t,o){var n,l=new _TreeMapItem;l.items=[],l.parent=i,l.depth=r,t.items&&a._getTMItemsAndLabelsAndValues(t.items,l.items,r+1,l),n=t.name?t.name:t.value.toString(),l.label=n,l.value=t.value,null!=i&&(t.value>i.maxValue&&(i.maxValue=t.value),t.value<i.minValue&&(i.minValue=t.value)),e.push(l),a._labels.push(n),a._values.push(t.value)})},e.prototype._calculateColorForItems=function(t,e,r){var i=this,o=r;t.forEach(function(t,r){var a=e;1===t.depth&&(a=i._getColor(r)),t.palette=a;var n=t.palette;if(wjcCore.isString(n)){var l=n,s=i._getLightColor(l);t.titleFill=l,t.titleStroke=l,t.fill=s,t.stroke=l}else if(n.maxColor&&n.minColor&&n.titleColor)if(t.titleFill=n.titleColor,t.titleStroke=n.titleColor,null==t.parent)t.fill=n.maxColor,t.stroke=n.maxColor;else{null==o&&(o=new _ColorConverter(n.minColor,t.minValue,n.maxColor,t.maxValue));var h=o._calculateColorByVal(t.value,!0).toString();t.fill=h,t.stroke=h}if(t.items&&t.items.length>0){var c=new _ColorConverter(n.minColor,t.minValue,n.maxColor,t.maxValue);i._calculateColorForItems(t.items,a,c)}})},e.prototype._getBindData=function(t,e,r){var i,o=0;r&&(i=t[r]);o=0;return wjcCore.isNumber(i)?o=wjcCore.asNumber(i):i&&(o=parseFloat(i.toString())),!isNaN(o)&&isFinite(o)?e.push(o):(o=0,e.push(o)),o},e.prototype._calculateValueAndDepth=function(t,e){var r=this,i=0,o=this._values;return this._depth<e&&(this._depth=e),t.forEach(function(t){var a;t.items?(a=r._calculateValueAndDepth(t.items,e+1),t.value=a,o.push(a)):(a=r._getBindData(t,o,"value"),t.value=a),i+=a}),i},e.prototype._prepareRender=function(){this._areas=[]},e.prototype._renderChart=function(t,r,i){var o,a,n,l=this._rectChart.clone();new wjcCore.Size(l.width,l.height);this.onRendering(new wjcChart.RenderEventArgs(t));var s=r.width,h=r.height;this._tmGroup=t.startGroup(null,null,!0);var c=this._parseMargin(this.plotMargin);this.dataLabel;isNaN(c.left)&&(c.left=e._MARGIN),isNaN(c.right)&&(c.right=e._MARGIN),isNaN(c.top)&&(c.top=e._MARGIN),isNaN(c.bottom)&&(c.bottom=e._MARGIN),r.top+=c.top;h=r.height-(c.top+c.bottom);r.height=h>0?h:24,r.left+=c.left;s=r.width-(c.left+c.right);r.width=s>0?s:24,this._plotRect=r,o=this._currentItem?[this._currentItem]:this._tmItems,a=null==this._currentItem||this.maxDepth<1?this.maxDepth:this._currentItem&&this._currentItem.items&&this._currentItem.items.length&&this.maxDepth>1?this.maxDepth:this.maxDepth+1,n=this._currentItem?this._currentItem.value:this._sum,this._renderTreeMap(t,r,this._tmGroup,o,n,a),t.endGroup(),this.dataLabel.content&&this.dataLabel.position!=wjcChart.LabelPosition.None&&this._renderLabels(t),this.onRendered(new wjcChart.RenderEventArgs(t))},e.prototype._renderTreeMap=function(t,e,r,i,o,a){o>0&&(this._itemIndex=0,this._resetItemRects(this._tmItems),this._calculateItemRects(e,i,o,1,a),this._renderHierarchicalTreeMapItems(t,r,e,this._tmItems,o,1,a))},e.prototype._resetItemRects=function(t){var e=this;t.forEach(function(t){t.rect=new wjcCore.Rect(0,0,0,0),t.isTitle=!1,t.type=e.type,t.items&&t.items.length&&e._resetItemRects(t.items)})},e.prototype._calculateItemRects=function(t,e,r,i,o){var a=this;switch(this.type){case TreeMapType.Horizontal:_TreeMapUtils.horizontal(e,t,r);break;case TreeMapType.Vertical:_TreeMapUtils.vertical(e,t,r);break;case TreeMapType.Squarified:_TreeMapUtils.squarified(e,t,r)}e.forEach(function(t,e){t.rect.clone();t.items&&t.items.length&&(i===o||i>o&&o>=1||(t.isTitle=!0,a._calculateItemRects(t.itemsRect,t.items,t.value,i+1,o)))})},e.prototype._renderHierarchicalTreeMapItems=function(t,r,i,o,a,n,l){var s,h,c,u,p,_=o.length;this.type;if(0!==_)for(var d=0;d<_;d++)s=t.startGroup(e._CSS_ITEMDEPTH+n),h=o[d],c=Math.abs(h.value),u=h.rect,h.draw(t),p=new wjcChart._RectArea(u),h.items&&this._renderHierarchicalTreeMapItems(t,s,h.itemsRect,h.items,c,n+1,l),p.tag=this._itemIndex,p.name=h.label,p.value=c,p.item=h,this._areas.push(p),this._itemIndex++,t.endGroup()},e.prototype._renderLabels=function(t){var e,r=this._areas.length,i=this.dataLabel,o=i.position,a=i.connectingLine,n=i.border,l=i.offset||0;t.stroke="null",t.fill="transparent",t.strokeWidth=1,t.startGroup("wj-data-labels");for(var s=0;s<r;s++){var h=this._areas[s];if(h){var c=h.rect,u=new wjcChart.HitTestInfo(this,e);u._setData(null,s);var p=this._getLabelContent(u,i.content);if(e=new wjcCore.Point(c.left+c.width/2,c.top+c.height/2),p&&c.width>0&&c.height>0){var _=new wjcChart.DataLabelRenderEventArgs(t,u,e,p);i.onRendering(_)&&(p=_.text,e=_.point,this._renderLabelAndBorder(t,h,c,p,o,l,e,a,2,n))}}}t.endGroup()},e.prototype._renderLabelAndBorder=function(t,e,r,i,o,a,n,l,s,h){var c,u="wj-data-label",p="wj-data-label-line";switch(o){case wjcChart.LabelPosition.Top:l&&t.drawLine(n.x,n.y,n.x,n.y-a,p),n.y-=s+a,c=this._renderText(t,e,r,i,n,1,2,u);break;case wjcChart.LabelPosition.Bottom:l&&t.drawLine(n.x,n.y,n.x,n.y+a,p),n.y+=s+a,c=this._renderText(t,e,r,i,n,1,0,u);break;case wjcChart.LabelPosition.Left:l&&t.drawLine(n.x,n.y,n.x-a,n.y,p),n.x-=s+a,c=this._renderText(t,e,r,i,n,2,1,u);break;case wjcChart.LabelPosition.Right:l&&t.drawLine(n.x,n.y,n.x+a,n.y,p),n.x+=s+a,c=this._renderText(t,e,r,i,n,0,1,u);break;case wjcChart.LabelPosition.Center:c=this._renderText(t,e,r,i,n,1,1,u)}return h&&c&&t.drawRect(c.left-s,c.top-s,c.width+2*s,c.height+2*s,"wj-data-label-border"),c},e.prototype._renderText=function(t,e,r,i,o,a,n,l){var s,h=i,c=e.item;return s=t.measureString(i,l),this.type===TreeMapType.Horizontal&&c.isTitle?(s.width>r.height&&(h=this._cutText(i,s.width,r.height)),wjcChart.FlexChart._renderRotatedText(t,h,o,a,n,o,-90,l),null):(s.width>r.width&&(h=this._cutText(i,s.width,r.width)),wjcChart.FlexChart._renderText(t,h,o,a,n,l))},e.prototype._cutText=function(t,e,r){var i="",o=t.length,a=Math.floor((1-(e-r)/e)*o);return t.length>0&&(i=t[0]+(a>1?t.substring(1,a-1)+"..":"")),i},e.prototype._measureLegendItem=function(t,e){var r=new wjcCore.Size;if(r.width=wjcChart.Series._LEGEND_ITEM_WIDTH,r.height=wjcChart.Series._LEGEND_ITEM_HEIGHT,e){var i=t.measureString(e,wjcChart.FlexChart._CSS_LABEL,wjcChart.FlexChart._CSS_LEGEND);r.width+=i.width,r.height<i.height&&(r.height=i.height)}return r.width+=3*wjcChart.Series._LEGEND_ITEM_MARGIN,r.height+=2*wjcChart.Series._LEGEND_ITEM_MARGIN,r},e.prototype._getDesiredLegendSize=function(t,e,r,i){var o=new wjcCore.Size,a=new wjcCore.Size(r,i),n=this._tmItems.length,l=0,s=0;this._colRowLens=[];for(var h=0;h<n;h++){var c=this._measureLegendItem(t,this._tmItems[h].label);e?(s+c.height>i&&(o.height=i,this._colRowLens.push(l),l=0,s=0),l<c.width&&(l=c.width),s+=c.height):(l+c.width>r&&(o.width=r,this._colRowLens.push(s),s=0,l=0),s<c.height&&(s=c.height),l+=c.width)}return e?(o.height<s&&(o.height=s),this._colRowLens.push(l),o.width=this._colRowLens.reduce(function(t,e){return t+e},0),o.width>a.width/2&&(o.width=a.width/2)):(o.width<l&&(o.width=l),this._colRowLens.push(s),o.height=this._colRowLens.reduce(function(t,e){return t+e},0),o.height>a.height/2&&(o.height=a.height/2)),o},e.prototype._renderLegend=function(t,e,r,i,o,a){for(var n,l=this._rectLegend,s=this._tmItems.length,h=0,c=e.clone(),u=0;u<s;u++){n=this._tmItems[u].label;var p=this._measureLegendItem(t,n);i?c.y+p.height>l.top+l.height+1&&(c.x+=this._colRowLens[h],h++,c.y=e.y):c.x+p.width>l.left+l.width+1&&(c.y+=this._colRowLens[h],h++,c.x=e.x);var _=new wjcCore.Rect(c.x,c.y,p.width,p.height);this._drawLegendItem(t,_,u,n),r.push(_),i?c.y+=p.height:c.x+=p.width}},e.prototype._drawLegendItem=function(t,e,r,i){t.strokeWidth=1;var o=wjcChart.Series._LEGEND_ITEM_MARGIN,a=this._getColor(r),n=a&&a.maxColor?a.maxColor:a,l=this._getLightColor(n);t.fill=n,t.stroke=l;var s=e.top+.5*e.height,h=wjcChart.Series._LEGEND_ITEM_WIDTH,c=wjcChart.Series._LEGEND_ITEM_HEIGHT;t.drawRect(e.left+o,s-.5*c,h,c,null),i&&wjcChart.FlexChart._renderText(t,i,new wjcCore.Point(e.left+c+2*o,s),0,1,wjcChart.FlexChart._CSS_LABEL)},e.prototype._getLabelContent=function(t,e){return wjcCore.isString(e)?this._keywords.replace(e,t):wjcCore.isFunction(e)?e(t):null},e.prototype.hitTest=function(t,e){var r=this._toControl(t,e),i=new wjcChart.HitTestInfo(this,r),o=null;if(wjcChart.FlexChart._contains(this._rectHeader,r))i._chartElement=wjcChart.ChartElement.Header;else if(wjcChart.FlexChart._contains(this._rectFooter,r))i._chartElement=wjcChart.ChartElement.Footer;else if(wjcChart.FlexChart._contains(this._rectLegend,r))i._chartElement=wjcChart.ChartElement.Legend,null!==(o=this.legend._hitTest(r))&&o>=0&&o<this._areas.length&&i._setData(null,o);else if(wjcChart.FlexChart._contains(this._rectChart,r)){for(var a,n=this._areas.length,l=NaN,s=0;s<n;s++){var h=r.clone(),c=this._areas[s];c.contains(h)&&(i._setData(null,c.tag),i._dist=0);var u=c.distance(h);void 0!==u&&(isNaN(l)||u<l)&&(l=u,a=c)}0!==i._dist&&null!=a&&(i._setData(null,a.tag),i._dist=l),i._chartElement=wjcChart.ChartElement.ChartArea}else i._chartElement=wjcChart.ChartElement.None;return i},e.prototype._getHitTestItem=function(t){var e=null,r=null;return(e=null!=this._cv?this._cv.items:this.itemsSource)&&t<e.length&&(r=e[t]),r},e.prototype._getHitTestValue=function(t){return this._values[t]},e.prototype._getHitTestLabel=function(t){return this._labels[t]},e._CSS_ITEMDEPTH="wj-treemap-item-depth",e._MARGIN=0,e}(wjcChart.FlexChartBase);exports.TreeMap=TreeMap;var _TreeMapItem=function(){function t(){this.items=[],this.maxValue=Number.MIN_VALUE,this.minValue=Number.MAX_VALUE}return t.prototype.draw=function(e){var r=this.rect;e.strokeWidth=0,this.isTitle?(e.fill=this.titleFill,e.stroke=this.titleStroke):(e.fill=this.fill,e.stroke=this.stroke),e.drawRect(r.left,r.top,r.width,r.height,t._CLASSNAME)},Object.defineProperty(t.prototype,"itemsRect",{get:function(){var t=this.rect,e=this._rect,r=1===this.depth?2:.5;return this.isTitle?this.type===TreeMapType.Horizontal?new wjcCore.Rect(t.left+t.width+1,t.top,e.width-t.width-2*r,t.height+1):new wjcCore.Rect(t.left,t.top+t.height+1,t.width+1,e.height-t.height-2*r):new wjcCore.Rect(0,0,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rect",{get:function(){var t=this._rect,e=1===this.depth?2:.5,r=t.width,i=t.height,o=t.left,a=t.top;return this.isTitle?(this.type===TreeMapType.Horizontal?(r=t.width>20?20:r,r=Math.max(20,r-2*e),i=i>2*e?i-2*e:0):(i=t.height>20?20:i,i=Math.max(20,i-2*e),r=r>2*e?r-2*e:0),o+=e,a+=e):(r=r>2*e?r-2*e:0,i=i>2*e?i-2*e:0),new wjcCore.Rect(o,a,r,i)},set:function(t){t!=this._rect&&(this._rect=t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isTitle",{get:function(){return this._isTitle},set:function(t){var e=wjcCore.asBoolean(t,!0);e!==this._isTitle&&(this._isTitle=e)},enumerable:!0,configurable:!0}),t._CLASSNAME="wj-treemap-item",t}(),_ColorConverter=function(){function t(t,e,r,i,o,a){this.minColor=new wjcCore.Color(t),this.minColorValue=e,this.maxColor=new wjcCore.Color(r),this.maxColorValue=i,this.midColorValue=this.originalMidColorValue=a,this._calculateMidColorValue(),this.midColor=this.originalMidColor=new wjcCore.Color(o),this._calculateMidColor()}return t.prototype._resetminColor=function(t){this.minColor=new wjcCore.Color(t),this._calculateMidColor()},t.prototype._resetmidColor=function(t){this.midColor=this.originalMidColor=new wjcCore.Color(t),this._calculateMidColor()},t.prototype._resetmaxColor=function(t){this.maxColor=new wjcCore.Color(t),this._calculateMidColor()},t.prototype._resetminColorValue=function(t){this.minColorValue=t,this._calculateMidColorValue()},t.prototype._resetmidColorValue=function(t){this.midColorValue=this.originalMidColorValue=t,this._calculateMidColorValue()},t.prototype._resetmaxColorValue=function(t){this.maxColorValue=t,this._calculateMidColorValue()},t.prototype._calculateMidColorValue=function(){null==this.originalMidColorValue&&(this.midColorValue=(this.maxColorValue+this.minColorValue)/2)},t.prototype._calculateMidColor=function(){null==this.originalMidColor&&(this.midColor=this._calculateColorByVal(this.midColorValue,!0))},t.prototype._calculateColorByVal=function(t,e){void 0===e&&(e=!1);var r=this.maxColor,i=this.minColor,o=this.maxColorValue,a=this.minColorValue;if(t>=this.maxColorValue)return new wjcCore.Color(r.toString());if(t<=this.minColorValue)return new wjcCore.Color(i.toString());if(!e){if(t===this.midColorValue)return new wjcCore.Color(this.midColor.toString());t<this.midColorValue?(r=this.midColor,o=this.midColorValue):(i=this.midColor,a=this.midColorValue)}return this._getColor(t,r,o,i,a)},t.prototype._getColor=function(t,e,r,i,o){return wjcCore.Color.fromRgba(this._getValueByRatio(t,e.r,r,i.r,o),this._getValueByRatio(t,e.g,r,i.g,o),this._getValueByRatio(t,e.b,r,i.b,o),this._getValueByRatio(t,e.a,r,i.a,o))},t.prototype._getValueByRatio=function(t,e,r,i,o){return Math.abs(i+Math.round((t-o)*(e-i)/(r-o)))},t}(),_TreeMapUtils=function(){function t(){}return t.squarified=function(e,r,i){var o=e.slice(),a=r.clone(),n=a.width*a.height/i;do{var l=t.getRowedItems(o,a,n);t.layoutRowedItems(r,l,a,a.width>a.height)}while(o.length)},t.horizontal=function(e,r,i){var o=r.clone();e.forEach(function(e){var a=[{item:e,val:e.value*r.width*r.height/i}];t.layoutRowedItems(r,a,o,!1)})},t.vertical=function(e,r,i){var o=r.clone();e.forEach(function(e){var a=[{item:e,val:e.value*r.width*r.height/i}];t.layoutRowedItems(r,a,o,!0)})},t.getNarrowLen=function(t){return Math.min(t.width,t.height)},t.getRowedItem=function(t,e,r){return{item:t,val:r*t.value}},t.getRowedItems=function(e,r,i){var o=e.shift(),a=[],n=[],l=t.getNarrowLen(r),s=t.getRowedItem(o,r,i);if(a.push(s),n.push(s),e.length>0)do{if(n.push(t.getRowedItem(e[0],r,i)),!(t.worst(a,l)>t.worst(n,l)))break;a=n.slice(),e.shift()}while(e.length);return a},t.layoutRowedItems=function(e,r,i,o){var a,n=i.left,l=i.top,s=n+i.width,h=l+i.height,c=t.sumRowedArray(r);o?(a=0===i.height?0:c/i.height,n+a>=s&&(a=s-n),r.forEach(function(t,e){var i=0===a?0:t.val/a;(l+i>h||e===r.length-1)&&(i=h-l);var o=new wjcCore.Rect(n,l,a,i);t.item.rect=o,l+=i}),i.left+=a,i.width-=a):(a=0===i.width?0:c/i.width,l+a>=h&&(a=h-l),r.forEach(function(t,e){var i=0===a?0:t.val/a;(n+i>s||e===r.length-1)&&(i=s-n);var o=new wjcCore.Rect(n,l,i,a);t.item.rect=o,n+=i}),i.top+=a,i.height-=a)},t.sumRowedArray=function(t){for(var e=0,r=t.length,i=0;i<r;i++)e+=t[i].val;return e},t.worst=function(e,r){var i,o,a=t.sumRowedArray(e),n=a*a,l=r*r;return i=o=e[0].val,e.forEach(function(t,e){t.val>i?i=t.val:t.val<o&&(o=t.val)}),Math.max(l*i/n,n/(l*o))},t}(),HierarchicalUtil=function(){function t(){}return t.parseDataToHierarchical=function(e,r,i,o){var a,n=[];return e instanceof wjcCore.CollectionView&&e.groups.length>0?n=t.parseGroupCV(e,r):e.length>0&&(wjcCore.isString(i)&&i.indexOf(",")>-1&&(i=i.split(",")),o?n=t.parseItems(e,r,i,o):(a=t.convertFlatData(e,r,i),n=t.parseItems(a,"value",i,"items"))),n},t.parseGroupCV=function(t,e){for(var r=[],i=0,o=t.groups.length;i<o;i++){var a=this.parseGroups(t.groups[i],e);r.push(a)}return r},t.parseGroups=function(t,e){var r={};if(r.name=t.name,r.nameField=t.groupDescription.propertyName,r.item=t.items,t.groups&&t.groups.length){r.items=[];for(var i=0,o=t.groups.length;i<o;i++){var a=this.parseGroups(t.groups[i],e);r.items.push(a)}}else t.isBottomLevel&&(r.value=t.getAggregate(wjcCore.Aggregate.Sum,e));return r},t.parseItems=function(e,r,i,o){var a,n=[],l=e.length;for(a=0;a<l;a++)n.push(t.parseItem(e[a],r,i,o));return n},t.isFlatItem=function(t,e){return!wjcCore.isArray(t[e])},t.convertFlatData=function(e,r,i){var o,a,n=[],l={},s=e.length;for(o=0;o<s;o++)a=e[o],t.convertFlatItem(l,a,r,wjcCore.isArray(i)?i:[i]);return t.convertFlatToHierarchical(n,l),n},t.convertFlatToHierarchical=function(e,r){var i=r.flatDataOrder;i&&i.forEach(function(i){var o,a={},n=r[i];a[r.field]=i,n.flatDataOrder?(o=[],t.convertFlatToHierarchical(o,n),a.items=o):a.value=n,e.push(a)})},t.convertFlatItem=function(e,r,i,o){var a,n,l,s;return a=o.slice(),n=a.shift(),n=wjcCore.isString(n)?n.trim():n,null!=(l=null==n?i:r[n])&&(0===a.length?(e[l]=r[i]||0,e.flatDataOrder?e.flatDataOrder.push(l):e.flatDataOrder=[l],e.field=n):(null==e[l]&&(e[l]={},e.flatDataOrder?e.flatDataOrder.push(l):e.flatDataOrder=[l],e.field=n),s=e[l],t.convertFlatItem(s,r,i,a)||(e[l]=r[i])),!0)},t.parseItem=function(e,r,i,o){var a,n,l,s,h,c={};return wjcCore.isArray(o)?s=(h=o.slice()).length?h.shift().trim():"":(h=o,s=o),wjcCore.isArray(i)?(n=null==(n=(a=i.slice()).shift())?n:n.trim(),c.nameField=null==n?r:n,c.name=null==n?e[r]:e[n],l=e[s],0===a.length?c.value=e[r]:l&&wjcCore.isArray(l)&&l.length>0?c.items=t.parseItems(l,r,a,h):c.value=e[r]||0):(c.nameField=null==i?r:i,c.name=null==i?e[r]:e[i],null!=(l=e[s])&&wjcCore.isArray(l)&&l.length>0?c.items=t.parseItems(l,r,i,h):c.value=e[r]),c.item=e,c},t.parseFlatItem=function(t,e,r,i){t.items||(t.items=[])},t}();exports.HierarchicalUtil=HierarchicalUtil;