import '../../utils/types/array.js';
import 'crypto';
import 'bs58';
import 'multiformats/bases/base58';
import 'varint';
import '../../utils/encoding/ss-58.js';
import { parseDIDUrl } from '../../utils/ident/parsers.js';
import DIDResolver from './did-resolver.js';
import '../../utils/inheritance.js';
import '../../utils/types/object.js';
import '../../utils/types/iterable.js';
import '../../utils/types/set.js';
import 'blake2b';
import '../../utils/types/bytes.js';
import '../../utils/interfaces.js';
import '../../utils/assert.js';
import '../../utils/error.js';
import '../../utils/types/string.js';
import '../../utils/ident/matchers.js';
import '../../modules/abstract/did/module.js';
import '../../modules/abstract/common/abstract-api-provider.js';
import '../../modules/abstract/common/abstract-base-module.js';
import '../generic/resolver.js';
import '../generic/const.js';

/**
 * Class DIDResolverWithDIDReplacement extends DIDResolver.
 *
 * This class provides an implementation of the resolve method that replaces a specific did in a document if it does not match the didURL.
 * The replacement is done by parsing the document into JSON, finding and replacing all instances of 'doc.id' with 'did', and then converting it back to an object.
 */
class DIDResolverWithDIDReplacement extends DIDResolver {
  async resolve(didURL) {
    const { did } = parseDIDUrl(didURL);
    const doc = await super.resolve(did);

    if (doc.id !== did) {
      return JSON.parse(JSON.stringify(doc).split(doc.id).join(did));
    } else {
      return doc;
    }
  }
}

export { DIDResolverWithDIDReplacement as default };
//# sourceMappingURL=did-resolver-with-did-replacement.js.map
