//@ts-nocheck
import { Collection, Claim, Evaluation, Dispute, CW20Output, CW1155IntentPayment, Intent } from "./claims";
import { WithdrawPaymentConstraints } from "./authz";
import * as _m0 from "protobufjs/minimal";
import { isSet } from "../../../helpers";
/** CollectionCreatedEvent is an event triggered on a Collection creation */

/** CollectionCreatedEvent is an event triggered on a Collection creation */

/** CollectionUpdatedEvent is an event triggered on a Collection update */

/** CollectionUpdatedEvent is an event triggered on a Collection update */

/** CollectionCreatedEvent is an event triggered on a Claim submission */

/** CollectionCreatedEvent is an event triggered on a Claim submission */

/** ClaimUpdatedEvent is an event triggered on a Claim update */

/** ClaimUpdatedEvent is an event triggered on a Claim update */

/** ClaimEvaluatedEvent is an event triggered on a Claim evaluation */

/** ClaimEvaluatedEvent is an event triggered on a Claim evaluation */

/** ClaimDisputedEvent is an event triggered on a Claim dispute */

/** ClaimDisputedEvent is an event triggered on a Claim dispute */

/** ClaimDisputedEvent is an event triggered on a Claim dispute */

/** ClaimDisputedEvent is an event triggered on a Claim dispute */

/** ClaimDisputedEvent is an event triggered on a Claim dispute */

/** ClaimDisputedEvent is an event triggered on a Claim dispute */

/** IntentSubmittedEvent is an event triggered on an Intent submission */

/** IntentSubmittedEvent is an event triggered on an Intent submission */

/** IntentUpdatedEvent is an event triggered on an Intent update */

/** IntentUpdatedEvent is an event triggered on an Intent update */

/**
 * ClaimAuthorizationCreatedEvent is an event triggered on a Claim authorization
 * creation
 */

/**
 * ClaimAuthorizationCreatedEvent is an event triggered on a Claim authorization
 * creation
 */

function createBaseCollectionCreatedEvent() {
  return {
    collection: undefined
  };
}
export const CollectionCreatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.collection !== undefined) {
      Collection.encode(message.collection, writer.uint32(10).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 = createBaseCollectionCreatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.collection = Collection.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      collection: isSet(object.collection) ? Collection.fromJSON(object.collection) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.collection !== undefined && (obj.collection = message.collection ? Collection.toJSON(message.collection) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseCollectionCreatedEvent();
    message.collection = object.collection !== undefined && object.collection !== null ? Collection.fromPartial(object.collection) : undefined;
    return message;
  }
};
function createBaseCollectionUpdatedEvent() {
  return {
    collection: undefined
  };
}
export const CollectionUpdatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.collection !== undefined) {
      Collection.encode(message.collection, writer.uint32(10).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 = createBaseCollectionUpdatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.collection = Collection.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      collection: isSet(object.collection) ? Collection.fromJSON(object.collection) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.collection !== undefined && (obj.collection = message.collection ? Collection.toJSON(message.collection) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseCollectionUpdatedEvent();
    message.collection = object.collection !== undefined && object.collection !== null ? Collection.fromPartial(object.collection) : undefined;
    return message;
  }
};
function createBaseClaimSubmittedEvent() {
  return {
    claim: undefined
  };
}
export const ClaimSubmittedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.claim !== undefined) {
      Claim.encode(message.claim, writer.uint32(10).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 = createBaseClaimSubmittedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.claim = Claim.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      claim: isSet(object.claim) ? Claim.fromJSON(object.claim) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.claim !== undefined && (obj.claim = message.claim ? Claim.toJSON(message.claim) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseClaimSubmittedEvent();
    message.claim = object.claim !== undefined && object.claim !== null ? Claim.fromPartial(object.claim) : undefined;
    return message;
  }
};
function createBaseClaimUpdatedEvent() {
  return {
    claim: undefined
  };
}
export const ClaimUpdatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.claim !== undefined) {
      Claim.encode(message.claim, writer.uint32(10).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 = createBaseClaimUpdatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.claim = Claim.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      claim: isSet(object.claim) ? Claim.fromJSON(object.claim) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.claim !== undefined && (obj.claim = message.claim ? Claim.toJSON(message.claim) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseClaimUpdatedEvent();
    message.claim = object.claim !== undefined && object.claim !== null ? Claim.fromPartial(object.claim) : undefined;
    return message;
  }
};
function createBaseClaimEvaluatedEvent() {
  return {
    evaluation: undefined
  };
}
export const ClaimEvaluatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.evaluation !== undefined) {
      Evaluation.encode(message.evaluation, writer.uint32(10).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 = createBaseClaimEvaluatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.evaluation = Evaluation.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      evaluation: isSet(object.evaluation) ? Evaluation.fromJSON(object.evaluation) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.evaluation !== undefined && (obj.evaluation = message.evaluation ? Evaluation.toJSON(message.evaluation) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseClaimEvaluatedEvent();
    message.evaluation = object.evaluation !== undefined && object.evaluation !== null ? Evaluation.fromPartial(object.evaluation) : undefined;
    return message;
  }
};
function createBaseClaimDisputedEvent() {
  return {
    dispute: undefined
  };
}
export const ClaimDisputedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.dispute !== undefined) {
      Dispute.encode(message.dispute, writer.uint32(10).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 = createBaseClaimDisputedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.dispute = Dispute.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      dispute: isSet(object.dispute) ? Dispute.fromJSON(object.dispute) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.dispute !== undefined && (obj.dispute = message.dispute ? Dispute.toJSON(message.dispute) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseClaimDisputedEvent();
    message.dispute = object.dispute !== undefined && object.dispute !== null ? Dispute.fromPartial(object.dispute) : undefined;
    return message;
  }
};
function createBasePaymentWithdrawnEvent() {
  return {
    withdraw: undefined,
    cw20Outputs: [],
    cw1155Payments: []
  };
}
export const PaymentWithdrawnEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.withdraw !== undefined) {
      WithdrawPaymentConstraints.encode(message.withdraw, writer.uint32(10).fork()).ldelim();
    }
    for (const v of message.cw20Outputs) {
      CW20Output.encode(v, writer.uint32(18).fork()).ldelim();
    }
    for (const v of message.cw1155Payments) {
      CW1155IntentPayment.encode(v, writer.uint32(26).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 = createBasePaymentWithdrawnEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.withdraw = WithdrawPaymentConstraints.decode(reader, reader.uint32());
          break;
        case 2:
          message.cw20Outputs.push(CW20Output.decode(reader, reader.uint32()));
          break;
        case 3:
          message.cw1155Payments.push(CW1155IntentPayment.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      withdraw: isSet(object.withdraw) ? WithdrawPaymentConstraints.fromJSON(object.withdraw) : undefined,
      cw20Outputs: Array.isArray(object === null || object === void 0 ? void 0 : object.cw20Outputs) ? object.cw20Outputs.map(e => CW20Output.fromJSON(e)) : [],
      cw1155Payments: Array.isArray(object === null || object === void 0 ? void 0 : object.cw1155Payments) ? object.cw1155Payments.map(e => CW1155IntentPayment.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.withdraw !== undefined && (obj.withdraw = message.withdraw ? WithdrawPaymentConstraints.toJSON(message.withdraw) : undefined);
    if (message.cw20Outputs) {
      obj.cw20Outputs = message.cw20Outputs.map(e => e ? CW20Output.toJSON(e) : undefined);
    } else {
      obj.cw20Outputs = [];
    }
    if (message.cw1155Payments) {
      obj.cw1155Payments = message.cw1155Payments.map(e => e ? CW1155IntentPayment.toJSON(e) : undefined);
    } else {
      obj.cw1155Payments = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$cw20Outputs, _object$cw1155Payment;
    const message = createBasePaymentWithdrawnEvent();
    message.withdraw = object.withdraw !== undefined && object.withdraw !== null ? WithdrawPaymentConstraints.fromPartial(object.withdraw) : undefined;
    message.cw20Outputs = ((_object$cw20Outputs = object.cw20Outputs) === null || _object$cw20Outputs === void 0 ? void 0 : _object$cw20Outputs.map(e => CW20Output.fromPartial(e))) || [];
    message.cw1155Payments = ((_object$cw1155Payment = object.cw1155Payments) === null || _object$cw1155Payment === void 0 ? void 0 : _object$cw1155Payment.map(e => CW1155IntentPayment.fromPartial(e))) || [];
    return message;
  }
};
function createBasePaymentWithdrawCreatedEvent() {
  return {
    withdraw: undefined
  };
}
export const PaymentWithdrawCreatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.withdraw !== undefined) {
      WithdrawPaymentConstraints.encode(message.withdraw, writer.uint32(10).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 = createBasePaymentWithdrawCreatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.withdraw = WithdrawPaymentConstraints.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      withdraw: isSet(object.withdraw) ? WithdrawPaymentConstraints.fromJSON(object.withdraw) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.withdraw !== undefined && (obj.withdraw = message.withdraw ? WithdrawPaymentConstraints.toJSON(message.withdraw) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBasePaymentWithdrawCreatedEvent();
    message.withdraw = object.withdraw !== undefined && object.withdraw !== null ? WithdrawPaymentConstraints.fromPartial(object.withdraw) : undefined;
    return message;
  }
};
function createBaseIntentSubmittedEvent() {
  return {
    intent: undefined
  };
}
export const IntentSubmittedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.intent !== undefined) {
      Intent.encode(message.intent, writer.uint32(10).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 = createBaseIntentSubmittedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.intent = Intent.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      intent: isSet(object.intent) ? Intent.fromJSON(object.intent) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.intent !== undefined && (obj.intent = message.intent ? Intent.toJSON(message.intent) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseIntentSubmittedEvent();
    message.intent = object.intent !== undefined && object.intent !== null ? Intent.fromPartial(object.intent) : undefined;
    return message;
  }
};
function createBaseIntentUpdatedEvent() {
  return {
    intent: undefined
  };
}
export const IntentUpdatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.intent !== undefined) {
      Intent.encode(message.intent, writer.uint32(10).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 = createBaseIntentUpdatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.intent = Intent.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      intent: isSet(object.intent) ? Intent.fromJSON(object.intent) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.intent !== undefined && (obj.intent = message.intent ? Intent.toJSON(message.intent) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseIntentUpdatedEvent();
    message.intent = object.intent !== undefined && object.intent !== null ? Intent.fromPartial(object.intent) : undefined;
    return message;
  }
};
function createBaseClaimAuthorizationCreatedEvent() {
  return {
    creator: "",
    creatorDid: "",
    grantee: "",
    admin: "",
    collectionId: "",
    authType: ""
  };
}
export const ClaimAuthorizationCreatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.creator !== "") {
      writer.uint32(10).string(message.creator);
    }
    if (message.creatorDid !== "") {
      writer.uint32(18).string(message.creatorDid);
    }
    if (message.grantee !== "") {
      writer.uint32(26).string(message.grantee);
    }
    if (message.admin !== "") {
      writer.uint32(34).string(message.admin);
    }
    if (message.collectionId !== "") {
      writer.uint32(42).string(message.collectionId);
    }
    if (message.authType !== "") {
      writer.uint32(50).string(message.authType);
    }
    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 = createBaseClaimAuthorizationCreatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.creator = reader.string();
          break;
        case 2:
          message.creatorDid = reader.string();
          break;
        case 3:
          message.grantee = reader.string();
          break;
        case 4:
          message.admin = reader.string();
          break;
        case 5:
          message.collectionId = reader.string();
          break;
        case 6:
          message.authType = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      creator: isSet(object.creator) ? String(object.creator) : "",
      creatorDid: isSet(object.creatorDid) ? String(object.creatorDid) : "",
      grantee: isSet(object.grantee) ? String(object.grantee) : "",
      admin: isSet(object.admin) ? String(object.admin) : "",
      collectionId: isSet(object.collectionId) ? String(object.collectionId) : "",
      authType: isSet(object.authType) ? String(object.authType) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    message.creator !== undefined && (obj.creator = message.creator);
    message.creatorDid !== undefined && (obj.creatorDid = message.creatorDid);
    message.grantee !== undefined && (obj.grantee = message.grantee);
    message.admin !== undefined && (obj.admin = message.admin);
    message.collectionId !== undefined && (obj.collectionId = message.collectionId);
    message.authType !== undefined && (obj.authType = message.authType);
    return obj;
  },
  fromPartial(object) {
    var _object$creator, _object$creatorDid, _object$grantee, _object$admin, _object$collectionId, _object$authType;
    const message = createBaseClaimAuthorizationCreatedEvent();
    message.creator = (_object$creator = object.creator) !== null && _object$creator !== void 0 ? _object$creator : "";
    message.creatorDid = (_object$creatorDid = object.creatorDid) !== null && _object$creatorDid !== void 0 ? _object$creatorDid : "";
    message.grantee = (_object$grantee = object.grantee) !== null && _object$grantee !== void 0 ? _object$grantee : "";
    message.admin = (_object$admin = object.admin) !== null && _object$admin !== void 0 ? _object$admin : "";
    message.collectionId = (_object$collectionId = object.collectionId) !== null && _object$collectionId !== void 0 ? _object$collectionId : "";
    message.authType = (_object$authType = object.authType) !== null && _object$authType !== void 0 ? _object$authType : "";
    return message;
  }
};