HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/werkzeug/__pycache__/urls.cpython-310.pyc
o

"wes��@s0UdZddlmZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZd	d
lmZd	dlmZd	dlmZd	d
lmZd	dlmZejrbd	dlmZe�d�ZdZee�d��ZdZdd�eD�Z dd�e!d�D�Z"Gdd�dej#�Z$Gdd�de$�Z%Gdd�de%�Z&Gdd �d e%�Z'e�e iZ(d!e)d"<d�d�d)d*�Z*d�d4d5�Z+d�d�d7d8�Z,	9d�d�d>d?�Z-	@	A	B	#d�d�dFdG�Z.e.�Z/e.dHdIdJ�Z0d�dKdL�Z1	@	A	B	#d�d�dMdN�Z2	#d�d�dOdP�Z3d�dSdT�Z4	@	U	#d�d�dWdX�Z5	Ud�d�dYdZ�Z6d�d�d[d\�Z7d�d`da�Z8e�9dbe8�d�dfdg�Z:e;ge!dh��di�dj�R��<�Z=e:dke=�Z>e:dle=dm�Z?e:dne=do�Z@e:dpe=dq�ZA		d�d�dtdu�ZB			d�d�dydz�ZCd�d{d|�ZD	@	9	U	}	d�d�d�d��ZE	@	9	U	�		d�d�d�d��ZFd�d�d��ZG	@	�		}d�d�d�d��ZH		@	�		}d�d�d�d��ZI	9d�d�d�d��ZJ	@d�d�d�d��ZKdS)�z�Functions for working with URLs.

Contains implementations of functions from :mod:`urllib.parse` that
handle bytes and strings.
�)�annotationsN)�quote)�unquote)�	urlencode)�urlsplit)�
urlunsplit�)�_check_str_tuple)�_decode_idna)�_make_encode_wrapper)�_to_str��iter_multi_items)�datastructuresz^[a-zA-Z0-9+-.]+$zKabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~$!'()*+,;�ascii�0123456789ABCDEFabcdefcCs8i|]}tD]}|�|���d�t|�|��d��qqS)r�)�
_hexdigits�encode�int)�.0�a�b�r�F/home/arjun/projects/env/lib/python3.10/site-packages/werkzeug/urls.py�
<dictcomp>*s� ��rcCsg|]}d|d���d��qS)�%�02Xr)r)r�charrrr�
<listcomp>/sr�c@s6eZdZUded<ded<ded<ded<ded<dS)�	_URLTuple�str�scheme�netloc�path�query�fragmentN)�__name__�
__module__�__qualname__�__annotations__rrrrr!2s
r!cs>eZdZUdZdZded<ded<ded<ded<d?�fdd
�Zd@dd�ZdAdd�Ze	dBdd��Z
e	dBdd��Ze	dCdd��Ze	dBdd��Z
e	dBdd��Ze	dBdd��Ze	dBd d!��Ze	dBd"d#��ZdDd%d&�Zd?d'd(�Zd@d)d*�Zd@d+d,�Zd@d-d.�ZdEd/d0�ZdEd1d2�Z	3dFdGd6d7�ZdHd9d:�ZdId;d<�ZdId=d>�Z�ZS)J�BaseURLz�Superclass of :py:class:`URL` and :py:class:`BytesURL`.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
    rr"�_at�_colon�	_lbracket�	_rbracket�args�t.Any�kwargs�returncs4tjd|j�d�tdd�t�j|g|�Ri|��S)Nz'werkzeug.urls.z\' is deprecated and will be removed in Werkzeug 3.0. Use the 'urllib.parse' library instead.���
stacklevel)�warnings�warnr(�DeprecationWarning�super�__new__)�clsr1r3��	__class__rrr<Gs�zBaseURL.__new__cCs|��S�N)�to_url��selfrrr�__str__PszBaseURL.__str__cKs|jdi|��S)z�Return an URL with the same values, except for those parameters
        given new values by whichever keyword arguments are specified.Nr)�_replace)rCr3rrr�replaceSszBaseURL.replace�
str | NonecC�|��dS)z�The host part of the URL if available, otherwise `None`.  The
        host is either the hostname or the IP address mentioned in the
        URL.  It will not contain the port.
        r)�_split_hostrBrrr�hostXszBaseURL.hostcCsH|j}|dur"t|t�r"z|�d��d�}W|Sty!Y|Sw|S)a Works exactly like :attr:`host` but will return a result that
        is restricted to ASCII.  If it finds a netloc that is not ASCII
        it will attempt to idna decode it.  This is useful for socket
        operations when the URL might include internationalized characters.
        N�idnar)rJ�
isinstancer"r�decode�UnicodeError�rC�rvrrr�
ascii_host`s��zBaseURL.ascii_host�
int | Nonec	CsTztt|��d��}d|krdkr|WSWdSWdSttfy)YdSw)z}The port in the URL as an integer if it was present, `None`
        otherwise.  This does not fill in default ports.
        rri��N)rrrI�
ValueError�	TypeErrorrOrrr�portos����zBaseURL.portcCrH)zSThe authentication part in the URL if available, `None`
        otherwise.
        r)�
_split_netlocrBrrr�auth|�zBaseURL.authcC� |��d}|durt|�SdS)z�The username if it was part of the URL, `None` otherwise.
        This undergoes URL decoding and will always be a string.
        rN��_split_auth�_url_unquote_legacyrOrrr�username��zBaseURL.usernamecCrH)z�The username if it was part of the URL, `None` otherwise.
        Unlike :attr:`username` this one is not being decoded.
        r�r[rBrrr�raw_username�rXzBaseURL.raw_usernamecCrY)z�The password if it was part of the URL, `None` otherwise.
        This undergoes URL decoding and will always be a string.
        rNrZrOrrr�password�r^zBaseURL.passwordcCrH)z�The password if it was part of the URL, `None` otherwise.
        Unlike :attr:`password` this one is not being decoded.
        rr_rBrrr�raw_password�rXzBaseURL.raw_password�ds.MultiDict[str, str]cOst|jg|�Ri|��S)z�Decodes the query part of the URL.  Ths is a shortcut for
        calling :func:`url_decode` on the query argument.  The arguments and
        keyword arguments are forwarded to :func:`url_decode` unchanged.
        )�
url_decoder&�rCr1r3rrr�decode_query�szBaseURL.decode_querycOstt|g|�Ri|���S)z�Joins this URL with another one.  This is just a convenience
        function for calling into :meth:`url_join` and then parsing the
        return value again.
        )�	url_parse�url_joinrerrr�join�szBaseURL.joincCst|�S)z�Returns a URL string or bytes depending on the type of the
        information stored.  This is just a convenience function
        for calling :meth:`url_unparse` for this URL.
        )�url_unparserBrrrrA�szBaseURL.to_urlc
Cs�|jpd}d|vrd|�d�}|j}|dur|�d|��}d�tdt|jp&dddd�t|jp/dddd�g��}|r@|�d	|��}|S)
z6Encodes the netloc part to an ASCII safe URL as bytes.��:�[�]N�utf-8�strictz/:%�@)rQrUri�filter�	url_quoter`rb)rCrPrUrWrrr�
encode_netloc�s"
���	zBaseURL.encode_netloccCs�|jpd}t|t�r|��}t|�}d|vrd|�d�}|j}|dur*|�d|��}d�tdt|j	p3dd�t|j
p:dd�g��}|rI|�d|��}|S)z&Decodes the netloc part into a string.rkrlrmrnNz/:%@rq)rJrL�bytesrMr
rUrirrr\r`rb)rCrJrPrUrWrrr�
decode_netloc�s(

���	zBaseURL.decode_netloccC�tt|��S)a*Returns a :class:`BytesURL` tuple that holds a URI.  This will
        encode all the information in the URL properly to ASCII using the
        rules a web browser would follow.

        It's usually more interesting to directly call :meth:`iri_to_uri` which
        will return a string.
        )rg�
iri_to_urirBrrr�to_uri_tuple�szBaseURL.to_uri_tuplecCrw)aSReturns a :class:`URL` tuple that holds a IRI.  This will try
        to decode as much information as possible in the URL without
        losing information similar to how a web browser does it for the
        URL bar.

        It's usually more interesting to directly call :meth:`uri_to_iri` which
        will return a string.
        )rg�
uri_to_irirBrrr�to_iri_tuple�s	zBaseURL.to_iri_tupleN�
pathformat�tuple[str | None, str | None]cCs6|jdkrdSt|j�}|jpd}|durtjdkrd}nd}|dkr||dd�dkrJ|dd	���rJ|d	d
�dvrJ|dd	��d|d
d���}|dd
�d
v}ddl}|�|�}|r{|dur{|�	d��
dd�}t|�d	kru|\}}n|d}d}n|dkr�ddl}|�|�}nt
d|����|dvr�d}||fS)a@Returns a tuple with the location of the file in the form
        ``(server, location)``.  If the netloc is empty in the URL or
        points to localhost, it's represented as ``None``.

        The `pathformat` by default is autodetection but needs to be set
        when working with URLs of a specific system.  The supported values
        are ``'windows'`` when working with Windows or DOS paths and
        ``'posix'`` when working with posix paths.

        If the URL does not point to a local file, the server and location
        are both represented as ``None``.

        :param pathformat: The expected format of the path component.
                           Currently ``'windows'`` and ``'posix'`` are
                           supported.  Defaults to ``None`` which is
                           autodetect.
        �file�NNN�nt�windows�posixr�/r5�z|:rl)z\\\z///r�\rkzInvalid path format )z	127.0.0.1z::1�	localhost)r#�url_unquoter%r$�os�name�isalpha�ntpath�normpath�lstrip�split�len�	posixpathrT)rCr|r%rJ�
windows_sharer��partsr�rrr�get_file_location�s8



0

�zBaseURL.get_file_location�tuple[str | None, str]cCs2|j|jvr|j�|j�\}}}||fSd|jfSr@)r-r$�	partition)rCrW�_r$rrrrV=s
zBaseURL._split_netloccCs@|��d}|s
dS|j|vr|dfS|�|j�\}}}||fS)Nrr)rVr.r�)rCrWr]r�rarrrr[Cs
zBaseURL._split_authcCs�|��d}|s
dS|�|j�s&|j|vr"|�|j�\}}}||fS|dfS|�|j�}|dkr4|dfS|d|�}||dd�}|�|j�rP||dd�fS|dfS)Nrrr)rV�
startswithr/r.r��findr0)rCrPrJr�rU�idx�restrrrrIMs 
zBaseURL._split_host)r1r2r3r2r4r,�r4r")r3r2r4r,)r4rG)r4rR)r1r2r3r2r4rc)r4r,r@)r|rGr4r})r4r�)r4r})r(r)r*�__doc__�	__slots__r+r<rDrF�propertyrJrQrUrWr]r`rarbrfrirArtrvryr{r�rVr[rI�
__classcell__rrr>rr,:sL

	
		







�
>

r,c@s0eZdZdZdZdZdZdZdZdddd�Z	dS)�URLz�Represents a parsed URL.  This behaves like a regular tuple but
    also has some extra attributes that give further insight into the
    URL.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
    rrqrlrmrnrorF�charsetr"�errorsr4�BytesURLc	C�:t|j�d�|��|j�||�|j�||�|j�||��S)z�Encodes the URL to a tuple made out of bytes.  The charset is
        only being used for the path, query and fragment.
        r)r�r#rrtr%r&r'�rCr�r�rrrrr�
�z
URL.encodeN�rorF)r�r"r�r"r4r�)
r(r)r*r�r�r-r.r/r0rrrrrr�csr�c@sDeZdZdZdZdZdZdZdZdd	d
�Z	ddd
�Z
dddd�ZdS)r�z�Represents a parsed URL in bytes.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
    r�@�:�[�]r4r"cCs|���dd�S)NrorF)rArMrBrrrrD��zBytesURL.__str__rucCs|jS)z&Returns the netloc unchanged as bytes.)r$rBrrrrt�szBytesURL.encode_netlocrorFr�r�r�c	Cr�)z�Decodes the URL to a tuple made out of strings.  The charset is
        only being used for the path, query and fragment.
        r)r�r#rMrvr%r&r'r�rrrrM�r�zBytesURL.decodeNr�)r4rur�)r�r"r�r"r4r�)r(r)r*r�r�r-r.r/r0rDrtrMrrrrr�s

r�z&dict[frozenset[int], dict[bytes, int]]�
_unquote_mapsrk�string�str | bytes�unsafer4rucs�t|t�r
|�d�}t�t�r��d��tt����t|�d��}tt|d��}zt�}Wnt	yF�fdd�t
��D�}t�<Ynw|D]'}|dd�}||vrf|�||�|�
|dd��qI|�d�|�
|�qIt|�S)Nro�%�csi|]\}}|�vr||�qSrr)r�hr�r�rrr�sz%_unquote_to_bytes.<locals>.<dictcomp>r5�%)rLr"r�	frozenset�	bytearray�iterr��nextr��KeyError�
_hextobyte�items�append�extendru)r�r��groups�result�hex_to_byte�group�coderr�r�_unquote_to_bytes�s,




��
r��obj�1t.Mapping[str, str] | t.Iterable[tuple[str, str]]r�r"�sort�bool�key�+t.Callable[[tuple[str, str]], t.Any] | None�t.Iterator[str]c
cs��ddlm}||�}|rt||d�}|D]3\}}|durqt|t�s+t|��|�}n|}t|t�s:t|��|�}	n|}	t|��dt|	���VqdS)Nrr
)r��=)rr�sortedrLrur"r�_fast_url_quote_plus)
r�r�r�r�r�iterable�key_str�	value_str�	key_bytes�value_bytesrrr�_url_encode_impl�s �

�r��valuecCs4z	t|dd|d�WStyt|d|d�YSw)Nrorp)r�r�r��latin1)r�r�)r�rN)r�r�rrrr\�s
�r\T�urlr#rG�allow_fragmentsc
s�tjdtdd�t|��t|t�}|dur�d�}�d�}}}|��d��}|dkrYt�t	|d|�dd	��rY||d
d�}|rNt
�fdd�|D��rY|d|���|}}|dd��d
�kr�t|�}	�d�D]}
|�|
d�}|dkr|t
|	|�}	qk|d|	�||	d�}}�d�|vr��d�|vs��d�|vr��d�|vr�td��|r��d�|vr�|��d�d
�\}}�d�|vr�|��d�d
�\}}|r�tnt}||||||�S)a�Parses a URL from a string into a :class:`URL` tuple.  If the URL
    is lacking a scheme it can be provided as second argument. Otherwise,
    it is ignored.  Optionally fragments can be stripped from the URL
    by setting `allow_fragments` to `False`.

    The inverse of this function is :func:`url_unparse`.

    :param url: the URL to parse.
    :param scheme: the default schema to use if the URL is schemaless.
    :param allow_fragments: if set to `False` a fragment will be removed
                            from the URL.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.urlsplit`` instead.
    zq'werkzeug.urls.url_parse' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.urlsplit' instead.r5r6NrkrlrrF)r�rc3s�|]	}|�d�vVqdS)�
0123456789Nr�r�c��srr�	<genexpr>
��zurl_parse.<locals>.<genexpr>�//�/?#rmrnzInvalid IPv6 URL�#�?)r8r9r:rrLr"r��
_scheme_re�matchr�any�lowerr��minrSr�r�r�)
r�r#r��
is_text_basedr$r&r'�ir��delimr��wdelim�result_typerr�rrg�s@�
"
�rgrorp�/:r��safe�t.Callable[[bytes], str]cspt�t�r��||��t|t�r|�||�}tt���tBtt|����fdd�td�D��d�fdd	�}|S)a�Precompile the translation table for a URL encoding function.

    Unlike :func:`url_quote`, the generated function only takes the
    string to quote.

    :param charset: The charset to encode the result with.
    :param errors: How to handle encoding errors.
    :param safe: An optional sequence of safe characters to never encode.
    :param unsafe: An optional sequence of unsafe characters to always encode.
    cs(g|]}|�vrt|�nd|d���qS)rr)�chrr��r�rrr;s(z(_make_fast_url_quote.<locals>.<listcomp>r r�rur4r"csd��fdd�|D��S)Nrkcsg|]}�|�qSrrr���tablerrr>sz7_make_fast_url_quote.<locals>.quote.<locals>.<listcomp>)ri�r�r�rrr=sz#_make_fast_url_quote.<locals>.quoteN�r�rur4r")rLr"rr�r��_always_safe�range)r�r�r�r�rr)r�r�r�_make_fast_url_quote$s

r�� �+)r�r�cCst|��dd�S)Nr�r�)�_fast_quote_plusrFr�rrrr�Gr�r�cCs�tjdtdd�t|tttf�st|�}t|t�r|�||�}t|t�r*|�||�}t|t�r5|�||�}tt|��t	Btt|��}t�}t|�D]}||vrV|�
|�qJ|�t|�qJt|��
|�S)a�URL encode a single string with a given encoding.

    :param s: the string to quote.
    :param charset: the charset to be used.
    :param safe: an optional sequence of safe characters.
    :param unsafe: an optional sequence of unsafe characters.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.quote`` instead.

    .. versionadded:: 0.9.2
       The `unsafe` parameter was added.
    zn'werkzeug.urls.url_quote' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.quote' instead.r5r6)r8r9r:rLr"rur�rr�r�r�r��
_bytetohexrM)r�r�r�r�r�rPrrrrrsKs(�


rscCs,tjdtdd�t||||dd��dd�S)aOURL encode a single string with the given encoding and convert
    whitespace to "+".

    :param s: The string to quote.
    :param charset: The charset to be used.
    :param safe: An optional sequence of safe characters.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.quote_plus`` instead.
    zx'werkzeug.urls.url_quote_plus' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.quote_plus' instead.r5r6r�r�)r8r9r:rsrF)r�r�r�r�rrr�url_quote_plusxs
�r��
components�tuple[str, str, str, str, str]cCs�tjdtdd�t|�|\}}}}}t|�}|d�}|s&|rE|�|d��rE|r8|dd�|d�kr8|d�|}|d�|p@|d�|}n|rK||7}|rU||d	�|}|r_||d
�|}|ri||d�|}|S)aiThe reverse operation to :meth:`url_parse`.  This accepts arbitrary
    as well as :class:`URL` tuples and returns a URL as a string.

    :param components: the parsed URL as tuple which should be converted
                       into a URL string.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.urlunsplit`` instead.
    zu'werkzeug.urls.url_unparse' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.urlunsplit' instead.r5r6rkr�Nrr�rlr�r�)r8r9r:r	rr�)r�r#r$r%r&r'r�r�rrrrj�s,
�rjrFr�cCs2tjdtdd�t||�}|dur|S|�||�S)a�URL decode a single string with a given encoding.  If the charset
    is set to `None` no decoding is performed and raw bytes are
    returned.

    :param s: the string to unquote.
    :param charset: the charset of the query string.  If set to `None`
        no decoding will take place.
    :param errors: the error handling for the charset decoding.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.unquote`` instead.
    zr'werkzeug.urls.url_unquote' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.unquote' instead.r5r6N)r8r9r:r�rM)r�r�r�r�rPrrrr��s�
r�cCs@tjdtdd�t|t�r|�dd�}n|�dd�}t|||�S)a&URL decode a single string with the given `charset` and decode "+" to
    whitespace.

    Per default encoding errors are ignored.  If you want a different behavior
    you can set `errors` to ``'replace'`` or ``'strict'``.

    :param s: The string to unquote.
    :param charset: the charset of the query string.  If set to `None`
        no decoding will take place.
    :param errors: The error handling for the `charset` decoding.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.unquote_plus`` instead.
    z|'werkzeug.urls.url_unquote_plus' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.unquote_plus' instead.r5r6r�r��+� )r8r9r:rLr"rFr�)r�r�r�rrr�url_unquote_plus�s�
rcCs�tjdtdd�t||d��dd�}|�d�r0|dd	���r0|d	d
�dvr0d|dd
���}t|�}t|j	|dd�}t
|j|dd�}t
|j|dd�}t
|j|��|||f�S)aFSometimes you get an URL by a user that just isn't a real URL because
    it contains unsafe characters like ' ' and so on. This function can fix
    some of the problems in a similar way browsers handle data entered by the
    user:

    >>> url_fix('http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)')
    'http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)'

    :param s: the string with the URL to fix.
    :param charset: The target charset for the URL if the url was given
        as a string.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0.
    zJ'werkzeug.urls.url_fix' is deprecated and will be removed in Werkzeug 3.0.r5r6rFr�r�zfile://���
)z:/z|/zfile:///Nz
/%+$!*'(),r�z:&%=+$!*'(),)r8r9r:rrFr�r�rgrsr%r�r&r'rjr#rt)r�r�r�r%�qs�anchorrrr�url_fix�s�*r	�erN�tuple[str, int]cCs$t|j|j|j�dd�}||jfS)zRUsed in :func:`uri_to_iri` after unquoting to re-quote any
    invalid bytes.
    rkr�)r�object�start�end)r
�outrrr�_codec_error_url_quotes
r�werkzeug.url_quoter��chars� t.Callable[[str, str, str], str]csLd�dd�t|�D��}t�d|�d�tj��d�fdd�}d
|��|_|S)z�Create a function that unquotes all percent encoded characters except those
    given. This allows working with unquoted characters if possible while not changing
    the meaning of a given part of a URL.
    �|css�|]	}t|�d�VqdS)rN)�ordr�rrrr�-r�z%_make_unquote_part.<locals>.<genexpr>z((?:%(?:z))+)r�r"�encodingr�r4csHt��|��}g}|D]}|�t|||��|�t|d��qd�|�S)Nrk)r�r�r�rr�ri)r�rr�r�r�part��patternrr�_unquote_partial0s
z,_make_unquote_part.<locals>._unquote_partial�	_unquote_N)r�r"rr"r�r"r4r")rir��re�compile�Ir()r�r�choicesrrrr�_make_unquote_part(s

r �!r��r'r&z&=+#r%r��userz:@/?#�uri�$str | tuple[str, str, str, str, str]c	CsFt|t�rtjdtdd�t|�}t|t�r"tjdtdd�|��}|dur/tjdtdd�nd}|dur>tjdtdd�nd	}t|�}t	|j
||�}t|j||�}t
|j||�}|jrbt|j�}nd
}d|vrnd|�d
�}|jry|�d|j��}|jr�t|j||�}|jr�|�dt|j||���}|�d|��}t|j||||f�S)aConvert a URI to an IRI. All valid UTF-8 characters are unquoted,
    leaving all reserved and invalid characters quoted. If the URL has
    a domain, it is decoded from Punycode.

    >>> uri_to_iri("http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF")
    'http://\u2603.net/p\xe5th?q=\xe8ry%DF'

    :param uri: The URI to convert.
    :param charset: The encoding to encode unquoted bytes with.
    :param errors: Error handler to use during ``bytes.encode``. By
        default, invalid bytes are left quoted.

    .. versionchanged:: 2.3
        Passing a tuple or bytes, and the ``charset`` and ``errors`` parameters, are
        deprecated and will be removed in Werkzeug 3.0.

    .. versionchanged:: 2.3
        Which characters remain quoted is specific to each part of the URL.

    .. versionchanged:: 0.15
        All reserved and invalid characters remain quoted. Previously,
        only some reserved characters were preserved, and invalid bytes
        were replaced instead of left quoted.

    .. versionadded:: 0.6
    �HPassing a tuple is deprecated and will not be supported in Werkzeug 3.0.r5r6�FPassing bytes is deprecated and will not be supported in Werkzeug 3.0.N�JThe 'charset' parameter is deprecated and will be removed in Werkzeug 3.0.ro�IThe 'errors' parameter is deprecated and will be removed in Werkzeug 3.0.rrkrlrmrnrq)rL�tupler8r9r:rrurMr�
_unquote_pathr%�_unquote_queryr&�_unquote_fragmentr'�hostnamer
rUr]�
_unquote_userrar#)	r$r�r�r�r%r&r'r$rWrrrrzHsZ
�
���rz�iri�safe_conversion�bool | NonecCs�|dur
tjdtdd�nd}t|t�r tjdtdd�t|�}t|t�r2tjdtdd�|�|�}|dur?tjdtdd�nd	}|durMtjd
tdd�|rkz|�d�}t	|�
��dkr`|WSWn	tyjYnwt|�}t
|jd
||d�}t
|jd||d�}t
|jd||d�}|jr�|j�d��d�}	nd}	d|	vr�d|	�d�}	|jr�|	�d|j��}	|jr�t
|jdd�}
|jr�t
|jdd�}|
�d|��}
|
�d|	��}	t|j|	|||f�S)a Convert an IRI to a URI. All non-ASCII and unsafe characters are
    quoted. If the URL has a domain, it is encoded to Punycode.

    >>> iri_to_uri('http://\u2603.net/p\xe5th?q=\xe8ry%DF')
    'http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF'

    :param iri: The IRI to convert.
    :param charset: The encoding of the IRI.
    :param errors: Error handler to use during ``bytes.encode``.

    .. versionchanged:: 2.3
        Passing a tuple or bytes, and the ``charset`` and ``errors`` parameters, are
        deprecated and will be removed in Werkzeug 3.0.

    .. versionchanged:: 2.3
        Which characters remain unquoted is specific to each part of the URL.

    .. versionchanged:: 2.3
        The ``safe_conversion`` parameter is deprecated and will be removed in Werkzeug
        2.4.

    .. versionchanged:: 0.15
        All reserved characters remain unquoted. Previously, only some reserved
        characters were left unquoted.

    .. versionchanged:: 0.9.6
       The ``safe_conversion`` parameter was added.

    .. versionadded:: 0.6
    Nr(r5r6ror&r'r)rpzRThe 'safe_conversion' parameter is deprecated and will be removed in Werkzeug 3.0.rrz%!$&'()*+,/:;=@)r�rr�z%!$&'()*+,/:;=?@z%!#$&'()*+,/:;=?@rKrkrlrmrnz%!$&'()*+,;=r�rq)r8r9r:rLr*rrurMrr�r�rNrrr%r&r'r.rUr]rar#)r0r�r�r1�	ascii_irir�r%r&r'r$rW�pass_quotedrrrrx�s~$�
�
�
��
��
�rxcCsHz|�d�WntyYt|�Swt|�dd��dkr |St|�S)a�The URL scheme ``itms-services://`` must contain the ``//`` even though it does
    not have a host component. There may be other invalid schemes as well. Currently,
    responses will always call ``iri_to_uri`` on the redirect ``Location`` header, which
    removes the ``//``. For now, if the IRI only contains ASCII and does not contain
    spaces, pass it on as-is. In Werkzeug 3.0, this should become a
    ``response.process_location`` flag.

    :meta private:
    rNr)rrNr�r�rx)r0rrr�_invalid_iri_to_uri s
�r5�&�t.AnyStr�
include_empty�	separatorr=�type[ds.MultiDict] | NonerccCs�tjdtdd�|durddlm}|}t|t�r&t|t�s&|�|p#d�}nt|t�r7t|t�s7|�	|p5d�}|t
|�|�|||��S)a�Parse a query string and return it as a :class:`MultiDict`.

    :param s: The query string to parse.
    :param charset: Decode bytes to string with this charset. If not
        given, bytes are returned as-is.
    :param include_empty: Include keys with empty values in the dict.
    :param errors: Error handling behavior when decoding bytes.
    :param separator: Separator character between pairs.
    :param cls: Container to hold result instead of :class:`MultiDict`.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.parse_qs`` instead.

    .. versionchanged:: 2.1
        The ``decode_keys`` parameter was removed.

    .. versionchanged:: 0.5
        In previous versions ";" and "&" could be used for url decoding.
        Now only "&" is supported. If you want to use ";", a different
        ``separator`` can be provided.

    .. versionchanged:: 0.5
        The ``cls`` parameter was added.
    zr'werkzeug.urls.url_decode' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.parse_qs' instead.r5r6Nr��	MultiDictr)r8r9r:rr<rLr"rMrur�_url_decode_implr�)r�r�r8r�r9r=r<rrrrd5s" ���rd�&�stream�t.IO[bytes]�limitrRcCsVtjdtdd�ddlm}||||�}t||||�}	|dur'ddlm}
|
}||	�S)a�Works like :func:`url_decode` but decodes a stream.  The behavior
    of stream and limit follows functions like
    :func:`~werkzeug.wsgi.make_line_iter`.  The generator of pairs is
    directly fed to the `cls` so you can consume the data while it's
    parsed.

    :param stream: a stream with the encoded querystring
    :param charset: the charset of the query string.  If set to `None`
        no decoding will take place.
    :param include_empty: Set to `False` if you don't want empty values to
                          appear in the dict.
    :param errors: the decoding error behavior.
    :param separator: the pair separator to be used, defaults to ``&``
    :param cls: an optional dict class to use.  If this is not specified
                       or `None` the default :class:`MultiDict` is used.
    :param limit: the content length of the URL data.  Not necessary if
                  a limited stream is provided.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.parse_qs`` instead.

    .. versionchanged:: 2.1
        The ``decode_keys`` and ``return_iterator`` parameters were removed.

    .. versionadded:: 0.8
    zy'werkzeug.urls.url_decode_stream' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.parse_qs' instead.r5r6r)�make_chunk_iterNr;)r8r9r:�wsgirBr=rr<)r?r�r8r�r9r=rArB�	pair_iter�decoderr<rrr�url_decode_streamks#�rFrD�t.Iterable[t.AnyStr]�t.Iterator[tuple[str, str]]c	csl�|D]0}|sqt|�}|d�}||vr|�|d�\}}n	|s q|}|d�}t|||�t|||�fVqdS)Nr�rrk)rr�r)	rDr�r8r��pairr��equalr�r�rrrr=�s �

��r=FcCs.tjdtdd�t|d�}|�t||||��S)aPURL encode a dict/`MultiDict`.  If a value is `None` it will not appear
    in the result string.  Per default only values are encoded into the target
    charset strings.

    :param obj: the object to encode into a query string.
    :param charset: the charset of the query string.
    :param sort: set to `True` if you want parameters to be sorted by `key`.
    :param separator: the separator to be used for the pairs.
    :param key: an optional function to be used for sorting.  For more details
                check out the :func:`sorted` documentation.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.urlencode`` instead.

    .. versionchanged:: 2.1
        The ``encode_keys`` parameter was removed.

    .. versionchanged:: 0.5
        Added the ``sort``, ``key``, and ``separator`` parameters.
    zs'werkzeug.urls.url_encode' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urlencode' instead.r5r6r)r8r9r:rrir�)r�r�r�r�r9rrr�
url_encode�s�
rK�t.IO[str] | None�Nonec	Csbtjdtdd�t|d�}t||||�}|dur|St|�D]\}}|r)|�|�|�|�qdS)a�Like :meth:`url_encode` but writes the results to a stream
    object.  If the stream is `None` a generator over all encoded
    pairs is returned.

    :param obj: the object to encode into a query string.
    :param stream: a stream to write the encoded object into or `None` if
                   an iterator over the encoded pairs should be returned.  In
                   that case the separator argument is ignored.
    :param charset: the charset of the query string.
    :param sort: set to `True` if you want parameters to be sorted by `key`.
    :param separator: the separator to be used for the pairs.
    :param key: an optional function to be used for sorting.  For more details
                check out the :func:`sorted` documentation.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.urlencode`` instead.

    .. versionchanged:: 2.1
        The ``encode_keys`` parameter was removed.

    .. versionadded:: 0.8
    zz'werkzeug.urls.url_encode_stream' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urlencode' instead.r5r6rN)r8r9r:rr��	enumerate�write)	r�r?r�r�r�r9�genr��chunkrrr�url_encode_stream�s�

rR�basecstjdtdd�t|t�rt|�}t|t�rt|�}t||f�t|��|s(|S|s,|St||d�\}}}}}t|||�\}}	}
}}||krH|S|	rSt||	|
||f�S|}	|
dd��d�krg|
�	�d��}
n |
su|�	�d��}
|st|}n|�	�d��dd�|
�	�d��}
|
d�d	�kr��d
�|
d<�fdd�|
D�}
	d}t
|
�d}||kr�|
|�d�kr�|
|d�d
��d�fvr�|
|d|d�=n	|d7}||ks�nq��d
��d�g}|
dd�|kr�|
d=|
dd�|ks�d��|
�}
t||	|
||f�S)aqJoin a base URL and a possibly relative URL to form an absolute
    interpretation of the latter.

    :param base: the base URL for the join operation.
    :param url: the URL to join.
    :param allow_fragments: indicates whether fragments should be allowed.

    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.urljoin`` instead.
    zo'werkzeug.urls.url_join' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urljoin' instead.r5r6)r�Nrr�����.rkcsg|]
}|�d�kr|�qS)rUr)r�segmentr�rrrG�zurl_join.<locals>.<listcomp>Tz..)r8r9r:rLr*rjr	rrgr�r�ri)rSr�r��bscheme�bnetloc�bpath�bquery�	bfragmentr#r$r%r&r'�segmentsr��n�unwanted_markerrr�rrhsh�

��$,���rhrcCs dd�t|�D�}t|d|d�S)NcSsg|]
}|ddur|�qS)rNr)r�xrrrr_rWz_urlencode.<locals>.<listcomp>z!$'()*,/:;?@)r�r)rr)r&rr�rrr�
_urlencode\sra)rk)r�r�r�r�r4ru)
r�r�r�r"r�r�r�r�r4r�)r�r"r�r"r4r")NT)r�r"r#rGr�r�r4r,)rorpr�rk)
r�r"r�r"r�r�r�r�r4r�r�)r�r�r�r"r�r"r�r�r�r�r4r")rorprk)
r�r"r�r"r�r"r�r"r4r")r�rr4r")rorFrk)
r�r�r�r"r�r"r�r"r4r"r�)r�r�r�r"r�r"r4r")ro)r�r"r�r"r4r")r
rNr4r)r�r"rr"r4rr)r$r%r�rGr�rGr4r")NNN)
r0r%r�rGr�rGr1r2r4r")r0r"r4r")roTrFr6N)r�r7r�r"r8r�r�r"r9r"r=r:r4rc)roTrFr>NN)r?r@r�r"r8r�r�r"r9rur=r:rArRr4rc)
rDrGr�r"r8r�r�r"r4rH)roFNr6)r�r�r�r"r�r�r�r�r9r"r4r")NroFNr6)r�r�r?rLr�r"r�r�r�r�r9r"r4rM)T)rSr%r�r%r�r�r4r")r&r�rr"r4r")Lr��
__future__r�codecsr�r�typing�tr8�urllib.parserrrrr�	_internalr	r
rrrr�
TYPE_CHECKINGrk�dsrr��_always_safe_charsr�rr�rr�r�r��
NamedTupler!r,r�r�r�r+r�r�r\rgr��_fast_url_quoter�r�rsr�rjr�rr	r�register_errorr rurM�_always_unsafer-r,r+r/rzrxr5rdrFr=rKrRrhrarrrr�<module>s�
��+!
�>�
�.�
*�� 
&


�_�
{�8�
7�'�2�R�