/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import{property as r,subclass as s}from"../../core/accessorSupport/decorators.js";import t from"../../renderers/support/ClassBreakInfo.js";import i from"./SmartMappingSliderBase.js";import l from"./ClassedColorSlider/ClassedColorSliderViewModel.js";import{globalCss as o}from"../support/globalCss.js";import{messageBundle as a,tsx as n}from"../support/widget.js";var d;const m="esri-classed-color-slider",p={base:m,rampElement:`${m}__ramp`,sliderContainer:`${m}__slider-container`,histogramContainer:`${m}__histogram-container`,track:`${m}--interactive-track`};let c=d=class extends i{constructor(e,r){super(e,r),this.messages=null,this.viewModel=new l,this._bgFillId=`${this.id}-bg-fill`,this._rampFillId=`${this.id}-linear-gradient`}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 d({breaks:t,histogramConfig:{bins:r?r.bins:[]}})}updateClassBreakInfos(e){const r=this.breaks;if(r.length===e.length)return e.map((e,s)=>{const i=e.symbol;return i.color=r[s].color,new t({minValue:r[s].min,maxValue:r[s].max,symbol:i})});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}),r?.bins&&(this.histogramConfig.bins=r.bins)}render(){const{state:e,label:r,visibleElements:s}=this,t="disabled"===e,i=this.classes(p.base,o.widget,o.panel,{[o.disabled]:t,[p.track]:!!s.interactiveTrack});return n("div",{"aria-label":r,class:i},t?null:this.renderContent(this._renderRamp(),p.sliderContainer,p.histogramContainer))}_renderRamp(){const{_bgFillId:e,_rampFillId:r,viewModel:s}=this,t=s.getStopInfo();return n("div",{class:p.rampElement},n("svg",{xmlns:"http://www.w3.org/2000/svg"},n("defs",null,this.renderRampFillDefinition(r,t),this.renderBackgroundFillDefinition(e)),n("rect",{fill:`url(#${e})`,height:"100%",width:"100%",x:"0",y:"0"}),n("rect",{fill:`url(#${r})`,height:"100%",width:"100%",x:"0",y:"0"})))}};e([r()],c.prototype,"breaks",null),e([r()],c.prototype,"label",null),e([r(),a("esri/widgets/smartMapping/ClassedColorSlider/t9n/ClassedColorSlider")],c.prototype,"messages",void 0),e([r({type:l})],c.prototype,"viewModel",void 0),c=d=e([s("esri.widgets.smartMapping.ClassedColorSlider")],c);const b=c;export{b as default};
