// packages/editor/src/components/post-last-revision/index.js
import { sprintf, __ } from "@wordpress/i18n";
import { Button } from "@wordpress/components";
import { useSelect } from "@wordpress/data";
import { backup } from "@wordpress/icons";
import { addQueryArgs } from "@wordpress/url";
import PostLastRevisionCheck from "./check";
import PostPanelRow from "../post-panel-row";
import { store as editorStore } from "../../store";
import { jsx } from "react/jsx-runtime";
function usePostLastRevisionInfo() {
  return useSelect((select) => {
    const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } = select(editorStore);
    return {
      lastRevisionId: getCurrentPostLastRevisionId(),
      revisionsCount: getCurrentPostRevisionsCount()
    };
  }, []);
}
function PostLastRevision() {
  const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
  return /* @__PURE__ */ jsx(PostLastRevisionCheck, { children: /* @__PURE__ */ jsx(
    Button,
    {
      __next40pxDefaultSize: true,
      href: addQueryArgs("revision.php", {
        revision: lastRevisionId
      }),
      className: "editor-post-last-revision__title",
      icon: backup,
      iconPosition: "right",
      text: sprintf(
        /* translators: %s: number of revisions. */
        __("Revisions (%s)"),
        revisionsCount
      )
    }
  ) });
}
function PrivatePostLastRevision() {
  const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
  return /* @__PURE__ */ jsx(PostLastRevisionCheck, { children: /* @__PURE__ */ jsx(PostPanelRow, { label: __("Revisions"), children: /* @__PURE__ */ jsx(
    Button,
    {
      href: addQueryArgs("revision.php", {
        revision: lastRevisionId
      }),
      className: "editor-private-post-last-revision__button",
      text: revisionsCount,
      variant: "tertiary",
      size: "compact"
    }
  ) }) });
}
var post_last_revision_default = PostLastRevision;
export {
  PrivatePostLastRevision,
  post_last_revision_default as default
};
//# sourceMappingURL=index.js.map
