"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const _ids_1 = require("../../../../_ids");
class Lookup extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['unit', 'name'],
            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._unlisten = this.__system.emitter.addListener('register', (_name, ref) => {
            if (_name === name) {
                done({ ref });
            }
        });
        if (ref) {
            done({ ref });
        }
    }
    d() {
        if (this._unlisten) {
            this._unlisten();
            this._unlisten = undefined;
        }
    }
}
exports.default = Lookup;
//# sourceMappingURL=index.js.map