// SPDX-License-Identifier: Apache-2.0
import { Metrics } from './metrics.js';
import { InjectTokens } from '../../../core/dependency-injection/inject-tokens.js';
import { container } from 'tsyringe-neo';
import { ComponentTypes } from '../../../core/config/remote/enumerations/component-types.js';
export class AggregatedMetrics extends Metrics {
    snapshotName;
    clusterMetrics;
    runtimeInMinutes;
    transactionCount;
    events;
    date;
    gitHubSha;
    soloVersion;
    soloChartVersion;
    consensusNodeVersion;
    mirrorNodeVersion;
    blockNodeVersion;
    relayVersion;
    explorerVersion;
    constructor(snapshotName, clusterMetrics, cpuInMillicores, memoryInMebibytes, runtimeInMinutes, transactionCount, events, date, gitHubSha, soloVersion, soloChartVersion, consensusNodeVersion, mirrorNodeVersion, blockNodeVersion, relayVersion, explorerVersion) {
        super(cpuInMillicores, memoryInMebibytes);
        this.snapshotName = snapshotName;
        this.clusterMetrics = clusterMetrics;
        this.runtimeInMinutes = runtimeInMinutes;
        this.transactionCount = transactionCount;
        this.events = events;
        this.date = date;
        this.gitHubSha = gitHubSha;
        this.soloVersion = soloVersion;
        this.soloChartVersion = soloChartVersion;
        this.consensusNodeVersion = consensusNodeVersion;
        this.mirrorNodeVersion = mirrorNodeVersion;
        this.blockNodeVersion = blockNodeVersion;
        this.relayVersion = relayVersion;
        this.explorerVersion = explorerVersion;
        this.date = new Date();
        this.gitHubSha = process.env.GITHUB_SHA;
        const remoteConfigRuntimeState = container.resolve(InjectTokens.RemoteConfigRuntimeState);
        if (remoteConfigRuntimeState.isLoaded()) {
            this.soloVersion = remoteConfigRuntimeState.getComponentVersion(ComponentTypes.Cli);
            this.soloChartVersion = remoteConfigRuntimeState.getComponentVersion(ComponentTypes.Chart);
            this.consensusNodeVersion = remoteConfigRuntimeState.getComponentVersion(ComponentTypes.ConsensusNode);
            this.mirrorNodeVersion = remoteConfigRuntimeState.getComponentVersion(ComponentTypes.MirrorNode);
            this.blockNodeVersion = remoteConfigRuntimeState.getComponentVersion(ComponentTypes.BlockNode);
            this.relayVersion = remoteConfigRuntimeState.getComponentVersion(ComponentTypes.RelayNodes);
            this.explorerVersion = remoteConfigRuntimeState.getComponentVersion(ComponentTypes.Explorer);
        }
    }
    toString() {
        let outputString = `{"snapshotName": "${this.snapshotName}", ` +
            `"date": "${this.date.toISOString()}", ` +
            `"gitHubSha": "${this.gitHubSha}", ` +
            `"soloVersion": "${this.soloVersion}", ` +
            `"soloChartVersion": "${this.soloChartVersion}", ` +
            `"consensusNodeVersion": "${this.consensusNodeVersion}", ` +
            `"mirrorNodeVersion": "${this.mirrorNodeVersion}", ` +
            `"blockNodeVersion": "${this.blockNodeVersion}", ` +
            `"relayVersion": "${this.relayVersion}", ` +
            `"explorerVersion": "${this.explorerVersion}", ` +
            `"cpuInMillicores": ${this.cpuInMillicores}, ` +
            `"memoryInMebibytes": ${this.memoryInMebibytes}, ` +
            `"runtimeInMinutes": ${this.runtimeInMinutes}, ` +
            `"transactionCount": ${this.transactionCount}, ` +
            `"events": [${this.events.map(event => `"${event}"`).join(',')}], ` +
            '"clusterMetrics": [';
        for (let index = 0; index < this.clusterMetrics?.length; index++) {
            outputString += this.clusterMetrics[index].toString();
            if (index + 1 < this.clusterMetrics.length) {
                outputString += ', ';
            }
        }
        return `${outputString}]}`;
    }
}
//# sourceMappingURL=aggregated-metrics.js.map