from __future__ import annotations
from typing import Any, overload, Iterable, Iterator, SupportsIndex, Union

_TibsLike = Union["Tibs", "Mutibs", str, bytes, bytearray, memoryview, Iterable[Any]]


class Tibs:
    def __init__(self, auto: _TibsLike | None = None) -> None: ...

    def to_raw_data(self) -> tuple[bytes, int, int]: ...

    def __str__(self) -> str: ...

    def __repr__(self) -> str: ...

    def __iter__(self) -> Iterator[bool]: ...

    def chunks(self, chunk_size: int, count: int | None = None) -> Iterator[Tibs]: ...

    def __eq__(self, other: Any) -> bool: ...

    def __hash__(self) -> int: ...

    def find_all(self, b: _TibsLike, start: int | None = None, end: int | None = None, byte_aligned: bool = False) -> \
            Iterator[int]: ...

    def __len__(self) -> int: ...

    @classmethod
    def from_zeros(cls, length: int, /) -> Tibs: ...

    @classmethod
    def from_ones(cls, length: int, /) -> Tibs: ...

    @classmethod
    def from_string(cls, s: str, /) -> Tibs: ...

    @classmethod
    def from_u(cls, u: int, /, length: int) -> Tibs: ...

    def to_u(self) -> int: ...

    @classmethod
    def from_i(cls, i: int, /, length: int) -> Tibs: ...

    def to_i(self) -> int: ...

    @classmethod
    def from_f(cls, f: float, /, length: int) -> Tibs: ...

    def to_f(self) -> float: ...

    @classmethod
    def from_bin(cls, s: str, /) -> Tibs: ...

    def to_bin(self) -> str: ...

    @classmethod
    def from_oct(cls, s: str, /) -> Tibs: ...

    def to_oct(self) -> str: ...

    @classmethod
    def from_hex(cls, s: str, /) -> Tibs: ...

    def to_hex(self) -> str: ...

    @classmethod
    def from_bytes(cls, data: bytes | bytearray | memoryview, /, offset: int | None = None,
                   length: int | None = None) -> Tibs: ...

    @classmethod
    def from_bools(cls, iterable: Iterable[Any], /) -> Tibs: ...

    @classmethod
    def from_random(cls, length: int, /, secure: bool = False, seed: bytes | bytearray | None = None) -> Tibs: ...

    @classmethod
    def from_joined(cls, iterable: Iterable[_TibsLike], /) -> Tibs: ...

    def to_bytes(self) -> bytes: ...

    def find(self, b: _TibsLike, start: int | None = None, end: int | None = None,
             byte_aligned: bool = False) -> int | None: ...

    def __contains__(self, b: _TibsLike) -> bool: ...

    def __copy__(self) -> Tibs: ...

    def rfind(self, b: _TibsLike, start: int | None = None, end: int | None = None,
              byte_aligned: bool = False) -> int | None: ...

    def starts_with(self, prefix: _TibsLike) -> bool: ...

    def ends_with(self, suffix: _TibsLike) -> bool: ...

    def count(self, value: Any) -> int: ...

    def all(self) -> bool: ...

    def any(self) -> bool: ...

    def to_mutibs(self) -> Mutibs: ...

    @overload
    def __getitem__(self, key: SupportsIndex) -> bool: ...

    @overload
    def __getitem__(self, key: slice) -> Tibs: ...

    def __getitem__(self, key: SupportsIndex | slice) -> bool | Tibs: ...

    def __lshift__(self, n: int) -> Tibs: ...

    def __rshift__(self, n: int) -> Tibs: ...

    def __add__(self, bs: _TibsLike) -> Tibs: ...

    def __radd__(self, bs: _TibsLike) -> Tibs: ...

    def __and__(self, bs: _TibsLike) -> Tibs: ...

    def __or__(self, bs: _TibsLike) -> Tibs: ...

    def __xor__(self, bs: _TibsLike) -> Tibs: ...

    def __rand__(self, bs: _TibsLike) -> Tibs: ...

    def __ror__(self, bs: _TibsLike) -> Tibs: ...

    def __rxor__(self, bs: _TibsLike) -> Tibs: ...

    def __invert__(self) -> Tibs: ...

    def __bytes__(self) -> bytes: ...

    def __mul__(self, n: int) -> Tibs: ...

    def __rmul__(self, n: int) -> Tibs: ...

    def __setitem__(self, key: Any, value: Any) -> None: ...

    def __delitem__(self, key: Any) -> None: ...


class Mutibs:
    def __init__(self, auto: _TibsLike | None = None) -> None: ...

    def __eq__(self, other: Any) -> bool: ...

    def __str__(self) -> str: ...

    def __repr__(self) -> str: ...

    @classmethod
    def from_string(cls, s: str, /) -> Mutibs: ...

    @classmethod
    def from_bin(cls, s: str, /) -> Mutibs: ...

    def to_bin(self) -> str: ...

    @classmethod
    def from_oct(cls, s: str, /) -> Mutibs: ...

    def to_oct(self) -> str: ...

    @classmethod
    def from_hex(cls, s: str, /) -> Mutibs: ...

    def to_hex(self) -> str: ...

    def to_bytes(self) -> bytes: ...

    def to_raw_data(self) -> tuple[bytes, int, int]: ...

    def as_raw_data(self) -> tuple[bytes, int, int]: ...

    @classmethod
    def from_u(cls, u: int, /, length: int) -> Mutibs: ...

    def to_u(self) -> int: ...

    @classmethod
    def from_i(cls, i: int, /, length: int) -> Mutibs: ...

    def to_i(self) -> int: ...

    @classmethod
    def from_f(cls, f: float, /, length: int) -> Mutibs: ...

    def to_f(self) -> float: ...

    @classmethod
    def from_zeros(cls, length: int, /) -> Mutibs: ...

    @classmethod
    def from_ones(cls, length: int, /) -> Mutibs: ...

    @classmethod
    def from_bools(cls, iterable: Iterable[Any], /) -> Mutibs: ...

    @classmethod
    def from_random(cls, length: int, /, secure: bool = False, seed: bytes | bytearray | None = None) -> Mutibs: ...

    @classmethod
    def from_bytes(cls, data: bytes | bytearray | memoryview, /, offset: int | None = None,
                   length: int | None = None) -> Mutibs: ...

    @classmethod
    def from_joined(cls, iterable: Iterable[_TibsLike], /) -> Mutibs: ...

    def __len__(self) -> int: ...

    @overload
    def __getitem__(self, key: SupportsIndex) -> bool: ...

    @overload
    def __getitem__(self, key: slice) -> Mutibs: ...

    def __getitem__(self, key: SupportsIndex | slice) -> bool | Mutibs: ...

    @overload
    def __setitem__(self, key: SupportsIndex, value: Any) -> None: ...

    @overload
    def __setitem__(self, key: slice, value: _TibsLike) -> None: ...

    def __setitem__(self, key: SupportsIndex | slice, value: Any | _TibsLike) -> None: ...

    def __delitem__(self, key: SupportsIndex | slice) -> None: ...

    def starts_with(self, prefix: _TibsLike) -> bool: ...

    def ends_with(self, suffix: _TibsLike) -> bool: ...

    def find(self, b: _TibsLike, start: int | None = None, end: int | None = None,
             byte_aligned: bool = False) -> int | None: ...

    def __and__(self, bs: _TibsLike) -> Mutibs: ...

    def __or__(self, bs: _TibsLike) -> Mutibs: ...

    def __xor__(self, bs: _TibsLike) -> Mutibs: ...

    def __rand__(self, bs: _TibsLike) -> Mutibs: ...

    def __ror__(self, bs: _TibsLike) -> Mutibs: ...

    def __rxor__(self, bs: _TibsLike) -> Mutibs: ...

    def rol(self, n: int, start: int | None = None, end: int | None = None) -> Mutibs: ...

    def ror(self, n: int, start: int | None = None, end: int | None = None) -> Mutibs: ...

    def set(self, value: Any, pos: SupportsIndex | Iterable[SupportsIndex] | range) -> Mutibs: ...

    def count(self, value: Any) -> int: ...

    def all(self) -> bool: ...

    def any(self) -> bool: ...

    def rfind(self, b: _TibsLike, start: int | None = None, end: int | None = None,
              byte_aligned: bool = False) -> int | None: ...

    def invert(self, pos: SupportsIndex | Iterable[SupportsIndex] | None = None) -> Mutibs: ...

    def reverse(self) -> Mutibs: ...

    def byte_swap(self, byte_length: int | None = None) -> Mutibs: ...

    def __invert__(self) -> Mutibs: ...

    def __lshift__(self, n: int) -> Mutibs: ...

    def __rshift__(self, n: int) -> Mutibs: ...

    def __copy__(self) -> Mutibs: ...

    def to_tibs(self) -> Tibs: ...

    def as_tibs(self) -> Tibs: ...

    def clear(self) -> None: ...

    def capacity(self) -> int: ...

    def reserve(self, additional: int) -> None: ...

    def __add__(self, bs: _TibsLike) -> Mutibs: ...

    def __radd__(self, bs: _TibsLike) -> Mutibs: ...

    def __iadd__(self, bs: _TibsLike) -> Mutibs: ...

    def append(self, bit: bool | int) -> Mutibs: ...

    def extend(self, bs: _TibsLike) -> Mutibs: ...

    def extend_left(self, bs: _TibsLike) -> Mutibs: ...

    def replace(self, old: _TibsLike, new: _TibsLike, start: int | None = None, end: int | None = None,
                count: int | None = None, byte_aligned: bool = False) -> Mutibs: ...

    def insert(self, pos: int, bs: _TibsLike) -> Mutibs: ...

    def __ilshift__(self, n: int) -> Mutibs: ...

    def __irshift__(self, n: int) -> Mutibs: ...

    def __bytes__(self) -> bytes: ...

    def __mul__(self, n: int) -> Mutibs: ...

    def __rmul__(self, n: int) -> Mutibs: ...

    def __iter__(self) -> None: ...

    def __iand__(self, bs: _TibsLike) -> Mutibs: ...

    def __ior__(self, bs: _TibsLike) -> Mutibs: ...

    def __ixor__(self, bs: _TibsLike) -> Mutibs: ...

    def __imul__(self, n: int) -> Mutibs: ...
