OwlCyberSecurity - MANAGER
Edit File: loadTruSeo.2fae4c5d.js
import{F as L,e as y,k as T,G as A,u as q,A as B,y as N,z as W}from"./index.7377ee90.js";import{s as U}from"./metabox.8f8ea589.js";import{m as e,i as P,j as $,k as z,l as D}from"./helpers.77f11e73.js";const F=()=>{let t=!1;if(document.querySelector("#wp-content-wrap.tmce-active")){const n=window.setInterval(()=>{!window.tinyMCE||!window.tinyMCE.activeEditor||(window.clearInterval(n),e(),window.tinyMCE.get("content").on("keyup",()=>{e(500)}),window.tinyMCE.get("content").on("paste",()=>{e(500)}))},50)}else{const n=document.querySelector("textarea#content");n&&(n.addEventListener("keyup",()=>{e(500)}),n.addEventListener("paste",()=>{e(500)}))}const o=document.querySelector("#post input#title");o&&o.addEventListener("input",()=>{e(500)}),I();const i=document.querySelector("#post_name");i&&i.addEventListener("change",()=>{e(500)});const c=document.querySelector("#edit-slug-buttons");c&&c.addEventListener("click",n=>{n.target===c.querySelector("#edit-slug-buttons button.save")&&e()});const s=document.querySelector("#categorychecklist");s&&s.addEventListener("change",function(){P()}),window.aioseoBus.$on("standalone-update-post",n=>{n.primary_term&&P()});const a=function(n){n.forEach(f=>{if(f.attributeName==="class"){if(document.querySelector("#wp-content-wrap.tmce-active")){if(!window.tinyMCE)return;window.tinyMCE.get("content").on("keyup",()=>{e(500)}),window.tinyMCE.get("content").on("paste",()=>{e(500)})}const l=document.querySelector("#content");l&&(l.addEventListener("keyup",()=>{e(500)}),l.addEventListener("paste",()=>{e(500)})),I()}})},d=new MutationObserver(a),u=document.querySelector("#wp-content-wrap");u&&d.observe(u,{attributes:!0});const p=document.querySelector("#wp-excerpt-wrap");p&&d.observe(p,{attributes:!0}),setInterval(()=>{t&&(t=!1)},500),$()&&!L()&&(t=!0,setInterval(()=>{window.tinyMCE&&window.tinyMCE.activeEditor&&window.tinyMCE.activeEditor.isDirty()&&!t&&(t=!0,e())},500))},I=()=>{if(document.querySelector("#wp-excerpt-wrap.tmce-active")){const o=window.setInterval(()=>{window.tinyMCE&&(window.clearInterval(o),e(),window.tinyMCE.get("excerpt").on("keyup",()=>{e(500)}),window.tinyMCE.get("excerpt").on("paste",()=>{e(500)}))},50)}const t=document.querySelector("#post textarea#excerpt");t&&(t.addEventListener("keyup",()=>{e(500)}),t.addEventListener("paste",()=>{e(500)}))},O=()=>{e(),window.wp.data.subscribe(()=>{e(500);const t=window.wp.data.select("core/editor").isSavingPost(),o=window.wp.data.select("core/editor").isAutosavingPost();if(t&&!o){const i=y();i.isDirty=!1,e()}})},M=()=>{const t=T();return(t==null?void 0:t.isUnlicensed)||!1},w=()=>{var v,S,_,g,x,C;let t="",o="",i="",c=[],s="";const a=A(),d=y(),u=document.getElementById("_sku");u&&(t=u.value,a.updateWooCommerceSku(t));const p=document.getElementById("_sale_price"),n=document.getElementById("_regular_price");p&&(o=p.value),!o&&n&&(o=n.value);const l=((S=(v=q().aioseo.data)==null?void 0:v.wooCommerce)==null?void 0:S.currencySymbol)||"$"+parseFloat(o||0).toFixed(2);a.updateWooCommercePrice(l),["pwb-brand","product_brand"].forEach(r=>{var b,h,k;if(c=document.querySelectorAll(`#post input[name="tax_input[${r}][]"]:checked`),!!c.length&&(i!==c[0].parentNode.innerText&&(i=c[0].parentNode.innerText,a.updateWooCommerceBrand(c[0].parentNode.innerText)),(h=(b=d.currentPost)==null?void 0:b.primary_term)!=null&&h[r])){const m=document.querySelector(`#${r}checklist input[value="${d.currentPost.primary_term[r]}"]`);(k=m==null?void 0:m.parentNode)!=null&&k.innerText&&a.updateWooCommerceBrand(m.parentNode.innerText)}});const E=document.querySelectorAll('#post input[name="tax_input[product_cat][]"]:checked');if(E.length&&(s=E[0].parentNode.innerText),(g=(_=d.currentPost)==null?void 0:_.primary_term)!=null&&g.product_cat){const r=document.getElementById(`in-product_cat-${d.currentPost.primary_term.product_cat}`)||document.getElementById(`in-product_cat-${d.currentPost.primary_term.product_cat}-1`);s=((x=r==null?void 0:r.childNodes[0])==null?void 0:x.innerText)||"",r.hasChildNodes()||(s=((C=r==null?void 0:r.parentNode)==null?void 0:C.innerText)||"")}a.updateTaxonomyTitle(s)};window.addEventListener("DOMContentLoaded",()=>{var t,o;((o=(t=window==null?void 0:window.aioseo)==null?void 0:t.screen)==null?void 0:o.base)!=="customize"&&!M()&&w()});const R=()=>{M()||(window.addEventListener("change",t=>{t.target.tagName==="INPUT"&&w()}),window.aioseoBus.$on("standalone-update-post",t=>{t.primary_term&&w()}))},K=(t,o=!0)=>{if(!U())return;e();const i=y();if(i.currentPost.context==="term")z();else if(q().ping(),o&&i.savePostState(),B()){const s=window.setInterval(()=>{window.wp.data.select("core/editor").getCurrentPost().id&&(window.clearInterval(s),O())},50)}else L()&&R(),(N()||W())&&F(),D()};export{K as l};