import{r as s,c as t,h as i,g as e}from"./p-23a36bb6.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{C as r}from"./p-ec7db713.js";const a=class{constructor(i){s(this,i),this.ezChange=t(this,"ezChange",7),this.ezSearching=t(this,"ezSearching",7),this.ezFocusIn=t(this,"ezFocusIn",7),this._searchingText="",this.handleFocus=()=>{this._textInput.value=""===this._searchingText?"":this._searchingText,this.ezFocusIn.emit()},this.label=void 0,this.value=void 0,this.enabled=!0,this.errorMessage=void 0,this.restrict=void 0,this.mode="regular",this.asyncSearch=!1,this.canShowError=!0,this.autoFocus=!1}observeLabel(){this._textInput&&(this._textInput.label=this.label)}observeErrorMessage(){this._textInput&&(this._textInput.errorMessage=this.errorMessage)}observeValue(s,t){this._textInput&&s!=t&&(this._textInput.value=s,this.ezChange.emit(s))}async setFocus(s){this._textInput.setFocus(s)}async setBlur(){this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}async setValue(s){this.asyncSearch&&null!=this._textInput&&(s!==this.value?(this.value=s,this._searchingText=""):this._textInput.value=s)}async endSearch(){this.asyncSearch&&null!=this._textInput&&this._textInput.value!==this.value&&(this._textInput.value=this.value)}handleChange(s){const t=s.detail;this.errorMessage="",this.asyncSearch?(this._searchingText=t,this.ezSearching.emit(t)):t!==this.value&&(this.value=t)}componentDidLoad(){r.applyVarsTextInput(this._elem,this._textInput),this.autoFocus&&requestAnimationFrame((()=>{this.setFocus({selectText:!0})}))}render(){return h.addIDInfoIfNotExists(this._elem,"input"),i("ez-text-input",{"data-element-id":h.getInternalIDInfo("textInput"),ref:s=>this._textInput=s,label:this.label,onEzChange:s=>this.handleChange(s),value:this.value,enabled:this.enabled,errorMessage:this.errorMessage,restrict:this.restrict,mode:this.mode,onFocusin:this.handleFocus,canShowError:this.canShowError},i("ez-icon",{slot:"leftIcon",iconName:"search"}))}get _elem(){return e(this)}static get watchers(){return{label:["observeLabel"],errorMessage:["observeErrorMessage"],value:["observeValue"]}}};a.style=":host{display:block;width:100%}";export{a as ez_filter_input}