Ë
    £èhV  ã                  ó¬   — d dl mZ d dlmZmZmZmZmZmZ d dl	m
Z
mZmZ d dlmZmZ erd dlmZ d dlmZmZ dd„Z edd	¬
«      Z G d„ dee   «      Zy)é    )Úannotations)ÚTYPE_CHECKINGÚIteratorÚcastÚOptionalÚTypeVarÚGeneric)ÚDXFValueErrorÚDXFKeyErrorÚINVALID_NAME_CHARACTERS)Úmake_table_keyÚis_valid_table_name)ÚDrawing)Ú	DXFObjectÚ
Dictionaryc                óP   — | d d } t        | «      st        d| › dt        › �«      ‚| S )Néÿ   ztable name 'z' contains invalid characters: )r   r
   r   )Únames    ú?lib/python3.12/site-packages/ezdxf/entities/objectcollection.pyÚvalidate_namer      s<   € Ø��ˆ:€DÜ˜tÔ$ÜØ˜4˜&Ð ?Ô@WÐ?XÐYó
ð 	
ð €Kó    ÚTr   )Úboundc                  ó¾   — e Zd ZdZ	 	 d	 	 	 	 	 dd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
edd	„«       Zedd
„«       Zdd„Zdd„Zddd„Zdd„Zdd„Zd d„Zd!d„Zdd„Zy)"ÚObjectCollectiona3  
    Note:
    ObjectCollections may contain entries where the name stored in the entity as
    "name" attribute diverges from the key in the DICTIONARY object e.g. MLEADERSTYLE
    collection may have entries for "Standard" and "Annotative" but both MLEADERSTYLE
    objects have the name "Standard".

    c                ón   — || _         || _        || _        |j                  j	                  |«      | _        y ©N)ÚdocÚobject_dict_nameÚobject_typeÚrootdictÚget_required_dictÚobject_dict)Úselfr   Ú	dict_namer    s       r   Ú__init__zObjectCollection.__init__.   s2   € ð  ˆŒØ )ˆÔØ +ˆÔØ'*§|¡|×'EÑ'EÀiÓ'PˆÕr   c                ól   — | j                   j                  j                  | j                  «      | _        y r   )r   r!   r"   r   r#   ©r$   s    r   Úupdate_object_dictz#ObjectCollection.update_object_dict9   s%   € ØŸ8™8×,Ñ,×>Ñ>¸t×?TÑ?TÓUˆÕr   c                 ó   — y r   © r(   s    r   Úcreate_required_entriesz(ObjectCollection.create_required_entries<   s   € Ør   c                ó6   — | j                   j                  «       S r   )r#   Úitemsr(   s    r   Ú__iter__zObjectCollection.__iter__?   s   € Ø×Ñ×%Ñ%Ó'Ð'r   c                ó,   — t        | j                  «      S r   )Úlenr#   r(   s    r   Ú__len__zObjectCollection.__len__B   s   € Ü�4×#Ñ#Ó$Ð$r   c                ó$   — | j                  |«      S r   )Ú	has_entry©r$   r   s     r   Ú__contains__zObjectCollection.__contains__E   s   € Ø�~‰~˜dÓ#Ð#r   c                óB   — | j                  |«      }|€t        |«      ‚|S r   )Úgetr   )r$   r   Úentrys      r   Ú__getitem__zObjectCollection.__getitem__H   s$   € Ø—‘˜“ˆØˆ=Ü˜dÓ#Ð#Øˆr   c                óB   — | j                   j                  j                  S )z0Returns the DXF handle of the DICTIONARY object.)r#   ÚdxfÚhandler(   s    r   r=   zObjectCollection.handleN   s   € ð ×Ñ×#Ñ#×*Ñ*Ð*r   c                ó.   — | j                   j                  S )z�Returns ``True`` if the collection is hard owner of entities.
        Hard owned entities will be destroyed by deleting the dictionary.
        )r#   Úis_hard_ownerr(   s    r   r?   zObjectCollection.is_hard_ownerS   s   € ð
 ×Ñ×-Ñ-Ð-r   c                ó(   — | j                  |«      d uS r   )r8   r5   s     r   r4   zObjectCollection.has_entryZ   s   € Ø�x‰x˜‹~ TÐ)Ð)r   c                óx   — t        |«      }| j                  j                  «       D ]  }t        |«      |k(  sŒ y y)NFT)r   r#   Úkeys)r$   r   Ú
entry_names      r   Úis_unique_namezObjectCollection.is_unique_name]   s:   € Ü˜dÓ#ˆØ×*Ñ*×/Ñ/Ö1ˆJÜ˜jÓ)¨TÓ1Ùð 2ð r   Nc                ó„   — t        |«      }| j                  j                  «       D ]  \  }}t        |«      |k(  sŒ|c S  |S )z§Get object by name. Object collection entries are case-insensitive.

        Args:
            name: object name as string
            default: default value

        )r   r#   r.   )r$   r   ÚdefaultrC   Úobjs        r   r8   zObjectCollection.getd   sD   € ô ˜dÓ#ˆØ#×/Ñ/×5Ñ5Ö7‰OˆJ˜Ü˜jÓ)¨TÓ1Ø’
ð  8ð ˆr   c                óš   — t        |«      }| j                  |«      st        | j                  › d|› d�«      ‚| j	                  |d|i¬«      S )aÃ  Create a new object of type `self.object_type` and store its handle
        in the object manager dictionary.  Object collection entry names are
        case-insensitive and limited to 255 characters.

        Args:
            name: name of new object as string

        Returns:
            new object of type `self.object_type`

        Raises:
            DXFValueError: if object name already exist or is invalid

        (internal API)

        z entry z already exists.r   ©Ú
dxfattribs)r   rD   r
   r    Ú_newr5   s     r   ÚnewzObjectCollection.newr   sS   € ô" ˜TÓ"ˆØ×"Ñ" 4Ô(Ü 4×#3Ñ#3Ð"4°G¸D¸6ÐAQÐ RÓSÐSØ�y‰y˜¨6°4¨.ˆyÓ9Ð9r   c                ó2  — | j                  |«      }|€t        d|› d�«      ‚t        |«      }| j                  |«      }|�| j                  |«       | j                  j
                  }|r|j                  |«      }n|j                  «       }|j                  j                  d«      r||j                  _
        | j                  j                  ||«       | j                  j                  j                  }||j                  _        |j                  |g«       |S )z¸Returns a new table entry `new_name` as copy of `name`,
        replaces entry `new_name` if already exist.

        Raises:
             DXFValueError: `name` does not exist

        zentry 'z' does not existr   )r8   r
   r   Údeleter   ÚentitydbÚduplicate_entityÚcopyr<   Úis_supportedr   r#   Úaddr=   ÚownerÚset_reactors)r$   r   Únew_namer9   Úexisting_entryrO   Ú	new_entryÚowner_handles           r   Úduplicate_entryz ObjectCollection.duplicate_entryˆ   sï   € ð —‘˜“ˆØˆ=Ü '¨$¨Ð/?Ð @ÓAÐAÜ  Ó*ˆàŸ™ (Ó+ˆØÐ%Ø�K‰K˜Ô!à—8‘8×$Ñ$ˆÙØ ×1Ñ1°%Ó8‰IàŸ
™
›ˆIØ�=‰=×%Ñ% fÔ-Ø!)ˆI�M‰MÔØ×Ñ×Ñ˜X yÔ1Ø×'Ñ'×+Ñ+×2Ñ2ˆØ*ˆ	�‰ÔØ×Ñ ˜~Ô.ØÐr   c                ó  — | j                   j                  }|€J ‚| j                  j                  j                  }||d<   |j                  | j                  |¬«      }| j                  j                  ||«       t        t        |«      S )NrT   rI   )
r   Úobjectsr#   r<   r=   Úadd_dxf_object_with_reactorr    rS   r   r   )r$   r   rJ   r\   rT   rG   s         r   rK   zObjectCollection._new¦   s‚   € Ø—(‘(×"Ñ"ˆØÐ"Ð"Ð"à× Ñ ×$Ñ$×+Ñ+ˆØ#ˆ
�7ÑØ×1Ñ1Ø×Ñ¨ð 2ó 
ˆð 	×Ñ×Ñ˜T 3Ô'Ü”A�s‹|Ðr   c                ó&  — | j                   j                  }|€J ‚| j                  |«      }|�d|j                  j	                  d«      r|j                  j                  d|«      }| j
                  j                  |«       |j                  |«       y y )Nr   )r   r\   r8   r<   rR   r#   ÚdiscardÚdelete_entity)r$   r   r\   rG   s       r   rN   zObjectCollection.delete²   s~   € Ø—(‘(×"Ñ"ˆØÐ"Ð"Ð"à�h‰h�t‹nˆØˆ?ð �w‰w×#Ñ# FÔ+Ø—w‘w—{‘{ 6¨4Ó0�Ø×Ñ×$Ñ$ TÔ*Ø×!Ñ! #Õ&ð r   c                ó8   — | j                   j                  «        y)zDelete all entries.N)r#   Úclearr(   s    r   rb   zObjectCollection.clear¿   s   € à×Ñ×ÑÕ r   )ÚACAD_MATERIALÚMATERIAL)r   r   r%   Ústrr    re   )ÚreturnÚNone)rf   zIterator[tuple[str, T]])rf   Úint)r   re   rf   Úbool)r   re   rf   r   )rf   re   )rf   ri   r   )r   re   rF   úOptional[T]rf   rj   )r   re   rV   re   rf   r   )r   re   rJ   Údictrf   r   )r   re   rf   rg   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r&   r)   r,   r/   r2   r6   r:   Úpropertyr=   r?   r4   rD   r8   rL   rZ   rK   rN   rb   r+   r   r   r   r   $   s£   „ ñð )Ø%ð		Qàð	Qð ð	Qð ó		QóVóó(ó%ó$óð ò+ó ð+ð ò.ó ð.ó*óôó:ó,ó<
ó'ô!r   r   N)r   re   rf   re   )Ú
__future__r   Útypingr   r   r   r   r   r	   Úezdxf.lldxf.constr
   r   r   Úezdxf.lldxf.validatorr   r   Úezdxf.documentr   Úezdxf.entitiesr   r   r   r   r   r+   r   r   Ú<module>rw      sR   ðõ #÷÷ ÷ñ ÷
 FáÝ&ß4óñ ˆC�{Ô#€ô]!�w˜q‘zõ ]!r   