Ë
    £èh»  ã                  ó˜   — d dl mZ d dlmZmZmZmZmZ d dlZerd dl	m
Z
 ddgZ	 d	 	 	 	 	 dd„Z	 d	 	 	 	 	 dd„Zdd	„Z	 	 	 	 	 	 	 	 dd
„Zy)é    )Úannotations)ÚTYPE_CHECKINGÚIterableÚUnionÚMappingÚOptionalN)Ú
DXFGraphicÚ	ascendingÚ
descendingc                óP   — |rt        |«      ni }t        | |d«      }t        |«      S )a%  Yields entities in ascending handle order.

    The sort-handle doesn't have to be the entity handle, every entity handle
    in `mapping` will be replaced by the given sort-handle, `mapping` is an
    iterable of 2-tuples (entity_handle, sort_handle) or a
    dict (entity_handle, sort_handle). Entities with equal sort-handles show
    up in source entities order.

    Args:
        entities: iterable of :class:`DXFGraphic` objects
        mapping: iterable of 2-tuples (entity_handle, sort_handle) or a
            handle mapping as dict.

    é   ©ÚdictÚ_buildÚ_sorted©ÚentitiesÚmappingÚheaps      ú-lib/python3.12/site-packages/ezdxf/reorder.pyr
   r
      ó)   € ñ$  'Œd�7Œm¨B€GÜ�(˜G RÓ(€DÜ�4‹=Ðó    c                óP   — |rt        |«      ni }t        | |d«      }t        |«      S )a/  Yields entities in descending handle order.

    The sort-handle doesn't have to be the entity handle, every entity handle
    in `mapping` will be replaced by the given sort-handle, `mapping` is an
    iterable of 2-tuples (entity_handle, sort_handle) or a
    dict (entity_handle, sort_handle). Entities with equal sort-handles show
    up in reversed source entities order.

    Args:
        entities: iterable of :class:`DXFGraphic` objects
        mapping: iterable of 2-tuples (entity_handle, sort_handle) or a
            handle mapping as dict.

    éÿÿÿÿr   r   s      r   r   r   $   r   r   c              #  óL   K  — | rt        j                  | «      d   –— | rŒyy­w)zYields heap content in order.r   N)ÚheapqÚheappop)r   s    r   r   r   ;   s"   è ø€ á
Ü�m‰m˜DÓ! "Ñ%Ò%ô ùs   ‚$¢$c                óˆ   ‡— dˆfd„}g }t        | «      D ]*  \  }}t        j                  | ||«      |z  ||z  |f«       Œ, |S )z§Returns a heap structure.

    Args:
        entities: DXF entities to order
        mapping: handle remapping
        order: +1 for ascending, -1 for descending

    c                ót   •— | j                   j                  }t        ‰j                  ||«      d«      }|r|S dS )Né   l   ÿÿÿÿ )ÚdxfÚhandleÚintÚget)Úentityr"   Úsort_handle_r   s      €r   Úsort_handlez_build.<locals>.sort_handleM   s9   ø€ Ø—‘×"Ñ"ˆÜ˜7Ÿ;™; v¨vÓ6¸Ó;ˆñ  ,ˆ|ÐCÐ1CÐCr   )r%   r	   Úreturnr#   )Ú	enumerater   Úheappush)r   r   Úorderr'   r   Úindexr%   s    `     r   r   r   A   sW   ø€ õDð /1€DÜ" 8Ö,‰ˆˆvô 	�‰Øá˜FÓ# eÑ+Ø˜‘Øðõ	
ð	 -ð €Kr   )N)r   úIterable[DXFGraphic]r   z0Optional[Union[dict, Iterable[tuple[str, str]]]]r(   r-   )r(   r-   )r   r-   r   r   r+   r#   r(   z!list[tuple[int, int, DXFGraphic]])Ú
__future__r   Útypingr   r   r   r   r   r   Úezdxf.entitiesr	   Ú__all__r
   r   r   r   © r   r   Ú<module>r3      s™   ðõ #ß DÕ DÛ áÝ)à˜Ð
%€ð
 AEðØ"ðà=ðð óð2 AEðØ"ðà=ðð óó.&ð#Ø"ð#Ø-4ð#Ø=@ð#à&ô#r   