
    #Yh|                       U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZ ddlmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZ ddlZddlmc mZ dd	lm Z m!Z! dd
l"m#Z# ddl$m%Z%m&Z&m'Z' ej(        dk    rddlm)Z)m*Z*m+Z+ n
ddl,m)Z)m*Z*m+Z+ ej(        dk    r	ddlm-Z-m.Z. nddl,m-Z-m.Z. erddlZ/ddl0Z1ddl"m2Z2 ddl3m4Z5 ddl6m7Z8  ede#          Z9 ed          Z: e.d          Z; ed          Z< e*dede<f         e<f          Z= e*dee;e<f         e;e<f          Z> e*dde:e<f          Z? e*dee-e:e;f         e<f         e:e;e<f          Z@e+ G d d e)                      ZAd!d"d#dd$d%ZBd& eBC                                D             ZDg d'ZEg d(ZFg d)ZG eH ejI         eJeB           eJeD                              ZKd*d+L                    d,M                    eK                    d-d.d/L                    d,M                    eE                    d0L                    d,M                    eEeFz                       d1L                    d,M                    eG                    d2ZN eOd3          ZPd4eQd5<   dvd:ZRdwd=ZSdxd@ZTdydDZUdzdGZVd{dIZWd|dLZX	 	 	 	 	 d}d~dVZYddZZZdd]Z[e	 dddc            Z\edde            Z\	 dddfZ\dddhZ]edi         Z^djeQdk<   	  G dl dj          Z_dm Z`ddqZadduZbdS )zUtility routines.    )annotationsN)IteratorMappingMutableMapping)deepcopy)groupby)
itemgetter)TYPE_CHECKINGAnyCallableLiteralTypeVarcastoverload)is_pandas_dataframeis_polars_dataframe)IntoDataFrame)
SchemaBase
SchemaLike	Undefined)      )ProtocolTypeAliasTyperuntime_checkable)r   
   )Concatenate	ParamSpec)IntoExpr)	DataFrame)StandardType_TTIntoDataFrame)boundTPR	WrapsFunc.)type_paramsWrappedFuncWrapsMethodz Callable[Concatenate[T, ...], R]WrappedMethodc                      e Zd Z	 d
ddZd	S )DataFrameLikeFTnan_as_nullbool
allow_copyreturnDfiDataFramec                    d S N )selfr.   r0   s      YD:\DownLoads\facial_attendance_system-main\venv311\Lib\site-packages\altair/utils/core.py__dataframe__zDataFrameLike.__dataframe__>   s    s    N)FT)r.   r/   r0   r/   r1   r2   )__name__
__module____qualname__r8   r5   r9   r7   r-   r-   <   s3         =A      r9   r-   ONQG)ordinalnominalquantitativetemporalgeojsonc                    i | ]\  }}||	S r5   r5   ).0kvs      r7   
<dictcomp>rJ   K   s    :::TQAq:::r9   )argmaxargminaveragecountdistinctmaxmeanmedianminmissingproductq1q3ci0ci1stderrstdevstdevpsumvalidvaluesvariance	variancepexponentialexponentialb)
row_numberrank
dense_rankpercent_rank	cume_distntilelagleadfirst_value
last_value	nth_value)Qyearquartermonthweekday	dayofyeardatehoursminutessecondsmillisecondsyearquarteryearquartermonth	yearmonthyearmonthdateyearmonthdatehoursyearmonthdatehoursminutes yearmonthdatehoursminutessecondsyearweekyearweekdayyearweekdayhoursyearweekdayhoursminutesyearweekdayhoursminutessecondsyeardayofyearquartermonth	monthdatemonthdatehoursmonthdatehoursminutesmonthdatehoursminutessecondsweekdayweeksdayhoursweekdayhoursweekdayhoursminutesweekdayhoursminutessecondsdayhoursdayhoursminutesdayhoursminutessecondshoursminuteshoursminutessecondsminutessecondssecondsmillisecondsutcyear
utcquarterutcmonthutcweekutcdayutcdayofyearutcdateutchours
utcminutes
utcsecondsutcmillisecondsutcyearquarterutcyearquartermonthutcyearmonthutcyearmonthdateutcyearmonthdatehoursutcyearmonthdatehoursminutes#utcyearmonthdatehoursminutessecondsutcyearweekutcyearweekdayutcyearweekdayhoursutcyearweekdayhoursminutes!utcyearweekdayhoursminutessecondsutcyeardayofyearutcquartermonthutcmonthdateutcmonthdatehoursutcmonthdatehoursminutesutcmonthdatehoursminutesseconds
utcweekdayutcweekdayhoursutcweekdayhoursminutesutcweekdayhoursminutessecondsutcdayhoursutcdayhoursminutesutcdayhoursminutessecondsutchoursminutesutchoursminutessecondsutcminutessecondsutcsecondsmillisecondsz(?P<field>.*)z(?P<type>{})|z(?P<aggregate>count)z(?P<op>count)z(?P<aggregate>{})z
(?P<op>{})z(?P<timeUnit>{}))fieldtype	agg_countop_count	aggregate	window_optimeUnit)r   r   r   r   z<frozenset[Literal['field', 'aggregate', 'type', 'timeUnit']]SHORTHAND_KEYSdatar   r1   =InferredVegaLiteType | tuple[InferredVegaLiteType, list[Any]]c                   ddl m}  || d          }|dv rdS |dk    r<t          | d          r,| j        j        r d	| j        j                                        fS |d
v rdS |dv rdS t          j        d| dd           dS )z
    From an array-like input, infer the correct vega typecode.

    ('ordinal', 'nominal', 'quantitative', or 'temporal').

    Parameters
    ----------
    data: Any
    r   )infer_dtypeF)skipna>   mixed-integermixed-integer-floatcomplexintegerfloatingrC   categoricalcatrA   >   bytesmixedstringbooleanunicoder   rB   >   ru   timeperioddatetime	timedelta
datetime64timedelta64rD   z.I don't know how to infer vegalite type from 'z'.  Defaulting to nominal.   
stacklevel)	pandas.api.typesr   hasattrr   ordered
categoriestolistwarningswarn)r   r   typs      r7   infer_vegalite_type_for_pandasr      s     -,,,,,
+d5
)
)
)C
    ~			'$"6"6	48;K	48.557788	Q	Q	Qy	  
 
 z%S % % %	
 	
 	
 	

 yr9   featdict[str, Any]c                      fddD             }	  d                              |            d         }n# t          t          f$ r |}Y nw xY w|S )zf
    Merge properties with geometry.

    * Overwrites 'type' and 'geometry' entries if existing.
    c                "    i | ]}||         S r5   r5   )rG   rH   r   s     r7   rJ   z$merge_props_geom.<locals>.<dictcomp>  s    5551AtAw555r9   r   geometry
properties)updateAttributeErrorKeyError)r   geom
props_geoms   `  r7   merge_props_geomr     s|     6555 4555D\!!$''','

H%    



 s   #5 A
Ageot.MutableMapping[Any, Any]c                   t          |           } | D ]Y}t          t          | |                   j                                      d          r| |                                         | |<   Zt          j        t          j        |                     }|d         dk    rC|d         }t          |          dk    r't          |          D ]\  }}t          |          ||<   n!|d         dk    rt          |          }nd|d}|S )z
    Santize a geo_interface to prepare it for serialization.

    * Make a copy
    * Convert type array or _Array to list
    * Convert tuples to lists (using json.loads/dumps)
    * Merge properties with geometry
    )_Arrayarrayr   FeatureCollectionfeaturesr   Featurer   )r   strr   r:   
startswithr   jsonloadsdumpslen	enumerater   )r   keygeo_dctidxr   s        r7   sanitize_geo_interfacer  "  s	    3--C  ) )tCH~~&''223FGG 	)3x((CH Jtz#//G v---*%w<<!&w// 6 6	T/55	I	%	%"7++$'::Nr9   dtypesubtyper/   c                h    dd l }	 |                    | |          S # t          t          f$ r Y dS w xY w)Nr   F)numpy
issubdtypeNotImplementedError	TypeError)r  r  nps      r7   numpy_is_subtyper  C  sN    }}UG,,,+   uus    11dfpd.DataFramec                  
 ddl 
ddl}|                                 } t          | j        |j                  r$| j                            t                    | _        | j        D ],}t          |t                    sd|d}t          |          -t          | j	        |j
                  rd}t          |          t          | j        |j
                  rd}t          |          
fd}| j                                        D ]T}t          t          |d                   }|d         }t          |          }|dk    rL| |                             t                    }|                    |                                d          | |<   |d	k    rL| |                             t                    }|                    |                                d          | |<   |d
k    r%| |                             t                    | |<   |dk    rM| |                             t                    }|                    |                                d          | |<   W|                    d          r5| |                             d                               dd          | |<   |                    d          rd| d| d}t          |          |                    d          r|dv rM| |                             t                    }|                    |                                d          | |<   6t)          |
j                  r%| |                             t                    | |<   pt)          |
j                  rf| |         }|                                
                    |          z  }	|                    t                                        |	 d          | |<   |t          k    r^| |                             t                                        |          }|                    |                                d          | |<   V| S )a  
    Sanitize a DataFrame to prepare it for serialization.

    * Make a copy
    * Convert RangeIndex columns to strings
    * Raise ValueError if column names are not strings
    * Raise ValueError if it has a hierarchical index.
    * Convert categoricals to strings.
    * Convert np.bool_ dtypes to Python bool objects
    * Convert np.int dtypes to Python int objects
    * Convert floats to objects and replace NaNs/infs with None.
    * Convert DateTime dtypes into appropriate string representations
    * Convert Nullable integers to objects and replace NaN with None
    * Convert Nullable boolean to objects and replace NaN with None
    * convert dedicated string column to objects and replace NaN with None
    * Raise a ValueError for TimeDelta dtypes
    r   Nz(Dataframe contains invalid column name: z. Column names must be stringsz"Hierarchical indices not supportedc                Z    t          | j                  r|                                 S | S r4   )
isinstancendarrayr   )valr  s    r7   to_list_if_arrayz3sanitize_pandas_dataframe.<locals>.to_list_if_arrayx  s*    c2:&& 	::<<Jr9   r   categoryr   r/   r   )r   	timestampc                *    |                                  S r4   )	isoformat)xs    r7   <lambda>z+sanitize_pandas_dataframe.<locals>.<lambda>  s    Q[[]] r9   NaT r   Field "" has type "^" which is not supported by Altair. Please convert to either a timestamp or a numerical value.r   >
   Int8Int16Int32Int64UInt8UInt16UInt32UInt64Float32Float64)r  pandascopyr  columns
RangeIndexastyper  
ValueErrorindex
MultiIndexdtypesitemsr   objectwherenotnullr  applyreplacer  r   r   isnullisinf)r  pdcol_namemsgr  
dtype_itemr  
dtype_namecol
bad_valuesr  s             @r7   sanitize_pandas_dataframerJ  M  s<   ( 	B"*bm,, ,Z&&s++
J " "(C(( 	"/8 / / /  S//!	" "(BM** 2oo"*bm,, 2oo     ioo'' O: O:
 Z]++1ZZ
## X,%%f--C99S[[]]D99BxLL8## X,%%f--C99S[[]]D99BxLL6!!h<..v66BxLL9$$ X,%%f--C99S[[]]D99BxLL""#<== 5	: 8""#:#:;;CCE2NN xLL "";// +	:(       S//!"":.. #	:   X,%%f--C99S[[]]D99BxLLeRZ00 	:h<..v66BxLLeR[11 
	: X,C5J::f--33ZKFFBxLLf__ X,%%f--334DEEC99S[[]]D99BxLIr9   nw.DataFrame[TIntoDataFrame]c                \   | j         }g }d}t          |                                           }|                                D ]V\  }}|t          j        k    r_|r]|                    t	          j        |                              t          j	                  j
                            |                     u|t          j        k    r@|                    t	          j        |          j
                            |                     |t          j	        k    rD|                    t	          j        |          j
                            | d                     |t          j        k    rd| d| d}t          |          |                    |           X|                     |          S )z3Sanitize narwhals.DataFrame for JSON serialization.z%Y-%m-%dT%H:%M:%Sz%.fr%  r&  r'  )schemar   	to_nativer;  nwDateappendrH  r   Datetimedt	to_stringDurationr7  select)r   rM  r4  local_iso_fmt_string	is_polarsnamer  rE  s           r7   sanitize_narwhals_dataframerZ    s    [F G.#DNN$4$455I||~~ ! !eBG	 NNt!!"+..1;;<PQQ    bgNN26$<<?445IJJKKKKbk!!NN26$<<?448L5Q5Q5QRRSSSSbk!!$  E     S//!NN4    ;;wr9   r   nw.DataFrame[Any]c                    t          j        | d          }t          j        |          dk    r'ddlm}  ||           }t          j        |d          }|S )z
    Wrap `data` in `narwhals.DataFrame`.

    If `data` is not supported by Narwhals, but it is convertible
    to a PyArrow table, then first convert to a PyArrow Table,
    and then wrap in `narwhals.DataFrame`.
    Teager_or_interchange_onlyinterchanger   )arrow_table_from_dfi_dataframe)
eager_only)rO  from_native	get_levelaltair.utils.datar`  )r   data_nwr`  pa_tables       r7   to_eager_narwhals_dataframerg    sk     nTTBBBG	|G-- 	EDDDDD11$77.d;;;Nr9   TF	shorthanddict[str, Any] | strIntoDataFrame | Noneparse_aggregatesparse_window_opsparse_timeunitsparse_typesc           	     0    ddl m}  si S g }|r,|                    dg           |                    dg           |r,|                    dg           |                    dg           |r|                    dg           |                    dg           |r%t          t	          j        d	 |D                        }d
 |D             }t           t                    r }	nt           fd|D                       }	d|	v r*t          
                    |	d         |	d                   |	d<   |	ddik    rd|	d<   d|	v r	d|	vrd|	d<   d|	vr ||          r|	d                             dd          }
t          j        |d          }|j        }|
|v r||
         }||
         t          j        t          j        hv rFt#          |                                          r%t'          |                                          |	d<   nt)          |          |	d<   t          |	d         t*                    r"|	d         d         |	d<   |	d         d         |	d<   d|	v rd|	d         v r|	d         |	d                             d          dz
           dk    rt/          d                    |	d                             d          d                   d                    d                    t6                                                              z   dz   dz   d z             |	S )!a 
  
    General tool to parse shorthand values.

    These are of the form:

    - "col_name"
    - "col_name:O"
    - "average(col_name)"
    - "average(col_name):O"

    Optionally, a dataframe may be supplied, from which the type
    will be inferred if not specified in the shorthand.

    Parameters
    ----------
    shorthand : dict or string
        The shorthand representation to be parsed
    data : DataFrame, optional
        If specified and of type DataFrame, then use these values to infer the
        column type if not provided by the shorthand.
    parse_aggregates : boolean
        If True (default), then parse aggregate functions within the shorthand.
    parse_window_ops : boolean
        If True then parse window operations within the shorthand (default:False)
    parse_timeunits : boolean
        If True (default), then parse timeUnits from within the shorthand
    parse_types : boolean
        If True (default), then parse typecodes within the shorthand

    Returns
    -------
    attrs : dict
        a dictionary of attributes extracted from the shorthand

    Examples
    --------
    >>> import pandas as pd
    >>> data = pd.DataFrame({"foo": ["A", "B", "A", "B"], "bar": [1, 2, 3, 4]})

    >>> parse_shorthand("name") == {"field": "name"}
    True

    >>> parse_shorthand("name:Q") == {"field": "name", "type": "quantitative"}
    True

    >>> parse_shorthand("average(col)") == {"aggregate": "average", "field": "col"}
    True

    >>> parse_shorthand("foo:O") == {"field": "foo", "type": "ordinal"}
    True

    >>> parse_shorthand("min(foo):Q") == {
    ...     "aggregate": "min",
    ...     "field": "foo",
    ...     "type": "quantitative",
    ... }
    True

    >>> parse_shorthand("month(col)") == {
    ...     "field": "col",
    ...     "timeUnit": "month",
    ...     "type": "temporal",
    ... }
    True

    >>> parse_shorthand("year(col):O") == {
    ...     "field": "col",
    ...     "timeUnit": "year",
    ...     "type": "ordinal",
    ... }
    True

    >>> parse_shorthand("foo", data) == {"field": "foo", "type": "nominal"}
    True

    >>> parse_shorthand("bar", data) == {"field": "bar", "type": "quantitative"}
    True

    >>> parse_shorthand("bar:O", data) == {"field": "bar", "type": "ordinal"}
    True

    >>> parse_shorthand("sum(bar)", data) == {
    ...     "aggregate": "sum",
    ...     "field": "bar",
    ...     "type": "quantitative",
    ... }
    True

    >>> parse_shorthand("count()", data) == {
    ...     "aggregate": "count",
    ...     "type": "quantitative",
    ... }
    True
    r   )is_data_typez{agg_count}\(\)z{aggregate}\({field}\)z{op_count}\(\)z{window_op}\({field}\)z{timeUnit}\({field}\)z{field}c              3  $   K   | ]}|d z   |fV  dS )z:{type}Nr5   rG   ps     r7   	<genexpr>z"parse_shorthand.<locals>.<genexpr>~  s+      )O)O1y=!*<)O)O)O)O)O)Or9   c           	   3     K   | ]9}t          j        d  |j        di t          z   dz   t           j                  V  :dS )z\Az\ZNr5   )recompileformatSHORTHAND_UNITSDOTALLrr  s     r7   rt  z"parse_shorthand.<locals>.<genexpr>  s`         	
581866o666>	JJ     r9   c              3     K   | ]@}|                               |                                                               V  Ad S r4   )match	groupdict)rG   exprh  s     r7   rt  z"parse_shorthand.<locals>.<genexpr>  sY       
 
yy##/ IIi  **,,////
 
r9   r   r   rN   rC   r   rD   r   \r$  Tr]  r   sort:z"{}" z0is not one of the valid encoding data types: {}.z, zi
For more details, see https://altair-viz.github.io/user_guide/encodings/index.html#encoding-data-types. z>If you are trying to use a column name that contains a colon, zPprefix it with a backslash; for example "column\:name" instead of "column:name".)rd  rp  extendlist	itertoolschainr  dictnextINV_TYPECODE_MAPgetr@  rO  rb  rM  ObjectUnknownr   rN  r    infer_vegalite_type_for_narwhalstuplerfindr7  rx  splitjoinTYPECODE_MAPr_   )rh  r   rk  rl  rm  rn  rp  patternsregexpsattrsunescaped_fieldre  rM  columns   `             r7   parse_shorthandr    s   L /..... 	H 5+,---23444 5*+,,,23444 412333OOZL!!! R	)O)Oh)O)O)OPQQ   G )T"" 
 
 
 
 

 
 
 
 
 (,,U6]E&MJJf g&&&&f UvU22"f U||D11.00r::.FFFf$$_-Fo&	
+   &g&7&7&9&9:: !?v?O?O?Q?Q R Rf @ H Hf%-// 1 %fa 0f %fa 0f
 	55>!!'N5>//44q89TAANN5>//44R899@GG		,--//00  {	{
 OO bb
 
 	
 Lr9   r  	nw.Series8InferredVegaLiteType | tuple[InferredVegaLiteType, list]c                   | j         }t          j        |           rC| j                                        x}                                sd|                                fS |t          j        k    s |t          j        k    s|t          j	        k    rdS |
                                rdS |t          j        k    s|t          j        k    rdS d| }t          |          )NrA   rB   rC   rD   zUnexpected DtypeKind: )r  rO  is_ordered_categoricalr   get_categoriesis_emptyto_listStringCategoricalBoolean
is_numericrR  rP  r7  )r  r  r   rE  s       r7   r  r    s     LE
!&))/%z88:::DDFF/ *,,....	Ubn448K8Ky					 	~	"+		"'!1!1 z.u..oor9   tpCallable[P, Any]c               X     t           dd            }t           dd            }d fd
}|S )a_  
    Use the signature and doc of ``tp`` for the decorated callable ``cb``.

    - **Overload 1**: Decorating method
    - **Overload 2**: Decorating function

    Returns
    -------
    **Adding the annotation breaks typing**:

        Overload[Callable[[WrapsMethod[T, R]], WrappedMethod[T, P, R]], Callable[[WrapsFunc[R]], WrappedFunc[P, R]]]
    cbWrapsMethod[T, R]r1   WrappedMethod[T, P, R]c                   d S r4   r5   r  s    r7   decoratezuse_signature.<locals>.decorate  s    FIcr9   WrapsFunc[R]WrappedFunc[P, R]c                   d S r4   r5   r  s    r7   r  zuse_signature.<locals>.decorate  s    <?Cr9   *WrappedMethod[T, P, R] | WrappedFunc[P, R]c                  t          d          | _        j        x}rQ| j        p
dj         d d}d                    |g|                    d          dd	         R           | _        | S d
}t          |          )z
        Raises when no doc was found.

        Notes
        -----
        - Reference to ``tp`` is stored in ``cb.__wrapped__``.
        - The doc for ``cb`` will have a ``.rst`` link added, referring  to ``tp``.
        __init__zRefer to :class:``
r$  T)keependsr   NzFound no doc for )getattr__wrapped____doc__r:   r  
splitlinesr   )r  doc_inline_1rE  r  s       r7   r  zuse_signature.<locals>.decorate  s     !Z44Z6 	&
H&H"+&H&H&HLLLF&!P6+<+<d+<+K+KABB+O!P!PQQBJI,b,,C %%%r9   )r  r  r1   r  )r  r  r1   r  )r  r  r1   r  )r   )r  r  s   ` r7   use_signaturer    sV     III XI??? X?& & & & & && Or9   originalr   t.Mapping[Any, Any]r3  Literal[False]c                    d S r4   r5   r  r   r3  s      r7   update_nestedr    	    
 "%r9   Literal[True]c                    d S r4   r5   r  s      r7   r  r    r  r9   c                   |rt          |           } |                                D ]d\  }}t          |t                    rE|                     |i           }t          |t
                    rt          ||          | |<   Y|| |<   _|| |<   e| S )a  
    Update nested dictionaries.

    Parameters
    ----------
    original : MutableMapping
        the original (nested) dictionary, which will be updated in-place
    update : Mapping
        the nested dictionary of updates
    copy : bool, default False
        if True, then copy the original dictionary rather than modifying it

    Returns
    -------
    original : MutableMapping
        a reference to the (modified) original dict

    Examples
    --------
    >>> original = {"x": {"b": 2, "c": 4}}
    >>> update = {"x": {"b": 5, "d": 6}, "y": 40}
    >>> update_nested(original, update)  # doctest: +SKIP
    {'x': {'b': 5, 'c': 4, 'd': 6}, 'y': 40}
    >>> original  # doctest: +SKIP
    {'x': {'b': 5, 'c': 4, 'd': 6}, 'y': 40}
    )r   r;  r  r   r  r   r  )r  r   r3  r  r  orig_vals         r7   r  r    s    >  &H%%LLNN    Sc7## 	 ||C,,H(N33 $ -h < < #HSMMOr9   
in_ipythonc                    t          j                    }| rddlm}  |            }nd }||                    |           d S t          j        |  d S )Nr   )get_ipython)sysexc_infoIPython.core.getipythonr  showtraceback	tracebackprint_exception)r  r  r  ips       r7   display_tracebackr  :  sl    |~~H 777777[]]	~
"""""!8,,,,r9   )r   datumvalue_ChannelCache_CHANNEL_CACHEc                  T    e Zd ZU ded<   ded<   edd            Zdd
ZddZddZdS )r  dict[type[SchemaBase], str]channel_to_name/dict[str, dict[_ChannelType, type[SchemaBase]]]name_to_channelr1   c                    	 t           }nS# t          $ rF |                     |           }t                      |_        t          |j                  |_        |a Y nw xY wt           S r4   )r  	NameError__new___init_channel_to_namer  _invert_group_channelsr  )clscacheds     r7   
from_cachez_ChannelCache.from_cacheV  sl    	$#FF 	$ 	$ 	$[[%%F%:%<%<F"%;F<R%S%SF"#NNN		$
 s   
 AAAr  	type[Any]r  c                   | j                             |          x}r|S dt          |          j        }t	          |          )Nzpositional of type )r  r  r   r:   r  )r6   r  encodingrE  s       r7   get_encodingz_ChannelCache.get_encodingb  sI    +//3338 	O9DHH$599!#&&&r9   objr   r  c                   t          |t                    r|S t          |t                    rd|i}nTt          |t          t          f          r fd|D             S t          |t
                    r|                                } j                                      x}r=|d|v rdnd         }	 |	                    |d          S # t          j        $ r |cY S w xY wt          j        dd	           |S )
Nrh  c                <    g | ]}                     |          S r5   )_wrap_in_channel)rG   elr  r6   s     r7   
<listcomp>z2_ChannelCache._wrap_in_channel.<locals>.<listcomp>n  s)    FFFBD))"h77FFFr9   r  r   F)validatezUnrecognized encoding channel r   r   )r  r   r  r  r  r   to_dictr  r  	from_dict
jsonschemaValidationErrorr   r   )r6   r  r  channelr  s   ` `  r7   r  z_ChannelCache._wrap_in_channelh  s)   c:&& 	 JS!! 	 $CCdE]++ 	 FFFFF#FFFFZ(( 	 ++--C*..x8887 	GsNN@B ||C%|888-   


 MG8GGTUVVVVJs   3C
 
CCkwargsr   c               D      fd|                                 D             S )Nc                V    i | ]%\  }}|t           u|                    ||          &S r5   )r   r  )rG   r  r  r6   s      r7   rJ   z6_ChannelCache.infer_encoding_types.<locals>.<dictcomp>  sD     
 
 
#)## d++C::###r9   )r;  )r6   r  s   ` r7   infer_encoding_typesz"_ChannelCache.infer_encoding_types~  s6    
 
 
 
!'
 
 
 	
r9   N)r1   r  )r  r  r1   r  )r  r   r  r  )r  r   )	r:   r;   r<   __annotations__classmethodr  r  r  r  r5   r9   r7   r  r  R  s         0000DDDD	 	 	 [	' ' ' '   ,
 
 
 
 
 
r9   c                     ddl m}  | j        | j        | j        ffd| j                                        D             S )a  
    Construct a dictionary of channel type to encoding name.

    Note
    ----
    The return type is not expressible using annotations, but is used
    internally by `mypy`/`pyright` and avoids the need for type ignores.

    Returns
    -------
        mapping: dict[type[`<subclass of FieldChannelMixin and SchemaBase>`] | type[`<subclass of ValueChannelMixin and SchemaBase>`] | type[`<subclass of DatumChannelMixin and SchemaBase>`], str]
    r   )channelsc                    i | ]D}t          |t                    t          |          't          |t                    <||j        ES r5   )r  r   
issubclassr   _encoding_name)rG   cmixinss     r7   rJ   z)_init_channel_to_name.<locals>.<dictcomp>  sg       a $.a#8#8 >H:=V=V	1  r9   )altair.vegalite.v5.schemar  FieldChannelMixinValueChannelMixinDatumChannelMixin__dict__r_   )chr   s    @r7   r  r    se     988888!2#79MMF   ##%%   r9   mr  r  c                   ddt          |                                 t          d                    }fd|D             S )	z;Grouped inverted index for `_ChannelCache.channel_to_name`.itIterator[tuple[type[Any], str]]r1   r   c                    i }| D ]A\  }}|j         }|                    d          r"|                    d          rd}nd}|||<   B|S )z
        Returns a 1-2 item dict, per channel.

        Never includes `datum`, as it is never utilized in `wrap_in_channel`.
        DatumValuer  r   )r:   endswith)r	  itemr  _rY  sub_keys         r7   _reducez'_invert_group_channels.<locals>._reduce  sj     -/ 	 	EB;D}}W%% "w'' "!!DMMr9   r   c                .    i | ]\  }}| |          S r5   r5   )rG   rH   chansr  s      r7   rJ   z*_invert_group_channels.<locals>.<dictcomp>  s'    666(!UAwwu~~666r9   )r	  r
  r1   r   )r   r;  r	   )r  grouperr  s     @r7   r  r    sP    
   $ aggiiA//G6666g6666r9   argstuple[Any, ...]r  c                ^   t                                           }| D ]}}t          |t          t          f          rt          t          |          d          n|}|                    t          |                    }||vr|||<   id|d}t          |          |
                    |          S )aa  
    Infer typed keyword arguments for args and kwargs.

    Parameters
    ----------
    args : Sequence
        Sequence of function args
    kwargs : MutableMapping
        Dict of function kwargs

    Returns
    -------
    kwargs : dict
        All args and kwargs in a single dict, with keys and types
        based on the channels mapping.
    Nz	encoding z specified twice.)r  r  r  r  r  r  iterr  r   r7  r  )r  r  cacheargr  r  rE  s          r7   r  r    s    " $$&&E " "&0tUm&D&DMT$s))T"""#%%d2hh//6!!"F8;h;;;CS//!%%f---r9   )r   r   r1   r   )r   r   r1   r   )r   r   r1   r   )r  r   r  r   r1   r/   )r  r  r1   r  )r   rK  r1   rK  )r   r   r1   r[  )NTFTT)rh  ri  r   rj  rk  r/   rl  r/   rm  r/   rn  r/   r1   r   )r  r  r1   r  )r  r  ).)r  r   r   r  r3  r  r1   r   )r  r  r   r  r3  r  r1   r   )F)r  r   r   r  r3  r/   r1   r   )T)r  r/   )r  r  r1   r  )r  r  r  r   )cr  
__future__r   r  r  rv  r  r  r   collections.abcr   r   r   r3  r   r   operatorr	   typingr
   r   r   r   r   r   r   r  narwhals.stable.v1stablev1rO  narwhals.stable.v1.dependenciesr   r   narwhals.stable.v1.typingr   altair.utils.schemapir   r   r   version_infor   r   r   typing_extensionsr   r   tr2  rC  r   altair.utils._dfi_typesr    r2   !altair.vegalite.v5.schema._typingr!   InferredVegaLiteTyper"   r$   r%   r&   r'   r)   r*   r+   r-   r  r;  r  
AGGREGATESWINDOW_AGGREGATES	TIMEUNITSr  r  r  VALID_TYPECODESrx  r  ry  	frozensetr   r  r   r   r  r  rJ  rZ  rg  r  r  r  r  r  _ChannelTyper  r  r  r  r5   r9   r7   <module>r2     s      " " " " " "      				 



      = = = = = = = = = =                   Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q              T T T T T T T T 3 3 3 3 3 3 C C C C C C C C C CwAAAAAAAAAAALLLLLLLLLLw---------88888888  Y222222AAAAAAXXXXXX)???GCLLIcNNGCLLM+xQ'7aTJJJ	mM8AqD>1vNNN m5Aq6   Xk!Q$/23!Q  
     H      ;:\%7%7%9%9:::   
:   R R R	h $yttL'9'944@P;Q;QRRSS !!#((?";";<<'$++CHHZ,@,@AA$$SXXj;L.L%M%MNN"))#((9*=*=>>  I899     
- - - -`   $   B   A A A AH       B   * "&!" x x x x xv   .' ' ' 'T 
 % % % % 
%
 
% % % 
% * * * * *Z- - - - -  01    1
 1
 1
 1
 1
 1
 1
 1
h  07 7 7 76. . . . . .r9   