"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.NestedTableFlatModeStateBIReporter = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _bexCore = require("@wix/bex-core");
var _bi = require("@wix/bex-core/bi");
var _mobx = require("mobx");
class NestedTableFlatModeStateBIReporter {
  constructor(_state) {
    (0, _defineProperty2.default)(this, "state", void 0);
    (0, _defineProperty2.default)(this, "_createReportSearchResults", (0, _mobx.action)(() => {
      const {
        state
      } = this;
      const {
        query
      } = state;
      this.reportBi((0, _bexCore.withoutDefaults)(_bi.cairoFilterToggled)({
        filterName: 'search',
        origin: 'toolbar',
        actionType: 'add',
        filterValue: query.search.value,
        numFiltersActive: query.activeFiltersCount,
        filteredListSize: this.state.wrapper.nestedCollection._fetchAllTotal,
        currentFilters: JSON.stringify(query.filtersKey)
      }));
      const startTime = performance.now();
      const searchTerm = query.search.value;
      return (0, _mobx.action)(() => {
        this.reportBi((0, _bexCore.withoutDefaults)(_bi.cairoSearchResults)({
          searchTerm,
          searchResultsCnt: this.state.wrapper.nestedCollection._fetchAllTotal,
          loadingTime: Math.round(performance.now() - startTime)
        }));
      });
    }));
    this.state = _state;
  }
  get reportBi() {
    return this.state.wrapper.reportBi;
  }
}
exports.NestedTableFlatModeStateBIReporter = NestedTableFlatModeStateBIReporter;
//# sourceMappingURL=NestedTableFlatModeStateBIReporter.js.map