//@ts-nocheck
import { Coin } from "../../../cosmos/base/v1beta1/coin";
import { CW20Payment, CW1155Payment, Contract1155Payment, paymentTypeFromJSON, paymentTypeToJSON } from "./claims";
import { Duration } from "../../../google/protobuf/duration";
import { Timestamp } from "../../../google/protobuf/timestamp";
import { Input, Output } from "../../../cosmos/bank/v1beta1/bank";
import { Long, isSet, fromJsonTimestamp, fromTimestamp } from "../../../helpers";
import * as _m0 from "protobufjs/minimal";
/**
 * AuthorizationType defines the types of claim authorizations that can be
 * created
 */
export let CreateClaimAuthorizationType = /*#__PURE__*/function (CreateClaimAuthorizationType) {
  /** ALL - both submit and evaluate */
  CreateClaimAuthorizationType[CreateClaimAuthorizationType["ALL"] = 0] = "ALL";
  /** SUBMIT - submit only */
  CreateClaimAuthorizationType[CreateClaimAuthorizationType["SUBMIT"] = 1] = "SUBMIT";
  /** EVALUATE - evaluate only */
  CreateClaimAuthorizationType[CreateClaimAuthorizationType["EVALUATE"] = 2] = "EVALUATE";
  CreateClaimAuthorizationType[CreateClaimAuthorizationType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return CreateClaimAuthorizationType;
}({});
export const CreateClaimAuthorizationTypeSDKType = CreateClaimAuthorizationType;
export function createClaimAuthorizationTypeFromJSON(object) {
  switch (object) {
    case 0:
    case "ALL":
      return CreateClaimAuthorizationType.ALL;
    case 1:
    case "SUBMIT":
      return CreateClaimAuthorizationType.SUBMIT;
    case 2:
    case "EVALUATE":
      return CreateClaimAuthorizationType.EVALUATE;
    case -1:
    case "UNRECOGNIZED":
    default:
      return CreateClaimAuthorizationType.UNRECOGNIZED;
  }
}
export function createClaimAuthorizationTypeToJSON(object) {
  switch (object) {
    case CreateClaimAuthorizationType.ALL:
      return "ALL";
    case CreateClaimAuthorizationType.SUBMIT:
      return "SUBMIT";
    case CreateClaimAuthorizationType.EVALUATE:
      return "EVALUATE";
    case CreateClaimAuthorizationType.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}

/**
 * CreateClaimAuthorizationAuthorization allows a grantee to create
 * SubmitClaimAuthorization and EvaluateClaimAuthorization for specific
 * collections(constraints)
 */

/**
 * CreateClaimAuthorizationAuthorization allows a grantee to create
 * SubmitClaimAuthorization and EvaluateClaimAuthorization for specific
 * collections(constraints)
 */

/**
 * CreateClaimAuthorizationConstraints defines the constraints for creating
 * claim authorizations
 */

/**
 * CreateClaimAuthorizationConstraints defines the constraints for creating
 * claim authorizations
 */

function createBaseSubmitClaimAuthorization() {
  return {
    admin: "",
    constraints: []
  };
}
export const SubmitClaimAuthorization = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.admin !== "") {
      writer.uint32(10).string(message.admin);
    }
    for (const v of message.constraints) {
      SubmitClaimConstraints.encode(v, 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 = createBaseSubmitClaimAuthorization();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.admin = reader.string();
          break;
        case 2:
          message.constraints.push(SubmitClaimConstraints.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      admin: isSet(object.admin) ? String(object.admin) : "",
      constraints: Array.isArray(object === null || object === void 0 ? void 0 : object.constraints) ? object.constraints.map(e => SubmitClaimConstraints.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.admin !== undefined && (obj.admin = message.admin);
    if (message.constraints) {
      obj.constraints = message.constraints.map(e => e ? SubmitClaimConstraints.toJSON(e) : undefined);
    } else {
      obj.constraints = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$admin, _object$constraints;
    const message = createBaseSubmitClaimAuthorization();
    message.admin = (_object$admin = object.admin) !== null && _object$admin !== void 0 ? _object$admin : "";
    message.constraints = ((_object$constraints = object.constraints) === null || _object$constraints === void 0 ? void 0 : _object$constraints.map(e => SubmitClaimConstraints.fromPartial(e))) || [];
    return message;
  }
};
function createBaseSubmitClaimConstraints() {
  return {
    collectionId: "",
    agentQuota: Long.UZERO,
    maxAmount: [],
    maxCw20Payment: [],
    intentDurationNs: undefined,
    maxCw1155Payment: []
  };
}
export const SubmitClaimConstraints = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.collectionId !== "") {
      writer.uint32(10).string(message.collectionId);
    }
    if (!message.agentQuota.isZero()) {
      writer.uint32(16).uint64(message.agentQuota);
    }
    for (const v of message.maxAmount) {
      Coin.encode(v, writer.uint32(26).fork()).ldelim();
    }
    for (const v of message.maxCw20Payment) {
      CW20Payment.encode(v, writer.uint32(34).fork()).ldelim();
    }
    if (message.intentDurationNs !== undefined) {
      Duration.encode(message.intentDurationNs, writer.uint32(42).fork()).ldelim();
    }
    for (const v of message.maxCw1155Payment) {
      CW1155Payment.encode(v, writer.uint32(50).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 = createBaseSubmitClaimConstraints();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.collectionId = reader.string();
          break;
        case 2:
          message.agentQuota = reader.uint64();
          break;
        case 3:
          message.maxAmount.push(Coin.decode(reader, reader.uint32()));
          break;
        case 4:
          message.maxCw20Payment.push(CW20Payment.decode(reader, reader.uint32()));
          break;
        case 5:
          message.intentDurationNs = Duration.decode(reader, reader.uint32());
          break;
        case 6:
          message.maxCw1155Payment.push(CW1155Payment.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      collectionId: isSet(object.collectionId) ? String(object.collectionId) : "",
      agentQuota: isSet(object.agentQuota) ? Long.fromValue(object.agentQuota) : Long.UZERO,
      maxAmount: Array.isArray(object === null || object === void 0 ? void 0 : object.maxAmount) ? object.maxAmount.map(e => Coin.fromJSON(e)) : [],
      maxCw20Payment: Array.isArray(object === null || object === void 0 ? void 0 : object.maxCw20Payment) ? object.maxCw20Payment.map(e => CW20Payment.fromJSON(e)) : [],
      intentDurationNs: isSet(object.intentDurationNs) ? Duration.fromJSON(object.intentDurationNs) : undefined,
      maxCw1155Payment: Array.isArray(object === null || object === void 0 ? void 0 : object.maxCw1155Payment) ? object.maxCw1155Payment.map(e => CW1155Payment.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.collectionId !== undefined && (obj.collectionId = message.collectionId);
    message.agentQuota !== undefined && (obj.agentQuota = (message.agentQuota || Long.UZERO).toString());
    if (message.maxAmount) {
      obj.maxAmount = message.maxAmount.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.maxAmount = [];
    }
    if (message.maxCw20Payment) {
      obj.maxCw20Payment = message.maxCw20Payment.map(e => e ? CW20Payment.toJSON(e) : undefined);
    } else {
      obj.maxCw20Payment = [];
    }
    message.intentDurationNs !== undefined && (obj.intentDurationNs = message.intentDurationNs ? Duration.toJSON(message.intentDurationNs) : undefined);
    if (message.maxCw1155Payment) {
      obj.maxCw1155Payment = message.maxCw1155Payment.map(e => e ? CW1155Payment.toJSON(e) : undefined);
    } else {
      obj.maxCw1155Payment = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$collectionId, _object$maxAmount, _object$maxCw20Paymen, _object$maxCw1155Paym;
    const message = createBaseSubmitClaimConstraints();
    message.collectionId = (_object$collectionId = object.collectionId) !== null && _object$collectionId !== void 0 ? _object$collectionId : "";
    message.agentQuota = object.agentQuota !== undefined && object.agentQuota !== null ? Long.fromValue(object.agentQuota) : Long.UZERO;
    message.maxAmount = ((_object$maxAmount = object.maxAmount) === null || _object$maxAmount === void 0 ? void 0 : _object$maxAmount.map(e => Coin.fromPartial(e))) || [];
    message.maxCw20Payment = ((_object$maxCw20Paymen = object.maxCw20Payment) === null || _object$maxCw20Paymen === void 0 ? void 0 : _object$maxCw20Paymen.map(e => CW20Payment.fromPartial(e))) || [];
    message.intentDurationNs = object.intentDurationNs !== undefined && object.intentDurationNs !== null ? Duration.fromPartial(object.intentDurationNs) : undefined;
    message.maxCw1155Payment = ((_object$maxCw1155Paym = object.maxCw1155Payment) === null || _object$maxCw1155Paym === void 0 ? void 0 : _object$maxCw1155Paym.map(e => CW1155Payment.fromPartial(e))) || [];
    return message;
  }
};
function createBaseEvaluateClaimAuthorization() {
  return {
    admin: "",
    constraints: []
  };
}
export const EvaluateClaimAuthorization = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.admin !== "") {
      writer.uint32(10).string(message.admin);
    }
    for (const v of message.constraints) {
      EvaluateClaimConstraints.encode(v, 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 = createBaseEvaluateClaimAuthorization();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.admin = reader.string();
          break;
        case 2:
          message.constraints.push(EvaluateClaimConstraints.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      admin: isSet(object.admin) ? String(object.admin) : "",
      constraints: Array.isArray(object === null || object === void 0 ? void 0 : object.constraints) ? object.constraints.map(e => EvaluateClaimConstraints.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.admin !== undefined && (obj.admin = message.admin);
    if (message.constraints) {
      obj.constraints = message.constraints.map(e => e ? EvaluateClaimConstraints.toJSON(e) : undefined);
    } else {
      obj.constraints = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$admin2, _object$constraints2;
    const message = createBaseEvaluateClaimAuthorization();
    message.admin = (_object$admin2 = object.admin) !== null && _object$admin2 !== void 0 ? _object$admin2 : "";
    message.constraints = ((_object$constraints2 = object.constraints) === null || _object$constraints2 === void 0 ? void 0 : _object$constraints2.map(e => EvaluateClaimConstraints.fromPartial(e))) || [];
    return message;
  }
};
function createBaseEvaluateClaimConstraints() {
  return {
    collectionId: "",
    claimIds: [],
    agentQuota: Long.UZERO,
    beforeDate: undefined,
    maxCustomAmount: [],
    maxCustomCw20Payment: [],
    maxCustomCw1155Payment: []
  };
}
export const EvaluateClaimConstraints = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.collectionId !== "") {
      writer.uint32(10).string(message.collectionId);
    }
    for (const v of message.claimIds) {
      writer.uint32(18).string(v);
    }
    if (!message.agentQuota.isZero()) {
      writer.uint32(24).uint64(message.agentQuota);
    }
    if (message.beforeDate !== undefined) {
      Timestamp.encode(message.beforeDate, writer.uint32(34).fork()).ldelim();
    }
    for (const v of message.maxCustomAmount) {
      Coin.encode(v, writer.uint32(82).fork()).ldelim();
    }
    for (const v of message.maxCustomCw20Payment) {
      CW20Payment.encode(v, writer.uint32(90).fork()).ldelim();
    }
    for (const v of message.maxCustomCw1155Payment) {
      CW1155Payment.encode(v, writer.uint32(98).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 = createBaseEvaluateClaimConstraints();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.collectionId = reader.string();
          break;
        case 2:
          message.claimIds.push(reader.string());
          break;
        case 3:
          message.agentQuota = reader.uint64();
          break;
        case 4:
          message.beforeDate = Timestamp.decode(reader, reader.uint32());
          break;
        case 10:
          message.maxCustomAmount.push(Coin.decode(reader, reader.uint32()));
          break;
        case 11:
          message.maxCustomCw20Payment.push(CW20Payment.decode(reader, reader.uint32()));
          break;
        case 12:
          message.maxCustomCw1155Payment.push(CW1155Payment.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      collectionId: isSet(object.collectionId) ? String(object.collectionId) : "",
      claimIds: Array.isArray(object === null || object === void 0 ? void 0 : object.claimIds) ? object.claimIds.map(e => String(e)) : [],
      agentQuota: isSet(object.agentQuota) ? Long.fromValue(object.agentQuota) : Long.UZERO,
      beforeDate: isSet(object.beforeDate) ? fromJsonTimestamp(object.beforeDate) : undefined,
      maxCustomAmount: Array.isArray(object === null || object === void 0 ? void 0 : object.maxCustomAmount) ? object.maxCustomAmount.map(e => Coin.fromJSON(e)) : [],
      maxCustomCw20Payment: Array.isArray(object === null || object === void 0 ? void 0 : object.maxCustomCw20Payment) ? object.maxCustomCw20Payment.map(e => CW20Payment.fromJSON(e)) : [],
      maxCustomCw1155Payment: Array.isArray(object === null || object === void 0 ? void 0 : object.maxCustomCw1155Payment) ? object.maxCustomCw1155Payment.map(e => CW1155Payment.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.collectionId !== undefined && (obj.collectionId = message.collectionId);
    if (message.claimIds) {
      obj.claimIds = message.claimIds.map(e => e);
    } else {
      obj.claimIds = [];
    }
    message.agentQuota !== undefined && (obj.agentQuota = (message.agentQuota || Long.UZERO).toString());
    message.beforeDate !== undefined && (obj.beforeDate = fromTimestamp(message.beforeDate).toISOString());
    if (message.maxCustomAmount) {
      obj.maxCustomAmount = message.maxCustomAmount.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.maxCustomAmount = [];
    }
    if (message.maxCustomCw20Payment) {
      obj.maxCustomCw20Payment = message.maxCustomCw20Payment.map(e => e ? CW20Payment.toJSON(e) : undefined);
    } else {
      obj.maxCustomCw20Payment = [];
    }
    if (message.maxCustomCw1155Payment) {
      obj.maxCustomCw1155Payment = message.maxCustomCw1155Payment.map(e => e ? CW1155Payment.toJSON(e) : undefined);
    } else {
      obj.maxCustomCw1155Payment = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$collectionId2, _object$claimIds, _object$maxCustomAmou, _object$maxCustomCw, _object$maxCustomCw2;
    const message = createBaseEvaluateClaimConstraints();
    message.collectionId = (_object$collectionId2 = object.collectionId) !== null && _object$collectionId2 !== void 0 ? _object$collectionId2 : "";
    message.claimIds = ((_object$claimIds = object.claimIds) === null || _object$claimIds === void 0 ? void 0 : _object$claimIds.map(e => e)) || [];
    message.agentQuota = object.agentQuota !== undefined && object.agentQuota !== null ? Long.fromValue(object.agentQuota) : Long.UZERO;
    message.beforeDate = object.beforeDate !== undefined && object.beforeDate !== null ? Timestamp.fromPartial(object.beforeDate) : undefined;
    message.maxCustomAmount = ((_object$maxCustomAmou = object.maxCustomAmount) === null || _object$maxCustomAmou === void 0 ? void 0 : _object$maxCustomAmou.map(e => Coin.fromPartial(e))) || [];
    message.maxCustomCw20Payment = ((_object$maxCustomCw = object.maxCustomCw20Payment) === null || _object$maxCustomCw === void 0 ? void 0 : _object$maxCustomCw.map(e => CW20Payment.fromPartial(e))) || [];
    message.maxCustomCw1155Payment = ((_object$maxCustomCw2 = object.maxCustomCw1155Payment) === null || _object$maxCustomCw2 === void 0 ? void 0 : _object$maxCustomCw2.map(e => CW1155Payment.fromPartial(e))) || [];
    return message;
  }
};
function createBaseWithdrawPaymentAuthorization() {
  return {
    admin: "",
    constraints: []
  };
}
export const WithdrawPaymentAuthorization = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.admin !== "") {
      writer.uint32(10).string(message.admin);
    }
    for (const v of message.constraints) {
      WithdrawPaymentConstraints.encode(v, 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 = createBaseWithdrawPaymentAuthorization();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.admin = reader.string();
          break;
        case 2:
          message.constraints.push(WithdrawPaymentConstraints.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      admin: isSet(object.admin) ? String(object.admin) : "",
      constraints: Array.isArray(object === null || object === void 0 ? void 0 : object.constraints) ? object.constraints.map(e => WithdrawPaymentConstraints.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.admin !== undefined && (obj.admin = message.admin);
    if (message.constraints) {
      obj.constraints = message.constraints.map(e => e ? WithdrawPaymentConstraints.toJSON(e) : undefined);
    } else {
      obj.constraints = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$admin3, _object$constraints3;
    const message = createBaseWithdrawPaymentAuthorization();
    message.admin = (_object$admin3 = object.admin) !== null && _object$admin3 !== void 0 ? _object$admin3 : "";
    message.constraints = ((_object$constraints3 = object.constraints) === null || _object$constraints3 === void 0 ? void 0 : _object$constraints3.map(e => WithdrawPaymentConstraints.fromPartial(e))) || [];
    return message;
  }
};
function createBaseWithdrawPaymentConstraints() {
  return {
    claimId: "",
    inputs: [],
    outputs: [],
    paymentType: 0,
    contract_1155Payment: undefined,
    toAddress: "",
    fromAddress: "",
    releaseDate: undefined,
    cw20Payment: [],
    cw1155Payment: []
  };
}
export const WithdrawPaymentConstraints = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.claimId !== "") {
      writer.uint32(10).string(message.claimId);
    }
    for (const v of message.inputs) {
      Input.encode(v, writer.uint32(18).fork()).ldelim();
    }
    for (const v of message.outputs) {
      Output.encode(v, writer.uint32(26).fork()).ldelim();
    }
    if (message.paymentType !== 0) {
      writer.uint32(32).int32(message.paymentType);
    }
    if (message.contract_1155Payment !== undefined) {
      Contract1155Payment.encode(message.contract_1155Payment, writer.uint32(42).fork()).ldelim();
    }
    if (message.toAddress !== "") {
      writer.uint32(50).string(message.toAddress);
    }
    if (message.fromAddress !== "") {
      writer.uint32(58).string(message.fromAddress);
    }
    if (message.releaseDate !== undefined) {
      Timestamp.encode(message.releaseDate, writer.uint32(66).fork()).ldelim();
    }
    for (const v of message.cw20Payment) {
      CW20Payment.encode(v, writer.uint32(74).fork()).ldelim();
    }
    for (const v of message.cw1155Payment) {
      CW1155Payment.encode(v, writer.uint32(82).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 = createBaseWithdrawPaymentConstraints();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.claimId = reader.string();
          break;
        case 2:
          message.inputs.push(Input.decode(reader, reader.uint32()));
          break;
        case 3:
          message.outputs.push(Output.decode(reader, reader.uint32()));
          break;
        case 4:
          message.paymentType = reader.int32();
          break;
        case 5:
          message.contract_1155Payment = Contract1155Payment.decode(reader, reader.uint32());
          break;
        case 6:
          message.toAddress = reader.string();
          break;
        case 7:
          message.fromAddress = reader.string();
          break;
        case 8:
          message.releaseDate = Timestamp.decode(reader, reader.uint32());
          break;
        case 9:
          message.cw20Payment.push(CW20Payment.decode(reader, reader.uint32()));
          break;
        case 10:
          message.cw1155Payment.push(CW1155Payment.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      claimId: isSet(object.claimId) ? String(object.claimId) : "",
      inputs: Array.isArray(object === null || object === void 0 ? void 0 : object.inputs) ? object.inputs.map(e => Input.fromJSON(e)) : [],
      outputs: Array.isArray(object === null || object === void 0 ? void 0 : object.outputs) ? object.outputs.map(e => Output.fromJSON(e)) : [],
      paymentType: isSet(object.paymentType) ? paymentTypeFromJSON(object.paymentType) : 0,
      contract_1155Payment: isSet(object.contract_1155Payment) ? Contract1155Payment.fromJSON(object.contract_1155Payment) : undefined,
      toAddress: isSet(object.toAddress) ? String(object.toAddress) : "",
      fromAddress: isSet(object.fromAddress) ? String(object.fromAddress) : "",
      releaseDate: isSet(object.releaseDate) ? fromJsonTimestamp(object.releaseDate) : undefined,
      cw20Payment: Array.isArray(object === null || object === void 0 ? void 0 : object.cw20Payment) ? object.cw20Payment.map(e => CW20Payment.fromJSON(e)) : [],
      cw1155Payment: Array.isArray(object === null || object === void 0 ? void 0 : object.cw1155Payment) ? object.cw1155Payment.map(e => CW1155Payment.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.claimId !== undefined && (obj.claimId = message.claimId);
    if (message.inputs) {
      obj.inputs = message.inputs.map(e => e ? Input.toJSON(e) : undefined);
    } else {
      obj.inputs = [];
    }
    if (message.outputs) {
      obj.outputs = message.outputs.map(e => e ? Output.toJSON(e) : undefined);
    } else {
      obj.outputs = [];
    }
    message.paymentType !== undefined && (obj.paymentType = paymentTypeToJSON(message.paymentType));
    message.contract_1155Payment !== undefined && (obj.contract_1155Payment = message.contract_1155Payment ? Contract1155Payment.toJSON(message.contract_1155Payment) : undefined);
    message.toAddress !== undefined && (obj.toAddress = message.toAddress);
    message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress);
    message.releaseDate !== undefined && (obj.releaseDate = fromTimestamp(message.releaseDate).toISOString());
    if (message.cw20Payment) {
      obj.cw20Payment = message.cw20Payment.map(e => e ? CW20Payment.toJSON(e) : undefined);
    } else {
      obj.cw20Payment = [];
    }
    if (message.cw1155Payment) {
      obj.cw1155Payment = message.cw1155Payment.map(e => e ? CW1155Payment.toJSON(e) : undefined);
    } else {
      obj.cw1155Payment = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$claimId, _object$inputs, _object$outputs, _object$paymentType, _object$toAddress, _object$fromAddress, _object$cw20Payment, _object$cw1155Payment;
    const message = createBaseWithdrawPaymentConstraints();
    message.claimId = (_object$claimId = object.claimId) !== null && _object$claimId !== void 0 ? _object$claimId : "";
    message.inputs = ((_object$inputs = object.inputs) === null || _object$inputs === void 0 ? void 0 : _object$inputs.map(e => Input.fromPartial(e))) || [];
    message.outputs = ((_object$outputs = object.outputs) === null || _object$outputs === void 0 ? void 0 : _object$outputs.map(e => Output.fromPartial(e))) || [];
    message.paymentType = (_object$paymentType = object.paymentType) !== null && _object$paymentType !== void 0 ? _object$paymentType : 0;
    message.contract_1155Payment = object.contract_1155Payment !== undefined && object.contract_1155Payment !== null ? Contract1155Payment.fromPartial(object.contract_1155Payment) : undefined;
    message.toAddress = (_object$toAddress = object.toAddress) !== null && _object$toAddress !== void 0 ? _object$toAddress : "";
    message.fromAddress = (_object$fromAddress = object.fromAddress) !== null && _object$fromAddress !== void 0 ? _object$fromAddress : "";
    message.releaseDate = object.releaseDate !== undefined && object.releaseDate !== null ? Timestamp.fromPartial(object.releaseDate) : undefined;
    message.cw20Payment = ((_object$cw20Payment = object.cw20Payment) === null || _object$cw20Payment === void 0 ? void 0 : _object$cw20Payment.map(e => CW20Payment.fromPartial(e))) || [];
    message.cw1155Payment = ((_object$cw1155Payment = object.cw1155Payment) === null || _object$cw1155Payment === void 0 ? void 0 : _object$cw1155Payment.map(e => CW1155Payment.fromPartial(e))) || [];
    return message;
  }
};
function createBaseCreateClaimAuthorizationAuthorization() {
  return {
    admin: "",
    constraints: []
  };
}
export const CreateClaimAuthorizationAuthorization = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.admin !== "") {
      writer.uint32(10).string(message.admin);
    }
    for (const v of message.constraints) {
      CreateClaimAuthorizationConstraints.encode(v, 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 = createBaseCreateClaimAuthorizationAuthorization();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.admin = reader.string();
          break;
        case 2:
          message.constraints.push(CreateClaimAuthorizationConstraints.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      admin: isSet(object.admin) ? String(object.admin) : "",
      constraints: Array.isArray(object === null || object === void 0 ? void 0 : object.constraints) ? object.constraints.map(e => CreateClaimAuthorizationConstraints.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.admin !== undefined && (obj.admin = message.admin);
    if (message.constraints) {
      obj.constraints = message.constraints.map(e => e ? CreateClaimAuthorizationConstraints.toJSON(e) : undefined);
    } else {
      obj.constraints = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$admin4, _object$constraints4;
    const message = createBaseCreateClaimAuthorizationAuthorization();
    message.admin = (_object$admin4 = object.admin) !== null && _object$admin4 !== void 0 ? _object$admin4 : "";
    message.constraints = ((_object$constraints4 = object.constraints) === null || _object$constraints4 === void 0 ? void 0 : _object$constraints4.map(e => CreateClaimAuthorizationConstraints.fromPartial(e))) || [];
    return message;
  }
};
function createBaseCreateClaimAuthorizationConstraints() {
  return {
    maxAuthorizations: Long.UZERO,
    maxAgentQuota: Long.UZERO,
    maxAmount: [],
    maxCw20Payment: [],
    expiration: undefined,
    collectionIds: [],
    allowedAuthTypes: 0,
    maxIntentDurationNs: undefined,
    maxCw1155Payment: []
  };
}
export const CreateClaimAuthorizationConstraints = {
  encode(message, writer = _m0.Writer.create()) {
    if (!message.maxAuthorizations.isZero()) {
      writer.uint32(8).uint64(message.maxAuthorizations);
    }
    if (!message.maxAgentQuota.isZero()) {
      writer.uint32(16).uint64(message.maxAgentQuota);
    }
    for (const v of message.maxAmount) {
      Coin.encode(v, writer.uint32(26).fork()).ldelim();
    }
    for (const v of message.maxCw20Payment) {
      CW20Payment.encode(v, writer.uint32(34).fork()).ldelim();
    }
    if (message.expiration !== undefined) {
      Timestamp.encode(message.expiration, writer.uint32(42).fork()).ldelim();
    }
    for (const v of message.collectionIds) {
      writer.uint32(50).string(v);
    }
    if (message.allowedAuthTypes !== 0) {
      writer.uint32(56).int32(message.allowedAuthTypes);
    }
    if (message.maxIntentDurationNs !== undefined) {
      Duration.encode(message.maxIntentDurationNs, writer.uint32(66).fork()).ldelim();
    }
    for (const v of message.maxCw1155Payment) {
      CW1155Payment.encode(v, writer.uint32(74).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 = createBaseCreateClaimAuthorizationConstraints();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.maxAuthorizations = reader.uint64();
          break;
        case 2:
          message.maxAgentQuota = reader.uint64();
          break;
        case 3:
          message.maxAmount.push(Coin.decode(reader, reader.uint32()));
          break;
        case 4:
          message.maxCw20Payment.push(CW20Payment.decode(reader, reader.uint32()));
          break;
        case 5:
          message.expiration = Timestamp.decode(reader, reader.uint32());
          break;
        case 6:
          message.collectionIds.push(reader.string());
          break;
        case 7:
          message.allowedAuthTypes = reader.int32();
          break;
        case 8:
          message.maxIntentDurationNs = Duration.decode(reader, reader.uint32());
          break;
        case 9:
          message.maxCw1155Payment.push(CW1155Payment.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      maxAuthorizations: isSet(object.maxAuthorizations) ? Long.fromValue(object.maxAuthorizations) : Long.UZERO,
      maxAgentQuota: isSet(object.maxAgentQuota) ? Long.fromValue(object.maxAgentQuota) : Long.UZERO,
      maxAmount: Array.isArray(object === null || object === void 0 ? void 0 : object.maxAmount) ? object.maxAmount.map(e => Coin.fromJSON(e)) : [],
      maxCw20Payment: Array.isArray(object === null || object === void 0 ? void 0 : object.maxCw20Payment) ? object.maxCw20Payment.map(e => CW20Payment.fromJSON(e)) : [],
      expiration: isSet(object.expiration) ? fromJsonTimestamp(object.expiration) : undefined,
      collectionIds: Array.isArray(object === null || object === void 0 ? void 0 : object.collectionIds) ? object.collectionIds.map(e => String(e)) : [],
      allowedAuthTypes: isSet(object.allowedAuthTypes) ? createClaimAuthorizationTypeFromJSON(object.allowedAuthTypes) : 0,
      maxIntentDurationNs: isSet(object.maxIntentDurationNs) ? Duration.fromJSON(object.maxIntentDurationNs) : undefined,
      maxCw1155Payment: Array.isArray(object === null || object === void 0 ? void 0 : object.maxCw1155Payment) ? object.maxCw1155Payment.map(e => CW1155Payment.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.maxAuthorizations !== undefined && (obj.maxAuthorizations = (message.maxAuthorizations || Long.UZERO).toString());
    message.maxAgentQuota !== undefined && (obj.maxAgentQuota = (message.maxAgentQuota || Long.UZERO).toString());
    if (message.maxAmount) {
      obj.maxAmount = message.maxAmount.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.maxAmount = [];
    }
    if (message.maxCw20Payment) {
      obj.maxCw20Payment = message.maxCw20Payment.map(e => e ? CW20Payment.toJSON(e) : undefined);
    } else {
      obj.maxCw20Payment = [];
    }
    message.expiration !== undefined && (obj.expiration = fromTimestamp(message.expiration).toISOString());
    if (message.collectionIds) {
      obj.collectionIds = message.collectionIds.map(e => e);
    } else {
      obj.collectionIds = [];
    }
    message.allowedAuthTypes !== undefined && (obj.allowedAuthTypes = createClaimAuthorizationTypeToJSON(message.allowedAuthTypes));
    message.maxIntentDurationNs !== undefined && (obj.maxIntentDurationNs = message.maxIntentDurationNs ? Duration.toJSON(message.maxIntentDurationNs) : undefined);
    if (message.maxCw1155Payment) {
      obj.maxCw1155Payment = message.maxCw1155Payment.map(e => e ? CW1155Payment.toJSON(e) : undefined);
    } else {
      obj.maxCw1155Payment = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$maxAmount2, _object$maxCw20Paymen2, _object$collectionIds, _object$allowedAuthTy, _object$maxCw1155Paym2;
    const message = createBaseCreateClaimAuthorizationConstraints();
    message.maxAuthorizations = object.maxAuthorizations !== undefined && object.maxAuthorizations !== null ? Long.fromValue(object.maxAuthorizations) : Long.UZERO;
    message.maxAgentQuota = object.maxAgentQuota !== undefined && object.maxAgentQuota !== null ? Long.fromValue(object.maxAgentQuota) : Long.UZERO;
    message.maxAmount = ((_object$maxAmount2 = object.maxAmount) === null || _object$maxAmount2 === void 0 ? void 0 : _object$maxAmount2.map(e => Coin.fromPartial(e))) || [];
    message.maxCw20Payment = ((_object$maxCw20Paymen2 = object.maxCw20Payment) === null || _object$maxCw20Paymen2 === void 0 ? void 0 : _object$maxCw20Paymen2.map(e => CW20Payment.fromPartial(e))) || [];
    message.expiration = object.expiration !== undefined && object.expiration !== null ? Timestamp.fromPartial(object.expiration) : undefined;
    message.collectionIds = ((_object$collectionIds = object.collectionIds) === null || _object$collectionIds === void 0 ? void 0 : _object$collectionIds.map(e => e)) || [];
    message.allowedAuthTypes = (_object$allowedAuthTy = object.allowedAuthTypes) !== null && _object$allowedAuthTy !== void 0 ? _object$allowedAuthTy : 0;
    message.maxIntentDurationNs = object.maxIntentDurationNs !== undefined && object.maxIntentDurationNs !== null ? Duration.fromPartial(object.maxIntentDurationNs) : undefined;
    message.maxCw1155Payment = ((_object$maxCw1155Paym2 = object.maxCw1155Payment) === null || _object$maxCw1155Paym2 === void 0 ? void 0 : _object$maxCw1155Paym2.map(e => CW1155Payment.fromPartial(e))) || [];
    return message;
  }
};