// packages/editor/src/components/collab-sidebar/add-note-menu-item.js
import { MenuItem } from "@wordpress/components";
import { __ } from "@wordpress/i18n";
import {
  privateApis as blockEditorPrivateApis,
  store as blockEditorStore
} from "@wordpress/block-editor";
import { useSelect } from "@wordpress/data";
import { getUnregisteredTypeHandlerName } from "@wordpress/blocks";
import { store as keyboardShortcutsStore } from "@wordpress/keyboard-shortcuts";
import { unlock } from "../../lock-unlock.mjs";
import { jsx } from "react/jsx-runtime";
var { NoteIconSlotFill } = unlock(blockEditorPrivateApis);
function NoteMenuItem({ clientId, onClick, isDistractionFree }) {
  const block = useSelect(
    (select) => {
      return select(blockEditorStore).getBlock(clientId);
    },
    [clientId]
  );
  const shortcut = useSelect(
    (select) => select(keyboardShortcutsStore).getShortcutRepresentation(
      "core/editor/new-note"
    ),
    []
  );
  if (!block?.isValid || block?.name === getUnregisteredTypeHandlerName()) {
    return null;
  }
  const isDisabled = isDistractionFree || block?.name === "core/freeform";
  let infoText;
  if (isDistractionFree) {
    infoText = __("Notes are disabled in distraction free mode.");
  } else if (block?.name === "core/freeform") {
    infoText = __("Convert to blocks to add notes.");
  }
  return /* @__PURE__ */ jsx(
    MenuItem,
    {
      onClick,
      "aria-haspopup": "dialog",
      disabled: isDisabled,
      info: infoText,
      shortcut,
      children: __("Add note")
    }
  );
}
function AddNoteMenuItem({ onClick, isDistractionFree }) {
  return /* @__PURE__ */ jsx(NoteIconSlotFill.Fill, { children: ({ clientId, onClose }) => /* @__PURE__ */ jsx(
    NoteMenuItem,
    {
      clientId,
      isDistractionFree,
      onClick: () => {
        onClick(clientId);
        onClose();
      }
    }
  ) });
}
export {
  AddNoteMenuItem
};
//# sourceMappingURL=add-note-menu-item.mjs.map
