import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import{useState as t,useEffect as n,useRef as o}from"react";import{get as i,isEqual as l}from"lodash";import{getAppTitle as c,getExpander as u,getOffsetPicker as f,getSecondaryAsset as a,getModeSelect as s,getPrimaryAsset as p}from"../utils.js";import{LARGE_SIZE_LAYOUT as d,MEDIUM_SIZE_LAYOUT as y,SMALL_SIZE_LAYOUT as m}from"../constants.js";import{jsx as b}from"react/jsx-runtime";function v(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 h(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function O(e,o,l){var b=t(null),v=r(b,2),h=v[0],O=v[1];return n((function(){if(l&&o){var r=c(e),t=u(e),n=f(e),b=a(e),v=s(e),h=p(e),j=o[i(r,"key")]||0,g=o[i(t,"key")]||0,k=o[i(n,"key")]||0,w=o[i(b,"key")]||0,P=o[i(v,"key")]||0,D=o[i(h,"key")]||0;O(j+(g+k+w+P+D)<=l?d:j+D<=l?y:m)}}),[o,l]),h}function j(c){var u=o(),a=t(null),s=r(a,2),p=s[0],d=s[1],y=o({}),m=c.filter((function(e){return!!e})),v=b("div",{ref:u,style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:m.map((function(e,r){return b("div",{"data-key":null==e?void 0:e.key,style:{position:"absolute"},children:e},r)}))});return n((function(){var r;if(!l(m,y.current)){var t=f(c),n=i(t,"key"),o=Array.from(null===(r=u.current)||void 0===r?void 0:r.childNodes).reduce((function(r,t){var o,i=null==t||null===(o=t.getAttribute)||void 0===o?void 0:o.call(t,"data-key"),l=i===n?36:null==t?void 0:t.getBoundingClientRect().width;return h(h({},r),{},e({},i,l))}),{});Object.values(o).length===m.length&&(l(p,o)||d(o)),y.current=m}})),{componentsWidth:p,hiddenElements:v}}export{j as useComonentsWidth,O as useFilterLayout};
