import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/typeof";import{useEffect as t}from"react";import{FilterType as n,StatusOptions as o}from"../constants.js";import{useFilterStore as i}from"../stores/filter-store/useFilterStore.js";import{getCascadeMaps as s}from"../stores/filter-store/utils/cascade-hierarchies.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}var c=function(c){var f=c.open,l=c.isAllWellsLoaded,p=c.filters,u=c.filterOptions,m=c.isLoadAllWells,y=c.setFilters,b=i((function(e){return e.segment}));t((function(){if(f&&l&&p){var t=s(b).upstream,i=new Map;u.forEach((function(e){var t=e.value,o=e.options;if(Array.isArray(o)){var s=t===n.company?o.map((function(e){return e&&"object"===r(e)?e.id:e})):o;i.set(t,new Set(s.filter((function(e){return null!=e}))))}else i.set(t,new Set)})),i.set(n.status,new Set(o.map((function(e){return e.value}))));var c=!1,O=function(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}({},p);i.forEach((function(e,r){var o=p[r];if(Array.isArray(o)&&0!==o.length&&(!t.has(r)||r===n.status)&&0!==e.size){var i=o.filter((function(r){return e.has(r)}));i.length!==o.length&&(c=!0,i.length>0?O[r]=i:r===n.company&&m?O[r]=[]:delete O[r])}})),c&&y(O,"system")}}),[f,l,p,u,m,y,b])};export{c as useFilterValidation};
//# sourceMappingURL=useFilterValidation.js.map
