"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.BinaryT = exports.Binary = void 0;
const flatbuffers = require("flatbuffers");
class Binary {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsBinary(bb, obj) {
        return (obj || new Binary()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsBinary(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new Binary()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    value(index) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
    }
    valueLength() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
    }
    valueArray() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
    }
    static startBinary(builder) {
        builder.startObject(1);
    }
    static addValue(builder, valueOffset) {
        builder.addFieldOffset(0, valueOffset, 0);
    }
    static createValueVector(builder, data) {
        builder.startVector(1, data.length, 1);
        for (let i = data.length - 1; i >= 0; i--) {
            builder.addInt8(data[i]);
        }
        return builder.endVector();
    }
    static startValueVector(builder, numElems) {
        builder.startVector(1, numElems, 1);
    }
    static endBinary(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // value
        return offset;
    }
    static createBinary(builder, valueOffset) {
        Binary.startBinary(builder);
        Binary.addValue(builder, valueOffset);
        return Binary.endBinary(builder);
    }
    unpack() {
        return new BinaryT(this.bb.createScalarList(this.value.bind(this), this.valueLength()));
    }
    unpackTo(_o) {
        _o.value = this.bb.createScalarList(this.value.bind(this), this.valueLength());
    }
}
exports.Binary = Binary;
class BinaryT {
    value;
    constructor(value = []) {
        this.value = value;
    }
    pack(builder) {
        const value = Binary.createValueVector(builder, this.value);
        return Binary.createBinary(builder, value);
    }
}
exports.BinaryT = BinaryT;
