
    ^h*                    V   S SK Jr  S SKJrJrJrJrJrJrJ	r	J
r
  S SKJr  \(       a  S SKJr  S SKJr  / SQr\	\\\4   \\\\\/S4   4   4   r\\   r\(       a  S SKJr   " S	 S
\5      r\	\S
\\/ \4   S4   r S       SS jjrSS jr " S S\5      r " S S5      rSS jrg)    )annotations)TYPE_CHECKINGAnyCallableIterableListTupleUnioncast)
MouseEvent)Protocol)NotImplementedOrNone)	OneStyleAndTextTupleStyleAndTextTuplesMagicFormattedTextAnyFormattedTextto_formatted_textis_formatted_textTemplatemerge_formatted_textFormattedTextr   )	TypeGuardc                  "    \ rS rSrSrSS jrSrg)r   #   zQ
Any object that implements ``__pt_formatted_text__`` represents formatted
text.
c                    g N selfs    \/home/james-whalen/.local/lib/python3.13/site-packages/prompt_toolkit/formatted_text/base.py__pt_formatted_text__(MagicFormattedText.__pt_formatted_text__)   s    s    r   Nreturnr   )__name__
__module____qualname____firstlineno____doc__r!   __static_attributes__r   r#   r    r   r   #   s    	
 	Cr#   r   Nr   c           	        U c  / nO[        U [        5      (       a  SU 4/nO[        U [        5      (       a  U nOh[        U S5      (       a  [	        SU 5      R                  5       nO<[        U 5      (       a  [        U " 5       US9$ U(       a  SU  4/nO[        SU < 35      eU(       a.  [	        [        U VVs/ s H  tpEUS-   U-   /UQ7PM     snn5      n[        U[        5      (       a  U$ [        U5      $ s  snnf )aH  
Convert the given value (which can be formatted text) into a list of text
fragments. (Which is the canonical form of formatted text.) The outcome is
always a `FormattedText` instance, which is a list of (style, text) tuples.

It can take a plain text string, an `HTML` or `ANSI` object, anything that
implements `__pt_formatted_text__` or a callable that takes no arguments and
returns one of those.

:param style: An additional style string which is applied to all text
    fragments.
:param auto_convert: If `True`, also accept other types, and convert them
    to a string first.
 r!   r   )stylez[No formatted text. Expecting a unicode object, HTML, ANSI or a FormattedText instance. Got  )
isinstancestrlisthasattrr   r!   callabler   
ValueErrorr   r   )valuer.   auto_convertresult
item_stylerests         r    r   r   6   s    & }	E3		u+	E4	 	 	/	0	0*E2HHJ	% 66	%"#;;@)E
 	
 HNO3D:eckJ&..O
 &-((V$$ Ps   8C9c                    [        U 5      (       a  g[        U [        [        45      (       a  g[	        U S5      (       a  gg)z
Check whether the input is valid formatted text (for use in assert
statements).
In case of a callable, it doesn't check the return type.
Tr!   F)r4   r0   r1   r2   r3   )r6   s    r    r   r   k   s8     %#t%%u-..r#   c                  :   ^  \ rS rSrSrSS jrSU 4S jjrSrU =r$ )r   z   zv
A list of ``(style, text)`` tuples.

(In some situations, this can also be ``(style, text, mouse_handler)``
tuples.)
c                    U $ r   r   r   s    r    r!   #FormattedText.__pt_formatted_text__   s    r#   c                (   > S[         TU ]  5        S3$ )NzFormattedText())super__repr__)r   	__class__s    r    rC   FormattedText.__repr__   s     0 23155r#   r   r$   )r%   r1   )	r&   r'   r(   r)   r*   r!   rC   r+   __classcell__)rD   s   @r    r   r   z   s    6 6r#   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r      z
Template for string interpolation with formatted text.

Example::

    Template(' ... {} ... ').format(HTML(...))

:param text: Plain text.
c                     SU;  d   eXl         g )Nz{0}text)r   rK   s     r    __init__Template.__init__   s    D   	r#   c                   ^ ^ SU U4S jjnU$ )Nc                 <  > TR                   R                  S5      n [        U 5      S-
  [        T5      :X  d   e[        5       n[	        U T5       H2  u  p#UR                  SU45        UR                  [        U5      5        M4     UR                  SU S   45        U$ )Nz{}   r-   )rK   splitlenr   zipappendextendr   )partsr8   partvalr   valuess       r    
get_result#Template.format.<locals>.get_result   s    IIOOD)Eu:>S[000"_F /	r4j)/45 0 MM2uRy/*Mr#   r%   r   r   )r   rZ   r[   s   `` r    formatTemplate.format   s    
	 
	 r#   rJ   N)rK   r1   r%   None)rZ   r   r%   r   )r&   r'   r(   r)   r*   rL   r^   r+   r   r#   r    r   r      s    r#   r   c                   ^  SU 4S jjnU$ )z@
Merge (Concatenate) several pieces of formatted text together.
c                 b   > [        5       n T H  nU R                  [        U5      5        M     U $ r   )r   rV   r   )r8   iitemss     r    _merge_formatted_text3merge_formatted_text.<locals>._merge_formatted_text   s+    AMM+A./ r#   r]   r   )rd   re   s   ` r    r   r      s    
 ! r#   )r-   F)r6   r   r.   r1   r7   boolr%   r   )r6   objectr%   zTypeGuard[AnyFormattedText])rd   zIterable[AnyFormattedText]r%   r   )
__future__r   typingr   r   r   r   r   r	   r
   r   prompt_toolkit.mouse_eventsr   typing_extensionsr   'prompt_toolkit.key_binding.key_bindingsr   __all__r1   r   r   r   r   r   r   r   r   r   r   r   r#   r    <module>ro      s    " S S S 2*L
 	#s(OU3Xzl<R.R%SSTT 
 ./  +CX C RW
  DI2%2%$'2%<@2%2%j6& 6 >!r#   