
    /_i                        d dl mZ d dlmZ d dlmZ d dlmZ erd dlm	Z	 	 	 	 	 	 	 d
dZ
ddZ	 	 	 	 	 	 	 	 	 	 	 	 ddZy	)    )annotations)TYPE_CHECKING)StreamlitAPIException)is_url)CustomThemeConfigc                <   | sy| j                         } d| vr| dfS | j                  dd      \  }}|j                         }|j                         }|j                  d      }|dkD  rt        d| d      t	        |      }|r|st        d| d	      |r||fS |dfS )
ai  Parse a single font configuration string.

    Args:
        font_config: The font configuration string (e.g., "Inter" or "Inter:https://...")
        property_name: The property name for error messages ("font", "codeFont", "headingFont")

    Returns
    -------
        A tuple of (font_name, source_url). source_url is None if not provided or not valid.
    ) N:N   zfamily=z The source URL specified in the za property of config.toml contains multiple fonts. Please specify only one font in the source URL.zDA font family name is required when specifying a source URL for the z property in config.toml.)stripsplitcountr   r   )font_configproperty_name	font_name
source_urlfamily_occurrencesis_valid_urls         [/var/www/html/land_sniper/venv/lib/python3.12/site-packages/streamlit/runtime/theme_util.py_parse_font_configr      s      ##%K
+D   (--c15Iz!I!!#J $)))4A#.}o >> >
 	

 *%L I#$o%>@
 	

 *$$d?    c                    |dk(  r| S |  dS )zGet the config name for font sources based on property and section. This is used on the FE
    as the id for the font source link in the html head.
    themez-sidebar )r   sections     r   _get_font_source_config_namer   Q   s     '_H%%r   c                   t        |d      \  }}|r|| _        |r)t        d|      }| j                  j	                  ||       t        |d      \  }}	|r|| _        |	r)t        d|      }| j                  j	                  ||	       t        |d      \  }
}|
r|
| _        |r)t        d|      }| j                  j	                  ||       | S )a  Populate the CustomThemeConfig message with the font, codeFont, and headingFont fields set,
    as well as the font_sources field to be added to the html head.

    Args:
        msg: CustomThemeConfig message to be populated.
        body_font_config: A string with just the font name (e.g., "Inter") or in the format
            "<font_family_name_here>:<source_url_here>".
        code_font_config: A string with just the font name (e.g., "Roboto Mono") or in the format
            "<code_font_family_name_here>:<source_url_here>".
        heading_font_config: A string with just the font name (e.g., "Inter Bold") or in the format
            "<heading_font_family_name_here>:<source_url_here>".
        section: The section of the config.toml file to parse the fonts from.

    Examples
    --------
    body_font_config: "Inter" (just font name)
    code_font_config: "Tagesschrift:https://fonts.googleapis.com/css2?family=Tagesschrift&display=swap" (with source)
    heading_font_config: "playwrite-cc-za:https://use.typekit.net/xxs7euo.css"

    Returns
    -------
        Updated CustomThemeConfig message with the font, codeFont, and headingFont fields set.
        Also sets sources in font_sources field to be added to the html (only when source URLs are provided).
    font)config_namer   codeFontheadingFont)r   	body_fontr   font_sourcesadd	code_fontheading_font)msgbody_font_configcode_font_configheading_font_configr   body_font_namebody_font_sourcer   code_font_namecode_font_sourceheading_font_nameheading_font_sources               r   parse_fonts_with_sourcer1   Z   s    B (::JF'S$N$&267CAQR (::JJ'W$N$&2:wGAQR .@].** ,2='JATUJr   N)r   
str | Noner   strreturnztuple[str, str | None])r   r3   r   r3   r4   r3   )r'   r   r(   r2   r)   r2   r*   r2   r   r3   r4   r   )
__future__r   typingr   streamlit.errorsr   streamlit.url_utilr   streamlit.proto.NewSession_pb2r   r   r   r1   r   r   r   <module>r:      s{     #   2 %@333 3l&:	: : !: $	:
 : :r   