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 React from 'react';
import { JzljDfTpdContext } from "../..";
import { VmEmpty, VmPieCharts, VmWrapper } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { overviewApis } from "../../api";
import "./index.less";
import { jsx as _jsx } from "react/jsx-runtime";
export default function CZZ(_ref) {
  var unitStr = _ref.unitStr;
  var _React$useContext = React.useContext(JzljDfTpdContext),
    id = _React$useContext.id,
    theme = _React$useContext.theme;
  var _overviewApis$useCtl = overviewApis.useCtl(id),
    data = _overviewApis$useCtl.data,
    loading = _overviewApis$useCtl.loading;
  var _data$garbageList = data.garbageList,
    garbageList = _data$garbageList === void 0 ? [] : _data$garbageList,
    _data$totalWeight = data.totalWeight,
    totalWeight = _data$totalWeight === void 0 ? 0 : _data$totalWeight;
  var dataList = garbageList.map(function (item) {
    return _objectSpread(_objectSpread({}, item), {}, {
      name: item.garbageTypeName,
      value: item.weight
    });
  });
  var _useSettings = useSettings(),
    chartFontColor = _useSettings.chartFontColor,
    isDark = _useSettings.isDark;
  return /*#__PURE__*/_jsx("div", {
    className: "df-tpd-overview-right-top-right ".concat(theme),
    children: /*#__PURE__*/_jsx(VmWrapper, {
      title: "\u63A5\u6536\u91CF\u4FE1\u606F",
      children: (dataList === null || dataList === void 0 ? void 0 : dataList.length) > 0 ? /*#__PURE__*/_jsx(VmPieCharts, {
        dataList: dataList,
        name: "\u4ECA\u65E5\u63A5\u6536\u91CF",
        title: "\u4ECA\u65E5\u63A5\u6536\u603B\u91CF",
        subTitle: "(".concat(unitStr, ")"),
        total: totalWeight,
        loading: loading,
        unit: unitStr,
        innerRadius: ['50%', '70%'],
        outerRadius: ['70%', '80%'],
        legendConfig: {
          right: 0,
          textStyle: {
            fontSize: 14,
            color: chartFontColor,
            rich: {
              name: {
                width: 70,
                fontSize: 14
              },
              space: {
                width: 0
              },
              number: {
                width: 50,
                align: 'right',
                fontSize: 14,
                color: chartFontColor
              },
              percent: {
                width: 50,
                align: 'right',
                fontSize: 14,
                color: isDark ? '#ffffff' : '#8C8C8C'
              }
            }
          }
        },
        spaceLength: 0,
        center: ['23%', 'center']
      }) : /*#__PURE__*/_jsx(VmEmpty, {
        type: "NO_CHART",
        style: {
          height: '100%',
          marginLeft: '50%',
          transform: 'translateX(-50%)'
        }
      })
    })
  });
}