from typing import Any, Iterator, Sequence

FileLike = File | bytes | dict | tuple

class AbstractType:
    def json_v(self, *args, **kwargs) -> Any: ...
    def map_v(self, *args, **kwargs) -> Any: ...

class Type(AbstractType):
    def __init__(self, value: Any): ...
    def json_v(self, *args, **kwargs) -> Any: ...
    def loads(self, value: Any) -> None: ...
    def dumps(self) -> Any: ...

class File(AbstractType):
    data: bytes | None
    data_b64: str | None
    file: Any | None
    hash: str | None
    size: int
    file_name: str
    mime: str | None
    etag: str | None
    guid: str
    params: dict[str, Any] | None
    engine: str | None
    def __init__(self, file: FileLike): ...
    def __len__(self) -> int: ...
    @classmethod
    def open(cls, path: str) -> File: ...
    def build_d(self, file_d: bytes, name: str = ...) -> None: ...
    def build_b64(self, file_m: dict[str, Any]) -> None: ...
    def build_t(self, file_t: tuple[str, str | None, bytes | None]) -> None: ...
    def build_i(self, file: File) -> None: ...
    def build_f(self, file: Any) -> None: ...
    def read(self, size: int | None = ...) -> bytes | None: ...
    def seek(self, offset: int | None = ...) -> None: ...
    def delete(self) -> None: ...
    def cleanup(self) -> None: ...
    def save(self, path: str | None = ...) -> None: ...
    def json_v(self, *args, **kwargs) -> dict[str, Any] | None: ...
    def is_seekable(self) -> bool: ...
    def is_stored(self) -> bool: ...
    def is_valid(self) -> bool: ...
    def is_empty(self) -> bool: ...
    def _hash(self, data: bytes | None) -> str | None: ...
    def _etag(self, data: bytes | None) -> str | None: ...
    def _guid(self) -> str: ...
    def _load(self, force: bool = ...) -> None: ...
    def _store(self, force: bool = ...) -> None: ...
    def _compute(self) -> None: ...
    def _engine(self) -> Any: ...

class Files(AbstractType):
    _files: list[File]
    def __init__(self, files: Files | Sequence[FileLike]): ...
    def __len__(self) -> int: ...
    def __iter__(self) -> Iterator[File]: ...
    def __getitem__(self, key: int) -> File: ...
    def base(self) -> type[File]: ...
    def build_i(self, files: Files) -> None: ...
    def build_f(self, files: Any) -> None: ...
    def json_v(self, *args, **kwargs) -> list[dict[str, Any]]: ...
    def is_empty(self) -> bool: ...
    def _load(self) -> None: ...

class ImageFile(File):
    width: int
    height: int
    format: str | None
    kwargs: dict[str, Any]
    def build_b64(self, file_m: dict[str, Any]) -> None: ...
    def build_t(self, file_t: tuple[str, str | None, bytes | None]) -> None: ...
    def build_i(self, file: File) -> None: ...
    def build_f(self, file: Any) -> None: ...
    def json_v(self, *args, **kwargs) -> dict[str, Any] | None: ...
    def _ensure_all(self) -> None: ...
    def _ensure_size(self) -> None: ...
    def _ensure_mime(self) -> None: ...
    def _ensure_kwargs(self) -> None: ...
    def _size(self) -> tuple[int, int]: ...
    def _size_image(self) -> tuple[int, int]: ...
    def _size_pil(self) -> tuple[int, int]: ...
    def _size_default(self) -> tuple[int, int]: ...
    def _mime(self) -> tuple[str | None, str]: ...
    def _mime_image(self) -> tuple[str | None, str]: ...
    def _mime_pil(self) -> tuple[str | None, str]: ...
    def _mime_default(self) -> tuple[str | None, str]: ...

class ImageFiles(Files):
    def base(self) -> type[ImageFile]: ...

def image(
    width: int | None = ..., height: int | None = ..., format: str = ..., **kwargs
) -> type[ImageFile]: ...
def images(
    width: int | None = ..., height: int | None = ..., format: str = ..., **kwargs
) -> type[ImageFiles]: ...

class Reference(AbstractType): ...

def reference(
    target: Any, name: str | None = ..., dumpall: bool = ...
) -> type[Reference]: ...
