"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.options = exports["default"] = exports.Toolbox = void 0;
var _react = _interopRequireWildcard(require("react"));
var _itemWrap = _interopRequireDefault(require("../components/item-wrap"));
var _Icon = _interopRequireDefault(require("@ant-design/icons/lib/components/Icon"));
var _toolItem = _interopRequireDefault(require("../components/tool-Item"));
var _useProps2 = _interopRequireDefault(require("../../_util/useProps"));
var _Distance = _interopRequireDefault(require("./Measure/Distance"));
var _Area = _interopRequireDefault(require("./Measure/Area"));
var _Height = _interopRequireDefault(require("./Measure/Height"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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() { _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(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(arr) { if (Array.isArray(arr)) return arr; }
var P = {
  measureDistance: _Distance["default"],
  measureArea: _Area["default"],
  measureHeight: _Height["default"]
};
var Toolbox = exports.Toolbox = function Toolbox(props) {
  var type = props.type;
  var Page = P[type];
  return /*#__PURE__*/_react["default"].createElement(Page, props);
};
var options = exports.options = [{
  label: '测距',
  icon: 'icon-ceju',
  key: 'measureDistance'
}, {
  label: '测面',
  icon: 'icon-mianji',
  key: 'measureArea'
}
// { label: '测高', icon: 'icon-mianji', key: 'measureHeight' },
];
var ToolBox = function ToolBox(props) {
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map;
  var _useState = (0, _react.useState)(''),
    _useState2 = _slicedToArray(_useState, 2),
    active = _useState2[0],
    setActive = _useState2[1];
  var onChange = function onChange(v) {
    if (!v.key) {
      return;
    }
    var value = active && v.key === active ? '' : v.key;
    setActive(value);
  };
  var content = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, options && options.length > 0 && options.map(function (v) {
    var params = props[v.key];
    if (params !== null && params !== void 0 && params.show) {
      return /*#__PURE__*/_react["default"].createElement(_toolItem["default"], {
        key: v.label,
        onClick: function onClick() {
          return onChange(v);
        },
        label: v.label,
        icon: v.icon,
        active: active === v.key || v.active
      });
    } else {
      return null;
    }
  }));
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_itemWrap["default"], {
    content: content
  }, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
    component: function component() {
      return /*#__PURE__*/_react["default"].createElement("svg", {
        width: "1em",
        height: "1em",
        fill: "currentColor",
        viewBox: "0 0 1024 1024"
      }, /*#__PURE__*/_react["default"].createElement("path", {
        d: "M558.933333 535.466667a45.866667 45.866667 0 0 0-6.4-23.466667h-80a42.666667 42.666667 0 0 0-6.4 23.466667A46.08 46.08 0 0 0 512 583.68a47.573333 47.573333 0 0 0 46.933333-48.213333zM605.013333 535.466667a93.013333 93.013333 0 1 1-185.813333 0 83.413333 83.413333 0 0 1 3.2-23.466667H138.026667v262.826667a94.933333 94.933333 0 0 0 1.066666 10.88v41.6a42.666667 42.666667 0 0 0 42.666667 42.666666h661.333333a42.666667 42.666667 0 0 0 42.666667-42.666666V512H601.813333a88.746667 88.746667 0 0 1 3.2 23.466667zM884.906667 334.72v-42.666667a42.666667 42.666667 0 0 0-42.666667-42.666666h-189.866667v-64a32 32 0 0 0-32-32h-217.6a32 32 0 0 0-32 32v64H181.76a42.666667 42.666667 0 0 0-42.666667 42.666666v173.013334h746.666667v-119.68a94.933333 94.933333 0 0 0-0.853333-10.666667z m-277.333334-85.333333h-189.653333v-26.026667a21.333333 21.333333 0 0 1 21.333333-21.333333h146.133334a21.333333 21.333333 0 0 1 21.333333 21.333333z"
      }));
    }
  })), active && /*#__PURE__*/_react["default"].createElement(Toolbox, _extends({
    map: map
  }, props[active] || {}, {
    type: active,
    onClose: function onClose() {
      return setActive('');
    }
  })));
};
ToolBox.defaultProps = {
  measureDistance: {
    show: true
  },
  measureArea: {
    show: true
  }
};
var _default = exports["default"] = ToolBox;
//# sourceMappingURL=index.js.map
