"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var event_query_service_exports = {};
__export(event_query_service_exports, {
  Archived: () => Archived,
  Created: () => Created,
  EventQueryService: () => EventQueryService,
  GetEventsByContractIdRequest: () => GetEventsByContractIdRequest,
  GetEventsByContractIdResponse: () => GetEventsByContractIdResponse
});
module.exports = __toCommonJS(event_query_service_exports);
var import_runtime_rpc = require("@protobuf-ts/runtime-rpc");
var import_runtime = require("@protobuf-ts/runtime");
var import_runtime2 = require("@protobuf-ts/runtime");
var import_runtime3 = require("@protobuf-ts/runtime");
var import_runtime4 = require("@protobuf-ts/runtime");
var import_event = require("./event.cjs");
var import_event2 = require("./event.cjs");
var import_transaction_filter = require("./transaction_filter.cjs");
class GetEventsByContractIdRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetEventsByContractIdRequest", [
      {
        no: 1,
        name: "contract_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "requesting_parties",
        kind: "scalar",
        repeat: 2,
        T: 9
      },
      {
        no: 3,
        name: "event_format",
        kind: "message",
        T: () => import_transaction_filter.EventFormat
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.contractId = "";
    message.requestingParties = [];
    if (value !== void 0)
      (0, import_runtime3.reflectionMergePartial)(
        this,
        message,
        value
      );
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* string contract_id */
        1:
          message.contractId = reader.string();
          break;
        case /* repeated string requesting_parties = 2 [deprecated = true] */
        2:
          message.requestingParties.push(reader.string());
          break;
        case /* com.daml.ledger.api.v2.EventFormat event_format */
        3:
          message.eventFormat = import_transaction_filter.EventFormat.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.eventFormat
          );
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.contractId !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.contractId);
    for (let i = 0; i < message.requestingParties.length; i++)
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.requestingParties[i]);
    if (message.eventFormat)
      import_transaction_filter.EventFormat.internalBinaryWrite(
        message.eventFormat,
        writer.tag(3, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetEventsByContractIdRequest = new GetEventsByContractIdRequest$Type();
class GetEventsByContractIdResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetEventsByContractIdResponse", [
      { no: 1, name: "created", kind: "message", T: () => Created },
      { no: 2, name: "archived", kind: "message", T: () => Archived }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      (0, import_runtime3.reflectionMergePartial)(
        this,
        message,
        value
      );
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* com.daml.ledger.api.v2.Created created */
        1:
          message.created = Created.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.created
          );
          break;
        case /* com.daml.ledger.api.v2.Archived archived */
        2:
          message.archived = Archived.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.archived
          );
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.created)
      Created.internalBinaryWrite(
        message.created,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.archived)
      Archived.internalBinaryWrite(
        message.archived,
        writer.tag(2, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetEventsByContractIdResponse = new GetEventsByContractIdResponse$Type();
class Created$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.Created", [
      {
        no: 1,
        name: "created_event",
        kind: "message",
        T: () => import_event2.CreatedEvent
      },
      {
        no: 2,
        name: "synchronizer_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.synchronizerId = "";
    if (value !== void 0)
      (0, import_runtime3.reflectionMergePartial)(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* com.daml.ledger.api.v2.CreatedEvent created_event */
        1:
          message.createdEvent = import_event2.CreatedEvent.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.createdEvent
          );
          break;
        case /* string synchronizer_id */
        2:
          message.synchronizerId = reader.string();
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.createdEvent)
      import_event2.CreatedEvent.internalBinaryWrite(
        message.createdEvent,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.synchronizerId !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.synchronizerId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const Created = new Created$Type();
class Archived$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.Archived", [
      {
        no: 1,
        name: "archived_event",
        kind: "message",
        T: () => import_event.ArchivedEvent
      },
      {
        no: 2,
        name: "synchronizer_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.synchronizerId = "";
    if (value !== void 0)
      (0, import_runtime3.reflectionMergePartial)(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* com.daml.ledger.api.v2.ArchivedEvent archived_event */
        1:
          message.archivedEvent = import_event.ArchivedEvent.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.archivedEvent
          );
          break;
        case /* string synchronizer_id */
        2:
          message.synchronizerId = reader.string();
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.archivedEvent)
      import_event.ArchivedEvent.internalBinaryWrite(
        message.archivedEvent,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.synchronizerId !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.synchronizerId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const Archived = new Archived$Type();
const EventQueryService = new import_runtime_rpc.ServiceType(
  "com.daml.ledger.api.v2.EventQueryService",
  [
    {
      name: "GetEventsByContractId",
      options: {},
      I: GetEventsByContractIdRequest,
      O: GetEventsByContractIdResponse
    }
  ]
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Archived,
  Created,
  EventQueryService,
  GetEventsByContractIdRequest,
  GetEventsByContractIdResponse
});
//# sourceMappingURL=event_query_service.cjs.map