//@ts-nocheck
import * as _m0 from "protobufjs/minimal";
import { isSet } from "../../../helpers";
/** Level is the permission level. */
export let Permissions_Level = /*#__PURE__*/function (Permissions_Level) {
  /**
   * LEVEL_NONE_UNSPECIFIED - LEVEL_NONE_UNSPECIFIED indicates that the account will have no circuit
   * breaker permissions.
   */
  Permissions_Level[Permissions_Level["LEVEL_NONE_UNSPECIFIED"] = 0] = "LEVEL_NONE_UNSPECIFIED";
  /**
   * LEVEL_SOME_MSGS - LEVEL_SOME_MSGS indicates that the account will have permission to
   * trip or reset the circuit breaker for some Msg type URLs. If this level
   * is chosen, a non-empty list of Msg type URLs must be provided in
   * limit_type_urls.
   */
  Permissions_Level[Permissions_Level["LEVEL_SOME_MSGS"] = 1] = "LEVEL_SOME_MSGS";
  /**
   * LEVEL_ALL_MSGS - LEVEL_ALL_MSGS indicates that the account can trip or reset the circuit
   * breaker for Msg's of all type URLs.
   */
  Permissions_Level[Permissions_Level["LEVEL_ALL_MSGS"] = 2] = "LEVEL_ALL_MSGS";
  /**
   * LEVEL_SUPER_ADMIN - LEVEL_SUPER_ADMIN indicates that the account can take all circuit breaker
   * actions and can grant permissions to other accounts.
   */
  Permissions_Level[Permissions_Level["LEVEL_SUPER_ADMIN"] = 3] = "LEVEL_SUPER_ADMIN";
  Permissions_Level[Permissions_Level["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return Permissions_Level;
}({});
export const Permissions_LevelSDKType = Permissions_Level;
export function permissions_LevelFromJSON(object) {
  switch (object) {
    case 0:
    case "LEVEL_NONE_UNSPECIFIED":
      return Permissions_Level.LEVEL_NONE_UNSPECIFIED;
    case 1:
    case "LEVEL_SOME_MSGS":
      return Permissions_Level.LEVEL_SOME_MSGS;
    case 2:
    case "LEVEL_ALL_MSGS":
      return Permissions_Level.LEVEL_ALL_MSGS;
    case 3:
    case "LEVEL_SUPER_ADMIN":
      return Permissions_Level.LEVEL_SUPER_ADMIN;
    case -1:
    case "UNRECOGNIZED":
    default:
      return Permissions_Level.UNRECOGNIZED;
  }
}
export function permissions_LevelToJSON(object) {
  switch (object) {
    case Permissions_Level.LEVEL_NONE_UNSPECIFIED:
      return "LEVEL_NONE_UNSPECIFIED";
    case Permissions_Level.LEVEL_SOME_MSGS:
      return "LEVEL_SOME_MSGS";
    case Permissions_Level.LEVEL_ALL_MSGS:
      return "LEVEL_ALL_MSGS";
    case Permissions_Level.LEVEL_SUPER_ADMIN:
      return "LEVEL_SUPER_ADMIN";
    case Permissions_Level.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
/**
 * Permissions are the permissions that an account has to trip
 * or reset the circuit breaker.
 */

/**
 * Permissions are the permissions that an account has to trip
 * or reset the circuit breaker.
 */

/** GenesisAccountPermissions is the account permissions for the circuit breaker in genesis */

/** GenesisAccountPermissions is the account permissions for the circuit breaker in genesis */

/** GenesisState is the state that must be provided at genesis. */

/** GenesisState is the state that must be provided at genesis. */

function createBasePermissions() {
  return {
    level: 0,
    limitTypeUrls: []
  };
}
export const Permissions = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.level !== 0) {
      writer.uint32(8).int32(message.level);
    }
    for (const v of message.limitTypeUrls) {
      writer.uint32(18).string(v);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBasePermissions();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.level = reader.int32();
          break;
        case 2:
          message.limitTypeUrls.push(reader.string());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      level: isSet(object.level) ? permissions_LevelFromJSON(object.level) : 0,
      limitTypeUrls: Array.isArray(object === null || object === void 0 ? void 0 : object.limitTypeUrls) ? object.limitTypeUrls.map(e => String(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.level !== undefined && (obj.level = permissions_LevelToJSON(message.level));
    if (message.limitTypeUrls) {
      obj.limitTypeUrls = message.limitTypeUrls.map(e => e);
    } else {
      obj.limitTypeUrls = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$level, _object$limitTypeUrls;
    const message = createBasePermissions();
    message.level = (_object$level = object.level) !== null && _object$level !== void 0 ? _object$level : 0;
    message.limitTypeUrls = ((_object$limitTypeUrls = object.limitTypeUrls) === null || _object$limitTypeUrls === void 0 ? void 0 : _object$limitTypeUrls.map(e => e)) || [];
    return message;
  }
};
function createBaseGenesisAccountPermissions() {
  return {
    address: "",
    permissions: undefined
  };
}
export const GenesisAccountPermissions = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.address !== "") {
      writer.uint32(10).string(message.address);
    }
    if (message.permissions !== undefined) {
      Permissions.encode(message.permissions, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGenesisAccountPermissions();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.address = reader.string();
          break;
        case 2:
          message.permissions = Permissions.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      address: isSet(object.address) ? String(object.address) : "",
      permissions: isSet(object.permissions) ? Permissions.fromJSON(object.permissions) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.address !== undefined && (obj.address = message.address);
    message.permissions !== undefined && (obj.permissions = message.permissions ? Permissions.toJSON(message.permissions) : undefined);
    return obj;
  },
  fromPartial(object) {
    var _object$address;
    const message = createBaseGenesisAccountPermissions();
    message.address = (_object$address = object.address) !== null && _object$address !== void 0 ? _object$address : "";
    message.permissions = object.permissions !== undefined && object.permissions !== null ? Permissions.fromPartial(object.permissions) : undefined;
    return message;
  }
};
function createBaseGenesisState() {
  return {
    accountPermissions: [],
    disabledTypeUrls: []
  };
}
export const GenesisState = {
  encode(message, writer = _m0.Writer.create()) {
    for (const v of message.accountPermissions) {
      GenesisAccountPermissions.encode(v, writer.uint32(10).fork()).ldelim();
    }
    for (const v of message.disabledTypeUrls) {
      writer.uint32(18).string(v);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGenesisState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.accountPermissions.push(GenesisAccountPermissions.decode(reader, reader.uint32()));
          break;
        case 2:
          message.disabledTypeUrls.push(reader.string());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      accountPermissions: Array.isArray(object === null || object === void 0 ? void 0 : object.accountPermissions) ? object.accountPermissions.map(e => GenesisAccountPermissions.fromJSON(e)) : [],
      disabledTypeUrls: Array.isArray(object === null || object === void 0 ? void 0 : object.disabledTypeUrls) ? object.disabledTypeUrls.map(e => String(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.accountPermissions) {
      obj.accountPermissions = message.accountPermissions.map(e => e ? GenesisAccountPermissions.toJSON(e) : undefined);
    } else {
      obj.accountPermissions = [];
    }
    if (message.disabledTypeUrls) {
      obj.disabledTypeUrls = message.disabledTypeUrls.map(e => e);
    } else {
      obj.disabledTypeUrls = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$accountPermis, _object$disabledTypeU;
    const message = createBaseGenesisState();
    message.accountPermissions = ((_object$accountPermis = object.accountPermissions) === null || _object$accountPermis === void 0 ? void 0 : _object$accountPermis.map(e => GenesisAccountPermissions.fromPartial(e))) || [];
    message.disabledTypeUrls = ((_object$disabledTypeU = object.disabledTypeUrls) === null || _object$disabledTypeU === void 0 ? void 0 : _object$disabledTypeU.map(e => e)) || [];
    return message;
  }
};