OwlCyberSecurity - MANAGER
Edit File: primary-term.BCJFEgLU.js
import{v as m,o as w,c as h,B as p,a as u,E as g,b as T,V as S}from"./js/runtime-dom.esm-bundler.tPRhSV4q.js";import{l as x}from"./js/index.CkBeLh4y.js";import{l as E}from"./js/index.B6JTtDta.js";import{l as $}from"./js/index.3BJ3ZnWB.js";import{l as d,u as v,F as f,b as k,C as b,E as B}from"./js/links.Ce9S4kjc.js";import{e as P}from"./js/elemLoaded.COgXIo-H.js";import{s as A}from"./js/metabox.CnmedXkm.js";import{S as L}from"./js/Information.Bv8uKEyF.js";import{S as C}from"./js/Caret.BthVBOwE.js";import{_}from"./js/_plugin-vue_export-helper.BN1snXvA.js";import"./js/default-i18n.DXRQgkn2.js";import"./js/constants.CPpKID74.js";import"./js/helpers.CXsRrhc8.js";const D={getTerms:async e=>{const{apiFetch:t}=window.wp,{addQueryArgs:o}=window.wp.url,s=c(e);return await t({path:o(`/wp/v2/${s.restBase}`,{per_page:-1,orderby:"count",order:"desc",_fields:"id,name"})})},getSelectedTerms:e=>{const t=c(e);return window.wp.data.select("core/editor").getEditedPostAttribute(t.restBase)||[]}},I={getTerms:async e=>{var r;const t=[],o=c(e);return(((r=document.getElementById(`${o.name}checklist`))==null?void 0:r.querySelectorAll("li"))||[]).forEach(n=>{const a=n.querySelector("input").value,i=n.querySelector("label").innerText;t.push({id:parseInt(a,10),name:i.trim()})}),new Promise(n=>{n(t)})},getSelectedTerms:e=>{var r;const t=[],o=c(e);return(((r=document.getElementById(`${o.name}checklist`))==null?void 0:r.querySelectorAll("input:checked"))||[]).forEach(n=>{t.push(parseInt(n.value,10))}),t}},l=()=>{var o;return d(),(((o=v().aioseo.postData)==null?void 0:o.taxonomies)||[]).filter(s=>s.primaryTermSupport===!0)},M=e=>l().some(t=>e===t.name),c=e=>{const t=l().filter(o=>e===o.name);return t.length?t[0]:{}},N=e=>f()?D.getSelectedTerms(e):I.getSelectedTerms(e),H={setup(){return{postEditorStore:k()}},components:{SvgCircleInformation:L,SvgClose:C},data(){return{selectedTerms:[],strings:{didYouKnow:this.$t.sprintf(this.$t.__("Did you know that %1$s Pro allows you to choose a %2$sprimary category%3$s for your posts? This feature works hand in hand with our powerful Breadcrumbs template to give you full navigational control to help improve your search rankings!",this.$td),"AIOSEO","<strong>","</strong>"),learnMoreLink:this.$t.sprintf('<a href="%1$s" target="_blank" rel="noreferrer nofollow">%2$s<span class="link-right-arrow"> →</span></a>',this.$links.getDocUrl("primaryTerm"),this.$t.__("Learn more",this.$td))}}},props:{taxonomy:String},methods:{updateSelectedTerms(){this.selectedTerms=N(this.taxonomy)}},computed:{canShowUpsell(){const{options:e}=this.postEditorStore.currentPost;return!e.primaryTerm.productEducationDismissed&&1<this.selectedTerms.length}},mounted(){this.updateSelectedTerms(),window.aioseoBus.$on("updateSelectedTerms",this.updateSelectedTerms)},beforeUnmount(){window.aioseoBus.$off("updateSelectedTerms",this.updateSelectedTerms)}},q={key:0,class:"aioseo-primary-term-cta"},U=["innerHTML"],V=["innerHTML"];function F(e,t,o,s,r,n){const a=m("svg-circle-information"),i=m("svg-close");return n.canShowUpsell?(w(),h("div",q,[p(a,{width:"15",height:"15"}),u("p",{innerHTML:r.strings.didYouKnow},null,8,U),u("p",{innerHTML:r.strings.learnMoreLink},null,8,V),p(i,{onClick:g(s.postEditorStore.disablePrimaryTermEducation,["stop"])},null,8,["onClick"])])):T("",!0)}const K=_(H,[["render",F]]),O={components:{PrimaryTerm:K},props:{taxonomy:String}},Q={class:"aioseo-app aioseo-primary-term"};function R(e,t,o,s,r,n){const a=m("primary-term");return w(),h("div",Q,[p(a,{taxonomy:o.taxonomy},null,8,["taxonomy"])])}const Y=_(O,[["render",R]]);if(f()&&window.wp){const{createElement:e,Fragment:t}=window.wp.element,{addFilter:o}=window.wp.hooks,{createHigherOrderComponent:s}=window.wp.compose,{subscribe:r}=window.wp.data;o("editor.PostTaxonomyType","aioseo/primary-term",s(n=>a=>{const{slug:i}=a;return M(i)?e(t,{},e(n,a),e("div",{id:`aioseo-primary-term-${i}`},e("div",{className:"aioseo-primary-term-app",taxonomy:i}))):e(n,a)},"withInspectorControls")),r(()=>{window.aioseoBus.$emit("updateSelectedTerms")})}(b()||B())&&(d(),l().forEach(e=>{var s;const t=(s=document.getElementById(`${e.name}div`))==null?void 0:s.querySelector(".inside");if(!t)return;const o=document.createElement("div");o.setAttribute("id",`aioseo-primary-term-${e.name}`),o.setAttribute("class","aioseo-primary-term-app"),o.setAttribute("taxonomy",e.name),t.append(o),function(r){r(`#${e.name}checklist`).on("change",'input[type="checkbox"]',()=>{window.aioseoBus.$emit("updateSelectedTerms")}),r(`#${e.name}checklist`).on("wpListAddEnd",()=>{window.aioseoBus.$emit("updateSelectedTerms")})}(window.jQuery)}));const y=e=>{if(!e)return;const t=e.getAttribute("taxonomy");let o=S({...Y,name:"Standalone/PrimaryTerm"},{taxonomy:t});o=x(o),o=E(o),o=$(o),d(o),o.mount(e)};if(A()&&window.aioseo&&window.aioseo.currentPost&&window.aioseo.currentPost.context==="post"){const e=document.getElementsByClassName("aioseo-primary-term-app");Array.prototype.forEach.call(e,t=>y(t)),P(".aioseo-primary-term-app","aioseoPrimaryTerm"),document.addEventListener("animationstart",function(t){t.animationName==="aioseoPrimaryTerm"&&y(t.target)},{passive:!0})}