// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v1.181.1
//   protoc               v3.21.12
// source: Event.proto
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "dai.proto.event";
function createBaseBatchUploadEvents() {
    return { events: [] };
}
export const BatchUploadEvents = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.events) {
            Event.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseBatchUploadEvents();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.events.push(Event.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { events: globalThis.Array.isArray(object?.events) ? object.events.map((e) => Event.fromJSON(e)) : [] };
    },
    toJSON(message) {
        const obj = {};
        if (message.events?.length) {
            obj.events = message.events.map((e) => Event.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return BatchUploadEvents.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseBatchUploadEvents();
        message.events = object.events?.map((e) => Event.fromPartial(e)) || [];
        return message;
    },
};
function createBaseEvent() {
    return {
        nonce: undefined,
        createdAt: 0,
        name: "",
        tags: [],
        extras: {},
        expectFilesNum: 0,
        sourceSerialNumber: undefined,
        sourceAppId: undefined,
        sourceAppIdentifier: undefined,
    };
}
export const Event = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.nonce !== undefined) {
            writer.uint32(10).string(message.nonce);
        }
        if (message.createdAt !== 0) {
            writer.uint32(16).int64(message.createdAt);
        }
        if (message.name !== "") {
            writer.uint32(26).string(message.name);
        }
        for (const v of message.tags) {
            writer.uint32(34).string(v);
        }
        Object.entries(message.extras).forEach(([key, value]) => {
            Event_ExtrasEntry.encode({ key: key, value }, writer.uint32(42).fork()).ldelim();
        });
        if (message.expectFilesNum !== 0) {
            writer.uint32(48).int32(message.expectFilesNum);
        }
        if (message.sourceSerialNumber !== undefined) {
            writer.uint32(58).string(message.sourceSerialNumber);
        }
        if (message.sourceAppId !== undefined) {
            writer.uint32(66).string(message.sourceAppId);
        }
        if (message.sourceAppIdentifier !== undefined) {
            writer.uint32(74).string(message.sourceAppIdentifier);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseEvent();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.nonce = reader.string();
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.createdAt = longToNumber(reader.int64());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.tags.push(reader.string());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    const entry5 = Event_ExtrasEntry.decode(reader, reader.uint32());
                    if (entry5.value !== undefined) {
                        message.extras[entry5.key] = entry5.value;
                    }
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.expectFilesNum = reader.int32();
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.sourceSerialNumber = reader.string();
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.sourceAppId = reader.string();
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.sourceAppIdentifier = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            nonce: isSet(object.nonce) ? globalThis.String(object.nonce) : undefined,
            createdAt: isSet(object.createdAt) ? globalThis.Number(object.createdAt) : 0,
            name: isSet(object.name) ? globalThis.String(object.name) : "",
            tags: globalThis.Array.isArray(object?.tags) ? object.tags.map((e) => globalThis.String(e)) : [],
            extras: isObject(object.extras)
                ? Object.entries(object.extras).reduce((acc, [key, value]) => {
                    acc[key] = String(value);
                    return acc;
                }, {})
                : {},
            expectFilesNum: isSet(object.expectFilesNum) ? globalThis.Number(object.expectFilesNum) : 0,
            sourceSerialNumber: isSet(object.sourceSerialNumber) ? globalThis.String(object.sourceSerialNumber) : undefined,
            sourceAppId: isSet(object.sourceAppId) ? globalThis.String(object.sourceAppId) : undefined,
            sourceAppIdentifier: isSet(object.sourceAppIdentifier)
                ? globalThis.String(object.sourceAppIdentifier)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.nonce !== undefined) {
            obj.nonce = message.nonce;
        }
        if (message.createdAt !== 0) {
            obj.createdAt = Math.round(message.createdAt);
        }
        if (message.name !== "") {
            obj.name = message.name;
        }
        if (message.tags?.length) {
            obj.tags = message.tags;
        }
        if (message.extras) {
            const entries = Object.entries(message.extras);
            if (entries.length > 0) {
                obj.extras = {};
                entries.forEach(([k, v]) => {
                    obj.extras[k] = v;
                });
            }
        }
        if (message.expectFilesNum !== 0) {
            obj.expectFilesNum = Math.round(message.expectFilesNum);
        }
        if (message.sourceSerialNumber !== undefined) {
            obj.sourceSerialNumber = message.sourceSerialNumber;
        }
        if (message.sourceAppId !== undefined) {
            obj.sourceAppId = message.sourceAppId;
        }
        if (message.sourceAppIdentifier !== undefined) {
            obj.sourceAppIdentifier = message.sourceAppIdentifier;
        }
        return obj;
    },
    create(base) {
        return Event.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseEvent();
        message.nonce = object.nonce ?? undefined;
        message.createdAt = object.createdAt ?? 0;
        message.name = object.name ?? "";
        message.tags = object.tags?.map((e) => e) || [];
        message.extras = Object.entries(object.extras ?? {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = globalThis.String(value);
            }
            return acc;
        }, {});
        message.expectFilesNum = object.expectFilesNum ?? 0;
        message.sourceSerialNumber = object.sourceSerialNumber ?? undefined;
        message.sourceAppId = object.sourceAppId ?? undefined;
        message.sourceAppIdentifier = object.sourceAppIdentifier ?? undefined;
        return message;
    },
};
function createBaseEvent_ExtrasEntry() {
    return { key: "", value: "" };
}
export const Event_ExtrasEntry = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.key !== "") {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== "") {
            writer.uint32(18).string(message.value);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseEvent_ExtrasEntry();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.key = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.value = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            key: isSet(object.key) ? globalThis.String(object.key) : "",
            value: isSet(object.value) ? globalThis.String(object.value) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.key !== "") {
            obj.key = message.key;
        }
        if (message.value !== "") {
            obj.value = message.value;
        }
        return obj;
    },
    create(base) {
        return Event_ExtrasEntry.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseEvent_ExtrasEntry();
        message.key = object.key ?? "";
        message.value = object.value ?? "";
        return message;
    },
};
function createBaseBatchUploadEventsResult() {
    return { events: [] };
}
export const BatchUploadEventsResult = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.events) {
            EventResult.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseBatchUploadEventsResult();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.events.push(EventResult.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            events: globalThis.Array.isArray(object?.events) ? object.events.map((e) => EventResult.fromJSON(e)) : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.events?.length) {
            obj.events = message.events.map((e) => EventResult.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return BatchUploadEventsResult.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseBatchUploadEventsResult();
        message.events = object.events?.map((e) => EventResult.fromPartial(e)) || [];
        return message;
    },
};
function createBaseEventResult() {
    return { nonce: "", accepted: undefined, error: undefined };
}
export const EventResult = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.nonce !== "") {
            writer.uint32(10).string(message.nonce);
        }
        if (message.accepted !== undefined) {
            AcceptedEvent.encode(message.accepted, writer.uint32(18).fork()).ldelim();
        }
        if (message.error !== undefined) {
            IngestError.encode(message.error, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseEventResult();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.nonce = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.accepted = AcceptedEvent.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.error = IngestError.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            nonce: isSet(object.nonce) ? globalThis.String(object.nonce) : "",
            accepted: isSet(object.accepted) ? AcceptedEvent.fromJSON(object.accepted) : undefined,
            error: isSet(object.error) ? IngestError.fromJSON(object.error) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.nonce !== "") {
            obj.nonce = message.nonce;
        }
        if (message.accepted !== undefined) {
            obj.accepted = AcceptedEvent.toJSON(message.accepted);
        }
        if (message.error !== undefined) {
            obj.error = IngestError.toJSON(message.error);
        }
        return obj;
    },
    create(base) {
        return EventResult.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseEventResult();
        message.nonce = object.nonce ?? "";
        message.accepted = (object.accepted !== undefined && object.accepted !== null)
            ? AcceptedEvent.fromPartial(object.accepted)
            : undefined;
        message.error = (object.error !== undefined && object.error !== null)
            ? IngestError.fromPartial(object.error)
            : undefined;
        return message;
    },
};
function createBaseAcceptedEvent() {
    return { fileUploadUrls: [] };
}
export const AcceptedEvent = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.fileUploadUrls) {
            writer.uint32(10).string(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseAcceptedEvent();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.fileUploadUrls.push(reader.string());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            fileUploadUrls: globalThis.Array.isArray(object?.fileUploadUrls)
                ? object.fileUploadUrls.map((e) => globalThis.String(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.fileUploadUrls?.length) {
            obj.fileUploadUrls = message.fileUploadUrls;
        }
        return obj;
    },
    create(base) {
        return AcceptedEvent.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseAcceptedEvent();
        message.fileUploadUrls = object.fileUploadUrls?.map((e) => e) || [];
        return message;
    },
};
function createBaseIngestError() {
    return { message: "" };
}
export const IngestError = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.message !== "") {
            writer.uint32(10).string(message.message);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseIngestError();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.message = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { message: isSet(object.message) ? globalThis.String(object.message) : "" };
    },
    toJSON(message) {
        const obj = {};
        if (message.message !== "") {
            obj.message = message.message;
        }
        return obj;
    },
    create(base) {
        return IngestError.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseIngestError();
        message.message = object.message ?? "";
        return message;
    },
};
function longToNumber(long) {
    if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
    }
    if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) {
        throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
    }
    return long.toNumber();
}
if (_m0.util.Long !== Long) {
    _m0.util.Long = Long;
    _m0.configure();
}
function isObject(value) {
    return typeof value === "object" && value !== null;
}
function isSet(value) {
    return value !== null && value !== undefined;
}
export const protobufName = "Event";
//# sourceMappingURL=Event.js.map