
    jW              
           d Z ddlmZ ddlmZ ddlZddlmZmZ ddl	m
Z
  G d d	          Ze
d
d
d
ddedededefd            ZdS )zDomain.    )environ)PathN)OptionalSet   )	validatorc                       e Zd ZU dZdZeee                  ed<   h dZ	e	
                    d           ed             Zedefd            ZdS )	_IanaTLDz*Read IANA TLDs, and optionally cache them.N_full_cache>
   BRDEFRITJPRUUKCOMNETORGONIONc              #     K   t          t                    j                            d                                          5 }t          |          }|D ]}|                                V  	 d d d            d S # 1 swxY w Y   d S )Nz_tld.txt)r   __file__parentjoinpathopennextstrip)clstld_f_lines       T/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/validators/domain.py	_retrievez_IanaTLD._retrieve   s      (^^"++J77<<>> 	#%UA # #jjll""""#	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s   +A::A>A>tldc                     || j         v rdS | j        Ut          j        d          dk    r't	          |                                           | _        n||                                 v S || j        v S )NTPYVLD_CACHE_TLDTrue)_popular_cacher   r   getsetr#   )r   r$   s     r"   checkz_IanaTLD.check   sl    #$$$4?"{,--77"%cmmoo"6"6cmmoo--co%%    )__name__
__module____qualname____doc__r   r   r   str__annotations__r(   addclassmethodr#   r+    r,   r"   r
   r
      s         44&*K#c(#***TTTNw# # [# & & & & [& & &r,   r
   F)consider_tldrfc_1034rfc_2782valuer6   r7   r8   c                  | sdS |r[t                               |                     d                              dd          d                                                   sdS 	 |rdnd}|rdnd}t          j        d	|            o`t          j        d
| dd| dz   d| dz   dz   d| z   |                     d          	                    d          t
          j
                  S # t          $ r}t          d|            |d}~ww xY w)a#  Return whether or not given value is a valid domain.

    Examples:
        >>> domain('example.com')
        True
        >>> domain('example.com/')
        ValidationError(func=domain, args={'value': 'example.com/'})
        >>> # Supports IDN domains as well::
        >>> domain('xn----gtbspbbmkef.xn--p1ai')
        True

    Args:
        value:
            Domain string to validate.
        consider_tld:
            Restrict domain to TLDs allowed by IANA.
        rfc_1034:
            Allows optional trailing dot in the domain name.
            Ref: [RFC 1034](https://www.rfc-editor.org/rfc/rfc1034).
        rfc_2782:
            Domain name is of type service record.
            Allows optional underscores in the domain name.
            Ref: [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782).


    Returns:
        (Literal[True]): If `value` is a valid domain name.
        (ValidationError): If `value` is an invalid domain name.

    Raises:
        (UnicodeError): If `value` cannot be encoded into `idna` or decoded into `utf-8`.
    F.r   r     z\.?$$z\s|__+z^(?:[a-z0-9]z(?:[a-z0-9-z]{0,61}z[a-z0-9z])?\.)z+[a-z0-9][a-z0-9-_]{0,61}z[a-z]idnazutf-8zUnable to encode/decode N)r
   r+   rstriprsplitupperresearchmatchencodedecode
IGNORECASEUnicodeError)r9   r6   r7   r8   service_recordtrailing_doterrs          r"   domainrN   (   s_   H  u HNN5<<+<+<+C+CC+K+KB+O+U+U+W+WXX uH!)1r"*4ww9Y... 
28,>,,,6^6667 0///	0 ++ &|%%& LL  ''00M4
 4
 	
  H H H=e==>>CGHs   #BC& &
D0DD)r0   osr   pathlibr   rD   typingr   r   utilsr   r
   r1   boolrN   r5   r,   r"   <module>rT      s                 				                      & & & & & & & &6 +05[`<H <H <H<H$(<H<@<HTX<H <H <H <H <H <Hr,   