§
    ³[6gªI  ã                   óÚ   — 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 dlmZ  G d„ de¦  «        Z e¦   «         Zd„ Zd	Zed
z   Zd„ Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd„ ZdS )é    N)ÚPath)Úvalidate_coerce_fig_to_dictÚvalidate_coerce_output_type)Ú
get_module)ÚImageUriValidatorc                   ód   — e Zd ZdZd„ Zed„ ¦   «         Zej        d„ ¦   «         Zed„ ¦   «         Z	dS )Ú
JsonConfig)ÚjsonÚorjsonÚautoc                 ó   — d| _         d S )Nr   ©Ú_default_engine©Úselfs    úN/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/plotly/io/_json.pyÚ__init__zJsonConfig.__init__   s   € Ø%ˆÔÐÐó    c                 ó   — | j         S ©Nr   r   s    r   Údefault_enginezJsonConfig.default_engine   s   € àÔ#Ð#r   c                 óÀ   — |t           j        vr.t          d                     t           j        |¬¦  «        ¦  «        ‚|dk    r|                      ¦   «          || _        d S )Nz9Supported JSON engines include {valid}
    Received {val})ÚvalidÚvalr   )r	   Ú_valid_enginesÚ
ValueErrorÚformatÚvalidate_orjsonr   )r   r   s     r   r   zJsonConfig.default_engine   sg   € à•jÔ/Ð/Ð/Ýð%ß%+¢Vµ*Ô2KÐQT VÑ%UÔ%Uñô ð ð
 �(Š?ˆ?Ø× Ò Ñ"Ô"Ð"à"ˆÔÐÐr   c                 óF   — t          d¦  «        }|€t          d¦  «        ‚d S )Nr   z-The orjson engine requires the orjson package)r   r   )Úclsr   s     r   r   zJsonConfig.validate_orjson%   s*   € å˜HÑ%Ô%ˆØˆ>ÝÐLÑMÔMÐMð ˆ>r   N)
Ú__name__Ú
__module__Ú__qualname__r   r   Úpropertyr   ÚsetterÚclassmethodr   © r   r   r	   r	      s‚   € € € € € Ø/€Nð&ð &ð &ð ð$ð $ñ „Xð$ð Ôð
#ð 
#ñ Ôð
#ð ðNð Nñ „[ðNð Nð Nr   r	   c                 ó   — | dv rdS | S )zM
    This is used to ultimately *encode* into strict JSON, see `encode`

    )ÚInfinityz	-InfinityÚNaNNr'   )Úconsts    r   Úcoerce_to_strictr,   /   s   € ð Ð0Ð0Ð0Øˆtàˆr   ))ú<z\u003c)ú>z\u003e)ú/z\u002f))u   â€¨z\u2028)u   â€©z\u2029c                 óN   — | }|D ]\  }}||v r|                      ||¦  «        }Œ |S r   )Úreplace)Újson_strÚ_swapÚoutÚunsafe_charÚ	safe_chars        r   Ú_safer7   F   s?   € Ø
€CØ"'ð 6ð 6Ñˆ�YØ˜#ÐÐØ—+’+˜k¨9Ñ5Ô5ˆCøØ€Jr   Fc                 ó’  — t          dd¬¦  «        }|€t          j        }|dk    r|�d}nd}n|dvrt          d|z  ¦  «        ‚t          d	d
¬¦  «        t          dd
¬¦  «        t          dd
¬¦  «        t          dd
¬¦  «        dœ}|dk    r<i }|rd|d<   nd|d<   ddlm} t          t          j        | fd|i|¤Žt          ¦  «        S |dk    røt                               ¦   «          |j        |j        z  }|r
||j        z  }	 |                      ¦   «         } n# t           $ r Y nw xY w	 t          |                     | |¬¦  «                             d¦  «        t$          ¦  «        S # t&          $ r Y nw xY wt)          | dd|¬¦  «        }t          |                     ||¬¦  «                             d¦  «        t$          ¦  «        S dS )aÉ  
    Convert a plotly/Dash object to a JSON string representation

    Parameters
    ----------
    plotly_object:
        A plotly/Dash object represented as a dict, graph_object, or Dash component

    pretty: bool (default False)
        True if JSON representation should be pretty-printed, False if
        representation should be as compact as possible.

    engine: str (default None)
        The JSON encoding engine to use. One of:
          - "json" for an engine based on the built-in Python json module
          - "orjson" for a faster engine that requires the orjson package
          - "auto" for the "orjson" engine if available, otherwise "json"
        If not specified, the default engine is set to the current value of
        plotly.io.json.config.default_engine.

    Returns
    -------
    str
        Representation of input object as a JSON string

    See Also
    --------
    to_json : Convert a plotly Figure to JSON with validation
    r   T©Úshould_loadNr   r
   ©r   r
   úInvalid json engine: %szsage.allFÚnumpyÚpandasz	PIL.Image)Úsage_allÚnpÚpdÚimageé   Úindent)ú,ú:Ú
separatorsr   )ÚPlotlyJSONEncoderr    )ÚoptionÚutf8)Únumpy_allowedÚdatetime_allowedÚmodules)r   Úconfigr   r   Ú_plotly_utils.utilsrH   r7   r
   ÚdumpsÚ
_swap_jsonr	   r   ÚOPT_NON_STR_KEYSÚOPT_SERIALIZE_NUMPYÚOPT_INDENT_2Úto_plotly_jsonÚAttributeErrorÚdecodeÚ_swap_orjsonÚ	TypeErrorÚclean_to_json_compatible)Úplotly_objectÚprettyÚenginer   rM   ÚoptsrH   Úcleaneds           r   Úto_json_plotlyr`   N   sV  € õ< ˜¨dÐ3Ñ3Ô3€Fð €~ÝÔ&ˆà�ÒÐØÐØˆFˆFàˆFˆFØ	Ð)Ð	)Ð	)ÝÐ2°VÑ;Ñ<Ô<Ð<õ ˜z°uÐ=Ñ=Ô=Ý˜¨eÐ4Ñ4Ô4Ý˜¨uÐ5Ñ5Ô5Ý˜K°UÐ;Ñ;Ô;ð	ð €Gð �ÒÐØˆØð 	,ØˆD�‰NˆNð ",ˆD�Ñà9Ð9Ð9Ð9Ð9Ð9åÝŒJ�}ÐDÐDÐ*;ÐD¸tÐDÐDÅjñ
ô 
ð 	
ð 
�8Ò	Ð	Ý×"Ò"Ñ$Ô$Ð$ØÔ&¨Ô)CÑCˆàð 	(Ø�FÔ'Ñ'ˆDð	Ø)×8Ò8Ñ:Ô:ˆMˆMøÝð 	ð 	ð 	ØˆDð	øøøð	ÝØ—’˜]°4�Ñ8Ô8×?Ò?ÀÑGÔGÍñô ð øõ ð 	ð 	ð 	ØˆDð	øøøõ +ØØØ!Øð	
ñ 
ô 
ˆõ �V—\’\ '°$�\Ñ7Ô7×>Ò>¸vÑFÔFÍÑUÔUÐUð7 
Ð	s$   ÄD Ä
D&Ä%D&Ä*<E' Å'
E4Å3E4Tc                 ó¨   — t          | |¦  «        }|r/|                     dg ¦  «        D ]}|                     dd¦  «         Œt          |||¬¦  «        S )a¢  
    Convert a figure to a JSON string representation

    Parameters
    ----------
    fig:
        Figure object or dict representing a figure

    validate: bool (default True)
        True if the figure should be validated before being converted to
        JSON, False otherwise.

    pretty: bool (default False)
        True if JSON representation should be pretty-printed, False if
        representation should be as compact as possible.

    remove_uids: bool (default True)
        True if trace UIDs should be omitted from the JSON representation

    engine: str (default None)
        The JSON encoding engine to use. One of:
          - "json" for an engine based on the built-in Python json module
          - "orjson" for a faster engine that requires the orjson package
          - "auto" for the "orjson" engine if available, otherwise "json"
        If not specified, the default engine is set to the current value of
        plotly.io.json.config.default_engine.

    Returns
    -------
    str
        Representation of figure as a JSON string

    See Also
    --------
    to_json_plotly : Convert an arbitrary plotly graph_object or Dash component to JSON
    ÚdataÚuidN)r\   r]   )r   ÚgetÚpopr`   )ÚfigÚvalidater\   Úremove_uidsr]   Úfig_dictÚtraces          r   Úto_jsonrk   ®   sg   € õN +¨3°Ñ9Ô9€Hð ð #Ø—\’\ &¨"Ñ-Ô-ð 	#ð 	#ˆEØ�IŠI�e˜TÑ"Ô"Ð"Ð"å˜(¨6¸&ÐAÑAÔAÐAr   c                 óp  — t          | ||||¬¦  «        }t          |t          ¦  «        rt          |¦  «        }nt          |t          ¦  «        r|}nd}|€K	 |                     |¦  «         dS # t
          $ r Y nw xY wt          d                     |¬¦  «        ¦  «        ‚|                     |¦  «         dS )a+  
    Convert a figure to JSON and write it to a file or writeable
    object

    Parameters
    ----------
    fig:
        Figure object or dict representing a figure

    file: str or writeable
        A string representing a local file path or a writeable object
        (e.g. a pathlib.Path object or an open file descriptor)

    pretty: bool (default False)
        True if JSON representation should be pretty-printed, False if
        representation should be as compact as possible.

    remove_uids: bool (default True)
        True if trace UIDs should be omitted from the JSON representation

    engine: str (default None)
        The JSON encoding engine to use. One of:
          - "json" for an engine based on the built-in Python json module
          - "orjson" for a faster engine that requires the orjson package
          - "auto" for the "orjson" engine if available, otherwise "json"
        If not specified, the default engine is set to the current value of
        plotly.io.json.config.default_engine.
    Returns
    -------
    None
    )rg   r\   rh   r]   NzX
The 'file' argument '{file}' is not a string, pathlib.Path object, or file descriptor.
)Úfile)	rk   Ú
isinstanceÚstrr   ÚwriterV   r   r   Ú
write_text)rf   rm   rg   r\   rh   r]   r2   Úpaths           r   Ú
write_jsonrs   à   sð   € õH Ø�h v¸;Èvðñ ô €Hõ �$�ÑÔð 	å�D‰zŒzˆˆÝ	�D�$Ñ	Ô	ð àˆˆð ˆð €|ð	Ø�JŠJ�xÑ Ô Ð ØˆFøÝð 	ð 	ð 	ØˆDð	øøøåðç
‚FØð ñ ô ñ
ô 
ð 	
ð 	�Š˜Ñ!Ô!Ð!Ð!Ð!s   ÁA. Á.
A;Á:A;c                 ó  — t          dd¬¦  «        }t          | t          t          f¦  «        s1t	          d                     t          | ¦  «        | ¬¦  «        ¦  «        ‚|€t          j        }|dk    r|�d}nd}n|d	vrt	          d
|z  ¦  «        ‚|dk    r/t           
                    ¦   «          |                     | ¦  «        }n>t          | t          ¦  «        r|                      d¦  «        } t          j        | ¦  «        }|S )aß  
    Parse JSON string using the specified JSON engine

    Parameters
    ----------
    value: str or bytes
        A JSON string or bytes object

    engine: str (default None)
        The JSON decoding engine to use. One of:
          - if "json", parse JSON using built in json module
          - if "orjson", parse using the faster orjson module, requires the orjson
            package
          - if "auto" use orjson module if available, otherwise use the json module

        If not specified, the default engine is set to the current value of
        plotly.io.json.config.default_engine.

    Returns
    -------
    dict

    See Also
    --------
    from_json_plotly : Parse JSON with plotly conventions into a dict
    r   Tr9   zr
from_json_plotly requires a string or bytes argument but received value of type {typ}
    Received value: {value})ÚtypÚvalueNr   r
   r;   r<   zutf-8)r   rn   ro   Úbytesr   r   ÚtyperN   r   r	   r   ÚloadsrW   r
   )rv   r]   r   Ú
value_dicts       r   Úfrom_json_plotlyr{   ,  s  € õ6 ˜¨dÐ3Ñ3Ô3€Fõ �e�c¥5˜\Ñ*Ô*ð 
Ýðç%švÝ˜‘K”K uð  &ñ  ô  ñ
ô 
ð 	
ð €~ÝÔ&ˆà�ÒÐØÐØˆFˆFàˆFˆFØ	Ð)Ð	)Ð	)ÝÐ2°VÑ;Ñ<Ô<Ð<à�ÒÐÝ×"Ò"Ñ$Ô$Ð$à—\’\ %Ñ(Ô(ˆ
ˆ
õ �e�UÑ#Ô#ð 	*Ø—L’L Ñ)Ô)ˆEÝ”Z Ñ&Ô&ˆ
àÐr   ÚFigurec                 ó`   — t          | |¬¦  «        }t          |¦  «        } |||¬¦  «        }|S )a®  
    Construct a figure from a JSON string

    Parameters
    ----------
    value: str or bytes
        String or bytes object containing the JSON representation of a figure

    output_type: type or str (default 'Figure')
        The output figure type or type name.
        One of:  graph_objs.Figure, 'Figure', graph_objs.FigureWidget, 'FigureWidget'

    skip_invalid: bool (default False)
        False if invalid figure properties should result in an exception.
        True if invalid figure properties should be silently ignored.

    engine: str (default None)
        The JSON decoding engine to use. One of:
          - if "json", parse JSON using built in json module
          - if "orjson", parse using the faster orjson module, requires the orjson
            package
          - if "auto" use orjson module if available, otherwise use the json module

        If not specified, the default engine is set to the current value of
        plotly.io.json.config.default_engine.

    Raises
    ------
    ValueError
        if value is not a string, or if skip_invalid=False and value contains
        invalid figure properties

    Returns
    -------
    Figure or FigureWidget
    )r]   )Úskip_invalid)r{   r   )rv   Úoutput_typer~   r]   ri   r    rf   s          r   Ú	from_jsonr€   m  sA   € õP   ¨fÐ5Ñ5Ô5€Hõ & kÑ
2Ô
2€Cð ˆ#ˆh \Ð
2Ñ
2Ô
2€CØ€Jr   c                 ó&  — t          | t          ¦  «        }t          | t          ¦  «        rt          | ¦  «        }nt          | t          ¦  «        r| }nd}|�|                     ¦   «         }n|                      ¦   «         }t          ||||¬¦  «        S )aŽ  
    Construct a figure from the JSON contents of a local file or readable
    Python object

    Parameters
    ----------
    file: str or readable
       A string containing the path to a local file or a read-able Python
       object (e.g. a pathlib.Path object or an open file descriptor)

    output_type: type or str (default 'Figure')
        The output figure type or type name.
        One of:  graph_objs.Figure, 'Figure', graph_objs.FigureWidget, 'FigureWidget'

    skip_invalid: bool (default False)
        False if invalid figure properties should result in an exception.
        True if invalid figure properties should be silently ignored.

    engine: str (default None)
        The JSON decoding engine to use. One of:
          - if "json", parse JSON using built in json module
          - if "orjson", parse using the faster orjson module, requires the orjson
            package
          - if "auto" use orjson module if available, otherwise use the json module

        If not specified, the default engine is set to the current value of
        plotly.io.json.config.default_engine.

    Returns
    -------
    Figure or FigureWidget
    N)r~   r   r]   )rn   ro   r   Ú	read_textÚreadr€   )rm   r   r~   r]   Úfile_is_strrr   r2   s          r   Ú	read_jsonr…   ¡  s›   € õJ ˜T¥3Ñ'Ô'€KÝ�$�ÑÔð 	å�D‰zŒzˆˆÝ	�D�$Ñ	Ô	ð àˆˆð ˆð ÐØ—>’>Ñ#Ô#ˆˆà—9’9‘;”;ˆõ Ø˜|¸ÈVðñ ô ð r   c                 óö	  ‡— t          | t          t          t          f¦  «        r| S t          | t          ¦  «        r ˆfd„|                      ¦   «         D ¦   «         S t          | t          t          f¦  «        r| rˆfd„| D ¦   «         S ‰                     dd¦  «        }‰                     dd¦  «        }‰                     di ¦  «        }|d         }|d         }|d	         }|d
         }|�0| |j	        v rt          | ¦  «        S | |j
        v rt          | ¦  «        S |�� | |j        j        j        u rt          d¦  «        S t          | |j        ¦  «        r¥|r#| j        j        dv r|                     | ¦  «        S | j        j        dk    r'|                     | ¦  «                             ¦   «         S | j        j        dk    r|                      ¦   «         S | j        j        dk    r|                      ¦   «         } n$t          | |j        ¦  «        rt          | ¦  «        S |��a| |j        u rd S t          | |j        |j        f¦  «        �r9|r(| j        j        dv r|                     | j        ¦  «        S | j        j        dk    rÿt          | |j        ¦  «        r„t3          j        ¦   «         5  t3          j        dt8          ¦  «         |                     | j                             ¦   «         ¦  «                             ¦   «         }	d d d ¦  «         n# 1 swxY w Y   n&|                      ¦   «                              ¦   «         }	|s<tA          tC          |	¦  «        ¦  «        D ]}
|	|
          "                    ¦   «         |	|
<   Œ |	S 	 |                      ¦   «         } n# tF          tH          f$ r Y nw xY w|s,	 |  "                    ¦   «         S # tF          tH          f$ r Y n w xY wt          | tJ          j%        ¦  «        r| S 	 |                      ¦   «         S # tH          $ r Y nw xY wt          | tL          j'        ¦  «        rt          | ¦  «        S |�)t          | |j(        ¦  «        rtS          j*        | ¦  «        S 	 |  +                    ¦   «         } n# tH          $ r Y nw xY wt          | t          ¦  «        r ˆfd„|                      ¦   «         D ¦   «         S t          | t          t          f¦  «        r| rˆfd„| D ¦   «         S | S )Nc                 ó2   •— i | ]\  }}|t          |fi ‰¤Ž“ŒS r'   ©rZ   ©Ú.0ÚkÚvÚkwargss      €r   ú
<dictcomp>z,clean_to_json_compatible.<locals>.<dictcomp>é  ó0   ø€ ÐQÐQÐQ¹T¸QÀ�Õ+¨AÐ8Ð8°Ð8Ð8ÐQÐQÐQr   c                 ó*   •— g | ]}t          |fi ‰¤Ž‘ŒS r'   rˆ   ©rŠ   rŒ   r�   s     €r   ú
<listcomp>z,clean_to_json_compatible.<locals>.<listcomp>í  ó*   ø€ ÐGÐGÐG¸aÕ,¨QÐ9Ð9°&Ð9Ð9ÐGÐGÐGr   rK   FrL   rM   r?   r@   rA   rB   Únan)ÚbÚiÚuÚfÚMÚUÚOÚignorec                 ó2   •— i | ]\  }}|t          |fi ‰¤Ž“ŒS r'   rˆ   r‰   s      €r   rŽ   z,clean_to_json_compatible.<locals>.<dictcomp>R  r�   r   c                 ó*   •— g | ]}t          |fi ‰¤Ž‘ŒS r'   rˆ   r‘   s     €r   r’   z,clean_to_json_compatible.<locals>.<listcomp>V  r“   r   ),rn   ÚintÚfloatro   ÚdictÚitemsÚlistÚtuplerd   ÚRRÚZZÚmaÚcoreÚmaskedÚndarrayÚdtypeÚkindÚascontiguousarrayÚdatetime_as_stringÚtolistÚ
datetime64ÚNaTÚSeriesÚDatetimeIndexÚvaluesÚwarningsÚcatch_warningsÚsimplefilterÚFutureWarningÚarrayÚdtÚto_pydatetimeÚrangeÚlenÚ	isoformatrY   rV   ÚdatetimeÚdecimalÚDecimalÚImager   Úpil_image_to_urirU   )Úobjr�   rK   rL   rM   r?   r@   rA   rB   Ú	dt_valuesr–   s    `         r   rZ   rZ   à  s…  ø€ õ
 �#��U¥CÐ(Ñ)Ô)ð Øˆ
å�#•tÑÔð HØQÐQÐQÐQÀSÇYÂYÁ[Ä[ÐQÑQÔQÐQÝ	�C�$¥˜Ñ	'Ô	'ð HØð 	HàGÐGÐGÐGÀ3ÐGÑGÔGÐGð —J’J˜°Ñ6Ô6€MØ—z’zÐ"4°eÑ<Ô<Ðà�jŠj˜ BÑ'Ô'€GØ�zÔ"€HØ	�Œ€BØ	�Œ€BØ�GÔ€Eð ÐØ�(”+ÐÐÝ˜‘:”:ÐØ�H”KÐÐÝ�s‘8”8ˆOð 
�~Ø�"”%”*Ô#Ð#Ð#Ý˜‘<”<ÐÝ˜˜RœZÑ(Ô(ð 	Øð 	# ¤¤Ð3GÐ!GÐ!GØ×+Ò+¨CÑ0Ô0Ð0Ø”” 3Ò&Ð&à×,Ò,¨SÑ1Ô1×8Ò8Ñ:Ô:Ð:Ø”” 3Ò&Ð&Ø—z’z‘|”|Ð#Ø”” 3Ò&Ð&à—j’j‘l”l�øÝ˜˜Rœ]Ñ+Ô+ð 	Ý�s‘8”8ˆOð 
�~Ø�"”&ˆ=ˆ=Ø�4Ý˜˜bœi¨Ô)9Ð:Ñ;Ô;ñ 	!Øð ! ¤¤Ð3GÐ!GÐ!GØ×+Ò+¨C¬JÑ7Ô7Ð7Ø”” 3Ò&Ð&Ý˜c 2¤9Ñ-Ô-ð =Ý!Ô0Ñ2Ô2ð Nð NÝ Ô-¨h½ÑFÔFÐFð %'§H¢H¨S¬V×-AÒ-AÑ-CÔ-CÑ$DÔ$D×$KÒ$KÑ$MÔ$M˜	ð	Nð Nð Nñ Nô Nð Nð Nð Nð Nð Nð Nøøøð Nð Nð Nð Nøð !$× 1Ò 1Ñ 3Ô 3× :Ò :Ñ <Ô <�Ià'ð @õ #¥3 y¡>¤>Ñ2Ô2ð @ð @˜Ø'0°¤|×'=Ò'=Ñ'?Ô'?˜	 !™˜à Ð ðð ×ÒÑ!Ô!ˆˆøÝ•~Ð&ð ð ð Øˆðøøøð ð ð	Ø—=’=‘?”?Ð"øÝ�>Ð*ð 	ð 	ð 	ØˆDð	øøøå	�C�Ô*Ñ	+Ô	+ð Øˆ
ðØ�zŠz‰|Œ|ÐøÝð ð ð Øˆðøøøõ �#•w”Ñ'Ô'ð Ý�S‰zŒzÐð Ð�Z¨¨U¬[Ñ9Ô9ÐÝ Ô1°#Ñ6Ô6Ð6ðØ× Ò Ñ"Ô"ˆˆøÝð ð ð Øˆðøøøõ �#•tÑÔð HØQÐQÐQÐQÀSÇYÂYÁ[Ä[ÐQÑQÔQÐQÝ	�C�$¥˜Ñ	'Ô	'ð HØð 	HàGÐGÐGÐGÀ3ÐGÑGÔGÐGà€Js[   Ê+ALÌLÌLÎN ÎN,Î+N,Î2O ÏOÏOÏ:P Ð
PÐPÑ3R Ò
RÒR)FN)TFTNr   )r|   FN)r
   rÀ   r¿   rµ   Úpathlibr   Úplotly.io._utilsr   r   Ú_plotly_utils.optional_importsr   Ú_plotly_utils.basevalidatorsr   Úobjectr	   rN   r,   rQ   rX   r7   r`   rk   rs   r{   r€   r…   rZ   r'   r   r   ú<module>rË      s˜  ðØ €€€Ø €€€Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð à UÐ UÐ UÐ UÐ UÐ UÐ UÐ UØ 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø :Ð :Ð :Ð :Ð :Ð :ð
Nð Nð Nð Nð N�ñ Nô Nð Nð< 
ˆ‰Œ€ð	ð 	ð 	ð€
ð
 ð ñ €ðð ð ð]Vð ]Vð ]Vð ]Vð@/Bð /Bð /Bð /BðdI"ð I"ð I"ð I"ðX>ð >ð >ð >ðB1ð 1ð 1ð 1ðh<ð <ð <ð <ð~xð xð xð xð xr   