(()=>{function e(i,e,t,s,o,n,r,a,c,u,l,d,g,f,m,h,y){var p,v,w;function U(e){v=e,i.user=_.cloneDeep(e),i.password.showPassword=!e.id,p=e.email}function S(e){return e?x(i.user):o.resolve()}function x(n){var e,t,i=!1;if(_.isEqual(v,n))P();else try{((e=n).language?(t=e.language.code,_.unset(e,"language"),d.set("language",t).then(function(){return l.switchToLanguage(t)}).catch(b)):o.when()).then(function(){var e,t;return h.isActivatedFor("units-conversion")?(_.get(n,"measurementUnit.value")!==w&&(i=!0),e=n,t=_.get(e,"measurementUnit.value"),_.unset(e,"measurementUnit"),d.set("unit",t)):o.when()}).then(function(){return r.saveCurrent(n)}).then(P).then(function(){i&&m({title:u("Reload application"),body:u("You are about to reload application in order to correctly apply measurement units setting changes. Do you want to proceed?"),labels:{ok:u("Reload")}}).then(function(){s.location.reload()})})}catch(e){a.danger(e.message)}}function P(){a.success(u("User saved.")),e.close(),t.reload()}function b(){l.switchToDefaultLanguage()}i.userSettingsBlocks=g.list(),i.checkPassword=function(e){i.password.showPassword||e.email!==p?c.askForPassword().then(S):x(e)},i.dismiss=function(){b(),e.dismiss()},i.forms={},i.password={},i.updateRoutesVisibilitySettings=function(e){var t=i.user,n={};n[e.externalServiceName]={visibility:e.visibility},t.customProperties=_.merge({},t.customProperties,n)},i.disconnectRoutesExportingService=function(e){return f.disconnectRoutesExportingService(e).then(function(){_.unset(i.user.customProperties,e),a.warning(y.getString("Disconnected from {{externalServiceName}}. Log into your account at {{externalServiceName}} and finalize deregistration.",{externalServiceName:_.capitalize(e)}))})},r.detailCurrent().then(n.getResData).then(U).then(function(){d.get("unit",i.user).then(function(e){w=e})})}e.$inject=["$scope","$uibModalInstance","$route","$window","$q","c8yBase","c8yUser","c8yAlert","c8yUserUtil","gettext","c8yLocales","c8yUserPreferences","c8yUserSettingsBlocks","c8yEditUser","c8yModal","c8yBeta","gettextCatalog"],angular.module("c8y.ui").controller("EditUserCtrl",e)})();