"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 version_service_exports = {};
__export(version_service_exports, {
  FeaturesDescriptor: () => FeaturesDescriptor,
  GetLedgerApiVersionRequest: () => GetLedgerApiVersionRequest,
  GetLedgerApiVersionResponse: () => GetLedgerApiVersionResponse,
  OffsetCheckpointFeature: () => OffsetCheckpointFeature,
  PartyManagementFeature: () => PartyManagementFeature,
  UserManagementFeature: () => UserManagementFeature,
  VersionService: () => VersionService
});
module.exports = __toCommonJS(version_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_duration = require("../../../../../google/protobuf/duration.cjs");
var import_experimental_features = require("./experimental_features.cjs");
class GetLedgerApiVersionRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetLedgerApiVersionRequest", []);
  }
  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 GetLedgerApiVersionRequest = new GetLedgerApiVersionRequest$Type();
class GetLedgerApiVersionResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetLedgerApiVersionResponse", [
      {
        no: 1,
        name: "version",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "features",
        kind: "message",
        T: () => FeaturesDescriptor
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.version = "";
    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 version */
        1:
          message.version = reader.string();
          break;
        case /* com.daml.ledger.api.v2.FeaturesDescriptor features */
        2:
          message.features = FeaturesDescriptor.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.features
          );
          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.version !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.version);
    if (message.features)
      FeaturesDescriptor.internalBinaryWrite(
        message.features,
        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 GetLedgerApiVersionResponse = new GetLedgerApiVersionResponse$Type();
class FeaturesDescriptor$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.FeaturesDescriptor", [
      {
        no: 1,
        name: "experimental",
        kind: "message",
        T: () => import_experimental_features.ExperimentalFeatures
      },
      {
        no: 2,
        name: "user_management",
        kind: "message",
        T: () => UserManagementFeature
      },
      {
        no: 3,
        name: "party_management",
        kind: "message",
        T: () => PartyManagementFeature
      },
      {
        no: 4,
        name: "offset_checkpoint",
        kind: "message",
        T: () => OffsetCheckpointFeature
      }
    ]);
  }
  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.ExperimentalFeatures experimental */
        1:
          message.experimental = import_experimental_features.ExperimentalFeatures.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.experimental
          );
          break;
        case /* com.daml.ledger.api.v2.UserManagementFeature user_management */
        2:
          message.userManagement = UserManagementFeature.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.userManagement
          );
          break;
        case /* com.daml.ledger.api.v2.PartyManagementFeature party_management */
        3:
          message.partyManagement = PartyManagementFeature.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.partyManagement
          );
          break;
        case /* com.daml.ledger.api.v2.OffsetCheckpointFeature offset_checkpoint */
        4:
          message.offsetCheckpoint = OffsetCheckpointFeature.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.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.experimental)
      import_experimental_features.ExperimentalFeatures.internalBinaryWrite(
        message.experimental,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.userManagement)
      UserManagementFeature.internalBinaryWrite(
        message.userManagement,
        writer.tag(2, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.partyManagement)
      PartyManagementFeature.internalBinaryWrite(
        message.partyManagement,
        writer.tag(3, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.offsetCheckpoint)
      OffsetCheckpointFeature.internalBinaryWrite(
        message.offsetCheckpoint,
        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 FeaturesDescriptor = new FeaturesDescriptor$Type();
class UserManagementFeature$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.UserManagementFeature", [
      {
        no: 1,
        name: "supported",
        kind: "scalar",
        T: 8
      },
      {
        no: 2,
        name: "max_rights_per_user",
        kind: "scalar",
        T: 5
      },
      {
        no: 3,
        name: "max_users_page_size",
        kind: "scalar",
        T: 5
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.supported = false;
    message.maxRightsPerUser = 0;
    message.maxUsersPageSize = 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 /* bool supported */
        1:
          message.supported = reader.bool();
          break;
        case /* int32 max_rights_per_user */
        2:
          message.maxRightsPerUser = reader.int32();
          break;
        case /* int32 max_users_page_size */
        3:
          message.maxUsersPageSize = 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.supported !== false)
      writer.tag(1, import_runtime.WireType.Varint).bool(message.supported);
    if (message.maxRightsPerUser !== 0)
      writer.tag(2, import_runtime.WireType.Varint).int32(message.maxRightsPerUser);
    if (message.maxUsersPageSize !== 0)
      writer.tag(3, import_runtime.WireType.Varint).int32(message.maxUsersPageSize);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const UserManagementFeature = new UserManagementFeature$Type();
class PartyManagementFeature$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.PartyManagementFeature", [
      {
        no: 1,
        name: "max_parties_page_size",
        kind: "scalar",
        T: 5
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.maxPartiesPageSize = 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 /* int32 max_parties_page_size */
        1:
          message.maxPartiesPageSize = 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.maxPartiesPageSize !== 0)
      writer.tag(1, import_runtime.WireType.Varint).int32(message.maxPartiesPageSize);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const PartyManagementFeature = new PartyManagementFeature$Type();
class OffsetCheckpointFeature$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.OffsetCheckpointFeature", [
      {
        no: 1,
        name: "max_offset_checkpoint_emission_delay",
        kind: "message",
        T: () => import_duration.Duration
      }
    ]);
  }
  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 /* google.protobuf.Duration max_offset_checkpoint_emission_delay */
        1:
          message.maxOffsetCheckpointEmissionDelay = import_duration.Duration.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.maxOffsetCheckpointEmissionDelay
          );
          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.maxOffsetCheckpointEmissionDelay)
      import_duration.Duration.internalBinaryWrite(
        message.maxOffsetCheckpointEmissionDelay,
        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 OffsetCheckpointFeature = new OffsetCheckpointFeature$Type();
const VersionService = new import_runtime_rpc.ServiceType(
  "com.daml.ledger.api.v2.VersionService",
  [
    {
      name: "GetLedgerApiVersion",
      options: {},
      I: GetLedgerApiVersionRequest,
      O: GetLedgerApiVersionResponse
    }
  ]
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FeaturesDescriptor,
  GetLedgerApiVersionRequest,
  GetLedgerApiVersionResponse,
  OffsetCheckpointFeature,
  PartyManagementFeature,
  UserManagementFeature,
  VersionService
});
//# sourceMappingURL=version_service.cjs.map