import{u as B}from"./js/index.e0fdfdc6.js";import{f as g}from"./js/helpers.b1696305.js";import{d as m}from"./js/debounce.e3ec254d.js";import"./js/runtime-core.esm-bundler.ce5add0b.js";import"./js/default-i18n.368c2d5c.js";import"./js/translations.5e539ab1.js";import"./js/toNumber.aa196b9c.js";var h;if(((h=window.aioseo.currentPost)==null?void 0:h.context)==="post"){let u=[];window.wp.data.subscribe(()=>{I()});const I=m(()=>{const s=window.wp.data.select("core/block-editor").getBlocks();(s.length<u.length||s.length===1)&&c(),u=s},200);window.aioseoBus.$on("schemaBlockUpdated",()=>{c()});const c=m(()=>{var f;let s=window.wp.data.select("core/block-editor").getBlocks();s=g(s),s=s.filter(t=>{var o;return(o=t==null?void 0:t.attributes)==null?void 0:o.schemaBlockId}),s=s.map(t=>(t.attributes.type=t.name,t));const d=B(),a=((f=d.currentPost.schema)==null?void 0:f.blockGraphs)||[];a.forEach((t,o)=>{const n=s.findIndex(e=>{var p;return((p=e==null?void 0:e.attributes)==null?void 0:p.schemaBlockId)===(t==null?void 0:t.schemaBlockId)});if(n===-1){a.splice(o,1);return}const r={...s[n].attributes};["backgroundColor","textColor","fontSize","style"].forEach(e=>{delete r[e]}),Object.keys(r).forEach(e=>{typeof r[e]=="string"&&r[e].match(/^({.*}|\[.*\])$/)&&(r[e]=JSON.parse(r[e]))}),a[o]=r}),s.forEach(t=>{a.findIndex(n=>{var r;return(n==null?void 0:n.schemaBlockId)===((r=t==null?void 0:t.attributes)==null?void 0:r.schemaBlockId)})===-1&&(t!=null&&t.attributes)&&(Object.keys(t==null?void 0:t.attributes).forEach(n=>{typeof t.attributes[n]=="string"&&t.attributes[n].match(/^({.*}|\[.*\])$/)&&(t.attributes[n]=JSON.parse(t.attributes[n]))}),a.push(t.attributes))}),a.sort((t,o)=>{const n=s.findIndex(i=>{var e;return((e=i==null?void 0:i.attributes)==null?void 0:e.schemaBlockId)===(t==null?void 0:t.schemaBlockId)}),r=s.findIndex(i=>{var e;return((e=i==null?void 0:i.attributes)==null?void 0:e.schemaBlockId)===(o==null?void 0:o.schemaBlockId)});return n-r}),d.currentPost.schema.blockGraphs=a},200)}
