ó
    Ãu„j.6  ã                  óB  • % 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rS SKJrJr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  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*  S SK+Jr  \
(       a  S SK,J-r-  S SK.J/r/  S(S jr0\" SS9 " S S5      5       r1 " S S\5      r2 " S S\35      r4Sr5S\6S '   S)S*S" jjr7 " S# S!\5      r8\Rr                  Rt                   " S$ S%\85      5       r;\Rr                  Rt                   " S& S'\85      5       r<g)+é    )Úannotations)ÚABCÚabstractmethod)Ú	dataclass)Úislice)ÚTYPE_CHECKINGÚCallableÚProtocolN)ÚConsoleÚConsoleOptionsÚRenderableType)ÚMeasurement)Úis_renderableÚ	rich_cast)ÚSegment)ÚStyle)ÚText)Ú
active_app)ÚRulesMap)ÚSpacing)Úmeasure)Ú	Selection)ÚStrip)Ú	TypeAlias)ÚWidgetc                óH   • [        U [        5      =(       d    [        U S5      $ )zFCheck if the given object is a Visual or supports the Visual protocol.Ú
textualize)Ú
isinstanceÚVisualÚhasattr)Úobjs    ÚœC:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\textual/visual.pyÚ	is_visualr#      s   € ä�cœ6Ó"×@¤g¨c°<Ó&@Ð@ó    T)Úfrozenc                  ó`   • \ rS rSr% SrS\S'    S\S'    SrS\S	'    SrS
\S'    SrS
\S'   Sr	g)ÚRenderOptionsé#   z4Additional options passed to `Visual.render_strips`.zCallable[[str | Style], Style]Ú	get_styler   ÚrulesNzSelection | NoneÚ	selectionúStyle | NoneÚselection_styleÚ
post_style© )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r+   r-   r.   Ú__static_attributes__r/   r$   r"   r'   r'   #   s>   ‡ á>à-Ó-Ø"ØƒOØ!Ø"&€IÐÓ&Ø%Ø$(€O�\Ó(Ø"Ø#€J�Ó#Ú.r$   r'   c                  ó"   • \ rS rSrSrSS jrSrg)ÚSupportsVisualé4   z0An object that supports the textualize protocol.c                ó   • g)zöConvert the result of a Widget.render() call into a Visual, using the Visual protocol.

Args:
    widget: The widget that generated the render.
    obj: The result of the render.

Returns:
    A Visual instance, or `None` if it wasn't possible.

Nr/   )ÚselfÚwidgetr!   s      r"   Ú	visualizeÚSupportsVisual.visualize7   ó   � r$   r/   N)r<   r   r!   ÚobjectÚreturnzVisual | None)r0   r1   r2   r3   r4   r=   r6   r/   r$   r"   r8   r8   4   s
   † Ù:÷
r$   r8   c                  ó   • \ rS rSrSrSrg)ÚVisualErroréD   z"An error with the visual protocol.r/   N)r0   r1   r2   r3   r4   r6   r/   r$   r"   rC   rC   D   s   † Ü,r$   rC   z(RenderableType | SupportsVisual | Visualr   Ú
VisualTyper   c                ó>  • Sn[        U[        5      (       a  U$ [        USS5      nUc¼  SSKJn  [        U[
        5      (       a   U(       a  UR                  U5      $ U" U5      $ [        U5      (       aM  [        U[        5      (       a#  UR                  XR                  R                  S9$ [        U [        U5      5      $ [        SUR                  R                   < S35      eU" 5       n[        U[        5      (       d  [        U5      (       a  [        X5      $ U$ )	a¿  Get a visual instance from an object.

If the object does not support the Visual protocol and is a Rich renderable, it
will be wrapped in a [RichVisual][textual.visual.RichVisual].

Args:
    widget: The parent widget.
    obj: An object.
    markup: Enable markup.

Raises:
    VisualError: If there is no Visual could be returned to render `obj`.

Returns:
    A Visual instance to render the object, or `None` if there is no associated visual.
Tr=   Nr   )ÚContent)Úconsolezunable to display z? type; must be a str, Rich renderable, or Textual Visual object)r   r   ÚgetattrÚtextual.contentrG   ÚstrÚfrom_markupr   r   Úfrom_rich_textÚapprH   Ú
RichVisualr   rC   Ú	__class__r0   )r<   r!   ÚmarkupÚ_rich_traceback_omitr=   rG   Úvisuals          r"   r=   r=   K   sü   € ð"  ÐÜ�#”v×Ñàˆ
ä˜˜[¨$Ó/€IØÑå+ä�cœ3×ÑÞ/5�7×&Ñ& sÓ+ÐG¹7À3»<ÐGä˜×ÑÜ˜#œt×$Ñ$Ø×-Ñ-¨c¿:¹:×;MÑ;MÐ-ÐNÐNô ˜f¤i°£nÓ5Ð5ô Ø$ S§]¡]×%;Ñ%;Ñ$>Ð>}Ð~óð ñ ‹[€FÜ�fœf×%Ñ%¬-¸×*?Ñ*?Ü˜&Ó)Ð)Ø€Mr$   c                  ó´   • \ rS rSrSr\          SS j5       r\SS j5       rSS jr\SS j5       r	\
SSS	S
.                 SS jj5       rSrg	)r   é{   z`A Textual 'Visual' object.

Analogous to a Rich renderable, but with support for transparency.

c                ó   • g)a  Render the Visual into an iterable of strips.

Args:
    width: Width of desired render.
    height: Height of desired render or `None` for any height.
    style: The base style to render on top of.
    options: Additional render options.

Returns:
    An list of Strips.
Nr/   )r;   ÚwidthÚheightÚstyleÚoptionss        r"   Úrender_stripsÚVisual.render_strips‚   r?   r$   c                ó   • g)a×  Get optimal width of the Visual to display its content.

The exact definition of "optimal width" is dependant on the Visual, but
will typically be wide enough to display output without cropping or wrapping,
and without superfluous space.

Args:
    rules: A mapping of style rules, such as the Widgets `styles` object.
    container_width: The width of the container, used by Rich Renderables.
        May be ignored for Textual Visuals.

Returns:
    A width in cells.

Nr/   ©r;   r*   Úcontainer_widths      r"   Úget_optimal_widthÚVisual.get_optimal_width’   r?   r$   c                ó   • g)a+  Get a minimal width (the smallest width before data loss occurs).

Args:
    rules: A mapping of style rules, such as the Widgets `styles` object.
    container_width: The width of the container, used by Rich Renderables.
        May be ignored for Textual Visuals.

Returns:
    A width in cells.

é   r/   )r;   r*   s     r"   Úget_minimal_widthÚVisual.get_minimal_width¤   s   € ð r$   c                ó   • g)zÔGet the height of the Visual if rendered at the given width.

Args:
    rules: A mapping of style rules, such as the Widgets `styles` object.
    width: Width of visual in cells.

Returns:
    A height in lines.
Nr/   ©r;   r*   rW   s      r"   Ú
get_heightÚVisual.get_height²   r?   r$   TFN)Úapply_selectionÚpadr.   c               ó  • UR                   n	U	b0  [        R                  " UR                  R	                  S5      5      n
OSn
UR                  UUU[        UR                  UR                  U(       a  U	OSU
5      5      nUR                  (       aX  UR                  (       dG  UR                  R                  (       d,  UR                  nU Vs/ s H  oÝR                  U5      PM     nnUc  [        U5      nU[        SS9-   R                  nU(       a   U Vs/ s H  oÝR!                  X>5      PM     nnUR                  R"                  nUS:w  a)  Uu  nn[%        [&        R(                  " UUUUUU5      5      nU$ s  snf s  snf )aá  High level function to render a visual to strips.

Args:
    widget: Widget that produced the visual.
    visual: A Visual instance.
    width: Desired width (in cells).
    height: Desired height (in lines) or `None` for no limit.
    style: A (Visual) Style instance.
    apply_selection: Automatically apply selection styles?
    pad: Pad to desired width?
    post_style: Optional Style to apply to strips after rendering.

Returns:
    A list of Strips containing the render.
Nzscreen--selectionF)Úreverse)ÚleftÚtop)Útext_selectionr   Úfrom_stylesÚscreenÚget_component_stylesr[   r'   Ú
_get_styleÚstylesÚ
auto_linksÚis_containerÚ
_selectingÚ
link_styleÚ_apply_link_styleÚlenÚ
rich_styleÚextend_cell_lengthÚcontent_alignÚlistr   Úalign)Úclsr<   rS   rW   rX   rY   rj   rk   r.   r+   r-   Ústripsry   Ústripr|   r~   Úalign_horizontalÚalign_verticals                     r"   Ú	to_stripsÚVisual.to_strips¾   sc  € ð: ×)Ñ)ˆ	ØÑ Ü#×/Ò/Ø—‘×2Ñ2Ð3FÓGó‰Oð #ˆOà×%Ñ%ØØØÜØ×!Ñ!Ø—‘Þ,‘	°$Øó	ó	

ˆð ××Ø×'×'Ø—M‘M×,×,à×*Ñ*ˆJÙGMÓNÂv¸e×-Ñ-¨jÖ9ÁvˆFÐNà‰>Ü˜“[ˆFØœe¨EÑ2Ñ2×>Ñ>ˆ
ÞÙOUÓVÊvÀe×.Ñ.¨uÖAÉvˆFÐVØŸ™×3Ñ3ˆØ˜OÓ+Ø/<Ñ,Ð˜nÜÜ—’ØØØØØ$Ø"óó	ˆFð ˆùò) Oùò Ws   ÃE:ÄE?r/   ©
rW   ÚintrX   ú
int | NonerY   r   rZ   r'   rA   úlist[Strip]©r*   r   r_   r‰   rA   r‰   )r*   r   rA   r‰   ©r*   r   rW   r‰   rA   r‰   )r<   r   rS   r   rW   r‰   rX   rŠ   rY   r   rj   Úboolrk   rŽ   r.   r,   rA   r‹   )r0   r1   r2   r3   r4   r   r[   r`   rd   rh   Úclassmethodr†   r6   r/   r$   r"   r   r   {   sò   † ñð ðØðØ",ðØ5:ðØERðà	óó ðð óó ðô"ð ó	ó ð	ð ð !%ØØ#'ñIàðIð ðIð ð	Ið
 ðIð ðIð ðIð ðIð !ðIð 
ôIó óIr$   c                  óh   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	          SS jr
S	rg
)rO   i  z#A Visual to wrap a Rich renderable.c                ó*   • Xl         X l        SU l        g)zN

Args:
    widget: The associated Widget.
    renderable: A Rich renderable.
N)Ú_widgetÚ_renderableÚ_measurement)r;   r<   Ú
renderables      r"   Ú__init__ÚRichVisual.__init__  s   € ð ŒØ%ÔØ04ˆÕr$   c              #  óD   #   • U R                   v •  U R                  v •  g 7f©N)r’   r“   ©r;   s    r"   Ú__rich_repr__ÚRichVisual.__rich_repr__  s   é € Ø�l‰lÒØ×ÑÓùó   ‚ c           	     óÜ   • U R                   cT  [        R                  " UUU R                  R	                  U R
                  [        R                  " 5       5      5      U l         U R                   $ r™   )r”   r   Úgetr’   Úpost_renderr“   Ú	RichStyleÚnull)r;   rH   rZ   s      r"   Ú_measureÚRichVisual._measure  sT   € Ø×ÑÑ$Ü +§¢ØØØ—‘×(Ñ(¨×)9Ñ)9¼9¿>º>Ó;KÓLó!ˆDÔð
 × Ñ Ð r$   c                ól   • [         R                  " 5       R                  n[        X0R                  X"S9nU$ )N)r_   )r   rŸ   rH   r   r“   )r;   r*   r_   rH   rW   s        r"   r`   ÚRichVisual.get_optimal_width'  s0   € Ü—.’.Ó"×*Ñ*ˆÜØ×%Ñ% ñ
ˆð ˆr$   c           	     ó  • [         R                  " 5       nUR                  nU R                  n[	        U[
        5      (       aM  [        [        UR                  5      R                  UUUR                  UR                  =(       d    SS95      nU$ UR                  nUR                  U5      R                  SS9nUR                  XX5      n	[        U	 V
Vs/ s H  u  n
  oºR!                  S5      PM     snn
5      nU$ s  snn
f )Né   )Úno_wrapÚtab_sizeF)Ú	highlightÚ
)r   rŸ   rH   r“   r   r   r{   ÚplainÚwrapr©   rª   Úconsole_optionsÚupdate_widthÚupdateÚrenderÚsumÚcount)r;   r*   rW   rN   rH   r•   rX   r¯   rZ   ÚsegmentsÚtextÚ_s               r"   rh   ÚRichVisual.get_height.  så   € Ü�nŠnÓˆØ—+‘+ˆØ×%Ñ%ˆ
Ü�j¤$×'Ñ'ÜÜ�Z×%Ñ%Ó&×+Ñ+ØØØ&×.Ñ.Ø'×0Ñ0×5°Að	 ,ð óˆFð ˆð "×1Ñ1ˆOØ%×2Ñ2°5Ó9×@Ñ@È5Ð@ÐQˆGØ—~‘~ jÓ:ˆHä¹XÔFºX©z¨t°Q¸Ÿ*™* TÖ*¹XÒFÓGˆFàˆùó Gs   ÃC=
c           	     ó   • [         R                  " 5       nUR                  nUR                  R	                  SUUS9nUR
                  nU R                  R                  U R                  U5      n	UR                  X—R                  U5      5      n
[        [        R                  " X¡SSS9SU5       Vs/ s H  n[        U5      PM     nnU$ s  snf )á-  Render the Visual into an iterable of strips. Part of the Visual protocol.

Args:
    width: Width of desired render.
    height: Height of desired render or `None` for any height.
    style: The base style to render on top of.
    options: Additional render options.

Returns:
    An list of Strips.
F)r«   rW   rX   )Úinclude_new_linesrk   N)r   rŸ   rH   r¯   r±   r|   r’   r    r“   r²   r°   r   r   Úsplit_and_crop_linesr   )r;   rW   rX   rY   rZ   rN   rH   r¯   r|   r•   rµ   Úliner‚   s                r"   r[   ÚRichVisual.render_stripsD  s×   € ô �nŠnÓˆØ—+‘+ˆØ×-Ñ-×4Ñ4ØØØð 5ð 
ˆð
 ×%Ñ%ˆ
Ø—\‘\×-Ñ-¨d×.>Ñ.>À
ÓKˆ
Ø—>‘> *×.JÑ.JÈ5Ó.QÓRˆô Ü×,Ò,Ø°uÀ%ñð Øôó	
ò�ô �$ŽKñð 	ð 	
ð ˆùò	
s   Â2C)r”   r“   r’   N)r<   r   r•   r   rA   ÚNone©rA   zrich.repr.Result)rH   r   rZ   r   rA   r   rŒ   r�   rˆ   )r0   r1   r2   r3   r4   r–   r›   r£   r`   rh   r[   r6   r/   r$   r"   rO   rO     sK   † á-ô	5ôô!ôôð,#Øð#Ø",ð#Ø5:ð#ØERð#à	÷#r$   rO   c                  ó^   • \ rS rSrSrS
S jrSS jrSS jrSS jr          SS jr	Sr
g	)ÚPaddingij  zA Visual to pad another visual.c                ó   • Xl         X l        g)zc

Args:
    Visual: A Visual.
    spacing: A Spacing object containing desired padding dimensions.
N©Ú_visualÚ_spacing)r;   rS   Úspacings      r"   r–   ÚPadding.__init__n  s   € ð ŒØ�r$   c              #  óD   #   • U R                   v •  U R                  v •  g 7fr™   rÄ   rš   s    r"   r›   ÚPadding.__rich_repr__x  s   é € Ø�l‰lÒØ�m‰mÓùr�   c                óf   • U R                   R                  X5      U R                  R                  -   $ r™   )rÅ   r`   rÆ   rW   r^   s      r"   r`   ÚPadding.get_optimal_width|  s(   € à�L‰L×*Ñ*¨5ÓBÀTÇ]Á]×EXÑEXÑXð	
r$   c                ó”   • U R                   R                  XU R                  R                  -
  5      U R                  R                  -   $ r™   )rÅ   rh   rÆ   rW   rX   rg   s      r"   rh   ÚPadding.get_height�  s:   € à�L‰L×#Ñ# E°4·=±=×3FÑ3FÑ+FÓGØ�m‰m×"Ñ"ñ#ð	
r$   c           
     óÆ  • U R                   nU R                   u  pgp‰XU-   -
  n
U
S::  a  / $ U R                  R                  U
Uc  SOX%R                  -
  UU5      nU(       a{  UR                  nU(       a  [
        R                  " X5      /U-  O/ nU(       a  [
        R                  " X5      /U-  O/ n/ UQU Vs/ s H  nUR                  X©X|5      PM     snQUQnU$ s  snf )rº   r   N)rÆ   rÅ   r[   rX   r|   r   ÚblankÚcrop_pad)r;   rW   rX   rY   rZ   Úpaddingro   ÚrightÚbottomrn   Úrender_widthr‚   r|   Útop_paddingÚbottom_paddingrƒ   s                   r"   r[   ÚPadding.render_strips‡  sø   € ð —-‘-ˆØ#'§=¡=Ñ ˆ�FØ u¡Ñ-ˆØ˜1ÓØˆIà—‘×+Ñ+ØØ‘N‰D¨·±Ñ(?ØØó	
ˆö Ø×)Ñ)ˆJÞDGœ5Ÿ;š; uÓ9Ð:¸SÒ@ÈRˆKÞJPœeŸkšk¨%Ó<Ð=ÀÒFÐVXˆNðØðñ "(óâ!'˜ð —N‘N <°uÖIÙ!'ñðð  ðˆFð ˆùòs   Â:C)rÆ   rÅ   N)rS   r   rÇ   r   rA   r¿   rÀ   rŒ   r�   rˆ   )r0   r1   r2   r3   r4   r–   r›   r`   rh   r[   r6   r/   r$   r"   rÂ   rÂ   j  sF   † á)ô ôô
ô

ð(Øð(Ø",ð(Ø5:ð(ØERð(à	÷(r$   rÂ   )r!   r@   rA   rŽ   )T)r<   r   r!   r@   rQ   rŽ   rA   r   )=Ú
__future__r   Úabcr   r   Údataclassesr   Ú	itertoolsr   Útypingr   r	   r
   Ú	rich.reprÚrichÚrich.consoler   r   r   Úrich.measurer   Úrich.protocolr   r   Úrich.segmentr   Ú
rich.styler   r¡   Ú	rich.textr   Útextual._contextr   Útextual.css.stylesr   Útextual.geometryr   Útextual.renderr   Útextual.selectionr   Útextual.stripr   Útextual.styleÚtyping_extensionsr   Útextual.widgetr   r#   r'   r8   Ú	ExceptionrC   rE   r5   r=   r   ÚreprÚautorO   rÂ   r/   r$   r"   Ú<module>rò      sø   ðÞ "ç #Ý !Ý ß 4Ñ 4ã ß @Ñ @Ý $ß 2Ý  Ý )Ý å 'Ý 'Ý $Ý "Ý 'Ý Ý æÝ+å%ôAñ
 �$Ñ÷/ð /ó ð/ô �Xô ô -�)ô -ð C€
ˆIÓ Bö-ô`MˆSô Mð` ‡�‡�ô[�ó [ó ð[ð| ‡�‡�ôDˆfó Dó ñDr$   