ó
    °"³j×"  ã                  ó®  • % S r SSKJr  SSKrSSKrSSK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rSSKrSS	K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  \\ \!\"\#" S5      4r$Sr%\&\\4   r'\\'/S4   r(\)" 5       r*S\+S'   SS.SS jjr,SS.       SS jjr-S S jr.S S jr/        S!S jr0S"S jr1S#S jr2S$S jr3S$S jr4S%S jr5S&S jr6g)'aÕ  Turns request params into plain data that can be serialized, logged and sent again on a retry.

This takes two phases. `copy_tree` walks the params once, in document order, copying every
container on the way: mappings into dicts without their `NotGiven` / `Omit` entries, sequences,
sets and iterators into lists, pydantic models into their dumped form and dates into their ISO
8601 string. In a request body it also collects the slots holding a file that is to be sent
base64-encoded, but leaves reading them to the second phase -- the only step in which
`prepare_request_data` and `async_prepare_request_data` differ. Query params never involve any
IO: a path among them stays in place and is later rendered as its string.
é    )ÚannotationsN)ÚIOÚAny)Údate)ÚCallable)ÚLiteralé   )Úis_sent_as_listÚopenapi_dumps_strÚopenapi_model_dump)Ú
is_mappingé   )Úis_base64_file_input)ÚOmitÚNotGivenÚBase64FileInput)ÚFILE_INPUT_MARKERSi † r   ÚEXIT_CONTAINERF)Úkeep_top_level_omitc               óX   • [        XUS9u  p4U H  u  pV[        XV   5      XV'   M     US   $ )a:  Copy request params into plain data that can be serialized and re-sent.

Drops `NotGiven` / `Omit` entries (`keep_top_level_omit` keeps `Omit` directly under the
root, for `_merge_mappings`), turns sequences, sets and iterators into lists, dumps pydantic
models and formats dates as ISO 8601 strings. In a `"body"`, a path / file object found under
`field` of a mapping matching one of `FILE_INPUT_MARKERS` is read and base64-encoded --
nowhere else, and never in a `"query"`.
Never mutates the caller's containers; a container that contains itself raises `ValueError`.
©Úlocationr   r   )Ú	copy_treeÚread_base64©Údatar   r   ÚrootÚ
file_slotsÚ	containerÚkeys          ÚV/home/mande/repo/quber/.venv/lib/python3.13/site-packages/anthropic/_utils/_prepare.pyÚprepare_request_datar"   /   s9   € ô ! ÐNaÑbÑ€DÛ$‰ˆ	Ü$ Y¡^Ó4ˆ	‹ñ %ð �‰7€Nó    c             ƒ  ót   #   • [        XUS9u  p4U H  u  pV[        XV   5      I Sh  v•N XV'   M     US   $  N7f)zV`prepare_request_data`, reading `pathlib.Path` inputs without blocking the event loop.r   Nr   )r   Úasync_read_base64r   s          r!   Úasync_prepare_request_datar&   @   sE   é € ô ! ÐNaÑbÑ€DÛ$‰ˆ	Ü0°±Ó@×@ˆ	‹ñ %ð �‰7€Nñ Aùs   ‚$8¦6§8c               ó&   • [        [        XS95      $ )z3The JSON text that `data` is sent as once prepared.©r   )r   r"   ©r   r   s     r!   Úserialize_datar*   K   s   € äÔ1°$ÑJÓKÐKr#   c             ƒ  óB   #   • [        [        XS9I Sh  v•N 5      $  N7f)zP`serialize_data`, reading `pathlib.Path` inputs without blocking the event loop.r(   N)r   r&   r)   s     r!   Úasync_serialize_datar,   P   s   é € äÔ#=¸dÑ#V×VÓWÐWÑVùs   ‚”•	c               ó  • U /n/ nUS:X  a  [         OSn0 nUS4/nUR                  nU(       GaÑ  UR                  5       u  pšU	[        L a  Xj	 M'  Xš   n[	        U5      n[        U5      nU[        L d  U[        La�  [        U5      (       aq  [        X¸U=(       a    X“L S9nU HR  u  nnnUR                  U5      U:X  d  M  [        UR                  U5      5      (       d  M?  UR                  UU45        MT     XéU
'   OU[        L d  [        U5      (       a  [        X¸5      Xš'   OX[        U[        R                   5      (       a  [#        U5      Xš'   O+[        U[$        5      (       a  UR'                  5       Xš'   OGMS  [        U5      U:”  am  [)        U5      nUU;   a  [+        S5      e[        U5      [,        :¼  a  [+        S5      eX¶U'   X}S nUR                  [        U45        UR/                  5         UX}S& U(       a  GMÑ  X44$ )z\Returns `[copied data]` and the slots whose file input is still to be read (in a body only).Úbody© r   )Ú	keep_omitzCircular reference detectedz!Exceeds the maximum nesting depthN)r   ÚappendÚpopr   ÚtypeÚlenÚdictÚlistr   Úcopy_mappingÚgetr   r
   Ú
copy_itemsÚ
isinstanceÚpydanticÚ	BaseModelr   r   Ú	isoformatÚidÚ
ValueErrorÚ	MAX_DEPTHÚreverse)r   r   r   r   r   ÚmarkersÚ	ancestorsÚpendingÚvisit_laterr   r    ÚvalueÚkindÚinner_startÚcopiedÚdiscriminatorÚtagÚfieldÚidentÚinners                       r!   r   r   U   sà  € ð
 �f€DØ€JØ$,°Ó$6Õ ¸B€Gð $&€Ið ! !˜9˜+€GØ—.‘.€Kç
Ø Ÿ™›‰ˆ	ØœÒ&Ø�Ùà!™ˆÜ�E‹{ˆÜ˜'“lˆð ”4Š<˜D¬Ò,´¸E×1BÑ1BÜ! %Ð@S×@iÐXaÐXiÑjˆFÛ-4Ñ)�˜s EØ—:‘:˜mÓ,°Õ3Ô8LÈVÏZÉZÐX]ÓM^×8_Ó8_Ø×%Ñ% v¨u oÖ6ñ .5ð $�cŠNØ”TŠ\œ_¨U×3Ñ3Ü'¨Ó;ˆIŠNÜ˜œx×1Ñ1×2Ñ2Ü/°Ó6ˆIŠNÜ˜œt×$Ñ$Ø"Ÿ_™_Ó.ˆIŠNò äˆw‹<˜+Ó%ä�u“IˆEØ˜	Ó!Ü Ð!>Ó?Ð?ä�9‹~¤Ó*Ü Ð!DÓEÐEà$�eÑð ˜LÐ)ˆEØ�L‰Lœ.¨%Ð0Ô1Ø�M‰MŒOØ$)ˆG�LÐ!÷Y ‰'ð\ ÐÐr#   c               ó
  • 0 nU R                  5        Hl  u  pE[        U5      [        ;   a  XSU'   M  [        U[        [
        45      (       d  XSU'   U" X445        MH  U(       d  MQ  [        U[
        5      (       d  Mh  XSU'   Mn     U$ )z�Copies the `Mapping` into a dict without its `NotGiven` / `Omit` entries.

Schedules a visit to the slots of the copy whose value may need preparing itself.
)Úitemsr3   ÚPLAIN_TYPESr:   r   r   )ÚmappingrE   r0   rI   r    rF   s         r!   r7   r7   —   sr   € ð
 !#€FØ—m‘m–o‰
ˆÜ�‹;œ+Ó%Ø�3‹KÜ˜E¤H¬dÐ#3×4Ñ4Ø�3‰KÙ˜˜Ö&ßˆYœ: e¬T×2Ó2ð  �3‹Kñ &ð €Mr#   c                ó€   • [        U 5      n[        U5       H#  u  p4[        U5      [        ;  d  M  U" X#45        M%     U$ )zcCopies the items into a list, scheduling a visit to the slots whose item may need preparing itself.)r6   Ú	enumerater3   rQ   )rP   rE   rI   ÚiÚitems        r!   r9   r9   «   s9   € ä�%‹[€FÜ˜VÖ$‰ˆÜ�‹:œ[Õ(Ù˜˜Ö$ñ %ð €Mr#   c                ó¸   • [        U [        R                  5      (       a  [        X R	                  5       5      $ [        U [        U 5      R                  5       5      $ ©N)r:   ÚpathlibÚPathÚ	b64encodeÚ
read_bytesÚreadableÚread©Úfiles    r!   r   r   µ   s?   € Ü�$œŸ™×%Ñ%Ü˜Ÿ™Ó0Ó1Ð1ä�Tœ8 D›>×.Ñ.Ó0Ó1Ð1r#   c              ƒ  óþ   #   • [        U [        R                  5      (       a6  [        U [        R                  " U 5      R                  5       I S h  v•N 5      $ [        U [        U 5      R                  5       5      $  N+7frX   )r:   rY   rZ   r[   Úanyior\   r]   r^   r_   s    r!   r%   r%   ¼   sX   é € Ü�$œŸ™×%Ñ%Ü˜¤U§Z¢Z°Ó%5×%@Ñ%@Ó%B×BÓCÐCä�Tœ8 D›>×.Ñ.Ó0Ó1Ð1ñ  Cùs   ‚AA=ÁA;
Á,A=c                ót   • [        U [        R                  5      (       a  [        S[	        U 5       S35      eU $ )z]The file object to read; any other `os.PathLike` is rejected without touching the filesystem.zCannot read z-; only pathlib.Path and file objects are read)r:   ÚosÚPathLikeÚ	TypeErrorr3   r_   s    r!   r]   r]   Ã   s1   € ä�$œŸ™×$Ñ$Ü˜,¤t¨D£z lÐ2_Ð`ÓaÐaà€Kr#   c                óô   • [        U[        5      (       a  UR                  5       n[        U[        5      (       d  [	        SU  S[        U5       35      e[        R                  " U5      R                  S5      $ )NzCould not read bytes from z; Received Úascii)	r:   ÚstrÚencodeÚbytesÚRuntimeErrorr3   Úbase64r[   Údecode)r`   Úcontents     r!   r[   r[   Ë   sa   € Ü�'œ3×ÑØ—.‘.Ó"ˆä�gœu×%Ñ%ÜÐ7¸°v¸[ÌÈgËÈÐXÓYÐYä×Ò˜GÓ$×+Ñ+¨GÓ4Ð4r#   )r   Úobjectr   úLiteral['body', 'query']r   ÚboolÚreturnr   )r   rp   r   rq   rs   ri   )r   rp   r   rq   r   rr   rs   ztuple[list[Any], list[Slot]])rR   r   rE   Ú
VisitLaterr0   rr   rs   zdict[Any, object])rP   r   rE   rt   rs   zlist[object])r`   r   rs   ri   )r`   r   rs   z	IO[bytes])r`   r   ro   rp   rs   ri   )7Ú__doc__Ú
__future__r   rd   rm   rY   Útypingr   r   Údatetimer   Úcollections.abcr   Útyping_extensionsr   rb   r;   Ú_jsonr
   r   r   Ú_utilsr   Ú_filesr   Ú_typesr   r   r   Ú
_constantsr   ri   ÚintÚfloatrr   r3   rQ   r@   ÚtupleÚSlotrt   rp   r   Ú__annotations__r"   r&   r*   r,   r   r7   r9   r   r%   r]   r[   r/   r#   r!   Ú<module>r…      s  ðò	õ #ã 	Û Û ß Ý Ý $Ý %ã Û ç IÑ IÝ Ý )ß 4Ñ 4Ý +à�C˜ ¡d¨4£jÐ1€ð €	ð ˆS�#ˆX�€Ø�t�f˜d�lÑ#€
ñ “h€�Ó ð kp÷ ð$ V[ñØ
ðØ7ðØNRðàõôLô
Xð
?Ø
ð?Ø7ð?ØNRð?à!ô?ôDô(ô2ô2ôõ5r#   