"use strict";
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2024-2026 Gracker (Chris)
// This file is part of SmartPerfetto. See LICENSE for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.probeTraceDuration = probeTraceDuration;
const PROBE_SQL = 'SELECT (end_ts - start_ts) / 1e9 AS duration_sec FROM trace_bounds';
async function probeTraceDuration(tps, traceId) {
    try {
        const result = await tps.query(traceId, PROBE_SQL);
        if (!result?.rows?.length)
            return 0;
        const raw = result.rows[0][0];
        const parsed = typeof raw === 'number' ? raw : Number(raw);
        return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
    }
    catch (err) {
        console.warn(`[sceneTraceDurationProbe] trace_bounds probe failed for ${traceId}:`, err?.message ?? err);
        return 0;
    }
}
//# sourceMappingURL=sceneTraceDurationProbe.js.map