
    is                     R   S r SSKJrJr  SSKJr  SSKJrJr  SSKJ	r	J
r
Jr  SSKJrJrJrJrJrJr  SSK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KJ r   SSK!J"r"  SSK#J$r$J%r%J&r&J'r'  \
" S5      r( " S S\)5      r* " S S\5      r+S\4S jr,\'" \+5      S\	S\	S\+4S j5       r-g)z"Preconfigured converters for bson.    )	b85decode	b85encode)Set)datedatetime)AnyTypeVarUnion)DEFAULT_CODEC_OPTIONSCodecOptionsInt64ObjectIddecodeencode   )
is_mappingis_subclass)mapping_structure_factory)BaseConverter	Converter)StructureHookidentity)is_literal_containing_enums)configure_union_passthrough   )is_primitive_enum'literals_with_enums_unstructure_factoryvalidate_datetimewrapTc                       \ rS rSrSrSrg)Base85Bytes   z5A subclass to help with binary key encoding/decoding. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r%       R/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/cattrs/preconf/bson.pyr#   r#      s    ?r,   r#   c                   b    \ rS rSrSS\4S\S\S\S\S\4
S	 jjr	\4S
\S\
\   S\S\4S jjrSrg)BsonConverter   NFobjunstructure_as
check_keyscodec_optionsreturnc                 2    [        U R                  XS9UUS9$ )N)r2   )r3   r4   )r   unstructure)selfr1   r2   r3   r4   s        r-   dumpsBsonConverter.dumps    s(     S@!'
 	
r,   dataclc                 4    U R                  [        XS9U5      $ )N)r4   )	structurer   )r8   r;   r<   r4   s       r-   loadsBsonConverter.loads-   s     ~~fTGLLr,   r%   )r&   r'   r(   r)   r   r   boolr   bytesr9   typer!   r?   r+   r%   r,   r-   r/   r/      s     # &;

 
 	

 $
 

" '<	MM GM $	M
 
M Mr,   r/   	converterc                   ^  SS[         4U 4S jjjnS[         S[        4U 4S jjnT R                  [        S 5        T R	                  [
        U5        T R                  [
        U5        T R                  [        S 5        [        [        [        [        [        [        S[        [        [        [         4	   T 5        T R#                  [        [$        5        T R                  [        [&        5        T R#                  [(        S 5        T R                  [(        S	 5        T R	                  [*        S
 5        T R	                  [,        [.        5        g)a  
Configure the converter for use with the bson library.

* sets are serialized as lists
* byte mapping keys are base85-encoded into strings when unstructuring, and reverse
* non-string, non-byte mapping keys are coerced into strings when unstructuring
* a deserialization hook is registered for bson.ObjectId by default
* string and int enums are passed through when unstructuring

.. versionchanged:: 24.2.0
    Enums are left to the library to unstructure, speeding them up.
Nr<   c                    > [         n[        U SS 5      nU(       a6  [        US   [         5      (       a  S nO[        US   [        5      (       a  S nTR	                  XUS9$ )N__args__r   c                 6    [        U 5      R                  S5      $ )Nutf8)r   r   )ks    r-   key_handlerIconfigure_converter.<locals>.gen_unstructure_mapping.<locals>.key_handlerL   s    $Q<..v66r,   )unstructure_torK   )strgetattrr   rB   gen_unstructure_mapping)r<   rM   rK   argsrD   s       r-   rP   4configure_converter.<locals>.gen_unstructure_mappingD   sd    r:t,47C(("T!We,,7 00; 1 
 	
r,   r5   c                    > [        U SS 5      nU(       a)  [        US   [        5      (       a  [        U T[        S9nU$ [        U T5      nU$ )NrG   r   )key_type)rO   r   rB   r   r#   )r<   rQ   hrD   s      r-   gen_structure_mapping2configure_converter.<locals>.gen_structure_mappingS   sL    r:t,KQ//)"i+NA  *"i8Ar,   c                     [        U 5      $ N)r   v_s     r-   <lambda>%configure_converter.<locals>.<lambda>[   s    	!r,   c                     [        U 5      $ rY   )r   rZ   s     r-   r]   r^   _   s    Xa[r,   c                 "    U R                  5       $ rY   )	isoformat)r[   s    r-   r]   r^   h   s
    r,   c                 .    [         R                  " U 5      $ rY   )r   fromisoformatrZ   s     r-   r]   r^   i   s    9K9KA9Nr,   c                     [         $ rY   r   )ts    r-   r]   r^   j   s    Xr,   rY   )r   r   register_structure_hookr#   !register_unstructure_hook_factoryr   register_structure_hook_factoryr   r   r
   rN   rA   intfloatrB   r   r   register_unstructure_hookr   r   r   r   r   r   )rD   rP   rV   s   `  r-   configure_converterrl   6   s    
C 
 
# -  %%k3LM//
<ST--j:OP%%h0HIc4eT5(HeKLi ''(;%%h0AB''.EF%%d,NO//0ACUV//#%Lr,   rQ   kwargsr5   c                  t    [         [        0UR                  S0 5      EUS'   [        U 0 UD6n[	        U5        U$ )Nunstruct_collection_overrides)r   listgetr/   rl   )rQ   rm   ress      r-   make_converterrs   p   sH     	T/
**4b
9/F*+ 
(
(CJr,   N).r*   base64r   r   collections.abcr   r   r   typingr   r	   r
   bsonr   r   r   r   r   r   _compatr   r   colsr   
convertersr   r   dispatchr   fnsr   literalsr   
strategiesr    r   r   r   r    r!   rB   r#   r/   rl   rs   r%   r,   r-   <module>r      s    ( '  # & & U U - , 1 $  2 4  CL@% @MI M.7= 7t m#    r,   