@lanaco/lnc-react-ui
Version:
React component library
799 lines (798 loc) • 24.1 kB
JavaScript
import S, { createElement as B, useRef as J, useLayoutEffect as Be, useEffect as z, useReducer as ye, isValidElement as Y, cloneElement as ue, useState as Te } from "react";
import { r as _e } from "./index-B2yaYXE2.js";
function Ce(e) {
var t, n, o = "";
if (typeof e == "string" || typeof e == "number") o += e;
else if (typeof e == "object") if (Array.isArray(e)) for (t = 0; t < e.length; t++) e[t] && (n = Ce(e[t])) && (o && (o += " "), o += n);
else for (t in e) e[t] && (o && (o += " "), o += t);
return o;
}
function H() {
for (var e, t, n = 0, o = ""; n < arguments.length; ) (e = arguments[n++]) && (t = Ce(e)) && (o && (o += " "), o += t);
return o;
}
function _() {
return _ = Object.assign || function(e) {
for (var t = 1; t < arguments.length; t++) {
var n = arguments[t];
for (var o in n)
Object.prototype.hasOwnProperty.call(n, o) && (e[o] = n[o]);
}
return e;
}, _.apply(this, arguments);
}
function Ee(e, t) {
if (e == null) return {};
var n = {}, o = Object.keys(e), s, u;
for (u = 0; u < o.length; u++)
s = o[u], !(t.indexOf(s) >= 0) && (n[s] = e[s]);
return n;
}
function Z(e) {
return typeof e == "number" && !isNaN(e);
}
function $(e) {
return typeof e == "boolean";
}
function U(e) {
return typeof e == "string";
}
function D(e) {
return typeof e == "function";
}
function te(e) {
return U(e) || D(e) ? e : null;
}
function ce(e) {
return e === 0 || e;
}
function Se(e, t) {
return e === !1 || Z(e) && e > 0 ? e : t;
}
var Ie = !!(typeof window < "u" && window.document && window.document.createElement);
function le(e) {
return Y(e) || U(e) || D(e) || Z(e);
}
var Oe = {
TOP_LEFT: "top-left",
TOP_RIGHT: "top-right",
TOP_CENTER: "top-center",
BOTTOM_LEFT: "bottom-left",
BOTTOM_RIGHT: "bottom-right",
BOTTOM_CENTER: "bottom-center"
}, A = {
INFO: "info",
SUCCESS: "success",
WARNING: "warning",
ERROR: "error",
DEFAULT: "default"
};
function we(e, t, n) {
n === void 0 && (n = 300);
var o = e.scrollHeight, s = e.style;
requestAnimationFrame(function() {
s.minHeight = "initial", s.height = o + "px", s.transition = "all " + n + "ms", requestAnimationFrame(function() {
s.height = "0", s.padding = "0", s.margin = "0", setTimeout(t, n);
});
});
}
function ke(e) {
var t = e.enter, n = e.exit, o = e.appendPosition, s = o === void 0 ? !1 : o, u = e.collapse, g = u === void 0 ? !0 : u, v = e.collapseDuration, r = v === void 0 ? 300 : v;
return function(l) {
var b = l.children, C = l.position, T = l.preventExitTransition, P = l.done, E = l.nodeRef, N = l.isIn, R = s ? t + "--" + C : t, L = s ? n + "--" + C : n, F = J(), i = J(
0
/* Enter */
);
Be(function() {
c();
}, []), z(function() {
N || (T ? I() : y());
}, [N]);
function c() {
var a = E.current;
F.current = a.className, a.className += " " + R, a.addEventListener("animationend", m);
}
function m(a) {
if (a.target === E.current) {
var f = E.current;
f.removeEventListener("animationend", m), i.current === 0 && (f.className = F.current);
}
}
function y() {
i.current = 1;
var a = E.current;
a.className += " " + L, a.addEventListener("animationend", I);
}
function I() {
var a = E.current;
a.removeEventListener("animationend", I), g ? we(a, P, r) : P();
}
return S.createElement(S.Fragment, null, b);
};
}
var w = {
list: /* @__PURE__ */ new Map(),
emitQueue: /* @__PURE__ */ new Map(),
on: function(t, n) {
return this.list.has(t) || this.list.set(t, []), this.list.get(t).push(n), this;
},
off: function(t, n) {
if (n) {
var o = this.list.get(t).filter(function(s) {
return s !== n;
});
return this.list.set(t, o), this;
}
return this.list.delete(t), this;
},
cancelEmit: function(t) {
var n = this.emitQueue.get(t);
return n && (n.forEach(clearTimeout), this.emitQueue.delete(t)), this;
},
/**
* Enqueue the event at the end of the call stack
* Doing so let the user call toast as follow:
* toast('1')
* toast('2')
* toast('3')
* Without setTimemout the code above will not work
*/
emit: function(t) {
for (var n = this, o = arguments.length, s = new Array(o > 1 ? o - 1 : 0), u = 1; u < o; u++)
s[u - 1] = arguments[u];
this.list.has(t) && this.list.get(t).forEach(function(g) {
var v = setTimeout(function() {
g.apply(void 0, s);
}, 0);
n.emitQueue.has(t) || n.emitQueue.set(t, []), n.emitQueue.get(t).push(v);
});
}
};
function q(e, t) {
t === void 0 && (t = !1);
var n = J(e);
return z(function() {
t && (n.current = e);
}), n.current;
}
function Ae(e, t) {
switch (t.type) {
case 0:
return [].concat(e, [t.toastId]).filter(function(n) {
return n !== t.staleId;
});
case 1:
return ce(t.toastId) ? e.filter(function(n) {
return n !== t.toastId;
}) : [];
}
}
var Fe = ["delay", "staleId"];
function Me(e) {
var t = ye(function(i) {
return i + 1;
}, 0), n = t[1], o = ye(Ae, []), s = o[0], u = o[1], g = J(null), v = q(0), r = q([]), h = q({}), l = q({
toastKey: 1,
displayedToast: 0,
props: e,
containerId: null,
isToastActive: b,
getToast: function(c) {
return h[c] || null;
}
});
z(function() {
return l.containerId = e.containerId, w.cancelEmit(
3
/* WillUnmount */
).on(
0,
N
).on(
1,
function(i) {
return g.current && T(i);
}
).on(
5,
C
).emit(
2,
l
), function() {
return w.emit(
3,
l
);
};
}, []), z(function() {
l.isToastActive = b, l.displayedToast = s.length, w.emit(
4,
s.length,
e.containerId
);
}, [s]), z(function() {
l.props = e;
});
function b(i) {
return s.indexOf(i) !== -1;
}
function C(i) {
var c = i.containerId, m = l.props.limit;
m && (!c || l.containerId === c) && (v -= r.length, r = []);
}
function T(i) {
u({
type: 1,
toastId: i
});
}
function P() {
var i = r.shift(), c = i.toastContent, m = i.toastProps, y = i.staleId;
R(c, m, y);
}
function E(i) {
var c = i.containerId, m = i.toastId, y = i.updateId;
return !!(!g.current || l.props.enableMultiContainer && c !== l.props.containerId || h[m] && y == null);
}
function N(i, c) {
var m, y = c.delay, I = c.staleId, a = Ee(c, Fe);
if (!(!le(i) || E(a))) {
var f = a.toastId, x = a.updateId, W = a.data, d = l.props, k = function() {
return T(f);
}, K = a.updateId == null;
K && v++;
var O = {
toastId: f,
updateId: x,
isLoading: a.isLoading,
theme: a.theme || d.theme,
icon: (m = a.icon) != null ? m : d.icon,
isIn: !1,
key: a.key || l.toastKey++,
type: a.type,
closeToast: k,
closeButton: a.closeButton,
rtl: d.rtl,
position: a.position || d.position,
transition: a.transition || d.transition,
className: te(a.className || d.toastClassName),
bodyClassName: te(a.bodyClassName || d.bodyClassName),
style: a.style || d.toastStyle,
bodyStyle: a.bodyStyle || d.bodyStyle,
onClick: a.onClick || d.onClick,
pauseOnHover: $(a.pauseOnHover) ? a.pauseOnHover : d.pauseOnHover,
pauseOnFocusLoss: $(a.pauseOnFocusLoss) ? a.pauseOnFocusLoss : d.pauseOnFocusLoss,
draggable: $(a.draggable) ? a.draggable : d.draggable,
draggablePercent: Z(a.draggablePercent) ? a.draggablePercent : d.draggablePercent,
draggableDirection: a.draggableDirection || d.draggableDirection,
closeOnClick: $(a.closeOnClick) ? a.closeOnClick : d.closeOnClick,
progressClassName: te(a.progressClassName || d.progressClassName),
progressStyle: a.progressStyle || d.progressStyle,
autoClose: a.isLoading ? !1 : Se(a.autoClose, d.autoClose),
hideProgressBar: $(a.hideProgressBar) ? a.hideProgressBar : d.hideProgressBar,
progress: a.progress,
role: U(a.role) ? a.role : d.role,
deleteToast: function() {
L(f);
}
};
D(a.onOpen) && (O.onOpen = a.onOpen), D(a.onClose) && (O.onClose = a.onClose), O.draggableDirection === "y" && O.draggablePercent === 80 && (O.draggablePercent *= 1.5);
var M = d.closeButton;
a.closeButton === !1 || le(a.closeButton) ? M = a.closeButton : a.closeButton === !0 && (M = le(d.closeButton) ? d.closeButton : !0), O.closeButton = M;
var j = i;
Y(i) && !U(i.type) ? j = ue(i, {
closeToast: k,
toastProps: O,
data: W
}) : D(i) && (j = i({
closeToast: k,
toastProps: O,
data: W
})), d.limit && d.limit > 0 && v > d.limit && K ? r.push({
toastContent: j,
toastProps: O,
staleId: I
}) : Z(y) && y > 0 ? setTimeout(function() {
R(j, O, I);
}, y) : R(j, O, I);
}
}
function R(i, c, m) {
var y = c.toastId;
m && delete h[m], h[y] = {
content: i,
props: c
}, u({
type: 0,
toastId: y,
staleId: m
});
}
function L(i) {
delete h[i];
var c = r.length;
if (v = ce(i) ? v - 1 : v - l.displayedToast, v < 0 && (v = 0), c > 0) {
var m = ce(i) ? 1 : l.props.limit;
if (c === 1 || m === 1)
l.displayedToast++, P();
else {
var y = m > c ? c : m;
l.displayedToast = y;
for (var I = 0; I < y; I++)
P();
}
} else
n();
}
function F(i) {
for (var c = {}, m = e.newestOnTop ? Object.keys(h).reverse() : Object.keys(h), y = 0; y < m.length; y++) {
var I = h[m[y]], a = I.props.position;
c[a] || (c[a] = []), c[a].push(I);
}
return Object.keys(c).map(function(f) {
return i(f, c[f]);
});
}
return {
getToastToRender: F,
collection: h,
containerRef: g,
isToastActive: b
};
}
function he(e) {
return e.targetTouches && e.targetTouches.length >= 1 ? e.targetTouches[0].clientX : e.clientX;
}
function pe(e) {
return e.targetTouches && e.targetTouches.length >= 1 ? e.targetTouches[0].clientY : e.clientY;
}
function je(e) {
var t = Te(!0), n = t[0], o = t[1], s = Te(!1), u = s[0], g = s[1], v = J(null), r = q({
start: 0,
x: 0,
y: 0,
delta: 0,
removalDistance: 0,
canCloseOnClick: !0,
canDrag: !1,
boundingRect: null
}), h = q(e, !0), l = e.autoClose, b = e.pauseOnHover, C = e.closeToast, T = e.onClick, P = e.closeOnClick;
z(function() {
return D(e.onOpen) && e.onOpen(Y(e.children) && e.children.props), function() {
D(h.onClose) && h.onClose(Y(h.children) && h.children.props);
};
}, []), z(function() {
return e.draggable && c(), function() {
e.draggable && m();
};
}, [e.draggable]), z(function() {
return e.pauseOnFocusLoss && F(), function() {
e.pauseOnFocusLoss && i();
};
}, [e.pauseOnFocusLoss]);
function E(f) {
if (e.draggable) {
var x = v.current;
r.canCloseOnClick = !0, r.canDrag = !0, r.boundingRect = x.getBoundingClientRect(), x.style.transition = "", r.x = he(f.nativeEvent), r.y = pe(f.nativeEvent), e.draggableDirection === "x" ? (r.start = r.x, r.removalDistance = x.offsetWidth * (e.draggablePercent / 100)) : (r.start = r.y, r.removalDistance = x.offsetHeight * (e.draggablePercent / 100));
}
}
function N() {
if (r.boundingRect) {
var f = r.boundingRect, x = f.top, W = f.bottom, d = f.left, k = f.right;
e.pauseOnHover && r.x >= d && r.x <= k && r.y >= x && r.y <= W ? L() : R();
}
}
function R() {
o(!0);
}
function L() {
o(!1);
}
function F() {
document.hasFocus() || L(), window.addEventListener("focus", R), window.addEventListener("blur", L);
}
function i() {
window.removeEventListener("focus", R), window.removeEventListener("blur", L);
}
function c() {
document.addEventListener("mousemove", y), document.addEventListener("mouseup", I), document.addEventListener("touchmove", y), document.addEventListener("touchend", I);
}
function m() {
document.removeEventListener("mousemove", y), document.removeEventListener("mouseup", I), document.removeEventListener("touchmove", y), document.removeEventListener("touchend", I);
}
function y(f) {
if (r.canDrag) {
f.preventDefault();
var x = v.current;
n && L(), r.x = he(f), r.y = pe(f), e.draggableDirection === "x" ? r.delta = r.x - r.start : r.delta = r.y - r.start, r.start !== r.x && (r.canCloseOnClick = !1), x.style.transform = "translate" + e.draggableDirection + "(" + r.delta + "px)", x.style.opacity = "" + (1 - Math.abs(r.delta / r.removalDistance));
}
}
function I() {
var f = v.current;
if (r.canDrag) {
if (r.canDrag = !1, Math.abs(r.delta) > r.removalDistance) {
g(!0), e.closeToast();
return;
}
f.style.transition = "transform 0.2s, opacity 0.2s", f.style.transform = "translate" + e.draggableDirection + "(0)", f.style.opacity = "1";
}
}
var a = {
onMouseDown: E,
onTouchStart: E,
onMouseUp: N,
onTouchEnd: N
};
return l && b && (a.onMouseEnter = L, a.onMouseLeave = R), P && (a.onClick = function(f) {
T && T(f), r.canCloseOnClick && C();
}), {
playToast: R,
pauseToast: L,
isRunning: n,
preventExitTransition: u,
toastRef: v,
eventHandlers: a
};
}
function Ne(e) {
var t = e.closeToast, n = e.theme, o = e.ariaLabel, s = o === void 0 ? "close" : o;
return B("button", {
className: "Toastify__close-button Toastify__close-button--" + n,
type: "button",
onClick: function(g) {
g.stopPropagation(), t(g);
},
"aria-label": s
}, B("svg", {
"aria-hidden": "true",
viewBox: "0 0 14 16"
}, B("path", {
fillRule: "evenodd",
d: "M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"
})));
}
function Pe(e) {
var t, n, o = e.delay, s = e.isRunning, u = e.closeToast, g = e.type, v = e.hide, r = e.className, h = e.style, l = e.controlledProgress, b = e.progress, C = e.rtl, T = e.isIn, P = e.theme, E = _({}, h, {
animationDuration: o + "ms",
animationPlayState: s ? "running" : "paused",
opacity: v ? 0 : 1
});
l && (E.transform = "scaleX(" + b + ")");
var N = H("Toastify__progress-bar", l ? "Toastify__progress-bar--controlled" : "Toastify__progress-bar--animated", "Toastify__progress-bar-theme--" + P, "Toastify__progress-bar--" + g, (t = {}, t["Toastify__progress-bar--rtl"] = C, t)), R = D(r) ? r({
rtl: C,
type: g,
defaultClassName: N
}) : H(N, r), L = (n = {}, n[l && b >= 1 ? "onTransitionEnd" : "onAnimationEnd"] = l && b < 1 ? null : function() {
T && u();
}, n);
return B("div", Object.assign({
role: "progressbar",
"aria-hidden": v ? "true" : "false",
"aria-label": "notification timer",
className: R,
style: E
}, L));
}
Pe.defaultProps = {
type: A.DEFAULT,
hide: !1
};
var He = ["theme", "type"], ne = function(t) {
var n = t.theme, o = t.type, s = Ee(t, He);
return S.createElement("svg", Object.assign({
viewBox: "0 0 24 24",
width: "100%",
height: "100%",
fill: n === "colored" ? "currentColor" : "var(--toastify-icon-color-" + o + ")"
}, s));
};
function ze(e) {
return S.createElement(ne, Object.assign({}, e), S.createElement("path", {
d: "M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"
}));
}
function Ue(e) {
return S.createElement(ne, Object.assign({}, e), S.createElement("path", {
d: "M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"
}));
}
function Qe(e) {
return S.createElement(ne, Object.assign({}, e), S.createElement("path", {
d: "M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"
}));
}
function We(e) {
return S.createElement(ne, Object.assign({}, e), S.createElement("path", {
d: "M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"
}));
}
function qe() {
return S.createElement("div", {
className: "Toastify__spinner"
});
}
var be = {
info: Ue,
warning: ze,
success: Qe,
error: We,
spinner: qe
}, Ge = function(t) {
var n, o, s = je(t), u = s.isRunning, g = s.preventExitTransition, v = s.toastRef, r = s.eventHandlers, h = t.closeButton, l = t.children, b = t.autoClose, C = t.onClick, T = t.type, P = t.hideProgressBar, E = t.closeToast, N = t.transition, R = t.position, L = t.className, F = t.style, i = t.bodyClassName, c = t.bodyStyle, m = t.progressClassName, y = t.progressStyle, I = t.updateId, a = t.role, f = t.progress, x = t.rtl, W = t.toastId, d = t.deleteToast, k = t.isIn, K = t.isLoading, O = t.icon, M = t.theme, j = H("Toastify__toast", "Toastify__toast-theme--" + M, "Toastify__toast--" + T, (n = {}, n["Toastify__toast--rtl"] = x, n)), re = D(L) ? L({
rtl: x,
position: R,
type: T,
defaultClassName: j
}) : H(j, L), se = !!f, ge = be[T], ie = {
theme: M,
type: T
}, Q = ge && ge(ie);
O === !1 ? Q = void 0 : D(O) ? Q = O(ie) : Y(O) ? Q = ue(O, ie) : U(O) ? Q = O : K && (Q = be.spinner());
function xe(X) {
if (X) {
var me = {
closeToast: E,
type: T,
theme: M
};
if (D(X)) return X(me);
if (Y(X)) return ue(X, me);
}
}
return B(N, {
isIn: k,
done: d,
position: R,
preventExitTransition: g,
nodeRef: v
}, B("div", Object.assign({
id: W,
onClick: C,
className: re
}, r, {
style: F,
ref: v
}), B("div", Object.assign({}, k && {
role: a
}, {
className: D(i) ? i({
type: T
}) : H("Toastify__toast-body", i),
style: c
}), Q && B("div", {
className: H("Toastify__toast-icon", (o = {}, o["Toastify--animate-icon Toastify__zoom-enter"] = !K, o))
}, Q), B("div", null, l)), xe(h), (b || se) && B(Pe, Object.assign({}, I && !se ? {
key: "pb-" + I
} : {}, {
rtl: x,
theme: M,
delay: b,
isRunning: u,
isIn: k,
closeToast: E,
hide: P,
type: T,
style: y,
className: m,
controlledProgress: se,
progress: f
}))));
}, Ye = /* @__PURE__ */ ke({
enter: "Toastify--animate Toastify__bounce-enter",
exit: "Toastify--animate Toastify__bounce-exit",
appendPosition: !0
}), Le = function(t) {
var n = Me(t), o = n.getToastToRender, s = n.containerRef, u = n.isToastActive, g = t.className, v = t.style, r = t.rtl, h = t.containerId;
function l(b) {
var C, T = H("Toastify__toast-container", "Toastify__toast-container--" + b, (C = {}, C["Toastify__toast-container--rtl"] = r, C));
return D(g) ? g({
position: b,
rtl: r,
defaultClassName: T
}) : H(T, te(g));
}
return B("div", {
ref: s,
className: "Toastify",
id: h
}, o(function(b, C) {
var T = C.length === 0 ? _({}, v, {
pointerEvents: "none"
}) : _({}, v);
return B("div", {
className: l(b),
style: T,
key: "container-" + b
}, C.map(function(P) {
var E = P.content, N = P.props;
return B(Ge, Object.assign({}, N, {
isIn: u(N.toastId),
key: "toast-" + N.key,
closeButton: N.closeButton === !0 ? Ne : N.closeButton
}), E);
}));
}));
};
Le.defaultProps = {
position: Oe.TOP_RIGHT,
transition: Ye,
rtl: !1,
autoClose: 5e3,
hideProgressBar: !1,
closeButton: Ne,
pauseOnHover: !0,
pauseOnFocusLoss: !0,
closeOnClick: !0,
newestOnTop: !1,
draggable: !0,
draggablePercent: 80,
draggableDirection: "x",
role: "alert",
theme: "light"
};
var G = /* @__PURE__ */ new Map(), de, V, Re, fe = [], ve = !1;
function Ke() {
return G.size > 0;
}
function Xe(e, t) {
var n = t.containerId, o = G.get(n || de);
return o ? o.getToast(e) : null;
}
function De() {
return Math.random().toString(36).substr(2, 9);
}
function $e(e) {
return e && (U(e.toastId) || Z(e.toastId)) ? e.toastId : De();
}
function ee(e, t) {
return Ke() ? w.emit(
0,
e,
t
) : (fe.push({
content: e,
options: t
}), ve && Ie && (ve = !1, V = document.createElement("div"), document.body.appendChild(V), _e.render(B(Le, Object.assign({}, Re)), V))), t.toastId;
}
function ae(e, t) {
return _({}, t, {
type: t && t.type || e,
toastId: $e(t)
});
}
var oe = function(t) {
return function(n, o) {
return ee(n, ae(t, o));
};
}, p = function(t, n) {
return ee(t, ae(A.DEFAULT, n));
};
p.loading = function(e, t) {
return ee(e, ae(A.DEFAULT, _({
isLoading: !0,
autoClose: !1,
closeOnClick: !1,
closeButton: !1,
draggable: !1
}, t)));
};
function Ve(e, t, n) {
var o = t.pending, s = t.error, u = t.success, g;
o && (g = U(o) ? p.loading(o, n) : p.loading(o.render, _({}, n, o)));
var v = {
isLoading: null,
autoClose: null,
closeOnClick: null,
closeButton: null,
draggable: null
}, r = function(b, C, T) {
var P = _({
type: b
}, v, n, {
data: T
}), E = U(C) ? {
render: C
} : C;
return g ? p.update(g, _({}, P, E)) : p(E.render, _({}, P, E)), T;
}, h = D(e) ? e() : e;
return h.then(function(l) {
return u && r("success", u, l);
}).catch(function(l) {
return s && r("error", s, l);
}), h;
}
p.promise = Ve;
p.success = /* @__PURE__ */ oe(A.SUCCESS);
p.info = /* @__PURE__ */ oe(A.INFO);
p.error = /* @__PURE__ */ oe(A.ERROR);
p.warning = /* @__PURE__ */ oe(A.WARNING);
p.warn = p.warning;
p.dark = function(e, t) {
return ee(e, ae(A.DEFAULT, _({
theme: "dark"
}, t)));
};
p.dismiss = function(e) {
return w.emit(
1,
e
);
};
p.clearWaitingQueue = function(e) {
return e === void 0 && (e = {}), w.emit(
5,
e
);
};
p.isActive = function(e) {
var t = !1;
return G.forEach(function(n) {
n.isToastActive && n.isToastActive(e) && (t = !0);
}), t;
};
p.update = function(e, t) {
t === void 0 && (t = {}), setTimeout(function() {
var n = Xe(e, t);
if (n) {
var o = n.props, s = n.content, u = _({}, o, t, {
toastId: t.toastId || e,
updateId: De()
});
u.toastId !== e && (u.staleId = e);
var g = u.render || s;
delete u.render, ee(g, u);
}
}, 0);
};
p.done = function(e) {
p.update(e, {
progress: 1
});
};
p.onChange = function(e) {
return D(e) && w.on(
4,
e
), function() {
D(e) && w.off(
4,
e
);
};
};
p.configure = function(e) {
e === void 0 && (e = {}), ve = !0, Re = e;
};
p.POSITION = Oe;
p.TYPE = A;
w.on(
2,
function(e) {
de = e.containerId || e, G.set(de, e), fe.forEach(function(t) {
w.emit(
0,
t.content,
t.options
);
}), fe = [];
}
).on(
3,
function(e) {
G.delete(e.containerId || e), G.size === 0 && w.off(
0
/* Show */
).off(
1
/* Clear */
).off(
5
/* ClearWaitingQueue */
), Ie && V && document.body.removeChild(V);
}
);
export {
Le as T,
p as t
};