
    g	                     l    d Z ddlmZ ddlmZmZ defdZdee         fdZ G d	 d
e	          Z
d ZdS )z
This file contains utilities for handling input from the user and registering specific keys to specific functions,
based on https://github.com/bchao1/bullet
    )List   )KEYMAPget_characterkeyc                       fd}|S )zR
    Mark the function with the key code so it can be handled in the register
    c                 D    t          | dg           }|gz  }|| _        | S N
handle_keygetattrr   )funchandler   s     Z/var/www/html/ai-engine/env/lib/python3.11/site-packages/accelerate/commands/menu/input.py	decoratorzmark.<locals>.decorator   s+    |R003%      )r   r   s   ` r   markr      $    
     r   keysc                        fd}|S )zS
    Mark the function with the key codes so it can be handled in the register
    c                 B    t          | dg           }|z  }|| _        | S r
   r   )r   r   r   s     r   r   z mark_multiple.<locals>.decorator,   s)    |R00$ r   r   )r   r   s   ` r   mark_multipler   '   r   r   c                   8     e Zd ZdZ fdZed             Z xZS )
KeyHandlerz;
    Metaclass that adds the key handlers to the class
    c                    t                                          | |||          }t          |d          si |_        t          j        |_        |                                D ]"}t          |dg           }|D ]}||j        |<   #|S )Nkey_handlerr   )super__new__hasattrr   r   handle_inputvaluesr   )	clsnamebasesattrsnew_clsvaluehandled_keysr   	__class__s	           r   r   zKeyHandler.__new__:   s    ''//#tUE::w.. 	%"$G)6\\^^ 	1 	1E"5,;;L# 1 1+0#C((1r   c                     t                      }|t          d         k    rt          |          }| j                            |          }|r|| _         ||           S dS )zDFinds and returns the selected character if it exists in the handler	undefinedN)r   r   ordr   getcurrent_selection)r#   charhandlers      r   r!   zKeyHandler.handle_inputF   s`     6+&&&t99D/%%d++ 	$(C!73<<4r   )__name__
__module____qualname____doc__r   staticmethodr!   __classcell__)r*   s   @r   r   r   5   s]         
 
 
 
 
 
 
 \
 
 
 
 
r   r   c                 f    t          | j        | j        | j                                                  S )z&Adds KeyHandler metaclass to the class)r   r2   	__bases____dict__copy)r#   s    r   registerr<   T   s&    clCM3<3D3D3F3FGGGr   N)r5   typingr   keymapr   r   strr   r   typer   r<   r   r   r   <module>rA      s    
       ) ) ) ) ) ) ) )c    c           >H H H H Hr   