import{r as i,e as t,h as s,g as e}from"./p-15c07fa9.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{F as a}from"./p-ff1990ad.js";import{F as l}from"./p-fa80e546.js";import{E as r}from"./p-1a68fb59.js";const n=class{constructor(s){i(this,s),this.valueChanged=t(this,"valueChanged",7),this._startIntervalLabel="Inicial",this._endIntervalLabel="Final",this._toLabel="até",this.config=void 0,this.getMessage=void 0,this.value=void 0,this.presentationMode=r.CHIP,this.errorMessage=void 0}ezInputListener(i){this.errorMessage=void 0;const t=i.detail;if(this.getVariation()===l.INTERVAL)return i.target!==this._startInterval||isNaN(t)||(this.value=Object.assign(this.value,{start:t})),i.target!==this._endInterval||isNaN(t)||(this.value=Object.assign(this.value,{end:t})),void this.valueChanged.emit(this.value);this.value=t,this.valueChanged.emit(this.value)}async show(){this.getVariation()!==l.INTERVAL?this._numberElement.setFocus():this._startInterval.setFocus()}async setFocus(){this.getVariation()!==l.INTERVAL?await this._numberElement.setFocus():await this._startInterval.setFocus()}async clearValue(){var i,t;if(this.value=this.config.value,this.getVariation()===l.INTERVAL){const s=this.config.value;this._startInterval&&(this._startInterval.value=null!==(i=null==s?void 0:s.start)&&void 0!==i?i:null),this._endInterval&&(this._endInterval.value=null!==(t=null==s?void 0:s.end)&&void 0!==t?t:null)}else this._numberElement&&(this._numberElement.value=this.config.value)}getIntervalValue(i){const t=this.value?this.value[i]:null;return null!=t?t:null}buildLabel(){if(this.presentationMode===r.CHIP)return s("label",{class:"ez-text ez-text--medium ez-text--primary ez-margin--medium"},this._toLabel)}getVariation(){var i,t;return null!==(t=null===(i=this.config.props)||void 0===i?void 0:i.variation)&&void 0!==t?t:l.DEFAULT}componentWillLoad(){this.getMessage&&(this._startIntervalLabel=this.getMessage("snkFilterBar.labelStart"),this._endIntervalLabel=this.getMessage("snkFilterBar.labelEnd"),this._toLabel=this.getMessage("snkFilterBar.labelTo"))}componentDidLoad(){this._element&&h.addIDInfo(this._element,"filterContentEditor")}render(){var i,t,e;if(this.config&&this.config.type===a.NUMBER)return this.getVariation()===l.INTERVAL?s("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},s("div",{class:"ez-col ez-col--nowrap"},s("ez-number-input",{id:`${this.config.id}_start`,class:this.presentationMode===r.MODAL?"ez-padding-right--medium":"",label:this._startIntervalLabel,ref:i=>this._startInterval=i,value:this.getIntervalValue("start"),enabled:this.config.enabled,precision:null===(i=this.config.props)||void 0===i?void 0:i.precision,errorMessage:this.errorMessage}),this.buildLabel(),s("ez-number-input",{id:`${this.config.id}_end`,label:this._endIntervalLabel,ref:i=>this._endInterval=i,value:this.getIntervalValue("end"),enabled:this.config.enabled,precision:null===(t=this.config.props)||void 0===t?void 0:t.precision,errorMessage:this.errorMessage}))):s("ez-tooltip",{active:!1===this.config.enabled,message:this.config.disabledMessage,type:"warning"},s("ez-number-input",{id:this.config.id,label:this.config.label,ref:i=>this._numberElement=i,value:this.config.value,precision:null===(e=this.config.props)||void 0===e?void 0:e.precision,enabled:this.config.enabled,errorMessage:this.errorMessage}))}get _element(){return e(this)}};export{n as snk_filter_number}