/**
 * 实时运行情况
 */
import _ from 'lodash';
import { Fragment } from 'react';
import useSettings from "../../_hooks/useSettings";
import { DownIcon, UpIcon } from "../../_util/iconSvgHtml";
import "./style";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
export default function VmFactor(_ref) {
  var name = _ref.name,
    unit = _ref.unit,
    value = _ref.value,
    img = _ref.img,
    _ref$fontType = _ref.fontType,
    fontType = _ref$fontType === void 0 ? '' : _ref$fontType,
    _ref$type = _ref.type,
    type = _ref$type === void 0 ? 'lg' : _ref$type,
    style = _ref.style,
    compare = _ref.compare,
    compareValue = _ref.compareValue,
    _ref$compareName = _ref.compareName,
    compareName = _ref$compareName === void 0 ? '与昨日比' : _ref$compareName,
    _ref$compareUnit = _ref.compareUnit,
    compareUnit = _ref$compareUnit === void 0 ? '' : _ref$compareUnit,
    _ref$isError = _ref.isError,
    isError = _ref$isError === void 0 ? false : _ref$isError,
    _ref$unitStyle = _ref.unitStyle,
    unitStyle = _ref$unitStyle === void 0 ? {} : _ref$unitStyle;
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var prefix = type === 'lg' ? 'vm-factor-lg' : 'vm-factor-sm';
  var suffix = {
    blue: 'white_blue',
    green: 'white_green',
    cyan: 'white_cyan',
    yellow: 'white_yellow',
    red: 'white_red',
    purple: 'white_purple',
    gray: 'white_gray'
  };
  return /*#__PURE__*/_jsxs("div", {
    className: "".concat(prefix, " ").concat(isDark ? 'isDark' : ''),
    style: style,
    children: [img && /*#__PURE__*/_jsx("div", {
      children: /*#__PURE__*/_jsx("img", {
        src: img
      })
    }), /*#__PURE__*/_jsxs("div", {
      children: [/*#__PURE__*/_jsx("div", {
        className: "".concat(prefix, "-name"),
        children: name || '-'
      }), /*#__PURE__*/_jsx("div", {
        className: "".concat(prefix, "-value_normal ").concat(isError ? "".concat(prefix, "-value_normal-error") : '', " ").concat(fontType && isDark ? suffix[fontType] : ''),
        children: _.isArray(value) ? value.map(function (item, index) {
          return /*#__PURE__*/_jsxs(Fragment, {
            children: [/*#__PURE__*/_jsx("span", {
              className: "".concat(prefix, "-value_normal-value"),
              children: item.value || 0
            }), /*#__PURE__*/_jsx("span", {
              className: "".concat(prefix, "-value_normal-unit"),
              style: unitStyle,
              children: item.unit || ''
            })]
          }, index);
        }) : /*#__PURE__*/_jsxs(_Fragment, {
          children: [/*#__PURE__*/_jsx("span", {
            className: "".concat(prefix, "-value_normal-value"),
            children: value || 0
          }), ' ', /*#__PURE__*/_jsx("span", {
            style: unitStyle,
            children: unit || ''
          })]
        })
      }), compare && /*#__PURE__*/_jsxs("div", {
        className: "".concat(prefix, "-compare"),
        children: [/*#__PURE__*/_jsxs("div", {
          children: [compareName, "\xA0\xA0", Math.abs(compareValue), compareUnit || unit]
        }), /*#__PURE__*/_jsxs("div", {
          className: "".concat(prefix, "-compare-unit"),
          children: [compareValue < 0 && /*#__PURE__*/_jsx(DownIcon, {
            fill: '#f5222d'
          }), compareValue > 0 && /*#__PURE__*/_jsx(UpIcon, {
            fill: '#0fb964'
          })]
        })]
      })]
    })]
  });
}