text: // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  // See http://js.arcgis.com/4.0beta2/esri/copyright.txt for details.
  //>>built
  define("./Widget ./_Tooltip ./VisibleScaleRangeSlider/_RecommendedScaleRangeBounds ./VisibleScaleRangeSlider/_SlideEvent ./VisibleScaleRangeSlider/ScaleMenu ./VisibleScaleRangeSlider/ScalePreview ./VisibleScaleRangeSlider/ScaleRanges dijit/form/DropDownButton dijit/popup dojo/_base/array ../core/declare dojo/_base/lang dojo/aspect dojo/debounce dojo/Deferred dojo/dom-class dojo/dom-construct dojo/dom-geometry dojo/dom-style dojo/on dojo/string dojox/form/HorizontalRangeSlider dojo/i18n!../nls/jsapi".split(" "),
  function(r,s,t,u,m,v,n,p,h,w,f,d,k,x,y,z,q,l,A,B,C,D,E){return f([r,s],{declaredClass:"esri.dijit.VisibleScaleRangeSlider",baseClass:"esriVisibleScaleRangeSlider",css:{currentScaleIndicator:"esriCurrentScaleIndicator",currentScaleIndicatorContainer:"esriCurrentScaleIndicatorContainer",scaleIndicator:"esriScaleIndicator",scaleIndicatorContainer:"esriScaleIndicatorContainer"},map:null,layer:null,region:"en-US",minScale:0,maxScale:0,intermediateChanges:!1,labels:E.widgets.visibleScaleRangeSlider,_slider:null,
  _currentScaleIndicator:null,_scalePreview:null,_maxScaleButton:null,_minScaleButton:null,_mapUpdateHandler:null,_scaleRanges:null,_scheduleScaleRangeChangeEmit:null,_getSliderIndexRange:function(a){a=Math.floor(a);return{min:a,max:a+0.99999}},_setMapAttr:function(a){this._set("map",a);this._mapUpdateHandler&&this._mapUpdateHandler.remove();this._slider.set("disabled",!0);this._ensureMapIsReady().then(d.hitch(this,function(){var b=a.getMinScale(),c=a.getMaxScale(),e;this._slider.set("disabled",!1);
  this._scaleRanges.set("scaleRangeBounds",{minScale:b,maxScale:c});e=this._getSliderIndexRange(this._scaleRanges.length-1);this._slider.set("maximum",e.max);this.set("minScale",b);this.set("maxScale",c);this._updateCurrentScaleIndicator();b=a.on("zoom-end",d.hitch(this,function(){this._updateCurrentScaleIndicator()}));this.own(b);this._mapUpdateHandler=b}))},_ensureMapIsReady:function(){return this._ensureLoadedResource(this.map)},_ensureLoadedResource:function(a){var b=new y;if(a)if(a.loaded)b.resolve();
  else a.on("load",function(){b.resolve()});else b.reject(Error("could not load resource"));return b.promise},_updateCurrentScaleIndicator:function(){var a=this._scaleRanges.clampScale(this.map.getScale()),a=this._mapScaleToSlider(a)/this._slider.maximum;this.isLeftToRight()||(a=1-a);A.set(this._currentScaleIndicator,{left:100*a+"%"})},_setLayerAttr:function(a){this._set("layer",a);this._ensureMapIsReady().then(d.hitch(this,this._ensureLayerIsReady)).then(d.hitch(this,function(){this._updateMinMaxScaleFromLayer(a)}))},
  _ensureLayerIsReady:function(){return this._ensureLoadedResource(this.layer)},_updateMinMaxScaleFromLayer:function(a){this.set("minScale",a.minScale);this.set("maxScale",a.maxScale)},_mapSliderToScale:function(a){var b=this._getSliderIndexRange(a),c=this._scaleRanges.findScaleRangeByIndex(a);return this._mapToRange(a,b.min,b.max,c.minScale,c.maxScale)},_mapToRange:function(a,b,c,e,d){return e+(a-b)*(d-e)/(c-b)},_setRegionAttr:function(a){this._set("region",a);this._scalePreview.set("source",n.getScalePreviewSource(a))},
  _getMinimumAttr:function(){return this._mapSliderToScale(this._slider.minimum)},_getMaximumAttr:function(){return this._mapSliderToScale(this._slider.maximum)},_getMaxScaleAttr:function(){return this.maxScale},_getActualMaxScaleAttr:function(){return this._scaleRanges.clampMaxScale(this.maxScale)},_setMaxScaleAttr:function(a){this._set("maxScale",a);this._ensureMapIsReady().then(d.hitch(this,function(){a=this._scaleRanges.clampMaxScale(a);this._set("maxScale",this._adjustMaxScale(a));this._updateSliderSilently({value:this._mapScaleToSlider(a),
  isMaxVal:!0});this._scheduleScaleRangeChangeEmit()}))},_updateSliderSilently:function(a){this._slider.set("value",a.value,!1,a.isMaxVal)},_mapScaleToSlider:function(a){var b=this._scaleRanges.scaleToRangeIndex(a),c=this._getSliderIndexRange(b),b=this._scaleRanges.findScaleRangeByIndex(b);return this._mapToRange(a,b.minScale,b.maxScale,c.min,c.max)},_getMinScaleAttr:function(){return this.minScale},_getActualMinScaleAttr:function(){return this._scaleRanges.clampMinScale(this.minScale)},_setMinScaleAttr:function(a){this._set("minScale",
  a);this._ensureMapIsReady().then(d.hitch(this,function(){a=this._scaleRanges.clampMinScale(a);this._set("minScale",this._adjustMinScale(a));this._updateSliderSilently({value:this._mapScaleToSlider(a),isMaxVal:!1});this._scheduleScaleRangeChangeEmit()}))},_emitScaleRangeChange:function(){this.emit("scale-range-change",{minScale:this.minScale,maxScale:this.maxScale})},_adjustMinScale:function(a){return this._scaleRanges.beyondMinScale(a)?0:a},_adjustMaxScale:function(a){return this._scaleRanges.beyondMaxScale(a)?
  0:a},constructor:function(){this._scaleRanges=new (f([n,t]));this._scheduleScaleRangeChangeEmit=x(d.hitch(this,this._emitScaleRangeChange),0)},buildRendering:function(){this.inherited(arguments);this._initSlider();this._initScalePreview();this._initScaleIndicators();this._initScaleMenus()},_initSlider:function(){var a=(new f([D,u]))({baseClass:"esriHorizontalSlider",showButtons:!1,intermediateChanges:this.intermediateChanges,disabled:!0});this._slider=a;a.placeAt(this.domNode);a.startup();this.own(a.on("slide-onmousemove, slidemax-onmousemove",
  d.hitch(this,function(a){this._updateScalePreview(a.movable.handle)})),a.on("slide-onmovestop, slidemax-onmovestop",d.hitch(this,function(a){z.contains(a.movable.handle,"dijitSliderThumbHover")||this._closeScalePreview()})),a.on("change",d.hitch(this,function(){var a=Math.round(this._mapSliderToScale(this._getSliderMin())),c=Math.round(this._mapSliderToScale(this._getSliderMax()));this.set("minScale",a);this.set("maxScale",c)})),k.after(a,"_setValueAttr",d.hitch(this,this._updateLabelMenus)))},_getSliderMin:function(){var a=
  this._slider.get("value");return this.isLeftToRight()?a[0]:a[1]},_getSliderMax:function(){var a=this._slider.get("value");return this.isLeftToRight()?a[1]:a[0]},_updateLabelMenus:function(){var a=this._maxScaleButton;this._minScaleButton.set("label",this._scaleRanges.getScaleRangeLabel(this._getSliderMin()));a.set("label",this._scaleRanges.getScaleRangeLabel(this._getSliderMax()))},_initScalePreview:function(){var a=new v;a.startup();h.moveOffScreen(a);w.forEach([this._slider._movable.handle,this._slider._movableMax.handle],
  function(a){a.onmouseenter=d.hitch(this,function(){this._updateScalePreview(a)});a.onmouseleave=d.hitch(this,function(){this._closeScalePreview()})},this);this.own(a);this._scalePreview=a},_closeScalePreview:function(){h.close(this._scalePreview)},_updateScalePreview:function(a){var b=this._slider,c=this._scalePreview,d=a===b.sliderHandle?this._getSliderMin():this._getSliderMax(),F=l.position(a),g=l.position(c.domNode),b=l.position(b.sliderBarContainer),f=this.isLeftToRight();c.set("backgroundPosition",
  this._scaleRanges.getScalePreviewSpriteBackgroundPosition(d));d=F.x-b.x;g=0.5*g.w;h.open({parent:this,popup:c,around:a,orient:d<g?f?["above","below"]:["above-alt","below-alt"]:d<b.w-g?["above-centered","below-centered"]:f?["above-alt","below-alt"]:["above","below"]})},_initScaleIndicators:function(){var a=q.create("div",{className:this.css.scaleIndicatorContainer+" "+this.css.currentScaleIndicatorContainer},this._slider.sliderBarContainer),b=q.create("div",{className:this.css.scaleIndicator+" "+this.css.currentScaleIndicator},
  a);this._currentScaleIndicator=b;this.createTooltip(b);a=B(b,"mouseover",d.hitch(this,function(){var a=C.substitute(this.labels.currentScaleTooltip,{scaleLabel:this._scaleRanges.getScaleRangeLabel(this._mapScaleToSlider(this.map.getScale()))});this.findTooltip(b).set("label",a)}));this.own(a)},_initScaleMenus:function(){var a=new m,b=new m,c,e;this.own(a.on("scale-selected",d.hitch(this,function(a){c.closeDropDown();this.set("minScale",a.scale)})));this.own(b.on("scale-selected",d.hitch(this,function(a){e.closeDropDown();
  this.set("maxScale",a.scale)})));c=new p({baseClass:"esriScaleMenuButton esriMinScaleMenuButton",dropDown:a,dropDownPosition:["below","above"]});c.toggleDropDown();c.toggleDropDown();e=new p({baseClass:"esriScaleMenuButton esriMaxScaleMenuButton",dropDown:b,dropDownPosition:["below","above"]});e.toggleDropDown();e.toggleDropDown();this.own(k.before(c,"openDropDown",d.hitch(this,function(){var b=this._scaleRanges.findScaleRange(this.get("actualMaxScale")).minScale;a.set("currentScale",{label:c.label,
  scale:{current:this.get("actualMinScale"),map:this.map.getScale(),min:this.get("minimum"),max:b}})})));this.own(k.before(e,"openDropDown",d.hitch(this,function(){var a=this._scaleRanges.findScaleRange(this.get("actualMinScale")).maxScale;b.set("currentScale",{label:e.label,scale:{current:this.get("actualMaxScale"),map:this.map.getScale(),min:a,max:this.get("maximum")}})})));c.placeAt(this.domNode);e.placeAt(this.domNode);a.startup();b.startup();c.startup();e.startup();this._minScaleButton=c;this._maxScaleButton=
  e},startup:function(){this.inherited(arguments);this.watch("intermediateChanges",function(a,b,c){this._slider.set(a,c)})}})});