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 useGetChannels from "../_hooks/useGetChannels";
import useGetConfig from "../_hooks/useGetConfig";
import { useMemo } from 'react';
import { VmCustom, VmVideo } from "../_components";
import VtxBaseModal from "../vtx-base-modal";
import { BaseService } from "./api";
import { BaseInfo } from "./components";
import DataAnalysis from "./components/DataAnalysis";
import "./style";
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
var TABS_BASE = 'base';
var TABS_DATA = 'statistical';
var TABS_VIDEO = 'video';
var VtxDeviceModal = function VtxDeviceModal(props) {
  var id = props.id,
    title = props.title,
    subTitle = props.subTitle,
    theme = props.theme,
    visible = props.visible,
    onCancel = props.onCancel,
    _props$tabChose = props.tabChose,
    tabChose = _props$tabChose === void 0 ? '' : _props$tabChose;
  var tabs = [{
    key: TABS_BASE,
    title: '总览信息'
  }, {
    key: TABS_DATA,
    title: '数据分析'
  }, {
    key: TABS_VIDEO,
    title: '视频信息'
  }];
  var _useGetConfig = useGetConfig('device', tabs),
    tabsData = _useGetConfig.tabsData;
  var _BaseService$useBaseI = BaseService.useBaseInfo(id),
    info = _BaseService$useBaseI.info;
  var _useGetChannels = useGetChannels("".concat(info === null || info === void 0 ? void 0 : info.facilitySubType, "_").concat(info === null || info === void 0 ? void 0 : info.facilityCode), !!(info !== null && info !== void 0 && info.facilitySubType)),
    channels = _useGetChannels.channels;
  var tabsList = useMemo(function () {
    var tabsList = tabsData;
    if (tabsList.findIndex(function (ele) {
      return ele.key === 'video';
    }) > -1 && (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)]);
  var contents = _defineProperty(_defineProperty(_defineProperty({}, TABS_BASE, /*#__PURE__*/_jsx(BaseInfo, {
    info: info
  })), TABS_DATA, /*#__PURE__*/_jsx(DataAnalysis, {
    id: id,
    info: info
  })), TABS_VIDEO, /*#__PURE__*/_jsx(VmVideo, {
    videoPlaceCode: "".concat(info === null || info === void 0 ? void 0 : info.facilitySubType, "_").concat(info === null || info === void 0 ? void 0 : info.facilityCode)
  }));
  // 自定义页签可配置多个，包含custom即可
  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
        }, ele.key);
      }
    });
  }
  return /*#__PURE__*/_jsx(_Fragment, {
    children: visible && /*#__PURE__*/_jsx(VtxBaseModal, {
      id: id,
      type: "facility",
      title: title,
      subTitle: subTitle,
      theme: theme,
      visible: visible,
      onCancel: onCancel,
      tabs: tabsList,
      tabChose: tabChose,
      showCollect: false,
      contents: contents,
      tagList: [{
        color: 'blue',
        value: info.deviceTypeName
      }, {
        color: info.realStatus === 'offline' ? 'red' : 'green',
        value: info.realStatusName
      }]
    })
  });
};
export default VtxDeviceModal;