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 _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(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); }
/**
 * ViewControls - 内置视图控制按钮：缩放（Stepper）、复位、区域定位
 */
import React from 'react';
import classNames from 'classnames';
import { MinusOutlined, PlusOutlined, FullscreenOutlined, FullscreenExitOutlined, BorderInnerOutlined } from '@ant-design/icons';
import { locales } from '@pisell/utils';
import "./ViewControls.less";
var PREFIX = 'pisell-floor-map-layout';
var I18N_VC = 'pisell-floor-map-layout.view-controls';

/** 从 react-zoom-pan-pinch 拿到的控制 API（由主组件传入） */

export function ViewControls(props) {
  var api = props.api,
    _props$config = props.config,
    config = _props$config === void 0 ? {} : _props$config,
    _props$scale = props.scale,
    scale = _props$scale === void 0 ? 1 : _props$scale,
    _props$isFullscreen = props.isFullscreen,
    isFullscreen = _props$isFullscreen === void 0 ? false : _props$isFullscreen,
    className = props.className,
    _props$mapGridVisible = props.mapGridVisible,
    mapGridVisible = _props$mapGridVisible === void 0 ? false : _props$mapGridVisible,
    onToggleMapGrid = props.onToggleMapGrid;
  var showZoom = config.showZoom !== false;
  var showReset = config.showReset === true;
  var showFitBounds = config.showFitBounds === true;
  var showFullscreen = config.showFullscreen === true;
  var showGridToggle = config.showGridToggle === true && typeof onToggleMapGrid === 'function';
  var scalePercent = Math.round(scale * 100);
  var showToolsCapsule = showReset || showFitBounds || showFullscreen || showGridToggle;
  return /*#__PURE__*/React.createElement("div", {
    className: classNames("".concat(PREFIX, "-view-controls"), className)
  }, showZoom && /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "-view-controls-zoom-stepper")
  }, /*#__PURE__*/React.createElement("button", {
    type: "button",
    className: "".concat(PREFIX, "-view-controls-zoom-stepper-btn"),
    onClick: function onClick() {
      return api.zoomOut();
    },
    "aria-label": locales.getText("".concat(I18N_VC, ".zoom-out-aria"))
  }, /*#__PURE__*/React.createElement(MinusOutlined, null)), /*#__PURE__*/React.createElement("span", {
    className: "".concat(PREFIX, "-view-controls-zoom-stepper-value")
  }, scalePercent, "%"), /*#__PURE__*/React.createElement("button", {
    type: "button",
    className: "".concat(PREFIX, "-view-controls-zoom-stepper-btn"),
    onClick: function onClick() {
      return api.zoomIn();
    },
    "aria-label": locales.getText("".concat(I18N_VC, ".zoom-in-aria"))
  }, /*#__PURE__*/React.createElement(PlusOutlined, null))), showToolsCapsule && /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "-view-controls-tools-capsule")
  }, showReset && /*#__PURE__*/React.createElement("button", {
    type: "button",
    className: "".concat(PREFIX, "-view-controls-tool-btn"),
    onClick: function onClick() {
      return api.resetTransform();
    },
    "aria-label": locales.getText("".concat(I18N_VC, ".reset-aria"))
  }, "\u27F2"), showFitBounds && api.fitBounds && /*#__PURE__*/React.createElement("button", {
    type: "button",
    className: "".concat(PREFIX, "-view-controls-tool-btn"),
    onClick: function onClick() {
      return api.fitBounds();
    },
    "aria-label": locales.getText("".concat(I18N_VC, ".fit-bounds-aria"))
  }, "\u229E"), showGridToggle && /*#__PURE__*/React.createElement("button", {
    type: "button",
    className: classNames("".concat(PREFIX, "-view-controls-tool-btn"), _defineProperty({}, "".concat(PREFIX, "-view-controls-tool-btn--active"), mapGridVisible)),
    onClick: function onClick() {
      return onToggleMapGrid();
    },
    "aria-pressed": mapGridVisible,
    "aria-label": locales.getText(mapGridVisible ? "".concat(I18N_VC, ".grid-hide-aria") : "".concat(I18N_VC, ".grid-show-aria"))
  }, /*#__PURE__*/React.createElement(BorderInnerOutlined, null)), showFullscreen && api.toggleFullscreen && /*#__PURE__*/React.createElement("button", {
    type: "button",
    className: "".concat(PREFIX, "-view-controls-tool-btn"),
    onClick: function onClick() {
      return api.toggleFullscreen();
    },
    "aria-label": locales.getText(isFullscreen ? "".concat(I18N_VC, ".fullscreen-exit-aria") : "".concat(I18N_VC, ".fullscreen-aria"))
  }, isFullscreen ? /*#__PURE__*/React.createElement(FullscreenExitOutlined, null) : /*#__PURE__*/React.createElement(FullscreenOutlined, null))));
}
export default ViewControls;