function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
 * 收集点-总览信息-收运规则
 */
import { getVtxToken } from '@vtx/utils';
import Progress from 'antd/es/progress';
import { VmEmpty, VmFactor } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import "./index.less";
import allRate from "../../imgs/allRate.png";
import allRateDark from "../../imgs/allRate_dark.png";
import bucket from "../../imgs/bucket.png";
import bucketDark from "../../imgs/bucket_dark.png";
import collect from "../../imgs/collect.png";
import collectDark from "../../imgs/collect_dark.png";
import plan from "../../imgs/plan.png";
import planDark from "../../imgs/plan_dark.png";
import weight from "../../imgs/weight.png";
import weightDark from "../../imgs/weight_dark.png";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
export default function TodayWork(props) {
  var data = props.data,
    paramConfigsList = props.paramConfigsList,
    productTypes = props.productTypes;
  var _useSettings = useSettings(),
    theme = _useSettings.theme,
    isDark = _useSettings.isDark;
  var getIcon = function getIcon(id) {
    var _productTypes$id;
    var src = '';
    if (productTypes !== null && productTypes !== void 0 && (_productTypes$id = productTypes[id]) !== null && _productTypes$id !== void 0 && _productTypes$id.icon) {
      var icon = JSON.parse(productTypes[id].icon)[0];
      src = "/cloudFile/common/downloadFile?id=".concat(icon.id, "&token=").concat(getVtxToken('token'));
    }
    return src;
  };
  var img = {
    dark: {
      全部: allRateDark
    },
    light: {
      全部: allRate
    },
    blue: {
      全部: allRate
    }
  };
  var getValue = function getValue(name, id) {
    var strokeColor = '#1890FF';
    var src = name === '全部' ? isDark ? allRateDark : allRate : getIcon(id);
    if (isDark) {
      if (name.indexOf('全部') > -1) {
        strokeColor = '#139DFF';
      } else if (name.indexOf('厨余') > -1) {
        strokeColor = '#13F97A';
      } else if (name.indexOf('可回收') > -1) {
        strokeColor = '#1890FF';
      } else if (name.indexOf('有害') > -1) {
        strokeColor = '#FF5861';
      } else if (name.indexOf('易腐') > -1) {
        strokeColor = '#1CE548';
      }
    } else {
      if (name.indexOf('全部') > -1) {
        strokeColor = '#1677FF';
      } else if (name.indexOf('厨余') > -1) {
        strokeColor = '#0FB964';
      } else if (name.indexOf('可回收') > -1) {
        strokeColor = '#1890FF';
      } else if (name.indexOf('有害') > -1) {
        strokeColor = '#F5222D';
      } else if (name.indexOf('易腐') > -1) {
        strokeColor = '#0FB964';
      }
    }
    return {
      strokeColor: strokeColor,
      src: src
    };
  };
  return /*#__PURE__*/_jsx(_Fragment, {
    children: Array.isArray(data) ? data.map(function (item, index) {
      var _paramConfigsList$SHO, _paramConfigsList$SHO2;
      var _getValue = getValue(item === null || item === void 0 ? void 0 : item.productTypeName, item === null || item === void 0 ? void 0 : item.productTypeId),
        strokeColor = _getValue.strokeColor,
        src = _getValue.src;
      return /*#__PURE__*/_jsxs("div", {
        className: "twork--item",
        children: [/*#__PURE__*/_jsx("div", {
          className: "twork--item-img",
          children: /*#__PURE__*/_jsx("img", {
            src: src
          })
        }), /*#__PURE__*/_jsxs("div", {
          className: "twork--item-progress",
          children: [/*#__PURE__*/_jsxs("div", {
            className: "twork--item-progress-row",
            children: ["".concat(item === null || item === void 0 ? void 0 : item.productTypeName, "\u5B8C\u6210\u7387\uFF1A"), "".concat(item.rate || 0, "%")]
          }), /*#__PURE__*/_jsx(Progress, {
            strokeLinecap: "butt",
            percent: item.rate,
            strokeColor: strokeColor,
            trailColor: isDark ? 'rgba(255,255,255,0.05)' : '#D2D2D2',
            railColor: isDark ? 'rgba(255,255,255,0.05)' : '#D2D2D2',
            strokeWidth: 6,
            showInfo: false
          })]
        }), /*#__PURE__*/_jsx("div", {
          className: "twork--item-block",
          children: [{
            name: '应收次数',
            unit: '次',
            value: item === null || item === void 0 ? void 0 : item.planCollectNums,
            img: isDark ? planDark : plan,
            fontType: 'blue'
          }, {
            name: '实收次数',
            unit: '次',
            value: item === null || item === void 0 ? void 0 : item.collectNums,
            img: isDark ? collectDark : collect,
            fontType: 'green'
          }, ((_paramConfigsList$SHO = paramConfigsList['SHOW_COLLECTING_BUCKETS']) === null || _paramConfigsList$SHO === void 0 ? void 0 : _paramConfigsList$SHO.value) === 'true' && {
            name: '收集桶数',
            unit: '桶',
            value: item === null || item === void 0 ? void 0 : item.bucketNum,
            img: isDark ? bucketDark : bucket,
            fontType: 'cyan'
          }, ((_paramConfigsList$SHO2 = paramConfigsList['SHOW_WEIGHTING']) === null || _paramConfigsList$SHO2 === void 0 ? void 0 : _paramConfigsList$SHO2.value) === 'true' && {
            name: '收集重量',
            unit: 'kg',
            value: item === null || item === void 0 ? void 0 : item.weight,
            img: isDark ? weightDark : weight,
            fontType: 'cyan'
          }].filter(function (ele) {
            return !!ele;
          }).map(function (ele, index) {
            return /*#__PURE__*/_jsx(VmFactor, _objectSpread(_objectSpread({}, ele), {}, {
              type: "sm",
              unitStyle: {
                fontSize: 14
              }
            }), index);
          })
        })]
      }, index);
    }) : /*#__PURE__*/_jsx(VmEmpty, {
      type: "NO_DATA"
    })
  });
}