import{f,u as h}from"./js/app-core.61d75c0b.js";import{l as d}from"./js/vendor-lodash.f9514987.js";import"./js/vendor-vue-ui.d70c869f.js";import"./js/vendor-other.2cdd5822.js";import"./js/vendor-datetime.430013a3.js";if(window.aioseo.currentPost?.context==="post"){let i=[];window.wp.data.subscribe(()=>{p()});const p=d(()=>{const o=window.wp.data.select("core/block-editor").getBlocks();(o.length<i.length||o.length===1)&&u(),i=o},200);window.aioseoBus.$on("schemaBlockUpdated",()=>{u()});const u=d(()=>{let o=window.wp.data.select("core/block-editor").getBlocks();o=f(o),o=o.filter(t=>t?.attributes?.schemaBlockId),o=o.map(t=>(t.attributes.type=t.name,t));const l=h(),r=l.currentPost.schema?.blockGraphs||[];r.forEach((t,c)=>{const e=o.findIndex(n=>n?.attributes?.schemaBlockId===t?.schemaBlockId);if(e===-1){r.splice(c,1);return}const s={...o[e].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}),o.forEach(t=>{r.findIndex(e=>e?.schemaBlockId===t?.attributes?.schemaBlockId)===-1&&t?.attributes&&(Object.keys(t?.attributes).forEach(e=>{typeof t.attributes[e]=="string"&&t.attributes[e].match(/^({.*}|\[.*\])$/)&&(t.attributes[e]=JSON.parse(t.attributes[e]))}),r.push(t.attributes))}),r.sort((t,c)=>{const e=o.findIndex(a=>a?.attributes?.schemaBlockId===t?.schemaBlockId),s=o.findIndex(a=>a?.attributes?.schemaBlockId===c?.schemaBlockId);return e-s}),l.currentPost.schema.blockGraphs=r},200)}
