+
    Ri3                       R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHtH	t	 ^ RI
Ht ^RIHtHtHtHtHt ^RIHt . ROt]P*                  ! 4        U Uu/ uF%  w  rV P-                  4       VP/                  R
4      bK'  	  upp tR R lt]! RRRRRRRRRRR7
      tR R ltR R lt]P:                  ! R4      t ! R R	]4      t]P@                  t! ! R R]4      t"]	! R4      t#R R lt$R R lt% ! R R]4      t&R# u upp i )z-
Tool for creating styles from a dictionary.
)annotationsN)Enum)HashableTypeVar)SimpleCache)ANSI_COLOR_NAMESANSI_COLOR_NAMES_ALIASESDEFAULT_ATTRSAttrs	BaseStyle)NAMED_COLORSStylePriority#c                    V ^8  d   QhRRRR/# )   textstrreturn )formats   "Z/home/ubuntu/hermes-agent/venv/lib/python3.14/site-packages/prompt_toolkit/styles/style.py__annotate__r   !   s     +5 +5c +5c +5    c                   V \         9   d   V # V \        9   d   \        V ,          #  \        V P                  4       ,          #   \         d     Mi ; iT R,          R8X  d   T R,          pT\         9   d   T# T\        9   d   \        T,          # \        T4      ^8X  d   T# \        T4      ^8X  d;   T^ ,          ^,          T^,          ^,          ,           T^,          ^,          ,           # M	T R9   d   T # \        RT : 24      h)z
Parse/validate color format.

Like in Pygments, but also support the ANSI color names.
(These will map to the colors of the 16 color palette.)
:       Nr   :r   NNzWrong color format ) default)r   r   _named_colors_lowercaselowerKeyErrorlen
ValueError)r   cols   & r   parse_colorr%   !   s     '''--&tzz|44  CyC2h ""J,,+C00 X]J X]q6A:A
*SVaZ77  
	 
*4(3
44s   A AA
colorbgcolorbold	underlinestrikeitalicblinkreversehiddendimc                    V ^8  d   QhRRRR/# )r   	classnamer   r   z	list[str]r   )r   s   "r   r   r   _   s        r   c                    . pV P                  R4      p\        ^\        V4      ^,           4       F4  pVP                  RP	                  VRV 4      P                  4       4       K6  	  V# )zy
Split a single class name at the `.` operator, and build a list of classes.

E.g. 'a.b.c' becomes ['a', 'a.b', 'a.b.c']
.N)splitranger"   appendjoinr    )r2   resultpartsis   &   r   _expand_classnamer<   _   s[     FOOC E1c%j1n%chhuRay)//12 & Mr   c                    V ^8  d   QhRRRR/# )r   	style_strr   r   r
   r   )r   s   "r   r   r   n   s     E E E Er   c                   RV 9   d   \         pM\        pV P                  4        EF  pVR8X  d   K  VR8X  d   VP                  RR7      pK(  VR8X  d   VP                  RR7      pKC  VR8X  d   VP                  RR7      pK^  VR	8X  d   VP                  RR7      pKy  VR
8X  d   VP                  RR7      pK  VR8X  d   VP                  RR7      pK  VR8X  d   VP                  RR7      pK  VR8X  d   VP                  RR7      pK  VR8X  d   VP                  RR7      pEK  VR8X  d   VP                  RR7      pEK  VR8X  d   VP                  RR7      pEK9  VR8X  d   VP                  RR7      pEKU  VR8X  d   VP                  RR7      pEKq  VR8X  d   VP                  RR7      pEK  VR8X  d   VP                  RR7      pEK  VR8X  d   VP                  RR7      pEK  VR$9   d   EK  VP	                  R4      '       d   EK  VP	                  R4      '       d   VP                  R4      '       d   EK  VP	                  R4      '       d&   VP                  \        VR ,          4      R!7      pEKV  VP	                  R"4      '       d&   VP                  \        VR ,          4      R#7      pEK  VP                  \        V4      R#7      pEK  	  V# )%zX
Take a style string, e.g.  'bg:red #88ff00 class:title'
and return a `Attrs` instance.
	noinheritr)   T)r)   noboldFr,   )r,   noitalicr*   )r*   nounderliner+   )r+   nostriker-   )r-   noblinkr.   )r.   	noreverser/   )r/   nohiddenr0   )r0   nodimzborder:[]zbg::   NN)r(   zfg:)r'   )romansansmono)r	   _EMPTY_ATTRSr5   _replace
startswithendswithr%   )r>   attrsparts   &  r   _parse_style_strrU   n   sd    i !;V^NNN-EXNNN.EXNN$N/EZNN%N0E[ NNTN2E]"NNUN3EXNN$N/EZNN%N0E W_NNN.EYNNN/EYNN4N0E[ NN5N1EXNN$N/EZNN%N0EU]NNtN,EW_NNuN-E ..__Y'' __S!!dmmC&8&8 __U##NN;tBx+@NAE__U##NNT"X)>N?ENNT):N;Eo "r Lr   z^[a-z0-9.\s_-]*$c                  "    ] tR t^tRtRtRtRtR# )r   a  
The priority of the rules, when a style is created from a dictionary.

In a `Style`, rules that are defined later will always override previous
defined rules, however in a dictionary, the key order was arbitrary before
Python 3.6. This means that the style could change at random between rules.

We have two options:

- `DICT_KEY_ORDER`: This means, iterate through the dictionary, and take
   the key/value pairs in order as they come. This is a good option if you
   have Python >3.6. Rules at the end will override rules at the beginning.
- `MOST_PRECISE`: keys that are defined with most precision will get higher
  priority. (More precise means: more elements.)
	KEY_ORDERMOST_PRECISEr   N)__name__
__module____qualname____firstlineno____doc__DICT_KEY_ORDERrX   __static_attributes__r   r   r   r   r      s      !N!Lr   c                  v    ] tR t^tRtR R lt]R R l4       t]]	3R R ll4       t
]3R R	 lltR
 R ltRtR# )r   aT  
Create a ``Style`` instance from a list of style rules.

The `style_rules` is supposed to be a list of ('classnames', 'style') tuples.
The classnames are a whitespace separated string of class names and the
style string is just like a Pygments style definition, but with a few
additions: it supports 'reverse' and 'blink'.

Later rules always override previous rules.

Usage::

    Style([
        ('title', '#ff0000 bold underline'),
        ('something-else', 'reverse'),
        ('class1 class2', 'reverse'),
    ])

The ``from_dict`` classmethod is similar, but takes a dictionary as input.
c                    V ^8  d   QhRRRR/# )r   style_ruleslist[tuple[str, str]]r   Noner   )r   s   "r   r   Style.__annotate__   s     ; ;$9 ;d ;r   c                	   . pV Ft  w  r4\         P                  V4      '       g   Q \        V4      4       h\        VP	                  4       P                  4       4      p\        V4      pVP                  WV34       Kv  	  Wn        W n	        R # N)
CLASS_NAMES_REmatchrepr	frozensetr    r5   rU   r7   _style_rulesclass_names_and_attrs)selfrb   rm   class_namesr>   class_names_setrS   s   &&     r   __init__Style.__init__   s     " '2"K!''44Gd;6GG4 ((9(9(;(A(A(CDO$Y/E!((/)AB '2 (%:"r   c                   V ^8  d   QhRR/# r   r   rc   r   )r   s   "r   r   re      s     ! !2 !r   c                	    V P                   # rg   )rl   rn   s   &r   rb   Style.style_rules   s       r   c               $    V ^8  d   QhRRRRRR/# )r   
style_dictzdict[str, str]priorityr   r   r   r   )r   s   "r   r   re      s$     1 1'13;1	1r   c                    V\         P                  8X  d(   R R lpV ! \        VP                  4       VR7      4      # V ! \	        VP                  4       4      4      # )zI
:param style_dict: Style dictionary.
:param priority: `Priority` value.
c                    V ^8  d   QhRRRR/# )r   itemztuple[str, str]r   intr   )r   s   "r   r   %Style.from_dict.<locals>.__annotate__	  s     G G/ Gc Gr   c                P    \        R  V ^ ,          P                  4        4       4      # )c              3  V   "   T F  p\        VP                  R 4      4      x  K!  	  R# 5i)r4   N)r"   r5   ).0r;   s   & r   	<genexpr>/Style.from_dict.<locals>.key.<locals>.<genexpr>  s      Fo3qwws|,,os   '))sumr5   )r}   s   &r   keyStyle.from_dict.<locals>.key	  s    Fd1gmmoFFFr   )r   )r   rX   sorteditemslist)clsry   rz   r   s   &&& r   	from_dictStyle.from_dict   sN     x,,,G vj..0c:;;tJ,,./00r   c               $    V ^8  d   QhRRRRRR/# r   r>   r   r   r
   r   r   )r   s   "r   r   re     s$     /+ /+/+',/+	/+r   c           
     `   V.p\        4       pV P                   F   w  rVV'       d   K  VP                  V4       K"  	  VP                  4        EFR  pVP	                  R4      '       Ed   . pVR,          P                  4       P                  R4       F  p	VP                  \        V	4      4       K  	  V F  p
\        4       pVP                  \        V
.4      4       \        ^\        V4      ^,           4       FA  p\        P                  ! WL4       F$  pVP                  \        W3,           4      4       K&  	  KC  	  V P                   F  w  rVW[9   g   K  VP                  V4       K   	  VP                  V
4       K  	  EK6  \        V4      pVP                  V4       EKU  	  \        V4      # )z)
Get `Attrs` for the given style string.
zclass::   NN,)setrm   r7   r5   rQ   r    extendr<   addrk   r6   r"   	itertoolscombinationsrU   _merge_attrs)rn   r>   r   list_of_attrsro   namesattrrT   new_class_namespnew_namecomboscountc2inline_attrss   &&&            r   get_attrs_for_style_strStyle.get_attrs_for_style_str  sa    !	 #  55KE5$$T* 6 OO%D x(("$b)//4A#**+<Q+?@ 5 !0H UFJJy(45!&q#k*:Q*>!?"+"8"8"LB"JJyk1A'BC #M "@
 (,'A'A ?)006 (B  OOH- !0$  05$$\2; &> M**r   c                   V ^8  d   QhRR/# r   r   r   r   )r   s   "r   r   re   B  s     . .8 .r   c                	,    \        V P                  4      # rg   )idrm   rv   s   &r   invalidation_hashStyle.invalidation_hashB  s    $,,--r   )rl   rm   N)rY   rZ   r[   r\   r]   rq   propertyrb   classmethoddefault_priorityr   r	   r   r   r_   r   r   r   r   r      sL    *;$ ! ! >N1 1$ 0=/+b. .r   _Tc                    V ^8  d   QhRRRR/# )r   r   zlist[Attrs]r   r
   r   )r   s   "r   r   r   I  s        r   c                0   R R lp\        T! R.V  Uu. uF  q"P                  NK  	  upO5!  T! R.V  Uu. uF  q"P                  NK  	  upO5!  T! R.V  Uu. uF  q"P                  NK  	  upO5!  T! R.V  Uu. uF  q"P                  NK  	  upO5!  T! R.V  Uu. uF  q"P
                  NK  	  upO5!  T! R.V  Uu. uF  q"P                  NK  	  upO5!  T! R.V  Uu. uF  q"P                  NK  	  upO5!  T! R.V  Uu. uF  q"P                  NK  	  upO5!  T! R.V  Uu. uF  q"P                  NK  	  upO5!  T! R.V  Uu. uF  q"P                  NK  	  upO5!  R7
      # u upi u upi u upi u upi u upi u upi u upi u upi u upi u upi )z
Take a list of :class:`.Attrs` instances and merge them into one.
Every `Attr` in the list can override the styling of the previous one. So,
the last one has highest priority.
c                    V ^8  d   QhRRRR/# )r   valuesr   r   r   )r   s   "r   r   "_merge_attrs.<locals>.__annotate__P  s      R B r   c                 D    V RRR1,           F  pVf   K	  Vu # 	  \         h)z/Take first not-None value, starting at the end.N)r#   )r   vs   * r   _or_merge_attrs.<locals>._orP  s(    "A}  r   r   Fr&   )r
   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   )r   r   as   &  r   r   r   I  s`    "87A78B<];]))];<9-8-Q&&-89eCMBMq{{MBC5=m<mHHm<=5=m<mHHm<=%;M:Mq77M:;E?>1YY>?5=m<mHHm<=76167 7;8B<<:><6s:   E&E+E0:E5E:>E? FF	$FF c                    V ^8  d   QhRRRR/# )r   styleslist[BaseStyle]r   _MergedStyler   )r   s   "r   r   r   e  s          \  r   c                N    V  Uu. uF
  qf   K  VNK  	  p p\        V 4      # u upi )z!
Merge multiple `Style` objects.
)r   )r   ss   & r   merge_stylesr   e  s*      1AaaF1 2s   ""c                  p    ] tR tRtRtR R lt]R R l4       t]R R l4       t]	3R	 R
 llt
R R ltRtR# )r   im  z
Merge multiple `Style` objects into one.
This is supposed to ensure consistency: if any of the given styles changes,
then this style will be updated.
c                    V ^8  d   QhRRRR/# )r   r   r   r   rd   r   )r   s   "r   r   _MergedStyle.__annotate__}  s     K K K4 Kr   c                	4    Wn         \        ^R7      V n        R# )r   )maxsizeN)r   r   _style)rn   r   s   &&r   rq   _MergedStyle.__init__}  s    4?4Jr   c                   V ^8  d   QhRR/# r   r   r   r   )r   s   "r   r   r     s     > >u >r   c                j   a  R V 3R llpS P                   P                  S P                  4       V4      # )z=The `Style` object that has the other styles merged together.c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   0_MergedStyle._merged_style.<locals>.__annotate__  s     	+ 	+U 	+r   c                 .   < \        S P                  4      # rg   )r   rb   rv   s   r   get'_MergedStyle._merged_style.<locals>.get  s    ))**r   )r   r   r   )rn   r   s   f r   _merged_style_MergedStyle._merged_style  s-    	+ 	+ {{t557==r   c                   V ^8  d   QhRR/# rt   r   )r   s   "r   r   r     s      2 r   c                	f    . pV P                    F  pVP                  VP                  4       K   	  V# rg   )r   r   rb   )rn   rb   r   s   &  r   rb   _MergedStyle.style_rules  s-    Aq}}- r   c               $    V ^8  d   QhRRRRRR/# r   r   )r   s   "r   r   r     s)     N NN',N	Nr   c                	8    V P                   P                  W4      # rg   )r   r   )rn   r>   r   s   &&&r   r   $_MergedStyle.get_attrs_for_style_str  s     !!99)MMr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s     A A8 Ar   c                	    \         ;QJ d    . R  V P                   4       F  NK  	  5# ! R  V P                   4       4      # )c              3  @   "   T F  qP                  4       x  K  	  R # 5irg   )r   )r   r   s   & r   r   1_MergedStyle.invalidation_hash.<locals>.<genexpr>  s     @Kq((**Ks   )tupler   rv   s   &r   r   _MergedStyle.invalidation_hash  s,    u@DKK@u@u@DKK@@@r   )r   r   N)rY   rZ   r[   r\   r]   rq   r   r   rb   r	   r   r   r_   r   r   r   r   r   m  sL    K > >   0=N
A Ar   r   )r   r%   r   r   )'r]   
__future__r   r   reenumr   typingr   r   prompt_toolkit.cacher   baser   r   r	   r
   r   named_colorsr   __all__r   r    lstripr   r%   rO   r<   rU   compilerh   r   r^   r   r   r   r   r   r   )kr   s   00r   <module>r      s   #  	  $ ,  ' AM@R@R@TU@T1779ahhsm3@TU +5` 
	
EP /0"t ". ** p.I p.f T]8 *A9 *A_
 Vs   +C9