"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.ManageTagsNotification = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _designSystem = require("@wix/design-system");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/Tags/ManageTags/ManageTagsModal/ManageTagsNotification.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const toastTypeToNotificationType = {
  SUCCESS: 'success',
  ERROR: 'destructive'
};
const convertToastConfigToButtonProps = ({
  toastConfig,
  onClose
}) => {
  var _toastConfig$action;
  return {
    label: (_toastConfig$action = toastConfig.action) == null ? void 0 : _toastConfig$action.text,
    onClick: () => {
      var _toastConfig$action2, _toastConfig$action3;
      (_toastConfig$action2 = toastConfig.action) == null || _toastConfig$action2.onClick == null || _toastConfig$action2.onClick();
      if ((_toastConfig$action3 = toastConfig.action) != null && _toastConfig$action3.removeToastOnClick) {
        onClose(toastConfig);
      }
    }
  };
};
const toastTypeToIcon = {
  SUCCESS: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.StatusComplete, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 45,
      columnNumber: 12
    }
  }),
  ERROR: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.InfoCircle, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 46,
      columnNumber: 10
    }
  })
};
const ManageTagsNotification = ({
  toastConfig,
  onClose,
  dataHook
}) => {
  const notificationProps = (0, _react.useMemo)(() => {
    var _toastConfig$action4, _toastConfig$action5;
    let type;
    let prefixIcon;
    if (toastConfig.type) {
      type = toastTypeToNotificationType[toastConfig.type];
      prefixIcon = toastTypeToIcon[toastConfig.type];
    }
    const buttonProps = convertToastConfigToButtonProps({
      toastConfig,
      onClose
    });
    return {
      type,
      prefixIcon,
      text: toastConfig.message,
      buttonProps: ((_toastConfig$action4 = toastConfig.action) == null ? void 0 : _toastConfig$action4.uiType) === 'BUTTON' ? buttonProps : undefined,
      textButtonProps: ((_toastConfig$action5 = toastConfig.action) == null ? void 0 : _toastConfig$action5.uiType) === 'LINK' ? buttonProps : undefined,
      onClose: () => onClose(toastConfig)
    };
  }, [toastConfig, onClose]);
  return /*#__PURE__*/_react.default.createElement(_designSystem.FloatingNotification, (0, _extends2.default)({
    dataHook: dataHook
  }, notificationProps, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 79,
      columnNumber: 10
    }
  }));
};
exports.ManageTagsNotification = ManageTagsNotification;
//# sourceMappingURL=ManageTagsNotification.js.map