// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.2.0
//   protoc               v6.33.4
// source: org/apache/texera/amber/core/virtualidentity.proto

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

export const protobufPackage = "org.apache.texera.amber.core";

export interface WorkflowIdentity {
  id: number;
}

export interface ExecutionIdentity {
  id: number;
}

export interface ActorVirtualIdentity {
  name: string;
}

export interface ChannelIdentity {
  fromWorkerId: ActorVirtualIdentity | undefined;
  toWorkerId: ActorVirtualIdentity | undefined;
  isControl: boolean;
}

export interface OperatorIdentity {
  id: string;
}

export interface PhysicalOpIdentity {
  logicalOpId: OperatorIdentity | undefined;
  layerName: string;
}

export interface EmbeddedControlMessageIdentity {
  id: string;
}

function createBaseWorkflowIdentity(): WorkflowIdentity {
  return { id: 0 };
}

export const WorkflowIdentity: MessageFns<WorkflowIdentity> = {
  encode(message: WorkflowIdentity, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.id !== 0) {
      writer.uint32(8).int64(message.id);
    }
    return writer;
  },

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

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

  fromJSON(object: any): WorkflowIdentity {
    return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 };
  },

  toJSON(message: WorkflowIdentity): unknown {
    const obj: any = {};
    if (message.id !== 0) {
      obj.id = Math.round(message.id);
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<WorkflowIdentity>, I>>(base?: I): WorkflowIdentity {
    return WorkflowIdentity.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<WorkflowIdentity>, I>>(object: I): WorkflowIdentity {
    const message = createBaseWorkflowIdentity();
    message.id = object.id ?? 0;
    return message;
  },
};

function createBaseExecutionIdentity(): ExecutionIdentity {
  return { id: 0 };
}

export const ExecutionIdentity: MessageFns<ExecutionIdentity> = {
  encode(message: ExecutionIdentity, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.id !== 0) {
      writer.uint32(8).int64(message.id);
    }
    return writer;
  },

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

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

  fromJSON(object: any): ExecutionIdentity {
    return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 };
  },

  toJSON(message: ExecutionIdentity): unknown {
    const obj: any = {};
    if (message.id !== 0) {
      obj.id = Math.round(message.id);
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<ExecutionIdentity>, I>>(base?: I): ExecutionIdentity {
    return ExecutionIdentity.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<ExecutionIdentity>, I>>(object: I): ExecutionIdentity {
    const message = createBaseExecutionIdentity();
    message.id = object.id ?? 0;
    return message;
  },
};

function createBaseActorVirtualIdentity(): ActorVirtualIdentity {
  return { name: "" };
}

export const ActorVirtualIdentity: MessageFns<ActorVirtualIdentity> = {
  encode(message: ActorVirtualIdentity, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    return writer;
  },

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

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

  fromJSON(object: any): ActorVirtualIdentity {
    return { name: isSet(object.name) ? globalThis.String(object.name) : "" };
  },

  toJSON(message: ActorVirtualIdentity): unknown {
    const obj: any = {};
    if (message.name !== "") {
      obj.name = message.name;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<ActorVirtualIdentity>, I>>(base?: I): ActorVirtualIdentity {
    return ActorVirtualIdentity.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<ActorVirtualIdentity>, I>>(object: I): ActorVirtualIdentity {
    const message = createBaseActorVirtualIdentity();
    message.name = object.name ?? "";
    return message;
  },
};

function createBaseChannelIdentity(): ChannelIdentity {
  return { fromWorkerId: undefined, toWorkerId: undefined, isControl: false };
}

export const ChannelIdentity: MessageFns<ChannelIdentity> = {
  encode(message: ChannelIdentity, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.fromWorkerId !== undefined) {
      ActorVirtualIdentity.encode(message.fromWorkerId, writer.uint32(10).fork()).join();
    }
    if (message.toWorkerId !== undefined) {
      ActorVirtualIdentity.encode(message.toWorkerId, writer.uint32(18).fork()).join();
    }
    if (message.isControl !== false) {
      writer.uint32(24).bool(message.isControl);
    }
    return writer;
  },

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

          message.fromWorkerId = ActorVirtualIdentity.decode(reader, reader.uint32());
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.toWorkerId = ActorVirtualIdentity.decode(reader, reader.uint32());
          continue;
        case 3:
          if (tag !== 24) {
            break;
          }

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

  fromJSON(object: any): ChannelIdentity {
    return {
      fromWorkerId: isSet(object.fromWorkerId) ? ActorVirtualIdentity.fromJSON(object.fromWorkerId) : undefined,
      toWorkerId: isSet(object.toWorkerId) ? ActorVirtualIdentity.fromJSON(object.toWorkerId) : undefined,
      isControl: isSet(object.isControl) ? globalThis.Boolean(object.isControl) : false,
    };
  },

  toJSON(message: ChannelIdentity): unknown {
    const obj: any = {};
    if (message.fromWorkerId !== undefined) {
      obj.fromWorkerId = ActorVirtualIdentity.toJSON(message.fromWorkerId);
    }
    if (message.toWorkerId !== undefined) {
      obj.toWorkerId = ActorVirtualIdentity.toJSON(message.toWorkerId);
    }
    if (message.isControl !== false) {
      obj.isControl = message.isControl;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<ChannelIdentity>, I>>(base?: I): ChannelIdentity {
    return ChannelIdentity.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<ChannelIdentity>, I>>(object: I): ChannelIdentity {
    const message = createBaseChannelIdentity();
    message.fromWorkerId = (object.fromWorkerId !== undefined && object.fromWorkerId !== null)
      ? ActorVirtualIdentity.fromPartial(object.fromWorkerId)
      : undefined;
    message.toWorkerId = (object.toWorkerId !== undefined && object.toWorkerId !== null)
      ? ActorVirtualIdentity.fromPartial(object.toWorkerId)
      : undefined;
    message.isControl = object.isControl ?? false;
    return message;
  },
};

function createBaseOperatorIdentity(): OperatorIdentity {
  return { id: "" };
}

export const OperatorIdentity: MessageFns<OperatorIdentity> = {
  encode(message: OperatorIdentity, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.id !== "") {
      writer.uint32(10).string(message.id);
    }
    return writer;
  },

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

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

  fromJSON(object: any): OperatorIdentity {
    return { id: isSet(object.id) ? globalThis.String(object.id) : "" };
  },

  toJSON(message: OperatorIdentity): unknown {
    const obj: any = {};
    if (message.id !== "") {
      obj.id = message.id;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<OperatorIdentity>, I>>(base?: I): OperatorIdentity {
    return OperatorIdentity.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<OperatorIdentity>, I>>(object: I): OperatorIdentity {
    const message = createBaseOperatorIdentity();
    message.id = object.id ?? "";
    return message;
  },
};

function createBasePhysicalOpIdentity(): PhysicalOpIdentity {
  return { logicalOpId: undefined, layerName: "" };
}

export const PhysicalOpIdentity: MessageFns<PhysicalOpIdentity> = {
  encode(message: PhysicalOpIdentity, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.logicalOpId !== undefined) {
      OperatorIdentity.encode(message.logicalOpId, writer.uint32(10).fork()).join();
    }
    if (message.layerName !== "") {
      writer.uint32(18).string(message.layerName);
    }
    return writer;
  },

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

          message.logicalOpId = OperatorIdentity.decode(reader, reader.uint32());
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }

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

  fromJSON(object: any): PhysicalOpIdentity {
    return {
      logicalOpId: isSet(object.logicalOpId) ? OperatorIdentity.fromJSON(object.logicalOpId) : undefined,
      layerName: isSet(object.layerName) ? globalThis.String(object.layerName) : "",
    };
  },

  toJSON(message: PhysicalOpIdentity): unknown {
    const obj: any = {};
    if (message.logicalOpId !== undefined) {
      obj.logicalOpId = OperatorIdentity.toJSON(message.logicalOpId);
    }
    if (message.layerName !== "") {
      obj.layerName = message.layerName;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<PhysicalOpIdentity>, I>>(base?: I): PhysicalOpIdentity {
    return PhysicalOpIdentity.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<PhysicalOpIdentity>, I>>(object: I): PhysicalOpIdentity {
    const message = createBasePhysicalOpIdentity();
    message.logicalOpId = (object.logicalOpId !== undefined && object.logicalOpId !== null)
      ? OperatorIdentity.fromPartial(object.logicalOpId)
      : undefined;
    message.layerName = object.layerName ?? "";
    return message;
  },
};

function createBaseEmbeddedControlMessageIdentity(): EmbeddedControlMessageIdentity {
  return { id: "" };
}

export const EmbeddedControlMessageIdentity: MessageFns<EmbeddedControlMessageIdentity> = {
  encode(message: EmbeddedControlMessageIdentity, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.id !== "") {
      writer.uint32(10).string(message.id);
    }
    return writer;
  },

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

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

  fromJSON(object: any): EmbeddedControlMessageIdentity {
    return { id: isSet(object.id) ? globalThis.String(object.id) : "" };
  },

  toJSON(message: EmbeddedControlMessageIdentity): unknown {
    const obj: any = {};
    if (message.id !== "") {
      obj.id = message.id;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<EmbeddedControlMessageIdentity>, I>>(base?: I): EmbeddedControlMessageIdentity {
    return EmbeddedControlMessageIdentity.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<EmbeddedControlMessageIdentity>, I>>(
    object: I,
  ): EmbeddedControlMessageIdentity {
    const message = createBaseEmbeddedControlMessageIdentity();
    message.id = object.id ?? "";
    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>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin ? P
  : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

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<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
  fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
}
