import { WireType } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { AddressVoucher } from "../../common/vouchers/v1/vouchers_pb.js";
import { Namespace } from "./permissions_pb.js";
import { Params } from "./params_pb.js";
class GenesisState$Type extends MessageType {
  constructor() {
    super("injective.permissions.v1beta1.GenesisState", [
      { no: 1, name: "params", kind: "message", T: () => Params, options: { "gogoproto.nullable": false } },
      { no: 2, name: "namespaces", kind: "message", repeat: 2, T: () => Namespace, options: { "gogoproto.nullable": false } },
      { no: 3, name: "vouchers", kind: "message", repeat: 2, T: () => AddressVoucher, options: { "gogoproto.nullable": false } }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.namespaces = [];
    message.vouchers = [];
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* injective.permissions.v1beta1.Params params */
        1:
          message.params = Params.internalBinaryRead(reader, reader.uint32(), options, message.params);
          break;
        case /* repeated injective.permissions.v1beta1.Namespace namespaces */
        2:
          message.namespaces.push(Namespace.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.common.vouchers.v1.AddressVoucher vouchers */
        3:
          message.vouchers.push(AddressVoucher.internalBinaryRead(reader, reader.uint32(), options));
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.params)
      Params.internalBinaryWrite(message.params, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.namespaces.length; i++)
      Namespace.internalBinaryWrite(message.namespaces[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.vouchers.length; i++)
      AddressVoucher.internalBinaryWrite(message.vouchers[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const GenesisState = new GenesisState$Type();
export {
  GenesisState
};
