"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/block-library/src/list-item/edit.js
var edit_exports = {};
__export(edit_exports, {
  IndentUI: () => IndentUI,
  default: () => ListItemEdit
});
module.exports = __toCommonJS(edit_exports);
var import_block_editor = require("@wordpress/block-editor");
var import_i18n = require("@wordpress/i18n");
var import_components = require("@wordpress/components");
var import_icons = require("@wordpress/icons");
var import_compose = require("@wordpress/compose");
var import_data = require("@wordpress/data");
var import_keycodes = require("@wordpress/keycodes");
var import_hooks = require("./hooks");
var import_jsx_runtime = require("react/jsx-runtime");
function IndentUI({ clientId }) {
  const indentListItem = (0, import_hooks.useIndentListItem)(clientId);
  const outdentListItem = (0, import_hooks.useOutdentListItem)();
  const { canIndent, canOutdent } = (0, import_data.useSelect)(
    (select) => {
      const { getBlockIndex, getBlockRootClientId, getBlockName } = select(import_block_editor.store);
      return {
        canIndent: getBlockIndex(clientId) > 0,
        canOutdent: getBlockName(
          getBlockRootClientId(getBlockRootClientId(clientId))
        ) === "core/list-item"
      };
    },
    [clientId]
  );
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      import_components.ToolbarButton,
      {
        icon: (0, import_i18n.isRTL)() ? import_icons.formatOutdentRTL : import_icons.formatOutdent,
        title: (0, import_i18n.__)("Outdent"),
        shortcut: import_keycodes.displayShortcut.shift("Tab"),
        description: (0, import_i18n.__)("Outdent list item"),
        disabled: !canOutdent,
        onClick: () => outdentListItem()
      }
    ),
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      import_components.ToolbarButton,
      {
        icon: (0, import_i18n.isRTL)() ? import_icons.formatIndentRTL : import_icons.formatIndent,
        title: (0, import_i18n.__)("Indent"),
        shortcut: "Tab",
        description: (0, import_i18n.__)("Indent list item"),
        disabled: !canIndent,
        onClick: () => indentListItem()
      }
    )
  ] });
}
function ListItemEdit({
  attributes,
  setAttributes,
  clientId,
  mergeBlocks
}) {
  const { placeholder, content } = attributes;
  const blockProps = (0, import_block_editor.useBlockProps)();
  const innerBlocksProps = (0, import_block_editor.useInnerBlocksProps)(blockProps, {
    renderAppender: false,
    __unstableDisableDropZone: true
  });
  const useEnterRef = (0, import_hooks.useEnter)({ content, clientId });
  const useSpaceRef = (0, import_hooks.useSpace)(clientId);
  const onMerge = (0, import_hooks.useMerge)(clientId, mergeBlocks);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { ...innerBlocksProps, children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        import_block_editor.RichText,
        {
          ref: (0, import_compose.useMergeRefs)([useEnterRef, useSpaceRef]),
          identifier: "content",
          tagName: "div",
          onChange: (nextContent) => setAttributes({ content: nextContent }),
          value: content,
          "aria-label": (0, import_i18n.__)("List text"),
          placeholder: placeholder || (0, import_i18n.__)("List"),
          onMerge
        }
      ),
      innerBlocksProps.children
    ] }),
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockControls, { group: "block", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IndentUI, { clientId }) })
  ] });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  IndentUI
});
//# sourceMappingURL=edit.js.map
