
    Dht                        S SK r S SKrS SKJr  S SKJrJrJrJrJ	r	J
r
  S SKrS SKrSSKJrJrJrJrJr  SSKJr  SSKJrJrJrJrJrJr  SSKJrJrJr  SS	K 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 r-S r. " S S5      r// r00 r1/ r2SSSSSSSSSSS.
S\3S\4S\\
\\   \4      S\S\\\	\\\4         S\\
\\   \4      S\\*   S\\5   S\\\6/\4      S\S\4   4S  jjr7S! r8\
\9\4   r:S"\:4S# jr;     S2S$\\3   4S% jjr<S\34S& jr=S' r>S(\?S\?S\
\*S4   4S) jr@S* rAS+ rBS, rC S3S- jrDS. rES/ rFS0rGS"\:4S1 jrHg)4    N)wraps)CallableOptionalAnyListTupleUnion   )handle_callback_argshandle_grouped_callback_argsOutputClientsideFunctionInput)ComponentRegistry)InvalidCallbackReturnValuePreventUpdateWildcardInLongCallbackMissingLongCallbackManagerErrorBackgroundCallbackErrorImportedInsideCallbackError)flatten_groupingmake_grouping_by_indexgrouping_len)create_callback_idstringify_idto_jsoncoerce_to_listAttributeDictclean_property_name)	_validate)BaseBackgroundCallbackManager)context_valuec                 t   #    [         R                  " U 5      (       a  U " U0 UD6I S h  vN $ U " U0 UD6$  N7fN)asyncioiscoroutinefunctionfuncargskwargss      aC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\dash/_callback.py_async_invoke_callbackr,   /   s@      ""4((4*6***    +s   '868c                     U " U0 UD6$ r$    r'   s      r+   _invoke_callbackr/   9   s           c                   *    \ rS rSrS r\S 5       rSrg)NoUpdate=   c                 
    SS0$ N_dash_no_updater.   )selfs    r+   to_plotly_jsonNoUpdate.to_plotly_json>   s    !#455r0   c                 l    [        U [        5      =(       d    [        U [        5      =(       a    U SS0:H  $ r5   )
isinstancer2   dict)objs    r+   is_no_updateNoUpdate.is_no_updateA   s1    #x( 
sD!Sc.?AR-S&S	
r0   r.   N)__name__
__module____qualname____firstlineno__r8   staticmethodr>   __static_attributes__r.   r0   r+   r2   r2   =   s    6 
 
r0   r2   Fi  T)

backgroundintervalprogressprogress_defaultrunningcancelmanagercache_args_to_ignorecache_ignore_triggeredon_errorrF   rG   rH   rI   rJ   rK   rL   rM   rO   return.c        
   	      T   SnUR                  SS5      nUR                  S[        5      nUR                  S[        5      nU (       a  SU0nU(       a  XlS'   U(       a  [        U5      US'   [	        US   5        U(       a7  [        U5      US	'   [        US   5      [        US	   5      :X  d  [        S
5      eU(       a?  [        U5      n[	        U5        U Vs/ s H  nUR                  5       PM     snUS'   UUS'   U(       a  X|S'   XS'   [        UUU/U
Q70 UDUUUU	S.D6$ s  snf )a$  
Normally used as a decorator, `@dash.callback` provides a server-side
callback relating the values of one or more `Output` items to one or
more `Input` items which will trigger the callback when they change,
and optionally `State` items which provide additional information but
do not trigger the callback directly.

`@dash.callback` is an alternative to `@app.callback` (where `app = dash.Dash()`)
introduced in Dash 2.0.
It allows you to register callbacks without defining or importing the `app`
object. The call signature is identical and it can be used instead of `app.callback`
in all cases.

The last, optional argument `prevent_initial_call` causes the callback
not to fire when its outputs are first added to the page. Defaults to
`False` and unlike `app.callback` is not configurable at the app level.

:Keyword Arguments:
    :param background:
        Mark the callback as a background callback to execute in a manager for
        callbacks that take a long time without locking up the Dash app
        or timing out.
    :param manager:
        A background callback manager instance. Currently, an instance of one of
        `DiskcacheManager` or `CeleryManager`.
        Defaults to the `background_callback_manager` instance provided to the
        `dash.Dash constructor`.
        - A diskcache manager (`DiskcacheManager`) that runs callback
          logic in a separate process and stores the results to disk using the
          diskcache library. This is the easiest backend to use for local
          development.
        - A Celery manager (`CeleryManager`) that runs callback logic
          in a celery worker and returns results to the Dash app through a Celery
          broker like RabbitMQ or Redis.
    :param running:
        A list of 3-element tuples. The first element of each tuple should be
        an `Output` dependency object referencing a property of a component in
        the app layout. The second element is the value that the property
        should be set to while the callback is running, and the third element
        is the value the property should be set to when the callback completes.
    :param cancel:
        A list of `Input` dependency objects that reference a property of a
        component in the app's layout.  When the value of this property changes
        while a callback is running, the callback is canceled.
        Note that the value of the property is not significant, any change in
        value will result in the cancellation of the running job (if any).
        This parameter only applies to background callbacks (`background=True`).
    :param progress:
        An `Output` dependency grouping that references properties of
        components in the app's layout. When provided, the decorated function
        will be called with an extra argument as the first argument to the
        function.  This argument, is a function handle that the decorated
        function should call in order to provide updates to the app on its
        current progress. This function accepts a single argument, which
        correspond to the grouping of properties specified in the provided
        `Output` dependency grouping. This parameter only applies to background
        callbacks (`background=True`).
    :param progress_default:
        A grouping of values that should be assigned to the components
        specified by the `progress` argument when the callback is not in
        progress. If `progress_default` is not provided, all the dependency
        properties specified in `progress` will be set to `None` when the
        callback is not running. This parameter only applies to background
        callbacks (`background=True`).
    :param cache_args_to_ignore:
        Arguments to ignore when caching is enabled. If callback is configured
        with keyword arguments (Input/State provided in a dict),
        this should be a list of argument names as strings. Otherwise,
        this should be a list of argument indices as integers.
        This parameter only applies to background callbacks (`background=True`).
    :param cache_ignore_triggered:
        Whether to ignore which inputs triggered the callback when creating
        the cache. This parameter only applies to background callbacks
        (`background=True`).
    :param interval:
        Time to wait between the background callback update requests.
    :param on_error:
        Function to call when the callback raises an exception. Receives the
        exception object as first argument. The callback_context can be used
        to access the original callback inputs, states and output.
N config_prevent_initial_callbacksFcallback_mapcallback_listrG   rL   rH   progressDefaultz8Progress and progress default needs to be of same lengthrK   cancel_inputsrM   rN   )rF   rL   rJ   rO   )	popGLOBAL_CALLBACK_MAPGLOBAL_CALLBACK_LISTr   validate_background_inputslen	Exceptionto_dictregister_callback)rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   _args_kwargsbackground_specrR   rS   rT   rV   cs                     r+   callbackrc   N   s]   @ O'.{{*E($ ;;~/BCLKK1EFM 
 )0I&*8*BOJ'&z'BC1?@P1QO-.z23s 128   N  *62M&}5>K(Lmm(LOH%/<OO,6J234J01(
 
	

 
 #
 
 )Ms   D%c                 p    U  H0  nUR                  5       (       d  M  [        S[        U5       S35      e   g )Nz
                background callbacks does not support dependencies with
                pattern-matching ids
                    Received: 
)has_wildcardr   repr)depsdeps     r+   rZ   rZ      s?    (  $Cyk/  r0   clientside_functionc                 @    [        [        [        S[        U /UQ70 UD6$ )NF)register_clientside_callbackrY   rX   GLOBAL_INLINE_SCRIPTS)rj   r)   r*   s      r+   clientside_callbackrn      s2    ' 
  r0   dynamic_creatorc                 |   Uc  Un[         R                  " X8U5        [        X5U5      nUU Vs/ s H  oR                  5       PM     snU Vs/ s H  oR                  5       PM     snS USL U	=(       a    SU	S   0UUS.nU(       a  UUS'   US   US   UUU	UUU
UUS.
X'   U R	                  U5        U$ s  snf s  snf )NTrG   )outputinputsstaterj   prevent_initial_callrF   ro   	no_outputrJ   rr   rs   )
rr   rs   outputs_indicesinputs_state_indicesrF   rq   
raw_inputsrL   allow_dynamic_callbacksru   )r    validate_duplicate_outputr   r]   append)rT   rS   rR   rq   rv   rr   rs   rw   rt   rF   rL   rJ   ro   ru   callback_idrb   callback_specs                    r+   insert_callbackr~      s      #?''&F %VY?K(./199;/',-u!))+u-# !5 <  

:.
 +M #*i   )w'* 4 #2!L '= 0-s   B4B9c                 V    [        U R                  5      n[        U5      S:  a  X!S'   gg)Nr   
sideUpdateTF)r<   updated_propsr[   )ctxresponseside_updates      r+   _set_side_updater   ;  s-    s(()K
;!!,r0   c                 f   UR                  SS5      nUR                  S5      nUR                  S[        S0 05      5      n[        R                  " U5        [        [        R
                  5      nU(       a  [        R                  " XF[        5        [        R                  " X5      u  pUUU	U
UUS4$ )z6Initialize context and validate output specifications.appNoutputs_listcallback_contextr   F)
rW   r   r"   setr   registryr    validate_output_specr   validate_and_group_input_args)r)   r*   rw   
has_outputinsert_outputr   output_speccallback_ctxoriginal_packages	func_argsfunc_kwargss              r+   _initialize_contextr   C  s    
**UD
!C**^,K::0-RT@U2VWLl#-667&&}6J&DDI 	 r0   r*   c                    UR                  SU R                  SS5      5      nUb  U(       d  [        S5      e[        R                  R                  R                  S5      nU(       a  U H  nUR                  U5        M     U$ )/Set up the background callback and manage jobs.rL   background_callback_managerNa;  Running `background` callbacks requires a manager to be installed.
Available managers:
- Diskcache (`pip install dash[diskcache]`) to run callbacks in a separate Process and store results on the local filesystem.
- Celery (`pip install dash[celery]`) to run callbacks in a celery worker and store results on redis.
oldJob)getr   flaskrequestr)   getlistterminate_job)r*   rF   callback_managerold_jobjobs        r+   _get_callback_managerr   \  s     "~~6::;TB 11  mm  ((2GC**3/  r0   c           	         [        X5      nUR                  S5      nUR                  SS5      n	UR                  UU(       a  UOUUR                  S/ 5      U	(       a  SOUR                  S/ 5      5      n
UR                  R                  U5      n[	        S0 [
        R                  " 5       D6nSUl        UR                  S5        UR                  S5        UR                  U
UU(       a  UOUU5      nU
US	.nUR                  S
5      nU(       a  XS
'   UR                  S5      nU(       a/  [        UU5       VVs0 s H  u  nn[        U5      U_M     snnUS'   [        U5      $ s  snnf )r   rH   rN   TrM   Ntriggered_inputsr   dash_response)cacheKeyr   rK   rU   r.   )r   r   build_cache_keyfunc_registryr   r"   ignore_register_pagerW   call_job_fnzipstrr   )r*   rF   background_keyr(   r   r   r   r   progress_outputsrN   	cache_keyjob_fn	ctx_valuer   datarK   rI   oxs                      r+   _setup_background_callbackr   w  s`    -V@!~~j1'^^,DdK 00	K-r2&L,<,<=OQS,TI ++//?F4 1 1 34I%)I"MM/0MM/"

&
&	K	C D
 ^^H%FX!~~&78"%&68H"I#
"I$!QCFAI"I#
 4=#
s   <E'c                 $   UR                  S5      n[        R                  R                  R                  S5      nU(       aI  UR	                  U5      nU(       a0  [        U5       VVs0 s H  u  pg[        U5      XV   _M     snnU S'   g g g s  snnf )NrH   r   )r   r   r   r)   get_progress	enumerater   )r   r   rF   r   r   rH   ir   s           r+   _progress_background_callbackr     s    !~~j1""&&z2I#00;09:J0K$0KA#0K$HZ   $s   (Bc                    [        X45      n[        R                  R                  R	                  S5      n[        R                  R                  R	                  S5      n[        X&U5        UR                  Xx5      n	[        XX X5      $ )r   r   r   )r   r   r   r)   r   r   
get_result _handle_rest_background_callback)
error_handlerr   r   r*   rF   multir   r   job_idoutput_values
             r+   _update_background_callbackr     sq     -V@""&&z2I]]##E*F!(jI#..yAL+ r0   c                    [         R                  R                  R                  S5      n[         R                  R                  R                  S5      nUR	                  U5      n	U	(       d  XR
                  L a  [        5       n Oy[        U [        5      (       ad  SU ;   a^  U R                  S0 5      n
[        SU
S    SU
S    35      nU(       a,  U" U5      n U c
  [        5       n [        XB5      =(       d    U S LnOUeU	(       a  XR
                  La  UR                  U5        U(       aQ  [        U [        [        45      (       a6  U  Vs/ s H)  n[        R                  U5      (       a
  [        5       OUPM+     n nUR                  U5      n[!        U5      S:  a  XS	'   S
nXR
                  L a  [#        U5      US
4$ XS4$ s  snf )Nr   r   background_callback_errorz0An error occurred inside a background callback: msgre   tbr   r   TF)r   r   r)   r   job_running	UNDEFINEDr2   r;   r<   r   r   r   listtupler>   get_updated_propsr[   r   )r   r   r   r   r   r   
has_updater   r   r   errorexcrr   s                 r+   r   r     s    ""&&z2I]]##E*F"..v6K<+E+EEz	L$	'	',G<,W  !<bA%>uU|nBuUY{m\
 (-L#'z
 !8TLPT<T  I|+E+EE&&v.L4-88CO
COa(//22HJ9< 	 
 %66yAM
=A!.
111x *d22U**
s   	0Gc                 l   [         R                  " [        5      nU	(       Ga3  U(       d  U /U/pU nOO[        U [        [
        45      (       a  [	        U 5      n [        R                  U 5      (       a  U /nO[        X
5      n[        R                  U 5      (       d  [        R                  " XU5        [        X5       H  u  nn[        R                  U5      (       a  M"  [        U[        5      (       a  [        UU5      OUU// HH  u  nn[        R                  U5      (       a  M"  Sn[        US   5      n[        US   5      nUUU   U'   MJ     M     OU b  [        SU  35      eU(       d  [        XC5      =(       d    U	nU(       d  [         e[#        [$        R&                  5      [#        U5      :w  an  [	        [)        [$        R&                  5      R+                  U5      5      nU(       d   [-        S[#        U5      S:X  a  SOS S	35      eUR/                  U5      nUUS
'   UR1                  SU05      $ )z9Prepare the response object based on the callback output.Tidpropertyz*No-output callback received return value: zComponent librarr
   yieszl was imported during callback.
You can set `_allow_dynamic_callbacks` to allow for development purpose only.distr   )collectionsdefaultdictr<   r;   r   r   r2   r>   r   r    validate_multi_returnr   r   r   r   r   r   r[   r   r   r   
differencer   get_distupdate)r   r   r   r   r   r   r   rF   r   r   rq   r|   ry   component_idsflat_output_valuesvalspecvalispeciid_strpropdiff_packagesr   s                          r+   _prepare_responser     s      ++D1M)5+!-,u66  $L1$$\22&2^" &6l%K"$$\22++ /=IC$$S))",T4"8"8CT{mK e  ,,T22!%J)%+6F.uZ/@AD26M&)$/ L	 > #,<\NK  %l=K

%%&#.?*@@!**+667HI
 '-"#m*<*A3u"M N` `  ||M*??J677r0   c                   ^^^^^^^^^^ [        X45      u  mnnmn[        T[        5      (       a  TmSmSmO[        T5      mSm[	        T5      S:  mUR                  S5      mUR                  S5      nUR                  S5      n	UR                  S5      mU	bh  [        U	S   [        [        45      (       d  U	/n	U	 V
s0 s H  n
[        U
S   5      U
S   _M     sn
U	 V
s0 s H  n
[        U
S   5      U
S	   _M     sn
S
.n	UR                  S5      m[        T[        [        [        T5      5      5      5      n[        U TUTUUUTUTUTU	T(       + S9mUUUUUUUUUU4
S jnU$ s  sn
f s  sn
f )NFTr   rF   rL   rJ   rO   r
      )rJ   
runningOff_allow_dynamic_callbacks)rF   rL   ro   rJ   ru   c                 <  >
^ ^ Tc  S mO)[         R                  " T TR                  S5      S LT5      m[        T 5      UUUUU UU	U
UUU4S j5       n[        T 5      UUUUU UU	U
UUU4S j5       n[        R
                  " T 5      (       a
  UTT   S'   T $ UTT   S'   T $ )NrH   c                  t  > T=(       d    UR                  SS5      n[        XTTT5      u  nnnnnnn	SS0n
Sn TbZ  [        R                  R                  R                  S5      (       d  [        UTTTUUU5      $ [        X$XTT5      u  pnU(       a  U$ O[        T/UQ70 UD6n [        UUTU
UUUTU	TTTT5         [        U
5      nU$ ! [         a    e [         a/  nU(       a!  U" U5      nUc  U(       a
  [        5       n SnANaUeSnAff = f! [         a    [        R                   " UT5         U$ f = f)z6Handles synchronous callbacks with context management.app_on_errorNr   Tr   )rW   r   r   r   r)   r   r   r   r/   r   r\   r2   r   r   	TypeErrorr    fail_callback_output)r)   r*   r   r   r   r   r   r   r   r   r   jsonResponser   skiperrry   rF   r   r|   r(   r   rw   r   r   rO   rq   s                  r+   add_context9register_callback.<locals>.wrap_func.<locals>.add_context  s    %H

>4(HM $2J!
 &t_HL) ==--11*==9"&* %'(   6Q%XzSX62Ld ++  $4D#T9#T#TL !'E&x0  = !   #0#5L#+'/zI2  E..|VDEs<   AC <C C ?D D #D
D

D!D76D7c                    >#    T=(       d    UR                  SS5      n[        XTTT5      u  nnnnnnn	SS0n
 TbZ  [        R                  R                  R                  S5      (       d  [        UTTTUUU5      $ [        X$XTT5      u  pnU(       a  U$ O[        T/UQ70 UD6I Sh  vN n [        UUTU
UUUTU	TTTT5         [        U
5      nU$  N*! [         a    e [         a/  nU(       a!  U" U5      nUc  U(       a
  [        5       n SnANcUeSnAff = f! [         a    [        R                   " UT5         W$ f = f7f)z0Handles async callbacks with context management.r   Nr   Tr   )rW   r   r   r   r)   r   r   r   r,   r   r\   r2   r   r   r   r    r   )r)   r*   r   r   r   r   r   r   r   r   r   r   r   r   r   ry   rF   r   r|   r(   r   rw   r   r   rO   rq   s                  r+   async_add_context?register_callback.<locals>.wrap_func.<locals>.async_add_context  s     %H

>4(HM $2J!
 &t_H) ==--11*==9"&* %'(   6Q%XzSX62Ld ++  *@*(*,7* $L !'E&x0  C$ !   #0#5L#+'/zI2  E..|VDEs   6EAC ;E<C EC )C*C .ED EC D*#DEDDE!E=E EErc   )r!   register_funcr   r   r%   r&   )r(   r   r   r   ry   rF   r|   rS   r   rw   r   r   rO   rq   s   `  @r+   	wrap_func$register_callback.<locals>.wrap_func  s    !N:HHz*$6N 
tE	  E	  
E	 N 
tE	  E	  
E	 N &&t,,4EL%j1  5@L%j1r0   )r   r;   r   r   r[   r   r   r   r   r   ranger   r~   )rT   rS   rR   r_   r`   flat_inputs
flat_statert   rL   rJ   r   output_indicesr   ry   rF   r|   r   rw   r   r   rO   rq   s    `           @@@@@@@@@r+   r^   r^   K  s    	%U4&&!!
 )0[1_
\*Jkk)$Gkk)$G{{:&H'!*tUm44iG189AAaD	1Q494;<Gq3qt9ad?G<
 &kk*DE+FD|F?S9T4UVN!(/ .K$_ _B s :<s   ?E&!E+z
(function() {{
    var clientside = window.dash_clientside = window.dash_clientside || {{}};
    var ns = clientside["{namespace}"] = clientside["{namespace}"] || {{}};
    ns["{function_name}"] = {clientside_function};
}})();
c                    [        XV5      u  pxp[        U[        45      =(       a    [        U5      S:H  n[	        U UUUS UU	S U
US9
  [        U[
        5      (       aZ  Sn[        R                  " UR                  S5      5      R                  5       nUR                  [        R                  UUUS95        OUR                  nUR                  nUUS.U S   S'   g )	Nr   )ru   _dashprivate_clientside_funcszutf-8)	namespacefunction_namerj   )r   r  rj   )r   r;   r   r[   r~   r   hashlibsha256encode	hexdigestr{   _inline_clientside_templateformatr   r  )rT   rS   rR   inline_scriptsrj   r)   r*   rq   rr   rs   rt   ru   r   r  s                 r+   rl   rl   -  s     3Gt2T/FE6D7+@Fq0@I( %s++3	':'A'A''JKUUW'..#+$7 / 	
 (11	+99 &0M"+,r0   )NNNFF)F)Ir   r  	functoolsr   typingr   r   r   r   r   r	   r%   r   dependenciesr   r   r   r   r   development.base_componentr   
exceptionsr   r   r   r   r   r   	_groupingr   r   r   _utilsr   r   r   r   r   r    r    background_callback.managersr!   _callback_contextr"   r,   r/   r2   rY   rX   rm   boolintr   r\   rc   rZ   r   ClientsideFuncTypern   r~   r   r   r<   r   r   r   r   r   r   r^   r  rl   r.   r0   r+   <module>r     s2      > >    :  
   G ,!!
 
     6: 7;267;+/59TT T uT&\6123	T
 T d5c!1234T U4;-./T 34T #4.T xS 012T c3hTn 3 223 	-? 	. &+8 d^8vt 2"
($./6.b
2 3+nI8ZVr /
 ,/r0   