from typing import Tuple


def parse_sleb128(data: bytes) -> Tuple[int, int]:
    """Parse sleb128 and return (value, length in bytes)."""
    i = 0
    val = data[i] & 0x7F
    while data[i] & 0x80:
        i += 1
        val |= (data[i] & 0x7F) << (7 * i)
    if val & (0x40 << (i * 7)):
        for j in range(6 + i * 7, -1, -1):
            if not (val | (1 << j)):
                break
            val ^= 1 << j
        val = -1 - val
    return val, i + 1