"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.NestedTableFlatModeSectionState = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _bexCore = require("@wix/bex-core");
var _createNestedOptimisticActions = require("./createNestedOptimisticActions");
class NestedTableFlatModeSectionState {
  constructor(params) {
    (0, _defineProperty2.default)(this, "collection", void 0);
    (0, _defineProperty2.default)(this, "levelDescriptor", void 0);
    (0, _defineProperty2.default)(this, "levelDescriptors", []);
    (0, _defineProperty2.default)(this, "initTask", new _bexCore.TaskState());
    const {
      levelDescriptor
    } = params;
    this.levelDescriptor = levelDescriptor;
    const nestedOptimisticActionsState = {
      levelDescriptor: this.levelDescriptor
    };
    const {
      collection,
      parentFilter
    } = levelDescriptor.createCollection(nestedOptimisticActionsState);
    (0, _createNestedOptimisticActions.createNestedOptimisticActions)(params.flatModeState.wrapper.container, collection, {
      ...nestedOptimisticActionsState,
      parentFilter
    });
    this.collection = collection;
    const {
      query: sharedQuery
    } = params;
    const {
      query
    } = collection;
    (0, _bexCore.syncWithSharedQuery)(query, sharedQuery);
  }
  get query() {
    return this.collection.query;
  }
  get columns() {
    return this.levelDescriptor.columns;
  }
  get renderMainColumn() {
    return this.levelDescriptor.renderMainColumn;
  }
  get breadcrumbs() {
    return this.levelDescriptor.breadcrumbs;
  }
  get expandable() {
    return this.levelDescriptor.expandable;
  }
  init() {
    var _collection$_optimist;
    const {
      collection
    } = this;
    const disposers = [(_collection$_optimist = collection._optimisticActions) == null ? void 0 : _collection$_optimist.init()];
    return () => {
      disposers.forEach(d => d == null ? void 0 : d());
    };
  }
}
exports.NestedTableFlatModeSectionState = NestedTableFlatModeSectionState;
//# sourceMappingURL=NestedTableFlatModeSectionState.js.map