§
    �Øj=  ã                   óÄ   — d dl mZ d dlmZmZmZmZmZmZ d dl	Z	d dl
Zd dl	mZ 	 d dlmZ d dlmZ  ed¦  «         n# e$ r  ed¦  «        ‚w xY w G d„ d	e¦  «        ZdS )
é    )ÚPath)ÚAnyÚCallableÚDictÚListÚOptionalÚUnionN)ÚDocument)Ú
BaseReaderz Successfully imported LlamaIndexzPlease install 'llama_index'.c                   óx  — e Zd ZU dZdZeeeee	f         geee	f         f                  e
d<   	 ddeeeee	f         geee	f         f                  fd„Z	 ddeeef         dee         de	dee         fd	„Zd
edeee	f         dededej        j        j        de	fd„Z	 dd
edeeef         dedee         fd„ZdS )ÚPDFMarkdownReaderz%Read PDF files using PyMuPDF library.NÚmeta_filterc                 ó   — || _         d S ©N)r   )Úselfr   s     úš/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/pymupdf4llm/llama/pdf_markdown_reader.pyÚ__init__zPDFMarkdownReader.__init__   s   € ð 'ˆÔÐÐó    Ú	file_pathÚ
extra_infoÚload_kwargsÚreturnc           
      óž  — t          |t          ¦  «        s$t          |t          ¦  «        st          d¦  «        ‚|si }|r$t          |t          ¦  «        st          d¦  «        ‚t
          j        j                             |¦  «        }t          j
        |¦  «        }g }|D ],}|                      | j        ||||j        |fi |¤Ž¦  «         Œ-|S )aá  Loads list of documents from PDF file and also accepts extra information in dict format.

        Args:
            file_path (Union[Path, str]): The path to the PDF file.
            extra_info (Optional[Dict], optional): A dictionary containing extra information. Defaults to None.
            **load_kwargs (Any): Additional keyword arguments to be passed to the load method.

        Returns:
            List[LlamaIndexDocument]: A list of LlamaIndexDocument objects.
        z#file_path must be a string or Path.z extra_info must be a dictionary.)Ú
isinstanceÚstrr   Ú	TypeErrorÚdictÚpymupdf4llmÚhelpersÚpymupdf_ragÚIdentifyHeadersÚpymupdfÚopenÚappendÚ_process_doc_pageÚnumber)r   r   r   r   Úhdr_infoÚdocÚdocsÚpages           r   Ú	load_datazPDFMarkdownReader.load_data   sû   € õ  ˜)¥SÑ)Ô)ð 	Cµ*¸YÍÑ2MÔ2Mð 	CÝÐAÑBÔBÐBàð 	ØˆJàð 	@�j¨µTÑ:Ô:ð 	@ÝÐ>Ñ?Ô?Ð?õ Ô&Ô2×BÒBÀ9ÑMÔMˆå#œL¨Ñ3Ô3ˆØˆàð 	ð 	ˆDØ�KŠKØ&�Ô&Ø˜ Y°´¸Xðð ØITðð ñô ð ð ð
 ˆr   r(   Úpage_numberr'   c                 óÌ   — |                       ||||¦  «        }| j        r|                      |¦  «        }t          j        j        j        |f|g|dœ|¤Ž}t          ||¬¦  «        S )z*Processes a single page of a PDF document.)Úpagesr'   )Útextr   )Ú_process_doc_metar   r   r   r    Úto_markdownÚLlamaIndexDocument)r   r(   r   r   r,   r'   r   r/   s           r   r%   z#PDFMarkdownReader._process_doc_pageF   s‡   € ð ×+Ò+¨C°¸KÈÑTÔTˆ
àÔð 	6Ø×)Ò)¨*Ñ5Ô5ˆJåÔ"Ô.Ô:Øð
à�-Øð
ð 
ð ð	
ð 
ˆõ " t¸
ÐCÑCÔCÐCr   c                 ó’   — |                      |j        ¦  «         |dz   |d<   t          |¦  «        |d<   t          |¦  «        |d<   |S )z"Processes metas of a PDF document.é   r*   Útotal_pagesr   )ÚupdateÚmetadataÚlenr   )r   r(   r   r,   r   s        r   r0   z#PDFMarkdownReader._process_doc_meta]   sN   € ð 	×Ò˜#œ,Ñ'Ô'Ð'Ø(¨1™_ˆ
�6ÑÝ$'¨¡H¤Hˆ
�=Ñ!Ý"% i¡.¤.ˆ
�;ÑàÐr   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   Ú__annotations__r   r	   r   r   r2   r+   ÚFitzDocumentÚintr   r   r    r!   r%   r0   © r   r   r   r      sª  € € € € € € Ø/Ð/àHL€K�˜( D¨¨c¨¤NÐ#3°T¸#¸s¸(´^Ð#CÔDÔEÐLÐLÑLð MQð'ð 'à˜h¨¨S°#¨X¬Ð'7¸¸cÀ3¸h¼Ð'GÔHÔIð'ð 'ð 'ð 'ð &*ð%ð %à˜˜s˜Ô#ð%ð ˜T”Nð%ð ð	%ð
 
Ð Ô	!ð%ð %ð %ð %ðTDàðDð ˜˜c˜”NðDð ð	Dð
 ðDð Ô%Ô1ÔAðDð ðDð Dð Dð Dð8 &*ðð àðð ˜˜s˜Ô#ðð ð	ð
 ˜T”Nðð ð ð ð ð r   r   )Úpathlibr   Útypingr   r   r   r   r   r	   r"   Úpymupdf4llm.helpers.pymupdf_ragr   r
   r>   Úllama_index.core.readers.baser   Úllama_index.core.schemar2   ÚprintÚImportErrorÚNotImplementedErrorr   r@   r   r   ú<module>rI      s  ðØ Ð Ð Ð Ð Ð Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =à €€€Ø &Ð &Ð &Ð &Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,ð?Ø8Ð8Ð8Ð8Ð8Ð8ØFÐFÐFÐFÐFÐFà	€EÐ
,Ñ-Ô-Ð-Ð-øØð ?ð ?ð ?Ø
Ð
Ð=Ñ
>Ô
>Ð>ð?øøøðYð Yð Yð Yð Y˜
ñ Yô Yð Yð Yð Ys	   ¦> ¾A