import{c as p,r as i,ap as x,j as s,b9 as y,bc as w,bq as t,b8 as S,br as T,bs as v}from"./index-DCNLpqIv.js";const z=p("button",{target:"elibz2u2"})(({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}}),""),R=p("div",{target:"elibz2u1"})(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing.lg,"> span":{marginTop:e.spacing.twoXS}}),""),j=p("div",{target:"elibz2u0"})(({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 C(e){const o=S(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:o?e.colors.gray10:e.colors.gray90,color:e.colors.bodyText,boxShadow:o?"0px 4px 16px rgba(0, 0, 0, 0.16)":"0px 4px 16px rgba(0, 0, 0, 0.7)"}},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 L(e){if(e.length>104){let o=e.replace(/^(.{104}[^\s]*).*/,"$1");return o.length>104&&(o=o.substring(0,104).split(" ").slice(0,-1).join(" ")),o.trim()}return e}function k({body:e,icon:o}){const n=x(),r=L(e),d=e!==r,[a,b]=i.useState(!d),[u,h]=i.useState(0),f=i.useCallback(()=>{b(!a)},[a]),l=i.useMemo(()=>C(n),[n]),c=i.useMemo(()=>s.jsxs(R,{expanded:a,children:[o&&s.jsx(y,{iconValue:o,size:"xl",testid:"stToastDynamicIcon"}),s.jsxs(j,{children:[s.jsx(w,{source:a?e:r,allowHTML:!1,isToast:!0}),d&&s.jsx(z,{"data-testid":"stToastViewButton",onClick:f,children:a?"view less":"view more"})]})]}),[d,a,e,o,r,f]);i.useEffect(()=>{if(n.inSidebar)return;const g=t.info(c,{overrides:{...l}});return h(g),()=>{t.update(g,{overrides:{Body:{style:{display:"none"}}}}),t.clear(g)}},[]),i.useEffect(()=>{t.update(u,{children:c,overrides:{...l}})},[u,c,l]);const m=s.jsx(T,{kind:v.ERROR,body:"Streamlit API Error: `st.toast` cannot be called directly on the sidebar with `st.sidebar.toast`.\n        See our `st.toast` API [docs](https://docs.streamlit.io/develop/api-reference/status/st.toast) for more information."});return s.jsx(s.Fragment,{children:n.inSidebar&&m})}const B=i.memo(k);export{B as default};
