export function cloneFilter(filter) {
  return JSON.parse(JSON.stringify(filter));
}
export function replaceParamsInFilter(filter, params) {
  if (!params) {
    return filter;
  }
  if (filter.value && filter.value.includes('$')) {
    if (filter.value.includes('+')) {
      // for building vars with config like: 'admin@+$organisationDomain'
      // the value of this config with the organisationDomain=acme is 'admin@acme'
      const parts = filter.value.split('+');
      filter.value = parts.map(part => {
        if (part.includes('$')) {
          const paramId = part.replace('$', '');
          return params[paramId];
        }
        return part;
      }).join('');
    }
    else {
      const paramId = filter.value.replace('$', '');
      filter.value = params[paramId];
    }
  }
  return filter;
}
