import{y as m,i as y,c as v,b as E,u as f,r as S,t as g,v as x}from"./links.23796d97.js";import{m as t,d as C,t as b,s as _,e as k,f as h}from"./postContent.dbf3451c.js";const I=()=>{let e=!1;if(document.querySelector("#wp-content-wrap.tmce-active")){const r=window.setInterval(()=>{!window.tinyMCE||!window.tinyMCE.activeEditor||(window.clearInterval(r),t(),window.tinyMCE.get("content").on("keyup",()=>{t(500)}),window.tinyMCE.get("content").on("paste",()=>{t(500)}))},50)}else{const r=document.querySelector("textarea#content");r&&(r.addEventListener("keyup",()=>{t(500)}),r.addEventListener("paste",()=>{t(500)}))}const o=document.querySelector("#post input#title");o&&o.addEventListener("input",()=>{t(500)}),w();const n=document.querySelector("#post_name");n&&n.addEventListener("change",()=>{t(500)});const c=document.querySelector("#edit-slug-buttons");c&&c.addEventListener("click",r=>{r.target===c.querySelector("#edit-slug-buttons button.save")&&t()});const s=document.querySelector("#categorychecklist");s&&s.addEventListener("change",function(){C()});const l=function(r){r.forEach(p=>{if(p.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 i=document.querySelector("#content");i&&(i.addEventListener("keyup",()=>{t(500)}),i.addEventListener("paste",()=>{t(500)})),w()}})},a=new MutationObserver(l),u=document.querySelector("#wp-content-wrap");u&&a.observe(u,{attributes:!0});const d=document.querySelector("#wp-excerpt-wrap");d&&a.observe(d,{attributes:!0}),setInterval(()=>{e&&(e=!1)},500),b()&&!m()&&(e=!0,setInterval(()=>{window.tinyMCE&&window.tinyMCE.activeEditor&&window.tinyMCE.activeEditor.isDirty()&&!e&&(e=!0,t())},500))},w=()=>{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)}))},P=()=>{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 n=y();n.isDirty=!1,t()}})},q=()=>{if(v().isUnlicensed)return;let o="",n="",c="";const s=E();window.addEventListener("change",l=>{if(l.target.tagName!=="INPUT")return;const a=document.getElementById("_sku");a&&(o=a.value),s.updateWooCommerceSku(o);const u=document.getElementById("_sale_price"),d=document.getElementById("_regular_price");u&&(n=u.value),!n&&d&&(n=d.value);const p=f().aioseo.data.wooCommerce.currencySymbol+parseFloat(n||0).toFixed(2);s.updateWooCommercePrice(p);let i=document.querySelectorAll('#post input[name="tax_input[product_brand][]"]:checked');i.length||(i=document.querySelectorAll('#post input[name="tax_input[pwb-brand][]"]:checked')),i.length?c!==i[0].parentNode.innerText&&(c=i[0].parentNode.innerText,s.updateWooCommerceBrand(i[0].parentNode.innerText)):c!==""&&(c="",s.updateWooCommerceBrand(""))})},A=(e,o=!0)=>{if(!_())return;t();const n=y();if(n.currentPost.context==="term")k();else if(f().ping(),o&&n.savePostState(),S()){const s=window.setInterval(()=>{window.wp.data.select("core/editor").getCurrentPost().id&&(window.clearInterval(s),P())},50)}else m()&&q(),(g()||x())&&I(),h()};export{A as l};
