
    d                     0    d dl mZ 	 	 	 	 	 ddZd Zd ZdS )   )spec_to_htmlNc                 (   |dk    rt          d          |dv rt          | ||fd|i|S |dk    rt          | f||||d|}d|iS |dk    r.|t          d	          d
                    |d                   | iS |dk    rd| iS t          d          )at  Convert a vega-lite specification to a mimebundle

    The mimebundle type is controlled by the ``format`` argument, which can be
    one of the following ['html', 'json', 'png', 'svg', 'pdf', 'vega', 'vega-lite']

    Parameters
    ----------
    spec : dict
        a dictionary representing a vega-lite plot spec
    format : string {'html', 'json', 'png', 'svg', 'pdf', 'vega', 'vega-lite'}
        the file format to be saved.
    mode : string {'vega-lite'}
        The rendering mode.
    vega_version : string
        The version of vega.js to use
    vegaembed_version : string
        The version of vegaembed.js to use
    vegalite_version : string
        The version of vegalite.js to use. Only required if mode=='vega-lite'
    engine: string {'vl-convert', 'altair_saver'}
        the conversion engine to use for 'png', 'svg', 'pdf', and 'vega' formats
    **kwargs :
        Additional arguments will be passed to the generating function

    Returns
    -------
    output : dict
        a mime-bundle representing the image

    Note
    ----
    The png, svg, pdf, and vega outputs require the altair_saver package
    z	vega-litezmode must be 'vega-lite')pngsvgpdfvegaenginehtml)modevega_versionvegaembed_versionvegalite_versionz	text/htmlNzMust specify vegalite_versionz!application/vnd.vegalite.v{}+json    jsonzapplication/jsonzPformat must be one of ['html', 'json', 'png', 'svg', 'pdf', 'vega', 'vega-lite'])
ValueError_spec_to_mimebundle_with_enginer   format)	specr   r   r   r   r   r	   kwargsr
   s	            7lib/python3.11/site-packages/altair/utils/mimebundle.pyspec_to_mimebundler      s   V {3444....&$
 
'-
17
 
 	
 
%/-
 
 
 
 T""#<===3::;KA;NOOQUVV"D))
	E      c                    |                     dd          }t          ||          }|dk    rddl}ddlm} d                    |                    d          dd                   }|d	k    r|                    | |
          }	d|	iS |dk    r|                    | |
          }
d|
iS |dk    r0|	                    | ||
                    dd                    }d|iS t          d                    |                    |dk    rddl} |j        | |fd|i|S t          d                    |                    )a   Helper for Vega-Lite to mimebundle conversions that require an engine

    Parameters
    ----------
    spec : dict
        a dictionary representing a vega-lite plot spec
    format : string {'png', 'svg', 'pdf', 'vega'}
        the format of the mimebundle to be returned
    mode : string {'vega-lite'}
        The rendering mode.
    engine: string {'vl-convert', 'altair_saver'}
        the conversion engine to use
    **kwargs :
        Additional arguments will be passed to the conversion function
    r	   N	vlconvertr      )SCHEMA_VERSION_.r   )
vl_versionzapplication/vnd.vega.v5+jsonr   zimage/svg+xmlr   scale_factorg      ?)r   scalez	image/pngzUnexpected format {fmt!r}fmtaltairsaverr   z$Unexpected normalized_engine {eng!r})eng)pop_validate_normalize_engine
vl_convertvegaliter   joinsplitvegalite_to_vegavegalite_to_svgvegalite_to_pnggetr   r   altair_saverrender)r   r   r   r   r	   normalized_enginevlcr   r   vgr   r   r0   s                r   r   r   L   s   $ ZZ$''F266BBK''    ------ XXn22377;<<
V%%dz%BBB2B77u__%%dz%BBC#S))u__%%%jj55 &  C
  %% 8??F?KKLLL	m	+	+"|"4EEdEfEEE 299>O9PP
 
 	
r   c                    	 ddl }n# t          $ r d}Y nw xY w	 ddl}n# t          $ r d}Y nw xY w| dn;|                                                     dd                              dd          }|dk    r;|t          d          |dk    r#t          d	                    |
                    n|dk    r|t          d          n|\|	|dk    rd}nu|d}np|dk    r#t          d                    |
                    t          d                    |
                    t          d                    | d                    |S )zHelper to validate and normalize the user-provided engine

    engine : {None, 'vl-convert', 'altair_saver'}
        the user-provided engine string
    format : string {'png', 'svg', 'pdf', 'vega'}
        the format of the mimebundle to be returned
    r   N- r   r   zIThe 'vl-convert' conversion engine requires the vl-convert-python packager   zmThe 'vl-convert' conversion engine does not support the {fmt!r} format.
Use the 'altair_saver' engine insteadr"   r$   zFThe 'altair_saver' conversion engine requires the altair_saver packagezqSaving charts in {fmt!r} format requires the altair_saver package: see http://github.com/altair-viz/altair_saver/zSaving charts in {fmt!r} format requires the vl-convert-python or altair_saver package: see http://github.com/altair-viz/altair_saver/z?Invalid conversion engine {engine!r}. Expected one of {valid!r})z
vl-convertr0   )r	   valid)r(   ImportErrorr0   lowerreplacer   r   )r	   r   r3   r0   r2   s        r   r'   r'      s              
 FLLNN$:$:3$C$C$K$KCQS$T$T 
 K'';[   U??88>68J8J   
 
m	+	+X     
	"?v +% - EEKVPVVEWEW  
 !EEKVPVVEWEW  
 MTT%C U  
 
 	

 s     ..)NNNNN)r
   r   r   r   r'    r   r   <module>r=      sj          
E E E EP6
 6
 6
r? ? ? ? ?r   