ó
    NÎh  ã                  óš   • S r SSKJr  SSKJrJrJrJrJr  SSK	J
r
JrJr  SSKJr  SSKJr  S/r\\\\\\   S\4   4   r " S	 S\5      rg)
zA
Nestedcompleter for completion of hierarchical data structures.
é    )Úannotations)ÚAnyÚIterableÚMappingÚSetÚUnion)ÚCompleteEventÚ	CompleterÚ
Completion)ÚWordCompleter)ÚDocumentÚNestedCompleterNc                  óf   • \ rS rSrSr S	     S
S jjrSS jr\SS j5       r      SS jr	Sr
g)r   é   aw  
Completer which wraps around several other completers, and calls any the
one that corresponds with the first word of the input.

By combining multiple `NestedCompleter` instances, we can achieve multiple
hierarchical levels of autocompletion. This is useful when `WordCompleter`
is not sufficient.

If you need multiple levels, check out the `from_nested_dict` classmethod.
c                ó   • Xl         X l        g )N©ÚoptionsÚignore_case)Úselfr   r   s      Ú]/home/mande/repo/quber/.venv/lib/python3.13/site-packages/prompt_toolkit/completion/nested.pyÚ__init__ÚNestedCompleter.__init__   s   € ð ŒØ&Õó    c                ó@   • SU R                   < SU R                  < S3$ )NzNestedCompleter(z, ignore_case=Ú)r   )r   s    r   Ú__repr__ÚNestedCompleter.__repr__%   s$   € Ø! $§,¡,Ñ!1°À×@PÑ@PÑ?SÐSTÐUÐUr   c                ó^  • 0 nUR                  5        H�  u  p4[        U[        5      (       a  XBU'   M   [        U[        5      (       a  U R	                  U5      X#'   MJ  [        U[
        5      (       a(  U R	                  [        R                  U5      5      X#'   M‡  Ub   eSX#'   M’     U " U5      $ )a"  
Create a `NestedCompleter`, starting from a nested dictionary data
structure, like this:

.. code::

    data = {
        'show': {
            'version': None,
            'interfaces': None,
            'clock': None,
            'ip': {'interface': {'brief'}}
        },
        'exit': None
        'enable': None
    }

The value should be `None` if there is no further completion at some
point. If all values in the dictionary are None, it is also possible to
use a set instead.

Values in this data structure can be a completers as well.
N)ÚitemsÚ
isinstancer
   ÚdictÚfrom_nested_dictÚsetÚfromkeys)ÚclsÚdatar   ÚkeyÚvalues        r   r"   Ú NestedCompleter.from_nested_dict(   s“   € ð2 02ˆØŸ*™*ž,‰JˆCÜ˜%¤×+Ñ+Ø$˜“Ü˜E¤4×(Ñ(Ø"×3Ñ3°EÓ:�“Ü˜E¤3×'Ñ'Ø"×3Ñ3´D·M±MÀ%Ó4HÓI�“à‘}Ð$�}Ø#�“ñ 'ñ �7‹|Ðr   c              #  ód  #   • UR                   R                  5       n[        UR                   5      [        U5      -
  nSU;   a™  UR                  5       S   nU R                  R                  U5      nUbg  U[        U5      S  R                  5       n[        U5      [        U5      -
  U-   n[        UUR                  U-
  S9n	UR                  X’5       S h  v•N   g g [        [        U R                  R                  5       5      U R                  S9nUR                  X5       S h  v•N   g  NU N7f)NÚ r   )Úcursor_position)r   )Útext_before_cursorÚlstripÚlenÚsplitr   Úgetr   r,   Úget_completionsr   ÚlistÚkeysr   )
r   ÚdocumentÚcomplete_eventÚtextÚstripped_lenÚ
first_termÚ	completerÚremaining_textÚmove_cursorÚnew_documents
             r   r2   ÚNestedCompleter.get_completionsO   s  é € ð ×*Ñ*×1Ñ1Ó3ˆÜ˜8×6Ñ6Ó7¼#¸d»)ÑCˆð �$‹;ØŸ™› a™ˆJØŸ™×(Ñ(¨Ó4ˆIð Ñ$Ø!%¤c¨*£oÐ&7Ð!8×!?Ñ!?Ó!A�Ü! $›i¬#¨nÓ*=Ñ=ÀÑL�ä'Ø"Ø$,×$<Ñ$<¸{Ñ$Jñ �ð
 %×4Ñ4°\ÓR×RÑRð %ô &Ü�T—\‘\×&Ñ&Ó(Ó)°t×7GÑ7GñˆIð !×0Ñ0°ÓJ×JÑJñ Sñ Kùs%   ‚CD0ÃD,ÃAD0Ä&D.Ä'D0Ä.D0)r   r   N)T)r   zdict[str, Completer | None]r   ÚboolÚreturnÚNone)r@   Ústr)r&   Ú
NestedDictr@   r   )r5   r   r6   r	   r@   zIterable[Completion])Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   Úclassmethodr"   r2   Ú__static_attributes__© r   r   r   r      sg   † ñ	ð IMð'Ø2ð'ØAEð'à	õ'ôVð ó$ó ð$ðLKØ ðKØ2?ðKà	÷Kr   )rH   Ú
__future__r   Útypingr   r   r   r   r   Úprompt_toolkit.completionr	   r
   r   Ú(prompt_toolkit.completion.word_completerr   Úprompt_toolkit.documentr   Ú__all__rB   rC   r   rK   r   r   Ú<module>rR      s\   ðñõ #ç 5Õ 5ç JÑ JÝ BÝ ,àÐ
€ð �S˜%  S¨¡X¨t°YÐ >Ñ?Ð?Ñ@€
ôZK�iõ ZKr   