"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = SitePreview;
var _i18n = require("@wordpress/i18n");
var _data = require("@wordpress/data");
var _coreData = require("@wordpress/core-data");
var _dom = require("@wordpress/dom");
var _url = require("@wordpress/url");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

function SitePreview() {
  const siteUrl = (0, _data.useSelect)(select => {
    const {
      getEntityRecord
    } = select(_coreData.store);
    const siteData = getEntityRecord('root', '__unstableBase');
    return siteData?.home;
  }, []);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {
    src: (0, _url.addQueryArgs)(siteUrl, {
      // Parameter for hiding the admin bar.
      wp_site_preview: 1
    }),
    title: (0, _i18n.__)('Site Preview'),
    style: {
      display: 'block',
      width: '100%',
      height: '100%',
      backgroundColor: '#fff'
    },
    onLoad: event => {
      // Make interactive elements unclickable.
      const document = event.target.contentDocument;
      const focusableElements = _dom.focus.focusable.find(document);
      focusableElements.forEach(element => {
        element.style.pointerEvents = 'none';
        element.tabIndex = -1;
        element.setAttribute('aria-hidden', 'true');
      });
    }
  });
}
//# sourceMappingURL=site-preview.js.map