import{j as C,a as m,k as i,L as b,O as g}from"./DGQDO-VU.js";const h=["type","value"],V=C({__name:"PriceInput",props:{modelValue:{},currencyCode:{},locale:{},max:{},min:{},formatOptions:{default:null}},emits:["update:model-value","focus","blur"],setup(p,{emit:f}){const o=p,a=f,u=m(!1),c=m(),d=e=>{u.value=!0,setTimeout(()=>{const t=c.value;t instanceof HTMLInputElement&&t.select()},0),a("focus",e)},s=i(()=>u.value?"number":"text"),v=e=>{u.value=!1,a("blur",e)},l=i(()=>{if(!o.currencyCode)return 2;const t=new Intl.NumberFormat(o.locale,{style:"currency",currency:o.currencyCode}).formatToParts(0).find(n=>n.type==="fraction");return t?t.value.length:0}),y=e=>{const{value:t}=e.target;if(t===o.modelValue.toString())return;const n=parseFloat(t);let r;r=Math.round(n)*10**l.value,r=Math.min(Math.max(o.min,r),o.max),isNaN(r)||a("update:model-value",r)},x=e=>(e/10**l.value).toLocaleString(o.locale,{style:"currency",currency:o.currencyCode,...o.formatOptions});return(e,t)=>(b(),g("input",{ref_key:"root",ref:c,type:s.value,class:"w-[100px] rounded border text-center text-sm font-semibold",value:s.value==="text"?x(e.modelValue):e.modelValue/10**l.value,onFocus:d,onBlur:v,onChange:t[0]||(t[0]=n=>y(n))},null,40,h))}});export{V as _};