






"""simple docstring"""




import builtins
import sys

from ...utils.imports import _is_package_available
from . import cursor, input
from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor
from .keymap import KEYMAP


_snake_case          =   False
try:
 _snake_case          =   _is_package_available('google.colab')
except ModuleNotFoundError:
 pass






@input.register
class        UpperCamelCase			:


 def __init__(     self		:						Optional[int]							,						UpperCAmelCase__		:						Optional[int] = None							,						UpperCAmelCase__		:						Union[str, Any] = []							)					->       List[str]:
   _a  :       List[Any]             =	0
   _a  :       Optional[Any]             =	choices
   _a  :       List[Any]             =	prompt
   if sys.platform == "win32":
     _a  :       Optional[int]             =	"*"
   else:
     _a  :       int             =	"➔ "


 def _lowercase	(     self		:						str							,						UpperCAmelCase__		:						Tuple							,						UpperCAmelCase__		:						int = ""							)					->       List[str]:
   if sys.platform != "win32":
     writeColor(self.choices[index]							,						32							,						lowercase_							)
   else:
     forceWrite(self.choices[index]							,						lowercase_							)


 def _lowercase	(     self		:						Union[str, Any]							,						UpperCAmelCase__		:						Optional[Any]							)					->       Union[str, Any]:
   if index == self.position:
     forceWrite(f""" {self.arrow_char} """							)
     self.write_choice(lowercase_							)
   else:
     forceWrite(f"""    {self.choices[index]}"""							)
   reset_cursor()


 def _lowercase	(     self		:						int							,						UpperCAmelCase__		:						List[str]							,						UpperCAmelCase__		:						Optional[int] = 1							)					->       Any:
   _a  :       List[str]             =	self.position
   if direction == Direction.DOWN:
     if self.position + 1 >= len(self.choices							):
       return
     self.position += num_spaces
   else:
     if self.position - 1 < 0:
       return
     self.position -= num_spaces
   clear_line()
   self.print_choice(lowercase_							)
   move_cursor(lowercase_							,						direction.name							)
   self.print_choice(self.position							)


 @input.mark(KEYMAP["""up"""]							)
 def _lowercase	(     self		:						Optional[int]							)					->       Tuple:
   self.move_direction(Direction.UP							)


 @input.mark(KEYMAP["""down"""]							)
 def _lowercase	(     self		:						List[Any]							)					->       Optional[int]:
   self.move_direction(Direction.DOWN							)


 @input.mark(KEYMAP["""newline"""]							)
 def _lowercase	(     self		:						Optional[int]							)					->       Any:
   move_cursor(len(self.choices							) - self.position							,						"""DOWN"""							)
   return self.position


 @input.mark(KEYMAP["""interrupt"""]							)
 def _lowercase	(     self		:						Any							)					->       Tuple:
   move_cursor(len(self.choices							) - self.position							,						"""DOWN"""							)
   raise KeyboardInterrupt


 @input.mark_multiple(*[KEYMAP[str(lowercase_							)] for number in range(10							)]							)
 def _lowercase	(     self		:						List[Any]							)					->       str:
   _a  :       Optional[Any]             =	int(chr(self.current_selection							)							)
   _a  :       Optional[Any]             =	index - self.position
   if index == self.position:
     return
   if index < len(self.choices							):
     if self.position > index:
       self.move_direction(Direction.UP							,						-movement							)
     elif self.position < index:
       self.move_direction(Direction.DOWN							,						lowercase_							)
     else:
       return
   else:
     return







 def _lowercase	(     self		:						int							,						UpperCAmelCase__		:						Any = 0							)					->       Tuple:
   if self.prompt:
     linebreak()
     forceWrite(self.prompt							,						"""\n"""							)
     if in_colab:
       forceWrite("""Please input a choice index (starting from 0), and press enter"""							,						"""\n"""							)
     else:
       forceWrite("""Please select a choice using the arrow or number keys, and selecting with enter"""							,						"""\n"""							)
   _a  :       Optional[Any]             =	default_choice
   for i in range(len(self.choices							)							):
     self.print_choice(lowercase_							)
     forceWrite("""\n"""							)
   move_cursor(len(self.choices							) - self.position							,						"""UP"""							)
   with cursor.hide():
     while True:
       if in_colab:
         try:
           _a  :       Tuple             =	int(builtins.input()							)
         except ValueError:
           _a  :       List[Any]             =	default_choice
       else:
         _a  :       Optional[int]             =	self.handle_input()
       if choice is not None:
         reset_cursor()
         for _ in range(len(self.choices							) + 1							):
           move_cursor(1							,						"""UP"""							)
           clear_line()
         self.write_choice(lowercase_							,						"""\n"""							)
         return choice



"""simple docstring"""





from diffusers.utils.testing_utils import require_onnxruntime


@require_onnxruntime
class A_	:




  '''simple docstring'''
  pass


