/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as e}from"tslib";import r from"../../Color.js";import{deprecateWidget as s}from"../../core/deprecate.js";import t from"../../core/Logger.js";import{property as i,cast as a,subclass as o}from"../../core/accessorSupport/decorators.js";import l from"../../renderers/support/ClassBreakInfo.js";import n from"./SmartMappingSliderBase.js";import m from"./ClassedSizeSlider/ClassedSizeSliderViewModel.js";import{getFillFromColor as d}from"./support/utils.js";import{globalCss as p}from"../support/globalCss.js";import{messageBundle as c,tsx as h}from"../support/widget.js";import{storeNode as u}from"../support/widgetUtils.js";var g;const b="esri-classed-size-slider",k={base:b,rampElement:`${b}__ramp`,sliderContainer:`${b}__slider-container`,histogramContainer:`${b}__histogram-container`,track:`${b}--interactive-track`},f={trackFillColor:new r([149,149,149]),trackBackgroundColor:new r([224,224,224])};let w=g=class extends n{constructor(e,r){super(e,r),this._rampNode=null,this.messages=null,this.style={...f},this.viewModel=new m,this.announceDeprecation=()=>{s(t.getLogger(this),"Slider Classed Size","arcgis-slider-classed-size-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)}castStyle(e){return{...f,...e}}static fromRendererResult(e,r){const{renderer:{classBreakInfos:s}}=e,t=s.map(e=>{const r=e.symbol;let s;switch(r.type){case"simple-line":s=r.width;break;case"simple-marker":s=r.size;break;case"picture-marker":s=r.height}return{min:e.minValue,max:e.maxValue,size:s}});return new g({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;switch(t.type){case"simple-line":t.width=r[s].size;break;case"simple-marker":t.size=r[s].size;break;case"picture-marker":{const e=r[s].size,i=t.width,a=t.height;t.height=e,t.width=e/a*i;break}}return new l({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;let s;switch(r.type){case"simple-line":s=r.width;break;case"simple-marker":s=r.size;break;case"picture-marker":s=r.height}return{min:e.minValue,max:e.maxValue,size:s}});this.set({breaks:t,histogramConfig:{...this.histogramConfig,bins:r?.bins??[]}})}render(){const{state:e,label:r,visibleElements:s}=this,t="disabled"===e,i=this.classes(k.base,p.widget,p.panel,{[p.disabled]:t,[k.track]:!!s.interactiveTrack});return h("div",{"aria-label":r,class:i},t?null:this.renderContent(this._renderRamp(),k.sliderContainer,k.histogramContainer))}_renderRamp(){const{style:{trackBackgroundColor:e}}=this;return h("div",{afterCreate:u,bind:this,class:k.rampElement,"data-node-ref":"_rampNode"},h("svg",{xmlns:"http://www.w3.org/2000/svg"},h("rect",{fill:d(e),height:"100%",width:"100%",x:"0",y:"0"}),this._renderPath()))}_renderPath(){if(!this._rampNode)return;const{offsetHeight:e=0,offsetWidth:r=0}=this._rampNode;if(null==e||null==r)return;const{breaks:s,viewModel:{max:t,min:i},style:{trackFillColor:a}}=this,o=t-i,l=r/s.length,n=s.map(r=>e-Math.round((r.min-i)/o*e)+1).reverse(),m=s[0].size>s[s.length-1].size||!1;let p=m?l:r,c=`M${p} 0 `;return n.forEach((e,s)=>{const t=l*(s+1);c+=`L${p} ${e} `,p=m?l+t:r-t,c+=`L${p} ${e} `}),c+=`L0 ${e} L0 ${e} L0 0 Z`,h("path",{d:c,fill:d(a)})}};e([i()],w.prototype,"breaks",null),e([i()],w.prototype,"label",null),e([i(),c("esri/widgets/smartMapping/ClassedSizeSlider/t9n/ClassedSizeSlider")],w.prototype,"messages",void 0),e([i()],w.prototype,"style",void 0),e([a("style")],w.prototype,"castStyle",null),e([i({type:m})],w.prototype,"viewModel",void 0),w=g=e([o("esri.widgets.smartMapping.ClassedSizeSlider")],w);const y=w;export{y as default};
