Ë
    |D™j|&  ã                  óö   — d Z ddlmZ ddlZddlmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZmZmZ dd	lmZ dd
lmZ dd„Zdd„Zdd„Z ede¬«      Z	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd„Z	 	 	 	 	 	 dd„Z	 	 	 	 	 	 	 	 dd„Zy)z.Strategies for customizing subclass behaviors.é    )ÚannotationsN)Úcollect)ÚAnyÚCallableÚTypeVarÚUnioné   )ÚBaseConverter)ÚAttributeOverrideÚmake_dict_structure_fnÚmake_dict_unstructure_fn)Úalready_generating)Ú
subclassesc                óœ   — t        j                  | «      xs | }| d i}t        |«      D ]  }t        |«      D ]  }d ||<   Œ	 Œ t	        |«      S ©N)ÚtypingÚ
get_originr   Ú_make_subclasses_treeÚlist)ÚclÚ
cls_originÚseenÚsclÚsscls        úi/var/www/html/Astrologybackend/backend/venv/lib/python3.12/site-packages/cattrs/strategies/_subclasses.pyr   r      s_   € ä×"Ñ" 2Ó&Ò,¨"€Jð �ˆ:€DÜ˜*Ó%ò ˆÜ)¨#Ó.ò 	ˆDØˆD�ŠJñ	ðô �‹:Ðó    c                óŽ   — t        j                  | «      xs | }t        t        |«      «      }t        |«      }t	        ||z  «      S )z?Whether the given class has subclasses from `given_subclasses`.)r   r   Úsetr   Úbool)r   Úgiven_subclassesr   ÚactualÚgivens        r   Ú_has_subclassesr#      s@   € ä×"Ñ" 2Ó&Ò,¨"€JÜ”˜JÓ'Ó(€FÜÐ Ó!€EÜ�˜‘ÓÐr   c                óœ   — t        t        | «      «      }t        t        |«      t        |«      z  «      }t        |«      dk\  r	t        |   S d S )Nr	   )Útupler   r   Úlenr   )r   Úgiven_subclasses_treeÚactual_subclass_treeÚ
class_trees       r   Ú_get_union_typer*   #   sI   € Ü Ô!6°rÓ!:Ó;ÐÜ”sÐ/Ó0´3Ð7LÓ3MÑMÓN€JÜ # J£°1Ò 4Œ5�ÑÐ>¸$Ð>r   ÚC)Úboundc                ó�   — t        «        |�| g|¢­}nt        t        | «      «      }|€t        | |||«       yt	        ||||«       y)a`  
    Configure the converter so that the attrs/dataclass `cl` is un/structured as if it
    was a union of itself and all its subclasses that are defined at the time when this
    strategy is applied.

    :param cl: A base `attrs` or `dataclass` class.
    :param converter: The `Converter` on which this strategy is applied. Do note that
        the strategy does not work for a :class:`cattrs.BaseConverter`.
    :param subclasses: A tuple of sublcasses whose ancestor is `cl`. If left as `None`,
        subclasses are detected using recursively the `__subclasses__` method of `cl`
        and its descendents.
    :param union_strategy: A callable of two arguments passed by position
        (`subclass_union`, `converter`) that defines the union strategy to use to
        disambiguate the subclasses union. If `None` (the default), the automatic unique
        field disambiguation is used which means that every single subclass
        participating in the union must have an attribute name that does not exist in
        any other sibling class.
    :param overrides: a mapping of `cl` attribute names to overrides (instantiated with
        :func:`cattrs.gen.override`) to customize un/structuring.

    .. versionadded:: 23.1.0
    .. versionchanged:: 24.1.0
       When overrides are not provided, hooks for individual classes are retrieved from
       the converter instead of generated with no overrides, using converter defaults.
    .. versionchanged:: 25.2.0
       Slotted dataclasses work on Python 3.14 via :func:`cattrs.subclasses.subclasses`,
       which filters out duplicate classes caused by slotting.
    N)r   r%   r   Ú*_include_subclasses_without_union_strategyÚ'_include_subclasses_with_union_strategy)r   Ú	converterr   Úunion_strategyÚ	overridesÚparent_subclass_trees         r   Úinclude_subclassesr4   ,   s[   € ôH „IØÐØ "Ð0 ZÑ0Ñä$Ô%:¸2Ó%>Ó?ÐàÐÜ2Ø�	Ð/°õ	
ô 	0ØÐ+¨^¸Yõ	
r   c                ób  — |D ]ª  } t        | |«      }| fd„}|�t        | |fi |¤Ž}t        | |fi |¤Ž}n"|j                  | «      }|j	                  | «      }|€| |fdd„}n|j                  ||¬«      }	|| ||	f	 	 	 dd„}|| |f	 	 	 dd„}
|j                  ||«       |j                  ||
«       Œ¬ y )Nc                ó
   — | |u S r   © ©ÚclsÚ_cls     r   Ú	cls_is_clz=_include_subclasses_without_union_strategy.<locals>.cls_is_clq   ó   € Ø˜#�:Ðr   c                ó   —  || |«      S r   r7   )ÚvalÚ_r:   Ú
_base_hooks       r   Ústruct_hookz?_include_subclasses_without_union_strategy.<locals>.struct_hook}   s   € Ù! # sÓ+Ð+r   )r2   c                óP   —  || «      }||u r	 || |«      S |j                  | |«      S )zË
                If val is disambiguated to the class `cl`, use its base hook.

                If val is disambiguated to a subclass, dispatch on its exact runtime
                type.
                )Ú	structure)r>   r?   Ú_cr:   r@   Ú_dis_fnÚdis_cls          r   rA   z?_include_subclasses_without_union_strategy.<locals>.struct_hookƒ   s2   € ñ ! ›�Ø˜S‘=Ù% c¨3Ó/Ð/Ø—|‘| C¨Ó0Ð0r   c                óh   — | j                   |u r || «      S |j                  | | j                   ¬«      S )z¦
            If val is an instance of the class `cl`, use the hook.

            If val is an instance of a subclass, dispatch on its exact runtime type.
            )Úunstructure_as)Ú	__class__Úunstructure)r>   rD   r:   r@   s       r   Úunstruct_hookzA_include_subclasses_without_union_strategy.<locals>.unstruct_hook–   s1   € ð �}‰} Ñ#Ù! #“Ð&Ø—>‘> #°c·m±m�>ÓDÐDr   )r>   ÚdictÚreturnr   )r>   zparent_subclass_tree[0]rM   rL   )r*   r   r   Úget_structure_hookÚget_unstructure_hookÚ_get_dis_funcÚregister_structure_hook_funcÚregister_unstructure_hook_func)r   r0   r3   r2   Úsubclass_unionr;   Úbase_struct_hookÚbase_unstruct_hookrA   Údis_fnrK   s              r   r.   r.   `   s  € ð #ò AKˆô )¨Ð-AÓBˆà!ó 	ð Ð Ü5°b¸)ÑQÀyÑQÐÜ!9¸"¸iÑ!UÈ9Ñ!UÑà(×;Ñ;¸BÓ?ÐØ!*×!?Ñ!?ÀÓ!CÐàÐ!à.0Ð=Mõ ,ð ×,Ñ,¨^ÀyÐ,ÓQˆFð
 ØØ+Øð1Øð1ð ó1ð* ØØ)ð		EØ(ð	Eð
 ó	Eð" 	×.Ñ.¨y¸+ÔFØ×0Ñ0°¸MÕJñCAKr   c                ó*  — |D �cg c]  }t        ||«      sŒ|‘Œ }}|syi }i }|D ]{  }t        |«      |hz
  t        _        	 |�t	        || fi |¤Ž}t        || fi |¤Ž}	n&| j                  |d¬«      }| j                  |d¬«      }	t        «       t        _        |||<   |	||<   Œ} t        |   }
|j                  «       D ]  \  }}|fd„}| j                  ||«       Œ |j                  «       D ]  \  }}|fd„}| j                  ||«       Œ  ||
| «       | j                  |
«      }| j                  |
«      }	|D ]·  }|fd„}| j                  ||«       t        |D �cg c]>  }t        t        j                  |«      xs |t        j                  |«      xs |«      r|‘Œ@ c}«      }t!        |«      dkD  sŒ|t        |   } ||| «       | j                  |«      }	||	fd	d„}| j                  ||«       Œ¹ yc c}w # t        «       t        _        w xY wc c}w )
a^  
    This function is tricky because we're dealing with what is essentially a circular
    reference.

    We need to generate a structure hook for a class that is both:
    * specific for that particular class and its own fields
    * but should handle specific functions for all its descendants too

    Hence the dance with registering below.
    NF)Úcache_resultc                ó
   — | |u S r   r7   r8   s     r   r;   z:_include_subclasses_with_union_strategy.<locals>.cls_is_clÚ   r<   r   c                ó
   — | |u S r   r7   r8   s     r   r;   z:_include_subclasses_with_union_strategy.<locals>.cls_is_clá   r<   r   c                ó
   — | |u S r   r7   r8   s     r   r;   z:_include_subclasses_with_union_strategy.<locals>.cls_is_clí   r<   r   é   c                ó   —  || |«      S r   r7   )Úpayloadr?   Ú_uÚ_ss       r   Úshz3_include_subclasses_with_union_strategy.<locals>.shý   s   € Ù˜' 2“Ð&r   )r^   rL   rM   r   )r#   r   r   Úworking_setr   r   rO   rN   r   ÚitemsrR   rQ   r%   Ú
issubclassr   r   r&   )r0   Úunion_classesr1   r2   r   Úparent_classesÚoriginal_unstruct_hooksÚoriginal_struct_hooksrK   rA   Úfinal_unionÚhookr;   Úcr   Úura   s                    r   r/   r/   «   s^  € ð" $1ÖW˜R´OÀBÈÕ4V’bÐW€NÐWÙØà ÐØÐØò 0ˆô
 *-¨]Ó);¸r¸dÑ)BÔÔ&ð	3ØÐ$Ü 8¸¸YÑ TÈ)Ñ T�Ü4°R¸ÑPÀiÑP‘à )× >Ñ >¸rÐPUÐ >Ó V�Ø'×:Ñ:¸2ÈEÐ:ÓR�ä-0«UÔÔ*Ø&3Ð Ñ#Ø$/Ð˜bÒ!ð!0ô( ˜Ñ&€Kà+×1Ñ1Ó3ò B‰ˆˆDà!ó 	ð 	×0Ñ0°¸DÕAðBð *×/Ñ/Ó1ò @‰ˆˆDà!ó 	ð 	×.Ñ.¨y¸$Õ?ð@ñ �; 	Ô*Ø×2Ñ2°;Ó?€MØ×.Ñ.¨{Ó;€Kàò Bˆð  "ó 	ð 	×0Ñ0°¸MÔJÜð 'öàÜœf×/Ñ/°Ó2Ò7°a¼×9JÑ9JÈ2Ó9NÒ9TÐRTÔUò òó
ˆ
ô ˆz‹?˜QÓÜ�jÑ!ˆAÙ˜1˜iÔ(Ø#×6Ñ6°qÓ9ˆKà()¨kô 'ð ×2Ñ2°9¸bÕAñ-Bùò] Xøô( .1«UÔÕ*üòDs   …G3—G3ÁAG8ÅAH
Ç8H)r   ÚtyperM   z
list[type])r   rm   r    útuple[type, ...]rM   r   )r   rm   r'   ztuple[type]rM   ztype | None)NNN)r   rm   r0   r+   r   ztuple[type, ...] | Noner1   zCallable[[Any, C], Any] | Noner2   ú#dict[str, AttributeOverride] | NonerM   ÚNone)r0   r
   r3   rn   r2   ro   )r0   r+   re   rn   r1   zCallable[[Any, C], Any]r2   ro   )Ú__doc__Ú
__future__r   r   Úgcr   r   r   r   r   Ú
convertersr
   Úgenr   r   r   Úgen._constsr   r   r   r#   r*   r+   r4   r.   r/   r7   r   r   ú<module>rw      sé   ðÙ 4å "ã Ý ß 0Ó 0å &ß UÑ UÝ ,Ý #ó	ó ó?ñ ˆC�}Ô%€ð +/Ø59Ø59ð1
Øð1
àð1
ð (ð1
ð 3ð	1
ð
 3ð1
ð 
ó1
ðhHKàðHKð +ðHKð 3ó	HKðVUBØðUBà#ðUBð ,ðUBð 3ô	UBr   