"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireWildcard(require("react"));
var _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _service = _interopRequireDefault(require("../../_mapUtil/service"));
var _olMap = require("@vtx/ol-map");
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 _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 MapLayer = function MapLayer(props) {
  var _props$emptyConfigDat = props.emptyConfigData,
    emptyConfigData = _props$emptyConfigDat === void 0 ? [{}] : _props$emptyConfigDat;
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map,
    layersConfig = _useProps.layersConfig;
  var mapLayer = _service["default"].getOptions(map, layersConfig) || [];
  var legendList = [];
  mapLayer === null || mapLayer === void 0 || mapLayer.map(function (item) {
    var _item$valueField;
    if (Array.isArray(item === null || item === void 0 || (_item$valueField = item.valueField) === null || _item$valueField === void 0 ? void 0 : _item$valueField.legendList)) {
      var _item$valueField$lege;
      legendList = legendList.concat((_item$valueField$lege = item.valueField.legendList) === null || _item$valueField$lege === void 0 ? void 0 : _item$valueField$lege.map(function (v) {
        return _objectSpread(_objectSpread({}, v), {}, {
          key: "INFILTRATION_GW_".concat(v.icon)
        });
      }));
    }
  });
  var group = [{}];
  //图层配置里配置了图例展示图层配置的图例，没有展示默认图例
  if ((layersConfig || []).some(function (item) {
    return item === null || item === void 0 ? void 0 : item.legendList;
  })) {
    var _legendList;
    group = (_legendList = legendList) !== null && _legendList !== void 0 && _legendList.length ? legendList : [{}];
  } else {
    group = emptyConfigData;
  }
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_olMap.FeatureLayer, {
    id: "test",
    data: [],
    name: 'test',
    show: true,
    zIndex: 60,
    layerControl: false,
    group: group.map(function (_ref) {
      var name = _ref.name,
        key = _ref.key,
        filter = _ref.filter,
        color = _ref.color,
        icon = _ref.icon,
        type = _ref.type;
      return {
        name: name,
        key: key,
        style: {
          type: 'Marker',
          style: {
            icon: icon,
            color: color,
            type: type || 'CommonIcon'
          }
        },
        filter: filter
      };
    })
  }));
};
MapLayer.propTypes = {
  data: _propTypes["default"].array
};
var _default = exports["default"] = MapLayer;
//# sourceMappingURL=index.js.map
