
    Pi                        d dl mZ d dlZd dlZd dlmZ d dlmZ d dlZd dl	m
Z
 d dlZd dlmZ d dlmZ  eej                  j        dz  d	z  Z ed
          dz   ed          dddfddZdS )    )annotationsN)Path)	Annotated)print)custom_component_analytics)_get_executable_path	templatesfrontenddemozapp.py.	localhostappxAnnotated[Path, typer.Argument(help='The path to the app. By default, looks for demo/app.py in the current directory.')]component_directoryAnnotated[Path, typer.Option(help='The directory with the custom component source code. By default, uses the current directory.')]hostdAnnotated[str, typer.Option(help='The host to run the front end server on. Defaults to localhost.')]python_pathAnnotated[str | None, typer.Option(help='Path to python executable. If None, will use the default path found by `which python3`. If python3 is not found, `which python` will be tried. If both fail an error will be raised.')]gradio_pathAnnotated[str | None, typer.Option(help='Path to gradio executable. If None, will use the default path found by `shutil.which`.')]c                   t          dd d d d ||           |                                }t          d|  d           t          j        d          }|st          d          t          d|dd	
          }t          d|d          }t          j        |ddgt          |dz            dd	          }|j
        dk    rt          d          |j                            d                                          }t          j        ||d|dt          dt!          |           ddd|d|d|gt          j        t          j                  }	 |                                 |j                                        }d }	|j        r|j                                        }	|                    d                              dd                              dd                              d d!          }d|v r+|d"t!          |dz                                             d#z  }d$|v rt          |           |	r"t          |	                    d                     |j
        t          d%           d S !)&Ndev)r   r   z:recycle: [green]Launching[/] z in reload mode
nodez0node must be installed in order to run dev mode.pythonz--python-pathT)cli_arg_namecheck_3gradioz--gradio-path)r   z-ez/console.log(require.resolve('@gradio/preview'))r
   F)cwdcheckcapture_outputr   zYCould not find `@gradio/preview`. Run `npm i -D @gradio/preview` in your frontend folder.zutf-8z--component-directoryz--rootz--appz--modez--host)stdoutstderrzChanges detected in:z [orange3]Changed detected in:[/]z	Watching:z[orange3]Watching:[/]zRunning on local URLz[orange3]Backend Server[/]'z',zTo create a public linkz)Backend server failed to launch. Exiting.)r   resolver   shutilwhich
ValueErrorr   
subprocessrunr   
returncoder"   decodestripPopengradio_template_pathstrPIPESTDOUTpollreadliner#   replace)
r   r   r   r   r   r   gradio_node_pathproctexterrs
             v/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/gradio/cli/commands/components/dev.py_devr;      s   @     .5577	
A3
A
A
ABBB<D MKLLL&+OT  K '+O  K "~	tFG$z122	   "a''g
 
 	
 (.55g>>DDFF# HH!	
$  )  D,		{##%%; 	)+&&((C KK  W+-OPPW["9::W+-IJJ	 	 #d**I/*<==CCEEIIIID$,,d 	'#**W%%&&&?&=>>>F1    )
r   r   r   r   r   r   r   r   r   r   )
__future__r   r&   r)   pathlibr   typingr   typerrichr   r   gradio.analyticsr   0gradio.cli.commands.components.install_componentr   __file__parentr/   r;    r<   r:   <module>rG      s   " " " " " "                          7 7 7 7 7 7 Q Q Q Q Q QtFO,,3kAJN  	Vx 	S		 	 	 	=t t t t t t tr<   