import { getBlockType, hasBlockSupport } from "@wordpress/blocks";
function getTransformedAttributes(attributes, newBlockName, bindingsCallback = null) {
  if (!attributes) {
    return void 0;
  }
  const newBlockType = getBlockType(newBlockName);
  if (!newBlockType) {
    return void 0;
  }
  const transformedAttributes = {};
  if (hasBlockSupport(newBlockType, "anchor") && attributes.anchor) {
    transformedAttributes.anchor = attributes.anchor;
  }
  if (hasBlockSupport(newBlockType, "ariaLabel") && attributes.ariaLabel) {
    transformedAttributes.ariaLabel = attributes.ariaLabel;
  }
  if (attributes.metadata) {
    const transformedMetadata = [];
    if (bindingsCallback) {
      transformedMetadata.push("id", "bindings");
    }
    if (transformedMetadata.length > 0) {
      const newMetadata = Object.entries(attributes.metadata).reduce(
        (obj, [prop, value]) => {
          if (!transformedMetadata.includes(prop)) {
            return obj;
          }
          obj[prop] = prop === "bindings" ? bindingsCallback(value) : value;
          return obj;
        },
        {}
      );
      if (Object.keys(newMetadata).length > 0) {
        transformedAttributes.metadata = newMetadata;
      }
    }
  }
  if (Object.keys(transformedAttributes).length === 0) {
    return void 0;
  }
  return transformedAttributes;
}
export {
  getTransformedAttributes
};
//# sourceMappingURL=get-transformed-attributes.js.map
