
    Cjn                       % S r SSKJr  SSKrSSKrSSKJr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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  SS
KJr  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*J+r+J,r,  SSK-J.r.  SSK/J0r0J1r1J2r2  SSK3J4r4  SSK5J6r6J7r7  SSK8J9r9J:r:  SSK;J<r<  SSK=J>r>J?r?J@r@  SSKAJBrBJCrCJDrDJErE  SSKFJGrGJHrH  SSKIJJrJ  SSKKJLrL  SSKMJNrN  SSKOJPrPJQrQJRrRJSrS  SS	KTJrU  SSKVJWrW  SSKXJYrYJZrZJ[r[  SSK\J]r]  \(       aD  SS K^J_r_J`r`  SS!KaJbrb  SS"KcJdrd  SS#KeJfrf  SS$KAJgrgJhrh  SS%KiJjrj  SS&KkJlrl  SS'KmJnrn  SS(KoJprp  SS)KqJrrrJsrsJtrt  SS*K^Juru  \R                  " \J5      rw\uS+   rxS,\yS-'    \" S.5      rzS/r{S,\yS0'     " S1 S2\|5      r}S<S3 jr~ " S4 S5\|5      r " S6 S7\5      r " S8 S95      r\GR                  GR                   " S: S;\N5      5       rg)=z
The module contains `DOMNode`, the base class for any object within the Textual Document Object Model,
which includes all Widgets, Screens, and Apps.

    )annotationsN)	lru_cachepartial)getfile)TYPE_CHECKINGAnyCallableClassVarIterableMappingSequenceTypeTypeVarcastoverload)ReprHighlighter)
NULL_STYLE)Style)Text)Tree)NoActiveAppErroractive_message_pump)NodeList)WatchCallbackType)BindingBindingsMapBindingType)LRUCache)BLACKWHITEColor)friendly_list)VALID_DISPLAYVALID_VISIBILITY)DeclarationErrorStyleValueError)match)is_id_selectorparse_declarationsparse_selectors)InvalidQueryFormat	NoMatchesTooManyMatches	WrongType)RenderStylesStyles)
IDENTIFIER)
TokenError)MessagePump)ReactiveReactiveError_Mutated_watch)Timer)walk_breadth_firstwalk_breadth_search_idwalk_depth_first)WorkerManager)Self	TypeAlias)SupportsRichComparison)RenderableType)AppDOMQuery	QueryType)CSSLocation)MessageScreenWidget)WorkerWorkType
ResultType)Literal)depthbreadthr>   
WalkMethodReactiveTypez$tuple[int, str, Type[Widget] | None]QueryOneCacheKeyc                      \ rS rSrSrSrg)BadIdentifierU   zRException raised if you supply a `id` attribute or class name in the wrong format. N__name__
__module____qualname____firstlineno____doc____static_attributes__rW       ]/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/textual/dom.pyrU   rU   U   s    \r_   rU   c                l    [         R                  nU H  nU" U5      b  M  [        U< SU  S35      e   g)zValidate identifier and raise an error if it fails.

Args:
    description: Description of where identifier is used for error message.
    *names: Identifiers to check.
Nz is an invalid zl; identifiers must contain only letters, numbers, underscores, or hyphens, and must not begin with a number.)_re_identifier	fullmatchrU   )descriptionnamesr'   names       r`   check_identifiersrg   Y   sG     $$E;(/+ 7} }  r_   c                      \ rS rSrSrSrg)DOMErrori   z4Base exception class for errors relating to the DOM.rW   NrX   rW   r_   r`   ri   ri   i   s    >r_   ri   c                      \ rS rSrSrSrg)NoScreenm   z.Raised when the node has no associated screen.rW   NrX   rW   r_   r`   rl   rl   m   s    8r_   rl   c                  <    \ rS rSrSr S     SS jjrS	S jrSrg)
_ClassesDescriptorq   z.A descriptor to manage the `classes` property.Nc                ,    [        UR                  5      $ )z1A frozenset of the current classes on the widget.)	frozenset_classes)selfobjobjtypes      r`   __get___ClassesDescriptor.__get__t   s     &&r_   c                    [        U[        5      (       a  [        UR                  5       5      nO[        U5      n[	        S/UQ76   UR
                  U:w  a  X1l        UR                  5         gg)zReplaces classes entirely.
class nameN)
isinstancestrsetsplitrg   rs   update_node_styles)rt   ru   classesclass_namess       r`   __set___ClassesDescriptor.__set__z   sW    gs##gmmo.Kg,K,55<<;&&L""$ 'r_   rW   N)ru   DOMNoderv   ztype[DOMNode] | Nonereturnfrozenset[str])ru   r   r   str | Iterable[str]r   None)rY   rZ   r[   r\   r]   rw   r   r^   rW   r_   r`   ro   ro   q   s-    8 =A''%9'	'	%r_   ro   c                  H
  ^  \ rS rSr% SrSrS\S'    SrS\S'    \" 5       r	S\S'    S	r
S
\S'    / rS\S'    SrS\S'    S	rS\S'    SrS\S'   SrS\S'   SrS\S'   \" 5       rS\S'   SrS\S'   S	rS\S'   S\S'   S\S'   S\S '   0 rS!\S"'    S	S	S	S#.       SU 4S$ jjjrSS% jr      SS& jrSS' jr      SS( jrSS) jrSS* jr\SS+ j5       r\SS, j5       r\SS- j5       r \SS. j5       r!S	S/S0.     SS1 jjr"\SS2 j5       r#\#RH                  SS3 j5       r#\SS4 j5       r%SSS5 jjr&       S                 SS6 jjr'\SS7 j5       r(\SS8 j5       r)SS9 jr*   S       SU 4S: jjjr+SS; jr,S< r-SS= jr.\SS> j5       r/\0\1" S	S?9SS@ j5       5       r2\0SSA j5       r3SSB jr4SSC jr5SSD jr6\0\1" S	S?9SSE j5       5       r7\SSF j5       r8\SSG j5       r9\SSH j5       r:\:RH                  SSI j5       r:\SSJ j5       r;\SSK j5       r<\SSL j5       r=\>" 5       r? \SSM j5       r@\SSN j5       rA\SSO j5       rB\SSP j5       rC\CRH                  SSQ j5       rC\SSR j5       rD\DRH                  SSS j5       rD\SST j5       rE\SSU j5       rF\SSV j5       rG\SSW j5       rH\SSX j5       rISSY jrJ    SSZ jrK    SS[ jrL\SS\ j5       rM\SS] j5       rN\SS^ j5       rO\SS_ j5       rP S         SS` jjrQSSa jrRSSb jrSSSc jrTSSd jrU\V" SeS Sf9rW\X(       a0  \YS/SgS/Sh.         SSi jj5       rZ\YS/SgS/Sh.       SSj jj5       rZ SS/SgS/Sh.         SSk jjjrZ\X(       a  \YSSSl jj5       r[\YSSm j5       r[ S   SSn jjr[\X(       a  \YSSSo jj5       r\\YSSp j5       r\ S   SSq jjr\\X(       a$  \YSSr j5       r]\YSSs j5       r]\Y      SSt j5       r] S     SSu jjr]\X(       a$  \YSSv j5       r^\YSSw j5       r^\Y      SSx j5       r^ S     SSy jjr^\X(       a$  \YSSz j5       r_\YSS{ j5       r_\Y      SS| j5       r_ S     SS} jjr_\X(       a$  \YSS~ j5       r`\YSS j5       r`\Y      SS j5       r` S     SS jjr`SSS jjraSS jrbSS.SS jjrc S       SS jjrdSS jreSSS jjrfSS.SS jjrgSS.SS jjrhSS jriSS jrjSS jrk\SS j5       rlSS/S/S.       SS jjrmSS jrnSS jroSS jrpSrqU =rr$ )r      zIThe base class for object that can be in the Textual DOM (App and Widget) zClassVar[str]DEFAULT_CSSDEFAULT_CLASSESzClassVar[set[str]]COMPONENT_CLASSESN
str | NoneBINDING_GROUP_TITLEzClassVar[list[BindingType]]BINDINGSTzClassVar[bool]
SCOPED_CSSzClassVar[str | None]HELP_inherit_css_inherit_component_classes_inherit_bindingszClassVar[frozenset[str]]_css_type_namesr|   _css_type_namezClassVar[BindingsMap | None]_merged_bindingszClassVar[dict[str, Reactive]]
_reactivesz6dict[type[Message], list[tuple[Callable, str | None]]]_decorated_handlers	_computesz/ClassVar[dict[str, Callable[[App[Any]], bool]]]_PSEUDO_CLASSES)rf   idr   c               H  > [        5       U l        Xl        S U l        Ub  [	        SU5        X l        U(       a  UR                  5       O/ n[	        S/UQ76   U R                  R                  U5        [        U 5      U l        [        U 5      U l
        [        U 5      U l        [        X R                  U R                  5      U l        0 U l        S U l        S U l        U R#                  U R$                  5       Vs1 s H  oUR&                  iM     snU l        U R*                  c
  [-        5       OU R*                  R/                  5       U l        SU l        SU l        SU l         SU l         S U l        SU l        [?        S5      U l         SU l!        [D        TU ]  5         g s  snf )Nr   rz   Fi   )$r}   rs   _name_idrg   r~   updater   _nodesr0   _css_styles_inline_stylesr/   styles_component_styles_auto_refresh_auto_refresh_timer
_css_bases	__class__rY   
_css_typesr   r   copy	_bindings_has_hover_style_has_focus_within_has_order_style_has_odd_or_even_reactive_connect_pruningr   _query_one_cache_trap_focussuper__init__)rt   rf   r   r   rs   clsr   s         r`   r   DOMNode.__init__   sq    #&%
>dB'H&-7==?2,22X& (#)$<&,Tl$0""D$7$7%
 ;=+/15 37??4>>3RS3RC<<3RS $$, M&&++- 	
 ',',&+ 	Q&+<  	 EMd^ ' Ts   :Fc                    U $ )zGet the DOM base node (typically self).

All DOM queries on this node will use the return value as the root node.
This method allows the App to query the default screen, and not the active screen.

Returns:
    DOMNode.
rW   rt   s    r`   _get_dom_baseDOMNode._get_dom_base   s	     r_   c                    UR                   n[        U[        5      (       d  [        S5      eX0R                  ;  a'  [        SU< SU R                  R                   S35      e[        U SU 3U5        g)a^  Sets a reactive value *without* invoking validators or watchers.

Example:
    ```python
    self.set_reactive(App.theme, "textual-light")
    ```

Args:
    reactive: A reactive property (use the class scope syntax, i.e. `MyClass.my_reactive`).
    value: New value of reactive.

Raises:
    AttributeError: If the first argument is not a reactive.
z6A Reactive class is required; for example: MyApp.themezNo reactive called z/; Have you called super().__init__(...) in the z constructor?
_reactive_N)	rf   r{   r4   	TypeErrorr   AttributeErrorr   rY   setattr)rt   reactivevaluerf   s       r`   set_reactiveDOMNode.set_reactive   s{    " }}(H--TUU& %dX-\]a]k]k]t]t\u  vC  D  	
4&)51r_   c                X    SUR                    3n[        X5      nUR                  XSS9  g)a  Force an update to a mutable reactive.

Example:
    ```python
    self.reactive_name_list.append("Jessica")
    self.mutate_reactive(MyClass.reactive_name_list)
    ```

Textual will automatically detect when a reactive is set to a new value, but it is unable
to detect if a value is _mutated_ (such as updating a list, dict, or attribute of an object).
If you do wish to use a collection or other mutable object in a reactive, then you can call
this method after your reactive is updated. This will ensure that all the reactive _superpowers_
work.

!!! note

    This method will cause watchers to be called, even if the value hasn't changed.

Args:
    reactive: A reactive property (use the class scope syntax, i.e. `MyClass.my_reactive`).
r   T)alwaysN)rf   getattr_set)rt   r   internal_namer   s       r`   mutate_reactiveDOMNode.mutate_reactive  s.    . %X]]O4,d$/r_   c                   Sn[         R                  " 5       nU R                  c  0 U l        0 U Vs0 s H  oUR                  U_M     snEUEnUR	                  5        H  u  peX`R
                  ;  a  [        SU< SU  35      e[        U[        5      (       aT  [        XER                  5      (       d:  [        SUR                  R                   SUR                  R                   S35      eXE4U R                  U'   M     U R                  (       a  U R                  5         U $ U R                  U R                  5        U $ s  snf )aS  Bind reactive data so that changes to a reactive automatically change the reactive on another widget.

Reactives may be given as positional arguments or keyword arguments.
See the [guide on data binding](/guide/reactivity#data-binding).

Example:
    ```python
    def compose(self) -> ComposeResult:
        yield WorldClock("Europe/London").data_bind(WorldClockApp.time)
        yield WorldClock("Europe/Paris").data_bind(WorldClockApp.time)
        yield WorldClock("Asia/Tokyo").data_bind(WorldClockApp.time)
    ```

Raises:
    ReactiveError: If the data wasn't bound.

Returns:
    Self.
Tz&Unable to bind non-reactive attribute  on zUnable to bind data; z is not defined on .)r   getr   rf   itemsr   r5   r{   r4   ownerrY   r   _is_mounted_initialize_data_bind
call_later)rt   	reactives	bind_vars_rich_traceback_omitparentr   rf   s          r`   	data_bindDOMNode.data_bind.  s;   0  $$((*!!)%'D"X	J	Hx/	JXiX	'oo/ND??*#<THDO  (H--j7 7 $+HNN,C,C+DDWX^XhXhXqXqWrrst  -3+=D""4( 0 &&(  OOD667# Ks   E c                l  ^  T R                   (       d  gT R                   R                  5        H|  u  nu  p#SU 4S jjn[        U[        5      (       d   eU" U5      n[        U[        5      (       a  T R                  UUR                  USS9  Mb  T R                  [        XS5      5        M~     ST l         g)zRinitialize a data binding.

Args:
    compose_parent: The node doing the binding.
Nc                   >^  SUU 4S jjnU$ )zMake a setter for the given variable name.

Args:
    variable_name: Name of variable being set.

Returns:
    A callable which takes the value to set.
c                b   > Sn[         R                  " T5        [        TT[        U 5      5        g)zSet bound data.TN)r4   _initialize_objectr   r6   )r   r   rt   variable_names     r`   setterBDOMNode._initialize_data_bind.<locals>.make_setter.<locals>.setters  s'    +/(//5D-%Ar_   )r   objectr   r   rW   )r   r   rt   s   ` r`   make_setter2DOMNode._initialize_data_bind.<locals>.make_setteri  s    B B r_   Tinit)r   r|   r   zCallable[[object], None])	r   r   r{   r   r4   watchrf   r   r   )rt   r   compose_parentr   r   r   s   `     r`   r   DOMNode._initialize_data_bind_  s     %%9=9O9O9U9U9W5M5N& ng6666 /F(H--

"MM	    9:? :X@ "&r_   c                :    U R                   R                  U5        g)a  Add a node to children.

This is used by the compose process when it adds children.
There is no need to use it directly, but you may want to override it in a subclass
if you want children to be attached to a different node.

Args:
    widget: A Widget to add.
N)r   _append)rt   widgets     r`   compose_add_childDOMNode.compose_add_child  s     	F#r_   c                    U R                   $ )z>A view on to the children.

Returns:
    The node's children.
)r   r   s    r`   childrenDOMNode.children  s     {{r_   c                .    U R                   R                  $ )zZThe displayed children (where `node.display==True`).

Returns:
    A sequence of widgets.
)r   	displayedr   s    r`   displayed_childrenDOMNode.displayed_children  s     {{$$$r_   c                .    U R                   R                  $ )zsThe displayed children (where `node.display==True` and `node.visible==True`).

Returns:
    A sequence of widgets.
)r   displayed_and_visibler   s    r`   displayed_and_visible_children&DOMNode.displayed_and_visible_children  s     {{000r_   c                D    [        S U R                   5       5      (       + $ )z Are there no displayed children?c              3  8   #    U  H  oR                   v   M     g 7fr   )display).0childs     r`   	<genexpr>#DOMNode.is_empty.<locals>.<genexpr>  s     >+}}+   )anyr   r   s    r`   is_emptyDOMNode.is_empty  s     >$++>>>>r_   Fkeyreversec               T    U R                   R                  XS9  U R                  SS9  g)a  Sort child widgets with an optional key function.

If `key` is not provided then widgets will be sorted in the order they are constructed.

Example:
    ```python
    # Sort widgets by name
    screen.sort_children(key=lambda widget: widget.name or "")
    ```

Args:
    key: A callable which accepts a widget and returns something that can be sorted,
        or `None` to sort without a key function.
    reverse: Sort in descending order.
r	  TlayoutN)r   _sortrefresh)rt   r
  r  s      r`   sort_childrenDOMNode.sort_children  s'    * 	c3D!r_   c                    U R                   $ )zPNumber of seconds between automatic refresh, or `None` for no automatic refresh.)r   r   s    r`   auto_refreshDOMNode.auto_refresh  s     !!!r_   c                    U R                   b!  U R                   R                  5         S U l         Ub#  U R                  XR                  SU < 3S9U l         Xl        g )Nzauto refresh )rf   )r   stopset_intervalautomatic_refreshr   )rt   intervals     r`   r  r    s`    ##/$$))+'+D$'+'8'800th7O (9 (D$ &r_   c                .    U R                   R                  $ )z:The app's worker manager. Shortcut for `self.app.workers`.)appworkersr   s    r`   r  DOMNode.workers  s     xxr_   c                    Xl         g)aj  Trap the focus.

When applied to a container, this will limit tab-to-focus to the children of that
container (once focus is within that container).

This can be useful for widgets that act like modal dialogs, where you want to restrict
the user to the controls within the dialog.

Args:
    trap_focus: `True` to trap focus. `False` to restore default behavior.
N)r   )rt   
trap_focuss     r`   r   DOMNode.trap_focus  s
     &r_   c	                   U R                   R                  [        R                  " 5       :w  a5  [	        U R                   R
                  U R                  R                  5      n	OU R                  R                  n	U	" UU UUUUUUUS9	n
U
$ )a  Run work in a worker.

A worker runs a function, coroutine, or awaitable, in the *background* as an async task or as a thread.

Args:
    work: A function, async function, or an awaitable object to run in a worker.
    name: A short string to identify the worker (in logs and debugging).
    group: A short string to identify a group of workers.
    description: A longer string to store longer information on the worker.
    exit_on_error: Exit the app if the worker raises an error. Set to `False` to suppress exceptions.
    start: Start the worker immediately.
    exclusive: Cancel all workers in the same group.
    thread: Mark the worker as a thread worker.

Returns:
    New Worker instance.
)rf   grouprd   exit_on_errorstart	exclusivethread)r  
_thread_id	threading	get_identr   call_from_threadr  _new_worker)rt   workrf   r#  rd   r$  r%  r&  r'  creatorworkers              r`   
run_workerDOMNode.run_worker  sz    > 88)"5"5"77dhh779Q9QRGll..G%,#'
&
 r_   c                    g)zIs the node a modal?FrW   r   s    r`   is_modalDOMNode.is_modal        r_   c                    g)z:Check if the node was displayed in the last screen update.FrW   r   s    r`   is_on_screenDOMNode.is_on_screen%  r5  r_   c                H    U R                   (       a  U R                  5         gg)zPerform an automatic refresh.

This method is called when you set the `auto_refresh` attribute.
You could implement this method if you want to perform additional work
during an automatic refresh.

N)r7  r  r   s    r`   r  DOMNode.automatic_refresh*  s     LLN r_   c                  > [         T
U ]  5         0 =o@l        [        U R                  5       HX  nUR                  UR                  R                  5        VVs0 s H  u  pg[        U[        5      (       d  M  Xg_M      snn5        MZ     Xl
        X l        X0l        [        5       nU R                  U 5      n	U	S   R                  U l        U	 H  nUR#                  UR                  5        M      U R%                  5       U l        [)        U5      U l        [)        [-        U 5       Vs/ s H/  nUR/                  S5      (       d  M  UR1                  S5      SS  PM1     sn5      U l        g s  snnf s  snf )Nr   )	_compute_compute__   )r   __init_subclass__r   reversed__mro__r   __dict__r   r{   r4   r   r   r   r}   r   rY   r   add_merge_bindingsr   rr   r   dir
startswithlstripr   )r   inherit_cssinherit_bindingsinherit_component_classesr   baserf   r   css_type_namesbasesr   s             r`   r@  DOMNode.__init_subclass__5  s@    	!#%''	NS[[)D +/--*=*=*?*?!(H5 #DN*? * ' 0)B&#&5s#"1X..Dt}}- "224'7!  H$D??#<= %C $$
#$s   E(7E(%E.E.c                   [        U [        5       [        5       5      nU H  nX0R                  ;  a  [        SU< S35      eU R                  U   nUR                  c   eUR                  UR                  5        UR                  R                  UR                  5        UR                  R                  UR                  5        U=R                  S-  sl	        M     U$ )zGet a "component" styles object (must be defined in COMPONENT_CLASSES classvar).

Args:
    names: Names of the components.

Raises:
    KeyError: If the component class doesn't exist.

Returns:
    A Styles object.
zNo z key in COMPONENT_CLASSES   )
r/   r0   r   KeyErrornode_update_noderL  mergeinline_updates)rt   re   r   rf   component_styless        r`   get_component_stylesDOMNode.get_component_stylesY  s     dFHfh7D111TH,EFGG#55d;#((444 0 5 56KK.334MM 0 7 78OOq O  r_   c                4    Sn[         R                  " U 5        g)z)Called after the object has been mounted.TN)r4   r   )rt   r   s     r`   _post_mountDOMNode._post_mountt  s    ###D)r_   c                    g)z~Called after styles are updated.

Implement this in a subclass if you want to clear any cached data when the CSS is reloaded.
NrW   r   s    r`   notify_style_updateDOMNode.notify_style_updatey      r_   c                8    U R                  U R                  5      $ )z4The DOMNode bases classes (including self.__class__))r   r   r   s    r`   _node_basesDOMNode._node_bases  s     t~~..r_   )maxsizec                    / nUn UR                  U5        UR                  (       d   U$ UR                   H  n[        U[        5      (       d  M  Un  O    U$ MV  )zGet the DOMNode base classes, which inherit CSS.

Args:
    base: A DOMNode class

Returns:
    An iterable of DOMNode classes.
)appendr   	__bases__
issubclassr   )r   rL  r   _class_bases        r`   r   DOMNode._css_bases  sf     (*NN6"&&   ))eW--"F *
  r_   c           	        / n[        U R                  5       Ho  n[        U[        5      (       d  M  UR                  (       d  UR                  5         UR                  [        UR                  R                  S/ 5      5      5        Mq     0 nU H*  nUR                  R                  5        H	  u  pVXcU'   M     M,     [        R                  " U5      nU$ )zAMerge bindings from base classes.

Returns:
    Merged bindings.
r   )rA  rB  ri  r   r   clearrg  r   rC  r   key_to_bindingsr   	from_keys)r   bindingsrL  keys	bindings_r
  key_bindingsnew_bindingss           r`   rE  DOMNode._merge_bindings  s     ')S[[)D$((--NN$))*b9	 * *,!I%.%>%>%D%D%F!(S	 &G " #,,T2r_   c                    g)zICalled when the widget is registered

Args:
    app: Parent application.
NrW   )rt   r  s     r`   _post_registerDOMNode._post_register  ra  r_   c              #    #    [        U S5      (       a  SU R                  S 4v   [        U S5      (       a  SU R                  S 4v   [        U S5      (       a2  U R                  (       a   SSR	                  U R                  5      4v   g g g 7f)Nr   rf   r   r   rs   r    )hasattrr   r   rs   joinr   s    r`   __rich_repr__DOMNode.__rich_repr__  st     4!!$**d**4$&&4$$SXXdmm444 *7$s   B	Bc                0   / nSS jn[        U R                  5       Hu  u  p4UR                  R                  SS5      nU(       d  M*  UR                  R                  SS5      nUR	                  U" U5      UU* U(       a  UR
                  OS45        Mw     U$ )a%  Gets the CSS for this class and inherited from bases.

Default CSS is inherited from base classes, unless `inherit_css` is set to
`False` when subclassing.

Returns:
    A list of tuples containing (LOCATION, SOURCE, SPECIFICITY, SCOPE) for this
        class and inherited from base classes.
c                     [        U 5      U R                   S34$ ! [        [        4 a    SU R                   S34s $ f = f)zGet the original location of this DEFAULT_CSS.

Args:
    base: The class from which the default css was extracted.

Returns:
    The filename where the class was defined (if possible) and the class
        variable the CSS was extracted from.
z.DEFAULT_CSSr   )r   rY   r   OSError)rL  s    r`   get_location.DOMNode._get_default_css.<locals>.get_location  sK    <$--'EFFw' <t}}o\:;;<s    !A A r   r   r   T)rL  Type[DOMNode]r   rE   )	enumeraterc  rC  r   rg  r   )rt   	css_stackr  tie_breakerrL  cssscopeds          r`   _get_default_cssDOMNode._get_default_css  s     >@		< "+4+;+;!<K}}((;Cs#}}00tD  $T*$/5++2		 "= r_   c                   [        5       nU R                  U 5       HY  nUR                  UR                  R	                  S[        5       5      5        UR                  R	                  SS5      (       a  MY    O   [        U5      $ )zGets the component classes for this class and inherited from bases.

Component classes are inherited from base classes, unless
`inherit_component_classes` is set to `False` when subclassing.

Returns:
    A set with all the component classes available.
r   r   T)r}   r   r   rC  r   rr   )r   component_classesrL  s      r`   _get_component_classesDOMNode._get_component_classes  sj     '*eNN3'D$$T]]%6%67JCE%RS==$$%A4HH (
 *++r_   c                .    [        SU R                  5      $ )zwThe parent node.

All nodes have parent once added to the DOM, with the exception of the App which is the *root* node.
DOMNode | None)r   _parentr   s    r`   r   DOMNode.parent  s     $dll33r_   c                    SSK Jn  U n Ub1  [        X!5      (       d!  UR                  nUb  [        X!5      (       d  M!  [        X!5      (       d  [        S5      eU$ ! [         a    [        S5      Sef = f)zThe screen containing this node.

Returns:
    A screen object.

Raises:
    NoScreen: If this node isn't mounted (and has no screen).
r   rG   NzSWidget is missing attributes; have you called the constructor in your widget class?znode has no screen)textual.screenrH   r{   r  r   RuntimeErrorrl   )rt   rH   rS  s      r`   screenDOMNode.screen  s~     	*#'	":d+C+C|| ":d+C+C $''/00  	e	s   2A A2c                    U R                   $ )z3The ID of this node, or None if the node has no ID.)r   r   s    r`   r   
DOMNode.id)  s     xxr_   c                    [        SU5        U R                  R                  5         U R                  b  [	        SU R                  < S35      eXl        U$ )zSets the ID (may only be done once).

Args:
    new_id: ID for this node.

Raises:
    ValueError: If the ID has already been set.
r   z<Node 'id' attribute may not be changed once set (current id=))rg   r   updatedr   
ValueError)rt   new_ids     r`   r   r  .  sR     	$'88NtxxlZ[\  r_   c                    U R                   $ )zThe name of the node.)r   r   s    r`   rf   DOMNode.nameA  s     zzr_   c                    U R                   R                  /nU R                  b  UR                  SU R                   35        SR	                  U5      $ )z-A CSS selector that identifies this DOM node.#r   )r   rY   r   rg  r}  rt   tokenss     r`   css_identifierDOMNode.css_identifierF  sD     ..))*77MMAdggY-(wwvr_   c                   [         R                  " U R                  R                  5      nU R                  b  UR                  SU R                   3SS9  U R                  (       aC  UR                  S5        UR                  SR                  S U R                   5       5      S5        U R                  (       a  UR                  SU R                   S3S	S9  U$ )
zGA syntax highlighted CSS identifier.

Returns:
    A Rich Text object.
r  bold)styler   c              3  $   #    U  H  ov   M     g 7fr   rW   r  
class_names     r`   r  0DOMNode.css_identifier_styled.<locals>.<genexpr>Z  s     "M*:s   italicz[name=]	underline)	r   styledr   rY   r   rg  r   r}  rf   r  s     r`   css_identifier_styledDOMNode.css_identifier_styledN  s     T^^44577MMAdggY-vM6<<MM#MM#(("M"MMxX99MMF499+Q/{MCr_   c                4    [        U R                  5       5      $ )z%A (frozen) set of all pseudo classes.)rr   get_pseudo_classesr   s    r`   pseudo_classesDOMNode.pseudo_classesb  s     00233r_   c                    U /nUR                   nU n[        UR                  =n[        5      (       a+  U" U5        [        UR                  =n[        5      (       a  M+  USSS2   $ )zA list of nodes from the App to this node, forming a "path".

Returns:
    A list of nodes, where the first item is the App, and the last is this node.
N)rg  r{   r  r   )rt   resultrg  rS  s       r`   css_path_nodesDOMNode.css_path_nodesg  s\     "&$,,.$994L $,,.$99dd|r_   c                    S1S U R                    5       kU R                  knU R                  b  UR                  SU R                   35        U$ )zWGet a set of selectors applicable to this widget.

Returns:
    Set of selector names.
*c              3  ,   #    U  H
  nS U 3v   M     g7f)r   NrW   r  s     r`   r  *DOMNode._selector_names.<locals>.<genexpr>  s     ?:*s   r  )rs   r   r   rD  )rt   	selectorss     r`   _selector_namesDOMNode._selector_namesv  sU     
??
 __
	
 88MMAdhhZ.)r_   c                    U R                   R                  S:g  =(       a7    U R                  =(       d    U R                  =(       d    U R                  (       + $ )zShould the DOM node be displayed?

May be set to a boolean to show or hide the node, or to any valid value for the `display` rule.

Example:
    ```python
    my_widget.display = False  # Hide my_widget
    ```
none)r   r   _closing_closedr   r   s    r`   r   DOMNode.display  s>     {{""f, 
MM:T\\:T]]2
 	
r_   c                    [        U[        5      (       a  U(       a  SOSU R                  l        gU[        ;   a  XR                  l        g[        SU< S[        [        5       S35      e)z
Args:
    new_val: Shortcut to set the ``display`` CSS property.
        ``False`` will set ``display: none``. ``True`` will set ``display: block``.
        A ``False`` value will prevent the DOMNode from consuming space in the layout.
blockr  z$invalid value for display (received , expected r  N)r{   boolr   r   r#   r&   r"   )rt   new_vals     r`   r   r    s_     gt$$-4'&DKK%")KK!6wk B)-89< r_   c                    U R                   R                  S5      nUb  US:g  $ U R                  (       a  U R                  R                  $ S$ )a  Is this widget visible in the DOM?

If a widget hasn't had its visibility set explicitly, then it inherits it from its
DOM ancestors.

This may be set explicitly to override inherited values.
The valid values include the valid values for the `visibility` rule and the booleans
`True` or `False`, to set the widget to be visible or invisible, respectively.

When a node is invisible, Textual will reserve space for it, but won't display anything.

visibilityhiddenT)r   get_ruler   visible)rt   	own_values     r`   r  DOMNode.visible  sD     KK((6	 ((&*kkt{{"";t;r_   c                    [        U[        5      (       a  U(       a  SOSU R                  l        g U[        ;   a  XR                  l        g [        SU< S[        [        5       S35      e)Nr  r  z'invalid value for visibility (received r  r  )r{   r  r   r  r$   r&   r"   )rt   	new_values     r`   r  r    s_    i&&2;YDKK"**%.KK"!9) G)*:;<A? r_   c                h   ^^^ SSK Jm  SU4S jjm[        T" U 5      5      nUU4S jmT" X5        U$ )zA Rich tree to display the DOM.

Log this to visualize your app in the textual console.

Example:
    ```python
    self.log(self.tree)
    ```

Returns:
    A Tree renderable.
r   Prettyc                   > T" U 5      $ )Render a node for the tree.rW   )rS  r  s    r`   render_info!DOMNode.tree.<locals>.render_info  s    $<r_   c                   > UR                    H7  nT" U5      nU R                  U5      nU R                   (       d  M/  T" XB5        M9     g r   )r   rD  )treerS  r  infobranchadd_childrenr  s        r`   r  "DOMNode.tree.<locals>.add_children  s9    "5)$=== /	 'r_   )rS  r   r   r  )rich.prettyr  r   )rt   r  r  r  r  s     @@@r`   r  DOMNode.tree  s2     	'	  K%&	0 	T r_   c                   ^^^^^^^^	 SSK Jm  SSKJm  SSKJm  SSKJm  SSKJ	m  S	UUUU4S jjm	[        5       m[        T	" U 5      5      nS
UUUU	4S jjmT" X5        U$ )zA Rich tree to display the DOM, annotated with the node's CSS.

Log this to visualize your app in the textual console.

Example:
    ```python
    self.log(self.css_tree)
    ```

Returns:
    A Tree renderable.
r   )Columns)Group)Panelr  rI   c                   > [        U T5      (       a;  T" T" U 5      T" SU R                  < 35      T" SU R                  < 35      /5      nU$ T" T" U 5      /5      nU$ )r  zregion=zvirtual_size=)r{   regionvirtual_size)rS  r  r  r  rJ   highlighters     r`   r  %DOMNode.css_tree.<locals>.render_info  sp    $''t#gdkk_$=>#+D,=,=+@A K t~.Kr_   c                :  > UR                    H  nT	" U5      nUR                  R                  nU(       a6  T" UTR                  [	        UR                  R                  5      SSSS95      nU R                  U5      nU R                   (       d  M  T" XR5        M     g)zAdd children to the tree.dimr  left)border_styletitletitle_alignN)r   r   r  fitr   rD  )
r  rS  r  r  r  r  r  r  r  r  s
         r`   r  &DOMNode.css_tree.<locals>.add_children  s    '25'9ll&& 		 !1!12)."'(.	 " D $=== / 'r_   )rS  r   r   r  )r  r   rS  r   r   r   )rich.columnsr  rich.consoler  
rich.panelr  r  r  textual.widgetrJ   r   r   )
rt   r  r  r  r  r  rJ   r  r  r  s
     @@@@@@@@r`   css_treeDOMNode.css_tree  sP     	)&$&)	 	  &'K%&	0 	0& 	T r_   c                b    [         R                  " S [        U R                  5       5       5      $ )zGet the text style object.

A widget's style is influenced by its parent. for instance if a parent is bold, then
the child will also be bold.

Returns:
    A Rich Style.
c              3  L   #    U  H  oR                   R                  v   M     g 7fr   )r   
text_style)r  rS  s     r`   r  %DOMNode.text_style.<locals>.<genexpr>0  s      
/QtKK""/Qs   "$)r   combinerA  ancestors_with_selfr   s    r`   r  DOMNode.text_style&  s-     }} 
/78P8P/Q
 
 	
r_   c                B    U R                   R                  S[        S9nU$ )zThe style of selected text.zscreen--selection)default)r  get_component_rich_styleRICH_NULL_STYLE)rt   r  s     r`   selection_styleDOMNode.selection_style4  s)     44 5 
 r_   c                L   [        SSSS5      n[        SSSS5      n[        5       nSn[        U R                  5       H  nUR                  nUR
                  nXFR                  -  nU" S5      (       a_  XR                  R                  UR                  5      -   nUUR                  R                  UR                  5      R                  U5      -  nOUnU" S5      (       a  UR                  nX6R                  -  nU" S5      (       d  M  UR                  (       d  M  UR                  UR                  5      nM     U[        R                   " UR                  (       d  UR                  (       a  X-   R"                  OSUR                  (       a  UR"                  OS5      -  nU$ )zFGet a Rich Style object for this DOMNode.

Returns:
    A Rich style.
r            ?
backgroundcolor
auto_colorN)r!   r   rA  r  r   has_ruleopacityr  tintbackground_tintmultiply_alphar  r  r  get_contrast_texta
from_color
rich_color)	rt   r  r  r  r  rS  r   r  text_backgrounds	            r`   
rich_styleDOMNode.rich_style<  s`    1aA&
c3Q'T556D[[FH~~%G%%",/@/@/E/E**0 # %%**6+A+AB .)*
 #-  &&&E%%&*;*;*;'99%''B# 7& 	!!0:Z++d%/\\J!!t
 	
 r_   c                    g)a  Check if the widget may consume the given key.

This should be implemented in widgets that handle [`Key`][textual.events.Key] events and
stop propagation (such as Input and TextArea).

Implementing this method will hide key bindings from the footer and key panel that would
be *consumed* by the focused widget.

Args:
    key: A key identifier.
    character: A character associated with the key, or `None` if there isn't one.

Returns:
    `True` if the widget may capture the key in its `Key` event handler, or `False` if it won't.
FrW   )rt   r
  	characters      r`   check_consume_keyDOMNode.check_consume_keyb  s      r_   c                    U R                   nUR                  (       a&  UR                  UR                  R                  5      nOUR                  nUUR
                  [        R                  " UR                  5      4$ )zoGet a Visual Style object for titles.

Args:
    background: The background color.

Returns:
    A Rich style.
)	r   auto_border_title_colorr  border_title_colorr  border_title_backgroundVisualStylefrom_rich_styleborder_title_stylert   r  r   r  s       r`   _get_title_style_information$DOMNode._get_title_style_informationt  sg     ))001J1J1L1LME--E**''(A(AB
 	
r_   c                    U R                   nUR                  (       a&  UR                  UR                  R                  5      nOUR                  nUUR
                  [        R                  " UR                  5      4$ )zpGet a Rich Style object for subtitles.

Args:
    background: The background color.

Returns:
    A Rich style.
)	r   auto_border_subtitle_colorr  border_subtitle_colorr  border_subtitle_backgroundr&  r'  border_subtitle_styler)  s       r`   _get_subtitle_style_information'DOMNode._get_subtitle_style_information  sg     ,,001M1M1O1OPE00E--''(D(DE
 	
r_   c                   [        SSSS5      =pSn[        U R                  5       HU  nUR                  nUnX5R                  -  nX%R
                  R                  UR                  5      R                  U5      -  nMW     X4$ )zVBackground colors adjusted for opacity.

Returns:
    `(<background color>, <color>)`
r   r  )	r!   rA  r  r   r  r  r  r  r  )rt   base_backgroundr  r  rS  r   s         r`   background_colorsDOMNode.background_colors  s     (-Q1a'88T556D[[F(O~~%G++001G1GHWW J	 7  ,,r_   c                p   [         =p[        =p4[        U R                  5       H  nUR                  nUnX&R
                  R                  UR                  5      -  nUR                  S5      (       d  MP  UnUR                  (       a  UR                  UR                  5      nM  UR                  nM     XX$4$ )zThe widget's background and foreground colors, and the parent's background and foreground colors.

Returns:
    `(<parent background>, <parent color>, <background>, <color>)`
r  )r    r   rA  r  r   r  r  r  r  r  r  r  r  )rt   r4  r  
base_colorr  rS  r   s          r`   colorsDOMNode.colors  s     (-,""
T556D[[F(O++001G1GHHJw''"
$$&88AE"LLE 7  Z??r_   c                    U /nUR                   nU nUR                  =nb  U" U5        UR                  =nb  M  [        SU5      $ )zA list of ancestor nodes found by tracing a path all the way back to App.

Note:
    This is inclusive of ``self``.

Returns:
    A list of nodes.
list[DOMNode]rg  r  r   rt   nodesadd_noderS  s       r`   r  DOMNode.ancestors_with_self  sM     ,0&<<#'||#t0TN ||#t0OU++r_   c                    / nUR                   nU nUR                  =nb  U" U5        UR                  =nb  M  [        SU5      $ )ziA list of ancestor nodes found by tracing a path all the way back to App.

Returns:
    A list of nodes.
r<  r=  r>  s       r`   	ancestorsDOMNode.ancestors  sK     +-<<#'||#t0TN ||#t0OU++r_   c                    [        XX#US9  g)a  Watches for modifications to reactive attributes on another object.

Example:
    ```python
    def on_theme_change(old_value:str, new_value:str) -> None:
        # Called when app.theme changes.
        print(f"App.theme went from {old_value} to {new_value}")

    self.watch(self.app, "theme", self.on_theme_change, init=False)
    ```

Args:
    obj: Object containing attribute to watch.
    attribute_name: Attribute to watch.
    callback: A callback to run when attribute changes.
    init: Check watchers on first call.
r   N)r7   )rt   ru   attribute_namecallbackr   s        r`   r   DOMNode.watch  s    0 	t.>r_   c                    U R                   R                  5        VVs1 s H  u  pU" U 5      (       d  M  UiM     snn$ s  snnf )zHPseudo classes for a widget.

Returns:
    Names of the pseudo classes.
)r   r   )rt   rf   check_classs      r`   r  DOMNode.get_pseudo_classes  sC     &*%9%9%?%?%A
%A!4  %A
 	
 
s   ??c                    SSK Jn  U R                  SS9 HF  nUR                  R	                  5         [        X!5      (       d  M/  UR                  5         SUl        MH     g)z)Reset styles back to their initial state.r   rI   T)	with_selfN)r  rJ   walk_childrenr   resetr{   
_set_dirty_layout_required)rt   rJ   rS  s      r`   reset_stylesDOMNode.reset_styles  sL    )&&&6D""$$''!(,%	 7r_   c                \    U R                   R                  U5        UR                  U 5        g)zQAdd a new child node.

!!! note
    For tests only.

Args:
    node: A DOM node.
N)r   r   _attach)rt   rS  s     r`   
_add_childDOMNode._add_child  s"     	D!Tr_   c                    U R                   R                  nU H5  nUR                  U 5        U" U5        UR                  " UR                  6   M7     g)z~Add multiple children to this node.

!!! note
    For tests only.

Args:
    *nodes: Positional args should be new DOM nodes.
N)r   r   rU  _add_children_pending_children)rt   r?  r   rS  s       r`   rY  DOMNode._add_children%  sD     ++%%DLLDM 6 67 r_   WalkType)boundrO   )rM  methodr  c                   g r   rW   )rt   filter_typerM  r^  r  s        r`   rN  DOMNode.walk_children8  s     !r_   c                   g r   rW   )rt   rM  r^  r  s       r`   rN  ra  B  s      r_   c                   U=(       d    [         nUS:X  a
  [        XUS9O	[        XUS9n[        U5      nU(       a  UR	                  5         [        SU5      $ )aN  Walk the subtree rooted at this node, and return every descendant encountered in a list.

Args:
    filter_type: Filter only this type, or None for no filter.
    with_self: Also yield self in addition to descendants.
    method: One of "depth" or "breadth".
    reverse: Reverse the order (bottom up).

Returns:
    A list of nodes.
rO   	with_rootr<  )r   r;   r9   listr  r   )rt   r`  rM  r^  r  
check_typenode_generatorr?  s           r`   rN  ra  K  sX    & !+G
   TC#D	J 	 ^$MMOOU++r_   c                    g r   rW   rt   selectors     r`   queryDOMNode.queryo      JMr_   c                    g r   rW   rj  s     r`   rl  rm  r  s    KNr_   c                    SSK JnJn  SSKJn  U R                  5       n[        U[        5      (       d  Uc  X$   " XQS9$ X#   " XQR                  S9$ )zQuery the DOM for children that match a selector or widget type.

Args:
    selector: A CSS selector, widget type, or `None` for all nodes.

Returns:
    A query object.
r   rB   rI   )filter	textual.css.queryrC   rD   r  rJ   r   r{   r|   rY   rt   rk  rC   rD   rJ   rS  s         r`   rl  rm  u  sL     	:)!!#h$$(8#D::&t4E4EFFr_   c                    g r   rW   rj  s     r`   query_childrenDOMNode.query_children  s    SVr_   c                    g r   rW   rj  s     r`   rv  rw    s    TWr_   c                    SSK JnJn  SSKJn  U R                  5       n[        U[        5      (       d  Uc
  X$   " USUS9$ X#   " USUR                  S9$ )az  Query the DOM for the immediate children that match a selector or widget type.

Note that this will not return child widgets more than a single level deep.
If you want to a query to potentially match all children in the widget tree,
see [query][textual.dom.DOMNode.query].

Args:
    selector: A CSS selector, widget type, or `None` for all nodes.

Returns:
    A query object.
r   rB   rI   F)deeprq  rr  rt  s         r`   rv  rw    sT     	:)!!#h$$(8#DuXFF&t%@Q@QRRr_   c                    g r   rW   rj  s     r`   	query_oneDOMNode.query_one  s    69r_   c                    g r   rW   rj  s     r`   r|  r}    s    EHr_   c                    g r   rW   rt   rk  expect_types      r`   r|  r}         r_   c           	        SnU R                  5       n[        U[        5      (       a  UnOUR                  n[	        U5      (       a  UR
                  R                  XR4nUR                  R                  U5      nUb  U$ [        XESS SS9=n bC  Ub0  [        X5      (       d   [        SU< SUR                  < SU 35      eXR                  U'   U$ [        S	U< S
U< 35      e [        U5      n	[        S U	 5       5      (       a9  UR
                  R                  XR4nUR                  R                  U5      nUb  U$ OSn[!        USS9 H[  n[#        X5      (       d  M  Ub0  [        X5      (       d   [        SU< SUR                  < SU 35      eUb  XR                  U'   Us  $    [        S	U< S
U< 35      e! [         a    [        SU< S35      Sef = f)ad  Get a widget from this widget's children that matches a selector or widget type.

Args:
    selector: A selector or widget type.
    expect_type: Require the object be of the supplied type, or None for any type.

Raises:
    WrongType: If the wrong type was found.
    NoMatches: If no node matches the query.

Returns:
    A widget matching the selector.
TNrQ  Frd  Node matching " is the wrong type; expected type , found No nodes match r   Unable to parse $ as a query; check for syntax errorsc              3  8   #    U  H  oR                   v   M     g 7fr   	is_simpler  r  s     r`   r  $DOMNode.query_one.<locals>.<genexpr>       ALy""Lr  )r   r{   r|   rY   r(   r   rW  r   r   r:   r.   r,   r*   r2   r+   allr9   r'   )
rt   rk  r  r   	base_nodequery_selector	cache_keycached_resultrS  selector_sets
             r`   r|  r}    sC   $  $&&(	h$$%N%..N.))"))22NPI%66::9EM($$.ab1U  	
 *:d3P3P#((::\]h]q]q\tt|  ~B  }C  D  9=**95on-?tI=QRR	*>:L ALAAA"))22NPI%66::9EM($$ ) I&yEBD,,&z$/L/L$^$66XYdYmYmXppxy}x~  $8<**95K C /.);4	}MNN1  	$">"44XY	s   'G   Gc                    g r   rW   rj  s     r`   query_one_optionalDOMNode.query_one_optional  s    FIr_   c                    g r   rW   rj  s     r`   r  r    s    UXr_   c                    g r   rW   r  s      r`   r  r    s      #r_   c                J     U R                  X5      nU$ ! [         a     gf = f)ab  Get a widget from this widget's children that matches a selector or widget type,
or `None` if there is no match.

Args:
    selector: A selector or widget type.
    expect_type: Require the object be of the supplied type, or None for any type.

Raises:
    WrongType: If the wrong type was found.

Returns:
    A widget matching the selector, or `None`.
N)r|  r,   )rt   rk  r  r   s       r`   r  r    s0    $	^^H:F   		s    
""c                    g r   rW   rj  s     r`   query_exactly_oneDOMNode.query_exactly_one&  s    >Ar_   c                    g r   rW   rj  s     r`   r  r  )  s    MPr_   c                    g r   rW   r  s      r`   r  r  ,  r  r_   c           	        SnU R                  5       n[        U[        5      (       a  UnOUR                  n [	        U5      n[        S U 5       5      (       a9  UR                  R                  XR4nUR                  R                  U5      nUb  U$ OSn[        USS9n	[        U	5      n
U
 H  n[        Xk5      (       d  M  Ub0  [        X5      (       d   [        SU< S	UR                  < S
U 35      eU
 H  n[        Xl5      (       d  M  [!        S5      e   Ub  XR                  U'   Us  $    [#        SU< SU< 35      e! [
         a    [        SU< S35      Sef = f)a  Get a widget from this widget's children that matches a selector or widget type.

!!! Note
    This method is similar to [query_one][textual.dom.DOMNode.query_one].
    The only difference is that it will raise `TooManyMatches` if there is more than a single match.

Args:
    selector: A selector or widget type.
    expect_type: Require the object be of the supplied type, or None for any type.

Raises:
    WrongType: If the wrong type was found.
    NoMatches: If no node matches the query.
    TooManyMatches: If there is more than one matching node in the query (and `exactly_one==True`).

Returns:
    A widget matching the selector.
Tr  r  Nc              3  8   #    U  H  oR                   v   M     g 7fr   r  r  s     r`   r  ,DOMNode.query_exactly_one.<locals>.<genexpr>X  r  r  Frd  r  r  r  z8Call to query_one resulted in more than one matched noder  r   )r   r{   r|   rY   r*   r2   r+   r  r   rW  r   r   r9   iterr'   r.   r-   r,   )rt   rk  r  r   r  r  r  r  r  r   iter_childrenrS  
later_nodes                r`   r  r  1  s   .  $&&(	h$$%N%..N	*>:L ALAAA"))22NPI%66::9EM($$ ) I%i5AX!D,,&z$/L/L$^$66XYdYmYmXppxy}x~  ,
22(R  ,
 $8<**95K "  /.);4	}MNN?  	$">"44XY	s   E Ec                    g r   rW   rj  s     r`   query_ancestorDOMNode.query_ancestorv  s    <?r_   c                    g r   rW   rj  s     r`   r  r  y  rn  r_   c                    g r   rW   r  s      r`   r  r  |  r  r_   c                   U R                  5       n[        U[        5      (       a  UnOUR                  n [	        U5      nUR                  bF  UR                  R                   H,  n[        XV5      (       d  M  Ub  [        Xb5      (       d  M*  Us  $    [        SU< SU < 35      e! [
         a    [        SU< S35      Sef = f)a:  Get an ancestor which matches a query.

Args:
    selector: A TCSS selector.
    expect_type: Expected type, or `None` for any DOMNode.

Raises:
    InvalidQueryFormat: If the selector is invalid.
    NoMatches: If there are no matching ancestors.

Returns:
    A DOMNode or subclass if `expect_type` is provided.
r  r  NzNo ancestor matches r   )r   r{   r|   rY   r*   r2   r+   r   r  r'   r,   )rt   rk  r  r  r  r  rS  s          r`   r  r    s    $ &&(	h$$%N%..N	*>:L
 '!((<<\00*:d3P3P = .xl$thGHH  	$">"44XY	s   B' 'Cc                T   Ub5   [        USS9nU R
                  R                  U5        U R                  SS9  U R                  nUR                  5        H  u  pg[        XVU5        M     U $ ! [         a1  n[        UR                  UR                  UR                  5      SeSnAff = f)zSet custom styles on this object.

Args:
    css: Styles in CSS format.
    update_styles: Keyword arguments map style names onto style values.

Returns:
    Self.
N)
set_stylesr   )	read_fromTr  )r)   r%   rf   tokenmessager   rU  r  r   r   r   )rt   r  update_styles
new_styleserrorr   r
  r   s           r`   r  DOMNode.set_styles  s     ?Y/?QR
 %%j1LLL%'--/JCF' 0 $ Y&uzz5;;NTXXYs   
A, ,
B'6,B""B'c                8    U R                   R                  U5      $ )zCheck if the Node has all the given class names.

Args:
    *class_names: CSS class names to check.

Returns:
    ``True`` if the node has all the given class names, otherwise ``False``.
)rs   
issuperset)rt   r   s     r`   	has_classDOMNode.has_class  s     }}''44r_   )r   c               `    U(       a  U R                   " USU06  U $ U R                  " USU06  U $ )a  Add or remove class(es) based on a condition.

This can condense the four lines required to implement the equivalent branch into a single line.

Example:
    ```python
    #if foo:
    #    self.add_class("-foo")
    #else:
    #    self.remove_class("-foo")
    self.set_class(foo, "-foo")
    ```

Args:
    add: Add the classes if True, otherwise remove them.
    update: Also update styles.

Returns:
    Self.
r   )	add_classremove_class)rt   rD  r   r   s       r`   	set_classDOMNode.set_class  s9    * NNK77  {:6:r_   c                    [        5       n[        5       nUR                  UR                  4nUR                  5        H  u  pxXh   " U5        M     U R                  U-  U-
  n	U R                  U	:w  a  Xl        U(       a  U R	                  US9  U $ )a   Update classes in an atomic batch.

Args:
    classes: A mapping of class name on to a boolean where `True` adds
        to the current classes, and `False` removes.
    update: Also update styles.
    animate: Enable any CSS animation?

Returns:
    Self
animate)r}   rD  r   rs   r   )
rt   r   r   r  add_classesremove_classesaddsr  rD  new_classess
             r`   update_classesDOMNode.update_classes  s     !$#&5""KOO4&}}OJIj!  / }}{2nD==K''M'''8r_   c                    Xl         U $ )zReplace all classes.

Args:
    classes: A string containing space separated classes, or an
        iterable of class names.

Returns:
    Self.
)r   )rt   r   s     r`   set_classesDOMNode.set_classes  s     r_   c                X     U R                   R                  XS9  g! [         a     gf = f)zjRequest an update of this node's styles.

Called by Textual whenever CSS classes / pseudo classes change.
r  N)r  r  r   )rt   r  s     r`   r   DOMNode.update_node_styles  s.    
	HH""4"9 		s    
))c                   [        S/UQ76   U R                  R                  U5      (       a  U $ U R                  R                  U5        U(       a  U R	                  5         U $ )zAdd class names to this Node.

Args:
    *class_names: CSS class names to add.
    update: Also update styles.

Returns:
    Self.
rz   )rg   rs   r  r   r   rt   r   r   s      r`   r  DOMNode.add_class  sQ     	,55==##K00K[)##%r_   c                   [        S/UQ76   U R                  R                  U5      (       a  U $ U R                  R                  U5        U(       a  U R	                  5         U $ )zRemove class names from this Node.

Args:
    *class_names: CSS class names to remove.
    update: Also update styles.

Returns:
    Self.
rz   )rg   rs   
isdisjointdifference_updater   r  s      r`   r  DOMNode.remove_class+  sQ     	,55==##K00K''4##%r_   c                    [        S/UQ76   U R                  R                  5       nU R                  R                  U5        X R                  :X  a  U $ U R	                  5         U $ )ziToggle class names on this Node.

Args:
    *class_names: CSS class names to toggle.

Returns:
    Self.
rz   )rg   rs   r   symmetric_difference_updater   )rt   r   old_classess      r`   toggle_classDOMNode.toggle_class=  sU     	,55mm((*11+>--'K!r_   c                N     U R                   U   " U 5      $ ! [         a     gf = f)zCheck the node has the given pseudo class.

Args:
    class_name: The pseudo class to check for.

Returns:
    `True` if the DOM node has the pseudo class, `False` if not.
F)r   rR  )rt   r  s     r`   has_pseudo_classDOMNode.has_pseudo_classN  s/    	''
3D99 		s    
$$c                l   ^ ^ T R                   m [        UU 4S jU 5       5      $ ! [         a     gf = f)zCheck the node has all the given pseudo classes.

Args:
    class_names: Set of class names to check for.

Returns:
    `True` if all pseudo class names are present.
c              3  :   >#    U  H  nTU   " T5      v   M     g 7fr   rW   )r  rf   PSEUDO_CLASSESrt   s     r`   r  -DOMNode.has_pseudo_classes.<locals>.<genexpr>g  s     Jkd~d+D11ks   F)r   r  rR  )rt   r   r  s   ` @r`   has_pseudo_classesDOMNode.has_pseudo_classes\  s8     --	JkJJJ 		s   & 
33c                    g)zEA cache key used when updating a number of nodes from the stylesheet.rW   rW   r   s    r`   _pseudo_classes_cache_key!DOMNode._pseudo_classes_cache_keyk  s     r_   )repaintr  	recomposec                   U $ r   rW   )rt   r  r  r  s       r`   r  DOMNode.refreshp  s	     r_   c                    g)a  Check whether an action is enabled.

Implement this method to add logic for [dynamic actions](/guide/actions#dynamic-actions) / bindings.

Args:
    action: The name of an action.
    parameters: A tuple of any action parameters.

Returns:
    `True` if the action is enabled+visible,
        `False` if the action is disabled+hidden,
        `None` if the action is disabled+visible (grayed out in footer)
TrW   )rt   action
parameterss      r`   check_actionDOMNode.check_actionu  s     r_   c                \    U R                   (       a  U R                  R                  5         gg)zCall to prompt widgets such as the [Footer][textual.widgets.Footer] to update
the display of key bindings.

See [actions](/guide/actions#dynamic-actions) for how to use this method.

N)r   r  refresh_bindingsr   s    r`   r  DOMNode.refresh_bindings  s"     KK((* r_   c                D   #    [        X5      n[        XU(       + 5        g7f)zuToggle an attribute on the node.

Assumes the attribute is a bool.

Args:
    attribute_name: Name of the attribute.
N)r   r   )rt   rF  r   s      r`   action_toggleDOMNode.action_toggle  s      -%i0s    )r   r   r   rs   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )rf   r   r   r   r   r   r   r   )r   r   )r   Reactive[ReactiveType]r   rR   r   r   )r   r  r   r   )r   zReactive[Any]r   zReactive[Any] | objectr   r=   )r   r   )r   rJ   r   r   )r   zSequence['Widget'])r   zSequence[Widget])r   r  )r
  z1Callable[[Widget], SupportsRichComparison] | Noner  r  r   r   )r   float | None)r  r  r   r   )r   r<   )T)r   r  r   r   )r   r  r   TTFF)r-  zWorkType[ResultType]rf   r   r#  r|   rd   r|   r$  r  r%  r  r&  r  r'  r  r   zWorker[ResultType])TTT)rI  r  rJ  r  rK  r  r   r   )re   r|   r   r/   )r   Sequence[Type[DOMNode]])rL  r  r   r  )r   r   )r  rA   r   r   )r   zrich.repr.Result)r   z'list[tuple[CSSLocation, str, int, str]])r   r   )r   r  )r   z'Screen[object]')r   r   )r  r|   r   r|   )r   r|   )r   r   )r   r<  )r   set[str])r  
bool | strr   r   )r  r  r   r   )r   r   )r   r   )r
  r|   r  r   r   r  )r  r!   r   z tuple[Color, Color, VisualStyle])r   ztuple[Color, Color])r   z!tuple[Color, Color, Color, Color])
ru   r   rF  r|   rG  r   r   r  r   r   )rS  rJ   r   r   )r?  rJ   r   r   )
r`  ztype[WalkType]rM  r  r^  rQ   r  r  r   zlist[WalkType])rM  r  r^  rQ   r  r  r   r<  r   )
r`  ztype[WalkType] | NonerM  r  r^  rQ   r  r  r   zlist[DOMNode] | list[WalkType])rk  r   r   zDOMQuery[Widget])rk  type[QueryType]r   zDOMQuery[QueryType])rk  zstr | type[QueryType] | Noner   z&DOMQuery[Widget] | DOMQuery[QueryType])rk  r|   r   rJ   )rk  r  r   rD   )rk  r|   r  r  r   rD   )rk  str | type[QueryType]r  type[QueryType] | Noner   zQueryType | Widget)rk  r|   r   zWidget | None)rk  r  r   QueryType | None)rk  r|   r  r  r   r  )rk  r  r  r  r   zQueryType | Widget | None)rk  r|   r   r   )rk  r  r  r  r   r   )r  r   r  r   r   r=   )r   r|   r   r  )rD  r  r   r|   r   r  r   r=   )TT)r   zMapping[str, bool]r   r  r  r  r   r=   )r   r   r   r=   )r  r  r   r   )r   r|   r   r  r   r=   )r   r|   r   r=   )r  r|   r   r  )r   r  r   r  )r   ztuple[int, ...])r  r  r  r  r  r  r   r=   )r  r|   r  ztuple[object, ...]r   zbool | None)rF  r|   r   r   )srY   rZ   r[   r\   r]   r   __annotations__r   r}   r   r   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   propertyr   r   r   r  r  r  r   r  r   r0  r3  r7  r  r@  rY  r\  r_  rc  classmethodr   r   rE  rx  r~  r  r  r   r  r   rf   r  r  ro   r   r  r  r  r   r  r  r  r  r
  r  r   r*  r1  r5  r9  r  rC  r   r  rR  rV  rY  r   r\  r   r   rN  rl  rv  r|  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r^   __classcell__)r   s   @r`   r   r      s	
   S!#K#%'O]'3,/E)1G&**W,.H).! "&J%;!%D
%C $(L.' 265 )-~, 1:O-; NC 6:29--OO ('GIODI
  "0 0 	0
 0 
0 0d	2.27C2	2406/!/ ,/ 
	/b(&T
$   % % 1 1 ? ? BF	" ?" 	"
 
"0 " " & &    &" ".". . 	.
 . . . . . 
.`    	 !!%*.	"
"
 "
 $(	"

 
"
 "
H6*
 / /
 t  .  45(T t,  ,$ 4 4  2   YY $        !"G(4 4     
 
 ^^ ( < <" ^^	 	  > ; ;z 
 
   # #J$

	)
.

	)
, - -" @ @* , ,  , ,$ ?? ? $	?
 ? 
?4
-
8 z3H	
 $!(!	!'	! 		!
 	! 	! 	! 
	! 
 $!(!	  	  		 
 	  	  
	  .2 ,  $ ,* , 	 ,
  ,  , 
( ,D 	M 
M	N 
N 8<G4G	/G( 	V 
V	W 
W 8<S4S	/S0 	9 
9	H 
H			.=		 
	 /3GO'GO ,GO 
	GOR 	I 
I	X 
X		#	#.=	#	# 
	# /3' , 
#	0 	A 
A	P 
P			.=		 
	 /3AO'AO ,AO 
	AOF 	? 
?	M 
M			.=		 
	 /3%I'%I ,%I 
	%IN0	5 FJ 8 QU)37IM	8 ;? $ >B $"  
 "&eu/3HL	
 +	1 	1r_   r   )rd   r|   re   r|   r   r   )r]   
__future__r   rer)  	functoolsr   r   inspectr   typingr   r   r	   r
   r   r   r   r   r   r   r   	rich.reprrichrich.highlighterr   
rich.styler   r	  r   	rich.textr   	rich.treer   textual._contextr   r   textual._node_listr   textual._typesr   textual.bindingr   r   r   textual.cacher   textual.colorr   r    r!   textual.css._error_toolsr"   textual.css.constantsr#   r$   textual.css.errorsr%   r&   textual.css.matchr'   textual.css.parser(   r)   r*   rs  r+   r,   r-   r.   textual.css.stylesr/   r0   textual.css.tokenizer1   textual.css.tokenizerr2   textual.message_pumpr3   textual.reactiver4   r5   r6   r7   textual.styler&  textual.timerr8   textual.walkr9   r:   r;   textual.worker_managerr<   typing_extensionsr=   r>   	_typeshedr?   r  r@   textual.apprA   rC   rD   textual.css.typesrE   textual.messagerF   r  rH   r  rJ   textual.workerrK   rL   rM   rN   compilerb   rQ   r  rR   rS   	ExceptionrU   rg   ri   rl   ro   reprautor   rW   r_   r`   <module>r*     sV   # 	  (      , 4    B ' , = = " - - 2 A @ # Q Q V V 3 + , , F F .  U U 010+5-'%%;; %J'   23
I 3 h ~& E ) D .]I ] ?y ?9x 9% %* Q1k Q1 Q1r_   