"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PacketFees = exports.PacketFee = exports.IdentifiedPacketFees = exports.Fee = void 0;
var _coin = require("../../../../cosmos/base/v1beta1/coin");
var _channel = require("../../../core/channel/v1/channel");
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
var _helpers = require("../../../../helpers");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } //@ts-nocheck
/** Fee defines the ICS29 receive, acknowledgement and timeout fees */

/** Fee defines the ICS29 receive, acknowledgement and timeout fees */

/** PacketFee contains ICS29 relayer fees, refund address and optional list of permitted relayers */

/** PacketFee contains ICS29 relayer fees, refund address and optional list of permitted relayers */

/** PacketFees contains a list of type PacketFee */

/** PacketFees contains a list of type PacketFee */

/** IdentifiedPacketFees contains a list of type PacketFee and associated PacketId */

/** IdentifiedPacketFees contains a list of type PacketFee and associated PacketId */

function createBaseFee() {
  return {
    recvFee: [],
    ackFee: [],
    timeoutFee: []
  };
}
var Fee = exports.Fee = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    var _iterator = _createForOfIteratorHelper(message.recvFee),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        _coin.Coin.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    var _iterator2 = _createForOfIteratorHelper(message.ackFee),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var _v = _step2.value;
        _coin.Coin.encode(_v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    var _iterator3 = _createForOfIteratorHelper(message.timeoutFee),
      _step3;
    try {
      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
        var _v2 = _step3.value;
        _coin.Coin.encode(_v2, writer.uint32(26).fork()).ldelim();
      }
    } catch (err) {
      _iterator3.e(err);
    } finally {
      _iterator3.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseFee();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.recvFee.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 2:
          message.ackFee.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 3:
          message.timeoutFee.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      recvFee: Array.isArray(object === null || object === void 0 ? void 0 : object.recvFee) ? object.recvFee.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      ackFee: Array.isArray(object === null || object === void 0 ? void 0 : object.ackFee) ? object.ackFee.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      timeoutFee: Array.isArray(object === null || object === void 0 ? void 0 : object.timeoutFee) ? object.timeoutFee.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    if (message.recvFee) {
      obj.recvFee = message.recvFee.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.recvFee = [];
    }
    if (message.ackFee) {
      obj.ackFee = message.ackFee.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.ackFee = [];
    }
    if (message.timeoutFee) {
      obj.timeoutFee = message.timeoutFee.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.timeoutFee = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$recvFee, _object$ackFee, _object$timeoutFee;
    var message = createBaseFee();
    message.recvFee = ((_object$recvFee = object.recvFee) === null || _object$recvFee === void 0 ? void 0 : _object$recvFee.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.ackFee = ((_object$ackFee = object.ackFee) === null || _object$ackFee === void 0 ? void 0 : _object$ackFee.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.timeoutFee = ((_object$timeoutFee = object.timeoutFee) === null || _object$timeoutFee === void 0 ? void 0 : _object$timeoutFee.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    return message;
  }
};
function createBasePacketFee() {
  return {
    fee: undefined,
    refundAddress: "",
    relayers: []
  };
}
var PacketFee = exports.PacketFee = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.fee !== undefined) {
      Fee.encode(message.fee, writer.uint32(10).fork()).ldelim();
    }
    if (message.refundAddress !== "") {
      writer.uint32(18).string(message.refundAddress);
    }
    var _iterator4 = _createForOfIteratorHelper(message.relayers),
      _step4;
    try {
      for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
        var v = _step4.value;
        writer.uint32(26).string(v);
      }
    } catch (err) {
      _iterator4.e(err);
    } finally {
      _iterator4.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBasePacketFee();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.fee = Fee.decode(reader, reader.uint32());
          break;
        case 2:
          message.refundAddress = reader.string();
          break;
        case 3:
          message.relayers.push(reader.string());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      fee: (0, _helpers.isSet)(object.fee) ? Fee.fromJSON(object.fee) : undefined,
      refundAddress: (0, _helpers.isSet)(object.refundAddress) ? String(object.refundAddress) : "",
      relayers: Array.isArray(object === null || object === void 0 ? void 0 : object.relayers) ? object.relayers.map(function (e) {
        return String(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.fee !== undefined && (obj.fee = message.fee ? Fee.toJSON(message.fee) : undefined);
    message.refundAddress !== undefined && (obj.refundAddress = message.refundAddress);
    if (message.relayers) {
      obj.relayers = message.relayers.map(function (e) {
        return e;
      });
    } else {
      obj.relayers = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$refundAddress, _object$relayers;
    var message = createBasePacketFee();
    message.fee = object.fee !== undefined && object.fee !== null ? Fee.fromPartial(object.fee) : undefined;
    message.refundAddress = (_object$refundAddress = object.refundAddress) !== null && _object$refundAddress !== void 0 ? _object$refundAddress : "";
    message.relayers = ((_object$relayers = object.relayers) === null || _object$relayers === void 0 ? void 0 : _object$relayers.map(function (e) {
      return e;
    })) || [];
    return message;
  }
};
function createBasePacketFees() {
  return {
    packetFees: []
  };
}
var PacketFees = exports.PacketFees = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    var _iterator5 = _createForOfIteratorHelper(message.packetFees),
      _step5;
    try {
      for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
        var v = _step5.value;
        PacketFee.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator5.e(err);
    } finally {
      _iterator5.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBasePacketFees();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.packetFees.push(PacketFee.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      packetFees: Array.isArray(object === null || object === void 0 ? void 0 : object.packetFees) ? object.packetFees.map(function (e) {
        return PacketFee.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    if (message.packetFees) {
      obj.packetFees = message.packetFees.map(function (e) {
        return e ? PacketFee.toJSON(e) : undefined;
      });
    } else {
      obj.packetFees = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$packetFees;
    var message = createBasePacketFees();
    message.packetFees = ((_object$packetFees = object.packetFees) === null || _object$packetFees === void 0 ? void 0 : _object$packetFees.map(function (e) {
      return PacketFee.fromPartial(e);
    })) || [];
    return message;
  }
};
function createBaseIdentifiedPacketFees() {
  return {
    packetId: undefined,
    packetFees: []
  };
}
var IdentifiedPacketFees = exports.IdentifiedPacketFees = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.packetId !== undefined) {
      _channel.PacketId.encode(message.packetId, writer.uint32(10).fork()).ldelim();
    }
    var _iterator6 = _createForOfIteratorHelper(message.packetFees),
      _step6;
    try {
      for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
        var v = _step6.value;
        PacketFee.encode(v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator6.e(err);
    } finally {
      _iterator6.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseIdentifiedPacketFees();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.packetId = _channel.PacketId.decode(reader, reader.uint32());
          break;
        case 2:
          message.packetFees.push(PacketFee.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      packetId: (0, _helpers.isSet)(object.packetId) ? _channel.PacketId.fromJSON(object.packetId) : undefined,
      packetFees: Array.isArray(object === null || object === void 0 ? void 0 : object.packetFees) ? object.packetFees.map(function (e) {
        return PacketFee.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.packetId !== undefined && (obj.packetId = message.packetId ? _channel.PacketId.toJSON(message.packetId) : undefined);
    if (message.packetFees) {
      obj.packetFees = message.packetFees.map(function (e) {
        return e ? PacketFee.toJSON(e) : undefined;
      });
    } else {
      obj.packetFees = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$packetFees2;
    var message = createBaseIdentifiedPacketFees();
    message.packetId = object.packetId !== undefined && object.packetId !== null ? _channel.PacketId.fromPartial(object.packetId) : undefined;
    message.packetFees = ((_object$packetFees2 = object.packetFees) === null || _object$packetFees2 === void 0 ? void 0 : _object$packetFees2.map(function (e) {
      return PacketFee.fromPartial(e);
    })) || [];
    return message;
  }
};