
    Cj                    L    S r SSKJr  SSKJr   " S S\5      r " S S\5      rg)	z!
Tools for lazy loading widgets.
    )annotations)Widgetc                  H   ^  \ rS rSrSrSrSU 4S jjrSS jrS	S jrSr	U =r
$ )
Lazy
   ay  Wraps a widget so that it is mounted *lazily*.

Lazy widgets are mounted after the first refresh. This can be used to display some parts of
the UI very quickly, followed by the lazy widgets. Technically, this won't make anything
faster, but it reduces the time the user sees a blank screen and will make apps feel
more responsive.

Making a widget lazy is beneficial for widgets which start out invisible, such as tab panes.

Note that since lazy widgets aren't mounted immediately (by definition), they will not appear
in queries for a brief interval until they are mounted. Your code should take this into account.

Example:
    ```python
    def compose(self) -> ComposeResult:
        yield Footer()
        with ColorTabs("Theme Colors", "Named Colors"):
            yield Content(ThemeColorButtons(), ThemeColorsView(), id="theme")
            yield Lazy(NamedColorsView())
    ```

z6
    Lazy {
        display: none;        
    } 
    c                .   > Xl         [        TU ]	  5         g)zZCreate a lazy widget.

Args:
    widget: A widget that should be mounted after a refresh.
N)_replace_widgetsuper__init__selfwidget	__class__s     ^/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/textual/lazy.pyr   Lazy.__init__(   s      &    c                :    U R                   R                  U5        g N)r	   compose_add_childr   r   s     r   r   Lazy.compose_add_child1   s    ..v6r   c                   ^ ^#    T R                   mTc  g [        T[        5      (       d   eSUU 4S jjnT R                  U5        g 7f)Nc                    >#    T R                  TR                  TS9I Sh  vN   TR                  5       I Sh  vN   g N N7f)z.Perform the mount and discard the lazy widget.afterN)mountr	   remove)parentr   s   r   r   *Lazy.mount_composed_widgets.<locals>.mount:   s:     ,,t334,@@@++- As   A?AAAAreturnNone)r   
isinstancer   call_after_refresh)r   widgetsr   r   s   `  @r   mount_composed_widgetsLazy.mount_composed_widgets4   sD     >&&))))	  	 
 	&s   AA)r	   r   r   r!   r"   r%   list[Widget]r!   r"   )__name__
__module____qualname____firstlineno____doc__DEFAULT_CSSr   r   r&   __static_attributes____classcell__r   s   @r   r   r   
   s#    .K7' 'r   r   c                  \   ^  \ rS rSrSrSrS	U 4S jjr\S
S j5       rS	S jr	SS jr
SrU =r$ )RevealB   a  Similar to [Lazy][textual.lazy.Lazy], but mounts children sequentially.

This is useful when you have so many child widgets that there is a noticeable delay before
you see anything. By mounting the children over several frames, the user will feel that
something is happening.

Example:
    ```python
    def compose(self) -> ComposeResult:
        with lazy.Reveal(containers.VerticalScroll(can_focus=False)):
            yield Markdown(WIDGETS_MD, classes="column")
            yield Buttons()
            yield Checkboxes()
            yield Datatables()
            yield Inputs()
            yield ListViews()
            yield Logs()
            yield Sparklines()
        yield Footer()
    ```
z/
    Reveal {
        display: none;
    }
    c                <   > Xl         / U l        [        TU ]  5         g)z&
Args:
    widget: A widget to mount.
N)r	   _widgetsr
   r   r   s     r   r   Reveal.__init___   s    
  &&(r   c                @   ^^^ SUUU4S jjmTR                  T5        g)zZReveal children lazily.

Args:
    parent: The parent widget.
    widgets: Child widgets.
c                    >#    T(       d  gTR                  S5      n  TR                  U 5      I Sh  vN   T(       a  TR                  ST5        gg N! [         a     gf = f7f)zCheck for pending childrenNr   g{Gz?)popr   	Exception	set_timer)r   check_childrenr   r%   s    r   r?   &Reveal._reveal.<locals>.check_childrenq   sb     [[^Fll6***   ~6  +  s7   A$A AA A$A 
A!A$ A!!A$Nr    )	call_next)clsr   r%   r?   s    ``@r   _revealReveal._revealh   s    	7 	7 	(r   c                :    U R                   R                  U5        g r   )r8   appendr   s     r   r   Reveal.compose_add_child   s    V$r   c                r  #    U R                   nUc  g [        U[        5      (       d   eUR                  U R                  U S9I S h  vN   U R                  5       I S h  vN   U R                  U R                  U R                  R                  5       5        U R                  R                  5         g  Nk NU7f)Nr   )
r   r#   r   r   r	   r   rC   r8   copyclear)r   r%   r   s      r   r&   Reveal.mount_composed_widgets   s     >&&))))ll4//tl<<<kkmT))4==+=+=+?@ 	=s%   AB7B3B7B5 AB75B7)r	   r8   r(   )r   r   r%   r*   r!   r"   r)   )r+   r,   r-   r.   r/   r0   r   classmethodrC   r   r&   r1   r2   r3   s   @r   r5   r5   B   s7    ,K ) )2% r   r5   N)r/   
__future__r   textual.widgetr   r   r5    r   r   <module>rP      s-    # !5'6 5'pKV Kr   