streamlit-nightly 1.43.3.dev20250312__py3-none-any.whl → 1.43.3.dev20250314__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. streamlit/auth_util.py +2 -1
  2. streamlit/commands/experimental_query_params.py +1 -1
  3. streamlit/commands/logo.py +3 -3
  4. streamlit/components/v1/__init__.py +1 -3
  5. streamlit/components/v1/custom_component.py +1 -1
  6. streamlit/config.py +3 -2
  7. streamlit/config_option.py +1 -3
  8. streamlit/connections/snowflake_connection.py +0 -1
  9. streamlit/connections/sql_connection.py +0 -1
  10. streamlit/dataframe_util.py +7 -6
  11. streamlit/delta_generator_singletons.py +2 -2
  12. streamlit/elements/arrow.py +0 -1
  13. streamlit/elements/exception.py +3 -1
  14. streamlit/elements/form.py +3 -3
  15. streamlit/elements/json.py +2 -2
  16. streamlit/elements/layouts.py +0 -5
  17. streamlit/elements/lib/built_in_chart_utils.py +1 -2
  18. streamlit/elements/lib/column_config_utils.py +0 -3
  19. streamlit/elements/lib/column_types.py +6 -39
  20. streamlit/elements/lib/image_utils.py +2 -1
  21. streamlit/elements/lib/options_selector_utils.py +6 -3
  22. streamlit/elements/lib/subtitle_utils.py +2 -0
  23. streamlit/elements/lib/utils.py +0 -2
  24. streamlit/elements/media.py +2 -1
  25. streamlit/elements/metric.py +0 -1
  26. streamlit/elements/plotly_chart.py +2 -2
  27. streamlit/elements/progress.py +1 -1
  28. streamlit/elements/text.py +2 -2
  29. streamlit/elements/vega_charts.py +2 -1
  30. streamlit/elements/widgets/audio_input.py +2 -1
  31. streamlit/elements/widgets/button.py +0 -1
  32. streamlit/elements/widgets/button_group.py +2 -3
  33. streamlit/elements/widgets/data_editor.py +2 -3
  34. streamlit/elements/widgets/slider.py +1 -1
  35. streamlit/elements/widgets/text_widgets.py +1 -0
  36. streamlit/elements/write.py +0 -1
  37. streamlit/errors.py +4 -2
  38. streamlit/external/langchain/streamlit_callback_handler.py +1 -2
  39. streamlit/file_util.py +4 -2
  40. streamlit/navigation/page.py +2 -3
  41. streamlit/platform.py +1 -3
  42. streamlit/runtime/caching/cache_data_api.py +5 -5
  43. streamlit/runtime/caching/cache_errors.py +1 -1
  44. streamlit/runtime/caching/cache_resource_api.py +4 -4
  45. streamlit/runtime/caching/cache_utils.py +6 -4
  46. streamlit/runtime/caching/storage/cache_storage_protocol.py +6 -6
  47. streamlit/runtime/caching/storage/dummy_cache_storage.py +2 -2
  48. streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +6 -6
  49. streamlit/runtime/caching/storage/local_disk_cache_storage.py +6 -6
  50. streamlit/runtime/connection_factory.py +0 -1
  51. streamlit/runtime/context.py +1 -1
  52. streamlit/runtime/credentials.py +1 -1
  53. streamlit/runtime/forward_msg_cache.py +1 -1
  54. streamlit/runtime/forward_msg_queue.py +2 -1
  55. streamlit/runtime/fragment.py +2 -1
  56. streamlit/runtime/memory_media_file_storage.py +2 -2
  57. streamlit/runtime/metrics_util.py +2 -2
  58. streamlit/runtime/runtime_util.py +1 -1
  59. streamlit/runtime/scriptrunner/script_runner.py +1 -1
  60. streamlit/runtime/scriptrunner_utils/exceptions.py +1 -1
  61. streamlit/runtime/scriptrunner_utils/script_run_context.py +1 -0
  62. streamlit/runtime/secrets.py +5 -3
  63. streamlit/runtime/state/common.py +1 -1
  64. streamlit/runtime/state/safe_session_state.py +1 -1
  65. streamlit/runtime/state/session_state.py +4 -3
  66. streamlit/runtime/stats.py +1 -1
  67. streamlit/runtime/uploaded_file_manager.py +4 -3
  68. streamlit/static/index.html +1 -1
  69. streamlit/static/static/js/{FileDownload.esm.C9csNfwR.js → FileDownload.esm.C9LJHGQA.js} +1 -1
  70. streamlit/static/static/js/{FileHelper.CTWNHaVI.js → FileHelper.jkT1raGU.js} +1 -1
  71. streamlit/static/static/js/{FormClearHelper.1VkFJY3v.js → FormClearHelper.DhbIpC8c.js} +1 -1
  72. streamlit/static/static/js/{Hooks.vPqq3xQ5.js → Hooks.CriWgW_b.js} +1 -1
  73. streamlit/static/static/js/{InputInstructions.7jABRwB0.js → InputInstructions.D3RY91P2.js} +1 -1
  74. streamlit/static/static/js/{ProgressBar.BWY8ITDS.js → ProgressBar.C3Pzm-B2.js} +1 -1
  75. streamlit/static/static/js/{RenderInPortalIfExists.CP_sn1OG.js → RenderInPortalIfExists.BZnHZgZS.js} +1 -1
  76. streamlit/static/static/js/{Toolbar.DzqMcgvB.js → Toolbar.B5rV1WJt.js} +1 -1
  77. streamlit/static/static/js/{base-input.DjuthXF0.js → base-input.Cw4qDIMU.js} +1 -1
  78. streamlit/static/static/js/{checkbox.BddRUN3_.js → checkbox.DkQySTTm.js} +1 -1
  79. streamlit/static/static/js/{createSuper.BAGgahBq.js → createSuper.BSo5GDIi.js} +1 -1
  80. streamlit/static/static/js/{data-grid-overlay-editor.Bscjz8_-.js → data-grid-overlay-editor.B1mf5JDE.js} +1 -1
  81. streamlit/static/static/js/{downloader.BgDSv-Ig.js → downloader.B1pPErIQ.js} +1 -1
  82. streamlit/static/static/js/{es6.3kVHyEdR.js → es6.DMqquk5e.js} +2 -2
  83. streamlit/static/static/js/{iframeResizer.contentWindow.n2oqEwdf.js → iframeResizer.contentWindow.ChumCRtp.js} +1 -1
  84. streamlit/static/static/js/{index.UJT9uVs_.js → index.5WgntJXP.js} +1 -1
  85. streamlit/static/static/js/{index.k2DDVmzp.js → index.7Uw588Xk.js} +1 -1
  86. streamlit/static/static/js/{index.DbI6X421.js → index.B3IKgYX5.js} +1 -1
  87. streamlit/static/static/js/{index.BfTunuGf.js → index.B3eHKw73.js} +1 -1
  88. streamlit/static/static/js/{index.D7k3QVrz.js → index.B740eLHm.js} +1 -1
  89. streamlit/static/static/js/{index.Bd5GUMH8.js → index.B96IeQgZ.js} +1 -1
  90. streamlit/static/static/js/{index.DAAc9Gb3.js → index.BFTTgLeU.js} +1 -1
  91. streamlit/static/static/js/{index.CFbiFnmq.js → index.BOaNnKYB.js} +1 -1
  92. streamlit/static/static/js/{index.C8ZHYetm.js → index.BTOGrbrn.js} +1 -1
  93. streamlit/static/static/js/{index.D3uVQMaA.js → index.BbRfGs1X.js} +1 -1
  94. streamlit/static/static/js/{index.0JqsAt5p.js → index.BgDVGIiW.js} +1 -1
  95. streamlit/static/static/js/{index.D3EE2F77.js → index.BlL9sy9J.js} +147 -146
  96. streamlit/static/static/js/{index.C28BRw13.js → index.BlmSw6QY.js} +1 -1
  97. streamlit/static/static/js/{index.BNTyamf9.js → index.C5YEuIXg.js} +1 -1
  98. streamlit/static/static/js/{index.BQXOwXQG.js → index.CKXJOTqx.js} +1 -1
  99. streamlit/static/static/js/{index.DlXteNnv.js → index.CSTjg2CK.js} +1 -1
  100. streamlit/static/static/js/{index.ChDimwy6.js → index.CVd_6WNy.js} +1 -1
  101. streamlit/static/static/js/{index.FJszpQ-y.js → index.Cd6xqijF.js} +5 -5
  102. streamlit/static/static/js/{index.svH5ea22.js → index.CfNMuIIh.js} +1 -1
  103. streamlit/static/static/js/{index.zrNj-omI.js → index.CrkWnEhn.js} +1 -1
  104. streamlit/static/static/js/{index.j6cgFK9c.js → index.D0wPNnz8.js} +1 -1
  105. streamlit/static/static/js/{index.mMuChmJi.js → index.DK1PVQ6C.js} +1 -1
  106. streamlit/static/static/js/{index.OtBp-Blq.js → index.DT_OGzkj.js} +1 -1
  107. streamlit/static/static/js/{index.S_LaABz9.js → index.DWAHTwxW.js} +1 -1
  108. streamlit/static/static/js/{index.pEU90S1o.js → index.DaaBud_u.js} +5 -5
  109. streamlit/static/static/js/{index.BaYVwylD.js → index.DbQZTVYH.js} +1 -1
  110. streamlit/static/static/js/{index.CrZncPLs.js → index.DqPipBPf.js} +1 -1
  111. streamlit/static/static/js/{index.3k9e_sFT.js → index.Dz2EqLgY.js} +1 -1
  112. streamlit/static/static/js/{index.DAghU1FB.js → index.LgpTjYjs.js} +1 -1
  113. streamlit/static/static/js/{index.BPcgpI5G.js → index.Sd38jGo-.js} +1 -1
  114. streamlit/static/static/js/{index.Dv6XiWKs.js → index.TcpXhGIM.js} +1 -1
  115. streamlit/static/static/js/{index.Cj7yHfOR.js → index._70PT65v.js} +1 -1
  116. streamlit/static/static/js/{index.B1ZLFKil.js → index.bVsz2ldg.js} +1 -1
  117. streamlit/static/static/js/{index.B8IuPu4x.js → index.lVcG4OCJ.js} +1 -1
  118. streamlit/static/static/js/{index.N6CP_9Qh.js → index.rPVy0ui5.js} +1 -1
  119. streamlit/static/static/js/{index.CrjCtGqg.js → index.szAaQUP4.js} +1 -1
  120. streamlit/static/static/js/{index.CYrF9jN2.js → index.w7piGYbJ.js} +1 -1
  121. streamlit/static/static/js/{input.A7Xel5Mz.js → input.CGLa0Mkr.js} +1 -1
  122. streamlit/static/static/js/{memory.DKAi1aOw.js → memory.u6Bv68yh.js} +1 -1
  123. streamlit/static/static/js/{mergeWith.BOXngkwE.js → mergeWith.BEgniPh1.js} +1 -1
  124. streamlit/static/static/js/{number-overlay-editor.Dr9nZLr4.js → number-overlay-editor.94bIlYUC.js} +1 -1
  125. streamlit/static/static/js/{possibleConstructorReturn.Dmq70n5Q.js → possibleConstructorReturn.Dfpu-j0D.js} +1 -1
  126. streamlit/static/static/js/{sandbox.OiNVhKVk.js → sandbox.CYYH_geg.js} +1 -1
  127. streamlit/static/static/js/{textarea.BvcErhuX.js → textarea.ByGG-B4n.js} +1 -1
  128. streamlit/static/static/js/{timepicker.BndxQ_56.js → timepicker.B7cgXhs2.js} +1 -1
  129. streamlit/static/static/js/{toConsumableArray.Bvyh5k2t.js → toConsumableArray.K_KdQrnP.js} +1 -1
  130. streamlit/static/static/js/{uniqueId.BJXawxf6.js → uniqueId.BoMGywDL.js} +1 -1
  131. streamlit/static/static/js/{useBasicWidgetState.-z6NaxAe.js → useBasicWidgetState.DJ657I97.js} +1 -1
  132. streamlit/static/static/js/{useOnInputChange.DvBUKld6.js → useOnInputChange.BT-TUWed.js} +1 -1
  133. streamlit/static/static/js/{withFullScreenWrapper.CubK7zml.js → withFullScreenWrapper.DpT3_k8t.js} +1 -1
  134. streamlit/string_util.py +3 -2
  135. streamlit/testing/v1/element_tree.py +30 -30
  136. streamlit/testing/v1/util.py +2 -1
  137. streamlit/time_util.py +1 -3
  138. streamlit/type_util.py +2 -1
  139. streamlit/user_info.py +0 -1
  140. streamlit/watcher/event_based_path_watcher.py +1 -1
  141. streamlit/web/bootstrap.py +3 -1
  142. streamlit/web/cache_storage_manager_config.py +1 -1
  143. streamlit/web/cli.py +2 -2
  144. streamlit/web/server/authlib_tornado_integration.py +1 -1
  145. streamlit/web/server/browser_websocket_handler.py +2 -1
  146. streamlit/web/server/routes.py +2 -2
  147. streamlit/web/server/server_util.py +2 -4
  148. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/METADATA +1 -1
  149. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/RECORD +153 -153
  150. {streamlit_nightly-1.43.3.dev20250312.data → streamlit_nightly-1.43.3.dev20250314.data}/scripts/streamlit.cmd +0 -0
  151. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/WHEEL +0 -0
  152. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/entry_points.txt +0 -0
  153. {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250314.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
1
- import{n,r as t,N as i,j as c,b1 as d,b2 as e,L as g}from"./index.pEU90S1o.js";const l=n("iframe",{target:"e3tg43n0"})(({theme:o,disableScrolling:r})=>({width:"100%",colorScheme:"normal",border:"none",padding:o.spacing.none,margin:o.spacing.none,overflow:r?"hidden":void 0}));function s(o){return g(o)||o===""?void 0:o}function m({element:o}){const r=s(o.src),a=i(r)?void 0:s(o.srcdoc);return c(l,{className:"stIFrame","data-testid":"stIFrame",allow:e,disableScrolling:!o.scrolling,src:r,srcDoc:a,height:o.height,scrolling:o.scrolling?"auto":"no",sandbox:d,title:"st.iframe"})}const I=t.memo(m);export{I as default};
1
+ import{n,r as t,N as i,j as c,b1 as d,b2 as e,L as g}from"./index.DaaBud_u.js";const l=n("iframe",{target:"e3tg43n0"})(({theme:o,disableScrolling:r})=>({width:"100%",colorScheme:"normal",border:"none",padding:o.spacing.none,margin:o.spacing.none,overflow:r?"hidden":void 0}));function s(o){return g(o)||o===""?void 0:o}function m({element:o}){const r=s(o.src),a=i(r)?void 0:s(o.srcdoc);return c(l,{className:"stIFrame","data-testid":"stIFrame",allow:e,disableScrolling:!o.scrolling,src:r,srcDoc:a,height:o.height,scrolling:o.scrolling?"auto":"no",sandbox:d,title:"st.iframe"})}const I=t.memo(m);export{I as default};
@@ -1 +1 @@
1
- import{r as i,j as c,br as g,bP as b}from"./index.pEU90S1o.js";import{a as m}from"./useBasicWidgetState.-z6NaxAe.js";import"./FormClearHelper.1VkFJY3v.js";const f=(t,e)=>t.getStringValue(e),p=t=>t.default??null,C=t=>t.value??null,d=(t,e,r,o)=>{e.setStringValue(t,r.value,{fromUi:r.fromUi},o)},P=({element:t,disabled:e,widgetMgr:r,fragmentId:o})=>{var l;const[s,a]=m({getStateFromWidgetMgr:f,getDefaultStateFromProto:p,getCurrStateFromProto:C,updateWidgetMgrState:d,element:t,widgetMgr:r,fragmentId:o}),u=i.useCallback(n=>{a({value:n,fromUi:!0})},[a]);return c(b,{label:t.label,labelVisibility:g((l=t.labelVisibility)==null?void 0:l.value),help:t.help,onChange:u,disabled:e,value:s})},k=i.memo(P);export{k as default};
1
+ import{r as i,j as c,br as g,bP as b}from"./index.DaaBud_u.js";import{a as m}from"./useBasicWidgetState.DJ657I97.js";import"./FormClearHelper.DhbIpC8c.js";const f=(t,e)=>t.getStringValue(e),p=t=>t.default??null,C=t=>t.value??null,d=(t,e,r,o)=>{e.setStringValue(t,r.value,{fromUi:r.fromUi},o)},P=({element:t,disabled:e,widgetMgr:r,fragmentId:o})=>{var l;const[s,a]=m({getStateFromWidgetMgr:f,getDefaultStateFromProto:p,getCurrStateFromProto:C,updateWidgetMgrState:d,element:t,widgetMgr:r,fragmentId:o}),u=i.useCallback(n=>{a({value:n,fromUi:!0})},[a]);return c(b,{label:t.label,labelVisibility:g((l=t.labelVisibility)==null?void 0:l.value),help:t.help,onChange:u,disabled:e,value:s})},k=i.memo(P);export{k as default};
@@ -1 +1 @@
1
- import{r as l,b5 as a,j as e,b6 as d,bp as u,b4 as c,b7 as B,b8 as b}from"./index.pEU90S1o.js";function m(i){const{disabled:o,element:t,widgetMgr:s,fragmentId:r}=i;let n=a.SECONDARY;return t.type==="primary"?n=a.PRIMARY:t.type==="tertiary"&&(n=a.TERTIARY),e(b,{className:"stButton","data-testid":"stButton",children:e(d,{help:t.help,containerWidth:t.useContainerWidth,children:e(u,{kind:n,size:c.SMALL,disabled:o,containerWidth:t.useContainerWidth,onClick:()=>s.setTriggerValue(t,{fromUi:!0},r),children:e(B,{icon:t.icon,label:t.label})})})})}const h=l.memo(m);export{h as default};
1
+ import{r as l,b5 as a,j as e,b6 as d,bp as u,b4 as c,b7 as B,b8 as b}from"./index.DaaBud_u.js";function m(i){const{disabled:o,element:t,widgetMgr:s,fragmentId:r}=i;let n=a.SECONDARY;return t.type==="primary"?n=a.PRIMARY:t.type==="tertiary"&&(n=a.TERTIARY),e(b,{className:"stButton","data-testid":"stButton",children:e(d,{help:t.help,containerWidth:t.useContainerWidth,children:e(u,{kind:n,size:c.SMALL,disabled:o,containerWidth:t.useContainerWidth,onClick:()=>s.setTriggerValue(t,{fromUi:!0},r),children:e(B,{icon:t.icon,label:t.label})})})})}const h=l.memo(m);export{h as default};
@@ -1 +1 @@
1
- import{n as o,bm as S,i as f,r as g,R as l,j as r,B as u,c5 as m,aC as $}from"./index.pEU90S1o.js";const x=o(S,{shouldForwardProp:f,target:"e12gfcky0"})(({theme:e})=>({fontSize:e.fontSizes.sm,width:e.sizes.spinnerSize,height:e.sizes.spinnerSize,borderWidth:e.sizes.spinnerThickness,justifyContents:"center",padding:e.spacing.none,margin:e.spacing.none,borderColor:e.colors.borderColor,borderTopColor:e.colors.secondary,flexGrow:0,flexShrink:0})),y=o("div",{target:"e12gfcky1"})(({theme:e,cache:s})=>({...s?{paddingBottom:e.spacing.lg,background:`linear-gradient(to bottom, ${e.colors.bgColor} 0%, ${e.colors.bgColor} 80%, transparent 100%)`}:null})),T=o("div",{target:"e12gfcky2"})(({theme:e})=>({opacity:.6,fontSize:e.fontSizes.sm})),h=o("div",{target:"e12gfcky3"})(({theme:e})=>({display:"flex",gap:e.spacing.sm,alignItems:"center",width:"100%"})),b=e=>{const s=Math.floor(e/3600),n=Math.floor(e%3600/60),t=e%60;if(s===0&&n===0)return`(${t.toFixed(1)} seconds)`;if(s===0){const d=`${n} minute${n===1?"":"s"}`,p=t===0?"":`, ${t.toFixed(1)} seconds`;return`(${d}${p})`}const i=`${s} hour${s===1?"":"s"}`,a=n===0?"":`, ${n} minute${n===1?"":"s"}`,c=t===0?"":`, ${t.toFixed(1)} seconds`;return`(${i}${a}${c})`};function z({element:e}){const{cache:s,showTime:n}=e,[t,i]=l.useState(0);return l.useEffect(()=>{if(!n)return;const a=setInterval(()=>{i(c=>c+.1)},100);return()=>clearInterval(a)},[n]),r(y,{className:m({stSpinner:!0,stCacheSpinner:s}),"data-testid":"stSpinner",cache:s,children:u(h,{children:[r(x,{}),r($,{source:e.text,allowHTML:!1}),n&&r(T,{children:b(t)})]})})}const k=g.memo(z);export{k as default};
1
+ import{n as o,bm as S,i as f,r as g,R as l,j as r,B as u,c5 as m,aC as $}from"./index.DaaBud_u.js";const x=o(S,{shouldForwardProp:f,target:"e12gfcky0"})(({theme:e})=>({fontSize:e.fontSizes.sm,width:e.sizes.spinnerSize,height:e.sizes.spinnerSize,borderWidth:e.sizes.spinnerThickness,justifyContents:"center",padding:e.spacing.none,margin:e.spacing.none,borderColor:e.colors.borderColor,borderTopColor:e.colors.secondary,flexGrow:0,flexShrink:0})),y=o("div",{target:"e12gfcky1"})(({theme:e,cache:s})=>({...s?{paddingBottom:e.spacing.lg,background:`linear-gradient(to bottom, ${e.colors.bgColor} 0%, ${e.colors.bgColor} 80%, transparent 100%)`}:null})),T=o("div",{target:"e12gfcky2"})(({theme:e})=>({opacity:.6,fontSize:e.fontSizes.sm})),h=o("div",{target:"e12gfcky3"})(({theme:e})=>({display:"flex",gap:e.spacing.sm,alignItems:"center",width:"100%"})),b=e=>{const s=Math.floor(e/3600),n=Math.floor(e%3600/60),t=e%60;if(s===0&&n===0)return`(${t.toFixed(1)} seconds)`;if(s===0){const d=`${n} minute${n===1?"":"s"}`,p=t===0?"":`, ${t.toFixed(1)} seconds`;return`(${d}${p})`}const i=`${s} hour${s===1?"":"s"}`,a=n===0?"":`, ${n} minute${n===1?"":"s"}`,c=t===0?"":`, ${t.toFixed(1)} seconds`;return`(${i}${a}${c})`};function z({element:e}){const{cache:s,showTime:n}=e,[t,i]=l.useState(0);return l.useEffect(()=>{if(!n)return;const a=setInterval(()=>{i(c=>c+.1)},100);return()=>clearInterval(a)},[n]),r(y,{className:m({stSpinner:!0,stCacheSpinner:s}),"data-testid":"stSpinner",cache:s,children:u(h,{children:[r(x,{}),r($,{source:e.text,allowHTML:!1}),n&&r(T,{children:b(t)})]})})}const k=g.memo(z);export{k as default};
@@ -1 +1 @@
1
- import{r as l,E as V,_ as $,n as u,A as ft,y as N,j as n,ba as J,bu as mt,B as z,bp as Q,b5 as Z,bo as U,a$ as vt,bG as yt,bj as wt,bH as I,bs as Ct,F as tt,bh as It,bI as xt,L as D,bl as bt,bk as St}from"./index.pEU90S1o.js";import{g as zt,F as k,C as Ft,I as Et,E as Ut,a as Ht,s as Tt,u as Bt,b as Dt}from"./FileHelper.CTWNHaVI.js";import{I as Lt}from"./InputInstructions.7jABRwB0.js";import{i as Rt}from"./inputUtils.CQWz5UKz.js";import{a as Y}from"./index.D8rVyQy1.js";import{U as et}from"./UploadFileInfo.C-jY39rj.js";import{T as Mt}from"./textarea.BvcErhuX.js";import"./base-input.DjuthXF0.js";var ot=l.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement(V,$({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),l.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),l.createElement("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5a2.5 2.5 0 015 0v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5a2.5 2.5 0 005 0V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"}))});ot.displayName="AttachFile";var nt=l.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement(V,$({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),l.createElement("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}))});nt.displayName="ErrorOutline";var at=l.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement(V,$({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),l.createElement("rect",{width:24,height:24,fill:"none"}),l.createElement("path",{d:"M3 5.51v3.71c0 .46.31.86.76.97L11 12l-7.24 1.81c-.45.11-.76.51-.76.97v3.71c0 .72.73 1.2 1.39.92l15.42-6.49c.82-.34.82-1.5 0-1.84L4.39 4.58C3.73 4.31 3 4.79 3 5.51z"}))});at.displayName="Send";const kt=u("div",{target:"e1togvvn0"})("border:none;position:relative;display:flex;"),Vt=u("div",{target:"e1togvvn1"})(({theme:t,extended:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.widgetBorderColor??t.colors.transparent,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,position:"relative",flexGrow:1,display:"flex",alignItems:"center",paddingLeft:t.spacing.lg,maxHeight:e?"none":t.sizes.minElementHeight,gap:t.spacing.sm,overflow:"hidden",":focus-within":{borderColor:t.colors.primary}})),$t=u("button",{target:"e1togvvn2"})(({theme:t,disabled:e,extended:r})=>{const c=ft(t),[f,p]=c?[t.colors.gray60,t.colors.gray80]:[t.colors.gray80,t.colors.gray40];return{border:"none",backgroundColor:t.colors.transparent,borderTopRightRadius:r?"0":t.radii.chatInput,borderTopLeftRadius:r?t.radii.default:"0",borderBottomRightRadius:t.radii.chatInput,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:t.lineHeights.none,margin:t.spacing.none,padding:t.spacing.sm,color:e?f:p,pointerEvents:"auto","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{backgroundColor:c?t.colors.gray10:t.colors.gray90},"&:hover":{color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{backgroundColor:t.colors.transparent,borderColor:t.colors.transparent,color:t.colors.gray,cursor:"not-allowed"}}}),Nt=u("div",{target:"e1togvvn3"})(({theme:t})=>({display:"flex",alignItems:"flex-end",height:"100%",position:"absolute",right:0,marginBottom:`-${t.sizes.borderWidth}`,pointerEvents:"none"})),At=u("div",{target:"e1togvvn4"})(({theme:t})=>({position:"absolute",bottom:"0px",right:`calc(${t.iconSizes.xl} + 2 * ${t.spacing.sm} + ${t.spacing.sm})`})),Wt=u("div",{target:"ewqvugz0"})(({theme:t,height:e})=>({backgroundColor:t.colors.transparent,position:"absolute",left:0,bottom:0,minHeight:`max(${t.sizes.emptyDropdownHeight}, ${e})`,width:"100%",zIndex:t.zIndices.priority})),qt=u("div",{target:"ewqvugz1"})(({theme:t,height:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.primary,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,color:t.colors.primary,display:"flex",alignItems:"center",justifyContent:"center",height:e,width:"100%",fontWeight:t.fontWeights.bold})),Pt=u("div",{target:"ewqvugz2"})(({theme:t,disabled:e})=>({display:"flex",alignItems:"top",height:"100%",marginTop:`-${t.sizes.borderWidth}`,cursor:e?"not-allowed":"auto"})),Kt=u("div",{target:"ewqvugz3"})(({disabled:t})=>({pointerEvents:t?"none":"auto"})),Ot=u("div",{target:"ewqvugz4"})(({theme:t})=>({marginTop:"0.625em",marginLeft:t.spacing.sm,height:t.spacing.xl,width:t.sizes.borderWidth,backgroundColor:t.colors.fadedText20})),_t=u("div",{target:"ewqvugz5"})(({theme:t})=>({left:0,right:0,lineHeight:t.lineHeights.tight,paddingLeft:t.spacing.sm,paddingRight:t.spacing.sm,overflowX:"auto"})),Xt=u("div",{target:"ewqvugz6"})(({})=>({display:"flex"})),Gt=u("div",{target:"ewqvugz7"})(({})=>({flex:"0 0 auto"})),jt=u("div",{target:"ewqvugz8"})(({theme:t})=>({display:"flex",alignItems:"center",padding:t.spacing.sm,gap:t.spacing.twoXS})),Yt=u("div",{target:"ewqvugz9"})(({theme:t})=>({color:t.colors.fadedText60})),Jt=u("div",{target:"ewqvugz10"})(({theme:t,fileStatus:e})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:e.type==="uploaded"?t.colors.bodyText:t.colors.fadedText60})),Qt=u("div",{target:"ewqvugz11"})(({theme:t})=>({marginRight:t.spacing.md,color:t.colors.fadedText60})),Zt=u("small",{target:"ewqvugz12"})(({theme:t})=>({display:"flex",alignItems:"center",maxHeight:t.sizes.smallElementHeight,color:t.colors.fadedText60,"& :hover":{color:t.colors.bodyText}}));function te({children:t,content:e}){const r=N();return n(mt,{content:e,placement:J.TOP,overrides:{Body:{style:{top:`-${r.sizes.minElementHeight}`}}},children:t})}const ee=({fileInfo:t})=>{const e=N(),{type:r}=t.status;switch(r){case"uploading":return n(yt,{usingCustomTheme:!1,"data-testid":"stChatInputFileIconSpinner",size:"lg",margin:"0",padding:"0"});case"error":return n(te,{content:t.status.errorMessage,children:n(U,{color:e.colors.red,content:nt,size:"lg"})});case"uploaded":return n(U,{content:Et,size:"lg"});default:return vt(r),null}},oe=({fileInfo:t,onDelete:e})=>z(jt,{className:"stChatInputFile","data-testid":"stChatInputFile",children:[n(Yt,{children:n(ee,{fileInfo:t})}),n(Jt,{className:"stChatInputFileName","data-testid":"stChatInputFileName",title:t.name,fileStatus:t.status,children:t.name}),n(Qt,{children:zt(t.size,k.Byte)}),n(Zt,{"data-testid":"stChatInputDeleteBtn",children:n(Q,{onClick:()=>e(t.id),kind:Z.MINIMAL,children:n(U,{content:Ft,size:"lg"})})})]}),ne=({items:t,onDelete:e})=>n(_t,{"data-testid":"stChatUploadedFiles",children:n(Xt,{children:t.map(r=>n(Gt,{children:n(oe,{fileInfo:r,onDelete:e})},r.id))})}),ae=({getNextLocalFileId:t,addFiles:e,updateFile:r,uploadClient:c,element:f,onUploadProgress:p,onUploadComplete:m})=>(x,h)=>{const v=Y.CancelToken.source(),g=new et(h.name,h.size,t(),{type:"uploading",cancelToken:v,progress:1});e([g]),c.uploadFile({formId:"",...f},x.uploadUrl,h,d=>p(d,g.id),v.token).then(()=>m(g.id,x)).catch(d=>{Y.isCancel(d)||r(g.id,g.setStatus({type:"error",errorMessage:d?d.toString():"Unknown error"}))})},re=({acceptMultipleFiles:t,maxFileSize:e,uploadClient:r,uploadFile:c,addFiles:f,getNextLocalFileId:p,deleteExistingFiles:m,onUploadComplete:x})=>(h,v)=>{if(!t&&h.length===0&&v.length>1){const g=v.findIndex(d=>{var y;return((y=d.errors)==null?void 0:y[0].code)===Ut.TooManyFiles});g>=0&&(h.push(v[g].file),v.splice(g,1))}if(!t&&h.length>0&&m(),r.fetchFileURLs(h).then(g=>{wt(g,h).forEach(([d,y])=>{c(d,y)})}).catch(g=>{f(h.map(d=>new et(d.name,d.size,p(),{type:"error",errorMessage:g})))}),v.length>0){const g=v.map(d=>Ht(d,p(),e));f(g)}x()},ie=({getRootProps:t,getInputProps:e,acceptFile:r,disabled:c,theme:f})=>z(Pt,{disabled:c,children:[z(Kt,{"data-testid":"stChatInputFileUploadButton",disabled:c,...t(),children:[n("input",{...e()}),n(Ct,{content:`Upload or drag and drop ${r===I.Multiple?"files":"a file"}`,placement:J.TOP,onMouseEnterDelay:500,children:n(Q,{kind:Z.MINIMAL,disabled:c,children:n(U,{content:ot,size:"lg",color:c?f.colors.fadedText40:f.colors.fadedText60})})})]}),n(Ot,{})]}),se=({getRootProps:t,getInputProps:e,acceptFile:r,inputHeight:c})=>z(tt,{children:[n(Wt,{height:c,...t(),children:n("input",{...e()})}),n(qt,{height:c,children:`Drag and drop ${r===I.Multiple?"files":"a file"} here`})]}),le=6.5,L=1,R=(t,e,r)=>r.map(c=>c.id===t?e:c),M=(t,e)=>e.find(r=>r.id===t);function de({disabled:t,element:e,widgetMgr:r,fragmentId:c,uploadClient:f}){const p=N(),m=l.useRef(null),x=l.useRef(0),h=l.useRef({minHeight:0,maxHeight:0}),[v,g]=It(),[d,y]=l.useState(e.default),[F,A]=l.useState(0),[H,rt]=l.useState(!1),[b,S]=l.useState([]),[E,T]=l.useState(!1),B=l.useMemo(()=>b.some(o=>o.status.type==="uploading")?!1:d!==""||b.length>0,[b,d]),C=xt(e.acceptFile),W=Tt(e.maxUploadSizeMb,k.Megabyte,k.Byte),q=l.useCallback(o=>S(a=>[...a,...o]),[]),P=l.useCallback(o=>{S(a=>{const s=M(o,a);return D(s)?a:(s.status.type==="uploading"&&s.status.cancelToken.cancel(),s.status.type==="uploaded"&&s.status.fileUrls.deleteUrl&&f.deleteFile(s.status.fileUrls.deleteUrl),a.filter(i=>i.id!==o))})},[f]),it=()=>{const o=b.filter(a=>a.status.type==="uploaded").map(a=>{const{name:s,size:i,status:w}=a,{fileId:gt,fileUrls:ht}=w;return new bt({fileId:gt,fileUrls:ht,name:s,size:i})});return new St({uploadedFileInfo:o})},K=()=>x.current++,st=re({acceptMultipleFiles:C===I.Multiple,maxFileSize:W,uploadClient:f,uploadFile:ae({getNextLocalFileId:K,addFiles:q,updateFile:(o,a)=>{S(s=>R(o,a,s))},uploadClient:f,element:e,onUploadProgress:(o,a)=>{S(s=>{const i=M(a,s);if(D(i)||i.status.type!=="uploading")return s;const w=Math.round(o.loaded*100/o.total);return i.status.progress===w?s:R(a,i.setStatus({type:"uploading",cancelToken:i.status.cancelToken,progress:w}),s)})},onUploadComplete:(o,a)=>{S(s=>{const i=M(o,s);return D(i)||i.status.type!=="uploading"?s:R(i.id,i.setStatus({type:"uploaded",fileId:a.fileId,fileUrls:a}),s)})}}),addFiles:q,getNextLocalFileId:K,deleteExistingFiles:()=>b.forEach(o=>P(o.id)),onUploadComplete:()=>{m.current&&m.current.focus()}}),{getRootProps:O,getInputProps:_}=Bt({onDrop:st,multiple:C===I.Multiple,accept:Dt(e.fileType),maxSize:W}),lt=()=>{let o=0;const{current:a}=m;if(a){const s=a.placeholder;a.placeholder="",a.style.height="auto",o=a.scrollHeight,a.placeholder=s,a.style.height=""}return o},X=()=>{if(m.current&&m.current.focus(),!B||t)return;const o={data:d,fileUploaderState:it()};r.setChatInputValue(e,o,{fromUi:!0},c),S([]),y(""),A(0)},dt=o=>{const{metaKey:a,ctrlKey:s,shiftKey:i}=o;Rt(o)&&!i&&!s&&!a&&(o.preventDefault(),X())},ct=o=>{const{value:a}=o.target,{maxChars:s}=e;s!==0&&a.length>s||(y(a),A(lt()))};l.useEffect(()=>{if(e.setValue){e.setValue=!1;const o=e.value||"";y(o)}},[e]),l.useLayoutEffect(()=>{if(m.current){const{offsetHeight:o}=m.current;h.current.minHeight=o,h.current.maxHeight=o*le}},[m]),l.useEffect(()=>{const o=i=>{var w;i.preventDefault(),i.stopPropagation(),!E&&((w=i.dataTransfer)!=null&&w.types.includes("Files"))&&T(!0)},a=i=>{i.preventDefault(),i.stopPropagation(),E&&(i.clientX<=0&&i.clientY<=0||i.clientX>=window.innerWidth&&i.clientY>=window.innerHeight)&&T(!1)},s=i=>{i.preventDefault(),i.stopPropagation(),E&&T(!1)};return window.addEventListener("dragover",o),window.addEventListener("drop",s),window.addEventListener("dragleave",a),()=>{window.removeEventListener("dragover",o),window.removeEventListener("drop",s),window.removeEventListener("dragleave",a)}},[E]),l.useLayoutEffect(()=>{const{minHeight:o}=h.current;rt(F>0&&m.current?Math.abs(F-o)>L:!1)},[F]);const{placeholder:G,maxChars:pt}=e,{maxHeight:j}=h.current,ut=C!==I.None&&E;return z(tt,{children:[C===I.None?null:n(ne,{items:[...b],onDelete:P}),n(kt,{className:"stChatInput","data-testid":"stChatInput",ref:g,children:ut?n(se,{getRootProps:O,getInputProps:_,acceptFile:C,inputHeight:H?`${F+L}px`:p.sizes.minElementHeight}):z(Vt,{extended:H,children:[C===I.None?null:n(ie,{getRootProps:O,getInputProps:_,acceptFile:C,disabled:t,theme:p}),n(Mt,{inputRef:m,value:d,placeholder:G,onChange:ct,onKeyDown:dt,"aria-label":G,disabled:t,rows:1,overrides:{Root:{style:{minHeight:p.sizes.minElementHeight,outline:"none",borderLeftWidth:"0",borderRightWidth:"0",borderTopWidth:"0",borderBottomWidth:"0"}},Input:{props:{"data-testid":"stChatInputTextArea"},style:{lineHeight:p.lineHeights.inputWidget,"::placeholder":{opacity:"0.7"},height:H?`${F+L}px`:"auto",maxHeight:j?`${j}px`:"none",paddingLeft:p.spacing.none,paddingBottom:p.spacing.sm,paddingTop:p.spacing.sm,paddingRight:`calc(${p.iconSizes.xl} + 2 * ${p.spacing.sm} + ${p.spacing.sm})`}}}}),v>p.breakpoints.hideWidgetDetails&&n(At,{children:n(Lt,{dirty:B,value:d,maxLength:pt,type:"chat",inForm:!1})}),n(Nt,{children:n($t,{onClick:X,disabled:!B||t,extended:H,"data-testid":"stChatInputSubmitButton",children:n(U,{content:at,size:"xl",color:"inherit"})})})]})})]})}const ye=l.memo(de);export{ye as default};
1
+ import{r as l,E as V,_ as $,n as u,A as ft,y as N,j as n,ba as J,bu as mt,B as z,bp as Q,b5 as Z,bo as U,a$ as vt,bG as yt,bj as wt,bH as I,bs as Ct,F as tt,bh as It,bI as xt,L as D,bl as bt,bk as St}from"./index.DaaBud_u.js";import{g as zt,F as k,C as Ft,I as Et,E as Ut,a as Ht,s as Tt,u as Bt,b as Dt}from"./FileHelper.jkT1raGU.js";import{I as Lt}from"./InputInstructions.D3RY91P2.js";import{i as Rt}from"./inputUtils.CQWz5UKz.js";import{a as Y}from"./index.D8rVyQy1.js";import{U as et}from"./UploadFileInfo.C-jY39rj.js";import{T as Mt}from"./textarea.ByGG-B4n.js";import"./base-input.Cw4qDIMU.js";var ot=l.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement(V,$({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),l.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),l.createElement("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5a2.5 2.5 0 015 0v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5a2.5 2.5 0 005 0V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"}))});ot.displayName="AttachFile";var nt=l.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement(V,$({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),l.createElement("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}))});nt.displayName="ErrorOutline";var at=l.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement(V,$({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),l.createElement("rect",{width:24,height:24,fill:"none"}),l.createElement("path",{d:"M3 5.51v3.71c0 .46.31.86.76.97L11 12l-7.24 1.81c-.45.11-.76.51-.76.97v3.71c0 .72.73 1.2 1.39.92l15.42-6.49c.82-.34.82-1.5 0-1.84L4.39 4.58C3.73 4.31 3 4.79 3 5.51z"}))});at.displayName="Send";const kt=u("div",{target:"e1togvvn0"})("border:none;position:relative;display:flex;"),Vt=u("div",{target:"e1togvvn1"})(({theme:t,extended:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.widgetBorderColor??t.colors.transparent,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,position:"relative",flexGrow:1,display:"flex",alignItems:"center",paddingLeft:t.spacing.lg,maxHeight:e?"none":t.sizes.minElementHeight,gap:t.spacing.sm,overflow:"hidden",":focus-within":{borderColor:t.colors.primary}})),$t=u("button",{target:"e1togvvn2"})(({theme:t,disabled:e,extended:r})=>{const c=ft(t),[f,p]=c?[t.colors.gray60,t.colors.gray80]:[t.colors.gray80,t.colors.gray40];return{border:"none",backgroundColor:t.colors.transparent,borderTopRightRadius:r?"0":t.radii.chatInput,borderTopLeftRadius:r?t.radii.default:"0",borderBottomRightRadius:t.radii.chatInput,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:t.lineHeights.none,margin:t.spacing.none,padding:t.spacing.sm,color:e?f:p,pointerEvents:"auto","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{backgroundColor:c?t.colors.gray10:t.colors.gray90},"&:hover":{color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{backgroundColor:t.colors.transparent,borderColor:t.colors.transparent,color:t.colors.gray,cursor:"not-allowed"}}}),Nt=u("div",{target:"e1togvvn3"})(({theme:t})=>({display:"flex",alignItems:"flex-end",height:"100%",position:"absolute",right:0,marginBottom:`-${t.sizes.borderWidth}`,pointerEvents:"none"})),At=u("div",{target:"e1togvvn4"})(({theme:t})=>({position:"absolute",bottom:"0px",right:`calc(${t.iconSizes.xl} + 2 * ${t.spacing.sm} + ${t.spacing.sm})`})),Wt=u("div",{target:"ewqvugz0"})(({theme:t,height:e})=>({backgroundColor:t.colors.transparent,position:"absolute",left:0,bottom:0,minHeight:`max(${t.sizes.emptyDropdownHeight}, ${e})`,width:"100%",zIndex:t.zIndices.priority})),qt=u("div",{target:"ewqvugz1"})(({theme:t,height:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.primary,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,color:t.colors.primary,display:"flex",alignItems:"center",justifyContent:"center",height:e,width:"100%",fontWeight:t.fontWeights.bold})),Pt=u("div",{target:"ewqvugz2"})(({theme:t,disabled:e})=>({display:"flex",alignItems:"top",height:"100%",marginTop:`-${t.sizes.borderWidth}`,cursor:e?"not-allowed":"auto"})),Kt=u("div",{target:"ewqvugz3"})(({disabled:t})=>({pointerEvents:t?"none":"auto"})),Ot=u("div",{target:"ewqvugz4"})(({theme:t})=>({marginTop:"0.625em",marginLeft:t.spacing.sm,height:t.spacing.xl,width:t.sizes.borderWidth,backgroundColor:t.colors.fadedText20})),_t=u("div",{target:"ewqvugz5"})(({theme:t})=>({left:0,right:0,lineHeight:t.lineHeights.tight,paddingLeft:t.spacing.sm,paddingRight:t.spacing.sm,overflowX:"auto"})),Xt=u("div",{target:"ewqvugz6"})(({})=>({display:"flex"})),Gt=u("div",{target:"ewqvugz7"})(({})=>({flex:"0 0 auto"})),jt=u("div",{target:"ewqvugz8"})(({theme:t})=>({display:"flex",alignItems:"center",padding:t.spacing.sm,gap:t.spacing.twoXS})),Yt=u("div",{target:"ewqvugz9"})(({theme:t})=>({color:t.colors.fadedText60})),Jt=u("div",{target:"ewqvugz10"})(({theme:t,fileStatus:e})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:e.type==="uploaded"?t.colors.bodyText:t.colors.fadedText60})),Qt=u("div",{target:"ewqvugz11"})(({theme:t})=>({marginRight:t.spacing.md,color:t.colors.fadedText60})),Zt=u("small",{target:"ewqvugz12"})(({theme:t})=>({display:"flex",alignItems:"center",maxHeight:t.sizes.smallElementHeight,color:t.colors.fadedText60,"& :hover":{color:t.colors.bodyText}}));function te({children:t,content:e}){const r=N();return n(mt,{content:e,placement:J.TOP,overrides:{Body:{style:{top:`-${r.sizes.minElementHeight}`}}},children:t})}const ee=({fileInfo:t})=>{const e=N(),{type:r}=t.status;switch(r){case"uploading":return n(yt,{usingCustomTheme:!1,"data-testid":"stChatInputFileIconSpinner",size:"lg",margin:"0",padding:"0"});case"error":return n(te,{content:t.status.errorMessage,children:n(U,{color:e.colors.red,content:nt,size:"lg"})});case"uploaded":return n(U,{content:Et,size:"lg"});default:return vt(r),null}},oe=({fileInfo:t,onDelete:e})=>z(jt,{className:"stChatInputFile","data-testid":"stChatInputFile",children:[n(Yt,{children:n(ee,{fileInfo:t})}),n(Jt,{className:"stChatInputFileName","data-testid":"stChatInputFileName",title:t.name,fileStatus:t.status,children:t.name}),n(Qt,{children:zt(t.size,k.Byte)}),n(Zt,{"data-testid":"stChatInputDeleteBtn",children:n(Q,{onClick:()=>e(t.id),kind:Z.MINIMAL,children:n(U,{content:Ft,size:"lg"})})})]}),ne=({items:t,onDelete:e})=>n(_t,{"data-testid":"stChatUploadedFiles",children:n(Xt,{children:t.map(r=>n(Gt,{children:n(oe,{fileInfo:r,onDelete:e})},r.id))})}),ae=({getNextLocalFileId:t,addFiles:e,updateFile:r,uploadClient:c,element:f,onUploadProgress:p,onUploadComplete:m})=>(x,h)=>{const v=Y.CancelToken.source(),g=new et(h.name,h.size,t(),{type:"uploading",cancelToken:v,progress:1});e([g]),c.uploadFile({formId:"",...f},x.uploadUrl,h,d=>p(d,g.id),v.token).then(()=>m(g.id,x)).catch(d=>{Y.isCancel(d)||r(g.id,g.setStatus({type:"error",errorMessage:d?d.toString():"Unknown error"}))})},re=({acceptMultipleFiles:t,maxFileSize:e,uploadClient:r,uploadFile:c,addFiles:f,getNextLocalFileId:p,deleteExistingFiles:m,onUploadComplete:x})=>(h,v)=>{if(!t&&h.length===0&&v.length>1){const g=v.findIndex(d=>{var y;return((y=d.errors)==null?void 0:y[0].code)===Ut.TooManyFiles});g>=0&&(h.push(v[g].file),v.splice(g,1))}if(!t&&h.length>0&&m(),r.fetchFileURLs(h).then(g=>{wt(g,h).forEach(([d,y])=>{c(d,y)})}).catch(g=>{f(h.map(d=>new et(d.name,d.size,p(),{type:"error",errorMessage:g})))}),v.length>0){const g=v.map(d=>Ht(d,p(),e));f(g)}x()},ie=({getRootProps:t,getInputProps:e,acceptFile:r,disabled:c,theme:f})=>z(Pt,{disabled:c,children:[z(Kt,{"data-testid":"stChatInputFileUploadButton",disabled:c,...t(),children:[n("input",{...e()}),n(Ct,{content:`Upload or drag and drop ${r===I.Multiple?"files":"a file"}`,placement:J.TOP,onMouseEnterDelay:500,children:n(Q,{kind:Z.MINIMAL,disabled:c,children:n(U,{content:ot,size:"lg",color:c?f.colors.fadedText40:f.colors.fadedText60})})})]}),n(Ot,{})]}),se=({getRootProps:t,getInputProps:e,acceptFile:r,inputHeight:c})=>z(tt,{children:[n(Wt,{height:c,...t(),children:n("input",{...e()})}),n(qt,{height:c,children:`Drag and drop ${r===I.Multiple?"files":"a file"} here`})]}),le=6.5,L=1,R=(t,e,r)=>r.map(c=>c.id===t?e:c),M=(t,e)=>e.find(r=>r.id===t);function de({disabled:t,element:e,widgetMgr:r,fragmentId:c,uploadClient:f}){const p=N(),m=l.useRef(null),x=l.useRef(0),h=l.useRef({minHeight:0,maxHeight:0}),[v,g]=It(),[d,y]=l.useState(e.default),[F,A]=l.useState(0),[H,rt]=l.useState(!1),[b,S]=l.useState([]),[E,T]=l.useState(!1),B=l.useMemo(()=>b.some(o=>o.status.type==="uploading")?!1:d!==""||b.length>0,[b,d]),C=xt(e.acceptFile),W=Tt(e.maxUploadSizeMb,k.Megabyte,k.Byte),q=l.useCallback(o=>S(a=>[...a,...o]),[]),P=l.useCallback(o=>{S(a=>{const s=M(o,a);return D(s)?a:(s.status.type==="uploading"&&s.status.cancelToken.cancel(),s.status.type==="uploaded"&&s.status.fileUrls.deleteUrl&&f.deleteFile(s.status.fileUrls.deleteUrl),a.filter(i=>i.id!==o))})},[f]),it=()=>{const o=b.filter(a=>a.status.type==="uploaded").map(a=>{const{name:s,size:i,status:w}=a,{fileId:gt,fileUrls:ht}=w;return new bt({fileId:gt,fileUrls:ht,name:s,size:i})});return new St({uploadedFileInfo:o})},K=()=>x.current++,st=re({acceptMultipleFiles:C===I.Multiple,maxFileSize:W,uploadClient:f,uploadFile:ae({getNextLocalFileId:K,addFiles:q,updateFile:(o,a)=>{S(s=>R(o,a,s))},uploadClient:f,element:e,onUploadProgress:(o,a)=>{S(s=>{const i=M(a,s);if(D(i)||i.status.type!=="uploading")return s;const w=Math.round(o.loaded*100/o.total);return i.status.progress===w?s:R(a,i.setStatus({type:"uploading",cancelToken:i.status.cancelToken,progress:w}),s)})},onUploadComplete:(o,a)=>{S(s=>{const i=M(o,s);return D(i)||i.status.type!=="uploading"?s:R(i.id,i.setStatus({type:"uploaded",fileId:a.fileId,fileUrls:a}),s)})}}),addFiles:q,getNextLocalFileId:K,deleteExistingFiles:()=>b.forEach(o=>P(o.id)),onUploadComplete:()=>{m.current&&m.current.focus()}}),{getRootProps:O,getInputProps:_}=Bt({onDrop:st,multiple:C===I.Multiple,accept:Dt(e.fileType),maxSize:W}),lt=()=>{let o=0;const{current:a}=m;if(a){const s=a.placeholder;a.placeholder="",a.style.height="auto",o=a.scrollHeight,a.placeholder=s,a.style.height=""}return o},X=()=>{if(m.current&&m.current.focus(),!B||t)return;const o={data:d,fileUploaderState:it()};r.setChatInputValue(e,o,{fromUi:!0},c),S([]),y(""),A(0)},dt=o=>{const{metaKey:a,ctrlKey:s,shiftKey:i}=o;Rt(o)&&!i&&!s&&!a&&(o.preventDefault(),X())},ct=o=>{const{value:a}=o.target,{maxChars:s}=e;s!==0&&a.length>s||(y(a),A(lt()))};l.useEffect(()=>{if(e.setValue){e.setValue=!1;const o=e.value||"";y(o)}},[e]),l.useLayoutEffect(()=>{if(m.current){const{offsetHeight:o}=m.current;h.current.minHeight=o,h.current.maxHeight=o*le}},[m]),l.useEffect(()=>{const o=i=>{var w;i.preventDefault(),i.stopPropagation(),!E&&((w=i.dataTransfer)!=null&&w.types.includes("Files"))&&T(!0)},a=i=>{i.preventDefault(),i.stopPropagation(),E&&(i.clientX<=0&&i.clientY<=0||i.clientX>=window.innerWidth&&i.clientY>=window.innerHeight)&&T(!1)},s=i=>{i.preventDefault(),i.stopPropagation(),E&&T(!1)};return window.addEventListener("dragover",o),window.addEventListener("drop",s),window.addEventListener("dragleave",a),()=>{window.removeEventListener("dragover",o),window.removeEventListener("drop",s),window.removeEventListener("dragleave",a)}},[E]),l.useLayoutEffect(()=>{const{minHeight:o}=h.current;rt(F>0&&m.current?Math.abs(F-o)>L:!1)},[F]);const{placeholder:G,maxChars:pt}=e,{maxHeight:j}=h.current,ut=C!==I.None&&E;return z(tt,{children:[C===I.None?null:n(ne,{items:[...b],onDelete:P}),n(kt,{className:"stChatInput","data-testid":"stChatInput",ref:g,children:ut?n(se,{getRootProps:O,getInputProps:_,acceptFile:C,inputHeight:H?`${F+L}px`:p.sizes.minElementHeight}):z(Vt,{extended:H,children:[C===I.None?null:n(ie,{getRootProps:O,getInputProps:_,acceptFile:C,disabled:t,theme:p}),n(Mt,{inputRef:m,value:d,placeholder:G,onChange:ct,onKeyDown:dt,"aria-label":G,disabled:t,rows:1,overrides:{Root:{style:{minHeight:p.sizes.minElementHeight,outline:"none",borderLeftWidth:"0",borderRightWidth:"0",borderTopWidth:"0",borderBottomWidth:"0"}},Input:{props:{"data-testid":"stChatInputTextArea"},style:{lineHeight:p.lineHeights.inputWidget,"::placeholder":{opacity:"0.7"},height:H?`${F+L}px`:"auto",maxHeight:j?`${j}px`:"none",paddingLeft:p.spacing.none,paddingBottom:p.spacing.sm,paddingTop:p.spacing.sm,paddingRight:`calc(${p.iconSizes.xl} + 2 * ${p.spacing.sm} + ${p.spacing.sm})`}}}}),v>p.breakpoints.hideWidgetDetails&&n(At,{children:n(Lt,{dirty:B,value:d,maxLength:pt,type:"chat",inForm:!1})}),n(Nt,{children:n($t,{onClick:X,disabled:!B||t,extended:H,"data-testid":"stChatInputSubmitButton",children:n(U,{content:at,size:"xl",color:"inherit"})})})]})})]})}const ye=l.memo(de);export{ye as default};