import{r as s,c as t,h as i,g as h}from"./p-b891c2f1.js";import{a as e}from"./p-936390dd.js";import{F as a}from"./p-8fc67a82.js";import{i as n,m as o}from"./p-ef0920f1.js";import"./p-684c85b4.js";import"./p-aafd8ea4.js";import"./p-112455b1.js";const l=class{constructor(i){s(this,i),this.scChange=t(this,"scChange",7),this.size="medium",this.value="",this.pill=!1,this.showLabel=!0,this.help="",this.clearable=!1,this.disabled=!1,this.readonly=!1,this.required=!1,this.invalid=!1}async reportValidity(){return this.scInput.shadowRoot.querySelector("input").reportValidity()}async triggerFocus(s){return this.scInput.triggerFocus(s)}async setCustomValidity(s){this.scInput.setCustomValidity(s)}async triggerBlur(){return this.scInput.blur()}handleFocusChange(){var s,t,i,h;this.hasFocus?null===(t=null===(s=this.scInput)||void 0===s?void 0:s.focus)||void 0===t||t.call(s):null===(h=null===(i=this.scInput)||void 0===i?void 0:i.blur)||void 0===h||h.call(i)}handleChange(){this.updateValue()}handleInput(){this.updateValue()}updateValue(){const s=n(this.currencyCode)?parseFloat(this.scInput.value):(100*parseFloat(this.scInput.value)).toFixed(2);this.value=this.scInput.value?s.toString():""}componentDidLoad(){this.handleFocusChange(),this.formController=new a(this.el).addFormData(),document.addEventListener("wheel",(()=>{this.scInput.triggerBlur()}))}disconnectedCallback(){var s;null===(s=this.formController)||void 0===s||s.removeFormData()}render(){return i("div",null,i("sc-input",{size:this.size,label:this.label,showLabel:this.showLabel,help:this.help,ref:s=>this.scInput=s,type:"number",name:this.name,disabled:this.disabled,readonly:this.readonly,required:this.required,placeholder:this.placeholder,minlength:this.minlength,maxlength:this.maxlength,min:this.min?this.min/100:0,step:.001,max:this.max?this.max/100:null,autofocus:this.autofocus,inputmode:"decimal",onScChange:()=>this.handleChange(),onScInput:()=>this.handleInput(),value:o(parseFloat(this.value),this.currencyCode).toString()},i("span",{style:{opacity:"0.5"},slot:"prefix"},e(this.currencyCode)),i("span",{slot:"suffix"},i("slot",{name:"suffix"},this.showCode&&(null==this?void 0:this.currencyCode)&&i("span",{style:{opacity:"0.5"}},this.currencyCode.toUpperCase())))))}get el(){return h(this)}static get watchers(){return{hasFocus:["handleFocusChange"]}}};l.style=":host{display:block}";export{l as sc_price_input}