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

from __future__ import annotations

import typing

from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ....core.request_options import RequestOptions
from ....types.dubbing_language_list_response import DubbingLanguageListResponse
from ....types.dubbing_language_response import DubbingLanguageResponse
from ....types.voice_settings import VoiceSettings
from .raw_client import AsyncRawLanguageClient, RawLanguageClient

if typing.TYPE_CHECKING:
    from .transcript.client import AsyncTranscriptClient, TranscriptClient
# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class LanguageClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawLanguageClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._transcript: typing.Optional[TranscriptClient] = None

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

        Returns
        -------
        RawLanguageClient
        """
        return self._raw_client

    def list(
        self,
        project_id: str,
        *,
        cursor: typing.Optional[str] = None,
        page_size: typing.Optional[int] = None,
        status: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingLanguageListResponse:
        """
        List a project's language targets (cursor-paginated).

        Parameters
        ----------
        project_id : str
            Identifier of the parent dubbing project.

        cursor : typing.Optional[str]
            Pagination cursor from a previous response's next_cursor.

        page_size : typing.Optional[int]
            Number of language targets per page (max 100).

        status : typing.Optional[str]
            Filter to targets in this status (queued, processing, completed, stale, failed).

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

        Returns
        -------
        DubbingLanguageListResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.language.list(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            page_size=20,
        )
        """
        _response = self._raw_client.list(
            project_id, cursor=cursor, page_size=page_size, status=status, request_options=request_options
        )
        return _response.data

    def create(
        self,
        project_id: str,
        *,
        target_language: str,
        voice_settings: typing.Optional[VoiceSettings] = OMIT,
        translations: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingLanguageResponse:
        """
        Queue a language target for a project (starts once the project is ready).

        Parameters
        ----------
        project_id : str
            Identifier of the parent dubbing project.

        target_language : str
            BCP-47 language tag to dub the project into (e.g. 'fr', 'es-MX'); must be a language the dubbing model supports. A region-qualified tag must be one of the supported dialects.

        voice_settings : typing.Optional[VoiceSettings]
            Voice settings applied to the whole language (e.g. cloning strength).

        translations : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Optional translations to use instead of machine translation. A map from each source segment's external_id (or its id, if you supplied none) to the translated text; every source segment must be covered exactly once. At most 20000 entries, totalling at most 4 MiB of text.

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

        Returns
        -------
        DubbingLanguageResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.language.create(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            target_language="es",
        )
        """
        _response = self._raw_client.create(
            project_id,
            target_language=target_language,
            voice_settings=voice_settings,
            translations=translations,
            request_options=request_options,
        )
        return _response.data

    def get(
        self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingLanguageResponse:
        """
        Full language-target detail.

        Parameters
        ----------
        project_id : str
            Identifier of the parent dubbing project.

        language_id : str
            Identifier of the language target to fetch.

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

        Returns
        -------
        DubbingLanguageResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.language.get(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
        )
        """
        _response = self._raw_client.get(project_id, language_id, request_options=request_options)
        return _response.data

    def delete(
        self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a language target.

        Parameters
        ----------
        project_id : str
            Identifier of the parent dubbing project.

        language_id : str
            Identifier of the language target to delete.

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

        Returns
        -------
        None

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.dubbing.project.language.delete(
            project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
            language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
        )
        """
        _response = self._raw_client.delete(project_id, language_id, request_options=request_options)
        return _response.data

    @property
    def transcript(self):
        if self._transcript is None:
            from .transcript.client import TranscriptClient  # noqa: E402

            self._transcript = TranscriptClient(client_wrapper=self._client_wrapper)
        return self._transcript


class AsyncLanguageClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawLanguageClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._transcript: typing.Optional[AsyncTranscriptClient] = None

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

        Returns
        -------
        AsyncRawLanguageClient
        """
        return self._raw_client

    async def list(
        self,
        project_id: str,
        *,
        cursor: typing.Optional[str] = None,
        page_size: typing.Optional[int] = None,
        status: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingLanguageListResponse:
        """
        List a project's language targets (cursor-paginated).

        Parameters
        ----------
        project_id : str
            Identifier of the parent dubbing project.

        cursor : typing.Optional[str]
            Pagination cursor from a previous response's next_cursor.

        page_size : typing.Optional[int]
            Number of language targets per page (max 100).

        status : typing.Optional[str]
            Filter to targets in this status (queued, processing, completed, stale, failed).

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

        Returns
        -------
        DubbingLanguageListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.language.list(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                page_size=20,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            project_id, cursor=cursor, page_size=page_size, status=status, request_options=request_options
        )
        return _response.data

    async def create(
        self,
        project_id: str,
        *,
        target_language: str,
        voice_settings: typing.Optional[VoiceSettings] = OMIT,
        translations: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DubbingLanguageResponse:
        """
        Queue a language target for a project (starts once the project is ready).

        Parameters
        ----------
        project_id : str
            Identifier of the parent dubbing project.

        target_language : str
            BCP-47 language tag to dub the project into (e.g. 'fr', 'es-MX'); must be a language the dubbing model supports. A region-qualified tag must be one of the supported dialects.

        voice_settings : typing.Optional[VoiceSettings]
            Voice settings applied to the whole language (e.g. cloning strength).

        translations : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Optional translations to use instead of machine translation. A map from each source segment's external_id (or its id, if you supplied none) to the translated text; every source segment must be covered exactly once. At most 20000 entries, totalling at most 4 MiB of text.

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

        Returns
        -------
        DubbingLanguageResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.language.create(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                target_language="es",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            project_id,
            target_language=target_language,
            voice_settings=voice_settings,
            translations=translations,
            request_options=request_options,
        )
        return _response.data

    async def get(
        self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DubbingLanguageResponse:
        """
        Full language-target detail.

        Parameters
        ----------
        project_id : str
            Identifier of the parent dubbing project.

        language_id : str
            Identifier of the language target to fetch.

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

        Returns
        -------
        DubbingLanguageResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.language.get(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get(project_id, language_id, request_options=request_options)
        return _response.data

    async def delete(
        self, project_id: str, language_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a language target.

        Parameters
        ----------
        project_id : str
            Identifier of the parent dubbing project.

        language_id : str
            Identifier of the language target to delete.

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dubbing.project.language.delete(
                project_id="proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
                language_id="lang_1001kwkyxp0je6ktn4knsfrasx5s",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(project_id, language_id, request_options=request_options)
        return _response.data

    @property
    def transcript(self):
        if self._transcript is None:
            from .transcript.client import AsyncTranscriptClient  # noqa: E402

            self._transcript = AsyncTranscriptClient(client_wrapper=self._client_wrapper)
        return self._transcript
