import abc
import voluptuous as vol
from .backports.enum import StrEnum as StrEnum
from .core import HomeAssistant as HomeAssistant, callback as callback
from .exceptions import HomeAssistantError as HomeAssistantError
from .helpers.frame import report as report
from _typeshed import Incomplete
from collections.abc import Iterable, Mapping
from typing import Any, TypedDict
from typing_extensions import Required

_LOGGER: Incomplete

class FlowResultType(StrEnum):
    FORM: str
    CREATE_ENTRY: str
    ABORT: str
    EXTERNAL_STEP: str
    EXTERNAL_STEP_DONE: str
    SHOW_PROGRESS: str
    SHOW_PROGRESS_DONE: str
    MENU: str

RESULT_TYPE_FORM: str
RESULT_TYPE_CREATE_ENTRY: str
RESULT_TYPE_ABORT: str
RESULT_TYPE_EXTERNAL_STEP: str
RESULT_TYPE_EXTERNAL_STEP_DONE: str
RESULT_TYPE_SHOW_PROGRESS: str
RESULT_TYPE_SHOW_PROGRESS_DONE: str
RESULT_TYPE_MENU: str
EVENT_DATA_ENTRY_FLOW_PROGRESSED: str

class BaseServiceInfo: ...
class FlowError(HomeAssistantError): ...
class UnknownHandler(FlowError): ...
class UnknownFlow(FlowError): ...
class UnknownStep(FlowError): ...

class AbortFlow(FlowError):
    reason: Incomplete
    description_placeholders: Incomplete
    def __init__(self, reason: str, description_placeholders: Union[Mapping[str, str], None] = ...) -> None: ...

class FlowResult(TypedDict):
    context: dict[str, Any]
    data_schema: Union[vol.Schema, None]
    data: Mapping[str, Any]
    description_placeholders: Union[Mapping[str, Union[str, None]], None]
    description: Union[str, None]
    errors: Union[dict[str, str], None]
    extra: str
    flow_id: Required[str]
    handler: Required[str]
    last_step: Union[bool, None]
    menu_options: Union[list[str], dict[str, str]]
    options: Mapping[str, Any]
    progress_action: str
    reason: str
    required: bool
    result: Any
    step_id: str
    title: str
    type: FlowResultType
    url: str
    version: int

def _async_flow_handler_to_flow_result(flows: Iterable[FlowHandler], include_uninitialized: bool) -> list[FlowResult]: ...

class FlowManager(abc.ABC, metaclass=abc.ABCMeta):
    hass: Incomplete
    _progress: Incomplete
    _handler_progress_index: Incomplete
    def __init__(self, hass: HomeAssistant) -> None: ...
    @abc.abstractmethod
    async def async_create_flow(self, handler_key: str, *, context: Union[dict[str, Any], None] = ..., data: Union[dict[str, Any], None] = ...) -> FlowHandler: ...
    @abc.abstractmethod
    async def async_finish_flow(self, flow: FlowHandler, result: FlowResult) -> FlowResult: ...
    async def async_post_init(self, flow: FlowHandler, result: FlowResult) -> None: ...
    def async_has_matching_flow(self, handler: str, context: dict[str, Any], data: Any) -> bool: ...
    def async_get(self, flow_id: str) -> FlowResult: ...
    def async_progress(self, include_uninitialized: bool = ...) -> list[FlowResult]: ...
    def async_progress_by_handler(self, handler: str, include_uninitialized: bool = ...) -> list[FlowResult]: ...
    def _async_progress_by_handler(self, handler: str) -> list[FlowHandler]: ...
    async def async_init(self, handler: str, *, context: Union[dict[str, Any], None] = ..., data: Any = ...) -> FlowResult: ...
    async def async_configure(self, flow_id: str, user_input: Union[dict, None] = ...) -> FlowResult: ...
    def async_abort(self, flow_id: str) -> None: ...
    def _async_add_flow_progress(self, flow: FlowHandler) -> None: ...
    def _async_remove_flow_progress(self, flow_id: str) -> None: ...
    async def _async_handle_step(self, flow: FlowHandler, step_id: str, user_input: Union[dict, BaseServiceInfo, None]) -> FlowResult: ...

class FlowHandler:
    cur_step: Union[FlowResult, None]
    flow_id: str
    hass: HomeAssistant
    handler: str
    context: dict[str, Any]
    init_step: str
    init_data: Any
    VERSION: int
    @property
    def source(self) -> Union[str, None]: ...
    @property
    def show_advanced_options(self) -> bool: ...
    def add_suggested_values_to_schema(self, data_schema: vol.Schema, suggested_values: Union[Mapping[str, Any], None]) -> vol.Schema: ...
    def async_show_form(self, *, step_id: str, data_schema: Union[vol.Schema, None] = ..., errors: Union[dict[str, str], None] = ..., description_placeholders: Union[Mapping[str, Union[str, None]], None] = ..., last_step: Union[bool, None] = ...) -> FlowResult: ...
    def async_create_entry(self, *, title: Union[str, None] = ..., data: Mapping[str, Any], description: Union[str, None] = ..., description_placeholders: Union[Mapping[str, str], None] = ...) -> FlowResult: ...
    def async_abort(self, *, reason: str, description_placeholders: Union[Mapping[str, str], None] = ...) -> FlowResult: ...
    def async_external_step(self, *, step_id: str, url: str, description_placeholders: Union[Mapping[str, str], None] = ...) -> FlowResult: ...
    def async_external_step_done(self, *, next_step_id: str) -> FlowResult: ...
    def async_show_progress(self, *, step_id: str, progress_action: str, description_placeholders: Union[Mapping[str, str], None] = ...) -> FlowResult: ...
    def async_show_progress_done(self, *, next_step_id: str) -> FlowResult: ...
    def async_show_menu(self, *, step_id: str, menu_options: Union[list[str], dict[str, str]], description_placeholders: Union[Mapping[str, str], None] = ...) -> FlowResult: ...
    def async_remove(self) -> None: ...

def _create_abort_data(flow_id: str, handler: str, reason: str, description_placeholders: Union[Mapping[str, str], None] = ...) -> FlowResult: ...
