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