L iUddlmZddlZddlmZddlmZmZmZm Z ddl m Z ddl m Z ddlmZddlmZer dd lmZdd l mZeezezej.zZd ed <dd ZGddZy)) annotationsN)Path) TYPE_CHECKINGAny TypeAliascast)url_util)validate_heightStreamlitAPIException)gather_metrics)DeltaGenerator)HeightWithoutContentrPdfDatacB ddl}|jS#t$rYywxYw)zGet the PDF custom component if available. Returns ------- Any | None The pdf_viewer function if the streamlit-pdf component is available, None otherwise. rN) streamlit_pdf pdf_viewer ImportError)rs \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/pdf.py_get_pdf_componentr!s(''' s  cveZdZedddd d dZ d dZd dZed dZy) PdfMixinpdfiN)heightkeyc|| tdt}||jS|j||||S)aDisplay a PDF viewer. .. Important:: You must install |streamlit-pdf|_ to use this command. You can install it as an extra with Streamlit: .. code-block:: shell pip install streamlit[pdf] .. |streamlit-pdf| replace:: ``streamlit-pdf`` .. _streamlit-pdf: https://github.com/streamlit/streamlit-pdf Parameters ---------- data : str, Path, BytesIO, or bytes The PDF file to show. This can be one of the following: - A URL (string) for a hosted PDF file. - A path to a local PDF file. If you use a relative path, it must be relative to the current working directory. - A file-like object. For example, this can be an ``UploadedFile`` from ``st.file_uploader``, or this can be a local file opened with ``open()``. - Raw bytes data. height : int or "stretch" The height of the PDF viewer. This can be one of the following: - An integer specifying the height in pixels: The viewer has a fixed height. If the content is larger than the specified height, scrolling is enabled. This is ``500`` by default. - ``"stretch"``: The height of the viewer matches the height of its content or the height of the parent container, whichever is larger. If the viewer is not in a parent container, the height of the viewer matches the height of its content. Example ------- >>> st.pdf("https://example.com/sample.pdf") >>> st.pdf("https://example.com/sample.pdf", height=600) zhThe PDF data cannot be None. Please provide a valid PDF file path, URL, bytes data, or file-like object.)r r_show_pdf_warning_call_pdf_component)selfdatarr pdf_components rrz PdfMixin.pdf3sRh <'3  +,  ))+ +'' tVSIIct|dt|ttfrZt|j }t j |dr|}n t|d5}|j}dddn{t|tr|}nht|d rt|d r|j}n?t|d r|j}n"td t|j d |d k(rd } n t|} || |} t#d| S#1swYxYw#ttf$r}td|d|d}~wwxYw)z5Call the custom PDF component with the provided data.F) allow_content)httphttps)allowed_schemasrbNzUnable to read file 'z': readgetvaluezUnsupported data type for PDF: zy. Please provide a file path (str or Path), URL (str), bytes data, or file-like object (such as BytesIO or UploadedFile).stretch)filerrr)r isinstancestrrstripr is_urlopenr)FileNotFoundErrorPermissionErrorr byteshasattrr*type__name__r) rr!r rrdata_str file_paramr,ecomponent_heightresults rrzPdfMixin._call_pdf_componenttsW e4 dS$K (4y(Hx9JK% h-1%)YY[ 1e $J T6 "wtZ'@J T6 "J(1$t*2E2E1FGIJ  Y  ) "6{ #  $f--K11)?;//zQC@s0 D/$D#5D/#D,(D//E>EEctd)z;Raise an exception that the PDF component is not available.zThe PDF viewer requires the `streamlit-pdf` component to be installed. Please run `pip install streamlit[pdf]` to install it. For more information, see the Streamlit PDF documentation at https://docs.streamlit.io/develop/api-reference/media/st.pdf.r rs rrzPdfMixin._show_pdf_warnings# L  r"ctd|S)zGet our DeltaGenerator.r)rr>s rdgz PdfMixin.dgs$d++r")r rrrr str | Nonereturnr) r!rr rrrrrArBr)rBr) r7 __module__ __qualname__r rrrpropertyr@r"rrr2sE (+ >J>J% >J  >J  >J>J@;.;.;.% ;.  ;.  ;.z ,,r"r)rBz Any | None) __future__riopathlibrtypingrrrr streamlitr #streamlit.elements.lib.layout_utilsr streamlit.errorsr streamlit.runtime.metrics_utilr streamlit.delta_generatorrrr.r4BytesIOr__annotations__rrrFr"rrRsX# 66?298H4Z%'"**44"L,L,r"