import{m as b,b as _}from"./vuex.esm-bundler.55d3d5b3.js";import{C as $}from"./Index.3662e61b.js";import{C as w}from"./index.fae5bbc8.js";import{G as U,a as A}from"./Row.d42459be.js";import{_ as L,r as l,c as g,a,d as k,w as s,B as W,b as p,f as m,o as r,F as O,G as x,t as n,y as d}from"./_plugin-vue_export-helper.a81c6319.js";import"./default-i18n.0e8bc810.js";import"./_commonjsHelpers.f84db168.js";import"./helpers.51e5fd9c.js";import"./Caret.19bf2275.js";const I={components:{Cta:$,CoreAlert:w,GridColumn:U,GridRow:A},data(){return{loadingUseSnippet:null,failed:!1,activationLoading:!1,strings:{codesnippets:this.$t.__("Code Snippets",this.$td),installSnippet:this.$t.__("Use Snippet",this.$td),editSnippet:this.$t.__("Edit Snippet",this.$td),ctaDescription:this.$t.__("Using WPCode you can install AIOSEO code snippets with 1-click directly from this page or the WPCode library inside the WordPress admin.",this.$td),ctaLearnMoreText:this.$t.__("Learn More about WPCode Snippets",this.$td),noSnippets:this.$t.__("We encountered an error loading the code snippets, please try again later.",this.$td),activateError:this.$t.__("An error occurred while activating the addon. Please upload it manually or contact support for more information.",this.$td),permissionWarning:this.$t.__("You currently don't have permission to activate this addon. Please ask a site administrator to activate first.",this.$td)}}},computed:{...b("wpcode",["snippets","pluginInstalled","pluginActive","pluginNeedsUpdate","ctaUrl"]),showSnippets(){return this.pluginInstalled&&this.pluginActive&&!this.pluginNeedsUpdate},blurClass(){return this.showSnippets?"":"aioseo-blur"},ctaTitle(){if(this.pluginNeedsUpdate)return this.$t.__("Please Update WPCode to load the AIOSEO Snippet Library",this.$td);if(this.pluginInstalled){if(!this.pluginActive)return this.$t.__("Please Activate WPCode to load the AIOSEO Snippet Library",this.$td)}else return this.$t.__("Please Install WPCode to load the AIOSEO Snippet Library",this.$td);return this.$t.__("Please Install WPCode to load the AIOSEO Snippet Library",this.$td)},ctaButtonText(){if(this.pluginNeedsUpdate)return this.$t.__("Update WPCode",this.$td);if(this.pluginInstalled){if(!this.pluginActive)return this.$t.__("Activate WPCode",this.$td)}else return this.$t.__("Install WPCode",this.$td);return this.$t.__("Install WPCode",this.$td)}},methods:{..._(["installPlugins","upgradePlugins"]),..._("wpcode",["loadSnippets"]),processUpdateOrActivate(){this.activateOrUpdate(this.pluginNeedsUpdate)},activateOrUpdate(i=!1){this.failed=!1,this.activationLoading=!0;const u=i?"upgradePlugins":"installPlugins",c=this.$aioseo.plugins.wpcodePro.installed?"wpcodePro":"wpcode";this[u]([{plugin:c,type:"plugin"}]).then(t=>{if(t.body.failed.length){this.activationLoading=!1,this.failed=!0;return}const e=[this.loadSnippets()];Promise.all(e).then(()=>{this.activationLoading=!1})}).catch(t=>{this.activationLoading=!1,this.failed=!0,console.error(`Unable to install ${c}: ${t}`)})},decodeHTMLEntities(i){return this.$tags.decodeHTMLEntities(i)}}},E={class:"aioseo-tools-wpcode"},N={class:"aioseo-wpcode-snippet"},T={class:"wpcode-snippet-body"},B={class:"snippet-title"},M={class:"snippet-description"},D={class:"wpcode-snippet-footer"};function G(i,u,f,c,t,e){const h=l("base-button"),y=l("grid-column"),v=l("grid-row"),C=l("cta"),S=l("core-alert");return r(),g("div",E,[a("div",{class:W(e.blurClass)},[k(v,null,{default:s(()=>[(r(!0),g(O,null,x(i.snippets,(o,P)=>(r(),p(y,{key:P,sm:"12",md:"6",lg:"4"},{default:s(()=>[a("div",N,[a("div",T,[a("div",B,n(o.title),1),a("div",M,n(o.note),1)]),a("div",D,[o.install?(r(),p(h,{key:0,type:"blue",size:"medium",tag:"a",href:e.decodeHTMLEntities(o.install),onClick:V=>t.loadingUseSnippet=o.install,loading:o.install===t.loadingUseSnippet},{default:s(()=>[d(n(o.installed?t.strings.editSnippet:t.strings.installSnippet),1)]),_:2},1032,["href","onClick","loading"])):(r(),p(h,{key:1,type:"gray",size:"medium",disabled:""},{default:s(()=>[d(n(t.strings.installSnippet),1)]),_:1}))])])]),_:2},1024))),128))]),_:1})],2),!e.showSnippets&&i.snippets.length?(r(),p(C,{key:0,"button-text":e.ctaButtonText,"learn-more-link":i.$links.getDocUrl("wpcode"),"cta-button-loading":t.activationLoading,onCtaButtonClick:e.processUpdateOrActivate,"same-tab":"","align-top":"","cta-button-action":""},{"header-text":s(()=>[d(n(e.ctaTitle),1)]),description:s(()=>[d(n(t.strings.ctaDescription),1)]),"learn-more-text":s(()=>[d(n(t.strings.ctaLearnMoreText),1)]),_:1},8,["button-text","learn-more-link","cta-button-loading","onCtaButtonClick"])):m("",!0),e.showSnippets&&i.snippets.length===0?(r(),p(S,{key:1,type:"yellow"},{default:s(()=>[a("div",null,n(t.strings.noSnippets),1)]),_:1})):m("",!0)])}const Q=L(I,[["render",G]]);export{Q as default};
