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

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

export const protobufPackage = "protobuf";

export interface OrderStatus {
  orderId?: number | undefined;
  status?: string | undefined;
  filled?: string | undefined;
  remaining?: string | undefined;
  avgFillPrice?: number | undefined;
  permId?: number | undefined;
  parentId?: number | undefined;
  lastFillPrice?: number | undefined;
  clientId?: number | undefined;
  whyHeld?: string | undefined;
  mktCapPrice?: number | undefined;
}

function createBaseOrderStatus(): OrderStatus {
  return {
    orderId: undefined,
    status: undefined,
    filled: undefined,
    remaining: undefined,
    avgFillPrice: undefined,
    permId: undefined,
    parentId: undefined,
    lastFillPrice: undefined,
    clientId: undefined,
    whyHeld: undefined,
    mktCapPrice: undefined,
  };
}

export const OrderStatus: MessageFns<OrderStatus> = {
  encode(message: OrderStatus, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.orderId !== undefined) {
      writer.uint32(8).int32(message.orderId);
    }
    if (message.status !== undefined) {
      writer.uint32(18).string(message.status);
    }
    if (message.filled !== undefined) {
      writer.uint32(26).string(message.filled);
    }
    if (message.remaining !== undefined) {
      writer.uint32(34).string(message.remaining);
    }
    if (message.avgFillPrice !== undefined) {
      writer.uint32(41).double(message.avgFillPrice);
    }
    if (message.permId !== undefined) {
      writer.uint32(48).int64(message.permId);
    }
    if (message.parentId !== undefined) {
      writer.uint32(56).int32(message.parentId);
    }
    if (message.lastFillPrice !== undefined) {
      writer.uint32(65).double(message.lastFillPrice);
    }
    if (message.clientId !== undefined) {
      writer.uint32(72).int32(message.clientId);
    }
    if (message.whyHeld !== undefined) {
      writer.uint32(82).string(message.whyHeld);
    }
    if (message.mktCapPrice !== undefined) {
      writer.uint32(89).double(message.mktCapPrice);
    }
    return writer;
  },

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

          message.orderId = reader.int32();
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

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

          message.filled = reader.string();
          continue;
        }
        case 4: {
          if (tag !== 34) {
            break;
          }

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

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

          message.permId = longToNumber(reader.int64());
          continue;
        }
        case 7: {
          if (tag !== 56) {
            break;
          }

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

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

          message.clientId = reader.int32();
          continue;
        }
        case 10: {
          if (tag !== 82) {
            break;
          }

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

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

  fromJSON(object: any): OrderStatus {
    return {
      orderId: isSet(object.orderId) ? globalThis.Number(object.orderId) : undefined,
      status: isSet(object.status) ? globalThis.String(object.status) : undefined,
      filled: isSet(object.filled) ? globalThis.String(object.filled) : undefined,
      remaining: isSet(object.remaining) ? globalThis.String(object.remaining) : undefined,
      avgFillPrice: isSet(object.avgFillPrice) ? globalThis.Number(object.avgFillPrice) : undefined,
      permId: isSet(object.permId) ? globalThis.Number(object.permId) : undefined,
      parentId: isSet(object.parentId) ? globalThis.Number(object.parentId) : undefined,
      lastFillPrice: isSet(object.lastFillPrice) ? globalThis.Number(object.lastFillPrice) : undefined,
      clientId: isSet(object.clientId) ? globalThis.Number(object.clientId) : undefined,
      whyHeld: isSet(object.whyHeld) ? globalThis.String(object.whyHeld) : undefined,
      mktCapPrice: isSet(object.mktCapPrice) ? globalThis.Number(object.mktCapPrice) : undefined,
    };
  },

  toJSON(message: OrderStatus): unknown {
    const obj: any = {};
    if (message.orderId !== undefined) {
      obj.orderId = Math.round(message.orderId);
    }
    if (message.status !== undefined) {
      obj.status = message.status;
    }
    if (message.filled !== undefined) {
      obj.filled = message.filled;
    }
    if (message.remaining !== undefined) {
      obj.remaining = message.remaining;
    }
    if (message.avgFillPrice !== undefined) {
      obj.avgFillPrice = message.avgFillPrice;
    }
    if (message.permId !== undefined) {
      obj.permId = Math.round(message.permId);
    }
    if (message.parentId !== undefined) {
      obj.parentId = Math.round(message.parentId);
    }
    if (message.lastFillPrice !== undefined) {
      obj.lastFillPrice = message.lastFillPrice;
    }
    if (message.clientId !== undefined) {
      obj.clientId = Math.round(message.clientId);
    }
    if (message.whyHeld !== undefined) {
      obj.whyHeld = message.whyHeld;
    }
    if (message.mktCapPrice !== undefined) {
      obj.mktCapPrice = message.mktCapPrice;
    }
    return obj;
  },

  create(base?: DeepPartial<OrderStatus>): OrderStatus {
    return OrderStatus.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<OrderStatus>): OrderStatus {
    const message = createBaseOrderStatus();
    message.orderId = object.orderId ?? undefined;
    message.status = object.status ?? undefined;
    message.filled = object.filled ?? undefined;
    message.remaining = object.remaining ?? undefined;
    message.avgFillPrice = object.avgFillPrice ?? undefined;
    message.permId = object.permId ?? undefined;
    message.parentId = object.parentId ?? undefined;
    message.lastFillPrice = object.lastFillPrice ?? undefined;
    message.clientId = object.clientId ?? undefined;
    message.whyHeld = object.whyHeld ?? undefined;
    message.mktCapPrice = object.mktCapPrice ?? 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 longToNumber(int64: { toString(): string }): number {
  const num = globalThis.Number(int64.toString());
  if (num > globalThis.Number.MAX_SAFE_INTEGER) {
    throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
  }
  if (num < globalThis.Number.MIN_SAFE_INTEGER) {
    throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
  }
  return num;
}

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;
}
