o
    UÌhŸ  ã                   @  sX   d dl mZ d dlmZ d dlmZ d dlmZ er d dlmZ G dd„ dee ƒZdS )	é    )Úannotations)ÚTYPE_CHECKING)ÚAny)ÚList)ÚFramec                      sN   e Zd Zdd‡ fd	d
„Zeddd„ƒZddd„Zdddd„Zddd„Z‡  Z	S )ÚFrameCollectionNr   Úframesúlist[Frame] | NoneÚcountÚintÚreturnÚNonec                   s"   |d u rg }t ƒ  |¡ || _d S ©N)ÚsuperÚ__init__Ú_count)Úselfr   r
   ©Ú	__class__© ún/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/crashtest/frame_collection.pyr      s   
zFrameCollection.__init__c                 C  s
   | j d S ©Né   ©r   ©r   r   r   r   Úrepetitions   s   
zFrameCollection.repetitionsÚboolc                 C  s
   | j dkS r   r   r   r   r   r   Úis_repeated   s   
zFrameCollection.is_repeatedr   Ú	incrementc                 C  s   |  j |7  _ | S r   r   )r   r   r   r   r   Úincrement_count   s   zFrameCollection.increment_countúlist[FrameCollection]c                 C  s&  g }t ƒ }d}|t| ƒd k rŒ| | }|| |d d… v rog }t| |d d… ƒD ]\}}||kr:| || d ¡ q)d}|D ]}	t | ||	… ƒ}
|
|krW| ¡  |	}d} nq?|r[q| |¡ t | ||d … ƒ}|d }q| ¡ r{| |¡ t ƒ }| |¡ |d7 }|t| ƒd k s| |¡ |S )zE
        Compacts the frames to deduplicate recursive calls.
        r   r   NFT)r   ÚlenÚ	enumerateÚappendr   r   )r   ÚcollectionsÚcurrent_collectionÚiÚframeÚduplicate_indicesÚ	sub_indexÚ	sub_frameÚfound_duplicateÚduplicate_indexÚ
collectionr   r   r   Úcompact!   sD   €ü


à
"zFrameCollection.compact)Nr   )r   r	   r
   r   r   r   )r   r   )r   r   )r   )r   r   r   r   )r   r    )
Ú__name__Ú
__module__Ú__qualname__r   Úpropertyr   r   r   r.   Ú__classcell__r   r   r   r   r      s    
r   N)	Ú
__future__r   Útypingr   r   r   Úcrashtest.framer   r   r   r   r   r   Ú<module>   s    