
    CjN                    R   % S r SSKJr  SSKJrJr  SSKJrJrJ	r	J
r
JrJr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JrJrJrJrJrJrJ r   SSK!r"SSK#J$r$  SSK%J&r&  SSK'J(r(J)r)  SSK*J+r+J,r,  SSK-J.r.J/r/  SSK0J1r1J2r2  SSK3J4r4  SSK5J6r6J7r7  SSK8J9r9  SSK:J;r;  SSK<J=r=  SSK>J?r?J@r@  SSKAJBrB  SSKCJDrD  SSKEJFrF  SSKGJHrH  SSKIJJrJ  SSKKJLrLJMrMJNrNJOrOJPrP  SSKQJRrR  SSKSJTrT  \(       a  SS KUJVrVJWrW  / S!QrX\ " S" S#5      5       rY\ " S$ S%5      5       rZ\S&   r[S'\\S('    S)r]S'\\S*'     " S+ S,\5      r^ " S- S.\ 5      r_S/r`S'\\S0'    " S1 S2\^5      ra\"R                  R                  \ " S3 S4\R5      5       5       rd " S5 S6\OS7S89re " S9 S:\PS7S;9rf " S< S=\M5      rg " S> S?\@S   5      rhg)@z
This module contains classes for working with Textual's command palette.

See the guide on the [Command Palette](../guide/command_palette.md) for full details.

    )annotations)ABCabstractmethod)CancelledErrorQueueTaskTimeoutErrorcreate_taskwaitwait_for)	dataclass)total_ordering)isclass)
attrgetter)	monotonic)TYPE_CHECKINGAnyAsyncGeneratorAsyncIteratorCallableClassVarIterable
NamedTupleN)Align)Text)Final	TypeAlias)onwork)BindingBindingType)
HorizontalVertical)Content)ClickMount)Matcher)Message)var)ScreenSystemModalScreen)Style)Timer)IgnoreReturnCallbackType)
VisualType)Widget)ButtonInputLoadingIndicator
OptionListStatic)Option)get_current_worker)AppComposeResult)CommandPaletteDiscoveryHitHitHitsr'   Providerc                      \ rS rSr% SrS\S'    S\S'    S\S'    S	rS
\S'    S	rS
\S'    \SS j5       r	SS jr
SS jrSS jrSrg	)r<   H   1Holds the details of a single command search hit.floatscorer/   match_displayr.   commandN
str | Nonetexthelpc                    U R                   $ )zAThe prompt to use when displaying the hit in the command palette.)rD   selfs    a/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/textual/command.pyprompt
Hit.promptb        !!!    c                j    [        U[        5      (       a  U R                  UR                  :  $ [        $ N
isinstancer<   rC   NotImplementedrK   others     rL   __lt__
Hit.__lt__g   s(    eS!!::++rP   c                j    [        U[        5      (       a  U R                  UR                  :H  $ [        $ rR   rS   rV   s     rL   __eq__
Hit.__eq__l   s(    eS!!::,,rP   c                T    U R                   c  [        U R                  5      U l         ggzEnsure 'text' is populated.N)rG   strrD   rJ   s    rL   __post_init__Hit.__post_init__q   s#    99D../DI rP   rG   returnr/   rW   objectrd   boolrd   None)__name__
__module____qualname____firstlineno____doc____annotations__rG   rH   propertyrM   rX   r[   r`   __static_attributes__ rP   rL   r<   r<   H   sb    ;L
 @%%:D* D*-" "

0rP   r<   c                      \ rS rSr% SrS\S'    S\S'    SrS\S	'    SrS\S
'    \SS j5       r	\SS j5       r
SS jrSS jrSS jrSrg)r;   w   rA   r/   displayr.   rE   NrF   rG   rH   c                    U R                   $ )zKThe prompt to use when displaying the discovery hit in the command palette.)ru   rJ   s    rL   rM   DiscoveryHit.prompt   s     ||rP   c                    g)zA discovery hit always has a score of 0.

The order in which discovery hits are displayed is determined by the order
in which they are yielded by the Provider. It's up to the developer to yield
DiscoveryHits in the .
g        rr   rJ   s    rL   rC   DiscoveryHit.score   s     rP   c                    [        U[        5      (       a7  U R                  c   eUR                  c   eUR                  U R                  :  $ [        $ rR   )rT   r;   rG   rU   rV   s     rL   rX   DiscoveryHit.__lt__   sH    e\**99(((::)))::		))rP   c                j    [        U[        5      (       a  U R                  UR                  :H  $ [        $ rR   )rT   r<   rG   rU   rV   s     rL   r[   DiscoveryHit.__eq__   s(    eS!!99

**rP   c                T    U R                   c  [        U R                  5      U l         ggr^   )rG   r_   ru   rJ   s    rL   r`   DiscoveryHit.__post_init__   s!    99DLL)DI rP   rb   rc   )rd   rB   re   rh   )rj   rk   rl   rm   rn   ro   rG   rH   rp   rM   rC   rX   r[   r`   rq   rr   rP   rL   r;   r;   w   sj    ;@%%:D* D*-   
*rP   r;   DiscoveryHit | Hitr   r=   z7Iterable[type[Provider] | Callable[[], type[Provider]]]ProviderSourcec                      \ rS rSrSrSSS jjr\SS j5       r\SS j5       r\SS j5       r	\SS j5       r
SSS	 jjrSS
 jrSS jrSS jrSS jr\SS j5       rSS jrSS jrSS jrSrg)r>      zBase class for command palette command providers.

To create new command provider, inherit from this class and implement
[`search`][textual.command.Provider.search].
Nc                v    Ub  [        U[        5      (       d   S5       eXl        X l        SU l        SU l        g)zVInitialise the command provider.

Args:
    screen: A reference to the active screen.
NzDmatch_style must be a Visual style (from textual.style import Style)F)rT   r,   _Provider__screen_Provider__match_style
_init_task_init_successrK   screenmatch_styles      rL   __init__Provider.__init__   sL     "U  VUV  ('+"rP   c                .    U R                   R                  $ )z}The currently-focused widget in the currently-active screen in the application.

If no widget has focus this will be `None`.
)r   focusedrJ   s    rL   r   Provider.focused   s     }}$$$rP   c                    U R                   $ )z/The currently-active screen in the application.)r   rJ   s    rL   r   Provider.screen   s     }}rP   c                .    U R                   R                  $ )zA reference to the application.)r   apprJ   s    rL   r   Provider.app   s     }}   rP   c                    U R                   $ )z{The preferred style to use when highlighting matching portions of the [`match_display`][textual.command.Hit.match_display].)r   rJ   s    rL   r   Provider.match_style   rO   rP   c                ,    [        UU R                  US9$ )a  Create a [fuzzy matcher][textual.fuzzy.Matcher] for the given user input.

Args:
    user_input: The text that the user has input.
    case_sensitive: Should matching be case sensitive?

Returns:
    A [fuzzy matcher][textual.fuzzy.Matcher] object for matching against candidate hits.
)r   case_sensitive)r'   r   )rK   
user_inputr   s      rL   matcherProvider.matcher   s      (()
 	
rP   c                @   ^  SU 4S jjn[        U" 5       5      T l        g)z&Internal method to run post init task.c                    >#     TR                  5       I Sh  vN   STl        g N! [         a3    SSKJn   TR
                  R                  R                  U " 5       5         gf = f7f)z)Wrapper to post init that runs in a task.NTr   	Traceback)startupr   	Exceptionrich.tracebackr   r   logerror)r   rK   s    rL   post_init_task+Provider._post_init.<locals>.post_init_task   sR     *lln$$ &*" % 04""9;/0s1   A'' %' A'' :A$!A'#A$$A'Nrh   )r
   r   )rK   r   s   ` rL   
_post_initProvider._post_init   s    		* &n&67rP   c                `   #    U R                   b  U R                   I Sh  vN   SU l         g N7f)zWait for initialization.N)r   rJ   s    rL   
_wait_initProvider._wait_init   s(     ??&//!! "s   .,.c                   #    g7f)zKCalled after the Provider is initialized, but before any calls to `search`.Nrr   rJ   s    rL   r   Provider.startup          c                  #    U R                  5       I Sh  vN   U R                  (       aE  U(       a  U R                  U5      OU R                  5       nU  Sh  vN nU[        Ld  M  U7v   M  g N[ N
 g7f)zInternal method to perform search.

Args:
    query: The user input to be matched.

Yields:
    Instances of [`Hit`][textual.command.Hit].
N)r   r   searchdiscoverrU   )rK   queryhitshits       rL   _searchProvider._search	  sb      oo */4;;u%DMMOD! cn,I  	 
Ts9   A8A2?A8A6A4A6A8*	A84A66A8c                  #    [         7v   g7f)zA request to search for commands relevant to the given query.

Args:
    query: The user input to be matched.

Yields:
    Instances of [`Hit`][textual.command.Hit].
NrU   )rK   r   s     rL   r   Provider.search  s         c                  #    [         7v   g7f)a  A default collection of hits for the provider.

Yields:
    Instances of [`DiscoveryHit`][textual.command.DiscoveryHit].

Note:
    This is different from
    [`search`][textual.command.Provider.search] in that it should
    yield [`DiscoveryHit`s][textual.command.DiscoveryHit] that
    should be shown by default (before user input).

    It is permitted to *not* implement this method.
Nr   rJ   s    rL   r   Provider.discover'  s      r   c                   #     U R                  5       I Sh  vN   g N! [         a3    SSKJn  U R                  R
                  R                  U" 5       5         gf = f7f)z0Internal method to call shutdown and log errors.Nr   r   )shutdownr   r   r   r   r   r   )rK   r   s     rL   	_shutdownProvider._shutdown7  sB     	,--/!! 	,0HHLLy{+	,s1   A  A :AAAAc                   #    g7f)z\Called when the Provider is shutdown.

Use this method to perform an cleanup, if required.

Nrr   rJ   s    rL   r   Provider.shutdown@  r   r   )__match_style__screenr   r   rR   )r   Screen[Any]r   Style | Nonerd   ri   )rd   zWidget | None)rd   zScreen[object])rd   App[object]rd   r   )F)r   r_   r   rg   rd   r'   rh   r   r_   rd   r=   rd   r=   )rj   rk   rl   rm   rn   r   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rq   rr   rP   rL   r>   r>      s    # % %   ! ! " "
 8 Z$ 	 	 ,rP   r>   c                  @    \ rS rSr% SrS\S'    S\S'    SrS\S	'   S
rg)SimpleCommandiH  zA simple command.r_   namer.   callbackNrF   	help_textrr   )rj   rk   rl   rm   rn   ro   r   rq   rr   rP   rL   r   r   H  s#    
I"&&> Iz )rP   r   zgSimpleCommand | tuple[str, IgnoreReturnCallbackType, str | None] | tuple[str, IgnoreReturnCallbackType]CommandListItemc                  ~   ^  \ rS rSrSr      S	U 4S jjr S
     SS jjr\SS j5       rSS jr	SS jr
SrU =r$ )SimpleProvideriX  z8A simple provider which the caller can pass commands to.c                  > [         TU ]  US 5        / U l        U H  n[        U[        5      (       a  U R                  R                  U5        M5  [        U5      S:X  a(  U R                  R                  [	        / UQS P76 5        Ml  [        U5      S:X  a#  U R                  R                  [	        U6 5        M  [        SU 35      e   g )N      zInvalid command: )superr   	_commandsrT   r   appendlen
ValueError)rK   r   commandsrE   	__class__s       rL   r   SimpleProvider.__init__[  s     	&.0G'=11%%g.W"%%m&CW&Cd&CDW"%%mW&=> #4WI!>??  rP   c                    X l         U $ rR   _SimpleProvider__match_styler   s      rL   __call__SimpleProvider.__call__m  s     )rP   c                    U R                   $ rR   r   rJ   s    rL   r   SimpleProvider.match_styles  s    !!!rP   c                  #    U R                  U5      nU R                   H=  u  p4nUR                  U5      =nS:  d  M  [        UUR	                  U5      UUS97v   M?     g 7f)Nr   rH   )r   r   matchr<   	highlight)rK   r   r   r   r   r   r   s          rL   r   SimpleProvider.searchw  s`     ,,u%)-%DI t,,1%%d+"	  *8s
   9A"#A"c               T   #    U R                    H  u  pn[        UUUS97v   M     g7f)zmHandle a request for the discovery commands for this provider.

Yields:
    Commands that can be discovered.
r   N)r   r;   )rK   r   r   r   s       rL   r   SimpleProvider.discover  s0      *.%DI  *8s   &()r   r   )r   r   r   zlist[CommandListItem]rd   ri   rR   )r   r   r   r   rd   r   r   r   r   )rj   rk   rl   rm   rn   r   r   rp   r   r   r   rq   __classcell__r   s   @rL   r   r   X  sr    B@@ (@ 
	@& @D!0<	 " "	 rP   r   c                  h   ^  \ rS rSrSr  S         S	U 4S jjjrS
S jrSS jrSS jrSr	U =r
$ )Commandi  zKClass that holds a hit in the [`CommandList`][textual.command.CommandList].c                2   > [         TU ]  XU5        X l        g)zInitialise the option.

Args:
    prompt: The prompt for the option.
    hit: The details of the hit associated with the option.
    id: The optional ID for the option.
    disabled: The initial enabled/disabled state. Enabled by default.
N)r   r   r   )rK   rM   r   iddisabledr   s        rL   r   Command.__init__  s     	X.@rP   c                    [        U 5      $ rR   r   rJ   s    rL   __hash__Command.__hash__  s    $xrP   c                j    [        U[        5      (       a  U R                  UR                  :  $ [        $ rR   rT   r   r   rU   rV   s     rL   rX   Command.__lt__  s(    eW%%88eii''rP   c                j    [        U[        5      (       a  U R                  UR                  :H  $ [        $ rR   r   rV   s     rL   r[   Command.__eq__  s(    eW%%88uyy((rP   )r   )NF)
rM   r/   r   r   r   rF   r   rg   rd   ri   )rd   intre   )rj   rk   rl   rm   rn   r   r   rX   r[   rq   r   r   s   @rL   r   r     sf     V AA  A 	A
 A 
A A&
 rP   r   c                      \ rS rSrSrSrSrg)CommandListi  z!The command palette command list.a  
    
    CommandList:ansi {
        & > .option-list--option-highlighted {             
            color: $block-cursor-foreground;
            background: $block-cursor-background;
            text-style: $block-cursor-text-style;    
        }               
    }       
    
    CommandList {
        visibility: hidden;
        border-top: blank;
        border-bottom: hkey black;
        border-left: none;
        border-right: none;
        height: auto;
        max-height: 70vh;
        background: transparent;
        padding: 0;
    }

    CommandList:focus {
        border: blank;
    }

    CommandList.--visible {
        visibility: visible;
    }

    CommandList.--populating {
        border-bottom: none;
    }

    CommandList > .option-list--option-highlighted {
        color: $block-cursor-blurred-foreground;
        background: $block-cursor-blurred-background;
        text-style: $block-cursor-blurred-text-style;        
    }
    

    CommandList:nocolor > .option-list--option-highlighted {       
        text-style: reverse;
    }

    CommandList > .option-list--option {
        padding: 0 2;
        color: $foreground;
        text-style: bold;
    }
    rr   Nrj   rk   rl   rm   rn   DEFAULT_CSSrq   rr   rP   rL   r  r    s    +2KrP   r  F)	can_focusc                  D    \ rS rSr% SrSr\" S5      rS\S'    S
S jr	Sr
g	)
SearchIconi  z=Widget for displaying a search icon before the command input.z
    SearchIcon {
        color: #000;  /* required for snapshot tests */
        margin-left: 1;
        margin-top: 1;
        width: 2;
    }
    u   🔎zvar[str]iconc                    U R                   $ )z4Render the icon.

Returns:
    The icon renderable.
)r  rJ   s    rL   renderSearchIcon.render  s     yyrP   rr   Nrc   )rj   rk   rl   rm   rn   r  r)   r  ro   r	  rq   rr   rP   rL   r  r    s$    GK [D( rP   r  )inherit_cssc                      \ rS rSrSrSrSrg)CommandInputi  z"The command palette input control.z
    CommandInput, CommandInput:focus {
        border: blank;
        width: 1fr;
        padding-left: 0;
        background: transparent;
        background-tint: 0%;
    }
    rr   Nr  rr   rP   rL   r  r    s    ,KrP   r  c                  <  ^  \ rS rSr% SrSr\R                  SS1-  rS\S'    Sr	\
" S	S
SSS9\
" SSSSS9\
" SSSSS9\
" SSS5      \
" SSSSS9\
" SSSSS9\
" SSSSS9/rS\S '    S!rS"\S#'    \" SSS$9rS%\S&'    \" SSS$9rS%\S''    \" S(5      rS)\S*'    \ " S+ S,\5      5       r\ " S- S.\5      5       r\ " S/ S0\5      5       r SYS1S(S(S(S2.           SZU 4S3 jjjjr\S[S4 j5       r\S\S5 j5       rS]S6 jrS^S7 jrS_S8 jrS`S9 jrS`S: jrS;r S<\S='    S`S> jr!S`S? jr"S;r#S<\S@'    SaSA jr$S`SB jr%S`SC jr&\SbSD j5       r'    ScSE jr(        SdSF jr)SGr*S<\SH'    SIr+SJ\SK'    SLr,SJ\SM'    \-" S!\,SN9SaSO j5       r.S`SP jr/\0" \1Rd                  5      SeSQ j5       r3\0" \4Rj                  5      SfSR j5       r6\0" \1Rn                  5      \0" \8Rr                  5       SY   SgSS jj5       5       r:\0" \4R&                  5      ShST j5       r;S`SU jr<SiSV jr=S`SW jr>SXr?U =r@$ )jr:   i  zThe Textual command palette.r  command-palette--help-textcommand-palette--highlightzClassVar[set[str]]COMPONENT_CLASSESa  
   
    CommandPalette:inline {
        /* If the command palette is invoked in inline mode, we may need additional lines. */
        min-height: 20;
    }
    CommandPalette {
        color: $foreground;
        background: $background 60%;
        align-horizontal: center;        

        #--container {
            display: none;
        }

        &:ansi {
            background: transparent;
        }
    }

    CommandPalette.-ready {
        #--container {
            display: block;
        }
    }


    CommandPalette > .command-palette--help-text  {
        color: transparent;
        text-style: dim not bold;
    }
    
    CommandPalette > .command-palette--highlight {
        text-style: bold underline;
    }   

    CommandPalette:nocolor > .command-palette--highlight {
        text-style: underline;
    }

    CommandPalette > Vertical {
        margin-top: 3; 
        height: 100%;
        visibility: hidden;
        background: $surface;
        &:dark { background: $panel-darken-1; }
    }

    CommandPalette #--input {
        height: auto;
        visibility: visible;
        border: hkey black 50%;
    }

    CommandPalette #--input.--list-visible {
        border-bottom: none;
    }

    CommandPalette #--input Label {
        margin-top: 1;
        margin-left: 1;
    }

    CommandPalette #--input Button {
        min-width: 7;
        margin-right: 1;
    }

    CommandPalette #--results {
        overlay: screen;
        height: auto;
    }

    CommandPalette LoadingIndicator {
        height: auto;
        visibility: hidden;
        border-bottom: hkey $border;
    }

    CommandPalette LoadingIndicator.--visible {
        visibility: visible;
    }
    zctrl+end, shift+endzcommand_list('last')zGo to bottomF)showzctrl+home, shift+homezcommand_list('first')z	Go to topdowncursor_downzNext commandescapezExit the command palettepagedownzcommand_list('page_down')z	Next pagepageupzcommand_list('page_up')zPrevious pageupzcommand_list('cursor_up')zPrevious commandzClassVar[list[BindingType]]BINDINGSTzClassVar[bool]run_on_select)initz	var[bool]_list_visible
_show_busyNzvar[Screen[Any] | None]_calling_screenc                  $    \ rS rSr% SrS\S'   Srg) CommandPalette.OptionHighlightedi  zCPosted to App when an option is highlighted in the command palette.OptionList.OptionHighlightedhighlighted_eventrr   Nrj   rk   rl   rm   rn   ro   rq   rr   rP   rL   OptionHighlightedr     s    Q77ZrP   r$  c                      \ rS rSrSrSrg)CommandPalette.Openedi  z1Posted to App when the command palette is opened.rr   N)rj   rk   rl   rm   rn   rq   rr   rP   rL   Openedr&    s    ?rP   r'  c                  $    \ rS rSr% SrS\S'   Srg)CommandPalette.Closedi  z1Posted to App when the command palette is closed.rg   option_selectedrr   Nr#  rr   rP   rL   Closedr)    s    ?jrP   r+  u   Search for commands…)placeholderr   r   classesc                  > [         TU ]  UUUS9  U R                  S5        SU l         SU l         SU l         Xl        / U l         SU l         X l	        g)zInitialise the command palette.

Args:
    providers: An optional list of providers to use. If None, the providers supplied
        in the App or Screen will be used.
    placeholder: The placeholder text for the command palette.
)r   r-  r   --textual-command-paletteNr   )
r   r   	add_class_selected_command_busy_timer_no_matches_timer_supplied_providers
_providers
_hit_count_placeholder)rK   	providersr,  r   r   r-  r   s         rL   r   CommandPalette.__init__  sp      	 	 	

 	23<@8)-J/3]:C *,> ''rP   c                8    U R                   R                  S5      $ )zIs a command palette current open?

Args:
    app: The app to test.

Returns:
    `True` if a command palette is currently open, `False` if not.
r/  )r   	has_class)r   s    rL   is_openCommandPalette.is_open  s     zz##$?@@rP   c                        SS jnU R                   c
  [        5       $ U R                  c:  1 U" U R                  R                  5      kU" U R                   R                  5      k$ 1 U" U R                  5      k$ )zThe currently available command providers.

This is a combination of the command providers defined [in the
application][textual.app.App.COMMANDS] and those [defined in
the current screen][textual.screen.Screen.COMMANDS].
c              3     #    U  HR  n[        U[        5      (       a  Uv   M  [        U5      (       a  [        U[        5      (       a  Uv   MI  U" 5       v   MT     g7f)zLoad the providers from a source (typically from the COMMANDS class variable)
at the App or Screen level.

Args:
    provider_source: The source of providers.

Returns:
    An iterable of providers.
N)rT   r   r   
issubclassr>   )provider_sourceproviders     rL   get_providers7CommandPalette._provider_classes.<locals>.get_providers  sI      ,h77"NX&&:h+I+I"N #*$ ,s   AA)rA  r   rd   zIterable[type[Provider]])r  setr4  r   COMMANDS)rK   rC  s     rL   _provider_classes CommandPalette._provider_classes  s    	%+	%%	%* '5L%%-txx001t33<<= 
 >]4#;#;<==rP   c              #    #    [        SS9   [        SS9   [        5       v   [        U R                  SS9v   U R
                  (       d  [        S5      v   SSS5        [        SS9   [        5       v   [        5       v   SSS5        SSS5        g! , (       d  f       NA= f! , (       d  f       N(= f! , (       d  f       g= f7f)	zFCompose the command palette.

Returns:
    The content of the screen.
z--containerr   z--inputF)r,  select_on_focusu   ▶Nz	--results)	r#   r"   r  r  r7  r  r1   r  r3   rJ   s    rL   composeCommandPalette.compose  s      'y) l""t/@/@RWXX)) **	 *
 [)!m#&(( * ('))
 *) ('sL   
C
B4ABB4(B#B4		C
B 	B4#
B1	-B44
C>Cc                    U R                  UR                  UR                  5      S   U L aM  U R                  5         U R                  R                  [        R                  SS95        U R                  5         gg)zHandle the click event.

Args:
    event: The click event.

This method is used to allow clicking on the 'background' as a
method of dismissing the palette.
r   Fr*  N)	get_widget_atscreen_xscreen_y_cancel_gather_commandsr   post_messager:   r+  dismissrK   events     rL   	_on_clickCommandPalette._on_click$  sa     ennenn=a@DH((*HH!!."7"7"7"NOLLN IrP   c                   U R                   R                  [        R                  5       5        U R                   R                  S   U l        U R                  SSS9nU R
                  c   eU R                   Vs/ s H  nU" U R
                  U5      PM     snU l        U R                   H  nUR                  5         M     U R                  S5        gs  snf )z4Configure the command palette once the DOM is ready.r  T)partialN )r   rS  r:   r'  screen_stackr  get_visual_stylerG  r5  r   _gather_commands)rK   _r   provider_classrB  s        rL   	_on_mountCommandPalette._on_mount2  s     	n3356#xx44R8++,HRV+W##/// #'"8"8
"8 4//="8
 H! (b!
s   9Cc           	        #    U R                   (       a`  [        U R                    Vs/ s H  n[        UR                  5       5      PM     sn5      I Sh  vN   U R                   R	                  5         ggs  snf  N%7f)z2Shutdown providers when command palette is closed.N)r5  r   r
   r   clear)rK   rB  s     rL   _on_unmountCommandPalette._on_unmountC  sa     ??CG??S?xX//12?S   OO!!#	 Ss   %A<#A5

A<A:&A<c                b    U R                   b"  U R                   R                  5         SU l         gg)z)Stop any busy countdown that's in effect.N)r2  stoprJ   s    rL   _stop_busy_countdown#CommandPalette._stop_busy_countdownK  s-    '!!##D (rP   g      ?zFinal[float]_BUSY_COUNTDOWNc                x   ^  T R                  5         SU 4S jjnT R                  T R                  U5      T l        g)z7Start a countdown to showing that we're busy searching.c                 8   > T R                   (       a  ST l        g g )NT)r  r  rJ   s   rL   _become_busy:CommandPalette._start_busy_countdown.<locals>._become_busyX  s    !!"& "rP   Nrh   )rj  	set_timerrl  r2  )rK   ro  s   ` rL   _start_busy_countdown$CommandPalette._start_busy_countdownT  s/    !!#	'  >>$*>*>MrP   c                b    U R                   b"  U R                   R                  5         SU l         gg)z1Stop any 'No matches' countdown that's in effect.N)r3  ri  rJ   s    rL   _stop_no_matches_countdown)CommandPalette._stop_no_matches_countdown^  s-    !!-""'')%)D" .rP   _NO_MATCHES_COUNTDOWNc                |   ^ ^ T R                  5         SUU 4S jjnT R                  T R                  U5      T l        g)zStart a countdown to showing that there are no matches for the query.

Args:
    search_value: The value being searched for.

Adds a 'No matches found' option to the command list after
`_NO_MATCHES_COUNTDOWN` seconds.
c                    > T(       a]  TR                  [        5      n U R                  [        [        R
                  " [        SSS95      STR                  S95        STl        g STl        g )NzNo matches foundznot bold)styleT)r   r   F)		query_oner  
add_optionr6   r   centerr   _NO_MATCHESr  )command_listsearch_valuerK   s    rL   _show_no_matchesDCommandPalette._start_no_matches_countdown.<locals>._show_no_matchesr  s`     #~~k:''T*<J%OP!%++ &*" &+"rP   Nrh   )ru  rq  rw  r3  )rK   r  r  s   `` rL   _start_no_matches_countdown*CommandPalette._start_no_matches_countdowng  s:     	'')	+ 	+( "&&&"
rP   c                    U R                  [        5      R                  U R                  S5        U R                  S[        5      R                  U R                  S5        U R                  (       d  SU l        gg)z-React to the list visible flag being toggled.	--visiblez#--inputz--list-visibleFN)r{  r  	set_classr  r"   r  rJ   s    rL   _watch__list_visible#CommandPalette._watch__list_visible  s]    {#--d.@.@+Nz:.88 0	
 !!#DO "rP   c                   #    U R                  [        5      R                  U R                  S5        U R                  [        5      R                  U R                  S5        g7f)zzReact to the show busy flag being toggled.

This watcher adds or removes a busy indication depending on the
flag's state.
r  z--populatingN)r{  r3   r  r  r  rJ   s    rL   _watch__show_busy CommandPalette._watch__show_busy  sB      	'(224??KP{#--doo~Ns   A A"c                b   #    U   Sh  vN nUR                  U5      I Sh  vN   M$   N N
 g7f)zConsume a source of matching commands, feeding the given command queue.

Args:
    hits: The hits to consume.
    commands: The command queue to feed.
N)put)r   r   r   s      rL   _consumeCommandPalette._consume  s0       	$#,,s###	$# s(   /-)-/+/-//c           
      #    [        5       nU R                   Vs/ s H-  n[        U R                  UR	                  U5      U5      5      PM/     nnU R                  5         SnU(       dm  [        S U 5       5      (       aV   [        UR                  5       S5      I Sh  vN 7v nUR                  5         U(       d  [        S U 5       5      (       a  MV  U Hs  nUR                  5       (       d  M  UR                  5       nUc  M/  SSKJn  U R                   R#                  UR%                  ['        U5      XwR(                  5      5        Mu     U(       d  U R+                  5         U(       dN  UR-                  5       (       d9  UR                  5       I Sh  vN 7v nU(       d  UR-                  5       (       d  M9  U(       a  U H  nUR/                  5         M     ggs  snf  GND! [         a     GN<[         a    Sn GNJf = f Nn7f)zSearch for a given search value amongst all of the command providers.

Args:
    search_value: The value to search for.

Yields:
    The hits made amongst the registered command providers.
Fc              3  J   #    U  H  oR                  5       (       + v   M     g 7frR   )done).0r   s     rL   	<genexpr>-CommandPalette._search_for.<locals>.<genexpr>  s     !K(kkm"3"3(s   !#g?NTr   r   )r   r5  r
   r  r   rr  anyr   get	task_doner	   r   r  	exceptionr   r   r   r   from_exceptiontype__traceback__rj  emptycancel)	rK   r  r   rB  searchesabortedr   r  r   s	            rL   _search_forCommandPalette._search_for  s     /4g !OO
 , $$\2 , 	 
 	""$  c!K(!KKK% '/x||~s&C CC ""$ c!K(!KKK. F{{}}",,.	(8HHNN!00 OY8O8O " %%'
 (.."2"2"*,,.00G (.."2"2 " # E
( !D  ! L 1sw   H4G2HG& G# G& '.HH3HBHH#H<'H#G& &
H0H3H>HHHc                    [        U[        S5      SS9nUR                  5       R                  U5        U(       a  SUl        [        UR                  5      U l        UR                  U l        g)zRefresh the command list.

Args:
    command_list: The widget that shows the list of commands.
    commands: The commands to show in the widget.
    clear_current: Should the current content of the list be cleared first?
z	hit.scoreT)keyreverser   N)	sortedr   clear_optionsadd_optionshighlightedrg   option_countr  r6  )rK   r  r   clear_currentsorted_commandss        rL   _refresh_command_list$CommandPalette._refresh_command_list  sZ     !z+/FPTU""$00A'(L$!,";";<&33rP   g      ?_RESULT_BATCH_TIMEz--no-matchesz
Final[str]r~  z)--textual-command-palette-gather-commands_GATHER_COMMANDS_GROUP)	exclusivegroupc           	     b  ^ ^#    / nT R                  [        5      nUR                  S:X  aD  UR                  S5      R                  T R
                  :X  a  UR                  T R
                  5        Sn[        5       nST l        Sn[        5       nT R                  U5      nUR                  5       n	 U	R                  5       I Sh  vN mT(       a  S
UU 4S jjn
[        S5      R                  U
" 5       5      nUR!                  [#        UT[%        U5      S95        UR&                  (       a  Od[        5       nX-
  T R(                  :  a  T R+                  X2U5        SnUnUS-  n UR-                  UR&                  5      I Sh  vN mT(       a  M  UR&                  (       d  T R+                  X2U5        ST l        UR                  S:X  a)  UR&                  (       d  ST l        T R1                  U5        T R3                  S	5        g GNB! [         a    Sm GNOf = f N! [         a     M  f = f7f)zmGather up all of the commands that match the search value.

Args:
    search_value: The value to search for.
   r   FTNc               3    >#    Tc   e[        TR                  [        5      (       a#  [        R                  " TR                  5      v   O"[        R
                  " TR                  5      v   TR                  (       aW  [        R                  " TR                  S5      5      n [        R
                  " TR                  5      R                  U 5      v   gg7f)zGenerator for prompt content.Nr  )rT   rM   r   r$   from_rich_textfrom_markuprH   r,   from_stylesget_component_stylesstylize_before)
help_styler   rK   s    rL   build_prompt5CommandPalette._gather_commands.<locals>.build_prompt\  s     &cjj$//!00<<!--cjj99 88!&!2!2112NO"J "--chh7FFzRR	 s   CC
r   z-ready)rd   zIterable[Content])r{  r  r  get_option_at_indexr   r~  remove_optionr7   r  r   r  	__aiter__	__anext__StopAsyncIterationr$   joinr   r   r_   is_cancelledr  r  asendr6  r  r0  )rK   r  gathered_commandsr  
command_idworkerr  last_updatesearch_routinesearch_resultsr  rM   nowr   s   `            @rL   r_  CommandPalette._gather_commands  s	     ,. ~~k2 %%*00366$:J:JJ&&t'7'78
 
 $%     k )),7'113	&0022C S S T]''7F$$WVSS_%MN""+C!T%<%<<** ] !&!!OJ
*001D1DEEQ c\ ""&&|V  
 $$)&2E2EDO,,\:x C 3! 	 C	Z F% sz   B,H/1H	 HH	 	BH/%H HH H/A5H/H	 	HH/HH/H 
H,(H/+H,,H/c                N    U R                   R                  X R                  5        g)z-Cancel any operation that is gather commands.N)workerscancel_groupr  rJ   s    rL   rR  &CommandPalette._cancel_gather_commands  s    !!$(C(CDrP   c                    UR                  5         U R                  5         U R                  5         U R                  UR                  R                  5       5        g)zJReact to input in the command palette.

Args:
    event: The input event.
N)ri  rR  ru  r_  valuestriprU  s     rL   _inputCommandPalette._input  s@     	

$$&'')ekk//12rP   c                T   UR                  5         U R                  5         U R                  [        5      nU R	                  [
        R                  5         [        UR                  [        5      (       d   eUR                  R                  n[        UR                  5      Ul        X0l        SSS5        UR                  5         SU l        U R                  ["        5      R%                  5         SU l        U R(                  (       a  U R+                  5         gg! , (       d  f       Nr= f)zcReact to a command being selected from the dropdown.

Args:
    event: The option selection event.
NFr   )ri  rR  r{  r  preventr2   ChangedrT   optionr   r   r_   rG   r  r1  
action_endr  r  r  r6  r  _select_or_command)rK   rV  inputr   s       rL   _select_commandCommandPalette._select_command  s     	

$$&|,\\%--(ellG4444,,""Cchh-EK%("	 )
 	"{#113##%  )(s   AD
D'c                `   Ub  UR                  5         U R                  (       ag  U R                  [        5      nUR                  c3  U R                  5         UR                  S:X  a  U R                  S5        ggU R                  S5        gU R                  b  U R                  5         U R                  R                  [        R                  SS95        U R                  R                  5         U R                  5         U R                  R!                  U R                  R"                  5        gg)z2Depending on context, select or execute a command.Nr  selectTrN  )ri  r  r{  r  r  _action_cursor_downr  _action_command_listr1  rR  r   rS  r:   r+  delay_updaterT  
call_laterrE   )rK   rV  r  s      rL   r  !CommandPalette._select_or_command  s     JJL>>+6L''/((*,,1--h7 2 ))(3 %%1 ,,.%%n&;&;D&;&QR%%'##D$:$:$B$BC 2rP   c                |    UR                  5         U R                  R                  [        R	                  US95        g)z=Stop any unused events so they don't leak to the application.)r"  N)ri  r   rS  r:   r$  rU  s     rL   _stop_event_leakCommandPalette._stop_event_leak  s.     	

n>>QV>WXrP   c                    U R                  5         U R                  R                  [        R	                  SS95        U R                  5         g)z6Handle a request to escape out of the command palette.FrN  N)rR  r   rS  r:   r+  rT  rJ   s    rL   _action_escapeCommandPalette._action_escape  s7    $$&n33E3JKrP   c                x     [        U R                  [        5      SU 35      nU" 5         g! [         a     gf = f)zPass an action on to the [`CommandList`][textual.command.CommandList].

Args:
    action: The action to pass on to the [`CommandList`][textual.command.CommandList].
action_N)getattrr{  r  AttributeError)rK   actioncommand_actions      rL   r  #CommandPalette._action_command_list  s?    	$T^^K%@GF8BTUN 	  		s   ", 
99c                *   U R                  [        5      nUR                  (       a   U R                  (       d  SU l        SUl        gUR                  (       a<  UR                  S5      R                  U R                  :X  d  U R                  S5        ggg)zHandle the cursor down action.

This allows the cursor down key to either open the command list, if
it's closed but has options, or if it's open with options just
cursor through them.
Tr   r  N)	r{  r  r  r  r  r  r   r~  r  )rK   r   s     rL   r  "CommandPalette._action_cursor_down  st     >>+.  ););!%D#$H !!00366$:J:JJ%%m4 K "rP   )
r2  r  r6  r  r3  r7  r5  r1  r  r4  rR   )r8  zProviderSource | Noner,  r_   r   rF   r   rF   r-  rF   rd   ri   )r   r   rd   rg   )rd   zset[type[Provider]])rd   r9   )rV  r%   rd   ri   )r`  r&   rd   ri   rh   )r  r_   rd   ri   )r   r=   r   zQueue[DiscoveryHit | Hit]rd   ri   )r  r_   rd   z(AsyncGenerator[DiscoveryHit | Hit, bool])r  r  r   zlist[Command]r  rg   rd   ri   )rV  zInput.Changedrd   ri   )rV  zOptionList.OptionSelectedrd   ri   )rV  z'Input.Submitted | Button.Pressed | Nonerd   ri   )rV  r!  rd   ri   )r  r_   rd   ri   )Arj   rk   rl   rm   rn   
AUTO_FOCUSr*   r  ro   r  r    r  r  r)   r  r  r  r   r(   r$  r'  r+  r   staticmethodr<  rp   rG  rK  rW  rb  rf  rj  rl  rr  ru  rw  r  r  r  r  r  r  r  r~  r  r   r_  rR  r   r2   r  r  r4   OptionSelectedr  	Submittedr1   Pressedr  r  r  r  r  rq   r   r   s   @rL   r:   r:     s   &J,2,D,D$$H -) RKj 	!"		
 	##		
 	~EB($>?
75Q3_5Q13EER#-H) &
 %)M>(  #5u5M95IE2J	2K/24yO,8E[G [ [ @ @ @ k k k ,0"( 4""(("( 	"(
 "( "( "( 
"( "(H 	A 	A %> %>N) ""$$ %(O\'UN* +.<-E"
H$O $ $U U 	1U n4'43@4QU4	4( (,+F,K,N)TJT9	D 67v! 8v!pE 	3 	3 
!!"& #&* ?C D< D	 D   DD 
$$%Y &Y

5 5rP   r:   )irn   
__future__r   abcr   r   asyncior   r   r   r	   r
   r   r   dataclassesr   	functoolsr   inspectr   operatorr   timer   typingr   r   r   r   r   r   r   r   	rich.reprrich
rich.alignr   	rich.textr   typing_extensionsr   r   textualr   r   textual.bindingr    r!   textual.containersr"   r#   textual.contentr$   textual.eventsr%   r&   textual.fuzzyr'   textual.messager(   textual.reactiver)   textual.screenr*   r+   textual.styler,   textual.timerr-   textual.typesr.   textual.visualr/   textual.widgetr0   textual.widgetsr1   r2   r3   r4   r5   textual.widgets.option_listr6   textual.workerr7   textual.appr8   r9   __all__r<   r;   r=   ro   r   r>   r   r   r   reprautor   r  r  r  r:   rr   rP   rL   <module>r      s   # #   " $   	 	 	    .  0 3 # ' ! #   4   2 % ! O O . -. +0 +0 +0\ 1* 1* 1*h   45i 5 =U	 U BRs Rj*J * n  
5X 5p !f !  !H5* 5pU 05 r5&t, r5rP   