U
    TZf                     @   sB   d dl Z d dlmZ d dlmZ dd Zdd Ze fddZdS )	    N)get_plotlyjs_versionc                 C   st   ddl m} t| |r |  }nPt| trF|r@tj|  }qp| }n*t	| drZ|  }nt
djt| | d|S )Nr   )
BaseFigureto_plotly_jsonzR
The fig parameter must be a dict or Figure.
    Received value of type {typ}: {v})typv)Zplotly.basedatatypesr   
isinstanceZto_dictdictplotly
graph_objsFigurer   hasattr
ValueErrorformattype)Zfigvalidater   Zfig_dict r   4/tmp/pip-unpacked-wheel-5ksk5baj/plotly/io/_utils.pyvalidate_coerce_fig_to_dict   s     




 r   c                 C   sJ   | dks| t jkrt j}n,| dks6tt dr>| t jkr>t j}ntd|S )Nr   FigureWidgetzP
Invalid output type: {output_type}
    Must be one of: 'Figure', 'FigureWidget')gor   r   r   r   )output_typeclsr   r   r   validate_coerce_output_type   s    r   c                 C   s   dj | dS )zReturn a valid plotly CDN url.z+https://cdn.plot.ly/plotly-{cdn_ver}.min.jsZcdn_ver)r   r   r   r   r   plotly_cdn_url.   s    r   )	r	   Zplotly.graph_objsr
   r   Zplotly.offliner   r   r   r   r   r   r   r   <module>   s
   