+
    f0i,                        ^ RI t ^ RIt^ RIHt ^ RIHtHtHt ^ RIH	t	H
t
Ht ^ RIHt . ROt^t^@t^?t^tRt^tRt^&t^1t^3tRt^tR	 R
 ltR R ltR R ltR R ltR R lt] ]!]"]#,          3,          t$] ]!]"]%]",          ,          ]%]#,          ,          3,          t&] ]!]#]",          ]',          ]$,          ]&,          3,          t( ! R R4      t) ! R R4      t*R# )    N)Iterable)calcsizepackunpack)BinaryIOClassVarcast)PDFValueErroril    s   JB2

c                <    V ^8  d   QhR\         R\         R\        /# )   bit_posvaluereturnintbool)formats   "T/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/pdfminer/jbig2.py__annotate__r   (   s!     ( (S ( ( (    c                 2    \        W,	          ^,          4      # )   r   )r   r   s   &&r   bit_setr   (   s    !Q&''r   c                <    V ^8  d   QhR\         R\         R\        /# )r   flagr   r   r   )r   s   "r   r   r   ,   s!      S   r   c                 $    \        W,          4      # Nr   )r   r   s   &&r   
check_flagr   ,   s    r   c                <    V ^8  d   QhR\         R\         R\         /# r   maskr   r   r   )r   s   "r   r   r   0   s!     1 1s 13 13 1r   c                     \        ^4       F%  p\        W 4      '       g   K  W,          V,	          u # 	  \        R4      h   zInvalid mask or valueranger   r
   r"   r   r   s   && r   masked_valuer*   0   s6    97!!LW,,  /
00r   c                <    V ^8  d   QhR\         R\         R\         /# r!   r#   )r   s   "r   r   r   8   s!     1 1S 1 1 1r   c                     \        ^4       F,  p\        W 4      '       g   K  WV,	          ,          V,          u # 	  \        R4      hr%   r'   r)   s   && r   
mask_valuer-   8   s;    97!!W_-'99  /
00r   c                <    V ^8  d   QhR\         R\        R\        /# )r   r   bufferr   )strbytesr   )r   s   "r   r   r   @   s!      s E c r   c                 d    V R9   g   Q h\        \        \        ,          \        W4      4      w  pV# )>B>   r3   >I>L)r	   tupler   r   )r   r/   results   && r   
unpack_intr8   @   s-    ''''E#Jv 67HVMr   c                      a  ] tR t^Nt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
V 3R lR ltRtV tR# )JBIG2StreamReaderz&Read segments from a JBIG2 byte streamc                $   < V ^8  d   QhRS[ RR/# r   streamr   Nr   )r   __classdict__s   "r   r   JBIG2StreamReader.__annotate__Q         x D r   c                    Wn         R # r   r=   selfr=   s   &&r   __init__JBIG2StreamReader.__init__Q       r   c                0   < V ^8  d   QhRS[ S[,          /# r   r   )listJBIG2Segment)r   r?   s   "r   r   r@   T   s      d<0 r   c                   . pV P                  4       '       g   / p\         F{  w  r4\        V4      pV P                  P	                  V4      p\        V4      V8  d   R VR&    M=\        W64      p\        V RV 2R4      p\        V4      '       d
   V! W'V4      pWrV&   K}  	  VP                  R4      '       d   K  VP                  V4       K  V# )T_errorparse_N)is_eof
SEG_STRUCTr   r=   readlenr8   getattrcallablegetappend)	rE   segmentssegmentfield_formatname	field_lenfieldr   parsers	   &        r   get_segmentsJBIG2StreamReader.get_segmentsT   s    ')++--$&G&0"$\2	((3u:	)(,GH%"<7 v=F##"759E % '1 ;;x(((r   c                    < V ^8  d   QhRS[ /# rJ   r   )r   r?   s   "r   r   r@   h   s       r   c                    V P                   P                  ^4      R8X  d   R# V P                   P                  R\        P                  4       R# )r   r   TF)r=   rR   seekosSEEK_CUR)rE   s   &r   rP   JBIG2StreamReader.is_eofh   s7    ;;A#%KKR-r   c                2   < V ^8  d   QhRS[ RS[RS[RS[/# r   rY   flagsr]   r   )rL   r   r1   JBIG2SegmentFlags)r   r?   s   "r   r   r@   o   s3     

 



 

 	


 


r   c           	     f    R \        \        V4      R\        \        V4      R\        \        V4      /# )deferredpage_assoc_longtype)r   HEADER_FLAG_DEFERREDHEADER_FLAG_PAGE_ASSOC_LONGr*   SEG_TYPE_MASK)rE   rY   rj   r]   s   &&&&r   parse_flagsJBIG2StreamReader.parse_flagso   s4     
#7?z*EuML6
 	
r   c                2   < V ^8  d   QhRS[ RS[RS[RS[/# ri   )rL   r   r1   JBIG2RetentionFlags)r   r?   s   "r   r   r@   {   s3     +
 +
+
 +
 	+

 
+
r   c                H   \        \        V4      p. p. pV\        8  d.   \        ^4       F  pVP	                  \        Wr4      4       K  	  MW0P                  P                  ^4      ,          p\        RV4      p\        \        V4      p\        P                  ! V^,           ^,          4      p\        V4       FT  p	\        RV P                  P                  ^4      4      p
\        ^4       F  pVP	                  \        Wz4      4       K  	  KV  	  VR,          p\        V\        4      '       g   Q hVR8:  d   RpMVR8:  d   RpMRp\        V4      p\        V4       F:  pV P                  P                  V4      p\        W4      pVP	                  V4       K<  	  RVRVR	V/# )
   r5   r3   number      r4   	ref_countretain_segmentsref_segments)r*   REF_COUNT_SHORT_MASKREF_COUNT_LONGr(   rW   r   r=   rR   r8   REF_COUNT_LONG_MASKmathceil
isinstancer   r   )rE   rY   rj   r]   r|   r}   r~   r   ret_bytes_count_ret_byte_indexret_byteseg_num
ref_formatref_size
_ref_indexref_datarefs   &&&&             r   parse_retention_flags'JBIG2StreamReader.parse_retention_flags{   su    !!5u=	~% 8&&ww'>? $ [[%%a((E"4/I$%8)DI"iiQ!(;<O#(#9%dDKK,<,<Q,?@$QxG#**77+EF  ( $:
 (#'3''''c>JJJJ'	*J{{''1HZ2C$ + L
 	
r   c                2   < V ^8  d   QhRS[ RS[RS[RS[/# )r   rY   pager]   r   rL   r   r1   )r   r?   s   "r   r   r@      s*       C  RU r   c                    \        \        VR ,          4      R,          '       d.   W0P                  P                  ^4      ,          p\	        RV4      pV# )rj   rn   r5   )r	   rk   r=   rR   r8   )rE   rY   r   r]   s   &&&&r   parse_page_assoc"JBIG2StreamReader.parse_page_assoc   sC    !77#345FGG[[%%a((EdE*Dr   c                2   < V ^8  d   QhRS[ RS[RS[RS[/# )r   rY   lengthr]   r   r   )r   r?   s   "r   r   r@      s3        	
 
r   c                    V'       d\   \        \        VR ,          4      R,          \        8X  d   V\        8X  d   \	        R4      hV P
                  P                  V4      VR&   V# )rj   ro   z:Working with unknown segment length is not implemented yetraw_data)r	   rk   SEG_TYPE_IMMEDIATE_GEN_REGIONDATA_LEN_UNKNOWNNotImplementedErrorr=   rR   )rE   rY   r   r]   s   &&&&r   parse_data_length#JBIG2StreamReader.parse_data_length   s]     &(89&A01--)P  '+kk&6&6v&>
#r   rC   N)__name__
__module____qualname____firstlineno____doc__rF   r_   rP   rs   r   r   r   __static_attributes____classdictcell__r?   s   @r   r:   r:   N   sO     0  ( 

 

+
 +
Z  r   r:   c            	       "  a  ] tR t^t o RtR^ R]! ]],          . 4      R]! ]],          . 4      /t	V 3R lR lt
RV 3R lR lltRV 3R	 lR
 lltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R ltRtV tR# )JBIG2StreamWriterz.Write JBIG2 segments to a file in JBIG2 formatr|   r~   r}   c                $   < V ^8  d   QhRS[ RR/# r<   r>   )r   r?   s   "r   r   JBIG2StreamWriter.__annotate__   rA   r   c                    Wn         R # r   rC   rD   s   &&r   rF   JBIG2StreamWriter.__init__   rH   r   c                <   < V ^8  d   QhRS[ S[,          RS[RS[/# r   rX   fix_last_pager   r   rL   r   r   )r   r?   s   "r   r   r      s.     ! !<(! ! 
	!r   c                r   ^ pRpRpV F  pV P                  V4      pV P                  P                  V4       V\        V4      ,          p\	        \
        R,          VR,          4      pV'       g   Ki  \	        \
        VP                  R4      4      p\	        \        VR,          4      R,          \        8X  d   RpK  V'       g   K  TpK  	  V'       dd   V'       d\   VeX   V P                  V^,           V4      pV P                  V4      pV P                  P                  V4       V\        V4      ,          pV# )r   Nry   
page_assocrj   ro   )
encode_segmentr=   writerS   r	   r   rV   rk   SEG_TYPE_END_OF_PAGEget_eop_segment)	rE   rX   r   data_lencurrent_pager   rY   dataseg_pages	   &&&      r   write_segments JBIG2StreamWriter.write_segments   s   
 #'"G&&w/DKKd#D	!H3:wx'89G}W[[%>? *GG,<=fE+, $(LX#+L!  $ \w/B**7Q;EG&&w/DKKd#D	!Hr   c                <   < V ^8  d   QhRS[ S[,          RS[RS[/# r   r   )r   r?   s   "r   r   r      s.      <(  
	r   c                   \         p\        pV\        R V4      ,          p\        R^4      pW5,          pV P                  P	                  V4       \        V4      pW`P                  W4      ,          p^ pV F  p\        \        VR,          4      pK  	  V'       d   ^M^p	V P                  Wy,           4      p
V P                  V
4      pV P                  P	                  V4       V\        V4      ,          pV# )r3   r5   ry   )FILE_HEADER_IDFILE_HEAD_FLAG_SEQUENTIALr   r=   r   rS   r   r	   r   get_eof_segmentr   )rE   rX   r   headerheader_flagsnumber_of_pagesr   r   rY   seg_num_offseteof_segmentr   s   &&&         r   
write_fileJBIG2StreamWriter.write_file   s    
  0$t\** tQ-!&!v;''@@G3 12G   ,**7+CD"";/$CIr   c                &   < V ^8  d   QhRS[ RS[/# )r   rY   r   )rL   r1   )r   r?   s   "r   r   r     s     
 
l 
u 
r   c                    R p\          FS  w  r4VP                  V4      p\        V RV 2R4      p\        V4      '       d
   V! WQ4      pM\	        W54      pW',          pKU  	  V# )r   encode_N)rQ   rV   rT   rU   r   )rE   rY   r   rZ   r[   r   encoderr]   s   &&      r   r    JBIG2StreamWriter.encode_segment  sd    ",LKK%EdgdV$4d;G  /\1MD #- r   c                ,   < V ^8  d   QhRS[ RS[RS[/# r   r   rY   r   )rk   rL   r1   )r   r?   s   "r   r   r     s#     ! !"3 !l !u !r   c                T   ^ pVP                  R4      '       d   V\        ,          pRV9   d   Y1R,          '       d   \        MT,          pM4T\        \        VP                  R^ 4      4      ^8  d   \        MT,          pV\        \        VR,          4      ,          p\        RV4      # )r   rm   rn   r   ro   r3   )rV   rp   rq   r	   r   r-   rr   r   )rE   r   rY   rj   s   &&& r   encode_flagsJBIG2StreamWriter.encode_flags  s    99Z  ))E%:K4L4L0RWWEW[[34s: ,E 	M5=99D%  r   c                ,   < V ^8  d   QhRS[ RS[RS[/# r   )rv   rL   r1   )r   r?   s   "r   r   r   -  s)     -* -*"-* -* 
	-*r   c                   . pR pVR,          p\        V\        4      '       g   Q h\        \        \        ,          VP                  R. 4      4      pV^8:  dQ   \        \        V4      p\        V4       F  w  rV	'       g   K  V^V,          ,          pK!  	  VP                  V4       M\        P                  ! V^,           ^,          4      p
RRV
,          ,           p\        \        \        4      ^,          pVP                  V4       \        V
4       F^  p^ pWl^,          V^,          ^,            p\        V4       F   w  ppTV'       d
   ^V,          MT,          pK"  	  VP                  V4       K`  	  \        \        \        ,          VP                  R. 4      4      p\        \        VR,          4      pVR8:  d   RpMVR8:  d   R	pMR
pV F  pVV,          pVP                  V4       K  	  \        V.VO5!  # )r3   r|   r}   r5   Br~   ry   rz   r{   IL)r   r   r	   rK   r   rV   r-   r   	enumeraterW   r   r   r   r(   r   )rE   r   rY   rj   flags_formatr|   r}   
flags_byte	ref_index
ref_retainbytes_countflags_dword
byte_indexr   ret_partr   ret_segr~   r   r   r   s   &&&                  r   encode_retention_flags(JBIG2StreamWriter.encode_retention_flags-  s   
 +&	)S))))tDz5995F+KL>#$8)DJ)2?)C%	:!y.0J *D LL$))Y]a$78K3#45L$%9>JbPKLL%#K0
*>JNQ<NO(1((;$GWWXEH )< X& 1 DIuyy'DEsGH-.c>JJJCJ&LLL   L)5))r   c                ,   < V ^8  d   QhRS[ RS[RS[/# r   )r   rL   r1   )r   r?   s   "r   r   r   \  s"       l u r   c                Z    \        R V4      pV\        \        VR,          4      ,          pV# )r5   r   )r   r	   r1   )rE   r   rY   r   s   &&& r   encode_data_length$JBIG2StreamWriter.encode_data_length\  s)    D% UGJ/00r   c                ,   < V ^8  d   QhRS[ RS[ RS[/# )r   
seg_numberpage_numberr   r   rL   )r   r?   s   "r   r   r   a  s"     
 
# 
C 
L 
r   c                J    R ^ RRRR\         /RVRVRRR	\        P                  /# 
data_lengthrj   rm   Fro   ry   r   r   r   retention_flags)r   r   EMPTY_RETENTION_FLAGS)rE   r   r   s   &&&r   r   !JBIG2StreamWriter.get_eop_segmenta  s;    1j%1EFj+0FF
 	
r   c                &   < V ^8  d   QhRS[ RS[/# )r   r   r   r   )r   r?   s   "r   r   r   k  s     
 
# 
, 
r   c                J    R ^ RRRR\         /RVR^ RRR	\        P                  /# r   )SEG_TYPE_END_OF_FILEr   r   )rE   r   s   &&r   r   !JBIG2StreamWriter.get_eof_segmentk  s;    1j%1EFj!0FF
 	
r   c                6   < V ^8  d   Qh/ S[ S[,          ;R&   # )r   r   )r   rv   )r   r?   s   "r   r   r      s      $$78  r   rC   N)T)r   r   r   r   r   r	   rK   r   r   r   rF   r   r   r   r   r   r   r   r   __annotate_func__r   r   r   s   @r   r   r      s     8 	QT#Y+4T
B/< ! !F <
 
! !$-* -*^ 

 

 
S  r   r   ))r5   ry   )r3   rj   )r3   r   )r3   r   )r5   r   )+r   re   collections.abcr   structr   r   r   typingr   r   r	   pdfminer.pdfexceptionsr
   rQ   rp   rq   rr   r   r   r   r   r   r   r   r   r   r   r   r*   r-   r8   dictr0   r   r   rk   rK   rv   r1   rL   r:   r    r   r   <module>r      s    	 $ ) ) + + 0
 " ( !     !#    5& (11 cDj) 3d3i$t* <<= 3J**-@@Bq qhq
 q
r   