# 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 .raw_client import AsyncRawBrowserStateClient, RawBrowserStateClient

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


class BrowserStateClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBrowserStateClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawBrowserStateClient
        """
        return self._raw_client

    def save(self, *, path: str, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Save browser state (cookies, localStorage, etc.) to a file.

        Parameters
        ----------
        path : str

        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_state.save(
            path="path",
        )
        """
        _response = self._raw_client.save(path=path, request_options=request_options)
        return _response.data

    def load(self, *, path: str, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Load browser state from a previously saved file.

        Parameters
        ----------
        path : str

        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_state.load(
            path="path",
        )
        """
        _response = self._raw_client.load(path=path, request_options=request_options)
        return _response.data


class AsyncBrowserStateClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBrowserStateClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawBrowserStateClient
        """
        return self._raw_client

    async def save(self, *, path: str, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Save browser state (cookies, localStorage, etc.) to a file.

        Parameters
        ----------
        path : str

        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_state.save(
                path="path",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.save(path=path, request_options=request_options)
        return _response.data

    async def load(self, *, path: str, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Load browser state from a previously saved file.

        Parameters
        ----------
        path : str

        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_state.load(
                path="path",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.load(path=path, request_options=request_options)
        return _response.data
