"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _data = require("@wordpress/data");
var _store = require("../../store");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function usePatternsSetup(clientId, blockName, filterPatternsFn) {
  return (0, _data.useSelect)(select => {
    const {
      getBlockRootClientId,
      getPatternsByBlockTypes,
      __experimentalGetAllowedPatterns
    } = select(_store.store);
    const rootClientId = getBlockRootClientId(clientId);
    if (filterPatternsFn) {
      return __experimentalGetAllowedPatterns(rootClientId).filter(filterPatternsFn);
    }
    return getPatternsByBlockTypes(blockName, rootClientId);
  }, [clientId, blockName, filterPatternsFn]);
}
var _default = exports.default = usePatternsSetup;
//# sourceMappingURL=use-patterns-setup.js.map