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