L iPfUdZddlmZddlmZddlmZmZddlm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZe rddlmZd Zd ed <d Zed ZeddZee dfee zZ ded<e!e"e fZ#ded<edZ$ded<ee gefZ%ded<eege fZ&ded<e dZ'ded<e(edee'Z)d ed<e e'dddd d!d"d#d$d%d&d'd(f Z*ded)<d7d*Z+ee d+ge fZ,ded,<ed-Gd.d/e eZ-ed-Gd0d1e eZ.d8d2Z/d9d3Z0d9d4Z1d:d5Z2y6);zHFunctions and data structures shared by session_state.py and widgets.py.) annotations)Callable) dataclassfield) TYPE_CHECKINGAnyFinalGenericLiteral TypeAlias TypeGuardTypeVarcastget_args)util)StreamlitAPIException) SessionStatez$$IDr GENERATED_ELEMENT_ID_PREFIXz $$STREAMLIT_INTERNAL_KEY_TESTINGTT_coT) covariant.r WidgetArgs WidgetKwargs).NWidgetCallbackWidgetDeserializerWidgetSerializer)double_array_valueint_array_valuestring_array_valueArrayValueFieldNameztuple[ArrayValueFieldName, ...]_ARRAY_VALUE_FIELD_NAMES arrow_value bool_value bytes_value double_valuefile_uploader_state_value int_value json_valuejson_trigger_value string_value trigger_valuestring_trigger_valuechat_input_valueValueFieldNamec|tvSN)r!)objs d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/runtime/state/common.pyis_array_value_field_namer3ks * **rWidgetValuePresenter)frozenceZdZUdZded<edZded<edZded <d ed <d Zd ed<d Z ded<d Z ded<d Z ded<d Z ded<d Z ded<ddZy )WidgetMetadataz4Metadata associated with a single widget. Immutable.stridF)reprzWidgetDeserializer[T] deserializerzWidgetSerializer[T] serializerr. value_typeNzWidgetCallback | Nonecallbackz dict[str, WidgetCallback] | None callbackszWidgetArgs | None callback_argszWidgetKwargs | Nonecallback_kwargs str | None fragment_idzWidgetValuePresenter | None presenterc,tj|Sr0)rrepr_)selfs r2__repr__zWidgetMetadata.__repr__szz$r4)returnr9)__name__ __module__ __qualname____doc____annotations__rr<r=r?r@rArBrDrErIr4r2r8r8vs|> G*/U*;L';&+&7J#7 '+H#*37I/6'+M$++/O(/"K" .2I*1 r4r8c@eZdZUdZded<ded<e ddZy) RegisterWidgetResultalResult returned by the `register_widget` family of functions/methods. Should be usable by widget code to determine what value to return, and whether to update the UI. Parameters ---------- value : T_co The widget's current value, or, in cases where the true widget value could not be determined, an appropriate fallback value. This value should be returned by the widget call. value_changed : bool True if the widget's value is different from the value most recently returned from the frontend. Implies an update to the frontend is needed. rvaluebool value_changedc"||ddS)zThe canonical way to construct a RegisterWidgetResult in cases where the true widget value could not be determined. NF)rSrUrP)clsr<s r2failurezRegisterWidgetResult.failuresd+5AAr4N)r<zWidgetDeserializer[T_co]rJzRegisterWidgetResult[T_co])rKrLrMrNrO classmethodrXrPr4r2rRrRs:& KB3B #BBr4rRc@|jddd}|dk(rdS|S)aTReturn the user key portion of a element id, or None if the id does not have a user key. TODO This will incorrectly indicate no user key if the user actually provides "None" as a key, but we can't avoid this kind of problem while storing the string representation of the no-user-key sentinel as part of the element id. -)maxsplitNoneN)split) element_iduser_keys r2user_key_from_element_idrcs0&++C!+>5 66r4c@t|xr|jd S)z_True if the given session_state key has the structure of a element ID with a user_key. z-None)rhendswithrfs r2is_keyed_element_idrks    ;cll7&;";;r4c@t|rtdtdy)z4Raise an Exception if the given user_key is invalid.zKeys beginning with z are reserved.N)rhrrrfs r2require_valid_user_keyrms*S#"#>"?~ N  r4N)r1objectrJzTypeGuard[ArrayValueFieldName])rar9rJrC)rgr9rJrT)rgr9rJr_)3rN __future__rcollections.abcr dataclassesrrtypingrrr r r r r rrr streamlitrstreamlit.errorsr%streamlit.runtime.state.session_staterrrO TESTING_KEYrrtuplelistrdictr9rrrrr frozensetr!r.r3r5r8rRrcrhrkrmrPr4r2r{sO"$(   B%+U+0  CLv&c3h$s)3 I3sCx. i($Y/ / !)# 2I2&sCx0)0")"Y#,) $% #% $  "+#+C+@#+E"FiF $  WQZ    F $B74=BBB 47 < r4