//@ts-nocheck
import { Context, VerificationMethod, Service, LinkedResource, LinkedClaim, AccordedRight, LinkedEntity, IidMetadata } from "./types";
import * as _m0 from "protobufjs/minimal";
import { isSet } from "../../../helpers";
function createBaseIidDocument() {
  return {
    context: [],
    id: "",
    controller: [],
    verificationMethod: [],
    service: [],
    authentication: [],
    assertionMethod: [],
    keyAgreement: [],
    capabilityInvocation: [],
    capabilityDelegation: [],
    linkedResource: [],
    linkedClaim: [],
    accordedRight: [],
    linkedEntity: [],
    alsoKnownAs: "",
    metadata: undefined
  };
}
export const IidDocument = {
  encode(message, writer = _m0.Writer.create()) {
    for (const v of message.context) {
      Context.encode(v, writer.uint32(10).fork()).ldelim();
    }
    if (message.id !== "") {
      writer.uint32(18).string(message.id);
    }
    for (const v of message.controller) {
      writer.uint32(26).string(v);
    }
    for (const v of message.verificationMethod) {
      VerificationMethod.encode(v, writer.uint32(34).fork()).ldelim();
    }
    for (const v of message.service) {
      Service.encode(v, writer.uint32(42).fork()).ldelim();
    }
    for (const v of message.authentication) {
      writer.uint32(50).string(v);
    }
    for (const v of message.assertionMethod) {
      writer.uint32(58).string(v);
    }
    for (const v of message.keyAgreement) {
      writer.uint32(66).string(v);
    }
    for (const v of message.capabilityInvocation) {
      writer.uint32(74).string(v);
    }
    for (const v of message.capabilityDelegation) {
      writer.uint32(82).string(v);
    }
    for (const v of message.linkedResource) {
      LinkedResource.encode(v, writer.uint32(90).fork()).ldelim();
    }
    for (const v of message.linkedClaim) {
      LinkedClaim.encode(v, writer.uint32(98).fork()).ldelim();
    }
    for (const v of message.accordedRight) {
      AccordedRight.encode(v, writer.uint32(106).fork()).ldelim();
    }
    for (const v of message.linkedEntity) {
      LinkedEntity.encode(v, writer.uint32(114).fork()).ldelim();
    }
    if (message.alsoKnownAs !== "") {
      writer.uint32(122).string(message.alsoKnownAs);
    }
    if (message.metadata !== undefined) {
      IidMetadata.encode(message.metadata, writer.uint32(130).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseIidDocument();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.context.push(Context.decode(reader, reader.uint32()));
          break;
        case 2:
          message.id = reader.string();
          break;
        case 3:
          message.controller.push(reader.string());
          break;
        case 4:
          message.verificationMethod.push(VerificationMethod.decode(reader, reader.uint32()));
          break;
        case 5:
          message.service.push(Service.decode(reader, reader.uint32()));
          break;
        case 6:
          message.authentication.push(reader.string());
          break;
        case 7:
          message.assertionMethod.push(reader.string());
          break;
        case 8:
          message.keyAgreement.push(reader.string());
          break;
        case 9:
          message.capabilityInvocation.push(reader.string());
          break;
        case 10:
          message.capabilityDelegation.push(reader.string());
          break;
        case 11:
          message.linkedResource.push(LinkedResource.decode(reader, reader.uint32()));
          break;
        case 12:
          message.linkedClaim.push(LinkedClaim.decode(reader, reader.uint32()));
          break;
        case 13:
          message.accordedRight.push(AccordedRight.decode(reader, reader.uint32()));
          break;
        case 14:
          message.linkedEntity.push(LinkedEntity.decode(reader, reader.uint32()));
          break;
        case 15:
          message.alsoKnownAs = reader.string();
          break;
        case 16:
          message.metadata = IidMetadata.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      context: Array.isArray(object === null || object === void 0 ? void 0 : object.context) ? object.context.map(e => Context.fromJSON(e)) : [],
      id: isSet(object.id) ? String(object.id) : "",
      controller: Array.isArray(object === null || object === void 0 ? void 0 : object.controller) ? object.controller.map(e => String(e)) : [],
      verificationMethod: Array.isArray(object === null || object === void 0 ? void 0 : object.verificationMethod) ? object.verificationMethod.map(e => VerificationMethod.fromJSON(e)) : [],
      service: Array.isArray(object === null || object === void 0 ? void 0 : object.service) ? object.service.map(e => Service.fromJSON(e)) : [],
      authentication: Array.isArray(object === null || object === void 0 ? void 0 : object.authentication) ? object.authentication.map(e => String(e)) : [],
      assertionMethod: Array.isArray(object === null || object === void 0 ? void 0 : object.assertionMethod) ? object.assertionMethod.map(e => String(e)) : [],
      keyAgreement: Array.isArray(object === null || object === void 0 ? void 0 : object.keyAgreement) ? object.keyAgreement.map(e => String(e)) : [],
      capabilityInvocation: Array.isArray(object === null || object === void 0 ? void 0 : object.capabilityInvocation) ? object.capabilityInvocation.map(e => String(e)) : [],
      capabilityDelegation: Array.isArray(object === null || object === void 0 ? void 0 : object.capabilityDelegation) ? object.capabilityDelegation.map(e => String(e)) : [],
      linkedResource: Array.isArray(object === null || object === void 0 ? void 0 : object.linkedResource) ? object.linkedResource.map(e => LinkedResource.fromJSON(e)) : [],
      linkedClaim: Array.isArray(object === null || object === void 0 ? void 0 : object.linkedClaim) ? object.linkedClaim.map(e => LinkedClaim.fromJSON(e)) : [],
      accordedRight: Array.isArray(object === null || object === void 0 ? void 0 : object.accordedRight) ? object.accordedRight.map(e => AccordedRight.fromJSON(e)) : [],
      linkedEntity: Array.isArray(object === null || object === void 0 ? void 0 : object.linkedEntity) ? object.linkedEntity.map(e => LinkedEntity.fromJSON(e)) : [],
      alsoKnownAs: isSet(object.alsoKnownAs) ? String(object.alsoKnownAs) : "",
      metadata: isSet(object.metadata) ? IidMetadata.fromJSON(object.metadata) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.context) {
      obj.context = message.context.map(e => e ? Context.toJSON(e) : undefined);
    } else {
      obj.context = [];
    }
    message.id !== undefined && (obj.id = message.id);
    if (message.controller) {
      obj.controller = message.controller.map(e => e);
    } else {
      obj.controller = [];
    }
    if (message.verificationMethod) {
      obj.verificationMethod = message.verificationMethod.map(e => e ? VerificationMethod.toJSON(e) : undefined);
    } else {
      obj.verificationMethod = [];
    }
    if (message.service) {
      obj.service = message.service.map(e => e ? Service.toJSON(e) : undefined);
    } else {
      obj.service = [];
    }
    if (message.authentication) {
      obj.authentication = message.authentication.map(e => e);
    } else {
      obj.authentication = [];
    }
    if (message.assertionMethod) {
      obj.assertionMethod = message.assertionMethod.map(e => e);
    } else {
      obj.assertionMethod = [];
    }
    if (message.keyAgreement) {
      obj.keyAgreement = message.keyAgreement.map(e => e);
    } else {
      obj.keyAgreement = [];
    }
    if (message.capabilityInvocation) {
      obj.capabilityInvocation = message.capabilityInvocation.map(e => e);
    } else {
      obj.capabilityInvocation = [];
    }
    if (message.capabilityDelegation) {
      obj.capabilityDelegation = message.capabilityDelegation.map(e => e);
    } else {
      obj.capabilityDelegation = [];
    }
    if (message.linkedResource) {
      obj.linkedResource = message.linkedResource.map(e => e ? LinkedResource.toJSON(e) : undefined);
    } else {
      obj.linkedResource = [];
    }
    if (message.linkedClaim) {
      obj.linkedClaim = message.linkedClaim.map(e => e ? LinkedClaim.toJSON(e) : undefined);
    } else {
      obj.linkedClaim = [];
    }
    if (message.accordedRight) {
      obj.accordedRight = message.accordedRight.map(e => e ? AccordedRight.toJSON(e) : undefined);
    } else {
      obj.accordedRight = [];
    }
    if (message.linkedEntity) {
      obj.linkedEntity = message.linkedEntity.map(e => e ? LinkedEntity.toJSON(e) : undefined);
    } else {
      obj.linkedEntity = [];
    }
    message.alsoKnownAs !== undefined && (obj.alsoKnownAs = message.alsoKnownAs);
    message.metadata !== undefined && (obj.metadata = message.metadata ? IidMetadata.toJSON(message.metadata) : undefined);
    return obj;
  },
  fromPartial(object) {
    var _object$context, _object$id, _object$controller, _object$verificationM, _object$service, _object$authenticatio, _object$assertionMeth, _object$keyAgreement, _object$capabilityInv, _object$capabilityDel, _object$linkedResourc, _object$linkedClaim, _object$accordedRight, _object$linkedEntity, _object$alsoKnownAs;
    const message = createBaseIidDocument();
    message.context = ((_object$context = object.context) === null || _object$context === void 0 ? void 0 : _object$context.map(e => Context.fromPartial(e))) || [];
    message.id = (_object$id = object.id) !== null && _object$id !== void 0 ? _object$id : "";
    message.controller = ((_object$controller = object.controller) === null || _object$controller === void 0 ? void 0 : _object$controller.map(e => e)) || [];
    message.verificationMethod = ((_object$verificationM = object.verificationMethod) === null || _object$verificationM === void 0 ? void 0 : _object$verificationM.map(e => VerificationMethod.fromPartial(e))) || [];
    message.service = ((_object$service = object.service) === null || _object$service === void 0 ? void 0 : _object$service.map(e => Service.fromPartial(e))) || [];
    message.authentication = ((_object$authenticatio = object.authentication) === null || _object$authenticatio === void 0 ? void 0 : _object$authenticatio.map(e => e)) || [];
    message.assertionMethod = ((_object$assertionMeth = object.assertionMethod) === null || _object$assertionMeth === void 0 ? void 0 : _object$assertionMeth.map(e => e)) || [];
    message.keyAgreement = ((_object$keyAgreement = object.keyAgreement) === null || _object$keyAgreement === void 0 ? void 0 : _object$keyAgreement.map(e => e)) || [];
    message.capabilityInvocation = ((_object$capabilityInv = object.capabilityInvocation) === null || _object$capabilityInv === void 0 ? void 0 : _object$capabilityInv.map(e => e)) || [];
    message.capabilityDelegation = ((_object$capabilityDel = object.capabilityDelegation) === null || _object$capabilityDel === void 0 ? void 0 : _object$capabilityDel.map(e => e)) || [];
    message.linkedResource = ((_object$linkedResourc = object.linkedResource) === null || _object$linkedResourc === void 0 ? void 0 : _object$linkedResourc.map(e => LinkedResource.fromPartial(e))) || [];
    message.linkedClaim = ((_object$linkedClaim = object.linkedClaim) === null || _object$linkedClaim === void 0 ? void 0 : _object$linkedClaim.map(e => LinkedClaim.fromPartial(e))) || [];
    message.accordedRight = ((_object$accordedRight = object.accordedRight) === null || _object$accordedRight === void 0 ? void 0 : _object$accordedRight.map(e => AccordedRight.fromPartial(e))) || [];
    message.linkedEntity = ((_object$linkedEntity = object.linkedEntity) === null || _object$linkedEntity === void 0 ? void 0 : _object$linkedEntity.map(e => LinkedEntity.fromPartial(e))) || [];
    message.alsoKnownAs = (_object$alsoKnownAs = object.alsoKnownAs) !== null && _object$alsoKnownAs !== void 0 ? _object$alsoKnownAs : "";
    message.metadata = object.metadata !== undefined && object.metadata !== null ? IidMetadata.fromPartial(object.metadata) : undefined;
    return message;
  }
};