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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = useThemePatterns;
var _coreData = require("@wordpress/core-data");
var _data = require("@wordpress/data");
var _element = require("@wordpress/element");
var _utils = require("../page-patterns/utils");
var _constants = require("../../utils/constants");
var _lockUnlock = require("../../lock-unlock");
var _store = require("../../store");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function useThemePatterns() {
  const blockPatterns = (0, _data.useSelect)(select => {
    var _getSettings$__experi;
    const {
      getSettings
    } = (0, _lockUnlock.unlock)(select(_store.store));
    return (_getSettings$__experi = getSettings().__experimentalAdditionalBlockPatterns) !== null && _getSettings$__experi !== void 0 ? _getSettings$__experi : getSettings().__experimentalBlockPatterns;
  });
  const restBlockPatterns = (0, _data.useSelect)(select => select(_coreData.store).getBlockPatterns());
  const patterns = (0, _element.useMemo)(() => [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !_constants.EXCLUDED_PATTERN_SOURCES.includes(pattern.source)).filter(_utils.filterOutDuplicatesByName).filter(pattern => pattern.inserter !== false), [blockPatterns, restBlockPatterns]);
  return patterns;
}
//# sourceMappingURL=use-theme-patterns.js.map