import { STRING_OPERATORS, } from '@wix/bex-core';
import React from 'react';
import { DateCustomFieldFilter } from './DateCustomFieldFilter';
import { DateTimeCustomFieldFilter } from './DateTimeCustomFieldFilter';
import { CheckboxCustomFieldFilter } from './CheckboxCustomFieldFilter';
import { NumberRangeFilter } from '../NumberRangeFilter';
import { OperatorFilterPicker } from '../OperatorFilterPicker';
export const buildCustomFieldFilterElement = (state, customField) => {
    const customFieldFilterComponents = {
        date: DateCustomFieldFilter,
        dateTime: DateTimeCustomFieldFilter,
        checkbox: CheckboxCustomFieldFilter,
        integer: NumberRangeFilter,
        decimal: ({ filter }) => React.createElement(NumberRangeFilter, { filter: filter, decimal: true }),
        shortText: ({ filter }) => (React.createElement(OperatorFilterPicker, { filter: filter, allowedOperators: STRING_OPERATORS })),
        url: ({ filter }) => (React.createElement(OperatorFilterPicker, { filter: filter, allowedOperators: STRING_OPERATORS })),
        longText: ({ filter }) => (React.createElement(OperatorFilterPicker, { filter: filter, allowedOperators: STRING_OPERATORS })),
    };
    const CustomFieldFilterComponent = customFieldFilterComponents[customField.type];
    if (!CustomFieldFilterComponent) {
        return null;
    }
    const label = customField.label || customField.id;
    return (React.createElement(CustomFieldFilterComponent, { key: customField.id, filter: state.collection.filters[customField.id], accordionItemProps: {
            label,
        }, toolbarItemProps: {
            label,
        } }));
};
//# sourceMappingURL=buildCustomFieldFilterElement.js.map