"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useActualCurrentTheme = useActualCurrentTheme;
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
var _element = require("@wordpress/element");
var _url = require("@wordpress/url");
/**
 * WordPress dependencies
 */

const ACTIVE_THEMES_URL = '/wp/v2/themes?status=active';
function useActualCurrentTheme() {
  const [currentTheme, setCurrentTheme] = (0, _element.useState)();
  (0, _element.useEffect)(() => {
    // Set the `wp_theme_preview` to empty string to bypass the createThemePreviewMiddleware.
    const path = (0, _url.addQueryArgs)(ACTIVE_THEMES_URL, {
      context: 'edit',
      wp_theme_preview: ''
    });
    (0, _apiFetch.default)({
      path
    }).then(activeThemes => setCurrentTheme(activeThemes[0]))
    // Do nothing
    .catch(() => {});
  }, []);
  return currentTheme;
}
//# sourceMappingURL=use-actual-current-theme.js.map