{"version":3,"file":"deprecated-attributes.cjs","names":["useDispatch","blockEditorStore","useEvent","useRef"],"sources":["../../src/paragraph/deprecated-attributes.js"],"sourcesContent":["import { useEvent } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * If a plugin is still using the old align attribute, we need to migrate its value\n * to the new style.typography.textAlign attribute.\n *\n * @param {string?}          align         Align attribute value.\n * @param {Object?}          style         Style attribute value.\n * @param {(Object) => void} setAttributes Updater function for block attributes.\n */\nexport default function useDeprecatedAlign( align, style, setAttributes ) {\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst updateStyleWithAlign = useEvent( () => {\n\t\tdeprecated( 'align attribute in paragraph block', {\n\t\t\talternative: 'style.typography.textAlign',\n\t\t\tsince: '7.0',\n\t\t} );\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( {\n\t\t\tstyle: {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\ttextAlign: align,\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t} );\n\tconst lastUpdatedAlignRef = useRef();\n\tuseEffect( () => {\n\t\tif (\n\t\t\talign === 'full' ||\n\t\t\talign === 'wide' ||\n\t\t\talign === lastUpdatedAlignRef.current\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tlastUpdatedAlignRef.current = align;\n\t\tupdateStyleWithAlign();\n\t}, [ align, updateStyleWithAlign ] );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAwB,mBAAoB,OAAO,OAAO,eAAgB;CACzE,MAAM,EAAE,6CAAA,GACPA,gBAAAA,YAAAA,CAAaC,wBAAAA,KAAiB;CAC/B,MAAM,wBAAA,GAAuBC,mBAAAA,SAAAA,OAAgB;EAC5C,CAAA,GAAA,sBAAA,QAAA,CAAY,sCAAsC;GACjD,aAAa;GACb,OAAO;EACR,CAAE;EACF,wCAAwC;EACxC,cAAe,EACd,OAAO;GACN,GAAG;GACH,YAAY;IACX,GAAG,OAAO;IACV,WAAW;GACZ;EACD,EACD,CAAE;CACH,CAAE;CACF,MAAM,uBAAA,GAAsBC,mBAAAA,OAAAA,CAAO;CACnC,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IACC,UAAU,UACV,UAAU,UACV,UAAU,oBAAoB,SAE9B;EAED,oBAAoB,UAAU;EAC9B,qBAAqB;CACtB,GAAG,CAAE,OAAO,oBAAqB,CAAE;AACpC"}