import{o as u,aR as E,p as l,m as c,t as M,S as f,w as A,D as v,bm as T,aX as U,ag as x,bn as O}from"./app-BgLa5dit.js";import{D as z}from"./BE59vaMU.chunk.js";function N(o){O.source().values.options.forEach(t=>o[t.value]=t.name)}function J(o,t){var S;const C=u(E.currentUser()),w=u(l.getQuickFilters(t)),I=c.getHardcodedQuickFilters(C.data,t),g=[...w.data||[],...I].find(e=>e.id===o.quickFilter),{objectType:m}=M[t],L=c.getFilterQueryParams(o,m);let a=c.deserializeFilterParams(L,m);if(g){const e=c.deserializeFilterRequestBody(g.filters);a=c.deserializeFilterParams(e,m)}let i={};N(i);const r=new Set,p=new Set,b=new Set,_=new Set,n=new Set,h=new Set;a.forEach(e=>{e.values.forEach(s=>{if(!(s.name||!s.value))switch(e.field){case"backbone_audience":p.add(s.value);break;case"backbone_classification":b.add(s.value);break;case"classification":n.add(s.value);break;case"audience":_.add(s.value);break;case"rating":h.add(s.value.toString());break;case"normal_tag":case"hidden_tag":case"skill_tag":case"pedagogy_tag":case"curation_tag":i[s.value]=s.value;case"thumbnail_quality":case"production_year":case"description":case"date_created":case"max_resolution":case"dashboard_target":case"stage_date_modified":case"view_count":case"duration":case"video_count":case"object_status":case"curated_dashboards":case"rights_line_id":case"master_type":case"region":case"source":case"visibility":case"bypass_unused_stage":case"seo_title":case"seo_description":case"topic_type":case"depth":case"is_leaf_node":case"points_of_interest":break;default:e.condition!=="is_not_applicable"&&e.condition!=="is_not_not_applicable"&&e.condition!=="empty"&&e.condition!=="not_empty"&&r.add(s.value)}})});const y=u(r.size&&l.getMasterObjects([...r])),B=[...p].map(e=>f.getBackboneAudience(e)),D=[...b].map(e=>f.getBackboneClassification(e)),H=[...n].map(e=>l.getTopic(e)),P=[..._].map(e=>f.getAudience(e)),Q=A.flatten([...n].map(e=>[z.dashboards({targetType:v.Classification,classificationId:e},!0),z.dashboards({targetType:v.ClassificationDirectory,classificationId:e},!0)])),k=u(l.countryRatings()),R=T([...B,...D,...H,...P]),q=T(Q),F=(S=q.data)==null?void 0:S.reduce((e,s)=>(e.push(...s.data),e),[]);if(r.size&&!y.hasCompleted||h.size&&!k.hasCompleted||(p.size||b.size||n.size||_.size)&&!R.hasCompleted||n.size&&!q.hasCompleted)return a;i=[...y.data||[],...A.flatten(R.data||[]),...k.data||[]].reduce((e,s)=>"masterId"in s?(e[s.masterId]=s.name,e):(U.isType(s,x.Rating)&&(e[s.value]=s.name,e[s.code]=s.name),e[s.id]=s.name,e),i);const d=a.map(e=>({...e,values:e.values.map(s=>({value:s.value,name:i[s.value]}))}));return F.length&&d.push({id:d[d.length-1].id+1,field:"curated_dashboards",condition:"in",values:F.map(e=>({value:e.id,name:e.name}))}),d}export{J as u};
//# sourceMappingURL=B_g5BN6j.chunk.js.map
