Ë
    úmxiÅx  ã                  óÜ  — d dl mZ d dlZd dlZd dlZd dlZd dlZd dlm	Z	m
Z
 e	rd dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZmZmZ d	Zdd
„Z	 	 	 	 	 	 dd„Z	 	 	 	 	 	 dd„Zdd„Zdd„Zd d„Z	 	 	 	 d!d„Z	 	 	 	 d"d„Z 	 	 	 	 d#d„Z!	 d$	 	 	 	 	 	 	 	 	 d%d„Z"	 d&	 	 	 	 	 	 	 	 	 	 	 	 	 d'd„Z#	 	 	 	 	 	 	 	 d(d„Z$	 	 	 	 	 	 d)d„Z%	 	 	 	 	 	 d*d„Z&	 	 	 	 	 	 d+d„Z'	 	 	 	 	 	 	 	 	 	 d,d„Z(	 	 	 	 	 	 	 	 d-d„Z)y).é    )ÚannotationsN)ÚTYPE_CHECKINGÚAny)ÚIterator)Úcli_utilÚurl_util)ÚConfigOption)Úis_css_color_like)ÚStreamlitInvalidThemeErrorÚ StreamlitInvalidThemeOptionErrorÚ!StreamlitInvalidThemeSectionErrori   c                 ó&   — ddl m}   | t        «      S )zHGet logger for this module. Separate function to avoid circular imports.r   ©Ú
get_logger)Ústreamlit.loggerr   Ú__name__r   s    úL/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/config_util.pyÚ_get_loggerr   )   s   € å+á”hÓÐó    c                óœ   — | j                  «       D ]9  \  }}|j                  d«      sŒ|j                  }||   j                  }||k7  sŒ9 y y)zpReturn True if and only if an option in the server section differs
    between old_options and new_options.
    ÚserverTF©ÚitemsÚ
startswithÚvalue)Úold_optionsÚnew_optionsÚopt_nameÚopt_valÚold_valÚnew_vals         r   Úserver_option_changedr"   0   s[   € ð )×.Ñ.Ó0ò Ñˆ�'Ø×"Ñ" 8Ô,Øà—-‘-ˆØ˜hÑ'×-Ñ-ˆØ�gÓÙðð r   c                ó~  ‡— g Š‰j                  t        d«      «       dˆfd„}dˆfd„}dˆfd„}dˆfd„}| D �]Ø  }|dk(  rŒ
|j                  «       D ��ci c]6  \  }}|j                  |k(  r"|j                  dk(  r|j                  «       s||“Œ8 }	}}t        |	«      dk(  rŒj‰j                  d	«        |d
|› d�«       ‰j                  d	«       |	j                  «       D �]-  }
|
j                  j                  d«      d   }t        |
j                  xs d	«      }t        |«      dz
  }t        |«      D ]r  \  }}|j                  «       j                  d«      }|r|d   j                  «       s|dd }|dk(  r|n|}|D ]  } ||j                  «       «       Œ ||k7  sŒk |d	«       Œt |
j                   ru‰d   dk7  r |d	«        |t#        j$                  dd¬«      «        |d	«       t        |
j&                  «      D ]
  } ||«       Œ  |d	«        |d|
j(                  › d�«       ddl}|j-                  d|
j.                  i«      }|dd j                  «       }t        |«      dkD  r‰d   dk7  r |d	«        |d|› �«       n	 |
j0                  t2        j4                  k7  }|r%‰d   dk7  r |d	«        |d|
j0                  › �«       |j-                  ||
j6                  i«      }t        |«      dk(  rd|› d�}n|sd|› �} ||«       �Œ0 �ŒÛ t#        j8                  dj;                  ‰«      «       yc c}}w )z8Print the given config sections/options to the terminal.zh
        # Below are all the sections and options you can have in
        ~/.streamlit/config.toml.
    c                óX   •— ‰j                  dt        j                  | d¬«      z   «       y )Nú# T)Úbold©Úappendr   Ústyle_for_cli©ÚtextÚouts    €r   Úappend_descz show_config.<locals>.append_descR   s!   ø€ Ø�
‰
�4œ(×0Ñ0°¸DÔAÑAÕBr   c                óT   •— ‰j                  dt        j                  | «      z   «       y )Nr%   r'   r*   s    €r   Úappend_commentz#show_config.<locals>.append_commentU   s   ø€ Ø�
‰
�4œ(×0Ñ0°Ó6Ñ6Õ7r   c                óT   •— ‰j                  t        j                  | dd¬«      «       y )NTÚgreen)r&   Úfgr'   r*   s    €r   Úappend_sectionz#show_config.<locals>.append_sectionX   s   ø€ Ø�
‰
”8×)Ñ)¨$°T¸gÔFÕGr   c                óR   •— ‰j                  t        j                  | d¬«      «       y )Nr1   ©r2   r'   r*   s    €r   Úappend_settingz#show_config.<locals>.append_setting[   s   ø€ Ø�
‰
”8×)Ñ)¨$°7Ô;Õ<r   Ú_testÚvisibler   Ú ú[ú]ú.éÿÿÿÿé   ú
Nú#zTHIS IS DEPRECATED.Úyellowr5   z(This option will be removed on or after Údefaulté
   z	Default: r%   zThe value below was set in z =
)r+   ÚstrÚreturnÚNone)r(   Ú_cleanr   ÚsectionÚ
visibilityÚ
is_expiredÚlenÚvaluesÚkeyÚsplitÚ_clean_paragraphsÚdescriptionÚ	enumerateÚrstripÚstripÚlstripÚ
deprecatedr   r)   Údeprecation_textÚexpiration_dateÚtomlÚdumpsÚdefault_valÚwhere_definedr	   ÚDEFAULT_DEFINITIONr   Úprint_to_cliÚjoin)Úsection_descriptionsÚconfig_optionsr-   r/   r3   r6   rH   ÚkÚvÚsection_optionsÚoptionrM   Údescription_paragraphsÚlast_paragraph_idxÚiÚ	paragraphÚlinesÚappend_funcÚlinerX   Útoml_defaultÚoption_is_manually_setÚtoml_settingr,   s                          @r   Úshow_configro   B   sm  ø€ ð €CØ‡J�JÜðó	
ôõCõ8õHõ=ð (ó ])ˆð �gÒØð '×,Ñ,Ó.÷
á��1Ø�y‰y˜GÒ#¨¯©¸	Ò(AÈ!Ï,É,Ì.ð ˆq‰Dð
ˆñ 
ô ˆÓ 1Ò$Øà�
‰
�2ŒÙ˜˜7˜) 1�~Ô&Ø�
‰
�2Œà%×,Ñ,Ó.ó H	)ˆFØ—*‘*×"Ñ" 3Ó'¨Ñ+ˆCÜ%6°v×7IÑ7IÒ7OÈRÓ%PÐ"ä!$Ð%;Ó!<¸qÑ!@Ðä )Ð*@Ó Aò '‘��9à!×(Ñ(Ó*×0Ñ0Øó�ñ
   q¡§¡Ô!1Ø! ! "˜I�Eð ./°!ªV™k¸�ð "ò /�DÙ §¡£Õ.ð/ð Ð*Ó*Ù" 2Õ&ð''ð* × Ò Ø�r‘7˜c’>Ù" 2Ô&ÙÜ×*Ñ*Ð+@ÀXÔNôñ ˜rÔ"Ü-¨f×.EÑ.EÓFò )�DÙ" 4Õ(ð)á˜rÔ"ÙØ>¸v×?UÑ?UÐ>VÐVWÐXôó àŸ:™: y°&×2DÑ2DÐ&EÓFˆLØ'¨¨Ð,×2Ñ2Ó4ˆLä�<Ó  1Ò$à�r‘7˜c’>Ù" 2Ô&Ù ¨<¨.Ð9Õ:ð ð ×$Ñ$¬×(GÑ(GÑGð #ñ &Ø�r‘7˜d’?Ù" 2Ô&ÙÐ!<¸V×=QÑ=QÐ<RÐSÔTàŸ:™: s¨F¯L©LÐ&9Ó:ˆLä�<Ó  AÒ%Ø!# C 5¨˜~‘Ù+Ø!# L >Ð2�á˜<Ö(òQH	)ð+])ô~ ×Ñ˜$Ÿ)™) C›.Õ)ùóq
s   Á;L9c                ó0   — t        j                  dd| «      S )z«Replace sequences of multiple spaces with a single space, excluding newlines.

    Preserves leading and trailing spaces, and does not modify spaces in between lines.
    z +ú )ÚreÚsub)Útxts    r   rG   rG   À   s   € ô
 �6‰6�$˜˜SÓ!Ð!r   c           	     óº   — | j                  d«      } | j                  d«      }|D �cg c])  }dj                  d„ |j                  d«      D «       «      ‘Œ+ c}S c c}w )zHSplit the text into paragraphs, preserve newlines within the paragraphs.r?   z

c              3  ó2   K  — | ]  }t        |«      –— Œ y ­w)N)rG   )Ú.0rk   s     r   ú	<genexpr>z$_clean_paragraphs.<locals>.<genexpr>Î   s   è ø€ ÒA 4”&˜—,ÑAùs   ‚)rS   rN   r^   )rt   Ú
paragraphsrh   s      r   rO   rO   È   sY   € ð �)‰)�D‹/€CØ—‘˜6Ó"€Jð $öàð 	�	‰	ÑA¨9¯?©?¸4Ó+@ÔAÕAòð ùò s   §.Ac                ól  — t        «       }t        | t        «      r£| st        d|› d�«      ‚t	        | «      D ]ƒ  \  }}t        |t
        «      s*t        d|› d|› dt        |«      j                  › d|› �«      ‚|j                  «       }|st        d|› d|› d�«      ‚t        |«      rŒp|j                  d|||«       Œ… yt        | t
        «      s't        d|› d	t        | «      j                  › d| › �«      ‚| j                  «       }|st        d|› d
�«      ‚t        |«      s|j                  d||«       yy)a‹  Validate theme color configuration option values.

    Validates that the value is a string (or list of strings, in the case of
    chartCategoricalColors and chartSequentialColors) and is not empty.

    Handles both single color strings (like primaryColor, backgroundColor)
    and arrays of color strings (like chartCategoricalColors, chartSequentialColors).

    Parameters
    ----------
    value : Any
        The color value to validate. Can be a string or list of strings.
    option_name : str
        The name of the theme option being validated (e.g., "theme.primaryColor").

    Raises
    ------
    StreamlitInvalidThemeOptionError
        If the value is not a string/list of strings, is empty, or contains
        empty values in the case of arrays.

    Notes
    -----
    Logs warnings for potentially invalid colors, since more comprehensive
    validation happens on the frontend.
    zTheme option 'z' cannot be an empty arrayr:   z]' must be a string, got ú: z]' cannot be emptyz^Theme option '%s[%s]' may be an invalid color: %s. Expected formats: hex, rgb, and rgba colorsNz,' must be a string or array of strings, got z' cannot be emptyzZTheme option '%s' may be an invalid color: %s. Expected formats: hex, rgb, and rgba colors)r   Ú
isinstanceÚlistr   rQ   rD   Útyper   rS   r
   Úwarning)r   Úoption_nameÚloggerrg   ÚcolorÚ	color_strÚ	value_strs          r   Ú_check_color_valuer…   Ö   s|  € ô6 ‹]€Fô �%œÔÙÜ2Ø   Ð-GÐHóð ô " %Ó(ò 	‰HˆAˆuÜ˜e¤SÔ)Ü6Ø$ [ M°°1°#Ð5NÌtÐTYË{×OcÑOcÐNdÐdfÐglÐfmÐnóð ð Ÿ™›ˆIÙÜ6Ø$ [ M°°1°#Ð5GÐHóð ô
 % YÕ/Ø—‘ðBàØØõð	ð, 	ô �eœSÔ!Ü.Ø˜[˜MÐ)UÔVZÐ[`ÓVa×VjÑVjÐUkÐkmÐnsÐmtÐuó
ð 	
ð —[‘[“]€IáÜ.Ø˜[˜MÐ):Ð;ó
ð 	
ô
 ˜YÔ'Ø�‰ð:àØõ		
ð (r   c              #  óš   K  — | j                  «       D ]4  \  }}|j                  d«      sŒ|j                  €Œ%||j                  f–— Œ6 y­w)zà
    Iterate through theme config options, yielding (option_path, value) pairs.
    Returns: theme.primaryColor, #ff0000, ...

    Leveraged by _extract_current_theme_config() to retrieve main config.toml theme options.
    útheme.Nr   )r`   r   r   s      r   Ú_iterate_theme_config_optionsrˆ   )  sK   è ø€ ð ,×1Ñ1Ó3ò *Ñˆ�'Ø×Ñ˜xÕ(¨W¯]©]Ñ-FØ˜GŸM™MÐ)Ó)ñ*ùs   ‚(A«A¸Ac                óN  — i }t        | «      D ]”  \  }}|j                  d«      }t        |«      dk(  r|\  }}|dk7  sŒ0|||<   Œ6t        |«      dk(  r|\  }}}||vri ||<   |||   |<   Œ\t        |«      dk(  sŒk|\  }}}}||vri ||<   |||   vri ||   |<   |||   |   |<   Œ– |S )zŒ
    Extract current theme configuration from config options.
    Returns a dictionary with the current theme options in nested format.
    r<   é   Úbaseé   é   )rˆ   rN   rK   )	r`   Úcurrent_theme_optionsr   Ú	opt_valueÚpartsÚ_rd   rH   Ú
subsections	            r   Ú_extract_current_theme_configr“   7  sý   € ð Ðä<¸^ÓLò KÑˆ�)Ø—‘˜sÓ#ˆÜˆu‹:˜Š?Ø‰IˆAˆvØ˜ÓØ09Ð% fÒ-Ü�‹Z˜1Š_Ø!&ÑˆAˆw˜ØÐ3Ñ3Ø13Ð% gÑ.Ø5>Ð! 'Ñ*¨6Ò2Ü�‹Z˜1‹_Ø-2Ñ*ˆAˆw˜
 FØÐ3Ñ3Ø13Ð% gÑ.ØÐ!6°wÑ!?Ñ?Ø=?Ð% gÑ.¨zÑ:ØAJÐ! 'Ñ*¨:Ñ6°vÒ>ð#Kð& !Ð r   c                óP  — t        «       }t        «       }| D ]Š  }|j                  d«      sŒ|j                  d«      }|d   dk(  r%t        |«      dk(  r|\  }}|j	                  |«       ŒS|d   dk(  sŒ\|d   dk(  sŒet        |«      dk(  sŒt|\  }}}|j	                  |«       ŒŒ ||fS )	ah  Get valid theme configuration options for main theme and theme sections.

    Extracts valid theme options from the config options template to ensure they
    stay in sync with the actual theme options defined via _create_theme_options() calls.

    Parameters
    ----------
    config_options_template : dict[str, ConfigOption]
        Template of all available configuration options.

    Returns
    -------
    tuple[set[str], set[str]]
        A tuple (main_theme_options, section_theme_options) where:
        - main_theme_options: Valid theme options for the main theme (without "theme." prefix)
        - section_theme_options: Valid theme options for sections/subsections
          (sidebar, light, dark, light.sidebar, dark.sidebar)

    Notes
    -----
    All non-main theme sections have the same valid options, so we only need to
    extract them once.
    r‡   r<   r   ÚthemerŠ   r>   ÚsidebarrŒ   )Úsetr   rN   rK   Úadd)Úconfig_options_templateÚmain_theme_optionsÚsection_theme_optionsÚ
option_keyr�   r‘   r€   s          r   Ú_get_valid_theme_optionsr�   V  s¼   € ô6 ›ÐÜ›EÐð .ò 7ˆ
Ø× Ñ  Õ*Ø×$Ñ$ SÓ)ˆEà�Q‰x˜7Ò"¤s¨5£z°Q¢Ø!&‘��;Ø"×&Ñ& {Õ3à�q‘˜WÓ$¨¨q©°YÓ)>Ä3ÀuÃ:ÐQRÃ?ð %*Ñ!��1�kØ%×)Ñ)¨+Õ6ð7ð Ð4Ð4Ð4r   c                óª   — |dk(  r|› d| › �}nd|› d| › �}dj                  d„ t        |«      D «       «      }t        «       j                  d||||«       y)z=Helper function to log a warning for an invalid theme option.r•   r<   r‡   r?   c              3  ó&   K  — | ]	  }d |› �–— Œ y­w)u     â€¢ N© )rw   Úopts     r   rx   z0_invalid_theme_option_warning.<locals>.<genexpr>•  s   è ø€ Ò"S°c V¨C¨5¤>Ñ"Sùs   ‚zNTheme file %s contains invalid theme option: '%s'.

Valid '%s' options are:
%sN)r^   Úsortedr   r   )r€   Úfile_path_or_urlÚvalid_optionsÚsection_nameÚfull_option_nameÚvalid_options_lists         r   Ú_invalid_theme_option_warningr¨   †  sm   € ð �wÒØ*˜^¨1¨[¨MÐ:Ñð $ L >°°;°-Ð@ÐàŸ™Ñ"S¼VÀMÓ=RÔ"SÓSÐÜƒM×Ñð	&àØØØõr   c           	     ól  — | j                  «       D ]¡  \  }}t        |t        «      r;|r|dk7  rt        d|› d|› �|«      ‚||vri ||<   t	        ||› d|› �||||   d«       ŒQ||vr!t        ||||«       |j                  |d«       Œv|||<   d|› d|› �}d|j                  «       v sŒ–t        ||«       Œ£ y)aß  Recursively validate a theme section and its subsection/options.

    Parameters
    ----------
    section_configs : dict[str, Any]
        The section configs to validate.
    section_path : str
        Path like 'sidebar', 'light', 'light.sidebar'.
    file_path_or_url : str
        Theme file path for error messages.
    section_options : set[str]
        Valid options for this section.
    filtered_parent : dict[str, Any]
        Parent section to populate/filter out invalid options.
    allow_sidebar_subsection : bool, optional
        Allow sidebar subsection (only "light" and "dark" sections), by default False.

    Raises
    ------
    StreamlitInvalidThemeSectionError
        If an invalid subsection is found.
    r–   r‡   r<   FNr‚   )	r   r|   Údictr   Ú!_validate_theme_section_recursiver¨   ÚpopÚlowerr…   )	Úsection_configsÚsection_pathr£   rc   Úfiltered_parentÚallow_sidebar_subsectionr€   Úoption_valuer¦   s	            r   r«   r«      s  € ð< &5×%:Ñ%:Ó%<ò $CÑ!ˆ�\Ü�l¤DÔ)á+¨{¸iÒ/GÜ7Ø˜\˜N¨!¨K¨=Ð9Ø$óð ð  /Ñ1Ø/1� Ñ,ä-ØØ�.  + Ð/Ø ØØ Ñ,Øõð  Ñ/ä)ØØ ØØô	ð ×Ñ ¨TÕ2ð ,8ˆO˜KÑ(Ø!'¨ ~°Q°{°mÐDÐØÐ*×0Ñ0Ó2Ò2Ü" <Ð1AÕBñI$Cr   c           	     óÞ  — t        |«      \  }}h d£}| j                  di «      }t        j                  | «      }|j                  di «      }|j	                  «       D ]Ž  \  }	}
t        |
t        «      r1|	|vrt        |	|«      ‚|	|vri ||	<   |	dv }t        |
|	||||	   |«       ŒG|	|vr t        |	||«       |j                  |	d«       Œkd|	› �}d|j                  «       v sŒƒt        |
|«       Œ� |S )a¦  
    Validate that a theme file contains only valid theme sections and config options.

    If invalid sections are found in the theme file, a StreamlitInvalidThemeSectionError is raised.

    If invalid config options are found in the theme file, a warning is logged with the valid
    options for the given section.

    Returns
    -------
        A filtered copy of the theme content with invalid options removed.
    >   ÚdarkÚlightr–   r•   >   r´   rµ   Nr‡   r‚   )r�   ÚgetÚcopyÚdeepcopyr   r|   rª   r   r«   r¨   r¬   r­   r…   )Útheme_contentr£   r™   Úvalid_main_optionsÚvalid_section_optionsÚvalid_sectionsÚtheme_sectionÚfiltered_themeÚfiltered_theme_sectionr€   r²   r±   r¦   s                r   Ú_validate_theme_file_contentrÀ   å  sB  € ô$ 1IØó1Ñ-ÐÐ-ò 2€Nà!×%Ñ% g¨rÓ2€Mô —]‘] =Ó1€NØ+×/Ñ/°¸Ó<Ðð &3×%8Ñ%8Ó%:ò (CÑ!ˆ�\ä�l¤DÔ)à .Ñ0Ü7ØØ$óð ð Ð"8Ñ8Ø68Ð& {Ñ3ð (3Ð6GÐ'GÐ$ä-ØØØ Ø%Ø& {Ñ3Ø(õð Ð 2Ñ2ä)ØØ Ø"ôð #×&Ñ& {°DÕ9ð "(¨ }Ð5ÐØÐ*×0Ñ0Ó2Ò2Ü" <Ð1AÕBðQ(CðT Ðr   c                ó   ‡ ‡— dd„}dˆ fd„}dˆ fd„}dˆˆ fd„}	 ddl }t        j                  ‰ «      }	 |rJt        j
                  j                  ‰ d¬«      5 }|j                  «       j                  d	«      Šddd«       n�t        j                  j                  ‰ «      s2t        j                  j                  t        j                  «       ‰ «      Š t        j                  j                  ‰ «      s |«        t        ‰ d	¬
«      5 }	|	j                  «       Šddd«       t!        ‰j#                  d	«      «      }
|
t$        kD  r |«        j'                  ‰«      }d|vr |«        t)        |‰ |«      }|S # t        $ r  |«        Y �Œgw xY w# 1 sw Y   ŒuxY w# 1 sw Y   Œ�xY w# t*        t,        t.        t0        f$ r ‚ t        j2                  j4                  $ r}t+        d‰ › d|› �«      |‚d}~wt6        $ r}t+        d‰ › d|› �«      |‚d}~ww xY w)zò
    Load and parse a theme TOML file from a local path or URL.

    Handles raising errors when a file cannot be found, read, parsed,
    or contains invalid theme options.

    Otherwise returns the parsed TOML content as a dictionary.
    c                 ó   — t        d«      ‚)Nz^The 'toml' package is required to load theme files. Please install it with 'pip install toml'.©r   r    r   r   Ú_raise_missing_tomlz-_load_theme_file.<locals>._raise_missing_toml=  s   € Ü(ð9ó
ð 	
r   c                 ó    •— t        d‰ › �«      ‚)NzTheme file not found: )ÚFileNotFoundError©r£   s   €r   Ú_raise_file_not_foundz/_load_theme_file.<locals>._raise_file_not_foundC  s   ø€ ÜÐ"8Ð9IÐ8JÐ KÓLÐLr   c                 ó"   •— t        d‰ › d�«      ‚)NúTheme file z must contain a [theme] section)r   rÇ   s   €r   Ú_raise_missing_theme_sectionz6_load_theme_file.<locals>._raise_missing_theme_sectionF  s   ø€ Ü/ØÐ*Ð+Ð+JÐKó
ð 	
r   c            	     ón   •— t        ‰j                  d«      «      } t        d‰› d| d›dt        d›d�«      ‚)Núutf-8rÊ   z is too large (ú,z! bytes). Maximum allowed size is zT bytes (1MB). Theme files should contain only configuration options, not large data.)rK   Úencoder   Ú_MAX_THEME_FILE_SIZE_BYTES)Úcontent_sizeÚcontentr£   s    €€r   Ú_raise_file_too_largez/_load_theme_file.<locals>._raise_file_too_largeK  sP   ø€ Ü˜7Ÿ>™>¨'Ó2Ó3ˆÜ(ØÐ*Ð+¨?¸<ÈÐ:Jð K'Ü'AÀ!Ð&Dð EUðVó
ð 	
r   r   Né   )ÚtimeoutrÍ   )Úencodingr•   z#Could not load theme file from URL r{   zError loading theme file ©rE   rF   )rX   ÚImportErrorr   Úis_urlÚurllibÚrequestÚurlopenÚreadÚdecodeÚosÚpathÚisabsr^   ÚgetcwdÚexistsÚopenrK   rÏ   rÐ   ÚloadsrÀ   r   r   r   rÆ   ÚerrorÚURLErrorÚ	Exception)r£   r™   rÄ   rÈ   rË   rÓ   rX   Úis_valid_urlÚresponseÚfrÑ   Úparsed_themer¾   ÚerÒ   s   `             @r   Ú_load_theme_filerî   1  sö  ù€ ó
õMõ
ö

ðÛô
 —?‘?Ð#3Ó4€Lð5Ùô —‘×'Ñ'Ð(8À"Ð'ÓEð :ÈØ"Ÿ-™-›/×0Ñ0°Ó9�÷:ð :ô
 —7‘7—=‘=Ð!1Ô2Ü#%§7¡7§<¡<´·	±	³Ð=MÓ#NÐ ä—7‘7—>‘>Ð"2Ô3Ù%Ô'äÐ&°Ô9ð #¸QØŸ&™&›(�÷#ô ˜7Ÿ>™>¨'Ó2Ó3ˆØÔ4Ò4Ù!Ô#ð —z‘z 'Ó*ˆð ˜,Ñ&Ù(Ô*ô 6ØÐ*Ð,Có
ˆð ÐøôU ò Ù×ðú÷:ð :ú÷#ð #ûô. 	#Ü(Ü)Üð	ò ð 	Ü�<‰<× Ñ ò Ü(Ø1Ð2BÐ1CÀ2ÀaÀSÐIó
àð	ûô ò Ü(Ø'Ð(8Ð'9¸¸A¸3Ð?ó
àð	ûðúsf   ›E3 µ#F" Á F
Á8BF" ÄFÄAF" Å3FÆFÆ
FÆF" ÆFÆF" Æ"6HÇG*Ç*HÇ6HÈHc                ó  — t        j                  | «      }|j                  «       D ]W  \  }}||v r6t        ||   t        «      r#t        |t        «      rt        ||   |«      ||<   Œ@t        j                  |«      ||<   ŒY |S )zœ
    Recursively merge two dictionaries, with override_dict values taking precedence.
    Handles arbitrary levels of nesting for theme configurations.
    )r·   r¸   r   r|   rª   Ú_deep_merge_theme_dicts)Ú	base_dictÚoverride_dictÚmergedrM   r   s        r   rð   rð   “  s{   € ô �]‰]˜9Ó%€Fà#×)Ñ)Ó+ò /‰
ˆˆUØ�&‰=œZ¨¨s©´TÔ:¼zÈ%ÔQUÔ?Vä1°&¸±+¸uÓEˆF�3ŠKô Ÿ-™-¨Ó.ˆF�3ŠKð/ð €Mr   c                ó   — t        | |«      S )z×
    Apply theme inheritance where theme config values from config.toml
    take precedence over the theme configs defined in theme.base toml file.

    Returns a dictionary with the merged theme configuration.
    )rð   )Ú
base_themeÚoverride_themes     r   Ú_apply_theme_inheritancer÷   §  s   € ô # :¨~Ó>Ð>r   c                ó²   — | j                  «       D ]D  \  }}|dk(  r|dk(  rŒ|r|› d|› �n|}t        |t        «      rt        ||||«       Œ; ||||«       ŒF y)zî
    Recursively set theme options from nested dictionary in process_theme_inheritance().
    This utility function traverses nested theme configuration sections/subsection
    and sets each option using the provided set_option_func.
    r‹   r•   r<   N)r   r|   rª   Ú_set_theme_options_recursive)Úoptions_dictÚprefixÚset_option_funcÚsourcer€   r²   Úcurrent_keys          r   rù   rù   ³  sp   € ð &2×%7Ñ%7Ó%9ò ?Ñ!ˆ�\Ø˜&Ò  V¨wÒ%6àá39˜˜  + Ñ/¸{ˆä�l¤DÔ)ä(Ø˜k¨?¸Fõñ
 ˜K¨°vÕ>ñ?r   c                ó  ‡— | €y| j                  d«      }|r|j                  €y|j                  Š‰dv rydˆfd„}	 t        ‰|«      }|j                  di «      j                  d«      }|r|dvr |«        | rt        | «      ni }t	        |d|i«      }i }	| �‘| j                  «       D ]H  \  }
}|
j                  d«      sŒ|
dk7  sŒ|j                  dv sŒ-|j                  |j                  d	œ|	|
<   ŒJ | D �
cg c]  }
|
j                  d«      r|
dk7  r|
‘Œ }}
|D ]  }
 ||
dd
«       Œ |j                  di «      j                  d«      }|r |d|d‰› �«       n |ddd‰› d�«       |j                  di «      }t        |d|d‰› �«       |	j                  «       D ]  \  }
} ||
|d   |d   «       Œ yc c}
w # t        t        t        t        f$ r ‚ t        $ r0}t        «       j                  d«       t        d‰› d|› �«      |‚d}~ww xY w)aG  
    Process theme inheritance if theme.base points to a theme file.

    This function checks if theme.base is set to a file path or URL,
    loads the theme file, and applies inheritance logic where the
    current config.toml values override the theme.base file values.

    Sets the merged theme options to the config.
    Nz
theme.base)rµ   r´   c                 ó"   •— t        d‰ › d�«      ‚)NrÊ   zy cannot reference another theme file in its base property. Only 'light' and 'dark' are allowed in referenced theme files.rÃ   )Ú
base_values   €r   Ú_raise_invalid_nested_basez=process_theme_inheritance.<locals>._raise_invalid_nested_baseë  s#   ø€ Ü(Ø˜*˜ð &Mð Nó
ð 	
r   r•   r‹   r‡   )zenvironment variablez-command-line argument or environment variable)r   r[   zreset for theme inheritanceztheme file: rµ   z
 (default)r   r[   z"Error processing theme inheritancez)Failed to process theme inheritance from r{   r×   )r¶   r   rî   r“   r÷   r   r   r[   rù   r   r   r   rÆ   rè   r   Ú	exception)r`   r™   rü   Úbase_optionr  Útheme_file_contentÚ
theme_baserŽ   Úmerged_themeÚhigh_precedence_theme_optionsr   Ú
opt_configÚtheme_options_to_removeÚtheme_file_baser½   Úopt_datarí   r  s                    @r   Úprocess_theme_inheritancer  Ï  sž  ø€ ð ÐØà ×$Ñ$ \Ó2€KÙ˜+×+Ñ+Ð3Øà×"Ñ"€Jð Ð&Ñ&Øõ
ðOä-¨jÐ:QÓRÐð (×+Ñ+¨G°RÓ8×<Ñ<¸VÓDˆ
Ù˜*Ð,=Ñ=Ù&Ô(ñ >LÔ)¨.Ô9ÐQSð 	ô
 0Ø Ð*?Ð @ó
ˆð
 )+Ð%ØÐ%Ø(6×(<Ñ(<Ó(>ò Ñ$�˜*à×'Ñ'¨Õ1Ø  LÓ0Ø"×0Ñ0ðòð ",×!1Ñ!1Ø)3×)AÑ)Añ?Ð1°(Ò;ðð$ !/ö'àØ×&Ñ& xÔ0°XÀÒ5Mò ð'Ð#ð 'ð
 4ò O�Ù ¨$Ð0MÕNðOð -×0Ñ0°¸"Ó=×AÑAÀ&ÓIˆÙÙ˜L¨/¸\È*ÈÐ;VÕWñ Ø˜g¨°j°\ÀÐ'Lôð
 %×(Ñ(¨°"Ó5ˆÜ$Ø˜7 O°|ÀJÀ<Ð5Pô	
ð
 #@×"EÑ"EÓ"Gò 	TÑˆH�hÙ˜H h¨wÑ&7¸À/Ñ9RÕSñ	Tùò3'øô: 	#Ü(Ü)Üð	ò ð 	Üò Ü‹×ÑÐ DÔEä(Ø7¸
°|À2ÀaÀSÐIó
àð	ûðús=   ½BF9 Ã F9 ÃF9 Ã"F9 Ã7F4ÄBF9 Æ4F9 Æ9"HÇ+HÈH)rE   r   )r   údict[str, ConfigOption]r   r  rE   Úbool)r_   zdict[str, str]r`   r  rE   rF   )rt   rD   rE   rD   )rt   rD   rE   z	list[str])r   r   r€   rD   rE   rF   )r`   r  rE   zIterator[tuple[str, Any]])r`   r  rE   údict[str, Any])r™   r  rE   ztuple[set[str], set[str]])r•   )
r€   rD   r£   rD   r¤   úset[str]r¥   rD   rE   rF   )F)r®   r  r¯   rD   r£   rD   rc   r  r°   r  r±   r  rE   rF   )r¹   r  r£   rD   r™   r  rE   r  )r£   rD   r™   r  rE   r  )rñ   r  rò   r  rE   r  )rõ   r  rö   r  rE   r  )
rú   r  rû   rD   rü   r   rý   rD   rE   rF   )r`   zdict[str, ConfigOption] | Noner™   r  rü   r   rE   rF   )*Ú
__future__r   r·   rß   rr   Úurllib.errorrÚ   Úurllib.requestÚtypingr   r   Úcollections.abcr   Ú	streamlitr   r   Ústreamlit.config_optionr	   Ú!streamlit.elements.lib.color_utilr
   Ústreamlit.errorsr   r   r   rÐ   r   r"   ro   rG   rO   r…   rˆ   r“   r�   r¨   r«   rÀ   rî   rð   r÷   rù   r  r    r   r   ú<module>r     sP  ðõ #ã Û 	Û 	Û Û ß %áÝ(ç (Ý 0Ý ?÷ñ ð )Ð ó ðØ(ðØ7Nðà	óð${*Ø(ð{*à+ð{*ð 
ó{*ó|"óóP
ðf*Ø+ð*àó*ð!Ø+ð!àó!ð>-5Ø4ð-5àó-5ðh  ð	Øðàðð ðð ð	ð
 
óð@ &+ðBCØ#ðBCàðBCð ðBCð ð	BCð
 $ðBCð #ðBCð 
óBCðJIØ!ðIàðIð 5ðIð ó	IðX_Øð_Ø4Kð_àó_ðDØðØ.<ðàóð(	?Øð	?Ø0>ð	?àó	?ð?Ø ð?Ø*-ð?Ø@Cð?ØMPð?à	ó?ð8qØ2ðqà4ðqð ðqð 
ô	qr   