"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 completion_exports = {};
__export(completion_exports, {
  Completion: () => Completion
});
module.exports = __toCommonJS(completion_exports);
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_trace_context = require("./trace_context.cjs");
var import_duration = require("../../../../../google/protobuf/duration.cjs");
var import_status = require("../../../../../google/rpc/status.cjs");
class Completion$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.Completion", [
      {
        no: 1,
        name: "command_id",
        kind: "scalar",
        T: 9
      },
      { no: 2, name: "status", kind: "message", T: () => import_status.Status },
      {
        no: 3,
        name: "update_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 4,
        name: "user_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 5,
        name: "act_as",
        kind: "scalar",
        repeat: 2,
        T: 9
      },
      {
        no: 6,
        name: "submission_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 7,
        name: "deduplication_offset",
        kind: "scalar",
        oneof: "deduplicationPeriod",
        T: 3,
        L: 0
      },
      {
        no: 8,
        name: "deduplication_duration",
        kind: "message",
        oneof: "deduplicationPeriod",
        T: () => import_duration.Duration
      },
      {
        no: 9,
        name: "trace_context",
        kind: "message",
        T: () => import_trace_context.TraceContext
      },
      {
        no: 10,
        name: "offset",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 11,
        name: "synchronizer_time",
        kind: "message",
        T: () => import_offset_checkpoint.SynchronizerTime
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.commandId = "";
    message.updateId = "";
    message.userId = "";
    message.actAs = [];
    message.submissionId = "";
    message.deduplicationPeriod = { oneofKind: void 0 };
    message.offset = 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 command_id */
        1:
          message.commandId = reader.string();
          break;
        case /* google.rpc.Status status */
        2:
          message.status = import_status.Status.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.status
          );
          break;
        case /* string update_id */
        3:
          message.updateId = reader.string();
          break;
        case /* string user_id */
        4:
          message.userId = reader.string();
          break;
        case /* repeated string act_as */
        5:
          message.actAs.push(reader.string());
          break;
        case /* string submission_id */
        6:
          message.submissionId = reader.string();
          break;
        case /* int64 deduplication_offset */
        7:
          message.deduplicationPeriod = {
            oneofKind: "deduplicationOffset",
            deduplicationOffset: reader.int64().toBigInt()
          };
          break;
        case /* google.protobuf.Duration deduplication_duration */
        8:
          message.deduplicationPeriod = {
            oneofKind: "deduplicationDuration",
            deduplicationDuration: import_duration.Duration.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.deduplicationPeriod.deduplicationDuration
            )
          };
          break;
        case /* com.daml.ledger.api.v2.TraceContext trace_context */
        9:
          message.traceContext = import_trace_context.TraceContext.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.traceContext
          );
          break;
        case /* int64 offset */
        10:
          message.offset = reader.int64().toBigInt();
          break;
        case /* com.daml.ledger.api.v2.SynchronizerTime synchronizer_time */
        11:
          message.synchronizerTime = import_offset_checkpoint.SynchronizerTime.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.synchronizerTime
          );
          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.commandId !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.commandId);
    if (message.status)
      import_status.Status.internalBinaryWrite(
        message.status,
        writer.tag(2, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.updateId !== "")
      writer.tag(3, import_runtime.WireType.LengthDelimited).string(message.updateId);
    if (message.userId !== "")
      writer.tag(4, import_runtime.WireType.LengthDelimited).string(message.userId);
    for (let i = 0; i < message.actAs.length; i++)
      writer.tag(5, import_runtime.WireType.LengthDelimited).string(message.actAs[i]);
    if (message.submissionId !== "")
      writer.tag(6, import_runtime.WireType.LengthDelimited).string(message.submissionId);
    if (message.deduplicationPeriod.oneofKind === "deduplicationOffset")
      writer.tag(7, import_runtime.WireType.Varint).int64(message.deduplicationPeriod.deduplicationOffset);
    if (message.deduplicationPeriod.oneofKind === "deduplicationDuration")
      import_duration.Duration.internalBinaryWrite(
        message.deduplicationPeriod.deduplicationDuration,
        writer.tag(8, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.traceContext)
      import_trace_context.TraceContext.internalBinaryWrite(
        message.traceContext,
        writer.tag(9, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.offset !== 0n)
      writer.tag(10, import_runtime.WireType.Varint).int64(message.offset);
    if (message.synchronizerTime)
      import_offset_checkpoint.SynchronizerTime.internalBinaryWrite(
        message.synchronizerTime,
        writer.tag(11, 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 Completion = new Completion$Type();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Completion
});
//# sourceMappingURL=completion.cjs.map