def __new__(cls: Type[_CIDSubclass], base: Union[(str, Multibase)], version: int, codec: Union[(str, int, Multicodec)], digest: Union[(str, BytesLike, Tuple[(Union[(str, int, Multihash)], Union[(str, BytesLike)])])]) -> _CIDSubclass:
    base = _CID_validate_multibase(base)
    codec = _CID_validate_multicodec(codec)
    raw_digest: Union[(str, bytes)]
    hashfun: Union[(str, int, Multihash)]
    if isinstance(digest, ((str,) + byteslike)):
        (hashfun, raw_digest) = _CID_validate_multihash_digest(digest)
    else:
        validate(digest, Tuple[(Union[(str, int, Multihash)], Union[(str, BytesLike)])])
        (hashfun, raw_digest) = digest
        hashfun = _CID_validate_multihash(hashfun)
        raw_digest = _CID_validate_raw_digest(raw_digest, hashfun)
    version = _CID_validate_version(version, base, codec, hashfun)
    if isinstance(digest, bytes):
        return CID._new_instance(cls, base, version, codec, hashfun, digest)
    return CID._new_instance(cls, base, version, codec, hashfun, (hashfun, raw_digest))
def __new__(cls: Type[_CIDSubclass], base: Union[(str, Multibase)], version: int, codec: Union[(str, int, Multicodec)], digest: Union[(str, BytesLike, Tuple[(Union[(str, int, Multihash)], Union[(str, BytesLike)])])]) -> _CIDSubclass:
    base = _CID_validate_multibase(base)
    codec = _CID_validate_multicodec(codec)
    raw_digest: Union[(str, bytes)]
    hashfun: Union[(str, int, Multihash)]
    if isinstance(digest, ((str,) + byteslike)):
        (hashfun, raw_digest) = _CID_validate_multihash_digest(digest)
    else:
        validate(digest, Tuple[(Union[(str, int, Multihash)], Union[(str, BytesLike)])])
        (hashfun, raw_digest) = digest
        hashfun = _CID_validate_multihash(hashfun)
        raw_digest = _CID_validate_raw_digest(raw_digest, hashfun)
    version = _CID_validate_version(version, base, codec, hashfun)
    if isinstance(digest, bytes):
        return CID._new_instance(cls, base, version, codec, hashfun, digest)
    return CID._new_instance(cls, base, version, codec, hashfun, (hashfun, raw_digest))