// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.10.1
//   protoc               v3.21.12
// source: ImageAnnotations.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { Color, ImgTransformation, Point2f, Timestamp } from "./common";
export const protobufPackage = "dai.proto.image_annotations";
export var PointsAnnotationType;
(function (PointsAnnotationType) {
    PointsAnnotationType[PointsAnnotationType["UNKNOWN"] = 0] = "UNKNOWN";
    PointsAnnotationType[PointsAnnotationType["POINTS"] = 1] = "POINTS";
    PointsAnnotationType[PointsAnnotationType["LINE_LOOP"] = 2] = "LINE_LOOP";
    PointsAnnotationType[PointsAnnotationType["LINE_STRIP"] = 3] = "LINE_STRIP";
    PointsAnnotationType[PointsAnnotationType["LINE_LIST"] = 4] = "LINE_LIST";
    PointsAnnotationType[PointsAnnotationType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(PointsAnnotationType || (PointsAnnotationType = {}));
export function pointsAnnotationTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "UNKNOWN":
            return PointsAnnotationType.UNKNOWN;
        case 1:
        case "POINTS":
            return PointsAnnotationType.POINTS;
        case 2:
        case "LINE_LOOP":
            return PointsAnnotationType.LINE_LOOP;
        case 3:
        case "LINE_STRIP":
            return PointsAnnotationType.LINE_STRIP;
        case 4:
        case "LINE_LIST":
            return PointsAnnotationType.LINE_LIST;
        case -1:
        case "UNRECOGNIZED":
        default:
            return PointsAnnotationType.UNRECOGNIZED;
    }
}
export function pointsAnnotationTypeToJSON(object) {
    switch (object) {
        case PointsAnnotationType.UNKNOWN:
            return "UNKNOWN";
        case PointsAnnotationType.POINTS:
            return "POINTS";
        case PointsAnnotationType.LINE_LOOP:
            return "LINE_LOOP";
        case PointsAnnotationType.LINE_STRIP:
            return "LINE_STRIP";
        case PointsAnnotationType.LINE_LIST:
            return "LINE_LIST";
        case PointsAnnotationType.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function createBaseImageAnnotations() {
    return { sequenceNum: 0, ts: undefined, tsDevice: undefined, annotations: [], transformation: undefined };
}
export const ImageAnnotations = {
    encode(message, writer = new BinaryWriter()) {
        if (message.sequenceNum !== 0) {
            writer.uint32(8).int64(message.sequenceNum);
        }
        if (message.ts !== undefined) {
            Timestamp.encode(message.ts, writer.uint32(18).fork()).join();
        }
        if (message.tsDevice !== undefined) {
            Timestamp.encode(message.tsDevice, writer.uint32(26).fork()).join();
        }
        for (const v of message.annotations) {
            ImageAnnotation.encode(v, writer.uint32(34).fork()).join();
        }
        if (message.transformation !== undefined) {
            ImgTransformation.encode(message.transformation, writer.uint32(42).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseImageAnnotations();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 8) {
                        break;
                    }
                    message.sequenceNum = longToNumber(reader.int64());
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.ts = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.tsDevice = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.annotations.push(ImageAnnotation.decode(reader, reader.uint32()));
                    continue;
                }
                case 5: {
                    if (tag !== 42) {
                        break;
                    }
                    message.transformation = ImgTransformation.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            sequenceNum: isSet(object.sequenceNum) ? globalThis.Number(object.sequenceNum) : 0,
            ts: isSet(object.ts) ? Timestamp.fromJSON(object.ts) : undefined,
            tsDevice: isSet(object.tsDevice) ? Timestamp.fromJSON(object.tsDevice) : undefined,
            annotations: globalThis.Array.isArray(object?.annotations)
                ? object.annotations.map((e) => ImageAnnotation.fromJSON(e))
                : [],
            transformation: isSet(object.transformation) ? ImgTransformation.fromJSON(object.transformation) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.sequenceNum !== 0) {
            obj.sequenceNum = Math.round(message.sequenceNum);
        }
        if (message.ts !== undefined) {
            obj.ts = Timestamp.toJSON(message.ts);
        }
        if (message.tsDevice !== undefined) {
            obj.tsDevice = Timestamp.toJSON(message.tsDevice);
        }
        if (message.annotations?.length) {
            obj.annotations = message.annotations.map((e) => ImageAnnotation.toJSON(e));
        }
        if (message.transformation !== undefined) {
            obj.transformation = ImgTransformation.toJSON(message.transformation);
        }
        return obj;
    },
    create(base) {
        return ImageAnnotations.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseImageAnnotations();
        message.sequenceNum = object.sequenceNum ?? 0;
        message.ts = (object.ts !== undefined && object.ts !== null) ? Timestamp.fromPartial(object.ts) : undefined;
        message.tsDevice = (object.tsDevice !== undefined && object.tsDevice !== null)
            ? Timestamp.fromPartial(object.tsDevice)
            : undefined;
        message.annotations = object.annotations?.map((e) => ImageAnnotation.fromPartial(e)) || [];
        message.transformation = (object.transformation !== undefined && object.transformation !== null)
            ? ImgTransformation.fromPartial(object.transformation)
            : undefined;
        return message;
    },
};
function createBaseImageAnnotation() {
    return { circles: [], points: [], texts: [] };
}
export const ImageAnnotation = {
    encode(message, writer = new BinaryWriter()) {
        for (const v of message.circles) {
            CircleAnnotation.encode(v, writer.uint32(10).fork()).join();
        }
        for (const v of message.points) {
            PointsAnnotation.encode(v, writer.uint32(18).fork()).join();
        }
        for (const v of message.texts) {
            TextAnnotation.encode(v, writer.uint32(26).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseImageAnnotation();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.circles.push(CircleAnnotation.decode(reader, reader.uint32()));
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.points.push(PointsAnnotation.decode(reader, reader.uint32()));
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.texts.push(TextAnnotation.decode(reader, reader.uint32()));
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            circles: globalThis.Array.isArray(object?.circles)
                ? object.circles.map((e) => CircleAnnotation.fromJSON(e))
                : [],
            points: globalThis.Array.isArray(object?.points)
                ? object.points.map((e) => PointsAnnotation.fromJSON(e))
                : [],
            texts: globalThis.Array.isArray(object?.texts) ? object.texts.map((e) => TextAnnotation.fromJSON(e)) : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.circles?.length) {
            obj.circles = message.circles.map((e) => CircleAnnotation.toJSON(e));
        }
        if (message.points?.length) {
            obj.points = message.points.map((e) => PointsAnnotation.toJSON(e));
        }
        if (message.texts?.length) {
            obj.texts = message.texts.map((e) => TextAnnotation.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return ImageAnnotation.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseImageAnnotation();
        message.circles = object.circles?.map((e) => CircleAnnotation.fromPartial(e)) || [];
        message.points = object.points?.map((e) => PointsAnnotation.fromPartial(e)) || [];
        message.texts = object.texts?.map((e) => TextAnnotation.fromPartial(e)) || [];
        return message;
    },
};
function createBaseCircleAnnotation() {
    return { position: undefined, diameter: 0, thickness: 0, fillColor: undefined, outlineColor: undefined };
}
export const CircleAnnotation = {
    encode(message, writer = new BinaryWriter()) {
        if (message.position !== undefined) {
            Point2f.encode(message.position, writer.uint32(10).fork()).join();
        }
        if (message.diameter !== 0) {
            writer.uint32(21).float(message.diameter);
        }
        if (message.thickness !== 0) {
            writer.uint32(29).float(message.thickness);
        }
        if (message.fillColor !== undefined) {
            Color.encode(message.fillColor, writer.uint32(34).fork()).join();
        }
        if (message.outlineColor !== undefined) {
            Color.encode(message.outlineColor, writer.uint32(42).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseCircleAnnotation();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.position = Point2f.decode(reader, reader.uint32());
                    continue;
                }
                case 2: {
                    if (tag !== 21) {
                        break;
                    }
                    message.diameter = reader.float();
                    continue;
                }
                case 3: {
                    if (tag !== 29) {
                        break;
                    }
                    message.thickness = reader.float();
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.fillColor = Color.decode(reader, reader.uint32());
                    continue;
                }
                case 5: {
                    if (tag !== 42) {
                        break;
                    }
                    message.outlineColor = Color.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            position: isSet(object.position) ? Point2f.fromJSON(object.position) : undefined,
            diameter: isSet(object.diameter) ? globalThis.Number(object.diameter) : 0,
            thickness: isSet(object.thickness) ? globalThis.Number(object.thickness) : 0,
            fillColor: isSet(object.fillColor) ? Color.fromJSON(object.fillColor) : undefined,
            outlineColor: isSet(object.outlineColor) ? Color.fromJSON(object.outlineColor) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.position !== undefined) {
            obj.position = Point2f.toJSON(message.position);
        }
        if (message.diameter !== 0) {
            obj.diameter = message.diameter;
        }
        if (message.thickness !== 0) {
            obj.thickness = message.thickness;
        }
        if (message.fillColor !== undefined) {
            obj.fillColor = Color.toJSON(message.fillColor);
        }
        if (message.outlineColor !== undefined) {
            obj.outlineColor = Color.toJSON(message.outlineColor);
        }
        return obj;
    },
    create(base) {
        return CircleAnnotation.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseCircleAnnotation();
        message.position = (object.position !== undefined && object.position !== null)
            ? Point2f.fromPartial(object.position)
            : undefined;
        message.diameter = object.diameter ?? 0;
        message.thickness = object.thickness ?? 0;
        message.fillColor = (object.fillColor !== undefined && object.fillColor !== null)
            ? Color.fromPartial(object.fillColor)
            : undefined;
        message.outlineColor = (object.outlineColor !== undefined && object.outlineColor !== null)
            ? Color.fromPartial(object.outlineColor)
            : undefined;
        return message;
    },
};
function createBasePointsAnnotation() {
    return { type: 0, points: [], outlineColor: undefined, outlineColors: [], fillColor: undefined, thickness: 0 };
}
export const PointsAnnotation = {
    encode(message, writer = new BinaryWriter()) {
        if (message.type !== 0) {
            writer.uint32(8).int32(message.type);
        }
        for (const v of message.points) {
            Point2f.encode(v, writer.uint32(18).fork()).join();
        }
        if (message.outlineColor !== undefined) {
            Color.encode(message.outlineColor, writer.uint32(26).fork()).join();
        }
        for (const v of message.outlineColors) {
            Color.encode(v, writer.uint32(34).fork()).join();
        }
        if (message.fillColor !== undefined) {
            Color.encode(message.fillColor, writer.uint32(42).fork()).join();
        }
        if (message.thickness !== 0) {
            writer.uint32(53).float(message.thickness);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBasePointsAnnotation();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 8) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.points.push(Point2f.decode(reader, reader.uint32()));
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.outlineColor = Color.decode(reader, reader.uint32());
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.outlineColors.push(Color.decode(reader, reader.uint32()));
                    continue;
                }
                case 5: {
                    if (tag !== 42) {
                        break;
                    }
                    message.fillColor = Color.decode(reader, reader.uint32());
                    continue;
                }
                case 6: {
                    if (tag !== 53) {
                        break;
                    }
                    message.thickness = reader.float();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            type: isSet(object.type) ? pointsAnnotationTypeFromJSON(object.type) : 0,
            points: globalThis.Array.isArray(object?.points) ? object.points.map((e) => Point2f.fromJSON(e)) : [],
            outlineColor: isSet(object.outlineColor) ? Color.fromJSON(object.outlineColor) : undefined,
            outlineColors: globalThis.Array.isArray(object?.outlineColors)
                ? object.outlineColors.map((e) => Color.fromJSON(e))
                : [],
            fillColor: isSet(object.fillColor) ? Color.fromJSON(object.fillColor) : undefined,
            thickness: isSet(object.thickness) ? globalThis.Number(object.thickness) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.type !== 0) {
            obj.type = pointsAnnotationTypeToJSON(message.type);
        }
        if (message.points?.length) {
            obj.points = message.points.map((e) => Point2f.toJSON(e));
        }
        if (message.outlineColor !== undefined) {
            obj.outlineColor = Color.toJSON(message.outlineColor);
        }
        if (message.outlineColors?.length) {
            obj.outlineColors = message.outlineColors.map((e) => Color.toJSON(e));
        }
        if (message.fillColor !== undefined) {
            obj.fillColor = Color.toJSON(message.fillColor);
        }
        if (message.thickness !== 0) {
            obj.thickness = message.thickness;
        }
        return obj;
    },
    create(base) {
        return PointsAnnotation.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBasePointsAnnotation();
        message.type = object.type ?? 0;
        message.points = object.points?.map((e) => Point2f.fromPartial(e)) || [];
        message.outlineColor = (object.outlineColor !== undefined && object.outlineColor !== null)
            ? Color.fromPartial(object.outlineColor)
            : undefined;
        message.outlineColors = object.outlineColors?.map((e) => Color.fromPartial(e)) || [];
        message.fillColor = (object.fillColor !== undefined && object.fillColor !== null)
            ? Color.fromPartial(object.fillColor)
            : undefined;
        message.thickness = object.thickness ?? 0;
        return message;
    },
};
function createBaseTextAnnotation() {
    return { position: undefined, text: "", fontSize: 0, textColor: undefined, backgroundColor: undefined };
}
export const TextAnnotation = {
    encode(message, writer = new BinaryWriter()) {
        if (message.position !== undefined) {
            Point2f.encode(message.position, writer.uint32(10).fork()).join();
        }
        if (message.text !== "") {
            writer.uint32(18).string(message.text);
        }
        if (message.fontSize !== 0) {
            writer.uint32(29).float(message.fontSize);
        }
        if (message.textColor !== undefined) {
            Color.encode(message.textColor, writer.uint32(34).fork()).join();
        }
        if (message.backgroundColor !== undefined) {
            Color.encode(message.backgroundColor, writer.uint32(42).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseTextAnnotation();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.position = Point2f.decode(reader, reader.uint32());
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.text = reader.string();
                    continue;
                }
                case 3: {
                    if (tag !== 29) {
                        break;
                    }
                    message.fontSize = reader.float();
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.textColor = Color.decode(reader, reader.uint32());
                    continue;
                }
                case 5: {
                    if (tag !== 42) {
                        break;
                    }
                    message.backgroundColor = Color.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            position: isSet(object.position) ? Point2f.fromJSON(object.position) : undefined,
            text: isSet(object.text) ? globalThis.String(object.text) : "",
            fontSize: isSet(object.fontSize) ? globalThis.Number(object.fontSize) : 0,
            textColor: isSet(object.textColor) ? Color.fromJSON(object.textColor) : undefined,
            backgroundColor: isSet(object.backgroundColor) ? Color.fromJSON(object.backgroundColor) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.position !== undefined) {
            obj.position = Point2f.toJSON(message.position);
        }
        if (message.text !== "") {
            obj.text = message.text;
        }
        if (message.fontSize !== 0) {
            obj.fontSize = message.fontSize;
        }
        if (message.textColor !== undefined) {
            obj.textColor = Color.toJSON(message.textColor);
        }
        if (message.backgroundColor !== undefined) {
            obj.backgroundColor = Color.toJSON(message.backgroundColor);
        }
        return obj;
    },
    create(base) {
        return TextAnnotation.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseTextAnnotation();
        message.position = (object.position !== undefined && object.position !== null)
            ? Point2f.fromPartial(object.position)
            : undefined;
        message.text = object.text ?? "";
        message.fontSize = object.fontSize ?? 0;
        message.textColor = (object.textColor !== undefined && object.textColor !== null)
            ? Color.fromPartial(object.textColor)
            : undefined;
        message.backgroundColor = (object.backgroundColor !== undefined && object.backgroundColor !== null)
            ? Color.fromPartial(object.backgroundColor)
            : undefined;
        return message;
    },
};
function longToNumber(int64) {
    const num = globalThis.Number(int64.toString());
    if (num > globalThis.Number.MAX_SAFE_INTEGER) {
        throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
    }
    if (num < globalThis.Number.MIN_SAFE_INTEGER) {
        throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
    }
    return num;
}
function isSet(value) {
    return value !== null && value !== undefined;
}
export const protobufName = "ImageAnnotations";
//# sourceMappingURL=ImageAnnotations.js.map