"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpeechStatistics = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const statistics_common_1 = require("../../../../../yandex/cloud/speechsense/v1/analysis/statistics_common");
exports.protobufPackage = 'yandex.cloud.speechsense.v1.analysis';
const baseSpeechStatistics = {
    totalSimultaneousSpeechDurationSeconds: 0,
    totalSimultaneousSpeechDurationMs: 0,
    totalSimultaneousSpeechRatio: 0,
};
exports.SpeechStatistics = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.totalSimultaneousSpeechDurationSeconds !== 0) {
            writer.uint32(8).int64(message.totalSimultaneousSpeechDurationSeconds);
        }
        if (message.totalSimultaneousSpeechDurationMs !== 0) {
            writer.uint32(16).int64(message.totalSimultaneousSpeechDurationMs);
        }
        if (message.totalSimultaneousSpeechRatio !== 0) {
            writer.uint32(25).double(message.totalSimultaneousSpeechRatio);
        }
        if (message.simultaneousSpeechDurationEstimation !== undefined) {
            statistics_common_1.DescriptiveStatistics.encode(message.simultaneousSpeechDurationEstimation, writer.uint32(34).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSpeechStatistics);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.totalSimultaneousSpeechDurationSeconds = longToNumber(reader.int64());
                    break;
                case 2:
                    message.totalSimultaneousSpeechDurationMs = longToNumber(reader.int64());
                    break;
                case 3:
                    message.totalSimultaneousSpeechRatio = reader.double();
                    break;
                case 4:
                    message.simultaneousSpeechDurationEstimation = statistics_common_1.DescriptiveStatistics.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSpeechStatistics);
        message.totalSimultaneousSpeechDurationSeconds =
            object.totalSimultaneousSpeechDurationSeconds !== undefined &&
                object.totalSimultaneousSpeechDurationSeconds !== null
                ? Number(object.totalSimultaneousSpeechDurationSeconds)
                : 0;
        message.totalSimultaneousSpeechDurationMs =
            object.totalSimultaneousSpeechDurationMs !== undefined &&
                object.totalSimultaneousSpeechDurationMs !== null
                ? Number(object.totalSimultaneousSpeechDurationMs)
                : 0;
        message.totalSimultaneousSpeechRatio =
            object.totalSimultaneousSpeechRatio !== undefined &&
                object.totalSimultaneousSpeechRatio !== null
                ? Number(object.totalSimultaneousSpeechRatio)
                : 0;
        message.simultaneousSpeechDurationEstimation =
            object.simultaneousSpeechDurationEstimation !== undefined &&
                object.simultaneousSpeechDurationEstimation !== null
                ? statistics_common_1.DescriptiveStatistics.fromJSON(object.simultaneousSpeechDurationEstimation)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.totalSimultaneousSpeechDurationSeconds !== undefined &&
            (obj.totalSimultaneousSpeechDurationSeconds = Math.round(message.totalSimultaneousSpeechDurationSeconds));
        message.totalSimultaneousSpeechDurationMs !== undefined &&
            (obj.totalSimultaneousSpeechDurationMs = Math.round(message.totalSimultaneousSpeechDurationMs));
        message.totalSimultaneousSpeechRatio !== undefined &&
            (obj.totalSimultaneousSpeechRatio = message.totalSimultaneousSpeechRatio);
        message.simultaneousSpeechDurationEstimation !== undefined &&
            (obj.simultaneousSpeechDurationEstimation = message.simultaneousSpeechDurationEstimation
                ? statistics_common_1.DescriptiveStatistics.toJSON(message.simultaneousSpeechDurationEstimation)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseSpeechStatistics);
        message.totalSimultaneousSpeechDurationSeconds =
            (_a = object.totalSimultaneousSpeechDurationSeconds) !== null && _a !== void 0 ? _a : 0;
        message.totalSimultaneousSpeechDurationMs = (_b = object.totalSimultaneousSpeechDurationMs) !== null && _b !== void 0 ? _b : 0;
        message.totalSimultaneousSpeechRatio = (_c = object.totalSimultaneousSpeechRatio) !== null && _c !== void 0 ? _c : 0;
        message.simultaneousSpeechDurationEstimation =
            object.simultaneousSpeechDurationEstimation !== undefined &&
                object.simultaneousSpeechDurationEstimation !== null
                ? statistics_common_1.DescriptiveStatistics.fromPartial(object.simultaneousSpeechDurationEstimation)
                : undefined;
        return message;
    },
};
var globalThis = (() => {
    if (typeof globalThis !== 'undefined')
        return globalThis;
    if (typeof self !== 'undefined')
        return self;
    if (typeof window !== 'undefined')
        return window;
    if (typeof global !== 'undefined')
        return global;
    throw 'Unable to locate global object';
})();
function longToNumber(long) {
    if (long.gt(Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
    }
    return long.toNumber();
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
