
    i                       S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
J	r	  SSKJr  SSKJr  SS	KJrJrJrJr  SS
KJr  SSKJr  SSKJrJrJr  SSKJrJr  SSKJ r J!r!J"r"J#r#J$r$J%r%J&r&  SSK'J(r(  SSK)J*r*J+r+  SSK,J-r-  SSK.J/r/  SSK0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7J8r8  \" S5      r9/ SQr: " S S\+5      r;S%S jr<\8" \;5      S&S j5       r=S%S jr>S'S  jr?S(S! jr@ S)       S*S" jjrA      S+S# jrBg$),z%Preconfigured converters for msgspec.    )annotations	b64decode)Callable)is_dataclass)datedatetime)Enum)partial)AnyTypeVarUnionget_type_hints)has)resolve_types)Structconvertto_builtins)Encoderdecode   )fieldsget_args
get_originis_bare
is_mappingis_sequenceis_subclass)is_namedtuple)BaseConverter	Converter)UnstructureHookidentity) make_hetero_tuple_unstructure_fn)is_literal_containing_enums)configure_union_passthrough   )'literals_with_enums_unstructure_factorywrapT)MsgspecJsonConverterconfigure_convertermake_converterc                  j    \ rS rSr% Sr\" 5       rS\S'   SSS jjr      SS jr	SS jr
SS	 jrS
rg)r,   )   z2A converter specialized for the _msgspec_ library.r   encoderNc                V    U R                   R                  " U R                  XS940 UD6$ )z-Unstructure and encode `obj` into JSON bytes.)unstructure_as)r1   encodeunstructure)selfobjr3   kwargss       U/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/cattrs/preconf/msgspec.pydumpsMsgspecJsonConverter.dumps/   s2    ||""S@
DJ
 	
    c                    U R                  U5      nU[        [        4;   a  U R                  R                  $ U R
                  $ )z*Produce a `dumps` hook for the given type.)get_unstructure_hookr$   r   r1   r4   r:   )r6   r3   r8   unstruct_hooks       r9   get_dumps_hook#MsgspecJsonConverter.get_dumps_hook5   s;     11.AX{33<<&&&zzr<   c                :    U R                  [        U40 UD6U5      $ )z7Decode and structure `cl` from the provided JSON bytes.)	structurer   )r6   dataclr8   s       r9   loadsMsgspecJsonConverter.loads>   s    ~~fT4V4b99r<   c                *    [        U R                  US9$ )z*Produce a `loads` hook for the given type.)rE   )r   rF   )r6   rE   s     r9   get_loads_hook#MsgspecJsonConverter.get_loads_hookB   s    tzzb))r<    N)r7   r   r3   r   r8   r   returnbytes)r3   r   r8   r   rM   zCallable[[Any], bytes])rD   rN   rE   type[T]r8   r   rM   r+   )rE   rO   rM   zCallable[[bytes], T])__name__
__module____qualname____firstlineno____doc__r   r1   __annotations__r:   r@   rF   rI   __static_attributes__rK   r<   r9   r,   r,   )   s?    < yGW 
!-0	:*r<   r,   c                   [        U 5        U R                  [        [        5        U R	                  S S 5        U R                  [        [        5        U R                  [        S 5        U R                  [        S 5        U R                  [        S 5        U R	                  [        [        5        [        [        [        [        [         ["        S4   U 5        g)a  Configure the converter for the msgspec library.

* bytes are serialized as base64 strings, directly by msgspec
* datetimes and dates are passed through to be serialized as RFC 3339 directly
* enums are passed through to msgspec directly
* union passthrough configured for str, bool, int, float and None
* bare, string and int enums are passed through when unstructuring

.. versionchanged:: 24.2.0
    Enums are left to the library to unstructure, speeding them up.
c                "    [        U [        5      $ rL   )r   r
   )ts    r9   <lambda>%configure_converter.<locals>.<lambda>W   s    +a&r<   c                    [         $ rL   r#   )rY   cs     r9   rZ   r[   W   s    Xr<   c                    [        U 5      $ rL   r   v_s     r9   rZ   r[   [   s    )A,r<   c                "    [        U [        5      $ rL   )r   r	   r_   s     r9   rZ   r[   \   s    WQ=Qr<   c                .    [         R                  " U 5      $ rL   )r   fromisoformatr_   s     r9   rZ   r[   ]   s    9K9KA9Nr<   N)configure_passthroughsregister_unstructure_hookr   r   !register_unstructure_hook_factoryregister_structure_hookr   rN   r	   r   r&   r)   r'   r   strboolintfloat	converters    r9   r-   r-   G   s     9%''<//&(= %%fg6%%e-FG%%h0QR%%d,NO//#%L  c4eT&A BINr<   c                 2    [        U 0 UD6n[        U5        U$ rL   )r,   r-   )argsr8   ress      r9   r.   r.   d   s    

/
/CJr<   c                L   U R                  [        [        5        U R                  [        [
        5        U R                  [        [        5        U R                  [        [        5        U R                  [        [        [        SS95        U R                  [        [        5        g)zConfigure optimizing passthroughs.

A passthrough is when we let msgspec handle something automatically.

.. versionchanged:: 25.1.0
    Dataclasses with private attributes are now passed through.
F)msgspec_skips_privateN)rf   rN   r   rg   r   mapping_unstructure_factoryr   seq_unstructure_factory	attrs_has!msgspec_attrs_unstructure_factoryr   r   r   namedtuple_unstructure_factoryrm   s    r9   re   re   k   s~     ''{;//
<WX//=TU//4 //1O //5r<   c                    [        U 5      (       a  [        nO[        U 5      nUS   nUR                  USS9nU[        [
        4;   a  U$ UR                  U 5      $ )z3The msgspec unstructure hook factory for sequences.r   Fcache_result)r   r   r   r>   r$   r   gen_unstructure_iterable)typern   type_argrp   handlers        r9   ru   ru      sZ    t}}~7,,XE,JG8[))--d33r<   c                v   [        U 5      (       a-  [        n[        nUR                  USS9nUR                  USS9nOF[        U 5      n[	        U5      S:X  a  Uu  p#OU[        p2UR                  USS9nUR                  USS9nU[
        [        4;   a  U[
        [        4;   a  [        $ UR                  U 5      $ )z2The msgspec unstructure hook factory for mappings.Frz   r   )r   r   r>   r   lenr$   r   gen_unstructure_mapping)r}   rn   key_argval_argkey_handlervalue_handlerrp   s          r9   rt   rt      s    t}}44W54Q!66wU6S~t9>#GW  $SW44W54Q!66wU6Sx---D 3 ,,T22r<   c                >  ^ [        U 5      n[        U=(       d    U 5      n[        U 5      (       a6  [        S U 5       5      (       a  [	        U 5        [        U=(       d    U 5      nU(       a+  [        U4S jU 5       5      (       a  TR                  U 5      $ [        $ )zChoose whether to use msgspec handling or our own.

Args:
    msgspec_skips_private: Whether the msgspec library skips unstructuring
        private attributes, making us do the work.
c              3  V   #    U  H  n[        UR                  [        5      v   M!     g 7frL   )
isinstancer}   ri   ).0as     r9   	<genexpr>4msgspec_attrs_unstructure_factory.<locals>.<genexpr>   s     H1z!&&#66s   ')c              3     >#    U  HN  nUR                   R                  S 5      =(       d'    TR                  UR                  SS9[        [
        4;  v   MP     g7f)ra   Frz   N)name
startswithr>   r}   r$   r   )r   attrrn   s     r9   r   r      sY      % D 			S! 	
**4995*Ik*+	

 s   AA)r   r   rv   anyr   gen_unstructure_attrs_fromdictr   )r}   rn   rs   originattribss    `   r9   rw   rw      s     FV^t$G3HHHHd4( % % " " 77==r<   c           
        ^ [        U4S j[        U 5      R                  5        5       5      (       a  [        $ [	        U T[
        [        [        U 5      R                  5       5      S9$ )zCA hook factory for unstructuring namedtuples, modified for msgspec.c              3  `   >#    U  H#  nTR                  U5      [        [        4;   v   M%     g 7frL   )r>   r$   r   )r   rY   rn   s     r9   r   1namedtuple_unstructure_factory.<locals>.<genexpr>   s-      .A 	&&q)h-DD.s   +.)unstructure_to	type_args)allr   valuesr$   r%   tuple)r}   rn   s    `r9   rx   rx      s`    
  %,,.   +t,3356	 r<   N)rn   r!   rM   None)rp   r   r8   r   rM   r,   )rn   r!   rM   r"   )rn   r    rM   r"   )T)r}   r   rn   r!   rs   rj   rM   r"   )r}   ztype[tuple]rn   r    rM   r"   )CrT   
__future__r   base64r   collections.abcr   dataclassesr   r	   r   enumr
   	functoolsr   typingr   r   r   r   attrsr   rv   r   msgspecr   r   r   msgspec.jsonr   r   _compatr   r   r   r   r   r   r   colsr   
convertersr    r!   dispatchr"   fnsr$   genr%   literalsr&   
strategiesr'    r)   r*   r+   __all__r,   r-   r.   re   ru   rt   rw   rx   rK   r<   r9   <module>r      s    + "  $ $ #   6 6 "  0 0 (   ! 1 &  2 2 4 ;CL
K*9 *<O:  .434 DH
#<@8
"/r<   