/* wp:polyfill */
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = SaveHub;
var _data = require("@wordpress/data");
var _components = require("@wordpress/components");
var _coreData = require("@wordpress/core-data");
var _icons = require("@wordpress/icons");
var _saveButton = _interopRequireDefault(require("../save-button"));
var _isPreviewingTheme = require("../../utils/is-previewing-theme");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function SaveHub() {
  const {
    isDisabled,
    isSaving
  } = (0, _data.useSelect)(select => {
    const {
      __experimentalGetDirtyEntityRecords,
      isSavingEntityRecord
    } = select(_coreData.store);
    const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
    const _isSaving = dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key));
    return {
      isSaving: _isSaving,
      isDisabled: _isSaving || !dirtyEntityRecords.length && !(0, _isPreviewingTheme.isPreviewingTheme)()
    };
  }, []);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalHStack, {
    className: "edit-site-save-hub",
    alignment: "right",
    spacing: 4,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_saveButton.default, {
      className: "edit-site-save-hub__button",
      variant: isDisabled ? null : 'primary',
      showTooltip: false,
      icon: isDisabled && !isSaving ? _icons.check : null,
      showReviewMessage: true,
      __next40pxDefaultSize: true
    })
  });
}
//# sourceMappingURL=index.js.map