"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringStringArrayT = exports.StringStringArray = void 0;
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
const flatbuffers = require("flatbuffers");
class StringStringArray {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsStringStringArray(bb, obj) {
        return (obj || new StringStringArray()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsStringStringArray(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new StringStringArray()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    key(optionalEncoding) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
    }
    values(index, optionalEncoding) {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
    }
    valuesLength() {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
    }
    static startStringStringArray(builder) {
        builder.startObject(2);
    }
    static addKey(builder, keyOffset) {
        builder.addFieldOffset(0, keyOffset, 0);
    }
    static addValues(builder, valuesOffset) {
        builder.addFieldOffset(1, valuesOffset, 0);
    }
    static createValuesVector(builder, data) {
        builder.startVector(4, data.length, 4);
        for (let i = data.length - 1; i >= 0; i--) {
            builder.addOffset(data[i]);
        }
        return builder.endVector();
    }
    static startValuesVector(builder, numElems) {
        builder.startVector(4, numElems, 4);
    }
    static endStringStringArray(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // key
        builder.requiredField(offset, 6); // values
        return offset;
    }
    static createStringStringArray(builder, keyOffset, valuesOffset) {
        StringStringArray.startStringStringArray(builder);
        StringStringArray.addKey(builder, keyOffset);
        StringStringArray.addValues(builder, valuesOffset);
        return StringStringArray.endStringStringArray(builder);
    }
    unpack() {
        return new StringStringArrayT(this.key(), this.bb.createScalarList(this.values.bind(this), this.valuesLength()));
    }
    unpackTo(_o) {
        _o.key = this.key();
        _o.values = this.bb.createScalarList(this.values.bind(this), this.valuesLength());
    }
}
exports.StringStringArray = StringStringArray;
class StringStringArrayT {
    key;
    values;
    constructor(key = null, values = []) {
        this.key = key;
        this.values = values;
    }
    pack(builder) {
        const key = (this.key !== null ? builder.createString(this.key) : 0);
        const values = StringStringArray.createValuesVector(builder, builder.createObjectOffsetList(this.values));
        return StringStringArray.createStringStringArray(builder, key, values);
    }
}
exports.StringStringArrayT = StringStringArrayT;
