// packages/block-editor/src/hooks/list-view.js
import { __ } from "@wordpress/i18n";
import { PanelBody } from "@wordpress/components";
import { useSelect } from "@wordpress/data";
import { store as blocksStore, hasBlockSupport } from "@wordpress/blocks";
import InspectorControls from "../components/inspector-controls/index.mjs";
import { store as blockEditorStore } from "../store/index.mjs";
import { PrivateListView } from "../components/list-view/index.mjs";
import { jsx, jsxs } from "react/jsx-runtime";
var LIST_VIEW_SUPPORT_KEY = "listView";
function hasListViewSupport(nameOrType) {
  return hasBlockSupport(nameOrType, LIST_VIEW_SUPPORT_KEY);
}
function ListViewPanel({ clientId, name }) {
  const isEnabled = hasListViewSupport(name);
  const { hasChildren, blockTitle } = useSelect(
    (select) => ({
      hasChildren: !!select(blockEditorStore).getBlockCount(clientId),
      blockTitle: select(blocksStore).getBlockType(name)?.title
    }),
    [clientId, name]
  );
  if (!isEnabled) {
    return null;
  }
  return /* @__PURE__ */ jsx(InspectorControls, { group: "list", children: /* @__PURE__ */ jsxs(PanelBody, { title: null, children: [
    !hasChildren && /* @__PURE__ */ jsx("p", { className: "block-editor-block-inspector__no-blocks", children: __("No items yet.") }),
    /* @__PURE__ */ jsx(
      PrivateListView,
      {
        rootClientId: clientId,
        isExpanded: true,
        description: blockTitle,
        showAppender: true
      }
    )
  ] }) });
}
var list_view_default = {
  edit: ListViewPanel,
  hasSupport: hasListViewSupport,
  attributeKeys: []
};
export {
  LIST_VIEW_SUPPORT_KEY,
  ListViewPanel,
  list_view_default as default,
  hasListViewSupport
};
//# sourceMappingURL=list-view.mjs.map
