
    $g@                         d dl Z d dlZd dl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
mZ  e	d      Z ej                  d       Zdd ej                  d      iiZ G d d	      Z G d
 de j$                        Zd Zd Z G d de      Zd Zy)    N   )patch_collections_abcstringify_id
OrderedSetMutableSequencedash_core_componentsLogoutButtonz
        The Logout Button is no longer used with Dash Enterprise and can be replaced with a html.Button or html.A.
        eg: html.A(href=os.getenv('DASH_LOGOUT_URL'))
    c                   X    e Zd ZdZ e       Z ej                  e      Z	i Z
edd       Zy)ComponentRegistryz6Holds a registry of the namespaces used by components.Nc                     g }| j                   D ]8  }|||vr
t        j                  |   }|j                  t	        ||g              : |S N)registrysysmodulesextendgetattr)clsresource_nameincludes	resourcesmodule_namemodules         \/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/dash/development/base_component.pyget_resourceszComponentRegistry.get_resources$   sY    	<< 	AK#8(C[[-FWV]B?@		A     r   )__name__
__module____qualname____doc__r   r   collectionsdefaultdictdictchildren_propsnamespace_to_packageclassmethodr    r   r   r   r      s6    @|H,[,,T2N	 	r   r   c                       e Zd Zd Zy)ComponentMetac                 b   t         j                  j                  | |||      }|d   j                  d      d   }|dk(  s|dk(  r|S |j	                  d|      }|t
        j                  |<   t
        j                  j                  |       |j	                  d      t
        j                  |   |<   |S )Nr   .r   	Componentbuiltins
_namespace_children_props)
abcABCMeta__new__splitgetr   r$   r   addr#   )mcsnamebases
attributes	componentr   r-   s          r   r1   zComponentMeta.__new__4   s    KK''T5*E	L)//4Q7;&J"6 ^^L&9
=C..z:""&&v.=G^^>
((4T: r   N)r   r   r   r1   r&   r   r   r(   r(   1   s    r   r(   c                 :    	 t        |        y# t        $ r Y yw xY w)NTF)float
ValueError)ss    r   	is_numberr>   G   s#    a s    	c                     t        | d      r:t        | j                  t              s't        | j                  t        t
        f      st        y y )Nchildren)hasattr
isinstancer@   r+   tupler   KeyError)items    r    _check_if_has_indexable_childrenrF   O   s?    4$t}}i04==5/*BC  D 1r   c                       e Zd Zg ZdgZ G d d      Z e       Z G d d      Z e       Zd Z	d Z
d Zdd
Zd Zd Zd Zd Zed        Zd Zd Zd Zd Zd Zd Zy	)r+   r@   c                       e Zd Zd Zd Zy)Component._UNDEFINEDc                      yN	undefinedr&   selfs    r   __repr__zComponent._UNDEFINED.__repr__]       r   c                      yrK   r&   rM   s    r   __str__zComponent._UNDEFINED.__str__`   rP   r   Nr   r   r   rO   rR   r&   r   r   
_UNDEFINEDrI   \   s    		r   rT   c                       e Zd Zd Zd Zy)Component._REQUIREDc                      yNrequiredr&   rM   s    r   rO   zComponent._REQUIRED.__repr__f       r   c                      yrX   r&   rM   s    r   rR   zComponent._REQUIRED.__str__i   rZ   r   NrS   r&   r   r   	_REQUIREDrV   e   s    		r   r\   c           
         | j                          dd l}t        |j                               D ]  \  }| j                  v }t        fd| j                  D              }d|v r	d|d    dnd}	 d}dd	d
d}| j                  |v r6|j                  || j                     | j                  |j                  |      }nF|j                  | j                  | j                  t        t        | j                        dd      |      }|s9|s7dj                  t        | j                              }	t!        | d d|	       | j"                  vr.t%        |t&              rt!        |dz   d d|dz   dz   dz         dk(  rt%        |t(              rq|j                         D ]]  \  }
}t%        |
t*              st!        dd|
d|z         t%        |t*        t,        t.        t0        f      rKt!        dd|d|z          nt%        |t*              st!        d|      t3        | |        y # t        $ r d| j                   d| }Y Jw xY w)Nr   c              3   @   K   | ]  }j                  |        y wr   
startswith.0wks     r   	<genexpr>z%Component.__init__.<locals>.<genexpr>v   s      !$%Q!   idz with the ID "" z$The `{}.{}` component (version {}){}htmldcc
dash_table)dash_html_componentsr   rl   __version__unknownzThe `z` component, z+ received an unexpected keyword argument: `z`
Allowed arguments: z7 detected a Component for a prop other than `children`
zProp z has value z

z8Did you forget to wrap multiple `children` in an array?
zNFor example, it must be html.Div(["a", "b", "c"]) not html.Div("a", "b", "c")
zdict id keys must be strings,
zfound z in id z2dict id values must be strings, numbers or bools,
z(`id` prop must be a string or dict, not )_validate_deprecationdashlistitems_prop_namesany_valid_wildcard_attributesr-   format_typern   r   
__import__ImportErrorjoinsorted	TypeError_base_nodesrB   r+   r"   strintr;   boolsetattr)rN   kwargsrr   vk_in_propnamesk_in_wildcards	id_suffixerror_string_prefixdash_packagesallowed_argsid_keyid_valrd   s               @r   __init__zComponent.__init__n   s   ""$ ( H	 DAq$"2"22N  !)-)H)H! N
 =AFN.a8PRIQ&L# -3,1".!
 ??m3*=*D*D%doo6

((!	+' +>*D*D


4?? ;]IV!	+' ".#yy4++,   *++VWXVY Z,,8>; 
 (((Z9-E'PQaSA556 RR h	h  Dya&*+'') 
)&#6"+ A$*6*GA5"A!B#   *&3UD2IJ"+ U$*6*GA5"A!B# 
 $As+#&Nqe$TUUD!QQH	 B  Q ).djj\YK&P#Qs   2BH00IIc           	      p   t        | d      rt        | d      S d| j                   d| j                   d}t        | dd      rt	        d| d      dt
        j                  v rt	        d	| d      t        t        j                  t        j                  d
ddz                    }t        | d|       |S )Nrg   `r*   persistenceFa  
                Attempting to use an auto-generated ID with the `persistence` prop.
                This is prohibited because persistence is tied to component IDs and
                auto-generated IDs can easily change.

                Please assign an explicit ID to this z component.
                dash_snapshotsa  
                Attempting to use an auto-generated ID in an app with `dash_snapshots`.
                This is prohibited because snapshots saves the whole app layout,
                including component IDs, and auto-generated IDs can easily change.
                Callbacks referencing the new IDs will not work with old snapshots.

                Please assign an explicit ID to this r   r      )r   )rA   r   r-   ry   RuntimeErrorr   r   r   uuidUUIDrdrandintr   )rN   kindr   s      r   _set_random_idzComponent._set_random_id   s    44&&4??#1TZZL24.6
 7;V <  s{{*6 7;V <	 	 		bjjAsF345dAr   c           
      V   | j                   D ci c]  }t        | |      r|t        | |       }}|j                  | j                  D ci c]-  t        fd| j                  D              rt        |       / c}       || j                  | j                  d}|S c c}w c c}w )Nc              3   @   K   | ]  }j                  |        y wr   r_   ra   s     r   re   z+Component.to_plotly_json.<locals>.<genexpr>   s#        LLOrf   )propstype	namespace)	ru   rA   r   update__dict__rv   rw   ry   r-   )rN   pr   rd   as_jsons      ` r   to_plotly_jsonzComponent.to_plotly_json   s     %%
tQ wtQ
 
 	   "<<  74##
	
 JJ
 /
s    B!2B&Nc                    t        |        t        | j                  t              rt	        | j                  dd       D| j                  j
                  |k(  r+|dk(  r| j                  S |dk(  r|| _        y |dk(  rd | _        y 	 |dk(  r| j                  j                  |      S |dk(  r| j                  j                  ||       y |dk(  r| j                  j                  |       y 	 t        | j                  t        t        f      rt        | j                        D ]  \  }}t	        |dd       |k(  r4|dk(  r|c S |dk(  r|| j                  |<    y |dk(  s;| j                  |=  y t        |t              s[	 |dk(  r|j                  |      c S |dk(  r|j                  ||        y |dk(  r|j                  |        y  t        |      # t        $ r Y w xY w# t        $ r Y w xY w)Nrg   r3   setdelete)rF   rB   r@   r+   r   rg   __getitem____setitem____delitem__rD   rC   r   	enumerate)rN   rg   	operationnew_itemirE   s         r   _get_set_or_deletezComponent._get_set_or_delete   s   (. dmmY/t}}dD1===##r) E)#}}, E)(0 H,(,
%==44R88%MM--b(;(MM--b1 ) dmme_%=>$T]]3 44t,2 E)# E)+3a( H, MM!,  i0
$-#'#3#3B#77$- ,,R:"$0 ,,R0" 1+: rlE  : $ s<   G "!G  G 7GG(G	GG	G('G(c                 &    | j                  |d      S )zTRecursively find the element with the given ID through the tree of
        children.r3   r   rN   rg   s     r   r   zComponent.__getitem__B  s     &&r511r   c                 (    | j                  |d|      S )zSet an element by its ID.r   r   )rN   rg   rE   s      r   r   zComponent.__setitem__J  s    &&r5$77r   c                 &    | j                  |d      S )z+Delete items by ID in the tree of children.r   r   r   s     r   r   zComponent.__delitem__N  s    &&r844r   c              #   D   K   | j                         D ]	  }|d     yw)zYield each item in the tree.   N)_traverse_with_pathsrN   ts     r   	_traversezComponent._traverseR  s'     **, 	AA$J	s    c                 D    t        t        | dd            }|xr d|ddS )Nrg   ri   z (id=r=   ))r   r   )r9   id_s     r   _id_strzComponent._id_strW  s+    79dB78's1gQ''r   c              #   L  K   t        | dd      }t        |      j                  }|| j                  |      z   }t	        |t
              r<d|z   |f |j                         D ]  \  }}dj                  d|z   |g      |f ! yt	        |t        t        f      rt        |      D ]y  \  }}d|ddt        |      j                  d| j                  |       }||f t	        |t
              sK|j                         D ]  \  }}dj                  ||g      |f  { yyw)	z*Yield each item with its path in the tree.r@   Nz[*] 
[dz] r=   )r   r   r   r   rB   r+   r   r|   rC   r   r   )	rN   r@   children_typechildren_stringr   r   idxr   	list_paths	            r   r   zComponent._traverse_with_paths\  s2    4T2X//'$,,x*@@ h	*?*H44 557 B1ii/!91 =>AAB 5/":;#H- ;QAwba)9)9!(<T\\!_<MN	l"a+ ! 6 6 8 ;1"iiA7::;; <s   C.D$13D$c              #   |   K   | j                         D ]%  }t        |t              st        |dd      "| ' yw)z2Yield components with IDs in the tree of children.rg   N)r   rB   r+   r   r   s     r   _traverse_idszComponent._traverse_idst  s9     ! 	A!Y'GAtT,B,N	s   $<<<c              #   R   K   | j                         D ]  }|j                    yw)z"Yield IDs in the tree of children.N)r   rg   r   s     r   __iter__zComponent.__iter__z  s'     ##% 	A$$J	s   %'c                 J   d}t        | dd      d}|S t        | j                  t              rd}|t	        | j                        z  }|S t        | j                  t
        t        f      r7| j                  D ]&  }|dz  }t        |t              s|t	        |      z  }( |S d}|S )z'Return the number of items in the tree.r   r@   Nr   )r   rB   r@   r+   lenrC   r   )rN   lengthcs      r   __len__zComponent.__len__  s     4T*2F  y1Fc$--((F  '?@]] %!a+c!f$F%  Fr   c                      j                   D cg c]  }t         |d       | c} j                  D cg c]"  t        fd j                  D              r$ c}z   }t        d |D              rdj                   fd|D              }nt        t         dd             } j                   d| dS c c}w c c}w )Nc              3   @   K   | ]  }j                  |        y wr   r_   )rb   wc_attrr   s     r   re   z%Component.__repr__.<locals>.<genexpr>  s     XW1<<(Xrf   c              3   &   K   | ]	  }|d k7    yw)r@   Nr&   )rb   r   s     r   re   z%Component.__repr__.<locals>.<genexpr>  s     :1qJ:s   rp   c              3   @   K   | ]  }| d t        |        yw)=N)r   )rb   r   rN   s     r   re   z%Component.__repr__.<locals>.<genexpr>  s)      %011#QwtQ'*+%rf   r@   (r   )ru   r   r   rv   rw   r|   reprry   )rN   r   props_with_valuesprops_strings   ``  r   rO   zComponent.__repr__  s     ''
74D+A+MA
 ]]
X8W8WXX 

 :(9::99 %5F% L  j$ ?@L**Q|nA..

s   B:B:'B?c                     t        | dd      }t        | dd      }t        j                  |i       j                  |      }|r2t        j                  t        t        j                  |                   y y )Nry   ri   r-   )r   _deprecated_componentsr3   warningswarnDeprecationWarningtextwrapdedent)rN   ry   _nsdeprecation_messages       r   rq   zComponent._validate_deprecation  s`    gr*dL"-488bAEEeLMM,X__=P-QRS r   r   )r   r   r   r.   r   rT   	UNDEFINEDr\   REQUIREDr   r   r   r   r   r   r   r   staticmethodr   r   r   r   r   rO   rq   r&   r   r   r+   r+   X   s    O,K  I  {HM ^B:>N285
 ( (;0
,/"Tr   r+   )	metaclassc                 V    t         d      r j                  j                  n j                  j                   fd}t        t        d      rWt	        j
                  |      j                  t	        j
                         j                  j                               }||_	        |S )N	func_codec                     d|v rt        d      t        t        t        d t        |              |j	                         D cg c]  \  }}|	 c}}z               |d<   d|d   v r|d   j                  d        | i |S c c}}w )N_explicit_argsz*Variable _explicit_args should not be set.rN   )	Exceptionrs   r   r   rt   remove)argsr   rd   _funcvarnamess       r   wrapperz"_explicitize_args.<locals>.wrapper  s    v%HII#'XkD	*+V\\^.LTQq.LLM$
  V,--#$++F3T$V$$	 /Ms   B	signature)
parameters)
rA   r   co_varnames__code__inspectr   replacer   values__signature__)r   r   new_sigr   s   `  @r   _explicitize_argsr     s    t[!>>-- ==,,% w$##G,44((.99@@B 5 
 !(Nr   )r/   r    r   r   r   randomr   r   _utilsr   r   r   r   Randomr   r   r   r   r0   r(   r>   rF   r+   r   r&   r   r   <module>r      s    
   
     D D'(9:V]]1 
	  (CKK ,ST- STl
r   