"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Defaults_1 = require("../support/Defaults");
/**
 * @inheritDoc
 *
 * Off switch listener implementation.
 *
 * The textbox and the invoker will be disabled when
 * the incoming message doesn't contain a NER strategy.
 */
var OffSwitchListener = /** @class */ (function () {
    function OffSwitchListener(txt, btn) {
        this.txt = txt || Defaults_1.Defaults.textbox();
        this.btn = btn || Defaults_1.Defaults.invoker();
    }
    /**
     * @inheritDoc
     */
    OffSwitchListener.prototype.onConnected = function () {
        // do nothing
    };
    /**
     * @inheritDoc
     */
    OffSwitchListener.prototype.onConnectionLost = function () {
        // do nothing
    };
    /**
     * @inheritDoc
     */
    OffSwitchListener.prototype.onDisconnected = function () {
        // do nothing
    };
    /**
     * @inheritDoc
     */
    OffSwitchListener.prototype.onError = function (error) {
        // do nothing
    };
    /**
     * @inheritDoc
     */
    OffSwitchListener.prototype.onPacketSend = function (packet) {
        // do nothing
    };
    /**
     * @inheritDoc
     */
    OffSwitchListener.prototype.onMessage = function (data) {
        this.switchOff(data.nerStrategies);
    };
    /**
     * Sets the disabled flag and adds the CSS class
     * lto-off to the invoker and textbox, if there is no
     * NER strategy passed
     *
     * @param nerStrategies the NER strategy which
     * is used in the current message
     */
    OffSwitchListener.prototype.switchOff = function (nerStrategies) {
        this.txt.classList.remove("lto-off");
        this.btn.classList.remove("lto-off");
        if (nerStrategies === undefined) {
            this.txt.classList.add("lto-off");
            this.btn.classList.add("lto-off");
            this.txt.disabled = true;
            this.btn.disabled = true;
        }
        else {
            this.txt.focus();
            this.txt.disabled = false;
            this.btn.disabled = false;
        }
    };
    return OffSwitchListener;
}());
exports.OffSwitchListener = OffSwitchListener;
//# sourceMappingURL=OffSwitchListener.js.map