"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../Class/Holder");
const makeUnitRemoteRef_1 = require("../../../../client/makeUnitRemoteRef");
const UCGJEE_1 = require("../../../../types/interface/UCGJEE");
const _ids_1 = require("../../../_ids");
class RemoteShareGraph extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['graph', 'opt'],
            fo: [],
            i: ['message'],
            o: ['message'],
        }, {
            input: {
                graph: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_REMOTE_SHARE_GRAPH);
        this.__ = ['U'];
        this._disconnect = () => { };
        this._close = () => {
            this._ref = null;
        };
        this._send = (data) => {
            this._output.message.push(data);
        };
    }
    f({ graph, opt }, done) {
        const ref = (0, makeUnitRemoteRef_1.makeUnitRemoteRef)(graph, UCGJEE_1.UCGJEE, (data) => {
            this._send(data);
        });
        this._ref = ref;
        if (this._input.message.active()) {
            this._ref.exec(this._input.message.peak());
            this._input.message.pull();
        }
    }
    d() {
        this._disconnect();
        this._close();
    }
    async onIterDataInputData(name, data) {
        if (name === 'message') {
            if (this._ref) {
                this._ref.exec(data);
                this._input.message.pull();
            }
        }
    }
}
exports.default = RemoteShareGraph;
//# sourceMappingURL=index.js.map