import{m as t,aj as v,ak as h,ah as g,u as y,h as P,al as k,b as _,ai as I,am as L,i as q,I as B,J as M,an as T}from"./app-core.52885c02.js";const N=()=>{let e=!1;if(document.querySelector("#wp-content-wrap.tmce-active")){const n=window.setInterval(()=>{!window.tinyMCE||!window.tinyMCE.activeEditor||(window.clearInterval(n),t(),window.tinyMCE.get("content").on("keyup",()=>{t(500)}),window.tinyMCE.get("content").on("paste",()=>{t(500)}))},50)}else{const n=document.querySelector("textarea#content");n&&(n.addEventListener("keyup",()=>{t(500)}),n.addEventListener("paste",()=>{t(500)}))}const o=document.querySelector("#post input#title");o&&o.addEventListener("input",()=>{t(500)}),S();const i=document.querySelector("#post_name");i&&i.addEventListener("change",()=>{t(500)});const r=document.querySelector("#edit-slug-buttons");r&&r.addEventListener("click",n=>{n.target===r.querySelector("#edit-slug-buttons button.save")&&t()});const d=document.querySelector("#categorychecklist");d&&d.addEventListener("change",function(){v()}),window.aioseoBus.$on("standalone-update-post",n=>{n.primary_term&&v()});const u=function(n){n.forEach(l=>{if(l.attributeName==="class"){if(document.querySelector("#wp-content-wrap.tmce-active")){if(!window.tinyMCE)return;window.tinyMCE.get("content").on("keyup",()=>{t(500)}),window.tinyMCE.get("content").on("paste",()=>{t(500)})}const m=document.querySelector("#content");m&&(m.addEventListener("keyup",()=>{t(500)}),m.addEventListener("paste",()=>{t(500)})),S()}})},a=new MutationObserver(u),c=document.querySelector("#wp-content-wrap");c&&a.observe(c,{attributes:!0});const p=document.querySelector("#wp-excerpt-wrap");p&&a.observe(p,{attributes:!0}),setInterval(()=>{e&&(e=!1)},500),h()&&!g()&&(e=!0,setInterval(()=>{window.tinyMCE&&window.tinyMCE.activeEditor&&window.tinyMCE.activeEditor.isDirty()&&!e&&(e=!0,t())},500))},S=()=>{if(document.querySelector("#wp-excerpt-wrap.tmce-active")){const o=window.setInterval(()=>{window.tinyMCE&&(window.clearInterval(o),t(),window.tinyMCE.get("excerpt").on("keyup",()=>{t(500)}),window.tinyMCE.get("excerpt").on("paste",()=>{t(500)}))},50)}const e=document.querySelector("#post textarea#excerpt");e&&(e.addEventListener("keyup",()=>{t(500)}),e.addEventListener("paste",()=>{t(500)}))},A=()=>{t(),window.wp.data.subscribe(()=>{t(500);const e=window.wp.data.select("core/editor").isSavingPost(),o=window.wp.data.select("core/editor").isAutosavingPost();if(e&&!o){const i=y();i.isDirty=!1,t()}})},b=()=>P()?.isUnlicensed||!1,w=()=>{let e="",o="",i="",r=[],d=!1,u="";const a=k(),c=y(),p=document.getElementById("_sku");p&&(e=p.value,a.updateWooCommerceSku(e));const n=document.getElementById("_sale_price"),l=document.getElementById("_regular_price");n&&(o=n.value),!o&&l&&(o=l.value);const x=_().aioseo.data?.wooCommerce?.currencySymbol||"$"+parseFloat(o||0).toFixed(2);a.updateWooCommercePrice(x);const C=["pwb-brand","product_brand"];for(const s of C)if(r=document.querySelectorAll(`#post input[name="tax_input[${s}][]"]:checked`),!!r.length){if(i!==r[0].parentNode.innerText&&(i=r[0].parentNode.innerText,a.updateWooCommerceBrand(r[0].parentNode.innerText)),c.currentPost?.primary_term?.[s]){const E=document.querySelector(`#${s}checklist input[value="${c.currentPost.primary_term[s]}"]`);E?.parentNode?.innerText&&a.updateWooCommerceBrand(E.parentNode.innerText)}d=!0;break}d||a.updateWooCommerceBrand("");const f=document.querySelectorAll('#post input[name="tax_input[product_cat][]"]:checked');if(f.length&&(u=f[0].parentNode.innerText),c.currentPost?.primary_term?.product_cat){const s=document.getElementById(`in-product_cat-${c.currentPost.primary_term.product_cat}`)||document.getElementById(`in-product_cat-${c.currentPost.primary_term.product_cat}-1`);u=s?.childNodes[0]?.innerText||"",s.hasChildNodes()||(u=s?.parentNode?.innerText||"")}a.updateTaxonomyTitle(u)};window.addEventListener("DOMContentLoaded",()=>{window?.aioseo?.screen?.base!=="customize"&&!b()&&w()});const W=()=>{b()||(window.addEventListener("change",e=>{e.target.tagName==="INPUT"&&w()}),window.aioseoBus.$on("standalone-update-post",e=>{e.primary_term&&w()}))},$=(e,o=!0)=>{if(!I())return;t();const i=y();if(i.currentPost.context==="term"){const r=document.querySelector("#edittag");r&&r.addEventListener("submit",()=>{i.isDirty=!1}),L()}else if(_().ping(),o&&i.savePostState(),q()){const d=window.setInterval(()=>{window.wp.data.select("core/editor").getCurrentPost().id&&(window.clearInterval(d),A())},50)}else g()&&W(),(B()||M())&&((document.querySelector("#post")||{})?.addEventListener("submit",()=>{i.isDirty=!1}),N()),T()};export{$ as l};
