Ë
    -Œ:j‘¯  ã                   ó:	  — U d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZ ddlmZ ddlmZ ddlmZ ddlmZmZ 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m Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& ddlm'Z' ddl(m)Z) ddl*m+Z+  e'jX                  e-«      Z. ed¬«       G d„ d«      «       Z/ ej`                  d«      Z1 ej`                  d«      Z2dee3e3f   de/dz  fd„Z4dZ5dZ6dZ7 ej`                  dejp                  ¬«      Z9 ej`                  dejp                  ¬«      Z: ej`                  d «      Z; ej`                  d!«      Z< ej`                  d"«      Z=h d#£Z>d$e3de?e3dz  e3dz  f   fd%„Z@d$e3de3dz  fd&„ZAd$e3de3dz  fd'„ZBd(ej†                  ddfd)„ZDd(ej†                  ddfd*„ZEd+ejŒ                  ddfd,„ZGdej�                  fd-„ZIdej”                  fd.„ZKe
g ej�                  f   ZLe
g ej”                  f   ZM ejœ                  «       ZOeIaPeLeQd/<   eKaReMeQd0<   daSej�                  dz  eQd1<   d2eLddfd3„ZTd4eMddfd5„ZUdej�                  fd6„ZVdej”                  fd7„ZWdjd8„ZX ej²                  eX«        eZed9«      r ej¶                  eX¬:«       ej¸                  ejº                  fZ^e?e_e`   d;f   eQd<<   d=Zae?ebd;f   eQd><   d?dd@e^eadAdBœdCe+d$e3dDebdEecdFecdGe_e`   e?e_e`   d;f   z  dHebe?ebd;f   z  dIeddeejŒ                  ddf   fdJ„Zed?dd@e^eadKœdCe+d$e3dDebdEecdFecdGe_e`   e?e_e`   d;f   z  dHebe?ebd;f   z  dejŒ                  fdL„Zfed?dd@e^eadKœdCe+d$e3dDebdEecdFecdGe_e`   e?e_e`   d;f   z  dHebe?ebd;f   z  deejŒ                  ddf   fdM„«       ZgdAdNœdCe+d$e3dOeddejŒ                  fdP„Zhd$e3dQe3dz  de3fdR„Zidkd+ejŒ                  dSe3dz  ddfdT„Zj ek«       Zld+ejŒ                  ddfdU„Zm edVe"¬W«      ZndXe_en   dYe3d+ejŒ                  dZedenf
d[„Zod\ZpepD � �cg c]9  }  ej`                  d]| › d^�«      d_f ej`                  d`| › da�«      dbffD ]  }|‘Œ Œ; c}} Zqdce3de3fdd„Zrd(ej†                  de3fde„Zs ej`                  dfejè                  «      Zudge3dz  dhebde3dz  fdi„Zvyc c}} w )lz>Contains utilities to handle HTTP requests in huggingface_hub.é    N)ÚCallableÚ	GeneratorÚMapping)Úcontextmanager)Ú	dataclass)Úquote)ÚAnyÚTypeVar)Úurlparse)ÚOfflineModeIsEnabledé   )Ú	constants)	ÚBadRequestErrorÚBucketNotFoundErrorÚDisabledRepoErrorÚGatedRepoErrorÚHfHubHTTPErrorÚJobNotFoundErrorÚRemoteEntryNotFoundErrorÚRepositoryNotFoundErrorÚRevisionNotFoundErroré   )Úlogging)ÚSliceFileObj)ÚHTTP_METHOD_TT)Úfrozenc                   óX   — e Zd ZU dZeed<   eed<   eed<   dZedz  ed<   dZedz  ed<   y)ÚRateLimitInfoaÿ  
    Parsed rate limit information from HTTP response headers.

    Attributes:
        resource_type (`str`): The type of resource being rate limited.
        remaining (`int`): The number of requests remaining in the current window.
        reset_in_seconds (`int`): The number of seconds until the rate limit resets.
        limit (`int`, *optional*): The maximum number of requests allowed in the current window.
        window_seconds (`int`, *optional*): The number of seconds in the current window.

    Úresource_typeÚ	remainingÚreset_in_secondsNÚlimitÚwindow_seconds)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__Úintr"   r#   © ó    ú]/var/www/html/tokenscope/api/venv/lib/python3.12/site-packages/huggingface_hub/utils/_http.pyr   r   7   s6   … ñ
ð ÓØƒNØÓØ€Eˆ3�‰:ÓØ!%€N�C˜$‘JÔ%r,   r   zL\"(?P<resource_type>\w+)\"\s*;\s*r\s*=\s*(?P<r>\d+)\s*;\s*t\s*=\s*(?P<t>\d+)z'q\s*=\s*(?P<q>\d+).*?w\s*=\s*(?P<w>\d+)ÚheadersÚreturnc                 óæ  — d}d}| D ](  }|j                  «       }|dk(  r| |   }Œ|dk(  sŒ$| |   }Œ* |syt        j                  |«      }|sy|j                  d«      }t	        |j                  d«      «      }t	        |j                  d«      «      }d}	d}
|rKt
        j                  |«      }|r4t	        |j                  d«      «      }	t	        |j                  d«      «      }
t        ||||	|
¬	«      S )
a*  Parse rate limit information from HTTP response headers.

    Follows IETF draft: https://www.ietf.org/archive/id/draft-ietf-httpapi-ratelimit-headers-09.html
    Only a subset is implemented.

    Example:
    ```python
    >>> from huggingface_hub.utils import parse_ratelimit_headers
    >>> headers = {
    ...     "ratelimit": '"api";r=0;t=55',
    ...     "ratelimit-policy": '"fixed window";"api";q=500;w=300',
    ... }
    >>> info = parse_ratelimit_headers(headers)
    >>> info.remaining
    0
    >>> info.reset_in_seconds
    55
    ```
    NÚ	ratelimitzratelimit-policyr   ÚrÚtÚqÚw)r   r    r!   r"   r#   )ÚlowerÚ_RATELIMIT_REGEXÚsearchÚgroupr*   Ú_RATELIMIT_POLICY_REGEXr   )r.   r1   ÚpolicyÚkeyÚ	lower_keyÚmatchr   r    r!   r"   r#   Úpolicy_matchs               r-   Úparse_ratelimit_headersr@   S   s  € ð* !€IØ€FØò "ˆØ—I‘I“Kˆ	Ø˜Ò#Ø ™‰IØÐ,Ó,Ø˜S‘\‰Fð"ñ Øä×#Ñ# IÓ.€EÙØà—K‘K Ó0€MÜ�E—K‘K Ó$Ó%€IÜ˜5Ÿ;™; sÓ+Ó,Ðà€EØ!%€NáÜ.×5Ñ5°fÓ=ˆÙÜ˜×*Ñ*¨3Ó/Ó0ˆEÜ  ×!3Ñ!3°CÓ!8Ó9ˆNäØ#ØØ)ØØ%ôð r,   zx-request-idzX-Amzn-Trace-Idzx-amz-cf-ida  
        # staging or production endpoint
        ^https://[^/]+
        (
            # on /api/repo_type/repo_id
            /api/(models|datasets|spaces)/(.+)
            |
            # or /repo_id/resolve/revision/...
            /(.+)/resolve/(.+)
        )
    )Úflagszz
        # staging or production endpoint
        ^https?://[^/]+
        # on /api/buckets/...
        /api/buckets/
    z:^https?://[^/]+/api/(?:scheduled-jobs|jobs)/[^/]+/([^/?]+)zA^https?://[^/]+/api/(models|datasets|spaces)/([^/]+)(?:/([^/]+))?z)^https?://[^/]+/api/buckets/([^/]+/[^/]+)>	   ÚrawÚblobÚrefsÚtreeÚcommitÚresolveÚrevisionÚsettingsÚdiscussionsÚurlc                 ó  — t         j                  | «      }|syt        j                  j	                  |j                  d«      «      }|j                  d«      |j                  d«      }}|r|t        vr|› d|› �}||fS |}||fS )a,  Extract (repo_type, repo_id) from an API URL.

    Returns canonical repo_type values: "model", "dataset", "space" (or None).

    Examples:
        >>> _parse_repo_info_from_url("https://huggingface.co/api/models/user/repo")
        ("model", "user/repo")
        >>> _parse_repo_info_from_url("https://huggingface.co/api/datasets/user/repo/resolve/main/data.csv")
        ("dataset", "user/repo")
        >>> _parse_repo_info_from_url("https://huggingface.co/api/models/bert-base-cased/resolve/main/config.json")
        ("model", "bert-base-cased")
    ©NNr   r   é   ú/)Ú_REPO_ID_FROM_URL_REGEXr8   r   ÚREPO_TYPES_MAPPINGÚgetr9   Ú_REPO_URL_SUBPATHS)rK   r>   Ú	repo_typeÚfirstÚsecondÚrepo_ids         r-   Ú_parse_repo_info_from_urlrX   ¼   s‹   € ô $×*Ñ*¨3Ó/€EÙØÜ×,Ñ,×0Ñ0°·±¸Q³Ó@€IØ—K‘K “N E§K¡K°£Nˆ6€EÙ�&Ô 2Ñ2Ø�G˜1˜V˜HÐ%ˆð �gÐÐð ˆØ�gÐÐr,   c                 óV   — t         j                  | «      }|r|j                  d«      S dS )z9Extract bucket_id (namespace/name) from a bucket API URL.r   N)Ú_BUCKET_ID_FROM_URL_REGEXr8   r9   ©rK   r>   s     r-   Ú_parse_bucket_id_from_urlr\   Õ   s'   € ä%×,Ñ,¨SÓ1€EÙ"ˆ5�;‰;�q‹>Ð,¨Ð,r,   c                 óV   — t         j                  | «      }|r|j                  d«      S dS )z>Extract the job_id from a (scheduled) job API URL, if present.r   N)Ú_JOB_ID_FROM_URL_REGEXr8   r9   r[   s     r-   Ú_parse_job_id_from_urlr_   Û   s'   € ä"×)Ñ)¨#Ó.€EÙ"ˆ5�;‰;�q‹>Ð,¨Ð,r,   Úrequestc           	      óN  — t        j                  «       rt        d| j                  › d�«      ‚t        | j
                  vrO| j
                  j                  t        «      xs t        t        j                  «       «      | j
                  t        <   | j
                  j                  t        «      }t        j                  d|| j                  | j                  | j
                  j                  d«      du«       t         j                  rt        j                  dt        | «      «       |S )zõ
    Event hook that will be used to make HTTP requests to the Hugging Face Hub.

    What it does:
    - Block requests if offline mode is enabled
    - Add a request ID to the request headers
    - Log the request if debug mode is enabled
    zCannot reach za: offline mode is enabled. To disable it, please unset the `HF_HUB_OFFLINE` environment variable.z%Request %s: %s %s (authenticated: %s)ÚauthorizationNzSend: %s)r   Úis_offline_moder   rK   ÚX_AMZN_TRACE_IDr.   rR   ÚX_REQUEST_IDr(   ÚuuidÚuuid4ÚloggerÚdebugÚmethodÚHF_DEBUGÚ_curlify)r`   Ú
request_ids     r-   Úhf_request_event_hookrn   á   så   € ô × Ñ Ô"Ü"Ø˜GŸK™K˜=ð  )Jð  Kó
ð 	
ô
 ˜gŸo™oÑ-Ø+2¯?©?×+>Ñ+>¼|Ó+LÒ+aÔPSÔTX×T^ÑT^ÓT`ÓPaˆ�‰œÑ(Ø—‘×$Ñ$¤_Ó5€Jô ‡L�LØ/ØØ�‰Ø�‰Ø�‰×Ñ˜OÓ,°DÐ8ôô ×ÒÜ�‰�Z¤¨'Ó!2Ô3àÐr,   c              ƒ   ó    K  — t        | «      S ­w)z3
    Async version of `hf_request_event_hook`.
    )rn   )r`   s    r-   Úasync_hf_request_event_hookrp     s   è ø€ ô ! Ó)Ð)ùs   ‚Úresponsec              ƒ   óÚ   K  — | j                   dk\  rGd| j                  v r8	 t        | j                  d   «      }|dk  r| j	                  «       ƒ d {  –—†  y y y y # t        $ r Y y w xY w7 Œ­w)Né�  zContent-lengthi@B )Ústatus_coder.   r*   Ú
ValueErrorÚaread)rq   Úlengths     r-   Úasync_hf_response_event_hookrx   	  s�   è ø€ Ø×Ñ˜sÒ"ð ˜x×/Ñ/Ñ/ðÜ˜X×-Ñ-Ð.>Ñ?Ó@�ð ˜	Ò!Ø—n‘nÓ&×&Ñ&ð "ð 0ð #øô ò Ùðúð 'ús3   ‚A+¡A ¹A+ÁA)ÁA+Á	A&Á#A+Á%A&Á&A+c                  ó@   — t        j                  dt        gidd¬«      S )zQ
    Factory function to create a `httpx.Client` with the default transport.
    r`   TN©Úevent_hooksÚfollow_redirectsÚtimeout)ÚhttpxÚClientrn   r+   r,   r-   Údefault_client_factoryr€     s'   € ô �<‰<ØÔ!6Ð 7Ð8ØØôð r,   c                  óL   — t        j                  t        gt        gdœdd¬«      S )zV
    Factory function to create a `httpx.AsyncClient` with the default transport.
    )r`   rq   TNrz   )r~   ÚAsyncClientrp   rx   r+   r,   r-   Údefault_async_client_factoryrƒ   "  s,   € ô ×ÑÜ!<Ð =ÔLhÐKiÑjØØôð r,   Ú_GLOBAL_CLIENT_FACTORYÚ_GLOBAL_ASYNC_CLIENT_FACTORYÚ_GLOBAL_CLIENTÚclient_factoryc                 óR   — t         5  t        «        | addd«       y# 1 sw Y   yxY w)a  
    Set the HTTP client factory to be used by `huggingface_hub`.

    The client factory is a method that returns a `httpx.Client` object. On the first call to [`get_session`] the client factory
    will be used to create a new `httpx.Client` object that will be shared between all calls made by `huggingface_hub`.

    This can be useful if you are running your scripts in a specific environment requiring custom configuration (e.g. custom proxy or certifications).

    Use [`get_session`] to get a correctly configured `httpx.Client`.
    N)Ú_CLIENT_LOCKÚclose_sessionr„   )r‡   s    r-   Úset_client_factoryr‹   6  s'   € ô 
ñ 0ÜŒØ!/Ð÷0÷ 0ñ 0ús   ‡�&Úasync_client_factoryc                 ó   — | a y)a¯  
    Set the HTTP async client factory to be used by `huggingface_hub`.

    The async client factory is a method that returns a `httpx.AsyncClient` object.
    This can be useful if you are running your scripts in a specific environment requiring custom configuration (e.g. custom proxy or certifications).
    Use [`get_async_client`] to get a correctly configured `httpx.AsyncClient`.

    <Tip warning={true}>

    Contrary to the `httpx.Client` that is shared between all calls made by `huggingface_hub`, the `httpx.AsyncClient` is not shared.
    It is recommended to use an async context manager to ensure the client is properly closed when the context is exited.

    </Tip>
    N©r…   )rŒ   s    r-   Úset_async_client_factoryr�   G  s
   € ð  $8Ñ r,   c                  óz   — t         €t        5  t        «       a ddd«       t         S t         S # 1 sw Y   t         S xY w)a  
    Get a `httpx.Client` object, using the transport factory from the user.

    This client is shared between all calls made by `huggingface_hub`. Therefore you should not close it manually.

    Use [`set_client_factory`] to customize the `httpx.Client`.
    N)r†   r‰   r„   r+   r,   r-   Úget_sessionr‘   Z  s6   € ô ÐÜñ 	6Ü3Ó5ˆN÷	6äÐŒ>Ð÷	6äÐús   �,¬:c                  ó   — t        «       S )aÌ  
    Return a `httpx.AsyncClient` object, using the transport factory from the user.

    Use [`set_async_client_factory`] to customize the `httpx.AsyncClient`.

    <Tip warning={true}>

    Contrary to the `httpx.Client` that is shared between all calls made by `huggingface_hub`, the `httpx.AsyncClient` is not shared.
    It is recommended to use an async context manager to ensure the client is properly closed when the context is exited.

    </Tip>
    rŽ   r+   r,   r-   Úget_async_sessionr“   i  s   € ô (Ó)Ð)r,   c                  ó˜   — t         } da | �	 | j                  «        yy# t        $ r"}t        j	                  d|› �«       Y d}~yd}~ww xY w)zÚ
    Close the global `httpx.Client` used by `huggingface_hub`.

    If a Client is closed, it will be recreated on the next call to [`get_session`].

    Can be useful if e.g. an SSL certificate has been updated.
    NzError closing client: )r†   ÚcloseÚ	Exceptionrh   Úwarning)ÚclientÚes     r-   rŠ   rŠ   y  sT   € ô €Fð €Nð Ðð	9Ø�L‰L�Nð øô ò 	9Ü�N‰NÐ3°A°3Ð7×8Ñ8ûð	9ús   Œ ž	A	§AÁA	Úregister_at_fork)Úafter_in_child.Ú_DEFAULT_RETRY_ON_EXCEPTIONS)i˜  é­  iô  iö  i÷  iø  Ú_DEFAULT_RETRY_ON_STATUS_CODESé   é   F)Úmax_retriesÚbase_wait_timeÚmax_wait_timeÚretry_on_exceptionsÚretry_on_status_codesÚstreamrj   r¡   r¢   r£   r¤   r¥   r¦   c          	   +   óê  ‡ ‡‡‡‡‡K  — t        |t        «      r|f}t        ‰t        «      r‰fŠdŠ|}	dŠd}
d|v r6t        |d   t        j                  t
        f«      r|d   j                  «       }
t        «       }	 ‰dz  ŠdŠ	 |
�|d   j                  |
«       dt        j                  dt        fˆˆ ˆˆˆˆfd„}|r6 |j                  d‰ ‰dœ|¤Ž5 } ||«      s|–— 	 ddd«       y	 ddd«       n" |j                  d‰ ‰dœ|¤Ž} ||«      s|–— y‰�.t%        ‰«      dz   }t        j                  d|› d‰› d‰› d�«       n!|	}t        j                  d|› d‰› d‰› d�«       t'        j(                  |«       t+        ||	dz  «      }	�Œ# 1 sw Y   Œ€xY w# |$ rS}t        j                  d	|› d
‰ › d‰› �«       t        |t        j                   «      r
t#        «        ‰‰kD  r|‚Y d}~ŒÖd}~ww xY w­w)zfInternal implementation of HTTP backoff logic shared between `http_backoff` and `http_stream_backoff`.r   NÚdatar   rq   r/   c                 óú   •— | j                   ‰vryt        j                  d| j                   › d‰› d‰› �«       ‰‰kD  rt        | «       y| j                   dk(  r#t	        | j
                  «      }|�|j                  Šy)zNHandle response and return True if should retry, False if should return/yield.FzHTTP Error z thrown while requesting ú r�   T)rt   rh   r—   Úhf_raise_for_statusr@   r.   r!   )rq   Úratelimit_infor¡   rj   Únb_triesÚratelimit_resetr¥   rK   s     €€€€€€r-   Ú_should_retryz)_http_backoff_base.<locals>._should_retryÁ  sŽ   ø€ ð ×'Ñ'Ð/DÑDØ ô —‘ ¨X×-AÑ-AÐ,BÐB[Ð\bÐ[cÐcdÐehÐdiÐjÔkØ˜kÒ)Ü'¨Ô1ð !ð ×'Ñ'¨3Ò.Ü%<¸X×=MÑ=MÓ%N�NØ%Ð1Ø*8×*IÑ*I˜àr,   ©rj   rK   ú'z' thrown while requesting rª   zRate limited. Waiting zs before retry [Retry rO   z].zRetrying in z	s [Retry r   r+   )Ú
isinstanceÚtyper*   ÚioÚIOBaser   Útellr‘   Úseekr~   ÚResponseÚboolr¦   r`   rh   r—   ÚConnectErrorrŠ   ÚfloatÚtimeÚsleepÚmin)rj   rK   r¡   r¢   r£   r¤   r¥   r¦   ÚkwargsÚ
sleep_timeÚio_obj_initial_posr˜   r¯   rq   ÚerrÚactual_sleepr­   r®   s   ```   `         @@r-   Ú_http_backoff_baserÄ   ˜  s2  ýè ø€ ô Ð%¤tÔ,Ø2Ð4ÐäÐ'¬Ô-Ø!6Ð 8Ðà€HØ€JØ"&€Oð
 ÐØ�ÑœJ v¨f¡~¼¿	¹	Ä<Ð7PÔQØ# F™^×0Ñ0Ó2Ðä‹]€FØ
Ø�A‰ˆØˆð0	ð "Ð-Ø�v‘×#Ñ#Ð$6Ô7ð¬¯©ð ¼4÷ ò ñ. Ø"�V—]‘]ÐD¨&°cÑD¸VÑDð ÈÙ(¨Ô2Ø&šØ÷ð Ø2÷ð ð
 *˜6Ÿ>™>ÐK°¸SÑKÀFÑK�Ù$ XÔ.Ø"’NØð Ð&Ü  Ó1°AÑ5ˆLÜ�N‰NÐ3°L°>ÐAWÐX`ÐWaÐabÐcnÐboÐoqÐrÕsà%ˆLÜ�N‰N˜\¨,¨°yÀÀ
È!ÈKÈ=ÐXZÐ[Ô\ä�
‰
�<Ô ô ˜¨
°Q©Ó7ˆ
ñ ÷Dð ûð #ò 	Ü�N‰N˜Q˜s˜eÐ#=¸f¸XÀQÀsÀeÐLÔMä˜#œu×1Ñ1Ô2Ü”à˜+Ò%Ø�	ô &ûð	üsW   ˆA;G3ÂAF ÃFÃ F Ã(G3Ã**F ÄA8G3ÆFÆF ÆG0ÆA	G+Ç&G3Ç+G0Ç0G3)r¡   r¢   r£   r¤   r¥   c                ó<   — t        t        d| ||||||ddœ|¤Ž«      S )a0  Wrapper around httpx to retry calls on an endpoint, with exponential backoff.

    Endpoint call is retried on exceptions (ex: connection timeout, proxy error,...)
    and/or on specific status codes (ex: service unavailable). If the call failed more
    than `max_retries`, the exception is thrown or `raise_for_status` is called on the
    response object.

    Re-implement mechanisms from the `backoff` library to avoid adding an external
    dependencies to `hugging_face_hub`. See https://github.com/litl/backoff.

    Args:
        method (`Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"]`):
            HTTP method to perform.
        url (`str`):
            The URL of the resource to fetch.
        max_retries (`int`, *optional*, defaults to `5`):
            Maximum number of retries, defaults to 5 (no retries).
        base_wait_time (`float`, *optional*, defaults to `1`):
            Duration (in seconds) to wait before retrying the first time.
            Wait time between retries then grows exponentially, capped by
            `max_wait_time`.
        max_wait_time (`float`, *optional*, defaults to `8`):
            Maximum duration (in seconds) to wait before retrying.
        retry_on_exceptions (`type[Exception]` or `tuple[type[Exception]]`, *optional*):
            Define which exceptions must be caught to retry the request. Can be a single type or a tuple of types.
            By default, retry on `httpx.TimeoutException` and `httpx.NetworkError`.
        retry_on_status_codes (`int` or `tuple[int]`, *optional*, defaults to `(429, 500, 502, 503, 504)`):
            Define on which status codes the request must be retried. By default, retries
            on rate limit (429) and server errors (5xx).
        **kwargs (`dict`, *optional*):
            kwargs to pass to `httpx.request`.

    Example:
    ```
    >>> from huggingface_hub.utils import http_backoff

    # Same usage as "httpx.request".
    >>> response = http_backoff("GET", "https://www.google.com")
    >>> response.raise_for_status()

    # If you expect a Gateway Timeout from time to time
    >>> http_backoff("PUT", upload_url, data=data, retry_on_status_codes=504)
    >>> response.raise_for_status()
    ```

    > [!WARNING]
    > When using `requests` it is possible to stream data by passing an iterator to the
    > `data` argument. On http backoff this is a problem as the iterator is not reset
    > after a failed call. This issue is mitigated for file objects or any IO streams
    > by saving the initial position of the cursor (with `data.tell()`) and resetting the
    > cursor between each call (with `data.seek()`). For arbitrary iterators, http backoff
    > will fail. If this is a hard constraint for you, please let us know by opening an
    > issue on [Github](https://github.com/huggingface/huggingface_hub).
    F©rj   rK   r¡   r¢   r£   r¤   r¥   r¦   r+   )ÚnextrÄ   ©rj   rK   r¡   r¢   r£   r¤   r¥   r¿   s           r-   Úhttp_backoffrÉ   ù  sA   € ôB Üð 
	
ØØØ#Ø)Ø'Ø 3Ø"7Øñ
	
ð ñ
	
óð r,   c             +   óH   K  — t        d| ||||||ddœ|¤ŽE d{  –—†  y7 Œ­w)aŽ  Wrapper around httpx to retry calls on an endpoint, with exponential backoff.

    Endpoint call is retried on exceptions (ex: connection timeout, proxy error,...)
    and/or on specific status codes (ex: service unavailable). If the call failed more
    than `max_retries`, the exception is thrown or `raise_for_status` is called on the
    response object.

    Re-implement mechanisms from the `backoff` library to avoid adding an external
    dependencies to `hugging_face_hub`. See https://github.com/litl/backoff.

    Args:
        method (`Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"]`):
            HTTP method to perform.
        url (`str`):
            The URL of the resource to fetch.
        max_retries (`int`, *optional*, defaults to `5`):
            Maximum number of retries, defaults to 5 (no retries).
        base_wait_time (`float`, *optional*, defaults to `1`):
            Duration (in seconds) to wait before retrying the first time.
            Wait time between retries then grows exponentially, capped by
            `max_wait_time`.
        max_wait_time (`float`, *optional*, defaults to `8`):
            Maximum duration (in seconds) to wait before retrying.
        retry_on_exceptions (`type[Exception]` or `tuple[type[Exception]]`, *optional*):
            Define which exceptions must be caught to retry the request. Can be a single type or a tuple of types.
            By default, retry on `httpx.TimeoutException` and `httpx.NetworkError`.
        retry_on_status_codes (`int` or `tuple[int]`, *optional*, defaults to `(429, 500, 502, 503, 504)`):
            Define on which status codes the request must be retried. By default, retries
            on rate limit (429) and server errors (5xx).
        **kwargs (`dict`, *optional*):
            kwargs to pass to `httpx.request`.

    Example:
    ```
    >>> from huggingface_hub.utils import http_stream_backoff

    # Same usage as "httpx.stream".
    >>> with http_stream_backoff("GET", "https://www.google.com") as response:
    ...     for chunk in response.iter_bytes():
    ...         print(chunk)

    # If you expect a Gateway Timeout from time to time
    >>> with http_stream_backoff("PUT", upload_url, data=data, retry_on_status_codes=504) as response:
    ...     response.raise_for_status()
    ```

    <Tip warning={true}>

    When using `httpx` it is possible to stream data by passing an iterator to the
    `data` argument. On http backoff this is a problem as the iterator is not reset
    after a failed call. This issue is mitigated for file objects or any IO streams
    by saving the initial position of the cursor (with `data.tell()`) and resetting the
    cursor between each call (with `data.seek()`). For arbitrary iterators, http backoff
    will fail. If this is a hard constraint for you, please let us know by opening an
    issue on [Github](https://github.com/huggingface/huggingface_hub).

    </Tip>
    TrÆ   Nr+   )rÄ   rÈ   s           r-   Úhttp_stream_backoffrË   I  sB   è ø€ ôL "ð 
ØØØØ%Ø#Ø/Ø3Øñ
ð ñ
÷ 
ò 
ús   ‚"š ›")Úretry_on_errorsrÌ   c                óD  — |ri ndddœ}	 t        d| |dœ|¤ddi¤|¤Ž}t        |«       d|j                  cxk  rdk  r`n 	 |S t        |j                  d   «      }|j
                  d	k(  r4t        |«      j                  |j                  ¬
«      j                  «       }Œ•	 |S )aF  Perform an HTTP request with backoff and follow relative redirects only.

    Used to fetch HEAD /resolve on repo or bucket files.

    This is useful to follow a redirection to a renamed repository without following redirection to a CDN.

    A backoff mechanism retries the HTTP call on errors (429, 5xx, timeout, network errors).

    Args:
        method (`str`):
            HTTP method, such as 'GET' or 'HEAD'.
        url (`str`):
            The URL of the resource to fetch.
        retry_on_errors (`bool`, *optional*, defaults to `False`):
            Whether to retry on errors. If False, no retry is performed (fast fallback to local cache).
            If True, uses default retry behavior (429, 5xx, timeout, network errors).
        **httpx_kwargs (`dict`, *optional*):
            Params to pass to `httpx.request`.
    r+   )r¤   r¥   r°   r|   Fi,  i�  ÚLocationÚ )Úpath)	rÉ   r«   rt   r   r.   ÚnetlocÚ_replacerÐ   Úgeturl)rj   rK   rÌ   Úhttpx_kwargsÚno_retry_kwargsrq   Úparsed_targets          r-   Ú-_httpx_follow_relative_redirects_with_backoffr×   œ  sÏ   € ñ0 ‰¸2ÐXZÑ#[ð ð Üð 
ØØñ
ð ñ
ð #ñ	
ð
 ñ
ˆô 	˜HÔ%ð �(×&Ñ&Ô-¨#Ô-ð 	à€Oô % X×%5Ñ%5°jÑ%AÓBˆMØ×#Ñ# rÒ)ä˜s“m×,Ñ,°-×2DÑ2DÐ,ÓE×LÑLÓN�Øð 	à€Or,   Úendpointc                 ó  — |r|j                  d«      nt        j                  }|t        j                  t        j                  fvr@| j                  t        j                  |«      } | j                  t        j                  |«      } | S )z¤Replace the default endpoint in a URL by a custom one.

    This is useful when using a proxy and the Hugging Face Hub returns a URL with the default endpoint.
    rO   )Úrstripr   ÚENDPOINTÚ_HF_DEFAULT_ENDPOINTÚ_HF_DEFAULT_STAGING_ENDPOINTÚreplace)rK   rØ   s     r-   Úfix_hf_endpoint_in_urlrß   Ï  sf   € ñ
 (0ˆx�‰˜sÔ#´Y×5GÑ5G€Hàœ	×6Ñ6¼	×8^Ñ8^Ð_Ñ_Ø�k‰kœ)×8Ñ8¸(ÓCˆØ�k‰kœ)×@Ñ@À(ÓKˆØ€Jr,   Úendpoint_namec           	      óÈ	  — 	 t        | «       	 | j	                  «        y# t        $ r t        j                  dd¬«       Y Œ4w xY w# t
        j                  $ �rˆ}| j                  dz  dk(  rY d}~y| j                  j                  d«      }| j                  j                  d«      }| j                  �5| j                  j                  �t        | j                  j                  «      nd}|rt        |«      nd	\  }}|d
k(  r8| j                  › d�dz   d| j                  › d�z   }t        t        || ||¬«      |‚|dk(  r8| j                  › d�dz   d| j                  › d�z   }t        t         || ||¬«      |‚|dk(  r8| j                  › d�dz   d| j                  › d�z   }t        t"        || ||¬«      |‚|dk(  r;| j                  › d�dz   d| j                  › d�z   dz   dz   }t        t$        || «      |‚|dk(  r]|�[t&        j)                  |«      �F| j                  › d�dz   d| j                  › d�z   dz   dz   }t        t*        || t-        |«      ¬«      |‚| j                  dk(  rI|�Gt/        |«      x}	�:| j                  › d�dz   d| j                  › d�z   dz   }t        t0        || |	¬«      |‚|dk(  s+| j                  d k(  rZ|d!k7  rU|�St2        j)                  |«      �>| j                  › d�dz   d"| j                  › d�z   d#z   d$z   }t        t4        || ||¬«      |‚| j                  d%k(  r|�d&|› d'�nd(}t        t6        || «      |‚| j                  d)k(  r9d| j                  › d*|› d�d+| j                  › d�z   d,z   }t        t8        || «      |‚| j                  d-k(  r»t;        | j                  «      }
|
�‚d.|
j<                  › d/�}|d0|
j>                  › d1�z  }|
j@                  �:|
jB                  �.|d2|
jD                  › d3|
j@                  › d4|
jB                  › d5�z  }n|dz  }|d6| j                  › d�z  }nd7| j                  › d�}t        t8        || «      |‚| j                  d8k(  r[| j                  j                  j                  d9«      }|› d:|› d;| j                  j                  d<«      › d�}t        t8        || «      |‚t        t8        t        |«      | «      |‚d}~ww xY w)=aÔ  
    Internal version of `response.raise_for_status()` that will refine a potential HTTPError.
    Raised exception will be an instance of [`~errors.HfHubHTTPError`].

    This helper is meant to be the unique method to raise_for_status when making a call to the Hugging Face Hub.

    Args:
        response (`Response`):
            Response from the server.
        endpoint_name (`str`, *optional*):
            Name of the endpoint that has been called. If provided, the error message will be more complete.

    > [!WARNING]
    > Raises when the request has failed:
    >
    >     - [`~utils.RepositoryNotFoundError`]
    >         If the repository to download from cannot be found. This may be because it
    >         doesn't exist, because `repo_type` is not set correctly, or because the repo
    >         is `private` and you do not have access.
    >     - [`~utils.GatedRepoError`]
    >         If the repository exists but is gated and the user is not on the authorized
    >         list.
    >     - [`~utils.RevisionNotFoundError`]
    >         If the repository exists but the revision couldn't be found.
    >     - [`~utils.EntryNotFoundError`]
    >         If the repository exists but the entry (e.g. the requested file) couldn't be
    >         find.
    >     - [`~utils.BadRequestError`]
    >         If request failed with a HTTP 400 BadRequest error.
    >     - [`~utils.HfHubHTTPError`]
    >         If request failed for a reason not listed above.
    zFailed to parse warning headersT)Úexc_infoéd   rN   NzX-Error-CodeúX-Error-MessagerM   ÚRevisionNotFoundz Client Error.ú

zRevision Not Found for url: ú.)rT   rW   ÚEntryNotFoundzEntry Not Found for url: Ú	GatedRepoz!Cannot access gated repo for url z$Access to this resource is disabled.z!Cannot access repository for url ú
ÚRepoNotFoundzBucket Not Found for url: zG
Please make sure you specified the correct bucket id (namespace/name).zg
If the bucket is private, make sure you are authenticated and your token has the required permissions.)Ú	bucket_idi”  zJob Not Found for url: zA
Please make sure you specified the correct job ID and namespace.)Újob_idi‘  z+Invalid credentials in Authorization headerzRepository Not Found for url: zÈ
Please make sure you specified the correct `repo_id` and `repo_type`.
If you are trying to access a private or gated repo, make sure you are authenticated and your token has the required permissions.zQ
For more details, see https://huggingface.co/docs/huggingface_hub/authenticationrs   z

Bad request for z
 endpoint:z

Bad request:i“  z Forbidden: z
Cannot access content at: z2
Make sure your token has the correct permissions.r�   z0

429 Too Many Requests: you have reached your 'z' rate limit.z
Retry after z secondsú (rO   z requests remaining in current z
s window).z
Url: z!

429 Too Many Requests for url: i   ÚRangez. Requested range: z. Content-Range: zContent-Range)#Ú_warn_on_warning_headersr–   rh   ri   Úraise_for_statusr~   ÚHTTPStatusErrorrt   r.   rR   r`   rK   r(   rX   Ú_formatr   r   r   r   ÚBUCKET_API_REGEXr8   r   r\   r_   r   ÚREPO_API_REGEXr   r   r   r@   r   r!   r"   r#   r    )rq   rà   r™   Ú
error_codeÚerror_messageÚrequest_urlrT   rW   Úmessagerí   r¬   Úrange_headers               r-   r«   r«   Ü  s  € ðBGÜ  Ô*ð
B?Ø×!Ñ!Õ#øô ò Gä�‰Ð6ÀˆÖFðGûô × Ñ ó @?Ø×Ñ 3Ñ&¨!Ò+Üà×%Ñ%×)Ñ)¨.Ó9ˆ
Ø ×(Ñ(×,Ñ,Ð->Ó?ˆð *2×)9Ñ)9Ð)EÈ(×JZÑJZ×J^ÑJ^ÐJjŒC�× Ñ ×$Ñ$Ô%Ðptð 	ñ HSÔ6°{ÔCÐXdÑˆ	�7àÐ+Ò+Ø!×-Ñ-Ð.¨nÐ=ÀÑFÐKgÐhp×htÑhtÐguÐuvÐIwÑwˆGÜÔ/°¸(ÈiÐahÔiÐopÐpà˜?Ò*Ø!×-Ñ-Ð.¨nÐ=ÀÑFÐKdÐem×eqÑeqÐdrÐrsÐItÑtˆGÜÔ2°G¸XÐQZÐdkÔlÐrsÐsà˜;Ò&à×'Ñ'Ð(¨Ð7¸&Ñ@ÐEfÐgo×gsÑgsÐftÐtuÐCvÑvð ô œ.¨'°8ÀyÐZaÔbÐhiÐiàÐDÒDà×'Ñ'Ð(¨Ð7Øñà5°h·l±l°^À1ÐEñFð ñð 9ñ	9ð ô Ô+¨W°hÓ?ÀQÐFð ˜.Ò(ØÐ'Ü ×'Ñ'¨Ó4Ð@ð ×'Ñ'Ð(¨Ð7Øñà.¨x¯|©|¨n¸AÐ>ñ?ð ]ñ]ð }ñ	}ð ô Ü# W¨hÔB[Ð\gÓBhôàðð
 × Ñ  CÒ'ØÐ'Ü1°+Ó>Ð>�ÐKð ×'Ñ'Ð(¨Ð7Øñà+¨H¯L©L¨>¸Ð;ñ<ð WñWð ô Ô*¨G°XÀfÔMÐSTÐTà˜>Ò)Ø× Ñ  CÒ'ØÐ!NÒNØÐ'Ü×%Ñ% kÓ2Ð>ð ×'Ñ'Ð(¨Ð7Øñà2°8·<±<°.ÀÐBñCð`ñ`ð gñgð ô Ô1°7¸HÐPYÐcjÔkÐqrÐrà×!Ñ! SÒ(àDQÐD]Ð& } o°ZÑ@Ðcuð ô œ/¨7°HÓ=À1ÐDà×!Ñ! SÒ(à�x×+Ñ+Ð,¨L¸¸ÀqÐIØ0°·±°¸aÐ@ñAàGñHð ô
 œ.¨'°8Ó<À!ÐCà×!Ñ! SÒ(Ü4°X×5EÑ5EÓFˆNØÐ)àHÈ×IeÑIeÐHfÐfsÐtð ð ˜^¨N×,KÑ,KÐ+LÈHÐUÑU�Ø!×'Ñ'Ð3¸×8UÑ8UÐ8aØØ˜^×5Ñ5Ð6°a¸×8LÑ8LÐ7Mð N'Ø'5×'DÑ'DÐ&EÀZðQñ‘Gð
 ˜s‘N�GØ˜W X§\¡\ N°!Ð4Ñ4‘à?ÀÇÁ¸~ÈQÐO�Üœ.¨'°8Ó<À!ÐCà×!Ñ! SÒ(Ø#×+Ñ+×3Ñ3×7Ñ7¸Ó@ˆLØ˜Ð.¨|¨nÐ<MÈh×N^ÑN^×NbÑNbÐcrÓNsÐMtÐtuÐvˆGÜœ.¨'°8Ó<À!ÐCô ”n¤c¨!£f¨hÓ7¸QÐ>ûðA@?ús-   ‚ ŽA Ÿ AÁAÁS!ÁSÁ0Q,SÓS!c                 ó.  — | j                   j                  d«      }|D ]u  }d|v r|j                  dd«      nd|f\  }}|j                  «       }|t        vsŒ9|j                  «       }|sŒLt        j                  |«       t        j                  |«       Œw y)a�  
    Emit warnings if warning headers are present in the HTTP response.

    Expected header format: 'X-HF-Warning: topic; message'

    Only the first warning for each topic will be shown. Topic is optional and can be empty. Note that several warning
    headers can be present in a single response.

    Args:
        response (`httpx.Response`):
            The HTTP response to check for warning headers.
    zX-HF-Warningú;r   rÏ   N)r.   Úget_listÚsplitÚstripÚ_WARNED_TOPICSÚaddrh   r—   )rq   Úserver_warningsÚserver_warningÚtopicrù   s        r-   rð   rð   ‹  sŠ   € ð ×&Ñ&×/Ñ/°Ó?€OØ)ò (ˆØ9<ÀÑ9N˜×-Ñ-¨c°1Ô5ÐUWÐYgÐTh‰ˆˆwØ—‘“ˆØœÒ&Ø—m‘m“oˆGÚÜ×"Ñ" 5Ô)Ü—‘˜wÕ'ñ(r,   Ú_HfHubHTTPErrorT)ÚboundÚ
error_typeÚcustom_messageÚattrsc                 ó�  — g }|j                   j                  d«      }|�|j                  |«       	 	 |j                  «       }|j                  d«      }|j                  d«      }|�Mt        |t        «      r|j                  |«       n>|�|j                  |› d|› �«       n%|j                  |«       n|�|j                  |«       |j                  d«      }	|	� |	D ]  }d|v sŒ|j                  |d   «       Œ |D �cg c]5  }t        |«      j                  «       sŒt        |«      j                  «       ‘Œ7 }}t        t         j#                  |«      «      }d
j%                  |«      }|}|r5|j                  «       |j                  «       vrd|v r	|d
|z   z  }n|d|z   z  }d}d}t&        dft(        dft*        dffD ]8  \  }}|j                   j                  |«      }|sŒ$t        |«      }d|› d|› d�} n |rI|j                  «       |j                  «       vr)d
|v r |j-                  d
«      }|d | |z   ||d  z   }n||z  } | |j                  «       ||xs d ¬«      }|j/                  «       D ]  \  }}t1        |||«       Œ |S # t        j
                  $ r7 	 |j                  «        |j                  «       }n# t        $ r i }Y nw xY wY �Œ�w xY w# t        j                  $ rY |j                   j                  dd«      }
|j                  r-d	|
j                  «       vr|j                  |j                  «       Y �ŒEw xY wc c}w )Nrä   ÚerrorÚerror_descriptionú: Úerrorsrù   zContent-TyperÏ   Úhtmlrê   ræ   z
Request IDzAmzn Trace IDz	Amz CF IDrî   ú))rq   Úserver_message)r.   rR   ÚappendÚjsonr~   ÚResponseNotReadÚreadÚRuntimeErrorr²   ÚlistÚextendÚJSONDecodeErrorÚtextr6   r(   rÿ   ÚdictÚfromkeysÚjoinre   rd   ÚX_AMZ_CF_IDÚindexÚitemsÚsetattr)r  r  rq   r	  Úserver_errorsÚfrom_headersr¨   r  r  r  Úcontent_typeÚliner  Úfinal_error_messagerm   Úrequest_id_messageÚheaderÚlabelÚvalueÚnewline_indexrÂ   ÚkÚvs                          r-   ró   ró   ¦  s|  € ð €Mð ×#Ñ#×'Ñ'Ð(9Ó:€LØÐØ×Ñ˜\Ô*ð+0ð	Ø—=‘=“?ˆDð —‘˜Ó!ˆØ ŸH™HÐ%8Ó9ÐØÐÜ˜%¤Ô&à×$Ñ$ UÕ+Ø"Ð.à×$Ñ$¨ w¨bÐ1BÐ0CÐ%DÕEð ×$Ñ$ UÕ+ØÐ*à× Ñ Ð!2Ô3à—‘˜(Ó#ˆØÐàò ;�Ø Ò%Ø!×(Ñ(¨¨yÑ)9Õ:ð;ð 4AÖV¨4ÄCÈÃIÇOÁOÕDU”S˜“Y—_‘_Õ&ÐV€MÐVô œŸ™ }Ó5Ó6€Mð —Y‘Y˜}Ó-€Nð )ÐÙ˜.×.Ñ.Ó0¸×8LÑ8LÓ8NÑNØ�^Ñ#Ø 4¨.Ñ#8Ñ8Ñà 6¨NÑ#:Ñ:Ðð €JØÐä	�|Ð$Ü	˜/Ð*Ü	�kÐ"ðò 	‰ˆ�ð
 × Ñ ×$Ñ$ VÓ,ˆÚÜ˜U›ˆJØ#% e W¨B¨u¨g°QÐ!7ÐÙð	ñ �j×&Ñ&Ó(Ð0C×0IÑ0IÓ0KÑKØÐ&Ñ&Ø/×5Ñ5°dÓ;ˆMà# N ]Ð3Ð6HÑHÐK^Ð_lÐ_mÐKnÑnñ  ð  Ð#5Ñ5Ðñ Ð(×.Ñ.Ó0¸8ÐTbÒTjÐfjÔ
k€CØ—‘“ò ‰ˆˆ1Ü��Q˜Õðà€Jøôo ×$Ñ$ò 
	ð	Ø—‘”Ø—}‘}“‘øÜò ð ’ðýð	
	ûôF ×Ñò 0à×'Ñ'×+Ñ+¨N¸BÓ?ˆØ�=Š=˜V¨<×+=Ñ+=Ó+?Ñ?Ø× Ñ  §¡Ô/úð	0üò Wsg   ³J ÁB K Ã$K Ã>MÄMÊKÊ J<Ê;KÊ<K
ËKË	K
Ë
KËK ËKËK ËA(M Ì?M )Úsubject_tokenÚaccess_tokenÚrefresh_tokenÚclient_secretÚdevice_codez("z"\s*:\s*")[^"]*(")z\1<REDACTED>\2z(^|&)(z=)[^&]*z\1\2<REDACTED>Úbodyc                 óF   — t         D ]  \  }}|j                  || «      } Œ | S )zRRedact OAuth credential values from a JSON or form-urlencoded request body string.)Ú_SENSITIVE_BODY_PATTERNSÚsub)r3  ÚpatternÚreplacements      r-   Ú_redact_sensitive_bodyr9    s+   € ä 8ò .Ñˆ�Ø�{‰{˜;¨Ó-‰ð.à€Kr,   c                 ó´  — dd| j                   fg}t        | j                  j                  «       «      D ]'  \  }}|j	                  «       dk(  rd}|d|› d|› �fgz  }Œ) d}	 | j
                  �>| j
                  j                  dd	¬
«      }t        |«      dkD  r|dd › d�}t        |«      }|�|d|j                  dd«      fgz  }|d| j                  fgz  }g }|D ]P  \  }}|r#|j                  t        t        |«      «      «       |sŒ.|j                  t        t        |«      «      «       ŒR dj!                  |«      S # t        j                  $ r d}Y Œ«w xY w)zÞConvert a `httpx.Request` into a curl command (str).

    Used for debug purposes only.

    Implementation vendored from https://github.com/ofw/curlify/blob/master/curlify.py.
    MIT License Copyright (c) 2016 Egor.
    )ÚcurlNz-Xrb   z<TOKEN>z-Hr  Nzutf-8Úignore)r  iè  z ... [truncated]z<streaming body>z-drê   rÏ   rª   )rj   Úsortedr.   r   r6   ÚcontentÚdecodeÚlenr9  r~   ÚRequestNotReadrÞ   rK   r  r   r(   r  )r`   Úpartsr,  r-  r3  Ú
flat_partss         r-   rl   rl   "  sz  € ð 	Ø	ˆw�~‰~Ðð$€Eô
 �w—‘×,Ñ,Ó.Ó/ò '‰ˆˆ1Ø�7‰7‹9˜Ò'ØˆAØ�4˜A˜3˜b  ˜Ð%Ð&Ñ&‰ð'ð
 €Dð"Ø�?‰?Ð&Ø—?‘?×)Ñ)¨'¸(Ð)ÓCˆDÜ�4‹y˜4ÒØ˜u ˜+˜Ð&6Ð7�Ü)¨$Ó/ˆDð ÐØ�4˜Ÿ™ d¨BÓ/Ð0Ð1Ñ1ˆà	ˆt�W—[‘[Ð!Ð"Ñ"€Eà€JØò -‰ˆˆ1ÙØ×Ñœe¤C¨£F›mÔ,ÚØ×Ñœe¤C¨£F›mÕ,ð	-ð �8‰8�JÓÐøô ×Ñò "Ø!Šð"ús   Á!A
D? Ä?EÅEz%^\s*bytes\s*=\s*(\d*)\s*-\s*(\d*)\s*$Úoriginal_rangeÚresume_sizec                 ó¤  — | sd|› d�S d| v rt        d| ›d�«      ‚t        j                  | «      }|st        d| ›d�«      ‚|j	                  «       \  }}|s:|st        d| ›d�«      ‚t        |«      |z
  }d|› �}|d	k  rt        d
|›d�«      ‚|S t        |«      }||z   }|r)t        |«      }d|› d|› �}||kD  rt        d
|›d�«      ‚|S d|› d�S )zB
    Adjust HTTP Range header to account for resume position.
    zbytes=ú-ú,zMultiple ranges detected - z, not supported yet.zInvalid range format - rç   zbytes=-r   zEmpty new range - )ru   ÚRANGE_REGEXr>   r  Úgroupsr*   )rD  rE  r>   ÚstartÚendÚ
new_suffixÚ	new_rangeÚ	new_starts           r-   Ú_adjust_range_headerrP  P  s'  € ñ Ø˜�} AÐ&Ð&à
ˆnÑÜÐ6°~Ð6HÐH\Ð]Ó^Ð^ä×Ñ˜nÓ-€EÙÜÐ4°^Ð4FÀaÐHÓIÐIØ—‘“�J€Eˆ3áÙÜÐ!8¸Ð8JÈ!ÐLÓMÐMä˜“X Ñ+ˆ
Ø˜j˜\Ð*ˆ	Ø˜Š?ÜÐ!3°I°=ÀÐBÓCÐCØÐä�‹J€EØ˜Ñ#€IÙ
Ü�#‹hˆØ˜Y˜K q¨¨Ð.ˆ	Ø�sŠ?ÜÐ!3°I°=ÀÐBÓCÐCØÐà�I�;˜aÐ Ð r,   )r/   N)N)wr'   Úatexitr´   r  ÚosÚreÚ	threadingr¼   rf   Úcollections.abcr   r   r   Ú
contextlibr   Údataclassesr   Úshlexr   Útypingr	   r
   Úurllib.parser   r~   Úhuggingface_hub.errorsr   rÏ   r   r  r   r   r   r   r   r   r   r   r   r   Ú_lfsr   Ú_typingr   Ú
get_loggerr$   rh   r   Úcompiler7   r:   r(   r@   re   rd   r  ÚVERBOSErõ   rô   r^   rP   rZ   rS   ÚtuplerX   r\   r_   ÚRequestrn   rp   r¸   rx   r   r€   r‚   rƒ   ÚCLIENT_FACTORY_TÚASYNC_CLIENT_FACTORY_TÚLockr‰   r„   r)   r…   r†   r‹   r�   r‘   r“   rŠ   ÚregisterÚhasattrrš   ÚTimeoutExceptionÚNetworkErrorrœ   r³   r–   rž   r*   r»   r¹   rÄ   rÉ   rË   r×   rß   r«   Úsetr   rð   r  ró   Ú_SENSITIVE_BODY_KEYSr5  r9  rl   Ú
IGNORECASErI  rP  )r<   r7  s   00r-   ú<module>rm     sÿ  ðò Eã Û 	Û Û 	Û 	Û Û Û ß 8Ñ 8Ý %Ý !Ý ß Ý !ã å 7å ÷
÷ 
õ 
õ Ý Ý "ð 
ˆ×	Ñ	˜HÓ	%€ñ �$Ô÷&ð &ó ð&ð, �2—:‘:ÐmÓnÐ à$˜"Ÿ*™*Ð%OÓPÐ ð8 W¨S°#¨XÑ%6ð 8¸=È4Ñ;Oó 8ðz €Ø#€Ø€à�—‘ð
ð �*‰*ô€ð �2—:‘:ðð �*‰*ôÐ ð $˜Ÿ™Ð$aÓbÐ ð %˜"Ÿ*™*Ð%iÓjÐ ð '˜BŸJ™JÐ'SÓTÐ ò qÐ ð 3ð ¨5°°t±¸SÀ4¹ZÐ1GÑ+Hó ð2- 3ð -¨3°©:ó -ð- ð -¨¨d©
ó -ð 5§=¡=ð °Tó ðB*¨u¯}©}ð *Àó *ð'°·±ð 'ÀDó 'ð §¡ó ð e×&7Ñ&7ó ð ˜B §¡Ð,Ñ-Ð Ø! " e×&7Ñ&7Ð"7Ñ8Ð àˆy�~‰~Ó€Ø+AÐ Ð(Ó AØ7SÐ Ð4Ó SØ&*€�—‘˜tÑ#Ó *ð0Ð'7ð 0¸Dó 0ð"8Ð3Ið 8Èdó 8ð&�U—\‘\ó ð*˜5×,Ñ,ó *ó 9ð, €‡��Ô Ù
ˆ2Ð!Ô"Ø€B×Ñ }Õ5ð >C×=SÑ=SÐUZ×UgÑUgÐ<hÐ ˜e D¨¡O°SÐ$8Ñ9Ó hØ2PÐ   c¨3 h¡Ó Pð ØØØIeØ3QØò^8Øð^8à	ð^8ð ð	^8ð
 ð^8ð ð^8ð ˜i™¨5°°i±À#Ð1EÑ+FÑFð^8ð   s¨C x¡Ñ0ð^8ð ð^8ð ˆu�~‰~˜t TÐ)Ñ*ó^8ðJ ØØØIeØ3QòMØðMà	ðMð ð	Mð
 ðMð ðMð ˜i™¨5°°i±À#Ð1EÑ+FÑFðMð   s¨C x¡Ñ0ðMð ‡^�^óMð` ð
 ØØØIeØ3QòOØðOà	ðOð ð	Oð
 ðOð ðOð ˜i™¨5°°i±À#Ð1EÑ+FÑFðOð   s¨C x¡Ñ0ðOð ˆu�~‰~˜t TÐ)Ñ*òOó ðOðf AFò0Øð0Ø #ð0Ø9=ð0à
‡^�^ó0ðf
 ð 
¨s°T©zð 
¸có 
ñi? %§.¡.ð i?ÀÀtÁð i?ÐW[ó i?ñX “€ð( u§~¡~ð (¸$ó (ñ0 Ð-°^ÔDÐ ðfØÐ%Ñ&ðfØ8;ðfØGLÇ~Á~ðfØ`cðfàófðT jÐ ð $÷àà	ˆ�‰�r˜#˜Ð0Ð1Ó	2Ð4EÐFØ	ˆ�‰�v˜c˜U 'Ð*Ó	+Ð->Ð?ðòð 	ò ðØóÐ ð ð ¨ó ð' �e—m‘mð ' ¨ó ' ðV ˆb�j‰jÐAÀ2Ç=Á=ÓQ€ð"!¨¨t©ð "!À#ð "!È#ÐPTÉ*ô "!ùós   Ð>R