"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 package_service_exports = {};
__export(package_service_exports, {
  GetPackageRequest: () => GetPackageRequest,
  GetPackageResponse: () => GetPackageResponse,
  GetPackageStatusRequest: () => GetPackageStatusRequest,
  GetPackageStatusResponse: () => GetPackageStatusResponse,
  HashFunction: () => HashFunction,
  ListPackagesRequest: () => ListPackagesRequest,
  ListPackagesResponse: () => ListPackagesResponse,
  PackageService: () => PackageService,
  PackageStatus: () => PackageStatus
});
module.exports = __toCommonJS(package_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 PackageStatus = /* @__PURE__ */ ((PackageStatus2) => {
  PackageStatus2[PackageStatus2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
  PackageStatus2[PackageStatus2["REGISTERED"] = 1] = "REGISTERED";
  return PackageStatus2;
})(PackageStatus || {});
var HashFunction = /* @__PURE__ */ ((HashFunction2) => {
  HashFunction2[HashFunction2["SHA256"] = 0] = "SHA256";
  return HashFunction2;
})(HashFunction || {});
class ListPackagesResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.ListPackagesResponse", [
      {
        no: 1,
        name: "package_ids",
        kind: "scalar",
        repeat: 2,
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.packageIds = [];
    if (value !== void 0)
      (0, import_runtime3.reflectionMergePartial)(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* repeated string package_ids */
        1:
          message.packageIds.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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    for (let i = 0; i < message.packageIds.length; i++)
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.packageIds[i]);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const ListPackagesResponse = new ListPackagesResponse$Type();
class GetPackageResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetPackageResponse", [
      {
        no: 1,
        name: "hash_function",
        kind: "enum",
        T: () => [
          "com.daml.ledger.api.v2.HashFunction",
          HashFunction,
          "HASH_FUNCTION_"
        ]
      },
      {
        no: 2,
        name: "archive_payload",
        kind: "scalar",
        T: 12
      },
      {
        no: 3,
        name: "hash",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.hashFunction = 0;
    message.archivePayload = new Uint8Array(0);
    message.hash = "";
    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.HashFunction hash_function */
        1:
          message.hashFunction = reader.int32();
          break;
        case /* bytes archive_payload */
        2:
          message.archivePayload = reader.bytes();
          break;
        case /* string hash */
        3:
          message.hash = 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.hashFunction !== 0)
      writer.tag(1, import_runtime.WireType.Varint).int32(message.hashFunction);
    if (message.archivePayload.length)
      writer.tag(2, import_runtime.WireType.LengthDelimited).bytes(message.archivePayload);
    if (message.hash !== "")
      writer.tag(3, import_runtime.WireType.LengthDelimited).string(message.hash);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetPackageResponse = new GetPackageResponse$Type();
class GetPackageStatusResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetPackageStatusResponse", [
      {
        no: 1,
        name: "package_status",
        kind: "enum",
        T: () => [
          "com.daml.ledger.api.v2.PackageStatus",
          PackageStatus,
          "PACKAGE_STATUS_"
        ]
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.packageStatus = 0;
    if (value !== void 0)
      (0, import_runtime3.reflectionMergePartial)(
        this,
        message,
        value
      );
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* com.daml.ledger.api.v2.PackageStatus package_status */
        1:
          message.packageStatus = reader.int32();
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.packageStatus !== 0)
      writer.tag(1, import_runtime.WireType.Varint).int32(message.packageStatus);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetPackageStatusResponse = new GetPackageStatusResponse$Type();
class ListPackagesRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.ListPackagesRequest", []);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      (0, import_runtime3.reflectionMergePartial)(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const ListPackagesRequest = new ListPackagesRequest$Type();
class GetPackageRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetPackageRequest", [
      {
        no: 1,
        name: "package_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.packageId = "";
    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 package_id */
        1:
          message.packageId = 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.packageId !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.packageId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetPackageRequest = new GetPackageRequest$Type();
class GetPackageStatusRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetPackageStatusRequest", [
      {
        no: 1,
        name: "package_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.packageId = "";
    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 package_id */
        1:
          message.packageId = 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.packageId !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.packageId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetPackageStatusRequest = new GetPackageStatusRequest$Type();
const PackageService = new import_runtime_rpc.ServiceType(
  "com.daml.ledger.api.v2.PackageService",
  [
    {
      name: "ListPackages",
      options: {},
      I: ListPackagesRequest,
      O: ListPackagesResponse
    },
    {
      name: "GetPackage",
      options: {},
      I: GetPackageRequest,
      O: GetPackageResponse
    },
    {
      name: "GetPackageStatus",
      options: {},
      I: GetPackageStatusRequest,
      O: GetPackageStatusResponse
    }
  ]
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  GetPackageRequest,
  GetPackageResponse,
  GetPackageStatusRequest,
  GetPackageStatusResponse,
  HashFunction,
  ListPackagesRequest,
  ListPackagesResponse,
  PackageService,
  PackageStatus
});
//# sourceMappingURL=package_service.cjs.map