import { _ as _asyncToGenerator, r as regenerator } from '../index-qSfOyGhk.js';
import { _ as _extends } from '../extends-C4cduGrv.js';
import { _ as _objectWithoutProperties } from '../objectWithoutProperties-TXwlfNxG.js';
import * as React from 'react';
import React__default, { useEffect, useCallback, useState } from 'react';
import PropTypes from 'prop-types';
import CloseIcon from './assets/close.js';
import SuccessIcon from './assets/success.js';
import ErrorIcon from './assets/error.js';
import InfoIcon from './assets/info.js';
import { B as Button } from '../index-CMfVNfTW.js';
import VisuallyHidden from '@reach/visually-hidden';
import { _ as _slicedToArray } from '../slicedToArray-BB-AwwkK.js';
import { _ as _toConsumableArray } from '../toConsumableArray-dKQYsfpV.js';
import { _ as _defineProperty } from '../defineProperty-CEd-kZQW.js';
import { _ as _typeof } from '../typeof-CgC7Bq6K.js';
import 'react-dom';
import 'classnames';
import '../icon/assets/icon-map/index.js';
import '../social-icon/index.js';
import '@fortawesome/react-fontawesome';
import '../social-icon/icons.js';
import '../social-icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/free-solid-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../tooltip/index.js';
import '../auto-id.esm-CjaDlg7r.js';
import '../utils.esm-BKUEBdyY.js';
import '../warning-s9zGJbnw.js';
import '../portal.esm-D9LQ40g_.js';
import '../portal/index.js';
import '../use-rerender-once/index.js';
import '../use-force-update/index.js';
import '../button/button-group.js';
import '../inject-css-BqVV5N0s.js';

function _taggedTemplateLiteral(strings, raw) {
  if (!raw) {
    raw = strings.slice(0);
  }

  return Object.freeze(Object.defineProperties(strings, {
    raw: {
      value: Object.freeze(raw)
    }
  }));
}

var e = {
  data: ""
},
    t = function t(_t) {
  return "object" == (typeof window === "undefined" ? "undefined" : _typeof(window)) ? ((_t ? _t.querySelector("#_goober") : window._goober) || Object.assign((_t || document.head).appendChild(document.createElement("style")), {
    innerHTML: " ",
    id: "_goober"
  })).firstChild : _t || e;
},
    l = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,
    a = /\/\*[^]*?\*\/|  +/g,
    n$1 = /\n+/g,
    o = function o(e, t) {
  var r = "",
      l = "",
      a = "";

  var _loop = function _loop(_n2) {
    var c = e[_n2];
    "@" == _n2[0] ? "i" == _n2[1] ? r = _n2 + " " + c + ";" : l += "f" == _n2[1] ? o(c, _n2) : _n2 + "{" + o(c, "k" == _n2[1] ? "" : t) + "}" : "object" == _typeof(c) ? l += o(c, t ? t.replace(/([^,])+/g, function (e) {
      return _n2.replace(/(^:.*)|([^,])+/g, function (t) {
        return /&/.test(t) ? t.replace(/&/g, e) : e ? e + " " + t : t;
      });
    }) : _n2) : null != c && (_n2 = /^--/.test(_n2) ? _n2 : _n2.replace(/[A-Z]/g, "-$&").toLowerCase(), a += o.p ? o.p(_n2, c) : _n2 + ":" + c + ";");
    _n = _n2;
  };

  for (var _n in e) {
    _loop(_n);
  }

  return r + (t && a ? t + "{" + a + "}" : a) + l;
},
    c = {},
    s = function s(e) {
  if ("object" == _typeof(e)) {
    var _t2 = "";

    for (var _r in e) {
      _t2 += _r + s(e[_r]);
    }

    return _t2;
  }

  return e;
},
    i = function i(e, t, r, _i, p) {
  var u = s(e),
      d = c[u] || (c[u] = function (e) {
    var t = 0,
        r = 11;

    for (; t < e.length;) {
      r = 101 * r + e.charCodeAt(t++) >>> 0;
    }

    return "go" + r;
  }(u));

  if (!c[d]) {
    var _t3 = u !== e ? e : function (e) {
      var t,
          r,
          o = [{}];

      for (; t = l.exec(e.replace(a, ""));) {
        t[4] ? o.shift() : t[3] ? (r = t[3].replace(n$1, " ").trim(), o.unshift(o[0][r] = o[0][r] || {})) : o[0][t[1]] = t[2].replace(n$1, " ").trim();
      }

      return o[0];
    }(e);

    c[d] = o(p ? _defineProperty({}, "@keyframes " + d, _t3) : _t3, r ? "" : "." + d);
  }

  var f = r && c.g ? c.g : null;
  return r && (c.g = c[d]), function (e, t, r, l) {
    l ? t.data = t.data.replace(l, e) : -1 === t.data.indexOf(e) && (t.data = r ? e + t.data : t.data + e);
  }(c[d], t, _i, f), d;
},
    p = function p(e, t, r) {
  return e.reduce(function (e, l, a) {
    var n = t[a];

    if (n && n.call) {
      var _e = n(r),
          _t4 = _e && _e.props && _e.props.className || /^go/.test(_e) && _e;

      n = _t4 ? "." + _t4 : _e && "object" == _typeof(_e) ? _e.props ? "" : o(_e, "") : !1 === _e ? "" : _e;
    }

    return e + l + (null == n ? "" : n);
  }, "");
};

function u$1(e) {
  var r = this || {},
      l = e.call ? e(r.p) : e;
  return i(l.unshift ? l.raw ? p(l, [].slice.call(arguments, 1), r.p) : l.reduce(function (e, t) {
    return Object.assign(e, t && t.call ? t(r.p) : t);
  }, {}) : l, t(r.target), r.g, r.o, r.k);
}

var d,
    f,
    g;
    u$1.bind({
  g: 1
});
    var h$1 = u$1.bind({
  k: 1
});

function m(e, t, r, l) {
  o.p = t, d = e, f = r, g = l;
}

function j(e, t) {
  var r = this || {};
  return function () {
    var l = arguments;

    function a(n, o) {
      var c = Object.assign({}, n),
          s = c.className || a.className;
      r.p = Object.assign({
        theme: f && f()
      }, c), r.o = / *go\d+/.test(s), c.className = u$1.apply(r, l) + (s ? " " + s : ""), t && (c.ref = o);
      var i = e;
      return e[0] && (i = c.as || e, delete c.as), g && i[0] && g(c), d(i, c);
    }

    return t ? t(a) : a;
  };
}

var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16;

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var W = function W(e) {
  return typeof e == "function";
},
    T = function T(e, t) {
  return W(e) ? e(t) : e;
};

var U = function () {
  var e = 0;
  return function () {
    return (++e).toString();
  };
}(),
    b = function () {
  var e;
  return function () {
    if (e === void 0 && (typeof window === "undefined" ? "undefined" : _typeof(window)) < "u") {
      var t = matchMedia("(prefers-reduced-motion: reduce)");
      e = !t || t.matches;
    }

    return e;
  };
}();
var Q = 20;

var S = new Map(),
    X = 1e3,
    $ = function $(e) {
  if (S.has(e)) return;
  var t = setTimeout(function () {
    S["delete"](e), u({
      type: 4,
      toastId: e
    });
  }, X);
  S.set(e, t);
},
    J = function J(e) {
  var t = S.get(e);
  t && clearTimeout(t);
},
    v = function v(e, t) {
  switch (t.type) {
    case 0:
      return _objectSpread(_objectSpread({}, e), {}, {
        toasts: [t.toast].concat(_toConsumableArray(e.toasts)).slice(0, Q)
      });

    case 1:
      return t.toast.id && J(t.toast.id), _objectSpread(_objectSpread({}, e), {}, {
        toasts: e.toasts.map(function (r) {
          return r.id === t.toast.id ? _objectSpread(_objectSpread({}, r), t.toast) : r;
        })
      });

    case 2:
      var o = t.toast;
      return e.toasts.find(function (r) {
        return r.id === o.id;
      }) ? v(e, {
        type: 1,
        toast: o
      }) : v(e, {
        type: 0,
        toast: o
      });

    case 3:
      var s = t.toastId;
      return s ? $(s) : e.toasts.forEach(function (r) {
        $(r.id);
      }), _objectSpread(_objectSpread({}, e), {}, {
        toasts: e.toasts.map(function (r) {
          return r.id === s || s === void 0 ? _objectSpread(_objectSpread({}, r), {}, {
            visible: !1
          }) : r;
        })
      });

    case 4:
      return t.toastId === void 0 ? _objectSpread(_objectSpread({}, e), {}, {
        toasts: []
      }) : _objectSpread(_objectSpread({}, e), {}, {
        toasts: e.toasts.filter(function (r) {
          return r.id !== t.toastId;
        })
      });

    case 5:
      return _objectSpread(_objectSpread({}, e), {}, {
        pausedAt: t.time
      });

    case 6:
      var a = t.time - (e.pausedAt || 0);
      return _objectSpread(_objectSpread({}, e), {}, {
        pausedAt: void 0,
        toasts: e.toasts.map(function (r) {
          return _objectSpread(_objectSpread({}, r), {}, {
            pauseDuration: r.pauseDuration + a
          });
        })
      });
  }
},
    A = [],
    P = {
  toasts: [],
  pausedAt: void 0
},
    u = function u(e) {
  P = v(P, e), A.forEach(function (t) {
    t(P);
  });
},
    Y = {
  blank: 4e3,
  error: 4e3,
  success: 2e3,
  loading: 1 / 0,
  custom: 4e3
},
    I = function I() {
  var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

  var _j = useState(P),
      _j2 = _slicedToArray(_j, 2),
      t = _j2[0],
      o = _j2[1];

  useEffect(function () {
    return A.push(o), function () {
      var a = A.indexOf(o);
      a > -1 && A.splice(a, 1);
    };
  }, [t]);
  var s = t.toasts.map(function (a) {
    var r, c;
    return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, e), e[a.type]), a), {}, {
      duration: a.duration || ((r = e[a.type]) == null ? void 0 : r.duration) || (e == null ? void 0 : e.duration) || Y[a.type],
      style: _objectSpread(_objectSpread(_objectSpread({}, e.style), (c = e[a.type]) == null ? void 0 : c.style), a.style)
    });
  });
  return _objectSpread(_objectSpread({}, t), {}, {
    toasts: s
  });
};

var G = function G(e) {
  var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "blank";
  var o = arguments.length > 2 ? arguments[2] : undefined;
  return _objectSpread(_objectSpread({
    createdAt: Date.now(),
    visible: !0,
    type: t,
    ariaProps: {
      role: "status",
      "aria-live": "polite"
    },
    message: e,
    pauseDuration: 0
  }, o), {}, {
    id: (o == null ? void 0 : o.id) || U()
  });
},
    h = function h(e) {
  return function (t, o) {
    var s = G(t, e, o);
    return u({
      type: 2,
      toast: s
    }), s.id;
  };
},
    n = function n(e, t) {
  return h("blank")(e, t);
};

n.error = h("error");
n.success = h("success");
n.loading = h("loading");
n.custom = h("custom");

n.dismiss = function (e) {
  u({
    type: 3,
    toastId: e
  });
};

n.remove = function (e) {
  return u({
    type: 4,
    toastId: e
  });
};

n.promise = function (e, t, o) {
  var s = n.loading(t.loading, _objectSpread(_objectSpread({}, o), o == null ? void 0 : o.loading));
  return e.then(function (a) {
    return n.success(T(t.success, a), _objectSpread(_objectSpread({
      id: s
    }, o), o == null ? void 0 : o.success)), a;
  })["catch"](function (a) {
    n.error(T(t.error, a), _objectSpread(_objectSpread({
      id: s
    }, o), o == null ? void 0 : o.error));
  }), e;
};

var Z = function Z(e, t) {
  u({
    type: 1,
    toast: {
      id: e,
      height: t
    }
  });
},
    ee = function ee() {
  u({
    type: 5,
    time: Date.now()
  });
},
    D = function D(e) {
  var _I = I(e),
      t = _I.toasts,
      o = _I.pausedAt;

  useEffect(function () {
    if (o) return;
    var r = Date.now(),
        c = t.map(function (i) {
      if (i.duration === 1 / 0) return;
      var d = (i.duration || 0) + i.pauseDuration - (r - i.createdAt);

      if (d < 0) {
        i.visible && n.dismiss(i.id);
        return;
      }

      return setTimeout(function () {
        return n.dismiss(i.id);
      }, d);
    });
    return function () {
      c.forEach(function (i) {
        return i && clearTimeout(i);
      });
    };
  }, [t, o]);
  var s = useCallback(function () {
    o && u({
      type: 6,
      time: Date.now()
    });
  }, [o]),
      a = useCallback(function (r, c) {
    var _g$filter;

    var _ref = c || {},
        _ref$reverseOrder = _ref.reverseOrder,
        i = _ref$reverseOrder === void 0 ? !1 : _ref$reverseOrder,
        _ref$gutter = _ref.gutter,
        d = _ref$gutter === void 0 ? 8 : _ref$gutter,
        p = _ref.defaultPosition,
        g = t.filter(function (m) {
      return (m.position || p) === (r.position || p) && m.height;
    }),
        E = g.findIndex(function (m) {
      return m.id === r.id;
    }),
        x = g.filter(function (m, R) {
      return R < E && m.visible;
    }).length;

    return (_g$filter = g.filter(function (m) {
      return m.visible;
    })).slice.apply(_g$filter, _toConsumableArray(i ? [x + 1] : [0, x])).reduce(function (m, R) {
      return m + (R.height || 0) + d;
    }, 0);
  }, [t]);
  return {
    toasts: t,
    handlers: {
      updateHeight: Z,
      startPause: ee,
      endPause: s,
      calculateOffset: a
    }
  };
};

var oe = h$1(_templateObject || (_templateObject = _taggedTemplateLiteral(["\nfrom {\n  transform: scale(0) rotate(45deg);\n\topacity: 0;\n}\nto {\n transform: scale(1) rotate(45deg);\n  opacity: 1;\n}"]))),
    re = h$1(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\nfrom {\n  transform: scale(0);\n  opacity: 0;\n}\nto {\n  transform: scale(1);\n  opacity: 1;\n}"]))),
    se = h$1(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\nfrom {\n  transform: scale(0) rotate(90deg);\n\topacity: 0;\n}\nto {\n  transform: scale(1) rotate(90deg);\n\topacity: 1;\n}"]))),
    _ = j("div")(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n  width: 20px;\n  opacity: 0;\n  height: 20px;\n  border-radius: 10px;\n  background: ", ";\n  position: relative;\n  transform: rotate(45deg);\n\n  animation: ", " 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)\n    forwards;\n  animation-delay: 100ms;\n\n  &:after,\n  &:before {\n    content: '';\n    animation: ", " 0.15s ease-out forwards;\n    animation-delay: 150ms;\n    position: absolute;\n    border-radius: 3px;\n    opacity: 0;\n    background: ", ";\n    bottom: 9px;\n    left: 4px;\n    height: 2px;\n    width: 12px;\n  }\n\n  &:before {\n    animation: ", " 0.15s ease-out forwards;\n    animation-delay: 180ms;\n    transform: rotate(90deg);\n  }\n"])), function (e) {
  return e.primary || "#ff4b4b";
}, oe, re, function (e) {
  return e.secondary || "#fff";
}, se);
var ne = h$1(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n  from {\n    transform: rotate(0deg);\n  }\n  to {\n    transform: rotate(360deg);\n  }\n"]))),
    V = j("div")(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n  width: 12px;\n  height: 12px;\n  box-sizing: border-box;\n  border: 2px solid;\n  border-radius: 100%;\n  border-color: ", ";\n  border-right-color: ", ";\n  animation: ", " 1s linear infinite;\n"])), function (e) {
  return e.secondary || "#e0e0e0";
}, function (e) {
  return e.primary || "#616161";
}, ne);
var pe = h$1(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\nfrom {\n  transform: scale(0) rotate(45deg);\n\topacity: 0;\n}\nto {\n  transform: scale(1) rotate(45deg);\n\topacity: 1;\n}"]))),
    de = h$1(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n0% {\n\theight: 0;\n\twidth: 0;\n\topacity: 0;\n}\n40% {\n  height: 0;\n\twidth: 6px;\n\topacity: 1;\n}\n100% {\n  opacity: 1;\n  height: 10px;\n}"]))),
    w = j("div")(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n  width: 20px;\n  opacity: 0;\n  height: 20px;\n  border-radius: 10px;\n  background: ", ";\n  position: relative;\n  transform: rotate(45deg);\n\n  animation: ", " 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)\n    forwards;\n  animation-delay: 100ms;\n  &:after {\n    content: '';\n    box-sizing: border-box;\n    animation: ", " 0.2s ease-out forwards;\n    opacity: 0;\n    animation-delay: 200ms;\n    position: absolute;\n    border-right: 2px solid;\n    border-bottom: 2px solid;\n    border-color: ", ";\n    bottom: 6px;\n    left: 6px;\n    height: 10px;\n    width: 6px;\n  }\n"])), function (e) {
  return e.primary || "#61d345";
}, pe, de, function (e) {
  return e.secondary || "#fff";
});

var ue = j("div")(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n  position: absolute;\n"]))),
    le = j("div")(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n  position: relative;\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  min-width: 20px;\n  min-height: 20px;\n"]))),
    Te = h$1(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\nfrom {\n  transform: scale(0.6);\n  opacity: 0.4;\n}\nto {\n  transform: scale(1);\n  opacity: 1;\n}"]))),
    fe = j("div")(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n  position: relative;\n  transform: scale(0.6);\n  opacity: 0.4;\n  min-width: 20px;\n  animation: ", " 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)\n    forwards;\n"])), Te),
    M = function M(_ref2) {
  var e = _ref2.toast;
  var t = e.icon,
      o = e.type,
      s = e.iconTheme;
  return t !== void 0 ? typeof t == "string" ? /*#__PURE__*/React.createElement(fe, null, t) : t : o === "blank" ? null : /*#__PURE__*/React.createElement(le, null, /*#__PURE__*/React.createElement(V, _objectSpread({}, s)), o !== "loading" && /*#__PURE__*/React.createElement(ue, null, o === "error" ? /*#__PURE__*/React.createElement(_, _objectSpread({}, s)) : /*#__PURE__*/React.createElement(w, _objectSpread({}, s))));
};

var ye = function ye(e) {
  return "\n0% {transform: translate3d(0,".concat(e * -200, "%,0) scale(.6); opacity:.5;}\n100% {transform: translate3d(0,0,0) scale(1); opacity:1;}\n");
},
    ge = function ge(e) {
  return "\n0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}\n100% {transform: translate3d(0,".concat(e * -150, "%,-1px) scale(.6); opacity:0;}\n");
},
    he = "0%{opacity:0;} 100%{opacity:1;}",
    xe = "0%{opacity:1;} 100%{opacity:0;}",
    be = j("div")(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n  display: flex;\n  align-items: center;\n  background: #fff;\n  color: #363636;\n  line-height: 1.3;\n  will-change: transform;\n  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05);\n  max-width: 350px;\n  pointer-events: auto;\n  padding: 8px 10px;\n  border-radius: 8px;\n"]))),
    Se = j("div")(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n  display: flex;\n  justify-content: center;\n  margin: 4px 10px;\n  color: inherit;\n  flex: 1 1 auto;\n  white-space: pre-line;\n"]))),
    Ae = function Ae(e, t) {
  var s = e.includes("top") ? 1 : -1,
      _ref3 = b() ? [he, xe] : [ye(s), ge(s)],
      _ref4 = _slicedToArray(_ref3, 2),
      a = _ref4[0],
      r = _ref4[1];

  return {
    animation: t ? "".concat(h$1(a), " 0.35s cubic-bezier(.21,1.02,.73,1) forwards") : "".concat(h$1(r), " 0.4s forwards cubic-bezier(.06,.71,.55,1)")
  };
},
    F = /*#__PURE__*/React.memo(function (_ref5) {
  var e = _ref5.toast,
      t = _ref5.position,
      o = _ref5.style,
      s = _ref5.children;
  var a = e.height ? Ae(e.position || t || "top-center", e.visible) : {
    opacity: 0
  },
      r = /*#__PURE__*/React.createElement(M, {
    toast: e
  }),
      c = /*#__PURE__*/React.createElement(Se, _objectSpread({}, e.ariaProps), T(e.message, e));
  return /*#__PURE__*/React.createElement(be, {
    className: e.className,
    style: _objectSpread(_objectSpread(_objectSpread({}, a), o), e.style)
  }, typeof s == "function" ? s({
    icon: r,
    message: c
  }) : /*#__PURE__*/React.createElement(React.Fragment, null, r, c));
});
m(React.createElement);

var Ee = function Ee(_ref6) {
  var e = _ref6.id,
      t = _ref6.className,
      o = _ref6.style,
      s = _ref6.onHeightUpdate,
      a = _ref6.children;
  var r = React.useCallback(function (c) {
    if (c) {
      var i = function i() {
        var d = c.getBoundingClientRect().height;
        s(e, d);
      };

      i(), new MutationObserver(i).observe(c, {
        subtree: !0,
        childList: !0,
        characterData: !0
      });
    }
  }, [e, s]);
  return /*#__PURE__*/React.createElement("div", {
    ref: r,
    className: t,
    style: o
  }, a);
},
    Re = function Re(e, t) {
  var o = e.includes("top"),
      s = o ? {
    top: 0
  } : {
    bottom: 0
  },
      a = e.includes("center") ? {
    justifyContent: "center"
  } : e.includes("right") ? {
    justifyContent: "flex-end"
  } : {};
  return _objectSpread(_objectSpread({
    left: 0,
    right: 0,
    display: "flex",
    position: "absolute",
    transition: b() ? void 0 : "all 230ms cubic-bezier(.21,1.02,.73,1)",
    transform: "translateY(".concat(t * (o ? 1 : -1), "px)")
  }, s), a);
},
    ve = u$1(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n  z-index: 9999;\n  > * {\n    pointer-events: auto;\n  }\n"]))),
    O = 16,
    Ie = function Ie(_ref7) {
  var e = _ref7.reverseOrder,
      _ref7$position = _ref7.position,
      t = _ref7$position === void 0 ? "top-center" : _ref7$position,
      o = _ref7.toastOptions,
      s = _ref7.gutter,
      a = _ref7.children,
      r = _ref7.containerStyle,
      c = _ref7.containerClassName;

  var _D = D(o),
      i = _D.toasts,
      d = _D.handlers;

  return /*#__PURE__*/React.createElement("div", {
    style: _objectSpread({
      position: "fixed",
      zIndex: 9999,
      top: O,
      left: O,
      right: O,
      bottom: O,
      pointerEvents: "none"
    }, r),
    className: c,
    onMouseEnter: d.startPause,
    onMouseLeave: d.endPause
  }, i.map(function (p) {
    var g = p.position || t,
        E = d.calculateOffset(p, {
      reverseOrder: e,
      gutter: s,
      defaultPosition: t
    }),
        x = Re(g, E);
    return /*#__PURE__*/React.createElement(Ee, {
      id: p.id,
      key: p.id,
      onHeightUpdate: d.updateHeight,
      className: p.visible ? ve : "",
      style: x
    }, p.type === "custom" ? T(p.message, p) : a ? a(p) : /*#__PURE__*/React.createElement(F, {
      toast: p,
      position: g
    }));
  }));
};

var _excluded = ["icon"];
var ICONS = {
  success: SuccessIcon,
  error: ErrorIcon,
  info: InfoIcon
}; // The convertkit-design build has trouble importing SVGs, so we've formatted
// the default icons as components. On the main app, it's cleaner to import an
// SVG and pass it into an <img src="" />, so we want to support both of these
// use cases. Once ck-design's build supports SVG imports, this can be removed.

var ImageOrSVG = function ImageOrSVG(_ref) {
  var icon = _ref.icon,
      rest = _objectWithoutProperties(_ref, _excluded);

  // If the icon is a React component...
  if (typeof icon === "function") {
    var IconComponent = icon;
    return /*#__PURE__*/React__default.createElement(IconComponent, rest);
  } else {
    // If the icon is imported...
    return /*#__PURE__*/React__default.createElement("img", _extends({
      src: icon
    }, rest));
  }
};

var getBarColor = function getBarColor(type) {
  switch (type) {
    case "success":
      return "#589D78";

    case "error":
      return "var(--yellow-500)";

    case "info":
      return "var(--blue-500)";

    case "cta":
    default:
      return "var(--gray-100)";
  }
};

var ToastIcon = function ToastIcon(_ref2) {
  var type = _ref2.type,
      icon = _ref2.icon;
  var barStyles = {
    backgroundColor: getBarColor(type),
    borderRadius: 6,
    top: 6,
    left: 6,
    bottom: 6,
    width: 4
  };
  var iconStyles = {
    width: 26,
    height: 26
  };
  return /*#__PURE__*/React__default.createElement("div", {
    className: "justify-center ml-6 mr-6 hidden md:flex"
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "absolute inset-y-auto left-0",
    style: barStyles
  }), /*#__PURE__*/React__default.createElement(ImageOrSVG, {
    icon: icon || ICONS[type],
    alt: "",
    style: iconStyles,
    className: "ml-2"
  }));
};

var Text = function Text(_ref3) {
  var title = _ref3.title,
      text = _ref3.text;
  return /*#__PURE__*/React__default.createElement("div", null, title && /*#__PURE__*/React__default.createElement("div", {
    className: "font-semibold text-gray-900 mb-1"
  }, title), text && /*#__PURE__*/React__default.createElement("div", {
    className: "text-gray-700"
  }, text));
};

var Actions = function Actions(_ref4) {
  var actions = _ref4.actions,
      handleClose = _ref4.handleClose;
  return /*#__PURE__*/React__default.createElement("div", {
    className: "ml-4"
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "flex items-center gap-2"
  }, actions.map(function (action) {
    // Closes the toast after an action button is clicked.
    var handleClick = /*#__PURE__*/function () {
      var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
        return regenerator.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                if (action.onClick) {
                  _context.next = 2;
                  break;
                }

                return _context.abrupt("return");

              case 2:
                _context.next = 4;
                return action.onClick();

              case 4:
                handleClose();

              case 5:
              case "end":
                return _context.stop();
            }
          }
        }, _callee);
      }));

      return function handleClick() {
        return _ref5.apply(this, arguments);
      };
    }();

    return /*#__PURE__*/React__default.createElement(Button, _extends({
      key: action.text,
      is: "primary",
      className: "whitespace-no-wrap"
    }, action, {
      onClick: handleClick
    }), action.text);
  })));
};

var Close = function Close(_ref6) {
  var handleClose = _ref6.handleClose;
  var closeStyles = {
    width: 16,
    height: 16
  };
  return /*#__PURE__*/React__default.createElement("button", {
    onClick: handleClose,
    className: "absolute top-0 right-0 p-2 block"
  }, /*#__PURE__*/React__default.createElement(CloseIcon, {
    className: "block",
    style: closeStyles
  }), /*#__PURE__*/React__default.createElement(VisuallyHidden, null, "Close notification"));
};

function Toast(_ref7) {
  var toast = _ref7.toast,
      _ref7$type = _ref7.type,
      type = _ref7$type === void 0 ? "info" : _ref7$type,
      title = _ref7.title,
      text = _ref7.text,
      icon = _ref7.icon,
      actions = _ref7.actions,
      handleClose = _ref7.handleClose,
      closable = _ref7.closable;
  return /*#__PURE__*/React__default.createElement(F, {
    toast: toast,
    position: "bottom-center",
    style: {
      padding: 0,
      maxWidth: 500
    }
  }, function () {
    return /*#__PURE__*/React__default.createElement("div", {
      role: "alert",
      className: "rounded bg-white flex items-center text-left relative shadow-lg text-sm p-3 md:pr-8 md:pl-0 md:py-6"
    }, /*#__PURE__*/React__default.createElement(ToastIcon, {
      type: type,
      icon: icon
    }), /*#__PURE__*/React__default.createElement(Text, {
      title: title,
      text: text
    }), actions && /*#__PURE__*/React__default.createElement(Actions, {
      actions: actions,
      handleClose: handleClose
    }), closable && /*#__PURE__*/React__default.createElement(Close, {
      handleClose: handleClose
    }));
  });
}

Toast.propTypes = {
  toast: PropTypes.object,
  text: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]).isRequired,
  type: PropTypes.oneOf(["info", "success", "error", "cta"]).isRequired,
  title: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
  actions: PropTypes.array,
  position: PropTypes.oneOf(["bottom", "top", "top-right", "bottom-right", "bottom-left", "top-left"]),
  duration: PropTypes.number,
  icon: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
  handleClose: PropTypes.func,
  closable: PropTypes.bool
};
function toast(props) {
  return n.custom(function (t) {
    return /*#__PURE__*/React__default.createElement(Toast, _extends({
      toast: t,
      handleClose: function handleClose() {
        return n.dismiss(t.id);
      }
    }, props));
  });
}
function Toaster() {
  return /*#__PURE__*/React__default.createElement(Ie, {
    position: "bottom-center"
  });
}

export { Toaster, Toast as default, toast };
