import TypedEnum from '../../generic/typed-enum.js';
import '../../generic/typed-bytes.js';
import '../../generic/typed-string.js';
import TypedArray from '../../generic/typed-array.js';
import '../../generic/typed-tuple.js';
import '../../generic/typed-null.js';
import '../../../utils/types/array.js';
import 'crypto';
import 'bs58';
import 'multiformats/bases/base58';
import 'varint';
import '../../../utils/encoding/ss-58.js';
import '../../generic/typed-number.js';
import '../../generic/typed-set.js';
import TypedMap from '../../generic/typed-map.js';
import TypedStruct from '../../generic/typed-struct.js';
import 'uuid';
import 'js-sha256';
import '../../public-keys/public-key.js';
import PublicKeySr25519Value from '../../public-keys/public-key-sr25519-value.js';
import PublicKeyEd25519Value from '../../public-keys/public-key-ed25519-value.js';
import PublicKeySecp256k1Value from '../../public-keys/public-key-secp256k1-value.js';
import PublicKeyX25519Value from '../../public-keys/public-key-x25519-value.js';
import '../../offchain-signatures/params/index.js';
import '../../offchain-signatures/public-keys/index.js';
import '../../offchain-signatures/curve-type.js';
import { VerificationRelationship } from './verification-relationship.js';
import '../../../vc/crypto/Bls12381BBDT16KeyPairDock2024.js';
import '../../../vc/crypto/Bls12381BBDT16MACDock2024.js';
import '../../../vc/crypto/Bls12381BBDT16MACProofDock2024.js';
import '../../../vc/crypto/Bls12381BBSKeyPairDock2023.js';
import '../../../vc/crypto/Bls12381BBSSignatureDock2022.js';
import '../../../vc/crypto/Bls12381BBSSignatureDock2023.js';
import '../../../vc/crypto/Bls12381BBSSignatureProofDock2022.js';
import '../../../vc/crypto/Bls12381BBSSignatureProofDock2023.js';
import '../../../vc/crypto/Bls12381BDDT16KeyPairDock2024.js';
import '../../../vc/crypto/Bls12381BDDT16MACDock2024.js';
import '../../../vc/crypto/Bls12381BDDT16MACProofDock2024.js';
import '../../../vc/crypto/Bls12381G2KeyPairDock2022.js';
import '../../../vc/crypto/Bls12381PSKeyPairDock2023.js';
import '../../../vc/crypto/Bls12381PSSignatureDock2023.js';
import '../../../vc/crypto/Bls12381PSSignatureProofDock2023.js';
import { Bls12381BBS23DockVerKeyName, Bls12381BBSDockVerKeyName, Bls12381PSDockVerKeyName } from '../../../vc/crypto/constants.js';
import '@juanelas/base64';
import '../../../keypairs/keypair-secp256k1.js';
import '../../../vc/crypto/common/CustomLinkedDataSignature.js';
import '@stablelib/ed25519';
import '../../signatures/signature-value.js';
import '../../signatures/signature.js';
import '../../../keypairs/dock-keypair.js';
import '@transmute/json-web-signature';
import { VerificationMethodRef } from '../document/verification-method-ref.js';
import { BBSPublicKeyValue, BBSPlusPublicKeyValue, PSPublicKeyValue } from '../../offchain-signatures/public-keys/value.js';
import '../../../utils/types/iterable.js';
import '../../../utils/types/object.js';
import '../../../utils/interfaces.js';
import '../../../utils/assert.js';
import '../../../utils/error.js';
import '../../../utils/inheritance.js';
import '../../../utils/types/set.js';
import '../../generic/with-base.js';
import '../../../utils/types/bytes.js';
import '../../../utils/types/string.js';
import '../../generic/with-catch-null.js';
import '../../generic/with-eq.js';
import '../../generic/any-of.js';
import '../../generic/with-from.js';
import '../../generic/with-from-json-bytes.js';
import '../../generic/create-placeholder.js';
import 'blake2b';
import '../../generic/sized.js';
import '../../../utils/types/number.js';
import '../../offchain-signatures/params/value.js';
import '../../generic/option.js';
import '../../offchain-signatures/params/id.js';
import '../../generic/typed-uuid.js';
import '../../generic/with-from-dock-id.js';
import './typed-did/index.js';
import './typed-did/did-method-key/did-method-key-public-key.js';
import '../../../utils/encoding/base-58-btc.js';
import '../../generic/with-qualifier.js';
import './constants.js';
import './typed-did/signature.js';
import './typed-did/did-method-key/did-method-key-signature.js';
import '../../signatures/signature-ed25519-value.js';
import '../../signatures/signature-secp256k1-value.js';
import './typed-did/dock-did-value.js';
import '../../generic/utils.js';
import '../../generic/typed-bytes-array.js';
import './typed-did/cheqd-did.js';
import '../../generic/with-prop.js';
import '../../generic/with-props.js';
import '../../offchain-signatures/public-keys/ref.js';
import '../../offchain-signatures/public-keys/id.js';
import '@docknetwork/crypto-wasm-ts';
import '../../../vc/crypto/common/DockCryptoKeyPair.js';
import '@docknetwork/crypto-wasm-ts/lib/index.js';
import '../../../vc/crypto/common/DockCryptoSignature.js';
import 'jsonld-signatures';
import 'json-stringify-deterministic';
import 'semver/preload.js';
import '../../../vc/crypto/common/DockCryptoSignatureProof.js';
import 'elliptic';
import 'base64url';
import 'jsonld';
import '../../../vc/jws.js';
import '../../signatures/signature-sr25519-value.js';

/**
 * Class representing either of possible DidKeys.
 * @class
 * @extends {TypedEnum}
 */
class DidKeyValue extends TypedEnum {
  static get VerKeyType() {
    return this.Class.VerKeyType;
  }
}

/**
 * Class representing Ed25519 PublicKey
 * @class
 * @extends {PublicKey}
 */
class DidKeyEd25519PublicKey extends DidKeyValue {
  static Type = 'ed25519';

  static Class = PublicKeyEd25519Value;
}
/**
 * Class representing Secp256k1 PublicKey
 * @class
 * @extends {PublicKey}
 */
class DidKeySecp256k1PublicKey extends DidKeyValue {
  static Type = 'secp256k1';

  static Class = PublicKeySecp256k1Value;
}
/**
 * Class representing Sr25519 PublicKey
 * @class
 * @extends {PublicKey}
 */
class DidKeySr25519PublicKey extends DidKeyValue {
  static Type = 'sr25519';

  static Class = PublicKeySr25519Value;
}
/**
 * Class representing X25519 PublicKey
 * @class
 * @extends {PublicKey}
 */
class DidKeyX25519PublicKey extends DidKeyValue {
  static Type = 'x25519';

  static Class = PublicKeyX25519Value;
}
class DidKeyBBSPublicKey extends DidKeyValue {
  static Class = BBSPublicKeyValue;

  static Type = 'bbs';

  static VerKeyType = Bls12381BBS23DockVerKeyName;
}
class DidKeyBBSPlusPublicKey extends DidKeyValue {
  static Class = BBSPlusPublicKeyValue;

  static Type = 'bbsPlus';

  static VerKeyType = Bls12381BBSDockVerKeyName;
}
class DidKeyPSPublicKey extends DidKeyValue {
  static Class = PSPublicKeyValue;

  static Type = 'ps';

  static VerKeyType = Bls12381PSDockVerKeyName;
}

DidKeyValue.bindVariants(
  DidKeyEd25519PublicKey,
  DidKeySecp256k1PublicKey,
  DidKeySr25519PublicKey,
  DidKeyX25519PublicKey,
  DidKeyBBSPublicKey,
  DidKeyBBSPlusPublicKey,
  DidKeyPSPublicKey,
);

const Signing = [
  DidKeyEd25519PublicKey,
  DidKeySr25519PublicKey,
  DidKeySecp256k1PublicKey,
];

const Assertion = [
  DidKeyBBSPublicKey,
  DidKeyBBSPlusPublicKey,
  DidKeyPSPublicKey,
];

class DidKey extends TypedStruct {
  static Classes = {
    publicKey: DidKeyValue,
    verRels: VerificationRelationship,
  };

  /**
   *
   * @param {DidKeyValue} pk
   * @param {VerificationRelationship} verRels
   */
  constructor(pk, verRels = new VerificationRelationship()) {
    const publicKey = DidKeyValue.from(pk);

    if (!+verRels) {
      if (
        Signing.some(
          (klass) => publicKey instanceof klass || publicKey instanceof klass.Class,
        )
      ) {
        verRels.setAllSigning();
      } else if (
        Assertion.some(
          (klass) => publicKey instanceof klass || publicKey instanceof klass.Class,
        )
      ) {
        verRels.setAssertion();
      } else {
        verRels.setKeyAgreement();
      }
    }

    super(publicKey, verRels);
  }

  static fromKeypair(keyPair, verRels) {
    return new this(keyPair.publicKey(), verRels);
  }

  isOffchain() {
    return Assertion.some((klass) => this.publicKey instanceof klass);
  }
}

class DidKeysList extends TypedArray {
  static Class = DidKey;
}

class DidKeys extends TypedMap {
  static KeyClass = VerificationMethodRef;

  static ValueClass = DidKey;
}

export { DidKey, DidKeyBBSPlusPublicKey, DidKeyBBSPublicKey, DidKeyEd25519PublicKey, DidKeyPSPublicKey, DidKeySecp256k1PublicKey, DidKeySr25519PublicKey, DidKeyValue, DidKeyX25519PublicKey, DidKeys, DidKeysList };
//# sourceMappingURL=did-key.js.map
