+
    7*i(>  c                  s  a  0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
HtHtHt ^ RIHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHtHtHtH t H!t!H"t" ^ RI#H$t$H%t%H&t&H't'H(t( ^ RI)H*t* ^ RI+H,t,H-t-H.t. ^ RI/H0t0 ^RI1H2t2H3t3 ^RI4H5t5 ]$'       dC   ]]6]%3,          ]]7]%3,          ,          t8R]9R&   ]]6,          ]]7,          ,          t:R]9R&   ^RI;H<t< ]6]=]>]7]?]@]A]3P                  ]]]!]	P                  ]]"]DP                  ]FP                  0tGR]9R&   ]H]I]J]K]L]]]0tMR]9R&   R R ltNR R ltOR R ltPR R ltQR  R! ltRR" R# ltS]'! R$4      tTR% R& ltUR' R( ltV]'! R)4      tWR*]7/R+ R, lltX ! R- R.]2P                  4      tZ]$'       d   R/ R0 lt[M
 ! R1 R24      t[]'! R34      t\R4 R5 lt]]^! 4       t_R6 R7 lt`R8 R9 lta]P                  ! R:R;7       ! R< R=4      4       tc]'! R>R?R@7      td]'! RA4      te ! RB RC]&]d]e3,          4      tfR# )DzBucket of reusable internal utilities.

This should be reduced as much as possible with functions only used in one place, moved to that place.
)annotationsN)OrderedDictdefaultdictdeque)CallableIterableMapping)Set)deepcopy)cached_property)	Parameter)zip_longest)BuiltinFunctionTypeCodeTypeFunctionTypeGeneratorType
LambdaType
ModuleType)TYPE_CHECKINGAnyGenericTypeVaroverload)MISSING)	TypeAlias	TypeGuard
deprecated)PydanticDeprecatedSince211)_repr_typing_extra)import_cached_base_modelr   MappingIntStrAnyAbstractSetIntStr)	BaseModelzset[type[Any]]IMMUTABLE_NON_COLLECTIONS_TYPESBUILTIN_COLLECTIONSc                    V ^8  d   QhRRRR/# )   paramr
   returnbool Zformat   ">/usr/lib/python3.14/site-packages/pydantic/_internal/_utils.py__annotate__r-   J   s     V VY V4 V    c                s\    V P                   \        P                  \        P                  39   # )a*  Return whether the parameter accepts a positional argument.

```python {test="skip" lint="skip"}
def func(a, /, b, *, c):
    pass

params = inspect.signature(func).parameters
can_be_positional(params['a'])
#> True
can_be_positional(params['b'])
#> True
can_be_positional(params['c'])
#> False
```
)Zkindr
   ZPOSITIONAL_ONLYZPOSITIONAL_OR_KEYWORD)r&      &r,   can_be_positionalr0   J   s$      ::)33Y5T5TUUUr.   c               r$   r%   vr   r'   r(   r)   r*   r+   r,   r-   r-   ]   s     N NS NT Nr.   c           	     sV    \        V \        \        \        \        \
        \        34      # N)
isinstancelisttupleset	frozensetr   r   r2   r/   r,   sequence_liker:   ]   s    a$sI}eLMMr.   c               $    V ^8  d   QhRRRRRR/# )r%   or   class_or_tuplez(type[Any] | tuple[type[Any], ...] | Noner'   r(   r)   r*   r+   r,   r-   r-   a   s#      # /W \` r.   c                s>     \        W4      #   \         d     R # i ; iF)r4   	TypeError)r<   r=      &&r,   lenient_isinstancerA   a   s$    !,, s   
 c               $    V ^8  d   QhRRRRRR/# )r%   clsr   r=   r'   r(   r)   r*   r+   r,   r-   r-   h   s!      C   r.   c                s     \        V \        4      ;'       d    \        W4      #   \         d&    \        T \        P
                  4      '       d    R # h i ; ir>   )r4   typeZ
issubclassr?   r   ZWithArgsTypes)rC   r=   r@   r,   lenient_issubclassrE   h   sI    #t$HHC)HH c=6677s   % % +AAc               r$   )r%   rC   r   r'   zTypeGuard[type[BaseModel]]r)   r*   r+   r,   r-   r-   q   s     G G G : Gr.   c                sB    \        4       p\        W4      ;'       d    WJ# )zReturns true if cls is a _proper_ subclass of BaseModel, and provides proper type-checking,
unlike raw calls to lenient_issubclass.
)r   rE   )rC   r!      & r,   is_model_classrG   q   s"     )*Ic-FF#2FFr.   c               r$   )r%   
identifierstrr'   r(   r)   r*   r+   r,   r-   r-   z   s     K KC KD Kr.   c                sh    V P                  4       ;'       d    \        P                  ! V 4      '       * # )zChecks that a string is a valid identifier and not a Python keyword.
:param identifier: The identifier to test.
:return: True if the identifier is valid.
)ZisidentifierkeywordZ	iskeyword)rH   r/   r,   is_valid_identifierrK   z   s)    
 ""$JJW->->z-J)JJr.   KeyTypec               $    V ^8  d   QhRRRRRR/# )r%   mappingzdict[KeyType, Any]updating_mappingsr'   r)   r*   r+   r,   r-   r-      s$      + AS Xj r.   c                s   V P                  4       pV Fn  pVP                  4        FW  w  rEWB9   dI   \        W$,          \        4      '       d-   \        V\        4      '       d   \	        W$,          V4      W$&   KS  WRV&   KY  	  Kp  	  V# r3   )copyitemsr4   dictdeep_update)rN   rO   Zupdated_mappingZupdating_mappingkr2   s   &*    r,   rS   rS      ss    llnO-$**,DA#
?3Et(L(LQ[\]_cQdQd%01CQ%G"%&"	 - . r.   c               r;   )r%   rN   zdict[Any, Any]updater   r'   Noner)   r*   r+   r,   r-   r-      s&     G G^ Gs Gt Gr.   c                s    T P                  VP                  4        UUu/ uF  w  r#Vf   K  W#bK  	  upp4       R # u uppi r3   )rU   rQ   )rN   rU   rT   r2   s   &,  r,   update_not_nonerW      s.    NNV\\^E^TQqDAD^EFEs   <
<
Tname_factoryc               r;   )r%   
input_listzlist[T] | tuple[T, ...]rY   zCallable[[T], str]r'   zlist[T]r)   r*   r+   r,   r-   r-      s(      ' % 	r.   c               s    . p. pV  FH  pV! V4      pWS9  d%   VP                  V4       VP                  V4       K5  WBVP                  V4      &   KJ  	  V# )zMake a list unique while maintaining order.
We update the list if another one with the same name is set
(e.g. model validator overridden in subclass).
)ZappendZindex)rZ   rY   ZresultZresult_namesr2   Zv_names   &$    r,   unique_listr[      s[     F La%'MM!12<%%f-.  Mr.   c                  s    ] tR t^tRtRtR R ltR R ltR R ltR R	 lt	R
 R lt
]RR R ll4       t]R R l4       t]R R l4       t]R R l4       tR R ltRtR# )
ValueItemszOClass for more convenient calculation of excluded or included fields on values.c               r;   )r%   valuer   rQ   $AbstractSetIntStr | MappingIntStrAnyr'   rV   r)   r*   r+   r,   r-   ValueItems.__annotate__   s#     . .c .*N .SW .r.   c                	s    V P                  V4      p\        V\        \        34      '       d   V P	                  V\        V4      4      pW n        R # r3   )_coerce_itemsr4   r5   r6   _normalize_indexesZlen_items)selfr]   rQ      &&&r,   __init__ZValueItems.__init__   s>    ""5)edE]++++E3u:>E(-r.   c               r$   r%   itemr   r'   r(   r)   r*   r+   r,   r-   r_      s     3 3 3 3r.   c                sV    V P                  V P                  P                  V4      4      # )zGCheck if item is fully excluded.

:param item: key or index of a value
)is_truerb   getrc   rg   r@   r,   is_excludedZValueItems.is_excluded   s     
 ||DKKOOD122r.   c               r$   rf   r)   r*   r+   r,   r-   r_      s     # # # #r.   c                s    WP                   9   # )zPCheck if value is contained in self._items.

:param item: key or index of value
rb   rj   r@   r,   is_includedZValueItems.is_included   s    
 {{""r.   c               r$   )r%   ez	int | strr'   z+AbstractSetIntStr | MappingIntStrAny | Noner)   r*   r+   r,   r-   r_      s     8 8Y 8+V 8r.   c                sn    V P                   P                  V4      pV P                  V4      '       g   V# R# )z}:param e: key or index of element on value
:return: raw values for element if self._items is dict and contain needed element
N)rb   ri   rh   )rc   rn   rg   s   && r,   for_elementZValueItems.for_element   s/     {{q!<<--t747r.   c               r;   )r%   rQ   r   v_lengthintr'   zdict[int | str, Any]r)   r*   r+   r,   r-   r_      s#     #  # (8 # C # L` # r.   c                s   / pRpVP                  4        F  w  rV\        V\        4      '       gI   \        V\        4      '       g3   V P	                  V4      '       g   \        RV RVP                   24      hVR8X  d   V P                  V4      pK}  \        V\        4      '       g   \        R4      hV^ 8  d	   W%,           MTpV P                  WcP                  V4      4      W7&   K  	  V'       g   V# V P	                  V4      '       d'   \        V4       F  pVP                  VR4       K  	  V# \        V4       FA  pVP                  V/ 4      pV P	                  V4      '       d   K.  V P                  WH4      W5&   KC  	  V# )a-  :param items: dict or set of indexes which will be normalized
:param v_length: length of sequence indexes of which will be

>>> self._normalize_indexes({0: True, -2: True, -1: True}, 4)
{0: True, 2: True, 3: True}
>>> self._normalize_indexes({'__all__': True}, 4)
{0: True, 1: True, 2: True, 3: True}
Nz,Unexpected type of exclude value for index "z" Z__all__zExcluding fields from a sequence of sub-models or dicts must be performed index-wise: expected integer keys or keyword "__all__".)rQ   r4   r   AbstractSetrh   r?   	__class___coerce_valuerq   mergeri   ZrangeZ
setdefault)	rc   rQ   rp   Znormalized_itemsZ	all_itemsZir2   Znormalized_iZnormalized_items	   &&&      r,   ra   ZValueItems._normalize_indexes   sY    24	KKMDAq'**jK.H.HDLLYZOO"NqcQSTUT_T_S` abbI~ ..q1	a%%A  ,-q58<aL-1ZZ;O;OP\;]-^* " ##<<	""8_ ++As3 %##xA.99!R@O<<00&*jj&L # !  r.   c               s(    V ^8  d   QhRRRRRRRR/# )r%   baser   override	intersectr(   r'   r)   r*   r+   r,   r-   r_      s(     # # # # # #r.   c                sZ   V P                  V4      pV P                  V4      pVf   V# V P                  V4      '       g   Vf   V# V P                  V4      '       d   V'       d   V# T# V'       d;   V Uu. uF  qDV9   g   K  VNK  	  upV Uu. uF  qDV9   g   K  VNK  	  up,           pM*\        V4      V Uu. uF  qDV9  g   K  VNK  	  up,           p/ pV F?  pV P                  VP	                  V4      VP	                  V4      VR7      pVf   K;  WvV&   KA  	  V# u upi u upi u upi )a   Merge a `base` item with an `override` item.

Both `base` and `override` are converted to dictionaries if possible.
Sets are converted to dictionaries with the sets entries as keys and
Ellipsis as values.

Each key-value pair existing in `base` is merged with `override`,
while the rest of the key-value pairs are updated recursively with this function.

Merging takes place based on the "union" of keys if `intersect` is
set to `False` (default) and on the intersection of keys if
`intersect` is set to `True`.
)rx   )rt   rh   r5   ru   ri   )rC   rv   rw   rx   rT   Z
merge_keysZmergedZmerged_items   &&&&    r,   ru   ZValueItems.merge   s    $$X.  &K;;tO;;x  $42(2 %);T(]!!T;(>`(Q[_V_qq(>``Jd(&L(Qtmqq(&LLJ')A))DHHQKaI)VK&'q	 
  <>`&Ls$   5DDD#D#9D(D(c               r$   )r%   rQ   r^   r'   r   r)   r*   r+   r,   r-   r_     s      A FV r.   c                	s    \        V \        4      '       d    V # \        V \        4      '       d   \        P	                  V R 4      p V # \        V RR4      p\        RV 24      h).rs   z???z!Unexpected type of exclude value )r4   r   rr   rR   ZfromkeysZgetattrr?   )rQ   Z
class_namerF   r,   r`   ZValueItems._coerce_items  sb    eW%%  {++MM%-E  !U;J?
|LMMr.   c                    V ^8  d   QhRRRR/# )r%   r]   r   r'   r)   r*   r+   r,   r-   r_   &  s     ( (# (# (r.   c                	s^    Ve   V P                  V4      '       d   V# V P                  V4      # r3   )rh   r`   )rC   r]   r@   r,   rt   ZValueItems._coerce_value%  s+    =CKK..L  ''r.   c               r$   r1   r)   r*   r+   r,   r-   r_   ,  s     % %3 %4 %r.   c                	s"    V R J ;'       g    V RJ # )T.r)   r9   r/   r,   rh   ZValueItems.is_true+  s    Dy$$AH$r.   c                   V ^8  d   QhRR/# )r%   r'   z_repr.ReprArgsr)   r*   r+   r,   r-   r_   /  s     % %~ %r.   c                	s     R V P                   3.# r3   rl   rc   r/   r,   __repr_args__ZValueItems.__repr_args__/  s    t{{#$$r.   rl   N)rb   Z_typer>   )__name__
__module____qualname____firstlineno____doc__	__slots__re   rk   rm   ro   ra   Zclassmethodru   Zstaticmethodr`   rt   rh   r|   __static_attributes__r)   r.   r,   r\   r\      s    Y#I.3#8# J # #J   ( (
 % %% %r.   r\   c               r;   )r%   namerI   	get_valuezCallable[[], T]r'   rX   r)   r*   r+   r,   r-   r-   5  s    KKKKQKr.   c                    R # r3   r)   r   r   r@   r,   LazyClassAttributer   5  s    r.   c                  sH    ] tR tRtRtR R lt]R R l4       tR R ltR	t	R
# )r   i9  zA descriptor exposing an attribute only accessible on a class (hidden from instances).

The attribute is lazily computed and cached during the first access.
c               r;   )r%   r   rI   r   zCallable[[], Any]r'   rV   r)   r*   r+   r,   r-   LazyClassAttribute.__annotate__?  s"     	' 	' 	'1B 	't 	'r.   c                	s    Wn         W n        R # r3   r   )rc   r   r   rd   r,   re   ZLazyClassAttribute.__init__?  s    I&Nr.   c               rz   )r%   r'   r   r)   r*   r+   r,   r-   r   D  s     	$ 	$3 	$r.   c                	s"    V P                  4       # r3   )r   r{   r/   r,   r]   ZLazyClassAttribute.valueC  s    >>##r.   c               r;   )r%   instancer   ownerz	type[Any]r'   rV   r)   r*   r+   r,   r-   r   G  s&     	a 	aC 	a	 	ad 	ar.   c                	sp    Vf   V P                   # \        V P                  : RVP                  : R24      h)Nz attribute of z is class-only)r]   ZAttributeErrorr   r}   )rc   r   r   rd   r,   __get__ZLazyClassAttribute.__get__G  s4    zz! DII=u~~>PP^!_``r.   )r   r   N)
r}   r~   r   r   r   re   r	   r]   r   r   r)   r.   r,   r   r   9  s,    	
	' 
	$ 
	$	a 	ar.   r   Objc               ry   )r%   objr   r'   r)   r*   r+   r,   r-   r-   P  s        r.   c                s    V \         J d   V # V P                  pV\        9   d   V #  V '       g(   V\        9   d   V\        J d   V # V P                  4       # \        T 4      #   \        \        \        3 d     L#i ; i)zReturn type as is for immutable built-in types
Use obj.copy() for built-in empty collections
Use copy.deepcopy() for non-empty collections and unknown objects.
)
r   rs   r"   r#   r6   rP   r?   Z
ValueErrorZRuntimeErrorr   )r   Zobj_typerF   r,   smart_deepcopyr   P  sv    
 g~
}}H22
x#66"e+3;;
 C=	 z<0 s   A! A! A! !A:9A:c               rB   )r%   leftzIterable[Any]rightr'   r(   r)   r*   r+   r,   r-   r-   h  s!       m  r.   c                sJ    \        W\        R7       F  w  r#W#Jg   K   R# 	  R# )zCheck that the items of `left` are the same objects as those in `right`.

>>> a, b = object(), object()
>>> all_identical([a, b, a], [a, b, a])
True
>>> all_identical([a, b, [a]], [a, b, [a]])  # new list object, while "equal" is not "identical"
False
)Z	fillvalueFT)r   	_SENTINEL)r   r   Z	left_itemZ
right_items   &&  r,   all_identicalr   h  s'     "-TI!N	& "O r.   c               rM   )r%   ar   br'   r)   r*   r+   r,   r-   r-   w  s!     % %# %# %# %r.   c                s    V e   V # T# )zTReturn the first argument if it is not `None`, otherwise return the second argument.r)   )r   r   r@   r,   get_first_not_noner   w  s    1$1$r.   T)Zfrozenc                  sZ    ] tR tRt$ RtRtR]R&   R R lt]'       d   R R lt	R	t
R
# R	t
R
# )SafeGetItemProxyi|  zWrapper redirecting `__getitem__` to `get` with a sentinel value as default

This makes is safe to use in `operator.itemgetter` when some keys may be missing
wrappedzMapping[str, Any]c               r$   )r%   keyrI   r'   r   r)   r*   r+   r,   r-   SafeGetItemProxy.__annotate__  s     0 0s 0# 0r.   c               	sB    V P                   P                  V\        4      # r3   )r   ri   r   rc   r      ""r,   __getitem__ZSafeGetItemProxy.__getitem__  s    ||Y//r.   c               r$   )r%   r   rI   r'   r(   r)   r*   r+   r,   r-   r     s     	2 	2C 	2t 	2r.   c               	s8    V P                   P                  V4      # r3   )r   __contains__r   r   r,   r   ZSafeGetItemProxy.__contains__  s    <<,,S11r.   r)   N)r   )r}   r~   r   r   r   r   __annotations__r   r   r   r   r)   r.   r,   r   r   |  s-     I0 	2 	2 r.   r   _ModelTr!   )Zbound_RTc                  sx    ] tR tRtRtR R lt]R R l4       t]]! RRR	7      R
 R l4       4       tR R ltRt	R# )deprecated_instance_propertyi  a  A decorator exposing the decorated class method as a property, with a warning on instance access.

This decorator takes a class method defined on the `BaseModel` class and transforms it into
an attribute. The attribute can be accessed on both the class and instances of the class. If accessed
via an instance, a deprecation warning is emitted stating that instance access will be removed in V3.
c               r$   )r%   fgetzCallable[[type[_ModelT]], _RT]r'   rV   r)   r*   r+   r,   r-   )deprecated_instance_property.__annotate__  s      ; 4 r.   c               	s    Wn         R # r3   r   )rc   r   r   r,   re   Z%deprecated_instance_property.__init__  s    	r.   c               r;   )r%   r   rV   objtypetype[_ModelT]r'   r   r)   r*   r+   r,   r-   r     s    III}IIr.   c                	r   r3   r)   rc   r   r   rd   r,   r   $deprecated_instance_property.__get__  s    FIr.   zAccessing this attribute on the instance is deprecated, and will be removed in Pydantic V3. Instead, you should access this attribute from the model class.N)categoryc               r;   )r%   r   r   r   r   r'   r   r)   r*   r+   r,   r-   r     s    LLL-LCLr.   c                	r   r3   r)   r   rd   r,   r   r     s	     JMr.   c               r;   )r%   r   z_ModelT | Noner   r   r'   r   r)   r*   r+   r,   r-   r     s!     6 6 6 63 6r.   c                	s$   Ven   \         P                  R8  d   V P                  P                  MV P                  P                  P                  p\
        P                  ! RV: R2\        ^R7       V P                  P                  W4      ! 4       # )NzAccessing the zi attribute on the instance is deprecated. Instead, you should access this attribute from the model class.)r   Z
stacklevel)i   i
   )	sysZversion_infor   r}   Z__func__warningsZwarnr   r   )rc   r   r   Z	attr_names   &&& r,   r   r     s     ##w. 		""YY''00  MM  .R R3	 yy  355r.   r   )
r}   r~   r   r   r   re   r   r   r   r   r)   r.   r,   r   r     sP     I I	J
 M  M6 6r.   r   )g__conditional_annotations__r   Z
__future__r    Z_annotationsZdataclassesrJ   r   r   ZweakrefZcollectionsr   r   r   Zcollections.abcr   r   r   r   rr   rP   r   Z	functoolsr	   Zinspectr
   Z	itertoolsr   Ztypesr   r   r   r   r   r   Ztypingr   r   r   r   r   Zpydantic_corer   Ztyping_extensionsr   r   r   Zpydanticr   Z r   r   Z_import_utilsr   rq   rI   r   r   r    Zmainr!   ZfloatZcomplexr(   ZbytesrD   ZNoneTypeZrefZNotImplementedrs   ZEllipsisr"   r5   r7   r6   r8   rR   r#   r0   r:   rA   rE   rG   rK   rL   rS   rW   rX   r[   ZRepresentationr\   r   r   r   Zobjectr   r   r   Z	dataclassr   r   r   r   )r   s   @r,   <module>r      s  
 3   
   7 7 7 7 .  %  ! d d A A ! > > / " 3")#s("3gc3h6G"GiG#.s#3k#6F#FyF 
 		KK '3  0 				' ^ 	V&NGK )
G CL (+,C%%% C%L Ka a( en* H	%
 d#2 2 $22 );
/en$677C<#8 $6r.   