import{f,u as h}from"./js/app-core.fa86622d.js";import{l as d}from"./js/vendor-lodash.45e85310.js";import"./js/vendor-vue-ui.ad4935f9.js";import"./js/vendor-other.835e467b.js";if(window.aioseo.currentPost?.context==="post"){let i=[];window.wp.data.subscribe(()=>{p()});const p=d(()=>{const e=window.wp.data.select("core/block-editor").getBlocks();(e.length<i.length||e.length===1)&&u(),i=e},200);window.aioseoBus.$on("schemaBlockUpdated",()=>{u()});const u=d(()=>{let e=window.wp.data.select("core/block-editor").getBlocks();e=f(e),e=e.filter(t=>t?.attributes?.schemaBlockId),e=e.map(t=>(t.attributes.type=t.name,t));const l=h(),r=l.currentPost.schema?.blockGraphs||[];r.forEach((t,c)=>{const o=e.findIndex(n=>n?.attributes?.schemaBlockId===t?.schemaBlockId);if(o===-1){r.splice(c,1);return}const s={...e[o].attributes};["backgroundColor","textColor","fontSize","style"].forEach(n=>{delete s[n]}),Object.keys(s).forEach(n=>{typeof s[n]=="string"&&s[n].match(/^({.*}|\[.*\])$/)&&(s[n]=JSON.parse(s[n]))}),r[c]=s}),e.forEach(t=>{r.findIndex(o=>o?.schemaBlockId===t?.attributes?.schemaBlockId)===-1&&t?.attributes&&(Object.keys(t?.attributes).forEach(o=>{typeof t.attributes[o]=="string"&&t.attributes[o].match(/^({.*}|\[.*\])$/)&&(t.attributes[o]=JSON.parse(t.attributes[o]))}),r.push(t.attributes))}),r.sort((t,c)=>{const o=e.findIndex(a=>a?.attributes?.schemaBlockId===t?.schemaBlockId),s=e.findIndex(a=>a?.attributes?.schemaBlockId===c?.schemaBlockId);return o-s}),l.currentPost.schema.blockGraphs=r},200)}
