import{_ as m,w as e,c as p}from"./js/_plugin-vue_export-helper.BLXtEB-G.js";import{l as k}from"./js/index.DQR9DFri.js";import{l as f}from"./js/index.CdwEuUIl.js";import{l as _}from"./js/index.3BJ3ZnWB.js";import{f as h,b as L,u as S,l as g}from"./js/links.C572zDFG.js";import{e as w}from"./js/elemLoaded.COgXIo-H.js";import{a as A}from"./js/addons.tTxptju5.js";import{u as y}from"./js/url.tCcrX6X6.js";import{S as v}from"./js/Information.JAmX9TGg.js";import{S as C}from"./js/Caret.CGwYaMo_.js";import{v as a,o as F,c as x,B as r,a as E,b as V}from"./js/runtime-core.esm-bundler.DMBo7TXk.js";import"./js/translations.Buvln_cw.js";import"./js/default-i18n.Bd0Z306Z.js";import"./js/constants.B6ynd7gz.js";import"./js/helpers.D5tYIqKS.js";import"./js/upperFirst.BGtMw2rr.js";import"./js/_stringToArray.DnK4tKcY.js";import"./js/toString.CkyAieyd.js";const P={setup(){return{licenseStore:h(),postEditorStore:L(),rootStore:S()}},components:{SvgCircleInformation:v,SvgClose:C},data(){return{linkFormatValue:{},disabled:!1,url:null,strings:{upsell:this.$t.sprintf(this.$t.__("Did you know you can automatically add internal links using Link Assistant? %1$s",this.$td),this.$links.getPlainLink(this.$constants.GLOBAL_STRINGS.learnMore,this.rootStore.aioseo.urls.aio.linkAssistant,!0))}}},computed:{canShowUpsell(){const t=A.getAddon("aioseo-link-assistant"),{options:o}=this.postEditorStore.currentPost,i=o.linkFormat.internalLinkCount,n=o.linkFormat.linkAssistantDismissed;return(this.licenseStore.isUnlicensed||!t||!t.isActive||t.requiresUpgrade)&&2<i&&!n&&!this.disabled&&this.linkFormatValue.url&&this.isInternalLink(this.linkFormatValue.url)}},methods:{async linkAdded(t){var s;await this.$nextTick();const{options:o}=this.postEditorStore.currentPost,i=o.linkFormat.internalLinkCount,n=o.linkFormat.linkAssistantDismissed;2<i||n||this.isInternalLink(t.url||((s=t.suggestion)==null?void 0:s.url)||null)&&this.postEditorStore.incrementInternalLinkCount()},async setLinkFormatValue(){await this.$nextTick();const t=document.querySelector("#aioseo-link-assistant-education input");!this.linkFormatValue.url&&(t!=null&&t.value)&&(this.linkFormatValue=JSON.parse(t.value))},isInternalLink(t){const o=y.parse(t,!1,!0);return t.indexOf("//")===-1&&t.indexOf("/")===0?!0:t.indexOf("#")===0?!1:o.host?o.host===this.rootStore.aioseo.urls.domain:!0}},created(){this.setLinkFormatValue();const{addAction:t,hasAction:o}=window.wp.hooks;o("aioseo-link-format-link-added","aioseo")||t("aioseo-link-format-link-added","aioseo",this.linkAdded)}},D={key:0,class:"aioseo-link-assistant-did-you-know"},I=["innerHTML"];function b(t,o,i,n,s,u){const c=a("svg-circle-information"),d=a("svg-close");return u.canShowUpsell?(F(),x("div",D,[r(c),E("span",{onClick:o[0]||(o[0]=e(N=>s.disabled=!0,["stop"])),innerHTML:s.strings.upsell},null,8,I),r(d,{onClick:e(n.postEditorStore.disableLinkAssistantEducation,["stop"])},null,8,["onClick"])])):V("",!0)}const B=m(P,[["render",b]]),l=()=>{let t=p({...B,name:"Standalone/LinkFormat"});t=k(t),t=f(t),t=_(t),g(t),t.mount("#aioseo-link-assistant-education-mount")};window.aioseo&&window.aioseo.currentPost&&window.aioseo.currentPost.context==="post"&&(document.getElementById("aioseo-link-assistant-education")?l():(w("#aioseo-link-assistant-education","aioseoLaDidYouKnow"),document.addEventListener("animationstart",function(o){o.animationName==="aioseoLaDidYouKnow"&&l()},{passive:!0})));
