// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.5
//   protoc               v7.34.1
// source: OrderState.proto

/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { OrderAllocation } from "./OrderAllocation.js";

export const protobufPackage = "protobuf";

export interface OrderState {
  status?: string | undefined;
  initMarginBefore?: number | undefined;
  maintMarginBefore?: number | undefined;
  equityWithLoanBefore?: number | undefined;
  initMarginChange?: number | undefined;
  maintMarginChange?: number | undefined;
  equityWithLoanChange?: number | undefined;
  initMarginAfter?: number | undefined;
  maintMarginAfter?: number | undefined;
  equityWithLoanAfter?: number | undefined;
  commissionAndFees?: number | undefined;
  minCommissionAndFees?: number | undefined;
  maxCommissionAndFees?: number | undefined;
  commissionAndFeesCurrency?: string | undefined;
  marginCurrency?: string | undefined;
  initMarginBeforeOutsideRTH?: number | undefined;
  maintMarginBeforeOutsideRTH?: number | undefined;
  equityWithLoanBeforeOutsideRTH?: number | undefined;
  initMarginChangeOutsideRTH?: number | undefined;
  maintMarginChangeOutsideRTH?: number | undefined;
  equityWithLoanChangeOutsideRTH?: number | undefined;
  initMarginAfterOutsideRTH?: number | undefined;
  maintMarginAfterOutsideRTH?: number | undefined;
  equityWithLoanAfterOutsideRTH?: number | undefined;
  suggestedSize?: string | undefined;
  rejectReason?: string | undefined;
  orderAllocations: OrderAllocation[];
  warningText?: string | undefined;
  completedTime?: string | undefined;
  completedStatus?: string | undefined;
}

function createBaseOrderState(): OrderState {
  return {
    status: undefined,
    initMarginBefore: undefined,
    maintMarginBefore: undefined,
    equityWithLoanBefore: undefined,
    initMarginChange: undefined,
    maintMarginChange: undefined,
    equityWithLoanChange: undefined,
    initMarginAfter: undefined,
    maintMarginAfter: undefined,
    equityWithLoanAfter: undefined,
    commissionAndFees: undefined,
    minCommissionAndFees: undefined,
    maxCommissionAndFees: undefined,
    commissionAndFeesCurrency: undefined,
    marginCurrency: undefined,
    initMarginBeforeOutsideRTH: undefined,
    maintMarginBeforeOutsideRTH: undefined,
    equityWithLoanBeforeOutsideRTH: undefined,
    initMarginChangeOutsideRTH: undefined,
    maintMarginChangeOutsideRTH: undefined,
    equityWithLoanChangeOutsideRTH: undefined,
    initMarginAfterOutsideRTH: undefined,
    maintMarginAfterOutsideRTH: undefined,
    equityWithLoanAfterOutsideRTH: undefined,
    suggestedSize: undefined,
    rejectReason: undefined,
    orderAllocations: [],
    warningText: undefined,
    completedTime: undefined,
    completedStatus: undefined,
  };
}

export const OrderState: MessageFns<OrderState> = {
  encode(message: OrderState, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.status !== undefined) {
      writer.uint32(10).string(message.status);
    }
    if (message.initMarginBefore !== undefined) {
      writer.uint32(17).double(message.initMarginBefore);
    }
    if (message.maintMarginBefore !== undefined) {
      writer.uint32(25).double(message.maintMarginBefore);
    }
    if (message.equityWithLoanBefore !== undefined) {
      writer.uint32(33).double(message.equityWithLoanBefore);
    }
    if (message.initMarginChange !== undefined) {
      writer.uint32(41).double(message.initMarginChange);
    }
    if (message.maintMarginChange !== undefined) {
      writer.uint32(49).double(message.maintMarginChange);
    }
    if (message.equityWithLoanChange !== undefined) {
      writer.uint32(57).double(message.equityWithLoanChange);
    }
    if (message.initMarginAfter !== undefined) {
      writer.uint32(65).double(message.initMarginAfter);
    }
    if (message.maintMarginAfter !== undefined) {
      writer.uint32(73).double(message.maintMarginAfter);
    }
    if (message.equityWithLoanAfter !== undefined) {
      writer.uint32(81).double(message.equityWithLoanAfter);
    }
    if (message.commissionAndFees !== undefined) {
      writer.uint32(89).double(message.commissionAndFees);
    }
    if (message.minCommissionAndFees !== undefined) {
      writer.uint32(97).double(message.minCommissionAndFees);
    }
    if (message.maxCommissionAndFees !== undefined) {
      writer.uint32(105).double(message.maxCommissionAndFees);
    }
    if (message.commissionAndFeesCurrency !== undefined) {
      writer.uint32(114).string(message.commissionAndFeesCurrency);
    }
    if (message.marginCurrency !== undefined) {
      writer.uint32(122).string(message.marginCurrency);
    }
    if (message.initMarginBeforeOutsideRTH !== undefined) {
      writer.uint32(129).double(message.initMarginBeforeOutsideRTH);
    }
    if (message.maintMarginBeforeOutsideRTH !== undefined) {
      writer.uint32(137).double(message.maintMarginBeforeOutsideRTH);
    }
    if (message.equityWithLoanBeforeOutsideRTH !== undefined) {
      writer.uint32(145).double(message.equityWithLoanBeforeOutsideRTH);
    }
    if (message.initMarginChangeOutsideRTH !== undefined) {
      writer.uint32(153).double(message.initMarginChangeOutsideRTH);
    }
    if (message.maintMarginChangeOutsideRTH !== undefined) {
      writer.uint32(161).double(message.maintMarginChangeOutsideRTH);
    }
    if (message.equityWithLoanChangeOutsideRTH !== undefined) {
      writer.uint32(169).double(message.equityWithLoanChangeOutsideRTH);
    }
    if (message.initMarginAfterOutsideRTH !== undefined) {
      writer.uint32(177).double(message.initMarginAfterOutsideRTH);
    }
    if (message.maintMarginAfterOutsideRTH !== undefined) {
      writer.uint32(185).double(message.maintMarginAfterOutsideRTH);
    }
    if (message.equityWithLoanAfterOutsideRTH !== undefined) {
      writer.uint32(193).double(message.equityWithLoanAfterOutsideRTH);
    }
    if (message.suggestedSize !== undefined) {
      writer.uint32(202).string(message.suggestedSize);
    }
    if (message.rejectReason !== undefined) {
      writer.uint32(210).string(message.rejectReason);
    }
    for (const v of message.orderAllocations) {
      OrderAllocation.encode(v!, writer.uint32(218).fork()).join();
    }
    if (message.warningText !== undefined) {
      writer.uint32(226).string(message.warningText);
    }
    if (message.completedTime !== undefined) {
      writer.uint32(234).string(message.completedTime);
    }
    if (message.completedStatus !== undefined) {
      writer.uint32(242).string(message.completedStatus);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): OrderState {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseOrderState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.status = reader.string();
          continue;
        }
        case 2: {
          if (tag !== 17) {
            break;
          }

          message.initMarginBefore = reader.double();
          continue;
        }
        case 3: {
          if (tag !== 25) {
            break;
          }

          message.maintMarginBefore = reader.double();
          continue;
        }
        case 4: {
          if (tag !== 33) {
            break;
          }

          message.equityWithLoanBefore = reader.double();
          continue;
        }
        case 5: {
          if (tag !== 41) {
            break;
          }

          message.initMarginChange = reader.double();
          continue;
        }
        case 6: {
          if (tag !== 49) {
            break;
          }

          message.maintMarginChange = reader.double();
          continue;
        }
        case 7: {
          if (tag !== 57) {
            break;
          }

          message.equityWithLoanChange = reader.double();
          continue;
        }
        case 8: {
          if (tag !== 65) {
            break;
          }

          message.initMarginAfter = reader.double();
          continue;
        }
        case 9: {
          if (tag !== 73) {
            break;
          }

          message.maintMarginAfter = reader.double();
          continue;
        }
        case 10: {
          if (tag !== 81) {
            break;
          }

          message.equityWithLoanAfter = reader.double();
          continue;
        }
        case 11: {
          if (tag !== 89) {
            break;
          }

          message.commissionAndFees = reader.double();
          continue;
        }
        case 12: {
          if (tag !== 97) {
            break;
          }

          message.minCommissionAndFees = reader.double();
          continue;
        }
        case 13: {
          if (tag !== 105) {
            break;
          }

          message.maxCommissionAndFees = reader.double();
          continue;
        }
        case 14: {
          if (tag !== 114) {
            break;
          }

          message.commissionAndFeesCurrency = reader.string();
          continue;
        }
        case 15: {
          if (tag !== 122) {
            break;
          }

          message.marginCurrency = reader.string();
          continue;
        }
        case 16: {
          if (tag !== 129) {
            break;
          }

          message.initMarginBeforeOutsideRTH = reader.double();
          continue;
        }
        case 17: {
          if (tag !== 137) {
            break;
          }

          message.maintMarginBeforeOutsideRTH = reader.double();
          continue;
        }
        case 18: {
          if (tag !== 145) {
            break;
          }

          message.equityWithLoanBeforeOutsideRTH = reader.double();
          continue;
        }
        case 19: {
          if (tag !== 153) {
            break;
          }

          message.initMarginChangeOutsideRTH = reader.double();
          continue;
        }
        case 20: {
          if (tag !== 161) {
            break;
          }

          message.maintMarginChangeOutsideRTH = reader.double();
          continue;
        }
        case 21: {
          if (tag !== 169) {
            break;
          }

          message.equityWithLoanChangeOutsideRTH = reader.double();
          continue;
        }
        case 22: {
          if (tag !== 177) {
            break;
          }

          message.initMarginAfterOutsideRTH = reader.double();
          continue;
        }
        case 23: {
          if (tag !== 185) {
            break;
          }

          message.maintMarginAfterOutsideRTH = reader.double();
          continue;
        }
        case 24: {
          if (tag !== 193) {
            break;
          }

          message.equityWithLoanAfterOutsideRTH = reader.double();
          continue;
        }
        case 25: {
          if (tag !== 202) {
            break;
          }

          message.suggestedSize = reader.string();
          continue;
        }
        case 26: {
          if (tag !== 210) {
            break;
          }

          message.rejectReason = reader.string();
          continue;
        }
        case 27: {
          if (tag !== 218) {
            break;
          }

          message.orderAllocations.push(OrderAllocation.decode(reader, reader.uint32()));
          continue;
        }
        case 28: {
          if (tag !== 226) {
            break;
          }

          message.warningText = reader.string();
          continue;
        }
        case 29: {
          if (tag !== 234) {
            break;
          }

          message.completedTime = reader.string();
          continue;
        }
        case 30: {
          if (tag !== 242) {
            break;
          }

          message.completedStatus = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): OrderState {
    return {
      status: isSet(object.status) ? globalThis.String(object.status) : undefined,
      initMarginBefore: isSet(object.initMarginBefore) ? globalThis.Number(object.initMarginBefore) : undefined,
      maintMarginBefore: isSet(object.maintMarginBefore) ? globalThis.Number(object.maintMarginBefore) : undefined,
      equityWithLoanBefore: isSet(object.equityWithLoanBefore)
        ? globalThis.Number(object.equityWithLoanBefore)
        : undefined,
      initMarginChange: isSet(object.initMarginChange) ? globalThis.Number(object.initMarginChange) : undefined,
      maintMarginChange: isSet(object.maintMarginChange) ? globalThis.Number(object.maintMarginChange) : undefined,
      equityWithLoanChange: isSet(object.equityWithLoanChange)
        ? globalThis.Number(object.equityWithLoanChange)
        : undefined,
      initMarginAfter: isSet(object.initMarginAfter) ? globalThis.Number(object.initMarginAfter) : undefined,
      maintMarginAfter: isSet(object.maintMarginAfter) ? globalThis.Number(object.maintMarginAfter) : undefined,
      equityWithLoanAfter: isSet(object.equityWithLoanAfter)
        ? globalThis.Number(object.equityWithLoanAfter)
        : undefined,
      commissionAndFees: isSet(object.commissionAndFees) ? globalThis.Number(object.commissionAndFees) : undefined,
      minCommissionAndFees: isSet(object.minCommissionAndFees)
        ? globalThis.Number(object.minCommissionAndFees)
        : undefined,
      maxCommissionAndFees: isSet(object.maxCommissionAndFees)
        ? globalThis.Number(object.maxCommissionAndFees)
        : undefined,
      commissionAndFeesCurrency: isSet(object.commissionAndFeesCurrency)
        ? globalThis.String(object.commissionAndFeesCurrency)
        : undefined,
      marginCurrency: isSet(object.marginCurrency) ? globalThis.String(object.marginCurrency) : undefined,
      initMarginBeforeOutsideRTH: isSet(object.initMarginBeforeOutsideRTH)
        ? globalThis.Number(object.initMarginBeforeOutsideRTH)
        : undefined,
      maintMarginBeforeOutsideRTH: isSet(object.maintMarginBeforeOutsideRTH)
        ? globalThis.Number(object.maintMarginBeforeOutsideRTH)
        : undefined,
      equityWithLoanBeforeOutsideRTH: isSet(object.equityWithLoanBeforeOutsideRTH)
        ? globalThis.Number(object.equityWithLoanBeforeOutsideRTH)
        : undefined,
      initMarginChangeOutsideRTH: isSet(object.initMarginChangeOutsideRTH)
        ? globalThis.Number(object.initMarginChangeOutsideRTH)
        : undefined,
      maintMarginChangeOutsideRTH: isSet(object.maintMarginChangeOutsideRTH)
        ? globalThis.Number(object.maintMarginChangeOutsideRTH)
        : undefined,
      equityWithLoanChangeOutsideRTH: isSet(object.equityWithLoanChangeOutsideRTH)
        ? globalThis.Number(object.equityWithLoanChangeOutsideRTH)
        : undefined,
      initMarginAfterOutsideRTH: isSet(object.initMarginAfterOutsideRTH)
        ? globalThis.Number(object.initMarginAfterOutsideRTH)
        : undefined,
      maintMarginAfterOutsideRTH: isSet(object.maintMarginAfterOutsideRTH)
        ? globalThis.Number(object.maintMarginAfterOutsideRTH)
        : undefined,
      equityWithLoanAfterOutsideRTH: isSet(object.equityWithLoanAfterOutsideRTH)
        ? globalThis.Number(object.equityWithLoanAfterOutsideRTH)
        : undefined,
      suggestedSize: isSet(object.suggestedSize) ? globalThis.String(object.suggestedSize) : undefined,
      rejectReason: isSet(object.rejectReason) ? globalThis.String(object.rejectReason) : undefined,
      orderAllocations: globalThis.Array.isArray(object?.orderAllocations)
        ? object.orderAllocations.map((e: any) => OrderAllocation.fromJSON(e))
        : [],
      warningText: isSet(object.warningText) ? globalThis.String(object.warningText) : undefined,
      completedTime: isSet(object.completedTime) ? globalThis.String(object.completedTime) : undefined,
      completedStatus: isSet(object.completedStatus) ? globalThis.String(object.completedStatus) : undefined,
    };
  },

  toJSON(message: OrderState): unknown {
    const obj: any = {};
    if (message.status !== undefined) {
      obj.status = message.status;
    }
    if (message.initMarginBefore !== undefined) {
      obj.initMarginBefore = message.initMarginBefore;
    }
    if (message.maintMarginBefore !== undefined) {
      obj.maintMarginBefore = message.maintMarginBefore;
    }
    if (message.equityWithLoanBefore !== undefined) {
      obj.equityWithLoanBefore = message.equityWithLoanBefore;
    }
    if (message.initMarginChange !== undefined) {
      obj.initMarginChange = message.initMarginChange;
    }
    if (message.maintMarginChange !== undefined) {
      obj.maintMarginChange = message.maintMarginChange;
    }
    if (message.equityWithLoanChange !== undefined) {
      obj.equityWithLoanChange = message.equityWithLoanChange;
    }
    if (message.initMarginAfter !== undefined) {
      obj.initMarginAfter = message.initMarginAfter;
    }
    if (message.maintMarginAfter !== undefined) {
      obj.maintMarginAfter = message.maintMarginAfter;
    }
    if (message.equityWithLoanAfter !== undefined) {
      obj.equityWithLoanAfter = message.equityWithLoanAfter;
    }
    if (message.commissionAndFees !== undefined) {
      obj.commissionAndFees = message.commissionAndFees;
    }
    if (message.minCommissionAndFees !== undefined) {
      obj.minCommissionAndFees = message.minCommissionAndFees;
    }
    if (message.maxCommissionAndFees !== undefined) {
      obj.maxCommissionAndFees = message.maxCommissionAndFees;
    }
    if (message.commissionAndFeesCurrency !== undefined) {
      obj.commissionAndFeesCurrency = message.commissionAndFeesCurrency;
    }
    if (message.marginCurrency !== undefined) {
      obj.marginCurrency = message.marginCurrency;
    }
    if (message.initMarginBeforeOutsideRTH !== undefined) {
      obj.initMarginBeforeOutsideRTH = message.initMarginBeforeOutsideRTH;
    }
    if (message.maintMarginBeforeOutsideRTH !== undefined) {
      obj.maintMarginBeforeOutsideRTH = message.maintMarginBeforeOutsideRTH;
    }
    if (message.equityWithLoanBeforeOutsideRTH !== undefined) {
      obj.equityWithLoanBeforeOutsideRTH = message.equityWithLoanBeforeOutsideRTH;
    }
    if (message.initMarginChangeOutsideRTH !== undefined) {
      obj.initMarginChangeOutsideRTH = message.initMarginChangeOutsideRTH;
    }
    if (message.maintMarginChangeOutsideRTH !== undefined) {
      obj.maintMarginChangeOutsideRTH = message.maintMarginChangeOutsideRTH;
    }
    if (message.equityWithLoanChangeOutsideRTH !== undefined) {
      obj.equityWithLoanChangeOutsideRTH = message.equityWithLoanChangeOutsideRTH;
    }
    if (message.initMarginAfterOutsideRTH !== undefined) {
      obj.initMarginAfterOutsideRTH = message.initMarginAfterOutsideRTH;
    }
    if (message.maintMarginAfterOutsideRTH !== undefined) {
      obj.maintMarginAfterOutsideRTH = message.maintMarginAfterOutsideRTH;
    }
    if (message.equityWithLoanAfterOutsideRTH !== undefined) {
      obj.equityWithLoanAfterOutsideRTH = message.equityWithLoanAfterOutsideRTH;
    }
    if (message.suggestedSize !== undefined) {
      obj.suggestedSize = message.suggestedSize;
    }
    if (message.rejectReason !== undefined) {
      obj.rejectReason = message.rejectReason;
    }
    if (message.orderAllocations?.length) {
      obj.orderAllocations = message.orderAllocations.map((e) => OrderAllocation.toJSON(e));
    }
    if (message.warningText !== undefined) {
      obj.warningText = message.warningText;
    }
    if (message.completedTime !== undefined) {
      obj.completedTime = message.completedTime;
    }
    if (message.completedStatus !== undefined) {
      obj.completedStatus = message.completedStatus;
    }
    return obj;
  },

  create(base?: DeepPartial<OrderState>): OrderState {
    return OrderState.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<OrderState>): OrderState {
    const message = createBaseOrderState();
    message.status = object.status ?? undefined;
    message.initMarginBefore = object.initMarginBefore ?? undefined;
    message.maintMarginBefore = object.maintMarginBefore ?? undefined;
    message.equityWithLoanBefore = object.equityWithLoanBefore ?? undefined;
    message.initMarginChange = object.initMarginChange ?? undefined;
    message.maintMarginChange = object.maintMarginChange ?? undefined;
    message.equityWithLoanChange = object.equityWithLoanChange ?? undefined;
    message.initMarginAfter = object.initMarginAfter ?? undefined;
    message.maintMarginAfter = object.maintMarginAfter ?? undefined;
    message.equityWithLoanAfter = object.equityWithLoanAfter ?? undefined;
    message.commissionAndFees = object.commissionAndFees ?? undefined;
    message.minCommissionAndFees = object.minCommissionAndFees ?? undefined;
    message.maxCommissionAndFees = object.maxCommissionAndFees ?? undefined;
    message.commissionAndFeesCurrency = object.commissionAndFeesCurrency ?? undefined;
    message.marginCurrency = object.marginCurrency ?? undefined;
    message.initMarginBeforeOutsideRTH = object.initMarginBeforeOutsideRTH ?? undefined;
    message.maintMarginBeforeOutsideRTH = object.maintMarginBeforeOutsideRTH ?? undefined;
    message.equityWithLoanBeforeOutsideRTH = object.equityWithLoanBeforeOutsideRTH ?? undefined;
    message.initMarginChangeOutsideRTH = object.initMarginChangeOutsideRTH ?? undefined;
    message.maintMarginChangeOutsideRTH = object.maintMarginChangeOutsideRTH ?? undefined;
    message.equityWithLoanChangeOutsideRTH = object.equityWithLoanChangeOutsideRTH ?? undefined;
    message.initMarginAfterOutsideRTH = object.initMarginAfterOutsideRTH ?? undefined;
    message.maintMarginAfterOutsideRTH = object.maintMarginAfterOutsideRTH ?? undefined;
    message.equityWithLoanAfterOutsideRTH = object.equityWithLoanAfterOutsideRTH ?? undefined;
    message.suggestedSize = object.suggestedSize ?? undefined;
    message.rejectReason = object.rejectReason ?? undefined;
    message.orderAllocations = object.orderAllocations?.map((e) => OrderAllocation.fromPartial(e)) || [];
    message.warningText = object.warningText ?? undefined;
    message.completedTime = object.completedTime ?? undefined;
    message.completedStatus = object.completedStatus ?? undefined;
    return message;
  },
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin ? T
  : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
  : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;

function isSet(value: any): boolean {
  return value !== null && value !== undefined;
}

export interface MessageFns<T> {
  encode(message: T, writer?: BinaryWriter): BinaryWriter;
  decode(input: BinaryReader | Uint8Array, length?: number): T;
  fromJSON(object: any): T;
  toJSON(message: T): unknown;
  create(base?: DeepPartial<T>): T;
  fromPartial(object: DeepPartial<T>): T;
}
