/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends } from "tslib";
import { Base, delegateCombine, delegateRemove, runOn, markType } from "igniteui-angular-core";
import { Message } from "./Message";
import { Queue$1 } from "igniteui-angular-core";
/**
 * @hidden
 */
var MessageChannel = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(MessageChannel, _super);
    function MessageChannel() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.c = new Queue$1(Message.$);
        _this.messageSent = null;
        _this.a = null;
        return _this;
    }
    MessageChannel.prototype.i = function (a) {
        if (this.messageSent != null) {
            this.messageSent(a);
        }
        else {
            this.c.g(a);
        }
    };
    MessageChannel.prototype.e = function (a) {
        this.messageSent = delegateCombine(this.messageSent, a);
        while (this.c.count > 0) {
            var b = this.c.b();
            this.messageSent(b);
        }
    };
    MessageChannel.prototype.h = function (a) {
        this.messageSent = delegateRemove(this.messageSent, a);
    };
    MessageChannel.prototype.f = function (a) {
        this.a = a;
        this.e(runOn(this, this.j));
    };
    MessageChannel.prototype.g = function () {
        if (this.a == null) {
            return;
        }
        this.h(runOn(this, this.j));
        this.a = null;
    };
    MessageChannel.prototype.j = function (a) {
        if (this.a != null) {
            this.a.i(a);
        }
    };
    MessageChannel.prototype.toString = function () {
        return "MessageQueue";
    };
    MessageChannel.$t = markType(MessageChannel, 'MessageChannel');
    return MessageChannel;
}(Base));
export { MessageChannel };
//# sourceMappingURL=MessageChannel.js.map
