// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/4.0beta2/esri/copyright.txt for details.
//>>built
define("../../core/declare dojo/_base/lang dojo/number ../../widgets/Popup/PopupRenderer ../../core/lang ../../core/screenUtils ../../symbols/TextSymbol ../../symbols/LabelSymbol3D ../../symbols/ShieldLabelSymbol".split(" "),function(n,h,p,q,m,l,r,s,t){var b=n(null,{declaredClass:"esri.layers.support.LabelClass",labelPlacement:null,labelExpression:null,useCodedValues:null,symbol:null,maxScale:0,minScale:0,where:null,sizeInfo:null,_labelPlacementLookup:{"above-center":"esriServerPointLabelPlacementAboveCenter",
"above-left":"esriServerPointLabelPlacementAboveLeft","above-right":"esriServerPointLabelPlacementAboveRight","below-center":"esriServerPointLabelPlacementBelowCenter","below-left":"esriServerPointLabelPlacementBelowLeft","below-right":"esriServerPointLabelPlacementBelowRight","center-center":"esriServerPointLabelPlacementCenterCenter","center-left":"esriServerPointLabelPlacementCenterLeft","center-right":"esriServerPointLabelPlacementCenterRight","above-after":"esriServerLinePlacementAboveAfter",
"above-along":"esriServerLinePlacementAboveAlong","above-before":"esriServerLinePlacementAboveBefore","above-start":"esriServerLinePlacementAboveStart","above-end":"esriServerLinePlacementAboveEnd","below-after":"esriServerLinePlacementBelowAfter","below-along":"esriServerLinePlacementBelowAlong","below-before":"esriServerLinePlacementBelowBefore","below-start":"esriServerLinePlacementBelowStart","below-end":"esriServerLinePlacementBelowEnd","center-after":"esriServerLinePlacementCenterAfter","center-along":"esriServerLinePlacementCenterAlong",
"center-before":"esriServerLinePlacementCenterBefore","center-start":"esriServerLinePlacementCenterStart","center-end":"esriServerLinePlacementCenterEnd","always-horizontal":"esriServerPolygonPlacementAlwaysHorizontal"},constructor:function(a){if(a&&(h.mixin(this,a),this._labelPlacementLookup.hasOwnProperty(this.labelPlacement)||(this.labelPlacement=m.valueOf(this._labelPlacementLookup,a.labelPlacement)),a.symbol&&(this.symbol=a.symbol.declaredClass?a.symbol:"LabelSymbol3D"===a.symbol.type?s.fromJSON(a.symbol):
"esriSHD"===a.symbol.type?new t(a.symbol):r.fromJSON(a.symbol)),a=this.sizeInfo))a.minSize&&(a.minSize=l.pt2px(a.minSize)),a.maxSize&&(a.maxSize=l.pt2px(a.maxSize))},getSymbol:function(){return this.symbol},getRequiredFields:function(){var a=Object.create(null);this.collectRequiredFields(a);return Object.keys(a)},collectRequiredFields:function(a){b.collectLabelExpressionRequiredFields(this.getLabelExpression(),a);b.collectWhereRequiredFields(this.where,a)},getLabelExpression:function(){return this.labelExpressionInfo?
this.labelExpressionInfo.value:b.isValidLabelExpression(this.labelExpression)?b._convertLabelExpression(this.labelExpression):""},toJson:function(){try{throw Error("toJson is deprecated, use toJSON instead");}catch(a){console.warn(a.stack)}return this.toJSON()},toJSON:function(){var a=this.sizeInfo;a&&(a=h.mixin({},a),a.minSize&&(a.minSize=l.px2pt(a.minSize)),a.maxSize&&(a.maxSize=l.px2pt(a.maxSize)));a={labelExpression:this.labelExpression,labelExpressionInfo:this.labelExpressionInfo&&h.clone(this.labelExpressionInfo),
useCodedValues:this.useCodedValues,maxScale:this.maxScale,minScale:this.minScale,where:this.where,sizeInfo:a,labelPlacement:this._labelPlacementLookup.hasOwnProperty(this.labelPlacement)?this._labelPlacementLookup[this.labelPlacement]:this.labelPlacement,symbol:this.symbol&&this.symbol.toJSON()};return m.fixJson(a)}});b.evaluateWhere=function(a,d){var k=function(a,d,c){switch(d){case "\x3d":return a==c?!0:!1;case "\x3c\x3e":return a!=c?!0:!1;case "\x3e":return a>c?!0:!1;case "\x3e\x3d":return a>=
c?!0:!1;case "\x3c":return a<c?!0:!1;case "\x3c\x3d":return a<=c?!0:!1}return!1};try{if(null==a)return!0;var c=a.split(" ");if(3===c.length)return k(d[c[0]],c[1],c[2]);if(7===c.length){var b=k(d[c[0]],c[1],c[2]),f=c[3],e=k(d[c[4]],c[5],c[6]);switch(f){case "AND":return b&&e;case "OR":return b||e}}return!1}catch(h){console.log("Error.: can't parse \x3d "+a)}};b.collectWhereRequiredFields=function(a,d){if(null!=a){var b=a.split(" ");3===b.length&&(d[b[0]]=!0);7===b.length&&(d[b[0]]=!0,d[b[4]]=!0)}};
b.collectLabelExpressionRequiredFields=function(a,d){var b=a.match(/{[^}]*}/g);b&&b.forEach(function(a){d[a.slice(1,-1)]=!0})};b.buildLabelText=function(a,d,k,c){return a.replace(/{[^}]*}/g,function(a){return b.formatField(a.slice(1,-1),a,d,k,c)})};b.formatField=function(a,d,b,c,g){var f;for(f=0;f<c.length;f++)if(c[f].name==a){d=b[c[f].name];var e=c[f].domain;if(e&&h.isObject(e)){if("codedValue"==e.type)for(a=0;a<e.codedValues.length;a++)e.codedValues[a].code==d&&(d=e.codedValues[a].name);else"range"==
e.type&&(e.minValue<=d&&d<=e.maxValue)&&(d=e.name);break}e=c[f].type;if("esriFieldTypeDate"==e)(e="DateFormat"+q.prototype._dateFormats[g&&g.dateFormat||"shortDate"])&&(d=m.substitute({myKey:d},"${myKey:"+e+"}"));else if("esriFieldTypeInteger"==e||"esriFieldTypeSmallInteger"==e||"esriFieldTypeLong"==e||"esriFieldTypeDouble"==e)g&&(g.numberFormat&&g.numberFormat.digitSeparator&&g.numberFormat.places)&&(d=p.format(d,{places:g.numberFormat.places}))}return null==d?"":d};b.isValidLabelExpression=function(a){return/^(\s*\[[^\]]+\]\s*)+$/i.test(a)};
b._convertLabelExpression=function(a){return a.replace(/\[/g,"{").replace(/\]/g,"}")};return b});