"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 = _interopRequireDefault(require("react"));
var _StatusIndicatorSt = require("./StatusIndicator.st.css.js");
var _Tooltip = _interopRequireDefault(require("../Tooltip"));
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";
var statusToIconMap = {
  success: /*#__PURE__*/_react.default.createElement(_system.FormFieldSuccessFilled, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 21,
      columnNumber: 12
    }
  }),
  warning: /*#__PURE__*/_react.default.createElement(_system.FormFieldWarningFilled, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 22,
      columnNumber: 12
    }
  }),
  loading: /*#__PURE__*/_react.default.createElement(_Loader.default, {
    size: "tiny",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 23,
      columnNumber: 12
    }
  }),
  error: /*#__PURE__*/_react.default.createElement(_system.FormFieldErrorFilled, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 24,
      columnNumber: 10
    }
  })
};
var StatusIndicator = _ref => {
  var {
    dataHook,
    status = _StatusIndicator.STATUS.ERROR,
    message,
    tooltipPlacement = _StatusIndicator.TOOLTIP_PLACEMENT.TOP,
    className,
    tooltipProps
  } = _ref;
  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: 40,
          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: 49,
      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: 55,
      columnNumber: 9
    }
  }), renderIcon()) : icon);
};
StatusIndicator.displayName = 'StatusIndicator';
var _default = exports.default = StatusIndicator;
//# sourceMappingURL=StatusIndicator.js.map