"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _StatusIndicatorSt = require("./StatusIndicator.st.css.js");
var _Tooltip = _interopRequireDefault(require("../Tooltip"));
var _deprecationLog = _interopRequireDefault(require("../utils/deprecationLog"));
var _system = require("@wix/wix-ui-icons-common/system");
var _Loader = _interopRequireDefault(require("../Loader"));
var _StatusIndicator = require("./StatusIndicator.constants");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/StatusIndicator/StatusIndicator.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(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 (var _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); }
var statusToIconMap = {
  success: /*#__PURE__*/_react.default.createElement(_system.FormFieldSuccessFilled, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 22,
      columnNumber: 12
    }
  }),
  warning: /*#__PURE__*/_react.default.createElement(_system.FormFieldWarningFilled, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 23,
      columnNumber: 12
    }
  }),
  loading: /*#__PURE__*/_react.default.createElement(_Loader.default, {
    size: "tiny",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 24,
      columnNumber: 12
    }
  }),
  error: /*#__PURE__*/_react.default.createElement(_system.FormFieldErrorFilled, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 25,
      columnNumber: 10
    }
  })
};
var StatusIndicator = props => {
  var {
    dataHook,
    status = _StatusIndicator.STATUS.ERROR,
    message,
    tooltipPlacement = _StatusIndicator.TOOLTIP_PLACEMENT.TOP,
    className,
    tooltipProps
  } = props;
  (0, _react.useEffect)(() => {
    if ('tooltipPlacement' in props) {
      (0, _deprecationLog.default)('<StatusIndicator/> - prop "tooltipPlacement" is deprecated and will be removed in next major release, please use "tooltipProps" instead.');
    }
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
  var icon = statusToIconMap[status];
  var renderIcon = () => {
    if (message) {
      return /*#__PURE__*/_react.default.createElement("span", {
        tabIndex: 0,
        className: _StatusIndicatorSt.classes.iconWrapper,
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 52,
          columnNumber: 9
        }
      }, icon);
    }
    return icon;
  };
  return /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _StatusIndicatorSt.st)(_StatusIndicatorSt.classes.root, {
      status
    }, className),
    "data-hook": dataHook,
    "data-status": status,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 61,
      columnNumber: 5
    }
  }, message ? /*#__PURE__*/_react.default.createElement(_Tooltip.default, (0, _extends2.default)({
    dataHook: _StatusIndicator.dataHooks.tooltip,
    appendTo: "window",
    placement: tooltipPlacement,
    exitDelay: 100,
    content: message,
    maxWidth: 250
  }, tooltipProps, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 67,
      columnNumber: 9
    }
  }), renderIcon()) : icon);
};
StatusIndicator.displayName = 'StatusIndicator';
var _default = exports.default = StatusIndicator;
//# sourceMappingURL=StatusIndicator.js.map