// packages/block-library/src/block/deprecated.js
var isObject = (obj) => typeof obj === "object" && !Array.isArray(obj) && obj !== null;
var v2 = {
  attributes: {
    ref: {
      type: "number"
    },
    content: {
      type: "object"
    }
  },
  supports: {
    customClassName: false,
    html: false,
    inserter: false,
    renaming: false
  },
  // Force this deprecation to run whenever there's a values sub-property that's an object.
  //
  // This could fail in the future if a block ever has binding to a `values` attribute.
  // Some extra protection is added to ensure `values` is an object, but this only reduces
  // the likelihood, it doesn't solve it completely.
  isEligible({ content }) {
    return !!content && Object.keys(content).every(
      (contentKey) => content[contentKey].values && isObject(content[contentKey].values)
    );
  },
  /*
   * Old attribute format:
   * content: {
   *     "V98q_x": {
   * 	   		// The attribute values are now stored as a 'values' sub-property.
   *         values: { content: 'My content value' },
   * 	       // ... additional metadata, like the block name can be stored here.
   *     }
   * }
   *
   * New attribute format:
   * content: {
   *     "V98q_x": {
   *         content: 'My content value',
   *     }
   * }
   */
  migrate(attributes) {
    const { content, ...retainedAttributes } = attributes;
    if (content && Object.keys(content).length) {
      const updatedContent = { ...content };
      for (const contentKey in content) {
        updatedContent[contentKey] = content[contentKey].values;
      }
      return {
        ...retainedAttributes,
        content: updatedContent
      };
    }
    return attributes;
  }
};
var v1 = {
  attributes: {
    ref: {
      type: "number"
    },
    overrides: {
      type: "object"
    }
  },
  supports: {
    customClassName: false,
    html: false,
    inserter: false,
    renaming: false
  },
  // Force this deprecation to run whenever there's an `overrides` object.
  isEligible({ overrides }) {
    return !!overrides;
  },
  /*
   * Old attribute format:
   * overrides: {
   *     // An key is an id that represents a block.
   *     // The values are the attribute values of the block.
   *     "V98q_x": { content: 'My content value' }
   * }
   *
   * New attribute format:
   * content: {
   *     "V98q_x": { content: 'My content value' }
   * }
   *
   */
  migrate(attributes) {
    const { overrides, ...retainedAttributes } = attributes;
    const content = {};
    Object.keys(overrides).forEach((id) => {
      content[id] = overrides[id];
    });
    return {
      ...retainedAttributes,
      content
    };
  }
};
var deprecated_default = [v2, v1];
export {
  deprecated_default as default
};
//# sourceMappingURL=deprecated.js.map
