"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _olMap = require("@vtx/ol-map");
var _useGetFacility2 = _interopRequireDefault(require("../_mapUtil/useGetFacility"));
var _config = require("./config");
var _space = _interopRequireDefault(require("antd/lib/space"));
var _MyTag = _interopRequireDefault(require("../_component/MyTag"));
var _GwLayer = _interopRequireDefault(require("../_component/GwLayer"));
var _config2 = _interopRequireDefault(require("../_mapUtil/config"));
var _lodash = _interopRequireDefault(require("lodash"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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(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); }
var gwColorMap = _config2["default"].gwColorMap;

// eslint-disable-next-line react/prop-types
var Popup = function Popup(_ref) {
  var _data$dataJson, _data$dataJson2, _data$dataJson3;
  var _ref$info = _ref.info,
    info = _ref$info === void 0 ? {} : _ref$info,
    openModal = _ref.openModal;
  var _useGetFacility = (0, _useGetFacility2["default"])(info.facilityId),
    _useGetFacility$data = _useGetFacility.data,
    data = _useGetFacility$data === void 0 ? {} : _useGetFacility$data;
  var roadName = info.roadName,
    networkStatus = info.networkStatus,
    riverWaterLevel = info.riverWaterLevel,
    networkWaterLevel = info.networkWaterLevel,
    nearRiverNames = info.nearRiverNames;
  var list = [{
    content: /*#__PURE__*/_react["default"].createElement(_space["default"], null, /*#__PURE__*/_react["default"].createElement(_MyTag["default"], {
      text: _config.RiverTypeName[networkStatus],
      color: _config.RiverTypeColor[networkStatus]
    }), /*#__PURE__*/_react["default"].createElement(_MyTag["default"], {
      text: data.facilityClassName,
      color: gwColorMap[data === null || data === void 0 ? void 0 : data.facilityClassCode]
    })),
    span: 24
  }, {
    label: '所在道路',
    value: roadName || '-',
    span: 24
  }, {
    label: '管材',
    value: data === null || data === void 0 || (_data$dataJson = data.dataJson) === null || _data$dataJson === void 0 ? void 0 : _data$dataJson.lineTextureName
  }, {
    label: '管长',
    value: (data === null || data === void 0 || (_data$dataJson2 = data.dataJson) === null || _data$dataJson2 === void 0 ? void 0 : _data$dataJson2.lineLength) + 'm'
  }, {
    label: '管径',
    value: (data === null || data === void 0 || (_data$dataJson3 = data.dataJson) === null || _data$dataJson3 === void 0 ? void 0 : _data$dataJson3.ds) + 'mm'
  }, {
    label: '毗邻河道名称',
    value: nearRiverNames,
    span: 24
  }, {
    label: '河道液位(m)',
    value: riverWaterLevel || 0
  }, {
    label: '管段液位(m)',
    value: networkWaterLevel || 0
  }];
  return /*#__PURE__*/_react["default"].createElement(_olMap.Popup.Template, {
    contentList: list,
    column: 2,
    contentStyle: {
      width: 380
    },
    detail: {
      show: true,
      onClick: function onClick() {
        return openModal({
          id: info === null || info === void 0 ? void 0 : info.id
        });
      }
    }
  });
};
var RiverMapLayer = function RiverMapLayer(_ref2) {
  var _ref2$data = _ref2.data,
    data = _ref2$data === void 0 ? [] : _ref2$data,
    openModal = _ref2.openModal;
  var group = Object.keys(_config.RiverType).map(function (key) {
    return {
      name: _config.RiverTypeName[_config.RiverType[key]],
      key: "INFILTRATION_RIVER_GW_".concat(_config.RiverType[key]),
      color: _config.RiverTypeColor[_config.RiverType[key]],
      filter: function filter(f) {
        return f.networkStatus === _config.RiverType[key];
      }
    };
  });
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_GwLayer["default"], {
    pointData: data.map(function (item) {
      var _item$facilitySimple, _item$facilitySimple2;
      return _objectSpread(_objectSpread(_objectSpread({}, item), _lodash["default"].omit((item === null || item === void 0 ? void 0 : item.facilitySimple) || {}, ['id'])), {}, {
        geometryInfo: _objectSpread(_objectSpread({}, (item === null || item === void 0 || (_item$facilitySimple = item.facilitySimple) === null || _item$facilitySimple === void 0 ? void 0 : _item$facilitySimple.geometryInfo) || {}), {}, {
          lngLats: item === null || item === void 0 || (_item$facilitySimple2 = item.facilitySimple) === null || _item$facilitySimple2 === void 0 || (_item$facilitySimple2 = _item$facilitySimple2.geometryInfo) === null || _item$facilitySimple2 === void 0 || (_item$facilitySimple2 = _item$facilitySimple2.lngLats) === null || _item$facilitySimple2 === void 0 || (_item$facilitySimple2 = _item$facilitySimple2.split(';')) === null || _item$facilitySimple2 === void 0 ? void 0 : _item$facilitySimple2[0],
          type: 'point'
        })
      });
    }),
    group: group,
    lineData: data.map(function (item) {
      return _objectSpread(_objectSpread({}, item), _lodash["default"].omit((item === null || item === void 0 ? void 0 : item.facilitySimple) || {}, ['id']));
    }),
    id: 'INFILTRATION_RIVER_GW',
    template: function template(feature) {
      return /*#__PURE__*/_react["default"].createElement(Popup, {
        info: feature.values_,
        openModal: openModal
      });
    },
    labelField: 'facilityCode'
  }));
};
RiverMapLayer.propTypes = {
  data: _propTypes["default"].array,
  openModal: _propTypes["default"].func
};
var _default = exports["default"] = RiverMapLayer;
//# sourceMappingURL=RiverMapLayer.js.map
