sogo/UI/WebServerResources/js/Common.js

2 lines
82 KiB
JavaScript

function l(){var n,e,t=arguments[0],i=t,r=arguments;for(labels[t]?i=labels[t]:clabels[t]&&(i=clabels[t]),n=1,e=0;n<r.length;n++,e++)i=i.replace("%{"+e+"}",r[n]);return i=(n=1)<r.length?i.replace(/%((%)|s|d)/g,function(e){var t=null;return e[2]?t=e[2]:(t=r[n],"%d"===e&&(t=parseFloat(t),isNaN(t)&&(t=0)),n++),t}):i}function hexToRgb(e){e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}function contrast(e){var t=1,e=hexToRgb(e);if(e){for(var n=[e.r/255,e.g/255,e.b/255],i=0;i<n.length;++i)n[i]<=.03928?n[i]=n[i]/12.92:n[i]=Math.pow((n[i]+.055)/1.055,2.4);t=.2126*n[0]+.7152*n[1]+.0722*n[2]}return.179<t?"black":"white"}function guid(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return(e()+e()+"-"+e()+"-4"+e().substr(0,3)+"-"+e()+"-"+e()+e()+e()).toLowerCase()}!function(){"use strict";function e(e,t,n,i,r,o,s){e.classNameFilter(/^(?:(?!ng-animate-disabled).)*$/),r.definePalette("sogo-green",{50:"eaf5e9",100:"cbe5c8",200:"aad6a5",300:"88c781",400:"66b86a",500:"56b04c",600:"4da143",700:"388e3c",800:"367d2e",900:"225e1b",A100:"fafafa",A200:"69f0ae",A400:"00e676",A700:"00c853",contrastDefaultColor:"dark",contrastLightColors:["300","400","500","600","700","800","900"]}),r.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"]});e=r.extendPalette("grey",{1e3:"baa870"});r.definePalette("sogo-grey",e),r.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("sogo-grey"),r.registerStyles(["md-toolbar.md-hue-1:not(.md-menu-toolbar).md-accent,","md-toolbar.md-hue-1:not(.md-menu-toolbar).md-accent md-input-container[md-no-float] .md-input {"," background-color: '{{accent-hue-1}}';"," color: '{{foreground-1}}';","}","md-toolbar.md-hue-1:not(.md-menu-toolbar).md-accent md-icon {"," color: '{{foreground-1}}';"," fill: '{{foreground-1}}';","}"].join("")),r.registerStyles([".md-autocomplete-suggestions.md-3-line li p {"," color: '{{foreground-2}}';","}"].join("")),r.registerStyles([".sg-time-selection-indicator.sg-time-selected,",".sg-time-selection-indicator:hover.sg-time-selected,",".sg-time-selection-indicator.md-focus.sg-time-selected {"," background: '{{primary-500}}';","}",".sg-timepicker-open .sg-timepicker-icon {"," color: '{{primary-900}}';","}",".sg-timepicker-time,",".sg-timepicker-open .sg-timepicker-input-container {"," background: '{{background-hue-1}}';","}",".sg-timepicker-input-mask-opaque {"," box-shadow: 0 0 0 9999px '{{background-hue-1}}';","}"].join("")),r.registerStyles(["[ui-view=calendars] .hours {"," color: '{{primary-700}}';","}",".attendees .busy {"," background-color: '{{background-1000}}';","}",".attendees .event {"," background-color: '{{primary-300}}';","}"].join("")),r.registerStyles([".sg-message-thread {"," background-color: '{{primary-100}}';","}",".sg-message-thread-first {"," background-color: '{{primary-200}}';","}"].join("")),window.DebugEnabled||(t.debugEnabled(!1),n.debugInfoEnabled(!1),o.disableWarnings(),s.errorOnUnhandledRejections(!1),r.generateThemesOnDemand(!0)),i.interceptors.push("AuthInterceptor"),i.interceptors.push("ErrorInterceptor")}function a(t,e,n,i,r){var o=e.defer(),s=angular.element('<iframe class="ng-hide" src="'+t.UserFolderURL+'recover"></iframe>');return s.on("load",function(){var e=i.get("$state");2<r.config.attempt?(angular.element(t).off("beforeunload"),t.location.href=t.ApplicationBaseURL+e.href(e.current),o.reject()):n(function(){var e=i.get("$http");r.config.attempt?r.config.attempt++:r.config.attempt=1,e(r.config).then(function(e){o.resolve(e)},function(e){o.reject(e)}).finally(function(){n(s.remove,1e3)})},2e3)}),document.body.appendChild(s[0]),o.promise}function t(n,i,r,o){return{response:function(e){var t;return e&&/^application\/json/.test(e.config.headers.Accept)&&/^[\n\r\t ]*<!DOCTYPE html/.test(e.data)?n.usesCASAuthentication||n.usesSAML2Authentication?a(n,i,r,o,e):(t=o.get("$state"),angular.element(n).off("beforeunload"),n.location.href=n.ApplicationBaseURL+t.href(t.current),i.reject()):e}}}function n(n,i,r,o,s){return{responseError:function(e){var t;if(/^application\/json/.test(e.config.headers.Accept)){if((i.usesCASAuthentication||i.usesSAML2Authentication)&&-1==e.status)return a(i,r,o,s,e);i.usesSAML2Authentication&&401==e.status&&!i.recovered?(t=s.get("$state"),angular.element(i).off("beforeunload"),i.recovered=!0,i.location.href=i.ApplicationBaseURL+t.href(t.current)):e.data&&!e.data.quiet&&n.$broadcast("http:Error",e)}return r.reject(e)}}}angular.module("SOGo.Common",["ngAnimate","ngMessages","ngSanitize","ngMaterial","mdColors"]).value("sgSettings",{isPopup:document.body.classList.contains("popup"),baseURL:function(){return ApplicationBaseURL||null},resourcesURL:function(){return ResourcesURL||null},activeUser:function(e){var t={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,help:HelpURL||null,logoff:UserLogoffPath||null}};return e?t[e]:t},minimumSearchLength:function(){return angular.isNumber(minimumSearchLength)?minimumSearchLength:2}}).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: 1023px)","gt-md":"(min-width: 1024px)",lg:"(min-width: 1024px) and (max-width: 1279px)","gt-lg":"(min-width: 1280px)",xl:"(min-width: 1920px)",print:"print"}).config(e).factory("AuthInterceptor",t).factory("ErrorInterceptor",n),e.$inject=["$animateProvider","$logProvider","$compileProvider","$httpProvider","$mdThemingProvider","$mdAriaProvider","$qProvider"],t.$inject=["$window","$q","$timeout","$injector"],n.$inject=["$rootScope","$window","$q","$timeout","$injector"]}(),function(){"use strict";var v;function e(e){v=e}function t(e,t,n){function i(e){return e.join("")}for(var r=e(i([".md-{{theme}}-theme",".md-fg"])+" { color:{{value}};}"),o=e(i([".md-{{theme}}-theme",".md-bg"])+" { background-color:{{value}};}"),s=e(i([".md-{{theme}}-theme",".md-bdr"])+" { border-color:{{value}};}"),a=e(i([".md-{{theme}}-theme",".md-{{hue}}",".md-fg"])+" { color:{{value}};}"),l=e(i([".md-{{theme}}-theme",".md-{{hue}}",".md-bg"])+" { background-color:{{value}};}"),c=e(i([".md-{{theme}}-theme",".md-{{palette}}",".md-fg"])+" { color:{{value}};}"),u=e(i([".md-{{theme}}-theme",".md-{{palette}}",".md-bg"])+" { background-color:{{value}}; color:{{contrast}} !important; }"),d=e(i([".md-{{theme}}-theme",".md-{{palette}}",".md-bdr"])+" { border-color:{{value}};}"),h=e(i([".md-{{theme}}-theme",".md-{{palette}}.md-{{hue}}",".md-fg"])+" { color:{{value}};}"),m=e(i([".md-{{theme}}-theme",".md-{{palette}}.md-{{hue}}",".md-bg"])+" { background-color:{{value}};}"),g=function(){var e=t[0].head.querySelector('style[title="Dynamic-Generated-by-mdColors"]');null===e&&((e=t[0].createElement("style")).title="Dynamic-Generated-by-mdColors",e.appendChild(t[0].createTextNode("")),t[0].head.appendChild(e));return e.sheet}(),p=0;0<g.cssRules.length;)g.deleteRule(0);function f(e,t,n,i,r,o){r&&(o={theme:n,palette:i,value:"rgb("+r.value[0]+","+r.value[1]+","+r.value[2]+")",contrast:"rgb("+r.contrast[0]+","+r.contrast[1]+","+r.contrast[2]+")",hue:o},g.insertRule(e(o),p),p+=1,g.insertRule(t(o),p),p+=1)}function y(e,t,n,i,r){i&&(i="rgb("+i.value[0]+","+i.value[1]+","+i.value[2]+")",g.insertRule(e({theme:t,palette:n,value:i,hue:r}),p),p+=1)}angular.forEach(v._THEMES,function(e,n){f(r,o,n,"primary",v._PALETTES[e.colors.primary.name][e.colors.primary.hues.default]),f(a,l,n,"primary",v._PALETTES[e.colors.primary.name][e.colors.primary.hues["hue-2"]],"hue-2"),f(a,l,n,"primary",v._PALETTES[e.colors.primary.name][e.colors.primary.hues["hue-3"]],"hue-3"),f(a,l,n,"primary",v._PALETTES[e.colors.primary.name][e.colors.primary.hues["hue-1"]],"hue-1"),y(s,n,"primary",v._PALETTES[e.colors.primary.name][e.colors.primary.hues.default]),angular.forEach(e.colors,function(e,t){f(c,u,n,t,v._PALETTES[e.name][e.hues.default]),y(d,n,t,v._PALETTES[e.name][e.hues.default]),f(h,m,n,t,v._PALETTES[e.name][e.hues["hue-2"]],"hue-2"),f(h,m,n,t,v._PALETTES[e.name][e.hues["hue-3"]],"hue-3"),f(h,m,n,t,v._PALETTES[e.name][e.hues["hue-1"]],"hue-1")})})}angular.module("mdColors",["ngMaterial"]).config(e).run(t),e.$inject=["$mdThemingProvider"],t.$inject=["$interpolate","$document","$log"]}(),function(){"use strict";function e(e){return e.decodeURIComponent}e.$inject=["$window"],angular.module("SOGo.Common").filter("decodeUri",e)}(),function(){"use strict";function e(e){return e.encodeURIComponent}e.$inject=["$window"],angular.module("SOGo.Common").filter("encodeUri",e)}(),function(){"use strict";function e(t){return function(e){e=angular.element("<div>"+e+"</div>");return e.find("a").attr("target","_blank"),t.trustAs("html",e.html())}}e.$inject=["$sce"],angular.module("SOGo.Common").filter("ensureTarget",e)}(),function(){"use strict";angular.module("SOGo.Common").filter("loc",function(){return l})}(),function(){"use strict";angular.module("SOGo.Common").filter("range",function(){return function(e){for(var t=[],n=0;n<parseInt(e);n++)t.push(n);return t}})}(),function(){"use strict";function e(t){return function(e){return e?String(t(e," _blank",{rel:"noopener"})).replace(/&#10;/gm,"<br>"):void 0}}e.$inject=["linkyFilter"],angular.module("SOGo.Common").filter("txt2html",e)}(),function(){"use strict";function e(t,n,e,i,r,o,s){var a=this;function c(e,t){if(t&&t.target.parentNode.classList.contains("md-secondary"))return!1;a.selectedUid==e.uid?a.selectedUid=null:(a.selectedUid=e.uid,(a.selectedUser=e).inactive||a.selectedUser.$rights())}a.users=r,a.folder=s,a.selectedUser=null,a.selectedUid=null,a.userToAdd="",a.searchText="",a.folderClassName=function(){return!!angular.isFunction(s.getClassName)&&s.getClassName("bg")},a.templateName=function(e){return"UIx"+(t[0].getElementById("UIxAnonymousUserRightsEditor")&&e.$isAnonymous()?"Anonymous":"")+"UserRightsEditor"},a.userFilter=function(e){return o.$filter(e,s.$acl.users,{dry:!0})},a.closeModal=function(){s.$acl.$resetUsersRights(),e.hide()},a.saveModal=function(){s.$acl.$saveUsersRights().then(function(){e.hide()},function(e,t){i.alert(l("Warning"),l("An error occured, please try again."))})},a.confirmChange=function(e){e=e.$confirmRights(a.folder);e&&(a.confirmation.showing=!0,a.confirmation.message=e)},a.removeUser=function(e){n(function(){s.$acl.$removeUser(e.uid)},500)},a.addUser=function(e){e&&s.$acl.$addUser(e).then(function(e){a.userToAdd="",a.searchText="",a.selectedUid=null,e&&c(e)})},a.toggleAllRights=function(e){s.$acl.$toggleAllRights(e)},a.selectUser=c,a.hasNoRight=function(e){return s.$acl.$hasNoRight(e)},a.showRights=function(e){return a.selectedUid==e.uid&&!e.inactive},a.confirmation={showing:!1,message:""}}e.$inject=["$document","$timeout","$mdDialog","Dialog","usersWithACL","User","folder"],angular.module("SOGo.Common").controller("AclController",e)}(),function(){"use strict";function e(e,t,n,i,r,o,s,a,c,u,d,h,m,g){var p=new m(h.baseURL(),h.activeUser());function f(e,t){var n;t.data&&t.data.message&&angular.isString(t.data.message)?n=t.data.message:t.status&&(n=t.statusText),n?a.show({template:["<md-toast>",' <div class="md-toast-content">',' <md-icon class="md-warn md-hue-1">error_outline</md-icon>'," <span flex>"+l(n)+"</span>"," </div>","</md-toast>"].join(""),hideDelay:5e3,position:"top right"}):u.debug("untrap error")}this.$onInit=function(){t.isPopup=h.isPopup,t.activeUser=h.activeUser(),t.baseURL=h.baseURL(),t.leftIsClose=!c(d["gt-md"]),t.centerIsClose=!!o.centerIsClose&&!t.leftIsClose,t.currentDay=window.currentDay,n(function(){i(function(){r.get("../date").then(function(e){t.currentDay=e})},864e5)},1e3*window.currentDay.secondsBeforeTomorrow),t.$watch(function(){return c(d["gt-xs"])},function(e){t.isGtExtraSmall=e}),t.$watch(function(){return c(d["gt-md"])},function(e){(t.isGtMedium=e)&&(t.leftIsClose=!1)}),e.$on("http:Error",f),h.activeUser("path").calendar&&g.getAlarms(),h.activeUser("path").mail&&g.pollInbox()},t.toggleLeft=function(){t.isGtMedium?t.leftIsClose=!t.leftIsClose:(t.leftIsClose=!s("left").isOpen(),t.leftIsClose&&angular.element(o).triggerHandler("resize"),s("left").toggle().then(function(){u.debug("toggle left is done")}))},t.toggleRight=function(){s("right").toggle().then(function(){u.debug("toggle right is done")})},t.toggleCenter=function(e){t.centerIsClose=!t.centerIsClose,e&&e.save&&p.post(null,"saveListState",{state:t.centerIsClose?"collapse":"rise"})}}e.$inject=["$rootScope","$scope","$timeout","$interval","$http","$window","$mdSidenav","$mdToast","$mdMedia","$log","sgConstant","sgSettings","Resource","Preferences"],angular.module("SOGo.Common").controller("navController",e)}(),function(){"use strict";function s(e){this.folderId=e}s.factory=["$q","$timeout","sgSettings","Resource","User",function(e,t,n,i,r){return angular.extend(s,{$q:e,$timeout:t,$$resource:new i(n.activeUser("folderURL"),n.activeUser()),$User:r}),s}],angular.module("SOGo.Common").factory("Acl",s.factory),s.prototype.$users=function(t){var n,i=this,r=s.$q.defer();if(this.users)return r.resolve(this.users),r.promise;var e=(angular.isDefined(t)?s.$$resource.userResource(t):s.$$resource).fetch(this.folderId,"acls");return e.then(function(e){return i.users=[],angular.forEach(e.users,function(e){(n=new s.$User(e)).canSubscribeUser=n.isSubscribed,n.wasSubscribed=n.isSubscribed,n.$rights=angular.bind(n,n.$acl,i.folderId,t),i.users.push(n)}),r.resolve(i.users),i.users})},s.prototype.$addUser=function(e,t){var n=this,i=s.$q.defer(),r={uid:e.uid};return!e.uid||-1<_.indexOf(_.map(this.users,"uid"),e.uid)?i.resolve():(angular.isDefined(t)?s.$$resource.userResource(t):s.$$resource).fetch(this.folderId,"addUserInAcls",r).then(function(){e.wasSubscribed=!1,e.userClass=e.isGroup?"normal-group":"normal-user",e.$rights=angular.bind(e,e.$acl,n.folderId,t),n.users.push(e),i.resolve(e)},function(e,t){i.reject(l("An error occured, please try again."))}),i.promise},s.prototype.$removeUser=function(t,e){var n=this,i={uid:t},i=(angular.isDefined(e)?s.$$resource.userResource(e):s.$$resource).fetch(this.folderId,"removeUserFromAcls",i);return i.then(function(){var e=_.indexOf(_.map(n.users,"uid"),t);0<=e&&(n.users[e].$shadowRights=null,n.users.splice(e,1))})},s.prototype.$toggleAllRights=function(n){var i=!angular.isUndefined(_.find(_.values(n.rights),function(e){return 1!==e&&"Modifier"!==e}));_.forEach(n.rights,function(e,t){angular.isNumber(n.rights[t])?n.rights[t]=i?1:0:n.rights[t]=i?"Modifier":"None"})},s.prototype.$hasNoRight=function(e){e=_.find(e.rights,function(e,t){return angular.isNumber(e)?1===e:"None"!==e});return _.isUndefined(e)},s.prototype.$resetUsersRights=function(){angular.forEach(this.users,function(e){e.$resetRights()})},s.prototype.$saveUsersRights=function(e){var t=this,n=s.$q.defer(),i=s.$q.defer(),r={action:"saveUserRights"},o=[];return angular.forEach(this.users,function(e){e.$rightsAreDirty()&&o.push(e.$omit())}),o.length?(angular.isDefined(e)?s.$$resource.userResource(e):s.$$resource).save(this.folderId,o,r).then(function(){angular.forEach(t.users,function(e){e.$rightsAreDirty()&&(e.$shadowRights=angular.copy(e.rights))}),n.resolve()},n.reject):n.resolve(),o=[],angular.forEach(this.users,function(e){!e.wasSubscribed&&e.isSubscribed&&o.push(e.uid)}),o.length?(r={uids:o.join(",")},s.$$resource.fetch(this.folderId,"subscribeUsers",r).then(function(){angular.forEach(t.users,function(e){e.wasSubscribed=e.isSubscribed}),i.resolve()},i.reject)):i.resolve(),s.$q.all([n.promise,i.promise])}}(),function(){"use strict";angular.module("SOGo.Authentication",["ngCookies"]).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",function(){function h(e,t){var n,i=e;return t&&(i+="@"+t),n=""+window.location.href,"/"==(e=ApplicationBaseURL+encodeURIComponent(i))[0]&&(i=(t=n.split("/"))[2],e=t[0]+"//"+i+e),n.startsWith(e)&&!n.endsWith("/logoff")?n:e}function e(c,u,s,d){return{login:function(e){var t,n=c.defer(),i=e.username,r=e.password,o=e.verificationCode,s=e.domain,a=e.rememberLogin?1:0;return e.loginSuffix&&!i.endsWith(e.loginSuffix)&&(i+=loginSuffix,s=!1),e.language&&"WONoSelectionString"!=e.language&&(t=e.language),u({method:"POST",url:"/SOGo/connect",data:{userName:i,password:r,verificationCode:o,domain:s,language:t,rememberLogin:a}}).then(function(e){var t=e.data;navigator&&!navigator.cookieEnabled?n.reject({error:l("cookiesNotEnabled")}):void 0!==t.totpMissingKey&&202==e.status?n.resolve({totpmissingkey:1}):void 0!==t.expire&&void 0!==t.grace?t.expire<0&&0<t.grace?n.reject({cn:t.cn,url:h(i,s),grace:t.grace}):0<t.expire&&-1==t.grace?n.reject({cn:t.cn,url:h(i,s),expire:t.expire}):n.resolve({cn:t.cn,url:h(i,s)}):n.resolve({url:h(i,s)})},function(e){var e=e.data,t=e&&e.totpInvalidKey?{error:l("You provided an invalid TOTP key.")}:e&&angular.isDefined(e.LDAPPasswordPolicyError)?(t=e.LDAPPasswordPolicyError)==d.PolicyNoError?{error:l("Wrong username or password.")}:t==d.PolicyAccountLocked?{error:l("Your account was locked due to too many failed attempts.")}:t==d.PolicyPasswordExpired||t==d.PolicyChangeAfterReset||t==d.PolicyChangeAfterReset?{passwordexpired:1,url:h(i,s)}:{error:l("Login failed due to unhandled error case: ")+t}:{error:l("Unhandled error response")};n.reject(t)}),n.promise},changePassword:function(e,t,n,i){var r=c.defer(),o=s.get("XSRF-TOKEN");return s.remove("XSRF-TOKEN",{path:"/SOGo/"}),u({method:"POST",url:"/SOGo/so/changePassword",headers:{"X-XSRF-TOKEN":o},data:{userName:e,newPassword:n,oldPassword:i}}).then(function(){r.resolve({url:h(e,t)})},function(e){var t,e=e.data.LDAPPasswordPolicyError;e?e==d.PolicyNoError||e==d.PolicyPasswordUnknown?t=l("Password change failed"):e==d.PolicyPasswordModNotAllowed?t=l("Password change failed - Permission denied"):e==d.PolicyInsufficientPasswordQuality?t=l("Password change failed - Insufficient password quality"):e==d.PolicyPasswordTooShort?t=l("Password change failed - Password is too short"):e==d.PolicyPasswordTooYoung?t=l("Password change failed - Password is too young"):e==d.PolicyPasswordInHistory?t=l("Password change failed - Password is in history"):(t=l("Unhandled policy error: %{0}").formatted(e),e=d.PolicyPasswordUnknown):(e=d.PolicyPasswordSystemUnknown,t=_("Unhandled error response")),s.put("XSRF-TOKEN",o,{path:"/SOGo/"}),r.reject(t)}),r.promise}}}(this.$get=e).$inject=["$q","$http","$cookies","passwordPolicyConfig"]})}(),function(){"use strict";function n(){}function e(e,t){return angular.extend(n,{$q:e,$modal:t}),n}n.alert=function(e,t){t=this.$modal.alert().title(e).htmlContent(t).ok(l("OK")).multiple(!0);this.$modal.show(t)},n.confirm=function(e,t,n){n=this.$modal.confirm().title(e).htmlContent(t).ok(n&&n.ok?n.ok:l("OK")).cancel(n&&n.cancel?n.cancel:l("Cancel"));return this.$modal.show(n)},n.prompt=function(n,e,t){var i=t||{},t=n.asCSSIdentifier(),r=this.$q.defer();function o(e,t){e.title=n,e.name="",e.cancel=function(){r.reject(),t.hide()},e.ok=function(){r.resolve(e.name),t.hide()}}return this.$modal.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,template:['<md-dialog flex="50" flex-xs="90">',' <form name="'+t+'Form" ng-submit="ok()">',' <md-dialog-content class="md-dialog-content" layout="column">',' <h2 class="md-title" ng-bind="title"></h2>'," <md-input-container>"," <label>"+e+"</label>",' <input type="'+(i.inputType||"text")+'"',' aria-label="'+n+'"',' ng-model="name" md-autofocus="true" required />'," </md-input-container>"," </md-dialog-content>"," <md-dialog-actions>",' <md-button ng-click="cancel()">'," "+l("Cancel")," </md-button>",' <md-button type="submit" class="md-primary" ng-disabled="'+t+'Form.$invalid">'," "+l("OK")," </md-button>"," </md-dialog-actions>"," </form>","</md-dialog>"].join(""),controller:o}),o.$inject=["scope","$mdDialog"],r.promise},e.$inject=["$q","$mdDialog"],angular.module("SOGo.Common").factory("Dialog",e)}(),function(){"use strict";angular.module("SOGo.Common").factory("Gravatar",function(){return function(e,t,n,i){var r,o=t,s=n;return e?(t||(o=48),"https://www.gravatar.com/avatar/"+(e=0<=(t=e.indexOf("<"))&&t<(r=e.indexOf(">",t))?e.substring(t+1,r):e).md5()+"?s="+o+"&d="+(n=!s||"none"==s?i&&i.no_404?"mm":"404":n)):""}})}(),function(){"use strict";function a(e,t,n,i,r,o,s){angular.extend(this,{_http:e,_q:t,_window:n,_cookies:i,_path:r,_activeUser:o}),angular.extend(this,s),this._path=this._path.replace(/\/$/,"")}a.$factory=["$http","$q","$window","$cookies",function(i,r,o,s){return function(e,t,n){return new a(i,r,o,s,e,t,n)}}],angular.module("SOGo.Common").factory("Resource",a.$factory),a.prototype.encodeURL=function(e){var t=this,n=e;return angular.isArray(n)||(n=e.split("/")),_.map(n,function(e){return t._window.encodeURIComponent(e.toString())})},a.prototype.userResource=function(e){var t=_.compact(this._activeUser.folderURL.split("/"));return e&&t.splice(t.length-1,1,escape(e)),new a(this._http,this._q,this._window,this._cookies,"/"+t.join("/"),this._activeUser)},a.prototype.path=function(){var e=[this._path];return 0<arguments.length&&Array.prototype.push.apply(e,Array.prototype.slice.call(arguments)),e.join("/")},a.prototype.fetch=function(e,t,n){var i=this._q.defer(),r=[this._path];return e&&r.push(this.encodeURL(e)),t&&r.push(t),r=_.compact(_.flatten(r)).join("/"),this._http({method:"GET",url:r,params:n}).then(function(e){return i.resolve(e.data)},i.reject),i.promise},a.prototype.quietFetch=function(e,t,n){var i=this._q.defer(),r=[this._path];return e&&r.push(this.encodeURL(e)),t&&r.push(t),r=_.compact(_.flatten(r)).join("/"),this._http({method:"GET",url:r,params:n,transformResponse:function(e){var t;try{t=angular.fromJson(e)}catch(e){t={}}return angular.extend({quiet:!0},t)}}).then(function(e){return i.resolve(e.data)},i.reject),i.promise},a.prototype.newguid=function(e){var t=this._q.defer(),e=this._path+"/"+e+"/newguid";return this._http.get(e).then(function(e){return t.resolve(e.data)},t.reject),t.promise},a.prototype.create=function(e,t){var n=this._q.defer(),e=this._path+"/"+e;return this._http.post(e,{name:t}).then(function(e){return n.resolve(e.data)},n.reject),n.promise},a.prototype.post=function(e,t,n){var i=this._q.defer(),r=[this._path];return e&&r.push(this.encodeURL(e)),t&&r.push(t),r=_.compact(_.flatten(r)).join("/"),this._http.post(r,n).then(function(e){return i.resolve(e.data)},i.reject),i.promise},a.prototype.save=function(e,t,n){n=n&&n.action?n.action:"save";return this.post(e,n,t)},a.prototype.download=function(e,t,n,o){this._q.defer();var s=o&&o.type?o.type:"application/zip",i=[this._path];if(e&&i.push(this.encodeURL(e)),t&&i.push(t),i=_.compact(_.flatten(i)).join("/"),"undefined"==typeof saveAs)throw new Error("To use Resource.download, FileSaver.js must be loaded.");return this._http({method:"POST",url:i,data:n,headers:{accept:s},responseType:"arraybuffer",cache:!1,transformResponse:function(e,t,n){var i,r=null;if(n<200||299<n)throw new Error("Bad gateway");e&&(r=new Blob([e],{type:s})),i=o&&o.filename?o.filename:(i=t("content-disposition"))?i.split(";")[1].trim().split("=")[1].replace(/"/g,""):null,saveAs(r,i)}})},a.prototype.open=function(e,t){var n=[this._path],i=this._cookies.get("XSRF-TOKEN");e&&n.push(e),t&&n.push(t),n=_.compact(_.flatten(n)).join("/"),i&&(n+="?X-XSRF-TOKEN="+i),this._window.location.href=n},a.prototype.remove=function(e){var t=this._q.defer(),e=_.flatten([this._path,this.encodeURL(e),"delete"]).join("/");return this._http.get(e).then(function(e){return t.resolve(e.data)},t.reject),t.promise}}(),function(){"use strict";function e(t,n){return function(e){n(function(){t.$broadcast("sgFocusOn",e)})}}e.$inject=["$rootScope","$timeout"],angular.module("SOGo.Common").factory("sgFocus",e)}(),function(){"use strict";function e(e,t){return angular.extend(t,{$modal:e}),new t}e.$inject=["$mdDialog","$sgHotkeys"],angular.module("SOGo.Common").service("sgHotkeys",e).provider("$sgHotkeys",function(){var r={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"caps",27:"escape",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"},o={42:"*",63:"?"};function e(i,e){function t(e){this.id=e.id||guid(),this.key=e.key,this.description=e.description||null,this.context=e.context||null,this.callback=e.callback,this.preventInClass=e.preventInClass,this.args=e.args,this.onKeyUp=!1,1<this.key.length&&(this.lkey=l("key_"+this.key))}t.prototype.clone=function(){return new t(this)};function n(){this._hotkeys={},this._hotkeysUp={},this._preventIn=["INPUT","SELECT","TEXTAREA","MD-OPTION"],this._preventInClass=["md-chip-content"],this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.initialize()}return n.prototype.initialize=function(){this.registerHotkey(this.createHotkey({key:"?",description:l("Show or hide this help"),callback:this._toggleCheatSheet.bind(this)})),e.addEventListener("keydown",this._onKeydown,!0),e.addEventListener("keyup",this._onKeyup,!0),e.addEventListener("keypress",this._onKeypress,!0)},n.prototype._invokeHotkeyHandlers=function(e,t,n){for(var i=0,r=n.length;i<r;i++){var o=n[i],s=e.target||e.srcElement,a=s.nodeName.toUpperCase();if(!_.includes(this._preventIn,a)&&0===_.intersection(s.classList,this._preventInClass).length&&0===_.intersection(s.classList,o.preventInClass).length)try{o.callback.call(o.context,e,o.args)}catch(e){console.error("HotKeys: ",o.key,e.message)}}},n.prototype._onKeydown=function(e){var t=this.keyStringFromEvent(e);this._hotkeys[t]&&this._invokeHotkeyHandlers(e,t,this._hotkeys[t])},n.prototype._onKeyup=function(e){e=this.keyStringFromEvent(e);this._hotkeysUp[e]&&this._invokeHotkeyHandlers(this._hotkeysUp[e],e)},n.prototype._onKeypress=function(e){var t=e.keyCode||e.which,t=o[t];t&&this._hotkeys[t]&&this._invokeHotkeyHandlers(e,t,this._hotkeys[t])},n.prototype.keyStringFromEvent=function(e){var t=[],n=e.which,n=r[n]||String.fromCharCode(n).toLowerCase();return e.ctrlKey&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.metaKey&&t.push("meta"),t.push(n),_.uniq(t).join("+")},n.prototype._deregisterHotkey=function(e){var t,n=this._hotkeys;if((n=e.onKeyUp?this._hotkeysUp:n)[e.key]){for(var i=n[e.key],r=0;r<i.length;++r){var o=i[r];(e.callback===o.callback&&o.context===e.context||e.id===o.id)&&(t=i.splice(r,1))}0===i.length&&delete this._hotkeys[e.key]}return t},n.prototype.deregisterHotkey=function(e){var t=[];if(this._validateHotkey(e),angular.isArray(e.key))for(var n=e.key.length-1;0<=n;n--){var i=e.clone();i.key=e.key[n];i=this._deregisterHotkey(i);void 0!==i&&t.push(i[0])}else t.push(this._deregisterHotkey(e));return t},n.prototype._validateHotkey=function(e){if(!(e instanceof t))throw new TypeError("Hotkeys: Expected a hotkey object be instance of HotKey")},n.prototype._registerKey=function(e){var t=this._hotkeys;return(t=e.onKeyUp?this._hotkeysUp:t)[e.key]=t[e.key]||[],t[e.key].push(e),e},n.prototype._registerKeys=function(e){var t=[];if(angular.isArray(e.key))for(var n=e.key.length-1;0<=n;n--){var i=e.clone();i.id=guid(),i.key=e.key[n],t.push(this._registerKey(i))}else t.push(this._registerKey(e));return t},n.prototype.registerHotkey=function(e){return this._validateHotkey(e),this._registerKeys(e)},n.prototype.registerHotkeyUp=function(e){this._validateHotkey(e),e.onKeyUp=!0,this._registerKeys(e)},n.prototype.createHotkey=function(e){if(null===e.key||void 0===e.key)throw new TypeError('HotKeys: Argument "key" is required');if(null===e.callback||void 0===e.callback)throw new TypeError('HotKeys: Argument "callback" is required');var n;return e.callback=(n=e.callback,function(e,t){i.$apply(function(){n.call(this,e,t)}.bind(this))}),new t(e)},n.prototype.match=function(e,t){angular.isArray(t)||(t=[t]);e=this.keyStringFromEvent(e);return Boolean(~t.indexOf(e))},n.prototype._toggleCheatSheet=function(){var e=this;function t(e,t){e.hotkeys=t,e.closeDialog=function(){n.$modal.hide()}}this._cheatSheet?(n.$modal.hide(),this._cheatSheet=null):this._cheatSheet=n.$modal.show({clickOutsideToClose:!0,escapeToClose:!0,template:["<md-dialog>",' <md-toolbar class="md-hue-2">',' <div class="md-toolbar-tools">'," <div ng-bind=\"::'Keyboard Shortcuts' | loc\"></div>"," </div>"," </md-toolbar>"," <md-dialog-content>"," <md-list>",' <md-list-item ng-repeat="(hotkey, keys) in hotkeys">'," {{keys[0].description}}",' <div class="md-secondary sg-hotkey-container">'," <sg-hotkey>{{keys[0].lkey || hotkey}}</sg-hotkey>"," </div>"," </md-list-item>"," </md-list>"," </md-dialog-content>","</md-dialog>"].join(""),controller:t,locals:{hotkeys:e._hotkeys}}).finally(function(){e._cheatSheet=null}),t.$inject=["$scope","hotkeys"]},n}(this.$get=e).$inject=["$rootScope","$window"]})}(),function(){"use strict";function c(e){e&&this.init(e)}c.factory=["$q","$log","sgSettings","Resource",function(e,t,n,i){return angular.extend(c,{$q:e,$log:t,$$resource:new i(n.activeUser("folderURL"),n.activeUser()),$query:"",$users:[]}),c}],angular.module("SOGo.Common").factory("User",c.factory),c.$filter=function(e,s,a){var t=c.$$resource,n={search:e};if(a&&a.dry)a&&a.uid&&(t=c.$$resource.userResource(a.uid));else{if(!e)return c.$users.splice(0,c.$users.length),c.$q.when(c.$users);if(c.$query==e)return c.$q.when(c.$users);c.$query=e}return t.fetch(null,"usersSearch",n).then(function(e){function n(e){return this.uid==e.uid}var t,i,r,o;for(a?a.dry?o=[]:a.results&&(o=a.results):o=c.$users,t=s?_.filter(e.users,function(e){return!_.find(s,_.bind(n,e))}):e.users,i=o.length-1;0<=i;i--)r=o[i],_.find(t,_.bind(n,r))||o.splice(i,1);return _.forEach(t,function(e,t){_.isUndefined(_.find(o,_.bind(n,e)))&&(e=new c(e),o.splice(t,0,e))}),c.$log.debug(o),o})},c.prototype.init=function(e){angular.extend(this,e),this.$$shortFormat||(this.$$shortFormat=this.$shortFormat()),this.$$image||(this.$$image=this.image),this.$avatarIcon=this.$isGroup()||this.$isSpecial()?"group":"person",this.empty=" "},c.prototype.$fullname=function(){var e=this.cn||this.uid;return this.c_info&&(e+=" ("+this.c_info.split("\n").join("; ")+")"),e},c.prototype.$shortFormat=function(e){var t=this.$fullname(),n=this.c_email;return!(e&&!1===e.email)&&n&&t!=n&&(t+=" <"+n+">"),t},c.prototype.$acl=function(e,t){var n=this,i=c.$q.defer(),r={uid:this.uid};return this.$shadowRights?i.resolve(this.rights):(angular.isDefined(t)?c.$$resource.userResource(t):c.$$resource).fetch(e,"userRights",r).then(function(e){return n.rights=e,n.$shadowRights=angular.copy(e),i.resolve(e),e}),i.promise},c.prototype.$isGroup=function(){return this.isGroup||this.userClass&&"normal-group"==this.userClass},c.prototype.$isAnonymous=function(){return"anonymous"==this.uid},c.prototype.$isSpecial=function(){return this.userClass&&"public-user"==this.userClass},c.prototype.$confirmRights=function(e){var t=!1;return!this.$confirmation&&(_.some(_.values(this.rights))&&("anonymous"==this.uid?"AddressBook"==e.constructor.name?t=l('Potentially anyone on the Internet will be able to access your address book "%{0}", even if they do not have an account on this system. Is this information suitable for the public Internet?',e.name):"Calendar"==e.constructor.name&&(t=l('Potentially anyone on the Internet will be able to access your calendar "%{0}", even if they do not have an account on this system. Is this information suitable for the public Internet?',e.name)):"anyone"!=this.uid&&"<default>"!=this.uid||("AddressBook"==e.constructor.name?t=l('Any user with an account on this system will be able to access your address book "%{0}". Are you certain you trust them all?',e.name):"Calendar"==e.constructor.name?t=l('Any user with an account on this system will be able to access your calendar "%{0}". Are you certain you trust them all?',e.name):"Mailbox"==e.constructor.name&&(t=l('Any user with an account on this system will be able to access your mailbox "%{0}". Are you certain you trust them all?',e.name)))),this.$confirmation=t)},c.prototype.$rightsAreDirty=function(){return this.rights&&!_.isEqual(this.rights,this.$shadowRights)},c.prototype.$resetRights=function(e){var t=this;e?_.map(_.keys(this.rights),function(e){angular.isString(t.rights[e])?t.rights[e]="None":t.rights[e]=0}):this.$shadowRights&&(this.rights=angular.copy(this.$shadowRights))},c.prototype.$folders=function(e){var t=this,n=c.$q.defer(),e={type:e};return this.$$folders?n.resolve(this.$$folders):c.$$resource.userResource(this.uid).fetch(null,"foldersSearch",e).then(function(e){t.$$folders=e.folders,n.resolve(e.folders)}),n.promise},c.prototype.$omit=function(){var n={};return angular.forEach(this,function(e,t){"constructor"!=t&&"$"!=t[0]&&(n[t]=e)}),n},c.prototype.toString=function(){return"[User "+this.c_email+"]"}}(),function(){"use strict";function e(c,e,u){return{restrict:"A",scope:{autogrow:"=sgAutogrow"},link:function(e,t,n){var i,r,o,s,a;function l(){s=(s=i.value.encodeEntities()).replace(/\n/g,"<br>"),o.innerHTML=s+'<br style="line-height: 3px;">',o.style.visibility="hidden",o.style.display="block",i.style.height=Math.max(r,o.offsetHeight)+"px",o.style.visibility="visible",o.style.display="none"}e.autogrow&&(i=t[0],r=i.clientHeight,o=c[0].createElement("div"),s=null,o.classList.add("md-input"),o.classList.add("plain-text"),o.style.display="none",o.style.whiteSpace="pre-wrap",o.style.wordWrap="break-word",i.parentNode.appendChild(o),i.style.resize="none",i.style.overflow="hidden",t.on("keyup",u.debounce(l,200)),t.on("paste",l),a=e.$watch(function(){return t[0].value},function(e){e&&(l(),a())}))}}}e.$inject=["$document","$timeout","$mdUtil"],angular.module("SOGo.Common").directive("sgAutogrow",e)}(),function(){"use strict";function e(e,t,r,n,o,s){var a,i;function l(){a.url=null,a.urlEmail=null,a.img.addClass("ng-hide"),a.genericImg.removeClass("ng-hide")}function c(){a.genericImg.addClass("ng-hide"),a.img.removeClass("ng-hide")}a=this,e.$on("$destroy",function(){i&&t.off("click",i)}),e.$watch(function(){return a.email},function(e,t){var n,i;e&&a.urlEmail!=e?(l(),o.defaults.SOGoGravatarEnabled&&(i=s(n=e,a.size,o.defaults.SOGoAlternateAvatar),r({method:"GET",url:i,cache:!0,headers:{Accept:"image/*"}}).then(function(){a.url||(a.url=i,a.urlEmail=n,c())},function(){l()}))):e||l()}),"sg-src"in t[0].attributes&&e.$watch(function(){return a.src},function(e){e&&(a.url=e,a.urlEmail=""+a.email,t.addClass("sg-avatar-image--zoomable"),i=function(){t.toggleClass("sg-avatar-image--zoom")},t.on("click",i),c())})}e.$inject=["$scope","$element","$http","$q","Preferences","Gravatar"],angular.module("SOGo.Common").directive("sgAvatarImage",function(){return{restrict:"AE",scope:{},bindToController:{size:"@",email:"=sgEmail",src:"=sgSrc"},transclude:!0,template:['<div class="sg-icon-badge-container">'," <md-icon ng-transclude></md-icon>",' <md-icon class="md-warn sg-icon--badge sg-icon--badge-bottom"',' style="display: none">not_interested</md-icon>',' <img class="ng-hide" ng-src="{{vm.url}}">',"</div>"].join(""),link:function(e,t,n,i){var r,o=t.find("img"),s=t.find("md-icon"),t=angular.element(s[0]),a=angular.element(s[1]);n.size&&(o.attr("width",n.size),o.attr("height",n.size),t.css("font-size",n.size+"px"),a.css("font-size",parseInt(.4*n.size)+"px"));angular.isDefined(n.ngDisabled)&&(r=e.$watch(n.ngDisabled,function(e){n.disabled&&a.css({display:"block"}),r()}));i.img=o,i.genericImg=t},controller:"sgAvatarImageController",controllerAs:"vm"}}).controller("sgAvatarImageController",e)}(),function(){"use strict";function e(e,l,c){return{link:function(e,t){var n=t[0].querySelector(".sg-button-toggle"),i=n.querySelector(".sg-icon-toggle"),r="md-rotate-180-ccw",o=t[0].querySelector(".sg-block-toggle"),s=!1;function a(){o.setAttribute("aria-hidden",!s),o.setAttribute("aria-expanded",s),s||(o.style.visibility="hidden")}n.classList.add("md-clickable"),angular.element(n).on("click",function(){(s=!s)?i.classList.add(r):i.classList.remove(r),s&&(o.style.visibility="visible"),c(function(){var e=s?o.scrollHeight:0;l(angular.element(o),{easing:"cubic-bezier(0.35, 0, 0.25, 1)",to:{height:e+"px"},duration:.75}).start().then(function(){a()})})}),a()}}}e.$inject=["$mdUtil","$animateCss","$$rAF"],angular.module("SOGo.Common").directive("sgBlockToggle",e)}(),function(){"use strict";function e(a,l,c,u){var d="sg-checked";return{restrict:"E",replace:!0,transclude:!0,require:"?ngModel",template:['<button class="md-button sg-checkmark" type="button">'," <md-icon>check</md-icon>"," <span ng-transclude></span","</button>"].join(""),compile:function(e,t){return e.on("click",function(e){this.hasAttribute("disabled")&&e.stopImmediatePropagation()}),function(e,n,t,i){var r=s(a,e,"sgTrueValue",t.sgTrueValue,!0),o=s(a,e,"sgFalseValue",t.sgFalseValue,!1);function s(e,t,n,i,r){if(angular.isDefined(i)){if(!(e=e(i)).constant)throw Error("Expected constant expression for `"+n+"`, but saw `"+i+"`.");return e(t)}return r}i=i||u.fakeNgModel(),c(n),l.expectWithText(n,"aria-label"),n.on("click",function(t){n[0].hasAttribute("disabled")||e.$apply(function(){var e=i.$viewValue==r?o:r;i.$setViewValue(e,t&&t.type),i.$render()})}),i.$render=function(){i.$viewValue==r?n.addClass(d):n.removeClass(d)}}}}}angular.module("SOGo.Common").directive("sgCheckmark",e),e.$inject=["$parse","$mdAria","$mdTheming","$mdUtil"]}(),function(){"use strict";function e(e,t,u,d){var h,m,g;function p(e){g=e,h.buttonIcon.css("color",g)}this.$onInit=function(){h=this,m=t.controller("ngModel")},this.$postLink=function(){this.buttonIcon=t.find("md-icon"),m.$render=function(){p(m.$viewValue)}},this.showPicker=function(e){for(var t=u.newPanelPosition().relativeTo(h.buttonIcon).addPanelPosition(u.xPosition.ALIGN_START,u.yPosition.ALIGN_TOPS),n=u.newPanelAnimation().openFrom(h.buttonIcon).duration(100).withAnimation(u.animation.FADE),i=[],r="",o=0;o<d.selection.length;o++){var s=d.selection[o],a=contrast(s),l=s==g;o%7==0&&(r.length&&i.push(r),r=""),r+="<span ",l&&(r+='class="selected" '),r+='style="background-color: '+s+'" ng-click="$menuCtrl.setColor($event, \''+s+"')\">",l&&(r+='<md-icon style="color: '+a+'">check</md-icon>'),r+="</span>"}e={attachTo:angular.element(document.body),bindToController:!0,controller:c,controllerAs:"$menuCtrl",position:t,animation:n,targetEvent:e,template:['<div class="sg-color-picker-panel" md-whiteframe="3">'," <div>"+i.join("</div><div>")+"</div>","</div>"].join(""),trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0};function c(e,t,n,i){this.setColor=function(e,t){e&&(_.forEach(e.currentTarget.parentElement.children,function(e){e.classList.remove("selected")}),e.currentTarget.classList.add("selected")),p(t),m.$setViewValue(t)}}u.open(e).then(function(e){e.panelEl.one("click",function(){e.close()})}),c.$inject=["mdPanelRef","$state","$mdDialog","User"]}}e.$inject=["$scope","$element","$mdPanel","sgColors"],angular.module("SOGo.Common").directive("sgColorPicker",function(){return{restrict:"E",require:"ngModel",template:[' <md-button class="md-icon-button"',' label:aria-label="Options"',' ng-click="$ctrl.showPicker($event)">'," <md-icon>format_color_fill</md-icon>"," </md-button>"].join(""),controller:e,controllerAs:"$ctrl"}})}(),function(){"use strict";function e(o){return{restrict:"A",link:function(t,n,i){var r=t.$watch(function(e){return e.$eval(i.sgCompile)},function(e){n.html(e),o(n.contents())(t),r()})}}}e.$inject=["$compile"],angular.module("SOGo.Common").directive("sgCompile",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgDatepickerReadonlyInput",function(){return{link:function(e,t,n,i){var r=e.$watch(function(){return t.find("input").eq(0)},function(e){e.length&&(r(),e.prop("disabled",!0),e.parent().addClass("sg-datepicker-readonly-input-container"))})},require:"mdDatepicker",restrict:"A"}})}(),function(){"use strict";function e(l,n,c,e,u){return{restrict:"A",link:function(i,r,o){var s;function a(e,t,n,i){if(this.$element=e,this.folder=t,this.dragStart=n,this.count=i,this.helper=c.find("sg-draggable-helper"),!this.helper)throw Error("sg-draggable requires a sg-draggable-helper element.");this.bindedOnDragDetect=angular.bind(this,this.onDragDetect),this.bindedOnDrag=angular.bind(this,this.onDrag),this.$element.on("mousedown",this.bindedOnDragDetect)}e(function(){var e=l(o.sgDraggable)(i),t=o.sgDragStart?l(o.sgDragStart):null,n=o.sgDragCount?l(o.sgDragCount):null;s=new a(r,e,t,n)}),i.$on("$destroy",function(){s.$destroy()}),a.prototype={dragHasStarted:!1,$destroy:function(){this.$element.off("mousedown",this.bindedOnDragDetect)},getDistanceFromStart:function(e){var t=this.startPosition.clientX-e.clientX,e=this.startPosition.clientY-e.clientY;return Math.sqrt(t*t+e*e)},onDragDetect:function(e){e.stopPropagation(),this.dragStart&&!this.dragStart(i)||(c.on("mousemove",this.bindedOnDrag),c.one("mouseup",angular.bind(this,this.onDragEnd)))},onDrag:function(e){var t;this.startPosition?!this.dragHasStarted&&10<this.getDistanceFromStart(e)&&(t=this.helper.find("sg-draggable-helper-counter"),this.dragHasStarted=!0,this.helper.removeClass("ng-hide"),this.count&&1<this.count(i)?t.text(this.count(i)).removeClass("ng-hide"):t.addClass("ng-hide"),u.debug("emit folder:dragstart"),n.$emit("folder:dragstart",this.folder)):this.startPosition={clientX:e.clientX,clientY:e.clientY},this.dragHasStarted&&(e.shiftKey||this.folder.isRemote?this.helper.addClass("sg-draggable-helper--copy"):this.helper.removeClass("sg-draggable-helper--copy"),this.helper.css({top:e.pageY+5+"px",left:e.pageX+5+"px"}))},onDragEnd:function(e){var t="move";this.startPosition=null,c.off("mousemove",this.bindedOnDrag),this.dragHasStarted&&((e.shiftKey||this.folder.isRemote)&&(t="copy"),u.debug("emit folder:dragend"),n.$emit("folder:dragend",this.folder,t),this.dragHasStarted=!1,this.helper.addClass("ng-hide"))}}}}}e.$inject=["$parse","$rootScope","$document","$timeout","$log"],angular.module("SOGo.Common").directive("sgDraggable",e)}(),function(){"use strict";function e(u,d,e,t,n){return{restrict:"A",link:function(i,r,e){var o,n,t,s,a=!1;if(!e.sgDrop)throw Error("sg-droppable requires a sg-drop action.");function l(e){a=!0,r.addClass("sg-droppable-over")}function c(e){a=!1,this.classList.remove("sg-droppable-over"),r.off("mousemove")}a=!1,n=u(e.sgDroppable),o=u(e.sgDrop),t=d.$on("folder:dragstart",function(e,t){n(i,{dragFolder:t})&&(r.on("mouseenter",l),r.on("mouseleave",c))}),s=d.$on("folder:dragend",function(e,t,n){r.off("mouseenter"),r.off("mouseleave"),a&&(angular.bind(r[0],c)(e),o(i,{dragFolder:t,dragMode:n}))}),i.$on("destroy",function(){t(),s()})}}}e.$inject=["$parse","$rootScope","$document","$timeout","$log"],angular.module("SOGo.Common").directive("sgDroppable",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgEnter",function(){return function(t,e,n){e.bind("keydown keypress",function(e){13===e.which&&(t.$apply(n.sgEnter),e.preventDefault())})}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgEscape",function(){return function(t,e,n){e.bind("keydown",function(e){27===e.keyCode&&t.$apply(n.sgEscape)})}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgFocusOn",function(){return function(e,n,i){e.$on("sgFocusOn",function(e,t){t===i.sgFocusOn&&(n[0].focus(),"function"==typeof n[0].select&&n[0].select())})}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgFolderStylesheet",function(){return{restrict:"E",require:"ngModel",scope:{ngModel:"="},replace:!0,bindToController:!0,controller:function(){this.contrast=contrast,this.transparent=function(e,t){e=hexToRgb(e);return["rgba("+e.r,e.g,e.b,t+")"].join(",")}},controllerAs:"cssCtrl",template:['<style type="text/css">'," .bg-folder{{ cssCtrl.ngModel.id }} {"," background-color: {{ cssCtrl.ngModel.color }} !important;"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .sg-event.bg-folder{{ cssCtrl.ngModel.id }} md-icon {"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," md-toolbar.bg-folder{{ cssCtrl.ngModel.id }} md-icon:not(.sg-icon-toolbar-bg) {"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .bg-folder{{ cssCtrl.ngModel.id }} label,"," .bg-folder{{ cssCtrl.ngModel.id }} .md-input {"," color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," opacity: 0.8;"," }"," .fg-folder{{ cssCtrl.ngModel.id }},"," .sg-event.fg-folder{{ cssCtrl.ngModel.id }} md-icon {"," color: {{ cssCtrl.ngModel.color }} !important;"," }"," .bdr-folder{{ cssCtrl.ngModel.id }} {"," border-color: {{ cssCtrl.ngModel.color }} !important;"," }"," .contrast-bdr-folder{{ cssCtrl.ngModel.id }} {"," border-color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .checkbox-folder{{ cssCtrl.ngModel.id }} .md-icon {"," background-color: {{ cssCtrl.ngModel.color }} !important;"," }"," .checkbox-folder{{ cssCtrl.ngModel.id }}.md-checked .md-icon:after {"," border-color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;"," }"," .md-switch-folder{{ cssCtrl.ngModel.id }}.md-checked .md-thumb {"," background-color: {{ cssCtrl.ngModel.color }} !important;"," }"," .md-switch-folder{{ cssCtrl.ngModel.id }}.md-checked .md-bar {",' background-color: {{ cssCtrl.transparent(cssCtrl.ngModel.color, "0.5") }} !important;'," }"," .md-switch-folder{{ cssCtrl.ngModel.id }} .md-bar {",' background-color: {{ cssCtrl.transparent(cssCtrl.ngModel.color, "0.3") }} !important;'," }","</style>"].join("")}})}(),function(){"use strict";function e(r,o,s){return{restrict:"A",link:function(e,t,n){var i=n.sgLabels,n=new o(r.activeUser("folderURL"),r.activeUser());_.includes(s.labels._loadedFrameworks,i)||n.post("labels",null,{framework:i}).then(function(e){var t=s.labels._loadedFrameworks;angular.extend(s.labels,e.labels),s.labels._loadedFrameworks=_.concat(s.labels._loadedFrameworks,t)})}}}e.$inject=["sgSettings","Resource","$window"],angular.module("SOGo.Common").directive("sgLabels",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgNoDirtyCheck",function(){return{restrict:"A",require:"ngModel",link:function(e,t,n,i){i&&i.$pristine&&!i.$dirty&&(i.$pristine=!1,i.$dirty=!0)}}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgPlaceholder",function(){return{restrict:"A",scope:{placeholder:"=sgPlaceholder"},link:function(e,t,n){e.$watch("placeholder",function(){t[0].placeholder=e.placeholder})}}})}(),function(){"use strict";function e(o){return{restrict:"E",scope:{text:"@",width:"@",height:"@"},link:function(e,t,n){var i=parseInt(e.width)||256,r=parseInt(e.height)||i,e="otpauth://totp/SOGo:"+o.activeUser("email")+"?secret="+e.text.replace(/=+$/,"")+"&issuer=SOGo";new QRCode(t[0],{text:e,width:i,height:r})}}}e.$inject=["sgSettings"],angular.module("SOGo.Common").directive("sgQrCode",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgResetOnDisabled",function(){return{link:function(e,t,n,i){var r=e.$watch(function(){return t.find("input").eq(0)},function(e){e.length&&(r(),i.$scope.$watch("ctrl.isDisabled",function(e){e&&i.ngModelCtrl.$invalid&&i.$scope.$emit("md-calendar-change",i.date)}))})},require:"mdDatepicker",restrict:"A"}})}(),function(){"use strict";function e(l,c){return{restrict:"A",compile:function(e,t){return function(e,n,t){for(var i,r,o=n.attr("sg-ripple-click"),s=n[0].parentNode;s&&s.id!=o;)s=s.parentNode;function a(e){var t;n[0].hasAttribute("disabled")||(t=e.pageX&&e.pageY?{left:e.pageX,top:e.pageY}:e.target.getBoundingClientRect(),r.classList.contains("ng-hide")?(angular.element(s).css({overflow:"hidden",position:"relative"}),angular.element(r).css({top:s.scrollTop+"px"}),c(function(){i.css({top:t.top-s.offsetTop+s.scrollTop+"px",left:t.left-s.offsetLeft+"px",height:"400vmin",width:"400vmin"}),r.classList.remove("ng-hide")})):(i.css({top:t.top-s.offsetTop+s.scrollTop+"px",left:t.left-s.offsetLeft+"px",height:"0px",width:"0px"}),r.classList.add("ng-hide"),c(function(){angular.element(s).css({overflow:"",position:""})},800)))}s?(r=s.querySelector("sg-ripple-content"))?((i=s.querySelector("sg-ripple"))?i=angular.element(i):(i=angular.element('<sg-ripple class="md-default-theme md-bg"></sg-ripple>'),s.appendChild(i[0]),r.classList.contains("ng-hide")||r.classList.add("ng-hide")),n.on("click",a),e.$on("$destroy",function(){n.off("click",a)})):l.error("sg-ripple-content not found inside #"+o):l.error("No parent element found with id "+o)}}}}angular.module("SOGo.Common").directive("sgRippleClick",e),e.$inject=["$log","$timeout"]}(),function(){"use strict";function e(l){return{restrict:"A",controller:"sgSearchController",controllerAs:"$sgSearchController",priority:1001,compile:function(e,t){e.find("md-input-container");var o=e.find("input"),n=e.find("md-select"),s=e.find("md-option"),a=e.find("md-button");o.attr("ng-model","$sgSearchController.searchText"),o.attr("ng-model-options","$sgSearchController.searchTextOptions"),o.attr("ng-change","$sgSearchController.onChange()"),n&&(n.attr("ng-model","$sgSearchController.searchField"),n.attr("ng-change","$sgSearchController.onChange()"));a&&a.attr("sg-search-cancel")?(a.attr("ng-click",a.attr("sg-search-cancel")),a.removeAttr("sg-search-cancel")):a=null;return function(e,t,n,i){var r=t.find("button");i.formName=t.attr("name"),i.inputName=o.attr("name"),i.allowDot=l(t.attr("sg-allow-dot"))(e),i.fields=l(t.attr("sg-search-fields"))(e),i.doSearch=l(t.attr("sg-search")),(t=_.find(s,function(e){return e.getAttribute("selected")}))&&(i.searchField=t.getAttribute("value")),a&&r&&r.on("click",i.cancelSearch)}}}}function t(e,i,t){var n,r=this;r.searchText=null,r.searchTextOptions={updateOn:"default blur",debounce:{default:300,blur:0}},t.attr("sg-search-fields")&&(n=i.$watch(r.fields,function(e){r.searchField=_.clone(r.fields),n()})),r.onChange=function(){var e=i[r.formName],t=e[r.inputName],n=t.$viewValue;(r.allowDot&&"."==n||e.$valid&&n)&&("."==n&&t.$setValidity("minlength",!0),r.doSearch(i,{searchText:n,searchField:r.searchField}))},r.cancelSearch=function(){r.searchText=null}}e.$inject=["$parse"],t.$inject=["$window","$scope","$element"],angular.module("SOGo.Common").controller("sgSearchController",t).directive("sgSearch",e).directive("sgSearch",function(){return{restrict:"A",priority:1e3,transclude:!0,compile:function(e,t){return function(e,t,n,i,r){r(function(e){t.append(e)})}}}})}(),function(){"use strict";angular.module("SOGo.Common").directive("sgSelectOnly",function(){return{link:function(n,e,t,i){var r=n.$watch(function(){return e.find("input").eq(0)},function(e){var t;e.length&&(r(),t=e.controller("ngModel"),e.on("blur",function(){i.scope.selectedItem||n.$applyAsync(t.$setValidity("required",!1))}))})},require:"mdAutocomplete",restrict:"A"}})}(),function(){"use strict";function e(e){return{restrict:"A",scope:{folderType:"@sgSubscribe",onFolderSelect:"&sgSubscribeOnSelect"},replace:!1,bindToController:!0,controller:n,controllerAs:"$sgSubscribeDialogController",link:t}}function t(e,t,n,i){t.find("input");t.on("click",i.showDialog)}function n(e){var t=this;t.showDialog=function(){e.show({templateUrl:"../Contacts/UIxContactsUserFolders",clickOutsideToClose:!0,locals:{folderType:t.folderType,onFolderSelect:t.onFolderSelect},controller:i,controllerAs:"subscribe"})}}function i(e,t,n,i){var r=this;r.selectedUser=null,r.users=[],r.folderType=t,r.searchTextOptions={updateOn:"default blur",debounce:{default:300,blur:0}},r.onChange=function(t){i.$filter(r.searchText,null,{results:r.users}).then(function(e){t.$setValidity("matches",0<e.length),t.$setTouched(),r.selectedUser&&_.isUndefined(_.find(e,function(e){return e.uid==r.selectedUser.uid}))&&(r.selectedUser=null)})},r.selectUser=function(e){r.selectedUser==r.users[e]?r.selectedUser=null:r.users[e].$folders(t).then(function(){r.selectedUser=r.users[e]})},r.selectFolder=function(e){n({folderData:e})},r.close=function(){i.$query=null,e.hide()}}e.$inject=["User"],n.$inject=["$mdDialog"],i.$inject=["$mdDialog","folderType","onFolderSelect","User"],angular.module("SOGo.Common").directive("sgSubscribe",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgTimePane",function(){return{template:['<div class="sg-time-pane">',' <div class="hours-pane">',' <div ng-repeat="hoursBigLine in hours" layout="row" layout-xs="column">',' <div ng-repeat="hoursLine in hoursBigLine" layout="row" class="hours">',' <md-button class="hourBtn sg-time-selection-indicator" id="{{hour.id}}"'," md-no-ink",' ng-repeat="hour in hoursLine"',' ng-click="hourClickHandler(hour.displayName)">{{hour.displayName}}</md-button>'," </div>"," </div>"," </div>",' <div class="min5" ng-show="is5min()">',' <div layout="row" layout-xs="column">',' <div ng-repeat="minutesLine in min5" layout="row">',' <md-button class="minuteBtn sg-time-selection-indicator" id="{{minute.id}}"'," md-no-ink",' ng-repeat="minute in minutesLine"',' ng-click="minuteClickHandler(minute.displayName)">{{minute.displayName}}</md-button>'," </div>"," </div>"," </div>",' <div class="sg-time-scroll-mask" ng-hide="is5min()">',' <div class="min1" layout="row" layout-xs="column" layout-wrap>',' <div ng-repeat="minutesLine in min1" layout="row" layout-align="space-around center">',' <md-button class="minuteBtn sg-time-selection-indicator" id="{{minute.id}}"'," md-no-ink",' ng-repeat="minute in minutesLine"',' ng-click="minuteClickHandler(minute.displayName)">{{minute.displayName}}</md-button>'," </div>"," </div>"," </div>",' <div flex layout="row" layout-align="center center" md-colors="::{background: \'default-background-200\'}">',' <md-button class="toggleBtn md-fab md-mini" ng-bind="getToggleBtnLbl()" ng-click="toggleManual5min()"></md-button>'," </div>","</div>"].join(""),scope:{},require:["ngModel","sgTimePane","?^mdInputContainer"],controller:e,controllerAs:"ctrl",bindToController:!0,link:function(e,t,n,i){var r=i[0],o=i[1];if(i[2])throw Error("sg-timepicker should not be placed inside md-input-container.");o.configureNgModel(r,o)}}});var g=0;function e(e,t,n,i,r,o,s,a,l){var c;o(e),this.$element=e,this.$scope=t,this.dateUtil=n,this.$mdUtil=i,this.keyCode=r.KEY_CODE,this.$$rAF=s,this.timePaneElement=e[0].querySelector(".sg-time-pane"),this.ngModelCtrl=null,this.SELECTED_TIME_CLASS="sg-time-selected",this.FOCUSED_TIME_CLASS="md-focus",this.id=g++,this.displayTime=null,this.selectedTime=null,this.isInitialized=!1,t.hours=[],t.hours[0]=[],t.hours[0][0]=[],t.hours[0][1]=[],t.hours[1]=[],t.hours[1][0]=[],t.hours[1][1]=[];for(var u=0;u<6;u++)t.hours[0][0][u]={id:"tp-"+this.id+"-hour-"+u,displayName:u<10?"0"+u:""+u,selected:!1},t.hours[0][1][u]={id:"tp-"+this.id+"-hour-"+(u+6),displayName:u+6<10?"0"+(u+6):""+(u+6),selected:!1},t.hours[1][0][u]={id:"tp-"+this.id+"-hour-"+(u+12),displayName:""+(u+12),selected:!1},t.hours[1][1][u]={id:"tp-"+this.id+"-hour-"+(u+18),displayName:""+(u+18),selected:!1};for(t.min5=[],t.min5[0]=[],t.min5[1]=[],u=0;u<6;u++)t.min5[0][u]={id:"tp-"+this.id+"-minute5-"+(c=5*u),displayName:c<10?":0"+c:":"+c,selected:!0},t.min5[1][u]={id:"tp-"+this.id+"-minute5-"+(c+30),displayName:":"+(c+30),selected:!1};for(t.min1=[],u=0;u<12;u++){t.min1[u]=[];for(var d=0;d<5;d++)t.min1[u][d]={id:"tp-"+this.id+"-minute-"+(c=5*u+d),displayName:c<10?":0"+c:":"+c,selected:!0}}t.show5min=!0,t.getToggleBtnLbl=function(){return t.is5min()?">>":"<<"},t.toggleManual5min=function(){t.manual5min=!t.is5min()},t.is5min=function(){return!0===t.manual5min||!1===t.manual5min?t.manual5min:t.show5min},a.tabindex||e.attr("tabindex","-1");var h=this;this.hourClickHandler=function(e){var t=new Date(h.displayTime);t.setHours(Number(e)),h.setNgModelValue(t,"hours")},t.hourClickHandler=this.hourClickHandler,this.minuteClickHandler=function(e){var t=e.substr(1),e=new Date(h.displayTime);e.setMinutes(Number(t)),h.setNgModelValue(e,"minutes")},t.minuteClickHandler=this.minuteClickHandler;var m=angular.bind(this,this.handleKeyEvent);angular.element(document.body).on("keydown",m),t.$on("$destroy",function(){angular.element(document.body).off("keydown",m)})}e.$inject=["$element","$scope","$$mdDateUtil","$mdUtil","$mdConstant","$mdTheming","$$rAF","$attrs","$mdDateLocale"],e.prototype.configureNgModel=function(e,t){var n=this;n.ngModelCtrl=e,n.$mdUtil.nextTick(function(){n.isInitialized=!0}),e.$render=function(){var e=this.$viewValue;n.$mdUtil.nextTick(function(){n.changeSelectedTime(e,t)})}},e.prototype.changeSelectedTime=function(e,t){var n,i,r=this.selectedTime;this.selectedTime=e,this.displayTime=new Date(e),r&&(i=r.getHours(),(i=document.getElementById("tp-"+t.id+"-hour-"+i))&&(i.classList.remove(this.SELECTED_TIME_CLASS),i.setAttribute("aria-selected","false")),i=r.getMinutes(),(r=document.getElementById("tp-"+t.id+"-minute-"+i))&&(r.classList.remove(this.SELECTED_TIME_CLASS),r.setAttribute("aria-selected","false")),(i=document.getElementById("tp-"+t.id+"-minute5-"+i))&&(i.classList.remove(this.SELECTED_TIME_CLASS),i.setAttribute("aria-selected","false"))),e&&(i=e.getHours(),(i=document.getElementById("tp-"+t.id+"-hour-"+i))&&(i.classList.add(this.SELECTED_TIME_CLASS),i.setAttribute("aria-selected","true")),(e=e.getMinutes())%5==0?(t.$scope.show5min=!0,(n=document.getElementById("tp-"+t.id+"-minute5-"+e))&&(n.classList.add(this.SELECTED_TIME_CLASS),n.setAttribute("aria-selected","true"))):t.$scope.show5min=!1,(n=document.getElementById("tp-"+t.id+"-minute-"+e))&&(n.classList.add(this.SELECTED_TIME_CLASS),n.setAttribute("aria-selected","true")))},e.prototype.setNgModelValue=function(e,t){return this.$scope.$emit("sg-time-pane-change",{date:e,changed:t}),this.ngModelCtrl.$setViewValue(e),this.ngModelCtrl.$render(),e},e.prototype.handleKeyEvent=function(e){var t=this;this.$scope.$apply(function(){return e.which==t.keyCode.ESCAPE||e.which==t.keyCode.TAB?(t.$scope.$emit("md-time-pane-close"),void(e.which==t.keyCode.TAB&&e.preventDefault())):void(e.which===t.keyCode.ENTER&&(t.setNgModelValue(t.displayTime,"enter"),e.preventDefault()))})},e.prototype.focus=function(e,t){var n=e||this.selectedTime||this.today,e=this.timePaneElement.querySelector(".md-focus");e&&e.classList.remove(this.FOCUSED_TIME_CLASS),n&&(n=n.getHours(),(n=document.getElementById("tp-"+t.id+"-hour-"+n))&&(n.classList.add(this.FOCUSED_TIME_CLASS),n.focus()))}}(),function(){"use strict";function e(u,d,h){return{template:function(e,t){t=t.ariaLabel||t.mdPlaceholder;return['<md-button class="sg-timepicker-button md-icon-button" type="button" ',' tabindex="-1" aria-hidden="true" ',' ng-click="ctrl.openTimePane($event)">',' <md-icon class="sg-timepicker-icon">access_time</md-icon>',"</md-button>",'<div class="md-default-theme sg-timepicker-input-container" '," ng-class=\"{'sg-timepicker-focused': ctrl.isFocused}\">",' <input class="sg-timepicker-input" ',t?'aria-label="'+t+'" ':"",' aria-haspopup="true"',' aria-expanded="{{ctrl.isTimeOpen}}" ',' aria-owns="{{::ctrl.timePaneId}}"',' ng-focus="ctrl.setFocused(true)" ng-blur="ctrl.setFocused(false)">',' <md-button type="button" md-no-ink ',' class="sg-timepicker-triangle-button md-icon-button" ',' ng-click="ctrl.openTimePane($event)" ',' aria-label="{{::ctrl.dateLocale.msgOpenCalendar}}">',' <div class="sg-timepicker-expand-triangle"></div>'," </md-button>","</div>",'<div class="sg-timepicker-time-pane md-whiteframe-z1" id="{{::ctrl.timePaneId}}">',' <div class="sg-timepicker-input-mask">',' <div class="sg-timepicker-input-mask-opaque"></div>'," </div>",' <div class="sg-timepicker-time">',' <sg-time-pane role="dialog" aria-label="{{::ctrl.dateLocale.msgCalendar}}" ',' ng-model="ctrl.time" ng-if="ctrl.isTimeOpen"></sg-time-pane>'," </div>","</div>"].join("")},require:["ngModel","sgTimepicker","?^mdInputContainer","?^form"],scope:{placeholder:"@mdPlaceholder"},controller:t,controllerAs:"ctrl",bindToController:!0,link:function(e,t,n,i){var r,o=i[0],s=i[1],a=i[2],l=i[3],c=u.parseAttributeBoolean(n.mdNoAsterisk);s.configureNgModel(o,a,h),a?((i=t[0].querySelector(".md-errors-spacer"))&&t.after(angular.element("<div>").append(i)),a.setHasPlaceholder(n.mdPlaceholder),a.input=t,a.element.addClass(m).toggleClass(g,"time"!==n.mdHideIcons&&"all"!==n.mdHideIcons),a.label?c||n.$observe("required",function(e){a.label.toggleClass("md-required",!!e)}):d.expect(t,"aria-label",n.mdPlaceholder),e.$watch(a.isErrorGetter||function(){return o.$invalid&&(o.$touched||l&&l.$submitted)},a.setInvalid)):l&&(r=e.$watch(function(){return l.$submitted},function(e){e&&(s.updateErrorState(),r())}))}}}angular.module("SOGo.Common").directive("sgTimepicker",e),e.$inject=["$mdUtil","$mdAria","inputDirective"];var i="sg-timepicker-invalid",c="sg-timepicker-open",m="_sg-timepicker-floating-label",g="_sg-timepicker-has-calendar-icon",u={MIN5:{GTXS:192,XS:311},MIN1:{GTXS:384,XS:474}},d={GTXS:530,XS:294},h=/ipad|iphone|ipod|android/i;function t(e,t,n,i,r,o,s,a,l,c,u){this.$window=i,this.dateLocale=a,this.dateUtil=l,this.$mdConstant=r,this.$mdUtil=s,this.$$rAF=c,this.$mdMedia=u,this.documentElement=angular.element(document.documentElement),this.ngModelCtrl=null,this.inputElement=t[0].querySelector("input"),this.ngInputElement=angular.element(this.inputElement),this.inputContainer=t[0].querySelector(".sg-timepicker-input-container"),this.timePane=t[0].querySelector(".sg-timepicker-time-pane"),this.timeButton=t[0].querySelector(".sg-timepicker-button"),this.inputMask=angular.element(t[0].querySelector(".sg-timepicker-input-mask-opaque")),this.$element=t,this.$attrs=n,this.$scope=e,this.time=null,this.isFocused=!1,this.isDisabled=!1,this.setDisabled(t[0].disabled||angular.isString(n.disabled)),this.isTimeOpen=!1,this.timePaneOpenedFrom=null,this.timePaneId="sg-time-pane"+s.nextUid(),this.bodyClickHandler=angular.bind(this,this.handleBodyClick),this.windowEventName=h.test(navigator.userAgent||navigator.vendor||window.opera)?"orientationchange":"resize",this.windowEventHandler=s.debounce(angular.bind(this,this.closeTimePane),100),this.windowBlurHandler=angular.bind(this,this.handleWindowBlur),this.leftMargin=20,this.topMargin=null,n.tabindex?(this.ngInputElement.attr("tabindex",n.tabindex),n.$set("tabindex",null)):n.$set("tabindex","-1"),o(t),o(angular.element(this.timePane));var d=this;e.$on("$destroy",function(){d.detachTimePane()}),n.mdIsOpen&&e.$watch("ctrl.isOpen",function(e){e?d.openTimePane({target:d.inputElement}):d.closeTimePane()})}t.$inject=["$scope","$element","$attrs","$window","$mdConstant","$mdTheming","$mdUtil","$mdDateLocale","$$mdDateUtil","$$rAF","$mdMedia"],t.prototype.$onInit=function(){this.installPropertyInterceptors(),this.attachChangeListeners(),this.attachInteractionListeners()},t.prototype.configureNgModel=function(e,t,n){this.ngModelCtrl=e,this.mdInputContainer=t,this.$attrs.$set("type","date");var i=this;i.ngModelCtrl.$formatters.push(function(e){if(e&&!(e instanceof Date))throw Error("The ng-model for sg-timepicker must be a Date instance. Currently the model is a: "+typeof e);return i.onExternalChange(e),e}),e.$viewChangeListeners.unshift(angular.bind(this,this.updateErrorState));e=i.$mdUtil.getModelOption(e,"updateOn");e&&this.ngInputElement.on(e,angular.bind(this.$element,this.$element.triggerHandler,e))},t.prototype.attachChangeListeners=function(){var i=this;i.$scope.$on("sg-time-pane-change",function(e,t){var n=new Date(t.date);i.setModelValue(n),i.onExternalChange(n),"minutes"==t.changed&&i.closeTimePane()}),i.ngInputElement.on("input",angular.bind(i,i.resizeInputElement));var e=angular.isDefined(this.debounceInterval)?this.debounceInterval:500;i.ngInputElement.on("input",i.$mdUtil.debounce(i.handleInputEvent,e,i))},t.prototype.attachInteractionListeners=function(){var t=this,n=this.$scope,i=this.$mdConstant.KEY_CODE;t.ngInputElement.on("keydown",function(e){e.altKey&&e.keyCode==i.DOWN_ARROW&&(t.openTimePane(e),n.$digest())}),n.$on("md-time-close",function(){t.closeTimePane()})},t.prototype.installPropertyInterceptors=function(){var e,t=this;!this.$attrs.ngDisabled||(e=this.$scope.$parent)&&e.$watch(this.$attrs.ngDisabled,function(e){t.setDisabled(e)}),Object.defineProperty(this,"placeholder",{get:function(){return t.inputElement.placeholder},set:function(e){t.inputElement.placeholder=e||""}})},t.prototype.setDisabled=function(e){this.isDisabled=e,this.inputElement.disabled=e,this.timeButton&&(this.timeButton.disabled=e)},t.prototype.updateErrorState=function(e){var t=e||this.time;this.clearErrorState(),this.dateUtil.isValidDate(t)||this.ngModelCtrl.$setValidity("valid",null===t);var n=this.inputElement.value,e=this.dateLocale.parseTime(n);!this.isInputValid(n,e)&&this.ngModelCtrl.$valid&&this.ngModelCtrl.$setValidity("valid",null==t),angular.element(this.inputContainer).toggleClass(i,!this.ngModelCtrl.$valid)},t.prototype.isInputValid=function(e,t){return""===e||this.dateUtil.isValidDate(t)},t.prototype.clearErrorState=function(){this.inputContainer.classList.remove(i),["valid"].forEach(function(e){this.ngModelCtrl.$setValidity(e,!0)},this)},t.prototype.resizeInputElement=function(){this.inputElement.size=this.inputElement.value.length+3},t.prototype.handleInputEvent=function(e){var t=this.inputElement.value,n=t?this.dateLocale.parseTime(t):null;this.isInputValid(t,n)&&(t=new Date(this.time),n?(t.setHours(n.getHours()),t.setMinutes(n.getMinutes())):t=null,this.setModelValue(t),this.time=t),this.updateErrorState(n)},t.prototype.attachTimePane=function(){var e=this.timePane,t=document.body;e.style.transform="",this.$element.addClass(c),angular.element(t).addClass("md-datepicker-is-showing");var n=this.inputContainer.getBoundingClientRect(),i=t.getBoundingClientRect();(!this.topMargin||this.topMargin<0)&&(this.topMargin=(this.inputMask.parent().prop("clientHeight")-this.ngInputElement.prop("clientHeight"))/2);var r=n.top-i.top-this.topMargin,o=n.left-i.left-this.leftMargin,s=i.top<0&&0===t.scrollTop?-i.top:document.body.scrollTop,a=i.left<0&&0===t.scrollLeft?-i.left:document.body.scrollLeft,t=s+this.$window.innerHeight,i=a+this.$window.innerWidth;this.inputMask.css({position:"absolute",left:this.leftMargin+"px",top:this.topMargin+"px",width:n.width-1+"px",height:n.height-2+"px"});n=this.$mdMedia("xs")?d.XS:d.GTXS;i<o+n&&(0<i-n?o=i-n:(o=a,l=this.$window.innerWidth/n,e.style.transform="scale("+l+")"),e.classList.add("sg-timepicker-pos-adjusted"));var l=this.time&&this.time.getMinutes()%5==0?"MIN5":"MIN1",l=this.$mdMedia("xs")?u[l].XS:u[l].GTXS;t<r+l&&s<t-l&&(r=t-l,e.classList.add("sg-timepicker-pos-adjusted")),e.style.left=o+"px",e.style.top=r+"px",document.body.appendChild(e),this.$$rAF(function(){e.classList.add("md-pane-open")})},t.prototype.detachTimePane=function(){this.$element.removeClass(c),angular.element(document.body).removeClass("md-datepicker-is-showing"),this.timePane.classList.remove("md-pane-open"),this.timePane.classList.remove("md-timepicker-pos-adjusted"),this.isTimeOpen&&this.$mdUtil.enableScrolling(),this.timePane.parentNode&&this.timePane.parentNode.removeChild(this.timePane)},t.prototype.openTimePane=function(e){var t;this.isTimeOpen||this.isDisabled||(this.isTimeOpen=!0,this.timePaneOpenedFrom=e.target,this.$mdUtil.disableScrollAround(this.timePane),this.attachTimePane(),this.evalAttr("ngFocus"),(t=this).$mdUtil.nextTick(function(){t.documentElement.on("click touchstart",t.bodyClickHandler)},!1),window.addEventListener(this.windowEventName,this.windowEventHandler))},t.prototype.closeTimePane=function(){var e;this.isTimeOpen&&((e=this).detachTimePane(),e.ngModelCtrl.$setTouched(),e.evalAttr("ngBlur"),e.documentElement.off("click touchstart",e.bodyClickHandler),window.removeEventListener(e.windowEventName,e.windowEventHandler),e.timePaneOpenedFrom.focus(),e.timePaneOpenedFrom=null,e.isTimeOpen=!1)},t.prototype.getTimePaneCtrl=function(){return angular.element(this.timePane.querySelector("sg-time-pane")).controller("sgTimePane")},t.prototype.focusTime=function(){var t=this;this.$mdUtil.nextTick(function(){var e=t.getTimePaneCtrl();t.getTimePaneCtrl().focus(null,e)},!1)},t.prototype.setFocused=function(e){e||this.ngModelCtrl.$setTouched(),this.evalAttr(e?"ngFocus":"ngBlur"),this.isFocused=e},t.prototype.handleBodyClick=function(e){this.isTimeOpen&&(this.$mdUtil.getClosest(e.target,"sg-time-pane")||this.closeTimePane(),this.$scope.$digest())},t.prototype.handleWindowBlur=function(){this.inputFocusedOnWindowBlur=document.activeElement===this.inputElement},t.prototype.evalAttr=function(e){this.$attrs[e]&&this.$scope.$parent.$eval(this.$attrs[e])},t.prototype.setModelValue=function(e){this.ngModelCtrl.$setViewValue(e)},t.prototype.onExternalChange=function(e){this.time=e,this.inputElement.value=this.dateLocale.formatTime(e),this.mdInputContainer&&this.mdInputContainer.setHasValue(!!e),this.resizeInputElement(),this.updateErrorState()}}(),function(){"use strict";function e(e,p,f){return{restrict:"A",require:["mdGridList","?ngModel"],compile:function(h,m){var g="md-default-theme md-accent md-bg md-bdr";return function(i,n,e,t){var r,o,s,a,l=h.find("md-grid-tile"),c=[],u=t[1]||p.fakeNgModel();for(u.$render=function(){var t=u.$viewValue;c=u.$viewValue,m.sgToggleGridAttr&&(s=m.sgToggleGridAttr,t=_.map(u.$viewValue,m.sgToggleGridAttr));_.forEach(l,function(e){e=angular.element(e);_.includes(t,e.attr("value"))&&e.addClass(g)}),u.$validate(),d(u.$invalid)},u.$isEmpty=function(e){return!e||0===e.length},a=function(){var e=angular.element(this),t=e.attr("value");e.toggleClass(g),function(t){var e=_.findIndex(c,function(e){return s?e[s]==t:e==t});{var n;e<0?s?((n={})[s]=t,c.push(n)):c.push(t):c.splice(e,1)}i.$apply(function(){u.$setViewValue(c),u.$setDirty(),u.$validate(),d(u.$invalid)})}(t)},o=0;o<l.length;o++)(r=angular.element(l[o])).addClass("sg-icon-button"),r.find("figure").addClass("md-icon"),r.on("click",a);function d(e){var t=n.parent().children()[0];e?(n.addClass("sg-toggle-grid-invalid"),"LABEL"==t.tagName&&(t.style.color=f.getThemeColor("warn"))):(n.removeClass("sg-toggle-grid-invalid"),"LABEL"==t.tagName&&(t.style.color=""))}}}}}e.$inject=["$parse","$mdUtil","$mdColors"],angular.module("SOGo.Common").directive("sgToggleGrid",e)}(),String.prototype.endsWith=function(e){return-1!==this.indexOf(e,this.length-e.length)},String.prototype.startsWith=function(e,t){return t=angular.isNumber(t)?t:0,this.lastIndexOf(e,t)===t},String.prototype.encodeEntities=function(){return this.replace(/&/g,"&amp;").replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,function(e){return"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";"}).replace(/([^#-~ |!])/g,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"&lt;").replace(/>/g,"&gt;")},String.prototype._base64_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",String.prototype.base64encode=function(){for(var e,t,n,i,r,o,s="",a=0,l=this.utf8encode();a<l.length;)n=(o=l.charCodeAt(a++))>>2,i=(3&o)<<4|(e=l.charCodeAt(a++))>>4,r=(15&e)<<2|(t=l.charCodeAt(a++))>>6,o=63&t,isNaN(e)?r=o=64:isNaN(t)&&(o=64),s=s+this._base64_keyStr.charAt(n)+this._base64_keyStr.charAt(i)+this._base64_keyStr.charAt(r)+this._base64_keyStr.charAt(o);return s},String.prototype.base64decode=function(){for(var e,t,n,i,r,o,s="",a=0,l=""+this;a<l.length;)n=this._base64_keyStr.indexOf(l.charAt(a++)),e=(15&(i=this._base64_keyStr.indexOf(l.charAt(a++))))<<4|(r=this._base64_keyStr.indexOf(l.charAt(a++)))>>2,t=(3&r)<<6|(o=this._base64_keyStr.indexOf(l.charAt(a++))),s+=String.fromCharCode(n<<2|i>>4),64!=r&&(s+=String.fromCharCode(e)),64!=o&&(s+=String.fromCharCode(t));return s},String.prototype.md5=function(){if(this.length)return function(e){function l(e,t){return e<<t|e>>>32-t}function c(e,t){var n=2147483648&e,i=2147483648&t,r=1073741824&e,o=1073741824&t,t=(1073741823&e)+(1073741823&t);return r&o?2147483648^t^n^i:r|o?1073741824&t?3221225472^t^n^i:1073741824^t^n^i:t^n^i}function t(e,t,n,i,r,o,s){var a;return e=c(e,c(c((a=t)&n|~a&i,r),s)),c(l(e,o),t)}function n(e,t,n,i,r,o,s){return e=c(e,c(c(t&(i=i)|n&~i,r),s)),c(l(e,o),t)}function i(e,t,n,i,r,o,s){return e=c(e,c(c(t^n^i,r),s)),c(l(e,o),t)}function r(e,t,n,i,r,o,s){return e=c(e,c(c(n^(t|~i),r),s)),c(l(e,o),t)}function o(e){for(var t="",n="",i=0;i<=3;i++)t+=(n="0"+(e>>>8*i&255).toString(16)).substr(n.length-2,2);return t}for(var s,a,u,d,h=Array(),h=function(e){for(var t,n=e.length,i=16*(1+((i=n+8)-i%64)/64),r=Array(i-1),o=0,s=0;s<n;)o=s%4*8,r[t=(s-s%4)/4]=r[t]|e.charCodeAt(s)<<o,s++;return r[t=(s-s%4)/4]=r[t]|128<<(o=s%4*8),r[i-2]=n<<3,r[i-1]=n>>>29,r}(e=function(e){e=e.replace(/rn/g,"n");for(var t="",n=0;n<e.length;n++){var i=e.charCodeAt(n);i<128?t+=String.fromCharCode(i):(127<i&&i<2048?t+=String.fromCharCode(i>>6|192):(t+=String.fromCharCode(i>>12|224),t+=String.fromCharCode(i>>6&63|128)),t+=String.fromCharCode(63&i|128))}return t}(e)),m=1732584193,g=4023233417,p=2562383102,f=271733878,y=0;y<h.length;y+=16)m=t(s=m,a=g,u=p,d=f,h[y+0],7,3614090360),f=t(f,m,g,p,h[y+1],12,3905402710),p=t(p,f,m,g,h[y+2],17,606105819),g=t(g,p,f,m,h[y+3],22,3250441966),m=t(m,g,p,f,h[y+4],7,4118548399),f=t(f,m,g,p,h[y+5],12,1200080426),p=t(p,f,m,g,h[y+6],17,2821735955),g=t(g,p,f,m,h[y+7],22,4249261313),m=t(m,g,p,f,h[y+8],7,1770035416),f=t(f,m,g,p,h[y+9],12,2336552879),p=t(p,f,m,g,h[y+10],17,4294925233),g=t(g,p,f,m,h[y+11],22,2304563134),m=t(m,g,p,f,h[y+12],7,1804603682),f=t(f,m,g,p,h[y+13],12,4254626195),p=t(p,f,m,g,h[y+14],17,2792965006),m=n(m,g=t(g,p,f,m,h[y+15],22,1236535329),p,f,h[y+1],5,4129170786),f=n(f,m,g,p,h[y+6],9,3225465664),p=n(p,f,m,g,h[y+11],14,643717713),g=n(g,p,f,m,h[y+0],20,3921069994),m=n(m,g,p,f,h[y+5],5,3593408605),f=n(f,m,g,p,h[y+10],9,38016083),p=n(p,f,m,g,h[y+15],14,3634488961),g=n(g,p,f,m,h[y+4],20,3889429448),m=n(m,g,p,f,h[y+9],5,568446438),f=n(f,m,g,p,h[y+14],9,3275163606),p=n(p,f,m,g,h[y+3],14,4107603335),g=n(g,p,f,m,h[y+8],20,1163531501),m=n(m,g,p,f,h[y+13],5,2850285829),f=n(f,m,g,p,h[y+2],9,4243563512),p=n(p,f,m,g,h[y+7],14,1735328473),m=i(m,g=n(g,p,f,m,h[y+12],20,2368359562),p,f,h[y+5],4,4294588738),f=i(f,m,g,p,h[y+8],11,2272392833),p=i(p,f,m,g,h[y+11],16,1839030562),g=i(g,p,f,m,h[y+14],23,4259657740),m=i(m,g,p,f,h[y+1],4,2763975236),f=i(f,m,g,p,h[y+4],11,1272893353),p=i(p,f,m,g,h[y+7],16,4139469664),g=i(g,p,f,m,h[y+10],23,3200236656),m=i(m,g,p,f,h[y+13],4,681279174),f=i(f,m,g,p,h[y+0],11,3936430074),p=i(p,f,m,g,h[y+3],16,3572445317),g=i(g,p,f,m,h[y+6],23,76029189),m=i(m,g,p,f,h[y+9],4,3654602809),f=i(f,m,g,p,h[y+12],11,3873151461),p=i(p,f,m,g,h[y+15],16,530742520),m=r(m,g=i(g,p,f,m,h[y+2],23,3299628645),p,f,h[y+0],6,4096336452),f=r(f,m,g,p,h[y+7],10,1126891415),p=r(p,f,m,g,h[y+14],15,2878612391),g=r(g,p,f,m,h[y+5],21,4237533241),m=r(m,g,p,f,h[y+12],6,1700485571),f=r(f,m,g,p,h[y+3],10,2399980690),p=r(p,f,m,g,h[y+10],15,4293915773),g=r(g,p,f,m,h[y+1],21,2240044497),m=r(m,g,p,f,h[y+8],6,1873313359),f=r(f,m,g,p,h[y+15],10,4264355552),p=r(p,f,m,g,h[y+6],15,2734768916),g=r(g,p,f,m,h[y+13],21,1309151649),m=r(m,g,p,f,h[y+4],6,4149444226),f=r(f,m,g,p,h[y+11],10,3174756917),p=r(p,f,m,g,h[y+2],15,718787259),g=r(g,p,f,m,h[y+9],21,3951481745),m=c(m,s),g=c(g,a),p=c(p,u),f=c(f,d);return(o(m)+o(g)+o(p)+o(f)).toLowerCase()}(this.toLowerCase())},String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)},String.prototype.asDate=function(){var e,t=this.split("/");return 3==t.length?e=new Date(t[2],t[1]-1,t[0]):3==(t=this.split("-")).length?e=new Date(t[0],t[1]-1,t[2]):8==this.length&&(e=new Date(this.substring(0,4),this.substring(4,6)-1,this.substring(6,8))),e},String.prototype.formatted=function(){for(var e=this,t=0;t<arguments.length;t++)e=e.replace("%{"+t+"}",arguments[t],"g");return e},String.prototype.isValidEmail=function(){return/^([\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.test(this)},String.prototype.asCSSIdentifier=function(){for(var e=["_","\\.","#","@","\\*",":",","," ","'","&","\\+"],t=["_U_","_D_","_H_","_A_","_S_","_C_","_CO_","_SP_","_SQ_","_AM_","_P_"],n=this,i=0;i<e.length;i++)var r=new RegExp(e[i],"g"),n=n.replace(r,t[i]);return n=n.replace(/[^\x00-\x7F]/g,""),n=/^\d+/.test(n)?"_"+n:n},String.prototype.timeInterval=function(){var e="once_per_hour"==this?3600:"every_minute"==this?60:60*parseInt(this.substr(6));return e},String.prototype.parseDate=function(t,e){for(var n,i,r=""+this,o=/%[dembByYHIMp]/g,s=new Date,a={year:s.getYear()+1900,month:s.getMonth(),day:s.getDate(),hour:0,minute:0},c={"%d":[/\d\d/,function(e){return a.day=parseInt(e),a.day<32}],"%e":[/ ?\d?\d/,function(e){return a.day=parseInt(e),a.day<32}],"%m":[/\d\d/,function(e){return a.month=parseInt(e)-1,a.month<12}],"%b":[/[^\d\s\.\/\-]{2,}/,function(e){e=_.indexOf(_.map(t.shortMonths,_.toLower),_.toLower(e));return 0<=e&&(a.month=e),0<=e}],"%B":[/[^\d\s\.\/\-]{2,}/,function(e){e=_.indexOf(_.map(t.months,_.toLower),_.toLower(e));return 0<=e&&(a.month=e),0<=e}],"%y":[/\d\d/,function(e){var t=parseInt(s.getFullYear().toString().substring(2))+50;return a.year=parseInt(e),a.year<t?a.year+=2e3:a.year+=1900,!0}],"%Y":[/[12]\d\d\d/,function(e){return a.year=parseInt(e),!0}],"%H":[/\d{1,2}/,function(e){return a.hour=parseInt(e),a.hour<24}],"%I":[/\d{1,2}/,function(e){return a.hour=parseInt(e),a.hour<=12}],"%M":[/[0-5]\d/,function(e){return a.minute=parseInt(e),a.minute<60}],"%p":[/[^\d\s\/\-]+/,function(e){var t=_.toLower(e),n=_.toLower(l("AM")),e=_.toLower(l("PM"));return t==e&&(a.hour+=12),t==n||t==e}]},u=e.match(o)||[],d=0,h=0;h<u.length;h++)n=u[h],(i=(r.match(c[n][0])||[])[0])&&(r=r.slice(r.indexOf(i)+i.length),c[n][1](i)&&d++);return u.length===d?new Date(a.year,a.month,a.day,a.hour,a.minute):new Date(NaN)},Date.prototype.clone=function(){var e=new Date;return e.setTime(this.getTime()),e},Date.prototype.daysUpTo=function(e){var t=[],n=this.getTime(),i=e.getTime();i<n&&(e=n,n=i,i=e);for(var r=Math.round((i-n)/9e7)+1,o=0;o<r;o++){var s=new Date;s.setTime(n+9e7*o),s.setHours(this.getHours()),s.setMinutes(this.getMinutes()),s.setSeconds(this.getSeconds()),s.setMilliseconds(this.getMilliseconds()),t.push(s)}return t},Date.prototype.minutesTo=function(e){return Math.floor(e.valueOf()-this.valueOf())/1e3/60-(e.getTimezoneOffset()-this.getTimezoneOffset())},Date.prototype.stringWithSeparator=function(e){var t=""+(this.getMonth()+1),n=""+this.getDate(),i=this.getYear();return i<1e3&&(i=""+(i+1900)),1==t.length&&(t="0"+t),1==n.length&&(n="0"+n),str="-"==e?i+"-"+t+"-"+n:n+"/"+t+"/"+i,str},Date.prototype.addDays=function(e){var t=this.getTime(),n=new Date(t);return this.setTime(t+=864e5*e),0!=(n=this.getTimezoneOffset()-n.getTimezoneOffset())&&(t=this.getTime()+60*n*1e3,this.setTime(t)),this},Date.prototype.addHours=function(e){var t=this.getTime();this.setTime(t+=36e5*e)},Date.prototype.addMinutes=function(e){var t=this.getTime();this.setTime(t+=6e4*e)},Date.prototype.beginOfDay=function(){var e=new Date(this.getTime());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),e},Date.prototype.dayOfWeek=function(e){var t=e.firstDayOfWeek,e=this.getDay();return e<t&&(e+=7),e-t},Date.prototype.firstWeekOfYearForDate=function(e){var t,n=e.firstWeekOfYear,i=new Date(this.getTime());return i.setMonth(0),i.setDate(1),t=i.dayOfWeek(e),("First4DayWeek"==n?t<4?i:i.addDays(7):"FirstFullWeek"!=n||0===t?i:i.addDays(7)).beginOfWeek(e.firstDayOfWeek)},Date.prototype.getWeek=function(e){var t,n=new Date(this.getTime());return n.addDays(6),(t=n.firstWeekOfYearForDate(e)).getTime()<n.getTime()?1+Math.floor((n.getTime()-t.getTime())/6048e5):((n=new Date(n.getTime())).addDays(-7),t=n.firstWeekOfYearForDate(e),2+Math.floor((n.getTime()-t.getTime())/6048e5))},Date.prototype.beginOfWeek=function(e){var t=e-this.getDay();0<t&&(t-=7);e=this.beginOfDay();return e.setHours(12),e.addDays(t),e},Date.prototype.endOfWeek=function(e){e=this.beginOfWeek(e);return e.addDays(6),e.setHours(23),e.setMinutes(59),e.setSeconds(59),e.setMilliseconds(999),e},Date.prototype.getDayString=function(){var e=this.getYear();e<1e3&&(e+=1900);var t=""+(this.getMonth()+1);e+=t=1==t.length?"0"+t:t;t=""+this.getDate();return e+=t=1==t.length?"0"+t:t},Date.prototype.getHourString=function(){var e=this.getHours()+"00";return e=3==e.length?"0"+e:e},Date.prototype.format=function(e,t){var n,i,r,o,s=[],a=/%[deaAmbByYUHIMp]/g,c={"%d":this.getDate(),"%e":this.getDate(),"%a":e.shortDays[this.getDay()],"%A":e.days[this.getDay()],"%m":this.getMonth()+1,"%b":e.shortMonths[this.getMonth()],"%B":e.months[this.getMonth()],"%y":this.getFullYear().toString().substring(2),"%Y":this.getFullYear(),"%U":this.getWeek(e),"%H":this.getHours(),"%M":this.getMinutes()};for(c["%I"]=12<c["%H"]?c["%H"]%12:c["%H"],c["%p"]=c["%H"]<12?l("AM"):l("PM"),c["%d"]=(c["%d"]<10?"0":"")+c["%d"],c["%e"]=(c["%e"]<10?" ":"")+c["%e"],c["%m"]=(c["%m"]<10?"0":"")+c["%m"],c["%H"]=(c["%H"]<10?"0":"")+c["%H"],c["%I"]=(c["%I"]<10?"0":"")+c["%I"],c["%M"]=(c["%M"]<10?"0":"")+c["%M"],n=t.replace(a,"\0").split("\0"),r=0,o=(i=t.match(a)).length;r<=o;r++)n.length&&s.push(n.shift()),s.push(c[i[r]]);return s.join("")},Element.prototype.setCaretTo=function(e){var t;this.setSelectionRange?(this.focus(),this.setSelectionRange(e,e)):this.createTextRange&&((t=this.createTextRange()).move("character",e),t.select())},Element.prototype.selectText=function(e,t){var n;this.setSelectionRange?this.setSelectionRange(e,t):this.createTextRange?((n=this.createTextRange()).moveStart("character",e),n.moveEnd("character",t-element.value.length),n.select()):this.select()};
//# sourceMappingURL=Common.js.map