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

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

export const protobufPackage = "protobuf";

export interface OrderAllocation {
  account?: string | undefined;
  position?: string | undefined;
  positionDesired?: string | undefined;
  positionAfter?: string | undefined;
  desiredAllocQty?: string | undefined;
  allowedAllocQty?: string | undefined;
  isMonetary?: boolean | undefined;
}

function createBaseOrderAllocation(): OrderAllocation {
  return {
    account: undefined,
    position: undefined,
    positionDesired: undefined,
    positionAfter: undefined,
    desiredAllocQty: undefined,
    allowedAllocQty: undefined,
    isMonetary: undefined,
  };
}

export const OrderAllocation: MessageFns<OrderAllocation> = {
  encode(message: OrderAllocation, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.account !== undefined) {
      writer.uint32(10).string(message.account);
    }
    if (message.position !== undefined) {
      writer.uint32(18).string(message.position);
    }
    if (message.positionDesired !== undefined) {
      writer.uint32(26).string(message.positionDesired);
    }
    if (message.positionAfter !== undefined) {
      writer.uint32(34).string(message.positionAfter);
    }
    if (message.desiredAllocQty !== undefined) {
      writer.uint32(42).string(message.desiredAllocQty);
    }
    if (message.allowedAllocQty !== undefined) {
      writer.uint32(50).string(message.allowedAllocQty);
    }
    if (message.isMonetary !== undefined) {
      writer.uint32(56).bool(message.isMonetary);
    }
    return writer;
  },

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

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

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

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

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

          message.desiredAllocQty = reader.string();
          continue;
        }
        case 6: {
          if (tag !== 50) {
            break;
          }

          message.allowedAllocQty = reader.string();
          continue;
        }
        case 7: {
          if (tag !== 56) {
            break;
          }

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

  fromJSON(object: any): OrderAllocation {
    return {
      account: isSet(object.account) ? globalThis.String(object.account) : undefined,
      position: isSet(object.position) ? globalThis.String(object.position) : undefined,
      positionDesired: isSet(object.positionDesired) ? globalThis.String(object.positionDesired) : undefined,
      positionAfter: isSet(object.positionAfter) ? globalThis.String(object.positionAfter) : undefined,
      desiredAllocQty: isSet(object.desiredAllocQty) ? globalThis.String(object.desiredAllocQty) : undefined,
      allowedAllocQty: isSet(object.allowedAllocQty) ? globalThis.String(object.allowedAllocQty) : undefined,
      isMonetary: isSet(object.isMonetary) ? globalThis.Boolean(object.isMonetary) : undefined,
    };
  },

  toJSON(message: OrderAllocation): unknown {
    const obj: any = {};
    if (message.account !== undefined) {
      obj.account = message.account;
    }
    if (message.position !== undefined) {
      obj.position = message.position;
    }
    if (message.positionDesired !== undefined) {
      obj.positionDesired = message.positionDesired;
    }
    if (message.positionAfter !== undefined) {
      obj.positionAfter = message.positionAfter;
    }
    if (message.desiredAllocQty !== undefined) {
      obj.desiredAllocQty = message.desiredAllocQty;
    }
    if (message.allowedAllocQty !== undefined) {
      obj.allowedAllocQty = message.allowedAllocQty;
    }
    if (message.isMonetary !== undefined) {
      obj.isMonetary = message.isMonetary;
    }
    return obj;
  },

  create(base?: DeepPartial<OrderAllocation>): OrderAllocation {
    return OrderAllocation.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<OrderAllocation>): OrderAllocation {
    const message = createBaseOrderAllocation();
    message.account = object.account ?? undefined;
    message.position = object.position ?? undefined;
    message.positionDesired = object.positionDesired ?? undefined;
    message.positionAfter = object.positionAfter ?? undefined;
    message.desiredAllocQty = object.desiredAllocQty ?? undefined;
    message.allowedAllocQty = object.allowedAllocQty ?? undefined;
    message.isMonetary = object.isMonetary ?? 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;
}
