import{l as e}from"./hooks.module-BrXTvcfS.js";import{p as t}from"./compat.module-C8KToj4y.js";import{t as n}from"./jsxRuntime.module-Cao1NCKs.js";t();function r({inputRef:t,className:r,type:i,currentValue:a,onChange:o,onBlur:s,autoFocus:c,...l}){e(()=>{c&&t?.current?.focus()},[]);function u(e){if(i===`number`){let{min:t,max:n}=l,r=parseInt(e,10);if(!Number.isFinite(r))return String(t??``);if(t&&r<parseInt(String(t),10))return String(t);if(n&&r>parseInt(String(n),10))return String(n)}return e}return n(`input`,{ref:t,className:`form-control ${r??``}`,type:i??`text`,value:a,onInput:o&&(e=>{let t=e.currentTarget,n=u(e.currentTarget.value);o?.(n,t.validity)}),onBlur:(e=>{let t=u(e.currentTarget.value);e.currentTarget.value=t,s?.(t)}),...l})}function i(e){return n(`label`,{class:`input-group tn-number-unit-pair`,children:[n(r,{...e}),n(`span`,{class:`input-group-text`,children:e.unit})]})}export{i as n,r as t};