"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../../../Class/Holder");
const local_1 = require("../../../../../../../process/share/local");
const _ids_1 = require("../../../../../../_ids");
class LocalShareGraph extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['opt', 'graph'],
            fo: ['id'],
            i: [],
            o: [],
        }, {
            input: {
                graph: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_LOCAL_SHARE_GRAPH);
        this._connected = false;
    }
    f({ opt, graph }, done) {
        const { id, terminate } = (0, local_1.shareLocalGraph)(graph);
        this._id = id;
        this._connected = true;
        this._terminate = terminate;
        done({ id });
    }
    d() {
        if (this._connected) {
            (0, local_1.stopBroadcastSource)(this._id);
            this._terminate();
            this._connected = false;
            this._id = undefined;
        }
    }
}
exports.default = LocalShareGraph;
//# sourceMappingURL=index.js.map