function __experimentalCloneSanitizedBlock(block) {
var mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
var clientId = Object(v4["a" /* default */])();
var sanitizedAttributes = sanitizeBlockAttributes(block.name, factory_objectSpread(factory_objectSpread({}, block.attributes), mergeAttributes));
return factory_objectSpread(factory_objectSpread({}, block), {}, {
attributes: sanitizedAttributes,
innerBlocks: newInnerBlocks || block.innerBlocks.map(function (innerBlock) {
return __experimentalCloneSanitizedBlock(innerBlock);
* Given a block object, returns a copy of the block object,
* optionally merging new attributes and/or replacing its inner blocks.
* @param {Object} block Block instance.
* @param {Object} mergeAttributes Block attributes.
* @param {?Array} newInnerBlocks Nested blocks.
* @return {Object} A cloned block.
function cloneBlock(block) {
var mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
var clientId = Object(v4["a" /* default */])();
return factory_objectSpread(factory_objectSpread({}, block), {}, {
attributes: factory_objectSpread(factory_objectSpread({}, block.attributes), mergeAttributes),
innerBlocks: newInnerBlocks || block.innerBlocks.map(function (innerBlock) {
return cloneBlock(innerBlock);
* Returns a boolean indicating whether a transform is possible based on
* various bits of context.
* @param {Object} transform The transform object to validate.
* @param {string} direction Is this a 'from' or 'to' transform.
* @param {Array} blocks The blocks to transform from.
* @return {boolean} Is the transform possible?
var factory_isPossibleTransformForSource = function isPossibleTransformForSource(transform, direction, blocks) {
if (Object(external_lodash_["isEmpty"])(blocks)) {
} // If multiple blocks are selected, only multi block transforms
// or wildcard transforms are allowed.
var isMultiBlock = blocks.length > 1;
var firstBlockName = Object(external_lodash_["first"])(blocks).name;
var isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock;
if (!isValidForMultiBlocks) {
} // Check non-wildcard transforms to ensure that transform is valid
// for a block selection of multiple blocks of different types
if (!isWildcardBlockTransform(transform) && !Object(external_lodash_["every"])(blocks, {
} // Only consider 'block' type transforms as valid.
var isBlockType = transform.type === 'block';
} // Check if the transform's block name matches the source block (or is a wildcard)
// only if this is a transform 'from'.
var sourceBlock = Object(external_lodash_["first"])(blocks);
var hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform);
} // Don't allow single Grouping blocks to be transformed into
if (!isMultiBlock && factory_isContainerGroupBlock(sourceBlock.name) && factory_isContainerGroupBlock(transform.blockName)) {
} // If the transform has a `isMatch` function specified, check that it returns true.
if (Object(external_lodash_["isFunction"])(transform.isMatch)) {
var attributes = transform.isMultiBlock ? blocks.map(function (block) {
}) : sourceBlock.attributes;
if (!transform.isMatch(attributes)) {
* Returns block types that the 'blocks' can be transformed into, based on
* 'from' transforms on other blocks.
* @param {Array} blocks The blocks to transform from.
* @return {Array} Block types that the blocks can be transformed into.
var factory_getBlockTypesForPossibleFromTransforms = function getBlockTypesForPossibleFromTransforms(blocks) {
if (Object(external_lodash_["isEmpty"])(blocks)) {
var allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform.
var blockTypesWithPossibleFromTransforms = Object(external_lodash_["filter"])(allBlockTypes, function (blockType) {
var fromTransforms = getBlockTransforms('from', blockType.name);
return !!findTransform(fromTransforms, function (transform) {
return factory_isPossibleTransformForSource(transform, 'from', blocks);
return blockTypesWithPossibleFromTransforms;
* Returns block types that the 'blocks' can be transformed into, based on
* the source block's own 'to' transforms.
* @param {Array} blocks The blocks to transform from.
* @return {Array} Block types that the source can be transformed into.
var factory_getBlockTypesForPossibleToTransforms = function getBlockTypesForPossibleToTransforms(blocks) {
if (Object(external_lodash_["isEmpty"])(blocks)) {
var sourceBlock = Object(external_lodash_["first"])(blocks);
var blockType = registration_getBlockType(sourceBlock.name);
var transformsTo = getBlockTransforms('to', blockType.name); // filter all 'to' transforms to find those that are possible.
var possibleTransforms = Object(external_lodash_["filter"])(transformsTo, function (transform) {
return transform && factory_isPossibleTransformForSource(transform, 'to', blocks);
}); // Build a list of block names using the possible 'to' transforms.
var blockNames = Object(external_lodash_["flatMap"])(possibleTransforms, function (transformation) {
return transformation.blocks;
}); // Map block names to block types.
return blockNames.map(function (name) {
return registration_getBlockType(name);
* Determines whether transform is a "block" type
* and if so whether it is a "wildcard" transform
* ie: targets "any" block type
* @param {Object} t the Block transform object
* @return {boolean} whether transform is a wildcard transform
var isWildcardBlockTransform = function isWildcardBlockTransform(t) {
return t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*');
* Determines whether the given Block is the core Block which
* acts as a container Block for other Blocks as part of the
* @param {string} name the name of the Block to test against
* @return {boolean} whether or not the Block is the container Block type
var factory_isContainerGroupBlock = function isContainerGroupBlock(name) {
return name === registration_getGroupingBlockName();
* Returns an array of block types that the set of blocks received as argument
* can be transformed into.
* @param {Array} blocks Blocks array.
* @return {Array} Block types that the blocks argument can be transformed to.
function getPossibleBlockTransformations(blocks) {
if (Object(external_lodash_["isEmpty"])(blocks)) {
var blockTypesForFromTransforms = factory_getBlockTypesForPossibleFromTransforms(blocks);
var blockTypesForToTransforms = factory_getBlockTypesForPossibleToTransforms(blocks);
return Object(external_lodash_["uniq"])([].concat(Object(toConsumableArray["a" /* default */])(blockTypesForFromTransforms), Object(toConsumableArray["a" /* default */])(blockTypesForToTransforms)));
* Given an array of transforms, returns the highest-priority transform where
* the predicate function returns a truthy value. A higher-priority transform
* is one with a lower priority value (i.e. first in priority order). Returns
* null if the transforms set is empty or the predicate function returns a
* falsey value for all entries.
* @param {Object[]} transforms Transforms to search.
* @param {Function} predicate Function returning true on matching transform.
* @return {?Object} Highest-priority transform candidate.
function findTransform(transforms, predicate) {
// The hooks library already has built-in mechanisms for managing priority
// queue, so leverage via locally-defined instance.
var hooks = Object(external_wp_hooks_["createHooks"])();
var _loop = function _loop(i) {
var candidate = transforms[i];
if (predicate(candidate)) {
hooks.addFilter('transform', 'transform/' + i.toString(), function (result) {
return result ? result : candidate;
for (var i = 0; i < transforms.length; i++) {
} // Filter name is arbitrarily chosen but consistent with above aggregation.
return hooks.applyFilters('transform', null);
* Returns normal block transforms for a given transform direction, optionally
* for a specific block by name, or an empty array if there are no transforms.
* If no block name is provided, returns transforms for all blocks. A normal
* transform object includes `blockName` as a property.
* @param {string} direction Transform direction ("to", "from").
* @param {string|Object} blockTypeOrName Block type or name.
* @return {Array} Block transforms for direction.
function getBlockTransforms(direction, blockTypeOrName) {
// When retrieving transforms for all block types, recurse into self.
if (blockTypeOrName === undefined) {
return Object(external_lodash_["flatMap"])(registration_getBlockTypes(), function (_ref) {
return getBlockTransforms(direction, name);
} // Validate that block type exists and has array of direction.
var blockType = normalizeBlockType(blockTypeOrName);
var _ref2 = blockType || {},
transforms = _ref2.transforms;
if (!transforms || !Array.isArray(transforms[direction])) {
} // Map transforms to normal form.
return transforms[direction].map(function (transform) {
return factory_objectSpread(factory_objectSpread({}, transform), {}, {
* Switch one or more blocks into one or more blocks of the new block type.
* @param {Array|Object} blocks Blocks array or block object.
* @param {string} name Block name.
* @return {?Array} Array of blocks or null.
function switchToBlockType(blocks, name) {
var blocksArray = Object(external_lodash_["castArray"])(blocks);
var isMultiBlock = blocksArray.length > 1;
var firstBlock = blocksArray[0];
var sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to"
var transformationsFrom = getBlockTransforms('from', name);
var transformationsTo = getBlockTransforms('to', sourceName);
var transformation = findTransform(transformationsTo, function (t) {
return t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(name) !== -1) && (!isMultiBlock || t.isMultiBlock);
}) || findTransform(transformationsFrom, function (t) {
return t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || t.isMultiBlock);
}); // Stop if there is no valid transformation.
var transformationResults;
if (transformation.isMultiBlock) {
if (Object(external_lodash_["has"])(transformation, '__experimentalConvert')) {
transformationResults = transformation.__experimentalConvert(blocksArray);
transformationResults = transformation.transform(blocksArray.map(function (currentBlock) {
return currentBlock.attributes;
}), blocksArray.map(function (currentBlock) {
return currentBlock.innerBlocks;
} else if (Object(external_lodash_["has"])(transformation, '__experimentalConvert')) {
transformationResults = transformation.__experimentalConvert(firstBlock);
transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks);
} // Ensure that the transformation function returned an object or an array
if (!Object(external_lodash_["isObjectLike"])(transformationResults)) {
} // If the transformation function returned a single object, we want to work
// with an array instead.
transformationResults = Object(external_lodash_["castArray"])(transformationResults); // Ensure that every block object returned by the transformation has a
if (transformationResults.some(function (result) {
return !registration_getBlockType(result.name);
var firstSwitchedBlock = Object(external_lodash_["findIndex"])(transformationResults, function (result) {
return result.name === name;
}); // Ensure that at least one block object returned by the transformation has
// the expected "destination" block type.
if (firstSwitchedBlock < 0) {
return transformationResults.map(function (result, index) {
var transformedBlock = factory_objectSpread(factory_objectSpread({}, result), {}, {
// The first transformed block whose type matches the "destination"
// type gets to keep the existing client ID of the first block.
clientId: index === firstSwitchedBlock ? firstBlock.clientId : result.clientId
* Filters an individual transform result from block transformation.
* All of the original blocks are passed, since transformations are
* many-to-many, not one-to-one.
* @param {Object} transformedBlock The transformed block.
* @param {Object[]} blocks Original blocks transformed.
return Object(external_wp_hooks_["applyFilters"])('blocks.switchToBlockType.transformedBlock', transformedBlock, blocks);
* Create a block object from the example API.
* @param {Object} example
* @return {Object} block.
var factory_getBlockFromExample = function getBlockFromExample(name, example) {
return createBlock(name, example.attributes, Object(external_lodash_["map"])(example.innerBlocks, function (innerBlock) {
return getBlockFromExample(innerBlock.name, innerBlock);
// CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js
* Given object and string of dot-delimited path segments, returns value at
* path or undefined if path cannot be resolved.
* @param {Object} object Lookup object
* @param {string} path Path to resolve
* @return {?*} Resolved value
function getPath(object, path) {
var segments = path.split('.');
while (segment = segments.shift()) {
if (!(segment in object)) {
object = object[segment];
// CONCATENATED MODULE: ./node_modules/hpq/es/index.js
* Function returning a DOM document created by `createHTMLDocument`. The same
* document is returned between invocations.
* @return {Document} DOM document.
var getDocument = function () {
doc = document.implementation.createHTMLDocument('');
* Given a markup string or DOM element, creates an object aligning with the
* shape of the matchers object, or the value returned by the matcher.
* @param {(string|Element)} source Source content
* @param {(Object|Function)} matchers Matcher function or object of matchers
* @return {(Object|*)} Matched value(s), shaped by object
function es_parse(source, matchers) {
if ('string' === typeof source) {
doc.body.innerHTML = source;
} // Return singular value
if ('function' === typeof matchers) {
} // Bail if we can't handle matchers
if (Object !== matchers.constructor) {
} // Shape result by matcher object
return Object.keys(matchers).reduce(function (memo, key) {
memo[key] = es_parse(source, matchers[key]);
* Generates a function which matches node of type selector, returning an
* attribute by property if the attribute exists. If no selector is passed,
* returns property of the query element.
* @param {?string} selector Optional selector
* @param {string} name Property name
* @return {*} Property value
function prop(selector, name) {
if (1 === arguments.length) {
match = node.querySelector(selector);
return getPath(match, name);
* Generates a function which matches node of type selector, returning an
* attribute by name if the attribute exists. If no selector is passed,