Ë
    8ø»j   ã                  ó¨   — d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
mZmZ d dlmZmZ erd dlmZ ddd	œ	 	 	 	 	 	 	 dd
„Zedd„«       Zdd„Zy)é    )ÚannotationsN)Ú	b64encode)Úcache)ÚisawaitableÚiscoroutine)ÚTYPE_CHECKINGÚAny)ÚWebhookCreateÚWebhookRepresentation)ÚWebhooksList)Úcontent_typeÚcontent_encodingc               ó\  — t        | dd«      }t        |«      ru |«       } t        | «      r&t        | «      r| j	                  «        t        d«      ‚t        | t        t        t        f«      s"t        dt        | «      j                  › d�«      ‚|xs dj                  «       j                  «       }|dvr;t        | t        t        f«      s%t        dt        | «      j                  › d	|› d
�«      ‚|s.t        | t        t        f«      rd}nt        | t        «      rd}nd}d|v rGt        | t        t        t        f«      s,t        j                  | ddt        ¬«      j!                  d«      } t        | t        t        t        f«      s%t        dt        | «      j                  › d|›d�«      ‚| |fS )aÏ  Encode a value for storage in a key-value store record.

    Args:
        value: The value to encode. Anything exposing a callable `read` is treated as a file-like object: `read`
            is called with no arguments, so the value is consumed from its current position and buffered in
            memory whole - the object is neither rewound nor closed, and async file-like objects are rejected.
            Any other value is JSON-serialized unless it is already bytes or a string.
        content_type: The content type; if None, it's inferred from the value type.
        content_encoding: The encoding the caller declares the value already carries, if any. Anything other than
            `identity` means the value is compressed, which only a bytes-like payload can be, so any other value
            is rejected. The check belongs here because a file-like value has to be read before its payload type
            is known, and reading it a second time in the caller is not possible.

    Returns:
        A tuple of (encoded_value, content_type).

    Raises:
        TypeError: If the value cannot be encoded into a body the transport accepts, or if it cannot be carrying
            the declared `content_encoding`.
    ÚreadNzjAsync file-like objects are not supported. Await the read yourself and pass the resulting bytes or string.z%Reading the file-like value returned z, expected bytes or str.Ú )r   ÚidentityzCannot upload a z value with `Content-Encoding: z“`. An encoding other than `identity` declares the value is already compressed, so pass the compressed bytes, or a file-like object that reads them.zapplication/octet-streamztext/plain; charset=utf-8zapplication/json; charset=utf-8zapplication/jsonF)Úensure_asciiÚ	allow_nanÚdefaultúutf-8zCannot encode a z
 value as zJ. Pass bytes, a string, or a file-like object, or use a JSON content type.)ÚgetattrÚcallabler   r   ÚcloseÚ	TypeErrorÚ
isinstanceÚbytesÚ	bytearrayÚstrÚtypeÚ__name__ÚstripÚlowerÚjsonÚdumpsÚencode)Úvaluer   r   r   Údeclared_encodings        úS/var/www/html/GAP/venv/lib/python3.12/site-packages/apify_client/_utils/encoding.pyÚ#encode_key_value_store_record_valuer)      s¨  € ô4 �5˜& $Ó'€DÜ�„~Ù“ˆä�uÔÜ˜5Ô!Ø—‘”Üð#óð ô
 ˜%¤%¬´CÐ!8Ô9ÜÐCÄDÈÃK×DXÑDXÐCYÐYqÐrÓsÐsð
 *Ò/¨R×6Ñ6Ó8×>Ñ>Ó@ÐØÐ 0Ñ0¼ÀEÌEÔS\ÐK]Ô9^ÜØœt E›{×3Ñ3Ð4Ð4SÐTdÐSeð f0ð 0ó
ð 	
ñ Ü�eœe¤YÐ/Ô0Ø5‰LÜ˜œsÔ#Ø6‰Là<ˆLà˜\Ñ)´*¸UÄUÌIÔWZÐD[Ô2\ä—
‘
ØØØÜô	
÷
 ‰&�‹/ð 	ô �eœe¤Y´Ð4Ô5ÜØœt E›{×3Ñ3Ð4°J¸|Ð>Nð O<ð <ó
ð 	
ð
 �<Ð Ð ó    c                 óø   — t        t           «       } t        j                  j	                  «       D ]>  \  }}| j                  |«       |j                  €Œ$| j                  |j                  «       Œ@ t        | «      S )zGReturn all field names and aliases declared on `WebhookRepresentation`.)Úsetr   r   Úmodel_fieldsÚitemsÚaddÚaliasÚ	frozenset)ÚkeysÚnameÚinfos      r(   Ú_webhook_representation_keysr5   _   sb   € ô Œs‰8‹:€DÜ+×8Ñ8×>Ñ>Ó@ò !‰
ˆˆdØ�‰�ŒØ�:‰:Ñ!Ø�H‰H�T—Z‘ZÕ ð!ô �T‹?Ðr*   c                óX  — | syt        t           «       }t        «       }| D ]�  }t        |t        «      r|j	                  |«       Œ%t        |t
        «      r|j                  d¬«      n
t        |«      }|j                  «       D ��ci c]  \  }}||v sŒ||“Œ }}}|j	                  t        j                  |«      «       ŒŸ |D �cg c]  }|j                  dd¬«      ‘Œ }}t        j                  |«      j                  d¬«      }	t        |	«      j                  d¬«      S c c}}w c c}w )aw  Encode a list of ad-hoc webhooks to a base64 string for the `webhooks` query parameter.

    Returns `None` for `None` or an empty list, so the query parameter is omitted.

    See `WebhooksList` for the accepted shapes. `WebhookRepresentation` instances are used as-is. `WebhookCreate`
    instances and dict shapes are projected onto the fields `WebhookRepresentation` declares, dropping anything else
    (e.g. persistent-only fields like `condition`). Filtering by the declared field names and aliases means new
    ad-hoc fields added to `WebhookRepresentation` flow through automatically, without touching this function.
    NT)Úby_alias)r7   Úexclude_noner   )ÚencodingÚascii)Úlistr   r5   r   Úappendr
   Ú
model_dumpÚdictr.   Úmodel_validater#   r$   r%   r   Údecode)
ÚwebhooksÚrepresentationsÚallowedÚwebhookÚdataÚkeyr&   ÚfilteredÚrÚjson_strings
             r(   Úencode_webhooks_to_base64rJ   j   s  € ñ ØäÔ0Ñ1Ó3€OÜ*Ó,€Gàò OˆÜ�gÔ4Ô5Ø×"Ñ" 7Ô+Øä4>¸wÌÔ4Vˆw×!Ñ!¨4Ð!Ô0Ô\`ÐahÓ\iˆØ15·±³×P¡: 3¨ÀÈÂ�C˜‘JÐPˆÑPØ×ÑÔ4×CÑCÀHÓMÕNðOð ETÖT¸qˆA�L‰L $°TˆLÕ:ÐT€DÐTÜ—*‘*˜TÓ"×)Ñ)°7Ð)Ó;€KÜ�[Ó!×(Ñ(°'Ð(Ó:Ð:ùó Qùò Us   ÂD!ÂD!ÃD')r&   r	   r   ú
str | Noner   rK   Úreturnz#tuple[bytes | bytearray | str, str])rL   zfrozenset[str])rA   zWebhooksList | NonerL   rK   )Ú
__future__r   r#   Úbase64r   Ú	functoolsr   Úinspectr   r   Útypingr   r	   Úapify_client._modelsr
   r   Úapify_client.typesr   r)   r5   rJ   © r*   r(   ú<module>rU      sl   ðÝ "ã Ý Ý ß ,ß %ç EáÝ/ð /3ÐSWñM!ØðM!Ø!+ðM!ØFPðM!à(óM!ð` òó ðô;r*   