"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.ArchiveFieldModalState = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _mobx = require("mobx");
var _ConditionalModalState = require("./ConditionalModalState");
var _FieldOperationsBIReporter = require("./FieldOperationsBIReporter");
class ArchiveFieldModalState {
  constructor(params) {
    (0, _defineProperty2.default)(this, "biReporter", void 0);
    (0, _defineProperty2.default)(this, "archiver", void 0);
    (0, _defineProperty2.default)(this, "modal", void 0);
    this.biReporter = new _FieldOperationsBIReporter.FieldOperationsBIReporter({
      reportBi: params.reportBi
    });
    this.archiver = params.archiver;
    this.modal = new _ConditionalModalState.ConditionalModalState({
      onConfirm: async () => {
        if (!this.modal.value) {
          return;
        }
        this.biReporter.reportArchiveFieldModalCtaClicked('Archive');
        await this.archiver.archiveField(this.modal.value.id, this.modal.value.origin);
      },
      onClose: () => {
        this.biReporter.reportArchiveFieldModalCtaClicked('Cancel');
      }
    });
    (0, _mobx.makeAutoObservable)(this);
  }
}
exports.ArchiveFieldModalState = ArchiveFieldModalState;
//# sourceMappingURL=ArchiveFieldModalState.js.map