/*
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 i}from"../../core/accessorSupport/decorators.js";import{authoringInfoVariableSliderMinMax as t}from"../../renderers/support/authoringInfoUtils.js";import s from"./SmartMappingSliderBase.js";import a from"./ColorSlider/ColorSliderViewModel.js";import{globalCss as l}from"../support/globalCss.js";import{messageBundle as o,tsx as n}from"../support/widget.js";var d;const p="esri-color-slider",m={base:p,rampElement:`${p}__ramp`,sliderContainer:`${p}__slider-container`,histogramContainer:`${p}__histogram-container`,primaryHandle:`${p}--primary-handle`,track:`${p}--interactive-track`};let h=d=class extends s{constructor(e,r){super(e,r),this.messages=null,this.viewModel=new a,this._bgFillId=`${this.id}-bg-fill`,this._rampFillId=`${this.id}-linear-gradient`}get handlesSyncedToPrimary(){return this.viewModel.handlesSyncedToPrimary}set handlesSyncedToPrimary(e){this.viewModel.handlesSyncedToPrimary=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get primaryHandleEnabled(){return this.viewModel.primaryHandleEnabled}set primaryHandleEnabled(e){this.viewModel.primaryHandleEnabled=e}get stops(){return this.viewModel.stops}set stops(e){this.viewModel.stops=e}static fromRendererResult(e,r){const{visualVariable:{stops:i},statistics:s}=e,{avg:a,stddev:l}=s,o=e.renderer.authoringInfo?.visualVariables.find(e=>"color"===e.type),[n,p]=t(o);return new d({max:p,min:n,stops:i,histogramConfig:{average:a??void 0,standardDeviation:l??void 0,bins:r?r.bins:[]},primaryHandleEnabled:"high-to-low"!==o?.theme})}updateFromRendererResult(e,r){const{visualVariable:{stops:i},statistics:s}=e,{avg:a,stddev:l}=s,o=e.renderer.authoringInfo?.visualVariables.find(e=>"color"===e.type),[n,d]=t(o);this.set({max:d,min:n,stops:i,histogramConfig:{average:a,standardDeviation:l,bins:r?r.bins:[]},primaryHandleEnabled:"high-to-low"!==o?.theme})}render(){const{label:e,primaryHandleEnabled:r,state:i,visibleElements:t}=this,s="disabled"===i,a=this.classes(m.base,l.widget,l.panel,{[l.disabled]:s,[m.primaryHandle]:r,[m.track]:!!t.interactiveTrack});return n("div",{"aria-label":e,class:a},s?null:this.renderContent(this._renderRamp(),m.sliderContainer,m.histogramContainer))}_renderRamp(){const{_bgFillId:e,_rampFillId:r,viewModel:i,zoomOptions:t}=this,s=i.getStopInfo();return n("div",{class:m.rampElement},n("svg",{xmlns:"http://www.w3.org/2000/svg"},n("defs",null,this.renderRampFillDefinition(r,s),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"})),t?this.renderZoomCaps():null)}};e([r()],h.prototype,"handlesSyncedToPrimary",null),e([r()],h.prototype,"label",null),e([r(),o("esri/widgets/smartMapping/ColorSlider/t9n/ColorSlider")],h.prototype,"messages",void 0),e([r()],h.prototype,"primaryHandleEnabled",null),e([r()],h.prototype,"stops",null),e([r({type:a})],h.prototype,"viewModel",void 0),h=d=e([i("esri.widgets.smartMapping.ColorSlider")],h);const g=h;export{g as default};
