import * as C from "../../../i18n/constants.mjs";
/**
 * @param {Comments} plugin The Comments plugin instance.
 * @returns {object}
 */
export default function removeCommentItem(plugin) {
  return {
    key: 'commentsRemove',
    name: function name() {
      return this.getTranslatedPhrase(C.CONTEXTMENU_ITEMS_REMOVE_COMMENT);
    },
    callback: function callback() {
      var range = this.getSelectedRangeLast();
      range.forAll(function (row, column) {
        if (row >= 0 && column >= 0) {
          plugin.removeCommentAtCell(row, column, false);
        }
      });
      this.render();
    },
    disabled: function disabled() {
      var range = this.getSelectedRangeLast();
      if (!range) {
        return true;
      }
      if (range.highlight.isHeader()) {
        return true;
      }
      return this.countRenderedRows() === 0 || this.countRenderedCols() === 0;
    }
  };
}