"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useShowBlockTools = useShowBlockTools;
var _data = require("@wordpress/data");
var _blocks = require("@wordpress/blocks");
var _store = require("../../store");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

/**
 * Source of truth for which block tools are showing in the block editor.
 *
 * @return {Object} Object of which block tools will be shown.
 */
function useShowBlockTools() {
  return (0, _data.useSelect)(select => {
    const {
      getSelectedBlockClientId,
      getFirstMultiSelectedBlockClientId,
      getBlock,
      getSettings,
      hasMultiSelection,
      __unstableGetEditorMode,
      isTyping
    } = select(_store.store);
    const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
    const block = getBlock(clientId);
    const editorMode = __unstableGetEditorMode();
    const hasSelectedBlock = !!clientId && !!block;
    const isEmptyDefaultBlock = hasSelectedBlock && (0, _blocks.isUnmodifiedDefaultBlock)(block);
    const _showEmptyBlockSideInserter = clientId && !isTyping() && editorMode === 'edit' && isEmptyDefaultBlock;
    const maybeShowBreadcrumb = hasSelectedBlock && !hasMultiSelection() && editorMode === 'navigation';
    const isZoomOut = editorMode === 'zoom-out';
    const _showZoomOutToolbar = isZoomOut && block?.attributes?.align === 'full' && !_showEmptyBlockSideInserter && !maybeShowBreadcrumb;
    const _showBlockToolbarPopover = !_showZoomOutToolbar && !getSettings().hasFixedToolbar && !_showEmptyBlockSideInserter && hasSelectedBlock && !isEmptyDefaultBlock && !maybeShowBreadcrumb;
    return {
      showEmptyBlockSideInserter: _showEmptyBlockSideInserter,
      showBreadcrumb: !_showEmptyBlockSideInserter && maybeShowBreadcrumb,
      showBlockToolbarPopover: _showBlockToolbarPopover,
      showZoomOutToolbar: _showZoomOutToolbar
    };
  }, []);
}
//# sourceMappingURL=use-show-block-tools.js.map