
    r)h*                         S r SSKJr  SSKJrJrJr  SSKJrJ	r	J
r
  SSKJr  SSKJrJrJr  SSKJr  \(       a  SS	KJr  \ " S
 S5      5       r " S S\5      r " S S\5      rS r " S S5      rg)u  
Quoting section 8.2.2 "Document Outline" of the 2006 PDF spec 1.7:
> The document outline consists of a tree-structured hierarchy of outline items (sometimes called bookmarks),
> which serve as a visual table of contents to display the document’s structure to the user.

The contents of this module are internal to fpdf2, and not part of the public API.
They may change at any time without prior warning or any deprecation period,
in non-backward-compatible ways.
    )	dataclass)ListOptionalTYPE_CHECKING   )AlignXPosYPos)	TextStyle)Destination	PDFObject	PDFString)
StructElem)FPDFc                   \    \ rS rSr% Sr\\S'   \\S'   \\S'   \\S'   \	\
   \S'   SS	 jrS
rg)OutlineSection   namelevelpage_numberdeststruct_elemr   r   r   r   r   Nc                 @    Xl         X l        X0l        X@l        XPl        g Nr   )selfr   r   r   r   r   s         GC:\Users\13-19\Desktop\Lekcja\testEnv\Lib\site-packages\fpdf/outline.py__init__OutlineSection.__init__"   s    	
&	&    )r   r   r   r   r   r   )__name__
__module____qualname____firstlineno__	__slots__str__annotations__intr   r   r   r   __static_attributes__ r    r   r   r      s0     HI
IJ
*%%'r    r   c                   J   ^  \ rS rSrSr  S	S\S\S\4U 4S jjjrS r	Sr
U =r$ )
OutlineItemDictionary*   )
_idtitleparentprevnextfirstlastcountr   r   r/   r   r   c                    > [         TU ]  5         [        USS9U l        S U l        S U l        S U l        S U l        S U l        SU l	        X l
        X0l        g )NT)encryptr   )superr   r   r/   r0   r1   r2   r3   r4   r5   r   r   )r   r/   r   r   	__class__s       r   r   OutlineItemDictionary.__init__8   sS     	ud3
		
	
	&r    c                 <    SU R                    SU R                   S3$ )NzOutlineItemDictionary(title=z, dest=))r/   r   r   s    r   __str__OutlineItemDictionary.__str__I   s    -djj\1MMr    )	r5   r   r3   r4   r2   r0   r1   r   r/   )NN)r!   r"   r#   r$   r%   r&   r   r   r   r>   r)   __classcell__r9   s   @r   r,   r,   *   sD    I  !"&	'' '  	' '"N Nr    r,   c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )OutlineDictionaryM   )r.   typer3   r4   r5   c                 ^   > [         TU ]  " S0 UD6  SU l        S U l        S U l        SU l        g )Nz	/Outlinesr   r*   )r8   r   rE   r3   r4   r5   )r   kwargsr9   s     r   r   OutlineDictionary.__init__P   s/    "6"	
	
r    c                 "    SU R                    S3$ )NzOutlineDictionary(count=r<   )r5   r=   s    r   r>   OutlineDictionary.__str__W   s    )$**Q77r    )r5   r3   r4   rE   )	r!   r"   r#   r$   r%   r   r>   r)   r@   rA   s   @r   rC   rC   M   s    9I8 8r    rC   c              #   h  #    [        5       nUv   / n0 nU  GH
  n[        UR                  UR                  UR                  S9nUv   UR
                  U;   a  X4R
                     nXVl        Xel        UR
                  S-
  U;   a  X4R
                  S-
     nOUnXul        UR                  c  XWl	        XWl
        U=R                  S-  sl        UR                  U5        XSUR
                  '   UR                  5        VV	s0 s H  u  pXR
                  ::  d  M  X_M     nnn	GM     U/U-   $ s  sn	nf 7f)zz
Build PDF objects constitutive of the documents outline,
and yield them one by one, starting with the outline dictionary
)r/   r   r   r   )rC   r,   r   r   r   r   r2   r1   r0   r3   r4   r5   appenditems)
sectionsoutlineoutline_itemslast_outline_item_per_levelsectionoutline_itemlast_outline_item_at_levelparent_outline_itemr   oitems
             r   build_outline_objsrW   [   s=    
  !G
MM"$,,,++

 ==77)D]])S&.:+ :==1 ;;"=mma>O"P")1$$,(4%#/ !!Q&!\*5AGMM2 !< A A C'
 C% EL C 	$ '
#- 6 9}$$'
s   C=D2?D,D,D2c                   v    \ rS rSrSr     SS\\   4S jjrSSS\4S	 jr	SSS\4S
 jr
SSS\\   4S jrSrg)TableOfContents   a  
A reference implementation of a Table of Contents (ToC) for use with `fpdf2`.

This class provides a customizable Table of Contents that can be used directly or subclassed
for additional functionality. To use this class, create an instance of `TableOfContents`,
configure it as needed, and pass its `render_toc` method as the `render_toc_function` argument
to `FPDF.insert_toc_placeholder()`.
N
text_stylec                 d    U=(       d
    [        5       U l        X l        X0l        X@l        XPl        g r   )r   r[   use_section_title_styleslevel_indentline_spacingignore_pages_before_toc)r   r[   r]   r^   r_   r`   s         r   r   TableOfContents.__init__   s*     %3	(@%(('>$r    pdfr   itemc                 L   U R                   (       a7  UR                  UR                     (       a  UR                  UR                     $ [        U R                  R
                  [        [        45      (       a"  [        SU R                  R
                   35      eU R                  $ )Nz2Unsupported l_margin value provided as TextStyle: )	r]   section_title_stylesr   
isinstancer[   l_marginr&   r   
ValueError)r   rb   rc   s      r   get_text_styleTableOfContents.get_text_style   sz    ((S-E-Edjj-Q++DJJ77doo..e==DT__E]E]D^_  r    c                    UR                  UR                  S9nUR                  UR                     R                  5       nUR	                  U R                  X5      5         UR                  U R                  -  nUR                  UR                  U-   5        UR                  UR                  U-
  UR                  [        R                  [        R                   U["        R$                  UR&                  U R(                  -  S9  UR+                  5       nUR-                  U5      nUR.                  U-
  U-
  UR0                  -
  nUS:  a?  UR3                  5         UR+                  5       nUR.                  U-
  U-
  UR0                  -
  nSn	US:  a  UR-                  U	S-   5      U:  a  U	S-  n	UR-                  U	S-   5      U:  a  M  [5        U	5      S:  as  UR                  UR.                  U-
  UR0                  -
  U	S S [        R                  [        R                   U["        R6                  UR&                  U R(                  -  S9  UR                  U5        UR                  UR.                  U-
  UR0                  -
  U[        R8                  [        R:                  U["        R<                  UR&                  U R(                  -  S9  S S S 5        g ! , (       d  f       g = f)	N)page)wtextnew_xnew_ylinkalignhr    z  .r   )add_linkr   pages	get_labeluse_text_styleri   r   r^   set_xrg   
multi_cellepwr   r	   ENDr
   LASTr   J	font_sizer_   get_xget_string_widthrm   r_marginlnlenLLMARGINNEXTR)
r   rb   rc   rq   
page_labelindent	current_xpage_label_lengthin_between_space
in_betweens
             r   render_toc_itemTableOfContents.render_toc_item   s^   ||!1!1|2YYt//0::<
  3 3C >?ZZ$"3"33FIIcllV+,NN''F"YYhhiigg--$"3"33   		I # 4 4Z @"uuy03DDs||S!#IIK	#&559#47H#H3<<#W J!#**:+<=@PP#%J **:+<=@PP z?Q&NN%%)+cll:'_"hh"ii!#gg--$*;*;; #  IIi NN%%)#cll2lliigg--$"3"33  Q @??s   !E'K
DK
K$rO   c                     U HK  nU R                   (       a&  UR                  UR                  R                  ::  a  M:  U R	                  X5        MM     g)zUThis method can be overridden by subclasses to customize the Table of Contents style.N)r`   r   toc_placeholder
start_pager   )r   rb   rO   rR   s       r   
render_tocTableOfContents.render_toc   s@    G,,''3+>+>+I+II  . r    )r`   r^   r_   r[   r]   )NFg      @g      ?T)r!   r"   r#   r$   __doc__r   r   r   r   ri   r   r   r   r)   r*   r    r   rY   rY      si     +/!& $?Y'?&  56 5 5n/f /tN/C /r    rY   N)r   dataclassesr   typingr   r   r   enumsr   r	   r
   fontsr   syntaxr   r   r   structure_treer   fpdfr   r   r,   rC   rW   rY   r*   r    r   <module>r      ss    " 0 0 $ $  5 5 & ' ' '$ NI  NF8	 8$%N`/ `/r    