angular.module("app").controller("PackageManagerModalController",["$modalScope","overviewMode","mode","package","packageManager","message","core","state","utils",function(e,r,a,t,n,o,i,s,c){e.utils=c,e.isStatic=!1,e.mode=a||"overview",e.overviewMode=r||"upgrades",e.packageManager=n,e.selected=t||null,e.log=!1,e.working=!1,e.core=i,e.search={filter:""},e.packageTypes={dropper:"Dropper",drop:"Drops",integration:"Template Integrationen"},e.select=function(r,a){e.mode=a,e.selected=r},e.setOverviewMode=function(r){e.overviewMode=r,e.search.filter=""},e.toOverview=function(){e.mode="overview",e.selected=null,e.log=!1,e.search.filter=""},e.dropInUse=function(e){for(var r=0;r<i.settings.drops.length;r++){var a=i.settings.drops[r];if(a&&a._internal&&a._internal.dropId===e)return!0}return!1},e.getInstalledIntegrations=function(){var e=[];for(var r in i.packages.installed){var a=i.packages.installed[r];"integration"===a.type&&e.push(a)}return e},e.getStatusClass=function(e){switch(e){case"info":return"info";case"error":return"important";case"success":return"success"}return""},e.getRepoInfo=function(e){return e&&e.repository&&i.packages.repos[e.repository]?i.packages.repos[e.repository].name:"Unbekanntes Repository"},e.getProgressTitle=function(e,r){switch(e){case"install":return"Installiere "+r.meta.name+" "+r.candidate.version;case"upgrade":return"Aktualisiere "+r.meta.name+" auf Version "+r.candidate.version;case"uninstall":return"Entferne "+r.meta.name}},e.takeAction=function(r,a){e.selected=a,e.mode="progress",e.action=r,e.working=!0,$.ajax({type:"POST",dataType:"JSON",url:i.shopURL,data:{kk_dropper_packagemanager_item:a.id,kk_dropper_packagemanager_action:r,kk_dropper_admin_pass:i.adminSecret},success:function(t){e.$apply((function(){e.log=t,e.working=!1,"kk_dropper"==a.id&&200==t.status?setTimeout((function(){alert("Dropper wurde erfolgreich auf Version "+a.candidate.version+" geupdated! Die Seite wird jetzt neu geladen."),window.location.reload()}),500):"upgrade"==r&&i.templates[a.id]&&angular.isArray(i.templates[a.id].adminScripts)&&200==t.status?setTimeout((function(){alert(a.meta.name+" wurde erfolgreich auf Version "+a.candidate.version+" geupdated! Das Dropper Backend wird jetzt neu geladen."),window.location.reload()}),500):s.loadSettings().then((function(){i.fn.reload()}))}))},error:function(r){o.error("Ein Fehler im Packetmanager ist aufgetreten.",r),e.working=!1}})}}]);