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 _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 { useMemo } from 'react';
import VmRepairMaintain from "../_components/vm-repair-maintain";
import useGetChannels from "../_hooks/useGetChannels";
import { BaseInfo as DefaultBaseInfo } from "../vtx-default-modal/components";
import { BaseInfo, Calendar, Metering, WorkCondition } from "../vtx-df-modal/components";
// import Appraisal from '../vm-appraisal-info';
import VmCustom from "../_components/vm-custom";
import VmVideo from "../_components/vm-video";
import useGetConfig from "../_hooks/useGetConfig";
import { CommonService } from "../_service";
import VtxBaseModal from "../vtx-base-modal";
import { BaseService } from "../vtx-df-modal/api";
import "../vtx-df-modal/style";
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
var TABS_BASE = 'base';
var TABS_METERING = 'metering';
var TABS_WC = 'workCondition';
var TABS_VIDEO = 'video';
var TABS_APPRAISAL = 'appraisal';
var TABS_RM = 'rm';
var TABS_Calendar = 'calendar';
var VtxDfModal = function VtxDfModal(props) {
  var id = props.id,
    title = props.title,
    subTitle = props.subTitle,
    theme = props.theme,
    startDate = props.startDate,
    endDate = props.endDate,
    visible = props.visible,
    onCancel = props.onCancel,
    mapCenter = props.mapCenter,
    source = props.source,
    customMapInfo = props.customMapInfo,
    tabChose = props.tabChose,
    _props$showCollect = props.showCollect,
    showCollect = _props$showCollect === void 0 ? true : _props$showCollect;
  var _CommonService$useBas = CommonService.useBaseInfo(id, (customMapInfo === null || customMapInfo === void 0 ? void 0 : customMapInfo.coordinate) || 'wgs84'),
    info = _CommonService$useBas.info,
    photos = _CommonService$useBas.photos;
  var tabs = [{
    key: TABS_BASE,
    title: '总览信息'
  }, {
    key: TABS_METERING,
    title: '计量信息'
  }, {
    key: TABS_WC,
    title: '工况信息'
  }];
  var _useGetConfig = useGetConfig(info === null || info === void 0 ? void 0 : info.typeCode, tabs),
    tabsData = _useGetConfig.tabsData;
  var _CommonService$useLmD = CommonService.useLmDetail(id),
    detail = _CommonService$useLmD.detail;
  var _BaseService$useRealt = BaseService.useRealtimeMonitor(info === null || info === void 0 ? void 0 : info.code),
    realtimeMonitor = _BaseService$useRealt.realtimeMonitor;
  var _useGetChannels = useGetChannels("".concat(info === null || info === void 0 ? void 0 : info.typeCode, "_").concat(info === null || info === void 0 ? void 0 : info.code), !!(info !== null && info !== void 0 && info.typeCode)),
    channels = _useGetChannels.channels;
  // realtimeRes为空则无工况，beenWeigh为false则无计量
  var tabsList = useMemo(function () {
    var tabsList = tabsData;
    if (!(detail !== null && detail !== void 0 && detail.beenWeigh)) {
      tabsList = tabsList.filter(function (ele) {
        return ele.key !== 'metering';
      });
    }
    if (tabsList.findIndex(function (ele) {
      return ele.key === 'video';
    }) > -1) {
      if ((channels === null || channels === void 0 ? void 0 : channels.length) < 1) {
        tabsList = tabsList.filter(function (ele) {
          return ele.key !== 'video';
        });
      }
    }
    return tabsList;
  }, [JSON.stringify(tabsData), JSON.stringify(channels), JSON.stringify(detail)]);
  var contents = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, TABS_BASE, !(detail !== null && detail !== void 0 && detail.beenWeigh) && !(realtimeMonitor !== null && realtimeMonitor !== void 0 && realtimeMonitor.length) ? /*#__PURE__*/_jsx(DefaultBaseInfo, {
    id: id,
    info: info,
    photos: photos,
    mapCenter: mapCenter,
    customMapInfo: customMapInfo
  }) : /*#__PURE__*/_jsx(BaseInfo, {
    code: info === null || info === void 0 ? void 0 : info.code,
    hasLm: detail === null || detail === void 0 ? void 0 : detail.beenWeigh,
    realtimeMonitor: realtimeMonitor,
    info: info,
    photos: photos
  })), TABS_METERING, /*#__PURE__*/_jsx(Metering, {
    id: id
  })), TABS_WC, /*#__PURE__*/_jsx(WorkCondition, {
    id: id,
    code: info === null || info === void 0 ? void 0 : info.code
  })), TABS_Calendar, /*#__PURE__*/_jsx(Calendar, {
    code: info === null || info === void 0 ? void 0 : info.code
  })), TABS_RM, /*#__PURE__*/_jsx(VmRepairMaintain, {
    id: id
  })), TABS_VIDEO, /*#__PURE__*/_jsx(VmVideo, {
    channels: channels
  }));
  // 自定义页签可配置多个，
  if (tabsData !== null && tabsData !== void 0 && tabsData.length) {
    tabsData.forEach(function (ele) {
      if (ele.url) {
        contents[ele.key] = /*#__PURE__*/_jsx(VmCustom, {
          id: id,
          url: ele === null || ele === void 0 ? void 0 : ele.url
        });
      }
    });
  }
  return /*#__PURE__*/_jsx(_Fragment, {
    children: visible && /*#__PURE__*/_jsx(VtxBaseModal, {
      id: id,
      type: "facility",
      title: title,
      subTitle: subTitle,
      theme: theme,
      source: source,
      startDate: startDate,
      endDate: endDate,
      visible: visible,
      onCancel: onCancel,
      tabs: tabsList,
      tabChose: tabChose,
      showCollect: showCollect,
      contents: contents
    })
  });
};
export default VtxDfModal;