§
    }Štj¦k  ã            
       ó®  — U d Z ddlZddlZddlmZmZ ddlmZmZm	Z	 ddl
mZ ddlmZmZ ddlmZ d	„ ej                             ¦   «         D ¦   «         Zeeef         ed
<    ej        d¦  «        Z eej                             ¦   «         ¦  «        Zee         ed<    eh d£¦  «        Zee         ed<    eddh¦  «        Zee         ed<    ed¬¦  «         G d„ d¦  «        ¦   «         Z ed¬¦  «         G d„ d¦  «        ¦   «         Zdede fd„Z!ej"        d.dededz  defd„¦   «         Z#dedz  de$edz  ef         fd„Z%dedz  dee         fd„Z&d.dededz  de fd„Z'd edefd!„Z(d.d"ededz  defd#„Z)d$edefd%„Z*d&ed'ede$eedz  e dz  f         fd(„Z+d)ed'ede$ej,        ef         fd*„Z-d)ed+ej,        d'edefd,„Z.d)ed+ej,        d'edefd-„Z/dS )/a  Centralized parser for Hugging Face Hub URIs ('hf://...') and mount specifications.

A HF URI is a URI-like string that identifies a location on the Hugging Face
Hub: a model/dataset/space/kernel repository, a bucket, optionally a revision,
and optionally a path inside the repo or bucket.

Canonical syntax:

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]
```

For convenience, [`parse_hf_uri`] also accepts Hugging Face **web URLs** (the
ones you copy-paste from your browser), e.g.
'https://huggingface.co/datasets/my-org/my-dataset/blob/main/train.csv'. They are
normalized to the canonical 'hf://' form before parsing. Only unambiguous URLs
(repository / bucket pages and file/folder viewer routes) are accepted; any other
route is rejected rather than guessed.

A HF mount wraps a HF URI with a local mount path and an optional ':ro'/':rw'
flag (used by Spaces and Jobs volumes):

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]
```

See 'docs/source/en/package_reference/hf_uris.md' for the full grammar and examples.
é    N)Ú	dataclassÚfield)ÚquoteÚunquoteÚurlsplit)Ú	constants)Ú
HfUriErrorÚHFValidationErroré   )Úvalidate_repo_idc                 ó   — i | ]\  }}||“Œ	S © r   )Ú.0ÚkÚvs      ú\/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/huggingface_hub/utils/_hf_uris.pyú
<dictcomp>r   8   s   € Ð"[Ð"[Ð"[©D¨A¨q 1 aÐ"[Ð"[Ð"[ó    Ú_TYPE_TO_PREFIXz ^refs/(?:convert/[\w.-]+|pr/\d+)Ú_VALID_URI_TYPES>   ÚrawÚblobÚtreeÚblameÚresolveÚ_URL_REPO_LOCATION_ACTIONSr   r   Ú_URL_BUCKET_LOCATION_ACTIONST)Úfrozenc                   óæ   — e Zd ZU dZej        ed<   eed<   dZedz  ed<   dZ	eed<    e
dddd¬	¦  «        Zedz  ed
<   dd„Zedefd„¦   «         Zedefd„¦   «         Zdefd„Zddedz  defd„ZdS )ÚHfUriaé  Parsed representation of a Hugging Face Hub URI ('hf://...').

    Attributes:
        type (`str`):
            One of 'model', 'dataset', 'space', 'kernel' or 'bucket'.
        id (`str`):
            The repository id ('namespace/name', e.g. 'my-org/my-model') for repo URIs, or the bucket id ('namespace/name') for bucket URIs.
        revision (`str`, *optional*):
            The revision specified after '@' in the URI, URL-decoded. 'None' if no revision was specified, or for bucket URIs (which
            never carry a revision). Special refs like 'refs/pr/10' and 'refs/convert/parquet' are preserved as-is.
        path_in_repo (`str`):
            The path inside the repo or bucket. Empty string if the URI points at the root.
    ÚtypeÚidNÚrevisionÚ Úpath_in_repoF©ÚreprÚhashÚcompareÚdefaultÚ_rawÚreturnc           	      óÄ  — | j         pd}| j        t          vr/t          |d| j        › dt	          t          ¦  «        › d�¬¦  «        ‚| j        r| j                             d¦  «        dk    rt          |d| j        › d	�¬¦  «        ‚| j        d
k    rG	 t          | j        ¦  «         n1# t          $ r$}t          |t          |¦  «        ¬¦  «        |‚d }~ww xY w| j
        �| j
        st          |d¬¦  «        ‚| j        d
k    r| j
        �t          |d¬¦  «        ‚| j        r=| j                             d¦  «        s	d| j        v rt          |d| j        › d�¬¦  «        ‚d S d S )Nr$   zInvalid type 'z'. Must be one of ú.©ÚuriÚmsgú/r   z"Id must be 'namespace/name', got 'ú'.Úbucketz%Revision must not be an empty string.z&Bucket URIs do not support a revision.ú//z+Path must not contain empty segments (got 'z').)r+   r!   r   r	   Úsortedr"   Úcountr   r
   Ústrr#   r%   Ú
startswith)Úselfr0   Úes      r   Ú__post_init__zHfUri.__post_init__d   s¬  € ØŒiˆo˜2ˆð Œ9Õ,Ð,Ð,Ý Ð*s¸4¼9Ð*sÐ*sÕX^Õ_oÑXpÔXpÐ*sÐ*sÐ*sÐtÑtÔtÐtð Œwð 	\˜$œ'Ÿ-š-¨Ñ,Ô,°Ò1Ð1Ý Ð*ZÈtÌwÐ*ZÐ*ZÐ*ZÐ[Ñ[Ô[Ð[ØŒ9˜Ò Ð ð=Ý  ¤Ñ)Ô)Ð)Ð)øÝ$ð =ð =ð =Ý  S­c°!©f¬fÐ5Ñ5Ô5¸1Ð<øøøøð=øøøð Œ=Ð$¨T¬]Ð$Ý Ð*QÐRÑRÔRÐRØŒ9˜Ò Ð  T¤]Ð%>Ý Ð*RÐSÑSÔSÐSð Ôð 	tØÔ ×+Ò+¨CÑ0Ô0ð t°D¸DÔ<MÐ4MÐ4MÝ  SÐ.rÐ\`Ô\mÐ.rÐ.rÐ.rÐsÑsÔsÐsð	tð 	tØ4MÐ4Ms   ÂB' Â'
CÂ1CÃCc                 ó   — | j         dk    S )z$True if this URI points at a bucket.r4   ©r!   ©r:   s    r   Ú	is_bucketzHfUri.is_bucket   ó   € ð Œy˜HÒ$Ð$r   c                 ó   — | j         dk    S )zJTrue if this URI points at a repository (model, dataset, space or kernel).r4   r>   r?   s    r   Úis_repozHfUri.is_repo„   rA   r   c                 ór  — t           j        t          | j                 d| j        g}| j        �S| j        }d|v r0t                               |¦  «        €|                     dd¦  «        }| 	                    d|› �¦  «         | j
        r| 	                    d| j
        › �¦  «         d                     |¦  «        S )z’Render the URI as a canonical 'hf://' string.

        The type prefix is always written explicitly (e.g. 'hf://models/my-org/my-model').
        r2   Nú%2Fú@r$   )r   ÚHF_PROTOCOLr   r!   r"   r#   Ú_SPECIAL_REFS_REVISION_REGEXÚ	fullmatchÚreplaceÚappendr%   Újoin)r:   Úpartsr#   s      r   Úto_urizHfUri.to_uri‰   s´   € õ
 &Ô1µ?À4Ä9Ô3MÈsÐTXÔT[Ð\ˆØŒ=Ð$ð ”}ˆHØ�hˆˆÕ#?×#IÒ#IÈ(Ñ#SÔ#SÐ#[Ø#×+Ò+¨C°Ñ7Ô7�Ø�LŠL˜˜X˜˜Ñ(Ô(Ð(ØÔð 	2Ø�LŠLÐ0˜TÔ.Ð0Ð0Ñ1Ô1Ð1Ø�wŠw�u‰~Œ~Ðr   Úendpointc                 óÖ  — |pt           j                             d¦  «        }t          | j        d¬¦  «        }| j        dk    r|› d| j        › �}|r|d|› �z  }|S | j        dk    r|› d| j        › �n|› dt          | j                 › d| j        › �}| j        }|�+t           
                    |¦  «        €t          |d¬¦  «        }|r|d	|pt           j        › d|› �z  }n
|�|d|› �z  }|S )
a  Render the URI as a Hugging Face **web URL** (the kind you open in a browser).

        This is the inverse of parsing a URL with [`parse_hf_uri`]. The returned URL points at:

        - the repository / bucket landing page when no path or revision is set;
        - the folder viewer ('/tree/<revision>') when only a revision is set;
        - the file viewer ('/blob/<revision>/<path>') for repository files (revision defaults to 'main');
        - the tree route ('/tree/<path>') for bucket files (buckets are not versioned).

        Args:
            endpoint (`str`, *optional*):
                Base endpoint to use. Defaults to 'constants.ENDPOINT' (i.e. 'https://huggingface.co').

        Returns:
            `str`: the web URL.

        Example:
            ```py
            >>> from huggingface_hub import parse_hf_uri
            >>> parse_hf_uri("hf://datasets/my-org/my-dataset@v1/train.csv").to_url()
            'https://huggingface.co/datasets/my-org/my-dataset/blob/v1/train.csv'
            ```
        r2   )Úsafer4   z	/buckets/z/tree/ÚmodelNr$   z/blob/)r   ÚENDPOINTÚrstripr   r%   r!   r"   r   r#   rH   rI   ÚDEFAULT_REVISION)r:   rO   ÚbaseÚpathÚurlr#   s         r   Úto_urlzHfUri.to_url›   s@  € ð0 Ð.�IÔ.×6Ò6°sÑ;Ô;ˆõ �TÔ&¨SÐ1Ñ1Ô1ˆàŒ9˜Ò Ð ØÐ-Ð- D¤GÐ-Ð-ˆCØð 'Ø� ��Ñ&�ØˆJð &*¤Y°'Ò%9Ð%9�Ð!Ð!˜œÐ!Ð!Ð!À$Ð?oÐ?oÍÐY]ÔYbÔIcÐ?oÐ?oÐfjÔfmÐ?oÐ?oˆØ”=ˆð
 ÐÕ$@×$JÒ$JÈ8Ñ$TÔ$TÐ$\Ý˜X¨BÐ/Ñ/Ô/ˆHØð 	'ØÐK˜HÐB­	Ô(BÐKÐKÀTÐKÐKÑKˆCˆCØÐ!ØÐ&˜HÐ&Ð&Ñ&ˆCØˆ
r   ©r,   N©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú	HfUriTypeÚ__annotations__r8   r#   r%   r   r+   r<   ÚpropertyÚboolr@   rC   rN   rY   r   r   r   r    r    N   s1  € € € € € € ðð ð Ô
ÐÐÑØ€G€G�GØ€Hˆc�D‰jÐÐÑØ€L�#ÐÐÑØ�u %¨e¸UÈDÐQÑQÔQ€Dˆ#�‰*ÐQÐQÑQðtð tð tð tð6 ð%˜4ð %ð %ð %ñ „Xð%ð ð%˜ð %ð %ð %ñ „Xð%ð˜ð ð ð ð ð$0ð 0˜s T™zð 0°Sð 0ð 0ð 0ð 0ð 0ð 0r   r    c                   ó~   — e Zd ZU dZeed<   eed<   dZedz  ed<    e	dddd¬¦  «        Z
edz  ed<   dd
„Zd	efd„ZdS )ÚHfMountaF  A HF URI paired with a local mount path and optional read-only flag.

    Used by Spaces and Jobs to describe volume mounts. The full syntax is:

    ```
    hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]
    ```

    Attributes:
        source ([`HfUri`]):
            The parsed HF URI identifying the Hub resource to mount.
        mount_path (`str`):
            The local mount path (always starts with '/').
        read_only (`bool`, *optional*):
            True if the mount ends with ':ro', False if it ends with ':rw', 'None' if no flag was provided.
    ÚsourceÚ
mount_pathNÚ	read_onlyFr&   r+   r,   c                 ó–   — | j         pd}| j                             d¦  «        r| j        dk    rt          |d| j        › d�¬¦  «        ‚d S )Nr$   r2   zEMount path must be a non-empty absolute path starting with '/', got 'r3   r/   )r+   rg   r9   r	   )r:   r   s     r   r<   zHfMount.__post_init__æ   sf   € ØŒiˆo˜2ˆØŒ×)Ò)¨#Ñ.Ô.ð 	°$´/ÀSÒ2HÐ2HÝØØoÐ\`Ô\kÐoÐoÐoðñ ô ð ð 3IÐ2Hr   c                 ó¸   — | j                              ¦   «         d| j        g}| j        �|                     | j        rdnd¦  «         d                     |¦  «        S )zqRender the mount as a canonical 'hf://' string.

        Example: 'hf://models/my-org/my-model:/data:ro'
        ú:Nú:roú:rwr$   )rf   rN   rg   rh   rK   rL   )r:   rM   s     r   rN   zHfMount.to_uriî   sU   € ð
 ”×#Ò#Ñ%Ô% s¨D¬OÐ<ˆØŒ>Ð%Ø�LŠL $¤.Ð;˜˜°eÑ<Ô<Ð<Ø�wŠw�u‰~Œ~Ðr   rZ   )r\   r]   r^   r_   r    ra   r8   rh   rc   r   r+   r<   rN   r   r   r   re   re   Î   sž   € € € € € € ðð ð" €M€M�MØ€O€O�OØ!€Iˆt�d‰{Ð!Ð!Ñ!Ø�u %¨e¸UÈDÐQÑQÔQ€Dˆ#�‰*ÐQÐQÑQðð ð ð ð˜ð ð ð ð ð ð r   re   r0   r,   c                 óH   — 	 t          | ¦  «         dS # t          $ r Y dS w xY w)zVCheck if a string is a valid HF URI ('hf://...') or a recognized Hugging Face web URL.TF)Úparse_hf_urir	   )r0   s    r   Ú	is_hf_urirp   ù   s<   € ðÝ�SÑÔÐØˆtøÝð ð ð Øˆuˆuðøøøs   ‚ “
! !rO   c                 óà  — | }|                       t          j        ¦  «        rB| t          t          j        ¦  «        d…         }|st	          | dt          j        › d�¦  «        ‚nNt          | |¬¦  «        rt          | |¬¦  «        }n+t	          | dt          j        › dt          j        › d�¦  «        ‚t          ||¬¦  «        \  }}|d	k    rt          |||¬¦  «        S t          |||¬¦  «        S )
a·  Parse a Hugging Face Hub URI ('hf://...') or a Hugging Face web URL.

    A HF URI is a URI-like string identifying a location on the Hugging Face Hub. The full grammar is:

    ```
    hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]
    ```

    For convenience, Hugging Face **web URLs** (the ones you copy-paste from the website) are also
    accepted and normalized to the canonical 'hf://' form, e.g.
    'https://huggingface.co/datasets/my-org/my-dataset/blob/main/train.csv'. Only unambiguous URLs
    (repository / bucket pages and file/folder viewer routes) are accepted; any other route is rejected.

    See 'docs/source/en/package_reference/hf_uris.md' for the full specification.

    Args:
        uri (`str`):
            The URI to parse. Must start with 'hf://', or be a Hugging Face URL (e.g. 'https://huggingface.co/...').
        endpoint (`str`, *optional*):
            A custom Hub endpoint (e.g. a self-hosted or proxied Hub like 'https://hub.my-company.com' or
            'http://localhost:8080/hf'). When provided, web URLs on that endpoint are recognized in addition to
            the default Hugging Face hosts. Has no effect on 'hf://' URIs.

    Returns:
        [`HfUri`]: the parsed URI.

    Raises:
        [`HfUriError`]:
            If the URI is malformed (missing prefix, invalid type, missing id, unsupported URL route, etc.).

    Examples:
        ```py
        >>> from huggingface_hub.utils import parse_hf_uri
        >>> parse_hf_uri("hf://my-org/my-model")
        HfUri(type='model', id='my-org/my-model', revision=None, path_in_repo='')
        >>> parse_hf_uri("hf://datasets/my-org/my-dataset@refs/pr/3/train.json")
        HfUri(type='dataset', id='my-org/my-dataset', revision='refs/pr/3', path_in_repo='train.json')
        >>> parse_hf_uri("https://huggingface.co/datasets/my-org/my-dataset/blob/main/train.csv")
        HfUri(type='dataset', id='my-org/my-dataset', revision='main', path_in_repo='train.csv')
        ```
    NúEmpty body after 'r3   )rO   úMust start with 'zQ' or be a Hugging Face URL (e.g. 'https://huggingface.co/...'). Expected format: z#[<TYPE>/]<ID>[@<REVISION>][/<PATH>]©r   r4   )
r9   r   rG   Úlenr	   Ú_looks_like_hf_urlÚ_url_to_uri_bodyÚ_split_typeÚ_parse_bucket_bodyÚ_parse_repo_body)r0   rO   r   ÚbodyÚtype_Úlocations         r   ro   ro     s$  € ðV €CØ
‡~‚~•iÔ+Ñ,Ô,ð 
Ø•3•yÔ,Ñ-Ô-Ð/Ð/Ô0ˆØð 	RÝ˜SÐ"PµyÔ7LÐ"PÐ"PÐ"PÑQÔQÐQð	Rå	˜C¨(Ð	3Ñ	3Ô	3ð 
Ý ¨hÐ7Ñ7Ô7ˆˆåØð[¥	Ô 5ð [ð [Ý )Ô 5ð[ð [ð [ñ
ô 
ð 	
õ " $¨CÐ0Ñ0Ô0�O€Eˆ8à�ÒÐÝ! (¨E°sÐ;Ñ;Ô;Ð;Ý˜H e°Ð5Ñ5Ô5Ð5r   c                 ó¶   — | €dS t          d| v r| nd| z   ¦  «        }|j        r|j                             ¦   «         nd}||j                             d¦  «        fS )a  Return the lowercased host and stripped path prefix of a custom Hub 'endpoint'.

    E.g. 'https://hub.my-company.com' -> ('hub.my-company.com', '') and a self-hosted
    'http://localhost:8080/hf' -> ('localhost', 'hf'). Returns '(None, "")' when 'endpoint' is None.
    N)Nr$   ú://r5   r2   )r   ÚhostnameÚlowerrW   Ústrip)rO   ÚparsedÚhosts      r   Ú_endpoint_host_and_pathr…   B  sh   € ð ÐØˆxå %¨8Ð"3Ð"3�h�h¸À¹ÑIÔI€FØ&,¤oÐ?ˆ6Œ?× Ò Ñ"Ô"Ð"¸4€DØ�”×"Ò" 3Ñ'Ô'Ð'Ð'r   c                 ób   — t          | ¦  «        \  }}|rt          j        |hz  nt          j        S )z^The set of hosts whose web URLs can be parsed: the default Hugging Face hosts plus 'endpoint'.)r…   r   ÚHF_URL_HOSTS)rO   r„   Ú_s      r   Ú_recognized_hostsr‰   P  s0   € å% hÑ/Ô/�G€Dˆ!Ø.2ÐN�9Ô! T FÑ*Ð*½	Ô8NÐNr   c                 óª   ‡— |                       ¦   «         Š‰                     d¦  «        rdS t          ˆfd„t          |¦  «        D ¦   «         ¦  «        S )zNReturn True if 'uri' looks like a (possibly scheme-less) Hugging Face web URL.)zhttp://zhttps://Tc              3   óT   •K  — | ]"}‰|k    p‰                      |d z   ¦  «        V — Œ#dS )r2   N)r9   )r   r„   Úlowereds     €r   ú	<genexpr>z%_looks_like_hf_url.<locals>.<genexpr>\  s>   øè è € ÐiÐiÀTˆw˜$ŠÐ@ '×"4Ò"4°T¸C±ZÑ"@Ô"@ÐiÐiÐiÐiÐiÐir   )r�   r9   Úanyr‰   )r0   rO   rŒ   s     @r   rv   rv   V  sY   ø€ à�iŠi‰kŒk€GØ×ÒÐ1Ñ2Ô2ð ØˆtåÐiÐiÐiÐiÕM^Ð_gÑMhÔMhÐiÑiÔiÑiÔiÐir   Úsegmentc                 óH   — t          | ¦  «                             dd¦  «        S )aw  Percent-decode a single URL path segment (e.g. 'file%20name.txt' -> 'file name.txt').

    A decoded '/' is re-encoded as '%2F' so the segment stays atomic when the normalized body is
    re-split by the shared parser. This decodes ordinary path characters (spaces, '#', ...) that
    browsers encode, while keeping '%2F'-encoded revisions (e.g. 'feature%2Ffoo') intact.
    r2   rE   )r   rJ   )r�   s    r   Ú_decode_url_path_segmentr‘   _  s"   € õ �7ÑÔ×#Ò# C¨Ñ/Ô/Ð/r   rX   c                 óD  — | }t          d| v r| nd| z   ¦  «        }|j        pd                     ¦   «         }|t          |¦  «        vrt	          |d|p| › d�¬¦  «        ‚|j        }t          |¦  «        \  }}|r@||k    r:d|z   }||k    s|                     |dz   ¦  «        r|t          |¦  «        d…         }d	„ | 	                    d¦  «        D ¦   «         }	|	st	          |d
| › d�¬¦  «        ‚d}
|	d         t          j        v r|	d         }
|	dd…         }	t          |	¦  «        dk     rt	          |d| › d�¬¦  «        ‚|	d         › d|	d         › �}|	dd…         }|
dk    rZ|sd|› �S |^}}|t          vrt	          |d| › d|› d�¬¦  «        ‚d                     d„ |D ¦   «         ¦  «        }|rd|› d|› �nd|› �S |
r|
› d�nd}|s|› |› �S |^}}|t          vrt	          |d| › d|› d�¬¦  «        ‚|s|› |› �S d                     d„ |D ¦   «         ¦  «        }|› |› d|› �S )aâ  Normalize a Hugging Face web URL into the body of a 'hf://' URI (everything after 'hf://').

    The returned string is fed back into the regular URI parsing logic, so all validation
    (repo id, revision, empty path segments, ...) is shared with the canonical 'hf://' path.
    Only unambiguous URLs are accepted: any unrecognized route raises [`HfUriError`]. When 'endpoint'
    is provided, URLs on that custom Hub host are recognized too (and its path prefix is stripped).
    r   r5   r$   zUnrecognized host 'zC'. Expected a Hugging Face URL (e.g. 'https://huggingface.co/...').r/   r2   Nc                 ó   — g | ]}|¯|‘ŒS r   r   ©r   r�   s     r   ú
<listcomp>z$_url_to_uri_body.<locals>.<listcomp>„  s   € ÐBÐBÐB˜G¸'ÐB�ÐBÐBÐBr   z0Missing repository or bucket identifier in URL 'r3   r   r   é   zCannot parse URL 'z{': expected a '<namespace>/<name>' repository or bucket. User/organization pages and single-segment URLs are not supported.Úbucketszbuckets/zCannot parse bucket URL 'z': unsupported '/z	/' route.c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r[   ©r‘   r”   s     r   r�   z#_url_to_uri_body.<locals>.<genexpr>¡  s+   è è € ÐNÐN¸gÕ0°Ñ9Ô9ÐNÐNÐNÐNÐNÐNr   zl/' route. Only repository pages and file/folder viewer routes (blob, resolve, raw, tree, ...) can be parsed.c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r[   r™   r”   s     r   r�   z#_url_to_uri_body.<locals>.<genexpr>·  s+   è è € ÐMÐM¸WÕ/°Ñ8Ô8ÐMÐMÐMÐMÐMÐMr   rF   )r   r€   r�   r‰   r	   rW   r…   r9   ru   Úsplitr   ÚHF_URI_TYPE_PREFIXESr   rL   r   )rX   rO   r   rƒ   r„   rW   Úendpoint_hostÚendpoint_pathÚprefixÚsegmentsÚtype_prefixÚrepo_idÚrestÚactionÚtailÚdecodeds                   r   rw   rw   i  sT  € ð €Cå˜U c˜\˜\�c�c¨t°c©zÑ:Ô:€FØŒOÐ!˜r×(Ò(Ñ*Ô*€DØÕ$ XÑ.Ô.Ð.Ð.ÝØØv d k¨cÐvÐvÐvð
ñ 
ô 
ð 	
ð Œ;€Dõ $;¸8Ñ#DÔ#DÑ €M�=Øð '˜ Ò.Ð.Ø�}Ñ$ˆØ�6Š>ˆ>˜TŸ_š_¨V°c©\Ñ:Ô:ˆ>Ø�˜F™œ˜˜Ô&ˆDØBÐB t§z¢z°#¡¤ÐBÑBÔB€HØð bÝ˜SÐ&`ÐY\Ð&`Ð&`Ð&`ÐaÑaÔaÐað #€KØ�„{•iÔ4Ð4Ð4Ø˜q”kˆØ˜A˜B˜B”<ˆõ ˆ8�}„}�qÒÐÝØðU Sð Uð Uð Uð
ñ 
ô 
ð 	
ð ˜!”Ð,Ð,˜x¨œ{Ð,Ð,€GØ�A�B�BŒ<€Dà�iÒÐØð 	(Ø'˜gÐ'Ð'Ð'Øˆˆ�ØÕ5Ð5Ð5Ý Ð*mÀcÐ*mÐ*mÐ\bÐ*mÐ*mÐ*mÐnÑnÔnÐnØ�xŠxÐNÐNÈÐNÑNÔNÑNÔNˆØ.2ÐLÐ*˜'Ð*Ð* DÐ*Ð*Ð*Ð8LÀ7Ð8LÐ8LÐLà"-Ð5�ÐÐÐÐ°2€FØð $ØÐ#˜'Ð#Ð#Ð#Ø€M€FˆTØÕ/Ð/Ð/ÝØðu Sð uð u¸6ð uð uð uð
ñ 
ô 
ð 	
ð ð $àÐ#˜'Ð#Ð#Ð#ð
 �hŠhÐMÐMÈÐMÑMÔMÑMÔM€GØÐ)�gÐ)Ð) Ð)Ð)Ð)r   Ú	mount_strc                 ó  — |                       t          j        ¦  «        st          | dt          j        › d�¬¦  «        ‚| }| t	          t          j        ¦  «        d…         }|st          |dt          j        › d�¬¦  «        ‚t          ||¬¦  «        \  }}}|€t          |d¬¦  «        ‚t          j        |z   }	 t          |¦  «        }n)# t          $ r}t          ||j        ¬¦  «        |‚d}~ww xY wt          ||||¬¦  «        S )	a·  Parse a HF mount specification ('hf://...:<MOUNT_PATH>[:ro|:rw]').

    A mount specification is a HF URI followed by a local mount path and an optional read-only/read-write flag.
    The full grammar is:

    ```
    hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]
    ```

    See 'docs/source/en/package_reference/hf_uris.md' for the full specification.

    Args:
        mount_str (`str`):
            The mount string to parse. Must start with 'hf://' and contain a ':<MOUNT_PATH>' segment.

    Returns:
        [`HfMount`]: the parsed mount.

    Raises:
        [`HfUriError`]:
            If the mount string is malformed (missing mount path, invalid URI, etc.).

    Examples:
        ```py
        >>> from huggingface_hub.utils import parse_hf_mount
        >>> parse_hf_mount("hf://my-org/my-model:/data:ro")
        HfMount(source=HfUri(type='model', id='my-org/my-model', revision=None, path_in_repo=''), mount_path='/data', read_only=True)
        >>> parse_hf_mount("hf://buckets/my-org/my-bucket/sub/dir:/mnt:rw")
        HfMount(source=HfUri(type='bucket', id='my-org/my-bucket', revision=None, path_in_repo='sub/dir'), mount_path='/mnt', read_only=False)
        ```
    rs   r3   r/   Nrr   rt   zKMissing mount path. Expected ':<MOUNT_PATH>' (e.g. 'hf://org/model:/data').)rf   rg   rh   r+   )	r9   r   rG   r	   ru   Ú_split_mountro   r1   re   )	r§   r   r{   r}   rg   rh   Úuri_strrf   r;   s	            r   Úparse_hf_mountr«   »  s<  € ð@ ×Ò¥	Ô 5Ñ6Ô6ð 
ÝØØ=¥IÔ$9Ð=Ð=Ð=ð
ñ 
ô 
ð 	
ð
 €CØ•S�Ô.Ñ/Ô/Ð1Ð1Ô2€DØð VÝ˜SÐ&T½9Ô;PÐ&TÐ&TÐ&TÐUÑUÔUÐUå&2°4¸SÐ&AÑ&AÔ&AÑ#€Hˆj˜)àÐÝ˜SÐ&sÐtÑtÔtÐtõ Ô# hÑ.€Gð4Ý˜gÑ&Ô&ˆˆøÝð 4ð 4ð 4Ý˜S a¤eÐ,Ñ,Ô,°!Ð3øøøøð4øøøõ ˜&¨ZÀ9ÐSVÐWÑWÔWÐWs   Â;C Ã
C1ÃC,Ã,C1r{   r   c                ó~  — |                       d¦  «        rd|                      d¦  «        } }n/|                       d¦  «        rd|                      d¦  «        } }nd}|                      d¦  «        }|dk    r|�t          |d¬	¦  «        ‚| ddfS | d|…         }| |d
z   d…         }|st          |d¬	¦  «        ‚|||fS )z©Split the ':<MOUNT_PATH>[:ro|:rw]' suffix from 'body'.

    Returns '(location, mount_path, read_only)' where 'mount_path' is 'None' if no mount segment is present.
    rl   Trm   FNz:/éÿÿÿÿzb':ro'/':rw' suffix is only valid when a mount path is provided (e.g. 'hf://...:/<MOUNT_PATH>:ro').r/   r   z#Missing location before mount path.)ÚendswithÚremovesuffixÚrfindr	   )r{   r   rh   Úidxr}   rg   s         r   r©   r©   õ  sù   € ð
 ‡}‚}�UÑÔð Ø × 1Ò 1°%Ñ 8Ô 8�4ˆ	ˆ	Ø	�Š�uÑ	Ô	ð Ø ×!2Ò!2°5Ñ!9Ô!9�4ˆ	ˆ	àˆ	ð �*Š*�TÑ
Ô
€CØ
ˆb‚y€yØÐ ÝØØxðñ ô ð ð �T˜4ÐÐà�D�S�DŒz€HØ�c˜A‘g�i�i”€JØð MÝ˜SÐ&KÐLÑLÔLÐLØ�Z Ð*Ð*r   r}   c          	      ó   — |                       d¦  «        }|dk    rs| t          j        v r$t          |d| › dt          j        › | › d�¬¦  «        ‚t
                               | ¦  «        x}�!t          |dt          j        › |› d	�¬¦  «        ‚d
| fS | d|…         }| |dz   d…         }|t          j        v rt          j        |         |fS t
                               |¦  «        x}�t          |d|› d|› d�¬¦  «        ‚d
| fS )zÙDetect the (optional) type prefix and return '(type, remaining_location)'.

    A missing type prefix defaults to 'model'. Singular forms ('model/', 'dataset/', etc.) are explicitly rejected with a helpful error.
    r2   r­   zMissing identifier after 'z'. Expected 'z/<ID>'.r/   Nz*Type prefix must be plural. Did you mean 'z/...'?rR   r   z!Type prefix must be plural, got 'z/'. Did you mean 'z/'?)Úfindr   rœ   r	   rG   r   Úget)r}   r   Ú	slash_idxÚsingular_pluralÚfirstr£   s         r   rx   rx     sV  € ð
 —’˜cÑ"Ô"€IØ�B‚€à•yÔ5Ð5Ð5ÝØØp°ÐpÐpÍ	ÔH]ÐpÐ_gÐpÐpÐpðñ ô ð õ  /×2Ò2°8Ñ<Ô<Ð<ˆOÐIÝØØoÅÔAVÐoÐXgÐoÐoÐoðñ ô ð ð ˜Ð Ð à�Z�i�ZÔ €EØ�I ‘M�O�OÔ$€DØ•	Ô.Ð.Ð.ÝÔ-¨eÔ4°dÐ:Ð:Ý*×.Ò.¨uÑ5Ô5Ð5ˆÐBÝØÐj¸UÐjÐjÐVeÐjÐjÐjð
ñ 
ô 
ð 	
ð �HÐÐr   r|   c                óz  — |                       d¦  «        } |                      dd¦  «        }t          |¦  «        dk     s|d         r|d         st          |d| › d�¬¦  «        ‚|d         › d|d         › �}d|v rt          |d	¬¦  «        ‚t          |¦  «        d
k    r|d         nd}t	          ||d||¬¦  «        S )z8Parse the body of a bucket URI: 'namespace/name[/path]'.r2   r–   r   r   z)Bucket id must be 'namespace/name', got 'r3   r/   rF   z3Bucket URIs do not support a revision marker ('@').é   r$   N©r!   r"   r#   r%   r+   )r‚   r›   ru   r	   r    )r}   r|   r   rM   Ú	bucket_idÚpath_in_buckets         r   ry   ry   2  sâ   € ð �~Š~˜cÑ"Ô"€HØ�NŠN˜3 Ñ"Ô"€EÝ
ˆ5�z„z�A‚~€~˜U 1œX€~¨U°1¬X€~Ý˜SÐ&^ÐRZÐ&^Ð&^Ð&^Ð_Ñ_Ô_Ð_Ø˜”8Ð(Ð(˜e AœhÐ(Ð(€IØ
ˆiÐÐÝ˜SÐ&[Ð\Ñ\Ô\Ð\Ý!$ U¡¤¨q¢ �U˜1”X�X°b€NÝØØØØ#Øðñ ô ð r   c                óî  — |                       d¦  «        } | st          |d¬¦  «        ‚|                      d¦  «        }|dk    s!| d|…                              d¦  «        dk    rrd}|                      dd¦  «        }t          |¦  «        dk     rt          |d	| › d
�¬¦  «        ‚|d         › d|d         › �}t          |¦  «        dk    r|d         nd}�n| d|…         }| |dz   d…         }|st          |d¬¦  «        ‚|                     d¦  «        dk    rt          |d	|› d�¬¦  «        ‚t                               |¦  «        }	|	�?|	                     ¦   «         }|t          |¦  «        d…          	                    d¦  «        }n7|                     d¦  «        }
|
dk    r|}d}n|d|
…         }||
dz   d…         }t          |¦  «        }|st          |d¬¦  «        ‚t          |||||¬¦  «        S )z@Parse the body of a repo URI: '<repo_id>[@<revision>][/<path>]'.r2   zMissing repository id.r/   rF   r­   Nr   r–   z-Repository id must be 'namespace/name', got 'z'. r   r$   z!Missing repository id before '@'.r3   zEmpty revision after '@'.rº   )r‚   r	   r³   r7   r›   ru   rH   ÚmatchÚgroupÚremoveprefixr   r    )r}   r|   r   Úat_idxr#   rM   r¢   r%   Úrev_and_pathr¾   rµ   s              r   rz   rz   J  sH  € ð �~Š~˜cÑ"Ô"€HØð @Ý˜SÐ&>Ð?Ñ?Ô?Ð?ð
 �]Š]˜3ÑÔ€Fð �‚|€|�x   Ô(×.Ò.¨sÑ3Ô3°aÒ7Ð7àˆØ—’˜s AÑ&Ô&ˆÝˆu‰:Œ:˜Š>ˆ>Ý Ð*gÐZbÐ*gÐ*gÐ*gÐhÑhÔhÐhØ˜1”XÐ*Ð*  a¤Ð*Ð*ˆÝ#& u¡:¤:°¢> >�u˜Q”x�x°rˆ‰à˜7˜F˜7Ô#ˆØ ¨¡
  Ô-ˆØð 	OÝ Ð*MÐNÑNÔNÐNØ�=Š=˜ÑÔ Ò"Ð"Ý Ð*eÐZaÐ*eÐ*eÐ*eÐfÑfÔfÐfõ -×2Ò2°<Ñ@Ô@ˆØÐØ—{’{‘}”}ˆHØ'­¨H©¬¨¨Ô8×EÒEÀcÑJÔJˆLˆLà$×)Ò)¨#Ñ.Ô.ˆIØ˜BŠˆØ'�Ø!��à'¨
¨¨
Ô3�Ø+¨I¸©M¨O¨OÔ<�Ý˜8Ñ$Ô$ˆØð 	GÝ Ð*EÐFÑFÔFÐFåØØØØ!Øðñ ô ð r   r[   )0r_   Ú	functoolsÚreÚdataclassesr   r   Úurllib.parser   r   r   Úhuggingface_hubr   Úhuggingface_hub.errorsr	   r
   Ú_validatorsr   rœ   Úitemsr   Údictr8   ra   ÚcompilerH   Ú	frozensetÚvaluesr   r   r   r    re   rc   rp   Ú	lru_cachero   Útupler…   r‰   rv   r‘   rw   r«   r©   r`   rx   ry   rz   r   r   r   ú<module>rÑ      sq  ððð ð ð: Ð Ð Ð Ø 	€	€	€	Ø (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1à %Ð %Ð %Ð %Ð %Ð %Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @à )Ð )Ð )Ð )Ð )Ð )ð
 #\Ð"[°IÔ4R×4XÒ4XÑ4ZÔ4ZÐ"[Ñ"[Ô"[€��c˜3�h”Ð [Ð [Ñ [ð  *˜rœzÐ*MÑNÔNÐ ð $- 9¨YÔ-K×-RÒ-RÑ-TÔ-TÑ#UÔ#UÐ �)˜C”.Ð UÐ UÑ Uð .7¨YÐ7bÐ7bÐ7bÑ-cÔ-cÐ ˜I cœNÐ cÐ cÑ cð 09¨y¸)ÀVÐ9LÑ/MÔ/MÐ ˜i¨œnÐ MÐ MÑ Mð €�$ÐÑÔð|ð |ð |ð |ð |ñ |ô |ñ Ôð|ð~ €�$ÐÑÔð'ð 'ð 'ð 'ð 'ñ 'ô 'ñ Ôð'ðT�3ð ˜4ð ð ð ð ð Ôð<6ð <6�cð <6 S¨4¡Zð <6¸5ð <6ð <6ð <6ñ Ôð<6ð~( c¨D¡jð (°U¸3À¹:Às¸?Ô5Kð (ð (ð (ð (ðO  d¡
ð O¨y¸¬~ð Oð Oð Oð Oðjð j˜Cð j¨3°©:ð jÀð jð jð jð jð0 cð 0¨cð 0ð 0ð 0ð 0ðO*ð O*˜#ð O*¨¨t©ð O*¸sð O*ð O*ð O*ð O*ðd7X˜cð 7X gð 7Xð 7Xð 7Xð 7Xðt+�sð + Cð +¨E°#°s¸T±zÀ4È$Á;Ð2NÔ,Oð +ð +ð +ð +ð<˜#ð  sð ¨u°YÔ5HÈ#Ð5MÔ/Nð ð ð ð ð>ØðàÔðð 
ð	ð
 ðð ð ð ð08Øð8àÔð8ð 
ð	8ð
 ð8ð 8ð 8ð 8ð 8ð 8r   