import React from 'react';
import { JzljXncContext } from "../..";
import { VmBarCharts, VmEmpty, VmFactorList, VmWrapper } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { overviewApis } from "../../api";
import "./index.less";
import overview_ctyl_pjrcc_dark from "../../imgs/overview_ctyl_pjrcc_dark.png";
import overview_ctyl_pjrcc_light from "../../imgs/overview_ctyl_pjrcc_light.png";
import overview_ctyl_pjryl_dark from "../../imgs/overview_ctyl_pjryl_dark.png";
import overview_ctyl_pjryl_light from "../../imgs/overview_ctyl_pjryl_light.png";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export default function CZZ(_ref) {
  var unitStr = _ref.unitStr;
  var _React$useContext = React.useContext(JzljXncContext),
    id = _React$useContext.id,
    theme = _React$useContext.theme;
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var _overviewApis$useCtyl = overviewApis.useCtyl(id),
    data = _overviewApis$useCtyl.data,
    loading = _overviewApis$useCtyl.loading;
  var _data$avgDayCount = data.avgDayCount,
    avgDayCount = _data$avgDayCount === void 0 ? 0 : _data$avgDayCount,
    _data$avgDayWeight = data.avgDayWeight,
    avgDayWeight = _data$avgDayWeight === void 0 ? 0 : _data$avgDayWeight,
    _data$histogramList = data.histogramList,
    histogramList = _data$histogramList === void 0 ? [] : _data$histogramList;
  var dataList_top = [{
    name: '平均日运量',
    unit: unitStr,
    value: avgDayWeight,
    img: isDark ? overview_ctyl_pjryl_dark : overview_ctyl_pjryl_light,
    fontType: 'blue',
    unitStyle: {
      fontSize: 14
    },
    style: {
      flex: 1,
      justifyContent: 'center'
    }
  }, {
    name: '平均日车次',
    unit: '次',
    value: avgDayCount,
    img: isDark ? overview_ctyl_pjrcc_dark : overview_ctyl_pjrcc_light,
    fontType: 'blue',
    unitStyle: {
      fontSize: 14
    },
    style: {
      flex: 1,
      justifyContent: 'center'
    }
  }];
  return /*#__PURE__*/_jsxs(VmWrapper, {
    title: "7\u65E5\u5185\u8FDB\u571F\u8FD0\u91CF\u4FE1\u606F",
    children: [/*#__PURE__*/_jsx(VmFactorList, {
      list: dataList_top,
      style: {
        background: 'unset'
      }
    }), /*#__PURE__*/_jsx("div", {
      style: {
        height: 160
      },
      children: histogramList !== null && histogramList !== void 0 && histogramList.length ? /*#__PURE__*/_jsx(VmBarCharts, {
        dataList: [{
          name: '运量',
          data: histogramList.map(function (item) {
            return "\u2000".concat(item.weight);
          }),
          color: 'geekblue',
          yAxisIndex: 1
        }],
        xAxis: histogramList.map(function (item) {
          return item.date;
        }),
        yAxisList: [{
          key: "\u2001",
          unit: '次',
          name: '(次)'
        }, {
          key: "\u2000",
          unit: unitStr,
          name: "(".concat(unitStr, ")")
        }],
        lineList: [{
          name: '车次',
          data: histogramList.map(function (item) {
            return "\u2001".concat(item.count);
          }),
          color: '#0FB964',
          yAxisIndex: 0
        }],
        loading: loading,
        barBorderRadius: [4, 4, 0, 0],
        gridOptions: {
          top: 30
        }
      }) : /*#__PURE__*/_jsx(VmEmpty, {
        type: "NO_CHART"
      })
    })]
  });
}