"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.FiltersPanelState = 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 FiltersPanelState {
  constructor(params) {
    (0, _defineProperty2.default)(this, "toolbar", void 0);
    (0, _defineProperty2.default)(this, "searchValue", '');
    (0, _defineProperty2.default)(this, "onCloseButtonClick", (0, _mobx.action)(async () => {
      const {
        reportBi,
        panels,
        pendingQuery
      } = this.toolbar;
      const result = await (pendingQuery == null ? void 0 : pendingQuery.onCloseFiltersPanelClick());
      if (result === 'dismissed') {
        return;
      }
      this.clearSearch();
      panels.closeSidePanel();
      reportBi((0, _bexCore.withoutDefaults)(_bi.cairoFiltersPanelUsed)({
        ...this.toolbar._commonDynamicBiParams(),
        origin: 'X Button',
        isOpened: false,
        feature: 'Filter'
      }));
    }));
    this.toolbar = params.toolbar;
    (0, _mobx.makeObservable)(this, {
      searchValue: _mobx.observable.ref,
      setSearchValue: _mobx.action.bound,
      clearSearch: _mobx.action.bound
    });
  }
  setSearchValue(value) {
    this.searchValue = value;
  }
  clearSearch() {
    this.searchValue = '';
  }
}
exports.FiltersPanelState = FiltersPanelState;
//# sourceMappingURL=FiltersPanelState.js.map