import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import{useState as t,useRef as n,useEffect as o}from"react";import{throttle as i,isEqual as s}from"lodash";import l from"./constants.scss.js";function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function d(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}var c=parseInt(l.gap,10),p=parseInt(l.titleMinWidth,10)+c,y=function(e){var r;return(null===(r=e.current)||void 0===r?void 0:r.getBoundingClientRect().width)||0},u=function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];var o=t.filter((function(e){return!!e.current&&e.current.offsetWidth>0}));return e+o.reduce((function(e,r){return e+y(r)}),0)+(o.length>1?(o.length-1)*c:0)},f=function(e){var l=e.disabled,a=e.actionsRef,y=e.chipsRef,f=e.logoRef,v=e.rootRef,h=e.titleControlsRef,b=e.additionalControlsRef,m=e.versionRef,O=e.padModeRef,g=e.titleControlsLeft,V=t({}),w=r(V,2),j=w[0],C=w[1],R=n(-1);return o((function(){var e=i((function(){requestAnimationFrame((function(){var e,r=(null===(e=v.current)||void 0===e?void 0:e.offsetWidth)||0,t=function(e){var t,n=g&&u(p,f,m,y,a,h,b,O)<=r?d(d({},e),{},{root:{style:d(d({},null===(t=e.root)||void 0===t?void 0:t.style),{},{"--headerV3-responsivity-flexwrap":"nowrap"})}}):e;C((function(e){return s(e,n)?e:n}))},n=function(){if(g){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=u.apply(void 0,[0].concat(r))+c;return{"--headerV3-responsivity-maxWidth":"calc(100% - ".concat(n,"px)")}}};u(p,f,m,y,a,h,b,O)<=r?t({title:{style:{"--headerV3-responsivity-marginRight":0}}}):u(p,f,m,y,a)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},padMode:{style:{"--headerV3-responsivity-order":120}},additionalControls:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:n(f,m,y,a)}}):!O.current&&u(p,f,m,y)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:n(f,m,y)}}):u(p,f,m,y)<=r&&u(0,h,b,O,a)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},padMode:{style:{"--headerV3-responsivity-order":130}},actions:{style:{"--headerV3-responsivity-order":140},lastInLine:!0},title:{style:n(f,m,y)}}):t({linebreaks:[{order:100},{order:200}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},padMode:{style:{"--headerV3-responsivity-order":210}},chips:{style:{"--headerV3-responsivity-order":220},lastInLine:!0},title:{style:n(f,m)}})}))}),100,{leading:!0}),r=new ResizeObserver((function(){var r,t=(null===(r=v.current)||void 0===r?void 0:r.offsetWidth)||0;t!==R.current&&e(),R.current=t})),t=new MutationObserver(e);return v.current&&!l&&(r.observe(v.current),t.observe(v.current,{childList:!0,subtree:!0,characterData:!0}),e.cancel()),function(){r.disconnect(),t.disconnect()}}),[a,y,f,v,h,b,m,O,l,g]),j};export{f as useResponsivity};
//# sourceMappingURL=useResponsivity.js.map
