import { columnTypesMap } from './datatables.types.js';
import dayjs from '../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js';
import isSameOrAfter from '../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/plugin/isSameOrAfter.js';
import isSameOrBefore from '../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/plugin/isSameOrBefore.js';

dayjs.extend(isSameOrAfter);
dayjs.extend(isSameOrBefore);
const operationsOptions = {
    [columnTypesMap.select]: [
        {
            label: "is",
            value: "is",
            fn: (row, columnId, filterValue) => {
                return row.getValue(columnId) === filterValue.value;
            },
        },
        {
            label: "is not",
            value: "is not",
            fn: (row, columnId, filterValue) => {
                return row.getValue(columnId) !== filterValue.value;
            },
        },
    ],
    [columnTypesMap.number]: [
        {
            label: "=",
            value: "=",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) === Number(filterValue.value);
            },
        },
        {
            label: "!=",
            value: "!=",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) !== Number(filterValue.value);
            },
        },
        {
            label: ">",
            value: ">",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) > Number(filterValue.value);
            },
        },
        {
            label: ">=",
            value: ">=",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) >= Number(filterValue.value);
            },
        },
        {
            label: "<",
            value: "<",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) < Number(filterValue.value);
            },
        },
        {
            label: "<=",
            value: "<=",
            fn: (row, columnId, filterValue) => {
                return Number(row.getValue(columnId)) <= Number(filterValue.value);
            },
        },
    ],
    [columnTypesMap.text]: [
        {
            label: "contains",
            value: "contains",
            fn: (row, columnId, filterValue) => {
                const columnValue = row.getValue(columnId).toLowerCase();
                const filterStr = filterValue.value.toLowerCase();
                return columnValue.includes(filterStr);
            },
        },
        {
            label: "does not contains",
            value: "does not contains",
            fn: (row, columnId, filterValue) => {
                const columnValue = row.getValue(columnId).toLowerCase();
                const filterStr = filterValue.value.toLowerCase();
                return !columnValue.includes(filterStr);
            },
        },
        {
            label: "starts with",
            value: "starts with",
            fn: (row, columnId, filterValue) => {
                const columnValue = row.getValue(columnId).toLowerCase();
                const filterStr = filterValue.value.toLowerCase();
                return columnValue.startsWith(filterStr);
            },
        },
        {
            label: "ends with",
            value: "ends with",
            fn: (row, columnId, filterValue) => {
                const columnValue = row.getValue(columnId).toLowerCase();
                const filterStr = filterValue.value.toLowerCase();
                return columnValue.endsWith(filterStr);
            },
        },
        {
            label: "is empty",
            value: "is empty",
            fn: (row, columnId, filterValue) => {
                return row.getValue(columnId).length === 0;
            },
            hideValueField: true,
        },
        {
            label: "is not empty",
            value: "is not empty",
            fn: (row, columnId, filterValue) => {
                return row.getValue(columnId).length > 0;
            },
            hideValueField: true,
        },
    ],
    [columnTypesMap.date]: [
        {
            label: "is",
            value: "is",
            fn: (row, columnId, filterValue) => {
                return dayjs(row.getValue(columnId)).isSame(dayjs(filterValue.date), "day");
            },
        },
        {
            label: "is before",
            value: "is before",
            fn: (row, columnId, filterValue) => {
                return dayjs(row.getValue(columnId)).isBefore(dayjs(filterValue.date), "day");
            },
        },
        {
            label: "is after",
            value: "is after",
            fn: (row, columnId, filterValue) => {
                return dayjs(row.getValue(columnId)).isAfter(dayjs(filterValue.date), "day");
            },
        },
        {
            label: "is between",
            value: "is between",
            fn: (row, columnId, filterValue) => {
                return (dayjs(row.getValue(columnId)).isSameOrAfter(dayjs(filterValue.dateRange?.from), "day") &&
                    dayjs(row.getValue(columnId)).isSameOrBefore(dayjs(filterValue.dateRange?.to), "day"));
            },
            component: "rangePicker",
        },
    ],
};

export { operationsOptions };
//# sourceMappingURL=filterFns.js.map
