L i#ddlmZddlZddlmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddl m!Z!m"Z"er ddl#m$Z$ddl%m&Z&GddeZ'GddeZ(y)) annotationsN) TYPE_CHECKINGAny)BaseCustomComponent)is_dataframe_like)get_dg_singleton_instance)current_form_id)check_cache_replay_rules)compute_and_register_element_id)StreamlitAPIException) ArrowTable) SpecialArg)Element)gather_metrics)get_script_run_ctx)register_widget) is_bytes_liketo_bytes)DeltaGenerator)WidgetCallbackceZdZdZy)MarshallComponentExceptionzCClass for exceptions generated during custom component marshalling.N)__name__ __module__ __qualname____doc__n/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/components/v1/custom_component.pyrr(sMrrceZdZdZddddd d dZedddddd d dZd dZejZ d dZ d d Z y) CustomComponentzA Custom Component declaration.Ndefaultkey on_change tab_indexc0|j|||||d|S)zAn alias for create_instance.r")create_instance)selfr#r$r%r&argskwargss r__call__zCustomComponent.__call__1s2$t##      rr(c t|dkDrtd|dd0ttrttsdk\s t d ddl}ddlmtt| }i} g|jD]\} } t| r3t} | | _t!| | _j%| Dt'| rIt} | | _j)| j*j,| j%| | | | < t/j0| d fd }t5j6}t9}|||}|j;d |j<|S#t$r t dwxYw#t2$r}td |d}~wwxYw)aCreate a new instance of the component. Parameters ---------- *args Must be empty; all args must be named. (This parameter exists to enforce correct use of the function.) default: any or None The default return value for the component. This is returned when the component's frontend hasn't yet specified a value with `setComponentValue`. key: str or None If not None, this is the user key we use to generate the component's "widget ID". on_change: WidgetCallback or None An optional callback invoked when the widget's value changes. No arguments are passed to it. tab_index : int, optional Specifies the tab order of the iframe containing the component. Possible values are: - ``None`` (default): Browser default behavior. - ``-1``: Removes the iframe from the natural tab order, but it can still be focused programmatically. - ``0`` or positive integer: Includes the iframe in the natural tab order. **kwargs Keyword args to pass to the component. Returns ------- any or None The component's widget value. rz Argument 'z' needs a labelNz6tab_index must be None, -1, or a non-negative integer.)component_arrowzTo use Custom Components in Streamlit, you need to install PyArrow. To do so locally: `pip install pyarrow` And if you're using Streamlit Cloud, add "pyarrow" to your requirements.txt.)r#r$z(Could not convert component args to JSONc  j|j_t||j_ j  j |j_  |j_ |j_|jjj tdddh| j j }||j_ d d}t|jj|dt d}|j}|}|St|t rj#|}|S) Ncomponent_instancenameurl)user_keykey_as_main_identitydgr2r3 json_args special_argsc|SNr)ui_values rdeserialize_componentzZCustomComponent.create_instance..marshall_component..deserialize_componentsrc|Sr:r)xs rzMCustomComponent.create_instance..marshall_component..sQr json_value) deserializer serializerctxon_change_handler value_type)r;rreturnr)r2r1component_namer form_idr3r&r7r8extendr idrrvalue isinstanceArrowTableProtoarrow_proto_to_dataframe)r6element computed_idr<component_state widget_valuer/r#r$r%r)serialized_json_argsr8r&s rmarshall_componentz;CustomComponent.create_instance..marshall_components48< G & & 51@1DG & & .xx#15**.$7@**43GG & & 0  & & 3 3 : :< H9$'-e_YYHH.) K-8G & & ) .**--2&&("+' O+00L#&  L/:.GG U  rr1)r6rrOrrFr)lenrrLintboolr pyarrowstreamlit.components.v1r/ ImportErrorr dictitemsrrr$rbytesappendrmarshallarrow_dataframedatajsondumps Exceptionrmain_dgr_enqueuer1)r)r#r$r%r&r*r+rXall_argsr7arg_namearg_val bytes_arg dataframe_argexrTr6rO return_valuer/rSr8s````` @@@rr(zCustomComponent.create_instanceDsR t9q=,z$q'/-RS S  y# &y$/R'H    ? !"S9  !)!1 . HgW%&L ( "*7"3 ##I."7+ * $, !(()F)F)K)KWU##M2&- (# . #'::i#8 , , `' ( 0 0))"g6  ('*D*DE{ 'P  D ,:B  s$ F2F1F.1 G : GG ct|txrj|j|jk(xrO|j|jk(xr4|j|jk(xr|j |j k(S)zEquality operator.)rLr!r2pathr3 module_namer)others r__eq__zCustomComponent.__eq__so uo . 6 UZZ' 6 UZZ' 6EII% 6  E$5$55  rc||k( S)zInequality operator.rrqs r__ne__zCustomComponent.__ne__s 5=  rcnd|jd|j|jS|jS)N'z': )r2ror3)r)s r__str__zCustomComponent.__str__s6499+Sdii.C RSS RSSr)r*rr#rr$z str | Noner%zWidgetCallback | Noner&z int | Noner+rrFr)rrobjectrFrW)rFstr) rrrrr,rr(rsr__hash__rurxrrrr!r!.s) +/ $      )       &%&+/ $ VVV V ) V  VV V'Vp #++H!Trr!)) __future__rrbtypingrr0streamlit.components.types.base_custom_componentrstreamlit.dataframe_utilr$streamlit.delta_generator_singletonsr!streamlit.elements.lib.form_utilsr streamlit.elements.lib.policiesr streamlit.elements.lib.utilsr streamlit.errorsr streamlit.proto.Components_pb2r rMrstreamlit.proto.Element_pb2rstreamlit.runtime.metrics_utilr7streamlit.runtime.scriptrunner_utils.script_run_contextrstreamlit.runtime.staterstreamlit.type_utilrrstreamlit.delta_generatorrstreamlit.runtime.state.commonrrr!rrrrsa# %P6J=DH2H5/9V378= !6 CT)CTr