import r from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/slicedToArray";import{useState as t,useEffect as i,useRef as o}from"react";import n from"react-dom";import{isEqual as l}from"lodash";import{MuiThemeProvider as u}from"@material-ui/core/styles";import c from"../components/FiltersToggler.js";import{getStartComponent as m,getMiddleComponent as s,getEndComponents as a}from"../utils.js";import{LARGE_SIZE_LAYOUT as d,MEDIUM_SIZE_LAYOUT as h,SMALL_SIZE_LAYOUT as p}from"../constants.js";import{darkTheme as f}from"../../../config/theme/index.js";import"@babel/runtime/helpers/typeof";import"highcharts";import"highcharts/highcharts-more";import"highcharts-multicolor-series";import"highcharts/modules/solid-gauge";import"highcharts/modules/heatmap";import"highcharts/modules/boost";import"highcharts/modules/exporting";import"highcharts/modules/xrange";import"highcharts/modules/dumbbell";import"highcharts/modules/pattern-fill";import"dompurify";import"../../../config/mapbox/index.js";import{jsx as v}from"react/jsx-runtime";function g(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,i)}return t}function y(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?g(Object(i),!0).forEach((function(t){r(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):g(Object(i)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(i,r))}))}return e}function b(r,o,n,l){var u=t(null),c=e(u,2),f=c[0],v=c[1];return i((function(){if(l&&o){var e=m(r),t=s(r),i=a(r),u=e&&t&&!i,c=e&&!t&&i,f=e&&t&&i;if(e&&!t&&!i){var g=o[e.key];if(g<=l)return void v(d);if(g<=l/2)return void v(h)}else if(u||c){var y=o[e.key],b=u?o[t.key]:o[i.key];if(y+b<=l)return void v(d);if(n+b<=l)return void v(h)}else if(f){var j=o[e.key],O=o[t.key],k=o[i.key];if(j+O+k<=l)return void v(d);if(n+O+k<=l)return void v(h);if(n+k<=l)return void v(p)}v(p)}}),[o,l]),f}function j(n){var u=o(),c=t(null),m=e(c,2),s=m[0],a=m[1],d=o({}),h=n.filter((function(r){return!!r})),p=v("div",{ref:u,style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:h.map((function(r,e){return v("div",{"data-key":null==r?void 0:r.key,style:{position:"absolute"},children:r},e)}))});return i((function(){var e;if(!l(h,d.current)){var t=Array.from(null===(e=u.current)||void 0===e?void 0:e.childNodes).reduce((function(e,t){var i,o=null==t||null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"data-key"),n=null==t?void 0:t.getBoundingClientRect().width;return y(y({},e),{},r({},o,n))}),{});Object.values(t).length===h.length&&(l(s,t)||a(t)),d.current=h}})),{componentsWidth:s,hiddenElements:p}}function O(){var r=t(null),o=e(r,2),l=o[0],m=o[1];return i((function(){var r=document.createElement("div");r.style.position="absolute",r.style.visibility="hidden",document.body.appendChild(r),n.render(v(u,{theme:f,children:v(c,{})}),r,(function(){var e=r.getBoundingClientRect();r.remove(),m(e.width)}))}),[]),l}export{O as useAppFilterTogglerWidth,j as useComonentsWidth,b as useFilterLayout};
