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 { StoreId_Temporary } from "./common.js";
import { SignedTopologyTransaction } from "../../../protocol/v30/topology.js";
import { Duration } from "../../../../../../google/protobuf/duration.js";
import { StoreId } from "./common.js";
import { TopologyMapping } from "../../../protocol/v30/topology.js";
import { Enums_TopologyChangeOp } from "../../../protocol/v30/topology.js";
var ForceFlag = /* @__PURE__ */ ((ForceFlag2) => {
  ForceFlag2[ForceFlag2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
  ForceFlag2[ForceFlag2["ALIEN_MEMBER"] = 1] = "ALIEN_MEMBER";
  ForceFlag2[ForceFlag2["LEDGER_TIME_RECORD_TIME_TOLERANCE_INCREASE"] = 2] = "LEDGER_TIME_RECORD_TIME_TOLERANCE_INCREASE";
  ForceFlag2[ForceFlag2["ALLOW_UNVET_PACKAGE"] = 3] = "ALLOW_UNVET_PACKAGE";
  ForceFlag2[ForceFlag2["ALLOW_UNKNOWN_PACKAGE"] = 4] = "ALLOW_UNKNOWN_PACKAGE";
  ForceFlag2[ForceFlag2["ALLOW_UNVETTED_DEPENDENCIES"] = 5] = "ALLOW_UNVETTED_DEPENDENCIES";
  ForceFlag2[ForceFlag2["DISABLE_PARTY_WITH_ACTIVE_CONTRACTS"] = 6] = "DISABLE_PARTY_WITH_ACTIVE_CONTRACTS";
  ForceFlag2[ForceFlag2["ALLOW_UNVALIDATED_SIGNING_KEYS"] = 7] = "ALLOW_UNVALIDATED_SIGNING_KEYS";
  ForceFlag2[ForceFlag2["ALLOW_UNVET_PACKAGE_WITH_ACTIVE_CONTRACTS"] = 8] = "ALLOW_UNVET_PACKAGE_WITH_ACTIVE_CONTRACTS";
  ForceFlag2[ForceFlag2["PREPARATION_TIME_RECORD_TIME_TOLERANCE_INCREASE"] = 9] = "PREPARATION_TIME_RECORD_TIME_TOLERANCE_INCREASE";
  ForceFlag2[ForceFlag2["ALLOW_INSUFFICIENT_PARTICIPANT_PERMISSION_FOR_SIGNATORY_PARTY"] = 10] = "ALLOW_INSUFFICIENT_PARTICIPANT_PERMISSION_FOR_SIGNATORY_PARTY";
  ForceFlag2[ForceFlag2["ALLOW_INSUFFICIENT_SIGNATORY_ASSIGNING_PARTICIPANTS_FOR_PARTY"] = 11] = "ALLOW_INSUFFICIENT_SIGNATORY_ASSIGNING_PARTICIPANTS_FOR_PARTY";
  return ForceFlag2;
})(ForceFlag || {});
class GenerateTransactionsRequest$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.GenerateTransactionsRequest",
      [
        {
          no: 1,
          name: "proposals",
          kind: "message",
          repeat: 2,
          T: () => GenerateTransactionsRequest_Proposal
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.proposals = [];
    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.digitalasset.canton.topology.admin.v30.GenerateTransactionsRequest.Proposal proposals */
        1:
          message.proposals.push(
            GenerateTransactionsRequest_Proposal.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.proposals.length; i++)
      GenerateTransactionsRequest_Proposal.internalBinaryWrite(
        message.proposals[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 GenerateTransactionsRequest = new GenerateTransactionsRequest$Type();
class GenerateTransactionsRequest_Proposal$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.GenerateTransactionsRequest.Proposal",
      [
        {
          no: 1,
          name: "operation",
          kind: "enum",
          T: () => [
            "com.digitalasset.canton.protocol.v30.Enums.TopologyChangeOp",
            Enums_TopologyChangeOp,
            "TOPOLOGY_CHANGE_OP_"
          ]
        },
        {
          no: 2,
          name: "serial",
          kind: "scalar",
          T: 13
        },
        {
          no: 3,
          name: "mapping",
          kind: "message",
          T: () => TopologyMapping
        },
        { no: 4, name: "store", kind: "message", T: () => StoreId }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.operation = 0;
    message.serial = 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 /* com.digitalasset.canton.protocol.v30.Enums.TopologyChangeOp operation */
        1:
          message.operation = reader.int32();
          break;
        case /* uint32 serial */
        2:
          message.serial = reader.uint32();
          break;
        case /* com.digitalasset.canton.protocol.v30.TopologyMapping mapping */
        3:
          message.mapping = TopologyMapping.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.mapping
          );
          break;
        case /* com.digitalasset.canton.topology.admin.v30.StoreId store */
        4:
          message.store = StoreId.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.store
          );
          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.operation !== 0)
      writer.tag(1, WireType.Varint).int32(message.operation);
    if (message.serial !== 0)
      writer.tag(2, WireType.Varint).uint32(message.serial);
    if (message.mapping)
      TopologyMapping.internalBinaryWrite(
        message.mapping,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.store)
      StoreId.internalBinaryWrite(
        message.store,
        writer.tag(4, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GenerateTransactionsRequest_Proposal = new GenerateTransactionsRequest_Proposal$Type();
class GenerateTransactionsResponse$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.GenerateTransactionsResponse",
      [
        {
          no: 1,
          name: "generated_transactions",
          kind: "message",
          repeat: 2,
          T: () => GenerateTransactionsResponse_GeneratedTransaction
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.generatedTransactions = [];
    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.digitalasset.canton.topology.admin.v30.GenerateTransactionsResponse.GeneratedTransaction generated_transactions */
        1:
          message.generatedTransactions.push(
            GenerateTransactionsResponse_GeneratedTransaction.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.generatedTransactions.length; i++)
      GenerateTransactionsResponse_GeneratedTransaction.internalBinaryWrite(
        message.generatedTransactions[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 GenerateTransactionsResponse = new GenerateTransactionsResponse$Type();
class GenerateTransactionsResponse_GeneratedTransaction$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.GenerateTransactionsResponse.GeneratedTransaction",
      [
        {
          no: 1,
          name: "serialized_transaction",
          kind: "scalar",
          T: 12
        },
        {
          no: 2,
          name: "transaction_hash",
          kind: "scalar",
          T: 12
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.serializedTransaction = new Uint8Array(0);
    message.transactionHash = 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 /* bytes serialized_transaction */
        1:
          message.serializedTransaction = reader.bytes();
          break;
        case /* bytes transaction_hash */
        2:
          message.transactionHash = 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.serializedTransaction.length)
      writer.tag(1, WireType.LengthDelimited).bytes(message.serializedTransaction);
    if (message.transactionHash.length)
      writer.tag(2, WireType.LengthDelimited).bytes(message.transactionHash);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GenerateTransactionsResponse_GeneratedTransaction = new GenerateTransactionsResponse_GeneratedTransaction$Type();
class AuthorizeRequest$Type extends MessageType {
  constructor() {
    super("com.digitalasset.canton.topology.admin.v30.AuthorizeRequest", [
      {
        no: 1,
        name: "proposal",
        kind: "message",
        oneof: "type",
        T: () => AuthorizeRequest_Proposal
      },
      {
        no: 2,
        name: "transaction_hash",
        kind: "scalar",
        oneof: "type",
        T: 9
      },
      {
        no: 3,
        name: "must_fully_authorize",
        kind: "scalar",
        T: 8
      },
      {
        no: 4,
        name: "force_changes",
        kind: "enum",
        repeat: 1,
        T: () => [
          "com.digitalasset.canton.topology.admin.v30.ForceFlag",
          ForceFlag,
          "FORCE_FLAG_"
        ]
      },
      {
        no: 5,
        name: "signed_by",
        kind: "scalar",
        repeat: 2,
        T: 9
      },
      { no: 6, name: "store", kind: "message", T: () => StoreId },
      {
        no: 7,
        name: "wait_to_become_effective",
        kind: "message",
        T: () => Duration
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.type = { oneofKind: void 0 };
    message.mustFullyAuthorize = false;
    message.forceChanges = [];
    message.signedBy = [];
    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.digitalasset.canton.topology.admin.v30.AuthorizeRequest.Proposal proposal */
        1:
          message.type = {
            oneofKind: "proposal",
            proposal: AuthorizeRequest_Proposal.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.type.proposal
            )
          };
          break;
        case /* string transaction_hash */
        2:
          message.type = {
            oneofKind: "transactionHash",
            transactionHash: reader.string()
          };
          break;
        case /* bool must_fully_authorize */
        3:
          message.mustFullyAuthorize = reader.bool();
          break;
        case /* repeated com.digitalasset.canton.topology.admin.v30.ForceFlag force_changes */
        4:
          if (wireType === WireType.LengthDelimited)
            for (let e = reader.int32() + reader.pos; reader.pos < e; )
              message.forceChanges.push(reader.int32());
          else message.forceChanges.push(reader.int32());
          break;
        case /* repeated string signed_by */
        5:
          message.signedBy.push(reader.string());
          break;
        case /* com.digitalasset.canton.topology.admin.v30.StoreId store */
        6:
          message.store = StoreId.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.store
          );
          break;
        case /* google.protobuf.Duration wait_to_become_effective */
        7:
          message.waitToBecomeEffective = Duration.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.waitToBecomeEffective
          );
          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.type.oneofKind === "proposal")
      AuthorizeRequest_Proposal.internalBinaryWrite(
        message.type.proposal,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.type.oneofKind === "transactionHash")
      writer.tag(2, WireType.LengthDelimited).string(message.type.transactionHash);
    if (message.mustFullyAuthorize !== false)
      writer.tag(3, WireType.Varint).bool(message.mustFullyAuthorize);
    if (message.forceChanges.length) {
      writer.tag(4, WireType.LengthDelimited).fork();
      for (let i = 0; i < message.forceChanges.length; i++)
        writer.int32(message.forceChanges[i]);
      writer.join();
    }
    for (let i = 0; i < message.signedBy.length; i++)
      writer.tag(5, WireType.LengthDelimited).string(message.signedBy[i]);
    if (message.store)
      StoreId.internalBinaryWrite(
        message.store,
        writer.tag(6, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.waitToBecomeEffective)
      Duration.internalBinaryWrite(
        message.waitToBecomeEffective,
        writer.tag(7, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AuthorizeRequest = new AuthorizeRequest$Type();
class AuthorizeRequest_Proposal$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.AuthorizeRequest.Proposal",
      [
        {
          no: 1,
          name: "change",
          kind: "enum",
          T: () => [
            "com.digitalasset.canton.protocol.v30.Enums.TopologyChangeOp",
            Enums_TopologyChangeOp,
            "TOPOLOGY_CHANGE_OP_"
          ]
        },
        {
          no: 2,
          name: "serial",
          kind: "scalar",
          T: 13
        },
        {
          no: 3,
          name: "mapping",
          kind: "message",
          T: () => TopologyMapping
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.change = 0;
    message.serial = 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 /* com.digitalasset.canton.protocol.v30.Enums.TopologyChangeOp change */
        1:
          message.change = reader.int32();
          break;
        case /* uint32 serial */
        2:
          message.serial = reader.uint32();
          break;
        case /* com.digitalasset.canton.protocol.v30.TopologyMapping mapping */
        3:
          message.mapping = TopologyMapping.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.mapping
          );
          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.change !== 0)
      writer.tag(1, WireType.Varint).int32(message.change);
    if (message.serial !== 0)
      writer.tag(2, WireType.Varint).uint32(message.serial);
    if (message.mapping)
      TopologyMapping.internalBinaryWrite(
        message.mapping,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AuthorizeRequest_Proposal = new AuthorizeRequest_Proposal$Type();
class AuthorizeResponse$Type extends MessageType {
  constructor() {
    super("com.digitalasset.canton.topology.admin.v30.AuthorizeResponse", [
      {
        no: 1,
        name: "transaction",
        kind: "message",
        T: () => SignedTopologyTransaction
      }
    ]);
  }
  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.digitalasset.canton.protocol.v30.SignedTopologyTransaction transaction */
        1:
          message.transaction = SignedTopologyTransaction.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.transaction
          );
          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)
      SignedTopologyTransaction.internalBinaryWrite(
        message.transaction,
        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 AuthorizeResponse = new AuthorizeResponse$Type();
class AddTransactionsRequest$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.AddTransactionsRequest",
      [
        {
          no: 1,
          name: "transactions",
          kind: "message",
          repeat: 2,
          T: () => SignedTopologyTransaction
        },
        {
          no: 2,
          name: "force_changes",
          kind: "enum",
          repeat: 1,
          T: () => [
            "com.digitalasset.canton.topology.admin.v30.ForceFlag",
            ForceFlag,
            "FORCE_FLAG_"
          ]
        },
        { no: 3, name: "store", kind: "message", T: () => StoreId },
        {
          no: 7,
          name: "wait_to_become_effective",
          kind: "message",
          T: () => Duration
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.transactions = [];
    message.forceChanges = [];
    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.digitalasset.canton.protocol.v30.SignedTopologyTransaction transactions */
        1:
          message.transactions.push(
            SignedTopologyTransaction.internalBinaryRead(
              reader,
              reader.uint32(),
              options
            )
          );
          break;
        case /* repeated com.digitalasset.canton.topology.admin.v30.ForceFlag force_changes */
        2:
          if (wireType === WireType.LengthDelimited)
            for (let e = reader.int32() + reader.pos; reader.pos < e; )
              message.forceChanges.push(reader.int32());
          else message.forceChanges.push(reader.int32());
          break;
        case /* com.digitalasset.canton.topology.admin.v30.StoreId store */
        3:
          message.store = StoreId.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.store
          );
          break;
        case /* google.protobuf.Duration wait_to_become_effective */
        7:
          message.waitToBecomeEffective = Duration.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.waitToBecomeEffective
          );
          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.transactions.length; i++)
      SignedTopologyTransaction.internalBinaryWrite(
        message.transactions[i],
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.forceChanges.length) {
      writer.tag(2, WireType.LengthDelimited).fork();
      for (let i = 0; i < message.forceChanges.length; i++)
        writer.int32(message.forceChanges[i]);
      writer.join();
    }
    if (message.store)
      StoreId.internalBinaryWrite(
        message.store,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.waitToBecomeEffective)
      Duration.internalBinaryWrite(
        message.waitToBecomeEffective,
        writer.tag(7, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AddTransactionsRequest = new AddTransactionsRequest$Type();
class AddTransactionsResponse$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.AddTransactionsResponse",
      []
    );
  }
  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 AddTransactionsResponse = new AddTransactionsResponse$Type();
class ImportTopologySnapshotRequest$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.ImportTopologySnapshotRequest",
      [
        {
          no: 1,
          name: "topology_snapshot",
          kind: "scalar",
          T: 12
        },
        { no: 2, name: "store", kind: "message", T: () => StoreId },
        {
          no: 3,
          name: "wait_to_become_effective",
          kind: "message",
          T: () => Duration
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.topologySnapshot = 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 /* bytes topology_snapshot */
        1:
          message.topologySnapshot = reader.bytes();
          break;
        case /* com.digitalasset.canton.topology.admin.v30.StoreId store */
        2:
          message.store = StoreId.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.store
          );
          break;
        case /* google.protobuf.Duration wait_to_become_effective */
        3:
          message.waitToBecomeEffective = Duration.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.waitToBecomeEffective
          );
          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.topologySnapshot.length)
      writer.tag(1, WireType.LengthDelimited).bytes(message.topologySnapshot);
    if (message.store)
      StoreId.internalBinaryWrite(
        message.store,
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.waitToBecomeEffective)
      Duration.internalBinaryWrite(
        message.waitToBecomeEffective,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const ImportTopologySnapshotRequest = new ImportTopologySnapshotRequest$Type();
class ImportTopologySnapshotResponse$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.ImportTopologySnapshotResponse",
      []
    );
  }
  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 ImportTopologySnapshotResponse = new ImportTopologySnapshotResponse$Type();
class SignTransactionsRequest$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.SignTransactionsRequest",
      [
        {
          no: 1,
          name: "transactions",
          kind: "message",
          repeat: 2,
          T: () => SignedTopologyTransaction
        },
        {
          no: 2,
          name: "signed_by",
          kind: "scalar",
          repeat: 2,
          T: 9
        },
        { no: 3, name: "store", kind: "message", T: () => StoreId },
        {
          no: 4,
          name: "force_flags",
          kind: "enum",
          repeat: 1,
          T: () => [
            "com.digitalasset.canton.topology.admin.v30.ForceFlag",
            ForceFlag,
            "FORCE_FLAG_"
          ]
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.transactions = [];
    message.signedBy = [];
    message.forceFlags = [];
    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.digitalasset.canton.protocol.v30.SignedTopologyTransaction transactions */
        1:
          message.transactions.push(
            SignedTopologyTransaction.internalBinaryRead(
              reader,
              reader.uint32(),
              options
            )
          );
          break;
        case /* repeated string signed_by */
        2:
          message.signedBy.push(reader.string());
          break;
        case /* com.digitalasset.canton.topology.admin.v30.StoreId store */
        3:
          message.store = StoreId.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.store
          );
          break;
        case /* repeated com.digitalasset.canton.topology.admin.v30.ForceFlag force_flags */
        4:
          if (wireType === WireType.LengthDelimited)
            for (let e = reader.int32() + reader.pos; reader.pos < e; )
              message.forceFlags.push(reader.int32());
          else message.forceFlags.push(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 ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    for (let i = 0; i < message.transactions.length; i++)
      SignedTopologyTransaction.internalBinaryWrite(
        message.transactions[i],
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    for (let i = 0; i < message.signedBy.length; i++)
      writer.tag(2, WireType.LengthDelimited).string(message.signedBy[i]);
    if (message.store)
      StoreId.internalBinaryWrite(
        message.store,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.forceFlags.length) {
      writer.tag(4, WireType.LengthDelimited).fork();
      for (let i = 0; i < message.forceFlags.length; i++)
        writer.int32(message.forceFlags[i]);
      writer.join();
    }
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const SignTransactionsRequest = new SignTransactionsRequest$Type();
class SignTransactionsResponse$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.SignTransactionsResponse",
      [
        {
          no: 1,
          name: "transactions",
          kind: "message",
          repeat: 2,
          T: () => SignedTopologyTransaction
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.transactions = [];
    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.digitalasset.canton.protocol.v30.SignedTopologyTransaction transactions */
        1:
          message.transactions.push(
            SignedTopologyTransaction.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.transactions.length; i++)
      SignedTopologyTransaction.internalBinaryWrite(
        message.transactions[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 SignTransactionsResponse = new SignTransactionsResponse$Type();
class CreateTemporaryTopologyStoreRequest$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.CreateTemporaryTopologyStoreRequest",
      [
        {
          no: 1,
          name: "name",
          kind: "scalar",
          T: 9
        },
        {
          no: 2,
          name: "protocol_version",
          kind: "scalar",
          T: 13
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.name = "";
    message.protocolVersion = 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 name */
        1:
          message.name = reader.string();
          break;
        case /* uint32 protocol_version */
        2:
          message.protocolVersion = reader.uint32();
          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.name !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.name);
    if (message.protocolVersion !== 0)
      writer.tag(2, WireType.Varint).uint32(message.protocolVersion);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const CreateTemporaryTopologyStoreRequest = new CreateTemporaryTopologyStoreRequest$Type();
class CreateTemporaryTopologyStoreResponse$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.CreateTemporaryTopologyStoreResponse",
      [
        {
          no: 1,
          name: "store_id",
          kind: "message",
          T: () => StoreId_Temporary
        }
      ]
    );
  }
  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.digitalasset.canton.topology.admin.v30.StoreId.Temporary store_id */
        1:
          message.storeId = StoreId_Temporary.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.storeId
          );
          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.storeId)
      StoreId_Temporary.internalBinaryWrite(
        message.storeId,
        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 CreateTemporaryTopologyStoreResponse = new CreateTemporaryTopologyStoreResponse$Type();
class DropTemporaryTopologyStoreRequest$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.DropTemporaryTopologyStoreRequest",
      [
        {
          no: 1,
          name: "store_id",
          kind: "message",
          T: () => StoreId_Temporary
        }
      ]
    );
  }
  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.digitalasset.canton.topology.admin.v30.StoreId.Temporary store_id */
        1:
          message.storeId = StoreId_Temporary.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.storeId
          );
          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.storeId)
      StoreId_Temporary.internalBinaryWrite(
        message.storeId,
        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 DropTemporaryTopologyStoreRequest = new DropTemporaryTopologyStoreRequest$Type();
class DropTemporaryTopologyStoreResponse$Type extends MessageType {
  constructor() {
    super(
      "com.digitalasset.canton.topology.admin.v30.DropTemporaryTopologyStoreResponse",
      []
    );
  }
  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 DropTemporaryTopologyStoreResponse = new DropTemporaryTopologyStoreResponse$Type();
const TopologyManagerWriteService = new ServiceType(
  "com.digitalasset.canton.topology.admin.v30.TopologyManagerWriteService",
  [
    {
      name: "Authorize",
      options: {},
      I: AuthorizeRequest,
      O: AuthorizeResponse
    },
    {
      name: "AddTransactions",
      options: {},
      I: AddTransactionsRequest,
      O: AddTransactionsResponse
    },
    {
      name: "ImportTopologySnapshot",
      clientStreaming: true,
      options: {},
      I: ImportTopologySnapshotRequest,
      O: ImportTopologySnapshotResponse
    },
    {
      name: "SignTransactions",
      options: {},
      I: SignTransactionsRequest,
      O: SignTransactionsResponse
    },
    {
      name: "GenerateTransactions",
      options: {},
      I: GenerateTransactionsRequest,
      O: GenerateTransactionsResponse
    },
    {
      name: "CreateTemporaryTopologyStore",
      options: {},
      I: CreateTemporaryTopologyStoreRequest,
      O: CreateTemporaryTopologyStoreResponse
    },
    {
      name: "DropTemporaryTopologyStore",
      options: {},
      I: DropTemporaryTopologyStoreRequest,
      O: DropTemporaryTopologyStoreResponse
    }
  ]
);
export {
  AddTransactionsRequest,
  AddTransactionsResponse,
  AuthorizeRequest,
  AuthorizeRequest_Proposal,
  AuthorizeResponse,
  CreateTemporaryTopologyStoreRequest,
  CreateTemporaryTopologyStoreResponse,
  DropTemporaryTopologyStoreRequest,
  DropTemporaryTopologyStoreResponse,
  ForceFlag,
  GenerateTransactionsRequest,
  GenerateTransactionsRequest_Proposal,
  GenerateTransactionsResponse,
  GenerateTransactionsResponse_GeneratedTransaction,
  ImportTopologySnapshotRequest,
  ImportTopologySnapshotResponse,
  SignTransactionsRequest,
  SignTransactionsResponse,
  TopologyManagerWriteService
};
//# sourceMappingURL=topology_manager_write_service.js.map