import{r as t,c as s,h as e,H as i}from"./p-CV0Pyo1O.js";import{I as a}from"./p-Ce_F4E0f.js";import{C as h}from"./p-CVaOFfrI.js";import{E as r,x as o,y as n,q as l,u as c,v as d}from"./p-CPKMvyV_.js";import{F as p}from"./p-B5gBiARs.js";import{F as f}from"./p-Ce_W43gc.js";import"./p-CZfYo5-1.js";const m=class{constructor(e){t(this,e),this.formControlInput=s(this,"formControlInput",7),this.formControlBlur=s(this,"formControlBlur",7),this.imask=null,this.isFocused=!1,this.errorText="",this.defaultValue="0",this.inputHandler=()=>{},this.maskOptions=h.DECIMAL,this.disabled=!1,this.initializeIMask=()=>{this.textInput&&(this.imask=a(this.textInput,this.maskOptions),this.imask.on("accept",(()=>{const t=this.imask.unmaskedValue;this.inputHandler(this.name,t),this.formControlInput.emit({name:this.name,value:t})})),this.textInput.addEventListener("blur",(()=>this.formControlBlur.emit())))},this.handleFormControlInput=t=>{const s=t.target.getAttribute("name");this.formControlInput.emit({name:s,value:this.imask.unmaskedValue})},this.updateInput=t=>{this.imask&&(this.imask.value=String(t))}}handleDefaultValueChange(t){this.updateInput(t)}componentDidLoad(){this.initializeIMask(),this.updateInput(this.defaultValue)}disconnectedCallback(){var t;null===(t=this.imask)||void 0===t||t.destroy()}get inputPart(){let t=r;return this.errorText&&(t=l),this.disabled&&(t=c),this.isFocused&&(t=d),t}render(){return e(i,{key:"8ecc68592c7e6ef4418301935dde43e4ea10404d"},e("div",{key:"ba267bd049287c297aa67b761214b9d60503e605",class:"form-group d-flex flex-column"},e("label",{key:"b020e228d70145d758bf58298914ed2b3384bbbc",part:o,class:"form-label",htmlFor:this.name},this.label),e("div",{key:"08415f471180958426563cf0e47e016b292108c7",class:"input-group"},e("span",{key:"dc22d1181a2a23e77003ee67212e724e48c2201e",class:"input-group-text",part:n},"$"),e("input",{key:"3cdedc0317df58360601186dd744bcb721a68ec7",ref:t=>this.textInput=t,id:this.name,name:this.name,onFocus:()=>this.isFocused=!0,onBlur:()=>{this.isFocused=!1,this.formControlBlur.emit()},onInput:this.handleFormControlInput,part:this.inputPart,class:this.errorText?"form-control monetary is-invalid":"form-control monetary",type:"text",disabled:this.disabled})),e(p,{key:"1315bdeefe7a551fbbb30680d289743a22a3792d",helpText:this.helpText,name:this.name}),e(f,{key:"7212797f21917530b6bb093f146f1ebead4c232b",errorText:this.errorText,name:this.name})))}static get watchers(){return{defaultValue:["handleDefaultValueChange"]}}};export{m as form_control_monetary_provisioning}