import { CredentialMultiInstanceState, CredentialMultiInstanceUseMode, CredentialMultiInstanceUseUpdateMode } from "./credentialUseTypes.mjs";
import { SdJwtVc } from "../modules/sd-jwt-vc/SdJwtVcService.mjs";
import { SdJwtVcRecord } from "../modules/sd-jwt-vc/repository/SdJwtVcRecord.mjs";
import "../modules/sd-jwt-vc/repository/index.mjs";
import { MdocRecord } from "../modules/mdoc/repository/MdocRecord.mjs";
import "../modules/mdoc/repository/index.mjs";
import { W3cCredentialRecord } from "../modules/vc/repository/W3cCredentialRecord.mjs";
import { W3cV2CredentialRecord } from "../modules/vc/repository/W3cV2CredentialRecord.mjs";
import "../modules/vc/repository/index.mjs";
import { W3cV2VerifiableCredential } from "../modules/vc/models/credential/W3cV2VerifiableCredential.mjs";
import { W3cVerifiableCredential } from "../modules/vc/models/credential/W3cVerifiableCredential.mjs";
import "../modules/vc/index.mjs";
import { Mdoc } from "../modules/mdoc/Mdoc.mjs";
import { AgentContext } from "../agent/context/AgentContext.mjs";
import "../agent/index.mjs";

//#region src/utils/credentialUse.d.ts
type CredentialRecord = W3cCredentialRecord | SdJwtVcRecord | MdocRecord | W3cV2CredentialRecord;
type CredentialInstanceReturnType<Record extends CredentialRecord> = Record extends W3cCredentialRecord ? W3cVerifiableCredential : Record extends W3cV2CredentialRecord ? W3cV2VerifiableCredential : Record extends SdJwtVcRecord ? SdJwtVc : Record extends MdocRecord ? Mdoc : CredentialRecord;
/**
 * Checks whether an instance can be used from the provided record based on
 * the required credential use mode.
 */
declare function canUseInstanceFromCredentialRecord({
  credentialRecord,
  useMode
}: {
  credentialRecord: CredentialRecord;
  useMode: CredentialMultiInstanceUseMode;
}): boolean;
interface UseInstanceFromCredentialRecordOptions<Record extends CredentialRecord> {
  agentContext: AgentContext;
  /**
   * Which mode to use for usage of the credential instance. See {@link CredentialMultiInstanceUseMode} for
   * more information on the available options
   */
  useMode: CredentialMultiInstanceUseMode;
  credentialRecord: Record;
  /**
   * The update mode for the credential record when a new instance is used.
   *
   * @default `CredentialMultiInstanceUseUpdateMode.RefetchAndUpdateWithLock`
   */
  updateMode?: CredentialMultiInstanceUseUpdateMode;
}
interface UseInstanceFromCredentialRecordReturn<Record extends CredentialRecord> {
  /**
   * The credential instance with the kms key id
   */
  credentialInstance: CredentialInstanceReturnType<Record>;
  /**
   * If the first instance was used, this value will be `true`. The first time
   * the first instance is used, technically the credential is not reused yet,
   * but we make no distinction between this.
   */
  isReused: boolean;
  /**
   * Whether the last new instance was used. If `isReused` is `true` this value will
   * always be `false`.
   *
   * The last new instance is the second entry in the mdoc instances, since the first
   * one is reserved for 'reused' usage.
   */
  isLastNewInstance: boolean;
}
/**
 * Extract an instance with the correct kms key id from the credential instances
 * on the record. Note that if an instance is extracted (that is not reused) it
 * will remove the instance from the record, and the record should be updated in
 * storage after usage.
 *
 * Note that the last credential instance is never removed from the record. So if the
 * method indicates the last instance has been used, you should remove the credential
 * from storage if you don't want it to be used anymore in the future.
 */
declare function useInstanceFromCredentialRecord<Record extends CredentialRecord>({
  credentialRecord,
  useMode,
  agentContext,
  updateMode
}: UseInstanceFromCredentialRecordOptions<Record>): Promise<UseInstanceFromCredentialRecordReturn<Record>>;
//#endregion
export { UseInstanceFromCredentialRecordOptions, UseInstanceFromCredentialRecordReturn, canUseInstanceFromCredentialRecord, useInstanceFromCredentialRecord };
//# sourceMappingURL=credentialUse.d.mts.map