"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("lodash/isEqual"),r=require("../../utils/omitKey.js"),n=require("./cascade-hierarchies.js"),s=require("./pruneDownstreamFilters.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=i(e),o=i(t);function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){a.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}exports.createFilterCrudActions=function(e){var t=e.get,i=e.setWithMutation;return{setFilter:function(e,l){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"system",f=t().filters;if(void 0!==l){if(!o.default(f[e],l)&&(i({filters:u(u({},f),{},a.default({},e,l))},c),"companyId"!==e||!t().isLoadAllWells)){var p=n.getCascadeMaps(t().segment),d=p.downstream;d.has(e)&&s.pruneDownstreamFilters(e,{get:t,setWithMutation:i})}}else{if(!(e in f))return;i({filters:r.omitKey(f,e)},c)}},setFilters:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"system",n=t().filters,s=null!=e?e:{},a="external_sync"===r?u(u({},t().defaultFilters),s):s;o.default(n,a)||(i({filters:a},r),t().pruneAllCascades())},pruneAllCascades:function(){var e=n.getCascadeMaps(t().segment),r=e.hierarchies,a=e.downstream;r.forEach((function(e){var r=e.chain[0];a.has(r)&&s.pruneDownstreamFilters(r,{get:t,setWithMutation:i})}))},hasActiveFilters:function(){var e=t().filters;return Object.keys(e).length>0}}};
//# sourceMappingURL=createFilterCrudActions.js.map
