"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const bundle_1 = require("../../../../../bundle");
const Semifunctional_1 = require("../../../../../Class/Semifunctional");
const weakMerge_1 = require("../../../../../weakMerge");
const wrap_1 = require("../../../../../wrap");
const _ids_1 = require("../../../../_ids");
class Start extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({
            fi: ['graph', 'system', 'opt'],
            fo: ['graph'],
            i: ['done'],
            o: [],
        }, {
            input: {
                system: {
                    ref: true,
                },
            },
            output: {
                graph: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_START);
    }
    f({ graph: Graph, system, opt }, done) {
        var _a;
        const { paused } = opt || {};
        const { __bundle } = Graph;
        const id = __bundle.unit.id;
        const spec = ((_a = this.__system.getSpec(id)) !== null && _a !== void 0 ? _a : __bundle.specs[id]);
        const bundle = (0, bundle_1.bundleSpec)(spec, (0, weakMerge_1.weakMerge)(__bundle.specs, this.__system.specs));
        const _ = ['G', 'C', 'U'];
        const $graph = system.$newGraph({ bundle, _ });
        const graph = (0, wrap_1.$wrap)(this.__system, $graph, _);
        if (!paused) {
            graph.$play({});
        }
        if (!paused) {
            graph.$play({});
        }
        done({ graph });
    }
    onIterDataInputData(name, data) {
        // if (name === 'done') {
        this._forward_empty('graph');
        // }
    }
}
exports.default = Start;
//# sourceMappingURL=index.js.map