import { mapSlice } from '../utils/slice';
export const transformSliceToRemoveMacroId = (slice, schema) => {
  const {
    extension,
    inlineExtension
  } = schema.nodes;
  return mapSlice(slice, node => {
    var _node$attrs$parameter, _node$attrs$parameter2, _node$attrs$parameter3;
    if ([extension, inlineExtension].includes(node.type) && typeof ((_node$attrs$parameter = node.attrs.parameters) === null || _node$attrs$parameter === void 0 ? void 0 : (_node$attrs$parameter2 = _node$attrs$parameter.macroMetadata) === null || _node$attrs$parameter2 === void 0 ? void 0 : (_node$attrs$parameter3 = _node$attrs$parameter2.macroId) === null || _node$attrs$parameter3 === void 0 ? void 0 : _node$attrs$parameter3.value) !== 'undefined') {
      // Strip the macroId. While pasting on the same page, macroId does not change until the page
      // is published and causes collision with the existing macroId where switching tabs of one
      // node changes the tabs for the other node
      delete node.attrs.parameters.macroMetadata.macroId;
    }
    return node;
  });
};