Ë
    Ã?ÆiÜ  ã                  óN   — d Z ddlmZ ddl­ ddlmZmZ d
d„Zd
d„Zdd„Z	d
d„Z
y	)un  CR (CÃ©dula de Residencia, Costa Rica foreigners ID number).

The CÃ©dula de Residencia (CR), also know as DIMEX or Documento de
IdentificaciÃ³n Migratorio para Extranjeros, is an identifier of foreigners in
Costa Rica.

This number consists of 11 or 12 digits in the form 1NNN-CC...C-EE...E where
NNN represents the code of the country the foreigner comes from as specified
by Costa Rica's DirecciÃ³n General de MigraciÃ³n y ExtranjerÃ­a, CC...C is a
sequence telling how many CÃ©dula de Residencia have been issued in total and
EE...E is a sequence telling how many CÃ©dula de Residencia have been issued
for that particular foreign country.

More information:

* https://www.hacienda.go.cr/consultapagos/ayuda_cedulas.htm
* https://www.procomer.com/downloads/quiero/guia_solicitud_vuce.pdf (page 12)
* https://www.hacienda.go.cr/ATV/frmConsultaSituTributaria.aspx

>>> validate('155812994816')
'155812994816'
>>> validate('30123456789')
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> validate('12345678')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> format('122200569906')
'122200569906'
é    )Úannotations)Ú*)ÚcleanÚisdigitsc                ó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   ÚupperÚstrip©Únumbers    úS/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/cr/cr.pyÚcompactr   <   s#   € ô �˜Ó×$Ñ$Ó&×,Ñ,Ó.Ð.ó    c                ó˜   — t        | «      } t        | «      dvr
t        «       ‚t        | «      s
t	        «       ‚| d   dk7  r
t        «       ‚| S )zeCheck if the number is a valid Costa Rica CR number.

    This checks the length and formatting.
    )é   é   r   Ú1)r   ÚlenÚInvalidLengthr   ÚInvalidFormatÚInvalidComponentr
   s    r   Úvalidater   E   sK   € ô
 �V‹_€FÜ
ˆ6ƒ{˜(Ñ"Ü‹oÐÜ�FÔÜ‹oÐØˆa�y�CÒÜÓ Ð Ø€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z4Check if the number is a valid Costa Rica CR number.F)Úboolr   ÚValidationErrorr
   s    r   Úis_validr   T   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ó   — t        | «      S )z8Reformat the number to the standard presentation format.)r   r
   s    r   Úformatr   \   s   € ä�6‹?Ðr   N)r   ÚstrÚreturnr   )r   r   r   r   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r   r   r   © r   r   ú<module>r%      s*   ðñ*õB #ä ß 'ó/óóôr   