"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 state_service_exports = {};
__export(state_service_exports, {
  ActiveContract: () => ActiveContract,
  GetActiveContractsRequest: () => GetActiveContractsRequest,
  GetActiveContractsResponse: () => GetActiveContractsResponse,
  GetConnectedSynchronizersRequest: () => GetConnectedSynchronizersRequest,
  GetConnectedSynchronizersResponse: () => GetConnectedSynchronizersResponse,
  GetConnectedSynchronizersResponse_ConnectedSynchronizer: () => GetConnectedSynchronizersResponse_ConnectedSynchronizer,
  GetLatestPrunedOffsetsRequest: () => GetLatestPrunedOffsetsRequest,
  GetLatestPrunedOffsetsResponse: () => GetLatestPrunedOffsetsResponse,
  GetLedgerEndRequest: () => GetLedgerEndRequest,
  GetLedgerEndResponse: () => GetLedgerEndResponse,
  IncompleteAssigned: () => IncompleteAssigned,
  IncompleteUnassigned: () => IncompleteUnassigned,
  ParticipantPermission: () => ParticipantPermission,
  StateService: () => StateService
});
module.exports = __toCommonJS(state_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_reassignment = require("./reassignment.cjs");
var import_reassignment2 = require("./reassignment.cjs");
var import_event = require("./event.cjs");
var import_transaction_filter = require("./transaction_filter.cjs");
var import_transaction_filter2 = require("./transaction_filter.cjs");
var ParticipantPermission = /* @__PURE__ */ ((ParticipantPermission2) => {
  ParticipantPermission2[ParticipantPermission2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
  ParticipantPermission2[ParticipantPermission2["SUBMISSION"] = 1] = "SUBMISSION";
  ParticipantPermission2[ParticipantPermission2["CONFIRMATION"] = 2] = "CONFIRMATION";
  ParticipantPermission2[ParticipantPermission2["OBSERVATION"] = 3] = "OBSERVATION";
  return ParticipantPermission2;
})(ParticipantPermission || {});
class GetActiveContractsRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetActiveContractsRequest", [
      {
        no: 1,
        name: "filter",
        kind: "message",
        T: () => import_transaction_filter2.TransactionFilter
      },
      {
        no: 2,
        name: "verbose",
        kind: "scalar",
        T: 8
      },
      {
        no: 3,
        name: "active_at_offset",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 4,
        name: "event_format",
        kind: "message",
        T: () => import_transaction_filter.EventFormat
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.verbose = false;
    message.activeAtOffset = 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 /* com.daml.ledger.api.v2.TransactionFilter filter = 1 [deprecated = true] */
        1:
          message.filter = import_transaction_filter2.TransactionFilter.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.filter
          );
          break;
        case /* bool verbose = 2 [deprecated = true] */
        2:
          message.verbose = reader.bool();
          break;
        case /* int64 active_at_offset */
        3:
          message.activeAtOffset = reader.int64().toBigInt();
          break;
        case /* com.daml.ledger.api.v2.EventFormat event_format */
        4:
          message.eventFormat = import_transaction_filter.EventFormat.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.eventFormat
          );
          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.filter)
      import_transaction_filter2.TransactionFilter.internalBinaryWrite(
        message.filter,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.verbose !== false)
      writer.tag(2, import_runtime.WireType.Varint).bool(message.verbose);
    if (message.activeAtOffset !== 0n)
      writer.tag(3, import_runtime.WireType.Varint).int64(message.activeAtOffset);
    if (message.eventFormat)
      import_transaction_filter.EventFormat.internalBinaryWrite(
        message.eventFormat,
        writer.tag(4, 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 GetActiveContractsRequest = new GetActiveContractsRequest$Type();
class GetActiveContractsResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetActiveContractsResponse", [
      {
        no: 1,
        name: "workflow_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "active_contract",
        kind: "message",
        oneof: "contractEntry",
        T: () => ActiveContract
      },
      {
        no: 3,
        name: "incomplete_unassigned",
        kind: "message",
        oneof: "contractEntry",
        T: () => IncompleteUnassigned
      },
      {
        no: 4,
        name: "incomplete_assigned",
        kind: "message",
        oneof: "contractEntry",
        T: () => IncompleteAssigned
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.workflowId = "";
    message.contractEntry = { 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 /* string workflow_id */
        1:
          message.workflowId = reader.string();
          break;
        case /* com.daml.ledger.api.v2.ActiveContract active_contract */
        2:
          message.contractEntry = {
            oneofKind: "activeContract",
            activeContract: ActiveContract.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.contractEntry.activeContract
            )
          };
          break;
        case /* com.daml.ledger.api.v2.IncompleteUnassigned incomplete_unassigned */
        3:
          message.contractEntry = {
            oneofKind: "incompleteUnassigned",
            incompleteUnassigned: IncompleteUnassigned.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.contractEntry.incompleteUnassigned
            )
          };
          break;
        case /* com.daml.ledger.api.v2.IncompleteAssigned incomplete_assigned */
        4:
          message.contractEntry = {
            oneofKind: "incompleteAssigned",
            incompleteAssigned: IncompleteAssigned.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.contractEntry.incompleteAssigned
            )
          };
          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.workflowId !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.workflowId);
    if (message.contractEntry.oneofKind === "activeContract")
      ActiveContract.internalBinaryWrite(
        message.contractEntry.activeContract,
        writer.tag(2, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.contractEntry.oneofKind === "incompleteUnassigned")
      IncompleteUnassigned.internalBinaryWrite(
        message.contractEntry.incompleteUnassigned,
        writer.tag(3, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.contractEntry.oneofKind === "incompleteAssigned")
      IncompleteAssigned.internalBinaryWrite(
        message.contractEntry.incompleteAssigned,
        writer.tag(4, 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 GetActiveContractsResponse = new GetActiveContractsResponse$Type();
class ActiveContract$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.ActiveContract", [
      {
        no: 1,
        name: "created_event",
        kind: "message",
        T: () => import_event.CreatedEvent
      },
      {
        no: 2,
        name: "synchronizer_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 3,
        name: "reassignment_counter",
        kind: "scalar",
        T: 4,
        L: 0
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.synchronizerId = "";
    message.reassignmentCounter = 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 /* com.daml.ledger.api.v2.CreatedEvent created_event */
        1:
          message.createdEvent = import_event.CreatedEvent.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.createdEvent
          );
          break;
        case /* string synchronizer_id */
        2:
          message.synchronizerId = reader.string();
          break;
        case /* uint64 reassignment_counter */
        3:
          message.reassignmentCounter = reader.uint64().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.createdEvent)
      import_event.CreatedEvent.internalBinaryWrite(
        message.createdEvent,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.synchronizerId !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.synchronizerId);
    if (message.reassignmentCounter !== 0n)
      writer.tag(3, import_runtime.WireType.Varint).uint64(message.reassignmentCounter);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const ActiveContract = new ActiveContract$Type();
class IncompleteUnassigned$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.IncompleteUnassigned", [
      {
        no: 1,
        name: "created_event",
        kind: "message",
        T: () => import_event.CreatedEvent
      },
      {
        no: 2,
        name: "unassigned_event",
        kind: "message",
        T: () => import_reassignment2.UnassignedEvent
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    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.CreatedEvent created_event */
        1:
          message.createdEvent = import_event.CreatedEvent.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.createdEvent
          );
          break;
        case /* com.daml.ledger.api.v2.UnassignedEvent unassigned_event */
        2:
          message.unassignedEvent = import_reassignment2.UnassignedEvent.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.unassignedEvent
          );
          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.createdEvent)
      import_event.CreatedEvent.internalBinaryWrite(
        message.createdEvent,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.unassignedEvent)
      import_reassignment2.UnassignedEvent.internalBinaryWrite(
        message.unassignedEvent,
        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 IncompleteUnassigned = new IncompleteUnassigned$Type();
class IncompleteAssigned$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.IncompleteAssigned", [
      {
        no: 1,
        name: "assigned_event",
        kind: "message",
        T: () => import_reassignment.AssignedEvent
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    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.AssignedEvent assigned_event */
        1:
          message.assignedEvent = import_reassignment.AssignedEvent.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.assignedEvent
          );
          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.assignedEvent)
      import_reassignment.AssignedEvent.internalBinaryWrite(
        message.assignedEvent,
        writer.tag(1, 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 IncompleteAssigned = new IncompleteAssigned$Type();
class GetConnectedSynchronizersRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetConnectedSynchronizersRequest", [
      {
        no: 1,
        name: "party",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "participant_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.party = "";
    message.participantId = "";
    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 party */
        1:
          message.party = reader.string();
          break;
        case /* string participant_id */
        2:
          message.participantId = reader.string();
          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.party !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.party);
    if (message.participantId !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.participantId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetConnectedSynchronizersRequest = new GetConnectedSynchronizersRequest$Type();
class GetConnectedSynchronizersResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetConnectedSynchronizersResponse", [
      {
        no: 1,
        name: "connected_synchronizers",
        kind: "message",
        repeat: 2,
        T: () => GetConnectedSynchronizersResponse_ConnectedSynchronizer
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.connectedSynchronizers = [];
    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 /* repeated com.daml.ledger.api.v2.GetConnectedSynchronizersResponse.ConnectedSynchronizer connected_synchronizers */
        1:
          message.connectedSynchronizers.push(
            GetConnectedSynchronizersResponse_ConnectedSynchronizer.internalBinaryRead(
              reader,
              reader.uint32(),
              options
            )
          );
          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) {
    for (let i = 0; i < message.connectedSynchronizers.length; i++)
      GetConnectedSynchronizersResponse_ConnectedSynchronizer.internalBinaryWrite(
        message.connectedSynchronizers[i],
        writer.tag(1, 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 GetConnectedSynchronizersResponse = new GetConnectedSynchronizersResponse$Type();
class GetConnectedSynchronizersResponse_ConnectedSynchronizer$Type extends import_runtime4.MessageType {
  constructor() {
    super(
      "com.daml.ledger.api.v2.GetConnectedSynchronizersResponse.ConnectedSynchronizer",
      [
        {
          no: 1,
          name: "synchronizer_alias",
          kind: "scalar",
          T: 9
        },
        {
          no: 2,
          name: "synchronizer_id",
          kind: "scalar",
          T: 9
        },
        {
          no: 3,
          name: "permission",
          kind: "enum",
          T: () => [
            "com.daml.ledger.api.v2.ParticipantPermission",
            ParticipantPermission,
            "PARTICIPANT_PERMISSION_"
          ]
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.synchronizerAlias = "";
    message.synchronizerId = "";
    message.permission = 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 /* string synchronizer_alias */
        1:
          message.synchronizerAlias = reader.string();
          break;
        case /* string synchronizer_id */
        2:
          message.synchronizerId = reader.string();
          break;
        case /* com.daml.ledger.api.v2.ParticipantPermission permission */
        3:
          message.permission = reader.int32();
          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.synchronizerAlias !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.synchronizerAlias);
    if (message.synchronizerId !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.synchronizerId);
    if (message.permission !== 0)
      writer.tag(3, import_runtime.WireType.Varint).int32(message.permission);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetConnectedSynchronizersResponse_ConnectedSynchronizer = new GetConnectedSynchronizersResponse_ConnectedSynchronizer$Type();
class GetLedgerEndRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetLedgerEndRequest", []);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    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) {
        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) {
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetLedgerEndRequest = new GetLedgerEndRequest$Type();
class GetLedgerEndResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetLedgerEndResponse", [
      {
        no: 1,
        name: "offset",
        kind: "scalar",
        T: 3,
        L: 0
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    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 /* int64 offset */
        1:
          message.offset = 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.offset !== 0n)
      writer.tag(1, import_runtime.WireType.Varint).int64(message.offset);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetLedgerEndResponse = new GetLedgerEndResponse$Type();
class GetLatestPrunedOffsetsRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetLatestPrunedOffsetsRequest", []);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    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) {
        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) {
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetLatestPrunedOffsetsRequest = new GetLatestPrunedOffsetsRequest$Type();
class GetLatestPrunedOffsetsResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetLatestPrunedOffsetsResponse", [
      {
        no: 1,
        name: "participant_pruned_up_to_inclusive",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 2,
        name: "all_divulged_contracts_pruned_up_to_inclusive",
        kind: "scalar",
        T: 3,
        L: 0
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.participantPrunedUpToInclusive = 0n;
    message.allDivulgedContractsPrunedUpToInclusive = 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 /* int64 participant_pruned_up_to_inclusive */
        1:
          message.participantPrunedUpToInclusive = reader.int64().toBigInt();
          break;
        case /* int64 all_divulged_contracts_pruned_up_to_inclusive */
        2:
          message.allDivulgedContractsPrunedUpToInclusive = 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.participantPrunedUpToInclusive !== 0n)
      writer.tag(1, import_runtime.WireType.Varint).int64(message.participantPrunedUpToInclusive);
    if (message.allDivulgedContractsPrunedUpToInclusive !== 0n)
      writer.tag(2, import_runtime.WireType.Varint).int64(message.allDivulgedContractsPrunedUpToInclusive);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetLatestPrunedOffsetsResponse = new GetLatestPrunedOffsetsResponse$Type();
const StateService = new import_runtime_rpc.ServiceType(
  "com.daml.ledger.api.v2.StateService",
  [
    {
      name: "GetActiveContracts",
      serverStreaming: true,
      options: {},
      I: GetActiveContractsRequest,
      O: GetActiveContractsResponse
    },
    {
      name: "GetConnectedSynchronizers",
      options: {},
      I: GetConnectedSynchronizersRequest,
      O: GetConnectedSynchronizersResponse
    },
    {
      name: "GetLedgerEnd",
      options: {},
      I: GetLedgerEndRequest,
      O: GetLedgerEndResponse
    },
    {
      name: "GetLatestPrunedOffsets",
      options: {},
      I: GetLatestPrunedOffsetsRequest,
      O: GetLatestPrunedOffsetsResponse
    }
  ]
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ActiveContract,
  GetActiveContractsRequest,
  GetActiveContractsResponse,
  GetConnectedSynchronizersRequest,
  GetConnectedSynchronizersResponse,
  GetConnectedSynchronizersResponse_ConnectedSynchronizer,
  GetLatestPrunedOffsetsRequest,
  GetLatestPrunedOffsetsResponse,
  GetLedgerEndRequest,
  GetLedgerEndResponse,
  IncompleteAssigned,
  IncompleteUnassigned,
  ParticipantPermission,
  StateService
});
//# sourceMappingURL=state_service.cjs.map