Ë
    Ã?Æi<  ã                  ó&  — d Z ddlmZ ddlZddlZddl­ ddlmZ ddlm	Z	  ej                  d«      Z ed„  ed	«      D «       «      Zej                   ed
„  ed«      D «       «      «        ed„  ed«      D «       «      Z ed„  ed	«      D «       «      Zej                   ed„  ed«      D «       «      «       g d¢Z ed„  ed	«      D «       «      Zej                   ed„  ed«      D «       «      «       [dd„Zdd„Zddd„Zdd„Zdd„Zdd„Zy)aÖ  Codice Fiscale (Italian tax code for individuals).

The Codice Fiscale is an alphanumeric code of 16 characters used to identify
individuals residing in Italy or 11 digits for non-individuals in which case
it matches the Imposta sul valore aggiunto.

The 16 digit number consists of three characters derived from the person's
last name, three from the person's first name, five that hold information on
the person's gender and birth date, four that represent the person's place of
birth and one check digit.

More information:

* https://it.m.wikipedia.org/wiki/Codice_fiscale

>>> validate('RCCMNL83S18D969H')  # personal number
'RCCMNL83S18D969H'
>>> validate('RCCMNL83S18D969')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> validate('00743110157')  # company number
'00743110157'
>>> validate('00743110158')  # company number with invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> calc_check_digit('RCCMNL83S18D969')
'H'
é    )ÚannotationsN)Ú*)Úiva)Úcleanza^[A-Z]{6}[0-9LMNPQRSTUV]{2}[ABCDEHLMPRST]{1}[0-9LMNPQRSTUV]{2}[A-Z]{1}[0-9LMNPQRSTUV]{3}[A-Z]{1}$c              #  ó*   K  — | ]  \  }}||f–— Œ y ­w©N© ©Ú.0ÚnÚxs      ú^/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/it/codicefiscale.pyú	<genexpr>r   L   ó   è ø€ Ò?™t˜q !�Q˜”FÑ?ùó   ‚Ú
0123456789c              #  ó*   K  — | ]  \  }}||f–— Œ y ­wr   r	   r
   s      r   r   r   M   s   è ø€ ÒD¡D A q˜!˜QœÑDùr   Ú
LMNPQRSTUVc              #  ó*   K  — | ]  \  }}||f–— Œ y ­wr   r	   r
   s      r   r   r   P   s   è ø€ ÒB¡  1�a˜”VÑBùr   ÚABCDEHLMPRSTc              #  ó*   K  — | ]  \  }}||f–— Œ y ­wr   r	   r
   s      r   r   r   S   r   r   c              #  ó*   K  — | ]  \  }}||f–— Œ y ­wr   r	   r
   s      r   r   r   U   s   è ø€ ÒD‘D�A�qˆ!ˆQŒÑDùr   ÚABCDEFGHIJKLMNOPQRSTUVWXYZ)é   r   é   é   é	   é   é   é   é   é   é   é   é   é   é   é   é   é   é   é   é   é
   é   é   é   é   c              #  ó8   K  — | ]  \  }}|t         |   f–— Œ y ­wr   ©Úvaluesr
   s      r   r   r   Z   s   è ø€ ÒF¡d a¨�A”v˜a‘y”>ÑFùó   ‚c              #  ó8   K  — | ]  \  }}|t         |   f–— Œ y ­wr   r4   r
   s      r   r   r   \   s   è ø€ ÒL™D˜A˜qˆ!ŒV�A‰YŒÑLùr6   c                óR   — t        | d«      j                  «       j                  «       S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.z -:)r   ÚstripÚupper©Únumbers    r   Úcompactr=   `   s#   € ô �˜Ó×%Ñ%Ó'×-Ñ-Ó/Ð/ó    c                óH   — t        d„ t        | «      D «       «      }d|dz     S )z�Compute the control code for the given personal number. The passed
    number should be the first 15 characters of a fiscal code.c              3  óV   K  — | ]!  \  }}|d z  dk(  r	t         |   nt        |   –— Œ# y­w)r#   r   N)Ú_odd_valuesÚ_even_valuesr
   s      r   r   z#calc_check_digit.<locals>.<genexpr>i   s3   è ø€ ò .Ù�1�að "# Q¡¨!¢Œ{˜1Š~´¸a±Ó@ñ .ùs   ‚')r   é   )ÚsumÚ	enumerate)r<   Úcodes     r   Úcalc_check_digitrG   f   s/   € ô ñ .Ü$ VÓ,ô.ó .€Dà'¨¨r©	Ñ2Ð2r>   c                ód  — t        | «      } t        | «      dk7  r
t        «       ‚t        | d      dz  t        | d      z   dz  }t        | d      dz   }t        | d      dz  t        | d      z   }||d	z  d	z  z  }||k  r|d	z  }	 t        j                  |||«      S # t        $ r t        «       ‚w xY w)
aj  Get the birth date from the person's fiscal code.

    Only the last two digits of the year are stored in the number. The dates
    will be returned in the range from minyear to minyear + 100.

    >>> get_birth_date('RCCMNL83S18D969H')
    datetime.date(1983, 11, 18)
    >>> get_birth_date('RCCMNL83S18D969H', minyear=1990)
    datetime.date(2083, 11, 18)
    r-   r   r.   é(   r*   r   r)   r   éd   )r=   ÚlenÚInvalidComponentÚ_date_digitsÚ_month_digitsÚdatetimeÚdateÚ
ValueError)r<   ÚminyearÚdayÚmonthÚyears        r   Úget_birth_daterV   n   sÏ   € ô �V‹_€FÜ
ˆ6ƒ{�bÒÜÓ Ð Ü˜˜q™	Ñ" RÑ'¬,°v¸b±zÑ*BÑBÀbÑ
H€CÜ˜& ™)Ñ$ qÑ(€EÜ˜˜q™	Ñ" RÑ'¬,°v¸a±yÑ*AÑA€DàˆW˜‰^˜sÑ"Ñ"€DØˆg‚~Ø�‰ˆð!Ü�}‰}˜T 5¨#Ó.Ð.øÜò !ÜÓ Ð ð!ús   ÂB ÂB/c                ór   — t        | «      } t        | «      dk7  r
t        «       ‚t        | dd «      dk  rdS dS )z�Get the gender of the person's fiscal code.

    >>> get_gender('RCCMNL83S18D969H')
    'M'
    >>> get_gender('CNTCHR83T41D969D')
    'F'
    r-   r   r'   é    ÚMÚF)r=   rK   rL   Úintr;   s    r   Ú
get_genderr\   ‰   s?   € ô �V‹_€FÜ
ˆ6ƒ{�bÒÜÓ Ð Ü�f˜Q˜r�lÓ# bÒ(ˆ3Ð1¨cÐ1r>   c                ó"  — t        | «      } t        | «      dk(  rt        j                  | «      S t        | «      dk7  r
t	        «       ‚t
        j                  | «      s
t        «       ‚t        | dd «      | d   k7  r
t        «       ‚t        | «       | S )zkCheck if the given fiscal code is valid. This checks the length and
    whether the check digit is correct.r'   r-   Néÿÿÿÿ)r=   rK   r   ÚvalidateÚInvalidLengthÚ_code_reÚmatchÚInvalidFormatrG   ÚInvalidChecksumrV   r;   s    r   r_   r_   —   s}   € ô �V‹_€FÜ
ˆ6ƒ{�bÒÜ�|‰|˜FÓ#Ð#Ü
ˆ6ƒ{�bÒÜ‹oÐÜ�>‰>˜&Ô!Ü‹oÐÜ˜˜s ˜Ó$¨¨r©
Ò2ÜÓÐä�6ÔØ€Mr>   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z(Check if the given fiscal code is valid.F)Úboolr_   ÚValidationErrorr;   s    r   Úis_validrh   ¨   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡")r<   ÚstrÚreturnri   )i€  )r<   ri   rR   r[   rj   zdatetime.date)r<   ri   rj   rf   )Ú__doc__Ú
__future__r   rO   ÚreÚstdnum.exceptionsÚ	stdnum.itr   Ústdnum.utilr   Úcompilera   ÚdictrE   rM   ÚupdaterN   rB   r5   rA   r=   rG   rV   r\   r_   rh   r	   r>   r   ú<module>rt      s  ðñ6õ> #ã Û 	ä Ý Ý ð ˆ2�:‰:ð+ó,€ñ Ñ?¡y°Ó'>Ô?Ó?€Ø × Ñ ‘DÑD©I°lÓ,CÔDÓDÔ Eñ ÑB©	°.Ó(AÔBÓB€ñ Ñ?¡y°Ó'>Ô?Ó?€Ø × Ñ ÙÑD™IÐ&BÓCÔDÓDôFò
*€áÑF©i¸Ó.EÔFÓF€Ø × Ñ ÙÑL¡IÐ.JÓ$KÔLÓLôNà
ó0ó3ô!ó62óô"r>   