Ë
    Ã?ÆiÝ  ã                  óv   — d Z ddlmZ ddlZddl­ ddlmZmZ dd„Zdd„Z	dd„Z
dd	„Zdd
„Zdd„Zdd„Zdd„Zy)u1  FÃ¸dselsnummer (Norwegian birth number, the national identity number).

The FÃ¸dselsnummer is an eleven-digit number that is built up of the date of
birth of the person, a serial number and two check digits.

More information:

* https://no.wikipedia.org/wiki/F%C3%B8dselsnummer
* https://en.wikipedia.org/wiki/National_identification_number#Norway

>>> validate('151086 95088')
'15108695088'
>>> get_gender('151086-95088')
'F'
>>> validate('15108695077')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('15108695077')
'151086 95077'
é    )ÚannotationsN)Ú*)ÚcleanÚisdigitsc                ó   — t        | d«      S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.z -:)r   ©Únumbers    ú^/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/no/fodselsnummer.pyÚcompactr   5   s   € ô �˜ÓÐó    c           
     ó\   — d}t        dt        d„ t        || «      D «       «      z
  dz  «      S )z/Calculate the first check digit for the number.)	é   é   é   é   é   é	   é   é   é   é   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­w©N©Úint©Ú.0ÚwÚns      r
   ú	<genexpr>z$calc_check_digit1.<locals>.<genexpr>>   ó   è ø€ ÒE©¨¨1˜œS ›V�ÑEùó   ‚©ÚstrÚsumÚzip©r	   Úweightss     r
   Úcalc_check_digit1r)   ;   s.   € à)€GÜ�”SÑE´°G¸VÓ0DÔEÓEÑEÈÑKÓLÐLr   c           
     ó\   — d}t        dt        d„ t        || «      D «       «      z
  dz  «      S )z0Calculate the second check digit for the number.)
r   r   r   r   r   r   r   r   r   r   r   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­wr   r   r   s      r
   r    z$calc_check_digit2.<locals>.<genexpr>D   r!   r"   r#   r'   s     r
   Úcalc_check_digit2r,   A   s.   € à,€GÜ�”SÑE´°G¸VÓ0DÔEÓEÑEÈÑKÓLÐLr   c                ó>   — t        | «      } t        | d   «      dz  ryy)z+Get the person's birth gender ('M' or 'F').r   r   ÚMÚF)r   r   r   s    r
   Ú
get_genderr0   G   s!   € ä�V‹_€FÜ
ˆ6�!‰9ƒ~˜ÒØàr   c                óâ  — t        | «      } t        | dd «      }t        | dd «      }t        | dd «      }t        | dd «      }|dk\  rt        d«      ‚|dkD  r|dz  }|dkD  r|dz  }|d	k  r|d
z  }nN|dk  r|dk\  r|dz  }n>|dk  r|dk  r|dz  }n.d|cxk  rdk  rn t        d«      ‚|dk\  r|d
z  }nt        d«      ‚	 t        j                  |||«      S # t
        $ r t        d«      ‚w xY w)z$Determine and return the birth date.r   r   r   r   r   éP   zSThis number is an FH-number, and does not contain birth date information by design.é(   iô  il  iî  é6   i  iè  iÐ  i„  z*The birthdate century cannot be determinedz9The number does not contain valid birth date information.)r   r   ÚInvalidComponentÚdatetimeÚdateÚ
ValueError)r	   ÚdayÚmonthÚyearÚindividual_digitss        r
   Úget_birth_dater=   P   s:  € ä�V‹_€FÜ
ˆf�Q�qˆkÓ
€CÜ��q˜�Ó€EÜˆv�a˜ˆ{Ó€DÜ˜F 1 Q˜KÓ(Ðà
ˆb‚yÜØaócð 	cð ˆR‚xØˆr‰	ˆð ˆr‚zØ�‰ˆØ˜3ÒØ�‰‰Ø	˜SÒ	  T¨R¢ZØ�‰‰Ø	˜TÒ	! d¨R¢iØ�‰‰Ø	Ð!Ô	( DÔ	(ô ÐKÓLÐLð	 .2°RªZØ�‰‰ô ÐKÓLÐLð\Ü�}‰}˜T 5¨#Ó.Ð.øÜò \ÜÐZÓ[Ð[ð\ús   ÃC ÃC.c                óL  — t        | «      } t        | «      dk7  r
t        «       ‚t        | «      s
t	        «       ‚| d   t        | «      k7  r
t        «       ‚| d   t        | «      k7  r
t        «       ‚t        | «      t        j                  j                  «       kD  rt        d«      ‚| S )ú,Check if the number is a valid birth number.r   éþÿÿÿéÿÿÿÿzKThe birth date information is valid, but this person has not been born yet.)r   ÚlenÚInvalidLengthr   ÚInvalidFormatr)   ÚInvalidChecksumr,   r=   r6   r7   Útodayr5   r   s    r
   ÚvalidaterG   t   s–   € ä�V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�FÔÜ‹oÐØˆb�zÔ& vÓ.Ò.ÜÓÐØˆb�zÔ& vÓ.Ò.ÜÓÐÜ�fÓ¤§¡× 3Ñ 3Ó 5Ò5ÜØYó[ð 	[à€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)r?   F)ÚboolrG   ÚValidationErrorr   s    r
   Úis_validrK   …   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ó4   — t        | «      } | dd dz   | dd z   S )z8Reformat the number to the standard presentation format.Nr   ú )r   r   s    r
   ÚformatrN   �   s'   € ä�V‹_€FØ�"�1ˆ:˜Ñ˜f Q R˜jÑ(Ð(r   )r	   r$   Úreturnr$   )r	   r$   rO   zdatetime.date)r	   r$   rO   rI   )Ú__doc__Ú
__future__r   r6   Ústdnum.exceptionsÚstdnum.utilr   r   r   r)   r,   r0   r=   rG   rK   rN   © r   r
   ú<module>rU      sD   ðñ.õ, #ã ä ß 'ó óMóMóó!\óHó"ô)r   