"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractSetUnitPinDataEventData = extractSetUnitPinDataEventData;
exports.stringifySetUnitPinDataEventData = stringifySetUnitPinDataEventData;
exports.watchGraphSetUnitPinData = watchGraphSetUnitPinData;
const stringify_1 = require("../../spec/stringify");
function extractSetUnitPinDataEventData(...[unitId, type, pinId, data, path]) {
    return {
        unitId,
        type,
        pinId,
        data,
        path,
    };
}
function stringifySetUnitPinDataEventData(data) {
    return {
        ...data,
        data: (0, stringify_1.stringify)(data.data),
    };
}
function watchGraphSetUnitPinData(event, graph, callback) {
    const listener = (...args) => {
        const data = stringifySetUnitPinDataEventData(extractSetUnitPinDataEventData(...args));
        callback({
            type: 'graph',
            event,
            data,
        });
    };
    graph.prependListener(event, listener);
    return () => {
        graph.removeListener(event, listener);
    };
}
//# sourceMappingURL=watchGraphSetUnitPinDataEvent.js.map