"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = Tools;
var _react = _interopRequireWildcard(require("react"));
var _icons = require("@ant-design/icons");
var _Search = _interopRequireDefault(require("./Search"));
var _Layer = _interopRequireDefault(require("./Layer"));
var _ItemWrap = _interopRequireDefault(require("./components/ItemWrap"));
var _baseMapSwitch = _interopRequireDefault(require("./base-map-switch"));
var _analysisTool = _interopRequireDefault(require("./analysis-tool"));
var _layerControl = _interopRequireDefault(require("./layer-control"));
var _fullScreen = _interopRequireDefault(require("./full-screen"));
var _refresh = _interopRequireDefault(require("./refresh"));
var _Toolbox = _interopRequireWildcard(require("./Toolbox"));
var _View = _interopRequireDefault(require("./View"));
var _classnames = _interopRequireDefault(require("classnames"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _useProps = _interopRequireDefault(require("../use-props"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function Tools(props) {
  var style = props.style,
    search = props.search,
    toolbox = props.toolbox,
    view = props.view,
    layer = props.layer,
    layerControl = props.layerControl,
    baseMapSwitch = props.baseMapSwitch,
    analysis = props.analysis,
    refresh = props.refresh,
    fullscreen = props.fullscreen,
    __map__ = props.__map__;
  var _useState = (0, _react.useState)(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  var _useState3 = (0, _react.useState)(''),
    _useState4 = _slicedToArray(_useState3, 2),
    active = _useState4[0],
    setActive = _useState4[1];
  var map = (0, _useProps["default"])().map || __map__;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])('ol-map-tools'),
    style: style
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])('ol-map-tools-item-wrap'),
    onClick: function onClick() {
      return setOpen(!open);
    }
  }, open ? /*#__PURE__*/_react["default"].createElement(_icons.DownCircleOutlined, null) : /*#__PURE__*/_react["default"].createElement(_icons.UpCircleOutlined, null)), /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])(open ? 'ol-map-tools-close' : 'ol-map-tools-open')
  }, (search === null || search === void 0 ? void 0 : search.show) && /*#__PURE__*/_react["default"].createElement(_Search["default"], _extends({
    active: active,
    setActive: setActive,
    map: map
  }, search)), (refresh === null || refresh === void 0 ? void 0 : refresh.show) && /*#__PURE__*/_react["default"].createElement(_refresh["default"], refresh), (fullscreen === null || fullscreen === void 0 ? void 0 : fullscreen.show) && /*#__PURE__*/_react["default"].createElement(_fullScreen["default"], fullscreen), (toolbox === null || toolbox === void 0 ? void 0 : toolbox.show) && /*#__PURE__*/_react["default"].createElement(_Toolbox["default"], _extends({
    active: active,
    setActive: setActive,
    map: map
  }, toolbox)), (view === null || view === void 0 ? void 0 : view.show) && /*#__PURE__*/_react["default"].createElement(_View["default"], _extends({
    map: map
  }, view)), (analysis === null || analysis === void 0 ? void 0 : analysis.show) && /*#__PURE__*/_react["default"].createElement(_analysisTool["default"], _extends({
    map: map
  }, analysis)), (baseMapSwitch === null || baseMapSwitch === void 0 ? void 0 : baseMapSwitch.show) && /*#__PURE__*/_react["default"].createElement(_baseMapSwitch["default"], _extends({
    map: map
  }, baseMapSwitch)), (layerControl === null || layerControl === void 0 ? void 0 : layerControl.show) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, layerControl.type === 'popover' ? /*#__PURE__*/_react["default"].createElement(_Layer["default"], _extends({
    map: map
  }, layerControl)) : /*#__PURE__*/_react["default"].createElement(_layerControl["default"], _extends({
    map: map
  }, layerControl))), props.children), active && /*#__PURE__*/_react["default"].createElement(_Toolbox.Toolbox, _extends({
    map: map
  }, props[active] || {}, {
    type: active,
    onClose: function onClose() {
      return setActive('');
    }
  })));
}
Tools.Item = _ItemWrap["default"];
Tools.defaultProps = {
  style: {
    left: 12,
    top: 12
  },
  search: {
    show: true
  },
  toolbox: {
    show: true
  },
  view: {
    show: true
  },
  layer: {
    show: true
  },
  baseMapSwitch: {
    show: false
  },
  analysis: {
    show: true
  },
  layerControl: {
    show: true
  },
  fullscreen: {
    show: true
  }
};
Tools.propTypes = {
  map: _propTypes["default"].object,
  style: _propTypes["default"].object,
  search: _propTypes["default"].object,
  toolbox: _propTypes["default"].object,
  view: _propTypes["default"].object,
  layer: _propTypes["default"].object,
  baseMapSwitch: _propTypes["default"].object,
  analysis: _propTypes["default"].object,
  children: _propTypes["default"].object,
  layerControl: _propTypes["default"].object,
  refresh: _propTypes["default"].object,
  fullscreen: _propTypes["default"].object
};
//# sourceMappingURL=index.js.map
