import abc
from _typeshed import Incomplete
from abc import ABC, abstractmethod
from com.exteragram.messenger.plugins.hooks import HookFilter as JavaHookFilter
from dataclasses import dataclass
from de.robv.android.xposed import XC_MethodHook as XC_MethodHook
from enum import Enum
from java.lang import Class as Class
from java.lang.reflect import Member as Member
from typing import Any, Callable

@dataclass
class PluginMetadata:
    id: str
    name: str
    description: str
    author: str
    version: str
    icon: str
    min_version: str
    def __init__(self, id, name, description, author, version, icon, min_version) -> None: ...

class HookStrategy(Enum):
    CANCEL = ...
    MODIFY = ...
    DEFAULT = ...
    MODIFY_FINAL = ...

@dataclass
class HookResult:
    strategy: HookStrategy = ...
    request: Any = ...
    response: Any = ...
    update: Any = ...
    updates: Any = ...
    error: Any = ...
    params: Any = ...
    def __init__(self, strategy=..., request=..., response=..., update=..., updates=..., error=..., params=...) -> None: ...

class PluginError(Exception):
    plugin_id: str | None
    def __init__(self, message: str, plugin_id: str | None = None) -> None: ...

class XposedHook(ABC): ...

class MethodReplacement(XposedHook, metaclass=abc.ABCMeta):
    @abstractmethod
    def replace_hooked_method(self, param: XC_MethodHook.MethodHookParam) -> Any: ...

class MethodHook(XposedHook):
    def before_hooked_method(self, param: XC_MethodHook.MethodHookParam): ...
    def after_hooked_method(self, param: XC_MethodHook.MethodHookParam): ...

class AppEvent(Enum):
    START = ...
    STOP = ...
    PAUSE = ...
    RESUME = ...

class MenuItemType(Enum):
    MESSAGE_CONTEXT_MENU = ...
    DRAWER_MENU = ...
    CHAT_ACTION_MENU = ...
    PROFILE_ACTION_MENU = ...

@dataclass
class MenuItemData:
    menu_type: MenuItemType
    text: str
    on_click: Callable[[dict[str, Any]], None]
    item_id: str | None = ...
    icon: str | None = ...
    subtext: str | None = ...
    condition: str | None = ...
    priority: int = ...
    def __init__(self, menu_type, text, on_click, item_id=..., icon=..., subtext=..., condition=..., priority=...) -> None: ...

@dataclass
class HookFilterData:
    filter_type: str
    arg_index: int | None = ...
    or_filters: Any | None = ...
    mvel_expression: str | None = ...
    instance_of: Any | None = ...
    object: Any = ...
    def to_java_filter(self) -> JavaHookFilter: ...
    def __init__(self, filter_type, arg_index=..., or_filters=..., mvel_expression=..., instance_of=..., object=...) -> None: ...

class HookFilter(Enum):
    RESULT_IS_NULL = ...
    RESULT_IS_TRUE = ...
    RESULT_IS_FALSE = ...
    RESULT_NOT_NULL = ...
    @property
    def filter_data(self): ...
    @staticmethod
    def ResultIsInstanceOf(clazz): ...
    @staticmethod
    def ResultEqual(value): ...
    @staticmethod
    def ResultNotEqual(value): ...
    @staticmethod
    def ArgumentIsNull(index: int): ...
    @staticmethod
    def ArgumentIsTrue(index: int): ...
    @staticmethod
    def ArgumentIsFalse(index: int): ...
    @staticmethod
    def ArgumentNotNull(index: int): ...
    @staticmethod
    def ArgumentIsInstanceOf(index: int, clazz): ...
    @staticmethod
    def ArgumentEqual(index: int, value): ...
    @staticmethod
    def ArgumentNotEqual(index: int, value): ...
    @staticmethod
    def Condition(condition: str, object: Any = None): ...
    @staticmethod
    def Or(*filters): ...

def hook_filters(*filters): ...

class BasePlugin:
    id: str
    name: str
    description: str
    author: str
    min_version: str
    version: str
    icon: Incomplete
    error_message: Incomplete
    enabled: bool
    initialized: bool
    def __init__(self) -> None: ...
    def on_plugin_load(self) -> None: ...
    def on_plugin_unload(self) -> None: ...
    def create_settings(self) -> list[Any]: ...
    def on_app_event(self, event_type: AppEvent): ...
    def pre_request_hook(self, request_name: str, account: int, request: Any) -> HookResult: ...
    def post_request_hook(self, request_name: str, account: int, response: Any, error: Any) -> HookResult: ...
    def on_update_hook(self, update_name: str, account: int, update: Any) -> HookResult: ...
    def on_updates_hook(self, container_name: str, account: int, updates: Any) -> HookResult: ...
    def on_send_message_hook(self, account: int, params: Any) -> HookResult: ...
    def add_hook(self, name: str, match_substring: bool = False, priority: int = 0): ...
    def add_on_send_message_hook(self, priority: int = 0): ...
    def remove_hook(self, name: str): ...
    def get_setting(self, key: str, default: Any = None) -> Any: ...
    def set_setting(self, key: str, value: Any, reload_settings: bool = False): ...
    def export_settings(self) -> dict: ...
    def import_settings(self, settings: dict, reload_settings: bool = True): ...
    def hook_method(self, method_or_constructor: Member, xposed_hook: Any | None, priority: int | None = None) -> XC_MethodHook.Unhook | None: ...
    def hook_all_methods(self, hook_class: Class, method_name: str, xposed_hook: Any | None, priority: int | None = None) -> list[XC_MethodHook.Unhook] | None: ...
    def hook_all_constructors(self, hook_class: Class, xposed_hook: Any | None, priority: int | None = None) -> list[XC_MethodHook.Unhook] | None: ...
    def unhook_method(self, unhook: XC_MethodHook.Unhook): ...
    def log(self, message: str): ...
    def add_menu_item(self, menu_item_data: MenuItemData) -> str | None: ...
    def remove_menu_item(self, item_id: str) -> bool: ...
