# This file was auto-generated by Fern from our API Definition.

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.response import Response
from ..types.response_captcha_wait_result import ResponseCaptchaWaitResult
from .raw_client import AsyncRawBrowserCaptchaClient, RawBrowserCaptchaClient

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class BrowserCaptchaClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBrowserCaptchaClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawBrowserCaptchaClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawBrowserCaptchaClient
        """
        return self._raw_client

    def detect(self, *, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Detect CAPTCHA on the current page.

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Response
            Successful Response

        Examples
        --------
        from agent_sandbox import Sandbox

        client = Sandbox(
            base_url="https://yourhost.com/path/to/api",
        )
        client.browser_captcha.detect()
        """
        _response = self._raw_client.detect(request_options=request_options)
        return _response.data

    def wait(
        self,
        *,
        timeout: typing.Optional[float] = OMIT,
        poll_interval: typing.Optional[float] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ResponseCaptchaWaitResult:
        """
        Wait for CAPTCHA to be resolved.

        Parameters
        ----------
        timeout : typing.Optional[float]

        poll_interval : typing.Optional[float]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ResponseCaptchaWaitResult
            Successful Response

        Examples
        --------
        from agent_sandbox import Sandbox

        client = Sandbox(
            base_url="https://yourhost.com/path/to/api",
        )
        client.browser_captcha.wait()
        """
        _response = self._raw_client.wait(timeout=timeout, poll_interval=poll_interval, request_options=request_options)
        return _response.data


class AsyncBrowserCaptchaClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBrowserCaptchaClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawBrowserCaptchaClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawBrowserCaptchaClient
        """
        return self._raw_client

    async def detect(self, *, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Detect CAPTCHA on the current page.

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Response
            Successful Response

        Examples
        --------
        import asyncio

        from agent_sandbox import AsyncSandbox

        client = AsyncSandbox(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.browser_captcha.detect()


        asyncio.run(main())
        """
        _response = await self._raw_client.detect(request_options=request_options)
        return _response.data

    async def wait(
        self,
        *,
        timeout: typing.Optional[float] = OMIT,
        poll_interval: typing.Optional[float] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ResponseCaptchaWaitResult:
        """
        Wait for CAPTCHA to be resolved.

        Parameters
        ----------
        timeout : typing.Optional[float]

        poll_interval : typing.Optional[float]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ResponseCaptchaWaitResult
            Successful Response

        Examples
        --------
        import asyncio

        from agent_sandbox import AsyncSandbox

        client = AsyncSandbox(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.browser_captcha.wait()


        asyncio.run(main())
        """
        _response = await self._raw_client.wait(
            timeout=timeout, poll_interval=poll_interval, request_options=request_options
        )
        return _response.data
