'use strict';

var dayjs_min = require('../../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.cjs');
var isSameOrAfter = require('../../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/plugin/isSameOrAfter.cjs');
var isSameOrBefore = require('../../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/plugin/isSameOrBefore.cjs');

dayjs_min.default.extend(isSameOrAfter.default);
dayjs_min.default.extend(isSameOrBefore.default);
const filterOperationsMap = {
    number: {
        eq: (row, columnId, filterValue) => {
            return Number(row.getValue(columnId)) === Number(filterValue.value);
        },
        neq: (row, columnId, filterValue) => {
            return Number(row.getValue(columnId)) !== Number(filterValue.value);
        },
        lt: (row, columnId, filterValue) => {
            return Number(row.getValue(columnId)) < Number(filterValue.value);
        },
        lte: (row, columnId, filterValue) => {
            return Number(row.getValue(columnId)) <= Number(filterValue.value);
        },
        gt: (row, columnId, filterValue) => {
            return Number(row.getValue(columnId)) > Number(filterValue.value);
        },
        gte: (row, columnId, filterValue) => {
            return Number(row.getValue(columnId)) >= Number(filterValue.value);
        },
    },
    text: {
        eq: (row, columnId, filterValue) => {
            return (String(row.getValue(columnId)).toLowerCase() ===
                String(filterValue.value).toLowerCase());
        },
        neq: (row, columnId, filterValue) => {
            return (String(row.getValue(columnId)).toLowerCase() !==
                String(filterValue.value).toLowerCase());
        },
        like: (row, columnId, filterValue) => {
            const columnValue = row.getValue(columnId).toLowerCase();
            const filterStr = filterValue.value.toLowerCase();
            return columnValue.includes(filterStr);
        },
    },
    date: {
        eq: (row, columnId, filterValue) => {
            return dayjs_min.default(row.getValue(columnId)).isSame(dayjs_min.default(filterValue.date), "day");
        },
        neq: (row, columnId, filterValue) => {
            return !dayjs_min.default(row.getValue(columnId)).isSame(dayjs_min.default(filterValue.date), "day");
        },
        lt: (row, columnId, filterValue) => {
            return dayjs_min.default(row.getValue(columnId)).isBefore(dayjs_min.default(filterValue.date), "day");
        },
        lte: (row, columnId, filterValue) => {
            return dayjs_min.default(row.getValue(columnId)).isSameOrBefore(dayjs_min.default(filterValue.date), "day");
        },
        gt: (row, columnId, filterValue) => {
            return dayjs_min.default(row.getValue(columnId)).isAfter(dayjs_min.default(filterValue.date), "day");
        },
        gte: (row, columnId, filterValue) => {
            return dayjs_min.default(row.getValue(columnId)).isSameOrAfter(dayjs_min.default(filterValue.date), "day");
        },
    },
    select: {
        eq: (row, columnId, filterValue) => {
            // Select only supports string values
            return String(row.getValue(columnId)) === String(filterValue.value);
        },
        neq: (row, columnId, filterValue) => {
            // Select only supports string values
            return String(row.getValue(columnId)) !== String(filterValue.value);
        },
    },
};
function getFilterFn(type, operator) {
    // @ts-expect-error FilterOperatorTypes is union of all possible operators
    return filterOperationsMap[type][operator];
}

exports.filterOperationsMap = filterOperationsMap;
exports.getFilterFn = getFilterFn;
//# sourceMappingURL=filter-operations.cjs.map
