"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Semifunctional_1 = require("../../../../../Class/Semifunctional");
const _ids_1 = require("../../../../_ids");
class Debug extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({
            fi: ['unit', 'event'],
            fo: [],
            i: ['remove'],
            o: ['data'],
        }, {
            input: {
                unit: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_DEBUG);
        this._unlisten = undefined;
        this._remove = () => {
            this._unlisten();
            this._listener = undefined;
            this._unlisten = undefined;
        };
        this.addListener('destroy', () => {
            if (this._listener) {
                this._remove();
                this._forward_empty('data');
            }
        });
    }
    f({ unit, event }) {
        const listener = (data) => {
            this._output.data.push(data);
        };
        this._listener = listener;
        const emitter = unit;
        this._unlisten = emitter.addListener(event, this._listener);
    }
    d() {
        this._remove();
        this._forward_empty('data');
    }
    onIterDataInputData(name, data) {
        // if (name === 'remove') {
        if (this._listener) {
            this._remove();
            this._done();
        }
        // }
    }
}
exports.default = Debug;
//# sourceMappingURL=index.js.map