import r from"@babel/runtime/helpers/toConsumableArray";import{FilterOptions as e,FilterType as n}from"../../../constants.js";import{doesWellPassFilters as t,WELL_PROPERTY_FILTER_KEYS as a}from"../../../utils/doesWellPassFilters.js";import{getCascadeMaps as i}from"./cascade-hierarchies.js";import{extractUniqueWellValues as l}from"./extractUniqueWellValues.js";var o=function(o,u,s,c,f){var m=s?e:e.filter((function(r){return r.value!==n.company})),p=o.filter((function(r){return t(r,c,{excludeKeys:a,segment:f})})),v=i(f),h=v.hierarchies,y=v.upstream,d=function(r,e,n,t){var a=new Map;return n.forEach((function(n){var i=n.chain,l=r;i.forEach((function(n){t.has(n)?a.set(n,l):a.set(n,r);var i=e[n];if(Array.isArray(i)&&i.length>0){var o=i.map(String);l=l.filter((function(r){var e=r[n];return null==e||"Null"===e?o.includes("Null"):Array.isArray(e)?e.some((function(r){return o.includes(String(r))})):o.includes(String(e))}))}}))})),a}(p,c,h,y);return m.map((function(e){var t,a=e.value,i=e.label;if(a===n.company)return{value:a,label:i,options:u||[]};var s,c=null!==(t=d.get(a))&&void 0!==t?t:o;return{value:a,label:i,options:(s=l(c,a),r(s).sort().concat(["Null"]))}}))};export{o as computeCascadedOptions};
//# sourceMappingURL=computeCascadedOptions.js.map
