"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/block-editor/src/components/default-block-appender/index.js
var default_block_appender_exports = {};
__export(default_block_appender_exports, {
  ZWNBSP: () => ZWNBSP,
  default: () => DefaultBlockAppender
});
module.exports = __toCommonJS(default_block_appender_exports);
var import_clsx = __toESM(require("clsx"));
var import_i18n = require("@wordpress/i18n");
var import_html_entities = require("@wordpress/html-entities");
var import_data = require("@wordpress/data");
var import_keycodes = require("@wordpress/keycodes");
var import_inserter = __toESM(require("../inserter"));
var import_store = require("../../store");
var import_jsx_runtime = require("react/jsx-runtime");
var ZWNBSP = "\uFEFF";
function DefaultBlockAppender({ rootClientId }) {
  const { showPrompt, isLocked, placeholder, isManualGrid } = (0, import_data.useSelect)(
    (select) => {
      const {
        getBlockCount,
        getSettings,
        getTemplateLock,
        getBlockAttributes
      } = select(import_store.store);
      const isEmpty = !getBlockCount(rootClientId);
      const { bodyPlaceholder } = getSettings();
      return {
        showPrompt: isEmpty,
        isLocked: !!getTemplateLock(rootClientId),
        placeholder: bodyPlaceholder,
        isManualGrid: getBlockAttributes(rootClientId)?.layout?.isManualPlacement
      };
    },
    [rootClientId]
  );
  const { insertDefaultBlock, startTyping } = (0, import_data.useDispatch)(import_store.store);
  if (isLocked || isManualGrid) {
    return null;
  }
  const value = (0, import_html_entities.decodeEntities)(placeholder) || (0, import_i18n.__)("Type / to choose a block");
  const onAppend = () => {
    insertDefaultBlock(void 0, rootClientId);
    startTyping();
  };
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
    "div",
    {
      "data-root-client-id": rootClientId || "",
      className: (0, import_clsx.default)("block-editor-default-block-appender", {
        "has-visible-prompt": showPrompt
      }),
      children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          "p",
          {
            tabIndex: "0",
            role: "button",
            "aria-label": (0, import_i18n.__)("Add default block"),
            className: "block-editor-default-block-appender__content",
            onKeyDown: (event) => {
              if (import_keycodes.ENTER === event.keyCode || import_keycodes.SPACE === event.keyCode) {
                onAppend();
              }
            },
            onClick: () => onAppend(),
            onFocus: () => {
              if (showPrompt) {
                onAppend();
              }
            },
            children: showPrompt ? value : ZWNBSP
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import_inserter.default,
          {
            rootClientId,
            position: "bottom right",
            isAppender: true,
            __experimentalIsQuick: true
          }
        )
      ]
    }
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ZWNBSP
});
//# sourceMappingURL=index.js.map
