"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _i18n = require("@wordpress/i18n");
var _useEditedEntityRecord = _interopRequireDefault(require("../use-edited-entity-record"));
var _useTitle = _interopRequireDefault(require("../routes/use-title"));
var _constants = require("../../utils/constants");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function useEditorTitle() {
  const {
    record: editedPost,
    getTitle,
    isLoaded: hasLoadedPost
  } = (0, _useEditedEntityRecord.default)();
  let title;
  if (hasLoadedPost) {
    var _POST_TYPE_LABELS$edi;
    title = (0, _i18n.sprintf)(
    // translators: A breadcrumb trail for the Admin document title. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).
    (0, _i18n.__)('%1$s ‹ %2$s'), getTitle(), (_POST_TYPE_LABELS$edi = _constants.POST_TYPE_LABELS[editedPost.type]) !== null && _POST_TYPE_LABELS$edi !== void 0 ? _POST_TYPE_LABELS$edi : _constants.POST_TYPE_LABELS[_constants.TEMPLATE_POST_TYPE]);
  }

  // Only announce the title once the editor is ready to prevent "Replace"
  // action in <URLQueryController> from double-announcing.
  (0, _useTitle.default)(hasLoadedPost && title);
}
var _default = exports.default = useEditorTitle;
//# sourceMappingURL=use-editor-title.js.map