
    PiPI                       U d Z ddlmZ ddlmZmZmZmZ ddlZddl	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ e
rdd
lmZ eeef         ee         z  Zded<    ed          Z ed          ZdPdZdQdRdZ	 dSdTd$Z	 dSdUd&Z 	 	 	 	 	 dVdWd/Z!	 dXdYd5Z"dZd8Z#d[d\d9Z$	 	 	 	 d]d^dCZ%d_dHZ& G dI dJe'eef                   Z( G dK dL          Z) G dM dNe)          Z*d`dOZ+dS )az
Printing tools.
    )annotations)CallableIterableMappingSequenceN)TYPE_CHECKINGAny	TypeAliasTypeVar)east_asian_width)
get_option)is_sequence)get_console_size)ListLiker
   EscapeChars_KT_VTspaceintlists	list[str]kwargsr	   returnstrc           	     t    |                     dt                    |                     dt                    }g } fd|dd         D             }|                    t	          t          t          |d                                        t	          t          t          |                    }t          |          D ]P\  }} ||||         d          }	d||         z  g|t          |          z
  z  |	z   }	|                    |	           Qt          |d	d
i}
d                    d |
D                       S )a  
    Glues together two sets of strings using the amount of space requested.
    The idea is to prettify.

    ----------
    space : int
        number of spaces for padding
    lists : str
        list of str which being joined
    strlen : callable
        function used to calculate the length of each str. Needed for unicode
        handling.
    justfunc : callable
        function used to justify str. Needed for unicode handling.
    strlenjustfuncc                P    g | ]"}t          t          |                    z   #S  )maxmap).0xr   r   s     n/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/io/formats/printing.py
<listcomp>zadjoin.<locals>.<listcomp>7   s.    ???qs3vq>>""U*???    Nleft)mode strictT
c              3  @   K   | ]}d                      |          V  dS ) N)join)r"   liness     r$   	<genexpr>zadjoin.<locals>.<genexpr>@   s,      88RWWU^^888888r&   )	poplen_adj_justifyappendr    r!   	enumeratezipr/   )r   r   r   r   newListslengthsmaxLenilstnltoJoinr   s   `          @r$   adjoinr?   #   s5     ZZ#&&Fzz*l33HH?????E#2#J???GNN3s3b	**++,,,S%!!FE""  3Xc71:F333WQZ FSXX$56"<((4((F9988888888r&   righttextsIterable[str]max_lenr)   c                p    |dk    rfd| D             S |dk    rfd| D             S fd| D             S )zB
    Perform ljust, center, rjust against string or list-like
    r(   c                :    g | ]}|                               S r   ljustr"   r#   rC   s     r$   r%   z _adj_justify.<locals>.<listcomp>H   %    000Q  000r&   centerc                :    g | ]}|                               S r   rJ   rH   s     r$   r%   z _adj_justify.<locals>.<listcomp>J   s%    111a!!111r&   c                :    g | ]}|                               S r   rjustrH   s     r$   r%   z _adj_justify.<locals>.<listcomp>L   rI   r&   r   )rA   rC   r)   s    ` r$   r4   r4   C   sg     v~~0000%0000			1111511110000%0000r&   seqr   	_nest_lvlmax_seq_items
int | Nonekwdsc                L   t          | t                    rd}n,t          | t                    rd}nt          | d          rdnd}|du rd}n |pt	          d          pt          |           }t          |           }g }d}t          |          D ]7\  }	}
|
|	|k    rd	} n'|                    t          |
|d
z   fd|i|           8d
                    |          }|r|dz  }n-t          | t                    rt          |           d
k    r|dz  }|                    |          S )z
    internal. pprinter for iterables. you should probably use pprint_thing()
    rather than calling this directly.

    bounds length of printed sequence, depending on options
    z
{{{body}}}zfrozenset({{{body}}})__setitem__z[{body}]z({body})FNrR   T   , , ...,)body)
isinstanceset	frozensethasattrr   r3   iterr6   r5   pprint_thingr/   tupleformat)rP   rQ   rR   rT   fmt	max_itemssrmax_items_reachedr;   itemr[   s               r$   _pprint_seqrj   g   sY    #s H	C	#	# H%#C77GjjZ		!LZ%@%@LCHH	S		A
AQ<< Y Y4!Y $E	dIMWWWRVWWXXXX99Q<<D 	C		 CHHMM::4:   r&   r   c                <   d}g }d}|du rt          |           }n |pt          d          pt          |           }t          |                                           d|         D ]Q\  }}	|                    |                    t          ||dz   fd|i|t          |	|dz   fd|i|                     R|t          |           k     r,|                    d                    |          d	z   
          S |                    d                    |          
          S )zy
    internal. pprinter for iterables. you should probably use pprint_thing()
    rather than calling this directly.
    z{{{things}}}z{key}: {val}FrR   NrW   )keyvalrX   rY   )things)r3   r   listitemsr5   rc   ra   r/   )
rP   rQ   rR   rT   rd   pairspfmtnitemskvs
             r$   _pprint_dictrv      s;    CEDSI*_"="=ISSYY[[!!'6'* 
 
1KK IMWWWRVWW IMWWWRVWW   	
 	
 	
 	
 Czz5!1!1G!;z<<<zz5!1!1z222r&   Fthingobjectescape_charsEscapeChars | Nonedefault_escapesboolquote_stringsc                   |fdfd}t          | d          rt          |           S t          | t                    r'|t	          d	          k     rt          | |d
|          }nit          |           r(|t	          d	          k     rt          | ||||          }n2t          | t                    r|rd ||            d}n ||           }|S )a3  
    This function is the sanctioned way of converting objects
    to a string representation and properly handles nested sequences.

    Parameters
    ----------
    thing : anything to be formatted
    _nest_lvl : internal use only. pprint_thing() is mutually-recursive
        with pprint_sequence, this argument is used to keep track of the
        current nesting level, and limit it.
    escape_chars : list[str] or Mapping[str, str], optional
        Characters to escape. If a Mapping is passed the values are the
        replacements
    default_escapes : bool, default False
        Whether the input escape characters replaces or adds to the defaults
    max_seq_items : int or None, default None
        Pass through to other pretty printers to limit sequence printing

    Returns
    -------
    str
    rw   r	   ry   rz   r   r   c                    ddddd}t          |t                    r<r|                    |           n|}t          |                                          }n|pd}t          |           }|D ]}|                    |||                   }|S )Nz\tz\nz\rz\')	r,   'r   )r\   r   updatero   keysr   replace)rw   ry   	translateresultcr{   s        r$   as_escaped_stringz'pprint_thing.<locals>.as_escaped_string   s     !UGG	lG,, 	. )  ....(	 1 1 3 344LL'-2LU 	5 	5A^^Ay|44FFr&   __next__zdisplay.pprint_nest_depthT)r}   rR   ry   r}   rR   r   )rw   r	   ry   rz   r   r   )r_   r   r\   r   r   rv   r   rj   )rw   rQ   ry   r{   r}   rR   r   r   s      `    r$   ra   ra      s5   @ 8D      $ uj!! *5zz	E7	#	# *	J#5 5 ) ) 9D
 
 
 
U		 *	J7R,S,S S S %''	
 	
 	
 
E3		 *M *0&&u--000""5))Mr&   utf-8r   encodingerrorsbytesc                L    t          |           }|                    ||          S N)ra   encode)rx   r   r   values       r$   pprint_thing_encodedr      s%       E<<&)))r&   enableNonec                   dt           j        vrd S ddlm}  |            }|d S |j        j        }d}| r<||vr)ddlm} ddlm	  G fdd|          } |            ||<   d	||         _
        d S ||v rd
||         _
        d S d S )NIPythonr   )get_ipythonz!application/vnd.dataresource+json)BaseFormatter
ObjectNamec                  ,    e Zd Z  d          ZefZdS )<enable_data_resource_formatter.<locals>.TableSchemaFormatter_repr_data_resource_N)__name__
__module____qualname__print_methoddict_return_typer   s   r$   TableSchemaFormatterr     s&        )z*@AA $wr&   r   TF)sysmodulesr   r   display_formatter
formattersIPython.core.formattersr   	traitletsr   enabled)r   r   ipr   mimetyper   r   r   s          @r$   enable_data_resource_formatterr     s   ######## 
B	z%0J2H -:%%======,,,,,,' ' ' ' ' ' '} ' ' '
 $8#7#9#9Jx '+
8$$$	Z		',
8$$$ 
 	r&   c                (    t          | dd|          S )N)r   r   r,   Tr   ra   )rw   rR   s     r$   default_pprintr   #  s%    '#	   r&   Tobj	formatterr   
is_justifyname
str | Noneindent_for_nameline_break_each_valuec                |   ! t                      \  }}|t          d          pd}|t          |           j        }|r&t	          |          }dd|dz   z   }	dd|dz   z   }
nd}	d}
t	          |           }|rd	dt	          |          z  z   }nd
}t          d          p|}||k    }t                      d+fd}d,fd}d}|dk    rd| }n|dk    r|s | d                   }d| d| }n|dk    r1|s/ | d                   } | d                   }d| d| d| }n|dk    rg }fd| dd         D             }nW||k    rAt          |dz  d           }fd!| d|         D             }fd"| | d         D             }ng }fd#| D             }|r|rt          ||          \  }}n|sLt	          d                    |                    |k     r&t	          d                    |                    |k     s>t           ||           ||                    !!fd$|D             }!fd%|D             }|r|t	          |
          z
  }|d         }d t          t          dt	          |          dz                       D ]*}t          ||&          }t	          |          |k     r|  n+ fd'|D             } fd(|D             }d)}|
}|D ]}||z   dz   } ||||||
          \  }}|r||                                |
z   d*z   z  }|
}|dd         D ]}||z   dz   } ||||||
          \  }} ||||d         |dz
  |
          \  }}||z  }d|                    d          z   }||z  }t	          |          |k    s|r||	z  }n|dz  }d|t	          |
          d         z   }|S )-a  
    Return the formatted obj as a unicode string

    Parameters
    ----------
    obj : object
        must be iterable and support __getitem__
    formatter : callable
        string formatter for an element
    is_justify : bool
        should justify the display
    name : name, optional
        defaults to the class name of the obj
    indent_for_name : bool, default True
        Whether subsequent lines should be indented to
        align with the name.
    line_break_each_value : bool, default False
        If True, inserts a line break for each value of ``obj``.
        If False, only break lines when the a line of values gets wider
        than the display width.

    Returns
    -------
    summary string
    Nzdisplay.widthP   r,   r*   rW      z
 z,
 rZ   zdisplay.max_seq_itemsrf   r   liner   display_widthr   next_line_prefixr   tuple[str, str]c                                         |                                                               |                                          z   |k    r| |                                z  } |}||z  }| |fS r   )r3   rstrip)rf   r   r   r   r   adjs        r$   _extend_linez+format_object_summary.<locals>._extend_linej  sf     774;;==!!CGGELLNN$;$;;}LLA#D$wr&   valuesr   c                B    | rt          fd| D                       S dS )Nc              3  B   K   | ]}                     |          V  d S r   r3   )r"   r#   r   s     r$   r1   z:format_object_summary.<locals>.best_len.<locals>.<genexpr>u  s-      22aswwqzz222222r&   r   r    )r   r   s    r$   best_lenz'format_object_summary.<locals>.best_lens  s3     	222262222221r&   rX   r   z[][]r'   c                &    g | ]} |          S r   r   r"   r#   r   s     r$   r%   z)format_object_summary.<locals>.<listcomp>  !    333QIIaLL333r&   
   c                &    g | ]} |          S r   r   r   s     r$   r%   z)format_object_summary.<locals>.<listcomp>  s!    222QIIaLL222r&   c                &    g | ]} |          S r   r   r   s     r$   r%   z)format_object_summary.<locals>.<listcomp>  r   r&   c                &    g | ]} |          S r   r   r   s     r$   r%   z)format_object_summary.<locals>.<listcomp>  s!    ...QIIaLL...r&   c                :    g | ]}|                               S r   rN   r"   r#   
max_lengths     r$   r%   z)format_object_summary.<locals>.<listcomp>  %    :::
++:::r&   c                :    g | ]}|                               S r   rN   r   s     r$   r%   z)format_object_summary.<locals>.<listcomp>  r   r&   rR   c                2    g | ]}t          |           S r   rj   r"   r#   re   s     r$   r%   z)format_object_summary.<locals>.<listcomp>  &    JJJK;;;JJJr&   c                2    g | ]}t          |           S r   r   r   s     r$   r%   z)format_object_summary.<locals>.<listcomp>  r   r&   r.   z...)rf   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   typer   r3   get_adjustmentmin_justifyr/   r    reversedrangerj   r   )"r   r   r   r   r   r   r   _name_lenspace1space2nseprR   is_truncatedr   r   closesummaryfirstlastheadtail	max_spacer   	num_itemspprinted_seqr   
head_valueword	tail_itemr   re   r   s"    `                             @@@r$   format_object_summaryr   ,  sT   B ())M1"?339r|Cyy! t99.shl+...shl+..CA  sSYY&677<1M }$L 

C           EAvvu,,	
a-	#a&!!%e%%e%%	
a-	#a&!!yR!!-e--t--e--AD3333#bcc(333DDMQ&++A2222#bqb'222D3333#qbcc(333DDD....#...D  	;$ ; &dD11
dd ;DIIdOO$$}44		$((=88 !$$@@
::::T:::::::T::: ! 	K
 &F3IGEI%eAs5zzA~&>&>??  	*5	JJJ|$$y00 )IE 1 KJJJTJJJDJJJJTJJJD 	U 	UJ#c)D(L$mVTTMGTT 	t{{}}v-55GDcrc 	U 	UIs?S(D(L$mVTTMGTT %WdDHma>OQWXX4 ell3'''5w<<=))-B)vGGsNG F..Nr&   r   list[Sequence[str]]r   3tuple[list[tuple[str, ...]], list[tuple[str, ...]]]c                    | |z   }dgt          |d                   z  |D ]*}d |D             }d t          |d          D             +fd| D             }fd|D             }||fS )a  
    Justify items in head and tail, so they are right-aligned when stacked.

    Parameters
    ----------
    head : list-like of list-likes of strings
    tail : list-like of list-likes of strings

    Returns
    -------
    tuple of list of tuples of strings
        Same as head and tail, but items are right aligned when stacked
        vertically.

    Examples
    --------
    >>> _justify([["a", "b"]], [["abc", "abcd"]])
    ([('  a', '   b')], [('abc', 'abcd')])
    r   c                ,    g | ]}t          |          S r   r   )r"   ri   s     r$   r%   z_justify.<locals>.<listcomp>  s    222#d))222r&   c                4    g | ]\  }}t          ||          S r   r   )r"   r#   ys      r$   r%   z_justify.<locals>.<listcomp>  s$    QQQDAqc!QiiQQQr&   Tr+   c           
     b    g | ]+}t          d  t          |d          D                       ,S )c              3  F   K   | ]\  }}|                     |          V  d S r   rN   rH   s      r$   r1   z&_justify.<locals>.<listcomp>.<genexpr>  2      SS:1gagggSSSSSSr&   Tr  rb   r7   r"   rP   r   s     r$   r%   z_justify.<locals>.<listcomp>  O        	SSS*T1R1R1RSSSSS  r&   c           
     b    g | ]+}t          d  t          |d          D                       ,S )c              3  F   K   | ]\  }}|                     |          V  d S r   rN   rH   s      r$   r1   z&_justify.<locals>.<listcomp>.<genexpr>  r  r&   Tr  r  r  s     r$   r%   z_justify.<locals>.<listcomp>  r  r&   )r3   r7   )r   r   combined	inner_seqlengthhead_tuplestail_tuplesr   s          @r$   r   r     s    , d{H s8A;'''J R R	22	222QQC
F4,P,P,PQQQ

     K     K ##r&   c                      e Zd ZdZddZdS )
PrettyDictz.Dict extension to support abbreviated __repr__r   r   c                     t          |           S r   r   selfs    r$   __repr__zPrettyDict.__repr__  s    D!!!r&   N)r   r   )r   r   r   __doc__r  r   r&   r$   r  r    s.        88" " " " " "r&   r  c                  0    e Zd ZddZddZdddZddZdS )_TextAdjustmentr   r   c                .    t          d          | _        d S )Nzdisplay.encoding)r   r   r  s    r$   __init__z_TextAdjustment.__init__
  s    "#566r&   textr   r   c                     t          |          S r   r   r  r  s     r$   r3   z_TextAdjustment.len  s    4yyr&   r@   rA   r	   rC   r)   r   c                p    |dk    rfd|D             S |dk    rfd|D             S fd|D             S )zJ
        Perform ljust, center, rjust against string or list-like
        r(   c                :    g | ]}|                               S r   rF   rH   s     r$   r%   z+_TextAdjustment.justify.<locals>.<listcomp>  %    444AGGG$$444r&   rJ   c                :    g | ]}|                               S r   rL   rH   s     r$   r%   z+_TextAdjustment.justify.<locals>.<listcomp>  s%    555!AHHW%%555r&   c                :    g | ]}|                               S r   rN   rH   s     r$   r%   z+_TextAdjustment.justify.<locals>.<listcomp>  r  r&   r   )r  rA   rC   r)   s     ` r$   justifyz_TextAdjustment.justify  sg     6>>4444e4444X5555u55554444e4444r&   r   r   r   c                <    t          |g|R | j        | j        d|S )N)r   r   )r?   r3   r"  )r  r   r   r   s       r$   r?   z_TextAdjustment.adjoin  s+    eVeVVDHt|VVvVVVr&   Nr   r   r  r   r   r   r@   )rA   r	   rC   r   r)   r   r   r   )r   r   r   r	   r   r	   r   r   )r   r   r   r  r3   r"  r?   r   r&   r$   r  r  	  so        7 7 7 7   	5 	5 	5 	5 	5W W W W W Wr&   r  c                  4     e Zd Zd fdZddZ	 dddZ xZS )_EastAsianTextAdjustmentr   r   c                    t                                                       t          d          rd| _        nd| _        dddddd| _        d S )Nz!display.unicode.ambiguous_as_wider   rW   )NaNWFH)superr  r   ambiguous_width_EAW_MAP)r  	__class__s    r$   r  z!_EastAsianTextAdjustment.__init__   sX    9:: 	%#$D  #$D 
  !qqqqAAr&   r  r   r   c                     t          |t                    st          |          S t           fd|D                       S )zN
        Calculate display width considering unicode East Asian Width
        c              3  r   K   | ]1}j                             t          |          j                  V  2d S r   )r1  getr   r0  )r"   r   r  s     r$   r1   z/_EastAsianTextAdjustment.len.<locals>.<genexpr>3  sR       
 
MNDM.q1143GHH
 
 
 
 
 
r&   )r\   r   r3   sumr  s   ` r$   r3   z_EastAsianTextAdjustment.len,  s[     $$$ 	t99 
 
 
 
RV
 
 
 
 
 	
r&   r@   rA   rB   rC   r)   r   c                     d fd|dk    rfd|D             S |dk    rfd	|D             S fd
|D             S )Ntr   r   r   c                T                         |           z
  t          |           z   S r   r   )r8  rC   r  s    r$   _get_padz2_EastAsianTextAdjustment.justify.<locals>._get_pad;  s#    TXXa[[(3q6611r&   r(   c                L    g | ] }|                      |                    !S r   rF   r"   r#   r:  s     r$   r%   z4_EastAsianTextAdjustment.justify.<locals>.<listcomp>?  -    888QAGGHHQKK((888r&   rJ   c                L    g | ] }|                      |                    !S r   rL   r<  s     r$   r%   z4_EastAsianTextAdjustment.justify.<locals>.<listcomp>A  s-    999aAHHXXa[[))999r&   c                L    g | ] }|                      |                    !S r   rN   r<  s     r$   r%   z4_EastAsianTextAdjustment.justify.<locals>.<listcomp>C  r=  r&   )r8  r   r   r   r   )r  rA   rC   r)   r:  s   ` ` @r$   r"  z _EastAsianTextAdjustment.justify7  s    	2 	2 	2 	2 	2 	2 	2 6>>8888%8888X9999599998888%8888r&   r$  r%  r&  rA   rB   rC   r   r)   r   r   r   )r   r   r   r  r3   r"  __classcell__)r2  s   @r$   r(  r(    sv        
B 
B 
B 
B 
B 
B	
 	
 	
 	
 ?F9 9 9 9 9 9 9 9 9r&   r(  c                 \    t          d          } | rt                      S t                      S )Nz display.unicode.east_asian_width)r   r(  r  )use_east_asian_widths    r$   r   r   F  s1    %&HII !')))   r&   )r   r   r   r   r   r	   r   r   r&  r@  )r   N)
rP   r   rQ   r   rR   rS   rT   r	   r   r   )
rP   r   rQ   r   rR   rS   rT   r	   r   r   )r   NFFN)rw   rx   rQ   r   ry   rz   r{   r|   r}   r|   rR   rS   r   r   )r   r   )rx   rx   r   r   r   r   r   r   )r   r|   r   r   r   )rw   r	   rR   rS   r   r   )TNTF)r   r   r   r   r   r|   r   r   r   r|   r   r|   r   r   )r   r   r   r   r   r   )r   r  ),r  
__future__r   collections.abcr   r   r   r   r   typingr   r	   r
   r   unicodedatar   pandas._configr   pandas.core.dtypes.inferencer   pandas.io.formats.consoler   pandas._typingr   r   r   __annotations__r   r   r?   r4   rj   rv   ra   r   r   r   r   r   r   r  r  r(  r   r   r&   r$   <module>rM     s'     # " " " " "            


            ) ( ( ( ( ( % % % % % % 4 4 4 4 4 4 6 6 6 6 6 6 ('''''' c*Xc]: : : : :genngenn9 9 9 9@	1 	1 	1 	1 	1J DH%! %! %! %! %!R CG3 3 3 3 3B '+! $I I I I IZ <E* * * * *- - - -D      "'h h h h hV($ ($ ($ ($V" " " " "c3h " " "W W W W W W W W,$9 $9 $9 $9 $9 $9 $9 $9N! ! ! ! ! !r&   