
    Mh                         d Z ddlZddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z dZdZ ej        d          Z ej        d	d
           dZdZdZdZdZdZdZed         Zd Zd ZdS )z%Utilities to manipulate JSON objects.    N)
b2a_base64)datedatetime)version_info__next__z%Y-%m-%dT%H:%M:%S.%fzJ^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(\.\d{1,6})?Z?([\+\-]\d{2}:?\d{2})?$1z%ds   PNG

s	   iVBORw0KGs   s   /9s   R0lGODdhs   R0lGODlhs   JVBERc                     | S )a  b64-encodes images in a displaypub format dict

    Perhaps this should be handled in json_clean itself?

    Parameters
    ----------
    format_dict : dict
        A dictionary of display data keyed by mime-type

    Returns
    -------
    format_dict : dict
        A copy of the same dictionary,
        but binary image data ('image/png', 'image/jpeg' or 'application/pdf')
        is base64-encoded.

     )format_dicts    R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/ipykernel/jsonutil.pyencode_imagesr   4   s
    ,     c                    t          t                    dk    r| S t          t          d          f}t          t
          t          j        f}t          | t                    r| S t          | t          j                  rt          |           S t          | t          j                  rFt          j        |           st          j        |           rt!          |           S t#          |           S t          | |          r| S t          | t$                    r"t'          |                               d          S t          | |          s%t+          | d          r$t+          | t,                    rt/          |           } t          | t.                    rd | D             S t          | t0                    rt3          |           }t3          t          t5          t          |                               }||k    rd}t7          |          i }|                                 D ]$\  }}t;          |          |t          |          <   %|S t          | t<          t>          f          r|                      tB                    S t7          d| z            )a  Deprecated, this is a no-op for jupyter-client>=7.

    Clean an object to ensure it's safe to encode in JSON.

    Atomic, immutable objects are returned unmodified.  Sets and tuples are
    converted to lists, lists are copied and dicts are also copied.

    Note: dicts whose keys could cause collisions upon encoding (such as a dict
    with both the number 1 and the string '1' as keys) will cause a ValueError
    to be raised.

    Parameters
    ----------
    obj : any python object

    Returns
    -------
    out : object
        A version of the input which will not cause an encoding error when
        encoded as JSON.  Note that this function does not *encode* its inputs,
        it simply sanitizes it so that there will be no encoding errors later.

       Nascii__iter__c                 ,    g | ]}t          |          S r
   )
json_clean).0xs     r   
<listcomp>zjson_clean.<locals>.<listcomp>   s    +++!
1+++r   zSdict cannot be safely converted to JSON: key collision would lead to dropped valueszCan't clean for JSON: %r)"intJUPYTER_CLIENT_MAJOR_VERSIONstrtypetuplesettypesGeneratorType
isinstanceboolnumbersIntegralRealmathisnanisinfreprfloatbytesr   decodehasattrnext_attr_namelistdictlenmap
ValueErroritemsr   r   r   strftimeISO8601)	obj	atomic_okcontainer_to_listnkeysnkeys_collapsedmsgoutkvs	            r   r   r   M   sN   0 '((A--
 d4jj!I U%89
 #t 
#w'(( 3xx#w|$$ :c?? 	djoo 	99Szz#y!! 
#u / #%%g...#()) Z  %,S.%A%A 3ii#t ,++s++++#t  Cc#c3--0011O##=  S//!IIKK 	( 	(DAq$Q--CAKK
#$'(( %||G$$$ /#5
6
66r   )__doc__r%   r"   rer   binasciir   r   r   jupyter_client._versionr   jupyter_client_versionr-   r5   compileISO8601_PATstrptimePNGPNG64JPEGJPEG64GIF_64GIF89_64PDF64r   r   r   r
   r   r   <module>rN      s   + +
   				        # # # # # # # # J J J J J J !bjQ   #t    		5a8   2V7 V7 V7 V7 V7r   