"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var command_completion_service_exports = {};
__export(command_completion_service_exports, {
  CommandCompletionService: () => CommandCompletionService,
  CompletionStreamRequest: () => CompletionStreamRequest,
  CompletionStreamResponse: () => CompletionStreamResponse
});
module.exports = __toCommonJS(command_completion_service_exports);
var import_runtime_rpc = require("@protobuf-ts/runtime-rpc");
var import_runtime = require("@protobuf-ts/runtime");
var import_runtime2 = require("@protobuf-ts/runtime");
var import_runtime3 = require("@protobuf-ts/runtime");
var import_runtime4 = require("@protobuf-ts/runtime");
var import_offset_checkpoint = require("./offset_checkpoint.cjs");
var import_completion = require("./completion.cjs");
class CompletionStreamRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.CompletionStreamRequest", [
      {
        no: 1,
        name: "user_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "parties",
        kind: "scalar",
        repeat: 2,
        T: 9
      },
      {
        no: 3,
        name: "begin_exclusive",
        kind: "scalar",
        T: 3,
        L: 0
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.userId = "";
    message.parties = [];
    message.beginExclusive = 0n;
    if (value !== void 0)
      (0, import_runtime3.reflectionMergePartial)(
        this,
        message,
        value
      );
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* string user_id */
        1:
          message.userId = reader.string();
          break;
        case /* repeated string parties */
        2:
          message.parties.push(reader.string());
          break;
        case /* int64 begin_exclusive */
        3:
          message.beginExclusive = reader.int64().toBigInt();
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.userId !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.userId);
    for (let i = 0; i < message.parties.length; i++)
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.parties[i]);
    if (message.beginExclusive !== 0n)
      writer.tag(3, import_runtime.WireType.Varint).int64(message.beginExclusive);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const CompletionStreamRequest = new CompletionStreamRequest$Type();
class CompletionStreamResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.CompletionStreamResponse", [
      {
        no: 1,
        name: "completion",
        kind: "message",
        oneof: "completionResponse",
        T: () => import_completion.Completion
      },
      {
        no: 2,
        name: "offset_checkpoint",
        kind: "message",
        oneof: "completionResponse",
        T: () => import_offset_checkpoint.OffsetCheckpoint
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.completionResponse = { oneofKind: void 0 };
    if (value !== void 0)
      (0, import_runtime3.reflectionMergePartial)(
        this,
        message,
        value
      );
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* com.daml.ledger.api.v2.Completion completion */
        1:
          message.completionResponse = {
            oneofKind: "completion",
            completion: import_completion.Completion.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.completionResponse.completion
            )
          };
          break;
        case /* com.daml.ledger.api.v2.OffsetCheckpoint offset_checkpoint */
        2:
          message.completionResponse = {
            oneofKind: "offsetCheckpoint",
            offsetCheckpoint: import_offset_checkpoint.OffsetCheckpoint.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.completionResponse.offsetCheckpoint
            )
          };
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.completionResponse.oneofKind === "completion")
      import_completion.Completion.internalBinaryWrite(
        message.completionResponse.completion,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.completionResponse.oneofKind === "offsetCheckpoint")
      import_offset_checkpoint.OffsetCheckpoint.internalBinaryWrite(
        message.completionResponse.offsetCheckpoint,
        writer.tag(2, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const CompletionStreamResponse = new CompletionStreamResponse$Type();
const CommandCompletionService = new import_runtime_rpc.ServiceType(
  "com.daml.ledger.api.v2.CommandCompletionService",
  [
    {
      name: "CompletionStream",
      serverStreaming: true,
      options: {},
      I: CompletionStreamRequest,
      O: CompletionStreamResponse
    }
  ]
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  CommandCompletionService,
  CompletionStreamRequest,
  CompletionStreamResponse
});
//# sourceMappingURL=command_completion_service.cjs.map