"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _clsx = _interopRequireDefault(require("clsx"));
var _data = require("@wordpress/data");
var _components = require("@wordpress/components");
var _i18n = require("@wordpress/i18n");
var _icons = require("@wordpress/icons");
var _coreData = require("@wordpress/core-data");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * External dependencies
 */

/**
 * WordPress dependencies
 */

function SiteIcon({
  className
}) {
  const {
    isRequestingSite,
    siteIconUrl
  } = (0, _data.useSelect)(select => {
    const {
      getEntityRecord
    } = select(_coreData.store);
    const siteData = getEntityRecord('root', '__unstableBase', undefined);
    return {
      isRequestingSite: !siteData,
      siteIconUrl: siteData?.site_icon_url
    };
  }, []);
  if (isRequestingSite && !siteIconUrl) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "edit-site-site-icon__image"
    });
  }
  const icon = siteIconUrl ? /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
    className: "edit-site-site-icon__image",
    alt: (0, _i18n.__)('Site Icon'),
    src: siteIconUrl
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
    className: "edit-site-site-icon__icon",
    icon: _icons.wordpress,
    size: 48
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: (0, _clsx.default)(className, 'edit-site-site-icon'),
    children: icon
  });
}
var _default = exports.default = SiteIcon;
//# sourceMappingURL=index.js.map