"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EpisodeServiceClient = exports.EpisodeServiceService = exports.GetEpisodeManifestsResponse = exports.GetEpisodeManifestsRequest = exports.GetEpisodePlayerURLResponse = exports.EpisodePlayerParams = exports.GetEpisodePlayerURLRequest = exports.PerformEpisodeActionMetadata = exports.UnpublishEpisodeAction = exports.PublishEpisodeAction = exports.PerformEpisodeActionRequest = exports.BatchDeleteEpisodesMetadata = exports.BatchDeleteEpisodesRequest = exports.DeleteEpisodeMetadata = exports.DeleteEpisodeRequest = exports.UpdateEpisodeMetadata = exports.UpdateEpisodeRequest = exports.CreateEpisodeMetadata = exports.EpisodeSignURLAccessParams = exports.EpisodeAuthSystemAccessParams = exports.EpisodePublicAccessParams = exports.CreateEpisodeRequest = exports.BatchGetEpisodesResponse = exports.BatchGetEpisodesRequest = exports.ListEpisodesResponse = exports.ListEpisodesRequest = exports.GetEpisodeRequest = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const grpc_js_1 = require("@grpc/grpc-js");
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const field_mask_1 = require("../../../../google/protobuf/field_mask");
const duration_1 = require("../../../../google/protobuf/duration");
const timestamp_1 = require("../../../../google/protobuf/timestamp");
const episode_1 = require("../../../../yandex/cloud/video/v1/episode");
const manifest_1 = require("../../../../yandex/cloud/video/v1/manifest");
const operation_1 = require("../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.video.v1';
const baseGetEpisodeRequest = { episodeId: '' };
exports.GetEpisodeRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        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({}, baseGetEpisodeRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetEpisodeRequest);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetEpisodeRequest);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListEpisodesRequest = { pageSize: 0, pageToken: '', orderBy: '', filter: '' };
exports.ListEpisodesRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.streamId !== undefined) {
            writer.uint32(10).string(message.streamId);
        }
        if (message.lineId !== undefined) {
            writer.uint32(18).string(message.lineId);
        }
        if (message.pageSize !== 0) {
            writer.uint32(800).int64(message.pageSize);
        }
        if (message.pageToken !== '') {
            writer.uint32(810).string(message.pageToken);
        }
        if (message.orderBy !== '') {
            writer.uint32(818).string(message.orderBy);
        }
        if (message.filter !== '') {
            writer.uint32(826).string(message.filter);
        }
        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({}, baseListEpisodesRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.streamId = reader.string();
                    break;
                case 2:
                    message.lineId = reader.string();
                    break;
                case 100:
                    message.pageSize = longToNumber(reader.int64());
                    break;
                case 101:
                    message.pageToken = reader.string();
                    break;
                case 102:
                    message.orderBy = reader.string();
                    break;
                case 103:
                    message.filter = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseListEpisodesRequest);
        message.streamId =
            object.streamId !== undefined && object.streamId !== null
                ? String(object.streamId)
                : undefined;
        message.lineId =
            object.lineId !== undefined && object.lineId !== null
                ? String(object.lineId)
                : undefined;
        message.pageSize =
            object.pageSize !== undefined && object.pageSize !== null ? Number(object.pageSize) : 0;
        message.pageToken =
            object.pageToken !== undefined && object.pageToken !== null
                ? String(object.pageToken)
                : '';
        message.orderBy =
            object.orderBy !== undefined && object.orderBy !== null ? String(object.orderBy) : '';
        message.filter =
            object.filter !== undefined && object.filter !== null ? String(object.filter) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.streamId !== undefined && (obj.streamId = message.streamId);
        message.lineId !== undefined && (obj.lineId = message.lineId);
        message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize));
        message.pageToken !== undefined && (obj.pageToken = message.pageToken);
        message.orderBy !== undefined && (obj.orderBy = message.orderBy);
        message.filter !== undefined && (obj.filter = message.filter);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f;
        const message = Object.assign({}, baseListEpisodesRequest);
        message.streamId = (_a = object.streamId) !== null && _a !== void 0 ? _a : undefined;
        message.lineId = (_b = object.lineId) !== null && _b !== void 0 ? _b : undefined;
        message.pageSize = (_c = object.pageSize) !== null && _c !== void 0 ? _c : 0;
        message.pageToken = (_d = object.pageToken) !== null && _d !== void 0 ? _d : '';
        message.orderBy = (_e = object.orderBy) !== null && _e !== void 0 ? _e : '';
        message.filter = (_f = object.filter) !== null && _f !== void 0 ? _f : '';
        return message;
    },
};
const baseListEpisodesResponse = { nextPageToken: '' };
exports.ListEpisodesResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.episodes) {
            episode_1.Episode.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.nextPageToken !== '') {
            writer.uint32(802).string(message.nextPageToken);
        }
        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({}, baseListEpisodesResponse);
        message.episodes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodes.push(episode_1.Episode.decode(reader, reader.uint32()));
                    break;
                case 100:
                    message.nextPageToken = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseListEpisodesResponse);
        message.episodes = ((_a = object.episodes) !== null && _a !== void 0 ? _a : []).map((e) => episode_1.Episode.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.episodes) {
            obj.episodes = message.episodes.map((e) => (e ? episode_1.Episode.toJSON(e) : undefined));
        }
        else {
            obj.episodes = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListEpisodesResponse);
        message.episodes = ((_a = object.episodes) === null || _a === void 0 ? void 0 : _a.map((e) => episode_1.Episode.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseBatchGetEpisodesRequest = { channelId: '', episodeIds: '' };
exports.BatchGetEpisodesRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.channelId !== '') {
            writer.uint32(10).string(message.channelId);
        }
        for (const v of message.episodeIds) {
            writer.uint32(18).string(v);
        }
        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({}, baseBatchGetEpisodesRequest);
        message.episodeIds = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.channelId = reader.string();
                    break;
                case 2:
                    message.episodeIds.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchGetEpisodesRequest);
        message.channelId =
            object.channelId !== undefined && object.channelId !== null
                ? String(object.channelId)
                : '';
        message.episodeIds = ((_a = object.episodeIds) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.channelId !== undefined && (obj.channelId = message.channelId);
        if (message.episodeIds) {
            obj.episodeIds = message.episodeIds.map((e) => e);
        }
        else {
            obj.episodeIds = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseBatchGetEpisodesRequest);
        message.channelId = (_a = object.channelId) !== null && _a !== void 0 ? _a : '';
        message.episodeIds = ((_b = object.episodeIds) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
        return message;
    },
};
const baseBatchGetEpisodesResponse = {};
exports.BatchGetEpisodesResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.episodes) {
            episode_1.Episode.encode(v, writer.uint32(10).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({}, baseBatchGetEpisodesResponse);
        message.episodes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodes.push(episode_1.Episode.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchGetEpisodesResponse);
        message.episodes = ((_a = object.episodes) !== null && _a !== void 0 ? _a : []).map((e) => episode_1.Episode.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.episodes) {
            obj.episodes = message.episodes.map((e) => (e ? episode_1.Episode.toJSON(e) : undefined));
        }
        else {
            obj.episodes = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseBatchGetEpisodesResponse);
        message.episodes = ((_a = object.episodes) === null || _a === void 0 ? void 0 : _a.map((e) => episode_1.Episode.fromPartial(e))) || [];
        return message;
    },
};
const baseCreateEpisodeRequest = {
    title: '',
    description: '',
    thumbnailId: '',
    dvrSeconds: 0,
};
exports.CreateEpisodeRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.streamId !== undefined) {
            writer.uint32(802).string(message.streamId);
        }
        if (message.lineId !== undefined) {
            writer.uint32(810).string(message.lineId);
        }
        if (message.title !== '') {
            writer.uint32(18).string(message.title);
        }
        if (message.description !== '') {
            writer.uint32(26).string(message.description);
        }
        if (message.thumbnailId !== '') {
            writer.uint32(34).string(message.thumbnailId);
        }
        if (message.startTime !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.startTime), writer.uint32(42).fork()).ldelim();
        }
        if (message.finishTime !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.finishTime), writer.uint32(50).fork()).ldelim();
        }
        if (message.dvrSeconds !== 0) {
            writer.uint32(56).int64(message.dvrSeconds);
        }
        if (message.publicAccess !== undefined) {
            exports.EpisodePublicAccessParams.encode(message.publicAccess, writer.uint32(8002).fork()).ldelim();
        }
        if (message.authSystemAccess !== undefined) {
            exports.EpisodeAuthSystemAccessParams.encode(message.authSystemAccess, writer.uint32(8018).fork()).ldelim();
        }
        if (message.signUrlAccess !== undefined) {
            exports.EpisodeSignURLAccessParams.encode(message.signUrlAccess, writer.uint32(8026).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({}, baseCreateEpisodeRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 100:
                    message.streamId = reader.string();
                    break;
                case 101:
                    message.lineId = reader.string();
                    break;
                case 2:
                    message.title = reader.string();
                    break;
                case 3:
                    message.description = reader.string();
                    break;
                case 4:
                    message.thumbnailId = reader.string();
                    break;
                case 5:
                    message.startTime = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 6:
                    message.finishTime = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 7:
                    message.dvrSeconds = longToNumber(reader.int64());
                    break;
                case 1000:
                    message.publicAccess = exports.EpisodePublicAccessParams.decode(reader, reader.uint32());
                    break;
                case 1002:
                    message.authSystemAccess = exports.EpisodeAuthSystemAccessParams.decode(reader, reader.uint32());
                    break;
                case 1003:
                    message.signUrlAccess = exports.EpisodeSignURLAccessParams.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateEpisodeRequest);
        message.streamId =
            object.streamId !== undefined && object.streamId !== null
                ? String(object.streamId)
                : undefined;
        message.lineId =
            object.lineId !== undefined && object.lineId !== null
                ? String(object.lineId)
                : undefined;
        message.title =
            object.title !== undefined && object.title !== null ? String(object.title) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.thumbnailId =
            object.thumbnailId !== undefined && object.thumbnailId !== null
                ? String(object.thumbnailId)
                : '';
        message.startTime =
            object.startTime !== undefined && object.startTime !== null
                ? fromJsonTimestamp(object.startTime)
                : undefined;
        message.finishTime =
            object.finishTime !== undefined && object.finishTime !== null
                ? fromJsonTimestamp(object.finishTime)
                : undefined;
        message.dvrSeconds =
            object.dvrSeconds !== undefined && object.dvrSeconds !== null
                ? Number(object.dvrSeconds)
                : 0;
        message.publicAccess =
            object.publicAccess !== undefined && object.publicAccess !== null
                ? exports.EpisodePublicAccessParams.fromJSON(object.publicAccess)
                : undefined;
        message.authSystemAccess =
            object.authSystemAccess !== undefined && object.authSystemAccess !== null
                ? exports.EpisodeAuthSystemAccessParams.fromJSON(object.authSystemAccess)
                : undefined;
        message.signUrlAccess =
            object.signUrlAccess !== undefined && object.signUrlAccess !== null
                ? exports.EpisodeSignURLAccessParams.fromJSON(object.signUrlAccess)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.streamId !== undefined && (obj.streamId = message.streamId);
        message.lineId !== undefined && (obj.lineId = message.lineId);
        message.title !== undefined && (obj.title = message.title);
        message.description !== undefined && (obj.description = message.description);
        message.thumbnailId !== undefined && (obj.thumbnailId = message.thumbnailId);
        message.startTime !== undefined && (obj.startTime = message.startTime.toISOString());
        message.finishTime !== undefined && (obj.finishTime = message.finishTime.toISOString());
        message.dvrSeconds !== undefined && (obj.dvrSeconds = Math.round(message.dvrSeconds));
        message.publicAccess !== undefined &&
            (obj.publicAccess = message.publicAccess
                ? exports.EpisodePublicAccessParams.toJSON(message.publicAccess)
                : undefined);
        message.authSystemAccess !== undefined &&
            (obj.authSystemAccess = message.authSystemAccess
                ? exports.EpisodeAuthSystemAccessParams.toJSON(message.authSystemAccess)
                : undefined);
        message.signUrlAccess !== undefined &&
            (obj.signUrlAccess = message.signUrlAccess
                ? exports.EpisodeSignURLAccessParams.toJSON(message.signUrlAccess)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h;
        const message = Object.assign({}, baseCreateEpisodeRequest);
        message.streamId = (_a = object.streamId) !== null && _a !== void 0 ? _a : undefined;
        message.lineId = (_b = object.lineId) !== null && _b !== void 0 ? _b : undefined;
        message.title = (_c = object.title) !== null && _c !== void 0 ? _c : '';
        message.description = (_d = object.description) !== null && _d !== void 0 ? _d : '';
        message.thumbnailId = (_e = object.thumbnailId) !== null && _e !== void 0 ? _e : '';
        message.startTime = (_f = object.startTime) !== null && _f !== void 0 ? _f : undefined;
        message.finishTime = (_g = object.finishTime) !== null && _g !== void 0 ? _g : undefined;
        message.dvrSeconds = (_h = object.dvrSeconds) !== null && _h !== void 0 ? _h : 0;
        message.publicAccess =
            object.publicAccess !== undefined && object.publicAccess !== null
                ? exports.EpisodePublicAccessParams.fromPartial(object.publicAccess)
                : undefined;
        message.authSystemAccess =
            object.authSystemAccess !== undefined && object.authSystemAccess !== null
                ? exports.EpisodeAuthSystemAccessParams.fromPartial(object.authSystemAccess)
                : undefined;
        message.signUrlAccess =
            object.signUrlAccess !== undefined && object.signUrlAccess !== null
                ? exports.EpisodeSignURLAccessParams.fromPartial(object.signUrlAccess)
                : undefined;
        return message;
    },
};
const baseEpisodePublicAccessParams = {};
exports.EpisodePublicAccessParams = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        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({}, baseEpisodePublicAccessParams);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseEpisodePublicAccessParams);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseEpisodePublicAccessParams);
        return message;
    },
};
const baseEpisodeAuthSystemAccessParams = {};
exports.EpisodeAuthSystemAccessParams = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        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({}, baseEpisodeAuthSystemAccessParams);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseEpisodeAuthSystemAccessParams);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseEpisodeAuthSystemAccessParams);
        return message;
    },
};
const baseEpisodeSignURLAccessParams = {};
exports.EpisodeSignURLAccessParams = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        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({}, baseEpisodeSignURLAccessParams);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseEpisodeSignURLAccessParams);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseEpisodeSignURLAccessParams);
        return message;
    },
};
const baseCreateEpisodeMetadata = { episodeId: '' };
exports.CreateEpisodeMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        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({}, baseCreateEpisodeMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateEpisodeMetadata);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreateEpisodeMetadata);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseUpdateEpisodeRequest = {
    episodeId: '',
    title: '',
    description: '',
    thumbnailId: '',
    dvrSeconds: 0,
};
exports.UpdateEpisodeRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        if (message.fieldMask !== undefined) {
            field_mask_1.FieldMask.encode(message.fieldMask, writer.uint32(18).fork()).ldelim();
        }
        if (message.title !== '') {
            writer.uint32(26).string(message.title);
        }
        if (message.description !== '') {
            writer.uint32(34).string(message.description);
        }
        if (message.thumbnailId !== '') {
            writer.uint32(42).string(message.thumbnailId);
        }
        if (message.startTime !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.startTime), writer.uint32(50).fork()).ldelim();
        }
        if (message.finishTime !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.finishTime), writer.uint32(58).fork()).ldelim();
        }
        if (message.dvrSeconds !== 0) {
            writer.uint32(64).int64(message.dvrSeconds);
        }
        if (message.publicAccess !== undefined) {
            exports.EpisodePublicAccessParams.encode(message.publicAccess, writer.uint32(8002).fork()).ldelim();
        }
        if (message.authSystemAccess !== undefined) {
            exports.EpisodeAuthSystemAccessParams.encode(message.authSystemAccess, writer.uint32(8018).fork()).ldelim();
        }
        if (message.signUrlAccess !== undefined) {
            exports.EpisodeSignURLAccessParams.encode(message.signUrlAccess, writer.uint32(8026).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({}, baseUpdateEpisodeRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                case 2:
                    message.fieldMask = field_mask_1.FieldMask.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.title = reader.string();
                    break;
                case 4:
                    message.description = reader.string();
                    break;
                case 5:
                    message.thumbnailId = reader.string();
                    break;
                case 6:
                    message.startTime = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 7:
                    message.finishTime = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 8:
                    message.dvrSeconds = longToNumber(reader.int64());
                    break;
                case 1000:
                    message.publicAccess = exports.EpisodePublicAccessParams.decode(reader, reader.uint32());
                    break;
                case 1002:
                    message.authSystemAccess = exports.EpisodeAuthSystemAccessParams.decode(reader, reader.uint32());
                    break;
                case 1003:
                    message.signUrlAccess = exports.EpisodeSignURLAccessParams.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUpdateEpisodeRequest);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        message.fieldMask =
            object.fieldMask !== undefined && object.fieldMask !== null
                ? field_mask_1.FieldMask.fromJSON(object.fieldMask)
                : undefined;
        message.title =
            object.title !== undefined && object.title !== null ? String(object.title) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.thumbnailId =
            object.thumbnailId !== undefined && object.thumbnailId !== null
                ? String(object.thumbnailId)
                : '';
        message.startTime =
            object.startTime !== undefined && object.startTime !== null
                ? fromJsonTimestamp(object.startTime)
                : undefined;
        message.finishTime =
            object.finishTime !== undefined && object.finishTime !== null
                ? fromJsonTimestamp(object.finishTime)
                : undefined;
        message.dvrSeconds =
            object.dvrSeconds !== undefined && object.dvrSeconds !== null
                ? Number(object.dvrSeconds)
                : 0;
        message.publicAccess =
            object.publicAccess !== undefined && object.publicAccess !== null
                ? exports.EpisodePublicAccessParams.fromJSON(object.publicAccess)
                : undefined;
        message.authSystemAccess =
            object.authSystemAccess !== undefined && object.authSystemAccess !== null
                ? exports.EpisodeAuthSystemAccessParams.fromJSON(object.authSystemAccess)
                : undefined;
        message.signUrlAccess =
            object.signUrlAccess !== undefined && object.signUrlAccess !== null
                ? exports.EpisodeSignURLAccessParams.fromJSON(object.signUrlAccess)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        message.fieldMask !== undefined &&
            (obj.fieldMask = message.fieldMask ? field_mask_1.FieldMask.toJSON(message.fieldMask) : undefined);
        message.title !== undefined && (obj.title = message.title);
        message.description !== undefined && (obj.description = message.description);
        message.thumbnailId !== undefined && (obj.thumbnailId = message.thumbnailId);
        message.startTime !== undefined && (obj.startTime = message.startTime.toISOString());
        message.finishTime !== undefined && (obj.finishTime = message.finishTime.toISOString());
        message.dvrSeconds !== undefined && (obj.dvrSeconds = Math.round(message.dvrSeconds));
        message.publicAccess !== undefined &&
            (obj.publicAccess = message.publicAccess
                ? exports.EpisodePublicAccessParams.toJSON(message.publicAccess)
                : undefined);
        message.authSystemAccess !== undefined &&
            (obj.authSystemAccess = message.authSystemAccess
                ? exports.EpisodeAuthSystemAccessParams.toJSON(message.authSystemAccess)
                : undefined);
        message.signUrlAccess !== undefined &&
            (obj.signUrlAccess = message.signUrlAccess
                ? exports.EpisodeSignURLAccessParams.toJSON(message.signUrlAccess)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g;
        const message = Object.assign({}, baseUpdateEpisodeRequest);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        message.fieldMask =
            object.fieldMask !== undefined && object.fieldMask !== null
                ? field_mask_1.FieldMask.fromPartial(object.fieldMask)
                : undefined;
        message.title = (_b = object.title) !== null && _b !== void 0 ? _b : '';
        message.description = (_c = object.description) !== null && _c !== void 0 ? _c : '';
        message.thumbnailId = (_d = object.thumbnailId) !== null && _d !== void 0 ? _d : '';
        message.startTime = (_e = object.startTime) !== null && _e !== void 0 ? _e : undefined;
        message.finishTime = (_f = object.finishTime) !== null && _f !== void 0 ? _f : undefined;
        message.dvrSeconds = (_g = object.dvrSeconds) !== null && _g !== void 0 ? _g : 0;
        message.publicAccess =
            object.publicAccess !== undefined && object.publicAccess !== null
                ? exports.EpisodePublicAccessParams.fromPartial(object.publicAccess)
                : undefined;
        message.authSystemAccess =
            object.authSystemAccess !== undefined && object.authSystemAccess !== null
                ? exports.EpisodeAuthSystemAccessParams.fromPartial(object.authSystemAccess)
                : undefined;
        message.signUrlAccess =
            object.signUrlAccess !== undefined && object.signUrlAccess !== null
                ? exports.EpisodeSignURLAccessParams.fromPartial(object.signUrlAccess)
                : undefined;
        return message;
    },
};
const baseUpdateEpisodeMetadata = { episodeId: '' };
exports.UpdateEpisodeMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        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({}, baseUpdateEpisodeMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUpdateEpisodeMetadata);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseUpdateEpisodeMetadata);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteEpisodeRequest = { episodeId: '' };
exports.DeleteEpisodeRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        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({}, baseDeleteEpisodeRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteEpisodeRequest);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteEpisodeRequest);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteEpisodeMetadata = { episodeId: '' };
exports.DeleteEpisodeMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        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({}, baseDeleteEpisodeMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteEpisodeMetadata);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteEpisodeMetadata);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseBatchDeleteEpisodesRequest = { episodeIds: '' };
exports.BatchDeleteEpisodesRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.streamId !== undefined) {
            writer.uint32(802).string(message.streamId);
        }
        if (message.lineId !== undefined) {
            writer.uint32(810).string(message.lineId);
        }
        for (const v of message.episodeIds) {
            writer.uint32(10).string(v);
        }
        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({}, baseBatchDeleteEpisodesRequest);
        message.episodeIds = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 100:
                    message.streamId = reader.string();
                    break;
                case 101:
                    message.lineId = reader.string();
                    break;
                case 1:
                    message.episodeIds.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchDeleteEpisodesRequest);
        message.streamId =
            object.streamId !== undefined && object.streamId !== null
                ? String(object.streamId)
                : undefined;
        message.lineId =
            object.lineId !== undefined && object.lineId !== null
                ? String(object.lineId)
                : undefined;
        message.episodeIds = ((_a = object.episodeIds) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.streamId !== undefined && (obj.streamId = message.streamId);
        message.lineId !== undefined && (obj.lineId = message.lineId);
        if (message.episodeIds) {
            obj.episodeIds = message.episodeIds.map((e) => e);
        }
        else {
            obj.episodeIds = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseBatchDeleteEpisodesRequest);
        message.streamId = (_a = object.streamId) !== null && _a !== void 0 ? _a : undefined;
        message.lineId = (_b = object.lineId) !== null && _b !== void 0 ? _b : undefined;
        message.episodeIds = ((_c = object.episodeIds) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
        return message;
    },
};
const baseBatchDeleteEpisodesMetadata = { episodeIds: '' };
exports.BatchDeleteEpisodesMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.episodeIds) {
            writer.uint32(10).string(v);
        }
        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({}, baseBatchDeleteEpisodesMetadata);
        message.episodeIds = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeIds.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchDeleteEpisodesMetadata);
        message.episodeIds = ((_a = object.episodeIds) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.episodeIds) {
            obj.episodeIds = message.episodeIds.map((e) => e);
        }
        else {
            obj.episodeIds = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseBatchDeleteEpisodesMetadata);
        message.episodeIds = ((_a = object.episodeIds) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
        return message;
    },
};
const basePerformEpisodeActionRequest = { episodeId: '' };
exports.PerformEpisodeActionRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        if (message.publish !== undefined) {
            exports.PublishEpisodeAction.encode(message.publish, writer.uint32(8018).fork()).ldelim();
        }
        if (message.unpublish !== undefined) {
            exports.UnpublishEpisodeAction.encode(message.unpublish, writer.uint32(8026).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({}, basePerformEpisodeActionRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                case 1002:
                    message.publish = exports.PublishEpisodeAction.decode(reader, reader.uint32());
                    break;
                case 1003:
                    message.unpublish = exports.UnpublishEpisodeAction.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, basePerformEpisodeActionRequest);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        message.publish =
            object.publish !== undefined && object.publish !== null
                ? exports.PublishEpisodeAction.fromJSON(object.publish)
                : undefined;
        message.unpublish =
            object.unpublish !== undefined && object.unpublish !== null
                ? exports.UnpublishEpisodeAction.fromJSON(object.unpublish)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        message.publish !== undefined &&
            (obj.publish = message.publish
                ? exports.PublishEpisodeAction.toJSON(message.publish)
                : undefined);
        message.unpublish !== undefined &&
            (obj.unpublish = message.unpublish
                ? exports.UnpublishEpisodeAction.toJSON(message.unpublish)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, basePerformEpisodeActionRequest);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        message.publish =
            object.publish !== undefined && object.publish !== null
                ? exports.PublishEpisodeAction.fromPartial(object.publish)
                : undefined;
        message.unpublish =
            object.unpublish !== undefined && object.unpublish !== null
                ? exports.UnpublishEpisodeAction.fromPartial(object.unpublish)
                : undefined;
        return message;
    },
};
const basePublishEpisodeAction = {};
exports.PublishEpisodeAction = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        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({}, basePublishEpisodeAction);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, basePublishEpisodeAction);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, basePublishEpisodeAction);
        return message;
    },
};
const baseUnpublishEpisodeAction = {};
exports.UnpublishEpisodeAction = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        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({}, baseUnpublishEpisodeAction);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseUnpublishEpisodeAction);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseUnpublishEpisodeAction);
        return message;
    },
};
const basePerformEpisodeActionMetadata = { episodeId: '' };
exports.PerformEpisodeActionMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        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({}, basePerformEpisodeActionMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, basePerformEpisodeActionMetadata);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, basePerformEpisodeActionMetadata);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseGetEpisodePlayerURLRequest = { episodeId: '' };
exports.GetEpisodePlayerURLRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        if (message.params !== undefined) {
            exports.EpisodePlayerParams.encode(message.params, writer.uint32(18).fork()).ldelim();
        }
        if (message.signedUrlExpirationDuration !== undefined) {
            duration_1.Duration.encode(message.signedUrlExpirationDuration, writer.uint32(26).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({}, baseGetEpisodePlayerURLRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                case 2:
                    message.params = exports.EpisodePlayerParams.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.signedUrlExpirationDuration = duration_1.Duration.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetEpisodePlayerURLRequest);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        message.params =
            object.params !== undefined && object.params !== null
                ? exports.EpisodePlayerParams.fromJSON(object.params)
                : undefined;
        message.signedUrlExpirationDuration =
            object.signedUrlExpirationDuration !== undefined &&
                object.signedUrlExpirationDuration !== null
                ? duration_1.Duration.fromJSON(object.signedUrlExpirationDuration)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        message.params !== undefined &&
            (obj.params = message.params ? exports.EpisodePlayerParams.toJSON(message.params) : undefined);
        message.signedUrlExpirationDuration !== undefined &&
            (obj.signedUrlExpirationDuration = message.signedUrlExpirationDuration
                ? duration_1.Duration.toJSON(message.signedUrlExpirationDuration)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetEpisodePlayerURLRequest);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        message.params =
            object.params !== undefined && object.params !== null
                ? exports.EpisodePlayerParams.fromPartial(object.params)
                : undefined;
        message.signedUrlExpirationDuration =
            object.signedUrlExpirationDuration !== undefined &&
                object.signedUrlExpirationDuration !== null
                ? duration_1.Duration.fromPartial(object.signedUrlExpirationDuration)
                : undefined;
        return message;
    },
};
const baseEpisodePlayerParams = { mute: false, autoplay: false, hidden: false };
exports.EpisodePlayerParams = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.mute === true) {
            writer.uint32(8).bool(message.mute);
        }
        if (message.autoplay === true) {
            writer.uint32(16).bool(message.autoplay);
        }
        if (message.hidden === true) {
            writer.uint32(24).bool(message.hidden);
        }
        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({}, baseEpisodePlayerParams);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.mute = reader.bool();
                    break;
                case 2:
                    message.autoplay = reader.bool();
                    break;
                case 3:
                    message.hidden = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseEpisodePlayerParams);
        message.mute =
            object.mute !== undefined && object.mute !== null ? Boolean(object.mute) : false;
        message.autoplay =
            object.autoplay !== undefined && object.autoplay !== null
                ? Boolean(object.autoplay)
                : false;
        message.hidden =
            object.hidden !== undefined && object.hidden !== null ? Boolean(object.hidden) : false;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.mute !== undefined && (obj.mute = message.mute);
        message.autoplay !== undefined && (obj.autoplay = message.autoplay);
        message.hidden !== undefined && (obj.hidden = message.hidden);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseEpisodePlayerParams);
        message.mute = (_a = object.mute) !== null && _a !== void 0 ? _a : false;
        message.autoplay = (_b = object.autoplay) !== null && _b !== void 0 ? _b : false;
        message.hidden = (_c = object.hidden) !== null && _c !== void 0 ? _c : false;
        return message;
    },
};
const baseGetEpisodePlayerURLResponse = { playerUrl: '', html: '' };
exports.GetEpisodePlayerURLResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.playerUrl !== '') {
            writer.uint32(10).string(message.playerUrl);
        }
        if (message.html !== '') {
            writer.uint32(18).string(message.html);
        }
        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({}, baseGetEpisodePlayerURLResponse);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playerUrl = reader.string();
                    break;
                case 2:
                    message.html = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetEpisodePlayerURLResponse);
        message.playerUrl =
            object.playerUrl !== undefined && object.playerUrl !== null
                ? String(object.playerUrl)
                : '';
        message.html = object.html !== undefined && object.html !== null ? String(object.html) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.playerUrl !== undefined && (obj.playerUrl = message.playerUrl);
        message.html !== undefined && (obj.html = message.html);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseGetEpisodePlayerURLResponse);
        message.playerUrl = (_a = object.playerUrl) !== null && _a !== void 0 ? _a : '';
        message.html = (_b = object.html) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseGetEpisodeManifestsRequest = { episodeId: '' };
exports.GetEpisodeManifestsRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.episodeId !== '') {
            writer.uint32(10).string(message.episodeId);
        }
        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({}, baseGetEpisodeManifestsRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.episodeId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetEpisodeManifestsRequest);
        message.episodeId =
            object.episodeId !== undefined && object.episodeId !== null
                ? String(object.episodeId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.episodeId !== undefined && (obj.episodeId = message.episodeId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetEpisodeManifestsRequest);
        message.episodeId = (_a = object.episodeId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseGetEpisodeManifestsResponse = {};
exports.GetEpisodeManifestsResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.manifests) {
            manifest_1.Manifest.encode(v, writer.uint32(10).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({}, baseGetEpisodeManifestsResponse);
        message.manifests = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.manifests.push(manifest_1.Manifest.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseGetEpisodeManifestsResponse);
        message.manifests = ((_a = object.manifests) !== null && _a !== void 0 ? _a : []).map((e) => manifest_1.Manifest.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.manifests) {
            obj.manifests = message.manifests.map((e) => (e ? manifest_1.Manifest.toJSON(e) : undefined));
        }
        else {
            obj.manifests = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetEpisodeManifestsResponse);
        message.manifests = ((_a = object.manifests) === null || _a === void 0 ? void 0 : _a.map((e) => manifest_1.Manifest.fromPartial(e))) || [];
        return message;
    },
};
/** Episode management service. */
exports.EpisodeServiceService = {
    /** Get the specific channel. */
    get: {
        path: '/yandex.cloud.video.v1.EpisodeService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetEpisodeRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetEpisodeRequest.decode(value),
        responseSerialize: (value) => Buffer.from(episode_1.Episode.encode(value).finish()),
        responseDeserialize: (value) => episode_1.Episode.decode(value),
    },
    /** List episodes for stream or line. */
    list: {
        path: '/yandex.cloud.video.v1.EpisodeService/List',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListEpisodesRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListEpisodesRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListEpisodesResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListEpisodesResponse.decode(value),
    },
    /** Batch get episodes for channel. */
    batchGet: {
        path: '/yandex.cloud.video.v1.EpisodeService/BatchGet',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.BatchGetEpisodesRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.BatchGetEpisodesRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.BatchGetEpisodesResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.BatchGetEpisodesResponse.decode(value),
    },
    /** Create episode. */
    create: {
        path: '/yandex.cloud.video.v1.EpisodeService/Create',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.CreateEpisodeRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.CreateEpisodeRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Update episode. */
    update: {
        path: '/yandex.cloud.video.v1.EpisodeService/Update',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.UpdateEpisodeRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.UpdateEpisodeRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Delete episode. */
    delete: {
        path: '/yandex.cloud.video.v1.EpisodeService/Delete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.DeleteEpisodeRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.DeleteEpisodeRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Batch delete episodes. */
    batchDelete: {
        path: '/yandex.cloud.video.v1.EpisodeService/BatchDelete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.BatchDeleteEpisodesRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.BatchDeleteEpisodesRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Perform an action on the episode. */
    performAction: {
        path: '/yandex.cloud.video.v1.EpisodeService/PerformAction',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.PerformEpisodeActionRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.PerformEpisodeActionRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Get player url. */
    getPlayerURL: {
        path: '/yandex.cloud.video.v1.EpisodeService/GetPlayerURL',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetEpisodePlayerURLRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetEpisodePlayerURLRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.GetEpisodePlayerURLResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.GetEpisodePlayerURLResponse.decode(value),
    },
    /** Get manifest urls. */
    getManifests: {
        path: '/yandex.cloud.video.v1.EpisodeService/GetManifests',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetEpisodeManifestsRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetEpisodeManifestsRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.GetEpisodeManifestsResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.GetEpisodeManifestsResponse.decode(value),
    },
};
exports.EpisodeServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.EpisodeServiceService, 'yandex.cloud.video.v1.EpisodeService');
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 toTimestamp(date) {
    const seconds = date.getTime() / 1000;
    const nanos = (date.getTime() % 1000) * 1000000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = t.seconds * 1000;
    millis += t.nanos / 1000000;
    return new Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof Date) {
        return o;
    }
    else if (typeof o === 'string') {
        return new Date(o);
    }
    else {
        return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
    }
}
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();
}
