import { AdaptableModuleBase } from './AdaptableModuleBase';
import * as ModuleConstants from '../Utilities/Constants/ModuleConstants';
import { QuickSearchStatusBarContent } from '../View/QuickSearch/QuickSearchStatusBarContent';
import { QUICK_SEARCH_SET_CELL_MATCHING_STYLE_DEFAULT, QuickSearchSetCellMatchingStyle, } from '../Redux/ActionsReducers/QuickSearchRedux';
export class QuickSearchModule extends AdaptableModuleBase {
    constructor(api) {
        super(ModuleConstants.QuickSearchModuleId, ModuleConstants.QuickSearchFriendlyName, 'search-table', 'QuickSearchPopup', 'Quickly highlight all cells in the grid that contain matching query text', api);
    }
    getAgGridModuleDependencies() {
        return ['FindModule'];
    }
    getViewProperties() {
        return {
            getStatusBarPanelProps() {
                return {
                    content: QuickSearchStatusBarContent,
                };
            },
        };
    }
    onAdaptableReady() {
        const { api } = this;
        const { internalApi, agGridApi } = api;
        // Check for AG Grid QuickFilterModule if running Filter After Quick Search
        if (api.optionsApi.getQuickSearchOptions().filterGridAfterQuickSearch) {
            if (!api.internalApi.getAgGridModulesAdapter().isAgGridModuleRegistered('QuickFilterModule')) {
                api.consoleError('The AG Grid "GridFilter" Module is required if running Quick Search as Filter; Quick Search will run but no Filters will be applied');
            }
        }
        const isServerSideRowModel = agGridApi.getGridOption('rowModelType') === 'serverSide';
        if (isServerSideRowModel &&
            internalApi.getAdaptableState().QuickSearch.CellMatchStyle === undefined) {
            // for server side row model,
            // let's setup some defaults if there are no styles set
            // as there are no defaults in the AG Grid find functionality (as it only works for non ssrm)
            // so we need to set the defaults here
            this.api.internalApi.dispatchReduxAction(QuickSearchSetCellMatchingStyle(QUICK_SEARCH_SET_CELL_MATCHING_STYLE_DEFAULT));
        }
    }
}
