
    ]OgJ1              
          S SK Jr  S SKrS SKr " S S5      r\R
                  " SS9S 5       r " S S	5      rS
 r/ SQr	\R                  \	 V s0 s H  o S_M     sn \R                  \	 V s0 s H  o S_M     sn \R                  \	 V s0 s H  o S_M     sn 0rS rS r\R                  S4S jr\R                  S4S jrS r\R                  S4S jrS rgs  sn f s  sn f s  sn f )    )StringIONc                   &    \ rS rSrS rS rS rSrg)PixelMapping   c                 "    XU4U l         X@l        g N)coordscode)selfrgbr
   s        T/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/climage/climage.py__init__PixelMapping.__init__   s    Qi	    c                 ,    [        U R                  5      $ r   )lenr	   )r   s    r   __len__PixelMapping.__len__   s    4;;r   c                      U R                   U   $ r   )r	   )r   is     r   __getitem__PixelMapping.__getitem__   s    {{1~r   )r
   r	   N)__name__
__module____qualname____firstlineno__r   r   r   __static_attributes__ r   r   r   r      s     r   r      )maxsizec                     [         U    U   c  [        X5        [         U    U   nUR                  U5      S   R                  R                  $ )Nr   )color_kdtreespopulate_kdtree	search_nndatar
   )
color_typepalettesourcetrs       r   _bestr,      sK     Z )1
,	z	"7	+B<<"'',,,r   c                   $    \ rS rSrSrSrSrSrSrg)color_types   r            r    N)	r   r   r   r   	truecolorcolor256color16color8r   r    r   r   r.   r.      s    IHGFr   r.   c                    U [         R                  :X  a  [        U5      S S nOU [         R                  :X  a  [        U5      S S  nOU [         R                  :X  a  [        U5      S S  nS H  nS H|  nS Hs  nUR                  UUUS[        [        [        SU-  S-  5      5      [        [        SU-  S-  5      5      -   [        [        SU-  S-  5      5      -   S5      -   /5        Mu     M~     M     S H  nUR                  XfUSUS	-  -   /5        M     [        R                  " W Vs/ s H  n[        U6 PM     sn5      [        U    U'   g s  snf )
N   )r   _                     r=      )r8         &   0   :   D   N   X   b   l   v                                          
   )r.   r6   _get_system_colorsr5   r4   appendintstrkdtreecreater   r$   )r(   r)   colorsr1g1b1scols           r   r%   r%   %   sP   ['''#G,Ra0	{**	*#G,Q/	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   )r   rL   rL   r@   )   rp   rp   r   )rL   rL   rL   r8   )r=   r   r   	   )r   r=   r   rY   )r=   r=   r      )r   r   r=      )r=   r   r=      )r   r=   r=      )r=   r=   r=      rg   )   r   r   r0   )r   rw   r   r1   )rw   rw   r   r2   )r   r   rW   ro   )rw   r   rw   r?   )r   rw   rw   r@   )   rx   rx   r   )   ry   ry   r8   )\   rz   r=   rs   rh   )   r   r   r0   )r   r{   r   r1   )r{   U   r   r2   )r   r   r{   ro   )r{   r   r{   r?   )r   r{   r{   r@   )r{   r{   r{   r   )r|   r|   r|   r8   )r=   r|   r|   rq   )r|   r=   r|   rY   )r=   r=   r|   rr   )r|   r|   r=   rs   )r=   r|   r=   rt   )r|   r=   r=   ru   ri   )r   6   B   r   )   2   /   r0   )      r   r1   )      r   r2   )rC         ro   )   r}      r?   )*         r@   )rW   rX      r   )r   +   r}   r8   )   K      rq   )rH   n   u   rY   )e   {      rr   )r   rN      rs   )rJ   q      rt   )   r   r   ru   )         rv   rj   )r   r   rw   ro   )      r<   r   )@   r   r   r8   rk   )   r   r   r0   )rG      r@   r1   )r      r   r2   )4   r      ro   )r   P   r   r?   )r@   r   r   r@   )r   r<      r   )r|   W   S   r8   )   )   r   rq   )rM      r   rY   )      O   rr   )r      r   rs   )   ry   rP   rt   )r   r   r   ru   )rW   rW      rv   rl   )         r   )r   $      r0   )r         r1   )r<   r   !   r2   )E   r      ro   )   rI      r?   )h      j   r@   )|   o   d   r   )   r   t   r8   )r   r   r@   rq   )y   r   ru   rY   )r   rK      rr   )r   f   x   rs   )   ?   r   rt   )r~   r   rH   ru   )<   8   r}   rv   rm   )(   r   r   r   )rP   r      r   )r   I   r   rq   )      rC   rY   )r      r   rr   )r      r   rs   )r   r      rt   )   rp   r   ru   )r      rQ   rv   zinvalid palette {})
ValueErrorformat)r)   s    r   rZ   rZ   t   s9   )!
 	
$ '!
 	
$ 
N	"!
 	
$ 
K	!
 	
$ 
F	!
 	
$ 
G	!
 	
$ 
I	!
 	
$ 
M	!!
 	
( -44W=>>r   c                     U S:  a)  U(       a  S[        U S-
  5      -   $ S[        U S-
  5      -   $ U(       a  S[        U 5      -   $ S[        U 5      -   $ )Nr8   10943)r]   )in_idis_bgs     r   _id_to_codepointr     sS    z#eai.((UQY''U##U##r   rf   c                 L    U[         R                  :X  a  U SS $ [        XU 5      $ )a  
Convert an RGB triple into the color used by the ANSI colour sequence,
depending on the color mode.

Arguments:
    pixel   -- (r,g,b) tuple representing the pixel. Each pixel is an 8 bit value, in the range [0, 255].

Keyword Arguments:
    ctype   -- the color depth to use, default color_types.color256
    palette -- if not using the truecolor depth, adjust how pixels map to the desired colourspace to match the colourscheme better.
Nr2   )r.   r3   r,   )pixelctyper)   s      r   convert_pixel_colorr   !  s-     %%%Ray ''r   c                     [        U UUS9nU[        R                  :X  a  SR                  " U6 $ U[        R                  :X  a  SR                  U5      $ SR                  [        USS95      $ )a  
Convert a single RGB pixel into an ANSI escape sequence representing that pixel.

Arguments:
    pixel   -- (r,g,b) tuple representing the pixel. Each pixel is an 8 bit value, in the range [0, 255].

Keyword Arguments:
    ctype   -- the color depth to use, default color_types.color256
    palette -- if not using the truecolor depth, adjust how pixels map to the desired colourspace to match the colourscheme better.
r   r)   z[48;2;{};{};{}m  z[48;5;{}m  z[{}m  Tr   r   r.   r3   r   r4   r   )r   r   r)   colors       r   get_ansi_pixelr   6  sp      E
 %%%&--u55$$$ ''../TBCCr   c                      g)z9
Get the ANSI escape sequence to return color to normal.
z[0mr    r    r   r   get_reset_coder   N  s     r   c                    [        U UUS9n[        UUUS9nU[        R                  :X  a  SR                  " / UQUQ76 $ U[        R                  :X  a  SR                  XE5      $ [        USS9n[        USS9nSR                  Xg5      $ )a/  
Convert two RGB pixels into an ANSI escape sequence representing those pixel using unicode.

Arguments:
    top_pixel   -- (r,g,b) tuple representing the top pixel. Each pixel is an 8 bit value, in the range [0, 255].
    bottom_pixel   -- (r,g,b) tuple representing the bottom pixel. Each pixel is an 8 bit value, in the range [0, 255].

Keyword Arguments:
    ctype   -- the color depth to use, default color_types.color256
    palette -- if not using the truecolor depth, adjust how pixels map to the desired colourspace to match the colourscheme better.
r   u#   [48;2;{};{};{}m[38;2;{};{};{}m▄u   [48;5;{}m[38;5;{}m▄Tr   Fu   [{}m[{}m▄r   )	top_pixelbottom_pixelr   r)   	color_topcolor_bottombg_codepointfg_codepoints           r   get_dual_unicode_ansi_pixelsr   U  s     $I
 'L %%%:AA 

%
 	
 $$$.55iNN#IT:L#L>L ''CCr   c                 ~   U R                   nU R                  nXQ-  nUn[        Xg-  5      nU(       a  XfS-  -  nO
US-  nUS-  nU R                  XV45      n [	        5       n[        [        U5      5      n	U	 H  n
[        U5       He  nU R                  X45      nU(       a0  U R                  XS-   45      nUR                  [        XX4S95        ML  UR                  [        XUS95        Mg     UR                  SR                  [        5       5      5        U(       d  M  [        U	S 5        M     UR                  5       $ )Nr1   r0   r   z{}
)widthheightr\   resizer   iterrangegetpixelwriter   r   r   r   nextgetvalue)imgoWidth
is_unicoder(   r)   	destWidth
destHeightscale
ansi_buildyityxpix
bottom_pixs                 r   _toAnsir  z  s*   		IJEIZ()J 1n$
 	a	q
 **i,
-CJ
uZ 
!Cy!A,,v&C \\1!e*5
  0z   w!WX " 	~'789:dO% (   r   )ior   r^   	functoolsr   	lru_cacher,   r.   r%   palettesr4   r5   r6   r$   rZ   r   r   r   r   r   r  )pals   0r   <module>r     s     	 	 S!- "- :z	 999x8xt)x8h7hsdh7\?@
$ &1%9%99 (* !, 4 4i D0 $/#7#7"DJ+!Y :87s   C,C
	C#