import { ServiceType } from "@protobuf-ts/runtime-rpc";
import { WireType } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { SigningPublicKey } from "../crypto.js";
import { FieldMask } from "../../../../../../google/protobuf/field_mask.js";
import { Signature } from "../interactive/interactive_submission_service.js";
import { ObjectMeta } from "./object_meta.js";
class GetParticipantIdRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.GetParticipantIdRequest", []);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetParticipantIdRequest = new GetParticipantIdRequest$Type();
class GetParticipantIdResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.GetParticipantIdResponse", [
      {
        no: 1,
        name: "participant_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.participantId = "";
    if (value !== void 0)
      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 participant_id */
        1:
          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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.participantId !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.participantId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetParticipantIdResponse = new GetParticipantIdResponse$Type();
class GetPartiesRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.GetPartiesRequest", [
      {
        no: 1,
        name: "parties",
        kind: "scalar",
        repeat: 2,
        T: 9
      },
      {
        no: 2,
        name: "identity_provider_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.parties = [];
    message.identityProviderId = "";
    if (value !== void 0)
      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 string parties */
        1:
          message.parties.push(reader.string());
          break;
        case /* string identity_provider_id */
        2:
          message.identityProviderId = 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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    for (let i = 0; i < message.parties.length; i++)
      writer.tag(1, WireType.LengthDelimited).string(message.parties[i]);
    if (message.identityProviderId !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.identityProviderId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetPartiesRequest = new GetPartiesRequest$Type();
class GetPartiesResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.GetPartiesResponse", [
      {
        no: 1,
        name: "party_details",
        kind: "message",
        repeat: 2,
        T: () => PartyDetails
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.partyDetails = [];
    if (value !== void 0)
      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.admin.PartyDetails party_details */
        1:
          message.partyDetails.push(
            PartyDetails.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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    for (let i = 0; i < message.partyDetails.length; i++)
      PartyDetails.internalBinaryWrite(
        message.partyDetails[i],
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetPartiesResponse = new GetPartiesResponse$Type();
class ListKnownPartiesRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.ListKnownPartiesRequest", [
      {
        no: 2,
        name: "page_token",
        kind: "scalar",
        T: 9
      },
      {
        no: 3,
        name: "page_size",
        kind: "scalar",
        T: 5
      },
      {
        no: 1,
        name: "identity_provider_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.pageToken = "";
    message.pageSize = 0;
    message.identityProviderId = "";
    if (value !== void 0)
      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 page_token */
        2:
          message.pageToken = reader.string();
          break;
        case /* int32 page_size */
        3:
          message.pageSize = reader.int32();
          break;
        case /* string identity_provider_id */
        1:
          message.identityProviderId = 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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.identityProviderId !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.identityProviderId);
    if (message.pageToken !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.pageToken);
    if (message.pageSize !== 0)
      writer.tag(3, WireType.Varint).int32(message.pageSize);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const ListKnownPartiesRequest = new ListKnownPartiesRequest$Type();
class ListKnownPartiesResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.ListKnownPartiesResponse", [
      {
        no: 1,
        name: "party_details",
        kind: "message",
        repeat: 2,
        T: () => PartyDetails
      },
      {
        no: 2,
        name: "next_page_token",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.partyDetails = [];
    message.nextPageToken = "";
    if (value !== void 0)
      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.admin.PartyDetails party_details */
        1:
          message.partyDetails.push(
            PartyDetails.internalBinaryRead(
              reader,
              reader.uint32(),
              options
            )
          );
          break;
        case /* string next_page_token */
        2:
          message.nextPageToken = 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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    for (let i = 0; i < message.partyDetails.length; i++)
      PartyDetails.internalBinaryWrite(
        message.partyDetails[i],
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.nextPageToken !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.nextPageToken);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const ListKnownPartiesResponse = new ListKnownPartiesResponse$Type();
class AllocatePartyRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.AllocatePartyRequest", [
      {
        no: 1,
        name: "party_id_hint",
        kind: "scalar",
        T: 9
      },
      {
        no: 3,
        name: "local_metadata",
        kind: "message",
        T: () => ObjectMeta
      },
      {
        no: 4,
        name: "identity_provider_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.partyIdHint = "";
    message.identityProviderId = "";
    if (value !== void 0)
      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_id_hint */
        1:
          message.partyIdHint = reader.string();
          break;
        case /* com.daml.ledger.api.v2.admin.ObjectMeta local_metadata */
        3:
          message.localMetadata = ObjectMeta.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.localMetadata
          );
          break;
        case /* string identity_provider_id */
        4:
          message.identityProviderId = 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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.partyIdHint !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.partyIdHint);
    if (message.localMetadata)
      ObjectMeta.internalBinaryWrite(
        message.localMetadata,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.identityProviderId !== "")
      writer.tag(4, WireType.LengthDelimited).string(message.identityProviderId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AllocatePartyRequest = new AllocatePartyRequest$Type();
class AllocatePartyResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.AllocatePartyResponse", [
      {
        no: 1,
        name: "party_details",
        kind: "message",
        T: () => PartyDetails
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      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.admin.PartyDetails party_details */
        1:
          message.partyDetails = PartyDetails.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.partyDetails
          );
          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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.partyDetails)
      PartyDetails.internalBinaryWrite(
        message.partyDetails,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AllocatePartyResponse = new AllocatePartyResponse$Type();
class AllocateExternalPartyRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.AllocateExternalPartyRequest", [
      {
        no: 1,
        name: "synchronizer",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "onboarding_transactions",
        kind: "message",
        repeat: 2,
        T: () => AllocateExternalPartyRequest_SignedTransaction
      },
      {
        no: 3,
        name: "multi_hash_signatures",
        kind: "message",
        repeat: 2,
        T: () => Signature
      },
      {
        no: 4,
        name: "identity_provider_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.synchronizer = "";
    message.onboardingTransactions = [];
    message.multiHashSignatures = [];
    message.identityProviderId = "";
    if (value !== void 0)
      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 */
        1:
          message.synchronizer = reader.string();
          break;
        case /* repeated com.daml.ledger.api.v2.admin.AllocateExternalPartyRequest.SignedTransaction onboarding_transactions */
        2:
          message.onboardingTransactions.push(
            AllocateExternalPartyRequest_SignedTransaction.internalBinaryRead(
              reader,
              reader.uint32(),
              options
            )
          );
          break;
        case /* repeated com.daml.ledger.api.v2.interactive.Signature multi_hash_signatures */
        3:
          message.multiHashSignatures.push(
            Signature.internalBinaryRead(
              reader,
              reader.uint32(),
              options
            )
          );
          break;
        case /* string identity_provider_id */
        4:
          message.identityProviderId = 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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.synchronizer !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.synchronizer);
    for (let i = 0; i < message.onboardingTransactions.length; i++)
      AllocateExternalPartyRequest_SignedTransaction.internalBinaryWrite(
        message.onboardingTransactions[i],
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    for (let i = 0; i < message.multiHashSignatures.length; i++)
      Signature.internalBinaryWrite(
        message.multiHashSignatures[i],
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.identityProviderId !== "")
      writer.tag(4, WireType.LengthDelimited).string(message.identityProviderId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AllocateExternalPartyRequest = new AllocateExternalPartyRequest$Type();
class AllocateExternalPartyRequest_SignedTransaction$Type extends MessageType {
  constructor() {
    super(
      "com.daml.ledger.api.v2.admin.AllocateExternalPartyRequest.SignedTransaction",
      [
        {
          no: 1,
          name: "transaction",
          kind: "scalar",
          T: 12
        },
        {
          no: 2,
          name: "signatures",
          kind: "message",
          repeat: 2,
          T: () => Signature
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.transaction = new Uint8Array(0);
    message.signatures = [];
    if (value !== void 0)
      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 /* bytes transaction */
        1:
          message.transaction = reader.bytes();
          break;
        case /* repeated com.daml.ledger.api.v2.interactive.Signature signatures */
        2:
          message.signatures.push(
            Signature.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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.transaction.length)
      writer.tag(1, WireType.LengthDelimited).bytes(message.transaction);
    for (let i = 0; i < message.signatures.length; i++)
      Signature.internalBinaryWrite(
        message.signatures[i],
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AllocateExternalPartyRequest_SignedTransaction = new AllocateExternalPartyRequest_SignedTransaction$Type();
class AllocateExternalPartyResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.AllocateExternalPartyResponse", [
      {
        no: 1,
        name: "party_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.partyId = "";
    if (value !== void 0)
      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_id */
        1:
          message.partyId = 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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.partyId !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.partyId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AllocateExternalPartyResponse = new AllocateExternalPartyResponse$Type();
class UpdatePartyDetailsRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.UpdatePartyDetailsRequest", [
      {
        no: 1,
        name: "party_details",
        kind: "message",
        T: () => PartyDetails
      },
      { no: 2, name: "update_mask", kind: "message", T: () => FieldMask }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      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.admin.PartyDetails party_details */
        1:
          message.partyDetails = PartyDetails.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.partyDetails
          );
          break;
        case /* google.protobuf.FieldMask update_mask */
        2:
          message.updateMask = FieldMask.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.updateMask
          );
          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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.partyDetails)
      PartyDetails.internalBinaryWrite(
        message.partyDetails,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.updateMask)
      FieldMask.internalBinaryWrite(
        message.updateMask,
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const UpdatePartyDetailsRequest = new UpdatePartyDetailsRequest$Type();
class UpdatePartyDetailsResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.UpdatePartyDetailsResponse", [
      {
        no: 1,
        name: "party_details",
        kind: "message",
        T: () => PartyDetails
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      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.admin.PartyDetails party_details */
        1:
          message.partyDetails = PartyDetails.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.partyDetails
          );
          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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.partyDetails)
      PartyDetails.internalBinaryWrite(
        message.partyDetails,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const UpdatePartyDetailsResponse = new UpdatePartyDetailsResponse$Type();
class PartyDetails$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.PartyDetails", [
      {
        no: 1,
        name: "party",
        kind: "scalar",
        T: 9
      },
      {
        no: 3,
        name: "is_local",
        kind: "scalar",
        T: 8
      },
      {
        no: 4,
        name: "local_metadata",
        kind: "message",
        T: () => ObjectMeta
      },
      {
        no: 5,
        name: "identity_provider_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.party = "";
    message.isLocal = false;
    message.identityProviderId = "";
    if (value !== void 0)
      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 /* bool is_local */
        3:
          message.isLocal = reader.bool();
          break;
        case /* com.daml.ledger.api.v2.admin.ObjectMeta local_metadata */
        4:
          message.localMetadata = ObjectMeta.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.localMetadata
          );
          break;
        case /* string identity_provider_id */
        5:
          message.identityProviderId = 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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.party !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.party);
    if (message.isLocal !== false)
      writer.tag(3, WireType.Varint).bool(message.isLocal);
    if (message.localMetadata)
      ObjectMeta.internalBinaryWrite(
        message.localMetadata,
        writer.tag(4, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.identityProviderId !== "")
      writer.tag(5, WireType.LengthDelimited).string(message.identityProviderId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const PartyDetails = new PartyDetails$Type();
class UpdatePartyIdentityProviderIdRequest$Type extends MessageType {
  constructor() {
    super(
      "com.daml.ledger.api.v2.admin.UpdatePartyIdentityProviderIdRequest",
      [
        {
          no: 1,
          name: "party",
          kind: "scalar",
          T: 9
        },
        {
          no: 2,
          name: "source_identity_provider_id",
          kind: "scalar",
          T: 9
        },
        {
          no: 3,
          name: "target_identity_provider_id",
          kind: "scalar",
          T: 9
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.party = "";
    message.sourceIdentityProviderId = "";
    message.targetIdentityProviderId = "";
    if (value !== void 0)
      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 source_identity_provider_id */
        2:
          message.sourceIdentityProviderId = reader.string();
          break;
        case /* string target_identity_provider_id */
        3:
          message.targetIdentityProviderId = 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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.party !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.party);
    if (message.sourceIdentityProviderId !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.sourceIdentityProviderId);
    if (message.targetIdentityProviderId !== "")
      writer.tag(3, WireType.LengthDelimited).string(message.targetIdentityProviderId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const UpdatePartyIdentityProviderIdRequest = new UpdatePartyIdentityProviderIdRequest$Type();
class UpdatePartyIdentityProviderIdResponse$Type extends MessageType {
  constructor() {
    super(
      "com.daml.ledger.api.v2.admin.UpdatePartyIdentityProviderIdResponse",
      []
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const UpdatePartyIdentityProviderIdResponse = new UpdatePartyIdentityProviderIdResponse$Type();
class GenerateExternalPartyTopologyRequest$Type extends MessageType {
  constructor() {
    super(
      "com.daml.ledger.api.v2.admin.GenerateExternalPartyTopologyRequest",
      [
        {
          no: 1,
          name: "synchronizer",
          kind: "scalar",
          T: 9
        },
        {
          no: 2,
          name: "party_hint",
          kind: "scalar",
          T: 9
        },
        {
          no: 3,
          name: "public_key",
          kind: "message",
          T: () => SigningPublicKey
        },
        {
          no: 4,
          name: "local_participant_observation_only",
          kind: "scalar",
          T: 8
        },
        {
          no: 5,
          name: "other_confirming_participant_uids",
          kind: "scalar",
          repeat: 2,
          T: 9
        },
        {
          no: 6,
          name: "confirmation_threshold",
          kind: "scalar",
          T: 13
        },
        {
          no: 7,
          name: "observing_participant_uids",
          kind: "scalar",
          repeat: 2,
          T: 9
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.synchronizer = "";
    message.partyHint = "";
    message.localParticipantObservationOnly = false;
    message.otherConfirmingParticipantUids = [];
    message.confirmationThreshold = 0;
    message.observingParticipantUids = [];
    if (value !== void 0)
      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 */
        1:
          message.synchronizer = reader.string();
          break;
        case /* string party_hint */
        2:
          message.partyHint = reader.string();
          break;
        case /* com.daml.ledger.api.v2.SigningPublicKey public_key */
        3:
          message.publicKey = SigningPublicKey.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.publicKey
          );
          break;
        case /* bool local_participant_observation_only */
        4:
          message.localParticipantObservationOnly = reader.bool();
          break;
        case /* repeated string other_confirming_participant_uids */
        5:
          message.otherConfirmingParticipantUids.push(reader.string());
          break;
        case /* uint32 confirmation_threshold */
        6:
          message.confirmationThreshold = reader.uint32();
          break;
        case /* repeated string observing_participant_uids */
        7:
          message.observingParticipantUids.push(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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.synchronizer !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.synchronizer);
    if (message.partyHint !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.partyHint);
    if (message.publicKey)
      SigningPublicKey.internalBinaryWrite(
        message.publicKey,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.localParticipantObservationOnly !== false)
      writer.tag(4, WireType.Varint).bool(message.localParticipantObservationOnly);
    for (let i = 0; i < message.otherConfirmingParticipantUids.length; i++)
      writer.tag(5, WireType.LengthDelimited).string(message.otherConfirmingParticipantUids[i]);
    if (message.confirmationThreshold !== 0)
      writer.tag(6, WireType.Varint).uint32(message.confirmationThreshold);
    for (let i = 0; i < message.observingParticipantUids.length; i++)
      writer.tag(7, WireType.LengthDelimited).string(message.observingParticipantUids[i]);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GenerateExternalPartyTopologyRequest = new GenerateExternalPartyTopologyRequest$Type();
class GenerateExternalPartyTopologyResponse$Type extends MessageType {
  constructor() {
    super(
      "com.daml.ledger.api.v2.admin.GenerateExternalPartyTopologyResponse",
      [
        {
          no: 1,
          name: "party_id",
          kind: "scalar",
          T: 9
        },
        {
          no: 2,
          name: "public_key_fingerprint",
          kind: "scalar",
          T: 9
        },
        {
          no: 3,
          name: "topology_transactions",
          kind: "scalar",
          repeat: 2,
          T: 12
        },
        {
          no: 4,
          name: "multi_hash",
          kind: "scalar",
          T: 12
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.partyId = "";
    message.publicKeyFingerprint = "";
    message.topologyTransactions = [];
    message.multiHash = new Uint8Array(0);
    if (value !== void 0)
      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_id */
        1:
          message.partyId = reader.string();
          break;
        case /* string public_key_fingerprint */
        2:
          message.publicKeyFingerprint = reader.string();
          break;
        case /* repeated bytes topology_transactions */
        3:
          message.topologyTransactions.push(reader.bytes());
          break;
        case /* bytes multi_hash */
        4:
          message.multiHash = reader.bytes();
          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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.partyId !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.partyId);
    if (message.publicKeyFingerprint !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.publicKeyFingerprint);
    for (let i = 0; i < message.topologyTransactions.length; i++)
      writer.tag(3, WireType.LengthDelimited).bytes(message.topologyTransactions[i]);
    if (message.multiHash.length)
      writer.tag(4, WireType.LengthDelimited).bytes(message.multiHash);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GenerateExternalPartyTopologyResponse = new GenerateExternalPartyTopologyResponse$Type();
const PartyManagementService = new ServiceType(
  "com.daml.ledger.api.v2.admin.PartyManagementService",
  [
    {
      name: "GetParticipantId",
      options: {},
      I: GetParticipantIdRequest,
      O: GetParticipantIdResponse
    },
    {
      name: "GetParties",
      options: {},
      I: GetPartiesRequest,
      O: GetPartiesResponse
    },
    {
      name: "ListKnownParties",
      options: {},
      I: ListKnownPartiesRequest,
      O: ListKnownPartiesResponse
    },
    {
      name: "AllocateParty",
      options: {},
      I: AllocatePartyRequest,
      O: AllocatePartyResponse
    },
    {
      name: "AllocateExternalParty",
      options: {},
      I: AllocateExternalPartyRequest,
      O: AllocateExternalPartyResponse
    },
    {
      name: "UpdatePartyDetails",
      options: {},
      I: UpdatePartyDetailsRequest,
      O: UpdatePartyDetailsResponse
    },
    {
      name: "UpdatePartyIdentityProviderId",
      options: {},
      I: UpdatePartyIdentityProviderIdRequest,
      O: UpdatePartyIdentityProviderIdResponse
    },
    {
      name: "GenerateExternalPartyTopology",
      options: {},
      I: GenerateExternalPartyTopologyRequest,
      O: GenerateExternalPartyTopologyResponse
    }
  ]
);
export {
  AllocateExternalPartyRequest,
  AllocateExternalPartyRequest_SignedTransaction,
  AllocateExternalPartyResponse,
  AllocatePartyRequest,
  AllocatePartyResponse,
  GenerateExternalPartyTopologyRequest,
  GenerateExternalPartyTopologyResponse,
  GetParticipantIdRequest,
  GetParticipantIdResponse,
  GetPartiesRequest,
  GetPartiesResponse,
  ListKnownPartiesRequest,
  ListKnownPartiesResponse,
  PartyDetails,
  PartyManagementService,
  UpdatePartyDetailsRequest,
  UpdatePartyDetailsResponse,
  UpdatePartyIdentityProviderIdRequest,
  UpdatePartyIdentityProviderIdResponse
};
//# sourceMappingURL=party_management_service.js.map