"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.graphComponentFromSpec = graphComponentFromSpec;
exports.graphComponentFromId = graphComponentFromId;
const fromSpec_1 = require("../spec/fromSpec");
const util_1 = require("../spec/util");
const AsyncGraph_1 = require("../types/interface/async/AsyncGraph");
const componentFromSpec_1 = require("./componentFromSpec");
function graphComponentFromSpec(system, spec, input = {}) {
    const { specs } = system;
    const graph = (0, fromSpec_1.graphFromSpec)(system, spec, specs, {}, true);
    for (const pinId in input) {
        const data = input[pinId];
        graph.setPinData('input', pinId, data);
    }
    const $graph = (0, AsyncGraph_1.AsyncGraph)(graph);
    const component = (0, componentFromSpec_1.componentFromSpec)(system, spec, specs);
    component.connect($graph);
    graph.play();
    const client = { graph, component };
    return client;
}
function graphComponentFromId(system, specId, input = {}) {
    const { specs } = system;
    const spec = (0, util_1.getSpec)(specs, specId);
    const { component, graph } = graphComponentFromSpec(system, spec, input);
    return { component, graph };
}
//# sourceMappingURL=graphComponentFromSpec.js.map