(()=>{var t,e={7719:(t,e,n)=>{const o=n(4116),s=n(9294);t.exports=Backbone.Collection.extend({model:s,parse:function(t){return _.map(t,(function(t,e){return new s({name:e,tools:new o(t)})}))}})},4116:(t,e,n)=>{t.exports=Backbone.Collection.extend({model:n(6696)})},8728:(t,e,n)=>{"use strict";function o(t){let e;switch(t){case"Activated":e="Get Started";break;case"Installed":e="Activate";break;case"Not installed":e="Install Now";break;default:e="Learn More"}return e}function s(){return"Learn More"}function a(){return"Install Now"}function l(){return"Activate"}function i(){return"Get Started"}function r(t){let e;switch(t){case"Activated":e="tve-action-btn-get-started";break;case"Installed":e="tve-action-btn-activate";break;case"Not installed":e="tve-action-btn-install-now";break;default:e="tve-action-btn-learn-more"}return e}function c(t){let e;switch(t){case"Activated":e="tve-btn-get-started";break;case"Installed":e="tve-btn-action-activate";break;case"Not installed":e="tve-btn-install-now";break;default:e="tve-btn-learn-more"}return e}function d(t){let e=t.get("status"),n=t.get("plugin_slug");const s=function(t,e){let n;return n="Learn More"===t?e.get("landing_url"):e.get("dashboard_uri"),encodeURIComponent(n)}(e,t);return'
"}function u(t,e="_self"){const{target:n}=t||{};let o=n;for(;o;){const{dataset:t}=o;if(t&&t.url){const n=decodeURIComponent(t.url);return void window.open(n,e)}o=o.parentElement}return!1}function h(t){t.hasClass("tve-action-btn-install-now")&&t.removeClass("tve-action-btn-install-now"),t.hasClass("tve-btn-info")&&t.removeClass("tve-btn-info"),t.hasClass("tve-btn-action-installing")||t.addClass("tve-btn-action-installing")}function g(t){t.hasClass("tve-btn-action-installing")&&t.removeClass("tve-btn-action-installing"),t.hasClass("tve-btn-info")||t.addClass("tve-btn-info"),t.hasClass("tve-action-btn-install-now")||t.addClass("tve-action-btn-install-now")}function p(t){t.hasClass("tve-action-btn-install-now")&&t.removeClass("tve-action-btn-install-now"),t.hasClass("tve-btn-action-installing")&&t.removeClass("tve-btn-action-installing"),t.hasClass("tve-btn-action-activating")||t.addClass("tve-btn-action-activating"),t.hasClass("tve-btn-action-activating")||t.addClass("tve-btn-action-activating")}function v(t){t.hasClass("tve-btn-info")&&t.removeClass("tve-btn-info"),t.hasClass("tve-action-btn-activate")&&t.removeClass("tve-action-btn-activate"),t.hasClass("tve-btn-get-started")||t.addClass("tve-btn-get-started"),t.hasClass("tve-action-btn-get-started")||t.addClass("tve-action-btn-get-started")}function f(t){return t.json().then((t=>Promise.reject(new Error(t.message))))}n.r(e),n.d(e,{getActionClass:()=>r,getActivateButtonText:()=>l,getButtonClass:()=>c,getButtonHtml:()=>d,getButtonText:()=>o,getGetStartedButtonText:()=>i,getInstallNowButtonText:()=>a,getLearnMoreButtonText:()=>s,handleError:()=>f,redirectToUri:()=>u,updateButtonClassAfterActivated:()=>v,updateButtonClassAfterInstallation:()=>p,updateButtonClassIfInstallationFailed:()=>g,updateButtonClassWhileInstalling:()=>h})},9294:(t,e,n)=>{const o=n(4116);t.exports=Backbone.Model.extend({defaults:{name:"",tools:new o}})},6696:t=>{t.exports=Backbone.Model.extend({defaults:{name:"",path:"",icon:"",status:"",summary:"",landing_url:""}})},108:t=>{var e;e=jQuery,t.exports=Backbone.View.extend({template:_.template(''),el:".tvd-filter-tools",events:{"change #tools-category-select":"filterTools"},initialize:function(t){this.toolsCategory=JSON.parse(TVD_AM_CONST.tools_category),this.growthToolsView=t.growthToolsView,this.render()},filterTools:function(){this.growthToolsView.filterTools()},render:function(){var t=e(this.template());return t.append(''),_.each(this.toolsCategory,(function(e){t.append('")})),this.$el.html(t),this.$("#tools-category-select").select2({minimumResultsForSearch:1/0}),this}})},8130:t=>{var e;e=jQuery,t.exports=Backbone.View.extend({template:_.template(''),el:".tvd-search-elem",events:{"click .tvd-clear-search-icon":"clearSearch","keyup #tvd-search-growth-tools":"handleSearchKeyPress","input #tvd-search-growth-tools":"toggleClearIcon"},initialize:function(t){this.growthToolsView=t.growthToolsView},searchTools:function(){this.growthToolsView.filterTools()},clearSearch:function(){e("#tvd-search-growth-tools").val(""),this.growthToolsView.filterTools(),e(".tvd-clear-search-icon").hide(),e(".tvd-tools-search-icon").show()},handleSearchKeyPress:function(t){13===t.keyCode&&this.growthToolsView.filterTools()},toggleClearIcon:function(){e("#tvd-search-growth-tools").val().trim().length>0?(e(".tvd-tools-search-icon").hide(),e(".tvd-clear-search-icon").show()):(e(".tvd-clear-search-icon").hide(),e(".tvd-tools-search-icon").show())},render:function(){return this.$el.html(this.template()),this.$el}})}},n={};function o(t){var s=n[t];if(void 0!==s)return s.exports;var a=n[t]={exports:{}};return e[t](a,a.exports,o),a.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(t=jQuery)(document).ready((()=>{const e=o(7719),n=o(8130),s=o(108),{getButtonHtml:a,redirectToUri:l,updateButtonClassWhileInstalling:i,updateButtonClassIfInstallationFailed:r,updateButtonClassAfterActivated:c,updateButtonClassAfterInstallation:d,handleError:u,getGetStartedButtonText:h,getActivateButtonText:g,getInstallNowButtonText:p}=o(8728),v=new e,f=new(Backbone.View.extend({el:".growth-tools-list",events:{"click .tve-action-btn-learn-more":"redirectToUri","click .tve-action-btn-get-started":"redirectToDashboard","click .tve-action-btn-install-now":"initInstallation","click .tve-action-btn-activate":"activatePlugin","click .tool-name":"redirectToUri"},initialize:function(){TVE_Dash.showLoader(!0);const t=this;v.url=TVD_AM_CONST.baseUrl,v.fetch({success:function(e){0===e.length?(t.$el.empty(),t.$el.append('
No tools found
')):(t.categories=e,t.filteredTools=e,t.render())},error:function(t,e){TVE_Dash.err("Error fetching data:",e,3e3,null,"top")},complete:function(){TVE_Dash.hideLoader()}})},filterTools:function(){const e=t("#tools-category-select option:selected").text(),n=encodeURIComponent(e),o=encodeURIComponent(t("#tvd-search-growth-tools").val().trim().toLowerCase());TVE_Dash.showLoader(!0);const s=this;v.url=TVD_AM_CONST.baseUrl+"?category="+n+"&query="+o,v.fetch({success:function(t){0===t.length?(s.$el.empty(),s.$el.append('
No tools found
')):(s.categories=t,s.filteredTools=t,s.render())},error:function(t,e){TVE_Dash.err("Error fetching data:",e,3e3,null,"top")},complete:function(){TVE_Dash.hideLoader()}})},redirectToUri:function(t){l(t,"_blank")},redirectToDashboard:function(t){l(t)},initInstallation:function(e){e.preventDefault();const n=t(e.currentTarget),o=n.data("plugin-slug");if(i(n),n.prop("disabled",!0).text("Installing..."),!o)return TVE_Dash.err("Plugin slug is missing.",3e3,null,"top"),void n.prop("disabled",!1).html(p());const s=TVD_AM_CONST.baseUrl,a={plugin_slug:o,action:"install"},l={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)};let c=this;fetch(s,l).then((t=>t.ok?t.json():u(t))).then((t=>{t&&null!=t&&t.dl?c.installPlugin(e):(TVE_Dash.success(null==t?void 0:t.success,3e3,null,"top"),c.activatePlugin(e))})).catch((t=>{r(n),TVE_Dash.err("Error: "+t.message,3e3,null,"top"),n.prop("disabled",!1).html(p())}))},installPlugin:function(e){const n=t(e.currentTarget),o=n.data("plugin-slug");i(n),n.prop("disabled",!0).text("Installing...");const s=TVD_AM_CONST.baseUrl,a={plugin_slug:o,action:"install"},l={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)};let c=this;fetch(s,l).then((t=>t.ok?t.json():u(t))).then((t=>{TVE_Dash.success(null==t?void 0:t.success,3e3,null,"top"),d(n),n.html(g()),c.activatePlugin(e)})).catch((t=>{r(n),TVE_Dash.err("Error: "+t.message,3e3,null,"top"),n.prop("disabled",!1).html(p())}))},activatePlugin:function(e){e.preventDefault();const n=t(e.currentTarget),o=n.data("plugin-slug");if(n.prop("disabled",!0).text("Activating"),!o)return TVE_Dash.err("Plugin slug is missing.",3e3,null,"top"),void n.prop("disabled",!1).html(g());const s=TVD_AM_CONST.baseUrl,a={plugin_slug:o,action:"activate"},l={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)};fetch(s,l).then((t=>t.ok?t.json():u(t))).then((t=>{TVE_Dash.success(null==t?void 0:t.success,3e3,null,"top"),c(n),n.prop("disabled",!1).html(h())})).catch((t=>{TVE_Dash.err("Error: "+t.message,3e3,null,"top"),n.prop("disabled",!1).html(g())}))},render:function(){if(this.$el.empty(),!this.filteredTools||0===this.filteredTools.length)return this;const e=this;return this.filteredTools.each((function(n){const o=t('
'),s=t(''+n.get("name")+"");o.append(s);const l=n.get("tools");if(l&&l.length>0){const e=t('
');l.forEach((function(n){const o=t('
'),s=t(''),l=t('
'+n.get("name")+'
'+n.get("summary")+"
"),i=t(a(n));o.append(s,l,i),e.append(o)})),o.append(e)}e.$el.append(o)})),this}})),b=new s({growthToolsView:f}),m=new n({growthToolsView:f});b.render(),m.render(),f.render()}))})();