"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[8166],{34752:(e,t,i)=>{i.d(t,{X:()=>l,o:()=>o});var s=i(58878),r=i(25571);class o{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,i){(0,r.se)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,r._L)(t)&&(this.formClearListener=e.addFormClearedListener(t,i),this.lastWidgetMgr=e,this.lastFormId=t))}disconnect(){var e;null===(e=this.formClearListener)||void 0===e||e.disconnect(),this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}}function l(e){let{element:t,widgetMgr:i,onFormCleared:o}=e;(0,s.useEffect)((()=>{if(!(0,r._L)(t.formId))return;const e=i.addFormClearedListener(t.formId,o);return()=>{e.disconnect()}}),[t,i,o])}},38166:(e,t,i)=>{i.r(t),i.d(t,{default:()=>m});var s=i(58878),r=i(8151),o=i(34752),l=i(4871),a=i(25571),n=i(90782);class d extends s.PureComponent{constructor(){super(...arguments),this.formClearHelper=new o.o,this.state={value:this.initialValue},this.commitWidgetValue=e=>{const{widgetMgr:t,element:i,fragmentId:s}=this.props;t.setIntValue(i,this.state.value,e,s)},this.onFormCleared=()=>{this.setState(((e,t)=>{var i;return{value:null!==(i=t.element.default)&&void 0!==i?i:null}}),(()=>this.commitWidgetValue({fromUi:!0})))},this.onChange=e=>{this.setState({value:e},(()=>this.commitWidgetValue({fromUi:!0})))}}get initialValue(){var e;const t=this.props.widgetMgr.getIntValue(this.props.element);return null!==(e=null!==t&&void 0!==t?t:this.props.element.default)&&void 0!==e?e:null}componentDidMount(){this.props.element.setValue?this.updateFromProtobuf():this.commitWidgetValue({fromUi:!1})}componentDidUpdate(){this.maybeUpdateFromProtobuf()}componentWillUnmount(){this.formClearHelper.disconnect()}maybeUpdateFromProtobuf(){const{setValue:e}=this.props.element;e&&this.updateFromProtobuf()}updateFromProtobuf(){const{value:e}=this.props.element;this.props.element.setValue=!1,this.setState({value:null!==e&&void 0!==e?e:null},(()=>{this.commitWidgetValue({fromUi:!1})}))}render(){const{options:e,help:t,label:i,labelVisibility:s,formId:r,placeholder:o}=this.props.element,{disabled:d,widgetMgr:m}=this.props,h=(0,a.hX)(this.props.element.default)&&!d;return this.formClearHelper.manageFormClearListener(m,r,this.onFormCleared),(0,n.jsx)(l.Ay,{label:i,labelVisibility:(0,a.yv)(null===s||void 0===s?void 0:s.value),options:e,disabled:d,width:this.props.width,onChange:this.onChange,value:this.state.value,help:t,placeholder:o,clearable:h})}}const m=(0,r.b)(d)}}]);