
    hx                    D   S SK Jr  S SKrS SKrS SKJrJrJrJrJrJ	r	J
r
  S SKrS SKrS SKJr  S SKJr  S SKrS SKJr  S SKJr  S SKJrJrJrJr  S S	KJrJrJrJrJrJ r J!r!  S S
K"J#r#J$r$  S SK%J&r&  S SK'J(r(  S SK)J*r*J+r+  \(       a  S SK,J-r-  S SK.J/r/  SS/r01 Skr1\Rd                  " S5      r3 S,     S-S jjr4S,S.S jjr5 S/     S-S jjr6S0S jr7 " S S5      r8S1S jr9S2S jr:S3S jr;   S4         S5S jjr<\Rz                  " S5      r>\Rz                  " S 5      r?S6S! jr@\Rz                  " S"5      rA\Rz                  " S#5      rBS7S$ jrC\R                  S8S% j5       rES8S& jrFS'rGS(rHS9S) jrIS:S* jrJ\R                  \R                  SS4       S;S+ jj5       rLg)<    )annotationsN)TYPE_CHECKINGBinaryIOIterableIteratorCallableUnionOptional)defaultdict)Path)const)repair)has_dxf_unicodedecode_dxf_unicodehas_mif_encodingdecode_mif_to_unicode)DXFTag	DXFVertexDXFBinaryTagPOINT_CODESBINARY_DATA
TYPE_TABLEMAX_GROUP_CODE)
group_tagsTags)entity_structure_validator)
toencoding)Auditor
AuditErrorDrawing)SectionDictreadreadfile>   EOFTABLEENDBLKENDSECENDTABSEQENDSECTIONezdxfsurrogateescapec                    [        U 5      n [        U SS9 n[        X!S9u  p4SSS5        U Wl        UW4$ ! , (       d  f       N= f)u  Read a DXF document from file system similar to :func:`ezdxf.readfile`,
but this function will repair as many flaws as possible, runs the required
audit process automatically the DXF document and the :class:`Auditor`.

Args:
    filename: file-system name of the DXF document to load
    errors: specify decoding error handler

        - "surrogateescape" to preserve possible binary data (default)
        - "ignore" to use the replacement char U+FFFD "�" for invalid data
        - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

Raises:
    DXFStructureError: for invalid or corrupted DXF structures
    UnicodeDecodeError: if `errors` is "strict" and a decoding error occurs

rbmodeerrorsN)stropenr#   filename)r6   r3   fpdocauditors        ?/var/www/html/env/lib/python3.13/site-packages/ezdxf/recover.pyr$   r$   >   sD    ( 8}H	hT	"bB. 
#CL< 
#	"s	   5
Ac                >    [         R                  XS9n[        U5      $ )u  Read a DXF document from a binary-stream similar to :func:`ezdxf.read`,
but this function will detect the text encoding automatically and repair
as many flaws as possible, runs the required audit process afterwards
and returns the DXF document and the :class:`Auditor`.

Args:
    stream: data stream to load in binary read mode
    errors: specify decoding error handler

        - "surrogateescape" to preserve possible binary data (default)
        - "ignore" to use the replacement char U+FFFD "�" for invalid data
        - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

Raises:
    DXFStructureError: for invalid or corrupted DXF structures
    UnicodeDecodeError: if `errors` is "strict" and a decoding error occurs

r2   )Recoverrun_load_and_audit_document)streamr3   recover_tools      r:   r#   r#   Y   s    & ;;v;5L#L11    c                    [        U 5      n [        U SS9 n[        R                  X![        S9n[        U5      u  pESSS5        U Wl        UW4$ ! , (       d  f       N= f)u  Read a DXF document from file system similar to :func:`readfile`,
but this function will use a special tag loader, which tries to recover the
tag stream if invalid tags occur.  This function is intended to load
corrupted DXF files and should only be used to explore such files, data loss
is very likely.

Args:
    filename: file-system name of the DXF document to load
    errors: specify decoding error handler

        - "surrogateescape" to preserve possible binary data (default)
        - "ignore" to use the replacement char U+FFFD "�" for invalid data
        - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

Raises:
    DXFStructureError: for invalid or corrupted DXF structures
    UnicodeDecodeError: if `errors` is "strict" and a decoding error occurs

r/   r0   )r3   loaderN)r4   r5   r<   r=   synced_bytes_loaderr>   r6   )r6   r3   r7   r@   r8   r9   s         r:   explorerE   p   sY    , 8}H	hT	"b{{2=P{Q/= 
# CL<	 
#	"s   &A
Ac                &   SSK Jn  U" 5       nUR                  U R                  5        [	        U5      nU R
                   H  u  pEUR                  XE5        M     U R                   H  u  pEUR                  XE5        M     UR                  5         X#4$ )Nr   r    )
ezdxf.documentr!   _load_section_dictsection_dictr   r3   	add_errorfixesfixed_errorr=   )r@   r!   r8   r9   codemsgs         r:   r>   r>      sz    &
)C<445clG!((	$$ )!''	D& (KKM<rA   c                      \ rS rSrSrSSS jjr\  S       SS jj5       rSS jrSS jr	SS jr
SS	 jr      SS
 jrSS jrS rS rSrg)r<      zLoose coupled recovering tools.Nc                    U=(       d    [         U l        [        5       U l        / U l        / U l        [        R                  U l        g N)	bytes_loader
tag_loaderdictrI   r3   rK   r   DXF12
dxfversion)selfrC   s     r:   __init__Recover.__init__   s9    
 !0L ,06 .0,.
  ++rA   c                   [        U5      nUR                  X5      nUR                  U5      nUR                  U5        UR                  R                  S5      nU(       a  UR                  U5      nXtR                  S'   UR                  S:  a   UR                  5         UR                  5         UR                  nUR                  S:*  n	UR                  5        H)  u  pU
S;   d  M  [        UR                  X5      5      X'   M+     U$ )zExecute the recover process.TABLESAC1009>   BLOCKSr\   OBJECTSENTITIES)r<   	load_tagsrebuild_sectionsload_section_dictrI   getrebuild_tablesrW   recover_rootdictfix_broken_layout_linksitemslistcheck_entities)clsr?   rC   r3   r@   tagssectionstablesrI   is_r12nameentitiess               r:   r=   Recover.run   s     v%%f5006&&x0**..x8!008F28%%h/""X-))+002#00((H4*002NDBB%) //A&" 3 rA   c                @    [        XR                  U R                  US9$ )Nmessagesr3   )safe_tag_loaderrT   r3   )rX   r?   r3   s      r:   ra   Recover.load_tags   s    OOdkk&
 	
rA   c                   ^ ^^^^^^^	^
^^ UUU
U 4S jmUUUU U4S jmUUUUU U4S jnUUUU	U UU4S jm/ m	/ m
/ mSmU H  mTu  mmTS:X  a	  U" 5         M  T" 5         M      T
R                  T	5        T
$ )a  Collect tags between SECTION and ENDSEC or next SECTION tag
as list of DXFTag objects, collects tags outside of sections
as an extra section.

Returns:
    List of sections as list of DXFTag() objects, the last section
    contains orphaned tags found outside of sections

c                    > T(       a  TR                  T 5        O+TR                  R                  [        R                  S45        / m Smg )Nz)DXF structure error: missing SECTION tag.F)appendrK   r   MISSING_SECTION_TAG)	collectorinside_sectionrm   rX   s   r:   close_section/Recover.rebuild_sections.<locals>.close_section   sE     	* 

!!"66C I"NrA   c                    > T(       a2  TR                   R                  [        R                  S45        T " 5         TR                  T5        Smg )N(DXF structure error: missing ENDSEC tag.TrK   rz   r   MISSING_ENDSEC_TAG)r~   r|   r}   rX   tags   r:   open_section.Recover.rebuild_sections.<locals>.open_section   sC    

!!"55B S!!NrA   c                    > TS:X  a  T" 5         g TS:X  a  T " 5         g TS:X  a;  T(       a3  TR                   R                  [        R                  S45        T " 5         g g T" 5         g )Nr+   r(   r%   r   r   )r~   collectr}   r   rX   values   r:   process_structure_tag7Recover.rebuild_sections.<locals>.process_structure_tag   s]    	!("%!JJ%%&99F "O " 	rA   c                    > T(       a  TR                  T5        g TR                  R                  [        R                  ST  ST S345        TR                  T5        g )Nz1DXF structure error: found tag outside section: (z, ))rz   rK   r   FOUND_TAG_OUTSIDE_SECTION)rM   r|   r}   orphansrX   r   r   s   r:   r   )Recover.rebuild_sections.<locals>.collect  sY      %

!!"<< 6E7!- s#rA   Fr   rz   )rX   rl   r   r~   rM   r   r|   r}   r   r   rm   r   r   s   `  @@@@@@@@@@r:   rb   Recover.rebuild_sections   sz    	# 	# 	" 	"	 	"	$ 	$ !#')"$	CKD%qy%'	  	 rA   c                6  ^ ^
 SU
4S jjnSU 4S jjnSU 4S jjnUR                  5       nU(       a  US   S:X  a  UR                  U5        / n[        5       m
U HE  nUS   u  pxUS:X  a
  U" X5        M  T R                  R                  [        R
                  S45        MG     T
R                  S	[        SS
5      [        SS	5      /5      n	T R                  X5        [        U	5      T l
        T R                  [        R                  ::  a  U" T
5        U" T
5        g)zMerge sections of same type.c                L   > U T;   a  TU    R                  USS  5        g UTU '   g )N   )extend)rp   rl   rI   s     r:   add_section.Recover.load_section_dict.<locals>.add_section-  s.    |#T"))$qr(3%)T"rA   c                   > U R                  5        H=  u  pU[        R                  ;   d  M  [        [	        US5      5      TR
                  U'   M?     g Nr   )rh   r   MANAGED_SECTIONSri   r   rI   )drp   sectionrX   s      r:   _build_section_dict6Recover.load_section_dict.<locals>._build_section_dict3  s?    !"5111.2:gq3I.JD%%d+ "+rA   c                   > S H;  nX;   d  M
  X	 TR                   R                  [        R                  SU S345        M=     g )N)CLASSESr_   ACDSDATAzRemoved unsupported z section for DXF R12.)rK   rz   r   REMOVED_UNSUPPORTED_SECTION)r   rp   rX   s     r:   _remove_unsupported_sections?Recover.load_section_dict.<locals>._remove_unsupported_sections8  sD    :9JJ%%&BB24&8MN ;rA   r   )r   r+      r   z>DXF structure error: missing section name tag, ignore section.HEADERr+   N)rp   r4   returnNone)r   rU   r   r   )r   rU   )poprz   rU   rK   r   MISSING_SECTION_NAME_TAG
setdefaultr   rescue_orphaned_header_vars_detect_dxf_versionrW   r   rV   )rX   rm   r   r   r   r   r   rM   rp   headerrI   s   `         @r:   rc   Recover.load_section_dict*  s    	*	K
		 ,,.wqz^3OOG$G&*fG JDqyD*

!!";;X   ((q)$q(#
 	((9-f5??ekk)(6L)rA   c                  ^^^	 S
UU	U4S jjn[        5       m	[        [        5      m[        [        R
                  5      nT Hf  nUS   R                  R                  5       nUS:X  a%   US   R                  R                  5       nUT	U'   MK  XS;   d  MR  TU   R                  U5        Mh     [        [        SS5      [        SS5      /5      /m[        [        R
                  5      nU R                  [        R                  ::  aB  UR                  S5        ST;   a+  U R                   R                  ["        R$                  S	45        U H  nU" U5        M     T$ ! [        [        4 a     GM,  f = f)zRebuild TABLES section.c           	     :  > U T;  a  g TR                  U 5      nU(       a  TR                  U5        O0TR                  [        [        SS5      [        SU 5      /5      5        TR	                  TU    5        TR                  [        [        SS5      /5      5        g )Nr   r&   r   r)   )rd   rz   r   r   r   )rp   headcontentheadsrn   s     r:   append_table,Recover.rebuild_tables.<locals>.append_tablek  sz    7"99T?Dd# dF1g$6q$#HIJMM'$-(MM$q( 3456rA   r   r&   r   r+   r   r\   BLOCK_RECORDz3Removed unsupported BLOCK_RECORD table for DXF R12.)rp   r4   )rU   r   ri   setr   TABLE_NAMES_ACAD_ORDERr   upper
IndexErrorAttributeErrorrz   r   r   rW   rV   removerK   r   REMOVED_UNSUPPORTED_TABLE)
rX   rn   r   valid_tablesentryrp   
table_namenamesr   r   s
    `      @@r:   re   Recover.rebuild_tablesd  sA   	7 	7 d#5778E8>>'')Dw.!&q!5!5!7J ).E*%%$$U+  q),fQ.ABCDU112??ekk)LL((

!!"<<M D - #N3 s   )EE/.E/c                    S nU H:  nUu  pVUS:X  a  UnM  Uc  M  UR                  U5        UR                  U5        S nM<     g )N	   r   )rX   r   r   var_namer   rM   r   s          r:   r   #Recover.rescue_orphaned_header_vars  sI     CKDqy%h'c" rA   c              #     #    SnU HJ  nUS   u  pVU[         ;   a  Uv   M  [        [        U5      5      nU(       a  UR                  U5        Uv   ML     g 7f)N)d   r   )EXCLUDE_STRUCTURE_CHECKr   r   remove_tags)rX   rq   ro   subclass_markersentity_dxftyperl   s           r:   rj   Recover.check_entities  sY     !FJA11 6v>? $$%56
 s   AAc                   U R                   R                  S5      nU(       a  [        U5      S:  a  g [        US   5      (       a  g [	        U5      u  p#U(       aL  US   X'   X1S'    UR                  5       nU R                  R                  [        R                  SU S345        g g ! [        R                   a    Sn NIf = f)Nr_   r   r   r   z%Recovered misplaced root DICTIONARY(#z).)rI   rd   len_is_rootdict_find_rootdict
get_handler   DXFValueErrorrK   rz   r   MISPLACED_ROOT_DICT)rX   objectsindexrootdicthandles        r:   rf   Recover.recover_rootdict  s    ##''	2#g,* 
##(1$QZGN!AJ !,,. JJ22;F82F 
 &&   s   'B( (C Cc                    g)zwFixes broke links (block_record_handle) between LAYOUT and BLOCK_RECORD
entities. See issue #997 for more information.
N )rX   s    r:   rg   Recover.fix_broken_layout_links  s     	rA   )rW   r3   rK   rI   rT   rR   )rC   Optional[Callable])Nr-   )r?   r   rC   r   r3   r4   r   r<   )r?   r   r3   r4   r   Iterator[DXFTag])rl   Iterable[DXFTag]r   list[list[DXFTag]])rm   r   r   r   )rn   
list[Tags]r   r   )r   zlist[DXFTag]r   r   r   r   )rq   r   ro   boolr   zIterator[Tags])__name__
__module____qualname____firstlineno____doc__rY   classmethodr=   ra   rb   rc   re   r   rj   rf   rg   __static_attributes__r   rA   r:   r<   r<      s    )&"  &*'	 # 	
 
 :

Sj8*t3j " -= 	 .rA   r<   c                    SnU  Ha  nU(       aM  [        US   5      R                  5       n[        R                  " SU5      (       a  Us  $   [        R
                  $ US:X  d  M_  SnMc     [        R
                  $ )NFr   z
AC[0-9]{4})r   z$ACADVERT)r4   stripre	fullmatchr   rV   )r   next_is_dxf_versionr   rW   s       r:   r   r     sm    SV**,J||M:66!! ;; /!"&  ;;rA   c                :    U S   S:w  a  g[        S U  5       5      $ )Nr   )r   
DICTIONARYFc              3  *   #    U  H	  oS :H  v   M     g7f))   
ACAD_GROUPNr   ).0r   s     r:   	<genexpr>_is_rootdict.<locals>.<genexpr>  s     :6C''6s   )any)r   s    r:   r   r     s#    ay%%:6:::rA   c                l    [        U 5       H  u  p[        U5      (       d  M  X4s  $    S[        5       4$ r   )	enumerater   r   )r   r   r   s      r:   r   r     s4    "7+=  , df9rA   c                    Uc  [         n[        R                  " U" U 5      S5      u  pE[        U5      n[        R
                  " U5      n[        R                  " U5      n[        R                  " U5      n[        XFX#S9$ )u  Yields :class:``DXFTag`` objects from a bytes `stream`
(untrusted external  source), skips all comment tags (group code == 999).

- Fixes unordered and invalid vertex tags.
- Pass :func:`synced_bytes_loader` as argument `loader` to brute force
  load invalid tag structure.

Args:
    stream: input data stream as bytes
    loader: low level tag loader, default loader is :func:`bytes_loader`
    messages: list to store error messages
    errors: specify decoding error handler

        - "surrogateescape" to preserve possible binary data (default)
        - "ignore" to use the replacement char U+FFFD "�" for invalid data
        - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

r   rt   )	rS   	itertoolsteedetect_encodingr   tag_reorder_layerfilter_invalid_point_codesfilter_invalid_handlesbyte_tag_compiler)r?   rC   ru   r3   rl   detector_streamencodings          r:   rv   rv     sn    0 ~%MM&.!<D/H ##D)D,,T2D((.DThNNrA   z[+-]?\d+s   [+-]?\d+c                    [         R                  " [        U [        5      (       a  [        O[
        U 5      nU(       a  UR                  5       n [        U 5      $ )zEmulate the behavior of the C function stoll(), which just stop
converting strings to integers at the first invalid char without raising
an exception. e.g. "42xyz" is a valid integer 42

)r   search
isinstancer4   INT_PATTERN_SINT_PATTERN_Bgroupintsress     r:   _search_intr    s>     ))#As++C IIKq6MrA   z#[+-]?\d+(:?\.\d*)?(:?[eE][+-]?\d+)?s#   [+-]?\d+(:?\.\d*)?(:?[eE][+-]?\d+)?c                    [         R                  " [        U [        5      (       a  [        O[
        U 5      nU(       a  UR                  5       n [        U 5      $ )zEmulate the behavior of the C function stod(), which just stop
converting strings to doubles at the first invalid char without raising
an exception. e.g. "47.11xyz" is a valid double 47.11

)r   r	  r
  r4   FLOAT_PATTERN_SFLOAT_PATTERN_Br  floatr  s     r:   _search_floatr  )  s>     ))%a--?AC IIK8OrA   c           	   #    #    SnSnU R                   nU(       dm  U" 5       nU(       a   [        U5      nOg	U" 5       nU(       a8  UR                  S
5      nUS:X  a  US:X  a  SnUS:w  a  [        XE5      v   US-  nOg	U(       d  Ml  g	g	! [         aX     [        U5      n Nj! [         a<    UR	                  SS9R                  S5      n[        R                  " SU SU S35      ef = ff = f7f)af  Yields :class:``DXFTag`` objects from a bytes `stream`
(untrusted external  source), skips all comment tags (group code == 999).

``DXFTag.code`` is always an ``int`` and ``DXFTag.value`` is always a
raw bytes value without line endings. Works with file system streams and
:class:`BytesIO` streams.

Raises:
    DXFStructureError: Found invalid group code.

Fr   ignorer2   z
zInvalid group code "z
" at line .N   
r   s   EOFT  r   )	readliner  
ValueErrorr  decoderstripr   DXFStructureErrorr   )r?   eofliner  rM   r   s         r:   rS   rS   7  s      CDHz	4y 
LL)EqyUf_s{T))AID7 c  &t,D! ;;h;7>>vFD11.tfJtfAF s;   &C-B AC-C-
C*B C- AC&&C**C-c              #  B  #    Sn[         S-   nU R                  n SnU(       a7  U" 5       nU(       a   [        U5      nSUs=::  a  U:  a  O  OSnOgU(       a  M7  U" 5       nU(       a#  US:w  a  [	        XR                  S5      5      v   OgMt  ! [         a     NIf = f7f)a  Yields :class:``DXFTag`` objects from a bytes `stream`
(untrusted external source), skips all comment tags (group code == 999).

``DXFTag.code`` is always an ``int`` and ``DXFTag.value`` is always a
raw bytes value without line endings. Works with file system streams and
:class:`BytesIO` streams.

Does not raise DXFStructureError on invalid group codes, instead skips
lines until a valid group code or EOF is found.

This can remove invalid lines before group codes, but can not
detect invalid lines between group code and tag value.

r  r   Tr   FNr  )r   r  r  r  r   r   )r?   rM   upper_boundaryr  seeking_valid_group_coder   s         r:   rD   rD   e  s      D#a'NH
#' &:D9&t,D D1>1380 '& 
s{T<<#899'  " s-   0BB B4B
BBBBs   $DWGCODEPAGEs   $ACADVERc                    [        [        R                  5      nSR                  U  Vs/ s H  o"U;  d  M
  UPM     sn5      $ s  snf )N )r   string
whitespacejoin)r  wscs      r:   _strip_whitespacer.    s7    	V	B77q0q!RKAq0110s
   	AAc                   SnSnSnU  H  u  pEUS:X  a"  U[         :X  a  [         nO}U[        :X  a  [        nOlUS:X  a5  U[         :X  a+  [        UR                  [        R
                  5      5      nSnO1US:X  a+  U[        :X  a!  UR                  [        R
                  5      nSnU(       d  M  U(       d  M  U[        R                  :  a  Ss  $ Us  $    [        R
                  $ )a  Detect text encoding from header variables $DWGCODEPAGE and $ACADVER
out of a stream of DXFTag objects.

Assuming a malformed DXF file:

The header variables could reside outside of the HEADER section,
an ENDSEC tag is not a reliable fact that no $DWGCODEPAGE or
$ACADVER header variable will show up in the remaining tag stream.

Worst case: DXF file without a $ACADVER var, and a $DWGCODEPAGE
unequal to "ANSI_1252" at the end of the file.

Nr   r   r   utf8)DWGCODEPAGEACADVERr   r  r   DEFAULT_ENCODINGDXF2007)rl   r  rW   next_tagrM   r   s         r:   r  r    s     HJH19#&'!"QY8{2!%,,u/E/E"FGHHQY8w.e&<&<=JH8

'5==86FhF   !!!rA   c              #    ^^^#    UU4S jnSUU4S jjnSUU4S jjn[        T[        5      (       d   e[        U[        5      (       d   eTc  / m[        U 5      n SnSm  Ub  UnSnO[        U 5      nTS-  mUR                  n	U	[
        ;   a  [        U 5      n
TS-  mU
R                  U	S-   :w  a  [        R                  " ST S	35      e[        U 5      nTS-  m UR                  U	S
-   :X  a@   [        UR                  5      [        U
R                  5      [        UR                  5      4nO. [        UR                  5      [        U
R                  5      4nUn [        X5      v   GOU	[        ;   a>  [        U[        5      (       a  UnO! [        R                  " XR                  5      nUv   O[        R                   " U	[        5      nUR                  nU[        L a  U	S:X  a(  UR                  R#                  5       R%                  5       n UR'                  TSS9nU	(       a7  [1        U5      (       a  [3        U5      nO[5        U5      (       a  [7        U5      n[9        U	U5      v   O [9        X" U5      5      v   GM(  ! [         a9    U" UR                  5      U" U
R                  5      U" UR                  5      4n GNlf = f! [         a(    U" UR                  5      U" U
R                  5      4n GNf = f! [         a    [        R                  " ST S	35      ef = f! [         a    [        R                  " ST S	35      ef = f! [(         a8    UR'                  TUS9nTR+                  [,        R.                  ST 345         GNpf = f! [         a    U[:        L aK   [9        X" UR                  5      5      v    GNG! [         a    [        R                  " U" U5      5      ef = fU[        L aK   [9        X" UR                  5      5      v    GN! [         a    [        R                  " U" U5      5      ef = f[        R                  " U" U5      5      ef = f! [<         a     gf = f7f)u$  Compiles DXF tag values imported by bytes_loader() into Python types.

Raises DXFStructureError() for invalid float values and invalid coordinate
values.

Expects DXF coordinates written in x, y[, z] order, see function
:func:`safe_tag_loader` for usage with applied repair filters.

Args:
    tags: DXF tag generator, yielding tag values as bytes like bytes_loader()
    encoding: text encoding
    messages: list to store error messages
    errors: specify decoding error handler

        - "surrogateescape" to preserve possible binary data (default)
        - "ignore" to use the replacement char U+FFFD "�" for invalid data
        - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

Raises:
    DXFStructureError: Found invalid DXF tag or unexpected coordinate order.

c                j   > U R                   nU R                  R                  T5      nSU SU ST S3$ )NzInvalid tag (z, "z") near line: r  )rM   r   r  )r   rM   r   r  r#  s      r:   	error_msg$byte_tag_compiler.<locals>.error_msg  s;    xx		  *tfCwnTF!DDrA   c                   > [        U [        5      (       a  U R                  SSS9n [        U 5      nSU  ST SU S3nTR	                  [
        R                  U45        [        R                  U5        U$ )Nr0  r  r  r3   z!recovered invalid integer value "" near line  as "")	r
  bytesr  r  rz   r   INVALID_INTEGER_VALUEloggerwarningr  r   rN   r#  ru   s      r:   recover_int&byte_tag_compiler.<locals>.recover_int  sn    a&:AA1!LeE7RST993?@srA   c                  > [        U [        5      (       a  U R                  SSS9n [        U 5      n [	        U 5      nSU  ST SU S3nTR                  [        R                  U45        [        R                  U5        U$ )Nr0  r  r;  z(recovered invalid floating point value "r<  r=  r>  )
r
  r?  r  r.  r  rz   r   INVALID_FLOATING_POINT_VALUErA  rB  rC  s      r:   recover_float(byte_tag_compiler.<locals>.recover_float  s{    a&:Aa a 8<vUSXRYYZ[@@#FGsrA   Nr   r   
   z)Missing required y-coordinate near line: r     z)Invalid floating point values near line: zInvalid binary data near line: strictr2   z'Fixed unicode decoding error near line r  Union[str, bytes]r   r  r  rN  r   r  )r
  r4   iternextrM   r   r   r!  r  r   r  r   r   r   from_stringr   rd   r   r   r  UnicodeDecodeErrorrz   r   DECODING_ERRORr   r   r   r   r   r  StopIteration)rl   r  ru   r3   r8  rD  rH  undo_tagxrM   yzpointr   type_r   str_r#  s    ``              @r:   r  r    s1    <E
   h$$$$fc"""":DHD
j	#J	66D{"J	66TBY&11CD6K  J	vv* %agg %agg %agg%E%*177^U177^$DE $%
  ,,$a..C*66tWWE
 	"tS1 wwC<qy ! 5 5 7	$||HX|F *400#5d#;D-d33#8#>D t,,H$T5<88w :  *  -agg 6 -agg 6 -agg 6%E  *  -agg 6 -agg 6%E " 11CD6K  & #55=dV1E  . $||HV|D  * 9 9"I$ P, & H C<L&,T;qww3G&H H#- L&+&=&=il&K KL"e^L&,T=3I&J J#- L&+&=&=il&K KL #("9"9)A,"GGH  		s;  AQ<#A;Q, L 3>J
 1Q, 3*K L Q, -Q</"Q,  L- 2Q, 6Q<7AQ, M &AQ, 2Q<4N Q<
?K	L 
Q, KL .L>L LL %L**Q, -%MQ, >NQ, NQ, Q).OQ, Q<'O55Q)P"Q,  Q<"'Q		 Q))Q, ,
Q96Q<8Q99Q<)r-   )r6   zUnion[str, Path]r3   r4   r   tuple[Drawing, Auditor])r?   r   r3   r4   r   r]  )r  )r   r]  )r   ri   r   r4   )r   r   r   r   )r   r   r   ztuple[int, Tags])NNr-   )
r?   r   rC   r   ru   Optional[list]r3   r4   r   r   rM  rO  )r?   r   r   r   )r  r4   r   r4   )rl   r   r   r4   )rl   r   ru   r^  r3   r4   r   r   )M
__future__r   r)  typingr   r   r   r   r   r	   r
   r   r   collectionsr   pathlibr   loggingezdxf.lldxfr   r   ezdxf.lldxf.encodingr   r   r   r   ezdxf.lldxf.typesr   r   r   r   r   r   r   ezdxf.lldxf.tagsr   r   ezdxf.lldxf.validatorr   ezdxf.tools.codepager   ezdxf.auditr   r   rG   r!   ezdxf.eztypesr"   __all__r   	getLoggerrA  r$   r#   rE   r>   r<   r   r   r   rv   compiler  r  r  r  r  r  no_type_checkrS   rD   r1  r2  r.  r  r3  r  r   rA   r:   <module>rp     s   #      	 #        . < + +&):
  
		7	# /@(+620 /7(+< r rj	; "&##	!O!O!O !O 	!O
 !OH 

;'

<( **CD**DE * *Z%P 
2
""J  ####	h
h h 	h
 h hrA   