import { cloneFilter, replaceParamsInFilter } from '@dvn/core/util/filter';
export function buildSort(query) {
  if (query && query.sort) {
    return query.sort;
  }
  return undefined;
}
export function buildQuery(query, quickFilter, params) {
  let queryFilter = query ? query.filter : undefined;
  if (quickFilter) {
    if (query && query.filter) {
      queryFilter = {
        operator: 'and',
        filters: [query.filter, quickFilter]
      };
    }
    else {
      queryFilter = quickFilter;
    }
  }
  if (!queryFilter) {
    return undefined;
  }
  return replaceParamsInFilter(cloneFilter(queryFilter), params);
}
