import{o as e}from"./chunk.DuxOD-Sk.js";import{r as t}from"./emotion-is-prop-valid.esm.DV_OErv-.js";import{c as n,l as r,s as i,t as a}from"./emotion-styled.browser.esm.BPUx6WuE.js";import{f as o}from"./getColors.DUygtxH4.js";import{$ as s}from"./protobuf.DyZGXwGk.js";import{St as c,ot as l}from"./src.sR_9Xh2m.js";import{t as u}from"./useEmotionTheme.61kSPILX.js";import{i as d}from"./ErrorElement.BPchO-rz.js";import{t as f}from"./DynamicIcon.BDXbm0Of.js";import{n as p}from"./toaster.B_KSvIoz.js";var m=e(t()),h=a(`button`,{target:`e1a81sb30`})(({theme:e})=>({fontSize:e.fontSizes.sm,lineHeight:e.lineHeights.base,color:e.colors.fadedText60,backgroundColor:e.colors.transparent,fontFamily:`inherit`,margin:e.spacing.none,border:`none`,boxShadow:`none`,padding:e.spacing.none,"&:hover, &:active, &:focus":{border:`none`,outline:`none`,boxShadow:`none`},"&:hover":{color:e.colors.primary}})),g=a(`div`,{target:`e1a81sb31`})(({theme:e})=>({display:`flex`,flexDirection:`row`,gap:e.spacing.lg,"> span":{marginTop:e.spacing.twoXS}})),_=a(`div`,{target:`e1a81sb32`})(({theme:e})=>({display:`flex`,flexDirection:`column`,gap:e.spacing.sm,alignItems:`start`,justifyContent:`center`,overflow:`hidden`,minHeight:`100%`,fontSize:e.fontSizes.sm,lineHeight:e.lineHeights.base,div:{display:`inline-flex`}}));function v(e){let t=o(e);return{Body:{props:{"data-testid":`stToast`,className:`stToast`},style:{display:`flex`,flexDirection:`row`,gap:e.spacing.md,width:e.sizes.toastWidth,marginTop:e.spacing.sm,borderTopLeftRadius:e.radii.default,borderTopRightRadius:e.radii.default,borderBottomLeftRadius:e.radii.default,borderBottomRightRadius:e.radii.default,paddingTop:e.spacing.lg,paddingBottom:e.spacing.lg,paddingLeft:e.spacing.twoXL,paddingRight:e.spacing.twoXL,backgroundColor:e.colors.bgColor,filter:t?`brightness(0.98)`:`brightness(1.2)`,color:e.colors.bodyText,boxShadow:e.shadows.popover}},CloseIcon:{style:{color:e.colors.fadedText40,width:e.fontSizes.lg,height:e.fontSizes.lg,marginRight:`calc(-1 * ${e.spacing.lg} / 2)`,":hover":{color:e.colors.bodyText}}}}}function y(e){if(e.length>104){let t=e.replace(/^(.{104}[^\s]*).*/,`$1`);return t.length>104&&(t=t.substring(0,104).split(` `).slice(0,-1).join(` `)),t.trim()}return e}function b({element:e}){let{body:t,icon:a,duration:o}=e,b=u(),x=y(t),S=t!==x,[C,w]=(0,m.useState)(!S),[T,E]=(0,m.useState)(0),D=(0,m.useCallback)(()=>{w(!C)},[C]),O=(0,m.useMemo)(()=>v(b),[b]),k=(0,m.useMemo)(()=>r(g,{expanded:C,children:[a&&n(f,{iconValue:a,size:`xl`,testid:`stToastDynamicIcon`}),r(_,{children:[n(c,{source:C?t:x,allowHTML:!1,isToast:!0}),S&&n(h,{"data-testid":`stToastViewButton`,onClick:D,children:C?`view less`:`view more`})]})]}),[S,C,t,a,x,D]);(0,m.useEffect)(()=>{if(b.inSidebar)return;let e=s(o)?o===0?0:o*1e3:4e3,t=p.info(k,{overrides:{...O},autoHideDuration:e});return E(t),()=>{p.update(t,{overrides:{Body:{style:{display:`none`}}}}),p.clear(t)}},[]),(0,m.useEffect)(()=>{p.update(T,{children:k,overrides:{...O}})},[T,k,O]);let A=n(l,{kind:d.ERROR,body:"Streamlit API Error: `st.toast` cannot be called directly on the sidebar with `st.sidebar.toast`. See our `st.toast` API [docs](https://docs.streamlit.io/develop/api-reference/status/st.toast) for more information."});return n(i,{children:b.inSidebar&&A})}var x=(0,m.memo)(b);export{x as default,y as shortenMessage};