import { j as o } from "../../node_modules/react/jsx-runtime.mjs";
import { Component as i } from "react";
class a extends i {
  constructor() {
    super(), this.transitionTime = 300, this.state = { notices: [] }, this.removeNotice = this.removeNotice.bind(this);
  }
  getNoticeKey() {
    const { notices: t } = this.state;
    return `notice-${(/* @__PURE__ */ new Date()).getTime()}-${t.length}`;
  }
  addNotice(t) {
    const { notices: e } = this.state;
    return t.key = this.getNoticeKey(), e[0] = t, this.setState({ notices: e }), t.duration > 0 && setTimeout(() => {
      this.removeNotice(t.key);
    }, t.duration), () => {
      this.removeNotice(t.key);
    };
  }
  removeNotice(t) {
    const { notices: e } = this.state;
    this.setState({
      notices: e.filter((s) => s.key === t ? (s.onClose && setTimeout(s.onClose, this.transitionTime), !1) : !0)
    });
  }
  render() {
    const { notices: t } = this.state, e = {
      info: "toast_info",
      success: "toast_success",
      error: "toast_error",
      loading: "toast_loading"
    };
    return /* @__PURE__ */ o.jsx("div", { className: "toast", children: t.map((s) => /* @__PURE__ */ o.jsx("div", { className: "toast_bg", children: /* @__PURE__ */ o.jsxs("div", { className: "toast_box", children: [
      /* @__PURE__ */ o.jsx("div", { className: `toast_icon ${e[s.type]}` }),
      /* @__PURE__ */ o.jsx("div", { className: "toast_text", children: s.content })
    ] }) }, s.key)) });
  }
}
const m = a;
export {
  m as default
};
