Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-toastify

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-toastify - npm Package Compare versions

Comparing version 8.1.0 to 8.1.1

2

dist/components/Icons.d.ts

@@ -1,2 +0,2 @@

import React from 'react';
import * as React from 'react';
import { Theme, TypeOptions } from '../types';

@@ -3,0 +3,0 @@ /**

@@ -0,1 +1,2 @@

/// <reference types="react" />
declare const Bounce: ({ children, position, preventExitTransition, done, nodeRef, isIn }: import("..").ToastTransitionProps) => JSX.Element;

@@ -2,0 +3,0 @@ declare const Slide: ({ children, position, preventExitTransition, done, nodeRef, isIn }: import("..").ToastTransitionProps) => JSX.Element;

import * as React from 'react';
import { OnChangeCallback } from './eventManager';
import { ToastContent, ToastOptions, Id, ToastContainerProps, UpdateOptions, ClearWaitingQueueParams, TypeOptions } from '../types';
declare const toast: {
(content: ToastContent, options?: ToastOptions<{}> | undefined): React.ReactText;
loading(content: ToastContent, options?: ToastOptions<{}> | undefined): React.ReactText;
promise: typeof handlePromise;
success: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
info: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
error: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
warning: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
warn: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
dark(content: ToastContent, options?: ToastOptions<{}> | undefined): React.ReactText;
/**
* Remove toast programmaticaly
*/
dismiss(id?: string | number | undefined): void;
/**
* Clear waiting queue when limit is used
*/
clearWaitingQueue(params?: ClearWaitingQueueParams): void;
/**
* return true if one container is displaying the toast
*/
isActive(id: Id): boolean;
update(toastId: Id, options?: UpdateOptions): void;
/**
* Used for controlled progress bar.
*/
done(id: Id): void;
/**
* Track changes. The callback get the number of toast displayed
*
*/
onChange(callback: OnChangeCallback): () => void;
/**
* Configure the ToastContainer when lazy mounted
*/
configure(config?: ToastContainerProps): void;
POSITION: {
import { ToastContent, ToastOptions, ToastContainerProps, UpdateOptions, ClearWaitingQueueParams, TypeOptions } from '../types';
declare function toast(content: ToastContent, options?: ToastOptions): React.ReactText;
declare namespace toast {
var loading: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
var promise: typeof handlePromise;
var success: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
var info: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
var error: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
var warning: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
var warn: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
var dark: (content: ToastContent, options?: ToastOptions<{}> | undefined) => React.ReactText;
var dismiss: (id?: string | number | undefined) => void;
var clearWaitingQueue: (params?: ClearWaitingQueueParams) => void;
var isActive: (id: React.ReactText) => boolean;
var update: (toastId: React.ReactText, options?: UpdateOptions) => void;
var done: (id: React.ReactText) => void;
var onChange: (callback: OnChangeCallback) => () => void;
var configure: (config?: ToastContainerProps) => void;
var POSITION: {
TOP_LEFT: import("../types").ToastPosition;

@@ -48,3 +29,3 @@ TOP_RIGHT: import("../types").ToastPosition;

};
TYPE: {
var TYPE: {
INFO: TypeOptions;

@@ -56,4 +37,4 @@ SUCCESS: TypeOptions;

};
};
interface ToastPromiseParams {
}
export interface ToastPromiseParams {
pending?: string | UpdateOptions;

@@ -60,0 +41,0 @@ success?: string | UpdateOptions;

export * from './useToastContainer';
export * from './useToast';
export * from './useKeeper';
/// <reference types="react" />
import { Id, ToastContainerProps, Toast, ToastPosition } from '../types';
import { Id, ToastContainerProps, ToastProps, ToastContent, Toast, ToastPosition } from '../types';
interface QueuedToast {
toastContent: ToastContent;
toastProps: ToastProps;
staleId?: Id;
}
export interface ContainerInstance {

@@ -9,9 +14,11 @@ toastKey: number;

isToastActive: (toastId: Id) => boolean;
getToast: (id: Id) => Toast | null;
getToast: (id: Id) => Toast | null | undefined;
queue: QueuedToast[];
count: number;
}
export declare function useToastContainer(props: ToastContainerProps): {
getToastToRender: <T>(cb: (position: ToastPosition, toastList: Toast[]) => T) => T[];
collection: Record<Id, Toast>;
containerRef: import("react").MutableRefObject<null>;
isToastActive: (id: Id) => boolean;
};
export {};
export { useToastContainer, useToast } from './hooks';
export { cssTransition, collapseToast } from './utils';
export { ToastContainer, Bounce, Flip, Slide, Zoom, Icons, IconProps, CloseButtonProps } from './components';
export { toast } from './core';
export { toast, ToastPromiseParams } from './core';
export { TypeOptions, Theme, ToastPosition, ToastContentProps, ToastContent, ToastTransition, ToastClassName, ClearWaitingQueueParams, DraggableDirection, ToastOptions, UpdateOptions, ToastContainerProps, ToastTransitionProps, Id } from './types';

@@ -165,2 +165,5 @@ 'use strict';

var node = nodeRef.current;
node.dispatchEvent(new Event("d"
/* ENTRANCE_ANIMATION_END */
));
node.removeEventListener('animationend', onEntered);

@@ -252,39 +255,2 @@

/**
* `useKeeper` is a helper around `useRef`.
*
* You don't need to access the `.current`property to get the value
* If refresh is set to true. The ref will be updated every render
*/
function useKeeper(arg, refresh) {
if (refresh === void 0) {
refresh = false;
}
var ref = React.useRef(arg);
React.useEffect(function () {
if (refresh) ref.current = arg;
});
return ref.current;
}
function reducer(state, action) {
switch (action.type) {
case 0
/* ADD */
:
return [].concat(state, [action.toastId]).filter(function (id) {
return id !== action.staleId;
});
case 1
/* REMOVE */
:
return isToastIdValid(action.toastId) ? state.filter(function (id) {
return id !== action.toastId;
}) : [];
}
}
var _excluded = ["delay", "staleId"];

@@ -297,13 +263,18 @@ function useToastContainer(props) {

var _useReducer2 = React.useReducer(reducer, []),
toast = _useReducer2[0],
dispatch = _useReducer2[1];
var _useState = React.useState([]),
toastIds = _useState[0],
setToastIds = _useState[1];
var containerRef = React.useRef(null);
var toastCount = useKeeper(0);
var queue = useKeeper([]);
var collection = useKeeper({});
var instance = useKeeper({
var toastToRender = React.useRef(new Map()).current;
var isToastActive = function isToastActive(id) {
return toastIds.indexOf(id) !== -1;
};
var instance = React.useRef({
toastKey: 1,
displayedToast: 0,
count: 0,
queue: [],
props: props,

@@ -313,5 +284,5 @@ containerId: null,

getToast: function getToast(id) {
return collection[id] || null;
return toastToRender.get(id);
}
});
}).current;
React.useEffect(function () {

@@ -340,7 +311,7 @@ instance.containerId = props.containerId;

instance.isToastActive = isToastActive;
instance.displayedToast = toast.length;
instance.displayedToast = toastIds.length;
eventManager.emit(4
/* Change */
, toast.length, props.containerId);
}, [toast]);
, toastIds.length, props.containerId);
}, [toastIds]);
React.useEffect(function () {

@@ -350,6 +321,2 @@ instance.props = props;

function isToastActive(id) {
return toast.indexOf(id) !== -1;
}
function clearWaitingQueue(_ref) {

@@ -360,4 +327,4 @@ var containerId = _ref.containerId;

if (limit && (!containerId || instance.containerId === containerId)) {
toastCount -= queue.length;
queue = [];
instance.count -= instance.queue.length;
instance.queue = [];
}

@@ -367,7 +334,6 @@ }

function removeToast(toastId) {
dispatch({
type: 1
/* REMOVE */
,
toastId: toastId
setToastIds(function (state) {
return isToastIdValid(toastId) ? state.filter(function (id) {
return id !== toastId;
}) : [];
});

@@ -377,6 +343,6 @@ }

function dequeueToast() {
var _queue$shift = queue.shift(),
toastContent = _queue$shift.toastContent,
toastProps = _queue$shift.toastProps,
staleId = _queue$shift.staleId;
var _instance$queue$shift = instance.queue.shift(),
toastContent = _instance$queue$shift.toastContent,
toastProps = _instance$queue$shift.toastProps,
staleId = _instance$queue$shift.staleId;

@@ -392,17 +358,12 @@ appendToast(toastContent, toastProps, staleId);

function isNotValid(_ref2) {
var containerId = _ref2.containerId,
toastId = _ref2.toastId,
updateId = _ref2.updateId;
return !containerRef.current || instance.props.enableMultiContainer && containerId !== instance.props.containerId || collection[toastId] && updateId == null ? true : false;
} // this function and all the function called inside needs to rely on ref(`useKeeper`)
function isNotValid(options) {
return !containerRef.current || instance.props.enableMultiContainer && options.containerId !== instance.props.containerId || toastToRender.has(options.toastId) && options.updateId == null;
} // this function and all the function called inside needs to rely on refs
function buildToast(content, _ref3) {
var _options$icon;
function buildToast(content, _ref2) {
var delay = _ref2.delay,
staleId = _ref2.staleId,
options = _objectWithoutPropertiesLoose(_ref2, _excluded);
var delay = _ref3.delay,
staleId = _ref3.staleId,
options = _objectWithoutPropertiesLoose(_ref3, _excluded);
if (!canBeRendered(content) || isNotValid(options)) return;

@@ -418,4 +379,4 @@ var toastId = options.toastId,

var isNotAnUpdate = options.updateId == null;
if (isNotAnUpdate) toastCount++;
var isNotAnUpdate = updateId == null;
if (isNotAnUpdate) instance.count++;
var toastProps = {

@@ -426,3 +387,3 @@ toastId: toastId,

theme: options.theme || props.theme,
icon: (_options$icon = options.icon) != null ? _options$icon : props.icon,
icon: options.icon != null ? options.icon : props.icon,
isIn: false,

@@ -444,3 +405,3 @@ key: options.key || instance.toastKey++,

draggable: isBool(options.draggable) ? options.draggable : props.draggable,
draggablePercent: isNum(options.draggablePercent) ? options.draggablePercent : props.draggablePercent,
draggablePercent: options.draggablePercent || props.draggablePercent,
draggableDirection: options.draggableDirection || props.draggableDirection,

@@ -453,27 +414,38 @@ closeOnClick: isBool(options.closeOnClick) ? options.closeOnClick : props.closeOnClick,

progress: options.progress,
role: isStr(options.role) ? options.role : props.role,
role: options.role || props.role,
deleteToast: function deleteToast() {
removeFromCollection(toastId);
toastToRender["delete"](toastId);
var queueLen = instance.queue.length;
instance.count = isToastIdValid(toastId) ? instance.count - 1 : instance.count - instance.displayedToast;
if (instance.count < 0) instance.count = 0;
if (queueLen > 0) {
var freeSlot = isToastIdValid(toastId) ? 1 : instance.props.limit;
if (queueLen === 1 || freeSlot === 1) {
instance.displayedToast++;
dequeueToast();
} else {
var toDequeue = freeSlot > queueLen ? queueLen : freeSlot;
instance.displayedToast = toDequeue;
for (var i = 0; i < toDequeue; i++) {
dequeueToast();
}
}
} else {
forceUpdate();
}
}
};
if (isFn(options.onOpen)) toastProps.onOpen = options.onOpen;
if (isFn(options.onClose)) toastProps.onClose = options.onClose; // tweak for vertical dragging
if (isFn(options.onClose)) toastProps.onClose = options.onClose;
toastProps.closeButton = props.closeButton;
if (toastProps.draggableDirection === "y"
/* Y */
&& toastProps.draggablePercent === 80
/* DRAGGABLE_PERCENT */
) {
toastProps.draggablePercent *= 1.5;
}
var closeButton = props.closeButton;
if (options.closeButton === false || canBeRendered(options.closeButton)) {
closeButton = options.closeButton;
toastProps.closeButton = options.closeButton;
} else if (options.closeButton === true) {
closeButton = canBeRendered(props.closeButton) ? props.closeButton : true;
toastProps.closeButton = canBeRendered(props.closeButton) ? props.closeButton : true;
}
toastProps.closeButton = closeButton;
var toastContent = content;

@@ -496,4 +468,4 @@

if (props.limit && props.limit > 0 && toastCount > props.limit && isNotAnUpdate) {
queue.push({
if (props.limit && props.limit > 0 && instance.count > props.limit && isNotAnUpdate) {
instance.queue.push({
toastContent: toastContent,

@@ -514,55 +486,26 @@ toastProps: toastProps,

var toastId = toastProps.toastId;
if (staleId) delete collection[staleId];
collection[toastId] = {
if (staleId) toastToRender["delete"](staleId);
toastToRender.set(toastId, {
content: content,
props: toastProps
};
dispatch({
type: 0
/* ADD */
,
toastId: toastId,
staleId: staleId
});
setToastIds(function (state) {
return [].concat(state, [toastId]).filter(function (id) {
return id !== staleId;
});
});
}
function removeFromCollection(toastId) {
delete collection[toastId];
var queueLen = queue.length;
toastCount = isToastIdValid(toastId) ? toastCount - 1 : toastCount - instance.displayedToast;
if (toastCount < 0) toastCount = 0;
if (queueLen > 0) {
var freeSlot = isToastIdValid(toastId) ? 1 : instance.props.limit;
if (queueLen === 1 || freeSlot === 1) {
instance.displayedToast++;
dequeueToast();
} else {
var toDequeue = freeSlot > queueLen ? queueLen : freeSlot;
instance.displayedToast = toDequeue;
for (var i = 0; i < toDequeue; i++) {
dequeueToast();
}
}
} else {
forceUpdate();
}
}
function getToastToRender(cb) {
var toastToRender = {};
var toastList = props.newestOnTop ? Object.keys(collection).reverse() : Object.keys(collection);
for (var i = 0; i < toastList.length; i++) {
var _toast = collection[toastList[i]];
var position = _toast.props.position;
toastToRender[position] || (toastToRender[position] = []);
toastToRender[position].push(_toast);
}
return Object.keys(toastToRender).map(function (p) {
return cb(p, toastToRender[p]);
var toRender = new Map();
var collection = Array.from(toastToRender.values());
if (props.newestOnTop) collection.reverse();
collection.forEach(function (toast) {
var position = toast.props.position;
toRender.has(position) || toRender.set(position, []);
toRender.get(position).push(toast);
});
return Array.from(toRender, function (p) {
return cb(p[0], p[1]);
});
}

@@ -572,3 +515,2 @@

getToastToRender: getToastToRender,
collection: collection,
containerRef: containerRef,

@@ -588,3 +530,3 @@ isToastActive: isToastActive

function useToast(props) {
var _useState = React.useState(true),
var _useState = React.useState(false),
isRunning = _useState[0],

@@ -598,3 +540,3 @@ setIsRunning = _useState[1];

var toastRef = React.useRef(null);
var drag = useKeeper({
var drag = React.useRef({
start: 0,

@@ -607,5 +549,6 @@ x: 0,

canDrag: false,
boundingRect: null
});
var syncProps = useKeeper(props, true);
boundingRect: null,
didMove: false
}).current;
var syncProps = React.useRef(props);
var autoClose = props.autoClose,

@@ -617,14 +560,17 @@ pauseOnHover = props.pauseOnHover,

React.useEffect(function () {
syncProps.current = props;
});
React.useEffect(function () {
if (toastRef.current) toastRef.current.addEventListener("d"
/* ENTRANCE_ANIMATION_END */
, playToast, {
once: true
});
if (isFn(props.onOpen)) props.onOpen(React.isValidElement(props.children) && props.children.props);
return function () {
if (isFn(syncProps.onClose)) syncProps.onClose(React.isValidElement(syncProps.children) && syncProps.children.props);
var props = syncProps.current;
if (isFn(props.onClose)) props.onClose(React.isValidElement(props.children) && props.children.props);
};
}, []);
React.useEffect(function () {
props.draggable && bindDragEvents();
return function () {
props.draggable && unbindDragEvents();
};
}, [props.draggable]);
React.useEffect(function () {
props.pauseOnFocusLoss && bindFocusEvents();

@@ -638,2 +584,3 @@ return function () {

if (props.draggable) {
bindDragEvents();
var toast = toastRef.current;

@@ -654,3 +601,5 @@ drag.canCloseOnClick = true;

drag.start = drag.y;
drag.removalDistance = toast.offsetHeight * (props.draggablePercent / 100);
drag.removalDistance = toast.offsetHeight * (props.draggablePercent === 80
/* DRAGGABLE_PERCENT */
? props.draggablePercent * 1.5 : props.draggablePercent / 100);
}

@@ -696,2 +645,3 @@ }

function bindDragEvents() {
drag.didMove = false;
document.addEventListener('mousemove', onDragMove);

@@ -711,5 +661,6 @@ document.addEventListener('mouseup', onDragEnd);

function onDragMove(e) {
if (drag.canDrag) {
e.preventDefault();
var toast = toastRef.current;
var toast = toastRef.current;
if (drag.canDrag && toast) {
drag.didMove = true;
if (isRunning) pauseToast();

@@ -735,5 +686,6 @@ drag.x = getX(e);

function onDragEnd() {
unbindDragEvents();
var toast = toastRef.current;
if (drag.canDrag) {
if (drag.canDrag && drag.didMove && toast) {
drag.canDrag = false;

@@ -877,3 +829,3 @@

return React__default.createElement("svg", Object.assign({
return React.createElement("svg", Object.assign({
viewBox: "0 0 24 24",

@@ -887,3 +839,3 @@ width: "100%",

function Warning(props) {
return React__default.createElement(Svg, Object.assign({}, props), React__default.createElement("path", {
return React.createElement(Svg, Object.assign({}, props), React.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"

@@ -894,3 +846,3 @@ }));

function Info(props) {
return React__default.createElement(Svg, Object.assign({}, props), React__default.createElement("path", {
return React.createElement(Svg, Object.assign({}, props), React.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"

@@ -901,3 +853,3 @@ }));

function Success(props) {
return React__default.createElement(Svg, Object.assign({}, props), React__default.createElement("path", {
return React.createElement(Svg, Object.assign({}, props), React.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"

@@ -908,3 +860,3 @@ }));

function Error(props) {
return React__default.createElement(Svg, Object.assign({}, props), React__default.createElement("path", {
return React.createElement(Svg, Object.assign({}, props), React.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"

@@ -915,3 +867,3 @@ }));

function Spinner() {
return React__default.createElement("div", {
return React.createElement("div", {
className: "Toastify"

@@ -1145,3 +1097,3 @@ /* CSS_NAMESPACE */

}, getToastToRender(function (position, toastList) {
var containerStyle = toastList.length === 0 ? _extends({}, style, {
var containerStyle = !toastList.length ? _extends({}, style, {
pointerEvents: 'none'

@@ -1193,13 +1145,5 @@ }) : _extends({}, style);

/**
* Check whether any container is currently mounted in the DOM
*/
function isAnyContainerMounted() {
return containers.size > 0;
}
/**
* Get the toast by id, given it's in the DOM, otherwise returns null
*/
function getToast(toastId, _ref) {

@@ -1217,3 +1161,3 @@ var containerId = _ref.containerId;

function generateToastId() {
return Math.random().toString(36).substr(2, 9);
return Math.random().toString(36).substring(2, 9);
}

@@ -1239,3 +1183,3 @@ /**

function dispatchToast(content, options) {
if (isAnyContainerMounted()) {
if (containers.size > 0) {
eventManager.emit(0

@@ -1272,11 +1216,11 @@ /* Show */

var createToastByType = function createToastByType(type) {
function createToastByType(type) {
return function (content, options) {
return dispatchToast(content, mergeOptions(type, options));
};
};
}
var toast = function toast(content, options) {
function toast(content, options) {
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, options));
};
}

@@ -1312,2 +1256,9 @@ toast.loading = function (content, options) {

var resolver = function resolver(type, input, result) {
// Remove the toast if the input has not been provided. This prevents the toast from hanging
// in the pending state if a success/error toast has not been provided.
if (input == null) {
toast.dismiss(id);
return;
}
var baseParams = _extends({

@@ -1336,5 +1287,5 @@ type: type

p.then(function (result) {
return success && resolver('success', success, result);
return resolver('success', success, result);
})["catch"](function (err) {
return error && resolver('error', error, err);
return resolver('error', error, err);
});

@@ -1452,2 +1403,3 @@ return p;

* Configure the ToastContainer when lazy mounted
* Prefer ToastContainer over this one
*/

@@ -1454,0 +1406,0 @@

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),o=e(require("clsx")),r=require("react-dom");function a(){return(a=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 s(e,t){if(null==e)return{};var n,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)t.indexOf(n=a[o])>=0||(r[n]=e[n]);return r}function i(e){return"number"==typeof e&&!isNaN(e)}function c(e){return"boolean"==typeof e}function l(e){return"string"==typeof e}function u(e){return"function"==typeof e}function d(e){return l(e)||u(e)?e:null}function f(e){return 0===e||e}var p=!("undefined"==typeof window||!window.document||!window.document.createElement);function m(e){return t.isValidElement(e)||l(e)||u(e)||i(e)}var g={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},v={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"};function y(e,t,n){void 0===n&&(n=300);var o=e.scrollHeight,r=e.style;requestAnimationFrame((function(){r.minHeight="initial",r.height=o+"px",r.transition="all "+n+"ms",requestAnimationFrame((function(){r.height="0",r.padding="0",r.margin="0",setTimeout(t,n)}))}))}function h(e){var o=e.enter,r=e.exit,a=e.appendPosition,s=void 0!==a&&a,i=e.collapse,c=void 0===i||i,l=e.collapseDuration,u=void 0===l?300:l;return function(e){var a=e.children,i=e.position,l=e.preventExitTransition,d=e.done,f=e.nodeRef,p=e.isIn,m=s?o+"--"+i:o,g=s?r+"--"+i:r,v=t.useRef(),h=t.useRef(0);function T(e){if(e.target===f.current){var t=f.current;t.removeEventListener("animationend",T),0===h.current&&(t.className=v.current)}}function E(){var e=f.current;e.removeEventListener("animationend",E),c?y(e,d,u):d()}return t.useLayoutEffect((function(){var e;v.current=(e=f.current).className,e.className+=" "+m,e.addEventListener("animationend",T)}),[]),t.useEffect((function(){p||(l?E():function(){h.current=1;var e=f.current;e.className+=" "+g,e.addEventListener("animationend",E)}())}),[p]),n.createElement(n.Fragment,null,a)}}var T={list:new Map,emitQueue:new Map,on:function(e,t){return this.list.has(e)||this.list.set(e,[]),this.list.get(e).push(t),this},off:function(e,t){if(t){var n=this.list.get(e).filter((function(e){return e!==t}));return this.list.set(e,n),this}return this.list.delete(e),this},cancelEmit:function(e){var t=this.emitQueue.get(e);return t&&(t.forEach(clearTimeout),this.emitQueue.delete(e)),this},emit:function(e){for(var t=this,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];this.list.has(e)&&this.list.get(e).forEach((function(n){var r=setTimeout((function(){n.apply(void 0,o)}),0);t.emitQueue.has(e)||t.emitQueue.set(e,[]),t.emitQueue.get(e).push(r)}))}};function E(e,n){void 0===n&&(n=!1);var o=t.useRef(e);return t.useEffect((function(){n&&(o.current=e)})),o.current}function b(e,t){switch(t.type){case 0:return[].concat(e,[t.toastId]).filter((function(e){return e!==t.staleId}));case 1:return f(t.toastId)?e.filter((function(e){return e!==t.toastId})):[]}}var O=["delay","staleId"];function C(e){var n=t.useReducer((function(e){return e+1}),0)[1],o=t.useReducer(b,[]),r=o[0],a=o[1],p=t.useRef(null),g=E(0),v=E([]),y=E({}),h=E({toastKey:1,displayedToast:0,props:e,containerId:null,isToastActive:C,getToast:function(e){return y[e]||null}});function C(e){return-1!==r.indexOf(e)}function _(e){var t=e.containerId;!h.props.limit||t&&h.containerId!==t||(g-=v.length,v=[])}function I(e){a({type:1,toastId:e})}function L(){var e=v.shift();N(e.toastContent,e.toastProps,e.staleId)}function x(e,o){var r,a=o.delay,T=o.staleId,E=s(o,O);if(m(e)&&(b=E,!(!p.current||h.props.enableMultiContainer&&b.containerId!==h.props.containerId||y[b.toastId]&&null==b.updateId))){var b,C=E.toastId,_=E.data,x=h.props,R=function(){return I(C)},P=null==E.updateId;P&&g++;var k,w,B={toastId:C,updateId:E.updateId,isLoading:E.isLoading,theme:E.theme||x.theme,icon:null!=(r=E.icon)?r:x.icon,isIn:!1,key:E.key||h.toastKey++,type:E.type,closeToast:R,closeButton:E.closeButton,rtl:x.rtl,position:E.position||x.position,transition:E.transition||x.transition,className:d(E.className||x.toastClassName),bodyClassName:d(E.bodyClassName||x.bodyClassName),style:E.style||x.toastStyle,bodyStyle:E.bodyStyle||x.bodyStyle,onClick:E.onClick||x.onClick,pauseOnHover:c(E.pauseOnHover)?E.pauseOnHover:x.pauseOnHover,pauseOnFocusLoss:c(E.pauseOnFocusLoss)?E.pauseOnFocusLoss:x.pauseOnFocusLoss,draggable:c(E.draggable)?E.draggable:x.draggable,draggablePercent:i(E.draggablePercent)?E.draggablePercent:x.draggablePercent,draggableDirection:E.draggableDirection||x.draggableDirection,closeOnClick:c(E.closeOnClick)?E.closeOnClick:x.closeOnClick,progressClassName:d(E.progressClassName||x.progressClassName),progressStyle:E.progressStyle||x.progressStyle,autoClose:!E.isLoading&&(k=E.autoClose,w=x.autoClose,!1===k||i(k)&&k>0?k:w),hideProgressBar:c(E.hideProgressBar)?E.hideProgressBar:x.hideProgressBar,progress:E.progress,role:l(E.role)?E.role:x.role,deleteToast:function(){!function(e){delete y[e];var t=v.length;if((g=f(e)?g-1:g-h.displayedToast)<0&&(g=0),t>0){var o=f(e)?1:h.props.limit;if(1===t||1===o)h.displayedToast++,L();else{var r=o>t?t:o;h.displayedToast=r;for(var a=0;a<r;a++)L()}}else n()}(C)}};u(E.onOpen)&&(B.onOpen=E.onOpen),u(E.onClose)&&(B.onClose=E.onClose),"y"===B.draggableDirection&&80===B.draggablePercent&&(B.draggablePercent*=1.5);var D=x.closeButton;!1===E.closeButton||m(E.closeButton)?D=E.closeButton:!0===E.closeButton&&(D=!m(x.closeButton)||x.closeButton),B.closeButton=D;var A=e;t.isValidElement(e)&&!l(e.type)?A=t.cloneElement(e,{closeToast:R,toastProps:B,data:_}):u(e)&&(A=e({closeToast:R,toastProps:B,data:_})),x.limit&&x.limit>0&&g>x.limit&&P?v.push({toastContent:A,toastProps:B,staleId:T}):i(a)&&a>0?setTimeout((function(){N(A,B,T)}),a):N(A,B,T)}}function N(e,t,n){var o=t.toastId;n&&delete y[n],y[o]={content:e,props:t},a({type:0,toastId:o,staleId:n})}return t.useEffect((function(){return h.containerId=e.containerId,T.cancelEmit(3).on(0,x).on(1,(function(e){return p.current&&I(e)})).on(5,_).emit(2,h),function(){return T.emit(3,h)}}),[]),t.useEffect((function(){h.isToastActive=C,h.displayedToast=r.length,T.emit(4,r.length,e.containerId)}),[r]),t.useEffect((function(){h.props=e})),{getToastToRender:function(t){for(var n={},o=e.newestOnTop?Object.keys(y).reverse():Object.keys(y),r=0;r<o.length;r++){var a=y[o[r]],s=a.props.position;n[s]||(n[s]=[]),n[s].push(a)}return Object.keys(n).map((function(e){return t(e,n[e])}))},collection:y,containerRef:p,isToastActive:C}}function _(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientX:e.clientX}function I(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientY:e.clientY}function L(e){var n=t.useState(!0),o=n[0],r=n[1],a=t.useState(!1),s=a[0],i=a[1],c=t.useRef(null),l=E({start:0,x:0,y:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null}),d=E(e,!0),f=e.autoClose,p=e.pauseOnHover,m=e.closeToast,g=e.onClick,v=e.closeOnClick;function y(t){if(e.draggable){var n=c.current;l.canCloseOnClick=!0,l.canDrag=!0,l.boundingRect=n.getBoundingClientRect(),n.style.transition="",l.x=_(t.nativeEvent),l.y=I(t.nativeEvent),"x"===e.draggableDirection?(l.start=l.x,l.removalDistance=n.offsetWidth*(e.draggablePercent/100)):(l.start=l.y,l.removalDistance=n.offsetHeight*(e.draggablePercent/100))}}function h(){if(l.boundingRect){var t=l.boundingRect;e.pauseOnHover&&l.x>=t.left&&l.x<=t.right&&l.y>=t.top&&l.y<=t.bottom?b():T()}}function T(){r(!0)}function b(){r(!1)}function O(t){if(l.canDrag){t.preventDefault();var n=c.current;o&&b(),l.x=_(t),l.y=I(t),l.delta="x"===e.draggableDirection?l.x-l.start:l.y-l.start,l.start!==l.x&&(l.canCloseOnClick=!1),n.style.transform="translate"+e.draggableDirection+"("+l.delta+"px)",n.style.opacity=""+(1-Math.abs(l.delta/l.removalDistance))}}function C(){var t=c.current;if(l.canDrag){if(l.canDrag=!1,Math.abs(l.delta)>l.removalDistance)return i(!0),void e.closeToast();t.style.transition="transform 0.2s, opacity 0.2s",t.style.transform="translate"+e.draggableDirection+"(0)",t.style.opacity="1"}}t.useEffect((function(){return u(e.onOpen)&&e.onOpen(t.isValidElement(e.children)&&e.children.props),function(){u(d.onClose)&&d.onClose(t.isValidElement(d.children)&&d.children.props)}}),[]),t.useEffect((function(){return e.draggable&&(document.addEventListener("mousemove",O),document.addEventListener("mouseup",C),document.addEventListener("touchmove",O),document.addEventListener("touchend",C)),function(){e.draggable&&(document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",C),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",C))}}),[e.draggable]),t.useEffect((function(){return e.pauseOnFocusLoss&&(document.hasFocus()||b(),window.addEventListener("focus",T),window.addEventListener("blur",b)),function(){e.pauseOnFocusLoss&&(window.removeEventListener("focus",T),window.removeEventListener("blur",b))}}),[e.pauseOnFocusLoss]);var L={onMouseDown:y,onTouchStart:y,onMouseUp:h,onTouchEnd:h};return f&&p&&(L.onMouseEnter=b,L.onMouseLeave=T),v&&(L.onClick=function(e){g&&g(e),l.canCloseOnClick&&m()}),{playToast:T,pauseToast:b,isRunning:o,preventExitTransition:s,toastRef:c,eventHandlers:L}}function x(e){var n=e.closeToast,o=e.ariaLabel;return t.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+e.theme,type:"button",onClick:function(e){e.stopPropagation(),n(e)},"aria-label":void 0===o?"close":o},t.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},t.createElement("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 N(e){var n,r,s=e.closeToast,i=e.type,c=e.hide,l=e.className,d=e.controlledProgress,f=e.progress,p=e.rtl,m=e.isIn,g=e.theme,v=a({},e.style,{animationDuration:e.delay+"ms",animationPlayState:e.isRunning?"running":"paused",opacity:c?0:1});d&&(v.transform="scaleX("+f+")");var y=o("Toastify__progress-bar",d?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar-theme--"+g,"Toastify__progress-bar--"+i,((n={})["Toastify__progress-bar--rtl"]=p,n)),h=u(l)?l({rtl:p,type:i,defaultClassName:y}):o(y,l),T=((r={})[d&&f>=1?"onTransitionEnd":"onAnimationEnd"]=d&&f<1?null:function(){m&&s()},r);return t.createElement("div",Object.assign({role:"progressbar","aria-hidden":c?"true":"false","aria-label":"notification timer",className:h,style:v},T))}N.defaultProps={type:v.DEFAULT,hide:!1};var R=["theme","type"],P=function(e){var t=e.theme,o=e.type,r=s(e,R);return n.createElement("svg",Object.assign({viewBox:"0 0 24 24",width:"100%",height:"100%",fill:"colored"===t?"currentColor":"var(--toastify-icon-color-"+o+")"},r))},k={info:function(e){return n.createElement(P,Object.assign({},e),n.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"}))},warning:function(e){return n.createElement(P,Object.assign({},e),n.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"}))},success:function(e){return n.createElement(P,Object.assign({},e),n.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"}))},error:function(e){return n.createElement(P,Object.assign({},e),n.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"}))},spinner:function(){return n.createElement("div",{className:"Toastify__spinner"})}},w=function(e){var n,r,a=L(e),s=a.isRunning,i=a.preventExitTransition,c=a.toastRef,d=a.eventHandlers,f=e.closeButton,p=e.children,m=e.autoClose,g=e.onClick,v=e.type,y=e.hideProgressBar,h=e.closeToast,T=e.transition,E=e.position,b=e.className,O=e.style,C=e.bodyClassName,_=e.bodyStyle,I=e.progressClassName,x=e.progressStyle,R=e.updateId,P=e.role,w=e.progress,B=e.rtl,D=e.toastId,A=e.deleteToast,F=e.isIn,M=e.isLoading,S=e.icon,j=e.theme,z=o("Toastify__toast","Toastify__toast-theme--"+j,"Toastify__toast--"+v,((n={})["Toastify__toast--rtl"]=B,n)),H=u(b)?b({rtl:B,position:E,type:v,defaultClassName:z}):o(z,b),U=!!w,Q=k[v],V={theme:j,type:v},q=Q&&Q(V);return!1===S?q=void 0:u(S)?q=S(V):t.isValidElement(S)?q=t.cloneElement(S,V):l(S)?q=S:M&&(q=k.spinner()),t.createElement(T,{isIn:F,done:A,position:E,preventExitTransition:i,nodeRef:c},t.createElement("div",Object.assign({id:D,onClick:g,className:H},d,{style:O,ref:c}),t.createElement("div",Object.assign({},F&&{role:P},{className:u(C)?C({type:v}):o("Toastify__toast-body",C),style:_}),q&&t.createElement("div",{className:o("Toastify__toast-icon",(r={},r["Toastify--animate-icon Toastify__zoom-enter"]=!M,r))},q),t.createElement("div",null,p)),function(e){if(e){var n={closeToast:h,type:v,theme:j};return u(e)?e(n):t.isValidElement(e)?t.cloneElement(e,n):void 0}}(f),(m||U)&&t.createElement(N,Object.assign({},R&&!U?{key:"pb-"+R}:{},{rtl:B,theme:j,delay:m,isRunning:s,isIn:F,closeToast:h,hide:y,type:v,style:x,className:I,controlledProgress:U,progress:w}))))},B=h({enter:"Toastify--animate Toastify__bounce-enter",exit:"Toastify--animate Toastify__bounce-exit",appendPosition:!0}),D=h({enter:"Toastify--animate Toastify__slide-enter",exit:"Toastify--animate Toastify__slide-exit",appendPosition:!0}),A=h({enter:"Toastify--animate Toastify__zoom-enter",exit:"Toastify--animate Toastify__zoom-exit"}),F=h({enter:"Toastify--animate Toastify__flip-enter",exit:"Toastify--animate Toastify__flip-exit"}),M=function(e){var n=C(e),r=n.isToastActive,s=e.className,i=e.style,c=e.rtl;function l(e){var t,n=o("Toastify__toast-container","Toastify__toast-container--"+e,((t={})["Toastify__toast-container--rtl"]=c,t));return u(s)?s({position:e,rtl:c,defaultClassName:n}):o(n,d(s))}return t.createElement("div",{ref:n.containerRef,className:"Toastify",id:e.containerId},(0,n.getToastToRender)((function(e,n){var o=0===n.length?a({},i,{pointerEvents:"none"}):a({},i);return t.createElement("div",{className:l(e),style:o,key:"container-"+e},n.map((function(e){var n=e.content,o=e.props;return t.createElement(w,Object.assign({},o,{isIn:r(o.toastId),key:"toast-"+o.key,closeButton:!0===o.closeButton?x:o.closeButton}),n)})))})))};M.defaultProps={position:g.TOP_RIGHT,transition:B,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:x,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};var S,j,z,H=new Map,U=[],Q=!1;function V(){return Math.random().toString(36).substr(2,9)}function q(e){return e&&(l(e.toastId)||i(e.toastId))?e.toastId:V()}function G(e,n){return H.size>0?T.emit(0,e,n):(U.push({content:e,options:n}),Q&&p&&(Q=!1,j=document.createElement("div"),document.body.appendChild(j),r.render(t.createElement(M,Object.assign({},z)),j))),n.toastId}function W(e,t){return a({},t,{type:t&&t.type||e,toastId:q(t)})}var X=function(e){return function(t,n){return G(t,W(e,n))}},Y=function(e,t){return G(e,W(v.DEFAULT,t))};Y.loading=function(e,t){return G(e,W(v.DEFAULT,a({isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1},t)))},Y.promise=function(e,t,n){var o,r=t.pending,s=t.error,i=t.success;r&&(o=l(r)?Y.loading(r,n):Y.loading(r.render,a({},n,r)));var c={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},d=function(e,t,r){var s=a({type:e},c,n,{data:r}),i=l(t)?{render:t}:t;return o?Y.update(o,a({},s,i)):Y(i.render,a({},s,i)),r},f=u(e)?e():e;return f.then((function(e){return i&&d("success",i,e)})).catch((function(e){return s&&d("error",s,e)})),f},Y.success=X(v.SUCCESS),Y.info=X(v.INFO),Y.error=X(v.ERROR),Y.warn=Y.warning=X(v.WARNING),Y.dark=function(e,t){return G(e,W(v.DEFAULT,a({theme:"dark"},t)))},Y.dismiss=function(e){return T.emit(1,e)},Y.clearWaitingQueue=function(e){return void 0===e&&(e={}),T.emit(5,e)},Y.isActive=function(e){var t=!1;return H.forEach((function(n){n.isToastActive&&n.isToastActive(e)&&(t=!0)})),t},Y.update=function(e,t){void 0===t&&(t={}),setTimeout((function(){var n=function(e,t){var n=H.get(t.containerId||S);return n?n.getToast(e):null}(e,t);if(n){var o=n.content,r=a({},n.props,t,{toastId:t.toastId||e,updateId:V()});r.toastId!==e&&(r.staleId=e);var s=r.render||o;delete r.render,G(s,r)}}),0)},Y.done=function(e){Y.update(e,{progress:1})},Y.onChange=function(e){return u(e)&&T.on(4,e),function(){u(e)&&T.off(4,e)}},Y.configure=function(e){void 0===e&&(e={}),Q=!0,z=e},Y.POSITION=g,Y.TYPE=v,T.on(2,(function(e){H.set(S=e.containerId||e,e),U.forEach((function(e){T.emit(0,e.content,e.options)})),U=[]})).on(3,(function(e){H.delete(e.containerId||e),0===H.size&&T.off(0).off(1).off(5),p&&j&&document.body.removeChild(j)})),exports.Bounce=B,exports.Flip=F,exports.Icons=k,exports.Slide=D,exports.ToastContainer=M,exports.Zoom=A,exports.collapseToast=y,exports.cssTransition=h,exports.toast=Y,exports.useToast=L,exports.useToastContainer=C;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),o=e(require("clsx")),r=require("react-dom");function a(){return(a=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 s(e,t){if(null==e)return{};var n,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)t.indexOf(n=a[o])>=0||(r[n]=e[n]);return r}function i(e){return"number"==typeof e&&!isNaN(e)}function c(e){return"boolean"==typeof e}function u(e){return"string"==typeof e}function l(e){return"function"==typeof e}function d(e){return u(e)||l(e)?e:null}function f(e){return 0===e||e}var p=!("undefined"==typeof window||!window.document||!window.document.createElement);function m(e){return t.isValidElement(e)||u(e)||l(e)||i(e)}var g={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},v={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"};function y(e,t,n){void 0===n&&(n=300);var o=e.scrollHeight,r=e.style;requestAnimationFrame((function(){r.minHeight="initial",r.height=o+"px",r.transition="all "+n+"ms",requestAnimationFrame((function(){r.height="0",r.padding="0",r.margin="0",setTimeout(t,n)}))}))}function h(e){var o=e.enter,r=e.exit,a=e.appendPosition,s=void 0!==a&&a,i=e.collapse,c=void 0===i||i,u=e.collapseDuration,l=void 0===u?300:u;return function(e){var a=e.children,i=e.position,u=e.preventExitTransition,d=e.done,f=e.nodeRef,p=e.isIn,m=s?o+"--"+i:o,g=s?r+"--"+i:r,v=t.useRef(),h=t.useRef(0);function T(e){if(e.target===f.current){var t=f.current;t.dispatchEvent(new Event("d")),t.removeEventListener("animationend",T),0===h.current&&(t.className=v.current)}}function E(){var e=f.current;e.removeEventListener("animationend",E),c?y(e,d,l):d()}return t.useLayoutEffect((function(){var e;v.current=(e=f.current).className,e.className+=" "+m,e.addEventListener("animationend",T)}),[]),t.useEffect((function(){p||(u?E():function(){h.current=1;var e=f.current;e.className+=" "+g,e.addEventListener("animationend",E)}())}),[p]),n.createElement(n.Fragment,null,a)}}var T={list:new Map,emitQueue:new Map,on:function(e,t){return this.list.has(e)||this.list.set(e,[]),this.list.get(e).push(t),this},off:function(e,t){if(t){var n=this.list.get(e).filter((function(e){return e!==t}));return this.list.set(e,n),this}return this.list.delete(e),this},cancelEmit:function(e){var t=this.emitQueue.get(e);return t&&(t.forEach(clearTimeout),this.emitQueue.delete(e)),this},emit:function(e){for(var t=this,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];this.list.has(e)&&this.list.get(e).forEach((function(n){var r=setTimeout((function(){n.apply(void 0,o)}),0);t.emitQueue.has(e)||t.emitQueue.set(e,[]),t.emitQueue.get(e).push(r)}))}},E=["delay","staleId"];function b(e){var n=t.useReducer((function(e){return e+1}),0)[1],o=t.useState([]),r=o[0],a=o[1],p=t.useRef(null),g=t.useRef(new Map).current,v=function(e){return-1!==r.indexOf(e)},y=t.useRef({toastKey:1,displayedToast:0,count:0,queue:[],props:e,containerId:null,isToastActive:v,getToast:function(e){return g.get(e)}}).current;function h(e){var t=e.containerId;!y.props.limit||t&&y.containerId!==t||(y.count-=y.queue.length,y.queue=[])}function b(e){a((function(t){return f(e)?t.filter((function(t){return t!==e})):[]}))}function C(){var e=y.queue.shift();_(e.toastContent,e.toastProps,e.staleId)}function O(e,o){var r=o.delay,a=o.staleId,v=s(o,E);if(m(e)&&!function(e){return!p.current||y.props.enableMultiContainer&&e.containerId!==y.props.containerId||g.has(e.toastId)&&null==e.updateId}(v)){var h=v.toastId,T=v.updateId,O=v.data,I=y.props,L=function(){return b(h)},x=null==T;x&&y.count++;var N,R,P={toastId:h,updateId:T,isLoading:v.isLoading,theme:v.theme||I.theme,icon:null!=v.icon?v.icon:I.icon,isIn:!1,key:v.key||y.toastKey++,type:v.type,closeToast:L,closeButton:v.closeButton,rtl:I.rtl,position:v.position||I.position,transition:v.transition||I.transition,className:d(v.className||I.toastClassName),bodyClassName:d(v.bodyClassName||I.bodyClassName),style:v.style||I.toastStyle,bodyStyle:v.bodyStyle||I.bodyStyle,onClick:v.onClick||I.onClick,pauseOnHover:c(v.pauseOnHover)?v.pauseOnHover:I.pauseOnHover,pauseOnFocusLoss:c(v.pauseOnFocusLoss)?v.pauseOnFocusLoss:I.pauseOnFocusLoss,draggable:c(v.draggable)?v.draggable:I.draggable,draggablePercent:v.draggablePercent||I.draggablePercent,draggableDirection:v.draggableDirection||I.draggableDirection,closeOnClick:c(v.closeOnClick)?v.closeOnClick:I.closeOnClick,progressClassName:d(v.progressClassName||I.progressClassName),progressStyle:v.progressStyle||I.progressStyle,autoClose:!v.isLoading&&(N=v.autoClose,R=I.autoClose,!1===N||i(N)&&N>0?N:R),hideProgressBar:c(v.hideProgressBar)?v.hideProgressBar:I.hideProgressBar,progress:v.progress,role:v.role||I.role,deleteToast:function(){g.delete(h);var e=y.queue.length;if(y.count=f(h)?y.count-1:y.count-y.displayedToast,y.count<0&&(y.count=0),e>0){var t=f(h)?1:y.props.limit;if(1===e||1===t)y.displayedToast++,C();else{var o=t>e?e:t;y.displayedToast=o;for(var r=0;r<o;r++)C()}}else n()}};l(v.onOpen)&&(P.onOpen=v.onOpen),l(v.onClose)&&(P.onClose=v.onClose),P.closeButton=I.closeButton,!1===v.closeButton||m(v.closeButton)?P.closeButton=v.closeButton:!0===v.closeButton&&(P.closeButton=!m(I.closeButton)||I.closeButton);var w=e;t.isValidElement(e)&&!u(e.type)?w=t.cloneElement(e,{closeToast:L,toastProps:P,data:O}):l(e)&&(w=e({closeToast:L,toastProps:P,data:O})),I.limit&&I.limit>0&&y.count>I.limit&&x?y.queue.push({toastContent:w,toastProps:P,staleId:a}):i(r)&&r>0?setTimeout((function(){_(w,P,a)}),r):_(w,P,a)}}function _(e,t,n){var o=t.toastId;n&&g.delete(n),g.set(o,{content:e,props:t}),a((function(e){return[].concat(e,[o]).filter((function(e){return e!==n}))}))}return t.useEffect((function(){return y.containerId=e.containerId,T.cancelEmit(3).on(0,O).on(1,(function(e){return p.current&&b(e)})).on(5,h).emit(2,y),function(){return T.emit(3,y)}}),[]),t.useEffect((function(){y.isToastActive=v,y.displayedToast=r.length,T.emit(4,r.length,e.containerId)}),[r]),t.useEffect((function(){y.props=e})),{getToastToRender:function(t){var n=new Map,o=Array.from(g.values());return e.newestOnTop&&o.reverse(),o.forEach((function(e){var t=e.props.position;n.has(t)||n.set(t,[]),n.get(t).push(e)})),Array.from(n,(function(e){return t(e[0],e[1])}))},containerRef:p,isToastActive:v}}function C(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientX:e.clientX}function O(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientY:e.clientY}function _(e){var n=t.useState(!1),o=n[0],r=n[1],a=t.useState(!1),s=a[0],i=a[1],c=t.useRef(null),u=t.useRef({start:0,x:0,y:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null,didMove:!1}).current,d=t.useRef(e),f=e.autoClose,p=e.pauseOnHover,m=e.closeToast,g=e.onClick,v=e.closeOnClick;function y(t){if(e.draggable){u.didMove=!1,document.addEventListener("mousemove",b),document.addEventListener("mouseup",_),document.addEventListener("touchmove",b),document.addEventListener("touchend",_);var n=c.current;u.canCloseOnClick=!0,u.canDrag=!0,u.boundingRect=n.getBoundingClientRect(),n.style.transition="",u.x=C(t.nativeEvent),u.y=O(t.nativeEvent),"x"===e.draggableDirection?(u.start=u.x,u.removalDistance=n.offsetWidth*(e.draggablePercent/100)):(u.start=u.y,u.removalDistance=n.offsetHeight*(80===e.draggablePercent?1.5*e.draggablePercent:e.draggablePercent/100))}}function h(){if(u.boundingRect){var t=u.boundingRect;e.pauseOnHover&&u.x>=t.left&&u.x<=t.right&&u.y>=t.top&&u.y<=t.bottom?E():T()}}function T(){r(!0)}function E(){r(!1)}function b(t){var n=c.current;u.canDrag&&n&&(u.didMove=!0,o&&E(),u.x=C(t),u.y=O(t),u.delta="x"===e.draggableDirection?u.x-u.start:u.y-u.start,u.start!==u.x&&(u.canCloseOnClick=!1),n.style.transform="translate"+e.draggableDirection+"("+u.delta+"px)",n.style.opacity=""+(1-Math.abs(u.delta/u.removalDistance)))}function _(){document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",b),document.removeEventListener("touchend",_);var t=c.current;if(u.canDrag&&u.didMove&&t){if(u.canDrag=!1,Math.abs(u.delta)>u.removalDistance)return i(!0),void e.closeToast();t.style.transition="transform 0.2s, opacity 0.2s",t.style.transform="translate"+e.draggableDirection+"(0)",t.style.opacity="1"}}t.useEffect((function(){d.current=e})),t.useEffect((function(){return c.current&&c.current.addEventListener("d",T,{once:!0}),l(e.onOpen)&&e.onOpen(t.isValidElement(e.children)&&e.children.props),function(){var e=d.current;l(e.onClose)&&e.onClose(t.isValidElement(e.children)&&e.children.props)}}),[]),t.useEffect((function(){return e.pauseOnFocusLoss&&(document.hasFocus()||E(),window.addEventListener("focus",T),window.addEventListener("blur",E)),function(){e.pauseOnFocusLoss&&(window.removeEventListener("focus",T),window.removeEventListener("blur",E))}}),[e.pauseOnFocusLoss]);var I={onMouseDown:y,onTouchStart:y,onMouseUp:h,onTouchEnd:h};return f&&p&&(I.onMouseEnter=E,I.onMouseLeave=T),v&&(I.onClick=function(e){g&&g(e),u.canCloseOnClick&&m()}),{playToast:T,pauseToast:E,isRunning:o,preventExitTransition:s,toastRef:c,eventHandlers:I}}function I(e){var n=e.closeToast,o=e.ariaLabel;return t.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+e.theme,type:"button",onClick:function(e){e.stopPropagation(),n(e)},"aria-label":void 0===o?"close":o},t.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},t.createElement("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 L(e){var n,r,s=e.closeToast,i=e.type,c=e.hide,u=e.className,d=e.controlledProgress,f=e.progress,p=e.rtl,m=e.isIn,g=e.theme,v=a({},e.style,{animationDuration:e.delay+"ms",animationPlayState:e.isRunning?"running":"paused",opacity:c?0:1});d&&(v.transform="scaleX("+f+")");var y=o("Toastify__progress-bar",d?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar-theme--"+g,"Toastify__progress-bar--"+i,((n={})["Toastify__progress-bar--rtl"]=p,n)),h=l(u)?u({rtl:p,type:i,defaultClassName:y}):o(y,u),T=((r={})[d&&f>=1?"onTransitionEnd":"onAnimationEnd"]=d&&f<1?null:function(){m&&s()},r);return t.createElement("div",Object.assign({role:"progressbar","aria-hidden":c?"true":"false","aria-label":"notification timer",className:h,style:v},T))}L.defaultProps={type:v.DEFAULT,hide:!1};var x=["theme","type"],N=function(e){var n=e.theme,o=e.type,r=s(e,x);return t.createElement("svg",Object.assign({viewBox:"0 0 24 24",width:"100%",height:"100%",fill:"colored"===n?"currentColor":"var(--toastify-icon-color-"+o+")"},r))},R={info:function(e){return t.createElement(N,Object.assign({},e),t.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"}))},warning:function(e){return t.createElement(N,Object.assign({},e),t.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"}))},success:function(e){return t.createElement(N,Object.assign({},e),t.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"}))},error:function(e){return t.createElement(N,Object.assign({},e),t.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"}))},spinner:function(){return t.createElement("div",{className:"Toastify__spinner"})}},P=function(e){var n,r,a=_(e),s=a.isRunning,i=a.preventExitTransition,c=a.toastRef,d=a.eventHandlers,f=e.closeButton,p=e.children,m=e.autoClose,g=e.onClick,v=e.type,y=e.hideProgressBar,h=e.closeToast,T=e.transition,E=e.position,b=e.className,C=e.style,O=e.bodyClassName,I=e.bodyStyle,x=e.progressClassName,N=e.progressStyle,P=e.updateId,w=e.role,B=e.progress,k=e.rtl,M=e.toastId,D=e.deleteToast,A=e.isIn,S=e.isLoading,F=e.icon,z=e.theme,j=o("Toastify__toast","Toastify__toast-theme--"+z,"Toastify__toast--"+v,((n={})["Toastify__toast--rtl"]=k,n)),H=l(b)?b({rtl:k,position:E,type:v,defaultClassName:j}):o(j,b),q=!!B,U=R[v],Q={theme:z,type:v},V=U&&U(Q);return!1===F?V=void 0:l(F)?V=F(Q):t.isValidElement(F)?V=t.cloneElement(F,Q):u(F)?V=F:S&&(V=R.spinner()),t.createElement(T,{isIn:A,done:D,position:E,preventExitTransition:i,nodeRef:c},t.createElement("div",Object.assign({id:M,onClick:g,className:H},d,{style:C,ref:c}),t.createElement("div",Object.assign({},A&&{role:w},{className:l(O)?O({type:v}):o("Toastify__toast-body",O),style:I}),V&&t.createElement("div",{className:o("Toastify__toast-icon",(r={},r["Toastify--animate-icon Toastify__zoom-enter"]=!S,r))},V),t.createElement("div",null,p)),function(e){if(e){var n={closeToast:h,type:v,theme:z};return l(e)?e(n):t.isValidElement(e)?t.cloneElement(e,n):void 0}}(f),(m||q)&&t.createElement(L,Object.assign({},P&&!q?{key:"pb-"+P}:{},{rtl:k,theme:z,delay:m,isRunning:s,isIn:A,closeToast:h,hide:y,type:v,style:N,className:x,controlledProgress:q,progress:B}))))},w=h({enter:"Toastify--animate Toastify__bounce-enter",exit:"Toastify--animate Toastify__bounce-exit",appendPosition:!0}),B=h({enter:"Toastify--animate Toastify__slide-enter",exit:"Toastify--animate Toastify__slide-exit",appendPosition:!0}),k=h({enter:"Toastify--animate Toastify__zoom-enter",exit:"Toastify--animate Toastify__zoom-exit"}),M=h({enter:"Toastify--animate Toastify__flip-enter",exit:"Toastify--animate Toastify__flip-exit"}),D=function(e){var n=b(e),r=n.isToastActive,s=e.className,i=e.style,c=e.rtl;function u(e){var t,n=o("Toastify__toast-container","Toastify__toast-container--"+e,((t={})["Toastify__toast-container--rtl"]=c,t));return l(s)?s({position:e,rtl:c,defaultClassName:n}):o(n,d(s))}return t.createElement("div",{ref:n.containerRef,className:"Toastify",id:e.containerId},(0,n.getToastToRender)((function(e,n){var o=n.length?a({},i):a({},i,{pointerEvents:"none"});return t.createElement("div",{className:u(e),style:o,key:"container-"+e},n.map((function(e){var n=e.content,o=e.props;return t.createElement(P,Object.assign({},o,{isIn:r(o.toastId),key:"toast-"+o.key,closeButton:!0===o.closeButton?I:o.closeButton}),n)})))})))};D.defaultProps={position:g.TOP_RIGHT,transition:w,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:I,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};var A,S,F,z=new Map,j=[],H=!1;function q(){return Math.random().toString(36).substring(2,9)}function U(e){return e&&(u(e.toastId)||i(e.toastId))?e.toastId:q()}function Q(e,n){return z.size>0?T.emit(0,e,n):(j.push({content:e,options:n}),H&&p&&(H=!1,S=document.createElement("div"),document.body.appendChild(S),r.render(t.createElement(D,Object.assign({},F)),S))),n.toastId}function V(e,t){return a({},t,{type:t&&t.type||e,toastId:U(t)})}function G(e){return function(t,n){return Q(t,V(e,n))}}function W(e,t){return Q(e,V(v.DEFAULT,t))}W.loading=function(e,t){return Q(e,V(v.DEFAULT,a({isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1},t)))},W.promise=function(e,t,n){var o,r=t.pending,s=t.error,i=t.success;r&&(o=u(r)?W.loading(r,n):W.loading(r.render,a({},n,r)));var c={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},d=function(e,t,r){if(null!=t){var s=a({type:e},c,n,{data:r}),i=u(t)?{render:t}:t;return o?W.update(o,a({},s,i)):W(i.render,a({},s,i)),r}W.dismiss(o)},f=l(e)?e():e;return f.then((function(e){return d("success",i,e)})).catch((function(e){return d("error",s,e)})),f},W.success=G(v.SUCCESS),W.info=G(v.INFO),W.error=G(v.ERROR),W.warn=W.warning=G(v.WARNING),W.dark=function(e,t){return Q(e,V(v.DEFAULT,a({theme:"dark"},t)))},W.dismiss=function(e){return T.emit(1,e)},W.clearWaitingQueue=function(e){return void 0===e&&(e={}),T.emit(5,e)},W.isActive=function(e){var t=!1;return z.forEach((function(n){n.isToastActive&&n.isToastActive(e)&&(t=!0)})),t},W.update=function(e,t){void 0===t&&(t={}),setTimeout((function(){var n=function(e,t){var n=z.get(t.containerId||A);return n?n.getToast(e):null}(e,t);if(n){var o=n.content,r=a({},n.props,t,{toastId:t.toastId||e,updateId:q()});r.toastId!==e&&(r.staleId=e);var s=r.render||o;delete r.render,Q(s,r)}}),0)},W.done=function(e){W.update(e,{progress:1})},W.onChange=function(e){return l(e)&&T.on(4,e),function(){l(e)&&T.off(4,e)}},W.configure=function(e){void 0===e&&(e={}),H=!0,F=e},W.POSITION=g,W.TYPE=v,T.on(2,(function(e){z.set(A=e.containerId||e,e),j.forEach((function(e){T.emit(0,e.content,e.options)})),j=[]})).on(3,(function(e){z.delete(e.containerId||e),0===z.size&&T.off(0).off(1).off(5),p&&S&&document.body.removeChild(S)})),exports.Bounce=w,exports.Flip=M,exports.Icons=R,exports.Slide=B,exports.ToastContainer=D,exports.Zoom=k,exports.collapseToast=y,exports.cssTransition=h,exports.toast=W,exports.useToast=_,exports.useToastContainer=b;
//# sourceMappingURL=react-toastify.cjs.production.min.js.map

@@ -1,2 +0,2 @@

import React__default, { isValidElement, useRef, useLayoutEffect, useEffect, useReducer, cloneElement, useState, createElement } from 'react';
import React__default, { isValidElement, useRef, useLayoutEffect, useEffect, useReducer, useState, cloneElement, createElement } from 'react';
import cx from 'clsx';

@@ -158,2 +158,5 @@ import { render } from 'react-dom';

var node = nodeRef.current;
node.dispatchEvent(new Event("d"
/* ENTRANCE_ANIMATION_END */
));
node.removeEventListener('animationend', onEntered);

@@ -245,39 +248,2 @@

/**
* `useKeeper` is a helper around `useRef`.
*
* You don't need to access the `.current`property to get the value
* If refresh is set to true. The ref will be updated every render
*/
function useKeeper(arg, refresh) {
if (refresh === void 0) {
refresh = false;
}
var ref = useRef(arg);
useEffect(function () {
if (refresh) ref.current = arg;
});
return ref.current;
}
function reducer(state, action) {
switch (action.type) {
case 0
/* ADD */
:
return [].concat(state, [action.toastId]).filter(function (id) {
return id !== action.staleId;
});
case 1
/* REMOVE */
:
return isToastIdValid(action.toastId) ? state.filter(function (id) {
return id !== action.toastId;
}) : [];
}
}
var _excluded = ["delay", "staleId"];

@@ -290,13 +256,18 @@ function useToastContainer(props) {

var _useReducer2 = useReducer(reducer, []),
toast = _useReducer2[0],
dispatch = _useReducer2[1];
var _useState = useState([]),
toastIds = _useState[0],
setToastIds = _useState[1];
var containerRef = useRef(null);
var toastCount = useKeeper(0);
var queue = useKeeper([]);
var collection = useKeeper({});
var instance = useKeeper({
var toastToRender = useRef(new Map()).current;
var isToastActive = function isToastActive(id) {
return toastIds.indexOf(id) !== -1;
};
var instance = useRef({
toastKey: 1,
displayedToast: 0,
count: 0,
queue: [],
props: props,

@@ -306,5 +277,5 @@ containerId: null,

getToast: function getToast(id) {
return collection[id] || null;
return toastToRender.get(id);
}
});
}).current;
useEffect(function () {

@@ -333,7 +304,7 @@ instance.containerId = props.containerId;

instance.isToastActive = isToastActive;
instance.displayedToast = toast.length;
instance.displayedToast = toastIds.length;
eventManager.emit(4
/* Change */
, toast.length, props.containerId);
}, [toast]);
, toastIds.length, props.containerId);
}, [toastIds]);
useEffect(function () {

@@ -343,6 +314,2 @@ instance.props = props;

function isToastActive(id) {
return toast.indexOf(id) !== -1;
}
function clearWaitingQueue(_ref) {

@@ -353,4 +320,4 @@ var containerId = _ref.containerId;

if (limit && (!containerId || instance.containerId === containerId)) {
toastCount -= queue.length;
queue = [];
instance.count -= instance.queue.length;
instance.queue = [];
}

@@ -360,7 +327,6 @@ }

function removeToast(toastId) {
dispatch({
type: 1
/* REMOVE */
,
toastId: toastId
setToastIds(function (state) {
return isToastIdValid(toastId) ? state.filter(function (id) {
return id !== toastId;
}) : [];
});

@@ -370,6 +336,6 @@ }

function dequeueToast() {
var _queue$shift = queue.shift(),
toastContent = _queue$shift.toastContent,
toastProps = _queue$shift.toastProps,
staleId = _queue$shift.staleId;
var _instance$queue$shift = instance.queue.shift(),
toastContent = _instance$queue$shift.toastContent,
toastProps = _instance$queue$shift.toastProps,
staleId = _instance$queue$shift.staleId;

@@ -385,17 +351,12 @@ appendToast(toastContent, toastProps, staleId);

function isNotValid(_ref2) {
var containerId = _ref2.containerId,
toastId = _ref2.toastId,
updateId = _ref2.updateId;
return !containerRef.current || instance.props.enableMultiContainer && containerId !== instance.props.containerId || collection[toastId] && updateId == null ? true : false;
} // this function and all the function called inside needs to rely on ref(`useKeeper`)
function isNotValid(options) {
return !containerRef.current || instance.props.enableMultiContainer && options.containerId !== instance.props.containerId || toastToRender.has(options.toastId) && options.updateId == null;
} // this function and all the function called inside needs to rely on refs
function buildToast(content, _ref3) {
var _options$icon;
function buildToast(content, _ref2) {
var delay = _ref2.delay,
staleId = _ref2.staleId,
options = _objectWithoutPropertiesLoose(_ref2, _excluded);
var delay = _ref3.delay,
staleId = _ref3.staleId,
options = _objectWithoutPropertiesLoose(_ref3, _excluded);
if (!canBeRendered(content) || isNotValid(options)) return;

@@ -411,4 +372,4 @@ var toastId = options.toastId,

var isNotAnUpdate = options.updateId == null;
if (isNotAnUpdate) toastCount++;
var isNotAnUpdate = updateId == null;
if (isNotAnUpdate) instance.count++;
var toastProps = {

@@ -419,3 +380,3 @@ toastId: toastId,

theme: options.theme || props.theme,
icon: (_options$icon = options.icon) != null ? _options$icon : props.icon,
icon: options.icon != null ? options.icon : props.icon,
isIn: false,

@@ -437,3 +398,3 @@ key: options.key || instance.toastKey++,

draggable: isBool(options.draggable) ? options.draggable : props.draggable,
draggablePercent: isNum(options.draggablePercent) ? options.draggablePercent : props.draggablePercent,
draggablePercent: options.draggablePercent || props.draggablePercent,
draggableDirection: options.draggableDirection || props.draggableDirection,

@@ -446,27 +407,38 @@ closeOnClick: isBool(options.closeOnClick) ? options.closeOnClick : props.closeOnClick,

progress: options.progress,
role: isStr(options.role) ? options.role : props.role,
role: options.role || props.role,
deleteToast: function deleteToast() {
removeFromCollection(toastId);
toastToRender["delete"](toastId);
var queueLen = instance.queue.length;
instance.count = isToastIdValid(toastId) ? instance.count - 1 : instance.count - instance.displayedToast;
if (instance.count < 0) instance.count = 0;
if (queueLen > 0) {
var freeSlot = isToastIdValid(toastId) ? 1 : instance.props.limit;
if (queueLen === 1 || freeSlot === 1) {
instance.displayedToast++;
dequeueToast();
} else {
var toDequeue = freeSlot > queueLen ? queueLen : freeSlot;
instance.displayedToast = toDequeue;
for (var i = 0; i < toDequeue; i++) {
dequeueToast();
}
}
} else {
forceUpdate();
}
}
};
if (isFn(options.onOpen)) toastProps.onOpen = options.onOpen;
if (isFn(options.onClose)) toastProps.onClose = options.onClose; // tweak for vertical dragging
if (isFn(options.onClose)) toastProps.onClose = options.onClose;
toastProps.closeButton = props.closeButton;
if (toastProps.draggableDirection === "y"
/* Y */
&& toastProps.draggablePercent === 80
/* DRAGGABLE_PERCENT */
) {
toastProps.draggablePercent *= 1.5;
}
var closeButton = props.closeButton;
if (options.closeButton === false || canBeRendered(options.closeButton)) {
closeButton = options.closeButton;
toastProps.closeButton = options.closeButton;
} else if (options.closeButton === true) {
closeButton = canBeRendered(props.closeButton) ? props.closeButton : true;
toastProps.closeButton = canBeRendered(props.closeButton) ? props.closeButton : true;
}
toastProps.closeButton = closeButton;
var toastContent = content;

@@ -489,4 +461,4 @@

if (props.limit && props.limit > 0 && toastCount > props.limit && isNotAnUpdate) {
queue.push({
if (props.limit && props.limit > 0 && instance.count > props.limit && isNotAnUpdate) {
instance.queue.push({
toastContent: toastContent,

@@ -507,55 +479,26 @@ toastProps: toastProps,

var toastId = toastProps.toastId;
if (staleId) delete collection[staleId];
collection[toastId] = {
if (staleId) toastToRender["delete"](staleId);
toastToRender.set(toastId, {
content: content,
props: toastProps
};
dispatch({
type: 0
/* ADD */
,
toastId: toastId,
staleId: staleId
});
setToastIds(function (state) {
return [].concat(state, [toastId]).filter(function (id) {
return id !== staleId;
});
});
}
function removeFromCollection(toastId) {
delete collection[toastId];
var queueLen = queue.length;
toastCount = isToastIdValid(toastId) ? toastCount - 1 : toastCount - instance.displayedToast;
if (toastCount < 0) toastCount = 0;
if (queueLen > 0) {
var freeSlot = isToastIdValid(toastId) ? 1 : instance.props.limit;
if (queueLen === 1 || freeSlot === 1) {
instance.displayedToast++;
dequeueToast();
} else {
var toDequeue = freeSlot > queueLen ? queueLen : freeSlot;
instance.displayedToast = toDequeue;
for (var i = 0; i < toDequeue; i++) {
dequeueToast();
}
}
} else {
forceUpdate();
}
}
function getToastToRender(cb) {
var toastToRender = {};
var toastList = props.newestOnTop ? Object.keys(collection).reverse() : Object.keys(collection);
for (var i = 0; i < toastList.length; i++) {
var _toast = collection[toastList[i]];
var position = _toast.props.position;
toastToRender[position] || (toastToRender[position] = []);
toastToRender[position].push(_toast);
}
return Object.keys(toastToRender).map(function (p) {
return cb(p, toastToRender[p]);
var toRender = new Map();
var collection = Array.from(toastToRender.values());
if (props.newestOnTop) collection.reverse();
collection.forEach(function (toast) {
var position = toast.props.position;
toRender.has(position) || toRender.set(position, []);
toRender.get(position).push(toast);
});
return Array.from(toRender, function (p) {
return cb(p[0], p[1]);
});
}

@@ -565,3 +508,2 @@

getToastToRender: getToastToRender,
collection: collection,
containerRef: containerRef,

@@ -581,3 +523,3 @@ isToastActive: isToastActive

function useToast(props) {
var _useState = useState(true),
var _useState = useState(false),
isRunning = _useState[0],

@@ -591,3 +533,3 @@ setIsRunning = _useState[1];

var toastRef = useRef(null);
var drag = useKeeper({
var drag = useRef({
start: 0,

@@ -600,5 +542,6 @@ x: 0,

canDrag: false,
boundingRect: null
});
var syncProps = useKeeper(props, true);
boundingRect: null,
didMove: false
}).current;
var syncProps = useRef(props);
var autoClose = props.autoClose,

@@ -610,14 +553,17 @@ pauseOnHover = props.pauseOnHover,

useEffect(function () {
syncProps.current = props;
});
useEffect(function () {
if (toastRef.current) toastRef.current.addEventListener("d"
/* ENTRANCE_ANIMATION_END */
, playToast, {
once: true
});
if (isFn(props.onOpen)) props.onOpen(isValidElement(props.children) && props.children.props);
return function () {
if (isFn(syncProps.onClose)) syncProps.onClose(isValidElement(syncProps.children) && syncProps.children.props);
var props = syncProps.current;
if (isFn(props.onClose)) props.onClose(isValidElement(props.children) && props.children.props);
};
}, []);
useEffect(function () {
props.draggable && bindDragEvents();
return function () {
props.draggable && unbindDragEvents();
};
}, [props.draggable]);
useEffect(function () {
props.pauseOnFocusLoss && bindFocusEvents();

@@ -631,2 +577,3 @@ return function () {

if (props.draggable) {
bindDragEvents();
var toast = toastRef.current;

@@ -647,3 +594,5 @@ drag.canCloseOnClick = true;

drag.start = drag.y;
drag.removalDistance = toast.offsetHeight * (props.draggablePercent / 100);
drag.removalDistance = toast.offsetHeight * (props.draggablePercent === 80
/* DRAGGABLE_PERCENT */
? props.draggablePercent * 1.5 : props.draggablePercent / 100);
}

@@ -689,2 +638,3 @@ }

function bindDragEvents() {
drag.didMove = false;
document.addEventListener('mousemove', onDragMove);

@@ -704,5 +654,6 @@ document.addEventListener('mouseup', onDragEnd);

function onDragMove(e) {
if (drag.canDrag) {
e.preventDefault();
var toast = toastRef.current;
var toast = toastRef.current;
if (drag.canDrag && toast) {
drag.didMove = true;
if (isRunning) pauseToast();

@@ -728,5 +679,6 @@ drag.x = getX(e);

function onDragEnd() {
unbindDragEvents();
var toast = toastRef.current;
if (drag.canDrag) {
if (drag.canDrag && drag.didMove && toast) {
drag.canDrag = false;

@@ -870,3 +822,3 @@

return React__default.createElement("svg", Object.assign({
return createElement("svg", Object.assign({
viewBox: "0 0 24 24",

@@ -880,3 +832,3 @@ width: "100%",

function Warning(props) {
return React__default.createElement(Svg, Object.assign({}, props), React__default.createElement("path", {
return createElement(Svg, Object.assign({}, props), 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"

@@ -887,3 +839,3 @@ }));

function Info(props) {
return React__default.createElement(Svg, Object.assign({}, props), React__default.createElement("path", {
return createElement(Svg, Object.assign({}, props), 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"

@@ -894,3 +846,3 @@ }));

function Success(props) {
return React__default.createElement(Svg, Object.assign({}, props), React__default.createElement("path", {
return createElement(Svg, Object.assign({}, props), 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"

@@ -901,3 +853,3 @@ }));

function Error(props) {
return React__default.createElement(Svg, Object.assign({}, props), React__default.createElement("path", {
return createElement(Svg, Object.assign({}, props), 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"

@@ -908,3 +860,3 @@ }));

function Spinner() {
return React__default.createElement("div", {
return createElement("div", {
className: "Toastify"

@@ -1138,3 +1090,3 @@ /* CSS_NAMESPACE */

}, getToastToRender(function (position, toastList) {
var containerStyle = toastList.length === 0 ? _extends({}, style, {
var containerStyle = !toastList.length ? _extends({}, style, {
pointerEvents: 'none'

@@ -1186,13 +1138,5 @@ }) : _extends({}, style);

/**
* Check whether any container is currently mounted in the DOM
*/
function isAnyContainerMounted() {
return containers.size > 0;
}
/**
* Get the toast by id, given it's in the DOM, otherwise returns null
*/
function getToast(toastId, _ref) {

@@ -1210,3 +1154,3 @@ var containerId = _ref.containerId;

function generateToastId() {
return Math.random().toString(36).substr(2, 9);
return Math.random().toString(36).substring(2, 9);
}

@@ -1232,3 +1176,3 @@ /**

function dispatchToast(content, options) {
if (isAnyContainerMounted()) {
if (containers.size > 0) {
eventManager.emit(0

@@ -1265,11 +1209,11 @@ /* Show */

var createToastByType = function createToastByType(type) {
function createToastByType(type) {
return function (content, options) {
return dispatchToast(content, mergeOptions(type, options));
};
};
}
var toast = function toast(content, options) {
function toast(content, options) {
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, options));
};
}

@@ -1305,2 +1249,9 @@ toast.loading = function (content, options) {

var resolver = function resolver(type, input, result) {
// Remove the toast if the input has not been provided. This prevents the toast from hanging
// in the pending state if a success/error toast has not been provided.
if (input == null) {
toast.dismiss(id);
return;
}
var baseParams = _extends({

@@ -1329,5 +1280,5 @@ type: type

p.then(function (result) {
return success && resolver('success', success, result);
return resolver('success', success, result);
})["catch"](function (err) {
return error && resolver('error', error, err);
return resolver('error', error, err);
});

@@ -1445,2 +1396,3 @@ return p;

* Configure the ToastContainer when lazy mounted
* Prefer ToastContainer over this one
*/

@@ -1447,0 +1399,0 @@

@@ -20,2 +20,5 @@ import { ToastPosition, TypeOptions } from '../types';

}
export declare const enum SyntheticEvent {
ENTRANCE_ANIMATION_END = "d"
}
export {};

@@ -0,1 +1,2 @@

/// <reference types="react" />
import { ToastTransitionProps } from '../types';

@@ -2,0 +3,0 @@ export interface CSSTransitionProps {

{
"version": "8.1.0",
"version": "8.1.1",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc