// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("dojo/_base/declare ./BaseDijit dojo/dom-style dojo/_base/html jimu/utils ../utils ./clientStatistic ./styleUtils".split(" "),function(l,m,g,c,f,h,n,p){return l([m],{templateString:'\x3cdiv tabindex\x3d"0" class\x3d"has-link" role\x3d"link" style\x3d"height:100%;width:100%;"\x3e\x3cdiv data-dojo-attach-point\x3d"noDataDiv"class\x3d"no-data-tip"\x3e${nls.noData}\x3c/div\x3e\x3ca tabindex\x3d"-1" data-dojo-attach-point\x3d"numberContent" class\x3d"number-content no-trim" target\x3d"_blank"\x3e\x3cdiv data-dojo-attach-point\x3d"leftIcon" class\x3d"icon"\x3e\x3c/div\x3e\x3cdiv data-dojo-attach-point\x3d"number" class\x3d"number"\x3e\x3cdiv data-dojo-attach-point\x3d"prefix" class\x3d"prefix"\x3e\x3c/div\x3e\x3cdiv class\x3d"value-content" data-dojo-attach-point\x3d"valueContent"\x3e\x3c/div\x3e\x3cdiv data-dojo-attach-point\x3d"suffix" class\x3d"suffix"\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv data-dojo-attach-point\x3d"rightIcon" class\x3d"icon"\x3e\x3c/div\x3e\x3c/a\x3e\x3c/div\x3e',
baseClass:"infographic-number-dijit",type:"number",config:null,constructor:function(a){this.visible=a.visible},postCreate:function(){this.inherited(arguments);this._value=this._features=null;this._upgradeConfig(this.config);this.setConfig(this.config);this._updateBackGroundColor()},_upgradeConfig:function(a){(a=a&&a.dataFormat)&&"undefined"===typeof a.digitSeparator&&(a.digitSeparator=!0)},setLayerInfo:function(){},setVisible:function(a){this.visible=a},resetData:function(){this.numberValue=this._value=
this._features=this.dataSource=null},onDataSourceDataUpdate:function(a){this.inSettingPage?a&&"undefined"!==typeof a.features&&(this._features=h.cleanFeatures(a.features)):"number"===typeof a&&(this._value=a)},setDataSource:function(a){this.inherited(arguments);this.dataSource=a},setConfig:function(a){a&&(this.config=a)},startRendering:function(){this._shouldRenderNumber()&&(this._updateBackGroundColor(),this._calculateNumberValue(),"number"!==typeof this.numberValue?this.showNodata():this._renderNumber(this.numberValue))},
_calculateNumberValue:function(){if(this.inSettingPage){var a=h.getStatisticForNumber(this.config);a=n.statistic(a,this.dataSource,this._features)}else a=this._value;"undefined"!==typeof a&&!1!==a&&(this.numberValue=a)},_renderNumber:function(a){this._cleanNumberContent();this.valueContent.innerHTML=f.localizeNumber(a);this._setValueDisplay()},_setValueDisplay:function(){var a=this.config;a&&(this._setBackground(a),this._setFont(a),this._setDataFormat(a),this._setIndicatorStyle())},_shouldRenderNumber:function(){if(this.visible&&
this.config){var a;(a=this.inSettingPage?this.domNode&&this._features:this.domNode&&"number"===typeof this._value)?this.hideNodata():this.showNodata();return!!a}},_getIndicatorColor:function(){var a=!1,b=!1,d=this.config.indicators;d&&((d=h.getVaildIndicator(this.numberValue,d))&&d.valueColor&&(a=d.valueColor),d&&f.isNotEmptyObject(d.iconInfo)&&(b=d.iconInfo));return{color:a,icon:b}},_cleanNumberContent:function(){c.removeClass(this.leftIcon);c.addClass(this.leftIcon,["icon"]);c.removeClass(this.rightIcon);
c.addClass(this.rightIcon,["icon"]);this.replaceIcon&&(c.destroy(this.replaceIcon),this.replaceIcon=null);c.empty(this.valueContent);c.empty(this.prefix);c.empty(this.suffix);this._setValueColor("")},_updateBackGroundColor:function(){var a=this.config;(a=a&&a.background&&a.background.backgroundColor)&&c.setStyle(this.domNode,"backgroundColor",a)},_setBackground:function(a){if(a=a&&a.background){a.backgroundColor&&c.setStyle(this.domNode,"backgroundColor",a.backgroundColor);var b=a.alignment;b&&(c.removeClass(this.domNode),
c.addClass(this.domNode,"infographic-number-dijit"),b.horizontal&&c.addClass(this.domNode,"horizontal-"+b.horizontal),b.vertical&&c.addClass(this.domNode,"vertical-"+b.vertical));a.link?c.setAttr(this.numberContent,"href",a.link):c.removeAttr(this.numberContent,"href")}},_setFont:function(a){if(a&&a.font){var b={};p.font.setStyle(a.font,b);c.setStyle(this.number,b)}},_setDataFormat:function(a){var b="";var d=this.numberValue;var e=a.dataFormat;if(e){a=e.decimalPlaces;var k=e.digitSeparator;a&&(a=
Number(a));"percentage"===e.unit?d=f.convertNumberToPercentage(d,a,k):"thousand"===e.unit?(b=this.nls.thousandAbbreviation,d/=1E3):"million"===e.unit?(b=this.nls.millionAbbreviation,d/=1E6):"billion"===e.unit&&(b=this.nls.billionAbbreviation,d/=1E9);"percentage"!==e.unit&&(d=f.localizeNumberByFieldInfo(d,{format:{places:a,digitSeparator:k}}));b&&(d+=b);this.valueContent.innerHTML=d;e.prefix&&(this.prefix.innerHTML=f.sanitizeHTML(e.prefix));e.suffix&&(this.suffix.innerHTML=f.sanitizeHTML(e.suffix))}},
_setIndicatorStyle:function(){var a=this._getIndicatorColor();a.color&&this._setValueColor(a.color);a.icon&&this._setIndicatorIcon(a.icon)},_setValueColor:function(a){g.set(this.number,"color",a)},_setIndicatorIcon:function(a){a&&("left"===a.placement||"right"===a.placement?this._setLeftRightIcon(a):"replace"===a.placement&&this._setReplaceIcon(a))},_setReplaceIcon:function(a){var b=c.create("div",{"class":"indicator-icon "+a.icon});c.empty(this.valueContent);c.place(b,this.valueContent);g.set(b,
"color",a.color);g.set(b,"display","inline-flex")},_setLeftRightIcon:function(a){if("left"===a.placement)var b=this.leftIcon;else"right"===a.placement&&(b=this.rightIcon);c.addClass(b,"indicator-icon "+a.icon);g.set(b,"color",a.color)},showNodata:function(a){this._cleanNumberContent();c.addClass(this.domNode,"no-data");a&&(this.noDataDiv.innerHTML=f.sanitizeHTML(a))},hideNodata:function(){c.removeClass(this.domNode,"no-data")}})});