/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as e}from"tslib";import{deprecateWidget as r}from"../../core/deprecate.js";import s from"../../core/Logger.js";import{property as t,subclass as o}from"../../core/accessorSupport/decorators.js";import i from"../../renderers/support/ClassBreakInfo.js";import l from"./SmartMappingSliderBase.js";import a from"./ClassedColorSlider/ClassedColorSliderViewModel.js";import{globalCss as n}from"../support/globalCss.js";import{messageBundle as d,tsx as m}from"../support/widget.js";var c;const p="esri-classed-color-slider",g={base:p,rampElement:`${p}__ramp`,sliderContainer:`${p}__slider-container`,histogramContainer:`${p}__histogram-container`,track:`${p}--interactive-track`};let h=c=class extends l{constructor(e,t){super(e,t),this.messages=null,this.viewModel=new a,this._bgFillId=`${this.id}-bg-fill`,this._rampFillId=`${this.id}-linear-gradient`,this.announceDeprecation=()=>{r(s.getLogger(this),"Slider Classed Color","arcgis-slider-classed-color-legacy",{version:"5.0"})}}get breaks(){return this.viewModel.breaks}set breaks(e){this.viewModel.breaks=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}static fromRendererResult(e,r){const{renderer:{classBreakInfos:s}}=e,t=s.map(e=>{const r=e.symbol.color;return{min:e.minValue,max:e.maxValue,color:r}});return new c({breaks:t,histogramConfig:{bins:r?r.bins:[]}})}updateClassBreakInfos(e){const r=this.breaks;if(r.length===e.length)return e.map((e,s)=>{const t=e.symbol;return t.color=r[s].color,new i({minValue:r[s].min,maxValue:r[s].max,symbol:t})});console.error(`Number of input breakInfos must match number of slider breaks: ${r.length}`)}updateFromRendererResult(e,r){const{renderer:{classBreakInfos:s}}=e,t=s.map(e=>{const r=e.symbol.color;return{min:e.minValue,max:e.maxValue,color:r}});this.set({breaks:t,histogramConfig:{...this.histogramConfig,bins:r?.bins??[]}})}render(){const{state:e,label:r,visibleElements:s}=this,t="disabled"===e,o=this.classes(g.base,n.widget,n.panel,{[n.disabled]:t,[g.track]:!!s.interactiveTrack});return m("div",{"aria-label":r,class:o},t?null:this.renderContent(this._renderRamp(),g.sliderContainer,g.histogramContainer))}_renderRamp(){const{_bgFillId:e,_rampFillId:r,viewModel:s}=this,t=s.getStopInfo();return m("div",{class:g.rampElement},m("svg",{xmlns:"http://www.w3.org/2000/svg"},m("defs",null,this.renderRampFillDefinition(r,t),this.renderBackgroundFillDefinition(e)),m("rect",{fill:`url(#${e})`,height:"100%",width:"100%",x:"0",y:"0"}),m("rect",{fill:`url(#${r})`,height:"100%",width:"100%",x:"0",y:"0"})))}};e([t()],h.prototype,"breaks",null),e([t()],h.prototype,"label",null),e([t(),d("esri/widgets/smartMapping/ClassedColorSlider/t9n/ClassedColorSlider")],h.prototype,"messages",void 0),e([t({type:a})],h.prototype,"viewModel",void 0),h=c=e([o("esri.widgets.smartMapping.ClassedColorSlider")],h);const u=h;export{u as default};
