"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAgGridFilterNotifyModelFn = void 0;
const tslib_1 = require("tslib");
const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
function getAgGridFilterNotifyModelFn(adaptableApi, colId, onModelChange) {
    const notifyModel = (0, debounce_1.default)(() => {
        const isActive = adaptableApi.filterApi.columnFilterApi.isColumnFilterActiveForColumn(colId);
        setTimeout(() => {
            // call it with non null to indicate that the filter is active
            // call it with null to indicate that the filter is not active
            // as per the AG Grid documentation
            // ref: also-this-handles-the-LAYOUT_COLUMN_FILTER_EDIT-case
            onModelChange(isActive ? true : null);
        }, 50);
    }, 50, {
        trailing: true,
    });
    return notifyModel;
}
exports.getAgGridFilterNotifyModelFn = getAgGridFilterNotifyModelFn;
