+
     Bi1                    ~   ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHtHtHt ^RIHtHt ^RIHt ]P6                  ! R	4      t]P6                  ! R
4      t]P?                  RRRR/4      t RR0t!0 R'mt"]#! ]4       U u0 uF#  q PI                  R4      '       d   K  ]! V 4      kK%  	  up t%R t& ! R R]4      t' ! R R]4      t(]PR                  R R l4       t*R R lt+R(R R llt,R R lt-R R lt.R  R! lt/0 R)mt00 R'mt1R" R# lt2R*R$ R% llt3R& ! 4       t4R# u up i )+    )annotationsN)deque)StringIO)	TokenInfo)IterableIteratorMatch
NamedTupleSelf)
CharBuffer
CharWidths)tracez\x1b\[[ -@]*[A-~]z\x01.*?\x02 defclass_c                 B    \         P                  ! R/ V B P                  # )N )	_colorize	get_themesyntax)kwargss   ,$/usr/lib/python3.14/_pyrepl/utils.pyTHEMEr      s    ((///    c                  \    ] tR t^ t$ RtR]R&   R]R&   ]R R l4       t]R R l4       tR	t	R
# )Spanz,Span indexing that's inclusive on both ends.intstartendc               $    V ^8  d   QhRRRRRR/# )   mz
Match[str]groupz	int | strreturnr   r   )formats   "r   __annotate__Span.__annotate__'   s!     / /
 /9 / /r   c                	`    VP                  V4      pV ! V^ ,          V^,          ^,
          4      # )r   )span)clsr%   r&   re_spans   &&& r   from_reSpan.from_re&   s(    &&-71:wqzA~..r   c               $    V ^8  d   QhRRRRRR/# )r$   tokenTIline_len	list[int]r'   r   r   )r(   s   "r   r)   r*   ,   s!     

 

r 

Y 

4 

r   c                	   RpVP                   \        P                  \        P                  09   d+   VP                  P                  R4      '       d
   V^,          pV ! W!P                  ^ ,          ^,
          ,          VP                  ^,          ,           W!P                  ^ ,          ^,
          ,          VP                  ^,          ,           V,           4      # )   ){})typeTFSTRING_MIDDLETSTRING_MIDDLEstringendswithr!   r"   )r-   r2   r4   
end_offsets   &&& r   
from_tokenSpan.from_token+   s    
JJ1++Q-=-=>>%%j11!OJ[[^a'(5;;q>9YYq\A%&15
B
 	
r   r   N)
__name__
__module____qualname____firstlineno____doc____annotations__classmethodr/   rB   __static_attributes__r   r   r   r   r       s5    6J	H/ / 

 

r   r   c                  ,    ] tR t^9t$ R]R&   R]R&   RtR# )	ColorSpanr   r,   strtagr   N)rD   rE   rF   rG   rI   rK   r   r   r   rM   rM   9   s    
J	Hr   rM   c                    V ^8  d   QhRRRR/# )r$   crN   r'   r    r   )r(   s   "r   r)   r)   ?   s        r   c                h    \        V 4      ^8  d   ^# \        P                  ! V 4      pVR9   d   ^# ^# )   )NNaHA)ordunicodedataeast_asian_width)rQ   ws   & r   	str_widthr\   >   s/    
1v|$$Q'A!!r   c                    V ^8  d   QhRRRR/# )r$   srN   r'   r    r   )r(   s   "r   r)   r)   H   s     ? ?C ?C ?r   c                    \        V 4      ^8X  d   V R8w  d   \        V 4      # \        R V  4       4      p\        P	                  V 4      pV P                  R4      pV\        R V 4       4      ,
          V,           # )r7   c              3  8   "   T F  p\        V4      x  K  	  R # 5iN)r\   .0is   & r   	<genexpr>wlen.<locals>.<genexpr>K   s     )q!1q   c              3  8   "   T F  p\        V4      x  K  	  R # 5irb   )lenrc   s   & r   rf   rg   O   s     11Arh   )rj   r\   sumANSI_ESCAPE_SEQUENCEfindallcount)r^   lengthsequence
ctrl_z_cnts   &   r   wlenrr   H   se    
1v{qF{|)q))F#++A.HJC1111J>>r   c               $    V ^8  d   QhRRRRRR/# )r$   r^   rN   including_contentboolr'   r   )r(   s   "r   r)   r)   R   s!     ) ) ) )# )r   c                h    V'       d   \         P                  RV 4      # V P                  \        4      # )zReturn `s` with \001 and \002 characters removed.

If `including_content` is True, content between \001 and \002 is also
stripped.
r   )ZERO_WIDTH_BRACKETsub	translateZERO_WIDTH_TRANS)r^   rt   s   &&r   	unbracketr{   R   s*     !%%b!,,;;'((r   c                    V ^8  d   QhRRRR/# )r$   bufferrN   r'   Iterator[ColorSpan]r   )r(   s   "r   r)   r)   ]   s     
 
s 
2 
r   c              #  ,  "   \        V 4      p^ .VP                  4        Uu. uF  p\        V4      NK  	  up,           p\        ^\        V4      4       F$  pW4;;,          W4^,
          ,          ,          uu&   K&  	  VP	                  ^ 4       \
        P                  ! VP                  4      pRp \        WS4       F	  pVx  TpK  	  R# u upi   \         d     R# \
        P                   d!   p\        YY`4       Rj  xL 
   Rp?R# Rp?ii ; i5i)zReturns a list of index spans to color using the given color tag.

The input `buffer` should be a valid start of a Python code block, i.e.
it cannot be a block starting in the middle of a multiline string.
N)r   	readlinesrj   rangeseektokenizegenerate_tokensreadlinegen_colors_from_token_streamSyntaxError
TokenErrorrecover_unterminated_string)	r}   siolineline_lengthsre   genlast_emittedcolortes	   &        r   
gen_colorsr   ]   s      6
C3@#d)@@L1c,'(<!,, ) HHQK

"
"3<<
0C%)L	
1#DEK L E A   
.l
 	
 	

sX    DC
A9D0C DDDD0D1D DDDDDc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r$   excztokenize.TokenErrorr   r5   r   zColorSpan | Noner}   rN   r'   r~   r   )r(   s   "r   r)   r)   x   s:     &
 &
	&
&
 #&
 	&

 &
r   c              #    "   V P                   w  rEVf   R # Vw  rgVP                  R4      '       d   W^,
          ,          V,           ^,
          pVR	,          ^,
          p	V'       dE   WP                  P                  8:  d+   \	        RVR7       VP                  P
                  ^,           p\        W4      p
\	        RV
P                  V
P
                  R7       \        V
R4      x  R # \	        R\        V4      \        V 4      R7       R # 5i)
Nzbefore last emitted = {s})r^   zyielding span {a} -> {b})abr?   z&unhandled token error({buffer}) = {te})r}   r   )zunterminated string literalzunterminated f-string literalzunterminated t-string literalzEOF in multi-line stringz+unterminated triple-quoted f-string literalz+unterminated triple-quoted t-string literalr8   )
args
startswithr,   r!   r   r"   r   rM   reprrN   )r   r   r   r}   msglocline_nocolumnr!   r"   r,   s   &&&&       r   r   r   x   s      xxHC
{OG
~~	
	 	 q[)F2Q62" E%6%6%<%<<-7 %%))A-EE(DJJ$((Ch''4<3x	
s   DD
c               $    V ^8  d   QhRRRRRR/# )r$   token_generatorzIterator[TI]r   r5   r'   r~   r   )r(   s   "r   r)   r)      s&     ;5 ;5!;5;5 ;5r   c              #    "   \        V 4      pR p^ pV EFk  w  rVpVP                  VP                  8X  d   K$  VP                  ;;\        P
                  8X  d   M;\        P                  8X  d   Mp;\        P                  8X  d   MZ;\        P                  8X  d   MD;\        P                  8X  d   M.;\        P                  8X  d   M;\        P                  8X  d   M M'  \        P                  Wa4      p\        VR4      x  K  ;\        P                  8X  d(    \        P                  Wa4      p\        VR4      x  EK/  ;\        P                   8X  d(    \        P                  Wa4      p\        VR4      x  EKk  ;\        P"                  8X  d]    VP$                  R9   d   V^,          pMVP$                  R9   d
   V^,          p\        P                  Wa4      p\        VR4      x  EK  \        P&                  8X  g   EK  V'       d)   R p\        P                  Wa4      p\        VR4      x  EK#  \(        P*                  ! VP$                  4      '       dY   Rp	VP$                  \,        9   d   R	p	\        P                  Wa4      p\        W4      x  VP$                  \.        9   d   R
pEK  EK  \(        P0                  ! VP$                  4      '       d@   V^ 8X  d9   \3        WVV4      '       d'   \        P                  Wa4      p\        VR4      x  EK  VP$                  \4        9   dQ   V'       d    VP6                  \        P8                  8X  g'   \        P                  Wa4      p\        VR4      x  EKh  EKk  EKn  	  R# 5i)Fr?   commentnumberz([{z)]}op
definitionkeywordkeyword_constantTsoft_keywordbuiltinN)prev_next_windowr!   r"   r;   r<   STRINGFSTRING_STARTr=   FSTRING_ENDTSTRING_STARTr>   TSTRING_ENDr   rB   rM   COMMENTNUMBEROPr?   NAMEr   	iskeywordKEYWORD_CONSTANTSIDENTIFIERS_AFTERissoftkeywordis_soft_keyword_usedBUILTINS
exact_typeDOT)
r   r   token_windowis_def_namebracket_level
prev_tokenr2   
next_tokenr,   span_clss
   &&        r   r   r      s[     $O4LKM)5%
:;;%))#jjE!!//$4A$4$4}q}}!!//$4A$4$4}q}}E u;h//u;i00u;h//<<5(!Q&M\\U*!Q&Mu;d++"'K??5?D#D,77&&u||44(H||'88#5??5?D#D33||'88&* 9 ))%,,77%*,Z
KK??5?D#D.99LLH,'J,A,AQUU,J??5?D#D)44 -K -_ *6s(   G?NNANA=NAN7ANc                    V ^8  d   QhRRRR/# )r$   tokensz	TI | Noner'   ru   r   )r(   s   "r   r)   r)      s     ) )) ) )r   c                 	   \        RV R7       T ; EdM    ^8H  EdE   w  ;f   M`;\        Rc;e   w  \        P                  8X  d   M= ;\        Rc;e   w  \        P                  8X  d   M ;\        Rc ;e
   w  R8X  d   M  M \        Rc ;e   w  R8X  d   ;\        Rc;e_   w  ;\        P
                  8X  d   MD;\        P                  8X  d   M.;\        P                  8X  d   M;\        P                  8X  d   M M MZ ;\        Rc;eK   w  \        P                  8X  d5   ;R8X  d   M*;R8X  d   M";R	8X  d   M;R
8X  d   M;R8X  d   M
;R8X  d   M M M  M  R#   ; d    ^8H  d   w  ;f   M`;\        Rc;e   w  \        P                  8X  d   M= ;\        Rc;e   w  \        P                  8X  d   M ;\        Rc ;e
   w  R8X  d   M  M^ \        Rc ;eS   w  R8X  dL   \        Rc;eA   w  \        P                  8X  d+   p \        P                  ! V4      '       d
   V\        9   # R#   ; Edi    ^8H  Eda   w  ;f   M;\        Rc;e   w  \        P                  8X  d   Ma ;\        Rc;e   w  \        P                  8X  d   M= ;\        Rc;e   w  \        P                  8X  d   M ;\        Rc ;e
   w  R8X  d   M  M \        Rc ;e   w  R8X  d   ;\        Rc;e_   w  ;\        P
                  8X  d   MD;\        P                  8X  d   M.;\        P                  8X  d   M;\        P                  8X  d   M M MR ;\        Rc;eC   w  \        P                  8X  d-   ;R8X  d   M";R8X  d   M;R8X  d   M;R	8X  d   M
;R
8X  d   M M M  M  R#   ; d    ^8H  d   w  ;f   M;\        Rc;e   w  \        P                  8X  d   Ma ;\        Rc;e   w  \        P                  8X  d   M= ;\        Rc;e   w  \        P                  8X  d   M ;\        Rc ;e
   w  R8X  d   M  M^ \        Rc ;eS   w  R8X  dL   \        Rc;eA   w  \        P                  8X  d+   p \        P                  ! V4      '       d
   V\        9   # R#    dG    ^8H  d@   w  \        Rc ;e1   w  R8X  d*   \        Rc ;e   w  R8X  d   \        Rc ;e   w  R8X  d   R#     R# )zReturns True if the current token is a keyword in this context.

For the `*tokens` to match anything, they have to be a three-tuple of
(previous, current, next).
zis_soft_keyword_used{t})tr   )r?   :match(*[r9   ~z...Tcase-r   F)r   r3   r<   NEWLINEINDENTr   r   r   r   r   r   r   r   keyword_first_sets_matchDEDENTkeyword_first_sets_case)r   r^   s   * r   r   r      sz    

#v.

 
=2=aii=<2<ahh<.".C.@gGBGxqxx(!((_Q__qFGBbBcC#cEABC 

 
=2=aii=<2<ahh<.".C.@g qvv

   ##444

 
=2=aii=<2<ahh<,",QXX,3OfGBGxqxx(!((_Q__qFG:b:cC#c9:; 

 
=2=aii=<2<ahh<,",QXX,3Of qvv

   ##333
 A@b33 Ar   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r$   r}   rN   colorszlist[ColorSpan] | Nonestart_indexr    force_colorru   r'   ztuple[CharBuffer, CharWidths]r   )r(   s   "r   r)   r)     sA     S SS"S S 	S
 #Sr   c                x   . p. pV '       g   WE3# V'       d6   V^ ,          P                   P                  V8  d   VP                  ^ 4       K=  \        VR7      pRpRpV'       d<   V^ ,          P                   P                  V8  d   Wa^ ,          P
                  ,          p\        W4       EF  w  rV'       d<   V^ ,          P                   P                  V	8X  d   Wa^ ,          P
                  ,          pV
R8X  d$   VP                  V
4       VP                  ^4       M\        V
4      ^8  d$   VP                  V
4       VP                  ^4       M\        P                  ! V
4      P                  R4      '       d?   R\        V
4      ,          p
VP                  V
4       VP                  \        V
4      4       M+VP                  V
4       VP                  \        V
4      4       V'       d@   V^ ,          P                   P                  V	8X  d   VP                  pVP                  ^ 4       WtR,          ,           V,           VR&   RpRpEK  	  V'       dd   V^ ,          P                   P                  X	8  dB   V^ ,          P                   P                  V	8  d    VR;;,          VP                  ,          uu&   WE3# )a  Decompose the input buffer into a printable variant with applied colors.

Returns a tuple of two lists:
- the first list is the input buffer, character by character, with color
  escape codes added (while those codes contain multiple ASCII characters,
  each code is considered atomic *and is attached for the corresponding
  visible character*);
- the second list is the visible width of each character in the input
  buffer.

Note on colors:
- The `colors` list, if provided, is partially consumed within. We're using
  a list and not a generator since we need to hold onto the current
  unfinished span between calls to disp_str in case of multiline strings.
- The `colors` list is computed from the start of the input block. `buffer`
  is only a subset of that input block, a single line within. This is why
  we need `start_index` to inform us which position is the start of `buffer`
  actually within user input. This allows us to match color spans correctly.

Examples:
>>> utils.disp_str("a = 9")
(['a', ' ', '=', ' ', '9'], [1, 1, 1, 1, 1])

>>> line = "while 1:"
>>> colors = list(utils.gen_colors(line))
>>> utils.disp_str(line, colors=colors)
(['\x1b[1;34mw', 'h', 'i', 'l', 'e\x1b[0m', ' ', '1', ':'], [1, 1, 1, 1, 1, 1, 1, 1])

)r   r   r`   Cz\u%04xr8   )r,   r"   popr   r!   rO   	enumerateappendrX   rY   categoryr   rj   r\   reset)r}   r   r   r   charschar_widthstheme	pre_color
post_colorre   rQ   s   &&&&       r   disp_strr     s   F E K!!
VAY^^''+5

1k*EIJ&)..&&4)--(	&.fQinn**a/Qimm,I;LLOq!Vc\LLOq!!!!$//44CF"ALLOs1v&LLOy|,fQinn((A-JJJqMb	)J6b		
1 /4 &)..&&*vay~~/A/AA/E 	b	U[[ 	r   c                     R 5;p3R R lu6# )r<   c                    V ^8  d   QhRRRR/# )r$   iterablezIterable[T]r'   zIterator[tuple[T | None, ...]]r   )r(   s   "r   r)   r)   e  s      #r   c              3  H  "   \        V 4      p\        R\        V4      3^R7      p V F!  pVP                  V4       \	        V4      x  K#  	   TP                  R4       \	        T4      x  R#   \
         d    h i ; i  TP                  R4       \	        T4      x  i ; i5i)a  Generates three-tuples of (previous, current, next) items.

On the first iteration previous is None. On the last iteration next
is None. In case of exception next is None and the exception is re-raised
on a subsequent next() call.

Inspired by `sliding_window` from `itertools` recipes.
N)maxlen)iterr   nextr   tuple	Exception)r   iteratorwindowxs   &   r   r   r   e  s      H~HD$x.)!4FAMM!-  	dFm	   	dFms(   $B"'A/  B"/A<<A? ? BB"r   )	.defaultsr<   s     r   (<generic parameters of prev_next_window>r   e  s	    Q r   >   NoneTrueFalse)F>   notr   r   r   awaitlambda)Nr   F)5
__future__r   builtins	functoolsr   rer2   r<   r   rY   r   collectionsr   ior   r   r3   typingr   r   r	   r
   r   typesr   r   r   compilerl   rw   rN   	maketransrz   r   r   dirr   r   r   r   rM   cacher\   rr   r{   r   r   r   r   r   r   r   r   )names   0r   <module>r     s!   "    	       $ > > ) zz"67 ZZ/ ==&"fb!9: G$ - "%h-L-$s7KICI-L0

: 
2
 
  ?)
6&
R;5| O 3 )XSl [
 Ms    D:=D: