import {J,c as tS,gb as Ys,aV as ut,cp as Mi,d$ as h$,gU as T$,kp as p$,L as w,ca as yo,b8 as eT,bi as et,gd as ut$1,cB as Kt,ap as Qi,hu as Gi,e0 as NM,lF as um,kS as lh,ms as vs,bW as JT}from'./main-WUGO6e7n.js';var B,I=J(()=>{tS();Ys();ut();Mi();tS();B=(()=>{class l{constructor(){this.showClear=h$(!1,{transform:T$}),this.onClear=p$(),this.el=w(yo),this.renderer=w(eT),this.ngModel=w(et,{optional:!0}),this.destroyRef=w(ut$1),this.pInputText=w(Kt),this.clearIcon=Qi(null),this.wrapper=Qi(null),this.nativeValue=Qi(""),this.isDisabled=Qi(!1),this.isReadonly=Qi(!1),this.isFluid=Qi(!1),this.ngModelValue=this.ngModel?Gi(this.ngModel.valueChanges,{initialValue:this.ngModel.value??""}):null,this.isVisible=NM(()=>this.showClear()?!!(this.ngModelValue?.()??this.nativeValue())&&!this.isDisabled()&&!this.isReadonly():!1),um(()=>{this.setupClearButton(),this.ngModel||this.setupNativeValueListener(),this.observeInputState();}),lh(()=>{let e=this.clearIcon(),t=this.isVisible();e&&this.renderer.setStyle(e,"display",t?"block":"none");}),lh(()=>{let e=this.wrapper(),t=this.isFluid();e&&(t?this.renderer.addClass(e,"w-full"):this.renderer.removeClass(e,"w-full"));});}setupClearButton(){let e=this.el.nativeElement,t=this.renderer.parentNode(e),s=this.renderer.createElement("span");this.renderer.setAttribute(s,"class","relative inline-block"),this.renderer.insertBefore(t,s,e),this.renderer.removeChild(t,e),this.renderer.appendChild(s,e),this.renderer.addClass(e,"pr-8");let i=this.renderer.createElement("i");this.renderer.setAttribute(i,"class","pi pi-times absolute top-1/2 -translate-y-1/2 right-3 cursor-pointer"),this.renderer.setStyle(i,"--p-icon-size","12px",vs.DashCase),this.renderer.setStyle(i,"color","var(--text-400)"),this.renderer.setStyle(i,"display","none");let M=this.renderer.listen(i,"click",()=>this.onClearHandler());this.destroyRef.onDestroy(M),this.renderer.appendChild(s,i),this.clearIcon.set(i),this.wrapper.set(s),this.destroyRef.onDestroy(()=>{let o=this.renderer.parentNode(s);o&&this.renderer.removeChild(o,s);});}setupNativeValueListener(){this.nativeValue.set(this.el.nativeElement.value);let e=this.renderer.listen(this.el.nativeElement,"input",()=>{this.nativeValue.set(this.el.nativeElement.value);});this.destroyRef.onDestroy(e);}observeInputState(){let e=this.el.nativeElement;this.syncState(e);let t=new MutationObserver(()=>this.syncState(e));t.observe(e,{attributes:!0,attributeFilter:["disabled","readonly"]}),this.destroyRef.onDestroy(()=>t.disconnect());}syncState(e){this.isDisabled.set(e.disabled),this.isReadonly.set(e.readOnly),this.isFluid.set(this.pInputText.hasFluid||e.classList.contains("w-full"));}onClearHandler(){this.ngModel?.control?this.ngModel.control.setValue(""):this.el.nativeElement.value="",this.el.nativeElement.dispatchEvent(new Event("input")),this.onClear.emit();}static{this.\u0275fac=function(t){return new(t||l)};}static{this.\u0275dir=JT({type:l,selectors:[["input","pInputText","","showClear",""]],inputs:{showClear:[1,"showClear"]},outputs:{onClear:"onClear"}});}}return l})();});export{B,I};