// packages/editor/src/components/collab-sidebar/comment-menu-item.js
import { MenuItem } from "@wordpress/components";
import { __ } from "@wordpress/i18n";
import { comment as commentIcon } from "@wordpress/icons";
import {
  privateApis as blockEditorPrivateApis,
  store as blockEditorStore
} from "@wordpress/block-editor";
import { useSelect } from "@wordpress/data";
import { getUnregisteredTypeHandlerName } from "@wordpress/blocks";
import { unlock } from "../../lock-unlock";
import { jsx } from "react/jsx-runtime";
var { CommentIconSlotFill } = unlock(blockEditorPrivateApis);
var AddCommentMenuItem = ({ clientId, onClick, isDistractionFree }) => {
  const block = useSelect(
    (select) => {
      return select(blockEditorStore).getBlock(clientId);
    },
    [clientId]
  );
  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,
    {
      icon: commentIcon,
      onClick,
      "aria-haspopup": "dialog",
      disabled: isDisabled,
      info: infoText,
      children: __("Add note")
    }
  );
};
var AddCommentMenuItemFill = ({ onClick, isDistractionFree }) => {
  return /* @__PURE__ */ jsx(CommentIconSlotFill.Fill, { children: ({ clientId, onClose }) => /* @__PURE__ */ jsx(
    AddCommentMenuItem,
    {
      clientId,
      isDistractionFree,
      onClick: () => {
        onClick();
        onClose();
      }
    }
  ) });
};
var comment_menu_item_default = AddCommentMenuItemFill;
export {
  comment_menu_item_default as default
};
//# sourceMappingURL=comment-menu-item.js.map
