"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"] = 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(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 _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
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; }
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
  }, layer)), (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
