import{n as p,r as s,y as T,B as x,j as i,D as w,aC as h,aP as r,aQ as v,aR as m,F as k,A as R}from"./index.DmrHunjf.js";const z=p("button",{target:"e1rpgzpk0"})(({theme:t})=>({fontSize:t.fontSizes.sm,lineHeight:t.lineHeights.base,color:t.colors.fadedText60,backgroundColor:t.colors.transparent,fontFamily:"inherit",margin:t.spacing.none,border:"none",boxShadow:"none",padding:t.spacing.none,"&:hover, &:active, &:focus":{border:"none",outline:"none",boxShadow:"none"},"&:hover":{color:t.colors.primary}})),L=p("div",{target:"e1rpgzpk1"})(({theme:t})=>({display:"flex",flexDirection:"row",gap:t.spacing.lg,"> span":{marginTop:t.spacing.twoXS}})),B=p("div",{target:"e1rpgzpk3"})(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing.sm,alignItems:"start",justifyContent:"center",overflow:"hidden",minHeight:"100%",fontSize:t.fontSizes.sm,lineHeight:t.lineHeights.base,div:{display:"inline-flex"}}));function C(t){const a=R(t);return{Body:{props:{"data-testid":"stToast",className:"stToast"},style:{display:"flex",flexDirection:"row",gap:t.spacing.md,width:t.sizes.toastWidth,marginTop:t.spacing.sm,borderTopLeftRadius:t.radii.default,borderTopRightRadius:t.radii.default,borderBottomLeftRadius:t.radii.default,borderBottomRightRadius:t.radii.default,paddingTop:t.spacing.lg,paddingBottom:t.spacing.lg,paddingLeft:t.spacing.twoXL,paddingRight:t.spacing.twoXL,backgroundColor:a?t.colors.gray10:t.colors.gray90,color:t.colors.bodyText,boxShadow:a?"0px 4px 16px rgba(0, 0, 0, 0.16)":"0px 4px 16px rgba(0, 0, 0, 0.7)"}},CloseIcon:{style:{color:t.colors.fadedText40,width:t.fontSizes.lg,height:t.fontSizes.lg,marginRight:`calc(-1 * ${t.spacing.lg} / 2)`,":hover":{color:t.colors.bodyText}}}}}function E(t){if(t.length>104){let o=t.replace(/^(.{104}[^\s]*).*/,"$1");return o.length>104&&(o=o.substring(0,104).split(" ").slice(0,-1).join(" ")),o.trim()}return t}function D({body:t,icon:a}){const o=T(),n=E(t),d=t!==n,[e,y]=s.useState(!d),[u,b]=s.useState(0),f=s.useCallback(()=>{y(!e)},[e]),c=s.useMemo(()=>C(o),[o]),l=s.useMemo(()=>x(L,{expanded:e,children:[a&&i(w,{iconValue:a,size:"xl",testid:"stToastDynamicIcon"}),x(B,{children:[i(h,{source:e?t:n,allowHTML:!1,isToast:!0}),d&&i(z,{"data-testid":"stToastViewButton",onClick:f,children:e?"view less":"view more"})]})]}),[d,e,t,a,n,f]);s.useEffect(()=>{if(o.inSidebar)return;const g=r.info(l,{overrides:{...c}});return b(g),()=>{r.update(g,{overrides:{Body:{style:{transitionDuration:0}}}}),r.clear(g)}},[]),s.useEffect(()=>{r.update(u,{children:l,overrides:{...c}})},[u,l,c]);const S=i(m,{kind:v.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 i(k,{children:o.inSidebar&&S})}const I=s.memo(D);export{I as default};
