
    Ցi&                        S SK r S SKrS SKrS SKrS SKrS SKJr  S SKJr  S SK	J
r
  S SK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JrJrJrJrJrJ r J!r!J"r"J#r#   " S S5      r$ " S S5      r% " S S5      r&S r' " S S5      r( " S S5      r) " S S5      r* " S S5      r+ " S S5      r, " S S5      r- " S S5      r. " S  S!5      r/ " S" S#5      r0g)$    N)abstractmethod)	signature)Path)AnyCallableDictListOptionalUnion)Image   )logging   )	AudioWriter	CSVWriter
HtmlWriterImageWriter
JsonWriterMarkdownWriter
TextWriterVideoWriter
XlsxWriterc                   x    \ rS rSrSrS\S\4S jr\S\	\
\4   4S j5       r\S\	\
\4   4S j5       rSS
 jrSrg	)	WordMixin+   z:
Mixin class for adding Word (.docx) export capabilities.
argskwargsc                 N    U R                   R                  U R                  5        g N)_save_funcsappendsave_to_wordselfr   r   s      e/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddlex/inference/common/result/mixin.py__init__WordMixin.__init__0   s     1 12    returnc                     [         ez
Convert the result to a Word-compatible format.

Returns:
    Dict[str, Any]: A dictionary containing Word-compatible blocks and image data.
NotImplementedErrorr$   s    r%   _to_wordWordMixin._to_word3   
     "!r(   c                 "    U R                  5       $ r+   )r/   r.   s    r%   wordWordMixin.word=        }}r(   Nc                   ^^^^^^ SSK Jm  SSKJm  SSKJm  SSKJm  SSKJ	mJ
m  S nUUUUUU4S jn[        U R                  5       5      nUR                  n[        U5      nX S	3-  n[        [        U S
S5      5      n	U	R                   R#                  5       n
[%        U
5      S:X  ab  U R'                  5       S   nU R'                  5       S   nU R'                  5       R)                  SS5      nU" U[        U5      5      nU" XU5      nOU R'                  UR+                  5       5      nUR-                  UR/                  5       5        g)zJ
Save the Word session dict to a .docx file (each page as separate file).
r   BeautifulSoup)Document)WD_ALIGN_PARAGRAPH)qn)InchesPtc                 4   0 nUS-  nUR                  SSS9  U  Hz  nUR                  S5      nUR                  S5      nU(       a  U(       d  M5  [        U5      R                  nX7-  nUR	                  U5        [        UR                  5       5      X%'   M|     U$ zU
Save images to disk and return a mapping from original path to saved absolute path.
imgsT)parentsexist_okpathimgmkdirgetr   namesavestrresolve	
image_listbase_save_pathabs_image_paths	image_diritemimg_pathimg_objimg_name	save_paths	            r%   save_images+WordMixin.save_to_word.<locals>.save_imagesQ        /1O&/IOOD4O8"88F+((5/w>..%0	Y',/	0A0A0C,D) # #"r(   c                   > UUUU4S jnU4S jnT" 5       nSnU  GH  nUR                  SS5      nUc  UnOX:w  a  UR                  5         UnUR                  S5      n	UR                  SS5      R                  5       n
UR                  S	5      nU	S
:X  aT  U
(       aM  UR                  S   nSUR                  l        UR                  R                  U
5      nTR                  Ul        OYU	S:X  aS  U
(       aL  UR                  S   nSUR                  l        UR                  R                  U
5      nTR                  Ul        U	S;   a  UR                  S5      nU(       d    gUR                  U5      nU(       d  SU S3s  $ UR                  5       nUR                  5       nUR                  UT" S5      S9  TR                  Ul        GM  U	S:X  a  U
(       a  SU
;   a  U" U
5      OGU
R                  S5       Vs/ s H+  nUR                  5       (       d  M  UR                  S5      PM-     snnU(       a  [        S U 5       5      nUR                  SUS9nSUl        U H[  nUR!                  5       R"                  n[%        U5       H/  nU['        U5      :  a  UU   R                  5       OSUU   l        M1     M]     GM  GM  U	S;  d  GM  U
(       d  GM  U	S:X  a  SU
 3n
UR                  U
5      nU" X5        GM     U$ s  snf )z.
Convert word blocks to Word document format.
c                 2  > U R                   (       a  U R                   S   OU R                  5       nUR                  SS5      nX2R                  l        UR
                  R                  R                  R                  T" S5      S5        T" UR                  SS5      5      UR                  l	        UR                  SS	5      Ul
        UR                  S
TR                  5      U l        UR                  SS	5      (       a  T" S5      U R                  l        g g )Nr   fontzTimes New Romanz
w:eastAsiau   宋体size   boldFalignindentg333333?)runsadd_runrG   r[   rH   _elementrPrrFontssetr\   r^   LEFT	alignmentparagraph_formatfirst_line_indent)paraconfigrun	font_namer<   r=   r:   r;   s       r%   set_paragraph_styleKWordMixin.save_to_word.<locals>.blocks_to_word.<locals>.set_paragraph_stylej   s    &*iidiilT\\^"JJv/@A	 )  ''++B|,<hG "6::fb#9 :!::fe4!'G5G5L5L!M::h..>DSkD)); /r(   c                    > T" U S5      nUR                  S5       VVs/ s H3  nUR                  SS/5       Vs/ s H  o3R                  SS9PM     snPM5     snn$ s  snf s  snnf )Nhtml.parsertrtdthTstrip)find_allget_text)htmlsouprs   cellr8   s       r%   parse_html_tableHWordMixin.save_to_word.<locals>.blocks_to_word.<locals>.parse_html_tableu   si    $T=9 #mmD11 <>;;d|;TU;T4]]].;TU1 Us   A"AA"A"N
page_indexr   typecontent rl   headerFfooter)chartimageseal% [Image not found]

% [Image path not found for ]

   )widthtable<table
	c              3   8   #    U  H  n[        U5      v   M     g 7fr   len.0rs     r%   	<genexpr>AWordMixin.save_to_word.<locals>.blocks_to_word.<locals>.<genexpr>   s     &<t!s1vvt   )rowscolsz
Table Grid)r   r   r   r   r   r   vision_footnoter   z[footnote] )rG   add_sectionrw   sectionsr   is_linked_to_previousadd_paragraphCENTERrh   r   rb   add_picturesplitmax	add_tablestyleadd_rowcellsranger   text)word_blocksoriginal_image_widthrO   ro   r}   doccurrent_pageblockpage_idxlabelr   rl   sectionrk   
image_nameabs_image_pathrm   r   r   max_colsr   	row_cellsrowir8   r9   r<   r=   r:   r;   s                           r%   blocks_to_word.WordMixin.save_to_word.<locals>.blocks_to_worde   s   
	J 	J *CL$ 99\15'#+L-OO%#+L		&)))Ir288:8, H$!ll2.G;@GNN8">>77@D%7%>%>DNh&7!ll2.G;@GNN8">>77@D%7%>%>DN 66!&9!5J%8 &5%8%8%DN)!=j\OO,,.D,,.COON&)OD%7%>%>DN g%' $w. )15<]]45HV5HAGGImaggdm5HV 
 #&&<t&<#< #18 D&2)-I"'--/"7"7C%*8_<=I<NIaL$6$6$8TV !$A &5 *.	  	   11$/y"9,,W5D'5Y %Z J? Ws   <LLz.docxr/   Nr   imagesr   i  )bs4r8   docxr9   docx.enum.textr:   docx.oxml.nsr;   docx.sharedr<   r=   r   _get_input_fnstemr   getattr
parameterskeysr   r/   rG   rK   rI   as_posix)r$   rU   r   r   rV   r   fnr   	save_filesigparamsblocksr   r   rO   r   r8   r9   r<   r=   r:   r;   s                   @@@@@@r%   r"   WordMixin.save_to_wordG   s    	&!5#*	#(g	 g	R $$$&'wwO	&.	j$78$$&v;!]]_]3F]]_X.F#'==?#6#67Ms#S )&$y/BO OC--	 1 1 34C##%&r(    r)   N)__name__
__module____qualname____firstlineno____doc__listdictr&   r   r   rJ   r   r/   propertyr3   r"   __static_attributes__r   r(   r%   r   r   +   sf    3d 3d 3 "$sCx. " " d38n  W'r(   r   c                   t    \ rS rSrS\S\4S jr\S\\	\
4   4S j5       r\S\\	\
4   4S j5       rSS	 jrS
rg)
LatexMixin   r   r   c                 N    U R                   R                  U R                  5        g r   )r    r!   save_to_latexr#   s      r%   r&   LatexMixin.__init__   s     2 23r(   r)   c                     [         e)z
Convert the result to a LaTeX-compatible format.

Returns:
    Dict[str, Any]: A dictionary containing LaTeX-compatible blocks and image data.
r,   r.   s    r%   	_to_latexLatexMixin._to_latex   r1   r(   c                 "    U R                  5       $ )zProperty to access the LaTeX-compatible data.

Returns:
    Dict[str, Any]: A dictionary containing LaTeX-compatible blocks and image data.
)r   r.   s    r%   latexLatexMixin.latex        ~~r(   Nc                 @  ^^^^^^ SSK Jm   S nS[        S[        4S jmS[        S[        4U4S jjmS[        4S jmS[        4UU4S	 jjmS[        4UUUU4S
 jjmS[        4UU4S jjn[        U R	                  5       5      nUR
                  n[        U5      nX S3-  n[        [        U SS 5      5      n	U	R                  R                  5       n
[        U
5      S:X  aA  U R                  5       S   nU R                  5       S   nU" U[        U5      5      nU" X5      nOU R                  UR                  5       5      n[        R                  " USS9  [        UR!                  5       SSS9 nUR#                  U5        S S S 5        g ! , (       d  f       g = f)Nr   r7   c                 4   0 nUS-  nUR                  SSS9  U  Hz  nUR                  S5      nUR                  S5      nU(       a  U(       d  M5  [        U5      R                  nX7-  nUR	                  U5        [        UR                  5       5      X%'   M|     U$ r?   rE   rL   s	            r%   rV   -LatexMixin.save_to_latex.<locals>.save_images   rX   r(   sr)   c                 V   U (       d  gU R                  SS5      R                  SS5      R                  SS5      R                  SS	5      R                  S
S5      R                  SS5      R                  SS5      R                  SS5      R                  SS5      R                  SS5      $ )z"
Escape LaTeX special characters.
r   \z\textbackslash{}&z\&%z\%$z\$#z\#_z\_{z\{}z\}~z\textasciitilde{}^z\textasciicircum{})replace)r   s    r%   escape_latex.LatexMixin.save_to_latex.<locals>.escape_latex  s     		$ 34e$e$e$e$e$e$e$2334r(   c                   >^ [         R                  " SU 5      n/ nU H  nUR                  5       nU(       d  M  / mU4S jn[         R                  " SXC[         R                  S9nT	" U5      n[        T5       H  u  pgUR                  SU S3U5      nM     UR                  SU-   5        M     SR                  U5      S-   $ )	z7
Process regular paragraphs while preserving formulas.
z\n\s*\nc                 h   > TR                  U R                  S5      5        S[        T5      S-
   S3$ )Nr   	@@FORMULA   @@)r!   groupr   )mplaceholderss    r%   _holdGLatexMixin.save_to_latex.<locals>.escaped_paragraph_text.<locals>._hold4  s3     ''
3&s<'8':&;2>>r(   z!(\$\$.*?\$\$|\$.*?\$|\\\[.*?\\\]))flagsr   r   z\par 

)	rer   rw   subDOTALL	enumerater   r!   join)
r   
paragraphs	processedpr   tempr   fr   r   s
           @r%   escaped_paragraph_text8LatexMixin.save_to_latex.<locals>.escaped_paragraph_text&  s     *a0JIGGI  "? vv8%")) $D)%l3DA<<)A3b(91=D 4  D1%  & ;;y)F22r(   c                 |    U R                  S5      nU(       d  gUR                  U5      nU(       d  SU S3$ SU S3$ )Nr   r   r   r   zC\begin{figure}[h]
\centering
\includegraphics[width=0.8\linewidth]{z}
\end{figure}

rG   )r   rO   r   r   s       r%   generate_image_latex6LatexMixin.save_to_latex.<locals>.generate_image_latexA  sU    9-J0 -00<N!5j\GG<<J;K L&'r(   c                   > U R                  SS5      nSU;   a  T" US5      nUR                  S5       VVs/ s Hr  nUR                  SS/5       Vs/ s HP  n[        R                  " SUR	                  S	S
95      (       d  T" UR	                  S	S
95      OUR	                  S	S
9PMR     snPMt     nnnO}UR                  5        VVs/ s H`  nUR                  5       (       d  M  UR                  S5       Vs/ s H)  n[        R                  " SU5      (       d  T" U5      OUPM+     snPMb     nnnU(       d  g[        S U 5       5      nU V	s/ s H  oS/U[        U	5      -
  -  -   PM     n
n	SR                  [        U5       Vs/ s H  nSPM     sn5      nSnUSU S3-  n[        U
5       H)  u  pUSR                  U5      S-   -  nUS:X  d  M$  US-  nM+     US-  nU$ s  snf s  snnf s  snf s  snnf s  sn	f s  snf )Nr   r   r   rr   rs   rt   ru   z!(\$.*?\$|\\\(.*?\\\)|\\\[.*?\\\])Trv   r   c              3   8   #    U  H  n[        U5      v   M     g 7fr   r   r   s     r%   r   ILatexMixin.save_to_latex.<locals>.generate_table_latex.<locals>.<genexpr>v  s     1DqCFFDr    z>{\raggedright\arraybackslash}Xz1\begin{center}
\renewcommand{\arraystretch}{1.5}
z\begin{tabularx}{\textwidth}{z}
\toprule
z & z \\
r   z	\midrule
z)\bottomrule
\end{tabularx}
\end{center}

)rG   rx   r  searchry   
splitlinesrw   r   r   r   r  r   r  )r   r   r{   rs   rt   r   r   c	col_countr   	norm_rowsr   
col_formatr   r   r8   r   s                  r%   generate_table_latex6LatexMixin.save_to_latex.<locals>.generate_table_latexS  s8   ii	2.G7"$Wm< #mmD1 2 #%++tTl";
 #<B $&99 D "$ 7$ $ )4)@A
 "$4!89 #<
 2  0  '113  4yy{ "%4 "1A $&99-QST#U#U )O!"# "1  4   1D11IBFG$QbTYQ%788$IG>CI>NO>N4>NOJ ME;J<WWE#I.C9446]*E / GGELW
 " HOsB   G)AG$)G)G4$G470G/'G4G:G?$G)/G4c                   > U R                  SS5      nU R                  SS5      =(       d    SnUS:X  a  ST" UR                  5       5       S3$ US;   a  gUS:X  a  S	T" UR                  5       5       S
3$ US:X  a  ST" UR                  5       5       S3$ US:X  a  T	" U5      $ US:X  aq  UR                  5        Vs/ s H  oDR                  5       PM     nnSR	                  U Vs/ s H$  oDR                  5       (       d  M  T" U5      S-   PM&     sn5      S-   $ US:X  a  SUR                  5        S3$ US:X  a  SU-   S-   $ US;   a  T
" X5      $ US:X  a  T" U 5      $ US;   a  ST" UR                  5       5       S3$ US:X  a  UR                  S5       Vs/ s H)  oDR                  5       (       d  M  UR                  5       PM+     nn/ nU HR  nT" [        R                  " SSU5      5      nS[        [        U5      5      S-   3nUR                  S U S!U 35        MT     SR	                  U5      S-   SR	                  U5      S-   4$ S"U S#T" U5       S3$ s  snf s  snf s  snf )$Nr   r   r   	doc_titlez\begin{center}
{\Huge z}\end{center}

)r   r   abstractz\begin{abstract}
z
\end{abstract}

paragraph_titlez
\section*{z}

r   r   z \\r  formulaz\[
z
\]

	algorithmz\begin{verbatim}
z
\end{verbatim}

)r   r   r   r   )figure_titletable_titlechart_titlez\begin{center}
{\small 	referencez^\[\d+\]\s*refi z	\bibitem{z} z% [Unknown block: z] )rG   rw   r  rstripr  r   r  r  abshashr!   )r   rO   r   r   linelinesbibitemskeyr   r  r  r  s           r%   block_to_latex0LatexMixin.save_to_latex.<locals>.block_to_latex  s   IIfb)Eii	2.4"G#5l7==?6S5TTijj,,
".|GMMO/L.MMdee))%l7==?&C%DFKK-g66	!3:3E3E3GH3G43GHIIBGX%$::<5d+g5%X  	!w}}/y99#,w69PPP22+ECC+E22FF6|GMMO7T6UUjkk#29--2EV2E$2EV!D*266."d+KLGDJ& 89:COOk#c'$CD " yy*T1499X3F3MMM'wbg1F0GtLL3 I Y Ws   <I&I I I%4I%c                   > 0 nU  HH  n[        UR                  SS5      =(       d    S5      nUR                  U/ 5      R                  U5        MJ     / SQnSn[	        UR                  5       5       GH?  n[	        X'   S S9nU Vs/ s H  o3R                  S5      S:X  d  M  UPM     n	nU Vs/ s H  o3R                  S5      S	:X  d  M  UPM     n
nS
R                  S U	 5       5      nS
R                  S U
 5       5      nUR                  SU S35        UR                  ST" U5       S35        UR                  ST" U5       S35        U HL  nUR                  SS5      S:X  a  U(       d  UR                  S5        SnM5  UR                  T" X5      5        MN     UR                  S5        GMB     U(       a  UR                  S5        UR                  S5        SR                  U5      $ s  snf s  snf )Nr   r   )z\documentclass[12pt]{article}z\usepackage{xeCJK}z\usepackage{fontspec}z\usepackage{graphicx}z\usepackage{amsmath}z\usepackage{geometry}z\usepackage{fancyhdr}z\usepackage{indentfirst}z\usepackage{caption}z\usepackage{tabularx, booktabs}z\usepackage{amssymb}z\usepackage{amsfonts}z\geometry{a4paper, margin=1in}z$\setCJKmainfont{Droid Sans Fallback}z\setmainfont{DejaVu Serif}z\setsansfont{Lato}z\setmonofont{Latin Modern Mono}z\pagestyle{fancy}z\setlength{\parindent}{2em}z\begin{document}
Fc                 0    U R                  S/ SQ5      S   $ )N
block_bbox)r   r   r   r   r   r  )bs    r%   <lambda>CLatexMixin.save_to_latex.<locals>.blocks_to_latex.<locals>.<lambda>  s    155|3TUV3Wr(   )r1  r   r   r   r  c              3   D   #    U  H  oR                  S S5      v   M     g7fr   r   Nr  r   r7  s     r%   r   DLatexMixin.save_to_latex.<locals>.blocks_to_latex.<locals>.<genexpr>       &S]uuY';';]    c              3   D   #    U  H  oR                  S S5      v   M     g7fr;  r  r<  s     r%   r   r=    r>  r?  z% ==== page z header/footer ====z\fancyhead[L]{r   z\fancyfoot[C]{z}
r   reference_titlez\begin{thebibliography}{99}Tz\clearpage
z\end{thebibliography}
z\end{document}r   )intrG   
setdefaultr!   sortedr   r  )r   rO   pagesr7  r  latex_linesin_bibpage_numpage_blocksheader_blocksfooter_blockspage_headerpage_footerr   r2  r   s                 r%   blocks_to_latex1LatexMixin.save_to_latex.<locals>.blocks_to_latex  s   ElA.3!4  B'..q1 K. F"5::<0$O)W -8 UKq55=H;TK U,7 UKq55=H;TK U!hh&S]&SS!hh&S]&SS""\(;N#OP""%5l;6O5PPR#ST""%5l;6O5PPT#UV(Eyy,0AA&#**+IJ!% &&~e'MN ) ""?3) 1, ""#=>0199[))- !V Us   G/"G/.G4
G4z.texr   latex_blocksr   T)rB   wzutf-8)encoding)r   r8   rJ   r   r   r   r   r   r   r   r   r   rK   osmakedirsopenr   write)r$   rU   r   r   rV   rN  r   r   r   r   r   r   r   rO   r   r  r8   r2  r   r  r  r  s                   @@@@@@r%   r   LatexMixin.save_to_latex   sp   %		#(	C 	C 	&	3c 	3c 	36	C 	$0	3 0	 0	d'	Mc '	M '	MR8	* 8	* 8	*t $$$&'wwO	&-	k489$$&v;!^^%n5F^^%h/F)&$y/BO#F<ENN9#4#4#67E
I-)$$&g>!GGEN ?>>s   4F
Fr   r   )r   r   r   r   r   r   r&   r   r   rJ   r   r   r   r   r   r   r   r(   r%   r   r      sa    4d 4d 4 "4S> " "  tCH~    Ar(   r   c                   J    \ rS rSrSr\S\\\4   4S j5       rS rS	S jr	Sr
g)
StrMixini  z6Mixin class for adding string conversion capabilities.r)   c                 "    U R                  5       $ )zProperty to get the string representation of the result.

Returns:
    Dict[str, str]: The string representation of the result.
)_to_strr.   s    r%   rJ   StrMixin.str  s     ||~r(   c                 
    SU 0$ )a  Convert the given result data to a string representation.

Args:
    json_format (bool): If True, return a JSON formatted string. Default is False.
    indent (int): Number of spaces to indent for JSON formatting. Default is 4.
    ensure_ascii (bool): If True, ensure all characters are ASCII. Default is False.

Returns:
    Dict[str, str]: The string representation of the result.
resr   r.   s    r%   r[  StrMixin._to_str	  s     t}r(   Nc                 L    [         R                  " U R                  5       5        g)z.Print the string representation of the result.N)r   infor[  r.   s    r%   printStrMixin.print  s    T\\^$r(   r   r   )r   r   r   r   r   r   r   rJ   r[  rb  r   r   r(   r%   rY  rY    s0    @T#s(^  %r(   rY  c           
      x   [        U [        R                  [        R                  45      (       a  [	        U 5      $ [        U [        R
                  [        R                  45      (       a  [        U 5      $ [        U [        R                  5      (       a*  U R                  5        Vs/ s H  n[        U5      PM     sn$ [        U [        R                  5      (       a$  [        R                  " U R                  SSS95      $ [        U [         5      (       a  U R#                  5       $ [        U [$        5      (       a8  [%        U R'                  5        VVs0 s H  u  p#U[        U5      _M     snn5      $ [        U [(        [*        45      (       a  U  Vs/ s H  n[        U5      PM     sn$ U $ s  snf s  snnf s  snf )zHelper function to format data into a JSON-serializable format.

Args:
    obj: The object to be formatted.

Returns:
    Any: The formatted object.
recordsF)orientforce_ascii)
isinstancenpfloat32float64floatint32int64rB  ndarraytolist_format_datapd	DataFramejsonloadsto_jsonr   r   r   itemsr   tuple)objrQ   kvr   s        r%   rq  rq    s7    #

BJJ/00Sz	C"((BHH-	.	.3x	C	$	$/2zz|<|tT"|<<	C	&	&zz#++YE+JKK	C		||~	C		CIIK@KDAQQ'K@AA	C$	'	'),-AQ--
 = A-s   &F,F1
F7c                       \ rS rSrSrSS jrS\\\\\4   4   4S jr	\
S\\\\\4   4   4S j5       r  SS\S	\S
\S\S\SS4S jjr   SS\S	\S
\4S jjr SS\S	\S
\SS4S jjrSrg)	JsonMixini8  z7Mixin class for adding JSON serialization capabilities.r)   Nc                 l    [        5       U l        U R                  R                  U R                  5        g r   )r   _json_writerr    r!   save_to_jsonr.   s    r%   r&   JsonMixin.__init__;  s&    &L 1 12r(   c                 D    S[        [        R                  " U 5      5      0$ )zConvert the object to a JSON-serializable format.

Returns:
    Dict[str, Dict[str, Any]]: A dictionary representation of the object that is JSON-serializable.
r^  )rq  copydeepcopyr.   s    r%   _to_jsonJsonMixin._to_json?  s     |DMM$$7899r(   c                 "    U R                  5       $ )zProperty to get the JSON representation of the result.

Returns:
    Dict[str, Dict[str, Any]]: The dict type JSON representation of the result.
)r  r.   s    r%   rt  JsonMixin.jsonH  r5   r(   rU   r`   ensure_asciir   r   c                    S nU R                  5       nU" U5      (       dx  [        U R                  5       5      nUR                  n	[        U5      n
U HA  nX SU S3-  nU R                  R
                  " UR                  5       X{   /UQ7UUS.UD6  MC     g	[        U5      S:  a  [        R                  " SU S35        U R                  R
                  " UU[        UR                  5       5      S      /UQ7UUS.UD6  g	)
a-  Save the JSON representation of the object to a file.

Args:
    save_path (str): The path to save the JSON file. If the save path does not end with '.json', it appends the base name and suffix of the input path.
    indent (int): The number of spaces to indent for pretty printing. Default is 4.
    ensure_ascii (bool): If False, non-ASCII characters will be included in the output. Default is False.
    *args: Additional positional arguments to pass to the underlying writer.
    **kwargs: Additional keyword arguments to pass to the underlying writer.
c                 R    [         R                  " U 5      u  pUS L=(       a    US:H  $ )Nzapplication/json	mimetypes
guess_type	file_path	mime_typer   s      r%   _is_json_file-JsonMixin.save_to_json.<locals>._is_json_filed  s*    $//	:LID(LY:L-LLr(   r   z.jsonr`   r  r   z`The result has multiple json files need to be saved. But the `save_path` has been specified as ``!r   N)r  r   r   r   r  rV  r   r   r   warningr   r   )r$   rU   r`   r  r   r   r  	json_datar   r   rN   r1  s               r%   r  JsonMixin.save_to_jsonR  s5   $	M MMO	Y''d((*+B77D!)_N *vQse5-AA	!!''&&(N
  "!-	  ! 9~!v  xA  wB  BD  E ##$y~~/034
  )	 r(   json_formatc                 X    U(       a   [         R                  " [        SU 05      X#S9$ SU 0$ )a  Convert the given result data to a string representation.
Args:
    data (dict): The data would be converted to str.
    json_format (bool): If True, return a JSON formatted string. Default is False.
    indent (int): Number of spaces to indent for JSON formatting. Default is 4.
    ensure_ascii (bool): If True, ensure all characters are ASCII. Default is False.
Returns:
    Dict[str, str]: The string representation of the result.
r^  r  )rt  dumpsrq  )r$   r  r`   r  s       r%   r[  JsonMixin._to_str  s2     ::eT]+F  4= r(   c                 P    U R                  XUS9n[        R                  " U5        g)a-  Print the string representation of the result.

Args:
    json_format (bool): If True, print a JSON formatted string. Default is False.
    indent (int): Number of spaces to indent for JSON formatting. Default is 4.
    ensure_ascii (bool): If True, ensure all characters are ASCII. Default is False.
)r  r`   r  N)r[  r   ra  )r$   r  r`   r  str_s        r%   rb  JsonMixin.print  s*     ||#  
 	Tr(   )r  r   )r   F)Fr   F)r   r   r   r   r   r&   r   rJ   r   r  r   rt  rB  boolr	   r  r[  rb  r   r   r(   r%   r}  r}  8  s    A3:$sDcN23 : d3S#X./   "	33 3 	3
 3 3 
3n ""	!! ! 	!. PU14HL	 r(   r}  c                       \ rS rSrSrS\S\SS4S jr\S\\	\	4   4S j5       r
\S\\	\	4   4S	 j5       rS
\	S\S\SS4S jrSrg)Base64Mixini  z4Mixin class for adding Base64 encoding capabilities.r   r   r)   Nc                 n    [        U0 UD6U l        U R                  R                  U R                  5        g)zInitializes the Base64Mixin.

Args:
    *args: Positional arguments to pass to the TextWriter.
    **kwargs: Keyword arguments to pass to the TextWriter.
N)r   _base64_writerr    r!   save_to_base64r#   s      r%   r&   Base64Mixin.__init__  s0     )$9&9 3 34r(   c                     [         e)zzAbstract method to convert the result to Base64.

Returns:
    Dict[str, str]: The str type Base64 representation result.
r,   r.   s    r%   
_to_base64Base64Mixin._to_base64  
     "!r(   c                 "    U R                  5       $ )zz
Property that returns the Base64 encoded content.

Returns:
    Dict[str, str]: The base64 representation of the result.
)r  r.   s    r%   base64Base64Mixin.base64  s       r(   rU   c                 4   U R                  5       n[        U5      R                  5       R                  S5      (       du  [	        U R                  5       5      nUR                  n[	        U5      nU H>  nXv SU S3-  nU R                  R                  " UR                  5       XH   /UQ70 UD6  M@     g[        U5      S:  a  [        R                  " SU S35        U R                  R                  " X[        UR                  5       5      S      /UQ70 UD6  g)a  Saves the Base64 encoded content to the specified path.

Args:
    save_path (str): The path to save the base64 representation result. If the save path does not end with '.b64', it appends the base name and suffix of the input path.

    *args: Additional positional arguments that will be passed to the base64 writer.
    **kwargs: Additional keyword arguments that will be passed to the base64 writer.
z.b64r   r   zbThe result has multiple base64 files need to be saved. But the `save_path` has been specified as `r  r   N)r  rJ   lowerendswithr   r   r   r  rV  r   r   r   r  r   r   )	r$   rU   r   r   r  r   r   rN   r1  s	            r%   r  Base64Mixin.save_to_base64  s    "9~##%..88d((*+B77D!)_N*vQse4-@@	##))&&(&+8<@F  6{Qx  zC  yD  DF  G %%$v{{}"5a"89<@DJr(   )r  )r   r   r   r   r   r	   r   r&   r   rJ   r  r   r  r  r   r   r(   r%   r  r    s    >5d 5d 5t 5 "DcN " " !S#X ! ! D D T r(   r  c            	           \ rS rSrSrSS\S\S\SS4S jjr\	S\\\
R                  4   4S	 j5       r\S\\\
R                  4   4S
 j5       rS\S\S\SS4S jrSrg)ImgMixini  z3Mixin class for adding image handling capabilities.backendr   r   r)   Nc                 r    [        USU0UD6U l        U R                  R                  U R                  5        g)zInitializes ImgMixin.

Args:
    backend (str): The backend to use for image processing. Defaults to "pillow".
    *args: Additional positional arguments to pass to the ImageWriter.
    **kwargs: Additional keyword arguments to pass to the ImageWriter.
r  N)r   _img_writerr    r!   save_to_imgr$   r  r   r   s       r%   r&   ImgMixin.__init__  s5     'HwHH 0 01r(   c                     [         e)zzAbstract method to convert the result to an image.

Returns:
    Dict[str, Image.Image]: The image representation result.
r,   r.   s    r%   _to_imgImgMixin._to_img  r  r(   c                 "    U R                  5       $ )zProperty to get the image representation of the result.

Returns:
    Dict[str, Image.Image]: The image representation of the result.
)r  r.   s    r%   rD   ImgMixin.img       ||~r(   rU   c                 2   S nU R                  5       nU" U5      (       d  [        U R                  5       5      nU" U5      (       a  UR                  OSnUR                  n[        U5      n	U H?  n
X SU
 U 3-  nU R
                  R                  " UR                  5       XZ   /UQ70 UD6  MA     g[        U5      S:  a  [        R                  " SU S35        U R
                  R                  " X[        UR                  5       5      S      /UQ70 UD6  g)	a  Saves the image representation of the result to the specified path.

Args:
    save_path (str): The path to save the image. If the save path does not end with .jpg or .png, it appends the input path's stem and suffix to the save path.
    *args: Additional positional arguments that will be passed to the image writer.
    **kwargs: Additional keyword arguments that will be passed to the image writer.
c                 j    [         R                  " U 5      u  pUS L=(       a    UR                  S5      $ )Nzimage/r  r  
startswithr  s      r%   _is_image_file,ImgMixin.save_to_img.<locals>._is_image_file  /    $//	:LID(KY-A-A(-KKr(   z.pngr   r   z_The result has multiple img files need to be saved. But the `save_path` has been specified as `r  r   N)r  r   r   suffixr   r  rV  r   r   r   r  r   r   )r$   rU   r   r   r  rD   r   r  r   rN   r1  s              r%   r  ImgMixin.save_to_img
  s   	L llni((d((*+B"0"4"4RYY&F77D!)_N*vQseF8-DD	  &&y'9'9';SXWWPVW  3x!|uv  vA  AC  D ""9$sxxz2B12E.FXXQWXr(   )r  )pillow)r   r   r   r   r   rJ   r	   r   r&   r   r   r  r   rD   r  r   r   r(   r%   r  r    s    =	2 	2t 	2t 	2PT 	2 "c5;;./ " " T#u{{*+  YS Y Y Y$ Yr(   r  c            	           \ rS rSrSrSS\S\S\SS4S jjr\	S\\\
R                  4   4S	 j5       r\S\\\
R                  4   4S
 j5       rS\S\S\SS4S jrSrg)CSVMixini(  z1Mixin class for adding CSV handling capabilities.r  r   r   r)   Nc                     [        USU0UD6U l        [        U S5      (       d  / U l        U R                  R	                  U R
                  5        g)zInitializes the CSVMixin.

Args:
    backend (str): The backend to use for CSV operations (default is "pandas").
    *args: Optional positional arguments to pass to the CSVWriter.
    **kwargs: Optional keyword arguments to pass to the CSVWriter.
r  r    N)r   _csv_writerhasattrr    r!   save_to_csvr  s       r%   r&   CSVMixin.__init__+  sJ     %tFWFvFt]++!D 0 01r(   c                 "    U R                  5       $ )zProperty to get the pandas Dataframe representation of the result.

Returns:
    Dict[str, pd.DataFrame]: The pandas.DataFrame representation of the result.
)_to_csvr.   s    r%   csvCSVMixin.csv8  r  r(   c                     [         e)zAbstract method to convert the result to pandas.DataFrame.

Returns:
    Dict[str, pd.DataFrame]: The pandas.DataFrame representation result.
r,   r.   s    r%   r  CSVMixin._to_csvA  r  r(   rU   c                    S nU R                  5       nU" U5      (       du  [        U R                  5       5      nUR                  n[        U5      nU H>  n	X SU	 S3-  nU R                  R
                  " UR                  5       XY   /UQ70 UD6  M@     g[        U5      S:  a  [        R                  " SU S35        U R                  R
                  " X[        UR                  5       5      S      /UQ70 UD6  g)	a  Saves the result to a CSV file.

Args:
    save_path (str): The path to save the CSV file. If the path does not end with ".csv",
        the stem of the input path attribute (self['input_path']) will be used as the filename.
    *args: Optional positional arguments to pass to the CSV writer's write method.
    **kwargs: Optional keyword arguments to pass to the CSV writer's write method.
c                 R    [         R                  " U 5      u  pUS L=(       a    US:H  $ )Nztext/csvr  r  s      r%   _is_csv_file*CSVMixin.save_to_csv.<locals>._is_csv_fileT  s)    $//	:LID(DY*-DDr(   r   z.csvr   z_The result has multiple csv files need to be saved. But the `save_path` has been specified as `r  r   N)r  r   r   r   r  rV  r   r   r   r  r   r   )
r$   rU   r   r   r  r  r   r   rN   r1  s
             r%   r  CSVMixin.save_to_csvJ  s    	E llnI&&d((*+B77D!)_N*vQse4-@@	  &&y'9'9';SXWWPVW  3x!|uv  vA  AC  D ""9$sxxz2B12E.FXXQWXr(   )r  r    )pandas)r   r   r   r   r   rJ   r	   r   r&   r   rr  rs  r  r   r  r  r   r   r(   r%   r  r  (  s    ;2 2t 2t 2PT 2 T#r||+,   "c2<</0 " "YS Y Y Y$ Yr(   r  c                       \ rS rSrSrS\S\SS4S jr\S\\	\	4   4S j5       r
\S\\	\	4   4S	 j5       rS
\	S\S\SS4S jrSrg)	HtmlMixinih  z2Mixin class for adding HTML handling capabilities.r   r   r)   Nc                 n    [        U0 UD6U l        U R                  R                  U R                  5        g)z
Initializes the HTML writer and appends the save_to_html method to the save functions list.

Args:
    *args: Positional arguments passed to the HtmlWriter.
    **kwargs: Keyword arguments passed to the HtmlWriter.
N)r   _html_writerr    r!   save_to_htmlr#   s      r%   r&   HtmlMixin.__init__k  s0     '77 1 12r(   c                 "    U R                  5       $ )zzProperty to get the HTML representation of the result.

Returns:
    str: The str type HTML representation of the result.
)_to_htmlr.   s    r%   rz   HtmlMixin.htmlv       }}r(   c                     [         e)zAbstract method to convert the result to str type HTML representation.

Returns:
    Dict[str, str]: The str type HTML representation result.
r,   r.   s    r%   r  HtmlMixin._to_html  r  r(   rU   c                    S nU R                  5       nU" U5      (       du  [        U R                  5       5      nUR                  n[        U5      nU H>  n	X SU	 S3-  nU R                  R
                  " UR                  5       XY   /UQ70 UD6  M@     g[        U5      S:  a  [        R                  " SU S35        U R                  R
                  " X[        UR                  5       5      S      /UQ70 UD6  g)	zSaves the HTML representation of the object to the specified path.

Args:
    save_path (str): The path to save the HTML file.
    *args: Additional positional arguments.
    **kwargs: Additional keyword arguments.
c                 R    [         R                  " U 5      u  pUS L=(       a    US:H  $ )Nz	text/htmlr  r  s      r%   _is_html_file-HtmlMixin.save_to_html.<locals>._is_html_file  s)    $//	:LID(EY+-EEr(   r   z.htmlr   z`The result has multiple html files need to be saved. But the `save_path` has been specified as `r  r   N)r  r   r   r   r  rV  r   r   r   r  r   r   )
r$   rU   r   r   r  rz   r   r   rN   r1  s
             r%   r  HtmlMixin.save_to_html  s   	F }}Y''d((*+B77D!)_N*vQse5-AA	!!''&&($)6:>D  4y1}v  xA  wB  BD  E ##TYY[ 1! 458<@Fr(   )r  )r   r   r   r   r   r	   r   r&   r   rJ   rz   r   r  r  r   r   r(   r%   r  r  h  s    <	3d 	3d 	3t 	3 d38n   "$sCx. " "c $ $ 4 r(   r  c                       \ rS rSrSrS\S\SS4S jr\S\\	\	4   4S j5       r
\S\\	\	4   4S	 j5       rS
\	S\S\SS4S jrSrg)	XlsxMixini  z2Mixin class for adding XLSX handling capabilities.r   r   r)   Nc                 n    [        U0 UD6U l        U R                  R                  U R                  5        g)zInitializes the XLSX writer and appends the save_to_xlsx method to the save functions.

Args:
    *args: Positional arguments to be passed to the XlsxWriter constructor.
    **kwargs: Keyword arguments to be passed to the XlsxWriter constructor.
N)r   _xlsx_writerr    r!   save_to_xlsxr#   s      r%   r&   XlsxMixin.__init__  s0     '77 1 12r(   c                 "    U R                  5       $ )zProperty to get the XLSX representation of the result.

Returns:
    Dict[str, str]: The str type XLSX representation of the result.
)_to_xlsxr.   s    r%   xlsxXlsxMixin.xlsx  r  r(   c                     [         e)zAbstract method to convert the result to str type XLSX representation.

Returns:
    Dict[str, str]: The str type HTML representation result.
r,   r.   s    r%   r  XlsxMixin._to_xlsx  r  r(   rU   c                    S nU R                  5       nU" U5      (       du  [        U R                  5       5      nUR                  n[        U5      nU H>  n	X SU	 S3-  nU R                  R
                  " UR                  5       XY   /UQ70 UD6  M@     g[        U5      S:  a  [        R                  " SU S35        U R                  R
                  " X[        UR                  5       5      S      /UQ70 UD6  g)	a  Saves the HTML representation to an XLSX file.

Args:
    save_path (str): The path to save the XLSX file. If the path does not end with ".xlsx",
                     the filename will be set to the stem of the input path with ".xlsx" extension.
    *args: Additional positional arguments to pass to the XLSX writer.
    **kwargs: Additional keyword arguments to pass to the XLSX writer.
c                 R    [         R                  " U 5      u  pUS L=(       a    US:H  $ )NzAapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheetr  r  s      r%   _is_xlsx_file-XlsxMixin.save_to_xlsx.<locals>._is_xlsx_file  s3    $//	:LI% WVWr(   r   z.xlsxr   z`The result has multiple xlsx files need to be saved. But the `save_path` has been specified as `r  r   N)r  r   r   r   r  rV  r   r   r   r  r   r   )
r$   rU   r   r   r  r  r   r   rN   r1  s
             r%   r  XlsxMixin.save_to_xlsx  s   	 }}Y''d((*+B77D!)_N*vQse5-AA	!!''&&($)6:>D  4y1}v  xA  wB  BD  E ##TYY[ 1! 458<@Fr(   )r  )r   r   r   r   r   r	   r   r&   r   rJ   r  r   r  r  r   r   r(   r%   r  r    s    <3d 3d 3t 3 d38n   "$sCx. " "#c #$ #$ #4 #r(   r  c            	           \ rS rSrSrSS\S\S\SS4S jjr\	S\\\
R                  4   4S	 j5       r\S\\\
R                  4   4S
 j5       rS\S\S\SS4S jrSrg)
VideoMixini  z3Mixin class for adding Video handling capabilities.r  r   r   r)   Nc                 Z    Xl         U R                  R                  U R                  5        g)zInitializes VideoMixin.

Args:
    backend (str): The backend to use for video processing. Defaults to "opencv".
    *args: Additional positional arguments to pass to the VideoWriter.
    **kwargs: Additional keyword arguments to pass to the VideoWriter.
N)_backendr    r!   save_to_videor  s       r%   r&   VideoMixin.__init__  s#       2 23r(   c                     [         e)zvAbstract method to convert the result to a video.

Returns:
    Dict[str, np.array]: The video representation result.
r,   r.   s    r%   	_to_videoVideoMixin._to_video  r  r(   c                 "    U R                  5       $ )zProperty to get the video representation of the result.

Returns:
    Dict[str, np.array]: The video representation of the result.
)r  r.   s    r%   videoVideoMixin.video  r   r(   rU   c                 8   S n[        USU R                  0UD6nU R                  5       nU" U5      (       d  [        U R	                  5       5      nUR
                  nU" U5      (       a  UR                  OSn	[        U5      n
U H5  nX SU U	 3-  nUR                  " UR                  5       Xk   /UQ70 UD6  M7     g	[        U5      S:  a  [        R                  " SU S35        UR                  " X[        UR                  5       5      S      /UQ70 UD6  g	)
a  Saves the video representation of the result to the specified path.

Args:
    save_path (str): The path to save the video. If the save path does not end with .mp4 or .avi, it appends the input path's stem and suffix to the save path.
    *args: Additional positional arguments that will be passed to the video writer.
    **kwargs: Additional keyword arguments that will be passed to the video writer.
c                 j    [         R                  " U 5      u  pUS L=(       a    UR                  S5      $ )Nzvideo/r  r  s      r%   _is_video_file0VideoMixin.save_to_video.<locals>._is_video_file  r  r(   r  z.mp4r   r   zaThe result has multiple video files need to be saved. But the `save_path` has been specified as `r  r   N)r   r  r  r   r   r   r  rV  r   r   r   r  r   r   )r$   rU   r   r   r  video_writerr	  r   r   r  rN   r1  s               r%   r  VideoMixin.save_to_video  s    	L #4J4==J6J i((d((*+B77D"0"4"4RYY&F!)_N*vQseF8-DD	""9#5#5#7UdUfU  5zA~w  yB  xC  CE  F yUZZ\0B10E*FXXQWXr(   )r  )opencv)r   r   r   r   r   rJ   r	   r   r&   r   ri  arrayr  r   r	  r  r   r   r(   r%   r   r     s    =	4 	4t 	4t 	4PT 	4 "4RXX. " "  tCM*    Ys Y4 Y4 YD Yr(   r   c                       \ rS rSrSrS\S\SS4S jr\S\\	\
R                  4   4S j5       r\S\\	\
R                  4   4S	 j5       rS
\	S\S\SS4S jrSrg)
AudioMixini-  z3Mixin class for adding Audio handling capabilities.r   r   r)   Nc                     Xl         U R                  R                  U R                  5        [	        USU R                   0UD6U l        g)zInitializes AudioMixin.

Args:
    *args: Additional positional arguments to pass to the AudioWriter.
    **kwargs: Additional keyword arguments to pass to the AudioWriter.
r  N)r  r    r!   save_to_audior   _audio_writerr  s       r%   r&   AudioMixin.__init__0  s>       2 23(PPPr(   c                     [         e)zvAbstract method to convert the result to a audio.

Returns:
    Dict[str, np.array]: The audio representation result.
r,   r.   s    r%   	_to_audioAudioMixin._to_audio;  r  r(   c                 "    U R                  5       $ )zProperty to get the audio representation of the result.

Returns:
    Dict[str, np.array]: The audio representation of the result.
)r  r.   s    r%   audioAudioMixin.audioD  r   r(   rU   c                 2   S nU R                  5       nU" U5      (       d  [        U R                  5       5      nUR                  nU" U5      (       a  UR                  OSn[        U5      n	U H?  n
X SU
 U 3-  nU R
                  R                  " UR                  5       XZ   /UQ70 UD6  MA     g[        U5      S:  a  [        R                  " SU S35        U R
                  R                  " X[        UR                  5       5      S      /UQ70 UD6  g)	a  Saves the audio representation of the result to the specified path.

Args:
    save_path (str): The path to save the audio. If the save path does not end with .mp4 or .avi, it appends the input path's stem and suffix to the save path.
    *args: Additional positional arguments that will be passed to the audio writer.
    **kwargs: Additional keyword arguments that will be passed to the audio writer.
c                 j    [         R                  " U 5      u  pUS L=(       a    UR                  S5      $ )Nzaudio/r  r  s      r%   _is_audio_file0AudioMixin.save_to_audio.<locals>._is_audio_fileV  r  r(   z.wavr   r   zaThe result has multiple audio files need to be saved. But the `save_path` has been specified as `r  r   N)r  r   r   r   r  r  rV  r   r   r   r  r   r   )r$   rU   r   r   r!  r  r   r   r  rN   r1  s              r%   r  AudioMixin.save_to_audioM  s%   	L  i((d((*+B77D"0"4"4RYY&F!)_N*vQseF8-DD	""((&&(%*7;?E  5zA~w  yB  xC  CE  F $$ejjl!3A!67:>BHr(   )r  r  )r   r   r   r   r   r	   r   r&   r   rJ   ri  r  r  r   r  r  r   r   r(   r%   r  r  -  s    =	Qt 	Qt 	Q 	Q "4RXX. " "  tCM*    s 4 4 D r(   r  c                       \ rS rSrSrS/rS\S\4S jr\	 SS\
\\\\
\\4   4   4   4S jj5       r\S\
\\\\
\\4   4   4   4S	 j5       r S SS jjrS\S\S\\\4   S\\
\\\\
\\4   4   4      SS
4
S jrSrg
)MarkdownMixinio  z6Mixin class for adding Markdown handling capabilities.markdown_textsr   r   c                     [        U0 UD6U l        [        U0 UD6U l        U R                  R                  U R                  5        g)a  Initializes the Markdown writer and appends the save_to_markdown method to the save functions.

Args:
    *args: Positional arguments to be passed to the MarkdownWriter constructor.
    **kwargs: Keyword arguments to be passed to the MarkdownWriter constructor.
N)r   _markdown_writerr   r  r    r!   save_to_markdownr#   s      r%   r&   MarkdownMixin.__init__t  sB     !/ ? ?&77 5 56r(   r)   c                     [         e)z
Convert the result to markdown format.

Args:
    pretty (Optional[bool]): whether to pretty markdown by HTML, default by True.

Returns:
    Dict[str, Union[str, Dict[str, Any]]]: A dictionary containing markdown text and image data.
r,   )r$   prettyshow_formula_numbers      r%   _to_markdownMarkdownMixin._to_markdown  s
     "!r(   c                 "    U R                  5       $ )zProperty to access the markdown data.

Returns:
    Dict[str, Union[str, Dict[str, Any]]]: A dictionary containing markdown text and image data.
)r.  r.   s    r%   markdownMarkdownMixin.markdown  s       ""r(   Nc           
         S[         4S jnU" U5      (       dZ  [        U R                  5       5      nU" U5      (       a  UR                  OSnUR                  n	[        U5      n
X U 3-  nXl        OXl        U R                  " U R                  R                  U R                  R                  U R
                  U R                  X#S9/UQ70 UD6  g)zSave the markdown data to a file.

Args:
    save_path (Union[str, Path]): The path where the markdown file will be saved.
    *args: Additional positional arguments for saving.
    **kwargs: Additional keyword arguments for saving.
r)   c                     1 Skn[         R                  R                  [        U 5      5      u  p#UR	                  5       U;   a  g[
        R                  " [        U 5      5      u  pBUS:H  $ )zCheck if a file is a markdown file based on its extension or MIME type.

Args:
    file_path (Union[str, Path]): The path to the file.

Returns:
    bool: True if the file is a markdown file, False otherwise.
>   .md.mkd.mdown	.markdownTztext/markdown)rS  rC   splitextrJ   r  r  r  )r  markdown_extensionsr   extr  s        r%   _is_markdown_file9MarkdownMixin.save_to_markdown.<locals>._is_markdown_file  sX     #IWW%%c)n5FAyy{11$//I?LI//r(   r5  )r,  r-  N)r  r   r   r  r   rU   
_save_datar(  rV  r  r.  )r$   rU   r,  r-  r   r   r<  r   r  r   rN   s              r%   r)  MarkdownMixin.save_to_markdown  s    	0D 	0  !++d((*+B"3B"7"7RYYUF77D!)_N&6&)::I&N&N!!''""NNVU		

 	
 	
r(   save_mkd_funcsave_img_funcrU   datac                 l   [        U5      nUc  gUR                  5        H  u  pxXpR                  ;   a  U" UR                  5       U/UQ70 UD6  [	        U[
        5      (       d  MF  UR                  n	UR                  5        H+  u  pU(       d  M  U" X-  R                  5       U/UQ70 UD6  M-     M     g)a  Internal method to save markdown and image data.

Args:
    save_mkd_func (Callable): Function to save markdown text.
    save_img_func (Callable): Function to save image data.
    save_path (Union[str, Path]): The base path where the data will be saved.
    data (Optional[Dict[str, Union[str, Dict[str, Any]]]]): The markdown data to save.
    *args: Additional positional arguments for saving.
    **kwargs: Additional keyword arguments for saving.
N)r   rw  MARKDOWN_SAVE_KEYSr   rh  r   parent)r$   r@  rA  rU   rB  r   r   r1  valuerN   rR   img_datas               r%   r>  MarkdownMixin._save_data  s    & O	<**,JC---i002EKDKFK%&&!*!1!1*/++-&Hx%+6@@B$ " %	 +8 'r(   )r  r(  rU   )TFr   )r   r   r   r   r   rD  r   r   r&   r   r   rJ   r   r   r.  r   r1  r)  r   r   r
   r>  r   r   r(   r%   r%  r%  o  s   @*+	7d 	7d 	7 /4"	c5d38n,--	." " #$sE#tCH~*=$>>? # # ;@+
	+
Z""  " d#	"
 tCsDcN':!;;<=" 
"r(   r%  )1r  rt  r  rS  r  abcr   inspectr   pathlibr   typingr   r   r   r	   r
   r   numpyri  r  rr  PILr   utilsr   utils.ior   r   r   r   r   r   r   r   r   r   r   rY  rq  r}  r  r  r  r  r  r   r  r%  r   r(   r%   <module>rQ     s       	 	    = =    
 
 
s' s'lX Xv% %B6r rj: :z;Y ;Y|=Y =Y@> >BB BJ<Y <Y~? ?Dw wr(   