"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),n=require("lodash"),o=require("./constants.scss.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),l=i(r);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(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?a(Object(t),!0).forEach((function(r){s.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var c=parseInt(o.gap,10),u=parseInt(o.titleMinWidth,10)+c,y=function(e){var r;return(null===(r=e.current)||void 0===r?void 0:r.getBoundingClientRect().width)||0},f=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)};exports.useResponsivity=function(e){var r=e.disabled,o=e.actionsRef,i=e.chipsRef,s=e.logoRef,a=e.rootRef,y=e.titleControlsRef,p=e.additionalControlsRef,v=e.versionRef,h=e.padModeRef,b=e.titleControlsLeft,O=t.useState({}),g=l.default(O,2),V=g[0],j=g[1],w=t.useRef(-1);return t.useEffect((function(){var e=n.throttle((function(){requestAnimationFrame((function(){var e,r=(null===(e=a.current)||void 0===e?void 0:e.offsetWidth)||0,t=function(e){var t,l=b&&f(u,s,v,i,o,y,p,h)<=r?d(d({},e),{},{root:{style:d(d({},null===(t=e.root)||void 0===t?void 0:t.style),{},{"--headerV3-responsivity-flexwrap":"nowrap"})}}):e;j((function(e){return n.isEqual(e,l)?e:l}))},l=function(){if(b){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=f.apply(void 0,[0].concat(r))+c;return{"--headerV3-responsivity-maxWidth":"calc(100% - ".concat(n,"px)")}}};f(u,s,v,i,o,y,p,h)<=r?t({title:{style:{"--headerV3-responsivity-marginRight":0}}}):f(u,s,v,i,o)<=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:l(s,v,i,o)}}):!h.current&&f(u,s,v,i)<=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:l(s,v,i)}}):f(u,s,v,i)<=r&&f(0,y,p,h,o)<=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:l(s,v,i)}}):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:l(s,v)}})}))}),100,{leading:!0}),t=new ResizeObserver((function(){var r,t=(null===(r=a.current)||void 0===r?void 0:r.offsetWidth)||0;t!==w.current&&e(),w.current=t})),l=new MutationObserver(e);return a.current&&!r&&(t.observe(a.current),l.observe(a.current,{childList:!0,subtree:!0,characterData:!0}),e.cancel()),function(){t.disconnect(),l.disconnect()}}),[o,i,s,a,y,p,v,h,r,b]),V};
//# sourceMappingURL=useResponsivity.js.map
