define("app/index",["lodash","angular","cjt/util/locale","cjt/core","cjt/io/whm-v1-request","cjt/io/websocket","cjt/util/query","cjt/util/logMetaformat","cjt/util/scrollSelect","cjt/io/whm-v1","cjt/util/parse","cjt/modules","cjt/decorators/growlAPIReporter","uiBootstrap","cjt/services/APICatcher","cjt/directives/formWaiting","cjt/directives/actionButtonDirective"],(function(e,t,n,a,i,o,r,s,l){"use strict";var u=PAGE.plugins;if(!u)throw"plugins";a.config.html5Mode=!1;var m=[[n.maketext("Name"),"label"],[n.maketext("Description"),"description"]],c=[],_={},p=u.map((function(e){for(var t=[],a={metadata:t,label:e.label,logo:e.logo,enabled:!!e.installed_version,to_enable:!!e.installed_version,pkg_name:e.id,minimum_ram:e.minimum_ram,minimum_cpus:e.minimum_cpus,installed_by:e.installed_by,should_hide:!!e.should_hide},i=0;i<m.length;i++){var o=m[i][1],r={label:m[i][0],value:e[o]};t.push(r)}var s=e.version;return e.installed_version&&e.installed_version!==s&&(s+=" ("+n.maketext("Installed: [_1]",e.installed_version)+")"),t.push({label:n.maketext("Version"),value:s}),_[a.pkg_name]=a,a.minimum_ram&&PAGE.total_memory<a.minimum_ram&&(a.alert=n.maketext("This plugin has a recommended minimum of [format_bytes,_1] of RAM, but your server only has [format_bytes,_2]. Your server may experience performance issues while using this plugin.",a.minimum_ram,PAGE.total_memory)),a.minimum_cpus&&PAGE.cpus<a.minimum_cpus&&(a.alert=n.maketext("This plugin has a recommended minimum of [quant,_1,core,cores] but your server only has [quant,_2,core,cores]. Your server may experience performance issues while using this plugin.",a.minimum_cpus,PAGE.cpus)),a.minimum_ram&&PAGE.total_memory<a.minimum_ram&&a.minimum_cpus&&PAGE.cpus<a.minimum_cpus&&(a.alert=n.maketext("This plugin has a recommended minimum of [format_bytes,_1] of RAM and [quant,_2,core,cores] but your server only has [format_bytes,_3] of RAM and [quant,_4,core,cores]. Your server may experience performance issues while using this plugin.",a.minimum_ram,a.minimum_cpus,PAGE.total_memory,PAGE.cpus)),a.should_hide&&a.installed_by&&a.alert&&c.push((function(e){e.pkg_name===a.installed_by&&(e.alert=a.alert)})),a})).filter((function(e){return!e.should_hide}));function d(e){return(new i.Class).initialize(null,"install_rpm_plugin",{name:e})}function f(e){return(new i.Class).initialize(null,"uninstall_rpm_plugin",{name:e})}function g(e,t,a){e.last_status_notice_type=t,e.last_status_message=n.local_datetime(new Date,"time_format_medium")+": "+a}function h(e){delete e.last_status_message,delete e.last_status_notice_type}function v(e){return e.last_status_dismissable="danger"!==e.last_status_notice_type,e.last_status_dismissable}p.forEach((function(e){c.forEach((function(t){t(e)}))}));var b={success:"ok",info:"info",warning:"exclamation",danger:"remove"};function y(e){return b[e.last_status_notice_type]}return function(){return t.module("App",["cjt2.config.whm.configProvider","ui.bootstrap","cjt2.whm","cjt2.decorators.growlAPIReporter"]),require(["cjt/bootstrap","uiBootstrap"],(function(a){var i=t.module("App");i.value("PAGE",PAGE),i.controller("BaseController",["$rootScope","$scope","$q","APICatcher","APIService",function(t,a,i,u,m){/debug=1/.test(location.search)&&(window.SCOPE=a),a.plugins=p,a.total_memory=PAGE.total_memory;var c={};a.any_plugin_in_progress=function(){return!!Object.keys(c).length},a.toggle=function(t){t.to_enable=!t.to_enable;var a=(t.to_enable?d:f)(t.pkg_name);return c[t.pkg_name]=!0,i((function(i,m){u.promise(a).then((function(a){!function(t,a,i,u){var m=e.escape(a.label);t.status?(a.in_progress=!0,a.to_enable?g(a,"info",n.maketext("Installation of “[_1]” is in progress.",m)):g(a,"info",n.maketext("Uninstallation of “[_1]” is in progress.",m)),a.log_entry=t.data.log_entry,function(t,a,i,u){var m=t.log_entry;t.tailing_log=!0;var _,p=o.getUrlBase();p+="/websocket/PluginLog?",p+=r.make_query_string({log_entry:m,pid:a});var d={},f=e.escape(t.label),h=new WebSocket(p);h.onerror=function(a){g(t,"danger",n.maketext("ERROR")+" ("+f+"): "+e.escape(a.data)),u()},h.onmessage=function(e){_||((_=document.getElementById(t.pkg_name+"-log")).value="");var n=l.isAtEnd(_);_.value+=s.parse(e.data,d),n&&l.scrollToEnd(_)},h.onclose=function(a){if(delete t.tailing_log,a.code===o.STATUS.SERVER_ERROR){u();var r=e.escape(a.reason);t.to_enable,g(t,"warning",n.maketext("The log follower for “[_1]” indicated an internal error ([_2]).",f,r))}if(d.CHILD_ERROR&&"?"!==d.CHILD_ERROR){var s=""+d.CHILD_ERROR;"0"===s?(i(),t.in_progress=!1,t.enabled=t.to_enable,delete c[t.pkg_name],t.to_enable?g(t,"success",n.maketext("“[_1]” is now installed.",f)):g(t,"success",n.maketext("“[_1]” is now uninstalled.",f))):(u(),t.to_enable?g(t,"warning",n.maketext("The log transmission for “[_1]” included a failure status ([_2]) for the installation.",f,e.escape(s))):g(t,"warning",n.maketext("The log transmission for “[_1]” included a failure status ([_2]) for the uninstallation.",f,e.escape(s))))}else{u();var l="/var/cpanel/logs/plugin/"+m+"/txt";t.to_enable?g(t,"warning",n.maketext("The log transmission for “[_1]” did not include a final status for the installation. This may indicate a failure. Check “[_2]” for more information.",f,e.escape(l))):g(t,"warning",n.maketext("The log transmission for “[_1]” did not include a final status for the uninstallation. This may indicate a failure. Check “[_2]” for more information.",f,e.escape(l)))}}}(a,t.data.pid,i,u)):a.to_enable?(g(a,"danger",n.maketext("The system failed to start the installation for “[_1]” because of an error: [_2]",m,e.escape(t.error))),u()):(g(a,"danger",n.maketext("The system failed to start the uninstallation for “[_1]” because of an error: [_2]",m,e.escape(t.error))),u())}(a,t,i,m)}),m)}))},a.clear_plugin_message=h,a.plugin_notice_glyphicon=y,a.plugin_notice_is_dismissable=v}]),a()}))}}));