{
  "version": 3,
  "sources": ["../../../src/api/parser/convert-legacy-block.ts"],
  "sourcesContent": ["/**\n * Convert legacy blocks to their canonical form. This function is used\n * both in the parser level for previous content and to convert such blocks\n * used in Custom Post Types templates.\n *\n * @param name       The block's name\n * @param attributes The block's attributes\n *\n * @return The block's name and attributes, changed accordingly if a match was found\n */\nexport function convertLegacyBlockNameAndAttributes(\n\tname: string | undefined | null,\n\tattributes: Record< string, unknown >\n): [ string | undefined | null, Record< string, unknown > ] {\n\tconst newAttributes = { ...attributes };\n\t// Convert 'core/cover-image' block in existing content to 'core/cover'.\n\tif ( 'core/cover-image' === name ) {\n\t\tname = 'core/cover';\n\t}\n\n\t// Convert 'core/text' blocks in existing content to 'core/paragraph'.\n\tif ( 'core/text' === name || 'core/cover-text' === name ) {\n\t\tname = 'core/paragraph';\n\t}\n\n\t// Convert derivative blocks such as 'core/social-link-wordpress' to the\n\t// canonical form 'core/social-link'.\n\tif ( name && name.indexOf( 'core/social-link-' ) === 0 ) {\n\t\t// Capture `social-link-wordpress` into `{\"service\":\"wordpress\"}`\n\t\tnewAttributes.service = name.substring( 17 );\n\t\tname = 'core/social-link';\n\t}\n\n\t// Convert derivative blocks such as 'core-embed/instagram' to the\n\t// canonical form 'core/embed'.\n\tif ( name && name.indexOf( 'core-embed/' ) === 0 ) {\n\t\t// Capture `core-embed/instagram` into `{\"providerNameSlug\":\"instagram\"}`\n\t\tconst providerSlug = name.substring( 11 );\n\t\tconst deprecated: Record< string, string > = {\n\t\t\tspeaker: 'speaker-deck',\n\t\t\tpolldaddy: 'crowdsignal',\n\t\t};\n\t\tnewAttributes.providerNameSlug =\n\t\t\tproviderSlug in deprecated\n\t\t\t\t? deprecated[ providerSlug ]\n\t\t\t\t: providerSlug;\n\t\t// This is needed as the `responsive` attribute was passed\n\t\t// in a different way before the refactoring to block variations.\n\t\tif ( ! [ 'amazon-kindle', 'wordpress' ].includes( providerSlug ) ) {\n\t\t\tnewAttributes.responsive = true;\n\t\t}\n\t\tname = 'core/embed';\n\t}\n\n\t// Convert Post Comment blocks in existing content to Comment blocks.\n\tif ( name === 'core/post-comment-author' ) {\n\t\tname = 'core/comment-author-name';\n\t}\n\tif ( name === 'core/post-comment-content' ) {\n\t\tname = 'core/comment-content';\n\t}\n\tif ( name === 'core/post-comment-date' ) {\n\t\tname = 'core/comment-date';\n\t}\n\tif ( name === 'core/comments-query-loop' ) {\n\t\tname = 'core/comments';\n\t\tconst className = ( newAttributes.className ?? '' ) as string;\n\t\tif ( ! className.includes( 'wp-block-comments-query-loop' ) ) {\n\t\t\tnewAttributes.className = [\n\t\t\t\t'wp-block-comments-query-loop',\n\t\t\t\tclassName,\n\t\t\t].join( ' ' );\n\t\t}\n\t\t// Note that we also had to add a deprecation to the block in order\n\t\t// for the ID change to work.\n\t}\n\tif ( name === 'core/post-comments' ) {\n\t\tname = 'core/comments';\n\t\tnewAttributes.legacy = true;\n\t}\n\n\t// Column count was stored as a string from WP 6.3-6.6. Convert it to a number.\n\tconst layout = attributes.layout as Record< string, unknown > | undefined;\n\tif ( layout?.type === 'grid' && typeof layout?.columnCount === 'string' ) {\n\t\tnewAttributes.layout = {\n\t\t\t...( newAttributes.layout as Record< string, unknown > ),\n\t\t\tcolumnCount: parseInt( layout.columnCount, 10 ),\n\t\t};\n\t}\n\n\t// Column span and row span were stored as strings in WP 6.6. Convert them to numbers.\n\tconst style = attributes.style as Record< string, unknown > | undefined;\n\tconst styleLayout = style?.layout as Record< string, unknown > | undefined;\n\tif ( typeof styleLayout?.columnSpan === 'string' ) {\n\t\tconst columnSpanNumber = parseInt( styleLayout.columnSpan, 10 );\n\t\tnewAttributes.style = {\n\t\t\t...( newAttributes.style as Record< string, unknown > ),\n\t\t\tlayout: {\n\t\t\t\t...( ( newAttributes.style as Record< string, unknown > )\n\t\t\t\t\t?.layout as Record< string, unknown > ),\n\t\t\t\tcolumnSpan: isNaN( columnSpanNumber )\n\t\t\t\t\t? undefined\n\t\t\t\t\t: columnSpanNumber,\n\t\t\t},\n\t\t};\n\t}\n\tif ( typeof styleLayout?.rowSpan === 'string' ) {\n\t\tconst rowSpanNumber = parseInt( styleLayout.rowSpan, 10 );\n\t\tnewAttributes.style = {\n\t\t\t...( newAttributes.style as Record< string, unknown > ),\n\t\t\tlayout: {\n\t\t\t\t...( ( newAttributes.style as Record< string, unknown > )\n\t\t\t\t\t?.layout as Record< string, unknown > ),\n\t\t\t\trowSpan: isNaN( rowSpanNumber ) ? undefined : rowSpanNumber,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn [ name, newAttributes ];\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,oCACf,MACA,YAC2D;AAC3D,QAAM,gBAAgB,EAAE,GAAG,WAAW;AAEtC,MAAK,uBAAuB,MAAO;AAClC,WAAO;AAAA,EACR;AAGA,MAAK,gBAAgB,QAAQ,sBAAsB,MAAO;AACzD,WAAO;AAAA,EACR;AAIA,MAAK,QAAQ,KAAK,QAAS,mBAAoB,MAAM,GAAI;AAExD,kBAAc,UAAU,KAAK,UAAW,EAAG;AAC3C,WAAO;AAAA,EACR;AAIA,MAAK,QAAQ,KAAK,QAAS,aAAc,MAAM,GAAI;AAElD,UAAM,eAAe,KAAK,UAAW,EAAG;AACxC,UAAM,aAAuC;AAAA,MAC5C,SAAS;AAAA,MACT,WAAW;AAAA,IACZ;AACA,kBAAc,mBACb,gBAAgB,aACb,WAAY,YAAa,IACzB;AAGJ,QAAK,CAAE,CAAE,iBAAiB,WAAY,EAAE,SAAU,YAAa,GAAI;AAClE,oBAAc,aAAa;AAAA,IAC5B;AACA,WAAO;AAAA,EACR;AAGA,MAAK,SAAS,4BAA6B;AAC1C,WAAO;AAAA,EACR;AACA,MAAK,SAAS,6BAA8B;AAC3C,WAAO;AAAA,EACR;AACA,MAAK,SAAS,0BAA2B;AACxC,WAAO;AAAA,EACR;AACA,MAAK,SAAS,4BAA6B;AAC1C,WAAO;AACP,UAAM,Y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