
    [i                    >   U d dl mZ d dlZd dlmZmZ d dlmZmZm	Z	 erd dl
mZ d dlmZ d dlmZ  G d d	      Zed
   ed   z  ee   z  Zded<   ddZddZ	 dddd	 	 	 	 	 	 	 	 	 	 	 ddZ	 ddd	 	 	 	 	 	 	 	 	 ddZ	 dddd	 	 	 	 	 	 	 	 	 	 	 ddZddZddZy)     )annotationsN)TYPE_CHECKING	TypeAlias)cli_utilconfigenv_util)CallableEventBasedPathWatcherPollingPathWatcherc                  .    e Zd Zddd	 	 	 	 	 	 	 	 	 ddZy)NoOpPathWatcherNFglob_patternallow_nonexistentc                    y N )self	_path_str_on_changedr   r   s        o/var/www/html/userprofiledev.eatanceapp.com/venv/lib/python3.12/site-packages/streamlit/watcher/path_watcher.py__init__zNoOpPathWatcher.__init__&   s     	    )
r   strr   Callable[[str], None]r   
str | Noner   boolreturnNone)__name__
__module____qualname__r   r   r   r   r   r   %   s?     $("' +
 !   
r   r   r   r   r   PathWatcherTypec                 ,    	 ddl } y# t        $ r Y yw xY w)z*Check if the watchdog module is installed.r   NTF)watchdogImportError)r'   s    r   _is_watchdog_availabler)   9   s     s    	c                     t        j                  d      dvrPt               sEt        j                  rdnd} t        j                  ddd       t        j                  |  d	       y y y )
Nserver.fileWatcherType>   nonepollz
  $ xcode-select --install z6  For better performance, install the Watchdog module:blueT)fgboldz&
  $ pip install watchdog
            )r   
get_optionr)   r   	IS_DARWINr   print_to_cli)msgs    r   report_watchdog_availabilityr6   C   sn    23;KK&(080B0B,D	

 	  	
 ) 	Lr   Fr   c               r    |t        j                  d      }t        |      }|t        u ry || |||       y)a&  Create a PathWatcher for the given path if we have a viable
    PathWatcher class.

    Parameters
    ----------
    path
        Path to watch.
    on_path_changed
        Function that's called when the path changes.
    watcher_type
        Optional watcher_type string. If None, it will default to the
        'server.fileWatcherType` config option.
    glob_pattern
        Optional glob pattern to use when watching a directory. If set, only
        files matching the pattern will be counted as being created/deleted
        within the watched directory.
    allow_nonexistent
        If True, allow the file or directory at the given path to be
        nonexistent.

    Returns
    -------
    bool
        True if the path is being watched, or False if we have no
        PathWatcher class.
    r+   Fr   T)r   r2   get_path_watcher_classr   )pathon_path_changedwatcher_typer   r   watcher_classs         r   _watch_pathr=   V   sJ    D (()AB*<8M'!+	 r   r   c                    t        | |||      S )ae  Watch a file for changes.

    The callback is invoked when the file's content changes (detected via MD5).
    If allow_nonexistent is True, the watcher will also detect when the file
    is created.

    Parameters
    ----------
    path
        Path to the file to watch.
    on_file_changed
        Callback invoked with the file path when changes are detected.
    watcher_type
        Optional watcher type ('watchdog', 'poll', 'auto', or 'none').
    allow_nonexistent
        If True, watch for file creation even if the file doesn't exist yet.
        Note: The file's parent directory must exist for watching to work.
        If the parent directory doesn't exist, the watcher silently skips
        watching (the file can't be created without its parent directory).

    Returns
    -------
    bool
        True if the watcher was successfully created.
    r>   )r=   )r9   on_file_changedr;   r   s       r   
watch_filerA      s    @ o|?P r   c               b    t         j                  j                  | d      } t        | ||||      S )a{  Watch a directory for file changes.

    The callback is invoked for any file activity within the directory,
    including file creation, deletion, and content modifications. The callback
    receives the path of the actual changed file (not the directory path).

    Note: The glob_pattern parameter only affects the initial state detection
    (which files are counted when determining if the directory changed). It does
    NOT filter which file events trigger the callback - all file events in the
    directory will invoke the callback regardless of glob_pattern.

    Parameters
    ----------
    path
        Path to the directory to watch.
    on_dir_changed
        Callback invoked with the changed file path when changes are detected.
    watcher_type
        Optional watcher type ('watchdog', 'poll', 'auto', or 'none').
    glob_pattern
        Glob pattern for initial state detection (e.g., "*.py"). Does not
        filter runtime events.
    allow_nonexistent
        If True, watch for directory creation even if it doesn't exist yet.

    Returns
    -------
    bool
        True if the watcher was successfully created.
    r.   r   )osr9   joinr=   )r9   on_dir_changedr;   r   r   s        r   	watch_dirrF      s5    P 77<<b!D!+ r   c                 >    t        t        j                  d            S )zsReturn the class to use for path changes notifications, based on the
    server.fileWatcherType config option.
    r+   )r8   r   r2   r   r   r   get_default_path_watcher_classrH      s     "&"3"34L"MNNr   c                R    | dv rt               rddlm} |S | dv rddlm} |S t
        S )zReturn the PathWatcher class that corresponds to the given watcher_type
    string. Acceptable values are 'auto', 'watchdog', 'poll' and 'none'.
    >   autor'   r   r
   >   rJ   r-   r   )r)   *streamlit.watcher.event_based_path_watcherr   &streamlit.watcher.polling_path_watcherr   r   )r;   r   r   s      r   r8   r8      s4     ++0F0HT$$''M!!r   )r    r   )r    r!   r   )r9   r   r:   r   r;   r   r   r   r   r   r    r   )
r9   r   r@   r   r;   r   r   r   r    r   )r9   r   rE   r   r;   r   r   r   r   r   r    r   )r    r%   )r;   r   r    r%   )
__future__r   rC   typingr   r   	streamlitr   r   r   collections.abcr	   rK   r   rL   r   r   typer%   __annotations__r)   r6   r=   rA   rF   rH   r8   r   r   r   <module>rS      sP   # 	 + 0 0(PI	 	  		 !D)=$>>oAVV  

,  $/
  $#/
/*/ /
 / / 
/j  $"
 $"
"*" "
 " 
"P  $0
  $#0
0)0 0
 0 0 
0fOr   