
    ,jip*              #          S SK r S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SK	J
r
  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S\\SSSSSSSSSS4S\S\\\\\\\4   4      S\\\\\\\4   4      S\S\\   S\\   S\S\S\S\S \S!\S"\S#\S$\\   S%\S&\4"S' jjr g)(    N)Any)Dict)Optional)Sequence)Union)Application)KeyBindings)Keys)Style)utils)DEFAULT_QUESTION_PREFIX)DEFAULT_SELECTED_POINTER)common)Choice)InquirerControl)	Separator)Question)merge_styles_defaultFTmessagechoicesdefaultqmarkpointerstyleuse_shortcutsuse_arrow_keysuse_indicatoruse_jk_keysuse_emacs_keysuse_search_filtershow_selectedshow_descriptioninstructionkwargsreturnc                   ^ ^^^^^^^ T(       d   T(       d  U	(       d  U
(       d  [        S5      eU	(       a  T(       a  [        S5      eT(       a)  U	(       a"  [        S U 5       5      (       a  [        S5      eUb  [        U5      S:X  a  [        S5      eT(       aa  [        S U 5       5      nU[        [        R
                  5      :  a2  [        SR                  [        [        R
                  5      U5      5      e[        U/5      n[	        UUUUTUUTUS	9	mUUU UUUU4S
 jn[        R                  " TU40 UD6n[        5       mTR                  [        R                  SS9TR                  [        R                  SS9S 5       5       nT(       a  [        TR                   5       H  u  nnUR"                  c<  UR$                  (       d+  T(       d$  ['        SR                  UR(                  5      5      e[+        U[,        5      (       d  UR"                  b  UR$                  (       a  M  UU4S jnU" UUR"                  5        M     U4S jnU4S jnT(       aW  U4S jn[.        R0                   H  nTR                  USS9" U5        M     TR                  [        R2                  SS9" U5        T(       aH  TR                  [        R4                  SS9" U5        TR                  [        R6                  SS9" U5        U	(       a,  TR                  SSS9" U5        TR                  SSS9" U5        U
(       aH  TR                  [        R8                  SS9" U5        TR                  [        R:                  SS9" U5        TR                  [        R<                  SS9U4S j5       nTR                  [        R>                  5      S 5       n[A        [C        SUTUS.[D        RF                  " U[B        RH                  5      D65      $ )u  A list of items to select **one** option from.

The user can pick one option and confirm it (if you want to allow
the user to select multiple options, use :meth:`questionary.checkbox` instead).

Example:
    >>> import questionary
    >>> questionary.select(
    ...     "What do you want to do?",
    ...     choices=[
    ...         "Order a pizza",
    ...         "Make a reservation",
    ...         "Ask for opening hours"
    ...     ]).ask()
    ? What do you want to do? Order a pizza
    'Order a pizza'

.. image:: ../images/select.gif

This is just a really basic example, the prompt can be customised using the
parameters.


Args:
    message: Question text

    choices: Items shown in the selection, this can contain :class:`Choice` or
             or :class:`Separator` objects or simple items as strings. Passing
             :class:`Choice` objects, allows you to configure the item more
             (e.g. preselecting it or disabling it).

    default: A value corresponding to a selectable item in the choices,
             to initially set the pointer position to.

    qmark: Question prefix displayed in front of the question.
           By default this is a ``?``.

    pointer: Pointer symbol in front of the currently highlighted element.
             By default this is a ``»``.
             Use ``None`` to disable it.

    instruction: A hint on how to navigate the menu.
                 It's ``(Use shortcuts)`` if only ``use_shortcuts`` is set
                 to True, ``(Use arrow keys or shortcuts)`` if ``use_arrow_keys``
                 & ``use_shortcuts`` are set and ``(Use arrow keys)`` by default.

    style: A custom color and style for the question parts. You can
           configure colors as well as font types for different elements.

    use_indicator: Flag to enable the small indicator in front of the
                   list highlighting the current location of the selection
                   cursor.

    use_shortcuts: Allow the user to select items from the list using
                   shortcuts. The shortcuts will be displayed in front of
                   the list items. Arrow keys, j/k keys and shortcuts are
                   not mutually exclusive.

    use_arrow_keys: Allow the user to select items from the list using
                    arrow keys. Arrow keys, j/k keys and shortcuts are not
                    mutually exclusive.

    use_jk_keys: Allow the user to select items from the list using
                 `j` (down) and `k` (up) keys. Arrow keys, j/k keys and
                 shortcuts are not mutually exclusive.

    use_emacs_keys: Allow the user to select items from the list using
                    `Ctrl+N` (down) and `Ctrl+P` (up) keys. Arrow keys, j/k keys,
                    emacs keys and shortcuts are not mutually exclusive.

    use_search_filter: Flag to enable search filtering. Typing some string will
                       filter the choices to keep only the ones that contain the
                       search string.
                       Note that activating this option disables "vi-like"
                       navigation as "j" and "k" can be part of a prefix and
                       therefore cannot be used for navigation

    show_selected: Display current selection choice at the bottom of list.

    show_description: Display description of current selection if available.

Returns:
    :class:`Question`: Question instance, ready to be prompted (using ``.ask()``).
z^Some option to move the selection is required. Arrow keys, j/k keys, emacs keys, or shortcuts.zSCannot use j/k keys with prefix filter search, since j/k can be part of the prefix.c              3   B   #    U  H  n[        US S5      S;   v   M     g7f)shortcut_key )jkN)getattr.0cs     T/home/james-whalen/.local/lib/python3.13/site-packages/questionary/prompts/select.py	<genexpr>select.<locals>.<genexpr>   s     MWwq."-;Ws   zqA choice is trying to register j/k as a shortcut key when they are in use as arrow keys disable one or the other.r   z'A list of choices needs to be provided.c              3   T   #    U  H  n[        U[        5      (       a  M  S v   M      g7f)   N)
isinstancer   r-   s     r0   r1   r2      s     !UWJq)<T!!Ws   (	(zA list with shortcuts supports a maximum of {} choices as this is the maximum number of keyboard shortcuts that are available. You provided {} choices!)r   r   r   r!   r"   r   initial_choicec            
        > ST4SSR                  T5      4/n TR                  (       a  [        TR                  5       R                  [
        5      (       aO  U R                  SSR                  TR                  5       R                   Vs/ s H  oS   PM	     sn5      45        U $ U R                  STR                  5       R                  45         U $ T(       a  U R                  ST45        U $ T	(       a  T(       a  ST(       a  S	OS S
3nO-T	(       a  T(       d  ST(       a  S	OS S
3nOST(       a  S	OS S
3nU R                  SU45        U $ s  snf )Nzclass:qmarkzclass:questionz {} zclass:answerr)   r4   zclass:instructionz(Use shortcuts or arrow keysz, type to filter)z(Use shortcutsz(Use arrow keys)formatis_answeredr5   get_pointed_attitlelistappendjoin)
tokenstokeninstruction_msgicr#   r   r   r   r    r   s
      r0   get_prompt_tokens!select.<locals>.get_prompt_tokens   sB    %(+;V]]7=S*TU>>"++-33T::&r7H7H7J7P7P Q7Peq7P QR(  ~r/@/@/B/H/HIJ  2K@A  !^(D[lEWrtDuuv&wO">(6M^7Idf6ggh&iO(7N_8Jeg7hhi&jO2ODE# !Rs   
ETeagerc                 @    U R                   R                  [        SS9  g )Nzclass:aborting)	exceptionr   )appexitKeyboardInterruptevents    r0   _select.<locals>._   s     			!2:JK    zc{} does not have a shortcut and arrow keys for movement are disabled. This choice is not reachable.c                 <   >^  TR                  USS9U U4S j5       ng )NTrF   c                    > TTl         g N)
pointed_at)rN   irC   s    r0   select_choice3select.<locals>._reg_binding.<locals>.select_choice   s
    $%BMrQ   )add)rV   keysrW   bindingsrC   s   `  r0   _reg_bindingselect.<locals>._reg_binding   s$     d$/& 0&rQ   c                    > TR                  5         TR                  5       (       d(  TR                  5         TR                  5       (       d  M'  g g rT   )select_nextis_selection_validrN   rC   s    r0   move_cursor_down select.<locals>.move_cursor_down   s7    
''))NN ''))rQ   c                    > TR                  5         TR                  5       (       d(  TR                  5         TR                  5       (       d  M'  g g rT   )select_previousr`   ra   s    r0   move_cursor_upselect.<locals>.move_cursor_up   s;    
''))  ''))rQ   c                 V   > TR                  U R                  S   R                  5        g )Nr   )add_search_characterkey_sequencekeyra   s    r0   search_filterselect.<locals>.search_filter   s"    ##E$6$6q$9$=$=>rQ   r*   r+   c                 v   > STl         U R                  R                  TR                  5       R                  S9  g )NT)result)r:   rJ   rK   r;   valuera   s    r0   
set_answerselect.<locals>.set_answer  s+    		b//1778rQ   c                     g)zDisallow inserting other text.N rM   s    r0   otherselect.<locals>.other  s    rQ   )layoutkey_bindingsr   rt   )%
ValueErroranylensumr   SHORTCUT_KEYSr9   r   r   create_inquirer_layoutr	   rY   r
   ControlQControlC	enumerater   r(   disabledRuntimeErrorr<   r5   r   string	printable	BackspaceDownUpControlNControlPControlMr   r   r   r   used_kwargs__init__) r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   real_len_of_choicesmerged_stylerD   rw   rO   rV   r/   r\   rb   rf   rl   	characterrq   ru   r[   rC   s    `  `  ``   `  `               @@r0   selectr      sh   L m{nB
 	
 (a
 	
 MWMMM,  #g,!+BCC!!UW!UU_%B%B!CC 6#o;;<>QR  (0L	###)%

B 8 **2/@KFKF}H\\$--t\,\\$--t\,L - -L bjj)DAq~~%ajj"44:F177O 
 !Y''1>>+AQZZ& ANN+% *(
!
 	?  ))ILL$L/> *T^^40?TYYd+,<=TWWD).9S%&67S%n5T]]$/0@AT]]$/?\\$--t\,9 -9 \\$((- -  	
!	
 (<(<=		
 rQ   )!r   typingr   r   r   r   r   prompt_toolkit.applicationr   prompt_toolkit.key_bindingr	   prompt_toolkit.keysr
   prompt_toolkit.stylesr   questionaryr   questionary.constantsr   r   questionary.promptsr   questionary.prompts.commonr   r   r   questionary.questionr   questionary.stylesr   strboolr   rt   rQ   r0   <module>r      se         2 2 $ '  9 : & - 6 0 ) 3 =A(5!#!!%AAeCc3h789A eCc3h789A 	A
 c]A E?A A A A A A A A A #A  !A" #ArQ   