"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = PostAuthorCheck;
var _data = require("@wordpress/data");
var _postTypeSupportCheck = _interopRequireDefault(require("../post-type-support-check"));
var _store = require("../../store");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

/**
 * Wrapper component that renders its children only if the post type supports the author.
 *
 * @param {Object}          props          The component props.
 * @param {React.ReactNode} props.children Children to be rendered.
 *
 * @return {React.ReactNode} The component to be rendered. Return `null` if the post type doesn't
 * supports the author or if there are no authors available.
 */function PostAuthorCheck({
  children
}) {
  const {
    hasAssignAuthorAction
  } = (0, _data.useSelect)(select => {
    const post = select(_store.store).getCurrentPost();
    const canAssignAuthor = post?._links?.['wp:action-assign-author'] ? true : false;
    return {
      hasAssignAuthorAction: canAssignAuthor
    };
  }, []);
  if (!hasAssignAuthorAction) {
    return null;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_postTypeSupportCheck.default, {
    supportKeys: "author",
    children: children
  });
}
//# sourceMappingURL=check.js.map