// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.10.1
//   protoc               v3.21.12
// source: PointCloudData.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { Timestamp } from "./common";
export const protobufPackage = "dai.proto.point_cloud_data";
function createBasePointCloudData() {
    return {
        ts: undefined,
        tsDevice: undefined,
        sequenceNum: 0,
        width: 0,
        height: 0,
        instanceNum: 0,
        minx: 0,
        miny: 0,
        minz: 0,
        maxx: 0,
        maxy: 0,
        maxz: 0,
        sparse: false,
        color: false,
        data: new Uint8Array(0),
    };
}
export const PointCloudData = {
    encode(message, writer = new BinaryWriter()) {
        if (message.ts !== undefined) {
            Timestamp.encode(message.ts, writer.uint32(10).fork()).join();
        }
        if (message.tsDevice !== undefined) {
            Timestamp.encode(message.tsDevice, writer.uint32(18).fork()).join();
        }
        if (message.sequenceNum !== 0) {
            writer.uint32(24).int64(message.sequenceNum);
        }
        if (message.width !== 0) {
            writer.uint32(32).uint32(message.width);
        }
        if (message.height !== 0) {
            writer.uint32(40).uint32(message.height);
        }
        if (message.instanceNum !== 0) {
            writer.uint32(48).uint32(message.instanceNum);
        }
        if (message.minx !== 0) {
            writer.uint32(61).float(message.minx);
        }
        if (message.miny !== 0) {
            writer.uint32(69).float(message.miny);
        }
        if (message.minz !== 0) {
            writer.uint32(77).float(message.minz);
        }
        if (message.maxx !== 0) {
            writer.uint32(85).float(message.maxx);
        }
        if (message.maxy !== 0) {
            writer.uint32(93).float(message.maxy);
        }
        if (message.maxz !== 0) {
            writer.uint32(101).float(message.maxz);
        }
        if (message.sparse !== false) {
            writer.uint32(104).bool(message.sparse);
        }
        if (message.color !== false) {
            writer.uint32(112).bool(message.color);
        }
        if (message.data.length !== 0) {
            writer.uint32(122).bytes(message.data);
        }
        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 = createBasePointCloudData();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.ts = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.tsDevice = Timestamp.decode(reader, reader.uint32());
                    continue;
                }
                case 3: {
                    if (tag !== 24) {
                        break;
                    }
                    message.sequenceNum = longToNumber(reader.int64());
                    continue;
                }
                case 4: {
                    if (tag !== 32) {
                        break;
                    }
                    message.width = reader.uint32();
                    continue;
                }
                case 5: {
                    if (tag !== 40) {
                        break;
                    }
                    message.height = reader.uint32();
                    continue;
                }
                case 6: {
                    if (tag !== 48) {
                        break;
                    }
                    message.instanceNum = reader.uint32();
                    continue;
                }
                case 7: {
                    if (tag !== 61) {
                        break;
                    }
                    message.minx = reader.float();
                    continue;
                }
                case 8: {
                    if (tag !== 69) {
                        break;
                    }
                    message.miny = reader.float();
                    continue;
                }
                case 9: {
                    if (tag !== 77) {
                        break;
                    }
                    message.minz = reader.float();
                    continue;
                }
                case 10: {
                    if (tag !== 85) {
                        break;
                    }
                    message.maxx = reader.float();
                    continue;
                }
                case 11: {
                    if (tag !== 93) {
                        break;
                    }
                    message.maxy = reader.float();
                    continue;
                }
                case 12: {
                    if (tag !== 101) {
                        break;
                    }
                    message.maxz = reader.float();
                    continue;
                }
                case 13: {
                    if (tag !== 104) {
                        break;
                    }
                    message.sparse = reader.bool();
                    continue;
                }
                case 14: {
                    if (tag !== 112) {
                        break;
                    }
                    message.color = reader.bool();
                    continue;
                }
                case 15: {
                    if (tag !== 122) {
                        break;
                    }
                    message.data = reader.bytes();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            ts: isSet(object.ts) ? Timestamp.fromJSON(object.ts) : undefined,
            tsDevice: isSet(object.tsDevice) ? Timestamp.fromJSON(object.tsDevice) : undefined,
            sequenceNum: isSet(object.sequenceNum) ? globalThis.Number(object.sequenceNum) : 0,
            width: isSet(object.width) ? globalThis.Number(object.width) : 0,
            height: isSet(object.height) ? globalThis.Number(object.height) : 0,
            instanceNum: isSet(object.instanceNum) ? globalThis.Number(object.instanceNum) : 0,
            minx: isSet(object.minx) ? globalThis.Number(object.minx) : 0,
            miny: isSet(object.miny) ? globalThis.Number(object.miny) : 0,
            minz: isSet(object.minz) ? globalThis.Number(object.minz) : 0,
            maxx: isSet(object.maxx) ? globalThis.Number(object.maxx) : 0,
            maxy: isSet(object.maxy) ? globalThis.Number(object.maxy) : 0,
            maxz: isSet(object.maxz) ? globalThis.Number(object.maxz) : 0,
            sparse: isSet(object.sparse) ? globalThis.Boolean(object.sparse) : false,
            color: isSet(object.color) ? globalThis.Boolean(object.color) : false,
            data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0),
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.ts !== undefined) {
            obj.ts = Timestamp.toJSON(message.ts);
        }
        if (message.tsDevice !== undefined) {
            obj.tsDevice = Timestamp.toJSON(message.tsDevice);
        }
        if (message.sequenceNum !== 0) {
            obj.sequenceNum = Math.round(message.sequenceNum);
        }
        if (message.width !== 0) {
            obj.width = Math.round(message.width);
        }
        if (message.height !== 0) {
            obj.height = Math.round(message.height);
        }
        if (message.instanceNum !== 0) {
            obj.instanceNum = Math.round(message.instanceNum);
        }
        if (message.minx !== 0) {
            obj.minx = message.minx;
        }
        if (message.miny !== 0) {
            obj.miny = message.miny;
        }
        if (message.minz !== 0) {
            obj.minz = message.minz;
        }
        if (message.maxx !== 0) {
            obj.maxx = message.maxx;
        }
        if (message.maxy !== 0) {
            obj.maxy = message.maxy;
        }
        if (message.maxz !== 0) {
            obj.maxz = message.maxz;
        }
        if (message.sparse !== false) {
            obj.sparse = message.sparse;
        }
        if (message.color !== false) {
            obj.color = message.color;
        }
        if (message.data.length !== 0) {
            obj.data = base64FromBytes(message.data);
        }
        return obj;
    },
    create(base) {
        return PointCloudData.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBasePointCloudData();
        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.sequenceNum = object.sequenceNum ?? 0;
        message.width = object.width ?? 0;
        message.height = object.height ?? 0;
        message.instanceNum = object.instanceNum ?? 0;
        message.minx = object.minx ?? 0;
        message.miny = object.miny ?? 0;
        message.minz = object.minz ?? 0;
        message.maxx = object.maxx ?? 0;
        message.maxy = object.maxy ?? 0;
        message.maxz = object.maxz ?? 0;
        message.sparse = object.sparse ?? false;
        message.color = object.color ?? false;
        message.data = object.data ?? new Uint8Array(0);
        return message;
    },
};
function bytesFromBase64(b64) {
    if (globalThis.Buffer) {
        return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
    }
    else {
        const bin = globalThis.atob(b64);
        const arr = new Uint8Array(bin.length);
        for (let i = 0; i < bin.length; ++i) {
            arr[i] = bin.charCodeAt(i);
        }
        return arr;
    }
}
function base64FromBytes(arr) {
    if (globalThis.Buffer) {
        return globalThis.Buffer.from(arr).toString("base64");
    }
    else {
        const bin = [];
        arr.forEach((byte) => {
            bin.push(globalThis.String.fromCharCode(byte));
        });
        return globalThis.btoa(bin.join(""));
    }
}
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 = "PointCloudData";
//# sourceMappingURL=PointCloudData.js.map