
    2i5                    r    d dl mZ d dlZd dlZddlmZ ddgZdZej                   G d d             Z
d
d	Zy)    )annotationsN   )
InvalidURI	parse_uriWebSocketURIz:/?#[]@!$&'()*+,;=c                      e Zd ZU dZded<   ded<   ded<   ded<   ded	<   d
Zded<   d
Zded<   edd       Zedd       Z	y
)r   a  
    WebSocket URI.

    Attributes:
        secure: :obj:`True` for a ``wss`` URI, :obj:`False` for a ``ws`` URI.
        host: Normalized to lower case.
        port: Always set even if it's the default.
        path: May be empty.
        query: May be empty if the URI doesn't include a query component.
        username: Available when the URI contains `User Information`_.
        password: Available when the URI contains `User Information`_.

    .. _User Information: https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1

    boolsecurestrhostintportpathqueryNz
str | Noneusernamepasswordc                x    | j                   r| j                   }nd}| j                  r|d| j                  z   z  }|S )N/?)r   r   )selfresource_names     V/var/www/html/marco-python-backend/venv/lib/python3.12/site-packages/websockets/uri.pyr   zWebSocketURI.resource_name*   s7    99 IIMM::S4::--M    c                h    | j                   y | j                  J | j                   | j                  fS )N)r   r   )r   s    r   	user_infozWebSocketURI.user_info4   s2    == }}(((t}}--r   )returnr   )r   ztuple[str, str] | None)
__name__
__module____qualname____doc____annotations__r   r   propertyr   r    r   r   r   r      s\      L
I
I
IJHjHj  . .r   c           	        t         j                  j                  |       }|j                  dvrt	        | d      |j
                  t	        | d      |j                  dk7  rt	        | d      |j                  dk(  }|j
                  }|j                  xs |rdnd}|j                  }|j                  }|j                  }|j                  }||t	        | d	      	 | j                  d
       t#        |||||||      S # t        $ r |j                  d      j                         }t         j                  j                  |t               }t         j                  j                  |t               }|N|J t         j                  j                  |t               }t         j                  j                  |t               }Y w xY w)z
    Parse and validate a WebSocket URI.

    Args:
        uri: WebSocket URI.

    Returns:
        Parsed WebSocket URI.

    Raises:
        InvalidURI: If ``uri`` isn't a valid WebSocket URI.

    )wswsszscheme isn't ws or wsszhostname isn't provided z"fragment identifier is meaninglessr&   i  P   z"username provided without passwordasciiidna)safe)urllibparseurlparseschemer   hostnamefragmentr   r   r   r   r   encodeUnicodeEncodeErrordecodequoteDELIMSr   )	uriparsedr
   r   r   r   r   r   r   s	            r   r   r   <   s    \\""3'F}}M)677788"BCC]]e#F??D;;1&3bD;;DLLEHH  0BCCA

7 dD%8LL  	A {{6"))+||!!$V!4""5v"6'''||))()@H||))()@H	As   C? ?CGG)r7   r   r   r   )
__future__r   dataclassesurllib.parser,   
exceptionsr   __all__r6   	dataclassr   r   r#   r   r   <module>r?      sJ    "   " 
' 
 (. (. (.V/Mr   