o
    no™i‹
  ã                   @   st   d dl mZ d dl mZ d dl mZ d dlmZ dededee fdd	„Z	ded
ee dededee f
dd„Z
dS )é    )ÚDIRECT_DICT)ÚNUMBER_SCALE_DICT)ÚVARIATIONS_DICT)ÚcombineÚ
number_strÚindexÚreturnc                 C   s  g }g }t | ƒdkrM|  d¡rM| d dkrt| d  d gnt| d  }| d |td  ¡¡ | d tv rD| dd„ t| d  D ƒ¡ | dd	…  d¡} | r}| dkre| t | g ¡|dkr`dnd ¡ n| t | g ¡d ¡ | tv r{| t|  ¡nd	 t	||ƒS )
a  
    Convert a number to its text representation.

    Args:
        number_str (str): The number to convert.
        index (int): The position of the number in the sequence, affecting scaling.

    Returns:
        list[str]: The text representation of the number.
    é   Ú0r   Ú1é   ú c                 S   s"   g | ]}d   |td d g¡‘qS )r   r
   r   )Újoinr   )Ú.0Ú	variation© r   úQ/home/ubuntu/.local/lib/python3.10/site-packages/indic_numtowords/sin/cardinal.pyÚ
<listcomp>   s   " z#convert_to_text.<locals>.<listcomp>N)
ÚlenÚlstripr   Úappendr   r   r   ÚextendÚgetr   )r   r   ÚhundredsÚonesÚprefixr   r   r   Úconvert_to_text   s   *$€
r   ÚtextsÚ
number_lenc                 C   sÌ   t | tƒr
t |tƒstdƒ‚| dv r|S |dkr$| dkr$tt| |ƒ|ƒS |  d¡dko<|g ko<||d d | ko<|dk}|rAdnd}|dkrOt|  d¡|ƒntt|  d¡|ƒtt|ƒ | gƒ}t||ƒS )	aá  
    Convert a number string to its text representation and append it to a list.

    Args:
        number_str (str): The number string to process.
        texts (list[str]): A list of texts to update with the converted number.
        index (int): The position of the number in the sequence, affecting scaling.
        number_len (int): The total length of the original number.

    Returns:
        list[str]: The updated list with the number's text representation appended.
    zInvalid input type>   Ú00Ú000r   r
   r   r   r	   é   )Ú
isinstanceÚstrÚintÚ
ValueErrorr   r   r   r   )r   r   r   r   Ú	conditionÚ	scale_idxÚconverted_textr   r   r   Úprocess_text)   s   2<
r)   N)Úindic_numtowords.sin.data.numsr   r   r   Úindic_numtowords.sin.utilsr   r#   r$   Úlistr   r)   r   r   r   r   Ú<module>   s    *#