관리-도구
편집 파일: postSlug.cemx0kwk.js
var Pt=Object.defineProperty;var Tt=(t,e,n)=>e in t?Pt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var y=(t,e,n)=>Tt(t,typeof e!="symbol"?e+"":e,n);import{o as X,a1 as K,b as p,a2 as kt,E as S,F as P,G as w,d as g,K as $,a3 as q,J as N,a4 as L,a5 as M,I as B,H as A,u as tt,a6 as vt,a as et,a7 as J,s as bt}from"./index.nsvc8vqf.js";import{d as Q}from"./Caret.hnvbzqgq.js";import{s as xt}from"./metabox.ncz5ucbq.js";import{c as I}from"./cleanForSlug.ncex5ar8.js";import{a as Ct,g as E}from"./_baseSet.lqwmtpeb.js";import{I as _t}from"./helpers.fdpg7vgg.js";import{aT as Y}from"./runtime-dom.esm-bundler.h3clfjuw.js";function At(t,e,n){return t==null?t:Ct(t,e,n)}const It=t=>{var n;if(typeof(window==null?void 0:window.acf)!="object"||typeof((n=window.acf)==null?void 0:n.getField)!="function")return null;const e=window.acf.getField(t)||{};return typeof(e==null?void 0:e.val)!="function"?null:e.val()||{}},$t=()=>{const t=window.elementor.documents.getCurrent(),e=[];return t.$element?(t.$element.find(".elementor-widget-container").each((n,r)=>{const o=r.innerHTML.trim().replaceAll(/<p.*>(<img.*>)<\/p>/g,"$1");X(o)===""&&K(o).length===0||e.push(o)}),e.join(" ")):""},D=()=>{var n;const{settings:t,config:e}=window.elementor;return{content:$t(),title:t.page.model.get("post_title"),excerpt:t.page.model.get("post_excerpt")||"",slug:I(t.page.model.get("post_title")),permalink:e.document.urls.permalink||"",featuredImage:((n=t.page.model.get("post_featured_image"))==null?void 0:n.url)||""}},qt=()=>{const t=E(ET_Builder,"Frames.app.frameElement",document.querySelector("iframe#et-fb-app-frame"));if(!t)return document.createElement("div");let e=t.contentWindow.document.querySelectorAll("#et-fb-app");return 1<e.length&&(e=[...e].filter(n=>n.classList.contains("et-fb-root-ancestor"))),e[0]||document.createElement("div")},Nt=()=>{const t=[],e=qt().querySelectorAll(".et_pb_section"),n=new RegExp(["<style.*?</style>","\\[object Object\\]"].join("|"),"gi");for(const r of e){const o=r.innerHTML.replace(n,"").replaceAll(/<p.*>(<img.*>)<\/p>/g,"$1");X(o)===""&&K(o).length===0||t.push(o)}return t.join(" ")},Lt=()=>{const t=new URL(E(ETBuilderBackendDynamic,"currentPage.permalink",""));return t.searchParams.delete("PageSpeed"),t.href},Mt=async()=>{const{wp:t}=window,e=E(ETBuilderBackendDynamic,"currentPage.thumbnailId",0);if(!t||e===0)return"";const n=t.media.attachment(e);let r="";return await n.fetch().then(()=>{r=n.get("url"),At(ETBuilderBackendDynamic,"currentPage.thumbnailUrl",r)}),r},O=()=>({content:Nt(),title:E(ETBuilderBackendDynamic,"postTitle",""),excerpt:E(ETBuilderBackendDynamic,"postMeta.post_excerpt",""),slug:E(ETBuilderBackendDynamic,"postMeta.post_name",""),permalink:Lt(),featuredImage:Mt()}),Bt=t=>{let e;switch(t.type){case"header":e=document.createElement(t.settings.tag),e.innerHTML=t.settings.headerTxt.trim();break;case"image":const n=document.createElement("img");t.settings.altTxt&&n.setAttribute("alt",t.settings.altTxt),t.settings.src&&n.setAttribute("src",t.settings.src),t.settings.noFollow&&n.setAttribute("rel","nofollow"),e=n,t.settings.link&&(e=document.createElement("a"),e.setAttribute("href",t.settings.link),e.innerHTML=n.outerHTML,t.settings.noFollow&&e.setAttribute("rel","nofollow"),t.settings.openNewWindow&&e.setAttribute("target","_blank"));break;case"video":t.settings.type==="youtube"?(e=document.createElement("iframe"),e.setAttribute("src",t.settings.youtubeUrl)):(e=document.createElement("div"),e.innerHTML=t.settings.code);break;case"text":e=document.createElement("div"),e.innerHTML=t.settings.txt.trim();break;case"button":e=document.createElement("a"),e.appendChild(document.createTextNode(t.settings.btnTxt+" "+t.settings.btnSubTxt)),t.settings.link&&e.setAttribute("href",t.settings.link),t.settings.altTxt&&e.setAttribute("alt",t.settings.altTxt),t.settings.src&&e.setAttribute("src",t.settings.src),t.settings.noFollow&&e.setAttribute("rel","nofollow"),t.settings.openNewWindow&&e.setAttribute("target","_blank");break;case"bullet-list":e=document.createElement("ul"),t.settings.items.forEach(r=>{const o=document.createElement("li");o.innerHTML=r.txt,e.appendChild(o)});break;case"custom-html":e=document.createElement("div"),e.innerHTML=t.settings.code;break}return e},Dt=()=>{const t=[];return JSON.parse(JSON.stringify(E(seedprod_data,"settings.document.sections",[]))).forEach(n=>{n.rows.forEach(r=>{r.cols.forEach(o=>{o.blocks.forEach(s=>{const a=Bt(s);a&&(X(a)===""&&K(a).length===0||t.push(a.outerHTML))})})})}),t.join(" ")},Ot=()=>{const t=E(seedprod_data,"home_url",""),e=E(seedprod_data,"settings.post_name","");return`${t}/${e}/`},R=()=>({content:Dt(),title:E(seedprod_data,"settings.post_title",""),excerpt:"",slug:E(seedprod_data,"settings.post_name",""),permalink:Ot()}),Rt=()=>p().currentPost.processedContent,Ut=t=>{var e;if(t==="admin_frontend_editor"){const{vc:n}=window;return n.builder.getTitle()}return((e=document.getElementById("#title"))==null?void 0:e.value)||""},Ht=t=>{var e;if(t==="admin_frontend_editor"){const{vc_iframe_src:n}=window,r=new URL(n).pathname.split("/").filter(o=>o);return r[r.length-1]}return((e=document.querySelector("#post_name"))==null?void 0:e.value)||""},Vt=t=>{var e;if(t==="admin_frontend_editor"){const{vc_iframe_src:n}=window;return n.replace(new URL(n).search,"")}return((e=document.querySelector("#sample-permalink a"))==null?void 0:e.href)||""},U=()=>{const{vc_mode:t}=window;return{content:Rt(),title:Ut(t),excerpt:"",slug:Ht(t),permalink:Vt(t),featuredImage:""}},Wt=()=>{var e;return((e=p().currentPost)==null?void 0:e.processedContent)||""},zt=()=>{var e;const{FusionApp:t}=window;return(t==null?void 0:t.getPost("post_title"))||((e=document.getElementById("#title"))==null?void 0:e.value)||""},jt=()=>{var e;const{FusionApp:t}=window;return(t==null?void 0:t.getPost("post_name"))||((e=document.querySelector("#post_name"))==null?void 0:e.value)||""},Gt=()=>{var e;const{FusionApp:t}=window;return(t==null?void 0:t.getPost("post_permalink").replace("?fb-edit=1",""))||((e=document.querySelector("#sample-permalink a"))==null?void 0:e.href)||""},Jt=async()=>{const{wp:t,FusionApp:e}=window;if(!t||!e||!e.getDynamicPost("post_meta")._thumbnail_id)return"";const n=t.media.attachment(e.getDynamicPost("post_meta")._thumbnail_id);let r="";return await n.fetch().then(()=>{r=n.get("url")}),r},H=()=>({content:Wt(),title:zt(),excerpt:"",slug:jt(),permalink:Gt(),featuredImage:Jt()}),Zt=()=>{let t="";const e=["p","a","img","caption","br","video","iframe","blockquote","cite","em","strong","i","b","q","h1","h2","h3","h4","h5","h6","ul","ol","li","table","tr","th","td"],n=function(o){var a;const s=kt(o);if(s.querySelectorAll(".so-panel").length===0)return o;for(const c of s.querySelectorAll("iframe, script, style, link"))c.remove();return s.querySelectorAll("*").forEach(c=>{if(!e.includes(c.tagName.toLowerCase())){const i=Array.from(c.childNodes);c.replaceWith(...i)}}),((a=s.innerHTML)==null?void 0:a.replace(/[\t|\n]/gm," "))||""},{soPanelsBuilderView:r}=window;return r&&(Array.isArray(r)?r.forEach(function(o){t+=n(o.contentPreview)}):t=n(r.contentPreview)),t},V=()=>({content:Zt(),title:"",excerpt:"",slug:"",permalink:"",featuredImage:""}),Xt=()=>{var t,e;return((e=(t=TVE==null?void 0:TVE.Editor_Page)==null?void 0:t.content_manager)==null?void 0:e.get_clean_content())||""},Ft=()=>{var t,e;return((e=(t=TVE==null?void 0:TVE.CONST)==null?void 0:t.post)==null?void 0:e.post_title)||""},Yt=()=>{var t,e;return((e=(t=TVE==null?void 0:TVE.CONST)==null?void 0:t.post)==null?void 0:e.post_name)||""},Qt=()=>{var t;return((t=TVE==null?void 0:TVE.CONST)==null?void 0:t.post_url)||""},Kt=()=>{var e,n,r,o,s;const t=((r=(n=(e=TVE==null?void 0:TVE.CONST)==null?void 0:e.theme)==null?void 0:n.post_featured_image)==null?void 0:r.src)||((s=(o=TVE==null?void 0:TVE.CONST)==null?void 0:o.post_image)==null?void 0:s.featured)||"";return t.includes("inc/assets/images/featured_image.png")?"":t},W=()=>({content:Xt(),title:Ft(),excerpt:"",slug:Yt(),permalink:Qt(),featuredImage:Kt()}),ot=()=>{let t="";switch(!0){case A():t=D().permalink;break;case B():t=O().permalink;break;case M():t=R().permalink;break;case L():t=U().permalink;break;case N():t=H().permalink;break;case q():t=V().permalink;break;case $():t=W().permalink;break}return t},te=()=>{const t=g();if(t.liveTags.permalink)return t.liveTags.permalink;let e;if(S()||P){const n=document.querySelector("#edit-slug-box a");n&&n.href&&(e=n.href)}return w()&&(e=window.wp.data.select("core/editor").getPermalink()),e||(e=ot()),e&&t.updatePermalink(e),e},b=()=>{let t;if(S()||P){const e=document.querySelector("#edit-slug-box a");e&&e.href&&(t=e.href)}return w()&&(t=window.wp.data.select("core/editor").getPermalink()),t||(t=ot()),t},ee=async(t=!0)=>{let e=te();const n=b();if(e!==n&&(e=n,e)){const r=p();if(g().updatePermalink(e),!t)return;new T().runAnalysis({postId:r.currentPost.id,postData:{...r.currentPost},content:v(),slug:b()})}},st=()=>{let t="";switch(!0){case A():t=D().title;break;case B():t=O().title;break;case M():t=R().title;break;case L():t=U().title;break;case N():t=H().title;break;case q():t=V().title;break;case $():t=W().title;break}return t},ne=()=>{const t=g();if(t.liveTags.post_title)return t.liveTags.post_title;let e;if(S()||P()){const n=document.querySelector("#post input#title");e=n?n.value:""}return w()&&(e=window.wp.data.select("core/editor").getCurrentPost().title),e||(e=st()),e&&t.updatePostTitle(e),e},at=()=>{let t;if(S()||P()){const e=document.querySelector("#post input#title");t=e?e.value:""}return w()&&(t=window.wp.data.select("core/editor").getEditedPostAttribute("title")),t||(t=st()),t},re=async(t=!0)=>{let e=ne();const n=at();if(e!==n){e=n;const r=p();if(g().updatePostTitle(e),!t)return;new T().runAnalysis({postId:r.currentPost.id,postData:{...r.currentPost},content:v(),slug:b()})}},it=t=>t?(t=t.replaceAll(/\n\n/g," "),t=X(t,!1,"innerText"),t=t.replace(/\[.*?]/g,""),t.trim()):"",ct=()=>{let t="";switch(!0){case A():t=D().excerpt;break;case B():t=O().excerpt;break;case M():t=R().excerpt;break;case L():t=U().excerpt;break;case N():t=H().excerpt;break;case q():t=V().excerpt;break;case $():t=W().excerpt;break}return t},oe=()=>{const t=g();if(t.liveTags.post_excerpt)return t.liveTags.post_excerpt;let e;return(S()||P())&&(e=lt()),w()&&(e=window.wp.data.select("core/editor").getCurrentPost().excerpt),e||(e=ct()),e||(e=it(yt())),e&&t.updatePostExcerpt(e),e},se=()=>{let t;return(S()||P())&&(t=lt()),w()&&(t=window.wp.data.select("core/editor").getEditedPostAttribute("excerpt")),t||(t=ct()),t||(t=it(v())),t},ae=async(t=!0)=>{let e=oe();const n=se();if(e!==n){e=n;const r=p();if(g().updatePostExcerpt(e),!t)return;new T().runAnalysis({postId:r.currentPost.id,postData:{...r.currentPost},content:v(),slug:b()})}},lt=()=>{let t="";const e=document.querySelector("#postexcerpt textarea#excerpt");if(t=e?e.value:"",document.querySelector("#wp-excerpt-wrap.tmce-active")){const n=window.tinyMCE?window.tinyMCE.get("excerpt"):"";n&&(t=n.getContent({format:"raw"}))}return t};let f="",k="";const ie=(t=!0)=>{var r;const e=g();if(S()||P()){const o=document.querySelectorAll('#post input[name="post_category[]"]:checked');o.length?(f!==o[0].parentNode.innerText&&(f=o[0].parentNode.innerText,e.updateTaxonomyTitle(f)),k=Array.from(o).map(s=>s.parentNode.innerText).join(", "),e.updateCategories(k)):f!==""&&(f=k="",e.updateTaxonomyTitle(f),e.updateCategories(k))}if(w()){let o=[],s=[];if((r=tt().aioseo.user.data.allcaps)!=null&&r.manageCategories&&(o=window.wp.data.select("core").getEntityRecords("taxonomy","category"),s=window.wp.data.select("core/editor").getEditedPostAttribute("categories")),s&&s.length&&o){const c=o.find(i=>i.id===s[0]);c&&f!==c.name&&(f=c.name,e.updateTaxonomyTitle(f)),k=o.filter(i=>s.includes(i.id)).map(i=>i.name).join(", "),e.updateCategories(k)}else f!==""&&(f=k="",e.updateTaxonomyTitle(f),e.updateCategories(k))}const n=p();t&&new T().runAnalysis({postId:n.currentPost.id})},ce=(t=!1)=>{const e=p();if(e.currentPost.context!=="term")return;const n=g(),r=document.querySelector("#edittag input#name");r&&(n.updateTaxonomyTitle(r.value),r.addEventListener("input",()=>{n.updateTaxonomyTitle(r.value)}));const o=document.querySelector("#edittag textarea#description");o&&(n.updateTaxonomyDescription(o.value),o.addEventListener("input",()=>{n.updateTaxonomyDescription(o.value)}));const s=document.querySelector("#edittag input#slug");if(s){const a=I(s.value);n.updatePermalinkSlug(a),n.updatePermalink(e.currentPost.permalink.replace(`/${n.permalinkSlug}`,`/${a.replace(/ /gi,"-").replace(/[^a-z0-9-]/gi,"").toLowerCase()}`)),s.addEventListener("input",()=>{n.updatePermalinkSlug(a),n.updatePermalink(e.currentPost.permalink.replace(`/${n.permalinkSlug}`,`/${a.replace(/ /gi,"-").replace(/[^a-z0-9-]/gi,"").toLowerCase()}`))})}e.savePostState(),t&&T.runAnalysis({postId:e.currentPost.id})},le=(t=!1)=>{const e=p();if(e.currentPost.postType!=="attachment")return;const n=g(),r=document.querySelector("textarea#attachment_caption");r&&(n.updateAttachmentCaption(r.value),r.addEventListener("input",i=>{n.updateAttachmentCaption(i.target.value)}));const o=document.querySelector("textarea#attachment-details-caption");o&&(n.updateAttachmentCaption(o.value),o.addEventListener("input",i=>{n.updateAttachmentCaption(i.target.value)}));const s=document.querySelector("textarea#attachment_content");s&&(n.updateAttachmentDescription(s.value),s.addEventListener("input",i=>{n.updateAttachmentDescription(i.target.value)}));const a=document.querySelector("input#attachment_alt");a&&(n.updateAltTag(a.value),a.addEventListener("input",i=>{n.updateAltTag(i.target.value)}));const c=document.querySelector("input#attachment-details-alt-text");c&&(n.updateAltTag(a.value),c.addEventListener("input",i=>{n.updateAltTag(i.target.value)})),t&&new T().runAnalysis({postId:e.currentPost.id})},ut=()=>{var e,n;const t=p();return(e=t==null?void 0:t.currentPost)!=null&&e.id&&!!((n=t.currentPost)!=null&&n.isPageAnalysisEligible)||!1},ve=()=>{var r,o;const t=tt();if(!((r=t.aioseo.screen)!=null&&r.postType))return!1;const e=p();return!!((o=et().options.advanced)!=null&&o.truSeo&&xt(t.aioseo.screen.postType)&&!e.currentPost.isStaticPostsPage)},_=async(t=900,e=!0)=>{Q(async()=>{const n=vt(),r=p();await re(!1),await de(!1),await ae(!1),await fe(!1),await ee(!1),ie(!1),ce(!1),le(!1),Q(n.updateSchemaOutput,Math.max(t*2,1800)),e&&new T().runAnalysis({postId:r.currentPost.id})},t)},be=t=>{const e=t.getRangeAt(0),n=e.cloneRange();return n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.startContainer,e.startOffset),t},xe=t=>{const e=new RegExp(" ","g");return t.replace(/ /g," ").replace(e," ")},Ce=({element:t,property:e,value:n})=>{if(!t)return document.documentElement;let r=t.parentElement;for(;r;){if(r.isEqualNode(document.documentElement)||n===document.defaultView.getComputedStyle(r).getPropertyValue(e))return r;r=r.parentElement}},_e=()=>{const t=document.createElement("div");return t.classList.add("tru-seo-highlight-popover-wrapper"),t.style.position="absolute",t.style.zIndex="999",t.style.display="flex",t.setAttribute("tabindex",-1),t},dt=()=>{const e=p().currentPost.postType;if(!e)return"";const r=et().dynamicOptions.searchAppearance.postTypes[e].customFields;if(!r||!ut)return"";const o=()=>{_(500)},s=r.replace(/\n/g,",").split(","),a=[],c=["INPUT","TEXTAREA","IMG"],i=u=>{try{document.createDocumentFragment().querySelector(u)}catch{return!1}return!0};s.forEach(u=>{u=u.trim();const m=i(`#${u}`)?document.querySelector(`#${u}`):!1,x=document.querySelectorAll("#the-list > tr"),z=document.querySelectorAll(".acf-field");c.includes(m==null?void 0:m.tagName)&&!(m!=null&&m.closest(".acf-field"))?a.push(m):x.forEach(d=>{const l=d.querySelector(`#${d.id}-key`),C=d.querySelector(`#${d.id}-value`);c.includes(C==null?void 0:C.tagName)&&s.includes(l==null?void 0:l.value)&&a.push(C)}),z.forEach(d=>{if(u!==d.dataset.name)return"";let l=d.querySelector(`[id^="acf"][name$="[${d.dataset.key}]"]`);if(d.dataset.type==="image"&&(l=d.querySelector(".has-value img")),d.dataset.type==="gallery"&&(l=d.querySelector(".acf-gallery-attachment img")),d.dataset.type==="link"&&(l=It(d.dataset.key)||d.querySelector(`[name$="[${d.dataset.key}][url]"]`)||{},l={tagName:"INPUT",type:"url",value:(l==null?void 0:l.url)??(l==null?void 0:l.value)??""}),!l||l.type&&l.type==="hidden")return"";if(d.dataset.type==="wysiwyg"){const C=window.setInterval(()=>{var j,G;(G=(j=window.tinyMCE)==null?void 0:j.activeEditor)!=null&&G.acf&&(window.clearInterval(C),window.tinyMCE.activeEditor.on("keyup",function(){_(500)}),window.tinyMCE.activeEditor.on("PostProcess",function(){Q(()=>{_(500)},10)}))},50),St=function(j){j.forEach(G=>{var rt;if(G.attributeName==="class"&&d.querySelector(".wp-editor-wrap.tmce-active")&&((rt=window.tinyMCE)!=null&&rt.activeEditor)){window.tinyMCE.activeEditor.on("keyup",function(){_(500)});const F=d.querySelector(`[name="acf[${d.dataset.key}]"]`);F&&(F.addEventListener("keyup",()=>{_(500)}),F.addEventListener("paste",()=>{_(500)}))}})},ht=new MutationObserver(St),nt=d.querySelector(".wp-editor-wrap");nt&&ht.observe(nt,{attributes:!0})}c.includes(l.tagName)&&a.push(l)})});let h="";return a.forEach(u=>{let m="";if(c.includes(u.tagName)&&typeof(u==null?void 0:u.addEventListener)=="function"&&u.addEventListener("keyup",o),u.value&&(m=u.value),u.tagName==="IMG"&&u.src){const x=u.alt?`alt="${u.alt}"`:"";m=`<img src="${u.src}" ${x}>`}u.value&&u.type&&u.type==="url"&&(m=`<a href="${m}">${m}</a>`),m&&(h+=`${m} `)}),h},Ae=(t,e=["INPUT","TEXTAREA","IMG"])=>{if(!t)return"";const n=document.querySelector(`#${t}`),r=document.querySelectorAll("#the-list > tr"),o=document.querySelectorAll(".acf-field");let s="";return n&&e.indexOf(n.tagName)!==-1&&(n.closest(".acf-field")||(s=n.tagName==="IMG"?n.getAttribute("src"):n.value)),r.length&&r.forEach(a=>{const c=a.querySelector(`#${a.id}-key`),i=a.querySelector(`#${a.id}-value`);i&&e.indexOf(i.tagName)!==-1&&c.value===t&&(s=i.tagName==="IMG"?i.getAttribute("src"):i.value)}),o.length&&o.forEach(a=>{if(t!==a.dataset.name)return;let c;e.forEach(i=>{const h=i.toLowerCase();c=a.querySelector(`[data-key="${a.dataset.key}"] ${h}`)||c}),c&&(s=c.tagName==="IMG"?c.getAttribute("src"):c.value)}),s},ue=t=>{const e=t.getBody();return 1<e.childNodes.length?!1:e.childNodes.length===0?!0:1<e.childNodes[0].childNodes.length?!1:/^\n?$/.test(e.innerText||e.textContent)},pt=/base64,(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)/g,mt=["acf","aioseo"],gt=()=>{let t="";switch(!0){case A():t=D().content;break;case B():t=O().content;break;case M():t=R().content;break;case L():t=U().content;break;case N():t=H().content;break;case q():t=V().content;break;case $():t=W().content;break}return t},ft=t=>{var r;if(!t.includes('<!-- wp:block {"ref":'))return t;const e=(r=window.wp.blocks)==null?void 0:r.rawHandler({HTML:t});return _t(e).forEach(o=>{var s,a,c;if(o.name==="core/block"){const i=window.wp.data.select("core").getEntityRecord("postType","wp_block",(s=o.attributes)==null?void 0:s.ref);(a=i==null?void 0:i.content)!=null&&a.raw&&(t=t.replace(`<!-- wp:block {"ref":${(c=o.attributes)==null?void 0:c.ref}} /-->`,i.content.raw))}}),t},wt=(t,e)=>(window.wp.data.select("core/block-editor").getBlocks().forEach(r=>{if(e.includes(r.name.split("/")[0])){const o=document.getElementById("block-"+r.clientId);if(o&&o.innerText){const s=`(<!-- wp:${r.name}.*?/wp:${r.name} -->)|(<!-- wp:${r.name}.*?/-->)`;t=t.replace(new RegExp(s,"s"),o.innerText)}}}),t),yt=()=>{const t=g();if(t.liveTags.post_content)return t.liveTags.post_content;let e="";if(S()&&!J())if(window.tinyMCE||document.querySelector("#wp-content-wrap.html-active"))e=Z();else{const r=window.setInterval(()=>{window.tinyMCE&&(window.clearInterval(r),e=Z())},50)}return w()&&(e=window.wp.data.select("core/editor").getCurrentPost().content||"",e=ft(e),e=wt(e,mt)),J()&&(e=gt()),p().currentPost.descriptionIncludeCustomFields&&(e=e+dt()),e=e.replace(pt,""),e&&t.updatePostContent(e),e},v=()=>{let t="";if(S()&&!J())if(window.tinyMCE||document.querySelector("#wp-content-wrap.html-active"))t=Z();else{const n=window.setInterval(()=>{window.tinyMCE&&(window.clearInterval(n),t=Z())},50)}return w()&&(t=window.wp.data.select("core/editor").getEditedPostContent(),t=ft(t),t=wt(t,mt)),J()&&(t=gt()),p().currentPost.descriptionIncludeCustomFields&&(t=t+dt()),t=t.replace(pt,""),t},de=async(t=!0)=>{let e=yt();const n=v();if(e!==n){e=n;const r=p();if(g().updatePostContent(e),!t)return;new T().runAnalysis({postId:r.currentPost.id,postData:{...r.currentPost},content:v(),slug:b()})}},Z=()=>{let t;const e=window.tinyMCE?window.tinyMCE.get("content"):"";if(document.querySelector("#wp-content-wrap.tmce-active")&&e)t=e.getContent({format:ue(e)?"html":"raw"});else{const n=document.querySelector("textarea#content");t=n?n.value:""}return t};function pe(t){return new Worker(""+window.__aioseoDynamicImportPreload__("main-B9xOVSYc.js"),{name:t==null?void 0:t.name})}class T{constructor(){y(this,"postId",null);y(this,"postTitle",null);y(this,"postParsedTitle",null);y(this,"postParsedDescription",null);y(this,"postDescription",null);y(this,"keyphrases",null);y(this,"postContent",null);y(this,"postSlug",null);y(this,"isAnalyzing",!1);y(this,"worker",null)}async runAnalysis({postId:e,postData:n,content:r=v(),slug:o=b()}){var d;const s=p(),a=et();if(n=n||{...s.currentPost},!((d=a.options.advanced)!=null&&d.truSeo)||!s.currentPost.page_analysis||this.isAnalyzing)return;this.worker&&this.worker.terminate();const c={separator:bt(a.options.searchAppearance.global.separator)},i=tt(),h=g(),u=h.tags.map(l=>h.liveTags[l.id]!==void 0&&l.value!==h.liveTags[l.id]?{...l,value:h.liveTags[l.id]}:l),m={...Y(i.aioseo),tags:Y(u),currentPost:Y(s.currentPost)},x=JSON.parse(JSON.stringify({postId:e,postData:n,content:r,aioseo:m,slug:o,postEditedTitle:at(),aioseoGlobals:c}));let z=[];this.worker=new pe,this.worker.addEventListener("message",l=>{l.data.event==="tru-seo-analysis-complete"&&(z=l.data.analysis,this.dispatchActions(z,x),this.worker.terminate())}),this.worker.postMessage({event:"tru-seo-analysis",analysisData:x})}setSidebarButtonScore(e){const n=document.getElementById("aioseo-post-settings-sidebar-button"),r=document.getElementById("aioseo-post-score");!n||!r||(n.className=80<e?"score-green":50<e?"score-orange":"score-red",w()||(n.classList.add("aioseo-score-button","classic-editor"),e=`${e}/100`),r.textContent=e)}dispatchActions(e,n){const r=p();e.forEach(o=>{o.action==="updateState"&&n.postEditedTitle&&ut()&&this.setSidebarButtonScore(o.data.seo_score),r[o.action](o.data)})}}const Et=()=>{let t="";switch(!0){case A():t=D().slug;break;case B():t=O().slug;break;case M():t=R().slug;break;case L():t=U().slug;break;case N():t=H().slug;break;case q():t=V().slug;break;case $():t=W().slug;break}return t},me=()=>{const t=g();if(t.permalinkSlug)return t.permalinkSlug;let e="";if(S()||P()){const n=document.querySelector("#post_name");n&&(e=I(n.value))}return w()&&(e=window.wp.data.select("core/editor").getCurrentPost().slug),e||(e=Et()),e&&t.updatePermalinkSlug(e),e},ge=()=>{let t="";if(S()||P()){const e=document.querySelector("#post_name");e&&(t=I(e.value))}if(w()&&(t=window.wp.data.select("core/editor").getEditedPostAttribute("slug")),A()){const e=window.elementor.settings.page.model.get("post_title");e&&(t=I(e))}return t||(t=Et()),t},fe=async(t=!0)=>{let e=me();const n=ge();if(e!==n){e=n;const r=p();if(g().updatePermalinkSlug(e),!t)return;new T().runAnalysis({postId:r.currentPost.id,postData:{...r.currentPost},content:v(),slug:b()})}};export{T,O as a,H as b,Ae as c,W as d,v as e,ie as f,D as g,ce as h,le as i,U as j,ve as k,V as l,_ as m,ge as n,Ce as o,xe as p,_e as q,be as r,At as s,ut as t};