import { SelectFilterOption } from '../models';

export function flattenSelectFilterOption(options: SelectFilterOption[]): SelectFilterOption[] {
  return options.reduce<SelectFilterOption[]>(
    (acc, option) => [...acc, option, ...(Array.isArray(option.options) ? flattenSelectFilterOption(option.options) : [])],
    []
  );
}
