import { r as i, m as S, j as o, c as f, F as T, H as v, I as a, J as R, K as z, M as j, x as C } from "./index-6wLGsgHc.js";
const H = /* @__PURE__ */ f("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
  }
}), ""), I = /* @__PURE__ */ f("div", {
  target: "elibz2u1"
})(({
  theme: e
}) => ({
  display: "flex",
  flexDirection: "row",
  gap: e.spacing.lg,
  "> span": {
    marginTop: e.spacing.twoXS
  }
}), ""), B = /* @__PURE__ */ f("div", {
  target: "elibz2u0"
})(({
  theme: e
}) => ({
  display: "flex",
  flexDirection: "column",
  gap: e.spacing.sm,
  alignItems: "start",
  // Align text to the center of the icon when only 1 line.
  justifyContent: "center",
  overflow: "hidden",
  minHeight: "100%",
  fontSize: e.fontSizes.sm,
  lineHeight: e.lineHeights.base,
  div: {
    display: "inline-flex"
  }
}), "");
function E(e) {
  const t = j(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,
        // Warnings logged if you use shorthand property here:
        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,
        // Take standard BaseWeb shadow and adjust for dark backgrounds
        boxShadow: t ? "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 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 k({
  element: e
}) {
  const {
    body: t,
    icon: r,
    duration: d
  } = e, n = S(), c = L(t), l = t !== c, [s, b] = i.useState(!l), [m, x] = i.useState(0), h = i.useCallback(() => {
    b(!s);
  }, [s]), g = i.useMemo(() => E(n), [n]), p = i.useMemo(() => /* @__PURE__ */ o.jsxs(I, {
    expanded: s,
    children: [r && /* @__PURE__ */ o.jsx(T, {
      iconValue: r,
      size: "xl",
      testid: "stToastDynamicIcon"
    }), /* @__PURE__ */ o.jsxs(B, {
      children: [/* @__PURE__ */ o.jsx(v, {
        source: s ? t : c,
        allowHTML: !1,
        isToast: !0
      }), l && /* @__PURE__ */ o.jsx(H, {
        "data-testid": "stToastViewButton",
        onClick: h,
        children: s ? "view less" : "view more"
      })]
    })]
  }), [l, s, t, r, c, h]);
  i.useEffect(() => {
    if (n.inSidebar) return;
    const w = C(d) ? d === 0 ? 0 : d * 1e3 : 4e3, u = a.info(p, {
      overrides: {
        ...g
      },
      autoHideDuration: w
    });
    return x(u), () => {
      a.update(u, {
        overrides: {
          Body: {
            style: {
              display: "none"
            }
          }
        }
      }), a.clear(u);
    };
  }, []), i.useEffect(() => {
    a.update(m, {
      children: p,
      overrides: {
        ...g
      }
    });
  }, [m, p, g]);
  const y = /* @__PURE__ */ o.jsx(R, {
    kind: z.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 (
    // Shows error if toast is called on st.sidebar
    /* @__PURE__ */ o.jsx(o.Fragment, {
      children: n.inSidebar && y
    })
  );
}
const M = i.memo(k);
export {
  M as default
};
//# sourceMappingURL=index-B-TfdrsK-UmniOXr4.js.map
