import r from"@babel/runtime/helpers/slicedToArray";import{useState as t,useRef as n,useCallback as e,useLayoutEffect as o,useMemo as f}from"react";var i=function(i){var u=i.propOnFocus,l=i.propOnBlur,p=i.value,c=i.suffix,a=i.prefix,s=i.status,v=i.inputRef,d=i.forceShrink,h=String(p).length>0,g=t(!1),m=r(g,2),x=m[0],y=m[1],L=t({left:0,right:0}),b=r(L,2),A=b[0],T=b[1],k=n(null),w=n(),B=function(){var r,t,n,e=(null===(r=function(r,t){if(r&&t&&r!==t){for(var n=0,e=0,o=r;o&&o!==t;)n+=o.offsetLeft,e+=o.offsetTop,o=o.parentElement;return{offsetLeft:n,offsetTop:e}}}(w.current,k.current))||void 0===r?void 0:r.offsetLeft)||0;T({left:e,right:((null===(t=k.current)||void 0===t?void 0:t.offsetWidth)||0)-e-((null===(n=w.current)||void 0===n?void 0:n.offsetWidth)||0)})},F=e((function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];null==u||u.apply(void 0,t),y(!0)}),[u]),O=e((function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];null==l||l.apply(void 0,t),y(!1),B()}),[l]);return o(B,[a,c,s]),f((function(){var r=h||x||!!d;return{ref:k,inputRef:function(r){w.current=r,"function"==typeof v?v(r):v&&(v.current=r)},InputLabelProps:{component:"div",shrink:r,style:{left:r?"0px":"".concat(A.left,"px"),right:r?"0px":"".concat(A.right,"px")}},onFocus:F,onBlur:O}}),[h,x,F,O,A,v,d])};export{i as useShrink};
//# sourceMappingURL=useShrink.js.map
