
    ̏khu'                     *   d dl Z d dlZd dlZd dlmZ 	 d dlmZ 	 d dlmZm	Z	 d Z	  ej                  dd       d	 Zej                  dk\  rd Znej                  dk  rd Znej                  Zd Zd Zd Zi eeeeeeeeeeej.                  eej0                  eej2                  eej4                  eej6                  eej8                  eej:                  eej<                  eej>                  eej@                  eejB                  eejD                  ee jF                  j8                  ee jF                  j:                  ee jF                  j<                  ee jF                  jB                  ee jF                  j2                  ee jF                  j>                  ee jF                  j@                  eiZ$d Z%d Z&d Z'd Z(y# e$ r
 d dlmZ Y w xY w# e$ r 	 d dlmZm	Z	 n# e$ r dxZ	ZY nw xY wY w xY w# e$ r d
 ZY w xY w)    N)_AnnotatedAlias)get_type_hints)NotRequiredRequiredc                     t        | d      S )NT)include_extras)_get_type_hints)objs    J/var/www/teggl/fontify/venv/lib/python3.12/site-packages/msgspec/_utils.pyr   r      s    3t44    FooT)is_classc                 2    t        j                  | dd      S )NFT)is_argumentr   typing
ForwardRefvalues    r   _forward_refr   '   s      EDIIr   c                 0    t        j                  | d      S )NF)r   r   r   s    r   r   r   "   s      E::r   )      c                 2    t        j                  | ||d      S )N )r   
_eval_type)tglobalnslocalnss      r   r   r   .   s      Hgr::r   )r   
   c                     	 t        j                  | ||      S # t        $ rE}	 ddlm} n'# t        $ r t        d| j
                  d      |w xY w || ||d      cY d }~S d }~ww xY w)Nr   )eval_type_backportz#Unable to evaluate type annotation a  . If you are making use of the new typing syntax (unions using `|` since Python 3.10 or builtins subscripting since Python 3.9), you should either replace the use of new syntax with the existing `typing` constructs or install the `eval_type_backport` package.F)try_default)r   r   	TypeErrorr"   ImportError__forward_arg__)r   r   r   er"   s        r   r   r   2   s    	$$Q':: 	A 9!:K:K9N OW W
  &!	 	s)    	A'*A"$AA"A'"A'c                     t        | t        j                        rj                  | |       S 	 t	        | j
                        }|s| S t	        fd|D              }| |   S # t        $ r | cY S w xY w)Nc              3   B   K   | ]  }j                  ||        y wN)get).0pmappings     r   	<genexpr>z _apply_params.<locals>.<genexpr>Y   s     7qQ"7s   )
isinstancer   TypeVarr+   tuple__parameters__	Exception)r
   r.   
parametersargss    `  r   _apply_paramsr7   J   ss    #v~~&{{3$$3--.

 
 7J77Dt9  
s   A! !A/.A/c                     i t        | t              r| }n| j                  }fd | i        |j                  fS )Nc                    t        | t              r| }i }nt        | dd       }|d t        t        j
                  fv s|	v ry |j                  }t        fd| j                  D              }t        |      t        |      k(  sJ t        t        ||            x	|<   }t        |t        j
                        r(t        |d|j                        }|D ]  } ||        y y )N
__origin__c              3   6   K   | ]  }t        |        y wr*   )r7   )r,   ascopes     r   r/   zE_get_class_mro_and_typevar_mappings.<locals>.inner.<locals>.<genexpr>n   s     EQq%0Es   __orig_bases__)r0   typegetattrobjectr   Genericr3   r2   __args__lendictzip
issubclass	__bases__)
cr=   cls	new_scopeparamsr6   basesbinnerr.   s
    `      r   rO   z2_get_class_mro_and_typevar_mappings.<locals>.innere   s    aCI!\40CtVV^^44w''FE!**EEDv;#d)+++'+C,='>>GCL9c6>>*C!13==AE $a#$ +r   )r0   r?   r:   __mro__)r
   rJ   rO   r.   s     @@r   #_get_class_mro_and_typevar_mappingsrQ   ]   s?    G#tnn$$ 
#rN;;r   c                    i }t        |       \  }}|D ]  }|t        j                  t        fv r|j	                  |      }t        t        |            }t        t        j                  j	                  |j                  d      di       }|j                  j	                  di       }|j                         D ]S  \  }	}
|	|v r|
t        d      }
nt        |
t              rt!        |
      }
t#        |
||      }
|t%        |
|      }
|
||	<   U  |S )a  Get the annotations for a class.

    This is similar to ``typing.get_type_hints``, except:

    - We maintain it
    - It leaves extras like ``Annotated``/``ClassVar`` alone
    - It resolves any parametrized generics in the class mro. The returned
      mapping may still include ``TypeVar`` values, but those should be treated
      as their unparametrized variants (i.e. equal to ``Any`` for the common case).

    Note that this function doesn't check that Generic types are being used
    properly - invalid uses of `Generic` may slip through without complaint.

    The assumption here is that the user is making use of a static analysis
    tool like ``mypy``/``pyright`` already, which would catch misuse of these
    APIs.
    N__dict____annotations__)rQ   r   rB   rA   r+   rE   varsr@   sysmodules
__module__rS   itemsr?   r0   strr   r   r7   )r
   hintsmrotypevar_mappingsrJ   r.   
cls_localscls_globalsannnamer   s              r   get_class_annotationsrb   {   s   $ E?DC	  6>>6**"&&s+$s)_
ckkoocnndCZQSTll0"599; 
	 KD%u}}T
E3'$U+uj+>E"%eW5E$K
	  ( Lr   c                    t        | t              r| }n| j                  }t        |       }t	        |d      rt        |j                        }n"|j                  rt        |      }n
t               }i }|j                         D ]o  \  }}t        |dd      }|t        u r$|j                  |       |j                  d   ||<   ?|t        u r$|j                  |       |j                  d   ||<   k|||<   q ||fS )N__required_keys__r:   Fr   )r0   r?   r:   rb   hasattrsetrd   	__total__rY   r@   r   addrC   r   discard)r
   rJ   	raw_hintsrequiredr[   kvorigins           r   get_typeddict_inforo      s    #tnn%c*Is'(s,,-	y>5 E! 	1L%0XLLOzz!}E!H{"Qzz!}E!HE!H	 (?r   c                    t        | t              r| }n| j                  }t        |       }g }g }g }t	        |d      rddlm}m}m} |j                  j                         D ]  }	|	j                  |ur|	j                  |u rt        d      +|	j                  }
||
   }|	j                  |ur0|j                  |	j                         |j                  |
|df       z|	j                   |ur0|j                  |	j                          |j                  |
|df       |j                  |
|df        |j#                  |       d }t%        |dd       }n ddlm}m} g }|j,                  D ]  }	|	j                  }
||
   }|	j                  }||uryt        ||      rG|j.                  rt1        d	      |j                  |j2                         |j                  |
|df       n:|j                  |       |j                  |
|df       n|j                  |
|df       |	j4                  |j                  |	        |j#                  |       t%        |d
d       }t%        |dd       }|rt7        ||      }|t9        |      t9        |      ||fS )N__dataclass_fields__r   )_FIELD_FIELD_INITVARMISSINGz3dataclasses with `InitVar` fields are not supportedFT__post_init__)NOTHINGFactoryzvSupport for default factories with `takes_self=True` is not implemented. File a GitHub issue if you need this feature!__attrs_pre_init____attrs_post_init__)r0   r?   r:   rb   re   dataclassesrr   rs   rt   rq   values_field_typer$   ra   defaultappenddefault_factoryextendr@   attrsrv   rw   __attrs_attrs__
takes_selfNotImplementedErrorfactory	validator_wrap_attrs_validatorsr2   )r
   rJ   r[   rk   optionaldefaultsrr   rs   rt   fieldra   typpre_init	post_initrv   rw   fields_with_validatorsr}   s                     r   get_dataclass_infor      se   #tnn!#&EHHHs*+??--446 	4E  .$$6#M  ::D+C}}G+.sE 23&&g5 5 56sD 12sE 23!	4$ 	!C$7	*!#(( 	5E::D+CmmGg%gw/))1, 
 OOGOO4OOT3$56OOG,OOT3$67sE 23*&--e4+	5. 	!3 4d;C!6=	!./EyQIhx(IEEr   c                       fd}|S )Nc           	      x    D ])  }|j                  | |t        | |j                               + 	 |        y y r*   )r   r@   ra   )r
   r   fieldsr   s     r   rO   z%_wrap_attrs_validators.<locals>.inner4  sA     	BEOOCUZZ(@A	B cN !r   r   )r   r   rO   s   `` r   r   r   3  s     Lr   c                      | di |S )z1Used to unpickle Structs with keyword-only fieldsr   r   )rJ   kwargss     r   rebuildr   =  s    ==r   ))collectionsrV   r   r   typing_extensionsr   r	   r4   r   r   r   r   r$   version_infor   r7   rQ   rb   listr2   rf   	frozensetrE   ListTupleSet	FrozenSetDict
CollectionMutableSequenceSequenceMutableMappingMapping
MutableSetAbstractSetabc_CONCRETE_TYPESro   r   r   r   r   r   r   <module>r      s}    
  "9C&75
JFed+J
 w;* ""J& <)^$	5  y	
 	$ KK LL% JJ i KK t D OOT 4 NND  s!" #$ OOOO##TOOdOOOOOO""DOOT18 FGFTg	  9889
  &&00 &!%%;&&"  ;;;sW   G G! H GG!H'G0/H0	G<9H;G<<HHHH