(function(){"use strict";angular.module("SOGo.Common",["ngAnimate","ngMaterial","mdColors"]).value("sgSettings",{isPopup:document.body.classList.contains("popup"),baseURL:function(){return ApplicationBaseURL||null},activeUser:function(param){var settings={login:UserLogin||null,identification:UserIdentification||null,email:UserEmail||null,language:UserLanguage||null,folderURL:UserFolderURL||null,isSuperUser:IsSuperUser||null,path:{calendar:UserCalendarPath||null,contacts:UserContactsPath||null,mail:UserMailPath||null,preferences:UserPreferencesPath||null,administration:IsSuperUser?UserAdministrationPath:null,logoff:UserLogoffPath||null}};if(param)return settings[param];else return settings}}).constant("sgColors",{selection:["#FFFFFF","#330033","#C0C0C0","#999999","#666666","#333333","#000000","#FFCCCC","#FF6666","#FF0000","#CC0000","#990000","#660000","#330000","#FFCC99","#FF9966","#FF9900","#FF6600","#CC6600","#993300","#663300","#FFFF99","#FFFF66","#FFCC66","#FFCC33","#CC9933","#996633","#663333","#FFFFCC","#FFFF33","#FFFF00","#FFCC00","#999900","#666600","#333300","#CCCCCC","#66FF99","#33FF33","#33CC00","#009900","#006600","#003300","#99FFFF","#33FFFF","#66CCCC","#00CCCC","#339999","#336666","#003333","#CCFFFF","#66FFFF","#33CCFF","#3366FF","#3333FF","#000099","#000066","#CCCCFF","#9999FF","#6666CC","#6633FF","#6600CC","#333399","#330099","#FFCCFF","#FF99FF","#CC66CC","#CC33CC","#993399","#663366","#99FF99"]}).constant("sgConstant",{xs:"(max-width: 599px)","gt-xs":"(min-width: 600px)",sm:"(min-width: 600px) and (max-width: 959px)","gt-sm":"(min-width: 960px)",md:"(min-width: 960px) and (max-width: 1279px)","gt-md":"(min-width: 1280px)",lg:"(min-width: 1280px) and (max-width: 1919px)","gt-lg":"(min-width: 1920px)",xl:"(min-width: 1920px)"}).config(configure).factory("AuthInterceptor",AuthInterceptor).factory("ErrorInterceptor",ErrorInterceptor);configure.$inject=["$logProvider","$compileProvider","$httpProvider","$mdThemingProvider"];function configure($logProvider,$compileProvider,$httpProvider,$mdThemingProvider){$mdThemingProvider.definePalette("sogo-green",{50:"eaf5e9",100:"cbe5c8",200:"aad6a5",300:"88c781",400:"66b86a",500:"56b04c",600:"4da143",700:"388e3c",800:"367d2e",900:"225e1b",A100:"ffffff",A200:"69f0ae",A400:"00e676",A700:"00c853",contrastDefaultColor:"dark",contrastLightColors:["300","400","500","600","700","800","900"]});$mdThemingProvider.definePalette("sogo-blue",{50:"f0faf9",100:"e1f5f3",200:"ceebe8",300:"bfe0dd",400:"b2d6d3",500:"a1ccc8",600:"8ebfbb",700:"7db3b0",800:"639997",900:"4d8080",A100:"d4f7fa",A200:"c3f5fa",A400:"53e3f0",A700:"00b0c0",contrastDefaultColor:"light",contrastDarkColors:["50","100","200"]});$mdThemingProvider.definePalette("sogo-paper",{50:"fcf7f8",100:"f7f1dc",200:"ede5ca",300:"e6d8ba",400:"e2d2a3",500:"d6c48d",600:"baa870",700:"857545",800:"524517",900:"433809",1000:"000000",A100:"ffffff",A200:"eeeeee",A400:"bdbdbd",A700:"616161",contrastDefaultColor:"dark",contrastLightColors:["800","900"]});$mdThemingProvider.theme("default").primaryPalette("sogo-blue",{"default":"900","hue-1":"400","hue-2":"800","hue-3":"A700"}).accentPalette("sogo-green",{"default":"500","hue-1":"A100","hue-2":"300","hue-3":"A700"}).backgroundPalette("grey",{"default":"A100","hue-1":"200","hue-2":"300","hue-3":"500"});if(!DebugEnabled){$logProvider.debugEnabled(false);$compileProvider.debugInfoEnabled(false)}$httpProvider.interceptors.push("AuthInterceptor");$httpProvider.interceptors.push("ErrorInterceptor")}AuthInterceptor.$inject=["$window","$q"];function AuthInterceptor($window,$q){return{response:function(response){if(/^application\/json/.test(response.config.headers.Accept)&&/^/.test(response.data)){$window.location.reload(true);return $q.reject()}return response}}}ErrorInterceptor.$inject=["$rootScope","$q"];function ErrorInterceptor($rootScope,$q){return{responseError:function(rejection){$rootScope.$broadcast("http:Error",rejection);return $q.reject(rejection)}}}})();(function(){"use strict";var _$mdThemingProvider;angular.module("mdColors",["ngMaterial"]).config(configure).run(runBlock);configure.$inject=["$mdThemingProvider"];function configure($mdThemingProvider){_$mdThemingProvider=$mdThemingProvider}runBlock.$inject=["$interpolate","$document","$log"];function runBlock($interpolate,$document,$log){function buildCssSelectors(selectors){var result=selectors.join("");return result}var fgDefault=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-fg"])+" { color:{{value}};}"),bgDefault=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-bg"])+" { background-color:{{value}};}"),bdrDefault=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-bdr"])+" { border-color:{{value}};}"),fgDefaultHue=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-{{hue}}",".md-fg"])+" { color:{{value}};}"),bgDefaultHue=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-{{hue}}",".md-bg"])+" { background-color:{{value}};}"),fgColor=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-{{palette}}",".md-fg"])+" { color:{{value}};}"),bgColor=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-{{palette}}",".md-bg"])+" { background-color:{{value}}; color:{{contrast}}; }"),bdrColor=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-{{palette}}",".md-bdr"])+" { border-color:{{value}};}"),fgHue=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-{{palette}}.md-{{hue}}",".md-fg"])+" { color:{{value}};}"),bgHue=$interpolate(buildCssSelectors([".md-{{theme}}-theme",".md-{{palette}}.md-{{hue}}",".md-bg"])+" { background-color:{{value}};}"),customSheet=getStyleSheet(),index=0;while(customSheet.cssRules.length>0){customSheet.deleteRule(0)}angular.forEach(_$mdThemingProvider._THEMES,function(theme,themeName){addRule(fgDefault,bgDefault,themeName,"primary",_$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues.default]);addRule(fgDefaultHue,bgDefaultHue,themeName,"primary",_$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues["hue-2"]],"hue-2");addRule(fgDefaultHue,bgDefaultHue,themeName,"primary",_$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues["hue-3"]],"hue-3");addRule(fgDefaultHue,bgDefaultHue,themeName,"primary",_$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues["hue-1"]],"hue-1");addBorderRule(bdrDefault,themeName,"primary",_$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues.default]);angular.forEach(theme.colors,function(color,paletteName){addRule(fgColor,bgColor,themeName,paletteName,_$mdThemingProvider._PALETTES[color.name][color.hues.default]);addBorderRule(bdrColor,themeName,paletteName,_$mdThemingProvider._PALETTES[color.name][color.hues.default]);addRule(fgHue,bgHue,themeName,paletteName,_$mdThemingProvider._PALETTES[color.name][color.hues["hue-2"]],"hue-2");addRule(fgHue,bgHue,themeName,paletteName,_$mdThemingProvider._PALETTES[color.name][color.hues["hue-3"]],"hue-3");addRule(fgHue,bgHue,themeName,paletteName,_$mdThemingProvider._PALETTES[color.name][color.hues["hue-1"]],"hue-1")})});function addRule(fgInterpolate,bgInterpolate,themeName,paletteName,colorArray,hueName){if(!colorArray)return;var colorValue="rgb("+colorArray.value[0]+","+colorArray.value[1]+","+colorArray.value[2]+")",colorContrast="rgb("+colorArray.contrast[0]+","+colorArray.contrast[1]+","+colorArray.contrast[2]+")",context={theme:themeName,palette:paletteName,value:colorValue,contrast:colorContrast,hue:hueName};customSheet.insertRule(fgInterpolate(context),index);index+=1;customSheet.insertRule(bgInterpolate(context),index);index+=1}function addBorderRule(bdrInterpolate,themeName,paletteName,colorArray,hueName){if(!colorArray)return;var colorValue="rgb("+colorArray.value[0]+","+colorArray.value[1]+","+colorArray.value[2]+")";customSheet.insertRule(bdrInterpolate({theme:themeName,palette:paletteName,value:colorValue,hue:hueName}),index);index+=1}function getStyleSheet(){var style=$document[0].head.querySelector('style[title="Dynamic-Generated-by-mdColors"]');if(style===null){style=$document[0].createElement("style");style.title="Dynamic-Generated-by-mdColors";style.appendChild($document[0].createTextNode(""));$document[0].head.appendChild(style)}return style.sheet}}})();(function(){"use strict";decodeUri.$inject=["$window"];function decodeUri($window){return $window.decodeURIComponent}angular.module("SOGo.Common").filter("decodeUri",decodeUri)})();(function(){"use strict";encodeUri.$inject=["$window"];function encodeUri($window){return $window.encodeURIComponent}angular.module("SOGo.Common").filter("encodeUri",encodeUri)})();(function(){"use strict";ensureTarget.$inject=["$sce"];function ensureTarget($sce){return function(element){var tree=angular.element("
"+element+"
");tree.find("a").attr("target","_blank");return $sce.trustAs("html",tree.html())}}angular.module("SOGo.Common").filter("ensureTarget",ensureTarget)})();(function(){"use strict";function loc(){return l}angular.module("SOGo.Common").filter("loc",loc)})();(function(){"use strict";function range(){return function(n){var res=[];for(var i=0;i",' error_outline'," "+l(message)+"",""].join(""),hideDelay:5e3,position:"top right"})}$rootScope.$on("http:Error",onHttpError);Alarm.getAlarms()}angular.module("SOGo.Common").controller("navController",navController)})();(function(){"use strict";function Acl(folderId){this.folderId=folderId}Acl.factory=["$q","$timeout","sgSettings","Resource","User",function($q,$timeout,Settings,Resource,User){angular.extend(Acl,{$q:$q,$timeout:$timeout,$$resource:new Resource(Settings.activeUser("folderURL"),Settings.activeUser()),$User:User});return Acl}];angular.module("SOGo.Common").factory("Acl",Acl.factory);Acl.prototype.$users=function(owner){var _this=this,deferred=Acl.$q.defer(),user;if(this.users){deferred.resolve(this.users)}else{var acls;if(angular.isDefined(owner))acls=Acl.$$resource.userResource(owner).fetch(this.folderId,"acls");else acls=Acl.$$resource.fetch(this.folderId,"acls");return acls.then(function(response){_this.users=[];angular.forEach(response.users,function(data){user=new Acl.$User(data);user.canSubscribeUser=user.isSubscribed;user.wasSubscribed=user.isSubscribed;user.$rights=angular.bind(user,user.$acl,_this.folderId,owner);_this.users.push(user)});deferred.resolve(_this.users);return _this.users})}return deferred.promise};Acl.prototype.$addUser=function(user,owner){var _this=this,deferred=Acl.$q.defer(),param={uid:user.uid};if(!user.uid||_.indexOf(_.pluck(this.users,"uid"),user.uid)>-1){deferred.resolve()}else{var acls;if(angular.isDefined(owner))acls=Acl.$$resource.userResource(owner).fetch(this.folderId,"addUserInAcls",param);else acls=Acl.$$resource.fetch(this.folderId,"addUserInAcls",param);acls.then(function(){user.wasSubscribed=false;user.userClass=user.isGroup?"normal-group":"normal-user";user.$rights=angular.bind(user,user.$acl,_this.folderId);_this.users.push(user);deferred.resolve(user)},function(data,status){deferred.reject(l("An error occured please try again."))})}return deferred.promise};Acl.prototype.$removeUser=function(uid){var _this=this,param={uid:uid};return Acl.$$resource.fetch(this.folderId,"removeUserFromAcls",param).then(function(){var i=_.indexOf(_.pluck(_this.users,"uid"),uid);if(i>=0){_this.users.splice(i,1)}})};Acl.prototype.$resetUsersRights=function(){angular.forEach(this.users,function(user){user.$resetRights()})};Acl.prototype.$saveUsersRights=function(owner){var _this=this,deferredSave=Acl.$q.defer(),deferredSubscribe=Acl.$q.defer(),param={action:"saveUserRights"},users=[];angular.forEach(this.users,function(user){if(user.$rightsAreDirty()){users.push(user.$omit())}});if(users.length){var acls;if(angular.isDefined(owner))acls=Acl.$$resource.userResource(owner).save(this.folderId,users,param);else acls=Acl.$$resource.save(this.folderId,users,param);acls.then(function(){angular.forEach(_this.users,function(user){if(user.$rightsAreDirty()){user.$shadowRights=angular.copy(user.rights)}});deferredSave.resolve()},deferredSave.reject)}else{deferredSave.resolve()}users=[];angular.forEach(this.users,function(user){if(!user.wasSubscribed&&user.isSubscribed){users.push(user.uid)}});if(users.length){param={uids:users.join(",")};Acl.$$resource.fetch(this.folderId,"subscribeUsers",param).then(function(){angular.forEach(_this.users,function(user){user.wasSubscribed=user.isSubscribed});deferredSubscribe.resolve()},deferredSubscribe.reject)}else{deferredSubscribe.resolve()}return Acl.$q.all([deferredSave.promise,deferredSubscribe.promise])}})();(function(){"use strict";function Alarm(){this.currentAlarm=null}Alarm.getAlarms=function(){var _this=this;var now=new Date;var browserTime=Math.floor(now.getTime()/1e3);this.$$resource.fetch("","alarmslist?browserTime="+browserTime).then(function(data){var alarms=data.alarms.sort(function reverseSortByAlarmTime(a,b){var x=parseInt(a[2]);var y=parseInt(b[2]);return y-x});if(alarms.length>0){var next=alarms.pop();var now=new Date;var utc=Math.floor(now.getTime()/1e3);var url=next[0]+"/"+next[1];var alarmTime=parseInt(next[2]);var delay=alarmTime;if(alarmTime>0)delay-=utc;var d=new Date(alarmTime*1e3);var f=angular.bind(_this,Alarm.showAlarm,url);if(_this.currentAlarm)_this.$timeout.cancel(_this.currentAlarm);_this.currentAlarm=_this.$timeout(f,delay*1e3)}})};Alarm.showAlarm=function(url){var _this=this;this.$$resource.fetch(url,"?resetAlarm=yes").then(function(data){_this.$toast.show({position:"top right",hideDelay:0,template:[""," ",' ",' '," ",l("5 minutes")," "," ",l("10 minutes")," "," ",l("15 minutes")," "," ",l("30 minutes")," "," ",l("45 minutes")," "," ",l("1 hour")," "," ",l("1 day")," "," "," ",' ',l("Cancel")," ",' ',l("Ok")," ",""].join(""),locals:{url:url},controller:AlarmController});AlarmController.$inject=["scope","$mdToast","url"];function AlarmController(scope,$mdToast,url){scope.reminder="10";scope.cancel=function(){$mdToast.hide()};scope.ok=function(){_this.$$resource.fetch(url,"view?snoozeAlarm="+scope.reminder);$mdToast.hide()}}})};AlarmService.$inject=["$timeout","sgSettings","Resource","$mdToast"];function AlarmService($timeout,Settings,Resource,$mdToast){angular.extend(Alarm,{$timeout:$timeout,$$resource:new Resource(Settings.activeUser("folderURL")+"Calendar",Settings.activeUser()),$toast:$mdToast});return Alarm}angular.module("SOGo.Common").factory("Alarm",AlarmService)})();(function(){"use strict";angular.module("SOGo.Authentication",[]).constant("passwordPolicyConfig",{PolicyPasswordChangeUnsupported:-3,PolicyPasswordSystemUnknown:-2,PolicyPasswordUnknown:-1,PolicyPasswordExpired:0,PolicyAccountLocked:1,PolicyChangeAfterReset:2,PolicyPasswordModNotAllowed:3,PolicyMustSupplyOldPassword:4,PolicyInsufficientPasswordQuality:5,PolicyPasswordTooShort:6,PolicyPasswordTooYoung:7,PolicyPasswordInHistory:8,PolicyNoError:65535}).provider("Authentication",Authentication);function Authentication(){function readCookie(name){var foundCookie,prefix,pairs,i,currentPair,start;foundCookie=null;prefix=name+"=";pairs=document.cookie.split(";");for(i=0;!foundCookie&&i0)currentPair=currentPair.substr(start);if(currentPair.indexOf(prefix)===0)foundCookie=currentPair.substr(prefix.length)}return foundCookie}function readLoginCookie(){var loginValues=null,cookie=readCookie("0xHIGHFLYxSOGo"),value;if(cookie&&cookie.length>8){value=decodeURIComponent(cookie.substr(8));loginValues=value.base64decode().split(":")}return loginValues}function redirectUrl(username,domain){var userName,address,baseAddress,altBaseAddress,parts,hostpart,protocol,newAddress;userName=username;if(domain)userName+="@"+domain.value;address=""+window.location.href;baseAddress=ApplicationBaseURL+"/"+encodeURIComponent(userName);if(baseAddress[0]=="/"){parts=address.split("/");hostpart=parts[2];protocol=parts[0];baseAddress=protocol+"//"+hostpart+baseAddress}parts=baseAddress.split("/");parts.splice(0,3);altBaseAddress=parts.join("/");if((address.startsWith(baseAddress)||address.startsWith(altBaseAddress))&&!address.endsWith("/logoff")){newAddress=address}else{newAddress=baseAddress}return newAddress}this.$get=getService;getService.$inject=["$q","$http","passwordPolicyConfig"];function getService($q,$http,passwordPolicyConfig){var _this=this,service;service={login:function(data){var d=$q.defer(),username=data.username,password=data.password,domain=data.domain,language,rememberLogin=data.rememberLogin?1:0;if(data.loginSuffix&&!username.endsWith(data.loginSuffix)){username+=loginSuffix;domain=false}if(data.language&&data.language!="WONoSelectionString"){language=data.language}$http({method:"POST",url:"/SOGo/connect",data:{userName:username,password:password,domain:domain,language:language,rememberLogin:rememberLogin}}).success(function(data,status){var loginCookie=readLoginCookie();if(!loginCookie){d.reject(l("cookiesNotEnabled"))}else{if(typeof data.expire!="undefined"&&typeof data.grace!="undefined"){if(data.expire<0&&data.grace>0){d.reject({grace:data.grace})}else if(data.expire>0&&data.grace==-1){d.reject({expire:data.expire})}else{d.resolve(redirectUrl(username,domain))}}else{d.resolve(redirectUrl(username,domain))}}}).error(function(data,status){var msg,perr;if(data&&data.LDAPPasswordPolicyError){perr=data.LDAPPasswordPolicyError;if(perr==passwordPolicyConfig.PolicyNoError){msg=l("Wrong username or password.")}else if(perr==passwordPolicyConfig.PolicyAccountLocked){msg=l("Your account was locked due to too many failed attempts.")}else{msg=l("Login failed due to unhandled error case: ")+perr}}else{msg=l("Unhandled error response")}d.reject({error:msg})});return d.promise},changePassword:function(newPassword){var d=$q.defer(),loginCookie=_this.readLoginCookie();$http({method:"POST",url:"/SOGo/so/changePassword",data:{userName:loginCookie[0],password:loginCookie[1],newPassword:newPassword}}).success(function(data,status){d.resolve()}).error(function(data,status){var error,perr=data.LDAPPasswordPolicyError;if(!perr){perr=passwordPolicyConfig.PolicyPasswordSystemUnknown;error=_("Unhandled error response")}else if(perr==passwordPolicyConfig.PolicyNoError){error=l("Password change failed")}else if(perr==passwordPolicyConfig.PolicyPasswordModNotAllowed){error=l("Password change failed - Permission denied")}else if(perr==passwordPolicyConfig.PolicyInsufficientPasswordQuality){error=l("Password change failed - Insufficient password quality")}else if(perr==passwordPolicyConfig.PolicyPasswordTooShort){error=l("Password change failed - Password is too short")}else if(perr==passwordPolicyConfig.PolicyPasswordTooYoung){error=l("Password change failed - Password is too young")}else if(perr==passwordPolicyConfig.PolicyPasswordInHistory){error=l("Password change failed - Password is in history")}else{error=l("Unhandled policy error: %{0}").formatted(perr);perr=passwordPolicyConfig.PolicyPasswordUnknown}d.reject(error)});return d.promise}};return service}}})();(function(){"use strict";function Dialog(){}Dialog.alert=function(title,content){var alert=this.$modal.alert().title(title).textContent(content).ok(l("OK"));this.$modal.show(alert)};Dialog.confirm=function(title,content,options){var confirm=this.$modal.confirm().title(title).textContent(content).ok(options&&options.ok?options.ok:l("OK")).cancel(options&&options.cancel?options.cancel:l("Cancel"));return this.$modal.show(confirm)};Dialog.prompt=function(title,label,options){var o=options||{},d=this.$q.defer();this.$modal.show({parent:angular.element(document.body),clickOutsideToClose:true,escapeToClose:true,template:['',' ',' '," "," ",' '," "," "," ",' '," "+l("Cancel")," ",' '," "+l("OK")," "," ",""].join(""),controller:PromptDialogController});PromptDialogController.$inject=["scope","$mdDialog"];function PromptDialogController(scope,$mdDialog){scope.title=title;scope.name="";scope.cancel=function(){d.reject();$mdDialog.hide()};scope.ok=function(){d.resolve(scope.name);$mdDialog.hide()}}return d.promise};DialogService.$inject=["$q","$mdDialog"];function DialogService($q,$mdDialog){angular.extend(Dialog,{$q:$q,$modal:$mdDialog});return Dialog}angular.module("SOGo.Common").factory("Dialog",DialogService)})();(function(){"use strict";function Gravatar(){return function(email,size,alternate_avatar){var x,y,hash,s=size;if(!email){return""}x=email.indexOf("<");if(x>=0){y=email.indexOf(">",x);if(y>x)email=email.substring(x+1,y)}if(!size){s=48}hash=email.md5();if(alternate_avatar=="none")alternate_avatar="404";return"https://www.gravatar.com/avatar/"+hash+"?s="+s+"&d="+alternate_avatar}}angular.module("SOGo.Common").factory("Gravatar",Gravatar)})();(function(){"use strict";function Resource($http,$q,path,activeUser,options){angular.extend(this,{_http:$http,_q:$q,_path:path,_activeUser:activeUser});angular.extend(this,options);this._path=this._path.replace(/\/$/,"")}Resource.$factory=["$http","$q",function($http,$q){return function(path,activeUser,options){return new Resource($http,$q,path,activeUser,options)}}];angular.module("SOGo.Common").factory("Resource",Resource.$factory);Resource.prototype.userResource=function(uid){var path=_.compact(this._activeUser.folderURL.split("/"));path.splice(path.length-1,1,escape(uid));return new Resource(this._http,this._q,"/"+path.join("/"),this._activeUser)};Resource.prototype.fetch=function(folderId,action,params){var deferred=this._q.defer(),path=[this._path];if(folderId)path.push(folderId.split("/"));if(action)path.push(action);path=_.compact(_.flatten(path)).join("/");this._http({method:"GET",url:path,params:params}).success(deferred.resolve).error(function(data,status){if(status==404)return deferred.reject()});return deferred.promise};Resource.prototype.newguid=function(folderId){var deferred=this._q.defer(),path=this._path+"/"+folderId+"/newguid";this._http.get(path).success(deferred.resolve).error(deferred.reject);return deferred.promise};Resource.prototype.create=function(action,name){var deferred=this._q.defer(),path=this._path+"/"+action;this._http.post(path,{name:name}).success(deferred.resolve).error(deferred.reject);return deferred.promise};Resource.prototype.post=function(id,action,data){var deferred=this._q.defer(),path=[this._path];if(id)path.push(id);if(action)path.push(action);path=_.compact(_.flatten(path)).join("/");this._http.post(path,data).success(deferred.resolve).error(deferred.reject);return deferred.promise};Resource.prototype.save=function(id,newValue,options){var deferred=this._q.defer(),action=options&&options.action?options.action:"save";return this.post(id,action,newValue)};Resource.prototype.remove=function(uid){var deferred=this._q.defer(),path=this._path+"/"+uid+"/delete";this._http.get(path).success(deferred.resolve).error(deferred.reject);return deferred.promise}})();(function(){"use strict";function User(userData){if(userData){this.init(userData)}}User.factory=["$q","$log","sgSettings","Resource","Gravatar",function($q,$log,Settings,Resource,Gravatar){angular.extend(User,{$q:$q,$log:$log,$$resource:new Resource(Settings.activeUser("folderURL"),Settings.activeUser()),$gravatar:Gravatar,$query:"",$users:[]});return User}];angular.module("SOGo.Common").factory("User",User.factory);User.$filter=function(search,excludedUsers,options){var _this=this,param={search:search};if(!options||!options.dry){if(!search){User.$users.splice(0,User.$users.length);return User.$q.when(User.$users)}if(User.$query==search){return User.$q.when(User.$users)}User.$query=search}return User.$$resource.fetch(null,"usersSearch",param).then(function(response){var results,index,user,users,compareUids=function(data){return this.uid==data.uid};if(options&&options.dry)users=[];else users=User.$users;if(excludedUsers){results=_.filter(response.users,function(user){return!_.find(excludedUsers,compareUids,user)})}else{results=response.users}for(index=users.length-1;index>=0;index--){user=users[index];if(!_.find(results,compareUids,user)){users.splice(index,1)}}_.each(results,function(data,index){if(_.isUndefined(_.find(users,compareUids,data))){var user=new User(data);users.splice(index,0,user)}});User.$log.debug(users);return users})};User.prototype.init=function(data){angular.extend(this,data);if(!this.$$shortFormat)this.$$shortFormat=this.$shortFormat();if(!this.$$image)this.$$image=this.image||User.$gravatar(this.c_email,32,User.$alternateAvatar);this.empty=" "};User.prototype.$shortFormat=function(options){var fullname=this.cn||this.c_email;var email=this.c_email;var no_email=options&&options.email===false;if(!no_email&&email&&fullname!=email){fullname+=" <"+email+">"}return fullname};User.prototype.$acl=function(folderId,owner){var _this=this,deferred=User.$q.defer(),param={uid:this.uid};if(this.$shadowRights){deferred.resolve(this.rights)}else{var rights;if(angular.isDefined(owner))rights=User.$$resource.userResource(owner).fetch(folderId,"userRights",param);else rights=User.$$resource.fetch(folderId,"userRights",param);rights.then(function(data){_this.rights=data;_this.$shadowRights=angular.copy(data);deferred.resolve(data);return data})}return deferred.promise};User.prototype.$isAnonymous=function(){return this.uid=="anonymous"};User.prototype.$isSpecial=function(){return this.userClass&&this.userClass=="public-user"};User.prototype.$confirmRights=function(){var confirmation=false;if(this.$confirmation){return false}if(_.some(_.values(this.rights))){if(this.uid=="anonymous"){confirmation=l("Potentially anyone on the Internet will be able to access your folder, even if they do not have an account on this system. Is this information suitable for the public Internet?")}else if(this.uid==""){confirmation=l("Any user with an account on this system will be able to access your folder. Are you certain you trust them all?")}}this.$confirmation=confirmation;return confirmation};User.prototype.$rightsAreDirty=function(){return this.rights&&!_.isEqual(this.rights,this.$shadowRights)};User.prototype.$resetRights=function(zero){var _this=this;if(zero){_.map(_.keys(this.rights),function(key){if(angular.isString(_this.rights[key]))_this.rights[key]="None";else _this.rights[key]=0})}else{this.rights=angular.copy(this.$shadowRights)}};User.prototype.$folders=function(type){var _this=this,deferred=User.$q.defer(),param={type:type};if(this.$$folders){deferred.resolve(this.$$folders)}else{User.$$resource.userResource(this.uid).fetch(null,"foldersSearch",param).then(function(response){_this.$$folders=response.folders;deferred.resolve(response.folders)})}return deferred.promise};User.prototype.$omit=function(){var user={};angular.forEach(this,function(value,key){if(key!="constructor"&&key[0]!="$"){user[key]=value}});return user};User.prototype.toString=function(){return"[User "+this.c_email+"]"}})();(function(){"use strict";sgFocus.$inject=["$rootScope","$timeout"];function sgFocus($rootScope,$timeout){return function(name){$timeout(function(){$rootScope.$broadcast("sgFocusOn",name)})}}angular.module("SOGo.Common").factory("sgFocus",sgFocus)})();(function(){"use strict";function sgAvatarImage(){return{restrict:"AE",scope:{size:"@",email:"=sgEmail",src:"=sgSrc"},template:'
',link:link,bindToController:true,controller:"sgAvatarImageController",controllerAs:"vm"}}function link(scope,element,attrs,controller){var el=element[0],className=el.className,imgElement=element.find("img"),img=imgElement[0];if(attrs.size){imgElement.attr("width",attrs.size);imgElement.attr("height",attrs.size)}imgElement.bind("error",function(){controller.insertGenericAvatar(img)})}sgAvatarImageController.$inject=["$scope","$element","Preferences","Gravatar"];function sgAvatarImageController($scope,$element,Preferences,Gravatar){var vm=this;$scope.$watch("vm.email",function(email){Preferences.ready().then(function(){
var img=$element.find("img")[0];if(!email&&!vm.genericAvatar){vm.insertGenericAvatar(img)}else if(email&&!vm.url){if(vm.genericAvatar){vm.genericAvatar.parentNode.removeChild(vm.genericAvatar);delete vm.genericAvatar;img.classList.remove("ng-hide")}vm.url=Gravatar(email,vm.size,Preferences.defaults.SOGoAlternateAvatar)}})});if("sg-src"in $element[0].attributes){$scope.$watch("vm.src",function(src){if(src){vm.url=src}})}vm.insertGenericAvatar=function(img){var avatar;if(!vm.genericAvatar){avatar=document.createElement("md-icon");avatar.className="material-icons icon-person";img.classList.add("ng-hide");vm.genericAvatar=img.parentNode.insertBefore(avatar,img)}}}angular.module("SOGo.Common").directive("sgAvatarImage",sgAvatarImage).controller("sgAvatarImageController",sgAvatarImageController)})();(function(){"use strict";function sgColorPicker(){return{restrict:"E",require:"ngModel",template:["",' ',' color_lens'," ",' ',' ',' ',' check_box'," "," "," ",""].join(""),replace:true,controller:sgColorPickerController,link:link};function link(scope,iElement,iAttr,ngModelController){ngModelController.$render=function(){scope.sgColor=ngModelController.$viewValue}}}sgColorPickerController.$inject=["$scope","$element","sgColors"];function sgColorPickerController($scope,$element,sgColors){var ngModelController=$element.controller("ngModel");$scope.sgColors=sgColors.selection;$scope.setColor=function(color){$scope.sgColor=color;ngModelController.$setViewValue(color)}}angular.module("SOGo.Common").directive("sgColorPicker",sgColorPicker)})();(function(){"use strict";sgCompile.$inject=["$compile"];function sgCompile($compile){return{restrict:"A",link:sgCompileLink};function sgCompileLink(scope,element,attrs){var ensureCompileRunsOnce=scope.$watch(function(scope){return scope.$eval(attrs.sgCompile)},function(value){element.html(value);$compile(element.contents())(scope);ensureCompileRunsOnce()})}}angular.module("SOGo.Common").directive("sgCompile",sgCompile)})();(function(){"use strict";function sgEnter(){var ENTER_KEY=13;return function(scope,element,attrs){element.bind("keydown keypress",function(event){if(event.which===ENTER_KEY){scope.$apply(attrs.sgEnter);event.preventDefault()}})}}angular.module("SOGo.Common").directive("sgEnter",sgEnter)})();(function(){"use strict";function sgEscape(){var ESCAPE_KEY=27;return function(scope,elem,attrs){elem.bind("keydown",function(event){if(event.keyCode===ESCAPE_KEY){scope.$apply(attrs.sgEscape)}})}}angular.module("SOGo.Common").directive("sgEscape",sgEscape)})();(function(){"use strict";function sgFocusOn(){return function(scope,elem,attr){scope.$on("sgFocusOn",function(e,name){if(name===attr.sgFocusOn){elem[0].focus();elem[0].select()}})}}angular.module("SOGo.Common").directive("sgFocusOn",sgFocusOn)})();(function(){"use strict";function sgFolderStylesheet(){return{restrict:"E",require:"ngModel",scope:{ngModel:"="},replace:true,bindToController:true,controller:sgFolderStylesheetController,controllerAs:"cssCtrl",template:['"].join("")};function sgFolderStylesheetController(){var vm=this;vm.contrast=contrast;function hexToRgb(hex){var result=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);return result?{r:parseInt(result[1],16),g:parseInt(result[2],16),b:parseInt(result[3],16)}:null}function contrast(hex){var color,c,l=1;color=hexToRgb(hex);if(color){c=[color.r/255,color.g/255,color.b/255];for(var i=0;i.179){return"black"}else{return"white"}}}}angular.module("SOGo.Common").directive("sgFolderStylesheet",sgFolderStylesheet)})();(function(){"use strict";function sgPlaceholder(){return{restrict:"A",scope:{placeholder:"=sgPlaceholder"},link:function(scope,elem,attr){scope.$watch("placeholder",function(){elem[0].placeholder=scope.placeholder})}}}angular.module("SOGo.Common").directive("sgPlaceholder",sgPlaceholder)})();(function(){"use strict";sgSearchPreTransclude.$inject=["$parse"];function sgSearchPreTransclude($parse){return{restrict:"A",controller:"sgSearchController",controllerAs:"$sgSearchController",priority:1001,compile:compile};function compile(tElement,tAttr){var mdInputEl=tElement.find("md-input-container"),inputEl=tElement.find("input"),selectEl=tElement.find("md-select"),buttonEl=tElement.find("md-button");inputEl.attr("ng-model","$sgSearchController.searchText");inputEl.attr("ng-model-options","$sgSearchController.searchTextOptions");inputEl.attr("ng-change","$sgSearchController.onChange()");if(selectEl){selectEl.attr("ng-model","$sgSearchController.searchField");selectEl.attr("ng-change","$sgSearchController.onChange()")}if(buttonEl&&buttonEl.attr("sg-search-cancel")){buttonEl.attr("ng-click",buttonEl.attr("sg-search-cancel"));buttonEl.removeAttr("sg-search-cancel")}else{buttonEl=null}return function postLink(scope,iElement,iAttr,controller){var compiledButtonEl=iElement.find("button");controller.doSearch=$parse(iElement.attr("sg-search"));if(buttonEl&&compiledButtonEl){compiledButtonEl.on("click",controller.cancelSearch)}}}}function sgSearch(){return{restrict:"A",priority:1e3,transclude:true,compile:compile};function compile(tElement,tAttr){return function postLink(scope,iElement,iAttr,controller,transclude){transclude(function(clone){iElement.append(clone)})}}}sgSearchController.$inject=["$scope","$element"];function sgSearchController($scope,$element){var vm=this;vm.previous={searchText:"",searchField:""};vm.searchText=null;vm.searchTextOptions={updateOn:"default blur",debounce:{"default":300,blur:0}};vm.onChange=function(){if(typeof vm.searchText!=="undefined"&&vm.searchText!==null){if(vm.searchText!=vm.previous.searchText||vm.searchField!=vm.previous.searchField){if(vm.searchText.length>2||vm.searchText.length===0||vm.searchText=="."){vm.doSearch($scope,{searchText:vm.searchText,searchField:vm.searchField})}vm.previous={searchText:vm.searchText,searchField:vm.searchField}}}};vm.cancelSearch=function(){vm.searchText=""}}angular.module("SOGo.Common").controller("sgSearchController",sgSearchController).directive("sgSearch",sgSearchPreTransclude).directive("sgSearch",sgSearch)})();(function(){"use strict";sgSubscribe.$inject=["User"];function sgSubscribe(User){return{restrict:"A",scope:{folderType:"@sgSubscribe",onFolderSelect:"&sgSubscribeOnSelect"},replace:false,bindToController:true,controller:sgSubscribeDialogController,controllerAs:"$sgSubscribeDialogController",link:link}}function link(scope,element,attrs,controller){var inputEl=element.find("input");element.on("click",controller.showDialog)}sgSubscribeDialogController.$inject=["$mdDialog"];function sgSubscribeDialogController($mdDialog){var vm=this;vm.showDialog=function(){$mdDialog.show({templateUrl:"../Contacts/UIxContactsUserFolders",clickOutsideToClose:true,locals:{folderType:vm.folderType,onFolderSelect:vm.onFolderSelect},controller:sgSubscribeController,controllerAs:"subscribe"})}}sgSubscribeController.$inject=["$mdDialog","folderType","onFolderSelect","User"];function sgSubscribeController($mdDialog,folderType,onFolderSelect,User){var vm=this;vm.selectedUser=null;vm.users=User.$users;vm.searchTextOptions={updateOn:"default blur",debounce:{"default":300,blur:0}};vm.onChange=function(){User.$filter(vm.searchText).then(function(){if(vm.selectedUser){if(_.isUndefined(_.find(User.$users,function(user){return user.uid==vm.selectedUser.uid}))){vm.selectedUser=null}}})};vm.selectUser=function(i){if(vm.selectedUser==vm.users[i]){vm.selectedUser=null}else{vm.users[i].$folders(folderType).then(function(){vm.selectedUser=vm.users[i]})}};vm.selectFolder=function(folder){onFolderSelect({folderData:folder})};vm.close=function(){$mdDialog.hide()}}angular.module("SOGo.Common").directive("sgSubscribe",sgSubscribe)})();(function(){"use strict";angular.module("SOGo.Common").directive("sgTimePane",timePaneDirective);function timePaneDirective(){return{template:['','
','
','
',' {{hour.displayName}}',"
","
","
",'
','
','
',' {{minute.displayName}}',"
","
","
",'
",'
',' ',"
","
"].join(""),scope:{},require:["ngModel","sgTimePane"],controller:TimePaneCtrl,controllerAs:"ctrl",bindToController:true,link:function(scope,element,attrs,controllers){var ngModelCtrl=controllers[0];var sgTimePaneCtrl=controllers[1];var timePaneElement=element;sgTimePaneCtrl.configureNgModel(ngModelCtrl,sgTimePaneCtrl,timePaneElement)}}}var SELECTED_TIME_CLASS="md-bg";var FOCUSED_TIME_CLASS="md-focus";var nextTimePaneUniqueId=0;function TimePaneCtrl($element,$attrs,$scope,$animate,$q,$mdConstant,$mdTheming,$$mdDateUtil,$mdDateLocale,$mdInkRipple,$mdUtil){var m;this.$scope=$scope;this.$element=$element;this.timePaneElement=$element[0].querySelector(".sg-time-pane");this.$animate=$animate;this.$q=$q;this.$mdInkRipple=$mdInkRipple;this.$mdUtil=$mdUtil;this.keyCode=$mdConstant.KEY_CODE;this.dateUtil=$$mdDateUtil;this.id=nextTimePaneUniqueId++;this.ngModelCtrl=null;this.selectedTime=null;this.displayTime=null;this.isInitialized=false;$scope.hours=[];$scope.hours[0]=[];$scope.hours[0][0]=[];$scope.hours[0][1]=[];$scope.hours[1]=[];$scope.hours[1][0]=[];$scope.hours[1][1]=[];for(var i=0;i<6;i++){$scope.hours[0][0][i]={id:"tp-"+this.id+"-hour-"+i,displayName:i<10?"0"+i:""+i,selected:false};$scope.hours[0][1][i]={id:"tp-"+this.id+"-hour-"+(i+6),displayName:i+6<10?"0"+(i+6):""+(i+6),selected:false};$scope.hours[1][0][i]={id:"tp-"+this.id+"-hour-"+(i+12),displayName:""+(i+12),selected:false};$scope.hours[1][1][i]={id:"tp-"+this.id+"-hour-"+(i+18),displayName:""+(i+18),selected:false}}$scope.min5=[];$scope.min5[0]=[];$scope.min5[1]=[];for(i=0;i<6;i++){m=i*5;$scope.min5[0][i]={id:"tp-"+this.id+"-minute5-"+m,displayName:m<10?":0"+m:":"+m,selected:true};$scope.min5[1][i]={id:"tp-"+this.id+"-minute5-"+(m+30),displayName:":"+(m+30),selected:false}}$scope.min1=[];for(i=0;i<12;i++){$scope.min1[i]=[];for(var ii=0;ii<5;ii++){m=i*5+ii;$scope.min1[i][ii]={id:"tp-"+this.id+"-minute-"+m,displayName:m<10?":0"+m:":"+m,selected:true}}}$scope.show5min=true;$scope.getToggleBtnLbl=function(){return $scope.is5min()?">>":"<<"};$scope.toggleManual5min=function(){$scope.manual5min=!$scope.is5min()};$scope.is5min=function(){if($scope.manual5min===true||$scope.manual5min===false){return $scope.manual5min}else{return $scope.show5min}};if(!$attrs.tabindex){$element.attr("tabindex","-1")}var self=this;this.hourClickHandler=function(displayVal){var updated=new Date(self.displayTime);updated.setHours(Number(displayVal));self.setNgModelValue(updated,"hours")};$scope.hourClickHandler=this.hourClickHandler;this.minuteClickHandler=function(displayVal){var val=displayVal.substr(1);var updated=new Date(self.displayTime);updated.setMinutes(Number(val));self.setNgModelValue(updated,"minutes")};$scope.minuteClickHandler=this.minuteClickHandler;this.attachTimePaneEventListeners()}TimePaneCtrl.$inject=["$element","$attrs","$scope","$animate","$q","$mdConstant","$mdTheming","$$mdDateUtil","$mdDateLocale","$mdInkRipple","$mdUtil"];TimePaneCtrl.prototype.configureNgModel=function(ngModelCtrl,sgTimePaneCtrl,timePaneElement){this.ngModelCtrl=ngModelCtrl;var self=this;ngModelCtrl.$render=function(){self.changeSelectedTime(self.ngModelCtrl.$viewValue,sgTimePaneCtrl,timePaneElement)}};TimePaneCtrl.prototype.changeSelectedTime=function(date,sgTimePaneCtrl,timePaneElement){var self=this;var previousSelectedTime=this.selectedTime;this.selectedTime=date;this.changeDisplayTime(date).then(function(){if(previousSelectedTime){var prevH=previousSelectedTime.getHours();var prevHCell=document.getElementById("tp-"+sgTimePaneCtrl.id+"-hour-"+prevH);if(prevHCell){prevHCell.classList.remove(SELECTED_TIME_CLASS);prevHCell.setAttribute("aria-selected","false")}var prevM=previousSelectedTime.getMinutes();var prevMCell=document.getElementById("tp-"+sgTimePaneCtrl.id+"-minute-"+prevM);if(prevMCell){prevMCell.classList.remove(SELECTED_TIME_CLASS);prevMCell.setAttribute("aria-selected","false")}var prevM5Cell=document.getElementById("tp-"+sgTimePaneCtrl.id+"-minute5-"+prevM);if(prevM5Cell){prevM5Cell.classList.remove(SELECTED_TIME_CLASS);prevM5Cell.setAttribute("aria-selected","false")}}if(date){var newH=date.getHours();var mCell,hCell=document.getElementById("tp-"+sgTimePaneCtrl.id+"-hour-"+newH);if(hCell){hCell.classList.add(SELECTED_TIME_CLASS);hCell.setAttribute("aria-selected","true")}var newM=date.getMinutes();if(newM%5===0){sgTimePaneCtrl.$scope.show5min=true;mCell=document.getElementById("tp-"+sgTimePaneCtrl.id+"-minute5-"+newM);if(mCell){mCell.classList.add(SELECTED_TIME_CLASS);mCell.setAttribute("aria-selected","true")}}else{sgTimePaneCtrl.$scope.show5min=false}mCell=document.getElementById("tp-"+sgTimePaneCtrl.id+"-minute-"+newM);if(mCell){mCell.classList.add(SELECTED_TIME_CLASS);mCell.setAttribute("aria-selected","true")}}})};TimePaneCtrl.prototype.changeDisplayTime=function(date){var d=new Date(date);if(!this.isInitialized){this.buildInitialTimePaneDisplay();return this.$q.when()}if(!this.dateUtil.isValidDate(d)){return this.$q.when()}this.displayTime=d;return this.$q.when()};TimePaneCtrl.prototype.buildInitialTimePaneDisplay=function(){this.displayTime=this.selectedTime||this.today;this.isInitialized=true};TimePaneCtrl.prototype.attachTimePaneEventListeners=function(){this.$element.on("keydown",angular.bind(this,this.handleKeyEvent))};TimePaneCtrl.prototype.handleKeyEvent=function(event){var self=this;this.$scope.$apply(function(){if(event.which==self.keyCode.ESCAPE||event.which==self.keyCode.TAB){self.$scope.$emit("md-time-pane-close");if(event.which==self.keyCode.TAB){event.preventDefault()}return}if(event.which===self.keyCode.ENTER){self.setNgModelValue(self.displayTime,"enter");event.preventDefault();return}})};TimePaneCtrl.prototype.setNgModelValue=function(date,mode){this.$scope.$emit("sg-time-pane-change",{date:date,changed:mode});this.ngModelCtrl.$setViewValue(date);this.ngModelCtrl.$render()};TimePaneCtrl.prototype.focus=function(opt_date,sgTimePaneCtrl){var date=opt_date||this.selectedTime||this.today;var previousFocus=this.timePaneElement.querySelector(".md-focus");if(previousFocus){previousFocus.classList.remove(FOCUSED_TIME_CLASS)}if(date){var newH=date.getHours();var hCell=document.getElementById("tp-"+sgTimePaneCtrl.id+"-hour-"+newH);if(hCell){hCell.classList.add(FOCUSED_TIME_CLASS);hCell.focus()}}}})();(function(){"use strict";angular.module("SOGo.Common").directive("sgTimepicker",timePickerDirective);function timePickerDirective(){return{template:[''," access_time","",'",'"].join(""),require:["ngModel","sgTimepicker"],scope:{placeholder:"@mdPlaceholder"},controller:TimePickerCtrl,controllerAs:"ctrl",bindToController:true,link:function(scope,element,attr,controllers){var ngModelCtrl=controllers[0];var mdTimePickerCtrl=controllers[1];mdTimePickerCtrl.configureNgModel(ngModelCtrl)}}}var EXTRA_INPUT_SIZE=3;var INVALID_CLASS="sg-timepicker-invalid";var DEFAULT_DEBOUNCE_INTERVAL=500;var TIME_PANE_HEIGHT={MIN5:{GTSM:172+20,SM:292+20},MIN1:{GTSM:364+20,SM:454+20}};var TIME_PANE_WIDTH={GTSM:510+20,SM:272+20};function TimePickerCtrl($scope,$element,$attrs,$compile,$timeout,$mdConstant,$mdMedia,$mdTheming,$mdUtil,$mdDateLocale,$$mdDateUtil,$$rAF){this.$compile=$compile;this.$timeout=$timeout;this.dateLocale=$mdDateLocale;this.dateUtil=$$mdDateUtil;this.$mdConstant=$mdConstant;this.$mdMedia=$mdMedia;this.$mdUtil=$mdUtil;this.$$rAF=$$rAF;this.ngModelCtrl=null;this.inputElement=$element[0].querySelector("input");this.inputContainer=$element[0].querySelector(".sg-timepicker-input-container");this.ngInputElement=angular.element(this.inputElement);this.timePane=$element[0].querySelector(".sg-timepicker-time-pane");this.timeButton=$element[0].querySelector(".sg-timepicker-button");this.inputMask=$element[0].querySelector(".sg-timepicker-input-mask-opaque");this.$element=$element;this.$attrs=$attrs;this.$scope=$scope;this.date=null;this.isFocused=false;this.isDisabled=false;this.setDisabled($element[0].disabled||angular.isString($attrs.disabled));this.isTimeOpen=false;this.timePaneOpenedFrom=null;this.timePane.id="sg-time-pane"+$mdUtil.nextUid();$mdTheming($element);this.bodyClickHandler=angular.bind(this,this.handleBodyClick);this.windowResizeHandler=$mdUtil.debounce(angular.bind(this,this.closeTimePane),100);if(!$attrs.tabindex){$element.attr("tabindex","-1")}this.installPropertyInterceptors();this.attachChangeListeners();this.attachInteractionListeners();var self=this;$scope.$on("$destroy",function(){self.detachTimePane()})}TimePickerCtrl.$inject=["$scope","$element","$attrs","$compile","$timeout","$mdConstant","$mdMedia","$mdTheming","$mdUtil","$mdDateLocale","$$mdDateUtil","$$rAF"];TimePickerCtrl.prototype.configureNgModel=function(ngModelCtrl){this.ngModelCtrl=ngModelCtrl;var self=this;ngModelCtrl.$render=function(){self.time=self.ngModelCtrl.$viewValue;self.inputElement.value=self.formatTime(self.time);self.resizeInputElement()}};TimePickerCtrl.prototype.formatTime=function(time){var t=new Date(time);if(t){var h=t.getHours();var m=t.getMinutes();return(h<10?"0"+h:h)+":"+(m<10?"0"+m:m)}else return""};TimePickerCtrl.prototype.attachChangeListeners=function(){var self=this;self.$scope.$on("sg-time-pane-change",function(event,data){var time=new Date(data.date);self.ngModelCtrl.$setViewValue(time);self.time=time;self.inputElement.value=self.formatTime(self.time);if(data.changed=="minutes"){self.closeTimePane()}self.resizeInputElement();self.inputContainer.classList.remove(INVALID_CLASS)});self.ngInputElement.on("input",angular.bind(self,self.resizeInputElement));self.ngInputElement.on("input",self.$mdUtil.debounce(self.handleInputEvent,DEFAULT_DEBOUNCE_INTERVAL,self))};TimePickerCtrl.prototype.attachInteractionListeners=function(){var self=this;var $scope=this.$scope;var keyCodes=this.$mdConstant.KEY_CODE;self.ngInputElement.on("keydown",function(event){if(event.altKey&&event.keyCode==keyCodes.DOWN_ARROW){self.openTimePane(event);$scope.$digest()}});$scope.$on("md-time-close",function(){self.closeTimePane()})};TimePickerCtrl.prototype.installPropertyInterceptors=function(){var self=this;if(this.$attrs.ngDisabled){var scope=this.$mdUtil.validateScope(this.$element)?this.$element.scope():null;if(scope){scope.$watch(this.$attrs.ngDisabled,function(isDisabled){self.setDisabled(isDisabled)})}}Object.defineProperty(this,"placeholder",{get:function(){return self.inputElement.placeholder},set:function(value){self.inputElement.placeholder=value||""}})};TimePickerCtrl.prototype.setDisabled=function(isDisabled){this.isDisabled=isDisabled;this.inputElement.disabled=isDisabled;this.timeButton.disabled=isDisabled};TimePickerCtrl.prototype.resizeInputElement=function(){this.inputElement.size=this.inputElement.value.length+EXTRA_INPUT_SIZE};TimePickerCtrl.prototype.handleInputEvent=function(self){var inputString=this.inputElement.value;var arr=inputString.split(":");if(inputString===""){this.ngModelCtrl.$setViewValue(null);this.time=null;this.inputContainer.classList.remove(INVALID_CLASS)}else if(arr.length<2){this.inputContainer.classList.toggle(INVALID_CLASS,inputString)}else{var h=Number(arr[0]);var m=Number(arr[1]);var newVal=new Date(this.time);if(h&&h>=0&&h<=23&&m&&m>=0&&m<=59&&angular.isDate(newVal)){newVal.setHours(h);newVal.setMinutes(m);this.ngModelCtrl.$setViewValue(newVal);this.time=newVal;this.inputContainer.classList.remove(INVALID_CLASS)}else{this.inputContainer.classList.toggle(INVALID_CLASS,inputString)}}};TimePickerCtrl.prototype.attachTimePane=function(){var timePane=this.timePane;this.$element.addClass("sg-timepicker-open");this.$element.find("button").addClass("md-primary");var elementRect=this.inputContainer.getBoundingClientRect();var bodyRect=document.body.getBoundingClientRect();var paneTop=elementRect.top-bodyRect.top;var paneLeft=elementRect.left-bodyRect.left;var paneWidth=this.$mdMedia("sm")?TIME_PANE_WIDTH.SM:TIME_PANE_WIDTH.GTSM;if(paneLeft+paneWidth>bodyRect.right&&bodyRect.right-paneWidth>0){paneLeft=bodyRect.right-paneWidth;timePane.classList.add("sg-timepicker-pos-adjusted")}timePane.style.left=paneLeft+"px";var min=typeof this.time=="object"&&this.time.getMinutes()%5===0?"MIN5":"MIN1";var paneHeight=this.$mdMedia("sm")?TIME_PANE_HEIGHT[min].SM:TIME_PANE_HEIGHT[min].GTSM;if(paneTop+paneHeight>bodyRect.bottom&&bodyRect.bottom-paneHeight>0){paneTop=bodyRect.bottom-paneHeight;timePane.classList.add("sg-timepicker-pos-adjusted")}timePane.style.top=paneTop+"px";document.body.appendChild(this.timePane);this.inputMask.style.left=elementRect.width+"px";this.$$rAF(function(){timePane.classList.add("md-pane-open")})};TimePickerCtrl.prototype.detachTimePane=function(){this.$element.removeClass("sg-timepicker-open");this.$element.find("button").removeClass("md-primary");this.timePane.classList.remove("md-pane-open");this.timePane.classList.remove("md-timepicker-pos-adjusted");if(this.timePane.parentNode){this.timePane.parentNode.removeChild(this.timePane)}};TimePickerCtrl.prototype.openTimePane=function(event){if(!this.isTimeOpen&&!this.isDisabled){this.isTimeOpen=true;this.timePaneOpenedFrom=event.target;this.attachTimePane();this.$mdUtil.disableScrollAround(this.timePane);var self=this;this.$mdUtil.nextTick(function(){document.body.addEventListener("click",self.bodyClickHandler)},false);window.addEventListener("resize",this.windowResizeHandler)}};TimePickerCtrl.prototype.closeTimePane=function(){this.isTimeOpen=false;this.detachTimePane();this.timePaneOpenedFrom.focus();this.timePaneOpenedFrom=null;this.$mdUtil.enableScrolling();document.body.removeEventListener("click",this.bodyClickHandler);window.removeEventListener("resize",this.windowResizeHandler)};TimePickerCtrl.prototype.getTimePaneCtrl=function(){return angular.element(this.timePane.querySelector("sg-time-pane")).controller("sgTimePane")};TimePickerCtrl.prototype.focusTime=function(){var self=this;this.$mdUtil.nextTick(function(){var ctrl=self.getTimePaneCtrl();self.getTimePaneCtrl().focus(null,ctrl)},false)};TimePickerCtrl.prototype.setFocused=function(isFocused){this.isFocused=isFocused};TimePickerCtrl.prototype.handleBodyClick=function(event){if(this.isTimeOpen){var isInTime=this.$mdUtil.getClosest(event.target,"sg-time-pane");if(!isInTime){this.closeTimePane()}this.$scope.$digest()}}})();(function(){"use strict";sgToggleGrid.$inject=["$parse"];function sgToggleGrid($parse){return{restrict:"A",link:link};function link(scope,iElement,attrs,ctrl){var tiles=iElement.find("md-grid-tile"),tile,i,modelDays,modelAttr,ensureInitRunsOnce,toggleClass;ensureInitRunsOnce=scope.$watch(function(){return $parse(attrs.sgToggleGrid)(scope)},function(days){if(angular.isDefined(days)){var flattenedDays=days;modelDays=days;if(attrs.sgToggleGridAttr){modelAttr=attrs.sgToggleGridAttr;flattenedDays=_.pluck(days,attrs.sgToggleGridAttr)}_.each(tiles,function(o){var tile=angular.element(o);if(_.contains(flattenedDays,tile.attr("value"))){tile.addClass("sg-active")}});ensureInitRunsOnce()}});toggleClass=function(){var tile=angular.element(this),day=tile.attr("value");tile.toggleClass("sg-active");toggle(day)};for(i=0;i>2;enc2=(chr1&3)<<4|chr2>>4;enc3=(chr2&15)<<2|chr3>>6;enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64}else if(isNaN(chr3)){enc4=64}output=output+this._base64_keyStr.charAt(enc1)+this._base64_keyStr.charAt(enc2)+this._base64_keyStr.charAt(enc3)+this._base64_keyStr.charAt(enc4)}return output};String.prototype.base64decode=function(){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;var input=""+this;while(i>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2)}if(enc4!=64){output=output+String.fromCharCode(chr3)}}return output};String.prototype.md5=function(){if(!this.length){return}var md5=function(s){function L(k,d){return k<>>32-d}function K(G,k){var I,d,F,H,x;F=G&2147483648;H=k&2147483648;I=G&1073741824;d=k&1073741824;x=(G&1073741823)+(k&1073741823);if(I&d){return x^2147483648^F^H}if(I|d){if(x&1073741824){return x^3221225472^F^H}else{return x^1073741824^F^H}}else{return x^F^H}}function r(d,F,k){return d&F|~d&k}function q(d,F,k){return d&k|F&~k}function p(d,F,k){return d^F^k}function n(d,F,k){return F^(d|~k)}function u(G,F,aa,Z,k,H,I){G=K(G,K(K(r(F,aa,Z),k),I));return K(L(G,H),F)}function f(G,F,aa,Z,k,H,I){G=K(G,K(K(q(F,aa,Z),k),I));return K(L(G,H),F)}function D(G,F,aa,Z,k,H,I){G=K(G,K(K(p(F,aa,Z),k),I));return K(L(G,H),F)}function t(G,F,aa,Z,k,H,I){G=K(G,K(K(n(F,aa,Z),k),I));return K(L(G,H),F)}function e(G){var Z;var F=G.length;var x=F+8;var k=(x-x%64)/64;var I=(k+1)*16;var aa=Array(I-1);var d=0;var H=0;while(H>>29;return aa}function B(x){var k="",F="",G,d;for(d=0;d<=3;d++){G=x>>>d*8&255;F="0"+G.toString(16);k=k+F.substr(F.length-2,2)}return k}function J(k){k=k.replace(/rn/g,"n");var d="";for(var F=0;F127&&x<2048){d+=String.fromCharCode(x>>6|192);d+=String.fromCharCode(x&63|128)}else{d+=String.fromCharCode(x>>12|224);d+=String.fromCharCode(x>>6&63|128);d+=String.fromCharCode(x&63|128)}}}return d}var C=Array();var P,h,E,v,g,Y,X,W,V;var S=7,Q=12,N=17,M=22;var A=5,z=9,y=14,w=20;var o=4,m=11,l=16,j=23;var U=6,T=10,R=15,O=21;s=J(s);C=e(s);Y=1732584193;X=4023233417;W=2562383102;V=271733878;for(P=0;P12){p="pm";i=hours%12}if(minutes<10){m="0"+minutes}newString=newString.replace("%H",hours<10?"0"+hours:hours);newString=newString.replace("%I",i<10?"0"+i:i);newString=newString.replace("%M",m);newString=newString.replace("%p",p);return newString};String.prototype.isValidEmail=function(){var emailRE=/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i;return emailRE.test(this)};String.prototype.asCSSIdentifier=function(){var characters=["_","\\.","#","@","\\*",":",","," ","'","&","\\+"];var escapeds=["_U_","_D_","_H_","_A_","_S_","_C_","_CO_","_SP_","_SQ_","_AM_","_P_"];var newString=this;for(var i=0;iday2){var tmp=day1;day1=day2;day2=tmp}var nbrDays=Math.round((day2-day1)/864e5)+1;for(var i=0;i0)offset-=7;var beginOfWeek=this.beginOfDay();beginOfWeek.setHours(12);beginOfWeek.addDays(offset);return beginOfWeek};Date.prototype.endOfWeek=function(){var endOfWeek=this.beginOfWeek();endOfWeek.addDays(6);endOfWeek.setHours(23);endOfWeek.setMinutes(59);endOfWeek.setSeconds(59);endOfWeek.setMilliseconds(999);return endOfWeek};Date.prototype.getDayString=function(){var newString=this.getYear();if(newString<1e3)newString+=1900;var month=""+(this.getMonth()+1);if(month.length==1)month="0"+month;newString+=month;var day=""+this.getDate();if(day.length==1)day="0"+day;newString+=day;return newString};Date.prototype.getHourString=function(){var newString=this.getHours()+"00";if(newString.length==3)newString="0"+newString;return newString};function l(){var key=arguments[0];var value=key;if(labels[key]){value=labels[key]}else if(clabels[key]){value=clabels[key]}for(var i=1,j=0;i