import { transformCustomDateFilterToWQL } from './transformCustomDateFilterToWQL';
import { transformCustomCheckboxToWQL } from './transformCustomCheckboxToWQL';
import { transformCustomNumberRangeFilterToWQL } from './transformCustomNumberRangeFilterToWQL';
import { prefixFieldWithNamespace } from '../../state/simplifyExtendedColumns';
import { transformOperatorFilterToWQL } from './transformOperatorFilterToWQL';
export const transformCustomFiltersToWQL = (state, filters) => {
    const transformToWqlMapper = {
        date: transformCustomDateFilterToWQL,
        dateTime: transformCustomDateFilterToWQL,
        checkbox: transformCustomCheckboxToWQL,
        decimal: transformCustomNumberRangeFilterToWQL,
        integer: transformCustomNumberRangeFilterToWQL,
        shortText: transformOperatorFilterToWQL,
        longText: transformOperatorFilterToWQL,
        url: transformOperatorFilterToWQL,
    };
    const platformizedFilters = Object.keys(filters).reduce((acc, filterId) => {
        const filterValue = filters[filterId];
        const currCustomField = state.toolbar.collectionDataExtension?.dataExtension.filterableCustomFields.find((field) => field.id === filterId);
        if (!currCustomField || filterValue == null) {
            return acc;
        }
        const filterName = prefixFieldWithNamespace(currCustomField.id, currCustomField.namespace);
        const transformToWql = transformToWqlMapper[currCustomField.type];
        if (!transformToWql) {
            return acc;
        }
        acc.push(...transformToWql(filterName, filterValue));
        return acc;
    }, []);
    return { $and: platformizedFilters };
};
//# sourceMappingURL=transformCustomFiltersToWQL.js.map