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

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

export const protobufPackage = "protobuf";

export interface Execution {
  orderId?: number | undefined;
  execId?: string | undefined;
  time?: string | undefined;
  acctNumber?: string | undefined;
  exchange?: string | undefined;
  side?: string | undefined;
  shares?: string | undefined;
  price?: number | undefined;
  permId?: number | undefined;
  clientId?: number | undefined;
  isLiquidation?: boolean | undefined;
  cumQty?: string | undefined;
  avgPrice?: number | undefined;
  orderRef?: string | undefined;
  evRule?: string | undefined;
  evMultiplier?: number | undefined;
  modelCode?: string | undefined;
  lastLiquidity?: number | undefined;
  isPriceRevisionPending?: boolean | undefined;
  submitter?: string | undefined;
  optExerciseOrLapseType?: number | undefined;
}

function createBaseExecution(): Execution {
  return {
    orderId: undefined,
    execId: undefined,
    time: undefined,
    acctNumber: undefined,
    exchange: undefined,
    side: undefined,
    shares: undefined,
    price: undefined,
    permId: undefined,
    clientId: undefined,
    isLiquidation: undefined,
    cumQty: undefined,
    avgPrice: undefined,
    orderRef: undefined,
    evRule: undefined,
    evMultiplier: undefined,
    modelCode: undefined,
    lastLiquidity: undefined,
    isPriceRevisionPending: undefined,
    submitter: undefined,
    optExerciseOrLapseType: undefined,
  };
}

export const Execution: MessageFns<Execution> = {
  encode(message: Execution, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.orderId !== undefined) {
      writer.uint32(8).int32(message.orderId);
    }
    if (message.execId !== undefined) {
      writer.uint32(18).string(message.execId);
    }
    if (message.time !== undefined) {
      writer.uint32(26).string(message.time);
    }
    if (message.acctNumber !== undefined) {
      writer.uint32(34).string(message.acctNumber);
    }
    if (message.exchange !== undefined) {
      writer.uint32(42).string(message.exchange);
    }
    if (message.side !== undefined) {
      writer.uint32(50).string(message.side);
    }
    if (message.shares !== undefined) {
      writer.uint32(58).string(message.shares);
    }
    if (message.price !== undefined) {
      writer.uint32(65).double(message.price);
    }
    if (message.permId !== undefined) {
      writer.uint32(72).int64(message.permId);
    }
    if (message.clientId !== undefined) {
      writer.uint32(80).int32(message.clientId);
    }
    if (message.isLiquidation !== undefined) {
      writer.uint32(88).bool(message.isLiquidation);
    }
    if (message.cumQty !== undefined) {
      writer.uint32(98).string(message.cumQty);
    }
    if (message.avgPrice !== undefined) {
      writer.uint32(105).double(message.avgPrice);
    }
    if (message.orderRef !== undefined) {
      writer.uint32(114).string(message.orderRef);
    }
    if (message.evRule !== undefined) {
      writer.uint32(122).string(message.evRule);
    }
    if (message.evMultiplier !== undefined) {
      writer.uint32(129).double(message.evMultiplier);
    }
    if (message.modelCode !== undefined) {
      writer.uint32(138).string(message.modelCode);
    }
    if (message.lastLiquidity !== undefined) {
      writer.uint32(144).int32(message.lastLiquidity);
    }
    if (message.isPriceRevisionPending !== undefined) {
      writer.uint32(152).bool(message.isPriceRevisionPending);
    }
    if (message.submitter !== undefined) {
      writer.uint32(162).string(message.submitter);
    }
    if (message.optExerciseOrLapseType !== undefined) {
      writer.uint32(168).int32(message.optExerciseOrLapseType);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): Execution {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseExecution();
    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.execId = reader.string();
          continue;
        }
        case 3: {
          if (tag !== 26) {
            break;
          }

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

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

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

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

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

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

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

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

          message.isLiquidation = reader.bool();
          continue;
        }
        case 12: {
          if (tag !== 98) {
            break;
          }

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

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

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

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

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

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

          message.lastLiquidity = reader.int32();
          continue;
        }
        case 19: {
          if (tag !== 152) {
            break;
          }

          message.isPriceRevisionPending = reader.bool();
          continue;
        }
        case 20: {
          if (tag !== 162) {
            break;
          }

          message.submitter = reader.string();
          continue;
        }
        case 21: {
          if (tag !== 168) {
            break;
          }

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

  fromJSON(object: any): Execution {
    return {
      orderId: isSet(object.orderId) ? globalThis.Number(object.orderId) : undefined,
      execId: isSet(object.execId) ? globalThis.String(object.execId) : undefined,
      time: isSet(object.time) ? globalThis.String(object.time) : undefined,
      acctNumber: isSet(object.acctNumber) ? globalThis.String(object.acctNumber) : undefined,
      exchange: isSet(object.exchange) ? globalThis.String(object.exchange) : undefined,
      side: isSet(object.side) ? globalThis.String(object.side) : undefined,
      shares: isSet(object.shares) ? globalThis.String(object.shares) : undefined,
      price: isSet(object.price) ? globalThis.Number(object.price) : undefined,
      permId: isSet(object.permId) ? globalThis.Number(object.permId) : undefined,
      clientId: isSet(object.clientId) ? globalThis.Number(object.clientId) : undefined,
      isLiquidation: isSet(object.isLiquidation) ? globalThis.Boolean(object.isLiquidation) : undefined,
      cumQty: isSet(object.cumQty) ? globalThis.String(object.cumQty) : undefined,
      avgPrice: isSet(object.avgPrice) ? globalThis.Number(object.avgPrice) : undefined,
      orderRef: isSet(object.orderRef) ? globalThis.String(object.orderRef) : undefined,
      evRule: isSet(object.evRule) ? globalThis.String(object.evRule) : undefined,
      evMultiplier: isSet(object.evMultiplier) ? globalThis.Number(object.evMultiplier) : undefined,
      modelCode: isSet(object.modelCode) ? globalThis.String(object.modelCode) : undefined,
      lastLiquidity: isSet(object.lastLiquidity) ? globalThis.Number(object.lastLiquidity) : undefined,
      isPriceRevisionPending: isSet(object.isPriceRevisionPending)
        ? globalThis.Boolean(object.isPriceRevisionPending)
        : undefined,
      submitter: isSet(object.submitter) ? globalThis.String(object.submitter) : undefined,
      optExerciseOrLapseType: isSet(object.optExerciseOrLapseType)
        ? globalThis.Number(object.optExerciseOrLapseType)
        : undefined,
    };
  },

  toJSON(message: Execution): unknown {
    const obj: any = {};
    if (message.orderId !== undefined) {
      obj.orderId = Math.round(message.orderId);
    }
    if (message.execId !== undefined) {
      obj.execId = message.execId;
    }
    if (message.time !== undefined) {
      obj.time = message.time;
    }
    if (message.acctNumber !== undefined) {
      obj.acctNumber = message.acctNumber;
    }
    if (message.exchange !== undefined) {
      obj.exchange = message.exchange;
    }
    if (message.side !== undefined) {
      obj.side = message.side;
    }
    if (message.shares !== undefined) {
      obj.shares = message.shares;
    }
    if (message.price !== undefined) {
      obj.price = message.price;
    }
    if (message.permId !== undefined) {
      obj.permId = Math.round(message.permId);
    }
    if (message.clientId !== undefined) {
      obj.clientId = Math.round(message.clientId);
    }
    if (message.isLiquidation !== undefined) {
      obj.isLiquidation = message.isLiquidation;
    }
    if (message.cumQty !== undefined) {
      obj.cumQty = message.cumQty;
    }
    if (message.avgPrice !== undefined) {
      obj.avgPrice = message.avgPrice;
    }
    if (message.orderRef !== undefined) {
      obj.orderRef = message.orderRef;
    }
    if (message.evRule !== undefined) {
      obj.evRule = message.evRule;
    }
    if (message.evMultiplier !== undefined) {
      obj.evMultiplier = message.evMultiplier;
    }
    if (message.modelCode !== undefined) {
      obj.modelCode = message.modelCode;
    }
    if (message.lastLiquidity !== undefined) {
      obj.lastLiquidity = Math.round(message.lastLiquidity);
    }
    if (message.isPriceRevisionPending !== undefined) {
      obj.isPriceRevisionPending = message.isPriceRevisionPending;
    }
    if (message.submitter !== undefined) {
      obj.submitter = message.submitter;
    }
    if (message.optExerciseOrLapseType !== undefined) {
      obj.optExerciseOrLapseType = Math.round(message.optExerciseOrLapseType);
    }
    return obj;
  },

  create(base?: DeepPartial<Execution>): Execution {
    return Execution.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<Execution>): Execution {
    const message = createBaseExecution();
    message.orderId = object.orderId ?? undefined;
    message.execId = object.execId ?? undefined;
    message.time = object.time ?? undefined;
    message.acctNumber = object.acctNumber ?? undefined;
    message.exchange = object.exchange ?? undefined;
    message.side = object.side ?? undefined;
    message.shares = object.shares ?? undefined;
    message.price = object.price ?? undefined;
    message.permId = object.permId ?? undefined;
    message.clientId = object.clientId ?? undefined;
    message.isLiquidation = object.isLiquidation ?? undefined;
    message.cumQty = object.cumQty ?? undefined;
    message.avgPrice = object.avgPrice ?? undefined;
    message.orderRef = object.orderRef ?? undefined;
    message.evRule = object.evRule ?? undefined;
    message.evMultiplier = object.evMultiplier ?? undefined;
    message.modelCode = object.modelCode ?? undefined;
    message.lastLiquidity = object.lastLiquidity ?? undefined;
    message.isPriceRevisionPending = object.isPriceRevisionPending ?? undefined;
    message.submitter = object.submitter ?? undefined;
    message.optExerciseOrLapseType = object.optExerciseOrLapseType ?? 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;
}
