
    Cj                        S SK Jr  S SK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5      r " S S	\5      r " S
 S\5      r S       SS jjrg)    )annotations)CallableTypeVar)SelectorSet)parse_selectors)
TokenError)MessageDecoratedTypec                      \ rS rSrSrSrg)OnDecoratorError   zcErrors related to the `on` decorator.

Typically raised at import time as an early warning system.
 N__name__
__module____qualname____firstlineno____doc____static_attributes__r       ]/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/textual/_on.pyr   r      s    r   r   c                      \ rS rSrSrSrg)
OnNoWidget   z;A selector was applied to an attribute that isn't a widget.r   Nr   r   r   r   r   r      s    Er   r   Nc           	       ^ ^ 0 nUb  XS'   U(       a  UR                  U5        0 mUR                  5        Ht  u  pEUS:X  a*  T R                  [        R                  :X  a  [	        S5      eO0UT R
                  ;  a   [	        SU< S3T R                   S3-   5      e [        U5      TU'   Mv     SU U4S
 jjnU$ ! [         a    [	        SU< SU S	35      Sef = f)ae  Decorator to declare that the method is a message handler.

The decorator accepts an optional CSS selector that will be matched against a widget exposed by
a `control` property on the message.

Example:
    ```python
    # Handle the press of buttons with ID "#quit".
    @on(Button.Pressed, "#quit")
    def quit_button(self) -> None:
        self.app.quit()
    ```

Keyword arguments can be used to match additional selectors for attributes
listed in [`ALLOW_SELECTOR_MATCH`][textual.message.Message.ALLOW_SELECTOR_MATCH].

Example:
    ```python
    # Handle the activation of the tab "#home" within the `TabbedContent` "#tabs".
    @on(TabbedContent.TabActivated, "#tabs", pane="#home")
    def switch_to_home(self) -> None:
        self.log("Switching back to the home tab.")
        ...
    ```

Args:
    message_type: The message type (i.e. the class).
    selector: An optional [selector](/guide/CSS#selectors). If supplied, the handler will only be called if `selector`
        matches the widget from the `control` attribute of the message.
    **kwargs: Additional selectors for other attributes of the message.
NcontrolzFThe message class must have a 'control' to match with the on decoratorzThe attribute z( can't be matched; have you added it to z.ALLOW_SELECTOR_MATCH?zUnable to parse selector z for z; check for syntax errorsc                ~   > [        U S5      (       d  [        U S/ 5        [        U S5      R                  TT45        U $ )zLStore message and selector in function attribute, return callable unaltered._textual_on)hasattrsetattrgetattrappend)methodmessage_typeparsed_selectorss    r   	decoratoron.<locals>.decoratorT   s>     v}--FM2.&--|=M.NOr   )r#   r
   returnr
   )	updateitemsr   r	   r   ALLOW_SELECTOR_MATCHr   r   r   )r$   selectorkwargs	selectors	attributecss_selectorr&   r%   s   `      @r   onr1      s   F !#I') ;=#,??#4		!##w6&\  7 l???" -UV!**++ABC 	*9,*GY' $5$    	"+L+;5Kde	s   B99C)N)r$   ztype[Message]r,   z
str | Noner-   strr(   z(Callable[[DecoratedType], DecoratedType])
__future__r   typingr   r   textual.css.modelr   textual.css.parser   textual.css.tokenizerr   textual.messager	   r
   	Exceptionr   r   r1   r   r   r   <module>r:      sj    " $ ) - , #(y F F
 9=EE+5EHKE-Er   