/**
 * DevExtreme (cjs/ui/gantt/ui.gantt.data_changes_processing_helper.js)
 * Version: 23.2.6 (build 24140-0112)
 * Build date: Sun May 19 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
exports.GanttDataChangesProcessingHelper = void 0;
let GanttDataChangesProcessingHelper = function() {
    function GanttDataChangesProcessingHelper() {
        this._waitingForGanttViewReady = false;
        this._waitingForTreeListReady = false;
        this._completionActions = []
    }
    var _proto = GanttDataChangesProcessingHelper.prototype;
    _proto.onGanttViewReady = function() {
        this._stopWaitForGanttViewReady();
        this.executeActionsIfPossible()
    };
    _proto.onTreeListReady = function() {
        this._stopWaitForTreeListReady();
        this.executeActionsIfPossible()
    };
    _proto.addCompletionAction = function(action, waitGanttViewReady, waitTreeListReady) {
        if (action) {
            if (waitGanttViewReady) {
                this._startWaitForGanttViewReady()
            }
            if (waitTreeListReady) {
                this._startWaitForTreeListReady()
            }
            this._completionActions.push(action)
        }
    };
    _proto.executeActionsIfPossible = function() {
        if (this._canExecuteActions()) {
            this._completionActions.forEach(act => act());
            this._completionActions = []
        }
    };
    _proto._startWaitForGanttViewReady = function() {
        this._waitingForGanttViewReady = true
    };
    _proto._stopWaitForGanttViewReady = function() {
        this._waitingForGanttViewReady = false
    };
    _proto._startWaitForTreeListReady = function() {
        this._waitingForTreeListReady = true
    };
    _proto._stopWaitForTreeListReady = function() {
        this._waitingForTreeListReady = false
    };
    _proto._canExecuteActions = function() {
        return !(this._waitingForGanttViewReady || this._waitingForTreeListReady)
    };
    return GanttDataChangesProcessingHelper
}();
exports.GanttDataChangesProcessingHelper = GanttDataChangesProcessingHelper;
