"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Semifunctional_1 = require("../../../../../Class/Semifunctional");
const _ids_1 = require("../../../../_ids");
class Lookup extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({
            fi: ['unit', 'name'],
            i: ['done'],
            fo: ['ref'],
            o: [],
        }, {
            input: {
                unit: {
                    ref: true,
                },
            },
            output: {
                ref: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_LOOKUP);
    }
    f({ unit, name }, done) {
        const ref = this.__system.global.scope[name];
        this.__system.emitter.addListener('register', (_name, ref) => {
            if (_name === name) {
                done({ ref });
            }
        });
        if (ref) {
            done({ ref });
        }
    }
    onIterDataInputData(name, data) {
        switch (name) {
            case 'done':
                this._done();
                this._backward('done');
                break;
        }
    }
}
exports.default = Lookup;
//# sourceMappingURL=index.js.map