"use strict";

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); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _vtxBaseModal = _interopRequireDefault(require("../vtx-base-modal"));
var _vtxBaseInfo = _interopRequireDefault(require("../vtx-base-info"));
var _components = require("./components");
var _components2 = require("../vtx-default-modal/components");
var _vmAppraisalInfo = _interopRequireDefault(require("../vm-appraisal-info"));
var _vmRepairMaintain = _interopRequireDefault(require("../vm-repair-maintain"));
var _vmVideo = _interopRequireDefault(require("../vm-video"));
var _api = _interopRequireDefault(require("../vm-video/api"));
var _api2 = require("./api");
require("../style");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : 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); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var TABS_BASE = 'wr-base';
var TABS_MONITOR = 'wr-monitor';
var TABS_EVALUATE = 'wr-appraise';
var TABS_ALARM = 'wr-alarm';
var TABS_APPRAISAL = 'default-appraisal';
var TABS_VIDEO = 'wr-video';
var TABS_RM = 'default-rm';
var TABS_ZTT = 'wr-ztt'; // 组态图（公厕实时监控）
var TABS_BASE_NEW = 'wr-base-new';
var TABS_BASE_NEW_2 = 'wr-base-new-2';
var TABS_BUILD = 'wr-build';
var TABS_FILE = 'wr-file';
var TABS_SCORE = 'wr-score';
var TABS_DETAIL = 'wr-detail';
var VtxWrModal = function VtxWrModal(props) {
  var _content;
  var id = props.id,
    title = props.title,
    subTitle = props.subTitle,
    _props$theme = props.theme,
    theme = _props$theme === void 0 ? 'light' : _props$theme,
    startDate = props.startDate,
    endDate = props.endDate,
    visible = props.visible,
    onCancel = props.onCancel,
    type = props.type,
    _props$ver = props.ver,
    ver = _props$ver === void 0 ? '2.0' : _props$ver,
    mapCenter = props.mapCenter,
    mapPoints = props.mapPoints,
    customMapInfo = props.customMapInfo,
    _props$modalShow = props.modalShow,
    modalShow = _props$modalShow === void 0 ? true : _props$modalShow,
    _props$showProcess = props.showProcess,
    showProcess = _props$showProcess === void 0 ? false : _props$showProcess,
    tabChose = props.tabChose,
    alarmDate = props.alarmDate;
  var _useState = (0, _react.useState)([]),
    _useState2 = _slicedToArray(_useState, 2),
    tabsC = _useState2[0],
    setTabsC = _useState2[1];
  var _useState3 = (0, _react.useState)(''),
    _useState4 = _slicedToArray(_useState3, 2),
    tabChoseC = _useState4[0],
    setTabChoseC = _useState4[1];
  var _BaseService$useBaseD = _api2.BaseService.useBaseDetail(id),
    _BaseService$useBaseD2 = _BaseService$useBaseD.photos,
    photos = _BaseService$useBaseD2 === void 0 ? [] : _BaseService$useBaseD2,
    _BaseService$useBaseD3 = _BaseService$useBaseD.info,
    info = _BaseService$useBaseD3 === void 0 ? {} : _BaseService$useBaseD3,
    _BaseService$useBaseD4 = _BaseService$useBaseD.tabConfig,
    tabConfig = _BaseService$useBaseD4 === void 0 ? [] : _BaseService$useBaseD4,
    visited = _BaseService$useBaseD.visited;
  var _BaseService$getField = _api2.BaseService.getFields(info === null || info === void 0 ? void 0 : info.typeCode),
    fields = _BaseService$getField.fields,
    beenSmart = _BaseService$getField.beenSmart;
  var _ref = type !== 'new' ? _api["default"].getChannels("".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 ? void 0 : info.typeCode)) : {},
    _ref$channels = _ref.channels,
    channels = _ref$channels === void 0 ? [] : _ref$channels;
  // 是否有组态图
  var hasProcess = _api2.processService.hasProcess(id);
  var allTabs = [{
    key: TABS_BASE_NEW_2,
    title: '基础信息',
    code: 'wr-base-new'
  }, {
    key: TABS_BUILD,
    title: '建设信息',
    code: 'wr-build'
  }, {
    key: TABS_FILE,
    title: '文档归档',
    code: 'wr-file'
  }, {
    key: TABS_SCORE,
    title: '公厕得分',
    code: 'wr-score'
  }, {
    key: TABS_DETAIL,
    title: '详细信息',
    code: 'wr-detail'
  },
  // { key: TABS_BASE_NEW, title: '基础信息', code: 'wr-base-new' },
  {
    key: TABS_BASE,
    title: '总览信息',
    code: 'wr-base'
  }, {
    key: TABS_MONITOR,
    title: '监测信息',
    code: 'wr-monitor'
  }, {
    key: TABS_ALARM,
    title: '报警信息',
    code: 'wr-alarm'
  }, {
    key: TABS_EVALUATE,
    title: '评价信息',
    code: 'wr-appraise'
  }, {
    key: TABS_APPRAISAL,
    title: '考核信息',
    code: 'default-appraisal'
  }, {
    key: TABS_RM,
    title: '维保信息',
    code: 'default-rm'
  }, {
    key: TABS_VIDEO,
    title: '视频信息',
    code: 'wr-video'
  }];
  if (showProcess && hasProcess) {
    allTabs.unshift({
      key: TABS_ZTT,
      title: '公厕实时监控',
      code: ''
    });
  }
  (0, _react.useEffect)(function () {
    if (visited) {
      var _tabsC = (tabConfig === null || tabConfig === void 0 ? void 0 : tabConfig.length) > 0 ? allTabs.filter(function (item) {
        return tabConfig.map(function (each) {
          return each.key;
        }).indexOf(item.code) !== -1;
      }) : allTabs;
      if (_tabsC.findIndex(function (ele) {
        return ele.key === 'wr-video';
      }) > -1) {
        if ((channels === null || channels === void 0 ? void 0 : channels.length) < 1) {
          _tabsC = _tabsC.filter(function (ele) {
            return ele.key !== 'wr-video';
          });
        }
      }
      setTabsC(_tabsC);
      if ((_tabsC === null || _tabsC === void 0 ? void 0 : _tabsC.length) > 0 && tabChose) {
        setTabChoseC(tabChose);
      }
    }
  }, [id, visited, tabChose, JSON.stringify(tabConfig), JSON.stringify(channels)]);
  var defaultBase = /*#__PURE__*/_react["default"].createElement(_components2.BaseInfo, {
    id: id,
    info: info,
    data: [],
    photos: photos,
    mapPoints: mapPoints,
    geometryType: "point",
    customMapInfo: customMapInfo,
    mapCenter: mapCenter || []
  });
  var content = (_content = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_content, TABS_ZTT, /*#__PURE__*/_react["default"].createElement(_components.Ztt, {
    id: id
  })), TABS_BASE, beenSmart ? (/*#__PURE__*/_react["default"].createElement(_components.BaseInfo, {
    id: id,
    info: info,
    photos: photos,
    fields: fields
  })) : defaultBase), TABS_MONITOR, /*#__PURE__*/_react["default"].createElement(_components.Monitor, {
    id: id
  })), TABS_ALARM, /*#__PURE__*/_react["default"].createElement(_components.AlarmInfo, {
    id: id
  })), TABS_EVALUATE, /*#__PURE__*/_react["default"].createElement(_components.Evaluate, {
    id: id
  })), TABS_APPRAISAL, /*#__PURE__*/_react["default"].createElement(_vmAppraisalInfo["default"], {
    id: id
  })), TABS_RM, /*#__PURE__*/_react["default"].createElement(_vmRepairMaintain["default"], {
    id: id
  })), TABS_VIDEO, /*#__PURE__*/_react["default"].createElement(_vmVideo["default"], {
    videoPlaceCode: "".concat(info === null || info === void 0 ? void 0 : info.typeCode, "_").concat(info === null || info === void 0 ? void 0 : info.code)
  })), TABS_BASE_NEW, /*#__PURE__*/_react["default"].createElement(_components.BaseInfoNew, {
    id: id,
    theme: theme
  })), TABS_BASE_NEW_2, /*#__PURE__*/_react["default"].createElement(_components.BaseInfoNew2, {
    id: id,
    theme: theme,
    modalShow: modalShow,
    alarmDate: alarmDate
  })), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_content, TABS_BUILD, /*#__PURE__*/_react["default"].createElement("div", null)), TABS_FILE, /*#__PURE__*/_react["default"].createElement("div", null)), TABS_SCORE, /*#__PURE__*/_react["default"].createElement(_components.Score, {
    id: id,
    theme: theme
  })), TABS_DETAIL, /*#__PURE__*/_react["default"].createElement(_components.Detail, {
    id: id,
    theme: theme
  })));
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, modalShow ? visible && (/*#__PURE__*/_react["default"].createElement(_vtxBaseModal["default"], {
    id: id,
    type: "facility",
    wrType: type,
    wrVer: ver,
    title: title,
    subTitle: subTitle,
    visible: visible,
    theme: theme,
    startDate: startDate,
    endDate: endDate,
    onCancel: onCancel,
    tabs: tabsC,
    tabChose: tabChoseC,
    contents: content
  })) : (/*#__PURE__*/_react["default"].createElement(_vtxBaseInfo["default"], {
    tabs: tabsC,
    tabChose: tabChoseC,
    contents: content
  })));
};
var _default = exports["default"] = VtxWrModal;
//# sourceMappingURL=index.js.map
