"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Primitive_1 = require("../../../../Primitive");
const _ids_1 = require("../../../_ids");
class Lever extends Primitive_1.Primitive {
    constructor(system) {
        super({
            i: ['a', 'b', 'c'],
            o: ['a'],
        }, {}, system, _ids_1.ID_LEVER);
    }
    onDataInputData() {
        if (this._o_active.size === 0) {
            if (this._i.a !== undefined && this._i.c === true) {
                this._current = 'a';
                this._forward('a', this._i[this._current]);
            }
            else if (this._i.b !== undefined && this._i.c === false) {
                this._current = 'b';
                this._forward('a', this._i[this._current]);
            }
        }
    }
    onDataInputDrop(name) {
        if (this._current === name || name === 'c') {
            this._forward_all_empty();
        }
    }
    onDataOutputDrop() {
        this._done();
    }
    _done() {
        const current = this._current;
        this._current = undefined;
        this._input[current].pull();
        this._input.c.pull();
    }
}
exports.default = Lever;
//# sourceMappingURL=Class.js.map