/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","exports","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/maybe","../../../core/reactiveUtils","../../../core/timeUtils","../../../core/uuid","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../../intl/number","../../Slider","../../Widget","../css","./Label","./LabeledColorPicker","../../support/widgetUtils","../../support/decorators/messageBundle","../../support/jsxFactory"],(function(e,o,r,t,s,i,l,a,n,u,c,d,h,p,v,_,m,b,g,S,C,f){"use strict";o.ThresholdConfigurator=function(o){function t(e){var r;return(r=o.call(this,e)||this).colorPickerVisible=!0,r._valueSliderId=`value-slider-${a.generateUUID()}`,r._colorPickerId=`color-picker-${a.generateUUID()}`,r._valueSlider=new v({visibleElements:{labels:!1,rangeLabels:!1},steps:l.convertTime(30,"minutes","milliseconds"),labelFormatFunction:(e,o)=>{const r=l.convertTime(e,"milliseconds","hours");return"tick"===o?p.formatNumber(r,{maximumFractionDigits:0}):""}}),r._onColorChange=e=>{r.options.color=e},r}r._inheritsLoose(t,o);var n=t.prototype;return n.initialize=function(){const e=({value:e})=>{this.options.value=e};this.own([i.watch((()=>{const{value:e,minValue:o,maxValue:r}=this.options;return{value:e,minValue:o,maxValue:r}}),(({value:e,minValue:o,maxValue:r})=>{const t=this._valueSlider;t.min=o,t.max=r,t.values=[e];const s=r-o,i=Math.floor(l.convertTime(s,"milliseconds","hours"));t.tickConfigs=[{mode:"count",values:2*i+1,labelsVisible:!1},{mode:"count",values:i+1,labelsVisible:!0}]}),i.syncAndInitial),this._valueSlider.on("thumb-change",e),this._valueSlider.on("thumb-drag",e)])},n.loadDependencies=function(){return new Promise(((o,r)=>e(["../../../chunks/calcite-label"],o,r)))},n.destroy=function(){this._valueSlider=s.destroyMaybe(this._valueSlider)},n.render=function(){const e=this._messages.threshold,{color:o}=this.options;return f.tsx("div",{class:m.THRESHOLD_CONFIGURATOR_CSS.base},f.tsx(b.Label,{class:m.THRESHOLD_CONFIGURATOR_CSS.valueLabel,for:this._valueSliderId,label:e.valueLabel},this._valueSlider.render()),this.colorPickerVisible&&f.tsx(g.LabeledColorPicker,{id:this._colorPickerId,label:e.colorLabel,value:o,onChange:this._onColorChange}))},r._createClass(t,[{key:"testData",get:function(){return{valueSlider:this._valueSlider}}}]),t}(_),t.__decorate([n.property()],o.ThresholdConfigurator.prototype,"options",void 0),t.__decorate([n.property()],o.ThresholdConfigurator.prototype,"colorPickerVisible",void 0),t.__decorate([n.property()],o.ThresholdConfigurator.prototype,"testData",null),t.__decorate([n.property()],o.ThresholdConfigurator.prototype,"_valueSlider",void 0),t.__decorate([n.property(),C.messageBundle("esri/widgets/ShadowCast/t9n/ShadowCast")],o.ThresholdConfigurator.prototype,"_messages",void 0),o.ThresholdConfigurator=t.__decorate([h.subclass("esri.widgets.ShadowCast.components.ThresholdConfigurator")],o.ThresholdConfigurator),Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
