
    Fg|.                       S r SSKJr  SSKrSSKrSSKrSSKJrJr  SSK	J
r
  SSKJrJr  SSKJrJrJrJrJrJrJr  SSKJr  SS	KJr  SS
KJrJr  SSKJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&  SSK'J(r(  SSK)J*r*  SSK+J,r,   SSKJ-r-  \" S\/5      r0\" S\/5      r1 " S S\5      r2 " S S\5      r3 " S S5      r4\\\44   r5 " S S\5      r6 " S S\65      r7 " S S\5      r8 " S S\5      r9 " S  S!\5      r: " S" S#\5      r; " S$ S%\5      r< " S& S'\5      r= " S( S)\#5      r> " S* S+\=\5      r? " S, S-\=\#5      r@\\?\@4   rA " S. S/\5      rB\" 5        " S0 S1\?5      5       rC " S2 S3\@5      rD " S4 S55      rE " S6 S7\5      rF " S8 S9\5      rG " S: S;\5      rH " S< S=\5      rI " S> S?\5      rJ " S@ SA\?5      rK " SB SC\?5      rLg! \. a    \r- GNIf = f)DzPydantic data models and other dataclasses. This is the only file that uses Optional[]
typing syntax instead of | None syntax to work with pydantic    )annotationsN)ABCabstractmethod)Iterator)Enumauto)	AnnotatedAnyLiteralNewTypeOptional	TypedDictUnion)Request)document)is_file_obj_with_metatraverse)		BaseModel
ConfigDictFieldGetCoreSchemaHandlerGetJsonSchemaHandler	RootModelValidationErrorValidationInfomodel_validator)JsonSchemaValue)core_schema)NotRequired)	JsonValueDeveloperPathUserProvidedPathc                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg)	
CancelBody1   strsession_hashintfn_indexevent_id N__name__
__module____qualname____firstlineno____annotations____static_attributes__r+       d/Users/admin/workspace/ai/PDFMathTranslate/myenv/lib/python3.13/site-packages/gradio/data_classes.pyr$   r$   1   s    MMr3   r$   c                  .    \ rS rSr% S\S'   SrS\S'   Srg)SimplePredictBody7   	list[Any]dataNOptional[str]r'   r+   )r-   r.   r/   r0   r1   r'   r2   r+   r3   r4   r6   r6   7   s    
O"&L-&r3   r6   c                  T    \ rS rSr\      SS j5       r\      SS j5       rSrg)#_StarletteRequestPydanticAnnotation<   c                8    SS jn[         R                  " U5      $ )Nc                F    [        U [        5      (       a  U $ [        S5      e)Nz(Input must be a Starlette Request object)
isinstancer   
ValueError)values    r4   validate_requestZ_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__.<locals>.validate_requestC   s     %))GHHr3   )rB   r
   returnr   )r    no_info_plain_validator_function)cls_source_type_handlerrC   s       r4   __get_pydantic_core_schema__@_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__=   s    	I
 ;;<LMMr3   c                    SSS.$ )NobjectStarletteRequest)typetitler+   )rG   _core_schemahandlers      r4   __get_pydantic_json_schema__@_StarletteRequestPydanticAnnotation.__get_pydantic_json_schema__J   s     !+=>>r3   r+   N)rH   r
   rI   r   rE   core_schema.CoreSchema)rQ   rU   rR   r   rE   r   )r-   r.   r/   r0   classmethodrJ   rS   r2   r+   r3   r4   r<   r<   <   sa    
N
N '
N 
 	
N 
N ?1?<P?	? ?r3   r<   c                      \ rS rSr% SrS\S'   SrS\S'   S\S'   SrS\S	'   SrS
\S'   Sr	S
\S'   Sr
S\S'   SrS\S'   \S 5       rSrg)PredictBodyT   Nr:   r'   r*   r8   r9   zOptional[Any]
event_dataOptional[int]r)   
trigger_idFboolsimple_formatzOptional[bool]batchedc                J    SSSS0SS0SSS0S.SS0SS0SS0SS0SS0S	.S
/S.$ )NrX   rM   rO   stringarray)rO   itemsintegerboolean)r'   r*   r9   rZ   r)   r\   r^   r_   r9   )rP   rO   
propertiesrequiredr+   )rG   r   rR   s      r4   rS   (PredictBody.__get_pydantic_json_schema__`   se     #!' 2#X.!(FH3EF%x0#Y/%y1"()!4"I.	  
 	
r3   r+   )r-   r.   r/   r0   r'   r1   r*   rZ   r)   r\   r^   r_   rV   rS   r2   r+   r3   r4   rX   rX   T   sf    "&L-&"Hm"
O $J$"Hm" $J$M4 ^  
 
r3   rX   c                  (    \ rS rSr% SrSrS\S'   Srg)PredictBodyInternals   zOSeparate class to avoid exposing PydanticStarletteRequest in the API validationNz"Optional[PydanticStarletteRequest]requestr+   )r-   r.   r/   r0   __doc__rl   r1   r2   r+   r3   r4   rj   rj   s   s    U 	 / r3   rj   c                       \ rS rSr% S\S'   Srg)	ResetBody{   r&   r*   r+   Nr,   r+   r3   r4   ro   ro   {   s    Mr3   ro   c                  >    \ rS rSr% S\S'   S\S'   S\S'   S\S'   S	rg
)ComponentServerJSONBody   r&   r'   r(   component_idfn_namer
   r9   r+   Nr,   r+   r3   r4   rr   rr      s    L
Ir3   rr   c                  *    \ rS rSr% S\S'   S\S'   Srg)DataWithFiles   r
   r9   zlist[tuple[str, bytes]]filesr+   Nr,   r+   r3   r4   rw   rw      s    
I""r3   rw   c                  >    \ rS rSr% S\S'   S\S'   S\S'   S\S'   S	rg
)ComponentServerBlobBody   r&   r'   r(   rt   ru   rw   r9   r+   Nr,   r+   r3   r4   r{   r{      s    L
r3   r{   c                  L    \ rS rSr\" 5       r\" 5       r\" 5       r\" 5       rSr	g)InterfaceTypes   r+   N)
r-   r.   r/   r0   r   STANDARD
INPUT_ONLYOUTPUT_ONLYUNIFIEDr2   r+   r3   r4   r~   r~      s    vHJ&KfGr3   r~   c                  <    \ rS rSrSS jr\\SS j5       5       rSrg)GradioBaseModel   c                  ^ [        U [        [        45      (       d  [        S5      e[        R
                  " T5      mSU4S jjnU R                  R                  [        U R                  5       U[        R                  5      S9$ )Nz must be used in a Pydantic modelc           
        > [        S0 U D6nUR                  [        [        R                  " T[
        R                  " S5      -  5      5      5      R                  5       $ )N
   r+   )FileData_copy_to_dirr&   pathlibPathsecrets	token_hex
model_dump)objr9   dirs     r4   unique_copy0GradioBaseModel.copy_to_dir.<locals>.unique_copy   sI    ?c?D$$GLLw'8'8'<!<=>jlr3   )x)r   dict)r@   r   r   	TypeErrorr   r   	__class__	from_jsonr   r   r   is_file_data)selfr   r   s    ` r4   copy_to_dirGradioBaseModel.copy_to_dir   sp    $I 677>??ll3	 ~~''!%% ( 
 	
r3   c                    g Nr+   rG   r   s     r4   r   GradioBaseModel.from_json   s     	r3   r+   N)r   zstr | pathlib.PathrE   GradioDataModel)rE   r   )	r-   r.   r/   r0   r   rV   r   r   r2   r+   r3   r4   r   r      s#    
(   r3   r   c                  $    \ rS rSr% SrS\S'   Srg)JsonData   zHJSON data returned from a component that should not be modified further.r    rootr+   N)r-   r.   r/   r0   rm   r1   r2   r+   r3   r4   r   r      s
    R
Or3   r   c                  (    \ rS rSr\SS j5       rSrg)GradioModel   c                    U " S0 UD6$ )Nr+   r+   r   s     r4   r   GradioModel.from_json   s    xQxr3   r+   N)rE   r   r-   r.   r/   r0   rV   r   r2   r+   r3   r4   r   r      s     r3   r   c                  (    \ rS rSr\SS j5       rSrg)GradioRootModel   c                    U " US9$ )Nr   r+   r   s     r4   r   GradioRootModel.from_json   s    {r3   r+   N)rE   r   r   r+   r3   r4   r   r      s     r3   r   c                  \    \ rS rSr% S\S'   S\S'   S\S'   S\S'   S\S	'   S
\S'   S\S'   Srg)FileDataDict   r&   pathzNotRequired[Optional[str]]urlzNotRequired[Optional[int]]size	orig_name	mime_typer]   	is_streamzNotRequired[dict]metar+   Nr,   r+   r3   r4   r   r      s*    
I	##
$$))))O
r3   r   c                      \ rS rSr% SrS\S'   SrS\S'   SrS\S	'   SrS\S
'   Sr	S\S'   Sr
S\S'   SS0rS\S'   \" SS9\SS j5       5       r\SS j5       r\SS j5       rSS jr\SS j5       rSrg) r      a<  
The FileData class is a subclass of the GradioModel class that represents a file object within a Gradio interface. It is used to store file data and metadata when a file is uploaded.

Attributes:
    path: The server file path where the file is stored.
    url: The normalized server URL pointing to the file.
    size: The size of the file in bytes.
    orig_name: The original filename before upload.
    mime_type: The MIME type of the file.
    is_stream: Indicates whether the file is a stream.
    meta: Additional metadata used internally (should not be changed).
r&   r   Nr:   r   r[   r   r   r   Fr]   r   _typegradio.FileDatar   r   before)modec                    UR                   (       a;  UR                   R                  S5      (       a  [        U5      (       d  [        S5      eU$ )Nvalidate_metazlThe 'meta' field must be explicitly provided in the input data and be equal to {'_type': 'gradio.FileData'}.)contextgetr   rA   )rG   vinfos      r4   validate_modelFileData.validate_model   sB     LL  11)!,,~  r3   c                    [        S U R                  U R                  U R                  U R                  U R
                  4 5       5      $ )z
Checks if the FileData object is empty, i.e., all attributes are None.

Returns:
    bool: True if all attributes (except 'is_stream' and 'meta') are None, False otherwise.
c              3  *   #    U  H	  nUS L v   M     g 7fr   r+   ).0fs     r4   	<genexpr>#FileData.is_none.<locals>.<genexpr>   s      	
 Is   )allr   r   r   r   r   r   s    r4   is_noneFileData.is_none   sE      	
 					
 	
 		
r3   c                    U " US9$ )z
Creates a FileData object from a given file path.

Args:
    path: The file path.

Returns:
    FileData: An instance of FileData representing the file at the specified path.
)r   r+   )rG   r   s     r4   	from_pathFileData.from_path
  s     ~r3   c                   [         R                  " U5      R                  SS9  [        U 5      nU R                  (       d  [        S5      e[        R                  " U R                  U5      nX2S'   U R                  " S0 UD6$ )a  
Copies the file to a specified directory and returns a new FileData object representing the copied file.

Args:
    dir: The destination directory.

Returns:
    FileData: A new FileData object representing the copied file.

Raises:
    ValueError: If the source file path is not set.
T)exist_okzSource file path is not setr   r+   )	r   r   mkdirr   r   rA   shutilcopyr   )r   r   new_objnew_names       r4   r   FileData._copy_to_dir  sg     	S.t*yy:;;;;tyy#."~~(((r3   c                    [        U[        5      (       a   [        S0 UD6R                  (       + $ g! [        [
        4 a     gf = f)z
Checks if an object is a valid FileData instance.

Args:
    obj: The object to check.

Returns:
    bool: True if the object is a valid FileData instance, False otherwise.
Fr+   )r@   r   r   r   r   r   )rG   r   s     r4   r   FileData.is_file_data-  sI     c4  #?c?2222  / s   2 AAr+   )r   r   )rE   r]   )r   r&   rE   r   )r   r&   rE   r   )r   r
   rE   r]   )r-   r.   r/   r0   rm   r1   r   r   r   r   r   r   r   rV   r   propertyr   r   r   r   r2   r+   r3   r4   r   r      s     ICD-#I}##I}#It,-D$-(#	  $	 
 
$ 
 
),  r3   r   c                  0    \ rS rSr% S\S'   S rSS jrSrg)		ListFilesi@  zlist[FileData]r   c                     U R                   U   $ r   r   )r   indexs     r4   __getitem__ListFiles.__getitem__C  s    yyr3   c                ,    [        U R                  5      $ r   )iterr   r   s    r4   __iter__ListFiles.__iter__F  s    DIIr3   r+   N)rE   zIterator[FileData])r-   r.   r/   r0   r1   r   r   r2   r+   r3   r4   r   r   @  s    
 r3   r   c                  6    \ rS rSrSr/ rSS jr\S 5       rSr	g)_StaticFilesiJ  z+
Class to hold all static files for an app
c                    Xl         U Vs/ s H'  n[        R                  " U5      R                  5       PM)     snU l        g s  snf r   )pathsr   r   resolve	all_paths)r   r   ps      r4   __init___StaticFiles.__init__Q  s1    
=BCU',,q/113UCCs   .Ac                    / U l         g r   )r   )rG   s    r4   clear_StaticFiles.clearU  s	    r3   )r   r   N)r   zlist[str | pathlib.Path]rE   None)
r-   r.   r/   r0   rm   r   r   rV   r   r2   r+   r3   r4   r   r   J  s(     ID  r3   r   c                  >    \ rS rSr% S\S'   S\S'   S\S'   S\S'   Srg)	BodyCSSiZ  r&   body_background_fillbody_text_colorbody_background_fill_darkbody_text_color_darkr+   Nr,   r+   r3   r4   r   r   Z  s    ""r3   r   c                  *    \ rS rSr% S\S'   S\S'   Srg)Layoutia  r(   idzNotRequired[list[int | Layout]]childrenr+   Nr,   r+   r3   r4   r  r  a  s    G--r3   r  c                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg)	Pageif  z	list[int]
componentsdependenciesr  layoutr+   Nr,   r+   r3   r4   r  r  f  s    Nr3   r  c                  `   \ rS rSr% S\S'   S\S'   S\S'   S\S'   S\S	'   S
\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S '   S\S!'   S\S"'   S#\S$'   S%\S&'   S'\S('   S'\S)'   S\S*'   S+\S,'   S-\S.'   S/\S0'   S1\S2'   S3rg4)5BlocksConfigDictil  r&   versionr   r(   app_idr]   dev_modeanalytics_enabledzlist[dict[str, Any]]r  z
str | Nonecssconnect_heartbeatjsheadrP   space_idenable_queue
show_errorshow_apiis_colabz
int | Nonemax_file_sizez	list[str]stylesheetsthemez>Literal['ws', 'sse', 'sse_v1', 'sse_v2', 'sse_v2.1', 'sse_v3']protocolr   body_cssfill_height
fill_width
theme_hashzNotRequired[Layout]r  z!NotRequired[list[dict[str, Any]]]r  zNotRequired[str | None]r   username
api_prefixzNotRequired[bool]pwazdict[str, Page]pagezlist[tuple[str, str]]pagesNotRequired[str]current_pager+   Nr,   r+   r3   r4   r
  r
  l  s    L
IKN$$	ON
JNNLLO33
!!%%O	
  ""r3   r
  c                  >    \ rS rSr% S\S'   S\S'   S\S'   S\S	'   S
rg)MediaStreamChunki  bytesr9   floatdurationr&   	extensionr%  r  r+   Nr,   r+   r3   r4   r(  r(    s    
KONr3   r(  c                      \ rS rSr% \" SSS9rS\S'   \" SSS9rS\S'   \" SS	S9rS
\S'   \" SSS9r	S\S'   \" SSS9r
S\S'   \" SSS9rS\S'   SS0rS\S'   \" SS0S9rSrg)	ImageDatai  NzPath to a local file)defaultdescriptionr:   r   z.Publicly available url or base64 encoded imager   zSize of image in bytesr[   r   zOriginal filenamer   zmime type of imager   FzCan always be set to Falser]   r   r   r   r   r   r0  zTFor input, either path or url must be provided. For output, path is always provided.)json_schema_extrar+   )r-   r.   r/   r0   r   r   r1   r   r   r   r   r   r   r   model_configr2   r+   r3   r4   r.  r.    s    :PQD-Q"RC   :RSD-S$T?RSI}S$T?STI}TE7STItT,-D$-q
Lr3   r.  c                  ,    \ rS rSr% \" SS9rS\S'   Srg)Base64ImageDatai  zbase64 encoded image)r0  r&   r   r+   N)r-   r.   r/   r0   r   r   r1   r2   r+   r3   r4   r4  r4    s    !78C8r3   r4  )Mrm   
__future__r   r   r   r   abcr   r   collections.abcr   enumr   r   typingr	   r
   r   r   r   r   r   fastapir   gradio_client.documentationr   gradio_client.utilsr   r   pydanticr   r   r   r   r   r   r   r   r   pydantic.json_schemar   pydantic_corer   typing_extensionsr   r    ImportErrorr&   r!   r"   r$   r6   r<   PydanticStarletteRequestrX   rj   ro   rr   rw   r{   r~   r   r   r   r   r   r   r   r   r   r   r  r  r
  r(  r.  r4  r+   r3   r4   <module>rC     s  @ #    # $     0 ?
 
 
 1 % )" --s3  '	 '
? ?* %W.Q%QR 
) 
>+ 	 i #I #
i T c 6y /9 oy  _459  
i{ i iX   i .Y .
9 !#y !#Hy  $9k 9  Is   :F> >G
	G
