// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
require({cache:{"dojo/debounce":function(){define([],function(){return function(l,r){var d;return function(){d&&clearTimeout(d);var b=this,g=arguments;d=setTimeout(function(){l.apply(b,g)},r)}}})},"dojo/DeferredList":function(){define(["./_base/kernel","./_base/Deferred","./_base/array"],function(l,r,d){l.DeferredList=function(b,g,w,v,q){var f=[];r.call(this);var l=this;0!==b.length||g||this.resolve([0,[]]);var y=0;d.forEach(b,function(q,d){function r(c,q){f[d]=[c,q];y++;y===b.length&&l.resolve(f)}
q.then(function(c){g?l.resolve([d,c]):r(!0,c)},function(c){w?l.reject(c):r(!1,c);if(v)return null;throw c;})})};l.DeferredList.prototype=new r;l.DeferredList.prototype.gatherResults=function(b){b=new l.DeferredList(b,!1,!0,!1);b.addCallback(function(b){var g=[];d.forEach(b,function(b){g.push(b[1])});return g});return b};return l.DeferredList})},"dijit/_Widget":function(){define("dojo/aspect dojo/_base/config dojo/_base/connect dojo/_base/declare dojo/has dojo/_base/kernel dojo/_base/lang dojo/query dojo/ready ./registry ./_WidgetBase ./_OnDijitClickMixin ./_FocusMixin dojo/uacss ./hccss".split(" "),
function(l,r,d,b,g,w,v,q,f,G,y,C,E){function u(){}function c(c){return function(m,k,b,q){return m&&"string"==typeof k&&m[k]==u?m.on(k.substring(2).toLowerCase(),v.hitch(b,q)):c.apply(d,arguments)}}l.around(d,"connect",c);w.connect&&l.around(w,"connect",c);l=b("dijit._Widget",[y,C,E],{onClick:u,onDblClick:u,onKeyDown:u,onKeyPress:u,onKeyUp:u,onMouseDown:u,onMouseMove:u,onMouseOut:u,onMouseOver:u,onMouseLeave:u,onMouseEnter:u,onMouseUp:u,constructor:function(c){this._toConnect={};for(var m in c)this[m]===
u&&(this._toConnect[m.replace(/^on/,"").toLowerCase()]=c[m],delete c[m])},postCreate:function(){this.inherited(arguments);for(var c in this._toConnect)this.on(c,this._toConnect[c]);delete this._toConnect},on:function(c,m){return this[this._onMap(c)]===u?d.connect(this.domNode,c.toLowerCase(),this,m):this.inherited(arguments)},_setFocusedAttr:function(c){this._focused=c;this._set("focused",c)},setAttribute:function(c,m){w.deprecated(this.declaredClass+"::setAttribute(attr, value) is deprecated. Use set() instead.",
"","2.0");this.set(c,m)},attr:function(c,m){return 2<=arguments.length||"object"===typeof c?this.set.apply(this,arguments):this.get(c)},getDescendants:function(){w.deprecated(this.declaredClass+"::getDescendants() is deprecated. Use getChildren() instead.","","2.0");return this.containerNode?q("[widgetId]",this.containerNode).map(G.byNode):[]},_onShow:function(){this.onShow()},onShow:function(){},onHide:function(){},onClose:function(){return!0}});g("dijit-legacy-requires")&&f(0,function(){require(["dijit/_base"])});
return l})},"dijit/_WidgetBase":function(){define("require dojo/_base/array dojo/aspect dojo/_base/config dojo/_base/connect dojo/_base/declare dojo/dom dojo/dom-attr dojo/dom-class dojo/dom-construct dojo/dom-geometry dojo/dom-style dojo/has dojo/_base/kernel dojo/_base/lang dojo/on dojo/ready dojo/Stateful dojo/topic dojo/_base/window ./Destroyable dojo/has!dojo-bidi?./_BidiMixin ./registry".split(" "),function(l,r,d,b,g,w,v,q,f,G,y,C,E,u,c,x,m,k,K,D,A,P,F){function L(c){return function(z){q[z?
"set":"remove"](this.domNode,c,z);this._set(c,z)}}E.add("dijit-legacy-requires",!u.isAsync);E.add("dojo-bidi",!1);E("dijit-legacy-requires")&&m(0,function(){l(["dijit/_base/manager"])});var H={};b=w("dijit._WidgetBase",[k,A],{id:"",_setIdAttr:"domNode",lang:"",_setLangAttr:L("lang"),dir:"",_setDirAttr:L("dir"),"class":"",_setClassAttr:{node:"domNode",type:"class"},_setTypeAttr:null,style:"",title:"",tooltip:"",baseClass:"",srcNodeRef:null,domNode:null,containerNode:null,ownerDocument:null,_setOwnerDocumentAttr:function(c){this._set("ownerDocument",
c)},attributeMap:{},_blankGif:b.blankGif||l.toUrl("dojo/resources/blank.gif"),textDir:"",_introspect:function(){var c=this.constructor;if(!c._setterAttrs){var m=c.prototype,k=c._setterAttrs=[],c=c._onMap={},b;for(b in m.attributeMap)k.push(b);for(b in m)/^on/.test(b)&&(c[b.substring(2).toLowerCase()]=b),/^_set[A-Z](.*)Attr$/.test(b)&&(b=b.charAt(4).toLowerCase()+b.substr(5,b.length-9),m.attributeMap&&b in m.attributeMap||k.push(b))}},postscript:function(c,b){this.create(c,b)},create:function(b,m){this._introspect();
this.srcNodeRef=v.byId(m);this._connects=[];this._supportingWidgets=[];this.srcNodeRef&&this.srcNodeRef.id&&"string"==typeof this.srcNodeRef.id&&(this.id=this.srcNodeRef.id);b&&(this.params=b,c.mixin(this,b));this.postMixInProperties();this.id||(this.id=F.getUniqueId(this.declaredClass.replace(/\./g,"_")),this.params&&delete this.params.id);this.ownerDocument=this.ownerDocument||(this.srcNodeRef?this.srcNodeRef.ownerDocument:document);this.ownerDocumentBody=D.body(this.ownerDocument);F.add(this);
this.buildRendering();var z;if(this.domNode){this._applyAttributes();var k=this.srcNodeRef;k&&k.parentNode&&this.domNode!==k&&(k.parentNode.replaceChild(this.domNode,k),z=!0);this.domNode.setAttribute("widgetId",this.id)}this.postCreate();z&&delete this.srcNodeRef;this._created=!0},_applyAttributes:function(){var c={},b;for(b in this.params||{})c[b]=this._get(b);r.forEach(this.constructor._setterAttrs,function(b){if(!(b in c)){var m=this._get(b);m&&this.set(b,m)}},this);for(b in c)this.set(b,c[b])},
postMixInProperties:function(){},buildRendering:function(){this.domNode||(this.domNode=this.srcNodeRef||this.ownerDocument.createElement("div"));if(this.baseClass){var c=this.baseClass.split(" ");this.isLeftToRight()||(c=c.concat(r.map(c,function(c){return c+"Rtl"})));f.add(this.domNode,c)}},postCreate:function(){},startup:function(){this._started||(this._started=!0,r.forEach(this.getChildren(),function(b){b._started||b._destroyed||!c.isFunction(b.startup)||(b.startup(),b._started=!0)}))},destroyRecursive:function(c){this._beingDestroyed=
!0;this.destroyDescendants(c);this.destroy(c)},destroy:function(b){function m(c){c.destroyRecursive?c.destroyRecursive(b):c.destroy&&c.destroy(b)}this._beingDestroyed=!0;this.uninitialize();r.forEach(this._connects,c.hitch(this,"disconnect"));r.forEach(this._supportingWidgets,m);this.domNode&&r.forEach(F.findWidgets(this.domNode,this.containerNode),m);this.destroyRendering(b);F.remove(this.id);this._destroyed=!0},destroyRendering:function(c){this.bgIframe&&(this.bgIframe.destroy(c),delete this.bgIframe);
this.domNode&&(c?q.remove(this.domNode,"widgetId"):G.destroy(this.domNode),delete this.domNode);this.srcNodeRef&&(c||G.destroy(this.srcNodeRef),delete this.srcNodeRef)},destroyDescendants:function(c){r.forEach(this.getChildren(),function(b){b.destroyRecursive&&b.destroyRecursive(c)})},uninitialize:function(){return!1},_setStyleAttr:function(b){var m=this.domNode;c.isObject(b)?C.set(m,b):m.style.cssText=m.style.cssText?m.style.cssText+("; "+b):b;this._set("style",b)},_attrToDom:function(b,m,k){k=3<=
arguments.length?k:this.attributeMap[b];r.forEach(c.isArray(k)?k:[k],function(k){var g=this[k.node||k||"domNode"];switch(k.type||"attribute"){case "attribute":c.isFunction(m)&&(m=c.hitch(this,m));k=k.attribute?k.attribute:/^on[A-Z][a-zA-Z]*$/.test(b)?b.toLowerCase():b;g.tagName?q.set(g,k,m):g.set(k,m);break;case "innerText":g.innerHTML="";g.appendChild(this.ownerDocument.createTextNode(m));break;case "innerHTML":g.innerHTML=m;break;case "class":f.replace(g,m,this[b]);break;case "toggleClass":f.toggle(g,
k.className||b,m)}},this)},get:function(c){var b=this._getAttrNames(c);return this[b.g]?this[b.g]():this._get(c)},set:function(b,m){if("object"===typeof b){for(var k in b)this.set(k,b[k]);return this}k=this._getAttrNames(b);var q=this[k.s];if(c.isFunction(q))var f=q.apply(this,Array.prototype.slice.call(arguments,1));else{var q=this.focusNode&&!c.isFunction(this.focusNode)?"focusNode":"domNode",g=this[q]&&this[q].tagName,v;if((v=g)&&!(v=H[g])){v=this[q];var w={},d;for(d in v)w[d.toLowerCase()]=!0;
v=H[g]=w}d=v;k=b in this.attributeMap?this.attributeMap[b]:k.s in this?this[k.s]:d&&k.l in d&&"function"!=typeof m||/^aria-|^data-|^role$/.test(b)?q:null;null!=k&&this._attrToDom(b,m,k);this._set(b,m)}return f||this},_attrPairNames:{},_getAttrNames:function(c){var b=this._attrPairNames;if(b[c])return b[c];var k=c.replace(/^[a-z]|-[a-zA-Z]/g,function(c){return c.charAt(c.length-1).toUpperCase()});return b[c]={n:c+"Node",s:"_set"+k+"Attr",g:"_get"+k+"Attr",l:k.toLowerCase()}},_set:function(c,b){var k=
this[c];this[c]=b;!this._created||k===b||k!==k&&b!==b||(this._watchCallbacks&&this._watchCallbacks(c,k,b),this.emit("attrmodified-"+c,{detail:{prevValue:k,newValue:b}}))},_get:function(c){return this[c]},emit:function(c,b,k){b=b||{};void 0===b.bubbles&&(b.bubbles=!0);void 0===b.cancelable&&(b.cancelable=!0);b.detail||(b.detail={});b.detail.widget=this;var m,q=this["on"+c];q&&(m=q.apply(this,k?k:[b]));this._started&&!this._beingDestroyed&&x.emit(this.domNode,c.toLowerCase(),b);return m},on:function(c,
b){var k=this._onMap(c);return k?d.after(this,k,b,!0):this.own(x(this.domNode,c,b))[0]},_onMap:function(c){var b=this.constructor,k=b._onMap;if(!k){var k=b._onMap={},m;for(m in b.prototype)/^on/.test(m)&&(k[m.replace(/^on/,"").toLowerCase()]=m)}return k["string"==typeof c&&c.toLowerCase()]},toString:function(){return"[Widget "+this.declaredClass+", "+(this.id||"NO ID")+"]"},getChildren:function(){return this.containerNode?F.findWidgets(this.containerNode):[]},getParent:function(){return F.getEnclosingWidget(this.domNode.parentNode)},
connect:function(c,b,k){return this.own(g.connect(c,b,this,k))[0]},disconnect:function(c){c.remove()},subscribe:function(b,k){return this.own(K.subscribe(b,c.hitch(this,k)))[0]},unsubscribe:function(c){c.remove()},isLeftToRight:function(){return this.dir?"ltr"==this.dir.toLowerCase():y.isBodyLtr(this.ownerDocument)},isFocusable:function(){return this.focus&&"none"!=C.get(this.domNode,"display")},placeAt:function(c,b){var k=!c.tagName&&F.byId(c);!k||!k.addChild||b&&"number"!==typeof b?(k=k&&"domNode"in
k?k.containerNode&&!/after|before|replace/.test(b||"")?k.containerNode:k.domNode:v.byId(c,this.ownerDocument),G.place(this.domNode,k,b),!this._started&&(this.getParent()||{})._started&&this.startup()):k.addChild(this,b);return this},defer:function(b,k){var m=setTimeout(c.hitch(this,function(){m&&(m=null,this._destroyed||c.hitch(this,b)())}),k||0);return{remove:function(){m&&(clearTimeout(m),m=null);return null}}}});E("dojo-bidi")&&b.extend(P);return b})},"dijit/Destroyable":function(){define(["dojo/_base/array",
"dojo/aspect","dojo/_base/declare"],function(l,r,d){return d("dijit.Destroyable",null,{destroy:function(b){this._destroyed=!0},own:function(){var b=["destroyRecursive","destroy","remove"];l.forEach(arguments,function(g){function d(){q.remove();l.forEach(f,function(b){b.remove()})}var v,q=r.before(this,"destroy",function(b){g[v](b)}),f=[];g.then?(v="cancel",g.then(d,d)):l.forEach(b,function(b){"function"===typeof g[b]&&(v||(v=b),f.push(r.after(g,b,d,!0)))})},this);return arguments}})})},"dijit/_OnDijitClickMixin":function(){define("dojo/on dojo/_base/array dojo/keys dojo/_base/declare dojo/has ./a11yclick".split(" "),
function(l,r,d,b,g,w){l=b("dijit._OnDijitClickMixin",null,{connect:function(b,q,f){return this.inherited(arguments,[b,"ondijitclick"==q?w:q,f])}});l.a11yclick=w;return l})},"dijit/_FocusMixin":function(){define(["./focus","./_WidgetBase","dojo/_base/declare","dojo/_base/lang"],function(l,r,d,b){b.extend(r,{focused:!1,onFocus:function(){},onBlur:function(){},_onFocus:function(){this.onFocus()},_onBlur:function(){this.onBlur()}});return d("dijit._FocusMixin",null,{_focusManager:l})})},"dijit/hccss":function(){define(["dojo/dom-class",
"dojo/hccss","dojo/domReady","dojo/_base/window"],function(l,r,d,b){d(function(){r("highcontrast")&&l.add(b.body(),"dijit_a11y")});return r})},"dojo/hccss":function(){define("require ./_base/config ./dom-class ./dom-style ./has ./domReady ./_base/window".split(" "),function(l,r,d,b,g,w,v){g.add("highcontrast",function(){var q=v.doc.createElement("div");try{q.style.cssText='border: 1px solid; border-color:red green; position: absolute; height: 5px; top: -999px;background-image: url("'+(r.blankGif||
l.toUrl("./resources/blank.gif"))+'");';v.body().appendChild(q);var f=b.getComputedStyle(q),d=f.backgroundImage;return f.borderTopColor==f.borderRightColor||d&&("none"==d||"url(invalid-url:)"==d)}catch(y){return console.warn("hccss: exception detecting high-contrast mode, document is likely hidden: "+y.toString()),!1}finally{8>=g("ie")?q.outerHTML="":v.body().removeChild(q)}});w(function(){g("highcontrast")&&d.add(v.body(),"dj_a11y")});return g})},"dojox/html/entities":function(){define(["dojo/_base/lang"],
function(l){var r=l.getObject("dojox.html.entities",!0),d=function(b,d){var g,q;if(d._encCache&&d._encCache.regexp&&d._encCache.mapper&&d.length==d._encCache.length)g=d._encCache.mapper,q=d._encCache.regexp;else{g={};q=["["];var f;for(f=0;f<d.length;f++)g[d[f][0]]="\x26"+d[f][1]+";",q.push(d[f][0]);q.push("]");q=new RegExp(q.join(""),"g");d._encCache={mapper:g,regexp:q,length:d.length}}return b=b.replace(q,function(b){return g[b]})},b=function(b,d){var g,q;if(d._decCache&&d._decCache.regexp&&d._decCache.mapper&&
d.length==d._decCache.length)g=d._decCache.mapper,q=d._decCache.regexp;else{g={};q=["("];var f;for(f=0;f<d.length;f++){var l="\x26"+d[f][1]+";";f&&q.push("|");g[l]=d[f][0];q.push(l)}q.push(")");q=new RegExp(q.join(""),"g");d._decCache={mapper:g,regexp:q,length:d.length}}return b=b.replace(q,function(b){return g[b]})};r.html=[["\x26","amp"],['"',"quot"],["\x3c","lt"],["\x3e","gt"],["\u00a0","nbsp"]];r.latin=[["\u00a1","iexcl"],["\u00a2","cent"],["\u00a3","pound"],["\u20ac","euro"],["\u00a4","curren"],
["\u00a5","yen"],["\u00a6","brvbar"],["\u00a7","sect"],["\u00a8","uml"],["\u00a9","copy"],["\u00aa","ordf"],["\u00ab","laquo"],["\u00ac","not"],["\u00ad","shy"],["\u00ae","reg"],["\u00af","macr"],["\u00b0","deg"],["\u00b1","plusmn"],["\u00b2","sup2"],["\u00b3","sup3"],["\u00b4","acute"],["\u00b5","micro"],["\u00b6","para"],["\u00b7","middot"],["\u00b8","cedil"],["\u00b9","sup1"],["\u00ba","ordm"],["\u00bb","raquo"],["\u00bc","frac14"],["\u00bd","frac12"],["\u00be","frac34"],["\u00bf","iquest"],["\u00c0",
"Agrave"],["\u00c1","Aacute"],["\u00c2","Acirc"],["\u00c3","Atilde"],["\u00c4","Auml"],["\u00c5","Aring"],["\u00c6","AElig"],["\u00c7","Ccedil"],["\u00c8","Egrave"],["\u00c9","Eacute"],["\u00ca","Ecirc"],["\u00cb","Euml"],["\u00cc","Igrave"],["\u00cd","Iacute"],["\u00ce","Icirc"],["\u00cf","Iuml"],["\u00d0","ETH"],["\u00d1","Ntilde"],["\u00d2","Ograve"],["\u00d3","Oacute"],["\u00d4","Ocirc"],["\u00d5","Otilde"],["\u00d6","Ouml"],["\u00d7","times"],["\u00d8","Oslash"],["\u00d9","Ugrave"],["\u00da",
"Uacute"],["\u00db","Ucirc"],["\u00dc","Uuml"],["\u00dd","Yacute"],["\u00de","THORN"],["\u00df","szlig"],["\u00e0","agrave"],["\u00e1","aacute"],["\u00e2","acirc"],["\u00e3","atilde"],["\u00e4","auml"],["\u00e5","aring"],["\u00e6","aelig"],["\u00e7","ccedil"],["\u00e8","egrave"],["\u00e9","eacute"],["\u00ea","ecirc"],["\u00eb","euml"],["\u00ec","igrave"],["\u00ed","iacute"],["\u00ee","icirc"],["\u00ef","iuml"],["\u00f0","eth"],["\u00f1","ntilde"],["\u00f2","ograve"],["\u00f3","oacute"],["\u00f4",
"ocirc"],["\u00f5","otilde"],["\u00f6","ouml"],["\u00f7","divide"],["\u00f8","oslash"],["\u00f9","ugrave"],["\u00fa","uacute"],["\u00fb","ucirc"],["\u00fc","uuml"],["\u00fd","yacute"],["\u00fe","thorn"],["\u00ff","yuml"],["\u0192","fnof"],["\u0391","Alpha"],["\u0392","Beta"],["\u0393","Gamma"],["\u0394","Delta"],["\u0395","Epsilon"],["\u0396","Zeta"],["\u0397","Eta"],["\u0398","Theta"],["\u0399","Iota"],["\u039a","Kappa"],["\u039b","Lambda"],["\u039c","Mu"],["\u039d","Nu"],["\u039e","Xi"],["\u039f",
"Omicron"],["\u03a0","Pi"],["\u03a1","Rho"],["\u03a3","Sigma"],["\u03a4","Tau"],["\u03a5","Upsilon"],["\u03a6","Phi"],["\u03a7","Chi"],["\u03a8","Psi"],["\u03a9","Omega"],["\u03b1","alpha"],["\u03b2","beta"],["\u03b3","gamma"],["\u03b4","delta"],["\u03b5","epsilon"],["\u03b6","zeta"],["\u03b7","eta"],["\u03b8","theta"],["\u03b9","iota"],["\u03ba","kappa"],["\u03bb","lambda"],["\u03bc","mu"],["\u03bd","nu"],["\u03be","xi"],["\u03bf","omicron"],["\u03c0","pi"],["\u03c1","rho"],["\u03c2","sigmaf"],["\u03c3",
"sigma"],["\u03c4","tau"],["\u03c5","upsilon"],["\u03c6","phi"],["\u03c7","chi"],["\u03c8","psi"],["\u03c9","omega"],["\u03d1","thetasym"],["\u03d2","upsih"],["\u03d6","piv"],["\u2022","bull"],["\u2026","hellip"],["\u2032","prime"],["\u2033","Prime"],["\u203e","oline"],["\u2044","frasl"],["\u2118","weierp"],["\u2111","image"],["\u211c","real"],["\u2122","trade"],["\u2135","alefsym"],["\u2190","larr"],["\u2191","uarr"],["\u2192","rarr"],["\u2193","darr"],["\u2194","harr"],["\u21b5","crarr"],["\u21d0",
"lArr"],["\u21d1","uArr"],["\u21d2","rArr"],["\u21d3","dArr"],["\u21d4","hArr"],["\u2200","forall"],["\u2202","part"],["\u2203","exist"],["\u2205","empty"],["\u2207","nabla"],["\u2208","isin"],["\u2209","notin"],["\u220b","ni"],["\u220f","prod"],["\u2211","sum"],["\u2212","minus"],["\u2217","lowast"],["\u221a","radic"],["\u221d","prop"],["\u221e","infin"],["\u2220","ang"],["\u2227","and"],["\u2228","or"],["\u2229","cap"],["\u222a","cup"],["\u222b","int"],["\u2234","there4"],["\u223c","sim"],["\u2245",
"cong"],["\u2248","asymp"],["\u2260","ne"],["\u2261","equiv"],["\u2264","le"],["\u2265","ge"],["\u2282","sub"],["\u2283","sup"],["\u2284","nsub"],["\u2286","sube"],["\u2287","supe"],["\u2295","oplus"],["\u2297","otimes"],["\u22a5","perp"],["\u22c5","sdot"],["\u2308","lceil"],["\u2309","rceil"],["\u230a","lfloor"],["\u230b","rfloor"],["\u2329","lang"],["\u232a","rang"],["\u25ca","loz"],["\u2660","spades"],["\u2663","clubs"],["\u2665","hearts"],["\u2666","diams"],["\u0152","OElig"],["\u0153","oelig"],
["\u0160","Scaron"],["\u0161","scaron"],["\u0178","Yuml"],["\u02c6","circ"],["\u02dc","tilde"],["\u2002","ensp"],["\u2003","emsp"],["\u2009","thinsp"],["\u200c","zwnj"],["\u200d","zwj"],["\u200e","lrm"],["\u200f","rlm"],["\u2013","ndash"],["\u2014","mdash"],["\u2018","lsquo"],["\u2019","rsquo"],["\u201a","sbquo"],["\u201c","ldquo"],["\u201d","rdquo"],["\u201e","bdquo"],["\u2020","dagger"],["\u2021","Dagger"],["\u2030","permil"],["\u2039","lsaquo"],["\u203a","rsaquo"]];r.encode=function(b,l){b&&(l?
b=d(b,l):(b=d(b,r.html),b=d(b,r.latin)));return b};r.decode=function(d,l){d&&(l?d=b(d,l):(d=b(d,r.html),d=b(d,r.latin)));return d};return r})},"esri/numberUtils":function(){define(["dojo/has","dojo/number","dojo/i18n!dojo/cldr/nls/number","./kernel"],function(l,r,d,b){var g=function(b,d){return b-d},w={_reNumber:/^-?(\d+)(\.(\d+))?$/i,getDigits:function(b){var d=String(b),f=d.match(w._reNumber);b={integer:0,fractional:0};f&&f[1]?(b.integer=f[1].split("").length,b.fractional=f[3]?f[3].split("").length:
0):-1<d.toLowerCase().indexOf("e")&&(f=d.split("e"),d=f[0],f=f[1],d&&f&&(d=Number(d),f=Number(f),(b=0<f)||(f=Math.abs(f)),d=w.getDigits(d),b?(d.integer+=f,d.fractional=f>d.fractional?0:d.fractional-f):(d.fractional+=f,d.integer=f>d.integer?1:d.integer-f),b=d));return b},getFixedNumbers:function(b,d){var f,q;f=Number(b.toFixed(d));f<b?q=f+1/Math.pow(10,d):(q=f,f-=1/Math.pow(10,d));f=Number(f.toFixed(d));q=Number(q.toFixed(d));return[f,q]},getPctChange:function(b,d,f,g){var q={prev:null,next:null},
l;null!=f&&(l=b-f,q.prev=Math.floor(Math.abs(100*(d-f-l)/l)));null!=g&&(l=g-b,q.next=Math.floor(Math.abs(100*(g-d-l)/l)));return q},round:function(b,d){var f=b.slice(0),q,l,v,r,u,c,x,m,k,K=d&&null!=d.tolerance?d.tolerance:2,D=d&&d.indexes,A=d&&null!=d.strictBounds?d.strictBounds:!1;if(D)D.sort(g);else for(D=[],c=0;c<f.length;c++)D.push(c);for(c=0;c<D.length;c++)if(k=D[c],q=f[k],l=0===k?null:f[k-1],v=k===f.length-1?null:f[k+1],r=w.getDigits(q),r=r.fractional){x=0;for(m=!1;x<=r&&!m;)u=w.getFixedNumbers(q,
x),u=A&&0===c?u[1]:u[0],m=w.hasMinimalChange(q,u,l,v,K),x++;m&&(f[k]=u)}return f},hasMinimalChange:function(b,d,f,g,l){b=w.getPctChange(b,d,f,g);d=null==b.prev||b.prev<=l;f=null==b.next||b.next<=l;return d&&f||b.prev+b.next<=2*l},_reAllZeros:new RegExp("\\"+d.decimal+"0+$","g"),_reSomeZeros:RegExp("(\\d)0*$","g"),format:function(b,d){d=d||{places:20,round:-1};var f=r.format(b,d);f&&(f=f.replace(w._reSomeZeros,"$1").replace(w._reAllZeros,""));return f}};l("extend-esri")&&(b.numberUtils=w);return w})},
"esri/renderers/utils":function(){define("dojo/_base/lang dojo/_base/array dojo/has dojo/date/locale ../kernel ../numberUtils ../Color dojo/i18n!dojo/cldr/nls/gregorian".split(" "),function(l,r,d,b,g,w,v,q){function f(b){return b&&r.map(b,function(b){return new v(b)})}function G(b,c,d){var k="";0===c?k=C.lt+" ":c===d&&(k=C.gt+" ");return k+b}var y={},C={lte:"\x3c\x3d",gte:"\x3e\x3d",lt:"\x3c",gt:"\x3e",pct:"%"},E={millisecond:0,second:1,minute:2,hour:3,day:4,month:5,year:6},u={millisecond:{dateOptions:{formatLength:"long"},
timeOptions:{formatLength:"medium"}},second:{dateOptions:{formatLength:"long"},timeOptions:{formatLength:"medium"}},minute:{dateOptions:{formatLength:"long"},timeOptions:{formatLength:"short"}},hour:{dateOptions:{formatLength:"long"},timeOptions:{formatLength:"short"}},day:{selector:"date",dateOptions:{formatLength:"long"}},month:{selector:"date",dateOptions:{formatLength:"long"}},year:{selector:"date",dateOptions:{selector:"year"}}},c={formatLength:"short",fullYear:!0},x={formatLength:"short"};l.mixin(y,
{timelineDateFormatOptions:{selector:"date",dateOptions:{formatLength:"short",fullYear:!0}},formatDate:function(d,k){var m,f=[];null==d||d instanceof Date||(d=new Date(d));k=k||{};k=l.mixin({},k);var g=k.selector?k.selector.toLowerCase():null;m=!g||-1<g.indexOf("time");g=!g||-1<g.indexOf("date");m&&(k.timeOptions=k.timeOptions||x,k.timeOptions&&(k.timeOptions=l.mixin({},k.timeOptions),k.timeOptions.selector=k.timeOptions.selector||"time",f.push(k.timeOptions)));g&&(k.dateOptions=k.dateOptions||c,
k.dateOptions&&(k.dateOptions=l.mixin({},k.dateOptions),k.dateOptions.selector=k.dateOptions.selector||"date",f.push(k.dateOptions)));f&&f.length?(f=r.map(f,function(c){return b.format(d,c)}),m=1==f.length?f[0]:q["dateTimeFormat-medium"].replace(/\'/g,"").replace(/\{(\d+)\}/g,function(b,c){return f[c]})):m=b.format(d);return m},createColorStops:function(b){var c=b.values,d=b.colors,m=b.labelIndexes,f=b.isDate,g=b.dateFormatOptions;b=[];return b=r.map(c,function(b,k){var q=null;if(!m||-1<r.indexOf(m,
k)){var l;(l=f?y.formatDate(b,g):w.format(b))&&(q=G(l,k,c.length-1))}return{value:b,color:d[k],label:q}})},updateColorStops:function(b){var c=b.stops,d=b.changes,m=b.isDate,f=b.dateFormatOptions,g=[],q,l=r.map(c,function(b){return b.value});r.forEach(d,function(b){g.push(b.index);l[b.index]=b.value});q=w.round(l,{indexes:g});r.forEach(c,function(b,d){b.value=l[d];if(null!=b.label){var k,g=null;(k=m?y.formatDate(q[d],f):w.format(q[d]))&&(g=G(k,d,c.length-1));b.label=g}})},createClassBreakLabel:function(b){var c=
b.minValue,d=b.maxValue,m=b.isFirstBreak?"":C.gt+" ";b="percent-of-total"===b.normalizationType?C.pct:"";c=null==c?"":w.format(c);d=null==d?"":w.format(d);return m+c+b+" \u2013 "+d+b},setLabelsForClassBreaks:function(b){var c=b.classBreaks,d=b.classificationMethod,m=b.normalizationType,f=[];c&&c.length&&("standard-deviation"===d?console.log("setLabelsForClassBreaks: cannot set labels for class breaks generated using 'standard-deviation' method."):b.round?(f.push(c[0].minValue),r.forEach(c,function(b){f.push(b.maxValue)}),
f=w.round(f),r.forEach(c,function(b,c){b.label=y.createClassBreakLabel({minValue:0===c?f[0]:f[c],maxValue:f[c+1],isFirstBreak:0===c,normalizationType:m})})):r.forEach(c,function(b,c){b.label=y.createClassBreakLabel({minValue:b.minValue,maxValue:b.maxValue,isFirstBreak:0===c,normalizationType:m})}))},updateClassBreak:function(b){var c=b.classBreaks,d=b.normalizationType,f=b.change,m=f.index,f=f.value,g=-1,q=-1,l=c.length;"standard-deviation"===b.classificationMethod?console.log("updateClassBreak: cannot update labels for class breaks generated using 'standard-deviation' method."):
(0===m?g=m:m===l?q=m-1:(q=m-1,g=m),-1<g&&g<l&&(b=c[g],b.minValue=f,b.label=y.createClassBreakLabel({minValue:b.minValue,maxValue:b.maxValue,isFirstBreak:0===g,normalizationType:d})),-1<q&&q<l&&(b=c[q],b.maxValue=f,b.label=y.createClassBreakLabel({minValue:b.minValue,maxValue:b.maxValue,isFirstBreak:0===q,normalizationType:d})))},calculateDateFormatInterval:function(b){var c,d,f=b.length,m,g,q,l,v,u,w=Infinity,x;b=r.map(b,function(b){return new Date(b)});for(c=0;c<f-1;c++){m=b[c];q=[];v=Infinity;u=
"";for(d=c+1;d<f;d++)g=b[d],g=m.getFullYear()!==g.getFullYear()&&"year"||m.getMonth()!==g.getMonth()&&"month"||m.getDate()!==g.getDate()&&"day"||m.getHours()!==g.getHours()&&"hour"||m.getMinutes()!==g.getMinutes()&&"minute"||m.getSeconds()!==g.getSeconds()&&"second"||"millisecond",l=E[g],l<v&&(v=l,u=g),q.push(g);v<w&&(w=v,x=u)}return x},createUniqueValueLabel:function(b){var c=b.value,d=b.fieldInfo,f=b.domain;b=b.dateFormatInterval;var g=String(c);(f=f&&f.codedValues?f.getName(c):null)?g=f:"number"===
typeof c&&(g=d&&"esriFieldTypeDate"===d.type?y.formatDate(c,b&&u[b]):w.format(c));return g},cloneColorInfo:function(b){var c;b&&(c=l.mixin({},b),c.colors=f(c.colors),c.stops=c.stops&&r.map(c.stops,function(b){b=l.mixin({},b);b.color&&(b.color=new v(b.color));return b}),c.legendOptions&&(c.legendOptions=l.mixin({},c.legendOptions)));return c},cloneOpacityInfo:function(b){var c;if(b){c=l.mixin({},b);if(b=c.opacityValues)c.opacityValues=b.slice(0);if(b=c.stops)c.stops=r.map(b,function(b){return l.mixin({},
b)});if(b=c.legendOptions)c.legendOptions=l.mixin({},b)}return c},cloneSizeInfo:function(b){var c;b&&(c=l.mixin({},b),c.stops&&(c.stops=r.map(c.stops,function(b){return l.mixin({},b)})),(b=c.minSize)&&"object"===typeof b&&(c.minSize=y.cloneSizeInfo(b)),(b=c.maxSize)&&"object"===typeof b&&(c.maxSize=y.cloneSizeInfo(b)),b=c.legendOptions)&&(c.legendOptions=l.mixin({},b),b=b.customValues)&&(c.legendOptions.customValues=b.slice(0));return c}});d("extend-esri")&&l.setObject("renderer.utils",y,g);return y})},
"esri/dijit/_EventedWidget":function(){define("dojo/_base/declare dojo/_base/lang dojo/aspect dojo/on ../Evented dijit/_WidgetBase".split(" "),function(l,r,d,b,g,w){return l([w,g],{_onMap:function(b){var d=this.constructor._onMap,f;d&&d.FINAL||(delete this.constructor._onMap,d=this.registerConnectEvents(),d.FINAL=!0);b=b.toLowerCase();d[b]?f=this[d[b].method]:(b=this._onCamelCase(b),this[b]&&(f=b));return f},on:function(d,g){var f=this._onMap(d),l=d.replace(/\-/g,""),q="on"+l in this.domNode;return f||
!q?this.inherited(arguments):this.own(b(this.domNode,l,g))[0]},emit:function(b,d,f){var g,l,q,v=b.toLowerCase(),u=this.constructor._onMap||this.registerConnectEvents();l=this[this._onMap(v)];d=d||{};d.target||(d.target=this);l&&u&&u[v]&&(this._onObj2Arr(function(){g=Array.prototype.slice.call(arguments)},u[v].argKeys)(d),q=r.mixin({},arguments),q[2]=g,q[0]=u[v].name.replace(/^on/,""));return this.inherited(q||arguments)}})})},"*noref":1}});
define("esri/dijit/Legend","dojo/_base/kernel dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/connect dojo/_base/json dojo/_base/Color dojo/debounce dojo/has dojo/sniff dojo/Deferred dojo/DeferredList dojo/json dojo/dom dojo/dom-construct dojo/dom-style dojo/dom-class dijit/_Widget dojox/gfx dojox/gfx/matrix dojox/html/entities ../kernel ../config ../request ../lang ../numberUtils ../renderers/utils ../renderers/SimpleRenderer ../renderers/UniqueValueRenderer ../renderers/ClassBreaksRenderer ../renderers/ScaleDependentRenderer ../renderers/DotDensityRenderer ../renderers/TemporalRenderer ../renderers/VectorFieldRenderer ../renderers/HeatmapRenderer ../symbols/PictureFillSymbol ../symbols/SimpleLineSymbol ../symbols/jsonUtils ../renderers/jsonUtils ./_EventedWidget dojo/i18n!../nls/jsapi".split(" "),function(l,
r,d,b,g,w,v,q,f,G,y,C,E,u,c,x,m,k,K,D,A,P,F,L,H,z,N,W,X,Y,Z,aa,ba,Q,ca,S,T,O,U,V,R){var J=r([V,k],{declaredClass:"esri.dijit.Legend",widgetsInTemplate:!1,layers:null,alignRight:!1,hoverLabelShowing:!1,_preserveCacheOnDestroy:!1,dotDensitySwatchSize:26,dotCoverage:75,gradientHeight:30,transparencyRampColor:new v([64,64,64]),defaultText:"Aa",sizeRampLightColor:new v([255,255,255]),sizeRampDarkColor:new v([128,128,128]),layerConnects:[],gradientWidth:34,colorRampBorder:"1px solid",_specialChars:{lt:"\x3c",
gt:"\x3e"},_ieTimer:100,_isRightToLeft:!1,_align:null,_legendAlign:null,constructor:function(a,b){d.mixin(this,R.widgets.legend);this._i18n=R.widgets.legend;a=a||{};a.map?b?(this.map=a.map,this.layerInfos=a.layerInfos,this._respectCurrentMapScale=!1===a.respectCurrentMapScale?!1:!0,this._respectVisibility=!1===a.respectVisibility?!1:!0,this._preserveCacheOnDestroy=a.preserveCacheOnDestroy?!0:!1,this.arrangement=a.arrangement===J.ALIGN_RIGHT?J.ALIGN_RIGHT:J.ALIGN_LEFT,this.arrangement===J.ALIGN_RIGHT&&
(this.alignRight=!0),this.autoUpdate=!1===a.autoUpdate?!1:!0,this._surfaceItems=[],this.hideLayersInLegend={},this.refresh=q(this.refresh,0)):console.error("esri.dijit.Legend: must specify a container for the legend"):console.error("esri.dijit.Legend: unable to find the 'map' property in parameters")},postMixInProperties:function(){this.inherited(arguments);var a=["ar","he"],b,c;for(b=0;b<a.length;b+=1)c=a[b],l.locale&&-1!==l.locale.indexOf(c)&&(-1!==l.locale.indexOf("-")?-1!==l.locale.indexOf(c+
"-")&&(this._isRightToLeft=!0):this._isRightToLeft=!0);this._isRightToLeft?(this._align=this.alignRight?"left":"right",this._legendAlign=this.alignRight?"esriLegendLeft":"esriLegendRight"):(this._align=this.alignRight?"right":"left",this._legendAlign=this.alignRight?"esriLegendRight":"esriLegendLeft")},startup:function(){this.inherited(arguments);this._initialize();9>f("ie")&&(this._repaintItems=d.hitch(this,this._repaintItems),setTimeout(this._repaintItems,this._ieTimer))},destroy:function(){this._deactivate();
this._removeCachedLegendResponses();this._removeHoverHandlers();this.inherited(arguments)},_removeCachedLegendResponses:function(){this._preserveCacheOnDestroy||b.forEach(this.layers,function(a){delete a.legendResponse})},refresh:function(a){if(this.domNode){a?(this.layerInfos=a,this.layers=[],b.forEach(this.layerInfos,function(a){this._isSupportedLayerType(a.layer)&&(a.title&&(a.layer._titleForLegend=a.title),a.layer._hideDefaultSymbol=!1===a.defaultSymbol?!0:!1,a.hideLayers?(this.hideLayersInLegend[a.layer.id]=
a.hideLayers,this._addSubLayersToHide(a)):this.hideLayersInLegend[a.layer.id]=[],a.hoverLabel&&(a.layer._hoverLabel=a.hoverLabel),a.hoverLabels&&(a.layer._hoverLabels=a.hoverLabels),this.layers.push(a.layer))},this)):this.useAllMapLayers&&(this.layers=this.layerInfos=null);for(a=this.domNode.children.length-1;0<=a;a--)c.destroy(this.domNode.children[a]);this._removeHoverHandlers();this.startup()}},_legendUrl:"http://utility.arcgis.com/sharing/tools/legend",_initialize:function(){this.layerInfos&&
(this.layers=[],b.forEach(this.layerInfos,function(a){this._isSupportedLayerType(a.layer)&&(a.title&&(a.layer._titleForLegend=a.title),a.layer._hideDefaultSymbol=!1===a.defaultSymbol?!0:!1,a.hideLayers?(this.hideLayersInLegend[a.layer.id]=a.hideLayers,this._addSubLayersToHide(a)):this.hideLayersInLegend[a.layer.id]=[],a.hoverLabel&&(a.layer._hoverLabel=a.hoverLabel),a.hoverLabels&&(a.layer._hoverLabels=a.hoverLabels),this.layers.push(a.layer))},this));this.useAllMapLayers=!1;if(!this.layers){this.useAllMapLayers=
!0;this.layers=[];var a=[],e=[];b.forEach(this.map.layerIds,function(c){c=this.map.getLayer(c);var n;this._isSupportedLayerType(c)&&(c.arcgisProps&&c.arcgisProps.title&&(c._titleForLegend=c.arcgisProps.title),this.layers.push(c));"esri.layers.KMLLayer"==c.declaredClass&&(n=c.getLayers(),b.forEach(n,function(b){a.push(b.id)},this));"esri.layers.GeoRSSLayer"==c.declaredClass&&(n=c.getFeatureLayers(),b.forEach(n,function(a){e.push(a.id)},this))},this);b.forEach(this.map.graphicsLayerIds,function(c){var n=
this.map.getLayer(c);-1==b.indexOf(a,c)&&-1==b.indexOf(e,c)&&this._isSupportedLayerType(n)&&this._isLayerDrawingEnabled(n)&&(n.arcgisProps&&n.arcgisProps.title&&(n._titleForLegend=n.arcgisProps.title),this.layers.push(n))},this)}this._createLegend()},_isLayerDrawingEnabled:function(a){return a&&(a._params&&a._params.drawMode||a.isFeatureReductionActive&&a.isFeatureReductionActive())},_activate:function(){this._deactivate();this.autoUpdate&&(this._respectCurrentMapScale&&(this._ozeConnect=g.connect(this.map,
"onZoomEnd",this,"_refreshLayers")),this.useAllMapLayers&&(this._olaConnect=g.connect(this.map,"onLayerAdd",this,"_updateAllMapLayers"),this._olrConnect=g.connect(this.map,"onLayerRemove",this,"_updateAllMapLayers"),this._olroConnect=g.connect(this.map,"onLayersReordered",this,"_updateAllMapLayers")),b.forEach(this.layers,function(a){var b={};b.oarcConnect=g.connect(a,"onFeatureReductionRendererChange",this,"_refreshLayers");b.oaicConnect=g.connect(a,"onFeatureReductionChange",this,"_refreshLayers");
b.ovcConnect=g.connect(a,"onVisibilityChange",this,"_refreshLayers");b.oocConnect=g.connect(a,"onOpacityChange",this,"_refreshLayers");b.oscConnect=g.connect(a,"onScaleRangeChange",this,"_refreshLayers");"esri.layers.ArcGISDynamicMapServiceLayer"===a.declaredClass&&a.supportsDynamicLayers&&(b.odcConnect=g.connect(a,"_onDynamicLayersChange",d.hitch(this,"_updateDynamicLayers",a)));"esri.layers.ArcGISImageServiceLayer"===a.declaredClass&&(b.oirConnect=g.connect(a,"onRenderingChange",d.partial(this._updateImageServiceLayers,
this,a)),b.oivrConnect=g.connect(a,"onRendererChange",d.partial(this._updateImageServiceLayers,this,a)));"esri.layers.ArcGISImageServiceVectorLayer"===a.declaredClass&&(b.oivrConnect=g.connect(a,"onRendererChange",d.hitch(this,"_refreshLayers")));this.layerConnects[a.id]=b},this))},_deactivate:function(){this._ozeConnect&&g.disconnect(this._ozeConnect);this._olaConnect&&g.disconnect(this._olaConnect);this._olroConnect&&g.disconnect(this._olroConnect);this._olrConnect&&g.disconnect(this._olrConnect);
b.forEach(this.layers,function(a){a=this.layerConnects[a.id]||{};a.oarcConnect&&g.disconnect(a.oarcConnect);a.oaicConnect&&g.disconnect(a.oaicConnect);a.ovcConnect&&g.disconnect(a.ovcConnect);a.oocConnect&&g.disconnect(a.oocConnect);a.oscConnect&&g.disconnect(a.oscConnect);a.odcConnect&&g.disconnect(a.odcConnect);a.oirConnect&&g.disconnect(a.oirConnect);a.oivrConnect&&g.disconnect(a.oivrConnect)},this);this.layerConnects=[]},_updateDynamicLayers:function(a){delete a.legendResponse;this._refreshLayers()},
_updateImageServiceLayers:function(a,b){delete b.legendResponse;a._refreshLayers()},_refreshLayers:function(){this.refresh()},_updateAllMapLayers:function(){this.layers=[];b.forEach(this.map.layerIds,function(a){a=this.map.getLayer(a);this._isSupportedLayerType(a)&&this.layers.push(a)},this);b.forEach(this.map.graphicsLayerIds,function(a){a=this.map.getLayer(a);this._isSupportedLayerType(a)&&this._isLayerDrawingEnabled(a)&&this.layers.push(a)},this);this.refresh()},_createLegend:function(){var a=
!1,e=!1;x.set(this.domNode,"position","relative");c.create("div",{id:this.id+"_msg",className:"esriLegendMsg",innerHTML:this.NLS_creatingLegend+"..."},this.domNode);var n=[];b.forEach(this.layers,function(h){if("esri.layers.KMLLayer"==h.declaredClass||"esri.layers.GeoRSSLayer"==h.declaredClass){var p;h.loaded?("esri.layers.KMLLayer"==h.declaredClass?p=h.getLayers():"esri.layers.GeoRSSLayer"==h.declaredClass&&(p=h.getFeatureLayers(),this.hideLayersInLegend[h.id]&&(p=b.filter(p,function(a){return-1==
b.indexOf(this.hideLayersInLegend[h.id],a.id)},this))),b.forEach(p,function(a){"esri.layers.FeatureLayer"==a.declaredClass&&h._titleForLegend&&(a._titleForLegend=h._titleForLegend+" - ","esriGeometryPoint"==a.geometryType?a._titleForLegend+=this.NLS_points:"esriGeometryPolyline"==a.geometryType?a._titleForLegend+=this.NLS_lines:"esriGeometryPolygon"==a.geometryType&&(a._titleForLegend+=this.NLS_areas),n.push(a))},this)):g.connect(h,"onLoad",d.hitch(this,function(){this.refresh(this.layerInfos)}))}else if("esri.layers.WMSLayer"===
h.declaredClass)if(!h.loaded)g.connect(h,"onLoad",d.hitch(this,function(){this.refresh(this.layerInfos)}));else{if((!this._respectVisibility||this._respectVisibility&&h.visible)&&0<h.layerInfos.length&&b.some(h.layerInfos,function(a){return a.legendURL})){var f=!1;b.forEach(h.layerInfos,function(e){if(e.legendURL&&-1<b.indexOf(h.visibleLayers,e.name)){f||(c.create("div",{innerHTML:"\x3cspan class\x3d'esriLegendServiceLabel'\x3e"+(h._titleForLegend||h.name||h.id)+"\x3c/span\x3e"},this.domNode),f=!0);
var n;e=e.legendURL;if(h.customParameters||h.customLayerParameters){var p=d.clone(h.customParameters||{});d.mixin(p,h.customLayerParameters||{});for(n in p)e+=(-1===e.indexOf("?")?"?":"\x26")+n+"\x3d"+p[n]}c.create("div",{innerHTML:"\x3cimg src\x3d'"+e+"'/\x3e"},this.domNode);a=!0}},this)}}else"esri.layers.WFSLayer"!==h.declaredClass||h.renderer?n.push(h):(p=c.create("div",{id:this.id+"_"+h.id,"class":"esriLegendService"}),c.create("span",{innerHTML:this._getServiceTitle(h),"class":"esriLegendServiceLabel"},
c.create("td",{align:this._align},c.create("tr",{},c.create("tbody",{},c.create("table",{width:"95%"},p))))),c.place(p,this.id,"first"),p=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},p),p=c.create("tbody",{},p),"esriGeometryComplex"===h.geometryType?(this._buildRow_Renderer(h,h._pointSymbol,null,this.NLS_points,null,p),this._buildRow_Renderer(h,h._lineSymbol,null,this.NLS_lines,null,p),this._buildRow_Renderer(h,h._polygonSymbol,null,this.NLS_areas,null,p)):
"esriGeometryPoint"===h.geometryType?this._buildRow_Renderer(h,h._pointSymbol,null,"",null,p):"esriGeometryPolyline"===h.geometryType?this._buildRow_Renderer(h,h._lineSymbol,null,"",null,p):"esriGeometryPolygon"===h.geometryType&&this._buildRow_Renderer(h,h._polygonSymbol,null,"",null,p),e=!0)},this);var p=[];b.forEach(n,function(a){if(!a.loaded)var b=g.connect(a,"onLoad",this,function(a){g.disconnect(b);b=null;this.refresh()});else if((!this._respectVisibility||this._respectVisibility&&a.visible)&&
(a.layerInfos||a.renderer||"esri.layers.ArcGISImageServiceLayer"==a.declaredClass)){var e=c.create("div",{id:this.id+"_"+a.id,style:{display:"none"},"class":"esriLegendService"});c.create("span",{innerHTML:this._getServiceTitle(a),"class":"esriLegendServiceLabel"},c.create("td",{align:this._align},c.create("tr",{},c.create("tbody",{},c.create("table",{width:"95%"},e)))));c.place(e,this.id,"first");a.legendResponse||a.renderer&&"esri.renderer.StretchRenderer"!==a.renderer.declaredClass?this._createLegendForLayer(a):
this.isHostedTileService(a)?this._getLayerInfos(a).then(d.hitch(this,function(a){this._createLegendForLayer(a)}),d.hitch(this,function(a){p.push(this._legendRequest(a))})):p.push(this._legendRequest(a))}},this);0!==p.length||a||e?(new C(p)).addCallback(d.hitch(this,function(b){a||e?u.byId(this.id+"_msg").innerHTML="":u.byId(this.id+"_msg").innerHTML=this.NLS_noLegend;this._activate()})):(u.byId(this.id+"_msg").innerHTML=this.NLS_noLegend,this._activate())},_createLegendForLayer:function(a){if(a.legendResponse||
a.renderer||this.isHostedTileService(a)){var e=!1;if(a.legendResponse||this.isHostedTileService(a)){var c=a.dynamicLayerInfos||a.layerInfos;c&&c.length?b.forEach(c,function(c,n){if(!this.hideLayersInLegend[a.id]||-1===b.indexOf(this.hideLayersInLegend[a.id],c.id)){var h=this._buildLegendItems(a,c,n);e=e||h}},this):"esri.layers.ArcGISImageServiceLayer"==a.declaredClass&&(e=this._buildLegendItems(a,{id:0,name:null,title:a.name,subLayerIds:null,parentLayerId:-1},0))}else a.renderer&&(c=a.url?a.url.substring(a.url.lastIndexOf("/")+
1,a.url.length):"fc_"+a.id,e=this._buildLegendItems(a,{id:c,name:null,subLayerIds:null,parentLayerId:-1},0));e&&(x.set(u.byId(this.id+"_"+a.id),"display","block"),x.set(u.byId(this.id+"_msg"),"display","none"))}},_legendRequest:function(a){if(a.loaded)return 10.01<=a.version?this._legendRequestServer(a):this._legendRequestTools(a);g.connect(a,"onLoad",d.hitch(this,"_legendRequest"))},_legendRequestServer:function(a){var e=a.url,c=e.indexOf("?"),e=-1<c?e.substring(0,c)+"/legend"+e.substring(c):e+"/legend";
(c=a._getToken())&&(e+="?token\x3d"+c);var p=d.hitch(this,"_processLegendResponse"),h={f:"json"};a._params.dynamicLayers&&(h.dynamicLayers=E.stringify(this._createDynamicLayers(a)),"[{}]"===h.dynamicLayers&&(h.dynamicLayers="[]"));a._params.bandIds&&(h.bandIds=a._params.bandIds);a._params.renderingRule?h.renderingRule=a._params.renderingRule:a.rasterFunctionInfos&&0<a.rasterFunctionInfos.length&&b.forEach(a.rasterFunctionInfos,function(a){a&&a.name&&"none"===a.name.toLowerCase()&&(h.renderingRule=
E.stringify({rasterFunction:a.name}))});return L({url:e,content:h,callbackParamName:"callback",load:function(b,e){p(a,b,e)},error:F.defaults.io.errorHandler})},_legendRequestTools:function(a){var b=a.url.toLowerCase().indexOf("/rest/"),b=a.url.substring(0,b)+a.url.substring(b+5,a.url.length),b=this._legendUrl+"?soapUrl\x3d"+window.escape(b);if(!f("ie")||8<f("ie"))b+="\x26returnbytes\x3dtrue";var c=d.hitch(this,"_processLegendResponse");return L({url:b,content:{f:"json"},callbackParamName:"callback",
load:function(b,e){c(a,b,e)},error:F.defaults.io.errorHandler})},_processLegendResponse:function(a,b){b&&b.layers?(a.legendResponse=b,u.byId(this.id+"_"+a.id)&&c.empty(u.byId(this.id+"_"+a.id)),c.create("span",{innerHTML:this._getServiceTitle(a),"class":"esriLegendServiceLabel"},c.create("td",{align:this._align},c.create("tr",{},c.create("tbody",{},c.create("table",{width:"95%"},u.byId(this.id+"_"+a.id)))))),this._createLegendForLayer(a)):console.log("Legend could not get generated for "+a.url+": "+
w.toJson(b))},_buildLegendItems:function(a,e,n){var p=!1,h=u.byId(this.id+"_"+a.id),d=e.parentLayerId;if(e.subLayerIds)a=c.create("div",{id:this.id+"_"+a.id+"_"+e.id+"_group",style:{display:"none"},"class":-1==d?0<n?"esriLegendGroupLayer":"":this._legendAlign},-1==d?h:u.byId(this.id+"_"+a.id+"_"+d+"_group")),c.create("td",{innerHTML:A.encode(e.name),align:this._align},c.create("tr",{},c.create("tbody",{},c.create("table",{width:"95%","class":"esriLegendLayerLabel"},a))));else{if(this._respectVisibility&&
a.visibleLayers)if(n=a.dynamicLayerInfos||a.layerInfos)if(a._params&&a._params.layers){if(-1===b.indexOf(a.visibleLayers,e.id))return p}else{if(n=this._getReallyVisibleLayers(n,a.visibleLayers),-1===b.indexOf(n,e.id))return p}else if(-1===b.indexOf(a.visibleLayers,e.id))return p;h=c.create("div",{id:this.id+"_"+a.id+"_"+e.id,style:{display:"none"},"class":-1<d?this._legendAlign:""},-1==d?h:u.byId(this.id+"_"+a.id+"_"+d+"_group"));c.create("td",{innerHTML:A.encode(e.name)||"",align:this._align},c.create("tr",
{},c.create("tbody",{},c.create("table",{width:"95%","class":"esriLegendLayerLabel"},h))));n=a.dynamicLayerInfos||a.layerInfos;d=!1;n&&n.length&&(d=b.some(n,function(a){return!!a.drawingInfo}));if(a.legendResponse)p=p||this._buildLegendItems_Tools(a,e,h);else if(a.renderer||d)p=p||this._buildLegendItems_Renderer(a,e,h)}return p},_getReallyVisibleLayers:function(a,e){if(!a||!e||!e.length)return[];var c=[],p=[],h;for(h=0;h<a.length;h++)if(a[h].subLayerIds){if(-1===b.indexOf(e,a[h].id)||-1<b.indexOf(p,
a[h].id))p=p.concat(a[h].subLayerIds)}else-1<b.indexOf(e,a[h].id)&&-1===b.indexOf(p,a[h].id)&&c.push(a[h].id);return c},_buildLegendItems_Tools:function(a,e,n){var p=e.parentLayerId,h=this.map.getScale(),d=!1,f=function(a,b){var e,c;for(e=0;e<a.length;e++)if(b.dynamicLayerInfos)for(c=0;c<b.dynamicLayerInfos[c].length;c++){if(b.dynamicLayerInfos[c].mapLayerId==a[e].layerId)return a[e]}else if(b.id==a[e].layerId)return a[e];return{}};if(!this._respectCurrentMapScale||this._respectCurrentMapScale&&this._isLayerInScale(a,
e,h)){var g=!0;if(this._respectCurrentMapScale&&("esri.layers.ArcGISDynamicMapServiceLayer"===a.declaredClass||"esri.layers.ArcGISMapServiceLayer"===a.declaredClass)){var k=this._getEffectiveScale(a,e);if(k.minScale&&k.minScale<h||k.maxScale&&k.maxScale>h)g=!1}if(g){var h=f(a.legendResponse.layers,e),l=h.legendType,t=h.layerType,m=h.legend;if(m){"esri.layers.ArcGISImageServiceLayer"!==a.declaredClass&&this._sanitizeLegendResponse(a,h,e);n=c.create("table",{cellpadding:0,cellspacing:0,width:"95%",
"class":"esriLegendLayer"},n);var q=c.create("tbody",{},n);(a._hoverLabel||a._hoverLabels)&&this._createHoverAction(n,a,e);var r=[];b.forEach(m,function(c){if(!(10.1<=a.version&&!c.values&&1<m.length)||!a._hideDefaultSymbol&&"\x3call other values\x3e"!==c.label&&(c.label||"esri.layers.ArcGISImageServiceLayer"===a.declaredClass&&10.3<=a.version||"Raster Layer"===t)){var n=c.label;if(c.url&&0===c.url.indexOf("http")||c.imageData&&0<c.imageData.length)d=!0,n&&-1!==b.indexOf(r,n)||(r.push(n),this._buildRow_Tools(c,
q,a,e.id,l))}},this)}}}d&&(x.set(u.byId(this.id+"_"+a.id+"_"+e.id),"display","block"),-1<p&&(x.set(u.byId(this.id+"_"+a.id+"_"+p+"_group"),"display","block"),this._findParentGroup(a.id,a,p)));return d},_getLayerInfos:function(a){var c=new y,n=a.dynamicLayerInfos||a.layerInfos;if(n&&n.length)if(b.some(n,function(a){return!!a.drawingInfo}))c.resolve(a);else{var p=a.url,h=p.indexOf("?"),p=-1==h?p+"/layers":p.substring(0,h)+"/layers"+p.substring(h,p.length);L({url:p,content:{f:"json"},callbackParamName:"callback",
load:function(e,h){e.layers?(b.forEach(n,function(a){var c=b.filter(e.layers,function(b){return a.source?b.id===a.source.mapLayerId:b.id===a.id});c&&c[0]&&c[0].drawingInfo&&(a.drawingInfo=c[0].drawingInfo,a.fields=c[0].fields)}),c.resolve(a)):c.reject(a)},error:function(b){c.reject(a)}})}return c},_sanitizeLegendResponse:function(a,c,n){var e=c.legend;if(10.1<=a.version&&1<e.length&&!c._sanitized){a=d.getObject("layerDefinition.drawingInfo.renderer",!1,n);var h,f;a||(a=d.getObject("drawingInfo.renderer",
!1,n));b.some(e,function(a){if(a.values)return!0})&&b.some(e,function(a,b){a.values||(f=b,h=a);return!!h});a?"uniqueValue"===a.type?h&&(e.splice(f,1),e.push(h)):"classBreaks"===a.type&&(h&&e.splice(f,1),e.reverse(),h&&e.push(h)):h&&(e.splice(f,1),e.push(h));c._sanitized=!0}},_buildRow_Tools:function(a,b,n,p,h){var e=c.create("tr",{},b),d;this.alignRight?(b=c.create("td",{align:this._isRightToLeft?"left":"right"},e),d=c.create("td",{align:this._isRightToLeft?"left":"right",width:35},e)):(d=c.create("td",
{width:35,align:"center"},e),b=c.create("td",{},e));e=a.url;(!f("ie")||9<=f("ie")||9>f("ie")&&"esri.layers.ArcGISImageServiceLayer"===n.declaredClass)&&a.imageData&&0<a.imageData.length?e="data:image/png;base64,"+a.imageData:0!==a.url.indexOf("http")&&(e=n.url+"/"+p+"/images/"+a.url,(p=n._getToken())&&(e+="?token\x3d"+p));p=c.create("img",{src:e,border:0,style:"opacity:"+n.opacity},d);a=c.create("td",{innerHTML:A.encode(a.label),align:this._align},c.create("tr",{},c.create("tbody",{},c.create("table",
{width:"95%",dir:"ltr"},b))));h&&"Stretched"===h&&10.3<=n.version&&"esri.layers.ArcGISImageServiceLayer"===n.declaredClass&&(a.style.verticalAlign="top",a.style.lineHeight="1",p.style.marginBottom="-1px",p.style.display="block",b.style.verticalAlign="top");9>f("ie")&&(p.style.filter="alpha(opacity\x3d"+100*n.opacity+")")},_getVariable:function(a,b,c){var e;a&&(e=(a=a.getVisualVariablesForType(b,c))&&a[0]);return e},_getVariables:function(a,c,n){a=[this._getVariable(a,"colorInfo",!1),this._getVariable(a,
"opacityInfo",!1),this._getVariable(a,"sizeInfo",!1)];return c?b.filter(a,function(a){return!(!a||a.field!==c||a.normalizationField!=n)}):a},_getFieldAlias:function(a,b,c){var e=b.infoTemplate||(b.infoTemplates&&c&&b.infoTemplates[c.id]?b.infoTemplates[c.id].infoTemplate:null),e=e&&e.getFieldInfo&&e.getFieldInfo(a);a=d.isFunction(a)?null:this.getField(b,a,c);b=e||a;c="";b&&(c=e&&e.label||a&&a.alias||b.name||b.fieldName);return c},_getDomainName:function(a,b,c,p){var e;a&&!d.isFunction(a)&&(e=(c=(a=
this.getField(c,a,p))&&c.getDomain?c.getDomain(a.name):null)&&c.codedValues?c.getName(b):null);return e},_getRampTitle:function(a,b,c){var e,h=a.field,n=a.normalizationField,f=!1,g=!1,k=!1,h=d.isFunction(h)?null:h,n=d.isFunction(n)?null:n;if(a.legendOptions&&a.legendOptions.title)e=a.legendOptions.title;else if(a.valueExpressionTitle)e=a.valueExpressionTitle;else{if(b.renderer&&b.renderer.authoringInfo&&b.renderer.authoringInfo.visualVariables){var l=b.renderer.authoringInfo.visualVariables;for(a=
0;a<l.length;a++){var t=l[a];if("colorInfo"===t.type&&"ratio"===t.style){f=!0;break}else if("colorInfo"===t.type&&"percent"===t.style){g=!0;break}else if("colorInfo"===t.type&&"percentTotal"===t.style){k=!0;break}}}(f=k&&"showRatioPercentTotal"||g&&"showRatioPercent"||f&&"showRatio"||n&&"showNormField"||h&&"showField"||null)&&(e=H.substitute({field:h&&this._getFieldAlias(h,b,c),normField:n&&this._getFieldAlias(n,b,c)},this._i18n[f]))}return e},_getRendererTitle:function(a,b,c){var e;if(a){var h,n,
f;"esri.renderer.ClassBreaksRenderer"===a.declaredClass&&(h=a.attributeField,n=a.normalizationField,f="percent-of-total"===a.normalizationType);h=d.isFunction(h)?null:h;n=d.isFunction(n)?null:n;a.legendOptions&&a.legendOptions.title?e=a.legendOptions.title:a.valueExpressionTitle?e=a.valueExpressionTitle:(a=n&&"showNormField"||(f?"showNormPct":null)||h&&"showField"||null)&&(e=H.substitute({field:h&&this._getFieldAlias(h,b,c),normField:n&&this._getFieldAlias(n,b,c)},this._i18n[a]))}return e},_buildLegendItems_Renderer:function(a,
e,n){var p=e.parentLayerId,h=this.map,f=h.getScale(),g,k=!1;if(!this._respectCurrentMapScale||this._isLayerInScale(a,e,f)){var l,m,t,q,r,v,w,y;t="esri.layers.ArcGISImageServiceVectorLayer"===a.declaredClass?a.renderer.renderer:e&&e.drawingInfo?U.fromJson(d.clone(e.drawingInfo.renderer)):a.isFeatureReductionActive&&a.isFeatureReductionActive()?a.getFeatureReductionRenderer():a.renderer;if("esri.renderer.ScaleDependentRenderer"===t.declaredClass&&(t=(h="zoom"===t.rangeType?t.getRendererInfoByZoom(h.getZoom()):
t.getRendererInfoByScale(f))&&h.renderer,!t))return!1;var B=this._getVariables(t),z=b.filter(B,function(a){return!!a}).length,f=B[0],h=B[1],B=B[2],C,E,M,D,F;f&&(q=this._getMedianColor(t,f),f.field&&(v=d.isFunction(f.field)?null:this.getField(a,f.field,e)),C=!(f.legendOptions&&!1===f.legendOptions.showLegend));h&&(h.field&&(y=d.isFunction(h.field)?null:this.getField(a,h.field,e)),E=!(h.legendOptions&&!1===h.legendOptions.showLegend));B&&(B.field&&(w=d.isFunction(B.field)?null:this.getField(a,B.field,
e)),M=!(B.legendOptions&&!1===B.legendOptions.showLegend));if("esri.renderer.HeatmapRenderer"===t.declaredClass)g=k=!0,this._showHeatRamp(a,e,t,n);else if("esri.renderer.DotDensityRenderer"===t.declaredClass)g=k=!0,this._showDotDensityLegend(a,e,t,n);else if("esri.renderer.TemporalRenderer"===t.declaredClass)g=k=!0,m=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},n),l=c.create("tbody",{},m),(a._hoverLabel||a._hoverLabels)&&this._createHoverAction(m,a,e),t.latestObservationRenderer&&
"esri.renderer.SimpleRenderer"===t.latestObservationRenderer.declaredClass&&this._buildRow_Renderer(a,t.latestObservationRenderer.symbol,q,A.encode(t.latestObservationRenderer.label)||this.NLS_currentObservations,null,l),t.observationRenderer&&"esri.renderer.SimpleRenderer"===t.observationRenderer.declaredClass&&this._buildRow_Renderer(a,t.observationRenderer.symbol,q,A.encode(t.observationRenderer.label)||this.NLS_previousObservations,null,l);else if("esri.renderer.UniqueValueRenderer"===t.declaredClass){if(t.infos&&
0<t.infos.length){g=k=!0;if(t.legendOptions&&t.legendOptions.title||t.valueExpressionTitle)m=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},n),l=c.create("tbody",{},m),z=t.legendOptions&&t.legendOptions.title?t.legendOptions.title:t.valueExpressionTitle,this._buildRow_Renderer(a,null,q,A.encode(z),null,l);m=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},n);l=c.create("tbody",{},m);(a._hoverLabel||a._hoverLabels)&&this._createHoverAction(m,
a,e);t.attributeField&&B&&this._addSubHeader(l,this._getFieldAlias(t.attributeField,a,e));var G=[];b.forEach(t.infos,function(c){var n=null;a._editable&&a.types&&(n=this._getTemplateFromTypes(a.types,c.value));var h=c.label;null==h&&(h=this._getDomainName(t.attributeField,c.value,a,e)||c.value);-1===b.indexOf(G,h)&&(G.push(h),this._buildRow_Renderer(a,c.symbol,q,A.encode(h),n,l))},this)}F=this._displayDefaultSymbol(a,t,n)}else if("esri.renderer.ClassBreaksRenderer"===t.declaredClass){if(t.infos&&
0<t.infos.length||"esri.layers.ArcGISImageServiceVectorLayer"===a.declaredClass)g=k=!0,D=this._isUnclassedRenderer(t),f||1!==t.infos.length||(r=(r=t.infos[0])&&r.symbol),D||(m=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},n),l=c.create("tbody",{},m),z=this._getRendererTitle(t,a,e),this._buildRow_Renderer(a,null,q,A.encode(z),null,l)),m=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},n),l=c.create("tbody",{},m),(a._hoverLabel||
a._hoverLabels)&&this._createHoverAction(m,a,e),D&&B&&M||(z=t.infos.slice(0).reverse(),b.forEach(z,function(b){var c=b.label;null!=c||D||(c=b.minValue+" - "+b.maxValue);this._buildRow_Renderer(a,b.symbol,q,A.encode(c),null,l)},this)),"esri.layers.ArcGISImageServiceVectorLayer"!==a.declaredClass||a.renderer.style!==Q.STYLE_SCALAR&&a.renderer.style!==Q.STYLE_SINGLE_ARROW||(this._buildRow_Renderer(a,t.defaultSymbol,null,"",null,l),a._hideDefaultSymbol=!0);D||(F=this._displayDefaultSymbol(a,t,n))}else"esri.renderer.SimpleRenderer"===
t.declaredClass&&(g=k=!0,m=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},n),l=c.create("tbody",{},m),(a._hoverLabel||a._hoverLabels)&&this._createHoverAction(m,a,e),r=null,a._editable&&a.templates&&0<a.templates.length&&(r=a.templates[0]),m=1<z?null:v&&C||y&&E||w&&M,this._buildRow_Renderer(a,t.symbol,q,A.encode(m?this._getRampTitle(1<z?null:f||h||B,a,e):t.label),r,l),r=f?null:t.symbol,m&&(v=y=w=null));g&&(f&&C&&(f.field||f.valueExpression)&&this._showGradientRamp(a,
e,t,null,n,f,v,null,B&&M?!0:!1),B&&M&&(B.field||B.valueExpression)&&(g=f&&C||"esri.renderer.UniqueValueRenderer"===t.declaredClass?!1:!0,this._showSizeLegend(a,e,t,B,q,n,w,null,g)),h&&E&&(h.field||h.valueExpression)&&this._showGradientRamp(a,e,t,r&&!r.url&&r.color?r.color:this.transparencyRampColor,n,h,y,null,!1));F||D&&!C&&!M&&!E||(F=this._displayDefaultSymbol(a,t,n));k=k||F}k&&(x.set(u.byId(this.id+"_"+a.id+"_"+e.id),"display","block"),-1<p&&(x.set(u.byId(this.id+"_"+a.id+"_"+p+"_group"),"display",
"block"),this._findParentGroup(a.id,p)));return k},_isUnclassedRenderer:function(a,b){var c;if("esri.renderer.ClassBreaksRenderer"===a.declaredClass&&a.infos&&1===a.infos.length){c=a.attributeField;var e=a.normalizationField;c=b?c===b:!!this._getVariables(a,c,e).length}return c},_displayDefaultSymbol:function(a,b,n){var e;!a._hideDefaultSymbol&&b.defaultSymbol&&(e=!0,n=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},n),n=c.create("tbody",{},n),this._buildRow_Renderer(a,
b.defaultSymbol,null,A.encode(b.defaultLabel)||"others",null,n));return e},_showGradientRamp:function(a,b,n,p,h,f,g,k,l){l=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"+(l?"":" esriLegendSubFragment")},h);h=c.create("tbody",{},l);(a._hoverLabel||a._hoverLabels||k)&&this._createHoverAction(l,a,b,k);(g||f.valueExpression||f.legendOptions&&f.legendOptions.title)&&this._addSubHeader(h,this._getRampTitle(f,a,b));g=f.field;var e;g&&(e=d.isFunction(g)?null:this.getField(a,
g,b));(b=this._getRampStops(n,f,p,e&&"esriFieldTypeDate"===e.type))&&b.length&&this._drawGradientRamp(h,b,!0,a,this._getRampBorderColor(n),!!p)},_getMedianColor:function(a,b){var c,e;b.colors?(c=b.minDataValue,e=b.maxDataValue):b.stops&&(c=b.stops[0].value,e=b.stops[b.stops.length-1].value);return a.getColor(c+(e-c)/2,{colorInfo:b})},_getRampStops:function(a,c,n,d){var e,p,f,g,k=!1;c.colors||c.opacityValues?(p=c.maxDataValue-c.minDataValue,e=b.map([0,.25,.5,.75,1],function(a){f=c.minDataValue+a*p;
return Number(f.toFixed(6))}),this._checkPrecision(0,4,e)):c.stops&&(e=b.map(c.stops,function(a){return a.value}),(k=b.some(c.stops,function(a){return!!a.label}))&&(g=b.map(c.stops,function(a){return a.label})));var l=e[0],m,q;p=e[e.length-1]-l;return b.map(e,function(b,h){n?(m=new v(n.toRgba()),q=a.getOpacity(b,{opacityInfo:c}),null!=q&&(m.a=q)):m=a.getColor(b,{colorInfo:c});var f="";if(k)f=g[h];else{var f=d?N.formatDate(b,N.timelineDateFormatOptions):z.format(b),t="";0===h?t=this._specialChars.lt+
" ":h===e.length-1&&(t=this._specialChars.gt+" ");f=t+f}return{value:b,color:m,offset:1-(b-l)/p,label:f}},this).reverse()},_checkPrecision:function(a,b,c){var e=a+(b-a)/2,h=c[a],n=c[e],d=c[b],f=Math.floor(h),g=Math.floor(n),k=Math.floor(d);f===h&&k===d&&g!==n&&f!==g&&k!==g&&(c[e]=g);a+1!==e&&this._checkPrecision(a,e,c);e+1!==b&&this._checkPrecision(e,b,c)},_getRampBorderColor:function(a){var b;if("esri.renderer.SimpleRenderer"===a.declaredClass)b=a.symbol;else if("esri.renderer.UniqueValueRenderer"===
a.declaredClass||"esri.renderer.ClassBreaksRenderer"===a.declaredClass)b=a.infos[0].symbol;return(a=b&&-1===b.type.indexOf("linesymbol")?b.getStroke():null)&&a.color},_drawGradientRamp:function(a,e,n,d,h,g){var p=c.create("tr",{},a),k,l,m,t,q,r=e.length-1,I;t=0;this.alignRight?(a=c.create("td",{align:this._isRightToLeft?"left":"right"},p),k=c.create("td",{align:this._isRightToLeft?"left":"right",width:this.gradientWidth},p)):(k=c.create("td",{width:this.gradientWidth,align:"center"},p),a=c.create("td",
{},p));p=h&&0<h.a&&!(240<=h.r&&240<=h.g&&240<=h.b);l=c.create("div",{"class":p?"":"esriLegendBorderLessColorRamp",style:"position: relative; width:"+this.gradientWidth+"px;"},k);k=c.create("div",{"class":"esriLegendColorRamp"+(g?" esriLegendTransparencyRamp":"")},l);g=x.get(k,"width");p&&(h=9>f("ie")?h.toHex():"rgba("+h.toRgba().join(",")+")",x.set(k,"border",this.colorRampBorder+" "+h));n?(h=this.gradientHeight*r,x.set(k,"height",h+"px")):h=x.get(k,"height");x.set(l,"height",h+"px");p=K.createSurface(k,
g,h);9>f("ie")&&(t=p.getEventSource(),x.set(t,"position","relative"),x.set(t.parentNode,"position","relative"),t=1);try{n&&b.forEach(e,function(a,b){a.offset=b/r}),q=p.createRect({x:-t,y:-t,width:g+t,height:h+t}),q.setFill({type:"linear",x1:0,y1:0,x2:0,y2:h,colors:e}).setStroke(null),p.createRect({width:g,height:h}).setFill(new v([255,255,255,1-d.opacity])).setStroke(null),this._surfaceItems.push(p)}catch(da){p.clear(),p.destroy()}b.forEach(e,function(a,b){if(a.label){I="top:"+100*a.offset+"%;";var h=
"";0===b&&(h+=" esriLegendColorRampTickFirst");b===e.length-1&&(h+=" esriLegendColorRampTickLast");c.create("div",{"class":"esriLegendColorRampTick"+h,innerHTML:"\x26nbsp;",style:I},l)}});m=c.create("div",{"class":"esriLegendColorRampLabels",style:{height:h+this.gradientHeight+"px"}},a);n?b.forEach(e,function(a){c.create("div",{"class":"esriLegendColorRampLabel",innerHTML:A.encode(a.label)||"\x26nbsp;"},m)}):(c.create("div",{"class":"esriLegendColorRampLabel",innerHTML:this._i18n.high},m),c.create("div",
{"class":"esriLegendColorRampLabel",innerHTML:this._i18n.low,style:"top: "+(h+this.gradientHeight-2*this.gradientHeight)+"px;"},m))},_showHeatRamp:function(a,b,n,d,h){var e,p=n.field;e=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},d);d=c.create("tbody",{},e);(a._hoverLabel||a._hoverLabels||h)&&this._createHoverAction(e,a,b,h);(p=p&&this.getField(a,p,b))&&this._addSubHeader(d,this._getFieldAlias(p.name,a,b));b=this._getHeatmapStops(n);b.length&&this._drawGradientRamp(d,
b,!1,a)},_getHeatmapStops:function(a){var c=a.colorStops;a=a.colors;var n,d,h,f;c&&c[0]?(n=c.length-1,(a=c[0]&&null!=c[0].ratio)?(a=c[n])&&1!==a.ratio&&(c=c.slice(0),c.push({ratio:1,color:a.color}),n++):(d=c[0].value,h=c[n].value-d,c=b.map(c,function(a){return{color:a.color,ratio:(a.value-d)/h}}))):a&&a[0]&&(n=a.length-1,f=1/(a.length-1),c=b.map(a,function(a,b){return{color:a,ratio:b*f}}));c=b.map(c,function(a,b){var c="";0===b?c="Low":b===n&&(c="High");return{color:a.color,label:c,offset:1-a.ratio}});
return c.reverse()},_showDotDensityLegend:function(a,e,n,p){var h=n.legendOptions,f,g,k,l,m,t,q,r=this.dotDensitySwatchSize,u=Math.round(r/2);h&&(g=h.backgroundColor,k=h.outline,l=h.valueUnit,m=h.dotCoverage);m=(m||this.dotCoverage)/100;q=Math.round(r*r/Math.pow(n.dotSize,2)*m);p=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"},p);t=c.create("tbody",{},p);(a._hoverLabel||a._hoverLabels)&&this._createHoverAction(p,a,e);this._addSubHeader(t,H.substitute({value:n.dotValue,
unit:l||""},this.NLS_dotValue));b.forEach(n.fields,function(b){b=d.mixin({},b);b.numPoints=q;f=new S(n._generateImageSrc(r,r,[b],{x:0,y:0},{x:r,y:r},g),k||n.outline,r,r);b=this.getField(a,b.name,e)||b;this._buildRow_Renderer(a,f,null,A.encode(this._getFieldAlias(b.name,a,e)),null,t,{type:"path",path:"M "+-u+","+-u+" L "+u+","+-u+" L "+u+","+u+" L "+-u+","+u+" L "+-u+","+-u+" E"})},this)},_showSizeLegend:function(a,b,n,p,h,f,g,k,l){var e=p.legendOptions,e=e&&e.customValues;h=this._getSizeSymbol(n,
h);if((!p.valueUnit||"unknown"===p.valueUnit)&&h&&(e||null!=p.minSize&&null!=p.maxSize&&null!=p.minDataValue&&null!=p.maxDataValue||p.stops&&!(1>=p.stops.length))){l=c.create("table",{cellpadding:0,cellspacing:0,width:"95%","class":"esriLegendLayer"+(l?"":" esriLegendSubFragment")},f);f=c.create("tbody",{},l);(a._hoverLabel||a._hoverLabels||k)&&this._createHoverAction(l,a,b,k);(g||p.valueExpression||p.legendOptions&&p.legendOptions.title)&&this._addSubHeader(f,this._getRampTitle(p,a,b));g=p.field;
var m;k=d.isFunction(g);g&&(m=k?null:a.isFeatureReductionActive&&a.isFeatureReductionActive()?a.getFeatureReductionField(g):this.getField(a,g,b));b=m&&"esriFieldTypeDate"===m.type;var e=e||this._getDataValues(n,h,p,b),q,r=e.length-1;for(m=r;0<=m;m--)l=e[m],h=O.fromJson(h.toJson()),this._applySize(h,n,p,l),l=b?N.formatDate(l,N.timelineDateFormatOptions):z.format(l),q="",m===r?q=this._specialChars.gt+" ":0===m&&(q=g&&!k&&"cluster_count"===g.toLowerCase()&&1===e[m]?"":this._specialChars.lt+" "),q="\x3cspan class\x3d'esriLegendSizeRampLabel'\x3e"+
A.encode(q+l)+"\x3c/span\x3e",this._buildRow_Renderer(a,h,null,q,null,f)}},_getSizeSymbol:function(a,b){var c,e;if("esri.renderer.SimpleRenderer"===a.declaredClass)c=a.symbol;else if("esri.renderer.VectorFieldRenderer"===a.declaredClass)c=a.defaultSymbol;else if("esri.renderer.UniqueValueRenderer"===a.declaredClass||"esri.renderer.ClassBreaksRenderer"===a.declaredClass)c=a.infos[0].symbol,e=1<a.infos.length;if(c=c&&-1!==c.type.indexOf("fillsymbol")?null:c)if(c=O.fromJson(c.toJson()),b||e)-1!==c.type.indexOf("linesymbol")?
c.setColor(new v(this.sizeRampDarkColor)):(c.setColor(new v(this.sizeRampLightColor)),c.setOutline&&(e=new T,e.setColor(new v(this.sizeRampDarkColor)),e.setWidth(1.5),c.setOutline(e)));return c},_getDataValues:function(a,c,d,f,h,g){h=null==h?5:h;g=null==g?20:g;var e=a.getSizeRangeAtScale(d,this.map.getScale());h=this._interpolateSizeRange(e,h);var n=this._getDataRange(d),p=b.map(h,function(a){return this._getDataValueFromSize(a,n,e)},this);if(!f){var k,p=z.round(p);for(f=1;f<p.length-1;f++)if(k=this._roundDataValue(a,
c,d,p[f],p[f-1],g))p[f]=k[0],h[f]=k[1]}return p},_getDataRange:function(a){var b=a.stops;return b?{min:b[0].value,max:b[b.length-1].value}:{min:a.minDataValue,max:a.maxDataValue}},_interpolateSizeRange:function(a,b){var c=a.minSize,e=(a.maxSize-c)/(b-1),h,d=[];for(h=0;h<b;h++)d.push(c+e*h);return d},_getDataValueFromSize:function(a,b,c){var e=c.minSize;c=c.maxSize;var h=b.min;b=b.max;return a<=e?h:a>=c?b:(a-e)/(c-e)*(b-h)+h},_roundDataValue:function(a,b,c,d,h,f){var e=this._getSize(b,a,c,d);h=this._getSize(b,
a,c,h);var n,g=z.getDigits(d),p=g.integer,g=g.fractional,k,l,m,q,r,u,v,w,I,x,y;0<d&&1>d&&(n=Math.pow(10,g),d*=n,p=z.getDigits(d).integer);for(--p;0<=p&&(k=Math.pow(10,p),g=Math.floor(d/k)*k,k*=Math.ceil(d/k),null!=n&&(g/=n,k/=n),l=(g+k)/2,l=z.round([g,l,k],{indexes:[1]})[1],m=this._getSize(b,a,c,g),q=this._getSize(b,a,c,k),r=this._getSize(b,a,c,l),u=z.getPctChange(e,m,h,null),v=z.getPctChange(e,q,h,null),w=z.getPctChange(e,r,h,null),I=u.prev<=f,x=v.prev<=f,I&&x&&(u.prev<=v.prev?(I=!0,x=!1):(x=!0,
I=!1)),I?y=[g,m]:x?y=[k,q]:w.prev<=f&&(y=[l,r]),!y);p--);return y},_applySize:function(a,b,c,d){var e=a.type;b=this._getSize(a,b,c,d);switch(e){case "simplemarkersymbol":a.setSize(b);break;case "picturemarkersymbol":e=a.width;c=a.height;a.setHeight(b);a.setWidth(e/c*b);break;case "simplelinesymbol":case "cartographiclinesymbol":a.setWidth(b);break;case "textsymbol":a.font&&a.font.setSize(b)}},_getSize:function(a,b,c,d){return b.getSize(d,{sizeInfo:c,scale:this.map.getScale(),shape:-1!==a.type.indexOf("markersymbol")?
a.style:null})},_buildRow_Renderer:function(a,b,d,f,h,g,k){var e=c.create("tr",{},g),n;this.alignRight?(g=c.create("td",{align:this._isRightToLeft?"left":"right"},e),b&&(n=c.create("td",{align:this._isRightToLeft?"left":"right",width:35},e))):(b&&(n=c.create("td",{width:35,align:"center"},e)),g=c.create("td",{},e));var p=e=30,l;if(b){if("simplemarkersymbol"==b.type)e=Math.min(Math.max(e,b.size+12),125),p=Math.min(Math.max(p,b.size+12),125);else if("picturemarkersymbol"==b.type)e=Math.min(Math.max(e,
b.width),125),p=Math.min(b.height||p,125);else if("textsymbol"==b.type){var m,q;b.text||(m=b.text,q=!0,b.setText(this.defaultText));e=Math.min(Math.max(e,b.getWidth()+12),125);p=Math.min(Math.max(p,b.getHeight()+12),125);q&&b.setText(m)}l=c.create("div",{style:"width:"+e+"px;height:"+p+"px;"},n)}H.isDefined(f)&&"number"===typeof f&&(f=""+f);c.create("td",{innerHTML:f||"",align:this._align},c.create("tr",{},c.create("tbody",{},c.create("table",{width:"95%"},g))));b&&(a=this._drawSymbol(l,b,d,e,p,h,
a,k),this._surfaceItems.push(a))},_addSubHeader:function(a,b){var e=c.create("tr",{},a),e=c.create("td",{align:this._align,colspan:2},e);c.create("td",{innerHTML:A.encode(b)||"",align:this._align},c.create("tr",{},c.create("tbody",{},c.create("table",{width:"95%"},e))))},_drawSymbol:function(a,b,c,g,h,k,l,m){b=O.fromJson(b.toJson());var e=l.opacity;c&&b.setColor(new v(c.toRgba()));if("simplelinesymbol"===b.type||"cartographiclinesymbol"===b.type||"textsymbol"===b.type){if(!b.color)return;c=b.color.toRgba();
c[3]*=e;b.color.setColor(c)}else"simplemarkersymbol"===b.type||"simplefillsymbol"===b.type?(b.color&&(c=b.color.toRgba(),c[3]*=e,b.color.setColor(c)),b.outline&&b.outline.color&&(c=b.outline.color.toRgba(),c[3]*=e,b.outline.color.setColor(c))):"picturemarkersymbol"===b.type&&(a.style.opacity=e,a.style.filter="alpha(opacity\x3d("+100*e+"))");a=K.createSurface(a,g,h);9>f("ie")&&(c=a.getEventSource(),x.set(c,"position","relative"),x.set(c.parentNode,"position","relative"));k=this._getDrawingToolShape(b,
k)||O.getShapeDescriptors(b);var n,e=(c=k.defaultShape)&&"text"===c.type;try{e&&!c.text&&(c.text=this.defaultText),n=a.createShape(m||c).setFill(k.fill).setStroke(k.stroke),e&&n.setFont(k.font)}catch(ea){a.clear();a.destroy();return}var p=n.getBoundingBox();m=p.width;k=p.height;var e=-(p.x+m/2),q=-(p.y+k/2);c=a.getDimensions();e={dx:e+c.width/2,dy:q+c.height/2};if("simplemarkersymbol"===b.type&&"path"===b.style)g=l._getScaleMatrix(p,b.size),n.applyTransform(D.scaleAt(g.xx,g.yy,{x:c.width/2,y:c.height/
2}));else if(m>g||k>h)l=m/g>k/h,g=((l?g:h)-5)/(l?m:k),d.mixin(e,{xx:g,yy:g});n.applyTransform(e);return a},_getDrawingToolShape:function(a,b){var c;switch(b?b.drawingTool||null:null){case "esriFeatureEditToolArrow":c={type:"path",path:"M 10,1 L 3,8 L 3,5 L -15,5 L -15,-2 L 3,-2 L 3,-5 L 10,1 Z"};break;case "esriFeatureEditToolTriangle":c={type:"path",path:"M -10,14 L 2,-10 L 14,14 L -10,14 Z"};break;case "esriFeatureEditToolRectangle":c={type:"path",path:"M -10,-10 L 10,-10 L 10,10 L -10,10 L -10,-10 Z"};
break;case "esriFeatureEditToolCircle":c={type:"circle",cx:0,cy:0,r:10};break;case "esriFeatureEditToolEllipse":c={type:"ellipse",cx:0,cy:0,rx:10,ry:5};break;default:return null}return{defaultShape:c,fill:a.getFill(),stroke:a.getStroke()}},_repaintItems:function(){b.forEach(this._surfaceItems,function(a){this._repaint(a)},this)},_repaint:function(a){if(a){a.getStroke&&a.setStroke&&a.setStroke(a.getStroke());try{a.getFill&&a.setFill&&a.setFill(a.getFill())}catch(e){}a.children&&d.isArray(a.children)&&
b.forEach(a.children,this._repaint,this)}},_createHoverAction:function(a,b,f,k){if(k=b._hoverLabel||b._hoverLabels&&b._hoverLabels[f.id]||k)k=A.encode(k),b.mouseMoveHandler=b.mouseMoveHandler||{},b.mouseMoveHandler[f.id]=g.connect(a,"onmousemove",d.hitch(this,function(a,b){this.mouseX=b.clientX;this.mouseY=b.clientY;this.hoverLabelShowing&&(this.hoverLabelShowing=!1,x.set(u.byId(this.id+"_hoverLabel"),"display","none"));setTimeout(d.hitch(this,function(a,b,e){if(a==this.mouseX&&b==this.mouseY&&!this.hoverLabelShowing)if(this.hoverLabelShowing=
!0,u.byId(this.id+"_hoverLabel")){var d=u.byId(this.id+"_hoverLabel");d.innerHTML="\x3cspan\x3e"+e+"\x3c/span\x3e";x.set(d,"top",b+"px");x.set(d,"left",a+15+"px");x.set(d,"display","")}else c.create("div",{innerHTML:"\x3cspan\x3e"+e+"\x3c/span\x3e",id:this.id+"_hoverLabel","class":"esriLegendHoverLabel",style:{top:b+"px",left:a+15+"px"}},document.body)},b.clientX,b.clientY,a),500)},k)),b.mouseOutHandler=b.mouseOutHandler||{},b.mouseOutHandler[f.id]=g.connect(a,"onmouseout",d.hitch(this,function(a){this.mouseY=
this.mouseX=-1;this.hoverLabelShowing&&(this.hoverLabelShowing=!1,x.set(u.byId(this.id+"_hoverLabel"),"display","none"))}))},_removeHoverHandlers:function(){var a;b.forEach(this.layers,function(b){if(b.mouseMoveHandler)for(a in b.mouseMoveHandler)g.disconnect(b.mouseMoveHandler[a]);if(b.mouseOutHandler)for(a in b.mouseOutHandler)g.disconnect(b.mouseOutHandler[a])})},_createDynamicLayers:function(a){var c=[],d;b.forEach(a.dynamicLayerInfos||a.layerInfos,function(b){d={id:b.id};d.source=b.source&&b.source.toJson();
var e;a.layerDefinitions&&a.layerDefinitions[b.id]&&(e=a.layerDefinitions[b.id]);e&&(d.definitionExpression=e);var f;a.layerDrawingOptions&&a.layerDrawingOptions[b.id]&&(f=a.layerDrawingOptions[b.id]);f&&(d.drawingInfo=f.toJson());d.minScale=b.minScale||0;d.maxScale=b.maxScale||0;c.push(d)});return c},_getTemplateFromTypes:function(a,b){var c;for(c=0;c<a.length;c++)if(a[c].id==b&&a[c].templates&&0<a[c].templates.length)return a[c].templates[0];return null},_findParentGroup:function(a,b,c){var e,d=
b.dynamicLayerInfos||b.layerInfos;for(e=0;e<d.length;e++)if(c==d[e].id){-1<d[e].parentLayerId&&(x.set(u.byId(this.id+"_"+a+"_"+d[e].parentLayerId+"_group"),"display","block"),this._findParentGroup(a,b,d[e].parentLayerId));break}},_addSubLayersToHide:function(a){function c(e,d){var h=a.layer.dynamicLayerInfos||a.layer.layerInfos,f,g;for(f=0;f<h.length;f++)if(h[f].id===e&&h[f].subLayerIds)for(g=0;g<h[f].subLayerIds.length;g++){var k=h[f].subLayerIds[g];-1===b.indexOf(d,k)&&(d.push(k),c(k,d))}}a.layer.layerInfos&&
b.forEach(this.hideLayersInLegend[a.layer.id],function(b){c(b,this.hideLayersInLegend[a.layer.id])},this)},_isLayerInScale:function(a,b,c){var d,e=!0;if(a.legendResponse&&a.legendResponse.layers)for(d=0;d<a.legendResponse.layers.length;d++){var f=a.legendResponse.layers[d];if(b.id==f.layerId){var g,k;!a.minScale&&0!==a.minScale||!a.maxScale&&0!==a.maxScale?(0==f.minScale&&a.tileInfo&&(g=a.tileInfo.lods[0].scale),0==f.maxScale&&a.tileInfo&&(k=a.tileInfo.lods[a.tileInfo.lods.length-1].scale)):(g=Math.min(a.minScale,
f.minScale)||a.minScale||f.minScale,k=Math.max(a.maxScale,f.maxScale));if(0<g&&g<c||k>c)e=!1;break}}else if(a.minScale||a.maxScale)if(a.minScale&&a.minScale<c||a.maxScale&&a.maxScale>c)e=!1;return e},_getServiceTitle:function(a){var b=a._titleForLegend;b||(b=a.url,a.url?-1<a.url.indexOf("/MapServer")?(b=a.url.substring(0,a.url.indexOf("/MapServer")),b=b.substring(b.lastIndexOf("/")+1,b.length)):-1<a.url.indexOf("/ImageServer")?(b=a.url.substring(0,a.url.indexOf("/ImageServer")),b=b.substring(b.lastIndexOf("/")+
1,b.length)):-1<a.url.indexOf("/FeatureServer")&&(b=a.url.substring(0,a.url.indexOf("/FeatureServer")),b=b.substring(b.lastIndexOf("/")+1,b.length)):b="",a.name&&(b=0<b.length?b+(" - "+a.name):a.name));"esri.layers.ArcGISImageServiceVectorLayer"===a.declaredClass&&a.vectorFieldPixelFilter&&(a=a.vectorFieldPixelFilter.outputUnit?this["NLS_"+a.vectorFieldPixelFilter.outputUnit]:this["NLS_"+a.vectorFieldPixelFilter.inputUnit],H.isDefined(a)&&(b+=" ("+a+")"));return A.encode(b)},_getEffectiveScale:function(b,
c){var a=c.minScale,d=c.maxScale;if(H.isDefined(c.parentLayerId)){var e=b.layerInfos,f=c.parentLayerId,g;for(g=e.length-1;0<=g;g--)if(e[g].id==f)if(0==a&&0<e[g].minScale?a=e[g].minScale:0<a&&0==e[g].minScale||0<a&&0<e[g].minScale&&(a=Math.min(a,e[g].minScale)),d=Math.max(d||0,e[g].maxScale||0),-1<e[g].parentLayerId)f=e[g].parentLayerId;else break}return{minScale:a,maxScale:d}},_isSupportedLayerType:function(a){return a&&("esri.layers.ArcGISDynamicMapServiceLayer"===a.declaredClass||"esri.layers.ArcGISImageServiceLayer"===
a.declaredClass&&10.2<=a.version||"esri.layers.ArcGISImageServiceVectorLayer"===a.declaredClass||"esri.layers.ArcGISTiledMapServiceLayer"===a.declaredClass||"esri.layers.FeatureLayer"===a.declaredClass||"esri.layers.StreamLayer"===a.declaredClass||"esri.layers.KMLLayer"===a.declaredClass||"esri.layers.GeoRSSLayer"===a.declaredClass||"esri.layers.WMSLayer"===a.declaredClass||"esri.layers.WFSLayer"===a.declaredClass||"esri.layers.CSVLayer"===a.declaredClass)?!0:!1},isHostedTileService:function(a){var b=
/(https?:)?\/\/services.*\.arcgis\.com/i;return"esri.layers.ArcGISTiledMapServiceLayer"===a.declaredClass&&b.test(a.url)?!0:!1},getField:function(a,c,d){if(a.getField)return a.getField(c);if(d&&d.fields){var e;b.forEach(d.fields,function(a){a.name===c&&(e=a)});return e}return null}});d.mixin(J,{ALIGN_LEFT:0,ALIGN_RIGHT:1});f("extend-esri")&&d.setObject("dijit.Legend",J,P);return J});