"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.watchGraphUnitCloneEvent = exports.watchGraphUnitEvent = void 0;
function watchGraphUnitEvent(event, graph, callback) {
    const listener = (unitId, unit, path) => {
        const bundle = unit.getUnitBundleSpec();
        callback({
            type: 'graph',
            event,
            data: {
                unitId,
                bundle,
                path,
            },
        });
    };
    graph.prependListener(event, listener);
    return () => {
        graph.removeListener(event, listener);
    };
}
exports.watchGraphUnitEvent = watchGraphUnitEvent;
function watchGraphUnitCloneEvent(event, graph, callback) {
    const listener = (unitId, newUnitId, unit, path) => {
        callback({
            type: 'graph',
            event,
            data: {
                unitId,
                newUnitId,
                path,
            },
        });
    };
    graph.prependListener(event, listener);
    return () => {
        graph.removeListener(event, listener);
    };
}
exports.watchGraphUnitCloneEvent = watchGraphUnitCloneEvent;
//# sourceMappingURL=watchGraphUnitEvent.js.map