
    hhY                         d dl Z d dlmZ d dlmZmZmZ d dlmZ ddZ	 G d	 d
e
          Z G d de          ZddZd Zd ZdS )    N)PrettyPrinter)NotEncodablePlotlyJSONEncoder
get_module)image_array_to_data_uri      P   c           
          t          | t                    rd\  }}n:t          | t                    rd\  }}nt          dt	          |           z            t          |           |k    r| }n4t          | d|                   dgz   t          | | d                   z   }|d                    d |D                       z   |z   }d                    t          j        ||d	|d
z   z  d	|d
z   z                      	                                }	|	S )a  
    Return a string representation for of a list where list is elided if
    it has more than n elements

    Parameters
    ----------
    v : list
        Input list
    threshold :
        Maximum number of elements to display

    Returns
    -------
    str
    )[])()zInvalid value of type: %sNz...z, c                 ,    g | ]}t          |          S  )str).0es     C/var/www/histauto/venv/lib/python3.11/site-packages/plotly/utils.py
<listcomp>z%_list_repr_elided.<locals>.<listcomp>%   s    ":":":a3q66":":":    
    )widthinitial_indentsubsequent_indent)

isinstancelisttuple
ValueErrortypelenjointextwrapwrapstrip)
v	threshold	edgeitemsindentr   	open_char
close_chardisp_vv_str	v_wrappeds
             r   _list_repr_elidedr1   	   s,     !T @ (	::	Au		 @ (	::4tAww>???
1vva

m$$w.a
n1E1EE		":":6":":":;;;jHE		&1*-!VaZ0		
 	
 	
  egg  r   c                   4    e Zd ZdZd Zed             Zd ZdS )ElidedWrapperz
    Helper class that wraps values of certain types and produces a custom
    __repr__() that may be elided and is suitable for use during pretty
    printing
    c                 0    || _         || _        || _        d S N)r(   r+   r)   )selfr(   r)   r+   s       r   __init__zElidedWrapper.__init__9   s    "r   c                    t          d          }t          | t          t          f          r0t	          |           dk    rt          | d         t
                    sdS |rt          | |j                  rdS t          | t                    rdS dS )Nnumpyr   TF)r   r   r   r    r#   dictndarrayr   )r(   r9   s     r   is_wrappablezElidedWrapper.is_wrappable>   s    7##a$'' 	CFFQJJz!A$PT?U?UJ4 	z!U]33 	43 	45r   c           
      T   t          d          }t          | j        t          t          f          r#t          | j        | j        | j                  }|S |rt          | j        |j                  r|	                                } |j
        di t          || j        dd           | j                                        }|                    d          }dd| j        z  z                       |          } |j
        di | |S t          | j        t                    rst!          | j                  dk    rBdt#          | j        d d	                   z   d
z   t#          | j        dd                    z   dz   S | j                                        S | j                                        S )Nr9   )r)   r+   r	   r
   )r)   r*   	linewidthr   r   r      z ... ir   r   )r   r   r(   r   r    r1   r)   r+   r;   get_printoptionsset_printoptionsr:   __repr__splitr$   r   r#   repr)r6   r9   res	orig_opts	res_liness        r   rB   zElidedWrapper.__repr__J   s   7##dftUm,, !	%#$.  C J 	%z$&%-88 	% ..00I #E"  yDNaSUVVV   &//##C 		$I#++11)<<C #E"//Y///J$$ 	%46{{RT$&"+...84stt;M;MMPSSSv(((6??$$$r   N)__name__
__module____qualname____doc__r7   staticmethodr<   rB   r   r   r   r3   r3   2   sW         # # #
 	 	 \	#% #% #% #% #%r   r3   c                       e Zd ZdZd Zd ZdS )ElidedPrettyPrinterzF
    PrettyPrinter subclass that elides long lists/arrays/strings
    c                 f    |                     dd          | _        t          j        | g|R i | d S )Nr)   r   )popr)   r   r7   )r6   argskwargss      r   r7   zElidedPrettyPrinter.__init__u   s>    K55t5d555f55555r   c           	          t                               |          r0t          || j        |          }|                     ||||||          S t	          j        | ||||||          S r5   )r3   r<   r)   _formatr   )r6   valstreamr+   	allowancecontextlevel
elided_vals           r   rT   zElidedPrettyPrinter._formaty   sl    %%c** 	&sDNFCCJ<<
FFIwPUVVV (c669gu  r   N)rH   rI   rJ   rK   r7   rT   r   r   r   rN   rN   p   s<         6 6 6    r   rN   r   c              #      K   t          | t                    sdS | |fV  |                                 D ]5\  }}t          |t                    rt          |||fz             D ]}|V  6dS )a  
    General, node-yielding generator.

    Yields (node, path) tuples when it finds values that are dict
    instances.

    A path is a sequence of hashable values that can be used as either keys to
    a mapping (dict) or indices to a sequence (list). A path is always wrt to
    some object. Given an object, a path explains how to get from the top level
    of that object to a nested value in the object.

    :param (dict) node: Part of a dict to be traversed.
    :param (tuple[str]) path: Defines the path of the current node.
    :return: (Generator)

    Example:

        >>> for node, path in node_generator({'a': {'b': 5}}):
        ...     print(node, path)
        {'a': {'b': 5}} ()
        {'b': 5} ('a',)

    N)r   r:   itemsnode_generator)nodepathkeyrU   items        r   r]   r]      s      0 dD!! 
*JJLL  Sc4   	&sDC6M::  



 r   c                      |D ]
}| |         } | S )aR  
    Iteratively get on obj for each key in path.

    :param (list|dict) obj: The top-level object.
    :param (tuple[str]|tuple[int]) path: Keys to access parts of obj.

    :return: (*)

    Example:

        >>> figure = {'data': [{'x': [5]}]}
        >>> path = ('data', 0, 'x')
        >>> get_by_path(figure, path)
        [5]
    r   )objr_   r`   s      r   get_by_pathrd      s#        #hJr   c                     t          | t                    r~t          |           D ]m\  }}t          |t          t          f          rt	          |          | |<   4t          |t
                    r$	 t          |          | |<   ]# t          $ r Y iw xY wnnt          | t                    rt          |                                           t          |                                           }}t          ||          D ]\  }}t          |t          t          f          rt	          |          | |<   n9t          |t
                    r$	 t          |          | |<   n# t          $ r Y nw xY w| 
                    |          | t          |          <   | S r5   )r   r   	enumerater:   decode_unicoder   UnicodeEncodeErrorkeysvaluesziprP   )collnoentryri   valsr`   rU   s          r   rg   rg      s   $ +"4 	 	IB%$.. )%00ReS)) #&u::R-   		 
D$		 
+$))++&&T[[]](;(;dD$ 	+ 	+HC#d|,, *3//S		C%%  #CDII)   D!XXc]]DSNNKs$   /B
BBE
E%$E%)r   r	   r   r
   )r   )r%   pprintr   _plotly_utils.utilsr   r   r   _plotly_utils.data_utilsr   r1   objectr3   rN   r]   rd   rg   r   r   r   <module>rt      s                 K K K K K K K K K K < < < < < <& & & &R;% ;% ;% ;% ;%F ;% ;% ;%|    -   (   B  *    r   