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 { Coin } from "../../../cosmos/base/v1beta1/coin_pb.js";
import { Timestamp } from "../../../google/protobuf/timestamp_pb.js";
import { OracleType } from "../../oracle/v1beta1/oracle_pb.js";
import { Duration } from "../../../google/protobuf/duration_pb.js";
class Params$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.Params", [
      { no: 1, name: "default_redemption_notice_period_duration", kind: "message", T: () => Duration, options: { "gogoproto.nullable": false, "gogoproto.moretags": 'yaml:"default_redemption_notice_period_duration"', "gogoproto.stdduration": true } }
    ], { "gogoproto.equal": true, "amino.name": "insurance/Params" });
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    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 /* google.protobuf.Duration default_redemption_notice_period_duration */
        1:
          message.defaultRedemptionNoticePeriodDuration = Duration.internalBinaryRead(reader, reader.uint32(), options, message.defaultRedemptionNoticePeriodDuration);
          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.defaultRedemptionNoticePeriodDuration)
      Duration.internalBinaryWrite(message.defaultRedemptionNoticePeriodDuration, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const Params = new Params$Type();
class InsuranceFund$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.InsuranceFund", [
      {
        no: 1,
        name: "deposit_denom",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 2,
        name: "insurance_pool_token_denom",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 3, name: "redemption_notice_period_duration", kind: "message", T: () => Duration, options: { "gogoproto.nullable": false, "gogoproto.moretags": 'yaml:"redemption_notice_period_duration"', "gogoproto.stdduration": true } },
      { no: 4, name: "balance", kind: "scalar", T: 9, options: { "gogoproto.nullable": false, "gogoproto.customtype": "cosmossdk.io/math.Int" } },
      { no: 5, name: "total_share", kind: "scalar", T: 9, options: { "gogoproto.nullable": false, "gogoproto.customtype": "cosmossdk.io/math.Int" } },
      {
        no: 6,
        name: "market_id",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 7,
        name: "market_ticker",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 8,
        name: "oracle_base",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 9,
        name: "oracle_quote",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 10, name: "oracle_type", kind: "enum", T: () => ["injective.oracle.v1beta1.OracleType", OracleType] },
      {
        no: 11,
        name: "expiry",
        kind: "scalar",
        T: 3,
        L: 0
        /*LongType.BIGINT*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.depositDenom = "";
    message.insurancePoolTokenDenom = "";
    message.balance = "";
    message.totalShare = "";
    message.marketId = "";
    message.marketTicker = "";
    message.oracleBase = "";
    message.oracleQuote = "";
    message.oracleType = 0;
    message.expiry = 0n;
    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 /* string deposit_denom */
        1:
          message.depositDenom = reader.string();
          break;
        case /* string insurance_pool_token_denom */
        2:
          message.insurancePoolTokenDenom = reader.string();
          break;
        case /* google.protobuf.Duration redemption_notice_period_duration */
        3:
          message.redemptionNoticePeriodDuration = Duration.internalBinaryRead(reader, reader.uint32(), options, message.redemptionNoticePeriodDuration);
          break;
        case /* string balance */
        4:
          message.balance = reader.string();
          break;
        case /* string total_share */
        5:
          message.totalShare = reader.string();
          break;
        case /* string market_id */
        6:
          message.marketId = reader.string();
          break;
        case /* string market_ticker */
        7:
          message.marketTicker = reader.string();
          break;
        case /* string oracle_base */
        8:
          message.oracleBase = reader.string();
          break;
        case /* string oracle_quote */
        9:
          message.oracleQuote = reader.string();
          break;
        case /* injective.oracle.v1beta1.OracleType oracle_type */
        10:
          message.oracleType = reader.int32();
          break;
        case /* int64 expiry */
        11:
          message.expiry = reader.int64().toBigInt();
          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.depositDenom !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.depositDenom);
    if (message.insurancePoolTokenDenom !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.insurancePoolTokenDenom);
    if (message.redemptionNoticePeriodDuration)
      Duration.internalBinaryWrite(message.redemptionNoticePeriodDuration, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
    if (message.balance !== "")
      writer.tag(4, WireType.LengthDelimited).string(message.balance);
    if (message.totalShare !== "")
      writer.tag(5, WireType.LengthDelimited).string(message.totalShare);
    if (message.marketId !== "")
      writer.tag(6, WireType.LengthDelimited).string(message.marketId);
    if (message.marketTicker !== "")
      writer.tag(7, WireType.LengthDelimited).string(message.marketTicker);
    if (message.oracleBase !== "")
      writer.tag(8, WireType.LengthDelimited).string(message.oracleBase);
    if (message.oracleQuote !== "")
      writer.tag(9, WireType.LengthDelimited).string(message.oracleQuote);
    if (message.oracleType !== 0)
      writer.tag(10, WireType.Varint).int32(message.oracleType);
    if (message.expiry !== 0n)
      writer.tag(11, WireType.Varint).int64(message.expiry);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const InsuranceFund = new InsuranceFund$Type();
class RedemptionSchedule$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.RedemptionSchedule", [
      {
        no: 1,
        name: "id",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      {
        no: 2,
        name: "marketId",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 3,
        name: "redeemer",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 4, name: "claimable_redemption_time", kind: "message", T: () => Timestamp, options: { "gogoproto.nullable": false, "gogoproto.moretags": 'yaml:"claimable_redemption_time"', "gogoproto.stdtime": true } },
      { no: 5, name: "redemption_amount", kind: "message", T: () => Coin, options: { "gogoproto.nullable": false } }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.id = 0n;
    message.marketId = "";
    message.redeemer = "";
    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 /* uint64 id */
        1:
          message.id = reader.uint64().toBigInt();
          break;
        case /* string marketId */
        2:
          message.marketId = reader.string();
          break;
        case /* string redeemer */
        3:
          message.redeemer = reader.string();
          break;
        case /* google.protobuf.Timestamp claimable_redemption_time */
        4:
          message.claimableRedemptionTime = Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.claimableRedemptionTime);
          break;
        case /* cosmos.base.v1beta1.Coin redemption_amount */
        5:
          message.redemptionAmount = Coin.internalBinaryRead(reader, reader.uint32(), options, message.redemptionAmount);
          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.id !== 0n)
      writer.tag(1, WireType.Varint).uint64(message.id);
    if (message.marketId !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.marketId);
    if (message.redeemer !== "")
      writer.tag(3, WireType.LengthDelimited).string(message.redeemer);
    if (message.claimableRedemptionTime)
      Timestamp.internalBinaryWrite(message.claimableRedemptionTime, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
    if (message.redemptionAmount)
      Coin.internalBinaryWrite(message.redemptionAmount, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const RedemptionSchedule = new RedemptionSchedule$Type();
class FailedRedemptionSchedule$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.FailedRedemptionSchedule", [
      {
        no: 1,
        name: "id",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      { no: 2, name: "schedule", kind: "message", T: () => RedemptionSchedule, options: { "gogoproto.nullable": false } },
      {
        no: 3,
        name: "err",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.id = 0n;
    message.err = "";
    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 /* uint64 id */
        1:
          message.id = reader.uint64().toBigInt();
          break;
        case /* injective.insurance.v1beta1.RedemptionSchedule schedule */
        2:
          message.schedule = RedemptionSchedule.internalBinaryRead(reader, reader.uint32(), options, message.schedule);
          break;
        case /* string err */
        3:
          message.err = reader.string();
          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.id !== 0n)
      writer.tag(1, WireType.Varint).uint64(message.id);
    if (message.schedule)
      RedemptionSchedule.internalBinaryWrite(message.schedule, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
    if (message.err !== "")
      writer.tag(3, WireType.LengthDelimited).string(message.err);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const FailedRedemptionSchedule = new FailedRedemptionSchedule$Type();
export {
  FailedRedemptionSchedule,
  InsuranceFund,
  Params,
  RedemptionSchedule
};
