Ë
    R/jk  ã                  óœ   — d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZmZ  ed¬«      d	d
œdd„«       Zdd„Z  ed¬«      e«      Zy)a‡  Multicast DNS Service Discovery for Python, v0.14-wmcbrine
Copyright 2003 Paul Scott-Murphy, 2014 William McBrine

This module provides a framework for the use of DNS Service Discovery
using IP multicast.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
é    )Úannotations)Ú	lru_cacheé   )ÚBadTypeInNameException)Ú_HAS_A_TO_ZÚ_HAS_ASCII_CONTROL_CHARSÚ_HAS_ONLY_A_TO_Z_NUM_HYPHENÚ&_HAS_ONLY_A_TO_Z_NUM_HYPHEN_UNDERSCOREÚ_LOCAL_TRAILERÚ_NONTCP_PROTOCOL_LOCAL_TRAILERÚ_TCP_PROTOCOL_LOCAL_TRAILERi   )ÚmaxsizeT)Ústrictc          	     óÖ  — t        | «      dkD  rt        d| › d�«      ‚| j                  «       }|j                  t        t
        f«      r8| dt        t        «        j                  d«      }| t        t        «       d }d}n…|rt        d| › dt        › d	t
        › d
�«      ‚|j                  t        «      r;| dt        t        «        j                  d«      }| t        t        «       dz   d }d}nt        d| › dt        › d
�«      ‚|s|�r|j                  «       }|st        d«      ‚t        |«      dk(  r t        |d   «      dk(  rt        d| › d�«      ‚|d   dk7  rt        d|› d�«      ‚|dd }|rt        |«      dkD  rt        d|› d�«      ‚d|v rt        d|› d�«      ‚d|d   |d   fv rt        d|› d�«      ‚t        j                  |«      st        d|› d�«      ‚|rt        nt        }|j                  |«      s t        |rd|r|nd› d�dz   «      ‚d«      ‚d}|rB|d   dk(  r:|j                  «        t        |«      dk(  st        |d   «      dk(  rt        d«      ‚t        |«      dkD  rdj                  |«      g}|r^t        |d   j                  d «      «      }	|	d!kD  rt        d"|d   › d
�«      ‚t        j                  |d   «      rt        d#|d   › d
�«      ‚||z   S )$a„  
    Validate a fully qualified service name, instance or subtype. [rfc6763]

    Returns fully qualified service name.

    Domain names used by mDNS-SD take the following forms:

                   <sn> . <_tcp|_udp> . local.
      <Instance> . <sn> . <_tcp|_udp> . local.
      <sub>._sub . <sn> . <_tcp|_udp> . local.

    1) must end with 'local.'

      This is true because we are implementing mDNS and since the 'm' means
      multi-cast, the 'local.' domain is mandatory.

    2) local is preceded with either '_udp.' or '_tcp.' unless
       strict is False

    3) service name <sn> precedes <_tcp|_udp> unless
       strict is False

      The rules for Service Names [RFC6335] state that they may be no more
      than fifteen characters long (not counting the mandatory underscore),
      consisting of only letters, digits, and hyphens, must begin and end
      with a letter or digit, must not contain consecutive hyphens, and
      must contain at least one letter.

    The instance name <Instance> and sub type <sub> may be up to 63 bytes.

    The portion of the Service Instance Name is a user-
    friendly name consisting of arbitrary Net-Unicode text [RFC5198]. It
    MUST NOT contain ASCII control characters (byte values 0x00-0x1F and
    0x7F) [RFC20] but otherwise is allowed to contain any characters,
    without restriction, including spaces, uppercase, lowercase,
    punctuation -- including dots -- accented characters, non-Roman text,
    and anything else that may be represented using Net-Unicode.

    :param type_: Type, SubType or service name to validate
    :return: fully qualified service name (eg: _http._tcp.local.)
    é   zFull name (z) must be > 256 bytesNú.TzType 'z' must end with 'z' or 'ú'é   FzNo Service name foundr   z' must not start with '.'Ú_zService name (z) must start with '_'é   z) must be <= 15 bytesz--z) must not contain '--'ú-éÿÿÿÿz) may not start or end with '-'z.) must contain at least one letter (eg: 'A-Z')Ú zA) must contain only these characters: A-Z, a-z, 0-9, hyphen ('-')z, underscore ('_')Ú_subz_sub requires a subtype namezutf-8é?   zToo long: 'z7Ascii control character 0x00-0x1F and 0x7F illegal in ')Úlenr   ÚlowerÚendswithr   r   Úsplitr   Úpopr   Úsearchr	   r
   ÚjoinÚencoder   )
Útype_r   Ú
type_lowerÚ	remainingÚtrailerÚhas_protocolÚservice_nameÚtest_service_nameÚallowed_characters_reÚlengths
             úF/home/josh/.local/lib/python3.12/site-packages/zeroconf/_utils/name.pyÚservice_type_namer.   '   s„  € ôV ˆ5ƒz�CÒä$ {°5°'Ð9NÐ%OÓPÐPð —‘“€JØ×ÑÔ7Ô9WÐXÔYØÐ=œSÔ!<Ó=Ð=Ð>×DÑDÀSÓIˆ	ØœÔ8Ó9Ð9Ð;Ð<ˆØ‰Ù	Ü$Ø�U�Gð Ü+Ð,¨FÔ3QÐ2RÐRSðUó
ð 	
ð 
×	Ñ	œ^Ô	,ØÐ0œS¤Ó0Ð0Ð1×7Ñ7¸Ó<ˆ	Øœœ^Ó,Ð,¨qÑ0Ð2Ð3ˆØ‰ä$ v¨e¨WÐ4EÄnÐEUÐUVÐ%WÓXÐXá’Ø —}‘}“ˆÙÜ(Ð)@ÓAÐAäˆy‹>˜QÒ¤3 y°¡|Ó#4¸Ò#9Ü(¨6°%°Ð8QÐ)RÓSÐSà˜‰?˜cÒ!Ü(¨>¸,¸ÐG\Ð)]Ó^Ð^à(¨¨Ð,Ðá”cÐ+Ó,¨rÒ1ä(¨>Ð:KÐ9LÐLaÐ)bÓcÐcàÐ$Ñ$Ü(¨>Ð:KÐ9LÐLcÐ)dÓeÐeàÐ$ QÑ'Ð):¸2Ñ)>Ð?Ñ?Ü(¨>Ð:KÐ9LÐLkÐ)lÓmÐmä×!Ñ!Ð"3Ô4Ü(Ø Ð!2Ð 3Ð3aÐbóð ñ
 ,2Õ'Ô7]ð 	ð %×+Ñ+Ð,=Ô>Ü(ñ ð !±fÑ!2À"Ð Eð F.ð .à0DñEóð ð
 óð ð ˆá�Y˜r‘] fÒ,Ø�‰ŒÜˆy‹>˜QÒ¤# i°¡lÓ"3°qÒ"8Ü(Ð)GÓHÐHä
ˆ9ƒ~˜ÒØ—X‘X˜iÓ(Ð)ˆ	áÜ�Y˜q‘\×(Ñ(¨Ó1Ó2ˆØ�BŠ;Ü(¨;°yÀ±|°nÀAÐ)FÓGÐGä#×*Ñ*¨9°Q©<Ô8Ü(ØIÈ)ÐTUÉ,ÈÐWXÐYóð ð ˜'Ñ!Ð!ó    c                óö   — | j                  d«      }t        |«      }t        «       }t        |«      D ]D  }|||z
  dz
  d }|d   j	                  d«      s |S |j                  dj                  |«      «       ŒF |S )z>Build a set of all possible types from a fully qualified name.r   é   Nr   r   )r   r   ÚsetÚrangeÚ
startswithÚaddr"   )ÚnameÚlabelsÚlabel_countÚtypesÚcountÚpartss         r-   Úpossible_typesr<   ¨   s�   € à�Z‰Z˜‹_€FÜ�f“+€KÜ‹E€EÜ�{Ó#ò #ˆØ�{ UÑ*¨QÑ.Ð0Ð1ˆØ�Q‰x×"Ñ" 3Ô'Øà€Lð 	�	‰	�#—(‘(˜5“/Õ"ð	#ð
 €Lr/   r   N)r$   Ústrr   ÚboolÚreturnr=   )r6   r=   r?   zset[str])Ú__doc__Ú
__future__r   Ú	functoolsr   Ú_exceptionsr   Úconstr   r   r	   r
   r   r   r   r.   r<   Úcached_possible_types© r/   r-   ú<module>rG      s\   ðñõ, #å å 0÷÷ ñ ñ �3ÔØ48ô }"ó ð}"ó@
ð /™	¨#Ô.¨~Ó>Ñ r/   