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