import { Empty } from "../../../../../../google/protobuf/empty.js";
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 { Timestamp } from "../../../../../../google/protobuf/timestamp.js";
class GetTimeRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.testing.GetTimeRequest", []);
  }
  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 GetTimeRequest = new GetTimeRequest$Type();
class GetTimeResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.testing.GetTimeResponse", [
      {
        no: 1,
        name: "current_time",
        kind: "message",
        T: () => Timestamp
      }
    ]);
  }
  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 /* google.protobuf.Timestamp current_time */
        1:
          message.currentTime = Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.currentTime
          );
          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.currentTime)
      Timestamp.internalBinaryWrite(
        message.currentTime,
        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 GetTimeResponse = new GetTimeResponse$Type();
class SetTimeRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.testing.SetTimeRequest", [
      {
        no: 1,
        name: "current_time",
        kind: "message",
        T: () => Timestamp
      },
      { no: 2, name: "new_time", kind: "message", T: () => Timestamp }
    ]);
  }
  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 /* google.protobuf.Timestamp current_time */
        1:
          message.currentTime = Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.currentTime
          );
          break;
        case /* google.protobuf.Timestamp new_time */
        2:
          message.newTime = Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.newTime
          );
          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.currentTime)
      Timestamp.internalBinaryWrite(
        message.currentTime,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.newTime)
      Timestamp.internalBinaryWrite(
        message.newTime,
        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 SetTimeRequest = new SetTimeRequest$Type();
const TimeService = new ServiceType(
  "com.daml.ledger.api.v2.testing.TimeService",
  [
    { name: "GetTime", options: {}, I: GetTimeRequest, O: GetTimeResponse },
    { name: "SetTime", options: {}, I: SetTimeRequest, O: Empty }
  ]
);
export {
  GetTimeRequest,
  GetTimeResponse,
  SetTimeRequest,
  TimeService
};
//# sourceMappingURL=time_service.js.map