o
    ,&]i[                     @  sV   d dl mZ d dlmZmZ er"d dlmZ d dlmZ d dl	m
Z
 G dd dZdS )	    )annotations)TYPE_CHECKINGAny)MutableMapping)Path)ComponentManifestc                   @  sB   e Zd ZdZdddZdddZdddZdddZdddZdS )ComponentManifestHandlerzEHandles component registration from parsed ComponentManifest objects.returnNonec                 C  s   i | _ i | _d S )N)	_metadata_asset_rootsself r   p/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/streamlit/components/v2/component_manifest_handler.py__init__   s   
z!ComponentManifestHandler.__init__manifestr   package_rootr   dict[str, dict[str, Any]]c           	      C  s`   |j }i }|jD ]%}|j }| d| }||}|dur"|| j|< d|i||< || j|< q|S )af  Process a manifest and return component definitions to register.

        Parameters
        ----------
        manifest : ComponentManifest
            The manifest to process
        package_root : Path
            The package root directory

        Returns
        -------
        dict[str, dict[str, Any]]
            Dictionary mapping component names to their definitions

        Raises
        ------
        StreamlitComponentRegistryError
            If a declared ``asset_dir`` does not exist, is not a directory, or
            resolves (after following symlinks) outside of ``package_root``.
        .Nname)r   
componentsresolve_asset_rootr   r   )	r   r   r   	base_namecomponent_definitionscomp_config	comp_namecomponent_name
asset_rootr   r   r   process_manifest#   s   


z)ComponentManifestHandler.process_manifestr   strComponentManifest | Nonec                 C     | j |S )aP  Get metadata for a specific component.

        Parameters
        ----------
        component_name : str
            Fully-qualified component name (e.g., ``"package.component"``).

        Returns
        -------
        ComponentManifest | None
            The manifest that declared this component, or ``None`` if unknown.
        )r   getr   r   r   r   r   get_metadataS      z%ComponentManifestHandler.get_metadataPath | Nonec                 C  r"   )a_  Get the absolute asset root directory for a component if declared.

        Parameters
        ----------
        component_name : str
            Fully-qualified component name (e.g. "package.component").

        Returns
        -------
        Path | None
            Absolute path to the component's asset root if present, otherwise None.
        )r   r#   r$   r   r   r   get_asset_rootb   r&   z'ComponentManifestHandler.get_asset_rootdict[str, Path]c                 C  s
   t | jS )zGet a mapping of component names to their asset root directories.

        Returns
        -------
        dict[str, Path]
            A shallow copy mapping fully-qualified component names to absolute
            asset root directories.
        )dictr   r   r   r   r   get_asset_watch_rootsq   s   
	z.ComponentManifestHandler.get_asset_watch_rootsN)r	   r
   )r   r   r   r   r	   r   )r   r    r	   r!   )r   r    r	   r'   )r	   r)   )	__name__
__module____qualname____doc__r   r   r%   r(   r+   r   r   r   r   r      s    


0
r   N)
__future__r   typingr   r   collections.abcr   pathlibr   (streamlit.components.v2.manifest_scannerr   r   r   r   r   r   <module>   s   