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