#!/usr/bin/env python3
# @generated AUTOGENERATED file. Do not Change!

from dataclasses import dataclass, field as _field
from ..schema_config.json_scalar import custom_scalars
from gql_client.runtime.variables import encode_variables
from gql import gql, Client
from gql.transport.exceptions import TransportQueryError
from functools import partial
from numbers import Number
from typing import Any, AsyncGenerator, Dict, List, Generator, Optional
from time import perf_counter
from dataclasses_json import DataClassJsonMixin, config


# fmt: off
QUERY: List[str] = ["""
query parseTextTokens($input: String!) {
  result: callNLU(input: $input) {
    tokens {
      dependency
      entity_type
      is_alpha
      is_currency
      is_digit
      is_oov
      is_sent_start
      is_stop
      is_title
      lemma
      like_email
      like_num
      like_url
      part_of_speech
      log_probability
      tag
      text

      subtree {
        dependency
        entity_type
        is_alpha
        is_currency
        is_digit
        is_oov
        is_sent_start
        is_stop
        is_title
        lemma
        like_email
        like_num
        like_url
        part_of_speech
        log_probability
        tag
        text
        subtree {
          dependency
          entity_type
          is_alpha
          is_currency
          is_digit
          is_oov
          is_sent_start
          is_stop
          is_title
          lemma
          like_email
          like_num
          like_url
          part_of_speech
          log_probability
          tag
          text

          subtree {
            dependency
            entity_type
            is_alpha
            is_currency
            is_digit
            is_oov
            is_sent_start
            is_stop
            is_title
            lemma
            like_email
            like_num
            like_url
            part_of_speech
            log_probability
            tag
            text

            subtree {
              dependency
              entity_type
              is_alpha
              is_currency
              is_digit
              is_oov
              is_sent_start
              is_stop
              is_title
              lemma
              like_email
              like_num
              like_url
              part_of_speech
              log_probability
              tag
              text
            }
          }
        }
      }
    }
  }
}

# FIXME: Unfortunately, fragments are not supported by the codegen

# fragment TokenSubtreeFields on NLUToken {
#   dependency
#   entity_type
#   is_alpha
#   is_currency
#   is_digit
#   is_oov
#   is_sent_start
#   is_stop
#   is_title
#   lemma
#   like_email
#   like_num
#   like_url
#   part_of_speech
#   log_probability
#   tag
#   text
# }
#
# fragment TokenSubtree on NLUToken {
#   ...TokenSubtreeFields
#   subtree {
#     ...TokenSubtreeFields
#     subtree {
#       ...TokenSubtreeFields
#       subtree {
#         ...TokenSubtreeFields
#         subtree {
#           ...TokenSubtreeFields
#         }
#       }
#     }
#   }
# }

"""
]


class parseTextTokens:
    @dataclass(frozen=True)
    class parseTextTokensData(DataClassJsonMixin):
        @dataclass(frozen=True)
        class NLUResult(DataClassJsonMixin):
            @dataclass(frozen=True)
            class NLUToken(DataClassJsonMixin):
                @dataclass(frozen=True)
                class NLUToken(DataClassJsonMixin):
                    @dataclass(frozen=True)
                    class NLUToken(DataClassJsonMixin):
                        @dataclass(frozen=True)
                        class NLUToken(DataClassJsonMixin):
                            @dataclass(frozen=True)
                            class NLUToken(DataClassJsonMixin):
                                dependency: Optional[str]
                                entity_type: Optional[str]
                                is_alpha: Optional[bool]
                                is_currency: Optional[bool]
                                is_digit: Optional[bool]
                                is_oov: Optional[bool]
                                is_sent_start: Optional[bool]
                                is_stop: Optional[bool]
                                is_title: Optional[bool]
                                lemma: Optional[str]
                                like_email: Optional[bool]
                                like_num: Optional[bool]
                                like_url: Optional[bool]
                                part_of_speech: Optional[str]
                                log_probability: Optional[Number]
                                tag: Optional[str]
                                text: Optional[str]

                            dependency: Optional[str]
                            entity_type: Optional[str]
                            is_alpha: Optional[bool]
                            is_currency: Optional[bool]
                            is_digit: Optional[bool]
                            is_oov: Optional[bool]
                            is_sent_start: Optional[bool]
                            is_stop: Optional[bool]
                            is_title: Optional[bool]
                            lemma: Optional[str]
                            like_email: Optional[bool]
                            like_num: Optional[bool]
                            like_url: Optional[bool]
                            part_of_speech: Optional[str]
                            log_probability: Optional[Number]
                            tag: Optional[str]
                            text: Optional[str]
                            subtree: Optional[List[NLUToken]]

                        dependency: Optional[str]
                        entity_type: Optional[str]
                        is_alpha: Optional[bool]
                        is_currency: Optional[bool]
                        is_digit: Optional[bool]
                        is_oov: Optional[bool]
                        is_sent_start: Optional[bool]
                        is_stop: Optional[bool]
                        is_title: Optional[bool]
                        lemma: Optional[str]
                        like_email: Optional[bool]
                        like_num: Optional[bool]
                        like_url: Optional[bool]
                        part_of_speech: Optional[str]
                        log_probability: Optional[Number]
                        tag: Optional[str]
                        text: Optional[str]
                        subtree: Optional[List[NLUToken]]

                    dependency: Optional[str]
                    entity_type: Optional[str]
                    is_alpha: Optional[bool]
                    is_currency: Optional[bool]
                    is_digit: Optional[bool]
                    is_oov: Optional[bool]
                    is_sent_start: Optional[bool]
                    is_stop: Optional[bool]
                    is_title: Optional[bool]
                    lemma: Optional[str]
                    like_email: Optional[bool]
                    like_num: Optional[bool]
                    like_url: Optional[bool]
                    part_of_speech: Optional[str]
                    log_probability: Optional[Number]
                    tag: Optional[str]
                    text: Optional[str]
                    subtree: Optional[List[NLUToken]]

                dependency: Optional[str]
                entity_type: Optional[str]
                is_alpha: Optional[bool]
                is_currency: Optional[bool]
                is_digit: Optional[bool]
                is_oov: Optional[bool]
                is_sent_start: Optional[bool]
                is_stop: Optional[bool]
                is_title: Optional[bool]
                lemma: Optional[str]
                like_email: Optional[bool]
                like_num: Optional[bool]
                like_url: Optional[bool]
                part_of_speech: Optional[str]
                log_probability: Optional[Number]
                tag: Optional[str]
                text: Optional[str]
                subtree: Optional[List[NLUToken]]

            tokens: Optional[List[NLUToken]]

        result: Optional[NLUResult]

    # fmt: off
    @classmethod
    def execute(cls, client: Client, input: str) -> Optional[parseTextTokensData.NLUResult]:
        variables: Dict[str, Any] = {"input": input}
        new_variables = encode_variables(variables, custom_scalars)
        response_text = client.execute(
            gql("".join(set(QUERY))), variable_values=new_variables
        )
        res = cls.parseTextTokensData.from_dict(response_text)
        return res.result

    # fmt: off
    @classmethod
    async def execute_async(cls, client: Client, input: str) -> Optional[parseTextTokensData.NLUResult]:
        variables: Dict[str, Any] = {"input": input}
        new_variables = encode_variables(variables, custom_scalars)
        response_text = await client.execute_async(
            gql("".join(set(QUERY))), variable_values=new_variables
        )
        res = cls.parseTextTokensData.from_dict(response_text)
        return res.result
