"use strict";
/**
 * Copyright: (c) Myia SAS 2026.
 * This file and its contents are licensed under the AGPLv3 License.
 * Please see the LICENSE file at the root of this repository
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildOkEvent = buildOkEvent;
const variable_snapshot_serializer_1 = require("../serializers/variable-snapshot-serializer");
function buildOkEvent(state, vars) {
    const enter = state.enterStack.pop();
    if (!enter)
        return;
    const n = state.clock.now() - state.startedAt;
    const event = {
        type: 'ok',
        seq: ++state.seq,
        enterSeq: enter.seq,
        t: n,
        wallTime: Date.now(),
        duration: n - enter.t,
    };
    const serialized = (0, variable_snapshot_serializer_1.safeVars)(vars);
    if (serialized)
        event.vars = serialized;
    state.exporter.write(event);
}
