"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("../../../utils/doesWellPassFilters.js"),t=require("./buildUpstreamFilters.js"),n=require("./cascade-hierarchies.js"),s=require("./extractUniqueWellValues.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=i(e);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}exports.pruneDownstreamFilters=function(e,i){var u=i.get,o=i.setWithMutation,c=u();if(c.isAllWellsLoaded&&c.wells){var f=n.getCascadeMaps(c.segment).downstream.get(e);if(f&&0!==f.length){var p=c.filters,b=!1,d=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?a(Object(t),!0).forEach((function(r){l.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}({},p);f.forEach((function(e){var n=p[e];if(Array.isArray(n)&&0!==n.length){var i=function(e,n){var i=n.wells,l=n.filters,a=n.segment;if(!i)return new Set;var u=t.buildUpstreamFilters(e,l,a),o=u?i.filter((function(e){return r.doesWellPassFilters(e,u,{segment:a})})):i,c=s.extractUniqueWellValues(o,e);return c.add("Null"),c}(e,c),l=n.filter((function(e){return i.has(e)}));l.length!==n.length&&(b=!0,l.length>0?d[e]=l:delete d[e])}})),b&&o({filters:d},"system")}}};
//# sourceMappingURL=pruneDownstreamFilters.js.map
