/* wp:polyfill */
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = TemplatePartContentPanel;
var _data = require("@wordpress/data");
var _element = require("@wordpress/element");
var _blocks = require("@wordpress/blocks");
var _blockEditor = require("@wordpress/block-editor");
var _components = require("@wordpress/components");
var _i18n = require("@wordpress/i18n");
var _lockUnlock = require("../../lock-unlock");
var _constants = require("../../store/constants");
var _store = require("../../store");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const {
  BlockQuickNavigation
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
function TemplatePartContentPanelInner() {
  const blockTypes = (0, _data.useSelect)(select => {
    const {
      getBlockTypes
    } = select(_blocks.store);
    return getBlockTypes();
  }, []);
  const themeBlockNames = (0, _element.useMemo)(() => {
    return blockTypes.filter(blockType => {
      return blockType.category === 'theme';
    }).map(({
      name
    }) => name);
  }, [blockTypes]);
  const themeBlocks = (0, _data.useSelect)(select => {
    const {
      getBlocksByName
    } = select(_blockEditor.store);
    return getBlocksByName(themeBlockNames);
  }, [themeBlockNames]);
  if (themeBlocks.length === 0) {
    return null;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PanelBody, {
    title: (0, _i18n.__)('Content'),
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockQuickNavigation, {
      clientIds: themeBlocks
    })
  });
}
function TemplatePartContentPanel() {
  const postType = (0, _data.useSelect)(select => {
    const {
      getCurrentPostType
    } = select(_store.store);
    return getCurrentPostType();
  }, []);
  if (postType !== _constants.TEMPLATE_PART_POST_TYPE) {
    return null;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(TemplatePartContentPanelInner, {});
}
//# sourceMappingURL=index.js.map