
    h	                     X   d dl mZ d dlmZ ddgZej                  j                  e       ej                  j                  e       ej                  j                  e       ej                  j                  e       ej                  j                  e       dZed	d       Zed        Zy)
    )public)parsewswss)
create_url	parse_urlNc                 b   t        |      t        k(  sJ | dk(  rd|z  }n;|"t        |      t        k(  r|t        dd      v sJ |d| |fz  }n|rd| z  }nd| z  }|rd	}nd
}|t	        j
                  |      }nd}|t	        j                  |      }nd}t	        j                  |||d|df      S )a  
    Create a WebSocket URL from components.

    :param hostname: WebSocket server hostname (for TCP/IP sockets) or
        filesystem path (for Unix domain sockets).
    :type hostname: str

    :param port: For TCP/IP sockets, WebSocket service port or ``None`` (to select default
        ports ``80`` or ``443`` depending on ``isSecure``. When ``hostname=="unix"``,
        this defines the path to the Unix domain socket instead of a TCP/IP network socket.
    :type port: int or str

    :param isSecure: Set ``True`` for secure WebSocket (``wss`` scheme).
    :type isSecure: bool

    :param path: WebSocket URL path of addressed resource (will be
        properly URL escaped). Ignored for RawSocket.
    :type path: str

    :param params: A dictionary of key-values to construct the query
        component of the addressed WebSocket resource (will be properly URL
        escaped). Ignored for RawSocket.
    :type params: dict

    :returns: Constructed WebSocket URL.
    :rtype: str
    unixzunix:%sNr     z%s:%dz%s:443z%s:80r   r   /)typeboolintrangeurlparsequote	urlencode
urlunparse)	hostnameportisSecurepathparamsnetlocschemeppathquerys	            S/var/www/Befach/backend/env/lib/python3.12/site-packages/autobahn/websocket/util.pyr   r   1   s    < >T!!!6T!|T
c 1deAuo6MNN$//F!H, 8+t$""6*tUDIJJ    c                 ,   t        j                   |       }|j                  dvr$t        dj                  |j                              |j                  r|j                  dk(  rt        d      |j
                  '|j
                  dk7  rt        d|j
                  z        |j                  1|j                  dk7  r"|j                  }t        j                  |      }nd}|}|j                  A|j                  dk7  r2|dz   |j                  z   }t        j                  |j                        }n|}i }|j                  dk(  rL|j                  |j                  z   }|j                  d	      d
   }|j                  dk(  |j                  ||||fS |j                  |j                  dk(  r|j                  dk(  rd}nd}nt        |j                        }|d
k  s|dkD  rt        dj                  |            |j                  dk(  |j                  ||||fS )a'  
    Parses as WebSocket URL into it's components and returns a tuple:

     - ``isSecure`` is a flag which is ``True`` for ``wss`` URLs.
     - ``host`` is the hostname or IP from the URL.

    and for TCP/IP sockets:

     - ``tcp_port`` is the port from the URL or standard port derived from
       scheme (``rs`` => ``80``, ``rss`` => ``443``).

    or for Unix domain sockets:

     - ``uds_path`` is the path on the local host filesystem.

    :param url: A valid WebSocket URL, i.e. ``ws://localhost:9000`` for TCP/IP sockets or
        ``ws://unix:/tmp/file.sock`` for Unix domain sockets (UDS).
    :type url: str

    :returns: A 6-tuple ``(isSecure, host, tcp_port, resource, path, params)`` (TCP/IP) or
        ``(isSecure, host, uds_path, resource, path, params)`` (UDS).
    :rtype: tuple
    )r   r   z@invalid WebSocket URL: protocol scheme '{}' is not for WebSocket z'invalid WebSocket URL: missing hostnamez-invalid WebSocket URL: non-empty fragment '%sr   ?r
   :   r   r   P   i  r   zinvalid port {})r   r   
ValueErrorformatr   fragmentr   unquoter   parse_qsr   splitr   r   )	urlparsedr   r   resourcer   fpuds_pathtcp_ports	            r   r   r   p   s   2 s#F}}M)[bbcicpcpqrr??foo3BCC"v"'<H6??Z[[{{6;;"#4&||FLLB$63;-""6<<0&  ]]V[[(88C=# }}%v(DRXXX
 ;;&++"3}}$6;;'Ha<8e+.55h?@@}}%v(DRXXXr   )NFNN)autobahn.utilr   urllibr   r   	wsschemesuses_relativeextenduses_netlocuses_params
uses_queryuses_fragment__all__r   r    r   r   <module>r=      s   6 ! $ 5M	     i (     I &     I &     9 %     i ( ;K ;K| JY JYr   