// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/ColorRampSelector","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/i18n!../nls/jsapi dojo/store/Memory dojo/has ../kernel ../renderers/colorRampUtils dijit/form/FilteringSelect dojo/query dojo/dom-style dojo/on dojo/dom-construct".split(" "),function(k,d,f,n,p,e,q,h,g,l,m,r,t){g=k([g],{declaredClass:"esri.dijit.ColorRampSelector",_colorRampNameMap:null,_colorRamps:null,_namesShown:!1,constructor:function(a){k.safeMixin(this,a);this._i18n=n.widgets.colorRampSelector;this._colorRamps=
d.clone(h.predefinedColorRamps);this._colorRampNameMap=d.clone(h.predefinedColorRampNameMap)},startup:function(){this.inherited(arguments);this._styleDijitInput();this._setupColorRampList();this._setupDropdownEvents();this._handleColorRampChange()},_setupDropdownEvents:function(){r(this.inputContainer,"click",d.hitch(this,this.toggleDropDown));this.dropDownEventsSetup=!0},_setupColorRampList:function(){this._generateColorRamps();this._populateColorRampList()},_styleDijitInput:function(){var a=l(".dijitReset.dijitInputInner",
this.domNode)[0];this.inputContainer=l(".dijitReset.dijitInputField.dijitInputContainer",this.domNode)[0];m.set(this.inputContainer,"height","25px!important");m.set(a,"display","none")},_generateColorRamps:function(){var a=this._i18n.colorRamps,c;f.forEach(this._colorRamps,function(b){"none"===b.id?b.label="\x3chtml\x3e\x3cbody\x3e\x3cdiv style\x3d'padding: 5px 0px 5px 2px; font-weight: 700;'\x3e"+a[b.id]+"\x3c/div\x3e\x3c/body\x3e\x3c/html\x3e":(b.name=a[b.id]||b.name,9>=e("ie")?(b.labelGradient=
"\x3chtml\x3e\x3cbody\x3e\x3clabel style\x3d'display: block; padding: 4px 0px 0px 4px;'\x3e"+b.name+"\x3c/label\x3e\x3c/body\x3e\x3c/html\x3e",b.label=b.labelGradient):(c=this._generateColorRampDivs(b),b.labelGradient="\x3chtml\x3e\x3cbody\x3e\x3cdiv title\x3d'"+b.name+"' style\x3d'height:20px; padding: 2px; direction: ltr!important;'\x3e"+c+"\x3c/div\x3e\x3c/body\x3e\x3c/html\x3e",b.label=this._namesShown?"\x3chtml\x3e\x3cbody\x3e\x3clabel style\x3d'display: block; padding-left: 2px;'\x3e"+b.name+
"\x3c/label\x3e\x3cdiv style\x3d'height:20px; padding: 2px; direction: ltr!important;'\x3e"+c+"\x3c/div\x3e\x3c/body\x3e\x3c/html\x3e":b.labelGradient))},this)},_populateColorRampList:function(){this.set("labelAttr","label");this.set("labelType","html");this.set("searchAttr","id");this.set("store",new p({data:this._colorRamps}));this._handleColorRampChange()},_generateColorRampDivs:function(a){if(a){var c,b="";"multipart"===a.type?(c=100/a.colorRamps.length,f.forEach(a.colorRamps,function(a){b+=this._generateSingleGradientDiv(a.fromColor,
a.toColor,c)},this)):b=this._generateSingleGradientDiv(a.fromColor,a.toColor,100);return b}},_generateSingleGradientDiv:function(a,c,b){if(a&&c){var d,e="";a=a.toRgb?a.toRgb():a;c=c.toRgb?c.toRgb():c;d="(90deg, rgb("+a.slice(0,3).join()+"), rgb("+c.slice(0,3).join()+"));";f.forEach(["-webkit-linear-gradient","-o-linear-gradient","-moz-linear-gradient","linear-gradient"],function(a){e+="background: "+a+d});return"\x3cdiv style\x3d' display: inline-block; width:"+b+"%; padding: 0; height: 100%;"+e+
"'\x3e\x3c/div\x3e"}},onChange:function(){this.inherited(arguments);this._handleColorRampChange()},_handleColorRampChange:function(){if(this.inputContainer){var a;f.some(this._colorRamps,function(c){if(c.id===this.value)return a=c,!0},this)&&("none"===this.value||9>=e("ie")?this.inputContainer.innerHTML="\x3chtml\x3e\x3cbody\x3e\x3cdiv style\x3d'padding: 4px 0px 0px 4px; font-weight: 400;'\x3e"+t.toDom(a.label).innerHTML+"\x3c/div\x3e\x3c/body\x3e\x3c/html\x3e":this.inputContainer.innerHTML=a.labelGradient,
"none"===a.id?this.colorRamp=this.colorRampName=null:(this.colorRampName=this._getColorRampName(a.id),this.colorRamp=a))}},_getColorRampName:function(a){var c;f.some(this._colorRampNameMap,function(b){if(b.id===a)return c=b.name,!0});return c},showNames:function(a){this._namesShown=a;this._setupColorRampList()},reset:function(){this.set("value","none",!1);this._handleColorRampChange()},removeColorRamp:function(a){a&&this.store&&this.store.data&&this.store.data.length&&this.store.remove(a.id)},addColorRamp:function(a){if(a){if(9>=
e("ie"))a.labelGradient="\x3clabel style\x3d'display: block; padding: 4px 0px 0px 4px;'\x3e"+a.name+"\x3c/label\x3e",a.label=a.labelGradient;else{var c=this._generateColorRampDivs(a);a.labelGradient="\x3cdiv title\x3d'"+a.name+"' style\x3d'height:18px; padding: 1px; direction: "+(this.reverseRamp?"rtl":"ltr")+"!important;'\x3e"+c+"\x3c/div\x3e";a.label=this._namesShown?"\x3clabel style\x3d'display: block; padding-left: 2px;'\x3e"+a.name+"\x3c/label\x3e\x3cdiv style\x3d'height:18px; padding: 1px; direction: ltr!important;'\x3e"+
c+"\x3c/div\x3e":a.labelGradient}this.store&&this.store.data&&this.store.data.length?this.store.put(a,{overwrite:!0}):this._colorRamps.push(a);this._colorRampNameMap.push({id:a.id,name:a.name})}},setSelected:function(a,c){if(!a)return this.reset();var b=h.getColorRampId(a,this._colorRamps,this._colorRampNameMap);if(b)return this.set("value",b,!1),this._handleColorRampChange(b),!0;this.reset();return!1}});e("extend-esri")&&d.setObject("dijit.ColorRampSelector",g,q);return g});