"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _components = require("@wordpress/components");
var _i18n = require("@wordpress/i18n");
var _data = require("@wordpress/data");
var _blockEditor = require("@wordpress/block-editor");
var _icons = require("@wordpress/icons");
var _preferences = require("@wordpress/preferences");
var _lockUnlock = require("../../lock-unlock");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const ZoomOutToggle = ({
  disabled
}) => {
  const {
    isZoomOut,
    showIconLabels
  } = (0, _data.useSelect)(select => ({
    isZoomOut: (0, _lockUnlock.unlock)(select(_blockEditor.store)).isZoomOut(),
    showIconLabels: select(_preferences.store).get('core', 'showIconLabels')
  }));
  const {
    resetZoomLevel,
    setZoomLevel,
    __unstableSetEditorMode
  } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_blockEditor.store));
  const handleZoomOut = () => {
    if (isZoomOut) {
      resetZoomLevel();
    } else {
      setZoomLevel(50);
    }
    __unstableSetEditorMode(isZoomOut ? 'edit' : 'zoom-out');
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
    accessibleWhenDisabled: true,
    disabled: disabled,
    onClick: handleZoomOut,
    icon: _icons.square,
    label: (0, _i18n.__)('Zoom Out'),
    isPressed: isZoomOut,
    size: "compact",
    showTooltip: !showIconLabels
  });
};
var _default = exports.default = ZoomOutToggle;
//# sourceMappingURL=index.js.map